@fluidframework/sequence 2.0.0-internal.7.3.0 → 2.0.0-internal.7.4.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 (203) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/api-extractor-lint.json +13 -0
  3. package/api-extractor.json +8 -3
  4. package/api-report/sequence.api.md +87 -84
  5. package/dist/defaultMap.d.ts +3 -3
  6. package/dist/defaultMap.d.ts.map +1 -1
  7. package/dist/defaultMap.js +7 -2
  8. package/dist/defaultMap.js.map +1 -1
  9. package/dist/defaultMapInterfaces.d.ts +11 -10
  10. package/dist/defaultMapInterfaces.d.ts.map +1 -1
  11. package/dist/defaultMapInterfaces.js.map +1 -1
  12. package/dist/intervalCollection.d.ts +66 -12
  13. package/dist/intervalCollection.d.ts.map +1 -1
  14. package/dist/intervalCollection.js +50 -45
  15. package/dist/intervalCollection.js.map +1 -1
  16. package/dist/intervalIndex/endpointInRangeIndex.d.ts +2 -2
  17. package/dist/intervalIndex/endpointInRangeIndex.js +1 -1
  18. package/dist/intervalIndex/endpointInRangeIndex.js.map +1 -1
  19. package/dist/intervalIndex/endpointIndex.d.ts +2 -2
  20. package/dist/intervalIndex/endpointIndex.js +1 -1
  21. package/dist/intervalIndex/endpointIndex.js.map +1 -1
  22. package/dist/intervalIndex/idIntervalIndex.d.ts +2 -2
  23. package/dist/intervalIndex/idIntervalIndex.js +1 -1
  24. package/dist/intervalIndex/idIntervalIndex.js.map +1 -1
  25. package/dist/intervalIndex/intervalIndex.d.ts +1 -1
  26. package/dist/intervalIndex/intervalIndex.js.map +1 -1
  27. package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +2 -2
  28. package/dist/intervalIndex/overlappingIntervalsIndex.js +1 -1
  29. package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  30. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +1 -1
  31. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js +1 -1
  32. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  33. package/dist/intervalIndex/sequenceIntervalIndexes.d.ts +2 -1
  34. package/dist/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
  35. package/dist/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
  36. package/dist/intervalIndex/startpointInRangeIndex.d.ts +2 -2
  37. package/dist/intervalIndex/startpointInRangeIndex.js +1 -1
  38. package/dist/intervalIndex/startpointInRangeIndex.js.map +1 -1
  39. package/dist/intervals/interval.d.ts +2 -7
  40. package/dist/intervals/interval.d.ts.map +1 -1
  41. package/dist/intervals/interval.js +1 -5
  42. package/dist/intervals/interval.js.map +1 -1
  43. package/dist/intervals/intervalUtils.d.ts +15 -14
  44. package/dist/intervals/intervalUtils.d.ts.map +1 -1
  45. package/dist/intervals/intervalUtils.js +3 -3
  46. package/dist/intervals/intervalUtils.js.map +1 -1
  47. package/dist/intervals/sequenceInterval.d.ts +3 -12
  48. package/dist/intervals/sequenceInterval.d.ts.map +1 -1
  49. package/dist/intervals/sequenceInterval.js +3 -11
  50. package/dist/intervals/sequenceInterval.js.map +1 -1
  51. package/dist/localValues.d.ts +2 -1
  52. package/dist/localValues.d.ts.map +1 -1
  53. package/dist/localValues.js.map +1 -1
  54. package/dist/packageVersion.d.ts +1 -1
  55. package/dist/packageVersion.js +1 -1
  56. package/dist/packageVersion.js.map +1 -1
  57. package/dist/revertibles.d.ts +9 -15
  58. package/dist/revertibles.d.ts.map +1 -1
  59. package/dist/revertibles.js +7 -9
  60. package/dist/revertibles.js.map +1 -1
  61. package/dist/sequence-alpha.d.ts +226 -507
  62. package/dist/sequence-beta.d.ts +131 -1368
  63. package/dist/sequence-public.d.ts +131 -1368
  64. package/dist/sequence-untrimmed.d.ts +121 -90
  65. package/dist/sequence.d.ts +2 -3
  66. package/dist/sequence.d.ts.map +1 -1
  67. package/dist/sequence.js +1 -1
  68. package/dist/sequence.js.map +1 -1
  69. package/dist/sequenceDeltaEvent.d.ts +4 -4
  70. package/dist/sequenceDeltaEvent.js +3 -3
  71. package/dist/sequenceDeltaEvent.js.map +1 -1
  72. package/dist/sequenceFactory.d.ts +1 -1
  73. package/dist/sequenceFactory.js +1 -1
  74. package/dist/sequenceFactory.js.map +1 -1
  75. package/dist/sharedIntervalCollection.d.ts +3 -3
  76. package/dist/sharedIntervalCollection.js +2 -2
  77. package/dist/sharedIntervalCollection.js.map +1 -1
  78. package/dist/sharedSequence.d.ts +3 -3
  79. package/dist/sharedSequence.js +2 -2
  80. package/dist/sharedSequence.js.map +1 -1
  81. package/dist/sharedString.d.ts +8 -5
  82. package/dist/sharedString.d.ts.map +1 -1
  83. package/dist/sharedString.js +6 -3
  84. package/dist/sharedString.js.map +1 -1
  85. package/lib/defaultMap.d.ts +3 -3
  86. package/lib/defaultMap.d.ts.map +1 -1
  87. package/lib/defaultMap.js +29 -20
  88. package/lib/defaultMap.js.map +1 -1
  89. package/lib/defaultMapInterfaces.d.ts +11 -10
  90. package/lib/defaultMapInterfaces.d.ts.map +1 -1
  91. package/lib/defaultMapInterfaces.js +2 -1
  92. package/lib/defaultMapInterfaces.js.map +1 -1
  93. package/lib/index.js +45 -10
  94. package/lib/index.js.map +1 -1
  95. package/lib/intervalCollection.d.ts +66 -12
  96. package/lib/intervalCollection.d.ts.map +1 -1
  97. package/lib/intervalCollection.js +174 -156
  98. package/lib/intervalCollection.js.map +1 -1
  99. package/lib/intervalIndex/endpointInRangeIndex.d.ts +2 -2
  100. package/lib/intervalIndex/endpointInRangeIndex.js +18 -13
  101. package/lib/intervalIndex/endpointInRangeIndex.js.map +1 -1
  102. package/lib/intervalIndex/endpointIndex.d.ts +2 -2
  103. package/lib/intervalIndex/endpointIndex.js +14 -9
  104. package/lib/intervalIndex/endpointIndex.js.map +1 -1
  105. package/lib/intervalIndex/idIntervalIndex.d.ts +2 -2
  106. package/lib/intervalIndex/idIntervalIndex.js +9 -5
  107. package/lib/intervalIndex/idIntervalIndex.js.map +1 -1
  108. package/lib/intervalIndex/index.js +19 -6
  109. package/lib/intervalIndex/index.js.map +1 -1
  110. package/lib/intervalIndex/intervalIndex.d.ts +1 -1
  111. package/lib/intervalIndex/intervalIndex.js +2 -1
  112. package/lib/intervalIndex/intervalIndex.js.map +1 -1
  113. package/lib/intervalIndex/intervalIndexUtils.js +8 -4
  114. package/lib/intervalIndex/intervalIndexUtils.js.map +1 -1
  115. package/lib/intervalIndex/overlappingIntervalsIndex.d.ts +2 -2
  116. package/lib/intervalIndex/overlappingIntervalsIndex.js +16 -11
  117. package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  118. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +1 -1
  119. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js +15 -11
  120. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  121. package/lib/intervalIndex/sequenceIntervalIndexes.d.ts +2 -1
  122. package/lib/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
  123. package/lib/intervalIndex/sequenceIntervalIndexes.js +2 -1
  124. package/lib/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
  125. package/lib/intervalIndex/startpointInRangeIndex.d.ts +2 -2
  126. package/lib/intervalIndex/startpointInRangeIndex.js +18 -13
  127. package/lib/intervalIndex/startpointInRangeIndex.js.map +1 -1
  128. package/lib/intervalTree.js +9 -4
  129. package/lib/intervalTree.js.map +1 -1
  130. package/lib/intervals/index.js +18 -3
  131. package/lib/intervals/index.js.map +1 -1
  132. package/lib/intervals/interval.d.ts +2 -7
  133. package/lib/intervals/interval.d.ts.map +1 -1
  134. package/lib/intervals/interval.js +19 -18
  135. package/lib/intervals/interval.js.map +1 -1
  136. package/lib/intervals/intervalUtils.d.ts +15 -14
  137. package/lib/intervals/intervalUtils.d.ts.map +1 -1
  138. package/lib/intervals/intervalUtils.js +21 -16
  139. package/lib/intervals/intervalUtils.js.map +1 -1
  140. package/lib/intervals/sequenceInterval.d.ts +3 -12
  141. package/lib/intervals/sequenceInterval.d.ts.map +1 -1
  142. package/lib/intervals/sequenceInterval.js +68 -70
  143. package/lib/intervals/sequenceInterval.js.map +1 -1
  144. package/lib/localValues.d.ts +2 -1
  145. package/lib/localValues.d.ts.map +1 -1
  146. package/lib/localValues.js +9 -4
  147. package/lib/localValues.js.map +1 -1
  148. package/lib/packageVersion.d.ts +1 -1
  149. package/lib/packageVersion.js +5 -2
  150. package/lib/packageVersion.js.map +1 -1
  151. package/lib/revertibles.d.ts +9 -15
  152. package/lib/revertibles.d.ts.map +1 -1
  153. package/lib/revertibles.js +76 -68
  154. package/lib/revertibles.js.map +1 -1
  155. package/lib/sequence-alpha.d.ts +226 -507
  156. package/lib/sequence-beta.d.ts +131 -1368
  157. package/lib/sequence-public.d.ts +131 -1368
  158. package/lib/sequence-untrimmed.d.ts +121 -90
  159. package/lib/sequence.d.ts +2 -3
  160. package/lib/sequence.d.ts.map +1 -1
  161. package/lib/sequence.js +45 -40
  162. package/lib/sequence.js.map +1 -1
  163. package/lib/sequenceDeltaEvent.d.ts +4 -4
  164. package/lib/sequenceDeltaEvent.js +16 -10
  165. package/lib/sequenceDeltaEvent.js.map +1 -1
  166. package/lib/sequenceFactory.d.ts +1 -1
  167. package/lib/sequenceFactory.js +14 -10
  168. package/lib/sequenceFactory.js.map +1 -1
  169. package/lib/sharedIntervalCollection.d.ts +3 -3
  170. package/lib/sharedIntervalCollection.js +20 -15
  171. package/lib/sharedIntervalCollection.js.map +1 -1
  172. package/lib/sharedSequence.d.ts +3 -3
  173. package/lib/sharedSequence.js +13 -8
  174. package/lib/sharedSequence.js.map +1 -1
  175. package/lib/sharedString.d.ts +8 -5
  176. package/lib/sharedString.d.ts.map +1 -1
  177. package/lib/sharedString.js +27 -19
  178. package/lib/sharedString.js.map +1 -1
  179. package/package.json +22 -20
  180. package/sequence.test-files.tar +0 -0
  181. package/src/defaultMap.ts +22 -16
  182. package/src/defaultMapInterfaces.ts +15 -12
  183. package/src/intervalCollection.ts +131 -67
  184. package/src/intervalIndex/endpointInRangeIndex.ts +2 -2
  185. package/src/intervalIndex/endpointIndex.ts +2 -2
  186. package/src/intervalIndex/idIntervalIndex.ts +2 -2
  187. package/src/intervalIndex/intervalIndex.ts +1 -1
  188. package/src/intervalIndex/overlappingIntervalsIndex.ts +2 -2
  189. package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +1 -1
  190. package/src/intervalIndex/sequenceIntervalIndexes.ts +2 -1
  191. package/src/intervalIndex/startpointInRangeIndex.ts +2 -2
  192. package/src/intervals/interval.ts +2 -7
  193. package/src/intervals/intervalUtils.ts +15 -15
  194. package/src/intervals/sequenceInterval.ts +3 -12
  195. package/src/localValues.ts +2 -1
  196. package/src/packageVersion.ts +1 -1
  197. package/src/revertibles.ts +9 -15
  198. package/src/sequence.ts +2 -3
  199. package/src/sequenceDeltaEvent.ts +4 -4
  200. package/src/sequenceFactory.ts +1 -1
  201. package/src/sharedIntervalCollection.ts +3 -3
  202. package/src/sharedSequence.ts +3 -3
  203. package/src/sharedString.ts +8 -5
