@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
package/lib/intervalTree.d.ts
CHANGED
|
@@ -3,71 +3,17 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { IIntegerRange, RBNode, IRBAugmentation, IRBMatcher, RedBlackTree } from "@fluidframework/merge-tree";
|
|
6
|
-
import {
|
|
6
|
+
import { IInterval } from "./intervals";
|
|
7
7
|
export interface AugmentedIntervalNode {
|
|
8
8
|
minmax: IInterval;
|
|
9
9
|
}
|
|
10
10
|
export declare const integerRangeToString: (range: IIntegerRange) => string;
|
|
11
|
-
/**
|
|
12
|
-
* Basic interval abstraction
|
|
13
|
-
*/
|
|
14
|
-
export interface IInterval {
|
|
15
|
-
/**
|
|
16
|
-
* @returns a new interval object with identical semantics.
|
|
17
|
-
*/
|
|
18
|
-
clone(): IInterval;
|
|
19
|
-
/**
|
|
20
|
-
* Compares this interval to `b` with standard comparator semantics:
|
|
21
|
-
* - returns -1 if this is less than `b`
|
|
22
|
-
* - returns 1 if this is greater than `b`
|
|
23
|
-
* - returns 0 if this is equivalent to `b`
|
|
24
|
-
* @param b - Interval to compare against
|
|
25
|
-
*/
|
|
26
|
-
compare(b: IInterval): number;
|
|
27
|
-
/**
|
|
28
|
-
* Compares the start endpoint of this interval to `b`'s start endpoint.
|
|
29
|
-
* Standard comparator semantics apply.
|
|
30
|
-
* @param b - Interval to compare against
|
|
31
|
-
*/
|
|
32
|
-
compareStart(b: IInterval): number;
|
|
33
|
-
/**
|
|
34
|
-
* Compares the end endpoint of this interval to `b`'s end endpoint.
|
|
35
|
-
* Standard comparator semantics apply.
|
|
36
|
-
* @param b - Interval to compare against
|
|
37
|
-
*/
|
|
38
|
-
compareEnd(b: IInterval): number;
|
|
39
|
-
/**
|
|
40
|
-
* Modifies one or more of the endpoints of this interval, returning a new interval representing the result.
|
|
41
|
-
* @internal
|
|
42
|
-
*/
|
|
43
|
-
modify(label: string, start: number | undefined, end: number | undefined, op?: ISequencedDocumentMessage, localSeq?: number): IInterval | undefined;
|
|
44
|
-
/**
|
|
45
|
-
* @returns whether this interval overlaps with `b`.
|
|
46
|
-
* Intervals are considered to overlap if their intersection is non-empty.
|
|
47
|
-
*/
|
|
48
|
-
overlaps(b: IInterval): boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Unions this interval with `b`, returning a new interval.
|
|
51
|
-
* The union operates as a convex hull, i.e. if the two intervals are disjoint, the return value includes
|
|
52
|
-
* intermediate values between the two intervals.
|
|
53
|
-
* @internal
|
|
54
|
-
*/
|
|
55
|
-
union(b: IInterval): IInterval;
|
|
56
|
-
}
|
|
57
11
|
export declare type IntervalNode<T extends IInterval> = RBNode<T, AugmentedIntervalNode>;
|
|
58
|
-
/**
|
|
59
|
-
* @deprecated - This functionality was useful when adding two intervals at the same start/end positions resulted
|
|
60
|
-
* in a conflict. This is no longer the case (as of PR#6407), as interval collections support multiple intervals
|
|
61
|
-
* at the same location and gives each interval a unique id.
|
|
62
|
-
*
|
|
63
|
-
* As such, conflict resolvers are never invoked and unnecessary. They will be removed in an upcoming release.
|
|
64
|
-
*/
|
|
65
|
-
export declare type IntervalConflictResolver<TInterval> = (a: TInterval, b: TInterval) => TInterval;
|
|
66
12
|
export declare class IntervalTree<T extends IInterval> implements IRBAugmentation<T, AugmentedIntervalNode>, IRBMatcher<T, AugmentedIntervalNode> {
|
|
67
13
|
intervals: RedBlackTree<T, AugmentedIntervalNode>;
|
|
68
14
|
remove(x: T): void;
|
|
69
15
|
removeExisting(x: T): void;
|
|
70
|
-
put(x: T
|
|
16
|
+
put(x: T): void;
|
|
71
17
|
map(fn: (x: T) => void): void;
|
|
72
18
|
mapUntil(fn: (X: T) => boolean): void;
|
|
73
19
|
mapBackward(fn: (x: T) => void): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intervalTree.d.ts","sourceRoot":"","sources":["../src/intervalTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,aAAa,EACb,MAAM,EACN,eAAe,EACf,UAAU,EACV,YAAY,
|
|
1
|
+
{"version":3,"file":"intervalTree.d.ts","sourceRoot":"","sources":["../src/intervalTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,aAAa,EACb,MAAM,EACN,eAAe,EACf,UAAU,EACV,YAAY,EAEZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,WAAW,qBAAqB;IACrC,MAAM,EAAE,SAAS,CAAC;CAClB;AAED,eAAO,MAAM,oBAAoB,UAAW,aAAa,WAAoC,CAAC;AAI9F,oBAAY,YAAY,CAAC,CAAC,SAAS,SAAS,IAAI,MAAM,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC;AAEjF,qBAAa,YAAY,CAAC,CAAC,SAAS,SAAS,CAC5C,YAAW,eAAe,CAAC,CAAC,EAAE,qBAAqB,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,qBAAqB,CAAC;IAEnF,SAAS,yCAAsE;IAE/E,MAAM,CAAC,CAAC,EAAE,CAAC;IAIX,cAAc,CAAC,CAAC,EAAE,CAAC;IAInB,GAAG,CAAC,CAAC,EAAE,CAAC;IAIR,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI;IAWtB,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO;IAU9B,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI;IAY9B,KAAK,CAAC,CAAC,EAAE,CAAC;IAIV,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,CAAC;IAInD,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,CAAC;IAIzD,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;CAanC"}
|
package/lib/intervalTree.js
CHANGED
|
@@ -15,17 +15,8 @@ export class IntervalTree {
|
|
|
15
15
|
removeExisting(x) {
|
|
16
16
|
this.intervals.removeExisting(x);
|
|
17
17
|
}
|
|
18
|
-
put(x
|
|
19
|
-
|
|
20
|
-
if (conflict) {
|
|
21
|
-
rbConflict = (key, currentKey) => {
|
|
22
|
-
const ival = conflict(key, currentKey);
|
|
23
|
-
return {
|
|
24
|
-
key: ival,
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
this.intervals.put(x, { minmax: x.clone() }, rbConflict);
|
|
18
|
+
put(x) {
|
|
19
|
+
this.intervals.put(x, { minmax: x.clone() });
|
|
29
20
|
}
|
|
30
21
|
map(fn) {
|
|
31
22
|
const actions = {
|
package/lib/intervalTree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intervalTree.js","sourceRoot":"","sources":["../src/intervalTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAKN,YAAY,
|
|
1
|
+
{"version":3,"file":"intervalTree.js","sourceRoot":"","sources":["../src/intervalTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAKN,YAAY,GAEZ,MAAM,4BAA4B,CAAC;AAOpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAoB,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,GAAG,GAAG,CAAC;AAE9F,MAAM,gBAAgB,GAAG,CAAC,CAAY,EAAE,CAAY,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAItE,MAAM,OAAO,YAAY;IAAzB;QAGQ,cAAS,GAAG,IAAI,YAAY,CAA2B,gBAAgB,EAAE,IAAI,CAAC,CAAC;IAwEvF,CAAC;IAtEO,MAAM,CAAC,CAAI;QACjB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IAEM,cAAc,CAAC,CAAI;QACzB,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;IAEM,GAAG,CAAC,CAAI;QACd,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC9C,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AAG,CAAC,CAAC;IACjD,CAAC;IAEM,MAAM,CAAC,IAAqB;QAClC,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;SACvF;aAAM;YACN,IAAI,IAAI,CAAC,IAAI,EAAE;gBACd,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACzD;iBAAM,IAAI,IAAI,CAAC,KAAK,EAAE;gBACtB,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aAC1D;iBAAM;gBACN,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;aACpC;SACD;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIIntegerRange,\n\tRBNode,\n\tIRBAugmentation,\n\tIRBMatcher,\n\tRedBlackTree,\n\tRBNodeActions,\n} from \"@fluidframework/merge-tree\";\nimport { IInterval } from \"./intervals\";\n\nexport interface AugmentedIntervalNode {\n\tminmax: IInterval;\n}\n\nexport const integerRangeToString = (range: IIntegerRange) => `[${range.start},${range.end})`;\n\nconst intervalComparer = (a: IInterval, b: IInterval) => a.compare(b);\n\nexport type IntervalNode<T extends IInterval> = RBNode<T, AugmentedIntervalNode>;\n\nexport class IntervalTree<T extends IInterval>\n\timplements IRBAugmentation<T, AugmentedIntervalNode>, IRBMatcher<T, AugmentedIntervalNode>\n{\n\tpublic intervals = new RedBlackTree<T, AugmentedIntervalNode>(intervalComparer, this);\n\n\tpublic remove(x: T) {\n\t\tthis.intervals.remove(x);\n\t}\n\n\tpublic removeExisting(x: T) {\n\t\tthis.intervals.removeExisting(x);\n\t}\n\n\tpublic put(x: T) {\n\t\tthis.intervals.put(x, { minmax: x.clone() });\n\t}\n\n\tpublic map(fn: (x: T) => void) {\n\t\tconst actions: RBNodeActions<T, AugmentedIntervalNode> = {\n\t\t\tinfix: (node) => {\n\t\t\t\tfn(node.key);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tshowStructure: true,\n\t\t};\n\t\tthis.intervals.walk(actions);\n\t}\n\n\tpublic mapUntil(fn: (X: T) => boolean) {\n\t\tconst actions: RBNodeActions<T, AugmentedIntervalNode> = {\n\t\t\tinfix: (node) => {\n\t\t\t\treturn fn(node.key);\n\t\t\t},\n\t\t\tshowStructure: true,\n\t\t};\n\t\tthis.intervals.walk(actions);\n\t}\n\n\tpublic mapBackward(fn: (x: T) => void) {\n\t\tconst actions: RBNodeActions<T, AugmentedIntervalNode> = {\n\t\t\tinfix: (node) => {\n\t\t\t\tfn(node.key);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tshowStructure: true,\n\t\t};\n\t\tthis.intervals.walkBackward(actions);\n\t}\n\n\t// TODO: toString()\n\tpublic match(x: T) {\n\t\treturn this.intervals.gather(x, this);\n\t}\n\n\tpublic matchNode(node: IntervalNode<T> | undefined, key: T) {\n\t\treturn !!node && node.key.overlaps(key);\n\t}\n\n\tpublic continueSubtree(node: IntervalNode<T> | undefined, key: T) {\n\t\treturn !!node && node.data.minmax.overlaps(key);\n\t}\n\n\tpublic update(node: IntervalNode<T>) {\n\t\tif (node.left && node.right) {\n\t\t\tnode.data.minmax = node.key.union(node.left.data.minmax.union(node.right.data.minmax));\n\t\t} else {\n\t\t\tif (node.left) {\n\t\t\t\tnode.data.minmax = node.key.union(node.left.data.minmax);\n\t\t\t} else if (node.right) {\n\t\t\t\tnode.data.minmax = node.key.union(node.right.data.minmax);\n\t\t\t} else {\n\t\t\t\tnode.data.minmax = node.key.clone();\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
export { IInterval, ISerializedInterval, ISerializableInterval, IntervalOpType, IntervalType, IIntervalHelpers, IntervalStickiness, SerializedIntervalDelta, CompressedSerializedInterval, endReferenceSlidingPreference, startReferenceSlidingPreference, } from "./intervalUtils";
|
|
6
|
+
export { Interval, createInterval, intervalHelpers } from "./interval";
|
|
7
|
+
export { SequenceInterval, createSequenceInterval, createPositionReferenceFromSegoff, sequenceIntervalHelpers, } from "./sequenceInterval";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/intervals/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,SAAS,EACT,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,4BAA4B,EAC5B,6BAA6B,EAC7B,+BAA+B,GAC/B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EACN,gBAAgB,EAChB,sBAAsB,EACtB,iCAAiC,EACjC,uBAAuB,GACvB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
export { IntervalOpType, IntervalType, IntervalStickiness, endReferenceSlidingPreference, startReferenceSlidingPreference, } from "./intervalUtils";
|
|
6
|
+
export { Interval, createInterval, intervalHelpers } from "./interval";
|
|
7
|
+
export { SequenceInterval, createSequenceInterval, createPositionReferenceFromSegoff, sequenceIntervalHelpers, } from "./sequenceInterval";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/intervals/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIN,cAAc,EACd,YAAY,EAEZ,kBAAkB,EAGlB,6BAA6B,EAC7B,+BAA+B,GAC/B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EACN,gBAAgB,EAChB,sBAAsB,EACtB,iCAAiC,EACjC,uBAAuB,GACvB,MAAM,oBAAoB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tIInterval,\n\tISerializedInterval,\n\tISerializableInterval,\n\tIntervalOpType,\n\tIntervalType,\n\tIIntervalHelpers,\n\tIntervalStickiness,\n\tSerializedIntervalDelta,\n\tCompressedSerializedInterval,\n\tendReferenceSlidingPreference,\n\tstartReferenceSlidingPreference,\n} from \"./intervalUtils\";\nexport { Interval, createInterval, intervalHelpers } from \"./interval\";\nexport {\n\tSequenceInterval,\n\tcreateSequenceInterval,\n\tcreatePositionReferenceFromSegoff,\n\tsequenceIntervalHelpers,\n} from \"./sequenceInterval\";\n"]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ICombiningOp, PropertiesManager, PropertySet } from "@fluidframework/merge-tree";
|
|
6
|
+
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
7
|
+
import { IIntervalHelpers, ISerializableInterval, ISerializedInterval } from "./intervalUtils";
|
|
8
|
+
/**
|
|
9
|
+
* Serializable interval whose endpoints are plain-old numbers.
|
|
10
|
+
*/
|
|
11
|
+
export declare class Interval implements ISerializableInterval {
|
|
12
|
+
start: number;
|
|
13
|
+
end: number;
|
|
14
|
+
/**
|
|
15
|
+
* {@inheritDoc ISerializableInterval.properties}
|
|
16
|
+
*/
|
|
17
|
+
properties: PropertySet;
|
|
18
|
+
/** @internal */
|
|
19
|
+
auxProps: PropertySet[] | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* {@inheritDoc ISerializableInterval.propertyManager}
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
propertyManager: PropertiesManager;
|
|
25
|
+
constructor(start: number, end: number, props?: PropertySet);
|
|
26
|
+
/**
|
|
27
|
+
* {@inheritDoc ISerializableInterval.getIntervalId}
|
|
28
|
+
*/
|
|
29
|
+
getIntervalId(): string;
|
|
30
|
+
/**
|
|
31
|
+
* @returns an array containing any auxiliary property sets added with `addPropertySet`.
|
|
32
|
+
*/
|
|
33
|
+
getAdditionalPropertySets(): PropertySet[];
|
|
34
|
+
/**
|
|
35
|
+
* Adds an auxiliary set of properties to this interval.
|
|
36
|
+
* These properties can be recovered using `getAdditionalPropertySets`
|
|
37
|
+
* @param props - set of properties to add
|
|
38
|
+
* @remarks This gets called as part of the default conflict resolver for `IIntervalCollection<Interval>`
|
|
39
|
+
* (i.e. non-sequence-based interval collections). However, the additional properties don't get serialized.
|
|
40
|
+
* This functionality seems half-baked.
|
|
41
|
+
*/
|
|
42
|
+
addPropertySet(props: PropertySet): void;
|
|
43
|
+
/**
|
|
44
|
+
* {@inheritDoc ISerializableInterval.serialize}
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
serialize(): ISerializedInterval;
|
|
48
|
+
/**
|
|
49
|
+
* {@inheritDoc IInterval.clone}
|
|
50
|
+
*/
|
|
51
|
+
clone(): Interval;
|
|
52
|
+
/**
|
|
53
|
+
* {@inheritDoc IInterval.compare}
|
|
54
|
+
*/
|
|
55
|
+
compare(b: Interval): number;
|
|
56
|
+
/**
|
|
57
|
+
* {@inheritDoc IInterval.compareStart}
|
|
58
|
+
*/
|
|
59
|
+
compareStart(b: Interval): number;
|
|
60
|
+
/**
|
|
61
|
+
* {@inheritDoc IInterval.compareEnd}
|
|
62
|
+
*/
|
|
63
|
+
compareEnd(b: Interval): number;
|
|
64
|
+
/**
|
|
65
|
+
* {@inheritDoc IInterval.overlaps}
|
|
66
|
+
*/
|
|
67
|
+
overlaps(b: Interval): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* {@inheritDoc IInterval.union}
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
union(b: Interval): Interval;
|
|
73
|
+
getProperties(): PropertySet;
|
|
74
|
+
/**
|
|
75
|
+
* {@inheritDoc ISerializableInterval.addProperties}
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
addProperties(newProps: PropertySet, collaborating?: boolean, seq?: number, op?: ICombiningOp): PropertySet | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* {@inheritDoc IInterval.modify}
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
modify(label: string, start: number, end: number, op?: ISequencedDocumentMessage): Interval | undefined;
|
|
84
|
+
private initializeProperties;
|
|
85
|
+
}
|
|
86
|
+
export declare function createInterval(label: string, start: number, end: number): Interval;
|
|
87
|
+
export declare const intervalHelpers: IIntervalHelpers<Interval>;
|
|
88
|
+
//# sourceMappingURL=interval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interval.d.ts","sourceRoot":"","sources":["../../src/intervals/interval.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,YAAY,EACZ,iBAAi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AAM,EAAE,EAAE,CAAC,EAAE,yBAAyB;IAmBvF,OAAO,CAAC,oBAAoB;CAQ5B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,CAQlF;AAED,eAAO,MAAM,eAAe,EAAE,gBAAgB,CAAC,QAAQ,CAItD,CAAC"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { PropertiesManager, createMap, reservedRangeLabelsKey, } from "@fluidframework/merge-tree";
|
|
6
|
+
import { assert } from "@fluidframework/core-utils";
|
|
7
|
+
const reservedIntervalIdKey = "intervalId";
|
|
8
|
+
/**
|
|
9
|
+
* Serializable interval whose endpoints are plain-old numbers.
|
|
10
|
+
*/
|
|
11
|
+
export class Interval {
|
|
12
|
+
constructor(start, end, props) {
|
|
13
|
+
this.start = start;
|
|
14
|
+
this.end = end;
|
|
15
|
+
this.propertyManager = new PropertiesManager();
|
|
16
|
+
this.properties = {};
|
|
17
|
+
if (props) {
|
|
18
|
+
this.addProperties(props);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* {@inheritDoc ISerializableInterval.getIntervalId}
|
|
23
|
+
*/
|
|
24
|
+
getIntervalId() {
|
|
25
|
+
const id = this.properties?.[reservedIntervalIdKey];
|
|
26
|
+
assert(id !== undefined, 0x5e1 /* interval ID should not be undefined */);
|
|
27
|
+
return `${id}`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @returns an array containing any auxiliary property sets added with `addPropertySet`.
|
|
31
|
+
*/
|
|
32
|
+
getAdditionalPropertySets() {
|
|
33
|
+
return this.auxProps ?? [];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Adds an auxiliary set of properties to this interval.
|
|
37
|
+
* These properties can be recovered using `getAdditionalPropertySets`
|
|
38
|
+
* @param props - set of properties to add
|
|
39
|
+
* @remarks This gets called as part of the default conflict resolver for `IIntervalCollection<Interval>`
|
|
40
|
+
* (i.e. non-sequence-based interval collections). However, the additional properties don't get serialized.
|
|
41
|
+
* This functionality seems half-baked.
|
|
42
|
+
*/
|
|
43
|
+
addPropertySet(props) {
|
|
44
|
+
if (this.auxProps === undefined) {
|
|
45
|
+
this.auxProps = [];
|
|
46
|
+
}
|
|
47
|
+
this.auxProps.push(props);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* {@inheritDoc ISerializableInterval.serialize}
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
serialize() {
|
|
54
|
+
const serializedInterval = {
|
|
55
|
+
end: this.end,
|
|
56
|
+
intervalType: 0,
|
|
57
|
+
sequenceNumber: 0,
|
|
58
|
+
start: this.start,
|
|
59
|
+
};
|
|
60
|
+
if (this.properties) {
|
|
61
|
+
serializedInterval.properties = this.properties;
|
|
62
|
+
}
|
|
63
|
+
return serializedInterval;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* {@inheritDoc IInterval.clone}
|
|
67
|
+
*/
|
|
68
|
+
clone() {
|
|
69
|
+
return new Interval(this.start, this.end, this.properties);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* {@inheritDoc IInterval.compare}
|
|
73
|
+
*/
|
|
74
|
+
compare(b) {
|
|
75
|
+
const startResult = this.compareStart(b);
|
|
76
|
+
if (startResult === 0) {
|
|
77
|
+
const endResult = this.compareEnd(b);
|
|
78
|
+
if (endResult === 0) {
|
|
79
|
+
const thisId = this.getIntervalId();
|
|
80
|
+
if (thisId) {
|
|
81
|
+
const bId = b.getIntervalId();
|
|
82
|
+
if (bId) {
|
|
83
|
+
return thisId > bId ? 1 : thisId < bId ? -1 : 0;
|
|
84
|
+
}
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
return endResult;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
return startResult;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* {@inheritDoc IInterval.compareStart}
|
|
99
|
+
*/
|
|
100
|
+
compareStart(b) {
|
|
101
|
+
return this.start - b.start;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* {@inheritDoc IInterval.compareEnd}
|
|
105
|
+
*/
|
|
106
|
+
compareEnd(b) {
|
|
107
|
+
return this.end - b.end;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* {@inheritDoc IInterval.overlaps}
|
|
111
|
+
*/
|
|
112
|
+
overlaps(b) {
|
|
113
|
+
const result = this.start <= b.end && this.end >= b.start;
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* {@inheritDoc IInterval.union}
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
union(b) {
|
|
121
|
+
return new Interval(Math.min(this.start, b.start), Math.max(this.end, b.end), this.properties);
|
|
122
|
+
}
|
|
123
|
+
getProperties() {
|
|
124
|
+
return this.properties;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* {@inheritDoc ISerializableInterval.addProperties}
|
|
128
|
+
* @internal
|
|
129
|
+
*/
|
|
130
|
+
addProperties(newProps, collaborating = false, seq, op) {
|
|
131
|
+
if (newProps) {
|
|
132
|
+
this.initializeProperties();
|
|
133
|
+
return this.propertyManager.addProperties(this.properties, newProps, op, seq, collaborating);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* {@inheritDoc IInterval.modify}
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
modify(label, start, end, op) {
|
|
141
|
+
const startPos = start ?? this.start;
|
|
142
|
+
const endPos = end ?? this.end;
|
|
143
|
+
if (this.start === startPos && this.end === endPos) {
|
|
144
|
+
// Return undefined to indicate that no change is necessary.
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const newInterval = new Interval(startPos, endPos);
|
|
148
|
+
if (this.properties) {
|
|
149
|
+
newInterval.initializeProperties();
|
|
150
|
+
this.propertyManager.copyTo(this.properties, newInterval.properties, newInterval.propertyManager);
|
|
151
|
+
}
|
|
152
|
+
return newInterval;
|
|
153
|
+
}
|
|
154
|
+
initializeProperties() {
|
|
155
|
+
if (!this.propertyManager) {
|
|
156
|
+
this.propertyManager = new PropertiesManager();
|
|
157
|
+
}
|
|
158
|
+
if (!this.properties) {
|
|
159
|
+
this.properties = createMap();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
export function createInterval(label, start, end) {
|
|
164
|
+
const rangeProp = {};
|
|
165
|
+
if (label && label.length > 0) {
|
|
166
|
+
rangeProp[reservedRangeLabelsKey] = [label];
|
|
167
|
+
}
|
|
168
|
+
return new Interval(start, end, rangeProp);
|
|
169
|
+
}
|
|
170
|
+
export const intervalHelpers = {
|
|
171
|
+
compareEnds: (a, b) => a.end - b.end,
|
|
172
|
+
compareStarts: (a, b) => a.start - b.start,
|
|
173
|
+
create: createInterval,
|
|
174
|
+
};
|
|
175
|
+
//# sourceMappingURL=interval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interval.js","sourceRoot":"","sources":["../../src/intervals/interval.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,iBAAiB,EAEjB,SAAS,EACT,sBAAsB,GACtB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGpD,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,QAAQ;IAYpB,YAAmB,KAAa,EAAS,GAAW,EAAE,KAAmB;QAAtD,UAAK,GAAL,KAAK,C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,CAAC,IAAI,CAAC,UAAU,EAAE;YACrB,IAAI,CAAC,UAAU,GAAG,SAAS,EAAO,CAAC;SACnC;IACF,CAAC;CACD;AAED,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,KAAa,EAAE,GAAW;IACvE,MAAM,SAAS,GAAgB,EAAE,CAAC;IAElC,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QAC9B,SAAS,CAAC,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KAC5C;IAED,OAAO,IAAI,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAA+B;IAC1D,WAAW,EAAE,CAAC,CAAW,EAAE,CAAW,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG;IACxD,aAAa,EAAE,CAAC,CAAW,EAAE,CAAW,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK;IAC9D,MAAM,EAAE,cAAc;CACtB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tICombiningOp,\n\tPropertiesManager,\n\tPropertySet,\n\tcreateMap,\n\treservedRangeLabelsKey,\n} from \"@fluidframework/merge-tree\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IIntervalHelpers, ISerializableInterval, ISerializedInterval } from \"./intervalUtils\";\n\nconst reservedIntervalIdKey = \"intervalId\";\n\n/**\n * Serializable interval whose endpoints are plain-old numbers.\n */\nexport class Interval implements ISerializableInterval {\n\t/**\n\t * {@inheritDoc ISerializableInterval.properties}\n\t */\n\tpublic properties: PropertySet;\n\t/** @internal */\n\tpublic auxProps: PropertySet[] | undefined;\n\t/**\n\t * {@inheritDoc ISerializableInterval.propertyManager}\n\t * @internal\n\t */\n\tpublic propertyManager: PropertiesManager;\n\tconstructor(public start: number, public end: number, props?: PropertySet) {\n\t\tthis.propertyManager = new PropertiesManager();\n\t\tthis.properties = {};\n\n\t\tif (props) {\n\t\t\tthis.addProperties(props);\n\t\t}\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, 0x5e1 /* interval ID should not be undefined */);\n\t\treturn `${id}`;\n\t}\n\n\t/**\n\t * @returns an array containing any auxiliary property sets added with `addPropertySet`.\n\t */\n\tpublic getAdditionalPropertySets(): PropertySet[] {\n\t\treturn this.auxProps ?? [];\n\t}\n\n\t/**\n\t * Adds an auxiliary set of properties to this interval.\n\t * These properties can be recovered using `getAdditionalPropertySets`\n\t * @param props - set of properties to add\n\t * @remarks This gets called as part of the default conflict resolver for `IIntervalCollection<Interval>`\n\t * (i.e. non-sequence-based interval collections). However, the additional properties don't get serialized.\n\t * This functionality seems half-baked.\n\t */\n\tpublic addPropertySet(props: PropertySet) {\n\t\tif (this.auxProps === undefined) {\n\t\t\tthis.auxProps = [];\n\t\t}\n\t\tthis.auxProps.push(props);\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.serialize}\n\t * @internal\n\t */\n\tpublic serialize(): ISerializedInterval {\n\t\tconst serializedInterval: ISerializedInterval = {\n\t\t\tend: this.end,\n\t\t\tintervalType: 0,\n\t\t\tsequenceNumber: 0,\n\t\t\tstart: this.start,\n\t\t};\n\t\tif (this.properties) {\n\t\t\tserializedInterval.properties = this.properties;\n\t\t}\n\t\treturn serializedInterval;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.clone}\n\t */\n\tpublic clone() {\n\t\treturn new Interval(this.start, this.end, this.properties);\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compare}\n\t */\n\tpublic compare(b: Interval) {\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: Interval) {\n\t\treturn this.start - b.start;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareEnd}\n\t */\n\tpublic compareEnd(b: Interval) {\n\t\treturn this.end - b.end;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.overlaps}\n\t */\n\tpublic overlaps(b: Interval) {\n\t\tconst result = this.start <= b.end && this.end >= b.start;\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.union}\n\t * @internal\n\t */\n\tpublic union(b: Interval) {\n\t\treturn new Interval(\n\t\t\tMath.min(this.start, b.start),\n\t\t\tMath.max(this.end, b.end),\n\t\t\tthis.properties,\n\t\t);\n\t}\n\n\tpublic getProperties() {\n\t\treturn this.properties;\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.addProperties}\n\t * @internal\n\t */\n\tpublic addProperties(\n\t\tnewProps: PropertySet,\n\t\tcollaborating: boolean = false,\n\t\tseq?: number,\n\t\top?: ICombiningOp,\n\t): PropertySet | undefined {\n\t\tif (newProps) {\n\t\t\tthis.initializeProperties();\n\t\t\treturn this.propertyManager.addProperties(\n\t\t\t\tthis.properties,\n\t\t\t\tnewProps,\n\t\t\t\top,\n\t\t\t\tseq,\n\t\t\t\tcollaborating,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.modify}\n\t * @internal\n\t */\n\tpublic modify(label: string, start: number, end: number, op?: ISequencedDocumentMessage) {\n\t\tconst startPos = start ?? this.start;\n\t\tconst endPos = end ?? this.end;\n\t\tif (this.start === startPos && this.end === endPos) {\n\t\t\t// Return undefined to indicate that no change is necessary.\n\t\t\treturn;\n\t\t}\n\t\tconst newInterval = new Interval(startPos, endPos);\n\t\tif (this.properties) {\n\t\t\tnewInterval.initializeProperties();\n\t\t\tthis.propertyManager.copyTo(\n\t\t\t\tthis.properties,\n\t\t\t\tnewInterval.properties,\n\t\t\t\tnewInterval.propertyManager,\n\t\t\t);\n\t\t}\n\t\treturn newInterval;\n\t}\n\n\tprivate initializeProperties(): void {\n\t\tif (!this.propertyManager) {\n\t\t\tthis.propertyManager = new PropertiesManager();\n\t\t}\n\t\tif (!this.properties) {\n\t\t\tthis.properties = createMap<any>();\n\t\t}\n\t}\n}\n\nexport function createInterval(label: string, start: number, end: number): Interval {\n\tconst rangeProp: PropertySet = {};\n\n\tif (label && label.length > 0) {\n\t\trangeProp[reservedRangeLabelsKey] = [label];\n\t}\n\n\treturn new Interval(start, end, rangeProp);\n}\n\nexport const intervalHelpers: IIntervalHelpers<Interval> = {\n\tcompareEnds: (a: Interval, b: Interval) => a.end - b.end,\n\tcompareStarts: (a: Interval, b: Interval) => a.start - b.start,\n\tcreate: createInterval,\n};\n"]}
|
|
@@ -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
|