@fluidframework/merge-tree 2.0.0-internal.5.3.2 → 2.0.0-internal.6.0.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 (162) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/MergeTreeTextHelper.js +2 -2
  3. package/dist/MergeTreeTextHelper.js.map +1 -1
  4. package/dist/attributionCollection.js +13 -20
  5. package/dist/attributionCollection.js.map +1 -1
  6. package/dist/attributionPolicy.js +6 -8
  7. package/dist/attributionPolicy.js.map +1 -1
  8. package/dist/client.d.ts +0 -13
  9. package/dist/client.d.ts.map +1 -1
  10. package/dist/client.js +18 -31
  11. package/dist/client.js.map +1 -1
  12. package/dist/collections/list.js +2 -2
  13. package/dist/collections/list.js.map +1 -1
  14. package/dist/endOfTreeSegment.d.ts +1 -1
  15. package/dist/endOfTreeSegment.d.ts.map +1 -1
  16. package/dist/endOfTreeSegment.js +2 -3
  17. package/dist/endOfTreeSegment.js.map +1 -1
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +2 -7
  21. package/dist/index.js.map +1 -1
  22. package/dist/localReference.js +31 -40
  23. package/dist/localReference.js.map +1 -1
  24. package/dist/mergeTree.d.ts +10 -12
  25. package/dist/mergeTree.d.ts.map +1 -1
  26. package/dist/mergeTree.js +87 -259
  27. package/dist/mergeTree.js.map +1 -1
  28. package/dist/mergeTreeNodeWalk.js +4 -4
  29. package/dist/mergeTreeNodeWalk.js.map +1 -1
  30. package/dist/mergeTreeNodes.d.ts +14 -58
  31. package/dist/mergeTreeNodes.d.ts.map +1 -1
  32. package/dist/mergeTreeNodes.js +14 -42
  33. package/dist/mergeTreeNodes.js.map +1 -1
  34. package/dist/mergeTreeTracking.d.ts +0 -6
  35. package/dist/mergeTreeTracking.d.ts.map +1 -1
  36. package/dist/mergeTreeTracking.js +0 -9
  37. package/dist/mergeTreeTracking.js.map +1 -1
  38. package/dist/partialLengths.js +27 -30
  39. package/dist/partialLengths.js.map +1 -1
  40. package/dist/properties.js +3 -3
  41. package/dist/properties.js.map +1 -1
  42. package/dist/referencePositions.d.ts.map +1 -1
  43. package/dist/referencePositions.js +2 -16
  44. package/dist/referencePositions.js.map +1 -1
  45. package/dist/revertibles.js +20 -30
  46. package/dist/revertibles.js.map +1 -1
  47. package/dist/segmentGroupCollection.d.ts +0 -4
  48. package/dist/segmentGroupCollection.d.ts.map +1 -1
  49. package/dist/segmentGroupCollection.js +2 -12
  50. package/dist/segmentGroupCollection.js.map +1 -1
  51. package/dist/segmentPropertiesManager.d.ts.map +1 -1
  52. package/dist/segmentPropertiesManager.js +7 -13
  53. package/dist/segmentPropertiesManager.js.map +1 -1
  54. package/dist/snapshotChunks.d.ts +0 -5
  55. package/dist/snapshotChunks.d.ts.map +1 -1
  56. package/dist/snapshotChunks.js +4 -4
  57. package/dist/snapshotChunks.js.map +1 -1
  58. package/dist/snapshotLoader.d.ts.map +1 -1
  59. package/dist/snapshotLoader.js +13 -13
  60. package/dist/snapshotLoader.js.map +1 -1
  61. package/dist/snapshotV1.d.ts.map +1 -1
  62. package/dist/snapshotV1.js +9 -10
  63. package/dist/snapshotV1.js.map +1 -1
  64. package/dist/snapshotlegacy.d.ts.map +1 -1
  65. package/dist/snapshotlegacy.js +6 -9
  66. package/dist/snapshotlegacy.js.map +1 -1
  67. package/dist/sortedSegmentSet.js +2 -3
  68. package/dist/sortedSegmentSet.js.map +1 -1
  69. package/dist/sortedSet.d.ts.map +1 -1
  70. package/dist/sortedSet.js +1 -3
  71. package/dist/sortedSet.js.map +1 -1
  72. package/dist/zamboni.js +45 -56
  73. package/dist/zamboni.js.map +1 -1
  74. package/lib/MergeTreeTextHelper.js +2 -2
  75. package/lib/MergeTreeTextHelper.js.map +1 -1
  76. package/lib/attributionCollection.js +13 -20
  77. package/lib/attributionCollection.js.map +1 -1
  78. package/lib/attributionPolicy.js +6 -8
  79. package/lib/attributionPolicy.js.map +1 -1
  80. package/lib/client.d.ts +0 -13
  81. package/lib/client.d.ts.map +1 -1
  82. package/lib/client.js +19 -32
  83. package/lib/client.js.map +1 -1
  84. package/lib/collections/list.js +2 -2
  85. package/lib/collections/list.js.map +1 -1
  86. package/lib/endOfTreeSegment.d.ts +1 -1
  87. package/lib/endOfTreeSegment.d.ts.map +1 -1
  88. package/lib/endOfTreeSegment.js +2 -3
  89. package/lib/endOfTreeSegment.js.map +1 -1
  90. package/lib/index.d.ts +1 -1
  91. package/lib/index.d.ts.map +1 -1
  92. package/lib/index.js +1 -1
  93. package/lib/index.js.map +1 -1
  94. package/lib/localReference.js +31 -40
  95. package/lib/localReference.js.map +1 -1
  96. package/lib/mergeTree.d.ts +10 -12
  97. package/lib/mergeTree.d.ts.map +1 -1
  98. package/lib/mergeTree.js +87 -259
  99. package/lib/mergeTree.js.map +1 -1
  100. package/lib/mergeTreeNodeWalk.js +4 -4
  101. package/lib/mergeTreeNodeWalk.js.map +1 -1
  102. package/lib/mergeTreeNodes.d.ts +14 -58
  103. package/lib/mergeTreeNodes.d.ts.map +1 -1
  104. package/lib/mergeTreeNodes.js +13 -40
  105. package/lib/mergeTreeNodes.js.map +1 -1
  106. package/lib/mergeTreeTracking.d.ts +0 -6
  107. package/lib/mergeTreeTracking.d.ts.map +1 -1
  108. package/lib/mergeTreeTracking.js +0 -9
  109. package/lib/mergeTreeTracking.js.map +1 -1
  110. package/lib/partialLengths.js +27 -30
  111. package/lib/partialLengths.js.map +1 -1
  112. package/lib/properties.js +3 -3
  113. package/lib/properties.js.map +1 -1
  114. package/lib/referencePositions.d.ts.map +1 -1
  115. package/lib/referencePositions.js +2 -16
  116. package/lib/referencePositions.js.map +1 -1
  117. package/lib/revertibles.js +20 -30
  118. package/lib/revertibles.js.map +1 -1
  119. package/lib/segmentGroupCollection.d.ts +0 -4
  120. package/lib/segmentGroupCollection.d.ts.map +1 -1
  121. package/lib/segmentGroupCollection.js +2 -12
  122. package/lib/segmentGroupCollection.js.map +1 -1
  123. package/lib/segmentPropertiesManager.d.ts.map +1 -1
  124. package/lib/segmentPropertiesManager.js +7 -13
  125. package/lib/segmentPropertiesManager.js.map +1 -1
  126. package/lib/snapshotChunks.d.ts +0 -5
  127. package/lib/snapshotChunks.d.ts.map +1 -1
  128. package/lib/snapshotChunks.js +4 -4
  129. package/lib/snapshotChunks.js.map +1 -1
  130. package/lib/snapshotLoader.d.ts.map +1 -1
  131. package/lib/snapshotLoader.js +14 -14
  132. package/lib/snapshotLoader.js.map +1 -1
  133. package/lib/snapshotV1.d.ts.map +1 -1
  134. package/lib/snapshotV1.js +10 -11
  135. package/lib/snapshotV1.js.map +1 -1
  136. package/lib/snapshotlegacy.d.ts.map +1 -1
  137. package/lib/snapshotlegacy.js +7 -10
  138. package/lib/snapshotlegacy.js.map +1 -1
  139. package/lib/sortedSegmentSet.js +2 -3
  140. package/lib/sortedSegmentSet.js.map +1 -1
  141. package/lib/sortedSet.d.ts.map +1 -1
  142. package/lib/sortedSet.js +1 -3
  143. package/lib/sortedSet.js.map +1 -1
  144. package/lib/zamboni.js +45 -56
  145. package/lib/zamboni.js.map +1 -1
  146. package/package.json +130 -17
  147. package/src/client.ts +9 -17
  148. package/src/endOfTreeSegment.ts +4 -3
  149. package/src/index.ts +0 -19
  150. package/src/mergeTree.ts +80 -229
  151. package/src/mergeTreeNodes.ts +22 -78
  152. package/src/mergeTreeTracking.ts +0 -10
  153. package/src/referencePositions.ts +2 -16
  154. package/src/revertibles.ts +2 -2
  155. package/src/segmentGroupCollection.ts +0 -9
  156. package/src/segmentPropertiesManager.ts +2 -4
  157. package/src/snapshotChunks.ts +0 -5
  158. package/src/snapshotLoader.ts +8 -5
  159. package/src/snapshotV1.ts +6 -4
  160. package/src/snapshotlegacy.ts +2 -2
  161. package/src/sortedSet.ts +1 -3
  162. package/src/zamboni.ts +55 -59
