@fluidframework/merge-tree 2.0.0-internal.2.2.1 → 2.0.0-internal.2.3.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 (104) hide show
  1. package/.eslintrc.js +1 -1
  2. package/dist/attributionCollection.d.ts +49 -14
  3. package/dist/attributionCollection.d.ts.map +1 -1
  4. package/dist/attributionCollection.js +16 -16
  5. package/dist/attributionCollection.js.map +1 -1
  6. package/dist/client.d.ts +1 -0
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/client.js +16 -26
  9. package/dist/client.js.map +1 -1
  10. package/dist/endOfTreeSegment.d.ts +3 -3
  11. package/dist/endOfTreeSegment.d.ts.map +1 -1
  12. package/dist/endOfTreeSegment.js +5 -4
  13. package/dist/endOfTreeSegment.js.map +1 -1
  14. package/dist/index.d.ts +3 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/mergeTree.d.ts +58 -4
  18. package/dist/mergeTree.d.ts.map +1 -1
  19. package/dist/mergeTree.js +39 -20
  20. package/dist/mergeTree.js.map +1 -1
  21. package/dist/mergeTreeDeltaCallback.d.ts.map +1 -1
  22. package/dist/mergeTreeDeltaCallback.js.map +1 -1
  23. package/dist/mergeTreeNodes.d.ts +48 -7
  24. package/dist/mergeTreeNodes.d.ts.map +1 -1
  25. package/dist/mergeTreeNodes.js +15 -4
  26. package/dist/mergeTreeNodes.js.map +1 -1
  27. package/dist/partialLengths.d.ts +6 -4
  28. package/dist/partialLengths.d.ts.map +1 -1
  29. package/dist/partialLengths.js +10 -14
  30. package/dist/partialLengths.js.map +1 -1
  31. package/dist/snapshotChunks.d.ts +3 -0
  32. package/dist/snapshotChunks.d.ts.map +1 -1
  33. package/dist/snapshotChunks.js +1 -0
  34. package/dist/snapshotChunks.js.map +1 -1
  35. package/dist/snapshotLoader.d.ts +1 -0
  36. package/dist/snapshotLoader.d.ts.map +1 -1
  37. package/dist/snapshotLoader.js +29 -8
  38. package/dist/snapshotLoader.js.map +1 -1
  39. package/dist/snapshotV1.d.ts +1 -0
  40. package/dist/snapshotV1.d.ts.map +1 -1
  41. package/dist/snapshotV1.js +21 -6
  42. package/dist/snapshotV1.js.map +1 -1
  43. package/dist/snapshotlegacy.d.ts +2 -3
  44. package/dist/snapshotlegacy.d.ts.map +1 -1
  45. package/dist/snapshotlegacy.js +16 -12
  46. package/dist/snapshotlegacy.js.map +1 -1
  47. package/lib/attributionCollection.d.ts +49 -14
  48. package/lib/attributionCollection.d.ts.map +1 -1
  49. package/lib/attributionCollection.js +16 -16
  50. package/lib/attributionCollection.js.map +1 -1
  51. package/lib/client.d.ts +1 -0
  52. package/lib/client.d.ts.map +1 -1
  53. package/lib/client.js +16 -26
  54. package/lib/client.js.map +1 -1
  55. package/lib/endOfTreeSegment.d.ts +3 -3
  56. package/lib/endOfTreeSegment.d.ts.map +1 -1
  57. package/lib/endOfTreeSegment.js +5 -4
  58. package/lib/endOfTreeSegment.js.map +1 -1
  59. package/lib/index.d.ts +3 -1
  60. package/lib/index.d.ts.map +1 -1
  61. package/lib/index.js.map +1 -1
  62. package/lib/mergeTree.d.ts +58 -4
  63. package/lib/mergeTree.d.ts.map +1 -1
  64. package/lib/mergeTree.js +39 -20
  65. package/lib/mergeTree.js.map +1 -1
  66. package/lib/mergeTreeDeltaCallback.d.ts.map +1 -1
  67. package/lib/mergeTreeDeltaCallback.js.map +1 -1
  68. package/lib/mergeTreeNodes.d.ts +48 -7
  69. package/lib/mergeTreeNodes.d.ts.map +1 -1
  70. package/lib/mergeTreeNodes.js +15 -4
  71. package/lib/mergeTreeNodes.js.map +1 -1
  72. package/lib/partialLengths.d.ts +6 -4
  73. package/lib/partialLengths.d.ts.map +1 -1
  74. package/lib/partialLengths.js +9 -14
  75. package/lib/partialLengths.js.map +1 -1
  76. package/lib/snapshotChunks.d.ts +3 -0
  77. package/lib/snapshotChunks.d.ts.map +1 -1
  78. package/lib/snapshotChunks.js +1 -0
  79. package/lib/snapshotChunks.js.map +1 -1
  80. package/lib/snapshotLoader.d.ts +1 -0
  81. package/lib/snapshotLoader.d.ts.map +1 -1
  82. package/lib/snapshotLoader.js +29 -8
  83. package/lib/snapshotLoader.js.map +1 -1
  84. package/lib/snapshotV1.d.ts +1 -0
  85. package/lib/snapshotV1.d.ts.map +1 -1
  86. package/lib/snapshotV1.js +21 -6
  87. package/lib/snapshotV1.js.map +1 -1
  88. package/lib/snapshotlegacy.d.ts +2 -3
  89. package/lib/snapshotlegacy.d.ts.map +1 -1
  90. package/lib/snapshotlegacy.js +16 -12
  91. package/lib/snapshotlegacy.js.map +1 -1
  92. package/package.json +17 -15
  93. package/src/attributionCollection.ts +67 -33
  94. package/src/client.ts +53 -63
  95. package/src/endOfTreeSegment.ts +10 -8
  96. package/src/index.ts +6 -0
  97. package/src/mergeTree.ts +108 -25
  98. package/src/mergeTreeDeltaCallback.ts +0 -1
  99. package/src/mergeTreeNodes.ts +67 -9
  100. package/src/partialLengths.ts +11 -13
  101. package/src/snapshotChunks.ts +4 -0
  102. package/src/snapshotLoader.ts +34 -8
  103. package/src/snapshotV1.ts +27 -4
  104. package/src/snapshotlegacy.ts +22 -18
