1/* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16// ProjectConfig begins 17export interface PluginsConfig { 18 [pluginName: string]: string; 19} 20 21export interface PathsConfig { 22 [pathName: string]: string[]; 23} 24 25export interface BuildBaseConfig { 26 buildType: 'build' | 'preview' | 'hotreload' | 'coldreload'; 27 buildMode: 'Debug' | 'Release'; 28 hasMainModule: boolean; 29 arkts: ArkTS; 30 arktsGlobal: ArkTSGlobal; 31 maxWorkers?: number; 32 isBuildConfigModified?: boolean; 33} 34 35export interface ArkTSGlobal { 36 filePath: string; 37 config: object; 38 compilerContext: { 39 program: object; 40 peer: object 41 }; 42 es2panda: { 43 _DestroyContext: Function; 44 _SetUpSoPath: Function; 45 } 46} 47 48export interface ArkTS { 49 Config: { 50 create: Function; 51 createContextGenerateAbcForExternalSourceFiles: Function; 52 }; 53 Context: { 54 createFromString: Function; 55 }; 56 EtsScript: { 57 fromContext: Function; 58 }; 59 proceedToState: Function; 60 generateTsDeclarationsFromContext: Function; 61 destroyConfig: Function; 62 Es2pandaContextState: typeof Es2pandaContextState; 63} 64 65export enum Es2pandaContextState { 66 ES2PANDA_STATE_NEW = 0, 67 ES2PANDA_STATE_PARSED = 1, 68 ES2PANDA_STATE_BOUND = 2, 69 ES2PANDA_STATE_CHECKED = 3, 70 ES2PANDA_STATE_LOWERED = 4, 71 ES2PANDA_STATE_ASM_GENERATED = 5, 72 ES2PANDA_STATE_BIN_GENERATED = 6, 73 ES2PANDA_STATE_ERROR = 7 74} 75 76export interface ModuleConfig { 77 packageName: string; 78 moduleType: string; 79 moduleRootPath: string; 80 sourceRoots: string[]; 81 byteCodeHar: boolean; 82} 83 84export interface PathConfig { 85 loaderOutPath: string; 86 cachePath: string; 87 buildSdkPath: string; 88 pandaSdkPath?: string; // path to panda sdk lib/bin, for local test 89 pandaStdlibPath?: string; // path to panda sdk stdlib, for local test 90 externalApiPaths: string[]; 91 abcLinkerPath?: string; 92 dependencyAnalyzerPath?: string; 93 projectRootPath: string; 94} 95 96/** 97 * Configuration for framework mode compilation using generate_static_abc gni. 98 * 99 * In framework mode, the compiler generates static ABC files from framework SDK ETS files. 100 * This mode requires additional arktsconfig.json parameters for proper operation. 101 */ 102export interface FrameworkConfig { 103 /** 104 * Enables or disables framework compilation mode. 105 * When enabled (true), activates special processing rules for framework-level 106 * compilation, including different output locations and packaging requirements. 107 */ 108 frameworkMode?: boolean; 109 110 /** 111 * Determines whether an empty package name should be used. 112 * Must be set to true when compiling framework components without a package name. 113 */ 114 useEmptyPackage?: boolean; 115} 116 117export interface DeclgenConfig { 118 enableDeclgenEts2Ts: boolean; 119 declgenV1OutPath?: string; 120 declgenV2OutPath?: string; 121 declgenBridgeCodePath?: string; 122} 123 124export interface LoggerConfig { 125 getHvigorConsoleLogger?: Function; 126} 127 128export interface DependentModuleConfig { 129 packageName: string; 130 moduleName: string; 131 moduleType: string; 132 modulePath: string; 133 sourceRoots: string[]; 134 entryFile: string; 135 language: string; 136 declFilesPath?: string; 137 dependencies?: string[]; 138 declgenV1OutPath?: string; 139 declgenV2OutPath?: string; 140 declgenBridgeCodePath?: string; 141 byteCodeHar: boolean; 142} 143 144export interface BuildConfig extends BuildBaseConfig, DeclgenConfig, LoggerConfig, ModuleConfig, PathConfig, FrameworkConfig { 145 plugins: PluginsConfig; 146 paths: PathsConfig; // paths config passed from template to generate arktsconfig.json "paths" configs. 147 compileFiles: string[]; 148 dependentModuleList: DependentModuleConfig[]; 149} 150// ProjectConfig ends 151 152export interface CompileFileInfo { 153 filePath: string, 154 dependentFiles: string[], 155 abcFilePath: string, 156 arktsConfigFile: string, 157 packageName: string, 158}; 159 160export interface ModuleInfo { 161 isMainModule: boolean, 162 packageName: string, 163 moduleRootPath: string, 164 moduleType: string, 165 sourceRoots: string[], 166 entryFile: string, 167 arktsConfigFile: string, 168 compileFileInfos: CompileFileInfo[], 169 declgenV1OutPath: string | undefined, 170 declgenV2OutPath: string | undefined, 171 declgenBridgeCodePath: string | undefined, 172 dependencies?: string[] 173 staticDepModuleInfos: Map<string, ModuleInfo>; 174 dynamicDepModuleInfos: Map<string, ModuleInfo>; 175 language?: string; 176 declFilesPath?: string; 177 frameworkMode?: boolean; 178 useEmptyPackage?: boolean; 179 byteCodeHar: boolean; 180} 181 182export type SetupClusterOptions = { 183 clearExitListeners?: boolean; 184 execPath?: string; 185 execArgs?: string[]; 186}; 187 188export interface DependencyFileConfig { 189 dependants: { 190 [filePath: string]: string[]; 191 }; 192 dependencies: { 193 [filePath: string]: string[]; 194 } 195}