@fluidframework/sequence 2.0.0-internal.1.4.2 → 2.0.0-internal.2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/defaultMap.d.ts.map +1 -1
- package/dist/defaultMap.js +1 -0
- package/dist/defaultMap.js.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/intervalCollection.d.ts +271 -34
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +343 -97
- package/dist/intervalCollection.js.map +1 -1
- package/dist/intervalTree.d.ts +72 -0
- package/dist/intervalTree.d.ts.map +1 -0
- package/dist/intervalTree.js +91 -0
- package/dist/intervalTree.js.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/sequence.d.ts +66 -15
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +73 -19
- package/dist/sequence.js.map +1 -1
- package/dist/sequenceDeltaEvent.d.ts +15 -1
- package/dist/sequenceDeltaEvent.d.ts.map +1 -1
- package/dist/sequenceDeltaEvent.js +2 -1
- package/dist/sequenceDeltaEvent.js.map +1 -1
- package/dist/sequenceFactory.d.ts +0 -89
- package/dist/sequenceFactory.d.ts.map +1 -1
- package/dist/sequenceFactory.js +2 -142
- package/dist/sequenceFactory.js.map +1 -1
- package/dist/sharedIntervalCollection.d.ts +0 -6
- package/dist/sharedIntervalCollection.d.ts.map +1 -1
- package/dist/sharedIntervalCollection.js +0 -7
- package/dist/sharedIntervalCollection.js.map +1 -1
- package/dist/sharedSequence.d.ts +2 -2
- package/dist/sharedString.d.ts +16 -15
- package/dist/sharedString.d.ts.map +1 -1
- package/dist/sharedString.js +96 -15
- package/dist/sharedString.js.map +1 -1
- package/lib/defaultMap.d.ts.map +1 -1
- package/lib/defaultMap.js +1 -0
- package/lib/defaultMap.js.map +1 -1
- package/lib/index.d.ts +4 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -4
- package/lib/index.js.map +1 -1
- package/lib/intervalCollection.d.ts +271 -34
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +341 -98
- package/lib/intervalCollection.js.map +1 -1
- package/lib/intervalTree.d.ts +72 -0
- package/lib/intervalTree.d.ts.map +1 -0
- package/lib/intervalTree.js +86 -0
- package/lib/intervalTree.js.map +1 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/sequence.d.ts +66 -15
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +73 -19
- package/lib/sequence.js.map +1 -1
- package/lib/sequenceDeltaEvent.d.ts +15 -1
- package/lib/sequenceDeltaEvent.d.ts.map +1 -1
- package/lib/sequenceDeltaEvent.js +2 -1
- package/lib/sequenceDeltaEvent.js.map +1 -1
- package/lib/sequenceFactory.d.ts +0 -89
- package/lib/sequenceFactory.d.ts.map +1 -1
- package/lib/sequenceFactory.js +1 -139
- package/lib/sequenceFactory.js.map +1 -1
- package/lib/sharedIntervalCollection.d.ts +0 -6
- package/lib/sharedIntervalCollection.d.ts.map +1 -1
- package/lib/sharedIntervalCollection.js +0 -7
- package/lib/sharedIntervalCollection.js.map +1 -1
- package/lib/sharedSequence.d.ts +2 -2
- package/lib/sharedString.d.ts +16 -15
- package/lib/sharedString.d.ts.map +1 -1
- package/lib/sharedString.js +97 -16
- package/lib/sharedString.js.map +1 -1
- package/package.json +99 -27
- package/src/defaultMap.ts +3 -0
- package/src/index.ts +4 -4
- package/src/intervalCollection.ts +486 -143
- package/src/intervalTree.ts +166 -0
- package/src/packageVersion.ts +1 -1
- package/src/sequence.ts +86 -30
- package/src/sequenceDeltaEvent.ts +18 -4
- package/src/sequenceFactory.ts +2 -163
- package/src/sharedIntervalCollection.ts +0 -11
- package/src/sharedString.ts +120 -23
- package/tsconfig.json +0 -1
- package/dist/sharedNumberSequence.d.ts +0 -50
- package/dist/sharedNumberSequence.d.ts.map +0 -1
- package/dist/sharedNumberSequence.js +0 -61
- package/dist/sharedNumberSequence.js.map +0 -1
- package/dist/sharedObjectSequence.d.ts +0 -50
- package/dist/sharedObjectSequence.d.ts.map +0 -1
- package/dist/sharedObjectSequence.js +0 -61
- package/dist/sharedObjectSequence.js.map +0 -1
- package/dist/sparsematrix.d.ts +0 -152
- package/dist/sparsematrix.d.ts.map +0 -1
- package/dist/sparsematrix.js +0 -343
- package/dist/sparsematrix.js.map +0 -1
- package/lib/sharedNumberSequence.d.ts +0 -50
- package/lib/sharedNumberSequence.d.ts.map +0 -1
- package/lib/sharedNumberSequence.js +0 -57
- package/lib/sharedNumberSequence.js.map +0 -1
- package/lib/sharedObjectSequence.d.ts +0 -50
- package/lib/sharedObjectSequence.d.ts.map +0 -1
- package/lib/sharedObjectSequence.js +0 -57
- package/lib/sharedObjectSequence.js.map +0 -1
- package/lib/sparsematrix.d.ts +0 -152
- package/lib/sparsematrix.d.ts.map +0 -1
- package/lib/sparsematrix.js +0 -334
- package/lib/sparsematrix.js.map +0 -1
- package/src/sharedNumberSequence.ts +0 -62
- package/src/sharedObjectSequence.ts +0 -62
- package/src/sparsematrix.ts +0 -434
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IIntegerRange, RBNode, IRBAugmentation, IRBMatcher, RedBlackTree } from "@fluidframework/merge-tree";
|
|
6
|
+
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
7
|
+
export interface AugmentedIntervalNode {
|
|
8
|
+
minmax: IInterval;
|
|
9
|
+
}
|
|
10
|
+
export declare const integerRangeToString: (range: IIntegerRange) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Basic interval abstraction
|
|
13
|
+
*/
|
|
14
|
+
export interface IInterval {
|
|
15
|
+
/**
|
|
16
|
+
* @returns a new interval object with identical semantics.
|
|
17
|
+
*/
|
|
18
|
+
clone(): IInterval;
|
|
19
|
+
/**
|
|
20
|
+
* Compares this interval to `b` with standard comparator semantics:
|
|
21
|
+
* - returns -1 if this is less than `b`
|
|
22
|
+
* - returns 1 if this is greater than `b`
|
|
23
|
+
* - returns 0 if this is equivalent to `b`
|
|
24
|
+
* @param b - Interval to compare against
|
|
25
|
+
*/
|
|
26
|
+
compare(b: IInterval): number;
|
|
27
|
+
/**
|
|
28
|
+
* Compares the start endpoint of this interval to `b`'s start endpoint.
|
|
29
|
+
* Standard comparator semantics apply.
|
|
30
|
+
* @param b - Interval to compare against
|
|
31
|
+
*/
|
|
32
|
+
compareStart(b: IInterval): number;
|
|
33
|
+
/**
|
|
34
|
+
* Compares the end endpoint of this interval to `b`'s end endpoint.
|
|
35
|
+
* Standard comparator semantics apply.
|
|
36
|
+
* @param b - Interval to compare against
|
|
37
|
+
*/
|
|
38
|
+
compareEnd(b: IInterval): number;
|
|
39
|
+
/**
|
|
40
|
+
* Modifies one or more of the endpoints of this interval, returning a new interval representing the result.
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
modify(label: string, start: number | undefined, end: number | undefined, op?: ISequencedDocumentMessage, localSeq?: number): IInterval | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* @returns whether this interval overlaps with `b`.
|
|
46
|
+
* Since intervals are inclusive, this includes cases where endpoints are equal.
|
|
47
|
+
*/
|
|
48
|
+
overlaps(b: IInterval): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Unions this interval with `b`, returning a new interval.
|
|
51
|
+
* The union operates as a convex hull, i.e. if the two intervals are disjoint, the return value includes
|
|
52
|
+
* intermediate values between the two intervals.
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
union(b: IInterval): IInterval;
|
|
56
|
+
}
|
|
57
|
+
export declare type IntervalNode<T extends IInterval> = RBNode<T, AugmentedIntervalNode>;
|
|
58
|
+
export declare type IntervalConflictResolver<TInterval> = (a: TInterval, b: TInterval) => TInterval;
|
|
59
|
+
export declare class IntervalTree<T extends IInterval> implements IRBAugmentation<T, AugmentedIntervalNode>, IRBMatcher<T, AugmentedIntervalNode> {
|
|
60
|
+
intervals: RedBlackTree<T, AugmentedIntervalNode>;
|
|
61
|
+
remove(x: T): void;
|
|
62
|
+
removeExisting(x: T): void;
|
|
63
|
+
put(x: T, conflict?: IntervalConflictResolver<T>): void;
|
|
64
|
+
map(fn: (x: T) => void): void;
|
|
65
|
+
mapUntil(fn: (X: T) => boolean): void;
|
|
66
|
+
mapBackward(fn: (x: T) => void): void;
|
|
67
|
+
match(x: T): RBNode<T, AugmentedIntervalNode>[];
|
|
68
|
+
matchNode(node: IntervalNode<T> | undefined, key: T): boolean;
|
|
69
|
+
continueSubtree(node: IntervalNode<T> | undefined, key: T): boolean;
|
|
70
|
+
update(node: IntervalNode<T>): void;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=intervalTree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intervalTree.d.ts","sourceRoot":"","sources":["../src/intervalTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,aAAa,EACb,MAAM,EACN,eAAe,EACf,UAAU,EACV,YAAY,EAGf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,MAAM,WAAW,qBAAqB;IAClC,MAAM,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,oBAAoB,UAAW,aAAa,WAAoC,CAAC;AAE9F;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB;;OAEG;IACH,KAAK,IAAI,SAAS,CAAC;IACnB;;;;;;OAMG;IACH,OAAO,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC9B;;;;OAIG;IACH,YAA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C;IAIV,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,CAAC;IAInD,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,CAAC;IAIzD,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;CActC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.IntervalTree = exports.integerRangeToString = void 0;
|
|
8
|
+
const merge_tree_1 = require("@fluidframework/merge-tree");
|
|
9
|
+
const integerRangeToString = (range) => `[${range.start},${range.end})`;
|
|
10
|
+
exports.integerRangeToString = integerRangeToString;
|
|
11
|
+
const intervalComparer = (a, b) => a.compare(b);
|
|
12
|
+
class IntervalTree {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.intervals = new merge_tree_1.RedBlackTree(intervalComparer, this);
|
|
15
|
+
}
|
|
16
|
+
remove(x) {
|
|
17
|
+
this.intervals.remove(x);
|
|
18
|
+
}
|
|
19
|
+
removeExisting(x) {
|
|
20
|
+
this.intervals.removeExisting(x);
|
|
21
|
+
}
|
|
22
|
+
put(x, conflict) {
|
|
23
|
+
let rbConflict;
|
|
24
|
+
if (conflict) {
|
|
25
|
+
rbConflict = (key, currentKey) => {
|
|
26
|
+
const ival = conflict(key, currentKey);
|
|
27
|
+
return {
|
|
28
|
+
key: ival,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
this.intervals.put(x, { minmax: x.clone() }, rbConflict);
|
|
33
|
+
}
|
|
34
|
+
map(fn) {
|
|
35
|
+
const actions = {
|
|
36
|
+
infix: (node) => {
|
|
37
|
+
fn(node.key);
|
|
38
|
+
return true;
|
|
39
|
+
},
|
|
40
|
+
showStructure: true,
|
|
41
|
+
};
|
|
42
|
+
this.intervals.walk(actions);
|
|
43
|
+
}
|
|
44
|
+
mapUntil(fn) {
|
|
45
|
+
const actions = {
|
|
46
|
+
infix: (node) => {
|
|
47
|
+
return fn(node.key);
|
|
48
|
+
},
|
|
49
|
+
showStructure: true,
|
|
50
|
+
};
|
|
51
|
+
this.intervals.walk(actions);
|
|
52
|
+
}
|
|
53
|
+
mapBackward(fn) {
|
|
54
|
+
const actions = {
|
|
55
|
+
infix: (node) => {
|
|
56
|
+
fn(node.key);
|
|
57
|
+
return true;
|
|
58
|
+
},
|
|
59
|
+
showStructure: true,
|
|
60
|
+
};
|
|
61
|
+
this.intervals.walkBackward(actions);
|
|
62
|
+
}
|
|
63
|
+
// TODO: toString()
|
|
64
|
+
match(x) {
|
|
65
|
+
return this.intervals.gather(x, this);
|
|
66
|
+
}
|
|
67
|
+
matchNode(node, key) {
|
|
68
|
+
return !!node && node.key.overlaps(key);
|
|
69
|
+
}
|
|
70
|
+
continueSubtree(node, key) {
|
|
71
|
+
return !!node && node.data.minmax.overlaps(key);
|
|
72
|
+
}
|
|
73
|
+
update(node) {
|
|
74
|
+
if (node.left && node.right) {
|
|
75
|
+
node.data.minmax = node.key.union(node.left.data.minmax.union(node.right.data.minmax));
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
if (node.left) {
|
|
79
|
+
node.data.minmax = node.key.union(node.left.data.minmax);
|
|
80
|
+
}
|
|
81
|
+
else if (node.right) {
|
|
82
|
+
node.data.minmax = node.key.union(node.right.data.minmax);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
node.data.minmax = node.key.clone();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.IntervalTree = IntervalTree;
|
|
91
|
+
//# sourceMappingURL=intervalTree.js.map
|
|
@@ -0,0 +1 @@
|
|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,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAC7B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;SAC5D;aAAM;YACH,IAAI,IAAI,CAAC,IAAI,EAAE;gBACX,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aAC5D;iBAAM,IAAI,IAAI,CAAC,KAAK,EAAE;gBACnB,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aAC7D;iBAAM;gBACH,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;aACvC;SACJ;IACL,CAAC;CACJ;AApFD,oCAoFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IIntegerRange,\n RBNode,\n IRBAugmentation,\n IRBMatcher,\n RedBlackTree,\n ConflictAction,\n RBNodeActions,\n} from \"@fluidframework/merge-tree\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\n\nexport interface AugmentedIntervalNode {\n minmax: IInterval;\n}\n\nexport const integerRangeToString = (range: IIntegerRange) => `[${range.start},${range.end})`;\n\n/**\n * Basic interval abstraction\n */\nexport interface IInterval {\n /**\n * @returns a new interval object with identical semantics.\n */\n clone(): IInterval;\n /**\n * Compares this interval to `b` with standard comparator semantics:\n * - returns -1 if this is less than `b`\n * - returns 1 if this is greater than `b`\n * - returns 0 if this is equivalent to `b`\n * @param b - Interval to compare against\n */\n compare(b: IInterval): number;\n /**\n * Compares the start endpoint of this interval to `b`'s start endpoint.\n * Standard comparator semantics apply.\n * @param b - Interval to compare against\n */\n compareStart(b: IInterval): number;\n /**\n * Compares the end endpoint of this interval to `b`'s end endpoint.\n * Standard comparator semantics apply.\n * @param b - Interval to compare against\n */\n compareEnd(b: IInterval): number;\n /**\n * Modifies one or more of the endpoints of this interval, returning a new interval representing the result.\n * @internal\n */\n modify(\n label: string,\n start: number | undefined,\n end: number | undefined,\n op?: ISequencedDocumentMessage,\n localSeq?: number\n ): IInterval | undefined;\n /**\n * @returns whether this interval overlaps with `b`.\n * Since intervals are inclusive, this includes cases where endpoints are equal.\n */\n overlaps(b: IInterval): boolean;\n /**\n * Unions this interval with `b`, returning a new interval.\n * The union operates as a convex hull, i.e. if the two intervals are disjoint, the return value includes\n * intermediate values between the two intervals.\n * @internal\n */\n union(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\nexport type IntervalConflictResolver<TInterval> = (a: TInterval, b: TInterval) => TInterval;\n\nexport class IntervalTree<T extends IInterval> implements IRBAugmentation<T, AugmentedIntervalNode>,\n IRBMatcher<T, AugmentedIntervalNode> {\n public intervals = new RedBlackTree<T, AugmentedIntervalNode>(intervalComparer, this);\n\n public remove(x: T) {\n this.intervals.remove(x);\n }\n\n public removeExisting(x: T) {\n this.intervals.removeExisting(x);\n }\n\n public put(x: T, conflict?: IntervalConflictResolver<T>) {\n let rbConflict: ConflictAction<T, AugmentedIntervalNode> | undefined;\n if (conflict) {\n rbConflict = (key: T, currentKey: T) => {\n const ival = conflict(key, currentKey);\n return {\n key: ival,\n };\n };\n }\n this.intervals.put(x, { minmax: x.clone() }, rbConflict);\n }\n\n public map(fn: (x: T) => void) {\n const actions: RBNodeActions<T, AugmentedIntervalNode> = {\n infix: (node) => {\n fn(node.key);\n return true;\n },\n showStructure: true,\n };\n this.intervals.walk(actions);\n }\n\n public mapUntil(fn: (X: T) => boolean) {\n const actions: RBNodeActions<T, AugmentedIntervalNode> = {\n infix: (node) => {\n return fn(node.key);\n },\n showStructure: true,\n };\n this.intervals.walk(actions);\n }\n\n public mapBackward(fn: (x: T) => void) {\n const actions: RBNodeActions<T, AugmentedIntervalNode> = {\n infix: (node) => {\n fn(node.key);\n return true;\n },\n showStructure: true,\n };\n this.intervals.walkBackward(actions);\n }\n\n // TODO: toString()\n public match(x: T) {\n return this.intervals.gather(x, this);\n }\n\n public matchNode(node: IntervalNode<T> | undefined, key: T) {\n return !!node && node.key.overlaps(key);\n }\n\n public continueSubtree(node: IntervalNode<T> | undefined, key: T) {\n return !!node && node.data.minmax.overlaps(key);\n }\n\n public update(node: IntervalNode<T>) {\n if (node.left && node.right) {\n node.data.minmax = node.key.union(\n node.left.data.minmax.union(node.right.data.minmax));\n } else {\n if (node.left) {\n node.data.minmax = node.key.union(node.left.data.minmax);\n } else if (node.right) {\n node.data.minmax = node.key.union(node.right.data.minmax);\n } else {\n node.data.minmax = node.key.clone();\n }\n }\n }\n}\n"]}
|
package/dist/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-internal.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.2.0.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/sequence";
|
|
11
|
-
exports.pkgVersion = "2.0.0-internal.
|
|
11
|
+
exports.pkgVersion = "2.0.0-internal.2.0.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,0BAA0B,CAAC;AACrC,QAAA,UAAU,GAAG,sBAAsB,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-internal.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,0BAA0B,CAAC;AACrC,QAAA,UAAU,GAAG,sBAAsB,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-internal.2.0.0\";\n"]}
|
package/dist/sequence.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { Deferred } from "@fluidframework/common-utils";
|
|
6
6
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
7
7
|
import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService } from "@fluidframework/datastore-definitions";
|
|
8
|
-
import { Client, ICombiningOp, IJSONSegment, IMergeTreeGroupMsg, IMergeTreeOp, IMergeTreeRemoveMsg, IRelativePosition, ISegment, ISegmentAction, LocalReferencePosition, PropertySet, RangeStackMap, ReferencePosition, ReferenceType } from "@fluidframework/merge-tree";
|
|
8
|
+
import { Client, ICombiningOp, IJSONSegment, IMergeTreeGroupMsg, IMergeTreeOp, IMergeTreeRemoveMsg, IRelativePosition, ISegment, ISegmentAction, LocalReferencePosition, PropertySet, RangeStackMap, ReferencePosition, ReferenceType, MergeTreeRevertibleDriver } from "@fluidframework/merge-tree";
|
|
9
9
|
import { IFluidSerializer, SharedObject, ISharedObjectEvents, SummarySerializer } from "@fluidframework/shared-object-base";
|
|
10
10
|
import { IEventThisPlaceHolder } from "@fluidframework/common-definitions";
|
|
11
11
|
import { ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
|
|
@@ -50,13 +50,14 @@ export interface ISharedSegmentSequenceEvents extends ISharedObjectEvents {
|
|
|
50
50
|
(event: "sequenceDelta", listener: (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void): any;
|
|
51
51
|
(event: "maintenance", listener: (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void): any;
|
|
52
52
|
}
|
|
53
|
-
export declare abstract class SharedSegmentSequence<T extends ISegment> extends SharedObject<ISharedSegmentSequenceEvents> implements ISharedIntervalCollection<SequenceInterval
|
|
53
|
+
export declare abstract class SharedSegmentSequence<T extends ISegment> extends SharedObject<ISharedSegmentSequenceEvents> implements ISharedIntervalCollection<SequenceInterval>, MergeTreeRevertibleDriver {
|
|
54
54
|
private readonly dataStoreRuntime;
|
|
55
55
|
id: string;
|
|
56
56
|
readonly segmentFromSpec: (spec: IJSONSegment) => ISegment;
|
|
57
57
|
get loaded(): Promise<void>;
|
|
58
58
|
private static createOpsFromDelta;
|
|
59
59
|
protected client: Client;
|
|
60
|
+
/** `Deferred` that triggers once the object is loaded */
|
|
60
61
|
protected loadedDeferred: Deferred<void>;
|
|
61
62
|
private readonly loadedDeferredOutgoingOps;
|
|
62
63
|
private deferIncomingOps;
|
|
@@ -70,9 +71,14 @@ export declare abstract class SharedSegmentSequence<T extends ISegment> extends
|
|
|
70
71
|
*/
|
|
71
72
|
removeRange(start: number, end: number): IMergeTreeRemoveMsg;
|
|
72
73
|
groupOperation(groupOp: IMergeTreeGroupMsg): void;
|
|
74
|
+
/**
|
|
75
|
+
* Finds the segment information (i.e. segment + offset) corresponding to a character position in the SharedString.
|
|
76
|
+
* If the position is past the end of the string, `segment` and `offset` on the returned object may be undefined.
|
|
77
|
+
* @param pos - Character position (index) into the current local view of the SharedString.
|
|
78
|
+
*/
|
|
73
79
|
getContainingSegment(pos: number): {
|
|
74
|
-
segment: T;
|
|
75
|
-
offset: number;
|
|
80
|
+
segment: T | undefined;
|
|
81
|
+
offset: number | undefined;
|
|
76
82
|
};
|
|
77
83
|
/**
|
|
78
84
|
* Returns the length of the current sequence for the client
|
|
@@ -94,13 +100,28 @@ export declare abstract class SharedSegmentSequence<T extends ISegment> extends
|
|
|
94
100
|
*
|
|
95
101
|
*/
|
|
96
102
|
annotateRange(start: number, end: number, props: PropertySet, combiningOp?: ICombiningOp): void;
|
|
97
|
-
getPropertiesAtPosition(pos: number): PropertySet;
|
|
103
|
+
getPropertiesAtPosition(pos: number): PropertySet | undefined;
|
|
98
104
|
getRangeExtentsOfPosition(pos: number): {
|
|
99
|
-
posStart: number;
|
|
100
|
-
posAfterEnd: number;
|
|
105
|
+
posStart: number | undefined;
|
|
106
|
+
posAfterEnd: number | undefined;
|
|
101
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* Creates a `LocalReferencePosition` on this SharedString. If the refType does not include
|
|
110
|
+
* ReferenceType.Transient, the returned reference will be added to the localRefs on the provided segment.
|
|
111
|
+
* @param segment - Segment to add the local reference on
|
|
112
|
+
* @param offset - Offset on the segment at which to place the local reference
|
|
113
|
+
* @param refType - ReferenceType for the created local reference
|
|
114
|
+
* @param properties - PropertySet to place on the created local reference
|
|
115
|
+
*/
|
|
102
116
|
createLocalReferencePosition(segment: T, offset: number, refType: ReferenceType, properties: PropertySet | undefined): LocalReferencePosition;
|
|
117
|
+
/**
|
|
118
|
+
* Resolves a `ReferencePosition` into a character position using this client's perspective.
|
|
119
|
+
*/
|
|
103
120
|
localReferencePositionToPosition(lref: ReferencePosition): number;
|
|
121
|
+
/**
|
|
122
|
+
* Removes a `LocalReferencePosition` from this SharedString.
|
|
123
|
+
*/
|
|
124
|
+
removeLocalReferencePosition(lref: LocalReferencePosition): LocalReferencePosition | undefined;
|
|
104
125
|
/**
|
|
105
126
|
* Resolves a remote client's position against the local sequence
|
|
106
127
|
* and returns the remote client's position relative to the local
|
|
@@ -115,9 +136,8 @@ export declare abstract class SharedSegmentSequence<T extends ISegment> extends
|
|
|
115
136
|
* @param remoteClientRefSeq - The reference sequence number of the remote client
|
|
116
137
|
* @param remoteClientId - The client id of the remote client
|
|
117
138
|
*/
|
|
118
|
-
resolveRemoteClientPosition(remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: string): number;
|
|
139
|
+
resolveRemoteClientPosition(remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: string): number | undefined;
|
|
119
140
|
submitSequenceMessage(message: IMergeTreeOp): void;
|
|
120
|
-
removeLocalReferencePosition(lref: LocalReferencePosition): LocalReferencePosition;
|
|
121
141
|
/**
|
|
122
142
|
* Given a position specified relative to a marker id, lookup the marker
|
|
123
143
|
* and convert the position to a character position.
|
|
@@ -138,18 +158,28 @@ export declare abstract class SharedSegmentSequence<T extends ISegment> extends
|
|
|
138
158
|
* @param splitRange - Optional. Splits boundary segments on the range boundaries
|
|
139
159
|
*/
|
|
140
160
|
walkSegments<TClientData>(handler: ISegmentAction<TClientData>, start?: number, end?: number, accum?: TClientData, splitRange?: boolean): void;
|
|
161
|
+
getStackContext(startPos: number, rangeLabels: string[]): RangeStackMap;
|
|
141
162
|
/**
|
|
142
|
-
* @
|
|
143
|
-
*
|
|
163
|
+
* @returns - The most recent sequence number which has been acked by the server and processed by this
|
|
164
|
+
* SharedSegmentSequence.
|
|
144
165
|
*/
|
|
145
|
-
getStackContext(startPos: number, rangeLabels: string[]): RangeStackMap;
|
|
146
166
|
getCurrentSeq(): number;
|
|
167
|
+
/**
|
|
168
|
+
* Inserts a segment directly before a `ReferencePosition`.
|
|
169
|
+
* @param refPos - The reference position to insert the segment at
|
|
170
|
+
* @param segment - The segment to insert
|
|
171
|
+
*/
|
|
147
172
|
insertAtReferencePosition(pos: ReferencePosition, segment: T): void;
|
|
148
173
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
174
|
+
* Inserts a segment
|
|
175
|
+
* @param start - The position to insert the segment at
|
|
176
|
+
* @param spec - The segment to inserts spec
|
|
177
|
+
*/
|
|
178
|
+
insertFromSpec(pos: number, spec: IJSONSegment): void;
|
|
179
|
+
/**
|
|
180
|
+
* Retrieves the interval collection keyed on `label`. If no such interval collection exists,
|
|
181
|
+
* creates one.
|
|
151
182
|
*/
|
|
152
|
-
waitIntervalCollection(label: string): Promise<IntervalCollection<SequenceInterval>>;
|
|
153
183
|
getIntervalCollection(label: string): IntervalCollection<SequenceInterval>;
|
|
154
184
|
/**
|
|
155
185
|
* @returns An iterable object that enumerates the IntervalCollection labels.
|
|
@@ -163,6 +193,9 @@ export declare abstract class SharedSegmentSequence<T extends ISegment> extends
|
|
|
163
193
|
* ```
|
|
164
194
|
*/
|
|
165
195
|
getIntervalCollectionLabels(): IterableIterator<string>;
|
|
196
|
+
/**
|
|
197
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
198
|
+
*/
|
|
166
199
|
protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
|
|
167
200
|
/**
|
|
168
201
|
* Runs serializer over the GC data for this SharedMatrix.
|
|
@@ -179,15 +212,33 @@ export declare abstract class SharedSegmentSequence<T extends ISegment> extends
|
|
|
179
212
|
* @param segment - The segment that will replace the range
|
|
180
213
|
*/
|
|
181
214
|
protected replaceRange(start: number, end: number, segment: ISegment): void;
|
|
215
|
+
/**
|
|
216
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onConnect}
|
|
217
|
+
*/
|
|
182
218
|
protected onConnect(): void;
|
|
219
|
+
/**
|
|
220
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
|
|
221
|
+
*/
|
|
183
222
|
protected onDisconnect(): void;
|
|
223
|
+
/**
|
|
224
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
|
|
225
|
+
*/
|
|
184
226
|
protected reSubmitCore(content: any, localOpMetadata: unknown): void;
|
|
185
227
|
/**
|
|
186
228
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
187
229
|
*/
|
|
188
230
|
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
231
|
+
/**
|
|
232
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
|
|
233
|
+
*/
|
|
189
234
|
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
235
|
+
/**
|
|
236
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.didAttach}
|
|
237
|
+
*/
|
|
190
238
|
protected didAttach(): void;
|
|
239
|
+
/**
|
|
240
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.initializeLocalCore}
|
|
241
|
+
*/
|
|
191
242
|
protected initializeLocalCore(): void;
|
|
192
243
|
/**
|
|
193
244
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
|
package/dist/sequence.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequence.d.ts","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAA0B,MAAM,8BAA8B,CAAC;AAEhF,OAAO,EACH,yBAAyB,EAE5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACzB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACH,MAAM,EAKN,YAAY,EACZ,YAAY,EAGZ,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,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"}
|
package/dist/sequence.js
CHANGED
|
@@ -11,8 +11,8 @@ const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
|
11
11
|
const merge_tree_1 = require("@fluidframework/merge-tree");
|
|
12
12
|
const runtime_utils_1 = require("@fluidframework/runtime-utils");
|
|
13
13
|
const shared_object_base_1 = require("@fluidframework/shared-object-base");
|
|
14
|
-
const intervalCollection_1 = require("./intervalCollection");
|
|
15
14
|
const defaultMap_1 = require("./defaultMap");
|
|
15
|
+
const intervalCollection_1 = require("./intervalCollection");
|
|
16
16
|
const sequenceDeltaEvent_1 = require("./sequenceDeltaEvent");
|
|
17
17
|
const snapshotFileName = "header";
|
|
18
18
|
const contentPath = "content";
|
|
@@ -22,7 +22,7 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
22
22
|
this.dataStoreRuntime = dataStoreRuntime;
|
|
23
23
|
this.id = id;
|
|
24
24
|
this.segmentFromSpec = segmentFromSpec;
|
|
25
|
-
|
|
25
|
+
/** `Deferred` that triggers once the object is loaded */
|
|
26
26
|
this.loadedDeferred = new common_utils_1.Deferred();
|
|
27
27
|
// cache out going ops created when partial loading
|
|
28
28
|
this.loadedDeferredOutgoingOps = [];
|
|
@@ -100,6 +100,7 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
100
100
|
case merge_tree_1.MergeTreeDeltaType.REMOVE: {
|
|
101
101
|
const lastRem = ops[ops.length - 1];
|
|
102
102
|
if ((lastRem === null || lastRem === void 0 ? void 0 : lastRem.pos1) === r.position) {
|
|
103
|
+
(0, common_utils_1.assert)(lastRem.pos2 !== undefined, 0x3ff /* pos2 should not be undefined here */);
|
|
103
104
|
lastRem.pos2 += r.segment.cachedLength;
|
|
104
105
|
}
|
|
105
106
|
else {
|
|
@@ -118,15 +119,18 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
118
119
|
*/
|
|
119
120
|
removeRange(start, end) {
|
|
120
121
|
const removeOp = this.client.removeRangeLocal(start, end);
|
|
121
|
-
|
|
122
|
-
this.submitSequenceMessage(removeOp);
|
|
123
|
-
}
|
|
122
|
+
this.submitSequenceMessage(removeOp);
|
|
124
123
|
return removeOp;
|
|
125
124
|
}
|
|
126
125
|
groupOperation(groupOp) {
|
|
127
126
|
this.client.localTransaction(groupOp);
|
|
128
127
|
this.submitSequenceMessage(groupOp);
|
|
129
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Finds the segment information (i.e. segment + offset) corresponding to a character position in the SharedString.
|
|
131
|
+
* If the position is past the end of the string, `segment` and `offset` on the returned object may be undefined.
|
|
132
|
+
* @param pos - Character position (index) into the current local view of the SharedString.
|
|
133
|
+
*/
|
|
130
134
|
getContainingSegment(pos) {
|
|
131
135
|
return this.client.getContainingSegment(pos);
|
|
132
136
|
}
|
|
@@ -165,12 +169,29 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
165
169
|
getRangeExtentsOfPosition(pos) {
|
|
166
170
|
return this.client.getRangeExtentsOfPosition(pos);
|
|
167
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Creates a `LocalReferencePosition` on this SharedString. If the refType does not include
|
|
174
|
+
* ReferenceType.Transient, the returned reference will be added to the localRefs on the provided segment.
|
|
175
|
+
* @param segment - Segment to add the local reference on
|
|
176
|
+
* @param offset - Offset on the segment at which to place the local reference
|
|
177
|
+
* @param refType - ReferenceType for the created local reference
|
|
178
|
+
* @param properties - PropertySet to place on the created local reference
|
|
179
|
+
*/
|
|
168
180
|
createLocalReferencePosition(segment, offset, refType, properties) {
|
|
169
181
|
return this.client.createLocalReferencePosition(segment, offset, refType, properties);
|
|
170
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Resolves a `ReferencePosition` into a character position using this client's perspective.
|
|
185
|
+
*/
|
|
171
186
|
localReferencePositionToPosition(lref) {
|
|
172
187
|
return this.client.localReferencePositionToPosition(lref);
|
|
173
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Removes a `LocalReferencePosition` from this SharedString.
|
|
191
|
+
*/
|
|
192
|
+
removeLocalReferencePosition(lref) {
|
|
193
|
+
return this.client.removeLocalReferencePosition(lref);
|
|
194
|
+
}
|
|
174
195
|
/**
|
|
175
196
|
* Resolves a remote client's position against the local sequence
|
|
176
197
|
* and returns the remote client's position relative to the local
|
|
@@ -198,15 +219,12 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
198
219
|
// local ops until loading is complete, and then
|
|
199
220
|
// they will be resent
|
|
200
221
|
if (!this.loadedDeferred.isCompleted) {
|
|
201
|
-
this.loadedDeferredOutgoingOps.push([translated, metadata]);
|
|
222
|
+
this.loadedDeferredOutgoingOps.push(metadata ? [translated, metadata] : translated);
|
|
202
223
|
}
|
|
203
224
|
else {
|
|
204
225
|
this.submitLocalMessage(translated, metadata);
|
|
205
226
|
}
|
|
206
227
|
}
|
|
207
|
-
removeLocalReferencePosition(lref) {
|
|
208
|
-
return this.client.removeLocalReferencePosition(lref);
|
|
209
|
-
}
|
|
210
228
|
/**
|
|
211
229
|
* Given a position specified relative to a marker id, lookup the marker
|
|
212
230
|
* and convert the position to a character position.
|
|
@@ -229,18 +247,23 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
229
247
|
* @param splitRange - Optional. Splits boundary segments on the range boundaries
|
|
230
248
|
*/
|
|
231
249
|
walkSegments(handler, start, end, accum, splitRange = false) {
|
|
232
|
-
|
|
250
|
+
this.client.walkSegments(handler, start, end, accum, splitRange);
|
|
233
251
|
}
|
|
234
|
-
/**
|
|
235
|
-
* @deprecated for internal use only. public export will be removed.
|
|
236
|
-
* @internal
|
|
237
|
-
*/
|
|
238
252
|
getStackContext(startPos, rangeLabels) {
|
|
239
253
|
return this.client.getStackContext(startPos, rangeLabels);
|
|
240
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* @returns - The most recent sequence number which has been acked by the server and processed by this
|
|
257
|
+
* SharedSegmentSequence.
|
|
258
|
+
*/
|
|
241
259
|
getCurrentSeq() {
|
|
242
260
|
return this.client.getCurrentSeq();
|
|
243
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Inserts a segment directly before a `ReferencePosition`.
|
|
264
|
+
* @param refPos - The reference position to insert the segment at
|
|
265
|
+
* @param segment - The segment to insert
|
|
266
|
+
*/
|
|
244
267
|
insertAtReferencePosition(pos, segment) {
|
|
245
268
|
const insertOp = this.client.insertAtReferencePositionLocal(pos, segment);
|
|
246
269
|
if (insertOp) {
|
|
@@ -248,12 +271,21 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
248
271
|
}
|
|
249
272
|
}
|
|
250
273
|
/**
|
|
251
|
-
*
|
|
252
|
-
*
|
|
274
|
+
* Inserts a segment
|
|
275
|
+
* @param start - The position to insert the segment at
|
|
276
|
+
* @param spec - The segment to inserts spec
|
|
253
277
|
*/
|
|
254
|
-
|
|
255
|
-
|
|
278
|
+
insertFromSpec(pos, spec) {
|
|
279
|
+
const segment = this.segmentFromSpec(spec);
|
|
280
|
+
const insertOp = this.client.insertSegmentLocal(pos, segment);
|
|
281
|
+
if (insertOp) {
|
|
282
|
+
this.submitSequenceMessage(insertOp);
|
|
283
|
+
}
|
|
256
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Retrieves the interval collection keyed on `label`. If no such interval collection exists,
|
|
287
|
+
* creates one.
|
|
288
|
+
*/
|
|
257
289
|
getIntervalCollection(label) {
|
|
258
290
|
return this.intervalCollections.get(label);
|
|
259
291
|
}
|
|
@@ -271,6 +303,9 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
271
303
|
getIntervalCollectionLabels() {
|
|
272
304
|
return this.intervalCollections.keys();
|
|
273
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
308
|
+
*/
|
|
274
309
|
summarizeCore(serializer, telemetryContext) {
|
|
275
310
|
const builder = new runtime_utils_1.SummaryTreeBuilder();
|
|
276
311
|
// conditionally write the interval collection blob
|
|
@@ -308,18 +343,28 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
308
343
|
if (insert) {
|
|
309
344
|
if (start < end) {
|
|
310
345
|
const remove = this.client.removeRangeLocal(start, end);
|
|
311
|
-
|
|
346
|
+
const op = remove ? (0, merge_tree_1.createGroupOp)(insert, remove) : insert;
|
|
347
|
+
this.submitSequenceMessage(op);
|
|
312
348
|
}
|
|
313
349
|
else {
|
|
314
350
|
this.submitSequenceMessage(insert);
|
|
315
351
|
}
|
|
316
352
|
}
|
|
317
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onConnect}
|
|
356
|
+
*/
|
|
318
357
|
onConnect() {
|
|
319
358
|
// Update merge tree collaboration information with new client ID and then resend pending ops
|
|
320
359
|
this.client.startOrUpdateCollaboration(this.runtime.clientId);
|
|
321
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
|
|
363
|
+
*/
|
|
322
364
|
onDisconnect() { }
|
|
365
|
+
/**
|
|
366
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
|
|
367
|
+
*/
|
|
323
368
|
reSubmitCore(content, localOpMetadata) {
|
|
324
369
|
if (!this.intervalCollections.tryResubmitMessage(content, localOpMetadata)) {
|
|
325
370
|
this.submitSequenceMessage(this.client.regeneratePendingOp(content, localOpMetadata));
|
|
@@ -379,6 +424,9 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
379
424
|
this.loadFinished(error);
|
|
380
425
|
}
|
|
381
426
|
}
|
|
427
|
+
/**
|
|
428
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
|
|
429
|
+
*/
|
|
382
430
|
processCore(message, local, localOpMetadata) {
|
|
383
431
|
// if loading isn't complete, we need to cache all
|
|
384
432
|
// incoming ops to be applied after loading is complete
|
|
@@ -394,6 +442,9 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
394
442
|
}
|
|
395
443
|
}
|
|
396
444
|
}
|
|
445
|
+
/**
|
|
446
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.didAttach}
|
|
447
|
+
*/
|
|
397
448
|
didAttach() {
|
|
398
449
|
var _a;
|
|
399
450
|
// If we are not local, and we've attached we need to start generating and sending ops
|
|
@@ -402,6 +453,9 @@ class SharedSegmentSequence extends shared_object_base_1.SharedObject {
|
|
|
402
453
|
this.client.startOrUpdateCollaboration((_a = this.runtime.clientId) !== null && _a !== void 0 ? _a : "attached");
|
|
403
454
|
}
|
|
404
455
|
}
|
|
456
|
+
/**
|
|
457
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.initializeLocalCore}
|
|
458
|
+
*/
|
|
405
459
|
initializeLocalCore() {
|
|
406
460
|
super.initializeLocalCore();
|
|
407
461
|
this.loadFinished();
|