UNPKG

fractal-core

Version:

A minimalist and well crafted app, content or component is our conviction

80 lines (79 loc) 3.16 kB
import { Component, Update, Context, Components, InputData, HandlerInterface, HandlerObject, State, EventData } from '.'; import { Off, Emit, On } from 'pullable-event-bus'; export interface ModuleDef { Root: Component<any>; record?: boolean; log?: boolean; render?: boolean; active?: boolean; groups?: HandlerInterfaceIndex; tasks?: HandlerInterfaceIndex; interfaces: HandlerInterfaceIndex; interfaceOrder?: Array<string>; onBeforeInit?(mod: ModuleAPI): Promise<void>; onInit?(mod: ModuleAPI): Promise<void>; onBeforeDestroy?(mod: ModuleAPI): Promise<void>; onDestroy?(mod: ModuleAPI): Promise<void>; beforeInput?(ctxIn: Context<any>, inputName: string, data: any): void; afterInput?(ctxIn: Context<any>, inputName: string, data: any): void; warn?(source: string, description: string): Promise<void>; error?(source: string, description: string): Promise<void>; } export declare const _: any; export interface HandlerInterfaceIndex { [name: string]: HandlerInterface | Promise<HandlerInterface>; } export interface HandlerObjectIndex { [name: string]: HandlerObject; } export interface Module { moduleDef: ModuleDef; isDisposed: boolean; moduleAPI: ModuleAPI; rootCtx: Context<any>; } export interface ModuleAPI { on: On; off: Off; emit: Emit; dispatchEv(event: any, iData: InputData): Promise<void>; dispatch(eventData: EventData): Promise<void>; toComp(id: string, inputName: string, data?: any): Promise<void>; destroy(): void; attach(comp: Component<any>, app?: Module, middleFn?: MiddleFn): Promise<Module>; setGroup(id: string, name: string, space: any): void; task: CtxPerformTask; warn(source: any, description: any): void; error(source: any, description: any): void; } export interface MiddleFn { (ctx: Context<any>, app: Module): void; } export declare const handlerTypes: string[]; export interface CtxNest { (name: string, component: Component<any>, isStatic?: boolean): void; } export interface CtxNestAll { (components: Components<any>, isStatic?: boolean): Promise<void>; } export declare const nestAll: <S extends State>(ctx: Context<S>) => CtxNestAll; export interface CtxUnnest { (name?: string): Promise<void>; } export declare const unnest: <S extends State>(ctx: Context<S>) => CtxUnnest; export interface CtxUnnestAll { (components: string[]): Promise<void>; } export declare const unnestAll: <S>(ctx: Context<S>) => CtxUnnestAll; export declare function propagate<S>(ctx: Context<S>, inputName: string, data: any): Promise<void>; export interface CtxToIn { (inputName: string, data?: any): Promise<void>; } export declare const toIn: <S>(ctx: Context<S>) => CtxToIn; export declare function performUpdate<S extends State>(compCtx: Context<S>, update: Update<S>): Promise<void>; export interface CtxPerformTask { (name: string, data?: any): Promise<any>; } export declare function performTask<S>(ctx: Context<S>): CtxPerformTask; export declare function calcAndNotifyInterfaces<S>(ctx: Context<S>): void; export declare function run(moduleDef: ModuleDef): Promise<Module>;