@fluidframework/sequence 2.0.0-dev.6.4.0.192049 → 2.0.0-dev.7.2.0.204906

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 (226) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/README.md +130 -0
  3. package/api-extractor.json +1 -1
  4. package/api-report/sequence.api.md +717 -0
  5. package/dist/defaultMap.d.ts +1 -1
  6. package/dist/defaultMap.d.ts.map +1 -1
  7. package/dist/defaultMap.js +6 -6
  8. package/dist/defaultMap.js.map +1 -1
  9. package/dist/defaultMapInterfaces.d.ts +22 -2
  10. package/dist/defaultMapInterfaces.d.ts.map +1 -1
  11. package/dist/defaultMapInterfaces.js.map +1 -1
  12. package/dist/index.d.ts +2 -2
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +2 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/intervalCollection.d.ts +164 -16
  17. package/dist/intervalCollection.d.ts.map +1 -1
  18. package/dist/intervalCollection.js +174 -54
  19. package/dist/intervalCollection.js.map +1 -1
  20. package/dist/intervalIndex/endpointInRangeIndex.d.ts +17 -3
  21. package/dist/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
  22. package/dist/intervalIndex/endpointInRangeIndex.js +12 -6
  23. package/dist/intervalIndex/endpointInRangeIndex.js.map +1 -1
  24. package/dist/intervalIndex/endpointIndex.d.ts +19 -2
  25. package/dist/intervalIndex/endpointIndex.d.ts.map +1 -1
  26. package/dist/intervalIndex/endpointIndex.js +10 -5
  27. package/dist/intervalIndex/endpointIndex.js.map +1 -1
  28. package/dist/intervalIndex/idIntervalIndex.d.ts +6 -0
  29. package/dist/intervalIndex/idIntervalIndex.d.ts.map +1 -1
  30. package/dist/intervalIndex/idIntervalIndex.js +3 -0
  31. package/dist/intervalIndex/idIntervalIndex.js.map +1 -1
  32. package/dist/intervalIndex/index.d.ts +4 -4
  33. package/dist/intervalIndex/index.d.ts.map +1 -1
  34. package/dist/intervalIndex/index.js +5 -1
  35. package/dist/intervalIndex/index.js.map +1 -1
  36. package/dist/intervalIndex/intervalIndex.d.ts +1 -0
  37. package/dist/intervalIndex/intervalIndex.d.ts.map +1 -1
  38. package/dist/intervalIndex/intervalIndex.js.map +1 -1
  39. package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +17 -6
  40. package/dist/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
  41. package/dist/intervalIndex/overlappingIntervalsIndex.js +17 -4
  42. package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  43. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +5 -2
  44. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
  45. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js +9 -1
  46. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  47. package/dist/intervalIndex/sequenceIntervalIndexes.d.ts +2 -1
  48. package/dist/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
  49. package/dist/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
  50. package/dist/intervalIndex/startpointInRangeIndex.d.ts +17 -3
  51. package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
  52. package/dist/intervalIndex/startpointInRangeIndex.js +12 -8
  53. package/dist/intervalIndex/startpointInRangeIndex.js.map +1 -1
  54. package/dist/intervalTree.d.ts +1 -1
  55. package/dist/intervalTree.d.ts.map +1 -1
  56. package/dist/intervals/interval.d.ts +4 -2
  57. package/dist/intervals/interval.d.ts.map +1 -1
  58. package/dist/intervals/interval.js +14 -5
  59. package/dist/intervals/interval.js.map +1 -1
  60. package/dist/intervals/intervalUtils.d.ts +51 -18
  61. package/dist/intervals/intervalUtils.d.ts.map +1 -1
  62. package/dist/intervals/intervalUtils.js +18 -10
  63. package/dist/intervals/intervalUtils.js.map +1 -1
  64. package/dist/intervals/sequenceInterval.d.ts +28 -13
  65. package/dist/intervals/sequenceInterval.d.ts.map +1 -1
  66. package/dist/intervals/sequenceInterval.js +124 -43
  67. package/dist/intervals/sequenceInterval.js.map +1 -1
  68. package/dist/localValues.d.ts.map +1 -1
  69. package/dist/localValues.js.map +1 -1
  70. package/dist/packageVersion.d.ts +1 -1
  71. package/dist/packageVersion.js +1 -1
  72. package/dist/packageVersion.js.map +1 -1
  73. package/dist/revertibles.d.ts +3 -15
  74. package/dist/revertibles.d.ts.map +1 -1
  75. package/dist/revertibles.js +11 -19
  76. package/dist/revertibles.js.map +1 -1
  77. package/dist/sequence-alpha.d.ts +1587 -0
  78. package/dist/sequence-beta.d.ts +1507 -0
  79. package/dist/sequence-public.d.ts +1507 -0
  80. package/dist/sequence-untrimmed.d.ts +1759 -0
  81. package/dist/sequence.d.ts +8 -4
  82. package/dist/sequence.d.ts.map +1 -1
  83. package/dist/sequence.js +53 -48
  84. package/dist/sequence.js.map +1 -1
  85. package/dist/sequenceDeltaEvent.d.ts +4 -0
  86. package/dist/sequenceDeltaEvent.d.ts.map +1 -1
  87. package/dist/sequenceDeltaEvent.js +3 -0
  88. package/dist/sequenceDeltaEvent.js.map +1 -1
  89. package/dist/sequenceFactory.d.ts +3 -0
  90. package/dist/sequenceFactory.d.ts.map +1 -1
  91. package/dist/sequenceFactory.js +4 -1
  92. package/dist/sequenceFactory.js.map +1 -1
  93. package/dist/sharedIntervalCollection.d.ts +5 -0
  94. package/dist/sharedIntervalCollection.d.ts.map +1 -1
  95. package/dist/sharedIntervalCollection.js +11 -9
  96. package/dist/sharedIntervalCollection.js.map +1 -1
  97. package/dist/sharedSequence.d.ts +6 -3
  98. package/dist/sharedSequence.d.ts.map +1 -1
  99. package/dist/sharedSequence.js +10 -8
  100. package/dist/sharedSequence.js.map +1 -1
  101. package/dist/sharedString.d.ts +17 -2
  102. package/dist/sharedString.d.ts.map +1 -1
  103. package/dist/sharedString.js +21 -7
  104. package/dist/sharedString.js.map +1 -1
  105. package/dist/tsdoc-metadata.json +1 -1
  106. package/lib/defaultMap.d.ts +1 -1
  107. package/lib/defaultMap.d.ts.map +1 -1
  108. package/lib/defaultMap.js +6 -6
  109. package/lib/defaultMap.js.map +1 -1
  110. package/lib/defaultMapInterfaces.d.ts +22 -2
  111. package/lib/defaultMapInterfaces.d.ts.map +1 -1
  112. package/lib/defaultMapInterfaces.js.map +1 -1
  113. package/lib/index.d.ts +2 -2
  114. package/lib/index.d.ts.map +1 -1
  115. package/lib/index.js +1 -1
  116. package/lib/index.js.map +1 -1
  117. package/lib/intervalCollection.d.ts +164 -16
  118. package/lib/intervalCollection.d.ts.map +1 -1
  119. package/lib/intervalCollection.js +172 -55
  120. package/lib/intervalCollection.js.map +1 -1
  121. package/lib/intervalIndex/endpointInRangeIndex.d.ts +17 -3
  122. package/lib/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
  123. package/lib/intervalIndex/endpointInRangeIndex.js +12 -7
  124. package/lib/intervalIndex/endpointInRangeIndex.js.map +1 -1
  125. package/lib/intervalIndex/endpointIndex.d.ts +19 -2
  126. package/lib/intervalIndex/endpointIndex.d.ts.map +1 -1
  127. package/lib/intervalIndex/endpointIndex.js +10 -6
  128. package/lib/intervalIndex/endpointIndex.js.map +1 -1
  129. package/lib/intervalIndex/idIntervalIndex.d.ts +6 -0
  130. package/lib/intervalIndex/idIntervalIndex.d.ts.map +1 -1
  131. package/lib/intervalIndex/idIntervalIndex.js +3 -0
  132. package/lib/intervalIndex/idIntervalIndex.js.map +1 -1
  133. package/lib/intervalIndex/index.d.ts +4 -4
  134. package/lib/intervalIndex/index.d.ts.map +1 -1
  135. package/lib/intervalIndex/index.js +4 -4
  136. package/lib/intervalIndex/index.js.map +1 -1
  137. package/lib/intervalIndex/intervalIndex.d.ts +1 -0
  138. package/lib/intervalIndex/intervalIndex.d.ts.map +1 -1
  139. package/lib/intervalIndex/intervalIndex.js.map +1 -1
  140. package/lib/intervalIndex/overlappingIntervalsIndex.d.ts +17 -6
  141. package/lib/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
  142. package/lib/intervalIndex/overlappingIntervalsIndex.js +18 -5
  143. package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  144. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +5 -2
  145. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
  146. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js +9 -1
  147. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  148. package/lib/intervalIndex/sequenceIntervalIndexes.d.ts +2 -1
  149. package/lib/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
  150. package/lib/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
  151. package/lib/intervalIndex/startpointInRangeIndex.d.ts +17 -3
  152. package/lib/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
  153. package/lib/intervalIndex/startpointInRangeIndex.js +12 -9
  154. package/lib/intervalIndex/startpointInRangeIndex.js.map +1 -1
  155. package/lib/intervalTree.d.ts +1 -1
  156. package/lib/intervalTree.d.ts.map +1 -1
  157. package/lib/intervals/interval.d.ts +4 -2
  158. package/lib/intervals/interval.d.ts.map +1 -1
  159. package/lib/intervals/interval.js +14 -5
  160. package/lib/intervals/interval.js.map +1 -1
  161. package/lib/intervals/intervalUtils.d.ts +51 -18
  162. package/lib/intervals/intervalUtils.d.ts.map +1 -1
  163. package/lib/intervals/intervalUtils.js +14 -6
  164. package/lib/intervals/intervalUtils.js.map +1 -1
  165. package/lib/intervals/sequenceInterval.d.ts +28 -13
  166. package/lib/intervals/sequenceInterval.d.ts.map +1 -1
  167. package/lib/intervals/sequenceInterval.js +125 -42
  168. package/lib/intervals/sequenceInterval.js.map +1 -1
  169. package/lib/localValues.d.ts.map +1 -1
  170. package/lib/localValues.js.map +1 -1
  171. package/lib/packageVersion.d.ts +1 -1
  172. package/lib/packageVersion.js +1 -1
  173. package/lib/packageVersion.js.map +1 -1
  174. package/lib/revertibles.d.ts +3 -15
  175. package/lib/revertibles.d.ts.map +1 -1
  176. package/lib/revertibles.js +11 -19
  177. package/lib/revertibles.js.map +1 -1
  178. package/lib/sequence.d.ts +8 -4
  179. package/lib/sequence.d.ts.map +1 -1
  180. package/lib/sequence.js +56 -49
  181. package/lib/sequence.js.map +1 -1
  182. package/lib/sequenceDeltaEvent.d.ts +4 -0
  183. package/lib/sequenceDeltaEvent.d.ts.map +1 -1
  184. package/lib/sequenceDeltaEvent.js +3 -0
  185. package/lib/sequenceDeltaEvent.js.map +1 -1
  186. package/lib/sequenceFactory.d.ts +3 -0
  187. package/lib/sequenceFactory.d.ts.map +1 -1
  188. package/lib/sequenceFactory.js +4 -1
  189. package/lib/sequenceFactory.js.map +1 -1
  190. package/lib/sharedIntervalCollection.d.ts +5 -0
  191. package/lib/sharedIntervalCollection.d.ts.map +1 -1
  192. package/lib/sharedIntervalCollection.js +11 -9
  193. package/lib/sharedIntervalCollection.js.map +1 -1
  194. package/lib/sharedSequence.d.ts +6 -3
  195. package/lib/sharedSequence.d.ts.map +1 -1
  196. package/lib/sharedSequence.js +10 -8
  197. package/lib/sharedSequence.js.map +1 -1
  198. package/lib/sharedString.d.ts +17 -2
  199. package/lib/sharedString.d.ts.map +1 -1
  200. package/lib/sharedString.js +21 -7
  201. package/lib/sharedString.js.map +1 -1
  202. package/package.json +31 -30
  203. package/src/defaultMapInterfaces.ts +22 -2
  204. package/src/index.ts +4 -1
  205. package/src/intervalCollection.ts +423 -82
  206. package/src/intervalIndex/endpointInRangeIndex.ts +23 -11
  207. package/src/intervalIndex/endpointIndex.ts +22 -9
  208. package/src/intervalIndex/idIntervalIndex.ts +7 -1
  209. package/src/intervalIndex/index.ts +12 -3
  210. package/src/intervalIndex/intervalIndex.ts +1 -0
  211. package/src/intervalIndex/overlappingIntervalsIndex.ts +40 -15
  212. package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +10 -1
  213. package/src/intervalIndex/sequenceIntervalIndexes.ts +2 -1
  214. package/src/intervalIndex/startpointInRangeIndex.ts +23 -18
  215. package/src/intervals/interval.ts +35 -8
  216. package/src/intervals/intervalUtils.ts +61 -27
  217. package/src/intervals/sequenceInterval.ts +197 -47
  218. package/src/localValues.ts +4 -1
  219. package/src/packageVersion.ts +1 -1
  220. package/src/revertibles.ts +14 -36
  221. package/src/sequence.ts +14 -5
  222. package/src/sequenceDeltaEvent.ts +4 -0
  223. package/src/sequenceFactory.ts +4 -1
  224. package/src/sharedIntervalCollection.ts +5 -0
  225. package/src/sharedSequence.ts +6 -3
  226. package/src/sharedString.ts +25 -2
