@fluidframework/sequence 2.0.0-internal.5.3.4 → 2.0.0-internal.5.4.2

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 (179) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/index.d.ts +4 -3
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +12 -9
  5. package/dist/index.js.map +1 -1
  6. package/dist/intervalCollection.d.ts +46 -410
  7. package/dist/intervalCollection.d.ts.map +1 -1
  8. package/dist/intervalCollection.js +44 -732
  9. package/dist/intervalCollection.js.map +1 -1
  10. package/dist/intervalIndex/endpointInRangeIndex.d.ts +20 -0
  11. package/dist/intervalIndex/endpointInRangeIndex.d.ts.map +1 -0
  12. package/dist/intervalIndex/endpointInRangeIndex.js +60 -0
  13. package/dist/intervalIndex/endpointInRangeIndex.js.map +1 -0
  14. package/dist/intervalIndex/endpointIndex.d.ts +21 -0
  15. package/dist/intervalIndex/endpointIndex.d.ts.map +1 -0
  16. package/dist/intervalIndex/endpointIndex.js +42 -0
  17. package/dist/intervalIndex/endpointIndex.js.map +1 -0
  18. package/dist/intervalIndex/idIntervalIndex.d.ts +12 -0
  19. package/dist/intervalIndex/idIntervalIndex.d.ts.map +1 -0
  20. package/dist/intervalIndex/idIntervalIndex.js +41 -0
  21. package/dist/intervalIndex/idIntervalIndex.js.map +1 -0
  22. package/dist/intervalIndex/index.d.ts +5 -0
  23. package/dist/intervalIndex/index.d.ts.map +1 -1
  24. package/dist/intervalIndex/index.js +9 -1
  25. package/dist/intervalIndex/index.js.map +1 -1
  26. package/dist/intervalIndex/intervalIndex.d.ts +29 -0
  27. package/dist/intervalIndex/intervalIndex.d.ts.map +1 -0
  28. package/dist/intervalIndex/intervalIndex.js +7 -0
  29. package/dist/intervalIndex/intervalIndex.js.map +1 -0
  30. package/dist/intervalIndex/intervalIndexUtils.d.ts +17 -0
  31. package/dist/intervalIndex/intervalIndexUtils.d.ts.map +1 -0
  32. package/dist/intervalIndex/intervalIndexUtils.js +23 -0
  33. package/dist/intervalIndex/intervalIndexUtils.js.map +1 -0
  34. package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +2 -1
  35. package/dist/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
  36. package/dist/intervalIndex/overlappingIntervalsIndex.js +3 -3
  37. package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  38. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js +5 -5
  39. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  40. package/dist/intervalIndex/sequenceIntervalIndexes.d.ts +1 -1
  41. package/dist/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
  42. package/dist/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
  43. package/dist/intervalIndex/startpointInRangeIndex.d.ts +20 -0
  44. package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -0
  45. package/dist/intervalIndex/startpointInRangeIndex.js +62 -0
  46. package/dist/intervalIndex/startpointInRangeIndex.js.map +1 -0
  47. package/dist/intervalTree.d.ts +1 -47
  48. package/dist/intervalTree.d.ts.map +1 -1
  49. package/dist/intervalTree.js.map +1 -1
  50. package/dist/intervals/index.d.ts +8 -0
  51. package/dist/intervals/index.d.ts.map +1 -0
  52. package/dist/intervals/index.js +23 -0
  53. package/dist/intervals/index.js.map +1 -0
  54. package/dist/intervals/interval.d.ts +88 -0
  55. package/dist/intervals/interval.d.ts.map +1 -0
  56. package/dist/intervals/interval.js +182 -0
  57. package/dist/intervals/interval.js.map +1 -0
  58. package/dist/intervals/intervalUtils.d.ts +194 -0
  59. package/dist/intervals/intervalUtils.d.ts.map +1 -0
  60. package/dist/intervals/intervalUtils.js +79 -0
  61. package/dist/intervals/intervalUtils.js.map +1 -0
  62. package/dist/intervals/sequenceInterval.d.ts +132 -0
  63. package/dist/intervals/sequenceInterval.d.ts.map +1 -0
  64. package/dist/intervals/sequenceInterval.js +315 -0
  65. package/dist/intervals/sequenceInterval.js.map +1 -0
  66. package/dist/packageVersion.d.ts +1 -1
  67. package/dist/packageVersion.js +1 -1
  68. package/dist/packageVersion.js.map +1 -1
  69. package/dist/revertibles.d.ts +1 -1
  70. package/dist/revertibles.d.ts.map +1 -1
  71. package/dist/revertibles.js +36 -29
  72. package/dist/revertibles.js.map +1 -1
  73. package/dist/sequence.d.ts +2 -1
  74. package/dist/sequence.d.ts.map +1 -1
  75. package/dist/sequence.js +4 -1
  76. package/dist/sequence.js.map +1 -1
  77. package/dist/sharedIntervalCollection.d.ts +2 -1
  78. package/dist/sharedIntervalCollection.d.ts.map +1 -1
  79. package/dist/sharedIntervalCollection.js.map +1 -1
  80. package/lib/index.d.ts +4 -3
  81. package/lib/index.d.ts.map +1 -1
  82. package/lib/index.js +3 -2
  83. package/lib/index.js.map +1 -1
  84. package/lib/intervalCollection.d.ts +46 -410
  85. package/lib/intervalCollection.d.ts.map +1 -1
  86. package/lib/intervalCollection.js +25 -705
  87. package/lib/intervalCollection.js.map +1 -1
  88. package/lib/intervalIndex/endpointInRangeIndex.d.ts +20 -0
  89. package/lib/intervalIndex/endpointInRangeIndex.d.ts.map +1 -0
  90. package/lib/intervalIndex/endpointInRangeIndex.js +56 -0
  91. package/lib/intervalIndex/endpointInRangeIndex.js.map +1 -0
  92. package/lib/intervalIndex/endpointIndex.d.ts +21 -0
  93. package/lib/intervalIndex/endpointIndex.d.ts.map +1 -0
  94. package/lib/intervalIndex/endpointIndex.js +38 -0
  95. package/lib/intervalIndex/endpointIndex.js.map +1 -0
  96. package/lib/intervalIndex/idIntervalIndex.d.ts +12 -0
  97. package/lib/intervalIndex/idIntervalIndex.d.ts.map +1 -0
  98. package/lib/intervalIndex/idIntervalIndex.js +37 -0
  99. package/lib/intervalIndex/idIntervalIndex.js.map +1 -0
  100. package/lib/intervalIndex/index.d.ts +5 -0
  101. package/lib/intervalIndex/index.d.ts.map +1 -1
  102. package/lib/intervalIndex/index.js +4 -0
  103. package/lib/intervalIndex/index.js.map +1 -1
  104. package/lib/intervalIndex/intervalIndex.d.ts +29 -0
  105. package/lib/intervalIndex/intervalIndex.d.ts.map +1 -0
  106. package/lib/intervalIndex/intervalIndex.js +6 -0
  107. package/lib/intervalIndex/intervalIndex.js.map +1 -0
  108. package/lib/intervalIndex/intervalIndexUtils.d.ts +17 -0
  109. package/lib/intervalIndex/intervalIndexUtils.d.ts.map +1 -0
  110. package/lib/intervalIndex/intervalIndexUtils.js +19 -0
  111. package/lib/intervalIndex/intervalIndexUtils.js.map +1 -0
  112. package/lib/intervalIndex/overlappingIntervalsIndex.d.ts +2 -1
  113. package/lib/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
  114. package/lib/intervalIndex/overlappingIntervalsIndex.js +1 -1
  115. package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  116. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js +1 -1
  117. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  118. package/lib/intervalIndex/sequenceIntervalIndexes.d.ts +1 -1
  119. package/lib/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
  120. package/lib/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
  121. package/lib/intervalIndex/startpointInRangeIndex.d.ts +20 -0
  122. package/lib/intervalIndex/startpointInRangeIndex.d.ts.map +1 -0
  123. package/lib/intervalIndex/startpointInRangeIndex.js +58 -0
  124. package/lib/intervalIndex/startpointInRangeIndex.js.map +1 -0
  125. package/lib/intervalTree.d.ts +1 -47
  126. package/lib/intervalTree.d.ts.map +1 -1
  127. package/lib/intervalTree.js.map +1 -1
  128. package/lib/intervals/index.d.ts +8 -0
  129. package/lib/intervals/index.d.ts.map +1 -0
  130. package/lib/intervals/index.js +8 -0
  131. package/lib/intervals/index.js.map +1 -0
  132. package/lib/intervals/interval.d.ts +88 -0
  133. package/lib/intervals/interval.d.ts.map +1 -0
  134. package/lib/intervals/interval.js +177 -0
  135. package/lib/intervals/interval.js.map +1 -0
  136. package/lib/intervals/intervalUtils.d.ts +194 -0
  137. package/lib/intervals/intervalUtils.d.ts.map +1 -0
  138. package/lib/intervals/intervalUtils.js +74 -0
  139. package/lib/intervals/intervalUtils.js.map +1 -0
  140. package/lib/intervals/sequenceInterval.d.ts +132 -0
  141. package/lib/intervals/sequenceInterval.d.ts.map +1 -0
  142. package/lib/intervals/sequenceInterval.js +307 -0
  143. package/lib/intervals/sequenceInterval.js.map +1 -0
  144. package/lib/packageVersion.d.ts +1 -1
  145. package/lib/packageVersion.js +1 -1
  146. package/lib/packageVersion.js.map +1 -1
  147. package/lib/revertibles.d.ts +1 -1
  148. package/lib/revertibles.d.ts.map +1 -1
  149. package/lib/revertibles.js +21 -14
  150. package/lib/revertibles.js.map +1 -1
  151. package/lib/sequence.d.ts +2 -1
  152. package/lib/sequence.d.ts.map +1 -1
  153. package/lib/sequence.js +5 -2
  154. package/lib/sequence.js.map +1 -1
  155. package/lib/sharedIntervalCollection.d.ts +2 -1
  156. package/lib/sharedIntervalCollection.d.ts.map +1 -1
  157. package/lib/sharedIntervalCollection.js.map +1 -1
  158. package/package.json +15 -15
  159. package/src/index.ts +19 -12
  160. package/src/intervalCollection.ts +75 -1204
  161. package/src/intervalIndex/endpointInRangeIndex.ts +104 -0
  162. package/src/intervalIndex/endpointIndex.ts +78 -0
  163. package/src/intervalIndex/idIntervalIndex.ts +58 -0
  164. package/src/intervalIndex/index.ts +5 -0
  165. package/src/intervalIndex/intervalIndex.ts +31 -0
  166. package/src/intervalIndex/intervalIndexUtils.ts +27 -0
  167. package/src/intervalIndex/overlappingIntervalsIndex.ts +2 -6
  168. package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +1 -1
  169. package/src/intervalIndex/sequenceIntervalIndexes.ts +1 -1
  170. package/src/intervalIndex/startpointInRangeIndex.ts +109 -0
  171. package/src/intervalTree.ts +1 -54
  172. package/src/intervals/index.ts +25 -0
  173. package/src/intervals/interval.ts +230 -0
  174. package/src/intervals/intervalUtils.ts +249 -0
  175. package/src/intervals/sequenceInterval.ts +494 -0
  176. package/src/packageVersion.ts +1 -1
  177. package/src/revertibles.ts +23 -12
  178. package/src/sequence.ts +6 -3
  179. package/src/sharedIntervalCollection.ts +1 -2
