@fluidframework/merge-tree 2.21.0 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/.eslintrc.cjs +0 -1
  2. package/CHANGELOG.md +4 -0
  3. package/README.md +1 -0
  4. package/dist/attributionCollection.js +5 -7
  5. package/dist/attributionCollection.js.map +1 -1
  6. package/dist/localReference.js +6 -8
  7. package/dist/localReference.js.map +1 -1
  8. package/dist/mergeTree.d.ts.map +1 -1
  9. package/dist/mergeTree.js +69 -34
  10. package/dist/mergeTree.js.map +1 -1
  11. package/dist/mergeTreeNodes.d.ts +15 -4
  12. package/dist/mergeTreeNodes.d.ts.map +1 -1
  13. package/dist/mergeTreeNodes.js +1 -1
  14. package/dist/mergeTreeNodes.js.map +1 -1
  15. package/dist/partialLengths.d.ts +114 -144
  16. package/dist/partialLengths.d.ts.map +1 -1
  17. package/dist/partialLengths.js +431 -525
  18. package/dist/partialLengths.js.map +1 -1
  19. package/dist/perspective.d.ts +10 -1
  20. package/dist/perspective.d.ts.map +1 -1
  21. package/dist/perspective.js +10 -1
  22. package/dist/perspective.js.map +1 -1
  23. package/dist/properties.d.ts.map +1 -1
  24. package/dist/properties.js +2 -3
  25. package/dist/properties.js.map +1 -1
  26. package/dist/revertibles.js +3 -3
  27. package/dist/revertibles.js.map +1 -1
  28. package/dist/segmentInfos.d.ts +3 -0
  29. package/dist/segmentInfos.d.ts.map +1 -1
  30. package/dist/segmentInfos.js.map +1 -1
  31. package/dist/segmentPropertiesManager.js +3 -3
  32. package/dist/segmentPropertiesManager.js.map +1 -1
  33. package/dist/snapshotLoader.js +2 -2
  34. package/dist/snapshotLoader.js.map +1 -1
  35. package/dist/sortedSegmentSet.d.ts +5 -3
  36. package/dist/sortedSegmentSet.d.ts.map +1 -1
  37. package/dist/sortedSegmentSet.js +33 -41
  38. package/dist/sortedSegmentSet.js.map +1 -1
  39. package/dist/sortedSet.d.ts +20 -3
  40. package/dist/sortedSet.d.ts.map +1 -1
  41. package/dist/sortedSet.js +23 -14
  42. package/dist/sortedSet.js.map +1 -1
  43. package/dist/test/Snapshot.perf.spec.js +1 -1
  44. package/dist/test/Snapshot.perf.spec.js.map +1 -1
  45. package/dist/test/client.applyMsg.spec.js +20 -0
  46. package/dist/test/client.applyMsg.spec.js.map +1 -1
  47. package/dist/test/client.applyStashedOpFarm.spec.js +1 -1
  48. package/dist/test/client.applyStashedOpFarm.spec.js.map +1 -1
  49. package/dist/test/client.attributionFarm.spec.js +1 -1
  50. package/dist/test/client.attributionFarm.spec.js.map +1 -1
  51. package/dist/test/client.localReference.spec.js +48 -0
  52. package/dist/test/client.localReference.spec.js.map +1 -1
  53. package/dist/test/client.obliterateFarm.spec.d.ts.map +1 -1
  54. package/dist/test/client.obliterateFarm.spec.js +12 -3
  55. package/dist/test/client.obliterateFarm.spec.js.map +1 -1
  56. package/dist/test/client.reconnectFarm.spec.js +1 -1
  57. package/dist/test/client.reconnectFarm.spec.js.map +1 -1
  58. package/dist/test/client.searchForMarker.spec.js +2 -2
  59. package/dist/test/client.searchForMarker.spec.js.map +1 -1
  60. package/dist/test/mergeTreeOperationRunner.d.ts +1 -1
  61. package/dist/test/mergeTreeOperationRunner.d.ts.map +1 -1
  62. package/dist/test/mergeTreeOperationRunner.js +23 -11
  63. package/dist/test/mergeTreeOperationRunner.js.map +1 -1
  64. package/dist/test/obliterate.concurrent.spec.js +45 -1
  65. package/dist/test/obliterate.concurrent.spec.js.map +1 -1
  66. package/dist/test/obliterate.rangeExpansion.spec.js +81 -5
  67. package/dist/test/obliterate.rangeExpansion.spec.js.map +1 -1
  68. package/dist/test/obliterate.spec.js +3 -3
  69. package/dist/test/obliterate.spec.js.map +1 -1
  70. package/dist/test/obliterateOperations.d.ts.map +1 -1
  71. package/dist/test/obliterateOperations.js +29 -18
  72. package/dist/test/obliterateOperations.js.map +1 -1
  73. package/dist/test/partialSyncHelper.d.ts +42 -0
  74. package/dist/test/partialSyncHelper.d.ts.map +1 -0
  75. package/dist/test/partialSyncHelper.js +96 -0
  76. package/dist/test/partialSyncHelper.js.map +1 -0
  77. package/dist/test/revertibles.spec.js +3 -3
  78. package/dist/test/revertibles.spec.js.map +1 -1
  79. package/dist/test/sortedSegmentSet.spec.js +21 -0
  80. package/dist/test/sortedSegmentSet.spec.js.map +1 -1
  81. package/dist/test/testClient.d.ts +1 -1
  82. package/dist/test/testClient.d.ts.map +1 -1
  83. package/dist/test/testClient.js +1 -0
  84. package/dist/test/testClient.js.map +1 -1
  85. package/dist/test/testUtils.js +2 -2
  86. package/dist/test/testUtils.js.map +1 -1
  87. package/lib/attributionCollection.js +5 -7
  88. package/lib/attributionCollection.js.map +1 -1
  89. package/lib/localReference.js +6 -8
  90. package/lib/localReference.js.map +1 -1
  91. package/lib/mergeTree.d.ts.map +1 -1
  92. package/lib/mergeTree.js +69 -34
  93. package/lib/mergeTree.js.map +1 -1
  94. package/lib/mergeTreeNodes.d.ts +15 -4
  95. package/lib/mergeTreeNodes.d.ts.map +1 -1
  96. package/lib/mergeTreeNodes.js +1 -1
  97. package/lib/mergeTreeNodes.js.map +1 -1
  98. package/lib/partialLengths.d.ts +114 -144
  99. package/lib/partialLengths.d.ts.map +1 -1
  100. package/lib/partialLengths.js +432 -525
  101. package/lib/partialLengths.js.map +1 -1
  102. package/lib/perspective.d.ts +10 -1
  103. package/lib/perspective.d.ts.map +1 -1
  104. package/lib/perspective.js +10 -1
  105. package/lib/perspective.js.map +1 -1
  106. package/lib/properties.d.ts.map +1 -1
  107. package/lib/properties.js +2 -3
  108. package/lib/properties.js.map +1 -1
  109. package/lib/revertibles.js +3 -3
  110. package/lib/revertibles.js.map +1 -1
  111. package/lib/segmentInfos.d.ts +3 -0
  112. package/lib/segmentInfos.d.ts.map +1 -1
  113. package/lib/segmentInfos.js.map +1 -1
  114. package/lib/segmentPropertiesManager.js +3 -3
  115. package/lib/segmentPropertiesManager.js.map +1 -1
  116. package/lib/snapshotLoader.js +2 -2
  117. package/lib/snapshotLoader.js.map +1 -1
  118. package/lib/sortedSegmentSet.d.ts +5 -3
  119. package/lib/sortedSegmentSet.d.ts.map +1 -1
  120. package/lib/sortedSegmentSet.js +33 -41
  121. package/lib/sortedSegmentSet.js.map +1 -1
  122. package/lib/sortedSet.d.ts +20 -3
  123. package/lib/sortedSet.d.ts.map +1 -1
  124. package/lib/sortedSet.js +23 -14
  125. package/lib/sortedSet.js.map +1 -1
  126. package/lib/test/Snapshot.perf.spec.js +1 -1
  127. package/lib/test/Snapshot.perf.spec.js.map +1 -1
  128. package/lib/test/client.applyMsg.spec.js +20 -0
  129. package/lib/test/client.applyMsg.spec.js.map +1 -1
  130. package/lib/test/client.applyStashedOpFarm.spec.js +1 -1
  131. package/lib/test/client.applyStashedOpFarm.spec.js.map +1 -1
  132. package/lib/test/client.attributionFarm.spec.js +1 -1
  133. package/lib/test/client.attributionFarm.spec.js.map +1 -1
  134. package/lib/test/client.localReference.spec.js +48 -0
  135. package/lib/test/client.localReference.spec.js.map +1 -1
  136. package/lib/test/client.obliterateFarm.spec.d.ts.map +1 -1
  137. package/lib/test/client.obliterateFarm.spec.js +16 -5
  138. package/lib/test/client.obliterateFarm.spec.js.map +1 -1
  139. package/lib/test/client.reconnectFarm.spec.js +1 -1
  140. package/lib/test/client.reconnectFarm.spec.js.map +1 -1
  141. package/lib/test/client.searchForMarker.spec.js +2 -2
  142. package/lib/test/client.searchForMarker.spec.js.map +1 -1
  143. package/lib/test/mergeTreeOperationRunner.d.ts +1 -1
  144. package/lib/test/mergeTreeOperationRunner.d.ts.map +1 -1
  145. package/lib/test/mergeTreeOperationRunner.js +23 -11
  146. package/lib/test/mergeTreeOperationRunner.js.map +1 -1
  147. package/lib/test/obliterate.concurrent.spec.js +45 -1
  148. package/lib/test/obliterate.concurrent.spec.js.map +1 -1
  149. package/lib/test/obliterate.rangeExpansion.spec.js +81 -5
  150. package/lib/test/obliterate.rangeExpansion.spec.js.map +1 -1
  151. package/lib/test/obliterate.spec.js +3 -3
  152. package/lib/test/obliterate.spec.js.map +1 -1
  153. package/lib/test/obliterateOperations.d.ts.map +1 -1
  154. package/lib/test/obliterateOperations.js +29 -18
  155. package/lib/test/obliterateOperations.js.map +1 -1
  156. package/lib/test/partialSyncHelper.d.ts +42 -0
  157. package/lib/test/partialSyncHelper.d.ts.map +1 -0
  158. package/lib/test/partialSyncHelper.js +92 -0
  159. package/lib/test/partialSyncHelper.js.map +1 -0
  160. package/lib/test/revertibles.spec.js +3 -3
  161. package/lib/test/revertibles.spec.js.map +1 -1
  162. package/lib/test/sortedSegmentSet.spec.js +21 -0
  163. package/lib/test/sortedSegmentSet.spec.js.map +1 -1
  164. package/lib/test/testClient.d.ts +1 -1
  165. package/lib/test/testClient.d.ts.map +1 -1
  166. package/lib/test/testClient.js +1 -0
  167. package/lib/test/testClient.js.map +1 -1
  168. package/lib/test/testUtils.js +2 -2
  169. package/lib/test/testUtils.js.map +1 -1
  170. package/package.json +18 -18
  171. package/src/mergeTree.ts +80 -28
  172. package/src/mergeTreeNodes.ts +15 -4
  173. package/src/partialLengths.ts +559 -776
  174. package/src/perspective.ts +10 -1
  175. package/src/properties.ts +2 -3
  176. package/src/segmentInfos.ts +3 -0
  177. package/src/snapshotLoader.ts +1 -1
  178. package/src/sortedSegmentSet.ts +41 -50
  179. package/src/sortedSet.ts +32 -16
package/.eslintrc.cjs CHANGED
@@ -15,6 +15,5 @@ module.exports = {
15
15
  "no-case-declarations": "off",
16
16
  "prefer-arrow/prefer-arrow-functions": "off",
17
17
  "unicorn/no-useless-spread": "off", // Off because it generates incorrect code in autofixes and cannot distinguish useful copies of arrays from useless ones
18
- "@fluid-internal/fluid/no-unchecked-record-access": "warn",
19
18
  },
20
19
  };
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluidframework/merge-tree
2
2
 
3
+ ## 2.22.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.21.0
4
8
 
5
9
  Dependency updates only.
