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