@@ -15,43 +15,16 @@ var __rest = (this && this.__rest) || function (s, e) {
15
15
  return t;
16
16
  };
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.intervalLocatorFromEndpoint = exports.IntervalCollection = exports.makeOpsMap = exports.IntervalCollectionValueType = exports.SequenceIntervalCollectionValueType = exports.intervalHelpers = exports.sequenceIntervalHelpers = exports.compareSequenceIntervalStarts = exports.compareSequenceIntervalEnds = exports.LocalIntervalCollection = exports.createStartpointInRangeIndex = exports.createEndpointInRangeIndex = exports.createIntervalIndex = exports.createSequenceInterval = exports.createPositionReferenceFromSegoff = exports.SequenceInterval = exports.Interval = exports.IntervalStickiness = exports.IntervalType = exports.IntervalOpType = void 0;
18
+ exports.intervalLocatorFromEndpoint = exports.IntervalCollection = exports.makeOpsMap = exports.IntervalCollectionValueType = exports.SequenceIntervalCollectionValueType = exports.LocalIntervalCollection = exports.createIntervalIndex = void 0;
19
19
  /* eslint-disable no-bitwise */
20
20
  const common_utils_1 = require("@fluidframework/common-utils");
21
21
  const container_utils_1 = require("@fluidframework/container-utils");
22
22
  const merge_tree_1 = require("@fluidframework/merge-tree");
23
23
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
24
24
  const uuid_1 = require("uuid");
25
+ const intervals_1 = require("./intervals");
25
26
  const intervalIndex_1 = require("./intervalIndex");
26
27
  const reservedIntervalIdKey = "intervalId";
