@fluidframework/sequence 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.224419
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/.eslintrc.js +9 -11
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +449 -0
- package/README.md +364 -183
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/sequence.api.md +741 -0
- package/dist/{defaultMap.js → defaultMap.cjs} +29 -22
- package/dist/defaultMap.cjs.map +1 -0
- package/dist/defaultMap.d.ts +7 -6
- package/dist/defaultMap.d.ts.map +1 -1
- package/dist/defaultMapInterfaces.cjs +7 -0
- package/dist/defaultMapInterfaces.cjs.map +1 -0
- package/dist/defaultMapInterfaces.d.ts +44 -12
- package/dist/defaultMapInterfaces.d.ts.map +1 -1
- package/dist/index.cjs +60 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +14 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/intervalCollection.cjs +1159 -0
- package/dist/intervalCollection.cjs.map +1 -0
- package/dist/intervalCollection.d.ts +461 -162
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalIndex/endpointInRangeIndex.cjs +66 -0
- package/dist/intervalIndex/endpointInRangeIndex.cjs.map +1 -0
- package/dist/intervalIndex/endpointInRangeIndex.d.ts +34 -0
- package/dist/intervalIndex/endpointInRangeIndex.d.ts.map +1 -0
- package/dist/intervalIndex/endpointIndex.cjs +47 -0
- package/dist/intervalIndex/endpointIndex.cjs.map +1 -0
- package/dist/intervalIndex/endpointIndex.d.ts +38 -0
- package/dist/intervalIndex/endpointIndex.d.ts.map +1 -0
- package/dist/intervalIndex/idIntervalIndex.cjs +44 -0
- package/dist/intervalIndex/idIntervalIndex.cjs.map +1 -0
- package/dist/intervalIndex/idIntervalIndex.d.ts +18 -0
- package/dist/intervalIndex/idIntervalIndex.d.ts.map +1 -0
- package/dist/intervalIndex/index.cjs +24 -0
- package/dist/intervalIndex/index.cjs.map +1 -0
- package/dist/intervalIndex/index.d.ts +13 -0
- package/dist/intervalIndex/index.d.ts.map +1 -0
- package/dist/{defaultMapInterfaces.js → intervalIndex/intervalIndex.cjs} +1 -1
- package/dist/intervalIndex/intervalIndex.cjs.map +1 -0
- package/dist/intervalIndex/intervalIndex.d.ts +30 -0
- package/dist/intervalIndex/intervalIndex.d.ts.map +1 -0
- package/dist/intervalIndex/intervalIndexUtils.cjs +22 -0
- package/dist/intervalIndex/intervalIndexUtils.cjs.map +1 -0
- package/dist/intervalIndex/intervalIndexUtils.d.ts +17 -0
- package/dist/intervalIndex/intervalIndexUtils.d.ts.map +1 -0
- package/dist/intervalIndex/overlappingIntervalsIndex.cjs +116 -0
- package/dist/intervalIndex/overlappingIntervalsIndex.cjs.map +1 -0
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +44 -0
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -0
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.cjs +41 -0
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.cjs.map +1 -0
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +11 -0
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -0
- package/dist/intervalIndex/sequenceIntervalIndexes.cjs +7 -0
- package/dist/intervalIndex/sequenceIntervalIndexes.cjs.map +1 -0
- package/dist/intervalIndex/sequenceIntervalIndexes.d.ts +35 -0
- package/dist/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -0
- package/dist/intervalIndex/startpointInRangeIndex.cjs +66 -0
- package/dist/intervalIndex/startpointInRangeIndex.cjs.map +1 -0
- package/dist/intervalIndex/startpointInRangeIndex.d.ts +34 -0
- package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -0
- package/dist/intervalTree.cjs +80 -0
- package/dist/intervalTree.cjs.map +1 -0
- package/dist/intervalTree.d.ts +24 -0
- package/dist/intervalTree.d.ts.map +1 -0
- package/dist/intervals/index.cjs +23 -0
- package/dist/intervals/index.cjs.map +1 -0
- package/dist/intervals/index.d.ts +8 -0
- package/dist/intervals/index.d.ts.map +1 -0
- package/dist/intervals/interval.cjs +181 -0
- package/dist/intervals/interval.cjs.map +1 -0
- package/dist/intervals/interval.d.ts +84 -0
- package/dist/intervals/interval.d.ts.map +1 -0
- package/dist/intervals/intervalUtils.cjs +83 -0
- package/dist/intervals/intervalUtils.cjs.map +1 -0
- package/dist/intervals/intervalUtils.d.ts +230 -0
- package/dist/intervals/intervalUtils.d.ts.map +1 -0
- package/dist/intervals/sequenceInterval.cjs +378 -0
- package/dist/intervals/sequenceInterval.cjs.map +1 -0
- package/dist/intervals/sequenceInterval.d.ts +137 -0
- package/dist/intervals/sequenceInterval.d.ts.map +1 -0
- package/dist/{localValues.js → localValues.cjs} +1 -1
- package/dist/localValues.cjs.map +1 -0
- package/dist/localValues.d.ts +2 -1
- package/dist/localValues.d.ts.map +1 -1
- package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
- package/dist/packageVersion.cjs.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/revertibles.cjs +425 -0
- package/dist/revertibles.cjs.map +1 -0
- package/dist/revertibles.d.ts +86 -0
- package/dist/revertibles.d.ts.map +1 -0
- package/dist/sequence-alpha.d.ts +1315 -0
- package/dist/sequence-beta.d.ts +244 -0
- package/dist/sequence-public.d.ts +244 -0
- package/dist/sequence-untrimmed.d.ts +1803 -0
- package/dist/{sequence.js → sequence.cjs} +226 -156
- package/dist/sequence.cjs.map +1 -0
- package/dist/sequence.d.ts +125 -48
- package/dist/sequence.d.ts.map +1 -1
- package/dist/{sequenceDeltaEvent.js → sequenceDeltaEvent.cjs} +18 -8
- package/dist/sequenceDeltaEvent.cjs.map +1 -0
- package/dist/sequenceDeltaEvent.d.ts +24 -7
- package/dist/sequenceDeltaEvent.d.ts.map +1 -1
- package/dist/sequenceFactory.cjs +55 -0
- package/dist/sequenceFactory.cjs.map +1 -0
- package/dist/sequenceFactory.d.ts +3 -89
- package/dist/sequenceFactory.d.ts.map +1 -1
- package/dist/{sharedIntervalCollection.js → sharedIntervalCollection.cjs} +17 -22
- package/dist/sharedIntervalCollection.cjs.map +1 -0
- package/dist/sharedIntervalCollection.d.ts +12 -12
- package/dist/sharedIntervalCollection.d.ts.map +1 -1
- package/dist/{sharedSequence.js → sharedSequence.cjs} +29 -22
- package/dist/sharedSequence.cjs.map +1 -0
- package/dist/sharedSequence.d.ts +14 -2
- package/dist/sharedSequence.d.ts.map +1 -1
- package/dist/sharedString.cjs +286 -0
- package/dist/sharedString.cjs.map +1 -0
- package/dist/sharedString.d.ts +58 -22
- package/dist/sharedString.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/{defaultMap.d.ts → defaultMap.d.mts} +7 -6
- package/lib/defaultMap.d.mts.map +1 -0
- package/lib/{defaultMap.js → defaultMap.mjs} +28 -21
- package/lib/defaultMap.mjs.map +1 -0
- package/lib/{defaultMapInterfaces.d.ts → defaultMapInterfaces.d.mts} +44 -12
- package/lib/defaultMapInterfaces.d.mts.map +1 -0
- package/lib/defaultMapInterfaces.mjs +6 -0
- package/lib/defaultMapInterfaces.mjs.map +1 -0
- package/lib/index.d.mts +17 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +16 -0
- package/lib/index.mjs.map +1 -0
- package/lib/intervalCollection.d.mts +569 -0
- package/lib/intervalCollection.d.mts.map +1 -0
- package/lib/intervalCollection.mjs +1144 -0
- package/lib/intervalCollection.mjs.map +1 -0
- package/lib/intervalIndex/endpointInRangeIndex.d.mts +34 -0
- package/lib/intervalIndex/endpointInRangeIndex.d.mts.map +1 -0
- package/lib/intervalIndex/endpointInRangeIndex.mjs +61 -0
- package/lib/intervalIndex/endpointInRangeIndex.mjs.map +1 -0
- package/lib/intervalIndex/endpointIndex.d.mts +38 -0
- package/lib/intervalIndex/endpointIndex.d.mts.map +1 -0
- package/lib/intervalIndex/endpointIndex.mjs +42 -0
- package/lib/intervalIndex/endpointIndex.mjs.map +1 -0
- package/lib/intervalIndex/idIntervalIndex.d.mts +18 -0
- package/lib/intervalIndex/idIntervalIndex.d.mts.map +1 -0
- package/lib/intervalIndex/idIntervalIndex.mjs +40 -0
- package/lib/intervalIndex/idIntervalIndex.mjs.map +1 -0
- package/lib/intervalIndex/index.d.mts +13 -0
- package/lib/intervalIndex/index.d.mts.map +1 -0
- package/lib/intervalIndex/index.mjs +11 -0
- package/lib/intervalIndex/index.mjs.map +1 -0
- package/lib/intervalIndex/intervalIndex.d.mts +30 -0
- package/lib/intervalIndex/intervalIndex.d.mts.map +1 -0
- package/lib/{defaultMapInterfaces.js → intervalIndex/intervalIndex.mjs} +1 -1
- package/lib/intervalIndex/intervalIndex.mjs.map +1 -0
- package/lib/intervalIndex/intervalIndexUtils.d.mts +17 -0
- package/lib/intervalIndex/intervalIndexUtils.d.mts.map +1 -0
- package/lib/intervalIndex/intervalIndexUtils.mjs +18 -0
- package/lib/intervalIndex/intervalIndexUtils.mjs.map +1 -0
- package/lib/intervalIndex/overlappingIntervalsIndex.d.mts +44 -0
- package/lib/intervalIndex/overlappingIntervalsIndex.d.mts.map +1 -0
- package/lib/intervalIndex/overlappingIntervalsIndex.mjs +111 -0
- package/lib/intervalIndex/overlappingIntervalsIndex.mjs.map +1 -0
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.mts +11 -0
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.mts.map +1 -0
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.mjs +37 -0
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.mjs.map +1 -0
- package/lib/intervalIndex/sequenceIntervalIndexes.d.mts +35 -0
- package/lib/intervalIndex/sequenceIntervalIndexes.d.mts.map +1 -0
- package/lib/intervalIndex/sequenceIntervalIndexes.mjs +6 -0
- package/lib/intervalIndex/sequenceIntervalIndexes.mjs.map +1 -0
- package/lib/intervalIndex/startpointInRangeIndex.d.mts +34 -0
- package/lib/intervalIndex/startpointInRangeIndex.d.mts.map +1 -0
- package/lib/intervalIndex/startpointInRangeIndex.mjs +61 -0
- package/lib/intervalIndex/startpointInRangeIndex.mjs.map +1 -0
- package/lib/intervalTree.d.mts +24 -0
- package/lib/intervalTree.d.mts.map +1 -0
- package/lib/intervalTree.mjs +76 -0
- package/lib/intervalTree.mjs.map +1 -0
- package/lib/intervals/index.d.mts +8 -0
- package/lib/intervals/index.d.mts.map +1 -0
- package/lib/intervals/index.mjs +8 -0
- package/lib/intervals/index.mjs.map +1 -0
- package/lib/intervals/interval.d.mts +84 -0
- package/lib/intervals/interval.d.mts.map +1 -0
- package/lib/intervals/interval.mjs +176 -0
- package/lib/intervals/interval.mjs.map +1 -0
- package/lib/intervals/intervalUtils.d.mts +230 -0
- package/lib/intervals/intervalUtils.d.mts.map +1 -0
- package/lib/intervals/intervalUtils.mjs +77 -0
- package/lib/intervals/intervalUtils.mjs.map +1 -0
- package/lib/intervals/sequenceInterval.d.mts +137 -0
- package/lib/intervals/sequenceInterval.d.mts.map +1 -0
- package/lib/intervals/sequenceInterval.mjs +370 -0
- package/lib/intervals/sequenceInterval.mjs.map +1 -0
- package/lib/{localValues.d.ts → localValues.d.mts} +3 -2
- package/lib/localValues.d.mts.map +1 -0
- package/lib/{localValues.js → localValues.mjs} +2 -2
- package/lib/localValues.mjs.map +1 -0
- package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
- package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +1 -1
- package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
- package/lib/packageVersion.mjs.map +1 -0
- package/lib/revertibles.d.mts +86 -0
- package/lib/revertibles.d.mts.map +1 -0
- package/lib/revertibles.mjs +416 -0
- package/lib/revertibles.mjs.map +1 -0
- package/lib/sequence-alpha.d.mts +1315 -0
- package/lib/sequence-beta.d.mts +244 -0
- package/lib/sequence-public.d.mts +244 -0
- package/lib/sequence-untrimmed.d.mts +1803 -0
- package/lib/{sequence.d.ts → sequence.d.mts} +127 -50
- package/lib/sequence.d.mts.map +1 -0
- package/lib/{sequence.js → sequence.mjs} +225 -152
- package/lib/sequence.mjs.map +1 -0
- package/lib/{sequenceDeltaEvent.d.ts → sequenceDeltaEvent.d.mts} +24 -7
- package/lib/sequenceDeltaEvent.d.mts.map +1 -0
- package/lib/{sequenceDeltaEvent.js → sequenceDeltaEvent.mjs} +20 -8
- package/lib/sequenceDeltaEvent.mjs.map +1 -0
- package/lib/sequenceFactory.d.mts +22 -0
- package/lib/sequenceFactory.d.mts.map +1 -0
- package/lib/sequenceFactory.mjs +51 -0
- package/lib/sequenceFactory.mjs.map +1 -0
- package/lib/{sharedIntervalCollection.d.ts → sharedIntervalCollection.d.mts} +12 -12
- package/lib/sharedIntervalCollection.d.mts.map +1 -0
- package/lib/{sharedIntervalCollection.js → sharedIntervalCollection.mjs} +16 -21
- package/lib/sharedIntervalCollection.mjs.map +1 -0
- package/lib/{sharedSequence.d.ts → sharedSequence.d.mts} +15 -3
- package/lib/sharedSequence.d.mts.map +1 -0
- package/lib/{sharedSequence.js → sharedSequence.mjs} +30 -23
- package/lib/sharedSequence.mjs.map +1 -0
- package/lib/{sharedString.d.ts → sharedString.d.mts} +60 -24
- package/lib/sharedString.d.mts.map +1 -0
- package/lib/sharedString.mjs +281 -0
- package/lib/sharedString.mjs.map +1 -0
- package/package.json +146 -75
- package/prettier.config.cjs +8 -0
- package/sequence.test-files.tar +0 -0
- package/src/defaultMap.ts +417 -403
- package/src/defaultMapInterfaces.ts +157 -117
- package/src/index.ts +86 -26
- package/src/intervalCollection.ts +2043 -1563
- package/src/intervalIndex/endpointInRangeIndex.ts +116 -0
- package/src/intervalIndex/endpointIndex.ts +91 -0
- package/src/intervalIndex/idIntervalIndex.ts +64 -0
- package/src/intervalIndex/index.ts +25 -0
- package/src/intervalIndex/intervalIndex.ts +32 -0
- package/src/intervalIndex/intervalIndexUtils.ts +27 -0
- package/src/intervalIndex/overlappingIntervalsIndex.ts +187 -0
- package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +80 -0
- package/src/intervalIndex/sequenceIntervalIndexes.ts +34 -0
- package/src/intervalIndex/startpointInRangeIndex.ts +114 -0
- package/src/intervalTree.ts +98 -0
- package/src/intervals/index.ts +25 -0
- package/src/intervals/interval.ts +238 -0
- package/src/intervals/intervalUtils.ts +288 -0
- package/src/intervals/sequenceInterval.ts +616 -0
- package/src/localValues.ts +68 -73
- package/src/packageVersion.ts +1 -1
- package/src/revertibles.ts +693 -0
- package/src/sequence.ts +845 -690
- package/src/sequenceDeltaEvent.ts +164 -131
- package/src/sequenceFactory.ts +58 -214
- package/src/sharedIntervalCollection.ts +161 -152
- package/src/sharedSequence.ts +181 -167
- package/src/sharedString.ts +390 -234
- package/tsc-multi.test.json +10 -0
- package/tsconfig.json +11 -13
- package/.editorconfig +0 -7
- package/.vscode/launch.json +0 -15
- package/dist/defaultMap.js.map +0 -1
- package/dist/defaultMapInterfaces.js.map +0 -1
- package/dist/index.js +0 -44
- package/dist/index.js.map +0 -1
- package/dist/intervalCollection.js +0 -1250
- package/dist/intervalCollection.js.map +0 -1
- package/dist/localValues.js.map +0 -1
- package/dist/packageVersion.js.map +0 -1
- package/dist/sequence.js.map +0 -1
- package/dist/sequenceDeltaEvent.js.map +0 -1
- package/dist/sequenceFactory.js +0 -192
- package/dist/sequenceFactory.js.map +0 -1
- package/dist/sharedIntervalCollection.js.map +0 -1
- package/dist/sharedNumberSequence.d.ts +0 -50
- package/dist/sharedNumberSequence.d.ts.map +0 -1
- package/dist/sharedNumberSequence.js +0 -61
- package/dist/sharedNumberSequence.js.map +0 -1
- package/dist/sharedObjectSequence.d.ts +0 -50
- package/dist/sharedObjectSequence.d.ts.map +0 -1
- package/dist/sharedObjectSequence.js +0 -61
- package/dist/sharedObjectSequence.js.map +0 -1
- package/dist/sharedSequence.js.map +0 -1
- package/dist/sharedString.js +0 -187
- package/dist/sharedString.js.map +0 -1
- package/dist/sparsematrix.d.ts +0 -139
- package/dist/sparsematrix.d.ts.map +0 -1
- package/dist/sparsematrix.js +0 -332
- package/dist/sparsematrix.js.map +0 -1
- package/lib/defaultMap.d.ts.map +0 -1
- package/lib/defaultMap.js.map +0 -1
- package/lib/defaultMapInterfaces.d.ts.map +0 -1
- package/lib/defaultMapInterfaces.js.map +0 -1
- package/lib/index.d.ts +0 -27
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -26
- package/lib/index.js.map +0 -1
- package/lib/intervalCollection.d.ts +0 -270
- package/lib/intervalCollection.d.ts.map +0 -1
- package/lib/intervalCollection.js +0 -1238
- package/lib/intervalCollection.js.map +0 -1
- package/lib/localValues.d.ts.map +0 -1
- package/lib/localValues.js.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/lib/sequence.d.ts.map +0 -1
- package/lib/sequence.js.map +0 -1
- package/lib/sequenceDeltaEvent.d.ts.map +0 -1
- package/lib/sequenceDeltaEvent.js.map +0 -1
- package/lib/sequenceFactory.d.ts +0 -108
- package/lib/sequenceFactory.d.ts.map +0 -1
- package/lib/sequenceFactory.js +0 -186
- package/lib/sequenceFactory.js.map +0 -1
- package/lib/sharedIntervalCollection.d.ts.map +0 -1
- package/lib/sharedIntervalCollection.js.map +0 -1
- package/lib/sharedNumberSequence.d.ts +0 -50
- package/lib/sharedNumberSequence.d.ts.map +0 -1
- package/lib/sharedNumberSequence.js +0 -57
- package/lib/sharedNumberSequence.js.map +0 -1
- package/lib/sharedObjectSequence.d.ts +0 -50
- package/lib/sharedObjectSequence.d.ts.map +0 -1
- package/lib/sharedObjectSequence.js +0 -57
- package/lib/sharedObjectSequence.js.map +0 -1
- package/lib/sharedSequence.d.ts.map +0 -1
- package/lib/sharedSequence.js.map +0 -1
- package/lib/sharedString.d.ts.map +0 -1
- package/lib/sharedString.js +0 -183
- package/lib/sharedString.js.map +0 -1
- package/lib/sparsematrix.d.ts +0 -139
- package/lib/sparsematrix.d.ts.map +0 -1
- package/lib/sparsematrix.js +0 -323
- package/lib/sparsematrix.js.map +0 -1
- package/src/sharedNumberSequence.ts +0 -62
- package/src/sharedObjectSequence.ts +0 -62
- package/src/sparsematrix.ts +0 -421
- package/tsconfig.esnext.json +0 -7
|
@@ -2,133 +2,92 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { TypedEventEmitter } from "@
|
|
6
|
-
import { IEvent } from "@fluidframework/
|
|
7
|
-
import { Client,
|
|
5
|
+
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
6
|
+
import { IEvent } from "@fluidframework/core-interfaces";
|
|
7
|
+
import { Client, PropertySet, LocalReferencePosition } from "@fluidframework/merge-tree";
|
|
8
8
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
9
|
-
import { IValueFactory, IValueOpEmitter, IValueOperation, IValueType } from "./defaultMapInterfaces";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Nest = 1,
|
|
13
|
-
/**
|
|
14
|
-
* SlideOnRemove indicates that the ends of the interval will slide if the segment
|
|
15
|
-
* they reference is removed and acked.
|
|
16
|
-
* See `packages\dds\merge-tree\REFERENCEPOSITIONS.md` for details
|
|
17
|
-
* SlideOnRemove is the default interval behavior and does not need to be specified.
|
|
18
|
-
*/
|
|
19
|
-
SlideOnRemove = 2,
|
|
20
|
-
/**
|
|
21
|
-
* @internal
|
|
22
|
-
* A temporary interval, used internally
|
|
23
|
-
*/
|
|
24
|
-
Transient = 4
|
|
25
|
-
}
|
|
26
|
-
export interface ISerializedInterval {
|
|
27
|
-
sequenceNumber: number;
|
|
28
|
-
start: number;
|
|
29
|
-
end: number;
|
|
30
|
-
intervalType: IntervalType;
|
|
31
|
-
properties?: PropertySet;
|
|
32
|
-
}
|
|
9
|
+
import { IMapMessageLocalMetadata, IValueFactory, IValueOpEmitter, IValueOperation, IValueType, SequenceOptions } from "./defaultMapInterfaces";
|
|
10
|
+
import { CompressedSerializedInterval, IIntervalHelpers, Interval, IntervalOpType, IntervalStickiness, IntervalType, ISerializableInterval, ISerializedInterval, SequenceInterval, SerializedIntervalDelta } from "./intervals";
|
|
11
|
+
import { IEndpointIndex, IIdIntervalIndex, IOverlappingIntervalsIndex, IntervalIndex } from "./intervalIndex";
|
|
33
12
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
13
|
+
* Defines a position and side relative to a character in a sequence.
|
|
14
|
+
*
|
|
15
|
+
* For this purpose, sequences look like:
|
|
16
|
+
*
|
|
17
|
+
* `{start} - {character 0} - {character 1} - ... - {character N} - {end}`
|
|
18
|
+
*
|
|
19
|
+
* Each `{value}` in the diagram is a character within a sequence.
|
|
20
|
+
* Each `-` in the above diagram is a position where text could be inserted.
|
|
21
|
+
* Each position between a `{value}` and a `-` is a `SequencePlace`.
|
|
22
|
+
*
|
|
23
|
+
* The special endpoints `{start}` and `{end}` refer to positions outside the
|
|
24
|
+
* contents of the string.
|
|
36
25
|
*
|
|
37
|
-
*
|
|
26
|
+
* This gives us 2N + 2 possible positions to refer to within a string, where N
|
|
27
|
+
* is the number of characters.
|
|
28
|
+
*
|
|
29
|
+
* If the position is specified with a bare number, the side defaults to
|
|
30
|
+
* `Side.Before`.
|
|
31
|
+
*
|
|
32
|
+
* If a SequencePlace is the endpoint of a range (e.g. start/end of an interval or search range),
|
|
33
|
+
* the Side value means it is exclusive if it is nearer to the other position and inclusive if it is farther.
|
|
34
|
+
* E.g. the start of a range with Side.After is exclusive of the character at the position.
|
|
35
|
+
* @alpha
|
|
38
36
|
*/
|
|
39
|
-
export
|
|
37
|
+
export type SequencePlace = number | "start" | "end" | InteriorSequencePlace;
|
|
40
38
|
/**
|
|
41
|
-
*
|
|
39
|
+
* A sequence place that does not refer to the special endpoint segments.
|
|
40
|
+
*
|
|
41
|
+
* See {@link SequencePlace} for additional context.
|
|
42
|
+
* @alpha
|
|
43
|
+
*/
|
|
44
|
+
export interface InteriorSequencePlace {
|
|
45
|
+
pos: number;
|
|
46
|
+
side: Side;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Defines a side relative to a character in a sequence.
|
|
50
|
+
*
|
|
51
|
+
* @remarks See {@link SequencePlace} for additional context on usage.
|
|
52
|
+
* @alpha
|
|
42
53
|
*/
|
|
54
|
+
export declare enum Side {
|
|
55
|
+
Before = 0,
|
|
56
|
+
After = 1
|
|
57
|
+
}
|
|
43
58
|
export interface ISerializedIntervalCollectionV2 {
|
|
44
59
|
label: string;
|
|
45
60
|
version: 2;
|
|
46
61
|
intervals: CompressedSerializedInterval[];
|
|
47
62
|
}
|
|
48
|
-
export
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
export declare
|
|
60
|
-
start: number;
|
|
61
|
-
end: number;
|
|
62
|
-
properties: PropertySet;
|
|
63
|
-
auxProps: PropertySet[];
|
|
64
|
-
propertyManager: PropertiesManager;
|
|
65
|
-
constructor(start: number, end: number, props?: PropertySet);
|
|
66
|
-
getIntervalId(): string | undefined;
|
|
67
|
-
getAdditionalPropertySets(): PropertySet[];
|
|
68
|
-
addPropertySet(props: PropertySet): void;
|
|
69
|
-
serialize(client: Client): ISerializedInterval;
|
|
70
|
-
clone(): Interval;
|
|
71
|
-
compare(b: Interval): number;
|
|
72
|
-
compareStart(b: Interval): number;
|
|
73
|
-
compareEnd(b: Interval): number;
|
|
74
|
-
overlaps(b: Interval): boolean;
|
|
75
|
-
union(b: Interval): Interval;
|
|
76
|
-
getProperties(): PropertySet;
|
|
77
|
-
addProperties(newProps: PropertySet, collaborating?: boolean, seq?: number, op?: ICombiningOp): PropertySet | undefined;
|
|
78
|
-
modify(label: string, start: number, end: number, op?: ISequencedDocumentMessage): Interval;
|
|
79
|
-
private initializeProperties;
|
|
80
|
-
}
|
|
81
|
-
export declare class SequenceInterval implements ISerializableInterval {
|
|
82
|
-
start: LocalReference;
|
|
83
|
-
end: LocalReference;
|
|
84
|
-
intervalType: IntervalType;
|
|
85
|
-
properties: PropertySet;
|
|
86
|
-
propertyManager: PropertiesManager;
|
|
87
|
-
constructor(start: LocalReference, end: LocalReference, intervalType: IntervalType, props?: PropertySet);
|
|
88
|
-
private callbacks?;
|
|
89
|
-
/**
|
|
90
|
-
* @internal
|
|
91
|
-
* Subscribes to position change events on this interval if there are no current listeners.
|
|
92
|
-
*/
|
|
93
|
-
addPositionChangeListeners(beforePositionChange: () => void, afterPositionChange: () => void): void;
|
|
94
|
-
/**
|
|
95
|
-
* @internal
|
|
96
|
-
* Removes the currently subscribed position change listeners.
|
|
97
|
-
*/
|
|
98
|
-
removePositionChangeListeners(): void;
|
|
99
|
-
serialize(client: Client): ISerializedInterval;
|
|
100
|
-
clone(): SequenceInterval;
|
|
101
|
-
compare(b: SequenceInterval): number;
|
|
102
|
-
compareStart(b: SequenceInterval): number;
|
|
103
|
-
compareEnd(b: SequenceInterval): number;
|
|
104
|
-
overlaps(b: SequenceInterval): boolean;
|
|
105
|
-
getIntervalId(): string | undefined;
|
|
106
|
-
union(b: SequenceInterval): SequenceInterval;
|
|
107
|
-
addProperties(newProps: PropertySet, collab?: boolean, seq?: number, op?: ICombiningOp): PropertySet | undefined;
|
|
108
|
-
overlapsPos(bstart: number, bend: number): boolean;
|
|
109
|
-
modify(label: string, start: number, end: number, op?: ISequencedDocumentMessage): SequenceInterval;
|
|
110
|
-
private initializeProperties;
|
|
111
|
-
}
|
|
112
|
-
export declare function defaultIntervalConflictResolver(a: Interval, b: Interval): Interval;
|
|
113
|
-
export declare function createIntervalIndex(conflict?: IntervalConflictResolver<Interval>): LocalIntervalCollection<Interval>;
|
|
63
|
+
export declare function sidesFromStickiness(stickiness: IntervalStickiness): {
|
|
64
|
+
startSide: Side;
|
|
65
|
+
endSide: Side;
|
|
66
|
+
};
|
|
67
|
+
export declare function endpointPosAndSide(start: SequencePlace | undefined, end: SequencePlace | undefined): {
|
|
68
|
+
startSide: Side | undefined;
|
|
69
|
+
endSide: Side | undefined;
|
|
70
|
+
startPos: number | "end" | "start" | undefined;
|
|
71
|
+
endPos: number | "end" | "start" | undefined;
|
|
72
|
+
};
|
|
73
|
+
export declare function computeStickinessFromSide(startPos?: number | "start" | "end" | undefined, startSide?: Side, endPos?: number | "start" | "end" | undefined, endSide?: Side): IntervalStickiness;
|
|
74
|
+
export declare function createIntervalIndex(): LocalIntervalCollection<Interval>;
|
|
114
75
|
export declare class LocalIntervalCollection<TInterval extends ISerializableInterval> {
|
|
115
76
|
private readonly client;
|
|
116
77
|
private readonly label;
|
|
117
78
|
private readonly helpers;
|
|
79
|
+
private readonly options;
|
|
118
80
|
/** Callback invoked each time one of the endpoints of an interval slides. */
|
|
119
81
|
private readonly onPositionChange?;
|
|
120
|
-
private readonly intervalTree;
|
|
121
|
-
private readonly endIntervalTree;
|
|
122
|
-
private readonly intervalIdMap;
|
|
123
|
-
private conflictResolver;
|
|
124
|
-
private endConflictResolver;
|
|
125
82
|
private static readonly legacyIdPrefix;
|
|
126
|
-
|
|
83
|
+
readonly overlappingIntervalsIndex: IOverlappingIntervalsIndex<TInterval>;
|
|
84
|
+
readonly idIntervalIndex: IIdIntervalIndex<TInterval>;
|
|
85
|
+
readonly endIntervalIndex: IEndpointIndex<TInterval>;
|
|
86
|
+
private readonly indexes;
|
|
87
|
+
constructor(client: Client, label: string, helpers: IIntervalHelpers<TInterval>, options: Partial<SequenceOptions>,
|
|
127
88
|
/** Callback invoked each time one of the endpoints of an interval slides. */
|
|
128
|
-
onPositionChange?: (interval: TInterval) => void);
|
|
129
|
-
|
|
130
|
-
map(fn: (interval: TInterval) => void): void;
|
|
131
|
-
createLegacyId(start: number, end: number): string;
|
|
89
|
+
onPositionChange?: ((interval: TInterval, previousInterval: TInterval) => void) | undefined);
|
|
90
|
+
createLegacyId(start: number | "start" | "end", end: number | "start" | "end"): string;
|
|
132
91
|
/**
|
|
133
92
|
* Validates that a serialized interval has the ID property. Creates an ID
|
|
134
93
|
* if one does not already exist
|
|
@@ -137,20 +96,16 @@ export declare class LocalIntervalCollection<TInterval extends ISerializableInte
|
|
|
137
96
|
* @returns The interval's existing or newly created id
|
|
138
97
|
*/
|
|
139
98
|
ensureSerializedId(serializedInterval: ISerializedInterval): string;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
previousInterval(pos: number): TInterval;
|
|
144
|
-
nextInterval(pos: number): TInterval;
|
|
145
|
-
removeInterval(startPosition: number, endPosition: number): TInterval;
|
|
146
|
-
private removeIntervalFromIndex;
|
|
99
|
+
private removeIntervalFromIndexes;
|
|
100
|
+
appendIndex(index: IntervalIndex<TInterval>): void;
|
|
101
|
+
removeIndex(index: IntervalIndex<TInterval>): boolean;
|
|
147
102
|
removeExistingInterval(interval: TInterval): void;
|
|
148
|
-
createInterval(start:
|
|
149
|
-
addInterval(start:
|
|
150
|
-
private
|
|
103
|
+
createInterval(start: SequencePlace, end: SequencePlace, intervalType: IntervalType, op?: ISequencedDocumentMessage): TInterval;
|
|
104
|
+
addInterval(start: SequencePlace, end: SequencePlace, intervalType: IntervalType, props?: PropertySet, op?: ISequencedDocumentMessage): TInterval;
|
|
105
|
+
private linkEndpointsToInterval;
|
|
106
|
+
private addIntervalToIndexes;
|
|
151
107
|
add(interval: TInterval): void;
|
|
152
|
-
|
|
153
|
-
changeInterval(interval: TInterval, start: number, end: number, op?: ISequencedDocumentMessage): TInterval;
|
|
108
|
+
changeInterval(interval: TInterval, start: SequencePlace | undefined, end: SequencePlace | undefined, op?: ISequencedDocumentMessage, localSeq?: number): TInterval | undefined;
|
|
154
109
|
serialize(): ISerializedIntervalCollectionV2;
|
|
155
110
|
private addIntervalListeners;
|
|
156
111
|
private removeIntervalListeners;
|
|
@@ -159,7 +114,7 @@ export declare class SequenceIntervalCollectionValueType implements IValueType<I
|
|
|
159
114
|
static Name: string;
|
|
160
115
|
get name(): string;
|
|
161
116
|
get factory(): IValueFactory<IntervalCollection<SequenceInterval>>;
|
|
162
|
-
get ops(): Map<
|
|
117
|
+
get ops(): Map<IntervalOpType, IValueOperation<IntervalCollection<SequenceInterval>>>;
|
|
163
118
|
private static readonly _factory;
|
|
164
119
|
private static readonly _ops;
|
|
165
120
|
}
|
|
@@ -167,104 +122,448 @@ export declare class IntervalCollectionValueType implements IValueType<IntervalC
|
|
|
167
122
|
static Name: string;
|
|
168
123
|
get name(): string;
|
|
169
124
|
get factory(): IValueFactory<IntervalCollection<Interval>>;
|
|
170
|
-
get ops(): Map<
|
|
125
|
+
get ops(): Map<IntervalOpType, IValueOperation<IntervalCollection<Interval>>>;
|
|
171
126
|
private static readonly _factory;
|
|
172
127
|
private static readonly _ops;
|
|
173
128
|
}
|
|
174
|
-
export declare
|
|
175
|
-
|
|
129
|
+
export declare function makeOpsMap<T extends ISerializableInterval>(): Map<IntervalOpType, IValueOperation<IntervalCollection<T>>>;
|
|
130
|
+
/**
|
|
131
|
+
* @alpha
|
|
132
|
+
*/
|
|
133
|
+
export type DeserializeCallback = (properties: PropertySet) => void;
|
|
134
|
+
declare class IntervalCollectionIterator<TInterval extends ISerializableInterval> implements Iterator<TInterval> {
|
|
176
135
|
private readonly results;
|
|
177
136
|
private index;
|
|
178
137
|
constructor(collection: IntervalCollection<TInterval>, iteratesForward?: boolean, start?: number, end?: number);
|
|
179
|
-
next():
|
|
180
|
-
value: TInterval;
|
|
181
|
-
done: boolean;
|
|
182
|
-
};
|
|
138
|
+
next(): IteratorResult<TInterval>;
|
|
183
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Change events emitted by `IntervalCollection`s
|
|
142
|
+
* @alpha
|
|
143
|
+
*/
|
|
184
144
|
export interface IIntervalCollectionEvent<TInterval extends ISerializableInterval> extends IEvent {
|
|
185
145
|
/**
|
|
186
|
-
* This event is invoked whenever the
|
|
146
|
+
* This event is invoked whenever the endpoints of an interval may have changed.
|
|
187
147
|
* This can happen on:
|
|
188
|
-
* - endpoint modification
|
|
189
|
-
* - ack of
|
|
190
|
-
* -
|
|
191
|
-
* - position change due to segment sliding (will always appear as a local change)
|
|
148
|
+
* - local endpoint modification
|
|
149
|
+
* - ack of a remote endpoint modification
|
|
150
|
+
* - position change due to segment sliding (slides due to mergeTree segment deletion will always appear local)
|
|
192
151
|
* The `interval` argument reflects the new values.
|
|
152
|
+
* `previousInterval` contains transient `ReferencePosition`s at the same location as the interval's original
|
|
153
|
+
* endpoints. These references should be used for position information only.
|
|
154
|
+
* `local` reflects whether the change originated locally.
|
|
155
|
+
* `op` is defined if and only if the server has acked this change.
|
|
156
|
+
* `slide` is true if the change is due to sliding on removal of position
|
|
157
|
+
*/
|
|
158
|
+
(event: "changeInterval", listener: (interval: TInterval, previousInterval: TInterval, local: boolean, op: ISequencedDocumentMessage | undefined, slide: boolean) => void): void;
|
|
159
|
+
/**
|
|
160
|
+
* This event is invoked whenever an interval is added or removed from the collection.
|
|
161
|
+
* `local` reflects whether the change originated locally.
|
|
162
|
+
* `op` is defined if and only if the server has acked this change.
|
|
163
|
+
*/
|
|
164
|
+
(event: "addInterval" | "deleteInterval", listener: (interval: TInterval, local: boolean, op: ISequencedDocumentMessage | undefined) => void): void;
|
|
165
|
+
/**
|
|
166
|
+
* This event is invoked whenever an interval's properties have changed.
|
|
167
|
+
* `interval` reflects the state of the updated properties.
|
|
168
|
+
* `propertyDeltas` is a map-like whose keys contain all values that were changed, and whose
|
|
169
|
+
* values contain all previous values of the property set.
|
|
170
|
+
* This object can be used directly in a call to `changeProperties` to revert the property change if desired.
|
|
171
|
+
* `local` reflects whether the change originated locally.
|
|
172
|
+
* `op` is defined if and only if the server has acked this change.
|
|
173
|
+
*/
|
|
174
|
+
(event: "propertyChanged", listener: (interval: TInterval, propertyDeltas: PropertySet, local: boolean, op: ISequencedDocumentMessage | undefined) => void): void;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Collection of intervals that supports addition, modification, removal, and efficient spatial querying.
|
|
178
|
+
* Changes to this collection will be incur updates on collaborating clients (i.e. they are not local-only).
|
|
179
|
+
* @alpha
|
|
180
|
+
*/
|
|
181
|
+
export interface IIntervalCollection<TInterval extends ISerializableInterval> extends TypedEventEmitter<IIntervalCollectionEvent<TInterval>> {
|
|
182
|
+
readonly attached: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Attaches an index to this collection.
|
|
185
|
+
* All intervals which are part of this collection will be added to the index, and the index will automatically
|
|
186
|
+
* be updated when this collection updates due to local or remote changes.
|
|
187
|
+
*
|
|
188
|
+
* @remarks After attaching an index to an interval collection, applications should typically store this
|
|
189
|
+
* index somewhere in their in-memory data model for future reference and querying.
|
|
190
|
+
*/
|
|
191
|
+
attachIndex(index: IntervalIndex<TInterval>): void;
|
|
192
|
+
/**
|
|
193
|
+
* Detaches an index from this collection.
|
|
194
|
+
* All intervals which are part of this collection will be removed from the index, and updates to this collection
|
|
195
|
+
* due to local or remote changes will no longer incur updates to the index.
|
|
196
|
+
*
|
|
197
|
+
* @returns `false` if the target index cannot be found in the indexes, otherwise remove all intervals in the index and return `true`.
|
|
198
|
+
*/
|
|
199
|
+
detachIndex(index: IntervalIndex<TInterval>): boolean;
|
|
200
|
+
/**
|
|
201
|
+
* @returns the interval in this collection that has the provided `id`.
|
|
202
|
+
* If no interval in the collection has this `id`, returns `undefined`.
|
|
203
|
+
*/
|
|
204
|
+
getIntervalById(id: string): TInterval | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* Creates a new interval and add it to the collection.
|
|
207
|
+
* @deprecated call IntervalCollection.add without specifying an intervalType
|
|
208
|
+
* @param start - interval start position (inclusive)
|
|
209
|
+
* @param end - interval end position (exclusive)
|
|
210
|
+
* @param intervalType - type of the interval. All intervals are SlideOnRemove. Intervals may not be Transient.
|
|
211
|
+
* @param props - properties of the interval
|
|
212
|
+
* @returns The created interval
|
|
213
|
+
* @remarks See documentation on {@link SequenceInterval} for comments on
|
|
214
|
+
* interval endpoint semantics: there are subtleties with how the current
|
|
215
|
+
* half-open behavior is represented.
|
|
216
|
+
*
|
|
217
|
+
* Note that intervals may behave unexpectedly if the entire contents
|
|
218
|
+
* of the string are deleted. In this case, it is possible for one endpoint
|
|
219
|
+
* of the interval to become detached, while the other remains on the string.
|
|
220
|
+
*
|
|
221
|
+
* By adjusting the `side` and `pos` values of the `start` and `end` parameters,
|
|
222
|
+
* it is possible to control whether the interval expands to include content
|
|
223
|
+
* inserted at its start or end.
|
|
224
|
+
*
|
|
225
|
+
* See {@link SequencePlace} for more details on the model.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
*
|
|
229
|
+
* Given the string "ABCD":
|
|
230
|
+
*
|
|
231
|
+
*```typescript
|
|
232
|
+
* // Refers to "BC". If any content is inserted before B or after C, this
|
|
233
|
+
* // interval will include that content
|
|
234
|
+
* //
|
|
235
|
+
* // Picture:
|
|
236
|
+
* // \{start\} - A[- B - C -]D - \{end\}
|
|
237
|
+
* // \{start\} - A - B - C - D - \{end\}
|
|
238
|
+
* collection.add(\{ pos: 0, side: Side.After \}, \{ pos: 3, side: Side.Before \}, IntervalType.SlideOnRemove);
|
|
239
|
+
* // Equivalent to specifying the same positions and Side.Before.
|
|
240
|
+
* // Refers to "ABC". Content inserted after C will be included in the
|
|
241
|
+
* // interval, but content inserted before A will not.
|
|
242
|
+
* // \{start\} -[A - B - C -]D - \{end\}
|
|
243
|
+
* // \{start\} - A - B - C - D - \{end\}
|
|
244
|
+
* collection.add(0, 3, IntervalType.SlideOnRemove);
|
|
245
|
+
*```
|
|
246
|
+
*
|
|
247
|
+
* In the case of the first example, if text is deleted,
|
|
248
|
+
*
|
|
249
|
+
* ```typescript
|
|
250
|
+
* // Delete the character "B"
|
|
251
|
+
* string.removeRange(1, 2);
|
|
252
|
+
* ```
|
|
253
|
+
*
|
|
254
|
+
* The start point of the interval will slide to the position immediately
|
|
255
|
+
* before "C", and the same will be true.
|
|
256
|
+
*
|
|
257
|
+
* ```
|
|
258
|
+
* \{start\} - A[- C -]D - \{end\}
|
|
259
|
+
* ```
|
|
260
|
+
*
|
|
261
|
+
* In this case, text inserted immediately before "C" would be included in
|
|
262
|
+
* the interval.
|
|
263
|
+
*
|
|
264
|
+
* ```typescript
|
|
265
|
+
* string.insertText(1, "EFG");
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* With the string now being,
|
|
269
|
+
*
|
|
270
|
+
* ```
|
|
271
|
+
* \{start\} - A[- E - F - G - C -]D - \{end\}
|
|
272
|
+
* ```
|
|
273
|
+
*
|
|
274
|
+
* @privateRemarks TODO: ADO:5205 the above comment regarding behavior in
|
|
275
|
+
* the case that the entire interval has been deleted should be resolved at
|
|
276
|
+
* the same time as this ticket
|
|
277
|
+
*/
|
|
278
|
+
add(start: SequencePlace, end: SequencePlace, intervalType: IntervalType, props?: PropertySet): TInterval;
|
|
279
|
+
/**
|
|
280
|
+
* Creates a new interval and add it to the collection.
|
|
281
|
+
* @param start - interval start position (inclusive)
|
|
282
|
+
* @param end - interval end position (exclusive)
|
|
283
|
+
* @param props - properties of the interval
|
|
284
|
+
* @returns - the created interval
|
|
285
|
+
* @remarks - See documentation on {@link SequenceInterval} for comments on interval endpoint semantics: there are subtleties
|
|
286
|
+
* with how the current half-open behavior is represented.
|
|
287
|
+
*/
|
|
288
|
+
add({ start, end, props, }: {
|
|
289
|
+
start: SequencePlace;
|
|
290
|
+
end: SequencePlace;
|
|
291
|
+
props?: PropertySet;
|
|
292
|
+
}): TInterval;
|
|
293
|
+
/**
|
|
294
|
+
* Removes an interval from the collection.
|
|
295
|
+
* @param id - Id of the interval to remove
|
|
296
|
+
* @returns the removed interval
|
|
297
|
+
*/
|
|
298
|
+
removeIntervalById(id: string): TInterval | undefined;
|
|
299
|
+
/**
|
|
300
|
+
* Changes the properties on an existing interval.
|
|
301
|
+
* @deprecated - call change with the id and and object containing the new properties
|
|
302
|
+
* @param id - Id of the interval whose properties should be changed
|
|
303
|
+
* @param props - Property set to apply to the interval. Shallow merging is used between any existing properties
|
|
304
|
+
* and `prop`, i.e. the interval will end up with a property object equivalent to `{ ...oldProps, ...props }`.
|
|
305
|
+
*/
|
|
306
|
+
changeProperties(id: string, props: PropertySet): void;
|
|
307
|
+
/**
|
|
308
|
+
* Changes the endpoints of an existing interval.
|
|
309
|
+
* @deprecated - call change with the start and end parameters encapsulated in an object
|
|
310
|
+
* @param id - Id of the interval to change
|
|
311
|
+
* @param start - New start value. To leave the endpoint unchanged, pass the current value.
|
|
312
|
+
* @param end - New end value. To leave the endpoint unchanged, pass the current value.
|
|
313
|
+
* @returns the interval that was changed, if it existed in the collection.
|
|
314
|
+
*/
|
|
315
|
+
change(id: string, start: SequencePlace, end: SequencePlace): TInterval | undefined;
|
|
316
|
+
/**
|
|
317
|
+
* Changes the endpoints, properties, or both of an existing interval.
|
|
318
|
+
* @param id - Id of the Interval to change
|
|
319
|
+
* @returns the interval that was changed, if it existed in the collection.
|
|
320
|
+
* Pass the desired new start position, end position, and/or properties in an object. Start and end positions must be changed
|
|
321
|
+
* simultaneously - they must either both be specified or both undefined. To only change the properties, leave both endpoints
|
|
322
|
+
* undefined. To only change the endpoints, leave the properties undefined.
|
|
323
|
+
*/
|
|
324
|
+
change(id: string, { start, end, props }: {
|
|
325
|
+
start?: SequencePlace;
|
|
326
|
+
end?: SequencePlace;
|
|
327
|
+
props?: PropertySet;
|
|
328
|
+
}): TInterval | undefined;
|
|
329
|
+
attachDeserializer(onDeserialize: DeserializeCallback): void;
|
|
330
|
+
/**
|
|
331
|
+
* @returns an iterator over all intervals in this collection.
|
|
332
|
+
*/
|
|
333
|
+
[Symbol.iterator](): Iterator<TInterval>;
|
|
334
|
+
/**
|
|
335
|
+
* @returns a forward iterator over all intervals in this collection with start point equal to `startPosition`.
|
|
336
|
+
*/
|
|
337
|
+
CreateForwardIteratorWithStartPosition(startPosition: number): Iterator<TInterval>;
|
|
338
|
+
/**
|
|
339
|
+
* @returns a backward iterator over all intervals in this collection with start point equal to `startPosition`.
|
|
340
|
+
*/
|
|
341
|
+
CreateBackwardIteratorWithStartPosition(startPosition: number): Iterator<TInterval>;
|
|
342
|
+
/**
|
|
343
|
+
* @returns a forward iterator over all intervals in this collection with end point equal to `endPosition`.
|
|
344
|
+
*/
|
|
345
|
+
CreateForwardIteratorWithEndPosition(endPosition: number): Iterator<TInterval>;
|
|
346
|
+
/**
|
|
347
|
+
* @returns a backward iterator over all intervals in this collection with end point equal to `endPosition`.
|
|
348
|
+
*/
|
|
349
|
+
CreateBackwardIteratorWithEndPosition(endPosition: number): Iterator<TInterval>;
|
|
350
|
+
/**
|
|
351
|
+
* Gathers iteration results that optionally match a start/end criteria into the provided array.
|
|
352
|
+
* @param results - Array to gather the results into. In lieu of a return value, this array will be populated with
|
|
353
|
+
* intervals matching the query upon edit.
|
|
354
|
+
* @param iteratesForward - whether or not iteration should be in the forward direction
|
|
355
|
+
* @param start - If provided, only match intervals whose start point is equal to `start`.
|
|
356
|
+
* @param end - If provided, only match intervals whose end point is equal to `end`.
|
|
357
|
+
*/
|
|
358
|
+
gatherIterationResults(results: TInterval[], iteratesForward: boolean, start?: number, end?: number): void;
|
|
359
|
+
/**
|
|
360
|
+
* @deprecated - Users must manually attach the corresponding interval index to utilize this functionality, for instance:
|
|
361
|
+
*
|
|
362
|
+
* ```typescript
|
|
363
|
+
* const overlappingIntervalsIndex = createOverlappingIntervalsIndex(sharedString);
|
|
364
|
+
* collection.attachIndex(overlappingIntervalsIndex)
|
|
365
|
+
* const result = overlappingIntervalsIndex.findOverlappingIntervals(start, end);
|
|
366
|
+
* ```
|
|
367
|
+
*
|
|
368
|
+
* @returns an array of all intervals in this collection that overlap with the interval
|
|
369
|
+
* `[startPosition, endPosition]`.
|
|
370
|
+
*/
|
|
371
|
+
findOverlappingIntervals(startPosition: number, endPosition: number): TInterval[];
|
|
372
|
+
/**
|
|
373
|
+
* Applies a function to each interval in this collection.
|
|
374
|
+
*/
|
|
375
|
+
map(fn: (interval: TInterval) => void): void;
|
|
376
|
+
/**
|
|
377
|
+
* @deprecated - due to the forthcoming change where the endpointIndex will no longer be
|
|
378
|
+
* automatically added to the collection. Users are advised to independently attach the
|
|
379
|
+
* index to the collection and utilize the API accordingly, for instance:
|
|
380
|
+
* ```typescript
|
|
381
|
+
* const endpointIndex = createEndpointIndex(sharedString);
|
|
382
|
+
* collection.attachIndex(endpointIndex);
|
|
383
|
+
* const result1 = endpointIndex.previousInterval(pos);
|
|
384
|
+
* ```
|
|
385
|
+
* If an index is used repeatedly, applications should generally attach it once and store it in memory.
|
|
386
|
+
*/
|
|
387
|
+
previousInterval(pos: number): TInterval | undefined;
|
|
388
|
+
/**
|
|
389
|
+
* @deprecated - due to the forthcoming change where the endpointIndex will no longer be
|
|
390
|
+
* automatically added to the collection. Users are advised to independently attach the
|
|
391
|
+
* index to the collection and utilize the API accordingly, for instance:
|
|
392
|
+
* ```typescript
|
|
393
|
+
* const endpointIndex = createEndpointIndex(sharedString);
|
|
394
|
+
* collection.attachIndex(endpointIndex);
|
|
395
|
+
* const result2 = endpointIndex.nextInterval(pos);
|
|
396
|
+
* ```
|
|
193
397
|
*/
|
|
194
|
-
(
|
|
195
|
-
(event: "addInterval" | "deleteInterval", listener: (interval: TInterval, local: boolean, op: ISequencedDocumentMessage) => void): any;
|
|
196
|
-
(event: "propertyChanged", listener: (interval: TInterval, propertyArgs: PropertySet) => void): any;
|
|
398
|
+
nextInterval(pos: number): TInterval | undefined;
|
|
197
399
|
}
|
|
198
|
-
|
|
400
|
+
/**
|
|
401
|
+
* {@inheritdoc IIntervalCollection}
|
|
402
|
+
*/
|
|
403
|
+
export declare class IntervalCollection<TInterval extends ISerializableInterval> extends TypedEventEmitter<IIntervalCollectionEvent<TInterval>> implements IIntervalCollection<TInterval> {
|
|
199
404
|
private readonly helpers;
|
|
200
405
|
private readonly requiresClient;
|
|
201
406
|
private readonly emitter;
|
|
407
|
+
private readonly options;
|
|
202
408
|
private savedSerializedIntervals?;
|
|
203
409
|
private localCollection;
|
|
204
410
|
private onDeserialize;
|
|
205
411
|
private client;
|
|
412
|
+
private readonly localSeqToSerializedInterval;
|
|
413
|
+
private readonly localSeqToRebasedInterval;
|
|
206
414
|
private readonly pendingChangesStart;
|
|
207
415
|
private readonly pendingChangesEnd;
|
|
208
416
|
get attached(): boolean;
|
|
209
417
|
/** @internal */
|
|
210
|
-
constructor(helpers: IIntervalHelpers<TInterval>, requiresClient: boolean, emitter: IValueOpEmitter, serializedIntervals: ISerializedInterval[] | ISerializedIntervalCollectionV2);
|
|
418
|
+
constructor(helpers: IIntervalHelpers<TInterval>, requiresClient: boolean, emitter: IValueOpEmitter, serializedIntervals: ISerializedInterval[] | ISerializedIntervalCollectionV2, options?: Partial<SequenceOptions>);
|
|
419
|
+
/**
|
|
420
|
+
* {@inheritdoc IIntervalCollection.attachIndex}
|
|
421
|
+
*/
|
|
422
|
+
attachIndex(index: IntervalIndex<TInterval>): void;
|
|
423
|
+
/**
|
|
424
|
+
* {@inheritdoc IIntervalCollection.detachIndex}
|
|
425
|
+
*/
|
|
426
|
+
detachIndex(index: IntervalIndex<TInterval>): boolean;
|
|
427
|
+
private rebasePositionWithSegmentSlide;
|
|
428
|
+
private computeRebasedPositions;
|
|
429
|
+
/** @internal */
|
|
211
430
|
attachGraph(client: Client, label: string): void;
|
|
212
431
|
/**
|
|
213
432
|
* Gets the next local sequence number, modifying this client's collab window in doing so.
|
|
214
433
|
*/
|
|
215
434
|
private getNextLocalSeq;
|
|
216
|
-
|
|
435
|
+
private emitChange;
|
|
217
436
|
/**
|
|
218
|
-
*
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
* @
|
|
437
|
+
* {@inheritdoc IIntervalCollection.getIntervalById}
|
|
438
|
+
*/
|
|
439
|
+
getIntervalById(id: string): TInterval | undefined;
|
|
440
|
+
private assertStickinessEnabled;
|
|
441
|
+
/**
|
|
442
|
+
* {@inheritdoc IIntervalCollection.add}
|
|
443
|
+
* @deprecated call IntervalCollection.add without specifying an intervalType
|
|
224
444
|
*/
|
|
225
|
-
add(start:
|
|
445
|
+
add(start: SequencePlace, end: SequencePlace, intervalType: IntervalType, props?: PropertySet): TInterval;
|
|
446
|
+
add({ start, end, props, }: {
|
|
447
|
+
start: SequencePlace;
|
|
448
|
+
end: SequencePlace;
|
|
449
|
+
props?: PropertySet;
|
|
450
|
+
}): TInterval;
|
|
226
451
|
private deleteExistingInterval;
|
|
227
|
-
|
|
452
|
+
/**
|
|
453
|
+
* {@inheritdoc IIntervalCollection.removeIntervalById}
|
|
454
|
+
*/
|
|
455
|
+
removeIntervalById(id: string): TInterval | undefined;
|
|
456
|
+
/**
|
|
457
|
+
* {@inheritdoc IIntervalCollection.changeProperties}
|
|
458
|
+
* @deprecated - call change with the id and an object containing the new props values
|
|
459
|
+
*/
|
|
228
460
|
changeProperties(id: string, props: PropertySet): void;
|
|
229
|
-
|
|
461
|
+
/**
|
|
462
|
+
* {@inheritdoc IIntervalCollection.change}
|
|
463
|
+
* @deprecated - call change with the id and an object containing the new start, end, and/or props values
|
|
464
|
+
*/
|
|
465
|
+
change(id: string, start: SequencePlace, end: SequencePlace): TInterval | undefined;
|
|
466
|
+
/**
|
|
467
|
+
* {@inheritdoc IIntervalCollection.change}
|
|
468
|
+
*/
|
|
469
|
+
change(id: string, { start, end, props }: {
|
|
470
|
+
start?: SequencePlace;
|
|
471
|
+
end?: SequencePlace;
|
|
472
|
+
props?: PropertySet;
|
|
473
|
+
}): TInterval | undefined;
|
|
474
|
+
private get isCollaborating();
|
|
230
475
|
private addPendingChange;
|
|
231
476
|
private addPendingChangeHelper;
|
|
232
477
|
private removePendingChange;
|
|
233
478
|
private removePendingChangeHelper;
|
|
234
479
|
private hasPendingChangeStart;
|
|
235
480
|
private hasPendingChangeEnd;
|
|
236
|
-
/** @deprecated - use ackChange */
|
|
237
|
-
changeInterval(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
|
|
238
481
|
/** @internal */
|
|
239
|
-
ackChange(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
|
|
240
|
-
|
|
482
|
+
ackChange(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage, localOpMetadata: IMapMessageLocalMetadata | undefined): void;
|
|
483
|
+
/**
|
|
484
|
+
* {@inheritdoc IIntervalCollection.attachDeserializer}
|
|
485
|
+
*/
|
|
241
486
|
attachDeserializer(onDeserialize: DeserializeCallback): void;
|
|
242
|
-
/**
|
|
243
|
-
|
|
487
|
+
/**
|
|
488
|
+
* Returns new interval after rebasing. If undefined, the interval was
|
|
489
|
+
* deleted as a result of rebasing. This can occur if the interval applies
|
|
490
|
+
* to a range that no longer exists, and the interval was unable to slide.
|
|
491
|
+
*
|
|
492
|
+
* @internal
|
|
493
|
+
*/
|
|
494
|
+
rebaseLocalInterval(opName: string, serializedInterval: SerializedIntervalDelta, localSeq: number): SerializedIntervalDelta | undefined;
|
|
244
495
|
private getSlideToSegment;
|
|
245
|
-
private setSlideOnRemove;
|
|
246
496
|
private ackInterval;
|
|
247
|
-
/** @deprecated - use ackAdd */
|
|
248
|
-
addInternal(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): TInterval;
|
|
249
497
|
/** @internal */
|
|
250
|
-
ackAdd(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): TInterval;
|
|
251
|
-
/** @deprecated - use ackDelete */
|
|
252
|
-
deleteInterval(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
|
|
498
|
+
ackAdd(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage, localOpMetadata: IMapMessageLocalMetadata | undefined): TInterval | undefined;
|
|
253
499
|
/** @internal */
|
|
254
500
|
ackDelete(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
|
|
255
501
|
/**
|
|
256
502
|
* @internal
|
|
257
503
|
*/
|
|
258
504
|
serializeInternal(): ISerializedIntervalCollectionV2;
|
|
505
|
+
/**
|
|
506
|
+
* @returns an iterator over all intervals in this collection.
|
|
507
|
+
*/
|
|
259
508
|
[Symbol.iterator](): IntervalCollectionIterator<TInterval>;
|
|
509
|
+
/**
|
|
510
|
+
* {@inheritdoc IIntervalCollection.CreateForwardIteratorWithStartPosition}
|
|
511
|
+
*/
|
|
260
512
|
CreateForwardIteratorWithStartPosition(startPosition: number): IntervalCollectionIterator<TInterval>;
|
|
513
|
+
/**
|
|
514
|
+
* {@inheritdoc IIntervalCollection.CreateBackwardIteratorWithStartPosition}
|
|
515
|
+
*/
|
|
261
516
|
CreateBackwardIteratorWithStartPosition(startPosition: number): IntervalCollectionIterator<TInterval>;
|
|
517
|
+
/**
|
|
518
|
+
* {@inheritdoc IIntervalCollection.CreateForwardIteratorWithEndPosition}
|
|
519
|
+
*/
|
|
262
520
|
CreateForwardIteratorWithEndPosition(endPosition: number): IntervalCollectionIterator<TInterval>;
|
|
521
|
+
/**
|
|
522
|
+
* {@inheritdoc IIntervalCollection.CreateBackwardIteratorWithEndPosition}
|
|
523
|
+
*/
|
|
263
524
|
CreateBackwardIteratorWithEndPosition(endPosition: number): IntervalCollectionIterator<TInterval>;
|
|
525
|
+
/**
|
|
526
|
+
* {@inheritdoc IIntervalCollection.gatherIterationResults}
|
|
527
|
+
*/
|
|
264
528
|
gatherIterationResults(results: TInterval[], iteratesForward: boolean, start?: number, end?: number): void;
|
|
529
|
+
/**
|
|
530
|
+
* {@inheritdoc IIntervalCollection.findOverlappingIntervals}
|
|
531
|
+
*/
|
|
265
532
|
findOverlappingIntervals(startPosition: number, endPosition: number): TInterval[];
|
|
533
|
+
/**
|
|
534
|
+
* {@inheritdoc IIntervalCollection.map}
|
|
535
|
+
*/
|
|
266
536
|
map(fn: (interval: TInterval) => void): void;
|
|
267
|
-
|
|
268
|
-
|
|
537
|
+
/**
|
|
538
|
+
* {@inheritdoc IIntervalCollection.previousInterval}
|
|
539
|
+
*/
|
|
540
|
+
previousInterval(pos: number): TInterval | undefined;
|
|
541
|
+
/**
|
|
542
|
+
* {@inheritdoc IIntervalCollection.nextInterval}
|
|
543
|
+
*/
|
|
544
|
+
nextInterval(pos: number): TInterval | undefined;
|
|
269
545
|
}
|
|
546
|
+
/**
|
|
547
|
+
* Information that identifies an interval within a `Sequence`.
|
|
548
|
+
* @internal
|
|
549
|
+
*/
|
|
550
|
+
export interface IntervalLocator {
|
|
551
|
+
/**
|
|
552
|
+
* Label for the collection the interval is a part of
|
|
553
|
+
*/
|
|
554
|
+
label: string;
|
|
555
|
+
/**
|
|
556
|
+
* Interval within that collection
|
|
557
|
+
*/
|
|
558
|
+
interval: SequenceInterval;
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Returns an object that can be used to find the interval a given LocalReferencePosition belongs to.
|
|
562
|
+
* @returns undefined if the reference position is not the endpoint of any interval (e.g. it was created
|
|
563
|
+
* on the merge tree directly by app code), otherwise an {@link IntervalLocator} for the interval this
|
|
564
|
+
* endpoint is a part of.
|
|
565
|
+
* @internal
|
|
566
|
+
*/
|
|
567
|
+
export declare function intervalLocatorFromEndpoint(potentialEndpoint: LocalReferencePosition): IntervalLocator | undefined;
|
|
568
|
+
export {};
|
|
270
569
|
//# sourceMappingURL=intervalCollection.d.ts.map
|