Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove internal usage of IFluidObject for IFluidModule, and IContainerContext.scope #7867

Merged
merged 5 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import {
IProvideFluidDataStoreRegistry,
NamedFluidDataStoreRegistryEntries,
} from "@fluidframework/runtime-definitions";
import { DependencyContainer, DependencyContainerRegistry } from "@fluidframework/synthesize";
import {
DependencyContainer,
DependencyContainerRegistry,
IProvideFluidDependencySynthesizer,
} from "@fluidframework/synthesize";
import { RuntimeFactoryHelper } from "@fluidframework/runtime-utils";

/**
Expand Down Expand Up @@ -65,15 +69,12 @@ export class BaseContainerRuntimeFactory
context: IContainerContext,
existing: boolean,
): Promise<ContainerRuntime> {
const parentDependencyContainer = context.scope.IFluidDependencySynthesizer;
const scope: Partial<IProvideFluidDependencySynthesizer> = context.scope;
const parentDependencyContainer = scope.IFluidDependencySynthesizer;
const dc = new DependencyContainer(parentDependencyContainer);
for (const entry of Array.from(this.providerEntries)) {
dc.register(entry.type, entry.provider);
}

// Create a scope object that passes through everything except for IFluidDependencySynthesizer
// which we will replace with the new one we just created.
anthony-murphy marked this conversation as resolved.
Show resolved Hide resolved
const scope: any = context.scope;
scope.IFluidDependencySynthesizer = dc;

const runtime: ContainerRuntime = await ContainerRuntime.load(
Expand Down
9 changes: 7 additions & 2 deletions packages/loader/container-loader/src/containerContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
IResponse,
IFluidCodeDetails,
IFluidCodeDetailsComparer,
IProvideFluidCodeDetailsComparer,
} from "@fluidframework/core-interfaces";
import {
IAudience,
Expand All @@ -24,6 +25,7 @@ import {
ILoaderOptions,
IRuntimeFactory,
ICodeLoader,
IProvideRuntimeFactory,
} from "@fluidframework/container-definitions";
import { IDocumentStorageService } from "@fluidframework/driver-definitions";
import {
Expand Down Expand Up @@ -263,7 +265,8 @@ export class ContainerContext implements IContainerContext {
}

const moduleWithDetails = await this._fluidModuleP;
const maybeCompareExport = moduleWithDetails.module?.fluidExport;
const maybeCompareExport: Partial<Readonly<IProvideFluidCodeDetailsComparer>> =
anthony-murphy marked this conversation as resolved.
Show resolved Hide resolved
moduleWithDetails.module?.fluidExport;
if (maybeCompareExport?.IFluidCodeDetailsComparer !== undefined) {
comparers.push(maybeCompareExport.IFluidCodeDetailsComparer);
}
Expand Down Expand Up @@ -296,7 +299,9 @@ export class ContainerContext implements IContainerContext {
// #region private

private async getRuntimeFactory(): Promise<IRuntimeFactory> {
const runtimeFactory = (await this._fluidModuleP).module?.fluidExport?.IRuntimeFactory;
const fluidExport: Partial<IProvideRuntimeFactory> | undefined =
anthony-murphy marked this conversation as resolved.
Show resolved Hide resolved
(await this._fluidModuleP)?.module.fluidExport;
anthony-murphy marked this conversation as resolved.
Show resolved Hide resolved
const runtimeFactory = fluidExport?.IRuntimeFactory;
if (runtimeFactory === undefined) {
throw new Error(PackageNotFactoryError);
}
Expand Down
1 change: 1 addition & 0 deletions packages/tools/webpack-fluid-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@fluidframework/odsp-driver-definitions": "^0.50.0",
"@fluidframework/protocol-definitions": "^0.1025.0",
"@fluidframework/routerlicious-driver": "^0.50.0",
"@fluidframework/runtime-definitions": "^0.50.0",
"@fluidframework/runtime-utils": "^0.50.0",
"@fluidframework/server-local-server": "^0.1033.0-40116",
"@fluidframework/server-services-client": "^0.1033.0-40116",
Expand Down
7 changes: 5 additions & 2 deletions packages/tools/webpack-fluid-loader/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
IFluidCodeResolver,
IResolvedFluidCodeDetails,
isFluidBrowserPackage,
IProvideRuntimeFactory,
} from "@fluidframework/container-definitions";
import { Container, Loader } from "@fluidframework/container-loader";
import { prefetchLatestSnapshot } from "@fluidframework/odsp-driver";
Expand All @@ -30,6 +31,7 @@ import { IDocumentServiceFactory, IResolvedUrl } from "@fluidframework/driver-de
import { LocalDocumentServiceFactory, LocalResolver } from "@fluidframework/local-driver";
import { RequestParser, createDataStoreFactory } from "@fluidframework/runtime-utils";
import { ensureFluidResolvedUrl } from "@fluidframework/driver-utils";
import { IProvideFluidDataStoreFactory } from "@fluidframework/runtime-definitions";
import { MultiUrlResolver } from "./multiResolver";
import { deltaConns, getDocumentServiceFactory } from "./multiDocumentServiceFactory";
import { OdspPersistentCache } from "./odspPersistantCache";
Expand Down Expand Up @@ -88,8 +90,9 @@ export type RouteOptions =
| IOdspRouteOptions;

function wrapWithRuntimeFactoryIfNeeded(packageJson: IFluidPackage, fluidModule: IFluidModule): IFluidModule {
if (fluidModule.fluidExport.IRuntimeFactory === undefined) {
const dataStoreFactory = fluidModule.fluidExport.IFluidDataStoreFactory;
const fluidExport: Partial<IProvideRuntimeFactory & IProvideFluidDataStoreFactory> = fluidModule.fluidExport;
if (fluidExport.IRuntimeFactory === undefined) {
const dataStoreFactory = fluidExport.IFluidDataStoreFactory;

const defaultFactory = createDataStoreFactory(packageJson.name, dataStoreFactory);

Expand Down