presta
Version:
Hyper minimal framework for the modern web.
32 lines (31 loc) • 1.19 kB
TypeScript
export declare enum Events {
PostBuild = "post-build",
BuildFile = "build-file",
BrowserRefresh = "browser-refresh"
}
export declare type Callable = (...args: any[]) => void;
export declare type HookPostBuildPayload = {
output: string;
staticOutput: string;
functionsOutput: string;
functionsManifest: Record<string, string>;
};
export declare type HookBuildFilePayload = {
file: string;
};
export declare type DestroyHookCallback = () => void;
export declare type Hooks = {
emitPostBuild(props: HookPostBuildPayload): void;
onPostBuild(cb: (props: HookPostBuildPayload) => void): DestroyHookCallback;
emitBuildFile(props: HookBuildFilePayload): void;
onBuildFile(cb: (props: HookBuildFilePayload) => void): DestroyHookCallback;
emitBrowserRefresh(): void;
onBrowserRefresh(cb: () => void): DestroyHookCallback;
};
export declare function createEmitter(): {
emit: (ev: string, ...args: any[]) => void;
on: (ev: string, fn: (...args: any[]) => void) => () => Callable[];
clear: () => void;
listeners: (ev: string) => Callable[];
};
export declare function createHooks(emitter: ReturnType<typeof createEmitter>): Hooks;