@fluidframework/container-loader 1.2.2 → 2.0.0-internal.1.0.0.81589
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audience.d.ts +2 -2
- package/dist/audience.d.ts.map +1 -1
- package/dist/audience.js.map +1 -1
- package/dist/catchUpMonitor.d.ts +40 -0
- package/dist/catchUpMonitor.d.ts.map +1 -0
- package/dist/catchUpMonitor.js +74 -0
- package/dist/catchUpMonitor.js.map +1 -0
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +0 -1
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionState.d.ts +0 -5
- package/dist/connectionState.d.ts.map +1 -1
- package/dist/connectionState.js +0 -5
- package/dist/connectionState.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +12 -4
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +47 -15
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +8 -6
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +82 -46
- package/dist/container.js.map +1 -1
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +6 -6
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaManagerProxy.d.ts +4 -1
- package/dist/deltaManagerProxy.d.ts.map +1 -1
- package/dist/deltaQueue.d.ts +9 -2
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js +31 -26
- package/dist/deltaQueue.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +7 -0
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +4 -3
- package/dist/loader.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocol.d.ts +22 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +52 -0
- package/dist/protocol.js.map +1 -0
- package/lib/audience.d.ts +2 -2
- package/lib/audience.d.ts.map +1 -1
- package/lib/audience.js.map +1 -1
- package/lib/catchUpMonitor.d.ts +40 -0
- package/lib/catchUpMonitor.d.ts.map +1 -0
- package/lib/catchUpMonitor.js +69 -0
- package/lib/catchUpMonitor.js.map +1 -0
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +0 -1
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionState.d.ts +0 -5
- package/lib/connectionState.d.ts.map +1 -1
- package/lib/connectionState.js +0 -5
- package/lib/connectionState.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +12 -4
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +47 -15
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +8 -6
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +82 -46
- package/lib/container.js.map +1 -1
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +6 -6
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaManagerProxy.d.ts +4 -1
- package/lib/deltaManagerProxy.d.ts.map +1 -1
- package/lib/deltaQueue.d.ts +9 -2
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js +32 -27
- package/lib/deltaQueue.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/loader.d.ts +7 -0
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +4 -3
- package/lib/loader.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/protocol.d.ts +22 -0
- package/lib/protocol.d.ts.map +1 -0
- package/lib/protocol.js +48 -0
- package/lib/protocol.js.map +1 -0
- package/package.json +23 -15
- package/src/audience.ts +2 -2
- package/src/catchUpMonitor.ts +99 -0
- package/src/connectionManager.ts +0 -1
- package/src/connectionState.ts +0 -6
- package/src/connectionStateHandler.ts +55 -15
- package/src/container.ts +115 -63
- package/src/deltaManager.ts +6 -4
- package/src/deltaQueue.ts +34 -28
- package/src/index.ts +4 -0
- package/src/loader.ts +13 -2
- package/src/packageVersion.ts +1 -1
- package/src/protocol.ts +96 -0
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACH,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,MAAM,EACN,cAAc,GACjB,MAAM,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACH,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,MAAM,EACN,cAAc,GACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EACH,gBAAgB,EAChB,sBAAsB,GACzB,MAAM,YAAY,CAAC"}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACH,SAAS,EAIT,sBAAsB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAOH,MAAM,EACN,cAAc,GACjB,MAAM,UAAU,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ConnectionState } from \"./connectionState\";\nexport {\n Container,\n IContainerLoadOptions,\n IContainerConfig,\n IPendingContainerState,\n waitContainerToCatchUp,\n} from \"./container\";\nexport {\n ICodeDetailsLoader,\n IDetachedBlobStorage,\n IFluidModuleWithDetails,\n ILoaderOptions,\n ILoaderProps,\n ILoaderServices,\n Loader,\n RelativeLoader,\n} from \"./loader\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACH,SAAS,EAIT,sBAAsB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAOH,MAAM,EACN,cAAc,GACjB,MAAM,UAAU,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ConnectionState } from \"./connectionState\";\nexport {\n Container,\n IContainerLoadOptions,\n IContainerConfig,\n IPendingContainerState,\n waitContainerToCatchUp,\n} from \"./container\";\nexport {\n ICodeDetailsLoader,\n IDetachedBlobStorage,\n IFluidModuleWithDetails,\n ILoaderOptions,\n ILoaderProps,\n ILoaderServices,\n Loader,\n RelativeLoader,\n} from \"./loader\";\nexport {\n IProtocolHandler,\n ProtocolHandlerBuilder,\n} from \"./protocol\";\n"]}
|
package/lib/loader.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { IContainer, IFluidModule, IHostLoader, ILoader, ILoaderOptions as ILoad
|
|
|
8
8
|
import { IConfigProviderBase } from "@fluidframework/telemetry-utils";
|
|
9
9
|
import { IDocumentServiceFactory, IDocumentStorageService, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
10
10
|
import { Container } from "./container";
|
|
11
|
+
import { ProtocolHandlerBuilder } from "./protocol";
|
|
11
12
|
export declare class RelativeLoader implements ILoader {
|
|
12
13
|
private readonly container;
|
|
13
14
|
private readonly loader;
|
|
@@ -93,6 +94,11 @@ export interface ILoaderProps {
|
|
|
93
94
|
* The configuration provider which may be used to control features.
|
|
94
95
|
*/
|
|
95
96
|
readonly configProvider?: IConfigProviderBase;
|
|
97
|
+
/**
|
|
98
|
+
* Optional property for allowing the container to use a custom
|
|
99
|
+
* protocol implementation for handling the quorum and/or the audience.
|
|
100
|
+
*/
|
|
101
|
+
readonly protocolHandlerBuilder?: ProtocolHandlerBuilder;
|
|
96
102
|
}
|
|
97
103
|
/**
|
|
98
104
|
* Services and properties used by and exposed by the loader
|
|
@@ -152,6 +158,7 @@ export declare class Loader implements IHostLoader {
|
|
|
152
158
|
private readonly containers;
|
|
153
159
|
readonly services: ILoaderServices;
|
|
154
160
|
private readonly mc;
|
|
161
|
+
private readonly protocolHandlerBuilder;
|
|
155
162
|
constructor(loaderProps: ILoaderProps);
|
|
156
163
|
get IFluidRouter(): IFluidRouter;
|
|
157
164
|
createDetachedContainer(codeDetails: IFluidCodeDetails): Promise<IContainer>;
|
package/lib/loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC5F,OAAO,EACH,WAAW,EACX,YAAY,EACZ,QAAQ,EAER,SAAS,EACZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,UAAU,EACV,YAAY,EACZ,WAAW,EACX,OAAO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+100,11 @@ export class Loader {
|
|
|
100
100
|
detachedBlobStorage: loaderProps.detachedBlobStorage,
|
|
101
101
|
};
|
|
102
102
|
this.mc = loggerToMonitoringContext(ChildLogger.create(this.services.subLogger, "Loader"));
|
|
103
|
+
this.protocolHandlerBuilder = loaderProps.protocolHandlerBuilder;
|
|
103
104
|
}
|
|
104
105
|
get IFluidRouter() { return this; }
|
|
105
106
|
async createDetachedContainer(codeDetails) {
|
|
106
|
-
const container = await Container.createDetached(this, codeDetails);
|
|
107
|
+
const container = await Container.createDetached(this, codeDetails, this.protocolHandlerBuilder);
|
|
107
108
|
if (this.cachingEnabled) {
|
|
108
109
|
container.once("attached", () => {
|
|
109
110
|
ensureFluidResolvedUrl(container.resolvedUrl);
|
|
@@ -116,7 +117,7 @@ export class Loader {
|
|
|
116
117
|
return container;
|
|
117
118
|
}
|
|
118
119
|
async rehydrateDetachedContainerFromSnapshot(snapshot) {
|
|
119
|
-
return Container.rehydrateDetachedFromSnapshot(this, snapshot);
|
|
120
|
+
return Container.rehydrateDetachedFromSnapshot(this, snapshot, this.protocolHandlerBuilder);
|
|
120
121
|
}
|
|
121
122
|
async resolve(request, pendingLocalState) {
|
|
122
123
|
const eventName = pendingLocalState === undefined ? "Resolve" : "ResolveWithPendingState";
|
|
@@ -230,7 +231,7 @@ export class Loader {
|
|
|
230
231
|
resolvedUrl: resolved,
|
|
231
232
|
version: (_d = (_c = request.headers) === null || _c === void 0 ? void 0 : _c[LoaderHeader.version]) !== null && _d !== void 0 ? _d : undefined,
|
|
232
233
|
loadMode: (_e = request.headers) === null || _e === void 0 ? void 0 : _e[LoaderHeader.loadMode],
|
|
233
|
-
}, pendingLocalState);
|
|
234
|
+
}, pendingLocalState, this.protocolHandlerBuilder);
|
|
234
235
|
}
|
|
235
236
|
}
|
|
236
237
|
//# sourceMappingURL=loader.js.map
|
package/lib/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["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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;SACrD,EACD,iBAAiB,CACpB,CAAC;IACN,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n FluidObject,\n IFluidRouter,\n IRequest,\n IRequestHeader,\n IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport {\n IContainer,\n IFluidModule,\n IHostLoader,\n ILoader,\n 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\";\n\nfunction canUseCache(request: IRequest): boolean {\n if (request.headers === undefined) {\n return true;\n }\n\n return request.headers[LoaderHeader.cache] !== false;\n}\n\nexport class RelativeLoader implements ILoader {\n constructor(\n private readonly container: Container,\n private readonly loader: ILoader | undefined,\n ) {\n }\n\n public get IFluidRouter(): IFluidRouter { return this; }\n\n public async resolve(request: IRequest): Promise<IContainer> {\n if (request.url.startsWith(\"/\")) {\n if (canUseCache(request)) {\n return this.container;\n } else {\n const resolvedUrl = this.container.resolvedUrl;\n ensureFluidResolvedUrl(resolvedUrl);\n const container = await Container.load(\n this.loader as Loader,\n {\n canReconnect: request.headers?.[LoaderHeader.reconnect],\n clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n resolvedUrl: { ...resolvedUrl },\n version: request.headers?.[LoaderHeader.version] ?? undefined,\n loadMode: request.headers?.[LoaderHeader.loadMode],\n },\n );\n return container;\n }\n }\n\n if (this.loader === undefined) {\n throw new Error(\"Cannot resolve external containers\");\n }\n return this.loader.resolve(request);\n }\n\n public async request(request: IRequest): Promise<IResponse> {\n if (request.url.startsWith(\"/\")) {\n const container = await this.resolve(request);\n return container.request(request);\n }\n\n if (this.loader === undefined) {\n return {\n status: 404,\n value: \"Cannot request external containers\",\n mimeType: \"plain/text\",\n };\n }\n return this.loader.request(request);\n }\n}\n\nfunction createCachedResolver(resolver: IUrlResolver) {\n const cacheResolver = Object.create(resolver) as IUrlResolver;\n const resolveCache = new Map<string, Promise<IResolvedUrl | undefined>>();\n cacheResolver.resolve = async (request: IRequest): Promise<IResolvedUrl | undefined> => {\n if (!canUseCache(request)) {\n return resolver.resolve(request);\n }\n if (!resolveCache.has(request.url)) {\n resolveCache.set(request.url, resolver.resolve(request));\n }\n\n return resolveCache.get(request.url);\n };\n return cacheResolver;\n}\n\nexport interface ILoaderOptions extends ILoaderOptions1 {\n summarizeProtocolTree?: boolean;\n}\n\n/**\n * @deprecated IFluidModuleWithDetails interface is moved to\n * {@link @fluidframework/container-definition#IFluidModuleWithDetails}\n * to have all the code loading modules in one package. #8193\n * Encapsulates a module entry point with corresponding code details.\n */\nexport interface IFluidModuleWithDetails {\n /** Fluid code module that implements the runtime factory needed to instantiate the container runtime. */\n module: IFluidModule;\n /**\n * Code details associated with the module. Represents a document schema this module supports.\n * If the code loader implements the {@link @fluidframework/core-interfaces#IFluidCodeDetailsComparer} interface,\n * it'll be called to determine whether the module code details satisfy the new code proposal in the quorum.\n */\n details: IFluidCodeDetails;\n}\n\n/**\n * @deprecated ICodeDetailsLoader interface is moved to {@link @fluidframework/container-definition#ICodeDetailsLoader}\n * to have code loading modules in one package. #8193\n * Fluid code loader resolves a code module matching the document schema, i.e. code details, such as\n * a package name and package version range.\n */\nexport interface ICodeDetailsLoader\n extends Partial<IProvideFluidCodeDetailsComparer> {\n /**\n * Load the code module (package) that is capable to interact with the document.\n *\n * @param source - Code proposal that articulates the current schema the document is written in.\n * @returns - Code module entry point along with the code details associated with it.\n */\n load(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;\n}\n\n/**\n * Services and properties necessary for creating a loader\n */\nexport interface ILoaderProps {\n /**\n * The url resolver used by the loader for resolving external urls\n * into Fluid urls such that the container specified by the\n * external url can be loaded.\n */\n readonly urlResolver: IUrlResolver;\n /**\n * The document service factory take the Fluid url provided\n * by the resolved url and constructs all the necessary services\n * for communication with the container's server.\n */\n readonly documentServiceFactory: IDocumentServiceFactory;\n /**\n * The code loader handles loading the necessary code\n * for running a container once it is loaded.\n */\n readonly codeLoader: ICodeDetailsLoader;\n\n /**\n * A property bag of options used by various layers\n * to control features\n */\n readonly options?: ILoaderOptions;\n\n /**\n * Scope is provided to all container and is a set of shared\n * services for container's to integrate with their host environment.\n */\n readonly scope?: FluidObject;\n\n /**\n * The logger that all telemetry should be pushed to.\n */\n readonly logger?: ITelemetryBaseLogger;\n\n /**\n * Blobs storage for detached containers.\n */\n readonly detachedBlobStorage?: IDetachedBlobStorage;\n\n /**\n * The configuration provider which may be used to control features.\n */\n readonly configProvider?: IConfigProviderBase;\n}\n\n/**\n * Services and properties used by and exposed by the loader\n */\nexport interface ILoaderServices {\n /**\n * The url resolver used by the loader for resolving external urls\n * into Fluid urls such that the container specified by the\n * external url can be loaded.\n */\n readonly urlResolver: IUrlResolver;\n /**\n * The document service factory take the Fluid url provided\n * by the resolved url and constructs all the necessary services\n * for communication with the container's server.\n */\n readonly documentServiceFactory: IDocumentServiceFactory;\n /**\n * The code loader handles loading the necessary code\n * for running a container once it is loaded.\n */\n readonly codeLoader: ICodeDetailsLoader;\n\n /**\n * A property bag of options used by various layers\n * to control features\n */\n readonly options: ILoaderOptions;\n\n /**\n * Scope is provided to all container and is a set of shared\n * services for container's to integrate with their host environment.\n */\n readonly scope: FluidObject;\n\n /**\n * The logger downstream consumers should construct their loggers from\n */\n readonly subLogger: ITelemetryLogger;\n\n /**\n * Blobs storage for detached containers.\n */\n readonly detachedBlobStorage?: IDetachedBlobStorage;\n}\n\n/**\n * Subset of IDocumentStorageService which only supports createBlob() and readBlob(). This is used to support\n * blobs in detached containers.\n */\nexport type IDetachedBlobStorage = Pick<IDocumentStorageService, \"createBlob\" | \"readBlob\"> & {\n size: number;\n /**\n * Return an array of all blob IDs present in storage\n */\n getBlobIds(): string[];\n };\n\n/**\n * Manages Fluid resource loading\n */\nexport class Loader implements IHostLoader {\n private readonly containers = new Map<string, Promise<Container>>();\n public readonly services: ILoaderServices;\n private readonly mc: MonitoringContext;\n\n constructor(loaderProps: ILoaderProps) {\n const scope: FluidObject<ILoader> = { ...loaderProps.scope };\n if (loaderProps.options?.provideScopeLoader !== false) {\n scope.ILoader = this;\n }\n const telemetryProps = {\n loaderId: uuid(),\n loaderVersion: pkgVersion,\n };\n\n const subMc = mixinMonitoringContext(\n DebugLogger.mixinDebugLogger(\"fluid:telemetry\", loaderProps.logger, { all: telemetryProps }),\n sessionStorageConfigProvider.value,\n loaderProps.configProvider,\n );\n\n this.services = {\n urlResolver: createCachedResolver(MultiUrlResolver.create(loaderProps.urlResolver)),\n documentServiceFactory: MultiDocumentServiceFactory.create(loaderProps.documentServiceFactory),\n codeLoader: loaderProps.codeLoader,\n options: loaderProps.options ?? {},\n scope,\n subLogger: subMc.logger,\n detachedBlobStorage: loaderProps.detachedBlobStorage,\n };\n this.mc = loggerToMonitoringContext(\n ChildLogger.create(this.services.subLogger, \"Loader\"));\n }\n\n public get IFluidRouter(): IFluidRouter { return this; }\n\n public async createDetachedContainer(codeDetails: IFluidCodeDetails): Promise<IContainer> {\n const container = await Container.createDetached(\n this,\n codeDetails,\n );\n\n if (this.cachingEnabled) {\n container.once(\"attached\", () => {\n ensureFluidResolvedUrl(container.resolvedUrl);\n const parsedUrl = parseUrl(container.resolvedUrl.url);\n if (parsedUrl !== undefined) {\n this.addToContainerCache(parsedUrl.id, Promise.resolve(container));\n }\n });\n }\n\n return container;\n }\n\n public async rehydrateDetachedContainerFromSnapshot(snapshot: string): Promise<IContainer> {\n return Container.rehydrateDetachedFromSnapshot(this, snapshot);\n }\n\n public async resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer> {\n const eventName = pendingLocalState === undefined ? \"Resolve\" : \"ResolveWithPendingState\";\n return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName }, async () => {\n const resolved = await this.resolveCore(\n request,\n pendingLocalState !== undefined ? JSON.parse(pendingLocalState) : undefined,\n );\n return resolved.container;\n });\n }\n\n public async request(request: IRequest): Promise<IResponse> {\n return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: \"Request\" }, async () => {\n const resolved = await this.resolveCore(request);\n return resolved.container.request({\n ...request,\n url: `${resolved.parsed.path}${resolved.parsed.query}`,\n });\n });\n }\n\n private getKeyForContainerCache(request: IRequest, parsedUrl: IParsedUrl): string {\n const key = request.headers?.[LoaderHeader.version] !== undefined\n ? `${parsedUrl.id}@${request.headers[LoaderHeader.version]}`\n : parsedUrl.id;\n return key;\n }\n\n private addToContainerCache(key: string, containerP: Promise<Container>) {\n this.containers.set(key, containerP);\n containerP.then((container) => {\n // If the container is closed or becomes closed after we resolve it, remove it from the cache.\n if (container.closed) {\n this.containers.delete(key);\n } else {\n container.once(\"closed\", () => {\n this.containers.delete(key);\n });\n }\n }).catch((error) => {});\n }\n\n private async resolveCore(\n request: IRequest,\n pendingLocalState?: 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 private async loadContainer(\n request: IRequest,\n resolved: IFluidResolvedUrl,\n pendingLocalState?: IPendingContainerState,\n ): Promise<Container> {\n return Container.load(\n this,\n {\n canReconnect: request.headers?.[LoaderHeader.reconnect],\n clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n resolvedUrl: resolved,\n version: request.headers?.[LoaderHeader.version] ?? undefined,\n loadMode: request.headers?.[LoaderHeader.loadMode],\n },\n pendingLocalState,\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AASlC,OAAO,EAMH,YAAY,GAGf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACH,WAAW,EACX,WAAW,EAEX,yBAAyB,EACzB,sBAAsB,EAEtB,gBAAgB,EAChB,4BAA4B,GAC/B,MAAM,iCAAiC,CAAC;AASzC,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EAChB,2BAA2B,GAC9B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAC;AAChE,OAAO,EAAc,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,SAAS,WAAW,CAAC,OAAiB;IAClC,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE;QAC/B,OAAO,IAAI,CAAC;KACf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B,GAAG,CAAC,CAAC,CAAC;QAE5B,OAAO,CAAC,OAAO,GAAG,MAAA,OAAO,CAAC,OAAO,mCAAI,EAAE,CAAC;QAExC,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;QAClE,IAAI,YAAY,KAAK,SAAS,EAAE;YAC5B,kBAAkB,GAAG,YAAY,CAAC;SACrC;QAED,4DAA4D;QAC5D,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,MAAA,MAAM,CAAC,OAAO,mCAAI,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAEhG,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAE1D,OAAO;YACH,QAAQ;YACR,kBAAkB;SACrB,CAAC;IACN,CAAC;IAEO,KAAK,CAAC,aAAa,CACvB,OAAiB,EACjB,QAA2B,EAC3B,iBAA0C;;QAE1C,OAAO,SAAS,CAAC,IAAI,CACjB,IAAI,EACJ;YACI,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;SACrD,EACD,iBAAiB,EACjB,IAAI,CAAC,sBAAsB,CAC9B,CAAC;IACN,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n FluidObject,\n IFluidRouter,\n IRequest,\n IRequestHeader,\n IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport {\n IContainer,\n IFluidModule,\n IHostLoader,\n ILoader,\n 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-definition#IFluidModuleWithDetails}\n * to have all the code loading modules in one package. #8193\n * Encapsulates a module entry point with corresponding code details.\n */\nexport interface IFluidModuleWithDetails {\n /** Fluid code module that implements the runtime factory needed to instantiate the container runtime. */\n module: IFluidModule;\n /**\n * Code details associated with the module. Represents a document schema this module supports.\n * If the code loader implements the {@link @fluidframework/core-interfaces#IFluidCodeDetailsComparer} interface,\n * it'll be called to determine whether the module code details satisfy the new code proposal in the quorum.\n */\n details: IFluidCodeDetails;\n}\n\n/**\n * @deprecated ICodeDetailsLoader interface is moved to {@link @fluidframework/container-definition#ICodeDetailsLoader}\n * to have code loading modules in one package. #8193\n * Fluid code loader resolves a code module matching the document schema, i.e. code details, such as\n * a package name and package version range.\n */\nexport interface ICodeDetailsLoader\n extends Partial<IProvideFluidCodeDetailsComparer> {\n /**\n * Load the code module (package) that is capable to interact with the document.\n *\n * @param source - Code proposal that articulates the current schema the document is written in.\n * @returns - Code module entry point along with the code details associated with it.\n */\n load(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;\n}\n\n/**\n * Services and properties necessary for creating a loader\n */\nexport interface ILoaderProps {\n /**\n * The url resolver used by the loader for resolving external urls\n * into Fluid urls such that the container specified by the\n * external url can be loaded.\n */\n readonly urlResolver: IUrlResolver;\n /**\n * The document service factory take the Fluid url provided\n * by the resolved url and constructs all the necessary services\n * for communication with the container's server.\n */\n readonly documentServiceFactory: IDocumentServiceFactory;\n /**\n * The code loader handles loading the necessary code\n * for running a container once it is loaded.\n */\n readonly codeLoader: ICodeDetailsLoader;\n\n /**\n * A property bag of options used by various layers\n * to control features\n */\n readonly options?: ILoaderOptions;\n\n /**\n * Scope is provided to all container and is a set of shared\n * services for container's to integrate with their host environment.\n */\n readonly scope?: FluidObject;\n\n /**\n * 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 private async loadContainer(\n request: IRequest,\n resolved: IFluidResolvedUrl,\n pendingLocalState?: IPendingContainerState,\n ): Promise<Container> {\n return Container.load(\n this,\n {\n canReconnect: request.headers?.[LoaderHeader.reconnect],\n clientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n resolvedUrl: resolved,\n version: request.headers?.[LoaderHeader.version] ?? undefined,\n loadMode: request.headers?.[LoaderHeader.loadMode],\n },\n pendingLocalState,\n this.protocolHandlerBuilder,\n );\n }\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/container-loader";
|
|
8
|
-
export declare const pkgVersion = "1.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.1.0.0.81589";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,qCAAqC,CAAC;AAC1D,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,qCAAqC,CAAC;AAC1D,eAAO,MAAM,UAAU,+BAA+B,CAAC"}
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,kCAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,UAAU,GAAG,
|
|
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,4BAA4B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-loader\";\nexport const pkgVersion = \"2.0.0-internal.1.0.0.81589\";\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IAudienceOwner } from "@fluidframework/container-definitions";
|
|
6
|
+
import { IProtocolHandler as IBaseProtocolHandler, IQuorumSnapshot, ProtocolOpHandler } from "@fluidframework/protocol-base";
|
|
7
|
+
import { IDocumentAttributes, IProcessMessageResult, ISequencedDocumentMessage, ISignalClient, ISignalMessage } from "@fluidframework/protocol-definitions";
|
|
8
|
+
/**
|
|
9
|
+
* Function to be used for creating a protocol handler.
|
|
10
|
+
*/
|
|
11
|
+
export declare type ProtocolHandlerBuilder = (attributes: IDocumentAttributes, snapshot: IQuorumSnapshot, sendProposal: (key: string, value: any) => number, initialClients: ISignalClient[]) => IProtocolHandler;
|
|
12
|
+
export interface IProtocolHandler extends IBaseProtocolHandler {
|
|
13
|
+
readonly audience: IAudienceOwner;
|
|
14
|
+
processSignal(message: ISignalMessage): any;
|
|
15
|
+
}
|
|
16
|
+
export declare class ProtocolHandler extends ProtocolOpHandler implements IProtocolHandler {
|
|
17
|
+
readonly audience: IAudienceOwner;
|
|
18
|
+
constructor(attributes: IDocumentAttributes, quorumSnapshot: IQuorumSnapshot, sendProposal: (key: string, value: any) => number, initialClients: ISignalClient[], audience: IAudienceOwner);
|
|
19
|
+
processMessage(message: ISequencedDocumentMessage, local: boolean): IProcessMessageResult;
|
|
20
|
+
processSignal(message: ISignalMessage): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +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,EAEH,gBAAgB,IAAI,oBAAoB,EACxC,eAAe,EACf,iBAAiB,EACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,EACb,cAAc,EAEjB,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,oBAAY,sBAAsB,GAAG,CACjC,UAAU,EAAE,mBAAmB,EAC/B,QAAQ,EAAE,eAAe,EACzB,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,MAAM,EACjD,cAAc,EAAE,aAAa,EAAE,KAC9B,gBAAgB,CAAC;AAEtB,MAAM,WAAW,gBAAiB,SAAQ,oBAAoB;IAC1D,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,aAAa,CAAC,OAAO,EAAE,cAAc,OAAE;CAC1C;AAED,qBAAa,eAAgB,SAAQ,iBAAkB,YAAW,gBAAgB;IAM1E,QAAQ,CAAC,QAAQ,EAAE,cAAc;gBAJjC,UAAU,EAAE,mBAAmB,EAC/B,cAAc,EAAE,eAAe,EAC/B,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,MAAM,EACjD,cAAc,EAAE,aAAa,EAAE,EACtB,QAAQ,EAAE,cAAc;IAiB9B,cAAc,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,GAAG,qBAAqB;IAoBzF,aAAa,CAAC,OAAO,EAAE,cAAc;CAgB/C"}
|
package/lib/protocol.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ProtocolOpHandler, } from "@fluidframework/protocol-base";
|
|
6
|
+
import { MessageType, } from "@fluidframework/protocol-definitions";
|
|
7
|
+
export class ProtocolHandler extends ProtocolOpHandler {
|
|
8
|
+
constructor(attributes, quorumSnapshot, sendProposal, initialClients, audience) {
|
|
9
|
+
super(attributes.minimumSequenceNumber, attributes.sequenceNumber, attributes.term, quorumSnapshot.members, quorumSnapshot.proposals, quorumSnapshot.values, sendProposal);
|
|
10
|
+
this.audience = audience;
|
|
11
|
+
for (const initialClient of initialClients) {
|
|
12
|
+
this.audience.addMember(initialClient.clientId, initialClient.client);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
processMessage(message, local) {
|
|
16
|
+
const client = this.quorum.getMember(message.clientId);
|
|
17
|
+
// Check and report if we're getting messages from a clientId that we previously
|
|
18
|
+
// flagged as shouldHaveLeft, or from a client that's not in the quorum but should be
|
|
19
|
+
if (message.clientId != null) {
|
|
20
|
+
if (client === undefined && message.type !== MessageType.ClientJoin) {
|
|
21
|
+
// pre-0.58 error message: messageClientIdMissingFromQuorum
|
|
22
|
+
throw new Error("Remote message's clientId is missing from the quorum");
|
|
23
|
+
}
|
|
24
|
+
if ((client === null || client === void 0 ? void 0 : client.shouldHaveLeft) === true && message.type !== MessageType.NoOp) {
|
|
25
|
+
// pre-0.58 error message: messageClientIdShouldHaveLeft
|
|
26
|
+
throw new Error("Remote message's clientId already should have left");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return super.processMessage(message, local);
|
|
30
|
+
}
|
|
31
|
+
processSignal(message) {
|
|
32
|
+
const innerContent = message.content;
|
|
33
|
+
switch (innerContent.type) {
|
|
34
|
+
case MessageType.ClientJoin: {
|
|
35
|
+
const newClient = innerContent.content;
|
|
36
|
+
this.audience.addMember(newClient.clientId, newClient.client);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case MessageType.ClientLeave: {
|
|
40
|
+
const leftClientId = innerContent.content;
|
|
41
|
+
this.audience.removeMember(leftClientId);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
default: break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAIH,iBAAiB,GACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAMH,WAAW,GACd,MAAM,sCAAsC,CAAC;AAiB9C,MAAM,OAAO,eAAgB,SAAQ,iBAAiB;IAClD,YACI,UAA+B,EAC/B,cAA+B,EAC/B,YAAiD,EACjD,cAA+B,EACtB,QAAwB;QAEjC,KAAK,CACD,UAAU,CAAC,qBAAqB,EAChC,UAAU,CAAC,cAAc,EACzB,UAAU,CAAC,IAAI,EACf,cAAc,CAAC,OAAO,EACtB,cAAc,CAAC,SAAS,EACxB,cAAc,CAAC,MAAM,EACrB,YAAY,CACf,CAAC;QAVO,aAAQ,GAAR,QAAQ,CAAgB;QAYjC,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE;YACxC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;SACzE;IACL,CAAC;IAEM,cAAc,CAAC,OAAkC,EAAE,KAAc;QACpE,MAAM,MAAM,GAAsC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE1F,gFAAgF;QAChF,qFAAqF;QACrF,IAAI,OAAO,CAAC,QAAQ,IAAI,IAAI,EAAE;YAC1B,IAAI,MAAM,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,UAAU,EAAE;gBACjE,2DAA2D;gBAC3D,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;aAC3E;YAED,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,MAAK,IAAI,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,EAAE;gBACtE,wDAAwD;gBACxD,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;aACzE;SACJ;QAED,OAAO,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC;IAEM,aAAa,CAAC,OAAuB;QACxC,MAAM,YAAY,GAAG,OAAO,CAAC,OAA0C,CAAC;QACxE,QAAQ,YAAY,CAAC,IAAI,EAAE;YACvB,KAAK,WAAW,CAAC,UAAU,CAAC,CAAC;gBACzB,MAAM,SAAS,GAAG,YAAY,CAAC,OAAwB,CAAC;gBACxD,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;gBAC9D,MAAM;aACT;YACD,KAAK,WAAW,CAAC,WAAW,CAAC,CAAC;gBAC1B,MAAM,YAAY,GAAG,YAAY,CAAC,OAAiB,CAAC;gBACpD,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;gBACzC,MAAM;aACT;YACD,OAAO,CAAC,CAAC,MAAM;SAClB;IACL,CAAC;CACJ","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 ILocalSequencedClient,\n IProtocolHandler as IBaseProtocolHandler,\n IQuorumSnapshot,\n ProtocolOpHandler,\n} from \"@fluidframework/protocol-base\";\nimport {\n IDocumentAttributes,\n IProcessMessageResult,\n ISequencedDocumentMessage,\n ISignalClient,\n ISignalMessage,\n MessageType,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * Function to be used for creating a protocol handler.\n */\nexport type ProtocolHandlerBuilder = (\n attributes: IDocumentAttributes,\n snapshot: IQuorumSnapshot,\n sendProposal: (key: string, value: any) => number,\n initialClients: ISignalClient[],\n) => IProtocolHandler;\n\nexport interface IProtocolHandler extends IBaseProtocolHandler {\n readonly audience: IAudienceOwner;\n processSignal(message: ISignalMessage);\n}\n\nexport class ProtocolHandler extends ProtocolOpHandler implements IProtocolHandler {\n constructor(\n attributes: IDocumentAttributes,\n quorumSnapshot: IQuorumSnapshot,\n sendProposal: (key: string, value: any) => number,\n initialClients: ISignalClient[],\n readonly audience: IAudienceOwner,\n ) {\n super(\n attributes.minimumSequenceNumber,\n attributes.sequenceNumber,\n attributes.term,\n quorumSnapshot.members,\n quorumSnapshot.proposals,\n quorumSnapshot.values,\n sendProposal,\n );\n\n for (const initialClient of initialClients) {\n this.audience.addMember(initialClient.clientId, initialClient.client);\n }\n }\n\n public processMessage(message: ISequencedDocumentMessage, local: boolean): IProcessMessageResult {\n const client: ILocalSequencedClient | undefined = this.quorum.getMember(message.clientId);\n\n // Check and report if we're getting messages from a clientId that we previously\n // flagged as shouldHaveLeft, or from a client that's not in the quorum but should be\n if (message.clientId != null) {\n if (client === undefined && message.type !== MessageType.ClientJoin) {\n // pre-0.58 error message: messageClientIdMissingFromQuorum\n throw new Error(\"Remote message's clientId is missing from the quorum\");\n }\n\n if (client?.shouldHaveLeft === true && message.type !== MessageType.NoOp) {\n // pre-0.58 error message: messageClientIdShouldHaveLeft\n throw new Error(\"Remote message's clientId already should have left\");\n }\n }\n\n return super.processMessage(message, local);\n }\n\n public processSignal(message: ISignalMessage) {\n const innerContent = message.content as { content: any; type: string; };\n switch (innerContent.type) {\n case MessageType.ClientJoin: {\n const newClient = innerContent.content as ISignalClient;\n this.audience.addMember(newClient.clientId, newClient.client);\n break;\n }\n case MessageType.ClientLeave: {\n const leftClientId = innerContent.content as string;\n this.audience.removeMember(leftClientId);\n break;\n }\n default: break;\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/container-loader",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.0.0-internal.1.0.0.81589",
|
|
4
4
|
"description": "Fluid container loader",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -63,26 +63,27 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
65
65
|
"@fluidframework/common-utils": "^0.32.1",
|
|
66
|
-
"@fluidframework/container-definitions": "
|
|
67
|
-
"@fluidframework/container-utils": "
|
|
68
|
-
"@fluidframework/core-interfaces": "
|
|
69
|
-
"@fluidframework/driver-definitions": "
|
|
70
|
-
"@fluidframework/driver-utils": "
|
|
71
|
-
"@fluidframework/protocol-base": "^0.
|
|
72
|
-
"@fluidframework/protocol-definitions": "^0.
|
|
73
|
-
"@fluidframework/telemetry-utils": "
|
|
66
|
+
"@fluidframework/container-definitions": "2.0.0-internal.1.0.0.81589",
|
|
67
|
+
"@fluidframework/container-utils": "2.0.0-internal.1.0.0.81589",
|
|
68
|
+
"@fluidframework/core-interfaces": "2.0.0-internal.1.0.0.81589",
|
|
69
|
+
"@fluidframework/driver-definitions": "2.0.0-internal.1.0.0.81589",
|
|
70
|
+
"@fluidframework/driver-utils": "2.0.0-internal.1.0.0.81589",
|
|
71
|
+
"@fluidframework/protocol-base": "^0.1037.1000-0",
|
|
72
|
+
"@fluidframework/protocol-definitions": "^0.1029.1000-0",
|
|
73
|
+
"@fluidframework/telemetry-utils": "2.0.0-internal.1.0.0.81589",
|
|
74
74
|
"abort-controller": "^3.0.0",
|
|
75
75
|
"double-ended-queue": "^2.1.0-0",
|
|
76
76
|
"lodash": "^4.17.21",
|
|
77
|
+
"url": "^0.11.0",
|
|
77
78
|
"uuid": "^8.3.1"
|
|
78
79
|
},
|
|
79
80
|
"devDependencies": {
|
|
80
81
|
"@fluidframework/build-common": "^0.24.0",
|
|
81
|
-
"@fluidframework/build-tools": "^0.
|
|
82
|
-
"@fluidframework/container-loader-previous": "npm:@fluidframework/container-loader
|
|
82
|
+
"@fluidframework/build-tools": "^0.3.0-0",
|
|
83
|
+
"@fluidframework/container-loader-previous": "npm:@fluidframework/container-loader@^1.0.0",
|
|
83
84
|
"@fluidframework/eslint-config-fluid": "^0.28.2000",
|
|
84
|
-
"@fluidframework/mocha-test-setup": "
|
|
85
|
-
"@fluidframework/test-loader-utils": "
|
|
85
|
+
"@fluidframework/mocha-test-setup": "2.0.0-internal.1.0.0.81589",
|
|
86
|
+
"@fluidframework/test-loader-utils": "2.0.0-internal.1.0.0.81589",
|
|
86
87
|
"@microsoft/api-extractor": "^7.22.2",
|
|
87
88
|
"@rushstack/eslint-config": "^2.5.1",
|
|
88
89
|
"@types/double-ended-queue": "^2.1.0",
|
|
@@ -102,7 +103,14 @@
|
|
|
102
103
|
"typescript-formatter": "7.1.0"
|
|
103
104
|
},
|
|
104
105
|
"typeValidation": {
|
|
105
|
-
"version": "
|
|
106
|
-
"broken": {
|
|
106
|
+
"version": "2.0.0",
|
|
107
|
+
"broken": {
|
|
108
|
+
"EnumDeclaration_ConnectionState": {
|
|
109
|
+
"forwardCompat": false
|
|
110
|
+
},
|
|
111
|
+
"ClassDeclaration_Container": {
|
|
112
|
+
"forwardCompat": false
|
|
113
|
+
}
|
|
114
|
+
}
|
|
107
115
|
}
|
|
108
116
|
}
|
package/src/audience.ts
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { EventEmitter } from "events";
|
|
6
|
-
import {
|
|
6
|
+
import { IAudienceOwner } from "@fluidframework/container-definitions";
|
|
7
7
|
import { IClient } from "@fluidframework/protocol-definitions";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Audience represents all clients connected to the op stream.
|
|
11
11
|
*/
|
|
12
|
-
export class Audience extends EventEmitter implements
|
|
12
|
+
export class Audience extends EventEmitter implements IAudienceOwner {
|
|
13
13
|
private readonly members = new Map<string, IClient>();
|
|
14
14
|
|
|
15
15
|
public on(event: "addMember" | "removeMember", listener: (clientId: string, client: IClient) => void): this;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IDisposable, IEvent } from "@fluidframework/common-definitions";
|
|
7
|
+
import { assert, TypedEventEmitter } from "@fluidframework/common-utils";
|
|
8
|
+
import { IDeltaManager } from "@fluidframework/container-definitions";
|
|
9
|
+
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
10
|
+
|
|
11
|
+
/** @see ICatchUpMonitor for usage */
|
|
12
|
+
type CaughtUpListener = () => void;
|
|
13
|
+
|
|
14
|
+
/** @see ICatchUpMonitor for usage */
|
|
15
|
+
export interface ICatchUpMonitorEvents extends IEvent {
|
|
16
|
+
(event: "caughtUp", listener: CaughtUpListener): void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Monitor that emits an event when a Container has caught up to a given point in the op stream */
|
|
20
|
+
export interface ICatchUpMonitor extends TypedEventEmitter<ICatchUpMonitorEvents>, IDisposable { }
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Monitors a Container's DeltaManager, notifying listeners when all ops have been processed
|
|
24
|
+
* that were known at the time the monitor was created.
|
|
25
|
+
*/
|
|
26
|
+
export class CatchUpMonitor extends TypedEventEmitter<ICatchUpMonitorEvents> implements ICatchUpMonitor {
|
|
27
|
+
private readonly targetSeqNumber: number;
|
|
28
|
+
private caughtUp: boolean = false;
|
|
29
|
+
|
|
30
|
+
private readonly opHandler = (message: Pick<ISequencedDocumentMessage, "sequenceNumber">) => {
|
|
31
|
+
if (!this.caughtUp && message.sequenceNumber >= this.targetSeqNumber) {
|
|
32
|
+
this.caughtUp = true;
|
|
33
|
+
this.emit("caughtUp");
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create the CatchUpMonitor, setting the target sequence number to wait for based on DeltaManager's current state.
|
|
39
|
+
*/
|
|
40
|
+
constructor(
|
|
41
|
+
private readonly deltaManager: IDeltaManager<any, any>,
|
|
42
|
+
) {
|
|
43
|
+
super();
|
|
44
|
+
|
|
45
|
+
this.targetSeqNumber = this.deltaManager.lastKnownSeqNumber;
|
|
46
|
+
|
|
47
|
+
assert(this.targetSeqNumber >= this.deltaManager.lastSequenceNumber,
|
|
48
|
+
"Cannot wait for seqNumber below last processed sequence number");
|
|
49
|
+
|
|
50
|
+
this.deltaManager.on("op", this.opHandler);
|
|
51
|
+
|
|
52
|
+
// Simulate the last processed op to set caughtUp in case we already are
|
|
53
|
+
this.opHandler({ sequenceNumber: this.deltaManager.lastSequenceNumber });
|
|
54
|
+
|
|
55
|
+
// If a listener is added after we are already caught up, notify that new listener immediately
|
|
56
|
+
this.on("newListener", (event: string, listener) => {
|
|
57
|
+
if (event === "caughtUp") {
|
|
58
|
+
const caughtUpListener = listener as CaughtUpListener;
|
|
59
|
+
if (this.caughtUp) {
|
|
60
|
+
caughtUpListener();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public disposed: boolean = false;
|
|
67
|
+
public dispose() {
|
|
68
|
+
if (this.disposed) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.disposed = true;
|
|
72
|
+
|
|
73
|
+
this.removeAllListeners();
|
|
74
|
+
this.deltaManager.off("op", this.opHandler);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Monitor that always notifies listeners immediately */
|
|
79
|
+
export class ImmediateCatchUpMonitor extends TypedEventEmitter<ICatchUpMonitorEvents> implements ICatchUpMonitor {
|
|
80
|
+
constructor() {
|
|
81
|
+
super();
|
|
82
|
+
this.on("newListener", (event: string, listener) => {
|
|
83
|
+
if (event === "caughtUp") {
|
|
84
|
+
const caughtUpListener = listener as CaughtUpListener;
|
|
85
|
+
caughtUpListener();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public disposed: boolean = false;
|
|
91
|
+
public dispose() {
|
|
92
|
+
if (this.disposed) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
this.disposed = true;
|
|
96
|
+
|
|
97
|
+
this.removeAllListeners();
|
|
98
|
+
}
|
|
99
|
+
}
|
package/src/connectionManager.ts
CHANGED
package/src/connectionState.ts
CHANGED
|
@@ -17,12 +17,6 @@ export enum ConnectionState {
|
|
|
17
17
|
*/
|
|
18
18
|
EstablishingConnection = 3,
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* See {@link ConnectionState.CatchingUp}, which is the new name for this state.
|
|
22
|
-
* @deprecated - This state itself is not gone, just being renamed. Please use {@link ConnectionState.CatchingUp}.
|
|
23
|
-
*/
|
|
24
|
-
Connecting = 1,
|
|
25
|
-
|
|
26
20
|
/**
|
|
27
21
|
* The container has an inbound connection only, and is catching up to the latest known state from the service.
|
|
28
22
|
*/
|