@fluidframework/sequence 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.225277

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 (350) 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-esm.json +4 -0
  6. package/api-extractor-lint.json +4 -0
  7. package/api-extractor.json +2 -2
  8. package/api-report/sequence.api.md +734 -0
  9. package/dist/{defaultMap.js → defaultMap.cjs} +38 -26
  10. package/dist/defaultMap.cjs.map +1 -0
  11. package/dist/defaultMap.d.ts +7 -6
  12. package/dist/defaultMap.d.ts.map +1 -1
  13. package/dist/defaultMapInterfaces.cjs +7 -0
  14. package/dist/defaultMapInterfaces.cjs.map +1 -0
  15. package/dist/defaultMapInterfaces.d.ts +45 -12
  16. package/dist/defaultMapInterfaces.d.ts.map +1 -1
  17. package/dist/index.cjs +60 -0
  18. package/dist/index.cjs.map +1 -0
  19. package/dist/index.d.ts +14 -12
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/intervalCollection.cjs +1193 -0
  22. package/dist/intervalCollection.cjs.map +1 -0
  23. package/dist/intervalCollection.d.ts +448 -162
  24. package/dist/intervalCollection.d.ts.map +1 -1
  25. package/dist/intervalIndex/endpointInRangeIndex.cjs +66 -0
  26. package/dist/intervalIndex/endpointInRangeIndex.cjs.map +1 -0
  27. package/dist/intervalIndex/endpointInRangeIndex.d.ts +34 -0
  28. package/dist/intervalIndex/endpointInRangeIndex.d.ts.map +1 -0
  29. package/dist/intervalIndex/endpointIndex.cjs +47 -0
  30. package/dist/intervalIndex/endpointIndex.cjs.map +1 -0
  31. package/dist/intervalIndex/endpointIndex.d.ts +38 -0
  32. package/dist/intervalIndex/endpointIndex.d.ts.map +1 -0
  33. package/dist/intervalIndex/idIntervalIndex.cjs +44 -0
  34. package/dist/intervalIndex/idIntervalIndex.cjs.map +1 -0
  35. package/dist/intervalIndex/idIntervalIndex.d.ts +18 -0
  36. package/dist/intervalIndex/idIntervalIndex.d.ts.map +1 -0
  37. package/dist/intervalIndex/index.cjs +24 -0
  38. package/dist/intervalIndex/index.cjs.map +1 -0
  39. package/dist/intervalIndex/index.d.ts +13 -0
  40. package/dist/intervalIndex/index.d.ts.map +1 -0
  41. package/dist/{defaultMapInterfaces.js → intervalIndex/intervalIndex.cjs} +1 -1
  42. package/dist/intervalIndex/intervalIndex.cjs.map +1 -0
  43. package/dist/intervalIndex/intervalIndex.d.ts +30 -0
  44. package/dist/intervalIndex/intervalIndex.d.ts.map +1 -0
  45. package/dist/intervalIndex/intervalIndexUtils.cjs +22 -0
  46. package/dist/intervalIndex/intervalIndexUtils.cjs.map +1 -0
  47. package/dist/intervalIndex/intervalIndexUtils.d.ts +17 -0
  48. package/dist/intervalIndex/intervalIndexUtils.d.ts.map +1 -0
  49. package/dist/intervalIndex/overlappingIntervalsIndex.cjs +116 -0
  50. package/dist/intervalIndex/overlappingIntervalsIndex.cjs.map +1 -0
  51. package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +44 -0
  52. package/dist/intervalIndex/overlappingIntervalsIndex.d.ts.map +1 -0
  53. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.cjs +41 -0
  54. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.cjs.map +1 -0
  55. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +11 -0
  56. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts.map +1 -0
  57. package/dist/intervalIndex/sequenceIntervalIndexes.cjs +7 -0
  58. package/dist/intervalIndex/sequenceIntervalIndexes.cjs.map +1 -0
  59. package/dist/intervalIndex/sequenceIntervalIndexes.d.ts +35 -0
  60. package/dist/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -0
  61. package/dist/intervalIndex/startpointInRangeIndex.cjs +66 -0
  62. package/dist/intervalIndex/startpointInRangeIndex.cjs.map +1 -0
  63. package/dist/intervalIndex/startpointInRangeIndex.d.ts +34 -0
  64. package/dist/intervalIndex/startpointInRangeIndex.d.ts.map +1 -0
  65. package/dist/intervalTree.cjs +80 -0
  66. package/dist/intervalTree.cjs.map +1 -0
  67. package/dist/intervalTree.d.ts +24 -0
  68. package/dist/intervalTree.d.ts.map +1 -0
  69. package/dist/intervals/index.cjs +24 -0
  70. package/dist/intervals/index.cjs.map +1 -0
  71. package/dist/intervals/index.d.ts +8 -0
  72. package/dist/intervals/index.d.ts.map +1 -0
  73. package/dist/intervals/interval.cjs +181 -0
  74. package/dist/intervals/interval.cjs.map +1 -0
  75. package/dist/intervals/interval.d.ts +84 -0
  76. package/dist/intervals/interval.d.ts.map +1 -0
  77. package/dist/intervals/intervalUtils.cjs +90 -0
  78. package/dist/intervals/intervalUtils.cjs.map +1 -0
  79. package/dist/intervals/intervalUtils.d.ts +240 -0
  80. package/dist/intervals/intervalUtils.d.ts.map +1 -0
  81. package/dist/intervals/sequenceInterval.cjs +378 -0
  82. package/dist/intervals/sequenceInterval.cjs.map +1 -0
  83. package/dist/intervals/sequenceInterval.d.ts +137 -0
  84. package/dist/intervals/sequenceInterval.d.ts.map +1 -0
  85. package/dist/{localValues.js → localValues.cjs} +1 -1
  86. package/dist/localValues.cjs.map +1 -0
  87. package/dist/localValues.d.ts +2 -1
  88. package/dist/localValues.d.ts.map +1 -1
  89. package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
  90. package/dist/packageVersion.cjs.map +1 -0
  91. package/dist/packageVersion.d.ts +1 -1
  92. package/dist/packageVersion.d.ts.map +1 -1
  93. package/dist/revertibles.cjs +425 -0
  94. package/dist/revertibles.cjs.map +1 -0
  95. package/dist/revertibles.d.ts +86 -0
  96. package/dist/revertibles.d.ts.map +1 -0
  97. package/dist/sequence-alpha.d.ts +1290 -0
  98. package/dist/sequence-beta.d.ts +244 -0
  99. package/dist/sequence-public.d.ts +244 -0
  100. package/dist/sequence-untrimmed.d.ts +1778 -0
  101. package/dist/{sequence.js → sequence.cjs} +230 -156
  102. package/dist/sequence.cjs.map +1 -0
  103. package/dist/sequence.d.ts +125 -48
  104. package/dist/sequence.d.ts.map +1 -1
  105. package/dist/{sequenceDeltaEvent.js → sequenceDeltaEvent.cjs} +18 -8
  106. package/dist/sequenceDeltaEvent.cjs.map +1 -0
  107. package/dist/sequenceDeltaEvent.d.ts +24 -7
  108. package/dist/sequenceDeltaEvent.d.ts.map +1 -1
  109. package/dist/sequenceFactory.cjs +55 -0
  110. package/dist/sequenceFactory.cjs.map +1 -0
  111. package/dist/sequenceFactory.d.ts +3 -89
  112. package/dist/sequenceFactory.d.ts.map +1 -1
  113. package/dist/{sharedIntervalCollection.js → sharedIntervalCollection.cjs} +17 -22
  114. package/dist/sharedIntervalCollection.cjs.map +1 -0
  115. package/dist/sharedIntervalCollection.d.ts +12 -12
  116. package/dist/sharedIntervalCollection.d.ts.map +1 -1
  117. package/dist/{sharedSequence.js → sharedSequence.cjs} +29 -22
  118. package/dist/sharedSequence.cjs.map +1 -0
  119. package/dist/sharedSequence.d.ts +14 -2
  120. package/dist/sharedSequence.d.ts.map +1 -1
  121. package/dist/sharedString.cjs +274 -0
  122. package/dist/sharedString.cjs.map +1 -0
  123. package/dist/sharedString.d.ts +49 -26
  124. package/dist/sharedString.d.ts.map +1 -1
  125. package/dist/tsdoc-metadata.json +11 -0
  126. package/lib/{defaultMap.d.ts → defaultMap.d.mts} +8 -7
  127. package/lib/defaultMap.d.mts.map +1 -0
  128. package/lib/{defaultMap.js → defaultMap.mjs} +38 -26
  129. package/lib/defaultMap.mjs.map +1 -0
  130. package/lib/{defaultMapInterfaces.d.ts → defaultMapInterfaces.d.mts} +46 -13
  131. package/lib/defaultMapInterfaces.d.mts.map +1 -0
  132. package/lib/defaultMapInterfaces.mjs +6 -0
  133. package/lib/defaultMapInterfaces.mjs.map +1 -0
  134. package/lib/index.d.mts +17 -0
  135. package/lib/index.d.mts.map +1 -0
  136. package/lib/index.mjs +16 -0
  137. package/lib/index.mjs.map +1 -0
  138. package/lib/intervalCollection.d.mts +556 -0
  139. package/lib/intervalCollection.d.mts.map +1 -0
  140. package/lib/intervalCollection.mjs +1178 -0
  141. package/lib/intervalCollection.mjs.map +1 -0
  142. package/lib/intervalIndex/endpointInRangeIndex.d.mts +34 -0
  143. package/lib/intervalIndex/endpointInRangeIndex.d.mts.map +1 -0
  144. package/lib/intervalIndex/endpointInRangeIndex.mjs +61 -0
  145. package/lib/intervalIndex/endpointInRangeIndex.mjs.map +1 -0
  146. package/lib/intervalIndex/endpointIndex.d.mts +38 -0
  147. package/lib/intervalIndex/endpointIndex.d.mts.map +1 -0
  148. package/lib/intervalIndex/endpointIndex.mjs +42 -0
  149. package/lib/intervalIndex/endpointIndex.mjs.map +1 -0
  150. package/lib/intervalIndex/idIntervalIndex.d.mts +18 -0
  151. package/lib/intervalIndex/idIntervalIndex.d.mts.map +1 -0
  152. package/lib/intervalIndex/idIntervalIndex.mjs +40 -0
  153. package/lib/intervalIndex/idIntervalIndex.mjs.map +1 -0
  154. package/lib/intervalIndex/index.d.mts +13 -0
  155. package/lib/intervalIndex/index.d.mts.map +1 -0
  156. package/lib/intervalIndex/index.mjs +11 -0
  157. package/lib/intervalIndex/index.mjs.map +1 -0
  158. package/lib/intervalIndex/intervalIndex.d.mts +30 -0
  159. package/lib/intervalIndex/intervalIndex.d.mts.map +1 -0
  160. package/lib/{defaultMapInterfaces.js → intervalIndex/intervalIndex.mjs} +1 -1
  161. package/lib/intervalIndex/intervalIndex.mjs.map +1 -0
  162. package/lib/intervalIndex/intervalIndexUtils.d.mts +17 -0
  163. package/lib/intervalIndex/intervalIndexUtils.d.mts.map +1 -0
  164. package/lib/intervalIndex/intervalIndexUtils.mjs +18 -0
  165. package/lib/intervalIndex/intervalIndexUtils.mjs.map +1 -0
  166. package/lib/intervalIndex/overlappingIntervalsIndex.d.mts +44 -0
  167. package/lib/intervalIndex/overlappingIntervalsIndex.d.mts.map +1 -0
  168. package/lib/intervalIndex/overlappingIntervalsIndex.mjs +111 -0
  169. package/lib/intervalIndex/overlappingIntervalsIndex.mjs.map +1 -0
  170. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.mts +11 -0
  171. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.mts.map +1 -0
  172. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.mjs +37 -0
  173. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.mjs.map +1 -0
  174. package/lib/intervalIndex/sequenceIntervalIndexes.d.mts +35 -0
  175. package/lib/intervalIndex/sequenceIntervalIndexes.d.mts.map +1 -0
  176. package/lib/intervalIndex/sequenceIntervalIndexes.mjs +6 -0
  177. package/lib/intervalIndex/sequenceIntervalIndexes.mjs.map +1 -0
  178. package/lib/intervalIndex/startpointInRangeIndex.d.mts +34 -0
  179. package/lib/intervalIndex/startpointInRangeIndex.d.mts.map +1 -0
  180. package/lib/intervalIndex/startpointInRangeIndex.mjs +61 -0
  181. package/lib/intervalIndex/startpointInRangeIndex.mjs.map +1 -0
  182. package/lib/intervalTree.d.mts +24 -0
  183. package/lib/intervalTree.d.mts.map +1 -0
  184. package/lib/intervalTree.mjs +76 -0
  185. package/lib/intervalTree.mjs.map +1 -0
  186. package/lib/intervals/index.d.mts +8 -0
  187. package/lib/intervals/index.d.mts.map +1 -0
  188. package/lib/intervals/index.mjs +8 -0
  189. package/lib/intervals/index.mjs.map +1 -0
  190. package/lib/intervals/interval.d.mts +84 -0
  191. package/lib/intervals/interval.d.mts.map +1 -0
  192. package/lib/intervals/interval.mjs +176 -0
  193. package/lib/intervals/interval.mjs.map +1 -0
  194. package/lib/intervals/intervalUtils.d.mts +240 -0
  195. package/lib/intervals/intervalUtils.d.mts.map +1 -0
  196. package/lib/intervals/intervalUtils.mjs +84 -0
  197. package/lib/intervals/intervalUtils.mjs.map +1 -0
  198. package/lib/intervals/sequenceInterval.d.mts +137 -0
  199. package/lib/intervals/sequenceInterval.d.mts.map +1 -0
  200. package/lib/intervals/sequenceInterval.mjs +370 -0
  201. package/lib/intervals/sequenceInterval.mjs.map +1 -0
  202. package/lib/{localValues.d.ts → localValues.d.mts} +4 -3
  203. package/lib/localValues.d.mts.map +1 -0
  204. package/lib/{localValues.js → localValues.mjs} +2 -2
  205. package/lib/localValues.mjs.map +1 -0
  206. package/lib/{packageVersion.d.ts → packageVersion.d.mts} +2 -2
  207. package/lib/packageVersion.d.mts.map +1 -0
  208. package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
  209. package/lib/packageVersion.mjs.map +1 -0
  210. package/lib/revertibles.d.mts +86 -0
  211. package/lib/revertibles.d.mts.map +1 -0
  212. package/lib/revertibles.mjs +416 -0
  213. package/lib/revertibles.mjs.map +1 -0
  214. package/lib/sequence-alpha.d.mts +1277 -0
  215. package/lib/sequence-beta.d.mts +231 -0
  216. package/lib/sequence-public.d.mts +231 -0
  217. package/lib/sequence-untrimmed.d.mts +1765 -0
  218. package/lib/{sequence.d.ts → sequence.d.mts} +128 -51
  219. package/lib/sequence.d.mts.map +1 -0
  220. package/lib/{sequence.js → sequence.mjs} +229 -152
  221. package/lib/sequence.mjs.map +1 -0
  222. package/lib/{sequenceDeltaEvent.d.ts → sequenceDeltaEvent.d.mts} +25 -8
  223. package/lib/sequenceDeltaEvent.d.mts.map +1 -0
  224. package/lib/{sequenceDeltaEvent.js → sequenceDeltaEvent.mjs} +20 -8
  225. package/lib/sequenceDeltaEvent.mjs.map +1 -0
  226. package/lib/sequenceFactory.d.mts +22 -0
  227. package/lib/sequenceFactory.d.mts.map +1 -0
  228. package/lib/sequenceFactory.mjs +51 -0
  229. package/lib/sequenceFactory.mjs.map +1 -0
  230. package/lib/{sharedIntervalCollection.d.ts → sharedIntervalCollection.d.mts} +13 -13
  231. package/lib/sharedIntervalCollection.d.mts.map +1 -0
  232. package/lib/{sharedIntervalCollection.js → sharedIntervalCollection.mjs} +16 -21
  233. package/lib/sharedIntervalCollection.mjs.map +1 -0
  234. package/lib/{sharedSequence.d.ts → sharedSequence.d.mts} +16 -4
  235. package/lib/sharedSequence.d.mts.map +1 -0
  236. package/lib/{sharedSequence.js → sharedSequence.mjs} +30 -23
  237. package/lib/sharedSequence.mjs.map +1 -0
  238. package/lib/{sharedString.d.ts → sharedString.d.mts} +52 -29
  239. package/lib/sharedString.d.mts.map +1 -0
  240. package/lib/sharedString.mjs +269 -0
  241. package/lib/sharedString.mjs.map +1 -0
  242. package/package.json +168 -75
  243. package/prettier.config.cjs +8 -0
  244. package/src/defaultMap.ts +419 -403
  245. package/src/defaultMapInterfaces.ts +164 -117
  246. package/src/index.ts +86 -26
  247. package/src/intervalCollection.ts +2042 -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 +26 -0
  260. package/src/intervals/interval.ts +238 -0
  261. package/src/intervals/intervalUtils.ts +298 -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 +850 -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 +367 -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.d.ts.map +0 -1
  319. package/lib/packageVersion.js.map +0 -1
  320. package/lib/sequence.d.ts.map +0 -1
  321. package/lib/sequence.js.map +0 -1
  322. package/lib/sequenceDeltaEvent.d.ts.map +0 -1
  323. package/lib/sequenceDeltaEvent.js.map +0 -1
  324. package/lib/sequenceFactory.d.ts +0 -108
  325. package/lib/sequenceFactory.d.ts.map +0 -1
  326. package/lib/sequenceFactory.js +0 -186
  327. package/lib/sequenceFactory.js.map +0 -1
  328. package/lib/sharedIntervalCollection.d.ts.map +0 -1
  329. package/lib/sharedIntervalCollection.js.map +0 -1
  330. package/lib/sharedNumberSequence.d.ts +0 -50
  331. package/lib/sharedNumberSequence.d.ts.map +0 -1
  332. package/lib/sharedNumberSequence.js +0 -57
  333. package/lib/sharedNumberSequence.js.map +0 -1
  334. package/lib/sharedObjectSequence.d.ts +0 -50
  335. package/lib/sharedObjectSequence.d.ts.map +0 -1
  336. package/lib/sharedObjectSequence.js +0 -57
  337. package/lib/sharedObjectSequence.js.map +0 -1
  338. package/lib/sharedSequence.d.ts.map +0 -1
  339. package/lib/sharedSequence.js.map +0 -1
  340. package/lib/sharedString.d.ts.map +0 -1
  341. package/lib/sharedString.js +0 -183
  342. package/lib/sharedString.js.map +0 -1
  343. package/lib/sparsematrix.d.ts +0 -139
  344. package/lib/sparsematrix.d.ts.map +0 -1
  345. package/lib/sparsematrix.js +0 -323
  346. package/lib/sparsematrix.js.map +0 -1
  347. package/src/sharedNumberSequence.ts +0 -62
  348. package/src/sharedObjectSequence.ts +0 -62
  349. package/src/sparsematrix.ts +0 -421
  350. package/tsconfig.esnext.json +0 -7
