@fluidframework/sequence 1.4.0-115997 → 2.0.0-dev-rc.1.0.0.224419

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 (349) hide show
  1. package/.eslintrc.js +9 -11
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +449 -0
  4. package/README.md +364 -183
  5. package/api-extractor-lint.json +4 -0
  6. package/api-extractor.json +2 -2
  7. package/api-report/sequence.api.md +741 -0
  8. package/dist/{defaultMap.js → defaultMap.cjs} +29 -22
  9. package/dist/defaultMap.cjs.map +1 -0
  10. package/dist/defaultMap.d.ts +7 -6
  11. package/dist/defaultMap.d.ts.map +1 -1
  12. package/dist/defaultMapInterfaces.cjs +7 -0
  13. package/dist/defaultMapInterfaces.cjs.map +1 -0
  14. package/dist/defaultMapInterfaces.d.ts +44 -12
  15. package/dist/defaultMapInterfaces.d.ts.map +1 -1
  16. package/dist/index.cjs +60 -0
  17. package/dist/index.cjs.map +1 -0
  18. package/dist/index.d.ts +14 -12
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/intervalCollection.cjs +1159 -0
  21. package/dist/intervalCollection.cjs.map +1 -0
  22. package/dist/intervalCollection.d.ts +461 -162
  23. package/dist/intervalCollection.d.ts.map +1 -1
  24. package/dist/intervalIndex/endpointInRangeIndex.cjs +66 -0
  25. package/dist/intervalIndex/endpointInRangeIndex.cjs.map +1 -0
  26. package/dist/intervalIndex/endpointInRangeIndex.d.ts +34 -0
  27. package/dist/intervalIndex/endpointInRangeIndex.d.ts.map +1 -0
  28. package/dist/intervalIndex/endpointIndex.cjs +47 -0
  29. package/dist/intervalIndex/endpointIndex.cjs.map +1 -0
  30. package/dist/intervalIndex/endpointIndex.d.ts +38 -0
  31. package/dist/intervalIndex/endpointIndex.d.ts.map +1 -0
  32. package/dist/intervalIndex/idIntervalIndex.cjs +44 -0
  33. package/dist/intervalIndex/idIntervalIndex.cjs.map +1 -0
  34. package/dist/intervalIndex/idIntervalIndex.d.ts +18 -0
  35. package/dist/intervalIndex/idIntervalIndex.d.ts.map +1 -0
  36. package/dist/intervalIndex/index.cjs +24 -0
  37. package/dist/intervalIndex/index.cjs.map +1 -0
  38. package/dist/intervalIndex/index.d.ts +13 -0
  39. package/dist/intervalIndex/index.d.ts.map +1 -0
  40. package/dist/{defaultMapInterfaces.js → intervalIndex/intervalIndex.cjs} +1 -1
  41. package/dist/intervalIndex/intervalIndex.cjs.map +1 -0
  42. package/dist/intervalIndex/intervalIndex.d.ts +30 -0
  43. package/dist/intervalIndex/intervalIndex.d.ts.map +1 -0
  44. package/dist/intervalIndex/intervalIndexUtils.cjs +22 -0
  45. package/dist/intervalIndex/intervalIndexUtils.cjs.map +1 -0
  46. package/dist/intervalIndex/intervalIndexUtils.d.ts +17 -0
  47. package/dist/intervalIndex/intervalIndexUtils.d.ts.map +1 -0
  48. package/dist/intervalIndex/overlappingIntervalsIndex.cjs +116 -0
  49. package/dist/intervalIndex/overlappingIntervalsIndex.cjs.map +1 -0
  50. package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +44 -0
  51. package/dist/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -0
  52. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.cjs +41 -0
  53. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.cjs.map +1 -0
  54. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +11 -0
  55. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -0
  56. package/dist/intervalIndex/sequenceIntervalIndexes.cjs +7 -0
  57. package/dist/intervalIndex/sequenceIntervalIndexes.cjs.map +1 -0
  58. package/dist/intervalIndex/sequenceIntervalIndexes.d.ts +35 -0
  59. package/dist/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -0
  60. package/dist/intervalIndex/startpointInRangeIndex.cjs +66 -0
  61. package/dist/intervalIndex/startpointInRangeIndex.cjs.map +1 -0
  62. package/dist/intervalIndex/startpointInRangeIndex.d.ts +34 -0
  63. package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -0
  64. package/dist/intervalTree.cjs +80 -0
  65. package/dist/intervalTree.cjs.map +1 -0
  66. package/dist/intervalTree.d.ts +24 -0
  67. package/dist/intervalTree.d.ts.map +1 -0
  68. package/dist/intervals/index.cjs +23 -0
  69. package/dist/intervals/index.cjs.map +1 -0
  70. package/dist/intervals/index.d.ts +8 -0
  71. package/dist/intervals/index.d.ts.map +1 -0
  72. package/dist/intervals/interval.cjs +181 -0
  73. package/dist/intervals/interval.cjs.map +1 -0
  74. package/dist/intervals/interval.d.ts +84 -0
  75. package/dist/intervals/interval.d.ts.map +1 -0
  76. package/dist/intervals/intervalUtils.cjs +83 -0
  77. package/dist/intervals/intervalUtils.cjs.map +1 -0
  78. package/dist/intervals/intervalUtils.d.ts +230 -0
  79. package/dist/intervals/intervalUtils.d.ts.map +1 -0
  80. package/dist/intervals/sequenceInterval.cjs +378 -0
  81. package/dist/intervals/sequenceInterval.cjs.map +1 -0
  82. package/dist/intervals/sequenceInterval.d.ts +137 -0
  83. package/dist/intervals/sequenceInterval.d.ts.map +1 -0
  84. package/dist/{localValues.js → localValues.cjs} +1 -1
  85. package/dist/localValues.cjs.map +1 -0
  86. package/dist/localValues.d.ts +2 -1
  87. package/dist/localValues.d.ts.map +1 -1
  88. package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
  89. package/dist/packageVersion.cjs.map +1 -0
  90. package/dist/packageVersion.d.ts +1 -1
  91. package/dist/packageVersion.d.ts.map +1 -1
  92. package/dist/revertibles.cjs +425 -0
  93. package/dist/revertibles.cjs.map +1 -0
  94. package/dist/revertibles.d.ts +86 -0
  95. package/dist/revertibles.d.ts.map +1 -0
  96. package/dist/sequence-alpha.d.ts +1315 -0
  97. package/dist/sequence-beta.d.ts +244 -0
  98. package/dist/sequence-public.d.ts +244 -0
  99. package/dist/sequence-untrimmed.d.ts +1803 -0
  100. package/dist/{sequence.js → sequence.cjs} +226 -156
  101. package/dist/sequence.cjs.map +1 -0
  102. package/dist/sequence.d.ts +125 -48
  103. package/dist/sequence.d.ts.map +1 -1
  104. package/dist/{sequenceDeltaEvent.js → sequenceDeltaEvent.cjs} +18 -8
  105. package/dist/sequenceDeltaEvent.cjs.map +1 -0
  106. package/dist/sequenceDeltaEvent.d.ts +24 -7
  107. package/dist/sequenceDeltaEvent.d.ts.map +1 -1
  108. package/dist/sequenceFactory.cjs +55 -0
  109. package/dist/sequenceFactory.cjs.map +1 -0
  110. package/dist/sequenceFactory.d.ts +3 -89
  111. package/dist/sequenceFactory.d.ts.map +1 -1
  112. package/dist/{sharedIntervalCollection.js → sharedIntervalCollection.cjs} +17 -22
  113. package/dist/sharedIntervalCollection.cjs.map +1 -0
  114. package/dist/sharedIntervalCollection.d.ts +12 -12
  115. package/dist/sharedIntervalCollection.d.ts.map +1 -1
  116. package/dist/{sharedSequence.js → sharedSequence.cjs} +29 -22
  117. package/dist/sharedSequence.cjs.map +1 -0
  118. package/dist/sharedSequence.d.ts +14 -2
  119. package/dist/sharedSequence.d.ts.map +1 -1
  120. package/dist/sharedString.cjs +286 -0
  121. package/dist/sharedString.cjs.map +1 -0
  122. package/dist/sharedString.d.ts +58 -22
  123. package/dist/sharedString.d.ts.map +1 -1
  124. package/dist/tsdoc-metadata.json +11 -0
  125. package/lib/{defaultMap.d.ts → defaultMap.d.mts} +7 -6
  126. package/lib/defaultMap.d.mts.map +1 -0
  127. package/lib/{defaultMap.js → defaultMap.mjs} +28 -21
  128. package/lib/defaultMap.mjs.map +1 -0
  129. package/lib/{defaultMapInterfaces.d.ts → defaultMapInterfaces.d.mts} +44 -12
  130. package/lib/defaultMapInterfaces.d.mts.map +1 -0
  131. package/lib/defaultMapInterfaces.mjs +6 -0
  132. package/lib/defaultMapInterfaces.mjs.map +1 -0
  133. package/lib/index.d.mts +17 -0
  134. package/lib/index.d.mts.map +1 -0
  135. package/lib/index.mjs +16 -0
  136. package/lib/index.mjs.map +1 -0
  137. package/lib/intervalCollection.d.mts +569 -0
  138. package/lib/intervalCollection.d.mts.map +1 -0
  139. package/lib/intervalCollection.mjs +1144 -0
  140. package/lib/intervalCollection.mjs.map +1 -0
  141. package/lib/intervalIndex/endpointInRangeIndex.d.mts +34 -0
  142. package/lib/intervalIndex/endpointInRangeIndex.d.mts.map +1 -0
  143. package/lib/intervalIndex/endpointInRangeIndex.mjs +61 -0
  144. package/lib/intervalIndex/endpointInRangeIndex.mjs.map +1 -0
  145. package/lib/intervalIndex/endpointIndex.d.mts +38 -0
  146. package/lib/intervalIndex/endpointIndex.d.mts.map +1 -0
  147. package/lib/intervalIndex/endpointIndex.mjs +42 -0
  148. package/lib/intervalIndex/endpointIndex.mjs.map +1 -0
  149. package/lib/intervalIndex/idIntervalIndex.d.mts +18 -0
  150. package/lib/intervalIndex/idIntervalIndex.d.mts.map +1 -0
  151. package/lib/intervalIndex/idIntervalIndex.mjs +40 -0
  152. package/lib/intervalIndex/idIntervalIndex.mjs.map +1 -0
  153. package/lib/intervalIndex/index.d.mts +13 -0
  154. package/lib/intervalIndex/index.d.mts.map +1 -0
  155. package/lib/intervalIndex/index.mjs +11 -0
  156. package/lib/intervalIndex/index.mjs.map +1 -0
  157. package/lib/intervalIndex/intervalIndex.d.mts +30 -0
  158. package/lib/intervalIndex/intervalIndex.d.mts.map +1 -0
  159. package/lib/{defaultMapInterfaces.js → intervalIndex/intervalIndex.mjs} +1 -1
  160. package/lib/intervalIndex/intervalIndex.mjs.map +1 -0
  161. package/lib/intervalIndex/intervalIndexUtils.d.mts +17 -0
  162. package/lib/intervalIndex/intervalIndexUtils.d.mts.map +1 -0
  163. package/lib/intervalIndex/intervalIndexUtils.mjs +18 -0
  164. package/lib/intervalIndex/intervalIndexUtils.mjs.map +1 -0
  165. package/lib/intervalIndex/overlappingIntervalsIndex.d.mts +44 -0
  166. package/lib/intervalIndex/overlappingIntervalsIndex.d.mts.map +1 -0
  167. package/lib/intervalIndex/overlappingIntervalsIndex.mjs +111 -0
  168. package/lib/intervalIndex/overlappingIntervalsIndex.mjs.map +1 -0
  169. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.mts +11 -0
  170. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.mts.map +1 -0
  171. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.mjs +37 -0
  172. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.mjs.map +1 -0
  173. package/lib/intervalIndex/sequenceIntervalIndexes.d.mts +35 -0
  174. package/lib/intervalIndex/sequenceIntervalIndexes.d.mts.map +1 -0
  175. package/lib/intervalIndex/sequenceIntervalIndexes.mjs +6 -0
  176. package/lib/intervalIndex/sequenceIntervalIndexes.mjs.map +1 -0
  177. package/lib/intervalIndex/startpointInRangeIndex.d.mts +34 -0
  178. package/lib/intervalIndex/startpointInRangeIndex.d.mts.map +1 -0
  179. package/lib/intervalIndex/startpointInRangeIndex.mjs +61 -0
  180. package/lib/intervalIndex/startpointInRangeIndex.mjs.map +1 -0
  181. package/lib/intervalTree.d.mts +24 -0
  182. package/lib/intervalTree.d.mts.map +1 -0
  183. package/lib/intervalTree.mjs +76 -0
  184. package/lib/intervalTree.mjs.map +1 -0
  185. package/lib/intervals/index.d.mts +8 -0
  186. package/lib/intervals/index.d.mts.map +1 -0
  187. package/lib/intervals/index.mjs +8 -0
  188. package/lib/intervals/index.mjs.map +1 -0
  189. package/lib/intervals/interval.d.mts +84 -0
  190. package/lib/intervals/interval.d.mts.map +1 -0
  191. package/lib/intervals/interval.mjs +176 -0
  192. package/lib/intervals/interval.mjs.map +1 -0
  193. package/lib/intervals/intervalUtils.d.mts +230 -0
  194. package/lib/intervals/intervalUtils.d.mts.map +1 -0
  195. package/lib/intervals/intervalUtils.mjs +77 -0
  196. package/lib/intervals/intervalUtils.mjs.map +1 -0
  197. package/lib/intervals/sequenceInterval.d.mts +137 -0
  198. package/lib/intervals/sequenceInterval.d.mts.map +1 -0
  199. package/lib/intervals/sequenceInterval.mjs +370 -0
  200. package/lib/intervals/sequenceInterval.mjs.map +1 -0
  201. package/lib/{localValues.d.ts → localValues.d.mts} +3 -2
  202. package/lib/localValues.d.mts.map +1 -0
  203. package/lib/{localValues.js → localValues.mjs} +2 -2
  204. package/lib/localValues.mjs.map +1 -0
  205. package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
  206. package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +1 -1
  207. package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
  208. package/lib/packageVersion.mjs.map +1 -0
  209. package/lib/revertibles.d.mts +86 -0
  210. package/lib/revertibles.d.mts.map +1 -0
  211. package/lib/revertibles.mjs +416 -0
  212. package/lib/revertibles.mjs.map +1 -0
  213. package/lib/sequence-alpha.d.mts +1315 -0
  214. package/lib/sequence-beta.d.mts +244 -0
  215. package/lib/sequence-public.d.mts +244 -0
  216. package/lib/sequence-untrimmed.d.mts +1803 -0
  217. package/lib/{sequence.d.ts → sequence.d.mts} +127 -50
  218. package/lib/sequence.d.mts.map +1 -0
  219. package/lib/{sequence.js → sequence.mjs} +225 -152
  220. package/lib/sequence.mjs.map +1 -0
  221. package/lib/{sequenceDeltaEvent.d.ts → sequenceDeltaEvent.d.mts} +24 -7
  222. package/lib/sequenceDeltaEvent.d.mts.map +1 -0
  223. package/lib/{sequenceDeltaEvent.js → sequenceDeltaEvent.mjs} +20 -8
  224. package/lib/sequenceDeltaEvent.mjs.map +1 -0
  225. package/lib/sequenceFactory.d.mts +22 -0
  226. package/lib/sequenceFactory.d.mts.map +1 -0
  227. package/lib/sequenceFactory.mjs +51 -0
  228. package/lib/sequenceFactory.mjs.map +1 -0
  229. package/lib/{sharedIntervalCollection.d.ts → sharedIntervalCollection.d.mts} +12 -12
  230. package/lib/sharedIntervalCollection.d.mts.map +1 -0
  231. package/lib/{sharedIntervalCollection.js → sharedIntervalCollection.mjs} +16 -21
  232. package/lib/sharedIntervalCollection.mjs.map +1 -0
  233. package/lib/{sharedSequence.d.ts → sharedSequence.d.mts} +15 -3
  234. package/lib/sharedSequence.d.mts.map +1 -0
  235. package/lib/{sharedSequence.js → sharedSequence.mjs} +30 -23
  236. package/lib/sharedSequence.mjs.map +1 -0
  237. package/lib/{sharedString.d.ts → sharedString.d.mts} +60 -24
  238. package/lib/sharedString.d.mts.map +1 -0
  239. package/lib/sharedString.mjs +281 -0
  240. package/lib/sharedString.mjs.map +1 -0
  241. package/package.json +146 -75
  242. package/prettier.config.cjs +8 -0
  243. package/sequence.test-files.tar +0 -0
  244. package/src/defaultMap.ts +417 -403
  245. package/src/defaultMapInterfaces.ts +157 -117
  246. package/src/index.ts +86 -26
  247. package/src/intervalCollection.ts +2043 -1563
  248. package/src/intervalIndex/endpointInRangeIndex.ts +116 -0
  249. package/src/intervalIndex/endpointIndex.ts +91 -0
  250. package/src/intervalIndex/idIntervalIndex.ts +64 -0
  251. package/src/intervalIndex/index.ts +25 -0
  252. package/src/intervalIndex/intervalIndex.ts +32 -0
  253. package/src/intervalIndex/intervalIndexUtils.ts +27 -0
  254. package/src/intervalIndex/overlappingIntervalsIndex.ts +187 -0
  255. package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +80 -0
  256. package/src/intervalIndex/sequenceIntervalIndexes.ts +34 -0
  257. package/src/intervalIndex/startpointInRangeIndex.ts +114 -0
  258. package/src/intervalTree.ts +98 -0
  259. package/src/intervals/index.ts +25 -0
  260. package/src/intervals/interval.ts +238 -0
  261. package/src/intervals/intervalUtils.ts +288 -0
  262. package/src/intervals/sequenceInterval.ts +616 -0
  263. package/src/localValues.ts +68 -73
  264. package/src/packageVersion.ts +1 -1
  265. package/src/revertibles.ts +693 -0
  266. package/src/sequence.ts +845 -690
  267. package/src/sequenceDeltaEvent.ts +164 -131
  268. package/src/sequenceFactory.ts +58 -214
  269. package/src/sharedIntervalCollection.ts +161 -152
  270. package/src/sharedSequence.ts +181 -167
  271. package/src/sharedString.ts +390 -234
  272. package/tsc-multi.test.json +10 -0
  273. package/tsconfig.json +11 -13
  274. package/.editorconfig +0 -7
  275. package/.vscode/launch.json +0 -15
  276. package/dist/defaultMap.js.map +0 -1
  277. package/dist/defaultMapInterfaces.js.map +0 -1
  278. package/dist/index.js +0 -44
  279. package/dist/index.js.map +0 -1
  280. package/dist/intervalCollection.js +0 -1250
  281. package/dist/intervalCollection.js.map +0 -1
  282. package/dist/localValues.js.map +0 -1
  283. package/dist/packageVersion.js.map +0 -1
  284. package/dist/sequence.js.map +0 -1
  285. package/dist/sequenceDeltaEvent.js.map +0 -1
  286. package/dist/sequenceFactory.js +0 -192
  287. package/dist/sequenceFactory.js.map +0 -1
  288. package/dist/sharedIntervalCollection.js.map +0 -1
  289. package/dist/sharedNumberSequence.d.ts +0 -50
  290. package/dist/sharedNumberSequence.d.ts.map +0 -1
  291. package/dist/sharedNumberSequence.js +0 -61
  292. package/dist/sharedNumberSequence.js.map +0 -1
  293. package/dist/sharedObjectSequence.d.ts +0 -50
  294. package/dist/sharedObjectSequence.d.ts.map +0 -1
  295. package/dist/sharedObjectSequence.js +0 -61
  296. package/dist/sharedObjectSequence.js.map +0 -1
  297. package/dist/sharedSequence.js.map +0 -1
  298. package/dist/sharedString.js +0 -187
  299. package/dist/sharedString.js.map +0 -1
  300. package/dist/sparsematrix.d.ts +0 -139
  301. package/dist/sparsematrix.d.ts.map +0 -1
  302. package/dist/sparsematrix.js +0 -332
  303. package/dist/sparsematrix.js.map +0 -1
  304. package/lib/defaultMap.d.ts.map +0 -1
  305. package/lib/defaultMap.js.map +0 -1
  306. package/lib/defaultMapInterfaces.d.ts.map +0 -1
  307. package/lib/defaultMapInterfaces.js.map +0 -1
  308. package/lib/index.d.ts +0 -27
  309. package/lib/index.d.ts.map +0 -1
  310. package/lib/index.js +0 -26
  311. package/lib/index.js.map +0 -1
  312. package/lib/intervalCollection.d.ts +0 -270
  313. package/lib/intervalCollection.d.ts.map +0 -1
  314. package/lib/intervalCollection.js +0 -1238
  315. package/lib/intervalCollection.js.map +0 -1
  316. package/lib/localValues.d.ts.map +0 -1
  317. package/lib/localValues.js.map +0 -1
  318. package/lib/packageVersion.js.map +0 -1
  319. package/lib/sequence.d.ts.map +0 -1
  320. package/lib/sequence.js.map +0 -1
  321. package/lib/sequenceDeltaEvent.d.ts.map +0 -1
  322. package/lib/sequenceDeltaEvent.js.map +0 -1
  323. package/lib/sequenceFactory.d.ts +0 -108
  324. package/lib/sequenceFactory.d.ts.map +0 -1
  325. package/lib/sequenceFactory.js +0 -186
  326. package/lib/sequenceFactory.js.map +0 -1
  327. package/lib/sharedIntervalCollection.d.ts.map +0 -1
  328. package/lib/sharedIntervalCollection.js.map +0 -1
  329. package/lib/sharedNumberSequence.d.ts +0 -50
  330. package/lib/sharedNumberSequence.d.ts.map +0 -1
  331. package/lib/sharedNumberSequence.js +0 -57
  332. package/lib/sharedNumberSequence.js.map +0 -1
  333. package/lib/sharedObjectSequence.d.ts +0 -50
  334. package/lib/sharedObjectSequence.d.ts.map +0 -1
  335. package/lib/sharedObjectSequence.js +0 -57
  336. package/lib/sharedObjectSequence.js.map +0 -1
  337. package/lib/sharedSequence.d.ts.map +0 -1
  338. package/lib/sharedSequence.js.map +0 -1
  339. package/lib/sharedString.d.ts.map +0 -1
  340. package/lib/sharedString.js +0 -183
  341. package/lib/sharedString.js.map +0 -1
  342. package/lib/sparsematrix.d.ts +0 -139
  343. package/lib/sparsematrix.d.ts.map +0 -1
  344. package/lib/sparsematrix.js +0 -323
  345. package/lib/sparsematrix.js.map +0 -1
  346. package/src/sharedNumberSequence.ts +0 -62
  347. package/src/sharedObjectSequence.ts +0 -62
  348. package/src/sparsematrix.ts +0 -421
  349. package/tsconfig.esnext.json +0 -7
