@fluidframework/merge-tree 2.12.0 → 2.20.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.
- package/CHANGELOG.md +46 -0
- package/api-report/merge-tree.legacy.alpha.api.md +0 -108
- package/dist/MergeTreeTextHelper.d.ts.map +1 -1
- package/dist/MergeTreeTextHelper.js +0 -2
- package/dist/MergeTreeTextHelper.js.map +1 -1
- package/dist/attributionPolicy.d.ts.map +1 -1
- package/dist/attributionPolicy.js +6 -16
- package/dist/attributionPolicy.js.map +1 -1
- package/dist/client.d.ts +3 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +39 -28
- package/dist/client.js.map +1 -1
- package/dist/endOfTreeSegment.d.ts +2 -1
- package/dist/endOfTreeSegment.d.ts.map +1 -1
- package/dist/endOfTreeSegment.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +0 -4
- package/dist/localReference.d.ts +5 -7
- package/dist/localReference.d.ts.map +1 -1
- package/dist/localReference.js +1 -3
- package/dist/localReference.js.map +1 -1
- package/dist/mergeTree.d.ts +8 -7
- package/dist/mergeTree.d.ts.map +1 -1
- package/dist/mergeTree.js +187 -228
- package/dist/mergeTree.js.map +1 -1
- package/dist/mergeTreeNodeWalk.d.ts.map +1 -1
- package/dist/mergeTreeNodeWalk.js +3 -2
- package/dist/mergeTreeNodeWalk.js.map +1 -1
- package/dist/mergeTreeNodes.d.ts +65 -325
- package/dist/mergeTreeNodes.d.ts.map +1 -1
- package/dist/mergeTreeNodes.js +96 -130
- package/dist/mergeTreeNodes.js.map +1 -1
- package/dist/mergeTreeTracking.d.ts.map +1 -1
- package/dist/mergeTreeTracking.js +0 -2
- package/dist/mergeTreeTracking.js.map +1 -1
- package/dist/opBuilder.d.ts +0 -5
- package/dist/opBuilder.d.ts.map +1 -1
- package/dist/opBuilder.js +0 -5
- package/dist/opBuilder.js.map +1 -1
- package/dist/package.json +2 -1
- package/dist/partialLengths.d.ts +2 -2
- package/dist/partialLengths.d.ts.map +1 -1
- package/dist/partialLengths.js +29 -31
- package/dist/partialLengths.js.map +1 -1
- package/dist/perspective.d.ts +3 -2
- package/dist/perspective.d.ts.map +1 -1
- package/dist/perspective.js +5 -2
- package/dist/perspective.js.map +1 -1
- package/dist/referencePositions.d.ts.map +1 -1
- package/dist/referencePositions.js +4 -1
- package/dist/referencePositions.js.map +1 -1
- package/dist/revertibles.d.ts.map +1 -1
- package/dist/revertibles.js +10 -14
- package/dist/revertibles.js.map +1 -1
- package/dist/segmentGroupCollection.d.ts +4 -4
- package/dist/segmentGroupCollection.d.ts.map +1 -1
- package/dist/segmentGroupCollection.js +0 -6
- package/dist/segmentGroupCollection.js.map +1 -1
- package/dist/segmentInfos.d.ts +251 -0
- package/dist/segmentInfos.d.ts.map +1 -0
- package/dist/segmentInfos.js +166 -0
- package/dist/segmentInfos.js.map +1 -0
- package/dist/snapshotLoader.d.ts.map +1 -1
- package/dist/snapshotLoader.js +36 -44
- package/dist/snapshotLoader.js.map +1 -1
- package/dist/snapshotV1.d.ts.map +1 -1
- package/dist/snapshotV1.js +9 -12
- package/dist/snapshotV1.js.map +1 -1
- package/dist/snapshotlegacy.d.ts +2 -2
- package/dist/snapshotlegacy.d.ts.map +1 -1
- package/dist/snapshotlegacy.js +5 -3
- package/dist/snapshotlegacy.js.map +1 -1
- package/dist/sortedSegmentSet.d.ts.map +1 -1
- package/dist/sortedSegmentSet.js +5 -8
- package/dist/sortedSegmentSet.js.map +1 -1
- package/dist/test/beastTest.spec.d.ts +0 -2
- package/dist/test/beastTest.spec.d.ts.map +1 -1
- package/dist/test/beastTest.spec.js +1 -5
- package/dist/test/beastTest.spec.js.map +1 -1
- package/dist/test/client.annotateMarker.spec.js.map +1 -1
- package/dist/test/client.applyMsg.spec.js +15 -12
- package/dist/test/client.applyMsg.spec.js.map +1 -1
- package/dist/test/client.attributionFarm.spec.js.map +1 -1
- package/dist/test/client.getPosition.spec.js +3 -2
- package/dist/test/client.getPosition.spec.js.map +1 -1
- package/dist/test/client.localReference.spec.js +6 -6
- package/dist/test/client.localReference.spec.js.map +1 -1
- package/dist/test/client.localReferenceFarm.spec.js.map +1 -1
- package/dist/test/client.rollback.spec.js.map +1 -1
- package/dist/test/dirname.cjs +0 -1
- package/dist/test/dirname.cjs.map +1 -1
- package/dist/test/index.d.ts +1 -1
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +2 -4
- package/dist/test/index.js.map +1 -1
- package/dist/test/mergeTree.annotate.spec.js +3 -0
- package/dist/test/mergeTree.annotate.spec.js.map +1 -1
- package/dist/test/mergeTree.insertingWalk.spec.js +1 -1
- package/dist/test/mergeTree.insertingWalk.spec.js.map +1 -1
- package/dist/test/mergeTree.markRangeRemoved.spec.js +2 -0
- package/dist/test/mergeTree.markRangeRemoved.spec.js.map +1 -1
- package/dist/test/mergeTree.walk.spec.js.map +1 -1
- package/dist/test/mergeTreeOperationRunner.d.ts.map +1 -1
- package/dist/test/mergeTreeOperationRunner.js +2 -3
- package/dist/test/mergeTreeOperationRunner.js.map +1 -1
- package/dist/test/obliterate.spec.js.map +1 -1
- package/dist/test/propertyManager.spec.js.map +1 -1
- package/dist/test/reconnectHelper.d.ts +2 -1
- package/dist/test/reconnectHelper.d.ts.map +1 -1
- package/dist/test/reconnectHelper.js.map +1 -1
- package/dist/test/resetPendingSegmentsToOp.spec.js.map +1 -1
- package/dist/test/revertibleFarm.spec.js.map +1 -1
- package/dist/test/segmentGroupCollection.spec.js +15 -3
- package/dist/test/segmentGroupCollection.spec.js.map +1 -1
- package/dist/test/snapshot.utils.d.ts +2 -2
- package/dist/test/snapshot.utils.d.ts.map +1 -1
- package/dist/test/snapshot.utils.js.map +1 -1
- package/dist/test/sortedSegmentSet.spec.js +4 -3
- package/dist/test/sortedSegmentSet.spec.js.map +1 -1
- package/dist/test/testClient.d.ts +8 -6
- package/dist/test/testClient.d.ts.map +1 -1
- package/dist/test/testClient.js +28 -27
- package/dist/test/testClient.js.map +1 -1
- package/dist/test/testClientLogger.d.ts.map +1 -1
- package/dist/test/testClientLogger.js +6 -4
- package/dist/test/testClientLogger.js.map +1 -1
- package/dist/test/testUtils.d.ts +2 -2
- package/dist/test/testUtils.d.ts.map +1 -1
- package/dist/test/testUtils.js +32 -8
- package/dist/test/testUtils.js.map +1 -1
- package/dist/test/text.d.ts +2 -2
- package/dist/test/text.d.ts.map +1 -1
- package/dist/test/text.js +12 -6
- package/dist/test/text.js.map +1 -1
- package/dist/test/tracking.spec.js.map +1 -1
- package/dist/test/wordUnitTests.spec.js +1 -1
- package/dist/test/wordUnitTests.spec.js.map +1 -1
- package/dist/zamboni.d.ts.map +1 -1
- package/dist/zamboni.js +8 -7
- package/dist/zamboni.js.map +1 -1
- package/lib/MergeTreeTextHelper.d.ts.map +1 -1
- package/lib/MergeTreeTextHelper.js +0 -2
- package/lib/MergeTreeTextHelper.js.map +1 -1
- package/lib/attributionPolicy.d.ts.map +1 -1
- package/lib/attributionPolicy.js +6 -16
- package/lib/attributionPolicy.js.map +1 -1
- package/lib/client.d.ts +3 -4
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +40 -29
- package/lib/client.js.map +1 -1
- package/lib/endOfTreeSegment.d.ts +2 -1
- package/lib/endOfTreeSegment.d.ts.map +1 -1
- package/lib/endOfTreeSegment.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +0 -4
- package/lib/localReference.d.ts +5 -7
- package/lib/localReference.d.ts.map +1 -1
- package/lib/localReference.js +1 -3
- package/lib/localReference.js.map +1 -1
- package/lib/mergeTree.d.ts +8 -7
- package/lib/mergeTree.d.ts.map +1 -1
- package/lib/mergeTree.js +175 -220
- package/lib/mergeTree.js.map +1 -1
- package/lib/mergeTreeNodeWalk.d.ts.map +1 -1
- package/lib/mergeTreeNodeWalk.js +3 -2
- package/lib/mergeTreeNodeWalk.js.map +1 -1
- package/lib/mergeTreeNodes.d.ts +65 -325
- package/lib/mergeTreeNodes.d.ts.map +1 -1
- package/lib/mergeTreeNodes.js +92 -127
- package/lib/mergeTreeNodes.js.map +1 -1
- package/lib/mergeTreeTracking.d.ts.map +1 -1
- package/lib/mergeTreeTracking.js +0 -2
- package/lib/mergeTreeTracking.js.map +1 -1
- package/lib/opBuilder.d.ts +0 -5
- package/lib/opBuilder.d.ts.map +1 -1
- package/lib/opBuilder.js +0 -5
- package/lib/opBuilder.js.map +1 -1
- package/lib/partialLengths.d.ts +2 -2
- package/lib/partialLengths.d.ts.map +1 -1
- package/lib/partialLengths.js +26 -28
- package/lib/partialLengths.js.map +1 -1
- package/lib/perspective.d.ts +3 -2
- package/lib/perspective.d.ts.map +1 -1
- package/lib/perspective.js +5 -2
- package/lib/perspective.js.map +1 -1
- package/lib/referencePositions.d.ts.map +1 -1
- package/lib/referencePositions.js +4 -1
- package/lib/referencePositions.js.map +1 -1
- package/lib/revertibles.d.ts.map +1 -1
- package/lib/revertibles.js +8 -12
- package/lib/revertibles.js.map +1 -1
- package/lib/segmentGroupCollection.d.ts +4 -4
- package/lib/segmentGroupCollection.d.ts.map +1 -1
- package/lib/segmentGroupCollection.js +0 -6
- package/lib/segmentGroupCollection.js.map +1 -1
- package/lib/segmentInfos.d.ts +251 -0
- package/lib/segmentInfos.d.ts.map +1 -0
- package/lib/segmentInfos.js +145 -0
- package/lib/segmentInfos.js.map +1 -0
- package/lib/snapshotLoader.d.ts.map +1 -1
- package/lib/snapshotLoader.js +36 -44
- package/lib/snapshotLoader.js.map +1 -1
- package/lib/snapshotV1.d.ts.map +1 -1
- package/lib/snapshotV1.js +9 -12
- package/lib/snapshotV1.js.map +1 -1
- package/lib/snapshotlegacy.d.ts +2 -2
- package/lib/snapshotlegacy.d.ts.map +1 -1
- package/lib/snapshotlegacy.js +5 -3
- package/lib/snapshotlegacy.js.map +1 -1
- package/lib/sortedSegmentSet.d.ts.map +1 -1
- package/lib/sortedSegmentSet.js +5 -8
- package/lib/sortedSegmentSet.js.map +1 -1
- package/lib/test/beastTest.spec.d.ts +0 -2
- package/lib/test/beastTest.spec.d.ts.map +1 -1
- package/lib/test/beastTest.spec.js +0 -3
- package/lib/test/beastTest.spec.js.map +1 -1
- package/lib/test/client.annotateMarker.spec.js.map +1 -1
- package/lib/test/client.applyMsg.spec.js +15 -12
- package/lib/test/client.applyMsg.spec.js.map +1 -1
- package/lib/test/client.attributionFarm.spec.js.map +1 -1
- package/lib/test/client.getPosition.spec.js +3 -2
- package/lib/test/client.getPosition.spec.js.map +1 -1
- package/lib/test/client.localReference.spec.js +1 -1
- package/lib/test/client.localReference.spec.js.map +1 -1
- package/lib/test/client.localReferenceFarm.spec.js.map +1 -1
- package/lib/test/client.rollback.spec.js +1 -1
- package/lib/test/client.rollback.spec.js.map +1 -1
- package/lib/test/dirname.cjs +0 -1
- package/lib/test/dirname.cjs.map +1 -1
- package/lib/test/index.d.ts +1 -1
- package/lib/test/index.d.ts.map +1 -1
- package/lib/test/index.js +1 -1
- package/lib/test/index.js.map +1 -1
- package/lib/test/mergeTree.annotate.spec.js +3 -0
- package/lib/test/mergeTree.annotate.spec.js.map +1 -1
- package/lib/test/mergeTree.insertingWalk.spec.js +2 -2
- package/lib/test/mergeTree.insertingWalk.spec.js.map +1 -1
- package/lib/test/mergeTree.markRangeRemoved.spec.js +2 -0
- package/lib/test/mergeTree.markRangeRemoved.spec.js.map +1 -1
- package/lib/test/mergeTree.walk.spec.js.map +1 -1
- package/lib/test/mergeTreeOperationRunner.d.ts.map +1 -1
- package/lib/test/mergeTreeOperationRunner.js +1 -2
- package/lib/test/mergeTreeOperationRunner.js.map +1 -1
- package/lib/test/obliterate.spec.js.map +1 -1
- package/lib/test/propertyManager.spec.js.map +1 -1
- package/lib/test/reconnectHelper.d.ts +2 -1
- package/lib/test/reconnectHelper.d.ts.map +1 -1
- package/lib/test/reconnectHelper.js.map +1 -1
- package/lib/test/resetPendingSegmentsToOp.spec.js.map +1 -1
- package/lib/test/revertibleFarm.spec.js.map +1 -1
- package/lib/test/segmentGroupCollection.spec.js +15 -3
- package/lib/test/segmentGroupCollection.spec.js.map +1 -1
- package/lib/test/snapshot.utils.d.ts +2 -2
- package/lib/test/snapshot.utils.d.ts.map +1 -1
- package/lib/test/snapshot.utils.js.map +1 -1
- package/lib/test/sortedSegmentSet.spec.js +4 -3
- package/lib/test/sortedSegmentSet.spec.js.map +1 -1
- package/lib/test/testClient.d.ts +8 -6
- package/lib/test/testClient.d.ts.map +1 -1
- package/lib/test/testClient.js +29 -28
- package/lib/test/testClient.js.map +1 -1
- package/lib/test/testClientLogger.d.ts.map +1 -1
- package/lib/test/testClientLogger.js +5 -3
- package/lib/test/testClientLogger.js.map +1 -1
- package/lib/test/testUtils.d.ts +2 -2
- package/lib/test/testUtils.d.ts.map +1 -1
- package/lib/test/testUtils.js +9 -8
- package/lib/test/testUtils.js.map +1 -1
- package/lib/test/text.d.ts +2 -2
- package/lib/test/text.d.ts.map +1 -1
- package/lib/test/text.js +12 -6
- package/lib/test/text.js.map +1 -1
- package/lib/test/tracking.spec.js.map +1 -1
- package/lib/test/wordUnitTests.spec.js +1 -1
- package/lib/test/wordUnitTests.spec.js.map +1 -1
- package/lib/zamboni.d.ts.map +1 -1
- package/lib/zamboni.js +7 -6
- package/lib/zamboni.js.map +1 -1
- package/package.json +77 -19
- package/src/MergeTreeTextHelper.ts +2 -4
- package/src/attributionPolicy.ts +5 -13
- package/src/client.ts +55 -44
- package/src/endOfTreeSegment.ts +3 -5
- package/src/index.ts +0 -7
- package/src/localReference.ts +6 -8
- package/src/mergeTree.ts +233 -290
- package/src/mergeTreeNodeWalk.ts +3 -2
- package/src/mergeTreeNodes.ts +160 -490
- package/src/mergeTreeTracking.ts +0 -3
- package/src/opBuilder.ts +0 -5
- package/src/partialLengths.ts +40 -29
- package/src/perspective.ts +23 -4
- package/src/referencePositions.ts +4 -1
- package/src/revertibles.ts +19 -16
- package/src/segmentGroupCollection.ts +7 -18
- package/src/segmentInfos.ts +371 -0
- package/src/snapshotLoader.ts +56 -57
- package/src/snapshotV1.ts +14 -16
- package/src/snapshotlegacy.ts +12 -17
- package/src/sortedSegmentSet.ts +6 -8
- package/src/zamboni.ts +10 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeTreeNodeWalk.d.ts","sourceRoot":"","sources":["../src/mergeTreeNodeWalk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"mergeTreeNodeWalk.d.ts","sourceRoot":"","sources":["../src/mergeTreeNodeWalk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGrF,eAAO,MAAM,UAAU;;CAEb,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;AAEpD,eAAO,MAAM,UAAU;;;;CAKb,CAAC;AAGX,MAAM,MAAM,UAAU,GACnB,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,GAC5C,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AAE7B;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CACjC,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,EAC7C,kBAAkB,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,UAAU,EACtD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,EACtC,OAAO,GAAE,OAAc,GACrB,OAAO,CAyET;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC/B,SAAS,EAAE,UAAU,EACrB,UAAU,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,OAAO,GAAG,SAAS,GACpD,OAAO,CAcT;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAChC,SAAS,EAAE,UAAU,EACrB,UAAU,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,OAAO,GAAG,SAAS,GACpD,OAAO,CAeT;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CACnC,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,GAAG,SAAS,GAAG,IAAI,GAC/D,OAAO,CAqBT"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.walkAllChildSegments = exports.backwardExcursion = exports.forwardExcursion = exports.depthFirstNodeWalk = exports.NodeAction = exports.LeafAction = void 0;
|
|
8
|
+
const segmentInfos_js_1 = require("./segmentInfos.js");
|
|
8
9
|
exports.LeafAction = {
|
|
9
10
|
Exit: false,
|
|
10
11
|
};
|
|
@@ -100,7 +101,7 @@ exports.depthFirstNodeWalk = depthFirstNodeWalk;
|
|
|
100
101
|
* All segments past `node` are visited, regardless of their visibility.
|
|
101
102
|
*/
|
|
102
103
|
function forwardExcursion(startNode, leafAction) {
|
|
103
|
-
if (
|
|
104
|
+
if (!(0, segmentInfos_js_1.isMergeNodeInfo)(startNode)) {
|
|
104
105
|
return true;
|
|
105
106
|
}
|
|
106
107
|
return depthFirstNodeWalk(startNode.parent,
|
|
@@ -115,7 +116,7 @@ exports.forwardExcursion = forwardExcursion;
|
|
|
115
116
|
* All segments past `node` are visited, regardless of their visibility.
|
|
116
117
|
*/
|
|
117
118
|
function backwardExcursion(startNode, leafAction) {
|
|
118
|
-
if (
|
|
119
|
+
if (!(0, segmentInfos_js_1.isMergeNodeInfo)(startNode)) {
|
|
119
120
|
return true;
|
|
120
121
|
}
|
|
121
122
|
return depthFirstNodeWalk(startNode.parent,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeTreeNodeWalk.js","sourceRoot":"","sources":["../src/mergeTreeNodeWalk.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIU,QAAA,UAAU,GAAG;IACzB,IAAI,EAAE,KAAK;CACF,CAAC;AAIE,QAAA,UAAU,GAAG;IACzB,QAAQ,EAAE,SAAS;IACnB,iDAAiD;IACjD,IAAI,EAAE,kBAAU,CAAC,IAAI;IACrB,IAAI,EAAE,CAAC;CACE,CAAC;AAOX;;;;;;;;;;GAUG;AACH,SAAgB,kBAAkB,CACjC,UAAsB,EACtB,UAAkC,EAClC,UAA6C,EAC7C,kBAAsD,EACtD,QAAsC,EACtC,UAAmB,IAAI;IAEvB,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,UAAU,GAAG,kBAAkB,IAAI,UAAU,CAAC;IACpD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,KAAK,GAAG,UAAU,CAAC;IACvB,IAAI,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;IAClC,IAAI,KAAK,GAA2B,UAAU,CAAC;IAE/C,iDAAiD;IACjD,OAAO,IAAI,EAAE,CAAC;QACb,4BAA4B;QAC5B,IAAI,WAAuB,CAAC;QAC5B,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,CAAC;YAClC,sDAAsD;YACtD,KAAK,GAAG,KAAmB,CAAC;YAC5B,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;YAC9B,WAAW,GAAG,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC;YAClC,kDAAkD;YAClD,gDAAgD;YAChD,YAAY;YACZ,K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CACnC,UAAsB,EACtB,UAAiE;IAEjE,IAAI,UAAU,CAAC,UAAU,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,yGAAyG;IACzG,gCAAgC;IAChC,MAAM,SAAS,GAAG,IAAI,GAAG,EAA0B,CAAC;IACpD,KAAK,IAAI,GAAG,GAAG,UAAU,CAAC,MAAM,EAAE,GAAG,KAAK,SAAS,EAAE,GAAG,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;QACvE,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,kBAAkB,CACxB,UAAU,EACV,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,EACtB,SAAS,CAAC,IAAI,KAAK,CAAC;QACnB,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,CAAC,IAAI,EAAqB,EAAE,CAC5B,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,kBAAU,CAAC,IAAI,CAAC,CAAC,CAAC,kBAAU,CAAC,QAAQ,EACrE,UAAU,CACV,CAAC;AACH,CAAC;AAxBD,oDAwBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type ISegmentLeaf, type MergeBlock, IMergeNode } from \"./mergeTreeNodes.js\";\n\nexport const LeafAction = {\n\tExit: false,\n} as const;\n\nexport type LeafAction = boolean | undefined | void;\n\nexport const NodeAction = {\n\tContinue: undefined,\n\t// exit is false to unify with leafActionOverride\n\tExit: LeafAction.Exit,\n\tSkip: 2,\n} as const;\n\n// we exclude true from, as we only want one continue value, undefined\nexport type NodeAction =\n\t| (typeof NodeAction)[keyof typeof NodeAction]\n\t| Exclude<LeafAction, true>;\n\n/**\n * Does a depth first walk of the tree from the specific start.\n *\n * @param startBlock - The block of the tree to start the walk from\n * @param startChild - The child of that block to start from\n * @param downAction - Called as we walk down the tree to the leaves.\n * @param leafActionOverride - Overrides downAction for leaves, generally used without downAction\n * @param upAction - Called after all the children of a block are walked.\n * @param forward - whether to walk forward or backward\n * @returns true if we naturally exit, false if exiting due to Exit action result\n */\nexport function depthFirstNodeWalk(\n\tstartBlock: MergeBlock,\n\tstartChild: IMergeNode | undefined,\n\tdownAction?: (node: IMergeNode) => NodeAction,\n\tleafActionOverride?: (seg: ISegmentLeaf) => LeafAction,\n\tupAction?: (block: MergeBlock) => void,\n\tforward: boolean = true,\n): boolean {\n\tconst increment = forward ? 1 : -1;\n\tconst leafAction = leafActionOverride ?? downAction;\n\tif (leafAction === undefined) {\n\t\treturn true;\n\t}\n\n\tlet block = startBlock;\n\tlet childCount = block.childCount;\n\tlet start: IMergeNode | undefined = startChild;\n\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\t// go down to the leaf level\n\t\tlet blockResult: NodeAction;\n\t\twhile (start?.isLeaf() === false) {\n\t\t\t// cast is safe due to isLeaf === false in while above\n\t\t\tblock = start as MergeBlock;\n\t\t\tchildCount = block.childCount;\n\t\t\tblockResult = downAction?.(block);\n\t\t\t// setting start undefined will skip the leaf walk\n\t\t\t// so if the block result isn't continue, set it\n\t\t\t// undefined\n\t\t\tstart =\n\t\t\t\tblockResult === NodeAction.Continue\n\t\t\t\t\t? block.children[forward ? 0 : childCount - 1]\n\t\t\t\t\t: undefined;\n\t\t}\n\n\t\tlet exit = blockResult === NodeAction.Exit;\n\n\t\t// walk the leaves if we reached them\n\t\tif (start !== undefined) {\n\t\t\tfor (let i = start.index; i !== -1 && i !== childCount; i += increment) {\n\t\t\t\t// the above loop ensures start is a leaf or undefined, so all children\n\t\t\t\t// will be leaves if start exits, so the cast is safe\n\t\t\t\tif (leafAction(block.children[i] as ISegmentLeaf) === LeafAction.Exit) {\n\t\t\t\t\texit = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// if there is no upAction, we don't need to walk up before exiting\n\t\tif (upAction === undefined && exit) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// since we already enumerated the children\n\t\t// we walk up to the next level until there is a sibling\n\t\t// or all the way up if exit is true\n\t\tlet nextIndex = -1;\n\t\tdo {\n\t\t\t// if the blockAction was exit or skip\n\t\t\t// we shouldn't process that block again,\n\t\t\t// if there are subsequent parents while walking up\n\t\t\t// we will process those.\n\t\t\tif (blockResult === NodeAction.Continue) {\n\t\t\t\tupAction?.(block);\n\t\t\t} else {\n\t\t\t\tblockResult = NodeAction.Continue;\n\t\t\t}\n\t\t\tif (block.parent === undefined) {\n\t\t\t\treturn !exit;\n\t\t\t}\n\t\t\tstart = block;\n\t\t\tblock = block.parent;\n\t\t\tchildCount = block.childCount;\n\t\t\tnextIndex = start.index + increment;\n\t\t} while (exit || nextIndex === -1 || nextIndex === childCount);\n\t\t// the above loop ensured that siblings are possible\n\t\tstart = block.children[nextIndex];\n\t}\n}\n\n/**\n * Visit segments starting from node's right/far/forward siblings, then up to node's parent.\n * All segments past `node` are visited, regardless of their visibility.\n */\nexport function forwardExcursion(\n\tstartNode: IMergeNode,\n\tleafAction: (seg: ISegmentLeaf) => boolean | undefined,\n): boolean {\n\tif (startNode.parent === undefined) {\n\t\treturn true;\n\t}\n\n\treturn depthFirstNodeWalk(\n\t\tstartNode.parent,\n\t\t// this will either be the sibling, or undefined\n\t\t// either is fine, and will result in skipping\n\t\t// the startNode only\n\t\tstartNode.parent.children[startNode.index + 1],\n\t\tundefined /* downAction */,\n\t\tleafAction,\n\t);\n}\n\n/**\n * Visit segments starting from node's left/near/backwards siblings, then up to node's parent.\n * All segments past `node` are visited, regardless of their visibility.\n */\nexport function backwardExcursion(\n\tstartNode: IMergeNode,\n\tleafAction: (seg: ISegmentLeaf) => boolean | undefined,\n): boolean {\n\tif (startNode.parent === undefined) {\n\t\treturn true;\n\t}\n\treturn depthFirstNodeWalk(\n\t\tstartNode.parent,\n\t\t// this will either be the sibling, or undefined\n\t\t// either is fine, and will result in skipping\n\t\t// the startNode only\n\t\tstartNode.parent.children[startNode.index - 1],\n\t\tundefined /* downAction */,\n\t\tleafAction,\n\t\tundefined /* upAction */,\n\t\tfalse /* forward */,\n\t);\n}\n\n/**\n * Walks all segments below the specific start block\n * @param startBlock - The block to start the walk at\n * @param leafAction - The action to perform on the leaves\n * @returns true if we naturally exit, false if exiting due to leaf action result\n */\nexport function walkAllChildSegments(\n\tstartBlock: MergeBlock,\n\tleafAction: (segment: ISegmentLeaf) => boolean | undefined | void,\n): boolean {\n\tif (startBlock.childCount === 0) {\n\t\treturn true;\n\t}\n\n\t// undefined shouldn't actually be added, but this allows subsequent check for `node.parent` to typecheck\n\t// without further runtime work.\n\tconst ancestors = new Set<MergeBlock | undefined>();\n\tfor (let cur = startBlock.parent; cur !== undefined; cur = cur.parent) {\n\t\tancestors.add(cur);\n\t}\n\n\treturn depthFirstNodeWalk(\n\t\tstartBlock,\n\t\tstartBlock.children[0],\n\t\tancestors.size === 0\n\t\t\t? undefined\n\t\t\t: (node): false | undefined =>\n\t\t\t\t\tancestors.has(node.parent) ? NodeAction.Exit : NodeAction.Continue,\n\t\tleafAction,\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mergeTreeNodeWalk.js","sourceRoot":"","sources":["../src/mergeTreeNodeWalk.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,uDAAoD;AAEvC,QAAA,UAAU,GAAG;IACzB,IAAI,EAAE,KAAK;CACF,CAAC;AAIE,QAAA,UAAU,GAAG;IACzB,QAAQ,EAAE,SAAS;IACnB,iDAAiD;IACjD,IAAI,EAAE,kBAAU,CAAC,IAAI;IACrB,IAAI,EAAE,CAAC;CACE,CAAC;AAOX;;;;;;;;;;GAUG;AACH,SAAgB,kBAAkB,CACjC,UAAsB,EACtB,UAAkC,EAClC,UAA6C,EAC7C,kBAAsD,EACtD,QAAsC,EACtC,UAAmB,IAAI;IAEvB,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAA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C,CAAC,CAAC,kBAAU,CAAC,IAAI,CAAC,CAAC,CAAC,kBAAU,CAAC,QAAQ,EACrE,UAAU,CACV,CAAC;AACH,CAAC;AAxBD,oDAwBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type ISegmentLeaf, type MergeBlock, IMergeNode } from \"./mergeTreeNodes.js\";\nimport { isMergeNodeInfo } from \"./segmentInfos.js\";\n\nexport const LeafAction = {\n\tExit: false,\n} as const;\n\nexport type LeafAction = boolean | undefined | void;\n\nexport const NodeAction = {\n\tContinue: undefined,\n\t// exit is false to unify with leafActionOverride\n\tExit: LeafAction.Exit,\n\tSkip: 2,\n} as const;\n\n// we exclude true from, as we only want one continue value, undefined\nexport type NodeAction =\n\t| (typeof NodeAction)[keyof typeof NodeAction]\n\t| Exclude<LeafAction, true>;\n\n/**\n * Does a depth first walk of the tree from the specific start.\n *\n * @param startBlock - The block of the tree to start the walk from\n * @param startChild - The child of that block to start from\n * @param downAction - Called as we walk down the tree to the leaves.\n * @param leafActionOverride - Overrides downAction for leaves, generally used without downAction\n * @param upAction - Called after all the children of a block are walked.\n * @param forward - whether to walk forward or backward\n * @returns true if we naturally exit, false if exiting due to Exit action result\n */\nexport function depthFirstNodeWalk(\n\tstartBlock: MergeBlock,\n\tstartChild: IMergeNode | undefined,\n\tdownAction?: (node: IMergeNode) => NodeAction,\n\tleafActionOverride?: (seg: ISegmentLeaf) => LeafAction,\n\tupAction?: (block: MergeBlock) => void,\n\tforward: boolean = true,\n): boolean {\n\tconst increment = forward ? 1 : -1;\n\tconst leafAction = leafActionOverride ?? downAction;\n\tif (leafAction === undefined) {\n\t\treturn true;\n\t}\n\n\tlet block = startBlock;\n\tlet childCount = block.childCount;\n\tlet start: IMergeNode | undefined = startChild;\n\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\t// go down to the leaf level\n\t\tlet blockResult: NodeAction;\n\t\twhile (start?.isLeaf() === false) {\n\t\t\t// cast is safe due to isLeaf === false in while above\n\t\t\tblock = start as MergeBlock;\n\t\t\tchildCount = block.childCount;\n\t\t\tblockResult = downAction?.(block);\n\t\t\t// setting start undefined will skip the leaf walk\n\t\t\t// so if the block result isn't continue, set it\n\t\t\t// undefined\n\t\t\tstart =\n\t\t\t\tblockResult === NodeAction.Continue\n\t\t\t\t\t? block.children[forward ? 0 : childCount - 1]\n\t\t\t\t\t: undefined;\n\t\t}\n\n\t\tlet exit = blockResult === NodeAction.Exit;\n\n\t\t// walk the leaves if we reached them\n\t\tif (start !== undefined) {\n\t\t\tfor (let i = start.index; i !== -1 && i !== childCount; i += increment) {\n\t\t\t\t// the above loop ensures start is a leaf or undefined, so all children\n\t\t\t\t// will be leaves if start exits, so the cast is safe\n\t\t\t\tif (leafAction(block.children[i] as ISegmentLeaf) === LeafAction.Exit) {\n\t\t\t\t\texit = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// if there is no upAction, we don't need to walk up before exiting\n\t\tif (upAction === undefined && exit) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// since we already enumerated the children\n\t\t// we walk up to the next level until there is a sibling\n\t\t// or all the way up if exit is true\n\t\tlet nextIndex = -1;\n\t\tdo {\n\t\t\t// if the blockAction was exit or skip\n\t\t\t// we shouldn't process that block again,\n\t\t\t// if there are subsequent parents while walking up\n\t\t\t// we will process those.\n\t\t\tif (blockResult === NodeAction.Continue) {\n\t\t\t\tupAction?.(block);\n\t\t\t} else {\n\t\t\t\tblockResult = NodeAction.Continue;\n\t\t\t}\n\t\t\tif (block.parent === undefined) {\n\t\t\t\treturn !exit;\n\t\t\t}\n\t\t\tstart = block;\n\t\t\tblock = block.parent;\n\t\t\tchildCount = block.childCount;\n\t\t\tnextIndex = start.index + increment;\n\t\t} while (exit || nextIndex === -1 || nextIndex === childCount);\n\t\t// the above loop ensured that siblings are possible\n\t\tstart = block.children[nextIndex];\n\t}\n}\n\n/**\n * Visit segments starting from node's right/far/forward siblings, then up to node's parent.\n * All segments past `node` are visited, regardless of their visibility.\n */\nexport function forwardExcursion(\n\tstartNode: IMergeNode,\n\tleafAction: (seg: ISegmentLeaf) => boolean | undefined,\n): boolean {\n\tif (!isMergeNodeInfo(startNode)) {\n\t\treturn true;\n\t}\n\n\treturn depthFirstNodeWalk(\n\t\tstartNode.parent,\n\t\t// this will either be the sibling, or undefined\n\t\t// either is fine, and will result in skipping\n\t\t// the startNode only\n\t\tstartNode.parent.children[startNode.index + 1],\n\t\tundefined /* downAction */,\n\t\tleafAction,\n\t);\n}\n\n/**\n * Visit segments starting from node's left/near/backwards siblings, then up to node's parent.\n * All segments past `node` are visited, regardless of their visibility.\n */\nexport function backwardExcursion(\n\tstartNode: IMergeNode,\n\tleafAction: (seg: ISegmentLeaf) => boolean | undefined,\n): boolean {\n\tif (!isMergeNodeInfo(startNode)) {\n\t\treturn true;\n\t}\n\treturn depthFirstNodeWalk(\n\t\tstartNode.parent,\n\t\t// this will either be the sibling, or undefined\n\t\t// either is fine, and will result in skipping\n\t\t// the startNode only\n\t\tstartNode.parent.children[startNode.index - 1],\n\t\tundefined /* downAction */,\n\t\tleafAction,\n\t\tundefined /* upAction */,\n\t\tfalse /* forward */,\n\t);\n}\n\n/**\n * Walks all segments below the specific start block\n * @param startBlock - The block to start the walk at\n * @param leafAction - The action to perform on the leaves\n * @returns true if we naturally exit, false if exiting due to leaf action result\n */\nexport function walkAllChildSegments(\n\tstartBlock: MergeBlock,\n\tleafAction: (segment: ISegmentLeaf) => boolean | undefined | void,\n): boolean {\n\tif (startBlock.childCount === 0) {\n\t\treturn true;\n\t}\n\n\t// undefined shouldn't actually be added, but this allows subsequent check for `node.parent` to typecheck\n\t// without further runtime work.\n\tconst ancestors = new Set<MergeBlock | undefined>();\n\tfor (let cur = startBlock.parent; cur !== undefined; cur = cur.parent) {\n\t\tancestors.add(cur);\n\t}\n\n\treturn depthFirstNodeWalk(\n\t\tstartBlock,\n\t\tstartBlock.children[0],\n\t\tancestors.size === 0\n\t\t\t? undefined\n\t\t\t: (node): false | undefined =>\n\t\t\t\t\tancestors.has(node.parent) ? NodeAction.Exit : NodeAction.Continue,\n\t\tleafAction,\n\t);\n}\n"]}
|
package/dist/mergeTreeNodes.d.ts
CHANGED
|
@@ -11,48 +11,46 @@ import type { PartialSequenceLengths } from "./partialLengths.js";
|
|
|
11
11
|
import { PropertySet, type MapLike } from "./properties.js";
|
|
12
12
|
import { ReferencePosition } from "./referencePositions.js";
|
|
13
13
|
import { SegmentGroupCollection } from "./segmentGroupCollection.js";
|
|
14
|
+
import { type IInsertionInfo, type IMergeNodeInfo, type SegmentWithInfo } from "./segmentInfos.js";
|
|
14
15
|
import { PropertiesManager } from "./segmentPropertiesManager.js";
|
|
15
|
-
/**
|
|
16
|
-
* Common properties for a node in a merge tree.
|
|
17
|
-
* @legacy
|
|
18
|
-
* @alpha
|
|
19
|
-
* @deprecated - This interface will be removed in 2.20 with no replacement.
|
|
20
|
-
*/
|
|
21
|
-
export interface IMergeNodeCommon {
|
|
22
|
-
/**
|
|
23
|
-
* The index of this node in its parent's list of children.
|
|
24
|
-
*/
|
|
25
|
-
index: number;
|
|
26
|
-
/**
|
|
27
|
-
* A string that can be used for comparing the location of this node to other `MergeNode`s in the same tree.
|
|
28
|
-
* `a.ordinal < b.ordinal` if and only if `a` comes before `b` in a pre-order traversal of the tree.
|
|
29
|
-
*/
|
|
30
|
-
ordinal: string;
|
|
31
|
-
isLeaf(): this is ISegment;
|
|
32
|
-
}
|
|
33
16
|
/**
|
|
34
17
|
* This interface exposes internal things to dds that leverage merge tree,
|
|
35
18
|
* like sequence and matrix.
|
|
36
19
|
*
|
|
37
20
|
* We use tiered interface to control visibility of segment properties.
|
|
38
|
-
* This sits between ISegment and
|
|
21
|
+
* This sits between ISegment and ISegmentPrivate. It should only expose
|
|
39
22
|
* things tagged internal.
|
|
40
23
|
*
|
|
24
|
+
* Everything added here beyond ISegment should be optional to keep the ability
|
|
25
|
+
* to implicitly convert between the tiered interfaces.
|
|
26
|
+
*
|
|
41
27
|
* @internal
|
|
42
28
|
*/
|
|
43
|
-
export
|
|
29
|
+
export interface ISegmentInternal extends ISegment {
|
|
44
30
|
localRefs?: LocalReferenceCollection;
|
|
45
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Whether or not this segment is a special segment denoting the start or
|
|
33
|
+
* end of the tree
|
|
34
|
+
*
|
|
35
|
+
* Endpoint segments are imaginary segments positioned immediately before or
|
|
36
|
+
* after the tree. These segments cannot be referenced by regular operations
|
|
37
|
+
* and exist primarily as a bucket for local references to slide onto during
|
|
38
|
+
* deletion of regular segments.
|
|
39
|
+
*/
|
|
40
|
+
readonly endpointType?: "start" | "end";
|
|
41
|
+
}
|
|
46
42
|
/**
|
|
47
43
|
* We use tiered interface to control visibility of segment properties.
|
|
48
44
|
* This is the lowest interface and is not exported, it site below ISegment and ISegmentInternal.
|
|
49
45
|
* It should only expose unexported things.
|
|
50
46
|
*
|
|
47
|
+
* Everything added here beyond ISegmentInternal should be optional to keep the ability
|
|
48
|
+
* to implicitly convert between the tiered interfaces.
|
|
49
|
+
*
|
|
51
50
|
* someday we may split tree leaves from segments, but for now they are the same
|
|
52
51
|
* this is just a convenience type that makes it clear that we need something that is both a segment and a leaf node
|
|
53
52
|
*/
|
|
54
|
-
export
|
|
55
|
-
parent?: MergeBlock;
|
|
53
|
+
export interface ISegmentPrivate extends ISegmentInternal {
|
|
56
54
|
segmentGroups?: SegmentGroupCollection;
|
|
57
55
|
propertyManager?: PropertiesManager;
|
|
58
56
|
/**
|
|
@@ -61,100 +59,49 @@ export type ISegmentLeaf = ISegmentInternal & {
|
|
|
61
59
|
* then the segment is not obliterated because it is aware of the latest obliteration.
|
|
62
60
|
*/
|
|
63
61
|
prevObliterateByInserter?: ObliterateInfo;
|
|
64
|
-
}
|
|
65
|
-
export type IMergeNode = MergeBlock | ISegmentLeaf;
|
|
62
|
+
}
|
|
66
63
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
64
|
+
* Segment leafs are segments that have both IMergeNodeInfo and IInsertionInfo. This means they
|
|
65
|
+
* are inserted at a position, and bound via their parent MergeBlock to the merge tree. MergeBlocks'
|
|
66
|
+
* children are either a segment leaf, or another merge block for interior nodes of the tree. When working
|
|
67
|
+
* within the tree it is generally unnecessary to use type coercions methods common to the infos, and segment
|
|
68
|
+
* leafs, as the children of MergeBlocks are already well typed. However, when segments come from outside the
|
|
69
|
+
* merge tree, like via client's public methods, it becomes necessary to use the type coercions methods
|
|
70
|
+
* to ensure the passed in segment objects are correctly bound to the merge tree.
|
|
71
71
|
*/
|
|
72
|
-
export
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
removedSeq: number;
|
|
81
|
-
/**
|
|
82
|
-
* List of client IDs that have removed this segment.
|
|
83
|
-
* The client that actually removed the segment (i.e. whose removal op was sequenced first) is stored as the first
|
|
84
|
-
* client in this list. Other clients in the list have all issued concurrent ops to remove the segment.
|
|
85
|
-
* @remarks When this list has length \> 1, this is referred to as the "overlapping remove" case.
|
|
86
|
-
*/
|
|
87
|
-
removedClientIds: number[];
|
|
88
|
-
}
|
|
72
|
+
export type ISegmentLeaf = SegmentWithInfo<IMergeNodeInfo & IInsertionInfo>;
|
|
73
|
+
/**
|
|
74
|
+
* A type-guard which determines if the segment has segment leaf, and
|
|
75
|
+
* returns true if it does, along with applying strong typing.
|
|
76
|
+
* @param nodeLike - The segment-like object to check.
|
|
77
|
+
* @returns True if the segment is a segment leaf, otherwise false.
|
|
78
|
+
*/
|
|
79
|
+
export declare const isSegmentLeaf: (segmentLike: unknown) => segmentLike is ISegmentLeaf;
|
|
89
80
|
/**
|
|
90
|
-
*
|
|
81
|
+
* Converts a segment-like object to a segment leaf object if possible.
|
|
91
82
|
*
|
|
92
|
-
* @
|
|
83
|
+
* @param segmentLike - The segment-like object to convert.
|
|
84
|
+
* @returns The segment leaf if the conversion is possible, otherwise undefined.
|
|
93
85
|
*/
|
|
94
|
-
export declare
|
|
86
|
+
export declare const toSegmentLeaf: (segmentLike: unknown) => ISegmentLeaf | undefined;
|
|
95
87
|
/**
|
|
96
|
-
*
|
|
88
|
+
* Asserts that the segment is a segment leaf. Usage of this function should not produce a user facing error.
|
|
97
89
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* in the future, when moves _are_ supported.
|
|
101
|
-
* @legacy
|
|
102
|
-
* @alpha
|
|
103
|
-
* @deprecated - This interface will be removed in 2.20 with no replacement.
|
|
90
|
+
* @param segmentLike - The segment-like object to check.
|
|
91
|
+
* @throws Will throw an error if the segment is not a segment leaf.
|
|
104
92
|
*/
|
|
105
|
-
export
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
* concurrent moves this array will contain multiple seqs.
|
|
118
|
-
*
|
|
119
|
-
* The seq at `movedSeqs[i]` corresponds to the client id at `movedClientIds[i]`.
|
|
120
|
-
*
|
|
121
|
-
* The first element corresponds to the seq of the first move
|
|
122
|
-
*/
|
|
123
|
-
movedSeqs: number[];
|
|
124
|
-
/**
|
|
125
|
-
* A reference to the inserted destination segment corresponding to this
|
|
126
|
-
* segment's move.
|
|
127
|
-
*
|
|
128
|
-
* If undefined, the move was an obliterate.
|
|
129
|
-
*
|
|
130
|
-
* Currently this field is unused, as we only support obliterate operations
|
|
131
|
-
*/
|
|
132
|
-
moveDst?: ReferencePosition;
|
|
133
|
-
/**
|
|
134
|
-
* List of client IDs that have moved this segment.
|
|
135
|
-
*
|
|
136
|
-
* The client that actually moved the segment (i.e. whose move op was sequenced
|
|
137
|
-
* first) is stored as the first client in this list. Other clients in the
|
|
138
|
-
* list have all issued concurrent ops to move the segment.
|
|
139
|
-
*/
|
|
140
|
-
movedClientIds: number[];
|
|
141
|
-
/**
|
|
142
|
-
* If this segment was inserted into a concurrently moved range and
|
|
143
|
-
* the move op was sequenced before the insertion op. In this case,
|
|
144
|
-
* the segment is visible only to the inserting client
|
|
145
|
-
*
|
|
146
|
-
* `wasMovedOnInsert` only applies for acked obliterates. That is, if
|
|
147
|
-
* a segment inserted by a remote client is moved on insertion by a local
|
|
148
|
-
* and unacked obliterate, we do not consider it as having been moved
|
|
149
|
-
* on insert
|
|
150
|
-
*
|
|
151
|
-
* If a segment is moved on insertion, its length is only ever visible to
|
|
152
|
-
* the client that inserted the segment. This is relevant in partial length
|
|
153
|
-
* calculations
|
|
154
|
-
*/
|
|
155
|
-
wasMovedOnInsert: boolean;
|
|
156
|
-
}
|
|
157
|
-
export declare function toMoveInfo(maybe: Partial<IMoveInfo> | undefined): IMoveInfo | undefined;
|
|
93
|
+
export declare const assertSegmentLeaf: (segmentLike: unknown) => asserts segmentLike is ISegmentLeaf;
|
|
94
|
+
/**
|
|
95
|
+
* This type is used for building MergeBlocks from segments and other MergeBlocks. We need this
|
|
96
|
+
* type as segments may not yet be bound to the tree, so lack merge node info which is required for
|
|
97
|
+
* segment leafs.
|
|
98
|
+
*/
|
|
99
|
+
export type IMergeNodeBuilder = MergeBlock | SegmentWithInfo<IInsertionInfo>;
|
|
100
|
+
/**
|
|
101
|
+
* This type is used by MergeBlocks to define their children, which are either segments or other
|
|
102
|
+
* MergeBlocks.
|
|
103
|
+
*/
|
|
104
|
+
export type IMergeNode = MergeBlock | ISegmentLeaf;
|
|
158
105
|
/**
|
|
159
106
|
* A segment representing a portion of the merge tree.
|
|
160
107
|
* Segments are leaf nodes of the merge tree and contain data.
|
|
@@ -164,17 +111,6 @@ export declare function toMoveInfo(maybe: Partial<IMoveInfo> | undefined): IMove
|
|
|
164
111
|
export interface ISegment {
|
|
165
112
|
readonly type: string;
|
|
166
113
|
readonly trackingCollection: TrackingGroupCollection;
|
|
167
|
-
/**
|
|
168
|
-
* Whether or not this segment is a special segment denoting the start or
|
|
169
|
-
* end of the tree
|
|
170
|
-
*
|
|
171
|
-
* Endpoint segments are imaginary segments positioned immediately before or
|
|
172
|
-
* after the tree. These segments cannot be referenced by regular operations
|
|
173
|
-
* and exist primarily as a bucket for local references to slide onto during
|
|
174
|
-
* deletion of regular segments.
|
|
175
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
176
|
-
*/
|
|
177
|
-
readonly endpointType?: "start" | "end";
|
|
178
114
|
/**
|
|
179
115
|
* The length of the contents of the node.
|
|
180
116
|
*/
|
|
@@ -195,44 +131,6 @@ export interface ISegment {
|
|
|
195
131
|
* or only attribute certain property modifications, etc.)
|
|
196
132
|
*/
|
|
197
133
|
attribution?: IAttributionCollection<AttributionKey>;
|
|
198
|
-
/**
|
|
199
|
-
* Local seq at which this segment was inserted.
|
|
200
|
-
* This is defined if and only if the insertion of the segment is pending ack, i.e. `seq` is UnassignedSequenceNumber.
|
|
201
|
-
* Once the segment is acked, this field is cleared.
|
|
202
|
-
*
|
|
203
|
-
* @privateRemarks
|
|
204
|
-
* See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.
|
|
205
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
206
|
-
*/
|
|
207
|
-
localSeq?: number;
|
|
208
|
-
/**
|
|
209
|
-
* Local seq at which this segment was removed. If this is defined, `removedSeq` will initially be set to
|
|
210
|
-
* UnassignedSequenceNumber. However, if another client concurrently removes the same segment, `removedSeq`
|
|
211
|
-
* will be updated to the seq at which that client removed this segment.
|
|
212
|
-
*
|
|
213
|
-
* Like {@link ISegment.localSeq}, this field is cleared once the local removal of the segment is acked.
|
|
214
|
-
*
|
|
215
|
-
* @privateRemarks
|
|
216
|
-
* See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.
|
|
217
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
218
|
-
*/
|
|
219
|
-
localRemovedSeq?: number;
|
|
220
|
-
/**
|
|
221
|
-
* Seq at which this segment was inserted.
|
|
222
|
-
* If undefined, it is assumed the segment was inserted prior to the collab window's minimum sequence number.
|
|
223
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
224
|
-
*/
|
|
225
|
-
seq?: number;
|
|
226
|
-
/**
|
|
227
|
-
* Short clientId for the client that inserted this segment.
|
|
228
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
229
|
-
*/
|
|
230
|
-
clientId: number;
|
|
231
|
-
/**
|
|
232
|
-
* Local references added to this segment.
|
|
233
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
234
|
-
*/
|
|
235
|
-
localRefs?: LocalReferenceCollection;
|
|
236
134
|
/**
|
|
237
135
|
* Properties that have been added to this segment via annotation.
|
|
238
136
|
*/
|
|
@@ -243,56 +141,6 @@ export interface ISegment {
|
|
|
243
141
|
splitAt(pos: number): ISegment | undefined;
|
|
244
142
|
toJSONObject(): any;
|
|
245
143
|
isLeaf(): this is ISegment;
|
|
246
|
-
/**
|
|
247
|
-
* {@inheritDoc @fluidframework/merge-tree#IMergeNodeCommon.index}
|
|
248
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
249
|
-
*/
|
|
250
|
-
index: number;
|
|
251
|
-
/**
|
|
252
|
-
* {@inheritDoc @fluidframework/merge-tree#IMergeNodeCommon.ordinal}
|
|
253
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
254
|
-
*/
|
|
255
|
-
ordinal: string;
|
|
256
|
-
/**
|
|
257
|
-
* {@inheritDoc @fluidframework/merge-tree#IRemovalInfo.removedSeq}
|
|
258
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
259
|
-
*/
|
|
260
|
-
removedSeq?: number;
|
|
261
|
-
/**
|
|
262
|
-
* {@inheritDoc @fluidframework/merge-tree#IRemovalInfo.removedClientIds}
|
|
263
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
264
|
-
*/
|
|
265
|
-
removedClientIds?: number[];
|
|
266
|
-
/**
|
|
267
|
-
* {@inheritDoc @fluidframework/merge-tree#IMoveInfo.localMovedSeq}
|
|
268
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
269
|
-
*/
|
|
270
|
-
localMovedSeq?: number;
|
|
271
|
-
/**
|
|
272
|
-
* {@inheritDoc @fluidframework/merge-tree#IMoveInfo.movedSeq}
|
|
273
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
274
|
-
*/
|
|
275
|
-
movedSeq?: number;
|
|
276
|
-
/**
|
|
277
|
-
* {@inheritDoc @fluidframework/merge-tree#IMoveInfo.movedSeqs}
|
|
278
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
279
|
-
*/
|
|
280
|
-
movedSeqs?: number[];
|
|
281
|
-
/**
|
|
282
|
-
* {@inheritDoc @fluidframework/merge-tree#IMoveInfo.moveDst}
|
|
283
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
284
|
-
*/
|
|
285
|
-
moveDst?: ReferencePosition;
|
|
286
|
-
/**
|
|
287
|
-
* {@inheritDoc @fluidframework/merge-tree#IMoveInfo.movedClientIds}
|
|
288
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
289
|
-
*/
|
|
290
|
-
movedClientIds?: number[];
|
|
291
|
-
/**
|
|
292
|
-
* {@inheritDoc @fluidframework/merge-tree#IMoveInfo.wasMovedOnInsert}
|
|
293
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
294
|
-
*/
|
|
295
|
-
wasMovedOnInsert?: boolean;
|
|
296
144
|
}
|
|
297
145
|
/**
|
|
298
146
|
* Determine if a segment has been removed.
|
|
@@ -300,12 +148,6 @@ export interface ISegment {
|
|
|
300
148
|
* @alpha
|
|
301
149
|
*/
|
|
302
150
|
export declare function segmentIsRemoved(segment: ISegment): boolean;
|
|
303
|
-
/**
|
|
304
|
-
* @internal
|
|
305
|
-
*/
|
|
306
|
-
export interface IMarkerModifiedAction {
|
|
307
|
-
(marker: Marker): void;
|
|
308
|
-
}
|
|
309
151
|
/**
|
|
310
152
|
* @legacy
|
|
311
153
|
* @alpha
|
|
@@ -313,46 +155,15 @@ export interface IMarkerModifiedAction {
|
|
|
313
155
|
export interface ISegmentAction<TClientData> {
|
|
314
156
|
(segment: ISegment, pos: number, refSeq: number, clientId: number, start: number, end: number, accum: TClientData): boolean;
|
|
315
157
|
}
|
|
316
|
-
/**
|
|
317
|
-
* @internal
|
|
318
|
-
*/
|
|
319
158
|
export interface ISegmentChanges {
|
|
320
|
-
next?:
|
|
321
|
-
replaceCurrent?:
|
|
159
|
+
next?: SegmentWithInfo<IInsertionInfo>;
|
|
160
|
+
replaceCurrent?: SegmentWithInfo<IInsertionInfo>;
|
|
322
161
|
}
|
|
323
|
-
/**
|
|
324
|
-
* @internal
|
|
325
|
-
*/
|
|
326
|
-
export interface BlockAction<TClientData> {
|
|
327
|
-
(block: MergeBlock, pos: number, refSeq: number, clientId: number, start: number | undefined, end: number | undefined, accum: TClientData): boolean;
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* @internal
|
|
331
|
-
*/
|
|
332
|
-
export interface NodeAction<TClientData> {
|
|
333
|
-
(node: IMergeNode, pos: number, refSeq: number, clientId: number, start: number | undefined, end: number | undefined, clientData: TClientData): boolean;
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* @internal
|
|
337
|
-
*/
|
|
338
162
|
export interface InsertContext {
|
|
339
|
-
candidateSegment?:
|
|
340
|
-
leaf: (segment:
|
|
163
|
+
candidateSegment?: SegmentWithInfo<IInsertionInfo>;
|
|
164
|
+
leaf: (segment: ISegmentLeaf | undefined, pos: number, ic: InsertContext) => ISegmentChanges;
|
|
341
165
|
continuePredicate?: (continueFromBlock: MergeBlock) => boolean;
|
|
342
166
|
}
|
|
343
|
-
/**
|
|
344
|
-
* @internal
|
|
345
|
-
*/
|
|
346
|
-
export interface SegmentActions<TClientData> {
|
|
347
|
-
leaf?: ISegmentAction<TClientData>;
|
|
348
|
-
shift?: NodeAction<TClientData>;
|
|
349
|
-
contains?: NodeAction<TClientData>;
|
|
350
|
-
pre?: BlockAction<TClientData>;
|
|
351
|
-
post?: BlockAction<TClientData>;
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* @internal
|
|
355
|
-
*/
|
|
356
167
|
export interface ObliterateInfo {
|
|
357
168
|
start: LocalReferencePosition;
|
|
358
169
|
end: LocalReferencePosition;
|
|
@@ -362,11 +173,8 @@ export interface ObliterateInfo {
|
|
|
362
173
|
localSeq: number | undefined;
|
|
363
174
|
segmentGroup: SegmentGroup | undefined;
|
|
364
175
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
*/
|
|
368
|
-
export interface SegmentGroup<S extends ISegmentInternal = ISegmentInternal> {
|
|
369
|
-
segments: S[];
|
|
176
|
+
export interface SegmentGroup {
|
|
177
|
+
segments: ISegmentLeaf[];
|
|
370
178
|
previousProps?: PropertySet[];
|
|
371
179
|
localSeq?: number;
|
|
372
180
|
refSeq: number;
|
|
@@ -377,13 +185,9 @@ export interface SegmentGroup<S extends ISegmentInternal = ISegmentInternal> {
|
|
|
377
185
|
* the MergeTree always inserts first, then checks for overflow and splits if the child count equals
|
|
378
186
|
* `MaxNodesInBlock`. (i.e., `MaxNodesInBlock` contains 1 extra slot for temporary storage to
|
|
379
187
|
* facilitate splits.)
|
|
380
|
-
* @internal
|
|
381
188
|
*/
|
|
382
189
|
export declare const MaxNodesInBlock = 8;
|
|
383
|
-
|
|
384
|
-
* @internal
|
|
385
|
-
*/
|
|
386
|
-
export declare class MergeBlock implements IMergeNodeCommon {
|
|
190
|
+
export declare class MergeBlock implements Partial<IMergeNodeInfo> {
|
|
387
191
|
childCount: number;
|
|
388
192
|
children: IMergeNode[];
|
|
389
193
|
needsScour?: boolean;
|
|
@@ -415,76 +219,20 @@ export declare class MergeBlock implements IMergeNodeCommon {
|
|
|
415
219
|
partialLengths?: PartialSequenceLengths;
|
|
416
220
|
constructor(childCount: number);
|
|
417
221
|
setOrdinal(child: IMergeNode, index: number): void;
|
|
418
|
-
assignChild(child: IMergeNode, index: number, updateOrdinal?: boolean): void;
|
|
419
222
|
}
|
|
223
|
+
export declare function assignChild<C extends IMergeNodeBuilder>(parent: MergeBlock, child: C, index: number, updateOrdinal?: boolean): asserts child is C & IMergeNodeInfo;
|
|
420
224
|
export declare function seqLTE(seq: number, minOrRefSeq: number): boolean;
|
|
421
225
|
/**
|
|
422
226
|
* @legacy
|
|
423
227
|
* @alpha
|
|
424
228
|
*/
|
|
425
229
|
export declare abstract class BaseSegment implements ISegment {
|
|
426
|
-
/**
|
|
427
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
428
|
-
*/
|
|
429
|
-
clientId: number;
|
|
430
|
-
/**
|
|
431
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
432
|
-
*/
|
|
433
|
-
seq: number;
|
|
434
|
-
/**
|
|
435
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
436
|
-
*/
|
|
437
|
-
removedSeq?: number;
|
|
438
|
-
/**
|
|
439
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
440
|
-
*/
|
|
441
|
-
removedClientIds?: number[];
|
|
442
|
-
/**
|
|
443
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
444
|
-
*/
|
|
445
|
-
movedSeq?: number;
|
|
446
|
-
/**
|
|
447
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
448
|
-
*/
|
|
449
|
-
movedSeqs?: number[];
|
|
450
|
-
/**
|
|
451
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
452
|
-
*/
|
|
453
|
-
movedClientIds?: number[];
|
|
454
|
-
/**
|
|
455
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
456
|
-
*/
|
|
457
|
-
wasMovedOnInsert?: boolean | undefined;
|
|
458
|
-
/**
|
|
459
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
460
|
-
*/
|
|
461
|
-
index: number;
|
|
462
|
-
/**
|
|
463
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
464
|
-
*/
|
|
465
|
-
ordinal: string;
|
|
466
230
|
cachedLength: number;
|
|
467
231
|
readonly trackingCollection: TrackingGroupCollection;
|
|
468
232
|
/***/
|
|
469
233
|
attribution?: IAttributionCollection<AttributionKey>;
|
|
470
234
|
properties?: PropertySet;
|
|
471
|
-
/**
|
|
472
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
473
|
-
*/
|
|
474
|
-
localRefs?: LocalReferenceCollection;
|
|
475
235
|
abstract readonly type: string;
|
|
476
|
-
/**
|
|
477
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
478
|
-
*/
|
|
479
|
-
localSeq?: number;
|
|
480
|
-
/**
|
|
481
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
482
|
-
*/
|
|
483
|
-
localRemovedSeq?: number;
|
|
484
|
-
/**
|
|
485
|
-
* @deprecated - This property will be removed in 2.20 with no replacement.
|
|
486
|
-
*/
|
|
487
|
-
localMovedSeq?: number;
|
|
488
236
|
constructor(properties?: PropertySet);
|
|
489
237
|
hasProperty(key: string): boolean;
|
|
490
238
|
isLeaf(): this is ISegment;
|
|
@@ -587,7 +335,7 @@ export declare class CollaborationWindow {
|
|
|
587
335
|
* { localSeq: 1, seq: UnassignedSequenceNumber, text: "C" },
|
|
588
336
|
* ]
|
|
589
337
|
* ```
|
|
590
|
-
* (note that
|
|
338
|
+
* (note that localSeq tracks the localSeq at which a segment was inserted)
|
|
591
339
|
*
|
|
592
340
|
* Suppose the client then disconnects and reconnects before any of its insertions are acked. The reconnect flow will necessitate
|
|
593
341
|
* that the client regenerates and resubmits ops based on its current segment state as well as the original op that was sent.
|
|
@@ -639,12 +387,4 @@ export declare const compareNumbers: (a: number, b: number) => number;
|
|
|
639
387
|
* Compares two strings.
|
|
640
388
|
*/
|
|
641
389
|
export declare const compareStrings: (a: string, b: string) => number;
|
|
642
|
-
/**
|
|
643
|
-
* Get a human-readable string for a given {@link Marker}.
|
|
644
|
-
*
|
|
645
|
-
* @remarks This function is intended for debugging only. The exact format of
|
|
646
|
-
* this string should not be relied upon between versions.
|
|
647
|
-
* @internal
|
|
648
|
-
*/
|
|
649
|
-
export declare function debugMarkerToString(marker: Marker): string;
|
|
650
390
|
//# sourceMappingURL=mergeTreeNodes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeTreeNodes.d.ts","sourceRoot":"","sources":["../src/mergeTreeNodes.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"mergeTreeNodes.d.ts","sourceRoot":"","sources":["../src/mergeTreeNodes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAE9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAAE,wBAAwB,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAoB,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAON,KAAK,cAAc,EACnB,KAAK,cAAc,EAGnB,KAAK,eAAe,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE;;;;;;;;;;;;GAYG;AACH,MAAM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