import { AppJSON } from './app'; import { ExtJSON } from './ext'; import { JSONContainer } from './jsons'; import type { ConditionItem } from './schema/base'; import type { IProject } from './schema/project'; import { CompilerPlugin, IPackItem } from '../constants/project'; import { GetEnvFunction } from '../network/axios'; import { IProjectPrivate } from './schema/project.private'; /** * 因为 @byted/miniprogram-utils 都是分模块打包和引入的,两个模块之间不共享数据,所以需要单独设置 * todo 其他文件都直接引入 @byted/miniprogram-utils 而不是 @byted/miniprogram-utils/dist/xxx/xxx */ export declare const setEnvFunctionForProject: (fn: GetEnvFunction) => void; export declare const DEFAULT_PROJECT_CONFIG: { appid: string; projectname: string; setting: { urlCheck: boolean; es6: boolean; postcss: boolean; minified: boolean; newFeature: boolean; }; scripts: { afterOpen: string; beforeCompile: string; }; }; export { ConditionItem }; interface ConditionData { current: number; list: ConditionItem[]; } /** * 用户自定义命令执行阶段 */ export declare enum UserScriptExecutePhase { AfterOpen = "afterOpen", BeforeCompile = "beforeCompile", BeforePreview = "beforePreview", BeforeUpload = "beforeUpload", AfterUpload = "afterUpload" } /** 扩展一波属性,给 IDE 用的,开发者不需要感知 */ export interface IProjectConfig extends IProject { ttappid?: string; setting: { urlCheck: boolean; es6: boolean; postcss: boolean; minified: boolean; newFeature: boolean; autoCompile?: boolean; compileHotReLoad?: boolean; nativeCompile?: boolean; scripts?: boolean; localPlugins?: boolean; nodeModules?: boolean; mockLogin?: boolean; autoPush?: boolean; IDEPreviewHotRestartCache?: boolean; IDEPreviewXScreen?: boolean; IDEPreviewOpenVConsole?: boolean; useCompilerPlugins?: CompilerPlugin[]; bigPackageSizeSupport?: boolean; webDetect?: boolean; previewPreload?: boolean; useRazor?: boolean; }; useRazor?: boolean; lynx?: { debugSchema?: Record; }; condition?: { miniprogram?: ConditionData; game?: ConditionData; }; douyinProjectType?: string; unity?: { build: { webgl: string; native: { il2cpp: string; apk: string; fullApk?: string; }; instantGame: string; }; publishType: '0' | '1' | '2' | '3' | '4' | '5'; starkSdkVersion: string; unityToolsVersion: string; unityEngineVersion: string; arch: string; }; } /** * 此处的技术类型与 ide 的技术类型有区别 * 这里的 TechType 通过项目特征获得,无法识别出小游戏和小玩法 * * IDE 本身的项目技术类型分为 microapp、microgame、plugin * microapp、plugin 属于 app 类型 * microgame 属于 game 类型 * live-plugin 为直播间互动插件 */ declare type TechType = 'app' | 'game' | 'unity' | 'liveplugin' | 'playablegame'; declare type IDEAppTechType = 'microapp' | 'microgame' | 'microapp-minicode' | 'plugin' | 'plugin-minicode' | 'microgame-minicode' | 'liveplugin-minicode' | 'unity' | 'liveplugin' | 'microapp-plugin' | 'microapp-plugin-minicode' | 'playablegame' | 'playablegame-minicode' | ''; export declare const PROJECT_TYPE_MAP: Record; export declare function setIDEAppTechType(type: IDEAppTechType): void; export declare function getIDEAppTechType(): IDEAppTechType; export declare function isTestAppid(appid: string): boolean; export declare function getOriginAppid(appid: string, type?: TechType): string; export declare type KeyMap = Record; export declare enum PrivateState { ALWAYS = "ALWAYS", NORMAL = "NORMAL" } /** * 包裹 ProjectConfigJSON 文件的读取。 * * 绝大部分数据读取都会在此处有 fallback default value。 * 上层调用时,通常是不需要再处理了,使用时请小心。 */ export declare class ProjectConfig extends JSONContainer> { static readonly PRIVATE_CONFIG_KEYS: KeyMap; private static _keyPath; static getKeyPath(): [string, PrivateState][]; static getKeyPathList(): string[]; private static generateList; static from(projectPath: string): Promise; static fromJson(json: Record, projectPath: string): ProjectConfig; static getMergedConfig(publicConfig: Partial, privateConfig: Partial): Partial; update(key: K, value: IProjectConfig[K], write?: boolean): Promise; /** * @param projectPath path to the project that contains `project.config.json` */ /** * project path */ readonly projectPath: string; private readonly privateConfigPath; private readonly publicJson; private privateJson; private _enablePrivateConfig; private constructor(); enablePrivateConfig(mergedJson: Partial, privateJson: Partial): void; getPublicRawJSON(): Partial; getPrivateRawJSON(): Partial; getAppid(): string; getRealAppid(): Promise; getRealPluginAppid(): string | null; getSetting(): IProjectConfig['setting']; getProjectName(): string; getScripts(): IProjectConfig['scripts']; getConditionData(conditionKeyName: keyof NonNullable): ConditionData; getAutoCompileSetting(): boolean; getCompileHotReloadSetting(): boolean; getNativeCompileSetting(): boolean; getLocalPluginsSetting(): boolean; /** * 获取用户自定义命令 * @param phase 用户自定义命令执行阶段 * @returns 对应阶段的用户自定义命令 */ getUserScript(phase: UserScriptExecutePhase): string; getSkipDomainCheck(): boolean; getPreviewHotRestartCache(): boolean; getIDEPreviewXScreen(): boolean; getPreviewOpenVConsole(): boolean; getMiniprogramRoot(): string; getCloudfunctionRoot(): string; getPluginRoot(): string; isPluginProject(): boolean; getBigPackageSizeSupport(): boolean; getWebDetect(): boolean; getPreviewPreload(): boolean; getPackOptions(): { ignore: IPackItem[]; include: IPackItem[]; }; getLynxConfig(): { debugSchema?: Record; }; getLynxPackage(): string; /** * Detect current project is 小程序 (`app.json`) or 游戏Like (`game.json`) * @param match Optional comparison type * @returns return `boolean` if {@link match} provide, otherwise the {@link TechType} */ detectProjectType(match: TechType): Promise; detectProjectType(): Promise; /** * 当前项目的特征,app.json / game.json */ private getProjectType; /** * This would throw error if the `app.json` doesn't exist, handler error at your own risk. * @returns the matching program config, `app.json` or `game.json` */ getAppJSON(): Promise; /** * This would throw error if the `ext.json` doesn't exist, handler error at your own risk. * @returns the matching ext config */ getExtJSON(): Promise; useTypeScript(): boolean; }