@fluidframework/container-loader 2.0.0-internal.3.0.5 → 2.0.0-internal.3.1.1
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/.eslintrc.js +18 -21
- package/.mocharc.js +2 -2
- package/README.md +45 -43
- package/api-extractor.json +2 -2
- package/closeAndGetPendingLocalState.md +51 -0
- package/dist/audience.d.ts.map +1 -1
- package/dist/audience.js.map +1 -1
- package/dist/catchUpMonitor.d.ts.map +1 -1
- package/dist/catchUpMonitor.js.map +1 -1
- package/dist/collabWindowTracker.d.ts.map +1 -1
- package/dist/collabWindowTracker.js.map +1 -1
- package/dist/connectionManager.d.ts +2 -2
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +51 -24
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionState.d.ts.map +1 -1
- package/dist/connectionState.js.map +1 -1
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +35 -16
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +1 -10
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +89 -44
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +6 -2
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +2 -4
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/deltaManager.d.ts +3 -3
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +56 -27
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaManagerProxy.d.ts.map +1 -1
- package/dist/deltaManagerProxy.js.map +1 -1
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js +4 -2
- package/dist/deltaQueue.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +3 -3
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +18 -15
- package/dist/loader.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/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +2 -1
- package/dist/protocol.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/quorum.d.ts.map +1 -1
- package/dist/quorum.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +6 -2
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +6 -4
- package/dist/utils.js.map +1 -1
- package/lib/audience.d.ts.map +1 -1
- package/lib/audience.js.map +1 -1
- package/lib/catchUpMonitor.d.ts.map +1 -1
- package/lib/catchUpMonitor.js.map +1 -1
- package/lib/collabWindowTracker.d.ts.map +1 -1
- package/lib/collabWindowTracker.js.map +1 -1
- package/lib/connectionManager.d.ts +2 -2
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +53 -26
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionState.d.ts.map +1 -1
- package/lib/connectionState.js.map +1 -1
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +35 -16
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +1 -10
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +93 -48
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +6 -2
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +2 -4
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/deltaManager.d.ts +3 -3
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +58 -29
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaManagerProxy.d.ts.map +1 -1
- package/lib/deltaManagerProxy.js.map +1 -1
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js +4 -2
- package/lib/deltaQueue.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/loader.d.ts +3 -3
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +18 -15
- package/lib/loader.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/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +2 -1
- package/lib/protocol.js.map +1 -1
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/lib/protocolTreeDocumentStorageService.js.map +1 -1
- package/lib/quorum.d.ts.map +1 -1
- package/lib/quorum.js.map +1 -1
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js +6 -2
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +6 -4
- package/lib/utils.js.map +1 -1
- package/package.json +115 -114
- package/prettier.config.cjs +1 -1
- package/src/audience.ts +51 -46
- package/src/catchUpMonitor.ts +39 -37
- package/src/collabWindowTracker.ts +75 -70
- package/src/connectionManager.ts +1006 -944
- package/src/connectionState.ts +19 -19
- package/src/connectionStateHandler.ts +544 -465
- package/src/container.ts +2056 -1909
- package/src/containerContext.ts +350 -340
- package/src/containerStorageAdapter.ts +163 -153
- package/src/contracts.ts +155 -153
- package/src/deltaManager.ts +1069 -992
- package/src/deltaManagerProxy.ts +143 -137
- package/src/deltaQueue.ts +155 -151
- package/src/index.ts +14 -17
- package/src/loader.ts +428 -430
- package/src/packageVersion.ts +1 -1
- package/src/protocol.ts +93 -87
- package/src/protocolTreeDocumentStorageService.ts +30 -33
- package/src/quorum.ts +34 -34
- package/src/retriableDocumentStorageService.ts +118 -102
- package/src/utils.ts +89 -82
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +8 -12
package/src/utils.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
import { parse } from "url";
|
|
7
7
|
import { v4 as uuid } from "uuid";
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
assert,
|
|
10
|
+
stringToBuffer,
|
|
11
|
+
Uint8ArrayToArrayBuffer,
|
|
12
|
+
unreachableCase,
|
|
13
13
|
} from "@fluidframework/common-utils";
|
|
14
14
|
import { ISummaryTree, ISnapshotTree, SummaryType } from "@fluidframework/protocol-definitions";
|
|
15
15
|
import { LoggingError } from "@fluidframework/telemetry-utils";
|
|
@@ -17,33 +17,33 @@ import { LoggingError } from "@fluidframework/telemetry-utils";
|
|
|
17
17
|
// This is used when we rehydrate a container from the snapshot. Here we put the blob contents
|
|
18
18
|
// in separate property: blobContents.
|
|
19
19
|
export interface ISnapshotTreeWithBlobContents extends ISnapshotTree {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
blobsContents: { [path: string]: ArrayBufferLike };
|
|
21
|
+
trees: { [path: string]: ISnapshotTreeWithBlobContents };
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export interface IParsedUrl {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
id: string;
|
|
26
|
+
path: string;
|
|
27
|
+
query: string;
|
|
28
|
+
/**
|
|
29
|
+
* Null means do not use snapshots, undefined means load latest snapshot
|
|
30
|
+
* otherwise it's version ID passed to IDocumentStorageService.getVersions() to figure out what snapshot to use.
|
|
31
|
+
* If needed, can add undefined which is treated by Container.load() as load latest snapshot.
|
|
32
|
+
*/
|
|
33
|
+
version: string | null | undefined;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export function parseUrl(url: string): IParsedUrl | undefined {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
const parsed = parse(url, true);
|
|
38
|
+
if (typeof parsed.pathname !== "string") {
|
|
39
|
+
throw new LoggingError("Failed to parse pathname");
|
|
40
|
+
}
|
|
41
|
+
const query = parsed.search ?? "";
|
|
42
|
+
const regex = /^\/([^/]*\/[^/]*)(\/?.*)$/;
|
|
43
|
+
const match = regex.exec(parsed.pathname);
|
|
44
|
+
return match?.length === 3
|
|
45
|
+
? { id: match[1], path: match[2], query, version: parsed.query.version as string }
|
|
46
|
+
: undefined;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
@@ -57,44 +57,49 @@ export function parseUrl(url: string): IParsedUrl | undefined {
|
|
|
57
57
|
* @param summary - summary to convert
|
|
58
58
|
*/
|
|
59
59
|
function convertSummaryToSnapshotWithEmbeddedBlobContents(
|
|
60
|
-
|
|
60
|
+
summary: ISummaryTree,
|
|
61
61
|
): ISnapshotTreeWithBlobContents {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
const treeNode: ISnapshotTreeWithBlobContents = {
|
|
63
|
+
blobs: {},
|
|
64
|
+
blobsContents: {},
|
|
65
|
+
trees: {},
|
|
66
|
+
id: uuid(),
|
|
67
|
+
unreferenced: summary.unreferenced,
|
|
68
|
+
};
|
|
69
|
+
const keys = Object.keys(summary.tree);
|
|
70
|
+
for (const key of keys) {
|
|
71
|
+
const summaryObject = summary.tree[key];
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
73
|
+
switch (summaryObject.type) {
|
|
74
|
+
case SummaryType.Tree: {
|
|
75
|
+
treeNode.trees[key] =
|
|
76
|
+
convertSummaryToSnapshotWithEmbeddedBlobContents(summaryObject);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
case SummaryType.Attachment:
|
|
80
|
+
treeNode.blobs[key] = summaryObject.id;
|
|
81
|
+
break;
|
|
82
|
+
case SummaryType.Blob: {
|
|
83
|
+
const blobId = uuid();
|
|
84
|
+
treeNode.blobs[key] = blobId;
|
|
85
|
+
const contentBuffer =
|
|
86
|
+
typeof summaryObject.content === "string"
|
|
87
|
+
? stringToBuffer(summaryObject.content, "utf8")
|
|
88
|
+
: Uint8ArrayToArrayBuffer(summaryObject.content);
|
|
89
|
+
treeNode.blobsContents[blobId] = contentBuffer;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case SummaryType.Handle:
|
|
93
|
+
throw new LoggingError(
|
|
94
|
+
"No handles should be there in summary in detached container!!",
|
|
95
|
+
);
|
|
96
|
+
break;
|
|
97
|
+
default: {
|
|
98
|
+
unreachableCase(summaryObject, `Unknown tree type ${(summaryObject as any).type}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return treeNode;
|
|
98
103
|
}
|
|
99
104
|
|
|
100
105
|
/**
|
|
@@ -103,35 +108,37 @@ function convertSummaryToSnapshotWithEmbeddedBlobContents(
|
|
|
103
108
|
* @param appSummaryTree - App Summary Tree
|
|
104
109
|
*/
|
|
105
110
|
export function convertProtocolAndAppSummaryToSnapshotTree(
|
|
106
|
-
|
|
107
|
-
|
|
111
|
+
protocolSummaryTree: ISummaryTree,
|
|
112
|
+
appSummaryTree: ISummaryTree,
|
|
108
113
|
): ISnapshotTreeWithBlobContents {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
// Shallow copy is fine, since we are doing a deep clone below.
|
|
115
|
+
const combinedSummary: ISummaryTree = {
|
|
116
|
+
type: SummaryType.Tree,
|
|
117
|
+
tree: { ...appSummaryTree.tree },
|
|
118
|
+
};
|
|
114
119
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
120
|
+
combinedSummary.tree[".protocol"] = protocolSummaryTree;
|
|
121
|
+
const snapshotTreeWithBlobContents =
|
|
122
|
+
convertSummaryToSnapshotWithEmbeddedBlobContents(combinedSummary);
|
|
123
|
+
return snapshotTreeWithBlobContents;
|
|
119
124
|
}
|
|
120
125
|
|
|
121
126
|
// This function converts the snapshot taken in detached container(by serialize api) to snapshotTree with which
|
|
122
127
|
// a detached container can be rehydrated.
|
|
123
128
|
export const getSnapshotTreeFromSerializedContainer = (detachedContainerSnapshot: ISummaryTree) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
const protocolSummaryTree = detachedContainerSnapshot.tree[".protocol"] as ISummaryTree;
|
|
130
|
+
const appSummaryTree = detachedContainerSnapshot.tree[".app"] as ISummaryTree;
|
|
131
|
+
assert(
|
|
132
|
+
protocolSummaryTree !== undefined && appSummaryTree !== undefined,
|
|
133
|
+
0x1e0 /* "Protocol and App summary trees should be present" */,
|
|
134
|
+
);
|
|
135
|
+
const snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToSnapshotTree(
|
|
136
|
+
protocolSummaryTree,
|
|
137
|
+
appSummaryTree,
|
|
138
|
+
);
|
|
139
|
+
return snapshotTreeWithBlobContents;
|
|
133
140
|
};
|
|
134
141
|
|
|
135
142
|
export function getProtocolSnapshotTree(snapshot: ISnapshotTree): ISnapshotTree {
|
|
136
|
-
|
|
143
|
+
return ".protocol" in snapshot.trees ? snapshot.trees[".protocol"] : snapshot;
|
|
137
144
|
}
|
package/tsconfig.esnext.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./lib",
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
},
|
|
7
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
"include": [
|
|
12
|
-
"src/**/*"
|
|
13
|
-
]
|
|
2
|
+
"extends": "@fluidframework/build-common/ts-common-config.json",
|
|
3
|
+
"exclude": ["src/test/**/*"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"composite": true,
|
|
8
|
+
},
|
|
9
|
+
"include": ["src/**/*"],
|
|
14
10
|
}
|