@fluidframework/container-loader 2.0.0-internal.5.3.2 → 2.0.0-internal.6.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/CHANGELOG.md +85 -0
- package/README.md +6 -3
- package/dist/audience.d.ts +1 -0
- package/dist/audience.d.ts.map +1 -1
- package/dist/audience.js +3 -1
- package/dist/audience.js.map +1 -1
- package/dist/connectionManager.d.ts +1 -1
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +30 -36
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +2 -1
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +9 -16
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +12 -8
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +199 -156
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +2 -12
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +1 -20
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.js +3 -5
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +11 -2
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +3 -3
- package/dist/contracts.js.map +1 -1
- package/dist/debugLogger.d.ts +30 -0
- package/dist/debugLogger.d.ts.map +1 -0
- package/dist/debugLogger.js +95 -0
- package/dist/debugLogger.js.map +1 -0
- package/dist/deltaManager.d.ts +16 -4
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +79 -33
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.js +1 -2
- package/dist/deltaQueue.js.map +1 -1
- package/dist/loader.d.ts +12 -0
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +73 -47
- 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 -3
- package/dist/protocol.js.map +1 -1
- package/dist/quorum.d.ts +4 -1
- package/dist/quorum.d.ts.map +1 -1
- package/dist/quorum.js +1 -13
- package/dist/quorum.js.map +1 -1
- package/dist/utils.d.ts +8 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +24 -6
- package/dist/utils.js.map +1 -1
- package/lib/audience.d.ts +1 -0
- package/lib/audience.d.ts.map +1 -1
- package/lib/audience.js +3 -1
- package/lib/audience.js.map +1 -1
- package/lib/connectionManager.d.ts +1 -1
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +32 -35
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +2 -1
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +9 -16
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +12 -8
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +200 -157
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +2 -12
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +1 -20
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.js +3 -5
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts +11 -2
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js +3 -3
- package/lib/contracts.js.map +1 -1
- package/lib/debugLogger.d.ts +30 -0
- package/lib/debugLogger.d.ts.map +1 -0
- package/lib/debugLogger.js +91 -0
- package/lib/debugLogger.js.map +1 -0
- package/lib/deltaManager.d.ts +16 -4
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +77 -28
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.js +1 -2
- package/lib/deltaQueue.js.map +1 -1
- package/lib/loader.d.ts +12 -0
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +73 -47
- 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 -3
- package/lib/protocol.js.map +1 -1
- package/lib/quorum.d.ts +4 -1
- package/lib/quorum.d.ts.map +1 -1
- package/lib/quorum.js +0 -11
- package/lib/quorum.js.map +1 -1
- package/lib/utils.d.ts +8 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +22 -5
- package/lib/utils.js.map +1 -1
- package/package.json +14 -14
- package/src/audience.ts +6 -0
- package/src/connectionManager.ts +13 -14
- package/src/connectionStateHandler.ts +3 -2
- package/src/container.ts +178 -120
- package/src/containerContext.ts +0 -24
- package/src/contracts.ts +16 -5
- package/src/debugLogger.ts +113 -0
- package/src/deltaManager.ts +50 -9
- package/src/loader.ts +53 -30
- package/src/packageVersion.ts +1 -1
- package/src/protocol.ts +0 -1
- package/src/quorum.ts +0 -10
- package/src/utils.ts +29 -0
package/lib/deltaQueue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deltaQueue.js","sourceRoot":"","sources":["../src/deltaQueue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,KAAK,MAAM,oBAAoB,CAAC;AAOvC,MAAM,OAAO,UACZ,SAAQ,iBAAuC;IA2C/C;;OAEG;IACH,YAA6B,MAA0B;QACtD,KAAK,EAAE,CAAC;QADoB,WAAM,GAAN,MAAM,CAAoB;QA3C/C,eAAU,GAAY,KAAK,CAAC;QACnB,MAAC,GAAG,IAAI,KAAK,EAAK,CAAC;QAEpC;;;WAGG;QACK,eAAU,GAAG,CAAC,CAAC;IAsCvB,CAAC;IA5BD,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED;;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ACR,uBAAuB;YACvB,8EAA8E;YAC9E,oEAAoE;YACpE,IAAI,CAAC,MAAM,CAAC,IAAK,CAAC,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACtB;QAED,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QAC3C,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;YACxB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;SACnC;QACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC5B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDeltaQueue, IDeltaQueueEvents } from \"@fluidframework/container-definitions\";\nimport { assert, performance, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport Deque from \"double-ended-queue\";\n\nexport interface IDeltaQueueWriter<T> {\n\tpush(task: T): void;\n\tclear(): void;\n}\n\nexport class DeltaQueue<T>\n\textends TypedEventEmitter<IDeltaQueueEvents<T>>\n\timplements IDeltaQueue<T>, IDeltaQueueWriter<T>\n{\n\tprivate isDisposed: boolean = false;\n\tprivate readonly q = new Deque<T>();\n\n\t/**\n\t * Tracks the number of pause requests for the queue.\n\t * The DeltaQueue is created initially paused.\n\t */\n\tprivate pauseCount = 1;\n\n\tprivate error: any | undefined;\n\n\t/**\n\t * When processing is ongoing, holds a deferred that will resolve once processing stops.\n\t * Undefined when not processing.\n\t */\n\tprivate processingPromise: Promise<{ count: number; duration: number }> | undefined;\n\n\tpublic get disposed(): boolean {\n\t\treturn this.isDisposed;\n\t}\n\n\t/**\n\t * @returns True if the queue is paused, false if not.\n\t */\n\tpublic get paused(): boolean {\n\t\treturn this.pauseCount !== 0;\n\t}\n\n\tpublic get length(): number {\n\t\treturn this.q.length;\n\t}\n\n\tpublic get idle(): boolean {\n\t\treturn this.processingPromise === undefined && this.q.length === 0;\n\t}\n\n\tpublic async waitTillProcessingDone() {\n\t\treturn this.processingPromise ?? { count: 0, duration: 0 };\n\t}\n\n\t/**\n\t * @param worker - A callback to process a delta.\n\t */\n\tconstructor(private readonly worker: (delta: T) => void) {\n\t\tsuper();\n\t}\n\n\tpublic dispose() {\n\t\tthrow new Error(\"Not implemented.\");\n\t\tthis.isDisposed = true;\n\t}\n\n\tpublic clear(): void {\n\t\tthis.q.clear();\n\t}\n\n\tpublic peek(): T | undefined {\n\t\treturn this.q.peekFront();\n\t}\n\n\tpublic toArray(): T[] {\n\t\treturn this.q.toArray();\n\t}\n\n\tpublic push(task: T) {\n\t\ttry {\n\t\t\tthis.q.push(task);\n\t\t\tthis.emit(\"push\", task);\n\t\t\tthis.ensureProcessing();\n\t\t} catch (error) {\n\t\t\tthis.emit(\"error\", error);\n\t\t}\n\t}\n\n\tpublic async pause(): Promise<void> {\n\t\tthis.pauseCount++;\n\t\t// If called from within the processing loop, we are in the middle of processing an op. Return a promise\n\t\t// that will resolve when processing has actually stopped.\n\t\tawait this.waitTillProcessingDone();\n\t}\n\n\tpublic resume(): void {\n\t\tassert(this.pauseCount > 0, 0x0f4 /* \"Nonzero pause-count on resume()\" */);\n\t\tthis.pauseCount--;\n\t\tthis.ensureProcessing();\n\t}\n\n\t/**\n\t * There are several actions that may need to kick off delta processing, so we want to guard against\n\t * accidental reentrancy. ensureProcessing can be called safely to start the processing loop if it is\n\t * not already started.\n\t */\n\tprivate ensureProcessing() {\n\t\tif (this.anythingToProcess() && this.processingPromise === undefined) {\n\t\t\t// Use a resolved promise to start the processing on a separate stack.\n\t\t\tthis.processingPromise = Promise.resolve()\n\t\t\t\t.then(() => {\n\t\t\t\t\tassert(this.processingPromise !== undefined, 0x37f /* reentrancy? */);\n\t\t\t\t\tconst result = this.processDeltas();\n\t\t\t\t\tassert(this.processingPromise !== undefined, 0x380 /* reentrancy? */);\n\t\t\t\t\t// WARNING: Do not move next line to .finally() clause!\n\t\t\t\t\t// It runs async and creates a race condition where incoming ensureProcessing() call observes\n\t\t\t\t\t// from previous run while previous run is over (but finally clause was not scheduled yet)\n\t\t\t\t\tthis.processingPromise = undefined;\n\t\t\t\t\treturn result;\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tthis.error = error;\n\t\t\t\t\tthis.processingPromise = undefined;\n\t\t\t\t\tthis.emit(\"error\", error);\n\t\t\t\t\treturn { count: 0, duration: 0 };\n\t\t\t\t});\n\t\t\tassert(\n\t\t\t\tthis.processingPromise !== undefined,\n\t\t\t\t0x381 /* processDeltas() should run async */,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate anythingToProcess() {\n\t\treturn this.q.length !== 0 && !this.paused && this.error === undefined;\n\t}\n\n\t/**\n\t * Executes the delta processing loop until a stop condition is reached.\n\t */\n\tprivate processDeltas() {\n\t\tconst start = performance.now();\n\t\tlet count = 0;\n\n\t\t// For grouping to work we must process all local messages immediately and in the single turn.\n\t\t// So loop over them until no messages to process, we have become paused, or hit an error.\n\t\twhile (this.anythingToProcess()) {\n\t\t\t// Get the next message in the queue\n\t\t\tconst next = this.q.shift();\n\t\t\tcount++;\n\t\t\t// Process the message.\n\t\t\t// We know next is defined since we did a length check just prior to shifting.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.worker(next!);\n\t\t\tthis.emit(\"op\", next);\n\t\t}\n\n\t\tconst duration = performance.now() - start;\n\t\tif (this.q.length === 0) {\n\t\t\tthis.emit(\"idle\", count, duration);\n\t\t}\n\t\treturn { count, duration };\n\t}\n}\n"]}
|
package/lib/loader.d.ts
CHANGED
|
@@ -15,8 +15,14 @@ export declare class RelativeLoader implements ILoader {
|
|
|
15
15
|
private readonly container;
|
|
16
16
|
private readonly loader;
|
|
17
17
|
constructor(container: Container, loader: ILoader | undefined);
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.
|
|
20
|
+
*/
|
|
18
21
|
get IFluidRouter(): IFluidRouter;
|
|
19
22
|
resolve(request: IRequest): Promise<IContainer>;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.
|
|
25
|
+
*/
|
|
20
26
|
request(request: IRequest): Promise<IResponse>;
|
|
21
27
|
}
|
|
22
28
|
export interface ILoaderOptions extends ILoaderOptions1 {
|
|
@@ -172,10 +178,16 @@ export declare class Loader implements IHostLoader {
|
|
|
172
178
|
readonly services: ILoaderServices;
|
|
173
179
|
private readonly mc;
|
|
174
180
|
constructor(loaderProps: ILoaderProps);
|
|
181
|
+
/**
|
|
182
|
+
* @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.
|
|
183
|
+
*/
|
|
175
184
|
get IFluidRouter(): IFluidRouter;
|
|
176
185
|
createDetachedContainer(codeDetails: IFluidCodeDetails): Promise<IContainer>;
|
|
177
186
|
rehydrateDetachedContainerFromSnapshot(snapshot: string): Promise<IContainer>;
|
|
178
187
|
resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer>;
|
|
188
|
+
/**
|
|
189
|
+
* @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.
|
|
190
|
+
*/
|
|
179
191
|
request(request: IRequest): Promise<IResponse>;
|
|
180
192
|
private getKeyForContainerCache;
|
|
181
193
|
private addToContainerCache;
|
package/lib/loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,mBAAmB,
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EAMnB,M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G;IAC7F,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,UAAU,IAAI,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,kCAAkC,CACvD,SAAS,EAAE,UAAU,EACrB,OAAO,CAAC,EAAE,cAAc,GACtB,OAAO,CAAC,SAAS,CAAC,CAepB;AAED;;GAEG;AACH,qBAAa,MAAO,YAAW,WAAW;IACzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyC;IACpE,SAAgB,QAAQ,EAAE,eAAe,CAAC;IAC1C,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAoB;gBAE3B,WAAW,EAAE,YAAY;IA2CrC;;OAEG;IACH,IAAW,YAAY,IAAI,YAAY,CAEtC;IAEY,uBAAuB,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;IAgB5E,sCAAsC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAI7E,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAWxF;;OAEG;IACU,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAc3D,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,mBAAmB;YAuBb,WAAW;IAsEzB,OAAO,KAAK,cAAc,GAEzB;YAEa,aAAa;CAoB3B"}
|
package/lib/loader.js
CHANGED
|
@@ -3,16 +3,15 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { v4 as uuid } from "uuid";
|
|
6
|
-
import {
|
|
6
|
+
import { mixinMonitoringContext, PerformanceEvent, sessionStorageConfigProvider, createChildMonitoringContext, } from "@fluidframework/telemetry-utils";
|
|
7
7
|
import { LoaderHeader, } from "@fluidframework/container-definitions";
|
|
8
|
+
import { UsageError } from "@fluidframework/container-utils";
|
|
8
9
|
import { Container } from "./container";
|
|
9
10
|
import { parseUrl } from "./utils";
|
|
10
11
|
import { pkgVersion } from "./packageVersion";
|
|
12
|
+
import { DebugLogger } from "./debugLogger";
|
|
11
13
|
function canUseCache(request) {
|
|
12
|
-
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
return request.headers[LoaderHeader.cache] !== false;
|
|
14
|
+
return request.headers?.[LoaderHeader.cache] === true;
|
|
16
15
|
}
|
|
17
16
|
function ensureResolvedUrlDefined(resolved) {
|
|
18
17
|
if (resolved === undefined) {
|
|
@@ -27,11 +26,13 @@ export class RelativeLoader {
|
|
|
27
26
|
this.container = container;
|
|
28
27
|
this.loader = loader;
|
|
29
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.
|
|
31
|
+
*/
|
|
30
32
|
get IFluidRouter() {
|
|
31
33
|
return this;
|
|
32
34
|
}
|
|
33
35
|
async resolve(request) {
|
|
34
|
-
var _a, _b, _c, _d, _e;
|
|
35
36
|
if (request.url.startsWith("/")) {
|
|
36
37
|
if (canUseCache(request)) {
|
|
37
38
|
return this.container;
|
|
@@ -39,12 +40,12 @@ export class RelativeLoader {
|
|
|
39
40
|
else {
|
|
40
41
|
ensureResolvedUrlDefined(this.container.resolvedUrl);
|
|
41
42
|
const container = await this.container.clone({
|
|
42
|
-
resolvedUrl:
|
|
43
|
-
version:
|
|
44
|
-
loadMode:
|
|
43
|
+
resolvedUrl: { ...this.container.resolvedUrl },
|
|
44
|
+
version: request.headers?.[LoaderHeader.version] ?? undefined,
|
|
45
|
+
loadMode: request.headers?.[LoaderHeader.loadMode],
|
|
45
46
|
}, {
|
|
46
|
-
canReconnect:
|
|
47
|
-
clientDetailsOverride:
|
|
47
|
+
canReconnect: request.headers?.[LoaderHeader.reconnect],
|
|
48
|
+
clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],
|
|
48
49
|
});
|
|
49
50
|
return container;
|
|
50
51
|
}
|
|
@@ -54,6 +55,9 @@ export class RelativeLoader {
|
|
|
54
55
|
}
|
|
55
56
|
return this.loader.resolve(request);
|
|
56
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.
|
|
60
|
+
*/
|
|
57
61
|
async request(request) {
|
|
58
62
|
if (request.url.startsWith("/")) {
|
|
59
63
|
const container = await this.resolve(request);
|
|
@@ -75,14 +79,13 @@ export class RelativeLoader {
|
|
|
75
79
|
* @returns component on the container
|
|
76
80
|
*/
|
|
77
81
|
export async function requestResolvedObjectFromContainer(container, headers) {
|
|
78
|
-
var _a, _b;
|
|
79
82
|
ensureResolvedUrlDefined(container.resolvedUrl);
|
|
80
83
|
const parsedUrl = parseUrl(container.resolvedUrl.url);
|
|
81
84
|
if (parsedUrl === undefined) {
|
|
82
85
|
throw new Error(`Invalid URL ${container.resolvedUrl.url}`);
|
|
83
86
|
}
|
|
84
|
-
const entryPoint = await
|
|
85
|
-
const router =
|
|
87
|
+
const entryPoint = await container.getEntryPoint?.();
|
|
88
|
+
const router = entryPoint?.IFluidRouter ?? container.IFluidRouter;
|
|
86
89
|
return router.request({
|
|
87
90
|
url: `${parsedUrl.path}${parsedUrl.query}`,
|
|
88
91
|
headers,
|
|
@@ -106,14 +109,20 @@ export class Loader {
|
|
|
106
109
|
urlResolver,
|
|
107
110
|
documentServiceFactory,
|
|
108
111
|
codeLoader,
|
|
109
|
-
options: options
|
|
110
|
-
scope:
|
|
112
|
+
options: options ?? {},
|
|
113
|
+
scope: options?.provideScopeLoader !== false ? { ...scope, ILoader: this } : { ...scope },
|
|
111
114
|
detachedBlobStorage,
|
|
112
115
|
protocolHandlerBuilder,
|
|
113
116
|
subLogger: subMc.logger,
|
|
114
117
|
};
|
|
115
|
-
this.mc =
|
|
118
|
+
this.mc = createChildMonitoringContext({
|
|
119
|
+
logger: this.services.subLogger,
|
|
120
|
+
namespace: "Loader",
|
|
121
|
+
});
|
|
116
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.
|
|
125
|
+
*/
|
|
117
126
|
get IFluidRouter() {
|
|
118
127
|
return this;
|
|
119
128
|
}
|
|
@@ -140,15 +149,20 @@ export class Loader {
|
|
|
140
149
|
return resolved.container;
|
|
141
150
|
});
|
|
142
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.
|
|
154
|
+
*/
|
|
143
155
|
async request(request) {
|
|
144
156
|
return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: "Request" }, async () => {
|
|
145
157
|
const resolved = await this.resolveCore(request);
|
|
146
|
-
return resolved.container.request(
|
|
158
|
+
return resolved.container.request({
|
|
159
|
+
...request,
|
|
160
|
+
url: `${resolved.parsed.path}${resolved.parsed.query}`,
|
|
161
|
+
});
|
|
147
162
|
});
|
|
148
163
|
}
|
|
149
164
|
getKeyForContainerCache(request, parsedUrl) {
|
|
150
|
-
|
|
151
|
-
const key = ((_a = request.headers) === null || _a === void 0 ? void 0 : _a[LoaderHeader.version]) !== undefined
|
|
165
|
+
const key = request.headers?.[LoaderHeader.version] !== undefined
|
|
152
166
|
? `${parsedUrl.id}@${request.headers[LoaderHeader.version]}`
|
|
153
167
|
: parsedUrl.id;
|
|
154
168
|
return key;
|
|
@@ -157,20 +171,26 @@ export class Loader {
|
|
|
157
171
|
this.containers.set(key, containerP);
|
|
158
172
|
containerP
|
|
159
173
|
.then((container) => {
|
|
160
|
-
// If the container is closed or becomes closed after we resolve it,
|
|
161
|
-
|
|
174
|
+
// If the container is closed/disposed or becomes closed/disposed after we resolve it,
|
|
175
|
+
// remove it from the cache.
|
|
176
|
+
if (container.closed || container.disposed) {
|
|
162
177
|
this.containers.delete(key);
|
|
163
178
|
}
|
|
164
179
|
else {
|
|
165
180
|
container.once("closed", () => {
|
|
166
181
|
this.containers.delete(key);
|
|
167
182
|
});
|
|
183
|
+
container.once("disposed", () => {
|
|
184
|
+
this.containers.delete(key);
|
|
185
|
+
});
|
|
168
186
|
}
|
|
169
187
|
})
|
|
170
|
-
.catch((error) => {
|
|
188
|
+
.catch((error) => {
|
|
189
|
+
// If an error occured while resolving the container request, then remove it from the cache.
|
|
190
|
+
this.containers.delete(key);
|
|
191
|
+
});
|
|
171
192
|
}
|
|
172
193
|
async resolveCore(request, pendingLocalState) {
|
|
173
|
-
var _a, _b, _c;
|
|
174
194
|
const resolvedAsFluid = await this.services.urlResolver.resolve(request);
|
|
175
195
|
ensureResolvedUrlDefined(resolvedAsFluid);
|
|
176
196
|
// Parse URL into data stores
|
|
@@ -180,20 +200,33 @@ export class Loader {
|
|
|
180
200
|
}
|
|
181
201
|
if (pendingLocalState !== undefined) {
|
|
182
202
|
const parsedPendingUrl = parseUrl(pendingLocalState.url);
|
|
183
|
-
if (
|
|
184
|
-
|
|
203
|
+
if (parsedPendingUrl?.id !== parsed.id ||
|
|
204
|
+
parsedPendingUrl?.path.replace(/\/$/, "") !== parsed.path.replace(/\/$/, "")) {
|
|
185
205
|
const message = `URL ${resolvedAsFluid.url} does not match pending state URL ${pendingLocalState.url}`;
|
|
186
206
|
throw new Error(message);
|
|
187
207
|
}
|
|
188
208
|
}
|
|
189
|
-
|
|
209
|
+
request.headers ?? (request.headers = {});
|
|
190
210
|
// If set in both query string and headers, use query string. Also write the value from the query string into the header either way.
|
|
191
211
|
request.headers[LoaderHeader.version] =
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
|
|
212
|
+
parsed.version ?? request.headers[LoaderHeader.version];
|
|
213
|
+
const cacheHeader = request.headers[LoaderHeader.cache];
|
|
214
|
+
const canCache =
|
|
215
|
+
// Take header value if present, else use ILoaderOptions.cache value
|
|
216
|
+
(cacheHeader !== undefined ? cacheHeader === true : this.cachingEnabled) &&
|
|
195
217
|
pendingLocalState === undefined;
|
|
196
|
-
const fromSequenceNumber =
|
|
218
|
+
const fromSequenceNumber = request.headers[LoaderHeader.sequenceNumber];
|
|
219
|
+
const opsBeforeReturn = request.headers[LoaderHeader.loadMode]?.opsBeforeReturn;
|
|
220
|
+
if (opsBeforeReturn === "sequenceNumber" &&
|
|
221
|
+
(fromSequenceNumber === undefined || fromSequenceNumber < 0)) {
|
|
222
|
+
// If opsBeforeReturn is set to "sequenceNumber", then fromSequenceNumber should be set to a non-negative integer.
|
|
223
|
+
throw new UsageError("sequenceNumber must be set to a non-negative integer");
|
|
224
|
+
}
|
|
225
|
+
else if (opsBeforeReturn !== "sequenceNumber" && fromSequenceNumber !== undefined) {
|
|
226
|
+
// If opsBeforeReturn is not set to "sequenceNumber", then fromSequenceNumber should be undefined (default value).
|
|
227
|
+
// In this case, we should throw an error since opsBeforeReturn is not explicitly set to "sequenceNumber".
|
|
228
|
+
throw new UsageError('opsBeforeReturn must be set to "sequenceNumber"');
|
|
229
|
+
}
|
|
197
230
|
let container;
|
|
198
231
|
if (canCache) {
|
|
199
232
|
const key = this.getKeyForContainerCache(request, parsed);
|
|
@@ -210,30 +243,23 @@ export class Loader {
|
|
|
210
243
|
else {
|
|
211
244
|
container = await this.loadContainer(request, resolvedAsFluid, pendingLocalState);
|
|
212
245
|
}
|
|
213
|
-
if (container.deltaManager.lastSequenceNumber <= fromSequenceNumber) {
|
|
214
|
-
await new Promise((resolve, reject) => {
|
|
215
|
-
function opHandler(message) {
|
|
216
|
-
if (message.sequenceNumber > fromSequenceNumber) {
|
|
217
|
-
resolve();
|
|
218
|
-
container.removeListener("op", opHandler);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
container.on("op", opHandler);
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
246
|
return { container, parsed };
|
|
225
247
|
}
|
|
226
248
|
get cachingEnabled() {
|
|
227
|
-
return this.services.options.cache
|
|
249
|
+
return this.services.options.cache === true;
|
|
228
250
|
}
|
|
229
251
|
async loadContainer(request, resolvedUrl, pendingLocalState) {
|
|
230
|
-
var _a, _b, _c, _d, _e;
|
|
231
252
|
return Container.load({
|
|
232
253
|
resolvedUrl,
|
|
233
|
-
version:
|
|
234
|
-
loadMode:
|
|
254
|
+
version: request.headers?.[LoaderHeader.version] ?? undefined,
|
|
255
|
+
loadMode: request.headers?.[LoaderHeader.loadMode],
|
|
235
256
|
pendingLocalState,
|
|
236
|
-
|
|
257
|
+
loadToSequenceNumber: request.headers?.[LoaderHeader.sequenceNumber],
|
|
258
|
+
}, {
|
|
259
|
+
canReconnect: request.headers?.[LoaderHeader.reconnect],
|
|
260
|
+
clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],
|
|
261
|
+
...this.services,
|
|
262
|
+
});
|
|
237
263
|
}
|
|
238
264
|
}
|
|
239
265
|
//# sourceMappingURL=loader.js.map
|
package/lib/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAEN,WAAW,EACX,WAAW,EAEX,yBAAyB,EACzB,sBAAsB,EAEtB,gBAAgB,EAChB,4BAA4B,GAC5B,MAAM,iCAAiC,CAAC;AASzC,OAAO,EAMN,YAAY,GAGZ,MAAM,uCAAuC,CAAC;AAQ/C,OAAO,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAC;AAChE,OAAO,EAAc,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,SAAS,WAAW,CAAC,OAAiB;IACrC,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE;QAClC,OAAO,IAAI,CAAC;KACZ;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC;AACtD,CAAC;A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,CAAC;IAEO,KAAK,CAAC,aAAa,CAC1B,OAAiB,EACjB,WAAyB,EACzB,iBAA0C;;QAE1C,OAAO,SAAS,CAAC,IAAI,CACpB;YACC,WAAW;YACX,OAAO,EAAE,MAAA,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,OAAO,CAAC,mCAAI,SAAS;YAC7D,QAAQ,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,QAAQ,CAAC;YAClD,iBAAiB;SACjB,kBAEA,YAAY,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,SAAS,CAAC,EACvD,qBAAqB,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,aAAa,CAAC,IACjE,IAAI,CAAC,QAAQ,EAEjB,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport {\n\tITelemetryLoggerExt,\n\tChildLogger,\n\tDebugLogger,\n\tIConfigProviderBase,\n\tloggerToMonitoringContext,\n\tmixinMonitoringContext,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tsessionStorageConfigProvider,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n\tITelemetryBaseLogger,\n\tFluidObject,\n\tIFluidRouter,\n\tIRequest,\n\tIRequestHeader,\n\tIResponse,\n} from \"@fluidframework/core-interfaces\";\nimport {\n\tIContainer,\n\tIFluidModule,\n\tIHostLoader,\n\tILoader,\n\tILoaderOptions as ILoaderOptions1,\n\tLoaderHeader,\n\tIProvideFluidCodeDetailsComparer,\n\tIFluidCodeDetails,\n} from \"@fluidframework/container-definitions\";\nimport {\n\tIDocumentServiceFactory,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { Container, IPendingContainerState } from \"./container\";\nimport { IParsedUrl, parseUrl } from \"./utils\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { ProtocolHandlerBuilder } from \"./protocol\";\n\nfunction canUseCache(request: IRequest): boolean {\n\tif (request.headers === undefined) {\n\t\treturn true;\n\t}\n\n\treturn request.headers[LoaderHeader.cache] !== false;\n}\n\nfunction ensureResolvedUrlDefined(\n\tresolved: IResolvedUrl | undefined,\n): asserts resolved is IResolvedUrl {\n\tif (resolved === undefined) {\n\t\tthrow new Error(`Object is not a IResolveUrl.`);\n\t}\n}\n/**\n * @internal\n */\nexport class RelativeLoader implements ILoader {\n\tconstructor(\n\t\tprivate readonly container: Container,\n\t\tprivate readonly loader: ILoader | undefined,\n\t) {}\n\n\tpublic get IFluidRouter(): IFluidRouter {\n\t\treturn this;\n\t}\n\n\tpublic async resolve(request: IRequest): Promise<IContainer> {\n\t\tif (request.url.startsWith(\"/\")) {\n\t\t\tif (canUseCache(request)) {\n\t\t\t\treturn this.container;\n\t\t\t} else {\n\t\t\t\tensureResolvedUrlDefined(this.container.resolvedUrl);\n\t\t\t\tconst container = await this.container.clone(\n\t\t\t\t\t{\n\t\t\t\t\t\tresolvedUrl: { ...this.container.resolvedUrl },\n\t\t\t\t\t\tversion: request.headers?.[LoaderHeader.version] ?? undefined,\n\t\t\t\t\t\tloadMode: request.headers?.[LoaderHeader.loadMode],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tcanReconnect: request.headers?.[LoaderHeader.reconnect],\n\t\t\t\t\t\tclientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn container;\n\t\t\t}\n\t\t}\n\n\t\tif (this.loader === undefined) {\n\t\t\tthrow new Error(\"Cannot resolve external containers\");\n\t\t}\n\t\treturn this.loader.resolve(request);\n\t}\n\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\tif (request.url.startsWith(\"/\")) {\n\t\t\tconst container = await this.resolve(request);\n\t\t\treturn container.request(request);\n\t\t}\n\n\t\tif (this.loader === undefined) {\n\t\t\treturn {\n\t\t\t\tstatus: 404,\n\t\t\t\tvalue: \"Cannot request external containers\",\n\t\t\t\tmimeType: \"plain/text\",\n\t\t\t};\n\t\t}\n\t\treturn this.loader.request(request);\n\t}\n}\n\nexport interface ILoaderOptions extends ILoaderOptions1 {\n\tsummarizeProtocolTree?: boolean;\n}\n\n/**\n * @deprecated IFluidModuleWithDetails interface is moved to\n * {@link @fluidframework/container-definitions#IFluidModuleWithDetails}\n * to have all the code loading modules in one package. #8193\n * Encapsulates a module entry point with corresponding code details.\n */\nexport interface IFluidModuleWithDetails {\n\t/** Fluid code module that implements the runtime factory needed to instantiate the container runtime. */\n\tmodule: IFluidModule;\n\t/**\n\t * Code details associated with the module. Represents a document schema this module supports.\n\t * If the code loader implements the {@link @fluidframework/core-interfaces#IFluidCodeDetailsComparer} interface,\n\t * it'll be called to determine whether the module code details satisfy the new code proposal in the quorum.\n\t */\n\tdetails: IFluidCodeDetails;\n}\n\n/**\n * @deprecated ICodeDetailsLoader interface is moved to {@link @fluidframework/container-definition#ICodeDetailsLoader}\n * to have code loading modules in one package. #8193\n * Fluid code loader resolves a code module matching the document schema, i.e. code details, such as\n * a package name and package version range.\n */\nexport interface ICodeDetailsLoader extends Partial<IProvideFluidCodeDetailsComparer> {\n\t/**\n\t * Load the code module (package) that is capable to interact with the document.\n\t *\n\t * @param source - Code proposal that articulates the current schema the document is written in.\n\t * @returns - Code module entry point along with the code details associated with it.\n\t */\n\tload(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;\n}\n\n/**\n * Services and properties necessary for creating a loader\n */\nexport interface ILoaderProps {\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options used by various layers\n\t * to control features\n\t */\n\treadonly options?: ILoaderOptions;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope?: FluidObject;\n\n\t/**\n\t * The logger that all telemetry should be pushed to.\n\t */\n\treadonly logger?: ITelemetryBaseLogger;\n\n\t/**\n\t * Blobs storage for detached containers.\n\t */\n\treadonly detachedBlobStorage?: IDetachedBlobStorage;\n\n\t/**\n\t * The configuration provider which may be used to control features.\n\t */\n\treadonly configProvider?: IConfigProviderBase;\n\n\t/**\n\t * Optional property for allowing the container to use a custom\n\t * protocol implementation for handling the quorum and/or the audience.\n\t */\n\treadonly protocolHandlerBuilder?: ProtocolHandlerBuilder;\n}\n\n/**\n * Services and properties used by and exposed by the loader\n */\nexport interface ILoaderServices {\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options used by various layers\n\t * to control features\n\t */\n\treadonly options: ILoaderOptions;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope: FluidObject;\n\n\t/**\n\t * The logger downstream consumers should construct their loggers from\n\t */\n\treadonly subLogger: ITelemetryLoggerExt;\n\n\t/**\n\t * Blobs storage for detached containers.\n\t */\n\treadonly detachedBlobStorage?: IDetachedBlobStorage;\n\n\t/**\n\t * Optional property for allowing the container to use a custom\n\t * protocol implementation for handling the quorum and/or the audience.\n\t */\n\treadonly protocolHandlerBuilder?: ProtocolHandlerBuilder;\n}\n\n/**\n * Subset of IDocumentStorageService which only supports createBlob() and readBlob(). This is used to support\n * blobs in detached containers.\n */\nexport type IDetachedBlobStorage = Pick<IDocumentStorageService, \"createBlob\" | \"readBlob\"> & {\n\tsize: number;\n\t/**\n\t * Return an array of all blob IDs present in storage\n\t */\n\tgetBlobIds(): string[];\n};\n\n/**\n * With an already-resolved container, we can request a component directly, without loading the container again\n * @param container - a resolved container\n * @returns component on the container\n */\nexport async function requestResolvedObjectFromContainer(\n\tcontainer: IContainer,\n\theaders?: IRequestHeader,\n): Promise<IResponse> {\n\tensureResolvedUrlDefined(container.resolvedUrl);\n\tconst parsedUrl = parseUrl(container.resolvedUrl.url);\n\n\tif (parsedUrl === undefined) {\n\t\tthrow new Error(`Invalid URL ${container.resolvedUrl.url}`);\n\t}\n\n\tconst entryPoint: FluidObject<IFluidRouter> | undefined = await container.getEntryPoint?.();\n\tconst router = entryPoint?.IFluidRouter ?? container.IFluidRouter;\n\n\treturn router.request({\n\t\turl: `${parsedUrl.path}${parsedUrl.query}`,\n\t\theaders,\n\t});\n}\n\n/**\n * Manages Fluid resource loading\n */\nexport class Loader implements IHostLoader {\n\tprivate readonly containers = new Map<string, Promise<Container>>();\n\tpublic readonly services: ILoaderServices;\n\tprivate readonly mc: MonitoringContext;\n\n\tconstructor(loaderProps: ILoaderProps) {\n\t\tconst {\n\t\t\turlResolver,\n\t\t\tdocumentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\toptions,\n\t\t\tscope,\n\t\t\tlogger,\n\t\t\tdetachedBlobStorage,\n\t\t\tconfigProvider,\n\t\t\tprotocolHandlerBuilder,\n\t\t} = loaderProps;\n\n\t\tconst telemetryProps = {\n\t\t\tloaderId: uuid(),\n\t\t\tloaderVersion: pkgVersion,\n\t\t};\n\n\t\tconst subMc = mixinMonitoringContext(\n\t\t\tDebugLogger.mixinDebugLogger(\"fluid:telemetry\", logger, {\n\t\t\t\tall: telemetryProps,\n\t\t\t}),\n\t\t\tsessionStorageConfigProvider.value,\n\t\t\tconfigProvider,\n\t\t);\n\n\t\tthis.services = {\n\t\t\turlResolver,\n\t\t\tdocumentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\toptions: options ?? {},\n\t\t\tscope:\n\t\t\t\toptions?.provideScopeLoader !== false ? { ...scope, ILoader: this } : { ...scope },\n\t\t\tdetachedBlobStorage,\n\t\t\tprotocolHandlerBuilder,\n\t\t\tsubLogger: subMc.logger,\n\t\t};\n\t\tthis.mc = loggerToMonitoringContext(ChildLogger.create(this.services.subLogger, \"Loader\"));\n\t}\n\n\tpublic get IFluidRouter(): IFluidRouter {\n\t\treturn this;\n\t}\n\n\tpublic async createDetachedContainer(codeDetails: IFluidCodeDetails): Promise<IContainer> {\n\t\tconst container = await Container.createDetached(this.services, codeDetails);\n\n\t\tif (this.cachingEnabled) {\n\t\t\tcontainer.once(\"attached\", () => {\n\t\t\t\tensureResolvedUrlDefined(container.resolvedUrl);\n\t\t\t\tconst parsedUrl = parseUrl(container.resolvedUrl.url);\n\t\t\t\tif (parsedUrl !== undefined) {\n\t\t\t\t\tthis.addToContainerCache(parsedUrl.id, Promise.resolve(container));\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn container;\n\t}\n\n\tpublic async rehydrateDetachedContainerFromSnapshot(snapshot: string): Promise<IContainer> {\n\t\treturn Container.rehydrateDetachedFromSnapshot(this.services, snapshot);\n\t}\n\n\tpublic async resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer> {\n\t\tconst eventName = pendingLocalState === undefined ? \"Resolve\" : \"ResolveWithPendingState\";\n\t\treturn PerformanceEvent.timedExecAsync(this.mc.logger, { eventName }, async () => {\n\t\t\tconst resolved = await this.resolveCore(\n\t\t\t\trequest,\n\t\t\t\tpendingLocalState !== undefined ? JSON.parse(pendingLocalState) : undefined,\n\t\t\t);\n\t\t\treturn resolved.container;\n\t\t});\n\t}\n\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{ eventName: \"Request\" },\n\t\t\tasync () => {\n\t\t\t\tconst resolved = await this.resolveCore(request);\n\t\t\t\treturn resolved.container.request({\n\t\t\t\t\t...request,\n\t\t\t\t\turl: `${resolved.parsed.path}${resolved.parsed.query}`,\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate getKeyForContainerCache(request: IRequest, parsedUrl: IParsedUrl): string {\n\t\tconst key =\n\t\t\trequest.headers?.[LoaderHeader.version] !== undefined\n\t\t\t\t? `${parsedUrl.id}@${request.headers[LoaderHeader.version]}`\n\t\t\t\t: parsedUrl.id;\n\t\treturn key;\n\t}\n\n\tprivate addToContainerCache(key: string, containerP: Promise<Container>) {\n\t\tthis.containers.set(key, containerP);\n\t\tcontainerP\n\t\t\t.then((container) => {\n\t\t\t\t// If the container is closed or becomes closed after we resolve it, remove it from the cache.\n\t\t\t\tif (container.closed) {\n\t\t\t\t\tthis.containers.delete(key);\n\t\t\t\t} else {\n\t\t\t\t\tcontainer.once(\"closed\", () => {\n\t\t\t\t\t\tthis.containers.delete(key);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch((error) => {});\n\t}\n\n\tprivate async resolveCore(\n\t\trequest: IRequest,\n\t\tpendingLocalState?: IPendingContainerState,\n\t): Promise<{ container: Container; parsed: IParsedUrl }> {\n\t\tconst resolvedAsFluid = await this.services.urlResolver.resolve(request);\n\t\tensureResolvedUrlDefined(resolvedAsFluid);\n\n\t\t// Parse URL into data stores\n\t\tconst parsed = parseUrl(resolvedAsFluid.url);\n\t\tif (parsed === undefined) {\n\t\t\tthrow new Error(`Invalid URL ${resolvedAsFluid.url}`);\n\t\t}\n\n\t\tif (pendingLocalState !== undefined) {\n\t\t\tconst parsedPendingUrl = parseUrl(pendingLocalState.url);\n\t\t\tif (\n\t\t\t\tparsedPendingUrl?.id !== parsed.id ||\n\t\t\t\tparsedPendingUrl?.path.replace(/\\/$/, \"\") !== parsed.path.replace(/\\/$/, \"\")\n\t\t\t) {\n\t\t\t\tconst message = `URL ${resolvedAsFluid.url} does not match pending state URL ${pendingLocalState.url}`;\n\t\t\t\tthrow new Error(message);\n\t\t\t}\n\t\t}\n\n\t\trequest.headers ??= {};\n\t\t// If set in both query string and headers, use query string. Also write the value from the query string into the header either way.\n\t\trequest.headers[LoaderHeader.version] =\n\t\t\tparsed.version ?? request.headers[LoaderHeader.version];\n\t\tconst canCache =\n\t\t\tthis.cachingEnabled &&\n\t\t\trequest.headers[LoaderHeader.cache] !== false &&\n\t\t\tpendingLocalState === undefined;\n\t\tconst fromSequenceNumber = request.headers[LoaderHeader.sequenceNumber] ?? -1;\n\n\t\tlet container: Container;\n\t\tif (canCache) {\n\t\t\tconst key = this.getKeyForContainerCache(request, parsed);\n\t\t\tconst maybeContainer = await this.containers.get(key);\n\t\t\tif (maybeContainer !== undefined) {\n\t\t\t\tcontainer = maybeContainer;\n\t\t\t} else {\n\t\t\t\tconst containerP = this.loadContainer(request, resolvedAsFluid);\n\t\t\t\tthis.addToContainerCache(key, containerP);\n\t\t\t\tcontainer = await containerP;\n\t\t\t}\n\t\t} else {\n\t\t\tcontainer = await this.loadContainer(request, resolvedAsFluid, pendingLocalState);\n\t\t}\n\n\t\tif (container.deltaManager.lastSequenceNumber <= fromSequenceNumber) {\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\tfunction opHandler(message: ISequencedDocumentMessage) {\n\t\t\t\t\tif (message.sequenceNumber > fromSequenceNumber) {\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t\tcontainer.removeListener(\"op\", opHandler);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tcontainer.on(\"op\", opHandler);\n\t\t\t});\n\t\t}\n\n\t\treturn { container, parsed };\n\t}\n\n\tprivate get cachingEnabled() {\n\t\treturn this.services.options.cache !== false;\n\t}\n\n\tprivate async loadContainer(\n\t\trequest: IRequest,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tpendingLocalState?: IPendingContainerState,\n\t): Promise<Container> {\n\t\treturn Container.load(\n\t\t\t{\n\t\t\t\tresolvedUrl,\n\t\t\t\tversion: request.headers?.[LoaderHeader.version] ?? undefined,\n\t\t\t\tloadMode: request.headers?.[LoaderHeader.loadMode],\n\t\t\t\tpendingLocalState,\n\t\t\t},\n\t\t\t{\n\t\t\t\tcanReconnect: request.headers?.[LoaderHeader.reconnect],\n\t\t\t\tclientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n\t\t\t\t...this.services,\n\t\t\t},\n\t\t);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAGN,sBAAsB,EAEtB,gBAAgB,EAChB,4BAA4B,EAC5B,4BAA4B,GAC5B,MAAM,iCAAiC,CAAC;AASzC,OAAO,EAMN,YAAY,GAGZ,MAAM,uCAAuC,CAAC;AAO/C,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAC;AAChE,OAAO,EAAc,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,SAAS,WAAW,CAAC,OAAiB;IACrC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;AACvD,CAAC;AAED,SAAS,wBAAwB,CAChC,QAAkC;IAElC,IAAI,QAAQ,KAAK,SAAS,EAAE;QAC3B,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AAO,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAC9B,CAAC;IAED,IAAY,cAAc;QACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC;IAC7C,CAAC;IAEO,KAAK,CAAC,aAAa,CAC1B,OAAiB,EACjB,WAAyB,EACzB,iBAA0C;QAE1C,OAAO,SAAS,CAAC,IAAI,CACpB;YACC,WAAW;YACX,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,SAAS;YAC7D,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC;YAClD,iBAAiB;YACjB,oBAAoB,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC;SACpE,EACD;YACC,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC;YACvD,qBAAqB,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,aAAa,CAAC;YACpE,GAAG,IAAI,CAAC,QAAQ;SAChB,CACD,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport {\n\tITelemetryLoggerExt,\n\tIConfigProviderBase,\n\tmixinMonitoringContext,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tsessionStorageConfigProvider,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n\tITelemetryBaseLogger,\n\tFluidObject,\n\tIFluidRouter,\n\tIRequest,\n\tIRequestHeader,\n\tIResponse,\n} from \"@fluidframework/core-interfaces\";\nimport {\n\tIContainer,\n\tIFluidModule,\n\tIHostLoader,\n\tILoader,\n\tILoaderOptions as ILoaderOptions1,\n\tLoaderHeader,\n\tIProvideFluidCodeDetailsComparer,\n\tIFluidCodeDetails,\n} from \"@fluidframework/container-definitions\";\nimport {\n\tIDocumentServiceFactory,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { Container, IPendingContainerState } from \"./container\";\nimport { IParsedUrl, parseUrl } from \"./utils\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { ProtocolHandlerBuilder } from \"./protocol\";\nimport { DebugLogger } from \"./debugLogger\";\n\nfunction canUseCache(request: IRequest): boolean {\n\treturn request.headers?.[LoaderHeader.cache] === true;\n}\n\nfunction ensureResolvedUrlDefined(\n\tresolved: IResolvedUrl | undefined,\n): asserts resolved is IResolvedUrl {\n\tif (resolved === undefined) {\n\t\tthrow new Error(`Object is not a IResolveUrl.`);\n\t}\n}\n/**\n * @internal\n */\nexport class RelativeLoader implements ILoader {\n\tconstructor(\n\t\tprivate readonly container: Container,\n\t\tprivate readonly loader: ILoader | undefined,\n\t) {}\n\n\t/**\n\t * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.\n\t */\n\tpublic get IFluidRouter(): IFluidRouter {\n\t\treturn this;\n\t}\n\n\tpublic async resolve(request: IRequest): Promise<IContainer> {\n\t\tif (request.url.startsWith(\"/\")) {\n\t\t\tif (canUseCache(request)) {\n\t\t\t\treturn this.container;\n\t\t\t} else {\n\t\t\t\tensureResolvedUrlDefined(this.container.resolvedUrl);\n\t\t\t\tconst container = await this.container.clone(\n\t\t\t\t\t{\n\t\t\t\t\t\tresolvedUrl: { ...this.container.resolvedUrl },\n\t\t\t\t\t\tversion: request.headers?.[LoaderHeader.version] ?? undefined,\n\t\t\t\t\t\tloadMode: request.headers?.[LoaderHeader.loadMode],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tcanReconnect: request.headers?.[LoaderHeader.reconnect],\n\t\t\t\t\t\tclientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn container;\n\t\t\t}\n\t\t}\n\n\t\tif (this.loader === undefined) {\n\t\t\tthrow new Error(\"Cannot resolve external containers\");\n\t\t}\n\t\treturn this.loader.resolve(request);\n\t}\n\n\t/**\n\t * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.\n\t */\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\tif (request.url.startsWith(\"/\")) {\n\t\t\tconst container = await this.resolve(request);\n\t\t\treturn container.request(request);\n\t\t}\n\n\t\tif (this.loader === undefined) {\n\t\t\treturn {\n\t\t\t\tstatus: 404,\n\t\t\t\tvalue: \"Cannot request external containers\",\n\t\t\t\tmimeType: \"plain/text\",\n\t\t\t};\n\t\t}\n\t\treturn this.loader.request(request);\n\t}\n}\n\nexport interface ILoaderOptions extends ILoaderOptions1 {\n\tsummarizeProtocolTree?: boolean;\n}\n\n/**\n * @deprecated IFluidModuleWithDetails interface is moved to\n * {@link @fluidframework/container-definitions#IFluidModuleWithDetails}\n * to have all the code loading modules in one package. #8193\n * Encapsulates a module entry point with corresponding code details.\n */\nexport interface IFluidModuleWithDetails {\n\t/** Fluid code module that implements the runtime factory needed to instantiate the container runtime. */\n\tmodule: IFluidModule;\n\t/**\n\t * Code details associated with the module. Represents a document schema this module supports.\n\t * If the code loader implements the {@link @fluidframework/core-interfaces#IFluidCodeDetailsComparer} interface,\n\t * it'll be called to determine whether the module code details satisfy the new code proposal in the quorum.\n\t */\n\tdetails: IFluidCodeDetails;\n}\n\n/**\n * @deprecated ICodeDetailsLoader interface is moved to {@link @fluidframework/container-definition#ICodeDetailsLoader}\n * to have code loading modules in one package. #8193\n * Fluid code loader resolves a code module matching the document schema, i.e. code details, such as\n * a package name and package version range.\n */\nexport interface ICodeDetailsLoader extends Partial<IProvideFluidCodeDetailsComparer> {\n\t/**\n\t * Load the code module (package) that is capable to interact with the document.\n\t *\n\t * @param source - Code proposal that articulates the current schema the document is written in.\n\t * @returns - Code module entry point along with the code details associated with it.\n\t */\n\tload(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;\n}\n\n/**\n * Services and properties necessary for creating a loader\n */\nexport interface ILoaderProps {\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options used by various layers\n\t * to control features\n\t */\n\treadonly options?: ILoaderOptions;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope?: FluidObject;\n\n\t/**\n\t * The logger that all telemetry should be pushed to.\n\t */\n\treadonly logger?: ITelemetryBaseLogger;\n\n\t/**\n\t * Blobs storage for detached containers.\n\t */\n\treadonly detachedBlobStorage?: IDetachedBlobStorage;\n\n\t/**\n\t * The configuration provider which may be used to control features.\n\t */\n\treadonly configProvider?: IConfigProviderBase;\n\n\t/**\n\t * Optional property for allowing the container to use a custom\n\t * protocol implementation for handling the quorum and/or the audience.\n\t */\n\treadonly protocolHandlerBuilder?: ProtocolHandlerBuilder;\n}\n\n/**\n * Services and properties used by and exposed by the loader\n */\nexport interface ILoaderServices {\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options used by various layers\n\t * to control features\n\t */\n\treadonly options: ILoaderOptions;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope: FluidObject;\n\n\t/**\n\t * The logger downstream consumers should construct their loggers from\n\t */\n\treadonly subLogger: ITelemetryLoggerExt;\n\n\t/**\n\t * Blobs storage for detached containers.\n\t */\n\treadonly detachedBlobStorage?: IDetachedBlobStorage;\n\n\t/**\n\t * Optional property for allowing the container to use a custom\n\t * protocol implementation for handling the quorum and/or the audience.\n\t */\n\treadonly protocolHandlerBuilder?: ProtocolHandlerBuilder;\n}\n\n/**\n * Subset of IDocumentStorageService which only supports createBlob() and readBlob(). This is used to support\n * blobs in detached containers.\n */\nexport type IDetachedBlobStorage = Pick<IDocumentStorageService, \"createBlob\" | \"readBlob\"> & {\n\tsize: number;\n\t/**\n\t * Return an array of all blob IDs present in storage\n\t */\n\tgetBlobIds(): string[];\n};\n\n/**\n * With an already-resolved container, we can request a component directly, without loading the container again\n * @param container - a resolved container\n * @returns component on the container\n */\nexport async function requestResolvedObjectFromContainer(\n\tcontainer: IContainer,\n\theaders?: IRequestHeader,\n): Promise<IResponse> {\n\tensureResolvedUrlDefined(container.resolvedUrl);\n\tconst parsedUrl = parseUrl(container.resolvedUrl.url);\n\n\tif (parsedUrl === undefined) {\n\t\tthrow new Error(`Invalid URL ${container.resolvedUrl.url}`);\n\t}\n\n\tconst entryPoint: FluidObject<IFluidRouter> | undefined = await container.getEntryPoint?.();\n\tconst router = entryPoint?.IFluidRouter ?? container.IFluidRouter;\n\n\treturn router.request({\n\t\turl: `${parsedUrl.path}${parsedUrl.query}`,\n\t\theaders,\n\t});\n}\n\n/**\n * Manages Fluid resource loading\n */\nexport class Loader implements IHostLoader {\n\tprivate readonly containers = new Map<string, Promise<Container>>();\n\tpublic readonly services: ILoaderServices;\n\tprivate readonly mc: MonitoringContext;\n\n\tconstructor(loaderProps: ILoaderProps) {\n\t\tconst {\n\t\t\turlResolver,\n\t\t\tdocumentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\toptions,\n\t\t\tscope,\n\t\t\tlogger,\n\t\t\tdetachedBlobStorage,\n\t\t\tconfigProvider,\n\t\t\tprotocolHandlerBuilder,\n\t\t} = loaderProps;\n\n\t\tconst telemetryProps = {\n\t\t\tloaderId: uuid(),\n\t\t\tloaderVersion: pkgVersion,\n\t\t};\n\n\t\tconst subMc = mixinMonitoringContext(\n\t\t\tDebugLogger.mixinDebugLogger(\"fluid:telemetry\", logger, {\n\t\t\t\tall: telemetryProps,\n\t\t\t}),\n\t\t\tsessionStorageConfigProvider.value,\n\t\t\tconfigProvider,\n\t\t);\n\n\t\tthis.services = {\n\t\t\turlResolver,\n\t\t\tdocumentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\toptions: options ?? {},\n\t\t\tscope:\n\t\t\t\toptions?.provideScopeLoader !== false ? { ...scope, ILoader: this } : { ...scope },\n\t\t\tdetachedBlobStorage,\n\t\t\tprotocolHandlerBuilder,\n\t\t\tsubLogger: subMc.logger,\n\t\t};\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: this.services.subLogger,\n\t\t\tnamespace: \"Loader\",\n\t\t});\n\t}\n\n\t/**\n\t * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.\n\t */\n\tpublic get IFluidRouter(): IFluidRouter {\n\t\treturn this;\n\t}\n\n\tpublic async createDetachedContainer(codeDetails: IFluidCodeDetails): Promise<IContainer> {\n\t\tconst container = await Container.createDetached(this.services, codeDetails);\n\n\t\tif (this.cachingEnabled) {\n\t\t\tcontainer.once(\"attached\", () => {\n\t\t\t\tensureResolvedUrlDefined(container.resolvedUrl);\n\t\t\t\tconst parsedUrl = parseUrl(container.resolvedUrl.url);\n\t\t\t\tif (parsedUrl !== undefined) {\n\t\t\t\t\tthis.addToContainerCache(parsedUrl.id, Promise.resolve(container));\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn container;\n\t}\n\n\tpublic async rehydrateDetachedContainerFromSnapshot(snapshot: string): Promise<IContainer> {\n\t\treturn Container.rehydrateDetachedFromSnapshot(this.services, snapshot);\n\t}\n\n\tpublic async resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer> {\n\t\tconst eventName = pendingLocalState === undefined ? \"Resolve\" : \"ResolveWithPendingState\";\n\t\treturn PerformanceEvent.timedExecAsync(this.mc.logger, { eventName }, async () => {\n\t\t\tconst resolved = await this.resolveCore(\n\t\t\t\trequest,\n\t\t\t\tpendingLocalState !== undefined ? JSON.parse(pendingLocalState) : undefined,\n\t\t\t);\n\t\t\treturn resolved.container;\n\t\t});\n\t}\n\n\t/**\n\t * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.\n\t */\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{ eventName: \"Request\" },\n\t\t\tasync () => {\n\t\t\t\tconst resolved = await this.resolveCore(request);\n\t\t\t\treturn resolved.container.request({\n\t\t\t\t\t...request,\n\t\t\t\t\turl: `${resolved.parsed.path}${resolved.parsed.query}`,\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate getKeyForContainerCache(request: IRequest, parsedUrl: IParsedUrl): string {\n\t\tconst key =\n\t\t\trequest.headers?.[LoaderHeader.version] !== undefined\n\t\t\t\t? `${parsedUrl.id}@${request.headers[LoaderHeader.version]}`\n\t\t\t\t: parsedUrl.id;\n\t\treturn key;\n\t}\n\n\tprivate addToContainerCache(key: string, containerP: Promise<Container>) {\n\t\tthis.containers.set(key, containerP);\n\t\tcontainerP\n\t\t\t.then((container) => {\n\t\t\t\t// If the container is closed/disposed or becomes closed/disposed after we resolve it,\n\t\t\t\t// remove it from the cache.\n\t\t\t\tif (container.closed || container.disposed) {\n\t\t\t\t\tthis.containers.delete(key);\n\t\t\t\t} else {\n\t\t\t\t\tcontainer.once(\"closed\", () => {\n\t\t\t\t\t\tthis.containers.delete(key);\n\t\t\t\t\t});\n\t\t\t\t\tcontainer.once(\"disposed\", () => {\n\t\t\t\t\t\tthis.containers.delete(key);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\t// If an error occured while resolving the container request, then remove it from the cache.\n\t\t\t\tthis.containers.delete(key);\n\t\t\t});\n\t}\n\n\tprivate async resolveCore(\n\t\trequest: IRequest,\n\t\tpendingLocalState?: IPendingContainerState,\n\t): Promise<{ container: Container; parsed: IParsedUrl }> {\n\t\tconst resolvedAsFluid = await this.services.urlResolver.resolve(request);\n\t\tensureResolvedUrlDefined(resolvedAsFluid);\n\n\t\t// Parse URL into data stores\n\t\tconst parsed = parseUrl(resolvedAsFluid.url);\n\t\tif (parsed === undefined) {\n\t\t\tthrow new Error(`Invalid URL ${resolvedAsFluid.url}`);\n\t\t}\n\n\t\tif (pendingLocalState !== undefined) {\n\t\t\tconst parsedPendingUrl = parseUrl(pendingLocalState.url);\n\t\t\tif (\n\t\t\t\tparsedPendingUrl?.id !== parsed.id ||\n\t\t\t\tparsedPendingUrl?.path.replace(/\\/$/, \"\") !== parsed.path.replace(/\\/$/, \"\")\n\t\t\t) {\n\t\t\t\tconst message = `URL ${resolvedAsFluid.url} does not match pending state URL ${pendingLocalState.url}`;\n\t\t\t\tthrow new Error(message);\n\t\t\t}\n\t\t}\n\n\t\trequest.headers ??= {};\n\t\t// If set in both query string and headers, use query string. Also write the value from the query string into the header either way.\n\t\trequest.headers[LoaderHeader.version] =\n\t\t\tparsed.version ?? request.headers[LoaderHeader.version];\n\t\tconst cacheHeader = request.headers[LoaderHeader.cache];\n\t\tconst canCache =\n\t\t\t// Take header value if present, else use ILoaderOptions.cache value\n\t\t\t(cacheHeader !== undefined ? cacheHeader === true : this.cachingEnabled) &&\n\t\t\tpendingLocalState === undefined;\n\t\tconst fromSequenceNumber = request.headers[LoaderHeader.sequenceNumber] as\n\t\t\t| number\n\t\t\t| undefined;\n\t\tconst opsBeforeReturn = request.headers[LoaderHeader.loadMode]?.opsBeforeReturn as\n\t\t\t| string\n\t\t\t| undefined;\n\n\t\tif (\n\t\t\topsBeforeReturn === \"sequenceNumber\" &&\n\t\t\t(fromSequenceNumber === undefined || fromSequenceNumber < 0)\n\t\t) {\n\t\t\t// If opsBeforeReturn is set to \"sequenceNumber\", then fromSequenceNumber should be set to a non-negative integer.\n\t\t\tthrow new UsageError(\"sequenceNumber must be set to a non-negative integer\");\n\t\t} else if (opsBeforeReturn !== \"sequenceNumber\" && fromSequenceNumber !== undefined) {\n\t\t\t// If opsBeforeReturn is not set to \"sequenceNumber\", then fromSequenceNumber should be undefined (default value).\n\t\t\t// In this case, we should throw an error since opsBeforeReturn is not explicitly set to \"sequenceNumber\".\n\t\t\tthrow new UsageError('opsBeforeReturn must be set to \"sequenceNumber\"');\n\t\t}\n\n\t\tlet container: Container;\n\t\tif (canCache) {\n\t\t\tconst key = this.getKeyForContainerCache(request, parsed);\n\t\t\tconst maybeContainer = await this.containers.get(key);\n\t\t\tif (maybeContainer !== undefined) {\n\t\t\t\tcontainer = maybeContainer;\n\t\t\t} else {\n\t\t\t\tconst containerP = this.loadContainer(request, resolvedAsFluid);\n\t\t\t\tthis.addToContainerCache(key, containerP);\n\t\t\t\tcontainer = await containerP;\n\t\t\t}\n\t\t} else {\n\t\t\tcontainer = await this.loadContainer(request, resolvedAsFluid, pendingLocalState);\n\t\t}\n\n\t\treturn { container, parsed };\n\t}\n\n\tprivate get cachingEnabled() {\n\t\treturn this.services.options.cache === true;\n\t}\n\n\tprivate async loadContainer(\n\t\trequest: IRequest,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tpendingLocalState?: IPendingContainerState,\n\t): Promise<Container> {\n\t\treturn Container.load(\n\t\t\t{\n\t\t\t\tresolvedUrl,\n\t\t\t\tversion: request.headers?.[LoaderHeader.version] ?? undefined,\n\t\t\t\tloadMode: request.headers?.[LoaderHeader.loadMode],\n\t\t\t\tpendingLocalState,\n\t\t\t\tloadToSequenceNumber: request.headers?.[LoaderHeader.sequenceNumber],\n\t\t\t},\n\t\t\t{\n\t\t\t\tcanReconnect: request.headers?.[LoaderHeader.reconnect],\n\t\t\t\tclientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n\t\t\t\t...this.services,\n\t\t\t},\n\t\t);\n\t}\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/container-loader";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-internal.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.6.0.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export const pkgName = "@fluidframework/container-loader";
|
|
8
|
-
export const pkgVersion = "2.0.0-internal.
|
|
8
|
+
export const pkgVersion = "2.0.0-internal.6.0.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,kCAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,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/container-loader\";\nexport const pkgVersion = \"2.0.0-internal.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,kCAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,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/container-loader\";\nexport const pkgVersion = \"2.0.0-internal.6.0.0\";\n"]}
|
package/lib/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EACN,gBAAgB,IAAI,oBAAoB,EACxC,eAAe,EACf,iBAAiB,EACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,mBAAmB,EAEnB,cAAc,EACd,MAAM,sCAAsC,CAAC;AAG9C,eAAO,MAAM,kBAAkB,GAAa,CAAC;AAG7C,oBAAY,UAAU;IACrB,UAAU,SAAS;IACnB,WAAW,UAAU;IACrB,KAAK,UAAU;CACf;AAED;;GAEG;AACH,oBAAY,sBAAsB,GAAG,CACpC,UAAU,EAAE,mBAAmB,EAC/B,QAAQ,EAAE,eAAe,EACzB,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,MAAM,KAC7C,gBAAgB,CAAC;AAEtB,MAAM,WAAW,gBAAiB,SAAQ,oBAAoB;IAC7D,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,aAAa,CAAC,OAAO,EAAE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AM,EACxC,QAAQ,EAAE,cAAc;IAqB3B,aAAa,CAAC,OAAO,EAAE,cAAc;CAgC5C;AAED;;;;GAIG;AACH,wBAAgB,kCAAkC,CAAC,OAAO,EAAE,cAAc,WAWzE"}
|
package/lib/protocol.js
CHANGED
|
@@ -14,7 +14,7 @@ export var SignalType;
|
|
|
14
14
|
})(SignalType || (SignalType = {}));
|
|
15
15
|
export class ProtocolHandler extends ProtocolOpHandler {
|
|
16
16
|
constructor(attributes, quorumSnapshot, sendProposal, audience) {
|
|
17
|
-
super(attributes.minimumSequenceNumber, attributes.sequenceNumber,
|
|
17
|
+
super(attributes.minimumSequenceNumber, attributes.sequenceNumber, quorumSnapshot.members, quorumSnapshot.proposals, quorumSnapshot.values, sendProposal);
|
|
18
18
|
this.audience = audience;
|
|
19
19
|
// Join / leave signals are ignored for "write" clients in favor of join / leave ops
|
|
20
20
|
this.quorum.on("addMember", (clientId, details) => audience.addMember(clientId, details.client));
|
|
@@ -24,7 +24,6 @@ export class ProtocolHandler extends ProtocolOpHandler {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
processSignal(message) {
|
|
27
|
-
var _a;
|
|
28
27
|
const innerContent = message.content;
|
|
29
28
|
switch (innerContent.type) {
|
|
30
29
|
case SignalType.Clear: {
|
|
@@ -47,7 +46,7 @@ export class ProtocolHandler extends ProtocolOpHandler {
|
|
|
47
46
|
case SignalType.ClientLeave: {
|
|
48
47
|
const leftClientId = innerContent.content;
|
|
49
48
|
// Ignore write clients - quorum will control such clients.
|
|
50
|
-
if (
|
|
49
|
+
if (this.audience.getMember(leftClientId)?.mode === "read") {
|
|
51
50
|
this.audience.removeMember(leftClientId);
|
|
52
51
|
}
|
|
53
52
|
break;
|
package/lib/protocol.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAGN,iBAAiB,GACjB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AA2D;gBAC3D,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,IAAI,KAAK,MAAM,EAAE;oBAC3D,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;iBACzC;gBACD,MAAM;aACN;YACD;gBACC,MAAM;SACP;IACF,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,UAAU,kCAAkC,CAAC,OAAuB;IACzE,gCAAgC;IAChC,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI,EAAE;QAC9B,MAAM,YAAY,GAAG,OAAO,CAAC,OAA6C,CAAC;QAC3E,OAAO,CACN,YAAY,CAAC,IAAI,KAAK,UAAU,CAAC,KAAK;YACtC,YAAY,CAAC,IAAI,KAAK,UAAU,CAAC,UAAU;YAC3C,YAAY,CAAC,IAAI,KAAK,UAAU,CAAC,WAAW,CAC5C,CAAC;KACF;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IAudienceOwner } from \"@fluidframework/container-definitions\";\nimport {\n\tIProtocolHandler as IBaseProtocolHandler,\n\tIQuorumSnapshot,\n\tProtocolOpHandler,\n} from \"@fluidframework/protocol-base\";\nimport {\n\tIDocumentAttributes,\n\tISignalClient,\n\tISignalMessage,\n} from \"@fluidframework/protocol-definitions\";\n\n// \"term\" was an experimental feature that is being removed. The only safe value to use is 1.\nexport const OnlyValidTermValue = 1 as const;\n\n// ADO: #1986: Start using enum from protocol-base.\nexport enum SignalType {\n\tClientJoin = \"join\", // same value as MessageType.ClientJoin,\n\tClientLeave = \"leave\", // same value as MessageType.ClientLeave,\n\tClear = \"clear\", // used only by client for synthetic signals\n}\n\n/**\n * Function to be used for creating a protocol handler.\n */\nexport type ProtocolHandlerBuilder = (\n\tattributes: IDocumentAttributes,\n\tsnapshot: IQuorumSnapshot,\n\tsendProposal: (key: string, value: any) => number,\n) => IProtocolHandler;\n\nexport interface IProtocolHandler extends IBaseProtocolHandler {\n\treadonly audience: IAudienceOwner;\n\tprocessSignal(message: ISignalMessage);\n}\n\nexport class ProtocolHandler extends ProtocolOpHandler implements IProtocolHandler {\n\tconstructor(\n\t\tattributes: IDocumentAttributes,\n\t\tquorumSnapshot: IQuorumSnapshot,\n\t\tsendProposal: (key: string, value: any) => number,\n\t\treadonly audience: IAudienceOwner,\n\t) {\n\t\tsuper(\n\t\t\tattributes.minimumSequenceNumber,\n\t\t\tattributes.sequenceNumber,\n\t\t\tquorumSnapshot.members,\n\t\t\tquorumSnapshot.proposals,\n\t\t\tquorumSnapshot.values,\n\t\t\tsendProposal,\n\t\t);\n\n\t\t// Join / leave signals are ignored for \"write\" clients in favor of join / leave ops\n\t\tthis.quorum.on(\"addMember\", (clientId, details) =>\n\t\t\taudience.addMember(clientId, details.client),\n\t\t);\n\t\tthis.quorum.on(\"removeMember\", (clientId) => audience.removeMember(clientId));\n\t\tfor (const [clientId, details] of this.quorum.getMembers()) {\n\t\t\tthis.audience.addMember(clientId, details.client);\n\t\t}\n\t}\n\n\tpublic processSignal(message: ISignalMessage) {\n\t\tconst innerContent = message.content as { content: any; type: string };\n\t\tswitch (innerContent.type) {\n\t\t\tcase SignalType.Clear: {\n\t\t\t\tconst members = this.audience.getMembers();\n\t\t\t\tfor (const [clientId, client] of members) {\n\t\t\t\t\tif (client.mode === \"read\") {\n\t\t\t\t\t\tthis.audience.removeMember(clientId);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SignalType.ClientJoin: {\n\t\t\t\tconst newClient = innerContent.content as ISignalClient;\n\t\t\t\t// Ignore write clients - quorum will control such clients.\n\t\t\t\tif (newClient.client.mode === \"read\") {\n\t\t\t\t\tthis.audience.addMember(newClient.clientId, newClient.client);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SignalType.ClientLeave: {\n\t\t\t\tconst leftClientId = innerContent.content as string;\n\t\t\t\t// Ignore write clients - quorum will control such clients.\n\t\t\t\tif (this.audience.getMember(leftClientId)?.mode === \"read\") {\n\t\t\t\t\tthis.audience.removeMember(leftClientId);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/**\n * Function to check whether the protocol handler should process the Signal.\n * The protocol handler should strictly handle only ClientJoin, ClientLeave\n * and Clear signal types.\n */\nexport function protocolHandlerShouldProcessSignal(message: ISignalMessage) {\n\t// Signal originates from server\n\tif (message.clientId === null) {\n\t\tconst innerContent = message.content as { content: unknown; type: string };\n\t\treturn (\n\t\t\tinnerContent.type === SignalType.Clear ||\n\t\t\tinnerContent.type === SignalType.ClientJoin ||\n\t\t\tinnerContent.type === SignalType.ClientLeave\n\t\t);\n\t}\n\treturn false;\n}\n"]}
|
package/lib/quorum.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
1
5
|
import { IFluidCodeDetails } from "@fluidframework/core-interfaces";
|
|
2
6
|
import { ICommittedProposal } from "@fluidframework/protocol-definitions";
|
|
3
|
-
export declare function getCodeDetailsFromQuorumValues(quorumValues: [string, ICommittedProposal][]): IFluidCodeDetails;
|
|
4
7
|
export declare function initQuorumValuesFromCodeDetails(source: IFluidCodeDetails): [string, ICommittedProposal][];
|
|
5
8
|
//# sourceMappingURL=quorum.d.ts.map
|
package/lib/quorum.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quorum.d.ts","sourceRoot":"","sources":["../src/quorum.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quorum.d.ts","sourceRoot":"","sources":["../src/quorum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE1E,wBAAgB,+BAA+B,CAC9C,MAAM,EAAE,iBAAiB,GACvB,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAUhC"}
|
package/lib/quorum.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { assert } from "@fluidframework/common-utils";
|
|
6
|
-
export function getCodeDetailsFromQuorumValues(quorumValues) {
|
|
7
|
-
const qValuesMap = new Map(quorumValues);
|
|
8
|
-
const proposal = qValuesMap.get("code");
|
|
9
|
-
assert(proposal !== undefined, 0x2dc /* "Cannot find code proposal" */);
|
|
10
|
-
return proposal === null || proposal === void 0 ? void 0 : proposal.value;
|
|
11
|
-
}
|
|
12
1
|
export function initQuorumValuesFromCodeDetails(source) {
|
|
13
2
|
// Seed the base quorum to be an empty list with a code quorum set
|
|
14
3
|
const committedCodeProposal = {
|
package/lib/quorum.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quorum.js","sourceRoot":"","sources":["../src/quorum.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quorum.js","sourceRoot":"","sources":["../src/quorum.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,+BAA+B,CAC9C,MAAyB;IAEzB,kEAAkE;IAClE,MAAM,qBAAqB,GAAuB;QACjD,GAAG,EAAE,MAAM;QACX,KAAK,EAAE,MAAM;QACb,sBAAsB,EAAE,CAAC;QACzB,oBAAoB,EAAE,CAAC;QACvB,cAAc,EAAE,CAAC;KACjB,CAAC;IACF,OAAO,CAAC,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { IFluidCodeDetails } from \"@fluidframework/core-interfaces\";\nimport { ICommittedProposal } from \"@fluidframework/protocol-definitions\";\n\nexport function initQuorumValuesFromCodeDetails(\n\tsource: IFluidCodeDetails,\n): [string, ICommittedProposal][] {\n\t// Seed the base quorum to be an empty list with a code quorum set\n\tconst committedCodeProposal: ICommittedProposal = {\n\t\tkey: \"code\",\n\t\tvalue: source,\n\t\tapprovalSequenceNumber: 0,\n\t\tcommitSequenceNumber: 0,\n\t\tsequenceNumber: 0,\n\t};\n\treturn [[\"code\", committedCodeProposal]];\n}\n"]}
|
package/lib/utils.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ISummaryTree, ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
6
|
-
import { DeltaStreamConnectionForbiddenError } from "@fluidframework/driver-utils";
|
|
6
|
+
import { CombinedAppAndProtocolSummary, DeltaStreamConnectionForbiddenError } from "@fluidframework/driver-utils";
|
|
7
7
|
export interface ISnapshotTreeWithBlobContents extends ISnapshotTree {
|
|
8
8
|
blobsContents: {
|
|
9
9
|
[path: string]: ArrayBufferLike;
|
|
@@ -24,6 +24,13 @@ export interface IParsedUrl {
|
|
|
24
24
|
version: string | null | undefined;
|
|
25
25
|
}
|
|
26
26
|
export declare function parseUrl(url: string): IParsedUrl | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Combine the app summary and protocol summary in 1 tree.
|
|
29
|
+
* @param appSummary - Summary of the app.
|
|
30
|
+
* @param protocolSummary - Summary of the protocol.
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export declare function combineAppAndProtocolSummary(appSummary: ISummaryTree, protocolSummary: ISummaryTree): CombinedAppAndProtocolSummary;
|
|
27
34
|
/**
|
|
28
35
|
* Combine and convert protocol and app summary tree to format which is readable by container while rehydrating.
|
|
29
36
|
* @param protocolSummaryTree - Protocol Summary Tree
|