package/README.md CHANGED
@@ -154,6 +154,7 @@ When making such a request please include if the configuration already works (an
154
154
  ### Supported Runtimes
155
155
 
156
156
  - NodeJs ^20.10.0 except that we will drop support for it [when NodeJs 20 loses its upstream support on 2026-04-30](https://github.com/nodejs/release#release-schedule), and will support a newer LTS version of NodeJS (22) at least 1 year before 20 is end-of-life. This same policy applies to NodeJS 22 when it is end of life (2027-04-30).
157
+ - Running Fluid in a Node.js environment with the `--no-experimental-fetch` flag is not supported.
157
158
  - Modern browsers supporting the es2022 standard library: in response to asks we can add explicit support for using babel to polyfill to target specific standards or runtimes (meaning we can avoid/remove use of things that don't polyfill robustly, but otherwise target modern standards).
158
159
 
159
160
  ### Supported Tools
@@ -134,7 +134,6 @@ class AttributionCollection {
134
134
  return splitCollection;
135
135
  }
136
136
  append(other) {
137
- var _a;
138
137
  const lastEntry = this.keys[this.keys.length - 1];
139
138
  for (let i = 0; i < other.keys.length; i++) {
140
139
  if (i !== 0 || !areEqualAttributionKeys(lastEntry, other.keys[i])) {
@@ -143,12 +142,12 @@ class AttributionCollection {
143
142
  }
144
143
  }
145
144
  if (other.channels !== undefined || this.channels !== undefined) {
146
- this.channels ?? (this.channels = {});
145
+ this.channels ??= {};
147
146
  for (const [key, collection] of other.channelEntries) {
148
- const thisCollection = ((_a = this.channels)[key] ?? (_a[key] = new AttributionCollection(this.length,
147
+ const thisCollection = (this.channels[key] ??= new AttributionCollection(this.length,
149
148
  // Null is needed as null and undefined have different meanings in the context of attribution collections.
150
149
  // eslint-disable-next-line unicorn/no-null
151
- null)));
150
+ null));
152
151
  thisCollection.append(collection);
153
152
  }
154
153
  for (const [key, collection] of this.channelEntries) {
@@ -197,7 +196,7 @@ class AttributionCollection {
197
196
  this.keys = [...channel.keys];
198
197
  }
199
198
  else {
200
- this.channels ?? (this.channels = {});
199
+ this.channels ??= {};
201
200
  if (this.channels[name] === undefined) {
202
201
  this.channels[name] = channel;
203
202
  }
@@ -253,10 +252,9 @@ class AttributionCollection {
253
252
  if (channels) {
254
253
  for (const [name, collectionSpec] of Object.entries(channels)) {
255
254
  extractOntoSegments(collectionSpec, (collection, segment) => {
256
- var _a;
257
255
  if (segment.attribution !== undefined) {
258
256
  // Cast is valid as we just assigned this field above
259
- ((_a = segment.attribution).channels ?? (_a.channels = {}))[name] =
257
+ (segment.attribution.channels ??= {})[name] =
260
258
  collection;
261
259
  }
262
260
  });
@@ -1 +1 @@
1
- {"version":3,"file":"attributionCollection.js","sourceRoot":"","sources":["../src/attributionCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAM9E,uEAAsE;AAsItE,gDAAgD;AAChD,SAAgB,uBAAuB;AACtC,kDAAkD;AAClD,CAAoC;AACpC,kDAAkD;AAClD,CAAoC;IAEpC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACd,OAAO,KAAK,CAAC;IACd,CAAC;IAED,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,gGAAgG;IAChG,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;QAChB,KAAK,IAAI,CAAC,CAAC,CAAC;YACX,OAAO,CAAC,CAAC,GAAG,KAAM,CAAsB,CAAC,GAAG,CAAC;QAC9C,CAAC;QACD,KAAK,UAAU,CAAC,CAAC,CAAC;YACjB,OAAO,CAAC,CAAC,EAAE,KAAM,CAA4B,CAAC,EAAE,CAAC;QAClD,CAAC;QACD,KAAK,OAAO,CAAC,CAAC,CAAC;YACd,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,IAAA,0BAAe,EAAC,CAAC,EAAE,+BAA+B,CAAC,CAAC;QACrD,CAAC;IACF,CAAC;AACF,CAAC;AAjCD,0DAiCC;AAED,MAAa,qBAA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,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAC7D,CAAC;gBACF,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;YAC3C,CAAC;YACD,YAAY,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAClC,CAAC;QAED,OAAO,YAAY,CAAC;IACrB,CAAC;CACD;AAxWD,sDAwWC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tAttributionKey,\n\tDetachedAttributionKey,\n\tOpAttributionKey,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ISegment } from \"./mergeTreeNodes.js\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface SequenceOffsets {\n\t/**\n\t * Parallel array with posBreakpoints which tracks the seq of insertion.\n\t *\n\t * @example\n\t *\n\t * If seqs is [45, 46] and posBreakpoints is [0, 3], the section of the string\n\t * between offsets 0 and 3 was inserted at seq 45 and the section of the string between\n\t * 3 and the length of the string was inserted at seq 46.\n\t *\n\t * @remarks We use null here rather than undefined as round-tripping through JSON converts\n\t * undefineds to null anyway\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tseqs: (number | AttributionKey | null)[];\n\tposBreakpoints: number[];\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface SerializedAttributionCollection extends SequenceOffsets {\n\tchannels?: { [name: string]: SequenceOffsets };\n\t/* Total length; only necessary for validation */\n\tlength: number;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IAttributionCollectionSpec<T> {\n\t// eslint-disable-next-line @rushstack/no-new-null\n\troot: Iterable<{ offset: number; key: T | null }>;\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tchannels?: { [name: string]: Iterable<{ offset: number; key: T | null }> };\n\tlength: number;\n}\n\n/**\n * @legacy\n * @alpha\n * @sealed\n */\nexport interface IAttributionCollectionSerializer {\n\t/***/\n\tserializeAttributionCollections(\n\t\tsegments: Iterable<{\n\t\t\tattribution?: IAttributionCollection<AttributionKey>;\n\t\t\tcachedLength: number;\n\t\t}>,\n\t): SerializedAttributionCollection;\n\n\t/**\n\t * Populates attribution information on segments using the provided summary.\n\t */\n\tpopulateAttributionCollections(\n\t\tsegments: Iterable<ISegment>,\n\t\tsummary: SerializedAttributionCollection,\n\t): void;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IAttributionCollection<T> {\n\t/**\n\t * Retrieves the attribution key associated with the provided offset.\n\t * @param channel - When specified, gets an attribution key associated with a particular channel.\n\t */\n\tgetAtOffset(offset: number, channel?: string): AttributionKey | undefined;\n\n\t/**\n\t * Retrieves all the [Offset, Attribution key] pairs for the provided offset range. Note:\n\t * The returned array is sorted by offset.\n\t * The first offset in response could be lower than the startOffset as the Attribution Key for the startOffset\n\t * could start at a lower offset than the startOffset in case where Attribution key offset boundaries don't\n\t * align exactly with startOffset.\n\t * Example: If the Attribution Offsets in the segment is [0, 10, 20, 30, 40] and request is for (startOffset: 5, endOffset: 25),\n\t * then result would be [(offset: 0, key: key1), (offset:10, key: key2), (offset:20, key: key3)].\n\t * @param channel - When specified, gets attribution keys associated with a particular channel.\n\t * @returns - undefined if the provided channel is not found or list of attribution keys along with\n\t * the corresponding offset start boundary.\n\t */\n\tgetKeysInOffsetRange(\n\t\tstartOffset: number,\n\t\tendOffset?: number,\n\t\tchannel?: string,\n\t): { offset: number; key: AttributionKey }[] | undefined;\n\n\t/**\n\t * Total length of all attribution keys in this collection.\n\t */\n\treadonly length: number;\n\n\treadonly channelNames: Iterable<string>;\n\n\t/**\n\t * Retrieve all key/offset pairs stored on this segment. Entries should be ordered by offset, such that\n\t * the `i`th result's attribution key applies to offsets in the open range between the `i`th offset and the\n\t * `i+1`th offset.\n\t * The last entry's key applies to the open interval from the last entry's offset to this collection's length.\n\t */\n\tgetAll(): IAttributionCollectionSpec<T>;\n\n\t/***/\n\tsplitAt(pos: number): IAttributionCollection<T>;\n\n\t/***/\n\tappend(other: IAttributionCollection<T>): void;\n\n\t/***/\n\tclone(): IAttributionCollection<T>;\n\n\t/**\n\t * Updates this collection with new attribution data.\n\t * @param name - Name of the channel that requires an update. Undefined signifies the root channel.\n\t * Updates apply only to the individual channel (i.e. if an attribution policy needs to update the root\n\t * channel and 4 other channels, it should call `.update` 5 times).\n\t * @param channel - Updated collection for that channel.\n\t */\n\tupdate(name: string | undefined, channel: IAttributionCollection<T>): void;\n}\n\n// note: treats null and undefined as equivalent\nexport function areEqualAttributionKeys(\n\t// eslint-disable-next-line @rushstack/no-new-null\n\ta: AttributionKey | null | undefined,\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tb: AttributionKey | null | undefined,\n): boolean {\n\tif (!a && !b) {\n\t\treturn true;\n\t}\n\n\tif (!a || !b) {\n\t\treturn false;\n\t}\n\n\tif (a.type !== b.type) {\n\t\treturn false;\n\t}\n\n\t// Note: TS can't narrow the type of b inside this switch statement, hence the need for casting.\n\tswitch (a.type) {\n\t\tcase \"op\": {\n\t\t\treturn a.seq === (b as OpAttributionKey).seq;\n\t\t}\n\t\tcase \"detached\": {\n\t\t\treturn a.id === (b as DetachedAttributionKey).id;\n\t\t}\n\t\tcase \"local\": {\n\t\t\treturn true;\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(a, \"Unhandled AttributionKey type\");\n\t\t}\n\t}\n}\n\nexport class AttributionCollection implements IAttributionCollection<AttributionKey> {\n\tprivate offsets: number[] = [];\n\tprivate keys: (AttributionKey | null)[] = [];\n\n\tprivate channels?: { [name: string]: AttributionCollection };\n\n\tprivate get channelEntries(): [string, AttributionCollection][] {\n\t\treturn Object.entries(this.channels ?? {});\n\t}\n\n\tpublic constructor(\n\t\tprivate _length: number,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tbaseEntry?: AttributionKey | null,\n\t) {\n\t\tif (baseEntry !== undefined) {\n\t\t\tthis.offsets.push(0);\n\t\t\tthis.keys.push(baseEntry);\n\t\t}\n\t}\n\n\tpublic get channelNames(): string[] {\n\t\treturn Object.keys(this.channels ?? {});\n\t}\n\n\tpublic getAtOffset(offset: number): AttributionKey;\n\tpublic getAtOffset(offset: number, channel: string): AttributionKey | undefined;\n\tpublic getAtOffset(offset: number, channel?: string): AttributionKey | undefined {\n\t\tif (channel !== undefined) {\n\t\t\tconst subCollection = this.channels?.[channel];\n\t\t\treturn subCollection?.getAtOffset(offset);\n\t\t}\n\t\tassert(offset >= 0 && offset < this._length, 0x443 /* Requested offset should be valid */);\n\t\treturn this.get(this.findIndex(offset));\n\t}\n\n\tpublic getKeysInOffsetRange(\n\t\tstartOffset: number,\n\t\tendOffset?: number,\n\t): { offset: number; key: AttributionKey }[];\n\tpublic getKeysInOffsetRange(\n\t\tstartOffset: number,\n\t\tendOffset?: number,\n\t\tchannel?: string,\n\t): { offset: number; key: AttributionKey }[] | undefined;\n\tpublic getKeysInOffsetRange(\n\t\tstartOffset: number,\n\t\tendOffset?: number,\n\t\tchannel?: string,\n\t): { offset: number; key: AttributionKey }[] | undefined {\n\t\tif (startOffset < 0 || startOffset >= this._length) {\n\t\t\tthrow new UsageError(\"startOffset should be valid and in range\");\n\t\t}\n\t\tif (\n\t\t\tendOffset !== undefined &&\n\t\t\t(endOffset < 0 || endOffset >= this._length || startOffset > endOffset)\n\t\t) {\n\t\t\tthrow new UsageError(\"endOffset should be valid and in range\");\n\t\t}\n\n\t\tif (channel !== undefined) {\n\t\t\tconst subCollection = this.channels?.[channel];\n\t\t\treturn subCollection?.getKeysInOffsetRange(startOffset, endOffset);\n\t\t}\n\t\tconst result: { offset: number; key: AttributionKey }[] = [];\n\t\tlet index = this.findIndex(startOffset);\n\t\tlet attributionKey = this.get(index);\n\t\tif (attributionKey !== undefined) {\n\t\t\tresult.push({ offset: this.offsets[index], key: attributionKey });\n\t\t}\n\t\tindex++;\n\t\tconst endOffsetVal = endOffset ?? Number.MAX_SAFE_INTEGER;\n\t\twhile (index < this.offsets.length && endOffsetVal >= this.offsets[index]) {\n\t\t\tattributionKey = this.get(index);\n\t\t\tif (attributionKey !== undefined) {\n\t\t\t\tresult.push({ offset: this.offsets[index], key: attributionKey });\n\t\t\t}\n\t\t\tindex++;\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate findIndex(offset: number): number {\n\t\t// Note: maximum length here is 256 for text segments. Perf testing shows that linear scan beats binary search\n\t\t// for attribution collections with under ~64 entries, and even at maximum size (which would require a maximum\n\t\t// length segment with every offset having different attribution), getAtOffset is on the order of 100ns.\n\t\tlet i = 0;\n\t\twhile (i < this.offsets.length && offset > this.offsets[i]) {\n\t\t\ti++;\n\t\t}\n\t\treturn this.offsets[i] === offset ? i : i - 1;\n\t}\n\n\tprivate get(index: number): AttributionKey | undefined {\n\t\tconst key = this.keys[index];\n\t\treturn key ?? undefined;\n\t}\n\n\tpublic get length(): number {\n\t\treturn this._length;\n\t}\n\n\t/**\n\t * Splits this attribution collection into two with entries for [0, pos) and [pos, length).\n\t */\n\tpublic splitAt(pos: number): AttributionCollection {\n\t\tconst splitIndex = this.findIndex(pos);\n\t\tconst splitCollection = new AttributionCollection(this.length - pos);\n\t\tfor (let i = splitIndex; i < this.keys.length; i++) {\n\t\t\tsplitCollection.offsets.push(Math.max(this.offsets[i] - pos, 0));\n\t\t\tsplitCollection.keys.push(this.keys[i]);\n\t\t}\n\n\t\tif (this.channels) {\n\t\t\tsplitCollection.channels = {};\n\t\t\tfor (const [key, collection] of this.channelEntries) {\n\t\t\t\tsplitCollection.channels[key] = collection.splitAt(pos);\n\t\t\t}\n\t\t}\n\n\t\tconst spliceIndex = this.offsets[splitIndex] === pos ? splitIndex : splitIndex + 1;\n\t\tthis.keys.splice(spliceIndex);\n\t\tthis.offsets.splice(spliceIndex);\n\t\tthis._length = pos;\n\t\treturn splitCollection;\n\t}\n\n\tpublic append(other: AttributionCollection): void {\n\t\tconst lastEntry = this.keys[this.keys.length - 1];\n\t\tfor (let i = 0; i < other.keys.length; i++) {\n\t\t\tif (i !== 0 || !areEqualAttributionKeys(lastEntry, other.keys[i])) {\n\t\t\t\tthis.offsets.push(other.offsets[i] + this.length);\n\t\t\t\tthis.keys.push(other.keys[i]);\n\t\t\t}\n\t\t}\n\n\t\tif (other.channels !== undefined || this.channels !== undefined) {\n\t\t\tthis.channels ??= {};\n\t\t\tfor (const [key, collection] of other.channelEntries) {\n\t\t\t\tconst thisCollection = (this.channels[key] ??= new AttributionCollection(\n\t\t\t\t\tthis.length,\n\t\t\t\t\t// Null is needed as null and undefined have different meanings in the context of attribution collections.\n\t\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\t\tnull,\n\t\t\t\t));\n\t\t\t\tthisCollection.append(collection);\n\t\t\t}\n\t\t\tfor (const [key, collection] of this.channelEntries) {\n\t\t\t\tif (other.channels?.[key] === undefined) {\n\t\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\t\tcollection.append(new AttributionCollection(other.length, null));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis._length += other.length;\n\t}\n\n\tpublic getAll(): IAttributionCollectionSpec<AttributionKey> {\n\t\ttype ExtractGeneric<T> = T extends Iterable<infer Q> ? Q : unknown;\n\t\tconst root: ExtractGeneric<IAttributionCollectionSpec<AttributionKey>[\"root\"]>[] =\n\t\t\tArray.from({ length: this.keys.length });\n\t\tfor (let i = 0; i < this.keys.length; i++) {\n\t\t\troot[i] = { offset: this.offsets[i], key: this.keys[i] };\n\t\t}\n\t\tconst result: IAttributionCollectionSpec<AttributionKey> = {\n\t\t\troot,\n\t\t\tlength: this.length,\n\t\t};\n\t\tif (this.channels !== undefined) {\n\t\t\tresult.channels = {};\n\t\t\tfor (const [key, collection] of this.channelEntries) {\n\t\t\t\tresult.channels[key] = collection.getAll().root;\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tpublic clone(): AttributionCollection {\n\t\tconst copy = new AttributionCollection(this.length);\n\t\tcopy.keys = [...this.keys];\n\t\tcopy.offsets = [...this.offsets];\n\t\tif (this.channels !== undefined) {\n\t\t\tconst channelsCopy: Record<string, AttributionCollection> = {};\n\t\t\tfor (const [key, collection] of this.channelEntries) {\n\t\t\t\tchannelsCopy[key] = collection.clone();\n\t\t\t}\n\t\t\tcopy.channels = channelsCopy;\n\t\t}\n\t\treturn copy;\n\t}\n\n\tpublic update(name: string | undefined, channel: AttributionCollection): void {\n\t\tassert(\n\t\t\tchannel.length === this.length,\n\t\t\t0x5c0 /* AttributionCollection channel update should have consistent segment length */,\n\t\t);\n\t\tif (name === undefined) {\n\t\t\tthis.offsets = [...channel.offsets];\n\t\t\tthis.keys = [...channel.keys];\n\t\t} else {\n\t\t\tthis.channels ??= {};\n\t\t\tif (this.channels[name] === undefined) {\n\t\t\t\tthis.channels[name] = channel;\n\t\t\t} else {\n\t\t\t\tthis.channels[name]?.update(undefined, channel);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Rehydrates attribution information from its serialized form into the provided iterable of consecutive segments.\n\t */\n\tpublic static populateAttributionCollections(\n\t\tsegments: ISegment[],\n\t\tsummary: SerializedAttributionCollection,\n\t): void {\n\t\tconst { channels } = summary;\n\t\tassert(\n\t\t\t// Destructuring here would require renaming the variables, since seqs is declared below\n\t\t\t// eslint-disable-next-line unicorn/consistent-destructuring\n\t\t\tsummary.seqs.length === summary.posBreakpoints.length,\n\t\t\t0x445 /* Invalid attribution summary blob provided */,\n\t\t);\n\n\t\tconst extractOntoSegments = (\n\t\t\t{ seqs, posBreakpoints }: SequenceOffsets,\n\t\t\tassignToSegment: (collection: AttributionCollection, segment: ISegment) => void,\n\t\t): void => {\n\t\t\tif (seqs.length === 0) {\n\t\t\t\tassert(\n\t\t\t\t\tposBreakpoints.length === 0,\n\t\t\t\t\t0x9e1 /* seqs and posBreakpoints length should match */,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet curIndex = 0;\n\t\t\tlet cumulativeSegPos = 0;\n\n\t\t\tfor (const segment of segments) {\n\t\t\t\tconst attribution = new AttributionCollection(segment.cachedLength);\n\t\t\t\t// This function is defined here to allow for the creation of a new collection for each segment.\n\t\t\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\t\t\tconst pushEntry = (offset: number, seq: AttributionKey | number | null): void => {\n\t\t\t\t\tattribution.offsets.push(offset);\n\t\t\t\t\tattribution.keys.push(\n\t\t\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\t\t\tseq === null ? null : typeof seq === \"object\" ? seq : { type: \"op\", seq },\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tif (posBreakpoints[curIndex] > cumulativeSegPos) {\n\t\t\t\t\tcurIndex--;\n\t\t\t\t}\n\n\t\t\t\twhile (posBreakpoints[curIndex] < cumulativeSegPos + segment.cachedLength) {\n\t\t\t\t\tconst nextOffset = Math.max(posBreakpoints[curIndex] - cumulativeSegPos, 0);\n\t\t\t\t\tpushEntry(nextOffset, seqs[curIndex]);\n\t\t\t\t\tcurIndex++;\n\t\t\t\t}\n\n\t\t\t\tif (attribution.offsets.length === 0) {\n\t\t\t\t\tpushEntry(0, seqs[curIndex - 1]);\n\t\t\t\t}\n\n\t\t\t\tassignToSegment(attribution, segment);\n\t\t\t\tcumulativeSegPos += segment.cachedLength;\n\t\t\t}\n\t\t};\n\n\t\textractOntoSegments(summary, (collection, segment) => {\n\t\t\tsegment.attribution = collection;\n\t\t});\n\t\tif (channels) {\n\t\t\tfor (const [name, collectionSpec] of Object.entries(channels)) {\n\t\t\t\textractOntoSegments(collectionSpec, (collection, segment) => {\n\t\t\t\t\tif (segment.attribution !== undefined) {\n\t\t\t\t\t\t// Cast is valid as we just assigned this field above\n\t\t\t\t\t\t((segment.attribution as AttributionCollection).channels ??= {})[name] =\n\t\t\t\t\t\t\tcollection;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Condenses attribution information on consecutive segments into a `SerializedAttributionCollection`\n\t *\n\t * Note: this operates on segments rather than attribution collections directly so that it can handle cases\n\t * where only some segments have attribution defined.\n\t */\n\tpublic static serializeAttributionCollections(\n\t\tsegments: Iterable<{\n\t\t\tattribution?: IAttributionCollection<AttributionKey>;\n\t\t\tcachedLength: number;\n\t\t}>,\n\t): SerializedAttributionCollection {\n\t\tconst allCollectionSpecs: IAttributionCollectionSpec<AttributionKey>[] = [];\n\n\t\tconst allChannelNames = new Set<string>();\n\t\tfor (const segment of segments) {\n\t\t\tconst collection =\n\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\tsegment.attribution ?? new AttributionCollection(segment.cachedLength, null);\n\t\t\tconst spec = collection.getAll();\n\t\t\tallCollectionSpecs.push(spec);\n\t\t\tif (spec.channels) {\n\t\t\t\tfor (const name of Object.keys(spec.channels)) {\n\t\t\t\t\tallChannelNames.add(name);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst extractSequenceOffsets = (\n\t\t\tgetSpecEntries: (\n\t\t\t\tspec: IAttributionCollectionSpec<AttributionKey>,\n\t\t\t) => Iterable<{ offset: number; key: AttributionKey | null }>,\n\t\t): SerializedAttributionCollection => {\n\t\t\tconst posBreakpoints: number[] = [];\n\t\t\tconst seqs: (number | AttributionKey | null)[] = [];\n\t\t\tlet mostRecentAttributionKey: AttributionKey | null | undefined;\n\t\t\tlet cumulativePos = 0;\n\n\t\t\tfor (const spec of allCollectionSpecs) {\n\t\t\t\tfor (const { offset, key } of getSpecEntries(spec)) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tkey?.type !== \"local\",\n\t\t\t\t\t\t0x5c1 /* local attribution keys should never be put in summaries */,\n\t\t\t\t\t);\n\t\t\t\t\tif (\n\t\t\t\t\t\tmostRecentAttributionKey === undefined ||\n\t\t\t\t\t\t!areEqualAttributionKeys(key, mostRecentAttributionKey)\n\t\t\t\t\t) {\n\t\t\t\t\t\tposBreakpoints.push(offset + cumulativePos);\n\t\t\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\t\t\tseqs.push(key ? (key.type === \"op\" ? key.seq : key) : null);\n\t\t\t\t\t}\n\t\t\t\t\tmostRecentAttributionKey = key;\n\t\t\t\t}\n\n\t\t\t\tcumulativePos += spec.length;\n\t\t\t}\n\n\t\t\treturn { seqs, posBreakpoints, length: cumulativePos };\n\t\t};\n\n\t\tconst blobContents = extractSequenceOffsets((spec) => spec.root);\n\t\tif (allChannelNames.size > 0) {\n\t\t\tconst channels: { [name: string]: SequenceOffsets } = {};\n\t\t\tfor (const name of allChannelNames) {\n\t\t\t\tconst { posBreakpoints, seqs } = extractSequenceOffsets(\n\t\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\t\t(spec) => spec.channels?.[name] ?? [{ offset: 0, key: null }],\n\t\t\t\t);\n\t\t\t\tchannels[name] = { posBreakpoints, seqs };\n\t\t\t}\n\t\t\tblobContents.channels = channels;\n\t\t}\n\n\t\treturn blobContents;\n\t}\n}\n"]}
1
+ {"version":3,"file":"attributionCollection.js","sourceRoot":"","sources":["../src/attributionCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAM9E,uEAAsE;AAsItE,gDAAgD;AAChD,SAAgB,uBAAuB;AACtC,kDAAkD;AAClD,CAAoC;AACpC,kDAAkD;AAClD,CAAoC;IAEpC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACd,OAAO,KAAK,CAAC;IACd,CAAC;IAED,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,gGAAgG;IAChG,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;QAChB,KAAK,IAAI,CAAC,CAAC,CAAC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AI,CAAC,CAAC;QACjE,IAAI,eAAe,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,QAAQ,GAAwC,EAAE,CAAC;YACzD,KAAK,MAAM,IAAI,IAAI,eAAe,EAAE,CAAC;gBACpC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,sBAAsB;gBACtD,2CAA2C;gBAC3C,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAC7D,CAAC;gBACF,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;YAC3C,CAAC;YACD,YAAY,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAClC,CAAC;QAED,OAAO,YAAY,CAAC;IACrB,CAAC;CACD;AAxWD,sDAwWC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tAttributionKey,\n\tDetachedAttributionKey,\n\tOpAttributionKey,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ISegment } from \"./mergeTreeNodes.js\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface SequenceOffsets {\n\t/**\n\t * Parallel array with posBreakpoints which tracks the seq of insertion.\n\t *\n\t * @example\n\t *\n\t * If seqs is [45, 46] and posBreakpoints is [0, 3], the section of the string\n\t * between offsets 0 and 3 was inserted at seq 45 and the section of the string between\n\t * 3 and the length of the string was inserted at seq 46.\n\t *\n\t * @remarks We use null here rather than undefined as round-tripping through JSON converts\n\t * undefineds to null anyway\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tseqs: (number | AttributionKey | null)[];\n\tposBreakpoints: number[];\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface SerializedAttributionCollection extends SequenceOffsets {\n\tchannels?: { [name: string]: SequenceOffsets };\n\t/* Total length; only necessary for validation */\n\tlength: number;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IAttributionCollectionSpec<T> {\n\t// eslint-disable-next-line @rushstack/no-new-null\n\troot: Iterable<{ offset: number; key: T | null }>;\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tchannels?: { [name: string]: Iterable<{ offset: number; key: T | null }> };\n\tlength: number;\n}\n\n/**\n * @legacy\n * @alpha\n * @sealed\n */\nexport interface IAttributionCollectionSerializer {\n\t/***/\n\tserializeAttributionCollections(\n\t\tsegments: Iterable<{\n\t\t\tattribution?: IAttributionCollection<AttributionKey>;\n\t\t\tcachedLength: number;\n\t\t}>,\n\t): SerializedAttributionCollection;\n\n\t/**\n\t * Populates attribution information on segments using the provided summary.\n\t */\n\tpopulateAttributionCollections(\n\t\tsegments: Iterable<ISegment>,\n\t\tsummary: SerializedAttributionCollection,\n\t): void;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IAttributionCollection<T> {\n\t/**\n\t * Retrieves the attribution key associated with the provided offset.\n\t * @param channel - When specified, gets an attribution key associated with a particular channel.\n\t */\n\tgetAtOffset(offset: number, channel?: string): AttributionKey | undefined;\n\n\t/**\n\t * Retrieves all the [Offset, Attribution key] pairs for the provided offset range. Note:\n\t * The returned array is sorted by offset.\n\t * The first offset in response could be lower than the startOffset as the Attribution Key for the startOffset\n\t * could start at a lower offset than the startOffset in case where Attribution key offset boundaries don't\n\t * align exactly with startOffset.\n\t * Example: If the Attribution Offsets in the segment is [0, 10, 20, 30, 40] and request is for (startOffset: 5, endOffset: 25),\n\t * then result would be [(offset: 0, key: key1), (offset:10, key: key2), (offset:20, key: key3)].\n\t * @param channel - When specified, gets attribution keys associated with a particular channel.\n\t * @returns - undefined if the provided channel is not found or list of attribution keys along with\n\t * the corresponding offset start boundary.\n\t */\n\tgetKeysInOffsetRange(\n\t\tstartOffset: number,\n\t\tendOffset?: number,\n\t\tchannel?: string,\n\t): { offset: number; key: AttributionKey }[] | undefined;\n\n\t/**\n\t * Total length of all attribution keys in this collection.\n\t */\n\treadonly length: number;\n\n\treadonly channelNames: Iterable<string>;\n\n\t/**\n\t * Retrieve all key/offset pairs stored on this segment. Entries should be ordered by offset, such that\n\t * the `i`th result's attribution key applies to offsets in the open range between the `i`th offset and the\n\t * `i+1`th offset.\n\t * The last entry's key applies to the open interval from the last entry's offset to this collection's length.\n\t */\n\tgetAll(): IAttributionCollectionSpec<T>;\n\n\t/***/\n\tsplitAt(pos: number): IAttributionCollection<T>;\n\n\t/***/\n\tappend(other: IAttributionCollection<T>): void;\n\n\t/***/\n\tclone(): IAttributionCollection<T>;\n\n\t/**\n\t * Updates this collection with new attribution data.\n\t * @param name - Name of the channel that requires an update. Undefined signifies the root channel.\n\t * Updates apply only to the individual channel (i.e. if an attribution policy needs to update the root\n\t * channel and 4 other channels, it should call `.update` 5 times).\n\t * @param channel - Updated collection for that channel.\n\t */\n\tupdate(name: string | undefined, channel: IAttributionCollection<T>): void;\n}\n\n// note: treats null and undefined as equivalent\nexport function areEqualAttributionKeys(\n\t// eslint-disable-next-line @rushstack/no-new-null\n\ta: AttributionKey | null | undefined,\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tb: AttributionKey | null | undefined,\n): boolean {\n\tif (!a && !b) {\n\t\treturn true;\n\t}\n\n\tif (!a || !b) {\n\t\treturn false;\n\t}\n\n\tif (a.type !== b.type) {\n\t\treturn false;\n\t}\n\n\t// Note: TS can't narrow the type of b inside this switch statement, hence the need for casting.\n\tswitch (a.type) {\n\t\tcase \"op\": {\n\t\t\treturn a.seq === (b as OpAttributionKey).seq;\n\t\t}\n\t\tcase \"detached\": {\n\t\t\treturn a.id === (b as DetachedAttributionKey).id;\n\t\t}\n\t\tcase \"local\": {\n\t\t\treturn true;\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(a, \"Unhandled AttributionKey type\");\n\t\t}\n\t}\n}\n\nexport class AttributionCollection implements IAttributionCollection<AttributionKey> {\n\tprivate offsets: number[] = [];\n\tprivate keys: (AttributionKey | null)[] = [];\n\n\tprivate channels?: { [name: string]: AttributionCollection };\n\n\tprivate get channelEntries(): [string, AttributionCollection][] {\n\t\treturn Object.entries(this.channels ?? {});\n\t}\n\n\tpublic constructor(\n\t\tprivate _length: number,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tbaseEntry?: AttributionKey | null,\n\t) {\n\t\tif (baseEntry !== undefined) {\n\t\t\tthis.offsets.push(0);\n\t\t\tthis.keys.push(baseEntry);\n\t\t}\n\t}\n\n\tpublic get channelNames(): string[] {\n\t\treturn Object.keys(this.channels ?? {});\n\t}\n\n\tpublic getAtOffset(offset: number): AttributionKey;\n\tpublic getAtOffset(offset: number, channel: string): AttributionKey | undefined;\n\tpublic getAtOffset(offset: number, channel?: string): AttributionKey | undefined {\n\t\tif (channel !== undefined) {\n\t\t\tconst subCollection = this.channels?.[channel];\n\t\t\treturn subCollection?.getAtOffset(offset);\n\t\t}\n\t\tassert(offset >= 0 && offset < this._length, 0x443 /* Requested offset should be valid */);\n\t\treturn this.get(this.findIndex(offset));\n\t}\n\n\tpublic getKeysInOffsetRange(\n\t\tstartOffset: number,\n\t\tendOffset?: number,\n\t): { offset: number; key: AttributionKey }[];\n\tpublic getKeysInOffsetRange(\n\t\tstartOffset: number,\n\t\tendOffset?: number,\n\t\tchannel?: string,\n\t): { offset: number; key: AttributionKey }[] | undefined;\n\tpublic getKeysInOffsetRange(\n\t\tstartOffset: number,\n\t\tendOffset?: number,\n\t\tchannel?: string,\n\t): { offset: number; key: AttributionKey }[] | undefined {\n\t\tif (startOffset < 0 || startOffset >= this._length) {\n\t\t\tthrow new UsageError(\"startOffset should be valid and in range\");\n\t\t}\n\t\tif (\n\t\t\tendOffset !== undefined &&\n\t\t\t(endOffset < 0 || endOffset >= this._length || startOffset > endOffset)\n\t\t) {\n\t\t\tthrow new UsageError(\"endOffset should be valid and in range\");\n\t\t}\n\n\t\tif (channel !== undefined) {\n\t\t\tconst subCollection = this.channels?.[channel];\n\t\t\treturn subCollection?.getKeysInOffsetRange(startOffset, endOffset);\n\t\t}\n\t\tconst result: { offset: number; key: AttributionKey }[] = [];\n\t\tlet index = this.findIndex(startOffset);\n\t\tlet attributionKey = this.get(index);\n\t\tif (attributionKey !== undefined) {\n\t\t\tresult.push({ offset: this.offsets[index], key: attributionKey });\n\t\t}\n\t\tindex++;\n\t\tconst endOffsetVal = endOffset ?? Number.MAX_SAFE_INTEGER;\n\t\twhile (index < this.offsets.length && endOffsetVal >= this.offsets[index]) {\n\t\t\tattributionKey = this.get(index);\n\t\t\tif (attributionKey !== undefined) {\n\t\t\t\tresult.push({ offset: this.offsets[index], key: attributionKey });\n\t\t\t}\n\t\t\tindex++;\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate findIndex(offset: number): number {\n\t\t// Note: maximum length here is 256 for text segments. Perf testing shows that linear scan beats binary search\n\t\t// for attribution collections with under ~64 entries, and even at maximum size (which would require a maximum\n\t\t// length segment with every offset having different attribution), getAtOffset is on the order of 100ns.\n\t\tlet i = 0;\n\t\twhile (i < this.offsets.length && offset > this.offsets[i]) {\n\t\t\ti++;\n\t\t}\n\t\treturn this.offsets[i] === offset ? i : i - 1;\n\t}\n\n\tprivate get(index: number): AttributionKey | undefined {\n\t\tconst key = this.keys[index];\n\t\treturn key ?? undefined;\n\t}\n\n\tpublic get length(): number {\n\t\treturn this._length;\n\t}\n\n\t/**\n\t * Splits this attribution collection into two with entries for [0, pos) and [pos, length).\n\t */\n\tpublic splitAt(pos: number): AttributionCollection {\n\t\tconst splitIndex = this.findIndex(pos);\n\t\tconst splitCollection = new AttributionCollection(this.length - pos);\n\t\tfor (let i = splitIndex; i < this.keys.length; i++) {\n\t\t\tsplitCollection.offsets.push(Math.max(this.offsets[i] - pos, 0));\n\t\t\tsplitCollection.keys.push(this.keys[i]);\n\t\t}\n\n\t\tif (this.channels) {\n\t\t\tsplitCollection.channels = {};\n\t\t\tfor (const [key, collection] of this.channelEntries) {\n\t\t\t\tsplitCollection.channels[key] = collection.splitAt(pos);\n\t\t\t}\n\t\t}\n\n\t\tconst spliceIndex = this.offsets[splitIndex] === pos ? splitIndex : splitIndex + 1;\n\t\tthis.keys.splice(spliceIndex);\n\t\tthis.offsets.splice(spliceIndex);\n\t\tthis._length = pos;\n\t\treturn splitCollection;\n\t}\n\n\tpublic append(other: AttributionCollection): void {\n\t\tconst lastEntry = this.keys[this.keys.length - 1];\n\t\tfor (let i = 0; i < other.keys.length; i++) {\n\t\t\tif (i !== 0 || !areEqualAttributionKeys(lastEntry, other.keys[i])) {\n\t\t\t\tthis.offsets.push(other.offsets[i] + this.length);\n\t\t\t\tthis.keys.push(other.keys[i]);\n\t\t\t}\n\t\t}\n\n\t\tif (other.channels !== undefined || this.channels !== undefined) {\n\t\t\tthis.channels ??= {};\n\t\t\tfor (const [key, collection] of other.channelEntries) {\n\t\t\t\tconst thisCollection = (this.channels[key] ??= new AttributionCollection(\n\t\t\t\t\tthis.length,\n\t\t\t\t\t// Null is needed as null and undefined have different meanings in the context of attribution collections.\n\t\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\t\tnull,\n\t\t\t\t));\n\t\t\t\tthisCollection.append(collection);\n\t\t\t}\n\t\t\tfor (const [key, collection] of this.channelEntries) {\n\t\t\t\tif (other.channels?.[key] === undefined) {\n\t\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\t\tcollection.append(new AttributionCollection(other.length, null));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis._length += other.length;\n\t}\n\n\tpublic getAll(): IAttributionCollectionSpec<AttributionKey> {\n\t\ttype ExtractGeneric<T> = T extends Iterable<infer Q> ? Q : unknown;\n\t\tconst root: ExtractGeneric<IAttributionCollectionSpec<AttributionKey>[\"root\"]>[] =\n\t\t\tArray.from({ length: this.keys.length });\n\t\tfor (let i = 0; i < this.keys.length; i++) {\n\t\t\troot[i] = { offset: this.offsets[i], key: this.keys[i] };\n\t\t}\n\t\tconst result: IAttributionCollectionSpec<AttributionKey> = {\n\t\t\troot,\n\t\t\tlength: this.length,\n\t\t};\n\t\tif (this.channels !== undefined) {\n\t\t\tresult.channels = {};\n\t\t\tfor (const [key, collection] of this.channelEntries) {\n\t\t\t\tresult.channels[key] = collection.getAll().root;\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tpublic clone(): AttributionCollection {\n\t\tconst copy = new AttributionCollection(this.length);\n\t\tcopy.keys = [...this.keys];\n\t\tcopy.offsets = [...this.offsets];\n\t\tif (this.channels !== undefined) {\n\t\t\tconst channelsCopy: Record<string, AttributionCollection> = {};\n\t\t\tfor (const [key, collection] of this.channelEntries) {\n\t\t\t\tchannelsCopy[key] = collection.clone();\n\t\t\t}\n\t\t\tcopy.channels = channelsCopy;\n\t\t}\n\t\treturn copy;\n\t}\n\n\tpublic update(name: string | undefined, channel: AttributionCollection): void {\n\t\tassert(\n\t\t\tchannel.length === this.length,\n\t\t\t0x5c0 /* AttributionCollection channel update should have consistent segment length */,\n\t\t);\n\t\tif (name === undefined) {\n\t\t\tthis.offsets = [...channel.offsets];\n\t\t\tthis.keys = [...channel.keys];\n\t\t} else {\n\t\t\tthis.channels ??= {};\n\t\t\tif (this.channels[name] === undefined) {\n\t\t\t\tthis.channels[name] = channel;\n\t\t\t} else {\n\t\t\t\tthis.channels[name]?.update(undefined, channel);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Rehydrates attribution information from its serialized form into the provided iterable of consecutive segments.\n\t */\n\tpublic static populateAttributionCollections(\n\t\tsegments: ISegment[],\n\t\tsummary: SerializedAttributionCollection,\n\t): void {\n\t\tconst { channels } = summary;\n\t\tassert(\n\t\t\t// Destructuring here would require renaming the variables, since seqs is declared below\n\t\t\t// eslint-disable-next-line unicorn/consistent-destructuring\n\t\t\tsummary.seqs.length === summary.posBreakpoints.length,\n\t\t\t0x445 /* Invalid attribution summary blob provided */,\n\t\t);\n\n\t\tconst extractOntoSegments = (\n\t\t\t{ seqs, posBreakpoints }: SequenceOffsets,\n\t\t\tassignToSegment: (collection: AttributionCollection, segment: ISegment) => void,\n\t\t): void => {\n\t\t\tif (seqs.length === 0) {\n\t\t\t\tassert(\n\t\t\t\t\tposBreakpoints.length === 0,\n\t\t\t\t\t0x9e1 /* seqs and posBreakpoints length should match */,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet curIndex = 0;\n\t\t\tlet cumulativeSegPos = 0;\n\n\t\t\tfor (const segment of segments) {\n\t\t\t\tconst attribution = new AttributionCollection(segment.cachedLength);\n\t\t\t\t// This function is defined here to allow for the creation of a new collection for each segment.\n\t\t\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\t\t\tconst pushEntry = (offset: number, seq: AttributionKey | number | null): void => {\n\t\t\t\t\tattribution.offsets.push(offset);\n\t\t\t\t\tattribution.keys.push(\n\t\t\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\t\t\tseq === null ? null : typeof seq === \"object\" ? seq : { type: \"op\", seq },\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tif (posBreakpoints[curIndex] > cumulativeSegPos) {\n\t\t\t\t\tcurIndex--;\n\t\t\t\t}\n\n\t\t\t\twhile (posBreakpoints[curIndex] < cumulativeSegPos + segment.cachedLength) {\n\t\t\t\t\tconst nextOffset = Math.max(posBreakpoints[curIndex] - cumulativeSegPos, 0);\n\t\t\t\t\tpushEntry(nextOffset, seqs[curIndex]);\n\t\t\t\t\tcurIndex++;\n\t\t\t\t}\n\n\t\t\t\tif (attribution.offsets.length === 0) {\n\t\t\t\t\tpushEntry(0, seqs[curIndex - 1]);\n\t\t\t\t}\n\n\t\t\t\tassignToSegment(attribution, segment);\n\t\t\t\tcumulativeSegPos += segment.cachedLength;\n\t\t\t}\n\t\t};\n\n\t\textractOntoSegments(summary, (collection, segment) => {\n\t\t\tsegment.attribution = collection;\n\t\t});\n\t\tif (channels) {\n\t\t\tfor (const [name, collectionSpec] of Object.entries(channels)) {\n\t\t\t\textractOntoSegments(collectionSpec, (collection, segment) => {\n\t\t\t\t\tif (segment.attribution !== undefined) {\n\t\t\t\t\t\t// Cast is valid as we just assigned this field above\n\t\t\t\t\t\t((segment.attribution as AttributionCollection).channels ??= {})[name] =\n\t\t\t\t\t\t\tcollection;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Condenses attribution information on consecutive segments into a `SerializedAttributionCollection`\n\t *\n\t * Note: this operates on segments rather than attribution collections directly so that it can handle cases\n\t * where only some segments have attribution defined.\n\t */\n\tpublic static serializeAttributionCollections(\n\t\tsegments: Iterable<{\n\t\t\tattribution?: IAttributionCollection<AttributionKey>;\n\t\t\tcachedLength: number;\n\t\t}>,\n\t): SerializedAttributionCollection {\n\t\tconst allCollectionSpecs: IAttributionCollectionSpec<AttributionKey>[] = [];\n\n\t\tconst allChannelNames = new Set<string>();\n\t\tfor (const segment of segments) {\n\t\t\tconst collection =\n\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\tsegment.attribution ?? new AttributionCollection(segment.cachedLength, null);\n\t\t\tconst spec = collection.getAll();\n\t\t\tallCollectionSpecs.push(spec);\n\t\t\tif (spec.channels) {\n\t\t\t\tfor (const name of Object.keys(spec.channels)) {\n\t\t\t\t\tallChannelNames.add(name);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst extractSequenceOffsets = (\n\t\t\tgetSpecEntries: (\n\t\t\t\tspec: IAttributionCollectionSpec<AttributionKey>,\n\t\t\t) => Iterable<{ offset: number; key: AttributionKey | null }>,\n\t\t): SerializedAttributionCollection => {\n\t\t\tconst posBreakpoints: number[] = [];\n\t\t\tconst seqs: (number | AttributionKey | null)[] = [];\n\t\t\tlet mostRecentAttributionKey: AttributionKey | null | undefined;\n\t\t\tlet cumulativePos = 0;\n\n\t\t\tfor (const spec of allCollectionSpecs) {\n\t\t\t\tfor (const { offset, key } of getSpecEntries(spec)) {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tkey?.type !== \"local\",\n\t\t\t\t\t\t0x5c1 /* local attribution keys should never be put in summaries */,\n\t\t\t\t\t);\n\t\t\t\t\tif (\n\t\t\t\t\t\tmostRecentAttributionKey === undefined ||\n\t\t\t\t\t\t!areEqualAttributionKeys(key, mostRecentAttributionKey)\n\t\t\t\t\t) {\n\t\t\t\t\t\tposBreakpoints.push(offset + cumulativePos);\n\t\t\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\t\t\tseqs.push(key ? (key.type === \"op\" ? key.seq : key) : null);\n\t\t\t\t\t}\n\t\t\t\t\tmostRecentAttributionKey = key;\n\t\t\t\t}\n\n\t\t\t\tcumulativePos += spec.length;\n\t\t\t}\n\n\t\t\treturn { seqs, posBreakpoints, length: cumulativePos };\n\t\t};\n\n\t\tconst blobContents = extractSequenceOffsets((spec) => spec.root);\n\t\tif (allChannelNames.size > 0) {\n\t\t\tconst channels: { [name: string]: SequenceOffsets } = {};\n\t\t\tfor (const name of allChannelNames) {\n\t\t\t\tconst { posBreakpoints, seqs } = extractSequenceOffsets(\n\t\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\t\t(spec) => spec.channels?.[name] ?? [{ offset: 0, key: null }],\n\t\t\t\t);\n\t\t\t\tchannels[name] = { posBreakpoints, seqs };\n\t\t\t}\n\t\t\tblobContents.channels = channels;\n\t\t}\n\n\t\treturn blobContents;\n\t}\n}\n"]}
@@ -49,7 +49,7 @@ function _validateReferenceType(refType) {
49
49
  */
50
50
  class LocalReference {
51
51
  get trackingCollection() {
52
- return (this._trackingCollection ?? (this._trackingCollection = new mergeTreeTracking_js_1.TrackingGroupCollection(this)));
52
+ return (this._trackingCollection ??= new mergeTreeTracking_js_1.TrackingGroupCollection(this));
53
53
  }
54
54
  constructor(refType = ops_js_1.ReferenceType.Simple, properties, slidingPreference = exports.SlidingPreference.FORWARD, canSlideToEndpoint) {
55
55
  this.refType = refType;
@@ -164,7 +164,7 @@ class LocalReferenceCollection {
164
164
  validateRefCount?.(seg2.localRefs);
165
165
  }
166
166
  static setOrGet(segment) {
167
- return (segment.localRefs ?? (segment.localRefs = new LocalReferenceCollection(segment)));
167
+ return (segment.localRefs ??= new LocalReferenceCollection(segment));
168
168
  }
169
169
  constructor(
170
170
  /**
@@ -360,11 +360,10 @@ class LocalReferenceCollection {
360
360
  * @remarks This method should only be called by mergeTree.
361
361
  */
362
362
  addBeforeTombstones(...refs) {
363
- var _a;
364
363
  const beforeRefs = this.refsByOffset[0]?.before ?? new index_js_1.DoublyLinkedList();
365
364
  if (this.refsByOffset[0]?.before === undefined) {
366
- const refsAtOffset = ((_a = this.refsByOffset)[0] ?? (_a[0] = { before: beforeRefs }));
367
- refsAtOffset.before ?? (refsAtOffset.before = beforeRefs);
365
+ const refsAtOffset = (this.refsByOffset[0] ??= { before: beforeRefs });
366
+ refsAtOffset.before ??= beforeRefs;
368
367
  }
369
368
  let precedingRef;
370
369
  for (const iterable of refs) {
@@ -395,12 +394,11 @@ class LocalReferenceCollection {
395
394
  * @remarks This method should only be called by mergeTree.
396
395
  */
397
396
  addAfterTombstones(...refs) {
398
- var _a;
399
397
  const lastOffset = this.segment.cachedLength - 1;
400
398
  const afterRefs = this.refsByOffset[lastOffset]?.after ?? new index_js_1.DoublyLinkedList();
401
399
  if (this.refsByOffset[lastOffset]?.after === undefined) {
402
- const refsAtOffset = ((_a = this.refsByOffset)[lastOffset] ?? (_a[lastOffset] = { after: afterRefs }));
403
- refsAtOffset.after ?? (refsAtOffset.after = afterRefs);
400
+ const refsAtOffset = (this.refsByOffset[lastOffset] ??= { after: afterRefs });
401
+ refsAtOffset.after ??= afterRefs;
404
402
  }
405
403
  for (const iterable of refs) {
406
404
  for (const lref of iterable) {
@@ -1 +1 @@
1
- {"version":3,"file":"localReference.js","sourceRoot":"","sources":["../src/localReference.ts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AC,CAAC,SAAS,EACzC,OAAO,CACP,CAAC;QACH,CAAC,CAAC;QACF,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,OAAO,MAAM,IAAI,CAAC,IAAI,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;YACzD,OAAO,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACnC,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC;gBAC5E,IAAI,SAAS,EAAE,IAAI,KAAK,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC;oBAC3E,OAAO,KAAK,CAAC;gBACd,CAAC;YACF,CAAC;YACD,MAAM,IAAI,SAAS,CAAC;YACpB,eAAe,CAAC,IAAI,CACnB,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,EACjC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,EAC7B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,KAAK,CAChC,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AA5YD,4DA4YC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { DoublyLinkedList, ListNode, walkList } from \"./collections/index.js\";\nimport { type ISegmentInternal } from \"./mergeTreeNodes.js\";\nimport { TrackingGroup, TrackingGroupCollection } from \"./mergeTreeTracking.js\";\nimport { ReferenceType } from \"./ops.js\";\nimport { PropertySet, addProperties } from \"./properties.js\";\nimport { ReferencePosition, refTypeIncludesFlag } from \"./referencePositions.js\";\n\n/**\n * Dictates the preferential direction for a {@link ReferencePosition} to slide\n * in a merge-tree\n * @legacy\n * @alpha\n */\nexport const SlidingPreference = {\n\t/**\n\t * Prefer sliding towards the start of the tree\n\t */\n\tBACKWARD: 0,\n\t/**\n\t * Prefer sliding towards the end of the tree\n\t */\n\tFORWARD: 1,\n} as const;\n\n/**\n * Dictates the preferential direction for a {@link ReferencePosition} to slide\n * in a merge-tree\n * @legacy\n * @alpha\n */\nexport type SlidingPreference = (typeof SlidingPreference)[keyof typeof SlidingPreference];\n\nfunction _validateReferenceType(refType: ReferenceType): void {\n\tlet exclusiveCount = 0;\n\tif (refTypeIncludesFlag(refType, ReferenceType.Transient)) {\n\t\t++exclusiveCount;\n\t}\n\tif (refTypeIncludesFlag(refType, ReferenceType.SlideOnRemove)) {\n\t\t++exclusiveCount;\n\t}\n\tif (refTypeIncludesFlag(refType, ReferenceType.StayOnRemove)) {\n\t\t++exclusiveCount;\n\t}\n\tif (exclusiveCount > 1) {\n\t\tthrow new UsageError(\n\t\t\t\"Reference types can only be one of Transient, SlideOnRemove, and StayOnRemove\",\n\t\t);\n\t}\n}\n/**\n * @sealed\n * @legacy\n * @alpha\n */\nexport interface LocalReferencePosition extends ReferencePosition {\n\tcallbacks?: Partial<\n\t\tRecord<\"beforeSlide\" | \"afterSlide\", (ref: LocalReferencePosition) => void>\n\t>;\n\treadonly trackingCollection: TrackingGroupCollection;\n\t/**\n\t * Whether or not this reference position can slide onto one of the two\n\t * special segments representing the position before or after the tree\n\t */\n\treadonly canSlideToEndpoint?: boolean;\n\n\t/**\n\t * @param newProps - Properties to add to this reference.\n\t * @remarks Note that merge-tree does not broadcast changes to other clients. It is up to the consumer\n\t * to ensure broadcast happens if that is desired.\n\t */\n\taddProperties(newProps: PropertySet): void;\n}\n\n/**\n * @privateRemarks This should not be exported outside merge tree.\n * @internal\n */\nclass LocalReference implements LocalReferencePosition {\n\tpublic properties: PropertySet | undefined;\n\n\tprivate segment: ISegmentInternal | undefined;\n\tprivate offset: number = 0;\n\tprivate listNode: ListNode<LocalReference> | undefined;\n\n\tpublic callbacks?:\n\t\t| Partial<Record<\"beforeSlide\" | \"afterSlide\", (ref: LocalReferencePosition) => void>>\n\t\t| undefined;\n\tprivate _trackingCollection?: TrackingGroupCollection;\n\tpublic get trackingCollection(): TrackingGroupCollection {\n\t\treturn (this._trackingCollection ??= new TrackingGroupCollection(this));\n\t}\n\n\tconstructor(\n\t\tpublic refType = ReferenceType.Simple,\n\t\tproperties?: PropertySet,\n\t\tpublic readonly slidingPreference: SlidingPreference = SlidingPreference.FORWARD,\n\t\tpublic readonly canSlideToEndpoint?: boolean,\n\t) {\n\t\t_validateReferenceType(refType);\n\t\tthis.properties = properties;\n\t}\n\n\tpublic link(\n\t\tsegment: ISegmentInternal | undefined,\n\t\toffset: number,\n\t\tlistNode: ListNode<LocalReference> | undefined,\n\t): void {\n\t\tif (listNode !== this.listNode && this.listNode !== undefined) {\n\t\t\tthis.segment?.localRefs?.removeLocalRef(this);\n\t\t}\n\t\tthis.listNode = listNode;\n\n\t\tif (segment !== this.segment) {\n\t\t\tconst groups: TrackingGroup[] = [];\n\t\t\tfor (const tg of this.trackingCollection.trackingGroups) {\n\t\t\t\ttg.unlink(this);\n\t\t\t\tgroups.push(tg);\n\t\t\t}\n\n\t\t\tthis.segment = segment;\n\n\t\t\tfor (const tg of groups) tg.link(this);\n\t\t}\n\t\tthis.offset = offset;\n\t}\n\n\tpublic isLeaf(): this is ISegmentInternal {\n\t\treturn false;\n\t}\n\n\tpublic addProperties(newProps: PropertySet): void {\n\t\tthis.properties = addProperties(this.properties, newProps);\n\t}\n\n\tpublic getSegment(): ISegmentInternal | undefined {\n\t\treturn this.segment;\n\t}\n\n\tpublic getOffset(): number {\n\t\treturn this.offset;\n\t}\n\n\tpublic getListNode(): ListNode<LocalReference> | undefined {\n\t\treturn this.listNode;\n\t}\n\n\tpublic getProperties(): PropertySet | undefined {\n\t\treturn this.properties;\n\t}\n}\n\n/**\n * Creates a new detached local reference.\n * @internal\n */\nexport function createDetachedLocalReferencePosition(\n\tslidingPreference: SlidingPreference | undefined,\n\trefType?: ReferenceType,\n): LocalReferencePosition {\n\treturn new LocalReference(refType, undefined, slidingPreference);\n}\n\ninterface IRefsAtOffset {\n\tbefore?: DoublyLinkedList<LocalReference>;\n\tat?: DoublyLinkedList<LocalReference>;\n\tafter?: DoublyLinkedList<LocalReference>;\n}\n\nfunction assertLocalReferences(lref: unknown): asserts lref is LocalReference {\n\tassert(lref instanceof LocalReference, 0x2e0 /* \"lref not a Local Reference\" */);\n}\n\n/**\n * Determines if the given function is true for any position within the collection.\n */\nexport function anyLocalReferencePosition(\n\tcollection: LocalReferenceCollection,\n\tfunc: (pos: LocalReferencePosition) => boolean,\n): boolean {\n\tfor (const pos of collection) {\n\t\tif (func(pos)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Finds the local reference positions that satisfy the given predicate.\n */\nexport function* filterLocalReferencePositions(\n\tcollection: LocalReferenceCollection,\n\tpredicate: (pos: LocalReferencePosition) => boolean,\n): Generator<LocalReferencePosition> {\n\tfor (const pos of collection) {\n\t\tif (predicate(pos)) {\n\t\t\tyield pos;\n\t\t}\n\t}\n}\n\n/**\n * Injectable hook for validating that the refCount property matches the\n * expected value\n */\nlet validateRefCount: ((collection?: LocalReferenceCollection) => void) | undefined;\n\nexport function setValidateRefCount(\n\tcb?: (collection?: LocalReferenceCollection) => void,\n): void {\n\tvalidateRefCount = cb;\n}\n\n/**\n * Represents a collection of {@link LocalReferencePosition}s associated with\n * one segment in a merge-tree.\n * Represents a collection of {@link LocalReferencePosition}s associated with one segment in a merge-tree.\n * @sealed\n *\n * @internal\n */\nexport class LocalReferenceCollection {\n\tpublic static append(seg1: ISegmentInternal, seg2: ISegmentInternal): void {\n\t\tif (seg2.localRefs && !seg2.localRefs.empty) {\n\t\t\tif (!seg1.localRefs) {\n\t\t\t\tseg1.localRefs = new LocalReferenceCollection(seg1);\n\t\t\t}\n\t\t\tassert(\n\t\t\t\tseg1.localRefs.refsByOffset.length === seg1.cachedLength,\n\t\t\t\t0x2be /* \"LocalReferences array contains a gap\" */,\n\t\t\t);\n\t\t\tseg1.localRefs.append(seg2.localRefs);\n\t\t} else if (seg1.localRefs) {\n\t\t\t// Since creating the LocalReferenceCollection, we may have appended\n\t\t\t// segments that had no local references. Account for them now by padding the array.\n\t\t\tseg1.localRefs.refsByOffset.length += seg2.cachedLength;\n\t\t}\n\t\tvalidateRefCount?.(seg1.localRefs);\n\t\tvalidateRefCount?.(seg2.localRefs);\n\t}\n\n\tpublic static setOrGet(segment: ISegmentInternal): LocalReferenceCollection {\n\t\treturn (segment.localRefs ??= new LocalReferenceCollection(segment));\n\t}\n\n\tprivate readonly refsByOffset: (IRefsAtOffset | undefined)[];\n\tprivate refCount: number = 0;\n\n\tprivate constructor(\n\t\t/**\n\t\t * The segment this `LocalReferenceCollection` is associated with.\n\t\t */\n\t\tprivate readonly segment: ISegmentInternal,\n\t\tinitialRefsByfOffset: (IRefsAtOffset | undefined)[] = Array.from({\n\t\t\tlength: segment.cachedLength,\n\t\t}),\n\t) {\n\t\t// Since javascript arrays are sparse the above won't populate any of the\n\t\t// indices, but it will ensure the length property of the array matches\n\t\t// the length of the segment.\n\t\tthis.refsByOffset = initialRefsByfOffset;\n\t}\n\n\t/**\n\t * Returns an iterator over this LocalReferenceCollection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic [Symbol.iterator](): {\n\t\tnext(): IteratorResult<LocalReferencePosition>;\n\t\t[Symbol.iterator](): IterableIterator<LocalReferencePosition>;\n\t} {\n\t\tconst subiterators: IterableIterator<ListNode<LocalReferencePosition>>[] = [];\n\t\tfor (const refs of this.refsByOffset) {\n\t\t\tif (refs) {\n\t\t\t\tif (refs.before) {\n\t\t\t\t\tsubiterators.push(refs.before[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t\tif (refs.at) {\n\t\t\t\t\tsubiterators.push(refs.at[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t\tif (refs.after) {\n\t\t\t\t\tsubiterators.push(refs.after[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<LocalReferencePosition> {\n\t\t\t\twhile (subiterators.length > 0) {\n\t\t\t\t\tconst next = subiterators[0].next();\n\t\t\t\t\tif (next.done === true) {\n\t\t\t\t\t\tsubiterators.shift();\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn { done: next.done, value: next.value.data };\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t},\n\t\t\t[Symbol.iterator](): {\n\t\t\t\tnext(): IteratorResult<LocalReferencePosition>;\n\t\t\t\t[Symbol.iterator](): IterableIterator<LocalReferencePosition>;\n\t\t\t} {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Determines if the collection has no references in it.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic get empty(): boolean {\n\t\tvalidateRefCount?.(this);\n\t\treturn this.refCount === 0;\n\t}\n\n\t/**\n\t * Creates a new local reference.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic createLocalRef(\n\t\toffset: number,\n\t\trefType: ReferenceType,\n\t\tproperties: PropertySet | undefined,\n\t\tslidingPreference?: SlidingPreference,\n\t\tcanSlideToEndpoint?: boolean,\n\t): LocalReferencePosition {\n\t\tconst ref = new LocalReference(refType, properties, slidingPreference, canSlideToEndpoint);\n\t\tref.link(this.segment, offset, undefined);\n\t\tif (!refTypeIncludesFlag(ref, ReferenceType.Transient)) {\n\t\t\tthis.addLocalRef(ref, offset);\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t\treturn ref;\n\t}\n\n\t/**\n\t * Adds a local reference to the collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addLocalRef(lref: LocalReferencePosition, offset: number): void {\n\t\tassertLocalReferences(lref);\n\t\tassert(\n\t\t\toffset < this.segment.cachedLength,\n\t\t\t0x348 /* offset cannot be beyond segment length */,\n\t\t);\n\t\tif (refTypeIncludesFlag(lref, ReferenceType.Transient)) {\n\t\t\tlref.link(this.segment, offset, undefined);\n\t\t} else {\n\t\t\tconst refsAtOffset = (this.refsByOffset[offset] = this.refsByOffset[offset] ?? {\n\t\t\t\tat: new DoublyLinkedList(),\n\t\t\t});\n\t\t\tconst atRefs = (refsAtOffset.at = refsAtOffset.at ?? new DoublyLinkedList());\n\n\t\t\tlref.link(this.segment, offset, atRefs.push(lref).last);\n\n\t\t\tthis.refCount++;\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Removes a local reference from the collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic removeLocalRef(lref: LocalReferencePosition): LocalReferencePosition | undefined {\n\t\tif (this.has(lref)) {\n\t\t\tassertLocalReferences(lref);\n\n\t\t\tconst node = lref.getListNode();\n\t\t\tnode?.list?.remove(node);\n\n\t\t\tlref.link(undefined, 0, undefined);\n\n\t\t\tthis.refCount--;\n\t\t\tvalidateRefCount?.(this);\n\t\t\treturn lref;\n\t\t}\n\t}\n\n\t/**\n\t *\n\t * Called by 'append()' implementations to append local refs from the given 'other' segment to the\n\t * end of 'this' segment.\n\t *\n\t * Note: This method should be invoked after the caller has ensured that segments can be merged,\n\t * but before 'this' segment's cachedLength has changed, or the adjustment to the local refs\n\t * will be incorrect.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic append(other: LocalReferenceCollection): void {\n\t\tif (!other || other.empty) {\n\t\t\treturn;\n\t\t}\n\t\tthis.refCount += other.refCount;\n\t\tother.refCount = 0;\n\t\tfor (const lref of other) {\n\t\t\tassertLocalReferences(lref);\n\t\t\tlref.link(this.segment, lref.getOffset() + this.refsByOffset.length, lref.getListNode());\n\t\t}\n\n\t\tthis.refsByOffset.push(...other.refsByOffset);\n\t\tother.refsByOffset.length = 0;\n\t}\n\t/**\n\t * Returns true of the local reference is in the collection, otherwise false.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic has(lref: ReferencePosition): boolean {\n\t\tif (\n\t\t\t!(lref instanceof LocalReference) ||\n\t\t\trefTypeIncludesFlag(lref, ReferenceType.Transient)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\tconst seg = lref.getSegment();\n\t\tif (seg !== this.segment) {\n\t\t\treturn false;\n\t\t}\n\t\t// we should be able to optimize finding the\n\t\t// list head\n\t\tconst listNode = lref.getListNode();\n\t\tif (listNode === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\tconst offset = lref.getOffset();\n\t\tconst refsAtOffset = this.refsByOffset[offset];\n\t\tif (\n\t\t\t!!refsAtOffset?.before?.includes(listNode) ||\n\t\t\t!!refsAtOffset?.at?.includes(listNode) ||\n\t\t\t!!refsAtOffset?.after?.includes(listNode)\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Splits this `LocalReferenceCollection` into the intervals [0, offset) and [offset, originalLength).\n\t * Local references in the former half of this split will remain associated with the segment used on construction.\n\t * Local references in the latter half of this split will be transferred to `splitSeg`,\n\t * and its `localRefs` field will be set.\n\t * @param offset - Offset into the original segment at which the collection should be split\n\t * @param splitSeg - Split segment which originally corresponded to the indices [offset, originalLength)\n\t * before splitting.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic split(offset: number, splitSeg: ISegmentInternal): void {\n\t\tif (this.empty) {\n\t\t\t// shrink the offset array when empty and splitting\n\t\t\tthis.refsByOffset.length = offset;\n\t\t} else {\n\t\t\tconst localRefs = new LocalReferenceCollection(\n\t\t\t\tsplitSeg,\n\t\t\t\tthis.refsByOffset.splice(offset, this.refsByOffset.length - offset),\n\t\t\t);\n\n\t\t\tsplitSeg.localRefs = localRefs;\n\t\t\tfor (const lref of localRefs) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tlref.link(splitSeg, lref.getOffset() - offset, lref.getListNode());\n\t\t\t\tthis.refCount--;\n\t\t\t\tlocalRefs.refCount++;\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Insert a reference before tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addBeforeTombstones(...refs: Iterable<LocalReferencePosition>[]): void {\n\t\tconst beforeRefs = this.refsByOffset[0]?.before ?? new DoublyLinkedList();\n\n\t\tif (this.refsByOffset[0]?.before === undefined) {\n\t\t\tconst refsAtOffset = (this.refsByOffset[0] ??= { before: beforeRefs });\n\t\t\trefsAtOffset.before ??= beforeRefs;\n\t\t}\n\n\t\tlet precedingRef: ListNode<LocalReference> | undefined;\n\t\tfor (const iterable of refs) {\n\t\t\tfor (const lref of iterable) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tif (refTypeIncludesFlag(lref, ReferenceType.StayOnRemove)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if (refTypeIncludesFlag(lref, ReferenceType.SlideOnRemove)) {\n\t\t\t\t\tlref.callbacks?.beforeSlide?.(lref);\n\t\t\t\t\tprecedingRef =\n\t\t\t\t\t\tprecedingRef === undefined\n\t\t\t\t\t\t\t? beforeRefs.unshift(lref)?.first\n\t\t\t\t\t\t\t: beforeRefs.insertAfter(precedingRef, lref)?.first;\n\t\t\t\t\tlref.link(this.segment, 0, precedingRef);\n\t\t\t\t\tthis.refCount++;\n\t\t\t\t\tlref.callbacks?.afterSlide?.(lref);\n\t\t\t\t} else {\n\t\t\t\t\tlref.link(undefined, 0, undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\t/**\n\t * Insert a reference after tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addAfterTombstones(...refs: Iterable<LocalReferencePosition>[]): void {\n\t\tconst lastOffset = this.segment.cachedLength - 1;\n\t\tconst afterRefs = this.refsByOffset[lastOffset]?.after ?? new DoublyLinkedList();\n\n\t\tif (this.refsByOffset[lastOffset]?.after === undefined) {\n\t\t\tconst refsAtOffset = (this.refsByOffset[lastOffset] ??= { after: afterRefs });\n\t\t\trefsAtOffset.after ??= afterRefs;\n\t\t}\n\n\t\tfor (const iterable of refs) {\n\t\t\tfor (const lref of iterable) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tif (refTypeIncludesFlag(lref, ReferenceType.StayOnRemove)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if (refTypeIncludesFlag(lref, ReferenceType.SlideOnRemove)) {\n\t\t\t\t\tlref.callbacks?.beforeSlide?.(lref);\n\t\t\t\t\tafterRefs.push(lref);\n\t\t\t\t\tlref.link(this.segment, lastOffset, afterRefs.last);\n\t\t\t\t\tthis.refCount++;\n\t\t\t\t\tlref.callbacks?.afterSlide?.(lref);\n\t\t\t\t} else {\n\t\t\t\t\tlref.link(undefined, 0, undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Determines if a reference is after tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic isAfterTombstone(lref: LocalReferencePosition): boolean {\n\t\tconst after = this.refsByOffset[lref.getOffset()]?.after;\n\t\tif (after) {\n\t\t\tassertLocalReferences(lref);\n\t\t\treturn after.includes(lref.getListNode());\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Walks all of the references in a collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic walkReferences(\n\t\tvisitor: (lref: LocalReferencePosition) => boolean | void | undefined,\n\t\tstart?: LocalReferencePosition,\n\t\tforward: boolean = true,\n\t): boolean {\n\t\tif (start !== undefined) {\n\t\t\tif (!this.has(start)) {\n\t\t\t\tthrow new UsageError(\"start must be in collection\");\n\t\t\t}\n\t\t\tassertLocalReferences(start);\n\t\t}\n\t\tlet offset = start?.getOffset() ?? (forward ? 0 : this.segment.cachedLength - 1);\n\n\t\tconst offsetPositions: DoublyLinkedList<IRefsAtOffset[keyof IRefsAtOffset]> =\n\t\t\tnew DoublyLinkedList();\n\t\toffsetPositions.push(\n\t\t\tthis.refsByOffset[offset]?.before,\n\t\t\tthis.refsByOffset[offset]?.at,\n\t\t\tthis.refsByOffset[offset]?.after,\n\t\t);\n\n\t\tconst startNode = start?.getListNode();\n\t\tconst startList = startNode?.list;\n\n\t\tif (startList !== undefined) {\n\t\t\tif (forward) {\n\t\t\t\twhile (!offsetPositions.empty && offsetPositions.first !== startNode) {\n\t\t\t\t\toffsetPositions.shift();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\twhile (!offsetPositions.empty && offsetPositions.last !== startNode) {\n\t\t\t\t\toffsetPositions.pop();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst listWalker = (pos: DoublyLinkedList<LocalReference>): boolean => {\n\t\t\treturn walkList(\n\t\t\t\tpos,\n\t\t\t\t(node) => visitor(node.data),\n\t\t\t\tstartList === pos ? startNode : undefined,\n\t\t\t\tforward,\n\t\t\t);\n\t\t};\n\t\tconst increment = forward ? 1 : -1;\n\t\twhile (offset >= 0 && offset < this.refsByOffset.length) {\n\t\t\twhile (offsetPositions.length > 0) {\n\t\t\t\tconst offsetPos = forward ? offsetPositions.shift() : offsetPositions.pop();\n\t\t\t\tif (offsetPos?.data !== undefined && listWalker(offsetPos.data) === false) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\toffset += increment;\n\t\t\toffsetPositions.push(\n\t\t\t\tthis.refsByOffset[offset]?.before,\n\t\t\t\tthis.refsByOffset[offset]?.at,\n\t\t\t\tthis.refsByOffset[offset]?.after,\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n}\n"]}
1
+ {"version":3,"file":"localReference.js","sourceRoot":"","sources":["../src/localReference.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,uEAAsE;AA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AM,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;YACzD,OAAO,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACnC,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC;gBAC5E,IAAI,SAAS,EAAE,IAAI,KAAK,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC;oBAC3E,OAAO,KAAK,CAAC;gBACd,CAAC;YACF,CAAC;YACD,MAAM,IAAI,SAAS,CAAC;YACpB,eAAe,CAAC,IAAI,CACnB,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,EACjC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,EAC7B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,KAAK,CAChC,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AA5YD,4DA4YC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { DoublyLinkedList, ListNode, walkList } from \"./collections/index.js\";\nimport { type ISegmentInternal } from \"./mergeTreeNodes.js\";\nimport { TrackingGroup, TrackingGroupCollection } from \"./mergeTreeTracking.js\";\nimport { ReferenceType } from \"./ops.js\";\nimport { PropertySet, addProperties } from \"./properties.js\";\nimport { ReferencePosition, refTypeIncludesFlag } from \"./referencePositions.js\";\n\n/**\n * Dictates the preferential direction for a {@link ReferencePosition} to slide\n * in a merge-tree\n * @legacy\n * @alpha\n */\nexport const SlidingPreference = {\n\t/**\n\t * Prefer sliding towards the start of the tree\n\t */\n\tBACKWARD: 0,\n\t/**\n\t * Prefer sliding towards the end of the tree\n\t */\n\tFORWARD: 1,\n} as const;\n\n/**\n * Dictates the preferential direction for a {@link ReferencePosition} to slide\n * in a merge-tree\n * @legacy\n * @alpha\n */\nexport type SlidingPreference = (typeof SlidingPreference)[keyof typeof SlidingPreference];\n\nfunction _validateReferenceType(refType: ReferenceType): void {\n\tlet exclusiveCount = 0;\n\tif (refTypeIncludesFlag(refType, ReferenceType.Transient)) {\n\t\t++exclusiveCount;\n\t}\n\tif (refTypeIncludesFlag(refType, ReferenceType.SlideOnRemove)) {\n\t\t++exclusiveCount;\n\t}\n\tif (refTypeIncludesFlag(refType, ReferenceType.StayOnRemove)) {\n\t\t++exclusiveCount;\n\t}\n\tif (exclusiveCount > 1) {\n\t\tthrow new UsageError(\n\t\t\t\"Reference types can only be one of Transient, SlideOnRemove, and StayOnRemove\",\n\t\t);\n\t}\n}\n/**\n * @sealed\n * @legacy\n * @alpha\n */\nexport interface LocalReferencePosition extends ReferencePosition {\n\tcallbacks?: Partial<\n\t\tRecord<\"beforeSlide\" | \"afterSlide\", (ref: LocalReferencePosition) => void>\n\t>;\n\treadonly trackingCollection: TrackingGroupCollection;\n\t/**\n\t * Whether or not this reference position can slide onto one of the two\n\t * special segments representing the position before or after the tree\n\t */\n\treadonly canSlideToEndpoint?: boolean;\n\n\t/**\n\t * @param newProps - Properties to add to this reference.\n\t * @remarks Note that merge-tree does not broadcast changes to other clients. It is up to the consumer\n\t * to ensure broadcast happens if that is desired.\n\t */\n\taddProperties(newProps: PropertySet): void;\n}\n\n/**\n * @privateRemarks This should not be exported outside merge tree.\n * @internal\n */\nclass LocalReference implements LocalReferencePosition {\n\tpublic properties: PropertySet | undefined;\n\n\tprivate segment: ISegmentInternal | undefined;\n\tprivate offset: number = 0;\n\tprivate listNode: ListNode<LocalReference> | undefined;\n\n\tpublic callbacks?:\n\t\t| Partial<Record<\"beforeSlide\" | \"afterSlide\", (ref: LocalReferencePosition) => void>>\n\t\t| undefined;\n\tprivate _trackingCollection?: TrackingGroupCollection;\n\tpublic get trackingCollection(): TrackingGroupCollection {\n\t\treturn (this._trackingCollection ??= new TrackingGroupCollection(this));\n\t}\n\n\tconstructor(\n\t\tpublic refType = ReferenceType.Simple,\n\t\tproperties?: PropertySet,\n\t\tpublic readonly slidingPreference: SlidingPreference = SlidingPreference.FORWARD,\n\t\tpublic readonly canSlideToEndpoint?: boolean,\n\t) {\n\t\t_validateReferenceType(refType);\n\t\tthis.properties = properties;\n\t}\n\n\tpublic link(\n\t\tsegment: ISegmentInternal | undefined,\n\t\toffset: number,\n\t\tlistNode: ListNode<LocalReference> | undefined,\n\t): void {\n\t\tif (listNode !== this.listNode && this.listNode !== undefined) {\n\t\t\tthis.segment?.localRefs?.removeLocalRef(this);\n\t\t}\n\t\tthis.listNode = listNode;\n\n\t\tif (segment !== this.segment) {\n\t\t\tconst groups: TrackingGroup[] = [];\n\t\t\tfor (const tg of this.trackingCollection.trackingGroups) {\n\t\t\t\ttg.unlink(this);\n\t\t\t\tgroups.push(tg);\n\t\t\t}\n\n\t\t\tthis.segment = segment;\n\n\t\t\tfor (const tg of groups) tg.link(this);\n\t\t}\n\t\tthis.offset = offset;\n\t}\n\n\tpublic isLeaf(): this is ISegmentInternal {\n\t\treturn false;\n\t}\n\n\tpublic addProperties(newProps: PropertySet): void {\n\t\tthis.properties = addProperties(this.properties, newProps);\n\t}\n\n\tpublic getSegment(): ISegmentInternal | undefined {\n\t\treturn this.segment;\n\t}\n\n\tpublic getOffset(): number {\n\t\treturn this.offset;\n\t}\n\n\tpublic getListNode(): ListNode<LocalReference> | undefined {\n\t\treturn this.listNode;\n\t}\n\n\tpublic getProperties(): PropertySet | undefined {\n\t\treturn this.properties;\n\t}\n}\n\n/**\n * Creates a new detached local reference.\n * @internal\n */\nexport function createDetachedLocalReferencePosition(\n\tslidingPreference: SlidingPreference | undefined,\n\trefType?: ReferenceType,\n): LocalReferencePosition {\n\treturn new LocalReference(refType, undefined, slidingPreference);\n}\n\ninterface IRefsAtOffset {\n\tbefore?: DoublyLinkedList<LocalReference>;\n\tat?: DoublyLinkedList<LocalReference>;\n\tafter?: DoublyLinkedList<LocalReference>;\n}\n\nfunction assertLocalReferences(lref: unknown): asserts lref is LocalReference {\n\tassert(lref instanceof LocalReference, 0x2e0 /* \"lref not a Local Reference\" */);\n}\n\n/**\n * Determines if the given function is true for any position within the collection.\n */\nexport function anyLocalReferencePosition(\n\tcollection: LocalReferenceCollection,\n\tfunc: (pos: LocalReferencePosition) => boolean,\n): boolean {\n\tfor (const pos of collection) {\n\t\tif (func(pos)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Finds the local reference positions that satisfy the given predicate.\n */\nexport function* filterLocalReferencePositions(\n\tcollection: LocalReferenceCollection,\n\tpredicate: (pos: LocalReferencePosition) => boolean,\n): Generator<LocalReferencePosition> {\n\tfor (const pos of collection) {\n\t\tif (predicate(pos)) {\n\t\t\tyield pos;\n\t\t}\n\t}\n}\n\n/**\n * Injectable hook for validating that the refCount property matches the\n * expected value\n */\nlet validateRefCount: ((collection?: LocalReferenceCollection) => void) | undefined;\n\nexport function setValidateRefCount(\n\tcb?: (collection?: LocalReferenceCollection) => void,\n): void {\n\tvalidateRefCount = cb;\n}\n\n/**\n * Represents a collection of {@link LocalReferencePosition}s associated with\n * one segment in a merge-tree.\n * Represents a collection of {@link LocalReferencePosition}s associated with one segment in a merge-tree.\n * @sealed\n *\n * @internal\n */\nexport class LocalReferenceCollection {\n\tpublic static append(seg1: ISegmentInternal, seg2: ISegmentInternal): void {\n\t\tif (seg2.localRefs && !seg2.localRefs.empty) {\n\t\t\tif (!seg1.localRefs) {\n\t\t\t\tseg1.localRefs = new LocalReferenceCollection(seg1);\n\t\t\t}\n\t\t\tassert(\n\t\t\t\tseg1.localRefs.refsByOffset.length === seg1.cachedLength,\n\t\t\t\t0x2be /* \"LocalReferences array contains a gap\" */,\n\t\t\t);\n\t\t\tseg1.localRefs.append(seg2.localRefs);\n\t\t} else if (seg1.localRefs) {\n\t\t\t// Since creating the LocalReferenceCollection, we may have appended\n\t\t\t// segments that had no local references. Account for them now by padding the array.\n\t\t\tseg1.localRefs.refsByOffset.length += seg2.cachedLength;\n\t\t}\n\t\tvalidateRefCount?.(seg1.localRefs);\n\t\tvalidateRefCount?.(seg2.localRefs);\n\t}\n\n\tpublic static setOrGet(segment: ISegmentInternal): LocalReferenceCollection {\n\t\treturn (segment.localRefs ??= new LocalReferenceCollection(segment));\n\t}\n\n\tprivate readonly refsByOffset: (IRefsAtOffset | undefined)[];\n\tprivate refCount: number = 0;\n\n\tprivate constructor(\n\t\t/**\n\t\t * The segment this `LocalReferenceCollection` is associated with.\n\t\t */\n\t\tprivate readonly segment: ISegmentInternal,\n\t\tinitialRefsByfOffset: (IRefsAtOffset | undefined)[] = Array.from({\n\t\t\tlength: segment.cachedLength,\n\t\t}),\n\t) {\n\t\t// Since javascript arrays are sparse the above won't populate any of the\n\t\t// indices, but it will ensure the length property of the array matches\n\t\t// the length of the segment.\n\t\tthis.refsByOffset = initialRefsByfOffset;\n\t}\n\n\t/**\n\t * Returns an iterator over this LocalReferenceCollection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic [Symbol.iterator](): {\n\t\tnext(): IteratorResult<LocalReferencePosition>;\n\t\t[Symbol.iterator](): IterableIterator<LocalReferencePosition>;\n\t} {\n\t\tconst subiterators: IterableIterator<ListNode<LocalReferencePosition>>[] = [];\n\t\tfor (const refs of this.refsByOffset) {\n\t\t\tif (refs) {\n\t\t\t\tif (refs.before) {\n\t\t\t\t\tsubiterators.push(refs.before[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t\tif (refs.at) {\n\t\t\t\t\tsubiterators.push(refs.at[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t\tif (refs.after) {\n\t\t\t\t\tsubiterators.push(refs.after[Symbol.iterator]());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst iterator = {\n\t\t\tnext(): IteratorResult<LocalReferencePosition> {\n\t\t\t\twhile (subiterators.length > 0) {\n\t\t\t\t\tconst next = subiterators[0].next();\n\t\t\t\t\tif (next.done === true) {\n\t\t\t\t\t\tsubiterators.shift();\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn { done: next.done, value: next.value.data };\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t},\n\t\t\t[Symbol.iterator](): {\n\t\t\t\tnext(): IteratorResult<LocalReferencePosition>;\n\t\t\t\t[Symbol.iterator](): IterableIterator<LocalReferencePosition>;\n\t\t\t} {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Determines if the collection has no references in it.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic get empty(): boolean {\n\t\tvalidateRefCount?.(this);\n\t\treturn this.refCount === 0;\n\t}\n\n\t/**\n\t * Creates a new local reference.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic createLocalRef(\n\t\toffset: number,\n\t\trefType: ReferenceType,\n\t\tproperties: PropertySet | undefined,\n\t\tslidingPreference?: SlidingPreference,\n\t\tcanSlideToEndpoint?: boolean,\n\t): LocalReferencePosition {\n\t\tconst ref = new LocalReference(refType, properties, slidingPreference, canSlideToEndpoint);\n\t\tref.link(this.segment, offset, undefined);\n\t\tif (!refTypeIncludesFlag(ref, ReferenceType.Transient)) {\n\t\t\tthis.addLocalRef(ref, offset);\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t\treturn ref;\n\t}\n\n\t/**\n\t * Adds a local reference to the collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addLocalRef(lref: LocalReferencePosition, offset: number): void {\n\t\tassertLocalReferences(lref);\n\t\tassert(\n\t\t\toffset < this.segment.cachedLength,\n\t\t\t0x348 /* offset cannot be beyond segment length */,\n\t\t);\n\t\tif (refTypeIncludesFlag(lref, ReferenceType.Transient)) {\n\t\t\tlref.link(this.segment, offset, undefined);\n\t\t} else {\n\t\t\tconst refsAtOffset = (this.refsByOffset[offset] = this.refsByOffset[offset] ?? {\n\t\t\t\tat: new DoublyLinkedList(),\n\t\t\t});\n\t\t\tconst atRefs = (refsAtOffset.at = refsAtOffset.at ?? new DoublyLinkedList());\n\n\t\t\tlref.link(this.segment, offset, atRefs.push(lref).last);\n\n\t\t\tthis.refCount++;\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Removes a local reference from the collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic removeLocalRef(lref: LocalReferencePosition): LocalReferencePosition | undefined {\n\t\tif (this.has(lref)) {\n\t\t\tassertLocalReferences(lref);\n\n\t\t\tconst node = lref.getListNode();\n\t\t\tnode?.list?.remove(node);\n\n\t\t\tlref.link(undefined, 0, undefined);\n\n\t\t\tthis.refCount--;\n\t\t\tvalidateRefCount?.(this);\n\t\t\treturn lref;\n\t\t}\n\t}\n\n\t/**\n\t *\n\t * Called by 'append()' implementations to append local refs from the given 'other' segment to the\n\t * end of 'this' segment.\n\t *\n\t * Note: This method should be invoked after the caller has ensured that segments can be merged,\n\t * but before 'this' segment's cachedLength has changed, or the adjustment to the local refs\n\t * will be incorrect.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic append(other: LocalReferenceCollection): void {\n\t\tif (!other || other.empty) {\n\t\t\treturn;\n\t\t}\n\t\tthis.refCount += other.refCount;\n\t\tother.refCount = 0;\n\t\tfor (const lref of other) {\n\t\t\tassertLocalReferences(lref);\n\t\t\tlref.link(this.segment, lref.getOffset() + this.refsByOffset.length, lref.getListNode());\n\t\t}\n\n\t\tthis.refsByOffset.push(...other.refsByOffset);\n\t\tother.refsByOffset.length = 0;\n\t}\n\t/**\n\t * Returns true of the local reference is in the collection, otherwise false.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic has(lref: ReferencePosition): boolean {\n\t\tif (\n\t\t\t!(lref instanceof LocalReference) ||\n\t\t\trefTypeIncludesFlag(lref, ReferenceType.Transient)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\tconst seg = lref.getSegment();\n\t\tif (seg !== this.segment) {\n\t\t\treturn false;\n\t\t}\n\t\t// we should be able to optimize finding the\n\t\t// list head\n\t\tconst listNode = lref.getListNode();\n\t\tif (listNode === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\tconst offset = lref.getOffset();\n\t\tconst refsAtOffset = this.refsByOffset[offset];\n\t\tif (\n\t\t\t!!refsAtOffset?.before?.includes(listNode) ||\n\t\t\t!!refsAtOffset?.at?.includes(listNode) ||\n\t\t\t!!refsAtOffset?.after?.includes(listNode)\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Splits this `LocalReferenceCollection` into the intervals [0, offset) and [offset, originalLength).\n\t * Local references in the former half of this split will remain associated with the segment used on construction.\n\t * Local references in the latter half of this split will be transferred to `splitSeg`,\n\t * and its `localRefs` field will be set.\n\t * @param offset - Offset into the original segment at which the collection should be split\n\t * @param splitSeg - Split segment which originally corresponded to the indices [offset, originalLength)\n\t * before splitting.\n\t *\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic split(offset: number, splitSeg: ISegmentInternal): void {\n\t\tif (this.empty) {\n\t\t\t// shrink the offset array when empty and splitting\n\t\t\tthis.refsByOffset.length = offset;\n\t\t} else {\n\t\t\tconst localRefs = new LocalReferenceCollection(\n\t\t\t\tsplitSeg,\n\t\t\t\tthis.refsByOffset.splice(offset, this.refsByOffset.length - offset),\n\t\t\t);\n\n\t\t\tsplitSeg.localRefs = localRefs;\n\t\t\tfor (const lref of localRefs) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tlref.link(splitSeg, lref.getOffset() - offset, lref.getListNode());\n\t\t\t\tthis.refCount--;\n\t\t\t\tlocalRefs.refCount++;\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Insert a reference before tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addBeforeTombstones(...refs: Iterable<LocalReferencePosition>[]): void {\n\t\tconst beforeRefs = this.refsByOffset[0]?.before ?? new DoublyLinkedList();\n\n\t\tif (this.refsByOffset[0]?.before === undefined) {\n\t\t\tconst refsAtOffset = (this.refsByOffset[0] ??= { before: beforeRefs });\n\t\t\trefsAtOffset.before ??= beforeRefs;\n\t\t}\n\n\t\tlet precedingRef: ListNode<LocalReference> | undefined;\n\t\tfor (const iterable of refs) {\n\t\t\tfor (const lref of iterable) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tif (refTypeIncludesFlag(lref, ReferenceType.StayOnRemove)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if (refTypeIncludesFlag(lref, ReferenceType.SlideOnRemove)) {\n\t\t\t\t\tlref.callbacks?.beforeSlide?.(lref);\n\t\t\t\t\tprecedingRef =\n\t\t\t\t\t\tprecedingRef === undefined\n\t\t\t\t\t\t\t? beforeRefs.unshift(lref)?.first\n\t\t\t\t\t\t\t: beforeRefs.insertAfter(precedingRef, lref)?.first;\n\t\t\t\t\tlref.link(this.segment, 0, precedingRef);\n\t\t\t\t\tthis.refCount++;\n\t\t\t\t\tlref.callbacks?.afterSlide?.(lref);\n\t\t\t\t} else {\n\t\t\t\t\tlref.link(undefined, 0, undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\t/**\n\t * Insert a reference after tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic addAfterTombstones(...refs: Iterable<LocalReferencePosition>[]): void {\n\t\tconst lastOffset = this.segment.cachedLength - 1;\n\t\tconst afterRefs = this.refsByOffset[lastOffset]?.after ?? new DoublyLinkedList();\n\n\t\tif (this.refsByOffset[lastOffset]?.after === undefined) {\n\t\t\tconst refsAtOffset = (this.refsByOffset[lastOffset] ??= { after: afterRefs });\n\t\t\trefsAtOffset.after ??= afterRefs;\n\t\t}\n\n\t\tfor (const iterable of refs) {\n\t\t\tfor (const lref of iterable) {\n\t\t\t\tassertLocalReferences(lref);\n\t\t\t\tif (refTypeIncludesFlag(lref, ReferenceType.StayOnRemove)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if (refTypeIncludesFlag(lref, ReferenceType.SlideOnRemove)) {\n\t\t\t\t\tlref.callbacks?.beforeSlide?.(lref);\n\t\t\t\t\tafterRefs.push(lref);\n\t\t\t\t\tlref.link(this.segment, lastOffset, afterRefs.last);\n\t\t\t\t\tthis.refCount++;\n\t\t\t\t\tlref.callbacks?.afterSlide?.(lref);\n\t\t\t\t} else {\n\t\t\t\t\tlref.link(undefined, 0, undefined);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvalidateRefCount?.(this);\n\t}\n\n\t/**\n\t * Determines if a reference is after tombstoned references.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic isAfterTombstone(lref: LocalReferencePosition): boolean {\n\t\tconst after = this.refsByOffset[lref.getOffset()]?.after;\n\t\tif (after) {\n\t\t\tassertLocalReferences(lref);\n\t\t\treturn after.includes(lref.getListNode());\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Walks all of the references in a collection.\n\t * @remarks This method should only be called by mergeTree.\n\t */\n\tpublic walkReferences(\n\t\tvisitor: (lref: LocalReferencePosition) => boolean | void | undefined,\n\t\tstart?: LocalReferencePosition,\n\t\tforward: boolean = true,\n\t): boolean {\n\t\tif (start !== undefined) {\n\t\t\tif (!this.has(start)) {\n\t\t\t\tthrow new UsageError(\"start must be in collection\");\n\t\t\t}\n\t\t\tassertLocalReferences(start);\n\t\t}\n\t\tlet offset = start?.getOffset() ?? (forward ? 0 : this.segment.cachedLength - 1);\n\n\t\tconst offsetPositions: DoublyLinkedList<IRefsAtOffset[keyof IRefsAtOffset]> =\n\t\t\tnew DoublyLinkedList();\n\t\toffsetPositions.push(\n\t\t\tthis.refsByOffset[offset]?.before,\n\t\t\tthis.refsByOffset[offset]?.at,\n\t\t\tthis.refsByOffset[offset]?.after,\n\t\t);\n\n\t\tconst startNode = start?.getListNode();\n\t\tconst startList = startNode?.list;\n\n\t\tif (startList !== undefined) {\n\t\t\tif (forward) {\n\t\t\t\twhile (!offsetPositions.empty && offsetPositions.first !== startNode) {\n\t\t\t\t\toffsetPositions.shift();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\twhile (!offsetPositions.empty && offsetPositions.last !== startNode) {\n\t\t\t\t\toffsetPositions.pop();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst listWalker = (pos: DoublyLinkedList<LocalReference>): boolean => {\n\t\t\treturn walkList(\n\t\t\t\tpos,\n\t\t\t\t(node) => visitor(node.data),\n\t\t\t\tstartList === pos ? startNode : undefined,\n\t\t\t\tforward,\n\t\t\t);\n\t\t};\n\t\tconst increment = forward ? 1 : -1;\n\t\twhile (offset >= 0 && offset < this.refsByOffset.length) {\n\t\t\twhile (offsetPositions.length > 0) {\n\t\t\t\tconst offsetPos = forward ? offsetPositions.shift() : offsetPositions.pop();\n\t\t\t\tif (offsetPos?.data !== undefined && listWalker(offsetPos.data) === false) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\toffset += increment;\n\t\t\toffsetPositions.push(\n\t\t\t\tthis.refsByOffset[offset]?.before,\n\t\t\t\tthis.refsByOffset[offset]?.at,\n\t\t\t\tthis.refsByOffset[offset]?.after,\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"mergeTree.d.ts","sourceRoot":"","sources":["../src/mergeTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAU,IAAI,EAAa,MAAM,qCAAqC,CAAC;AAG9E,OAAO,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAY,MAAM,wBA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