import * as PagesJSON from '@uni-ku/pages-json/types'; type MaybePromise = T | Promise; type MaybeCallable = T | (() => T); type MaybePromiseCallable = T | (() => T) | (() => Promise); type ExcludeIndexSignature = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K]; }; type KnownKeys = keyof ExcludeIndexSignature; type DeepPartial = T extends Array ? Array> : T extends object ? { [P in keyof T]?: DeepPartial; } : T; /** * `process.env.UNI_PLATFORM` * * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-node.d.ts#L9} * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-uni-app.d.ts#L24} * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/shims-uni-app.d.ts#L193-L211} * @link {https://github.com/dcloudio/uni-app/blob/v3.0.0-4020920240930001/packages/uni-cli-shared/src/env/define.ts#L24} */ type UniPlatform = 'h5' | 'web' | 'app' | 'app-plus' | 'app-harmony' | 'mp-360' | 'mp-alipay' | 'mp-baidu' | 'mp-qq' | 'mp-toutiao' | 'mp-weixin' | 'mp-kuaishou' | 'mp-lark' | 'mp-jd' | 'mp-xhs' | 'mp-harmony' | 'quickapp-webview' | 'quickapp-webview-huawei' | 'quickapp-webview-union'; declare const PLATFORMS: unique symbol; declare const DEFINES: unique symbol; declare const CONDITION: unique symbol; /** * 重构后:Key 直接约束为 keyof T 的子类型,保证索引兼容性 * - 数组:Key = number(keyof T[] 的子类型) * - 对象:Key = keyof T * - 非对象/数组:never */ type Key = keyof T & (T extends any[] ? number : T extends object ? keyof T : never); type ConditionValue = Key> = T & { [PLATFORMS]: UniPlatform[]; [DEFINES]: Map; }; interface Define { platforms: UniPlatform[]; platformStr: string; condition: 'ifdef' | 'ifndef'; value: any; } declare class Condition = Key> { [CONDITION]: ConditionValue; constructor(orig: T, ...platform: UniPlatform[]); ifdef(platform: UniPlatform | UniPlatform[], obj: DeepPartial): this; ifndef(platform: UniPlatform | UniPlatform[], obj: DeepPartial): this; } interface DefinePageFuncArgs { define: (meta: UserPageMeta) => Condition; platform: UniPlatform; } declare function definePage(arg: UserPageMeta | null | ((arg: DefinePageFuncArgs) => MaybePromise>)): void; interface UserTabBarItem extends DeepPartial { /** * 配置tabbar路径 * @deprecated 无效,将会根据文件路径自动生成 */ pagePath?: string; /** * 排序,数值越小越靠前 */ index?: number; } interface UserPageMeta extends DeepPartial { /** * 标识 page 类型 */ type?: 'page' | 'home'; /** * 配置页面路径 * @deprecated 无效,将会根据文件路径自动生成 */ path?: string; /** * 配置 tabbar 属性 */ tabbar?: UserTabBarItem; } interface PageFileOption { /** 文件路径 */ filePath: string; /** 页面路径,对应 pages.json 中的 path */ pagePath: string; /** subPackages 中的 root,为空则非subPackage */ root?: string; } interface ConfigHook { /** * 获取页面路径 * @param filePath - 文件路径 * @param pagePath - 页面路径 * @returns page path 页面路径 */ parsePageOption?: (opt: PageFileOption) => MaybePromise; /** * 过滤、修改 pages 的页面文件信息 */ filterPages?: (platform: UniPlatform, opts: PageFileOption[]) => MaybePromise; /** * 修改生成的页面配置 * 返回 null 可忽略该页面 */ transformPage?: (platform: UniPlatform, page: PagesJSON.Page, opt: PageFileOption) => MaybePromise; } interface UserConfig { /** * 项目根目录 * @default process.env.UNI_CLI_CONTEXT || process.cwd() */ root?: string; /** * 源码目录 * pages.json 放置的目录 * @default process.env.UNI_INPUT_DIR || path.resolve(root, 'src') || root */ src?: string; /** * pages 绝对路径或基于源码目录的相对路径 * @default 'pages' */ pageDir?: string; /** * subPackages 绝对路径或基于源码目录的相对路径 * @default [] */ subPackageDirs?: string[]; /** * 排除条件,应用于 pages 和 subPackages 的文件 * @default ['node_modules', '.git', '** /__*__/ **'] */ exclude?: string[]; /** * 为页面路径生成 TypeScript 声明 * 绝对路径或基于源码目录的相对路径 * false 则取消生成 * @default "pages.d.ts" */ dts?: string | boolean; /** * 显示调试 * @default false */ debug?: boolean | 'info' | 'error' | 'debug' | 'warn'; /** * 钩子 */ hooks?: ConfigHook[]; /** * 缓存目录 * @default 'node_modules/.cache/@uni-ku/pages-json' */ cacheDir?: string; /** * 运行平台 */ platform?: UniPlatform | UniPlatform[]; /** * pages.json 格式化缩进,默认使用 4 个空格缩进 */ indent?: string | number; } export { Condition as C, type DeepPartial as D, type ExcludeIndexSignature as E, type KnownKeys as K, type MaybePromise as M, type PageFileOption as P, type UniPlatform as U, type UserConfig as a, type ConfigHook as b, type DefinePageFuncArgs as c, type UserPageMeta as d, type UserTabBarItem as e, definePage as f, type MaybeCallable as g, type MaybePromiseCallable as h };