27
- /**
28
- * Values are used in persisted formats (ops) and revertibles.
29
- * @alpha
30
- */
31
- exports.IntervalOpType = {
32
- ADD: "add",
33
- DELETE: "delete",
34
- CHANGE: "change",
35
- PROPERTY_CHANGED: "propertyChanged",
36
- POSITION_REMOVE: "positionRemove",
37
- };
38
- var IntervalType;
39
- (function (IntervalType) {
40
- IntervalType[IntervalType["Simple"] = 0] = "Simple";
41
- IntervalType[IntervalType["Nest"] = 1] = "Nest";
42
- /**
43
- * SlideOnRemove indicates that the ends of the interval will slide if the segment
44
- * they reference is removed and acked.
45
- * See `packages\dds\merge-tree\docs\REFERENCEPOSITIONS.md` for details
46
- * SlideOnRemove is the default interval behavior and does not need to be specified.
47
- */
48
- IntervalType[IntervalType["SlideOnRemove"] = 2] = "SlideOnRemove";
49
- /**
50
- * A temporary interval, used internally
51
- * @internal
52
- */
53
- IntervalType[IntervalType["Transient"] = 4] = "Transient";
54
- })(IntervalType = exports.IntervalType || (exports.IntervalType = {}));
55
28
  /**
56
29
  * Decompress an interval after loading a summary from JSON. The exact format
57
30
  * of this compression is unspecified and subject to change
@@ -79,677 +52,20 @@ function compressInterval(interval) {
79
52
  intervalType,
80
53
  Object.assign(Object.assign({}, properties), { [merge_tree_1.reservedRangeLabelsKey]: undefined }),
81
54
  ];
82
- if (interval.stickiness !== undefined && interval.stickiness !== exports.IntervalStickiness.END) {
55
+ if (interval.stickiness !== undefined && interval.stickiness !== intervals_1.IntervalStickiness.END) {
83
56
  base.push(interval.stickiness);
84
57
  }
85
58
  return base;
86
59
  }
87
- function startReferenceSlidingPreference(stickiness) {
88
- // if any start stickiness, prefer sliding backwards
89
- return (stickiness & exports.IntervalStickiness.START) !== 0
90
- ? merge_tree_1.SlidingPreference.BACKWARD
91
- : merge_tree_1.SlidingPreference.FORWARD;
92
- }
93
- function endReferenceSlidingPreference(stickiness) {
94
- // if any end stickiness, prefer sliding forwards
95
- return (stickiness & exports.IntervalStickiness.END) !== 0
96
- ? merge_tree_1.SlidingPreference.FORWARD
97
- : merge_tree_1.SlidingPreference.BACKWARD;
98
- }
99
- /**
100
- * Determines how an interval should expand when segments are inserted adjacent
101
- * to the range it spans
102
- *
103
- * Note that interval stickiness is currently an experimental feature and must
104
- * be explicitly enabled with the `intervalStickinessEnabled` flag
105
- */
106
- exports.IntervalStickiness = {
107
- /**
108
- * Interval does not expand to include adjacent segments
109
- */
110
- NONE: 0b00,
111
- /**
112
- * Interval expands to include segments inserted adjacent to the start
113
- */
114
- START: 0b01,
115
- /**
116
- * Interval expands to include segments inserted adjacent to the end
117
- *
118
- * This is the default stickiness
119
- */
120
- END: 0b10,
121
- /**
122
- * Interval expands to include all segments inserted adjacent to it
123
- */
124
- FULL: 0b11,
125
- };
126
- /**
127
- * Serializable interval whose endpoints are plain-old numbers.
128
- */
129
- class Interval {
130
- constructor(start, end, props) {
131
- this.start = start;
132
- this.end = end;
133
- this.propertyManager = new merge_tree_1.PropertiesManager();
134
- this.properties = {};
135
- if (props) {
136
- this.addProperties(props);
137
- }
138
- }
139
- /**
140
- * {@inheritDoc ISerializableInterval.getIntervalId}
141
- */
142
- getIntervalId() {
143
- var _a;
144
- const id = (_a = this.properties) === null || _a === void 0 ? void 0 : _a[reservedIntervalIdKey];
145
- (0, common_utils_1.assert)(id !== undefined, 0x5e1 /* interval ID should not be undefined */);
146
- return `${id}`;
147
- }
148
- /**
149
- * @returns an array containing any auxiliary property sets added with `addPropertySet`.
150
- */
151
- getAdditionalPropertySets() {
152
- var _a;
153
- return (_a = this.auxProps) !== null && _a !== void 0 ? _a : [];
154
- }
155
- /**
156
- * Adds an auxiliary set of properties to this interval.
157
- * These properties can be recovered using `getAdditionalPropertySets`
158
- * @param props - set of properties to add
159
- * @remarks - This gets called as part of the default conflict resolver for `IIntervalCollection<Interval>`
160
- * (i.e. non-sequence-based interval collections). However, the additional properties don't get serialized.
161
- * This functionality seems half-baked.
162
- */
163
- addPropertySet(props) {
164
- if (this.auxProps === undefined) {
165
- this.auxProps = [];
166
- }
167
- this.auxProps.push(props);
168
- }
169
- /**
170
- * {@inheritDoc ISerializableInterval.serialize}
171
- * @internal
172
- */
173
- serialize() {
174
- const serializedInterval = {
175
- end: this.end,
176
- intervalType: 0,
177
- sequenceNumber: 0,
178
- start: this.start,
179
- };
180
- if (this.properties) {
181
- serializedInterval.properties = this.properties;
182
- }
183
- return serializedInterval;
184
- }
185
- /**
186
- * {@inheritDoc IInterval.clone}
187
- */
188
- clone() {
189
- return new Interval(this.start, this.end, this.properties);
190
- }
191
- /**
192
- * {@inheritDoc IInterval.compare}
193
- */
194
- compare(b) {
195
- const startResult = this.compareStart(b);
196
- if (startResult === 0) {
197
- const endResult = this.compareEnd(b);
198
- if (endResult === 0) {
199
- const thisId = this.getIntervalId();
200
- if (thisId) {
201
- const bId = b.getIntervalId();
202
- if (bId) {
203
- return thisId > bId ? 1 : thisId < bId ? -1 : 0;
204
- }
205
- return 0;
206
- }
207
- return 0;
208
- }
209
- else {
210
- return endResult;
211
- }
212
- }
213
- else {
214
- return startResult;
215
- }
216
- }
217
- /**
218
- * {@inheritDoc IInterval.compareStart}
219
- */
220
- compareStart(b) {
221
- return this.start - b.start;
222
- }
223
- /**
224
- * {@inheritDoc IInterval.compareEnd}
225
- */
226
- compareEnd(b) {
227
- return this.end - b.end;
228
- }
229
- /**
230
- * {@inheritDoc IInterval.overlaps}
231
- */
232
- overlaps(b) {
233
- const result = this.start <= b.end && this.end >= b.start;
234
- return result;
235
- }
236
- /**
237
- * {@inheritDoc IInterval.union}
238
- * @deprecated - This API was never intended to be public and will be marked internal in a future release.
239
- */
240
- union(b) {
241
- return new Interval(Math.min(this.start, b.start), Math.max(this.end, b.end), this.properties);
242
- }
243
- getProperties() {
244
- return this.properties;
245
- }
246
- /**
247
- * {@inheritDoc ISerializableInterval.addProperties}
248
- * @deprecated - This API was never intended to be public and will be marked internal in a future release.
249
- */
250
- addProperties(newProps, collaborating = false, seq, op) {
251
- if (newProps) {
252
- this.initializeProperties();
253
- return this.propertyManager.addProperties(this.properties, newProps, op, seq, collaborating);
254
- }
255
- }
256
- /**
257
- * {@inheritDoc IInterval.modify}
258
- * @deprecated - This API was never intended to be public and will be marked internal in a future release.
259
- */
260
- modify(label, start, end, op) {
261
- const startPos = start !== null && start !== void 0 ? start : this.start;
262
- const endPos = end !== null && end !== void 0 ? end : this.end;
263
- if (this.start === startPos && this.end === endPos) {
264
- // Return undefined to indicate that no change is necessary.
265
- return;
266
- }
267
- const newInterval = new Interval(startPos, endPos);
268
- if (this.properties) {
269
- newInterval.initializeProperties();
270
- this.propertyManager.copyTo(this.properties, newInterval.properties, newInterval.propertyManager);
271
- }
272
- return newInterval;
273
- }
274
- initializeProperties() {
275
- if (!this.propertyManager) {
276
- this.propertyManager = new merge_tree_1.PropertiesManager();
277
- }
278
- if (!this.properties) {
279
- this.properties = (0, merge_tree_1.createMap)();
280
- }
281
- }
282
- }
283
- exports.Interval = Interval;
284
- /**
285
- * Interval implementation whose ends are associated with positions in a mutatable sequence.
286
- * As such, when content is inserted into the middle of the interval, the interval expands to
287
- * include that content.
288
- *
289
- * @remarks - The endpoint's position should be treated exclusively to get reasonable behavior--i.e.
290
- * an interval referring to "hello" in "hello world" should have a start position of 0 and an end
291
- * position of 5.
292
- *
293
- * To see why, consider what happens if "llo wor" is removed from the string to make "held".
294
- * The interval's startpoint remains on the "h" (it isn't altered), but the interval's endpoint
295
- * slides forward to the next unremoved position, which is the "l" in "held".
296
- * Users would generally expect the interval to now refer to "he" (as it is the subset of content
297
- * remaining after the removal), hence the "l" should be excluded.
298
- * If the interval endpoint was treated inclusively, the interval would now refer to "hel", which
299
- * is undesirable.
300
- *
301
- * Since the end of an interval is treated exclusively but cannot be greater than or equal to the
302
- * length of the associated sequence, application models which leverage interval collections should
303
- * consider inserting a marker at the end of the sequence to represent the end of the content.
304
- */
305
- class SequenceInterval {
306
- constructor(client,
307
- /**
308
- * Start endpoint of this interval.
309
- * @remarks - This endpoint can be resolved into a character position using the SharedString it's a part of.
310
- */
311
- start,
312
- /**
313
- * End endpoint of this interval.
314
- * @remarks - This endpoint can be resolved into a character position using the SharedString it's a part of.
315
- */
316
- end, intervalType, props, stickiness = exports.IntervalStickiness.END) {
317
- this.client = client;
318
- this.start = start;
319
- this.end = end;
320
- this.intervalType = intervalType;
321
- this.stickiness = stickiness;
322
- this.propertyManager = new merge_tree_1.PropertiesManager();
323
- this.properties = {};
324
- if (props) {
325
- this.addProperties(props);
326
- }
327
- }
328
- /**
329
- * Subscribes to position change events on this interval if there are no current listeners.
330
- * @internal
331
- */
332
- addPositionChangeListeners(beforePositionChange, afterPositionChange) {
333
- var _a, _b;
334
- var _c, _d;
335
- if (this.callbacks === undefined) {
336
- this.callbacks = {
337
- beforePositionChange,
338
- afterPositionChange,
339
- };
340
- const startCbs = ((_a = (_c = this.start).callbacks) !== null && _a !== void 0 ? _a : (_c.callbacks = {}));
341
- const endCbs = ((_b = (_d = this.end).callbacks) !== null && _b !== void 0 ? _b : (_d.callbacks = {}));
342
- startCbs.beforeSlide = endCbs.beforeSlide = beforePositionChange;
343
- startCbs.afterSlide = endCbs.afterSlide = afterPositionChange;
344
- }
345
- }
346
- /**
347
- * Removes the currently subscribed position change listeners.
348
- * @internal
349
- */
350
- removePositionChangeListeners() {
351
- if (this.callbacks) {
352
- this.callbacks = undefined;
353
- this.start.callbacks = undefined;
354
- this.end.callbacks = undefined;
355
- }
356
- }
357
- /**
358
- * {@inheritDoc ISerializableInterval.serialize}
359
- * @internal
360
- */
361
- serialize() {
362
- const startPosition = this.client.localReferencePositionToPosition(this.start);
363
- const endPosition = this.client.localReferencePositionToPosition(this.end);
364
- const serializedInterval = {
365
- end: endPosition,
366
- intervalType: this.intervalType,
367
- sequenceNumber: this.client.getCurrentSeq(),
368
- start: startPosition,
369
- };
370
- if (this.properties) {
371
- serializedInterval.properties = this.properties;
372
- }
373
- if (this.stickiness !== exports.IntervalStickiness.END) {
374
- serializedInterval.stickiness = this.stickiness;
375
- }
376
- return serializedInterval;
377
- }
378
- /**
379
- * {@inheritDoc IInterval.clone}
380
- */
381
- clone() {
382
- return new SequenceInterval(this.client, this.start, this.end, this.intervalType, this.properties, this.stickiness);
383
- }
384
- /**
385
- * {@inheritDoc IInterval.compare}
386
- */
387
- compare(b) {
388
- const startResult = this.compareStart(b);
389
- if (startResult === 0) {
390
- const endResult = this.compareEnd(b);
391
- if (endResult === 0) {
392
- const thisId = this.getIntervalId();
393
- if (thisId) {
394
- const bId = b.getIntervalId();
395
- if (bId) {
396
- return thisId > bId ? 1 : thisId < bId ? -1 : 0;
397
- }
398
- return 0;
399
- }
400
- return 0;
401
- }
402
- else {
403
- return endResult;
404
- }
405
- }
406
- else {
407
- return startResult;
408
- }
409
- }
410
- /**
411
- * {@inheritDoc IInterval.compareStart}
412
- */
413
- compareStart(b) {
414
- return (0, merge_tree_1.compareReferencePositions)(this.start, b.start);
415
- }
416
- /**
417
- * {@inheritDoc IInterval.compareEnd}
418
- */
419
- compareEnd(b) {
420
- return (0, merge_tree_1.compareReferencePositions)(this.end, b.end);
421
- }
422
- /**
423
- * {@inheritDoc IInterval.overlaps}
424
- */
425
- overlaps(b) {
426
- const result = (0, merge_tree_1.compareReferencePositions)(this.start, b.end) <= 0 &&
427
- (0, merge_tree_1.compareReferencePositions)(this.end, b.start) >= 0;
428
- return result;
429
- }
430
- /**
431
- * {@inheritDoc ISerializableInterval.getIntervalId}
432
- */
433
- getIntervalId() {
434
- var _a;
435
- const id = (_a = this.properties) === null || _a === void 0 ? void 0 : _a[reservedIntervalIdKey];
436
- (0, common_utils_1.assert)(id !== undefined, 0x5e2 /* interval ID should not be undefined */);
437
- return `${id}`;
438
- }
439
- /**
440
- * {@inheritDoc IInterval.union}
441
- * @deprecated - This API was never intended to be public and will be marked internal in a future release.
442
- */
443
- union(b) {
444
- return new SequenceInterval(this.client, (0, merge_tree_1.minReferencePosition)(this.start, b.start), (0, merge_tree_1.maxReferencePosition)(this.end, b.end), this.intervalType);
445
- }
446
- /**
447
- * {@inheritDoc ISerializableInterval.addProperties}
448
- * @deprecated - This API was never intended to be public and will be marked internal in a future release.
449
- */
450
- addProperties(newProps, collab = false, seq, op) {
451
- this.initializeProperties();
452
- return this.propertyManager.addProperties(this.properties, newProps, op, seq, collab);
453
- }
454
- /**
455
- * @returns whether this interval overlaps two numerical positions.
456
- */
457
- overlapsPos(bstart, bend) {
458
- const startPos = this.client.localReferencePositionToPosition(this.start);
459
- const endPos = this.client.localReferencePositionToPosition(this.end);
460
- return endPos > bstart && startPos < bend;
461
- }
462
- /**
463
- * {@inheritDoc IInterval.modify}
464
- * @deprecated - This API was never intended to be public and will be marked internal in a future release.
465
- */
466
- modify(label, start, end, op, localSeq, stickiness = exports.IntervalStickiness.END) {
467
- const getRefType = (baseType) => {
468
- let refType = baseType;
469
- if (op === undefined) {
470
- refType &= ~merge_tree_1.ReferenceType.SlideOnRemove;
471
- refType |= merge_tree_1.ReferenceType.StayOnRemove;
472
- }
473
- return refType;
474
- };
475
- let startRef = this.start;
476
- if (start !== undefined) {
477
- startRef = createPositionReference(this.client, start, getRefType(this.start.refType), op, undefined, localSeq, startReferenceSlidingPreference(stickiness));
478
- if (this.start.properties) {
479
- startRef.addProperties(this.start.properties);
480
- }
481
- }
482
- let endRef = this.end;
483
- if (end !== undefined) {
484
- endRef = createPositionReference(this.client, end, getRefType(this.end.refType), op, undefined, localSeq, endReferenceSlidingPreference(stickiness));
485
- if (this.end.properties) {
486
- endRef.addProperties(this.end.properties);
487
- }
488
- }
489
- const newInterval = new SequenceInterval(this.client, startRef, endRef, this.intervalType);
490
- if (this.properties) {
491
- newInterval.initializeProperties();
492
- this.propertyManager.copyTo(this.properties, newInterval.properties, newInterval.propertyManager);
493
- }
494
- return newInterval;
495
- }
496
- initializeProperties() {
497
- if (!this.propertyManager) {
498
- this.propertyManager = new merge_tree_1.PropertiesManager();
499
- }
500
- if (!this.properties) {
501
- this.properties = (0, merge_tree_1.createMap)();
502
- }
503
- }
504
- }
505
- exports.SequenceInterval = SequenceInterval;
506
- function createPositionReferenceFromSegoff(client, segoff, refType, op, localSeq, fromSnapshot, slidingPreference) {
507
- if (segoff.segment) {
508
- const ref = client.createLocalReferencePosition(segoff.segment, segoff.offset, refType, undefined, slidingPreference);
509
- return ref;
510
- }
511
- // Creating references on detached segments is allowed for:
512
- // - Transient segments
513
- // - References coming from a remote client (location may have been concurrently removed)
514
- // - References being rebased to a new sequence number
515
- // (segment they originally referred to may have been removed with no suitable replacement)
516
- if (!op &&
517
- !localSeq &&
518
- !fromSnapshot &&
519
- !(0, merge_tree_1.refTypeIncludesFlag)(refType, merge_tree_1.ReferenceType.Transient)) {
520
- throw new container_utils_1.UsageError("Non-transient references need segment");
521
- }
522
- return (0, merge_tree_1.createDetachedLocalReferencePosition)(refType);
523
- }
524
- exports.createPositionReferenceFromSegoff = createPositionReferenceFromSegoff;
525
- function createPositionReference(client, pos, refType, op, fromSnapshot, localSeq, slidingPreference) {
526
- let segoff;
527
- if (op) {
528
- (0, common_utils_1.assert)((refType & merge_tree_1.ReferenceType.SlideOnRemove) !== 0, 0x2f5 /* op create references must be SlideOnRemove */);
529
- segoff = client.getContainingSegment(pos, {
530
- referenceSequenceNumber: op.referenceSequenceNumber,
531
- clientId: op.clientId,
532
- });
533
- segoff = (0, merge_tree_1.getSlideToSegoff)(segoff);
534
- }
535
- else {
536
- (0, common_utils_1.assert)((refType & merge_tree_1.ReferenceType.SlideOnRemove) === 0 || !!fromSnapshot, 0x2f6 /* SlideOnRemove references must be op created */);
537
- segoff = client.getContainingSegment(pos, undefined, localSeq);
538
- }
539
- return createPositionReferenceFromSegoff(client, segoff, refType, op, localSeq, fromSnapshot, slidingPreference);
540
- }
541
- function createSequenceInterval(label, start, end, client, intervalType, op, fromSnapshot, stickiness = exports.IntervalStickiness.END) {
542
- let beginRefType = merge_tree_1.ReferenceType.RangeBegin;
543
- let endRefType = merge_tree_1.ReferenceType.RangeEnd;
544
- if (intervalType === IntervalType.Transient) {
545
- beginRefType = merge_tree_1.ReferenceType.Transient;
546
- endRefType = merge_tree_1.ReferenceType.Transient;
547
- }
548
- else {
549
- if (intervalType === IntervalType.Nest) {
550
- beginRefType = merge_tree_1.ReferenceType.NestBegin;
551
- endRefType = merge_tree_1.ReferenceType.NestEnd;
552
- }
553
- // All non-transient interval references must eventually be SlideOnRemove
554
- // To ensure eventual consistency, they must start as StayOnRemove when
555
- // pending (created locally and creation op is not acked)
556
- if (op || fromSnapshot) {
557
- beginRefType |= merge_tree_1.ReferenceType.SlideOnRemove;
558
- endRefType |= merge_tree_1.ReferenceType.SlideOnRemove;
559
- }
560
- else {
561
- beginRefType |= merge_tree_1.ReferenceType.StayOnRemove;
562
- endRefType |= merge_tree_1.ReferenceType.StayOnRemove;
563
- }
564
- }
565
- const startLref = createPositionReference(client, start, beginRefType, op, fromSnapshot, undefined, startReferenceSlidingPreference(stickiness));
566
- const endLref = createPositionReference(client, end, endRefType, op, fromSnapshot, undefined, endReferenceSlidingPreference(stickiness));
567
- const rangeProp = {
568
- [merge_tree_1.reservedRangeLabelsKey]: [label],
569
- };
570
- startLref.addProperties(rangeProp);
571
- endLref.addProperties(rangeProp);
572
- const ival = new SequenceInterval(client, startLref, endLref, intervalType, rangeProp, stickiness);
573
- return ival;
574
- }
575
- exports.createSequenceInterval = createSequenceInterval;
576
60
  function createIntervalIndex() {
577
61
  const helpers = {
578
- compareEnds: compareIntervalEnds,
579
- create: createInterval,
62
+ compareEnds: (a, b) => a.end - b.end,
63
+ create: intervals_1.createInterval,
580
64
  };
581
65
  const lc = new LocalIntervalCollection(undefined, "", helpers);
582
66
  return lc;
583
67
  }
