@fluidframework/sequence 1.4.0-121020 → 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
@@ -2,133 +2,92 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { TypedEventEmitter } from "@fluidframework/common-utils";
6
- import { IEvent } from "@fluidframework/common-definitions";
7
- import { Client, ICombiningOp, IInterval, IntervalConflictResolver, LocalReference, PropertiesManager, PropertySet } from "@fluidframework/merge-tree";
5
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
6
+ import { IEvent } from "@fluidframework/core-interfaces";
7
+ import { Client, PropertySet, LocalReferencePosition } from "@fluidframework/merge-tree";
8
8
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
9
- import { IValueFactory, IValueOpEmitter, IValueOperation, IValueType } from "./defaultMapInterfaces";
10
- export declare enum IntervalType {
11
- Simple = 0,
12
- Nest = 1,
13
- /**
14
- * SlideOnRemove indicates that the ends of the interval will slide if the segment
15
- * they reference is removed and acked.
16
- * See `packages\dds\merge-tree\REFERENCEPOSITIONS.md` for details
17
- * SlideOnRemove is the default interval behavior and does not need to be specified.
18
- */
19
- SlideOnRemove = 2,
20
- /**
21
- * @internal
22
- * A temporary interval, used internally
23
- */
24
- Transient = 4
25
- }
26
- export interface ISerializedInterval {
27
- sequenceNumber: number;
28
- start: number;
29
- end: number;
30
- intervalType: IntervalType;
31
- properties?: PropertySet;
32
- }
9
+ import { IMapMessageLocalMetadata, IValueFactory, IValueOpEmitter, IValueOperation, IValueType, SequenceOptions } from "./defaultMapInterfaces";
10
+ import { CompressedSerializedInterval, IIntervalHelpers, Interval, IntervalOpType, IntervalStickiness, IntervalType, ISerializableInterval, ISerializedInterval, SequenceInterval, SerializedIntervalDelta } from "./intervals";
11
+ import { IEndpointIndex, IIdIntervalIndex, IOverlappingIntervalsIndex, IntervalIndex } from "./intervalIndex";
33
12
  /**
34
- * A size optimization to avoid redundantly storing keys when serializing intervals
35
- * as JSON. Intervals are of the format:
13
+ * Defines a position and side relative to a character in a sequence.
14
+ *
15
+ * For this purpose, sequences look like:
16
+ *
17
+ * `{start} - {character 0} - {character 1} - ... - {character N} - {end}`
18
+ *
19
+ * Each `{value}` in the diagram is a character within a sequence.
20
+ * Each `-` in the above diagram is a position where text could be inserted.
21
+ * Each position between a `{value}` and a `-` is a `SequencePlace`.
22
+ *
23
+ * The special endpoints `{start}` and `{end}` refer to positions outside the
24
+ * contents of the string.
36
25
  *
37
- * [start, end, sequenceNumber, intervalType, properties]
26
+ * This gives us 2N + 2 possible positions to refer to within a string, where N
27
+ * is the number of characters.
28
+ *
29
+ * If the position is specified with a bare number, the side defaults to
30
+ * `Side.Before`.
31
+ *
32
+ * If a SequencePlace is the endpoint of a range (e.g. start/end of an interval or search range),
33
+ * the Side value means it is exclusive if it is nearer to the other position and inclusive if it is farther.
34
+ * E.g. the start of a range with Side.After is exclusive of the character at the position.
35
+ * @alpha
38
36
  */
39
- export declare type CompressedSerializedInterval = [number, number, number, IntervalType, PropertySet];
37
+ export type SequencePlace = number | "start" | "end" | InteriorSequencePlace;
40
38
  /**
41
- * @internal
39
+ * A sequence place that does not refer to the special endpoint segments.
40
+ *
41
+ * See {@link SequencePlace} for additional context.
42
+ * @alpha
43
+ */
44
+ export interface InteriorSequencePlace {
45
+ pos: number;
46
+ side: Side;
47
+ }
48
+ /**
49
+ * Defines a side relative to a character in a sequence.
50
+ *
51
+ * @remarks See {@link SequencePlace} for additional context on usage.
52
+ * @alpha
42
53
  */
54
+ export declare enum Side {
55
+ Before = 0,
56
+ After = 1
57
+ }
43
58
  export interface ISerializedIntervalCollectionV2 {
44
59
  label: string;
45
60
  version: 2;
46
61
  intervals: CompressedSerializedInterval[];
47
62
  }