@@ -0,0 +1,286 @@
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.getTextAndMarkers = exports.SharedString = void 0;
8
+ const merge_tree_1 = require("@fluidframework/merge-tree");
9
+ const sequence_1 = require("./sequence.cjs");
10
+ const sequenceFactory_1 = require("./sequenceFactory.cjs");
11
+ /**
12
+ * The Shared String is a specialized data structure for handling collaborative
13
+ * text. It is based on a more general Sequence data structure but has
14
+ * additional features that make working with text easier.
15
+ *
16
+ * In addition to text, a Shared String can also contain markers. Markers can be
17
+ * used to store metadata at positions within the text, like the details of an
18
+ * image or Fluid object that should be rendered with the text.
19
+ * @alpha
20
+ */
21
+ class SharedString extends sequence_1.SharedSegmentSequence {
22
+ /**
23
+ * Create a new shared string.
24
+ * @param runtime - data store runtime the new shared string belongs to
25
+ * @param id - optional name of the shared string
26
+ * @returns newly create shared string (but not attached yet)
27
+ */
28
+ static create(runtime, id) {
29
+ return runtime.createChannel(id, sequenceFactory_1.SharedStringFactory.Type);
30
+ }
31
+ /**
32
+ * Get a factory for SharedString to register with the data store.
33
+ * @returns a factory that creates and load SharedString
34
+ */
35
+ static getFactory() {
36
+ return new sequenceFactory_1.SharedStringFactory();
37
+ }
38
+ get ISharedString() {
39
+ return this;
40
+ }
41
+ constructor(document, id, attributes) {
42
+ super(document, id, attributes, sequenceFactory_1.SharedStringFactory.segmentFromSpec);
43
+ this.id = id;
44
+ this.mergeTreeTextHelper = this.client.createTextHelper();
45
+ }
46
+ /**
47
+ * Inserts a marker at a relative position.
48
+ * @param relativePos1 - The relative position to insert the marker at
49
+ * @param refType - The reference type of the marker
50
+ * @param props - The properties of the marker
51
+ */
52
+ insertMarkerRelative(relativePos1, refType, props) {
53
+ const segment = new merge_tree_1.Marker(refType);
54
+ if (props) {
55
+ segment.addProperties(props);
56
+ }
57
+ const pos = this.posFromRelativePos(relativePos1);
58
+ this.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));
59
+ }
60
+ /**
61
+ * {@inheritDoc ISharedString.insertMarker}
62
+ */
63
+ insertMarker(pos, refType, props) {
64
+ const segment = new merge_tree_1.Marker(refType);
65
+ if (props) {
66
+ segment.addProperties(props);
67
+ }
68
+ this.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));
69
+ }
70
+ /**
71
+ * Inserts the text at the position.
72
+ * @param relativePos1 - The relative position to insert the text at
73
+ * @param text - The text to insert
74
+ * @param props - The properties of text
75
+ */
76
+ insertTextRelative(relativePos1, text, props) {
77
+ const segment = new merge_tree_1.TextSegment(text);
78
+ if (props) {
79
+ segment.addProperties(props);
80
+ }
81
+ const pos = this.posFromRelativePos(relativePos1);
82
+ this.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));
83
+ }
84
+ /**
85
+ * {@inheritDoc ISharedString.insertText}
86
+ */
87
+ insertText(pos, text, props) {
88
+ const segment = new merge_tree_1.TextSegment(text);
89
+ if (props) {
90
+ segment.addProperties(props);
91
+ }
92
+ this.guardReentrancy(() => this.client.insertSegmentLocal(pos, segment));
93
+ }
94
+ /**
95
+ * Replaces a range with the provided text.
96
+ * @param start - The inclusive start of the range to replace
97
+ * @param end - The exclusive end of the range to replace
98
+ * @param text - The text to replace the range with
99
+ * @param props - Optional. The properties of the replacement text
100
+ */
101
+ replaceText(start, end, text, props) {
102
+ this.replaceRange(start, end, merge_tree_1.TextSegment.make(text, props));
103
+ }
104
+ /**
105
+ * Removes the text in the given range.
106
+ * @param start - The inclusive start of the range to remove
107
+ * @param end - The exclusive end of the range to replace
108
+ * @returns the message sent.
109
+ */
110
+ removeText(start, end) {
111
+ this.removeRange(start, end);
112
+ }
113
+ /**
114
+ * Annotates the marker with the provided properties.
115
+ * @param marker - The marker to annotate
116
+ * @param props - The properties to annotate the marker with
117
+ */
118
+ annotateMarker(marker, props) {
119
+ this.guardReentrancy(() => this.client.annotateMarker(marker, props));
120
+ }
121
+ /**
122
+ * Finds the nearest reference with ReferenceType.Tile to `startPos` in the direction dictated by `tilePrecedesPos`.
123
+ * Note that Markers receive `ReferenceType.Tile` by default.
124
+ * @deprecated Use `searchForMarker` instead.
125
+ * @param startPos - Position at which to start the search
126
+ * @param clientId - clientId dictating the perspective to search from
127
+ * @param tileLabel - Label of the tile to search for
128
+ * @param preceding - Whether the desired tile comes before (true) or after (false) `startPos`
129
+ */
130
+ findTile(startPos, tileLabel, preceding = true) {
131
+ return this.client.findTile(startPos ?? 0, tileLabel, preceding);
132
+ }
133
+ /**
134
+ * Searches a string for the nearest marker in either direction to a given start position.
135
+ * The search will include the start position, so markers at the start position are valid
136
+ * results of the search.
137
+ * @param startPos - Position at which to start the search
138
+ * @param markerLabel - Label of the marker to search for
139
+ * @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`
140
+ */
141
+ searchForMarker(startPos, markerLabel, forwards = true) {
142
+ return this.client.searchForMarker(startPos, markerLabel, forwards);
143
+ }
144
+ /**
145
+ * Retrieve text from the SharedString in string format.
146
+ * @param start - The starting index of the text to retrieve, or 0 if omitted.
147
+ * @param end - The ending index of the text to retrieve, or the end of the string if omitted
148
+ * @returns The requested text content as a string.
149
+ */
150
+ getText(start, end) {
151
+ const segmentWindow = this.client.getCollabWindow();
152
+ return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, "", start, end);
153
+ }
154
+ /**
155
+ * Adds spaces for markers and handles, so that position calculations account for them.
156
+ */
157
+ getTextWithPlaceholders(start, end) {
158
+ const segmentWindow = this.client.getCollabWindow();
159
+ return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, " ", start, end);
160
+ }
161
+ getTextRangeWithMarkers(start, end) {
162
+ const segmentWindow = this.client.getCollabWindow();
163
+ return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, "*", start, end);
164
+ }
165
+ /**
166
+ * Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided
167
+ * id in this `SharedString`.
168
+ */
169
+ getMarkerFromId(id) {
170
+ return this.client.getMarkerFromId(id);
171
+ }
172
+ /**
173
+ * Revert an op
174
+ */
175
+ rollback(content, localOpMetadata) {
176
+ if (this.client.rollback !== undefined) {
177
+ this.client.rollback(content, localOpMetadata);
178
+ }
179
+ else {
180
+ super.rollback(content, localOpMetadata);
181
+ }
182
+ }
183
+ }
184
+ exports.SharedString = SharedString;
185
+ /**
186
+ * Splits the text into regions ending with markers with the given `label`.
187
+ * @param sharedString - String to retrieve text and markers from
188
+ * @param label - label to split on
189
+ * @returns Two parallel lists of text and markers, split by markers with the provided `label`.
190
+ * For example:
191
+ * ```typescript
192
+ * // Say sharedstring has contents "hello<paragraph marker 1>world<paragraph marker 2>missing".
193
+ * const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, "paragraph");
194
+ * // parallelText === ["hello", "world"]
195
+ * // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]
196
+ * // Note parallelText does not include "missing".
197
+ * ```
198
+ * @internal
199
+ */
200
+ function getTextAndMarkers(sharedString, label, start, end) {
201
+ const accum = {
202
+ parallelMarkerLabel: label,
203
+ parallelMarkers: [],
204
+ parallelText: [],
205
+ tagsInProgress: [],
206
+ textSegment: new merge_tree_1.TextSegment(""),
207
+ };
208
+ sharedString.walkSegments(gatherTextAndMarkers, start, end, accum);
209
+ return { parallelText: accum.parallelText, parallelMarkers: accum.parallelMarkers };
210
+ }
211
+ exports.getTextAndMarkers = getTextAndMarkers;
212
+ const gatherTextAndMarkers = (segment, pos, refSeq, clientId, start, end, accumText) => {
213
+ const { placeholder, tagsInProgress, textSegment } = accumText;
214
+ if (merge_tree_1.TextSegment.is(segment)) {
215
+ let beginTags = "";
216
+ let endTags = "";
217
+ // TODO: let clients pass in function to get tag
218
+ const tags = [];
219
+ const initTags = [];
220
+ if (segment.properties?.["font-weight"]) {
221
+ tags.push("b");
222
+ }
223
+ if (segment.properties?.["text-decoration"]) {
224
+ tags.push("u");
225
+ }
226
+ const remTags = [];
227
+ if (tags.length > 0) {
228
+ for (const tag of tags) {
229
+ if (!tagsInProgress.includes(tag)) {
230
+ beginTags += `<${tag}>`;
231
+ initTags.push(tag);
232
+ }
233
+ }
234
+ for (const accumTag of tagsInProgress) {
235
+ if (!tags.includes(accumTag)) {
236
+ endTags += `</${accumTag}>`;
237
+ remTags.push(accumTag);
238
+ }
239
+ }
240
+ for (const initTag of initTags.reverse()) {
241
+ tagsInProgress.push(initTag);
242
+ }
243
+ }
244
+ else {
245
+ for (const accumTag of tagsInProgress) {
246
+ endTags += `</${accumTag}>`;
247
+ remTags.push(accumTag);
248
+ }
249
+ }
250
+ for (const remTag of remTags) {
251
+ const remdex = tagsInProgress.indexOf(remTag);
252
+ if (remdex >= 0) {
253
+ tagsInProgress.splice(remdex, 1);
254
+ }
255
+ }
256
+ textSegment.text += endTags;
257
+ textSegment.text += beginTags;
258
+ if (start <= 0 && end >= segment.text.length) {
259
+ textSegment.text += segment.text;
260
+ }
261
+ else {
262
+ const seglen = segment.text.length;
263
+ const _start = start < 0 ? 0 : start;
264
+ const _end = end >= seglen ? undefined : end;
265
+ textSegment.text += segment.text.substring(_start, _end);
266
+ }
267
+ }
268
+ else {
269
+ if (placeholder && placeholder.length > 0) {
270
+ const placeholderText =
271
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
272
+ placeholder === "*" ? `\n${segment}` : placeholder.repeat(segment.cachedLength);
273
+ textSegment.text += placeholderText;
274
+ }
275
+ else {
276
+ const marker = segment;
277
+ if ((0, merge_tree_1.refHasTileLabel)(marker, accumText.parallelMarkerLabel)) {
278
+ accumText.parallelMarkers.push(marker);
279
+ accumText.parallelText.push(textSegment.text);
280
+ textSegment.text = "";
281
+ }
282
+ }
283
+ }
284
+ return true;
285
+ };
286
+ //# sourceMappingURL=sharedString.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharedString.cjs","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAWoC;AAEpC,6CAAmD;AACnD,2DAAwD;AAkCxD;;;;;;;;;GASG;AACH,MAAa,YACZ,SAAQ,gCAA0C;IAGlD;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAChE,OAAO,OAAO,CAAC,aAAa,CA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,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\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(pos: number, refType: ReferenceType, props?: PropertySet): void;\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): void {\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(pos: number, refType: ReferenceType, props?: PropertySet): void {\n\t\tconst segment = new Marker(refType);\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 * 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(\n\t\trelativePos1: IRelativePosition,\n\t\ttext: string,\n\t\tprops?: PropertySet,\n\t): void {\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): void {\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): void {\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): void {\n\t\tthis.removeRange(start, end);\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 */\n\tpublic annotateMarker(marker: Marker, props: PropertySet) {\n\t\tthis.guardReentrancy(() => this.client.annotateMarker(marker, props));\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\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\t\tplaceholder === \"*\" ? `\\n${segment}` : 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"]}
@@ -2,12 +2,13 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ICombiningOp, IMergeTreeInsertMsg, IMergeTreeRemoveMsg, IRelativePosition, ISegment, Marker, PropertySet, ReferencePosition, ReferenceType, TextSegment } from "@fluidframework/merge-tree";
5
+ import { IRelativePosition, ISegment, Marker, PropertySet, ReferencePosition, ReferenceType, TextSegment } from "@fluidframework/merge-tree";
6
6
  import { IFluidDataStoreRuntime, IChannelAttributes } from "@fluidframework/datastore-definitions";
