UNPKG

1.19 kBTypeScriptView Raw
1export declare enum Events {
2 PostBuild = "post-build",
3 BuildFile = "build-file",
4 BrowserRefresh = "browser-refresh"
5}
6export declare type Callable = (...args: any[]) => void;
7export declare type HookPostBuildPayload = {
8 output: string;
9 staticOutput: string;
10 functionsOutput: string;
11 functionsManifest: Record<string, string>;
12};
13export declare type HookBuildFilePayload = {
14 file: string;
15};
16export declare type DestroyHookCallback = () => void;
17export declare type Hooks = {
18 emitPostBuild(props: HookPostBuildPayload): void;
19 onPostBuild(cb: (props: HookPostBuildPayload) => void): DestroyHookCallback;
20 emitBuildFile(props: HookBuildFilePayload): void;
21 onBuildFile(cb: (props: HookBuildFilePayload) => void): DestroyHookCallback;
22 emitBrowserRefresh(): void;
23 onBrowserRefresh(cb: () => void): DestroyHookCallback;
24};
25export declare function createEmitter(): {
26 emit: (ev: string, ...args: any[]) => void;
27 on: (ev: string, fn: (...args: any[]) => void) => () => Callable[];
28 clear: () => void;
29 listeners: (ev: string) => Callable[];
30};
31export declare function createHooks(emitter: ReturnType<typeof createEmitter>): Hooks;