@@ -0,0 +1,274 @@
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
+ * Searches a string for the nearest marker in either direction to a given start position.
123
+ * The search will include the start position, so markers at the start position are valid
124
+ * results of the search.
125
+ * @param startPos - Position at which to start the search
126
+ * @param markerLabel - Label of the marker to search for
127
+ * @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`
128
+ */
129
+ searchForMarker(startPos, markerLabel, forwards = true) {
130
+ return this.client.searchForMarker(startPos, markerLabel, forwards);
131
+ }
132
+ /**
133
+ * Retrieve text from the SharedString in string format.
134
+ * @param start - The starting index of the text to retrieve, or 0 if omitted.
135
+ * @param end - The ending index of the text to retrieve, or the end of the string if omitted
136
+ * @returns The requested text content as a string.
137
+ */
138
+ getText(start, end) {
139
+ const segmentWindow = this.client.getCollabWindow();
140
+ return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, "", start, end);
141
+ }
142
+ /**
143
+ * Adds spaces for markers and handles, so that position calculations account for them.
144
+ */
145
+ getTextWithPlaceholders(start, end) {
146
+ const segmentWindow = this.client.getCollabWindow();
147
+ return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, " ", start, end);
148
+ }
149
+ getTextRangeWithMarkers(start, end) {
150
+ const segmentWindow = this.client.getCollabWindow();
151
+ return this.mergeTreeTextHelper.getText(segmentWindow.currentSeq, segmentWindow.clientId, "*", start, end);
152
+ }
153
+ /**
154
+ * Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided
155
+ * id in this `SharedString`.
156
+ */
157
+ getMarkerFromId(id) {
158
+ return this.client.getMarkerFromId(id);
159
+ }
160
+ /**
161
+ * Revert an op
162
+ */
163
+ rollback(content, localOpMetadata) {
164
+ if (this.client.rollback !== undefined) {
165
+ this.client.rollback(content, localOpMetadata);
166
+ }
167
+ else {
168
+ super.rollback(content, localOpMetadata);
169
+ }
170
+ }
171
+ }
172
+ exports.SharedString = SharedString;
173
+ /**
174
+ * Splits the text into regions ending with markers with the given `label`.
175
+ * @param sharedString - String to retrieve text and markers from
176
+ * @param label - label to split on
177
+ * @returns Two parallel lists of text and markers, split by markers with the provided `label`.
178
+ * For example:
179
+ * ```typescript
180
+ * // Say sharedstring has contents "hello<paragraph marker 1>world<paragraph marker 2>missing".
181
+ * const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, "paragraph");
182
+ * // parallelText === ["hello", "world"]
183
+ * // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]
184
+ * // Note parallelText does not include "missing".
185
+ * ```
186
+ * @internal
187
+ */
188
+ function getTextAndMarkers(sharedString, label, start, end) {
189
+ const accum = {
190
+ parallelMarkerLabel: label,
191
+ parallelMarkers: [],
192
+ parallelText: [],
193
+ tagsInProgress: [],
194
+ textSegment: new merge_tree_1.TextSegment(""),
195
+ };
196
+ sharedString.walkSegments(gatherTextAndMarkers, start, end, accum);
197
+ return { parallelText: accum.parallelText, parallelMarkers: accum.parallelMarkers };
198
+ }
199
+ exports.getTextAndMarkers = getTextAndMarkers;
200
+ const gatherTextAndMarkers = (segment, pos, refSeq, clientId, start, end, accumText) => {
201
+ const { placeholder, tagsInProgress, textSegment } = accumText;
202
+ if (merge_tree_1.TextSegment.is(segment)) {
203
+ let beginTags = "";
204
+ let endTags = "";
205
+ // TODO: let clients pass in function to get tag
206
+ const tags = [];
207
+ const initTags = [];
208
+ if (segment.properties?.["font-weight"]) {
209
+ tags.push("b");
210
+ }
211
+ if (segment.properties?.["text-decoration"]) {
212
+ tags.push("u");
213
+ }
214
+ const remTags = [];
215
+ if (tags.length > 0) {
216
+ for (const tag of tags) {
217
+ if (!tagsInProgress.includes(tag)) {
218
+ beginTags += `<${tag}>`;
219
+ initTags.push(tag);
220
+ }
221
+ }
222
+ for (const accumTag of tagsInProgress) {
223
+ if (!tags.includes(accumTag)) {
224
+ endTags += `</${accumTag}>`;
225
+ remTags.push(accumTag);
226
+ }
227
+ }
228
+ for (const initTag of initTags.reverse()) {
229
+ tagsInProgress.push(initTag);
230
+ }
231
+ }
232
+ else {
233
+ for (const accumTag of tagsInProgress) {
234
+ endTags += `</${accumTag}>`;
235
+ remTags.push(accumTag);
236
+ }
237
+ }
238
+ for (const remTag of remTags) {
239
+ const remdex = tagsInProgress.indexOf(remTag);
240
+ if (remdex >= 0) {
241
+ tagsInProgress.splice(remdex, 1);
242
+ }
243
+ }
244
+ textSegment.text += endTags;
245
+ textSegment.text += beginTags;
246
+ if (start <= 0 && end >= segment.text.length) {
247
+ textSegment.text += segment.text;
248
+ }
249
+ else {
250
+ const seglen = segment.text.length;
251
+ const _start = start < 0 ? 0 : start;
252
+ const _end = end >= seglen ? undefined : end;
253
+ textSegment.text += segment.text.substring(_start, _end);
254
+ }
255
+ }
256
+ else {
257
+ if (placeholder && placeholder.length > 0) {
258
+ const placeholderText =
259
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
260
+ placeholder === "*" ? `\n${segment}` : placeholder.repeat(segment.cachedLength);
261
+ textSegment.text += placeholderText;
262
+ }
263
+ else {
264
+ const marker = segment;
265
+ if ((0, merge_tree_1.refHasTileLabel)(marker, accumText.parallelMarkerLabel)) {
266
+ accumText.parallelMarkers.push(marker);
267
+ accumText.parallelText.push(textSegment.text);
268
+ textSegment.text = "";
269
+ }
270
+ }
271
+ }
272
+ return true;
273
+ };
274
+ //# sourceMappingURL=sharedString.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharedString.cjs","sourceRoot":"","sources":["../src/sharedString.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAUoC;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,CAAC,EAAE,EAAE,qCAAmB,CAAC,IAAI,CAAiB,CAAC;IAC5E,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,UAAU;QACvB,OAAO,IAAI,qCAAmB,EAAE,CAAC;IAClC,CAAC;IAED,IAAW,aAAa;QACvB,OAAO,IAAI,CAAC;IACb,CAAC;IAID,YACC,QAAgC,EACzB,EAAU,EACjB,UAA8B;QAE9B,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,qCAAmB,CAAC,eAAsB,CAAC,CAAC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AW,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;SACzD;KACD;SAAM;QACN,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1C,MAAM,eAAe;YACpB,gEAAgE;YAChE,WAAW,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YACjF,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\tIMergeTreeTextHelper,\n\tIRelativePosition,\n\tISegment,\n\tISegmentAction,\n\tMarker,\n\tPropertySet,\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 * 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, 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,22 @@ 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.
109
- */
110
- annotateMarker(marker: Marker, props: PropertySet, combiningOp?: ICombiningOp): void;
111
- findTile(startPos: number | undefined, tileLabel: string, preceding?: boolean): {
112
- tile: ReferencePosition;
113
- pos: number;
114
- };
115
- getTextAndMarkers(label: string): {
116
- parallelText: string[];
117
- parallelMarkers: Marker[];
118
- };
108
+ * Searches a string for the nearest marker in either direction to a given start position.
109
+ * The search will include the start position, so markers at the start position are valid
110
+ * results of the search.
111
+ * @param startPos - Position at which to start the search
112
+ * @param markerLabel - Label of the marker to search for
113
+ * @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`
114
+ */
115
+ searchForMarker(startPos: number, markerLabel: string, forwards?: boolean): Marker | undefined;
119
116
  /**
120
117
  * Retrieve text from the SharedString in string format.
121
118
  * @param start - The starting index of the text to retrieve, or 0 if omitted.
@@ -126,9 +123,35 @@ export declare class SharedString extends SharedSegmentSequence<SharedStringSegm
126
123
  /**
127
124
  * Adds spaces for markers and handles, so that position calculations account for them.
128
125
  */