7
7
  import { SharedSegmentSequence } from "./sequence";
8
8
  import { SharedStringFactory } from "./sequenceFactory";
9
9
  /**
10
10
  * Fluid object interface describing access methods on a SharedString
11
+ * @alpha
11
12
  */
12
13
  export interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {
13
14
  /**
@@ -23,13 +24,16 @@ export interface ISharedString extends SharedSegmentSequence<SharedStringSegment
23
24
  * @param refType - The reference type of the marker
24
25
  * @param props - The properties of the marker
25
26
  */
26
- insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): IMergeTreeInsertMsg;
27
+ insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): void;
27
28
  /**
28
29
  * {@inheritDoc SharedSegmentSequence.posFromRelativePos}
29
30
  */
30
31
  posFromRelativePos(relativePos: IRelativePosition): number;
31
32
  }
32
- export declare type SharedStringSegment = TextSegment | Marker;
33
+ /**
34
+ * @alpha
35
+ */
36
+ export type SharedStringSegment = TextSegment | Marker;
33
37
  /**
34
38
  * The Shared String is a specialized data structure for handling collaborative
35
39
  * text. It is based on a more general Sequence data structure but has
@@ -38,7 +42,7 @@ export declare type SharedStringSegment = TextSegment | Marker;
38
42
  * In addition to text, a Shared String can also contain markers. Markers can be
39
43
  * used to store metadata at positions within the text, like the details of an
40
44
  * image or Fluid object that should be rendered with the text.
41
- *
45
+ * @alpha
42
46
  */
