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