import { IFluidHandle } from "@fluidframework/core-interfaces" ; import { IFluidDataStoreContext , IFluidDataStoreFactory } from "@fluidframework/runtime-definitions" ; import { LazyLoadedDataObjectFactory , LazyLoadedDataObject } from "@fluidframework/data-object-base" ; import { ISharedDirectory , SharedDirectory } from "@fluidframework/map" ; import { FlowDocument } from "../document" ; import { hostType } from "../package" ; import { importDoc } from "./import" ; export class WebFlow extends LazyLoadedDataObject < ISharedDirectory > { private static readonly factory = new LazyLoadedDataObjectFactory < WebFlow > ( hostType , WebFlow , SharedDirectory . getFactory ( ) , [ ] , [ FlowDocument . getFactory ( ) ] ) ; public static getFactory ( ) { return WebFlow . factory ; } public static async create ( parentContext , props ? ) { return WebFlow . factory . create ( parentContext , props ) ; } public async create ( ) { const doc = await FlowDocument . create ( this . context ) as FlowDocument ; this . root . set ( "doc" , doc . handle ) ; const url = new URL ( window . location . href ) ; const template = url . searchParams . get ( "template" ) ; if ( template ) { importDoc ( doc , template ) ; } } public async load ( ) { } protected async initializingFirstTime ( ) { await this . create ( ) ; } public async getFlowDocument ( ) { return this . root . get < IFluidHandle < FlowDocument > > ( "doc" ) . get ( ) ; } }