"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=compile;const tslib_1=require("tslib"),config_1=require("../../../../config/config"),reactiveCache_1=require("../json/reactiveCache"),common_1=require("../../../../utils/common"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),gamePlugin_1=require("./gamePlugin"),miniprogramPlugin_1=require("./miniprogramPlugin"),miniprogram_1=require("./miniprogram"),game_1=require("./game");async function checkProjectTypeMatchProjectAttr(e){const i=await e.attr();!i.gameApp||e.type!==config_1.COMPILE_TYPE.miniProgramPlugin&&e.type!==config_1.COMPILE_TYPE.miniProgram||(0,common_1.throwError)({filePath:"",msg:locales_1.default.config.PROJECT_TYPE_ERROR.format(e.type,e.appid,locales_1.default.config.MINI_GAME),code:config_1.PROJECT_TYPE_ERROR}),i.gameApp||e.type!==config_1.COMPILE_TYPE.miniGame&&e.type!==config_1.COMPILE_TYPE.miniGamePlugin||(0,common_1.throwError)({filePath:"",msg:locales_1.default.config.PROJECT_TYPE_ERROR.format(e.type,e.appid,locales_1.default.config.MINI_PROGRAM),code:config_1.PROJECT_TYPE_ERROR})}async function compile(e,i){const o=(0,reactiveCache_1.tryToGetReactiveProject)(e);return await o.updateProject(),i.__compileDebugInfo__?i.__compileDebugInfo__.ciVersion=config_1.CI_VERSION:i.__compileDebugInfo__={from:"inner",useNewCompileModule:!0,devtoolsVersion:"0",compileSetting:i.setting,ciVersion:config_1.CI_VERSION},process.env.isDevtools&&(e.nameMappingFromDevtools=i.nameMapping||{}),await checkProjectTypeMatchProjectAttr(e),e.type===config_1.COMPILE_TYPE.miniGame?(0,game_1.compile)(e,i):e.type===config_1.COMPILE_TYPE.miniProgramPlugin?(0,miniprogramPlugin_1.compile)(e,i):e.type===config_1.COMPILE_TYPE.miniGamePlugin?(0,gamePlugin_1.compile)(e,i):(0,miniprogram_1.compile)(e,i)}