@fluidframework/sequence 2.0.0-rc.3.0.3 → 2.0.0-rc.4.0.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 (121) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +10 -3
  3. package/api-report/sequence.api.md +34 -35
  4. package/dist/IntervalCollectionValues.d.ts +0 -2
  5. package/dist/IntervalCollectionValues.d.ts.map +1 -1
  6. package/dist/IntervalCollectionValues.js +0 -2
  7. package/dist/IntervalCollectionValues.js.map +1 -1
  8. package/dist/index.d.ts +2 -2
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +3 -3
  11. package/dist/index.js.map +1 -1
  12. package/dist/intervalCollection.js +1 -1
  13. package/dist/intervalCollection.js.map +1 -1
  14. package/dist/intervalIndex/endpointInRangeIndex.d.ts +2 -2
  15. package/dist/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
  16. package/dist/intervalIndex/endpointInRangeIndex.js.map +1 -1
  17. package/dist/intervalIndex/endpointIndex.d.ts +2 -2
  18. package/dist/intervalIndex/endpointIndex.d.ts.map +1 -1
  19. package/dist/intervalIndex/endpointIndex.js.map +1 -1
  20. package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +2 -2
  21. package/dist/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
  22. package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  23. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +2 -2
  24. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
  25. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  26. package/dist/intervalIndex/startpointInRangeIndex.d.ts +2 -2
  27. package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
  28. package/dist/intervalIndex/startpointInRangeIndex.js.map +1 -1
  29. package/dist/intervals/interval.js +1 -1
  30. package/dist/intervals/interval.js.map +1 -1
  31. package/dist/intervals/sequenceInterval.js +1 -1
  32. package/dist/intervals/sequenceInterval.js.map +1 -1
  33. package/dist/legacy.d.ts +2 -2
  34. package/dist/packageVersion.d.ts +1 -1
  35. package/dist/packageVersion.js +1 -1
  36. package/dist/packageVersion.js.map +1 -1
  37. package/dist/revertibles.d.ts +6 -6
  38. package/dist/revertibles.d.ts.map +1 -1
  39. package/dist/revertibles.js.map +1 -1
  40. package/dist/sequence.js +2 -2
  41. package/dist/sequence.js.map +1 -1
  42. package/dist/sequenceDeltaEvent.d.ts +24 -3
  43. package/dist/sequenceDeltaEvent.d.ts.map +1 -1
  44. package/dist/sequenceDeltaEvent.js +16 -3
  45. package/dist/sequenceDeltaEvent.js.map +1 -1
  46. package/dist/sequenceFactory.d.ts +15 -7
  47. package/dist/sequenceFactory.d.ts.map +1 -1
  48. package/dist/sequenceFactory.js +9 -6
  49. package/dist/sequenceFactory.js.map +1 -1
  50. package/dist/sharedString.d.ts +70 -47
  51. package/dist/sharedString.d.ts.map +1 -1
  52. package/dist/sharedString.js +15 -52
  53. package/dist/sharedString.js.map +1 -1
  54. package/lib/IntervalCollectionValues.d.ts +0 -2
  55. package/lib/IntervalCollectionValues.d.ts.map +1 -1
  56. package/lib/IntervalCollectionValues.js +0 -2
  57. package/lib/IntervalCollectionValues.js.map +1 -1
  58. package/lib/index.d.ts +2 -2
  59. package/lib/index.d.ts.map +1 -1
  60. package/lib/index.js +2 -2
  61. package/lib/index.js.map +1 -1
  62. package/lib/intervalCollection.js +1 -1
  63. package/lib/intervalCollection.js.map +1 -1
  64. package/lib/intervalIndex/endpointInRangeIndex.d.ts +2 -2
  65. package/lib/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
  66. package/lib/intervalIndex/endpointInRangeIndex.js.map +1 -1
  67. package/lib/intervalIndex/endpointIndex.d.ts +2 -2
  68. package/lib/intervalIndex/endpointIndex.d.ts.map +1 -1
  69. package/lib/intervalIndex/endpointIndex.js.map +1 -1
  70. package/lib/intervalIndex/overlappingIntervalsIndex.d.ts +2 -2
  71. package/lib/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
  72. package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  73. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +2 -2
  74. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
  75. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  76. package/lib/intervalIndex/startpointInRangeIndex.d.ts +2 -2
  77. package/lib/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
  78. package/lib/intervalIndex/startpointInRangeIndex.js.map +1 -1
  79. package/lib/intervals/interval.js +1 -1
  80. package/lib/intervals/interval.js.map +1 -1
  81. package/lib/intervals/sequenceInterval.js +1 -1
  82. package/lib/intervals/sequenceInterval.js.map +1 -1
  83. package/lib/legacy.d.ts +2 -2
  84. package/lib/packageVersion.d.ts +1 -1
  85. package/lib/packageVersion.js +1 -1
  86. package/lib/packageVersion.js.map +1 -1
  87. package/lib/revertibles.d.ts +6 -6
  88. package/lib/revertibles.d.ts.map +1 -1
  89. package/lib/revertibles.js.map +1 -1
  90. package/lib/sequence.js +2 -2
  91. package/lib/sequence.js.map +1 -1
  92. package/lib/sequenceDeltaEvent.d.ts +24 -3
  93. package/lib/sequenceDeltaEvent.d.ts.map +1 -1
  94. package/lib/sequenceDeltaEvent.js +16 -3
  95. package/lib/sequenceDeltaEvent.js.map +1 -1
  96. package/lib/sequenceFactory.d.ts +15 -7
  97. package/lib/sequenceFactory.d.ts.map +1 -1
  98. package/lib/sequenceFactory.js +9 -6
  99. package/lib/sequenceFactory.js.map +1 -1
  100. package/lib/sharedString.d.ts +70 -47
  101. package/lib/sharedString.d.ts.map +1 -1
  102. package/lib/sharedString.js +13 -50
  103. package/lib/sharedString.js.map +1 -1
  104. package/lib/tsdoc-metadata.json +1 -1
  105. package/package.json +38 -24
  106. package/src/IntervalCollectionValues.ts +0 -2
  107. package/src/index.ts +2 -2
  108. package/src/intervalCollection.ts +1 -1
  109. package/src/intervalIndex/endpointInRangeIndex.ts +2 -2
  110. package/src/intervalIndex/endpointIndex.ts +2 -2
  111. package/src/intervalIndex/overlappingIntervalsIndex.ts +2 -2
  112. package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +2 -2
  113. package/src/intervalIndex/startpointInRangeIndex.ts +2 -2
  114. package/src/intervals/interval.ts +1 -1
  115. package/src/intervals/sequenceInterval.ts +1 -1
  116. package/src/packageVersion.ts +1 -1
  117. package/src/revertibles.ts +18 -14
  118. package/src/sequence.ts +2 -2
  119. package/src/sequenceDeltaEvent.ts +12 -1
  120. package/src/sequenceFactory.ts +21 -9
  121. package/src/sharedString.ts +87 -56
