@fluidframework/merge-tree 2.0.0-rc.1.0.2 → 2.0.0-rc.1.0.4
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/dist/mergeTree.d.ts.map +1 -1
- package/dist/mergeTree.js +6 -1
- package/dist/mergeTree.js.map +1 -1
- package/dist/sortedSegmentSet.d.ts.map +1 -1
- package/dist/sortedSegmentSet.js +5 -3
- package/dist/sortedSegmentSet.js.map +1 -1
- package/dist/test/client.localReference.spec.js +77 -46
- package/dist/test/client.localReference.spec.js.map +1 -1
- package/dist/test/client.rollback.spec.js +1 -1
- package/dist/test/client.rollback.spec.js.map +1 -1
- package/dist/test/client.searchForMarker.spec.js +51 -0
- package/dist/test/client.searchForMarker.spec.js.map +1 -1
- package/lib/mergeTree.d.mts.map +1 -1
- package/lib/mergeTree.mjs +6 -1
- package/lib/mergeTree.mjs.map +1 -1
- package/lib/sortedSegmentSet.d.mts.map +1 -1
- package/lib/sortedSegmentSet.mjs +5 -3
- package/lib/sortedSegmentSet.mjs.map +1 -1
- package/package.json +14 -14
- package/src/mergeTree.ts +9 -4
- package/src/sortedSegmentSet.ts +5 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortedSegmentSet.d.mts","sourceRoot":"","sources":["../src/sortedSegmentSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,sBAAsB,EAAE;OAC1B,EAAE,QAAQ,EAAE;OAEZ,EAAE,SAAS,EAAE;AAEpB;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAC7B,QAAQ,GACR,sBAAsB,GACtB;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;AAElC;;;;;;;;;;;;GAYG;AAEH,qBAAa,gBAAgB,CAAC,CAAC,SAAS,oBAAoB,GAAG,QAAQ,CAAE,SAAQ,SAAS,CACzF,CAAC,EACD,MAAM,CACN;IACA,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"sortedSegmentSet.d.mts","sourceRoot":"","sources":["../src/sortedSegmentSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,sBAAsB,EAAE;OAC1B,EAAE,QAAQ,EAAE;OAEZ,EAAE,SAAS,EAAE;AAEpB;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAC7B,QAAQ,GACR,sBAAsB,GACtB;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;AAElC;;;;;;;;;;;;GAYG;AAEH,qBAAa,gBAAgB,CAAC,CAAC,SAAS,oBAAoB,GAAG,QAAQ,CAAE,SAAQ,SAAS,CACzF,CAAC,EACD,MAAM,CACN;IACA,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,MAAM;IAmBjC,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,GAAG;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;CAqDvE"}
|
package/lib/sortedSegmentSet.mjs
CHANGED
|
@@ -22,9 +22,11 @@ export class SortedSegmentSet extends SortedSet {
|
|
|
22
22
|
const maybeRef = item;
|
|
23
23
|
if (maybeRef.getSegment !== undefined && maybeRef.isLeaf?.() === false) {
|
|
24
24
|
const lref = maybeRef;
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
// If the reference position has no associated segment, assign it a sentinel value.
|
|
26
|
+
// The particular value for comparison doesn't matter because `findItemPosition` tolerates
|
|
27
|
+
// elements with duplicate keys (as it must, since local references use the same key as their segment).
|
|
28
|
+
// All that matters is that it's consistent.
|
|
29
|
+
return lref.getSegment()?.ordinal ?? "";
|
|
28
30
|
}
|
|
29
31
|
const maybeObject = item;
|
|
30
32
|
if (maybeObject?.segment) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortedSegmentSet.mjs","sourceRoot":"","sources":["../src/sortedSegmentSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAKI,EAAE,SAAS,EAAE;AAWpB;;;;;;;;;;;;GAYG;AACH,gDAAgD;AAChD,MAAM,OAAO,gBAA4D,SAAQ,SAGhF;IACU,MAAM,CAAC,IAAO;QACvB,MAAM,QAAQ,GAAG,IAAuC,CAAC;QACzD,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE,KAAK,KAAK,EAAE;YACvE,MAAM,IAAI,GAAG,QAAkC,CAAC;YAChD,
|
|
1
|
+
{"version":3,"file":"sortedSegmentSet.mjs","sourceRoot":"","sources":["../src/sortedSegmentSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAKI,EAAE,SAAS,EAAE;AAWpB;;;;;;;;;;;;GAYG;AACH,gDAAgD;AAChD,MAAM,OAAO,gBAA4D,SAAQ,SAGhF;IACU,MAAM,CAAC,IAAO;QACvB,MAAM,QAAQ,GAAG,IAAuC,CAAC;QACzD,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE,KAAK,KAAK,EAAE;YACvE,MAAM,IAAI,GAAG,QAAkC,CAAC;YAChD,mFAAmF;YACnF,0FAA0F;YAC1F,uGAAuG;YACvG,4CAA4C;YAC5C,OAAO,IAAI,CAAC,UAAU,EAAE,EAAE,OAAO,IAAI,EAAE,CAAC;SACxC;QACD,MAAM,WAAW,GAAG,IAAsC,CAAC;QAC3D,IAAI,WAAW,EAAE,OAAO,EAAE;YACzB,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC;SACnC;QAED,MAAM,YAAY,GAAG,IAAgB,CAAC;QACtC,OAAO,YAAY,CAAC,OAAO,CAAC;IAC7B,CAAC;IAES,gBAAgB,CAAC,IAAO;QACjC,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;YACrC,OAAO,EAAE,MAAM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AAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,EACzD,CAAC,EAAE,EACF;oBACD,IAAI,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;wBACpC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;qBAClC;iBACD;gBACD,KACC,KAAK,GAAG,CAAC,EACT,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM;oBAClC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,KAAK,OAAO,EACnD,KAAK,EAAE,EACN;oBACD,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;wBACxC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;qBAC/B;iBACD;gBACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;aAChC;SACD;QACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IACjC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { LocalReferencePosition } from \"./localReference\";\nimport { ISegment } from \"./mergeTreeNodes\";\n// eslint-disable-next-line import/no-deprecated\nimport { SortedSet } from \"./sortedSet\";\n\n/**\n * @deprecated This functionality was not meant to be exported and will be removed in a future release\n * @internal\n */\nexport type SortedSegmentSetItem =\n\t| ISegment\n\t| LocalReferencePosition\n\t| { readonly segment: ISegment };\n\n/**\n * Stores a unique and sorted set of segments, or objects with segments\n *\n * This differs from a normal sorted set in that the keys are not fixed.\n * The segments are sorted via their ordinals which can change as the merge tree is modified.\n * Even though the values of the ordinals can change their ordering and uniqueness cannot, so the order of a set of\n * segments ordered by their ordinals will always have the same order even if the ordinal values on\n * the segments changes. This invariant allows us to ensure the segments stay\n * ordered and unique, and that new segments can be inserted into that order.\n *\n * @deprecated This functionality was not meant to be exported and will be removed in a future release\n * @internal\n */\n// eslint-disable-next-line import/no-deprecated\nexport class SortedSegmentSet<T extends SortedSegmentSetItem = ISegment> extends SortedSet<\n\tT,\n\tstring\n> {\n\tprotected getKey(item: T): string {\n\t\tconst maybeRef = item as Partial<LocalReferencePosition>;\n\t\tif (maybeRef.getSegment !== undefined && maybeRef.isLeaf?.() === false) {\n\t\t\tconst lref = maybeRef as LocalReferencePosition;\n\t\t\t// If the reference position has no associated segment, assign it a sentinel value.\n\t\t\t// The particular value for comparison doesn't matter because `findItemPosition` tolerates\n\t\t\t// elements with duplicate keys (as it must, since local references use the same key as their segment).\n\t\t\t// All that matters is that it's consistent.\n\t\t\treturn lref.getSegment()?.ordinal ?? \"\";\n\t\t}\n\t\tconst maybeObject = item as { readonly segment: ISegment };\n\t\tif (maybeObject?.segment) {\n\t\t\treturn maybeObject.segment.ordinal;\n\t\t}\n\n\t\tconst maybeSegment = item as ISegment;\n\t\treturn maybeSegment.ordinal;\n\t}\n\n\tprotected findItemPosition(item: T): { exists: boolean; index: number } {\n\t\tif (this.keySortedItems.length === 0) {\n\t\t\treturn { exists: false, index: 0 };\n\t\t}\n\t\tlet start = 0;\n\t\tlet end = this.keySortedItems.length - 1;\n\t\tconst itemKey = this.getKey(item);\n\t\tlet index = -1;\n\n\t\twhile (start <= end) {\n\t\t\tindex = start + Math.floor((end - start) / 2);\n\t\t\tconst indexKey = this.getKey(this.keySortedItems[index]);\n\t\t\tif (indexKey > itemKey) {\n\t\t\t\tif (start === index) {\n\t\t\t\t\treturn { exists: false, index };\n\t\t\t\t}\n\t\t\t\tend = index - 1;\n\t\t\t} else if (indexKey < itemKey) {\n\t\t\t\tif (index === end) {\n\t\t\t\t\treturn { exists: false, index: index + 1 };\n\t\t\t\t}\n\t\t\t\tstart = index + 1;\n\t\t\t} else if (indexKey === itemKey) {\n\t\t\t\t// at this point we've found the key of the item\n\t\t\t\t// so we need to find the index of the item instance\n\t\t\t\t//\n\t\t\t\tif (item === this.keySortedItems[index]) {\n\t\t\t\t\treturn { exists: true, index };\n\t\t\t\t}\n\t\t\t\tfor (\n\t\t\t\t\tlet b = index - 1;\n\t\t\t\t\tb >= 0 && this.getKey(this.keySortedItems[b]) === itemKey;\n\t\t\t\t\tb--\n\t\t\t\t) {\n\t\t\t\t\tif (this.keySortedItems[b] === item) {\n\t\t\t\t\t\treturn { exists: true, index: b };\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (\n\t\t\t\t\tindex + 1;\n\t\t\t\t\tindex < this.keySortedItems.length &&\n\t\t\t\t\tthis.getKey(this.keySortedItems[index]) === itemKey;\n\t\t\t\t\tindex++\n\t\t\t\t) {\n\t\t\t\t\tif (this.keySortedItems[index] === item) {\n\t\t\t\t\t\treturn { exists: true, index };\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn { exists: false, index };\n\t\t\t}\n\t\t}\n\t\treturn { exists: false, index };\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/merge-tree",
|
|
3
|
-
"version": "2.0.0-rc.1.0.
|
|
3
|
+
"version": "2.0.0-rc.1.0.4",
|
|
4
4
|
"description": "Merge tree",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -97,29 +97,29 @@
|
|
|
97
97
|
"temp-directory": "nyc/.nyc_output"
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"@fluid-internal/client-utils": ">=2.0.0-rc.1.0.
|
|
101
|
-
"@fluidframework/container-definitions": ">=2.0.0-rc.1.0.
|
|
102
|
-
"@fluidframework/core-interfaces": ">=2.0.0-rc.1.0.
|
|
103
|
-
"@fluidframework/core-utils": ">=2.0.0-rc.1.0.
|
|
104
|
-
"@fluidframework/datastore-definitions": ">=2.0.0-rc.1.0.
|
|
100
|
+
"@fluid-internal/client-utils": ">=2.0.0-rc.1.0.4 <2.0.0-rc.1.1.0",
|
|
101
|
+
"@fluidframework/container-definitions": ">=2.0.0-rc.1.0.4 <2.0.0-rc.1.1.0",
|
|
102
|
+
"@fluidframework/core-interfaces": ">=2.0.0-rc.1.0.4 <2.0.0-rc.1.1.0",
|
|
103
|
+
"@fluidframework/core-utils": ">=2.0.0-rc.1.0.4 <2.0.0-rc.1.1.0",
|
|
104
|
+
"@fluidframework/datastore-definitions": ">=2.0.0-rc.1.0.4 <2.0.0-rc.1.1.0",
|
|
105
105
|
"@fluidframework/protocol-definitions": "^3.1.0",
|
|
106
|
-
"@fluidframework/runtime-definitions": ">=2.0.0-rc.1.0.
|
|
107
|
-
"@fluidframework/runtime-utils": ">=2.0.0-rc.1.0.
|
|
108
|
-
"@fluidframework/shared-object-base": ">=2.0.0-rc.1.0.
|
|
109
|
-
"@fluidframework/telemetry-utils": ">=2.0.0-rc.1.0.
|
|
106
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-rc.1.0.4 <2.0.0-rc.1.1.0",
|
|
107
|
+
"@fluidframework/runtime-utils": ">=2.0.0-rc.1.0.4 <2.0.0-rc.1.1.0",
|
|
108
|
+
"@fluidframework/shared-object-base": ">=2.0.0-rc.1.0.4 <2.0.0-rc.1.1.0",
|
|
109
|
+
"@fluidframework/telemetry-utils": ">=2.0.0-rc.1.0.4 <2.0.0-rc.1.1.0"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
112
|
"@arethetypeswrong/cli": "^0.13.3",
|
|
113
|
-
"@fluid-private/stochastic-test-utils": ">=2.0.0-rc.1.0.
|
|
114
|
-
"@fluid-private/test-pairwise-generator": ">=2.0.0-rc.1.0.
|
|
113
|
+
"@fluid-private/stochastic-test-utils": ">=2.0.0-rc.1.0.4 <2.0.0-rc.1.1.0",
|
|
114
|
+
"@fluid-private/test-pairwise-generator": ">=2.0.0-rc.1.0.4 <2.0.0-rc.1.1.0",
|
|
115
115
|
"@fluid-tools/benchmark": "^0.48.0",
|
|
116
116
|
"@fluid-tools/build-cli": "^0.29.0",
|
|
117
117
|
"@fluidframework/build-common": "^2.0.3",
|
|
118
118
|
"@fluidframework/build-tools": "^0.29.0",
|
|
119
119
|
"@fluidframework/eslint-config-fluid": "^3.2.0",
|
|
120
120
|
"@fluidframework/merge-tree-previous": "npm:@fluidframework/merge-tree@2.0.0-internal.8.0.0",
|
|
121
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-rc.1.0.
|
|
122
|
-
"@fluidframework/test-runtime-utils": ">=2.0.0-rc.1.0.
|
|
121
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-rc.1.0.4 <2.0.0-rc.1.1.0",
|
|
122
|
+
"@fluidframework/test-runtime-utils": ">=2.0.0-rc.1.0.4 <2.0.0-rc.1.1.0",
|
|
123
123
|
"@microsoft/api-extractor": "^7.38.3",
|
|
124
124
|
"@types/diff": "^3.5.1",
|
|
125
125
|
"@types/mocha": "^9.1.1",
|
package/src/mergeTree.ts
CHANGED
|
@@ -102,11 +102,11 @@ function markSegmentMoved(seg: ISegment, moveInfo: IMoveInfo): void {
|
|
|
102
102
|
seg.wasMovedOnInsert = moveInfo.wasMovedOnInsert;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function isMoved(segment: ISegment):
|
|
105
|
+
function isMoved(segment: ISegment): segment is ISegment & IMoveInfo {
|
|
106
106
|
return toMoveInfo(segment) !== undefined;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
function isRemoved(segment: ISegment):
|
|
109
|
+
function isRemoved(segment: ISegment): segment is ISegment & IRemovalInfo {
|
|
110
110
|
return toRemovalInfo(segment) !== undefined;
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -115,7 +115,7 @@ function isRemovedAndAcked(segment: ISegment): segment is ISegment & IRemovalInf
|
|
|
115
115
|
return removalInfo !== undefined && removalInfo.removedSeq !== UnassignedSequenceNumber;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
function isMovedAndAcked(segment: ISegment):
|
|
118
|
+
function isMovedAndAcked(segment: ISegment): segment is ISegment & IMoveInfo {
|
|
119
119
|
const moveInfo = toMoveInfo(segment);
|
|
120
120
|
return moveInfo !== undefined && moveInfo.movedSeq !== UnassignedSequenceNumber;
|
|
121
121
|
}
|
|
@@ -1270,7 +1270,12 @@ export class MergeTree {
|
|
|
1270
1270
|
|
|
1271
1271
|
// TODO: error checking
|
|
1272
1272
|
public getMarkerFromId(id: string): Marker | undefined {
|
|
1273
|
-
|
|
1273
|
+
const marker = this.idToMarker.get(id);
|
|
1274
|
+
return marker === undefined ||
|
|
1275
|
+
isRemoved(marker) ||
|
|
1276
|
+
(isMoved(marker) && marker.moveDst === undefined)
|
|
1277
|
+
? undefined
|
|
1278
|
+
: marker;
|
|
1274
1279
|
}
|
|
1275
1280
|
|
|
1276
1281
|
/**
|
package/src/sortedSegmentSet.ts
CHANGED
|
@@ -39,9 +39,11 @@ export class SortedSegmentSet<T extends SortedSegmentSetItem = ISegment> extends
|
|
|
39
39
|
const maybeRef = item as Partial<LocalReferencePosition>;
|
|
40
40
|
if (maybeRef.getSegment !== undefined && maybeRef.isLeaf?.() === false) {
|
|
41
41
|
const lref = maybeRef as LocalReferencePosition;
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
// If the reference position has no associated segment, assign it a sentinel value.
|
|
43
|
+
// The particular value for comparison doesn't matter because `findItemPosition` tolerates
|
|
44
|
+
// elements with duplicate keys (as it must, since local references use the same key as their segment).
|
|
45
|
+
// All that matters is that it's consistent.
|
|
46
|
+
return lref.getSegment()?.ordinal ?? "";
|
|
45
47
|
}
|
|
46
48
|
const maybeObject = item as { readonly segment: ISegment };
|
|
47
49
|
if (maybeObject?.segment) {
|