"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compilePlugin=compilePlugin,exports.compile=compile;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),projectconfig_1=require("../json/projectconfig"),plugin_1=require("../json/plugin/plugin"),white_ext_list_1=require("../../../../utils/white_ext_list"),game_1=require("./game"),common_1=require("./common");async function compilePlugin(e,i){const t=(0,projectconfig_1.getProjectConfigJSON)(e),o=t.pluginRoot,{GameWhiteList:n}=await(0,white_ext_list_1.getWhiteExtList)(),l=e.getFileList(o,"").filter(common_1.isNotIgnoredByProjectConfig.bind(null,t,o)).filter(e=>n.has(path_1.default.posix.extname(e))),s=(0,plugin_1.getDevPluginJSON)(e,!1),a=l.filter(e=>".js"===path_1.default.posix.extname(e)).map(e=>path_1.default.posix.relative(o,e)),c=await(0,common_1.compileJSFiles)(e,a,o,i),p=l.filter(e=>".js"!==path_1.default.posix.extname(e)&&e!==path_1.default.posix.join(o,"plugin.json")),r=await(0,common_1.compileOther)(e,p,i);return Object.assign(Object.assign({[path_1.default.posix.join(o,"plugin.json")]:JSON.stringify(s)},c),r)}async function compile(e,i){const t=(0,projectconfig_1.getProjectConfigJSON)(e),o=await compilePlugin(e,i),n=await(0,game_1.compile)(e,i),l=await(0,common_1.getUploadProjectConfig)(e,t);return l.__compileDebugInfo__=i.__compileDebugInfo__||{},Object.assign(Object.assign(Object.assign({},o),n),{"project.config.json":JSON.stringify(l)})}