@fluidframework/merge-tree 2.117.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/CHANGELOG.md +36 -2
  2. package/README.md +53 -50
  3. package/{api-extractor.json → api-extractor/api-extractor-model.json} +1 -1
  4. package/dist/MergeTreeTextHelper.js +1 -0
  5. package/dist/MergeTreeTextHelper.js.map +1 -1
  6. package/dist/attributionCollection.js +6 -4
  7. package/dist/attributionCollection.js.map +1 -1
  8. package/dist/attributionPolicy.js +3 -4
  9. package/dist/attributionPolicy.js.map +1 -1
  10. package/dist/client.js +27 -10
  11. package/dist/client.js.map +1 -1
  12. package/dist/collections/rbTree.d.ts.map +1 -1
  13. package/dist/collections/rbTree.js +3 -0
  14. package/dist/collections/rbTree.js.map +1 -1
  15. package/dist/endOfTreeSegment.d.ts.map +1 -1
  16. package/dist/endOfTreeSegment.js +25 -26
  17. package/dist/endOfTreeSegment.js.map +1 -1
  18. package/dist/localReference.js +17 -7
  19. package/dist/localReference.js.map +1 -1
  20. package/dist/mergeTree.d.ts.map +1 -1
  21. package/dist/mergeTree.js +90 -74
  22. package/dist/mergeTree.js.map +1 -1
  23. package/dist/mergeTreeNodeWalk.js +5 -5
  24. package/dist/mergeTreeNodeWalk.js.map +1 -1
  25. package/dist/mergeTreeNodes.d.ts.map +1 -1
  26. package/dist/mergeTreeNodes.js +117 -90
  27. package/dist/mergeTreeNodes.js.map +1 -1
  28. package/dist/mergeTreeTracking.js +4 -0
  29. package/dist/mergeTreeTracking.js.map +1 -1
  30. package/dist/opBuilder.js +9 -10
  31. package/dist/opBuilder.js.map +1 -1
  32. package/dist/ordinal.js +1 -2
  33. package/dist/ordinal.js.map +1 -1
  34. package/dist/partialLengths.js +109 -73
  35. package/dist/partialLengths.js.map +1 -1
  36. package/dist/perspective.js +31 -11
  37. package/dist/perspective.js.map +1 -1
  38. package/dist/properties.js +6 -7
  39. package/dist/properties.js.map +1 -1
  40. package/dist/referencePositions.d.ts.map +1 -1
  41. package/dist/referencePositions.js +7 -7
  42. package/dist/referencePositions.js.map +1 -1
  43. package/dist/revertibles.js +4 -5
  44. package/dist/revertibles.js.map +1 -1
  45. package/dist/segmentGroupCollection.js +2 -0
  46. package/dist/segmentGroupCollection.js.map +1 -1
  47. package/dist/segmentInfos.d.ts.map +1 -1
  48. package/dist/segmentInfos.js +5 -5
  49. package/dist/segmentInfos.js.map +1 -1
  50. package/dist/segmentPropertiesManager.js +3 -5
  51. package/dist/segmentPropertiesManager.js.map +1 -1
  52. package/dist/sequencePlace.js +3 -3
  53. package/dist/sequencePlace.js.map +1 -1
  54. package/dist/snapshotChunks.d.ts.map +1 -1
  55. package/dist/snapshotChunks.js +6 -6
  56. package/dist/snapshotChunks.js.map +1 -1
  57. package/dist/snapshotLoader.js +85 -70
  58. package/dist/snapshotLoader.js.map +1 -1
  59. package/dist/snapshotV1.d.ts.map +1 -1
  60. package/dist/snapshotV1.js +34 -14
  61. package/dist/snapshotV1.js.map +1 -1
  62. package/dist/snapshotlegacy.d.ts.map +1 -1
  63. package/dist/snapshotlegacy.js +18 -10
  64. package/dist/snapshotlegacy.js.map +1 -1
  65. package/dist/sortedSet.js +1 -3
  66. package/dist/sortedSet.js.map +1 -1
  67. package/dist/stamps.js +11 -12
  68. package/dist/stamps.js.map +1 -1
  69. package/dist/test/attributionCollection.spec.js +1 -1
  70. package/dist/test/attributionCollection.spec.js.map +1 -1
  71. package/dist/test/beastTest.spec.js +15 -11
  72. package/dist/test/beastTest.spec.js.map +1 -1
  73. package/dist/test/client.apis.spec.js +2 -3
  74. package/dist/test/client.apis.spec.js.map +1 -1
  75. package/dist/test/client.replay.spec.js +17 -7
  76. package/dist/test/client.replay.spec.js.map +1 -1
  77. package/dist/test/clientTestHelper.js +7 -4
  78. package/dist/test/clientTestHelper.js.map +1 -1
  79. package/dist/test/mergeTreeOperationRunner.js +26 -16
  80. package/dist/test/mergeTreeOperationRunner.js.map +1 -1
  81. package/dist/test/obliterateOperations.d.ts.map +1 -1
  82. package/dist/test/revertibles.spec.js +1 -2
  83. package/dist/test/revertibles.spec.js.map +1 -1
  84. package/dist/test/snapshot.utils.d.ts.map +1 -1
  85. package/dist/test/snapshot.utils.js +7 -5
  86. package/dist/test/snapshot.utils.js.map +1 -1
  87. package/dist/test/stamps.spec.js +17 -7
  88. package/dist/test/stamps.spec.js.map +1 -1
  89. package/dist/test/testClient.d.ts.map +1 -1
  90. package/dist/test/testClient.js +19 -17
  91. package/dist/test/testClient.js.map +1 -1
  92. package/dist/test/testClientLogger.d.ts.map +1 -1
  93. package/dist/test/testClientLogger.js +12 -8
  94. package/dist/test/testClientLogger.js.map +1 -1
  95. package/dist/test/testServer.js +7 -7
  96. package/dist/test/testServer.js.map +1 -1
  97. package/dist/test/testUtils.d.ts +0 -1
  98. package/dist/test/testUtils.d.ts.map +1 -1
  99. package/dist/test/testUtils.js +9 -10
  100. package/dist/test/testUtils.js.map +1 -1
  101. package/dist/test/text.js +2 -3
  102. package/dist/test/text.js.map +1 -1
  103. package/dist/test/wordUnitTests.spec.js +1 -2
  104. package/dist/test/wordUnitTests.spec.js.map +1 -1
  105. package/dist/textSegment.js +3 -2
  106. package/dist/textSegment.js.map +1 -1
  107. package/dist/zamboni.js +20 -10
  108. package/dist/zamboni.js.map +1 -1
  109. package/lib/MergeTreeTextHelper.js +1 -0
  110. package/lib/MergeTreeTextHelper.js.map +1 -1
  111. package/lib/attributionCollection.js +4 -2
  112. package/lib/attributionCollection.js.map +1 -1
  113. package/lib/client.js +10 -3
  114. package/lib/client.js.map +1 -1
  115. package/lib/collections/rbTree.d.ts.map +1 -1
  116. package/lib/collections/rbTree.js +3 -0
  117. package/lib/collections/rbTree.js.map +1 -1
  118. package/lib/endOfTreeSegment.d.ts.map +1 -1
  119. package/lib/endOfTreeSegment.js +25 -26
  120. package/lib/endOfTreeSegment.js.map +1 -1
  121. package/lib/legacy.d.ts +1 -1
  122. package/lib/localReference.js +12 -2
  123. package/lib/localReference.js.map +1 -1
  124. package/lib/mergeTree.d.ts.map +1 -1
  125. package/lib/mergeTree.js +68 -62
  126. package/lib/mergeTree.js.map +1 -1
  127. package/lib/mergeTreeNodes.d.ts.map +1 -1
  128. package/lib/mergeTreeNodes.js +111 -84
  129. package/lib/mergeTreeNodes.js.map +1 -1
  130. package/lib/mergeTreeTracking.js +4 -0
  131. package/lib/mergeTreeTracking.js.map +1 -1
  132. package/lib/partialLengths.js +89 -63
  133. package/lib/partialLengths.js.map +1 -1
  134. package/lib/perspective.js +12 -2
  135. package/lib/perspective.js.map +1 -1
  136. package/lib/public.d.ts +1 -1
  137. package/lib/referencePositions.d.ts.map +1 -1
  138. package/lib/segmentGroupCollection.js +2 -0
  139. package/lib/segmentGroupCollection.js.map +1 -1
  140. package/lib/segmentInfos.d.ts.map +1 -1
  141. package/lib/segmentPropertiesManager.js +1 -3
  142. package/lib/segmentPropertiesManager.js.map +1 -1
  143. package/lib/snapshotChunks.d.ts.map +1 -1
  144. package/lib/snapshotChunks.js +2 -1
  145. package/lib/snapshotChunks.js.map +1 -1
  146. package/lib/snapshotLoader.js +68 -63
  147. package/lib/snapshotLoader.js.map +1 -1
  148. package/lib/snapshotV1.d.ts.map +1 -1
  149. package/lib/snapshotV1.js +17 -7
  150. package/lib/snapshotV1.js.map +1 -1
  151. package/lib/snapshotlegacy.d.ts.map +1 -1
  152. package/lib/snapshotlegacy.js +18 -10
  153. package/lib/snapshotlegacy.js.map +1 -1
  154. package/lib/sortedSet.js +1 -3
  155. package/lib/sortedSet.js.map +1 -1
  156. package/lib/test/attributionCollection.spec.js +1 -1
  157. package/lib/test/attributionCollection.spec.js.map +1 -1
  158. package/lib/test/beastTest.spec.js +7 -3
  159. package/lib/test/beastTest.spec.js.map +1 -1
  160. package/lib/test/clientTestHelper.js +7 -4
  161. package/lib/test/clientTestHelper.js.map +1 -1
  162. package/lib/test/obliterateOperations.d.ts.map +1 -1
  163. package/lib/test/snapshot.utils.d.ts.map +1 -1
  164. package/lib/test/snapshot.utils.js +5 -3
  165. package/lib/test/snapshot.utils.js.map +1 -1
  166. package/lib/test/testClient.d.ts.map +1 -1
  167. package/lib/test/testClient.js +16 -14
  168. package/lib/test/testClient.js.map +1 -1
  169. package/lib/test/testClientLogger.d.ts.map +1 -1
  170. package/lib/test/testClientLogger.js +10 -6
  171. package/lib/test/testClientLogger.js.map +1 -1
  172. package/lib/test/testServer.js +5 -5
  173. package/lib/test/testServer.js.map +1 -1
  174. package/lib/test/testUtils.d.ts +0 -1
  175. package/lib/test/testUtils.d.ts.map +1 -1
  176. package/lib/textSegment.js +3 -2
  177. package/lib/textSegment.js.map +1 -1
  178. package/package.json +39 -58
  179. package/src/snapshotChunks.ts +10 -6
  180. package/tsconfig.json +1 -1
  181. package/internal.d.ts +0 -11
  182. package/legacy.d.ts +0 -11
  183. /package/api-extractor/{api-extractor.current.json → api-extractor-report.current.json} +0 -0
  184. /package/api-extractor/{api-extractor.legacy.json → api-extractor-report.legacy.json} +0 -0