@@ -42,9 +42,79 @@ export interface ISharedString extends SharedSegmentSequence<SharedStringSegment
42
42
  insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): void;
43
43
 
44
44
  /**
45
- * {@inheritDoc SharedSegmentSequence.posFromRelativePos}
45
+ * Inserts a marker at a relative position.
46
+ * @param relativePos1 - The relative position to insert the marker at
47
+ * @param refType - The reference type of the marker
48
+ * @param props - The properties of the marker
49
+ */
50
+ insertMarkerRelative(
51
+ relativePos1: IRelativePosition,
52
+ refType: ReferenceType,
53
+ props?: PropertySet,
54
+ ): void;
55
+
56
+ /**
57
+ * Inserts the text at the position.
58
+ * @param relativePos1 - The relative position to insert the text at
59
+ * @param text - The text to insert
60
+ * @param props - The properties of text
61
+ */
62
+ insertTextRelative(relativePos1: IRelativePosition, text: string, props?: PropertySet): void;
63
+
64
+ /**
65
+ * Replaces a range with the provided text.
66
+ * @param start - The inclusive start of the range to replace
67
+ * @param end - The exclusive end of the range to replace
68
+ * @param text - The text to replace the range with
69
+ * @param props - Optional. The properties of the replacement text
70
+ */
71
+ replaceText(start: number, end: number, text: string, props?: PropertySet): void;
72
+
73
+ /**
74
+ * Removes the text in the given range.
75
+ * @param start - The inclusive start of the range to remove
76
+ * @param end - The exclusive end of the range to replace
77
+ * @returns the message sent.
78
+ */
79
+ removeText(start: number, end: number): void;
80
+
81
+ /**
82
+ * Annotates the marker with the provided properties.
83
+ * @param marker - The marker to annotate
84
+ * @param props - The properties to annotate the marker with
85
+ */
86
+ annotateMarker(marker: Marker, props: PropertySet): void;
87
+
88
+ /**
89
+ * Searches a string for the nearest marker in either direction to a given start position.
90
+ * The search will include the start position, so markers at the start position are valid
91
+ * results of the search.
92
+ * @param startPos - Position at which to start the search
93
+ * @param markerLabel - Label of the marker to search for
94
+ * @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`. Default true.
95
+ */
96
+ searchForMarker(startPos: number, markerLabel: string, forwards?: boolean): Marker | undefined;
97
+
98
+ /**
99
+ * Retrieve text from the SharedString in string format.
100
+ * @param start - The starting index of the text to retrieve, or 0 if omitted.
101
+ * @param end - The ending index of the text to retrieve, or the end of the string if omitted
102
+ * @returns The requested text content as a string.
103
+ */
104
+ getText(start?: number, end?: number): string;
105
+
106
+ /**
107
+ * Adds spaces for markers and handles, so that position calculations account for them.
46
108
  */