43
47
  export declare class SharedString extends SharedSegmentSequence<SharedStringSegment> implements ISharedString {
44
48
  id: string;
@@ -67,7 +71,7 @@ export declare class SharedString extends SharedSegmentSequence<SharedStringSegm
67
71
  /**
68
72
  * {@inheritDoc ISharedString.insertMarker}
69
73
  */
70
- insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): IMergeTreeInsertMsg;
74
+ insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): void;
71
75
  /**
72
76
  * Inserts the text at the position.
73
77
  * @param relativePos1 - The relative position to insert the text at
@@ -93,29 +97,35 @@ export declare class SharedString extends SharedSegmentSequence<SharedStringSegm
93
97
  * @param end - The exclusive end of the range to replace
94
98
  * @returns the message sent.
95
99
  */
96
- removeText(start: number, end: number): IMergeTreeRemoveMsg;
100
+ removeText(start: number, end: number): void;
97
101
  /**
98
- * Annotates the marker with the provided properties and calls the callback on consensus.
102
+ * Annotates the marker with the provided properties.
99
103
  * @param marker - The marker to annotate
100
104
  * @param props - The properties to annotate the marker with
101
- * @param consensusCallback - The callback called when consensus is reached
102
105
  */
103
- annotateMarkerNotifyConsensus(marker: Marker, props: PropertySet, callback: (m: Marker) => void): void;
106
+ annotateMarker(marker: Marker, props: PropertySet): void;
104
107
  /**
105
- * Annotates the marker with the provided properties.
106
- * @param marker - The marker to annotate
107
- * @param props - The properties to annotate the marker with
108
- * @param combiningOp - Optional. Specifies how to combine values for the property, such as "incr" for increment.
108
+ * Finds the nearest reference with ReferenceType.Tile to `startPos` in the direction dictated by `tilePrecedesPos`.
109
+ * Note that Markers receive `ReferenceType.Tile` by default.
110
+ * @deprecated Use `searchForMarker` instead.
111
+ * @param startPos - Position at which to start the search
112
+ * @param clientId - clientId dictating the perspective to search from
113
+ * @param tileLabel - Label of the tile to search for
114
+ * @param preceding - Whether the desired tile comes before (true) or after (false) `startPos`
109
115
  */