@@ -25,6 +25,8 @@ class PerspectiveBase {
25
25
  * catches unacked edits from the local client.
26
26
  */
27
27
  export class PriorPerspective extends PerspectiveBase {
28
+ refSeq;
29
+ clientId;
28
30
  constructor(refSeq, clientId) {
29
31
  super();
30
32
  this.refSeq = refSeq;
@@ -45,6 +47,9 @@ export class PriorPerspective extends PerspectiveBase {
45
47
  * rederive positions for unacked ops while only considering a portion of its own edits as having been applied.
46
48
  */
47
49
  export class LocalReconnectingPerspective extends PerspectiveBase {
50
+ refSeq;
51
+ clientId;
52
+ localSeq;
48
53
  constructor(refSeq, clientId, localSeq) {
49
54
  super();
50
55
  this.refSeq = refSeq;
@@ -66,6 +71,9 @@ export class LocalReconnectingPerspective extends PerspectiveBase {
66
71
  * fully correct.
67
72
  */
68
73
  export class LocalSquashPerspective extends LocalReconnectingPerspective {
74
+ refSeq;
75
+ clientId;
76
+ localSeq;
69
77
  constructor(refSeq, clientId, localSeq) {
70
78
  super(refSeq, clientId, localSeq);
71
79
  this.refSeq = refSeq;
@@ -99,10 +107,11 @@ export function createLocalReconnectingPerspective(refSeq, clientId, localSeq, s
99
107
  * variant of this perspective renders extra refSeq checks unnecessary and is a bit easier to read.
100
108
  */
101
109
  export class LocalDefaultPerspective extends PerspectiveBase {
110
+ clientId;
111
+ refSeq = Number.MAX_SAFE_INTEGER;
102
112
  constructor(clientId) {
103
113
  super();
104
114
  this.clientId = clientId;
105
- this.refSeq = Number.MAX_SAFE_INTEGER;
106
115
  }
107
116
  hasOccurred(_stamp) {
108
117
  return true;
@@ -117,10 +126,11 @@ export class LocalDefaultPerspective extends PerspectiveBase {
117
126
  * but use with caution.
118
127
  */
119
128
  export class RemoteObliteratePerspective extends PerspectiveBase {
129
+ clientId;
130
+ refSeq = Number.MAX_SAFE_INTEGER;
120
131
  constructor(clientId) {
121
132
  super();
122
133
  this.clientId = clientId;
123
- this.refSeq = Number.MAX_SAFE_INTEGER;
124
134
  }
125
135
  hasOccurred(stamp) {
126
136
  // Local-only removals are not visible to an obliterate operation, since this means the local removal was concurrent
@@ -1 +1 @@
1
- {"version":3,"file":"perspective.js","sourceRoot":"","sources":["../src/perspective.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAiB,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,YAAY,MAAM,aAAa,CAAC;AAgD5C,MAAe,eAAe;IAGtB,gBAAgB,CAAC,GAAa;QACpC,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACtD,OAAO,KAAK,CAAC;QACd,CAAC;QAED,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC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;QACzH,sHAAsH;QACtH,iCAAiC;QACjC,IAAI,sBAAsB,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAClE,OAAO,KAAK,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED,SAAS,sBAAsB,CAAC,KAAqB;IACpD,MAAM,EAAE,IAAI,EAAE,GAAG,KAAwC,CAAC;IAC1D,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,aAAa,CAAC;AACvD,CAAC;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,gBAAgB,CAC7D,MAAM,CAAC,gBAAgB,EACvB,eAAe,CACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { NonCollabClient } from \"./constants.js\";\nimport { seqLTE, type ISegment } from \"./mergeTreeNodes.js\";\nimport { isInserted, isRemoved } from \"./segmentInfos.js\";\nimport * as opstampUtils from \"./stamps.js\";\nimport type { OperationStamp, RemoveOperationStamp } from \"./stamps.js\";\n\n/**\n * A perspective which includes some subset of operations known to the local client.\n *\n * This helps the local client reason about the state of other clients when they issued an operation.\n * @internal\n */\nexport interface Perspective {\n\t/**\n\t * The sequence number last seen from this perspective. Same concept as `ISequencedDocumentMessage.referenceSequenceNumber`.\n\t * @privateRemarks\n\t * This currently allows inter-operation between MergeTree methods and the partial lengths implementation, which still depends\n\t * on the (refSeq, clientId, localSeq?) representation of perspectives.\n\t */\n\treadonly refSeq: number;\n\n\t/**\n\t * The client id for this perspective.\n\t * @privateRemarks\n\t * This currently allows inter-operation between MergeTree methods and the partial lengths implementation, which still depends\n\t * on the (refSeq, clientId, localSeq?) representation of perspectives.\n\t */\n\treadonly clientId: number;\n\n\t/**\n\t * When this is a local perspective, the local sequence number last seen from this perspective.\n\t *\n\t * Perspectives with defined `localSeq` values are useful in reconnection flows, where the local client may need to resend some\n\t * of its ops after rederiving their new equivalents.\n\t * @privateRemarks\n\t * This currently allows inter-operation between MergeTree methods and the partial lengths implementation, which still depends\n\t * on the (refSeq, clientId, localSeq?) representation of perspectives.\n\t */\n\treadonly localSeq?: number;\n\n\t/**\n\t * @returns Whether the segment is present (visible) from this perspective\n\t */\n\tisSegmentPresent(segment: ISegment): boolean;\n\n\t/**\n\t * @returns Whether this perspective has seen the given operation.\n\t */\n\thasOccurred(stamp: OperationStamp): boolean;\n}\n\nabstract class PerspectiveBase {\n\tabstract hasOccurred(stamp: OperationStamp): boolean;\n\n\tpublic isSegmentPresent(seg: ISegment): boolean {\n\t\tif (isInserted(seg) && !this.hasOccurred(seg.insert)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (isRemoved(seg) && seg.removes.some((remove) => this.hasOccurred(remove))) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n}\n\n/**\n * A perspective which includes edits at or before some reference sequence number alongside all edits from some particular client.\n *\n * @remarks\n * This works for both the local client as well as remote clients since refSeq-based checks disallow unacked edits, but the clientId check\n * catches unacked edits from the local client.\n */\nexport class PriorPerspective extends PerspectiveBase implements Perspective {\n\tpublic constructor(\n\t\tpublic readonly refSeq: number,\n\t\tpublic readonly clientId: number,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic hasOccurred(stamp: OperationStamp): boolean {\n\t\tconst predatesViaRefSeq = seqLTE(stamp.seq, this.refSeq);\n\t\tconst predatesViaSameClient = stamp.clientId === this.clientId;\n\t\treturn predatesViaRefSeq || predatesViaSameClient;\n\t}\n}\n\n/**\n * A perspective which includes edits which were either:\n * - acked and at or before some reference sequence number\n * - unacked, but at or before some local sequence number\n *\n * This is a useful perspective when the local client is in the process of reconnecting, since it must\n * rederive positions for unacked ops while only considering a portion of its own edits as having been applied.\n */\nexport class LocalReconnectingPerspective extends PerspectiveBase implements Perspective {\n\tpublic constructor(\n\t\tpublic readonly refSeq: number,\n\t\tpublic readonly clientId: number,\n\t\tpublic readonly localSeq: number,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic hasOccurred(stamp: OperationStamp): boolean {\n\t\tconst predatesViaRefSeq = seqLTE(stamp.seq, this.refSeq);\n\t\tconst predatesViaLocalSeq =\n\t\t\tstamp.localSeq !== undefined && stamp.localSeq <= this.localSeq;\n\t\treturn predatesViaRefSeq || predatesViaLocalSeq;\n\t}\n}\n\n/**\n * This perspective is used when rebasing obliterate endpoints to find the segment to slide to when squash is enabled.\n *\n * TODO:AB#39357: This class would not be necessary if obliterate rebasing occurred as resubmit was called rather than\n * precomputed before segment normalization. It also adds more dependencies on all ops being resubmitted (the squash\n * parameter coming from rebasing an obliterate does not necessarily align with an inserted segment), which is not\n * fully correct.\n */\nexport class LocalSquashPerspective extends LocalReconnectingPerspective {\n\tpublic constructor(\n\t\treadonly refSeq: number,\n\t\treadonly clientId: number,\n\t\treadonly localSeq: number,\n\t) {\n\t\tsuper(refSeq, clientId, localSeq);\n\t}\n\n\tpublic override isSegmentPresent(seg: ISegment): boolean {\n\t\t// Avoid sliding to segments whose insertion will be squashed.\n\t\tif (isInserted(seg) && opstampUtils.isLocal(seg.insert) && isRemoved(seg)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn super.isSegmentPresent(seg);\n\t}\n}\n\n/**\n * A perspective which includes edits which were either:\n * - acked and at or before some reference sequence number\n * - unacked, but at or before some local sequence number\n *\n * @internal\n */\nexport function createLocalReconnectingPerspective(\n\trefSeq: number,\n\tclientId: number,\n\tlocalSeq: number,\n\tsquash: boolean = false,\n): Perspective {\n\treturn new (squash ? LocalSquashPerspective : LocalReconnectingPerspective)(\n\t\trefSeq,\n\t\tclientId,\n\t\tlocalSeq,\n\t);\n}\n\n/**\n * A perspective which includes all known edits.\n *\n * This is the perspective that the application sees.\n * @remarks\n * This can be represented using {@link PriorPerspective} with a refSeq of `Number.MAX_SAFE_INTEGER`, but having an explicit\n * variant of this perspective renders extra refSeq checks unnecessary and is a bit easier to read.\n */\nexport class LocalDefaultPerspective extends PerspectiveBase implements Perspective {\n\tpublic readonly refSeq = Number.MAX_SAFE_INTEGER;\n\n\tpublic constructor(public readonly clientId: number) {\n\t\tsuper();\n\t}\n\n\tpublic hasOccurred(_stamp: OperationStamp): boolean {\n\t\treturn true;\n\t}\n}\n\n/**\n * A perspective dictating whether segments are 'visible' to a remote obliterate operation.\n *\n * NOTE: Beware that partial lengths doesn't support this perspective, in the sense that consulting partial lengths' for the length of a block\n * can give different results than summing the lengths of present segments in that block.\n * This ends up not affecting the current obliterate implementation (which has some special casing in the mapRange calls it uses),\n * but use with caution.\n */\nexport class RemoteObliteratePerspective extends PerspectiveBase implements Perspective {\n\tpublic readonly refSeq = Number.MAX_SAFE_INTEGER;\n\n\tconstructor(public readonly clientId: number) {\n\t\tsuper();\n\t}\n\n\tpublic hasOccurred(stamp: OperationStamp): boolean {\n\t\t// Local-only removals are not visible to an obliterate operation, since this means the local removal was concurrent\n\t\t// to a remote obliterate and we may need to mark the segment appropriately to reflect this overlapping remove.\n\t\t// Every other type of operation is visible: obliterates do not affect segments that have already been removed and acked,\n\t\t// and they always affect segments within their range that have not been removed, even if those segments were inserted\n\t\t// after the obliterate's refSeq.\n\t\tif (isRemoveOperationStamp(stamp) && opstampUtils.isLocal(stamp)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n}\n\nfunction isRemoveOperationStamp(stamp: OperationStamp): stamp is RemoveOperationStamp {\n\tconst { type } = stamp as unknown as RemoveOperationStamp;\n\treturn type === \"setRemove\" || type === \"sliceRemove\";\n}\n\nexport const allAckedChangesPerspective = new PriorPerspective(\n\tNumber.MAX_SAFE_INTEGER,\n\tNonCollabClient,\n);\n"]}
1
+ {"version":3,"file":"perspective.js","sourceRoot":"","sources":["../src/perspective.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAiB,MAAM,qBAAqB,CAAC;AAC5D,OA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jD,YAAmC,QAAgB;QAClD,KAAK,EAAE,CAAC;QAD0B,aAAQ,GAAR,QAAQ,CAAQ;IAEnD,CAAC;IAEM,WAAW,CAAC,MAAsB;QACxC,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,2BAA4B,SAAQ,eAAe;IAGnC;IAFZ,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAEjD,YAA4B,QAAgB;QAC3C,KAAK,EAAE,CAAC;QADmB,aAAQ,GAAR,QAAQ,CAAQ;IAE5C,CAAC;IAEM,WAAW,CAAC,KAAqB;QACvC,oHAAoH;QACpH,+GAA+G;QAC/G,yHAAyH;QACzH,sHAAsH;QACtH,iCAAiC;QACjC,IAAI,sBAAsB,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAClE,OAAO,KAAK,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED,SAAS,sBAAsB,CAAC,KAAqB;IACpD,MAAM,EAAE,IAAI,EAAE,GAAG,KAAwC,CAAC;IAC1D,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,aAAa,CAAC;AACvD,CAAC;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,gBAAgB,CAC7D,MAAM,CAAC,gBAAgB,EACvB,eAAe,CACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { NonCollabClient } from \"./constants.js\";\nimport { seqLTE, type ISegment } from \"./mergeTreeNodes.js\";\nimport { isInserted, isRemoved } from \"./segmentInfos.js\";\nimport * as opstampUtils from \"./stamps.js\";\nimport type { OperationStamp, RemoveOperationStamp } from \"./stamps.js\";\n\n/**\n * A perspective which includes some subset of operations known to the local client.\n *\n * This helps the local client reason about the state of other clients when they issued an operation.\n * @internal\n */\nexport interface Perspective {\n\t/**\n\t * The sequence number last seen from this perspective. Same concept as `ISequencedDocumentMessage.referenceSequenceNumber`.\n\t * @privateRemarks\n\t * This currently allows inter-operation between MergeTree methods and the partial lengths implementation, which still depends\n\t * on the (refSeq, clientId, localSeq?) representation of perspectives.\n\t */\n\treadonly refSeq: number;\n\n\t/**\n\t * The client id for this perspective.\n\t * @privateRemarks\n\t * This currently allows inter-operation between MergeTree methods and the partial lengths implementation, which still depends\n\t * on the (refSeq, clientId, localSeq?) representation of perspectives.\n\t */\n\treadonly clientId: number;\n\n\t/**\n\t * When this is a local perspective, the local sequence number last seen from this perspective.\n\t *\n\t * Perspectives with defined `localSeq` values are useful in reconnection flows, where the local client may need to resend some\n\t * of its ops after rederiving their new equivalents.\n\t * @privateRemarks\n\t * This currently allows inter-operation between MergeTree methods and the partial lengths implementation, which still depends\n\t * on the (refSeq, clientId, localSeq?) representation of perspectives.\n\t */\n\treadonly localSeq?: number;\n\n\t/**\n\t * @returns Whether the segment is present (visible) from this perspective\n\t */\n\tisSegmentPresent(segment: ISegment): boolean;\n\n\t/**\n\t * @returns Whether this perspective has seen the given operation.\n\t */\n\thasOccurred(stamp: OperationStamp): boolean;\n}\n\nabstract class PerspectiveBase {\n\tabstract hasOccurred(stamp: OperationStamp): boolean;\n\n\tpublic isSegmentPresent(seg: ISegment): boolean {\n\t\tif (isInserted(seg) && !this.hasOccurred(seg.insert)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (isRemoved(seg) && seg.removes.some((remove) => this.hasOccurred(remove))) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n}\n\n/**\n * A perspective which includes edits at or before some reference sequence number alongside all edits from some particular client.\n *\n * @remarks\n * This works for both the local client as well as remote clients since refSeq-based checks disallow unacked edits, but the clientId check\n * catches unacked edits from the local client.\n */\nexport class PriorPerspective extends PerspectiveBase implements Perspective {\n\tpublic constructor(\n\t\tpublic readonly refSeq: number,\n\t\tpublic readonly clientId: number,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic hasOccurred(stamp: OperationStamp): boolean {\n\t\tconst predatesViaRefSeq = seqLTE(stamp.seq, this.refSeq);\n\t\tconst predatesViaSameClient = stamp.clientId === this.clientId;\n\t\treturn predatesViaRefSeq || predatesViaSameClient;\n\t}\n}\n\n/**\n * A perspective which includes edits which were either:\n * - acked and at or before some reference sequence number\n * - unacked, but at or before some local sequence number\n *\n * This is a useful perspective when the local client is in the process of reconnecting, since it must\n * rederive positions for unacked ops while only considering a portion of its own edits as having been applied.\n */\nexport class LocalReconnectingPerspective extends PerspectiveBase implements Perspective {\n\tpublic constructor(\n\t\tpublic readonly refSeq: number,\n\t\tpublic readonly clientId: number,\n\t\tpublic readonly localSeq: number,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic hasOccurred(stamp: OperationStamp): boolean {\n\t\tconst predatesViaRefSeq = seqLTE(stamp.seq, this.refSeq);\n\t\tconst predatesViaLocalSeq =\n\t\t\tstamp.localSeq !== undefined && stamp.localSeq <= this.localSeq;\n\t\treturn predatesViaRefSeq || predatesViaLocalSeq;\n\t}\n}\n\n/**\n * This perspective is used when rebasing obliterate endpoints to find the segment to slide to when squash is enabled.\n *\n * TODO:AB#39357: This class would not be necessary if obliterate rebasing occurred as resubmit was called rather than\n * precomputed before segment normalization. It also adds more dependencies on all ops being resubmitted (the squash\n * parameter coming from rebasing an obliterate does not necessarily align with an inserted segment), which is not\n * fully correct.\n */\nexport class LocalSquashPerspective extends LocalReconnectingPerspective {\n\tpublic constructor(\n\t\treadonly refSeq: number,\n\t\treadonly clientId: number,\n\t\treadonly localSeq: number,\n\t) {\n\t\tsuper(refSeq, clientId, localSeq);\n\t}\n\n\tpublic override isSegmentPresent(seg: ISegment): boolean {\n\t\t// Avoid sliding to segments whose insertion will be squashed.\n\t\tif (isInserted(seg) && opstampUtils.isLocal(seg.insert) && isRemoved(seg)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn super.isSegmentPresent(seg);\n\t}\n}\n\n/**\n * A perspective which includes edits which were either:\n * - acked and at or before some reference sequence number\n * - unacked, but at or before some local sequence number\n *\n * @internal\n */\nexport function createLocalReconnectingPerspective(\n\trefSeq: number,\n\tclientId: number,\n\tlocalSeq: number,\n\tsquash: boolean = false,\n): Perspective {\n\treturn new (squash ? LocalSquashPerspective : LocalReconnectingPerspective)(\n\t\trefSeq,\n\t\tclientId,\n\t\tlocalSeq,\n\t);\n}\n\n/**\n * A perspective which includes all known edits.\n *\n * This is the perspective that the application sees.\n * @remarks\n * This can be represented using {@link PriorPerspective} with a refSeq of `Number.MAX_SAFE_INTEGER`, but having an explicit\n * variant of this perspective renders extra refSeq checks unnecessary and is a bit easier to read.\n */\nexport class LocalDefaultPerspective extends PerspectiveBase implements Perspective {\n\tpublic readonly refSeq = Number.MAX_SAFE_INTEGER;\n\n\tpublic constructor(public readonly clientId: number) {\n\t\tsuper();\n\t}\n\n\tpublic hasOccurred(_stamp: OperationStamp): boolean {\n\t\treturn true;\n\t}\n}\n\n/**\n * A perspective dictating whether segments are 'visible' to a remote obliterate operation.\n *\n * NOTE: Beware that partial lengths doesn't support this perspective, in the sense that consulting partial lengths' for the length of a block\n * can give different results than summing the lengths of present segments in that block.\n * This ends up not affecting the current obliterate implementation (which has some special casing in the mapRange calls it uses),\n * but use with caution.\n */\nexport class RemoteObliteratePerspective extends PerspectiveBase implements Perspective {\n\tpublic readonly refSeq = Number.MAX_SAFE_INTEGER;\n\n\tconstructor(public readonly clientId: number) {\n\t\tsuper();\n\t}\n\n\tpublic hasOccurred(stamp: OperationStamp): boolean {\n\t\t// Local-only removals are not visible to an obliterate operation, since this means the local removal was concurrent\n\t\t// to a remote obliterate and we may need to mark the segment appropriately to reflect this overlapping remove.\n\t\t// Every other type of operation is visible: obliterates do not affect segments that have already been removed and acked,\n\t\t// and they always affect segments within their range that have not been removed, even if those segments were inserted\n\t\t// after the obliterate's refSeq.\n\t\tif (isRemoveOperationStamp(stamp) && opstampUtils.isLocal(stamp)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n}\n\nfunction isRemoveOperationStamp(stamp: OperationStamp): stamp is RemoveOperationStamp {\n\tconst { type } = stamp as unknown as RemoveOperationStamp;\n\treturn type === \"setRemove\" || type === \"sliceRemove\";\n}\n\nexport const allAckedChangesPerspective = new PriorPerspective(\n\tNumber.MAX_SAFE_INTEGER,\n\tNonCollabClient,\n);\n"]}
package/lib/public.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat" in @fluid-tools/build-cli.
8
+ * Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export {}
@@ -1 +1 @@
1
- {"version":3,"file":"referencePositions.d.ts","sourceRoot":"","sources":["../src/referencePositions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGnD;;GAEG;AACH,eAAO,MAAM,qBAAqB,wBAAwB,CAAC;AAC3D;;GAEG;AACH,eAAO,MAAM,sBAAsB,yBAAyB,CAAC;AAE7D;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,YAAY,EAAE,iBAAiB,GAAG,aAAa,EAC/C,KAAK,EAAE,aAAa,GAClB,OAAO,CAIT;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,WAAY,iBAAiB,KAAG,MAAM,EAAE,GAAG,SAG3D,CAAC;AAEd;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,iBAAiB,EAAE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8 @@
4
4
  */
5
5
  import { DoublyLinkedList, walkList } from "@fluidframework/core-utils/internal";
6
6
  export class SegmentGroupCollection {
7
+ segment;
8
+ segmentGroups;
7
9
  constructor(segment) {
8
10
  this.segment = segment;
9
11
  this.segmentGroups = new DoublyLinkedList();
@@ -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,qCAAqC,CAAC;AAIjF,MAAM,OAAO,sBAAsB;IAGlC,YAA6B,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;QACjD,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;IAEM,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;IAEM,OAAO;QACb,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC;IACzC,CAAC;IAEM,MAAM,CAAC,YAA0B;QACvC,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;IAEM,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,aAAqC;QAClD,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,aAAa,CAAC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1F,CAAC;IAEO,aAAa,CAAC,YAA0B,EAAE,aAA2B;QAC5E,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,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;YACpE,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 \"@fluidframework/core-utils/internal\";\n\nimport type { SegmentGroup, ISegmentLeaf } from \"./mergeTreeNodes.js\";\n\nexport class SegmentGroupCollection {\n\tprivate readonly segmentGroups: DoublyLinkedList<SegmentGroup>;\n\n\tconstructor(private readonly segment: ISegmentLeaf) {\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\tpublic enqueue(segmentGroup: SegmentGroup): void {\n\t\tthis.segmentGroups.push(segmentGroup);\n\t\tsegmentGroup.segments.push(this.segment);\n\t}\n\n\tpublic dequeue(): SegmentGroup | undefined {\n\t\treturn this.segmentGroups.shift()?.data;\n\t}\n\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\tpublic pop(): SegmentGroup | undefined {\n\t\treturn this.segmentGroups.pop ? this.segmentGroups.pop()?.data : undefined;\n\t}\n\n\tpublic copyTo(segmentGroups: SegmentGroupCollection): void {\n\t\twalkList(this.segmentGroups, (sg) => segmentGroups.enqueueOnCopy(sg.data, this.segment));\n\t}\n\n\tprivate enqueueOnCopy(segmentGroup: SegmentGroup, sourceSegment: ISegmentLeaf): 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\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,qCAAqC,CAAC;AAIjF,MAAM,OAAO,sBAAsB;IAGL;IAFZ,aAAa,CAAiC;IAE/D,YAA6B,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;QACjD,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,C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C,CAAC,EAAE,CAAC;gBAClB,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;YACpE,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 \"@fluidframework/core-utils/internal\";\n\nimport type { SegmentGroup, ISegmentLeaf } from \"./mergeTreeNodes.js\";\n\nexport class SegmentGroupCollection {\n\tprivate readonly segmentGroups: DoublyLinkedList<SegmentGroup>;\n\n\tconstructor(private readonly segment: ISegmentLeaf) {\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\tpublic enqueue(segmentGroup: SegmentGroup): void {\n\t\tthis.segmentGroups.push(segmentGroup);\n\t\tsegmentGroup.segments.push(this.segment);\n\t}\n\n\tpublic dequeue(): SegmentGroup | undefined {\n\t\treturn this.segmentGroups.shift()?.data;\n\t}\n\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\tpublic pop(): SegmentGroup | undefined {\n\t\treturn this.segmentGroups.pop ? this.segmentGroups.pop()?.data : undefined;\n\t}\n\n\tpublic copyTo(segmentGroups: SegmentGroupCollection): void {\n\t\twalkList(this.segmentGroups, (sg) => segmentGroups.enqueueOnCopy(sg.data, this.segment));\n\t}\n\n\tprivate enqueueOnCopy(segmentGroup: SegmentGroup, sourceSegment: ISegmentLeaf): 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\tsegmentGroup.previousProps.push(segmentGroup.previousProps[index]);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"segmentInfos.d.ts","sourceRoot":"","sources":["../src/segmentInfos.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,UAAU,EACV,KAAK,cAAc,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE9F,MAAM,WAAW,YAAY;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAC1C,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,CAAC,GACL,KAAK,IAAI,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAE7B;AAED,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,YAAY,EACrE,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,CAAC,GACL,KAAK,IAAI,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,OAAO,IAAI,CAAC,CAAC,CAK/C;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EACjD,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAC7B,KAAK,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,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ACrB,CAAC,SAAS,eAAe,GAAG,eAAe,IACxC,CAAC,GAAG,CAAC,CAAC;AAEV;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GACzB,CAAC,SAAS,WAAW,EACrB,CAAC,SAAS,eAAe,GAAG,eAAe,EAE3C,aAAa,CAAC,EACd,MAAM,CAAC,KACL,eAAe,CAAC,CAAC,EAAE,CAAC,CAAqC,CAAC"}
@@ -73,9 +73,7 @@ function applyChanges(op, seg, seq, run) {
73
73
  * @internal
74
74
  */
75
75
  export class PropertiesManager {
76
- constructor() {
77
- this.changes = new Map();
78
- }
76
+ changes = new Map();
79
77
  /**
80
78
  * Rolls back local property changes.
81
79
  * This method reverts property changes based on the provided operation and segment.
@@ -1 +1 @@
1
- {"version":3,"file":"segmentPropertiesManager.js","sourceRoot":"","sources":["../src/segmentPropertiesManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,MAAM,EACN,gBAAgB,EAChB,sBAAsB,GACtB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAMnF,OAAO,EAAkC,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEnF;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACvC,MAGC,EACD,WAGC;IAED,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACvB,IAAI,MAAM,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YAC1C,WAAW,CAAC,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACP,WAAW,CAAC,eAAe,KAAK,IAAI,iBAAiB,EAAE,CAAC;YACxD,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAC/D,CAAC;IACF,CAAC;AACF,CAAC;AAYD,SAAS,oBAAoB,CAC5B,SAAkB,EA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ACd,CAAC;QACF,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tassert,\n\tDoublyLinkedList,\n\titerateListValuesWhile,\n} from \"@fluidframework/core-utils/internal\";\n\nimport { UnassignedSequenceNumber, UniversalSequenceNumber } from \"./constants.js\";\nimport type {\n\tAdjustParams,\n\tIMergeTreeAnnotateAdjustMsg,\n\tIMergeTreeAnnotateMsg,\n} from \"./ops.js\";\nimport { type MapLike, type PropertySet, clone, createMap } from \"./properties.js\";\n\n/**\n * Minimally copies properties and the property manager from source to destination.\n * @internal\n */\nexport function copyPropertiesAndManager(\n\tsource: {\n\t\tproperties?: PropertySet;\n\t\tpropertyManager?: PropertiesManager;\n\t},\n\tdestination: {\n\t\tproperties?: PropertySet;\n\t\tpropertyManager?: PropertiesManager;\n\t},\n): void {\n\tif (source.properties) {\n\t\tif (source.propertyManager === undefined) {\n\t\t\tdestination.properties = clone(source.properties);\n\t\t} else {\n\t\t\tdestination.propertyManager ??= new PropertiesManager();\n\t\t\tsource.propertyManager.copyTo(source.properties, destination);\n\t\t}\n\t}\n}\n\ntype PropertyChange = {\n\tseq: number;\n} & ({ adjust: AdjustParams; raw?: undefined } | { raw: unknown; adjust?: undefined });\n\ninterface PropertyChanges {\n\tmsnConsensus: unknown;\n\tremote: DoublyLinkedList<PropertyChange>;\n\tlocal: DoublyLinkedList<PropertyChange>;\n}\n\nfunction computePropertyValue(\n\tconsensus: unknown,\n\t...changes: Iterable<PropertyChange>[]\n): unknown {\n\tlet computedValue: unknown = consensus;\n\tfor (const change of changes) {\n\t\tfor (const op of change) {\n\t\t\tconst { raw, adjust } = op;\n\t\t\tif (adjust === undefined) {\n\t\t\t\tcomputedValue = raw;\n\t\t\t} else {\n\t\t\t\tconst adjusted =\n\t\t\t\t\t(typeof computedValue === \"number\" ? computedValue : 0) + adjust.delta;\n\t\t\t\tif (adjust.max !== undefined && adjusted > adjust.max) {\n\t\t\t\t\tcomputedValue = adjust.max;\n\t\t\t\t} else if (adjust.min !== undefined && adjusted < adjust.min) {\n\t\t\t\t\tcomputedValue = adjust.min;\n\t\t\t\t} else {\n\t\t\t\t\tcomputedValue = adjusted;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn computedValue;\n}\n\n/**\n * @internal\n */\nexport type PropsOrAdjust =\n\t| Pick<IMergeTreeAnnotateAdjustMsg, \"props\" | \"adjust\">\n\t| Pick<IMergeTreeAnnotateMsg, \"props\" | \"adjust\">;\n\nconst opToChanges = (op: PropsOrAdjust, seq: number): [string, PropertyChange][] => [\n\t...Object.entries(op.props ?? {})\n\t\t.map<[string, PropertyChange]>(([k, raw]) => [k, { raw, seq }])\n\t\t.filter(([_, v]) => v.raw !== undefined),\n\t...Object.entries(op.adjust ?? {}).map<[string, PropertyChange]>(([k, adjust]) => [\n\t\tk,\n\t\t{ adjust, seq },\n\t]),\n];\n\nfunction applyChanges(\n\top: PropsOrAdjust,\n\tseg: { properties?: MapLike<unknown> },\n\tseq: number,\n\trun: (\n\t\tproperties: MapLike<unknown>,\n\t\tdeltas: MapLike<unknown>,\n\t\tkey: string,\n\t\tvalue: PropertyChange,\n\t) => void,\n): MapLike<unknown> {\n\tconst properties = (seg.properties ??= createMap<unknown>());\n\tconst deltas: MapLike<unknown> = {};\n\tfor (const [key, value] of opToChanges(op, seq)) {\n\t\trun(properties, deltas, key, value);\n\t\tif (properties[key] === null) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\tdelete properties[key];\n\t\t}\n\t}\n\treturn deltas;\n}\n\n/**\n * The PropertiesManager class handles changes to properties, both remote and local.\n * It manages the lifecycle for local property changes, ensures all property changes are eventually consistent,\n * and provides methods to acknowledge changes, update the minimum sequence number (msn), and copy properties to another manager.\n * This class is essential for maintaining the integrity and consistency of property changes in collaborative environments.\n * @internal\n */\nexport class PropertiesManager {\n\tprivate readonly changes = new Map<string, PropertyChanges>();\n\n\t/**\n\t * Rolls back local property changes.\n\t * This method reverts property changes based on the provided operation and segment.\n\t * If the operation is part of a collaborative session, it ensures that the changes are consistent with the remote state.\n\t *\n\t * @param op - The operation containing property changes. This can be an adjustment or a set of properties.\n\t * @param seg - The segment containing properties. This object may have a properties map that will be modified.\n\t * @param collaborating - Indicates if the operation is part of a collaborative session. Defaults to false.\n\t * @returns The deltas of the rolled-back properties. This is a map-like object representing the changes that were reverted.\n\t */\n\tpublic rollbackProperties(\n\t\top: PropsOrAdjust,\n\t\tseg: { properties?: MapLike<unknown> },\n\t\tcollaborating: boolean = false,\n\t): MapLike<unknown> {\n\t\treturn applyChanges(op, seg, UniversalSequenceNumber, (properties, deltas, key, value) => {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tconst previousValue = properties[key] ?? null;\n\n\t\t\tconst pending = this.changes.get(key);\n\t\t\tif (collaborating) {\n\t\t\t\tassert(\n\t\t\t\t\tpending !== undefined,\n\t\t\t\t\t0xa6f /* Pending changes must exist for rollback when collaborating */,\n\t\t\t\t);\n\t\t\t\tpending.local.pop();\n\t\t\t\tproperties[key] = computePropertyValue(\n\t\t\t\t\tpending.msnConsensus,\n\t\t\t\t\tpending.remote.map((n) => n.data),\n\t\t\t\t\tpending.local.map((n) => n.data),\n\t\t\t\t);\n\t\t\t\tif (pending.local.empty && pending.remote.empty) {\n\t\t\t\t\tthis.changes.delete(key);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tassert(\n\t\t\t\t\tpending === undefined,\n\t\t\t\t\t0xa70 /* Pending changes must not exist when not collaborating */,\n\t\t\t\t);\n\t\t\t\tproperties[key] = computePropertyValue(previousValue, [value]);\n\t\t\t}\n\t\t\tdeltas[key] = previousValue;\n\t\t});\n\t}\n\n\t/**\n\t * Handles property changes.\n\t * This method applies property changes based on the provided operation, segment, sequence number, and collaboration state.\n\t * It also handles rolling back changes if specified.\n\t *\n\t * @param op - The operation containing property changes.\n\t * @param seg - The segment containing properties.\n\t * @param seq - The sequence number for the operation.\n\t * @param msn - The minimum sequence number for the operation.\n\t * @param collaborating - Indicates if the operation is part of a collaborative session. Defaults to false.\n\t * @param rollback - Specifies if the changes should be rolled back. Defaults to PropertiesRollback.None.\n\t * @returns The deltas of the applied or rolled-back properties. This is a map-like object representing the changes.\n\t */\n\tpublic handleProperties(\n\t\top: PropsOrAdjust,\n\t\tseg: { properties?: MapLike<unknown> },\n\t\tseq: number,\n\t\tmsn: number,\n\t\tcollaborating: boolean = false,\n\t\trollback: boolean = false,\n\t): MapLike<unknown> {\n\t\tif (rollback) {\n\t\t\treturn this.rollbackProperties(op, seg, collaborating);\n\t\t}\n\t\tconst rtn = applyChanges(op, seg, seq, (properties, deltas, key, value) => {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tconst previousValue = properties[key] ?? null;\n\t\t\tif (collaborating) {\n\t\t\t\tconst pending: PropertyChanges | undefined = this.changes.get(key) ?? {\n\t\t\t\t\tmsnConsensus: previousValue,\n\t\t\t\t\tremote: new DoublyLinkedList(),\n\t\t\t\t\tlocal: new DoublyLinkedList(),\n\t\t\t\t};\n\t\t\t\tthis.changes.set(key, pending);\n\t\t\t\tconst local = seq === UnassignedSequenceNumber;\n\t\t\t\tif (local) {\n\t\t\t\t\tpending.local.push(value);\n\t\t\t\t} else {\n\t\t\t\t\t// we only track remotes if there are adjusts, as only adjusts make application anti-commutative\n\t\t\t\t\t// this will limit the impact of this change to only those using adjusts. Additionally, we only\n\t\t\t\t\t// need to track remotes at all to support emitting the legacy snapshot format, which only sharedstring\n\t\t\t\t\t// uses. when we remove the ability to emit that format, we can remove all remote op tracking\n\t\t\t\t\tif (value.raw !== undefined && pending.remote.empty) {\n\t\t\t\t\t\tpending.msnConsensus = computePropertyValue(pending.msnConsensus, [value]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpending.remote.push(value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tproperties[key] = computePropertyValue(\n\t\t\t\t\tpending.msnConsensus,\n\t\t\t\t\tpending.remote.map((n) => n.data),\n\t\t\t\t\tpending.local.map((n) => n.data),\n\t\t\t\t);\n\t\t\t\tif (local || pending.local.empty || properties[key] !== previousValue) {\n\t\t\t\t\tdeltas[key] = previousValue;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tproperties[key] = computePropertyValue(previousValue, [value]);\n\t\t\t\tdeltas[key] = previousValue;\n\t\t\t}\n\t\t});\n\t\tthis.updateMsn(msn);\n\t\treturn rtn;\n\t}\n\n\t/**\n\t * Acknowledges property changes.\n\t * This method acknowledges the property changes based on the provided sequence number and operation.\n\t *\n\t * @param seq - The sequence number for the operation.\n\t * @param msn - The minimum sequence number for the operation.\n\t * @param op - The operation containing property changes.\n\t */\n\tpublic ack(seq: number, msn: number, op: PropsOrAdjust): void {\n\t\tfor (const [key, value] of opToChanges(op, seq)) {\n\t\t\tconst change = this.changes.get(key);\n\t\t\tconst acked = change?.local?.shift();\n\t\t\tassert(\n\t\t\t\tchange !== undefined && acked !== undefined,\n\t\t\t\t0xa71 /* must have local change to ack */,\n\t\t\t);\n\t\t\t// we only track remotes if there are adjusts, as only adjusts make application anti-commutative\n\t\t\t// this will limit the impact of this change to only those using adjusts. Additionally, we only\n\t\t\t// need to track remotes at all to support emitting the legacy snapshot format, which only sharedstring\n\t\t\t// uses. when we remove the ability to emit that format, we can remove all remote op tracking\n\t\t\tif (value.raw !== undefined && change.remote.empty) {\n\t\t\t\tchange.msnConsensus = computePropertyValue(change.msnConsensus, [value]);\n\t\t\t} else {\n\t\t\t\tchange.remote.push(value);\n\t\t\t}\n\t\t}\n\t\tthis.updateMsn(msn);\n\t}\n\n\t/**\n\t * Updates the minimum sequence number (msn).\n\t * This method updates the minimum sequence number and removes any changes that have been acknowledged.\n\t *\n\t * @param msn - The minimum sequence number to update.\n\t */\n\tpublic updateMsn(msn: number): void {\n\t\tfor (const [key, pending] of this.changes) {\n\t\t\tpending.msnConsensus = computePropertyValue(\n\t\t\t\tpending.msnConsensus,\n\t\t\t\titerateListValuesWhile(pending.remote.first, (n) => {\n\t\t\t\t\tif (n.data.seq <= msn) {\n\t\t\t\t\t\tn.list?.remove(n);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (pending.local.empty && pending.remote.empty) {\n\t\t\t\tthis.changes.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Copies properties to another manager.\n\t * This method copies the properties and their changes from the current manager to the destination manager.\n\t *\n\t * @param oldProps - The old properties to be copied.\n\t * @param dest - The destination object containing properties and property manager.\n\t */\n\tpublic copyTo(\n\t\toldProps: PropertySet | undefined,\n\t\tdest: {\n\t\t\tproperties?: PropertySet;\n\t\t\tpropertyManager?: PropertiesManager;\n\t\t},\n\t): void {\n\t\tconst newManager = (dest.propertyManager ??= new PropertiesManager());\n\t\tdest.properties = clone(oldProps);\n\t\tfor (const [key, { local, remote, msnConsensus }] of this.changes.entries()) {\n\t\t\tnewManager.changes.set(key, {\n\t\t\t\tmsnConsensus,\n\t\t\t\tremote: new DoublyLinkedList(remote.empty ? undefined : remote.map((c) => c.data)),\n\t\t\t\tlocal: new DoublyLinkedList(local.empty ? undefined : local.map((c) => c.data)),\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Gets properties at a specific sequence number.\n\t * This method retrieves the properties at the given sequence number.\n\t * This is only needed to support emitting snapshots in the legacy format.\n\t * If we remove the ability to emit the legacy format, we can remove this method, along with the need to track remote changes at all.\n\t *\n\t * @param oldProps - The old properties to be retrieved.\n\t * @param sequenceNumber - The sequence number to get properties at.\n\t * @returns The properties at the given sequence number.\n\t */\n\tpublic getAtSeq(\n\t\toldProps: MapLike<unknown> | undefined,\n\t\tsequenceNumber: number,\n\t): MapLike<unknown> {\n\t\tconst properties: MapLike<unknown> = { ...oldProps };\n\t\tfor (const [key, changes] of this.changes) {\n\t\t\tproperties[key] = computePropertyValue(\n\t\t\t\tchanges.msnConsensus,\n\t\t\t\titerateListValuesWhile(changes.remote.first, (c) => c.data.seq <= sequenceNumber),\n\t\t\t);\n\t\t\tif (properties[key] === null) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete properties[key];\n\t\t\t}\n\t\t}\n\t\treturn properties;\n\t}\n\n\t/**\n\t * Determines if all of the defined properties in a given property set are pending.\n\t *\n\t * @param props - The properties to check.\n\t * @returns True if all the properties are pending, false otherwise.\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.changes.get(key)?.local.empty !== false) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n}\n"]}
1
+ {"version":3,"file":"segmentPropertiesManager.js","sourceRoot":"","sources":["../src/segmentPropertiesManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,MAAM,EACN,gBAAgB,EAChB,sBAAsB,GACtB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAMnF,OAAO,EAAkC,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEnF;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACvC,MAGC,EACD,WAGC;IAED,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACvB,IAAI,MAAM,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YAC1C,WAAW,CAAC,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACP,WAAW,CAAC,eAAe,KAAK,IAAI,iBAAiB,EAAE,CAAC;YACxD,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAC/D,CAAC;IACF,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CAAC;gBACzE,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tassert,\n\tDoublyLinkedList,\n\titerateListValuesWhile,\n} from \"@fluidframework/core-utils/internal\";\n\nimport { UnassignedSequenceNumber, UniversalSequenceNumber } from \"./constants.js\";\nimport type {\n\tAdjustParams,\n\tIMergeTreeAnnotateAdjustMsg,\n\tIMergeTreeAnnotateMsg,\n} from \"./ops.js\";\nimport { type MapLike, type PropertySet, clone, createMap } from \"./properties.js\";\n\n/**\n * Minimally copies properties and the property manager from source to destination.\n * @internal\n */\nexport function copyPropertiesAndManager(\n\tsource: {\n\t\tproperties?: PropertySet;\n\t\tpropertyManager?: PropertiesManager;\n\t},\n\tdestination: {\n\t\tproperties?: PropertySet;\n\t\tpropertyManager?: PropertiesManager;\n\t},\n): void {\n\tif (source.properties) {\n\t\tif (source.propertyManager === undefined) {\n\t\t\tdestination.properties = clone(source.properties);\n\t\t} else {\n\t\t\tdestination.propertyManager ??= new PropertiesManager();\n\t\t\tsource.propertyManager.copyTo(source.properties, destination);\n\t\t}\n\t}\n}\n\ntype PropertyChange = {\n\tseq: number;\n} & ({ adjust: AdjustParams; raw?: undefined } | { raw: unknown; adjust?: undefined });\n\ninterface PropertyChanges {\n\tmsnConsensus: unknown;\n\tremote: DoublyLinkedList<PropertyChange>;\n\tlocal: DoublyLinkedList<PropertyChange>;\n}\n\nfunction computePropertyValue(\n\tconsensus: unknown,\n\t...changes: Iterable<PropertyChange>[]\n): unknown {\n\tlet computedValue: unknown = consensus;\n\tfor (const change of changes) {\n\t\tfor (const op of change) {\n\t\t\tconst { raw, adjust } = op;\n\t\t\tif (adjust === undefined) {\n\t\t\t\tcomputedValue = raw;\n\t\t\t} else {\n\t\t\t\tconst adjusted =\n\t\t\t\t\t(typeof computedValue === \"number\" ? computedValue : 0) + adjust.delta;\n\t\t\t\tif (adjust.max !== undefined && adjusted > adjust.max) {\n\t\t\t\t\tcomputedValue = adjust.max;\n\t\t\t\t} else if (adjust.min !== undefined && adjusted < adjust.min) {\n\t\t\t\t\tcomputedValue = adjust.min;\n\t\t\t\t} else {\n\t\t\t\t\tcomputedValue = adjusted;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn computedValue;\n}\n\n/**\n * @internal\n */\nexport type PropsOrAdjust =\n\t| Pick<IMergeTreeAnnotateAdjustMsg, \"props\" | \"adjust\">\n\t| Pick<IMergeTreeAnnotateMsg, \"props\" | \"adjust\">;\n\nconst opToChanges = (op: PropsOrAdjust, seq: number): [string, PropertyChange][] => [\n\t...Object.entries(op.props ?? {})\n\t\t.map<[string, PropertyChange]>(([k, raw]) => [k, { raw, seq }])\n\t\t.filter(([_, v]) => v.raw !== undefined),\n\t...Object.entries(op.adjust ?? {}).map<[string, PropertyChange]>(([k, adjust]) => [\n\t\tk,\n\t\t{ adjust, seq },\n\t]),\n];\n\nfunction applyChanges(\n\top: PropsOrAdjust,\n\tseg: { properties?: MapLike<unknown> },\n\tseq: number,\n\trun: (\n\t\tproperties: MapLike<unknown>,\n\t\tdeltas: MapLike<unknown>,\n\t\tkey: string,\n\t\tvalue: PropertyChange,\n\t) => void,\n): MapLike<unknown> {\n\tconst properties = (seg.properties ??= createMap<unknown>());\n\tconst deltas: MapLike<unknown> = {};\n\tfor (const [key, value] of opToChanges(op, seq)) {\n\t\trun(properties, deltas, key, value);\n\t\tif (properties[key] === null) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\tdelete properties[key];\n\t\t}\n\t}\n\treturn deltas;\n}\n\n/**\n * The PropertiesManager class handles changes to properties, both remote and local.\n * It manages the lifecycle for local property changes, ensures all property changes are eventually consistent,\n * and provides methods to acknowledge changes, update the minimum sequence number (msn), and copy properties to another manager.\n * This class is essential for maintaining the integrity and consistency of property changes in collaborative environments.\n * @internal\n */\nexport class PropertiesManager {\n\tprivate readonly changes = new Map<string, PropertyChanges>();\n\n\t/**\n\t * Rolls back local property changes.\n\t * This method reverts property changes based on the provided operation and segment.\n\t * If the operation is part of a collaborative session, it ensures that the changes are consistent with the remote state.\n\t *\n\t * @param op - The operation containing property changes. This can be an adjustment or a set of properties.\n\t * @param seg - The segment containing properties. This object may have a properties map that will be modified.\n\t * @param collaborating - Indicates if the operation is part of a collaborative session. Defaults to false.\n\t * @returns The deltas of the rolled-back properties. This is a map-like object representing the changes that were reverted.\n\t */\n\tpublic rollbackProperties(\n\t\top: PropsOrAdjust,\n\t\tseg: { properties?: MapLike<unknown> },\n\t\tcollaborating: boolean = false,\n\t): MapLike<unknown> {\n\t\treturn applyChanges(op, seg, UniversalSequenceNumber, (properties, deltas, key, value) => {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tconst previousValue = properties[key] ?? null;\n\n\t\t\tconst pending = this.changes.get(key);\n\t\t\tif (collaborating) {\n\t\t\t\tassert(\n\t\t\t\t\tpending !== undefined,\n\t\t\t\t\t0xa6f /* Pending changes must exist for rollback when collaborating */,\n\t\t\t\t);\n\t\t\t\tpending.local.pop();\n\t\t\t\tproperties[key] = computePropertyValue(\n\t\t\t\t\tpending.msnConsensus,\n\t\t\t\t\tpending.remote.map((n) => n.data),\n\t\t\t\t\tpending.local.map((n) => n.data),\n\t\t\t\t);\n\t\t\t\tif (pending.local.empty && pending.remote.empty) {\n\t\t\t\t\tthis.changes.delete(key);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tassert(\n\t\t\t\t\tpending === undefined,\n\t\t\t\t\t0xa70 /* Pending changes must not exist when not collaborating */,\n\t\t\t\t);\n\t\t\t\tproperties[key] = computePropertyValue(previousValue, [value]);\n\t\t\t}\n\t\t\tdeltas[key] = previousValue;\n\t\t});\n\t}\n\n\t/**\n\t * Handles property changes.\n\t * This method applies property changes based on the provided operation, segment, sequence number, and collaboration state.\n\t * It also handles rolling back changes if specified.\n\t *\n\t * @param op - The operation containing property changes.\n\t * @param seg - The segment containing properties.\n\t * @param seq - The sequence number for the operation.\n\t * @param msn - The minimum sequence number for the operation.\n\t * @param collaborating - Indicates if the operation is part of a collaborative session. Defaults to false.\n\t * @param rollback - Specifies if the changes should be rolled back. Defaults to PropertiesRollback.None.\n\t * @returns The deltas of the applied or rolled-back properties. This is a map-like object representing the changes.\n\t */\n\tpublic handleProperties(\n\t\top: PropsOrAdjust,\n\t\tseg: { properties?: MapLike<unknown> },\n\t\tseq: number,\n\t\tmsn: number,\n\t\tcollaborating: boolean = false,\n\t\trollback: boolean = false,\n\t): MapLike<unknown> {\n\t\tif (rollback) {\n\t\t\treturn this.rollbackProperties(op, seg, collaborating);\n\t\t}\n\t\tconst rtn = applyChanges(op, seg, seq, (properties, deltas, key, value) => {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tconst previousValue = properties[key] ?? null;\n\t\t\tif (collaborating) {\n\t\t\t\tconst pending: PropertyChanges | undefined = this.changes.get(key) ?? {\n\t\t\t\t\tmsnConsensus: previousValue,\n\t\t\t\t\tremote: new DoublyLinkedList(),\n\t\t\t\t\tlocal: new DoublyLinkedList(),\n\t\t\t\t};\n\t\t\t\tthis.changes.set(key, pending);\n\t\t\t\tconst local = seq === UnassignedSequenceNumber;\n\t\t\t\tif (local) {\n\t\t\t\t\tpending.local.push(value);\n\t\t\t\t} else {\n\t\t\t\t\t// we only track remotes if there are adjusts, as only adjusts make application anti-commutative\n\t\t\t\t\t// this will limit the impact of this change to only those using adjusts. Additionally, we only\n\t\t\t\t\t// need to track remotes at all to support emitting the legacy snapshot format, which only sharedstring\n\t\t\t\t\t// uses. when we remove the ability to emit that format, we can remove all remote op tracking\n\t\t\t\t\tif (value.raw !== undefined && pending.remote.empty) {\n\t\t\t\t\t\tpending.msnConsensus = computePropertyValue(pending.msnConsensus, [value]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpending.remote.push(value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tproperties[key] = computePropertyValue(\n\t\t\t\t\tpending.msnConsensus,\n\t\t\t\t\tpending.remote.map((n) => n.data),\n\t\t\t\t\tpending.local.map((n) => n.data),\n\t\t\t\t);\n\t\t\t\tif (local || pending.local.empty || properties[key] !== previousValue) {\n\t\t\t\t\tdeltas[key] = previousValue;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tproperties[key] = computePropertyValue(previousValue, [value]);\n\t\t\t\tdeltas[key] = previousValue;\n\t\t\t}\n\t\t});\n\t\tthis.updateMsn(msn);\n\t\treturn rtn;\n\t}\n\n\t/**\n\t * Acknowledges property changes.\n\t * This method acknowledges the property changes based on the provided sequence number and operation.\n\t *\n\t * @param seq - The sequence number for the operation.\n\t * @param msn - The minimum sequence number for the operation.\n\t * @param op - The operation containing property changes.\n\t */\n\tpublic ack(seq: number, msn: number, op: PropsOrAdjust): void {\n\t\tfor (const [key, value] of opToChanges(op, seq)) {\n\t\t\tconst change = this.changes.get(key);\n\t\t\tconst acked = change?.local?.shift();\n\t\t\tassert(\n\t\t\t\tchange !== undefined && acked !== undefined,\n\t\t\t\t0xa71 /* must have local change to ack */,\n\t\t\t);\n\t\t\t// we only track remotes if there are adjusts, as only adjusts make application anti-commutative\n\t\t\t// this will limit the impact of this change to only those using adjusts. Additionally, we only\n\t\t\t// need to track remotes at all to support emitting the legacy snapshot format, which only sharedstring\n\t\t\t// uses. when we remove the ability to emit that format, we can remove all remote op tracking\n\t\t\tif (value.raw !== undefined && change.remote.empty) {\n\t\t\t\tchange.msnConsensus = computePropertyValue(change.msnConsensus, [value]);\n\t\t\t} else {\n\t\t\t\tchange.remote.push(value);\n\t\t\t}\n\t\t}\n\t\tthis.updateMsn(msn);\n\t}\n\n\t/**\n\t * Updates the minimum sequence number (msn).\n\t * This method updates the minimum sequence number and removes any changes that have been acknowledged.\n\t *\n\t * @param msn - The minimum sequence number to update.\n\t */\n\tpublic updateMsn(msn: number): void {\n\t\tfor (const [key, pending] of this.changes) {\n\t\t\tpending.msnConsensus = computePropertyValue(\n\t\t\t\tpending.msnConsensus,\n\t\t\t\titerateListValuesWhile(pending.remote.first, (n) => {\n\t\t\t\t\tif (n.data.seq <= msn) {\n\t\t\t\t\t\tn.list?.remove(n);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (pending.local.empty && pending.remote.empty) {\n\t\t\t\tthis.changes.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Copies properties to another manager.\n\t * This method copies the properties and their changes from the current manager to the destination manager.\n\t *\n\t * @param oldProps - The old properties to be copied.\n\t * @param dest - The destination object containing properties and property manager.\n\t */\n\tpublic copyTo(\n\t\toldProps: PropertySet | undefined,\n\t\tdest: {\n\t\t\tproperties?: PropertySet;\n\t\t\tpropertyManager?: PropertiesManager;\n\t\t},\n\t): void {\n\t\tconst newManager = (dest.propertyManager ??= new PropertiesManager());\n\t\tdest.properties = clone(oldProps);\n\t\tfor (const [key, { local, remote, msnConsensus }] of this.changes.entries()) {\n\t\t\tnewManager.changes.set(key, {\n\t\t\t\tmsnConsensus,\n\t\t\t\tremote: new DoublyLinkedList(remote.empty ? undefined : remote.map((c) => c.data)),\n\t\t\t\tlocal: new DoublyLinkedList(local.empty ? undefined : local.map((c) => c.data)),\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Gets properties at a specific sequence number.\n\t * This method retrieves the properties at the given sequence number.\n\t * This is only needed to support emitting snapshots in the legacy format.\n\t * If we remove the ability to emit the legacy format, we can remove this method, along with the need to track remote changes at all.\n\t *\n\t * @param oldProps - The old properties to be retrieved.\n\t * @param sequenceNumber - The sequence number to get properties at.\n\t * @returns The properties at the given sequence number.\n\t */\n\tpublic getAtSeq(\n\t\toldProps: MapLike<unknown> | undefined,\n\t\tsequenceNumber: number,\n\t): MapLike<unknown> {\n\t\tconst properties: MapLike<unknown> = { ...oldProps };\n\t\tfor (const [key, changes] of this.changes) {\n\t\t\tproperties[key] = computePropertyValue(\n\t\t\t\tchanges.msnConsensus,\n\t\t\t\titerateListValuesWhile(changes.remote.first, (c) => c.data.seq <= sequenceNumber),\n\t\t\t);\n\t\t\tif (properties[key] === null) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete properties[key];\n\t\t\t}\n\t\t}\n\t\treturn properties;\n\t}\n\n\t/**\n\t * Determines if all of the defined properties in a given property set are pending.\n\t *\n\t * @param props - The properties to check.\n\t * @returns True if all the properties are pending, false otherwise.\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.changes.get(key)?.local.empty !== false) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"snapshotChunks.d.ts","sourceRoot":"","sources":["../src/snapshotChunks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAEnF,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGnD,MAAM,WAAW,uBAAuB;IACvC,OAAO,EAAE,SAAS,GAAG,GAAG,CAAC;CACzB;AAED,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,yBAAyB,CAAC;AAExE,MAAM,WAAW,oBAAqB,SAAQ,uBAAuB;IACpE,OAAO,EAAE,SAAS,CAAC;IACnB,sBAAsB,EAAE,MAAM,CAA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E,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC3B,IAAI,EAAE,YAAY,GAAG,yBAAyB,GAC5C,IAAI,IAAI,yBAAyB,CAEnC;AAED,wBAAgB,8BAA8B,CAC7C,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,uBAAuB,EAC9B,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,YAAY,GAChB,MAAM,CAkDR;AAED,wBAAgB,8BAA8B,CAC7C,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,uBAAuB,EAC9B,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,YAAY,GAChB,MAAM,CAGR;AAED,wBAAgB,eAAe,CAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,uBAAuB,EAC9B,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,WAAW,GAAG,SAAS,GAC9B,gBAAgB,CAsBlB"}
@@ -2,6 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import { LogLevel } from "@fluidframework/core-interfaces";
5
6
  import { SnapshotLegacy } from "./snapshotlegacy.js";
6
7
  /**
7
8
  * Returns true if the given 'spec' is an IJSONSegmentWithMergeInfo.
@@ -17,7 +18,7 @@ export function serializeAsMinSupportedVersion(path, chunk, logger, options, ser
17
18
  category: "generic",
18
19
  fromChunkVersion: chunk.version,
19
20
  toChunkVersion: undefined,
20
- });
21
+ }, LogLevel.essential);
21
22
  }
22
23
  switch (chunk.version) {
23
24
  case undefined: {
@@ -1 +1 @@
1
- {"version":3,"file":"snapshotChunks.js","sourceRoot":"","sources":["../src/snapshotChunks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AA6DrD;;GAEG;AACH,MAAM,UAAU,YAAY,CAC3B,IAA8C;IAE9C,OAAO,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,MAAM,IAAI,IAAI,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,8BAA8B,CAC7C,IAAY,EACZ,KAA8B,EAC9B,MAA0B,EAC1B,OAAgC,EAChC,UAA4B,EAC5B,IAAkB;IAElB,IAAI,WAAiC,CAAC;IAEtC,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,CAAC,IAAI,CAAC;YACX,SAAS,EAAE,+CAA+C;YAC1D,QAAQ,EAAE,SAAS;YACnB,gBAAgB,EAAE,KAAK,CAAC,OAAO;YAC/B,cAAc,EAAE,SAAS;SACzB,CAAC,CAAC;IACJ,CAAC;IAED,QAAQ,KAAK,CAAC,OAAO,EAAE,CAAC;QACvB,KAAK,SAAS,CAAC,CAAC,CAAC;YAChB,WAAW,GAAG,KAA6B,CAAC;YAC5C,WAAW,CAAC,cAAc,GAAG,iCAAiC,CAC7D,IAAI,EACJ,WAAW,EACX,OAAO,CACP,CAAC;YACF,MAAM;QACP,CAAC;QAED,KAAK,GAAG,CAAC,CAAC,CAAC;YACV,MAAM,OAAO,GAAG,KAAyB,CAAC;YAC1C,MAAM,cAAc,GACnB,IAAI,KAAK,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC;YACrE,WAAW,GAAG;gBACb,OAAO,EAAE,SAAS;gBAClB,sBAAsB,EAAE,OAAO,CAAC,UAAU;gBAC1C,gBAAgB,EAAE,OAAO,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AE,WAAW,CAAC,sBAAsB;gBAC9C,WAAW,EAAE,WAAW,CAAC,WAAW;aACpC,CAAC;QACH,CAAC;QACD,KAAK,GAAG,CAAC,CAAC,CAAC;YACV,OAAO,KAAyB,CAAC;QAClC,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,aAAa,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9E,CAAC;IACF,CAAC;AACF,CAAC;AAED,SAAS,iCAAiC,CACzC,IAAY,EACZ,KAA2B,EAC3B,OAAgC;IAEhC,IAAI,IAAI,KAAK,cAAc,CAAC,MAAM,EAAE,CAAC;QACpC,IAAI,KAAK,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;YACxC,OAAO,KAAK,CAAC,cAAc,CAAC;QAC7B,CAAC;QACD,MAAM,QAAQ,GAAmC,CAAC,EAAE,EAAE,EAAE,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC;QACjF,IAAI,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAiB,EAAE,CAAC;YACtD,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO;YACN,oBAAoB,EAAE,QAAQ;YAC9B,iBAAiB,EAAE,KAAK,CAAC,sBAAuB;YAChD,cAAc,EAAE,KAAK,CAAC,mBAAoB;YAC1C,WAAW,EAAE,KAAK,CAAC,gBAAiB;YACpC,iBAAiB,EAAE,KAAK,CAAC,iBAAkB;SAC3C,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,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 type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport type { TelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { SerializedAttributionCollection } from \"./attributionCollection.js\";\nimport type { IJSONSegment } from \"./ops.js\";\nimport type { PropertySet } from \"./properties.js\";\nimport { SnapshotLegacy } from \"./snapshotlegacy.js\";\n\nexport interface VersionedMergeTreeChunk {\n\tversion: undefined | \"1\";\n}\n\nexport type JsonSegmentSpecs = IJSONSegment | IJSONSegmentWithMergeInfo;\n\nexport interface MergeTreeChunkLegacy extends VersionedMergeTreeChunk {\n\tversion: undefined;\n\tchunkStartSegmentIndex: number;\n\tchunkSegmentCount: number;\n\tchunkLengthChars: number;\n\ttotalLengthChars?: number;\n\ttotalSegmentCount?: number;\n\tchunkSequenceNumber?: number;\n\tchunkMinSequenceNumber?: number;\n\tsegmentTexts: JsonSegmentSpecs[];\n\theaderMetadata?: MergeTreeHeaderMetadata;\n\tattribution?: SerializedAttributionCollection;\n}\n\nexport interface MergeTreeHeaderChunkMetadata {\n\tid: string;\n}\n\nexport interface MergeTreeHeaderMetadata {\n\ttotalLength: number;\n\ttotalSegmentCount: number;\n\torderedChunkMetadata: MergeTreeHeaderChunkMetadata[];\n\tsequenceNumber: number;\n\tminSequenceNumber: number;\n}\n\nexport interface MergeTreeChunkV1 extends VersionedMergeTreeChunk {\n\tversion: \"1\";\n\tstartIndex: number;\n\tsegmentCount: number;\n\tlength: number;\n\tsegments: JsonSegmentSpecs[];\n\theaderMetadata: MergeTreeHeaderMetadata | undefined;\n\tattribution?: SerializedAttributionCollection;\n}\n\n/**\n * Used during snapshotting to record the metadata required to merge segments above the MSN\n * to the raw output of `ISegment.toJSONObject()`. (Note that IJSONSegment may be a raw\n * string or array, which is why this interface wraps the original IJSONSegment instead of\n * extending it.)\n */\nexport interface IJSONSegmentWithMergeInfo {\n\tjson: IJSONSegment;\n\tclient?: string;\n\tseq?: number;\n\tremovedClientIds?: string[];\n\tremovedSeq?: number;\n\tmovedClientIds?: string[];\n\tmovedSeq?: number;\n\tmovedSeqs?: number[];\n}\n\n/**\n * Returns true if the given 'spec' is an IJSONSegmentWithMergeInfo.\n */\nexport function hasMergeInfo(\n\tspec: IJSONSegment | IJSONSegmentWithMergeInfo,\n): spec is IJSONSegmentWithMergeInfo {\n\treturn !!spec && typeof spec === \"object\" && \"json\" in spec;\n}\n\nexport function serializeAsMinSupportedVersion(\n\tpath: string,\n\tchunk: VersionedMergeTreeChunk,\n\tlogger: TelemetryLoggerExt,\n\toptions: PropertySet | undefined,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n): string {\n\tlet targetChuck: MergeTreeChunkLegacy;\n\n\tif (chunk.version !== undefined) {\n\t\tlogger.send({\n\t\t\teventName: \"MergeTreeChunk:serializeAsMinSupportedVersion\",\n\t\t\tcategory: \"generic\",\n\t\t\tfromChunkVersion: chunk.version,\n\t\t\ttoChunkVersion: undefined,\n\t\t});\n\t}\n\n\tswitch (chunk.version) {\n\t\tcase undefined: {\n\t\t\ttargetChuck = chunk as MergeTreeChunkLegacy;\n\t\t\ttargetChuck.headerMetadata = buildHeaderMetadataForLegacyChunk(\n\t\t\t\tpath,\n\t\t\t\ttargetChuck,\n\t\t\t\toptions,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"1\": {\n\t\t\tconst chunkV1 = chunk as MergeTreeChunkV1;\n\t\t\tconst headerMetadata =\n\t\t\t\tpath === SnapshotLegacy.header ? chunkV1.headerMetadata : undefined;\n\t\t\ttargetChuck = {\n\t\t\t\tversion: undefined,\n\t\t\t\tchunkStartSegmentIndex: chunkV1.startIndex,\n\t\t\t\tchunkLengthChars: chunkV1.length,\n\t\t\t\tchunkSegmentCount: chunkV1.segmentCount,\n\t\t\t\tsegmentTexts: chunkV1.segments,\n\t\t\t\ttotalLengthChars: headerMetadata?.totalLength,\n\t\t\t\ttotalSegmentCount: headerMetadata?.totalSegmentCount,\n\t\t\t\tchunkSequenceNumber: headerMetadata?.sequenceNumber,\n\t\t\t\tchunkMinSequenceNumber: headerMetadata?.minSequenceNumber,\n\t\t\t\theaderMetadata,\n\t\t\t};\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tthrow new Error(`Unsupported chunk path: ${path} version: ${chunk.version}`);\n\t\t}\n\t}\n\treturn serializer.stringify(targetChuck, bind);\n}\n\nexport function serializeAsMaxSupportedVersion(\n\tpath: string,\n\tchunk: VersionedMergeTreeChunk,\n\tlogger: TelemetryLoggerExt,\n\toptions: PropertySet | undefined,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n): string {\n\tconst targetChuck = toLatestVersion(path, chunk, logger, options);\n\treturn serializer.stringify(targetChuck, bind);\n}\n\nexport function toLatestVersion(\n\tpath: string,\n\tchunk: VersionedMergeTreeChunk,\n\tlogger: TelemetryLoggerExt,\n\toptions: PropertySet | undefined,\n): MergeTreeChunkV1 {\n\tswitch (chunk.version) {\n\t\tcase undefined: {\n\t\t\tconst chunkLegacy = chunk as MergeTreeChunkLegacy;\n\t\t\treturn {\n\t\t\t\tversion: \"1\",\n\t\t\t\tlength: chunkLegacy.chunkLengthChars,\n\t\t\t\tsegmentCount: chunkLegacy.chunkSegmentCount,\n\t\t\t\theaderMetadata: buildHeaderMetadataForLegacyChunk(path, chunkLegacy, options),\n\t\t\t\tsegments: chunkLegacy.segmentTexts,\n\t\t\t\tstartIndex: chunkLegacy.chunkStartSegmentIndex,\n\t\t\t\tattribution: chunkLegacy.attribution,\n\t\t\t};\n\t\t}\n\t\tcase \"1\": {\n\t\t\treturn chunk as MergeTreeChunkV1;\n\t\t}\n\n\t\tdefault: {\n\t\t\tthrow new Error(`Unsupported chunk path: ${path} version: ${chunk.version}`);\n\t\t}\n\t}\n}\n\nfunction buildHeaderMetadataForLegacyChunk(\n\tpath: string,\n\tchunk: MergeTreeChunkLegacy,\n\toptions: PropertySet | undefined,\n): MergeTreeHeaderMetadata | undefined {\n\tif (path === SnapshotLegacy.header) {\n\t\tif (chunk.headerMetadata !== undefined) {\n\t\t\treturn chunk.headerMetadata;\n\t\t}\n\t\tconst chunkIds: MergeTreeHeaderChunkMetadata[] = [{ id: SnapshotLegacy.header }];\n\t\tif (chunk.chunkLengthChars < chunk.totalLengthChars!) {\n\t\t\tchunkIds.push({ id: SnapshotLegacy.body });\n\t\t}\n\t\treturn {\n\t\t\torderedChunkMetadata: chunkIds,\n\t\t\tminSequenceNumber: chunk.chunkMinSequenceNumber!,\n\t\t\tsequenceNumber: chunk.chunkSequenceNumber!,\n\t\t\ttotalLength: chunk.totalLengthChars!,\n\t\t\ttotalSegmentCount: chunk.totalSegmentCount!,\n\t\t};\n\t}\n\treturn undefined;\n}\n"]}
1
+ {"version":3,"file":"snapshotChunks.js","sourceRoot":"","sources":["../src/snapshotChunks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAO3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AA6DrD;;GAEG;AACH,MAAM,UAAU,YAAY,CAC3B,IAA8C;IAE9C,OAAO,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,MAAM,IAAI,IAAI,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,8BAA8B,CAC7C,IAAY,EACZ,KAA8B,EAC9B,MAA0B,EAC1B,OAAgC,EAChC,UAA4B,EAC5B,IAAkB;IAElB,IAAI,WAAiC,CAAC;IAEtC,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,CAAC,IAAI,CACV;YACC,SAAS,EAAE,+CAA+C;YAC1D,QAAQ,EAAE,SAAS;YACnB,gBAAgB,EAAE,KAAK,CAAC,OAAO;YAC/B,cAAc,EAAE,SAAS;SACzB,EACD,QAAQ,CAAC,SAAS,CAClB,CAAC;IACH,CAAC;IAED,QAAQ,KAAK,CAAC,OAAO,EAAE,CAAC;QACvB,KAAK,SAAS,CAAC,CAAC,CAAC;YAChB,WAAW,GAA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AE,QAAQ;YAC9B,iBAAiB,EAAE,KAAK,CAAC,sBAAuB;YAChD,cAAc,EAAE,KAAK,CAAC,mBAAoB;YAC1C,WAAW,EAAE,KAAK,CAAC,gBAAiB;YACpC,iBAAiB,EAAE,KAAK,CAAC,iBAAkB;SAC3C,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,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 type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { LogLevel } from \"@fluidframework/core-interfaces\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport type { TelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { SerializedAttributionCollection } from \"./attributionCollection.js\";\nimport type { IJSONSegment } from \"./ops.js\";\nimport type { PropertySet } from \"./properties.js\";\nimport { SnapshotLegacy } from \"./snapshotlegacy.js\";\n\nexport interface VersionedMergeTreeChunk {\n\tversion: undefined | \"1\";\n}\n\nexport type JsonSegmentSpecs = IJSONSegment | IJSONSegmentWithMergeInfo;\n\nexport interface MergeTreeChunkLegacy extends VersionedMergeTreeChunk {\n\tversion: undefined;\n\tchunkStartSegmentIndex: number;\n\tchunkSegmentCount: number;\n\tchunkLengthChars: number;\n\ttotalLengthChars?: number;\n\ttotalSegmentCount?: number;\n\tchunkSequenceNumber?: number;\n\tchunkMinSequenceNumber?: number;\n\tsegmentTexts: JsonSegmentSpecs[];\n\theaderMetadata?: MergeTreeHeaderMetadata;\n\tattribution?: SerializedAttributionCollection;\n}\n\nexport interface MergeTreeHeaderChunkMetadata {\n\tid: string;\n}\n\nexport interface MergeTreeHeaderMetadata {\n\ttotalLength: number;\n\ttotalSegmentCount: number;\n\torderedChunkMetadata: MergeTreeHeaderChunkMetadata[];\n\tsequenceNumber: number;\n\tminSequenceNumber: number;\n}\n\nexport interface MergeTreeChunkV1 extends VersionedMergeTreeChunk {\n\tversion: \"1\";\n\tstartIndex: number;\n\tsegmentCount: number;\n\tlength: number;\n\tsegments: JsonSegmentSpecs[];\n\theaderMetadata: MergeTreeHeaderMetadata | undefined;\n\tattribution?: SerializedAttributionCollection;\n}\n\n/**\n * Used during snapshotting to record the metadata required to merge segments above the MSN\n * to the raw output of `ISegment.toJSONObject()`. (Note that IJSONSegment may be a raw\n * string or array, which is why this interface wraps the original IJSONSegment instead of\n * extending it.)\n */\nexport interface IJSONSegmentWithMergeInfo {\n\tjson: IJSONSegment;\n\tclient?: string;\n\tseq?: number;\n\tremovedClientIds?: string[];\n\tremovedSeq?: number;\n\tmovedClientIds?: string[];\n\tmovedSeq?: number;\n\tmovedSeqs?: number[];\n}\n\n/**\n * Returns true if the given 'spec' is an IJSONSegmentWithMergeInfo.\n */\nexport function hasMergeInfo(\n\tspec: IJSONSegment | IJSONSegmentWithMergeInfo,\n): spec is IJSONSegmentWithMergeInfo {\n\treturn !!spec && typeof spec === \"object\" && \"json\" in spec;\n}\n\nexport function serializeAsMinSupportedVersion(\n\tpath: string,\n\tchunk: VersionedMergeTreeChunk,\n\tlogger: TelemetryLoggerExt,\n\toptions: PropertySet | undefined,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n): string {\n\tlet targetChuck: MergeTreeChunkLegacy;\n\n\tif (chunk.version !== undefined) {\n\t\tlogger.send(\n\t\t\t{\n\t\t\t\teventName: \"MergeTreeChunk:serializeAsMinSupportedVersion\",\n\t\t\t\tcategory: \"generic\",\n\t\t\t\tfromChunkVersion: chunk.version,\n\t\t\t\ttoChunkVersion: undefined,\n\t\t\t},\n\t\t\tLogLevel.essential,\n\t\t);\n\t}\n\n\tswitch (chunk.version) {\n\t\tcase undefined: {\n\t\t\ttargetChuck = chunk as MergeTreeChunkLegacy;\n\t\t\ttargetChuck.headerMetadata = buildHeaderMetadataForLegacyChunk(\n\t\t\t\tpath,\n\t\t\t\ttargetChuck,\n\t\t\t\toptions,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"1\": {\n\t\t\tconst chunkV1 = chunk as MergeTreeChunkV1;\n\t\t\tconst headerMetadata =\n\t\t\t\tpath === SnapshotLegacy.header ? chunkV1.headerMetadata : undefined;\n\t\t\ttargetChuck = {\n\t\t\t\tversion: undefined,\n\t\t\t\tchunkStartSegmentIndex: chunkV1.startIndex,\n\t\t\t\tchunkLengthChars: chunkV1.length,\n\t\t\t\tchunkSegmentCount: chunkV1.segmentCount,\n\t\t\t\tsegmentTexts: chunkV1.segments,\n\t\t\t\ttotalLengthChars: headerMetadata?.totalLength,\n\t\t\t\ttotalSegmentCount: headerMetadata?.totalSegmentCount,\n\t\t\t\tchunkSequenceNumber: headerMetadata?.sequenceNumber,\n\t\t\t\tchunkMinSequenceNumber: headerMetadata?.minSequenceNumber,\n\t\t\t\theaderMetadata,\n\t\t\t};\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tthrow new Error(`Unsupported chunk path: ${path} version: ${chunk.version}`);\n\t\t}\n\t}\n\treturn serializer.stringify(targetChuck, bind);\n}\n\nexport function serializeAsMaxSupportedVersion(\n\tpath: string,\n\tchunk: VersionedMergeTreeChunk,\n\tlogger: TelemetryLoggerExt,\n\toptions: PropertySet | undefined,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n): string {\n\tconst targetChuck = toLatestVersion(path, chunk, logger, options);\n\treturn serializer.stringify(targetChuck, bind);\n}\n\nexport function toLatestVersion(\n\tpath: string,\n\tchunk: VersionedMergeTreeChunk,\n\tlogger: TelemetryLoggerExt,\n\toptions: PropertySet | undefined,\n): MergeTreeChunkV1 {\n\tswitch (chunk.version) {\n\t\tcase undefined: {\n\t\t\tconst chunkLegacy = chunk as MergeTreeChunkLegacy;\n\t\t\treturn {\n\t\t\t\tversion: \"1\",\n\t\t\t\tlength: chunkLegacy.chunkLengthChars,\n\t\t\t\tsegmentCount: chunkLegacy.chunkSegmentCount,\n\t\t\t\theaderMetadata: buildHeaderMetadataForLegacyChunk(path, chunkLegacy, options),\n\t\t\t\tsegments: chunkLegacy.segmentTexts,\n\t\t\t\tstartIndex: chunkLegacy.chunkStartSegmentIndex,\n\t\t\t\tattribution: chunkLegacy.attribution,\n\t\t\t};\n\t\t}\n\t\tcase \"1\": {\n\t\t\treturn chunk as MergeTreeChunkV1;\n\t\t}\n\n\t\tdefault: {\n\t\t\tthrow new Error(`Unsupported chunk path: ${path} version: ${chunk.version}`);\n\t\t}\n\t}\n}\n\nfunction buildHeaderMetadataForLegacyChunk(\n\tpath: string,\n\tchunk: MergeTreeChunkLegacy,\n\toptions: PropertySet | undefined,\n): MergeTreeHeaderMetadata | undefined {\n\tif (path === SnapshotLegacy.header) {\n\t\tif (chunk.headerMetadata !== undefined) {\n\t\t\treturn chunk.headerMetadata;\n\t\t}\n\t\tconst chunkIds: MergeTreeHeaderChunkMetadata[] = [{ id: SnapshotLegacy.header }];\n\t\tif (chunk.chunkLengthChars < chunk.totalLengthChars!) {\n\t\t\tchunkIds.push({ id: SnapshotLegacy.body });\n\t\t}\n\t\treturn {\n\t\t\torderedChunkMetadata: chunkIds,\n\t\t\tminSequenceNumber: chunk.chunkMinSequenceNumber!,\n\t\t\tsequenceNumber: chunk.chunkSequenceNumber!,\n\t\t\ttotalLength: chunk.totalLengthChars!,\n\t\t\ttotalSegmentCount: chunk.totalSegmentCount!,\n\t\t};\n\t}\n\treturn undefined;\n}\n"]}
@@ -15,74 +15,16 @@ import { SnapshotV1 } from "./snapshotV1.js";
15
15
  import { SnapshotLegacy } from "./snapshotlegacy.js";
16
16
  import * as opstampUtils from "./stamps.js";
17
17
  export class SnapshotLoader {
18
+ runtime;
19
+ client;
20
+ mergeTree;
21
+ serializer;
22
+ logger;
18
23
  constructor(runtime, client, mergeTree, logger, serializer) {
19
24
  this.runtime = runtime;
20
25
  this.client = client;
21
26
  this.mergeTree = mergeTree;
22
27
  this.serializer = serializer;
23
- this.specToSegment = (spec) => {
24
- if (hasMergeInfo(spec)) {
25
- const seg = overwriteInfo(this.client.specToSegment(spec.json), {
26
- insert: {
27
- type: "insert",
28
- seq: spec.seq ?? UniversalSequenceNumber,
29
- clientId: spec.client === undefined
30
- ? NonCollabClient
31
- : this.client.getOrAddShortClientId(spec.client),
32
- },
33
- });
34
- const removes = [];
35
- if (spec.removedSeq !== undefined) {
36
- // this format had a bug where it didn't store all the overlap clients
37
- // this is for back compat, so we change the singular id to an array
38
- // this will only cause problems if there is an overlapping delete
39
- // spanning the snapshot, which should be rare
40
- const specAsBuggyFormat = spec;
41
- if (specAsBuggyFormat.removedClient !== undefined) {
42
- spec.removedClientIds ??= [specAsBuggyFormat.removedClient];
43
- }
44
- assert(spec.removedClientIds !== undefined, 0xaac /* must have removedClient ids */);
45
- const firstRemovedSeq = spec.removedSeq;
46
- // TODO:AB#32299: To correctly support perspectives from other clients which don't assume they have seen
47
- // all ops, we need to actually record these in the summary. For now we use fake data, and it turns
48
- // out ok since none of these values end up being used. (specifically, the 'firstRemovedSeq' is fake
49
- // for all values other than the actual first remove).
50
- // This issue only affects V1 summaries, as the strategy in snapshotlegacy avoids storing merge info directly.
51
- for (const id of spec.removedClientIds) {
52
- removes.push({
53
- type: "setRemove",
54
- seq: firstRemovedSeq,
55
- clientId: this.client.getOrAddShortClientId(id),
56
- });
57
- }
58
- }
59
- if (spec.movedSeq !== undefined) {
60
- assert(spec.movedClientIds !== undefined && spec.movedSeqs !== undefined, 0xaa5 /* must have movedIds ids */);
61
- assert(spec.movedClientIds.length === spec.movedSeqs.length, 0xb5f /* Expected same length for client ids and seqs */);
62
- // Avoid spreading into push: a large array could exceed the engine's
63
- // argument-count limit and throw RangeError.
64
- for (let i = 0; i < spec.movedClientIds.length; i++) {
65
- removes.push({
66
- type: "sliceRemove",
67
- seq: spec.movedSeqs[i],
68
- clientId: this.client.getOrAddShortClientId(spec.movedClientIds[i]),
69
- });
70
- }
71
- }
72
- if (removes.length > 0) {
73
- removes.sort(opstampUtils.compare);
74
- overwriteInfo(seg, { removes });
75
- }
76
- return seg;
77
- }
78
- return overwriteInfo(this.client.specToSegment(spec), {
79
- insert: {
80
- type: "insert",
81
- seq: UniversalSequenceNumber,
82
- clientId: NonCollabClient,
83
- },
84
- });
85
- };
86
28
  this.logger = createChildLogger({ logger, namespace: "SnapshotLoader" });
87
29
  }
88
30
  async initialize(services) {
@@ -115,6 +57,69 @@ export class SnapshotLoader {
115
57
  }
116
58
  return [];
117
59
  }
60
+ specToSegment = (spec) => {
61
+ if (hasMergeInfo(spec)) {
62
+ const seg = overwriteInfo(this.client.specToSegment(spec.json), {
63
+ insert: {
64
+ type: "insert",
65
+ seq: spec.seq ?? UniversalSequenceNumber,
66
+ clientId: spec.client === undefined
67
+ ? NonCollabClient
68
+ : this.client.getOrAddShortClientId(spec.client),
69
+ },
70
+ });
71
+ const removes = [];
72
+ if (spec.removedSeq !== undefined) {
73
+ // this format had a bug where it didn't store all the overlap clients
74
+ // this is for back compat, so we change the singular id to an array
75
+ // this will only cause problems if there is an overlapping delete
76
+ // spanning the snapshot, which should be rare
77
+ const specAsBuggyFormat = spec;
78
+ if (specAsBuggyFormat.removedClient !== undefined) {
79
+ spec.removedClientIds ??= [specAsBuggyFormat.removedClient];
80
+ }
81
+ assert(spec.removedClientIds !== undefined, 0xaac /* must have removedClient ids */);
82
+ const firstRemovedSeq = spec.removedSeq;
83
+ // TODO:AB#32299: To correctly support perspectives from other clients which don't assume they have seen
84
+ // all ops, we need to actually record these in the summary. For now we use fake data, and it turns
85
+ // out ok since none of these values end up being used. (specifically, the 'firstRemovedSeq' is fake
86
+ // for all values other than the actual first remove).
87
+ // This issue only affects V1 summaries, as the strategy in snapshotlegacy avoids storing merge info directly.
88
+ for (const id of spec.removedClientIds) {
89
+ removes.push({
90
+ type: "setRemove",
91
+ seq: firstRemovedSeq,
92
+ clientId: this.client.getOrAddShortClientId(id),
93
+ });
94
+ }
95
+ }
96
+ if (spec.movedSeq !== undefined) {
97
+ assert(spec.movedClientIds !== undefined && spec.movedSeqs !== undefined, 0xaa5 /* must have movedIds ids */);
98
+ assert(spec.movedClientIds.length === spec.movedSeqs.length, 0xb5f /* Expected same length for client ids and seqs */);
99
+ // Avoid spreading into push: a large array could exceed the engine's
100
+ // argument-count limit and throw RangeError.
101
+ for (let i = 0; i < spec.movedClientIds.length; i++) {
102
+ removes.push({
103
+ type: "sliceRemove",
104
+ seq: spec.movedSeqs[i],
105
+ clientId: this.client.getOrAddShortClientId(spec.movedClientIds[i]),
106
+ });
107
+ }
108
+ }
109
+ if (removes.length > 0) {
110
+ removes.sort(opstampUtils.compare);
111
+ overwriteInfo(seg, { removes });
112
+ }
113
+ return seg;
114
+ }
115
+ return overwriteInfo(this.client.specToSegment(spec), {
116
+ insert: {
117
+ type: "insert",
118
+ seq: UniversalSequenceNumber,
119
+ clientId: NonCollabClient,
120
+ },
121
+ });
122
+ };
118
123
  loadHeader(header) {
119
124
  const chunk = SnapshotV1.processChunk(SnapshotLegacy.header, header, this.logger, this.mergeTree.options, this.serializer);
120
125
  const segs = chunk.segments.map((element) => this.specToSegment(element));