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