@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 @@
|
|
|
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,yBAA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AAO,EACtB,UAAU,CAAC,EAAE,kBAAkB,GAC7B,SAAS,CAAC;CACb;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;IAC9B;;OAEG;;IAGH;;OAEG;;IAGH;;;;OAIG;;IAGH;;OAEG;;CAEM,CAAC;AAEX;;;;;;GAMG;AACH,oBAAY,kBAAkB,GAAG,OAAO,kBAAkB,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAE5F,wBAAgB,6BAA6B,CAAC,UAAU,EAAE,kBAAkB,GAAG,iBAAiB,CAK/F;AAED,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,kBAAkB,GAAG,iBAAiB,CAKjG"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/* eslint-disable no-bitwise */
|
|
6
|
+
import { SlidingPreference, } from "@fluidframework/merge-tree";
|
|
7
|
+
/**
|
|
8
|
+
* Values are used in persisted formats (ops) and revertibles.
|
|
9
|
+
* @alpha
|
|
10
|
+
*/
|
|
11
|
+
export const IntervalOpType = {
|
|
12
|
+
ADD: "add",
|
|
13
|
+
DELETE: "delete",
|
|
14
|
+
CHANGE: "change",
|
|
15
|
+
PROPERTY_CHANGED: "propertyChanged",
|
|
16
|
+
POSITION_REMOVE: "positionRemove",
|
|
17
|
+
};
|
|
18
|
+
export var IntervalType;
|
|
19
|
+
(function (IntervalType) {
|
|
20
|
+
IntervalType[IntervalType["Simple"] = 0] = "Simple";
|
|
21
|
+
IntervalType[IntervalType["Nest"] = 1] = "Nest";
|
|
22
|
+
/**
|
|
23
|
+
* SlideOnRemove indicates that the ends of the interval will slide if the segment
|
|
24
|
+
* they reference is removed and acked.
|
|
25
|
+
* See `packages\dds\merge-tree\docs\REFERENCEPOSITIONS.md` for details
|
|
26
|
+
* SlideOnRemove is the default interval behavior and does not need to be specified.
|
|
27
|
+
*/
|
|
28
|
+
IntervalType[IntervalType["SlideOnRemove"] = 2] = "SlideOnRemove";
|
|
29
|
+
/**
|
|
30
|
+
* A temporary interval, used internally
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
IntervalType[IntervalType["Transient"] = 4] = "Transient";
|
|
34
|
+
})(IntervalType || (IntervalType = {}));
|
|
35
|
+
/**
|
|
36
|
+
* Determines how an interval should expand when segments are inserted adjacent
|
|
37
|
+
* to the range it spans
|
|
38
|
+
*
|
|
39
|
+
* Note that interval stickiness is currently an experimental feature and must
|
|
40
|
+
* be explicitly enabled with the `intervalStickinessEnabled` flag
|
|
41
|
+
*/
|
|
42
|
+
export const IntervalStickiness = {
|
|
43
|
+
/**
|
|
44
|
+
* Interval does not expand to include adjacent segments
|
|
45
|
+
*/
|
|
46
|
+
NONE: 0b00,
|
|
47
|
+
/**
|
|
48
|
+
* Interval expands to include segments inserted adjacent to the start
|
|
49
|
+
*/
|
|
50
|
+
START: 0b01,
|
|
51
|
+
/**
|
|
52
|
+
* Interval expands to include segments inserted adjacent to the end
|
|
53
|
+
*
|
|
54
|
+
* This is the default stickiness
|
|
55
|
+
*/
|
|
56
|
+
END: 0b10,
|
|
57
|
+
/**
|
|
58
|
+
* Interval expands to include all segments inserted adjacent to it
|
|
59
|
+
*/
|
|
60
|
+
FULL: 0b11,
|
|
61
|
+
};
|
|
62
|
+
export function endReferenceSlidingPreference(stickiness) {
|
|
63
|
+
// if any end stickiness, prefer sliding forwards
|
|
64
|
+
return (stickiness & IntervalStickiness.END) !== 0
|
|
65
|
+
? SlidingPreference.FORWARD
|
|
66
|
+
: SlidingPreference.BACKWARD;
|
|
67
|
+
}
|
|
68
|
+
export function startReferenceSlidingPreference(stickiness) {
|
|
69
|
+
// if any start stickiness, prefer sliding backwards
|
|
70
|
+
return (stickiness & IntervalStickiness.START) !== 0
|
|
71
|
+
? SlidingPreference.BACKWARD
|
|
72
|
+
: SlidingPreference.FORWARD;
|
|
73
|
+
}
|
|
74
|
+
//# 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,OAAO,EAIN,iBAAiB,GACjB,MAAM,4BAA4B,CAAC;AAuDpC;;;GAGG;AACH,MAAM,CAAC,MAAM,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,MAAM,CAAN,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,KAAZ,YAAY,QAiBvB;AA2GD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,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,MAAM,UAAU,6BAA6B,CAAC,UAA8B;IAC3E,iDAAiD;IACjD,OAAO,CAAC,UAAU,GAAG,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC;QACjD,CAAC,CAAC,iBAAiB,CAAC,OAAO;QAC3B,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,UAA8B;IAC7E,oDAAoD;IACpD,OAAO,CAAC,UAAU,GAAG,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC;QACnD,CAAC,CAAC,iBAAiB,CAAC,QAAQ;QAC5B,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC;AAC9B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport {\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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequenceInterval.d.ts","sourceRoot":"","sources":["../../src/intervals/sequenceInterval.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,iBAAiB,EASjB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OAAO,EACN,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EAGZ,MAAM,iBAAiB,CAAC;AAIzB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,gBAAiB,YAAW,qBAAqB;IAY5D,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB;;;OAGG;IACI,KAAK,EAAE,sBAAsB;IACpC;;;OAGG;IACI,GAAG,EAAE,sBAAsB;IAC3B,YAAY,EAAE,YAAY;aAEjB,UAAU,EAAE,kBAAkB;IAxB/C;;OAEG;IACI,UAAU,EAAE,WAAW,CAAC;IAC/B;;;OAGG;IACI,eAAe,EAAE,iBAAiB,CAAC;gBAGxB,MAAM,EAAE,MAAM;IAC/B;;;OAGG;IACI,KAAK,EAAE,sBAAsB;IACpC;;;OAGG;IACI,GAAG,EAAE,sBAAsB,EAC3B,YAAY,EAAE,YAAY,EACjC,KAAK,CAAC,EAAE,WAAW,EACH,UAAU,GAAE,kBAA2C;IAUxE,OAAO,CAAC,SAAS,CAAC,CAAqE;IAEvF;;;OAGG;IACI,0BAA0B,CAChC,oBAAoB,EAAE,MAAM,IAAI,EAChC,mBAAmB,EAAE,MAAM,IAAI,GAC7B,IAAI;IAcP;;;OAGG;IACI,6BAA6B,IAAI,IAAI;IAQ5C;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,MAAM,EACX,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,EAAE,CAAC,EAAE,yBAAyB,EAC9B,YAAY,CAAC,EAAE,OAAO,EACtB,UAAU,GAAE,kBAA2C,GACrD,gBAAgB,CA0DlB;AAED,eAAO,MAAM,2BAA2B,MAAO,gBAAgB,KAAK,gBAAgB,KAAG,MAC/C,CAAC;AAEzC,eAAO,MAAM,6BAA6B,MAAO,gBAAgB,KAAK,gBAAgB,KAAG,MAC7C,CAAC;AAE7C,eAAO,MAAM,uBAAuB,EAAE,gBAAgB,CAAC,gBAAgB,CAItE,CAAC"}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/* eslint-disable no-bitwise */
|
|
6
|
+
import { PropertiesManager, ReferenceType, compareReferencePositions, createDetachedLocalReferencePosition, createMap, getSlideToSegoff, maxReferencePosition, minReferencePosition, refTypeIncludesFlag, reservedRangeLabelsKey, } from "@fluidframework/merge-tree";
|
|
7
|
+
import { assert } from "@fluidframework/core-utils";
|
|
8
|
+
import { UsageError } from "@fluidframework/telemetry-utils";
|
|
9
|
+
import { IntervalStickiness, IntervalType, endReferenceSlidingPreference, startReferenceSlidingPreference, } from "./intervalUtils";
|
|
10
|
+
const reservedIntervalIdKey = "intervalId";
|
|
11
|
+
/**
|
|
12
|
+
* Interval implementation whose ends are associated with positions in a mutatable sequence.
|
|
13
|
+
* As such, when content is inserted into the middle of the interval, the interval expands to
|
|
14
|
+
* include that content.
|
|
15
|
+
*
|
|
16
|
+
* @remarks The endpoint's position should be treated exclusively to get reasonable behavior--i.e.
|
|
17
|
+
* an interval referring to "hello" in "hello world" should have a start position of 0 and an end
|
|
18
|
+
* position of 5.
|
|
19
|
+
*
|
|
20
|
+
* To see why, consider what happens if "llo wor" is removed from the string to make "held".
|
|
21
|
+
* The interval's startpoint remains on the "h" (it isn't altered), but the interval's endpoint
|
|
22
|
+
* slides forward to the next unremoved position, which is the "l" in "held".
|
|
23
|
+
* Users would generally expect the interval to now refer to "he" (as it is the subset of content
|
|
24
|
+
* remaining after the removal), hence the "l" should be excluded.
|
|
25
|
+
* If the interval endpoint was treated inclusively, the interval would now refer to "hel", which
|
|
26
|
+
* is undesirable.
|
|
27
|
+
*
|
|
28
|
+
* Since the end of an interval is treated exclusively but cannot be greater than or equal to the
|
|
29
|
+
* length of the associated sequence, application models which leverage interval collections should
|
|
30
|
+
* consider inserting a marker at the end of the sequence to represent the end of the content.
|
|
31
|
+
*/
|
|
32
|
+
export class SequenceInterval {
|
|
33
|
+
constructor(client,
|
|
34
|
+
/**
|
|
35
|
+
* Start endpoint of this interval.
|
|
36
|
+
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
37
|
+
*/
|
|
38
|
+
start,
|
|
39
|
+
/**
|
|
40
|
+
* End endpoint of this interval.
|
|
41
|
+
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
42
|
+
*/
|
|
43
|
+
end, intervalType, props, stickiness = IntervalStickiness.END) {
|
|
44
|
+
this.client = client;
|
|
45
|
+
this.start = start;
|
|
46
|
+
this.end = end;
|
|
47
|
+
this.intervalType = intervalType;
|
|
48
|
+
this.stickiness = stickiness;
|
|
49
|
+
this.propertyManager = new PropertiesManager();
|
|
50
|
+
this.properties = {};
|
|
51
|
+
if (props) {
|
|
52
|
+
this.addProperties(props);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Subscribes to position change events on this interval if there are no current listeners.
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
addPositionChangeListeners(beforePositionChange, afterPositionChange) {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
if (this.callbacks === undefined) {
|
|
62
|
+
this.callbacks = {
|
|
63
|
+
beforePositionChange,
|
|
64
|
+
afterPositionChange,
|
|
65
|
+
};
|
|
66
|
+
const startCbs = ((_a = this.start).callbacks ?? (_a.callbacks = {}));
|
|
67
|
+
const endCbs = ((_b = this.end).callbacks ?? (_b.callbacks = {}));
|
|
68
|
+
startCbs.beforeSlide = endCbs.beforeSlide = beforePositionChange;
|
|
69
|
+
startCbs.afterSlide = endCbs.afterSlide = afterPositionChange;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Removes the currently subscribed position change listeners.
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
removePositionChangeListeners() {
|
|
77
|
+
if (this.callbacks) {
|
|
78
|
+
this.callbacks = undefined;
|
|
79
|
+
this.start.callbacks = undefined;
|
|
80
|
+
this.end.callbacks = undefined;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* {@inheritDoc ISerializableInterval.serialize}
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
serialize() {
|
|
88
|
+
const startPosition = this.client.localReferencePositionToPosition(this.start);
|
|
89
|
+
const endPosition = this.client.localReferencePositionToPosition(this.end);
|
|
90
|
+
const serializedInterval = {
|
|
91
|
+
end: endPosition,
|
|
92
|
+
intervalType: this.intervalType,
|
|
93
|
+
sequenceNumber: this.client.getCurrentSeq(),
|
|
94
|
+
start: startPosition,
|
|
95
|
+
};
|
|
96
|
+
if (this.properties) {
|
|
97
|
+
serializedInterval.properties = this.properties;
|
|
98
|
+
}
|
|
99
|
+
if (this.stickiness !== IntervalStickiness.END) {
|
|
100
|
+
serializedInterval.stickiness = this.stickiness;
|
|
101
|
+
}
|
|
102
|
+
return serializedInterval;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* {@inheritDoc IInterval.clone}
|
|
106
|
+
*/
|
|
107
|
+
clone() {
|
|
108
|
+
return new SequenceInterval(this.client, this.start, this.end, this.intervalType, this.properties, this.stickiness);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* {@inheritDoc IInterval.compare}
|
|
112
|
+
*/
|
|
113
|
+
compare(b) {
|
|
114
|
+
const startResult = this.compareStart(b);
|
|
115
|
+
if (startResult === 0) {
|
|
116
|
+
const endResult = this.compareEnd(b);
|
|
117
|
+
if (endResult === 0) {
|
|
118
|
+
const thisId = this.getIntervalId();
|
|
119
|
+
if (thisId) {
|
|
120
|
+
const bId = b.getIntervalId();
|
|
121
|
+
if (bId) {
|
|
122
|
+
return thisId > bId ? 1 : thisId < bId ? -1 : 0;
|
|
123
|
+
}
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
return 0;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
return endResult;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
return startResult;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* {@inheritDoc IInterval.compareStart}
|
|
138
|
+
*/
|
|
139
|
+
compareStart(b) {
|
|
140
|
+
return compareReferencePositions(this.start, b.start);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* {@inheritDoc IInterval.compareEnd}
|
|
144
|
+
*/
|
|
145
|
+
compareEnd(b) {
|
|
146
|
+
return compareReferencePositions(this.end, b.end);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* {@inheritDoc IInterval.overlaps}
|
|
150
|
+
*/
|
|
151
|
+
overlaps(b) {
|
|
152
|
+
const result = compareReferencePositions(this.start, b.end) <= 0 &&
|
|
153
|
+
compareReferencePositions(this.end, b.start) >= 0;
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* {@inheritDoc ISerializableInterval.getIntervalId}
|
|
158
|
+
*/
|
|
159
|
+
getIntervalId() {
|
|
160
|
+
const id = this.properties?.[reservedIntervalIdKey];
|
|
161
|
+
assert(id !== undefined, 0x5e2 /* interval ID should not be undefined */);
|
|
162
|
+
return `${id}`;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* {@inheritDoc IInterval.union}
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
union(b) {
|
|
169
|
+
return new SequenceInterval(this.client, minReferencePosition(this.start, b.start), maxReferencePosition(this.end, b.end), this.intervalType);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* {@inheritDoc ISerializableInterval.addProperties}
|
|
173
|
+
* @internal
|
|
174
|
+
*/
|
|
175
|
+
addProperties(newProps, collab = false, seq, op) {
|
|
176
|
+
this.initializeProperties();
|
|
177
|
+
return this.propertyManager.addProperties(this.properties, newProps, op, seq, collab);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* @returns whether this interval overlaps two numerical positions.
|
|
181
|
+
*/
|
|
182
|
+
overlapsPos(bstart, bend) {
|
|
183
|
+
const startPos = this.client.localReferencePositionToPosition(this.start);
|
|
184
|
+
const endPos = this.client.localReferencePositionToPosition(this.end);
|
|
185
|
+
return endPos > bstart && startPos < bend;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* {@inheritDoc IInterval.modify}
|
|
189
|
+
* @internal
|
|
190
|
+
*/
|
|
191
|
+
modify(label, start, end, op, localSeq, stickiness = IntervalStickiness.END) {
|
|
192
|
+
const getRefType = (baseType) => {
|
|
193
|
+
let refType = baseType;
|
|
194
|
+
if (op === undefined) {
|
|
195
|
+
refType &= ~ReferenceType.SlideOnRemove;
|
|
196
|
+
refType |= ReferenceType.StayOnRemove;
|
|
197
|
+
}
|
|
198
|
+
return refType;
|
|
199
|
+
};
|
|
200
|
+
let startRef = this.start;
|
|
201
|
+
if (start !== undefined) {
|
|
202
|
+
startRef = createPositionReference(this.client, start, getRefType(this.start.refType), op, undefined, localSeq, startReferenceSlidingPreference(stickiness));
|
|
203
|
+
if (this.start.properties) {
|
|
204
|
+
startRef.addProperties(this.start.properties);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
let endRef = this.end;
|
|
208
|
+
if (end !== undefined) {
|
|
209
|
+
endRef = createPositionReference(this.client, end, getRefType(this.end.refType), op, undefined, localSeq, endReferenceSlidingPreference(stickiness));
|
|
210
|
+
if (this.end.properties) {
|
|
211
|
+
endRef.addProperties(this.end.properties);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const newInterval = new SequenceInterval(this.client, startRef, endRef, this.intervalType);
|
|
215
|
+
if (this.properties) {
|
|
216
|
+
newInterval.initializeProperties();
|
|
217
|
+
this.propertyManager.copyTo(this.properties, newInterval.properties, newInterval.propertyManager);
|
|
218
|
+
}
|
|
219
|
+
return newInterval;
|
|
220
|
+
}
|
|
221
|
+
initializeProperties() {
|
|
222
|
+
if (!this.propertyManager) {
|
|
223
|
+
this.propertyManager = new PropertiesManager();
|
|
224
|
+
}
|
|
225
|
+
if (!this.properties) {
|
|
226
|
+
this.properties = createMap();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
export function createPositionReferenceFromSegoff(client, segoff, refType, op, localSeq, fromSnapshot, slidingPreference) {
|
|
231
|
+
if (segoff.segment) {
|
|
232
|
+
const ref = client.createLocalReferencePosition(segoff.segment, segoff.offset, refType, undefined, slidingPreference);
|
|
233
|
+
return ref;
|
|
234
|
+
}
|
|
235
|
+
// Creating references on detached segments is allowed for:
|
|
236
|
+
// - Transient segments
|
|
237
|
+
// - References coming from a remote client (location may have been concurrently removed)
|
|
238
|
+
// - References being rebased to a new sequence number
|
|
239
|
+
// (segment they originally referred to may have been removed with no suitable replacement)
|
|
240
|
+
if (!op &&
|
|
241
|
+
!localSeq &&
|
|
242
|
+
!fromSnapshot &&
|
|
243
|
+
!refTypeIncludesFlag(refType, ReferenceType.Transient)) {
|
|
244
|
+
throw new UsageError("Non-transient references need segment");
|
|
245
|
+
}
|
|
246
|
+
return createDetachedLocalReferencePosition(refType);
|
|
247
|
+
}
|
|
248
|
+
function createPositionReference(client, pos, refType, op, fromSnapshot, localSeq, slidingPreference) {
|
|
249
|
+
let segoff;
|
|
250
|
+
if (op) {
|
|
251
|
+
assert((refType & ReferenceType.SlideOnRemove) !== 0, 0x2f5 /* op create references must be SlideOnRemove */);
|
|
252
|
+
segoff = client.getContainingSegment(pos, {
|
|
253
|
+
referenceSequenceNumber: op.referenceSequenceNumber,
|
|
254
|
+
clientId: op.clientId,
|
|
255
|
+
});
|
|
256
|
+
segoff = getSlideToSegoff(segoff);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
assert((refType & ReferenceType.SlideOnRemove) === 0 || !!fromSnapshot, 0x2f6 /* SlideOnRemove references must be op created */);
|
|
260
|
+
segoff = client.getContainingSegment(pos, undefined, localSeq);
|
|
261
|
+
}
|
|
262
|
+
return createPositionReferenceFromSegoff(client, segoff, refType, op, localSeq, fromSnapshot, slidingPreference);
|
|
263
|
+
}
|
|
264
|
+
export function createSequenceInterval(label, start, end, client, intervalType, op, fromSnapshot, stickiness = IntervalStickiness.END) {
|
|
265
|
+
let beginRefType = ReferenceType.RangeBegin;
|
|
266
|
+
let endRefType = ReferenceType.RangeEnd;
|
|
267
|
+
if (intervalType === IntervalType.Transient) {
|
|
268
|
+
beginRefType = ReferenceType.Transient;
|
|
269
|
+
endRefType = ReferenceType.Transient;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
if (intervalType === IntervalType.Nest) {
|
|
273
|
+
beginRefType = ReferenceType.NestBegin;
|
|
274
|
+
endRefType = ReferenceType.NestEnd;
|
|
275
|
+
}
|
|
276
|
+
// All non-transient interval references must eventually be SlideOnRemove
|
|
277
|
+
// To ensure eventual consistency, they must start as StayOnRemove when
|
|
278
|
+
// pending (created locally and creation op is not acked)
|
|
279
|
+
if (op || fromSnapshot) {
|
|
280
|
+
beginRefType |= ReferenceType.SlideOnRemove;
|
|
281
|
+
endRefType |= ReferenceType.SlideOnRemove;
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
beginRefType |= ReferenceType.StayOnRemove;
|
|
285
|
+
endRefType |= ReferenceType.StayOnRemove;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const startLref = createPositionReference(client, start, beginRefType, op, fromSnapshot, undefined, startReferenceSlidingPreference(stickiness));
|
|
289
|
+
const endLref = createPositionReference(client, end, endRefType, op, fromSnapshot, undefined, endReferenceSlidingPreference(stickiness));
|
|
290
|
+
const rangeProp = {
|
|
291
|
+
[reservedRangeLabelsKey]: [label],
|
|
292
|
+
};
|
|
293
|
+
startLref.addProperties(rangeProp);
|
|
294
|
+
endLref.addProperties(rangeProp);
|
|
295
|
+
const ival = new SequenceInterval(client, startLref, endLref, intervalType, rangeProp, stickiness);
|
|
296
|
+
return ival;
|
|
297
|
+
}
|
|
298
|
+
export const compareSequenceIntervalEnds = (a, b) => compareReferencePositions(a.end, b.end);
|
|
299
|
+
export const compareSequenceIntervalStarts = (a, b) => compareReferencePositions(a.start, b.start);
|
|
300
|
+
export const sequenceIntervalHelpers = {
|
|
301
|
+
compareEnds: compareSequenceIntervalEnds,
|
|
302
|
+
compareStarts: compareSequenceIntervalStarts,
|
|
303
|
+
create: createSequenceInterval,
|
|
304
|
+
};
|
|
305
|
+
//# sourceMappingURL=sequenceInterval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequenceInterval.js","sourceRoot":"","sources":["../../src/intervals/sequenceInterval.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAE/B,OAAO,EAKN,iBAAiB,EAEjB,aAAa,EAEb,yBAAyB,EACzB,oCAAoC,EACpC,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAIN,kBAAkB,EAClB,YAAY,EACZ,6BAA6B,EAC7B,+BAA+B,GAC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AAuB,CACxC,MAAM,EACN,KAAK,EACL,YAAY,EACZ,EAAE,EACF,YAAY,EACZ,SAAS,EACT,+BAA+B,CAAC,UAAU,CAAC,CAC3C,CAAC;IAEF,MAAM,OAAO,GAAG,uBAAuB,CACtC,MAAM,EACN,GAAG,EACH,UAAU,EACV,EAAE,EACF,YAAY,EACZ,SAAS,EACT,6BAA6B,CAAC,UAAU,CAAC,CACzC,CAAC;IAEF,MAAM,SAAS,GAAG;QACjB,CAAC,sBAAsB,CAAC,EAAE,CAAC,KAAK,CAAC;KACjC,CAAC;IACF,SAAS,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAEjC,MAAM,IAAI,GAAG,IAAI,gBAAgB,CAChC,MAAM,EACN,SAAS,EACT,OAAO,EACP,YAAY,EACZ,SAAS,EACT,UAAU,CACV,CAAC;IACF,OAAO,IAAI,CAAC;AACb,CAAC;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAmB,EAAE,CAAmB,EAAU,EAAE,CAC/F,yBAAyB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AAEzC,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAmB,EAAE,CAAmB,EAAU,EAAE,CACjG,yBAAyB,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,uBAAuB,GAAuC;IAC1E,WAAW,EAAE,2BAA2B;IACxC,aAAa,EAAE,6BAA6B;IAC5C,MAAM,EAAE,sBAAsB;CAC9B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport {\n\tClient,\n\tICombiningOp,\n\tISegment,\n\tLocalReferencePosition,\n\tPropertiesManager,\n\tPropertySet,\n\tReferenceType,\n\tSlidingPreference,\n\tcompareReferencePositions,\n\tcreateDetachedLocalReferencePosition,\n\tcreateMap,\n\tgetSlideToSegoff,\n\tmaxReferencePosition,\n\tminReferencePosition,\n\trefTypeIncludesFlag,\n\treservedRangeLabelsKey,\n} from \"@fluidframework/merge-tree\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { UsageError } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIIntervalHelpers,\n\tISerializableInterval,\n\tISerializedInterval,\n\tIntervalStickiness,\n\tIntervalType,\n\tendReferenceSlidingPreference,\n\tstartReferenceSlidingPreference,\n} from \"./intervalUtils\";\n\nconst reservedIntervalIdKey = \"intervalId\";\n\n/**\n * Interval implementation whose ends are associated with positions in a mutatable sequence.\n * As such, when content is inserted into the middle of the interval, the interval expands to\n * include that content.\n *\n * @remarks The endpoint's position should be treated exclusively to get reasonable behavior--i.e.\n * an interval referring to \"hello\" in \"hello world\" should have a start position of 0 and an end\n * position of 5.\n *\n * To see why, consider what happens if \"llo wor\" is removed from the string to make \"held\".\n * The interval's startpoint remains on the \"h\" (it isn't altered), but the interval's endpoint\n * slides forward to the next unremoved position, which is the \"l\" in \"held\".\n * Users would generally expect the interval to now refer to \"he\" (as it is the subset of content\n * remaining after the removal), hence the \"l\" should be excluded.\n * If the interval endpoint was treated inclusively, the interval would now refer to \"hel\", which\n * is undesirable.\n *\n * Since the end of an interval is treated exclusively but cannot be greater than or equal to the\n * length of the associated sequence, application models which leverage interval collections should\n * consider inserting a marker at the end of the sequence to represent the end of the content.\n */\nexport class SequenceInterval implements ISerializableInterval {\n\t/**\n\t * {@inheritDoc ISerializableInterval.properties}\n\t */\n\tpublic properties: PropertySet;\n\t/**\n\t * {@inheritDoc ISerializableInterval.propertyManager}\n\t * @internal\n\t */\n\tpublic propertyManager: PropertiesManager;\n\n\tconstructor(\n\t\tprivate readonly client: Client,\n\t\t/**\n\t\t * Start endpoint of this interval.\n\t\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t\t */\n\t\tpublic start: LocalReferencePosition,\n\t\t/**\n\t\t * End endpoint of this interval.\n\t\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t\t */\n\t\tpublic end: LocalReferencePosition,\n\t\tpublic intervalType: IntervalType,\n\t\tprops?: PropertySet,\n\t\tpublic readonly stickiness: IntervalStickiness = IntervalStickiness.END,\n\t) {\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\tprivate callbacks?: Record<\"beforePositionChange\" | \"afterPositionChange\", () => void>;\n\n\t/**\n\t * Subscribes to position change events on this interval if there are no current listeners.\n\t * @internal\n\t */\n\tpublic addPositionChangeListeners(\n\t\tbeforePositionChange: () => void,\n\t\tafterPositionChange: () => void,\n\t): void {\n\t\tif (this.callbacks === undefined) {\n\t\t\tthis.callbacks = {\n\t\t\t\tbeforePositionChange,\n\t\t\t\tafterPositionChange,\n\t\t\t};\n\n\t\t\tconst startCbs = (this.start.callbacks ??= {});\n\t\t\tconst endCbs = (this.end.callbacks ??= {});\n\t\t\tstartCbs.beforeSlide = endCbs.beforeSlide = beforePositionChange;\n\t\t\tstartCbs.afterSlide = endCbs.afterSlide = afterPositionChange;\n\t\t}\n\t}\n\n\t/**\n\t * Removes the currently subscribed position change listeners.\n\t * @internal\n\t */\n\tpublic removePositionChangeListeners(): void {\n\t\tif (this.callbacks) {\n\t\t\tthis.callbacks = undefined;\n\t\t\tthis.start.callbacks = undefined;\n\t\t\tthis.end.callbacks = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.serialize}\n\t * @internal\n\t */\n\tpublic serialize(): ISerializedInterval {\n\t\tconst startPosition = this.client.localReferencePositionToPosition(this.start);\n\t\tconst endPosition = this.client.localReferencePositionToPosition(this.end);\n\t\tconst serializedInterval: ISerializedInterval = {\n\t\t\tend: endPosition,\n\t\t\tintervalType: this.intervalType,\n\t\t\tsequenceNumber: this.client.getCurrentSeq(),\n\t\t\tstart: startPosition,\n\t\t};\n\n\t\tif (this.properties) {\n\t\t\tserializedInterval.properties = this.properties;\n\t\t}\n\t\tif (this.stickiness !== IntervalStickiness.END) {\n\t\t\tserializedInterval.stickiness = this.stickiness;\n\t\t}\n\n\t\treturn serializedInterval;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.clone}\n\t */\n\tpublic clone() {\n\t\treturn new SequenceInterval(\n\t\t\tthis.client,\n\t\t\tthis.start,\n\t\t\tthis.end,\n\t\t\tthis.intervalType,\n\t\t\tthis.properties,\n\t\t\tthis.stickiness,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compare}\n\t */\n\tpublic compare(b: SequenceInterval) {\n\t\tconst startResult = this.compareStart(b);\n\t\tif (startResult === 0) {\n\t\t\tconst endResult = this.compareEnd(b);\n\t\t\tif (endResult === 0) {\n\t\t\t\tconst thisId = this.getIntervalId();\n\t\t\t\tif (thisId) {\n\t\t\t\t\tconst bId = b.getIntervalId();\n\t\t\t\t\tif (bId) {\n\t\t\t\t\t\treturn thisId > bId ? 1 : thisId < bId ? -1 : 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn endResult;\n\t\t\t}\n\t\t} else {\n\t\t\treturn startResult;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareStart}\n\t */\n\tpublic compareStart(b: SequenceInterval) {\n\t\treturn compareReferencePositions(this.start, b.start);\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareEnd}\n\t */\n\tpublic compareEnd(b: SequenceInterval) {\n\t\treturn compareReferencePositions(this.end, b.end);\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.overlaps}\n\t */\n\tpublic overlaps(b: SequenceInterval) {\n\t\tconst result =\n\t\t\tcompareReferencePositions(this.start, b.end) <= 0 &&\n\t\t\tcompareReferencePositions(this.end, b.start) >= 0;\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.getIntervalId}\n\t */\n\tpublic getIntervalId(): string {\n\t\tconst id = this.properties?.[reservedIntervalIdKey];\n\t\tassert(id !== undefined, 0x5e2 /* interval ID should not be undefined */);\n\t\treturn `${id}`;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.union}\n\t * @internal\n\t */\n\tpublic union(b: SequenceInterval) {\n\t\treturn new SequenceInterval(\n\t\t\tthis.client,\n\t\t\tminReferencePosition(this.start, b.start),\n\t\t\tmaxReferencePosition(this.end, b.end),\n\t\t\tthis.intervalType,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.addProperties}\n\t * @internal\n\t */\n\tpublic addProperties(\n\t\tnewProps: PropertySet,\n\t\tcollab: boolean = false,\n\t\tseq?: number,\n\t\top?: ICombiningOp,\n\t): PropertySet | undefined {\n\t\tthis.initializeProperties();\n\t\treturn this.propertyManager.addProperties(this.properties, newProps, op, seq, collab);\n\t}\n\n\t/**\n\t * @returns whether this interval overlaps two numerical positions.\n\t */\n\tpublic overlapsPos(bstart: number, bend: number) {\n\t\tconst startPos = this.client.localReferencePositionToPosition(this.start);\n\t\tconst endPos = this.client.localReferencePositionToPosition(this.end);\n\t\treturn endPos > bstart && startPos < bend;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.modify}\n\t * @internal\n\t */\n\tpublic modify(\n\t\tlabel: string,\n\t\tstart: number,\n\t\tend: number,\n\t\top?: ISequencedDocumentMessage,\n\t\tlocalSeq?: number,\n\t\tstickiness: IntervalStickiness = IntervalStickiness.END,\n\t) {\n\t\tconst getRefType = (baseType: ReferenceType): ReferenceType => {\n\t\t\tlet refType = baseType;\n\t\t\tif (op === undefined) {\n\t\t\t\trefType &= ~ReferenceType.SlideOnRemove;\n\t\t\t\trefType |= ReferenceType.StayOnRemove;\n\t\t\t}\n\t\t\treturn refType;\n\t\t};\n\n\t\tlet startRef = this.start;\n\t\tif (start !== undefined) {\n\t\t\tstartRef = createPositionReference(\n\t\t\t\tthis.client,\n\t\t\t\tstart,\n\t\t\t\tgetRefType(this.start.refType),\n\t\t\t\top,\n\t\t\t\tundefined,\n\t\t\t\tlocalSeq,\n\t\t\t\tstartReferenceSlidingPreference(stickiness),\n\t\t\t);\n\t\t\tif (this.start.properties) {\n\t\t\t\tstartRef.addProperties(this.start.properties);\n\t\t\t}\n\t\t}\n\n\t\tlet endRef = this.end;\n\t\tif (end !== undefined) {\n\t\t\tendRef = createPositionReference(\n\t\t\t\tthis.client,\n\t\t\t\tend,\n\t\t\t\tgetRefType(this.end.refType),\n\t\t\t\top,\n\t\t\t\tundefined,\n\t\t\t\tlocalSeq,\n\t\t\t\tendReferenceSlidingPreference(stickiness),\n\t\t\t);\n\t\t\tif (this.end.properties) {\n\t\t\t\tendRef.addProperties(this.end.properties);\n\t\t\t}\n\t\t}\n\n\t\tconst newInterval = new SequenceInterval(this.client, startRef, endRef, this.intervalType);\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 createPositionReferenceFromSegoff(\n\tclient: Client,\n\tsegoff: { segment: ISegment | undefined; offset: number | undefined },\n\trefType: ReferenceType,\n\top?: ISequencedDocumentMessage,\n\tlocalSeq?: number,\n\tfromSnapshot?: boolean,\n\tslidingPreference?: SlidingPreference,\n): LocalReferencePosition {\n\tif (segoff.segment) {\n\t\tconst ref = client.createLocalReferencePosition(\n\t\t\tsegoff.segment,\n\t\t\tsegoff.offset,\n\t\t\trefType,\n\t\t\tundefined,\n\t\t\tslidingPreference,\n\t\t);\n\t\treturn ref;\n\t}\n\n\t// Creating references on detached segments is allowed for:\n\t// - Transient segments\n\t// - References coming from a remote client (location may have been concurrently removed)\n\t// - References being rebased to a new sequence number\n\t// (segment they originally referred to may have been removed with no suitable replacement)\n\tif (\n\t\t!op &&\n\t\t!localSeq &&\n\t\t!fromSnapshot &&\n\t\t!refTypeIncludesFlag(refType, ReferenceType.Transient)\n\t) {\n\t\tthrow new UsageError(\"Non-transient references need segment\");\n\t}\n\n\treturn createDetachedLocalReferencePosition(refType);\n}\n\nfunction createPositionReference(\n\tclient: Client,\n\tpos: number,\n\trefType: ReferenceType,\n\top?: ISequencedDocumentMessage,\n\tfromSnapshot?: boolean,\n\tlocalSeq?: number,\n\tslidingPreference?: SlidingPreference,\n): LocalReferencePosition {\n\tlet segoff;\n\tif (op) {\n\t\tassert(\n\t\t\t(refType & ReferenceType.SlideOnRemove) !== 0,\n\t\t\t0x2f5 /* op create references must be SlideOnRemove */,\n\t\t);\n\t\tsegoff = client.getContainingSegment(pos, {\n\t\t\treferenceSequenceNumber: op.referenceSequenceNumber,\n\t\t\tclientId: op.clientId,\n\t\t});\n\t\tsegoff = getSlideToSegoff(segoff);\n\t} else {\n\t\tassert(\n\t\t\t(refType & ReferenceType.SlideOnRemove) === 0 || !!fromSnapshot,\n\t\t\t0x2f6 /* SlideOnRemove references must be op created */,\n\t\t);\n\t\tsegoff = client.getContainingSegment(pos, undefined, localSeq);\n\t}\n\n\treturn createPositionReferenceFromSegoff(\n\t\tclient,\n\t\tsegoff,\n\t\trefType,\n\t\top,\n\t\tlocalSeq,\n\t\tfromSnapshot,\n\t\tslidingPreference,\n\t);\n}\n\nexport function createSequenceInterval(\n\tlabel: string,\n\tstart: number,\n\tend: number,\n\tclient: Client,\n\tintervalType: IntervalType,\n\top?: ISequencedDocumentMessage,\n\tfromSnapshot?: boolean,\n\tstickiness: IntervalStickiness = IntervalStickiness.END,\n): SequenceInterval {\n\tlet beginRefType = ReferenceType.RangeBegin;\n\tlet endRefType = ReferenceType.RangeEnd;\n\tif (intervalType === IntervalType.Transient) {\n\t\tbeginRefType = ReferenceType.Transient;\n\t\tendRefType = ReferenceType.Transient;\n\t} else {\n\t\tif (intervalType === IntervalType.Nest) {\n\t\t\tbeginRefType = ReferenceType.NestBegin;\n\t\t\tendRefType = ReferenceType.NestEnd;\n\t\t}\n\t\t// All non-transient interval references must eventually be SlideOnRemove\n\t\t// To ensure eventual consistency, they must start as StayOnRemove when\n\t\t// pending (created locally and creation op is not acked)\n\t\tif (op || fromSnapshot) {\n\t\t\tbeginRefType |= ReferenceType.SlideOnRemove;\n\t\t\tendRefType |= ReferenceType.SlideOnRemove;\n\t\t} else {\n\t\t\tbeginRefType |= ReferenceType.StayOnRemove;\n\t\t\tendRefType |= ReferenceType.StayOnRemove;\n\t\t}\n\t}\n\n\tconst startLref = createPositionReference(\n\t\tclient,\n\t\tstart,\n\t\tbeginRefType,\n\t\top,\n\t\tfromSnapshot,\n\t\tundefined,\n\t\tstartReferenceSlidingPreference(stickiness),\n\t);\n\n\tconst endLref = createPositionReference(\n\t\tclient,\n\t\tend,\n\t\tendRefType,\n\t\top,\n\t\tfromSnapshot,\n\t\tundefined,\n\t\tendReferenceSlidingPreference(stickiness),\n\t);\n\n\tconst rangeProp = {\n\t\t[reservedRangeLabelsKey]: [label],\n\t};\n\tstartLref.addProperties(rangeProp);\n\tendLref.addProperties(rangeProp);\n\n\tconst ival = new SequenceInterval(\n\t\tclient,\n\t\tstartLref,\n\t\tendLref,\n\t\tintervalType,\n\t\trangeProp,\n\t\tstickiness,\n\t);\n\treturn ival;\n}\n\nexport const compareSequenceIntervalEnds = (a: SequenceInterval, b: SequenceInterval): number =>\n\tcompareReferencePositions(a.end, b.end);\n\nexport const compareSequenceIntervalStarts = (a: SequenceInterval, b: SequenceInterval): number =>\n\tcompareReferencePositions(a.start, b.start);\n\nexport const sequenceIntervalHelpers: IIntervalHelpers<SequenceInterval> = {\n\tcompareEnds: compareSequenceIntervalEnds,\n\tcompareStarts: compareSequenceIntervalStarts,\n\tcreate: createSequenceInterval,\n};\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/sequence";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-dev.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-dev.6.4.0.191457";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export const pkgName = "@fluidframework/sequence";
|
|
8
|
-
export const pkgVersion = "2.0.0-dev.
|
|
8
|
+
export const pkgVersion = "2.0.0-dev.6.4.0.191457";
|
|
9
9
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.0.0-dev.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.0.0-dev.6.4.0.191457\";\n"]}
|
package/lib/revertibles.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { LocalReferencePosition, MergeTreeDeltaRevertible, PropertySet } from "@fluidframework/merge-tree";
|
|
6
|
-
import { IntervalOpType, SequenceInterval } from "./
|
|
6
|
+
import { IntervalOpType, SequenceInterval } from "./intervals";
|
|
7
7
|
import { SharedString } from "./sharedString";
|
|
8
8
|
import { SequenceDeltaEvent } from "./sequenceDeltaEvent";
|
|
9
9
|
/**
|
package/lib/revertibles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revertibles.d.ts","sourceRoot":"","sources":["../src/revertibles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAIN,sBAAsB,EAEtB,wBAAwB,EAExB,WAAW,EAMX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"revertibles.d.ts","sourceRoot":"","sources":["../src/revertibles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAIN,sBAAsB,EAEtB,wBAAwB,EAExB,WAAW,EAMX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAuB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAuB,kBAAkB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