@fluidframework/sequence 2.0.0-dev.4.1.0.148229 → 2.0.0-dev.4.2.0.153917
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 +12 -0
- package/README.md +28 -6
- package/dist/intervalCollection.d.ts +32 -8
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +36 -13
- package/dist/intervalCollection.js.map +1 -1
- package/dist/intervalTree.d.ts +8 -1
- package/dist/intervalTree.d.ts.map +1 -1
- package/dist/intervalTree.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/intervalCollection.d.ts +32 -8
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +36 -13
- package/lib/intervalCollection.js.map +1 -1
- package/lib/intervalTree.d.ts +8 -1
- package/lib/intervalTree.d.ts.map +1 -1
- package/lib/intervalTree.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +16 -16
- package/src/intervalCollection.ts +42 -16
- package/src/intervalTree.ts +8 -1
- package/src/packageVersion.ts +1 -1
package/lib/intervalTree.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export interface IInterval {
|
|
|
43
43
|
modify(label: string, start: number | undefined, end: number | undefined, op?: ISequencedDocumentMessage, localSeq?: number): IInterval | undefined;
|
|
44
44
|
/**
|
|
45
45
|
* @returns whether this interval overlaps with `b`.
|
|
46
|
-
*
|
|
46
|
+
* Intervals are considered to overlap if their intersection is non-empty.
|
|
47
47
|
*/
|
|
48
48
|
overlaps(b: IInterval): boolean;
|
|
49
49
|
/**
|
|
@@ -55,6 +55,13 @@ export interface IInterval {
|
|
|
55
55
|
union(b: IInterval): IInterval;
|
|
56
56
|
}
|
|
57
57
|
export declare type IntervalNode<T extends IInterval> = RBNode<T, AugmentedIntervalNode>;
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated - This functionality was useful when adding two intervals at the same start/end positions resulted
|
|
60
|
+
* in a conflict. This is no longer the case (as of PR#6407), as interval collections support multiple intervals
|
|
61
|
+
* at the same location and gives each interval a unique id.
|
|
62
|
+
*
|
|
63
|
+
* As such, conflict resolvers are never invoked and unnecessary. They will be removed in an upcoming release.
|
|
64
|
+
*/
|
|
58
65
|
export declare type IntervalConflictResolver<TInterval> = (a: TInterval, b: TInterval) => TInterval;
|
|
59
66
|
export declare class IntervalTree<T extends IInterval> implements IRBAugmentation<T, AugmentedIntervalNode>, IRBMatcher<T, AugmentedIntervalNode> {
|
|
60
67
|
intervals: RedBlackTree<T, AugmentedIntervalNode>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intervalTree.d.ts","sourceRoot":"","sources":["../src/intervalTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,aAAa,EACb,MAAM,EACN,eAAe,EACf,UAAU,EACV,YAAY,EAGZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,MAAM,WAAW,qBAAqB;IACrC,MAAM,EAAE,SAAS,CAAC;CAClB;AAED,eAAO,MAAM,oBAAoB,UAAW,aAAa,WAAoC,CAAC;AAE9F;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB;;OAEG;IACH,KAAK,IAAI,SAAS,CAAC;IACnB;;;;;;OAMG;IACH,OAAO,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC9B;;;;OAIG;IACH,YAAY,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACnC;;;;OAIG;IACH,UAAU,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACjC;;;OAGG;IACH,MAAM,CACL,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,GAAG,EAAE,MAAM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IAAI,CAAC,KAAK,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;SACvF;aAAM;YACN,IAAI,IAAI,CAAC,IAAI,EAAE;gBACd,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACzD;iBAAM,IAAI,IAAI,CAAC,KAAK,EAAE;gBACtB,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aAC1D;iBAAM;gBACN,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;aACpC;SACD;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIIntegerRange,\n\tRBNode,\n\tIRBAugmentation,\n\tIRBMatcher,\n\tRedBlackTree,\n\tConflictAction,\n\tRBNodeActions,\n} from \"@fluidframework/merge-tree\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\n\nexport interface AugmentedIntervalNode {\n\tminmax: IInterval;\n}\n\nexport const integerRangeToString = (range: IIntegerRange) => `[${range.start},${range.end})`;\n\n/**\n * Basic interval abstraction\n */\nexport interface IInterval {\n\t/**\n\t * @returns a new interval object with identical semantics.\n\t */\n\tclone(): IInterval;\n\t/**\n\t * Compares this interval to `b` with standard comparator semantics:\n\t * - returns -1 if this is less than `b`\n\t * - returns 1 if this is greater than `b`\n\t * - returns 0 if this is equivalent to `b`\n\t * @param b - Interval to compare against\n\t */\n\tcompare(b: IInterval): number;\n\t/**\n\t * Compares the start endpoint of this interval to `b`'s start endpoint.\n\t * Standard comparator semantics apply.\n\t * @param b - Interval to compare against\n\t */\n\tcompareStart(b: IInterval): number;\n\t/**\n\t * Compares the end endpoint of this interval to `b`'s end endpoint.\n\t * Standard comparator semantics apply.\n\t * @param b - Interval to compare against\n\t */\n\tcompareEnd(b: IInterval): number;\n\t/**\n\t * Modifies one or more of the endpoints of this interval, returning a new interval representing the result.\n\t * @internal\n\t */\n\tmodify(\n\t\tlabel: string,\n\t\tstart: number | undefined,\n\t\tend: number | undefined,\n\t\top?: ISequencedDocumentMessage,\n\t\tlocalSeq?: number,\n\t): IInterval | undefined;\n\t/**\n\t * @returns whether this interval overlaps with `b`.\n\t * Intervals are considered to overlap if their intersection is non-empty.\n\t */\n\toverlaps(b: IInterval): boolean;\n\t/**\n\t * Unions this interval with `b`, returning a new interval.\n\t * The union operates as a convex hull, i.e. if the two intervals are disjoint, the return value includes\n\t * intermediate values between the two intervals.\n\t * @internal\n\t */\n\tunion(b: IInterval): IInterval;\n}\n\nconst intervalComparer = (a: IInterval, b: IInterval) => a.compare(b);\n\nexport type IntervalNode<T extends IInterval> = RBNode<T, AugmentedIntervalNode>;\n\n/**\n * @deprecated - This functionality was useful when adding two intervals at the same start/end positions resulted\n * in a conflict. This is no longer the case (as of PR#6407), as interval collections support multiple intervals\n * at the same location and gives each interval a unique id.\n *\n * As such, conflict resolvers are never invoked and unnecessary. They will be removed in an upcoming release.\n */\nexport type IntervalConflictResolver<TInterval> = (a: TInterval, b: TInterval) => TInterval;\n\nexport class IntervalTree<T extends IInterval>\n\timplements IRBAugmentation<T, AugmentedIntervalNode>, IRBMatcher<T, AugmentedIntervalNode>\n{\n\tpublic intervals = new RedBlackTree<T, AugmentedIntervalNode>(intervalComparer, this);\n\n\tpublic remove(x: T) {\n\t\tthis.intervals.remove(x);\n\t}\n\n\tpublic removeExisting(x: T) {\n\t\tthis.intervals.removeExisting(x);\n\t}\n\n\tpublic put(x: T, conflict?: IntervalConflictResolver<T>) {\n\t\tlet rbConflict: ConflictAction<T, AugmentedIntervalNode> | undefined;\n\t\tif (conflict) {\n\t\t\trbConflict = (key: T, currentKey: T) => {\n\t\t\t\tconst ival = conflict(key, currentKey);\n\t\t\t\treturn {\n\t\t\t\t\tkey: ival,\n\t\t\t\t};\n\t\t\t};\n\t\t}\n\t\tthis.intervals.put(x, { minmax: x.clone() }, rbConflict);\n\t}\n\n\tpublic map(fn: (x: T) => void) {\n\t\tconst actions: RBNodeActions<T, AugmentedIntervalNode> = {\n\t\t\tinfix: (node) => {\n\t\t\t\tfn(node.key);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tshowStructure: true,\n\t\t};\n\t\tthis.intervals.walk(actions);\n\t}\n\n\tpublic mapUntil(fn: (X: T) => boolean) {\n\t\tconst actions: RBNodeActions<T, AugmentedIntervalNode> = {\n\t\t\tinfix: (node) => {\n\t\t\t\treturn fn(node.key);\n\t\t\t},\n\t\t\tshowStructure: true,\n\t\t};\n\t\tthis.intervals.walk(actions);\n\t}\n\n\tpublic mapBackward(fn: (x: T) => void) {\n\t\tconst actions: RBNodeActions<T, AugmentedIntervalNode> = {\n\t\t\tinfix: (node) => {\n\t\t\t\tfn(node.key);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tshowStructure: true,\n\t\t};\n\t\tthis.intervals.walkBackward(actions);\n\t}\n\n\t// TODO: toString()\n\tpublic match(x: T) {\n\t\treturn this.intervals.gather(x, this);\n\t}\n\n\tpublic matchNode(node: IntervalNode<T> | undefined, key: T) {\n\t\treturn !!node && node.key.overlaps(key);\n\t}\n\n\tpublic continueSubtree(node: IntervalNode<T> | undefined, key: T) {\n\t\treturn !!node && node.data.minmax.overlaps(key);\n\t}\n\n\tpublic update(node: IntervalNode<T>) {\n\t\tif (node.left && node.right) {\n\t\t\tnode.data.minmax = node.key.union(node.left.data.minmax.union(node.right.data.minmax));\n\t\t} else {\n\t\t\tif (node.left) {\n\t\t\t\tnode.data.minmax = node.key.union(node.left.data.minmax);\n\t\t\t} else if (node.right) {\n\t\t\t\tnode.data.minmax = node.key.union(node.right.data.minmax);\n\t\t\t} else {\n\t\t\t\tnode.data.minmax = node.key.clone();\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/sequence";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-dev.4.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-dev.4.2.0.153917";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export const pkgName = "@fluidframework/sequence";
|
|
8
|
-
export const pkgVersion = "2.0.0-dev.4.
|
|
8
|
+
export const pkgVersion = "2.0.0-dev.4.2.0.153917";
|
|
9
9
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.0.0-dev.4.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/sequence\";\nexport const pkgVersion = \"2.0.0-dev.4.2.0.153917\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/sequence",
|
|
3
|
-
"version": "2.0.0-dev.4.
|
|
3
|
+
"version": "2.0.0-dev.4.2.0.153917",
|
|
4
4
|
"description": "Distributed sequence",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -37,30 +37,30 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
39
39
|
"@fluidframework/common-utils": "^1.1.1",
|
|
40
|
-
"@fluidframework/container-utils": "2.0.0-dev.4.
|
|
41
|
-
"@fluidframework/core-interfaces": "2.0.0-dev.4.
|
|
42
|
-
"@fluidframework/datastore-definitions": "2.0.0-dev.4.
|
|
43
|
-
"@fluidframework/merge-tree": "2.0.0-dev.4.
|
|
40
|
+
"@fluidframework/container-utils": "2.0.0-dev.4.2.0.153917",
|
|
41
|
+
"@fluidframework/core-interfaces": "2.0.0-dev.4.2.0.153917",
|
|
42
|
+
"@fluidframework/datastore-definitions": "2.0.0-dev.4.2.0.153917",
|
|
43
|
+
"@fluidframework/merge-tree": "2.0.0-dev.4.2.0.153917",
|
|
44
44
|
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
45
|
-
"@fluidframework/runtime-definitions": "2.0.0-dev.4.
|
|
46
|
-
"@fluidframework/runtime-utils": "2.0.0-dev.4.
|
|
47
|
-
"@fluidframework/shared-object-base": "2.0.0-dev.4.
|
|
48
|
-
"@fluidframework/telemetry-utils": "2.0.0-dev.4.
|
|
45
|
+
"@fluidframework/runtime-definitions": "2.0.0-dev.4.2.0.153917",
|
|
46
|
+
"@fluidframework/runtime-utils": "2.0.0-dev.4.2.0.153917",
|
|
47
|
+
"@fluidframework/shared-object-base": "2.0.0-dev.4.2.0.153917",
|
|
48
|
+
"@fluidframework/telemetry-utils": "2.0.0-dev.4.2.0.153917",
|
|
49
49
|
"uuid": "^8.3.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@fluid-internal/stochastic-test-utils": "2.0.0-dev.4.
|
|
53
|
-
"@fluid-internal/test-dds-utils": "2.0.0-dev.4.
|
|
54
|
-
"@fluid-tools/benchmark": "0.47.0
|
|
55
|
-
"@fluid-tools/build-cli": "^0.
|
|
52
|
+
"@fluid-internal/stochastic-test-utils": "2.0.0-dev.4.2.0.153917",
|
|
53
|
+
"@fluid-internal/test-dds-utils": "2.0.0-dev.4.2.0.153917",
|
|
54
|
+
"@fluid-tools/benchmark": "^0.47.0",
|
|
55
|
+
"@fluid-tools/build-cli": "^0.15.0",
|
|
56
56
|
"@fluidframework/build-common": "^1.1.0",
|
|
57
|
-
"@fluidframework/build-tools": "^0.
|
|
57
|
+
"@fluidframework/build-tools": "^0.15.0",
|
|
58
58
|
"@fluidframework/eslint-config-fluid": "^2.0.0",
|
|
59
59
|
"@fluidframework/gitresources": "^0.1039.1000",
|
|
60
|
-
"@fluidframework/mocha-test-setup": "2.0.0-dev.4.
|
|
60
|
+
"@fluidframework/mocha-test-setup": "2.0.0-dev.4.2.0.153917",
|
|
61
61
|
"@fluidframework/sequence-previous": "npm:@fluidframework/sequence@2.0.0-internal.4.0.0",
|
|
62
62
|
"@fluidframework/server-services-client": "^0.1039.1000",
|
|
63
|
-
"@fluidframework/test-runtime-utils": "2.0.0-dev.4.
|
|
63
|
+
"@fluidframework/test-runtime-utils": "2.0.0-dev.4.2.0.153917",
|
|
64
64
|
"@microsoft/api-extractor": "^7.34.4",
|
|
65
65
|
"@types/diff": "^3.5.1",
|
|
66
66
|
"@types/mocha": "^9.1.1",
|
|
@@ -78,9 +78,9 @@ export interface ISerializedInterval {
|
|
|
78
78
|
* At the time of writing, it's not plumbed through to the reconnect/rebase code, however, which does need it.
|
|
79
79
|
*/
|
|
80
80
|
sequenceNumber: number;
|
|
81
|
-
/** Start position of the interval
|
|
81
|
+
/** Start position of the interval */
|
|
82
82
|
start: number;
|
|
83
|
-
/** End position of the interval
|
|
83
|
+
/** End position of the interval */
|
|
84
84
|
end: number;
|
|
85
85
|
/** Interval type to create */
|
|
86
86
|
intervalType: IntervalType;
|
|
@@ -224,11 +224,9 @@ export class Interval implements ISerializableInterval {
|
|
|
224
224
|
/**
|
|
225
225
|
* {@inheritDoc ISerializableInterval.getIntervalId}
|
|
226
226
|
*/
|
|
227
|
-
public getIntervalId(): string
|
|
227
|
+
public getIntervalId(): string {
|
|
228
228
|
const id = this.properties?.[reservedIntervalIdKey];
|
|
229
|
-
|
|
230
|
-
return undefined;
|
|
231
|
-
}
|
|
229
|
+
assert(id !== undefined, 0x5e1 /* interval ID should not be undefined */);
|
|
232
230
|
return `${id}`;
|
|
233
231
|
}
|
|
234
232
|
|
|
@@ -400,6 +398,22 @@ export class Interval implements ISerializableInterval {
|
|
|
400
398
|
* Interval impelmentation whose ends are associated with positions in a mutatable sequence.
|
|
401
399
|
* As such, when content is inserted into the middle of the interval, the interval expands to
|
|
402
400
|
* include that content.
|
|
401
|
+
*
|
|
402
|
+
* @remarks - The endpoint's position should be treated exclusively to get reasonable behavior--i.e.
|
|
403
|
+
* an interval referring to "hello" in "hello world" should have a start position of 0 and an end
|
|
404
|
+
* position of 5.
|
|
405
|
+
*
|
|
406
|
+
* To see why, consider what happens if "llo wor" is removed from the string to make "held".
|
|
407
|
+
* The interval's startpoint remains on the "h" (it isn't altered), but the interval's endpoint
|
|
408
|
+
* slides forward to the next unremoved position, which is the "l" in "held".
|
|
409
|
+
* Users would generally expect the interval to now refer to "he" (as it is the subset of content
|
|
410
|
+
* remaining after the removal), hence the "l" should be excluded.
|
|
411
|
+
* If the interval endpoint was treated inclusively, the interval would now refer to "hel", which
|
|
412
|
+
* is undesirable.
|
|
413
|
+
*
|
|
414
|
+
* Since the end of an interval is treated exclusively but cannot be greater than or equal to the
|
|
415
|
+
* length of the associated sequence, application models which leverage interval collections should
|
|
416
|
+
* consider inserting a marker at the end of the sequence to represent the end of the content.
|
|
403
417
|
*/
|
|
404
418
|
export class SequenceInterval implements ISerializableInterval {
|
|
405
419
|
/**
|
|
@@ -556,11 +570,9 @@ export class SequenceInterval implements ISerializableInterval {
|
|
|
556
570
|
/**
|
|
557
571
|
* {@inheritDoc ISerializableInterval.getIntervalId}
|
|
558
572
|
*/
|
|
559
|
-
public getIntervalId(): string
|
|
573
|
+
public getIntervalId(): string {
|
|
560
574
|
const id = this.properties?.[reservedIntervalIdKey];
|
|
561
|
-
|
|
562
|
-
return undefined;
|
|
563
|
-
}
|
|
575
|
+
assert(id !== undefined, 0x5e2 /* interval ID should not be undefined */);
|
|
564
576
|
return `${id}`;
|
|
565
577
|
}
|
|
566
578
|
|
|
@@ -593,7 +605,6 @@ export class SequenceInterval implements ISerializableInterval {
|
|
|
593
605
|
|
|
594
606
|
/**
|
|
595
607
|
* @returns whether this interval overlaps two numerical positions.
|
|
596
|
-
* @remarks - this is currently strict overlap, which doesn't align with the endpoint treatment of`.overlaps()`
|
|
597
608
|
*/
|
|
598
609
|
public overlapsPos(bstart: number, bend: number) {
|
|
599
610
|
const startPos = this.client.localReferencePositionToPosition(this.start);
|
|
@@ -679,6 +690,7 @@ function createPositionReferenceFromSegoff(
|
|
|
679
690
|
refType: ReferenceType,
|
|
680
691
|
op?: ISequencedDocumentMessage,
|
|
681
692
|
localSeq?: number,
|
|
693
|
+
fromSnapshot?: boolean,
|
|
682
694
|
): LocalReferencePosition {
|
|
683
695
|
if (segoff.segment) {
|
|
684
696
|
const ref = client.createLocalReferencePosition(
|
|
@@ -695,7 +707,12 @@ function createPositionReferenceFromSegoff(
|
|
|
695
707
|
// - References coming from a remote client (location may have been concurrently removed)
|
|
696
708
|
// - References being rebased to a new sequence number
|
|
697
709
|
// (segment they originally referred to may have been removed with no suitable replacement)
|
|
698
|
-
if (
|
|
710
|
+
if (
|
|
711
|
+
!op &&
|
|
712
|
+
!localSeq &&
|
|
713
|
+
!fromSnapshot &&
|
|
714
|
+
!refTypeIncludesFlag(refType, ReferenceType.Transient)
|
|
715
|
+
) {
|
|
699
716
|
throw new UsageError("Non-transient references need segment");
|
|
700
717
|
}
|
|
701
718
|
|
|
@@ -728,7 +745,7 @@ function createPositionReference(
|
|
|
728
745
|
);
|
|
729
746
|
segoff = client.getContainingSegment(pos, undefined, localSeq);
|
|
730
747
|
}
|
|
731
|
-
return createPositionReferenceFromSegoff(client, segoff, refType, op, localSeq);
|
|
748
|
+
return createPositionReferenceFromSegoff(client, segoff, refType, op, localSeq, fromSnapshot);
|
|
732
749
|
}
|
|
733
750
|
|
|
734
751
|
export function createSequenceInterval(
|
|
@@ -953,7 +970,7 @@ export class LocalIntervalCollection<TInterval extends ISerializableInterval> {
|
|
|
953
970
|
|
|
954
971
|
/**
|
|
955
972
|
* @returns an array of all intervals contained in this collection that overlap the range
|
|
956
|
-
* `[startPosition, endPosition
|
|
973
|
+
* `[startPosition, endPosition)`.
|
|
957
974
|
*/
|
|
958
975
|
public findOverlappingIntervals(startPosition: number, endPosition: number) {
|
|
959
976
|
if (endPosition < startPosition || this.intervalTree.intervals.isEmpty()) {
|
|
@@ -1634,11 +1651,13 @@ export class IntervalCollection<TInterval extends ISerializableInterval> extends
|
|
|
1634
1651
|
|
|
1635
1652
|
/**
|
|
1636
1653
|
* Creates a new interval and add it to the collection.
|
|
1637
|
-
* @param start - interval start position
|
|
1638
|
-
* @param end - interval end position
|
|
1654
|
+
* @param start - interval start position (inclusive)
|
|
1655
|
+
* @param end - interval end position (exclusive)
|
|
1639
1656
|
* @param intervalType - type of the interval. All intervals are SlideOnRemove. Intervals may not be Transient.
|
|
1640
1657
|
* @param props - properties of the interval
|
|
1641
1658
|
* @returns - the created interval
|
|
1659
|
+
* @remarks - See documentation on {@link SequenceInterval} for comments on interval endpoint semantics: there are subtleties
|
|
1660
|
+
* with how the current half-open behavior is represented.
|
|
1642
1661
|
*/
|
|
1643
1662
|
public add(
|
|
1644
1663
|
start: number,
|
|
@@ -1939,6 +1958,13 @@ export class IntervalCollection<TInterval extends ISerializableInterval> extends
|
|
|
1939
1958
|
}
|
|
1940
1959
|
}
|
|
1941
1960
|
|
|
1961
|
+
/**
|
|
1962
|
+
* @deprecated - This functionality was useful when adding two intervals at the same start/end positions resulted
|
|
1963
|
+
* in a conflict. This is no longer the case (as of PR#6407), as interval collections support multiple intervals
|
|
1964
|
+
* at the same location and gives each interval a unique id.
|
|
1965
|
+
*
|
|
1966
|
+
* As such, the conflict resolver is never invoked and unnecessary. This API will be removed in an upcoming release.
|
|
1967
|
+
*/
|
|
1942
1968
|
public addConflictResolver(conflictResolver: IntervalConflictResolver<TInterval>): void {
|
|
1943
1969
|
if (!this.localCollection) {
|
|
1944
1970
|
throw new LoggingError("attachSequence must be called");
|
package/src/intervalTree.ts
CHANGED
|
@@ -61,7 +61,7 @@ export interface IInterval {
|
|
|
61
61
|
): IInterval | undefined;
|
|
62
62
|
/**
|
|
63
63
|
* @returns whether this interval overlaps with `b`.
|
|
64
|
-
*
|
|
64
|
+
* Intervals are considered to overlap if their intersection is non-empty.
|
|
65
65
|
*/
|
|
66
66
|
overlaps(b: IInterval): boolean;
|
|
67
67
|
/**
|
|
@@ -77,6 +77,13 @@ const intervalComparer = (a: IInterval, b: IInterval) => a.compare(b);
|
|
|
77
77
|
|
|
78
78
|
export type IntervalNode<T extends IInterval> = RBNode<T, AugmentedIntervalNode>;
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated - This functionality was useful when adding two intervals at the same start/end positions resulted
|
|
82
|
+
* in a conflict. This is no longer the case (as of PR#6407), as interval collections support multiple intervals
|
|
83
|
+
* at the same location and gives each interval a unique id.
|
|
84
|
+
*
|
|
85
|
+
* As such, conflict resolvers are never invoked and unnecessary. They will be removed in an upcoming release.
|
|
86
|
+
*/
|
|
80
87
|
export type IntervalConflictResolver<TInterval> = (a: TInterval, b: TInterval) => TInterval;
|
|
81
88
|
|
|
82
89
|
export class IntervalTree<T extends IInterval>
|
package/src/packageVersion.ts
CHANGED