package/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # @fluidframework/merge-tree
2
2
 
3
+ ## 2.0.0-internal.6.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - Client.getSlideToSegment removed [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
8
+
9
+ Client.getSlideToSegment was deprecated in 2.0.0-internal.5.3.0 and has been removed. Use getSlideToSegoff function instead.
10
+
11
+ - Remove ISegment.parent [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
12
+
13
+ This change removed the parent property on the ISegment interface. The property will still exist, but should not generally be used by outside consumers.
14
+
15
+ There are some circumstances where a consumer may wish to know if a segment is still in the underlying tree and were using the parent property to determine that.
16
+
17
+ Please change those checks to use the following `"parent" in segment && segment.parent !== undefined`
18
+
19
+ - merge-tree now has new length calculations by default [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
20
+
21
+ The merge-tree now enables new length calculations by default and resolves some related performance bugs by making cached segment length
22
+ nullable.
23
+
24
+ Hierarchy cached segment length is `undefined` if the length of all child nodes is `undefined`.
25
+
26
+ - Segments Property Removed from TrackingGroup [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
27
+
28
+ Tracking groups can contain more than just segments, so the deprecated segments property has been removed. Use the tracked property instead to see all tracked objects.
29
+
30
+ - Remove unnecessary exports [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
31
+
32
+ This change removes a number of interfaces in the merge tree package that are not used in the exported apis surface and therefore should not be used.
33
+
34
+ - Upgraded typescript transpilation target to ES2020 [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
35
+
36
+ Upgraded typescript transpilation target to ES2020. This is done in order to decrease the bundle sizes of Fluid Framework packages. This has provided size improvements across the board for ex. Loader, Driver, Runtime etc. Reduced bundle sizes helps to load lesser code in apps and hence also helps to improve the perf.If any app wants to target any older versions of browsers with which this target version is not compatible, then they can use packages like babel to transpile to a older target.
37
+
38
+ ## 2.0.0-internal.5.4.0
39
+
40
+ Dependency updates only.
41
+
3
42
  ## 2.0.0-internal.5.3.0
4
43
 
5
44
  Dependency updates only.
@@ -18,8 +18,8 @@ class MergeTreeTextHelper {
18
18
  }
19
19
  getValidRange(start, end, refSeq, clientId) {
20
20
  const range = {
21
- end: end !== null && end !== void 0 ? end : this.mergeTree.getLength(refSeq, clientId),
22
- start: start !== null && start !== void 0 ? start : 0,
21
+ end: end ?? this.mergeTree.getLength(refSeq, clientId),
22
+ start: start ?? 0,
23
23
  };
24
24
  return range;
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MergeTreeTextHelper.js","sourceRoot":"","sources":["../src/MergeTreeTextHelper.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,+CAAkE;AAQlE,MAAa,mBAAmB;IAC/B,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAE9C,OAAO,CACb,MAAc,EACd,QAAgB,EAChB,WAAW,GAAG,EAAE,EAChB,KAAc,EACd,GAAY;QAEZ,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QAE/D,MAAM,KAAK,GAAqB,EAAE,WAAW,EAAE,IAAI,yBAAW,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC;QAElF,IAAI,CAAC,SAAS,CAAC,QAAQ,CACtB,UAAU,EACV,MAAM,EACN,QAAQ,EACR,KAAK,EACL,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,GAAG,CACT,CAAC;QACF,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;IAEO,aAAa,CACpB,KAAyB,EACzB,GAAuB,EACvB,MAAc,EACd,QAAgB;QAEhB,MAAM,KAAK,GAAkB;YAC5B,GAAG,EA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right (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IIntegerRange } from \"./base\";\nimport { ISegment } from \"./mergeTreeNodes\";\nimport { MergeTree } from \"./mergeTree\";\nimport { IMergeTreeTextHelper, TextSegment } from \"./textSegment\";\n\ninterface ITextAccumulator {\n\ttextSegment: TextSegment;\n\tplaceholder?: string;\n\tparallelArrays?: boolean;\n}\n\nexport class MergeTreeTextHelper implements IMergeTreeTextHelper {\n\tconstructor(private readonly mergeTree: MergeTree) {}\n\n\tpublic getText(\n\t\trefSeq: number,\n\t\tclientId: number,\n\t\tplaceholder = \"\",\n\t\tstart?: number,\n\t\tend?: number,\n\t) {\n\t\tconst range = this.getValidRange(start, end, refSeq, clientId);\n\n\t\tconst accum: ITextAccumulator = { textSegment: new TextSegment(\"\"), placeholder };\n\n\t\tthis.mergeTree.mapRange<ITextAccumulator>(\n\t\t\tgatherText,\n\t\t\trefSeq,\n\t\t\tclientId,\n\t\t\taccum,\n\t\t\trange.start,\n\t\t\trange.end,\n\t\t);\n\t\treturn accum.textSegment.text;\n\t}\n\n\tprivate getValidRange(\n\t\tstart: number | undefined,\n\t\tend: number | undefined,\n\t\trefSeq: number,\n\t\tclientId: number,\n\t): IIntegerRange {\n\t\tconst range: IIntegerRange = {\n\t\t\tend: end ?? this.mergeTree.getLength(refSeq, clientId),\n\t\t\tstart: start ?? 0,\n\t\t};\n\t\treturn range;\n\t}\n}\n\nfunction gatherText(\n\tsegment: ISegment,\n\tpos: number,\n\trefSeq: number,\n\tclientId: number,\n\tstart: number,\n\tend: number,\n\t{ textSegment, placeholder }: ITextAccumulator,\n): boolean {\n\tif (TextSegment.is(segment)) {\n\t\tif (start <= 0 && end >= segment.text.length) {\n\t\t\ttextSegment.text += segment.text;\n\t\t} else {\n\t\t\tconst seglen = segment.text.length;\n\t\t\tconst _start = start < 0 ? 0 : start;\n\t\t\tconst _end = end >= seglen ? undefined : end;\n\t\t\ttextSegment.text += segment.text.substring(_start, _end);\n\t\t}\n\t} else if (placeholder && placeholder.length > 0) {\n\t\tconst placeholderText =\n\t\t\tplaceholder === \"*\" ? `\\n${segment}` : placeholder.repeat(segment.cachedLength);\n\t\ttextSegment.text += placeholderText;\n\t}\n\n\treturn true;\n}\n"]}
1
+ {"version":3,"file":"MergeTreeTextHelper.js","sourceRoot":"","sources":["../src/MergeTreeTextHelper.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,+CAAkE;AAQlE,MAAa,mBAAmB;IAC/B,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAE9C,OAAO,CACb,MAAc,EACd,QAAgB,EAChB,WAAW,GAAG,EAAE,EAChB,KAAc,EACd,GAAY;QAEZ,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QAE/D,MAAM,KAAK,GAAqB,EAAE,WAAW,EAAE,IAAI,yBAAW,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC;QAElF,IAAI,CAAC,SAAS,CAAC,QAAQ,CACtB,UAAU,EACV,MAAM,EACN,QAAQ,EACR,KAAK,EACL,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,GAAG,CACT,CAAC;QACF,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;IAEO,aAAa,CACpB,KAAyB,EACzB,GAAuB,EACvB,MAAc,EACd,QAAgB;QAEhB,MAAM,KAAK,GAAkB;YAC5B,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC;YACtD,KAAK,EAAE,KAAK,IAAI,CAAC;SACjB,CAAC;QACF,OAAO,KAAK,CAAC;IACd,CAAC;CACD;AArCD,kDAqCC;AAED,SAAS,UAAU,CAClB,OAAiB,EACjB,GAAW,EACX,MAAc,EACd,QAAgB,EAChB,KAAa,EACb,GAAW,EACX,EAAE,WAAW,EAAE,WAAW,EAAoB;IAE9C,IAAI,yBAAW,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE;QAC5B,IAAI,KAAK,IAAI,CAAC,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE;YAC7C,WAAW,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;SACjC;aAAM;YACN,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;YACnC,MAAM,MAAM,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YACrC,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;YAC7C,WAAW,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;SACzD;KACD;SAAM,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;QACjD,MAAM,eAAe,GACpB,WAAW,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACjF,WAAW,CAAC,IAAI,IAAI,eAAe,CAAC;KACpC;IAED,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IIntegerRange } from \"./base\";\nimport { ISegment } from \"./mergeTreeNodes\";\nimport { MergeTree } from \"./mergeTree\";\nimport { IMergeTreeTextHelper, TextSegment } from \"./textSegment\";\n\ninterface ITextAccumulator {\n\ttextSegment: TextSegment;\n\tplaceholder?: string;\n\tparallelArrays?: boolean;\n}\n\nexport class MergeTreeTextHelper implements IMergeTreeTextHelper {\n\tconstructor(private readonly mergeTree: MergeTree) {}\n\n\tpublic getText(\n\t\trefSeq: number,\n\t\tclientId: number,\n\t\tplaceholder = \"\",\n\t\tstart?: number,\n\t\tend?: number,\n\t) {\n\t\tconst range = this.getValidRange(start, end, refSeq, clientId);\n\n\t\tconst accum: ITextAccumulator = { textSegment: new TextSegment(\"\"), placeholder };\n\n\t\tthis.mergeTree.mapRange<ITextAccumulator>(\n\t\t\tgatherText,\n\t\t\trefSeq,\n\t\t\tclientId,\n\t\t\taccum,\n\t\t\trange.start,\n\t\t\trange.end,\n\t\t);\n\t\treturn accum.textSegment.text;\n\t}\n\n\tprivate getValidRange(\n\t\tstart: number | undefined,\n\t\tend: number | undefined,\n\t\trefSeq: number,\n\t\tclientId: number,\n\t): IIntegerRange {\n\t\tconst range: IIntegerRange = {\n\t\t\tend: end ?? this.mergeTree.getLength(refSeq, clientId),\n\t\t\tstart: start ?? 0,\n\t\t};\n\t\treturn range;\n\t}\n}\n\nfunction gatherText(\n\tsegment: ISegment,\n\tpos: number,\n\trefSeq: number,\n\tclientId: number,\n\tstart: number,\n\tend: number,\n\t{ textSegment, placeholder }: ITextAccumulator,\n): boolean {\n\tif (TextSegment.is(segment)) {\n\t\tif (start <= 0 && end >= segment.text.length) {\n\t\t\ttextSegment.text += segment.text;\n\t\t} else {\n\t\t\tconst seglen = segment.text.length;\n\t\t\tconst _start = start < 0 ? 0 : start;\n\t\t\tconst _end = end >= seglen ? undefined : end;\n\t\t\ttextSegment.text += segment.text.substring(_start, _end);\n\t\t}\n\t} else if (placeholder && placeholder.length > 0) {\n\t\tconst placeholderText =\n\t\t\tplaceholder === \"*\" ? `\\n${segment}` : placeholder.repeat(segment.cachedLength);\n\t\ttextSegment.text += placeholderText;\n\t}\n\n\treturn true;\n}\n"]}
@@ -41,18 +41,15 @@ class AttributionCollection {
41
41
  }
42
42
  }
43
43
  get channelEntries() {
44
- var _a;
45
- return Object.entries((_a = this.channels) !== null && _a !== void 0 ? _a : {});
44
+ return Object.entries(this.channels ?? {});
46
45
  }
47
46
  get channelNames() {
48
- var _a;
49
- return Object.keys((_a = this.channels) !== null && _a !== void 0 ? _a : {});
47
+ return Object.keys(this.channels ?? {});
50
48
  }
51
49
  getAtOffset(offset, channel) {
52
- var _a;
53
50
  if (channel !== undefined) {
54
- const subCollection = (_a = this.channels) === null || _a === void 0 ? void 0 : _a[channel];
55
- return subCollection === null || subCollection === void 0 ? void 0 : subCollection.getAtOffset(offset);
51
+ const subCollection = this.channels?.[channel];
52
+ return subCollection?.getAtOffset(offset);
56
53
  }
57
54
  (0, common_utils_1.assert)(offset >= 0 && offset < this._length, 0x443 /* Requested offset should be valid */);
58
55
  return this.get(this.findIndex(offset));
@@ -97,8 +94,7 @@ class AttributionCollection {
97
94
  return splitCollection;
98
95
  }
99
96
  append(other) {
100
- var _a, _b, _c;
101
- var _d;
97
+ var _a;
102
98
  const lastEntry = this.keys[this.keys.length - 1];
103
99
  for (let i = 0; i < other.keys.length; i++) {
104
100
  if (i !== 0 || !areEqualAttributionKeys(lastEntry, other.keys[i])) {
@@ -107,13 +103,13 @@ class AttributionCollection {
107
103
  }
108
104
  }
109
105
  if (other.channels !== undefined || this.channels !== undefined) {
110
- (_a = this.channels) !== null && _a !== void 0 ? _a : (this.channels = {});
106
+ this.channels ?? (this.channels = {});
111
107
  for (const [key, collection] of other.channelEntries) {
112
- const thisCollection = ((_b = (_d = this.channels)[key]) !== null && _b !== void 0 ? _b : (_d[key] = new AttributionCollection(this.length, null)));
108
+ const thisCollection = ((_a = this.channels)[key] ?? (_a[key] = new AttributionCollection(this.length, null)));
113
109
  thisCollection.append(collection);
114
110
  }
115
111
  for (const [key, collection] of this.channelEntries) {
116
- if (((_c = other.channels) === null || _c === void 0 ? void 0 : _c[key]) === undefined) {
112
+ if (other.channels?.[key] === undefined) {
117
113
  collection.append(new AttributionCollection(other.length, null));
118
114
  }
119
115
  }
@@ -151,14 +147,13 @@ class AttributionCollection {
151
147
  return copy;
152
148
  }
153
149
  update(name, channel) {
154
- var _a;
155
150
  (0, common_utils_1.assert)(channel.length === this.length, 0x5c0 /* AttributionCollection channel update should have consistent segment length */);
156
151
  if (name === undefined) {
157
152
  this.offsets = [...channel.offsets];
158
153
  this.keys = [...channel.keys];
159
154
  }
160
155
  else {
161
- (_a = this.channels) !== null && _a !== void 0 ? _a : (this.channels = {});
156
+ this.channels ?? (this.channels = {});
162
157
  if (this.channels[name] !== undefined) {
163
158
  this.channels[name].update(undefined, channel);
164
159
  }
@@ -204,9 +199,8 @@ class AttributionCollection {
204
199
  for (const [name, collectionSpec] of Object.entries(channels)) {
205
200
  extractOntoSegments(collectionSpec, (collection, segment) => {
206
201
  var _a;
207
- var _b;
208
202
  // Cast is valid as we just assigned this field above
209
- ((_a = (_b = segment.attribution).channels) !== null && _a !== void 0 ? _a : (_b.channels = {}))[name] =
203
+ ((_a = segment.attribution).channels ?? (_a.channels = {}))[name] =
210
204
  collection;
211
205
  });
212
206
  }
@@ -219,11 +213,10 @@ class AttributionCollection {
219
213
  * where only some segments have attribution defined.
220
214
  */
221
215
  static serializeAttributionCollections(segments) {
222
- var _a;
223
216
  const allCollectionSpecs = [];
224
217
  const allChannelNames = new Set();
225
218
  for (const segment of segments) {
226
- const collection = (_a = segment.attribution) !== null && _a !== void 0 ? _a : new AttributionCollection(segment.cachedLength, null);
219
+ const collection = segment.attribution ?? new AttributionCollection(segment.cachedLength, null);
227
220
  const spec = collection.getAll();
228
221
  allCollectionSpecs.push(spec);
229
222
  if (spec.channels) {
@@ -239,7 +232,7 @@ class AttributionCollection {
239
232
  let cumulativePos = 0;
240
233
  for (const spec of allCollectionSpecs) {
241
234
  for (const { offset, key } of getSpecEntries(spec)) {
242
- (0, common_utils_1.assert)((key === null || key === void 0 ? void 0 : key.type) !== "local", 0x5c1 /* local attribution keys should never be put in summaries */);
235
+ (0, common_utils_1.assert)(key?.type !== "local", 0x5c1 /* local attribution keys should never be put in summaries */);
243
236
  if (mostRecentAttributionKey === undefined ||
244
237
  !areEqualAttributionKeys(key, mostRecentAttributionKey)) {
245
238
  posBreakpoints.push(offset + cumulativePos);
@@ -255,7 +248,7 @@ class AttributionCollection {
255
248
  if (allChannelNames.size > 0) {
256
249
  const channels = {};
257
250
  for (const name of allChannelNames) {
258
- const { posBreakpoints, seqs } = extractSequenceOffsets((spec) => { var _a, _b; return (_b = (_a = spec.channels) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : [{ offset: 0, key: null }]; });
251
+ const { posBreakpoints, seqs } = extractSequenceOffsets((spec) => spec.channels?.[name] ?? [{ offset: 0, key: null }]);
259
252
  channels[name] = { posBreakpoints, seqs };
260
253
  }
261
254
  blobContents.channels = channels;
@@ -1 +1 @@
1
- {"version":3,"file":"attributionCollection.js","sourceRoot":"","sources":["../src/attributionCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAuE;AAkHvE,gDAAgD;AAChD,SAAgB,uBAAuB,CACtC,CAAoC,EACpC,CAAoC;IAEpC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE;QACb,OAAO,IAAI,CAAC;KACZ;IAED,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE;QACb,OAAO,KAAK,CAAC;KACb;IAED,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE;QACtB,OAAO,KAAK,CAAC;KACb;IAED,gGAAgG;IAChG,QAAQ,CAAC,CAAC,IAAI,EAAE;QACf,KAAK,IAAI;YACR,OAAO,CAAC,CAAC,GAAG,KAAM,CAAsB,CAAC,GAAG,CAAC;QAC9C,KAAK,UAAU;YACd,OAAO,CAAC,CAAC,EAAE,KAAM,CAA4B,CAAC,EAAE,CAAC;QAClD,KAAK,OAAO;YACX,OAAO,IAAI,CAAC;QACb;YACC,IAAA,8BAAe,EAAC,CAAC,EAAE,+BAA+B,CAAC,CAAC;KACrD;AACF,CAAC;AA3BD,0DA2BC;AAED,MAAa,qBAAqB;IAUjC,YAA2B,OAAe,EAAE,SAAiC;QAAlD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YAC7B,MAAM,QAAQ,GAAwC,EAAE,CAAC;YACzD,KAAK,MAAM,IAAI,IAAI,eAAe,EAAE;gBACnC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,sBAAsB,CACtD,CAAC,IAAI,EAAE,EAAE,eAAC,OAAA,MAAA,MAAA,IAAI,CAAC,QAAQ,0CAAG,IAAI,CAAC,mCAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAA,EAAA,CAC7D,CAAC;gBACF,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;aAC1C;YACD,YAAY,CAAC,QAAQ,GAAG,QAAQ,CAAC;SACjC;QAED,OAAO,YAAY,CAAC;IACrB,CAAC;CACD;AAlSD,sDAkSC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/common-utils\";\nimport {\n\tAttributionKey,\n\tOpAttributionKey,\n\tDetachedAttributionKey,\n} from \"@fluidframework/runtime-definitions\";\nimport { ISegment } from \"./mergeTreeNodes\";\n\n/**\n * @internal\n */\nexport interface SequenceOffsets {\n\t/**\n\t * Parallel array with posBreakpoints which tracks the seq of insertion.\n\t * Ex: 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\tseqs: (number | AttributionKey | null)[];\n\tposBreakpoints: number[];\n}\n\n/**\n * @internal\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 * @internal\n */\nexport interface IAttributionCollectionSpec<T> {\n\troot: Iterable<{ offset: number; key: T | null }>;\n\tchannels?: { [name: string]: Iterable<{ offset: number; key: T | null }> };\n\tlength: number;\n}\n\n/**\n * @internal\n * @sealed\n */\nexport interface IAttributionCollectionSerializer {\n\t/**\n\t * @internal\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 * @internal\n\t */\n\tpopulateAttributionCollections(\n\t\tsegments: Iterable<ISegment>,\n\t\tsummary: SerializedAttributionCollection,\n\t): void;\n}\n\n/**\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 * 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 * @internal\n\t */\n\tgetAll(): IAttributionCollectionSpec<T>;\n\n\t/** @internal */\n\tsplitAt(pos: number): IAttributionCollection<T>;\n\n\t/** @internal */\n\tappend(other: IAttributionCollection<T>): void;\n\n\t/** @internal */\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 * @internal\n\t */\n\tupdate(name: string | undefined, channel: IAttributionCollection<T>);\n}\n\n// note: treats null and undefined as equivalent\nexport function areEqualAttributionKeys(\n\ta: AttributionKey | null | undefined,\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\tcase \"detached\":\n\t\t\treturn a.id === (b as DetachedAttributionKey).id;\n\t\tcase \"local\":\n\t\t\treturn true;\n\t\tdefault:\n\t\t\tunreachableCase(a, \"Unhandled AttributionKey type\");\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(private _length: number, baseEntry?: AttributionKey | null) {\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\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 !== null ? 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\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\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\tconst root: IAttributionCollectionSpec<AttributionKey>[\"root\"] = new Array(\n\t\t\tthis.keys.length,\n\t\t);\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.slice();\n\t\tcopy.offsets = this.offsets.slice();\n\t\tif (this.channels !== undefined) {\n\t\t\tconst channelsCopy = {};\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) {\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].update(undefined, channel);\n\t\t\t} else {\n\t\t\t\tthis.channels[name] = 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\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) => {\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\tconst pushEntry = (offset: number, seq: AttributionKey | number | null) => {\n\t\t\t\t\tattribution.offsets.push(offset);\n\t\t\t\t\tattribution.keys.push(\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\t// Cast is valid as we just assigned this field above\n\t\t\t\t\t((segment.attribution as AttributionCollection).channels ??= {})[name] =\n\t\t\t\t\t\tcollection;\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\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\tseqs.push(!key ? null : key.type === \"op\" ? key.seq : key);\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(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,+DAAuE;AAkHvE,gDAAgD;AAChD,SAAgB,uBAAuB,CACtC,CAAoC,EACpC,CAAoC;IAEpC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE;QACb,OAAO,IAAI,CAAC;KACZ;IAED,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE;QACb,OAAO,KAAK,CAAC;KACb;IAED,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE;QACtB,OAAO,KAAK,CAAC;KACb;IAED,gGAAgG;IACh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AAI,IAAI,CAAC,MAAM,CAAC;aAC7B;YAED,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;QACxD,CAAC,CAAC;QAEF,MAAM,YAAY,GAAG,sBAAsB,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjE,IAAI,eAAe,CAAC,IAAI,GAAG,CAAC,EAAE;YAC7B,MAAM,QAAQ,GAAwC,EAAE,CAAC;YACzD,KAAK,MAAM,IAAI,IAAI,eAAe,EAAE;gBACnC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,sBAAsB,CACtD,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;aAC1C;YACD,YAAY,CAAC,QAAQ,GAAG,QAAQ,CAAC;SACjC;QAED,OAAO,YAAY,CAAC;IACrB,CAAC;CACD;AAlSD,sDAkSC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/common-utils\";\nimport {\n\tAttributionKey,\n\tOpAttributionKey,\n\tDetachedAttributionKey,\n} from \"@fluidframework/runtime-definitions\";\nimport { ISegment } from \"./mergeTreeNodes\";\n\n/**\n * @internal\n */\nexport interface SequenceOffsets {\n\t/**\n\t * Parallel array with posBreakpoints which tracks the seq of insertion.\n\t * Ex: 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\tseqs: (number | AttributionKey | null)[];\n\tposBreakpoints: number[];\n}\n\n/**\n * @internal\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 * @internal\n */\nexport interface IAttributionCollectionSpec<T> {\n\troot: Iterable<{ offset: number; key: T | null }>;\n\tchannels?: { [name: string]: Iterable<{ offset: number; key: T | null }> };\n\tlength: number;\n}\n\n/**\n * @internal\n * @sealed\n */\nexport interface IAttributionCollectionSerializer {\n\t/**\n\t * @internal\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 * @internal\n\t */\n\tpopulateAttributionCollections(\n\t\tsegments: Iterable<ISegment>,\n\t\tsummary: SerializedAttributionCollection,\n\t): void;\n}\n\n/**\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 * 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 * @internal\n\t */\n\tgetAll(): IAttributionCollectionSpec<T>;\n\n\t/** @internal */\n\tsplitAt(pos: number): IAttributionCollection<T>;\n\n\t/** @internal */\n\tappend(other: IAttributionCollection<T>): void;\n\n\t/** @internal */\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 * @internal\n\t */\n\tupdate(name: string | undefined, channel: IAttributionCollection<T>);\n}\n\n// note: treats null and undefined as equivalent\nexport function areEqualAttributionKeys(\n\ta: AttributionKey | null | undefined,\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\tcase \"detached\":\n\t\t\treturn a.id === (b as DetachedAttributionKey).id;\n\t\tcase \"local\":\n\t\t\treturn true;\n\t\tdefault:\n\t\t\tunreachableCase(a, \"Unhandled AttributionKey type\");\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(private _length: number, baseEntry?: AttributionKey | null) {\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\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 !== null ? 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\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\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\tconst root: IAttributionCollectionSpec<AttributionKey>[\"root\"] = new Array(\n\t\t\tthis.keys.length,\n\t\t);\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.slice();\n\t\tcopy.offsets = this.offsets.slice();\n\t\tif (this.channels !== undefined) {\n\t\t\tconst channelsCopy = {};\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) {\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].update(undefined, channel);\n\t\t\t} else {\n\t\t\t\tthis.channels[name] = 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\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) => {\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\tconst pushEntry = (offset: number, seq: AttributionKey | number | null) => {\n\t\t\t\t\tattribution.offsets.push(offset);\n\t\t\t\t\tattribution.keys.push(\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\t// Cast is valid as we just assigned this field above\n\t\t\t\t\t((segment.attribution as AttributionCollection).channels ??= {})[name] =\n\t\t\t\t\t\tcollection;\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\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\tseqs.push(!key ? null : key.type === \"op\" ? key.seq : key);\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(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"]}
@@ -24,7 +24,7 @@ function createAttributionPolicyFromCallbacks({ delta, maintenance, }) {
24
24
  };
25
25
  },
26
26
  detach: () => {
27
- unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe();
27
+ unsubscribe?.();
28
28
  unsubscribe = undefined;
29
29
  },
30
30
  get isAttached() {
@@ -51,10 +51,9 @@ const getAttributionKey = (client, msg) => {
51
51
  return collabWindow.collaborating ? { type: "local" } : { type: "detached", id: 0 };
52
52
  };
53
53
  const attributeInsertionOnSegments = (deltaSegments, key) => {
54
- var _a;
55
54
  for (const { segment } of deltaSegments) {
56
55
  if (segment.seq !== undefined) {
57
- (_a = segment.attribution) === null || _a === void 0 ? void 0 : _a.update(undefined, new attributionCollection_1.AttributionCollection(segment.cachedLength, key));
56
+ segment.attribution?.update(undefined, new attributionCollection_1.AttributionCollection(segment.cachedLength, key));
58
57
  }
59
58
  }
60
59
  };
@@ -66,7 +65,7 @@ const insertOnlyAttributionPolicyCallbacks = {
66
65
  },
67
66
  maintenance: ({ deltaSegments, operation }, opArgs, client) => {
68
67
  if (operation === mergeTreeDeltaCallback_1.MergeTreeMaintenanceType.ACKNOWLEDGED &&
69
- (opArgs === null || opArgs === void 0 ? void 0 : opArgs.op.type) === ops_1.MergeTreeDeltaType.INSERT) {
68
+ opArgs?.op.type === ops_1.MergeTreeDeltaType.INSERT) {
70
69
  attributeInsertionOnSegments(deltaSegments, getAttributionKey(client, opArgs.sequencedMessage));
71
70
  }
72
71
  },
@@ -74,11 +73,10 @@ const insertOnlyAttributionPolicyCallbacks = {
74
73
  function createPropertyTrackingMergeTreeCallbacks(...propNames) {
75
74
  const toTrack = propNames.map((entry) => ({ propName: entry, channelName: entry }));
76
75
  const attributeAnnotateOnSegments = (deltaSegments, { op, sequencedMessage }, key) => {
77
- var _a, _b, _c;
78
76
  for (const { segment } of deltaSegments) {
79
77
  for (const { propName, channelName } of toTrack) {
80
78
  const shouldAttributeInsert = op.type === ops_1.MergeTreeDeltaType.INSERT &&
81
- ((_a = segment.properties) === null || _a === void 0 ? void 0 : _a[propName]) !== undefined;
79
+ segment.properties?.[propName] !== undefined;
82
80
  const isLocal = sequencedMessage === undefined;
83
81
  const shouldAttributeAnnotate = op.type === ops_1.MergeTreeDeltaType.ANNOTATE &&
84
82
  // Only attribute annotations which change the tracked property
@@ -86,9 +84,9 @@ function createPropertyTrackingMergeTreeCallbacks(...propNames) {
86
84
  // Local changes to the tracked property always take effect
87
85
  (isLocal ||
88
86
  // Acked changes only take effect if there isn't a pending local change
89
- (!isLocal && !((_b = segment.propertyManager) === null || _b === void 0 ? void 0 : _b.hasPendingProperty(propName))));
87
+ (!isLocal && !segment.propertyManager?.hasPendingProperty(propName)));
90
88
  if (shouldAttributeInsert || shouldAttributeAnnotate) {
91
- (_c = segment.attribution) === null || _c === void 0 ? void 0 : _c.update(channelName, new attributionCollection_1.AttributionCollection(segment.cachedLength, key));
89
+ segment.attribution?.update(channelName, new attributionCollection_1.AttributionCollection(segment.cachedLength, key));
92
90
  }
93
91
  }
94
92
  }
@@ -1 +1 @@
1
- {"version":3,"file":"attributionPolicy.js","sourceRoot":"","sources":["../src/attributionPolicy.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAKtD,qEAMkC;AAClC,+BAA2C;AAC3C,mEAAgE;AAkBhE,SAAS,oCAAoC,CAAC,EAC7C,KAAK,EACL,WAAW,GACW;IACtB,IAAI,WAAqC,CAAC;IAC1C,OAAO;QACN,MAAM,EAAE,CAAC,MAAc,EAAE,EAAE;YAC1B,IAAA,qBAAM,EACL,WAAW,KAAK,SAAS,EACzB,KAAK,CAAC,+CAA+C,CACrD,CAAC;YAEF,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YAChF,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;YAElF,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;YACpC,MAAM,CAAC,EAAE,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;YAEhD,WAAW,GAAG,GAA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AS,CAAC;KACtD,CAAC,CACF,CAAC;AACJ,CAAC;AAXD,gIAWC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { AttributionKey } from \"@fluidframework/runtime-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { AttributionPolicy } from \"./mergeTree\";\nimport { Client } from \"./client\";\nimport {\n\tIMergeTreeDeltaCallbackArgs,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tIMergeTreeSegmentDelta,\n\tMergeTreeMaintenanceType,\n} from \"./mergeTreeDeltaCallback\";\nimport { MergeTreeDeltaType } from \"./ops\";\nimport { AttributionCollection } from \"./attributionCollection\";\n\n// Note: these thinly wrap MergeTreeDeltaCallback and MergeTreeMaintenanceCallback to provide the client.\n// This is because the base callbacks don't always have enough information to infer whether the op being\n// processed is in a detached or attached state, which may affect the attribution key.\ninterface AttributionCallbacks {\n\tdelta: (\n\t\topArgs: IMergeTreeDeltaOpArgs,\n\t\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\t\tclient: Client,\n\t) => void;\n\tmaintenance: (\n\t\tmaintenanceArgs: IMergeTreeMaintenanceCallbackArgs,\n\t\topArgs: IMergeTreeDeltaOpArgs | undefined,\n\t\tclient: Client,\n\t) => void;\n}\n\nfunction createAttributionPolicyFromCallbacks({\n\tdelta,\n\tmaintenance,\n}: AttributionCallbacks): AttributionPolicy {\n\tlet unsubscribe: undefined | (() => void);\n\treturn {\n\t\tattach: (client: Client) => {\n\t\t\tassert(\n\t\t\t\tunsubscribe === undefined,\n\t\t\t\t0x557 /* cannot attach to multiple clients at once */,\n\t\t\t);\n\n\t\t\tconst deltaSubscribed = (opArgs, deltaArgs) => delta(opArgs, deltaArgs, client);\n\t\t\tconst maintenanceSubscribed = (args, opArgs) => maintenance(args, opArgs, client);\n\n\t\t\tclient.on(\"delta\", deltaSubscribed);\n\t\t\tclient.on(\"maintenance\", maintenanceSubscribed);\n\n\t\t\tunsubscribe = () => {\n\t\t\t\tclient.off(\"delta\", deltaSubscribed);\n\t\t\t\tclient.off(\"maintenance\", maintenanceSubscribed);\n\t\t\t};\n\t\t},\n\t\tdetach: () => {\n\t\t\tunsubscribe?.();\n\t\t\tunsubscribe = undefined;\n\t\t},\n\t\tget isAttached() {\n\t\t\treturn unsubscribe !== undefined;\n\t\t},\n\t\tserializer: AttributionCollection,\n\t};\n}\n\nconst ensureAttributionCollectionCallbacks: AttributionCallbacks = {\n\tdelta: ({ op }, { deltaSegments }) => {\n\t\tif (op.type === MergeTreeDeltaType.INSERT) {\n\t\t\tfor (const { segment } of deltaSegments) {\n\t\t\t\tsegment.attribution = new AttributionCollection(segment.cachedLength);\n\t\t\t}\n\t\t}\n\t},\n\tmaintenance: () => {},\n};\n\nconst getAttributionKey = (\n\tclient: Client,\n\tmsg: ISequencedDocumentMessage | undefined,\n): AttributionKey => {\n\tif (msg) {\n\t\treturn { type: \"op\", seq: msg.sequenceNumber };\n\t}\n\tconst collabWindow = client.getCollabWindow();\n\treturn collabWindow.collaborating ? { type: \"local\" } : { type: \"detached\", id: 0 };\n};\n\nconst attributeInsertionOnSegments = (\n\tdeltaSegments: IMergeTreeSegmentDelta[],\n\tkey: AttributionKey,\n): void => {\n\tfor (const { segment } of deltaSegments) {\n\t\tif (segment.seq !== undefined) {\n\t\t\tsegment.attribution?.update(\n\t\t\t\tundefined,\n\t\t\t\tnew AttributionCollection(segment.cachedLength, key),\n\t\t\t);\n\t\t}\n\t}\n};\n\nconst insertOnlyAttributionPolicyCallbacks: AttributionCallbacks = {\n\tdelta: (opArgs, { deltaSegments, operation }, client) => {\n\t\tif (operation === MergeTreeDeltaType.INSERT) {\n\t\t\tattributeInsertionOnSegments(\n\t\t\t\tdeltaSegments,\n\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t);\n\t\t}\n\t},\n\tmaintenance: ({ deltaSegments, operation }, opArgs, client) => {\n\t\tif (\n\t\t\toperation === MergeTreeMaintenanceType.ACKNOWLEDGED &&\n\t\t\topArgs?.op.type === MergeTreeDeltaType.INSERT\n\t\t) {\n\t\t\tattributeInsertionOnSegments(\n\t\t\t\tdeltaSegments,\n\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t);\n\t\t}\n\t},\n};\n\nfunction createPropertyTrackingMergeTreeCallbacks(...propNames: string[]): AttributionCallbacks {\n\tconst toTrack = propNames.map((entry) => ({ propName: entry, channelName: entry }));\n\tconst attributeAnnotateOnSegments = (\n\t\tdeltaSegments: IMergeTreeSegmentDelta[],\n\t\t{ op, sequencedMessage }: IMergeTreeDeltaOpArgs,\n\t\tkey: AttributionKey,\n\t): void => {\n\t\tfor (const { segment } of deltaSegments) {\n\t\t\tfor (const { propName, channelName } of toTrack) {\n\t\t\t\tconst shouldAttributeInsert =\n\t\t\t\t\top.type === MergeTreeDeltaType.INSERT &&\n\t\t\t\t\tsegment.properties?.[propName] !== undefined;\n\n\t\t\t\tconst isLocal = sequencedMessage === undefined;\n\t\t\t\tconst shouldAttributeAnnotate =\n\t\t\t\t\top.type === MergeTreeDeltaType.ANNOTATE &&\n\t\t\t\t\t// Only attribute annotations which change the tracked property\n\t\t\t\t\top.props[propName] !== undefined &&\n\t\t\t\t\t// Local changes to the tracked property always take effect\n\t\t\t\t\t(isLocal ||\n\t\t\t\t\t\t// Acked changes only take effect if there isn't a pending local change\n\t\t\t\t\t\t(!isLocal && !segment.propertyManager?.hasPendingProperty(propName)));\n\n\t\t\t\tif (shouldAttributeInsert || shouldAttributeAnnotate) {\n\t\t\t\t\tsegment.attribution?.update(\n\t\t\t\t\t\tchannelName,\n\t\t\t\t\t\tnew AttributionCollection(segment.cachedLength, key),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\treturn {\n\t\tdelta: (opArgs, { deltaSegments }, client) => {\n\t\t\tconst { op, sequencedMessage } = opArgs;\n\t\t\tif (op.type === MergeTreeDeltaType.ANNOTATE || op.type === MergeTreeDeltaType.INSERT) {\n\t\t\t\tattributeAnnotateOnSegments(\n\t\t\t\t\tdeltaSegments,\n\t\t\t\t\topArgs,\n\t\t\t\t\tgetAttributionKey(client, sequencedMessage),\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\tmaintenance: ({ deltaSegments, operation }, opArgs, client) => {\n\t\t\tif (operation === MergeTreeMaintenanceType.ACKNOWLEDGED && opArgs !== undefined) {\n\t\t\t\tattributeAnnotateOnSegments(\n\t\t\t\t\tdeltaSegments,\n\t\t\t\t\topArgs,\n\t\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction combineMergeTreeCallbacks(callbacks: AttributionCallbacks[]): AttributionCallbacks {\n\treturn {\n\t\tdelta: (...args) => callbacks.forEach(({ delta }) => delta(...args)),\n\t\tmaintenance: (...args) => callbacks.forEach(({ maintenance }) => maintenance(...args)),\n\t};\n}\n\n/**\n * @alpha\n * @returns - An {@link AttributionPolicy} which tracks only insertion of content.\n */\nexport function createInsertOnlyAttributionPolicy(): AttributionPolicy {\n\treturn createAttributionPolicyFromCallbacks(\n\t\tcombineMergeTreeCallbacks([\n\t\t\tensureAttributionCollectionCallbacks,\n\t\t\tinsertOnlyAttributionPolicyCallbacks,\n\t\t]),\n\t);\n}\n\n/**\n * @param propNames - List of property names for which attribution should be tracked.\n * @returns - A policy which only attributes annotation of the properties specified.\n * Keys for each property are stored under attribution channels of the same name--see example below.\n *\n * @example\n *\n * ```typescript\n * // Use this policy when creating your merge-tree:\n * const policy = createPropertyTrackingAttributionPolicyFactory(\"bold\", \"italic\");\n * // ... later, you can get attribution keys for the last time the \"bold\" and \"italic\"\n * // properties were changed on a segment using `getAtOffset`:\n * const lastBoldedAttributionKey = segment.attribution?.getAtOffset(0, \"bold\");\n * const lastItalicizedAttributionKey = segment.attribution?.getAtOffset(0, \"italic\");\n * ```\n * @alpha\n */\nexport function createPropertyTrackingAttributionPolicyFactory(\n\t...propNames: string[]\n): () => AttributionPolicy {\n\treturn () =>\n\t\tcreateAttributionPolicyFromCallbacks(\n\t\t\tcombineMergeTreeCallbacks([\n\t\t\t\tensureAttributionCollectionCallbacks,\n\t\t\t\tcreatePropertyTrackingMergeTreeCallbacks(...propNames),\n\t\t\t]),\n\t\t);\n}\n\n/**\n * Creates an attribution policy which tracks insertion as well as annotation of certain property names.\n * This combines the policies creatable using {@link createPropertyTrackingAttributionPolicyFactory} and\n * {@link createInsertOnlyAttributionPolicy}: see there for more details.\n * @alpha\n */\nexport function createPropertyTrackingAndInsertionAttributionPolicyFactory(\n\t...propNames: string[]\n): () => AttributionPolicy {\n\treturn () =>\n\t\tcreateAttributionPolicyFromCallbacks(\n\t\t\tcombineMergeTreeCallbacks([\n\t\t\t\tensureAttributionCollectionCallbacks,\n\t\t\t\tinsertOnlyAttributionPolicyCallbacks,\n\t\t\t\tcreatePropertyTrackingMergeTreeCallbacks(...propNames),\n\t\t\t]),\n\t\t);\n}\n"]}
1
+ {"version":3,"file":"attributionPolicy.js","sourceRoot":"","sources":["../src/attributionPolicy.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAKtD,qEAMkC;AAClC,+BAA2C;AAC3C,mEAAgE;AAkBhE,SAAS,oCAAoC,CAAC,EAC7C,KAAK,EACL,WAAW,GACW;IACtB,IAAI,WAAqC,CAAC;IAC1C,OAAO;QACN,MAAM,EAAE,CAAC,MAAc,EAAE,EAAE;YAC1B,IAAA,qBAAM,EACL,WAAW,KAAK,SAAS,EACzB,KAAK,CAAC,+CAA+C,CACrD,CAAC;YAEF,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YAChF,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE,M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AAG,SAAmB;IAEtB,OAAO,GAAG,EAAE,CACX,oCAAoC,CACnC,yBAAyB,CAAC;QACzB,oCAAoC;QACpC,oCAAoC;QACpC,wCAAwC,CAAC,GAAG,SAAS,CAAC;KACtD,CAAC,CACF,CAAC;AACJ,CAAC;AAXD,gIAWC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { AttributionKey } from \"@fluidframework/runtime-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { AttributionPolicy } from \"./mergeTree\";\nimport { Client } from \"./client\";\nimport {\n\tIMergeTreeDeltaCallbackArgs,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tIMergeTreeSegmentDelta,\n\tMergeTreeMaintenanceType,\n} from \"./mergeTreeDeltaCallback\";\nimport { MergeTreeDeltaType } from \"./ops\";\nimport { AttributionCollection } from \"./attributionCollection\";\n\n// Note: these thinly wrap MergeTreeDeltaCallback and MergeTreeMaintenanceCallback to provide the client.\n// This is because the base callbacks don't always have enough information to infer whether the op being\n// processed is in a detached or attached state, which may affect the attribution key.\ninterface AttributionCallbacks {\n\tdelta: (\n\t\topArgs: IMergeTreeDeltaOpArgs,\n\t\tdeltaArgs: IMergeTreeDeltaCallbackArgs,\n\t\tclient: Client,\n\t) => void;\n\tmaintenance: (\n\t\tmaintenanceArgs: IMergeTreeMaintenanceCallbackArgs,\n\t\topArgs: IMergeTreeDeltaOpArgs | undefined,\n\t\tclient: Client,\n\t) => void;\n}\n\nfunction createAttributionPolicyFromCallbacks({\n\tdelta,\n\tmaintenance,\n}: AttributionCallbacks): AttributionPolicy {\n\tlet unsubscribe: undefined | (() => void);\n\treturn {\n\t\tattach: (client: Client) => {\n\t\t\tassert(\n\t\t\t\tunsubscribe === undefined,\n\t\t\t\t0x557 /* cannot attach to multiple clients at once */,\n\t\t\t);\n\n\t\t\tconst deltaSubscribed = (opArgs, deltaArgs) => delta(opArgs, deltaArgs, client);\n\t\t\tconst maintenanceSubscribed = (args, opArgs) => maintenance(args, opArgs, client);\n\n\t\t\tclient.on(\"delta\", deltaSubscribed);\n\t\t\tclient.on(\"maintenance\", maintenanceSubscribed);\n\n\t\t\tunsubscribe = () => {\n\t\t\t\tclient.off(\"delta\", deltaSubscribed);\n\t\t\t\tclient.off(\"maintenance\", maintenanceSubscribed);\n\t\t\t};\n\t\t},\n\t\tdetach: () => {\n\t\t\tunsubscribe?.();\n\t\t\tunsubscribe = undefined;\n\t\t},\n\t\tget isAttached() {\n\t\t\treturn unsubscribe !== undefined;\n\t\t},\n\t\tserializer: AttributionCollection,\n\t};\n}\n\nconst ensureAttributionCollectionCallbacks: AttributionCallbacks = {\n\tdelta: ({ op }, { deltaSegments }) => {\n\t\tif (op.type === MergeTreeDeltaType.INSERT) {\n\t\t\tfor (const { segment } of deltaSegments) {\n\t\t\t\tsegment.attribution = new AttributionCollection(segment.cachedLength);\n\t\t\t}\n\t\t}\n\t},\n\tmaintenance: () => {},\n};\n\nconst getAttributionKey = (\n\tclient: Client,\n\tmsg: ISequencedDocumentMessage | undefined,\n): AttributionKey => {\n\tif (msg) {\n\t\treturn { type: \"op\", seq: msg.sequenceNumber };\n\t}\n\tconst collabWindow = client.getCollabWindow();\n\treturn collabWindow.collaborating ? { type: \"local\" } : { type: \"detached\", id: 0 };\n};\n\nconst attributeInsertionOnSegments = (\n\tdeltaSegments: IMergeTreeSegmentDelta[],\n\tkey: AttributionKey,\n): void => {\n\tfor (const { segment } of deltaSegments) {\n\t\tif (segment.seq !== undefined) {\n\t\t\tsegment.attribution?.update(\n\t\t\t\tundefined,\n\t\t\t\tnew AttributionCollection(segment.cachedLength, key),\n\t\t\t);\n\t\t}\n\t}\n};\n\nconst insertOnlyAttributionPolicyCallbacks: AttributionCallbacks = {\n\tdelta: (opArgs, { deltaSegments, operation }, client) => {\n\t\tif (operation === MergeTreeDeltaType.INSERT) {\n\t\t\tattributeInsertionOnSegments(\n\t\t\t\tdeltaSegments,\n\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t);\n\t\t}\n\t},\n\tmaintenance: ({ deltaSegments, operation }, opArgs, client) => {\n\t\tif (\n\t\t\toperation === MergeTreeMaintenanceType.ACKNOWLEDGED &&\n\t\t\topArgs?.op.type === MergeTreeDeltaType.INSERT\n\t\t) {\n\t\t\tattributeInsertionOnSegments(\n\t\t\t\tdeltaSegments,\n\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t);\n\t\t}\n\t},\n};\n\nfunction createPropertyTrackingMergeTreeCallbacks(...propNames: string[]): AttributionCallbacks {\n\tconst toTrack = propNames.map((entry) => ({ propName: entry, channelName: entry }));\n\tconst attributeAnnotateOnSegments = (\n\t\tdeltaSegments: IMergeTreeSegmentDelta[],\n\t\t{ op, sequencedMessage }: IMergeTreeDeltaOpArgs,\n\t\tkey: AttributionKey,\n\t): void => {\n\t\tfor (const { segment } of deltaSegments) {\n\t\t\tfor (const { propName, channelName } of toTrack) {\n\t\t\t\tconst shouldAttributeInsert =\n\t\t\t\t\top.type === MergeTreeDeltaType.INSERT &&\n\t\t\t\t\tsegment.properties?.[propName] !== undefined;\n\n\t\t\t\tconst isLocal = sequencedMessage === undefined;\n\t\t\t\tconst shouldAttributeAnnotate =\n\t\t\t\t\top.type === MergeTreeDeltaType.ANNOTATE &&\n\t\t\t\t\t// Only attribute annotations which change the tracked property\n\t\t\t\t\top.props[propName] !== undefined &&\n\t\t\t\t\t// Local changes to the tracked property always take effect\n\t\t\t\t\t(isLocal ||\n\t\t\t\t\t\t// Acked changes only take effect if there isn't a pending local change\n\t\t\t\t\t\t(!isLocal && !segment.propertyManager?.hasPendingProperty(propName)));\n\n\t\t\t\tif (shouldAttributeInsert || shouldAttributeAnnotate) {\n\t\t\t\t\tsegment.attribution?.update(\n\t\t\t\t\t\tchannelName,\n\t\t\t\t\t\tnew AttributionCollection(segment.cachedLength, key),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\treturn {\n\t\tdelta: (opArgs, { deltaSegments }, client) => {\n\t\t\tconst { op, sequencedMessage } = opArgs;\n\t\t\tif (op.type === MergeTreeDeltaType.ANNOTATE || op.type === MergeTreeDeltaType.INSERT) {\n\t\t\t\tattributeAnnotateOnSegments(\n\t\t\t\t\tdeltaSegments,\n\t\t\t\t\topArgs,\n\t\t\t\t\tgetAttributionKey(client, sequencedMessage),\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\tmaintenance: ({ deltaSegments, operation }, opArgs, client) => {\n\t\t\tif (operation === MergeTreeMaintenanceType.ACKNOWLEDGED && opArgs !== undefined) {\n\t\t\t\tattributeAnnotateOnSegments(\n\t\t\t\t\tdeltaSegments,\n\t\t\t\t\topArgs,\n\t\t\t\t\tgetAttributionKey(client, opArgs.sequencedMessage),\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction combineMergeTreeCallbacks(callbacks: AttributionCallbacks[]): AttributionCallbacks {\n\treturn {\n\t\tdelta: (...args) => callbacks.forEach(({ delta }) => delta(...args)),\n\t\tmaintenance: (...args) => callbacks.forEach(({ maintenance }) => maintenance(...args)),\n\t};\n}\n\n/**\n * @alpha\n * @returns - An {@link AttributionPolicy} which tracks only insertion of content.\n */\nexport function createInsertOnlyAttributionPolicy(): AttributionPolicy {\n\treturn createAttributionPolicyFromCallbacks(\n\t\tcombineMergeTreeCallbacks([\n\t\t\tensureAttributionCollectionCallbacks,\n\t\t\tinsertOnlyAttributionPolicyCallbacks,\n\t\t]),\n\t);\n}\n\n/**\n * @param propNames - List of property names for which attribution should be tracked.\n * @returns - A policy which only attributes annotation of the properties specified.\n * Keys for each property are stored under attribution channels of the same name--see example below.\n *\n * @example\n *\n * ```typescript\n * // Use this policy when creating your merge-tree:\n * const policy = createPropertyTrackingAttributionPolicyFactory(\"bold\", \"italic\");\n * // ... later, you can get attribution keys for the last time the \"bold\" and \"italic\"\n * // properties were changed on a segment using `getAtOffset`:\n * const lastBoldedAttributionKey = segment.attribution?.getAtOffset(0, \"bold\");\n * const lastItalicizedAttributionKey = segment.attribution?.getAtOffset(0, \"italic\");\n * ```\n * @alpha\n */\nexport function createPropertyTrackingAttributionPolicyFactory(\n\t...propNames: string[]\n): () => AttributionPolicy {\n\treturn () =>\n\t\tcreateAttributionPolicyFromCallbacks(\n\t\t\tcombineMergeTreeCallbacks([\n\t\t\t\tensureAttributionCollectionCallbacks,\n\t\t\t\tcreatePropertyTrackingMergeTreeCallbacks(...propNames),\n\t\t\t]),\n\t\t);\n}\n\n/**\n * Creates an attribution policy which tracks insertion as well as annotation of certain property names.\n * This combines the policies creatable using {@link createPropertyTrackingAttributionPolicyFactory} and\n * {@link createInsertOnlyAttributionPolicy}: see there for more details.\n * @alpha\n */\nexport function createPropertyTrackingAndInsertionAttributionPolicyFactory(\n\t...propNames: string[]\n): () => AttributionPolicy {\n\treturn () =>\n\t\tcreateAttributionPolicyFromCallbacks(\n\t\t\tcombineMergeTreeCallbacks([\n\t\t\t\tensureAttributionCollectionCallbacks,\n\t\t\t\tinsertOnlyAttributionPolicyCallbacks,\n\t\t\t\tcreatePropertyTrackingMergeTreeCallbacks(...propNames),\n\t\t\t]),\n\t\t);\n}\n"]}
package/dist/client.d.ts CHANGED
@@ -223,19 +223,6 @@ export declare class Client extends TypedEventEmitter<IClientEvents> {
223
223
  segment: T | undefined;
224
224
  offset: number | undefined;
225
225
  };
226
- /**
227
- * Returns the position to slide a reference to if a slide is required.
228
- * @param segoff - The segment and offset to slide from
229
- * @returns - segment and offset to slide the reference to
230
- * @deprecated Use getSlideToSegoff function instead.
231
- */
232
- getSlideToSegment(segoff: {
233
- segment: ISegment | undefined;
234
- offset: number | undefined;
235
- }): {
236
- segment: ISegment | undefined;
237
- offset: number | undefined;
238
- };
239
226
  getPropertiesAtPosition(pos: number): PropertySet | undefined;
240
227
  getRangeExtentsOfPosition(pos: number): {
241
228
  posStart: number | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAU,iBAAiB,EAAmB,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAgB,MAAM,iCAAiC,CAAC;AAKpF,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EACN,mBAAmB,EAGnB,QAAQ,EACR,cAAc,EACd,MAAM,EACN,YAAY,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,2BAA2B,EAC3B,iCAAiC,EACjC,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,EAEjB,aAAa,EACb,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAA6B,MAAM,sBAAsB,CAAC;AAInG,OAAO,EAAgC,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAK9E;;;;;;GAMG;AACH,MAAM,WAAW,aAA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