message: add detached container creation ability to base host
diff: * Licensed under the MIT License.
  */
  +import assert from "assert";
  import { IFluidObject } from "@fluidframework/core-interfaces";
  import {
  IFluidCodeDetails,
  @@ -73,6 +74,44 @@ export class BaseHost {
  return container;
  }
  + /**
  + * Used to create a detached container from code details.
  + * @param codeDetails - codeDetails used to create detached container.
  + */
  + public async createContainer(codeDetails: IFluidCodeDetails): Promise<Container> {
  + const loader = await this.getLoader();
  + const container = await loader.createDetachedContainer(codeDetails);
  +
  + assert(container.hasNullRuntime() === false, "Detached container should never have null runtime");
  + return container;
  + }
  +
  + /**
  + * Used to create a detached container from snapshot of another detached container.
  + * @param snapshot - Snapshot of detached container.
  + */
  + public async rehydrateContainer(snapshot: string): Promise<Container> {
  + const loader = await this.getLoader();
  + const container = await loader.rehydrateDetachedContainerFromSnapshot(snapshot);
  +
  + assert(container.hasNullRuntime() === false, "Detached container should never have null runtime");
  + return container;
  + }
  +
  + public async requestFluidObjectFromContainer(container: Container, url: string) {
  + const response = await container.request({ url });
  +
  + if (response.status !== 200 ||
  + !(
  + response.mimeType === "fluid/component" ||
  + response.mimeType === "fluid/object"
  + )) {
  + return undefined;
  + }
  +
  + return response.value as IFluidObject;
  + }
  +
  public async requestFluidObject(url: string) {
  const loader = await this.getLoader();
  const response = await loader.request({ url });
  