129
- getTextWithPlaceholders(): string;
130
- getTextRangeWithPlaceholders(start: number, end: number): string;
126
+ getTextWithPlaceholders(start?: number, end?: number): string;
131
127
  getTextRangeWithMarkers(start: number, end: number): string;
132
- getMarkerFromId(id: string): ISegment;
128
+ /**
129
+ * Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided
130
+ * id in this `SharedString`.
131
+ */
132
+ getMarkerFromId(id: string): ISegment | undefined;
133
+ /**
134
+ * Revert an op
135
+ */
136
+ protected rollback(content: any, localOpMetadata: unknown): void;
133
137
  }
138
+ /**
139
+ * Splits the text into regions ending with markers with the given `label`.
140
+ * @param sharedString - String to retrieve text and markers from
141
+ * @param label - label to split on
142
+ * @returns Two parallel lists of text and markers, split by markers with the provided `label`.
143
+ * For example:
144
+ * ```typescript
145
+ * // Say sharedstring has contents "hello<paragraph marker 1>world<paragraph marker 2>missing".
146
+ * const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, "paragraph");
147
+ * // parallelText === ["hello", "world"]
148
+ * // parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]
149
+ * // Note parallelText does not include "missing".
150
+ * ```
151
+ * @internal
152
+ */
153
+ export declare function getTextAndMarkers(sharedString: SharedString, label: string, start?: number, end?: number): {
154
+ parallelText: string[];
155
+ parallelMarkers: Marker[];
156
+ };
134
157
  //# 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,OAAO,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,mBAA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,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI;IAIvF;;;;;OAKG;IACI,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAInD;;;;OAIG;IACI,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW;IAIxD;;;;;;;OAOG;IACI,eAAe,CACrB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,QAAQ,UAAO,GACb,MAAM,GAAG,SAAS;IAIrB;;;;;OAKG;IACI,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAW3C;;OAEG;IACI,uBAAuB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAWpD,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAWzD;;;OAGG;IACI,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAIxD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;CAOhE;AAWD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAChC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM,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, ISharedDefaultMapEvents, IMapMessageLocalMetadata, SequenceOptions, IValueTypeOperationValue } 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: unknown): IMapMessageLocalMetadata | undefined;
135
136
  /**
136
137
  * Process the given op if a handler is registered.
137
138
  * @param message - The message to process
@@ -172,4 +173,4 @@ export declare class DefaultMap<T> {
172
173
  */
173
174
  private makeMapValueOpEmitter;
174
175
  }
175
- //# sourceMappingURL=defaultMap.d.ts.map
176
+ //# sourceMappingURL=defaultMap.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultMap.d.mts","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,uBAAuB,EACvB,wBAAwB,EACxB,eAAe,EACf,wBAAwB,EACxB;AAoCD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;IAEZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,KAAK,EAAE,wBAAwB,CAAC;CAChC;AAED;;GAEG;AACH,MAAM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