47
- posFromRelativePos(relativePos: IRelativePosition): number;
109
+ getTextWithPlaceholders(start?: number, end?: number): string;
110
+
111
+ getTextRangeWithMarkers(start: number, end: number): string;
112
+
113
+ /**
114
+ * Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided
115
+ * id in this `SharedString`.
116
+ */
117
+ getMarkerFromId(id: string): ISegment | undefined;
48
118
  }
49
119
 
50
120
  /**
@@ -62,28 +132,10 @@ export type SharedStringSegment = TextSegment | Marker;
62
132
  * image or Fluid object that should be rendered with the text.
63
133
  * @alpha
64
134
  */
65
- export class SharedString
135
+ export class SharedStringClass
66
136
  extends SharedSegmentSequence<SharedStringSegment>
67
137
  implements ISharedString
68
138
  {
69
- /**
70
- * Create a new shared string.
71
- * @param runtime - data store runtime the new shared string belongs to
72
- * @param id - optional name of the shared string
73
- * @returns newly create shared string (but not attached yet)
74
- */
75
- public static create(runtime: IFluidDataStoreRuntime, id?: string) {
76
- return runtime.createChannel(id, SharedStringFactory.Type) as SharedString;
77
- }
78
-
79
- /**
80
- * Get a factory for SharedString to register with the data store.
81
- * @returns a factory that creates and load SharedString
82
- */
83
- public static getFactory() {
84
- return new SharedStringFactory();
85
- }
86
-
87
139
  public get ISharedString(): ISharedString {
88
140
  return this;
89
141
  }
@@ -101,10 +153,7 @@ export class SharedString
101
153
  }
102
154
 
103
155
  /**
104
- * Inserts a marker at a relative position.
105
- * @param relativePos1 - The relative position to insert the marker at
106
- * @param refType - The reference type of the marker
107
- * @param props - The properties of the marker
156
+ * {@inheritDoc ISharedString.insertMarkerRelative}
108
157
  */
109
158
  public insertMarkerRelative(
110
159
  relativePos1: IRelativePosition,
@@ -133,10 +182,7 @@ export class SharedString
133
182
  }
134
183
 
135
184
  /**
136
- * Inserts the text at the position.
137
- * @param relativePos1 - The relative position to insert the text at
138
- * @param text - The text to insert
139
- * @param props - The properties of text
185
+ * {@inheritDoc ISharedString.insertTextRelative}
140
186
  */
