UNPKG

@prodo/core

Version:

Core package for [Prodo](https://prodo.dev). See [documentation](https://docs.prodo.dev) for more info.

59 lines 3.25 kB
import * as React from "react"; import { Comp, Event, PluginDispatch } from "./types"; export interface PluginActionCtx<ActionCtx, Universe> { dispatch: PluginDispatch<ActionCtx>; universe: Universe; rootDispatch: PluginDispatch<ActionCtx>; } export interface PluginViewCtx<ActionCtx, Universe> { dispatch: PluginDispatch<ActionCtx>; universe: Universe; subscribe: (path: string[], unsubscribe?: (comp: Comp) => void) => void; } export declare type PluginInitFn<InitOptions, Universe> = (config: InitOptions, universe: Universe, store: { dispatch: PluginDispatch<any>; exposedUniverseVars: string[]; }) => void; export declare type PluginActionCtxFn<InitOptions, Universe, ActionCtx, CustomEvent = {}> = (env: { ctx: PluginActionCtx<ActionCtx, Universe> & ActionCtx; universe: Universe; event: Event & CustomEvent; }, config: InitOptions) => void; export declare type PluginViewCtxFn<InitOptions, Universe, ActionCtx, ViewCtx> = (env: { ctx: PluginViewCtx<ActionCtx, Universe> & ViewCtx; universe: Universe; comp: Comp; }, config: InitOptions) => void; export declare type PluginOnCompleteEventFn<InitOptions, CustomEvent, ActionCtx> = (env: { event: Event & CustomEvent; rootDispatch: PluginDispatch<ActionCtx>; }, config: InitOptions) => void; export interface ProdoInternals<InitOptions, Universe, ActionCtx, ViewCtx, CustomEvent = {}> { name: string; init?: PluginInitFn<InitOptions, Universe>; actionCtx?: PluginActionCtxFn<InitOptions, Universe, ActionCtx, CustomEvent>; viewCtx?: PluginViewCtxFn<InitOptions, Universe, ActionCtx, ViewCtx>; onCompleteEvent?: PluginOnCompleteEventFn<InitOptions, CustomEvent, ActionCtx>; Provider?: React.ComponentType<{ children: React.ReactNode; }>; exposedUniverseVars?: string[]; } export declare type PluginAction<ActionCtx, A extends any[]> = (ctx: ActionCtx) => (...args: A) => void; export declare type PluginActionCreator<ActionCtx> = <A extends any[]>(func: (ctx: ActionCtx) => (...args: A) => void, actionName: string) => (ctx: ActionCtx) => (...args: A) => void; export interface ProdoPlugin<InitOptions, Universe, ActionCtx, ViewCtx, CustomEvent = {}> { name: string; init: (initFn: PluginInitFn<InitOptions, Universe>) => void; prepareActionCtx: (actionCtxFn: PluginActionCtxFn<InitOptions, Universe, ActionCtx, CustomEvent>) => void; prepareViewCtx: (viewCtxFn: PluginViewCtxFn<InitOptions, Universe, ActionCtx, ViewCtx>) => void; onCompleteEvent: (completeEventFn: PluginOnCompleteEventFn<InitOptions, CustomEvent, ActionCtx>) => void; action: PluginActionCreator<ActionCtx>; setProvider: (provider: React.ComponentType<{ children: React.ReactNode; }>) => void; _internals: ProdoInternals<InitOptions, Universe, ActionCtx, ViewCtx, CustomEvent>; exposeUniverseVars: (vars: string[]) => void; } export declare const mkUserAction: <ActionCtx, A extends any[]>(action: PluginAction<ActionCtx, A>) => (...args: A) => void; export declare const createPlugin: <InitOptions, Universe, ActionCtx, ViewCtx, CustomEvent_1 = {}>(name: string) => ProdoPlugin<InitOptions, Universe, ActionCtx, ViewCtx, CustomEvent_1>; //# sourceMappingURL=plugins.d.ts.map