"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileWXML=compileWXML;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),config_1=require("../../../../../config/config"),taskstatus_1=require("../../../../../utils/taskstatus"),workerThread_1=require("../../workerThread"),common_1=require("../../../../../utils/common");async function compileWXML(e,r,o){const{root:t="",setting:s={},onProgressUpdate:a=(()=>{})}=o,{minifyWXML:i}=s,l=new taskstatus_1.TaskStatus(r),c=path_1.default.posix.join(t,r),n=await e.getFile(t,r);if(!i){a(l);const e=(0,tools_1.bufferToUtf8String)(n);return void 0===e&&(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_UTF8.format(c),code:config_1.FILE_NOT_UTF8,filePath:c}),l.done(),a(l),{filePath:r,code:e.replace(/\r\n/g,"\n")}}const _=await(0,workerThread_1.runTask)(workerThread_1.TASK_NAME.MINIFY_WXML,{projectPath:e.projectPath,root:t,filePath:r,setting:s,code:n},e=>{e===workerThread_1.ETaskStatus.progress?a(l):e===workerThread_1.ETaskStatus.done&&(l.done(),a(l))});return _.error&&(0,common_1.throwError)({msg:_.error.message,code:_.error.code,filePath:c}),{filePath:r,code:_.code.replace(/\r\n/g,"\n")}}