@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
@@ -4,8 +4,11 @@
4
4
  */
5
5
  import { ISegment, SegmentGroup } from "./mergeTreeNodes.js";
6
6
  /**
7
+ * @deprecated - This class should not be used externally and will be removed in a subsequent release.
7
8
  * @legacy
8
9
  * @alpha
10
+ *
11
+ * @privateRemarks After the deprecation period this class should be remove from this package's exports, and only be used internally
9
12
  */
10
13
  export declare class SegmentGroupCollection {
11
14
  private readonly segment;
@@ -1 +1 @@
1
- {"version":3,"file":"segmentGroupCollection.d.ts","sourceRoot":"","sources":["../src/segmentGroupCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;GAGG;AACH,qBAAa,sBAAsB;IAItB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiC;gBAElC,OAAO,EAAE,QAAQ;IAK9C,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,KAAK,IAAI,OAAO,CAE1B;IAGM,OAAO,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IAMzC,OAAO,IAAI,YAAY,GAAG,SAAS;IAKnC,MAAM,CAAC,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO;IAU5C,GAAG,CAAC,IAAI,YAAY,GAAG,SAAS;IAIhC,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;IAOtC,OAAO,CAAC,aAAa;CAYrB"}
1
+ {"version":3,"file":"segmentGroupCollection.d.ts","sourceRoot":"","sources":["../src/segmentGroupCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;;;;GAMG;AACH,qBAAa,sBAAsB;IAItB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiC;gBAElC,OAAO,EAAE,QAAQ;IAK9C,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,KAAK,IAAI,OAAO,CAE1B;IAGM,OAAO,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IAMzC,OAAO,IAAI,YAAY,GAAG,SAAS;IAKnC,MAAM,CAAC,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO;IAU5C,GAAG,CAAC,IAAI,YAAY,GAAG,SAAS;IAIhC,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;IAOtC,OAAO,CAAC,aAAa;CAYrB"}
@@ -4,8 +4,11 @@
4
4
  */
5
5
  import { DoublyLinkedList, walkList } from "./collections/index.js";
6
6
  /**
7
+ * @deprecated - This class should not be used externally and will be removed in a subsequent release.
7
8
  * @legacy
8
9
  * @alpha
10
+ *
11
+ * @privateRemarks After the deprecation period this class should be remove from this package's exports, and only be used internally
9
12
  */
10
13
  export class SegmentGroupCollection {
11
14
  constructor(segment) {
@@ -1 +1 @@
1
- {"version":3,"file":"segmentGroupCollection.js","sourceRoot":"","sources":["../src/segmentGroupCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAIpE;;;GAGG;AACH,MAAM,OAAO,sBAAsB;IAIlC,YAA6B,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;QAC7C,gDAAgD;QAChD,IAAI,CAAC,aAAa,GAAG,IAAI,gBAAgB,EAAgB,CAAC;IAC3D,CAAC;IAED,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;IAClC,CAAC;IAED,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;IACjC,CAAC;IAED,gDAAgD;IACzC,OAAO,CAAC,YAA0B;QACxC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACtC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,gDAAgD;IACzC,OAAO;QACb,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC;IACzC,CAAC;IAED,gDAAgD;IACzC,MAAM,CAAE,YAA0B;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;QACtE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACd,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,gDAAgD;IACzC,GAAG;QACT,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,CAAC;IAEM,MAAM,CAAC,OAAiB;QAC9B,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,EAAE,EAAE,EAAE,CACnC,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAC1D,CAAC;IACH,CAAC;IAED,gDAAgD;IACxC,aAAa,CAAC,YAA0B,EAAE,aAAuB;QACxE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC3B,IAAI,YAAY,CAAC,aAAa,EAAE,CAAC;YAChC,+CAA+C;YAC/C,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;YAC3D,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;gBAClB,iDAAiD;gBACjD,oEAAoE;gBACpE,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,CAAE,CAAC,CAAC;YACrE,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DoublyLinkedList, walkList } from \"./collections/index.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { ISegment, SegmentGroup } from \"./mergeTreeNodes.js\";\n\n/**\n * @legacy\n * @alpha\n */\nexport class SegmentGroupCollection {\n\t// eslint-disable-next-line import/no-deprecated\n\tprivate readonly segmentGroups: DoublyLinkedList<SegmentGroup>;\n\n\tconstructor(private readonly segment: ISegment) {\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tthis.segmentGroups = new DoublyLinkedList<SegmentGroup>();\n\t}\n\n\tpublic get size(): number {\n\t\treturn this.segmentGroups.length;\n\t}\n\n\tpublic get empty(): boolean {\n\t\treturn this.segmentGroups.empty;\n\t}\n\n\t// eslint-disable-next-line import/no-deprecated\n\tpublic enqueue(segmentGroup: SegmentGroup): void {\n\t\tthis.segmentGroups.push(segmentGroup);\n\t\tsegmentGroup.segments.push(this.segment);\n\t}\n\n\t// eslint-disable-next-line import/no-deprecated\n\tpublic dequeue(): SegmentGroup | undefined {\n\t\treturn this.segmentGroups.shift()?.data;\n\t}\n\n\t// eslint-disable-next-line import/no-deprecated\n\tpublic remove?(segmentGroup: SegmentGroup): boolean {\n\t\tconst found = this.segmentGroups.find((v) => v.data === segmentGroup);\n\t\tif (found === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.segmentGroups.remove(found);\n\t\treturn true;\n\t}\n\n\t// eslint-disable-next-line import/no-deprecated\n\tpublic pop?(): SegmentGroup | undefined {\n\t\treturn this.segmentGroups.pop ? this.segmentGroups.pop()?.data : undefined;\n\t}\n\n\tpublic copyTo(segment: ISegment): void {\n\t\twalkList(this.segmentGroups, (sg) =>\n\t\t\tsegment.segmentGroups.enqueueOnCopy(sg.data, this.segment),\n\t\t);\n\t}\n\n\t// eslint-disable-next-line import/no-deprecated\n\tprivate enqueueOnCopy(segmentGroup: SegmentGroup, sourceSegment: ISegment): void {\n\t\tthis.enqueue(segmentGroup);\n\t\tif (segmentGroup.previousProps) {\n\t\t\t// duplicate the previousProps for this segment\n\t\t\tconst index = segmentGroup.segments.indexOf(sourceSegment);\n\t\t\tif (index !== -1) {\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\tsegmentGroup.previousProps.push(segmentGroup.previousProps[index]!);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"segmentGroupCollection.js","sourceRoot":"","sources":["../src/segmentGroupCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAIpE;;;;;;GAMG;AACH,MAAM,OAAO,sBAAsB;IAIlC,YAA6B,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;QAC7C,gDAAgD;QAChD,IAAI,CAAC,aAAa,GAAG,IAAI,gBAAgB,EAAgB,CAAC;IAC3D,CAAC;IAED,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;IAClC,CAAC;IAED,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;IACjC,CAAC;IAED,gDAAgD;IACzC,OAAO,CAAC,YAA0B;QACxC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACtC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,gDAAgD;IACzC,OAAO;QACb,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC;IACzC,CAAC;IAED,gDAAgD;IACzC,MAAM,CAAE,YAA0B;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;QACtE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACd,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,gDAAgD;IACzC,GAAG;QACT,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,CAAC;IAEM,MAAM,CAAC,OAAiB;QAC9B,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,EAAE,EAAE,EAAE,CACnC,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAC1D,CAAC;IACH,CAAC;IAED,gDAAgD;IACxC,aAAa,CAAC,YAA0B,EAAE,aAAuB;QACxE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC3B,IAAI,YAAY,CAAC,aAAa,EAAE,CAAC;YAChC,+CAA+C;YAC/C,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;YAC3D,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;gBAClB,iDAAiD;gBACjD,oEAAoE;gBACpE,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,CAAE,CAAC,CAAC;YACrE,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DoublyLinkedList, walkList } from \"./collections/index.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { ISegment, SegmentGroup } from \"./mergeTreeNodes.js\";\n\n/**\n * @deprecated - This class should not be used externally and will be removed in a subsequent release.\n * @legacy\n * @alpha\n *\n * @privateRemarks After the deprecation period this class should be remove from this package's exports, and only be used internally\n */\nexport class SegmentGroupCollection {\n\t// eslint-disable-next-line import/no-deprecated\n\tprivate readonly segmentGroups: DoublyLinkedList<SegmentGroup>;\n\n\tconstructor(private readonly segment: ISegment) {\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tthis.segmentGroups = new DoublyLinkedList<SegmentGroup>();\n\t}\n\n\tpublic get size(): number {\n\t\treturn this.segmentGroups.length;\n\t}\n\n\tpublic get empty(): boolean {\n\t\treturn this.segmentGroups.empty;\n\t}\n\n\t// eslint-disable-next-line import/no-deprecated\n\tpublic enqueue(segmentGroup: SegmentGroup): void {\n\t\tthis.segmentGroups.push(segmentGroup);\n\t\tsegmentGroup.segments.push(this.segment);\n\t}\n\n\t// eslint-disable-next-line import/no-deprecated\n\tpublic dequeue(): SegmentGroup | undefined {\n\t\treturn this.segmentGroups.shift()?.data;\n\t}\n\n\t// eslint-disable-next-line import/no-deprecated\n\tpublic remove?(segmentGroup: SegmentGroup): boolean {\n\t\tconst found = this.segmentGroups.find((v) => v.data === segmentGroup);\n\t\tif (found === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.segmentGroups.remove(found);\n\t\treturn true;\n\t}\n\n\t// eslint-disable-next-line import/no-deprecated\n\tpublic pop?(): SegmentGroup | undefined {\n\t\treturn this.segmentGroups.pop ? this.segmentGroups.pop()?.data : undefined;\n\t}\n\n\tpublic copyTo(segment: ISegment): void {\n\t\twalkList(this.segmentGroups, (sg) =>\n\t\t\tsegment.segmentGroups.enqueueOnCopy(sg.data, this.segment),\n\t\t);\n\t}\n\n\t// eslint-disable-next-line import/no-deprecated\n\tprivate enqueueOnCopy(segmentGroup: SegmentGroup, sourceSegment: ISegment): void {\n\t\tthis.enqueue(segmentGroup);\n\t\tif (segmentGroup.previousProps) {\n\t\t\t// duplicate the previousProps for this segment\n\t\t\tconst index = segmentGroup.segments.indexOf(sourceSegment);\n\t\t\tif (index !== -1) {\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\tsegmentGroup.previousProps.push(segmentGroup.previousProps[index]!);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -7,6 +7,10 @@ import { PropertySet } from "./properties.js";
7
7
  /**
8
8
  * @legacy
9
9
  * @alpha
10
+ *
11
+ * @deprecated - This enum should not be used externally and will be removed in a subsequent release.
12
+ *
13
+ * @privateRemarks This enum should be made internal after the deprecation period
10
14
  */
11
15
  export declare enum PropertiesRollback {
12
16
  /**
@@ -21,6 +25,10 @@ export declare enum PropertiesRollback {
21
25
  /**
22
26
  * @legacy
23
27
  * @alpha
28
+ *
29
+ * @deprecated - This class should not be used externally and will be removed in a subsequent release.
30
+ *
31
+ * @privateRemarks This class should be made internal after the deprecation period
24
32
  */
25
33
  export declare class PropertiesManager {
26
34
  private pendingKeyUpdateCount;
@@ -1 +1 @@
1
- {"version":3,"file":"segmentPropertiesManager.d.ts","sourceRoot":"","sources":["../src/segmentPropertiesManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAW,WAAW,EAAa,MAAM,iBAAiB,CAAC;AAElE;;;GAGG;AACH,oBAAY,kBAAkB;IAC7B;;OAEG;IACH,IAAI,IAAA;IAEJ;;OAEG;IACH,QAAQ,IAAA;CACR;AAED;;;GAGG;AACH,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,qBAAqB,CAA8B;IAEpD,oBAAoB,CAAC,UAAU,EAAE,qBAAqB,GAAG,IAAI;IAIpE,OAAO,CAAC,sBAAsB;IAiBvB,aAAa,CACnB,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,WAAW,EACrB,GAAG,CAAC,EAAE,MAAM,EACZ,aAAa,GAAE,OAAe,EAC9B,QAAQ,GAAE,kBAA4C,GACpD,WAAW;IAqDP,MAAM,CACZ,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,WAAW,GAAG,SAAS,EACjC,UAAU,EAAE,iBAAiB,GAC3B,WAAW,GAAG,SAAS;IAoB1B;;OAEG;IACI,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO;IASjD,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAG/C"}
1
+ {"version":3,"file":"segmentPropertiesManager.d.ts","sourceRoot":"","sources":["../src/segmentPropertiesManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAW,WAAW,EAA4B,MAAM,iBAAiB,CAAC;AAEjF;;;;;;;GAOG;AACH,oBAAY,kBAAkB;IAC7B;;OAEG;IACH,IAAI,IAAA;IAEJ;;OAEG;IACH,QAAQ,IAAA;CACR;AAED;;;;;;;GAOG;AACH,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,qBAAqB,CAA8B;IAEpD,oBAAoB,CAAC,UAAU,EAAE,qBAAqB,GAAG,IAAI;IAIpE,OAAO,CAAC,sBAAsB;IAiBvB,aAAa,CACnB,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,WAAW,EACrB,GAAG,CAAC,EAAE,MAAM,EACZ,aAAa,GAAE,OAAe,EAC9B,QAAQ,GAAE,kBAA4C,GACpD,WAAW;IAqDP,MAAM,CACZ,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,WAAW,GAAG,SAAS,EACjC,UAAU,EAAE,iBAAiB,GAC3B,WAAW,GAAG,SAAS;IAgB1B;;OAEG;IACI,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO;IASjD,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAG/C"}
@@ -5,10 +5,14 @@
5
5
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
6
6
  import { assert } from "@fluidframework/core-utils/internal";
7
7
  import { UnassignedSequenceNumber, UniversalSequenceNumber } from "./constants.js";
8
- import { createMap } from "./properties.js";
8
+ import { clone, createMap, extend } from "./properties.js";
9
9
  /**
10
10
  * @legacy
11
11
  * @alpha
12
+ *
13
+ * @deprecated - This enum should not be used externally and will be removed in a subsequent release.
14
+ *
15
+ * @privateRemarks This enum should be made internal after the deprecation period
12
16
  */
13
17
  export var PropertiesRollback;
14
18
  (function (PropertiesRollback) {
@@ -24,6 +28,10 @@ export var PropertiesRollback;
24
28
  /**
25
29
  * @legacy
26
30
  * @alpha
31
+ *
32
+ * @deprecated - This class should not be used externally and will be removed in a subsequent release.
33
+ *
34
+ * @privateRemarks This class should be made internal after the deprecation period
27
35
  */
28
36
  export class PropertiesManager {
29
37
  ackPendingProperties(annotateOp) {
@@ -95,14 +103,9 @@ export class PropertiesManager {
95
103
  if (!newManager) {
96
104
  throw new Error("Must provide new PropertyManager");
97
105
  }
98
- for (const key of Object.keys(oldProps)) {
99
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
100
- newProps[key] = oldProps[key];
101
- }
102
- newManager.pendingKeyUpdateCount = createMap();
103
- for (const key of Object.keys(this.pendingKeyUpdateCount)) {
104
- // TODO Non null asserting, why is this not null?
105
- newManager.pendingKeyUpdateCount[key] = this.pendingKeyUpdateCount[key];
106
+ extend(newProps, oldProps);
107
+ if (this.pendingKeyUpdateCount) {
108
+ newManager.pendingKeyUpdateCount = clone(this.pendingKeyUpdateCount);
106
109
  }
107
110
  }
108
111
  return newProps;
@@ -1 +1 @@
1
- {"version":3,"file":"segmentPropertiesManager.js","sourceRoot":"","sources":["../src/segmentPropertiesManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,6DAA6D;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEnF,OAAO,EAAwB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAN,IAAY,kBAUX;AAVD,WAAY,kBAAkB;IAC7B;;OAEG;IACH,2DAAI,CAAA;IAEJ;;OAEG;IACH,mEAAQ,CAAA;AACT,CAAC,EAVW,kBAAkB,KAAlB,kB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the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { UnassignedSequenceNumber, UniversalSequenceNumber } from \"./constants.js\";\nimport { IMergeTreeAnnotateMsg } from \"./ops.js\";\nimport { MapLike, PropertySet, createMap } from \"./properties.js\";\n\n/**\n * @legacy\n * @alpha\n */\nexport enum PropertiesRollback {\n\t/**\n\t * Not in a rollback\n\t */\n\tNone,\n\n\t/**\n\t * Rollback\n\t */\n\tRollback,\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport class PropertiesManager {\n\tprivate pendingKeyUpdateCount: MapLike<number> | undefined;\n\n\tpublic ackPendingProperties(annotateOp: IMergeTreeAnnotateMsg): void {\n\t\tthis.decrementPendingCounts(annotateOp.props);\n\t}\n\n\tprivate decrementPendingCounts(props: PropertySet): void {\n\t\tfor (const [key, value] of Object.entries(props)) {\n\t\t\tif (value !== undefined && this.pendingKeyUpdateCount?.[key] !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\t// TODO Non null asserting, why is this not null?\n\t\t\t\t\tthis.pendingKeyUpdateCount[key]! > 0,\n\t\t\t\t\t0x05c /* \"Trying to update more annotate props than do exist!\" */,\n\t\t\t\t);\n\t\t\t\tthis.pendingKeyUpdateCount[key]--;\n\t\t\t\tif (this.pendingKeyUpdateCount?.[key] === 0) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\t\tdelete this.pendingKeyUpdateCount[key];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic addProperties(\n\t\toldProps: PropertySet,\n\t\tnewProps: PropertySet,\n\t\tseq?: number,\n\t\tcollaborating: boolean = false,\n\t\trollback: PropertiesRollback = PropertiesRollback.None,\n\t): PropertySet {\n\t\tthis.pendingKeyUpdateCount ??= createMap<number>();\n\n\t\t// Clean up counts for rolled back edits before modifying oldProps\n\t\tif (collaborating && rollback === PropertiesRollback.Rollback) {\n\t\t\tthis.decrementPendingCounts(newProps);\n\t\t}\n\n\t\tconst shouldModifyKey = (key: string): boolean => {\n\t\t\tif (\n\t\t\t\tseq === UnassignedSequenceNumber ||\n\t\t\t\tseq === UniversalSequenceNumber ||\n\t\t\t\tthis.pendingKeyUpdateCount?.[key] === undefined\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t};\n\n\t\tconst deltas: PropertySet = {};\n\n\t\tfor (const [key, newValue] of Object.entries(newProps)) {\n\t\t\tif (newValue === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (collaborating) {\n\t\t\t\tif (seq === UnassignedSequenceNumber) {\n\t\t\t\t\tif (this.pendingKeyUpdateCount?.[key] === undefined) {\n\t\t\t\t\t\tthis.pendingKeyUpdateCount[key] = 0;\n\t\t\t\t\t}\n\t\t\t\t\tthis.pendingKeyUpdateCount[key]++;\n\t\t\t\t} else if (!shouldModifyKey(key)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst previousValue: unknown = oldProps[key];\n\t\t\t// The delta should be null if undefined, as that's how we encode delete\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tdeltas[key] = previousValue === undefined ? null : previousValue;\n\t\t\tif (newValue === null) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete oldProps[key];\n\t\t\t} else {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\toldProps[key] = newValue;\n\t\t\t}\n\t\t}\n\n\t\treturn deltas;\n\t}\n\n\tpublic copyTo(\n\t\toldProps: PropertySet,\n\t\tnewProps: PropertySet | undefined,\n\t\tnewManager: PropertiesManager,\n\t): PropertySet | undefined {\n\t\tif (oldProps) {\n\t\t\t// eslint-disable-next-line no-param-reassign\n\t\t\tnewProps ??= createMap<unknown>();\n\t\t\tif (!newManager) {\n\t\t\t\tthrow new Error(\"Must provide new PropertyManager\");\n\t\t\t}\n\t\t\tfor (const key of Object.keys(oldProps)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tnewProps[key] = oldProps[key];\n\t\t\t}\n\t\t\tnewManager.pendingKeyUpdateCount = createMap<number>();\n\t\t\tfor (const key of Object.keys(this.pendingKeyUpdateCount!)) {\n\t\t\t\t// TODO Non null asserting, why is this not null?\n\t\t\t\tnewManager.pendingKeyUpdateCount[key] = this.pendingKeyUpdateCount![key]!;\n\t\t\t}\n\t\t}\n\t\treturn newProps;\n\t}\n\n\t/**\n\t * Determines if all of the defined properties in a given property set are pending.\n\t */\n\tpublic hasPendingProperties(props: PropertySet): boolean {\n\t\tfor (const [key, value] of Object.entries(props)) {\n\t\t\tif (value !== undefined && this.pendingKeyUpdateCount?.[key] === undefined) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic hasPendingProperty(key: string): boolean {\n\t\treturn (this.pendingKeyUpdateCount?.[key] ?? 0) > 0;\n\t}\n}\n"]}
1
+ {"version":3,"file":"segmentPropertiesManager.js","sourceRoot":"","sources":["../src/segmentPropertiesManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,6DAA6D;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEnF,OAAO,EAAwB,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEjF;;;;;;;GAOG;AACH,MAAM,CAAN,IAAY,kBAUX;AAVD,WAAY,kBAAkB;IAC7B;;OAEG;IACH,2DAAI,CAAA;IAEJ;;OAEG;IACH,mEAAQ,CAAA;AACT,CAAC,EAVW,kBAAkB,KAAlB,kBAAkB,QAU7B;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,iBAAiB;IAGtB,oBAAoB,CAAC,UA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R,QAAQ,GAAK,SAAS,EAAW,EAAC;YAClC,IAAI,CAAC,UAAU,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;YACrD,CAAC;YACD,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAE3B,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;gBAChC,UAAU,CAAC,qBAAqB,GAAG,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;YACtE,CAAC;QACF,CAAC;QACD,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED;;OAEG;IACI,oBAAoB,CAAC,KAAkB;QAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAClD,IAAI,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;gBAC5E,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,kBAAkB,CAAC,GAAW;QACpC,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACrD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { UnassignedSequenceNumber, UniversalSequenceNumber } from \"./constants.js\";\nimport { IMergeTreeAnnotateMsg } from \"./ops.js\";\nimport { MapLike, PropertySet, clone, createMap, extend } from \"./properties.js\";\n\n/**\n * @legacy\n * @alpha\n *\n * @deprecated - This enum should not be used externally and will be removed in a subsequent release.\n *\n * @privateRemarks This enum should be made internal after the deprecation period\n */\nexport enum PropertiesRollback {\n\t/**\n\t * Not in a rollback\n\t */\n\tNone,\n\n\t/**\n\t * Rollback\n\t */\n\tRollback,\n}\n\n/**\n * @legacy\n * @alpha\n *\n * @deprecated - This class should not be used externally and will be removed in a subsequent release.\n *\n * @privateRemarks This class should be made internal after the deprecation period\n */\nexport class PropertiesManager {\n\tprivate pendingKeyUpdateCount: MapLike<number> | undefined;\n\n\tpublic ackPendingProperties(annotateOp: IMergeTreeAnnotateMsg): void {\n\t\tthis.decrementPendingCounts(annotateOp.props);\n\t}\n\n\tprivate decrementPendingCounts(props: PropertySet): void {\n\t\tfor (const [key, value] of Object.entries(props)) {\n\t\t\tif (value !== undefined && this.pendingKeyUpdateCount?.[key] !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\t// TODO Non null asserting, why is this not null?\n\t\t\t\t\tthis.pendingKeyUpdateCount[key]! > 0,\n\t\t\t\t\t0x05c /* \"Trying to update more annotate props than do exist!\" */,\n\t\t\t\t);\n\t\t\t\tthis.pendingKeyUpdateCount[key]--;\n\t\t\t\tif (this.pendingKeyUpdateCount?.[key] === 0) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\t\tdelete this.pendingKeyUpdateCount[key];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic addProperties(\n\t\toldProps: PropertySet,\n\t\tnewProps: PropertySet,\n\t\tseq?: number,\n\t\tcollaborating: boolean = false,\n\t\trollback: PropertiesRollback = PropertiesRollback.None,\n\t): PropertySet {\n\t\tthis.pendingKeyUpdateCount ??= createMap<number>();\n\n\t\t// Clean up counts for rolled back edits before modifying oldProps\n\t\tif (collaborating && rollback === PropertiesRollback.Rollback) {\n\t\t\tthis.decrementPendingCounts(newProps);\n\t\t}\n\n\t\tconst shouldModifyKey = (key: string): boolean => {\n\t\t\tif (\n\t\t\t\tseq === UnassignedSequenceNumber ||\n\t\t\t\tseq === UniversalSequenceNumber ||\n\t\t\t\tthis.pendingKeyUpdateCount?.[key] === undefined\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t};\n\n\t\tconst deltas: PropertySet = {};\n\n\t\tfor (const [key, newValue] of Object.entries(newProps)) {\n\t\t\tif (newValue === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (collaborating) {\n\t\t\t\tif (seq === UnassignedSequenceNumber) {\n\t\t\t\t\tif (this.pendingKeyUpdateCount?.[key] === undefined) {\n\t\t\t\t\t\tthis.pendingKeyUpdateCount[key] = 0;\n\t\t\t\t\t}\n\t\t\t\t\tthis.pendingKeyUpdateCount[key]++;\n\t\t\t\t} else if (!shouldModifyKey(key)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst previousValue: unknown = oldProps[key];\n\t\t\t// The delta should be null if undefined, as that's how we encode delete\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tdeltas[key] = previousValue === undefined ? null : previousValue;\n\t\t\tif (newValue === null) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete oldProps[key];\n\t\t\t} else {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\toldProps[key] = newValue;\n\t\t\t}\n\t\t}\n\n\t\treturn deltas;\n\t}\n\n\tpublic copyTo(\n\t\toldProps: PropertySet,\n\t\tnewProps: PropertySet | undefined,\n\t\tnewManager: PropertiesManager,\n\t): PropertySet | undefined {\n\t\tif (oldProps) {\n\t\t\t// eslint-disable-next-line no-param-reassign\n\t\t\tnewProps ??= createMap<unknown>();\n\t\t\tif (!newManager) {\n\t\t\t\tthrow new Error(\"Must provide new PropertyManager\");\n\t\t\t}\n\t\t\textend(newProps, oldProps);\n\n\t\t\tif (this.pendingKeyUpdateCount) {\n\t\t\t\tnewManager.pendingKeyUpdateCount = clone(this.pendingKeyUpdateCount);\n\t\t\t}\n\t\t}\n\t\treturn newProps;\n\t}\n\n\t/**\n\t * Determines if all of the defined properties in a given property set are pending.\n\t */\n\tpublic hasPendingProperties(props: PropertySet): boolean {\n\t\tfor (const [key, value] of Object.entries(props)) {\n\t\t\tif (value !== undefined && this.pendingKeyUpdateCount?.[key] === undefined) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic hasPendingProperty(key: string): boolean {\n\t\treturn (this.pendingKeyUpdateCount?.[key] ?? 0) > 0;\n\t}\n}\n"]}
@@ -0,0 +1,66 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * Defines a position and side relative to a character in a sequence.
7
+ *
8
+ * For this purpose, sequences look like:
9
+ *
10
+ * `{start} - {character 0} - {character 1} - ... - {character N} - {end}`
11
+ *
12
+ * Each `{value}` in the diagram is a character within a sequence.
13
+ * Each `-` in the above diagram is a position where text could be inserted.
14
+ * Each position between a `{value}` and a `-` is a `SequencePlace`.
15
+ *
16
+ * The special endpoints `{start}` and `{end}` refer to positions outside the
17
+ * contents of the string.
18
+ *
19
+ * This gives us 2N + 2 possible positions to refer to within a string, where N
20
+ * is the number of characters.
21
+ *
22
+ * If the position is specified with a bare number, the side defaults to
23
+ * `Side.Before`.
24
+ *
25
+ * If a SequencePlace is the endpoint of a range (e.g. start/end of an interval or search range),
26
+ * the Side value means it is exclusive if it is nearer to the other position and inclusive if it is farther.
27
+ * E.g. the start of a range with Side.After is exclusive of the character at the position.
28
+ * @legacy
29
+ * @alpha
30
+ */
31
+ export type SequencePlace = number | "start" | "end" | InteriorSequencePlace;
32
+ /**
33
+ * A sequence place that does not refer to the special endpoint segments.
34
+ *
35
+ * See {@link SequencePlace} for additional context.
36
+ * @legacy
37
+ * @alpha
38
+ */
39
+ export interface InteriorSequencePlace {
40
+ pos: number;
41
+ side: Side;
42
+ }
43
+ /**
44
+ * Defines a side relative to a character in a sequence.
45
+ *
46
+ * @remarks See {@link SequencePlace} for additional context on usage.
47
+ * @legacy
48
+ * @alpha
49
+ */
50
+ export declare enum Side {
51
+ Before = 0,
52
+ After = 1
53
+ }
54
+ /**
55
+ * Returns the position and side of the start and end of a sequence.
56
+ *
57
+ * @legacy
58
+ * @alpha
59
+ */
60
+ export declare function endpointPosAndSide(start: SequencePlace | undefined, end: SequencePlace | undefined): {
61
+ startSide: Side | undefined;
62
+ endSide: Side | undefined;
63
+ startPos: number | "start" | "end" | undefined;
64
+ endPos: number | "start" | "end" | undefined;
65
+ };
66
+ //# sourceMappingURL=sequencePlace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sequencePlace.d.ts","sourceRoot":"","sources":["../src/sequencePlace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,qBAAqB,CAAC;AAE7E;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,IAAI,CAAC;CACX;AAED;;;;;;GAMG;AACH,oBAAY,IAAI;IACf,MAAM,IAAI;IACV,KAAK,IAAI;CACT;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,aAAa,GAAG,SAAS,EAChC,GAAG,EAAE,aAAa,GAAG,SAAS,GAC5B;IACF,SAAS,EAAE,IAAI,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,IAAI,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,SAAS,CAAC;IAC/C,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,SAAS,CAAC;CAC7C,CAiBA"}
@@ -0,0 +1,37 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * Defines a side relative to a character in a sequence.
7
+ *
8
+ * @remarks See {@link SequencePlace} for additional context on usage.
9
+ * @legacy
10
+ * @alpha
11
+ */
12
+ export var Side;
13
+ (function (Side) {
14
+ Side[Side["Before"] = 0] = "Before";
15
+ Side[Side["After"] = 1] = "After";
16
+ })(Side || (Side = {}));
17
+ /**
18
+ * Returns the position and side of the start and end of a sequence.
19
+ *
20
+ * @legacy
21
+ * @alpha
22
+ */
23
+ export function endpointPosAndSide(start, end) {
24
+ const startIsPlainEndpoint = typeof start === "number" || start === "start" || start === "end";
25
+ const endIsPlainEndpoint = typeof end === "number" || end === "start" || end === "end";
26
+ const startSide = startIsPlainEndpoint ? Side.Before : start?.side;
27
+ const endSide = endIsPlainEndpoint ? Side.Before : end?.side;
28
+ const startPos = startIsPlainEndpoint ? start : start?.pos;
29
+ const endPos = endIsPlainEndpoint ? end : end?.pos;
30
+ return {
31
+ startSide,
32
+ endSide,
33
+ startPos,
34
+ endPos,
35
+ };
36
+ }
37
+ //# sourceMappingURL=sequencePlace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sequencePlace.js","sourceRoot":"","sources":["../src/sequencePlace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA0CH;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,IAGX;AAHD,WAAY,IAAI;IACf,mCAAU,CAAA;IACV,iCAAS,CAAA;AACV,CAAC,EAHW,IAAI,KAAJ,IAAI,QAGf;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CACjC,KAAgC,EAChC,GAA8B;IAO9B,MAAM,oBAAoB,GACzB,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,KAAK,CAAC;IACnE,MAAM,kBAAkB,GAAG,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,KAAK,CAAC;IAEvF,MAAM,SAAS,GAAG,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC;IACnE,MAAM,OAAO,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC;IAE7D,MAAM,QAAQ,GAAG,oBAAoB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC;IAC3D,MAAM,MAAM,GAAG,kBAAkB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC;IAEnD,OAAO;QACN,SAAS;QACT,OAAO;QACP,QAAQ;QACR,MAAM;KACN,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Defines a position and side relative to a character in a sequence.\n *\n * For this purpose, sequences look like:\n *\n * `{start} - {character 0} - {character 1} - ... - {character N} - {end}`\n *\n * Each `{value}` in the diagram is a character within a sequence.\n * Each `-` in the above diagram is a position where text could be inserted.\n * Each position between a `{value}` and a `-` is a `SequencePlace`.\n *\n * The special endpoints `{start}` and `{end}` refer to positions outside the\n * contents of the string.\n *\n * This gives us 2N + 2 possible positions to refer to within a string, where N\n * is the number of characters.\n *\n * If the position is specified with a bare number, the side defaults to\n * `Side.Before`.\n *\n * If a SequencePlace is the endpoint of a range (e.g. start/end of an interval or search range),\n * the Side value means it is exclusive if it is nearer to the other position and inclusive if it is farther.\n * E.g. the start of a range with Side.After is exclusive of the character at the position.\n * @legacy\n * @alpha\n */\nexport type SequencePlace = number | \"start\" | \"end\" | InteriorSequencePlace;\n\n/**\n * A sequence place that does not refer to the special endpoint segments.\n *\n * See {@link SequencePlace} for additional context.\n * @legacy\n * @alpha\n */\nexport interface InteriorSequencePlace {\n\tpos: number;\n\tside: Side;\n}\n\n/**\n * Defines a side relative to a character in a sequence.\n *\n * @remarks See {@link SequencePlace} for additional context on usage.\n * @legacy\n * @alpha\n */\nexport enum Side {\n\tBefore = 0,\n\tAfter = 1,\n}\n\n/**\n * Returns the position and side of the start and end of a sequence.\n *\n * @legacy\n * @alpha\n */\nexport function endpointPosAndSide(\n\tstart: SequencePlace | undefined,\n\tend: SequencePlace | undefined,\n): {\n\tstartSide: Side | undefined;\n\tendSide: Side | undefined;\n\tstartPos: number | \"start\" | \"end\" | undefined;\n\tendPos: number | \"start\" | \"end\" | undefined;\n} {\n\tconst startIsPlainEndpoint =\n\t\ttypeof start === \"number\" || start === \"start\" || start === \"end\";\n\tconst endIsPlainEndpoint = typeof end === \"number\" || end === \"start\" || end === \"end\";\n\n\tconst startSide = startIsPlainEndpoint ? Side.Before : start?.side;\n\tconst endSide = endIsPlainEndpoint ? Side.Before : end?.side;\n\n\tconst startPos = startIsPlainEndpoint ? start : start?.pos;\n\tconst endPos = endIsPlainEndpoint ? end : end?.pos;\n\n\treturn {\n\t\tstartSide,\n\t\tendSide,\n\t\tstartPos,\n\t\tendPos,\n\t};\n}\n"]}
@@ -48,7 +48,7 @@ export class SnapshotLegacy {
48
48
  totalSegmentCount: allSegments.length,
49
49
  chunkSequenceNumber: this.header.seq,
50
50
  segmentTexts: segs.map((seg) => seg.toJSONObject()),
51
- attribution: segsWithAttribution > 0
51
+ attribution: segsWithAttribution > 0 || this.mergeTree.attributionPolicy?.isAttached
52
52
  ? attributionSerializer?.serializeAttributionCollections(segs)
53
53
  : undefined,
54
54
  };
@@ -1 +1 @@
1
- {"version":3,"file":"snapshotlegacy.js","sourceRoot":"","sources":["../src/snapshotlegacy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAG7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E,OAAO,EAEN,iBAAiB,GACjB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,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,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;gBAC1B,SAAS,EAAE,6BAA6B;gBACxC,WAAW;gBACX,mBAAmB,EAAE,IAAI,CAAC,MAAM,CAAC,mBAAmB;aACpD,CAAC,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,mBAAmB,GAAG,WAAW,CAAC;QAC/C,CAAC;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;;AA7OsB,qBAAM,GAAG,QAAQ,CAAC;AAClB,mBAAI,GAAG,MAAM,CAAC;AACb,yBAAU,GAAG,YAAY,CAAC;AAElD,2GAA2G;AAC3G,gHAAgH;AAChH,wFAAwF;AACxF,8FAA8F;AAC9F,wEAAwE;AACxE,sEAAsE;AAC/C,+BAAgB,GAAW,KAAK,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tcreateChildLogger,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { NonCollabClient, UnassignedSequenceNumber } from \"./constants.js\";\nimport { MergeTree } from \"./mergeTree.js\";\nimport { ISegment } from \"./mergeTreeNodes.js\";\nimport { matchProperties } from \"./properties.js\";\nimport {\n\tJsonSegmentSpecs,\n\tMergeTreeChunkLegacy,\n\tserializeAsMinSupportedVersion,\n} from \"./snapshotChunks.js\";\n\ninterface SnapshotHeader {\n\tchunkCount?: number;\n\tsegmentsTotalLength: number;\n\tindexOffset?: number;\n\tsegmentsOffset?: number;\n\tseq: number;\n\t// TODO: Make 'minSeq' non-optional once the new snapshot format becomes the default?\n\t// (See https://github.com/microsoft/FluidFramework/issues/84)\n\tminSeq?: number;\n}\n\n/**\n * @internal\n */\nexport class SnapshotLegacy {\n\tpublic static readonly header = \"header\";\n\tpublic static readonly body = \"body\";\n\tprivate static readonly catchupOps = \"catchupOps\";\n\n\t// Split snapshot into two entries - headers (small) and body (overflow) for faster loading initial content\n\t// Please note that this number has no direct relationship to anything other than size of raw text (characters).\n\t// As we produce json for the blob (and then send over the wire compressed), this number\n\t// is really hard to correlate with any actual metric that matters (like bytes over the wire).\n\t// For test with small number of chunks it would be closer to blob size,\n\t// for very chunky text, blob size can easily be 4x-8x of that number.\n\tpublic static readonly sizeOfFirstChunk: number = 10000;\n\n\tprivate header: SnapshotHeader | undefined;\n\tprivate seq: number | undefined;\n\tprivate segments: ISegment[] | undefined;\n\tprivate readonly logger: ITelemetryLoggerExt;\n\tprivate readonly chunkSize: number;\n\n\tconstructor(\n\t\tpublic mergeTree: MergeTree,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tpublic filename?: string,\n\t\tpublic onCompletion?: () => void,\n\t) {\n\t\tthis.logger = createChildLogger({ logger, namespace: \"Snapshot\" });\n\t\tthis.chunkSize =\n\t\t\tmergeTree?.options?.mergeTreeSnapshotChunkSize ?? SnapshotLegacy.sizeOfFirstChunk;\n\t}\n\n\tprivate getSeqLengthSegs(\n\t\tallSegments: ISegment[],\n\t\tapproxSequenceLength: number,\n\t\tstartIndex = 0,\n\t): MergeTreeChunkLegacy {\n\t\tconst segs: ISegment[] = [];\n\t\tlet sequenceLength = 0;\n\t\tlet segCount = 0;\n\t\tlet segsWithAttribution = 0;\n\t\twhile (\n\t\t\tsequenceLength < approxSequenceLength &&\n\t\t\tstartIndex + segCount < allSegments.length\n\t\t) {\n\t\t\t// TODO Non null asserting, why is this not null?\n\t\t\tconst pseg = allSegments[startIndex + segCount]!;\n\t\t\tsegs.push(pseg);\n\t\t\tif (pseg.attribution) {\n\t\t\t\tsegsWithAttribution++;\n\t\t\t}\n\t\t\tsequenceLength += pseg.cachedLength;\n\t\t\tsegCount++;\n\t\t}\n\n\t\tassert(\n\t\t\tsegsWithAttribution === 0 || segsWithAttribution === segCount,\n\t\t\t0x4bf /* all or no segments should have attribution */,\n\t\t);\n\n\t\tconst attributionSerializer = this.mergeTree.attributionPolicy?.serializer;\n\t\tassert(\n\t\t\tsegsWithAttribution === 0 || attributionSerializer !== undefined,\n\t\t\t0x559 /* attribution serializer must be provided when there are segments with attribution. */,\n\t\t);\n\t\treturn {\n\t\t\tversion: undefined,\n\t\t\tchunkStartSegmentIndex: startIndex,\n\t\t\tchunkSegmentCount: segCount,\n\t\t\tchunkLengthChars: sequenceLength,\n\t\t\ttotalLengthChars: this.header!.segmentsTotalLength,\n\t\t\ttotalSegmentCount: allSegments.length,\n\t\t\tchunkSequenceNumber: this.header!.seq,\n\t\t\tsegmentTexts: segs.map((seg) => seg.toJSONObject() as JsonSegmentSpecs),\n\t\t\tattribution:\n\t\t\t\tsegsWithAttribution > 0\n\t\t\t\t\t? attributionSerializer?.serializeAttributionCollections(segs)\n\t\t\t\t\t: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Emits the snapshot to an ISummarizeResult. If provided the optional IFluidSerializer will be used when\n\t * serializing the summary data rather than JSON.stringify.\n\t */\n\temit(\n\t\tcatchUpMsgs: ISequencedDocumentMessage[],\n\t\tserializer: IFluidSerializer,\n\t\tbind: IFluidHandle,\n\t): ISummaryTreeWithStats {\n\t\tconst chunk1 = this.getSeqLengthSegs(this.segments!, this.chunkSize);\n\t\tlet length: number = chunk1.chunkLengthChars;\n\t\tlet segments: number = chunk1.chunkSegmentCount;\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addBlob(\n\t\t\tSnapshotLegacy.header,\n\t\t\tserializeAsMinSupportedVersion(\n\t\t\t\tSnapshotLegacy.header,\n\t\t\t\tchunk1,\n\t\t\t\tthis.logger,\n\t\t\t\tthis.mergeTree.options,\n\t\t\t\tserializer,\n\t\t\t\tbind,\n\t\t\t),\n\t\t);\n\n\t\tif (chunk1.chunkSegmentCount < chunk1.totalSegmentCount!) {\n\t\t\tconst chunk2 = this.getSeqLengthSegs(\n\t\t\t\tthis.segments!,\n\t\t\t\tthis.header!.segmentsTotalLength,\n\t\t\t\tchunk1.chunkSegmentCount,\n\t\t\t);\n\t\t\tlength += chunk2.chunkLengthChars;\n\t\t\tsegments += chunk2.chunkSegmentCount;\n\t\t\tbuilder.addBlob(\n\t\t\t\tSnapshotLegacy.body,\n\t\t\t\tserializeAsMinSupportedVersion(\n\t\t\t\t\tSnapshotLegacy.body,\n\t\t\t\t\tchunk2,\n\t\t\t\t\tthis.logger,\n\t\t\t\t\tthis.mergeTree.options,\n\t\t\t\t\tserializer,\n\t\t\t\t\tbind,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tassert(\n\t\t\tlength === this.header!.segmentsTotalLength,\n\t\t\t0x05d /* \"emit: mismatch in segmentsTotalLength\" */,\n\t\t);\n\n\t\tassert(\n\t\t\tsegments === chunk1.totalSegmentCount,\n\t\t\t0x05e /* \"emit: mismatch in totalSegmentCount\" */,\n\t\t);\n\n\t\tif (catchUpMsgs !== undefined && catchUpMsgs.length > 0) {\n\t\t\t// Messages used to have a \"term\" property which has since been removed.\n\t\t\t// It is benign so it doesn't really need to be deleted here, but doing so permits snapshot tests\n\t\t\t// to pass with an exact match (and matching the updated definition of ISequencedDocumentMessage).\n\t\t\tfor (const message of catchUpMsgs) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n\t\t\t\tdelete (message as any).term;\n\t\t\t}\n\t\t\tbuilder.addBlob(\n\t\t\t\tthis.mergeTree.options?.catchUpBlobName ?? SnapshotLegacy.catchupOps,\n\t\t\t\tserializer ? serializer.stringify(catchUpMsgs, bind) : JSON.stringify(catchUpMsgs),\n\t\t\t);\n\t\t}\n\n\t\treturn builder.getSummaryTree();\n\t}\n\n\textractSync(): ISegment[] {\n\t\tconst collabWindow = this.mergeTree.collabWindow;\n\t\tthis.seq = collabWindow.minSeq;\n\t\tthis.header = {\n\t\t\tsegmentsTotalLength: this.mergeTree.getLength(\n\t\t\t\tthis.mergeTree.collabWindow.minSeq,\n\t\t\t\tNonCollabClient,\n\t\t\t),\n\t\t\tseq: this.mergeTree.collabWindow.minSeq,\n\t\t};\n\n\t\tlet originalSegments = 0;\n\n\t\tconst segs: ISegment[] = [];\n\t\tlet prev: ISegment | undefined;\n\t\tconst extractSegment = (\n\t\t\tsegment: ISegment,\n\t\t\tpos: number,\n\t\t\trefSeq: number,\n\t\t\tclientId: number,\n\t\t\tstart: number | undefined,\n\t\t\tend: number | undefined,\n\t\t): boolean => {\n\t\t\tif (\n\t\t\t\tsegment.seq !== UnassignedSequenceNumber &&\n\t\t\t\tsegment.seq! <= this.seq! &&\n\t\t\t\t(segment.removedSeq === undefined ||\n\t\t\t\t\tsegment.removedSeq === UnassignedSequenceNumber ||\n\t\t\t\t\tsegment.removedSeq > this.seq!)\n\t\t\t) {\n\t\t\t\toriginalSegments += 1;\n\t\t\t\tif (prev?.canAppend(segment) && matchProperties(prev.properties, segment.properties)) {\n\t\t\t\t\tprev = prev.clone();\n\t\t\t\t\tprev.append(segment.clone());\n\t\t\t\t} else {\n\t\t\t\t\tif (prev) {\n\t\t\t\t\t\tsegs.push(prev);\n\t\t\t\t\t}\n\t\t\t\t\tprev = segment;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\tthis.mergeTree.mapRange(extractSegment, this.seq, NonCollabClient, undefined);\n\t\tif (prev) {\n\t\t\tsegs.push(prev);\n\t\t}\n\n\t\tthis.segments = [];\n\t\tlet totalLength: number = 0;\n\t\tsegs.map((segment) => {\n\t\t\ttotalLength += segment.cachedLength;\n\t\t\tif (segment.properties !== undefined && Object.keys(segment.properties).length === 0) {\n\t\t\t\tsegment.properties = undefined;\n\t\t\t\tsegment.propertyManager = undefined;\n\t\t\t}\n\t\t\tthis.segments!.push(segment);\n\t\t});\n\n\t\t// To reduce potential spam from this telemetry, we sample only a small\n\t\t// percentage of summaries\n\t\tif (Math.abs(originalSegments - segs.length) > 500 && Math.random() < 0.005) {\n\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"MergeTreeLegacySummarizeSegmentCount\",\n\t\t\t\toriginalSegments,\n\t\t\t\tsegmentsAfterCombine: segs.length,\n\t\t\t\tsegmentsLen: this.segments.length,\n\t\t\t});\n\t\t}\n\n\t\t// We observed this.header.segmentsTotalLength < totalLength to happen in some cases\n\t\t// When this condition happens, we might not write out all segments in getSeqLengthSegs()\n\t\t// when writing out \"body\". Issue #1995 tracks following up on the core of the problem.\n\t\t// In the meantime, this code makes sure we will write out all segments properly\n\n\t\tif (this.header.segmentsTotalLength !== totalLength) {\n\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\teventName: \"SegmentsTotalLengthMismatch\",\n\t\t\t\ttotalLength,\n\t\t\t\tsegmentsTotalLength: this.header.segmentsTotalLength,\n\t\t\t});\n\t\t\tthis.header.segmentsTotalLength = totalLength;\n\t\t}\n\n\t\treturn this.segments;\n\t}\n}\n"]}
1
+ {"version":3,"file":"snapshotlegacy.js","sourceRoot":"","sources":["../src/snapshotlegacy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAG7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E,OAAO,EAEN,iBAAiB,GACjB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAG3E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAGN,8BAA8B,GAC9B,MAAM,qBAAqB,CAAC;AAa7B;;GAEG;AACH,MAAM,OAAO,cAAc;IAmB1B,Y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AC,MAAM,CAAC,mBAAmB;aACpD,CAAC,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,mBAAmB,GAAG,WAAW,CAAC;QAC/C,CAAC;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;;AA7OsB,qBAAM,GAAG,QAAQ,CAAC;AAClB,mBAAI,GAAG,MAAM,CAAC;AACb,yBAAU,GAAG,YAAY,CAAC;AAElD,2GAA2G;AAC3G,gHAAgH;AAChH,wFAAwF;AACxF,8FAA8F;AAC9F,wEAAwE;AACxE,sEAAsE;AAC/C,+BAAgB,GAAW,KAAK,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tcreateChildLogger,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { NonCollabClient, UnassignedSequenceNumber } from \"./constants.js\";\nimport { MergeTree } from \"./mergeTree.js\";\nimport { ISegment } from \"./mergeTreeNodes.js\";\nimport { matchProperties } from \"./properties.js\";\nimport {\n\tJsonSegmentSpecs,\n\tMergeTreeChunkLegacy,\n\tserializeAsMinSupportedVersion,\n} from \"./snapshotChunks.js\";\n\ninterface SnapshotHeader {\n\tchunkCount?: number;\n\tsegmentsTotalLength: number;\n\tindexOffset?: number;\n\tsegmentsOffset?: number;\n\tseq: number;\n\t// TODO: Make 'minSeq' non-optional once the new snapshot format becomes the default?\n\t// (See https://github.com/microsoft/FluidFramework/issues/84)\n\tminSeq?: number;\n}\n\n/**\n * @internal\n */\nexport class SnapshotLegacy {\n\tpublic static readonly header = \"header\";\n\tpublic static readonly body = \"body\";\n\tprivate static readonly catchupOps = \"catchupOps\";\n\n\t// Split snapshot into two entries - headers (small) and body (overflow) for faster loading initial content\n\t// Please note that this number has no direct relationship to anything other than size of raw text (characters).\n\t// As we produce json for the blob (and then send over the wire compressed), this number\n\t// is really hard to correlate with any actual metric that matters (like bytes over the wire).\n\t// For test with small number of chunks it would be closer to blob size,\n\t// for very chunky text, blob size can easily be 4x-8x of that number.\n\tpublic static readonly sizeOfFirstChunk: number = 10000;\n\n\tprivate header: SnapshotHeader | undefined;\n\tprivate seq: number | undefined;\n\tprivate segments: ISegment[] | undefined;\n\tprivate readonly logger: ITelemetryLoggerExt;\n\tprivate readonly chunkSize: number;\n\n\tconstructor(\n\t\tpublic mergeTree: MergeTree,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tpublic filename?: string,\n\t\tpublic onCompletion?: () => void,\n\t) {\n\t\tthis.logger = createChildLogger({ logger, namespace: \"Snapshot\" });\n\t\tthis.chunkSize =\n\t\t\tmergeTree?.options?.mergeTreeSnapshotChunkSize ?? SnapshotLegacy.sizeOfFirstChunk;\n\t}\n\n\tprivate getSeqLengthSegs(\n\t\tallSegments: ISegment[],\n\t\tapproxSequenceLength: number,\n\t\tstartIndex = 0,\n\t): MergeTreeChunkLegacy {\n\t\tconst segs: ISegment[] = [];\n\t\tlet sequenceLength = 0;\n\t\tlet segCount = 0;\n\t\tlet segsWithAttribution = 0;\n\t\twhile (\n\t\t\tsequenceLength < approxSequenceLength &&\n\t\t\tstartIndex + segCount < allSegments.length\n\t\t) {\n\t\t\t// TODO Non null asserting, why is this not null?\n\t\t\tconst pseg = allSegments[startIndex + segCount]!;\n\t\t\tsegs.push(pseg);\n\t\t\tif (pseg.attribution) {\n\t\t\t\tsegsWithAttribution++;\n\t\t\t}\n\t\t\tsequenceLength += pseg.cachedLength;\n\t\t\tsegCount++;\n\t\t}\n\n\t\tassert(\n\t\t\tsegsWithAttribution === 0 || segsWithAttribution === segCount,\n\t\t\t0x4bf /* all or no segments should have attribution */,\n\t\t);\n\n\t\tconst attributionSerializer = this.mergeTree.attributionPolicy?.serializer;\n\t\tassert(\n\t\t\tsegsWithAttribution === 0 || attributionSerializer !== undefined,\n\t\t\t0x559 /* attribution serializer must be provided when there are segments with attribution. */,\n\t\t);\n\t\treturn {\n\t\t\tversion: undefined,\n\t\t\tchunkStartSegmentIndex: startIndex,\n\t\t\tchunkSegmentCount: segCount,\n\t\t\tchunkLengthChars: sequenceLength,\n\t\t\ttotalLengthChars: this.header!.segmentsTotalLength,\n\t\t\ttotalSegmentCount: allSegments.length,\n\t\t\tchunkSequenceNumber: this.header!.seq,\n\t\t\tsegmentTexts: segs.map((seg) => seg.toJSONObject() as JsonSegmentSpecs),\n\t\t\tattribution:\n\t\t\t\tsegsWithAttribution > 0 || this.mergeTree.attributionPolicy?.isAttached\n\t\t\t\t\t? attributionSerializer?.serializeAttributionCollections(segs)\n\t\t\t\t\t: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Emits the snapshot to an ISummarizeResult. If provided the optional IFluidSerializer will be used when\n\t * serializing the summary data rather than JSON.stringify.\n\t */\n\temit(\n\t\tcatchUpMsgs: ISequencedDocumentMessage[],\n\t\tserializer: IFluidSerializer,\n\t\tbind: IFluidHandle,\n\t): ISummaryTreeWithStats {\n\t\tconst chunk1 = this.getSeqLengthSegs(this.segments!, this.chunkSize);\n\t\tlet length: number = chunk1.chunkLengthChars;\n\t\tlet segments: number = chunk1.chunkSegmentCount;\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addBlob(\n\t\t\tSnapshotLegacy.header,\n\t\t\tserializeAsMinSupportedVersion(\n\t\t\t\tSnapshotLegacy.header,\n\t\t\t\tchunk1,\n\t\t\t\tthis.logger,\n\t\t\t\tthis.mergeTree.options,\n\t\t\t\tserializer,\n\t\t\t\tbind,\n\t\t\t),\n\t\t);\n\n\t\tif (chunk1.chunkSegmentCount < chunk1.totalSegmentCount!) {\n\t\t\tconst chunk2 = this.getSeqLengthSegs(\n\t\t\t\tthis.segments!,\n\t\t\t\tthis.header!.segmentsTotalLength,\n\t\t\t\tchunk1.chunkSegmentCount,\n\t\t\t);\n\t\t\tlength += chunk2.chunkLengthChars;\n\t\t\tsegments += chunk2.chunkSegmentCount;\n\t\t\tbuilder.addBlob(\n\t\t\t\tSnapshotLegacy.body,\n\t\t\t\tserializeAsMinSupportedVersion(\n\t\t\t\t\tSnapshotLegacy.body,\n\t\t\t\t\tchunk2,\n\t\t\t\t\tthis.logger,\n\t\t\t\t\tthis.mergeTree.options,\n\t\t\t\t\tserializer,\n\t\t\t\t\tbind,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tassert(\n\t\t\tlength === this.header!.segmentsTotalLength,\n\t\t\t0x05d /* \"emit: mismatch in segmentsTotalLength\" */,\n\t\t);\n\n\t\tassert(\n\t\t\tsegments === chunk1.totalSegmentCount,\n\t\t\t0x05e /* \"emit: mismatch in totalSegmentCount\" */,\n\t\t);\n\n\t\tif (catchUpMsgs !== undefined && catchUpMsgs.length > 0) {\n\t\t\t// Messages used to have a \"term\" property which has since been removed.\n\t\t\t// It is benign so it doesn't really need to be deleted here, but doing so permits snapshot tests\n\t\t\t// to pass with an exact match (and matching the updated definition of ISequencedDocumentMessage).\n\t\t\tfor (const message of catchUpMsgs) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n\t\t\t\tdelete (message as any).term;\n\t\t\t}\n\t\t\tbuilder.addBlob(\n\t\t\t\tthis.mergeTree.options?.catchUpBlobName ?? SnapshotLegacy.catchupOps,\n\t\t\t\tserializer ? serializer.stringify(catchUpMsgs, bind) : JSON.stringify(catchUpMsgs),\n\t\t\t);\n\t\t}\n\n\t\treturn builder.getSummaryTree();\n\t}\n\n\textractSync(): ISegment[] {\n\t\tconst collabWindow = this.mergeTree.collabWindow;\n\t\tthis.seq = collabWindow.minSeq;\n\t\tthis.header = {\n\t\t\tsegmentsTotalLength: this.mergeTree.getLength(\n\t\t\t\tthis.mergeTree.collabWindow.minSeq,\n\t\t\t\tNonCollabClient,\n\t\t\t),\n\t\t\tseq: this.mergeTree.collabWindow.minSeq,\n\t\t};\n\n\t\tlet originalSegments = 0;\n\n\t\tconst segs: ISegment[] = [];\n\t\tlet prev: ISegment | undefined;\n\t\tconst extractSegment = (\n\t\t\tsegment: ISegment,\n\t\t\tpos: number,\n\t\t\trefSeq: number,\n\t\t\tclientId: number,\n\t\t\tstart: number | undefined,\n\t\t\tend: number | undefined,\n\t\t): boolean => {\n\t\t\tif (\n\t\t\t\tsegment.seq !== UnassignedSequenceNumber &&\n\t\t\t\tsegment.seq! <= this.seq! &&\n\t\t\t\t(segment.removedSeq === undefined ||\n\t\t\t\t\tsegment.removedSeq === UnassignedSequenceNumber ||\n\t\t\t\t\tsegment.removedSeq > this.seq!)\n\t\t\t) {\n\t\t\t\toriginalSegments += 1;\n\t\t\t\tif (prev?.canAppend(segment) && matchProperties(prev.properties, segment.properties)) {\n\t\t\t\t\tprev = prev.clone();\n\t\t\t\t\tprev.append(segment.clone());\n\t\t\t\t} else {\n\t\t\t\t\tif (prev) {\n\t\t\t\t\t\tsegs.push(prev);\n\t\t\t\t\t}\n\t\t\t\t\tprev = segment;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\tthis.mergeTree.mapRange(extractSegment, this.seq, NonCollabClient, undefined);\n\t\tif (prev) {\n\t\t\tsegs.push(prev);\n\t\t}\n\n\t\tthis.segments = [];\n\t\tlet totalLength: number = 0;\n\t\tsegs.map((segment) => {\n\t\t\ttotalLength += segment.cachedLength;\n\t\t\tif (segment.properties !== undefined && Object.keys(segment.properties).length === 0) {\n\t\t\t\tsegment.properties = undefined;\n\t\t\t\tsegment.propertyManager = undefined;\n\t\t\t}\n\t\t\tthis.segments!.push(segment);\n\t\t});\n\n\t\t// To reduce potential spam from this telemetry, we sample only a small\n\t\t// percentage of summaries\n\t\tif (Math.abs(originalSegments - segs.length) > 500 && Math.random() < 0.005) {\n\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"MergeTreeLegacySummarizeSegmentCount\",\n\t\t\t\toriginalSegments,\n\t\t\t\tsegmentsAfterCombine: segs.length,\n\t\t\t\tsegmentsLen: this.segments.length,\n\t\t\t});\n\t\t}\n\n\t\t// We observed this.header.segmentsTotalLength < totalLength to happen in some cases\n\t\t// When this condition happens, we might not write out all segments in getSeqLengthSegs()\n\t\t// when writing out \"body\". Issue #1995 tracks following up on the core of the problem.\n\t\t// In the meantime, this code makes sure we will write out all segments properly\n\n\t\tif (this.header.segmentsTotalLength !== totalLength) {\n\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\teventName: \"SegmentsTotalLengthMismatch\",\n\t\t\t\ttotalLength,\n\t\t\t\tsegmentsTotalLength: this.header.segmentsTotalLength,\n\t\t\t});\n\t\t\tthis.header.segmentsTotalLength = totalLength;\n\t\t}\n\n\t\treturn this.segments;\n\t}\n}\n"]}
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=obliterate.rangeExpansion.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"obliterate.rangeExpansion.spec.d.ts","sourceRoot":"","sources":["../../src/test/obliterate.rangeExpansion.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG"}