@fluidframework/sequence 2.0.0-internal.7.2.2 → 2.0.0-internal.7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/api-extractor-lint.json +13 -0
- package/api-extractor.json +9 -1
- package/api-report/sequence.api.md +87 -84
- package/dist/defaultMap.d.ts +3 -3
- package/dist/defaultMap.d.ts.map +1 -1
- package/dist/defaultMap.js +7 -2
- package/dist/defaultMap.js.map +1 -1
- package/dist/defaultMapInterfaces.d.ts +11 -10
- package/dist/defaultMapInterfaces.d.ts.map +1 -1
- package/dist/defaultMapInterfaces.js.map +1 -1
- package/dist/intervalCollection.d.ts +68 -14
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +50 -45
- package/dist/intervalCollection.js.map +1 -1
- package/dist/intervalIndex/endpointInRangeIndex.d.ts +2 -2
- package/dist/intervalIndex/endpointInRangeIndex.js +1 -1
- package/dist/intervalIndex/endpointInRangeIndex.js.map +1 -1
- package/dist/intervalIndex/endpointIndex.d.ts +2 -2
- package/dist/intervalIndex/endpointIndex.js +1 -1
- package/dist/intervalIndex/endpointIndex.js.map +1 -1
- package/dist/intervalIndex/idIntervalIndex.d.ts +2 -2
- package/dist/intervalIndex/idIntervalIndex.js +1 -1
- package/dist/intervalIndex/idIntervalIndex.js.map +1 -1
- package/dist/intervalIndex/intervalIndex.d.ts +1 -1
- package/dist/intervalIndex/intervalIndex.js.map +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +2 -2
- package/dist/intervalIndex/overlappingIntervalsIndex.js +1 -1
- package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +1 -1
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js +1 -1
- package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
- package/dist/intervalIndex/sequenceIntervalIndexes.d.ts +2 -1
- package/dist/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
- package/dist/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
- package/dist/intervalIndex/startpointInRangeIndex.d.ts +2 -2
- package/dist/intervalIndex/startpointInRangeIndex.js +1 -1
- package/dist/intervalIndex/startpointInRangeIndex.js.map +1 -1
- package/dist/intervals/interval.d.ts +2 -7
- package/dist/intervals/interval.d.ts.map +1 -1
- package/dist/intervals/interval.js +1 -5
- package/dist/intervals/interval.js.map +1 -1
- package/dist/intervals/intervalUtils.d.ts +15 -14
- package/dist/intervals/intervalUtils.d.ts.map +1 -1
- package/dist/intervals/intervalUtils.js +4 -3
- package/dist/intervals/intervalUtils.js.map +1 -1
- package/dist/intervals/sequenceInterval.d.ts +3 -12
- package/dist/intervals/sequenceInterval.d.ts.map +1 -1
- package/dist/intervals/sequenceInterval.js +3 -11
- package/dist/intervals/sequenceInterval.js.map +1 -1
- package/dist/localValues.d.ts +2 -1
- package/dist/localValues.d.ts.map +1 -1
- package/dist/localValues.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/revertibles.d.ts +9 -15
- package/dist/revertibles.d.ts.map +1 -1
- package/dist/revertibles.js +41 -21
- package/dist/revertibles.js.map +1 -1
- package/dist/sequence-alpha.d.ts +1306 -0
- package/dist/sequence-beta.d.ts +270 -0
- package/dist/sequence-public.d.ts +270 -0
- package/dist/sequence-untrimmed.d.ts +1790 -0
- package/dist/sequence.d.ts +2 -3
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +4 -5
- package/dist/sequence.js.map +1 -1
- package/dist/sequenceDeltaEvent.d.ts +4 -4
- package/dist/sequenceDeltaEvent.d.ts.map +1 -1
- package/dist/sequenceDeltaEvent.js +4 -3
- package/dist/sequenceDeltaEvent.js.map +1 -1
- package/dist/sequenceFactory.d.ts +1 -1
- package/dist/sequenceFactory.js +1 -1
- package/dist/sequenceFactory.js.map +1 -1
- package/dist/sharedIntervalCollection.d.ts +3 -3
- package/dist/sharedIntervalCollection.js +2 -2
- package/dist/sharedIntervalCollection.js.map +1 -1
- package/dist/sharedSequence.d.ts +3 -3
- package/dist/sharedSequence.js +2 -2
- package/dist/sharedSequence.js.map +1 -1
- package/dist/sharedString.d.ts +8 -5
- package/dist/sharedString.d.ts.map +1 -1
- package/dist/sharedString.js +6 -3
- package/dist/sharedString.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/defaultMap.d.ts +3 -3
- package/lib/defaultMap.d.ts.map +1 -1
- package/lib/defaultMap.js +29 -20
- package/lib/defaultMap.js.map +1 -1
- package/lib/defaultMapInterfaces.d.ts +11 -10
- package/lib/defaultMapInterfaces.d.ts.map +1 -1
- package/lib/defaultMapInterfaces.js +2 -1
- package/lib/defaultMapInterfaces.js.map +1 -1
- package/lib/index.js +45 -10
- package/lib/index.js.map +1 -1
- package/lib/intervalCollection.d.ts +68 -14
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +174 -156
- package/lib/intervalCollection.js.map +1 -1
- package/lib/intervalIndex/endpointInRangeIndex.d.ts +2 -2
- package/lib/intervalIndex/endpointInRangeIndex.js +18 -13
- package/lib/intervalIndex/endpointInRangeIndex.js.map +1 -1
- package/lib/intervalIndex/endpointIndex.d.ts +2 -2
- package/lib/intervalIndex/endpointIndex.js +14 -9
- package/lib/intervalIndex/endpointIndex.js.map +1 -1
- package/lib/intervalIndex/idIntervalIndex.d.ts +2 -2
- package/lib/intervalIndex/idIntervalIndex.js +9 -5
- package/lib/intervalIndex/idIntervalIndex.js.map +1 -1
- package/lib/intervalIndex/index.js +19 -6
- package/lib/intervalIndex/index.js.map +1 -1
- package/lib/intervalIndex/intervalIndex.d.ts +1 -1
- package/lib/intervalIndex/intervalIndex.js +2 -1
- package/lib/intervalIndex/intervalIndex.js.map +1 -1
- package/lib/intervalIndex/intervalIndexUtils.js +8 -4
- package/lib/intervalIndex/intervalIndexUtils.js.map +1 -1
- package/lib/intervalIndex/overlappingIntervalsIndex.d.ts +2 -2
- package/lib/intervalIndex/overlappingIntervalsIndex.js +16 -11
- package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +1 -1
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js +15 -11
- package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.d.ts +2 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.js +2 -1
- package/lib/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
- package/lib/intervalIndex/startpointInRangeIndex.d.ts +2 -2
- package/lib/intervalIndex/startpointInRangeIndex.js +18 -13
- package/lib/intervalIndex/startpointInRangeIndex.js.map +1 -1
- package/lib/intervalTree.js +9 -4
- package/lib/intervalTree.js.map +1 -1
- package/lib/intervals/index.js +18 -3
- package/lib/intervals/index.js.map +1 -1
- package/lib/intervals/interval.d.ts +2 -7
- package/lib/intervals/interval.d.ts.map +1 -1
- package/lib/intervals/interval.js +19 -18
- package/lib/intervals/interval.js.map +1 -1
- package/lib/intervals/intervalUtils.d.ts +15 -14
- package/lib/intervals/intervalUtils.d.ts.map +1 -1
- package/lib/intervals/intervalUtils.js +22 -16
- package/lib/intervals/intervalUtils.js.map +1 -1
- package/lib/intervals/sequenceInterval.d.ts +3 -12
- package/lib/intervals/sequenceInterval.d.ts.map +1 -1
- package/lib/intervals/sequenceInterval.js +68 -70
- package/lib/intervals/sequenceInterval.js.map +1 -1
- package/lib/localValues.d.ts +2 -1
- package/lib/localValues.d.ts.map +1 -1
- package/lib/localValues.js +9 -4
- package/lib/localValues.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +5 -2
- package/lib/packageVersion.js.map +1 -1
- package/lib/revertibles.d.ts +9 -15
- package/lib/revertibles.d.ts.map +1 -1
- package/lib/revertibles.js +98 -68
- package/lib/revertibles.js.map +1 -1
- package/lib/sequence-alpha.d.ts +1306 -0
- package/lib/sequence-beta.d.ts +270 -0
- package/lib/sequence-public.d.ts +270 -0
- package/lib/sequence-untrimmed.d.ts +1790 -0
- package/lib/sequence.d.ts +2 -3
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +46 -46
- package/lib/sequence.js.map +1 -1
- package/lib/sequenceDeltaEvent.d.ts +4 -4
- package/lib/sequenceDeltaEvent.d.ts.map +1 -1
- package/lib/sequenceDeltaEvent.js +17 -10
- package/lib/sequenceDeltaEvent.js.map +1 -1
- package/lib/sequenceFactory.d.ts +1 -1
- package/lib/sequenceFactory.js +14 -10
- package/lib/sequenceFactory.js.map +1 -1
- package/lib/sharedIntervalCollection.d.ts +3 -3
- package/lib/sharedIntervalCollection.js +20 -15
- package/lib/sharedIntervalCollection.js.map +1 -1
- package/lib/sharedSequence.d.ts +3 -3
- package/lib/sharedSequence.js +13 -8
- package/lib/sharedSequence.js.map +1 -1
- package/lib/sharedString.d.ts +8 -5
- package/lib/sharedString.d.ts.map +1 -1
- package/lib/sharedString.js +27 -19
- package/lib/sharedString.js.map +1 -1
- package/package.json +43 -29
- package/sequence.test-files.tar +0 -0
- package/src/defaultMap.ts +22 -16
- package/src/defaultMapInterfaces.ts +15 -12
- package/src/intervalCollection.ts +131 -67
- package/src/intervalIndex/endpointInRangeIndex.ts +2 -2
- package/src/intervalIndex/endpointIndex.ts +2 -2
- package/src/intervalIndex/idIntervalIndex.ts +2 -2
- package/src/intervalIndex/intervalIndex.ts +1 -1
- package/src/intervalIndex/overlappingIntervalsIndex.ts +2 -2
- package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +1 -1
- package/src/intervalIndex/sequenceIntervalIndexes.ts +2 -1
- package/src/intervalIndex/startpointInRangeIndex.ts +2 -2
- package/src/intervals/interval.ts +2 -7
- package/src/intervals/intervalUtils.ts +16 -15
- package/src/intervals/sequenceInterval.ts +3 -12
- package/src/localValues.ts +2 -1
- package/src/packageVersion.ts +1 -1
- package/src/revertibles.ts +95 -24
- package/src/sequence.ts +5 -7
- package/src/sequenceDeltaEvent.ts +6 -4
- package/src/sequenceFactory.ts +1 -1
- package/src/sharedIntervalCollection.ts +3 -3
- package/src/sharedSequence.ts +3 -3
- package/src/sharedString.ts +8 -5
- package/tsconfig.esnext.json +1 -2
- package/tsconfig.json +5 -3
|
@@ -0,0 +1,1306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supports distributed data structures which are list-like.
|
|
3
|
+
*
|
|
4
|
+
* This library's main export is {@link SharedString}, a DDS for storing and simultaneously editing a sequence of
|
|
5
|
+
* text.
|
|
6
|
+
*
|
|
7
|
+
* See the package's README for a high-level introduction to `SharedString`'s feature set.
|
|
8
|
+
* @remarks Note that SharedString is a sequence DDS but it has additional specialized features and behaviors for
|
|
9
|
+
* working with text.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { BaseSegment } from '@fluidframework/merge-tree';
|
|
15
|
+
import { Client } from '@fluidframework/merge-tree';
|
|
16
|
+
import { Deferred } from '@fluidframework/core-utils';
|
|
17
|
+
import { IChannelAttributes } from '@fluidframework/datastore-definitions';
|
|
18
|
+
import { IChannelFactory } from '@fluidframework/datastore-definitions';
|
|
19
|
+
import { IChannelServices } from '@fluidframework/datastore-definitions';
|
|
20
|
+
import { IChannelStorageService } from '@fluidframework/datastore-definitions';
|
|
21
|
+
import { ICombiningOp } from '@fluidframework/merge-tree';
|
|
22
|
+
import { IEvent } from '@fluidframework/core-interfaces';
|
|
23
|
+
import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
|
|
24
|
+
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
|
|
25
|
+
import { IFluidSerializer } from '@fluidframework/shared-object-base';
|
|
26
|
+
import { IJSONSegment } from '@fluidframework/merge-tree';
|
|
27
|
+
import { IMergeTreeDeltaCallbackArgs } from '@fluidframework/merge-tree';
|
|
28
|
+
import { IMergeTreeDeltaOpArgs } from '@fluidframework/merge-tree';
|
|
29
|
+
import { IMergeTreeGroupMsg } from '@fluidframework/merge-tree';
|
|
30
|
+
import { IMergeTreeInsertMsg } from '@fluidframework/merge-tree';
|
|
31
|
+
import { IMergeTreeMaintenanceCallbackArgs } from '@fluidframework/merge-tree';
|
|
32
|
+
import { IMergeTreeOp } from '@fluidframework/merge-tree';
|
|
33
|
+
import { IMergeTreeRemoveMsg } from '@fluidframework/merge-tree';
|
|
34
|
+
import { IRelativePosition } from '@fluidframework/merge-tree';
|
|
35
|
+
import { ISegment } from '@fluidframework/merge-tree';
|
|
36
|
+
import { ISegmentAction } from '@fluidframework/merge-tree';
|
|
37
|
+
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
38
|
+
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
|
|
39
|
+
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
|
|
40
|
+
import { ITelemetryContext } from '@fluidframework/runtime-definitions';
|
|
41
|
+
import { LocalReferencePosition } from '@fluidframework/merge-tree';
|
|
42
|
+
import { Marker } from '@fluidframework/merge-tree';
|
|
43
|
+
import { MergeTreeDeltaOperationType } from '@fluidframework/merge-tree';
|
|
44
|
+
import { MergeTreeDeltaOperationTypes } from '@fluidframework/merge-tree';
|
|
45
|
+
import { MergeTreeDeltaRevertible } from '@fluidframework/merge-tree';
|
|
46
|
+
import { MergeTreeMaintenanceType } from '@fluidframework/merge-tree';
|
|
47
|
+
import { MergeTreeRevertibleDriver } from '@fluidframework/merge-tree';
|
|
48
|
+
import { PropertiesManager } from '@fluidframework/merge-tree';
|
|
49
|
+
import { PropertySet } from '@fluidframework/merge-tree';
|
|
50
|
+
import { RangeStackMap } from '@fluidframework/merge-tree';
|
|
51
|
+
import { ReferencePosition } from '@fluidframework/merge-tree';
|
|
52
|
+
import { ReferenceType } from '@fluidframework/merge-tree';
|
|
53
|
+
import { Serializable } from '@fluidframework/datastore-definitions';
|
|
54
|
+
import { SharedObject } from '@fluidframework/shared-object-base';
|
|
55
|
+
import { SlidingPreference } from '@fluidframework/merge-tree';
|
|
56
|
+
import { SummarySerializer } from '@fluidframework/shared-object-base';
|
|
57
|
+
import { TextSegment } from '@fluidframework/merge-tree';
|
|
58
|
+
import { TypedEventEmitter } from '@fluid-internal/client-utils';
|
|
59
|
+
|
|
60
|
+
/* Excluded from this release type: appendAddIntervalToRevertibles */
|
|
61
|
+
|
|
62
|
+
/* Excluded from this release type: appendChangeIntervalToRevertibles */
|
|
63
|
+
|
|
64
|
+
/* Excluded from this release type: appendDeleteIntervalToRevertibles */
|
|
65
|
+
|
|
66
|
+
/* Excluded from this release type: appendIntervalPropertyChangedToRevertibles */
|
|
67
|
+
|
|
68
|
+
/* Excluded from this release type: appendSharedStringDeltaToRevertibles */
|
|
69
|
+
|
|
70
|
+
/* Excluded from this release type: createEndpointIndex */
|
|
71
|
+
|
|
72
|
+
/* Excluded from this release type: createEndpointInRangeIndex */
|
|
73
|
+
|
|
74
|
+
/* Excluded from this release type: createIdIntervalIndex */
|
|
75
|
+
|
|
76
|
+
/* Excluded from this release type: createOverlappingIntervalsIndex */
|
|
77
|
+
|
|
78
|
+
/* Excluded from this release type: createOverlappingSequenceIntervalsIndex */
|
|
79
|
+
|
|
80
|
+
/* Excluded from this release type: createStartpointInRangeIndex */
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @alpha
|
|
84
|
+
*/
|
|
85
|
+
export declare type DeserializeCallback = (properties: PropertySet) => void;
|
|
86
|
+
|
|
87
|
+
/* Excluded from this release type: discardSharedStringRevertibles */
|
|
88
|
+
|
|
89
|
+
/* Excluded from this release type: getTextAndMarkers */
|
|
90
|
+
|
|
91
|
+
/* Excluded from this release type: IEndpointIndex */
|
|
92
|
+
|
|
93
|
+
/* Excluded from this release type: IEndpointInRangeIndex */
|
|
94
|
+
|
|
95
|
+
/* Excluded from this release type: IIdIntervalIndex */
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Basic interval abstraction
|
|
99
|
+
* @alpha
|
|
100
|
+
*/
|
|
101
|
+
export declare interface IInterval {
|
|
102
|
+
/**
|
|
103
|
+
* @returns a new interval object with identical semantics.
|
|
104
|
+
*/
|
|
105
|
+
clone(): IInterval;
|
|
106
|
+
/**
|
|
107
|
+
* Compares this interval to `b` with standard comparator semantics:
|
|
108
|
+
* - returns -1 if this is less than `b`
|
|
109
|
+
* - returns 1 if this is greater than `b`
|
|
110
|
+
* - returns 0 if this is equivalent to `b`
|
|
111
|
+
* @param b - Interval to compare against
|
|
112
|
+
*/
|
|
113
|
+
compare(b: IInterval): number;
|
|
114
|
+
/**
|
|
115
|
+
* Compares the start endpoint of this interval to `b`'s start endpoint.
|
|
116
|
+
* Standard comparator semantics apply.
|
|
117
|
+
* @param b - Interval to compare against
|
|
118
|
+
*/
|
|
119
|
+
compareStart(b: IInterval): number;
|
|
120
|
+
/**
|
|
121
|
+
* Compares the end endpoint of this interval to `b`'s end endpoint.
|
|
122
|
+
* Standard comparator semantics apply.
|
|
123
|
+
* @param b - Interval to compare against
|
|
124
|
+
*/
|
|
125
|
+
compareEnd(b: IInterval): number;
|
|
126
|
+
/**
|
|
127
|
+
* Modifies one or more of the endpoints of this interval, returning a new interval representing the result.
|
|
128
|
+
*/
|
|
129
|
+
modify(label: string, start: SequencePlace | undefined, end: SequencePlace | undefined, op?: ISequencedDocumentMessage, localSeq?: number, useNewSlidingBehavior?: boolean): IInterval | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* @returns whether this interval overlaps with `b`.
|
|
132
|
+
* Intervals are considered to overlap if their intersection is non-empty.
|
|
133
|
+
*/
|
|
134
|
+
overlaps(b: IInterval): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Unions this interval with `b`, returning a new interval.
|
|
137
|
+
* The union operates as a convex hull, i.e. if the two intervals are disjoint, the return value includes
|
|
138
|
+
* intermediate values between the two intervals.
|
|
139
|
+
*/
|
|
140
|
+
union(b: IInterval): IInterval;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Collection of intervals that supports addition, modification, removal, and efficient spatial querying.
|
|
145
|
+
* Changes to this collection will be incur updates on collaborating clients (i.e. they are not local-only).
|
|
146
|
+
* @alpha
|
|
147
|
+
*/
|
|
148
|
+
export declare interface IIntervalCollection<TInterval extends ISerializableInterval> extends TypedEventEmitter<IIntervalCollectionEvent<TInterval>> {
|
|
149
|
+
readonly attached: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Attaches an index to this collection.
|
|
152
|
+
* All intervals which are part of this collection will be added to the index, and the index will automatically
|
|
153
|
+
* be updated when this collection updates due to local or remote changes.
|
|
154
|
+
*
|
|
155
|
+
* @remarks After attaching an index to an interval collection, applications should typically store this
|
|
156
|
+
* index somewhere in their in-memory data model for future reference and querying.
|
|
157
|
+
*/
|
|
158
|
+
attachIndex(index: IntervalIndex<TInterval>): void;
|
|
159
|
+
/**
|
|
160
|
+
* Detaches an index from this collection.
|
|
161
|
+
* All intervals which are part of this collection will be removed from the index, and updates to this collection
|
|
162
|
+
* due to local or remote changes will no longer incur updates to the index.
|
|
163
|
+
*
|
|
164
|
+
* @returns `false` if the target index cannot be found in the indexes, otherwise remove all intervals in the index and return `true`.
|
|
165
|
+
*/
|
|
166
|
+
detachIndex(index: IntervalIndex<TInterval>): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* @returns the interval in this collection that has the provided `id`.
|
|
169
|
+
* If no interval in the collection has this `id`, returns `undefined`.
|
|
170
|
+
*/
|
|
171
|
+
getIntervalById(id: string): TInterval | undefined;
|
|
172
|
+
/**
|
|
173
|
+
* Creates a new interval and add it to the collection.
|
|
174
|
+
* @deprecated call IntervalCollection.add without specifying an intervalType
|
|
175
|
+
* @param start - interval start position (inclusive)
|
|
176
|
+
* @param end - interval end position (exclusive)
|
|
177
|
+
* @param intervalType - type of the interval. All intervals are SlideOnRemove. Intervals may not be Transient.
|
|
178
|
+
* @param props - properties of the interval
|
|
179
|
+
* @returns The created interval
|
|
180
|
+
* @remarks See documentation on {@link SequenceInterval} for comments on
|
|
181
|
+
* interval endpoint semantics: there are subtleties with how the current
|
|
182
|
+
* half-open behavior is represented.
|
|
183
|
+
*
|
|
184
|
+
* Note that intervals may behave unexpectedly if the entire contents
|
|
185
|
+
* of the string are deleted. In this case, it is possible for one endpoint
|
|
186
|
+
* of the interval to become detached, while the other remains on the string.
|
|
187
|
+
*
|
|
188
|
+
* By adjusting the `side` and `pos` values of the `start` and `end` parameters,
|
|
189
|
+
* it is possible to control whether the interval expands to include content
|
|
190
|
+
* inserted at its start or end.
|
|
191
|
+
*
|
|
192
|
+
* See {@link SequencePlace} for more details on the model.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
*
|
|
196
|
+
* Given the string "ABCD":
|
|
197
|
+
*
|
|
198
|
+
*```typescript
|
|
199
|
+
* // Refers to "BC". If any content is inserted before B or after C, this
|
|
200
|
+
* // interval will include that content
|
|
201
|
+
* //
|
|
202
|
+
* // Picture:
|
|
203
|
+
* // \{start\} - A[- B - C -]D - \{end\}
|
|
204
|
+
* // \{start\} - A - B - C - D - \{end\}
|
|
205
|
+
* collection.add(\{ pos: 0, side: Side.After \}, \{ pos: 3, side: Side.Before \}, IntervalType.SlideOnRemove);
|
|
206
|
+
* // Equivalent to specifying the same positions and Side.Before.
|
|
207
|
+
* // Refers to "ABC". Content inserted after C will be included in the
|
|
208
|
+
* // interval, but content inserted before A will not.
|
|
209
|
+
* // \{start\} -[A - B - C -]D - \{end\}
|
|
210
|
+
* // \{start\} - A - B - C - D - \{end\}
|
|
211
|
+
* collection.add(0, 3, IntervalType.SlideOnRemove);
|
|
212
|
+
*```
|
|
213
|
+
*
|
|
214
|
+
* In the case of the first example, if text is deleted,
|
|
215
|
+
*
|
|
216
|
+
* ```typescript
|
|
217
|
+
* // Delete the character "B"
|
|
218
|
+
* string.removeRange(1, 2);
|
|
219
|
+
* ```
|
|
220
|
+
*
|
|
221
|
+
* The start point of the interval will slide to the position immediately
|
|
222
|
+
* before "C", and the same will be true.
|
|
223
|
+
*
|
|
224
|
+
* ```
|
|
225
|
+
* \{start\} - A[- C -]D - \{end\}
|
|
226
|
+
* ```
|
|
227
|
+
*
|
|
228
|
+
* In this case, text inserted immediately before "C" would be included in
|
|
229
|
+
* the interval.
|
|
230
|
+
*
|
|
231
|
+
* ```typescript
|
|
232
|
+
* string.insertText(1, "EFG");
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* With the string now being,
|
|
236
|
+
*
|
|
237
|
+
* ```
|
|
238
|
+
* \{start\} - A[- E - F - G - C -]D - \{end\}
|
|
239
|
+
* ```
|
|
240
|
+
*
|
|
241
|
+
* @privateRemarks TODO: ADO:5205 the above comment regarding behavior in
|
|
242
|
+
* the case that the entire interval has been deleted should be resolved at
|
|
243
|
+
* the same time as this ticket
|
|
244
|
+
*/
|
|
245
|
+
add(start: SequencePlace, end: SequencePlace, intervalType: IntervalType, props?: PropertySet): TInterval;
|
|
246
|
+
/**
|
|
247
|
+
* Creates a new interval and add it to the collection.
|
|
248
|
+
* @param start - interval start position (inclusive)
|
|
249
|
+
* @param end - interval end position (exclusive)
|
|
250
|
+
* @param props - properties of the interval
|
|
251
|
+
* @returns - the created interval
|
|
252
|
+
* @remarks - See documentation on {@link SequenceInterval} for comments on interval endpoint semantics: there are subtleties
|
|
253
|
+
* with how the current half-open behavior is represented.
|
|
254
|
+
*/
|
|
255
|
+
add({ start, end, props, }: {
|
|
256
|
+
start: SequencePlace;
|
|
257
|
+
end: SequencePlace;
|
|
258
|
+
props?: PropertySet;
|
|
259
|
+
}): TInterval;
|
|
260
|
+
/**
|
|
261
|
+
* Removes an interval from the collection.
|
|
262
|
+
* @param id - Id of the interval to remove
|
|
263
|
+
* @returns the removed interval
|
|
264
|
+
*/
|
|
265
|
+
removeIntervalById(id: string): TInterval | undefined;
|
|
266
|
+
/**
|
|
267
|
+
* Changes the properties on an existing interval.
|
|
268
|
+
* @deprecated - call change with the id and and object containing the new properties
|
|
269
|
+
* @param id - Id of the interval whose properties should be changed
|
|
270
|
+
* @param props - Property set to apply to the interval. Shallow merging is used between any existing properties
|
|
271
|
+
* and `prop`, i.e. the interval will end up with a property object equivalent to `{ ...oldProps, ...props }`.
|
|
272
|
+
*/
|
|
273
|
+
changeProperties(id: string, props: PropertySet): any;
|
|
274
|
+
/**
|
|
275
|
+
* Changes the endpoints of an existing interval.
|
|
276
|
+
* @deprecated - call change with the start and end parameters encapsulated in an object
|
|
277
|
+
* @param id - Id of the interval to change
|
|
278
|
+
* @param start - New start value. To leave the endpoint unchanged, pass the current value.
|
|
279
|
+
* @param end - New end value. To leave the endpoint unchanged, pass the current value.
|
|
280
|
+
* @returns the interval that was changed, if it existed in the collection.
|
|
281
|
+
*/
|
|
282
|
+
change(id: string, start: SequencePlace, end: SequencePlace): TInterval | undefined;
|
|
283
|
+
/**
|
|
284
|
+
* Changes the endpoints, properties, or both of an existing interval.
|
|
285
|
+
* @param id - Id of the Interval to change
|
|
286
|
+
* @returns the interval that was changed, if it existed in the collection.
|
|
287
|
+
* Pass the desired new start position, end position, and/or properties in an object. Start and end positions must be changed
|
|
288
|
+
* simultaneously - they must either both be specified or both undefined. To only change the properties, leave both endpoints
|
|
289
|
+
* undefined. To only change the endpoints, leave the properties undefined.
|
|
290
|
+
*/
|
|
291
|
+
change(id: string, { start, end, props }: {
|
|
292
|
+
start?: SequencePlace;
|
|
293
|
+
end?: SequencePlace;
|
|
294
|
+
props?: PropertySet;
|
|
295
|
+
}): TInterval | undefined;
|
|
296
|
+
attachDeserializer(onDeserialize: DeserializeCallback): void;
|
|
297
|
+
/**
|
|
298
|
+
* @returns an iterator over all intervals in this collection.
|
|
299
|
+
*/
|
|
300
|
+
[Symbol.iterator](): Iterator<TInterval>;
|
|
301
|
+
/**
|
|
302
|
+
* @returns a forward iterator over all intervals in this collection with start point equal to `startPosition`.
|
|
303
|
+
*/
|
|
304
|
+
CreateForwardIteratorWithStartPosition(startPosition: number): Iterator<TInterval>;
|
|
305
|
+
/**
|
|
306
|
+
* @returns a backward iterator over all intervals in this collection with start point equal to `startPosition`.
|
|
307
|
+
*/
|
|
308
|
+
CreateBackwardIteratorWithStartPosition(startPosition: number): Iterator<TInterval>;
|
|
309
|
+
/**
|
|
310
|
+
* @returns a forward iterator over all intervals in this collection with end point equal to `endPosition`.
|
|
311
|
+
*/
|
|
312
|
+
CreateForwardIteratorWithEndPosition(endPosition: number): Iterator<TInterval>;
|
|
313
|
+
/**
|
|
314
|
+
* @returns a backward iterator over all intervals in this collection with end point equal to `endPosition`.
|
|
315
|
+
*/
|
|
316
|
+
CreateBackwardIteratorWithEndPosition(endPosition: number): Iterator<TInterval>;
|
|
317
|
+
/**
|
|
318
|
+
* Gathers iteration results that optionally match a start/end criteria into the provided array.
|
|
319
|
+
* @param results - Array to gather the results into. In lieu of a return value, this array will be populated with
|
|
320
|
+
* intervals matching the query upon edit.
|
|
321
|
+
* @param iteratesForward - whether or not iteration should be in the forward direction
|
|
322
|
+
* @param start - If provided, only match intervals whose start point is equal to `start`.
|
|
323
|
+
* @param end - If provided, only match intervals whose end point is equal to `end`.
|
|
324
|
+
*/
|
|
325
|
+
gatherIterationResults(results: TInterval[], iteratesForward: boolean, start?: number, end?: number): void;
|
|
326
|
+
/**
|
|
327
|
+
* @deprecated - Users must manually attach the corresponding interval index to utilize this functionality, for instance:
|
|
328
|
+
*
|
|
329
|
+
* ```typescript
|
|
330
|
+
* const overlappingIntervalsIndex = createOverlappingIntervalsIndex(sharedString);
|
|
331
|
+
* collection.attachIndex(overlappingIntervalsIndex)
|
|
332
|
+
* const result = overlappingIntervalsIndex.findOverlappingIntervals(start, end);
|
|
333
|
+
* ```
|
|
334
|
+
*
|
|
335
|
+
* @returns an array of all intervals in this collection that overlap with the interval
|
|
336
|
+
* `[startPosition, endPosition]`.
|
|
337
|
+
*/
|
|
338
|
+
findOverlappingIntervals(startPosition: number, endPosition: number): TInterval[];
|
|
339
|
+
/**
|
|
340
|
+
* Applies a function to each interval in this collection.
|
|
341
|
+
*/
|
|
342
|
+
map(fn: (interval: TInterval) => void): void;
|
|
343
|
+
/**
|
|
344
|
+
* @deprecated - due to the forthcoming change where the endpointIndex will no longer be
|
|
345
|
+
* automatically added to the collection. Users are advised to independently attach the
|
|
346
|
+
* index to the collection and utilize the API accordingly, for instance:
|
|
347
|
+
* ```typescript
|
|
348
|
+
* const endpointIndex = createEndpointIndex(sharedString);
|
|
349
|
+
* collection.attachIndex(endpointIndex);
|
|
350
|
+
* const result1 = endpointIndex.previousInterval(pos);
|
|
351
|
+
* ```
|
|
352
|
+
* If an index is used repeatedly, applications should generally attach it once and store it in memory.
|
|
353
|
+
*/
|
|
354
|
+
previousInterval(pos: number): TInterval | undefined;
|
|
355
|
+
/**
|
|
356
|
+
* @deprecated - due to the forthcoming change where the endpointIndex will no longer be
|
|
357
|
+
* automatically added to the collection. Users are advised to independently attach the
|
|
358
|
+
* index to the collection and utilize the API accordingly, for instance:
|
|
359
|
+
* ```typescript
|
|
360
|
+
* const endpointIndex = createEndpointIndex(sharedString);
|
|
361
|
+
* collection.attachIndex(endpointIndex);
|
|
362
|
+
* const result2 = endpointIndex.nextInterval(pos);
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
nextInterval(pos: number): TInterval | undefined;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Change events emitted by `IntervalCollection`s
|
|
370
|
+
* @alpha
|
|
371
|
+
*/
|
|
372
|
+
export declare interface IIntervalCollectionEvent<TInterval extends ISerializableInterval> extends IEvent {
|
|
373
|
+
/**
|
|
374
|
+
* This event is invoked whenever the endpoints of an interval may have changed.
|
|
375
|
+
* This can happen on:
|
|
376
|
+
* - local endpoint modification
|
|
377
|
+
* - ack of a remote endpoint modification
|
|
378
|
+
* - position change due to segment sliding (slides due to mergeTree segment deletion will always appear local)
|
|
379
|
+
* The `interval` argument reflects the new values.
|
|
380
|
+
* `previousInterval` contains transient `ReferencePosition`s at the same location as the interval's original
|
|
381
|
+
* endpoints. These references should be used for position information only.
|
|
382
|
+
* `local` reflects whether the change originated locally.
|
|
383
|
+
* `op` is defined if and only if the server has acked this change.
|
|
384
|
+
* `slide` is true if the change is due to sliding on removal of position
|
|
385
|
+
*/
|
|
386
|
+
(event: "changeInterval", listener: (interval: TInterval, previousInterval: TInterval, local: boolean, op: ISequencedDocumentMessage | undefined, slide: boolean) => void): any;
|
|
387
|
+
/**
|
|
388
|
+
* This event is invoked whenever an interval is added or removed from the collection.
|
|
389
|
+
* `local` reflects whether the change originated locally.
|
|
390
|
+
* `op` is defined if and only if the server has acked this change.
|
|
391
|
+
*/
|
|
392
|
+
(event: "addInterval" | "deleteInterval", listener: (interval: TInterval, local: boolean, op: ISequencedDocumentMessage | undefined) => void): any;
|
|
393
|
+
/**
|
|
394
|
+
* This event is invoked whenever an interval's properties have changed.
|
|
395
|
+
* `interval` reflects the state of the updated properties.
|
|
396
|
+
* `propertyDeltas` is a map-like whose keys contain all values that were changed, and whose
|
|
397
|
+
* values contain all previous values of the property set.
|
|
398
|
+
* This object can be used directly in a call to `changeProperties` to revert the property change if desired.
|
|
399
|
+
* `local` reflects whether the change originated locally.
|
|
400
|
+
* `op` is defined if and only if the server has acked this change.
|
|
401
|
+
*/
|
|
402
|
+
(event: "propertyChanged", listener: (interval: TInterval, propertyDeltas: PropertySet, local: boolean, op: ISequencedDocumentMessage | undefined) => void): any;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/* Excluded from this release type: IIntervalHelpers */
|
|
406
|
+
|
|
407
|
+
/* Excluded from this release type: IJSONRunSegment */
|
|
408
|
+
|
|
409
|
+
/* Excluded from this release type: IMapMessageLocalMetadata */
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* A sequence place that does not refer to the special endpoint segments.
|
|
413
|
+
*
|
|
414
|
+
* See {@link SequencePlace} for additional context.
|
|
415
|
+
* @alpha
|
|
416
|
+
*/
|
|
417
|
+
export declare interface InteriorSequencePlace {
|
|
418
|
+
pos: number;
|
|
419
|
+
side: Side;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/* Excluded from this release type: Interval */
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Collection of intervals.
|
|
426
|
+
*
|
|
427
|
+
* Implementers of this interface will typically implement additional APIs to support efficiently querying a collection
|
|
428
|
+
* of intervals in some manner, for example:
|
|
429
|
+
* - "find all intervals with start endpoint between these two points"
|
|
430
|
+
* - "find all intervals which overlap this range"
|
|
431
|
+
* etc.
|
|
432
|
+
* @alpha
|
|
433
|
+
*/
|
|
434
|
+
export declare interface IntervalIndex<TInterval extends ISerializableInterval> {
|
|
435
|
+
/**
|
|
436
|
+
* Adds an interval to the index.
|
|
437
|
+
* @remarks Application code should never need to invoke this method on their index for production scenarios:
|
|
438
|
+
* Fluid handles adding and removing intervals from an index in response to sequence or interval changes.
|
|
439
|
+
*/
|
|
440
|
+
add(interval: TInterval): void;
|
|
441
|
+
/**
|
|
442
|
+
* Removes an interval from the index.
|
|
443
|
+
* @remarks Application code should never need to invoke this method on their index for production scenarios:
|
|
444
|
+
* Fluid handles adding and removing intervals from an index in response to sequence or interval changes.
|
|
445
|
+
*/
|
|
446
|
+
remove(interval: TInterval): void;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/* Excluded from this release type: IntervalLocator */
|
|
450
|
+
|
|
451
|
+
/* Excluded from this release type: intervalLocatorFromEndpoint */
|
|
452
|
+
|
|
453
|
+
/* Excluded from this release type: IntervalOpType */
|
|
454
|
+
|
|
455
|
+
/* Excluded from this release type: IntervalRevertible */
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Determines how an interval should expand when segments are inserted adjacent
|
|
459
|
+
* to the range it spans
|
|
460
|
+
*
|
|
461
|
+
* Note that interval stickiness is currently an experimental feature and must
|
|
462
|
+
* be explicitly enabled with the `intervalStickinessEnabled` flag
|
|
463
|
+
*
|
|
464
|
+
* @alpha
|
|
465
|
+
*/
|
|
466
|
+
export declare const IntervalStickiness: {
|
|
467
|
+
/**
|
|
468
|
+
* Interval does not expand to include adjacent segments
|
|
469
|
+
*/
|
|
470
|
+
readonly NONE: 0;
|
|
471
|
+
/**
|
|
472
|
+
* Interval expands to include segments inserted adjacent to the start
|
|
473
|
+
*/
|
|
474
|
+
readonly START: 1;
|
|
475
|
+
/**
|
|
476
|
+
* Interval expands to include segments inserted adjacent to the end
|
|
477
|
+
*
|
|
478
|
+
* This is the default stickiness
|
|
479
|
+
*/
|
|
480
|
+
readonly END: 2;
|
|
481
|
+
/**
|
|
482
|
+
* Interval expands to include all segments inserted adjacent to it
|
|
483
|
+
*/
|
|
484
|
+
readonly FULL: 3;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Determines how an interval should expand when segments are inserted adjacent
|
|
489
|
+
* to the range it spans
|
|
490
|
+
*
|
|
491
|
+
* Note that interval stickiness is currently an experimental feature and must
|
|
492
|
+
* be explicitly enabled with the `intervalStickinessEnabled` flag
|
|
493
|
+
* @alpha
|
|
494
|
+
*/
|
|
495
|
+
export declare type IntervalStickiness = (typeof IntervalStickiness)[keyof typeof IntervalStickiness];
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* @alpha
|
|
499
|
+
*/
|
|
500
|
+
export declare enum IntervalType {
|
|
501
|
+
Simple = 0,
|
|
502
|
+
/**
|
|
503
|
+
* @deprecated this functionality is no longer supported and will be removed
|
|
504
|
+
*/
|
|
505
|
+
Nest = 1,
|
|
506
|
+
/**
|
|
507
|
+
* SlideOnRemove indicates that the ends of the interval will slide if the segment
|
|
508
|
+
* they reference is removed and acked.
|
|
509
|
+
* See `packages\dds\merge-tree\docs\REFERENCEPOSITIONS.md` for details
|
|
510
|
+
* SlideOnRemove is the default interval behavior and does not need to be specified.
|
|
511
|
+
*/
|
|
512
|
+
SlideOnRemove = 2,
|
|
513
|
+
/* Excluded from this release type: Transient */
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/* Excluded from this release type: IOverlappingIntervalsIndex */
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* A range that has changed corresponding to a segment modification.
|
|
520
|
+
* @alpha
|
|
521
|
+
*/
|
|
522
|
+
export declare interface ISequenceDeltaRange<TOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes> {
|
|
523
|
+
/**
|
|
524
|
+
* The type of operation that changed this range.
|
|
525
|
+
*
|
|
526
|
+
* @remarks Consuming code should typically compare this to the enum values defined in
|
|
527
|
+
* `MergeTreeDeltaOperationTypes`.
|
|
528
|
+
*/
|
|
529
|
+
operation: TOperation;
|
|
530
|
+
/**
|
|
531
|
+
* The index of the start of the range.
|
|
532
|
+
*/
|
|
533
|
+
position: number;
|
|
534
|
+
/**
|
|
535
|
+
* The segment that corresponds to the range.
|
|
536
|
+
*/
|
|
537
|
+
segment: ISegment;
|
|
538
|
+
/**
|
|
539
|
+
* Deltas object which contains all modified properties with their previous values.
|
|
540
|
+
* Since `undefined` doesn't survive a round-trip through JSON serialization, the old value being absent
|
|
541
|
+
* is instead encoded with `null`.
|
|
542
|
+
*
|
|
543
|
+
* @remarks This object is motivated by undo/redo scenarios, and provides a convenient "inverse op" to apply to
|
|
544
|
+
* undo a property change.
|
|
545
|
+
*
|
|
546
|
+
* @example
|
|
547
|
+
*
|
|
548
|
+
* If a segment initially had properties `{ foo: "1", bar: 2 }` and it was annotated with
|
|
549
|
+
* `{ foo: 3, baz: 5 }`, the corresponding event would have a `propertyDeltas` of `{ foo: "1", baz: null }`.
|
|
550
|
+
*/
|
|
551
|
+
propertyDeltas: PropertySet;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* @alpha
|
|
556
|
+
*/
|
|
557
|
+
export declare interface ISerializableInterval extends IInterval {
|
|
558
|
+
/** Serializable bag of properties associated with the interval. */
|
|
559
|
+
properties: PropertySet;
|
|
560
|
+
/***/
|
|
561
|
+
propertyManager: PropertiesManager;
|
|
562
|
+
/***/
|
|
563
|
+
serialize(): ISerializedInterval;
|
|
564
|
+
/***/
|
|
565
|
+
addProperties(props: PropertySet, collaborating?: boolean, seq?: number): PropertySet | undefined;
|
|
566
|
+
/**
|
|
567
|
+
* Gets the id associated with this interval.
|
|
568
|
+
* When the interval is used as part of an interval collection, this id can be used to modify or remove the
|
|
569
|
+
* interval.
|
|
570
|
+
* @remarks This signature includes `undefined` strictly for backwards-compatibility reasons, as older versions
|
|
571
|
+
* of Fluid didn't always write interval ids.
|
|
572
|
+
*/
|
|
573
|
+
getIntervalId(): string | undefined;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Serialized object representation of an interval.
|
|
578
|
+
* This representation is used for ops that create or change intervals.
|
|
579
|
+
* @alpha
|
|
580
|
+
*/
|
|
581
|
+
export declare interface ISerializedInterval {
|
|
582
|
+
/**
|
|
583
|
+
* Sequence number at which `start` and `end` should be interpreted
|
|
584
|
+
*
|
|
585
|
+
* @remarks It's unclear that this is necessary to store here.
|
|
586
|
+
* This should just be the refSeq on the op that modified the interval, which should be available via other means.
|
|
587
|
+
* At the time of writing, it's not plumbed through to the reconnect/rebase code, however, which does need it.
|
|
588
|
+
*/
|
|
589
|
+
sequenceNumber: number;
|
|
590
|
+
/** Start position of the interval */
|
|
591
|
+
start: number | "start" | "end";
|
|
592
|
+
/** End position of the interval */
|
|
593
|
+
end: number | "start" | "end";
|
|
594
|
+
/** Interval type to create */
|
|
595
|
+
intervalType: IntervalType;
|
|
596
|
+
/**
|
|
597
|
+
* The stickiness of this interval
|
|
598
|
+
*/
|
|
599
|
+
stickiness?: IntervalStickiness;
|
|
600
|
+
startSide?: Side;
|
|
601
|
+
endSide?: Side;
|
|
602
|
+
/** Any properties the interval has */
|
|
603
|
+
properties?: PropertySet;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* @alpha
|
|
608
|
+
*/
|
|
609
|
+
export declare interface ISharedIntervalCollection<TInterval extends ISerializableInterval> {
|
|
610
|
+
getIntervalCollection(label: string): IIntervalCollection<TInterval>;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Events emitted in response to changes to the sequence data.
|
|
615
|
+
*
|
|
616
|
+
* @remarks
|
|
617
|
+
*
|
|
618
|
+
* The following is the list of events emitted.
|
|
619
|
+
*
|
|
620
|
+
* ### "sequenceDelta"
|
|
621
|
+
*
|
|
622
|
+
* The sequenceDelta event is emitted when segments are inserted, annotated, or removed.
|
|
623
|
+
*
|
|
624
|
+
* #### Listener signature
|
|
625
|
+
*
|
|
626
|
+
* ```typescript
|
|
627
|
+
* (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void
|
|
628
|
+
* ```
|
|
629
|
+
* - `event` - Various information on the segments that were modified.
|
|
630
|
+
*
|
|
631
|
+
* - `target` - The sequence itself.
|
|
632
|
+
*
|
|
633
|
+
* ### "maintenance"
|
|
634
|
+
*
|
|
635
|
+
* The maintenance event is emitted when segments are modified during merge-tree maintenance.
|
|
636
|
+
*
|
|
637
|
+
* #### Listener signature
|
|
638
|
+
*
|
|
639
|
+
* ```typescript
|
|
640
|
+
* (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void
|
|
641
|
+
* ```
|
|
642
|
+
* - `event` - Various information on the segments that were modified.
|
|
643
|
+
*
|
|
644
|
+
* - `target` - The sequence itself.
|
|
645
|
+
* @alpha
|
|
646
|
+
*/
|
|
647
|
+
export declare interface ISharedSegmentSequenceEvents extends ISharedObjectEvents {
|
|
648
|
+
(event: "createIntervalCollection", listener: (label: string, local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
649
|
+
(event: "sequenceDelta", listener: (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void): any;
|
|
650
|
+
(event: "maintenance", listener: (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void): any;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Fluid object interface describing access methods on a SharedString
|
|
655
|
+
* @alpha
|
|
656
|
+
*/
|
|
657
|
+
export declare interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {
|
|
658
|
+
/**
|
|
659
|
+
* Inserts the text at the position.
|
|
660
|
+
* @param pos - The position to insert the text at
|
|
661
|
+
* @param text - The text to insert
|
|
662
|
+
* @param props - The properties of the text
|
|
663
|
+
*/
|
|
664
|
+
insertText(pos: number, text: string, props?: PropertySet): void;
|
|
665
|
+
/**
|
|
666
|
+
* Inserts a marker at the position.
|
|
667
|
+
* @param pos - The position to insert the marker at
|
|
668
|
+
* @param refType - The reference type of the marker
|
|
669
|
+
* @param props - The properties of the marker
|
|
670
|
+
*/
|
|
671
|
+
insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): IMergeTreeInsertMsg | undefined;
|
|
672
|
+
/**
|
|
673
|
+
* {@inheritDoc SharedSegmentSequence.posFromRelativePos}
|
|
674
|
+
*/
|
|
675
|
+
posFromRelativePos(relativePos: IRelativePosition): number;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/* Excluded from this release type: IStartpointInRangeIndex */
|
|
679
|
+
|
|
680
|
+
/* Excluded from this release type: IValueOpEmitter */
|
|
681
|
+
|
|
682
|
+
/* Excluded from this release type: MergeTreeDeltaRevertible */
|
|
683
|
+
|
|
684
|
+
/* Excluded from this release type: revertSharedStringRevertibles */
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* The event object returned on sequenceDelta events.
|
|
688
|
+
*
|
|
689
|
+
* The properties of this object and its sub-objects represent the state of the sequence at the
|
|
690
|
+
* point in time at which the operation was applied.
|
|
691
|
+
* They will not take into consideration any future modifications performed to the underlying sequence and merge tree.
|
|
692
|
+
*
|
|
693
|
+
* For group ops, each op will get its own event, and the group op property will be set on the op args.
|
|
694
|
+
*
|
|
695
|
+
* Ops may get multiple events. For instance, an insert-replace will get a remove then an insert event.
|
|
696
|
+
* @alpha
|
|
697
|
+
*/
|
|
698
|
+
export declare class SequenceDeltaEvent extends SequenceEvent<MergeTreeDeltaOperationType> {
|
|
699
|
+
readonly opArgs: IMergeTreeDeltaOpArgs;
|
|
700
|
+
/**
|
|
701
|
+
* Whether the event was caused by a locally-made change.
|
|
702
|
+
*/
|
|
703
|
+
readonly isLocal: boolean;
|
|
704
|
+
constructor(opArgs: IMergeTreeDeltaOpArgs, deltaArgs: IMergeTreeDeltaCallbackArgs, mergeTreeClient: Client);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Base class for SequenceDeltaEvent and SequenceMaintenanceEvent.
|
|
709
|
+
*
|
|
710
|
+
* The properties of this object and its sub-objects represent the state of the sequence at the
|
|
711
|
+
* point in time at which the operation was applied.
|
|
712
|
+
* They will not take into any future modifications performed to the underlying sequence and merge tree.
|
|
713
|
+
* @alpha
|
|
714
|
+
*/
|
|
715
|
+
export declare abstract class SequenceEvent<TOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes> {
|
|
716
|
+
readonly deltaArgs: IMergeTreeDeltaCallbackArgs<TOperation>;
|
|
717
|
+
private readonly mergeTreeClient;
|
|
718
|
+
readonly deltaOperation: TOperation;
|
|
719
|
+
private readonly sortedRanges;
|
|
720
|
+
private readonly pFirst;
|
|
721
|
+
private readonly pLast;
|
|
722
|
+
constructor(deltaArgs: IMergeTreeDeltaCallbackArgs<TOperation>, mergeTreeClient: Client);
|
|
723
|
+
/**
|
|
724
|
+
* The in-order ranges affected by this delta.
|
|
725
|
+
* These may not be continuous.
|
|
726
|
+
*/
|
|
727
|
+
get ranges(): readonly Readonly<ISequenceDeltaRange<TOperation>>[];
|
|
728
|
+
/**
|
|
729
|
+
* The client id of the client that made the change which caused the delta event
|
|
730
|
+
*/
|
|
731
|
+
get clientId(): string | undefined;
|
|
732
|
+
/**
|
|
733
|
+
* The first of the modified ranges.
|
|
734
|
+
*/
|
|
735
|
+
get first(): Readonly<ISequenceDeltaRange<TOperation>>;
|
|
736
|
+
/**
|
|
737
|
+
* The last of the modified ranges.
|
|
738
|
+
*/
|
|
739
|
+
get last(): Readonly<ISequenceDeltaRange<TOperation>>;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Interval implementation whose ends are associated with positions in a mutatable sequence.
|
|
744
|
+
* As such, when content is inserted into the middle of the interval, the interval expands to
|
|
745
|
+
* include that content.
|
|
746
|
+
*
|
|
747
|
+
* @remarks The endpoints' positions should be treated exclusively to get
|
|
748
|
+
* reasonable behavior. E.g., an interval referring to "hello" in "hello world"
|
|
749
|
+
* should have a start position of 0 and an end position of 5.
|
|
750
|
+
*
|
|
751
|
+
* To see why, consider what happens if "llo wor" is removed from the string to make "held".
|
|
752
|
+
* The interval's startpoint remains on the "h" (it isn't altered), but the interval's endpoint
|
|
753
|
+
* slides forward to the next unremoved position, which is the "l" in "held".
|
|
754
|
+
* Users would generally expect the interval to now refer to "he" (as it is the subset of content
|
|
755
|
+
* remaining after the removal), hence the "l" should be excluded.
|
|
756
|
+
* If the interval endpoint was treated inclusively, the interval would now refer to "hel", which
|
|
757
|
+
* is undesirable.
|
|
758
|
+
*
|
|
759
|
+
* Since the endpoints of an interval are treated exclusively but cannot be greater
|
|
760
|
+
* than or equal to the length of the associated sequence, there exist special
|
|
761
|
+
* endpoint segments, "start" and "end", which represent the position immediately
|
|
762
|
+
* before or immediately after the string respectively.
|
|
763
|
+
*
|
|
764
|
+
* If a `SequenceInterval` is created on a sequence with the
|
|
765
|
+
* `mergeTreeReferencesCanSlideToEndpoint` feature flag set to true, the endpoints
|
|
766
|
+
* of the interval that are exclusive will have the ability to slide to these
|
|
767
|
+
* special endpoint segments.
|
|
768
|
+
* @alpha
|
|
769
|
+
*/
|
|
770
|
+
export declare class SequenceInterval implements ISerializableInterval {
|
|
771
|
+
private readonly client;
|
|
772
|
+
/**
|
|
773
|
+
* Start endpoint of this interval.
|
|
774
|
+
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
775
|
+
*/
|
|
776
|
+
start: LocalReferencePosition;
|
|
777
|
+
/**
|
|
778
|
+
* End endpoint of this interval.
|
|
779
|
+
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
780
|
+
*/
|
|
781
|
+
end: LocalReferencePosition;
|
|
782
|
+
intervalType: IntervalType;
|
|
783
|
+
readonly startSide: Side;
|
|
784
|
+
readonly endSide: Side;
|
|
785
|
+
/**
|
|
786
|
+
* {@inheritDoc ISerializableInterval.properties}
|
|
787
|
+
*/
|
|
788
|
+
properties: PropertySet;
|
|
789
|
+
/**
|
|
790
|
+
* {@inheritDoc ISerializableInterval.propertyManager}
|
|
791
|
+
*/
|
|
792
|
+
propertyManager: PropertiesManager;
|
|
793
|
+
/***/
|
|
794
|
+
get stickiness(): IntervalStickiness;
|
|
795
|
+
constructor(client: Client,
|
|
796
|
+
/**
|
|
797
|
+
* Start endpoint of this interval.
|
|
798
|
+
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
799
|
+
*/
|
|
800
|
+
start: LocalReferencePosition,
|
|
801
|
+
/**
|
|
802
|
+
* End endpoint of this interval.
|
|
803
|
+
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
804
|
+
*/
|
|
805
|
+
end: LocalReferencePosition, intervalType: IntervalType, props?: PropertySet, startSide?: Side, endSide?: Side);
|
|
806
|
+
private callbacks?;
|
|
807
|
+
/**
|
|
808
|
+
* Subscribes to position change events on this interval if there are no current listeners.
|
|
809
|
+
*/
|
|
810
|
+
addPositionChangeListeners(beforePositionChange: () => void, afterPositionChange: () => void): void;
|
|
811
|
+
/**
|
|
812
|
+
* Removes the currently subscribed position change listeners.
|
|
813
|
+
*/
|
|
814
|
+
removePositionChangeListeners(): void;
|
|
815
|
+
/**
|
|
816
|
+
* {@inheritDoc ISerializableInterval.serialize}
|
|
817
|
+
*/
|
|
818
|
+
serialize(): ISerializedInterval;
|
|
819
|
+
/**
|
|
820
|
+
* {@inheritDoc IInterval.clone}
|
|
821
|
+
*/
|
|
822
|
+
clone(): SequenceInterval;
|
|
823
|
+
/**
|
|
824
|
+
* {@inheritDoc IInterval.compare}
|
|
825
|
+
*/
|
|
826
|
+
compare(b: SequenceInterval): number;
|
|
827
|
+
/**
|
|
828
|
+
* {@inheritDoc IInterval.compareStart}
|
|
829
|
+
*/
|
|
830
|
+
compareStart(b: SequenceInterval): number;
|
|
831
|
+
/**
|
|
832
|
+
* {@inheritDoc IInterval.compareEnd}
|
|
833
|
+
*/
|
|
834
|
+
compareEnd(b: SequenceInterval): number;
|
|
835
|
+
/**
|
|
836
|
+
* {@inheritDoc IInterval.overlaps}
|
|
837
|
+
*/
|
|
838
|
+
overlaps(b: SequenceInterval): boolean;
|
|
839
|
+
/**
|
|
840
|
+
* {@inheritDoc ISerializableInterval.getIntervalId}
|
|
841
|
+
*/
|
|
842
|
+
getIntervalId(): string;
|
|
843
|
+
/**
|
|
844
|
+
* {@inheritDoc IInterval.union}
|
|
845
|
+
*/
|
|
846
|
+
union(b: SequenceInterval): SequenceInterval;
|
|
847
|
+
/**
|
|
848
|
+
* {@inheritDoc ISerializableInterval.addProperties}
|
|
849
|
+
*/
|
|
850
|
+
addProperties(newProps: PropertySet, collab?: boolean, seq?: number, op?: ICombiningOp): PropertySet | undefined;
|
|
851
|
+
/**
|
|
852
|
+
* @returns whether this interval overlaps two numerical positions.
|
|
853
|
+
*/
|
|
854
|
+
overlapsPos(bstart: number, bend: number): boolean;
|
|
855
|
+
/**
|
|
856
|
+
* {@inheritDoc IInterval.modify}
|
|
857
|
+
*/
|
|
858
|
+
modify(label: string, start: SequencePlace | undefined, end: SequencePlace | undefined, op?: ISequencedDocumentMessage, localSeq?: number, useNewSlidingBehavior?: boolean): SequenceInterval;
|
|
859
|
+
private initializeProperties;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/* Excluded from this release type: sequenceIntervalHelpers */
|
|
863
|
+
|
|
864
|
+
/* Excluded from this release type: SequenceIntervalIndexes */
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* The event object returned on maintenance events.
|
|
868
|
+
*
|
|
869
|
+
* The properties of this object and its sub-objects represent the state of the sequence at the
|
|
870
|
+
* point in time at which the operation was applied.
|
|
871
|
+
* They will not take into consideration any future modifications performed to the underlying sequence and merge tree.
|
|
872
|
+
* @alpha
|
|
873
|
+
*/
|
|
874
|
+
export declare class SequenceMaintenanceEvent extends SequenceEvent<MergeTreeMaintenanceType> {
|
|
875
|
+
readonly opArgs: IMergeTreeDeltaOpArgs | undefined;
|
|
876
|
+
constructor(opArgs: IMergeTreeDeltaOpArgs | undefined, deltaArgs: IMergeTreeMaintenanceCallbackArgs, mergeTreeClient: Client);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/* Excluded from this release type: SequenceOptions */
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* Defines a position and side relative to a character in a sequence.
|
|
883
|
+
*
|
|
884
|
+
* For this purpose, sequences look like:
|
|
885
|
+
*
|
|
886
|
+
* `{start} - {character 0} - {character 1} - ... - {character N} - {end}`
|
|
887
|
+
*
|
|
888
|
+
* Each `{value}` in the diagram is a character within a sequence.
|
|
889
|
+
* Each `-` in the above diagram is a position where text could be inserted.
|
|
890
|
+
* Each position between a `{value}` and a `-` is a `SequencePlace`.
|
|
891
|
+
*
|
|
892
|
+
* The special endpoints `{start}` and `{end}` refer to positions outside the
|
|
893
|
+
* contents of the string.
|
|
894
|
+
*
|
|
895
|
+
* This gives us 2N + 2 possible positions to refer to within a string, where N
|
|
896
|
+
* is the number of characters.
|
|
897
|
+
*
|
|
898
|
+
* If the position is specified with a bare number, the side defaults to
|
|
899
|
+
* `Side.Before`.
|
|
900
|
+
*
|
|
901
|
+
* If a SequencePlace is the endpoint of a range (e.g. start/end of an interval or search range),
|
|
902
|
+
* the Side value means it is exclusive if it is nearer to the other position and inclusive if it is farther.
|
|
903
|
+
* E.g. the start of a range with Side.After is exclusive of the character at the position.
|
|
904
|
+
* @alpha
|
|
905
|
+
*/
|
|
906
|
+
export declare type SequencePlace = number | "start" | "end" | InteriorSequencePlace;
|
|
907
|
+
|
|
908
|
+
/* Excluded from this release type: SerializedIntervalDelta */
|
|
909
|
+
|
|
910
|
+
/* Excluded from this release type: SharedIntervalCollection */
|
|
911
|
+
|
|
912
|
+
/* Excluded from this release type: SharedIntervalCollectionFactory */
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* @alpha
|
|
916
|
+
*/
|
|
917
|
+
export declare abstract class SharedSegmentSequence<T extends ISegment> extends SharedObject<ISharedSegmentSequenceEvents> implements ISharedIntervalCollection<SequenceInterval>, MergeTreeRevertibleDriver {
|
|
918
|
+
private readonly dataStoreRuntime;
|
|
919
|
+
id: string;
|
|
920
|
+
readonly segmentFromSpec: (spec: IJSONSegment) => ISegment;
|
|
921
|
+
get loaded(): Promise<void>;
|
|
922
|
+
/**
|
|
923
|
+
* This is a safeguard to avoid problematic reentrancy of local ops. This type of scenario occurs if the user of SharedString subscribes
|
|
924
|
+
* to the `sequenceDelta` event and uses the callback for a local op to submit further local ops.
|
|
925
|
+
* Historically (before 2.0.0-internal.6.1.0), doing so would result in eventual consistency issues or a corrupted document.
|
|
926
|
+
* These issues were fixed in #16815 which makes such reentrancy no different from applying the ops in order but not from within the change events,
|
|
927
|
+
* but there is still little test coverage for reentrant scenarios.
|
|
928
|
+
* Additionally, applications submitting ops from inside change events need to take extreme care that their data models also support reentrancy.
|
|
929
|
+
* Since this is likely not the case, by default SharedString throws when encountering reentrant ops.
|
|
930
|
+
*
|
|
931
|
+
* An application using SharedString which explicitly wants to opt in to allowing reentrancy anyway can set `sharedStringPreventReentrancy`
|
|
932
|
+
* on the data store options to `false`.
|
|
933
|
+
*/
|
|
934
|
+
protected guardReentrancy: <TRet>(callback: () => TRet) => TRet;
|
|
935
|
+
private static createOpsFromDelta;
|
|
936
|
+
protected client: Client;
|
|
937
|
+
/** `Deferred` that triggers once the object is loaded */
|
|
938
|
+
protected loadedDeferred: Deferred<void>;
|
|
939
|
+
private readonly loadedDeferredOutgoingOps;
|
|
940
|
+
private deferIncomingOps;
|
|
941
|
+
private readonly loadedDeferredIncomingOps;
|
|
942
|
+
private messagesSinceMSNChange;
|
|
943
|
+
private readonly intervalCollections;
|
|
944
|
+
constructor(dataStoreRuntime: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes, segmentFromSpec: (spec: IJSONSegment) => ISegment);
|
|
945
|
+
/**
|
|
946
|
+
* @param start - The inclusive start of the range to remove
|
|
947
|
+
* @param end - The exclusive end of the range to remove
|
|
948
|
+
*/
|
|
949
|
+
removeRange(start: number, end: number): IMergeTreeRemoveMsg;
|
|
950
|
+
/**
|
|
951
|
+
* @deprecated The ability to create group ops will be removed in an upcoming release, as group ops are redundant with the native batching capabilities of the runtime
|
|
952
|
+
*/
|
|
953
|
+
groupOperation(groupOp: IMergeTreeGroupMsg): void;
|
|
954
|
+
/**
|
|
955
|
+
* Finds the segment information (i.e. segment + offset) corresponding to a character position in the SharedString.
|
|
956
|
+
* If the position is past the end of the string, `segment` and `offset` on the returned object may be undefined.
|
|
957
|
+
* @param pos - Character position (index) into the current local view of the SharedString.
|
|
958
|
+
*/
|
|
959
|
+
getContainingSegment(pos: number): {
|
|
960
|
+
segment: T | undefined;
|
|
961
|
+
offset: number | undefined;
|
|
962
|
+
};
|
|
963
|
+
/**
|
|
964
|
+
* Returns the length of the current sequence for the client
|
|
965
|
+
*/
|
|
966
|
+
getLength(): number;
|
|
967
|
+
/**
|
|
968
|
+
* Returns the current position of a segment, and -1 if the segment
|
|
969
|
+
* does not exist in this sequence
|
|
970
|
+
* @param segment - The segment to get the position of
|
|
971
|
+
*/
|
|
972
|
+
getPosition(segment: ISegment): number;
|
|
973
|
+
/**
|
|
974
|
+
* Annotates the range with the provided properties
|
|
975
|
+
*
|
|
976
|
+
* @param start - The inclusive start position of the range to annotate
|
|
977
|
+
* @param end - The exclusive end position of the range to annotate
|
|
978
|
+
* @param props - The properties to annotate the range with
|
|
979
|
+
* @param combiningOp - Optional. Specifies how to combine values for the property, such as "incr" for increment.
|
|
980
|
+
*
|
|
981
|
+
*/
|
|
982
|
+
annotateRange(start: number, end: number, props: PropertySet, combiningOp?: ICombiningOp): void;
|
|
983
|
+
getPropertiesAtPosition(pos: number): PropertySet | undefined;
|
|
984
|
+
getRangeExtentsOfPosition(pos: number): {
|
|
985
|
+
posStart: number | undefined;
|
|
986
|
+
posAfterEnd: number | undefined;
|
|
987
|
+
};
|
|
988
|
+
/**
|
|
989
|
+
* Creates a `LocalReferencePosition` on this SharedString. If the refType does not include
|
|
990
|
+
* ReferenceType.Transient, the returned reference will be added to the localRefs on the provided segment.
|
|
991
|
+
* @param segment - Segment to add the local reference on
|
|
992
|
+
* @param offset - Offset on the segment at which to place the local reference
|
|
993
|
+
* @param refType - ReferenceType for the created local reference
|
|
994
|
+
* @param properties - PropertySet to place on the created local reference
|
|
995
|
+
*/
|
|
996
|
+
createLocalReferencePosition(segment: T, offset: number, refType: ReferenceType, properties: PropertySet | undefined, slidingPreference?: SlidingPreference, canSlideToEndpoint?: boolean): LocalReferencePosition;
|
|
997
|
+
/**
|
|
998
|
+
* Resolves a `ReferencePosition` into a character position using this client's perspective.
|
|
999
|
+
*/
|
|
1000
|
+
localReferencePositionToPosition(lref: ReferencePosition): number;
|
|
1001
|
+
/**
|
|
1002
|
+
* Removes a `LocalReferencePosition` from this SharedString.
|
|
1003
|
+
*/
|
|
1004
|
+
removeLocalReferencePosition(lref: LocalReferencePosition): LocalReferencePosition | undefined;
|
|
1005
|
+
/**
|
|
1006
|
+
* Resolves a remote client's position against the local sequence
|
|
1007
|
+
* and returns the remote client's position relative to the local
|
|
1008
|
+
* sequence. The client ref seq must be above the minimum sequence number
|
|
1009
|
+
* or the return value will be undefined.
|
|
1010
|
+
* Generally this method is used in conjunction with signals which provide
|
|
1011
|
+
* point in time values for the below parameters, and is useful for things
|
|
1012
|
+
* like displaying user position. It should not be used with persisted values
|
|
1013
|
+
* as persisted values will quickly become invalid as the remoteClientRefSeq
|
|
1014
|
+
* moves below the minimum sequence number
|
|
1015
|
+
* @param remoteClientPosition - The remote client's position to resolve
|
|
1016
|
+
* @param remoteClientRefSeq - The reference sequence number of the remote client
|
|
1017
|
+
* @param remoteClientId - The client id of the remote client
|
|
1018
|
+
*/
|
|
1019
|
+
resolveRemoteClientPosition(remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: string): number | undefined;
|
|
1020
|
+
/**
|
|
1021
|
+
* @deprecated This method will no longer be public in an upcoming release as it is not safe to use outside of this class
|
|
1022
|
+
*/
|
|
1023
|
+
submitSequenceMessage(message: IMergeTreeOp): void;
|
|
1024
|
+
/**
|
|
1025
|
+
* Given a position specified relative to a marker id, lookup the marker
|
|
1026
|
+
* and convert the position to a character position.
|
|
1027
|
+
* @param relativePos - Id of marker (may be indirect) and whether position is before or after marker.
|
|
1028
|
+
*/
|
|
1029
|
+
posFromRelativePos(relativePos: IRelativePosition): number;
|
|
1030
|
+
/**
|
|
1031
|
+
* Walk the underlying segments of the sequence.
|
|
1032
|
+
* The walked segments may extend beyond the range
|
|
1033
|
+
* if the segments cross the ranges start or end boundaries.
|
|
1034
|
+
* Set split range to true to ensure only segments within the
|
|
1035
|
+
* range are walked.
|
|
1036
|
+
*
|
|
1037
|
+
* @param handler - The function to handle each segment
|
|
1038
|
+
* @param start - Optional. The start of range walk.
|
|
1039
|
+
* @param end - Optional. The end of range walk
|
|
1040
|
+
* @param accum - Optional. An object that will be passed to the handler for accumulation
|
|
1041
|
+
* @param splitRange - Optional. Splits boundary segments on the range boundaries
|
|
1042
|
+
*/
|
|
1043
|
+
walkSegments<TClientData>(handler: ISegmentAction<TClientData>, start?: number, end?: number, accum?: TClientData, splitRange?: boolean): void;
|
|
1044
|
+
/**
|
|
1045
|
+
* @deprecated this functionality is no longer supported and will be removed
|
|
1046
|
+
*/
|
|
1047
|
+
getStackContext(startPos: number, rangeLabels: string[]): RangeStackMap;
|
|
1048
|
+
/**
|
|
1049
|
+
* @returns The most recent sequence number which has been acked by the server and processed by this
|
|
1050
|
+
* SharedSegmentSequence.
|
|
1051
|
+
*/
|
|
1052
|
+
getCurrentSeq(): number;
|
|
1053
|
+
/**
|
|
1054
|
+
* Inserts a segment directly before a `ReferencePosition`.
|
|
1055
|
+
* @param refPos - The reference position to insert the segment at
|
|
1056
|
+
* @param segment - The segment to insert
|
|
1057
|
+
*/
|
|
1058
|
+
insertAtReferencePosition(pos: ReferencePosition, segment: T): void;
|
|
1059
|
+
/**
|
|
1060
|
+
* Inserts a segment
|
|
1061
|
+
* @param start - The position to insert the segment at
|
|
1062
|
+
* @param spec - The segment to inserts spec
|
|
1063
|
+
*/
|
|
1064
|
+
insertFromSpec(pos: number, spec: IJSONSegment): void;
|
|
1065
|
+
/**
|
|
1066
|
+
* Retrieves the interval collection keyed on `label`. If no such interval collection exists,
|
|
1067
|
+
* creates one.
|
|
1068
|
+
*/
|
|
1069
|
+
getIntervalCollection(label: string): IIntervalCollection<SequenceInterval>;
|
|
1070
|
+
/**
|
|
1071
|
+
* @returns An iterable object that enumerates the IntervalCollection labels.
|
|
1072
|
+
*
|
|
1073
|
+
* @example
|
|
1074
|
+
*
|
|
1075
|
+
* ```typescript
|
|
1076
|
+
* const iter = this.getIntervalCollectionKeys();
|
|
1077
|
+
* for (key of iter)
|
|
1078
|
+
* const collection = this.getIntervalCollection(key);
|
|
1079
|
+
* ...
|
|
1080
|
+
* ```
|
|
1081
|
+
*/
|
|
1082
|
+
getIntervalCollectionLabels(): IterableIterator<string>;
|
|
1083
|
+
/**
|
|
1084
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
1085
|
+
*/
|
|
1086
|
+
protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
|
|
1087
|
+
/**
|
|
1088
|
+
* Runs serializer over the GC data for this SharedMatrix.
|
|
1089
|
+
* All the IFluidHandle's represent routes to other objects.
|
|
1090
|
+
*/
|
|
1091
|
+
protected processGCDataCore(serializer: SummarySerializer): void;
|
|
1092
|
+
/**
|
|
1093
|
+
* Replace the range specified from start to end with the provided segment
|
|
1094
|
+
* This is done by inserting the segment at the end of the range, followed
|
|
1095
|
+
* by removing the contents of the range
|
|
1096
|
+
* For a zero or reverse range (start \>= end), insert at end do not remove anything
|
|
1097
|
+
* @param start - The start of the range to replace
|
|
1098
|
+
* @param end - The end of the range to replace
|
|
1099
|
+
* @param segment - The segment that will replace the range
|
|
1100
|
+
*/
|
|
1101
|
+
protected replaceRange(start: number, end: number, segment: ISegment): void;
|
|
1102
|
+
/**
|
|
1103
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onConnect}
|
|
1104
|
+
*/
|
|
1105
|
+
protected onConnect(): void;
|
|
1106
|
+
/**
|
|
1107
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
|
|
1108
|
+
*/
|
|
1109
|
+
protected onDisconnect(): void;
|
|
1110
|
+
/**
|
|
1111
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
|
|
1112
|
+
*/
|
|
1113
|
+
protected reSubmitCore(content: any, localOpMetadata: unknown): void;
|
|
1114
|
+
/**
|
|
1115
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
1116
|
+
*/
|
|
1117
|
+
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
1118
|
+
/**
|
|
1119
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
|
|
1120
|
+
*/
|
|
1121
|
+
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
1122
|
+
/**
|
|
1123
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.didAttach}
|
|
1124
|
+
*/
|
|
1125
|
+
protected didAttach(): void;
|
|
1126
|
+
/**
|
|
1127
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.initializeLocalCore}
|
|
1128
|
+
*/
|
|
1129
|
+
protected initializeLocalCore(): void;
|
|
1130
|
+
/**
|
|
1131
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
|
1132
|
+
*/
|
|
1133
|
+
protected applyStashedOp(content: any): unknown;
|
|
1134
|
+
private summarizeMergeTree;
|
|
1135
|
+
private processMergeTreeMsg;
|
|
1136
|
+
private processMinSequenceNumberChanged;
|
|
1137
|
+
private loadFinished;
|
|
1138
|
+
private initializeIntervalCollections;
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
/* Excluded from this release type: SharedSequence */
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* The Shared String is a specialized data structure for handling collaborative
|
|
1145
|
+
* text. It is based on a more general Sequence data structure but has
|
|
1146
|
+
* additional features that make working with text easier.
|
|
1147
|
+
*
|
|
1148
|
+
* In addition to text, a Shared String can also contain markers. Markers can be
|
|
1149
|
+
* used to store metadata at positions within the text, like the details of an
|
|
1150
|
+
* image or Fluid object that should be rendered with the text.
|
|
1151
|
+
* @alpha
|
|
1152
|
+
*/
|
|
1153
|
+
export declare class SharedString extends SharedSegmentSequence<SharedStringSegment> implements ISharedString {
|
|
1154
|
+
id: string;
|
|
1155
|
+
/**
|
|
1156
|
+
* Create a new shared string.
|
|
1157
|
+
* @param runtime - data store runtime the new shared string belongs to
|
|
1158
|
+
* @param id - optional name of the shared string
|
|
1159
|
+
* @returns newly create shared string (but not attached yet)
|
|
1160
|
+
*/
|
|
1161
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): SharedString;
|
|
1162
|
+
/**
|
|
1163
|
+
* Get a factory for SharedString to register with the data store.
|
|
1164
|
+
* @returns a factory that creates and load SharedString
|
|
1165
|
+
*/
|
|
1166
|
+
static getFactory(): SharedStringFactory;
|
|
1167
|
+
get ISharedString(): ISharedString;
|
|
1168
|
+
private readonly mergeTreeTextHelper;
|
|
1169
|
+
constructor(document: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes);
|
|
1170
|
+
/**
|
|
1171
|
+
* Inserts a marker at a relative position.
|
|
1172
|
+
* @param relativePos1 - The relative position to insert the marker at
|
|
1173
|
+
* @param refType - The reference type of the marker
|
|
1174
|
+
* @param props - The properties of the marker
|
|
1175
|
+
*/
|
|
1176
|
+
insertMarkerRelative(relativePos1: IRelativePosition, refType: ReferenceType, props?: PropertySet): void;
|
|
1177
|
+
/**
|
|
1178
|
+
* {@inheritDoc ISharedString.insertMarker}
|
|
1179
|
+
*/
|
|
1180
|
+
insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): IMergeTreeInsertMsg | undefined;
|
|
1181
|
+
/**
|
|
1182
|
+
* Inserts the text at the position.
|
|
1183
|
+
* @param relativePos1 - The relative position to insert the text at
|
|
1184
|
+
* @param text - The text to insert
|
|
1185
|
+
* @param props - The properties of text
|
|
1186
|
+
*/
|
|
1187
|
+
insertTextRelative(relativePos1: IRelativePosition, text: string, props?: PropertySet): void;
|
|
1188
|
+
/**
|
|
1189
|
+
* {@inheritDoc ISharedString.insertText}
|
|
1190
|
+
*/
|
|
1191
|
+
insertText(pos: number, text: string, props?: PropertySet): void;
|
|
1192
|
+
/**
|
|
1193
|
+
* Replaces a range with the provided text.
|
|
1194
|
+
* @param start - The inclusive start of the range to replace
|
|
1195
|
+
* @param end - The exclusive end of the range to replace
|
|
1196
|
+
* @param text - The text to replace the range with
|
|
1197
|
+
* @param props - Optional. The properties of the replacement text
|
|
1198
|
+
*/
|
|
1199
|
+
replaceText(start: number, end: number, text: string, props?: PropertySet): void;
|
|
1200
|
+
/**
|
|
1201
|
+
* Removes the text in the given range.
|
|
1202
|
+
* @param start - The inclusive start of the range to remove
|
|
1203
|
+
* @param end - The exclusive end of the range to replace
|
|
1204
|
+
* @returns the message sent.
|
|
1205
|
+
*/
|
|
1206
|
+
removeText(start: number, end: number): IMergeTreeRemoveMsg;
|
|
1207
|
+
/**
|
|
1208
|
+
* Annotates the marker with the provided properties and calls the callback on consensus.
|
|
1209
|
+
* @param marker - The marker to annotate
|
|
1210
|
+
* @param props - The properties to annotate the marker with
|
|
1211
|
+
* @param consensusCallback - The callback called when consensus is reached
|
|
1212
|
+
*
|
|
1213
|
+
* @deprecated We no longer intend to support this functionality and it will
|
|
1214
|
+
* be removed in a future release. There is no replacement for this
|
|
1215
|
+
* functionality.
|
|
1216
|
+
*/
|
|
1217
|
+
annotateMarkerNotifyConsensus(marker: Marker, props: PropertySet, callback: (m: Marker) => void): void;
|
|
1218
|
+
/**
|
|
1219
|
+
* Annotates the marker with the provided properties.
|
|
1220
|
+
* @param marker - The marker to annotate
|
|
1221
|
+
* @param props - The properties to annotate the marker with
|
|
1222
|
+
* @param combiningOp - Optional. Specifies how to combine values for the property, such as "incr" for increment.
|
|
1223
|
+
*/
|
|
1224
|
+
annotateMarker(marker: Marker, props: PropertySet, combiningOp?: ICombiningOp): void;
|
|
1225
|
+
/**
|
|
1226
|
+
* Finds the nearest reference with ReferenceType.Tile to `startPos` in the direction dictated by `tilePrecedesPos`.
|
|
1227
|
+
* Note that Markers receive `ReferenceType.Tile` by default.
|
|
1228
|
+
* @deprecated Use `searchForMarker` instead.
|
|
1229
|
+
* @param startPos - Position at which to start the search
|
|
1230
|
+
* @param clientId - clientId dictating the perspective to search from
|
|
1231
|
+
* @param tileLabel - Label of the tile to search for
|
|
1232
|
+
* @param preceding - Whether the desired tile comes before (true) or after (false) `startPos`
|
|
1233
|
+
*/
|
|
1234
|
+
findTile(startPos: number | undefined, tileLabel: string, preceding?: boolean): {
|
|
1235
|
+
tile: ReferencePosition;
|
|
1236
|
+
pos: number;
|
|
1237
|
+
} | undefined;
|
|
1238
|
+
/**
|
|
1239
|
+
* Searches a string for the nearest marker in either direction to a given start position.
|
|
1240
|
+
* The search will include the start position, so markers at the start position are valid
|
|
1241
|
+
* results of the search.
|
|
1242
|
+
* @param startPos - Position at which to start the search
|
|
1243
|
+
* @param markerLabel - Label of the marker to search for
|
|
1244
|
+
* @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`
|
|
1245
|
+
*/
|
|
1246
|
+
searchForMarker(startPos: number, markerLabel: string, forwards?: boolean): Marker | undefined;
|
|
1247
|
+
/**
|
|
1248
|
+
* Retrieve text from the SharedString in string format.
|
|
1249
|
+
* @param start - The starting index of the text to retrieve, or 0 if omitted.
|
|
1250
|
+
* @param end - The ending index of the text to retrieve, or the end of the string if omitted
|
|
1251
|
+
* @returns The requested text content as a string.
|
|
1252
|
+
*/
|
|
1253
|
+
getText(start?: number, end?: number): string;
|
|
1254
|
+
/**
|
|
1255
|
+
* Adds spaces for markers and handles, so that position calculations account for them.
|
|
1256
|
+
*/
|
|
1257
|
+
getTextWithPlaceholders(start?: number, end?: number): string;
|
|
1258
|
+
getTextRangeWithMarkers(start: number, end: number): string;
|
|
1259
|
+
/**
|
|
1260
|
+
* Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided
|
|
1261
|
+
* id in this `SharedString`.
|
|
1262
|
+
*/
|
|
1263
|
+
getMarkerFromId(id: string): ISegment | undefined;
|
|
1264
|
+
/**
|
|
1265
|
+
* Revert an op
|
|
1266
|
+
*/
|
|
1267
|
+
protected rollback(content: any, localOpMetadata: unknown): void;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
/**
|
|
1271
|
+
* @alpha
|
|
1272
|
+
*/
|
|
1273
|
+
export declare class SharedStringFactory implements IChannelFactory {
|
|
1274
|
+
static Type: string;
|
|
1275
|
+
static readonly Attributes: IChannelAttributes;
|
|
1276
|
+
static segmentFromSpec(spec: any): SharedStringSegment;
|
|
1277
|
+
get type(): string;
|
|
1278
|
+
get attributes(): IChannelAttributes;
|
|
1279
|
+
/**
|
|
1280
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
1281
|
+
*/
|
|
1282
|
+
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<SharedString>;
|
|
1283
|
+
create(document: IFluidDataStoreRuntime, id: string): SharedString;
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
/* Excluded from this release type: SharedStringRevertible */
|
|
1287
|
+
|
|
1288
|
+
/**
|
|
1289
|
+
* @alpha
|
|
1290
|
+
*/
|
|
1291
|
+
export declare type SharedStringSegment = TextSegment | Marker;
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* Defines a side relative to a character in a sequence.
|
|
1295
|
+
*
|
|
1296
|
+
* @remarks See {@link SequencePlace} for additional context on usage.
|
|
1297
|
+
* @alpha
|
|
1298
|
+
*/
|
|
1299
|
+
export declare enum Side {
|
|
1300
|
+
Before = 0,
|
|
1301
|
+
After = 1
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
/* Excluded from this release type: SubSequence */
|
|
1305
|
+
|
|
1306
|
+
export { }
|