@fluidframework/sequence 2.0.0-dev.5.3.2.178189 → 2.0.0-dev.6.4.0.191457
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 +114 -0
- package/README.md +4 -3
- package/dist/defaultMap.d.ts +1 -1
- package/dist/defaultMap.d.ts.map +1 -1
- package/dist/defaultMap.js +9 -10
- package/dist/defaultMap.js.map +1 -1
- package/dist/defaultMapInterfaces.d.ts +1 -1
- package/dist/defaultMapInterfaces.d.ts.map +1 -1
- package/dist/defaultMapInterfaces.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -1
- package/dist/intervalCollection.d.ts +11 -424
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +74 -815
- package/dist/intervalCollection.js.map +1 -1
- package/dist/intervalIndex/endpointInRangeIndex.d.ts +20 -0
- package/dist/intervalIndex/endpointInRangeIndex.d.ts.map +1 -0
- package/dist/intervalIndex/endpointInRangeIndex.js +60 -0
- package/dist/intervalIndex/endpointInRangeIndex.js.map +1 -0
- package/dist/intervalIndex/endpointIndex.d.ts +21 -0
- package/dist/intervalIndex/endpointIndex.d.ts.map +1 -0
- package/dist/intervalIndex/endpointIndex.js +42 -0
- package/dist/intervalIndex/endpointIndex.js.map +1 -0
- package/dist/intervalIndex/idIntervalIndex.d.ts +12 -0
- package/dist/intervalIndex/idIntervalIndex.d.ts.map +1 -0
- package/dist/intervalIndex/idIntervalIndex.js +41 -0
- package/dist/intervalIndex/idIntervalIndex.js.map +1 -0
- package/dist/intervalIndex/index.d.ts +5 -0
- package/dist/intervalIndex/index.d.ts.map +1 -1
- package/dist/intervalIndex/index.js +9 -1
- package/dist/intervalIndex/index.js.map +1 -1
- package/dist/intervalIndex/intervalIndex.d.ts +29 -0
- package/dist/intervalIndex/intervalIndex.d.ts.map +1 -0
- package/dist/intervalIndex/intervalIndex.js +7 -0
- package/dist/intervalIndex/intervalIndex.js.map +1 -0
- package/dist/intervalIndex/intervalIndexUtils.d.ts +17 -0
- package/dist/intervalIndex/intervalIndexUtils.d.ts.map +1 -0
- package/dist/intervalIndex/intervalIndexUtils.js +22 -0
- package/dist/intervalIndex/intervalIndexUtils.js.map +1 -0
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +2 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.js +3 -3
- package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js +5 -5
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
- package/dist/intervalIndex/sequenceIntervalIndexes.d.ts +1 -1
- package/dist/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
- package/dist/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
- package/dist/intervalIndex/startpointInRangeIndex.d.ts +20 -0
- package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -0
- package/dist/intervalIndex/startpointInRangeIndex.js +62 -0
- package/dist/intervalIndex/startpointInRangeIndex.js.map +1 -0
- package/dist/intervalTree.d.ts +2 -56
- package/dist/intervalTree.d.ts.map +1 -1
- package/dist/intervalTree.js +2 -11
- package/dist/intervalTree.js.map +1 -1
- package/dist/intervals/index.d.ts +8 -0
- package/dist/intervals/index.d.ts.map +1 -0
- package/dist/intervals/index.js +23 -0
- package/dist/intervals/index.js.map +1 -0
- package/dist/intervals/interval.d.ts +88 -0
- package/dist/intervals/interval.d.ts.map +1 -0
- package/dist/intervals/interval.js +180 -0
- package/dist/intervals/interval.js.map +1 -0
- package/dist/intervals/intervalUtils.d.ts +200 -0
- package/dist/intervals/intervalUtils.d.ts.map +1 -0
- package/dist/intervals/intervalUtils.js +79 -0
- package/dist/intervals/intervalUtils.js.map +1 -0
- package/dist/intervals/sequenceInterval.d.ts +132 -0
- package/dist/intervals/sequenceInterval.d.ts.map +1 -0
- package/dist/intervals/sequenceInterval.js +313 -0
- package/dist/intervals/sequenceInterval.js.map +1 -0
- 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 +1 -1
- package/dist/revertibles.d.ts.map +1 -1
- package/dist/revertibles.js +45 -52
- package/dist/revertibles.js.map +1 -1
- package/dist/sequence.d.ts +33 -4
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +91 -47
- package/dist/sequence.js.map +1 -1
- package/dist/sequenceDeltaEvent.d.ts +8 -3
- package/dist/sequenceDeltaEvent.d.ts.map +1 -1
- package/dist/sequenceDeltaEvent.js +3 -4
- package/dist/sequenceDeltaEvent.js.map +1 -1
- package/dist/sharedIntervalCollection.d.ts +2 -1
- package/dist/sharedIntervalCollection.d.ts.map +1 -1
- package/dist/sharedIntervalCollection.js +2 -2
- package/dist/sharedIntervalCollection.js.map +1 -1
- package/dist/sharedSequence.d.ts +9 -0
- package/dist/sharedSequence.d.ts.map +1 -1
- package/dist/sharedSequence.js +9 -6
- package/dist/sharedSequence.js.map +1 -1
- package/dist/sharedString.d.ts.map +1 -1
- package/dist/sharedString.js +9 -29
- package/dist/sharedString.js.map +1 -1
- package/lib/defaultMap.d.ts +1 -1
- package/lib/defaultMap.d.ts.map +1 -1
- package/lib/defaultMap.js +5 -6
- package/lib/defaultMap.js.map +1 -1
- package/lib/defaultMapInterfaces.d.ts +1 -1
- package/lib/defaultMapInterfaces.d.ts.map +1 -1
- package/lib/defaultMapInterfaces.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -2
- package/lib/index.js.map +1 -1
- package/lib/intervalCollection.d.ts +11 -424
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +43 -776
- package/lib/intervalCollection.js.map +1 -1
- package/lib/intervalIndex/endpointInRangeIndex.d.ts +20 -0
- package/lib/intervalIndex/endpointInRangeIndex.d.ts.map +1 -0
- package/lib/intervalIndex/endpointInRangeIndex.js +56 -0
- package/lib/intervalIndex/endpointInRangeIndex.js.map +1 -0
- package/lib/intervalIndex/endpointIndex.d.ts +21 -0
- package/lib/intervalIndex/endpointIndex.d.ts.map +1 -0
- package/lib/intervalIndex/endpointIndex.js +38 -0
- package/lib/intervalIndex/endpointIndex.js.map +1 -0
- package/lib/intervalIndex/idIntervalIndex.d.ts +12 -0
- package/lib/intervalIndex/idIntervalIndex.d.ts.map +1 -0
- package/lib/intervalIndex/idIntervalIndex.js +37 -0
- package/lib/intervalIndex/idIntervalIndex.js.map +1 -0
- package/lib/intervalIndex/index.d.ts +5 -0
- package/lib/intervalIndex/index.d.ts.map +1 -1
- package/lib/intervalIndex/index.js +4 -0
- package/lib/intervalIndex/index.js.map +1 -1
- package/lib/intervalIndex/intervalIndex.d.ts +29 -0
- package/lib/intervalIndex/intervalIndex.d.ts.map +1 -0
- package/lib/intervalIndex/intervalIndex.js +6 -0
- package/lib/intervalIndex/intervalIndex.js.map +1 -0
- package/lib/intervalIndex/intervalIndexUtils.d.ts +17 -0
- package/lib/intervalIndex/intervalIndexUtils.d.ts.map +1 -0
- package/lib/intervalIndex/intervalIndexUtils.js +18 -0
- package/lib/intervalIndex/intervalIndexUtils.js.map +1 -0
- package/lib/intervalIndex/overlappingIntervalsIndex.d.ts +2 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.js +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js +1 -1
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.d.ts +1 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
- package/lib/intervalIndex/startpointInRangeIndex.d.ts +20 -0
- package/lib/intervalIndex/startpointInRangeIndex.d.ts.map +1 -0
- package/lib/intervalIndex/startpointInRangeIndex.js +58 -0
- package/lib/intervalIndex/startpointInRangeIndex.js.map +1 -0
- package/lib/intervalTree.d.ts +2 -56
- package/lib/intervalTree.d.ts.map +1 -1
- package/lib/intervalTree.js +2 -11
- package/lib/intervalTree.js.map +1 -1
- package/lib/intervals/index.d.ts +8 -0
- package/lib/intervals/index.d.ts.map +1 -0
- package/lib/intervals/index.js +8 -0
- package/lib/intervals/index.js.map +1 -0
- package/lib/intervals/interval.d.ts +88 -0
- package/lib/intervals/interval.d.ts.map +1 -0
- package/lib/intervals/interval.js +175 -0
- package/lib/intervals/interval.js.map +1 -0
- package/lib/intervals/intervalUtils.d.ts +200 -0
- package/lib/intervals/intervalUtils.d.ts.map +1 -0
- package/lib/intervals/intervalUtils.js +74 -0
- package/lib/intervals/intervalUtils.js.map +1 -0
- package/lib/intervals/sequenceInterval.d.ts +132 -0
- package/lib/intervals/sequenceInterval.d.ts.map +1 -0
- package/lib/intervals/sequenceInterval.js +305 -0
- package/lib/intervals/sequenceInterval.js.map +1 -0
- 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 +1 -1
- package/lib/revertibles.d.ts.map +1 -1
- package/lib/revertibles.js +28 -35
- package/lib/revertibles.js.map +1 -1
- package/lib/sequence.d.ts +33 -4
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +86 -41
- package/lib/sequence.js.map +1 -1
- package/lib/sequenceDeltaEvent.d.ts +8 -3
- package/lib/sequenceDeltaEvent.d.ts.map +1 -1
- package/lib/sequenceDeltaEvent.js +2 -3
- package/lib/sequenceDeltaEvent.js.map +1 -1
- package/lib/sharedIntervalCollection.d.ts +2 -1
- package/lib/sharedIntervalCollection.d.ts.map +1 -1
- package/lib/sharedIntervalCollection.js +1 -1
- package/lib/sharedIntervalCollection.js.map +1 -1
- package/lib/sharedSequence.d.ts +9 -0
- package/lib/sharedSequence.d.ts.map +1 -1
- package/lib/sharedSequence.js +8 -5
- package/lib/sharedSequence.js.map +1 -1
- package/lib/sharedString.d.ts.map +1 -1
- package/lib/sharedString.js +9 -29
- package/lib/sharedString.js.map +1 -1
- package/package.json +29 -32
- package/src/defaultMap.ts +2 -1
- package/src/defaultMapInterfaces.ts +1 -1
- package/src/index.ts +18 -12
- package/src/intervalCollection.ts +42 -1225
- package/src/intervalIndex/endpointInRangeIndex.ts +104 -0
- package/src/intervalIndex/endpointIndex.ts +78 -0
- package/src/intervalIndex/idIntervalIndex.ts +58 -0
- package/src/intervalIndex/index.ts +5 -0
- package/src/intervalIndex/intervalIndex.ts +31 -0
- package/src/intervalIndex/intervalIndexUtils.ts +27 -0
- package/src/intervalIndex/overlappingIntervalsIndex.ts +2 -6
- package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +1 -1
- package/src/intervalIndex/sequenceIntervalIndexes.ts +1 -1
- package/src/intervalIndex/startpointInRangeIndex.ts +109 -0
- package/src/intervalTree.ts +3 -75
- package/src/intervals/index.ts +25 -0
- package/src/intervals/interval.ts +230 -0
- package/src/intervals/intervalUtils.ts +256 -0
- package/src/intervals/sequenceInterval.ts +494 -0
- package/src/packageVersion.ts +1 -1
- package/src/revertibles.ts +24 -13
- package/src/sequence.ts +100 -35
- package/src/sequenceDeltaEvent.ts +12 -4
- package/src/sharedIntervalCollection.ts +2 -3
- package/src/sharedSequence.ts +11 -5
- package/src/sharedString.ts +8 -25
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { Client, PropertiesManager, PropertySet, SlidingPreference } from "@fluidframework/merge-tree";
|
|
6
|
+
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
7
|
+
/**
|
|
8
|
+
* Basic interval abstraction
|
|
9
|
+
*/
|
|
10
|
+
export interface IInterval {
|
|
11
|
+
/**
|
|
12
|
+
* @returns a new interval object with identical semantics.
|
|
13
|
+
*/
|
|
14
|
+
clone(): IInterval;
|
|
15
|
+
/**
|
|
16
|
+
* Compares this interval to `b` with standard comparator semantics:
|
|
17
|
+
* - returns -1 if this is less than `b`
|
|
18
|
+
* - returns 1 if this is greater than `b`
|
|
19
|
+
* - returns 0 if this is equivalent to `b`
|
|
20
|
+
* @param b - Interval to compare against
|
|
21
|
+
*/
|
|
22
|
+
compare(b: IInterval): number;
|
|
23
|
+
/**
|
|
24
|
+
* Compares the start endpoint of this interval to `b`'s start endpoint.
|
|
25
|
+
* Standard comparator semantics apply.
|
|
26
|
+
* @param b - Interval to compare against
|
|
27
|
+
*/
|
|
28
|
+
compareStart(b: IInterval): number;
|
|
29
|
+
/**
|
|
30
|
+
* Compares the end endpoint of this interval to `b`'s end endpoint.
|
|
31
|
+
* Standard comparator semantics apply.
|
|
32
|
+
* @param b - Interval to compare against
|
|
33
|
+
*/
|
|
34
|
+
compareEnd(b: IInterval): number;
|
|
35
|
+
/**
|
|
36
|
+
* Modifies one or more of the endpoints of this interval, returning a new interval representing the result.
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
modify(label: string, start: number | undefined, end: number | undefined, op?: ISequencedDocumentMessage, localSeq?: number): IInterval | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* @returns whether this interval overlaps with `b`.
|
|
42
|
+
* Intervals are considered to overlap if their intersection is non-empty.
|
|
43
|
+
*/
|
|
44
|
+
overlaps(b: IInterval): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Unions this interval with `b`, returning a new interval.
|
|
47
|
+
* The union operates as a convex hull, i.e. if the two intervals are disjoint, the return value includes
|
|
48
|
+
* intermediate values between the two intervals.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
union(b: IInterval): IInterval;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Values are used in persisted formats (ops) and revertibles.
|
|
55
|
+
* @alpha
|
|
56
|
+
*/
|
|
57
|
+
export declare const IntervalOpType: {
|
|
58
|
+
readonly ADD: "add";
|
|
59
|
+
readonly DELETE: "delete";
|
|
60
|
+
readonly CHANGE: "change";
|
|
61
|
+
readonly PROPERTY_CHANGED: "propertyChanged";
|
|
62
|
+
readonly POSITION_REMOVE: "positionRemove";
|
|
63
|
+
};
|
|
64
|
+
export declare enum IntervalType {
|
|
65
|
+
Simple = 0,
|
|
66
|
+
Nest = 1,
|
|
67
|
+
/**
|
|
68
|
+
* SlideOnRemove indicates that the ends of the interval will slide if the segment
|
|
69
|
+
* they reference is removed and acked.
|
|
70
|
+
* See `packages\dds\merge-tree\docs\REFERENCEPOSITIONS.md` for details
|
|
71
|
+
* SlideOnRemove is the default interval behavior and does not need to be specified.
|
|
72
|
+
*/
|
|
73
|
+
SlideOnRemove = 2,
|
|
74
|
+
/**
|
|
75
|
+
* A temporary interval, used internally
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
Transient = 4
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Serialized object representation of an interval.
|
|
82
|
+
* This representation is used for ops that create or change intervals.
|
|
83
|
+
* @internal
|
|
84
|
+
*/
|
|
85
|
+
export interface ISerializedInterval {
|
|
86
|
+
/**
|
|
87
|
+
* Sequence number at which `start` and `end` should be interpreted
|
|
88
|
+
*
|
|
89
|
+
* @remarks It's unclear that this is necessary to store here.
|
|
90
|
+
* This should just be the refSeq on the op that modified the interval, which should be available via other means.
|
|
91
|
+
* At the time of writing, it's not plumbed through to the reconnect/rebase code, however, which does need it.
|
|
92
|
+
*/
|
|
93
|
+
sequenceNumber: number;
|
|
94
|
+
/** Start position of the interval */
|
|
95
|
+
start: number;
|
|
96
|
+
/** End position of the interval */
|
|
97
|
+
end: number;
|
|
98
|
+
/** Interval type to create */
|
|
99
|
+
intervalType: IntervalType;
|
|
100
|
+
stickiness?: IntervalStickiness;
|
|
101
|
+
/** Any properties the interval has */
|
|
102
|
+
properties?: PropertySet;
|
|
103
|
+
}
|
|
104
|
+
export interface ISerializableInterval extends IInterval {
|
|
105
|
+
/** Serializable bag of properties associated with the interval. */
|
|
106
|
+
properties: PropertySet;
|
|
107
|
+
/** @internal */
|
|
108
|
+
propertyManager: PropertiesManager;
|
|
109
|
+
/** @internal */
|
|
110
|
+
serialize(): ISerializedInterval;
|
|
111
|
+
/** @internal */
|
|
112
|
+
addProperties(props: PropertySet, collaborating?: boolean, seq?: number): PropertySet | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* Gets the id associated with this interval.
|
|
115
|
+
* When the interval is used as part of an interval collection, this id can be used to modify or remove the
|
|
116
|
+
* interval.
|
|
117
|
+
* @remarks This signature includes `undefined` strictly for backwards-compatibility reasons, as older versions
|
|
118
|
+
* of Fluid didn't always write interval ids.
|
|
119
|
+
*/
|
|
120
|
+
getIntervalId(): string | undefined;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Represents a change that should be applied to an existing interval.
|
|
124
|
+
* Changes can modify any of start/end/properties, with `undefined` signifying no change should be made.
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
export declare type SerializedIntervalDelta = Omit<ISerializedInterval, "start" | "end" | "properties"> & Partial<Pick<ISerializedInterval, "start" | "end" | "properties">>;
|
|
128
|
+
/**
|
|
129
|
+
* A size optimization to avoid redundantly storing keys when serializing intervals
|
|
130
|
+
* as JSON for summaries.
|
|
131
|
+
*
|
|
132
|
+
* Intervals are of the format:
|
|
133
|
+
*
|
|
134
|
+
* [start, end, sequenceNumber, intervalType, properties, stickiness?]
|
|
135
|
+
*/
|
|
136
|
+
export declare type CompressedSerializedInterval = [number, number, number, IntervalType, PropertySet, IntervalStickiness] | [number, number, number, IntervalType, PropertySet];
|
|
137
|
+
/**
|
|
138
|
+
* @sealed
|
|
139
|
+
*/
|
|
140
|
+
export interface IIntervalHelpers<TInterval extends ISerializableInterval> {
|
|
141
|
+
/**
|
|
142
|
+
* @deprecated Use the method `IInterval.compareEnd` instead
|
|
143
|
+
*/
|
|
144
|
+
compareEnds(a: TInterval, b: TInterval): number;
|
|
145
|
+
/**
|
|
146
|
+
* @deprecated Use the method `IInterval.compareStart` instead
|
|
147
|
+
*/
|
|
148
|
+
compareStarts?(a: TInterval, b: TInterval): number;
|
|
149
|
+
/**
|
|
150
|
+
*
|
|
151
|
+
* @param label - label of the interval collection this interval is being added to. This parameter is
|
|
152
|
+
* irrelevant for transient intervals.
|
|
153
|
+
* @param start - numerical start position of the interval
|
|
154
|
+
* @param end - numerical end position of the interval
|
|
155
|
+
* @param client - client creating the interval
|
|
156
|
+
* @param intervalType - Type of interval to create. Default is SlideOnRemove
|
|
157
|
+
* @param op - If this create came from a remote client, op that created it. Default is undefined (i.e. local)
|
|
158
|
+
* @param fromSnapshot - If this create came from loading a snapshot. Default is false.
|
|
159
|
+
* @param stickiness - {@link (IntervalStickiness:type)} to apply to the added interval.
|
|
160
|
+
*/
|
|
161
|
+
create(label: string, start: number | undefined, end: number | undefined, client: Client | undefined, intervalType: IntervalType, op?: ISequencedDocumentMessage, fromSnapshot?: boolean, stickiness?: IntervalStickiness): TInterval;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Determines how an interval should expand when segments are inserted adjacent
|
|
165
|
+
* to the range it spans
|
|
166
|
+
*
|
|
167
|
+
* Note that interval stickiness is currently an experimental feature and must
|
|
168
|
+
* be explicitly enabled with the `intervalStickinessEnabled` flag
|
|
169
|
+
*/
|
|
170
|
+
export declare const IntervalStickiness: {
|
|
171
|
+
/**
|
|
172
|
+
* Interval does not expand to include adjacent segments
|
|
173
|
+
*/
|
|
174
|
+
readonly NONE: 0;
|
|
175
|
+
/**
|
|
176
|
+
* Interval expands to include segments inserted adjacent to the start
|
|
177
|
+
*/
|
|
178
|
+
readonly START: 1;
|
|
179
|
+
/**
|
|
180
|
+
* Interval expands to include segments inserted adjacent to the end
|
|
181
|
+
*
|
|
182
|
+
* This is the default stickiness
|
|
183
|
+
*/
|
|
184
|
+
readonly END: 2;
|
|
185
|
+
/**
|
|
186
|
+
* Interval expands to include all segments inserted adjacent to it
|
|
187
|
+
*/
|
|
188
|
+
readonly FULL: 3;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Determines how an interval should expand when segments are inserted adjacent
|
|
192
|
+
* to the range it spans
|
|
193
|
+
*
|
|
194
|
+
* Note that interval stickiness is currently an experimental feature and must
|
|
195
|
+
* be explicitly enabled with the `intervalStickinessEnabled` flag
|
|
196
|
+
*/
|
|
197
|
+
export declare type IntervalStickiness = typeof IntervalStickiness[keyof typeof IntervalStickiness];
|
|
198
|
+
export declare function endReferenceSlidingPreference(stickiness: IntervalStickiness): SlidingPreference;
|
|
199
|
+
export declare function startReferenceSlidingPreference(stickiness: IntervalStickiness): SlidingPreference;
|
|
200
|
+
//# sourceMappingURL=intervalUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intervalUtils.d.ts","sourceRoot":"","sources":["../../src/intervals/intervalUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,MAAM,EACN,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB;;OAEG;IACH,KAAK,IAAI,SAAS,CAAC;IACnB;;;;;;OAMG;IACH,OAAO,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC9B;;;;OAIG;IACH,YAAY,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACnC;;;;OAIG;IACH,UAAU,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACjC;;;OAGG;IACH,MAAM,CACL,KAAK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BAAgB,+BAA+B,CAAC,UAAU,EAAE,kBAAkB,GAAG,iBAAiB,CAKjG"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.startReferenceSlidingPreference = exports.endReferenceSlidingPreference = exports.IntervalStickiness = exports.IntervalType = exports.IntervalOpType = void 0;
|
|
8
|
+
/* eslint-disable no-bitwise */
|
|
9
|
+
const merge_tree_1 = require("@fluidframework/merge-tree");
|
|
10
|
+
/**
|
|
11
|
+
* Values are used in persisted formats (ops) and revertibles.
|
|
12
|
+
* @alpha
|
|
13
|
+
*/
|
|
14
|
+
exports.IntervalOpType = {
|
|
15
|
+
ADD: "add",
|
|
16
|
+
DELETE: "delete",
|
|
17
|
+
CHANGE: "change",
|
|
18
|
+
PROPERTY_CHANGED: "propertyChanged",
|
|
19
|
+
POSITION_REMOVE: "positionRemove",
|
|
20
|
+
};
|
|
21
|
+
var IntervalType;
|
|
22
|
+
(function (IntervalType) {
|
|
23
|
+
IntervalType[IntervalType["Simple"] = 0] = "Simple";
|
|
24
|
+
IntervalType[IntervalType["Nest"] = 1] = "Nest";
|
|
25
|
+
/**
|
|
26
|
+
* SlideOnRemove indicates that the ends of the interval will slide if the segment
|
|
27
|
+
* they reference is removed and acked.
|
|
28
|
+
* See `packages\dds\merge-tree\docs\REFERENCEPOSITIONS.md` for details
|
|
29
|
+
* SlideOnRemove is the default interval behavior and does not need to be specified.
|
|
30
|
+
*/
|
|
31
|
+
IntervalType[IntervalType["SlideOnRemove"] = 2] = "SlideOnRemove";
|
|
32
|
+
/**
|
|
33
|
+
* A temporary interval, used internally
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
IntervalType[IntervalType["Transient"] = 4] = "Transient";
|
|
37
|
+
})(IntervalType = exports.IntervalType || (exports.IntervalType = {}));
|
|
38
|
+
/**
|
|
39
|
+
* Determines how an interval should expand when segments are inserted adjacent
|
|
40
|
+
* to the range it spans
|
|
41
|
+
*
|
|
42
|
+
* Note that interval stickiness is currently an experimental feature and must
|
|
43
|
+
* be explicitly enabled with the `intervalStickinessEnabled` flag
|
|
44
|
+
*/
|
|
45
|
+
exports.IntervalStickiness = {
|
|
46
|
+
/**
|
|
47
|
+
* Interval does not expand to include adjacent segments
|
|
48
|
+
*/
|
|
49
|
+
NONE: 0b00,
|
|
50
|
+
/**
|
|
51
|
+
* Interval expands to include segments inserted adjacent to the start
|
|
52
|
+
*/
|
|
53
|
+
START: 0b01,
|
|
54
|
+
/**
|
|
55
|
+
* Interval expands to include segments inserted adjacent to the end
|
|
56
|
+
*
|
|
57
|
+
* This is the default stickiness
|
|
58
|
+
*/
|
|
59
|
+
END: 0b10,
|
|
60
|
+
/**
|
|
61
|
+
* Interval expands to include all segments inserted adjacent to it
|
|
62
|
+
*/
|
|
63
|
+
FULL: 0b11,
|
|
64
|
+
};
|
|
65
|
+
function endReferenceSlidingPreference(stickiness) {
|
|
66
|
+
// if any end stickiness, prefer sliding forwards
|
|
67
|
+
return (stickiness & exports.IntervalStickiness.END) !== 0
|
|
68
|
+
? merge_tree_1.SlidingPreference.FORWARD
|
|
69
|
+
: merge_tree_1.SlidingPreference.BACKWARD;
|
|
70
|
+
}
|
|
71
|
+
exports.endReferenceSlidingPreference = endReferenceSlidingPreference;
|
|
72
|
+
function startReferenceSlidingPreference(stickiness) {
|
|
73
|
+
// if any start stickiness, prefer sliding backwards
|
|
74
|
+
return (stickiness & exports.IntervalStickiness.START) !== 0
|
|
75
|
+
? merge_tree_1.SlidingPreference.BACKWARD
|
|
76
|
+
: merge_tree_1.SlidingPreference.FORWARD;
|
|
77
|
+
}
|
|
78
|
+
exports.startReferenceSlidingPreference = startReferenceSlidingPreference;
|
|
79
|
+
//# sourceMappingURL=intervalUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intervalUtils.js","sourceRoot":"","sources":["../../src/intervals/intervalUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAA+B;AAE/B,2DAKoC;AAuDpC;;;GAGG;AACU,QAAA,cAAc,GAAG;IAC7B,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,gBAAgB,EAAE,iBAAiB;IACnC,eAAe,EAAE,gBAAgB;CACxB,CAAC;AAEX,IAAY,YAiBX;AAjBD,WAAY,YAAY;IACvB,mDAAY,CAAA;IACZ,+CAAU,CAAA;IAEV;;;;;OAKG;IACH,iEAAmB,CAAA;IAEnB;;;OAGG;IACH,yDAAe,CAAA;AAChB,CAAC,EAjBW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAiBvB;AA2GD;;;;;;GAMG;AACU,QAAA,kBAAkB,GAAG;IACjC;;OAEG;IACH,IAAI,EAAE,IAAI;IAEV;;OAEG;IACH,KAAK,EAAE,IAAI;IAEX;;;;OAIG;IACH,GAAG,EAAE,IAAI;IAET;;OAEG;IACH,IAAI,EAAE,IAAI;CACD,CAAC;AAWX,SAAgB,6BAA6B,CAAC,UAA8B;IAC3E,iDAAiD;IACjD,OAAO,CAAC,UAAU,GAAG,0BAAkB,CAAC,GAAG,CAAC,KAAK,CAAC;QACjD,CAAC,CAAC,8BAAiB,CAAC,OAAO;QAC3B,CAAC,CAAC,8BAAiB,CAAC,QAAQ,CAAC;AAC/B,CAAC;AALD,sEAKC;AAED,SAAgB,+BAA+B,CAAC,UAA8B;IAC7E,oDAAoD;IACpD,OAAO,CAAC,UAAU,GAAG,0BAAkB,CAAC,KAAK,CAAC,KAAK,CAAC;QACnD,CAAC,CAAC,8BAAiB,CAAC,QAAQ;QAC5B,CAAC,CAAC,8BAAiB,CAAC,OAAO,CAAC;AAC9B,CAAC;AALD,0EAKC","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 {\n\tClient,\n\tPropertiesManager,\n\tPropertySet,\n\tSlidingPreference,\n} from \"@fluidframework/merge-tree\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\n/**\n * Basic interval abstraction\n */\nexport interface IInterval {\n\t/**\n\t * @returns a new interval object with identical semantics.\n\t */\n\tclone(): IInterval;\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: IInterval): 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: IInterval): 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: IInterval): number;\n\t/**\n\t * Modifies one or more of the endpoints of this interval, returning a new interval representing the result.\n\t * @internal\n\t */\n\tmodify(\n\t\tlabel: string,\n\t\tstart: number | undefined,\n\t\tend: number | undefined,\n\t\top?: ISequencedDocumentMessage,\n\t\tlocalSeq?: number,\n\t): IInterval | 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: IInterval): 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 * @internal\n\t */\n\tunion(b: IInterval): IInterval;\n}\n\n/**\n * Values are used in persisted formats (ops) and revertibles.\n * @alpha\n */\nexport const IntervalOpType = {\n\tADD: \"add\",\n\tDELETE: \"delete\",\n\tCHANGE: \"change\",\n\tPROPERTY_CHANGED: \"propertyChanged\",\n\tPOSITION_REMOVE: \"positionRemove\",\n} as const;\n\nexport enum IntervalType {\n\tSimple = 0x0,\n\tNest = 0x1,\n\n\t/**\n\t * SlideOnRemove indicates that the ends of the interval will slide if the segment\n\t * they reference is removed and acked.\n\t * See `packages\\dds\\merge-tree\\docs\\REFERENCEPOSITIONS.md` for details\n\t * SlideOnRemove is the default interval behavior and does not need to be specified.\n\t */\n\tSlideOnRemove = 0x2, // SlideOnRemove is default behavior - all intervals are SlideOnRemove\n\n\t/**\n\t * A temporary interval, used internally\n\t * @internal\n\t */\n\tTransient = 0x4,\n}\n\n/**\n * Serialized object representation of an interval.\n * This representation is used for ops that create or change intervals.\n * @internal\n */\nexport interface ISerializedInterval {\n\t/**\n\t * Sequence number at which `start` and `end` should be interpreted\n\t *\n\t * @remarks It's unclear that this is necessary to store here.\n\t * This should just be the refSeq on the op that modified the interval, which should be available via other means.\n\t * At the time of writing, it's not plumbed through to the reconnect/rebase code, however, which does need it.\n\t */\n\tsequenceNumber: number;\n\t/** Start position of the interval */\n\tstart: number;\n\t/** End position of the interval */\n\tend: number;\n\t/** Interval type to create */\n\tintervalType: IntervalType;\n\tstickiness?: IntervalStickiness;\n\t/** Any properties the interval has */\n\tproperties?: PropertySet;\n}\n\nexport interface ISerializableInterval extends IInterval {\n\t/** Serializable bag of properties associated with the interval. */\n\tproperties: PropertySet;\n\t/** @internal */\n\tpropertyManager: PropertiesManager;\n\t/** @internal */\n\tserialize(): ISerializedInterval;\n\t/** @internal */\n\taddProperties(\n\t\tprops: PropertySet,\n\t\tcollaborating?: boolean,\n\t\tseq?: number,\n\t): PropertySet | undefined;\n\t/**\n\t * Gets the id associated with this interval.\n\t * When the interval is used as part of an interval collection, this id can be used to modify or remove the\n\t * interval.\n\t * @remarks This signature includes `undefined` strictly for backwards-compatibility reasons, as older versions\n\t * of Fluid didn't always write interval ids.\n\t */\n\tgetIntervalId(): string | undefined;\n}\n\n/**\n * Represents a change that should be applied to an existing interval.\n * Changes can modify any of start/end/properties, with `undefined` signifying no change should be made.\n * @internal\n */\nexport type SerializedIntervalDelta = Omit<ISerializedInterval, \"start\" | \"end\" | \"properties\"> &\n\tPartial<Pick<ISerializedInterval, \"start\" | \"end\" | \"properties\">>;\n\n/**\n * A size optimization to avoid redundantly storing keys when serializing intervals\n * as JSON for summaries.\n *\n * Intervals are of the format:\n *\n * [start, end, sequenceNumber, intervalType, properties, stickiness?]\n */\nexport type CompressedSerializedInterval =\n\t| [number, number, number, IntervalType, PropertySet, IntervalStickiness]\n\t| [number, number, number, IntervalType, PropertySet];\n\n/**\n * @sealed\n */\nexport interface IIntervalHelpers<TInterval extends ISerializableInterval> {\n\t/**\n\t * @deprecated Use the method `IInterval.compareEnd` instead\n\t */\n\tcompareEnds(a: TInterval, b: TInterval): number;\n\n\t/**\n\t * @deprecated Use the method `IInterval.compareStart` instead\n\t */\n\tcompareStarts?(a: TInterval, b: TInterval): number;\n\t/**\n\t *\n\t * @param label - label of the interval collection this interval is being added to. This parameter is\n\t * irrelevant for transient intervals.\n\t * @param start - numerical start position of the interval\n\t * @param end - numerical end position of the interval\n\t * @param client - client creating the interval\n\t * @param intervalType - Type of interval to create. Default is SlideOnRemove\n\t * @param op - If this create came from a remote client, op that created it. Default is undefined (i.e. local)\n\t * @param fromSnapshot - If this create came from loading a snapshot. Default is false.\n\t * @param stickiness - {@link (IntervalStickiness:type)} to apply to the added interval.\n\t */\n\tcreate(\n\t\tlabel: string,\n\t\tstart: number | undefined,\n\t\tend: number | undefined,\n\t\tclient: Client | undefined,\n\t\tintervalType: IntervalType,\n\t\top?: ISequencedDocumentMessage,\n\t\tfromSnapshot?: boolean,\n\t\tstickiness?: IntervalStickiness,\n\t): TInterval;\n}\n\n/**\n * Determines how an interval should expand when segments are inserted adjacent\n * to the range it spans\n *\n * Note that interval stickiness is currently an experimental feature and must\n * be explicitly enabled with the `intervalStickinessEnabled` flag\n */\nexport const IntervalStickiness = {\n\t/**\n\t * Interval does not expand to include adjacent segments\n\t */\n\tNONE: 0b00,\n\n\t/**\n\t * Interval expands to include segments inserted adjacent to the start\n\t */\n\tSTART: 0b01,\n\n\t/**\n\t * Interval expands to include segments inserted adjacent to the end\n\t *\n\t * This is the default stickiness\n\t */\n\tEND: 0b10,\n\n\t/**\n\t * Interval expands to include all segments inserted adjacent to it\n\t */\n\tFULL: 0b11,\n} as const;\n\n/**\n * Determines how an interval should expand when segments are inserted adjacent\n * to the range it spans\n *\n * Note that interval stickiness is currently an experimental feature and must\n * be explicitly enabled with the `intervalStickinessEnabled` flag\n */\nexport type IntervalStickiness = typeof IntervalStickiness[keyof typeof IntervalStickiness];\n\nexport function endReferenceSlidingPreference(stickiness: IntervalStickiness): SlidingPreference {\n\t// if any end stickiness, prefer sliding forwards\n\treturn (stickiness & IntervalStickiness.END) !== 0\n\t\t? SlidingPreference.FORWARD\n\t\t: SlidingPreference.BACKWARD;\n}\n\nexport function startReferenceSlidingPreference(stickiness: IntervalStickiness): SlidingPreference {\n\t// if any start stickiness, prefer sliding backwards\n\treturn (stickiness & IntervalStickiness.START) !== 0\n\t\t? SlidingPreference.BACKWARD\n\t\t: SlidingPreference.FORWARD;\n}\n"]}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { Client, ICombiningOp, ISegment, LocalReferencePosition, PropertiesManager, PropertySet, ReferenceType, SlidingPreference } from "@fluidframework/merge-tree";
|
|
6
|
+
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
7
|
+
import { IIntervalHelpers, ISerializableInterval, ISerializedInterval, IntervalStickiness, IntervalType } from "./intervalUtils";
|
|
8
|
+
/**
|
|
9
|
+
* Interval implementation whose ends are associated with positions in a mutatable sequence.
|
|
10
|
+
* As such, when content is inserted into the middle of the interval, the interval expands to
|
|
11
|
+
* include that content.
|
|
12
|
+
*
|
|
13
|
+
* @remarks The endpoint's position should be treated exclusively to get reasonable behavior--i.e.
|
|
14
|
+
* an interval referring to "hello" in "hello world" should have a start position of 0 and an end
|
|
15
|
+
* position of 5.
|
|
16
|
+
*
|
|
17
|
+
* To see why, consider what happens if "llo wor" is removed from the string to make "held".
|
|
18
|
+
* The interval's startpoint remains on the "h" (it isn't altered), but the interval's endpoint
|
|
19
|
+
* slides forward to the next unremoved position, which is the "l" in "held".
|
|
20
|
+
* Users would generally expect the interval to now refer to "he" (as it is the subset of content
|
|
21
|
+
* remaining after the removal), hence the "l" should be excluded.
|
|
22
|
+
* If the interval endpoint was treated inclusively, the interval would now refer to "hel", which
|
|
23
|
+
* is undesirable.
|
|
24
|
+
*
|
|
25
|
+
* Since the end of an interval is treated exclusively but cannot be greater than or equal to the
|
|
26
|
+
* length of the associated sequence, application models which leverage interval collections should
|
|
27
|
+
* consider inserting a marker at the end of the sequence to represent the end of the content.
|
|
28
|
+
*/
|
|
29
|
+
export declare class SequenceInterval implements ISerializableInterval {
|
|
30
|
+
private readonly client;
|
|
31
|
+
/**
|
|
32
|
+
* Start endpoint of this interval.
|
|
33
|
+
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
34
|
+
*/
|
|
35
|
+
start: LocalReferencePosition;
|
|
36
|
+
/**
|
|
37
|
+
* End endpoint of this interval.
|
|
38
|
+
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
39
|
+
*/
|
|
40
|
+
end: LocalReferencePosition;
|
|
41
|
+
intervalType: IntervalType;
|
|
42
|
+
readonly stickiness: IntervalStickiness;
|
|
43
|
+
/**
|
|
44
|
+
* {@inheritDoc ISerializableInterval.properties}
|
|
45
|
+
*/
|
|
46
|
+
properties: PropertySet;
|
|
47
|
+
/**
|
|
48
|
+
* {@inheritDoc ISerializableInterval.propertyManager}
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
propertyManager: PropertiesManager;
|
|
52
|
+
constructor(client: Client,
|
|
53
|
+
/**
|
|
54
|
+
* Start endpoint of this interval.
|
|
55
|
+
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
56
|
+
*/
|
|
57
|
+
start: LocalReferencePosition,
|
|
58
|
+
/**
|
|
59
|
+
* End endpoint of this interval.
|
|
60
|
+
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
61
|
+
*/
|
|
62
|
+
end: LocalReferencePosition, intervalType: IntervalType, props?: PropertySet, stickiness?: IntervalStickiness);
|
|
63
|
+
private callbacks?;
|
|
64
|
+
/**
|
|
65
|
+
* Subscribes to position change events on this interval if there are no current listeners.
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
addPositionChangeListeners(beforePositionChange: () => void, afterPositionChange: () => void): void;
|
|
69
|
+
/**
|
|
70
|
+
* Removes the currently subscribed position change listeners.
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
removePositionChangeListeners(): void;
|
|
74
|
+
/**
|
|
75
|
+
* {@inheritDoc ISerializableInterval.serialize}
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
serialize(): ISerializedInterval;
|
|
79
|
+
/**
|
|
80
|
+
* {@inheritDoc IInterval.clone}
|
|
81
|
+
*/
|
|
82
|
+
clone(): SequenceInterval;
|
|
83
|
+
/**
|
|
84
|
+
* {@inheritDoc IInterval.compare}
|
|
85
|
+
*/
|
|
86
|
+
compare(b: SequenceInterval): number;
|
|
87
|
+
/**
|
|
88
|
+
* {@inheritDoc IInterval.compareStart}
|
|
89
|
+
*/
|
|
90
|
+
compareStart(b: SequenceInterval): number;
|
|
91
|
+
/**
|
|
92
|
+
* {@inheritDoc IInterval.compareEnd}
|
|
93
|
+
*/
|
|
94
|
+
compareEnd(b: SequenceInterval): number;
|
|
95
|
+
/**
|
|
96
|
+
* {@inheritDoc IInterval.overlaps}
|
|
97
|
+
*/
|
|
98
|
+
overlaps(b: SequenceInterval): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* {@inheritDoc ISerializableInterval.getIntervalId}
|
|
101
|
+
*/
|
|
102
|
+
getIntervalId(): string;
|
|
103
|
+
/**
|
|
104
|
+
* {@inheritDoc IInterval.union}
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
107
|
+
union(b: SequenceInterval): SequenceInterval;
|
|
108
|
+
/**
|
|
109
|
+
* {@inheritDoc ISerializableInterval.addProperties}
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
addProperties(newProps: PropertySet, collab?: boolean, seq?: number, op?: ICombiningOp): PropertySet | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* @returns whether this interval overlaps two numerical positions.
|
|
115
|
+
*/
|
|
116
|
+
overlapsPos(bstart: number, bend: number): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* {@inheritDoc IInterval.modify}
|
|
119
|
+
* @internal
|
|
120
|
+
*/
|
|
121
|
+
modify(label: string, start: number, end: number, op?: ISequencedDocumentMessage, localSeq?: number, stickiness?: IntervalStickiness): SequenceInterval;
|
|
122
|
+
private initializeProperties;
|
|
123
|
+
}
|
|
124
|
+
export declare function createPositionReferenceFromSegoff(client: Client, segoff: {
|
|
125
|
+
segment: ISegment | undefined;
|
|
126
|
+
offset: number | undefined;
|
|
127
|
+
}, refType: ReferenceType, op?: ISequencedDocumentMessage, localSeq?: number, fromSnapshot?: boolean, slidingPreference?: SlidingPreference): LocalReferencePosition;
|
|
128
|
+
export declare function createSequenceInterval(label: string, start: number, end: number, client: Client, intervalType: IntervalType, op?: ISequencedDocumentMessage, fromSnapshot?: boolean, stickiness?: IntervalStickiness): SequenceInterval;
|
|
129
|
+
export declare const compareSequenceIntervalEnds: (a: SequenceInterval, b: SequenceInterval) => number;
|
|
130
|
+
export declare const compareSequenceIntervalStarts: (a: SequenceInterval, b: SequenceInterval) => number;
|
|
131
|
+
export declare const sequenceIntervalHelpers: IIntervalHelpers<SequenceInterval>;
|
|
132
|
+
//# sourceMappingURL=sequenceInterval.d.ts.map
|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