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