@@ -1,10 +1,13 @@
1
+ "use strict";
1
2
  /*!
2
3
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
4
  * Licensed under the MIT License.
4
5
  */
5
- import { Marker, refHasTileLabel, TextSegment, } from "@fluidframework/merge-tree";
6
- import { SharedSegmentSequence } from "./sequence";
7
- import { SharedStringFactory } from "./sequenceFactory";
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.getTextAndMarkers = exports.SharedString = void 0;
8
+ const merge_tree_1 = require("@fluidframework/merge-tree");
9
+ const sequence_1 = require("./sequence");
10
+ const sequenceFactory_1 = require("./sequenceFactory");
8
11
  /**
9
12
  * The Shared String is a specialized data structure for handling collaborative
10
13
  * text. It is based on a more general Sequence data structure but has
@@ -13,10 +16,9 @@ import { SharedStringFactory } from "./sequenceFactory";
13
16
  * In addition to text, a Shared String can also contain markers. Markers can be
14
17
  * used to store metadata at positions within the text, like the details of an
15
18
  * image or Fluid object that should be rendered with the text.
16
- *
17
- * @public
19
+ * @alpha
18
20
  */
19
- export class SharedString extends SharedSegmentSequence {
21
+ class SharedString extends sequence_1.SharedSegmentSequence {
20
22
  /**
21
23
  * Create a new shared string.
22
24
  * @param runtime - data store runtime the new shared string belongs to
@@ -24,20 +26,20 @@ export class SharedString extends SharedSegmentSequence {
24
26
  * @returns newly create shared string (but not attached yet)
25
27
  */
26
28
  static create(runtime, id) {
27
- return runtime.createChannel(id, SharedStringFactory.Type);
29
+ return runtime.createChannel(id, sequenceFactory_1.SharedStringFactory.Type);
28
30
  }
29
31
  /**
30
32
  * Get a factory for SharedString to register with the data store.
31
33
  * @returns a factory that creates and load SharedString
32
34
  */
33
35
  static getFactory() {
34
- return new SharedStringFactory();
36
+ return new sequenceFactory_1.SharedStringFactory();
35
37
  }
36
38
  get ISharedString() {
37
39
  return this;
38
40
  }
39
41
  constructor(document, id, attributes) {
40
- super(document, id, attributes, SharedStringFactory.segmentFromSpec);
42
+ super(document, id, attributes, sequenceFactory_1.SharedStringFactory.segmentFromSpec);
41
43
  this.id = id;
42
44
  this.mergeTreeTextHelper = this.client.createTextHelper();
43
45
  }
@@ -48,7 +50,7 @@ export class SharedString extends SharedSegmentSequence {
48
50
  * @param props - The properties of the marker
49
51
  */
50
52
  insertMarkerRelative(relativePos1, refType, props) {
51
- const segment = new Marker(refType);
53
+ const segment = new merge_tree_1.Marker(refType);
52
54
  if (props) {
53
55
  segment.addProperties(props);
54
56
  }
@@ -59,7 +61,7 @@ export class SharedString extends SharedSegmentSequence {
59
61
  * {@inheritDoc ISharedString.insertMarker}
60
62
  */
61
63
  insertMarker(pos, refType, props) {
62
- const segment = new Marker(refType);
64
+ const segment = new merge_tree_1.Marker(refType);
63
65
  if (props) {
64
66
  segment.addProperties(props);
65
67
  }
@@ -72,7 +74,7 @@ export class SharedString extends SharedSegmentSequence {
72
74
  * @param props - The properties of text
73
75
  */
74
76
  insertTextRelative(relativePos1, text, props) {
75
- const segment = new TextSegment(text);
77
+ const segment = new merge_tree_1.TextSegment(text);
76
78
  if (props) {
77
79
  segment.addProperties(props);
78
80
  }
@@ -83,7 +85,7 @@ export class SharedString extends SharedSegmentSequence {
83
85
  * {@inheritDoc ISharedString.insertText}
84
86
  */
85
87
  insertText(pos, text, props) {
86
- const segment = new TextSegment(text);
88
+ const segment = new merge_tree_1.TextSegment(text);
87
89
  if (props) {
88
90
  segment.addProperties(props);
89
91
  }
@@ -97,7 +99,7 @@ export class SharedString extends SharedSegmentSequence {
97
99
  * @param props - Optional. The properties of the replacement text
98
100
  */
99
101
  replaceText(start, end, text, props) {
100
- this.replaceRange(start, end, TextSegment.make(text, props));
102
+ this.replaceRange(start, end, merge_tree_1.TextSegment.make(text, props));
101
103
  }
102
104
  /**
103
105
  * Removes the text in the given range.
@@ -113,6 +115,10 @@ export class SharedString extends SharedSegmentSequence {
113
115
  * @param marker - The marker to annotate
114
116
  * @param props - The properties to annotate the marker with
115
117
  * @param consensusCallback - The callback called when consensus is reached
118
+ *
119
+ * @deprecated We no longer intend to support this functionality and it will
120
+ * be removed in a future release. There is no replacement for this
121
+ * functionality.
116
122
  */
117
123
  annotateMarkerNotifyConsensus(marker, props, callback) {
118
124
  this.guardReentrancy(() => this.client.annotateMarkerNotifyConsensus(marker, props, callback));
@@ -189,6 +195,7 @@ export class SharedString extends SharedSegmentSequence {
189
195
  }
190
196
  }
191
197
  }
198
+ exports.SharedString = SharedString;
192
199
  /**
193
200
  * Splits the text into regions ending with markers with the given `label`.
194
201
  * @param sharedString - String to retrieve text and markers from
@@ -202,22 +209,23 @@ export class SharedString extends SharedSegmentSequence {
202
209
  * // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]
203
210
  * // Note parallelText does not include "missing".
204
211
  * ```
205
- * @public
212
+ * @internal
206
213
  */
207
- export function getTextAndMarkers(sharedString, label, start, end) {
214
+ function getTextAndMarkers(sharedString, label, start, end) {
208
215
  const accum = {
209
216
  parallelMarkerLabel: label,
210
217
  parallelMarkers: [],
211
218
  parallelText: [],
212
219
  tagsInProgress: [],
213
- textSegment: new TextSegment(""),
220
+ textSegment: new merge_tree_1.TextSegment(""),
214
221
  };
215
222
  sharedString.walkSegments(gatherTextAndMarkers, start, end, accum);
216
223
  return { parallelText: accum.parallelText, parallelMarkers: accum.parallelMarkers };
217
224
  }
225
+ exports.getTextAndMarkers = getTextAndMarkers;
218
226
  const gatherTextAndMarkers = (segment, pos, refSeq, clientId, start, end, accumText) => {
219
227
  const { placeholder, tagsInProgress, textSegment } = accumText;
220
- if (TextSegment.is(segment)) {
228
+ if (merge_tree_1.TextSegment.is(segment)) {
221
229
  let beginTags = "";
222
230
  let endTags = "";
223
231
  // TODO: let clients pass in function to get tag
@@ -281,7 +289,7 @@ const gatherTextAndMarkers = (segment, pos, refSeq, clientId, start, end, accumT
281
289
  }
282
290
  else {
283
291
  const marker = segment;
284
- if (refHasTileLabel(marker, accumText.parallelMarkerLabel)) {
292
+ if ((0, merge_tree_1.refHasTileLabel)(marker, accumText.parallelMarkerLabel)) {
285
293
  accumText.parallelMarkers.push(marker);
286
294
  accumText.parallelText.push(textSegment.text);
287
295
  textSegment.text = "";
@@ -1 +1 @@
1
- {"version":3,"file":"sharedString.js","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAQN,MAAM,EAIN,eAAe,EACf,WAAW,GACX,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAsCxD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,YACZ,SAAQ,qBAA0C;IAGlD;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAChE,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,mBAAmB,CAAC,IAAI,CAAiB,CAAC;IAC5E,CAAC;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I,CAAC,MAAM,CAAC,CAAC;gBACvC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAC9C,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC;aACtB;SACD;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tICombiningOp,\n\tIMergeTreeInsertMsg,\n\tIMergeTreeRemoveMsg,\n\tIMergeTreeTextHelper,\n\tIRelativePosition,\n\tISegment,\n\tISegmentAction,\n\tMarker,\n\tPropertySet,\n\tReferencePosition,\n\tReferenceType,\n\trefHasTileLabel,\n\tTextSegment,\n} from \"@fluidframework/merge-tree\";\nimport { IFluidDataStoreRuntime, IChannelAttributes } from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\nimport { SharedStringFactory } from \"./sequenceFactory\";\n\n/**\n * Fluid object interface describing access methods on a SharedString\n * @public\n */\nexport interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {\n\t/**\n\t * Inserts the text at the position.\n\t * @param pos - The position to insert the text at\n\t * @param text - The text to insert\n\t * @param props - The properties of the text\n\t */\n\tinsertText(pos: number, text: string, props?: PropertySet): void;\n\n\t/**\n\t * Inserts a marker at the position.\n\t * @param pos - The position to insert the marker at\n\t * @param refType - The reference type of the marker\n\t * @param props - The properties of the marker\n\t */\n\tinsertMarker(\n\t\tpos: number,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): IMergeTreeInsertMsg | undefined;\n\n\t/**\n\t * {@inheritDoc SharedSegmentSequence.posFromRelativePos}\n\t */\n\tposFromRelativePos(relativePos: IRelativePosition): number;\n}\n\n/**\n * @public\n */\nexport type SharedStringSegment = TextSegment | Marker;\n\n/**\n * The Shared String is a specialized data structure for handling collaborative\n * text. It is based on a more general Sequence data structure but has\n * additional features that make working with text easier.\n *\n * In addition to text, a Shared String can also contain markers. Markers can be\n * used to store metadata at positions within the text, like the details of an\n * image or Fluid object that should be rendered with the text.\n *\n * @public\n */\nexport class SharedString\n\textends SharedSegmentSequence<SharedStringSegment>\n\timplements ISharedString\n{\n\t/**\n\t * Create a new shared string.\n\t * @param runtime - data store runtime the new shared string belongs to\n\t * @param id - optional name of the shared string\n\t * @returns newly create shared string (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string) {\n\t\treturn runtime.createChannel(id, SharedStringFactory.Type) as SharedString;\n\t}\n\n\t/**\n\t * Get a factory for SharedString to register with the data store.\n\t * @returns a factory that creates and load SharedString\n\t */\n\tpublic static getFactory() {\n\t\treturn new SharedStringFactory();\n\t}\n\n\tpublic get ISharedString(): ISharedString {\n\t\treturn this;\n\t}\n\n\tprivate readonly mergeTreeTextHelper: IMergeTreeTextHelper;\n\n\tconstructor(\n\t\tdocument: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(document, id, attributes, SharedStringFactory.segmentFromSpec as any);\n\t\tthis.mergeTreeTextHelper = this.client.createTextHelper();\n\t}\n\n\t/**\n\t * Inserts a marker at a relative position.\n\t * @param relativePos1 - The relative position to insert the marker at\n\t * @param refType - The reference type of the marker\n\t * @param props - The properties of the marker\n\t */\n\tpublic insertMarkerRelative(\n\t\trelativePos1: IRelativePosition,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t) {\n\t\tconst segment = new Marker(refType);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertMarker}\n\t */\n\tpublic insertMarker(\n\t\tpos: number,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): IMergeTreeInsertMsg | undefined {\n\t\tconst segment = new Marker(refType);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\treturn this.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * Inserts the text at the position.\n\t * @param relativePos1 - The relative position to insert the text at\n\t * @param text - The text to insert\n\t * @param props - The properties of text\n\t */\n\tpublic insertTextRelative(relativePos1: IRelativePosition, text: string, props?: PropertySet) {\n\t\tconst segment = new TextSegment(text);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertText}\n\t */\n\tpublic insertText(pos: number, text: string, props?: PropertySet) {\n\t\tconst segment = new TextSegment(text);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * Replaces a range with the provided text.\n\t * @param start - The inclusive start of the range to replace\n\t * @param end - The exclusive end of the range to replace\n\t * @param text - The text to replace the range with\n\t * @param props - Optional. The properties of the replacement text\n\t */\n\tpublic replaceText(start: number, end: number, text: string, props?: PropertySet) {\n\t\tthis.replaceRange(start, end, TextSegment.make(text, props));\n\t}\n\n\t/**\n\t * Removes the text in the given range.\n\t * @param start - The inclusive start of the range to remove\n\t * @param end - The exclusive end of the range to replace\n\t * @returns the message sent.\n\t */\n\tpublic removeText(start: number, end: number): IMergeTreeRemoveMsg {\n\t\treturn this.removeRange(start, end);\n\t}\n\n\t/**\n\t * Annotates the marker with the provided properties and calls the callback on consensus.\n\t * @param marker - The marker to annotate\n\t * @param props - The properties to annotate the marker with\n\t * @param consensusCallback - The callback called when consensus is reached\n\t */\n\tpublic annotateMarkerNotifyConsensus(\n\t\tmarker: Marker,\n\t\tprops: PropertySet,\n\t\tcallback: (m: Marker) => void,\n\t) {\n\t\tthis.guardReentrancy(() =>\n\t\t\tthis.client.annotateMarkerNotifyConsensus(marker, props, callback),\n\t\t);\n\t}\n\n\t/**\n\t * Annotates the marker with the provided properties.\n\t * @param marker - The marker to annotate\n\t * @param props - The properties to annotate the marker with\n\t * @param combiningOp - Optional. Specifies how to combine values for the property, such as \"incr\" for increment.\n\t */\n\tpublic annotateMarker(marker: Marker, props: PropertySet, combiningOp?: ICombiningOp) {\n\t\tthis.guardReentrancy(() => this.client.annotateMarker(marker, props, combiningOp));\n\t}\n\n\t/**\n\t * Finds the nearest reference with ReferenceType.Tile to `startPos` in the direction dictated by `tilePrecedesPos`.\n\t * Note that Markers receive `ReferenceType.Tile` by default.\n\t * @deprecated Use `searchForMarker` instead.\n\t * @param startPos - Position at which to start the search\n\t * @param clientId - clientId dictating the perspective to search from\n\t * @param tileLabel - Label of the tile to search for\n\t * @param preceding - Whether the desired tile comes before (true) or after (false) `startPos`\n\t */\n\tpublic findTile(\n\t\tstartPos: number | undefined,\n\t\ttileLabel: string,\n\t\tpreceding = true,\n\t):\n\t\t| {\n\t\t\t\ttile: ReferencePosition;\n\t\t\t\tpos: number;\n\t\t }\n\t\t| undefined {\n\t\treturn this.client.findTile(startPos ?? 0, tileLabel, preceding);\n\t}\n\n\t/**\n\t * Searches a string for the nearest marker in either direction to a given start position.\n\t * The search will include the start position, so markers at the start position are valid\n\t * results of the search.\n\t * @param startPos - Position at which to start the search\n\t * @param markerLabel - Label of the marker to search for\n\t * @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`\n\t */\n\tpublic searchForMarker(\n\t\tstartPos: number,\n\t\tmarkerLabel: string,\n\t\tforwards = true,\n\t): Marker | undefined {\n\t\treturn this.client.searchForMarker(startPos, markerLabel, forwards);\n\t}\n\n\t/**\n\t * Retrieve text from the SharedString in string format.\n\t * @param start - The starting index of the text to retrieve, or 0 if omitted.\n\t * @param end - The ending index of the text to retrieve, or the end of the string if omitted\n\t * @returns The requested text content as a string.\n\t */\n\tpublic getText(start?: number, end?: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\"\",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\t/**\n\t * Adds spaces for markers and handles, so that position calculations account for them.\n\t */\n\tpublic getTextWithPlaceholders(start?: number, end?: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\" \",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\tpublic getTextRangeWithMarkers(start: number, end: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\"*\",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\t/**\n\t * Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided\n\t * id in this `SharedString`.\n\t */\n\tpublic getMarkerFromId(id: string): ISegment | undefined {\n\t\treturn this.client.getMarkerFromId(id);\n\t}\n\n\t/**\n\t * Revert an op\n\t */\n\tprotected rollback(content: any, localOpMetadata: unknown): void {\n\t\tif (this.client.rollback !== undefined) {\n\t\t\tthis.client.rollback(content, localOpMetadata);\n\t\t} else {\n\t\t\tsuper.rollback(content, localOpMetadata);\n\t\t}\n\t}\n}\n\ninterface ITextAndMarkerAccumulator {\n\tparallelText: string[];\n\tparallelMarkers: Marker[];\n\tparallelMarkerLabel: string;\n\tplaceholder?: string;\n\ttagsInProgress: string[];\n\ttextSegment: TextSegment;\n}\n\n/**\n * Splits the text into regions ending with markers with the given `label`.\n * @param sharedString - String to retrieve text and markers from\n * @param label - label to split on\n * @returns Two parallel lists of text and markers, split by markers with the provided `label`.\n * For example:\n * ```typescript\n * // Say sharedstring has contents \"hello<paragraph marker 1>world<paragraph marker 2>missing\".\n * const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, \"paragraph\");\n * // parallelText === [\"hello\", \"world\"]\n * // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]\n * // Note parallelText does not include \"missing\".\n * ```\n * @public\n */\nexport function getTextAndMarkers(\n\tsharedString: SharedString,\n\tlabel: string,\n\tstart?: number,\n\tend?: number,\n): {\n\tparallelText: string[];\n\tparallelMarkers: Marker[];\n} {\n\tconst accum: ITextAndMarkerAccumulator = {\n\t\tparallelMarkerLabel: label,\n\t\tparallelMarkers: [],\n\t\tparallelText: [],\n\t\ttagsInProgress: [],\n\t\ttextSegment: new TextSegment(\"\"),\n\t};\n\n\tsharedString.walkSegments(gatherTextAndMarkers, start, end, accum);\n\treturn { parallelText: accum.parallelText, parallelMarkers: accum.parallelMarkers };\n}\n\nconst gatherTextAndMarkers: ISegmentAction<ITextAndMarkerAccumulator> = (\n\tsegment: ISegment,\n\tpos: number,\n\trefSeq: number,\n\tclientId: number,\n\tstart: number,\n\tend: number,\n\taccumText: ITextAndMarkerAccumulator,\n) => {\n\tconst { placeholder, tagsInProgress, textSegment } = accumText;\n\tif (TextSegment.is(segment)) {\n\t\tlet beginTags = \"\";\n\t\tlet endTags = \"\";\n\t\t// TODO: let clients pass in function to get tag\n\t\tconst tags = [] as string[];\n\t\tconst initTags = [] as string[];\n\n\t\tif (segment.properties?.[\"font-weight\"]) {\n\t\t\ttags.push(\"b\");\n\t\t}\n\t\tif (segment.properties?.[\"text-decoration\"]) {\n\t\t\ttags.push(\"u\");\n\t\t}\n\t\tconst remTags = [] as string[];\n\t\tif (tags.length > 0) {\n\t\t\tfor (const tag of tags) {\n\t\t\t\tif (!tagsInProgress.includes(tag)) {\n\t\t\t\t\tbeginTags += `<${tag}>`;\n\t\t\t\t\tinitTags.push(tag);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const accumTag of tagsInProgress) {\n\t\t\t\tif (!tags.includes(accumTag)) {\n\t\t\t\t\tendTags += `</${accumTag}>`;\n\t\t\t\t\tremTags.push(accumTag);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const initTag of initTags.reverse()) {\n\t\t\t\ttagsInProgress.push(initTag);\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const accumTag of tagsInProgress) {\n\t\t\t\tendTags += `</${accumTag}>`;\n\t\t\t\tremTags.push(accumTag);\n\t\t\t}\n\t\t}\n\t\tfor (const remTag of remTags) {\n\t\t\tconst remdex = tagsInProgress.indexOf(remTag);\n\t\t\tif (remdex >= 0) {\n\t\t\t\ttagsInProgress.splice(remdex, 1);\n\t\t\t}\n\t\t}\n\t\ttextSegment.text += endTags;\n\t\ttextSegment.text += beginTags;\n\t\tif (start <= 0 && end >= segment.text.length) {\n\t\t\ttextSegment.text += segment.text;\n\t\t} else {\n\t\t\tconst seglen = segment.text.length;\n\t\t\tconst _start = start < 0 ? 0 : start;\n\t\t\tconst _end = end >= seglen ? undefined : end;\n\t\t\ttextSegment.text += segment.text.substring(_start, _end);\n\t\t}\n\t} else {\n\t\tif (placeholder && placeholder.length > 0) {\n\t\t\tconst placeholderText =\n\t\t\t\tplaceholder === \"*\"\n\t\t\t\t\t? // eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\t\t\t `\\n${segment.toString()}`\n\t\t\t\t\t: placeholder.repeat(segment.cachedLength);\n\t\t\ttextSegment.text += placeholderText;\n\t\t} else {\n\t\t\tconst marker = segment as Marker;\n\t\t\tif (refHasTileLabel(marker, accumText.parallelMarkerLabel)) {\n\t\t\t\taccumText.parallelMarkers.push(marker);\n\t\t\t\taccumText.parallelText.push(textSegment.text);\n\t\t\t\ttextSegment.text = \"\";\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n};\n"]}
1
+ {"version":3,"file":"sharedString.js","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAco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AQ,EAAE,EAAE;gBAC3B,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YAC7C,WAAW,CAAC,IAAI,IAAI,eAAe,CAAC;SACpC;aAAM;YACN,MAAM,MAAM,GAAG,OAAiB,CAAC;YACjC,IAAI,IAAA,4BAAe,EAAC,MAAM,EAAE,SAAS,CAAC,mBAAmB,CAAC,EAAE;gBAC3D,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACvC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAC9C,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC;aACtB;SACD;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tICombiningOp,\n\tIMergeTreeInsertMsg,\n\tIMergeTreeRemoveMsg,\n\tIMergeTreeTextHelper,\n\tIRelativePosition,\n\tISegment,\n\tISegmentAction,\n\tMarker,\n\tPropertySet,\n\tReferencePosition,\n\tReferenceType,\n\trefHasTileLabel,\n\tTextSegment,\n} from \"@fluidframework/merge-tree\";\nimport { IFluidDataStoreRuntime, IChannelAttributes } from \"@fluidframework/datastore-definitions\";\nimport { SharedSegmentSequence } from \"./sequence\";\nimport { SharedStringFactory } from \"./sequenceFactory\";\n\n/**\n * Fluid object interface describing access methods on a SharedString\n * @alpha\n */\nexport interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {\n\t/**\n\t * Inserts the text at the position.\n\t * @param pos - The position to insert the text at\n\t * @param text - The text to insert\n\t * @param props - The properties of the text\n\t */\n\tinsertText(pos: number, text: string, props?: PropertySet): void;\n\n\t/**\n\t * Inserts a marker at the position.\n\t * @param pos - The position to insert the marker at\n\t * @param refType - The reference type of the marker\n\t * @param props - The properties of the marker\n\t */\n\tinsertMarker(\n\t\tpos: number,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): IMergeTreeInsertMsg | undefined;\n\n\t/**\n\t * {@inheritDoc SharedSegmentSequence.posFromRelativePos}\n\t */\n\tposFromRelativePos(relativePos: IRelativePosition): number;\n}\n\n/**\n * @alpha\n */\nexport type SharedStringSegment = TextSegment | Marker;\n\n/**\n * The Shared String is a specialized data structure for handling collaborative\n * text. It is based on a more general Sequence data structure but has\n * additional features that make working with text easier.\n *\n * In addition to text, a Shared String can also contain markers. Markers can be\n * used to store metadata at positions within the text, like the details of an\n * image or Fluid object that should be rendered with the text.\n * @alpha\n */\nexport class SharedString\n\textends SharedSegmentSequence<SharedStringSegment>\n\timplements ISharedString\n{\n\t/**\n\t * Create a new shared string.\n\t * @param runtime - data store runtime the new shared string belongs to\n\t * @param id - optional name of the shared string\n\t * @returns newly create shared string (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string) {\n\t\treturn runtime.createChannel(id, SharedStringFactory.Type) as SharedString;\n\t}\n\n\t/**\n\t * Get a factory for SharedString to register with the data store.\n\t * @returns a factory that creates and load SharedString\n\t */\n\tpublic static getFactory() {\n\t\treturn new SharedStringFactory();\n\t}\n\n\tpublic get ISharedString(): ISharedString {\n\t\treturn this;\n\t}\n\n\tprivate readonly mergeTreeTextHelper: IMergeTreeTextHelper;\n\n\tconstructor(\n\t\tdocument: IFluidDataStoreRuntime,\n\t\tpublic id: string,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(document, id, attributes, SharedStringFactory.segmentFromSpec as any);\n\t\tthis.mergeTreeTextHelper = this.client.createTextHelper();\n\t}\n\n\t/**\n\t * Inserts a marker at a relative position.\n\t * @param relativePos1 - The relative position to insert the marker at\n\t * @param refType - The reference type of the marker\n\t * @param props - The properties of the marker\n\t */\n\tpublic insertMarkerRelative(\n\t\trelativePos1: IRelativePosition,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t) {\n\t\tconst segment = new Marker(refType);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertMarker}\n\t */\n\tpublic insertMarker(\n\t\tpos: number,\n\t\trefType: ReferenceType,\n\t\tprops?: PropertySet,\n\t): IMergeTreeInsertMsg | undefined {\n\t\tconst segment = new Marker(refType);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\treturn this.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * Inserts the text at the position.\n\t * @param relativePos1 - The relative position to insert the text at\n\t * @param text - The text to insert\n\t * @param props - The properties of text\n\t */\n\tpublic insertTextRelative(relativePos1: IRelativePosition, text: string, props?: PropertySet) {\n\t\tconst segment = new TextSegment(text);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tconst pos = this.posFromRelativePos(relativePos1);\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedString.insertText}\n\t */\n\tpublic insertText(pos: number, text: string, props?: PropertySet) {\n\t\tconst segment = new TextSegment(text);\n\t\tif (props) {\n\t\t\tsegment.addProperties(props);\n\t\t}\n\n\t\tthis.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));\n\t}\n\n\t/**\n\t * Replaces a range with the provided text.\n\t * @param start - The inclusive start of the range to replace\n\t * @param end - The exclusive end of the range to replace\n\t * @param text - The text to replace the range with\n\t * @param props - Optional. The properties of the replacement text\n\t */\n\tpublic replaceText(start: number, end: number, text: string, props?: PropertySet) {\n\t\tthis.replaceRange(start, end, TextSegment.make(text, props));\n\t}\n\n\t/**\n\t * Removes the text in the given range.\n\t * @param start - The inclusive start of the range to remove\n\t * @param end - The exclusive end of the range to replace\n\t * @returns the message sent.\n\t */\n\tpublic removeText(start: number, end: number): IMergeTreeRemoveMsg {\n\t\treturn this.removeRange(start, end);\n\t}\n\n\t/**\n\t * Annotates the marker with the provided properties and calls the callback on consensus.\n\t * @param marker - The marker to annotate\n\t * @param props - The properties to annotate the marker with\n\t * @param consensusCallback - The callback called when consensus is reached\n\t *\n\t * @deprecated We no longer intend to support this functionality and it will\n\t * be removed in a future release. There is no replacement for this\n\t * functionality.\n\t */\n\tpublic annotateMarkerNotifyConsensus(\n\t\tmarker: Marker,\n\t\tprops: PropertySet,\n\t\tcallback: (m: Marker) => void,\n\t) {\n\t\tthis.guardReentrancy(() =>\n\t\t\tthis.client.annotateMarkerNotifyConsensus(marker, props, callback),\n\t\t);\n\t}\n\n\t/**\n\t * Annotates the marker with the provided properties.\n\t * @param marker - The marker to annotate\n\t * @param props - The properties to annotate the marker with\n\t * @param combiningOp - Optional. Specifies how to combine values for the property, such as \"incr\" for increment.\n\t */\n\tpublic annotateMarker(marker: Marker, props: PropertySet, combiningOp?: ICombiningOp) {\n\t\tthis.guardReentrancy(() => this.client.annotateMarker(marker, props, combiningOp));\n\t}\n\n\t/**\n\t * Finds the nearest reference with ReferenceType.Tile to `startPos` in the direction dictated by `tilePrecedesPos`.\n\t * Note that Markers receive `ReferenceType.Tile` by default.\n\t * @deprecated Use `searchForMarker` instead.\n\t * @param startPos - Position at which to start the search\n\t * @param clientId - clientId dictating the perspective to search from\n\t * @param tileLabel - Label of the tile to search for\n\t * @param preceding - Whether the desired tile comes before (true) or after (false) `startPos`\n\t */\n\tpublic findTile(\n\t\tstartPos: number | undefined,\n\t\ttileLabel: string,\n\t\tpreceding = true,\n\t):\n\t\t| {\n\t\t\t\ttile: ReferencePosition;\n\t\t\t\tpos: number;\n\t\t }\n\t\t| undefined {\n\t\treturn this.client.findTile(startPos ?? 0, tileLabel, preceding);\n\t}\n\n\t/**\n\t * Searches a string for the nearest marker in either direction to a given start position.\n\t * The search will include the start position, so markers at the start position are valid\n\t * results of the search.\n\t * @param startPos - Position at which to start the search\n\t * @param markerLabel - Label of the marker to search for\n\t * @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`\n\t */\n\tpublic searchForMarker(\n\t\tstartPos: number,\n\t\tmarkerLabel: string,\n\t\tforwards = true,\n\t): Marker | undefined {\n\t\treturn this.client.searchForMarker(startPos, markerLabel, forwards);\n\t}\n\n\t/**\n\t * Retrieve text from the SharedString in string format.\n\t * @param start - The starting index of the text to retrieve, or 0 if omitted.\n\t * @param end - The ending index of the text to retrieve, or the end of the string if omitted\n\t * @returns The requested text content as a string.\n\t */\n\tpublic getText(start?: number, end?: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\"\",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\t/**\n\t * Adds spaces for markers and handles, so that position calculations account for them.\n\t */\n\tpublic getTextWithPlaceholders(start?: number, end?: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\" \",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\tpublic getTextRangeWithMarkers(start: number, end: number) {\n\t\tconst segmentWindow = this.client.getCollabWindow();\n\t\treturn this.mergeTreeTextHelper.getText(\n\t\t\tsegmentWindow.currentSeq,\n\t\t\tsegmentWindow.clientId,\n\t\t\t\"*\",\n\t\t\tstart,\n\t\t\tend,\n\t\t);\n\t}\n\n\t/**\n\t * Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided\n\t * id in this `SharedString`.\n\t */\n\tpublic getMarkerFromId(id: string): ISegment | undefined {\n\t\treturn this.client.getMarkerFromId(id);\n\t}\n\n\t/**\n\t * Revert an op\n\t */\n\tprotected rollback(content: any, localOpMetadata: unknown): void {\n\t\tif (this.client.rollback !== undefined) {\n\t\t\tthis.client.rollback(content, localOpMetadata);\n\t\t} else {\n\t\t\tsuper.rollback(content, localOpMetadata);\n\t\t}\n\t}\n}\n\ninterface ITextAndMarkerAccumulator {\n\tparallelText: string[];\n\tparallelMarkers: Marker[];\n\tparallelMarkerLabel: string;\n\tplaceholder?: string;\n\ttagsInProgress: string[];\n\ttextSegment: TextSegment;\n}\n\n/**\n * Splits the text into regions ending with markers with the given `label`.\n * @param sharedString - String to retrieve text and markers from\n * @param label - label to split on\n * @returns Two parallel lists of text and markers, split by markers with the provided `label`.\n * For example:\n * ```typescript\n * // Say sharedstring has contents \"hello<paragraph marker 1>world<paragraph marker 2>missing\".\n * const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, \"paragraph\");\n * // parallelText === [\"hello\", \"world\"]\n * // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]\n * // Note parallelText does not include \"missing\".\n * ```\n * @internal\n */\nexport function getTextAndMarkers(\n\tsharedString: SharedString,\n\tlabel: string,\n\tstart?: number,\n\tend?: number,\n): {\n\tparallelText: string[];\n\tparallelMarkers: Marker[];\n} {\n\tconst accum: ITextAndMarkerAccumulator = {\n\t\tparallelMarkerLabel: label,\n\t\tparallelMarkers: [],\n\t\tparallelText: [],\n\t\ttagsInProgress: [],\n\t\ttextSegment: new TextSegment(\"\"),\n\t};\n\n\tsharedString.walkSegments(gatherTextAndMarkers, start, end, accum);\n\treturn { parallelText: accum.parallelText, parallelMarkers: accum.parallelMarkers };\n}\n\nconst gatherTextAndMarkers: ISegmentAction<ITextAndMarkerAccumulator> = (\n\tsegment: ISegment,\n\tpos: number,\n\trefSeq: number,\n\tclientId: number,\n\tstart: number,\n\tend: number,\n\taccumText: ITextAndMarkerAccumulator,\n) => {\n\tconst { placeholder, tagsInProgress, textSegment } = accumText;\n\tif (TextSegment.is(segment)) {\n\t\tlet beginTags = \"\";\n\t\tlet endTags = \"\";\n\t\t// TODO: let clients pass in function to get tag\n\t\tconst tags = [] as string[];\n\t\tconst initTags = [] as string[];\n\n\t\tif (segment.properties?.[\"font-weight\"]) {\n\t\t\ttags.push(\"b\");\n\t\t}\n\t\tif (segment.properties?.[\"text-decoration\"]) {\n\t\t\ttags.push(\"u\");\n\t\t}\n\t\tconst remTags = [] as string[];\n\t\tif (tags.length > 0) {\n\t\t\tfor (const tag of tags) {\n\t\t\t\tif (!tagsInProgress.includes(tag)) {\n\t\t\t\t\tbeginTags += `<${tag}>`;\n\t\t\t\t\tinitTags.push(tag);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const accumTag of tagsInProgress) {\n\t\t\t\tif (!tags.includes(accumTag)) {\n\t\t\t\t\tendTags += `</${accumTag}>`;\n\t\t\t\t\tremTags.push(accumTag);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const initTag of initTags.reverse()) {\n\t\t\t\ttagsInProgress.push(initTag);\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const accumTag of tagsInProgress) {\n\t\t\t\tendTags += `</${accumTag}>`;\n\t\t\t\tremTags.push(accumTag);\n\t\t\t}\n\t\t}\n\t\tfor (const remTag of remTags) {\n\t\t\tconst remdex = tagsInProgress.indexOf(remTag);\n\t\t\tif (remdex >= 0) {\n\t\t\t\ttagsInProgress.splice(remdex, 1);\n\t\t\t}\n\t\t}\n\t\ttextSegment.text += endTags;\n\t\ttextSegment.text += beginTags;\n\t\tif (start <= 0 && end >= segment.text.length) {\n\t\t\ttextSegment.text += segment.text;\n\t\t} else {\n\t\t\tconst seglen = segment.text.length;\n\t\t\tconst _start = start < 0 ? 0 : start;\n\t\t\tconst _end = end >= seglen ? undefined : end;\n\t\t\ttextSegment.text += segment.text.substring(_start, _end);\n\t\t}\n\t} else {\n\t\tif (placeholder && placeholder.length > 0) {\n\t\t\tconst placeholderText =\n\t\t\t\tplaceholder === \"*\"\n\t\t\t\t\t? // eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\t\t\t `\\n${segment.toString()}`\n\t\t\t\t\t: placeholder.repeat(segment.cachedLength);\n\t\t\ttextSegment.text += placeholderText;\n\t\t} else {\n\t\t\tconst marker = segment as Marker;\n\t\t\tif (refHasTileLabel(marker, accumText.parallelMarkerLabel)) {\n\t\t\t\taccumText.parallelMarkers.push(marker);\n\t\t\t\taccumText.parallelText.push(textSegment.text);\n\t\t\t\ttextSegment.text = \"\";\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/sequence",
3
- "version": "2.0.0-internal.7.3.0",
3
+ "version": "2.0.0-internal.7.4.0",
4
4
  "description": "Distributed sequence",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -35,34 +35,34 @@
35
35
  "temp-directory": "nyc/.nyc_output"
36
36
  },
37
37
  "dependencies": {
38
- "@fluid-internal/client-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
39
- "@fluidframework/core-interfaces": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
40
- "@fluidframework/core-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
41
- "@fluidframework/datastore-definitions": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
42
- "@fluidframework/merge-tree": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
38
+ "@fluid-internal/client-utils": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
39
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
40
+ "@fluidframework/core-utils": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
41
+ "@fluidframework/datastore-definitions": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
42
+ "@fluidframework/merge-tree": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
43
43
  "@fluidframework/protocol-definitions": "^3.0.0",
44
- "@fluidframework/runtime-definitions": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
45
- "@fluidframework/runtime-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
46
- "@fluidframework/shared-object-base": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
47
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
44
+ "@fluidframework/runtime-definitions": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
45
+ "@fluidframework/runtime-utils": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
46
+ "@fluidframework/shared-object-base": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
47
+ "@fluidframework/telemetry-utils": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
48
48
  "uuid": "^9.0.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@fluid-private/stochastic-test-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
52
- "@fluid-private/test-dds-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
51
+ "@arethetypeswrong/cli": "^0.13.3",
52
+ "@fluid-private/stochastic-test-utils": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
53
+ "@fluid-private/test-dds-utils": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
53
54
  "@fluid-tools/benchmark": "^0.48.0",
54
55
  "@fluid-tools/build-cli": "^0.28.0",
55
56
  "@fluidframework/build-common": "^2.0.3",
56
57
  "@fluidframework/build-tools": "^0.28.0",
57
58
  "@fluidframework/eslint-config-fluid": "^3.1.0",
58
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
59
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
59
60
  "@fluidframework/sequence-previous": "npm:@fluidframework/sequence@2.0.0-internal.7.2.0",
60
- "@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
61
+ "@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
61
62
  "@microsoft/api-extractor": "^7.38.3",
62
63
  "@types/diff": "^3.5.1",
63
64
  "@types/mocha": "^9.1.1",
64
- "@types/node": "^16.18.38",
65
- "@types/random-js": "^1.0.31",
65
+ "@types/node": "^18.19.0",
66
66
  "c8": "^7.7.1",
67
67
  "copyfiles": "^2.4.1",
68
68
  "cross-env": "^7.0.3",
@@ -73,7 +73,7 @@
73
73
  "mocha-multi-reporters": "^1.5.1",
74
74
  "moment": "^2.21.0",
75
75
  "prettier": "~3.0.3",
76
- "random-js": "^1.0.8",
76
+ "random-js": "^2.1.0",
77
77
  "rimraf": "^4.4.0",
78
78
  "typescript": "~5.1.6"
79
79
  },
@@ -107,17 +107,19 @@
107
107
  "build:esnext": "tsc --project ./tsconfig.esnext.json",
108
108
  "build:genver": "gen-version",
109
109
  "build:test": "tsc --project ./src/test/tsconfig.json",
110
+ "check:are-the-types-wrong": "attw --pack",
111
+ "check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
110
112
  "ci:build:docs": "api-extractor run",
111
113
  "clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
112
114
  "eslint": "eslint --format stylish src",
113
115
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
114
116
  "format": "npm run prettier:fix",
115
- "lint": "npm run prettier && npm run eslint",
117
+ "lint": "npm run prettier && npm run check:release-tags && npm run eslint",
116
118
  "lint:fix": "npm run prettier:fix && npm run eslint:fix",
117
119
  "perf": "cross-env FLUID_TEST_VERBOSE=1 mocha \"dist/**/*.spec.js\" --node-option unhandled-rejections=strict,expose-gc --exit -r node_modules/@fluidframework/mocha-test-setup --perfMode --fgrep @Benchmark --reporter @fluid-tools/benchmark/dist/MochaReporter.js --timeout 30000",
118
120
  "perf:measure": "npm run perf -- --fgrep @Measurement",
119
- "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
120
- "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
121
+ "prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
122
+ "prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
121
123
  "test": "npm run test:mocha",
122
124
  "test:benchmark:report": "mocha \"dist/test/*.perf.spec.js\" --node-option unhandled-rejections=strict,expose-gc --exit --perfMode --fgrep @Benchmark -r @fluidframework/mocha-test-setup --reporter @fluid-tools/benchmark/dist/MochaReporter.js --timeout 60000",
123
125
  "test:coverage": "c8 npm test",
Binary file
package/src/defaultMap.ts CHANGED
@@ -18,6 +18,7 @@ import {
18
18
  ISerializableValue,
19
19
  ISerializedValue,
20
20
  IValueChanged,
21
+ // eslint-disable-next-line import/no-deprecated
21
22
  IValueOpEmitter,
22
23
  IValueType,
23
24
  IValueTypeOperationValue,
@@ -25,6 +26,7 @@ import {
25
26
  IMapMessageLocalMetadata,
26
27
  SequenceOptions,
27
28
  } from "./defaultMapInterfaces";
29
+ import { IntervalOpType, SerializedIntervalDelta } from "./intervals";
28
30
 
29
31
  /**
30
32
  * Defines the means to process and submit a given op on a map.
@@ -131,7 +133,7 @@ export class DefaultMap<T> {
131
133
  private readonly serializer: IFluidSerializer,
132
134
  private readonly handle: IFluidHandle,
133
135
  private readonly submitMessage: (
134
- op: any,
136
+ op: IMapValueTypeOperation,
135
137
  localOpMetadata: IMapMessageLocalMetadata,
136
138
  ) => void,
137
139
  private readonly type: IValueType<T>,
@@ -292,21 +294,24 @@ export class DefaultMap<T> {
292
294
  * also sent if we are asked to resubmit the message.
293
295
  * @returns True if the operation was submitted, false otherwise.
294
296
  */
295
- public tryResubmitMessage(op: any, localOpMetadata: IMapMessageLocalMetadata): boolean {
297
+ public tryResubmitMessage(
298
+ op: IMapOperation,
299
+ localOpMetadata: IMapMessageLocalMetadata,
300
+ ): boolean {
296
301
  const type: string = op.type;
297
302
  const handler = this.messageHandlers.get(type);
298
303
  if (handler !== undefined) {
299
- handler.resubmit(op as IMapOperation, localOpMetadata);
304
+ handler.resubmit(op, localOpMetadata);
300
305
  return true;
301
306
  }
302
307
  return false;
303
308
  }
304
309
 
305
- public tryGetStashedOpLocalMetadata(op: any): unknown {
310
+ public tryGetStashedOpLocalMetadata(op: IMapOperation): unknown {
306
311
  const type: string = op.type;
307
312
  if (this.messageHandlers.has(type)) {
308
313
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
309
- return this.messageHandlers.get(type)!.getStashedOpLocalMetadata(op as IMapOperation);
314
+ return this.messageHandlers.get(type)!.getStashedOpLocalMetadata(op);
310
315
  }
311
316
  throw new Error("no apply stashed op handler");
312
317
  }
@@ -406,12 +411,11 @@ export class DefaultMap<T> {
406
411
  assert(localValue !== undefined, 0x3f8 /* Local value expected on resubmission */);
407
412
 
408
413
  const handler = localValue.getOpHandler(op.value.opName);
409
- const { rebasedOp, rebasedLocalOpMetadata } = handler.rebase(
410
- localValue.value,
411
- op.value,
412
- localOpMetadata,
413
- );
414
- this.submitMessage({ ...op, value: rebasedOp }, rebasedLocalOpMetadata);
414
+ const rebased = handler.rebase(localValue.value, op.value, localOpMetadata);
415
+ if (rebased !== undefined) {
416
+ const { rebasedOp, rebasedLocalOpMetadata } = rebased;
417
+ this.submitMessage({ ...op, value: rebasedOp }, rebasedLocalOpMetadata);
418
+ }
415
419
  },
416
420
  getStashedOpLocalMetadata: (op: IMapValueTypeOperation) => {
417
421
  assert(
@@ -430,13 +434,15 @@ export class DefaultMap<T> {
430
434
  * @param key - The key of the map that the value type will be stored on
431
435
  * @returns A value op emitter for the given key
432
436
  */
437
+ // eslint-disable-next-line import/no-deprecated
433
438
  private makeMapValueOpEmitter(key: string): IValueOpEmitter {
434
- const emit = (
435
- opName: string,
436
- previousValue: any,
437
- params: any,
439
+ // eslint-disable-next-line import/no-deprecated
440
+ const emit: IValueOpEmitter["emit"] = (
441
+ opName: IntervalOpType,
442
+ previousValue: unknown,
443
+ params: SerializedIntervalDelta,
438
444
  localOpMetadata: IMapMessageLocalMetadata,
439
- ) => {
445
+ ): void => {
440
446
  const translatedParams = makeHandlesSerializable(params, this.serializer, this.handle);
441
447
 
442
448
  const op: IMapValueTypeOperation = {
@@ -6,6 +6,7 @@
6
6
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
7
7
  import { ISharedObjectEvents } from "@fluidframework/shared-object-base";
8
8
  import { IEventThisPlaceHolder } from "@fluidframework/core-interfaces";
9
+ import { ISerializedInterval, IntervalOpType, SerializedIntervalDelta } from "./intervals";
9
10
 
10
11
  /**
11
12
  * Type of "valueChanged" event parameter.
@@ -25,20 +26,20 @@ export interface IValueChanged {
25
26
  /**
26
27
  * Value types are given an IValueOpEmitter to emit their ops through the container type that holds them.
27
28
  * @internal
29
+ * @deprecated - will be remove from public api as there is no public used of this type
28
30
  */
29
31
  export interface IValueOpEmitter {
30
32
  /**
31
33
  * Called by the value type to emit a value type operation through the container type holding it.
32
34
  * @param opName - Name of the emitted operation
33
- * @param previousValue - JSONable previous value as defined by the value type
35
+ * @param previousValue - JSONable previous value as defined by the value type @deprecated unused
34
36
  * @param params - JSONable params for the operation as defined by the value type
35
37
  * @param localOpMetadata - JSONable local metadata which should be submitted with the op
36
- * @internal
37
38
  */
38
39
  emit(
39
- opName: string,
40
- previousValue: any,
41
- params: any,
40
+ opName: IntervalOpType,
41
+ previousValue: undefined,
42
+ params: SerializedIntervalDelta,
42
43
  localOpMetadata: IMapMessageLocalMetadata,
43
44
  ): void;
44
45
  }
@@ -52,7 +53,7 @@ export interface IMapMessageLocalMetadata {
52
53
 
53
54
  /**
54
55
  * Optional flags that configure options for sequence DDSs
55
- * @public
56
+ * @internal
56
57
  */
57
58
  export interface SequenceOptions {
58
59
  /**
@@ -123,7 +124,7 @@ export interface IValueOperation<T> {
123
124
  */
124
125
  process(
125
126
  value: T,
126
- params: any,
127
+ params: ISerializedInterval,
127
128
  local: boolean,
128
129
  message: ISequencedDocumentMessage | undefined,
129
130
  localOpMetadata: IMapMessageLocalMetadata | undefined,
@@ -141,7 +142,9 @@ export interface IValueOperation<T> {
141
142
  value: T,
142
143
  op: IValueTypeOperationValue,
143
144
  localOpMetadata: IMapMessageLocalMetadata,
144
- ): { rebasedOp: IValueTypeOperationValue; rebasedLocalOpMetadata: IMapMessageLocalMetadata };
145
+ ):
146
+ | { rebasedOp: IValueTypeOperationValue; rebasedLocalOpMetadata: IMapMessageLocalMetadata }
147
+ | undefined;
145
148
  }
146
149
 
147
150
  /**
@@ -164,7 +167,7 @@ export interface IValueType<T> {
164
167
  * Operations that can be applied to the value type.
165
168
  * @alpha
166
169
  */
167
- ops: Map<string, IValueOperation<T>>;
170
+ ops: Map<IntervalOpType, IValueOperation<T>>;
168
171
  }
169
172
 
170
173
  export interface ISharedDefaultMapEvents extends ISharedObjectEvents {
@@ -182,7 +185,7 @@ export interface ISharedDefaultMapEvents extends ISharedObjectEvents {
182
185
  * JSON.stringify and comes out of JSON.parse. This format is used both for snapshots (loadCore/populate)
183
186
  * and ops (set).
184
187
  *
185
- * The DefaultMap impelmentation for sequence has been specialized to only support a single ValueType, which serializes
188
+ * The DefaultMap implementation for sequence has been specialized to only support a single ValueType, which serializes
186
189
  * and deserializes via .store() and .load().
187
190
  */
188
191
  export interface ISerializableValue {
@@ -222,10 +225,10 @@ export interface IValueTypeOperationValue {
222
225
  /**
223
226
  * The name of the operation.
224
227
  */
225
- opName: string;
228
+ opName: IntervalOpType;
226
229
 
227
230
  /**
228
231
  * The payload that is submitted along with the operation.
229
232
  */
230
- value: any;
233
+ value: SerializedIntervalDelta;
231
234
  }