@fluidframework/merge-tree 2.1.0 → 2.2.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 (152) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +2 -2
  3. package/api-report/merge-tree.legacy.alpha.api.md +47 -11
  4. package/dist/attributionCollection.d.ts.map +1 -1
  5. package/dist/attributionCollection.js +9 -2
  6. package/dist/attributionCollection.js.map +1 -1
  7. package/dist/attributionPolicy.d.ts.map +1 -1
  8. package/dist/attributionPolicy.js +5 -9
  9. package/dist/attributionPolicy.js.map +1 -1
  10. package/dist/client.d.ts.map +1 -1
  11. package/dist/client.js +18 -19
  12. package/dist/client.js.map +1 -1
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +5 -2
  16. package/dist/index.js.map +1 -1
  17. package/dist/legacy.d.ts +4 -0
  18. package/dist/localReference.d.ts +6 -0
  19. package/dist/localReference.d.ts.map +1 -1
  20. package/dist/localReference.js.map +1 -1
  21. package/dist/mergeTree.d.ts +11 -1
  22. package/dist/mergeTree.d.ts.map +1 -1
  23. package/dist/mergeTree.js +51 -14
  24. package/dist/mergeTree.js.map +1 -1
  25. package/dist/mergeTreeNodes.d.ts +35 -1
  26. package/dist/mergeTreeNodes.d.ts.map +1 -1
  27. package/dist/mergeTreeNodes.js +35 -12
  28. package/dist/mergeTreeNodes.js.map +1 -1
  29. package/dist/properties.d.ts.map +1 -1
  30. package/dist/properties.js +7 -21
  31. package/dist/properties.js.map +1 -1
  32. package/dist/referencePositions.d.ts +6 -0
  33. package/dist/referencePositions.d.ts.map +1 -1
  34. package/dist/referencePositions.js.map +1 -1
  35. package/dist/segmentGroupCollection.d.ts +3 -0
  36. package/dist/segmentGroupCollection.d.ts.map +1 -1
  37. package/dist/segmentGroupCollection.js +3 -0
  38. package/dist/segmentGroupCollection.js.map +1 -1
  39. package/dist/segmentPropertiesManager.d.ts +8 -0
  40. package/dist/segmentPropertiesManager.d.ts.map +1 -1
  41. package/dist/segmentPropertiesManager.js +11 -8
  42. package/dist/segmentPropertiesManager.js.map +1 -1
  43. package/dist/sequencePlace.d.ts +66 -0
  44. package/dist/sequencePlace.d.ts.map +1 -0
  45. package/dist/sequencePlace.js +41 -0
  46. package/dist/sequencePlace.js.map +1 -0
  47. package/dist/snapshotlegacy.js +1 -1
  48. package/dist/snapshotlegacy.js.map +1 -1
  49. package/dist/test/obliterate.rangeExpansion.spec.d.ts +6 -0
  50. package/dist/test/obliterate.rangeExpansion.spec.d.ts.map +1 -0
  51. package/dist/test/obliterate.rangeExpansion.spec.js +288 -0
  52. package/dist/test/obliterate.rangeExpansion.spec.js.map +1 -0
  53. package/dist/test/obliterate.reconnect.spec.js +5 -5
  54. package/dist/test/obliterate.reconnect.spec.js.map +1 -1
  55. package/dist/test/reconnectHelper.d.ts +3 -3
  56. package/dist/test/reconnectHelper.d.ts.map +1 -1
  57. package/dist/test/reconnectHelper.js +14 -3
  58. package/dist/test/reconnectHelper.js.map +1 -1
  59. package/dist/test/resetPendingSegmentsToOp.spec.js +12 -0
  60. package/dist/test/resetPendingSegmentsToOp.spec.js.map +1 -1
  61. package/dist/test/testClient.d.ts +3 -3
  62. package/dist/test/testClient.d.ts.map +1 -1
  63. package/dist/test/testClient.js +4 -16
  64. package/dist/test/testClient.js.map +1 -1
  65. package/dist/test/text.js +1 -1
  66. package/dist/test/text.js.map +1 -1
  67. package/dist/textSegment.d.ts +2 -2
  68. package/dist/textSegment.d.ts.map +1 -1
  69. package/dist/textSegment.js +3 -7
  70. package/dist/textSegment.js.map +1 -1
  71. package/lib/attributionCollection.d.ts.map +1 -1
  72. package/lib/attributionCollection.js +9 -2
  73. package/lib/attributionCollection.js.map +1 -1
  74. package/lib/attributionPolicy.d.ts.map +1 -1
  75. package/lib/attributionPolicy.js +5 -9
  76. package/lib/attributionPolicy.js.map +1 -1
  77. package/lib/client.d.ts.map +1 -1
  78. package/lib/client.js +21 -22
  79. package/lib/client.js.map +1 -1
  80. package/lib/index.d.ts +1 -0
  81. package/lib/index.d.ts.map +1 -1
  82. package/lib/index.js +1 -0
  83. package/lib/index.js.map +1 -1
  84. package/lib/legacy.d.ts +4 -0
  85. package/lib/localReference.d.ts +6 -0
  86. package/lib/localReference.d.ts.map +1 -1
  87. package/lib/localReference.js.map +1 -1
  88. package/lib/mergeTree.d.ts +11 -1
  89. package/lib/mergeTree.d.ts.map +1 -1
  90. package/lib/mergeTree.js +49 -13
  91. package/lib/mergeTree.js.map +1 -1
  92. package/lib/mergeTreeNodes.d.ts +35 -1
  93. package/lib/mergeTreeNodes.d.ts.map +1 -1
  94. package/lib/mergeTreeNodes.js +35 -12
  95. package/lib/mergeTreeNodes.js.map +1 -1
  96. package/lib/properties.d.ts.map +1 -1
  97. package/lib/properties.js +7 -21
  98. package/lib/properties.js.map +1 -1
  99. package/lib/referencePositions.d.ts +6 -0
  100. package/lib/referencePositions.d.ts.map +1 -1
  101. package/lib/referencePositions.js.map +1 -1
  102. package/lib/segmentGroupCollection.d.ts +3 -0
  103. package/lib/segmentGroupCollection.d.ts.map +1 -1
  104. package/lib/segmentGroupCollection.js +3 -0
  105. package/lib/segmentGroupCollection.js.map +1 -1
  106. package/lib/segmentPropertiesManager.d.ts +8 -0
  107. package/lib/segmentPropertiesManager.d.ts.map +1 -1
  108. package/lib/segmentPropertiesManager.js +12 -9
  109. package/lib/segmentPropertiesManager.js.map +1 -1
  110. package/lib/sequencePlace.d.ts +66 -0
  111. package/lib/sequencePlace.d.ts.map +1 -0
  112. package/lib/sequencePlace.js +37 -0
  113. package/lib/sequencePlace.js.map +1 -0
  114. package/lib/snapshotlegacy.js +1 -1
  115. package/lib/snapshotlegacy.js.map +1 -1
  116. package/lib/test/obliterate.rangeExpansion.spec.d.ts +6 -0
  117. package/lib/test/obliterate.rangeExpansion.spec.d.ts.map +1 -0
  118. package/lib/test/obliterate.rangeExpansion.spec.js +286 -0
  119. package/lib/test/obliterate.rangeExpansion.spec.js.map +1 -0
  120. package/lib/test/obliterate.reconnect.spec.js +5 -5
  121. package/lib/test/obliterate.reconnect.spec.js.map +1 -1
  122. package/lib/test/reconnectHelper.d.ts +3 -3
  123. package/lib/test/reconnectHelper.d.ts.map +1 -1
  124. package/lib/test/reconnectHelper.js +14 -3
  125. package/lib/test/reconnectHelper.js.map +1 -1
  126. package/lib/test/resetPendingSegmentsToOp.spec.js +12 -0
  127. package/lib/test/resetPendingSegmentsToOp.spec.js.map +1 -1
  128. package/lib/test/testClient.d.ts +3 -3
  129. package/lib/test/testClient.d.ts.map +1 -1
  130. package/lib/test/testClient.js +4 -16
  131. package/lib/test/testClient.js.map +1 -1
  132. package/lib/test/text.js +1 -1
  133. package/lib/test/text.js.map +1 -1
  134. package/lib/textSegment.d.ts +2 -2
  135. package/lib/textSegment.d.ts.map +1 -1
  136. package/lib/textSegment.js +3 -7
  137. package/lib/textSegment.js.map +1 -1
  138. package/package.json +19 -19
  139. package/src/attributionCollection.ts +12 -2
  140. package/src/attributionPolicy.ts +6 -7
  141. package/src/client.ts +28 -23
  142. package/src/index.ts +6 -0
  143. package/src/localReference.ts +8 -1
  144. package/src/mergeTree.ts +74 -17
  145. package/src/mergeTreeNodes.ts +66 -14
  146. package/src/properties.ts +7 -22
  147. package/src/referencePositions.ts +6 -0
  148. package/src/segmentGroupCollection.ts +3 -0
  149. package/src/segmentPropertiesManager.ts +13 -9
  150. package/src/sequencePlace.ts +89 -0
  151. package/src/snapshotlegacy.ts +1 -1
  152. package/src/textSegment.ts +8 -9