@@ -3,19 +3,42 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  /* eslint-disable no-bitwise */
6
- import { PropertiesManager, ReferenceType, compareReferencePositions, createDetachedLocalReferencePosition, createMap, getSlideToSegoff, maxReferencePosition, minReferencePosition, refTypeIncludesFlag, reservedRangeLabelsKey, } from "@fluidframework/merge-tree";
6
+ /* eslint-disable import/no-deprecated */
7
+ import { PropertiesManager, ReferenceType, SlidingPreference, compareReferencePositions, createDetachedLocalReferencePosition, createMap, getSlideToSegoff, maxReferencePosition, minReferencePosition, refTypeIncludesFlag, reservedRangeLabelsKey, } from "@fluidframework/merge-tree";
7
8
  import { assert } from "@fluidframework/core-utils";
8
9
  import { UsageError } from "@fluidframework/telemetry-utils";
9
- import { IntervalStickiness, IntervalType, endReferenceSlidingPreference, startReferenceSlidingPreference, } from "./intervalUtils";
10
+ import { Side, computeStickinessFromSide, endpointPosAndSide, sidesFromStickiness, } from "../intervalCollection";
11
+ import { IntervalType, endReferenceSlidingPreference, startReferenceSlidingPreference, } from "./intervalUtils";
10
12
  const reservedIntervalIdKey = "intervalId";
13
+ function compareSides(sideA, sideB) {
14
+ if (sideA === sideB) {
15
+ return 0;
16
+ }
17
+ if (sideA === Side.Before) {
18
+ return 1;
19
+ }
20
+ return -1;
21
+ }
22
+ function minSide(sideA, sideB) {
23
+ if (sideA === Side.After && sideB === Side.After) {
24
+ return Side.After;
25
+ }
26
+ return Side.Before;
27
+ }
28
+ function maxSide(sideA, sideB) {
29
+ if (sideA === Side.Before && sideB === Side.Before) {
30
+ return Side.Before;
31
+ }
32
+ return Side.After;
33
+ }
11
34
  /**
12
35
  * Interval implementation whose ends are associated with positions in a mutatable sequence.
13
36
  * As such, when content is inserted into the middle of the interval, the interval expands to
14
37
  * include that content.
15
38
  *
16
- * @remarks The endpoint's position should be treated exclusively to get reasonable behavior--i.e.
17
- * an interval referring to "hello" in "hello world" should have a start position of 0 and an end
18
- * position of 5.
39
+ * @remarks The endpoints' positions should be treated exclusively to get
40
+ * reasonable behavior. E.g., an interval referring to "hello" in "hello world"
41
+ * should have a start position of 0 and an end position of 5.
19
42
  *
20
43
  * To see why, consider what happens if "llo wor" is removed from the string to make "held".
21
44
  * The interval's startpoint remains on the "h" (it isn't altered), but the interval's endpoint
@@ -25,11 +48,26 @@ const reservedIntervalIdKey = "intervalId";
25
48
  * If the interval endpoint was treated inclusively, the interval would now refer to "hel", which
26
49
  * is undesirable.
27
50
  *
28
- * Since the end of an interval is treated exclusively but cannot be greater than or equal to the
29
- * length of the associated sequence, application models which leverage interval collections should
30
- * consider inserting a marker at the end of the sequence to represent the end of the content.
51
+ * Since the endpoints of an interval are treated exclusively but cannot be greater
52
+ * than or equal to the length of the associated sequence, there exist special
53
+ * endpoint segments, "start" and "end", which represent the position immediately
54
+ * before or immediately after the string respectively.
55
+ *
56
+ * If a `SequenceInterval` is created on a sequence with the
57
+ * `mergeTreeReferencesCanSlideToEndpoint` feature flag set to true, the endpoints
58
+ * of the interval that are exclusive will have the ability to slide to these
59
+ * special endpoint segments.
60
+ * @public
31
61
  */
