@fluidframework/merge-tree 2.0.0-dev-rc.3.0.0.254513 → 2.0.0-dev-rc.3.0.0.254674

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.
@@ -1,1921 +0,0 @@
1
- import { AttributionKey } from '@fluidframework/runtime-definitions/internal';
2
- import { IChannelStorageService } from '@fluidframework/datastore-definitions';
3
- import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
4
- import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
5
- import { IFluidHandle } from '@fluidframework/core-interfaces';
6
- import { IFluidSerializer } from '@fluidframework/shared-object-base';
7
- import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
8
- import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
9
- import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
10
- import { TypedEventEmitter } from '@fluid-internal/client-utils';
11
-
12
- /**
13
- * @deprecated This functionality was not intended for public export and will
14
- * be removed in a future release.
15
- * @internal
16
- */
17
- export declare function addProperties(oldProps: PropertySet | undefined, newProps: PropertySet): PropertySet;
18
-
19
- /**
20
- * @alpha
21
- */
22
- export declare function appendToMergeTreeDeltaRevertibles(deltaArgs: IMergeTreeDeltaCallbackArgs, revertibles: MergeTreeDeltaRevertible[]): void;
23
-
24
- /**
25
- * Implements policy dictating which kinds of operations should be attributed and how.
26
- * @sealed
27
- * @alpha
28
- */
29
- export declare interface AttributionPolicy {
30
- /**
31
- * Enables tracking attribution information for operations on this merge-tree.
32
- * This function is expected to subscribe to appropriate change events in order
33
- * to manage any attribution data it stores on segments.
34
- *
35
- * This must be done in an eventually consistent fashion.
36
- */
37
- attach: (client: Client) => void;
38
- /**
39
- * Disables tracking attribution information on segments.
40
- */
41
- detach: () => void;
42
- /***/
43
- isAttached: boolean;
44
- /**
45
- * Serializer capable of serializing any attribution data this policy stores on segments.
46
- */
47
- serializer: IAttributionCollectionSerializer;
48
- }
49
-
50
- /**
51
- * @alpha
52
- */
53
- export declare abstract class BaseSegment extends MergeNode implements ISegment {
54
- clientId: number;
55
- seq: number;
56
- removedSeq?: number;
57
- removedClientIds?: number[];
58
- movedSeq?: number;
59
- movedSeqs?: number[];
60
- movedClientIds?: number[];
61
- wasMovedOnInsert?: boolean | undefined;
62
- readonly segmentGroups: SegmentGroupCollection;
63
- readonly trackingCollection: TrackingGroupCollection;
64
- /***/
65
- attribution?: IAttributionCollection<AttributionKey>;
66
- propertyManager?: PropertiesManager;
67
- properties?: PropertySet;
68
- localRefs?: LocalReferenceCollection;
69
- abstract readonly type: string;
70
- localSeq?: number;
71
- localRemovedSeq?: number;
72
- localMovedSeq?: number;
73
- addProperties(newProps: PropertySet, seq?: number, collaborating?: boolean, rollback?: PropertiesRollback): PropertySet;
74
- hasProperty(key: string): boolean;
75
- isLeaf(): this is ISegment;
76
- protected cloneInto(b: ISegment): void;
77
- canAppend(segment: ISegment): boolean;
78
- protected addSerializedProps(jseg: IJSONSegment): void;
79
- abstract toJSONObject(): any;
80
- /***/
81
- ack(segmentGroup: SegmentGroup, opArgs: IMergeTreeDeltaOpArgs): boolean;
82
- splitAt(pos: number): ISegment | undefined;
83
- private copyPropertiesTo;
84
- abstract clone(): ISegment;
85
- append(other: ISegment): void;
86
- protected abstract createSplitSegmentAt(pos: number): BaseSegment | undefined;
87
- }
88
-
89
- /**
90
- * @deprecated This functionality was not meant to be exported and will be removed in a future release
91
- * @alpha
92
- */
93
- export declare class Client extends TypedEventEmitter<IClientEvents> {
94
- readonly specToSegment: (spec: IJSONSegment) => ISegment;
95
- readonly logger: ITelemetryLoggerExt;
96
- private readonly getMinInFlightRefSeq;
97
- longClientId: string | undefined;
98
- private readonly _mergeTree;
99
- private readonly clientNameToIds;
100
- private readonly shortClientIdMap;
101
- /**
102
- * @param specToSegment - Rehydrates a segment from its JSON representation
103
- * @param logger - Telemetry logger for diagnostics
104
- * @param options - Options for this client. See {@link IMergeTreeOptions} for details.
105
- * @param getMinInFlightRefSeq - Upon applying a message (see {@link Client.applyMsg}), client purges collab-window information which
106
- * is no longer necessary based on that message's minimum sequence number.
107
- * However, if the user of this client has in-flight messages which refer to positions in this Client,
108
- * they may wish to preserve additional merge information.
109
- * The effective minimum sequence number will be the minimum of the message's minimumSequenceNumber and the result of this function.
110
- * If this function returns undefined, the message's minimumSequenceNumber will be used.
111
- *
112
- * @privateRemarks
113
- * - Passing specToSegment would be unnecessary if Client were merged with SharedSegmentSequence
114
- * - AB#6866 tracks a more unified approach to collab window min seq handling.
115
- */
116
- constructor(specToSegment: (spec: IJSONSegment) => ISegment, logger: ITelemetryLoggerExt, options?: IMergeTreeOptions & PropertySet, getMinInFlightRefSeq?: () => number | undefined);
117
- /**
118
- * The merge tree maintains a queue of segment groups for each local operation.
119
- * These segment groups track segments modified by an operation.
120
- * This method peeks the tail of that queue, and returns the segments groups there.
121
- * It is used to get the segment group(s) for the previous operations.
122
- * @param count - The number segment groups to get peek from the tail of the queue. Default 1.
123
- */
124
- peekPendingSegmentGroups(): SegmentGroup | undefined;
125
- peekPendingSegmentGroups(count: number): SegmentGroup | SegmentGroup[] | undefined;
126
- /**
127
- * Annotates the markers with the provided properties
128
- * @param marker - The marker to annotate
129
- * @param props - The properties to annotate the marker with
130
- * @returns The annotate op if valid, otherwise undefined
131
- */
132
- annotateMarker(marker: Marker, props: PropertySet): IMergeTreeAnnotateMsg | undefined;
133
- /**
134
- * Annotates the range with the provided properties
135
- * @param start - The inclusive start position of the range to annotate
136
- * @param end - The exclusive end position of the range to annotate
137
- * @param props - The properties to annotate the range with
138
- * @returns The annotate op if valid, otherwise undefined
139
- */
140
- annotateRangeLocal(start: number, end: number, props: PropertySet): IMergeTreeAnnotateMsg | undefined;
141
- /**
142
- * Removes the range
143
- *
144
- * @param start - The inclusive start of the range to remove
145
- * @param end - The exclusive end of the range to remove
146
- */
147
- removeRangeLocal(start: number, end: number): IMergeTreeRemoveMsg;
148
- /**
149
- * Obliterates the range. This is similar to removing the range, but also
150
- * includes any concurrently inserted content.
151
- *
152
- * @param start - The inclusive start of the range to obliterate
153
- * @param end - The exclusive end of the range to obliterate
154
- */
155
- obliterateRangeLocal(start: number, end: number): IMergeTreeObliterateMsg;
156
- /**
157
- * @param pos - The position to insert the segment at
158
- * @param segment - The segment to insert
159
- */
160
- insertSegmentLocal(pos: number, segment: ISegment): IMergeTreeInsertMsg | undefined;
161
- /**
162
- * @param refPos - The reference position to insert the segment at
163
- * @param segment - The segment to insert
164
- */
165
- insertAtReferencePositionLocal(refPos: ReferencePosition, segment: ISegment): IMergeTreeInsertMsg | undefined;
166
- walkSegments<TClientData>(handler: ISegmentAction<TClientData>, start: number | undefined, end: number | undefined, accum: TClientData, splitRange?: boolean): void;
167
- walkSegments<undefined>(handler: ISegmentAction<undefined>, start?: number, end?: number, accum?: undefined, splitRange?: boolean): void;
168
- protected walkAllSegments<TClientData>(action: (segment: ISegment, accum?: TClientData) => boolean, accum?: TClientData): boolean;
169
- /**
170
- * Serializes the data required for garbage collection. The IFluidHandles stored in all segments that haven't
171
- * been removed represent routes to other objects. We serialize the data in these segments using the passed in
172
- * serializer which keeps track of all serialized handles.
173
- */
174
- serializeGCData(handle: IFluidHandle, handleCollectingSerializer: IFluidSerializer): void;
175
- getCollabWindow(): CollaborationWindow;
176
- /**
177
- * Returns the current position of a segment, and -1 if the segment
178
- * does not exist in this merge tree
179
- * @param segment - The segment to get the position of
180
- */
181
- getPosition(segment: ISegment | undefined, localSeq?: number): number;
182
- /**
183
- * Creates a `LocalReferencePosition` on this client. If the refType does not include ReferenceType.Transient,
184
- * the returned reference will be added to the localRefs on the provided segment.
185
- * @param segment - Segment to add the local reference on
186
- * @param offset - Offset on the segment at which to place the local reference
187
- * @param refType - ReferenceType for the created local reference
188
- * @param properties - PropertySet to place on the created local reference
189
- * @param canSlideToEndpoint - Whether or not the created local reference can
190
- * slide onto one of the special endpoint segments denoting the position
191
- * before the start of or after the end of the tree
192
- */
193
- createLocalReferencePosition(segment: ISegment | "start" | "end", offset: number | undefined, refType: ReferenceType, properties: PropertySet | undefined, slidingPreference?: SlidingPreference, canSlideToEndpoint?: boolean): LocalReferencePosition;
194
- /**
195
- * Removes a `LocalReferencePosition` from this client.
196
- */
197
- removeLocalReferencePosition(lref: LocalReferencePosition): LocalReferencePosition | undefined;
198
- /**
199
- * Resolves a `ReferencePosition` into a character position using this client's perspective.
200
- *
201
- * Reference positions that point to a character that has been removed will
202
- * always return the position of the nearest non-removed character, regardless
203
- * of {@link ReferenceType}. To handle this case specifically, one may wish
204
- * to look at the segment returned by {@link ReferencePosition.getSegment}.
205
- */
206
- localReferencePositionToPosition(lref: ReferencePosition): number;
207
- /**
208
- * Given a position specified relative to a marker id, lookup the marker
209
- * and convert the position to a character position.
210
- * @param relativePos - Id of marker (may be indirect) and whether position is before or after marker.
211
- */
212
- posFromRelativePos(relativePos: IRelativePosition): number;
213
- getMarkerFromId(id: string): ISegment | undefined;
214
- /**
215
- * Revert an op
216
- */
217
- rollback?(op: any, localOpMetadata: unknown): void;
218
- private applyObliterateRangeOp;
219
- /**
220
- * Performs the remove based on the provided op
221
- * @param opArgs - The ops args for the op
222
- */
223
- private applyRemoveRangeOp;
224
- /**
225
- * Performs the annotate based on the provided op
226
- * @param opArgs - The ops args for the op
227
- */
228
- private applyAnnotateRangeOp;
229
- /**
230
- * Performs the insert based on the provided op
231
- * @param opArgs - The ops args for the op
232
- * @returns True if the insert was applied. False if it could not be.
233
- */
234
- private applyInsertOp;
235
- /**
236
- * Returns a valid range for the op, or undefined
237
- * @param op - The op to generate the range for
238
- * @param clientArgs - The client args for the op
239
- */
240
- private getValidOpRange;
241
- /**
242
- * Gets the client args from the op if remote, otherwise uses the local clients info
243
- * @param sequencedMessage - The sequencedMessage to get the client sequence args for
244
- */
245
- private getClientSequenceArgsForMessage;
246
- /**
247
- * Gets the client args from the op if remote, otherwise uses the local clients info
248
- * @param opArgs - The op arg to get the client sequence args for
249
- */
250
- private getClientSequenceArgs;
251
- private ackPendingSegment;
252
- getOrAddShortClientId(longClientId: string): number;
253
- protected getShortClientId(longClientId: string): number;
254
- getLongClientId(shortClientId: number): string;
255
- addLongClientId(longClientId: string): void;
256
- private getOrAddShortClientIdFromMessage;
257
- /**
258
- * During reconnect, we must find the positions to pending segments
259
- * relative to other pending segments. This methods computes that
260
- * position relative to a localSeq. Pending segments above the localSeq
261
- * will be ignored.
262
- *
263
- * @param segment - The segment to find the position for
264
- * @param localSeq - The localSeq to find the position of the segment at
265
- */
266
- findReconnectionPosition(segment: ISegment, localSeq: number): number;
267
- private resetPendingDeltaToOps;
268
- private applyRemoteOp;
269
- applyStashedOp(op: IMergeTreeOp): void;
270
- applyMsg(msg: ISequencedDocumentMessage, local?: boolean): void;
271
- private updateSeqNumbers;
272
- /**
273
- * Resolves a remote client's position against the local sequence
274
- * and returns the remote client's position relative to the local
275
- * sequence
276
- * @param remoteClientPosition - The remote client's position to resolve
277
- * @param remoteClientRefSeq - The reference sequence number of the remote client
278
- * @param remoteClientId - The client id of the remote client
279
- */
280
- resolveRemoteClientPosition(remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: string): number | undefined;
281
- private lastNormalizationRefSeq;
282
- private pendingRebase;
283
- /**
284
- * Given a pending operation and segment group, regenerate the op, so it
285
- * can be resubmitted
286
- * @param resetOp - The op to reset
287
- * @param segmentGroup - The segment group associated with the op
288
- */
289
- regeneratePendingOp(resetOp: IMergeTreeOp, segmentGroup: SegmentGroup | SegmentGroup[]): IMergeTreeOp;
290
- createTextHelper(): IMergeTreeTextHelper;
291
- summarize(runtime: IFluidDataStoreRuntime, handle: IFluidHandle, serializer: IFluidSerializer, catchUpMsgs: ISequencedDocumentMessage[]): ISummaryTreeWithStats;
292
- load(runtime: IFluidDataStoreRuntime, storage: IChannelStorageService, serializer: IFluidSerializer): Promise<{
293
- catchupOpsP: Promise<ISequencedDocumentMessage[]>;
294
- }>;
295
- private getLocalSequenceNumber;
296
- localTransaction(groupOp: IMergeTreeGroupMsg): void;
297
- updateMinSeq(minSeq: number): void;
298
- getContainingSegment<T extends ISegment>(pos: number, sequenceArgs?: Pick<ISequencedDocumentMessage, "referenceSequenceNumber" | "clientId">, localSeq?: number): {
299
- segment: T | undefined;
300
- offset: number | undefined;
301
- };
302
- getPropertiesAtPosition(pos: number): PropertySet | undefined;
303
- getRangeExtentsOfPosition(pos: number): {
304
- posStart: number | undefined;
305
- posAfterEnd: number | undefined;
306
- };
307
- getCurrentSeq(): number;
308
- getClientId(): number;
309
- getLength(): number;
310
- startOrUpdateCollaboration(longClientId: string | undefined, minSeq?: number, currentSeq?: number): void;
311
- /**
312
- * Searches a string for the nearest marker in either direction to a given start position.
313
- * The search will include the start position, so markers at the start position are valid
314
- * results of the search. Makes use of block-accelerated search functions for log(n) complexity.
315
- *
316
- * @param startPos - Position at which to start the search
317
- * @param markerLabel - Label of the marker to search for
318
- * @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`
319
- */
320
- searchForMarker(startPos: number, markerLabel: string, forwards?: boolean): Marker | undefined;
321
- }
322
-
323
- /**
324
- * @deprecated This functionality was not meant to be exported and will be removed in a future release
325
- * @alpha
326
- */
327
- export declare class CollaborationWindow {
328
- clientId: number;
329
- collaborating: boolean;
330
- /**
331
- * Lowest-numbered segment in window; no client can reference a state before this one
332
- */
333
- minSeq: number;
334
- /**
335
- * Highest-numbered segment in window and current reference sequence number for this client.
336
- */
337
- currentSeq: number;
338
- /**
339
- * Highest-numbered localSeq used for a pending segment.
340
- * Semantically, `localSeq`s provide an ordering on in-flight merge-tree operations:
341
- * for operations stamped with localSeqs `a` and `b`, `a < b` if and only if `a` was submitted before `b`.
342
- *
343
- * @remarks - This field is analogous to the `clientSequenceNumber` field on ops, but it's accessible to merge-tree
344
- * at op submission time rather than only at ack time. This enables more natural state tracking for in-flight ops.
345
- *
346
- * It's useful to stamp ops with such an incrementing counter because it enables reasoning about which segments existed from
347
- * the perspective of the local client at a given point in 'un-acked' time, which is necessary to support the reconnect flow.
348
- *
349
- * For example, imagine a client with initial state "123456" submits some ops to create the text "123456ABC".
350
- * If they insert the "C" first, then "B", then "A", their local segment state might look like this:
351
- * ```js
352
- * [
353
- * { seq: 0, text: "1234" },
354
- * { seq: 5, text: "56" },
355
- * { localSeq: 3, seq: UnassignedSequenceNumber, text: "A" },
356
- * { localSeq: 2, seq: UnassignedSequenceNumber, text: "B" },
357
- * { localSeq: 1, seq: UnassignedSequenceNumber, text: "C" },
358
- * ]
359
- * ```
360
- * (note that {@link ISegment.localSeq} tracks the localSeq at which a segment was inserted)
361
- *
362
- * Suppose the client then disconnects and reconnects before any of its insertions are acked. The reconnect flow will necessitate
363
- * that the client regenerates and resubmits ops based on its current segment state as well as the original op that was sent.
364
- *
365
- * It will generate the ops
366
- * 1. \{ pos: 6, text: "C" \}
367
- * 2. \{ pos: 6, text: "B" \}
368
- * 3. \{ pos: 6, text: "A" \}
369
- *
370
- * since when submitting the first op, remote clients don't know that this client is about to submit the "A" and "B".
371
- *
372
- * On the other hand, imagine if the client had originally submitted the ops in the order "A", "B", "C"
373
- * such that the segments' local state was instead:
374
- *
375
- * ```js
376
- * [
377
- * { seq: 0, text: "1234" },
378
- * { seq: 5, text: "56" },
379
- * { localSeq: 1, seq: UnassignedSequenceNumber, text: "A" },
380
- * { localSeq: 2, seq: UnassignedSequenceNumber, text: "B" },
381
- * { localSeq: 3, seq: UnassignedSequenceNumber, text: "C" },
382
- * ]
383
- * ```
384
- *
385
- * The resubmitted ops should instead be:
386
- * 1. \{ pos: 6, text: "A" \}
387
- * 2. \{ pos: 7, text: "B" \}
388
- * 3. \{ pos: 8, text: "C" \}
389
- *
390
- * since remote clients will have seen the "A" when processing the "B" as well as both the "A" and "B" when processing the "C".
391
- * As can be seen, the list of resubmitted ops is different in the two cases despite the merge-tree's segment state only differing
392
- * in `localSeq`.
393
- *
394
- * This example is a bit simplified from the general scenario: since no remote clients modified the merge-tree while the client
395
- * was disconnected, the resubmitted ops end up matching the original ops exactly.
396
- * However, this is not generally true: the production reconnect code takes into account visibility of segments based on both acked
397
- * and local information as appropriate.
398
- * Nonetheless, this simple scenario is enough to understand why it's useful to be able to determine if a segment should be visible
399
- * from a given (seq, localSeq) perspective.
400
- */
401
- localSeq: number;
402
- loadFrom(a: CollaborationWindow): void;
403
- }
404
-
405
- /**
406
- * @internal
407
- */
408
- export declare function compareReferencePositions(a: ReferencePosition, b: ReferencePosition): number;
409
-
410
- /**
411
- * @internal
412
- */
413
- export declare type ConflictAction<TKey, TData> = (key: TKey, currentKey: TKey, data: TData, currentData: TData) => QProperty<TKey, TData>;
414
-
415
- /**
416
- * Creates the op for annotating the range with the provided properties
417
- * @param start - The inclusive start position of the range to annotate
418
- * @param end - The exclusive end position of the range to annotate
419
- * @param props - The properties to annotate the range with
420
- * @returns The annotate op
421
- *
422
- * @internal
423
- */
424
- export declare function createAnnotateRangeOp(start: number, end: number, props: PropertySet): IMergeTreeAnnotateMsg;
425
-
426
- /**
427
- * @internal
428
- */
429
- export declare function createDetachedLocalReferencePosition(refType?: ReferenceType): LocalReferencePosition;
430
-
431
- /**
432
- *
433
- * @param ops - The ops to group
434
- *
435
- * @deprecated The ability to create group ops will be removed in an upcoming
436
- * release, as group ops are redundant with he native batching capabilities of
437
- * the runtime
438
- *
439
- * @deprecated The ability to create group ops will be removed in an upcoming release, as group ops are redundant with he native batching capabilities of the runtime
440
- * @internal
441
- */
442
- export declare function createGroupOp(...ops: IMergeTreeDeltaOp[]): IMergeTreeGroupMsg;
443
-
444
- /**
445
- * @returns An {@link AttributionPolicy} which tracks only insertion of content.
446
- * @internal
447
- */
448
- export declare function createInsertOnlyAttributionPolicy(): AttributionPolicy;
449
-
450
- /**
451
- * @internal
452
- */
453
- export declare function createInsertOp(pos: number, segSpec: any): IMergeTreeInsertMsg;
454
-
455
- /**
456
- *
457
- * @param pos - The position to insert the segment at
458
- * @param segment - The segment to insert
459
- *
460
- * @internal
461
- */
462
- export declare function createInsertSegmentOp(pos: number, segment: ISegment): IMergeTreeInsertMsg;
463
-
464
- /**
465
- * @deprecated This functionality was not intended for public export and will
466
- * be removed in a future release.
467
- * @internal
468
- */
469
- export declare function createMap<T>(): MapLike<T>;
470
-
471
- /**
472
- * Creates the op to obliterate a range
473
- *
474
- * @param start - The inclusive start of the range to obliterate
475
- * @param end - The exclusive end of the range to obliterate
476
- *
477
- * @internal
478
- */
479
- export declare function createObliterateRangeOp(start: number, end: number): IMergeTreeObliterateMsg;
480
-
481
- /**
482
- * Creates an attribution policy which tracks insertion as well as annotation of certain property names.
483
- * This combines the policies creatable using {@link createPropertyTrackingAttributionPolicyFactory} and
484
- * {@link createInsertOnlyAttributionPolicy}: see there for more details.
485
- * @internal
486
- */
487
- export declare function createPropertyTrackingAndInsertionAttributionPolicyFactory(...propNames: string[]): () => AttributionPolicy;
488
-
489
- /**
490
- * @param propNames - List of property names for which attribution should be tracked.
491
- * @returns A policy which only attributes annotation of the properties specified.
492
- * Keys for each property are stored under attribution channels of the same name--see example below.
493
- *
494
- * @example
495
- *
496
- * ```typescript
497
- * // Use this policy when creating your merge-tree:
498
- * const policy = createPropertyTrackingAttributionPolicyFactory("bold", "italic");
499
- * // ... later, you can get attribution keys for the last time the "bold" and "italic"
500
- * // properties were changed on a segment using `getAtOffset`:
501
- * const lastBoldedAttributionKey = segment.attribution?.getAtOffset(0, "bold");
502
- * const lastItalicizedAttributionKey = segment.attribution?.getAtOffset(0, "italic");
503
- * ```
504
- * @internal
505
- */
506
- export declare function createPropertyTrackingAttributionPolicyFactory(...propNames: string[]): () => AttributionPolicy;
507
-
508
- /**
509
- * Creates the op to remove a range
510
- *
511
- * @param start - The inclusive start of the range to remove
512
- * @param end - The exclusive end of the range to remove
513
- *
514
- * @internal
515
- */
516
- export declare function createRemoveRangeOp(start: number, end: number): IMergeTreeRemoveMsg;
517
-
518
- /**
519
- * Get a human-readable string for a given {@link Marker}.
520
- *
521
- * @remarks This function is intended for debugging only. The exact format of
522
- * this string should not be relied upon between versions.
523
- * @internal
524
- */
525
- export declare function debugMarkerToString(marker: Marker): string;
526
-
527
- /**
528
- * @internal
529
- */
530
- export declare const DetachedReferencePosition = -1;
531
-
532
- /**
533
- * @internal
534
- */
535
- export declare interface Dictionary<TKey, TData> {
536
- get(key: TKey): Property<TKey, TData> | undefined;
537
- put(key: TKey, data: TData, conflict?: ConflictAction<TKey, TData>): void;
538
- remove(key: TKey): void;
539
- map<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum): void;
540
- }
541
-
542
- /**
543
- * @alpha
544
- */
545
- export declare function discardMergeTreeDeltaRevertible(revertibles: MergeTreeDeltaRevertible[]): void;
546
-
547
- /**
548
- * Returns the position to slide a reference to if a slide is required.
549
- * @param segoff - The segment and offset to slide from
550
- * @returns segment and offset to slide the reference to
551
- * @internal
552
- */
553
- export declare function getSlideToSegoff(segoff: {
554
- segment: ISegment | undefined;
555
- offset: number | undefined;
556
- }, slidingPreference?: SlidingPreference, useNewSlidingBehavior?: boolean): {
557
- segment: ISegment | undefined;
558
- offset: number | undefined;
559
- };
560
-
561
- /**
562
- * @alpha
563
- */
564
- export declare interface IAttributionCollection<T> {
565
- /**
566
- * Retrieves the attribution key associated with the provided offset.
567
- * @param channel - When specified, gets an attribution key associated with a particular channel.
568
- */
569
- getAtOffset(offset: number, channel?: string): AttributionKey | undefined;
570
- /**
571
- * Total length of all attribution keys in this collection.
572
- */
573
- readonly length: number;
574
- readonly channelNames: Iterable<string>;
575
- /**
576
- * Retrieve all key/offset pairs stored on this segment. Entries should be ordered by offset, such that
577
- * the `i`th result's attribution key applies to offsets in the open range between the `i`th offset and the
578
- * `i+1`th offset.
579
- * The last entry's key applies to the open interval from the last entry's offset to this collection's length.
580
- */
581
- getAll(): IAttributionCollectionSpec<T>;
582
- /***/
583
- splitAt(pos: number): IAttributionCollection<T>;
584
- /***/
585
- append(other: IAttributionCollection<T>): void;
586
- /***/
587
- clone(): IAttributionCollection<T>;
588
- /**
589
- * Updates this collection with new attribution data.
590
- * @param name - Name of the channel that requires an update. Undefined signifies the root channel.
591
- * Updates apply only to the individual channel (i.e. if an attribution policy needs to update the root
592
- * channel and 4 other channels, it should call `.update` 5 times).
593
- * @param channel - Updated collection for that channel.
594
- */
595
- update(name: string | undefined, channel: IAttributionCollection<T>): void;
596
- }
597
-
598
- /**
599
- * @alpha
600
- * @sealed
601
- */
602
- export declare interface IAttributionCollectionSerializer {
603
- /***/
604
- serializeAttributionCollections(segments: Iterable<{
605
- attribution?: IAttributionCollection<AttributionKey>;
606
- cachedLength: number;
607
- }>): SerializedAttributionCollection;
608
- /**
609
- * Populates attribution information on segments using the provided summary.
610
- */
611
- populateAttributionCollections(segments: Iterable<ISegment>, summary: SerializedAttributionCollection): void;
612
- }
613
-
614
- /**
615
- * @alpha
616
- */
617
- export declare interface IAttributionCollectionSpec<T> {
618
- root: Iterable<{
619
- offset: number;
620
- key: T | null;
621
- }>;
622
- channels?: {
623
- [name: string]: Iterable<{
624
- offset: number;
625
- key: T | null;
626
- }>;
627
- };
628
- length: number;
629
- }
630
-
631
- /**
632
- * Emitted before this client's merge-tree normalizes its segments on reconnect, potentially
633
- * ordering them. Useful for DDS-like consumers built atop the merge-tree to compute any information
634
- * they need for rebasing their ops on reconnection.
635
- * @alpha
636
- */
637
- export declare interface IClientEvents {
638
- (event: "normalize", listener: (target: IEventThisPlaceHolder) => void): void;
639
- (event: "delta", listener: (opArgs: IMergeTreeDeltaOpArgs, deltaArgs: IMergeTreeDeltaCallbackArgs, target: IEventThisPlaceHolder) => void): void;
640
- (event: "maintenance", listener: (args: IMergeTreeMaintenanceCallbackArgs, deltaArgs: IMergeTreeDeltaOpArgs | undefined, target: IEventThisPlaceHolder) => void): void;
641
- }
642
-
643
- /**
644
- * @alpha
645
- */
646
- export declare interface IJSONMarkerSegment extends IJSONSegment {
647
- marker: IMarkerDef;
648
- }
649
-
650
- /**
651
- * @alpha
652
- */
653
- export declare interface IJSONSegment {
654
- props?: Record<string, any>;
655
- }
656
-
657
- /**
658
- * @alpha
659
- */
660
- export declare interface IJSONTextSegment extends IJSONSegment {
661
- text: string;
662
- }
663
-
664
- /**
665
- * @alpha
666
- */
667
- export declare interface IMarkerDef {
668
- refType?: ReferenceType;
669
- }
670
-
671
- /**
672
- * Common properties for a node in a merge tree.
673
- * @alpha
674
- */
675
- export declare interface IMergeNodeCommon {
676
- /**
677
- * The index of this node in its parent's list of children.
678
- */
679
- index: number;
680
- /**
681
- * A string that can be used for comparing the location of this node to other `MergeNode`s in the same tree.
682
- * `a.ordinal < b.ordinal` if and only if `a` comes before `b` in a pre-order traversal of the tree.
683
- */
684
- ordinal: string;
685
- isLeaf(): this is ISegment;
686
- }
687
-
688
- /**
689
- * @alpha
690
- */
691
- export declare interface IMergeTreeAnnotateMsg extends IMergeTreeDelta {
692
- type: typeof MergeTreeDeltaType.ANNOTATE;
693
- pos1?: number;
694
- relativePos1?: IRelativePosition;
695
- pos2?: number;
696
- relativePos2?: IRelativePosition;
697
- props: Record<string, any>;
698
- }
699
-
700
- /**
701
- * @alpha
702
- */
703
- export declare interface IMergeTreeAttributionOptions {
704
- /**
705
- * If enabled, segments will store attribution keys which can be used with the runtime to determine
706
- * attribution information (i.e. who created the content and when it was created).
707
- *
708
- * This flag only applied to new documents: if a snapshot is loaded, whether or not attribution keys
709
- * are tracked is determined by the presence of existing attribution keys in the snapshot.
710
- *
711
- * default: false
712
- */
713
- track?: boolean;
714
- /**
715
- * Provides a policy for how to track attribution data on segments.
716
- * This option must be provided if either:
717
- * - `track` is set to true
718
- * - a document containing existing attribution information is loaded
719
- */
720
- policyFactory?: () => AttributionPolicy;
721
- }
722
-
723
- /**
724
- * @internal
725
- */
726
- export declare interface IMergeTreeClientSequenceArgs {
727
- readonly clientId: number;
728
- readonly referenceSequenceNumber: number;
729
- readonly sequenceNumber: number;
730
- }
731
-
732
- /**
733
- * @alpha
734
- */
735
- export declare interface IMergeTreeDelta {
736
- /**
737
- * Type of this change.
738
- */
739
- type: MergeTreeDeltaType;
740
- }
741
-
742
- /**
743
- * @alpha
744
- */
745
- export declare interface IMergeTreeDeltaCallbackArgs<TOperationType extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationType> {
746
- readonly operation: TOperationType;
747
- readonly deltaSegments: IMergeTreeSegmentDelta[];
748
- }
749
-
750
- /**
751
- * @alpha
752
- */
753
- export declare type IMergeTreeDeltaOp = IMergeTreeInsertMsg | IMergeTreeRemoveMsg | IMergeTreeAnnotateMsg | IMergeTreeObliterateMsg;
754
-
755
- /**
756
- * @alpha
757
- */
758
- export declare interface IMergeTreeDeltaOpArgs {
759
- /**
760
- * The group op which contains the operation
761
- * if there operation is part of a group op.
762
- */
763
- readonly groupOp?: IMergeTreeGroupMsg;
764
- /**
765
- * The merge tree operation
766
- */
767
- readonly op: IMergeTreeOp;
768
- /**
769
- * Get the sequence message, should only be null if the
770
- * Delta op args are for an unacked local change
771
- */
772
- readonly sequencedMessage?: ISequencedDocumentMessage;
773
- }
774
-
775
- /**
776
- * @deprecated The ability to create group ops will be removed in an upcoming
777
- * release, as group ops are redundant with the native batching capabilities
778
- * of the runtime
779
- *
780
- * @alpha
781
- */
782
- export declare interface IMergeTreeGroupMsg extends IMergeTreeDelta {
783
- type: typeof MergeTreeDeltaType.GROUP;
784
- ops: IMergeTreeDeltaOp[];
785
- }
786
-
787
- /**
788
- * @alpha
789
- */
790
- export declare interface IMergeTreeInsertMsg extends IMergeTreeDelta {
791
- type: typeof MergeTreeDeltaType.INSERT;
792
- pos1?: number;
793
- relativePos1?: IRelativePosition;
794
- pos2?: number;
795
- relativePos2?: IRelativePosition;
796
- seg?: any;
797
- }
798
-
799
- /**
800
- * @alpha
801
- */
802
- export declare interface IMergeTreeMaintenanceCallbackArgs extends IMergeTreeDeltaCallbackArgs<MergeTreeMaintenanceType> {
803
- }
804
-
805
- /**
806
- * @deprecated We no longer intend to support this functionality and it will
807
- * be removed in a future release. There is no replacement for this
808
- * functionality.
809
- * @alpha
810
- */
811
- export declare interface IMergeTreeObliterateMsg extends IMergeTreeDelta {
812
- type: typeof MergeTreeDeltaType.OBLITERATE;
813
- pos1?: number;
814
- /**
815
- * This field is currently unused, but we keep it around to make the union
816
- * type of all merge-tree messages have the same fields
817
- */
818
- relativePos1?: never;
819
- pos2?: number;
820
- /**
821
- * This field is currently unused, but we keep it around to make the union
822
- * type of all merge-tree messages have the same fields
823
- */
824
- relativePos2?: never;
825
- }
826
-
827
- /**
828
- * @alpha
829
- */
830
- export declare type IMergeTreeOp = IMergeTreeDeltaOp | IMergeTreeGroupMsg;
831
-
832
- /**
833
- * @alpha
834
- */
835
- export declare interface IMergeTreeOptions {
836
- catchUpBlobName?: string;
837
- /**
838
- * Whether or not reference positions can slide to special endpoint segments
839
- * denoting the positions immediately before the start and immediately after
840
- * the end of the string.
841
- *
842
- * This is primarily useful in the case of interval stickiness.
843
- */
844
- mergeTreeReferencesCanSlideToEndpoint?: boolean;
845
- mergeTreeSnapshotChunkSize?: number;
846
- /**
847
- * Whether to use the SnapshotV1 format over SnapshotLegacy.
848
- *
849
- * SnapshotV1 stores a view of the merge-tree at the current sequence number, preserving merge metadata
850
- * (e.g. clientId, seq, etc.) only for segment changes within the collab window.
851
- *
852
- * SnapshotLegacy stores a view of the merge-tree at the minimum sequence number along with the ops between
853
- * the minimum sequence number and the current sequence number.
854
- *
855
- * Both formats merge segments where possible (see {@link ISegment.canAppend})
856
- *
857
- * default: false
858
- *
859
- * @remarks
860
- * Despite the "legacy"/"V1" naming, both formats are actively used at the time of writing. SharedString
861
- * uses legacy and Matrix uses V1.
862
- */
863
- newMergeTreeSnapshotFormat?: boolean;
864
- /**
865
- * Options related to attribution
866
- */
867
- attribution?: IMergeTreeAttributionOptions;
868
- /**
869
- * Enables support for the obliterate operation -- a stronger form of remove
870
- * which deletes concurrently inserted segments
871
- *
872
- * Obliterate is currently experimental and may not work in all scenarios.
873
- *
874
- * Default value: false
875
- */
876
- mergeTreeEnableObliterate?: boolean;
877
- }
878
-
879
- /**
880
- * @alpha
881
- */
882
- export declare interface IMergeTreeRemoveMsg extends IMergeTreeDelta {
883
- type: typeof MergeTreeDeltaType.REMOVE;
884
- pos1?: number;
885
- relativePos1?: IRelativePosition;
886
- pos2?: number;
887
- relativePos2?: IRelativePosition;
888
- }
889
-
890
- /**
891
- * @alpha
892
- */
893
- export declare interface IMergeTreeSegmentDelta {
894
- segment: ISegment;
895
- propertyDeltas?: PropertySet;
896
- }
897
-
898
- /**
899
- * @deprecated This functionality was not meant to be exported and will be removed in a future release
900
- * @alpha
901
- */
902
- export declare interface IMergeTreeTextHelper {
903
- getText(refSeq: number, clientId: number, placeholder: string, start?: number, end?: number): string;
904
- }
905
-
906
- /**
907
- * Tracks information about when and where this segment was moved to.
908
- *
909
- * Note that merge-tree does not currently support moving and only supports
910
- * obliterate. The fields below include "move" in their names to avoid renaming
911
- * in the future, when moves _are_ supported.
912
- * @alpha
913
- */
914
- export declare interface IMoveInfo {
915
- /**
916
- * Local seq at which this segment was moved if the move is yet-to-be
917
- * acked.
918
- */
919
- localMovedSeq?: number;
920
- /**
921
- * The first seq at which this segment was moved.
922
- */
923
- movedSeq: number;
924
- /**
925
- * All seqs at which this segment was moved. In the case of overlapping,
926
- * concurrent moves this array will contain multiple seqs.
927
- *
928
- * The seq at `movedSeqs[i]` corresponds to the client id at `movedClientIds[i]`.
929
- *
930
- * The first element corresponds to the seq of the first move
931
- */
932
- movedSeqs: number[];
933
- /**
934
- * A reference to the inserted destination segment corresponding to this
935
- * segment's move.
936
- *
937
- * If undefined, the move was an obliterate.
938
- *
939
- * Currently this field is unused, as we only support obliterate operations
940
- */
941
- moveDst?: ReferencePosition;
942
- /**
943
- * List of client IDs that have moved this segment.
944
- *
945
- * The client that actually moved the segment (i.e. whose move op was sequenced
946
- * first) is stored as the first client in this list. Other clients in the
947
- * list have all issued concurrent ops to move the segment.
948
- */
949
- movedClientIds: number[];
950
- /**
951
- * If this segment was inserted into a concurrently moved range and
952
- * the move op was sequenced before the insertion op. In this case,
953
- * the segment is visible only to the inserting client
954
- *
955
- * `wasMovedOnInsert` only applies for acked obliterates. That is, if
956
- * a segment inserted by a remote client is moved on insertion by a local
957
- * and unacked obliterate, we do not consider it as having been moved
958
- * on insert
959
- *
960
- * If a segment is moved on insertion, its length is only ever visible to
961
- * the client that inserted the segment. This is relevant in partial length
962
- * calculations
963
- */
964
- wasMovedOnInsert: boolean;
965
- }
966
-
967
- /**
968
- * @internal
969
- */
970
- export declare interface IRBAugmentation<TKey, TData> {
971
- update(node: RBNode<TKey, TData>): void;
972
- }
973
-
974
- /**
975
- * @internal
976
- */
977
- export declare interface IRBMatcher<TKey, TData> {
978
- continueSubtree(node: RBNode<TKey, TData> | undefined, key: TKey): boolean;
979
- matchNode(node: RBNode<TKey, TData> | undefined, key: TKey): boolean;
980
- }
981
-
982
- /**
983
- * A position specified relative to a segment.
984
- * @alpha
985
- */
986
- export declare interface IRelativePosition {
987
- /**
988
- * String identifier specifying a segment.
989
- */
990
- id?: string;
991
- /**
992
- * If true, insert before the specified segment. If false or not defined,
993
- * insert after the specified segment.
994
- */
995
- before?: boolean;
996
- /**
997
- * A positive number \>= 1. If before is false, offset is added to the position.
998
- * If before is true, offset is subtracted from the position.
999
- */
1000
- offset?: number;
1001
- }
1002
-
1003
- /**
1004
- * Contains removal information associated to an {@link ISegment}.
1005
- * @alpha
1006
- */
1007
- export declare interface IRemovalInfo {
1008
- /**
1009
- * Local seq at which this segment was removed, if the removal is yet-to-be acked.
1010
- */
1011
- localRemovedSeq?: number;
1012
- /**
1013
- * Seq at which this segment was removed.
1014
- */
1015
- removedSeq: number;
1016
- /**
1017
- * List of client IDs that have removed this segment.
1018
- * The client that actually removed the segment (i.e. whose removal op was sequenced first) is stored as the first
1019
- * client in this list. Other clients in the list have all issued concurrent ops to remove the segment.
1020
- * @remarks When this list has length \> 1, this is referred to as the "overlapping remove" case.
1021
- */
1022
- removedClientIds: number[];
1023
- }
1024
-
1025
- /**
1026
- * A segment representing a portion of the merge tree.
1027
- * Segments are leaf nodes of the merge tree and contain data.
1028
- * @alpha
1029
- */
1030
- export declare interface ISegment extends IMergeNodeCommon, Partial<IRemovalInfo>, Partial<IMoveInfo> {
1031
- readonly type: string;
1032
- readonly segmentGroups: SegmentGroupCollection;
1033
- readonly trackingCollection: TrackingGroupCollection;
1034
- /**
1035
- * Whether or not this segment is a special segment denoting the start or
1036
- * end of the tree
1037
- *
1038
- * Endpoint segments are imaginary segments positioned immediately before or
1039
- * after the tree. These segments cannot be referenced by regular operations
1040
- * and exist primarily as a bucket for local references to slide onto during
1041
- * deletion of regular segments.
1042
- */
1043
- readonly endpointType?: "start" | "end";
1044
- /**
1045
- * The length of the contents of the node.
1046
- */
1047
- cachedLength: number;
1048
- /**
1049
- * Stores attribution keys associated with offsets of this segment.
1050
- * This data is only persisted if MergeTree's `attributions.track` flag is set to true.
1051
- * Pending segments (i.e. ones that only exist locally and haven't been acked by the server) also have
1052
- * `attribution === undefined` until ack.
1053
- *
1054
- * Keys can be used opaquely with an IAttributor or a container runtime that provides attribution.
1055
- * @remarks There are plans to make the shape of the data stored extensible in a couple ways:
1056
- *
1057
- * 1. Injection of custom attribution information associated with the segment (ex: copy-paste of
1058
- * content but keeping the old attribution information).
1059
- *
1060
- * 2. Storage of multiple "channels" of information (ex: track property changes separately from insertion,
1061
- * or only attribute certain property modifications, etc.)
1062
- */
1063
- attribution?: IAttributionCollection<AttributionKey>;
1064
- /**
1065
- * Manages pending local state for properties on this segment.
1066
- */
1067
- propertyManager?: PropertiesManager;
1068
- /**
1069
- * Local seq at which this segment was inserted.
1070
- * This is defined if and only if the insertion of the segment is pending ack, i.e. `seq` is UnassignedSequenceNumber.
1071
- * Once the segment is acked, this field is cleared.
1072
- *
1073
- * See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.
1074
- */
1075
- localSeq?: number;
1076
- /**
1077
- * Local seq at which this segment was removed. If this is defined, `removedSeq` will initially be set to
1078
- * UnassignedSequenceNumber. However, if another client concurrently removes the same segment, `removedSeq`
1079
- * will be updated to the seq at which that client removed this segment.
1080
- *
1081
- * Like {@link ISegment.localSeq}, this field is cleared once the local removal of the segment is acked.
1082
- * See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.
1083
- */
1084
- localRemovedSeq?: number;
1085
- /**
1086
- * Seq at which this segment was inserted.
1087
- * If undefined, it is assumed the segment was inserted prior to the collab window's minimum sequence number.
1088
- */
1089
- seq?: number;
1090
- /**
1091
- * Short clientId for the client that inserted this segment.
1092
- */
1093
- clientId: number;
1094
- /**
1095
- * Local references added to this segment.
1096
- */
1097
- localRefs?: LocalReferenceCollection;
1098
- /**
1099
- * Properties that have been added to this segment via annotation.
1100
- */
1101
- properties?: PropertySet;
1102
- /**
1103
- * Add properties to this segment via annotation.
1104
- *
1105
- * @remarks This function should not be called directly. Properties should
1106
- * be added through the `annotateRange` functions.
1107
- */
1108
- addProperties(newProps: PropertySet, seq?: number, collaborating?: boolean, rollback?: PropertiesRollback): PropertySet;
1109
- clone(): ISegment;
1110
- canAppend(segment: ISegment): boolean;
1111
- append(segment: ISegment): void;
1112
- splitAt(pos: number): ISegment | undefined;
1113
- toJSONObject(): any;
1114
- /**
1115
- * Acks the current segment against the segment group, op, and merge tree.
1116
- *
1117
- * @param segmentGroup - Pending segment group associated with this op.
1118
- * @param opArgs - Information about the op that was acked
1119
- * @returns `true` if the op modifies the segment, otherwise `false`.
1120
- * The only current false case is overlapping remove, where a segment is removed
1121
- * by a previously sequenced operation before the current operation is acked.
1122
- * @throws - error if the segment state doesn't match segment group or op.
1123
- * E.g. if the segment group is not first in the pending queue, or
1124
- * an inserted segment does not have unassigned sequence number.
1125
- */
1126
- ack(segmentGroup: SegmentGroup, opArgs: IMergeTreeDeltaOpArgs): boolean;
1127
- }
1128
-
1129
- /**
1130
- * @alpha
1131
- */
1132
- export declare interface ISegmentAction<TClientData> {
1133
- (segment: ISegment, pos: number, refSeq: number, clientId: number, start: number, end: number, accum: TClientData): boolean;
1134
- }
1135
-
1136
- /**
1137
- * Tests whether x is a MergeTreeDeltaRevertible
1138
- * @internal
1139
- */
1140
- export declare function isMergeTreeDeltaRevertible(x: unknown): x is MergeTreeDeltaRevertible;
1141
-
1142
- /**
1143
- * @alpha
1144
- */
1145
- export declare interface ITrackingGroup {
1146
- tracked: readonly Trackable[];
1147
- size: number;
1148
- has(trackable: Trackable): boolean;
1149
- link(trackable: Trackable): void;
1150
- unlink(trackable: Trackable): boolean;
1151
- }
1152
-
1153
- /**
1154
- * @internal
1155
- */
1156
- export declare interface KeyComparer<TKey> {
1157
- (a: TKey, b: TKey): number;
1158
- }
1159
-
1160
- /**
1161
- * Represents a collection of {@link LocalReferencePosition}s associated with
1162
- * one segment in a merge-tree.
1163
- * Represents a collection of {@link LocalReferencePosition}s associated with one segment in a merge-tree.
1164
- * @sealed
1165
- *
1166
- * @alpha
1167
- */
1168
- export declare class LocalReferenceCollection {
1169
- /** Segment this `LocalReferenceCollection` is associated to. */
1170
- private readonly segment;
1171
- static append(seg1: ISegment, seg2: ISegment): void;
1172
- static setOrGet(segment: ISegment): LocalReferenceCollection;
1173
- private readonly refsByOffset;
1174
- private refCount;
1175
- /***/
1176
- private constructor();
1177
- /**
1178
- * @remarks This method should only be called by mergeTree.
1179
- */
1180
- [Symbol.iterator](): {
1181
- next(): IteratorResult<LocalReferencePosition>;
1182
- [Symbol.iterator](): any;
1183
- };
1184
- /**
1185
- * @remarks This method should only be called by mergeTree.
1186
- */
1187
- get empty(): boolean;
1188
- /**
1189
- * @remarks This method should only be called by mergeTree.
1190
- */
1191
- createLocalRef(offset: number, refType: ReferenceType, properties: PropertySet | undefined, slidingPreference?: SlidingPreference, canSlideToEndpoint?: boolean): LocalReferencePosition;
1192
- /**
1193
- * @remarks This method should only be called by mergeTree.
1194
- */
1195
- addLocalRef(lref: LocalReferencePosition, offset: number): void;
1196
- /**
1197
- * @remarks This method should only be called by mergeTree.
1198
- */
1199
- removeLocalRef(lref: LocalReferencePosition): LocalReferencePosition | undefined;
1200
- /**
1201
- *
1202
- * Called by 'append()' implementations to append local refs from the given 'other' segment to the
1203
- * end of 'this' segment.
1204
- *
1205
- * Note: This method should be invoked after the caller has ensured that segments can be merged,
1206
- * but before 'this' segment's cachedLength has changed, or the adjustment to the local refs
1207
- * will be incorrect.
1208
- *
1209
- * @remarks This method should only be called by mergeTree.
1210
- */
1211
- append(other: LocalReferenceCollection): void;
1212
- /**
1213
- * Returns true of the local reference is in the collection, otherwise false.
1214
- *
1215
- * @remarks This method should only be called by mergeTree.
1216
- */
1217
- has(lref: ReferencePosition): boolean;
1218
- /**
1219
- * Splits this `LocalReferenceCollection` into the intervals [0, offset) and [offset, originalLength).
1220
- * Local references in the former half of this split will remain associated with the segment used on construction.
1221
- * Local references in the latter half of this split will be transferred to `splitSeg`,
1222
- * and its `localRefs` field will be set.
1223
- * @param offset - Offset into the original segment at which the collection should be split
1224
- * @param splitSeg - Split segment which originally corresponded to the indices [offset, originalLength)
1225
- * before splitting.
1226
- *
1227
- * @remarks This method should only be called by mergeTree.
1228
- */
1229
- split(offset: number, splitSeg: ISegment): void;
1230
- /**
1231
- * @remarks This method should only be called by mergeTree.
1232
- */
1233
- addBeforeTombstones(...refs: Iterable<LocalReferencePosition>[]): void;
1234
- /**
1235
- * @remarks This method should only be called by mergeTree.
1236
- */
1237
- addAfterTombstones(...refs: Iterable<LocalReferencePosition>[]): void;
1238
- /**
1239
- * @remarks This method should only be called by mergeTree.
1240
- */
1241
- isAfterTombstone(lref: LocalReferencePosition): boolean;
1242
- /**
1243
- * @remarks This method should only be called by mergeTree.
1244
- */
1245
- walkReferences(visitor: (lref: LocalReferencePosition) => boolean | void | undefined, start?: LocalReferencePosition, forward?: boolean): boolean;
1246
- }
1247
-
1248
- /**
1249
- * @sealed
1250
- * @alpha
1251
- */
1252
- export declare interface LocalReferencePosition extends ReferencePosition {
1253
- callbacks?: Partial<Record<"beforeSlide" | "afterSlide", (ref: LocalReferencePosition) => void>>;
1254
- readonly trackingCollection: TrackingGroupCollection;
1255
- /**
1256
- * Whether or not this reference position can slide onto one of the two
1257
- * special segments representing the position before or after the tree
1258
- */
1259
- readonly canSlideToEndpoint?: boolean;
1260
- }
1261
-
1262
- /**
1263
- * Any mapping from a string to values of type `T`
1264
- * @alpha
1265
- */
1266
- export declare interface MapLike<T> {
1267
- [index: string]: T;
1268
- }
1269
-
1270
- /**
1271
- * Markers are a special kind of segment that do not hold any content.
1272
- *
1273
- * Markers with a reference type of {@link ReferenceType.Tile} support spatially
1274
- * accelerated queries for finding the next marker to the left or right of it in
1275
- * sub-linear time. This is useful, for example, in the case of jumping from the
1276
- * start of a paragraph to the end, assuming a paragraph is bound by markers at
1277
- * the start and end.
1278
- *
1279
- * @alpha
1280
- */
1281
- export declare class Marker extends BaseSegment implements ReferencePosition, ISegment {
1282
- refType: ReferenceType;
1283
- static readonly type = "Marker";
1284
- static is(segment: ISegment): segment is Marker;
1285
- readonly type = "Marker";
1286
- static make(refType: ReferenceType, props?: PropertySet): Marker;
1287
- constructor(refType: ReferenceType);
1288
- toJSONObject(): IJSONMarkerSegment;
1289
- static fromJSONObject(spec: any): Marker | undefined;
1290
- clone(): Marker;
1291
- getSegment(): this;
1292
- getOffset(): number;
1293
- getProperties(): PropertySet | undefined;
1294
- getId(): string | undefined;
1295
- toString(): string;
1296
- protected createSplitSegmentAt(pos: number): undefined;
1297
- canAppend(segment: ISegment): boolean;
1298
- append(): void;
1299
- }
1300
-
1301
- /**
1302
- * @internal
1303
- */
1304
- export declare function matchProperties(a: PropertySet | undefined, b: PropertySet | undefined): boolean;
1305
-
1306
- /**
1307
- * @internal
1308
- */
1309
- export declare function maxReferencePosition<T extends ReferencePosition>(a: T, b: T): T;
1310
-
1311
- /**
1312
- * @alpha
1313
- */
1314
- export declare class MergeNode implements IMergeNodeCommon {
1315
- index: number;
1316
- ordinal: string;
1317
- cachedLength: number;
1318
- isLeaf(): this is ISegment;
1319
- }
1320
-
1321
- /**
1322
- * @alpha
1323
- */
1324
- export declare type MergeTreeDeltaOperationType = typeof MergeTreeDeltaType.ANNOTATE | typeof MergeTreeDeltaType.INSERT | typeof MergeTreeDeltaType.REMOVE | typeof MergeTreeDeltaType.OBLITERATE;
1325
-
1326
- /**
1327
- * @alpha
1328
- */
1329
- export declare type MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationType | MergeTreeMaintenanceType;
1330
-
1331
- /**
1332
- * @alpha
1333
- */
1334
- export declare type MergeTreeDeltaRevertible = {
1335
- operation: typeof MergeTreeDeltaType.INSERT;
1336
- trackingGroup: ITrackingGroup;
1337
- } | {
1338
- operation: typeof MergeTreeDeltaType.REMOVE;
1339
- trackingGroup: ITrackingGroup;
1340
- } | {
1341
- operation: typeof MergeTreeDeltaType.ANNOTATE;
1342
- trackingGroup: ITrackingGroup;
1343
- propertyDeltas: PropertySet;
1344
- };
1345
-
1346
- /**
1347
- * @alpha
1348
- */
1349
- export declare const MergeTreeDeltaType: {
1350
- readonly INSERT: 0;
1351
- readonly REMOVE: 1;
1352
- readonly ANNOTATE: 2;
1353
- /**
1354
- * @deprecated The ability to create group ops will be removed in an upcoming release, as group ops are redundant with he native batching capabilities of the runtime
1355
- */
1356
- readonly GROUP: 3;
1357
- readonly OBLITERATE: 4;
1358
- };
1359
-
1360
- /**
1361
- * @alpha
1362
- */
1363
- export declare type MergeTreeDeltaType = (typeof MergeTreeDeltaType)[keyof typeof MergeTreeDeltaType];
1364
-
1365
- /**
1366
- * Enum-like constant defining the types of "maintenance" events on a merge tree.
1367
- * Maintenance events correspond to structural segment changes or acks of pending segments.
1368
- *
1369
- * Note: these values are assigned negative integers to avoid clashing with `MergeTreeDeltaType`.
1370
- * @alpha
1371
- */
1372
- export declare const MergeTreeMaintenanceType: {
1373
- /**
1374
- * Notification that a segment "append" has occurred, i.e. two adjacent segments have been merged.
1375
- * BEWARE: `deltaSegments` on the corresponding event will contain both the merged segment and the latter
1376
- * segment, pre-merge.
1377
- * For example, if the merge tree originally had two adjacent segments [A][B] and called A.append(B) to get
1378
- * segment [AB], `deltaSegments` would contain [AB] and [B].
1379
- */
1380
- readonly APPEND: -1;
1381
- /**
1382
- * Notification that a segment has been split in two.
1383
- * `deltaSegments` on the corresponding event will contain the resulting two segments.
1384
- */
1385
- readonly SPLIT: -2;
1386
- /**
1387
- * Notification that a segment has been unlinked (i.e. removed) from the MergeTree.
1388
- * This occurs on leaf segments during Zamboni when the segment's tracking collection is empty
1389
- * (e.g., not being tracked for undo/redo).
1390
- * It also occurs on internal merge tree segments when re-packing children to maintain tree balancing invariants.
1391
- */
1392
- readonly UNLINK: -3;
1393
- /**
1394
- * Notification that a local change has been acknowledged by the server.
1395
- * This means that it has made the round trip to the server and has had a sequence number assigned.
1396
- */
1397
- readonly ACKNOWLEDGED: -4;
1398
- };
1399
-
1400
- /**
1401
- * @alpha
1402
- */
1403
- export declare type MergeTreeMaintenanceType = (typeof MergeTreeMaintenanceType)[keyof typeof MergeTreeMaintenanceType];
1404
-
1405
- /**
1406
- * @alpha
1407
- */
1408
- export declare interface MergeTreeRevertibleDriver {
1409
- insertFromSpec(pos: number, spec: IJSONSegment): void;
1410
- removeRange(start: number, end: number): void;
1411
- annotateRange(start: number, end: number, props: PropertySet): void;
1412
- }
1413
-
1414
- /**
1415
- * @internal
1416
- */
1417
- export declare function minReferencePosition<T extends ReferencePosition>(a: T, b: T): T;
1418
-
1419
- /**
1420
- * @alpha
1421
- */
1422
- export declare class PropertiesManager {
1423
- private pendingKeyUpdateCount;
1424
- ackPendingProperties(annotateOp: IMergeTreeAnnotateMsg): void;
1425
- private decrementPendingCounts;
1426
- addProperties(oldProps: PropertySet, newProps: PropertySet, seq?: number, collaborating?: boolean, rollback?: PropertiesRollback): PropertySet;
1427
- copyTo(oldProps: PropertySet, newProps: PropertySet | undefined, newManager: PropertiesManager): PropertySet | undefined;
1428
- hasPendingProperties(): boolean;
1429
- hasPendingProperty(key: string): boolean;
1430
- }
1431
-
1432
- /**
1433
- * @alpha
1434
- */
1435
- export declare enum PropertiesRollback {
1436
- /** Not in a rollback */
1437
- None = 0,
1438
- /** Rollback */
1439
- Rollback = 1
1440
- }
1441
-
1442
- /**
1443
- * @internal
1444
- */
1445
- export declare interface Property<TKey, TData> {
1446
- key: TKey;
1447
- data: TData;
1448
- }
1449
-
1450
- /**
1451
- * @internal
1452
- */
1453
- export declare interface PropertyAction<TKey, TData> {
1454
- <TAccum>(p: Property<TKey, TData>, accum?: TAccum): boolean;
1455
- }
1456
-
1457
- /**
1458
- * A loosely-typed mapping from strings to any value.
1459
- *
1460
- * @remarks Property sets are expected to be JSON-stringify-able.
1461
- *
1462
- * @privateRemarks PropertySet is typed using `any` because when you include
1463
- * custom methods such as toJSON(), JSON.stringify accepts most types other than
1464
- * functions
1465
- * @alpha
1466
- */
1467
- export declare type PropertySet = MapLike<any>;
1468
-
1469
- /**
1470
- * @internal
1471
- */
1472
- export declare interface QProperty<TKey, TData> {
1473
- key?: TKey;
1474
- data?: TData;
1475
- }
1476
-
1477
- /**
1478
- * @internal
1479
- */
1480
- export declare const RBColor: {
1481
- readonly RED: 0;
1482
- readonly BLACK: 1;
1483
- };
1484
-
1485
- /**
1486
- * @internal
1487
- */
1488
- export declare type RBColor = (typeof RBColor)[keyof typeof RBColor];
1489
-
1490
- /**
1491
- * @internal
1492
- */
1493
- export declare interface RBNode<TKey, TData> {
1494
- key: TKey;
1495
- data: TData;
1496
- left: RBNode<TKey, TData> | undefined;
1497
- right: RBNode<TKey, TData> | undefined;
1498
- color: RBColor;
1499
- size: number;
1500
- }
1501
-
1502
- /**
1503
- * @internal
1504
- */
1505
- export declare interface RBNodeActions<TKey, TData> {
1506
- infix?(node: RBNode<TKey, TData>): boolean;
1507
- pre?(node: RBNode<TKey, TData>): boolean;
1508
- post?(node: RBNode<TKey, TData>): boolean;
1509
- showStructure?: boolean;
1510
- }
1511
-
1512
- /**
1513
- * @internal
1514
- */
1515
- export declare class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData> {
1516
- private readonly compareKeys;
1517
- private readonly aug?;
1518
- private root;
1519
- constructor(compareKeys: KeyComparer<TKey>, aug?: IRBAugmentation<TKey, TData> | undefined);
1520
- private makeNode;
1521
- private isRed;
1522
- private nodeSize;
1523
- size(): number;
1524
- isEmpty(): boolean;
1525
- get(key: TKey): RBNode<TKey, TData> | undefined;
1526
- private nodeGet;
1527
- private contains;
1528
- gather(key: TKey, matcher: IRBMatcher<TKey, TData>): RBNode<TKey, TData>[];
1529
- private nodeGather;
1530
- walkExactMatchesForward(compareFn: (node: RBNode<TKey, TData>) => number, actionFn: (node: RBNode<TKey, TData>) => void, continueLeftFn: (number: number) => boolean, continueRightFn: (number: number) => boolean): void;
1531
- private nodeWalkExactMatchesForward;
1532
- walkExactMatchesBackward(compareFn: (node: RBNode<TKey, TData>) => number, actionFn: (node: RBNode<TKey, TData>) => void, continueLeftFn: (number: number) => boolean, continueRightFn: (number: number) => boolean): void;
1533
- private nodeWalkExactMatchesBackward;
1534
- put(key: TKey, data: TData, conflict?: ConflictAction<TKey, TData>): void;
1535
- private nodePut;
1536
- private updateLocal;
1537
- private nodeRemoveMin;
1538
- remove(key: TKey): void;
1539
- removeExisting(key: TKey): void;
1540
- private nodeRemove;
1541
- /**
1542
- * @returns The largest node in this tree which compares less than or equal to `key`
1543
- */
1544
- floor(key: TKey): RBNode<TKey, TData> | undefined;
1545
- private nodeFloor;
1546
- /**
1547
- * @returns The smallest node in this tree which compares greater than or equal to `key`
1548
- */
1549
- ceil(key: TKey): RBNode<TKey, TData> | undefined;
1550
- private nodeCeil;
1551
- min(): RBNode<TKey, TData> | undefined;
1552
- private nodeMin;
1553
- max(): RBNode<TKey, TData> | undefined;
1554
- private nodeMax;
1555
- private rotateRight;
1556
- private rotateLeft;
1557
- private oppositeColor;
1558
- private flipColors;
1559
- private moveRedLeft;
1560
- private moveRedRight;
1561
- private balance;
1562
- mapRange<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum, start?: TKey, end?: TKey): void;
1563
- map<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum): void;
1564
- keys(): TKey[];
1565
- /**
1566
- * Depth-first traversal with custom action; if action returns
1567
- * false, traversal is halted.
1568
- * @param action - action to apply to each node
1569
- */
1570
- walk(actions: RBNodeActions<TKey, TData>): void;
1571
- walkBackward(actions: RBNodeActions<TKey, TData>): void;
1572
- private nodeWalk;
1573
- private nodeWalkBackward;
1574
- private nodeMap;
1575
- }
1576
-
1577
- /**
1578
- * Represents a reference to a place within a merge tree. This place conceptually remains stable over time
1579
- * by referring to a particular segment and offset within that segment.
1580
- * Thus, this reference's character position changes as the tree is edited.
1581
- * @alpha
1582
- */
1583
- export declare interface ReferencePosition {
1584
- /**
1585
- * Properties associated with this reference
1586
- */
1587
- properties?: PropertySet;
1588
- /**
1589
- * The direction for this reference position to slide when the segment it
1590
- * points to is removed. See {@link (SlidingPreference:type)} for additional context.
1591
- *
1592
- * Defaults to SlidingPreference.Forward
1593
- */
1594
- slidingPreference?: SlidingPreference;
1595
- refType: ReferenceType;
1596
- /**
1597
- * Gets the segment that this reference position is semantically associated with. Returns undefined iff the
1598
- * reference became detached from the string.
1599
- */
1600
- getSegment(): ISegment | undefined;
1601
- /**
1602
- * Gets the offset for this reference position within its associated segment.
1603
- *
1604
- * @example
1605
- *
1606
- * If a merge-tree has 3 leaf segments ["hello", " ", "world"] and a ReferencePosition refers to the "l"
1607
- * in "world", that reference's offset would be 3 as "l" is the character at index 3 within "world".
1608
- */
1609
- getOffset(): number;
1610
- /**
1611
- * @param newProps - Properties to add to this reference.
1612
- * @remarks Note that merge-tree does not broadcast changes to other clients. It is up to the consumer
1613
- * to ensure broadcast happens if that is desired.
1614
- */
1615
- addProperties(newProps: PropertySet): void;
1616
- isLeaf(): this is ISegment;
1617
- }
1618
-
1619
- /**
1620
- * Flags enum that dictates behavior of a {@link ReferencePosition}
1621
- * @alpha
1622
- */
1623
- export declare enum ReferenceType {
1624
- Simple = 0,
1625
- /**
1626
- * Allows this reference to be located using the `searchForMarker` API on merge-tree.
1627
- */
1628
- Tile = 1,
1629
- /**
1630
- * Denotes that this reference begins the start of an interval. This is
1631
- * generally not meaningful outside the context of interval collections
1632
- * on SharedString.
1633
- */
1634
- RangeBegin = 16,
1635
- /**
1636
- * Denotes that this reference is the end of an interval. This is
1637
- * generally not meaningful outside the context of interval collections
1638
- * on SharedString.
1639
- */
1640
- RangeEnd = 32,
1641
- /**
1642
- * When a segment is marked removed (locally or with ack), this reference will slide to the first
1643
- * valid option of:
1644
- * 1. the start of the next furthest segment
1645
- * 2. the end of the next nearest segment
1646
- * 3. DetachedReferencePosition
1647
- */
1648
- SlideOnRemove = 64,
1649
- /**
1650
- * When a segment is marked removed (locally or with ack), this reference will remain on that segment.
1651
- */
1652
- StayOnRemove = 128,
1653
- /**
1654
- * Specifies that the reference position should never be added to the segment it refers to.
1655
- * This is useful for comparison/iteration purposes
1656
- */
1657
- Transient = 256
1658
- }
1659
-
1660
- /**
1661
- * @internal
1662
- */
1663
- export declare const refGetTileLabels: (refPos: ReferencePosition) => string[] | undefined;
1664
-
1665
- /**
1666
- * @internal
1667
- */
1668
- export declare function refHasTileLabel(refPos: ReferencePosition, label: string): boolean;
1669
-
1670
- /**
1671
- * @internal
1672
- */
1673
- export declare function refHasTileLabels(refPos: ReferencePosition): boolean;
1674
-
1675
- /**
1676
- * @internal
1677
- */
1678
- export declare function refTypeIncludesFlag(refPosOrType: ReferencePosition | ReferenceType, flags: ReferenceType): boolean;
1679
-
1680
- /**
1681
- * The special-cased property key that tracks the id of a {@link Marker}.
1682
- *
1683
- * @remarks In general, marker ids should be accessed using the inherent method
1684
- * {@link Marker.getId}. Marker ids should not be updated after creation.
1685
- * @internal
1686
- */
1687
- export declare const reservedMarkerIdKey = "markerId";
1688
-
1689
- /**
1690
- * @internal
1691
- */
1692
- export declare const reservedMarkerSimpleTypeKey = "markerSimpleType";
1693
-
1694
- /**
1695
- * @internal
1696
- */
1697
- export declare const reservedRangeLabelsKey = "referenceRangeLabels";
1698
-
1699
- /**
1700
- * @internal
1701
- */
1702
- export declare const reservedTileLabelsKey = "referenceTileLabels";
1703
-
1704
- /**
1705
- * @alpha
1706
- */
1707
- export declare function revertMergeTreeDeltaRevertibles(driver: MergeTreeRevertibleDriver, revertibles: MergeTreeDeltaRevertible[]): void;
1708
-
1709
- /**
1710
- * @deprecated This functionality was not meant to be exported and will be removed in a future release
1711
- * @alpha
1712
- */
1713
- export declare interface SegmentGroup {
1714
- segments: ISegment[];
1715
- previousProps?: PropertySet[];
1716
- localSeq?: number;
1717
- refSeq: number;
1718
- }
1719
-
1720
- /**
1721
- * @alpha
1722
- */
1723
- export declare class SegmentGroupCollection {
1724
- private readonly segment;
1725
- private readonly segmentGroups;
1726
- constructor(segment: ISegment);
1727
- get size(): number;
1728
- get empty(): boolean;
1729
- enqueue(segmentGroup: SegmentGroup): void;
1730
- dequeue(): SegmentGroup | undefined;
1731
- remove?(segmentGroup: SegmentGroup): boolean;
1732
- pop?(): SegmentGroup | undefined;
1733
- copyTo(segment: ISegment): void;
1734
- private enqueueOnCopy;
1735
- }
1736
-
1737
- /**
1738
- * @alpha
1739
- */
1740
- export declare interface SequenceOffsets {
1741
- /**
1742
- * Parallel array with posBreakpoints which tracks the seq of insertion.
1743
- *
1744
- * @example
1745
- *
1746
- * If seqs is [45, 46] and posBreakpoints is [0, 3], the section of the string
1747
- * between offsets 0 and 3 was inserted at seq 45 and the section of the string between
1748
- * 3 and the length of the string was inserted at seq 46.
1749
- *
1750
- * @remarks We use null here rather than undefined as round-tripping through JSON converts
1751
- * undefineds to null anyway
1752
- */
1753
- seqs: (number | AttributionKey | null)[];
1754
- posBreakpoints: number[];
1755
- }
1756
-
1757
- /**
1758
- * @alpha
1759
- */
1760
- export declare interface SerializedAttributionCollection extends SequenceOffsets {
1761
- channels?: {
1762
- [name: string]: SequenceOffsets;
1763
- };
1764
- length: number;
1765
- }
1766
-
1767
- /**
1768
- * Dictates the preferential direction for a {@link ReferencePosition} to slide
1769
- * in a merge-tree
1770
- * @alpha
1771
- */
1772
- export declare const SlidingPreference: {
1773
- /**
1774
- * Prefer sliding towards the start of the tree
1775
- */
1776
- readonly BACKWARD: 0;
1777
- /**
1778
- * Prefer sliding towards the end of the tree
1779
- */
1780
- readonly FORWARD: 1;
1781
- };
1782
-
1783
- /**
1784
- * Dictates the preferential direction for a {@link ReferencePosition} to slide
1785
- * in a merge-tree
1786
- * @alpha
1787
- */
1788
- export declare type SlidingPreference = (typeof SlidingPreference)[keyof typeof SlidingPreference];
1789
-
1790
- /**
1791
- * @internal
1792
- */
1793
- export declare interface SortedDictionary<TKey, TData> extends Dictionary<TKey, TData> {
1794
- max(): Property<TKey, TData> | undefined;
1795
- min(): Property<TKey, TData> | undefined;
1796
- mapRange<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum, start?: TKey, end?: TKey): void;
1797
- }
1798
-
1799
- /**
1800
- * Stores a unique and sorted set of segments, or objects with segments
1801
- *
1802
- * This differs from a normal sorted set in that the keys are not fixed.
1803
- * The segments are sorted via their ordinals which can change as the merge tree is modified.
1804
- * Even though the values of the ordinals can change their ordering and uniqueness cannot, so the order of a set of
1805
- * segments ordered by their ordinals will always have the same order even if the ordinal values on
1806
- * the segments changes. This invariant allows us to ensure the segments stay
1807
- * ordered and unique, and that new segments can be inserted into that order.
1808
- *
1809
- * @deprecated This functionality was not meant to be exported and will be removed in a future release
1810
- * @internal
1811
- */
1812
- export declare class SortedSegmentSet<T extends SortedSegmentSetItem = ISegment> extends SortedSet<T, string> {
1813
- protected getKey(item: T): string;
1814
- protected findItemPosition(item: T): {
1815
- exists: boolean;
1816
- index: number;
1817
- };
1818
- }
1819
-
1820
- /**
1821
- * @deprecated This functionality was not meant to be exported and will be removed in a future release
1822
- * @internal
1823
- */
1824
- export declare type SortedSegmentSetItem = ISegment | LocalReferencePosition | {
1825
- readonly segment: ISegment;
1826
- };
1827
-
1828
- /**
1829
- * @deprecated This functionality was not meant to be exported and will be removed in a future release
1830
- * @internal
1831
- */
1832
- export declare abstract class SortedSet<T, U extends string | number> {
1833
- protected abstract getKey(t: T): U;
1834
- protected readonly keySortedItems: T[];
1835
- get size(): number;
1836
- get items(): readonly T[];
1837
- addOrUpdate(newItem: T, update?: (existingItem: T, newItem: T) => void): void;
1838
- remove(item: T): boolean;
1839
- has(item: T): boolean;
1840
- protected findItemPosition(item: T): {
1841
- exists: boolean;
1842
- index: number;
1843
- };
1844
- }
1845
-
1846
- /**
1847
- * @alpha
1848
- */
1849
- export declare class TextSegment extends BaseSegment {
1850
- text: string;
1851
- static readonly type = "TextSegment";
1852
- readonly type = "TextSegment";
1853
- static is(segment: ISegment): segment is TextSegment;
1854
- static make(text: string, props?: PropertySet): TextSegment;
1855
- static fromJSONObject(spec: any): TextSegment | undefined;
1856
- constructor(text: string);
1857
- toJSONObject(): IJSONTextSegment | string;
1858
- clone(start?: number, end?: number): TextSegment;
1859
- canAppend(segment: ISegment): boolean;
1860
- toString(): string;
1861
- append(segment: ISegment): void;
1862
- protected createSplitSegmentAt(pos: number): TextSegment | undefined;
1863
- }
1864
-
1865
- /**
1866
- * @internal
1867
- */
1868
- export declare function toRemovalInfo(maybe: Partial<IRemovalInfo> | undefined): IRemovalInfo | undefined;
1869
-
1870
- /**
1871
- * @alpha
1872
- */
1873
- export declare type Trackable = ISegment | LocalReferencePosition;
1874
-
1875
- /**
1876
- * @alpha
1877
- */
1878
- export declare class TrackingGroup implements ITrackingGroup {
1879
- private readonly trackedSet;
1880
- constructor();
1881
- get tracked(): readonly Trackable[];
1882
- get size(): number;
1883
- has(trackable: Trackable): boolean;
1884
- link(trackable: Trackable): void;
1885
- unlink(trackable: Trackable): boolean;
1886
- }
1887
-
1888
- /**
1889
- * A collection of {@link ITrackingGroup}.
1890
- * @alpha
1891
- */
1892
- export declare class TrackingGroupCollection {
1893
- private readonly trackable;
1894
- private readonly _trackingGroups;
1895
- get trackingGroups(): Set<TrackingGroup>;
1896
- constructor(trackable: Trackable);
1897
- link(trackingGroup: ITrackingGroup): void;
1898
- unlink(trackingGroup: ITrackingGroup): boolean;
1899
- copyTo(trackable: Trackable): void;
1900
- get empty(): boolean;
1901
- matches(trackingCollection: TrackingGroupCollection): boolean;
1902
- }
1903
-
1904
- /**
1905
- * The sequence number of an op before it is acked.
1906
- *
1907
- * @internal
1908
- */
1909
- export declare const UnassignedSequenceNumber = -1;
1910
-
1911
- /**
1912
- * The sequence number which can be seen by all ops.
1913
- *
1914
- * This is useful in the context of snapshot loading, rollback, among other
1915
- * scenarios.
1916
- *
1917
- * @internal
1918
- */
1919
- export declare const UniversalSequenceNumber = 0;
1920
-
1921
- export { }