@@ -1 +1 @@
1
- {"version":3,"file":"attributionCollection.js","sourceRoot":"","sources":["../src/attributionCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAM9E,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAsItE,gDAAgD;AAChD,MAAM,UAAU,uBAAuB;AACtC,kDAAkD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,CAAC;CACD","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\t// TODO Non null asserting, why is this not null?\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\t// TODO Non null asserting, why is this not null?\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\t// TODO Non null asserting, why is this not null?\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\t// TODO Non null asserting, why is this not null?\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\t// TODO Non null asserting, why is this not null?\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tsplitCollection.offsets.push(Math.max(this.offsets[i]! - pos, 0));\n\t\t\tconst key = this.keys[i];\n\t\t\tif (key !== undefined) {\n\t\t\t\tsplitCollection.keys.push(key);\n\t\t\t}\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\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.offsets.push(other.offsets[i]! + this.length);\n\t\t\t\t// Looping through the keys, so we can be sure that the key is not undefined.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\t// TODO Non null asserting, why is this not null?\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\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\t// TODO Non null asserting, why is this not null?\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tif (posBreakpoints[curIndex]! > cumulativeSegPos) {\n\t\t\t\t\tcurIndex--;\n\t\t\t\t}\n\n\t\t\t\t// TODO Non null asserting, why is this not null?\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\twhile (posBreakpoints[curIndex]! < cumulativeSegPos + segment.cachedLength) {\n\t\t\t\t\t// TODO Non null asserting, why is this not null?\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tconst nextOffset = Math.max(posBreakpoints[curIndex]! - cumulativeSegPos, 0);\n\t\t\t\t\t// TODO Non null asserting, why is this not null?\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\t// TODO Non null asserting, why is this not null?\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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] = collection;\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,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAM9E,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAsItE,gDAAgD;AAChD,MAAM,UAAU,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,eAAe,CAAC,CAAC,EAAE,+BAA+B,CAAC,CAAC;QACrD,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,OAAO,qBAAqB;IAMjC,IAAY,cAAc;QACzB,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,YACS,OAAe;IACvB,kDAAkD;IAClD,SAAiC;QAFzB,YAAO,GAAP,OA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AM,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","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\t// TODO Non null asserting, why is this not null?\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\t// TODO Non null asserting, why is this not null?\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\t// TODO Non null asserting, why is this not null?\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\t// TODO Non null asserting, why is this not null?\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\t// TODO Non null asserting, why is this not null?\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tsplitCollection.offsets.push(Math.max(this.offsets[i]! - pos, 0));\n\t\t\tconst key = this.keys[i];\n\t\t\tif (key !== undefined) {\n\t\t\t\tsplitCollection.keys.push(key);\n\t\t\t}\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\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.offsets.push(other.offsets[i]! + this.length);\n\t\t\t\t// Looping through the keys, so we can be sure that the key is not undefined.\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\t// TODO Non null asserting, why is this not null?\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\t// TODO Non null asserting, why is this not null?\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tif (posBreakpoints[curIndex]! > cumulativeSegPos) {\n\t\t\t\t\tcurIndex--;\n\t\t\t\t}\n\n\t\t\t\t// TODO Non null asserting, why is this not null?\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\twhile (posBreakpoints[curIndex]! < cumulativeSegPos + segment.cachedLength) {\n\t\t\t\t\t// TODO Non null asserting, why is this not null?\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tconst nextOffset = Math.max(posBreakpoints[curIndex]! - cumulativeSegPos, 0);\n\t\t\t\t\t// TODO Non null asserting, why is this not null?\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\t// TODO Non null asserting, why is this not null?\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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 +1 @@
1
- {"version":3,"file":"attributionPolicy.d.ts","sourceRoot":"","sources":["../src/attributionPolicy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AA6LnD;;;GAGG;AACH,wBAAgB,iCAAiC,IAAI,iBAAiB,CAOrE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,8CAA8C,CAC7D,GAAG,SAAS,EAAE,MAAM,EAAE,GACpB,MAAM,iBAAiB,CAQzB;AAED;;;;;GAKG;AACH,wBAAgB,0DAA0D,CACzE,GAAG,SAAS,EAAE,MAAM,EAAE,GACpB,MAAM,iBAAiB,CASzB"}
1
+ {"version":3,"file":"attributionPolicy.d.ts","sourceRoot":"","sources":["../src/attributionPolicy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AA4LnD;;;GAGG;AACH,wBAAgB,iCAAiC,IAAI,iBAAiB,CAOrE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,8CAA8C,CAC7D,GAAG,SAAS,EAAE,MAAM,EAAE,GACpB,MAAM,iBAAiB,CAQzB;AAED;;;;;GAKG;AACH,wBAAgB,0DAA0D,CACzE,GAAG,SAAS,EAAE,MAAM,EAAE,GACpB,MAAM,iBAAiB,CASzB"}
@@ -72,19 +72,15 @@ const insertOnlyAttributionPolicyCallbacks = {
72
72
  };
73
73
  function createPropertyTrackingMergeTreeCallbacks(...propNames) {
74
74
  const toTrack = propNames.map((entry) => ({ propName: entry, channelName: entry }));
75
- const attributeAnnotateOnSegments = (deltaSegments, { op, sequencedMessage }, key) => {
76
- for (const { segment } of deltaSegments) {
75
+ const attributeAnnotateOnSegments = (isLocal, deltaSegments, { op }, key) => {
76
+ for (const { segment, propertyDeltas } of deltaSegments) {
77
77
  for (const { propName, channelName } of toTrack) {
78
78
  const shouldAttributeInsert = op.type === MergeTreeDeltaType.INSERT &&
79
79
  segment.properties?.[propName] !== undefined;
80
- const isLocal = sequencedMessage === undefined;
81
80
  const shouldAttributeAnnotate = op.type === MergeTreeDeltaType.ANNOTATE &&
82
81
  // Only attribute annotations which change the tracked property
83
82
  op.props[propName] !== undefined &&
84
- // Local changes to the tracked property always take effect
85
- (isLocal ||
86
- // Acked changes only take effect if there isn't a pending local change
87
- (!isLocal && !segment.propertyManager?.hasPendingProperty(propName)));
83
+ (isLocal || (propertyDeltas !== undefined && propName in propertyDeltas));
88
84
  if (shouldAttributeInsert || shouldAttributeAnnotate) {
89
85
  segment.attribution?.update(channelName, new AttributionCollection(segment.cachedLength, key));
90
86
  }
@@ -95,12 +91,12 @@ function createPropertyTrackingMergeTreeCallbacks(...propNames) {
95
91
  delta: (opArgs, { deltaSegments }, client) => {
96
92
  const { op, sequencedMessage } = opArgs;
97
93
  if (op.type === MergeTreeDeltaType.ANNOTATE || op.type === MergeTreeDeltaType.INSERT) {
98
- attributeAnnotateOnSegments(deltaSegments, opArgs, getAttributionKey(client, sequencedMessage));
94
+ attributeAnnotateOnSegments(sequencedMessage === undefined, deltaSegments, opArgs, getAttributionKey(client, sequencedMessage));
99
95
  }
100
96
  },
101
97
  maintenance: ({ deltaSegments, operation }, opArgs, client) => {
102
98
  if (operation === MergeTreeMaintenanceType.ACKNOWLEDGED && opArgs !== undefined) {
103
- attributeAnnotateOnSegments(deltaSegments, opArgs, getAttributionKey(client, opArgs.sequencedMessage));
99
+ attributeAnnotateOnSegments(true, deltaSegments, opArgs, getAttributionKey(client, opArgs.sequencedMessage));
104
100
  }
105
101
  },
106
102
  };
@@ -1 +1 @@
1
- {"version":3,"file":"attributionPolicy.js","sourceRoot":"","sources":["../src/attributionPolicy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAI7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAInE,OAAO,EAKN,wBAAwB,GACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAoB9C,SAAS,oCAAoC,CAAC,EAC7C,KAAK,EACL,WAAW,GACW;IACtB,IAAI,WAAqC,CAAC;IAC1C,OAAO;QACN,gDAAgD;QAChD,MAAM,EAAE,CAAC,MAAc,EAAQ,EAAE;YAChC,MAAM,CAAC,WAAW,KAAK,SAAS,EAAE,KAAK,CAAC,+CAA+C,CAAC,CAAC;YAEzF,MAAM,eAAe,GAAkC,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,CAC5E,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YAClC,MAAM,qBAAqB,GAAwC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CACnF,WAAW,CAAC,I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AAC,GAAG,SAAS,CAAC;KACtD,CAAC,CACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0DAA0D,CACzE,GAAG,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","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 { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { AttributionKey } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { AttributionCollection } from \"./attributionCollection.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { Client } from \"./client.js\";\nimport { AttributionPolicy } from \"./mergeTree.js\";\nimport {\n\tIMergeTreeDeltaCallbackArgs,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tIMergeTreeSegmentDelta,\n\tMergeTreeMaintenanceType,\n} from \"./mergeTreeDeltaCallback.js\";\nimport { MergeTreeDeltaType } from \"./ops.js\";\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\t// eslint-disable-next-line import/no-deprecated\n\t\tclient: Client,\n\t) => void;\n\tmaintenance: (\n\t\tmaintenanceArgs: IMergeTreeMaintenanceCallbackArgs,\n\t\topArgs: IMergeTreeDeltaOpArgs | undefined,\n\t\t// eslint-disable-next-line import/no-deprecated\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\t// eslint-disable-next-line import/no-deprecated\n\t\tattach: (client: Client): void => {\n\t\t\tassert(unsubscribe === undefined, 0x557 /* cannot attach to multiple clients at once */);\n\n\t\t\tconst deltaSubscribed: AttributionCallbacks[\"delta\"] = (opArgs, deltaArgs) =>\n\t\t\t\tdelta(opArgs, deltaArgs, client);\n\t\t\tconst maintenanceSubscribed: AttributionCallbacks[\"maintenance\"] = (args, opArgs) =>\n\t\t\t\tmaintenance(args, opArgs, client);\n\n\t\t\tclient.on(\"delta\", deltaSubscribed);\n\t\t\tclient.on(\"maintenance\", maintenanceSubscribed);\n\n\t\t\tunsubscribe = (): void => {\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: (): void => {\n\t\t\tunsubscribe?.();\n\t\t\tunsubscribe = undefined;\n\t\t},\n\t\tget isAttached(): boolean {\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\t// eslint-disable-next-line import/no-deprecated\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(\n\t...propNames: string[]\n): 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): void => {\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): void => {\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): void => {\n\t\t\tfor (const { delta } of callbacks) delta(...args);\n\t\t},\n\t\tmaintenance: (...args): void => {\n\t\t\tfor (const { maintenance } of callbacks) maintenance(...args);\n\t\t},\n\t};\n}\n\n/**\n * Creates an {@link AttributionPolicy} which only tracks initial insertion of content.\n * @internal\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 * Creates an {@link AttributionPolicy} for tracking annotation of specific properties.\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 * @internal\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 * @internal\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":"attribut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ACnE,OAAO;QACN,KAAK,EAAE,CAAC,GAAG,IAAI,EAAQ,EAAE;YACxB,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,SAAS;gBAAE,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QACnD,CAAC;QACD,WAAW,EAAE,CAAC,GAAG,IAAI,EAAQ,EAAE;YAC9B,KAAK,MAAM,EAAE,WAAW,EAAE,IAAI,SAAS;gBAAE,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC;QAC/D,CAAC;KACD,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iCAAiC;IAChD,OAAO,oCAAoC,CAC1C,yBAAyB,CAAC;QACzB,oCAAoC;QACpC,oCAAoC;KACpC,CAAC,CACF,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,8CAA8C,CAC7D,GAAG,SAAmB;IAEtB,OAAO,GAAG,EAAE,CACX,oCAAoC,CACnC,yBAAyB,CAAC;QACzB,oCAAoC;QACpC,wCAAwC,CAAC,GAAG,SAAS,CAAC;KACtD,CAAC,CACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0DAA0D,CACzE,GAAG,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","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 { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { AttributionKey } from \"@fluidframework/runtime-definitions/internal\";\n\nimport { AttributionCollection } from \"./attributionCollection.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { Client } from \"./client.js\";\nimport { AttributionPolicy } from \"./mergeTree.js\";\nimport {\n\tIMergeTreeDeltaCallbackArgs,\n\tIMergeTreeDeltaOpArgs,\n\tIMergeTreeMaintenanceCallbackArgs,\n\tIMergeTreeSegmentDelta,\n\tMergeTreeMaintenanceType,\n} from \"./mergeTreeDeltaCallback.js\";\nimport { MergeTreeDeltaType } from \"./ops.js\";\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\t// eslint-disable-next-line import/no-deprecated\n\t\tclient: Client,\n\t) => void;\n\tmaintenance: (\n\t\tmaintenanceArgs: IMergeTreeMaintenanceCallbackArgs,\n\t\topArgs: IMergeTreeDeltaOpArgs | undefined,\n\t\t// eslint-disable-next-line import/no-deprecated\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\t// eslint-disable-next-line import/no-deprecated\n\t\tattach: (client: Client): void => {\n\t\t\tassert(unsubscribe === undefined, 0x557 /* cannot attach to multiple clients at once */);\n\n\t\t\tconst deltaSubscribed: AttributionCallbacks[\"delta\"] = (opArgs, deltaArgs) =>\n\t\t\t\tdelta(opArgs, deltaArgs, client);\n\t\t\tconst maintenanceSubscribed: AttributionCallbacks[\"maintenance\"] = (args, opArgs) =>\n\t\t\t\tmaintenance(args, opArgs, client);\n\n\t\t\tclient.on(\"delta\", deltaSubscribed);\n\t\t\tclient.on(\"maintenance\", maintenanceSubscribed);\n\n\t\t\tunsubscribe = (): void => {\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: (): void => {\n\t\t\tunsubscribe?.();\n\t\t\tunsubscribe = undefined;\n\t\t},\n\t\tget isAttached(): boolean {\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\t// eslint-disable-next-line import/no-deprecated\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(\n\t...propNames: string[]\n): AttributionCallbacks {\n\tconst toTrack = propNames.map((entry) => ({ propName: entry, channelName: entry }));\n\tconst attributeAnnotateOnSegments = (\n\t\tisLocal: boolean,\n\t\tdeltaSegments: IMergeTreeSegmentDelta[],\n\t\t{ op }: IMergeTreeDeltaOpArgs,\n\t\tkey: AttributionKey,\n\t): void => {\n\t\tfor (const { segment, propertyDeltas } 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 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(isLocal || (propertyDeltas !== undefined && propName in propertyDeltas));\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): void => {\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\tsequencedMessage === undefined,\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): void => {\n\t\t\tif (operation === MergeTreeMaintenanceType.ACKNOWLEDGED && opArgs !== undefined) {\n\t\t\t\tattributeAnnotateOnSegments(\n\t\t\t\t\ttrue,\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): void => {\n\t\t\tfor (const { delta } of callbacks) delta(...args);\n\t\t},\n\t\tmaintenance: (...args): void => {\n\t\t\tfor (const { maintenance } of callbacks) maintenance(...args);\n\t\t},\n\t};\n}\n\n/**\n * Creates an {@link AttributionPolicy} which only tracks initial insertion of content.\n * @internal\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 * Creates an {@link AttributionPolicy} for tracking annotation of specific properties.\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 * @internal\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 * @internal\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 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,KAAK,qBAAqB,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE3F,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAEN,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAErF,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EACN,mBAAmB,EAGnB,MAAM,0CAA0C,CAAC;AAKlD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAa,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,EAEX,2BAA2B,EAC3B,qBAAqB,EACr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AO,EAAE,kBAAkB,GAAG,IAAI;IA8BnD,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIlC,oBAAoB,CAAC,CAAC,SAAS,QAAQ,EACtC,GAAG,EAAE,MAAM,EACX,YAAY,CAAC,EAAE,IAAI,CAAC,yBAAyB,EAAE,yBAAyB,GAAG,UAAU,CAAC,EACtF,QAAQ,CAAC,EAAE,MAAM,GACf;QACF,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC;QACvB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;KAC3B;IAWD,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAU7D,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG;QACvC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;KAChC;IAaD,aAAa,IAAI,MAAM;IAIvB,WAAW,IAAI,MAAM;IAIrB,SAAS,IAAI,MAAM;IAInB,0BAA0B,CACzB,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,MAAM,SAAI,EACV,UAAU,SAAI,GACZ,IAAI;IAyBP;;;;;;;;OAQG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,UAAO,GAAG,MAAM,GAAG,SAAS;CAI3F"}
package/lib/client.js CHANGED
@@ -4,32 +4,24 @@
4
4
  */
5
5
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
6
6
  import { TypedEventEmitter } from "@fluid-internal/client-utils";
7
- import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
7
+ import { assert, unreachableCase, isObject } from "@fluidframework/core-utils/internal";
8
8
  import { MessageType, } from "@fluidframework/driver-definitions/internal";
9
9
  import { toDeltaManagerInternal } from "@fluidframework/runtime-utils/internal";
10
10
  import { LoggingError, UsageError, } from "@fluidframework/telemetry-utils/internal";
11
11
  import { MergeTreeTextHelper } from "./MergeTreeTextHelper.js";
12
12
  import { RedBlackTree } from "./collections/index.js";
13
13
  import { UnassignedSequenceNumber, UniversalSequenceNumber } from "./constants.js";
14
- import { MergeTree } from "./mergeTree.js";
14
+ import { MergeTree, errorIfOptionNotTrue } from "./mergeTree.js";
15
15
  import { walkAllChildSegments } from "./mergeTreeNodeWalk.js";
16
- import { compareStrings, } from "./mergeTreeNodes.js";
16
+ import { compareStrings, toMoveInfo, } from "./mergeTreeNodes.js";
17
17
  import { createAnnotateMarkerOp, createAnnotateRangeOp,
18
18
  // eslint-disable-next-line import/no-deprecated
19
19
  createGroupOp, createInsertSegmentOp, createObliterateRangeOp, createRemoveRangeOp, } from "./opBuilder.js";
20
20
  import { MergeTreeDeltaType, } from "./ops.js";
21
- import { createMap } from "./properties.js";
22
21
  import { DetachedReferencePosition } from "./referencePositions.js";
23
22
  import { SnapshotLoader } from "./snapshotLoader.js";
24
23
  import { SnapshotV1 } from "./snapshotV1.js";
25
24
  import { SnapshotLegacy } from "./snapshotlegacy.js";
26
- function removeMoveInfo(segment) {
27
- delete segment.movedSeq;
28
- delete segment.movedSeqs;
29
- delete segment.localMovedSeq;
30
- delete segment.movedClientIds;
31
- delete segment.wasMovedOnInsert;
32
- }
33
25
  /**
34
26
  * @deprecated This functionality was not meant to be exported and will be removed in a future release
35
27
  * @legacy
@@ -481,18 +473,24 @@ export class Client extends TypedEventEmitter {
481
473
  }
482
474
  case MergeTreeDeltaType.INSERT: {
483
475
  assert(segment.seq === UnassignedSequenceNumber, 0x037 /* "Segment already has assigned sequence number" */);
484
- let segInsertOp = segment;
485
- // The suppression is needed because the segment needs to have a type of any.
486
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
487
- if (typeof resetOp.seg === "object" && resetOp.seg.props !== undefined) {
488
- segInsertOp = segment.clone();
489
- segInsertOp.properties = createMap();
490
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
491
- segInsertOp.addProperties(resetOp.seg.props);
492
- }
493
- if (segment.movedSeq !== UnassignedSequenceNumber) {
494
- removeMoveInfo(segment);
476
+ const moveInfo = toMoveInfo(segment);
477
+ if (moveInfo !== undefined) {
478
+ errorIfOptionNotTrue(this._mergeTree.options, "mergeTreeEnableObliterateReconnect");
479
+ if (moveInfo.movedSeq !== UnassignedSequenceNumber) {
480
+ // the segment was remotely obliterated, so is considered removed
481
+ // we set the seq to the universal seq and remove the local seq,
482
+ // so its length is not considered for subsequent local changes
483
+ // this allows us to not send the op as even the local client will ignore the segment
484
+ segment.seq = UniversalSequenceNumber;
485
+ segment.localSeq = undefined;
486
+ break;
487
+ }
495
488
  }
489
+ const segInsertOp = segment.clone();
490
+ const opProps = isObject(resetOp.seg) && "props" in resetOp.seg && isObject(resetOp.seg.props)
491
+ ? { ...resetOp.seg.props }
492
+ : undefined;
493
+ segInsertOp.properties = opProps;
496
494
  newOp = createInsertSegmentOp(segmentPosition, segInsertOp);
497
495
  break;
498
496
  }
@@ -507,6 +505,7 @@ export class Client extends TypedEventEmitter {
507
505
  break;
508
506
  }
509
507
  case MergeTreeDeltaType.OBLITERATE: {
508
+ errorIfOptionNotTrue(this._mergeTree.options, "mergeTreeEnableObliterateReconnect");
510
509
  if (segment.localMovedSeq !== undefined &&
511
510
  segment.movedSeq === UnassignedSequenceNumber &&
512
511
  (segment.removedSeq === undefined ||