@fluidframework/container-loader 1.4.0-115997 → 2.0.0-dev-rc.1.0.0.224419
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +18 -21
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +364 -0
- package/README.md +152 -56
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/container-loader.api.md +143 -0
- package/dist/{audience.js → audience.cjs} +15 -13
- package/dist/audience.cjs.map +1 -0
- package/dist/audience.d.ts +3 -6
- package/dist/audience.d.ts.map +1 -1
- package/dist/catchUpMonitor.cjs +43 -0
- package/dist/catchUpMonitor.cjs.map +1 -0
- package/dist/catchUpMonitor.d.ts +29 -0
- package/dist/catchUpMonitor.d.ts.map +1 -0
- package/dist/{connectionManager.js → connectionManager.cjs} +397 -240
- package/dist/connectionManager.cjs.map +1 -0
- package/dist/connectionManager.d.ts +23 -33
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/{connectionState.js → connectionState.cjs} +5 -7
- package/dist/connectionState.cjs.map +1 -0
- package/dist/connectionState.d.ts +3 -5
- package/dist/connectionState.d.ts.map +1 -1
- package/dist/connectionStateHandler.cjs +474 -0
- package/dist/connectionStateHandler.cjs.map +1 -0
- package/dist/connectionStateHandler.d.ts +127 -29
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/container-loader-alpha.d.ts +274 -0
- package/dist/container-loader-beta.d.ts +75 -0
- package/dist/container-loader-public.d.ts +75 -0
- package/dist/container-loader-untrimmed.d.ts +331 -0
- package/dist/container.cjs +1585 -0
- package/dist/container.cjs.map +1 -0
- package/dist/container.d.ts +227 -83
- package/dist/container.d.ts.map +1 -1
- package/dist/containerContext.cjs +74 -0
- package/dist/containerContext.cjs.map +1 -0
- package/dist/containerContext.d.ts +33 -59
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerStorageAdapter.cjs +234 -0
- package/dist/containerStorageAdapter.cjs.map +1 -0
- package/dist/containerStorageAdapter.d.ts +48 -23
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/{contracts.js → contracts.cjs} +5 -5
- package/dist/contracts.cjs.map +1 -0
- package/dist/contracts.d.ts +45 -17
- package/dist/contracts.d.ts.map +1 -1
- package/dist/debugLogger.cjs +101 -0
- package/dist/debugLogger.cjs.map +1 -0
- package/dist/debugLogger.d.ts +30 -0
- package/dist/debugLogger.d.ts.map +1 -0
- package/dist/{deltaManager.js → deltaManager.cjs} +379 -186
- package/dist/deltaManager.cjs.map +1 -0
- package/dist/deltaManager.d.ts +54 -18
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/{deltaQueue.js → deltaQueue.cjs} +29 -28
- package/dist/deltaQueue.cjs.map +1 -0
- package/dist/deltaQueue.d.ts +3 -4
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/disposal.cjs +25 -0
- package/dist/disposal.cjs.map +1 -0
- package/dist/disposal.d.ts +13 -0
- package/dist/disposal.d.ts.map +1 -0
- package/dist/error.cjs +32 -0
- package/dist/error.cjs.map +1 -0
- package/dist/error.d.ts +23 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/index.cjs +19 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/loader.cjs +148 -0
- package/dist/loader.cjs.map +1 -0
- package/dist/loader.d.ts +38 -19
- package/dist/loader.d.ts.map +1 -1
- package/dist/location-redirection-utilities/index.cjs +11 -0
- package/dist/location-redirection-utilities/index.cjs.map +1 -0
- package/dist/location-redirection-utilities/index.d.ts +6 -0
- package/dist/location-redirection-utilities/index.d.ts.map +1 -0
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.cjs +53 -0
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.cjs.map +1 -0
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts +24 -0
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -0
- package/dist/{collabWindowTracker.js → noopHeuristic.cjs} +37 -39
- package/dist/noopHeuristic.cjs.map +1 -0
- package/dist/noopHeuristic.d.ts +23 -0
- package/dist/noopHeuristic.d.ts.map +1 -0
- package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
- package/dist/packageVersion.cjs.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/protocol.cjs +99 -0
- package/dist/protocol.cjs.map +1 -0
- package/dist/protocol.d.ts +38 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/{protocolTreeDocumentStorageService.js → protocolTreeDocumentStorageService.cjs} +8 -5
- package/dist/protocolTreeDocumentStorageService.cjs.map +1 -0
- package/dist/protocolTreeDocumentStorageService.d.ts +8 -4
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/quorum.cjs +16 -0
- package/dist/quorum.cjs.map +1 -0
- package/dist/quorum.d.ts +1 -14
- package/dist/quorum.d.ts.map +1 -1
- package/dist/{retriableDocumentStorageService.js → retriableDocumentStorageService.cjs} +36 -21
- package/dist/retriableDocumentStorageService.cjs.map +1 -0
- package/dist/retriableDocumentStorageService.d.ts +7 -5
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/{utils.js → utils.cjs} +52 -14
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.ts +34 -1
- package/dist/utils.d.ts.map +1 -1
- package/lib/{audience.d.ts → audience.d.mts} +3 -10
- package/lib/audience.d.mts.map +1 -0
- package/lib/{audience.js → audience.mjs} +15 -17
- package/lib/audience.mjs.map +1 -0
- package/lib/catchUpMonitor.d.mts +29 -0
- package/lib/catchUpMonitor.d.mts.map +1 -0
- package/lib/catchUpMonitor.mjs +39 -0
- package/lib/catchUpMonitor.mjs.map +1 -0
- package/lib/{connectionManager.d.ts → connectionManager.d.mts} +23 -33
- package/lib/connectionManager.d.mts.map +1 -0
- package/lib/{connectionManager.js → connectionManager.mjs} +378 -218
- package/lib/connectionManager.mjs.map +1 -0
- package/lib/{connectionState.d.ts → connectionState.d.mts} +3 -5
- package/lib/connectionState.d.mts.map +1 -0
- package/lib/{connectionState.js → connectionState.mjs} +4 -6
- package/lib/connectionState.mjs.map +1 -0
- package/lib/connectionStateHandler.d.mts +179 -0
- package/lib/connectionStateHandler.d.mts.map +1 -0
- package/lib/connectionStateHandler.mjs +469 -0
- package/lib/connectionStateHandler.mjs.map +1 -0
- package/lib/container-loader-alpha.d.mts +274 -0
- package/lib/container-loader-beta.d.mts +75 -0
- package/lib/container-loader-public.d.mts +75 -0
- package/lib/container-loader-untrimmed.d.mts +331 -0
- package/lib/container.d.mts +382 -0
- package/lib/container.d.mts.map +1 -0
- package/lib/container.mjs +1579 -0
- package/lib/container.mjs.map +1 -0
- package/lib/containerContext.d.mts +58 -0
- package/lib/containerContext.d.mts.map +1 -0
- package/lib/containerContext.mjs +70 -0
- package/lib/containerContext.mjs.map +1 -0
- package/lib/containerStorageAdapter.d.mts +73 -0
- package/lib/containerStorageAdapter.d.mts.map +1 -0
- package/lib/containerStorageAdapter.mjs +228 -0
- package/lib/containerStorageAdapter.mjs.map +1 -0
- package/lib/{contracts.d.ts → contracts.d.mts} +45 -17
- package/lib/contracts.d.mts.map +1 -0
- package/lib/{contracts.js → contracts.mjs} +4 -4
- package/lib/contracts.mjs.map +1 -0
- package/lib/debugLogger.d.mts +30 -0
- package/lib/debugLogger.d.mts.map +1 -0
- package/lib/debugLogger.mjs +93 -0
- package/lib/debugLogger.mjs.map +1 -0
- package/lib/{deltaManager.d.ts → deltaManager.d.mts} +54 -18
- package/lib/deltaManager.d.mts.map +1 -0
- package/lib/{deltaManager.js → deltaManager.mjs} +361 -165
- package/lib/deltaManager.mjs.map +1 -0
- package/lib/{deltaQueue.d.ts → deltaQueue.d.mts} +3 -4
- package/lib/deltaQueue.d.mts.map +1 -0
- package/lib/{deltaQueue.js → deltaQueue.mjs} +25 -24
- package/lib/deltaQueue.mjs.map +1 -0
- package/lib/disposal.d.mts +13 -0
- package/lib/disposal.d.mts.map +1 -0
- package/lib/disposal.mjs +21 -0
- package/lib/disposal.mjs.map +1 -0
- package/lib/error.d.mts +23 -0
- package/lib/error.d.mts.map +1 -0
- package/lib/error.mjs +28 -0
- package/lib/error.mjs.map +1 -0
- package/lib/index.d.mts +11 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +10 -0
- package/lib/index.mjs.map +1 -0
- package/lib/{loader.d.ts → loader.d.mts} +39 -20
- package/lib/loader.d.mts.map +1 -0
- package/lib/loader.mjs +143 -0
- package/lib/loader.mjs.map +1 -0
- package/lib/location-redirection-utilities/index.d.mts +6 -0
- package/lib/location-redirection-utilities/index.d.mts.map +1 -0
- package/lib/location-redirection-utilities/index.mjs +6 -0
- package/lib/location-redirection-utilities/index.mjs.map +1 -0
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.mts +24 -0
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.mts.map +1 -0
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.mjs +48 -0
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.mjs.map +1 -0
- package/lib/noopHeuristic.d.mts +23 -0
- package/lib/noopHeuristic.d.mts.map +1 -0
- package/lib/{collabWindowTracker.js → noopHeuristic.mjs} +33 -35
- package/lib/noopHeuristic.mjs.map +1 -0
- package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
- package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +1 -1
- package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
- package/lib/packageVersion.mjs.map +1 -0
- package/lib/protocol.d.mts +38 -0
- package/lib/protocol.d.mts.map +1 -0
- package/lib/protocol.mjs +94 -0
- package/lib/protocol.mjs.map +1 -0
- package/lib/{protocolTreeDocumentStorageService.d.ts → protocolTreeDocumentStorageService.d.mts} +8 -4
- package/lib/protocolTreeDocumentStorageService.d.mts.map +1 -0
- package/lib/{protocolTreeDocumentStorageService.js → protocolTreeDocumentStorageService.mjs} +8 -5
- package/lib/protocolTreeDocumentStorageService.mjs.map +1 -0
- package/lib/quorum.d.mts +4 -0
- package/lib/quorum.d.mts.map +1 -0
- package/lib/quorum.mjs +12 -0
- package/lib/quorum.mjs.map +1 -0
- package/lib/{retriableDocumentStorageService.d.ts → retriableDocumentStorageService.d.mts} +7 -5
- package/lib/retriableDocumentStorageService.d.mts.map +1 -0
- package/lib/{retriableDocumentStorageService.js → retriableDocumentStorageService.mjs} +35 -20
- package/lib/retriableDocumentStorageService.mjs.map +1 -0
- package/lib/utils.d.mts +67 -0
- package/lib/utils.d.mts.map +1 -0
- package/lib/{utils.js → utils.mjs} +47 -11
- package/lib/utils.mjs.map +1 -0
- package/package.json +163 -70
- package/prettier.config.cjs +8 -0
- package/src/audience.ts +59 -49
- package/src/catchUpMonitor.ts +61 -0
- package/src/connectionManager.ts +1154 -910
- package/src/connectionState.ts +22 -25
- package/src/connectionStateHandler.ts +689 -319
- package/src/container.ts +2476 -1792
- package/src/containerContext.ts +98 -330
- package/src/containerStorageAdapter.ts +301 -105
- package/src/contracts.ts +184 -146
- package/src/debugLogger.ts +123 -0
- package/src/deltaManager.ts +1165 -900
- package/src/deltaQueue.ts +156 -152
- package/src/disposal.ts +25 -0
- package/src/error.ts +44 -0
- package/src/index.ts +14 -15
- package/src/loader.ts +356 -427
- package/src/location-redirection-utilities/index.ts +9 -0
- package/src/location-redirection-utilities/resolveWithLocationRedirection.ts +61 -0
- package/src/noopHeuristic.ts +107 -0
- package/src/packageVersion.ts +1 -1
- package/src/protocol.ts +150 -0
- package/src/protocolTreeDocumentStorageService.ts +35 -35
- package/src/quorum.ts +11 -50
- package/src/retriableDocumentStorageService.ts +135 -95
- package/src/utils.ts +159 -86
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +10 -12
- package/dist/audience.js.map +0 -1
- package/dist/collabWindowTracker.d.ts +0 -19
- package/dist/collabWindowTracker.d.ts.map +0 -1
- package/dist/collabWindowTracker.js.map +0 -1
- package/dist/connectionManager.js.map +0 -1
- package/dist/connectionState.js.map +0 -1
- package/dist/connectionStateHandler.js +0 -280
- package/dist/connectionStateHandler.js.map +0 -1
- package/dist/container.js +0 -1284
- package/dist/container.js.map +0 -1
- package/dist/containerContext.js +0 -217
- package/dist/containerContext.js.map +0 -1
- package/dist/containerStorageAdapter.js +0 -104
- package/dist/containerStorageAdapter.js.map +0 -1
- package/dist/contracts.js.map +0 -1
- package/dist/deltaManager.js.map +0 -1
- package/dist/deltaManagerProxy.d.ts +0 -54
- package/dist/deltaManagerProxy.d.ts.map +0 -1
- package/dist/deltaManagerProxy.js +0 -115
- package/dist/deltaManagerProxy.js.map +0 -1
- package/dist/deltaQueue.js.map +0 -1
- package/dist/index.js +0 -16
- package/dist/index.js.map +0 -1
- package/dist/loader.js +0 -241
- package/dist/loader.js.map +0 -1
- package/dist/packageVersion.js.map +0 -1
- package/dist/protocolTreeDocumentStorageService.js.map +0 -1
- package/dist/quorum.js +0 -44
- package/dist/quorum.js.map +0 -1
- package/dist/retriableDocumentStorageService.js.map +0 -1
- package/dist/utils.js.map +0 -1
- package/lib/audience.d.ts.map +0 -1
- package/lib/audience.js.map +0 -1
- package/lib/collabWindowTracker.d.ts +0 -19
- package/lib/collabWindowTracker.d.ts.map +0 -1
- package/lib/collabWindowTracker.js.map +0 -1
- package/lib/connectionManager.d.ts.map +0 -1
- package/lib/connectionManager.js.map +0 -1
- package/lib/connectionState.d.ts.map +0 -1
- package/lib/connectionState.js.map +0 -1
- package/lib/connectionStateHandler.d.ts +0 -81
- package/lib/connectionStateHandler.d.ts.map +0 -1
- package/lib/connectionStateHandler.js +0 -276
- package/lib/connectionStateHandler.js.map +0 -1
- package/lib/container.d.ts +0 -238
- package/lib/container.d.ts.map +0 -1
- package/lib/container.js +0 -1276
- package/lib/container.js.map +0 -1
- package/lib/containerContext.d.ts +0 -84
- package/lib/containerContext.d.ts.map +0 -1
- package/lib/containerContext.js +0 -213
- package/lib/containerContext.js.map +0 -1
- package/lib/containerStorageAdapter.d.ts +0 -48
- package/lib/containerStorageAdapter.d.ts.map +0 -1
- package/lib/containerStorageAdapter.js +0 -99
- package/lib/containerStorageAdapter.js.map +0 -1
- package/lib/contracts.d.ts.map +0 -1
- package/lib/contracts.js.map +0 -1
- package/lib/deltaManager.d.ts.map +0 -1
- package/lib/deltaManager.js.map +0 -1
- package/lib/deltaManagerProxy.d.ts +0 -54
- package/lib/deltaManagerProxy.d.ts.map +0 -1
- package/lib/deltaManagerProxy.js +0 -110
- package/lib/deltaManagerProxy.js.map +0 -1
- package/lib/deltaQueue.d.ts.map +0 -1
- package/lib/deltaQueue.js.map +0 -1
- package/lib/index.d.ts +0 -8
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -8
- package/lib/index.js.map +0 -1
- package/lib/loader.d.ts.map +0 -1
- package/lib/loader.js +0 -236
- package/lib/loader.js.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/lib/protocolTreeDocumentStorageService.d.ts.map +0 -1
- package/lib/protocolTreeDocumentStorageService.js.map +0 -1
- package/lib/quorum.d.ts +0 -21
- package/lib/quorum.d.ts.map +0 -1
- package/lib/quorum.js +0 -38
- package/lib/quorum.js.map +0 -1
- package/lib/retriableDocumentStorageService.d.ts.map +0 -1
- package/lib/retriableDocumentStorageService.js.map +0 -1
- package/lib/utils.d.ts +0 -34
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js.map +0 -1
- package/src/collabWindowTracker.ts +0 -102
- package/src/deltaManagerProxy.ts +0 -158
- package/tsconfig.esnext.json +0 -7
package/src/loader.ts
CHANGED
|
@@ -4,147 +4,107 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { v4 as uuid } from "uuid";
|
|
7
|
-
import { ITelemetryBaseLogger, ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
8
7
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
ITelemetryLoggerExt,
|
|
9
|
+
mixinMonitoringContext,
|
|
10
|
+
MonitoringContext,
|
|
11
|
+
PerformanceEvent,
|
|
12
|
+
sessionStorageConfigProvider,
|
|
13
|
+
createChildMonitoringContext,
|
|
14
|
+
UsageError,
|
|
15
|
+
} from "@fluidframework/telemetry-utils";
|
|
16
|
+
import {
|
|
17
|
+
ITelemetryBaseLogger,
|
|
18
|
+
FluidObject,
|
|
19
|
+
IRequest,
|
|
20
|
+
IConfigProviderBase,
|
|
14
21
|
} from "@fluidframework/core-interfaces";
|
|
15
22
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
IContainer,
|
|
24
|
+
IFluidModule,
|
|
25
|
+
IHostLoader,
|
|
26
|
+
ILoader,
|
|
27
|
+
ILoaderOptions as ILoaderOptions1,
|
|
28
|
+
LoaderHeader,
|
|
29
|
+
IProvideFluidCodeDetailsComparer,
|
|
30
|
+
IFluidCodeDetails,
|
|
24
31
|
} from "@fluidframework/container-definitions";
|
|
25
32
|
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
mixinMonitoringContext,
|
|
31
|
-
MonitoringContext,
|
|
32
|
-
PerformanceEvent,
|
|
33
|
-
sessionStorageConfigProvider,
|
|
34
|
-
} from "@fluidframework/telemetry-utils";
|
|
35
|
-
import {
|
|
36
|
-
IDocumentServiceFactory,
|
|
37
|
-
IDocumentStorageService,
|
|
38
|
-
IFluidResolvedUrl,
|
|
39
|
-
IResolvedUrl,
|
|
40
|
-
IUrlResolver,
|
|
33
|
+
IDocumentServiceFactory,
|
|
34
|
+
IDocumentStorageService,
|
|
35
|
+
IResolvedUrl,
|
|
36
|
+
IUrlResolver,
|
|
41
37
|
} from "@fluidframework/driver-definitions";
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
ensureFluidResolvedUrl,
|
|
45
|
-
MultiUrlResolver,
|
|
46
|
-
MultiDocumentServiceFactory,
|
|
47
|
-
} from "@fluidframework/driver-utils";
|
|
38
|
+
import { IClientDetails } from "@fluidframework/protocol-definitions";
|
|
48
39
|
import { Container, IPendingContainerState } from "./container";
|
|
49
|
-
import { IParsedUrl,
|
|
40
|
+
import { IParsedUrl, tryParseCompatibleResolvedUrl } from "./utils";
|
|
50
41
|
import { pkgVersion } from "./packageVersion";
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
import { ProtocolHandlerBuilder } from "./protocol";
|
|
43
|
+
import { DebugLogger } from "./debugLogger";
|
|
44
|
+
|
|
45
|
+
function ensureResolvedUrlDefined(
|
|
46
|
+
resolved: IResolvedUrl | undefined,
|
|
47
|
+
): asserts resolved is IResolvedUrl {
|
|
48
|
+
if (resolved === undefined) {
|
|
49
|
+
throw new Error(`Object is not a IResolveUrl.`);
|
|
50
|
+
}
|
|
58
51
|
}
|
|
59
|
-
|
|
52
|
+
/**
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
60
55
|
export class RelativeLoader implements ILoader {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (this.loader === undefined) {
|
|
91
|
-
throw new Error("Cannot resolve external containers");
|
|
92
|
-
}
|
|
93
|
-
return this.loader.resolve(request);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
public async request(request: IRequest): Promise<IResponse> {
|
|
97
|
-
if (request.url.startsWith("/")) {
|
|
98
|
-
const container = await this.resolve(request);
|
|
99
|
-
return container.request(request);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (this.loader === undefined) {
|
|
103
|
-
return {
|
|
104
|
-
status: 404,
|
|
105
|
-
value: "Cannot request external containers",
|
|
106
|
-
mimeType: "plain/text",
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
return this.loader.request(request);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function createCachedResolver(resolver: IUrlResolver) {
|
|
114
|
-
const cacheResolver = Object.create(resolver) as IUrlResolver;
|
|
115
|
-
const resolveCache = new Map<string, Promise<IResolvedUrl | undefined>>();
|
|
116
|
-
cacheResolver.resolve = async (request: IRequest): Promise<IResolvedUrl | undefined> => {
|
|
117
|
-
if (!canUseCache(request)) {
|
|
118
|
-
return resolver.resolve(request);
|
|
119
|
-
}
|
|
120
|
-
if (!resolveCache.has(request.url)) {
|
|
121
|
-
resolveCache.set(request.url, resolver.resolve(request));
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return resolveCache.get(request.url);
|
|
125
|
-
};
|
|
126
|
-
return cacheResolver;
|
|
56
|
+
constructor(
|
|
57
|
+
private readonly container: Container,
|
|
58
|
+
private readonly loader: ILoader | undefined,
|
|
59
|
+
) {}
|
|
60
|
+
|
|
61
|
+
public async resolve(request: IRequest): Promise<IContainer> {
|
|
62
|
+
if (request.url.startsWith("/")) {
|
|
63
|
+
ensureResolvedUrlDefined(this.container.resolvedUrl);
|
|
64
|
+
const container = await this.container.clone(
|
|
65
|
+
{
|
|
66
|
+
resolvedUrl: { ...this.container.resolvedUrl },
|
|
67
|
+
version: request.headers?.[LoaderHeader.version] ?? undefined,
|
|
68
|
+
loadMode: request.headers?.[LoaderHeader.loadMode],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
canReconnect: request.headers?.[LoaderHeader.reconnect],
|
|
72
|
+
clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
return container;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (this.loader === undefined) {
|
|
79
|
+
throw new Error("Cannot resolve external containers");
|
|
80
|
+
}
|
|
81
|
+
return this.loader.resolve(request);
|
|
82
|
+
}
|
|
127
83
|
}
|
|
128
84
|
|
|
85
|
+
/**
|
|
86
|
+
* @alpha
|
|
87
|
+
*/
|
|
129
88
|
export interface ILoaderOptions extends ILoaderOptions1 {
|
|
130
|
-
|
|
89
|
+
summarizeProtocolTree?: boolean;
|
|
131
90
|
}
|
|
132
91
|
|
|
133
92
|
/**
|
|
134
93
|
* @deprecated IFluidModuleWithDetails interface is moved to
|
|
135
|
-
* {@link @fluidframework/container-
|
|
94
|
+
* {@link @fluidframework/container-definitions#IFluidModuleWithDetails}
|
|
136
95
|
* to have all the code loading modules in one package. #8193
|
|
137
96
|
* Encapsulates a module entry point with corresponding code details.
|
|
97
|
+
* @alpha
|
|
138
98
|
*/
|
|
139
99
|
export interface IFluidModuleWithDetails {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
100
|
+
/** Fluid code module that implements the runtime factory needed to instantiate the container runtime. */
|
|
101
|
+
module: IFluidModule;
|
|
102
|
+
/**
|
|
103
|
+
* Code details associated with the module. Represents a document schema this module supports.
|
|
104
|
+
* If the code loader implements the {@link @fluidframework/core-interfaces#IFluidCodeDetailsComparer} interface,
|
|
105
|
+
* it'll be called to determine whether the module code details satisfy the new code proposal in the quorum.
|
|
106
|
+
*/
|
|
107
|
+
details: IFluidCodeDetails;
|
|
148
108
|
}
|
|
149
109
|
|
|
150
110
|
/**
|
|
@@ -152,336 +112,305 @@ export interface IFluidModuleWithDetails {
|
|
|
152
112
|
* to have code loading modules in one package. #8193
|
|
153
113
|
* Fluid code loader resolves a code module matching the document schema, i.e. code details, such as
|
|
154
114
|
* a package name and package version range.
|
|
115
|
+
* @alpha
|
|
155
116
|
*/
|
|
156
|
-
export interface ICodeDetailsLoader
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
load(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;
|
|
117
|
+
export interface ICodeDetailsLoader extends Partial<IProvideFluidCodeDetailsComparer> {
|
|
118
|
+
/**
|
|
119
|
+
* Load the code module (package) that is capable to interact with the document.
|
|
120
|
+
*
|
|
121
|
+
* @param source - Code proposal that articulates the current schema the document is written in.
|
|
122
|
+
* @returns Code module entry point along with the code details associated with it.
|
|
123
|
+
*/
|
|
124
|
+
load(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;
|
|
165
125
|
}
|
|
166
126
|
|
|
167
127
|
/**
|
|
168
128
|
* Services and properties necessary for creating a loader
|
|
129
|
+
* @alpha
|
|
169
130
|
*/
|
|
170
131
|
export interface ILoaderProps {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
132
|
+
/**
|
|
133
|
+
* The url resolver used by the loader for resolving external urls
|
|
134
|
+
* into Fluid urls such that the container specified by the
|
|
135
|
+
* external url can be loaded.
|
|
136
|
+
*/
|
|
137
|
+
readonly urlResolver: IUrlResolver;
|
|
138
|
+
/**
|
|
139
|
+
* The document service factory take the Fluid url provided
|
|
140
|
+
* by the resolved url and constructs all the necessary services
|
|
141
|
+
* for communication with the container's server.
|
|
142
|
+
*/
|
|
143
|
+
readonly documentServiceFactory: IDocumentServiceFactory;
|
|
144
|
+
/**
|
|
145
|
+
* The code loader handles loading the necessary code
|
|
146
|
+
* for running a container once it is loaded.
|
|
147
|
+
*/
|
|
148
|
+
readonly codeLoader: ICodeDetailsLoader;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* A property bag of options used by various layers
|
|
152
|
+
* to control features
|
|
153
|
+
*/
|
|
154
|
+
readonly options?: ILoaderOptions;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Scope is provided to all container and is a set of shared
|
|
158
|
+
* services for container's to integrate with their host environment.
|
|
159
|
+
*/
|
|
160
|
+
readonly scope?: FluidObject;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The logger that all telemetry should be pushed to.
|
|
164
|
+
*/
|
|
165
|
+
readonly logger?: ITelemetryBaseLogger;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Blobs storage for detached containers.
|
|
169
|
+
*/
|
|
170
|
+
readonly detachedBlobStorage?: IDetachedBlobStorage;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* The configuration provider which may be used to control features.
|
|
174
|
+
*/
|
|
175
|
+
readonly configProvider?: IConfigProviderBase;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Optional property for allowing the container to use a custom
|
|
179
|
+
* protocol implementation for handling the quorum and/or the audience.
|
|
180
|
+
*/
|
|
181
|
+
readonly protocolHandlerBuilder?: ProtocolHandlerBuilder;
|
|
215
182
|
}
|
|
216
183
|
|
|
217
184
|
/**
|
|
218
185
|
* Services and properties used by and exposed by the loader
|
|
186
|
+
* @alpha
|
|
219
187
|
*/
|
|
220
188
|
export interface ILoaderServices {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
189
|
+
/**
|
|
190
|
+
* The url resolver used by the loader for resolving external urls
|
|
191
|
+
* into Fluid urls such that the container specified by the
|
|
192
|
+
* external url can be loaded.
|
|
193
|
+
*/
|
|
194
|
+
readonly urlResolver: IUrlResolver;
|
|
195
|
+
/**
|
|
196
|
+
* The document service factory take the Fluid url provided
|
|
197
|
+
* by the resolved url and constructs all the necessary services
|
|
198
|
+
* for communication with the container's server.
|
|
199
|
+
*/
|
|
200
|
+
readonly documentServiceFactory: IDocumentServiceFactory;
|
|
201
|
+
/**
|
|
202
|
+
* The code loader handles loading the necessary code
|
|
203
|
+
* for running a container once it is loaded.
|
|
204
|
+
*/
|
|
205
|
+
readonly codeLoader: ICodeDetailsLoader;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* A property bag of options used by various layers
|
|
209
|
+
* to control features
|
|
210
|
+
*/
|
|
211
|
+
readonly options: ILoaderOptions;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Scope is provided to all container and is a set of shared
|
|
215
|
+
* services for container's to integrate with their host environment.
|
|
216
|
+
*/
|
|
217
|
+
readonly scope: FluidObject;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The logger downstream consumers should construct their loggers from
|
|
221
|
+
*/
|
|
222
|
+
readonly subLogger: ITelemetryLoggerExt;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Blobs storage for detached containers.
|
|
226
|
+
*/
|
|
227
|
+
readonly detachedBlobStorage?: IDetachedBlobStorage;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Optional property for allowing the container to use a custom
|
|
231
|
+
* protocol implementation for handling the quorum and/or the audience.
|
|
232
|
+
*/
|
|
233
|
+
readonly protocolHandlerBuilder?: ProtocolHandlerBuilder;
|
|
260
234
|
}
|
|
261
235
|
|
|
262
236
|
/**
|
|
263
237
|
* Subset of IDocumentStorageService which only supports createBlob() and readBlob(). This is used to support
|
|
264
238
|
* blobs in detached containers.
|
|
239
|
+
* @alpha
|
|
265
240
|
*/
|
|
266
241
|
export type IDetachedBlobStorage = Pick<IDocumentStorageService, "createBlob" | "readBlob"> & {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
242
|
+
size: number;
|
|
243
|
+
/**
|
|
244
|
+
* Return an array of all blob IDs present in storage
|
|
245
|
+
*/
|
|
246
|
+
getBlobIds(): string[];
|
|
247
|
+
};
|
|
273
248
|
|
|
274
249
|
/**
|
|
275
250
|
* Manages Fluid resource loading
|
|
251
|
+
* @alpha
|
|
276
252
|
*/
|
|
277
253
|
export class Loader implements IHostLoader {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
private get cachingEnabled() {
|
|
442
|
-
return this.services.options.cache !== false;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
private canCacheForRequest(headers: IRequestHeader): boolean {
|
|
446
|
-
return this.cachingEnabled && headers[LoaderHeader.cache] !== false;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
private parseHeader(parsed: IParsedUrl, request: IRequest) {
|
|
450
|
-
let fromSequenceNumber = -1;
|
|
451
|
-
|
|
452
|
-
request.headers = request.headers ?? {};
|
|
453
|
-
|
|
454
|
-
const headerSeqNum = request.headers[LoaderHeader.sequenceNumber];
|
|
455
|
-
if (headerSeqNum !== undefined) {
|
|
456
|
-
fromSequenceNumber = headerSeqNum;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
// If set in both query string and headers, use query string
|
|
460
|
-
request.headers[LoaderHeader.version] = parsed.version ?? request.headers[LoaderHeader.version];
|
|
461
|
-
|
|
462
|
-
const canCache = this.canCacheForRequest(request.headers);
|
|
463
|
-
|
|
464
|
-
return {
|
|
465
|
-
canCache,
|
|
466
|
-
fromSequenceNumber,
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
private async loadContainer(
|
|
471
|
-
request: IRequest,
|
|
472
|
-
resolved: IFluidResolvedUrl,
|
|
473
|
-
pendingLocalState?: IPendingContainerState,
|
|
474
|
-
): Promise<Container> {
|
|
475
|
-
return Container.load(
|
|
476
|
-
this,
|
|
477
|
-
{
|
|
478
|
-
canReconnect: request.headers?.[LoaderHeader.reconnect],
|
|
479
|
-
clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],
|
|
480
|
-
resolvedUrl: resolved,
|
|
481
|
-
version: request.headers?.[LoaderHeader.version] ?? undefined,
|
|
482
|
-
loadMode: request.headers?.[LoaderHeader.loadMode],
|
|
483
|
-
},
|
|
484
|
-
pendingLocalState,
|
|
485
|
-
);
|
|
486
|
-
}
|
|
254
|
+
public readonly services: ILoaderServices;
|
|
255
|
+
private readonly mc: MonitoringContext;
|
|
256
|
+
|
|
257
|
+
constructor(loaderProps: ILoaderProps) {
|
|
258
|
+
const {
|
|
259
|
+
urlResolver,
|
|
260
|
+
documentServiceFactory,
|
|
261
|
+
codeLoader,
|
|
262
|
+
options,
|
|
263
|
+
scope,
|
|
264
|
+
logger,
|
|
265
|
+
detachedBlobStorage,
|
|
266
|
+
configProvider,
|
|
267
|
+
protocolHandlerBuilder,
|
|
268
|
+
} = loaderProps;
|
|
269
|
+
|
|
270
|
+
const telemetryProps = {
|
|
271
|
+
loaderId: uuid(),
|
|
272
|
+
loaderVersion: pkgVersion,
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const subMc = mixinMonitoringContext(
|
|
276
|
+
DebugLogger.mixinDebugLogger("fluid:telemetry", logger, {
|
|
277
|
+
all: telemetryProps,
|
|
278
|
+
}),
|
|
279
|
+
sessionStorageConfigProvider.value,
|
|
280
|
+
configProvider,
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
this.services = {
|
|
284
|
+
urlResolver,
|
|
285
|
+
documentServiceFactory,
|
|
286
|
+
codeLoader,
|
|
287
|
+
options: options ?? {},
|
|
288
|
+
scope:
|
|
289
|
+
options?.provideScopeLoader !== false ? { ...scope, ILoader: this } : { ...scope },
|
|
290
|
+
detachedBlobStorage,
|
|
291
|
+
protocolHandlerBuilder,
|
|
292
|
+
subLogger: subMc.logger,
|
|
293
|
+
};
|
|
294
|
+
this.mc = createChildMonitoringContext({
|
|
295
|
+
logger: this.services.subLogger,
|
|
296
|
+
namespace: "Loader",
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
public async createDetachedContainer(
|
|
301
|
+
codeDetails: IFluidCodeDetails,
|
|
302
|
+
createDetachedProps?: {
|
|
303
|
+
canReconnect?: boolean;
|
|
304
|
+
clientDetailsOverride?: IClientDetails;
|
|
305
|
+
},
|
|
306
|
+
): Promise<IContainer> {
|
|
307
|
+
return Container.createDetached(
|
|
308
|
+
{
|
|
309
|
+
...createDetachedProps,
|
|
310
|
+
...this.services,
|
|
311
|
+
},
|
|
312
|
+
codeDetails,
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
public async rehydrateDetachedContainerFromSnapshot(
|
|
317
|
+
snapshot: string,
|
|
318
|
+
createDetachedProps?: {
|
|
319
|
+
canReconnect?: boolean;
|
|
320
|
+
clientDetailsOverride?: IClientDetails;
|
|
321
|
+
},
|
|
322
|
+
): Promise<IContainer> {
|
|
323
|
+
return Container.rehydrateDetachedFromSnapshot(
|
|
324
|
+
{
|
|
325
|
+
...createDetachedProps,
|
|
326
|
+
...this.services,
|
|
327
|
+
},
|
|
328
|
+
snapshot,
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
public async resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer> {
|
|
333
|
+
const eventName = pendingLocalState === undefined ? "Resolve" : "ResolveWithPendingState";
|
|
334
|
+
return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName }, async () => {
|
|
335
|
+
const resolved = await this.resolveCore(
|
|
336
|
+
request,
|
|
337
|
+
pendingLocalState !== undefined ? JSON.parse(pendingLocalState) : undefined,
|
|
338
|
+
);
|
|
339
|
+
return resolved.container;
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
private async resolveCore(
|
|
344
|
+
request: IRequest,
|
|
345
|
+
pendingLocalState?: IPendingContainerState,
|
|
346
|
+
): Promise<{ container: Container; parsed: IParsedUrl }> {
|
|
347
|
+
const resolvedAsFluid = await this.services.urlResolver.resolve(request);
|
|
348
|
+
ensureResolvedUrlDefined(resolvedAsFluid);
|
|
349
|
+
|
|
350
|
+
// Parse URL into data stores
|
|
351
|
+
const parsed = tryParseCompatibleResolvedUrl(resolvedAsFluid.url);
|
|
352
|
+
if (parsed === undefined) {
|
|
353
|
+
throw new Error(`Invalid URL ${resolvedAsFluid.url}`);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (pendingLocalState !== undefined) {
|
|
357
|
+
const parsedPendingUrl = tryParseCompatibleResolvedUrl(pendingLocalState.url);
|
|
358
|
+
if (
|
|
359
|
+
parsedPendingUrl?.id !== parsed.id ||
|
|
360
|
+
parsedPendingUrl?.path.replace(/\/$/, "") !== parsed.path.replace(/\/$/, "")
|
|
361
|
+
) {
|
|
362
|
+
const message = `URL ${resolvedAsFluid.url} does not match pending state URL ${pendingLocalState.url}`;
|
|
363
|
+
throw new Error(message);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
request.headers ??= {};
|
|
368
|
+
// If set in both query string and headers, use query string. Also write the value from the query string into the header either way.
|
|
369
|
+
request.headers[LoaderHeader.version] =
|
|
370
|
+
parsed.version ?? request.headers[LoaderHeader.version];
|
|
371
|
+
const fromSequenceNumber = request.headers[LoaderHeader.sequenceNumber] as
|
|
372
|
+
| number
|
|
373
|
+
| undefined;
|
|
374
|
+
const opsBeforeReturn = request.headers[LoaderHeader.loadMode]?.opsBeforeReturn as
|
|
375
|
+
| string
|
|
376
|
+
| undefined;
|
|
377
|
+
|
|
378
|
+
if (
|
|
379
|
+
opsBeforeReturn === "sequenceNumber" &&
|
|
380
|
+
(fromSequenceNumber === undefined || fromSequenceNumber < 0)
|
|
381
|
+
) {
|
|
382
|
+
// If opsBeforeReturn is set to "sequenceNumber", then fromSequenceNumber should be set to a non-negative integer.
|
|
383
|
+
throw new UsageError("sequenceNumber must be set to a non-negative integer");
|
|
384
|
+
} else if (opsBeforeReturn !== "sequenceNumber" && fromSequenceNumber !== undefined) {
|
|
385
|
+
// If opsBeforeReturn is not set to "sequenceNumber", then fromSequenceNumber should be undefined (default value).
|
|
386
|
+
// In this case, we should throw an error since opsBeforeReturn is not explicitly set to "sequenceNumber".
|
|
387
|
+
throw new UsageError('opsBeforeReturn must be set to "sequenceNumber"');
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
return {
|
|
391
|
+
container: await this.loadContainer(request, resolvedAsFluid, pendingLocalState),
|
|
392
|
+
parsed,
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
private async loadContainer(
|
|
397
|
+
request: IRequest,
|
|
398
|
+
resolvedUrl: IResolvedUrl,
|
|
399
|
+
pendingLocalState?: IPendingContainerState,
|
|
400
|
+
): Promise<Container> {
|
|
401
|
+
return Container.load(
|
|
402
|
+
{
|
|
403
|
+
resolvedUrl,
|
|
404
|
+
version: request.headers?.[LoaderHeader.version] ?? undefined,
|
|
405
|
+
loadMode: request.headers?.[LoaderHeader.loadMode],
|
|
406
|
+
pendingLocalState,
|
|
407
|
+
loadToSequenceNumber: request.headers?.[LoaderHeader.sequenceNumber],
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
canReconnect: request.headers?.[LoaderHeader.reconnect],
|
|
411
|
+
clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],
|
|
412
|
+
...this.services,
|
|
413
|
+
},
|
|
414
|
+
);
|
|
415
|
+
}
|
|
487
416
|
}
|