import { IContainer , IRuntimeFactory , } from "@fluidframework/container-definitions" ; import { Loader } from "@fluidframework/container-loader" ; import { IRequest } from "@fluidframework/core-interfaces" ; import { IDocumentServiceFactory , IUrlResolver , } from "@fluidframework/driver-definitions" ; export interface IGetContainerParams { documentServiceFactory : IDocumentServiceFactory ; urlResolver : IUrlResolver ; containerRuntimeFactory : IRuntimeFactory ; request : IRequest ; } export async function createContainer ( params ) { const module = { fluidExport : params . containerRuntimeFactory } ; const codeLoader = { load : async ( ) => module } ; const loader = new Loader ( { urlResolver : params . urlResolver , documentServiceFactory : params . documentServiceFactory , codeLoader } ) ; const container = await loader . createDetachedContainer ( { package : "no-dynamic-package" , config : { } } ) ; await container . attach ( params . request ) ; return container ; } export async function getContainer ( params ) { const module = { fluidExport : params . containerRuntimeFactory } ; const codeLoader = { load : async ( ) => module } ; const loader = new Loader ( { urlResolver : params . urlResolver , documentServiceFactory : params . documentServiceFactory , codeLoader } ) ; const container = await loader . resolve ( params . request ) ; return container ; }