@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,1315 @@
1
+ /**
2
+ * Supports distributed data structures which are list-like.
3
+ *
4
+ * This library's main export is {@link SharedString}, a DDS for storing and simultaneously editing a sequence of
5
+ * text.
6
+ *
7
+ * See the package's README for a high-level introduction to `SharedString`'s feature set.
8
+ * @remarks Note that SharedString is a sequence DDS but it has additional specialized features and behaviors for
9
+ * working with text.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+
14
+ import { BaseSegment } from '@fluidframework/merge-tree';
15
+ import { Client } from '@fluidframework/merge-tree';
16
+ import { Deferred } from '@fluidframework/core-utils';
17
+ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
18
+ import { IChannelFactory } from '@fluidframework/datastore-definitions';
19
+ import { IChannelServices } from '@fluidframework/datastore-definitions';
20
+ import { IChannelStorageService } from '@fluidframework/datastore-definitions';
21
+ import { IEvent } from '@fluidframework/core-interfaces';
22
+ import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
23
+ import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
24
+ import { IFluidSerializer } from '@fluidframework/shared-object-base';
25
+ import { IJSONSegment } from '@fluidframework/merge-tree';
26
+ import { IMergeTreeDeltaCallbackArgs } from '@fluidframework/merge-tree';
27
+ import { IMergeTreeDeltaOpArgs } from '@fluidframework/merge-tree';
28
+ import { IMergeTreeGroupMsg } from '@fluidframework/merge-tree';
29
+ import { IMergeTreeMaintenanceCallbackArgs } from '@fluidframework/merge-tree';
30
+ import { IRelativePosition } from '@fluidframework/merge-tree';
31
+ import { ISegment } from '@fluidframework/merge-tree';
32
+ import { ISegmentAction } from '@fluidframework/merge-tree';
33
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
34
+ import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
35
+ import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
36
+ import { ITelemetryContext } from '@fluidframework/runtime-definitions';
37
+ import { LocalReferencePosition } from '@fluidframework/merge-tree';
38
+ import { MapLike } from '@fluidframework/merge-tree';
39
+ import { Marker } from '@fluidframework/merge-tree';
40
+ import { MergeTreeDeltaOperationType } from '@fluidframework/merge-tree';
41
+ import { MergeTreeDeltaOperationTypes } from '@fluidframework/merge-tree';
42
+ import { MergeTreeDeltaRevertible } from '@fluidframework/merge-tree';
43
+ import { MergeTreeDeltaType } from '@fluidframework/merge-tree';
44
+ import { MergeTreeMaintenanceType } from '@fluidframework/merge-tree';
45
+ import { MergeTreeRevertibleDriver } from '@fluidframework/merge-tree';
46
+ import { PropertiesManager } from '@fluidframework/merge-tree';
47
+ import { PropertySet } from '@fluidframework/merge-tree';
48
+ import { ReferencePosition } from '@fluidframework/merge-tree';
49
+ import { ReferenceType } from '@fluidframework/merge-tree';
50
+ import { reservedMarkerIdKey } from '@fluidframework/merge-tree';
51
+ import { reservedRangeLabelsKey } from '@fluidframework/merge-tree';
52
+ import { reservedTileLabelsKey } from '@fluidframework/merge-tree';
53
+ import { Serializable } from '@fluidframework/datastore-definitions';
54
+ import { SharedObject } from '@fluidframework/shared-object-base';
55
+ import { SlidingPreference } from '@fluidframework/merge-tree';
56
+ import { TextSegment } from '@fluidframework/merge-tree';
57
+ import { TrackingGroup } from '@fluidframework/merge-tree';
58
+ import { TypedEventEmitter } from '@fluid-internal/client-utils';
59
+
60
+ /* Excluded from this release type: appendAddIntervalToRevertibles */
61
+
62
+ /* Excluded from this release type: appendChangeIntervalToRevertibles */
63
+
64
+ /* Excluded from this release type: appendDeleteIntervalToRevertibles */
65
+
66
+ /* Excluded from this release type: appendIntervalPropertyChangedToRevertibles */
67
+
68
+ /* Excluded from this release type: appendSharedStringDeltaToRevertibles */
69
+ export { BaseSegment }
70
+
71
+ /* Excluded from this release type: createEndpointIndex */
72
+
73
+ /* Excluded from this release type: createEndpointInRangeIndex */
74
+
75
+ /* Excluded from this release type: createIdIntervalIndex */
76
+
77
+ /* Excluded from this release type: createOverlappingIntervalsIndex */
78
+
79
+ /* Excluded from this release type: createOverlappingSequenceIntervalsIndex */
80
+
81
+ /* Excluded from this release type: createStartpointInRangeIndex */
82
+
83
+ /**
84
+ * @alpha
85
+ */
86
+ export declare type DeserializeCallback = (properties: PropertySet) => void;
87
+
88
+ /* Excluded from this release type: discardSharedStringRevertibles */
89
+
90
+ /* Excluded from this release type: getTextAndMarkers */
91
+
92
+ /* Excluded from this release type: IEndpointIndex */
93
+
94
+ /* Excluded from this release type: IEndpointInRangeIndex */
95
+
96
+ /* Excluded from this release type: IIdIntervalIndex */
97
+
98
+ /**
99
+ * Basic interval abstraction
100
+ * @alpha
101
+ */
102
+ export declare interface IInterval {
103
+ /**
104
+ * @returns a new interval object with identical semantics.
105
+ */
106
+ clone(): IInterval;
107
+ /**
108
+ * Compares this interval to `b` with standard comparator semantics:
109
+ * - returns -1 if this is less than `b`
110
+ * - returns 1 if this is greater than `b`
111
+ * - returns 0 if this is equivalent to `b`
112
+ * @param b - Interval to compare against
113
+ */
114
+ compare(b: IInterval): number;
115
+ /**
116
+ * Compares the start endpoint of this interval to `b`'s start endpoint.
117
+ * Standard comparator semantics apply.
118
+ * @param b - Interval to compare against
119
+ */
120
+ compareStart(b: IInterval): number;
121
+ /**
122
+ * Compares the end endpoint of this interval to `b`'s end endpoint.
123
+ * Standard comparator semantics apply.
124
+ * @param b - Interval to compare against
125
+ */
126
+ compareEnd(b: IInterval): number;
127
+ /**
128
+ * Modifies one or more of the endpoints of this interval, returning a new interval representing the result.
129
+ */
130
+ modify(label: string, start: SequencePlace | undefined, end: SequencePlace | undefined, op?: ISequencedDocumentMessage, localSeq?: number, useNewSlidingBehavior?: boolean): IInterval | undefined;
131
+ /**
132
+ * @returns whether this interval overlaps with `b`.
133
+ * Intervals are considered to overlap if their intersection is non-empty.
134
+ */
135
+ overlaps(b: IInterval): boolean;
136
+ /**
137
+ * Unions this interval with `b`, returning a new interval.
138
+ * The union operates as a convex hull, i.e. if the two intervals are disjoint, the return value includes
139
+ * intermediate values between the two intervals.
140
+ */
141
+ union(b: IInterval): IInterval;
142
+ }
143
+
144
+ /**
145
+ * Collection of intervals that supports addition, modification, removal, and efficient spatial querying.
146
+ * Changes to this collection will be incur updates on collaborating clients (i.e. they are not local-only).
147
+ * @alpha
148
+ */
149
+ export declare interface IIntervalCollection<TInterval extends ISerializableInterval> extends TypedEventEmitter<IIntervalCollectionEvent<TInterval>> {
150
+ readonly attached: boolean;
151
+ /**
152
+ * Attaches an index to this collection.
153
+ * All intervals which are part of this collection will be added to the index, and the index will automatically
154
+ * be updated when this collection updates due to local or remote changes.
155
+ *
156
+ * @remarks After attaching an index to an interval collection, applications should typically store this
157
+ * index somewhere in their in-memory data model for future reference and querying.
158
+ */
159
+ attachIndex(index: IntervalIndex<TInterval>): void;
160
+ /**
161
+ * Detaches an index from this collection.
162
+ * All intervals which are part of this collection will be removed from the index, and updates to this collection
163
+ * due to local or remote changes will no longer incur updates to the index.
164
+ *
165
+ * @returns `false` if the target index cannot be found in the indexes, otherwise remove all intervals in the index and return `true`.
166
+ */
167
+ detachIndex(index: IntervalIndex<TInterval>): boolean;
168
+ /**
169
+ * @returns the interval in this collection that has the provided `id`.
170
+ * If no interval in the collection has this `id`, returns `undefined`.
171
+ */
172
+ getIntervalById(id: string): TInterval | undefined;
173
+ /**
174
+ * Creates a new interval and add it to the collection.
175
+ * @deprecated call IntervalCollection.add without specifying an intervalType
176
+ * @param start - interval start position (inclusive)
177
+ * @param end - interval end position (exclusive)
178
+ * @param intervalType - type of the interval. All intervals are SlideOnRemove. Intervals may not be Transient.
179
+ * @param props - properties of the interval
180
+ * @returns The created interval
181
+ * @remarks See documentation on {@link SequenceInterval} for comments on
182
+ * interval endpoint semantics: there are subtleties with how the current
183
+ * half-open behavior is represented.
184
+ *
185
+ * Note that intervals may behave unexpectedly if the entire contents
186
+ * of the string are deleted. In this case, it is possible for one endpoint
187
+ * of the interval to become detached, while the other remains on the string.
188
+ *
189
+ * By adjusting the `side` and `pos` values of the `start` and `end` parameters,
190
+ * it is possible to control whether the interval expands to include content
191
+ * inserted at its start or end.
192
+ *
193
+ * See {@link SequencePlace} for more details on the model.
194
+ *
195
+ * @example
196
+ *
197
+ * Given the string "ABCD":
198
+ *
199
+ *```typescript
200
+ * // Refers to "BC". If any content is inserted before B or after C, this
201
+ * // interval will include that content
202
+ * //
203
+ * // Picture:
204
+ * // \{start\} - A[- B - C -]D - \{end\}
205
+ * // \{start\} - A - B - C - D - \{end\}
206
+ * collection.add(\{ pos: 0, side: Side.After \}, \{ pos: 3, side: Side.Before \}, IntervalType.SlideOnRemove);
207
+ * // Equivalent to specifying the same positions and Side.Before.
208
+ * // Refers to "ABC". Content inserted after C will be included in the
209
+ * // interval, but content inserted before A will not.
210
+ * // \{start\} -[A - B - C -]D - \{end\}
211
+ * // \{start\} - A - B - C - D - \{end\}
212
+ * collection.add(0, 3, IntervalType.SlideOnRemove);
213
+ *```
214
+ *
215
+ * In the case of the first example, if text is deleted,
216
+ *
217
+ * ```typescript
218
+ * // Delete the character "B"
219
+ * string.removeRange(1, 2);
220
+ * ```
221
+ *
222
+ * The start point of the interval will slide to the position immediately
223
+ * before "C", and the same will be true.
224
+ *
225
+ * ```
226
+ * \{start\} - A[- C -]D - \{end\}
227
+ * ```
228
+ *
229
+ * In this case, text inserted immediately before "C" would be included in
230
+ * the interval.
231
+ *
232
+ * ```typescript
233
+ * string.insertText(1, "EFG");
234
+ * ```
235
+ *
236
+ * With the string now being,
237
+ *
238
+ * ```
239
+ * \{start\} - A[- E - F - G - C -]D - \{end\}
240
+ * ```
241
+ *
242
+ * @privateRemarks TODO: ADO:5205 the above comment regarding behavior in
243
+ * the case that the entire interval has been deleted should be resolved at
244
+ * the same time as this ticket
245
+ */
246
+ add(start: SequencePlace, end: SequencePlace, intervalType: IntervalType, props?: PropertySet): TInterval;
247
+ /**
248
+ * Creates a new interval and add it to the collection.
249
+ * @param start - interval start position (inclusive)
250
+ * @param end - interval end position (exclusive)
251
+ * @param props - properties of the interval
252
+ * @returns - the created interval
253
+ * @remarks - See documentation on {@link SequenceInterval} for comments on interval endpoint semantics: there are subtleties
254
+ * with how the current half-open behavior is represented.
255
+ */
256
+ add({ start, end, props, }: {
257
+ start: SequencePlace;
258
+ end: SequencePlace;
259
+ props?: PropertySet;
260
+ }): TInterval;
261
+ /**
262
+ * Removes an interval from the collection.
263
+ * @param id - Id of the interval to remove
264
+ * @returns the removed interval
265
+ */
266
+ removeIntervalById(id: string): TInterval | undefined;
267
+ /**
268
+ * Changes the properties on an existing interval.
269
+ * @deprecated - call change with the id and and object containing the new properties
270
+ * @param id - Id of the interval whose properties should be changed
271
+ * @param props - Property set to apply to the interval. Shallow merging is used between any existing properties
272
+ * and `prop`, i.e. the interval will end up with a property object equivalent to `{ ...oldProps, ...props }`.
273
+ */
274
+ changeProperties(id: string, props: PropertySet): void;
275
+ /**
276
+ * Changes the endpoints of an existing interval.
277
+ * @deprecated - call change with the start and end parameters encapsulated in an object
278
+ * @param id - Id of the interval to change
279
+ * @param start - New start value. To leave the endpoint unchanged, pass the current value.
280
+ * @param end - New end value. To leave the endpoint unchanged, pass the current value.
281
+ * @returns the interval that was changed, if it existed in the collection.
282
+ */
283
+ change(id: string, start: SequencePlace, end: SequencePlace): TInterval | undefined;
284
+ /**
285
+ * Changes the endpoints, properties, or both of an existing interval.
286
+ * @param id - Id of the Interval to change
287
+ * @returns the interval that was changed, if it existed in the collection.
288
+ * Pass the desired new start position, end position, and/or properties in an object. Start and end positions must be changed
289
+ * simultaneously - they must either both be specified or both undefined. To only change the properties, leave both endpoints
290
+ * undefined. To only change the endpoints, leave the properties undefined.
291
+ */
292
+ change(id: string, { start, end, props }: {
293
+ start?: SequencePlace;
294
+ end?: SequencePlace;
295
+ props?: PropertySet;
296
+ }): TInterval | undefined;
297
+ attachDeserializer(onDeserialize: DeserializeCallback): void;
298
+ /**
299
+ * @returns an iterator over all intervals in this collection.
300
+ */
301
+ [Symbol.iterator](): Iterator<TInterval>;
302
+ /**
303
+ * @returns a forward iterator over all intervals in this collection with start point equal to `startPosition`.
304
+ */
305
+ CreateForwardIteratorWithStartPosition(startPosition: number): Iterator<TInterval>;
306
+ /**
307
+ * @returns a backward iterator over all intervals in this collection with start point equal to `startPosition`.
308
+ */
309
+ CreateBackwardIteratorWithStartPosition(startPosition: number): Iterator<TInterval>;
310
+ /**
311
+ * @returns a forward iterator over all intervals in this collection with end point equal to `endPosition`.
312
+ */
313
+ CreateForwardIteratorWithEndPosition(endPosition: number): Iterator<TInterval>;
314
+ /**
315
+ * @returns a backward iterator over all intervals in this collection with end point equal to `endPosition`.
316
+ */
317
+ CreateBackwardIteratorWithEndPosition(endPosition: number): Iterator<TInterval>;
318
+ /**
319
+ * Gathers iteration results that optionally match a start/end criteria into the provided array.
320
+ * @param results - Array to gather the results into. In lieu of a return value, this array will be populated with
321
+ * intervals matching the query upon edit.
322
+ * @param iteratesForward - whether or not iteration should be in the forward direction
323
+ * @param start - If provided, only match intervals whose start point is equal to `start`.
324
+ * @param end - If provided, only match intervals whose end point is equal to `end`.
325
+ */
326
+ gatherIterationResults(results: TInterval[], iteratesForward: boolean, start?: number, end?: number): void;
327
+ /**
328
+ * @deprecated - Users must manually attach the corresponding interval index to utilize this functionality, for instance:
329
+ *
330
+ * ```typescript
331
+ * const overlappingIntervalsIndex = createOverlappingIntervalsIndex(sharedString);
332
+ * collection.attachIndex(overlappingIntervalsIndex)
333
+ * const result = overlappingIntervalsIndex.findOverlappingIntervals(start, end);
334
+ * ```
335
+ *
336
+ * @returns an array of all intervals in this collection that overlap with the interval
337
+ * `[startPosition, endPosition]`.
338
+ */
339
+ findOverlappingIntervals(startPosition: number, endPosition: number): TInterval[];
340
+ /**
341
+ * Applies a function to each interval in this collection.
342
+ */
343
+ map(fn: (interval: TInterval) => void): void;
344
+ /**
345
+ * @deprecated - due to the forthcoming change where the endpointIndex will no longer be
346
+ * automatically added to the collection. Users are advised to independently attach the
347
+ * index to the collection and utilize the API accordingly, for instance:
348
+ * ```typescript
349
+ * const endpointIndex = createEndpointIndex(sharedString);
350
+ * collection.attachIndex(endpointIndex);
351
+ * const result1 = endpointIndex.previousInterval(pos);
352
+ * ```
353
+ * If an index is used repeatedly, applications should generally attach it once and store it in memory.
354
+ */
355
+ previousInterval(pos: number): TInterval | undefined;
356
+ /**
357
+ * @deprecated - due to the forthcoming change where the endpointIndex will no longer be
358
+ * automatically added to the collection. Users are advised to independently attach the
359
+ * index to the collection and utilize the API accordingly, for instance:
360
+ * ```typescript
361
+ * const endpointIndex = createEndpointIndex(sharedString);
362
+ * collection.attachIndex(endpointIndex);
363
+ * const result2 = endpointIndex.nextInterval(pos);
364
+ * ```
365
+ */
366
+ nextInterval(pos: number): TInterval | undefined;
367
+ }
368
+
369
+ /**
370
+ * Change events emitted by `IntervalCollection`s
371
+ * @alpha
372
+ */
373
+ export declare interface IIntervalCollectionEvent<TInterval extends ISerializableInterval> extends IEvent {
374
+ /**
375
+ * This event is invoked whenever the endpoints of an interval may have changed.
376
+ * This can happen on:
377
+ * - local endpoint modification
378
+ * - ack of a remote endpoint modification
379
+ * - position change due to segment sliding (slides due to mergeTree segment deletion will always appear local)
380
+ * The `interval` argument reflects the new values.
381
+ * `previousInterval` contains transient `ReferencePosition`s at the same location as the interval's original
382
+ * endpoints. These references should be used for position information only.
383
+ * `local` reflects whether the change originated locally.
384
+ * `op` is defined if and only if the server has acked this change.
385
+ * `slide` is true if the change is due to sliding on removal of position
386
+ */
387
+ (event: "changeInterval", listener: (interval: TInterval, previousInterval: TInterval, local: boolean, op: ISequencedDocumentMessage | undefined, slide: boolean) => void): void;
388
+ /**
389
+ * This event is invoked whenever an interval is added or removed from the collection.
390
+ * `local` reflects whether the change originated locally.
391
+ * `op` is defined if and only if the server has acked this change.
392
+ */
393
+ (event: "addInterval" | "deleteInterval", listener: (interval: TInterval, local: boolean, op: ISequencedDocumentMessage | undefined) => void): void;
394
+ /**
395
+ * This event is invoked whenever an interval's properties have changed.
396
+ * `interval` reflects the state of the updated properties.
397
+ * `propertyDeltas` is a map-like whose keys contain all values that were changed, and whose
398
+ * values contain all previous values of the property set.
399
+ * This object can be used directly in a call to `changeProperties` to revert the property change if desired.
400
+ * `local` reflects whether the change originated locally.
401
+ * `op` is defined if and only if the server has acked this change.
402
+ */
403
+ (event: "propertyChanged", listener: (interval: TInterval, propertyDeltas: PropertySet, local: boolean, op: ISequencedDocumentMessage | undefined) => void): void;
404
+ }
405
+
406
+ /* Excluded from this release type: IIntervalHelpers */
407
+
408
+ /* Excluded from this release type: IJSONRunSegment */
409
+
410
+ /* Excluded from this release type: IMapMessageLocalMetadata */
411
+
412
+ /**
413
+ * A sequence place that does not refer to the special endpoint segments.
414
+ *
415
+ * See {@link SequencePlace} for additional context.
416
+ * @alpha
417
+ */
418
+ export declare interface InteriorSequencePlace {
419
+ pos: number;
420
+ side: Side;
421
+ }
422
+
423
+ /* Excluded from this release type: Interval */
424
+
425
+ /**
426
+ * Collection of intervals.
427
+ *
428
+ * Implementers of this interface will typically implement additional APIs to support efficiently querying a collection
429
+ * of intervals in some manner, for example:
430
+ * - "find all intervals with start endpoint between these two points"
431
+ * - "find all intervals which overlap this range"
432
+ * etc.
433
+ * @alpha
434
+ */
435
+ export declare interface IntervalIndex<TInterval extends ISerializableInterval> {
436
+ /**
437
+ * Adds an interval to the index.
438
+ * @remarks Application code should never need to invoke this method on their index for production scenarios:
439
+ * Fluid handles adding and removing intervals from an index in response to sequence or interval changes.
440
+ */
441
+ add(interval: TInterval): void;
442
+ /**
443
+ * Removes an interval from the index.
444
+ * @remarks Application code should never need to invoke this method on their index for production scenarios:
445
+ * Fluid handles adding and removing intervals from an index in response to sequence or interval changes.
446
+ */
447
+ remove(interval: TInterval): void;
448
+ }
449
+
450
+ /* Excluded from this release type: IntervalLocator */
451
+
452
+ /* Excluded from this release type: intervalLocatorFromEndpoint */
453
+
454
+ /* Excluded from this release type: IntervalOpType */
455
+
456
+ /* Excluded from this release type: IntervalRevertible */
457
+
458
+ /**
459
+ * Determines how an interval should expand when segments are inserted adjacent
460
+ * to the range it spans
461
+ *
462
+ * Note that interval stickiness is currently an experimental feature and must
463
+ * be explicitly enabled with the `intervalStickinessEnabled` flag
464
+ *
465
+ * @alpha
466
+ */
467
+ export declare const IntervalStickiness: {
468
+ /**
469
+ * Interval does not expand to include adjacent segments
470
+ */
471
+ readonly NONE: 0;
472
+ /**
473
+ * Interval expands to include segments inserted adjacent to the start
474
+ */
475
+ readonly START: 1;
476
+ /**
477
+ * Interval expands to include segments inserted adjacent to the end
478
+ *
479
+ * This is the default stickiness
480
+ */
481
+ readonly END: 2;
482
+ /**
483
+ * Interval expands to include all segments inserted adjacent to it
484
+ */
485
+ readonly FULL: 3;
486
+ };
487
+
488
+ /**
489
+ * Determines how an interval should expand when segments are inserted adjacent
490
+ * to the range it spans
491
+ *
492
+ * Note that interval stickiness is currently an experimental feature and must
493
+ * be explicitly enabled with the `intervalStickinessEnabled` flag
494
+ * @alpha
495
+ */
496
+ export declare type IntervalStickiness = (typeof IntervalStickiness)[keyof typeof IntervalStickiness];
497
+
498
+ /**
499
+ * @alpha
500
+ */
501
+ export declare enum IntervalType {
502
+ Simple = 0,
503
+ /**
504
+ * SlideOnRemove indicates that the ends of the interval will slide if the segment
505
+ * they reference is removed and acked.
506
+ * See `packages\dds\merge-tree\docs\REFERENCEPOSITIONS.md` for details
507
+ * SlideOnRemove is the default interval behavior and does not need to be specified.
508
+ */
509
+ SlideOnRemove = 2,
510
+ /* Excluded from this release type: Transient */
511
+ }
512
+
513
+ /* Excluded from this release type: IOverlappingIntervalsIndex */
514
+
515
+ export { ISegment }
516
+
517
+ /**
518
+ * A range that has changed corresponding to a segment modification.
519
+ * @alpha
520
+ */
521
+ export declare interface ISequenceDeltaRange<TOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes> {
522
+ /**
523
+ * The type of operation that changed this range.
524
+ *
525
+ * @remarks Consuming code should typically compare this to the enum values defined in
526
+ * `MergeTreeDeltaOperationTypes`.
527
+ */
528
+ operation: TOperation;
529
+ /**
530
+ * The index of the start of the range.
531
+ */
532
+ position: number;
533
+ /**
534
+ * The segment that corresponds to the range.
535
+ */
536
+ segment: ISegment;
537
+ /**
538
+ * Deltas object which contains all modified properties with their previous values.
539
+ * Since `undefined` doesn't survive a round-trip through JSON serialization, the old value being absent
540
+ * is instead encoded with `null`.
541
+ *
542
+ * @remarks This object is motivated by undo/redo scenarios, and provides a convenient "inverse op" to apply to
543
+ * undo a property change.
544
+ *
545
+ * @example
546
+ *
547
+ * If a segment initially had properties `{ foo: "1", bar: 2 }` and it was annotated with
548
+ * `{ foo: 3, baz: 5 }`, the corresponding event would have a `propertyDeltas` of `{ foo: "1", baz: null }`.
549
+ */
550
+ propertyDeltas: PropertySet;
551
+ }
552
+
553
+ /**
554
+ * @alpha
555
+ */
556
+ export declare interface ISerializableInterval extends IInterval {
557
+ /** Serializable bag of properties associated with the interval. */
558
+ properties: PropertySet;
559
+ /***/
560
+ propertyManager: PropertiesManager;
561
+ /***/
562
+ serialize(): ISerializedInterval;
563
+ /***/
564
+ addProperties(props: PropertySet, collaborating?: boolean, seq?: number): PropertySet | undefined;
565
+ /**
566
+ * Gets the id associated with this interval.
567
+ * When the interval is used as part of an interval collection, this id can be used to modify or remove the
568
+ * interval.
569
+ * @remarks This signature includes `undefined` strictly for backwards-compatibility reasons, as older versions
570
+ * of Fluid didn't always write interval ids.
571
+ */
572
+ getIntervalId(): string | undefined;
573
+ }
574
+
575
+ /**
576
+ * Serialized object representation of an interval.
577
+ * This representation is used for ops that create or change intervals.
578
+ * @alpha
579
+ */
580
+ export declare interface ISerializedInterval {
581
+ /**
582
+ * Sequence number at which `start` and `end` should be interpreted
583
+ *
584
+ * @remarks It's unclear that this is necessary to store here.
585
+ * This should just be the refSeq on the op that modified the interval, which should be available via other means.
586
+ * At the time of writing, it's not plumbed through to the reconnect/rebase code, however, which does need it.
587
+ */
588
+ sequenceNumber: number;
589
+ /** Start position of the interval */
590
+ start: number | "start" | "end";
591
+ /** End position of the interval */
592
+ end: number | "start" | "end";
593
+ /** Interval type to create */
594
+ intervalType: IntervalType;
595
+ /**
596
+ * The stickiness of this interval
597
+ */
598
+ stickiness?: IntervalStickiness;
599
+ startSide?: Side;
600
+ endSide?: Side;
601
+ /** Any properties the interval has */
602
+ properties?: PropertySet;
603
+ }
604
+
605
+ /**
606
+ * @alpha
607
+ */
608
+ export declare interface ISharedIntervalCollection<TInterval extends ISerializableInterval> {
609
+ getIntervalCollection(label: string): IIntervalCollection<TInterval>;
610
+ }
611
+
612
+ /**
613
+ * Events emitted in response to changes to the sequence data.
614
+ *
615
+ * @remarks
616
+ *
617
+ * The following is the list of events emitted.
618
+ *
619
+ * ### "sequenceDelta"
620
+ *
621
+ * The sequenceDelta event is emitted when segments are inserted, annotated, or removed.
622
+ *
623
+ * #### Listener signature
624
+ *
625
+ * ```typescript
626
+ * (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void
627
+ * ```
628
+ * - `event` - Various information on the segments that were modified.
629
+ *
630
+ * - `target` - The sequence itself.
631
+ *
632
+ * ### "maintenance"
633
+ *
634
+ * The maintenance event is emitted when segments are modified during merge-tree maintenance.
635
+ *
636
+ * #### Listener signature
637
+ *
638
+ * ```typescript
639
+ * (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void
640
+ * ```
641
+ * - `event` - Various information on the segments that were modified.
642
+ *
643
+ * - `target` - The sequence itself.
644
+ * @alpha
645
+ */
646
+ export declare interface ISharedSegmentSequenceEvents extends ISharedObjectEvents {
647
+ (event: "createIntervalCollection", listener: (label: string, local: boolean, target: IEventThisPlaceHolder) => void): void;
648
+ (event: "sequenceDelta", listener: (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void): void;
649
+ (event: "maintenance", listener: (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void): void;
650
+ }
651
+
652
+ /**
653
+ * Fluid object interface describing access methods on a SharedString
654
+ * @alpha
655
+ */
656
+ export declare interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {
657
+ /**
658
+ * Inserts the text at the position.
659
+ * @param pos - The position to insert the text at
660
+ * @param text - The text to insert
661
+ * @param props - The properties of the text
662
+ */
663
+ insertText(pos: number, text: string, props?: PropertySet): void;
664
+ /**
665
+ * Inserts a marker at the position.
666
+ * @param pos - The position to insert the marker at
667
+ * @param refType - The reference type of the marker
668
+ * @param props - The properties of the marker
669
+ */
670
+ insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): void;
671
+ /**
672
+ * {@inheritDoc SharedSegmentSequence.posFromRelativePos}
673
+ */
674
+ posFromRelativePos(relativePos: IRelativePosition): number;
675
+ }
676
+
677
+ /* Excluded from this release type: IStartpointInRangeIndex */
678
+
679
+ /* Excluded from this release type: IValueOpEmitter */
680
+ export { LocalReferencePosition }
681
+
682
+ export { MapLike }
683
+
684
+ export { Marker }
685
+
686
+ export { MergeTreeDeltaType }
687
+
688
+ export { PropertySet }
689
+
690
+ export { ReferencePosition }
691
+
692
+ export { ReferenceType }
693
+
694
+ /* Excluded from this release type: reservedMarkerIdKey */
695
+
696
+ /* Excluded from this release type: reservedRangeLabelsKey */
697
+
698
+ /* Excluded from this release type: reservedTileLabelsKey */
699
+
700
+ /* Excluded from this release type: revertSharedStringRevertibles */
701
+
702
+ /**
703
+ * The event object returned on sequenceDelta events.
704
+ *
705
+ * The properties of this object and its sub-objects represent the state of the sequence at the
706
+ * point in time at which the operation was applied.
707
+ * They will not take into consideration any future modifications performed to the underlying sequence and merge tree.
708
+ *
709
+ * For group ops, each op will get its own event, and the group op property will be set on the op args.
710
+ *
711
+ * Ops may get multiple events. For instance, an insert-replace will get a remove then an insert event.
712
+ * @alpha
713
+ */
714
+ export declare class SequenceDeltaEvent extends SequenceEvent<MergeTreeDeltaOperationType> {
715
+ readonly opArgs: IMergeTreeDeltaOpArgs;
716
+ /**
717
+ * Whether the event was caused by a locally-made change.
718
+ */
719
+ readonly isLocal: boolean;
720
+ constructor(opArgs: IMergeTreeDeltaOpArgs, deltaArgs: IMergeTreeDeltaCallbackArgs, mergeTreeClient: Client);
721
+ }
722
+
723
+ /**
724
+ * Base class for SequenceDeltaEvent and SequenceMaintenanceEvent.
725
+ *
726
+ * The properties of this object and its sub-objects represent the state of the sequence at the
727
+ * point in time at which the operation was applied.
728
+ * They will not take into any future modifications performed to the underlying sequence and merge tree.
729
+ * @alpha
730
+ */
731
+ export declare abstract class SequenceEvent<TOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes> {
732
+ readonly deltaArgs: IMergeTreeDeltaCallbackArgs<TOperation>;
733
+ private readonly mergeTreeClient;
734
+ readonly deltaOperation: TOperation;
735
+ private readonly sortedRanges;
736
+ private readonly pFirst;
737
+ private readonly pLast;
738
+ constructor(deltaArgs: IMergeTreeDeltaCallbackArgs<TOperation>, mergeTreeClient: Client);
739
+ /**
740
+ * The in-order ranges affected by this delta.
741
+ * These may not be continuous.
742
+ */
743
+ get ranges(): readonly Readonly<ISequenceDeltaRange<TOperation>>[];
744
+ /**
745
+ * The client id of the client that made the change which caused the delta event
746
+ */
747
+ get clientId(): string | undefined;
748
+ /**
749
+ * The first of the modified ranges.
750
+ */
751
+ get first(): Readonly<ISequenceDeltaRange<TOperation>>;
752
+ /**
753
+ * The last of the modified ranges.
754
+ */
755
+ get last(): Readonly<ISequenceDeltaRange<TOperation>>;
756
+ }
757
+
758
+ /**
759
+ * Interval implementation whose ends are associated with positions in a mutatable sequence.
760
+ * As such, when content is inserted into the middle of the interval, the interval expands to
761
+ * include that content.
762
+ *
763
+ * @remarks The endpoints' positions should be treated exclusively to get
764
+ * reasonable behavior. E.g., an interval referring to "hello" in "hello world"
765
+ * should have a start position of 0 and an end position of 5.
766
+ *
767
+ * To see why, consider what happens if "llo wor" is removed from the string to make "held".
768
+ * The interval's startpoint remains on the "h" (it isn't altered), but the interval's endpoint
769
+ * slides forward to the next unremoved position, which is the "l" in "held".
770
+ * Users would generally expect the interval to now refer to "he" (as it is the subset of content
771
+ * remaining after the removal), hence the "l" should be excluded.
772
+ * If the interval endpoint was treated inclusively, the interval would now refer to "hel", which
773
+ * is undesirable.
774
+ *
775
+ * Since the endpoints of an interval are treated exclusively but cannot be greater
776
+ * than or equal to the length of the associated sequence, there exist special
777
+ * endpoint segments, "start" and "end", which represent the position immediately
778
+ * before or immediately after the string respectively.
779
+ *
780
+ * If a `SequenceInterval` is created on a sequence with the
781
+ * `mergeTreeReferencesCanSlideToEndpoint` feature flag set to true, the endpoints
782
+ * of the interval that are exclusive will have the ability to slide to these
783
+ * special endpoint segments.
784
+ * @alpha
785
+ */
786
+ export declare class SequenceInterval implements ISerializableInterval {
787
+ private readonly client;
788
+ /**
789
+ * Start endpoint of this interval.
790
+ * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
791
+ */
792
+ start: LocalReferencePosition;
793
+ /**
794
+ * End endpoint of this interval.
795
+ * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
796
+ */
797
+ end: LocalReferencePosition;
798
+ intervalType: IntervalType;
799
+ readonly startSide: Side;
800
+ readonly endSide: Side;
801
+ /**
802
+ * {@inheritDoc ISerializableInterval.properties}
803
+ */
804
+ properties: PropertySet;
805
+ /**
806
+ * {@inheritDoc ISerializableInterval.propertyManager}
807
+ */
808
+ propertyManager: PropertiesManager;
809
+ /***/
810
+ get stickiness(): IntervalStickiness;
811
+ constructor(client: Client,
812
+ /**
813
+ * Start endpoint of this interval.
814
+ * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
815
+ */
816
+ start: LocalReferencePosition,
817
+ /**
818
+ * End endpoint of this interval.
819
+ * @remarks This endpoint can be resolved into a character position using the SharedString it's a part of.
820
+ */
821
+ end: LocalReferencePosition, intervalType: IntervalType, props?: PropertySet, startSide?: Side, endSide?: Side);
822
+ private callbacks?;
823
+ /**
824
+ * Subscribes to position change events on this interval if there are no current listeners.
825
+ */
826
+ addPositionChangeListeners(beforePositionChange: () => void, afterPositionChange: () => void): void;
827
+ /**
828
+ * Removes the currently subscribed position change listeners.
829
+ */
830
+ removePositionChangeListeners(): void;
831
+ /**
832
+ * {@inheritDoc ISerializableInterval.serialize}
833
+ */
834
+ serialize(): ISerializedInterval;
835
+ /**
836
+ * {@inheritDoc IInterval.clone}
837
+ */
838
+ clone(): SequenceInterval;
839
+ /**
840
+ * {@inheritDoc IInterval.compare}
841
+ */
842
+ compare(b: SequenceInterval): number;
843
+ /**
844
+ * {@inheritDoc IInterval.compareStart}
845
+ */
846
+ compareStart(b: SequenceInterval): number;
847
+ /**
848
+ * {@inheritDoc IInterval.compareEnd}
849
+ */
850
+ compareEnd(b: SequenceInterval): number;
851
+ /**
852
+ * {@inheritDoc IInterval.overlaps}
853
+ */
854
+ overlaps(b: SequenceInterval): boolean;
855
+ /**
856
+ * {@inheritDoc ISerializableInterval.getIntervalId}
857
+ */
858
+ getIntervalId(): string;
859
+ /**
860
+ * {@inheritDoc IInterval.union}
861
+ */
862
+ union(b: SequenceInterval): SequenceInterval;
863
+ /**
864
+ * {@inheritDoc ISerializableInterval.addProperties}
865
+ */
866
+ addProperties(newProps: PropertySet, collab?: boolean, seq?: number): PropertySet | undefined;
867
+ /**
868
+ * @returns whether this interval overlaps two numerical positions.
869
+ */
870
+ overlapsPos(bstart: number, bend: number): boolean;
871
+ /**
872
+ * {@inheritDoc IInterval.modify}
873
+ */
874
+ modify(label: string, start: SequencePlace | undefined, end: SequencePlace | undefined, op?: ISequencedDocumentMessage, localSeq?: number, useNewSlidingBehavior?: boolean): SequenceInterval;
875
+ }
876
+
877
+ /* Excluded from this release type: sequenceIntervalHelpers */
878
+
879
+ /* Excluded from this release type: SequenceIntervalIndexes */
880
+
881
+ /**
882
+ * The event object returned on maintenance events.
883
+ *
884
+ * The properties of this object and its sub-objects represent the state of the sequence at the
885
+ * point in time at which the operation was applied.
886
+ * They will not take into consideration any future modifications performed to the underlying sequence and merge tree.
887
+ * @alpha
888
+ */
889
+ export declare class SequenceMaintenanceEvent extends SequenceEvent<MergeTreeMaintenanceType> {
890
+ readonly opArgs: IMergeTreeDeltaOpArgs | undefined;
891
+ constructor(opArgs: IMergeTreeDeltaOpArgs | undefined, deltaArgs: IMergeTreeMaintenanceCallbackArgs, mergeTreeClient: Client);
892
+ }
893
+
894
+ /* Excluded from this release type: SequenceOptions */
895
+
896
+ /**
897
+ * Defines a position and side relative to a character in a sequence.
898
+ *
899
+ * For this purpose, sequences look like:
900
+ *
901
+ * `{start} - {character 0} - {character 1} - ... - {character N} - {end}`
902
+ *
903
+ * Each `{value}` in the diagram is a character within a sequence.
904
+ * Each `-` in the above diagram is a position where text could be inserted.
905
+ * Each position between a `{value}` and a `-` is a `SequencePlace`.
906
+ *
907
+ * The special endpoints `{start}` and `{end}` refer to positions outside the
908
+ * contents of the string.
909
+ *
910
+ * This gives us 2N + 2 possible positions to refer to within a string, where N
911
+ * is the number of characters.
912
+ *
913
+ * If the position is specified with a bare number, the side defaults to
914
+ * `Side.Before`.
915
+ *
916
+ * If a SequencePlace is the endpoint of a range (e.g. start/end of an interval or search range),
917
+ * the Side value means it is exclusive if it is nearer to the other position and inclusive if it is farther.
918
+ * E.g. the start of a range with Side.After is exclusive of the character at the position.
919
+ * @alpha
920
+ */
921
+ export declare type SequencePlace = number | "start" | "end" | InteriorSequencePlace;
922
+
923
+ /* Excluded from this release type: SerializedIntervalDelta */
924
+
925
+ /* Excluded from this release type: SharedIntervalCollection */
926
+
927
+ /* Excluded from this release type: SharedIntervalCollectionFactory */
928
+
929
+ /**
930
+ * @alpha
931
+ */
932
+ export declare abstract class SharedSegmentSequence<T extends ISegment> extends SharedObject<ISharedSegmentSequenceEvents> implements ISharedIntervalCollection<SequenceInterval>, MergeTreeRevertibleDriver {
933
+ private readonly dataStoreRuntime;
934
+ id: string;
935
+ readonly segmentFromSpec: (spec: IJSONSegment) => ISegment;
936
+ get loaded(): Promise<void>;
937
+ /**
938
+ * This is a safeguard to avoid problematic reentrancy of local ops. This type of scenario occurs if the user of SharedString subscribes
939
+ * to the `sequenceDelta` event and uses the callback for a local op to submit further local ops.
940
+ * Historically (before 2.0.0-internal.6.1.0), doing so would result in eventual consistency issues or a corrupted document.
941
+ * These issues were fixed in #16815 which makes such reentrancy no different from applying the ops in order but not from within the change events,
942
+ * but there is still little test coverage for reentrant scenarios.
943
+ * Additionally, applications submitting ops from inside change events need to take extreme care that their data models also support reentrancy.
944
+ * Since this is likely not the case, by default SharedString throws when encountering reentrant ops.
945
+ *
946
+ * An application using SharedString which explicitly wants to opt in to allowing reentrancy anyway can set `sharedStringPreventReentrancy`
947
+ * on the data store options to `false`.
948
+ */
949
+ protected guardReentrancy: <TRet>(callback: () => TRet) => TRet;
950
+ private static createOpsFromDelta;
951
+ protected client: Client;
952
+ /** `Deferred` that triggers once the object is loaded */
953
+ protected loadedDeferred: Deferred<void>;
954
+ private readonly loadedDeferredOutgoingOps;
955
+ private deferIncomingOps;
956
+ private readonly loadedDeferredIncomingOps;
957
+ private messagesSinceMSNChange;
958
+ private readonly intervalCollections;
959
+ constructor(dataStoreRuntime: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes, segmentFromSpec: (spec: IJSONSegment) => ISegment);
960
+ /**
961
+ * @param start - The inclusive start of the range to remove
962
+ * @param end - The exclusive end of the range to remove
963
+ */
964
+ removeRange(start: number, end: number): void;
965
+ /**
966
+ * Obliterate is similar to remove, but differs in that segments concurrently
967
+ * inserted into an obliterated range will also be removed
968
+ *
969
+ * @param start - The inclusive start of the range to obliterate
970
+ * @param end - The exclusive end of the range to obliterate
971
+ */
972
+ obliterateRange(start: number, end: number): void;
973
+ /**
974
+ * @deprecated The ability to create group ops will be removed in an upcoming
975
+ * release, as group ops are redundant with the native batching capabilities
976
+ * of the runtime
977
+ */
978
+ groupOperation(groupOp: IMergeTreeGroupMsg): void;
979
+ /**
980
+ * Finds the segment information (i.e. segment + offset) corresponding to a character position in the SharedString.
981
+ * If the position is past the end of the string, `segment` and `offset` on the returned object may be undefined.
982
+ * @param pos - Character position (index) into the current local view of the SharedString.
983
+ */
984
+ getContainingSegment(pos: number): {
985
+ segment: T | undefined;
986
+ offset: number | undefined;
987
+ };
988
+ /**
989
+ * Returns the length of the current sequence for the client
990
+ */
991
+ getLength(): number;
992
+ /**
993
+ * Returns the current position of a segment, and -1 if the segment
994
+ * does not exist in this sequence
995
+ * @param segment - The segment to get the position of
996
+ */
997
+ getPosition(segment: ISegment): number;
998
+ /**
999
+ * Annotates the range with the provided properties
1000
+ *
1001
+ * @param start - The inclusive start position of the range to annotate
1002
+ * @param end - The exclusive end position of the range to annotate
1003
+ * @param props - The properties to annotate the range with
1004
+ *
1005
+ */
1006
+ annotateRange(start: number, end: number, props: PropertySet): void;
1007
+ getPropertiesAtPosition(pos: number): PropertySet | undefined;
1008
+ getRangeExtentsOfPosition(pos: number): {
1009
+ posStart: number | undefined;
1010
+ posAfterEnd: number | undefined;
1011
+ };
1012
+ /**
1013
+ * Creates a `LocalReferencePosition` on this SharedString. If the refType does not include
1014
+ * ReferenceType.Transient, the returned reference will be added to the localRefs on the provided segment.
1015
+ * @param segment - Segment to add the local reference on
1016
+ * @param offset - Offset on the segment at which to place the local reference
1017
+ * @param refType - ReferenceType for the created local reference
1018
+ * @param properties - PropertySet to place on the created local reference
1019
+ */
1020
+ createLocalReferencePosition(segment: T, offset: number, refType: ReferenceType, properties: PropertySet | undefined, slidingPreference?: SlidingPreference, canSlideToEndpoint?: boolean): LocalReferencePosition;
1021
+ /**
1022
+ * Resolves a `ReferencePosition` into a character position using this client's perspective.
1023
+ */
1024
+ localReferencePositionToPosition(lref: ReferencePosition): number;
1025
+ /**
1026
+ * Removes a `LocalReferencePosition` from this SharedString.
1027
+ */
1028
+ removeLocalReferencePosition(lref: LocalReferencePosition): LocalReferencePosition | undefined;
1029
+ /**
1030
+ * Resolves a remote client's position against the local sequence
1031
+ * and returns the remote client's position relative to the local
1032
+ * sequence. The client ref seq must be above the minimum sequence number
1033
+ * or the return value will be undefined.
1034
+ * Generally this method is used in conjunction with signals which provide
1035
+ * point in time values for the below parameters, and is useful for things
1036
+ * like displaying user position. It should not be used with persisted values
1037
+ * as persisted values will quickly become invalid as the remoteClientRefSeq
1038
+ * moves below the minimum sequence number
1039
+ * @param remoteClientPosition - The remote client's position to resolve
1040
+ * @param remoteClientRefSeq - The reference sequence number of the remote client
1041
+ * @param remoteClientId - The client id of the remote client
1042
+ */
1043
+ resolveRemoteClientPosition(remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: string): number | undefined;
1044
+ private submitSequenceMessage;
1045
+ /**
1046
+ * Given a position specified relative to a marker id, lookup the marker
1047
+ * and convert the position to a character position.
1048
+ * @param relativePos - Id of marker (may be indirect) and whether position is before or after marker.
1049
+ */
1050
+ posFromRelativePos(relativePos: IRelativePosition): number;
1051
+ /**
1052
+ * Walk the underlying segments of the sequence.
1053
+ * The walked segments may extend beyond the range if the segments cross the
1054
+ * ranges start or end boundaries.
1055
+ *
1056
+ * Set split range to true to ensure only segments within the range are walked.
1057
+ *
1058
+ * @param handler - The function to handle each segment. Traversal ends if
1059
+ * this function returns true.
1060
+ * @param start - Optional. The start of range walk.
1061
+ * @param end - Optional. The end of range walk
1062
+ * @param accum - Optional. An object that will be passed to the handler for accumulation
1063
+ * @param splitRange - Optional. Splits boundary segments on the range boundaries
1064
+ */
1065
+ walkSegments<TClientData>(handler: ISegmentAction<TClientData>, start?: number, end?: number, accum?: TClientData, splitRange?: boolean): void;
1066
+ /**
1067
+ * @returns The most recent sequence number which has been acked by the server and processed by this
1068
+ * SharedSegmentSequence.
1069
+ */
1070
+ getCurrentSeq(): number;
1071
+ /**
1072
+ * Inserts a segment directly before a `ReferencePosition`.
1073
+ * @param refPos - The reference position to insert the segment at
1074
+ * @param segment - The segment to insert
1075
+ */
1076
+ insertAtReferencePosition(pos: ReferencePosition, segment: T): void;
1077
+ /**
1078
+ * Inserts a segment
1079
+ * @param start - The position to insert the segment at
1080
+ * @param spec - The segment to inserts spec
1081
+ */
1082
+ insertFromSpec(pos: number, spec: IJSONSegment): void;
1083
+ /**
1084
+ * Retrieves the interval collection keyed on `label`. If no such interval collection exists,
1085
+ * creates one.
1086
+ */
1087
+ getIntervalCollection(label: string): IIntervalCollection<SequenceInterval>;
1088
+ /**
1089
+ * @returns An iterable object that enumerates the IntervalCollection labels.
1090
+ *
1091
+ * @example
1092
+ *
1093
+ * ```typescript
1094
+ * const iter = this.getIntervalCollectionKeys();
1095
+ * for (key of iter)
1096
+ * const collection = this.getIntervalCollection(key);
1097
+ * ...
1098
+ * ```
1099
+ */
1100
+ getIntervalCollectionLabels(): IterableIterator<string>;
1101
+ /**
1102
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
1103
+ */
1104
+ protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
1105
+ /**
1106
+ * Runs serializer over the GC data for this SharedMatrix.
1107
+ * All the IFluidHandle's represent routes to other objects.
1108
+ */
1109
+ protected processGCDataCore(serializer: IFluidSerializer): void;
1110
+ /**
1111
+ * Replace the range specified from start to end with the provided segment
1112
+ * This is done by inserting the segment at the end of the range, followed
1113
+ * by removing the contents of the range
1114
+ * For a zero or reverse range (start \>= end), insert at end do not remove anything
1115
+ * @param start - The start of the range to replace
1116
+ * @param end - The end of the range to replace
1117
+ * @param segment - The segment that will replace the range
1118
+ */
1119
+ protected replaceRange(start: number, end: number, segment: ISegment): void;
1120
+ /**
1121
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onConnect}
1122
+ */
1123
+ protected onConnect(): void;
1124
+ /**
1125
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
1126
+ */
1127
+ protected onDisconnect(): void;
1128
+ /**
1129
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
1130
+ */
1131
+ protected reSubmitCore(content: any, localOpMetadata: unknown): void;
1132
+ /**
1133
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
1134
+ */
1135
+ protected loadCore(storage: IChannelStorageService): Promise<void>;
1136
+ /**
1137
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
1138
+ */
1139
+ protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
1140
+ /**
1141
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.didAttach}
1142
+ */
1143
+ protected didAttach(): void;
1144
+ /**
1145
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.initializeLocalCore}
1146
+ */
1147
+ protected initializeLocalCore(): void;
1148
+ /**
1149
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
1150
+ */
1151
+ protected applyStashedOp(content: any): unknown;
1152
+ private summarizeMergeTree;
1153
+ private processMergeTreeMsg;
1154
+ private processMinSequenceNumberChanged;
1155
+ private loadFinished;
1156
+ private initializeIntervalCollections;
1157
+ }
1158
+
1159
+ /* Excluded from this release type: SharedSequence */
1160
+
1161
+ /**
1162
+ * The Shared String is a specialized data structure for handling collaborative
1163
+ * text. It is based on a more general Sequence data structure but has
1164
+ * additional features that make working with text easier.
1165
+ *
1166
+ * In addition to text, a Shared String can also contain markers. Markers can be
1167
+ * used to store metadata at positions within the text, like the details of an
1168
+ * image or Fluid object that should be rendered with the text.
1169
+ * @alpha
1170
+ */
1171
+ export declare class SharedString extends SharedSegmentSequence<SharedStringSegment> implements ISharedString {
1172
+ id: string;
1173
+ /**
1174
+ * Create a new shared string.
1175
+ * @param runtime - data store runtime the new shared string belongs to
1176
+ * @param id - optional name of the shared string
1177
+ * @returns newly create shared string (but not attached yet)
1178
+ */
1179
+ static create(runtime: IFluidDataStoreRuntime, id?: string): SharedString;
1180
+ /**
1181
+ * Get a factory for SharedString to register with the data store.
1182
+ * @returns a factory that creates and load SharedString
1183
+ */
1184
+ static getFactory(): SharedStringFactory;
1185
+ get ISharedString(): ISharedString;
1186
+ private readonly mergeTreeTextHelper;
1187
+ constructor(document: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes);
1188
+ /**
1189
+ * Inserts a marker at a relative position.
1190
+ * @param relativePos1 - The relative position to insert the marker at
1191
+ * @param refType - The reference type of the marker
1192
+ * @param props - The properties of the marker
1193
+ */
1194
+ insertMarkerRelative(relativePos1: IRelativePosition, refType: ReferenceType, props?: PropertySet): void;
1195
+ /**
1196
+ * {@inheritDoc ISharedString.insertMarker}
1197
+ */
1198
+ insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): void;
1199
+ /**
1200
+ * Inserts the text at the position.
1201
+ * @param relativePos1 - The relative position to insert the text at
1202
+ * @param text - The text to insert
1203
+ * @param props - The properties of text
1204
+ */
1205
+ insertTextRelative(relativePos1: IRelativePosition, text: string, props?: PropertySet): void;
1206
+ /**
1207
+ * {@inheritDoc ISharedString.insertText}
1208
+ */
1209
+ insertText(pos: number, text: string, props?: PropertySet): void;
1210
+ /**
1211
+ * Replaces a range with the provided text.
1212
+ * @param start - The inclusive start of the range to replace
1213
+ * @param end - The exclusive end of the range to replace
1214
+ * @param text - The text to replace the range with
1215
+ * @param props - Optional. The properties of the replacement text
1216
+ */
1217
+ replaceText(start: number, end: number, text: string, props?: PropertySet): void;
1218
+ /**
1219
+ * Removes the text in the given range.
1220
+ * @param start - The inclusive start of the range to remove
1221
+ * @param end - The exclusive end of the range to replace
1222
+ * @returns the message sent.
1223
+ */
1224
+ removeText(start: number, end: number): void;
1225
+ /**
1226
+ * Annotates the marker with the provided properties.
1227
+ * @param marker - The marker to annotate
1228
+ * @param props - The properties to annotate the marker with
1229
+ */
1230
+ annotateMarker(marker: Marker, props: PropertySet): void;
1231
+ /**
1232
+ * Finds the nearest reference with ReferenceType.Tile to `startPos` in the direction dictated by `tilePrecedesPos`.
1233
+ * Note that Markers receive `ReferenceType.Tile` by default.
1234
+ * @deprecated Use `searchForMarker` instead.
1235
+ * @param startPos - Position at which to start the search
1236
+ * @param clientId - clientId dictating the perspective to search from
1237
+ * @param tileLabel - Label of the tile to search for
1238
+ * @param preceding - Whether the desired tile comes before (true) or after (false) `startPos`
1239
+ */
1240
+ findTile(startPos: number | undefined, tileLabel: string, preceding?: boolean): {
1241
+ tile: ReferencePosition;
1242
+ pos: number;
1243
+ } | undefined;
1244
+ /**
1245
+ * Searches a string for the nearest marker in either direction to a given start position.
1246
+ * The search will include the start position, so markers at the start position are valid
1247
+ * results of the search.
1248
+ * @param startPos - Position at which to start the search
1249
+ * @param markerLabel - Label of the marker to search for
1250
+ * @param forwards - Whether the desired marker comes before (false) or after (true) `startPos`
1251
+ */
1252
+ searchForMarker(startPos: number, markerLabel: string, forwards?: boolean): Marker | undefined;
1253
+ /**
1254
+ * Retrieve text from the SharedString in string format.
1255
+ * @param start - The starting index of the text to retrieve, or 0 if omitted.
1256
+ * @param end - The ending index of the text to retrieve, or the end of the string if omitted
1257
+ * @returns The requested text content as a string.
1258
+ */
1259
+ getText(start?: number, end?: number): string;
1260
+ /**
1261
+ * Adds spaces for markers and handles, so that position calculations account for them.
1262
+ */
1263
+ getTextWithPlaceholders(start?: number, end?: number): string;
1264
+ getTextRangeWithMarkers(start: number, end: number): string;
1265
+ /**
1266
+ * Looks up and returns a `Marker` using its id. Returns `undefined` if there is no marker with the provided
1267
+ * id in this `SharedString`.
1268
+ */
1269
+ getMarkerFromId(id: string): ISegment | undefined;
1270
+ /**
1271
+ * Revert an op
1272
+ */
1273
+ protected rollback(content: any, localOpMetadata: unknown): void;
1274
+ }
1275
+
1276
+ /**
1277
+ * @alpha
1278
+ */
1279
+ export declare class SharedStringFactory implements IChannelFactory {
1280
+ static Type: string;
1281
+ static readonly Attributes: IChannelAttributes;
1282
+ static segmentFromSpec(spec: any): SharedStringSegment;
1283
+ get type(): string;
1284
+ get attributes(): IChannelAttributes;
1285
+ /**
1286
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
1287
+ */
1288
+ load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<SharedString>;
1289
+ create(document: IFluidDataStoreRuntime, id: string): SharedString;
1290
+ }
1291
+
1292
+ /* Excluded from this release type: SharedStringRevertible */
1293
+
1294
+ /**
1295
+ * @alpha
1296
+ */
1297
+ export declare type SharedStringSegment = TextSegment | Marker;
1298
+
1299
+ /**
1300
+ * Defines a side relative to a character in a sequence.
1301
+ *
1302
+ * @remarks See {@link SequencePlace} for additional context on usage.
1303
+ * @alpha
1304
+ */
1305
+ export declare enum Side {
1306
+ Before = 0,
1307
+ After = 1
1308
+ }
1309
+
1310
+ /* Excluded from this release type: SubSequence */
1311
+ export { TextSegment }
1312
+
1313
+ export { TrackingGroup }
1314
+
1315
+ export { }