"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const fs_extra_1=__importDefault(require("fs-extra")),path_1=__importDefault(require("path")),commonData_1=require("../../../types/commonData"),compile_1=__importDefault(require("../compile"));class GadgetCompile extends compile_1.default{getPackVersion(){return"default"}start(){const{type:e,sourcePath:t,distPath:a,appInfo:o}=this.options,{pluginRoot:p}=fs_extra_1.default.readJSONSync(path_1.default.join(t,"project.config.json")),i=this.getPackVersion();if(p){const r=path_1.default.join(t,p),c={type:"compile",data:{packVersion:i,type:"plugin",watch:"watch"===e||"live"===e,projectDir:t,outputDir:path_1.default.join(a||r,"../",p),context:{isIDE:!0,compileType:"splits",packageType:o.packageType,remoteDebugUrl:o.remoteDebugUrl,forceMinify:!1,sourceMapType:"INLINE",needComponentList:!0,needSubPackage:!1,showPerformance:!0,disableSafeCheck:!0}}};"upgrade"===i&&(c.data.context.compileVersion="upgrade"===i?"upgrade":"legacy"),this.startProcess(c)}const r={type:"compile",data:{packVersion:i,type:commonData_1.AppTypeEnum.Gadget,watch:"watch"===e||"live"===e,projectDir:t,outputDir:a,context:{isIDE:!0,compileType:"splits",packageType:o.packageType,remoteDebugUrl:o.remoteDebugUrl,forceMinify:!1,sourceMapType:"INLINE",needComponentList:!0,needSubPackage:!1,showPerformance:!0,disableSafeCheck:!0}}};return"upgrade"===i&&(r.data.context.compileVersion="upgrade"===i?"upgrade":"legacy"),this.startProcess(r)}get events(){return{live:{compile:"gadget_preview_compile",first:"gadget_preview_first_compile",watch:"gadget_preview_watch_compile"},force:{compile:"gadget_force_compile",first:"gadget_force_first_compile",watch:"gadget_force_watch_compile"},debug:{compile:"gadget_remote_debug",first:"gadget_remote_debug_first_compile",watch:"gadget_remote_debug_watch_compile"},watch:{compile:"gadget_develop",first:"gadget_develop_first_compile",watch:"gadget_develop_watch_compile"}}[this.compileType]}}exports.default=GadgetCompile;