32
62
  export class SequenceInterval {
63
+ /**
64
+ * @internal
65
+ */
66
+ get stickiness() {
67
+ const startSegment = this.start.getSegment();
68
+ const endSegment = this.end.getSegment();
69
+ return computeStickinessFromSide(startSegment?.endpointType, this.startSide, endSegment?.endpointType, this.endSide);
70
+ }
33
71
  constructor(client,
34
72
  /**
35
73
  * Start endpoint of this interval.
@@ -40,12 +78,13 @@ export class SequenceInterval {
40
78
  * End endpoint of this interval.
41
79
  * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
42
80
  */
43
- end, intervalType, props, stickiness = IntervalStickiness.END) {
81
+ end, intervalType, props, startSide = Side.Before, endSide = Side.Before) {
44
82
  this.client = client;
45
83
  this.start = start;
46
84
  this.end = end;
47
85
  this.intervalType = intervalType;
48
- this.stickiness = stickiness;
86
+ this.startSide = startSide;
87
+ this.endSide = endSide;
49
88
  this.propertyManager = new PropertiesManager();
50
89
  this.properties = {};
51
90
  if (props) {
@@ -87,25 +126,26 @@ export class SequenceInterval {
87
126
  serialize() {
88
127
  const startPosition = this.client.localReferencePositionToPosition(this.start);
89
128
  const endPosition = this.client.localReferencePositionToPosition(this.end);
129
+ const { startSide, endSide } = sidesFromStickiness(this.stickiness);
90
130
  const serializedInterval = {
91
131
  end: endPosition,
92
132
  intervalType: this.intervalType,
93
133
  sequenceNumber: this.client.getCurrentSeq(),
94
134
  start: startPosition,
135
+ stickiness: this.stickiness,
136
+ startSide,
137
+ endSide,
95
138
  };
96
139
  if (this.properties) {
97
140
  serializedInterval.properties = this.properties;
98
141
  }
99
- if (this.stickiness !== IntervalStickiness.END) {
100
- serializedInterval.stickiness = this.stickiness;
101
- }
102
142
  return serializedInterval;
103
143
  }
104
144
  /**
105
145
  * {@inheritDoc IInterval.clone}
106
146
  */
107
147
  clone() {
108
- return new SequenceInterval(this.client, this.start, this.end, this.intervalType, this.properties, this.stickiness);
148
+ return new SequenceInterval(this.client, this.start, this.end, this.intervalType, this.properties, this.startSide, this.endSide);
109
149
  }
110
150
  /**
111
151
  * {@inheritDoc IInterval.compare}
@@ -137,13 +177,21 @@ export class SequenceInterval {
137
177
  * {@inheritDoc IInterval.compareStart}
138
178
  */
139
179
  compareStart(b) {
140
- return compareReferencePositions(this.start, b.start);
180
+ const dist = compareReferencePositions(this.start, b.start);
181
+ if (dist === 0) {
182
+ return compareSides(this.startSide, b.startSide);
183
+ }
184
+ return dist;
141
185
  }
142
186
  /**
143
187
  * {@inheritDoc IInterval.compareEnd}
144
188
  */
145
189
  compareEnd(b) {
146
- return compareReferencePositions(this.end, b.end);
190
+ const dist = compareReferencePositions(this.end, b.end);
191
+ if (dist === 0) {
192
+ return compareSides(b.endSide, this.endSide);
193
+ }
194
+ return dist;
147
195
  }
148
196
  /**
149
197
  * {@inheritDoc IInterval.overlaps}
@@ -166,7 +214,23 @@ export class SequenceInterval {
166
214
  * @internal
167
215
  */
168
216
  union(b) {
169
- return new SequenceInterval(this.client, minReferencePosition(this.start, b.start), maxReferencePosition(this.end, b.end), this.intervalType);
217
+ const newStart = minReferencePosition(this.start, b.start);
218
+ const newEnd = maxReferencePosition(this.end, b.end);
219
+ let startSide;
220
+ if (this.start === b.start) {
221
+ startSide = minSide(this.startSide, b.startSide);
222
+ }
223
+ else {
224
+ startSide = this.start === newStart ? this.startSide : b.startSide;
225
+ }
226
+ let endSide;
227
+ if (this.end === b.end) {
228
+ endSide = maxSide(this.endSide, b.endSide);
229
+ }
230
+ else {
231
+ endSide = this.end === newEnd ? this.endSide : b.endSide;
232
+ }
233
+ return new SequenceInterval(this.client, newStart, newEnd, this.intervalType, undefined, startSide, endSide);
170
234
  }
171
235
  /**
172
236
  * {@inheritDoc ISerializableInterval.addProperties}
@@ -188,7 +252,9 @@ export class SequenceInterval {
188
252
  * {@inheritDoc IInterval.modify}
189
253
  * @internal
190
254
  */
191
- modify(label, start, end, op, localSeq, stickiness = IntervalStickiness.END) {
255
+ modify(label, start, end, op, localSeq, useNewSlidingBehavior = false) {
256
+ const { startSide, endSide, startPos, endPos } = endpointPosAndSide(start, end);
257
+ const stickiness = computeStickinessFromSide(startPos ?? this.start.getSegment()?.endpointType, startSide ?? this.startSide, endPos ?? this.end.getSegment()?.endpointType, endSide ?? this.endSide);
192
258
  const getRefType = (baseType) => {
193
259
  let refType = baseType;
194
260
  if (op === undefined) {
@@ -198,20 +264,20 @@ export class SequenceInterval {
198
264
  return refType;
199
265
  };
200
266
  let startRef = this.start;
201
- if (start !== undefined) {
202
- startRef = createPositionReference(this.client, start, getRefType(this.start.refType), op, undefined, localSeq, startReferenceSlidingPreference(stickiness));
267
+ if (startPos !== undefined) {
268
+ startRef = createPositionReference(this.client, startPos, getRefType(this.start.refType), op, undefined, localSeq, startReferenceSlidingPreference(stickiness), startReferenceSlidingPreference(stickiness) === SlidingPreference.BACKWARD, useNewSlidingBehavior);
203
269
  if (this.start.properties) {
204
270
  startRef.addProperties(this.start.properties);
205
271
  }
206
272
  }
207
273
  let endRef = this.end;
208
- if (end !== undefined) {
209
- endRef = createPositionReference(this.client, end, getRefType(this.end.refType), op, undefined, localSeq, endReferenceSlidingPreference(stickiness));
274
+ if (endPos !== undefined) {
275
+ endRef = createPositionReference(this.client, endPos, getRefType(this.end.refType), op, undefined, localSeq, endReferenceSlidingPreference(stickiness), endReferenceSlidingPreference(stickiness) === SlidingPreference.FORWARD, useNewSlidingBehavior);
210
276
  if (this.end.properties) {
211
277
  endRef.addProperties(this.end.properties);
212
278
  }
213
279
  }
214
- const newInterval = new SequenceInterval(this.client, startRef, endRef, this.intervalType);
280
+ const newInterval = new SequenceInterval(this.client, startRef, endRef, this.intervalType, undefined, startSide ?? this.startSide, endSide ?? this.endSide);
215
281
  if (this.properties) {
216
282
  newInterval.initializeProperties();
217
283
  this.propertyManager.copyTo(this.properties, newInterval.properties, newInterval.propertyManager);
@@ -227,9 +293,12 @@ export class SequenceInterval {
227
293
  }
228
294
  }
229
295
  }
230
- export function createPositionReferenceFromSegoff(client, segoff, refType, op, localSeq, fromSnapshot, slidingPreference) {
296
+ export function createPositionReferenceFromSegoff(client, segoff, refType, op, localSeq, fromSnapshot, slidingPreference, canSlideToEndpoint) {
297
+ if (segoff === "start" || segoff === "end") {
298
+ return client.createLocalReferencePosition(segoff, undefined, refType, undefined, slidingPreference, canSlideToEndpoint);
299
+ }
231
300
  if (segoff.segment) {
232
- const ref = client.createLocalReferencePosition(segoff.segment, segoff.offset, refType, undefined, slidingPreference);
301
+ const ref = client.createLocalReferencePosition(segoff.segment, segoff.offset, refType, undefined, slidingPreference, canSlideToEndpoint);
233
302
  return ref;
234
303
  }
235
304
  // Creating references on detached segments is allowed for:
@@ -245,23 +314,37 @@ export function createPositionReferenceFromSegoff(client, segoff, refType, op, l
245
314
  }
246
315
  return createDetachedLocalReferencePosition(refType);
247
316
  }
248
- function createPositionReference(client, pos, refType, op, fromSnapshot, localSeq, slidingPreference) {
317
+ function createPositionReference(client, pos, refType, op, fromSnapshot, localSeq, slidingPreference, exclusive = false, useNewSlidingBehavior = false) {
249
318
  let segoff;
250
319
  if (op) {
251
320
  assert((refType & ReferenceType.SlideOnRemove) !== 0, 0x2f5 /* op create references must be SlideOnRemove */);
252
- segoff = client.getContainingSegment(pos, {
253
- referenceSequenceNumber: op.referenceSequenceNumber,
254
- clientId: op.clientId,
255
- });
256
- segoff = getSlideToSegoff(segoff);
321
+ if (pos === "start" || pos === "end") {
322
+ segoff = pos;
323
+ }
324
+ else {
325
+ segoff = client.getContainingSegment(pos, {
326
+ referenceSequenceNumber: op.referenceSequenceNumber,
327
+ clientId: op.clientId,
328
+ });
329
+ segoff = getSlideToSegoff(segoff, undefined, useNewSlidingBehavior);
330
+ }
257
331
  }
258
332
  else {
259
333
  assert((refType & ReferenceType.SlideOnRemove) === 0 || !!fromSnapshot, 0x2f6 /* SlideOnRemove references must be op created */);
260
- segoff = client.getContainingSegment(pos, undefined, localSeq);
334
+ segoff =
335
+ pos === "start" || pos === "end"
336
+ ? pos
337
+ : client.getContainingSegment(pos, undefined, localSeq);
261
338
  }
262
- return createPositionReferenceFromSegoff(client, segoff, refType, op, localSeq, fromSnapshot, slidingPreference);
339
+ return createPositionReferenceFromSegoff(client, segoff, refType, op, localSeq, fromSnapshot, slidingPreference, exclusive);
263
340
  }
264
- export function createSequenceInterval(label, start, end, client, intervalType, op, fromSnapshot, stickiness = IntervalStickiness.END) {
341
+ export function createSequenceInterval(label, start, end, client, intervalType, op, fromSnapshot, useNewSlidingBehavior = false) {
342
+ const { startPos, startSide, endPos, endSide } = endpointPosAndSide(start ?? "start", end ?? "end");
343
+ assert(startPos !== undefined &&
344
+ endPos !== undefined &&
345
+ startSide !== undefined &&
346
+ endSide !== undefined, 0x794 /* start and end cannot be undefined because they were not passed in as undefined */);
347
+ const stickiness = computeStickinessFromSide(startPos, startSide, endPos, endSide);
265
348
  let beginRefType = ReferenceType.RangeBegin;
266
349
  let endRefType = ReferenceType.RangeEnd;
267
350
  if (intervalType === IntervalType.Transient) {
@@ -276,7 +359,7 @@ export function createSequenceInterval(label, start, end, client, intervalType,
276
359
  // All non-transient interval references must eventually be SlideOnRemove
277
360
  // To ensure eventual consistency, they must start as StayOnRemove when
278
361
  // pending (created locally and creation op is not acked)
279
- if (op || fromSnapshot) {
362
+ if (op ?? fromSnapshot) {
280
363
  beginRefType |= ReferenceType.SlideOnRemove;
281
364
  endRefType |= ReferenceType.SlideOnRemove;
282
365
  }
@@ -285,21 +368,21 @@ export function createSequenceInterval(label, start, end, client, intervalType,
285
368
  endRefType |= ReferenceType.StayOnRemove;
286
369
  }
287
370
  }
288
- const startLref = createPositionReference(client, start, beginRefType, op, fromSnapshot, undefined, startReferenceSlidingPreference(stickiness));
289
- const endLref = createPositionReference(client, end, endRefType, op, fromSnapshot, undefined, endReferenceSlidingPreference(stickiness));
371
+ const startLref = createPositionReference(client, startPos, beginRefType, op, fromSnapshot, undefined, startReferenceSlidingPreference(stickiness), startReferenceSlidingPreference(stickiness) === SlidingPreference.BACKWARD, useNewSlidingBehavior);
372
+ const endLref = createPositionReference(client, endPos, endRefType, op, fromSnapshot, undefined, endReferenceSlidingPreference(stickiness), endReferenceSlidingPreference(stickiness) === SlidingPreference.FORWARD, useNewSlidingBehavior);
290
373
  const rangeProp = {
291
374
  [reservedRangeLabelsKey]: [label],
292
375
  };
293
376
  startLref.addProperties(rangeProp);
294
377
  endLref.addProperties(rangeProp);
295
- const ival = new SequenceInterval(client, startLref, endLref, intervalType, rangeProp, stickiness);
378
+ const ival = new SequenceInterval(client, startLref, endLref, intervalType, rangeProp, startSide, endSide);
296
379
  return ival;
297
380
  }
298
- export const compareSequenceIntervalEnds = (a, b) => compareReferencePositions(a.end, b.end);
299
- export const compareSequenceIntervalStarts = (a, b) => compareReferencePositions(a.start, b.start);
381
+ /**
382
+ * @deprecated The methods within have substitutions
383
+ * @public
384
+ */
300
385
  export const sequenceIntervalHelpers = {
301
- compareEnds: compareSequenceIntervalEnds,
302
- compareStarts: compareSequenceIntervalStarts,
303
386
  create: createSequenceInterval,
304
387
  };
305
388
  //# sourceMappingURL=sequenceInterval.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sequenceInterval.js","sourceRoot":"","sources":["../../src/intervals/sequenceInterval.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAE/B,OAAO,EAKN,iBAAiB,EAEjB,aAAa,EAEb,yBAAyB,EACzB,oCAAoC,EACpC,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAIN,kBAAkB,EAClB,YAAY,EACZ,6BAA6B,EAC7B,+BAA+B,GAC/B,MAAM,iBAAiB,CAAC;AAEzB,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,gBAAgB;IAW5B,YACkB,MAAc;IAC/B;;;OAGG;IACI,KAA6B;IACpC;;;OAGG;IACI,GAA2B,EAC3B,YAA0B,EACjC,KAAmB,EACH,aAAiC,kBAAkB,CAAC,GAAG;QAbtD,WAAM,GAAN,MAAM,CAAQ;QAKxB,UAAK,GAAL,KAAK,CAAwB;QAK7B,QAAG,GAAH,GAAG,CAA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SAAS,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAEjC,MAAM,IAAI,GAAG,IAAI,gBAAgB,CAChC,MAAM,EACN,SAAS,EACT,OAAO,EACP,YAAY,EACZ,SAAS,EACT,UAAU,CACV,CAAC;IACF,OAAO,IAAI,CAAC;AACb,CAAC;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAmB,EAAE,CAAmB,EAAU,EAAE,CAC/F,yBAAyB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AAEzC,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAmB,EAAE,CAAmB,EAAU,EAAE,CACjG,yBAAyB,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,uBAAuB,GAAuC;IAC1E,WAAW,EAAE,2BAA2B;IACxC,aAAa,EAAE,6BAA6B;IAC5C,MAAM,EAAE,sBAAsB;CAC9B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport {\n\tClient,\n\tICombiningOp,\n\tISegment,\n\tLocalReferencePosition,\n\tPropertiesManager,\n\tPropertySet,\n\tReferenceType,\n\tSlidingPreference,\n\tcompareReferencePositions,\n\tcreateDetachedLocalReferencePosition,\n\tcreateMap,\n\tgetSlideToSegoff,\n\tmaxReferencePosition,\n\tminReferencePosition,\n\trefTypeIncludesFlag,\n\treservedRangeLabelsKey,\n} from \"@fluidframework/merge-tree\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { UsageError } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIIntervalHelpers,\n\tISerializableInterval,\n\tISerializedInterval,\n\tIntervalStickiness,\n\tIntervalType,\n\tendReferenceSlidingPreference,\n\tstartReferenceSlidingPreference,\n} from \"./intervalUtils\";\n\nconst reservedIntervalIdKey = \"intervalId\";\n\n/**\n * Interval implementation whose ends are associated with positions in a mutatable sequence.\n * As such, when content is inserted into the middle of the interval, the interval expands to\n * include that content.\n *\n * @remarks The endpoint's position should be treated exclusively to get reasonable behavior--i.e.\n * an interval referring to \"hello\" in \"hello world\" should have a start position of 0 and an end\n * position of 5.\n *\n * To see why, consider what happens if \"llo wor\" is removed from the string to make \"held\".\n * The interval's startpoint remains on the \"h\" (it isn't altered), but the interval's endpoint\n * slides forward to the next unremoved position, which is the \"l\" in \"held\".\n * Users would generally expect the interval to now refer to \"he\" (as it is the subset of content\n * remaining after the removal), hence the \"l\" should be excluded.\n * If the interval endpoint was treated inclusively, the interval would now refer to \"hel\", which\n * is undesirable.\n *\n * Since the end of an interval is treated exclusively but cannot be greater than or equal to the\n * length of the associated sequence, application models which leverage interval collections should\n * consider inserting a marker at the end of the sequence to represent the end of the content.\n */\nexport class SequenceInterval implements ISerializableInterval {\n\t/**\n\t * {@inheritDoc ISerializableInterval.properties}\n\t */\n\tpublic properties: PropertySet;\n\t/**\n\t * {@inheritDoc ISerializableInterval.propertyManager}\n\t * @internal\n\t */\n\tpublic propertyManager: PropertiesManager;\n\n\tconstructor(\n\t\tprivate readonly client: Client,\n\t\t/**\n\t\t * Start endpoint of this interval.\n\t\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t\t */\n\t\tpublic start: LocalReferencePosition,\n\t\t/**\n\t\t * End endpoint of this interval.\n\t\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t\t */\n\t\tpublic end: LocalReferencePosition,\n\t\tpublic intervalType: IntervalType,\n\t\tprops?: PropertySet,\n\t\tpublic readonly stickiness: IntervalStickiness = IntervalStickiness.END,\n\t) {\n\t\tthis.propertyManager = new PropertiesManager();\n\t\tthis.properties = {};\n\n\t\tif (props) {\n\t\t\tthis.addProperties(props);\n\t\t}\n\t}\n\n\tprivate callbacks?: Record<\"beforePositionChange\" | \"afterPositionChange\", () => void>;\n\n\t/**\n\t * Subscribes to position change events on this interval if there are no current listeners.\n\t * @internal\n\t */\n\tpublic addPositionChangeListeners(\n\t\tbeforePositionChange: () => void,\n\t\tafterPositionChange: () => void,\n\t): void {\n\t\tif (this.callbacks === undefined) {\n\t\t\tthis.callbacks = {\n\t\t\t\tbeforePositionChange,\n\t\t\t\tafterPositionChange,\n\t\t\t};\n\n\t\t\tconst startCbs = (this.start.callbacks ??= {});\n\t\t\tconst endCbs = (this.end.callbacks ??= {});\n\t\t\tstartCbs.beforeSlide = endCbs.beforeSlide = beforePositionChange;\n\t\t\tstartCbs.afterSlide = endCbs.afterSlide = afterPositionChange;\n\t\t}\n\t}\n\n\t/**\n\t * Removes the currently subscribed position change listeners.\n\t * @internal\n\t */\n\tpublic removePositionChangeListeners(): void {\n\t\tif (this.callbacks) {\n\t\t\tthis.callbacks = undefined;\n\t\t\tthis.start.callbacks = undefined;\n\t\t\tthis.end.callbacks = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.serialize}\n\t * @internal\n\t */\n\tpublic serialize(): ISerializedInterval {\n\t\tconst startPosition = this.client.localReferencePositionToPosition(this.start);\n\t\tconst endPosition = this.client.localReferencePositionToPosition(this.end);\n\t\tconst serializedInterval: ISerializedInterval = {\n\t\t\tend: endPosition,\n\t\t\tintervalType: this.intervalType,\n\t\t\tsequenceNumber: this.client.getCurrentSeq(),\n\t\t\tstart: startPosition,\n\t\t};\n\n\t\tif (this.properties) {\n\t\t\tserializedInterval.properties = this.properties;\n\t\t}\n\t\tif (this.stickiness !== IntervalStickiness.END) {\n\t\t\tserializedInterval.stickiness = this.stickiness;\n\t\t}\n\n\t\treturn serializedInterval;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.clone}\n\t */\n\tpublic clone() {\n\t\treturn new SequenceInterval(\n\t\t\tthis.client,\n\t\t\tthis.start,\n\t\t\tthis.end,\n\t\t\tthis.intervalType,\n\t\t\tthis.properties,\n\t\t\tthis.stickiness,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compare}\n\t */\n\tpublic compare(b: SequenceInterval) {\n\t\tconst startResult = this.compareStart(b);\n\t\tif (startResult === 0) {\n\t\t\tconst endResult = this.compareEnd(b);\n\t\t\tif (endResult === 0) {\n\t\t\t\tconst thisId = this.getIntervalId();\n\t\t\t\tif (thisId) {\n\t\t\t\t\tconst bId = b.getIntervalId();\n\t\t\t\t\tif (bId) {\n\t\t\t\t\t\treturn thisId > bId ? 1 : thisId < bId ? -1 : 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn endResult;\n\t\t\t}\n\t\t} else {\n\t\t\treturn startResult;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareStart}\n\t */\n\tpublic compareStart(b: SequenceInterval) {\n\t\treturn compareReferencePositions(this.start, b.start);\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareEnd}\n\t */\n\tpublic compareEnd(b: SequenceInterval) {\n\t\treturn compareReferencePositions(this.end, b.end);\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.overlaps}\n\t */\n\tpublic overlaps(b: SequenceInterval) {\n\t\tconst result =\n\t\t\tcompareReferencePositions(this.start, b.end) <= 0 &&\n\t\t\tcompareReferencePositions(this.end, b.start) >= 0;\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.getIntervalId}\n\t */\n\tpublic getIntervalId(): string {\n\t\tconst id = this.properties?.[reservedIntervalIdKey];\n\t\tassert(id !== undefined, 0x5e2 /* interval ID should not be undefined */);\n\t\treturn `${id}`;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.union}\n\t * @internal\n\t */\n\tpublic union(b: SequenceInterval) {\n\t\treturn new SequenceInterval(\n\t\t\tthis.client,\n\t\t\tminReferencePosition(this.start, b.start),\n\t\t\tmaxReferencePosition(this.end, b.end),\n\t\t\tthis.intervalType,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.addProperties}\n\t * @internal\n\t */\n\tpublic addProperties(\n\t\tnewProps: PropertySet,\n\t\tcollab: boolean = false,\n\t\tseq?: number,\n\t\top?: ICombiningOp,\n\t): PropertySet | undefined {\n\t\tthis.initializeProperties();\n\t\treturn this.propertyManager.addProperties(this.properties, newProps, op, seq, collab);\n\t}\n\n\t/**\n\t * @returns whether this interval overlaps two numerical positions.\n\t */\n\tpublic overlapsPos(bstart: number, bend: number) {\n\t\tconst startPos = this.client.localReferencePositionToPosition(this.start);\n\t\tconst endPos = this.client.localReferencePositionToPosition(this.end);\n\t\treturn endPos > bstart && startPos < bend;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.modify}\n\t * @internal\n\t */\n\tpublic modify(\n\t\tlabel: string,\n\t\tstart: number,\n\t\tend: number,\n\t\top?: ISequencedDocumentMessage,\n\t\tlocalSeq?: number,\n\t\tstickiness: IntervalStickiness = IntervalStickiness.END,\n\t) {\n\t\tconst getRefType = (baseType: ReferenceType): ReferenceType => {\n\t\t\tlet refType = baseType;\n\t\t\tif (op === undefined) {\n\t\t\t\trefType &= ~ReferenceType.SlideOnRemove;\n\t\t\t\trefType |= ReferenceType.StayOnRemove;\n\t\t\t}\n\t\t\treturn refType;\n\t\t};\n\n\t\tlet startRef = this.start;\n\t\tif (start !== undefined) {\n\t\t\tstartRef = createPositionReference(\n\t\t\t\tthis.client,\n\t\t\t\tstart,\n\t\t\t\tgetRefType(this.start.refType),\n\t\t\t\top,\n\t\t\t\tundefined,\n\t\t\t\tlocalSeq,\n\t\t\t\tstartReferenceSlidingPreference(stickiness),\n\t\t\t);\n\t\t\tif (this.start.properties) {\n\t\t\t\tstartRef.addProperties(this.start.properties);\n\t\t\t}\n\t\t}\n\n\t\tlet endRef = this.end;\n\t\tif (end !== undefined) {\n\t\t\tendRef = createPositionReference(\n\t\t\t\tthis.client,\n\t\t\t\tend,\n\t\t\t\tgetRefType(this.end.refType),\n\t\t\t\top,\n\t\t\t\tundefined,\n\t\t\t\tlocalSeq,\n\t\t\t\tendReferenceSlidingPreference(stickiness),\n\t\t\t);\n\t\t\tif (this.end.properties) {\n\t\t\t\tendRef.addProperties(this.end.properties);\n\t\t\t}\n\t\t}\n\n\t\tconst newInterval = new SequenceInterval(this.client, startRef, endRef, this.intervalType);\n\t\tif (this.properties) {\n\t\t\tnewInterval.initializeProperties();\n\t\t\tthis.propertyManager.copyTo(\n\t\t\t\tthis.properties,\n\t\t\t\tnewInterval.properties,\n\t\t\t\tnewInterval.propertyManager,\n\t\t\t);\n\t\t}\n\t\treturn newInterval;\n\t}\n\n\tprivate initializeProperties(): void {\n\t\tif (!this.propertyManager) {\n\t\t\tthis.propertyManager = new PropertiesManager();\n\t\t}\n\t\tif (!this.properties) {\n\t\t\tthis.properties = createMap<any>();\n\t\t}\n\t}\n}\n\nexport function createPositionReferenceFromSegoff(\n\tclient: Client,\n\tsegoff: { segment: ISegment | undefined; offset: number | undefined },\n\trefType: ReferenceType,\n\top?: ISequencedDocumentMessage,\n\tlocalSeq?: number,\n\tfromSnapshot?: boolean,\n\tslidingPreference?: SlidingPreference,\n): LocalReferencePosition {\n\tif (segoff.segment) {\n\t\tconst ref = client.createLocalReferencePosition(\n\t\t\tsegoff.segment,\n\t\t\tsegoff.offset,\n\t\t\trefType,\n\t\t\tundefined,\n\t\t\tslidingPreference,\n\t\t);\n\t\treturn ref;\n\t}\n\n\t// Creating references on detached segments is allowed for:\n\t// - Transient segments\n\t// - References coming from a remote client (location may have been concurrently removed)\n\t// - References being rebased to a new sequence number\n\t// (segment they originally referred to may have been removed with no suitable replacement)\n\tif (\n\t\t!op &&\n\t\t!localSeq &&\n\t\t!fromSnapshot &&\n\t\t!refTypeIncludesFlag(refType, ReferenceType.Transient)\n\t) {\n\t\tthrow new UsageError(\"Non-transient references need segment\");\n\t}\n\n\treturn createDetachedLocalReferencePosition(refType);\n}\n\nfunction createPositionReference(\n\tclient: Client,\n\tpos: number,\n\trefType: ReferenceType,\n\top?: ISequencedDocumentMessage,\n\tfromSnapshot?: boolean,\n\tlocalSeq?: number,\n\tslidingPreference?: SlidingPreference,\n): LocalReferencePosition {\n\tlet segoff;\n\tif (op) {\n\t\tassert(\n\t\t\t(refType & ReferenceType.SlideOnRemove) !== 0,\n\t\t\t0x2f5 /* op create references must be SlideOnRemove */,\n\t\t);\n\t\tsegoff = client.getContainingSegment(pos, {\n\t\t\treferenceSequenceNumber: op.referenceSequenceNumber,\n\t\t\tclientId: op.clientId,\n\t\t});\n\t\tsegoff = getSlideToSegoff(segoff);\n\t} else {\n\t\tassert(\n\t\t\t(refType & ReferenceType.SlideOnRemove) === 0 || !!fromSnapshot,\n\t\t\t0x2f6 /* SlideOnRemove references must be op created */,\n\t\t);\n\t\tsegoff = client.getContainingSegment(pos, undefined, localSeq);\n\t}\n\n\treturn createPositionReferenceFromSegoff(\n\t\tclient,\n\t\tsegoff,\n\t\trefType,\n\t\top,\n\t\tlocalSeq,\n\t\tfromSnapshot,\n\t\tslidingPreference,\n\t);\n}\n\nexport function createSequenceInterval(\n\tlabel: string,\n\tstart: number,\n\tend: number,\n\tclient: Client,\n\tintervalType: IntervalType,\n\top?: ISequencedDocumentMessage,\n\tfromSnapshot?: boolean,\n\tstickiness: IntervalStickiness = IntervalStickiness.END,\n): SequenceInterval {\n\tlet beginRefType = ReferenceType.RangeBegin;\n\tlet endRefType = ReferenceType.RangeEnd;\n\tif (intervalType === IntervalType.Transient) {\n\t\tbeginRefType = ReferenceType.Transient;\n\t\tendRefType = ReferenceType.Transient;\n\t} else {\n\t\tif (intervalType === IntervalType.Nest) {\n\t\t\tbeginRefType = ReferenceType.NestBegin;\n\t\t\tendRefType = ReferenceType.NestEnd;\n\t\t}\n\t\t// All non-transient interval references must eventually be SlideOnRemove\n\t\t// To ensure eventual consistency, they must start as StayOnRemove when\n\t\t// pending (created locally and creation op is not acked)\n\t\tif (op || fromSnapshot) {\n\t\t\tbeginRefType |= ReferenceType.SlideOnRemove;\n\t\t\tendRefType |= ReferenceType.SlideOnRemove;\n\t\t} else {\n\t\t\tbeginRefType |= ReferenceType.StayOnRemove;\n\t\t\tendRefType |= ReferenceType.StayOnRemove;\n\t\t}\n\t}\n\n\tconst startLref = createPositionReference(\n\t\tclient,\n\t\tstart,\n\t\tbeginRefType,\n\t\top,\n\t\tfromSnapshot,\n\t\tundefined,\n\t\tstartReferenceSlidingPreference(stickiness),\n\t);\n\n\tconst endLref = createPositionReference(\n\t\tclient,\n\t\tend,\n\t\tendRefType,\n\t\top,\n\t\tfromSnapshot,\n\t\tundefined,\n\t\tendReferenceSlidingPreference(stickiness),\n\t);\n\n\tconst rangeProp = {\n\t\t[reservedRangeLabelsKey]: [label],\n\t};\n\tstartLref.addProperties(rangeProp);\n\tendLref.addProperties(rangeProp);\n\n\tconst ival = new SequenceInterval(\n\t\tclient,\n\t\tstartLref,\n\t\tendLref,\n\t\tintervalType,\n\t\trangeProp,\n\t\tstickiness,\n\t);\n\treturn ival;\n}\n\nexport const compareSequenceIntervalEnds = (a: SequenceInterval, b: SequenceInterval): number =>\n\tcompareReferencePositions(a.end, b.end);\n\nexport const compareSequenceIntervalStarts = (a: SequenceInterval, b: SequenceInterval): number =>\n\tcompareReferencePositions(a.start, b.start);\n\nexport const sequenceIntervalHelpers: IIntervalHelpers<SequenceInterval> = {\n\tcompareEnds: compareSequenceIntervalEnds,\n\tcompareStarts: compareSequenceIntervalStarts,\n\tcreate: createSequenceInterval,\n};\n"]}
1
+ {"version":3,"file":"sequenceInterval.js","sourceRoot":"","sources":["../../src/intervals/sequenceInterval.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAC/B,yCAAyC;AAEzC,OAAO,EAKN,iBAAiB,EAEjB,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,oCAAoC,EACpC,SAAS,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YAAY,EAAE;YACvB,YAAY,IAAI,aAAa,CAAC,aAAa,CAAC;YAC5C,UAAU,IAAI,aAAa,CAAC,aAAa,CAAC;SAC1C;aAAM;YACN,YAAY,IAAI,aAAa,CAAC,YAAY,CAAC;YAC3C,UAAU,IAAI,aAAa,CAAC,YAAY,CAAC;SACzC;KACD;IAED,MAAM,SAAS,GAAG,uBAAuB,CACxC,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,EAAE,EACF,YAAY,EACZ,SAAS,EACT,+BAA+B,CAAC,UAAU,CAAC,EAC3C,+BAA+B,CAAC,UAAU,CAAC,KAAK,iBAAiB,CAAC,QAAQ,EAC1E,qBAAqB,CACrB,CAAC;IAEF,MAAM,OAAO,GAAG,uBAAuB,CACtC,MAAM,EACN,MAAM,EACN,UAAU,EACV,EAAE,EACF,YAAY,EACZ,SAAS,EACT,6BAA6B,CAAC,UAAU,CAAC,EACzC,6BAA6B,CAAC,UAAU,CAAC,KAAK,iBAAiB,CAAC,OAAO,EACvE,qBAAqB,CACrB,CAAC;IAEF,MAAM,SAAS,GAAG;QACjB,CAAC,sBAAsB,CAAC,EAAE,CAAC,KAAK,CAAC;KACjC,CAAC;IACF,SAAS,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAEjC,MAAM,IAAI,GAAG,IAAI,gBAAgB,CAChC,MAAM,EACN,SAAS,EACT,OAAO,EACP,YAAY,EACZ,SAAS,EACT,SAAS,EACT,OAAO,CACP,CAAC;IACF,OAAO,IAAI,CAAC;AACb,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAuC;IAC1E,MAAM,EAAE,sBAAsB;CAC9B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n/* eslint-disable import/no-deprecated */\n\nimport {\n\tClient,\n\tICombiningOp,\n\tISegment,\n\tLocalReferencePosition,\n\tPropertiesManager,\n\tPropertySet,\n\tReferenceType,\n\tSlidingPreference,\n\tcompareReferencePositions,\n\tcreateDetachedLocalReferencePosition,\n\tcreateMap,\n\tgetSlideToSegoff,\n\tmaxReferencePosition,\n\tminReferencePosition,\n\trefTypeIncludesFlag,\n\treservedRangeLabelsKey,\n} from \"@fluidframework/merge-tree\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { UsageError } from \"@fluidframework/telemetry-utils\";\nimport {\n\tSequencePlace,\n\tSide,\n\tcomputeStickinessFromSide,\n\tendpointPosAndSide,\n\tsidesFromStickiness,\n} from \"../intervalCollection\";\nimport {\n\tIIntervalHelpers,\n\tISerializableInterval,\n\tISerializedInterval,\n\tIntervalStickiness,\n\tIntervalType,\n\tendReferenceSlidingPreference,\n\tstartReferenceSlidingPreference,\n} from \"./intervalUtils\";\n\nconst reservedIntervalIdKey = \"intervalId\";\n\nfunction compareSides(sideA: Side, sideB: Side): number {\n\tif (sideA === sideB) {\n\t\treturn 0;\n\t}\n\n\tif (sideA === Side.Before) {\n\t\treturn 1;\n\t}\n\n\treturn -1;\n}\n\nfunction minSide(sideA: Side, sideB: Side): Side {\n\tif (sideA === Side.After && sideB === Side.After) {\n\t\treturn Side.After;\n\t}\n\n\treturn Side.Before;\n}\n\nfunction maxSide(sideA: Side, sideB: Side): Side {\n\tif (sideA === Side.Before && sideB === Side.Before) {\n\t\treturn Side.Before;\n\t}\n\n\treturn Side.After;\n}\n\n/**\n * Interval implementation whose ends are associated with positions in a mutatable sequence.\n * As such, when content is inserted into the middle of the interval, the interval expands to\n * include that content.\n *\n * @remarks The endpoints' positions should be treated exclusively to get\n * reasonable behavior. E.g., an interval referring to \"hello\" in \"hello world\"\n * should have a start position of 0 and an end position of 5.\n *\n * To see why, consider what happens if \"llo wor\" is removed from the string to make \"held\".\n * The interval's startpoint remains on the \"h\" (it isn't altered), but the interval's endpoint\n * slides forward to the next unremoved position, which is the \"l\" in \"held\".\n * Users would generally expect the interval to now refer to \"he\" (as it is the subset of content\n * remaining after the removal), hence the \"l\" should be excluded.\n * If the interval endpoint was treated inclusively, the interval would now refer to \"hel\", which\n * is undesirable.\n *\n * Since the endpoints of an interval are treated exclusively but cannot be greater\n * than or equal to the length of the associated sequence, there exist special\n * endpoint segments, \"start\" and \"end\", which represent the position immediately\n * before or immediately after the string respectively.\n *\n * If a `SequenceInterval` is created on a sequence with the\n * `mergeTreeReferencesCanSlideToEndpoint` feature flag set to true, the endpoints\n * of the interval that are exclusive will have the ability to slide to these\n * special endpoint segments.\n * @public\n */\nexport class SequenceInterval implements ISerializableInterval {\n\t/**\n\t * {@inheritDoc ISerializableInterval.properties}\n\t */\n\tpublic properties: PropertySet;\n\t/**\n\t * {@inheritDoc ISerializableInterval.propertyManager}\n\t * @internal\n\t */\n\tpublic propertyManager: PropertiesManager;\n\n\t/**\n\t * @internal\n\t */\n\tpublic get stickiness(): IntervalStickiness {\n\t\tconst startSegment = this.start.getSegment();\n\t\tconst endSegment = this.end.getSegment();\n\t\treturn computeStickinessFromSide(\n\t\t\tstartSegment?.endpointType,\n\t\t\tthis.startSide,\n\t\t\tendSegment?.endpointType,\n\t\t\tthis.endSide,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tprivate readonly client: Client,\n\t\t/**\n\t\t * Start endpoint of this interval.\n\t\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t\t */\n\t\tpublic start: LocalReferencePosition,\n\t\t/**\n\t\t * End endpoint of this interval.\n\t\t * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.\n\t\t */\n\t\tpublic end: LocalReferencePosition,\n\t\tpublic intervalType: IntervalType,\n\t\tprops?: PropertySet,\n\t\tpublic readonly startSide: Side = Side.Before,\n\t\tpublic readonly endSide: Side = Side.Before,\n\t) {\n\t\tthis.propertyManager = new PropertiesManager();\n\t\tthis.properties = {};\n\n\t\tif (props) {\n\t\t\tthis.addProperties(props);\n\t\t}\n\t}\n\n\tprivate callbacks?: Record<\"beforePositionChange\" | \"afterPositionChange\", () => void>;\n\n\t/**\n\t * Subscribes to position change events on this interval if there are no current listeners.\n\t * @internal\n\t */\n\tpublic addPositionChangeListeners(\n\t\tbeforePositionChange: () => void,\n\t\tafterPositionChange: () => void,\n\t): void {\n\t\tif (this.callbacks === undefined) {\n\t\t\tthis.callbacks = {\n\t\t\t\tbeforePositionChange,\n\t\t\t\tafterPositionChange,\n\t\t\t};\n\n\t\t\tconst startCbs = (this.start.callbacks ??= {});\n\t\t\tconst endCbs = (this.end.callbacks ??= {});\n\t\t\tstartCbs.beforeSlide = endCbs.beforeSlide = beforePositionChange;\n\t\t\tstartCbs.afterSlide = endCbs.afterSlide = afterPositionChange;\n\t\t}\n\t}\n\n\t/**\n\t * Removes the currently subscribed position change listeners.\n\t * @internal\n\t */\n\tpublic removePositionChangeListeners(): void {\n\t\tif (this.callbacks) {\n\t\t\tthis.callbacks = undefined;\n\t\t\tthis.start.callbacks = undefined;\n\t\t\tthis.end.callbacks = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.serialize}\n\t * @internal\n\t */\n\tpublic serialize(): ISerializedInterval {\n\t\tconst startPosition = this.client.localReferencePositionToPosition(this.start);\n\t\tconst endPosition = this.client.localReferencePositionToPosition(this.end);\n\t\tconst { startSide, endSide } = sidesFromStickiness(this.stickiness);\n\t\tconst serializedInterval: ISerializedInterval = {\n\t\t\tend: endPosition,\n\t\t\tintervalType: this.intervalType,\n\t\t\tsequenceNumber: this.client.getCurrentSeq(),\n\t\t\tstart: startPosition,\n\t\t\tstickiness: this.stickiness,\n\t\t\tstartSide,\n\t\t\tendSide,\n\t\t};\n\n\t\tif (this.properties) {\n\t\t\tserializedInterval.properties = this.properties;\n\t\t}\n\n\t\treturn serializedInterval;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.clone}\n\t */\n\tpublic clone() {\n\t\treturn new SequenceInterval(\n\t\t\tthis.client,\n\t\t\tthis.start,\n\t\t\tthis.end,\n\t\t\tthis.intervalType,\n\t\t\tthis.properties,\n\t\t\tthis.startSide,\n\t\t\tthis.endSide,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compare}\n\t */\n\tpublic compare(b: SequenceInterval) {\n\t\tconst startResult = this.compareStart(b);\n\t\tif (startResult === 0) {\n\t\t\tconst endResult = this.compareEnd(b);\n\t\t\tif (endResult === 0) {\n\t\t\t\tconst thisId = this.getIntervalId();\n\t\t\t\tif (thisId) {\n\t\t\t\t\tconst bId = b.getIntervalId();\n\t\t\t\t\tif (bId) {\n\t\t\t\t\t\treturn thisId > bId ? 1 : thisId < bId ? -1 : 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn endResult;\n\t\t\t}\n\t\t} else {\n\t\t\treturn startResult;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareStart}\n\t */\n\tpublic compareStart(b: SequenceInterval) {\n\t\tconst dist = compareReferencePositions(this.start, b.start);\n\n\t\tif (dist === 0) {\n\t\t\treturn compareSides(this.startSide, b.startSide);\n\t\t}\n\n\t\treturn dist;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareEnd}\n\t */\n\tpublic compareEnd(b: SequenceInterval): number {\n\t\tconst dist = compareReferencePositions(this.end, b.end);\n\n\t\tif (dist === 0) {\n\t\t\treturn compareSides(b.endSide, this.endSide);\n\t\t}\n\n\t\treturn dist;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.overlaps}\n\t */\n\tpublic overlaps(b: SequenceInterval) {\n\t\tconst result =\n\t\t\tcompareReferencePositions(this.start, b.end) <= 0 &&\n\t\t\tcompareReferencePositions(this.end, b.start) >= 0;\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.getIntervalId}\n\t */\n\tpublic getIntervalId(): string {\n\t\tconst id = this.properties?.[reservedIntervalIdKey];\n\t\tassert(id !== undefined, 0x5e2 /* interval ID should not be undefined */);\n\t\treturn `${id}`;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.union}\n\t * @internal\n\t */\n\tpublic union(b: SequenceInterval) {\n\t\tconst newStart = minReferencePosition(this.start, b.start);\n\t\tconst newEnd = maxReferencePosition(this.end, b.end);\n\n\t\tlet startSide: Side;\n\n\t\tif (this.start === b.start) {\n\t\t\tstartSide = minSide(this.startSide, b.startSide);\n\t\t} else {\n\t\t\tstartSide = this.start === newStart ? this.startSide : b.startSide;\n\t\t}\n\n\t\tlet endSide: Side;\n\n\t\tif (this.end === b.end) {\n\t\t\tendSide = maxSide(this.endSide, b.endSide);\n\t\t} else {\n\t\t\tendSide = this.end === newEnd ? this.endSide : b.endSide;\n\t\t}\n\n\t\treturn new SequenceInterval(\n\t\t\tthis.client,\n\t\t\tnewStart,\n\t\t\tnewEnd,\n\t\t\tthis.intervalType,\n\t\t\tundefined,\n\t\t\tstartSide,\n\t\t\tendSide,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.addProperties}\n\t * @internal\n\t */\n\tpublic addProperties(\n\t\tnewProps: PropertySet,\n\t\tcollab: boolean = false,\n\t\tseq?: number,\n\t\top?: ICombiningOp,\n\t): PropertySet | undefined {\n\t\tthis.initializeProperties();\n\t\treturn this.propertyManager.addProperties(this.properties, newProps, op, seq, collab);\n\t}\n\n\t/**\n\t * @returns whether this interval overlaps two numerical positions.\n\t */\n\tpublic overlapsPos(bstart: number, bend: number) {\n\t\tconst startPos = this.client.localReferencePositionToPosition(this.start);\n\t\tconst endPos = this.client.localReferencePositionToPosition(this.end);\n\t\treturn endPos > bstart && startPos < bend;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.modify}\n\t * @internal\n\t */\n\tpublic modify(\n\t\tlabel: string,\n\t\tstart: SequencePlace | undefined,\n\t\tend: SequencePlace | undefined,\n\t\top?: ISequencedDocumentMessage,\n\t\tlocalSeq?: number,\n\t\tuseNewSlidingBehavior: boolean = false,\n\t) {\n\t\tconst { startSide, endSide, startPos, endPos } = endpointPosAndSide(start, end);\n\t\tconst stickiness = computeStickinessFromSide(\n\t\t\tstartPos ?? this.start.getSegment()?.endpointType,\n\t\t\tstartSide ?? this.startSide,\n\t\t\tendPos ?? this.end.getSegment()?.endpointType,\n\t\t\tendSide ?? this.endSide,\n\t\t);\n\t\tconst getRefType = (baseType: ReferenceType): ReferenceType => {\n\t\t\tlet refType = baseType;\n\t\t\tif (op === undefined) {\n\t\t\t\trefType &= ~ReferenceType.SlideOnRemove;\n\t\t\t\trefType |= ReferenceType.StayOnRemove;\n\t\t\t}\n\t\t\treturn refType;\n\t\t};\n\n\t\tlet startRef = this.start;\n\t\tif (startPos !== undefined) {\n\t\t\tstartRef = createPositionReference(\n\t\t\t\tthis.client,\n\t\t\t\tstartPos,\n\t\t\t\tgetRefType(this.start.refType),\n\t\t\t\top,\n\t\t\t\tundefined,\n\t\t\t\tlocalSeq,\n\t\t\t\tstartReferenceSlidingPreference(stickiness),\n\t\t\t\tstartReferenceSlidingPreference(stickiness) === SlidingPreference.BACKWARD,\n\t\t\t\tuseNewSlidingBehavior,\n\t\t\t);\n\t\t\tif (this.start.properties) {\n\t\t\t\tstartRef.addProperties(this.start.properties);\n\t\t\t}\n\t\t}\n\n\t\tlet endRef = this.end;\n\t\tif (endPos !== undefined) {\n\t\t\tendRef = createPositionReference(\n\t\t\t\tthis.client,\n\t\t\t\tendPos,\n\t\t\t\tgetRefType(this.end.refType),\n\t\t\t\top,\n\t\t\t\tundefined,\n\t\t\t\tlocalSeq,\n\t\t\t\tendReferenceSlidingPreference(stickiness),\n\t\t\t\tendReferenceSlidingPreference(stickiness) === SlidingPreference.FORWARD,\n\t\t\t\tuseNewSlidingBehavior,\n\t\t\t);\n\t\t\tif (this.end.properties) {\n\t\t\t\tendRef.addProperties(this.end.properties);\n\t\t\t}\n\t\t}\n\n\t\tconst newInterval = new SequenceInterval(\n\t\t\tthis.client,\n\t\t\tstartRef,\n\t\t\tendRef,\n\t\t\tthis.intervalType,\n\t\t\tundefined,\n\t\t\tstartSide ?? this.startSide,\n\t\t\tendSide ?? this.endSide,\n\t\t);\n\t\tif (this.properties) {\n\t\t\tnewInterval.initializeProperties();\n\t\t\tthis.propertyManager.copyTo(\n\t\t\t\tthis.properties,\n\t\t\t\tnewInterval.properties,\n\t\t\t\tnewInterval.propertyManager,\n\t\t\t);\n\t\t}\n\t\treturn newInterval;\n\t}\n\n\tprivate initializeProperties(): void {\n\t\tif (!this.propertyManager) {\n\t\t\tthis.propertyManager = new PropertiesManager();\n\t\t}\n\t\tif (!this.properties) {\n\t\t\tthis.properties = createMap<any>();\n\t\t}\n\t}\n}\n\nexport function createPositionReferenceFromSegoff(\n\tclient: Client,\n\tsegoff: { segment: ISegment | undefined; offset: number | undefined } | \"start\" | \"end\",\n\trefType: ReferenceType,\n\top?: ISequencedDocumentMessage,\n\tlocalSeq?: number,\n\tfromSnapshot?: boolean,\n\tslidingPreference?: SlidingPreference,\n\tcanSlideToEndpoint?: boolean,\n): LocalReferencePosition {\n\tif (segoff === \"start\" || segoff === \"end\") {\n\t\treturn client.createLocalReferencePosition(\n\t\t\tsegoff,\n\t\t\tundefined,\n\t\t\trefType,\n\t\t\tundefined,\n\t\t\tslidingPreference,\n\t\t\tcanSlideToEndpoint,\n\t\t);\n\t}\n\n\tif (segoff.segment) {\n\t\tconst ref = client.createLocalReferencePosition(\n\t\t\tsegoff.segment,\n\t\t\tsegoff.offset,\n\t\t\trefType,\n\t\t\tundefined,\n\t\t\tslidingPreference,\n\t\t\tcanSlideToEndpoint,\n\t\t);\n\t\treturn ref;\n\t}\n\n\t// Creating references on detached segments is allowed for:\n\t// - Transient segments\n\t// - References coming from a remote client (location may have been concurrently removed)\n\t// - References being rebased to a new sequence number\n\t// (segment they originally referred to may have been removed with no suitable replacement)\n\tif (\n\t\t!op &&\n\t\t!localSeq &&\n\t\t!fromSnapshot &&\n\t\t!refTypeIncludesFlag(refType, ReferenceType.Transient)\n\t) {\n\t\tthrow new UsageError(\"Non-transient references need segment\");\n\t}\n\n\treturn createDetachedLocalReferencePosition(refType);\n}\n\nfunction createPositionReference(\n\tclient: Client,\n\tpos: number | \"start\" | \"end\",\n\trefType: ReferenceType,\n\top?: ISequencedDocumentMessage,\n\tfromSnapshot?: boolean,\n\tlocalSeq?: number,\n\tslidingPreference?: SlidingPreference,\n\texclusive: boolean = false,\n\tuseNewSlidingBehavior: boolean = false,\n): LocalReferencePosition {\n\tlet segoff;\n\n\tif (op) {\n\t\tassert(\n\t\t\t(refType & ReferenceType.SlideOnRemove) !== 0,\n\t\t\t0x2f5 /* op create references must be SlideOnRemove */,\n\t\t);\n\t\tif (pos === \"start\" || pos === \"end\") {\n\t\t\tsegoff = pos;\n\t\t} else {\n\t\t\tsegoff = client.getContainingSegment(pos, {\n\t\t\t\treferenceSequenceNumber: op.referenceSequenceNumber,\n\t\t\t\tclientId: op.clientId,\n\t\t\t});\n\t\t\tsegoff = getSlideToSegoff(segoff, undefined, useNewSlidingBehavior);\n\t\t}\n\t} else {\n\t\tassert(\n\t\t\t(refType & ReferenceType.SlideOnRemove) === 0 || !!fromSnapshot,\n\t\t\t0x2f6 /* SlideOnRemove references must be op created */,\n\t\t);\n\t\tsegoff =\n\t\t\tpos === \"start\" || pos === \"end\"\n\t\t\t\t? pos\n\t\t\t\t: client.getContainingSegment(pos, undefined, localSeq);\n\t}\n\n\treturn createPositionReferenceFromSegoff(\n\t\tclient,\n\t\tsegoff,\n\t\trefType,\n\t\top,\n\t\tlocalSeq,\n\t\tfromSnapshot,\n\t\tslidingPreference,\n\t\texclusive,\n\t);\n}\n\nexport function createSequenceInterval(\n\tlabel: string,\n\tstart: SequencePlace | undefined,\n\tend: SequencePlace | undefined,\n\tclient: Client,\n\tintervalType: IntervalType,\n\top?: ISequencedDocumentMessage,\n\tfromSnapshot?: boolean,\n\tuseNewSlidingBehavior: boolean = false,\n): SequenceInterval {\n\tconst { startPos, startSide, endPos, endSide } = endpointPosAndSide(\n\t\tstart ?? \"start\",\n\t\tend ?? \"end\",\n\t);\n\tassert(\n\t\tstartPos !== undefined &&\n\t\t\tendPos !== undefined &&\n\t\t\tstartSide !== undefined &&\n\t\t\tendSide !== undefined,\n\t\t0x794 /* start and end cannot be undefined because they were not passed in as undefined */,\n\t);\n\tconst stickiness = computeStickinessFromSide(startPos, startSide, endPos, endSide);\n\tlet beginRefType = ReferenceType.RangeBegin;\n\tlet endRefType = ReferenceType.RangeEnd;\n\tif (intervalType === IntervalType.Transient) {\n\t\tbeginRefType = ReferenceType.Transient;\n\t\tendRefType = ReferenceType.Transient;\n\t} else {\n\t\tif (intervalType === IntervalType.Nest) {\n\t\t\tbeginRefType = ReferenceType.NestBegin;\n\t\t\tendRefType = ReferenceType.NestEnd;\n\t\t}\n\t\t// All non-transient interval references must eventually be SlideOnRemove\n\t\t// To ensure eventual consistency, they must start as StayOnRemove when\n\t\t// pending (created locally and creation op is not acked)\n\t\tif (op ?? fromSnapshot) {\n\t\t\tbeginRefType |= ReferenceType.SlideOnRemove;\n\t\t\tendRefType |= ReferenceType.SlideOnRemove;\n\t\t} else {\n\t\t\tbeginRefType |= ReferenceType.StayOnRemove;\n\t\t\tendRefType |= ReferenceType.StayOnRemove;\n\t\t}\n\t}\n\n\tconst startLref = createPositionReference(\n\t\tclient,\n\t\tstartPos,\n\t\tbeginRefType,\n\t\top,\n\t\tfromSnapshot,\n\t\tundefined,\n\t\tstartReferenceSlidingPreference(stickiness),\n\t\tstartReferenceSlidingPreference(stickiness) === SlidingPreference.BACKWARD,\n\t\tuseNewSlidingBehavior,\n\t);\n\n\tconst endLref = createPositionReference(\n\t\tclient,\n\t\tendPos,\n\t\tendRefType,\n\t\top,\n\t\tfromSnapshot,\n\t\tundefined,\n\t\tendReferenceSlidingPreference(stickiness),\n\t\tendReferenceSlidingPreference(stickiness) === SlidingPreference.FORWARD,\n\t\tuseNewSlidingBehavior,\n\t);\n\n\tconst rangeProp = {\n\t\t[reservedRangeLabelsKey]: [label],\n\t};\n\tstartLref.addProperties(rangeProp);\n\tendLref.addProperties(rangeProp);\n\n\tconst ival = new SequenceInterval(\n\t\tclient,\n\t\tstartLref,\n\t\tendLref,\n\t\tintervalType,\n\t\trangeProp,\n\t\tstartSide,\n\t\tendSide,\n\t);\n\treturn ival;\n}\n\n/**\n * @deprecated The methods within have substitutions\n * @public\n */\nexport const sequenceIntervalHelpers: IIntervalHelpers<SequenceInterval> = {\n\tcreate: createSequenceInterval,\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"localValues.d.ts","sourceRoot":"","sources":["../src/localValues.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAoB,MAAM,oCAAoC,CAAC;AACxF,OAAO,EACN,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,GAAG;IACnC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAElB;;;;;OAKG;IACH,cAAc,CAAC,UAAU,EAAE,gBAAgB,EAAE,IAAI,EAAE,YAAY,GAAG,gBAAgB,CAAC;CACnF;AAED,wBAAgB,gBAAgB,CAC/B,UAAU,EAAE,WAAW,EACvB,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,YAAY,GAChB,kBAAkB,CAMpB;AAED;;;;GAIG;AACH,qBAAa,mBAAmB,CAAC,CAAC,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;aAMhC,KAAK,EAAE,CAAC;IAAE,OAAO,CAAC,QAAQ,CAAC,SAAS;IALhE;;;;OAIG;gBACyB,KAAK,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YAAY,CAAC,MAAc;QACjC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,EAAE;YACb,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SACxC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { IFluidSerializer, serializeHandles } from \"@fluidframework/shared-object-base\";\nimport {\n\tISerializableValue,\n\tISerializedValue,\n\tIValueOperation,\n\tIValueType,\n} from \"./defaultMapInterfaces\";\n\n/**\n * A local value to be stored in a container type DDS.\n */\nexport interface ILocalValue<T = any> {\n\t/**\n\t * Type indicator of the value stored within.\n\t */\n\treadonly type: string;\n\n\t/**\n\t * The in-memory value stored within.\n\t */\n\treadonly value: T;\n\n\t/**\n\t * Retrieve the serialized form of the value stored within.\n\t * @param serializer - Data store runtime's serializer\n\t * @param bind - Container type's handle\n\t * @returns The serialized form of the contained value\n\t */\n\tmakeSerialized(serializer: IFluidSerializer, bind: IFluidHandle): ISerializedValue;\n}\n\nexport function makeSerializable(\n\tlocalValue: ILocalValue,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n): ISerializableValue {\n\tconst value = localValue.makeSerialized(serializer, bind);\n\treturn {\n\t\ttype: value.type,\n\t\tvalue: value.value && JSON.parse(value.value),\n\t};\n}\n\n/**\n * Manages a contained value type.\n *\n * @alpha\n */\nexport class ValueTypeLocalValue<T> implements ILocalValue<T> {\n\t/**\n\t * Create a new ValueTypeLocalValue.\n\t * @param value - The instance of the value type stored within\n\t * @param valueType - The type object of the value type stored within\n\t */\n\tconstructor(public readonly value: T, private readonly valueType: IValueType<T>) {}\n\n\t/**\n\t * {@inheritDoc ILocalValue.\"type\"}\n\t */\n\tpublic get type(): string {\n\t\treturn this.valueType.name;\n\t}\n\n\t/**\n\t * {@inheritDoc ILocalValue.makeSerialized}\n\t */\n\tpublic makeSerialized(serializer: IFluidSerializer, bind: IFluidHandle): ISerializedValue {\n\t\tconst storedValueType = this.valueType.factory.store(this.value);\n\t\tconst value = serializeHandles(storedValueType, serializer, bind);\n\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tvalue,\n\t\t};\n\t}\n\n\t/**\n\t * Get the handler for a given op of this value type.\n\t * @param opName - The name of the operation that needs processing\n\t * @returns The object which can process the given op\n\t */\n\tpublic getOpHandler(opName: string): IValueOperation<T> {\n\t\tconst handler = this.valueType.ops.get(opName);\n\t\tif (!handler) {\n\t\t\tthrow new Error(\"Unknown type message\");\n\t\t}\n\n\t\treturn handler;\n\t}\n}\n"]}
1
+ {"version":3,"file":"localValues.js","sourceRoot":"","sources":["../src/localValues.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAoB,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AA+BxF,MAAM,UAAU,gBAAgB,CAC/B,UAAuB,EACvB,UAA4B,EAC5B,IAAkB;IAElB,MAAM,KAAK,GAAG,UAAU,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC1D,OAAO;QACN,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;KAC7C,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAC/B;;;;OAIG;IACH,YACiB,KAAQ,EACP,SAAwB;QADzB,UAAK,GAAL,KAAK,CAAG;QACP,cAAS,GAAT,SAAS,CAAe;IACvC,CAAC;IAEJ;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,cAAc,CAAC,UAA4B,EAAE,IAAkB;QACrE,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACjE,MAAM,KAAK,GAAG,gBAAgB,CAAC,eAAe,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;QAElE,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK;SACL,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,YAAY,CAAC,MAAc;QACjC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,EAAE;YACb,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SACxC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { IFluidSerializer, serializeHandles } from \"@fluidframework/shared-object-base\";\nimport {\n\tISerializableValue,\n\tISerializedValue,\n\tIValueOperation,\n\tIValueType,\n} from \"./defaultMapInterfaces\";\n\n/**\n * A local value to be stored in a container type DDS.\n */\nexport interface ILocalValue<T = any> {\n\t/**\n\t * Type indicator of the value stored within.\n\t */\n\treadonly type: string;\n\n\t/**\n\t * The in-memory value stored within.\n\t */\n\treadonly value: T;\n\n\t/**\n\t * Retrieve the serialized form of the value stored within.\n\t * @param serializer - Data store runtime's serializer\n\t * @param bind - Container type's handle\n\t * @returns The serialized form of the contained value\n\t */\n\tmakeSerialized(serializer: IFluidSerializer, bind: IFluidHandle): ISerializedValue;\n}\n\nexport function makeSerializable(\n\tlocalValue: ILocalValue,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n): ISerializableValue {\n\tconst value = localValue.makeSerialized(serializer, bind);\n\treturn {\n\t\ttype: value.type,\n\t\tvalue: value.value && JSON.parse(value.value),\n\t};\n}\n\n/**\n * Manages a contained value type.\n *\n * @alpha\n */\nexport class ValueTypeLocalValue<T> implements ILocalValue<T> {\n\t/**\n\t * Create a new ValueTypeLocalValue.\n\t * @param value - The instance of the value type stored within\n\t * @param valueType - The type object of the value type stored within\n\t */\n\tconstructor(\n\t\tpublic readonly value: T,\n\t\tprivate readonly valueType: IValueType<T>,\n\t) {}\n\n\t/**\n\t * {@inheritDoc ILocalValue.\"type\"}\n\t */\n\tpublic get type(): string {\n\t\treturn this.valueType.name;\n\t}\n\n\t/**\n\t * {@inheritDoc ILocalValue.makeSerialized}\n\t */\n\tpublic makeSerialized(serializer: IFluidSerializer, bind: IFluidHandle): ISerializedValue {\n\t\tconst storedValueType = this.valueType.factory.store(this.value);\n\t\tconst value = serializeHandles(storedValueType, serializer, bind);\n\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tvalue,\n\t\t};\n\t}\n\n\t/**\n\t * Get the handler for a given op of this value type.\n\t * @param opName - The name of the operation that needs processing\n\t * @returns The object which can process the given op\n\t */\n\tpublic getOpHandler(opName: string): IValueOperation<T> {\n\t\tconst handler = this.valueType.ops.get(opName);\n\t\tif (!handler) {\n\t\t\tthrow new Error(\"Unknown type message\");\n\t\t}\n\n\t\treturn handler;\n\t}\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/sequence";
8
- export declare const pkgVersion = "2.0.0-dev.6.4.0.192049";
8
+ export declare const pkgVersion = "2.0.0-dev.7.2.0.204906";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/sequence";
8
- export const pkgVersion = "2.0.0-dev.6.4.0.192049";
8
+ export const pkgVersion = "2.0.0-dev.7.2.0.204906";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.0.0-dev.6.4.0.192049\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.0.0-dev.7.2.0.204906\";\n"]}
@@ -9,22 +9,16 @@ import { SequenceDeltaEvent } from "./sequenceDeltaEvent";
9
9
  /**
10
10
  * Data for undoing edits on SharedStrings and Intervals.
11
11
  *
12
- * Revertibles are new and require the option mergeTreeUseNewLengthCalculations to
13
- * be set as true on the underlying merge tree in order to function correctly.
14
- *
15
12
  * @alpha
16
13
  */
17
- export declare type SharedStringRevertible = MergeTreeDeltaRevertible | IntervalRevertible;
18
- declare type IntervalOpType = typeof IntervalOpType[keyof typeof IntervalOpType];
14
+ export type SharedStringRevertible = MergeTreeDeltaRevertible | IntervalRevertible;
15
+ type IntervalOpType = (typeof IntervalOpType)[keyof typeof IntervalOpType];
19
16
  /**
20
17
  * Data for undoing edits affecting Intervals.
21
18
  *
22
- * Revertibles are new and require the option mergeTreeUseNewLengthCalculations to
23
- * be set as true on the underlying merge tree in order to function correctly.
24
- *
25
19
  * @alpha
26
20
  */
27
- export declare type IntervalRevertible = {
21
+ export type IntervalRevertible = {
28
22
  event: typeof IntervalOpType.CHANGE;
29
23
  interval: SequenceInterval;
30
24
  start: LocalReferencePosition;
@@ -80,9 +74,6 @@ export declare function appendIntervalPropertyChangedToRevertibles(interval: Seq
80
74
  * Create revertibles for SharedStringDeltas, handling indirectly modified intervals
81
75
  * (e.g. reverting remove of a range that contains an interval will move the interval back)
82
76
  *
83
- * Revertibles are new and require the option mergeTreeUseNewLengthCalculations to
84
- * be set as true on the underlying merge tree in order to function correctly.
85
- *
86
77
  * @alpha
87
78
  */
88
79
  export declare function appendSharedStringDeltaToRevertibles(string: SharedString, delta: SequenceDeltaEvent, revertibles: SharedStringRevertible[]): void;
@@ -94,9 +85,6 @@ export declare function discardSharedStringRevertibles(sharedString: SharedStrin
94
85
  /**
95
86
  * Invoke revertibles to reverse prior edits
96
87
  *
97
- * Revertibles are new and require the option mergeTreeUseNewLengthCalculations to
98
- * be set as true on the underlying merge tree in order to function correctly.
99
- *
100
88
  * @alpha
101
89
  */
102
90
  export declare function revertSharedStringRevertibles(sharedString: SharedString, revertibles: SharedStringRevertible[]): void;
@@ -1 +1 @@
1
- {"version":3,"file":"revertibles.d.ts","sourceRoot":"","sources":["../src/revertibles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAIN,sBAAsB,EAEtB,wBAAwB,EAExB,WAAW,EAMX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAuB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAuB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/E;;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AqCrC;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAChD,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,gBAAgB,EAC7B,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,sBAAsB,EAAE,4BAwCrC;AAED;;;GAGG;AACH,wBAAgB,0CAA0C,CACzD,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,WAAW,EACnB,WAAW,EAAE,sBAAsB,EAAE,4BASrC;AA2CD;;;;;GAKG;AACH,wBAAgB,oCAAoC,CACnD,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,kBAAkB,EACzB,WAAW,EAAE,sBAAsB,EAAE,QAoFrC;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAC7C,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,sBAAsB,EAAE,QAUrC;AA2MD;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC5C,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,sBAAsB,EAAE,QA8BrC"}
@@ -123,9 +123,6 @@ function addIfRevertibleRef(ref, segmentLengths, revertibleRefs) {
123
123
  * Create revertibles for SharedStringDeltas, handling indirectly modified intervals
124
124
  * (e.g. reverting remove of a range that contains an interval will move the interval back)
125
125
  *
126
- * Revertibles are new and require the option mergeTreeUseNewLengthCalculations to
127
- * be set as true on the underlying merge tree in order to function correctly.
128
- *
129
126
  * @alpha
130
127
  */
131
128
  export function appendSharedStringDeltaToRevertibles(string, delta, revertibles) {
@@ -240,11 +237,14 @@ function revertLocalDelete(string, revertible) {
240
237
  const startSlidePos = getSlidePosition(string, revertible.start, start);
241
238
  const end = string.localReferencePositionToPosition(revertible.end);
242
239
  const endSlidePos = getSlidePosition(string, revertible.end, end);
243
- const type = revertible.interval.intervalType;
244
240
  // reusing the id causes eventual consistency bugs, so it is removed here and recreated in add
245
241
  const { intervalId, ...props } = revertible.interval.properties;
246
242
  if (isValidRange(startSlidePos, endSlidePos, string)) {
247
- const int = collection.add(startSlidePos, endSlidePos, type, props);
243
+ const int = collection.add({
244
+ start: startSlidePos,
245
+ end: endSlidePos,
246
+ props,
247
+ });
248
248
  idMap.forEach((newId, oldId) => {
249
249
  if (intervalId === newId) {
250
250
  idMap.set(oldId, getUpdatedIdFromInterval(int));
@@ -322,17 +322,12 @@ function revertLocalSequenceRemove(sharedString, revertible) {
322
322
  const intervalId = getUpdatedId(intervalInfo.intervalId);
323
323
  const interval = intervalCollection.getIntervalById(intervalId);
324
324
  if (interval !== undefined) {
325
- const newStart = newEndpointPosition(intervalInfo.startOffset, restoredRanges, sharedString);
326
- const newEnd = newEndpointPosition(intervalInfo.endOffset, restoredRanges, sharedString);
327
- // only move interval if start <= end
328
- if ((newStart === undefined &&
329
- newEnd !== undefined &&
330
- sharedString.localReferencePositionToPosition(interval.start) <= newEnd) ||
331
- (newEnd === undefined &&
332
- newStart !== undefined &&
333
- sharedString.localReferencePositionToPosition(interval.end) >= newStart) ||
334
- (newStart !== undefined && newEnd !== undefined && newStart <= newEnd)) {
335
- intervalCollection.change(intervalId, newStart, newEnd);
325
+ const start = newEndpointPosition(intervalInfo.startOffset, restoredRanges, sharedString) ??
326
+ sharedString.localReferencePositionToPosition(interval.start);
327
+ const end = newEndpointPosition(intervalInfo.endOffset, restoredRanges, sharedString) ??
328
+ sharedString.localReferencePositionToPosition(interval.end);
329
+ if (start <= end) {
330
+ intervalCollection.change(intervalId, start, end);
336
331
  }
337
332
  }
338
333
  });
@@ -358,9 +353,6 @@ function revertLocalSequenceRemove(sharedString, revertible) {
358
353
  /**
359
354
  * Invoke revertibles to reverse prior edits
360
355
  *
361
- * Revertibles are new and require the option mergeTreeUseNewLengthCalculations to
362
- * be set as true on the underlying merge tree in order to function correctly.
363
- *
364
356
  * @alpha
365
357
  */
366
358
  export function revertSharedStringRevertibles(sharedString, revertibles) {