110
- annotateMarker(marker: Marker, props: PropertySet, combiningOp?: ICombiningOp): void;
111
116
  findTile(startPos: number | undefined, tileLabel: string, preceding?: boolean): {
112
117
  tile: ReferencePosition;
113
118
  pos: number;
114
- };
115
- getTextAndMarkers(label: string): {
116
- parallelText: string[];
117
- parallelMarkers: Marker[];
118
- };
119
+ } | undefined;
120
+ /**
121
+ * Searches a string for the nearest marker in either direction to a given start position.
122
+ * The search will include the start position, so markers at the start position are valid
123
+ * results of the search.
124
+ * @param startPos - Position at which to start the search
125
+ * @param markerLabel - Label of the marker to search for
126
+ * @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`
127
+ */
128
+ searchForMarker(startPos: number, markerLabel: string, forwards?: boolean): Marker | undefined;
119
129
  /**
120
130
  * Retrieve text from the SharedString in string format.
121
131
  * @param start - The starting index of the text to retrieve, or 0 if omitted.
@@ -126,9 +136,35 @@ export declare class SharedString extends SharedSegmentSequence<SharedStringSegm
126
136
  /**
127
137
  * Adds spaces for markers and handles, so that position calculations account for them.
128
138
  */
129
- getTextWithPlaceholders(): string;
130
- getTextRangeWithPlaceholders(start: number, end: number): string;
139
+ getTextWithPlaceholders(start?: number, end?: number): string;
131
140
  getTextRangeWithMarkers(start: number, end: number): string;