48
- export interface ISerializableInterval extends IInterval {
49
- properties: PropertySet;
50
- propertyManager: PropertiesManager;
51
- serialize(client: Client): ISerializedInterval;
52
- addProperties(props: PropertySet, collaborating?: boolean, seq?: number): PropertySet | undefined;
53
- getIntervalId(): string | undefined;
54
- }
55
- export interface IIntervalHelpers<TInterval extends ISerializableInterval> {
56
- compareEnds(a: TInterval, b: TInterval): number;
57
- create(label: string, start: number, end: number, client: Client, intervalType?: IntervalType, op?: ISequencedDocumentMessage): TInterval;
58
- }
59
- export declare class Interval implements ISerializableInterval {
60
- start: number;
61
- end: number;
62
- properties: PropertySet;
63
- auxProps: PropertySet[];
64
- propertyManager: PropertiesManager;
65
- constructor(start: number, end: number, props?: PropertySet);
66
- getIntervalId(): string | undefined;
67
- getAdditionalPropertySets(): PropertySet[];
68
- addPropertySet(props: PropertySet): void;
69
- serialize(client: Client): ISerializedInterval;
70
- clone(): Interval;
71
- compare(b: Interval): number;
72
- compareStart(b: Interval): number;
73
- compareEnd(b: Interval): number;
74
- overlaps(b: Interval): boolean;
75
- union(b: Interval): Interval;
76
- getProperties(): PropertySet;
77
- addProperties(newProps: PropertySet, collaborating?: boolean, seq?: number, op?: ICombiningOp): PropertySet | undefined;
78
- modify(label: string, start: number, end: number, op?: ISequencedDocumentMessage): Interval;
79
- private initializeProperties;
80
- }
81
- export declare class SequenceInterval implements ISerializableInterval {
82
- start: LocalReference;
83
- end: LocalReference;
84
- intervalType: IntervalType;
85
- properties: PropertySet;
86
- propertyManager: PropertiesManager;
87
- constructor(start: LocalReference, end: LocalReference, intervalType: IntervalType, props?: PropertySet);
88
- private callbacks?;
89
- /**
90
- * @internal
91
- * Subscribes to position change events on this interval if there are no current listeners.
92
- */
93
- addPositionChangeListeners(beforePositionChange: () => void, afterPositionChange: () => void): void;
94
- /**
95
- * @internal
96
- * Removes the currently subscribed position change listeners.
97
- */
98
- removePositionChangeListeners(): void;
99
- serialize(client: Client): ISerializedInterval;
100
- clone(): SequenceInterval;
101
- compare(b: SequenceInterval): number;
102
- compareStart(b: SequenceInterval): number;
103
- compareEnd(b: SequenceInterval): number;
104
- overlaps(b: SequenceInterval): boolean;
105
- getIntervalId(): string | undefined;
106
- union(b: SequenceInterval): SequenceInterval;
107
- addProperties(newProps: PropertySet, collab?: boolean, seq?: number, op?: ICombiningOp): PropertySet | undefined;
108
- overlapsPos(bstart: number, bend: number): boolean;
109
- modify(label: string, start: number, end: number, op?: ISequencedDocumentMessage): SequenceInterval;
110
- private initializeProperties;
111
- }
112
- export declare function defaultIntervalConflictResolver(a: Interval, b: Interval): Interval;
113
- export declare function createIntervalIndex(conflict?: IntervalConflictResolver<Interval>): LocalIntervalCollection<Interval>;
63
+ export declare function sidesFromStickiness(stickiness: IntervalStickiness): {
64
+ startSide: Side;
65
+ endSide: Side;
66
+ };
67
+ export declare function endpointPosAndSide(start: SequencePlace | undefined, end: SequencePlace | undefined): {
68
+ startSide: Side | undefined;
69
+ endSide: Side | undefined;
70
+ startPos: number | "end" | "start" | undefined;
71
+ endPos: number | "end" | "start" | undefined;
72
+ };
73
+ export declare function computeStickinessFromSide(startPos?: number | "start" | "end" | undefined, startSide?: Side, endPos?: number | "start" | "end" | undefined, endSide?: Side): IntervalStickiness;
74
+ export declare function createIntervalIndex(): LocalIntervalCollection<Interval>;
114
75
  export declare class LocalIntervalCollection<TInterval extends ISerializableInterval> {
115
76
  private readonly client;
116
77
  private readonly label;
117
78
  private readonly helpers;
79
+ private readonly options;
118
80
  /** Callback invoked each time one of the endpoints of an interval slides. */
119
81
  private readonly onPositionChange?;
120
- private readonly intervalTree;
121
- private readonly endIntervalTree;
122
- private readonly intervalIdMap;
123
- private conflictResolver;
124
- private endConflictResolver;
125
82
  private static readonly legacyIdPrefix;
126
- constructor(client: Client, label: string, helpers: IIntervalHelpers<TInterval>,
83
+ readonly overlappingIntervalsIndex: IOverlappingIntervalsIndex<TInterval>;
84
+ readonly idIntervalIndex: IIdIntervalIndex<TInterval>;
85
+ readonly endIntervalIndex: IEndpointIndex<TInterval>;
86
+ private readonly indexes;
87
+ constructor(client: Client, label: string, helpers: IIntervalHelpers<TInterval>, options: Partial<SequenceOptions>,
127
88
  /** Callback invoked each time one of the endpoints of an interval slides. */
128
- onPositionChange?: (interval: TInterval) => void);
129
- addConflictResolver(conflictResolver: IntervalConflictResolver<TInterval>): void;
130
- map(fn: (interval: TInterval) => void): void;
131
- createLegacyId(start: number, end: number): string;
89
+ onPositionChange?: ((interval: TInterval, previousInterval: TInterval) => void) | undefined);
90
+ createLegacyId(start: number | "start" | "end", end: number | "start" | "end"): string;
132
91
  /**
133
92
  * Validates that a serialized interval has the ID property. Creates an ID
134
93
  * if one does not already exist
@@ -137,20 +96,16 @@ export declare class LocalIntervalCollection<TInterval extends ISerializableInte
137
96
  * @returns The interval's existing or newly created id
138
97
  */
139
98
  ensureSerializedId(serializedInterval: ISerializedInterval): string;
140
- mapUntil(fn: (interval: TInterval) => boolean): void;
141
- gatherIterationResults(results: TInterval[], iteratesForward: boolean, start?: number, end?: number): void;
142
- findOverlappingIntervals(startPosition: number, endPosition: number): TInterval[];
143
- previousInterval(pos: number): TInterval;
144
- nextInterval(pos: number): TInterval;
145
- removeInterval(startPosition: number, endPosition: number): TInterval;
146
- private removeIntervalFromIndex;
99
+ private removeIntervalFromIndexes;
100
+ appendIndex(index: IntervalIndex<TInterval>): void;
101
+ removeIndex(index: IntervalIndex<TInterval>): boolean;
147
102
  removeExistingInterval(interval: TInterval): void;
148
- createInterval(start: number, end: number, intervalType: IntervalType, op?: ISequencedDocumentMessage): TInterval;
149
- addInterval(start: number, end: number, intervalType: IntervalType, props?: PropertySet, op?: ISequencedDocumentMessage): TInterval;
150
- private addIntervalToIndex;
103
+ createInterval(start: SequencePlace, end: SequencePlace, intervalType: IntervalType, op?: ISequencedDocumentMessage): TInterval;
104
+ addInterval(start: SequencePlace, end: SequencePlace, intervalType: IntervalType, props?: PropertySet, op?: ISequencedDocumentMessage): TInterval;
105
+ private linkEndpointsToInterval;
106
+ private addIntervalToIndexes;
151
107
  add(interval: TInterval): void;
152
- getIntervalById(id: string): TInterval;
153
- changeInterval(interval: TInterval, start: number, end: number, op?: ISequencedDocumentMessage): TInterval;
108
+ changeInterval(interval: TInterval, start: SequencePlace | undefined, end: SequencePlace | undefined, op?: ISequencedDocumentMessage, localSeq?: number): TInterval | undefined;
154
109
  serialize(): ISerializedIntervalCollectionV2;
155
110
  private addIntervalListeners;
156
111
  private removeIntervalListeners;
@@ -159,7 +114,7 @@ export declare class SequenceIntervalCollectionValueType implements IValueType<I
159
114
  static Name: string;
160
115
  get name(): string;
161
116
  get factory(): IValueFactory<IntervalCollection<SequenceInterval>>;
162
- get ops(): Map<string, IValueOperation<IntervalCollection<SequenceInterval>>>;
117
+ get ops(): Map<IntervalOpType, IValueOperation<IntervalCollection<SequenceInterval>>>;
163
118
  private static readonly _factory;
164
119
  private static readonly _ops;
165
120
  }
