@fluidframework/sequence 2.0.0-internal.7.2.1 → 2.0.0-internal.7.3.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 +4 -0
- package/api-extractor.json +4 -1
- package/dist/intervalCollection.d.ts +2 -2
- package/dist/intervals/intervalUtils.d.ts.map +1 -1
- package/dist/intervals/intervalUtils.js +1 -0
- package/dist/intervals/intervalUtils.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.map +1 -1
- package/dist/revertibles.js +34 -12
- package/dist/revertibles.js.map +1 -1
- package/dist/sequence-alpha.d.ts +1587 -0
- package/dist/sequence-beta.d.ts +1507 -0
- package/dist/sequence-public.d.ts +1507 -0
- package/dist/sequence-untrimmed.d.ts +1759 -0
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +3 -4
- package/dist/sequence.js.map +1 -1
- package/dist/sequenceDeltaEvent.d.ts.map +1 -1
- package/dist/sequenceDeltaEvent.js +1 -0
- package/dist/sequenceDeltaEvent.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/intervalCollection.d.ts +2 -2
- package/lib/intervals/intervalUtils.d.ts.map +1 -1
- package/lib/intervals/intervalUtils.js +1 -0
- package/lib/intervals/intervalUtils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/revertibles.d.ts.map +1 -1
- package/lib/revertibles.js +34 -12
- package/lib/revertibles.js.map +1 -1
- package/lib/sequence-alpha.d.ts +1587 -0
- package/lib/sequence-beta.d.ts +1507 -0
- package/lib/sequence-public.d.ts +1507 -0
- package/lib/sequence-untrimmed.d.ts +1759 -0
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +2 -7
- package/lib/sequence.js.map +1 -1
- package/lib/sequenceDeltaEvent.d.ts.map +1 -1
- package/lib/sequenceDeltaEvent.js +1 -0
- package/lib/sequenceDeltaEvent.js.map +1 -1
- package/package.json +36 -28
- package/src/intervals/intervalUtils.ts +1 -0
- package/src/packageVersion.ts +1 -1
- package/src/revertibles.ts +86 -9
- package/src/sequence.ts +3 -4
- package/src/sequenceDeltaEvent.ts +2 -0
- package/tsconfig.esnext.json +1 -2
- package/tsconfig.json +5 -3
|
@@ -0,0 +1,1587 @@
|
|
|
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
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Create revertibles for adding an interval
|
|
61
|
+
* @alpha
|
|
62
|
+
*/
|
|
63
|
+
export declare function appendAddIntervalToRevertibles(interval: SequenceInterval, revertibles: SharedStringRevertible[]): SharedStringRevertible[];
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Create revertibles for moving endpoints of an interval
|
|
67
|
+
* @alpha
|
|
68
|
+
*/
|
|
69
|
+
export declare function appendChangeIntervalToRevertibles(string: SharedString, newInterval: SequenceInterval, previousInterval: SequenceInterval, revertibles: SharedStringRevertible[]): SharedStringRevertible[];
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Create revertibles for deleting an interval
|
|
73
|
+
* @alpha
|
|
74
|
+
*/
|
|
75
|
+
export declare function appendDeleteIntervalToRevertibles(string: SharedString, interval: SequenceInterval, revertibles: SharedStringRevertible[]): SharedStringRevertible[];
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Create revertibles for changing properties of an interval
|
|
79
|
+
* @alpha
|
|
80
|
+
*/
|
|
81
|
+
export declare function appendIntervalPropertyChangedToRevertibles(interval: SequenceInterval, deltas: PropertySet, revertibles: SharedStringRevertible[]): SharedStringRevertible[];
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Create revertibles for SharedStringDeltas, handling indirectly modified intervals
|
|
85
|
+
* (e.g. reverting remove of a range that contains an interval will move the interval back)
|
|
86
|
+
*
|
|
87
|
+
* @alpha
|
|
88
|
+
*/
|
|
89
|
+
export declare function appendSharedStringDeltaToRevertibles(string: SharedString, delta: SequenceDeltaEvent, revertibles: SharedStringRevertible[]): void;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
export declare function createEndpointIndex(sharedString: SharedString): IEndpointIndex<SequenceInterval>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
export declare function createEndpointInRangeIndex(sharedString: SharedString): IEndpointInRangeIndex<SequenceInterval>;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
export declare function createIdIntervalIndex<TInterval extends ISerializableInterval>(): IIdIntervalIndex<TInterval>;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
109
|
+
export declare function createOverlappingIntervalsIndex(sharedString: SharedString): IOverlappingIntervalsIndex<SequenceInterval>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
export declare function createOverlappingSequenceIntervalsIndex(sharedString: SharedString): SequenceIntervalIndexes.Overlapping;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
export declare function createStartpointInRangeIndex(sharedString: SharedString): IStartpointInRangeIndex<SequenceInterval>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
export declare type DeserializeCallback = (properties: PropertySet) => void;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Clean up resources held by revertibles that are no longer needed.
|
|
128
|
+
* @alpha
|
|
129
|
+
*/
|
|
130
|
+
export declare function discardSharedStringRevertibles(sharedString: SharedString, revertibles: SharedStringRevertible[]): void;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Splits the text into regions ending with markers with the given `label`.
|
|
134
|
+
* @param sharedString - String to retrieve text and markers from
|
|
135
|
+
* @param label - label to split on
|
|
136
|
+
* @returns Two parallel lists of text and markers, split by markers with the provided `label`.
|
|
137
|
+
* For example:
|
|
138
|
+
* ```typescript
|
|
139
|
+
* // Say sharedstring has contents "hello<paragraph marker 1>world<paragraph marker 2>missing".
|
|
140
|
+
* const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, "paragraph");
|
|
141
|
+
* // parallelText === ["hello", "world"]
|
|
142
|
+
* // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]
|
|
143
|
+
* // Note parallelText does not include "missing".
|
|
144
|
+
* ```
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
export declare function getTextAndMarkers(sharedString: SharedString, label: string, start?: number, end?: number): {
|
|
148
|
+
parallelText: string[];
|
|
149
|
+
parallelMarkers: Marker[];
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @public
|
|
154
|
+
*/
|
|
155
|
+
export declare interface IEndpointIndex<TInterval extends ISerializableInterval> extends IntervalIndex<TInterval> {
|
|
156
|
+
/**
|
|
157
|
+
* @returns the previous interval based on the given position number.
|
|
158
|
+
* If no such interval exists in this index, returns `undefined`
|
|
159
|
+
*/
|
|
160
|
+
previousInterval(pos: number): TInterval | undefined;
|
|
161
|
+
/**
|
|
162
|
+
* @returns the next interval based on the given position number.
|
|
163
|
+
* If no such interval exists in this index, returns `undefined`
|
|
164
|
+
*/
|
|
165
|
+
nextInterval(pos: number): TInterval | undefined;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Collection of intervals.
|
|
170
|
+
*
|
|
171
|
+
* Provide additional APIs to support efficiently querying a collection of intervals whose endpoints fall within a specified range.
|
|
172
|
+
* @public
|
|
173
|
+
*/
|
|
174
|
+
export declare interface IEndpointInRangeIndex<TInterval extends ISerializableInterval> extends IntervalIndex<TInterval> {
|
|
175
|
+
/**
|
|
176
|
+
* @returns an array of all intervals contained in this collection whose endpoints locate in the range [start, end] (includes both ends)
|
|
177
|
+
*/
|
|
178
|
+
findIntervalsWithEndpointInRange(start: number, end: number): TInterval[];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @public
|
|
183
|
+
*/
|
|
184
|
+
export declare interface IIdIntervalIndex<TInterval extends ISerializableInterval> extends IntervalIndex<TInterval>, Iterable<TInterval> {
|
|
185
|
+
getIntervalById(id: string): TInterval | undefined;
|
|
186
|
+
[Symbol.iterator](): Iterator<TInterval>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Basic interval abstraction
|
|
191
|
+
* @public
|
|
192
|
+
*/
|
|
193
|
+
export declare interface IInterval {
|
|
194
|
+
/**
|
|
195
|
+
* @returns a new interval object with identical semantics.
|
|
196
|
+
*/
|
|
197
|
+
clone(): IInterval;
|
|
198
|
+
/**
|
|
199
|
+
* Compares this interval to `b` with standard comparator semantics:
|
|
200
|
+
* - returns -1 if this is less than `b`
|
|
201
|
+
* - returns 1 if this is greater than `b`
|
|
202
|
+
* - returns 0 if this is equivalent to `b`
|
|
203
|
+
* @param b - Interval to compare against
|
|
204
|
+
*/
|
|
205
|
+
compare(b: IInterval): number;
|
|
206
|
+
/**
|
|
207
|
+
* Compares the start endpoint of this interval to `b`'s start endpoint.
|
|
208
|
+
* Standard comparator semantics apply.
|
|
209
|
+
* @param b - Interval to compare against
|
|
210
|
+
*/
|
|
211
|
+
compareStart(b: IInterval): number;
|
|
212
|
+
/**
|
|
213
|
+
* Compares the end endpoint of this interval to `b`'s end endpoint.
|
|
214
|
+
* Standard comparator semantics apply.
|
|
215
|
+
* @param b - Interval to compare against
|
|
216
|
+
*/
|
|
217
|
+
compareEnd(b: IInterval): number;
|
|
218
|
+
/* Excluded from this release type: modify */
|
|
219
|
+
/**
|
|
220
|
+
* @returns whether this interval overlaps with `b`.
|
|
221
|
+
* Intervals are considered to overlap if their intersection is non-empty.
|
|
222
|
+
*/
|
|
223
|
+
overlaps(b: IInterval): boolean;
|
|
224
|
+
/* Excluded from this release type: union */
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Collection of intervals that supports addition, modification, removal, and efficient spatial querying.
|
|
229
|
+
* Changes to this collection will be incur updates on collaborating clients (i.e. they are not local-only).
|
|
230
|
+
* @public
|
|
231
|
+
*/
|
|
232
|
+
export declare interface IIntervalCollection<TInterval extends ISerializableInterval> extends TypedEventEmitter<IIntervalCollectionEvent<TInterval>> {
|
|
233
|
+
readonly attached: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Attaches an index to this collection.
|
|
236
|
+
* All intervals which are part of this collection will be added to the index, and the index will automatically
|
|
237
|
+
* be updated when this collection updates due to local or remote changes.
|
|
238
|
+
*
|
|
239
|
+
* @remarks After attaching an index to an interval collection, applications should typically store this
|
|
240
|
+
* index somewhere in their in-memory data model for future reference and querying.
|
|
241
|
+
*/
|
|
242
|
+
attachIndex(index: IntervalIndex<TInterval>): void;
|
|
243
|
+
/**
|
|
244
|
+
* Detaches an index from this collection.
|
|
245
|
+
* All intervals which are part of this collection will be removed from the index, and updates to this collection
|
|
246
|
+
* due to local or remote changes will no longer incur updates to the index.
|
|
247
|
+
*
|
|
248
|
+
* @returns `false` if the target index cannot be found in the indexes, otherwise remove all intervals in the index and return `true`.
|
|
249
|
+
*/
|
|
250
|
+
detachIndex(index: IntervalIndex<TInterval>): boolean;
|
|
251
|
+
/**
|
|
252
|
+
* @returns the interval in this collection that has the provided `id`.
|
|
253
|
+
* If no interval in the collection has this `id`, returns `undefined`.
|
|
254
|
+
*/
|
|
255
|
+
getIntervalById(id: string): TInterval | undefined;
|
|
256
|
+
/**
|
|
257
|
+
* Creates a new interval and add it to the collection.
|
|
258
|
+
* @deprecated call IntervalCollection.add without specifying an intervalType
|
|
259
|
+
* @param start - interval start position (inclusive)
|
|
260
|
+
* @param end - interval end position (exclusive)
|
|
261
|
+
* @param intervalType - type of the interval. All intervals are SlideOnRemove. Intervals may not be Transient.
|
|
262
|
+
* @param props - properties of the interval
|
|
263
|
+
* @returns The created interval
|
|
264
|
+
* @remarks See documentation on {@link SequenceInterval} for comments on
|
|
265
|
+
* interval endpoint semantics: there are subtleties with how the current
|
|
266
|
+
* half-open behavior is represented.
|
|
267
|
+
*
|
|
268
|
+
* Note that intervals may behave unexpectedly if the entire contents
|
|
269
|
+
* of the string are deleted. In this case, it is possible for one endpoint
|
|
270
|
+
* of the interval to become detached, while the other remains on the string.
|
|
271
|
+
*
|
|
272
|
+
* By adjusting the `side` and `pos` values of the `start` and `end` parameters,
|
|
273
|
+
* it is possible to control whether the interval expands to include content
|
|
274
|
+
* inserted at its start or end.
|
|
275
|
+
*
|
|
276
|
+
* See {@link SequencePlace} for more details on the model.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
*
|
|
280
|
+
* Given the string "ABCD":
|
|
281
|
+
*
|
|
282
|
+
*```typescript
|
|
283
|
+
* // Refers to "BC". If any content is inserted before B or after C, this
|
|
284
|
+
* // interval will include that content
|
|
285
|
+
* //
|
|
286
|
+
* // Picture:
|
|
287
|
+
* // \{start\} - A[- B - C -]D - \{end\}
|
|
288
|
+
* // \{start\} - A - B - C - D - \{end\}
|
|
289
|
+
* collection.add(\{ pos: 0, side: Side.After \}, \{ pos: 3, side: Side.Before \}, IntervalType.SlideOnRemove);
|
|
290
|
+
* // Equivalent to specifying the same positions and Side.Before.
|
|
291
|
+
* // Refers to "ABC". Content inserted after C will be included in the
|
|
292
|
+
* // interval, but content inserted before A will not.
|
|
293
|
+
* // \{start\} -[A - B - C -]D - \{end\}
|
|
294
|
+
* // \{start\} - A - B - C - D - \{end\}
|
|
295
|
+
* collection.add(0, 3, IntervalType.SlideOnRemove);
|
|
296
|
+
*```
|
|
297
|
+
*
|
|
298
|
+
* In the case of the first example, if text is deleted,
|
|
299
|
+
*
|
|
300
|
+
* ```typescript
|
|
301
|
+
* // Delete the character "B"
|
|
302
|
+
* string.removeRange(1, 2);
|
|
303
|
+
* ```
|
|
304
|
+
*
|
|
305
|
+
* The start point of the interval will slide to the position immediately
|
|
306
|
+
* before "C", and the same will be true.
|
|
307
|
+
*
|
|
308
|
+
* ```
|
|
309
|
+
* \{start\} - A[- C -]D - \{end\}
|
|
310
|
+
* ```
|
|
311
|
+
*
|
|
312
|
+
* In this case, text inserted immediately before "C" would be included in
|
|
313
|
+
* the interval.
|
|
314
|
+
*
|
|
315
|
+
* ```typescript
|
|
316
|
+
* string.insertText(1, "EFG");
|
|
317
|
+
* ```
|
|
318
|
+
*
|
|
319
|
+
* With the string now being,
|
|
320
|
+
*
|
|
321
|
+
* ```
|
|
322
|
+
* \{start\} - A[- E - F - G - C -]D - \{end\}
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* @privateRemarks TODO: ADO:5205 the above comment regarding behavior in
|
|
326
|
+
* the case that the entire interval has been deleted should be resolved at
|
|
327
|
+
* the same time as this ticket
|
|
328
|
+
*/
|
|
329
|
+
add(start: SequencePlace, end: SequencePlace, intervalType: IntervalType, props?: PropertySet): TInterval;
|
|
330
|
+
/**
|
|
331
|
+
* Creates a new interval and add it to the collection.
|
|
332
|
+
* @param start - interval start position (inclusive)
|
|
333
|
+
* @param end - interval end position (exclusive)
|
|
334
|
+
* @param props - properties of the interval
|
|
335
|
+
* @returns - the created interval
|
|
336
|
+
* @remarks - See documentation on {@link SequenceInterval} for comments on interval endpoint semantics: there are subtleties
|
|
337
|
+
* with how the current half-open behavior is represented.
|
|
338
|
+
*/
|
|
339
|
+
add({ start, end, props, }: {
|
|
340
|
+
start: SequencePlace;
|
|
341
|
+
end: SequencePlace;
|
|
342
|
+
props?: PropertySet;
|
|
343
|
+
}): TInterval;
|
|
344
|
+
/**
|
|
345
|
+
* Removes an interval from the collection.
|
|
346
|
+
* @param id - Id of the interval to remove
|
|
347
|
+
* @returns the removed interval
|
|
348
|
+
*/
|
|
349
|
+
removeIntervalById(id: string): TInterval | undefined;
|
|
350
|
+
/**
|
|
351
|
+
* Changes the properties on an existing interval.
|
|
352
|
+
* @param id - Id of the interval whose properties should be changed
|
|
353
|
+
* @param props - Property set to apply to the interval. Shallow merging is used between any existing properties
|
|
354
|
+
* and `prop`, i.e. the interval will end up with a property object equivalent to `{ ...oldProps, ...props }`.
|
|
355
|
+
*/
|
|
356
|
+
changeProperties(id: string, props: PropertySet): any;
|
|
357
|
+
/**
|
|
358
|
+
* Changes the endpoints of an existing interval.
|
|
359
|
+
* @param id - Id of the interval to change
|
|
360
|
+
* @param start - New start value. To leave the endpoint unchanged, pass the current value.
|
|
361
|
+
* @param end - New end value. To leave the endpoint unchanged, pass the current value.
|
|
362
|
+
* @returns the interval that was changed, if it existed in the collection.
|
|
363
|
+
*/
|
|
364
|
+
change(id: string, start: SequencePlace, end: SequencePlace): TInterval | undefined;
|
|
365
|
+
attachDeserializer(onDeserialize: DeserializeCallback): void;
|
|
366
|
+
/**
|
|
367
|
+
* @returns an iterator over all intervals in this collection.
|
|
368
|
+
*/
|
|
369
|
+
[Symbol.iterator](): Iterator<TInterval>;
|
|
370
|
+
/**
|
|
371
|
+
* @returns a forward iterator over all intervals in this collection with start point equal to `startPosition`.
|
|
372
|
+
*/
|
|
373
|
+
CreateForwardIteratorWithStartPosition(startPosition: number): Iterator<TInterval>;
|
|
374
|
+
/**
|
|
375
|
+
* @returns a backward iterator over all intervals in this collection with start point equal to `startPosition`.
|
|
376
|
+
*/
|
|
377
|
+
CreateBackwardIteratorWithStartPosition(startPosition: number): Iterator<TInterval>;
|
|
378
|
+
/**
|
|
379
|
+
* @returns a forward iterator over all intervals in this collection with end point equal to `endPosition`.
|
|
380
|
+
*/
|
|
381
|
+
CreateForwardIteratorWithEndPosition(endPosition: number): Iterator<TInterval>;
|
|
382
|
+
/**
|
|
383
|
+
* @returns a backward iterator over all intervals in this collection with end point equal to `endPosition`.
|
|
384
|
+
*/
|
|
385
|
+
CreateBackwardIteratorWithEndPosition(endPosition: number): Iterator<TInterval>;
|
|
386
|
+
/**
|
|
387
|
+
* Gathers iteration results that optionally match a start/end criteria into the provided array.
|
|
388
|
+
* @param results - Array to gather the results into. In lieu of a return value, this array will be populated with
|
|
389
|
+
* intervals matching the query upon edit.
|
|
390
|
+
* @param iteratesForward - whether or not iteration should be in the forward direction
|
|
391
|
+
* @param start - If provided, only match intervals whose start point is equal to `start`.
|
|
392
|
+
* @param end - If provided, only match intervals whose end point is equal to `end`.
|
|
393
|
+
*/
|
|
394
|
+
gatherIterationResults(results: TInterval[], iteratesForward: boolean, start?: number, end?: number): void;
|
|
395
|
+
/**
|
|
396
|
+
* @returns an array of all intervals in this collection that overlap with the interval
|
|
397
|
+
* `[startPosition, endPosition]`.
|
|
398
|
+
*/
|
|
399
|
+
findOverlappingIntervals(startPosition: number, endPosition: number): TInterval[];
|
|
400
|
+
/**
|
|
401
|
+
* Applies a function to each interval in this collection.
|
|
402
|
+
*/
|
|
403
|
+
map(fn: (interval: TInterval) => void): void;
|
|
404
|
+
previousInterval(pos: number): TInterval | undefined;
|
|
405
|
+
nextInterval(pos: number): TInterval | undefined;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Change events emitted by `IntervalCollection`s
|
|
410
|
+
* @public
|
|
411
|
+
*/
|
|
412
|
+
export declare interface IIntervalCollectionEvent<TInterval extends ISerializableInterval> extends IEvent {
|
|
413
|
+
/**
|
|
414
|
+
* This event is invoked whenever the endpoints of an interval may have changed.
|
|
415
|
+
* This can happen on:
|
|
416
|
+
* - local endpoint modification
|
|
417
|
+
* - ack of a remote endpoint modification
|
|
418
|
+
* - position change due to segment sliding (slides due to mergeTree segment deletion will always appear local)
|
|
419
|
+
* The `interval` argument reflects the new values.
|
|
420
|
+
* `previousInterval` contains transient `ReferencePosition`s at the same location as the interval's original
|
|
421
|
+
* endpoints. These references should be used for position information only.
|
|
422
|
+
* `local` reflects whether the change originated locally.
|
|
423
|
+
* `op` is defined if and only if the server has acked this change.
|
|
424
|
+
* `slide` is true if the change is due to sliding on removal of position
|
|
425
|
+
*/
|
|
426
|
+
(event: "changeInterval", listener: (interval: TInterval, previousInterval: TInterval, local: boolean, op: ISequencedDocumentMessage | undefined, slide: boolean) => void): any;
|
|
427
|
+
/**
|
|
428
|
+
* This event is invoked whenever an interval is added or removed from the collection.
|
|
429
|
+
* `local` reflects whether the change originated locally.
|
|
430
|
+
* `op` is defined if and only if the server has acked this change.
|
|
431
|
+
*/
|
|
432
|
+
(event: "addInterval" | "deleteInterval", listener: (interval: TInterval, local: boolean, op: ISequencedDocumentMessage | undefined) => void): any;
|
|
433
|
+
/**
|
|
434
|
+
* This event is invoked whenever an interval's properties have changed.
|
|
435
|
+
* `interval` reflects the state of the updated properties.
|
|
436
|
+
* `propertyDeltas` is a map-like whose keys contain all values that were changed, and whose
|
|
437
|
+
* values contain all previous values of the property set.
|
|
438
|
+
* This object can be used directly in a call to `changeProperties` to revert the property change if desired.
|
|
439
|
+
* `local` reflects whether the change originated locally.
|
|
440
|
+
* `op` is defined if and only if the server has acked this change.
|
|
441
|
+
*/
|
|
442
|
+
(event: "propertyChanged", listener: (interval: TInterval, propertyDeltas: PropertySet, local: boolean, op: ISequencedDocumentMessage | undefined) => void): any;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* @sealed
|
|
447
|
+
* @deprecated The methods within have substitutions
|
|
448
|
+
* @public
|
|
449
|
+
*/
|
|
450
|
+
export declare interface IIntervalHelpers<TInterval extends ISerializableInterval> {
|
|
451
|
+
/**
|
|
452
|
+
*
|
|
453
|
+
* @param label - label of the interval collection this interval is being added to. This parameter is
|
|
454
|
+
* irrelevant for transient intervals.
|
|
455
|
+
* @param start - numerical start position of the interval
|
|
456
|
+
* @param end - numerical end position of the interval
|
|
457
|
+
* @param client - client creating the interval
|
|
458
|
+
* @param intervalType - Type of interval to create. Default is SlideOnRemove
|
|
459
|
+
* @param op - If this create came from a remote client, op that created it. Default is undefined (i.e. local)
|
|
460
|
+
* @param fromSnapshot - If this create came from loading a snapshot. Default is false.
|
|
461
|
+
* @param startSide - The side on which the start position lays. See
|
|
462
|
+
* {@link SequencePlace} for additional context
|
|
463
|
+
* @param endSide - The side on which the end position lays. See
|
|
464
|
+
* {@link SequencePlace} for additional context
|
|
465
|
+
*/
|
|
466
|
+
create(label: string, start: SequencePlace | undefined, end: SequencePlace | undefined, client: Client | undefined, intervalType: IntervalType, op?: ISequencedDocumentMessage, fromSnapshot?: boolean, useNewSlidingBehavior?: boolean): TInterval;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* @deprecated IJSONRunSegment will be removed in a upcoming release. It has been moved to the fluid-experimental/sequence-deprecated package
|
|
471
|
+
* @public
|
|
472
|
+
*/
|
|
473
|
+
export declare interface IJSONRunSegment<T> extends IJSONSegment {
|
|
474
|
+
items: Serializable<T>[];
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/* Excluded from this release type: IMapMessageLocalMetadata */
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* A sequence place that does not refer to the special endpoint segments.
|
|
481
|
+
*
|
|
482
|
+
* See {@link SequencePlace} for additional context.
|
|
483
|
+
* @public
|
|
484
|
+
*/
|
|
485
|
+
export declare interface InteriorSequencePlace {
|
|
486
|
+
pos: number;
|
|
487
|
+
side: Side;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Serializable interval whose endpoints are plain-old numbers.
|
|
492
|
+
* @public
|
|
493
|
+
*/
|
|
494
|
+
export declare class Interval implements ISerializableInterval {
|
|
495
|
+
start: number;
|
|
496
|
+
end: number;
|
|
497
|
+
/**
|
|
498
|
+
* {@inheritDoc ISerializableInterval.properties}
|
|
499
|
+
*/
|
|
500
|
+
properties: PropertySet;
|
|
501
|
+
/* Excluded from this release type: auxProps */
|
|
502
|
+
/* Excluded from this release type: propertyManager */
|
|
503
|
+
constructor(start: number, end: number, props?: PropertySet);
|
|
504
|
+
/**
|
|
505
|
+
* {@inheritDoc ISerializableInterval.getIntervalId}
|
|
506
|
+
*/
|
|
507
|
+
getIntervalId(): string;
|
|
508
|
+
/**
|
|
509
|
+
* @returns an array containing any auxiliary property sets added with `addPropertySet`.
|
|
510
|
+
*/
|
|
511
|
+
getAdditionalPropertySets(): PropertySet[];
|
|
512
|
+
/**
|
|
513
|
+
* Adds an auxiliary set of properties to this interval.
|
|
514
|
+
* These properties can be recovered using `getAdditionalPropertySets`
|
|
515
|
+
* @param props - set of properties to add
|
|
516
|
+
* @remarks This gets called as part of the default conflict resolver for `IIntervalCollection<Interval>`
|
|
517
|
+
* (i.e. non-sequence-based interval collections). However, the additional properties don't get serialized.
|
|
518
|
+
* This functionality seems half-baked.
|
|
519
|
+
*/
|
|
520
|
+
addPropertySet(props: PropertySet): void;
|
|
521
|
+
/* Excluded from this release type: serialize */
|
|
522
|
+
/**
|
|
523
|
+
* {@inheritDoc IInterval.clone}
|
|
524
|
+
*/
|
|
525
|
+
clone(): Interval;
|
|
526
|
+
/**
|
|
527
|
+
* {@inheritDoc IInterval.compare}
|
|
528
|
+
*/
|
|
529
|
+
compare(b: Interval): number;
|
|
530
|
+
/**
|
|
531
|
+
* {@inheritDoc IInterval.compareStart}
|
|
532
|
+
*/
|
|
533
|
+
compareStart(b: Interval): number;
|
|
534
|
+
/**
|
|
535
|
+
* {@inheritDoc IInterval.compareEnd}
|
|
536
|
+
*/
|
|
537
|
+
compareEnd(b: Interval): number;
|
|
538
|
+
/**
|
|
539
|
+
* {@inheritDoc IInterval.overlaps}
|
|
540
|
+
*/
|
|
541
|
+
overlaps(b: Interval): boolean;
|
|
542
|
+
/* Excluded from this release type: union */
|
|
543
|
+
getProperties(): PropertySet;
|
|
544
|
+
/* Excluded from this release type: addProperties */
|
|
545
|
+
/* Excluded from this release type: modify */
|
|
546
|
+
private initializeProperties;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Collection of intervals.
|
|
551
|
+
*
|
|
552
|
+
* Implementers of this interface will typically implement additional APIs to support efficiently querying a collection
|
|
553
|
+
* of intervals in some manner, for example:
|
|
554
|
+
* - "find all intervals with start endpoint between these two points"
|
|
555
|
+
* - "find all intervals which overlap this range"
|
|
556
|
+
* etc.
|
|
557
|
+
* @public
|
|
558
|
+
*/
|
|
559
|
+
export declare interface IntervalIndex<TInterval extends ISerializableInterval> {
|
|
560
|
+
/**
|
|
561
|
+
* Adds an interval to the index.
|
|
562
|
+
* @remarks Application code should never need to invoke this method on their index for production scenarios:
|
|
563
|
+
* Fluid handles adding and removing intervals from an index in response to sequence or interval changes.
|
|
564
|
+
*/
|
|
565
|
+
add(interval: TInterval): void;
|
|
566
|
+
/**
|
|
567
|
+
* Removes an interval from the index.
|
|
568
|
+
* @remarks Application code should never need to invoke this method on their index for production scenarios:
|
|
569
|
+
* Fluid handles adding and removing intervals from an index in response to sequence or interval changes.
|
|
570
|
+
*/
|
|
571
|
+
remove(interval: TInterval): void;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Information that identifies an interval within a `Sequence`.
|
|
576
|
+
* @public
|
|
577
|
+
*/
|
|
578
|
+
export declare interface IntervalLocator {
|
|
579
|
+
/**
|
|
580
|
+
* Label for the collection the interval is a part of
|
|
581
|
+
*/
|
|
582
|
+
label: string;
|
|
583
|
+
/**
|
|
584
|
+
* Interval within that collection
|
|
585
|
+
*/
|
|
586
|
+
interval: SequenceInterval;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Returns an object that can be used to find the interval a given LocalReferencePosition belongs to.
|
|
591
|
+
* @returns undefined if the reference position is not the endpoint of any interval (e.g. it was created
|
|
592
|
+
* on the merge tree directly by app code), otherwise an {@link IntervalLocator} for the interval this
|
|
593
|
+
* endpoint is a part of.
|
|
594
|
+
* @public
|
|
595
|
+
*/
|
|
596
|
+
export declare function intervalLocatorFromEndpoint(potentialEndpoint: LocalReferencePosition): IntervalLocator | undefined;
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Values are used in persisted formats (ops) and revertibles.
|
|
600
|
+
* @alpha
|
|
601
|
+
*/
|
|
602
|
+
export declare const IntervalOpType: {
|
|
603
|
+
readonly ADD: "add";
|
|
604
|
+
readonly DELETE: "delete";
|
|
605
|
+
readonly CHANGE: "change";
|
|
606
|
+
readonly PROPERTY_CHANGED: "propertyChanged";
|
|
607
|
+
readonly POSITION_REMOVE: "positionRemove";
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Data for undoing edits affecting Intervals.
|
|
612
|
+
*
|
|
613
|
+
* @alpha
|
|
614
|
+
*/
|
|
615
|
+
export declare type IntervalRevertible = {
|
|
616
|
+
event: typeof IntervalOpType.CHANGE;
|
|
617
|
+
interval: SequenceInterval;
|
|
618
|
+
start: LocalReferencePosition;
|
|
619
|
+
end: LocalReferencePosition;
|
|
620
|
+
} | {
|
|
621
|
+
event: typeof IntervalOpType.ADD;
|
|
622
|
+
interval: SequenceInterval;
|
|
623
|
+
} | {
|
|
624
|
+
event: typeof IntervalOpType.DELETE;
|
|
625
|
+
interval: SequenceInterval;
|
|
626
|
+
start: LocalReferencePosition;
|
|
627
|
+
end: LocalReferencePosition;
|
|
628
|
+
} | {
|
|
629
|
+
event: typeof IntervalOpType.PROPERTY_CHANGED;
|
|
630
|
+
interval: SequenceInterval;
|
|
631
|
+
propertyDeltas: PropertySet;
|
|
632
|
+
} | {
|
|
633
|
+
event: typeof IntervalOpType.POSITION_REMOVE;
|
|
634
|
+
intervals: {
|
|
635
|
+
intervalId: string;
|
|
636
|
+
label: string;
|
|
637
|
+
startOffset?: number;
|
|
638
|
+
endOffset?: number;
|
|
639
|
+
}[];
|
|
640
|
+
revertibleRefs: {
|
|
641
|
+
revertible: IntervalRevertible;
|
|
642
|
+
offset: number;
|
|
643
|
+
isStart: boolean;
|
|
644
|
+
}[];
|
|
645
|
+
mergeTreeRevertible: MergeTreeDeltaRevertible;
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
/* Excluded from this release type: IntervalStickiness */
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* @public
|
|
652
|
+
*/
|
|
653
|
+
export declare enum IntervalType {
|
|
654
|
+
Simple = 0,
|
|
655
|
+
/**
|
|
656
|
+
* @deprecated this functionality is no longer supported and will be removed
|
|
657
|
+
*/
|
|
658
|
+
Nest = 1,
|
|
659
|
+
/**
|
|
660
|
+
* SlideOnRemove indicates that the ends of the interval will slide if the segment
|
|
661
|
+
* they reference is removed and acked.
|
|
662
|
+
* See `packages\dds\merge-tree\docs\REFERENCEPOSITIONS.md` for details
|
|
663
|
+
* SlideOnRemove is the default interval behavior and does not need to be specified.
|
|
664
|
+
*/
|
|
665
|
+
SlideOnRemove = 2,
|
|
666
|
+
/* Excluded from this release type: Transient */
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* @public
|
|
671
|
+
*/
|
|
672
|
+
export declare interface IOverlappingIntervalsIndex<TInterval extends ISerializableInterval> extends IntervalIndex<TInterval> {
|
|
673
|
+
/**
|
|
674
|
+
* @returns an array of all intervals contained in this collection that overlap the range
|
|
675
|
+
* `[start end]`.
|
|
676
|
+
*/
|
|
677
|
+
findOverlappingIntervals(start: SequencePlace, end: SequencePlace): TInterval[];
|
|
678
|
+
/**
|
|
679
|
+
* Gathers the interval results based on specified parameters.
|
|
680
|
+
*/
|
|
681
|
+
gatherIterationResults(results: TInterval[], iteratesForward: boolean, start?: SequencePlace, end?: SequencePlace): void;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* A range that has changed corresponding to a segment modification.
|
|
686
|
+
* @public
|
|
687
|
+
*/
|
|
688
|
+
export declare interface ISequenceDeltaRange<TOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes> {
|
|
689
|
+
/**
|
|
690
|
+
* The type of operation that changed this range.
|
|
691
|
+
*
|
|
692
|
+
* @remarks Consuming code should typically compare this to the enum values defined in
|
|
693
|
+
* `MergeTreeDeltaOperationTypes`.
|
|
694
|
+
*/
|
|
695
|
+
operation: TOperation;
|
|
696
|
+
/**
|
|
697
|
+
* The index of the start of the range.
|
|
698
|
+
*/
|
|
699
|
+
position: number;
|
|
700
|
+
/**
|
|
701
|
+
* The segment that corresponds to the range.
|
|
702
|
+
*/
|
|
703
|
+
segment: ISegment;
|
|
704
|
+
/**
|
|
705
|
+
* Deltas object which contains all modified properties with their previous values.
|
|
706
|
+
* Since `undefined` doesn't survive a round-trip through JSON serialization, the old value being absent
|
|
707
|
+
* is instead encoded with `null`.
|
|
708
|
+
*
|
|
709
|
+
* @remarks This object is motivated by undo/redo scenarios, and provides a convenient "inverse op" to apply to
|
|
710
|
+
* undo a property change.
|
|
711
|
+
*
|
|
712
|
+
* @example
|
|
713
|
+
*
|
|
714
|
+
* If a segment initially had properties `{ foo: "1", bar: 2 }` and it was annotated with
|
|
715
|
+
* `{ foo: 3, baz: 5 }`, the corresponding event would have a `propertyDeltas` of `{ foo: "1", baz: null }`.
|
|
716
|
+
*/
|
|
717
|
+
propertyDeltas: PropertySet;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* @public
|
|
722
|
+
*/
|
|
723
|
+
export declare interface ISerializableInterval extends IInterval {
|
|
724
|
+
/** Serializable bag of properties associated with the interval. */
|
|
725
|
+
properties: PropertySet;
|
|
726
|
+
/* Excluded from this release type: propertyManager */
|
|
727
|
+
/* Excluded from this release type: serialize */
|
|
728
|
+
/* Excluded from this release type: addProperties */
|
|
729
|
+
/**
|
|
730
|
+
* Gets the id associated with this interval.
|
|
731
|
+
* When the interval is used as part of an interval collection, this id can be used to modify or remove the
|
|
732
|
+
* interval.
|
|
733
|
+
* @remarks This signature includes `undefined` strictly for backwards-compatibility reasons, as older versions
|
|
734
|
+
* of Fluid didn't always write interval ids.
|
|
735
|
+
*/
|
|
736
|
+
getIntervalId(): string | undefined;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/* Excluded from this release type: ISerializedInterval */
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* @public
|
|
743
|
+
*/
|
|
744
|
+
export declare interface ISharedIntervalCollection<TInterval extends ISerializableInterval> {
|
|
745
|
+
getIntervalCollection(label: string): IIntervalCollection<TInterval>;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* Events emitted in response to changes to the sequence data.
|
|
750
|
+
*
|
|
751
|
+
* @remarks
|
|
752
|
+
*
|
|
753
|
+
* The following is the list of events emitted.
|
|
754
|
+
*
|
|
755
|
+
* ### "sequenceDelta"
|
|
756
|
+
*
|
|
757
|
+
* The sequenceDelta event is emitted when segments are inserted, annotated, or removed.
|
|
758
|
+
*
|
|
759
|
+
* #### Listener signature
|
|
760
|
+
*
|
|
761
|
+
* ```typescript
|
|
762
|
+
* (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void
|
|
763
|
+
* ```
|
|
764
|
+
* - `event` - Various information on the segments that were modified.
|
|
765
|
+
*
|
|
766
|
+
* - `target` - The sequence itself.
|
|
767
|
+
*
|
|
768
|
+
* ### "maintenance"
|
|
769
|
+
*
|
|
770
|
+
* The maintenance event is emitted when segments are modified during merge-tree maintenance.
|
|
771
|
+
*
|
|
772
|
+
* #### Listener signature
|
|
773
|
+
*
|
|
774
|
+
* ```typescript
|
|
775
|
+
* (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void
|
|
776
|
+
* ```
|
|
777
|
+
* - `event` - Various information on the segments that were modified.
|
|
778
|
+
*
|
|
779
|
+
* - `target` - The sequence itself.
|
|
780
|
+
* @public
|
|
781
|
+
*/
|
|
782
|
+
export declare interface ISharedSegmentSequenceEvents extends ISharedObjectEvents {
|
|
783
|
+
(event: "createIntervalCollection", listener: (label: string, local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
784
|
+
(event: "sequenceDelta", listener: (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void): any;
|
|
785
|
+
(event: "maintenance", listener: (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void): any;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* Fluid object interface describing access methods on a SharedString
|
|
790
|
+
* @public
|
|
791
|
+
*/
|
|
792
|
+
export declare interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {
|
|
793
|
+
/**
|
|
794
|
+
* Inserts the text at the position.
|
|
795
|
+
* @param pos - The position to insert the text at
|
|
796
|
+
* @param text - The text to insert
|
|
797
|
+
* @param props - The properties of the text
|
|
798
|
+
*/
|
|
799
|
+
insertText(pos: number, text: string, props?: PropertySet): void;
|
|
800
|
+
/**
|
|
801
|
+
* Inserts a marker at the position.
|
|
802
|
+
* @param pos - The position to insert the marker at
|
|
803
|
+
* @param refType - The reference type of the marker
|
|
804
|
+
* @param props - The properties of the marker
|
|
805
|
+
*/
|
|
806
|
+
insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): IMergeTreeInsertMsg | undefined;
|
|
807
|
+
/**
|
|
808
|
+
* {@inheritDoc SharedSegmentSequence.posFromRelativePos}
|
|
809
|
+
*/
|
|
810
|
+
posFromRelativePos(relativePos: IRelativePosition): number;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* Collection of intervals.
|
|
815
|
+
*
|
|
816
|
+
* Provide additional APIs to support efficiently querying a collection of intervals whose startpoints fall within a specified range.
|
|
817
|
+
* @public
|
|
818
|
+
*/
|
|
819
|
+
export declare interface IStartpointInRangeIndex<TInterval extends ISerializableInterval> extends IntervalIndex<TInterval> {
|
|
820
|
+
/**
|
|
821
|
+
* @returns an array of all intervals contained in this collection whose startpoints locate in the range [start, end] (includes both ends)
|
|
822
|
+
*/
|
|
823
|
+
findIntervalsWithStartpointInRange(start: number, end: number): TInterval[];
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
/* Excluded from this release type: IValueOpEmitter */
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* Invoke revertibles to reverse prior edits
|
|
830
|
+
*
|
|
831
|
+
* @alpha
|
|
832
|
+
*/
|
|
833
|
+
export declare function revertSharedStringRevertibles(sharedString: SharedString, revertibles: SharedStringRevertible[]): void;
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* The event object returned on sequenceDelta events.
|
|
837
|
+
*
|
|
838
|
+
* The properties of this object and its sub-objects represent the state of the sequence at the
|
|
839
|
+
* point in time at which the operation was applied.
|
|
840
|
+
* They will not take into consideration any future modifications performed to the underlying sequence and merge tree.
|
|
841
|
+
*
|
|
842
|
+
* For group ops, each op will get its own event, and the group op property will be set on the op args.
|
|
843
|
+
*
|
|
844
|
+
* Ops may get multiple events. For instance, an insert-replace will get a remove then an insert event.
|
|
845
|
+
* @public
|
|
846
|
+
*/
|
|
847
|
+
export declare class SequenceDeltaEvent extends SequenceEvent<MergeTreeDeltaOperationType> {
|
|
848
|
+
readonly opArgs: IMergeTreeDeltaOpArgs;
|
|
849
|
+
/**
|
|
850
|
+
* Whether the event was caused by a locally-made change.
|
|
851
|
+
*/
|
|
852
|
+
readonly isLocal: boolean;
|
|
853
|
+
constructor(opArgs: IMergeTreeDeltaOpArgs, deltaArgs: IMergeTreeDeltaCallbackArgs, mergeTreeClient: Client);
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* Base class for SequenceDeltaEvent and SequenceMaintenanceEvent.
|
|
858
|
+
*
|
|
859
|
+
* The properties of this object and its sub-objects represent the state of the sequence at the
|
|
860
|
+
* point in time at which the operation was applied.
|
|
861
|
+
* They will not take into any future modifications performed to the underlying sequence and merge tree.
|
|
862
|
+
* @public
|
|
863
|
+
*/
|
|
864
|
+
export declare abstract class SequenceEvent<TOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes> {
|
|
865
|
+
readonly deltaArgs: IMergeTreeDeltaCallbackArgs<TOperation>;
|
|
866
|
+
private readonly mergeTreeClient;
|
|
867
|
+
readonly deltaOperation: TOperation;
|
|
868
|
+
private readonly sortedRanges;
|
|
869
|
+
private readonly pFirst;
|
|
870
|
+
private readonly pLast;
|
|
871
|
+
constructor(deltaArgs: IMergeTreeDeltaCallbackArgs<TOperation>, mergeTreeClient: Client);
|
|
872
|
+
/**
|
|
873
|
+
* The in-order ranges affected by this delta.
|
|
874
|
+
* These may not be continuous.
|
|
875
|
+
*/
|
|
876
|
+
get ranges(): readonly Readonly<ISequenceDeltaRange<TOperation>>[];
|
|
877
|
+
/**
|
|
878
|
+
* The client id of the client that made the change which caused the delta event
|
|
879
|
+
*/
|
|
880
|
+
get clientId(): string | undefined;
|
|
881
|
+
/**
|
|
882
|
+
* The first of the modified ranges.
|
|
883
|
+
*/
|
|
884
|
+
get first(): Readonly<ISequenceDeltaRange<TOperation>>;
|
|
885
|
+
/**
|
|
886
|
+
* The last of the modified ranges.
|
|
887
|
+
*/
|
|
888
|
+
get last(): Readonly<ISequenceDeltaRange<TOperation>>;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Interval implementation whose ends are associated with positions in a mutatable sequence.
|
|
893
|
+
* As such, when content is inserted into the middle of the interval, the interval expands to
|
|
894
|
+
* include that content.
|
|
895
|
+
*
|
|
896
|
+
* @remarks The endpoints' positions should be treated exclusively to get
|
|
897
|
+
* reasonable behavior. E.g., an interval referring to "hello" in "hello world"
|
|
898
|
+
* should have a start position of 0 and an end position of 5.
|
|
899
|
+
*
|
|
900
|
+
* To see why, consider what happens if "llo wor" is removed from the string to make "held".
|
|
901
|
+
* The interval's startpoint remains on the "h" (it isn't altered), but the interval's endpoint
|
|
902
|
+
* slides forward to the next unremoved position, which is the "l" in "held".
|
|
903
|
+
* Users would generally expect the interval to now refer to "he" (as it is the subset of content
|
|
904
|
+
* remaining after the removal), hence the "l" should be excluded.
|
|
905
|
+
* If the interval endpoint was treated inclusively, the interval would now refer to "hel", which
|
|
906
|
+
* is undesirable.
|
|
907
|
+
*
|
|
908
|
+
* Since the endpoints of an interval are treated exclusively but cannot be greater
|
|
909
|
+
* than or equal to the length of the associated sequence, there exist special
|
|
910
|
+
* endpoint segments, "start" and "end", which represent the position immediately
|
|
911
|
+
* before or immediately after the string respectively.
|
|
912
|
+
*
|
|
913
|
+
* If a `SequenceInterval` is created on a sequence with the
|
|
914
|
+
* `mergeTreeReferencesCanSlideToEndpoint` feature flag set to true, the endpoints
|
|
915
|
+
* of the interval that are exclusive will have the ability to slide to these
|
|
916
|
+
* special endpoint segments.
|
|
917
|
+
* @public
|
|
918
|
+
*/
|
|
919
|
+
export declare class SequenceInterval implements ISerializableInterval {
|
|
920
|
+
private readonly client;
|
|
921
|
+
/**
|
|
922
|
+
* Start endpoint of this interval.
|
|
923
|
+
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
924
|
+
*/
|
|
925
|
+
start: LocalReferencePosition;
|
|
926
|
+
/**
|
|
927
|
+
* End endpoint of this interval.
|
|
928
|
+
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
929
|
+
*/
|
|
930
|
+
end: LocalReferencePosition;
|
|
931
|
+
intervalType: IntervalType;
|
|
932
|
+
readonly startSide: Side;
|
|
933
|
+
readonly endSide: Side;
|
|
934
|
+
/**
|
|
935
|
+
* {@inheritDoc ISerializableInterval.properties}
|
|
936
|
+
*/
|
|
937
|
+
properties: PropertySet;
|
|
938
|
+
/* Excluded from this release type: propertyManager */
|
|
939
|
+
/* Excluded from this release type: stickiness */
|
|
940
|
+
constructor(client: Client,
|
|
941
|
+
/**
|
|
942
|
+
* Start endpoint of this interval.
|
|
943
|
+
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
944
|
+
*/
|
|
945
|
+
start: LocalReferencePosition,
|
|
946
|
+
/**
|
|
947
|
+
* End endpoint of this interval.
|
|
948
|
+
* @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
|
|
949
|
+
*/
|
|
950
|
+
end: LocalReferencePosition, intervalType: IntervalType, props?: PropertySet, startSide?: Side, endSide?: Side);
|
|
951
|
+
private callbacks?;
|
|
952
|
+
/* Excluded from this release type: addPositionChangeListeners */
|
|
953
|
+
/* Excluded from this release type: removePositionChangeListeners */
|
|
954
|
+
/* Excluded from this release type: serialize */
|
|
955
|
+
/**
|
|
956
|
+
* {@inheritDoc IInterval.clone}
|
|
957
|
+
*/
|
|
958
|
+
clone(): SequenceInterval;
|
|
959
|
+
/**
|
|
960
|
+
* {@inheritDoc IInterval.compare}
|
|
961
|
+
*/
|
|
962
|
+
compare(b: SequenceInterval): number;
|
|
963
|
+
/**
|
|
964
|
+
* {@inheritDoc IInterval.compareStart}
|
|
965
|
+
*/
|
|
966
|
+
compareStart(b: SequenceInterval): number;
|
|
967
|
+
/**
|
|
968
|
+
* {@inheritDoc IInterval.compareEnd}
|
|
969
|
+
*/
|
|
970
|
+
compareEnd(b: SequenceInterval): number;
|
|
971
|
+
/**
|
|
972
|
+
* {@inheritDoc IInterval.overlaps}
|
|
973
|
+
*/
|
|
974
|
+
overlaps(b: SequenceInterval): boolean;
|
|
975
|
+
/**
|
|
976
|
+
* {@inheritDoc ISerializableInterval.getIntervalId}
|
|
977
|
+
*/
|
|
978
|
+
getIntervalId(): string;
|
|
979
|
+
/* Excluded from this release type: union */
|
|
980
|
+
/* Excluded from this release type: addProperties */
|
|
981
|
+
/**
|
|
982
|
+
* @returns whether this interval overlaps two numerical positions.
|
|
983
|
+
*/
|
|
984
|
+
overlapsPos(bstart: number, bend: number): boolean;
|
|
985
|
+
/* Excluded from this release type: modify */
|
|
986
|
+
private initializeProperties;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* @deprecated The methods within have substitutions
|
|
991
|
+
* @public
|
|
992
|
+
*/
|
|
993
|
+
export declare const sequenceIntervalHelpers: IIntervalHelpers<SequenceInterval>;
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* This namespace contains specialiazations of indexes which support spatial queries
|
|
997
|
+
* specifically for `SequenceInterval`s.
|
|
998
|
+
* @public
|
|
999
|
+
*/
|
|
1000
|
+
export declare namespace SequenceIntervalIndexes {
|
|
1001
|
+
/**
|
|
1002
|
+
* Collection of intervals.
|
|
1003
|
+
*
|
|
1004
|
+
* Provides additional APIs to support efficiently querying a collection of intervals based on segments and offset.
|
|
1005
|
+
*/
|
|
1006
|
+
export interface Overlapping extends IOverlappingIntervalsIndex<SequenceInterval> {
|
|
1007
|
+
/**
|
|
1008
|
+
* Finds overlapping intervals within the specified range.
|
|
1009
|
+
*
|
|
1010
|
+
* @returns an array of all intervals that overlap with the specified SegOff range (includes both ends)
|
|
1011
|
+
*/
|
|
1012
|
+
findOverlappingIntervalsBySegoff(startSegoff: {
|
|
1013
|
+
segment: ISegment | undefined;
|
|
1014
|
+
offset: number | undefined;
|
|
1015
|
+
}, endSegoff: {
|
|
1016
|
+
segment: ISegment | undefined;
|
|
1017
|
+
offset: number | undefined;
|
|
1018
|
+
}): Iterable<SequenceInterval>;
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* The event object returned on maintenance events.
|
|
1024
|
+
*
|
|
1025
|
+
* The properties of this object and its sub-objects represent the state of the sequence at the
|
|
1026
|
+
* point in time at which the operation was applied.
|
|
1027
|
+
* They will not take into consideration any future modifications performed to the underlying sequence and merge tree.
|
|
1028
|
+
* @public
|
|
1029
|
+
*/
|
|
1030
|
+
export declare class SequenceMaintenanceEvent extends SequenceEvent<MergeTreeMaintenanceType> {
|
|
1031
|
+
readonly opArgs: IMergeTreeDeltaOpArgs | undefined;
|
|
1032
|
+
constructor(opArgs: IMergeTreeDeltaOpArgs | undefined, deltaArgs: IMergeTreeMaintenanceCallbackArgs, mergeTreeClient: Client);
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* Optional flags that configure options for sequence DDSs
|
|
1037
|
+
* @public
|
|
1038
|
+
*/
|
|
1039
|
+
export declare interface SequenceOptions {
|
|
1040
|
+
/**
|
|
1041
|
+
* Enable the ability to use interval APIs that rely on positions before and
|
|
1042
|
+
* after individual characters, referred to as "sides". See {@link SequencePlace}
|
|
1043
|
+
* for additional context.
|
|
1044
|
+
*
|
|
1045
|
+
* This flag must be enabled to pass instances of {@link SequencePlace} to
|
|
1046
|
+
* any IIntervalCollection API.
|
|
1047
|
+
*
|
|
1048
|
+
* Also see the feature flag `mergeTreeReferencesCanSlideToEndpoint` to allow
|
|
1049
|
+
* endpoints to slide to the special endpoint segments.
|
|
1050
|
+
*
|
|
1051
|
+
* The default value is false.
|
|
1052
|
+
*/
|
|
1053
|
+
intervalStickinessEnabled: boolean;
|
|
1054
|
+
/**
|
|
1055
|
+
* Enable the ability for interval endpoints to slide to the special endpoint
|
|
1056
|
+
* segments that exist before and after the bounds of the string. This is
|
|
1057
|
+
* primarily useful for workflows involving interval stickiness, and it is
|
|
1058
|
+
* suggested to enable both this flag and `intervalStickinessEnabled` at the
|
|
1059
|
+
* same time.
|
|
1060
|
+
*
|
|
1061
|
+
* The default value is false.
|
|
1062
|
+
*/
|
|
1063
|
+
mergeTreeReferencesCanSlideToEndpoint: boolean;
|
|
1064
|
+
[key: string]: boolean;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
/**
|
|
1068
|
+
* Defines a position and side relative to a character in a sequence.
|
|
1069
|
+
*
|
|
1070
|
+
* For this purpose, sequences look like:
|
|
1071
|
+
*
|
|
1072
|
+
* `{start} - {character 0} - {character 1} - ... - {character N} - {end}`
|
|
1073
|
+
*
|
|
1074
|
+
* Each `{value}` in the diagram is a character within a sequence.
|
|
1075
|
+
* Each `-` in the above diagram is a position where text could be inserted.
|
|
1076
|
+
* Each position between a `{value}` and a `-` is a `SequencePlace`.
|
|
1077
|
+
*
|
|
1078
|
+
* The special endpoints `{start}` and `{end}` refer to positions outside the
|
|
1079
|
+
* contents of the string.
|
|
1080
|
+
*
|
|
1081
|
+
* This gives us 2N + 2 possible positions to refer to within a string, where N
|
|
1082
|
+
* is the number of characters.
|
|
1083
|
+
*
|
|
1084
|
+
* If the position is specified with a bare number, the side defaults to
|
|
1085
|
+
* `Side.Before`.
|
|
1086
|
+
*
|
|
1087
|
+
* If a SequencePlace is the endpoint of a range (e.g. start/end of an interval or search range),
|
|
1088
|
+
* the Side value means it is exclusive if it is nearer to the other position and inclusive if it is farther.
|
|
1089
|
+
* E.g. the start of a range with Side.After is exclusive of the character at the position.
|
|
1090
|
+
* @public
|
|
1091
|
+
*/
|
|
1092
|
+
export declare type SequencePlace = number | "start" | "end" | InteriorSequencePlace;
|
|
1093
|
+
|
|
1094
|
+
/* Excluded from this release type: SerializedIntervalDelta */
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.
|
|
1098
|
+
* @public
|
|
1099
|
+
*/
|
|
1100
|
+
export declare class SharedIntervalCollection extends SharedObject implements ISharedIntervalCollection<Interval> {
|
|
1101
|
+
/**
|
|
1102
|
+
* Create a SharedIntervalCollection
|
|
1103
|
+
*
|
|
1104
|
+
* @param runtime - data store runtime the new shared map belongs to
|
|
1105
|
+
* @param id - optional name of the shared map
|
|
1106
|
+
* @returns newly create shared map (but not attached yet)
|
|
1107
|
+
*/
|
|
1108
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): SharedIntervalCollection;
|
|
1109
|
+
/**
|
|
1110
|
+
* Get a factory for SharedIntervalCollection to register with the data store.
|
|
1111
|
+
*
|
|
1112
|
+
* @returns a factory that creates and load SharedIntervalCollection
|
|
1113
|
+
*/
|
|
1114
|
+
static getFactory(): IChannelFactory;
|
|
1115
|
+
readonly [Symbol.toStringTag]: string;
|
|
1116
|
+
private readonly intervalCollections;
|
|
1117
|
+
/**
|
|
1118
|
+
* Constructs a new shared SharedIntervalCollection. If the object is non-local an id and service interfaces will
|
|
1119
|
+
* be provided
|
|
1120
|
+
*/
|
|
1121
|
+
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
1122
|
+
getIntervalCollection(label: string): IIntervalCollection<Interval>;
|
|
1123
|
+
protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
|
|
1124
|
+
protected reSubmitCore(content: any, localOpMetadata: unknown): void;
|
|
1125
|
+
protected onDisconnect(): void;
|
|
1126
|
+
/**
|
|
1127
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
1128
|
+
*/
|
|
1129
|
+
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
1130
|
+
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
1131
|
+
/**
|
|
1132
|
+
* Creates the full path of the intervalCollection label
|
|
1133
|
+
* @param label - the incoming label
|
|
1134
|
+
*/
|
|
1135
|
+
protected getIntervalCollectionPath(label: string): string;
|
|
1136
|
+
protected applyStashedOp(): void;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
/**
|
|
1140
|
+
* The factory that defines the SharedIntervalCollection.
|
|
1141
|
+
* @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.
|
|
1142
|
+
* @public
|
|
1143
|
+
*/
|
|
1144
|
+
export declare class SharedIntervalCollectionFactory implements IChannelFactory {
|
|
1145
|
+
static readonly Type = "https://graph.microsoft.com/types/sharedIntervalCollection";
|
|
1146
|
+
static readonly Attributes: IChannelAttributes;
|
|
1147
|
+
get type(): string;
|
|
1148
|
+
get attributes(): IChannelAttributes;
|
|
1149
|
+
/**
|
|
1150
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
1151
|
+
*/
|
|
1152
|
+
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<SharedIntervalCollection>;
|
|
1153
|
+
create(runtime: IFluidDataStoreRuntime, id: string): SharedIntervalCollection;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
/**
|
|
1157
|
+
* @public
|
|
1158
|
+
*/
|
|
1159
|
+
export declare abstract class SharedSegmentSequence<T extends ISegment> extends SharedObject<ISharedSegmentSequenceEvents> implements ISharedIntervalCollection<SequenceInterval>, MergeTreeRevertibleDriver {
|
|
1160
|
+
private readonly dataStoreRuntime;
|
|
1161
|
+
id: string;
|
|
1162
|
+
readonly segmentFromSpec: (spec: IJSONSegment) => ISegment;
|
|
1163
|
+
get loaded(): Promise<void>;
|
|
1164
|
+
/* Excluded from this release type: guardReentrancy */
|
|
1165
|
+
private static createOpsFromDelta;
|
|
1166
|
+
protected client: Client;
|
|
1167
|
+
/** `Deferred` that triggers once the object is loaded */
|
|
1168
|
+
protected loadedDeferred: Deferred<void>;
|
|
1169
|
+
private readonly loadedDeferredOutgoingOps;
|
|
1170
|
+
private deferIncomingOps;
|
|
1171
|
+
private readonly loadedDeferredIncomingOps;
|
|
1172
|
+
private messagesSinceMSNChange;
|
|
1173
|
+
private readonly intervalCollections;
|
|
1174
|
+
constructor(dataStoreRuntime: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes, segmentFromSpec: (spec: IJSONSegment) => ISegment);
|
|
1175
|
+
/**
|
|
1176
|
+
* @param start - The inclusive start of the range to remove
|
|
1177
|
+
* @param end - The exclusive end of the range to remove
|
|
1178
|
+
*/
|
|
1179
|
+
removeRange(start: number, end: number): IMergeTreeRemoveMsg;
|
|
1180
|
+
/**
|
|
1181
|
+
* @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
|
|
1182
|
+
*/
|
|
1183
|
+
groupOperation(groupOp: IMergeTreeGroupMsg): void;
|
|
1184
|
+
/**
|
|
1185
|
+
* Finds the segment information (i.e. segment + offset) corresponding to a character position in the SharedString.
|
|
1186
|
+
* If the position is past the end of the string, `segment` and `offset` on the returned object may be undefined.
|
|
1187
|
+
* @param pos - Character position (index) into the current local view of the SharedString.
|
|
1188
|
+
*/
|
|
1189
|
+
getContainingSegment(pos: number): {
|
|
1190
|
+
segment: T | undefined;
|
|
1191
|
+
offset: number | undefined;
|
|
1192
|
+
};
|
|
1193
|
+
/**
|
|
1194
|
+
* Returns the length of the current sequence for the client
|
|
1195
|
+
*/
|
|
1196
|
+
getLength(): number;
|
|
1197
|
+
/**
|
|
1198
|
+
* Returns the current position of a segment, and -1 if the segment
|
|
1199
|
+
* does not exist in this sequence
|
|
1200
|
+
* @param segment - The segment to get the position of
|
|
1201
|
+
*/
|
|
1202
|
+
getPosition(segment: ISegment): number;
|
|
1203
|
+
/**
|
|
1204
|
+
* Annotates the range with the provided properties
|
|
1205
|
+
*
|
|
1206
|
+
* @param start - The inclusive start position of the range to annotate
|
|
1207
|
+
* @param end - The exclusive end position of the range to annotate
|
|
1208
|
+
* @param props - The properties to annotate the range with
|
|
1209
|
+
* @param combiningOp - Optional. Specifies how to combine values for the property, such as "incr" for increment.
|
|
1210
|
+
*
|
|
1211
|
+
*/
|
|
1212
|
+
annotateRange(start: number, end: number, props: PropertySet, combiningOp?: ICombiningOp): void;
|
|
1213
|
+
getPropertiesAtPosition(pos: number): PropertySet | undefined;
|
|
1214
|
+
getRangeExtentsOfPosition(pos: number): {
|
|
1215
|
+
posStart: number | undefined;
|
|
1216
|
+
posAfterEnd: number | undefined;
|
|
1217
|
+
};
|
|
1218
|
+
/**
|
|
1219
|
+
* Creates a `LocalReferencePosition` on this SharedString. If the refType does not include
|
|
1220
|
+
* ReferenceType.Transient, the returned reference will be added to the localRefs on the provided segment.
|
|
1221
|
+
* @param segment - Segment to add the local reference on
|
|
1222
|
+
* @param offset - Offset on the segment at which to place the local reference
|
|
1223
|
+
* @param refType - ReferenceType for the created local reference
|
|
1224
|
+
* @param properties - PropertySet to place on the created local reference
|
|
1225
|
+
*/
|
|
1226
|
+
createLocalReferencePosition(segment: T, offset: number, refType: ReferenceType, properties: PropertySet | undefined, slidingPreference?: SlidingPreference, canSlideToEndpoint?: boolean): LocalReferencePosition;
|
|
1227
|
+
/**
|
|
1228
|
+
* Resolves a `ReferencePosition` into a character position using this client's perspective.
|
|
1229
|
+
*/
|
|
1230
|
+
localReferencePositionToPosition(lref: ReferencePosition): number;
|
|
1231
|
+
/**
|
|
1232
|
+
* Removes a `LocalReferencePosition` from this SharedString.
|
|
1233
|
+
*/
|
|
1234
|
+
removeLocalReferencePosition(lref: LocalReferencePosition): LocalReferencePosition | undefined;
|
|
1235
|
+
/**
|
|
1236
|
+
* Resolves a remote client's position against the local sequence
|
|
1237
|
+
* and returns the remote client's position relative to the local
|
|
1238
|
+
* sequence. The client ref seq must be above the minimum sequence number
|
|
1239
|
+
* or the return value will be undefined.
|
|
1240
|
+
* Generally this method is used in conjunction with signals which provide
|
|
1241
|
+
* point in time values for the below parameters, and is useful for things
|
|
1242
|
+
* like displaying user position. It should not be used with persisted values
|
|
1243
|
+
* as persisted values will quickly become invalid as the remoteClientRefSeq
|
|
1244
|
+
* moves below the minimum sequence number
|
|
1245
|
+
* @param remoteClientPosition - The remote client's position to resolve
|
|
1246
|
+
* @param remoteClientRefSeq - The reference sequence number of the remote client
|
|
1247
|
+
* @param remoteClientId - The client id of the remote client
|
|
1248
|
+
*/
|
|
1249
|
+
resolveRemoteClientPosition(remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: string): number | undefined;
|
|
1250
|
+
/**
|
|
1251
|
+
* @deprecated This method will no longer be public in an upcoming release as it is not safe to use outside of this class
|
|
1252
|
+
*/
|
|
1253
|
+
submitSequenceMessage(message: IMergeTreeOp): void;
|
|
1254
|
+
/**
|
|
1255
|
+
* Given a position specified relative to a marker id, lookup the marker
|
|
1256
|
+
* and convert the position to a character position.
|
|
1257
|
+
* @param relativePos - Id of marker (may be indirect) and whether position is before or after marker.
|
|
1258
|
+
*/
|
|
1259
|
+
posFromRelativePos(relativePos: IRelativePosition): number;
|
|
1260
|
+
/**
|
|
1261
|
+
* Walk the underlying segments of the sequence.
|
|
1262
|
+
* The walked segments may extend beyond the range
|
|
1263
|
+
* if the segments cross the ranges start or end boundaries.
|
|
1264
|
+
* Set split range to true to ensure only segments within the
|
|
1265
|
+
* range are walked.
|
|
1266
|
+
*
|
|
1267
|
+
* @param handler - The function to handle each segment
|
|
1268
|
+
* @param start - Optional. The start of range walk.
|
|
1269
|
+
* @param end - Optional. The end of range walk
|
|
1270
|
+
* @param accum - Optional. An object that will be passed to the handler for accumulation
|
|
1271
|
+
* @param splitRange - Optional. Splits boundary segments on the range boundaries
|
|
1272
|
+
*/
|
|
1273
|
+
walkSegments<TClientData>(handler: ISegmentAction<TClientData>, start?: number, end?: number, accum?: TClientData, splitRange?: boolean): void;
|
|
1274
|
+
/**
|
|
1275
|
+
* @deprecated this functionality is no longer supported and will be removed
|
|
1276
|
+
*/
|
|
1277
|
+
getStackContext(startPos: number, rangeLabels: string[]): RangeStackMap;
|
|
1278
|
+
/**
|
|
1279
|
+
* @returns The most recent sequence number which has been acked by the server and processed by this
|
|
1280
|
+
* SharedSegmentSequence.
|
|
1281
|
+
*/
|
|
1282
|
+
getCurrentSeq(): number;
|
|
1283
|
+
/**
|
|
1284
|
+
* Inserts a segment directly before a `ReferencePosition`.
|
|
1285
|
+
* @param refPos - The reference position to insert the segment at
|
|
1286
|
+
* @param segment - The segment to insert
|
|
1287
|
+
*/
|
|
1288
|
+
insertAtReferencePosition(pos: ReferencePosition, segment: T): void;
|
|
1289
|
+
/**
|
|
1290
|
+
* Inserts a segment
|
|
1291
|
+
* @param start - The position to insert the segment at
|
|
1292
|
+
* @param spec - The segment to inserts spec
|
|
1293
|
+
*/
|
|
1294
|
+
insertFromSpec(pos: number, spec: IJSONSegment): void;
|
|
1295
|
+
/**
|
|
1296
|
+
* Retrieves the interval collection keyed on `label`. If no such interval collection exists,
|
|
1297
|
+
* creates one.
|
|
1298
|
+
*/
|
|
1299
|
+
getIntervalCollection(label: string): IIntervalCollection<SequenceInterval>;
|
|
1300
|
+
/**
|
|
1301
|
+
* @returns An iterable object that enumerates the IntervalCollection labels.
|
|
1302
|
+
*
|
|
1303
|
+
* @example
|
|
1304
|
+
*
|
|
1305
|
+
* ```typescript
|
|
1306
|
+
* const iter = this.getIntervalCollectionKeys();
|
|
1307
|
+
* for (key of iter)
|
|
1308
|
+
* const collection = this.getIntervalCollection(key);
|
|
1309
|
+
* ...
|
|
1310
|
+
* ```
|
|
1311
|
+
*/
|
|
1312
|
+
getIntervalCollectionLabels(): IterableIterator<string>;
|
|
1313
|
+
/**
|
|
1314
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
1315
|
+
*/
|
|
1316
|
+
protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
|
|
1317
|
+
/**
|
|
1318
|
+
* Runs serializer over the GC data for this SharedMatrix.
|
|
1319
|
+
* All the IFluidHandle's represent routes to other objects.
|
|
1320
|
+
*/
|
|
1321
|
+
protected processGCDataCore(serializer: SummarySerializer): void;
|
|
1322
|
+
/**
|
|
1323
|
+
* Replace the range specified from start to end with the provided segment
|
|
1324
|
+
* This is done by inserting the segment at the end of the range, followed
|
|
1325
|
+
* by removing the contents of the range
|
|
1326
|
+
* For a zero or reverse range (start \>= end), insert at end do not remove anything
|
|
1327
|
+
* @param start - The start of the range to replace
|
|
1328
|
+
* @param end - The end of the range to replace
|
|
1329
|
+
* @param segment - The segment that will replace the range
|
|
1330
|
+
*/
|
|
1331
|
+
protected replaceRange(start: number, end: number, segment: ISegment): void;
|
|
1332
|
+
/**
|
|
1333
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onConnect}
|
|
1334
|
+
*/
|
|
1335
|
+
protected onConnect(): void;
|
|
1336
|
+
/**
|
|
1337
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
|
|
1338
|
+
*/
|
|
1339
|
+
protected onDisconnect(): void;
|
|
1340
|
+
/**
|
|
1341
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
|
|
1342
|
+
*/
|
|
1343
|
+
protected reSubmitCore(content: any, localOpMetadata: unknown): void;
|
|
1344
|
+
/**
|
|
1345
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
1346
|
+
*/
|
|
1347
|
+
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
1348
|
+
/**
|
|
1349
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
|
|
1350
|
+
*/
|
|
1351
|
+
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
1352
|
+
/**
|
|
1353
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.didAttach}
|
|
1354
|
+
*/
|
|
1355
|
+
protected didAttach(): void;
|
|
1356
|
+
/**
|
|
1357
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.initializeLocalCore}
|
|
1358
|
+
*/
|
|
1359
|
+
protected initializeLocalCore(): void;
|
|
1360
|
+
/**
|
|
1361
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
|
1362
|
+
*/
|
|
1363
|
+
protected applyStashedOp(content: any): unknown;
|
|
1364
|
+
private summarizeMergeTree;
|
|
1365
|
+
private processMergeTreeMsg;
|
|
1366
|
+
private processMinSequenceNumberChanged;
|
|
1367
|
+
private loadFinished;
|
|
1368
|
+
private initializeIntervalCollections;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
/**
|
|
1372
|
+
* @deprecated SharedSequence will be removed in a upcoming release. It has been moved to the fluid-experimental/sequence-deprecated package
|
|
1373
|
+
* @public
|
|
1374
|
+
*/
|
|
1375
|
+
export declare class SharedSequence<T> extends SharedSegmentSequence<SubSequence<T>> {
|
|
1376
|
+
id: string;
|
|
1377
|
+
constructor(document: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes, specToSegment: (spec: IJSONSegment) => ISegment);
|
|
1378
|
+
/**
|
|
1379
|
+
* @param pos - The position to insert the items at.
|
|
1380
|
+
* @param items - The items to insert.
|
|
1381
|
+
* @param props - Optional. Properties to set on the inserted items.
|
|
1382
|
+
*/
|
|
1383
|
+
insert(pos: number, items: Serializable<T>[], props?: PropertySet): void;
|
|
1384
|
+
/**
|
|
1385
|
+
* @param start - The inclusive start of the range to remove
|
|
1386
|
+
* @param end - The exclusive end of the range to remove
|
|
1387
|
+
*/
|
|
1388
|
+
remove(start: number, end: number): void;
|
|
1389
|
+
/**
|
|
1390
|
+
* Returns the total count of items in the sequence
|
|
1391
|
+
*/
|
|
1392
|
+
getItemCount(): number;
|
|
1393
|
+
/**
|
|
1394
|
+
* Gets the items in the specified range
|
|
1395
|
+
*
|
|
1396
|
+
* @param start - The inclusive start of the range
|
|
1397
|
+
* @param end - The exclusive end of the range
|
|
1398
|
+
*/
|
|
1399
|
+
getItems(start: number, end?: number): Serializable<T>[];
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* The Shared String is a specialized data structure for handling collaborative
|
|
1404
|
+
* text. It is based on a more general Sequence data structure but has
|
|
1405
|
+
* additional features that make working with text easier.
|
|
1406
|
+
*
|
|
1407
|
+
* In addition to text, a Shared String can also contain markers. Markers can be
|
|
1408
|
+
* used to store metadata at positions within the text, like the details of an
|
|
1409
|
+
* image or Fluid object that should be rendered with the text.
|
|
1410
|
+
*
|
|
1411
|
+
* @public
|
|
1412
|
+
*/
|
|
1413
|
+
export declare class SharedString extends SharedSegmentSequence<SharedStringSegment> implements ISharedString {
|
|
1414
|
+
id: string;
|
|
1415
|
+
/**
|
|
1416
|
+
* Create a new shared string.
|
|
1417
|
+
* @param runtime - data store runtime the new shared string belongs to
|
|
1418
|
+
* @param id - optional name of the shared string
|
|
1419
|
+
* @returns newly create shared string (but not attached yet)
|
|
1420
|
+
*/
|
|
1421
|
+
static create(runtime: IFluidDataStoreRuntime, id?: string): SharedString;
|
|
1422
|
+
/**
|
|
1423
|
+
* Get a factory for SharedString to register with the data store.
|
|
1424
|
+
* @returns a factory that creates and load SharedString
|
|
1425
|
+
*/
|
|
1426
|
+
static getFactory(): SharedStringFactory;
|
|
1427
|
+
get ISharedString(): ISharedString;
|
|
1428
|
+
private readonly mergeTreeTextHelper;
|
|
1429
|
+
constructor(document: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes);
|
|
1430
|
+
/**
|
|
1431
|
+
* Inserts a marker at a relative position.
|
|
1432
|
+
* @param relativePos1 - The relative position to insert the marker at
|
|
1433
|
+
* @param refType - The reference type of the marker
|
|
1434
|
+
* @param props - The properties of the marker
|
|
1435
|
+
*/
|
|
1436
|
+
insertMarkerRelative(relativePos1: IRelativePosition, refType: ReferenceType, props?: PropertySet): void;
|
|
1437
|
+
/**
|
|
1438
|
+
* {@inheritDoc ISharedString.insertMarker}
|
|
1439
|
+
*/
|
|
1440
|
+
insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): IMergeTreeInsertMsg | undefined;
|
|
1441
|
+
/**
|
|
1442
|
+
* Inserts the text at the position.
|
|
1443
|
+
* @param relativePos1 - The relative position to insert the text at
|
|
1444
|
+
* @param text - The text to insert
|
|
1445
|
+
* @param props - The properties of text
|
|
1446
|
+
*/
|
|
1447
|
+
insertTextRelative(relativePos1: IRelativePosition, text: string, props?: PropertySet): void;
|
|
1448
|
+
/**
|
|
1449
|
+
* {@inheritDoc ISharedString.insertText}
|
|
1450
|
+
*/
|
|
1451
|
+
insertText(pos: number, text: string, props?: PropertySet): void;
|
|
1452
|
+
/**
|
|
1453
|
+
* Replaces a range with the provided text.
|
|
1454
|
+
* @param start - The inclusive start of the range to replace
|
|
1455
|
+
* @param end - The exclusive end of the range to replace
|
|
1456
|
+
* @param text - The text to replace the range with
|
|
1457
|
+
* @param props - Optional. The properties of the replacement text
|
|
1458
|
+
*/
|
|
1459
|
+
replaceText(start: number, end: number, text: string, props?: PropertySet): void;
|
|
1460
|
+
/**
|
|
1461
|
+
* Removes the text in the given range.
|
|
1462
|
+
* @param start - The inclusive start of the range to remove
|
|
1463
|
+
* @param end - The exclusive end of the range to replace
|
|
1464
|
+
* @returns the message sent.
|
|
1465
|
+
*/
|
|
1466
|
+
removeText(start: number, end: number): IMergeTreeRemoveMsg;
|
|
1467
|
+
/**
|
|
1468
|
+
* Annotates the marker with the provided properties and calls the callback on consensus.
|
|
1469
|
+
* @param marker - The marker to annotate
|
|
1470
|
+
* @param props - The properties to annotate the marker with
|
|
1471
|
+
* @param consensusCallback - The callback called when consensus is reached
|
|
1472
|
+
*/
|
|
1473
|
+
annotateMarkerNotifyConsensus(marker: Marker, props: PropertySet, callback: (m: Marker) => void): void;
|
|
1474
|
+
/**
|
|
1475
|
+
* Annotates the marker with the provided properties.
|
|
1476
|
+
* @param marker - The marker to annotate
|
|
1477
|
+
* @param props - The properties to annotate the marker with
|
|
1478
|
+
* @param combiningOp - Optional. Specifies how to combine values for the property, such as "incr" for increment.
|
|
1479
|
+
*/
|
|
1480
|
+
annotateMarker(marker: Marker, props: PropertySet, combiningOp?: ICombiningOp): void;
|
|
1481
|
+
/**
|
|
1482
|
+
* Finds the nearest reference with ReferenceType.Tile to `startPos` in the direction dictated by `tilePrecedesPos`.
|
|
1483
|
+
* Note that Markers receive `ReferenceType.Tile` by default.
|
|
1484
|
+
* @deprecated Use `searchForMarker` instead.
|
|
1485
|
+
* @param startPos - Position at which to start the search
|
|
1486
|
+
* @param clientId - clientId dictating the perspective to search from
|
|
1487
|
+
* @param tileLabel - Label of the tile to search for
|
|
1488
|
+
* @param preceding - Whether the desired tile comes before (true) or after (false) `startPos`
|
|
1489
|
+
*/
|
|
1490
|
+
findTile(startPos: number | undefined, tileLabel: string, preceding?: boolean): {
|
|
1491
|
+
tile: ReferencePosition;
|
|
1492
|
+
pos: number;
|
|
1493
|
+
} | undefined;
|
|
1494
|
+
/**
|
|
1495
|
+
* Searches a string for the nearest marker in either direction to a given start position.
|
|
1496
|
+
* The search will include the start position, so markers at the start position are valid
|
|
1497
|
+
* results of the search.
|
|
1498
|
+
* @param startPos - Position at which to start the search
|
|
1499
|
+
* @param markerLabel - Label of the marker to search for
|
|
1500
|
+
* @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`
|
|
1501
|
+
*/
|
|
1502
|
+
searchForMarker(startPos: number, markerLabel: string, forwards?: boolean): Marker | undefined;
|
|
1503
|
+
/**
|
|
1504
|
+
* Retrieve text from the SharedString in string format.
|
|
1505
|
+
* @param start - The starting index of the text to retrieve, or 0 if omitted.
|
|
1506
|
+
* @param end - The ending index of the text to retrieve, or the end of the string if omitted
|
|
1507
|
+
* @returns The requested text content as a string.
|
|
1508
|
+
*/
|
|
1509
|
+
getText(start?: number, end?: number): string;
|
|
1510
|
+
/**
|
|
1511
|
+
* Adds spaces for markers and handles, so that position calculations account for them.
|
|
1512
|
+
*/
|
|
1513
|
+
getTextWithPlaceholders(start?: number, end?: number): string;
|
|
1514
|
+
getTextRangeWithMarkers(start: number, end: number): string;
|
|
1515
|
+
/**
|
|
1516
|
+
* Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided
|
|
1517
|
+
* id in this `SharedString`.
|
|
1518
|
+
*/
|
|
1519
|
+
getMarkerFromId(id: string): ISegment | undefined;
|
|
1520
|
+
/**
|
|
1521
|
+
* Revert an op
|
|
1522
|
+
*/
|
|
1523
|
+
protected rollback(content: any, localOpMetadata: unknown): void;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
/**
|
|
1527
|
+
* @public
|
|
1528
|
+
*/
|
|
1529
|
+
export declare class SharedStringFactory implements IChannelFactory {
|
|
1530
|
+
static Type: string;
|
|
1531
|
+
static readonly Attributes: IChannelAttributes;
|
|
1532
|
+
static segmentFromSpec(spec: any): SharedStringSegment;
|
|
1533
|
+
get type(): string;
|
|
1534
|
+
get attributes(): IChannelAttributes;
|
|
1535
|
+
/**
|
|
1536
|
+
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
1537
|
+
*/
|
|
1538
|
+
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<SharedString>;
|
|
1539
|
+
create(document: IFluidDataStoreRuntime, id: string): SharedString;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
/**
|
|
1543
|
+
* Data for undoing edits on SharedStrings and Intervals.
|
|
1544
|
+
*
|
|
1545
|
+
* @alpha
|
|
1546
|
+
*/
|
|
1547
|
+
export declare type SharedStringRevertible = MergeTreeDeltaRevertible | IntervalRevertible;
|
|
1548
|
+
|
|
1549
|
+
/**
|
|
1550
|
+
* @public
|
|
1551
|
+
*/
|
|
1552
|
+
export declare type SharedStringSegment = TextSegment | Marker;
|
|
1553
|
+
|
|
1554
|
+
/**
|
|
1555
|
+
* Defines a side relative to a character in a sequence.
|
|
1556
|
+
*
|
|
1557
|
+
* @remarks See {@link SequencePlace} for additional context on usage.
|
|
1558
|
+
* @public
|
|
1559
|
+
*/
|
|
1560
|
+
export declare enum Side {
|
|
1561
|
+
Before = 0,
|
|
1562
|
+
After = 1
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
/**
|
|
1566
|
+
* @deprecated SubSequence will be removed in a upcoming release. It has been moved to the fluid-experimental/sequence-deprecated package
|
|
1567
|
+
* @public
|
|
1568
|
+
*/
|
|
1569
|
+
export declare class SubSequence<T> extends BaseSegment {
|
|
1570
|
+
items: Serializable<T>[];
|
|
1571
|
+
static readonly typeString: string;
|
|
1572
|
+
static is(segment: ISegment): segment is SubSequence<any>;
|
|
1573
|
+
static fromJSONObject<U>(spec: Serializable): SubSequence<U> | undefined;
|
|
1574
|
+
readonly type: string;
|
|
1575
|
+
constructor(items: Serializable<T>[]);
|
|
1576
|
+
toJSONObject(): IJSONRunSegment<T>;
|
|
1577
|
+
clone(start?: number, end?: number): SubSequence<T>;
|
|
1578
|
+
canAppend(segment: ISegment): boolean;
|
|
1579
|
+
toString(): string;
|
|
1580
|
+
append(segment: ISegment): void;
|
|
1581
|
+
removeRange(start: number, end: number): boolean;
|
|
1582
|
+
protected createSplitSegmentAt(pos: number): SubSequence<T> | undefined;
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
/* Excluded from this release type: TypedEventEmitter */
|
|
1586
|
+
|
|
1587
|
+
export { }
|