@fluidframework/container-loader 0.58.3000-61081 → 0.59.1001-62246
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/container.d.ts +2 -9
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +15 -24
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +5 -7
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +6 -4
- package/dist/containerContext.js.map +1 -1
- package/dist/contracts.d.ts +8 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +21 -1
- package/dist/contracts.js.map +1 -1
- package/dist/loader.d.ts +4 -4
- package/dist/loader.d.ts.map +1 -1
- 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/utils.d.ts.map +1 -1
- package/dist/utils.js +0 -1
- package/dist/utils.js.map +1 -1
- package/lib/container.d.ts +2 -9
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +15 -24
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +5 -7
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +6 -4
- package/lib/containerContext.js.map +1 -1
- package/lib/contracts.d.ts +8 -1
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js +19 -0
- package/lib/contracts.js.map +1 -1
- package/lib/loader.d.ts +4 -4
- package/lib/loader.d.ts.map +1 -1
- 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/utils.d.ts.map +1 -1
- package/lib/utils.js +0 -1
- package/lib/utils.js.map +1 -1
- package/package.json +17 -16
- package/src/container.ts +16 -25
- package/src/containerContext.ts +11 -13
- package/src/contracts.ts +20 -0
- package/src/loader.ts +5 -6
- package/src/packageVersion.ts +1 -1
- package/src/utils.ts +0 -1
|
@@ -3,21 +3,19 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
6
|
-
import { IAudience, IContainerContext, IDeltaManager, ILoader, ICriticalContainerError,
|
|
7
|
-
import {
|
|
6
|
+
import { IAudience, IContainerContext, IDeltaManager, ILoader, ICriticalContainerError, AttachState, ILoaderOptions, IFluidCodeDetails, ICodeDetailsLoader } from "@fluidframework/container-definitions";
|
|
7
|
+
import { IRequest, IResponse, FluidObject } from "@fluidframework/core-interfaces";
|
|
8
8
|
import { IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
9
9
|
import { IClientConfiguration, IClientDetails, IDocumentMessage, IQuorum, IQuorumClients, ISequencedDocumentMessage, ISignalMessage, ISnapshotTree, ISummaryTree, IVersion, MessageType } from "@fluidframework/protocol-definitions";
|
|
10
10
|
import { Container } from "./container";
|
|
11
|
-
import { ICodeDetailsLoader } from "./loader";
|
|
12
11
|
export declare class ContainerContext implements IContainerContext {
|
|
13
12
|
private readonly container;
|
|
14
|
-
readonly scope:
|
|
13
|
+
readonly scope: FluidObject;
|
|
15
14
|
private readonly codeLoader;
|
|
16
15
|
private readonly _codeDetails;
|
|
17
16
|
private readonly _baseSnapshot;
|
|
18
17
|
readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
|
|
19
18
|
readonly loader: ILoader;
|
|
20
|
-
readonly raiseContainerWarning: (warning: ContainerWarning) => void;
|
|
21
19
|
readonly submitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number;
|
|
22
20
|
readonly submitSignalFn: (contents: any) => void;
|
|
23
21
|
readonly closeFn: (error?: ICriticalContainerError) => void;
|
|
@@ -25,7 +23,7 @@ export declare class ContainerContext implements IContainerContext {
|
|
|
25
23
|
readonly updateDirtyContainerState: (dirty: boolean) => void;
|
|
26
24
|
readonly existing: boolean;
|
|
27
25
|
readonly pendingLocalState?: unknown;
|
|
28
|
-
static createOrLoad(container: Container, scope: FluidObject, codeLoader: ICodeDetailsLoader
|
|
26
|
+
static createOrLoad(container: Container, scope: FluidObject, codeLoader: ICodeDetailsLoader, codeDetails: IFluidCodeDetails, baseSnapshot: ISnapshotTree | undefined, deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>, quorum: IQuorum, loader: ILoader, submitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number, submitSignalFn: (contents: any) => void, closeFn: (error?: ICriticalContainerError) => void, version: string, updateDirtyContainerState: (dirty: boolean) => void, existing: boolean, pendingLocalState?: unknown): Promise<ContainerContext>;
|
|
29
27
|
readonly taggedLogger: ITelemetryLogger;
|
|
30
28
|
get clientId(): string | undefined;
|
|
31
29
|
/** @deprecated Added back to unblock 0.56 integration */
|
|
@@ -46,7 +44,7 @@ export declare class ContainerContext implements IContainerContext {
|
|
|
46
44
|
private readonly _quorum;
|
|
47
45
|
get quorum(): IQuorumClients;
|
|
48
46
|
private readonly _fluidModuleP;
|
|
49
|
-
constructor(container: Container, scope:
|
|
47
|
+
constructor(container: Container, scope: FluidObject, codeLoader: ICodeDetailsLoader, _codeDetails: IFluidCodeDetails, _baseSnapshot: ISnapshotTree | undefined, deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>, quorum: IQuorum, loader: ILoader, submitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number, submitSignalFn: (contents: any) => void, closeFn: (error?: ICriticalContainerError) => void, version: string, updateDirtyContainerState: (dirty: boolean) => void, existing: boolean, pendingLocalState?: unknown);
|
|
50
48
|
/**
|
|
51
49
|
* @deprecated - Temporary migratory API, to be removed when customers no longer need it. When removed,
|
|
52
50
|
* ContainerContext should only take an IQuorumClients rather than an IQuorum. See IContainerContext for more
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerContext.d.ts","sourceRoot":"","sources":["../src/containerContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,E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AAE,MAAM,CAAC,GAAG,YAAY;IAIpE,kBAAkB,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM;IAQxD,OAAO,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG;IAIxE,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO;IAI/C,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAI3C,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAItE,oBAAoB,IAAI,OAAO;IAItC;;;OAGG;IACU,SAAS,CAAC,qBAAqB,EAAE,iBAAiB;IAoCxD,eAAe;YAMR,iBAAiB;YAWjB,kBAAkB;IAKhC,OAAO,CAAC,cAAc;YAMR,cAAc;CAqB/B"}
|
package/lib/containerContext.js
CHANGED
|
@@ -8,7 +8,7 @@ import { isFluidResolvedUrl } from "@fluidframework/driver-utils";
|
|
|
8
8
|
import { PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
9
9
|
const PackageNotFactoryError = "Code package does not implement IRuntimeFactory";
|
|
10
10
|
export class ContainerContext {
|
|
11
|
-
constructor(container, scope, codeLoader, _codeDetails, _baseSnapshot, deltaManager, quorum, loader,
|
|
11
|
+
constructor(container, scope, codeLoader, _codeDetails, _baseSnapshot, deltaManager, quorum, loader, submitFn, submitSignalFn, closeFn, version, updateDirtyContainerState, existing, pendingLocalState) {
|
|
12
12
|
this.container = container;
|
|
13
13
|
this.scope = scope;
|
|
14
14
|
this.codeLoader = codeLoader;
|
|
@@ -16,7 +16,6 @@ export class ContainerContext {
|
|
|
16
16
|
this._baseSnapshot = _baseSnapshot;
|
|
17
17
|
this.deltaManager = deltaManager;
|
|
18
18
|
this.loader = loader;
|
|
19
|
-
this.raiseContainerWarning = raiseContainerWarning;
|
|
20
19
|
this.submitFn = submitFn;
|
|
21
20
|
this.submitSignalFn = submitSignalFn;
|
|
22
21
|
this.closeFn = closeFn;
|
|
@@ -30,8 +29,8 @@ export class ContainerContext {
|
|
|
30
29
|
this._fluidModuleP = new LazyPromise(async () => this.loadCodeModule(_codeDetails));
|
|
31
30
|
this.attachListener();
|
|
32
31
|
}
|
|
33
|
-
static async createOrLoad(container, scope, codeLoader, codeDetails, baseSnapshot, deltaManager, quorum, loader,
|
|
34
|
-
const context = new ContainerContext(container, scope, codeLoader, codeDetails, baseSnapshot, deltaManager, quorum, loader,
|
|
32
|
+
static async createOrLoad(container, scope, codeLoader, codeDetails, baseSnapshot, deltaManager, quorum, loader, submitFn, submitSignalFn, closeFn, version, updateDirtyContainerState, existing, pendingLocalState) {
|
|
33
|
+
const context = new ContainerContext(container, scope, codeLoader, codeDetails, baseSnapshot, deltaManager, quorum, loader, submitFn, submitSignalFn, closeFn, version, updateDirtyContainerState, existing, pendingLocalState);
|
|
35
34
|
await context.instantiateRuntime(existing);
|
|
36
35
|
return context;
|
|
37
36
|
}
|
|
@@ -199,6 +198,9 @@ export class ContainerContext {
|
|
|
199
198
|
};
|
|
200
199
|
}
|
|
201
200
|
else {
|
|
201
|
+
// If "module" is not in the result, we are using a legacy ICodeLoader. Fix the result up with details.
|
|
202
|
+
// Once usage drops to 0 we can remove this compat path.
|
|
203
|
+
this.taggedLogger.sendTelemetryEvent({ eventName: "LegacyCodeLoader" });
|
|
202
204
|
return { module: loadCodeResult, details: codeDetails };
|
|
203
205
|
}
|
|
204
206
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerContext.js","sourceRoot":"","sources":["../src/containerContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAQH,WAAW,GAKd,MAAM,uCAAuC,CAAC;AAW/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAclE,OAAO,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C5E,CAAC;IAEO,cAAc;QAClB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE;YACjC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,KAAK,CAAC,cAAc,CAAC,WAA8B;QACvD,MAAM,cAAc,GAAG,MAAM,gBAAgB,CAAC,cAAc,CACxD,IAAI,CAAC,YAAY,EACjB,EAAE,SAAS,EAAE,UAAU,EAAE,EACzB,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAChD,CAAC;QAEF,IAAI,QAAQ,IAAI,cAAc,EAAE;YAC5B,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,CAAC;YAC3C,OAAO;gBACH,MAAM;gBACN,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,WAAW;aAClC,CAAC;SACL;aAAM;YACH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;SAC3D;IACL,CAAC;CAEJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, LazyPromise } from \"@fluidframework/common-utils\";\nimport {\n IAudience,\n IContainerContext,\n IDeltaManager,\n ILoader,\n IRuntime,\n ICriticalContainerError,\n ContainerWarning,\n AttachState,\n ILoaderOptions,\n IRuntimeFactory,\n ICodeLoader,\n IProvideRuntimeFactory,\n} from \"@fluidframework/container-definitions\";\nimport {\n IFluidObject,\n IRequest,\n IResponse,\n IFluidCodeDetails,\n IFluidCodeDetailsComparer,\n IProvideFluidCodeDetailsComparer,\n FluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { isFluidResolvedUrl } from \"@fluidframework/driver-utils\";\nimport {\n IClientConfiguration,\n IClientDetails,\n IDocumentMessage,\n IQuorum,\n IQuorumClients,\n ISequencedDocumentMessage,\n ISignalMessage,\n ISnapshotTree,\n ISummaryTree,\n IVersion,\n MessageType,\n} from \"@fluidframework/protocol-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { Container } from \"./container\";\nimport { ICodeDetailsLoader, IFluidModuleWithDetails } from \"./loader\";\n\nconst PackageNotFactoryError = \"Code package does not implement IRuntimeFactory\";\n\nexport class ContainerContext implements IContainerContext {\n public static async createOrLoad(\n container: Container,\n scope: FluidObject,\n codeLoader: ICodeDetailsLoader | ICodeLoader,\n codeDetails: IFluidCodeDetails,\n baseSnapshot: ISnapshotTree | undefined,\n deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n quorum: IQuorum,\n loader: ILoader,\n raiseContainerWarning: (warning: ContainerWarning) => void,\n submitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number,\n submitSignalFn: (contents: any) => void,\n closeFn: (error?: ICriticalContainerError) => void,\n version: string,\n updateDirtyContainerState: (dirty: boolean) => void,\n existing: boolean,\n pendingLocalState?: unknown,\n ): Promise<ContainerContext> {\n const context = new ContainerContext(\n container,\n scope,\n codeLoader,\n codeDetails,\n baseSnapshot,\n deltaManager,\n quorum,\n loader,\n raiseContainerWarning,\n submitFn,\n submitSignalFn,\n closeFn,\n version,\n updateDirtyContainerState,\n existing,\n pendingLocalState);\n await context.instantiateRuntime(existing);\n return context;\n }\n\n public readonly taggedLogger: ITelemetryLogger;\n\n public get clientId(): string | undefined {\n return this.container.clientId;\n }\n\n /** @deprecated Added back to unblock 0.56 integration */\n public get id(): string {\n const resolvedUrl = this.container.resolvedUrl;\n if (isFluidResolvedUrl(resolvedUrl)) {\n return resolvedUrl.id;\n }\n return \"\";\n }\n\n public get clientDetails(): IClientDetails {\n return this.container.clientDetails;\n }\n\n public get connected(): boolean {\n return this.container.connected;\n }\n\n public get canSummarize(): boolean {\n return \"summarize\" in this.runtime;\n }\n\n public get serviceConfiguration(): IClientConfiguration | undefined {\n return this.container.serviceConfiguration;\n }\n\n public get audience(): IAudience {\n return this.container.audience;\n }\n\n public get options(): ILoaderOptions {\n return this.container.options;\n }\n\n public get baseSnapshot() {\n return this._baseSnapshot;\n }\n\n public get storage(): IDocumentStorageService {\n return this.container.storage;\n }\n\n private _runtime: IRuntime | undefined;\n private get runtime() {\n if (this._runtime === undefined) {\n throw new Error(\"Attempted to access runtime before it was defined\");\n }\n return this._runtime;\n }\n\n private _disposed = false;\n\n public get disposed() {\n return this._disposed;\n }\n\n public get codeDetails() { return this._codeDetails; }\n\n private readonly _quorum: IQuorum;\n public get quorum(): IQuorumClients { return this._quorum; }\n\n private readonly _fluidModuleP: Promise<IFluidModuleWithDetails>;\n\n constructor(\n private readonly container: Container,\n public readonly scope: IFluidObject & FluidObject,\n private readonly codeLoader: ICodeDetailsLoader | ICodeLoader,\n private readonly _codeDetails: IFluidCodeDetails,\n private readonly _baseSnapshot: ISnapshotTree | undefined,\n public readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n quorum: IQuorum,\n public readonly loader: ILoader,\n public readonly raiseContainerWarning: (warning: ContainerWarning) => void,\n public readonly submitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number,\n public readonly submitSignalFn: (contents: any) => void,\n public readonly closeFn: (error?: ICriticalContainerError) => void,\n public readonly version: string,\n public readonly updateDirtyContainerState: (dirty: boolean) => void,\n public readonly existing: boolean,\n public readonly pendingLocalState?: unknown,\n\n ) {\n this._quorum = quorum;\n this.taggedLogger = container.subLogger;\n this._fluidModuleP = new LazyPromise<IFluidModuleWithDetails>(\n async () => this.loadCodeModule(_codeDetails),\n );\n this.attachListener();\n }\n\n /**\n * @deprecated - Temporary migratory API, to be removed when customers no longer need it. When removed,\n * ContainerContext should only take an IQuorumClients rather than an IQuorum. See IContainerContext for more\n * details.\n */\n public getSpecifiedCodeDetails(): IFluidCodeDetails | undefined {\n return (this._quorum.get(\"code\") ?? this._quorum.get(\"code2\")) as IFluidCodeDetails | undefined;\n }\n\n public dispose(error?: Error): void {\n if (this._disposed) {\n return;\n }\n this._disposed = true;\n\n this.runtime.dispose(error);\n this._quorum.dispose();\n this.deltaManager.dispose();\n }\n\n public getLoadedFromVersion(): IVersion | undefined {\n return this.container.loadedFromVersion;\n }\n\n public get attachState(): AttachState {\n return this.container.attachState;\n }\n\n /**\n * Create a summary. Used when attaching or serializing a detached container.\n *\n * @param blobRedirectTable - A table passed during the attach process. While detached, blob upload is supported\n * using IDs generated locally. After attach, these IDs cannot be used, so this table maps the old local IDs to the\n * new storage IDs so requests can be redirected.\n */\n public createSummary(blobRedirectTable?: Map<string, string>): ISummaryTree {\n return this.runtime.createSummary(blobRedirectTable);\n }\n\n public setConnectionState(connected: boolean, clientId?: string) {\n const runtime = this.runtime;\n\n assert(connected === this.connected, 0x0de /* \"Mismatch in connection state while setting\" */);\n\n runtime.setConnectionState(connected, clientId);\n }\n\n public process(message: ISequencedDocumentMessage, local: boolean, context: any) {\n this.runtime.process(message, local, context);\n }\n\n public processSignal(message: ISignalMessage, local: boolean) {\n this.runtime.processSignal(message, local);\n }\n\n public async request(path: IRequest): Promise<IResponse> {\n return this.runtime.request(path);\n }\n\n public async getAbsoluteUrl(relativeUrl: string): Promise<string | undefined> {\n return this.container.getAbsoluteUrl(relativeUrl);\n }\n\n public getPendingLocalState(): unknown {\n return this.runtime.getPendingLocalState();\n }\n\n /**\n * Determines if the current code details of the context\n * satisfy the incoming constraint code details\n */\n public async satisfies(constraintCodeDetails: IFluidCodeDetails) {\n const comparers: IFluidCodeDetailsComparer[] = [];\n\n const maybeCompareCodeLoader = this.codeLoader;\n if (maybeCompareCodeLoader.IFluidCodeDetailsComparer !== undefined) {\n comparers.push(maybeCompareCodeLoader.IFluidCodeDetailsComparer);\n }\n\n const moduleWithDetails = await this._fluidModuleP;\n const maybeCompareExport: Partial<IProvideFluidCodeDetailsComparer> | undefined =\n moduleWithDetails.module?.fluidExport;\n if (maybeCompareExport?.IFluidCodeDetailsComparer !== undefined) {\n comparers.push(maybeCompareExport.IFluidCodeDetailsComparer);\n }\n\n // if there are not comparers it is not possible to know\n // if the current satisfy the incoming, so return false,\n // as assuming they do not satisfy is safer .e.g we will\n // reload, rather than potentially running with\n // incompatible code\n if (comparers.length === 0) {\n return false;\n }\n\n for (const comparer of comparers) {\n const satisfies = await comparer.satisfies(\n moduleWithDetails.details,\n constraintCodeDetails,\n );\n if (satisfies === false) {\n return false;\n }\n }\n return true;\n }\n\n public notifyAttaching() {\n this.runtime.setAttachState(AttachState.Attaching);\n }\n\n // #region private\n\n private async getRuntimeFactory(): Promise<IRuntimeFactory> {\n const fluidExport: FluidObject<IProvideRuntimeFactory> | undefined =\n (await this._fluidModuleP).module?.fluidExport;\n const runtimeFactory = fluidExport?.IRuntimeFactory;\n if (runtimeFactory === undefined) {\n throw new Error(PackageNotFactoryError);\n }\n\n return runtimeFactory;\n }\n\n private async instantiateRuntime(existing: boolean) {\n const runtimeFactory = await this.getRuntimeFactory();\n this._runtime = await runtimeFactory.instantiateRuntime(this, existing);\n }\n\n private attachListener() {\n this.container.once(\"attached\", () => {\n this.runtime.setAttachState(AttachState.Attached);\n });\n }\n\n private async loadCodeModule(codeDetails: IFluidCodeDetails) {\n const loadCodeResult = await PerformanceEvent.timedExecAsync(\n this.taggedLogger,\n { eventName: \"CodeLoad\" },\n async () => this.codeLoader.load(codeDetails),\n );\n\n if (\"module\" in loadCodeResult) {\n const { module, details } = loadCodeResult;\n return {\n module,\n details: details ?? codeDetails,\n };\n } else {\n return { module: loadCodeResult, details: codeDetails };\n }\n }\n // #endregion\n}\n"]}
|
|
1
|
+
{"version":3,"file":"containerContext.js","sourceRoot":"","sources":["../src/containerContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,8BAA8B,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CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC5E,CAAC;IAEO,cAAc;QAClB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE;YACjC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,KAAK,CAAC,cAAc,CAAC,WAA8B;QACvD,MAAM,cAAc,GAAG,MAAM,gBAAgB,CAAC,cAAc,CACxD,IAAI,CAAC,YAAY,EACjB,EAAE,SAAS,EAAE,UAAU,EAAE,EACzB,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAChD,CAAC;QAEF,IAAI,QAAQ,IAAI,cAAc,EAAE;YAC5B,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,CAAC;YAC3C,OAAO;gBACH,MAAM;gBACN,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,WAAW;aAClC,CAAC;SACL;aAAM;YACH,wGAAwG;YACxG,wDAAwD;YACxD,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC,CAAC;YACxE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;SAC3D;IACL,CAAC;CAEJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, LazyPromise } from \"@fluidframework/common-utils\";\nimport {\n IAudience,\n IContainerContext,\n IDeltaManager,\n ILoader,\n IRuntime,\n ICriticalContainerError,\n AttachState,\n ILoaderOptions,\n IRuntimeFactory,\n IProvideRuntimeFactory,\n IFluidCodeDetails,\n IFluidCodeDetailsComparer,\n IProvideFluidCodeDetailsComparer,\n ICodeDetailsLoader,\n IFluidModuleWithDetails,\n} from \"@fluidframework/container-definitions\";\nimport {\n IRequest,\n IResponse,\n FluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { isFluidResolvedUrl } from \"@fluidframework/driver-utils\";\nimport {\n IClientConfiguration,\n IClientDetails,\n IDocumentMessage,\n IQuorum,\n IQuorumClients,\n ISequencedDocumentMessage,\n ISignalMessage,\n ISnapshotTree,\n ISummaryTree,\n IVersion,\n MessageType,\n} from \"@fluidframework/protocol-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { Container } from \"./container\";\n\nconst PackageNotFactoryError = \"Code package does not implement IRuntimeFactory\";\n\nexport class ContainerContext implements IContainerContext {\n public static async createOrLoad(\n container: Container,\n scope: FluidObject,\n codeLoader: ICodeDetailsLoader,\n codeDetails: IFluidCodeDetails,\n baseSnapshot: ISnapshotTree | undefined,\n deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n quorum: IQuorum,\n loader: ILoader,\n submitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number,\n submitSignalFn: (contents: any) => void,\n closeFn: (error?: ICriticalContainerError) => void,\n version: string,\n updateDirtyContainerState: (dirty: boolean) => void,\n existing: boolean,\n pendingLocalState?: unknown,\n ): Promise<ContainerContext> {\n const context = new ContainerContext(\n container,\n scope,\n codeLoader,\n codeDetails,\n baseSnapshot,\n deltaManager,\n quorum,\n loader,\n submitFn,\n submitSignalFn,\n closeFn,\n version,\n updateDirtyContainerState,\n existing,\n pendingLocalState);\n await context.instantiateRuntime(existing);\n return context;\n }\n\n public readonly taggedLogger: ITelemetryLogger;\n\n public get clientId(): string | undefined {\n return this.container.clientId;\n }\n\n /** @deprecated Added back to unblock 0.56 integration */\n public get id(): string {\n const resolvedUrl = this.container.resolvedUrl;\n if (isFluidResolvedUrl(resolvedUrl)) {\n return resolvedUrl.id;\n }\n return \"\";\n }\n\n public get clientDetails(): IClientDetails {\n return this.container.clientDetails;\n }\n\n public get connected(): boolean {\n return this.container.connected;\n }\n\n public get canSummarize(): boolean {\n return \"summarize\" in this.runtime;\n }\n\n public get serviceConfiguration(): IClientConfiguration | undefined {\n return this.container.serviceConfiguration;\n }\n\n public get audience(): IAudience {\n return this.container.audience;\n }\n\n public get options(): ILoaderOptions {\n return this.container.options;\n }\n\n public get baseSnapshot() {\n return this._baseSnapshot;\n }\n\n public get storage(): IDocumentStorageService {\n return this.container.storage;\n }\n\n private _runtime: IRuntime | undefined;\n private get runtime() {\n if (this._runtime === undefined) {\n throw new Error(\"Attempted to access runtime before it was defined\");\n }\n return this._runtime;\n }\n\n private _disposed = false;\n\n public get disposed() {\n return this._disposed;\n }\n\n public get codeDetails() { return this._codeDetails; }\n\n private readonly _quorum: IQuorum;\n public get quorum(): IQuorumClients { return this._quorum; }\n\n private readonly _fluidModuleP: Promise<IFluidModuleWithDetails>;\n\n constructor(\n private readonly container: Container,\n public readonly scope: FluidObject,\n private readonly codeLoader: ICodeDetailsLoader,\n private readonly _codeDetails: IFluidCodeDetails,\n private readonly _baseSnapshot: ISnapshotTree | undefined,\n public readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n quorum: IQuorum,\n public readonly loader: ILoader,\n public readonly submitFn: (type: MessageType, contents: any, batch: boolean, appData: any) => number,\n public readonly submitSignalFn: (contents: any) => void,\n public readonly closeFn: (error?: ICriticalContainerError) => void,\n public readonly version: string,\n public readonly updateDirtyContainerState: (dirty: boolean) => void,\n public readonly existing: boolean,\n public readonly pendingLocalState?: unknown,\n\n ) {\n this._quorum = quorum;\n this.taggedLogger = container.subLogger;\n this._fluidModuleP = new LazyPromise<IFluidModuleWithDetails>(\n async () => this.loadCodeModule(_codeDetails),\n );\n this.attachListener();\n }\n\n /**\n * @deprecated - Temporary migratory API, to be removed when customers no longer need it. When removed,\n * ContainerContext should only take an IQuorumClients rather than an IQuorum. See IContainerContext for more\n * details.\n */\n public getSpecifiedCodeDetails(): IFluidCodeDetails | undefined {\n return (this._quorum.get(\"code\") ?? this._quorum.get(\"code2\")) as IFluidCodeDetails | undefined;\n }\n\n public dispose(error?: Error): void {\n if (this._disposed) {\n return;\n }\n this._disposed = true;\n\n this.runtime.dispose(error);\n this._quorum.dispose();\n this.deltaManager.dispose();\n }\n\n public getLoadedFromVersion(): IVersion | undefined {\n return this.container.loadedFromVersion;\n }\n\n public get attachState(): AttachState {\n return this.container.attachState;\n }\n\n /**\n * Create a summary. Used when attaching or serializing a detached container.\n *\n * @param blobRedirectTable - A table passed during the attach process. While detached, blob upload is supported\n * using IDs generated locally. After attach, these IDs cannot be used, so this table maps the old local IDs to the\n * new storage IDs so requests can be redirected.\n */\n public createSummary(blobRedirectTable?: Map<string, string>): ISummaryTree {\n return this.runtime.createSummary(blobRedirectTable);\n }\n\n public setConnectionState(connected: boolean, clientId?: string) {\n const runtime = this.runtime;\n\n assert(connected === this.connected, 0x0de /* \"Mismatch in connection state while setting\" */);\n\n runtime.setConnectionState(connected, clientId);\n }\n\n public process(message: ISequencedDocumentMessage, local: boolean, context: any) {\n this.runtime.process(message, local, context);\n }\n\n public processSignal(message: ISignalMessage, local: boolean) {\n this.runtime.processSignal(message, local);\n }\n\n public async request(path: IRequest): Promise<IResponse> {\n return this.runtime.request(path);\n }\n\n public async getAbsoluteUrl(relativeUrl: string): Promise<string | undefined> {\n return this.container.getAbsoluteUrl(relativeUrl);\n }\n\n public getPendingLocalState(): unknown {\n return this.runtime.getPendingLocalState();\n }\n\n /**\n * Determines if the current code details of the context\n * satisfy the incoming constraint code details\n */\n public async satisfies(constraintCodeDetails: IFluidCodeDetails) {\n const comparers: IFluidCodeDetailsComparer[] = [];\n\n const maybeCompareCodeLoader = this.codeLoader;\n if (maybeCompareCodeLoader.IFluidCodeDetailsComparer !== undefined) {\n comparers.push(maybeCompareCodeLoader.IFluidCodeDetailsComparer);\n }\n\n const moduleWithDetails = await this._fluidModuleP;\n const maybeCompareExport: Partial<IProvideFluidCodeDetailsComparer> | undefined =\n moduleWithDetails.module?.fluidExport;\n if (maybeCompareExport?.IFluidCodeDetailsComparer !== undefined) {\n comparers.push(maybeCompareExport.IFluidCodeDetailsComparer);\n }\n\n // if there are not comparers it is not possible to know\n // if the current satisfy the incoming, so return false,\n // as assuming they do not satisfy is safer .e.g we will\n // reload, rather than potentially running with\n // incompatible code\n if (comparers.length === 0) {\n return false;\n }\n\n for (const comparer of comparers) {\n const satisfies = await comparer.satisfies(\n moduleWithDetails.details,\n constraintCodeDetails,\n );\n if (satisfies === false) {\n return false;\n }\n }\n return true;\n }\n\n public notifyAttaching() {\n this.runtime.setAttachState(AttachState.Attaching);\n }\n\n // #region private\n\n private async getRuntimeFactory(): Promise<IRuntimeFactory> {\n const fluidExport: FluidObject<IProvideRuntimeFactory> | undefined =\n (await this._fluidModuleP).module?.fluidExport;\n const runtimeFactory = fluidExport?.IRuntimeFactory;\n if (runtimeFactory === undefined) {\n throw new Error(PackageNotFactoryError);\n }\n\n return runtimeFactory;\n }\n\n private async instantiateRuntime(existing: boolean) {\n const runtimeFactory = await this.getRuntimeFactory();\n this._runtime = await runtimeFactory.instantiateRuntime(this, existing);\n }\n\n private attachListener() {\n this.container.once(\"attached\", () => {\n this.runtime.setAttachState(AttachState.Attached);\n });\n }\n\n private async loadCodeModule(codeDetails: IFluidCodeDetails) {\n const loadCodeResult = await PerformanceEvent.timedExecAsync(\n this.taggedLogger,\n { eventName: \"CodeLoad\" },\n async () => this.codeLoader.load(codeDetails),\n );\n\n if (\"module\" in loadCodeResult) {\n const { module, details } = loadCodeResult;\n return {\n module,\n details: details ?? codeDetails,\n };\n } else {\n // If \"module\" is not in the result, we are using a legacy ICodeLoader. Fix the result up with details.\n // Once usage drops to 0 we can remove this compat path.\n this.taggedLogger.sendTelemetryEvent({ eventName: \"LegacyCodeLoader\" });\n return { module: loadCodeResult, details: codeDetails };\n }\n }\n // #endregion\n}\n"]}
|
package/lib/contracts.d.ts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ITelemetryProperties } from "@fluidframework/common-definitions";
|
|
6
|
-
import { IDeltaQueue, ReadOnlyInfo, IConnectionDetails, ICriticalContainerError } from "@fluidframework/container-definitions";
|
|
6
|
+
import { IDeltaQueue, ReadOnlyInfo, IConnectionDetails, ICriticalContainerError, IFluidCodeDetails } from "@fluidframework/container-definitions";
|
|
7
7
|
import { ConnectionMode, IDocumentMessage, ISequencedDocumentMessage, IClientConfiguration, IClientDetails, ISignalMessage } from "@fluidframework/protocol-definitions";
|
|
8
|
+
import { IContainerPackageInfo } from "@fluidframework/driver-definitions";
|
|
8
9
|
export declare enum ReconnectMode {
|
|
9
10
|
Never = "Never",
|
|
10
11
|
Disabled = "Disabled",
|
|
@@ -109,4 +110,10 @@ export interface IConnectionManagerFactoryArgs {
|
|
|
109
110
|
*/
|
|
110
111
|
readonly readonlyChangeHandler: (readonly?: boolean) => void;
|
|
111
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
*
|
|
115
|
+
* @param codeDetails- Data structure used to describe the code to load on the Fluid document
|
|
116
|
+
* @returns The name of the Fluid package
|
|
117
|
+
*/
|
|
118
|
+
export declare const getPackageName: (codeDetails: IFluidCodeDetails | undefined) => IContainerPackageInfo;
|
|
112
119
|
//# sourceMappingURL=contracts.d.ts.map
|
package/lib/contracts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,oBAAoB,EACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACH,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAC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10 +2,29 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
import { isFluidPackage, } from "@fluidframework/container-definitions";
|
|
5
6
|
export var ReconnectMode;
|
|
6
7
|
(function (ReconnectMode) {
|
|
7
8
|
ReconnectMode["Never"] = "Never";
|
|
8
9
|
ReconnectMode["Disabled"] = "Disabled";
|
|
9
10
|
ReconnectMode["Enabled"] = "Enabled";
|
|
10
11
|
})(ReconnectMode || (ReconnectMode = {}));
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param codeDetails- Data structure used to describe the code to load on the Fluid document
|
|
15
|
+
* @returns The name of the Fluid package
|
|
16
|
+
*/
|
|
17
|
+
export const getPackageName = (codeDetails) => {
|
|
18
|
+
let containerPackageName;
|
|
19
|
+
if (codeDetails && "name" in codeDetails) {
|
|
20
|
+
containerPackageName = codeDetails;
|
|
21
|
+
}
|
|
22
|
+
else if (isFluidPackage(codeDetails === null || codeDetails === void 0 ? void 0 : codeDetails.package)) {
|
|
23
|
+
containerPackageName = codeDetails === null || codeDetails === void 0 ? void 0 : codeDetails.package.name;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
containerPackageName = codeDetails === null || codeDetails === void 0 ? void 0 : codeDetails.package;
|
|
27
|
+
}
|
|
28
|
+
return { name: containerPackageName };
|
|
29
|
+
};
|
|
11
30
|
//# sourceMappingURL=contracts.js.map
|
package/lib/contracts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAMH,cAAc,GACjB,MAAM,uCAAuC,CAAC;AAW/C,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACrB,gCAAe,CAAA;IACf,sCAAqB,CAAA;IACrB,oCAAmB,CAAA;AACvB,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAmID;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,WAA0C,EAAyB,EAAE;IAChG,IAAI,oBAAoB,CAAC;IACzB,IAAI,WAAW,IAAI,MAAM,IAAI,WAAW,EAAE;QACtC,oBAAoB,GAAG,WAAW,CAAC;KACtC;SAAM,IAAI,cAAc,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,CAAC,EAAE;QAC7C,oBAAoB,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,CAAC,IAAI,CAAC;KACpD;SAAM;QACH,oBAAoB,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,CAAC;KAC/C;IACD,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,CAAC;AAC1C,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n ITelemetryProperties,\n} from \"@fluidframework/common-definitions\";\nimport {\n IDeltaQueue,\n ReadOnlyInfo,\n IConnectionDetails,\n ICriticalContainerError,\n IFluidCodeDetails,\n isFluidPackage,\n} from \"@fluidframework/container-definitions\";\nimport {\n ConnectionMode,\n IDocumentMessage,\n ISequencedDocumentMessage,\n IClientConfiguration,\n IClientDetails,\n ISignalMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport { IContainerPackageInfo } from \"@fluidframework/driver-definitions\";\n\nexport enum ReconnectMode {\n Never = \"Never\",\n Disabled = \"Disabled\",\n Enabled = \"Enabled\",\n}\n\n/**\n * Connection manager (implements this interface) is responsible for maintaining connection\n * to relay service.\n */\nexport interface IConnectionManager {\n readonly connected: boolean;\n\n readonly clientId: string | undefined;\n\n /** The queue of outbound delta messages */\n readonly outbound: IDeltaQueue<IDocumentMessage[]>;\n\n /** Details of client */\n readonly clientDetails: IClientDetails;\n\n /** Protocol version being used to communicate with the service */\n readonly version: string;\n\n /** Max message size allowed to the delta manager */\n readonly maxMessageSize: number;\n\n /** Service configuration provided by the service. */\n readonly serviceConfiguration: IClientConfiguration | undefined;\n\n readonly readOnlyInfo: ReadOnlyInfo;\n\n // Various connectivity propetries for telemetry describing type of current connection\n // Things like connection mode, service info, etc.\n // Called when connection state changes (connect / disconnect)\n readonly connectionProps: ITelemetryProperties;\n\n // Verbose information about connection logged to telemetry in case of issues with\n // maintaining healphy connection, including op gaps, not receiving join op in time, etc.\n // Contains details information, like sequence numbers at connection time, initial ops info, etc.\n readonly connectionVerboseProps: ITelemetryProperties;\n\n /**\n * Prepares message to be sent. Fills in clientSequenceNumber.\n * Called only when active connection is present.\n */\n prepareMessageToSend(message: Omit<IDocumentMessage, \"clientSequenceNumber\">): IDocumentMessage | undefined;\n\n /**\n * Called before incomming message is processed. Incomming messages can be comming from connection,\n * but also could come from storage.\n * This call allows connection manager to adjust knowledge about acked ops sent on previous connection.\n * Can be called at any time, including when there is no active connection.\n */\n beforeProcessingIncomingOp(message: ISequencedDocumentMessage): void;\n\n /**\n * Submits signal to relay service.\n * Called only when active connection is present.\n */\n submitSignal(content: any): void;\n\n /**\n * Submits messages to relay service.\n * Called only when active connection is present.\n */\n sendMessages(messages: IDocumentMessage[]): void;\n\n /**\n * Initiates connection to relay service (noop if already connected).\n */\n connect(connectionMode?: ConnectionMode): void;\n\n /**\n * Disposed connection manager\n */\n dispose(error?: ICriticalContainerError): void;\n}\n\n/**\n * This interface represents a set of callbacks provided by DeltaManager to IConnectionManager on its creation\n * IConnectionManager instance will use them to communicate to DeltaManager abour various events.\n */\nexport interface IConnectionManagerFactoryArgs {\n /**\n * Called by connection manager for each incomming op. Some ops maybe delivered before\n * connectHandler is called (initial ops on socket connection)\n */\n readonly incomingOpHandler: (messages: ISequencedDocumentMessage[], reason: string) => void,\n\n /**\n * Called by connection manager for each incoming signals.\n * Maybe called before connectHandler is called (initial signals on socket connection)\n */\n readonly signalHandler: (message: ISignalMessage) => void,\n\n /**\n * Called when connection manager experiences delay in connecting to relay service.\n * This can happen because client is offline, or service is busy and asks to not connect for some time.\n * Can be called many times while not connected.\n * Situation is considered resolved when connection is established and connectHandler is called.\n */\n readonly reconnectionDelayHandler: (delayMs: number, error: unknown) => void,\n\n /**\n * Called by connection manager whwnever critical error happens and container should be closed.\n * Expects dispose() call in respose to this call.\n */\n readonly closeHandler: (error?: any) => void,\n\n /**\n * Called whenever connection to relay service is lost.\n */\n readonly disconnectHandler: (reason: string) => void,\n\n /**\n * Called whenever new connection to rely service is established\n */\n readonly connectHandler: (connection: IConnectionDetails) => void,\n\n /**\n * Called whenever ping/pong messages are roundtripped on connection.\n */\n readonly pongHandler: (latency: number) => void,\n\n /**\n * Called whenever connection type changes from writable to read-only or vice versa.\n * Connection can be read-only if user has no edit permissions, or if container forced\n * connection to be read-only.\n * This should not be confused with \"read\" / \"write\"connection mode which is internal\n * optimization.\n */\n readonly readonlyChangeHandler: (readonly?: boolean) => void,\n}\n\n/**\n *\n * @param codeDetails- Data structure used to describe the code to load on the Fluid document\n * @returns The name of the Fluid package\n */\nexport const getPackageName = (codeDetails: IFluidCodeDetails | undefined): IContainerPackageInfo => {\n let containerPackageName;\n if (codeDetails && \"name\" in codeDetails) {\n containerPackageName = codeDetails;\n } else if (isFluidPackage(codeDetails?.package)) {\n containerPackageName = codeDetails?.package.name;\n } else {\n containerPackageName = codeDetails?.package;\n }\n return { name: containerPackageName };\n};\n"]}
|
package/lib/loader.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ITelemetryBaseLogger, ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
6
|
-
import { FluidObject,
|
|
7
|
-
import {
|
|
6
|
+
import { FluidObject, IFluidRouter, IRequest, IResponse } from "@fluidframework/core-interfaces";
|
|
7
|
+
import { IContainer, IFluidModule, IHostLoader, ILoader, ILoaderOptions as ILoaderOptions1, IProxyLoaderFactory, IProvideFluidCodeDetailsComparer, IFluidCodeDetails } from "@fluidframework/container-definitions";
|
|
8
8
|
import { IConfigProviderBase } from "@fluidframework/telemetry-utils";
|
|
9
9
|
import { IDocumentServiceFactory, IDocumentStorageService, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
10
10
|
import { Container } from "./container";
|
|
@@ -70,7 +70,7 @@ export interface ILoaderProps {
|
|
|
70
70
|
* The code loader handles loading the necessary code
|
|
71
71
|
* for running a container once it is loaded.
|
|
72
72
|
*/
|
|
73
|
-
readonly codeLoader: ICodeDetailsLoader
|
|
73
|
+
readonly codeLoader: ICodeDetailsLoader;
|
|
74
74
|
/**
|
|
75
75
|
* A property bag of options used by various layers
|
|
76
76
|
* to control features
|
|
@@ -119,7 +119,7 @@ export interface ILoaderServices {
|
|
|
119
119
|
* The code loader handles loading the necessary code
|
|
120
120
|
* for running a container once it is loaded.
|
|
121
121
|
*/
|
|
122
|
-
readonly codeLoader: ICodeDetailsLoader
|
|
122
|
+
readonly codeLoader: ICodeDetailsLoader;
|
|
123
123
|
/**
|
|
124
124
|
* A property bag of options used by various layers
|
|
125
125
|
* to control features
|
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,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC5F,OAAO,EACH,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC5F,OAAO,EACH,WAAW,EACX,YAAY,EACZ,QAAQ,EAER,SAAS,EACZ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ed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n FluidObject,\n IFluidCodeDetails,\n IFluidRouter,\n IProvideFluidCodeDetailsComparer,\n IRequest,\n IRequestHeader,\n IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport {\n ICodeLoader,\n IContainer,\n IFluidModule,\n IHostLoader,\n ILoader,\n IPendingLocalState,\n ILoaderOptions as ILoaderOptions1,\n IProxyLoaderFactory,\n LoaderHeader,\n} from \"@fluidframework/container-definitions\";\nimport {\n ChildLogger,\n DebugLogger,\n IConfigProviderBase,\n loggerToMonitoringContext,\n mixinMonitoringContext,\n MonitoringContext,\n PerformanceEvent,\n sessionStorageConfigProvider,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n IDocumentServiceFactory,\n IDocumentStorageService,\n IFluidResolvedUrl,\n IResolvedUrl,\n IUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n ensureFluidResolvedUrl,\n MultiUrlResolver,\n MultiDocumentServiceFactory,\n} from \"@fluidframework/driver-utils\";\nimport { Container } from \"./container\";\nimport { IParsedUrl, parseUrl } from \"./utils\";\nimport { pkgVersion } from \"./packageVersion\";\n\nfunction canUseCache(request: IRequest): boolean {\n if (request.headers === undefined) {\n return true;\n }\n\n return request.headers[LoaderHeader.cache] !== false;\n}\n\nexport class RelativeLoader implements ILoader {\n constructor(\n private readonly container: Container,\n private readonly loader: ILoader | undefined,\n ) {\n }\n\n public get IFluidRouter(): IFluidRouter { return this; }\n\n public async resolve(request: IRequest): Promise<IContainer> {\n if (request.url.startsWith(\"/\")) {\n if (canUseCache(request)) {\n return this.container;\n } else {\n const resolvedUrl = this.container.resolvedUrl;\n ensureFluidResolvedUrl(resolvedUrl);\n const container = await Container.load(\n this.loader as Loader,\n {\n canReconnect: request.headers?.[LoaderHeader.reconnect],\n clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n resolvedUrl: {...resolvedUrl},\n version: request.headers?.[LoaderHeader.version] ?? undefined,\n loadMode: request.headers?.[LoaderHeader.loadMode],\n },\n );\n return container;\n }\n }\n\n if (this.loader === undefined) {\n throw new Error(\"Cannot resolve external containers\");\n }\n return this.loader.resolve(request);\n }\n\n public async request(request: IRequest): Promise<IResponse> {\n if (request.url.startsWith(\"/\")) {\n const container = await this.resolve(request);\n return container.request(request);\n }\n\n if (this.loader === undefined) {\n return {\n status: 404,\n value: \"Cannot request external containers\",\n mimeType: \"plain/text\",\n };\n }\n return this.loader.request(request);\n }\n}\n\nfunction createCachedResolver(resolver: IUrlResolver) {\n const cacheResolver = Object.create(resolver) as IUrlResolver;\n const resolveCache = new Map<string, Promise<IResolvedUrl | undefined>>();\n cacheResolver.resolve = async (request: IRequest): Promise<IResolvedUrl | undefined> => {\n if (!canUseCache(request)) {\n return resolver.resolve(request);\n }\n if (!resolveCache.has(request.url)) {\n resolveCache.set(request.url, resolver.resolve(request));\n }\n\n return resolveCache.get(request.url);\n };\n return cacheResolver;\n}\n\nexport interface ILoaderOptions extends ILoaderOptions1{\n summarizeProtocolTree?: boolean,\n}\n\n/**\n * @deprecated IFluidModuleWithDetails interface is moved to\n * {@link @fluidframework/container-definition#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 /** Fluid code module that implements the runtime factory needed to instantiate the container runtime. */\n module: IFluidModule;\n /**\n * Code details associated with the module. Represents a document schema this module supports.\n * If the code loader implements the {@link @fluidframework/core-interfaces#IFluidCodeDetailsComparer} interface,\n * it'll be called to determine whether the module code details satisfy the new code proposal in the quorum.\n */\n details: 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\n extends Partial<IProvideFluidCodeDetailsComparer> {\n /**\n * Load the code module (package) that is capable to interact with the document.\n *\n * @param source - Code proposal that articulates the current schema the document is written in.\n * @returns - Code module entry point along with the code details associated with it.\n */\n load(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;\n}\n\n/**\n * Services and properties necessary for creating a loader\n */\nexport interface ILoaderProps {\n /**\n * The url resolver used by the loader for resolving external urls\n * into Fluid urls such that the container specified by the\n * external url can be loaded.\n */\n readonly urlResolver: IUrlResolver;\n /**\n * The document service factory take the Fluid url provided\n * by the resolved url and constructs all the necessary services\n * for communication with the container's server.\n */\n readonly documentServiceFactory: IDocumentServiceFactory;\n /**\n * The code loader handles loading the necessary code\n * for running a container once it is loaded.\n */\n readonly codeLoader: ICodeDetailsLoader | ICodeLoader;\n\n /**\n * A property bag of options used by various layers\n * to control features\n */\n readonly options?: ILoaderOptions;\n\n /**\n * Scope is provided to all container and is a set of shared\n * services for container's to integrate with their host environment.\n */\n readonly scope?: FluidObject;\n\n /**\n * Proxy loader factories for loading containers via proxy in other contexts,\n * like web workers, or worker threads.\n */\n readonly proxyLoaderFactories?: Map<string, IProxyLoaderFactory>;\n\n /**\n * The logger that all telemetry should be pushed to.\n */\n readonly logger?: ITelemetryBaseLogger;\n\n /**\n * Blobs storage for detached containers.\n */\n readonly detachedBlobStorage?: IDetachedBlobStorage;\n\n /**\n * The configuration provider which may be used to control features.\n */\n readonly configProvider?: IConfigProviderBase;\n}\n\n/**\n * Services and properties used by and exposed by the loader\n */\nexport interface ILoaderServices {\n /**\n * The url resolver used by the loader for resolving external urls\n * into Fluid urls such that the container specified by the\n * external url can be loaded.\n */\n readonly urlResolver: IUrlResolver;\n /**\n * The document service factory take the Fluid url provided\n * by the resolved url and constructs all the necessary services\n * for communication with the container's server.\n */\n readonly documentServiceFactory: IDocumentServiceFactory;\n /**\n * The code loader handles loading the necessary code\n * for running a container once it is loaded.\n */\n readonly codeLoader: ICodeDetailsLoader | ICodeLoader;\n\n /**\n * A property bag of options used by various layers\n * to control features\n */\n readonly options: ILoaderOptions;\n\n /**\n * Scope is provided to all container and is a set of shared\n * services for container's to integrate with their host environment.\n */\n readonly scope: FluidObject;\n\n /**\n * Proxy loader factories for loading containers via proxy in other contexts,\n * like web workers, or worker threads.\n */\n readonly proxyLoaderFactories: Map<string, IProxyLoaderFactory>;\n\n /**\n * The logger downstream consumers should construct their loggers from\n */\n readonly subLogger: ITelemetryLogger;\n\n /**\n * Blobs storage for detached containers.\n */\n readonly detachedBlobStorage?: IDetachedBlobStorage;\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 size: number;\n /**\n * Return an array of all blob IDs present in storage\n */\n getBlobIds(): string[];\n };\n\n/**\n * Manages Fluid resource loading\n */\nexport class Loader implements IHostLoader {\n private readonly containers = new Map<string, Promise<Container>>();\n public readonly services: ILoaderServices;\n private readonly mc: MonitoringContext;\n\n constructor(loaderProps: ILoaderProps) {\n const scope = { ...loaderProps.scope as FluidObject<ILoader> };\n if (loaderProps.options?.provideScopeLoader !== false) {\n scope.ILoader = this;\n }\n const telemetryProps = {\n loaderId: uuid(),\n loaderVersion: pkgVersion,\n };\n\n const subMc = mixinMonitoringContext(\n DebugLogger.mixinDebugLogger(\"fluid:telemetry\", loaderProps.logger, { all: telemetryProps }),\n sessionStorageConfigProvider.value,\n loaderProps.configProvider,\n );\n\n this.services = {\n urlResolver: createCachedResolver(MultiUrlResolver.create(loaderProps.urlResolver)),\n documentServiceFactory: MultiDocumentServiceFactory.create(loaderProps.documentServiceFactory),\n codeLoader: loaderProps.codeLoader,\n options: loaderProps.options ?? {},\n scope,\n subLogger: subMc.logger,\n proxyLoaderFactories: loaderProps.proxyLoaderFactories ?? new Map<string, IProxyLoaderFactory>(),\n detachedBlobStorage: loaderProps.detachedBlobStorage,\n };\n this.mc = loggerToMonitoringContext(\n ChildLogger.create(this.services.subLogger, \"Loader\"));\n }\n\n public get IFluidRouter(): IFluidRouter { return this; }\n\n public async createDetachedContainer(codeDetails: IFluidCodeDetails): Promise<IContainer> {\n const container = await Container.createDetached(\n this,\n codeDetails,\n );\n\n if (this.cachingEnabled) {\n container.once(\"attached\", () => {\n ensureFluidResolvedUrl(container.resolvedUrl);\n const parsedUrl = parseUrl(container.resolvedUrl.url);\n if (parsedUrl !== undefined) {\n this.addToContainerCache(parsedUrl.id, Promise.resolve(container));\n }\n });\n }\n\n return container;\n }\n\n public async rehydrateDetachedContainerFromSnapshot(snapshot: string): Promise<IContainer> {\n return Container.rehydrateDetachedFromSnapshot(this, snapshot);\n }\n\n public async resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer> {\n const eventName = pendingLocalState === undefined ? \"Resolve\" : \"ResolveWithPendingState\";\n return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName }, async () => {\n const resolved = await this.resolveCore(\n request,\n pendingLocalState !== undefined ? JSON.parse(pendingLocalState) : undefined,\n );\n return resolved.container;\n });\n }\n\n public async request(request: IRequest): Promise<IResponse> {\n return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: \"Request\" }, async () => {\n const resolved = await this.resolveCore(request);\n return resolved.container.request({\n ...request,\n url: `${resolved.parsed.path}${resolved.parsed.query}`,\n });\n });\n }\n\n private getKeyForContainerCache(request: IRequest, parsedUrl: IParsedUrl): string {\n const key = request.headers?.[LoaderHeader.version] !== undefined\n ? `${parsedUrl.id}@${request.headers[LoaderHeader.version]}`\n : parsedUrl.id;\n return key;\n }\n\n private addToContainerCache(key: string, containerP: Promise<Container>) {\n this.containers.set(key, containerP);\n containerP.then((container) => {\n // If the container is closed or becomes closed after we resolve it, remove it from the cache.\n if (container.closed) {\n this.containers.delete(key);\n } else {\n container.once(\"closed\", () => {\n this.containers.delete(key);\n });\n }\n }).catch((error) => {});\n }\n\n private async resolveCore(\n request: IRequest,\n pendingLocalState?: IPendingLocalState,\n ): Promise<{ container: Container; parsed: IParsedUrl }> {\n const resolvedAsFluid = await this.services.urlResolver.resolve(request);\n ensureFluidResolvedUrl(resolvedAsFluid);\n\n // Parse URL into data stores\n const parsed = parseUrl(resolvedAsFluid.url);\n if (parsed === undefined) {\n throw new Error(`Invalid URL ${resolvedAsFluid.url}`);\n }\n\n if (pendingLocalState !== undefined) {\n const parsedPendingUrl = parseUrl(pendingLocalState.url);\n if (parsedPendingUrl?.id !== parsed.id ||\n parsedPendingUrl?.path.replace(/\\/$/, \"\") !== parsed.path.replace(/\\/$/, \"\")) {\n const message = `URL ${resolvedAsFluid.url} does not match pending state URL ${pendingLocalState.url}`;\n throw new Error(message);\n }\n }\n\n const { canCache, fromSequenceNumber } = this.parseHeader(parsed, request);\n const shouldCache = pendingLocalState !== undefined ? false : canCache;\n\n let container: Container;\n if (shouldCache) {\n const key = this.getKeyForContainerCache(request, parsed);\n const maybeContainer = await this.containers.get(key);\n if (maybeContainer !== undefined) {\n container = maybeContainer;\n } else {\n const containerP =\n this.loadContainer(\n request,\n resolvedAsFluid);\n this.addToContainerCache(key, containerP);\n container = await containerP;\n }\n } else {\n container =\n await this.loadContainer(\n request,\n resolvedAsFluid,\n pendingLocalState?.pendingRuntimeState);\n }\n\n if (container.deltaManager.lastSequenceNumber <= fromSequenceNumber) {\n await new Promise<void>((resolve, reject) => {\n function opHandler(message: ISequencedDocumentMessage) {\n if (message.sequenceNumber > fromSequenceNumber) {\n resolve();\n container.removeListener(\"op\", opHandler);\n }\n }\n\n container.on(\"op\", opHandler);\n });\n }\n\n return { container, parsed };\n }\n\n private get cachingEnabled() {\n return this.services.options.cache !== false;\n }\n\n private canCacheForRequest(headers: IRequestHeader): boolean {\n return this.cachingEnabled && headers[LoaderHeader.cache] !== false;\n }\n\n private parseHeader(parsed: IParsedUrl, request: IRequest) {\n let fromSequenceNumber = -1;\n\n request.headers = request.headers ?? {};\n\n const headerSeqNum = request.headers[LoaderHeader.sequenceNumber];\n if (headerSeqNum !== undefined) {\n fromSequenceNumber = headerSeqNum;\n }\n\n // If set in both query string and headers, use query string\n request.headers[LoaderHeader.version] = parsed.version ?? request.headers[LoaderHeader.version];\n\n const canCache = this.canCacheForRequest(request.headers);\n\n return {\n canCache,\n fromSequenceNumber,\n };\n }\n\n private async loadContainer(\n request: IRequest,\n resolved: IFluidResolvedUrl,\n pendingLocalState?: unknown,\n ): Promise<Container> {\n return Container.load(\n this,\n {\n canReconnect: request.headers?.[LoaderHeader.reconnect],\n clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n resolvedUrl: resolved,\n version: request.headers?.[LoaderHeader.version] ?? undefined,\n loadMode: request.headers?.[LoaderHeader.loadMode],\n },\n pendingLocalState,\n );\n }\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;AASlC,OAAO,EAQH,YAAY,GAGf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACH,WAAW,EACX,WAAW,EAEX,yBAAyB,EACzB,sBAAsB,EAEtB,gBAAgB,EAChB,4BAA4B,GAC/B,MAAM,iCAAiC,CAAC;AASzC,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EAChB,2BAA2B,GAC9B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAc,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,SAAS,WAAW,CAAC,OAAiB;IAClC,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE;QAC/B,OAAO,IAAI,CAAC;KACf;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC;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YAAY,CAAC,cAAc,CAAC,CAAC;QAClE,IAAI,YAAY,KAAK,SAAS,EAAE;YAC5B,kBAAkB,GAAG,YAAY,CAAC;SACrC;QAED,4DAA4D;QAC5D,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,SAAG,MAAM,CAAC,OAAO,mCAAI,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAEhG,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAE1D,OAAO;YACH,QAAQ;YACR,kBAAkB;SACrB,CAAC;IACN,CAAC;IAEO,KAAK,CAAC,aAAa,CACvB,OAAiB,EACjB,QAA2B,EAC3B,iBAA2B;;QAE3B,OAAO,SAAS,CAAC,IAAI,CACjB,IAAI,EACJ;YACI,YAAY,QAAE,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,SAAS,CAAC;YACvD,qBAAqB,QAAE,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,aAAa,CAAC;YACpE,WAAW,EAAE,QAAQ;YACrB,OAAO,cAAE,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,OAAO,oCAAK,SAAS;YAC7D,QAAQ,QAAE,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,QAAQ,CAAC;SACrD,EACD,iBAAiB,CACpB,CAAC;IACN,CAAC;CACJ","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 { ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n FluidObject,\n IFluidRouter,\n IRequest,\n IRequestHeader,\n IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport {\n IContainer,\n IFluidModule,\n IHostLoader,\n ILoader,\n IPendingLocalState,\n ILoaderOptions as ILoaderOptions1,\n IProxyLoaderFactory,\n LoaderHeader,\n IProvideFluidCodeDetailsComparer,\n IFluidCodeDetails,\n} from \"@fluidframework/container-definitions\";\nimport {\n ChildLogger,\n DebugLogger,\n IConfigProviderBase,\n loggerToMonitoringContext,\n mixinMonitoringContext,\n MonitoringContext,\n PerformanceEvent,\n sessionStorageConfigProvider,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n IDocumentServiceFactory,\n IDocumentStorageService,\n IFluidResolvedUrl,\n IResolvedUrl,\n IUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n ensureFluidResolvedUrl,\n MultiUrlResolver,\n MultiDocumentServiceFactory,\n} from \"@fluidframework/driver-utils\";\nimport { Container } from \"./container\";\nimport { IParsedUrl, parseUrl } from \"./utils\";\nimport { pkgVersion } from \"./packageVersion\";\n\nfunction canUseCache(request: IRequest): boolean {\n if (request.headers === undefined) {\n return true;\n }\n\n return request.headers[LoaderHeader.cache] !== false;\n}\n\nexport class RelativeLoader implements ILoader {\n constructor(\n private readonly container: Container,\n private readonly loader: ILoader | undefined,\n ) {\n }\n\n public get IFluidRouter(): IFluidRouter { return this; }\n\n public async resolve(request: IRequest): Promise<IContainer> {\n if (request.url.startsWith(\"/\")) {\n if (canUseCache(request)) {\n return this.container;\n } else {\n const resolvedUrl = this.container.resolvedUrl;\n ensureFluidResolvedUrl(resolvedUrl);\n const container = await Container.load(\n this.loader as Loader,\n {\n canReconnect: request.headers?.[LoaderHeader.reconnect],\n clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n resolvedUrl: {...resolvedUrl},\n version: request.headers?.[LoaderHeader.version] ?? undefined,\n loadMode: request.headers?.[LoaderHeader.loadMode],\n },\n );\n return container;\n }\n }\n\n if (this.loader === undefined) {\n throw new Error(\"Cannot resolve external containers\");\n }\n return this.loader.resolve(request);\n }\n\n public async request(request: IRequest): Promise<IResponse> {\n if (request.url.startsWith(\"/\")) {\n const container = await this.resolve(request);\n return container.request(request);\n }\n\n if (this.loader === undefined) {\n return {\n status: 404,\n value: \"Cannot request external containers\",\n mimeType: \"plain/text\",\n };\n }\n return this.loader.request(request);\n }\n}\n\nfunction createCachedResolver(resolver: IUrlResolver) {\n const cacheResolver = Object.create(resolver) as IUrlResolver;\n const resolveCache = new Map<string, Promise<IResolvedUrl | undefined>>();\n cacheResolver.resolve = async (request: IRequest): Promise<IResolvedUrl | undefined> => {\n if (!canUseCache(request)) {\n return resolver.resolve(request);\n }\n if (!resolveCache.has(request.url)) {\n resolveCache.set(request.url, resolver.resolve(request));\n }\n\n return resolveCache.get(request.url);\n };\n return cacheResolver;\n}\n\nexport interface ILoaderOptions extends ILoaderOptions1{\n summarizeProtocolTree?: boolean,\n}\n\n/**\n * @deprecated IFluidModuleWithDetails interface is moved to\n * {@link @fluidframework/container-definition#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 /** Fluid code module that implements the runtime factory needed to instantiate the container runtime. */\n module: IFluidModule;\n /**\n * Code details associated with the module. Represents a document schema this module supports.\n * If the code loader implements the {@link @fluidframework/core-interfaces#IFluidCodeDetailsComparer} interface,\n * it'll be called to determine whether the module code details satisfy the new code proposal in the quorum.\n */\n details: 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\n extends Partial<IProvideFluidCodeDetailsComparer> {\n /**\n * Load the code module (package) that is capable to interact with the document.\n *\n * @param source - Code proposal that articulates the current schema the document is written in.\n * @returns - Code module entry point along with the code details associated with it.\n */\n load(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;\n}\n\n/**\n * Services and properties necessary for creating a loader\n */\nexport interface ILoaderProps {\n /**\n * The url resolver used by the loader for resolving external urls\n * into Fluid urls such that the container specified by the\n * external url can be loaded.\n */\n readonly urlResolver: IUrlResolver;\n /**\n * The document service factory take the Fluid url provided\n * by the resolved url and constructs all the necessary services\n * for communication with the container's server.\n */\n readonly documentServiceFactory: IDocumentServiceFactory;\n /**\n * The code loader handles loading the necessary code\n * for running a container once it is loaded.\n */\n readonly codeLoader: ICodeDetailsLoader;\n\n /**\n * A property bag of options used by various layers\n * to control features\n */\n readonly options?: ILoaderOptions;\n\n /**\n * Scope is provided to all container and is a set of shared\n * services for container's to integrate with their host environment.\n */\n readonly scope?: FluidObject;\n\n /**\n * Proxy loader factories for loading containers via proxy in other contexts,\n * like web workers, or worker threads.\n */\n readonly proxyLoaderFactories?: Map<string, IProxyLoaderFactory>;\n\n /**\n * The logger that all telemetry should be pushed to.\n */\n readonly logger?: ITelemetryBaseLogger;\n\n /**\n * Blobs storage for detached containers.\n */\n readonly detachedBlobStorage?: IDetachedBlobStorage;\n\n /**\n * The configuration provider which may be used to control features.\n */\n readonly configProvider?: IConfigProviderBase;\n}\n\n/**\n * Services and properties used by and exposed by the loader\n */\nexport interface ILoaderServices {\n /**\n * The url resolver used by the loader for resolving external urls\n * into Fluid urls such that the container specified by the\n * external url can be loaded.\n */\n readonly urlResolver: IUrlResolver;\n /**\n * The document service factory take the Fluid url provided\n * by the resolved url and constructs all the necessary services\n * for communication with the container's server.\n */\n readonly documentServiceFactory: IDocumentServiceFactory;\n /**\n * The code loader handles loading the necessary code\n * for running a container once it is loaded.\n */\n readonly codeLoader: ICodeDetailsLoader;\n\n /**\n * A property bag of options used by various layers\n * to control features\n */\n readonly options: ILoaderOptions;\n\n /**\n * Scope is provided to all container and is a set of shared\n * services for container's to integrate with their host environment.\n */\n readonly scope: FluidObject;\n\n /**\n * Proxy loader factories for loading containers via proxy in other contexts,\n * like web workers, or worker threads.\n */\n readonly proxyLoaderFactories: Map<string, IProxyLoaderFactory>;\n\n /**\n * The logger downstream consumers should construct their loggers from\n */\n readonly subLogger: ITelemetryLogger;\n\n /**\n * Blobs storage for detached containers.\n */\n readonly detachedBlobStorage?: IDetachedBlobStorage;\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 size: number;\n /**\n * Return an array of all blob IDs present in storage\n */\n getBlobIds(): string[];\n };\n\n/**\n * Manages Fluid resource loading\n */\nexport class Loader implements IHostLoader {\n private readonly containers = new Map<string, Promise<Container>>();\n public readonly services: ILoaderServices;\n private readonly mc: MonitoringContext;\n\n constructor(loaderProps: ILoaderProps) {\n const scope: FluidObject<ILoader> = { ...loaderProps.scope };\n if (loaderProps.options?.provideScopeLoader !== false) {\n scope.ILoader = this;\n }\n const telemetryProps = {\n loaderId: uuid(),\n loaderVersion: pkgVersion,\n };\n\n const subMc = mixinMonitoringContext(\n DebugLogger.mixinDebugLogger(\"fluid:telemetry\", loaderProps.logger, { all: telemetryProps }),\n sessionStorageConfigProvider.value,\n loaderProps.configProvider,\n );\n\n this.services = {\n urlResolver: createCachedResolver(MultiUrlResolver.create(loaderProps.urlResolver)),\n documentServiceFactory: MultiDocumentServiceFactory.create(loaderProps.documentServiceFactory),\n codeLoader: loaderProps.codeLoader,\n options: loaderProps.options ?? {},\n scope,\n subLogger: subMc.logger,\n proxyLoaderFactories: loaderProps.proxyLoaderFactories ?? new Map<string, IProxyLoaderFactory>(),\n detachedBlobStorage: loaderProps.detachedBlobStorage,\n };\n this.mc = loggerToMonitoringContext(\n ChildLogger.create(this.services.subLogger, \"Loader\"));\n }\n\n public get IFluidRouter(): IFluidRouter { return this; }\n\n public async createDetachedContainer(codeDetails: IFluidCodeDetails): Promise<IContainer> {\n const container = await Container.createDetached(\n this,\n codeDetails,\n );\n\n if (this.cachingEnabled) {\n container.once(\"attached\", () => {\n ensureFluidResolvedUrl(container.resolvedUrl);\n const parsedUrl = parseUrl(container.resolvedUrl.url);\n if (parsedUrl !== undefined) {\n this.addToContainerCache(parsedUrl.id, Promise.resolve(container));\n }\n });\n }\n\n return container;\n }\n\n public async rehydrateDetachedContainerFromSnapshot(snapshot: string): Promise<IContainer> {\n return Container.rehydrateDetachedFromSnapshot(this, snapshot);\n }\n\n public async resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer> {\n const eventName = pendingLocalState === undefined ? \"Resolve\" : \"ResolveWithPendingState\";\n return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName }, async () => {\n const resolved = await this.resolveCore(\n request,\n pendingLocalState !== undefined ? JSON.parse(pendingLocalState) : undefined,\n );\n return resolved.container;\n });\n }\n\n public async request(request: IRequest): Promise<IResponse> {\n return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: \"Request\" }, async () => {\n const resolved = await this.resolveCore(request);\n return resolved.container.request({\n ...request,\n url: `${resolved.parsed.path}${resolved.parsed.query}`,\n });\n });\n }\n\n private getKeyForContainerCache(request: IRequest, parsedUrl: IParsedUrl): string {\n const key = request.headers?.[LoaderHeader.version] !== undefined\n ? `${parsedUrl.id}@${request.headers[LoaderHeader.version]}`\n : parsedUrl.id;\n return key;\n }\n\n private addToContainerCache(key: string, containerP: Promise<Container>) {\n this.containers.set(key, containerP);\n containerP.then((container) => {\n // If the container is closed or becomes closed after we resolve it, remove it from the cache.\n if (container.closed) {\n this.containers.delete(key);\n } else {\n container.once(\"closed\", () => {\n this.containers.delete(key);\n });\n }\n }).catch((error) => {});\n }\n\n private async resolveCore(\n request: IRequest,\n pendingLocalState?: IPendingLocalState,\n ): Promise<{ container: Container; parsed: IParsedUrl }> {\n const resolvedAsFluid = await this.services.urlResolver.resolve(request);\n ensureFluidResolvedUrl(resolvedAsFluid);\n\n // Parse URL into data stores\n const parsed = parseUrl(resolvedAsFluid.url);\n if (parsed === undefined) {\n throw new Error(`Invalid URL ${resolvedAsFluid.url}`);\n }\n\n if (pendingLocalState !== undefined) {\n const parsedPendingUrl = parseUrl(pendingLocalState.url);\n if (parsedPendingUrl?.id !== parsed.id ||\n parsedPendingUrl?.path.replace(/\\/$/, \"\") !== parsed.path.replace(/\\/$/, \"\")) {\n const message = `URL ${resolvedAsFluid.url} does not match pending state URL ${pendingLocalState.url}`;\n throw new Error(message);\n }\n }\n\n const { canCache, fromSequenceNumber } = this.parseHeader(parsed, request);\n const shouldCache = pendingLocalState !== undefined ? false : canCache;\n\n let container: Container;\n if (shouldCache) {\n const key = this.getKeyForContainerCache(request, parsed);\n const maybeContainer = await this.containers.get(key);\n if (maybeContainer !== undefined) {\n container = maybeContainer;\n } else {\n const containerP =\n this.loadContainer(\n request,\n resolvedAsFluid);\n this.addToContainerCache(key, containerP);\n container = await containerP;\n }\n } else {\n container =\n await this.loadContainer(\n request,\n resolvedAsFluid,\n pendingLocalState?.pendingRuntimeState);\n }\n\n if (container.deltaManager.lastSequenceNumber <= fromSequenceNumber) {\n await new Promise<void>((resolve, reject) => {\n function opHandler(message: ISequencedDocumentMessage) {\n if (message.sequenceNumber > fromSequenceNumber) {\n resolve();\n container.removeListener(\"op\", opHandler);\n }\n }\n\n container.on(\"op\", opHandler);\n });\n }\n\n return { container, parsed };\n }\n\n private get cachingEnabled() {\n return this.services.options.cache !== false;\n }\n\n private canCacheForRequest(headers: IRequestHeader): boolean {\n return this.cachingEnabled && headers[LoaderHeader.cache] !== false;\n }\n\n private parseHeader(parsed: IParsedUrl, request: IRequest) {\n let fromSequenceNumber = -1;\n\n request.headers = request.headers ?? {};\n\n const headerSeqNum = request.headers[LoaderHeader.sequenceNumber];\n if (headerSeqNum !== undefined) {\n fromSequenceNumber = headerSeqNum;\n }\n\n // If set in both query string and headers, use query string\n request.headers[LoaderHeader.version] = parsed.version ?? request.headers[LoaderHeader.version];\n\n const canCache = this.canCacheForRequest(request.headers);\n\n return {\n canCache,\n fromSequenceNumber,\n };\n }\n\n private async loadContainer(\n request: IRequest,\n resolved: IFluidResolvedUrl,\n pendingLocalState?: unknown,\n ): Promise<Container> {\n return Container.load(\n this,\n {\n canReconnect: request.headers?.[LoaderHeader.reconnect],\n clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n resolvedUrl: resolved,\n version: request.headers?.[LoaderHeader.version] ?? undefined,\n loadMode: request.headers?.[LoaderHeader.loadMode],\n },\n pendingLocalState,\n );\n }\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 = "0.
|
|
8
|
+
export declare const pkgVersion = "0.59.1001-62246";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -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,iBAAiB,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 = \"0.
|
|
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,iBAAiB,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 = \"0.59.1001-62246\";\n"]}
|
package/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAe,MAAM,sCAAsC,CAAC;AAIhG,MAAM,WAAW,6BAA8B,SAAQ,aAAa;IAChE,aAAa,EAAE;QAAC,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAA;KAAC,CAAC;IACjD,KAAK,EAAE;QAAC,CAAC,IAAI,EAAE,MAAM,GAAG,6BAA6B,CAAA;KAAC,CAAC;CAC1D;AAED,MAAM,WAAW,UAAU;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACtC;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAW5D;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAe,MAAM,sCAAsC,CAAC;AAIhG,MAAM,WAAW,6BAA8B,SAAQ,aAAa;IAChE,aAAa,EAAE;QAAC,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAA;KAAC,CAAC;IACjD,KAAK,EAAE;QAAC,CAAC,IAAI,EAAE,MAAM,GAAG,6BAA6B,CAAA;KAAC,CAAC;CAC1D;AAED,MAAM,WAAW,UAAU;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAA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AAM;gBACnB,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;gBACjF,MAAM;YACV,OAAO,CAAC,CAAC;gBACL,eAAe,CAAC,aAAa,EAAE,qBAAsB,aAAqB,CAAC,IAAI,EAAE,CAAC,CAAC;aACtF;SACJ;KACJ;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0CAA0C,CACtD,mBAAiC,EACjC,cAA4B;IAE5B,+DAA+D;IAC/D,MAAM,eAAe,GAAiB;QAClC,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,IAAI,oBAAO,cAAc,CAAC,IAAI,CAAE;KACnC,CAAC;IAEF,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,mBAAmB,CAAC;IACxD,MAAM,4BAA4B,GAC9B,gDAAgD,CAAC,eAAe,CAAC,CAAC;IACtE,OAAO,4BAA4B,CAAC;AACxC,CAAC;AAED,+GAA+G;AAC/G,0CAA0C;AAC1C,MAAM,CAAC,MAAM,sCAAsC,GAAG,CAAC,yBAAuC,EAAE,EAAE;IAC9F,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,IAAI,CAAC,WAAW,CAAiB,CAAC;IACxF,MAAM,cAAc,GAAG,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAiB,CAAC;IAC9E,MAAM,CAAC,mBAAmB,KAAK,SAAS,IAAI,cAAc,KAAK,SAAS,EACpE,KAAK,CAAC,wDAAwD,CAAC,CAAC;IACpE,MAAM,4BAA4B,GAAG,0CAA0C,CAC3E,mBAAmB,EACnB,cAAc,CACjB,CAAC;IACF,OAAO,4BAA4B,CAAC;AACxC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n assert,\n stringToBuffer,\n Uint8ArrayToArrayBuffer,\n unreachableCase,\n} from \"@fluidframework/common-utils\";\nimport { ISummaryTree, ISnapshotTree, SummaryType } from \"@fluidframework/protocol-definitions\";\n\n// This is used when we rehydrate a container from the snapshot. Here we put the blob contents\n// in separate property: blobContents.\nexport interface ISnapshotTreeWithBlobContents extends ISnapshotTree {\n blobsContents: {[path: string]: ArrayBufferLike},\n trees: {[path: string]: ISnapshotTreeWithBlobContents},\n}\n\nexport interface IParsedUrl {\n id: string;\n path: string;\n query: string;\n /**\n * Null means do not use snapshots, undefined means load latest snapshot\n * otherwise it's version ID passed to IDocumentStorageService.getVersions() to figure out what snapshot to use.\n * If needed, can add undefined which is treated by Container.load() as load latest snapshot.\n */\n version: string | null | undefined;\n}\n\nexport function parseUrl(url: string): IParsedUrl | undefined {\n const parsed = parse(url, true);\n if (typeof parsed.pathname !== \"string\") {\n throw new Error(\"Failed to parse pathname\");\n }\n const query = parsed.search ?? \"\";\n const regex = /^\\/([^/]*\\/[^/]*)(\\/?.*)$/;\n const match = regex.exec(parsed.pathname);\n return (match?.length === 3)\n ? { id: match[1], path: match[2], query, version: parsed.query.version as string }\n : undefined;\n}\n\n/**\n * Converts summary tree (for upload) to snapshot tree (for download).\n * Summary tree blobs contain contents, but snapshot tree blobs normally\n * contain IDs pointing to storage. This will create 2 blob entries in the\n * snapshot tree for each blob in the summary tree. One will be the regular\n * path pointing to a uniquely generated ID. Then there will be another\n * entry with the path as that uniquely generated ID, and value as the\n * blob contents as a base-64 string.\n * @param summary - summary to convert\n */\nfunction convertSummaryToSnapshotWithEmbeddedBlobContents(\n summary: ISummaryTree,\n): ISnapshotTreeWithBlobContents {\n const treeNode: ISnapshotTreeWithBlobContents = {\n blobs: {},\n blobsContents: {},\n trees: {},\n id: uuid(),\n unreferenced: summary.unreferenced,\n };\n const keys = Object.keys(summary.tree);\n for (const key of keys) {\n const summaryObject = summary.tree[key];\n\n switch (summaryObject.type) {\n case SummaryType.Tree: {\n treeNode.trees[key] = convertSummaryToSnapshotWithEmbeddedBlobContents(summaryObject);\n break;\n }\n case SummaryType.Attachment:\n treeNode.blobs[key] = summaryObject.id;\n break;\n case SummaryType.Blob: {\n const blobId = uuid();\n treeNode.blobs[key] = blobId;\n const contentBuffer = typeof summaryObject.content === \"string\" ?\n stringToBuffer(summaryObject.content, \"utf8\") : Uint8ArrayToArrayBuffer(summaryObject.content);\n treeNode.blobsContents[blobId] = contentBuffer;\n break;\n }\n case SummaryType.Handle:\n throw new Error(\"No handles should be there in summary in detached container!!\");\n break;\n default: {\n unreachableCase(summaryObject, `Unknown tree type ${(summaryObject as any).type}`);\n }\n }\n }\n return treeNode;\n}\n\n/**\n * Combine and convert protocol and app summary tree to format which is readable by container while rehydrating.\n * @param protocolSummaryTree - Protocol Summary Tree\n * @param appSummaryTree - App Summary Tree\n */\nexport function convertProtocolAndAppSummaryToSnapshotTree(\n protocolSummaryTree: ISummaryTree,\n appSummaryTree: ISummaryTree,\n): ISnapshotTreeWithBlobContents {\n // Shallow copy is fine, since we are doing a deep clone below.\n const combinedSummary: ISummaryTree = {\n type: SummaryType.Tree,\n tree: { ...appSummaryTree.tree },\n };\n\n combinedSummary.tree[\".protocol\"] = protocolSummaryTree;\n const snapshotTreeWithBlobContents =\n convertSummaryToSnapshotWithEmbeddedBlobContents(combinedSummary);\n return snapshotTreeWithBlobContents;\n}\n\n// This function converts the snapshot taken in detached container(by serialize api) to snapshotTree with which\n// a detached container can be rehydrated.\nexport const getSnapshotTreeFromSerializedContainer = (detachedContainerSnapshot: ISummaryTree) => {\n const protocolSummaryTree = detachedContainerSnapshot.tree[\".protocol\"] as ISummaryTree;\n const appSummaryTree = detachedContainerSnapshot.tree[\".app\"] as ISummaryTree;\n assert(protocolSummaryTree !== undefined && appSummaryTree !== undefined,\n 0x1e0 /* \"Protocol and App summary trees should be present\" */);\n const snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToSnapshotTree(\n protocolSummaryTree,\n appSummaryTree,\n );\n return snapshotTreeWithBlobContents;\n};\n"]}
|