132
- getMarkerFromId(id: string): ISegment;
141
+ /**
142
+ * Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided
143
+ * id in this `SharedString`.
144
+ */
145
+ getMarkerFromId(id: string): ISegment | undefined;
146
+ /**
147
+ * Revert an op
148
+ */
149
+ protected rollback(content: any, localOpMetadata: unknown): void;
133
150
  }
151
+ /**
152
+ * Splits the text into regions ending with markers with the given `label`.
153
+ * @param sharedString - String to retrieve text and markers from
154
+ * @param label - label to split on
155
+ * @returns Two parallel lists of text and markers, split by markers with the provided `label`.
156
+ * For example:
157
+ * ```typescript
158
+ * // Say sharedstring has contents "hello<paragraph marker 1>world<paragraph marker 2>missing".
159
+ * const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, "paragraph");
160
+ * // parallelText === ["hello", "world"]
161
+ * // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]
162
+ * // Note parallelText does not include "missing".
163
+ * ```
164
+ * @internal
165
+ */
166
+ export declare function getTextAndMarkers(sharedString: SharedString, label: string, start?: number, end?: number): {
167
+ parallelText: string[];
168
+ parallelMarkers: Marker[];
169
+ };
134
170
  //# sourceMappingURL=sharedString.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sharedString.d.ts","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,MAAM,EAEN,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,WAAW,EACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,qBAAqB,CAAC,mBAAmB,CAAC;IAC7E;;;;;OAKG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAEjE;;;;;OAKG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,O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AAM,GACV;IACF,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC1B,CAWA"}
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.38.3"
9
+ }
10
+ ]
11
+ }
@@ -5,8 +5,8 @@
5
5
  import { IFluidHandle } from "@fluidframework/core-interfaces";
