@fluidframework/sequence 2.30.0 → 2.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/CHANGELOG.md +506 -495
  2. package/api-report/sequence.legacy.alpha.api.md +67 -5
  3. package/dist/IntervalCollectionValues.d.ts +3 -51
  4. package/dist/IntervalCollectionValues.d.ts.map +1 -1
  5. package/dist/IntervalCollectionValues.js +6 -49
  6. package/dist/IntervalCollectionValues.js.map +1 -1
  7. package/dist/index.d.ts +4 -4
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +1 -8
  10. package/dist/index.js.map +1 -1
  11. package/dist/intervalCollection.d.ts +292 -63
  12. package/dist/intervalCollection.d.ts.map +1 -1
  13. package/dist/intervalCollection.js +111 -193
  14. package/dist/intervalCollection.js.map +1 -1
  15. package/dist/intervalCollectionMap.d.ts +11 -32
  16. package/dist/intervalCollectionMap.d.ts.map +1 -1
  17. package/dist/intervalCollectionMap.js +37 -90
  18. package/dist/intervalCollectionMap.js.map +1 -1
  19. package/dist/intervalCollectionMapInterfaces.d.ts +10 -83
  20. package/dist/intervalCollectionMapInterfaces.d.ts.map +1 -1
  21. package/dist/intervalCollectionMapInterfaces.js.map +1 -1
  22. package/dist/intervalIndex/endpointInRangeIndex.d.ts +10 -11
  23. package/dist/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
  24. package/dist/intervalIndex/endpointInRangeIndex.js +4 -5
  25. package/dist/intervalIndex/endpointInRangeIndex.js.map +1 -1
  26. package/dist/intervalIndex/endpointIndex.d.ts +12 -13
  27. package/dist/intervalIndex/endpointIndex.d.ts.map +1 -1
  28. package/dist/intervalIndex/endpointIndex.js +4 -5
  29. package/dist/intervalIndex/endpointIndex.js.map +1 -1
  30. package/dist/intervalIndex/idIntervalIndex.d.ts +6 -12
  31. package/dist/intervalIndex/idIntervalIndex.d.ts.map +1 -1
  32. package/dist/intervalIndex/idIntervalIndex.js +0 -3
  33. package/dist/intervalIndex/idIntervalIndex.js.map +1 -1
  34. package/dist/intervalIndex/index.d.ts +2 -2
  35. package/dist/intervalIndex/index.d.ts.map +1 -1
  36. package/dist/intervalIndex/index.js.map +1 -1
  37. package/dist/intervalIndex/intervalIndex.d.ts +28 -1
  38. package/dist/intervalIndex/intervalIndex.d.ts.map +1 -1
  39. package/dist/intervalIndex/intervalIndex.js.map +1 -1
  40. package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +30 -13
  41. package/dist/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
  42. package/dist/intervalIndex/overlappingIntervalsIndex.js +4 -5
  43. package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  44. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
  45. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js +1 -1
  46. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  47. package/dist/intervalIndex/sequenceIntervalIndexes.d.ts +2 -2
  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 +10 -11
  51. package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
  52. package/dist/intervalIndex/startpointInRangeIndex.js +4 -5
  53. package/dist/intervalIndex/startpointInRangeIndex.js.map +1 -1
  54. package/dist/intervals/index.d.ts +2 -3
  55. package/dist/intervals/index.d.ts.map +1 -1
  56. package/dist/intervals/index.js +1 -6
  57. package/dist/intervals/index.js.map +1 -1
  58. package/dist/intervals/intervalUtils.d.ts +3 -25
  59. package/dist/intervals/intervalUtils.d.ts.map +1 -1
  60. package/dist/intervals/intervalUtils.js.map +1 -1
  61. package/dist/intervals/sequenceInterval.d.ts +3 -8
  62. package/dist/intervals/sequenceInterval.d.ts.map +1 -1
  63. package/dist/intervals/sequenceInterval.js +1 -9
  64. package/dist/intervals/sequenceInterval.js.map +1 -1
  65. package/dist/legacy.d.ts +4 -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/sequence.d.ts +4 -6
  70. package/dist/sequence.d.ts.map +1 -1
  71. package/dist/sequence.js +3 -5
  72. package/dist/sequence.js.map +1 -1
  73. package/dist/sharedIntervalCollection.d.ts +2 -63
  74. package/dist/sharedIntervalCollection.d.ts.map +1 -1
  75. package/dist/sharedIntervalCollection.js +0 -113
  76. package/dist/sharedIntervalCollection.js.map +1 -1
  77. package/dist/sharedString.d.ts.map +1 -1
  78. package/dist/sharedString.js +6 -6
  79. package/dist/sharedString.js.map +1 -1
  80. package/lib/IntervalCollectionValues.d.ts +3 -51
  81. package/lib/IntervalCollectionValues.d.ts.map +1 -1
  82. package/lib/IntervalCollectionValues.js +5 -47
  83. package/lib/IntervalCollectionValues.js.map +1 -1
  84. package/lib/index.d.ts +4 -4
  85. package/lib/index.d.ts.map +1 -1
  86. package/lib/index.js +2 -3
  87. package/lib/index.js.map +1 -1
  88. package/lib/intervalCollection.d.ts +292 -63
  89. package/lib/intervalCollection.d.ts.map +1 -1
  90. package/lib/intervalCollection.js +113 -191
  91. package/lib/intervalCollection.js.map +1 -1
  92. package/lib/intervalCollectionMap.d.ts +11 -32
  93. package/lib/intervalCollectionMap.d.ts.map +1 -1
  94. package/lib/intervalCollectionMap.js +39 -92
  95. package/lib/intervalCollectionMap.js.map +1 -1
  96. package/lib/intervalCollectionMapInterfaces.d.ts +10 -83
  97. package/lib/intervalCollectionMapInterfaces.d.ts.map +1 -1
  98. package/lib/intervalCollectionMapInterfaces.js.map +1 -1
  99. package/lib/intervalIndex/endpointInRangeIndex.d.ts +10 -11
  100. package/lib/intervalIndex/endpointInRangeIndex.d.ts.map +1 -1
  101. package/lib/intervalIndex/endpointInRangeIndex.js +5 -6
  102. package/lib/intervalIndex/endpointInRangeIndex.js.map +1 -1
  103. package/lib/intervalIndex/endpointIndex.d.ts +12 -13
  104. package/lib/intervalIndex/endpointIndex.d.ts.map +1 -1
  105. package/lib/intervalIndex/endpointIndex.js +5 -6
  106. package/lib/intervalIndex/endpointIndex.js.map +1 -1
  107. package/lib/intervalIndex/idIntervalIndex.d.ts +6 -12
  108. package/lib/intervalIndex/idIntervalIndex.d.ts.map +1 -1
  109. package/lib/intervalIndex/idIntervalIndex.js +0 -3
  110. package/lib/intervalIndex/idIntervalIndex.js.map +1 -1
  111. package/lib/intervalIndex/index.d.ts +2 -2
  112. package/lib/intervalIndex/index.d.ts.map +1 -1
  113. package/lib/intervalIndex/index.js.map +1 -1
  114. package/lib/intervalIndex/intervalIndex.d.ts +28 -1
  115. package/lib/intervalIndex/intervalIndex.d.ts.map +1 -1
  116. package/lib/intervalIndex/intervalIndex.js.map +1 -1
  117. package/lib/intervalIndex/overlappingIntervalsIndex.d.ts +30 -13
  118. package/lib/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -1
  119. package/lib/intervalIndex/overlappingIntervalsIndex.js +5 -6
  120. package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  121. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -1
  122. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js +2 -2
  123. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  124. package/lib/intervalIndex/sequenceIntervalIndexes.d.ts +2 -2
  125. package/lib/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
  126. package/lib/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
  127. package/lib/intervalIndex/startpointInRangeIndex.d.ts +10 -11
  128. package/lib/intervalIndex/startpointInRangeIndex.d.ts.map +1 -1
  129. package/lib/intervalIndex/startpointInRangeIndex.js +5 -6
  130. package/lib/intervalIndex/startpointInRangeIndex.js.map +1 -1
  131. package/lib/intervals/index.d.ts +2 -3
  132. package/lib/intervals/index.d.ts.map +1 -1
  133. package/lib/intervals/index.js +1 -2
  134. package/lib/intervals/index.js.map +1 -1
  135. package/lib/intervals/intervalUtils.d.ts +3 -25
  136. package/lib/intervals/intervalUtils.d.ts.map +1 -1
  137. package/lib/intervals/intervalUtils.js.map +1 -1
  138. package/lib/intervals/sequenceInterval.d.ts +3 -8
  139. package/lib/intervals/sequenceInterval.d.ts.map +1 -1
  140. package/lib/intervals/sequenceInterval.js +0 -8
  141. package/lib/intervals/sequenceInterval.js.map +1 -1
  142. package/lib/legacy.d.ts +4 -0
  143. package/lib/packageVersion.d.ts +1 -1
  144. package/lib/packageVersion.js +1 -1
  145. package/lib/packageVersion.js.map +1 -1
  146. package/lib/sequence.d.ts +4 -6
  147. package/lib/sequence.d.ts.map +1 -1
  148. package/lib/sequence.js +3 -5
  149. package/lib/sequence.js.map +1 -1
  150. package/lib/sharedIntervalCollection.d.ts +2 -63
  151. package/lib/sharedIntervalCollection.d.ts.map +1 -1
  152. package/lib/sharedIntervalCollection.js +1 -110
  153. package/lib/sharedIntervalCollection.js.map +1 -1
  154. package/lib/sharedString.d.ts.map +1 -1
  155. package/lib/sharedString.js +6 -6
  156. package/lib/sharedString.js.map +1 -1
  157. package/lib/tsdoc-metadata.json +1 -1
  158. package/package.json +19 -22
  159. package/src/IntervalCollectionValues.ts +10 -93
  160. package/src/index.ts +6 -17
  161. package/src/intervalCollection.ts +524 -343
  162. package/src/intervalCollectionMap.ts +72 -140
  163. package/src/intervalCollectionMapInterfaces.ts +13 -104
  164. package/src/intervalIndex/endpointInRangeIndex.ts +17 -29
  165. package/src/intervalIndex/endpointIndex.ts +19 -31
  166. package/src/intervalIndex/idIntervalIndex.ts +15 -25
  167. package/src/intervalIndex/index.ts +2 -1
  168. package/src/intervalIndex/intervalIndex.ts +30 -1
  169. package/src/intervalIndex/overlappingIntervalsIndex.ts +50 -27
  170. package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +2 -3
  171. package/src/intervalIndex/sequenceIntervalIndexes.ts +2 -2
  172. package/src/intervalIndex/startpointInRangeIndex.ts +17 -29
  173. package/src/intervals/index.ts +0 -3
  174. package/src/intervals/intervalUtils.ts +3 -38
  175. package/src/intervals/sequenceInterval.ts +2 -12
  176. package/src/packageVersion.ts +1 -1
  177. package/src/sequence.ts +8 -20
  178. package/src/sharedIntervalCollection.ts +5 -183
  179. package/src/sharedString.ts +6 -24
  180. package/dist/intervals/interval.d.ts +0 -76
  181. package/dist/intervals/interval.d.ts.map +0 -1
  182. package/dist/intervals/interval.js +0 -167
  183. package/dist/intervals/interval.js.map +0 -1
  184. package/lib/intervals/interval.d.ts +0 -76
  185. package/lib/intervals/interval.d.ts.map +0 -1
  186. package/lib/intervals/interval.js +0 -162
  187. package/lib/intervals/interval.js.map +0 -1
  188. package/prettier.config.cjs +0 -8
  189. package/src/intervals/interval.ts +0 -226
