import { IAction, IActorItem, ISubComp } from "moon-core/src/typings/page"; /** * 获取处理页面内容;; * 处理文件 的公共逻辑; 从模板中取出内容,渲染出来, 然后保存; * @param {string} outDir projectPath 项目根目录 * @param {string} outDir 输出文件目录 * @param {string} tplDir 模板文件目录 * * @returns {(filePath: string, dealCal: (tplContent: string) => Promise, param?: IHandlePageParam) => Promise} */ export declare function getHandleFile({ outDir, tplBase, context }: IHandleFile): (tplPath: string, dealCal: (tplContent: string) => Promise, param?: IHandlePageParam) => Promise; /** * 向内容中间插入数据; * * @param {string} rawContent * @param {IInsertOption[]} inserts * @returns {string} */ export declare function insertContent(rawContent: string, inserts: IInsertOption[]): string; /** * * 向文件内容中间插入数据; 插入后再保存数据; * @param {string} filepath * @param {IInsertOption[]} inserts * @returns {Promise} */ export declare function insertFile(filepath: string, inserts: IInsertOption[]): Promise; interface IHandlePageParam { saveFilePath: string; subComp?: ISubComp; actor?: IActorItem; action?: IAction; } export interface IFileSaveOpt { beforeSave?: (options: IFileSaveOptions, context: any) => Promise; afterSave?: (options: IFileSaveOptions, context: any) => Promise; } export interface IHandleFile { outDir: string; tplBase: string; context?: IFileSaveOpt; } export interface IInsertOption { mark: string | RegExp; isBefore?: boolean; content: string; /** * * @param content * @returns {boolean} 验证是否需要做 true 继续,false 中断 */ check?: (content: any, rawContent: any) => boolean; } export interface IFileSaveOptions { projectOutDir: string; tplPath: string; toSaveFilePath: string; content: string; param?: IHandlePageParam; } export {};