6
6
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
7
7
  import { IFluidSerializer } from "@fluidframework/shared-object-base";
8
- import { TypedEventEmitter } from "@fluidframework/common-utils";
9
- import { ISerializableValue, ISerializedValue, IValueType, IValueTypeOperationValue, ISharedDefaultMapEvents, IMapMessageLocalMetadata } from "./defaultMapInterfaces";
8
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
9
+ import { ISerializableValue, ISerializedValue, IValueType, IValueTypeOperationValue, ISharedDefaultMapEvents, IMapMessageLocalMetadata, SequenceOptions } from "./defaultMapInterfaces.mjs";
10
10
  /**
11
11
  * Describes an operation specific to a value type.
12
12
  */
@@ -28,7 +28,7 @@ export interface IMapValueTypeOperation {
28
28
  /**
29
29
  * Description of a map delta operation
30
30
  */
31
- export declare type IMapOperation = IMapValueTypeOperation;
31
+ export type IMapOperation = IMapValueTypeOperation;
32
32
  /**
33
33
  * Defines the in-memory object structure to be used for the conversion to/from serialized.
34
34
  * Directly used in JSON.stringify, direct result from JSON.parse
@@ -51,6 +51,7 @@ export declare class DefaultMap<T> {
51
51
  private readonly handle;
52
52
  private readonly submitMessage;
53
53
  private readonly type;
54
+ private readonly options?;
54
55
  readonly eventEmitter: TypedEventEmitter<ISharedDefaultMapEvents>;
55
56
  /**
56
57
  * The number of key/value pairs stored in the map.
@@ -72,7 +73,7 @@ export declare class DefaultMap<T> {
72
73
  * @param type - The value type to create at values of this map
73
74
  * @param eventEmitter - The object that will emit map events
74
75
  */
75
- constructor(serializer: IFluidSerializer, handle: IFluidHandle, submitMessage: (op: any, localOpMetadata: IMapMessageLocalMetadata) => void, type: IValueType<T>, eventEmitter?: TypedEventEmitter<ISharedDefaultMapEvents>);
76
+ constructor(serializer: IFluidSerializer, handle: IFluidHandle, submitMessage: (op: IMapValueTypeOperation, localOpMetadata: IMapMessageLocalMetadata) => void, type: IValueType<T>, options?: Partial<SequenceOptions> | undefined, eventEmitter?: TypedEventEmitter<ISharedDefaultMapEvents>);
76
77
  /**
77
78
  * Get an iterator over the keys in this map.
78
79
  * @returns The iterator
@@ -130,8 +131,8 @@ export declare class DefaultMap<T> {
130
131
  * also sent if we are asked to resubmit the message.
131
132
  * @returns True if the operation was submitted, false otherwise.
132
133
  */
133
- tryResubmitMessage(op: any, localOpMetadata: IMapMessageLocalMetadata): boolean;
134
- tryGetStashedOpLocalMetadata(op: any): unknown;
134
+ tryResubmitMessage(op: IMapOperation, localOpMetadata: IMapMessageLocalMetadata): boolean;
135
+ tryGetStashedOpLocalMetadata(op: IMapOperation): unknown;
135
136
  /**
136
137
  * Process the given op if a handler is registered.
137
138
  * @param message - The message to process
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultMap.d.ts","sourceRoot":"","sources":["../src/defaultMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,YAAY,EAAE,MAAM,iCAAiC;OACvD,EAAE,yBAAyB,EAAE,MAAM,sCAAsC;OACzE,EACN,gBAAgB,EAIhB,MAAM,oCAAoC;OACpC,EAAE,iBAAiB,EAAE,MAAM,8BAA8B;OAGzD,EACN,kBAAkB,EAClB,gBAAgB,EAIhB,UAAU,EACV,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,eAAe,EACf;AAiCD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;IAEZ;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