package/.eslintrc.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  module.exports = {
7
7
  "extends": [
8
- require.resolve("@fluidframework/eslint-config-fluid"),
8
+ require.resolve("@fluidframework/eslint-config-fluid/minimal"),
9
9
  "prettier"
10
10
  ],
11
11
  "parserOptions": {
@@ -2,31 +2,64 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ISegment as ISegmentCurrent } from "./mergeTreeNodes";
6
- interface ISegment extends ISegmentCurrent {
7
- attribution?: AttributionCollection<unknown>;
8
- }
5
+ import { AttributionKey, ISegment } from "./mergeTreeNodes";
9
6
  export interface SerializedAttributionCollection {
10
- keys: unknown[];
7
+ /**
8
+ * Parallel array with posBreakpoints which tracks the seq of insertion.
9
+ * Ex: if seqs is [45, 46] and posBreakpoints is [0, 3], the section of the string
10
+ * between offsets 0 and 3 was inserted at seq 45 and the section of the string between
11
+ * 3 and the length of the string was inserted at seq 46.
12
+ */
13
+ seqs: number[];
11
14
  posBreakpoints: number[];
12
15
  length: number;
13
16
  }
14
- export declare class AttributionCollection<T> {
17
+ /**
18
+ * @alpha
19
+ */
20
+ export interface IAttributionCollection<T> {
21
+ /**
22
+ * Retrieves the attribution key associated with the provided offset.
23
+ */
24
+ getAtOffset(offset: number): T;
25
+ /**
26
+ * Total length of all attribution keys in this collection.
27
+ */
28
+ readonly length: number;
29
+ /**
30
+ * Retrieve all key/offset pairs stored on this segment. Entries should be ordered by offset, such that
31
+ * the `i`th result's attribution key applies to offsets in the open range between the `i`th offset and the
32
+ * `i+1`th offset.
33
+ * The last entry's key applies to the open interval from the last entry's offset to this collection's length.
34
+ * @internal
35
+ */
36
+ getAll(): Iterable<{
37
+ offset: number;
38
+ key: T;
39
+ }>;
40
+ /** @internal */
41
+ splitAt(pos: number): IAttributionCollection<T>;
42
+ /** @internal */
43
+ append(other: IAttributionCollection<T>): void;
44
+ /** @internal */
45
+ clone(): IAttributionCollection<T>;
46
+ }
47
+ export declare class AttributionCollection implements IAttributionCollection<AttributionKey> {
15
48
  private _length;
16
49
  private readonly entries;
17
- constructor(baseEntry: T, _length: number);
18
- getAtOffset(offset: number): T;
50
+ constructor(baseEntry: number, _length: number);
51
+ getAtOffset(offset: number): AttributionKey;
19
52
  get length(): number;
20
53
  /**
21
54
  * Splits this attribution collection into two with entries for [0, pos) and [pos, length).
22
55
  */
23
- splitAt(pos: number): AttributionCollection<T>;
24
- append(other: AttributionCollection<T>): void;
56
+ splitAt(pos: number): AttributionCollection;
57
+ append(other: AttributionCollection): void;
25
58
  getAll(): {
26
59
  offset: number;
27
- key: T;
60
+ key: AttributionKey;
28
61
  }[];
29
- clone(): AttributionCollection<T>;
62
+ clone(): AttributionCollection;
30
63
  /**
31
64
  * Rehydrates attribution information from its serialized form into the provided iterable of consecutive segments.
32
65
  */
@@ -34,7 +67,9 @@ export declare class AttributionCollection<T> {
34
67
  /**
35
68
  * Condenses attribution information on consecutive segments into a `SerializedAttributionCollection`
36
69
  */
37
- static serializeAttributionCollections(segments: Iterable<ISegment>): SerializedAttributionCollection;
70
+ static serializeAttributionCollections(segments: Iterable<{
71
+ attribution?: IAttributionCollection<AttributionKey>;
72
+ cachedLength: number;
73
+ }>): SerializedAttributionCollection;
38
74
  }
39
- export {};
40
75
  //# sourceMappingURL=attributionCollection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"attributionCollection.d.ts","sourceRoot":"","sources":["../src/attributionCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAkB,QAAQ,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAG/E,UAAU,QAAS,SAAQ,eAAe;IACtC,WAAW,CAAC,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,+BAA+B;IAC5C,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,cAAc,EAAE,MAAM,EAAE,CAAC;IAEzB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,qBAAqB,CAAC,CAAC;IAGC,OAAO,CAAC,OAAO;IAFhD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6D;gBAElE,SAAS,EAAE,CAAC,EAAU,OAAO,EAAE,MAAM;IAIjD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC;IAOrC,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED;;OAEG;IACI,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAAC,CAAC,CAAC;IAc9C,MAAM,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,IAAI;IAW7C,MAAM,IAAI;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,CAAC,CAAC;KAAE,EAA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AO,CAAkE;gBAEvE,SAAS,EAAE,MAAM,EAAU,OAAO,EAAE,MAAM;IAItD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc;IAOlD,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED;;OAEG;IACI,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB;IAc3C,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI;IAW1C,MAAM,IAAI;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,cAAc,CAAC;KAAE,EAAE;IASpD,KAAK,IAAI,qBAAqB;IASrC;;OAEG;WACW,8BAA8B,CACxC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAC5B,OAAO,EAAE,+BAA+B,GACzC,IAAI;IAsBP;;OAEG;WACW,+BAA+B,CACzC,QAAQ,EAAE,QAAQ,CAAC;QAAE,WAAW,CAAC,EAAE,sBAAsB,CAAC,cAAc,CAAC,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;KAAE,CAAC,GACpG,+BAA+B;CA+BrC"}
@@ -18,7 +18,7 @@ class AttributionCollection {
18
18
  (0, common_utils_1.assert)(offset >= 0 && offset < this._length, 0x443 /* Requested offset should be valid */);
19
19
  const node = this.entries.floor(offset);
20
20
  (0, common_utils_1.assert)(node !== undefined, 0x444 /* Collection should have at least one entry */);
21
- return node.data;
21
+ return { type: "op", seq: node.data };
22
22
  }
23
23
  get length() {
24
24
  return this._length;
@@ -28,7 +28,7 @@ class AttributionCollection {
28
28
  */
29
29
  splitAt(pos) {
30
30
  const splitBaseEntry = this.getAtOffset(pos);
31
- const splitCollection = new AttributionCollection(splitBaseEntry, this.length - pos);
31
+ const splitCollection = new AttributionCollection(splitBaseEntry.seq, this.length - pos);
32
32
  for (let current = this.entries.ceil(pos); current !== undefined; current = this.entries.ceil(pos)) {
33
33
  // If there happened to be an attribution change at exactly pos, it's already set in the base entry
34
34
  if (current.key !== pos) {
@@ -40,7 +40,7 @@ class AttributionCollection {
40
40
  return splitCollection;
41
41
  }
42
42
  append(other) {
43
- const lastEntry = this.getAtOffset(this.length - 1);
43
+ const lastEntry = this.getAtOffset(this.length - 1).seq;
44
44
  other.entries.map(({ key, data }) => {
45
45
  if (key !== 0 || lastEntry !== data) {
46
46
  this.entries.put(key + this.length, data);
@@ -52,13 +52,13 @@ class AttributionCollection {
52
52
  getAll() {
53
53
  const results = [];
54
54
  this.entries.map(({ key, data }) => {
55
- results.push({ offset: key, key: data });
55
+ results.push({ offset: key, key: { type: "op", seq: data } });
56
56
  return true;
57
57
  });
58
58
  return results;
59
59
  }
60
60
  clone() {
61
- const copy = new AttributionCollection(this.getAtOffset(0), this.length);
61
+ const copy = new AttributionCollection(this.getAtOffset(0).seq, this.length);
62
62
  this.entries.map(({ key, data }) => {
63
63
  copy.entries.put(key, data);
64
64
  return true;
@@ -69,15 +69,15 @@ class AttributionCollection {
69
69
  * Rehydrates attribution information from its serialized form into the provided iterable of consecutive segments.
70
70
  */
71
71
  static populateAttributionCollections(segments, summary) {
72
- const { keys, posBreakpoints } = summary;
73
- (0, common_utils_1.assert)(keys.length === posBreakpoints.length && keys.length > 0, 0x445 /* Invalid attribution summary blob provided */);
72
+ const { seqs, posBreakpoints } = summary;
73
+ (0, common_utils_1.assert)(seqs.length === posBreakpoints.length && seqs.length > 0, 0x445 /* Invalid attribution summary blob provided */);
74
74
  let curIndex = 0;
75
75
  let cumulativeSegPos = 0;
76
- let currentInfo = keys[curIndex];
76
+ let currentInfo = seqs[curIndex];
77
77
  for (const segment of segments) {
78
78
  const attribution = new AttributionCollection(currentInfo, segment.cachedLength);
79
79
  while (posBreakpoints[curIndex] < cumulativeSegPos + segment.cachedLength) {
80
- currentInfo = keys[curIndex];
80
+ currentInfo = seqs[curIndex];
81
81
  attribution.entries.put(posBreakpoints[curIndex] - cumulativeSegPos, currentInfo);
82
82
  curIndex++;
83
83
  }
@@ -89,9 +89,9 @@ class AttributionCollection {
89
89
  * Condenses attribution information on consecutive segments into a `SerializedAttributionCollection`
90
90
  */
91
91
  static serializeAttributionCollections(segments) {
92
- var _a;
92
+ var _a, _b;
93
93
  const posBreakpoints = [];
94
- const keys = [];
94
+ const seqs = [];
95
95
  let mostRecentAttributionKey;
96
96
  let cumulativePos = 0;
97
97
  let segmentsWithAttribution = 0;
@@ -99,12 +99,12 @@ class AttributionCollection {
99
99
  for (const segment of segments) {
100
100
  if (segment.attribution) {
101
101
  segmentsWithAttribution++;
102
- for (const { offset, key: info } of (_a = segment.attribution.getAll()) !== null && _a !== void 0 ? _a : []) {
103
- if (info !== mostRecentAttributionKey) {
102
+ for (const { offset, key: info } of (_b = (_a = segment.attribution) === null || _a === void 0 ? void 0 : _a.getAll()) !== null && _b !== void 0 ? _b : []) {
103
+ if (info.seq !== mostRecentAttributionKey) {
104
104
  posBreakpoints.push(offset + cumulativePos);
105
- keys.push(info);
105
+ seqs.push(info.seq);
106
106
  }
107
- mostRecentAttributionKey = info;
107
+ mostRecentAttributionKey = info.seq;
108
108
  }
109
109
  }
110
110
  else {
@@ -113,7 +113,7 @@ class AttributionCollection {
113
113
  cumulativePos += segment.cachedLength;
114
114
  }
115
115
  (0, common_utils_1.assert)(segmentsWithAttribution === 0 || segmentsWithoutAttribution === 0, 0x446 /* Expected either all segments or no segments to have attribution information. */);
116
- const blobContents = { keys, posBreakpoints, length: cumulativePos };
116
+ const blobContents = { seqs, posBreakpoints, length: cumulativePos };
117
117
  return blobContents;
118
118
  }
119
119
  }
@@ -1 +1 @@
1
- {"version":3,"file":"attributionCollection.js","sourceRoot":"","sources":["../src/attributionCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,+CAA6C;AAC7C,qDAA+E;AAc/E,MAAa,qBAAqB;IAG9B,YAAmB,SAAY,EAAU,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QAFvC,YAAO,GAA4B,IAAI,0BAAY,CAAC,+BAAc,CAAC,CAAC;QAGjF,IAAI,CAAC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AAE,IAAI,EAAE,IAAI,MAAA,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,mCAAI,EAAE,EAAE;oBACpE,IAAI,IAAI,KAAK,wBAAwB,EAAE;wBACnC,cAAc,CAAC,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,CAAC;wBAC5C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;qBACnB;oBACD,wBAAwB,GAAG,IAAI,CAAC;iBACnC;aACJ;iBAAM;gBACH,0BAA0B,EAAE,CAAC;aAChC;YAED,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC;SACzC;QAED,IAAA,qBAAM,EAAC,uBAAuB,KAAK,CAAC,IAAI,0BAA0B,KAAK,CAAC,EACpE,KAAK,CAAC,kFAAkF,CAAC,CAAC;QAE9F,MAAM,YAAY,GAAoC,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;QACtG,OAAO,YAAY,CAAC;IACxB,CAAC;CACJ;AAhID,sDAgIC","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 { RedBlackTree } from \"./collections\";\nimport { compareNumbers, ISegment as ISegmentCurrent } from \"./mergeTreeNodes\";\n\n// TODO: Once integrated into merge-tree, this interface can be removed\ninterface ISegment extends ISegmentCurrent {\n attribution?: AttributionCollection<unknown>;\n}\n\nexport interface SerializedAttributionCollection {\n keys: unknown[];\n posBreakpoints: number[];\n /* Total length; only necessary for validation */\n length: number;\n}\n\nexport class AttributionCollection<T> {\n private readonly entries: RedBlackTree<number, T> = new RedBlackTree(compareNumbers);\n\n public constructor(baseEntry: T, private _length: number) {\n this.entries.put(0, baseEntry);\n }\n\n public getAtOffset(offset: number): T {\n assert(offset >= 0 && offset < this._length, 0x443 /* Requested offset should be valid */);\n const node = this.entries.floor(offset);\n assert(node !== undefined, 0x444 /* Collection should have at least one entry */);\n return node.data;\n }\n\n public get length(): number {\n return this._length;\n }\n\n /**\n * Splits this attribution collection into two with entries for [0, pos) and [pos, length).\n */\n public splitAt(pos: number): AttributionCollection<T> {\n const splitBaseEntry = this.getAtOffset(pos);\n const splitCollection = new AttributionCollection(splitBaseEntry, this.length - pos);\n for (let current = this.entries.ceil(pos); current !== undefined; current = this.entries.ceil(pos)) {\n // If there happened to be an attribution change at exactly pos, it's already set in the base entry\n if (current.key !== pos) {\n splitCollection.entries.put(current.key - pos, current.data);\n }\n this.entries.remove(current.key);\n }\n this._length = pos;\n return splitCollection;\n }\n\n public append(other: AttributionCollection<T>): void {\n const lastEntry = this.getAtOffset(this.length - 1);\n other.entries.map(({ key, data }) => {\n if (key !== 0 || lastEntry !== data) {\n this.entries.put(key + this.length, data);\n }\n return true;\n });\n this._length += other.length;\n }\n\n public getAll(): { offset: number; key: T; }[] {\n const results: { offset: number; key: T; }[] = [];\n this.entries.map(({ key, data }) => {\n results.push({ offset: key, key: data });\n return true;\n });\n return results;\n }\n\n public clone(): AttributionCollection<T> {\n const copy = new AttributionCollection(this.getAtOffset(0), this.length);\n this.entries.map(({ key, data }) => {\n copy.entries.put(key, data);\n return true;\n });\n return copy;\n }\n\n /**\n * Rehydrates attribution information from its serialized form into the provided iterable of consecutive segments.\n */\n public static populateAttributionCollections(\n segments: Iterable<ISegment>,\n summary: SerializedAttributionCollection,\n ): void {\n const { keys, posBreakpoints } = summary;\n assert(\n keys.length === posBreakpoints.length && keys.length > 0,\n 0x445 /* Invalid attribution summary blob provided */);\n let curIndex = 0;\n let cumulativeSegPos = 0;\n let currentInfo = keys[curIndex];\n\n for (const segment of segments) {\n const attribution = new AttributionCollection(currentInfo, segment.cachedLength);\n while (posBreakpoints[curIndex] < cumulativeSegPos + segment.cachedLength) {\n currentInfo = keys[curIndex];\n attribution.entries.put(posBreakpoints[curIndex] - cumulativeSegPos, currentInfo);\n curIndex++;\n }\n\n segment.attribution = attribution;\n cumulativeSegPos += segment.cachedLength;\n }\n }\n\n /**\n * Condenses attribution information on consecutive segments into a `SerializedAttributionCollection`\n */\n public static serializeAttributionCollections(\n segments: Iterable<ISegment>,\n ): SerializedAttributionCollection {\n const posBreakpoints: number[] = [];\n const keys: unknown[] = [];\n let mostRecentAttributionKey: unknown | undefined;\n let cumulativePos = 0;\n\n let segmentsWithAttribution = 0;\n let segmentsWithoutAttribution = 0;\n for (const segment of segments) {\n if (segment.attribution) {\n segmentsWithAttribution++;\n for (const { offset, key: info } of segment.attribution.getAll() ?? []) {\n if (info !== mostRecentAttributionKey) {\n posBreakpoints.push(offset + cumulativePos);\n keys.push(info);\n }\n mostRecentAttributionKey = info;\n }\n } else {\n segmentsWithoutAttribution++;\n }\n\n cumulativePos += segment.cachedLength;\n }\n\n assert(segmentsWithAttribution === 0 || segmentsWithoutAttribution === 0,\n 0x446 /* Expected either all segments or no segments to have attribution information. */);\n\n const blobContents: SerializedAttributionCollection = { keys, posBreakpoints, length: cumulativePos };\n return blobContents;\n }\n}\n"]}
1
+ {"version":3,"file":"attributionCollection.js","sourceRoot":"","sources":["../src/attributionCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,+CAA6C;AAC7C,qDAA4E;AAgD5E,MAAa,qBAAqB;IAG9B,YAAmB,SAAiB,EAAU,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QAF5C,YAAO,GAAiC,IAAI,0BAAY,CAAC,+BAAc,CAAC,CAAC;QAGtF,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IACnC,CAAC;IAEM,WAAW,CAAC,MAAc;QAC7B,IAAA,qBAAM,EAAC,MAAM,IAAI,CAAC,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC3F,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACxC,IAAA,qBAAM,EAAC,IAAI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AG,aAAa,CAAC,CAAC;wBAC5C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;qBACvB;oBACD,wBAAwB,GAAG,IAAI,CAAC,GAAG,CAAC;iBACvC;aACJ;iBAAM;gBACH,0BAA0B,EAAE,CAAC;aAChC;YAED,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC;SACzC;QAED,IAAA,qBAAM,EAAC,uBAAuB,KAAK,CAAC,IAAI,0BAA0B,KAAK,CAAC,EACpE,KAAK,CAAC,kFAAkF,CAAC,CAAC;QAE9F,MAAM,YAAY,GAAoC,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;QACtG,OAAO,YAAY,CAAC;IACxB,CAAC;CACJ;AAhID,sDAgIC","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 { RedBlackTree } from \"./collections\";\nimport { AttributionKey, compareNumbers, ISegment } from \"./mergeTreeNodes\";\n\nexport interface SerializedAttributionCollection {\n /**\n * Parallel array with posBreakpoints which tracks the seq of insertion.\n * Ex: if seqs is [45, 46] and posBreakpoints is [0, 3], the section of the string\n * between offsets 0 and 3 was inserted at seq 45 and the section of the string between\n * 3 and the length of the string was inserted at seq 46.\n */\n seqs: number[];\n posBreakpoints: number[];\n /* Total length; only necessary for validation */\n length: number;\n}\n\n/**\n * @alpha\n */\nexport interface IAttributionCollection<T> {\n /**\n * Retrieves the attribution key associated with the provided offset.\n */\n getAtOffset(offset: number): T;\n\n /**\n * Total length of all attribution keys in this collection.\n */\n readonly length: number;\n\n /**\n * Retrieve all key/offset pairs stored on this segment. Entries should be ordered by offset, such that\n * the `i`th result's attribution key applies to offsets in the open range between the `i`th offset and the\n * `i+1`th offset.\n * The last entry's key applies to the open interval from the last entry's offset to this collection's length.\n * @internal\n */\n getAll(): Iterable<{ offset: number; key: T; }>;\n\n /** @internal */\n splitAt(pos: number): IAttributionCollection<T>;\n\n /** @internal */\n append(other: IAttributionCollection<T>): void;\n\n /** @internal */\n clone(): IAttributionCollection<T>;\n}\n\nexport class AttributionCollection implements IAttributionCollection<AttributionKey> {\n private readonly entries: RedBlackTree<number, number> = new RedBlackTree(compareNumbers);\n\n public constructor(baseEntry: number, private _length: number) {\n this.entries.put(0, baseEntry);\n }\n\n public getAtOffset(offset: number): AttributionKey {\n assert(offset >= 0 && offset < this._length, 0x443 /* Requested offset should be valid */);\n const node = this.entries.floor(offset);\n assert(node !== undefined, 0x444 /* Collection should have at least one entry */);\n return { type: \"op\", seq: node.data };\n }\n\n public get length(): number {\n return this._length;\n }\n\n /**\n * Splits this attribution collection into two with entries for [0, pos) and [pos, length).\n */\n public splitAt(pos: number): AttributionCollection {\n const splitBaseEntry = this.getAtOffset(pos);\n const splitCollection = new AttributionCollection(splitBaseEntry.seq, this.length - pos);\n for (let current = this.entries.ceil(pos); current !== undefined; current = this.entries.ceil(pos)) {\n // If there happened to be an attribution change at exactly pos, it's already set in the base entry\n if (current.key !== pos) {\n splitCollection.entries.put(current.key - pos, current.data);\n }\n this.entries.remove(current.key);\n }\n this._length = pos;\n return splitCollection;\n }\n\n public append(other: AttributionCollection): void {\n const lastEntry = this.getAtOffset(this.length - 1).seq;\n other.entries.map(({ key, data }) => {\n if (key !== 0 || lastEntry !== data) {\n this.entries.put(key + this.length, data);\n }\n return true;\n });\n this._length += other.length;\n }\n\n public getAll(): { offset: number; key: AttributionKey; }[] {\n const results: { offset: number; key: AttributionKey; }[] = [];\n this.entries.map(({ key, data }) => {\n results.push({ offset: key, key: { type: \"op\", seq: data } });\n return true;\n });\n return results;\n }\n\n public clone(): AttributionCollection {\n const copy = new AttributionCollection(this.getAtOffset(0).seq, this.length);\n this.entries.map(({ key, data }) => {\n copy.entries.put(key, data);\n return true;\n });\n return copy;\n }\n\n /**\n * Rehydrates attribution information from its serialized form into the provided iterable of consecutive segments.\n */\n public static populateAttributionCollections(\n segments: Iterable<ISegment>,\n summary: SerializedAttributionCollection,\n ): void {\n const { seqs, posBreakpoints } = summary;\n assert(\n seqs.length === posBreakpoints.length && seqs.length > 0,\n 0x445 /* Invalid attribution summary blob provided */);\n let curIndex = 0;\n let cumulativeSegPos = 0;\n let currentInfo = seqs[curIndex];\n\n for (const segment of segments) {\n const attribution = new AttributionCollection(currentInfo, segment.cachedLength);\n while (posBreakpoints[curIndex] < cumulativeSegPos + segment.cachedLength) {\n currentInfo = seqs[curIndex];\n attribution.entries.put(posBreakpoints[curIndex] - cumulativeSegPos, currentInfo);\n curIndex++;\n }\n\n segment.attribution = attribution;\n cumulativeSegPos += segment.cachedLength;\n }\n }\n\n /**\n * Condenses attribution information on consecutive segments into a `SerializedAttributionCollection`\n */\n public static serializeAttributionCollections(\n segments: Iterable<{ attribution?: IAttributionCollection<AttributionKey>; cachedLength: number; }>,\n ): SerializedAttributionCollection {\n const posBreakpoints: number[] = [];\n const seqs: number[] = [];\n let mostRecentAttributionKey: number | undefined;\n let cumulativePos = 0;\n\n let segmentsWithAttribution = 0;\n let segmentsWithoutAttribution = 0;\n for (const segment of segments) {\n if (segment.attribution) {\n segmentsWithAttribution++;\n for (const { offset, key: info } of segment.attribution?.getAll() ?? []) {\n if (info.seq !== mostRecentAttributionKey) {\n posBreakpoints.push(offset + cumulativePos);\n seqs.push(info.seq);\n }\n mostRecentAttributionKey = info.seq;\n }\n } else {\n segmentsWithoutAttribution++;\n }\n\n cumulativePos += segment.cachedLength;\n }\n\n assert(segmentsWithAttribution === 0 || segmentsWithoutAttribution === 0,\n 0x446 /* Expected either all segments or no segments to have attribution information. */);\n\n const blobContents: SerializedAttributionCollection = { seqs, posBreakpoints, length: cumulativePos };\n return blobContents;\n }\n}\n"]}
package/dist/client.d.ts CHANGED
@@ -87,6 +87,7 @@ export declare class Client {
87
87
  * @param segment - The segment to insert
88
88
  */
89
89
  insertAtReferencePositionLocal(refPos: ReferencePosition, segment: ISegment): IMergeTreeInsertMsg | undefined;
90
+ private traceOp;
90
91
  walkSegments<TClientData>(handler: ISegmentAction<TClientData>, start: number | undefined, end: number | undefined, accum: TClientData, splitRange?: boolean): void;
91
92
  walkSegments<undefined>(handler: ISegmentAction<undefined>, start?: number, end?: number, accum?: undefined, splitRange?: boolean): void;
92
93
  protected walkAllSegments<TClientData>(action: (segment: ISegment, accum?: TClientData) => boolean, accum?: TClientData): boolean;
@@ -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,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AACvG,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAMtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EACH,mBAAmB,EAInB,QAAQ,EACR,cAAc,EACd,MAAM,EACN,YAAY,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAQlE,OAAO,EACH,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,EAEjB,aAAa,EAChB,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,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AAI;IAsBvF,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,UAAO;;;;CAIjE"}
package/dist/client.js CHANGED
@@ -158,13 +158,16 @@ class Client {
158
158
  }
159
159
  const op = (0, opBuilder_1.createInsertSegmentOp)(pos, segment);
160
160
  const opArgs = { op };
161
+ this.traceOp(opArgs, () => this._mergeTree.insertAtReferencePosition(refPos, segment, opArgs));
162
+ return op;
163
+ }
164
+ traceOp(opArgs, applyOp) {
161
165
  let traceStart;
162
166
  if (this.measureOps) {
163
167
  traceStart = common_utils_1.Trace.start();
164
168
  }
165
- this._mergeTree.insertAtReferencePosition(refPos, segment, opArgs);
166
- this.completeAndLogOp(opArgs, this.getClientSequenceArgs(opArgs), { start: op.pos1 }, traceStart);
167
- return op;
169
+ applyOp();
170
+ this.completeAndLogOp(opArgs, traceStart);
168
171
  }
169
172
  walkSegments(handler, start, end, accum, splitRange = false) {
170
173
  this._mergeTree.mapRange(handler, this.getCurrentSeq(), this.getClientId(), accum, start, end, splitRange);
@@ -198,7 +201,7 @@ class Client {
198
201
  }
199
202
  }
200
203
  getCollabWindow() {
201
- return this._mergeTree.getCollabWindow();
204
+ return this._mergeTree.collabWindow;
202
205
  }
203
206
  /**
204
207
  * Returns the current position of a segment, and -1 if the segment
@@ -261,12 +264,7 @@ class Client {
261
264
  const op = opArgs.op;
262
265
  const clientArgs = this.getClientSequenceArgs(opArgs);
263
266
  const range = this.getValidOpRange(op, clientArgs);
264
- let traceStart;
265
- if (this.measureOps) {
266
- traceStart = common_utils_1.Trace.start();
267
- }
268
- this._mergeTree.markRangeRemoved(range.start, range.end, clientArgs.referenceSequenceNumber, clientArgs.clientId, clientArgs.sequenceNumber, false, opArgs);
269
- this.completeAndLogOp(opArgs, clientArgs, range, traceStart);
267
+ this.traceOp(opArgs, () => this._mergeTree.markRangeRemoved(range.start, range.end, clientArgs.referenceSequenceNumber, clientArgs.clientId, clientArgs.sequenceNumber, false, opArgs));
270
268
  return true;
271
269
  }
272
270
  /**
@@ -282,12 +280,7 @@ class Client {
282
280
  if (!range) {
283
281
  return false;
284
282
  }
285
- let traceStart;
286
- if (this.measureOps) {
287
- traceStart = common_utils_1.Trace.start();
288
- }
289
- this._mergeTree.annotateRange(range.start, range.end, op.props, op.combiningOp, clientArgs.referenceSequenceNumber, clientArgs.clientId, clientArgs.sequenceNumber, opArgs);
290
- this.completeAndLogOp(opArgs, clientArgs, range, traceStart);
283
+ this.traceOp(opArgs, () => this._mergeTree.annotateRange(range.start, range.end, op.props, op.combiningOp, clientArgs.referenceSequenceNumber, clientArgs.clientId, clientArgs.sequenceNumber, opArgs));
291
284
  return true;
292
285
  }
293
286
  /**
@@ -310,12 +303,7 @@ class Client {
310
303
  if (!segments || segments.length === 0) {
311
304
  return false;
312
305
  }
313
- let traceStart;
314
- if (this.measureOps) {
315
- traceStart = common_utils_1.Trace.start();
316
- }
317
- this._mergeTree.insertSegments(range.start, segments, clientArgs.referenceSequenceNumber, clientArgs.clientId, clientArgs.sequenceNumber, opArgs);
318
- this.completeAndLogOp(opArgs, clientArgs, range, traceStart);
306
+ this.traceOp(opArgs, () => this._mergeTree.insertSegments(range.start, segments, clientArgs.referenceSequenceNumber, clientArgs.clientId, clientArgs.sequenceNumber, opArgs));
319
307
  return true;
320
308
  }
321
309
  /**
@@ -325,7 +313,7 @@ class Client {
325
313
  * @param range - The range the op applied to
326
314
  * @param clockStart - Optional. The clock start if timing data should be updated.
327
315
  */
328
- completeAndLogOp(opArgs, clientArgs, range, traceStart) {
316
+ completeAndLogOp(opArgs, traceStart) {
329
317
  if (!opArgs.sequencedMessage) {
330
318
  if (traceStart) {
331
319
  this.localTime += elapsedMicroseconds(traceStart);
@@ -333,8 +321,10 @@ class Client {
333
321
  }
334
322
  }
335
323
  else {
336
- (0, common_utils_1.assert)(this._mergeTree.getCollabWindow().currentSeq < clientArgs.sequenceNumber, 0x030 /* "Incoming remote op sequence# <= local collabWindow's currentSequence#" */);
337
- (0, common_utils_1.assert)(this._mergeTree.getCollabWindow().minSeq <= opArgs.sequencedMessage.minimumSequenceNumber, 0x031 /* "Incoming remote op minSequence# < local collabWindow's minSequence#" */);
324
+ const { currentSeq, minSeq } = this.getCollabWindow();
325
+ const { minimumSequenceNumber, sequenceNumber } = opArgs.sequencedMessage;
326
+ (0, common_utils_1.assert)(currentSeq < sequenceNumber, 0x030 /* "Incoming remote op sequence# <= local collabWindow's currentSequence#" */);
327
+ (0, common_utils_1.assert)(minSeq <= minimumSequenceNumber, 0x031 /* "Incoming remote op minSequence# < local collabWindow's minSequence#" */);
338
328
  if (traceStart) {
339
329
  this.accumTime += elapsedMicroseconds(traceStart);
340
330
  this.accumOps++;
@@ -676,7 +666,7 @@ class Client {
676
666
  this.updateSeqNumbers(msg.minimumSequenceNumber, msg.sequenceNumber);
677
667
  }
678
668
  updateSeqNumbers(min, seq) {
679
- const collabWindow = this._mergeTree.getCollabWindow();
669
+ const collabWindow = this.getCollabWindow();
680
670
  // Equal is fine here due to SharedSegmentSequence<>.snapshotContent() potentially updating with same #
681
671
  (0, common_utils_1.assert)(collabWindow.currentSeq <= seq, 0x038 /* "Incoming op sequence# < local collabWindow's currentSequence#" */);
682
672
  collabWindow.currentSeq = seq;