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