@@ -4,7 +4,6 @@
4
4
  */
5
5
 
6
6
  /* eslint-disable no-bitwise */
7
- /* eslint-disable import/no-deprecated */
8
7
 
9
8
  import { assert } from "@fluidframework/core-utils/internal";
10
9
  import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
@@ -46,7 +45,6 @@ import {
46
45
  IntervalType,
47
46
  endReferenceSlidingPreference,
48
47
  startReferenceSlidingPreference,
49
- type IIntervalHelpers,
50
48
  } from "./intervalUtils.js";
51
49
 
52
50
  function compareSides(sideA: Side, sideB: Side): number {
@@ -292,7 +290,7 @@ export class SequenceIntervalClass implements SequenceInterval {
292
290
  /**
293
291
  * {@inheritDoc IInterval.clone}
294
292
  */
295
- public clone(): SequenceInterval {
293
+ public clone(): SequenceIntervalClass {
296
294
  return new SequenceIntervalClass(
297
295
  this.client,
298
296
  this.start,
@@ -605,7 +603,7 @@ export function createSequenceInterval(
605
603
  op?: ISequencedDocumentMessage,
606
604
  fromSnapshot?: boolean,
607
605
  useNewSlidingBehavior: boolean = false,
608
- ): SequenceInterval {
606
+ ): SequenceIntervalClass {
609
607
  const { startPos, startSide, endPos, endSide } = endpointPosAndSide(
610
608
  start ?? "start",
611
609
  end ?? "end",
@@ -677,11 +675,3 @@ export function createSequenceInterval(
677
675
  );
678
676
  return ival;
679
677
  }
680
-
681
- /**
682
- * @deprecated The methods within have substitutions
683
- * @internal
684
- */
685
- export const sequenceIntervalHelpers: IIntervalHelpers<SequenceInterval> = {
686
- create: createSequenceInterval,
687
- };
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/sequence";
9
- export const pkgVersion = "2.30.0";
9
+ export const pkgVersion = "2.31.0";
package/src/sequence.ts CHANGED
@@ -69,24 +69,18 @@ import {
69
69
  } from "@fluidframework/telemetry-utils/internal";
70
70
  import Deque from "double-ended-queue";
71
71
 
72
- import {
73
- IIntervalCollection,
74
- SequenceIntervalCollectionValueType,
75
- } from "./intervalCollection.js";
72
+ import { type ISequenceIntervalCollection } from "./intervalCollection.js";
76
73
  import { IMapOperation, IntervalCollectionMap } from "./intervalCollectionMap.js";
77
74
  import {
78
75
  IMapMessageLocalMetadata,
79
- IValueChanged,
80
76
  type SequenceOptions,
81
77
  } from "./intervalCollectionMapInterfaces.js";
82
- import { SequenceInterval } from "./intervals/index.js";
83
78
  import {
84
79
  SequenceDeltaEvent,
85
80
  SequenceDeltaEventClass,
86
81
  SequenceMaintenanceEvent,
87
82
  SequenceMaintenanceEventClass,
88
83
  } from "./sequenceDeltaEvent.js";
89
- import { ISharedIntervalCollection } from "./sharedIntervalCollection.js";
90
84
 
91
85
  const snapshotFileName = "header";
92
86
  const contentPath = "content";
@@ -147,7 +141,6 @@ export interface ISharedSegmentSequenceEvents extends ISharedObjectEvents {
147
141
  */
148
142
  export interface ISharedSegmentSequence<T extends ISegment>
149
143
  extends ISharedObject<ISharedSegmentSequenceEvents>,
150
- ISharedIntervalCollection<SequenceInterval>,
151
144
  MergeTreeRevertibleDriver {
152
145
  /**
153
146
  * Creates a `LocalReferencePosition` on this SharedString. If the refType does not include
@@ -254,7 +247,7 @@ export interface ISharedSegmentSequence<T extends ISegment>
254
247
  * Retrieves the interval collection keyed on `label`. If no such interval collection exists,
255
248
  * creates one.
256
249
  */
257
- getIntervalCollection(label: string): IIntervalCollection<SequenceInterval>;
250
+ getIntervalCollection(label: string): ISequenceIntervalCollection;
258
251
 
259
252
  /**
260
253
  * Obliterate is similar to remove, but differs in that segments concurrently
@@ -494,7 +487,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
494
487
 
495
488
  protected client: Client;
496
489
  private messagesSinceMSNChange: ISequencedDocumentMessage[] = [];
497
- private readonly intervalCollections: IntervalCollectionMap<SequenceInterval>;
490
+ private readonly intervalCollections: IntervalCollectionMap;
498
491
  constructor(
499
492
  dataStoreRuntime: IFluidDataStoreRuntime,
500
493
  public id: string,
@@ -542,7 +535,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
542
535
 
543
536
  this.client.prependListener("delta", (opArgs, deltaArgs) => {
544
537
  const event = new SequenceDeltaEventClass(opArgs, deltaArgs, this.client);
545
- if (event.isLocal) {
538
+ if (event.isLocal && event.opArgs.rollback !== true) {
546
539
  this.submitSequenceMessage(opArgs.op);
547
540
  }
548
541
  if (deltaArgs.deltaSegments.length > 0) {
@@ -569,7 +562,6 @@ export abstract class SharedSegmentSequence<T extends ISegment>
569
562
  this.inFlightRefSeqs.push(this.currentRefSeq);
570
563
  this.submitLocalMessage(op, localOpMetadata);
571
564
  },
572
- new SequenceIntervalCollectionValueType(),
573
565
  options,
574
566
  );
575
567
  }
@@ -705,7 +697,7 @@ export abstract class SharedSegmentSequence<T extends ISegment>
705
697
  this.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));
706
698
  }
707
699
 
708
- public getIntervalCollection(label: string): IIntervalCollection<SequenceInterval> {
700
+ public getIntervalCollection(label: string): ISequenceIntervalCollection {
709
701
  return this.intervalCollections.get(label);
710
702
  }
711
703
 
@@ -999,17 +991,13 @@ export abstract class SharedSegmentSequence<T extends ISegment>
999
991
 
1000
992
  private initializeIntervalCollections() {
1001
993
  // Listen and initialize new SharedIntervalCollections
1002
- this.intervalCollections.eventEmitter.on(
1003
- "create",
1004
- ({ key, previousValue }: IValueChanged, local: boolean) => {
994
+ this.intervalCollections.events.on(
995
+ "createIntervalCollection",
996
+ (key: string, local: boolean) => {
1005
997
  const intervalCollection = this.intervalCollections.get(key);
1006
998
  if (!intervalCollection.attached) {
1007
999
  intervalCollection.attachGraph(this.client, key);
1008
1000
  }
1009
- assert(
1010
- previousValue === undefined,
1011
- 0x2c1 /* "Creating an interval collection that already exists?" */,
1012
- );
1013
1001
  this.emit("createIntervalCollection", key, local, this);
1014
1002
  },
1015
1003
  );
@@ -3,194 +3,16 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { bufferToString } from "@fluid-internal/client-utils";
7
- import { assert } from "@fluidframework/core-utils/internal";
8
- import {
9
- IChannelAttributes,
10
- IChannelFactory,
11
- IFluidDataStoreRuntime,
12
- IChannelServices,
13
- IChannelStorageService,
14
- } from "@fluidframework/datastore-definitions/internal";
15
- import {
16
- MessageType,
17
- ISequencedDocumentMessage,
18
- } from "@fluidframework/driver-definitions/internal";
19
- import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
20
- import {
21
- IFluidSerializer,
22
- SharedObject,
23
- createSingleBlobSummary,
24
- } from "@fluidframework/shared-object-base/internal";
25
-
26
- import { IIntervalCollection, IntervalCollectionValueType } from "./intervalCollection.js";
27
- import { IMapOperation, IntervalCollectionMap } from "./intervalCollectionMap.js";
28
- import { IMapMessageLocalMetadata } from "./intervalCollectionMapInterfaces.js";
29
- import { ISerializableInterval, Interval } from "./intervals/index.js";
30
- import { pkgVersion } from "./packageVersion.js";
31
-
32
- const snapshotFileName = "header";
33
-
34
- /**
35
- * The factory that defines the SharedIntervalCollection.
36
- * @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.
37
- * @internal
38
- */
39
- export class SharedIntervalCollectionFactory implements IChannelFactory {
40
- public static readonly Type = "https://graph.microsoft.com/types/sharedIntervalCollection";
41
-
42
- public static readonly Attributes: IChannelAttributes = {
43
- type: SharedIntervalCollectionFactory.Type,
44
- snapshotFormatVersion: "0.1",
45
- packageVersion: pkgVersion,
46
- };
47
-
48
- public get type() {
49
- return SharedIntervalCollectionFactory.Type;
50
- }
51
-
52
- public get attributes() {
53
- return SharedIntervalCollectionFactory.Attributes;
54
- }
55
-
56
- /**
57
- * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
58
- */
59
- public async load(
60
- runtime: IFluidDataStoreRuntime,
61
- id: string,
62
- services: IChannelServices,
63
- attributes: IChannelAttributes,
64
- ): Promise<SharedIntervalCollection> {
65
- const map = new SharedIntervalCollection(id, runtime, attributes);
66
- await map.load(services);
67
-
68
- return map;
69
- }
70
-
71
- public create(runtime: IFluidDataStoreRuntime, id: string): SharedIntervalCollection {
72
- const map = new SharedIntervalCollection(id, runtime, this.attributes);
73
- map.initializeLocal();
74
-
75
- return map;
76
- }
77
- }
6
+ // eslint-disable-next-line import/no-deprecated
7
+ import { IIntervalCollection } from "./intervalCollection.js";
8
+ import { ISerializableInterval } from "./intervals/index.js";
78
9
 
79
10
  /**
80
11
  * @legacy
81
12
  * @alpha
13
+ * @remarks This interface is no longer used and will be removed.
82
14
  */
83
15
  export interface ISharedIntervalCollection<TInterval extends ISerializableInterval> {
16
+ // eslint-disable-next-line import/no-deprecated
84
17
  getIntervalCollection(label: string): IIntervalCollection<TInterval>;
85
18
  }
86
-
87
- /**
88
- * @deprecated `SharedIntervalCollection` is not maintained and is planned to be removed.
89
- * @internal
90
- */
91
- export class SharedIntervalCollection
92
- extends SharedObject
93
- implements ISharedIntervalCollection<Interval>
94
- {
95
- /**
96
- * Create a SharedIntervalCollection
97
- *
98
- * @param runtime - data store runtime the new shared map belongs to
99
- * @param id - optional name of the shared map
100
- * @returns newly create shared map (but not attached yet)
101
- */
102
- public static create(runtime: IFluidDataStoreRuntime, id?: string) {
103
- return runtime.createChannel(
104
- id,
105
- SharedIntervalCollectionFactory.Type,
106
- ) as SharedIntervalCollection;
107
- }
108
-
109
- /**
110
- * Get a factory for SharedIntervalCollection to register with the data store.
111
- *
112
- * @returns a factory that creates and load SharedIntervalCollection
113
- */
114
- public static getFactory(): IChannelFactory {
115
- return new SharedIntervalCollectionFactory();
116
- }
117
-
118
- public readonly [Symbol.toStringTag]: string = "SharedIntervalCollection";
119
- private readonly intervalCollections: IntervalCollectionMap<Interval>;
120
-
121
- /**
122
- * Constructs a new shared SharedIntervalCollection. If the object is non-local an id and service interfaces will
123
- * be provided
124
- */
125
- constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes) {
126
- super(id, runtime, attributes, "fluid_sharedIntervalCollection_");
127
- this.intervalCollections = new IntervalCollectionMap(
128
- this.serializer,
129
- this.handle,
130
- (op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),
131
- new IntervalCollectionValueType(),
132
- runtime.options,
133
- );
134
- }
135
-
136
- public getIntervalCollection(label: string): IIntervalCollection<Interval> {
137
- const realLabel = this.getIntervalCollectionPath(label);
138
- const sharedCollection = this.intervalCollections.get(realLabel);
139
- return sharedCollection;
140
- }
141
-
142
- protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {
143
- return createSingleBlobSummary(
144
- snapshotFileName,
145
- this.intervalCollections.serialize(serializer),
146
- );
147
- }
148
-
149
- protected reSubmitCore(content: any, localOpMetadata: unknown) {
150
- this.intervalCollections.tryResubmitMessage(
151
- content,
152
- localOpMetadata as IMapMessageLocalMetadata,
153
- );
154
- }
155
-
156
- protected onDisconnect() {}
157
-
158
- /**
159
- * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
160
- */
161
- protected async loadCore(storage: IChannelStorageService) {
162
- const blob = await storage.readBlob(snapshotFileName);
163
- const header = bufferToString(blob, "utf8");
164
- this.intervalCollections.populate(header);
165
- }
166
-
167
- protected processCore(
168
- message: ISequencedDocumentMessage,
169
- local: boolean,
170
- localOpMetadata: unknown,
171
- ) {
172
- if (message.type === MessageType.Operation) {
173
- assert(
174
- this.intervalCollections.tryProcessMessage(
175
- message.contents as IMapOperation,
176
- local,
177
- message,
178
- localOpMetadata,
179
- ),
180
- 0xab3 /* SharedIntervalCollection received an unrecognized op, possibly from a newer version */,
181
- );
182
- }
183
- }
184
-
185
- /**
186
- * Creates the full path of the intervalCollection label
187
- * @param label - the incoming label
188
- */
189
- protected getIntervalCollectionPath(label: string): string {
190
- return label;
191
- }
192
-
193
- protected applyStashedOp() {
194
- throw new Error("not implemented");
195
- }
196
- }
@@ -245,42 +245,24 @@ export class SharedStringClass
245
245
  * {@inheritDoc ISharedString.getText}
246
246
  */
247
247
  public getText(start?: number, end?: number) {
248
- const segmentWindow = this.client.getCollabWindow();
249
- return this.mergeTreeTextHelper.getText(
250
- segmentWindow.currentSeq,
251
- segmentWindow.clientId,
252
- "",
253
- start,
254
- end,
255
- );
248
+ const collabWindow = this.client.getCollabWindow();
249
+ return this.mergeTreeTextHelper.getText(collabWindow.localPerspective, "", start, end);
256
250
  }
257
251
 
258
252
  /**
259
253
  * {@inheritDoc ISharedString.getTextWithPlaceholders}
260
254
  */
261
255
  public getTextWithPlaceholders(start?: number, end?: number) {
262
- const segmentWindow = this.client.getCollabWindow();
263
- return this.mergeTreeTextHelper.getText(
264
- segmentWindow.currentSeq,
265
- segmentWindow.clientId,
266
- " ",
267
- start,
268
- end,
269
- );
256
+ const collabWindow = this.client.getCollabWindow();
257
+ return this.mergeTreeTextHelper.getText(collabWindow.localPerspective, " ", start, end);
270
258
  }
271
259
 
272
260
  /**
273
261
  * {@inheritDoc ISharedString.getTextRangeWithMarkers}
274
262
  */
275
263
  public getTextRangeWithMarkers(start: number, end: number) {
276
- const segmentWindow = this.client.getCollabWindow();
277
- return this.mergeTreeTextHelper.getText(
278
- segmentWindow.currentSeq,
279
- segmentWindow.clientId,
280
- "*",
281
- start,
282
- end,
283
- );
264
+ const collabWindow = this.client.getCollabWindow();
265
+ return this.mergeTreeTextHelper.getText(collabWindow.localPerspective, "*", start, end);
284
266
  }
285
267
 
286
268
  /**
@@ -1,76 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
6
- import { PropertiesManager, PropertySet, SequencePlace } from "@fluidframework/merge-tree/internal";
7
- import { IIntervalHelpers, ISerializableInterval, ISerializedInterval } from "./intervalUtils.js";
8
- /**
9
- * Serializable interval whose endpoints are plain-old numbers.
10
- * @internal
11
- */
12
- export declare class Interval implements ISerializableInterval {
13
- start: number;
14
- end: number;
15
- /**
16
- * {@inheritDoc ISerializableInterval.properties}
17
- */
18
- properties: PropertySet;
19
- /***/
20
- auxProps: PropertySet[] | undefined;
21
- propertyManager?: PropertiesManager;
22
- constructor(start: number, end: number, props?: PropertySet);
23
- /**
24
- * {@inheritDoc ISerializableInterval.getIntervalId}
25
- */
26
- getIntervalId(): string;
27
- /**
28
- * @returns an array containing any auxiliary property sets added with `addPropertySet`.
29
- */
30
- getAdditionalPropertySets(): PropertySet[];
31
- /**
32
- * Adds an auxiliary set of properties to this interval.
33
- * These properties can be recovered using `getAdditionalPropertySets`
34
- * @param props - set of properties to add
35
- * @remarks This gets called as part of the default conflict resolver for `IIntervalCollection<Interval>`
36
- * (i.e. non-sequence-based interval collections). However, the additional properties don't get serialized.
37
- * This functionality seems half-baked.
38
- */
39
- addPropertySet(props: PropertySet): void;
40
- /**
41
- * {@inheritDoc ISerializableInterval.serialize}
42
- */
43
- serialize(): ISerializedInterval;
44
- /**
45
- * {@inheritDoc IInterval.clone}
46
- */
47
- clone(): Interval;
48
- /**
49
- * {@inheritDoc IInterval.compare}
50
- */
51
- compare(b: Interval): number;
52
- /**
53
- * {@inheritDoc IInterval.compareStart}
54
- */
55
- compareStart(b: Interval): number;
56
- /**
57
- * {@inheritDoc IInterval.compareEnd}
58
- */
59
- compareEnd(b: Interval): number;
60
- /**
61
- * {@inheritDoc IInterval.overlaps}
62
- */
63
- overlaps(b: Interval): boolean;
64
- /**
65
- * {@inheritDoc IInterval.union}
66
- */
67
- union(b: Interval): Interval;
68
- getProperties(): PropertySet;
69
- /**
70
- * {@inheritDoc IInterval.modify}
71
- */
72
- modify(label: string, start?: SequencePlace, end?: SequencePlace, op?: ISequencedDocumentMessage): Interval | undefined;
73
- }
74
- export declare function createInterval(label: string, start: SequencePlace, end: SequencePlace): Interval;
75
- export declare const intervalHelpers: IIntervalHelpers<Interval>;
76
- //# sourceMappingURL=interval.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interval.d.ts","sourceRoot":"","sources":["../../src/intervals/interval.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EACN,iBAAiB,EACjB,WAAW,EAGX,aAAa,EAGb,MAAM,qCAAqC,CAAC;AAK7C,OAAO,EACN,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,qBAAa,QAAS,YAAW,qBAAqB;IAY7C,KAAK,EAAE,MAAM;IACb,GAAG,EAAE,MAAM;IAZnB;;OAEG;IACI,UAAU,EAAE,WAAW,CAAoB;IAElD,KAAK;IACE,QAAQ,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC;IAEpC,eAAe,CAAC,EAAE,iBAAiB,CAAC;gBAGnC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,WAAW;IAOpB;;OAEG;IACI,aAAa,IAAI,MAAM;IAM9B;;OAEG;IACI,yBAAyB,IAAI,WAAW,EAAE;IAIjD;;;;;;;OAOG;IACI,cAAc,CAAC,KAAK,EAAE,WAAW;IAOxC;;OAEG;IACI,SAAS,IAAI,mBAAmB;IAgBvC;;OAEG;IACI,KAAK;IAIZ;;OAEG;IACI,OAAO,CAAC,CAAC,EAAE,QAAQ;IAsB1B;;OAEG;IACI,YAAY,CAAC,CAAC,EAAE,QAAQ;IAI/B;;OAEG;IACI,UAAU,CAAC,CAAC,EAAE,QAAQ;IAI7B;;OAEG;IACI,QAAQ,CAAC,CAAC,EAAE,QAAQ;IAK3B;;OAEG;IACI,KAAK,CAAC,CAAC,EAAE,QAAQ;IAQjB,aAAa;IAIpB;;OAEG;IACI,MAAM,CACZ,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,aAAa,EACrB,GAAG,CAAC,EAAE,aAAa,EACnB,EAAE,CAAC,EAAE,yBAAyB;CAmB/B;AAED,wBAAgB,cAAc,CAC7B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,aAAa,EACpB,GAAG,EAAE,aAAa,GAChB,QAAQ,CAiBV;AAED,eAAO,MAAM,eAAe,EAAE,gBAAgB,CAAC,QAAQ,CAEtD,CAAC"}
@@ -1,167 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.intervalHelpers = exports.createInterval = exports.Interval = void 0;
8
- /* eslint-disable import/no-deprecated */
9
- const internal_1 = require("@fluidframework/core-utils/internal");
10
- const internal_2 = require("@fluidframework/merge-tree/internal");
11
- const internal_3 = require("@fluidframework/telemetry-utils/internal");
12
- const intervalCollection_js_1 = require("../intervalCollection.js");
13
- /**
14
- * Serializable interval whose endpoints are plain-old numbers.
15
- * @internal
16
- */
17
- class Interval {
18
- constructor(start, end, props) {
19
- this.start = start;
20
- this.end = end;
21
- /**
22
- * {@inheritDoc ISerializableInterval.properties}
23
- */
24
- this.properties = (0, internal_2.createMap)();
25
- if (props) {
26
- this.properties = (0, internal_2.addProperties)(this.properties, props);
27
- }
28
- }
29
- /**
30
- * {@inheritDoc ISerializableInterval.getIntervalId}
31
- */
32
- getIntervalId() {
33
- const id = this.properties?.[intervalCollection_js_1.reservedIntervalIdKey];
34
- (0, internal_1.assert)(id !== undefined, 0x5e1 /* interval ID should not be undefined */);
35
- return `${id}`;
36
- }
37
- /**
38
- * @returns an array containing any auxiliary property sets added with `addPropertySet`.
39
- */
40
- getAdditionalPropertySets() {
41
- return this.auxProps ?? [];
42
- }
43
- /**
44
- * Adds an auxiliary set of properties to this interval.
45
- * These properties can be recovered using `getAdditionalPropertySets`
46
- * @param props - set of properties to add
47
- * @remarks This gets called as part of the default conflict resolver for `IIntervalCollection<Interval>`
48
- * (i.e. non-sequence-based interval collections). However, the additional properties don't get serialized.
49
- * This functionality seems half-baked.
50
- */
51
- addPropertySet(props) {
52
- if (this.auxProps === undefined) {
53
- this.auxProps = [];
54
- }
55
- this.auxProps.push(props);
56
- }
57
- /**
58
- * {@inheritDoc ISerializableInterval.serialize}
59
- */
60
- serialize() {
61
- const serializedInterval = {
62
- end: this.end,
63
- intervalType: 0,
64
- sequenceNumber: 0,
65
- start: this.start,
66
- };
67
- if (this.properties) {
68
- serializedInterval.properties = (0, internal_2.addProperties)(serializedInterval.properties, this.properties);
69
- }
70
- return serializedInterval;
71
- }
72
- /**
73
- * {@inheritDoc IInterval.clone}
74
- */
75
- clone() {
76
- return new Interval(this.start, this.end, this.properties);
77
- }
78
- /**
79
- * {@inheritDoc IInterval.compare}
80
- */
81
- compare(b) {
82
- const startResult = this.compareStart(b);
83
- if (startResult === 0) {
84
- const endResult = this.compareEnd(b);
85
- if (endResult === 0) {
86
- const thisId = this.getIntervalId();
87
- if (thisId) {
88
- const bId = b.getIntervalId();
89
- if (bId) {
90
- return thisId > bId ? 1 : thisId < bId ? -1 : 0;
91
- }
92
- return 0;
93
- }
94
- return 0;
95
- }
96
- else {
97
- return endResult;
98
- }
99
- }
100
- else {
101
- return startResult;
102
- }
103
- }
104
- /**
105
- * {@inheritDoc IInterval.compareStart}
106
- */
107
- compareStart(b) {
108
- return this.start - b.start;
109
- }
110
- /**
111
- * {@inheritDoc IInterval.compareEnd}
112
- */
113
- compareEnd(b) {
114
- return this.end - b.end;
115
- }
116
- /**
117
- * {@inheritDoc IInterval.overlaps}
118
- */
119
- overlaps(b) {
120
- const result = this.start <= b.end && this.end >= b.start;
121
- return result;
122
- }
123
- /**
124
- * {@inheritDoc IInterval.union}
125
- */
126
- union(b) {
127
- return new Interval(Math.min(this.start, b.start), Math.max(this.end, b.end), this.properties);
128
- }
129
- getProperties() {
130
- return this.properties;
131
- }
132
- /**
133
- * {@inheritDoc IInterval.modify}
134
- */
135
- modify(label, start, end, op) {
136
- if (typeof start === "string" || typeof end === "string") {
137
- throw new internal_3.UsageError("The start and end positions of a plain interval may not be on the special endpoint segments.");
138
- }
139
- const startPos = typeof start === "number" ? start : (start?.pos ?? this.start);
140
- const endPos = typeof end === "number" ? end : (end?.pos ?? this.end);
141
- if (this.start === startPos && this.end === endPos) {
142
- // Return undefined to indicate that no change is necessary.
143
- return;
144
- }
145
- const newInterval = new Interval(startPos, endPos);
146
- (0, internal_2.copyPropertiesAndManager)(this, newInterval);
147
- return newInterval;
148
- }
149
- }
150
- exports.Interval = Interval;
151
- function createInterval(label, start, end) {
152
- if (typeof start === "string" || typeof end === "string") {
153
- throw new internal_3.UsageError("The start and end positions of a plain interval may not be on the special endpoint segments.");
154
- }
155
- const rangeProp = {};
156
- if (label && label.length > 0) {
157
- rangeProp[internal_2.reservedRangeLabelsKey] = [label];
158
- }
159
- const startPos = typeof start === "number" ? start : start.pos;
160
- const endPos = typeof end === "number" ? end : end.pos;
161
- return new Interval(startPos, endPos, rangeProp);
162
- }
163
- exports.createInterval = createInterval;
164
- exports.intervalHelpers = {
165
- create: createInterval,
166
- };
167
- //# sourceMappingURL=interval.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interval.js","sourceRoot":"","sources":["../../src/intervals/interval.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAAyC;AAEzC,kEAA6D;AAE7D,kEAQ6C;AAC7C,uEAAsE;AAEtE,oEAAiE;AAQjE;;;GAGG;AACH,MAAa,QAAQ;IAWpB,YACQ,KAAa,EACb,GAAW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BAsKC;AAED,SAAgB,cAAc,CAC7B,KAAa,EACb,KAAoB,EACpB,GAAkB;IAElB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC1D,MAAM,IAAI,qBAAU,CACnB,8FAA8F,CAC9F,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAgB,EAAE,CAAC;IAElC,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,SAAS,CAAC,iCAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;IAC/D,MAAM,MAAM,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAEvD,OAAO,IAAI,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAClD,CAAC;AArBD,wCAqBC;AAEY,QAAA,eAAe,GAA+B;IAC1D,MAAM,EAAE,cAAc;CACtB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-deprecated */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tPropertiesManager,\n\tPropertySet,\n\tcreateMap,\n\treservedRangeLabelsKey,\n\tSequencePlace,\n\taddProperties,\n\tcopyPropertiesAndManager,\n} from \"@fluidframework/merge-tree/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { reservedIntervalIdKey } from \"../intervalCollection.js\";\n\nimport {\n\tIIntervalHelpers,\n\tISerializableInterval,\n\tISerializedInterval,\n} from \"./intervalUtils.js\";\n\n/**\n * Serializable interval whose endpoints are plain-old numbers.\n * @internal\n */\nexport class Interval implements ISerializableInterval {\n\t/**\n\t * {@inheritDoc ISerializableInterval.properties}\n\t */\n\tpublic properties: PropertySet = createMap<any>();\n\n\t/***/\n\tpublic auxProps: PropertySet[] | undefined;\n\n\tpublic propertyManager?: PropertiesManager;\n\n\tconstructor(\n\t\tpublic start: number,\n\t\tpublic end: number,\n\t\tprops?: PropertySet,\n\t) {\n\t\tif (props) {\n\t\t\tthis.properties = addProperties(this.properties, props);\n\t\t}\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, 0x5e1 /* interval ID should not be undefined */);\n\t\treturn `${id}`;\n\t}\n\n\t/**\n\t * @returns an array containing any auxiliary property sets added with `addPropertySet`.\n\t */\n\tpublic getAdditionalPropertySets(): PropertySet[] {\n\t\treturn this.auxProps ?? [];\n\t}\n\n\t/**\n\t * Adds an auxiliary set of properties to this interval.\n\t * These properties can be recovered using `getAdditionalPropertySets`\n\t * @param props - set of properties to add\n\t * @remarks This gets called as part of the default conflict resolver for `IIntervalCollection<Interval>`\n\t * (i.e. non-sequence-based interval collections). However, the additional properties don't get serialized.\n\t * This functionality seems half-baked.\n\t */\n\tpublic addPropertySet(props: PropertySet) {\n\t\tif (this.auxProps === undefined) {\n\t\t\tthis.auxProps = [];\n\t\t}\n\t\tthis.auxProps.push(props);\n\t}\n\n\t/**\n\t * {@inheritDoc ISerializableInterval.serialize}\n\t */\n\tpublic serialize(): ISerializedInterval {\n\t\tconst serializedInterval: ISerializedInterval = {\n\t\t\tend: this.end,\n\t\t\tintervalType: 0,\n\t\t\tsequenceNumber: 0,\n\t\t\tstart: this.start,\n\t\t};\n\t\tif (this.properties) {\n\t\t\tserializedInterval.properties = addProperties(\n\t\t\t\tserializedInterval.properties,\n\t\t\t\tthis.properties,\n\t\t\t);\n\t\t}\n\t\treturn serializedInterval;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.clone}\n\t */\n\tpublic clone() {\n\t\treturn new Interval(this.start, this.end, this.properties);\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compare}\n\t */\n\tpublic compare(b: Interval) {\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: Interval) {\n\t\treturn this.start - b.start;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.compareEnd}\n\t */\n\tpublic compareEnd(b: Interval) {\n\t\treturn this.end - b.end;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.overlaps}\n\t */\n\tpublic overlaps(b: Interval) {\n\t\tconst result = this.start <= b.end && this.end >= b.start;\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.union}\n\t */\n\tpublic union(b: Interval) {\n\t\treturn new Interval(\n\t\t\tMath.min(this.start, b.start),\n\t\t\tMath.max(this.end, b.end),\n\t\t\tthis.properties,\n\t\t);\n\t}\n\n\tpublic getProperties() {\n\t\treturn this.properties;\n\t}\n\n\t/**\n\t * {@inheritDoc IInterval.modify}\n\t */\n\tpublic modify(\n\t\tlabel: string,\n\t\tstart?: SequencePlace,\n\t\tend?: SequencePlace,\n\t\top?: ISequencedDocumentMessage,\n\t) {\n\t\tif (typeof start === \"string\" || typeof end === \"string\") {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"The start and end positions of a plain interval may not be on the special endpoint segments.\",\n\t\t\t);\n\t\t}\n\n\t\tconst startPos = typeof start === \"number\" ? start : (start?.pos ?? this.start);\n\t\tconst endPos = typeof end === \"number\" ? end : (end?.pos ?? this.end);\n\n\t\tif (this.start === startPos && this.end === endPos) {\n\t\t\t// Return undefined to indicate that no change is necessary.\n\t\t\treturn;\n\t\t}\n\t\tconst newInterval = new Interval(startPos, endPos);\n\t\tcopyPropertiesAndManager(this, newInterval);\n\t\treturn newInterval;\n\t}\n}\n\nexport function createInterval(\n\tlabel: string,\n\tstart: SequencePlace,\n\tend: SequencePlace,\n): Interval {\n\tif (typeof start === \"string\" || typeof end === \"string\") {\n\t\tthrow new UsageError(\n\t\t\t\"The start and end positions of a plain interval may not be on the special endpoint segments.\",\n\t\t);\n\t}\n\n\tconst rangeProp: PropertySet = {};\n\n\tif (label && label.length > 0) {\n\t\trangeProp[reservedRangeLabelsKey] = [label];\n\t}\n\n\tconst startPos = typeof start === \"number\" ? start : start.pos;\n\tconst endPos = typeof end === \"number\" ? end : end.pos;\n\n\treturn new Interval(startPos, endPos, rangeProp);\n}\n\nexport const intervalHelpers: IIntervalHelpers<Interval> = {\n\tcreate: createInterval,\n};\n"]}