141
187
  public insertTextRelative(
142
188
  relativePos1: IRelativePosition,
@@ -165,42 +211,28 @@ export class SharedString
165
211
  }
166
212
 
167
213
  /**
168
- * Replaces a range with the provided text.
169
- * @param start - The inclusive start of the range to replace
170
- * @param end - The exclusive end of the range to replace
171
- * @param text - The text to replace the range with
172
- * @param props - Optional. The properties of the replacement text
214
+ * {@inheritDoc ISharedString.replaceText}
173
215
  */
174
216
  public replaceText(start: number, end: number, text: string, props?: PropertySet): void {
175
217
  this.replaceRange(start, end, TextSegment.make(text, props));
176
218
  }
177
219
 
178
220
  /**
179
- * Removes the text in the given range.
180
- * @param start - The inclusive start of the range to remove
181
- * @param end - The exclusive end of the range to replace
182
- * @returns the message sent.
221
+ * {@inheritDoc ISharedString.removeText}
183
222
  */
184
223
  public removeText(start: number, end: number): void {
185
224
  this.removeRange(start, end);
186
225
  }
187
226
 
188
227
  /**
189
- * Annotates the marker with the provided properties.
190
- * @param marker - The marker to annotate
191
- * @param props - The properties to annotate the marker with
228
+ * {@inheritDoc ISharedString.annotateMarker}
192
229
  */
193
- public annotateMarker(marker: Marker, props: PropertySet) {
230
+ public annotateMarker(marker: Marker, props: PropertySet): void {
194
231
  this.guardReentrancy(() => this.client.annotateMarker(marker, props));
195
232
  }
196
233
 
197
234
  /**
198
- * Searches a string for the nearest marker in either direction to a given start position.
199
- * The search will include the start position, so markers at the start position are valid
200
- * results of the search.
201
- * @param startPos - Position at which to start the search
202
- * @param markerLabel - Label of the marker to search for
203
- * @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`
235
+ * {@inheritDoc ISharedString.searchForMarker}
204
236
  */
205
237
  public searchForMarker(
206
238
  startPos: number,
@@ -211,10 +243,7 @@ export class SharedString
211
243
  }
212
244
 
213
245
  /**
214
- * Retrieve text from the SharedString in string format.
215
- * @param start - The starting index of the text to retrieve, or 0 if omitted.
216
- * @param end - The ending index of the text to retrieve, or the end of the string if omitted
217
- * @returns The requested text content as a string.
246
+ * {@inheritDoc ISharedString.getText}
218
247
  */
219
248
  public getText(start?: number, end?: number) {
220
249
  const segmentWindow = this.client.getCollabWindow();
@@ -228,7 +257,7 @@ export class SharedString
228
257
  }
229
258
 
230
259
  /**
231
- * Adds spaces for markers and handles, so that position calculations account for them.
260
+ * {@inheritDoc ISharedString.getTextWithPlaceholders}
232
261
  */
233
262
  public getTextWithPlaceholders(start?: number, end?: number) {
234
263
  const segmentWindow = this.client.getCollabWindow();
@@ -241,6 +270,9 @@ export class SharedString
241
270
  );
242
271
  }
243
272
 
273
+ /**
274
+ * {@inheritDoc ISharedString.getTextRangeWithMarkers}
275
+ */
244
276
  public getTextRangeWithMarkers(start: number, end: number) {
245
277
  const segmentWindow = this.client.getCollabWindow();
246
278
  return this.mergeTreeTextHelper.getText(
@@ -253,8 +285,7 @@ export class SharedString
253
285
  }
254
286
 
255
287
  /**
256
- * Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided
257
- * id in this `SharedString`.
288
+ * {@inheritDoc ISharedString.getMarkerFromId}
258
289
  */
259
290
  public getMarkerFromId(id: string): ISegment | undefined {
260
291
  return this.client.getMarkerFromId(id);
@@ -297,7 +328,7 @@ interface ITextAndMarkerAccumulator {
297
328
  * @internal
298
329
  */
299
330
  export function getTextAndMarkers(
300
- sharedString: SharedString,
331
+ sharedString: ISharedString,
301
332
  label: string,
302
333
  start?: number,
303
334
  end?: number,