import { IFluidHandle , IFluidLoadable , IFluidRouter , IRequest , IResponse , IProvideFluidHandle , } from "@fluidframework/core-interfaces" ; import { IFluidDataStoreContext , } from "@fluidframework/runtime-definitions" ; import { IFluidDataStoreRuntime , } from "@fluidframework/datastore-definitions" ; import { FluidObjectHandle } from "@fluidframework/datastore" ; import { ISharedObject } from "@fluidframework/shared-object-base" ; import { EventForwarder } from "@fluidframework/common-utils" ; import { IEvent } from "@fluidframework/common-definitions" ; import { create404Response } from "@fluidframework/runtime-utils" ; export abstract class LazyLoadedDataObject < TRoot extends ISharedObject = ISharedObject , TEvents extends IEvent = IEvent > extends EventForwarder < TEvents > implements IFluidLoadable , IProvideFluidHandle , IFluidRouter { private _handle ? : IFluidHandle < this > ; public get IFluidRouter ( ) { return this ; } public get IFluidLoadable ( ) { return this ; } public get IFluidHandle ( ) { return this . handle ; } public get IProvideFluidHandle ( ) { return this ; } protected readonly root : TRoot ; public constructor ( protected readonly context , protected readonly runtime , root ) { super ( ) ; this . root = root as TRoot ; } public async request ( r ) { return r . url === "" || r . url === "/" ? { status : 200 , mimeType : "fluid/object" , value : this } : create404Response ( r ) ; } public get handle ( ) : IFluidHandle < this > { if ( ! this . _handle ) { this . _handle = new FluidObjectHandle ( this , "" , this . runtime . objectsRoutingContext ) ; } return this . _handle ; } public abstract create ( props ? ) ; public abstract load ( context , runtime , existing ) ; }