73 lines
1.9 KiB
TypeScript
73 lines
1.9 KiB
TypeScript
/// <reference types="node" />
|
|
export type LogFormatterProp = {
|
|
level: "info" | "warn" | "error";
|
|
caller: NodeJS.CallSite | null;
|
|
args: any[];
|
|
};
|
|
export type LogFormatter = (props: LogFormatterProp) => any[];
|
|
export type WatchConfig = {
|
|
/**
|
|
* 是否启用polyfill
|
|
*/
|
|
polyfill?: {
|
|
/**
|
|
* 是否启用console polyfill
|
|
*/
|
|
console?: {
|
|
/**
|
|
* 是否启用
|
|
*/
|
|
enable?: boolean;
|
|
/**
|
|
* 是否打印调用堆栈信息
|
|
*/
|
|
trace?: boolean;
|
|
/**
|
|
* 格式化函数
|
|
*/
|
|
formatter: LogFormatter;
|
|
};
|
|
};
|
|
/**
|
|
* 生命周期钩子
|
|
*/
|
|
lifecycle?: {
|
|
/**
|
|
* 初始化时调用
|
|
* @returns void
|
|
*/
|
|
onInit?: () => void;
|
|
/**
|
|
* 服务启动时调用
|
|
* @returns void
|
|
*/
|
|
onServerStart?: () => void;
|
|
/**
|
|
* 编译前调用
|
|
* @returns void
|
|
*/
|
|
onBeforeCompile?: () => void;
|
|
/**
|
|
* 编译后调用
|
|
* @returns void
|
|
*/
|
|
onAfterCompile?: () => void;
|
|
/**
|
|
* 服务关闭时调用
|
|
* @returns void
|
|
*/
|
|
onServerShutdown?: () => void;
|
|
/**
|
|
* 销毁监视器时调用
|
|
* @returns void
|
|
*/
|
|
onDispose?: () => void;
|
|
};
|
|
};
|
|
type DeepRequiredIfPresent<T> = {
|
|
[P in keyof T]-?: NonNullable<T[P]> extends (...args: any) => any ? T[P] : NonNullable<T[P]> extends (infer U)[] ? DeepRequiredIfPresent<U>[] : NonNullable<T[P]> extends object ? DeepRequiredIfPresent<NonNullable<T[P]>> : T[P] extends undefined | null ? T[P] : NonNullable<T[P]>;
|
|
};
|
|
export type RealWatchConfig = DeepRequiredIfPresent<WatchConfig>;
|
|
export declare const watch: (projectPath: string, config?: WatchConfig) => Promise<() => Promise<void>>;
|
|
export {};
|