@fluidframework/tree 2.50.0-345060 → 2.50.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 +100 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree-core/defaultResubmitMachine.d.ts +8 -12
- package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
- package/dist/shared-tree-core/defaultResubmitMachine.js +54 -46
- package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
- package/dist/shared-tree-core/resubmitMachine.d.ts +6 -0
- package/dist/shared-tree-core/resubmitMachine.d.ts.map +1 -1
- package/dist/shared-tree-core/resubmitMachine.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +16 -3
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/configuration.js +4 -4
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree-core/defaultResubmitMachine.d.ts +8 -12
- package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
- package/lib/shared-tree-core/defaultResubmitMachine.js +55 -47
- package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
- package/lib/shared-tree-core/resubmitMachine.d.ts +6 -0
- package/lib/shared-tree-core/resubmitMachine.d.ts.map +1 -1
- package/lib/shared-tree-core/resubmitMachine.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +16 -3
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/configuration.js +4 -4
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/package.json +20 -20
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree-core/defaultResubmitMachine.ts +99 -52
- package/src/shared-tree-core/resubmitMachine.ts +7 -0
- package/src/shared-tree-core/sharedTreeCore.ts +18 -6
- package/src/simple-tree/api/configuration.ts +4 -4
- package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,105 @@
|
|
|
1
1
|
# @fluidframework/tree
|
|
2
2
|
|
|
3
|
+
## 2.50.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Record node kind was added (alpha) ([#24908](https://github.com/microsoft/FluidFramework/pull/24908)) [b25667bcdc](https://github.com/microsoft/FluidFramework/commit/b25667bcdcad5584f35783f6a32270803b6dfb1c)
|
|
8
|
+
|
|
9
|
+
Adds a new kind of node to SharedTree that models a TypeScript record.
|
|
10
|
+
As is the case with map nodes, record nodes only support string keys.
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
class MyRecord extends schemaFactory.record("my-record", [
|
|
14
|
+
schemaFactory.number,
|
|
15
|
+
schemaFactory.string,
|
|
16
|
+
]) {}
|
|
17
|
+
const myRecord = new MyRecord({
|
|
18
|
+
foo: 42,
|
|
19
|
+
bar: "Hello world!",
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const foo = myRecord.foo; // 42
|
|
23
|
+
|
|
24
|
+
delete myRecord.foo;
|
|
25
|
+
|
|
26
|
+
myRecord.baz = 37;
|
|
27
|
+
|
|
28
|
+
const keys = Object.keys(myRecord); // ["bar", "baz"]
|
|
29
|
+
const values = Object.values(myRecord); // ["Hello world!", 37]
|
|
30
|
+
const entries = Object.entries(myRecord); // [["bar", "Hello world!"], ["baz", 37]]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
#### `NodeKind` enum update
|
|
34
|
+
|
|
35
|
+
This change includes the addition of a new flag to the [NodeKind](https://fluidframework.com/docs/api/fluid-framework/nodekind-enum) enum.
|
|
36
|
+
This API notes in its documentation that users should not treat its flags as an exhaustive set.
|
|
37
|
+
|
|
38
|
+
This change may break code that treats it that way.
|
|
39
|
+
We recommend updating your code to be more tolerant of unknown node kinds going forward.
|
|
40
|
+
|
|
41
|
+
Also see alternative options for schema-agnostic tree traversal if needed:
|
|
42
|
+
|
|
43
|
+
- [Tree.parent](https://fluidframework.com/docs/api/fluid-framework/treenodeapi-interface#parent-methodsignature)
|
|
44
|
+
- [TreeAlpha.child](https://fluidframework.com/docs/api/fluid-framework/treealpha-interface#child-methodsignature)
|
|
45
|
+
- [TreeAlpha.children](https://fluidframework.com/docs/api/fluid-framework/treealpha-interface#children-methodsignature)
|
|
46
|
+
|
|
47
|
+
#### Additional features
|
|
48
|
+
|
|
49
|
+
In addition to the operations afforded by TypeScript records, SharedTree record nodes can be iterated (equivalent to Object.entries).
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
class MyRecord extends schemaFactory.record("my-record", [schemaFactory.number, schemaFactory.string]) {}
|
|
53
|
+
const myRecord = new MyRecord({
|
|
54
|
+
foo: 42,
|
|
55
|
+
bar: "Hello world!"
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
for (const [key, value] of myRecord) {
|
|
59
|
+
...
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const a = { ...myRecord }; // { foo: 42, bar: "Hello world!" }
|
|
63
|
+
const b = [...myRecord]; // [["foo", 42], ["bar, "Hello world!"]]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### Recursive records
|
|
67
|
+
|
|
68
|
+
Recursive record schema can be defined using `recordRecursive` on [SchemaFactoryAlpha](https://fluidframework.com/docs/api/fluid-framework/schemafactoryalpha-class).
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
class MyRecord extends schemaFactory.recordRecursive("my-record", [
|
|
72
|
+
schemaFactory.string,
|
|
73
|
+
() => MyRecord,
|
|
74
|
+
]) {}
|
|
75
|
+
const myRecord = new MyRecord({
|
|
76
|
+
foo: "Hello world!",
|
|
77
|
+
bar: new MyRecord({
|
|
78
|
+
x: "foo",
|
|
79
|
+
y: new MyRecord({}),
|
|
80
|
+
}),
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### TableSchema update (alpha)
|
|
85
|
+
|
|
86
|
+
The [TableSchema](https://fluidframework.com/docs/api/fluid-framework/tableschema-namespace/) APIs have been updated to use record nodes in the schema they generate.
|
|
87
|
+
Specifically, the `Row` representation now uses a record to store its column-cell pairs, rather than a map.
|
|
88
|
+
|
|
89
|
+
The node types derived from these APIs model their data in a row-major format.
|
|
90
|
+
That is, each row in the table contains the set of cells that belong to that row, where each cell is indexed by its corresponding column.
|
|
91
|
+
|
|
92
|
+
Previously, this was modeled using a [MapNode](https://fluidframework.com/docs/api/fluid-framework/treemapnode-interface).
|
|
93
|
+
This format proved cumbersome to interop with popular table rendering libraries like [tanstack](https://tanstack.com/table), which expect a record-like format.
|
|
94
|
+
|
|
95
|
+
The persisted format of documents containing trees derived from these APIs is the same, so this change is forward and backward compatible.
|
|
96
|
+
|
|
97
|
+
#### JsonDomainSchema update (alpha)
|
|
98
|
+
|
|
99
|
+
[JsonObject](https://fluidframework.com/docs/api/fluid-framework/jsonastree-namespace/jsonobject-class) has been updated to a record rather than a map.
|
|
100
|
+
|
|
101
|
+
The persisted format of documents containing trees derived from these APIs is the same, so this change is forward and backward compatible.
|
|
102
|
+
|
|
3
103
|
## 2.43.0
|
|
4
104
|
|
|
5
105
|
### Minor Changes
|
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/tree";
|
|
8
|
-
export declare const pkgVersion = "2.50.0
|
|
8
|
+
export declare const pkgVersion = "2.50.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,yBAAyB,CAAC;AAC9C,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,yBAAyB,CAAC;AAC9C,eAAO,MAAM,UAAU,WAAW,CAAC"}
|
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/tree";
|
|
11
|
-
exports.pkgVersion = "2.50.0
|
|
11
|
+
exports.pkgVersion = "2.50.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,sBAAsB,CAAC;AACjC,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,sBAAsB,CAAC;AACjC,QAAA,UAAU,GAAG,QAAQ,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/tree\";\nexport const pkgVersion = \"2.50.0\";\n"]}
|
|
@@ -20,22 +20,17 @@ export declare class DefaultResubmitMachine<TChange> implements ResubmitMachine<
|
|
|
20
20
|
/**
|
|
21
21
|
* The list of commits (from oldest to most recent) that have been submitted but not sequenced.
|
|
22
22
|
*/
|
|
23
|
-
private inFlightQueue;
|
|
23
|
+
private readonly inFlightQueue;
|
|
24
24
|
/**
|
|
25
|
-
* The
|
|
25
|
+
* The range of in-flight commits that are currently being resubmitted.
|
|
26
|
+
* Defined only during the resubmit phase.
|
|
26
27
|
*/
|
|
27
|
-
private
|
|
28
|
+
private pendingResubmitRange;
|
|
28
29
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* All in-flight commits with an index inferior or equal to this number have stale enrichments.
|
|
32
|
-
*
|
|
33
|
-
* Is -1 when *any* of the following is true:
|
|
34
|
-
* - There are no in-flight commits (i.e., no local commits have been made or they have all been sequenced)
|
|
35
|
-
* - None of the in-flight commits have been rebased
|
|
36
|
-
* - In-flight commits that have been rebased have all had their enrichments updated
|
|
30
|
+
* The current enrichment version for in-flight commits.
|
|
31
|
+
* Incremented when a peer commit is sequenced.
|
|
37
32
|
*/
|
|
38
|
-
private
|
|
33
|
+
private currentEnrichment;
|
|
39
34
|
constructor(
|
|
40
35
|
/**
|
|
41
36
|
* A function that can create a rollback for a given change.
|
|
@@ -47,6 +42,7 @@ export declare class DefaultResubmitMachine<TChange> implements ResubmitMachine<
|
|
|
47
42
|
*/
|
|
48
43
|
tip: ChangeEnricherReadonlyCheckout<TChange>);
|
|
49
44
|
onCommitSubmitted(commit: GraphCommit<TChange>): void;
|
|
45
|
+
onCommitRollback(commit: GraphCommit<TChange>): void;
|
|
50
46
|
prepareForResubmit(toResubmit: readonly GraphCommit<TChange>[]): void;
|
|
51
47
|
peekNextCommit(): GraphCommit<TChange>;
|
|
52
48
|
get isInResubmitPhase(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultResubmitMachine.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/defaultResubmitMachine.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"defaultResubmitMachine.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/defaultResubmitMachine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGlE,OAAO,KAAK,EAAE,8BAA8B,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAQlF;;GAEG;AACH,qBAAa,sBAAsB,CAAC,OAAO,CAAE,YAAW,eAAe,CAAC,OAAO,CAAC;IAoB9E;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,GAAG;IA3BrB;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CACN;IAExB;;;OAGG;IACH,OAAO,CAAC,oBAAoB,CAAoD;IAEhF;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAAa;;IAGrC;;OAEG;IACc,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,OAAO;IACzE;;;OAGG;IACc,GAAG,EAAE,8BAA8B,CAAC,OAAO,CAAC;IAGvD,iBAAiB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI;IAoBrD,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI;IAQpD,kBAAkB,CAAC,UAAU,EAAE,SAAS,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI;IA0ErE,cAAc,IAAI,WAAW,CAAC,OAAO,CAAC;IAY7C,IAAW,iBAAiB,IAAI,OAAO,CAEtC;IAEM,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CAUvD"}
|
|
@@ -26,39 +26,49 @@ class DefaultResubmitMachine {
|
|
|
26
26
|
/**
|
|
27
27
|
* The list of commits (from oldest to most recent) that have been submitted but not sequenced.
|
|
28
28
|
*/
|
|
29
|
-
this.inFlightQueue =
|
|
29
|
+
this.inFlightQueue = new internal_1.DoublyLinkedList();
|
|
30
30
|
/**
|
|
31
|
-
* The
|
|
31
|
+
* The current enrichment version for in-flight commits.
|
|
32
|
+
* Incremented when a peer commit is sequenced.
|
|
32
33
|
*/
|
|
33
|
-
this.
|
|
34
|
-
/**
|
|
35
|
-
* Represents the index in the `inFlightQueue` array of the most recent in flight commit that has
|
|
36
|
-
* undergone rebasing but whose enrichments have not been updated.
|
|
37
|
-
* All in-flight commits with an index inferior or equal to this number have stale enrichments.
|
|
38
|
-
*
|
|
39
|
-
* Is -1 when *any* of the following is true:
|
|
40
|
-
* - There are no in-flight commits (i.e., no local commits have been made or they have all been sequenced)
|
|
41
|
-
* - None of the in-flight commits have been rebased
|
|
42
|
-
* - In-flight commits that have been rebased have all had their enrichments updated
|
|
43
|
-
*/
|
|
44
|
-
this.latestInFlightCommitWithStaleEnrichments = -1;
|
|
34
|
+
this.currentEnrichment = 0;
|
|
45
35
|
}
|
|
46
36
|
onCommitSubmitted(commit) {
|
|
47
|
-
if (this.
|
|
48
|
-
const toResubmit = this.
|
|
49
|
-
(0, internal_1.assert)(toResubmit === commit, 0x981 /* Unexpected commit submitted during resubmit phase */);
|
|
37
|
+
if (this.pendingResubmitRange !== undefined) {
|
|
38
|
+
const toResubmit = this.pendingResubmitRange?.first;
|
|
39
|
+
(0, internal_1.assert)(toResubmit?.data.commit === commit, 0x981 /* Unexpected commit submitted during resubmit phase */);
|
|
40
|
+
// If we are not at the last commit to resubmit, advance the range to the next node.
|
|
41
|
+
// Otherwise, clear the resubmit range as we are done resubmitting.
|
|
42
|
+
if (toResubmit !== this.pendingResubmitRange.last) {
|
|
43
|
+
(0, internal_1.assert)(toResubmit.next !== undefined, 0xbd6 /* must be more in the list */);
|
|
44
|
+
this.pendingResubmitRange.first = toResubmit.next;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.pendingResubmitRange = undefined;
|
|
48
|
+
}
|
|
49
|
+
toResubmit.remove();
|
|
50
50
|
}
|
|
51
|
-
this.inFlightQueue.push(commit);
|
|
51
|
+
this.inFlightQueue.push({ commit, lastEnrichment: this.currentEnrichment });
|
|
52
|
+
}
|
|
53
|
+
onCommitRollback(commit) {
|
|
54
|
+
(0, internal_1.assert)(commit.revision === this.inFlightQueue.last?.data.commit.revision, 0xbd7 /* must rollback latest commit in the in flight queue */);
|
|
55
|
+
this.inFlightQueue.pop();
|
|
52
56
|
}
|
|
53
57
|
prepareForResubmit(toResubmit) {
|
|
54
58
|
(0, internal_1.assert)(!this.isInResubmitPhase, 0x957 /* Invalid resubmit phase start during incomplete resubmit phase */);
|
|
55
|
-
(0,
|
|
56
|
-
|
|
57
|
-
// No in-flight commits have stale enrichments, so we can resubmit them as is
|
|
58
|
-
this.resubmitQueue = this.inFlightQueue;
|
|
59
|
-
this.inFlightQueue = [];
|
|
59
|
+
if (!(0, index_js_1.hasSome)(toResubmit)) {
|
|
60
|
+
return;
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
+
(0, internal_1.assert)(toResubmit.length <= this.inFlightQueue.length, 0xbd8 /* Unexpected resubmit of more commits than are in flight */);
|
|
63
|
+
// Find the first in-flight commit to resubmit.
|
|
64
|
+
const first = this.inFlightQueue.find((v) => v.data.commit.revision === toResubmit[0].revision);
|
|
65
|
+
// Always resubmit to the end of all outstanding ops, but the list may grow during resubmit,
|
|
66
|
+
// so we must track the current end at the start of the phase.
|
|
67
|
+
const last = this.inFlightQueue.last;
|
|
68
|
+
(0, internal_1.assert)(first !== undefined && last !== undefined, 0xbd9 /* there must be inflight commits to resubmit */);
|
|
69
|
+
this.pendingResubmitRange = { first, last };
|
|
70
|
+
// If any in-flight commits have stale enrichments, recompute them.
|
|
71
|
+
if (first.data.lastEnrichment < this.currentEnrichment) {
|
|
62
72
|
const checkout = this.tip.fork();
|
|
63
73
|
// Roll back the checkout to the state before the oldest commit
|
|
64
74
|
for (let iCommit = toResubmit.length - 1; iCommit >= 0; iCommit -= 1) {
|
|
@@ -69,46 +79,44 @@ class DefaultResubmitMachine {
|
|
|
69
79
|
// forwards from an earlier fork instead of backwards.
|
|
70
80
|
checkout.applyTipChange(rollback);
|
|
71
81
|
}
|
|
72
|
-
// Update the enrichments of the stale commits
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
// Update the enrichments of the stale commits in the in-flight queue.
|
|
83
|
+
let current = first;
|
|
84
|
+
for (const commit of toResubmit) {
|
|
85
|
+
(0, internal_1.assert)(current !== undefined, 0xbda /* there must be an inflight commit for each resubmit commit */);
|
|
86
|
+
current.data.commit = commit;
|
|
87
|
+
if (current.data.lastEnrichment < this.currentEnrichment) {
|
|
88
|
+
const enrichedChange = checkout.updateChangeEnrichments(commit.change, commit.revision);
|
|
89
|
+
const enrichedCommit = { ...commit, change: enrichedChange };
|
|
90
|
+
// Optimization: only apply the enriched change if the next commit also needs enrichment.
|
|
91
|
+
if (current.next !== undefined &&
|
|
92
|
+
current.next.data.lastEnrichment < this.currentEnrichment) {
|
|
93
|
+
checkout.applyTipChange(enrichedChange, commit.revision);
|
|
94
|
+
}
|
|
95
|
+
current.data.commit = enrichedCommit;
|
|
96
|
+
current.data.lastEnrichment = this.currentEnrichment;
|
|
80
97
|
}
|
|
81
|
-
|
|
98
|
+
current = current.next;
|
|
82
99
|
}
|
|
83
100
|
checkout[index_js_1.disposeSymbol]();
|
|
84
|
-
// Whatever commits are left do not have stale enrichments
|
|
85
|
-
for (const commit of this.inFlightQueue) {
|
|
86
|
-
this.resubmitQueue.push(commit);
|
|
87
|
-
}
|
|
88
|
-
this.inFlightQueue.length = 0;
|
|
89
101
|
}
|
|
90
|
-
this.latestInFlightCommitWithStaleEnrichments = -1;
|
|
91
102
|
}
|
|
92
103
|
peekNextCommit() {
|
|
93
104
|
(0, internal_1.assert)(this.isInResubmitPhase, 0x982 /* No available commit to resubmit outside of resubmit phase */);
|
|
94
|
-
(0, internal_1.assert)(
|
|
95
|
-
return this.
|
|
105
|
+
(0, internal_1.assert)(this.pendingResubmitRange !== undefined, 0xa87 /* Expected resubmit queue to be non-empty */);
|
|
106
|
+
return this.pendingResubmitRange.first.data.commit;
|
|
96
107
|
}
|
|
97
108
|
get isInResubmitPhase() {
|
|
98
|
-
return this.
|
|
109
|
+
return this.pendingResubmitRange !== undefined;
|
|
99
110
|
}
|
|
100
111
|
onSequencedCommitApplied(isLocal) {
|
|
101
112
|
if (isLocal) {
|
|
102
113
|
// The oldest in-flight commit has been sequenced
|
|
103
114
|
(0, internal_1.assert)(this.inFlightQueue.length > 0, 0x959 /* Sequencing of unknown local commit */);
|
|
104
115
|
this.inFlightQueue.shift();
|
|
105
|
-
if (this.latestInFlightCommitWithStaleEnrichments >= 0) {
|
|
106
|
-
this.latestInFlightCommitWithStaleEnrichments -= 1;
|
|
107
|
-
}
|
|
108
116
|
}
|
|
109
117
|
else {
|
|
110
118
|
// A peer commit has been sequenced
|
|
111
|
-
this.
|
|
119
|
+
this.currentEnrichment++;
|
|
112
120
|
}
|
|
113
121
|
}
|
|
114
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultResubmitMachine.js","sourceRoot":"","sources":["../../src/shared-tree-core/defaultResubmitMachine.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAGlE,+CAA0D;AAI1D;;GAEG;AACH,MAAa,sBAAsB;IAuBlC;IACC;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cAAc;QACpB,IAAA,iBAAM,EACL,IAAI,CAAC,iBAAiB,EACtB,KAAK,CAAC,+DAA+D,CACrE,CAAC;QACF,IAAA,iBAAM,EAAC,IAAA,kBAAO,EAAC,IAAI,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACzF,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,IAAW,iBAAiB;QAC3B,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC;IACxC,CAAC;IAEM,wBAAwB,CAAC,OAAgB;QAC/C,IAAI,OAAO,EAAE,CAAC;YACb,iDAAiD;YACjD,IAAA,iBAAM,EAAC,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,CAAC,wCAAwC,CAAC,CAAC;YACtF,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;YAC3B,IAAI,IAAI,CAAC,wCAAwC,IAAI,CAAC,EAAE,CAAC;gBACxD,IAAI,CAAC,wCAAwC,IAAI,CAAC,CAAC;YACpD,CAAC;QACF,CAAC;aAAM,CAAC;YACP,mCAAmC;YACnC,IAAI,CAAC,wCAAwC,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/E,CAAC;IACF,CAAC;CACD;AA5HD,wDA4HC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob } from \"@fluidframework/core-utils/internal\";\n\nimport type { GraphCommit, TaggedChange } from \"../core/index.js\";\nimport { disposeSymbol, hasSome } from \"../util/index.js\";\n\nimport type { ChangeEnricherReadonlyCheckout, ResubmitMachine } from \"./index.js\";\n\n/**\n * Default implementation of {@link ResubmitMachine}.\n */\nexport class DefaultResubmitMachine<TChange> implements ResubmitMachine<TChange> {\n\t/**\n\t * The list of commits (from oldest to most recent) that have been submitted but not sequenced.\n\t */\n\tprivate inFlightQueue: GraphCommit<TChange>[] = [];\n\n\t/**\n\t * The list of commits (from oldest to most recent) that should be resubmitted.\n\t */\n\tprivate resubmitQueue: GraphCommit<TChange>[] = [];\n\n\t/**\n\t * Represents the index in the `inFlightQueue` array of the most recent in flight commit that has\n\t * undergone rebasing but whose enrichments have not been updated.\n\t * All in-flight commits with an index inferior or equal to this number have stale enrichments.\n\t *\n\t * Is -1 when *any* of the following is true:\n\t * - There are no in-flight commits (i.e., no local commits have been made or they have all been sequenced)\n\t * - None of the in-flight commits have been rebased\n\t * - In-flight commits that have been rebased have all had their enrichments updated\n\t */\n\tprivate latestInFlightCommitWithStaleEnrichments: number = -1;\n\n\tpublic constructor(\n\t\t/**\n\t\t * A function that can create a rollback for a given change.\n\t\t */\n\t\tprivate readonly makeRollback: (change: TaggedChange<TChange>) => TChange,\n\t\t/**\n\t\t * Change enricher that represent the tip of the top-level local branch (i.e., the branch on which in-flight\n\t\t * commits are applied and automatically rebased).\n\t\t */\n\t\tprivate readonly tip: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {}\n\n\tpublic onCommitSubmitted(commit: GraphCommit<TChange>): void {\n\t\tif (this.isInResubmitPhase) {\n\t\t\tconst toResubmit = this.resubmitQueue.shift();\n\t\t\tassert(\n\t\t\t\ttoResubmit === commit,\n\t\t\t\t0x981 /* Unexpected commit submitted during resubmit phase */,\n\t\t\t);\n\t\t}\n\t\tthis.inFlightQueue.push(commit);\n\t}\n\n\tpublic prepareForResubmit(toResubmit: readonly GraphCommit<TChange>[]): void {\n\t\tassert(\n\t\t\t!this.isInResubmitPhase,\n\t\t\t0x957 /* Invalid resubmit phase start during incomplete resubmit phase */,\n\t\t);\n\t\tassert(\n\t\t\ttoResubmit.length === this.inFlightQueue.length,\n\t\t\t0x958 /* Unexpected resubmit of more or fewer commits than are in flight */,\n\t\t);\n\t\tif (this.latestInFlightCommitWithStaleEnrichments === -1) {\n\t\t\t// No in-flight commits have stale enrichments, so we can resubmit them as is\n\t\t\tthis.resubmitQueue = this.inFlightQueue;\n\t\t\tthis.inFlightQueue = [];\n\t\t} else {\n\t\t\tconst checkout = this.tip.fork();\n\t\t\t// Roll back the checkout to the state before the oldest commit\n\t\t\tfor (let iCommit = toResubmit.length - 1; iCommit >= 0; iCommit -= 1) {\n\t\t\t\tconst commit = toResubmit[iCommit] ?? oob();\n\t\t\t\tconst rollback = this.makeRollback(commit);\n\t\t\t\t// WARNING: it's not currently possible to roll back past a schema change (see AB#7265).\n\t\t\t\t// Either we have to make it possible to do so, or this logic will have to change to work\n\t\t\t\t// forwards from an earlier fork instead of backwards.\n\t\t\t\tcheckout.applyTipChange(rollback);\n\t\t\t}\n\t\t\t// Update the enrichments of the stale commits\n\t\t\tfor (\n\t\t\t\tlet iCommit = 0;\n\t\t\t\tiCommit <= this.latestInFlightCommitWithStaleEnrichments;\n\t\t\t\tiCommit += 1\n\t\t\t) {\n\t\t\t\tconst commit = toResubmit[iCommit] ?? oob();\n\t\t\t\tconst enrichedChange = checkout.updateChangeEnrichments(\n\t\t\t\t\tcommit.change,\n\t\t\t\t\tcommit.revision,\n\t\t\t\t);\n\t\t\t\tconst enrichedCommit = { ...commit, change: enrichedChange };\n\t\t\t\tthis.resubmitQueue.push(enrichedCommit);\n\t\t\t\tif (iCommit < this.latestInFlightCommitWithStaleEnrichments) {\n\t\t\t\t\tcheckout.applyTipChange(enrichedChange, commit.revision);\n\t\t\t\t}\n\t\t\t\tthis.inFlightQueue.shift();\n\t\t\t}\n\t\t\tcheckout[disposeSymbol]();\n\t\t\t// Whatever commits are left do not have stale enrichments\n\t\t\tfor (const commit of this.inFlightQueue) {\n\t\t\t\tthis.resubmitQueue.push(commit);\n\t\t\t}\n\t\t\tthis.inFlightQueue.length = 0;\n\t\t}\n\t\tthis.latestInFlightCommitWithStaleEnrichments = -1;\n\t}\n\n\tpublic peekNextCommit(): GraphCommit<TChange> {\n\t\tassert(\n\t\t\tthis.isInResubmitPhase,\n\t\t\t0x982 /* No available commit to resubmit outside of resubmit phase */,\n\t\t);\n\t\tassert(hasSome(this.resubmitQueue), 0xa87 /* Expected resubmit queue to be non-empty */);\n\t\treturn this.resubmitQueue[0];\n\t}\n\n\tpublic get isInResubmitPhase(): boolean {\n\t\treturn this.resubmitQueue.length !== 0;\n\t}\n\n\tpublic onSequencedCommitApplied(isLocal: boolean): void {\n\t\tif (isLocal) {\n\t\t\t// The oldest in-flight commit has been sequenced\n\t\t\tassert(this.inFlightQueue.length > 0, 0x959 /* Sequencing of unknown local commit */);\n\t\t\tthis.inFlightQueue.shift();\n\t\t\tif (this.latestInFlightCommitWithStaleEnrichments >= 0) {\n\t\t\t\tthis.latestInFlightCommitWithStaleEnrichments -= 1;\n\t\t\t}\n\t\t} else {\n\t\t\t// A peer commit has been sequenced\n\t\t\tthis.latestInFlightCommitWithStaleEnrichments = this.inFlightQueue.length - 1;\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"defaultResubmitMachine.js","sourceRoot":"","sources":["../../src/shared-tree-core/defaultResubmitMachine.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAM6C;AAG7C,+CAA0D;AAU1D;;GAEG;AACH,MAAa,sBAAsB;IAmBlC;IACC;;OAEG;IACc,YAAwD;IACzE;;;OAGG;IACc,GAA4C;QAL5C,iBAAY,GAAZ,YAAY,CAA4C;QAKxD,QAAG,GAAH,GAAG,CAAyC;QA3B9D;;WAEG;QACc,kBAAa,GAC7B,IAAI,2BAAgB,EAAE,CAAC;QAQxB;;;WAGG;QACK,sBAAiB,GAAW,CAAC,CAAC;IAYnC,CAAC;IAEG,iBAAiB,CAAC,MAA4B;QACpD,IAAI,IAAI,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;YAC7C,MAAM,UAAU,GAAG,IAAI,CAAC,oBAAoB,EAAE,KAAK,CAAC;YACpD,IAAA,iBAAM,EACL,UAAU,EAAE,IAAI,CAAC,MAAM,KAAK,MAAM,EAClC,KAAK,CAAC,uDAAuD,C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CAAC;QAC5B,CAAC;aAAM,CAAC;YACP,mCAAmC;YACnC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC1B,CAAC;IACF,CAAC;CACD;AA/JD,wDA+JC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tassert,\n\tDoublyLinkedList,\n\toob,\n\ttype ListNode,\n\ttype ListNodeRange,\n} from \"@fluidframework/core-utils/internal\";\n\nimport type { GraphCommit, TaggedChange } from \"../core/index.js\";\nimport { disposeSymbol, hasSome } from \"../util/index.js\";\n\nimport type { ChangeEnricherReadonlyCheckout, ResubmitMachine } from \"./index.js\";\n\ninterface PendingChange<TChange> {\n\tcommit: GraphCommit<TChange>;\n\tlastEnrichment: number;\n}\ntype PendingChangeNode<TChange> = ListNode<PendingChange<TChange>>;\n\n/**\n * Default implementation of {@link ResubmitMachine}.\n */\nexport class DefaultResubmitMachine<TChange> implements ResubmitMachine<TChange> {\n\t/**\n\t * The list of commits (from oldest to most recent) that have been submitted but not sequenced.\n\t */\n\tprivate readonly inFlightQueue: DoublyLinkedList<PendingChange<TChange>> =\n\t\tnew DoublyLinkedList();\n\n\t/**\n\t * The range of in-flight commits that are currently being resubmitted.\n\t * Defined only during the resubmit phase.\n\t */\n\tprivate pendingResubmitRange: ListNodeRange<PendingChange<TChange>> | undefined;\n\n\t/**\n\t * The current enrichment version for in-flight commits.\n\t * Incremented when a peer commit is sequenced.\n\t */\n\tprivate currentEnrichment: number = 0;\n\n\tpublic constructor(\n\t\t/**\n\t\t * A function that can create a rollback for a given change.\n\t\t */\n\t\tprivate readonly makeRollback: (change: TaggedChange<TChange>) => TChange,\n\t\t/**\n\t\t * Change enricher that represent the tip of the top-level local branch (i.e., the branch on which in-flight\n\t\t * commits are applied and automatically rebased).\n\t\t */\n\t\tprivate readonly tip: ChangeEnricherReadonlyCheckout<TChange>,\n\t) {}\n\n\tpublic onCommitSubmitted(commit: GraphCommit<TChange>): void {\n\t\tif (this.pendingResubmitRange !== undefined) {\n\t\t\tconst toResubmit = this.pendingResubmitRange?.first;\n\t\t\tassert(\n\t\t\t\ttoResubmit?.data.commit === commit,\n\t\t\t\t0x981 /* Unexpected commit submitted during resubmit phase */,\n\t\t\t);\n\t\t\t// If we are not at the last commit to resubmit, advance the range to the next node.\n\t\t\t// Otherwise, clear the resubmit range as we are done resubmitting.\n\t\t\tif (toResubmit !== this.pendingResubmitRange.last) {\n\t\t\t\tassert(toResubmit.next !== undefined, 0xbd6 /* must be more in the list */);\n\t\t\t\tthis.pendingResubmitRange.first = toResubmit.next;\n\t\t\t} else {\n\t\t\t\tthis.pendingResubmitRange = undefined;\n\t\t\t}\n\t\t\ttoResubmit.remove();\n\t\t}\n\t\tthis.inFlightQueue.push({ commit, lastEnrichment: this.currentEnrichment });\n\t}\n\n\tpublic onCommitRollback(commit: GraphCommit<TChange>): void {\n\t\tassert(\n\t\t\tcommit.revision === this.inFlightQueue.last?.data.commit.revision,\n\t\t\t0xbd7 /* must rollback latest commit in the in flight queue */,\n\t\t);\n\t\tthis.inFlightQueue.pop();\n\t}\n\n\tpublic prepareForResubmit(toResubmit: readonly GraphCommit<TChange>[]): void {\n\t\tassert(\n\t\t\t!this.isInResubmitPhase,\n\t\t\t0x957 /* Invalid resubmit phase start during incomplete resubmit phase */,\n\t\t);\n\n\t\tif (!hasSome(toResubmit)) {\n\t\t\treturn;\n\t\t}\n\n\t\tassert(\n\t\t\ttoResubmit.length <= this.inFlightQueue.length,\n\t\t\t0xbd8 /* Unexpected resubmit of more commits than are in flight */,\n\t\t);\n\n\t\t// Find the first in-flight commit to resubmit.\n\t\tconst first = this.inFlightQueue.find(\n\t\t\t(v) => v.data.commit.revision === toResubmit[0].revision,\n\t\t);\n\t\t// Always resubmit to the end of all outstanding ops, but the list may grow during resubmit,\n\t\t// so we must track the current end at the start of the phase.\n\t\tconst last = this.inFlightQueue.last;\n\t\tassert(\n\t\t\tfirst !== undefined && last !== undefined,\n\t\t\t0xbd9 /* there must be inflight commits to resubmit */,\n\t\t);\n\n\t\tthis.pendingResubmitRange = { first, last };\n\t\t// If any in-flight commits have stale enrichments, recompute them.\n\t\tif (first.data.lastEnrichment < this.currentEnrichment) {\n\t\t\tconst checkout = this.tip.fork();\n\n\t\t\t// Roll back the checkout to the state before the oldest commit\n\t\t\tfor (let iCommit = toResubmit.length - 1; iCommit >= 0; iCommit -= 1) {\n\t\t\t\tconst commit = toResubmit[iCommit] ?? oob();\n\t\t\t\tconst rollback = this.makeRollback(commit);\n\t\t\t\t// WARNING: it's not currently possible to roll back past a schema change (see AB#7265).\n\t\t\t\t// Either we have to make it possible to do so, or this logic will have to change to work\n\t\t\t\t// forwards from an earlier fork instead of backwards.\n\t\t\t\tcheckout.applyTipChange(rollback);\n\t\t\t}\n\n\t\t\t// Update the enrichments of the stale commits in the in-flight queue.\n\t\t\tlet current: PendingChangeNode<TChange> | undefined = first;\n\t\t\tfor (const commit of toResubmit) {\n\t\t\t\tassert(\n\t\t\t\t\tcurrent !== undefined,\n\t\t\t\t\t0xbda /* there must be an inflight commit for each resubmit commit */,\n\t\t\t\t);\n\t\t\t\tcurrent.data.commit = commit;\n\t\t\t\tif (current.data.lastEnrichment < this.currentEnrichment) {\n\t\t\t\t\tconst enrichedChange = checkout.updateChangeEnrichments(\n\t\t\t\t\t\tcommit.change,\n\t\t\t\t\t\tcommit.revision,\n\t\t\t\t\t);\n\t\t\t\t\tconst enrichedCommit = { ...commit, change: enrichedChange };\n\n\t\t\t\t\t// Optimization: only apply the enriched change if the next commit also needs enrichment.\n\t\t\t\t\tif (\n\t\t\t\t\t\tcurrent.next !== undefined &&\n\t\t\t\t\t\tcurrent.next.data.lastEnrichment < this.currentEnrichment\n\t\t\t\t\t) {\n\t\t\t\t\t\tcheckout.applyTipChange(enrichedChange, commit.revision);\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrent.data.commit = enrichedCommit;\n\t\t\t\t\tcurrent.data.lastEnrichment = this.currentEnrichment;\n\t\t\t\t}\n\t\t\t\tcurrent = current.next;\n\t\t\t}\n\t\t\tcheckout[disposeSymbol]();\n\t\t}\n\t}\n\n\tpublic peekNextCommit(): GraphCommit<TChange> {\n\t\tassert(\n\t\t\tthis.isInResubmitPhase,\n\t\t\t0x982 /* No available commit to resubmit outside of resubmit phase */,\n\t\t);\n\t\tassert(\n\t\t\tthis.pendingResubmitRange !== undefined,\n\t\t\t0xa87 /* Expected resubmit queue to be non-empty */,\n\t\t);\n\t\treturn this.pendingResubmitRange.first.data.commit;\n\t}\n\n\tpublic get isInResubmitPhase(): boolean {\n\t\treturn this.pendingResubmitRange !== undefined;\n\t}\n\n\tpublic onSequencedCommitApplied(isLocal: boolean): void {\n\t\tif (isLocal) {\n\t\t\t// The oldest in-flight commit has been sequenced\n\t\t\tassert(this.inFlightQueue.length > 0, 0x959 /* Sequencing of unknown local commit */);\n\t\t\tthis.inFlightQueue.shift();\n\t\t} else {\n\t\t\t// A peer commit has been sequenced\n\t\t\tthis.currentEnrichment++;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -31,6 +31,12 @@ export interface ResubmitMachine<TChange> {
|
|
|
31
31
|
* @param commit - the (enriched) commit (re)submitted. Not mutated.
|
|
32
32
|
*/
|
|
33
33
|
onCommitSubmitted(commit: GraphCommit<TChange>): void;
|
|
34
|
+
/**
|
|
35
|
+
* Must be called on a commit after rollback, so it can be removed
|
|
36
|
+
* as it will never be (re)submitted.
|
|
37
|
+
* @param commit - The commit that was rolled back
|
|
38
|
+
*/
|
|
39
|
+
onCommitRollback(commit: GraphCommit<TChange>): void;
|
|
34
40
|
/**
|
|
35
41
|
* Must be called after a sequenced commit is applied.
|
|
36
42
|
* Note that this may be called multiples times in a row after a number of sequenced commits have been applied
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resubmitMachine.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/resubmitMachine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAA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3,"file":"resubmitMachine.js","sourceRoot":"","sources":["../../src/shared-tree-core/resubmitMachine.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { GraphCommit } from \"../core/index.js\";\n\n/**\n * Encapsulates a state machine that can be used by a {@link SharedTreeCore} manage resubmit phases,\n * especially dealing with the proper updating of enrichments on resubmitted commits.\n */\nexport interface ResubmitMachine<TChange> {\n\t/**\n\t * Must be called before calling `enrichCommit` as part of a resubmit phase.\n\t * @param toResubmit - the commits that will be resubmitted (from oldest to newest).\n\t * This must be the most rebased version of these commits (i.e., rebased over all known concurrent edits)\n\t * as opposed to the version which was last submitted.\n\t * `toResubmit` can be safely mutated by the caller after this call returns.\n\t */\n\tprepareForResubmit(toResubmit: readonly GraphCommit<TChange>[]): void;\n\n\t/**\n\t * @returns the next commit that should be resubmitted.\n\t *\n\t * Throws when invoked outside of a resubmit phase.\n\t */\n\tpeekNextCommit(): GraphCommit<TChange>;\n\n\t/**\n\t * Is true iff the commit enricher is currently in a resubmit phase.\n\t */\n\treadonly isInResubmitPhase: boolean;\n\n\t/**\n\t * Must be when a commit is submitted or resubmitted.\n\t * @param commit - the (enriched) commit (re)submitted. Not mutated.\n\t */\n\tonCommitSubmitted(commit: GraphCommit<TChange>): void;\n\n\t/**\n\t * Must be called after a sequenced commit is applied.\n\t * Note that this may be called multiples times in a row after a number of sequenced commits have been applied\n\t * (as opposed to always being called before the next sequenced commit is applied).\n\t * @param isLocal - whether the sequenced commit was generated by the local session.\n\t */\n\tonSequencedCommitApplied(isLocal: boolean): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resubmitMachine.js","sourceRoot":"","sources":["../../src/shared-tree-core/resubmitMachine.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { GraphCommit } from \"../core/index.js\";\n\n/**\n * Encapsulates a state machine that can be used by a {@link SharedTreeCore} manage resubmit phases,\n * especially dealing with the proper updating of enrichments on resubmitted commits.\n */\nexport interface ResubmitMachine<TChange> {\n\t/**\n\t * Must be called before calling `enrichCommit` as part of a resubmit phase.\n\t * @param toResubmit - the commits that will be resubmitted (from oldest to newest).\n\t * This must be the most rebased version of these commits (i.e., rebased over all known concurrent edits)\n\t * as opposed to the version which was last submitted.\n\t * `toResubmit` can be safely mutated by the caller after this call returns.\n\t */\n\tprepareForResubmit(toResubmit: readonly GraphCommit<TChange>[]): void;\n\n\t/**\n\t * @returns the next commit that should be resubmitted.\n\t *\n\t * Throws when invoked outside of a resubmit phase.\n\t */\n\tpeekNextCommit(): GraphCommit<TChange>;\n\n\t/**\n\t * Is true iff the commit enricher is currently in a resubmit phase.\n\t */\n\treadonly isInResubmitPhase: boolean;\n\n\t/**\n\t * Must be when a commit is submitted or resubmitted.\n\t * @param commit - the (enriched) commit (re)submitted. Not mutated.\n\t */\n\tonCommitSubmitted(commit: GraphCommit<TChange>): void;\n\n\t/**\n\t * Must be called on a commit after rollback, so it can be removed\n\t * as it will never be (re)submitted.\n\t * @param commit - The commit that was rolled back\n\t */\n\tonCommitRollback(commit: GraphCommit<TChange>): void;\n\n\t/**\n\t * Must be called after a sequenced commit is applied.\n\t * Note that this may be called multiples times in a row after a number of sequenced commits have been applied\n\t * (as opposed to always being called before the next sequenced commit is applied).\n\t * @param isLocal - whether the sequenced commit was generated by the local session.\n\t */\n\tonSequencedCommitApplied(isLocal: boolean): void;\n}\n"]}
|
|
@@ -79,6 +79,7 @@ export declare class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
|
79
79
|
getLocalBranch(): SharedTreeBranch<TEditor, TChange>;
|
|
80
80
|
didAttach(): void;
|
|
81
81
|
reSubmitCore(content: JsonCompatibleReadOnly, localOpMetadata: unknown): void;
|
|
82
|
+
rollback(content: JsonCompatibleReadOnly, localOpMetadata: unknown): void;
|
|
82
83
|
applyStashedOp(content: JsonCompatibleReadOnly): void;
|
|
83
84
|
}
|
|
84
85
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedTreeCore.d.ts","sourceRoot":"","sources":["../../src/shared-tree-core/sharedTreeCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAa,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EACX,sCAAsC,EACtC,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,8CAA8C,CAAC;AAEtD,OAAO,KAAK,EACX,YAAY,EACZ,gBAAgB,EAChB,MAAM,6CAA6C,CAAC;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,mBAAmB,CAAC;AACnE,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,kBAAkB,EAEvB,KAAK,WAAW,EAChB,KAAK,WAAW,EAEhB,KAAK,eAAe,EACpB,KAAK,YAAY,EAEjB,KAAK,0BAA0B,EAC/B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,KAAK,sBAAsB,EAE3B,KAAK,SAAS,EACd,KAAK,aAAa,EAGlB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,KAAK,8BAA8B,EAAsB,MAAM,qBAAqB,CAAC;AAQ9F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAK5D,MAAM,WAAW,yBAAyB;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,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AAI;IA4CP;;OAEG;IACI,mBAAmB,CAAC,kBAAkB,EAAE,yBAAyB,GAAG,IAAI;IAuCxE,cAAc,IAAI,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC;IAIpD,SAAS,IAAI,IAAI;IAIjB,YAAY,CAAC,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IA0B7E,QAAQ,CAAC,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAezE,cAAc,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI;CAO5D;AASD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,KAAK,EAAE;QAChB,SAAS,EAAE,yBAAyB,CAAC;QACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;QACrC,yBAAyB,CAAC,EAAE,sCAAsC,CAAC;KACnE,GAAG,qBAAqB,CAAC;IAE1B;;;;;OAKG;IACH,IAAI,CAAC,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClF;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,QAAQ,EAAE,OAAO,KAAK,MAAM,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC"}
|
|
@@ -258,11 +258,12 @@ let SharedTreeCore = (() => {
|
|
|
258
258
|
const { commit: { revision }, } = this.messageCodec.decode(this.serializer.decode(content), {
|
|
259
259
|
idCompressor: this.idCompressor,
|
|
260
260
|
});
|
|
261
|
-
const [commit] = this.editManager.findLocalCommit(revision);
|
|
262
261
|
// If a resubmit phase is not already in progress, then this must be the first commit of a new resubmit phase.
|
|
263
262
|
if (this.resubmitMachine.isInResubmitPhase === false) {
|
|
264
|
-
const
|
|
265
|
-
|
|
263
|
+
const localCommits = this.editManager.getLocalCommits();
|
|
264
|
+
const revisionIndex = localCommits.findIndex((c) => c.revision === revision);
|
|
265
|
+
(0, internal_1.assert)(revisionIndex >= 0, 0xbdb /* revision must exist in local commits */);
|
|
266
|
+
const toResubmit = localCommits.slice(revisionIndex);
|
|
266
267
|
this.resubmitMachine.prepareForResubmit(toResubmit);
|
|
267
268
|
}
|
|
268
269
|
(0, internal_1.assert)(isClonableSchemaPolicy(localOpMetadata), 0x95e /* Local metadata must contain schema and policy. */);
|
|
@@ -270,6 +271,18 @@ let SharedTreeCore = (() => {
|
|
|
270
271
|
const enrichedCommit = this.resubmitMachine.peekNextCommit();
|
|
271
272
|
this.submitCommit(enrichedCommit, localOpMetadata, true);
|
|
272
273
|
}
|
|
274
|
+
rollback(content, localOpMetadata) {
|
|
275
|
+
// Empty context object is passed in, as our decode function is schema-agnostic.
|
|
276
|
+
const { commit: { revision }, } = this.messageCodec.decode(this.serializer.decode(content), {
|
|
277
|
+
idCompressor: this.idCompressor,
|
|
278
|
+
});
|
|
279
|
+
const [commit] = this.editManager.findLocalCommit(revision);
|
|
280
|
+
const { parent } = commit;
|
|
281
|
+
(0, internal_1.assert)(parent !== undefined, 0xbdc /* must have parent */);
|
|
282
|
+
const [precedingCommit] = this.editManager.findLocalCommit(parent.revision);
|
|
283
|
+
this.editManager.localBranch.removeAfter(precedingCommit);
|
|
284
|
+
this.resubmitMachine.onCommitRollback(commit);
|
|
285
|
+
}
|
|
273
286
|
applyStashedOp(content) {
|
|
274
287
|
// Empty context object is passed in, as our decode function is schema-agnostic.
|
|
275
288
|
const { commit: { revision, change }, } = this.messageCodec.decode(content, { idCompressor: this.idCompressor });
|