@fluidframework/container-loader 2.0.0-internal.3.0.1 → 2.0.0-internal.3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +18 -21
- package/.mocharc.js +2 -2
- package/README.md +45 -43
- package/api-extractor.json +2 -2
- package/closeAndGetPendingLocalState.md +51 -0
- package/dist/audience.d.ts.map +1 -1
- package/dist/audience.js.map +1 -1
- package/dist/catchUpMonitor.d.ts.map +1 -1
- package/dist/catchUpMonitor.js.map +1 -1
- package/dist/collabWindowTracker.d.ts.map +1 -1
- package/dist/collabWindowTracker.js.map +1 -1
- package/dist/connectionManager.d.ts +2 -2
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +50 -23
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionState.d.ts.map +1 -1
- package/dist/connectionState.js.map +1 -1
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +35 -16
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +96 -46
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +6 -2
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +2 -4
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/deltaManager.d.ts +3 -3
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +56 -27
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaManagerProxy.d.ts.map +1 -1
- package/dist/deltaManagerProxy.js.map +1 -1
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js +4 -2
- package/dist/deltaQueue.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +3 -3
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +16 -8
- package/dist/loader.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +2 -1
- package/dist/protocol.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/quorum.d.ts.map +1 -1
- package/dist/quorum.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +6 -2
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +6 -4
- package/dist/utils.js.map +1 -1
- package/lib/audience.d.ts.map +1 -1
- package/lib/audience.js.map +1 -1
- package/lib/catchUpMonitor.d.ts.map +1 -1
- package/lib/catchUpMonitor.js.map +1 -1
- package/lib/collabWindowTracker.d.ts.map +1 -1
- package/lib/collabWindowTracker.js.map +1 -1
- package/lib/connectionManager.d.ts +2 -2
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +52 -25
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionState.d.ts.map +1 -1
- package/lib/connectionState.js.map +1 -1
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +35 -16
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +100 -50
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +6 -2
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +2 -4
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/deltaManager.d.ts +3 -3
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +58 -29
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaManagerProxy.d.ts.map +1 -1
- package/lib/deltaManagerProxy.js.map +1 -1
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js +4 -2
- package/lib/deltaQueue.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/loader.d.ts +3 -3
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +16 -8
- package/lib/loader.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +2 -1
- package/lib/protocol.js.map +1 -1
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/lib/protocolTreeDocumentStorageService.js.map +1 -1
- package/lib/quorum.d.ts.map +1 -1
- package/lib/quorum.js.map +1 -1
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js +6 -2
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +6 -4
- package/lib/utils.js.map +1 -1
- package/package.json +115 -114
- package/prettier.config.cjs +1 -1
- package/src/audience.ts +51 -46
- package/src/catchUpMonitor.ts +39 -37
- package/src/collabWindowTracker.ts +75 -70
- package/src/connectionManager.ts +1006 -943
- package/src/connectionState.ts +19 -19
- package/src/connectionStateHandler.ts +544 -465
- package/src/container.ts +2056 -1895
- package/src/containerContext.ts +350 -340
- package/src/containerStorageAdapter.ts +163 -153
- package/src/contracts.ts +155 -153
- package/src/deltaManager.ts +1069 -992
- package/src/deltaManagerProxy.ts +143 -137
- package/src/deltaQueue.ts +155 -151
- package/src/index.ts +14 -17
- package/src/loader.ts +408 -403
- package/src/packageVersion.ts +1 -1
- package/src/protocol.ts +93 -87
- package/src/protocolTreeDocumentStorageService.ts +30 -33
- package/src/quorum.ts +34 -34
- package/src/retriableDocumentStorageService.ts +118 -102
- package/src/utils.ts +89 -82
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +8 -12
package/lib/loader.js
CHANGED
|
@@ -20,7 +20,9 @@ export class RelativeLoader {
|
|
|
20
20
|
this.container = container;
|
|
21
21
|
this.loader = loader;
|
|
22
22
|
}
|
|
23
|
-
get IFluidRouter() {
|
|
23
|
+
get IFluidRouter() {
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
24
26
|
async resolve(request) {
|
|
25
27
|
var _a, _b, _c, _d, _e;
|
|
26
28
|
if (request.url.startsWith("/")) {
|
|
@@ -89,7 +91,9 @@ export class Loader {
|
|
|
89
91
|
loaderId: uuid(),
|
|
90
92
|
loaderVersion: pkgVersion,
|
|
91
93
|
};
|
|
92
|
-
const subMc = mixinMonitoringContext(DebugLogger.mixinDebugLogger("fluid:telemetry", loaderProps.logger, {
|
|
94
|
+
const subMc = mixinMonitoringContext(DebugLogger.mixinDebugLogger("fluid:telemetry", loaderProps.logger, {
|
|
95
|
+
all: telemetryProps,
|
|
96
|
+
}), sessionStorageConfigProvider.value, loaderProps.configProvider);
|
|
93
97
|
this.services = {
|
|
94
98
|
urlResolver: createCachedResolver(MultiUrlResolver.create(loaderProps.urlResolver)),
|
|
95
99
|
documentServiceFactory: MultiDocumentServiceFactory.create(loaderProps.documentServiceFactory),
|
|
@@ -102,7 +106,9 @@ export class Loader {
|
|
|
102
106
|
this.mc = loggerToMonitoringContext(ChildLogger.create(this.services.subLogger, "Loader"));
|
|
103
107
|
this.protocolHandlerBuilder = loaderProps.protocolHandlerBuilder;
|
|
104
108
|
}
|
|
105
|
-
get IFluidRouter() {
|
|
109
|
+
get IFluidRouter() {
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
106
112
|
async createDetachedContainer(codeDetails) {
|
|
107
113
|
const container = await Container.createDetached(this, codeDetails, this.protocolHandlerBuilder);
|
|
108
114
|
if (this.cachingEnabled) {
|
|
@@ -141,7 +147,8 @@ export class Loader {
|
|
|
141
147
|
}
|
|
142
148
|
addToContainerCache(key, containerP) {
|
|
143
149
|
this.containers.set(key, containerP);
|
|
144
|
-
containerP
|
|
150
|
+
containerP
|
|
151
|
+
.then((container) => {
|
|
145
152
|
// If the container is closed or becomes closed after we resolve it, remove it from the cache.
|
|
146
153
|
if (container.closed) {
|
|
147
154
|
this.containers.delete(key);
|
|
@@ -151,7 +158,8 @@ export class Loader {
|
|
|
151
158
|
this.containers.delete(key);
|
|
152
159
|
});
|
|
153
160
|
}
|
|
154
|
-
})
|
|
161
|
+
})
|
|
162
|
+
.catch((error) => { });
|
|
155
163
|
}
|
|
156
164
|
async resolveCore(request, pendingLocalState) {
|
|
157
165
|
const resolvedAsFluid = await this.services.urlResolver.resolve(request);
|
|
@@ -185,8 +193,7 @@ export class Loader {
|
|
|
185
193
|
}
|
|
186
194
|
}
|
|
187
195
|
else {
|
|
188
|
-
container =
|
|
189
|
-
await this.loadContainer(request, resolvedAsFluid, pendingLocalState);
|
|
196
|
+
container = await this.loadContainer(request, resolvedAsFluid, pendingLocalState);
|
|
190
197
|
}
|
|
191
198
|
if (container.deltaManager.lastSequenceNumber <= fromSequenceNumber) {
|
|
192
199
|
await new Promise((resolve, reject) => {
|
|
@@ -216,7 +223,8 @@ export class Loader {
|
|
|
216
223
|
fromSequenceNumber = headerSeqNum;
|
|
217
224
|
}
|
|
218
225
|
// If set in both query string and headers, use query string
|
|
219
|
-
request.headers[LoaderHeader.version] =
|
|
226
|
+
request.headers[LoaderHeader.version] =
|
|
227
|
+
(_b = parsed.version) !== null && _b !== void 0 ? _b : request.headers[LoaderHeader.version];
|
|
220
228
|
const canCache = this.canCacheForRequest(request.headers);
|
|
221
229
|
return {
|
|
222
230
|
canCache,
|
package/lib/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","source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A2B,EAC3B,iBAA0C;;QAE1C,OAAO,SAAS,CAAC,IAAI,CACpB,IAAI,EACJ;YACC,YAAY,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,SAAS,CAAC;YACvD,qBAAqB,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,aAAa,CAAC;YACpE,WAAW,EAAE,QAAQ;YACrB,OAAO,EAAE,MAAA,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,OAAO,CAAC,mCAAI,SAAS;YAC7D,QAAQ,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,QAAQ,CAAC;YAClD,UAAU,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAG,mBAAmB,CAAC;SAClD,EACD,iBAAiB,EACjB,IAAI,CAAC,sBAAsB,CAC3B,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { 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 ILoaderOptions as ILoaderOptions1,\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, IPendingContainerState } from \"./container\";\nimport { IParsedUrl, parseUrl } from \"./utils\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { ProtocolHandlerBuilder } from \"./protocol\";\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-definitions#IFluidModuleWithDetails}\n * to have all the code loading modules in one package. #8193\n * Encapsulates a module entry point with corresponding code details.\n */\nexport interface IFluidModuleWithDetails {\n /** 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 * 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 * Optional property for allowing the container to use a custom\n * protocol implementation for handling the quorum and/or the audience.\n */\n readonly protocolHandlerBuilder?: ProtocolHandlerBuilder;\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 * 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 private readonly protocolHandlerBuilder: ProtocolHandlerBuilder | undefined;\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 detachedBlobStorage: loaderProps.detachedBlobStorage,\n };\n this.mc = loggerToMonitoringContext(\n ChildLogger.create(this.services.subLogger, \"Loader\"));\n this.protocolHandlerBuilder = loaderProps.protocolHandlerBuilder;\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 this.protocolHandlerBuilder,\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, this.protocolHandlerBuilder);\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?: IPendingContainerState,\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);\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\tprivate async loadContainer(\n\t\trequest: IRequest,\n\t\tresolved: IFluidResolvedUrl,\n\t\tpendingLocalState?: IPendingContainerState,\n\t): Promise<Container> {\n\t\treturn Container.load(\n\t\t\tthis,\n\t\t\t{\n\t\t\t\tcanReconnect: request.headers?.[LoaderHeader.reconnect],\n\t\t\t\tclientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n\t\t\t\tresolvedUrl: resolved,\n\t\t\t\tversion: request.headers?.[LoaderHeader.version] ?? undefined,\n\t\t\t\tloadMode: request.headers?.[LoaderHeader.loadMode],\n\t\t\t\tbaseLogger: request.headers?.[\"fluid-base-logger\"],\n\t\t\t},\n\t\t\tpendingLocalState,\n\t\t\tthis.protocolHandlerBuilder,\n\t\t);\n\t}\n}\n"]}
|
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AiB,EACjB,QAA2B,EAC3B,iBAA0C;;QAE1C,OAAO,SAAS,CAAC,IAAI,CACpB,IAAI,EACJ;YACC,YAAY,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,SAAS,CAAC;YACvD,qBAAqB,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,aAAa,CAAC;YACpE,WAAW,EAAE,QAAQ;YACrB,OAAO,EAAE,MAAA,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,OAAO,CAAC,mCAAI,SAAS;YAC7D,QAAQ,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,QAAQ,CAAC;YAClD,UAAU,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAG,mBAAmB,CAAC;SAClD,EACD,iBAAiB,EACjB,IAAI,CAAC,sBAAsB,CAC3B,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n\tFluidObject,\n\tIFluidRouter,\n\tIRequest,\n\tIRequestHeader,\n\tIResponse,\n} from \"@fluidframework/core-interfaces\";\nimport {\n\tIContainer,\n\tIFluidModule,\n\tIHostLoader,\n\tILoader,\n\tILoaderOptions as ILoaderOptions1,\n\tLoaderHeader,\n\tIProvideFluidCodeDetailsComparer,\n\tIFluidCodeDetails,\n} from \"@fluidframework/container-definitions\";\nimport {\n\tChildLogger,\n\tDebugLogger,\n\tIConfigProviderBase,\n\tloggerToMonitoringContext,\n\tmixinMonitoringContext,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tsessionStorageConfigProvider,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n\tIDocumentServiceFactory,\n\tIDocumentStorageService,\n\tIFluidResolvedUrl,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\tensureFluidResolvedUrl,\n\tMultiUrlResolver,\n\tMultiDocumentServiceFactory,\n} from \"@fluidframework/driver-utils\";\nimport { Container, IPendingContainerState } from \"./container\";\nimport { IParsedUrl, parseUrl } from \"./utils\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { ProtocolHandlerBuilder } from \"./protocol\";\n\nfunction canUseCache(request: IRequest): boolean {\n\tif (request.headers === undefined) {\n\t\treturn true;\n\t}\n\n\treturn request.headers[LoaderHeader.cache] !== false;\n}\n\nexport class RelativeLoader implements ILoader {\n\tconstructor(\n\t\tprivate readonly container: Container,\n\t\tprivate readonly loader: ILoader | undefined,\n\t) {}\n\n\tpublic get IFluidRouter(): IFluidRouter {\n\t\treturn this;\n\t}\n\n\tpublic async resolve(request: IRequest): Promise<IContainer> {\n\t\tif (request.url.startsWith(\"/\")) {\n\t\t\tif (canUseCache(request)) {\n\t\t\t\treturn this.container;\n\t\t\t} else {\n\t\t\t\tconst resolvedUrl = this.container.resolvedUrl;\n\t\t\t\tensureFluidResolvedUrl(resolvedUrl);\n\t\t\t\tconst container = await Container.load(this.loader as Loader, {\n\t\t\t\t\tcanReconnect: request.headers?.[LoaderHeader.reconnect],\n\t\t\t\t\tclientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n\t\t\t\t\tresolvedUrl: { ...resolvedUrl },\n\t\t\t\t\tversion: request.headers?.[LoaderHeader.version] ?? undefined,\n\t\t\t\t\tloadMode: request.headers?.[LoaderHeader.loadMode],\n\t\t\t\t});\n\t\t\t\treturn container;\n\t\t\t}\n\t\t}\n\n\t\tif (this.loader === undefined) {\n\t\t\tthrow new Error(\"Cannot resolve external containers\");\n\t\t}\n\t\treturn this.loader.resolve(request);\n\t}\n\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\tif (request.url.startsWith(\"/\")) {\n\t\t\tconst container = await this.resolve(request);\n\t\t\treturn container.request(request);\n\t\t}\n\n\t\tif (this.loader === undefined) {\n\t\t\treturn {\n\t\t\t\tstatus: 404,\n\t\t\t\tvalue: \"Cannot request external containers\",\n\t\t\t\tmimeType: \"plain/text\",\n\t\t\t};\n\t\t}\n\t\treturn this.loader.request(request);\n\t}\n}\n\nfunction createCachedResolver(resolver: IUrlResolver) {\n\tconst cacheResolver = Object.create(resolver) as IUrlResolver;\n\tconst resolveCache = new Map<string, Promise<IResolvedUrl | undefined>>();\n\tcacheResolver.resolve = async (request: IRequest): Promise<IResolvedUrl | undefined> => {\n\t\tif (!canUseCache(request)) {\n\t\t\treturn resolver.resolve(request);\n\t\t}\n\t\tif (!resolveCache.has(request.url)) {\n\t\t\tresolveCache.set(request.url, resolver.resolve(request));\n\t\t}\n\n\t\treturn resolveCache.get(request.url);\n\t};\n\treturn cacheResolver;\n}\n\nexport interface ILoaderOptions extends ILoaderOptions1 {\n\tsummarizeProtocolTree?: boolean;\n}\n\n/**\n * @deprecated IFluidModuleWithDetails interface is moved to\n * {@link @fluidframework/container-definitions#IFluidModuleWithDetails}\n * to have all the code loading modules in one package. #8193\n * Encapsulates a module entry point with corresponding code details.\n */\nexport interface IFluidModuleWithDetails {\n\t/** Fluid code module that implements the runtime factory needed to instantiate the container runtime. */\n\tmodule: IFluidModule;\n\t/**\n\t * Code details associated with the module. Represents a document schema this module supports.\n\t * If the code loader implements the {@link @fluidframework/core-interfaces#IFluidCodeDetailsComparer} interface,\n\t * it'll be called to determine whether the module code details satisfy the new code proposal in the quorum.\n\t */\n\tdetails: IFluidCodeDetails;\n}\n\n/**\n * @deprecated ICodeDetailsLoader interface is moved to {@link @fluidframework/container-definition#ICodeDetailsLoader}\n * to have code loading modules in one package. #8193\n * Fluid code loader resolves a code module matching the document schema, i.e. code details, such as\n * a package name and package version range.\n */\nexport interface ICodeDetailsLoader extends Partial<IProvideFluidCodeDetailsComparer> {\n\t/**\n\t * Load the code module (package) that is capable to interact with the document.\n\t *\n\t * @param source - Code proposal that articulates the current schema the document is written in.\n\t * @returns - Code module entry point along with the code details associated with it.\n\t */\n\tload(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;\n}\n\n/**\n * Services and properties necessary for creating a loader\n */\nexport interface ILoaderProps {\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options used by various layers\n\t * to control features\n\t */\n\treadonly options?: ILoaderOptions;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope?: FluidObject;\n\n\t/**\n\t * The logger that all telemetry should be pushed to.\n\t */\n\treadonly logger?: ITelemetryBaseLogger;\n\n\t/**\n\t * Blobs storage for detached containers.\n\t */\n\treadonly detachedBlobStorage?: IDetachedBlobStorage;\n\n\t/**\n\t * The configuration provider which may be used to control features.\n\t */\n\treadonly configProvider?: IConfigProviderBase;\n\n\t/**\n\t * Optional property for allowing the container to use a custom\n\t * protocol implementation for handling the quorum and/or the audience.\n\t */\n\treadonly protocolHandlerBuilder?: ProtocolHandlerBuilder;\n}\n\n/**\n * Services and properties used by and exposed by the loader\n */\nexport interface ILoaderServices {\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options used by various layers\n\t * to control features\n\t */\n\treadonly options: ILoaderOptions;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope: FluidObject;\n\n\t/**\n\t * The logger downstream consumers should construct their loggers from\n\t */\n\treadonly subLogger: ITelemetryLogger;\n\n\t/**\n\t * Blobs storage for detached containers.\n\t */\n\treadonly 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\tsize: number;\n\t/**\n\t * Return an array of all blob IDs present in storage\n\t */\n\tgetBlobIds(): string[];\n};\n\n/**\n * Manages Fluid resource loading\n */\nexport class Loader implements IHostLoader {\n\tprivate readonly containers = new Map<string, Promise<Container>>();\n\tpublic readonly services: ILoaderServices;\n\tprivate readonly mc: MonitoringContext;\n\tprivate readonly protocolHandlerBuilder: ProtocolHandlerBuilder | undefined;\n\n\tconstructor(loaderProps: ILoaderProps) {\n\t\tconst scope: FluidObject<ILoader> = { ...loaderProps.scope };\n\t\tif (loaderProps.options?.provideScopeLoader !== false) {\n\t\t\tscope.ILoader = this;\n\t\t}\n\t\tconst telemetryProps = {\n\t\t\tloaderId: uuid(),\n\t\t\tloaderVersion: pkgVersion,\n\t\t};\n\n\t\tconst subMc = mixinMonitoringContext(\n\t\t\tDebugLogger.mixinDebugLogger(\"fluid:telemetry\", loaderProps.logger, {\n\t\t\t\tall: telemetryProps,\n\t\t\t}),\n\t\t\tsessionStorageConfigProvider.value,\n\t\t\tloaderProps.configProvider,\n\t\t);\n\n\t\tthis.services = {\n\t\t\turlResolver: createCachedResolver(MultiUrlResolver.create(loaderProps.urlResolver)),\n\t\t\tdocumentServiceFactory: MultiDocumentServiceFactory.create(\n\t\t\t\tloaderProps.documentServiceFactory,\n\t\t\t),\n\t\t\tcodeLoader: loaderProps.codeLoader,\n\t\t\toptions: loaderProps.options ?? {},\n\t\t\tscope,\n\t\t\tsubLogger: subMc.logger,\n\t\t\tdetachedBlobStorage: loaderProps.detachedBlobStorage,\n\t\t};\n\t\tthis.mc = loggerToMonitoringContext(ChildLogger.create(this.services.subLogger, \"Loader\"));\n\t\tthis.protocolHandlerBuilder = loaderProps.protocolHandlerBuilder;\n\t}\n\n\tpublic get IFluidRouter(): IFluidRouter {\n\t\treturn this;\n\t}\n\n\tpublic async createDetachedContainer(codeDetails: IFluidCodeDetails): Promise<IContainer> {\n\t\tconst container = await Container.createDetached(\n\t\t\tthis,\n\t\t\tcodeDetails,\n\t\t\tthis.protocolHandlerBuilder,\n\t\t);\n\n\t\tif (this.cachingEnabled) {\n\t\t\tcontainer.once(\"attached\", () => {\n\t\t\t\tensureFluidResolvedUrl(container.resolvedUrl);\n\t\t\t\tconst parsedUrl = parseUrl(container.resolvedUrl.url);\n\t\t\t\tif (parsedUrl !== undefined) {\n\t\t\t\t\tthis.addToContainerCache(parsedUrl.id, Promise.resolve(container));\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn container;\n\t}\n\n\tpublic async rehydrateDetachedContainerFromSnapshot(snapshot: string): Promise<IContainer> {\n\t\treturn Container.rehydrateDetachedFromSnapshot(this, snapshot, this.protocolHandlerBuilder);\n\t}\n\n\tpublic async resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer> {\n\t\tconst eventName = pendingLocalState === undefined ? \"Resolve\" : \"ResolveWithPendingState\";\n\t\treturn PerformanceEvent.timedExecAsync(this.mc.logger, { eventName }, async () => {\n\t\t\tconst resolved = await this.resolveCore(\n\t\t\t\trequest,\n\t\t\t\tpendingLocalState !== undefined ? JSON.parse(pendingLocalState) : undefined,\n\t\t\t);\n\t\t\treturn resolved.container;\n\t\t});\n\t}\n\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{ eventName: \"Request\" },\n\t\t\tasync () => {\n\t\t\t\tconst resolved = await this.resolveCore(request);\n\t\t\t\treturn resolved.container.request({\n\t\t\t\t\t...request,\n\t\t\t\t\turl: `${resolved.parsed.path}${resolved.parsed.query}`,\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate getKeyForContainerCache(request: IRequest, parsedUrl: IParsedUrl): string {\n\t\tconst key =\n\t\t\trequest.headers?.[LoaderHeader.version] !== undefined\n\t\t\t\t? `${parsedUrl.id}@${request.headers[LoaderHeader.version]}`\n\t\t\t\t: parsedUrl.id;\n\t\treturn key;\n\t}\n\n\tprivate addToContainerCache(key: string, containerP: Promise<Container>) {\n\t\tthis.containers.set(key, containerP);\n\t\tcontainerP\n\t\t\t.then((container) => {\n\t\t\t\t// If the container is closed or becomes closed after we resolve it, remove it from the cache.\n\t\t\t\tif (container.closed) {\n\t\t\t\t\tthis.containers.delete(key);\n\t\t\t\t} else {\n\t\t\t\t\tcontainer.once(\"closed\", () => {\n\t\t\t\t\t\tthis.containers.delete(key);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch((error) => {});\n\t}\n\n\tprivate async resolveCore(\n\t\trequest: IRequest,\n\t\tpendingLocalState?: IPendingContainerState,\n\t): Promise<{ container: Container; parsed: IParsedUrl }> {\n\t\tconst resolvedAsFluid = await this.services.urlResolver.resolve(request);\n\t\tensureFluidResolvedUrl(resolvedAsFluid);\n\n\t\t// Parse URL into data stores\n\t\tconst parsed = parseUrl(resolvedAsFluid.url);\n\t\tif (parsed === undefined) {\n\t\t\tthrow new Error(`Invalid URL ${resolvedAsFluid.url}`);\n\t\t}\n\n\t\tif (pendingLocalState !== undefined) {\n\t\t\tconst parsedPendingUrl = parseUrl(pendingLocalState.url);\n\t\t\tif (\n\t\t\t\tparsedPendingUrl?.id !== parsed.id ||\n\t\t\t\tparsedPendingUrl?.path.replace(/\\/$/, \"\") !== parsed.path.replace(/\\/$/, \"\")\n\t\t\t) {\n\t\t\t\tconst message = `URL ${resolvedAsFluid.url} does not match pending state URL ${pendingLocalState.url}`;\n\t\t\t\tthrow new Error(message);\n\t\t\t}\n\t\t}\n\n\t\tconst { canCache, fromSequenceNumber } = this.parseHeader(parsed, request);\n\t\tconst shouldCache = pendingLocalState !== undefined ? false : canCache;\n\n\t\tlet container: Container;\n\t\tif (shouldCache) {\n\t\t\tconst key = this.getKeyForContainerCache(request, parsed);\n\t\t\tconst maybeContainer = await this.containers.get(key);\n\t\t\tif (maybeContainer !== undefined) {\n\t\t\t\tcontainer = maybeContainer;\n\t\t\t} else {\n\t\t\t\tconst containerP = this.loadContainer(request, resolvedAsFluid);\n\t\t\t\tthis.addToContainerCache(key, containerP);\n\t\t\t\tcontainer = await containerP;\n\t\t\t}\n\t\t} else {\n\t\t\tcontainer = await this.loadContainer(request, resolvedAsFluid, pendingLocalState);\n\t\t}\n\n\t\tif (container.deltaManager.lastSequenceNumber <= fromSequenceNumber) {\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\tfunction opHandler(message: ISequencedDocumentMessage) {\n\t\t\t\t\tif (message.sequenceNumber > fromSequenceNumber) {\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t\tcontainer.removeListener(\"op\", opHandler);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tcontainer.on(\"op\", opHandler);\n\t\t\t});\n\t\t}\n\n\t\treturn { container, parsed };\n\t}\n\n\tprivate get cachingEnabled() {\n\t\treturn this.services.options.cache !== false;\n\t}\n\n\tprivate canCacheForRequest(headers: IRequestHeader): boolean {\n\t\treturn this.cachingEnabled && headers[LoaderHeader.cache] !== false;\n\t}\n\n\tprivate parseHeader(parsed: IParsedUrl, request: IRequest) {\n\t\tlet fromSequenceNumber = -1;\n\n\t\trequest.headers = request.headers ?? {};\n\n\t\tconst headerSeqNum = request.headers[LoaderHeader.sequenceNumber];\n\t\tif (headerSeqNum !== undefined) {\n\t\t\tfromSequenceNumber = headerSeqNum;\n\t\t}\n\n\t\t// If set in both query string and headers, use query string\n\t\trequest.headers[LoaderHeader.version] =\n\t\t\tparsed.version ?? request.headers[LoaderHeader.version];\n\n\t\tconst canCache = this.canCacheForRequest(request.headers);\n\n\t\treturn {\n\t\t\tcanCache,\n\t\t\tfromSequenceNumber,\n\t\t};\n\t}\n\n\tprivate async loadContainer(\n\t\trequest: IRequest,\n\t\tresolved: IFluidResolvedUrl,\n\t\tpendingLocalState?: IPendingContainerState,\n\t): Promise<Container> {\n\t\treturn Container.load(\n\t\t\tthis,\n\t\t\t{\n\t\t\t\tcanReconnect: request.headers?.[LoaderHeader.reconnect],\n\t\t\t\tclientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n\t\t\t\tresolvedUrl: resolved,\n\t\t\t\tversion: request.headers?.[LoaderHeader.version] ?? undefined,\n\t\t\t\tloadMode: request.headers?.[LoaderHeader.loadMode],\n\t\t\t\tbaseLogger: request.headers?.[\"fluid-base-logger\"],\n\t\t\t},\n\t\t\tpendingLocalState,\n\t\t\tthis.protocolHandlerBuilder,\n\t\t);\n\t}\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/container-loader";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-internal.3.0
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.3.1.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export const pkgName = "@fluidframework/container-loader";
|
|
8
|
-
export const pkgVersion = "2.0.0-internal.3.0
|
|
8
|
+
export const pkgVersion = "2.0.0-internal.3.1.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,kCAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-loader\";\nexport const pkgVersion = \"2.0.0-internal.3.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,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-loader\";\nexport const pkgVersion = \"2.0.0-internal.3.1.0\";\n"]}
|
package/lib/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAEN,gBAAgB,IAAI,oBAAoB,EACxC,eAAe,EACf,iBAAiB,EACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,EAEzB,cAAc,EAEd,MAAM,sCAAsC,CAAC;AAI9C,oBAAY,UAAU;IACrB,UAAU,SAAS;IACnB,WAAW,UAAU;IACrB,KAAK,UAAU;CACf;AAED;;GAEG;AACH,oBAAY,sBAAsB,GAAG,CACpC,UAAU,EAAE,mBAAmB,EAC/B,QAAQ,EAAE,eAAe,EACzB,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,MAAM,KAC7C,gBAAgB,CAAC;AAEtB,MAAM,WAAW,gBAAiB,SAAQ,oBAAoB;IAC7D,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,aAAa,CAAC,OAAO,EAAE,cAAc,OAAE;CACvC;AAED,qBAAa,eAAgB,SAAQ,iBAAkB,YAAW,gBAAgB;IAKhF,QAAQ,CAAC,QAAQ,EAAE,cAAc;gBAHjC,UAAU,EAAE,mBAAmB,EAC/B,cAAc,EAAE,eAAe,EAC/B,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,MAAM,EACxC,QAAQ,EAAE,cAAc;IAsB3B,cAAc,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,GACZ,qBAAqB;IAoBjB,aAAa,CAAC,OAAO,EAAE,cAAc;CAgC5C"}
|
package/lib/protocol.js
CHANGED
package/lib/protocol.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AA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AC,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;iBAC9D;gBACD,MAAM;aACN;YACD,KAAK,UAAU,CAAC,WAAW,CAAC,CAAC;gBAC5B,MAAM,YAAY,GAAG,YAAY,CAAC,OAAiB,CAAC;gBACpD,2DAA2D;gBAC3D,IAAI,CAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,YAAY,CAAC,0CAAE,IAAI,MAAK,MAAM,EAAE;oBAC3D,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;iBACzC;gBACD,MAAM;aACN;YACD;gBACC,MAAM;SACP;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IAudienceOwner } from \"@fluidframework/container-definitions\";\nimport {\n\tILocalSequencedClient,\n\tIProtocolHandler as IBaseProtocolHandler,\n\tIQuorumSnapshot,\n\tProtocolOpHandler,\n} from \"@fluidframework/protocol-base\";\nimport {\n\tIDocumentAttributes,\n\tIProcessMessageResult,\n\tISequencedDocumentMessage,\n\tISignalClient,\n\tISignalMessage,\n\tMessageType,\n} from \"@fluidframework/protocol-definitions\";\nimport { canBeCoalescedByService } from \"@fluidframework/driver-utils\";\n\n// ADO: #1986: Start using enum from protocol-base.\nexport enum SignalType {\n\tClientJoin = \"join\", // same value as MessageType.ClientJoin,\n\tClientLeave = \"leave\", // same value as MessageType.ClientLeave,\n\tClear = \"clear\", // used only by client for synthetic signals\n}\n\n/**\n * Function to be used for creating a protocol handler.\n */\nexport type ProtocolHandlerBuilder = (\n\tattributes: IDocumentAttributes,\n\tsnapshot: IQuorumSnapshot,\n\tsendProposal: (key: string, value: any) => number,\n) => IProtocolHandler;\n\nexport interface IProtocolHandler extends IBaseProtocolHandler {\n\treadonly audience: IAudienceOwner;\n\tprocessSignal(message: ISignalMessage);\n}\n\nexport class ProtocolHandler extends ProtocolOpHandler implements IProtocolHandler {\n\tconstructor(\n\t\tattributes: IDocumentAttributes,\n\t\tquorumSnapshot: IQuorumSnapshot,\n\t\tsendProposal: (key: string, value: any) => number,\n\t\treadonly audience: IAudienceOwner,\n\t) {\n\t\tsuper(\n\t\t\tattributes.minimumSequenceNumber,\n\t\t\tattributes.sequenceNumber,\n\t\t\tattributes.term,\n\t\t\tquorumSnapshot.members,\n\t\t\tquorumSnapshot.proposals,\n\t\t\tquorumSnapshot.values,\n\t\t\tsendProposal,\n\t\t);\n\n\t\t// Join / leave signals are ignored for \"write\" clients in favor of join / leave ops\n\t\tthis.quorum.on(\"addMember\", (clientId, details) =>\n\t\t\taudience.addMember(clientId, details.client),\n\t\t);\n\t\tthis.quorum.on(\"removeMember\", (clientId) => audience.removeMember(clientId));\n\t\tfor (const [clientId, details] of this.quorum.getMembers()) {\n\t\t\tthis.audience.addMember(clientId, details.client);\n\t\t}\n\t}\n\n\tpublic processMessage(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t): IProcessMessageResult {\n\t\tconst client: ILocalSequencedClient | undefined = this.quorum.getMember(message.clientId);\n\n\t\t// Check and report if we're getting messages from a clientId that we previously\n\t\t// flagged as shouldHaveLeft, or from a client that's not in the quorum but should be\n\t\tif (message.clientId != null) {\n\t\t\tif (client === undefined && message.type !== MessageType.ClientJoin) {\n\t\t\t\t// pre-0.58 error message: messageClientIdMissingFromQuorum\n\t\t\t\tthrow new Error(\"Remote message's clientId is missing from the quorum\");\n\t\t\t}\n\n\t\t\tif (client?.shouldHaveLeft === true && !canBeCoalescedByService(message)) {\n\t\t\t\t// pre-0.58 error message: messageClientIdShouldHaveLeft\n\t\t\t\tthrow new Error(\"Remote message's clientId already should have left\");\n\t\t\t}\n\t\t}\n\n\t\treturn super.processMessage(message, local);\n\t}\n\n\tpublic processSignal(message: ISignalMessage) {\n\t\tconst innerContent = message.content as { content: any; type: string };\n\t\tswitch (innerContent.type) {\n\t\t\tcase SignalType.Clear: {\n\t\t\t\tconst members = this.audience.getMembers();\n\t\t\t\tfor (const [clientId, client] of members) {\n\t\t\t\t\tif (client.mode === \"read\") {\n\t\t\t\t\t\tthis.audience.removeMember(clientId);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SignalType.ClientJoin: {\n\t\t\t\tconst newClient = innerContent.content as ISignalClient;\n\t\t\t\t// Ignore write clients - quorum will control such clients.\n\t\t\t\tif (newClient.client.mode === \"read\") {\n\t\t\t\t\tthis.audience.addMember(newClient.clientId, newClient.client);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SignalType.ClientLeave: {\n\t\t\t\tconst leftClientId = innerContent.content as string;\n\t\t\t\t// Ignore write clients - quorum will control such clients.\n\t\t\t\tif (this.audience.getMember(leftClientId)?.mode === \"read\") {\n\t\t\t\t\tthis.audience.removeMember(leftClientId);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocolTreeDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/protocolTreeDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,
|
|
1
|
+
{"version":3,"file":"protocolTreeDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/protocolTreeDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE9F,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEpE,qBAAa,0BAA2B,YAAW,uBAAuB,EAAE,WAAW;IAErF,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,oBAAoB;gBADpB,sBAAsB,EAAE,uBAAuB,GAAG,WAAW,EAC7D,oBAAoB,EAAE,MAAM,YAAY;IAE1D,IAAW,QAAQ,6FAElB;IACD,IAAW,aAAa,WAEvB;IACD,IAAW,QAAQ,YAElB;IAED,eAAe,qMAAiF;IAChG,WAAW,yOAA6E;IACxF,UAAU,yGAA4E;IACtF,QAAQ,2CAA0E;IAClF,eAAe,mGAAiF;IAChG,OAAO,sCAAyE;IAE1E,wBAAwB,CAC7B,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;CAMlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocolTreeDocumentStorageService.js","sourceRoot":"","sources":["../src/protocolTreeDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"protocolTreeDocumentStorageService.js","sourceRoot":"","sources":["../src/protocolTreeDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAG5E,MAAM,OAAO,0BAA0B;IACtC,YACkB,sBAA6D,EAC7D,oBAAwC;QADxC,2BAAsB,GAAtB,sBAAsB,CAAuC;QAC7D,yBAAoB,GAApB,oBAAoB,CAAoB;QAY1D,oBAAe,GAAG,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAChG,gBAAW,GAAG,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACxF,eAAU,GAAG,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACtF,aAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAClF,oBAAe,GAAG,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAChG,YAAO,GAAG,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAhB7E,CAAC;IACJ,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAC7C,CAAC;IACD,IAAW,aAAa;QACvB,OAAO,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC;IAClD,CAAC;IACD,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAC7C,CAAC;IASD,KAAK,CAAC,wBAAwB,CAC7B,OAAqB,EACrB,OAAwB;QAExB,OAAO,IAAI,CAAC,sBAAsB,CAAC,wBAAwB,CAC1D,4BAA4B,CAAC,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,CAAC,EAClE,OAAO,CACP,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/common-definitions\";\nimport { IDocumentStorageService, ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { combineAppAndProtocolSummary } from \"@fluidframework/driver-utils\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\n\nexport class ProtocolTreeStorageService implements IDocumentStorageService, IDisposable {\n\tconstructor(\n\t\tprivate readonly internalStorageService: IDocumentStorageService & IDisposable,\n\t\tprivate readonly generateProtocolTree: () => ISummaryTree,\n\t) {}\n\tpublic get policies() {\n\t\treturn this.internalStorageService.policies;\n\t}\n\tpublic get repositoryUrl() {\n\t\treturn this.internalStorageService.repositoryUrl;\n\t}\n\tpublic get disposed() {\n\t\treturn this.internalStorageService.disposed;\n\t}\n\n\tgetSnapshotTree = this.internalStorageService.getSnapshotTree.bind(this.internalStorageService);\n\tgetVersions = this.internalStorageService.getVersions.bind(this.internalStorageService);\n\tcreateBlob = this.internalStorageService.createBlob.bind(this.internalStorageService);\n\treadBlob = this.internalStorageService.readBlob.bind(this.internalStorageService);\n\tdownloadSummary = this.internalStorageService.downloadSummary.bind(this.internalStorageService);\n\tdispose = this.internalStorageService.dispose.bind(this.internalStorageService);\n\n\tasync uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\treturn this.internalStorageService.uploadSummaryWithContext(\n\t\t\tcombineAppAndProtocolSummary(summary, this.generateProtocolTree()),\n\t\t\tcontext,\n\t\t);\n\t}\n}\n"]}
|
package/lib/quorum.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quorum.d.ts","sourceRoot":"","sources":["../src/quorum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAU,cAAc,EAAmB,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,
|
|
1
|
+
{"version":3,"file":"quorum.d.ts","sourceRoot":"","sources":["../src/quorum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAU,cAAc,EAAmB,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EACN,kBAAkB,EAClB,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,qBAAa,WAAY,SAAQ,cAAc,CAAC,aAAa,CAAE,YAAW,OAAO;IAChF,SAAgB,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,SAAgB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IAC9C,SAAgB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAC;IAC1C,SAAgB,UAAU,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAChE,SAAgB,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,gBAAgB,GAAG,SAAS,CAAC;gBAElE,MAAM,EAAE,OAAO;CAY3B;AAED,wBAAgB,8BAA8B,CAC7C,YAAY,EAAE,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,GAC1C,iBAAiB,CAKnB;AAED,wBAAgB,+BAA+B,CAC9C,MAAM,EAAE,iBAAiB,GACvB,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAUhC"}
|
package/lib/quorum.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quorum.js","sourceRoot":"","sources":["../src/quorum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AASvF;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,cAA6B;
|
|
1
|
+
{"version":3,"file":"quorum.js","sourceRoot":"","sources":["../src/quorum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AASvF;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,cAA6B;IAO7D,YAAY,MAAe;QAC1B,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,6EAA6E;QAC7E,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAE1B,IAAI,CAAC,OAAO,GAAG,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAClE,IAAI,CAAC,GAAG,GAAG,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1D,IAAI,CAAC,GAAG,GAAG,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1D,IAAI,CAAC,UAAU,GAAG,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QACxE,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACvE,CAAC;CACD;AAED,MAAM,UAAU,8BAA8B,CAC7C,YAA4C;IAE5C,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACxE,OAAO,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAA0B,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC9C,MAAyB;IAEzB,kEAAkE;IAClE,MAAM,qBAAqB,GAAuB;QACjD,GAAG,EAAE,MAAM;QACX,KAAK,EAAE,MAAM;QACb,sBAAsB,EAAE,CAAC;QACzB,oBAAoB,EAAE,CAAC;QACvB,cAAc,EAAE,CAAC;KACjB,CAAC;IACF,OAAO,CAAC,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { assert, EventForwarder, doIfNotDisposed } from \"@fluidframework/common-utils\";\nimport { IFluidCodeDetails } from \"@fluidframework/core-interfaces\";\nimport {\n\tICommittedProposal,\n\tIQuorum,\n\tIQuorumEvents,\n\tISequencedClient,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * Proxies Quorum events.\n */\nexport class QuorumProxy extends EventForwarder<IQuorumEvents> implements IQuorum {\n\tpublic readonly propose: (key: string, value: any) => Promise<void>;\n\tpublic readonly has: (key: string) => boolean;\n\tpublic readonly get: (key: string) => any;\n\tpublic readonly getMembers: () => Map<string, ISequencedClient>;\n\tpublic readonly getMember: (clientId: string) => ISequencedClient | undefined;\n\n\tconstructor(quorum: IQuorum) {\n\t\tsuper(quorum);\n\n\t\t// This is heavily used object, increase limit at which Node prints warnings.\n\t\tsuper.setMaxListeners(50);\n\n\t\tthis.propose = doIfNotDisposed(this, quorum.propose.bind(quorum));\n\t\tthis.has = doIfNotDisposed(this, quorum.has.bind(quorum));\n\t\tthis.get = doIfNotDisposed(this, quorum.get.bind(quorum));\n\t\tthis.getMembers = doIfNotDisposed(this, quorum.getMembers.bind(quorum));\n\t\tthis.getMember = doIfNotDisposed(this, quorum.getMember.bind(quorum));\n\t}\n}\n\nexport function getCodeDetailsFromQuorumValues(\n\tquorumValues: [string, ICommittedProposal][],\n): IFluidCodeDetails {\n\tconst qValuesMap = new Map(quorumValues);\n\tconst proposal = qValuesMap.get(\"code\");\n\tassert(proposal !== undefined, 0x2dc /* \"Cannot find code proposal\" */);\n\treturn proposal?.value as IFluidCodeDetails;\n}\n\nexport function initQuorumValuesFromCodeDetails(\n\tsource: IFluidCodeDetails,\n): [string, ICommittedProposal][] {\n\t// Seed the base quorum to be an empty list with a code quorum set\n\tconst committedCodeProposal: ICommittedProposal = {\n\t\tkey: \"code\",\n\t\tvalue: source,\n\t\tapprovalSequenceNumber: 0,\n\t\tcommitSequenceNumber: 0,\n\t\tsequenceNumber: 0,\n\t};\n\treturn [[\"code\", committedCodeProposal]];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retriableDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"retriableDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,WAAW,EACX,uBAAuB,EACvB,+BAA+B,EAC/B,eAAe,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGnF,qBAAa,+BAAgC,YAAW,uBAAuB,EAAE,WAAW;IAG1F,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHxB,OAAO,CAAC,SAAS,CAAS;gBAER,sBAAsB,EAAE,uBAAuB,EAC/C,MAAM,EAAE,gBAAgB;IAG1C,IAAW,QAAQ,IAAI,+BAA+B,GAAG,SAAS,CAEjE;IACD,IAAW,QAAQ,YAElB;IACM,OAAO;IAId,IAAW,aAAa,IAAI,MAAM,CAEjC;IAEY,eAAe,CAC3B,OAAO,CAAC,EAAE,QAAQ,EAClB,YAAY,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAOnB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAO9C,WAAW,CACvB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,WAAW,GACvB,OAAO,CAAC,QAAQ,EAAE,CAAC;IAaT,wBAAwB,CACpC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IAyBL,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAO9D,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO5E,OAAO,CAAC,oBAAoB;YAiBd,YAAY;CAM1B"}
|
|
@@ -14,7 +14,9 @@ export class RetriableDocumentStorageService {
|
|
|
14
14
|
get policies() {
|
|
15
15
|
return this.internalStorageService.policies;
|
|
16
16
|
}
|
|
17
|
-
get disposed() {
|
|
17
|
+
get disposed() {
|
|
18
|
+
return this._disposed;
|
|
19
|
+
}
|
|
18
20
|
dispose() {
|
|
19
21
|
this._disposed = true;
|
|
20
22
|
}
|
|
@@ -60,7 +62,9 @@ export class RetriableDocumentStorageService {
|
|
|
60
62
|
fetchCallName: callName, // fetchCallName matches logs in runWithRetry.ts
|
|
61
63
|
}, error);
|
|
62
64
|
// pre-0.58 error message: storageServiceDisposedCannotRetry
|
|
63
|
-
throw new GenericError("Storage Service is disposed. Cannot retry", {
|
|
65
|
+
throw new GenericError("Storage Service is disposed. Cannot retry", {
|
|
66
|
+
canRetry: false,
|
|
67
|
+
});
|
|
64
68
|
}
|
|
65
69
|
return;
|
|
66
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retriableDocumentStorageService.js","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAe/D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,MAAM,OAAO,+BAA+B;
|
|
1
|
+
{"version":3,"file":"retriableDocumentStorageService.js","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,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AgD;aACzE,EACD,KAAK,CACL,CAAC;YACF,4DAA4D;YAC5D,MAAM,IAAI,YAAY,CAAC,2CAA2C,EAAE;gBACnE,QAAQ,EAAE,KAAK;aACf,CAAC,CAAC;SACH;QACD,OAAO;IACR,CAAC;IAEO,KAAK,CAAC,YAAY,CAAI,GAAqB,EAAE,QAAgB;QACpE,OAAO,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE;YAC/C,OAAO,EAAE,CAAC,UAAkB,EAAE,KAAc,EAAE,EAAE,CAC/C,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,KAAK,CAAC;SAC3C,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { GenericError } from \"@fluidframework/container-utils\";\nimport {\n\tFetchSource,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IDisposable, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { runWithRetry } from \"@fluidframework/driver-utils\";\n\nexport class RetriableDocumentStorageService implements IDocumentStorageService, IDisposable {\n\tprivate _disposed = false;\n\tconstructor(\n\t\tprivate readonly internalStorageService: IDocumentStorageService,\n\t\tprivate readonly logger: ITelemetryLogger,\n\t) {}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\treturn this.internalStorageService.policies;\n\t}\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose() {\n\t\tthis._disposed = true;\n\t}\n\n\tpublic get repositoryUrl(): string {\n\t\treturn this.internalStorageService.repositoryUrl;\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageService.getSnapshotTree(version, scenarioName),\n\t\t\t\"storage_getSnapshotTree\",\n\t\t);\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageService.readBlob(id),\n\t\t\t\"storage_readBlob\",\n\t\t);\n\t}\n\n\tpublic async getVersions(\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageService.getVersions(\n\t\t\t\t\tversionId,\n\t\t\t\t\tcount,\n\t\t\t\t\tscenarioName,\n\t\t\t\t\tfetchSource,\n\t\t\t\t),\n\t\t\t\"storage_getVersions\",\n\t\t);\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\t// Not using retry loop here. Couple reasons:\n\t\t// 1. If client lost connectivity, then retry loop will result in uploading stale summary\n\t\t// by stale summarizer after connectivity comes back. It will cause failures for this client and for\n\t\t// real (new) summarizer. This problem in particular should be solved in future by supplying abort handle\n\t\t// on all APIs and caller (ContainerRuntime.submitSummary) aborting call on loss of connectivity\n\t\t// 2. Similar, if we get 429 with retryAfter = 10 minutes, it's likely not the right call to retry summary\n\t\t// upload in 10 minutes - it's better to keep processing ops and retry later. Though caller needs to take\n\t\t// retryAfter into account!\n\t\t// But retry loop is required for creation flow (Container.attach)\n\t\tassert(\n\t\t\t(context.referenceSequenceNumber === 0) === (context.ackHandle === undefined),\n\t\t\t0x251 /* \"creation summary has to have seq=0 && handle === undefined\" */,\n\t\t);\n\t\tif (context.referenceSequenceNumber !== 0) {\n\t\t\treturn this.internalStorageService.uploadSummaryWithContext(summary, context);\n\t\t}\n\n\t\t// Creation flow with attachment blobs - need to do retries!\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageService.uploadSummaryWithContext(summary, context),\n\t\t\t\"storage_uploadSummaryWithContext\",\n\t\t);\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageService.downloadSummary(handle),\n\t\t\t\"storage_downloadSummary\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageService.createBlob(file),\n\t\t\t\"storage_createBlob\",\n\t\t);\n\t}\n\n\tprivate checkStorageDisposed(callName: string, error: unknown) {\n\t\tif (this._disposed) {\n\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: `${callName}_abortedStorageDisposed`,\n\t\t\t\t\tfetchCallName: callName, // fetchCallName matches logs in runWithRetry.ts\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\t// pre-0.58 error message: storageServiceDisposedCannotRetry\n\t\t\tthrow new GenericError(\"Storage Service is disposed. Cannot retry\", {\n\t\t\t\tcanRetry: false,\n\t\t\t});\n\t\t}\n\t\treturn;\n\t}\n\n\tprivate async runWithRetry<T>(api: () => Promise<T>, callName: string): Promise<T> {\n\t\treturn runWithRetry(api, callName, this.logger, {\n\t\t\tonRetry: (_delayInMs: number, error: unknown) =>\n\t\t\t\tthis.checkStorageDisposed(callName, error),\n\t\t});\n\t}\n}\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;AAKhG,MAAM,WAAW,6BAA8B,SAAQ,aAAa;
|
|
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;AAKhG,MAAM,WAAW,6BAA8B,SAAQ,aAAa;IACnE,aAAa,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAA;KAAE,CAAC;IACnD,KAAK,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,6BAA6B,CAAA;KAAE,CAAC;CACzD;AAED,MAAM,WAAW,UAAU;IAC1B,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;CACnC;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAW5D;AA0DD;;;;GAIG;AACH,wBAAgB,0CAA0C,CACzD,mBAAmB,EAAE,YAAY,EACjC,cAAc,EAAE,YAAY,GAC1B,6BAA6B,CAW/B;AAID,eAAO,MAAM,sCAAsC,8BAA+B,YAAY,kCAY7F,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,aAAa,GAAG,aAAa,CAE9E"}
|
package/lib/utils.js
CHANGED
|
@@ -16,7 +16,7 @@ export function parseUrl(url) {
|
|
|
16
16
|
const query = (_a = parsed.search) !== null && _a !== void 0 ? _a : "";
|
|
17
17
|
const regex = /^\/([^/]*\/[^/]*)(\/?.*)$/;
|
|
18
18
|
const match = regex.exec(parsed.pathname);
|
|
19
|
-
return (
|
|
19
|
+
return (match === null || match === void 0 ? void 0 : match.length) === 3
|
|
20
20
|
? { id: match[1], path: match[2], query, version: parsed.query.version }
|
|
21
21
|
: undefined;
|
|
22
22
|
}
|
|
@@ -43,7 +43,8 @@ function convertSummaryToSnapshotWithEmbeddedBlobContents(summary) {
|
|
|
43
43
|
const summaryObject = summary.tree[key];
|
|
44
44
|
switch (summaryObject.type) {
|
|
45
45
|
case SummaryType.Tree: {
|
|
46
|
-
treeNode.trees[key] =
|
|
46
|
+
treeNode.trees[key] =
|
|
47
|
+
convertSummaryToSnapshotWithEmbeddedBlobContents(summaryObject);
|
|
47
48
|
break;
|
|
48
49
|
}
|
|
49
50
|
case SummaryType.Attachment:
|
|
@@ -52,8 +53,9 @@ function convertSummaryToSnapshotWithEmbeddedBlobContents(summary) {
|
|
|
52
53
|
case SummaryType.Blob: {
|
|
53
54
|
const blobId = uuid();
|
|
54
55
|
treeNode.blobs[key] = blobId;
|
|
55
|
-
const contentBuffer = typeof summaryObject.content === "string"
|
|
56
|
-
stringToBuffer(summaryObject.content, "utf8")
|
|
56
|
+
const contentBuffer = typeof summaryObject.content === "string"
|
|
57
|
+
? stringToBuffer(summaryObject.content, "utf8")
|
|
58
|
+
: Uint8ArrayToArrayBuffer(summaryObject.content);
|
|
57
59
|
treeNode.blobsContents[blobId] = contentBuffer;
|
|
58
60
|
break;
|
|
59
61
|
}
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAC5B,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAC5B,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EACN,MAAM,EACN,cAAc,EACd,uBAAuB,EACvB,eAAe,GACf,MAAM,8BAA8B,CAAC;A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DAAgD,CAAC,eAAe,CAAC,CAAC;IACnE,OAAO,4BAA4B,CAAC;AACrC,CAAC;AAED,+GAA+G;AAC/G,0CAA0C;AAC1C,MAAM,CAAC,MAAM,sCAAsC,GAAG,CAAC,yBAAuC,EAAE,EAAE;IACjG,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,IAAI,CAAC,WAAW,CAAiB,CAAC;IACxF,MAAM,cAAc,GAAG,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAiB,CAAC;IAC9E,MAAM,CACL,mBAAmB,KAAK,SAAS,IAAI,cAAc,KAAK,SAAS,EACjE,KAAK,CAAC,wDAAwD,CAC9D,CAAC;IACF,MAAM,4BAA4B,GAAG,0CAA0C,CAC9E,mBAAmB,EACnB,cAAc,CACd,CAAC;IACF,OAAO,4BAA4B,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,UAAU,uBAAuB,CAAC,QAAuB;IAC9D,OAAO,WAAW,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC/E,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\tassert,\n\tstringToBuffer,\n\tUint8ArrayToArrayBuffer,\n\tunreachableCase,\n} from \"@fluidframework/common-utils\";\nimport { ISummaryTree, ISnapshotTree, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { LoggingError } from \"@fluidframework/telemetry-utils\";\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\tblobsContents: { [path: string]: ArrayBufferLike };\n\ttrees: { [path: string]: ISnapshotTreeWithBlobContents };\n}\n\nexport interface IParsedUrl {\n\tid: string;\n\tpath: string;\n\tquery: string;\n\t/**\n\t * Null means do not use snapshots, undefined means load latest snapshot\n\t * otherwise it's version ID passed to IDocumentStorageService.getVersions() to figure out what snapshot to use.\n\t * If needed, can add undefined which is treated by Container.load() as load latest snapshot.\n\t */\n\tversion: string | null | undefined;\n}\n\nexport function parseUrl(url: string): IParsedUrl | undefined {\n\tconst parsed = parse(url, true);\n\tif (typeof parsed.pathname !== \"string\") {\n\t\tthrow new LoggingError(\"Failed to parse pathname\");\n\t}\n\tconst query = parsed.search ?? \"\";\n\tconst regex = /^\\/([^/]*\\/[^/]*)(\\/?.*)$/;\n\tconst match = regex.exec(parsed.pathname);\n\treturn match?.length === 3\n\t\t? { id: match[1], path: match[2], query, version: parsed.query.version as string }\n\t\t: 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\tsummary: ISummaryTree,\n): ISnapshotTreeWithBlobContents {\n\tconst treeNode: ISnapshotTreeWithBlobContents = {\n\t\tblobs: {},\n\t\tblobsContents: {},\n\t\ttrees: {},\n\t\tid: uuid(),\n\t\tunreferenced: summary.unreferenced,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\ttreeNode.trees[key] =\n\t\t\t\t\tconvertSummaryToSnapshotWithEmbeddedBlobContents(summaryObject);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Attachment:\n\t\t\t\ttreeNode.blobs[key] = summaryObject.id;\n\t\t\t\tbreak;\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tconst contentBuffer =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? stringToBuffer(summaryObject.content, \"utf8\")\n\t\t\t\t\t\t: Uint8ArrayToArrayBuffer(summaryObject.content);\n\t\t\t\ttreeNode.blobsContents[blobId] = contentBuffer;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\t\tthrow new LoggingError(\n\t\t\t\t\t\"No handles should be there in summary in detached container!!\",\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(summaryObject, `Unknown tree type ${(summaryObject as any).type}`);\n\t\t\t}\n\t\t}\n\t}\n\treturn 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\tprotocolSummaryTree: ISummaryTree,\n\tappSummaryTree: ISummaryTree,\n): ISnapshotTreeWithBlobContents {\n\t// Shallow copy is fine, since we are doing a deep clone below.\n\tconst combinedSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: { ...appSummaryTree.tree },\n\t};\n\n\tcombinedSummary.tree[\".protocol\"] = protocolSummaryTree;\n\tconst snapshotTreeWithBlobContents =\n\t\tconvertSummaryToSnapshotWithEmbeddedBlobContents(combinedSummary);\n\treturn 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\tconst protocolSummaryTree = detachedContainerSnapshot.tree[\".protocol\"] as ISummaryTree;\n\tconst appSummaryTree = detachedContainerSnapshot.tree[\".app\"] as ISummaryTree;\n\tassert(\n\t\tprotocolSummaryTree !== undefined && appSummaryTree !== undefined,\n\t\t0x1e0 /* \"Protocol and App summary trees should be present\" */,\n\t);\n\tconst snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToSnapshotTree(\n\t\tprotocolSummaryTree,\n\t\tappSummaryTree,\n\t);\n\treturn snapshotTreeWithBlobContents;\n};\n\nexport function getProtocolSnapshotTree(snapshot: ISnapshotTree): ISnapshotTree {\n\treturn \".protocol\" in snapshot.trees ? snapshot.trees[\".protocol\"] : snapshot;\n}\n"]}
|