@@ -167,104 +122,448 @@ export declare class IntervalCollectionValueType implements IValueType<IntervalC
167
122
  static Name: string;
168
123
  get name(): string;
169
124
  get factory(): IValueFactory<IntervalCollection<Interval>>;
170
- get ops(): Map<string, IValueOperation<IntervalCollection<Interval>>>;
125
+ get ops(): Map<IntervalOpType, IValueOperation<IntervalCollection<Interval>>>;
171
126
  private static readonly _factory;
172
127
  private static readonly _ops;
173
128
  }
174
- export declare type DeserializeCallback = (properties: PropertySet) => void;
175
- export declare class IntervalCollectionIterator<TInterval extends ISerializableInterval> {
129
+ export declare function makeOpsMap<T extends ISerializableInterval>(): Map<IntervalOpType, IValueOperation<IntervalCollection<T>>>;
130
+ /**
131
+ * @alpha
132
+ */
133
+ export type DeserializeCallback = (properties: PropertySet) => void;
134
+ declare class IntervalCollectionIterator<TInterval extends ISerializableInterval> implements Iterator<TInterval> {
176
135
  private readonly results;
177
136
  private index;
178
137
  constructor(collection: IntervalCollection<TInterval>, iteratesForward?: boolean, start?: number, end?: number);
179
- next(): {
180
- value: TInterval;
181
- done: boolean;
182
- };
138
+ next(): IteratorResult<TInterval>;
183
139
  }
140
+ /**
141
+ * Change events emitted by `IntervalCollection`s
142
+ * @alpha
143
+ */
184
144
  export interface IIntervalCollectionEvent<TInterval extends ISerializableInterval> extends IEvent {
185
145
  /**
186
- * This event is invoked whenever the properties or endpoints of an interval may have changed.
146
+ * This event is invoked whenever the endpoints of an interval may have changed.
187
147
  * This can happen on:
188
- * - endpoint modification (local or remote)
189
- * - ack of an endpoint modification
190
- * - property change (local or remote)
191
- * - position change due to segment sliding (will always appear as a local change)
148
+ * - local endpoint modification
149
+ * - ack of a remote endpoint modification
150
+ * - position change due to segment sliding (slides due to mergeTree segment deletion will always appear local)
192
151
  * The `interval` argument reflects the new values.
152
+ * `previousInterval` contains transient `ReferencePosition`s at the same location as the interval's original
153
+ * endpoints. These references should be used for position information only.
154
+ * `local` reflects whether the change originated locally.
155
+ * `op` is defined if and only if the server has acked this change.
156
+ * `slide` is true if the change is due to sliding on removal of position
157
+ */
158
+ (event: "changeInterval", listener: (interval: TInterval, previousInterval: TInterval, local: boolean, op: ISequencedDocumentMessage | undefined, slide: boolean) => void): void;
159
+ /**
160
+ * This event is invoked whenever an interval is added or removed from the collection.
161
+ * `local` reflects whether the change originated locally.
162
+ * `op` is defined if and only if the server has acked this change.
163
+ */
164
+ (event: "addInterval" | "deleteInterval", listener: (interval: TInterval, local: boolean, op: ISequencedDocumentMessage | undefined) => void): void;
165
+ /**
166
+ * This event is invoked whenever an interval's properties have changed.
167
+ * `interval` reflects the state of the updated properties.
168
+ * `propertyDeltas` is a map-like whose keys contain all values that were changed, and whose
169
+ * values contain all previous values of the property set.
170
+ * This object can be used directly in a call to `changeProperties` to revert the property change if desired.
171
+ * `local` reflects whether the change originated locally.
172
+ * `op` is defined if and only if the server has acked this change.
173
+ */
174
+ (event: "propertyChanged", listener: (interval: TInterval, propertyDeltas: PropertySet, local: boolean, op: ISequencedDocumentMessage | undefined) => void): void;
175
+ }
176
+ /**
177
+ * Collection of intervals that supports addition, modification, removal, and efficient spatial querying.
178
+ * Changes to this collection will be incur updates on collaborating clients (i.e. they are not local-only).
179
+ * @alpha
180
+ */
181
+ export interface IIntervalCollection<TInterval extends ISerializableInterval> extends TypedEventEmitter<IIntervalCollectionEvent<TInterval>> {
182
+ readonly attached: boolean;
183
+ /**
184
+ * Attaches an index to this collection.
185
+ * All intervals which are part of this collection will be added to the index, and the index will automatically
186
+ * be updated when this collection updates due to local or remote changes.
187
+ *
188
+ * @remarks After attaching an index to an interval collection, applications should typically store this
189
+ * index somewhere in their in-memory data model for future reference and querying.
190
+ */
191
+ attachIndex(index: IntervalIndex<TInterval>): void;
192
+ /**
193
+ * Detaches an index from this collection.
194
+ * All intervals which are part of this collection will be removed from the index, and updates to this collection
195
+ * due to local or remote changes will no longer incur updates to the index.
196
+ *
197
+ * @returns `false` if the target index cannot be found in the indexes, otherwise remove all intervals in the index and return `true`.
198
+ */
199
+ detachIndex(index: IntervalIndex<TInterval>): boolean;
200
+ /**
201
+ * @returns the interval in this collection that has the provided `id`.
202
+ * If no interval in the collection has this `id`, returns `undefined`.
203
+ */
204
+ getIntervalById(id: string): TInterval | undefined;
205
+ /**
206
+ * Creates a new interval and add it to the collection.
207
+ * @deprecated call IntervalCollection.add without specifying an intervalType
208
+ * @param start - interval start position (inclusive)
209
+ * @param end - interval end position (exclusive)
210
+ * @param intervalType - type of the interval. All intervals are SlideOnRemove. Intervals may not be Transient.
211
+ * @param props - properties of the interval
212
+ * @returns The created interval
213
+ * @remarks See documentation on {@link SequenceInterval} for comments on
214
+ * interval endpoint semantics: there are subtleties with how the current
215
+ * half-open behavior is represented.
216
+ *
217
+ * Note that intervals may behave unexpectedly if the entire contents
218
+ * of the string are deleted. In this case, it is possible for one endpoint
219
+ * of the interval to become detached, while the other remains on the string.
220
+ *
221
+ * By adjusting the `side` and `pos` values of the `start` and `end` parameters,
222
+ * it is possible to control whether the interval expands to include content
223
+ * inserted at its start or end.
224
+ *
225
+ * See {@link SequencePlace} for more details on the model.
226
+ *
227
+ * @example
228
+ *
229
+ * Given the string "ABCD":
230
+ *
231
+ *```typescript
232
+ * // Refers to "BC". If any content is inserted before B or after C, this
233
+ * // interval will include that content
234
+ * //
235
+ * // Picture:
236
+ * // \{start\} - A[- B - C -]D - \{end\}
237
+ * // \{start\} - A - B - C - D - \{end\}
238
+ * collection.add(\{ pos: 0, side: Side.After \}, \{ pos: 3, side: Side.Before \}, IntervalType.SlideOnRemove);
239
+ * // Equivalent to specifying the same positions and Side.Before.
240
+ * // Refers to "ABC". Content inserted after C will be included in the
241
+ * // interval, but content inserted before A will not.
242
+ * // \{start\} -[A - B - C -]D - \{end\}
243
+ * // \{start\} - A - B - C - D - \{end\}
244
+ * collection.add(0, 3, IntervalType.SlideOnRemove);
245
+ *```
246
+ *
247
+ * In the case of the first example, if text is deleted,
248
+ *
249
+ * ```typescript
250
+ * // Delete the character "B"
251
+ * string.removeRange(1, 2);
252
+ * ```
253
+ *
254
+ * The start point of the interval will slide to the position immediately
255
+ * before "C", and the same will be true.
256
+ *
257
+ * ```
258
+ * \{start\} - A[- C -]D - \{end\}
259
+ * ```
260
+ *
261
+ * In this case, text inserted immediately before "C" would be included in
262
+ * the interval.
263
+ *
264
+ * ```typescript
265
+ * string.insertText(1, "EFG");
266
+ * ```
267
+ *
268
+ * With the string now being,
269
+ *
270
+ * ```
271
+ * \{start\} - A[- E - F - G - C -]D - \{end\}
272
+ * ```
273
+ *
274
+ * @privateRemarks TODO: ADO:5205 the above comment regarding behavior in
275
+ * the case that the entire interval has been deleted should be resolved at
276
+ * the same time as this ticket
277
+ */
278
+ add(start: SequencePlace, end: SequencePlace, intervalType: IntervalType, props?: PropertySet): TInterval;
279
+ /**
280
+ * Creates a new interval and add it to the collection.
281
+ * @param start - interval start position (inclusive)
282
+ * @param end - interval end position (exclusive)
283
+ * @param props - properties of the interval
284
+ * @returns - the created interval
285
+ * @remarks - See documentation on {@link SequenceInterval} for comments on interval endpoint semantics: there are subtleties
286
+ * with how the current half-open behavior is represented.
287
+ */
288
+ add({ start, end, props, }: {
289
+ start: SequencePlace;
290
+ end: SequencePlace;
291
+ props?: PropertySet;
292
+ }): TInterval;
293
+ /**
294
+ * Removes an interval from the collection.
295
+ * @param id - Id of the interval to remove
296
+ * @returns the removed interval
297
+ */
298
+ removeIntervalById(id: string): TInterval | undefined;
299
+ /**
300
+ * Changes the properties on an existing interval.
301
+ * @deprecated - call change with the id and and object containing the new properties
302
+ * @param id - Id of the interval whose properties should be changed
303
+ * @param props - Property set to apply to the interval. Shallow merging is used between any existing properties
304
+ * and `prop`, i.e. the interval will end up with a property object equivalent to `{ ...oldProps, ...props }`.
305
+ */
306
+ changeProperties(id: string, props: PropertySet): void;
307
+ /**
308
+ * Changes the endpoints of an existing interval.
309
+ * @deprecated - call change with the start and end parameters encapsulated in an object
310
+ * @param id - Id of the interval to change
311
+ * @param start - New start value. To leave the endpoint unchanged, pass the current value.
312
+ * @param end - New end value. To leave the endpoint unchanged, pass the current value.
313
+ * @returns the interval that was changed, if it existed in the collection.
314
+ */
315
+ change(id: string, start: SequencePlace, end: SequencePlace): TInterval | undefined;
316
+ /**
317
+ * Changes the endpoints, properties, or both of an existing interval.
318
+ * @param id - Id of the Interval to change
319
+ * @returns the interval that was changed, if it existed in the collection.
320
+ * Pass the desired new start position, end position, and/or properties in an object. Start and end positions must be changed
321
+ * simultaneously - they must either both be specified or both undefined. To only change the properties, leave both endpoints
322
+ * undefined. To only change the endpoints, leave the properties undefined.
323
+ */
324
+ change(id: string, { start, end, props }: {
325
+ start?: SequencePlace;
326
+ end?: SequencePlace;
327
+ props?: PropertySet;
328
+ }): TInterval | undefined;
329
+ attachDeserializer(onDeserialize: DeserializeCallback): void;
330
+ /**
331
+ * @returns an iterator over all intervals in this collection.
332
+ */
333
+ [Symbol.iterator](): Iterator<TInterval>;
334
+ /**
335
+ * @returns a forward iterator over all intervals in this collection with start point equal to `startPosition`.
336
+ */
337
+ CreateForwardIteratorWithStartPosition(startPosition: number): Iterator<TInterval>;
338
+ /**
339
+ * @returns a backward iterator over all intervals in this collection with start point equal to `startPosition`.
340
+ */
341
+ CreateBackwardIteratorWithStartPosition(startPosition: number): Iterator<TInterval>;
342
+ /**
343
+ * @returns a forward iterator over all intervals in this collection with end point equal to `endPosition`.
344
+ */
345
+ CreateForwardIteratorWithEndPosition(endPosition: number): Iterator<TInterval>;
346
+ /**
347
+ * @returns a backward iterator over all intervals in this collection with end point equal to `endPosition`.
348
+ */
349
+ CreateBackwardIteratorWithEndPosition(endPosition: number): Iterator<TInterval>;
350
+ /**
351
+ * Gathers iteration results that optionally match a start/end criteria into the provided array.
352
+ * @param results - Array to gather the results into. In lieu of a return value, this array will be populated with
353
+ * intervals matching the query upon edit.
354
+ * @param iteratesForward - whether or not iteration should be in the forward direction
355
+ * @param start - If provided, only match intervals whose start point is equal to `start`.
356
+ * @param end - If provided, only match intervals whose end point is equal to `end`.
357
+ */
358
+ gatherIterationResults(results: TInterval[], iteratesForward: boolean, start?: number, end?: number): void;
359
+ /**
360
+ * @deprecated - Users must manually attach the corresponding interval index to utilize this functionality, for instance:
361
+ *
362
+ * ```typescript
363
+ * const overlappingIntervalsIndex = createOverlappingIntervalsIndex(sharedString);
364
+ * collection.attachIndex(overlappingIntervalsIndex)
365
+ * const result = overlappingIntervalsIndex.findOverlappingIntervals(start, end);
366
+ * ```
367
+ *
368
+ * @returns an array of all intervals in this collection that overlap with the interval
369
+ * `[startPosition, endPosition]`.
370
+ */
371
+ findOverlappingIntervals(startPosition: number, endPosition: number): TInterval[];
372
+ /**
373
+ * Applies a function to each interval in this collection.
374
+ */
375
+ map(fn: (interval: TInterval) => void): void;
376
+ /**
377
+ * @deprecated - due to the forthcoming change where the endpointIndex will no longer be
378
+ * automatically added to the collection. Users are advised to independently attach the
379
+ * index to the collection and utilize the API accordingly, for instance:
380
+ * ```typescript
381
+ * const endpointIndex = createEndpointIndex(sharedString);
382
+ * collection.attachIndex(endpointIndex);
383
+ * const result1 = endpointIndex.previousInterval(pos);
384
+ * ```
385
+ * If an index is used repeatedly, applications should generally attach it once and store it in memory.
386
+ */
387
+ previousInterval(pos: number): TInterval | undefined;
388
+ /**
389
+ * @deprecated - due to the forthcoming change where the endpointIndex will no longer be
390
+ * automatically added to the collection. Users are advised to independently attach the
391
+ * index to the collection and utilize the API accordingly, for instance:
392
+ * ```typescript
393
+ * const endpointIndex = createEndpointIndex(sharedString);
394
+ * collection.attachIndex(endpointIndex);
395
+ * const result2 = endpointIndex.nextInterval(pos);
396
+ * ```
193
397
  */
194
- (event: "changeInterval", listener: (interval: TInterval, local: boolean, op: ISequencedDocumentMessage | undefined) => void): any;
195
- (event: "addInterval" | "deleteInterval", listener: (interval: TInterval, local: boolean, op: ISequencedDocumentMessage) => void): any;
196
- (event: "propertyChanged", listener: (interval: TInterval, propertyArgs: PropertySet) => void): any;
398
+ nextInterval(pos: number): TInterval | undefined;
197
399
  }
198
- export declare class IntervalCollection<TInterval extends ISerializableInterval> extends TypedEventEmitter<IIntervalCollectionEvent<TInterval>> {
400
+ /**
401
+ * {@inheritdoc IIntervalCollection}
402
+ */
403
+ export declare class IntervalCollection<TInterval extends ISerializableInterval> extends TypedEventEmitter<IIntervalCollectionEvent<TInterval>> implements IIntervalCollection<TInterval> {
199
404
  private readonly helpers;
200
405
  private readonly requiresClient;
201
406
  private readonly emitter;
407
+ private readonly options;
202
408
  private savedSerializedIntervals?;
203
409
  private localCollection;
204
410
  private onDeserialize;
205
411
  private client;
412
+ private readonly localSeqToSerializedInterval;
413
+ private readonly localSeqToRebasedInterval;
206
414
  private readonly pendingChangesStart;
207
415
  private readonly pendingChangesEnd;
208
416
  get attached(): boolean;
209
417
  /** @internal */
210
- constructor(helpers: IIntervalHelpers<TInterval>, requiresClient: boolean, emitter: IValueOpEmitter, serializedIntervals: ISerializedInterval[] | ISerializedIntervalCollectionV2);
418
+ constructor(helpers: IIntervalHelpers<TInterval>, requiresClient: boolean, emitter: IValueOpEmitter, serializedIntervals: ISerializedInterval[] | ISerializedIntervalCollectionV2, options?: Partial<SequenceOptions>);
419
+ /**
420
+ * {@inheritdoc IIntervalCollection.attachIndex}
421
+ */
422
+ attachIndex(index: IntervalIndex<TInterval>): void;
423
+ /**
424
+ * {@inheritdoc IIntervalCollection.detachIndex}
425
+ */
426
+ detachIndex(index: IntervalIndex<TInterval>): boolean;
427
+ private rebasePositionWithSegmentSlide;
428
+ private computeRebasedPositions;
429
+ /** @internal */
211
430
  attachGraph(client: Client, label: string): void;
212
431
  /**
213
432
  * Gets the next local sequence number, modifying this client's collab window in doing so.
214
433
  */
215
434
  private getNextLocalSeq;
216
- getIntervalById(id: string): TInterval;
435
+ private emitChange;
217
436
  /**
218
- * Create a new interval and add it to the collection
219
- * @param start - interval start position
220
- * @param end - interval end position
221
- * @param intervalType - type of the interval. All intervals are SlideOnRemove. Intervals may not be Transient.
222
- * @param props - properties of the interval
223
- * @returns - the created interval
437
+ * {@inheritdoc IIntervalCollection.getIntervalById}
438
+ */
439
+ getIntervalById(id: string): TInterval | undefined;
440
+ private assertStickinessEnabled;
441
+ /**
442
+ * {@inheritdoc IIntervalCollection.add}
443
+ * @deprecated call IntervalCollection.add without specifying an intervalType
224
444
  */
225
- add(start: number, end: number, intervalType: IntervalType, props?: PropertySet): TInterval;
445
+ add(start: SequencePlace, end: SequencePlace, intervalType: IntervalType, props?: PropertySet): TInterval;
446
+ add({ start, end, props, }: {
447
+ start: SequencePlace;
448
+ end: SequencePlace;
449
+ props?: PropertySet;
450
+ }): TInterval;
226
451
  private deleteExistingInterval;
227
- removeIntervalById(id: string): TInterval;
452
+ /**
453
+ * {@inheritdoc IIntervalCollection.removeIntervalById}
454
+ */
455
+ removeIntervalById(id: string): TInterval | undefined;
456
+ /**
457
+ * {@inheritdoc IIntervalCollection.changeProperties}
458
+ * @deprecated - call change with the id and an object containing the new props values
459
+ */
228
460
  changeProperties(id: string, props: PropertySet): void;
229
- change(id: string, start?: number, end?: number): TInterval | undefined;
461
+ /**
462
+ * {@inheritdoc IIntervalCollection.change}
463
+ * @deprecated - call change with the id and an object containing the new start, end, and/or props values
464
+ */
465
+ change(id: string, start: SequencePlace, end: SequencePlace): TInterval | undefined;
466
+ /**
467
+ * {@inheritdoc IIntervalCollection.change}
468
+ */
469
+ change(id: string, { start, end, props }: {
470
+ start?: SequencePlace;
471
+ end?: SequencePlace;
472
+ props?: PropertySet;
473
+ }): TInterval | undefined;
474
+ private get isCollaborating();
230
475
  private addPendingChange;
231
476
  private addPendingChangeHelper;
232
477
  private removePendingChange;
233
478
  private removePendingChangeHelper;
234
479
  private hasPendingChangeStart;
235
480
  private hasPendingChangeEnd;
236
- /** @deprecated - use ackChange */
237
- changeInterval(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
238
481
  /** @internal */
239
- ackChange(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
240
- addConflictResolver(conflictResolver: IntervalConflictResolver<TInterval>): void;
482
+ ackChange(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage, localOpMetadata: IMapMessageLocalMetadata | undefined): void;
483
+ /**
484
+ * {@inheritdoc IIntervalCollection.attachDeserializer}
485
+ */
241
486
  attachDeserializer(onDeserialize: DeserializeCallback): void;
242
- /** @internal */
243
- rebaseLocalInterval(opName: string, serializedInterval: ISerializedInterval, localSeq: number): ISerializedInterval;
487
+ /**
488
+ * Returns new interval after rebasing. If undefined, the interval was
489
+ * deleted as a result of rebasing. This can occur if the interval applies
490
+ * to a range that no longer exists, and the interval was unable to slide.
491
+ *
492
+ * @internal
493
+ */
494
+ rebaseLocalInterval(opName: string, serializedInterval: SerializedIntervalDelta, localSeq: number): SerializedIntervalDelta | undefined;
244
495
  private getSlideToSegment;
245
- private setSlideOnRemove;
246
496
  private ackInterval;
247
- /** @deprecated - use ackAdd */
248
- addInternal(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): TInterval;
249
497
  /** @internal */
250
- ackAdd(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): TInterval;
251
- /** @deprecated - use ackDelete */
252
- deleteInterval(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
498
+ ackAdd(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage, localOpMetadata: IMapMessageLocalMetadata | undefined): TInterval | undefined;
253
499
  /** @internal */
254
500
  ackDelete(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
255
501
  /**
256
502
  * @internal
257
503
  */
258
504
  serializeInternal(): ISerializedIntervalCollectionV2;
505
+ /**
506
+ * @returns an iterator over all intervals in this collection.
507
+ */
259
508
  [Symbol.iterator](): IntervalCollectionIterator<TInterval>;
509
+ /**
510
+ * {@inheritdoc IIntervalCollection.CreateForwardIteratorWithStartPosition}
511
+ */
260
512
  CreateForwardIteratorWithStartPosition(startPosition: number): IntervalCollectionIterator<TInterval>;
513
+ /**
514
+ * {@inheritdoc IIntervalCollection.CreateBackwardIteratorWithStartPosition}
515
+ */
261
516
  CreateBackwardIteratorWithStartPosition(startPosition: number): IntervalCollectionIterator<TInterval>;
517
+ /**
518
+ * {@inheritdoc IIntervalCollection.CreateForwardIteratorWithEndPosition}
519
+ */
262
520
  CreateForwardIteratorWithEndPosition(endPosition: number): IntervalCollectionIterator<TInterval>;
521
+ /**
522
+ * {@inheritdoc IIntervalCollection.CreateBackwardIteratorWithEndPosition}
523
+ */
263
524
  CreateBackwardIteratorWithEndPosition(endPosition: number): IntervalCollectionIterator<TInterval>;
525
+ /**
526
+ * {@inheritdoc IIntervalCollection.gatherIterationResults}
527
+ */
264
528
  gatherIterationResults(results: TInterval[], iteratesForward: boolean, start?: number, end?: number): void;
529
+ /**
530
+ * {@inheritdoc IIntervalCollection.findOverlappingIntervals}
531
+ */
265
532
  findOverlappingIntervals(startPosition: number, endPosition: number): TInterval[];
533
+ /**
534
+ * {@inheritdoc IIntervalCollection.map}
535
+ */
266
536
  map(fn: (interval: TInterval) => void): void;
267
- previousInterval(pos: number): TInterval;
268
- nextInterval(pos: number): TInterval;
537
+ /**
538
+ * {@inheritdoc IIntervalCollection.previousInterval}
539
+ */
540
+ previousInterval(pos: number): TInterval | undefined;
541
+ /**
542
+ * {@inheritdoc IIntervalCollection.nextInterval}
543
+ */
544
+ nextInterval(pos: number): TInterval | undefined;
269
545
  }
546
+ /**
547
+ * Information that identifies an interval within a `Sequence`.
548
+ * @internal
549
+ */
550
+ export interface IntervalLocator {
551
+ /**
552
+ * Label for the collection the interval is a part of
553
+ */
554
+ label: string;
555
+ /**
556
+ * Interval within that collection
557
+ */
558
+ interval: SequenceInterval;
559
+ }
560
+ /**
561
+ * Returns an object that can be used to find the interval a given LocalReferencePosition belongs to.
562
+ * @returns undefined if the reference position is not the endpoint of any interval (e.g. it was created
563
+ * on the merge tree directly by app code), otherwise an {@link IntervalLocator} for the interval this
564
+ * endpoint is a part of.
565
+ * @internal
566
+ */
567
+ export declare function intervalLocatorFromEndpoint(potentialEndpoint: LocalReferencePosition): IntervalLocator | undefined;
568
+ export {};
270
569
  //# sourceMappingURL=intervalCollection.d.ts.map