584
68
  exports.createIntervalIndex = createIntervalIndex;
585
- class IdIntervalIndex {
586
- constructor() {
587
- this.intervalIdMap = new Map();
588
- }
589
- add(interval) {
590
- const id = interval.getIntervalId();
591
- (0, common_utils_1.assert)(id !== undefined, 0x2c0 /* "ID must be created before adding interval to collection" */);
592
- // Make the ID immutable.
593
- Object.defineProperty(interval.properties, reservedIntervalIdKey, {
594
- configurable: false,
595
- enumerable: true,
596
- writable: false,
597
- });
598
- this.intervalIdMap.set(id, interval);
599
- }
600
- remove(interval) {
601
- const id = interval.getIntervalId();
602
- (0, common_utils_1.assert)(id !== undefined, 0x311 /* expected id to exist on interval */);
603
- this.intervalIdMap.delete(id);
604
- }
605
- getIntervalById(id) {
606
- return this.intervalIdMap.get(id);
607
- }
608
- [Symbol.iterator]() {
609
- return this.intervalIdMap.values();
610
- }
611
- }
612
- class EndpointIndex {
613
- constructor(client, helpers) {
614
- this.client = client;
615
- this.helpers = helpers;
616
- // eslint-disable-next-line @typescript-eslint/unbound-method
617
- this.endIntervalTree = new merge_tree_1.RedBlackTree(helpers.compareEnds);
618
- }
619
- previousInterval(pos) {
620
- const transientInterval = this.helpers.create("transient", pos, pos, this.client, IntervalType.Transient);
621
- const rbNode = this.endIntervalTree.floor(transientInterval);
622
- if (rbNode) {
623
- return rbNode.data;
624
- }
625
- }
626
- nextInterval(pos) {
627
- const transientInterval = this.helpers.create("transient", pos, pos, this.client, IntervalType.Transient);
628
- const rbNode = this.endIntervalTree.ceil(transientInterval);
629
- if (rbNode) {
630
- return rbNode.data;
631
- }
632
- }
633
- add(interval) {
634
- this.endIntervalTree.put(interval, interval);
635
- }
636
- remove(interval) {
637
- this.endIntervalTree.remove(interval);
638
- }
639
- }
640
- /**
641
- * Interface for intervals that have comparison override properties.
642
- */
643
- const forceCompare = Symbol();
644
- /**
645
- * Compares two objects based on their comparison override properties.
646
- * @returns A number indicating the order of the intervals (negative for a is lower than b, 0 for tie, positive for a is greater than b).
647
- */
648
- function compareOverrideables(a, b) {
649
- var _a, _b;
650
- const forceCompareA = (_a = a[forceCompare]) !== null && _a !== void 0 ? _a : 0;
651
- const forceCompareB = (_b = b[forceCompare]) !== null && _b !== void 0 ? _b : 0;
652
- return forceCompareA - forceCompareB;
653
- }
654
- class EndpointInRangeIndex {
655
- constructor(helpers, client) {
656
- this.helpers = helpers;
657
- this.client = client;
658
- this.intervalTree = new merge_tree_1.RedBlackTree((a, b) => {
659
- const compareEndsResult = helpers.compareEnds(a, b);
660
- if (compareEndsResult !== 0) {
661
- return compareEndsResult;
662
- }
663
- const overrideablesComparison = compareOverrideables(a, b);
664
- if (overrideablesComparison !== 0) {
665
- return overrideablesComparison;
666
- }
667
- const aId = a.getIntervalId();
668
- const bId = b.getIntervalId();
669
- if (aId !== undefined && bId !== undefined) {
670
- return aId.localeCompare(bId);
671
- }
672
- return 0;
673
- });
674
- }
675
- add(interval) {
676
- this.intervalTree.put(interval, interval);
677
- }
678
- remove(interval) {
679
- this.intervalTree.remove(interval);
680
- }
681
- findIntervalsWithEndpointInRange(start, end) {
682
- if (start <= 0 || start > end || this.intervalTree.isEmpty()) {
683
- return [];
684
- }
685
- const results = [];
686
- const action = (node) => {
687
- results.push(node.data);
688
- return true;
689
- };
690
- const transientStartInterval = this.helpers.create("transient", start, start, this.client, IntervalType.Transient);
691
- const transientEndInterval = this.helpers.create("transient", end, end, this.client, IntervalType.Transient);
692
- // Add comparison overrides to the transient intervals
693
- transientStartInterval[forceCompare] = -1;
694
- transientEndInterval[forceCompare] = 1;
695
- this.intervalTree.mapRange(action, results, transientStartInterval, transientEndInterval);
696
- return results;
697
- }
698
- }
699
- class StartpointInRangeIndex {
700
- constructor(helpers, client) {
701
- this.helpers = helpers;
702
- this.client = client;
703
- this.intervalTree = new merge_tree_1.RedBlackTree((a, b) => {
704
- (0, common_utils_1.assert)(typeof helpers.compareStarts === "function", 0x6d1 /* compareStarts does not exist in the helpers */);
705
- const compareStartsResult = helpers.compareStarts(a, b);
706
- if (compareStartsResult !== 0) {
707
- return compareStartsResult;
708
- }
709
- const overrideablesComparison = compareOverrideables(a, b);
710
- if (overrideablesComparison !== 0) {
711
- return overrideablesComparison;
712
- }
713
- const aId = a.getIntervalId();
714
- const bId = b.getIntervalId();
715
- if (aId !== undefined && bId !== undefined) {
716
- return aId.localeCompare(bId);
717
- }
718
- return 0;
719
- });
720
- }
721
- add(interval) {
722
- this.intervalTree.put(interval, interval);
723
- }
724
- remove(interval) {
725
- this.intervalTree.remove(interval);
726
- }
727
- findIntervalsWithStartpointInRange(start, end) {
728
- if (start <= 0 || start > end || this.intervalTree.isEmpty()) {
729
- return [];
730
- }
731
- const results = [];
732
- const action = (node) => {
733
- results.push(node.data);
734
- return true;
735
- };
736
- const transientStartInterval = this.helpers.create("transient", start, start, this.client, IntervalType.Transient);
737
- const transientEndInterval = this.helpers.create("transient", end, end, this.client, IntervalType.Transient);
738
- // Add comparison overrides to the transient intervals
739
- transientStartInterval[forceCompare] = -1;
740
- transientEndInterval[forceCompare] = 1;
741
- this.intervalTree.mapRange(action, results, transientStartInterval, transientEndInterval);
742
- return results;
743
- }
744
- }
745
- function createEndpointInRangeIndex(helpers, client) {
746
- return new EndpointInRangeIndex(helpers, client);
747
- }
748
- exports.createEndpointInRangeIndex = createEndpointInRangeIndex;
749
- function createStartpointInRangeIndex(helpers, client) {
750
- return new StartpointInRangeIndex(helpers, client);
751
- }
752
- exports.createStartpointInRangeIndex = createStartpointInRangeIndex;
753
69
  class LocalIntervalCollection {
754
70
  constructor(client, label, helpers,
755
71
  /** Callback invoked each time one of the endpoints of an interval slides. */
@@ -759,8 +75,8 @@ class LocalIntervalCollection {
759
75
  this.helpers = helpers;
760
76
  this.onPositionChange = onPositionChange;
761
77
  this.overlappingIntervalsIndex = (0, intervalIndex_1.createOverlappingIntervalsIndex)(client, helpers);
762
- this.idIntervalIndex = new IdIntervalIndex();
763
- this.endIntervalIndex = new EndpointIndex(client, helpers);
78
+ this.idIntervalIndex = (0, intervalIndex_1.createIdIntervalIndex)();
79
+ this.endIntervalIndex = (0, intervalIndex_1.createEndpointIndex)(client, helpers);
764
80
  this.indexes = new Set([
765
81
  this.overlappingIntervalsIndex,
766
82
  this.idIntervalIndex,
@@ -815,10 +131,10 @@ class LocalIntervalCollection {
815
131
  this.removeIntervalFromIndexes(interval);
816
132
  this.removeIntervalListeners(interval);
817
133
  }
818
- createInterval(start, end, intervalType, op, stickiness = exports.IntervalStickiness.END) {
134
+ createInterval(start, end, intervalType, op, stickiness = intervals_1.IntervalStickiness.END) {
819
135
  return this.helpers.create(this.label, start, end, this.client, intervalType, op, undefined, stickiness);
820
136
  }
821
- addInterval(start, end, intervalType, props, op, stickiness = exports.IntervalStickiness.END) {
137
+ addInterval(start, end, intervalType, props, op, stickiness = intervals_1.IntervalStickiness.END) {
822
138
  var _a;
823
139
  var _b;
824
140
  const interval = this.createInterval(start, end, intervalType, op, stickiness);
@@ -842,7 +158,7 @@ class LocalIntervalCollection {
842
158
  return interval;
843
159
  }
844
160
  linkEndpointsToInterval(interval) {
845
- if (interval instanceof SequenceInterval) {
161
+ if (interval instanceof intervals_1.SequenceInterval) {
846
162
  interval.start.addProperties({ interval });
847
163
  interval.end.addProperties({ interval });
848
164
  }
@@ -883,7 +199,7 @@ class LocalIntervalCollection {
883
199
  }
884
200
  return this.client.createLocalReferencePosition(segment, ref.getOffset(), merge_tree_1.ReferenceType.Transient, ref.properties, ref.slidingPreference);
885
201
  };
886
- if (interval instanceof SequenceInterval) {
202
+ if (interval instanceof intervals_1.SequenceInterval) {
887
203
  let previousInterval;
888
204
  let pendingChanges = 0;
889
205
  interval.addPositionChangeListeners(() => {
@@ -908,30 +224,16 @@ class LocalIntervalCollection {
908
224
  }
909
225
  }
910
226
  removeIntervalListeners(interval) {
911
- if (interval instanceof SequenceInterval) {
227
+ if (interval instanceof intervals_1.SequenceInterval) {
912
228
  interval.removePositionChangeListeners();
913
229
  }
914
230
  }
915
231
  }
916
232
  exports.LocalIntervalCollection = LocalIntervalCollection;
917
233
  LocalIntervalCollection.legacyIdPrefix = "legacy";
918
- const compareSequenceIntervalEnds = (a, b) => (0, merge_tree_1.compareReferencePositions)(a.end, b.end);
919
- exports.compareSequenceIntervalEnds = compareSequenceIntervalEnds;
920
- const compareSequenceIntervalStarts = (a, b) => (0, merge_tree_1.compareReferencePositions)(a.start, b.start);
921
- exports.compareSequenceIntervalStarts = compareSequenceIntervalStarts;
922
- exports.sequenceIntervalHelpers = {
923
- compareEnds: exports.compareSequenceIntervalEnds,
924
- compareStarts: exports.compareSequenceIntervalStarts,
925
- create: createSequenceInterval,
926
- };
927
- exports.intervalHelpers = {
928
- compareEnds: (a, b) => a.end - b.end,
929
- compareStarts: (a, b) => a.start - b.start,
930
- create: createInterval,
931
- };
932
234
  class SequenceIntervalCollectionFactory {
933
235
  load(emitter, raw = [], options) {
934
- return new IntervalCollection(exports.sequenceIntervalHelpers, true, emitter, raw, options);
236
+ return new IntervalCollection(intervals_1.sequenceIntervalHelpers, true, emitter, raw, options);
935
237
  }
936
238
  store(value) {
937
239
  return value.serializeInternal();
@@ -952,19 +254,11 @@ exports.SequenceIntervalCollectionValueType = SequenceIntervalCollectionValueTyp
952
254
  SequenceIntervalCollectionValueType.Name = "sharedStringIntervalCollection";
953
255
  SequenceIntervalCollectionValueType._factory = new SequenceIntervalCollectionFactory();
954
256
  SequenceIntervalCollectionValueType._ops = makeOpsMap();
955
- const compareIntervalEnds = (a, b) => a.end - b.end;
956
- function createInterval(label, start, end, client, intervalType, op, fromSnapshot) {
957
- const rangeProp = {};
958
- if (label && label.length > 0) {
959
- rangeProp[merge_tree_1.reservedRangeLabelsKey] = [label];
960
- }
961
- return new Interval(start, end, rangeProp);
962
- }
963
257
  class IntervalCollectionFactory {
964
258
  load(emitter, raw = [], options) {
965
259
  const helpers = {
966
- compareEnds: compareIntervalEnds,
967
- create: createInterval,
260
+ compareEnds: (a, b) => a.end - b.end,
261
+ create: intervals_1.createInterval,
968
262
  };
969
263
  const collection = new IntervalCollection(helpers, false, emitter, raw, options);
970
264
  collection.attachGraph(undefined, "");
@@ -998,7 +292,7 @@ function makeOpsMap() {
998
292
  };
999
293
  return new Map([
1000
294
  [
1001
- exports.IntervalOpType.ADD,
295
+ intervals_1.IntervalOpType.ADD,
1002
296
  {
1003
297
  process: (collection, params, local, op, localOpMetadata) => {
1004
298
  // if params is undefined, the interval was deleted during
@@ -1013,7 +307,7 @@ function makeOpsMap() {
1013
307
  },
1014
308
  ],
1015
309
  [
1016
- exports.IntervalOpType.DELETE,
310
+ intervals_1.IntervalOpType.DELETE,
1017
311
  {
1018
312
  process: (collection, params, local, op) => {
1019
313
  (0, common_utils_1.assert)(op !== undefined, 0x3fc /* op should exist here */);
@@ -1026,7 +320,7 @@ function makeOpsMap() {
1026
320
  },
1027
321
  ],
1028
322
  [
1029
- exports.IntervalOpType.CHANGE,
323
+ intervals_1.IntervalOpType.CHANGE,
1030
324
  {
1031
325
  process: (collection, params, local, op, localOpMetadata) => {
1032
326
  // if params is undefined, the interval was deleted during
@@ -1194,7 +488,7 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
1194
488
  // is restored as single-endpoint changes re-use previous references.
1195
489
  let startRefType;
1196
490
  let endRefType;
1197
- if (previousInterval instanceof SequenceInterval) {
491
+ if (previousInterval instanceof intervals_1.SequenceInterval) {
1198
492
  startRefType = previousInterval.start.refType;
1199
493
  endRefType = previousInterval.end.refType;
1200
494
  previousInterval.start.refType = merge_tree_1.ReferenceType.Transient;
@@ -1219,15 +513,15 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
1219
513
  /**
1220
514
  * {@inheritdoc IIntervalCollection.add}
1221
515
  */
1222
- add(start, end, intervalType, props, stickiness = exports.IntervalStickiness.END) {
516
+ add(start, end, intervalType, props, stickiness = intervals_1.IntervalStickiness.END) {
1223
517
  var _a, _b;
1224
518
  if (!this.localCollection) {
1225
519
  throw new telemetry_utils_1.LoggingError("attach must be called prior to adding intervals");
1226
520
  }
1227
- if (intervalType & IntervalType.Transient) {
521
+ if (intervalType & intervals_1.IntervalType.Transient) {
1228
522
  throw new telemetry_utils_1.LoggingError("Can not add transient intervals");
1229
523
  }
1230
- if (stickiness !== exports.IntervalStickiness.END && !this.options.intervalStickinessEnabled) {
524
+ if (stickiness !== intervals_1.IntervalStickiness.END && !this.options.intervalStickinessEnabled) {
1231
525
  throw new container_utils_1.UsageError("attempted to set interval stickiness without enabling `intervalStickinessEnabled` feature flag");
1232
526
  }
1233
527
  const interval = this.localCollection.addInterval(start, end, intervalType, props, undefined, stickiness);
@@ -1530,7 +824,7 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
1530
824
  }
1531
825
  if (localInterval !== undefined) {
1532
826
  // we know we must be using `SequenceInterval` because `this.client` exists
1533
- (0, common_utils_1.assert)(localInterval instanceof SequenceInterval, 0x3a0 /* localInterval must be `SequenceInterval` when used with client */);
827
+ (0, common_utils_1.assert)(localInterval instanceof intervals_1.SequenceInterval, 0x3a0 /* localInterval must be `SequenceInterval` when used with client */);
1534
828
  // The rebased op may place this interval's endpoints on different segments. Calling `changeInterval` here
1535
829
  // updates the local client's state to be consistent with the emitted op.
1536
830
  (_f = this.localCollection) === null || _f === void 0 ? void 0 : _f.changeInterval(localInterval, startRebased, endRebased, undefined, localSeq);
@@ -1561,7 +855,7 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
1561
855
  ackInterval(interval, op) {
1562
856
  var _a, _b;
1563
857
  // Only SequenceIntervals need potential sliding
1564
- if (!(interval instanceof SequenceInterval)) {
858
+ if (!(interval instanceof intervals_1.SequenceInterval)) {
1565
859
  return;
1566
860
  }
1567
861
  if (!(0, merge_tree_1.refTypeIncludesFlag)(interval.start, merge_tree_1.ReferenceType.StayOnRemove) &&
@@ -1596,7 +890,7 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
1596
890
  }
1597
891
  if (needsStartUpdate) {
1598
892
  const props = interval.start.properties;
1599
- interval.start = createPositionReferenceFromSegoff(this.client, newStart, interval.start.refType, op, startReferenceSlidingPreference(interval.stickiness));
893
+ interval.start = (0, intervals_1.createPositionReferenceFromSegoff)(this.client, newStart, interval.start.refType, op, (0, intervals_1.startReferenceSlidingPreference)(interval.stickiness));
1600
894
  if (props) {
1601
895
  interval.start.addProperties(props);
1602
896
  }
@@ -1608,7 +902,7 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
1608
902
  }
1609
903
  if (needsEndUpdate) {
1610
904
  const props = interval.end.properties;
1611
- interval.end = createPositionReferenceFromSegoff(this.client, newEnd, interval.end.refType, op, endReferenceSlidingPreference(interval.stickiness));
905
+ interval.end = (0, intervals_1.createPositionReferenceFromSegoff)(this.client, newEnd, interval.end.refType, op, (0, intervals_1.endReferenceSlidingPreference)(interval.stickiness));
1612
906
  if (props) {
1613
907
  interval.end.addProperties(props);
1614
908
  }
@@ -1683,6 +977,8 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
1683
977
  }
1684
978
  /**
1685
979
  * {@inheritdoc IIntervalCollection.CreateForwardIteratorWithStartPosition}
980
+ *
981
+ * @deprecated - The sequence order of collection order will not be supported
1686
982
  */
1687
983
  CreateForwardIteratorWithStartPosition(startPosition) {
1688
984
  const iterator = new IntervalCollectionIterator(this, true, startPosition);
@@ -1690,6 +986,8 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
1690
986
  }
1691
987
  /**
1692
988
  * {@inheritdoc IIntervalCollection.CreateBackwardIteratorWithStartPosition}
989
+ *
990
+ * @deprecated - The sequence order of collection order will not be supported
1693
991
  */
1694
992
  CreateBackwardIteratorWithStartPosition(startPosition) {
1695
993
  const iterator = new IntervalCollectionIterator(this, false, startPosition);
@@ -1697,6 +995,8 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
1697
995
  }
1698
996
  /**
1699
997
  * {@inheritdoc IIntervalCollection.CreateForwardIteratorWithEndPosition}
998
+ *
999
+ * @deprecated - The sequence order of collection order will not be supported
1700
1000
  */
1701
1001
  CreateForwardIteratorWithEndPosition(endPosition) {
1702
1002
  const iterator = new IntervalCollectionIterator(this, true, undefined, endPosition);
@@ -1704,6 +1004,8 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
1704
1004
  }
1705
1005
  /**
1706
1006
  * {@inheritdoc IIntervalCollection.CreateBackwardIteratorWithEndPosition}
1007
+ *
1008
+ * @deprecated - The sequence order of collection order will not be supported
1707
1009
  */
1708
1010
  CreateBackwardIteratorWithEndPosition(endPosition) {
1709
1011
  const iterator = new IntervalCollectionIterator(this, false, undefined, endPosition);
@@ -1711,6 +1013,8 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
1711
1013
  }
1712
1014
  /**
1713
1015
  * {@inheritdoc IIntervalCollection.gatherIterationResults}
1016
+ * @deprecated - This API will be deprecated as its functionality will be moved to the `OverlappingIntervalsIndex`.
1017
+ * We would like the user to attach the index to the collection on their own.
1714
1018
  */
1715
1019
  gatherIterationResults(results, iteratesForward, start, end) {
1716
1020
  if (!this.localCollection) {
@@ -1720,6 +1024,8 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
1720
1024
  }
1721
1025
  /**
1722
1026
  * {@inheritdoc IIntervalCollection.findOverlappingIntervals}
1027
+ * @deprecated - This API will be deprecated as its functionality will be moved to the `OverlappingIntervalsIndex`.
1028
+ * We would like the user to attach the index to the collection on their own.
1723
1029
  */
1724
1030
  findOverlappingIntervals(startPosition, endPosition) {
1725
1031
  if (!this.localCollection) {
@@ -1740,6 +1046,9 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
1740
1046
  }
1741
1047
  /**
1742
1048
  * {@inheritdoc IIntervalCollection.previousInterval}
1049
+ *
1050
+ * @deprecated - This API will be deprecated as its functionality will be moved to the `EndpointIndex`.
1051
+ * We would like the user to attach the index to the collection on their own.
1743
1052
  */
1744
1053
  previousInterval(pos) {
1745
1054
  if (!this.localCollection) {
@@ -1749,6 +1058,9 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
1749
1058
  }
1750
1059
  /**
1751
1060
  * {@inheritdoc IIntervalCollection.nextInterval}
1061
+ *
1062
+ * @deprecated - This API will be deprecated as its functionality will be moved to the `EndpointIndex`.
1063
+ * We would like the user to attach the index to the collection on their own.
1752
1064
  */
1753
1065
  nextInterval(pos) {
1754
1066
  if (!this.localCollection) {