miniprogram-ci 2.1.29 → 2.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +5 -0
  3. package/dist/@types/config/config.d.ts +1 -1
  4. package/dist/@types/modules/corecompiler/baseCompiler.d.ts +1 -0
  5. package/dist/@types/modules/corecompiler/originalCompiler.d.ts +1 -0
  6. package/dist/@types/modules/corecompiler/summer/graph/basegraph.d.ts +2 -0
  7. package/dist/@types/modules/corecompiler/summer/module.d.ts +8 -3
  8. package/dist/@types/modules/corecompiler/summer/pluginconfig.d.ts +1 -1
  9. package/dist/@types/modules/corecompiler/summer/plugins/base/es6module.d.ts +0 -17
  10. package/dist/@types/modules/corecompiler/summer/plugins/filetask/script.d.ts +28 -0
  11. package/dist/@types/modules/corecompiler/summer/plugins/index.d.ts +1 -1
  12. package/dist/@types/modules/corecompiler/summer/plugins/script_task/babel_script_task.d.ts +22 -0
  13. package/dist/@types/modules/corecompiler/summer/plugins/script_task/load_script_task.d.ts +7 -0
  14. package/dist/@types/modules/corecompiler/summer/plugins/script_task/minify_script_task.d.ts +5 -0
  15. package/dist/@types/modules/corecompiler/summer/plugins/script_task/swc_task.d.ts +22 -0
  16. package/dist/@types/modules/corecompiler/summerCompiler.d.ts +4 -0
  17. package/dist/@types/modules/nativecompiler/processHandler.d.ts +5 -0
  18. package/dist/@types/types/devtools.d.ts +9 -0
  19. package/dist/@types/types/summer.d.ts +7 -2
  20. package/dist/@types/utils/babel_plugin_worklet.d.ts +10 -1
  21. package/dist/@types/utils/env.d.ts +1 -0
  22. package/dist/@types/utils/helper_util.d.ts +1 -1
  23. package/dist/@types/utils/packOptionsHelper.d.ts +1 -0
  24. package/dist/@types/utils/subprocess/processManager.d.ts +2 -1
  25. package/dist/ci/android-miniapp-toolkit/dist/index.js +1 -1
  26. package/dist/ci/build-apk.js +1 -1
  27. package/dist/config/config.js +1 -1
  28. package/dist/modules/corecompiler/original/json/game.js +1 -1
  29. package/dist/modules/corecompiler/original/workerThread/index.js +1 -1
  30. package/dist/modules/corecompiler/original/workerThread/task/minifywxml.js +1 -1
  31. package/dist/modules/corecompiler/originalCompiler.js +1 -1
  32. package/dist/modules/corecompiler/processHandler.js +1 -1
  33. package/dist/modules/corecompiler/summer/graph/basegraph.js +1 -1
  34. package/dist/modules/corecompiler/summer/module.js +1 -1
  35. package/dist/modules/corecompiler/summer/pluginconfig.js +1 -1
  36. package/dist/modules/corecompiler/summer/plugins/base/es6module.js +1 -1
  37. package/dist/modules/corecompiler/summer/plugins/base/javascript.js +1 -1
  38. package/dist/modules/corecompiler/summer/plugins/base/swc.js +1 -1
  39. package/dist/modules/corecompiler/summer/plugins/enhance.js +1 -1
  40. package/dist/modules/corecompiler/summer/plugins/filetask/script.js +1 -0
  41. package/dist/modules/corecompiler/summer/plugins/index.js +1 -1
  42. package/dist/modules/corecompiler/summer/plugins/less.js +1 -1
  43. package/dist/modules/corecompiler/summer/plugins/sass.js +1 -1
  44. package/dist/modules/corecompiler/summer/plugins/script_task/babel_script_task.js +1 -0
  45. package/dist/modules/corecompiler/summer/plugins/script_task/load_script_task.js +1 -0
  46. package/dist/modules/corecompiler/summer/plugins/script_task/minify_script_task.js +1 -0
  47. package/dist/modules/corecompiler/summer/plugins/script_task/swc_task.js +1 -0
  48. package/dist/modules/corecompiler/summer/plugins/terser.js +1 -1
  49. package/dist/modules/corecompiler/summer/plugins/typescript.js +1 -1
  50. package/dist/modules/corecompiler/summer/summer.js +1 -1
  51. package/dist/modules/corecompiler/summerCompiler.js +1 -1
  52. package/dist/modules/createSummer.js +1 -1
  53. package/dist/modules/nativecompiler/ios/buildCloud.js +1 -1
  54. package/dist/modules/nativecompiler/nativeEntryProcess.js +1 -1
  55. package/dist/modules/nativecompiler/processHandler.js +1 -0
  56. package/dist/utils/babel_plugin_worklet.js +1 -1
  57. package/dist/utils/cosUpload.js +1 -1
  58. package/dist/utils/debug.js +1 -1
  59. package/dist/utils/env.js +1 -1
  60. package/dist/utils/packOptionsHelper.js +1 -1
  61. package/dist/utils/subprocess/processManager.js +1 -1
  62. package/dist/utils/subprocess/processService.js +1 -1
  63. package/package.json +5 -54
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.generateCloudAndroidApk=exports.buildApk=void 0;const tslib_1=require("tslib"),request_1=require("../utils/request"),miniAppI18N_1=tslib_1.__importDefault(require("../utils/miniAppI18N")),checkBuildArgument_1=require("./miniapp/checkBuildArgument"),miniappJson_1=require("../utils/miniappJson"),tools_1=require("../utils/tools"),androidCloudBuild_1=require("./miniapp/androidCloudBuild"),log=tslib_1.__importStar(require("../utils/log")),tools_2=require("./utils/tools"),report_1=require("../utils/report");async function buildApk(e){const r=Date.now();let i;try{if(!e.project)throw new Error("缺少参数 project");const{project:r}=e;r.targetPlatform="mini-android",await r.miniappAttr();const{buildArchiveOpts:o,cloudBuildInfo:t}=(0,checkBuildArgument_1.transformAndroidBuildArgument)(e);e.disableCache&&((0,tools_2.clearAndroidCacheDir)(),log.info("清除 Apk 构建缓存成功")),i=await generateCloudAndroidApk(e,o,t)}catch(e){log.error("构建 Apk 失败:",e.message),i={success:!1,errmsg:"构建 Apk 失败:"+e.message}}const o=Date.now()-r;return e.project&&(0,report_1.reportAction)("buildApk",i.success?0:-1,i.errmsg,o,e.project),i}async function generateCloudAndroidApk(e,r,i){var o;const{project:t,output:s}=e;let n=!1,d="failed";try{miniAppI18N_1.default.createI18NInfo(t.projectPath);const{useCloudUpload:u,useAab:a,packageVersion:c,packageDesc:l,certificateInfo:p,uploadAppInfo:A}=i,g=Object.assign({},r);u?(g.useCloudSync=!0,g.version=c,g.desc=l):(g.version=A?A.userVersion:"",g.desc=A?A.userDesc:"");const k=(0,miniappJson_1.tryGetAndroidMiniappJson)(t.projectPath);await checkAndroidSdkVersion(k);const m=Object.assign(Object.assign({},e),{resourceDir:(0,tools_2.getMiniappCacheDir)(),robot:e.robot||1});let _="";_=a?await(0,androidCloudBuild_1.getAndroidAabBuild)(m).build(g,s,p.androidCertificate):await(0,androidCloudBuild_1.getAndroidApkBuild)(m).build(g,s,p.androidCertificate),(null===(o=k.channel)||void 0===o?void 0:o.value)&&(_=`${_.slice(0,-4)}-${k.channel.value}${a?".aab":".Apk"}`),log.success("构建 Apk 成功"),n=!0,d="success! output file at "+_}catch(e){n=!1,d=e.message,log.error("构建 Apk 失败:",e.message)}return{success:n,errmsg:d}}async function checkAndroidSdkVersion(e){if(e.sdkVersion&&(null==e?void 0:e.usePluginSdk)){const r="http://dldir1.qq.com/WechatWebDev/donut/android-extended-sdk-version.json";let{body:i}=await(0,request_1.request)({url:r,method:"get"});try{i=JSON.parse(i)}catch(e){}const o=i;if(o){Object.keys(e.usePluginSdk).forEach(r=>{const i=e.usePluginSdk[r];if(!i)return;const t=o[r][i].minMainSdk;if((0,tools_1.compareSemVer)(e.sdkVersion,t)<0)throw new Error("存在主模块 SDK 版本不满足拓展 SDK 使用最小版本情况,请检查")})}}}exports.buildApk=buildApk,exports.generateCloudAndroidApk=generateCloudAndroidApk;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.generateCloudAndroidApk=exports.buildApk=void 0;const tslib_1=require("tslib"),request_1=require("../utils/request"),miniAppI18N_1=tslib_1.__importDefault(require("../utils/miniAppI18N")),checkBuildArgument_1=require("./miniapp/checkBuildArgument"),miniappJson_1=require("../utils/miniappJson"),tools_1=require("../utils/tools"),androidCloudBuild_1=require("./miniapp/androidCloudBuild"),log=tslib_1.__importStar(require("../utils/log")),tools_2=require("./utils/tools"),report_1=require("../utils/report");async function buildApk(e){const r=Date.now();let i;try{if(!e.project)throw new Error("缺少参数 project");const{project:r}=e;r.targetPlatform="mini-android",await r.miniappAttr();const{buildArchiveOpts:o,cloudBuildInfo:t}=(0,checkBuildArgument_1.transformAndroidBuildArgument)(e);e.disableCache&&((0,tools_2.clearAndroidCacheDir)(),log.info("清除 Apk 构建缓存成功")),i=await generateCloudAndroidApk(e,o,t)}catch(e){log.error("构建 Apk 失败:",e.message),i={success:!1,errmsg:"构建 Apk 失败:"+e.message}}const o=Date.now()-r;return e.project&&(0,report_1.reportAction)("buildApk",i.success?0:-1,i.errmsg,o,e.project),i}async function generateCloudAndroidApk(e,r,i){var o;const{project:t,output:s}=e;let n=!1,d="failed";try{miniAppI18N_1.default.createI18NInfo(t.projectPath);const{useCloudUpload:u,useAab:a,packageVersion:c,packageDesc:l,certificateInfo:p,uploadAppInfo:A}=i,g=Object.assign({},r);u?(g.useCloudSync=!0,g.version=c,g.desc=l):(g.version=A?A.userVersion:"",g.desc=A?A.userDesc:"");const k=(0,miniappJson_1.tryGetAndroidMiniappJson)(t.projectPath);await checkAndroidSdkVersion(k);const m=Object.assign(Object.assign({},e),{resourceDir:(0,tools_2.getMiniappCacheDir)(),robot:e.robot||1});let _="";_=a?await(0,androidCloudBuild_1.getAndroidAabBuild)(m).build(g,s,p.androidCertificate):await(0,androidCloudBuild_1.getAndroidApkBuild)(m).build(g,s,p.androidCertificate),(null===(o=k.channel)||void 0===o?void 0:o.value)&&(_=`${_.slice(0,-4)}-${k.channel.value}${a?".aab":".Apk"}`),log.success("构建 Apk 成功"),n=!0,d="success! output file at "+_}catch(e){n=!1,d=e.message,log.error("构建 Apk 失败:",e.message)}return{success:n,errmsg:d}}async function checkAndroidSdkVersion(e){if(e.sdkVersion&&(null==e?void 0:e.usePluginSdk)){const r="http://dldir1.qq.com/WechatWebDev/donut/android-extended-sdk-version.json";let{body:i}=await(0,request_1.request)({url:r,method:"get"});try{i=JSON.parse(i)}catch(e){}const o=i;if(o){Object.keys(e.usePluginSdk).forEach(r=>{const i=e.usePluginSdk[r];if(!i)return;const t=o[r],s=t?t[i]:void 0;if(!s){const e=`当前使用的 ${r} 扩展SDK版本(${i})未包含在官方支持的版本列表内,请检查`;return void log.warn(e)}const n=s.minMainSdk;if((0,tools_1.compareSemVer)(e.sdkVersion,n)<0)throw new Error("存在主模块 SDK 版本不满足拓展 SDK 使用最小版本情况,请检查")})}}}exports.buildApk=buildApk,exports.generateCloudAndroidApk=generateCloudAndroidApk;
@@ -1 +1 @@
1
- "use strict";var COMPILE_TYPE,AstType,EFilterCode;function getDefaultIgnores(e){const _=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];return"multiPlatform"===e.projectArchitecture&&_.push(exports.multiPlatformRoot+"/**/*"),_}Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=exports.EFilterCode=exports.AstType=exports.compileTypeConfig=exports.getDefaultIgnores=exports.FullPkg=exports.MainPkg=exports.multiPlatformRoot=exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_WORKERS_PACKAGE_ROOT=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.CI_VERSION="2.1.29",exports.PARAM_ERROR=1e4,exports.WXML_NOT_FOUND=10007,exports.JS_NOT_FOUND=10008,exports.BABEL_TRANS_JS_ERR=10032,exports.UGLIFY_JS_ERR=10033,exports.BABILI_JS_ERR=10034,exports.JS_ES6_ERR=10035,exports.FILE_FLAT_ERR=10036,exports.POST_WXSS_ERR=10037,exports.MINIFY_WXML_ERR=10038,exports.SUMMER_PLUGIN_ERR=10045,exports.SUMMER_PLUGIN_CODE_ERR=10046,exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=10081,exports.PLUGIN_JSON_FILE_NOT_FOUND=10091,exports.PLUGIN_JSON_CONTENT_ERR=10092,exports.PLUGIN_JSON_PARSE_ERR=10093,exports.FILE_NOT_FOUND=10005,exports.JSON_PARSE_ERR=10006,exports.FILE_NOT_UTF8=10031,exports.JSON_CONTENT_ERR=10009,exports.APP_JSON_NOT_FOUND=2e4,exports.GET_SIGNATURE_RAND_STRING_ERR=20001,exports.GENERATE_LOCAL_SIGNATURE_ERR=20002,exports.UPLOAD_CGI_ERR=20003,exports.CODE_PROTECT_TRANSLATE_FILENAME=20004,exports.UPLOAD_JS_SERVER_CGI_ERR=20005,exports.GET_LATEST_VERSION_CGI_ERR=20006,exports.PROJECT_TYPE_ERROR=3e4,exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT="__APP__",exports.MINI_GAME_MAIN_PACKAGE_ROOT="__GAME__",exports.MINI_GAME_WORKERS_PACKAGE_ROOT="workers.js",exports.APP_TYPE={NORMAL:0,PLUGIN:1,SHOP:2,MINISHOP:3,GAME:4,CARD:5,NATIVE:7},function(e){e.miniProgram="miniProgram",e.miniProgramPlugin="miniProgramPlugin",e.miniGame="miniGame",e.miniGamePlugin="miniGamePlugin"}(COMPILE_TYPE=exports.COMPILE_TYPE||(exports.COMPILE_TYPE={})),exports.TABBAR_ICON_WHITE_LIST=[".png",".jpg",".jpeg"],exports.DefaultProjectAttr={platform:!1,appType:0,isSandbox:!1,released:!1,setting:{MaxCodeSize:2,MaxSubpackageSubCodeSize:2,MaxSubpackageFullCodeSize:12,NavigateMiniprogramLimit:10,MaxSubPackageLimit:100,MinTabbarCount:2,MaxTabbarCount:5,MaxCustomTabbarCount:10,MaxTabbarIconSize:40}},exports.jsonVariablePropertyWhiteList={windowPropertWhiteList:["navigationBarBackgroundColor","navigationBarTextStyle","backgroundColor","backgroundTextStyle","backgroundColorTop","backgroundColorBottom","backgroundColorContent"],tabBarPropertyWhiteList:["color","selectedColor","backgroundColor","borderStyle"],tabbarListItemPropertyWhiteList:["iconPath","selectedIconPath"]},exports.extendedLibMap={kbone:{packages:["miniprogram-element","miniprogram-render"]},weui:{packages:["weui-miniprogram"]}},exports.multiPlatformRoot="miniapp",exports.MainPkg="__APP__",exports.FullPkg="__FULL__",exports.getDefaultIgnores=getDefaultIgnores,exports.compileTypeConfig={weapp:"weapp",game:"game",plugin:"plugin",gamePlugin:"gamePlugin"},function(e){e.Babel="babel",e.Acorn="acorn"}(AstType=exports.AstType||(exports.AstType={})),function(e){e[e.Include=0]="Include",e[e.PackOptionsIgnore=1]="PackOptionsIgnore",e[e.AnalyseNoUse=2]="AnalyseNoUse",e[e.PartialCompileNoUse=3]="PartialCompileNoUse"}(EFilterCode=exports.EFilterCode||(exports.EFilterCode={})),exports.MAX_CODE_LENGTH=2048e3;
1
+ "use strict";var COMPILE_TYPE,AstType,EFilterCode;function getDefaultIgnores(e){const _=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];return"multiPlatform"===e.projectArchitecture&&_.push(exports.multiPlatformRoot+"/**/*"),_}Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=exports.EFilterCode=exports.AstType=exports.compileTypeConfig=exports.getDefaultIgnores=exports.FullPkg=exports.MainPkg=exports.multiPlatformRoot=exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_WORKERS_PACKAGE_ROOT=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.CI_VERSION="2.1.31",exports.PARAM_ERROR=1e4,exports.WXML_NOT_FOUND=10007,exports.JS_NOT_FOUND=10008,exports.BABEL_TRANS_JS_ERR=10032,exports.UGLIFY_JS_ERR=10033,exports.BABILI_JS_ERR=10034,exports.JS_ES6_ERR=10035,exports.FILE_FLAT_ERR=10036,exports.POST_WXSS_ERR=10037,exports.MINIFY_WXML_ERR=10038,exports.SUMMER_PLUGIN_ERR=10045,exports.SUMMER_PLUGIN_CODE_ERR=10046,exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=10081,exports.PLUGIN_JSON_FILE_NOT_FOUND=10091,exports.PLUGIN_JSON_CONTENT_ERR=10092,exports.PLUGIN_JSON_PARSE_ERR=10093,exports.FILE_NOT_FOUND=10005,exports.JSON_PARSE_ERR=10006,exports.FILE_NOT_UTF8=10031,exports.JSON_CONTENT_ERR=10009,exports.APP_JSON_NOT_FOUND=2e4,exports.GET_SIGNATURE_RAND_STRING_ERR=20001,exports.GENERATE_LOCAL_SIGNATURE_ERR=20002,exports.UPLOAD_CGI_ERR=20003,exports.CODE_PROTECT_TRANSLATE_FILENAME=20004,exports.UPLOAD_JS_SERVER_CGI_ERR=20005,exports.GET_LATEST_VERSION_CGI_ERR=20006,exports.PROJECT_TYPE_ERROR=3e4,exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT="__APP__",exports.MINI_GAME_MAIN_PACKAGE_ROOT="__GAME__",exports.MINI_GAME_WORKERS_PACKAGE_ROOT="workers.js",exports.APP_TYPE={NORMAL:0,PLUGIN:1,SHOP:2,MINISHOP:3,GAME:4,CARD:5,NATIVE:7},function(e){e.miniProgram="miniProgram",e.miniProgramPlugin="miniProgramPlugin",e.miniGame="miniGame",e.miniGamePlugin="miniGamePlugin"}(COMPILE_TYPE=exports.COMPILE_TYPE||(exports.COMPILE_TYPE={})),exports.TABBAR_ICON_WHITE_LIST=[".png",".jpg",".jpeg"],exports.DefaultProjectAttr={platform:!1,appType:0,isSandbox:!1,released:!1,setting:{MaxCodeSize:2,MaxSubpackageSubCodeSize:2,MaxSubpackageFullCodeSize:12,NavigateMiniprogramLimit:10,MaxSubPackageLimit:100,MinTabbarCount:2,MaxTabbarCount:5,MaxCustomTabbarCount:10,MaxTabbarIconSize:40}},exports.jsonVariablePropertyWhiteList={windowPropertWhiteList:["navigationBarBackgroundColor","navigationBarTextStyle","backgroundColor","backgroundTextStyle","backgroundColorTop","backgroundColorBottom","backgroundColorContent"],tabBarPropertyWhiteList:["color","selectedColor","backgroundColor","borderStyle"],tabbarListItemPropertyWhiteList:["iconPath","selectedIconPath"]},exports.extendedLibMap={kbone:{packages:["miniprogram-element","miniprogram-render"]},weui:{packages:["weui-miniprogram"]}},exports.multiPlatformRoot="miniapp",exports.MainPkg="__APP__",exports.FullPkg="__FULL__",exports.getDefaultIgnores=getDefaultIgnores,exports.compileTypeConfig={weapp:"weapp",game:"game",plugin:"plugin",gamePlugin:"gamePlugin"},function(e){e.Babel="babel",e.Acorn="acorn"}(AstType=exports.AstType||(exports.AstType={})),function(e){e[e.Include=0]="Include",e[e.PackOptionsIgnore=1]="PackOptionsIgnore",e[e.AnalyseNoUse=2]="AnalyseNoUse",e[e.PartialCompileNoUse=3]="PartialCompileNoUse"}(EFilterCode=exports.EFilterCode||(exports.EFilterCode={})),exports.MAX_CODE_LENGTH=2048e3;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),cache_1=require("../../../../utils/cache"),common_1=require("../../../../utils/common"),config_1=require("../../../../config/config"),tools_1=require("../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),schemaValidate_1=require("../validate/schemaValidate"),signaturejson_1=tslib_1.__importDefault(require("../validate/signaturejson")),gamepluginjson_1=tslib_1.__importDefault(require("../validate/gamepluginjson")),projectconfig_1=require("./projectconfig"),common_2=require("./common"),reactiveCache_1=require("./reactiveCache");function isPluginMode(o){return o.type===config_1.COMPILE_TYPE.miniGamePlugin}function checkLocalPlugin(o,t){const{project:e,root:a,filePath:i}=o,r=t.path;let n=e.stat(a,r);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t.tips+'["path"]',locales_1.default.config.DIRECTORY),filePath:i});const s=path_1.default.posix.join(r,"signature.json");n=e.stat(a,s);let c=(0,tools_1.normalizePath)(path_1.default.posix.join(a,s));n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',c),filePath:i,code:config_1.FILE_NOT_FOUND});let _=e.getFile(a,s),l=(0,common_1.checkUTF8)(_,c);const f=(0,common_2.checkJSONFormat)(l,c);try{signaturejson_1.default.check(f)}catch(o){(0,common_1.throwError)({msg:"signature.json"+o.message,filePath:c})}f.provider!==t.provider&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format('["provider"]',`"${t.provider}"`),filePath:c});for(let o=0;o<f.signature.length;o++){const t=f.signature[o];(0,common_1.checkPath)({value:t.path,tips:`["signature"][${o}]["path"]`,filePath:c});const i=path_1.default.posix.join(r,t.path);n=e.stat(a,i),n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["signature"][${o}]["path"]`,i),filePath:c,code:config_1.FILE_NOT_FOUND});const s=e.getFile(a,i),_=(0,tools_1.generateMD5)(s);_!==t.md5&&(0,common_1.throwError)({msg:locales_1.default.config.GAME_PLUGIN_SIGNATURE_MD5_NOT_MATCH_CONTENT.format(path_1.default.posix.join(r,t.path),_,t.md5),code:config_1.GAME_PLUGIN_LIB_MD5_NOT_MATCH,filePath:c})}const u=path_1.default.posix.join(r,"plugin.json");n=e.stat(a,u),c=(0,tools_1.normalizePath)(path_1.default.posix.join(a,u)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',c),code:config_1.FILE_NOT_FOUND,filePath:i}),_=e.getFile(a,u),l=(0,common_1.checkUTF8)(_,c);const h=(0,common_2.checkJSONFormat)(l,c);try{gamepluginjson_1.default.check(h)}catch(o){(0,common_1.throwError)({msg:"plugin.json"+o.message,filePath:c})}h.main&&((0,common_1.checkPath)({value:h.main,tips:'["main"]',filePath:c}),n=e.stat(a,path_1.default.posix.join(r,h.main)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["main"]',""+h.main),filePath:c,code:config_1.FILE_NOT_FOUND}))}function checkPluginPath(o,t){const{subPackages:e}=t,a=[],i=(o,t,e)=>{const{plugins:i}=o;if(i)for(const o in i){if(!i.hasOwnProperty(o))continue;const r=i[o];r&&r.path&&a.push({alias:o,version:r.version||"",provider:r.provider||"",tips:`${e}["plugins"]["${o}"]`,path:(0,tools_1.normalizePath)(path_1.default.posix.join(t,r.path))})}};if(i(t,"",""),e)for(let o=0;o<e.length;o++){const t=e[o];i(t,t.root||"",`["subPackages"][${o}]`)}if(!(a.length<=0))for(const t of a)checkLocalPlugin(o,t)}function checkPlugins(o,t){const{project:e,filePath:a}=o,i=[],r=t.plugins||{};function n(o,t){const{appid:r}=e,n=isPluginMode(e);if(n||"dev"!==o.version)if(n&&"dev"===o.version&&o.provider!==r)i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["provider"]',r));else if("dev"!==o.version||"string"!=typeof o.path){if("dev"===o.version||"latest"===o.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(o.version)||/^dev-[A-Za-z0-9]+$/.test(o.version))return o.path&&(0,common_1.checkPath)({value:o.path,tips:t+'["path"]',filePath:a}),!0;i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT))}else i.push(locales_1.default.config.GAME_DEV_PLUGIN_SHOULD_NOT_USE_LOCAL_PATH.format(t,t+'["path"]'));else i.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(t+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}const s={},c={};for(const o in r){if(!r.hasOwnProperty(o))continue;const t=r[o];n(t,`["plugins"]["${o}"]`)&&(s[t.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${o}"]`,s[t.provider].tips,"provider")):s[t.provider]=c[o]={provider:t.provider,version:t.version,alias:o,path:t.path||"",tips:`["plugins"]["${o}"]`})}const _=t.subPackages||t.subpackages;if(Array.isArray(_))for(let o=0,t=_.length;o<t;o++){const t=_[o];if(!t.plugins)continue;const e=`["subPackages"][${o}]["plugins"]`;for(const o in t.plugins){const a=t.plugins[o],r=`${e}["${o}"]`;n(a,r)&&(s[a.provider]?i.push(locales_1.default.config.SAME_ITEM.format(r,s[a.provider].tips,"provider")):c[o]?i.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(r,c[o].tips)):s[a.provider]=c[o]={provider:a.provider,version:a.version,alias:o,path:a.path||"",tips:r})}}i.length>0&&(0,common_1.throwError)({msg:i.join("\n"),filePath:a})}function checkSubpackages(o,t){const{root:e,project:a,filePath:i}=o,r=[];let n='["subPackages"]';if(t.subpackages&&(n='["subpackages"]',t.subPackages=t.subpackages,delete t.subpackages),t.subPackages){const o=a.attrSync(),{setting:s}=o;t.subPackages.length>s.MaxSubPackageLimit&&(0,common_1.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([n,s.MaxSubPackageLimit]),filePath:i});const c={},_={};for(let o=0,i=t.subPackages.length;o<i;o++){const i=t.subPackages[o];if(i.name){if(i.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(i.name===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}c[i.name]&&r.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,c[i.name],"name")),c[i.name]=`${n}[${o}]`}if(i.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(i.root===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}if(i.root===config_1.MINI_GAME_WORKERS_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_WORKERS_PACKAGE_ROOT));continue}if(i.root==="/"+config_1.MINI_GAME_WORKERS_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,"/"+config_1.MINI_GAME_WORKERS_PACKAGE_ROOT));continue}if(i.root.startsWith(".")){r.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"."));continue}if(i.root.startsWith("__wx__")){r.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"__wx__"));continue}i.root.startsWith("/")||(i.root=(0,tools_1.normalizePath)("/"+i.root)),i.root.endsWith(".js")?i.root=(0,tools_1.normalizePath)(i.root):i.root=(0,tools_1.normalizePath)(i.root+"/"),_[i.root]&&r.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,_[i.root],"root")),_[i.root]=`${n}[${o}]`;const s=a.stat(e,i.root);if(s){if(s.isDirectory){i.root.endsWith("/")||(i.root+="/");const t=path_1.default.posix.join(i.root,"./game.js"),s=a.stat(e,t);s&&s.isFile||r.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`${n}[${o}]["root"]`,t))}}else r.push(locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`${n}[${o}]["root"]`))}}r.length>0&&(0,common_1.throwError)({msg:r.join("\n"),filePath:i})}function checkLoadingImageUrl(o,t){const{project:e,root:a,filePath:i}=o,{loadingImageInfo:r}=t;if(!r)return;(0,common_1.checkPath)({tips:'["loadingImageInfo"]["path"]',value:r.path,filePath:i});const n=e.stat(a,r.path);n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`["loadingImageInfo"]["path"]: "${r.path}"`),filePath:i}),r.progressBarColor&&!(0,tools_1.isHexColor)(r.progressBarColor)&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["loadingImageInfo"]["progressBarColor"]: "${r.progressBarColor}"`,"HexColor"),filePath:i})}function checkWorkers(o,t){const{project:e,root:a,filePath:i}=o,{workers:r}=t;if(void 0===r)return;const n=(0,tools_1.getWorkersPath)(r);(0,common_1.checkPath)({tips:'["workers"]',value:n,filePath:i});const s=e.stat(a,n);s&&!s.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["workers"]',locales_1.default.config.DIRECTORY]),filePath:i})}function checkOpenDataContext(o,t){const{project:e,root:a,filePath:i}=o,{openDataContext:r}=t;if(void 0===r)return;(0,common_1.checkPath)({value:r,tips:'["openDataContext"]',filePath:i});const n=e.stat(a,r);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:i});const s=path_1.default.posix.join(r,"./index.js"),c=e.stat(a,s);c&&c.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',s),filePath:i}),t.openDataContext=(0,tools_1.normalizePath)(r+"/")}function checkGameJSON(o){const{project:t,root:e,filePath:a}=o;t.stat(e,"game.json")||(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(path_1.default.posix.join(a)),filePath:a,code:config_1.FILE_NOT_FOUND});const i=t.getFile(e,"game.json"),r=(0,common_2.checkJSONFormat)((0,common_1.checkUTF8)(i,a),a),n=(0,schemaValidate_1.schemaValidate)("game",r);return n.warning&&(r.__warning__=locales_1.default.config.INVALID.format(n.warning)),(0,schemaValidate_1.transValidateResult)(a,n),checkOpenDataContext(o,r),checkPlugins(o,r),checkSubpackages(o,r),checkPluginPath(o,r),checkLoadingImageUrl(o,r),checkWorkers(o,r),r}const getGameJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.GAME_JSON,o=>{const t=(0,projectconfig_1.getProjectConfigJSON)(o).miniprogramRoot||"";return checkGameJSON({project:o,root:t,filePath:(0,tools_1.normalizePath)(path_1.default.posix.join(t,"game.json"))})});exports.default=getGameJSON;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),cache_1=require("../../../../utils/cache"),common_1=require("../../../../utils/common"),config_1=require("../../../../config/config"),tools_1=require("../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),schemaValidate_1=require("../validate/schemaValidate"),signaturejson_1=tslib_1.__importDefault(require("../validate/signaturejson")),gamepluginjson_1=tslib_1.__importDefault(require("../validate/gamepluginjson")),projectconfig_1=require("./projectconfig"),common_2=require("./common"),reactiveCache_1=require("./reactiveCache");function isPluginMode(o){return o.type===config_1.COMPILE_TYPE.miniGamePlugin}function checkLocalPlugin(o,t){const{project:e,root:a,filePath:i}=o,r=t.path;let n=e.stat(a,r);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t.tips+'["path"]',locales_1.default.config.DIRECTORY),filePath:i});const c=path_1.default.posix.join(r,"signature.json");n=e.stat(a,c);let s=(0,tools_1.normalizePath)(path_1.default.posix.join(a,c));n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',s),filePath:i,code:config_1.FILE_NOT_FOUND});let _=e.getFile(a,c),l=(0,common_1.checkUTF8)(_,s);const f=(0,common_2.checkJSONFormat)(l,s);try{signaturejson_1.default.check(f)}catch(o){(0,common_1.throwError)({msg:"signature.json"+o.message,filePath:s})}f.provider!==t.provider&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format('["provider"]',`"${t.provider}"`),filePath:s});for(let o=0;o<f.signature.length;o++){const t=f.signature[o];(0,common_1.checkPath)({value:t.path,tips:`["signature"][${o}]["path"]`,filePath:s});const i=path_1.default.posix.join(r,t.path);n=e.stat(a,i),n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["signature"][${o}]["path"]`,i),filePath:s,code:config_1.FILE_NOT_FOUND});const c=e.getFile(a,i),_=(0,tools_1.generateMD5)(c);_!==t.md5&&(0,common_1.throwError)({msg:locales_1.default.config.GAME_PLUGIN_SIGNATURE_MD5_NOT_MATCH_CONTENT.format(path_1.default.posix.join(r,t.path),_,t.md5),code:config_1.GAME_PLUGIN_LIB_MD5_NOT_MATCH,filePath:s})}const g=path_1.default.posix.join(r,"plugin.json");n=e.stat(a,g),s=(0,tools_1.normalizePath)(path_1.default.posix.join(a,g)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',s),code:config_1.FILE_NOT_FOUND,filePath:i}),_=e.getFile(a,g),l=(0,common_1.checkUTF8)(_,s);const u=(0,common_2.checkJSONFormat)(l,s);try{gamepluginjson_1.default.check(u)}catch(o){(0,common_1.throwError)({msg:"plugin.json"+o.message,filePath:s})}u.main&&((0,common_1.checkPath)({value:u.main,tips:'["main"]',filePath:s}),n=e.stat(a,path_1.default.posix.join(r,u.main)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["main"]',""+u.main),filePath:s,code:config_1.FILE_NOT_FOUND}))}function checkPluginPath(o,t){const{subPackages:e}=t,a=[],i=(o,t,e)=>{const{plugins:i}=o;if(i)for(const o in i){if(!i.hasOwnProperty(o))continue;const r=i[o];r&&r.path&&a.push({alias:o,version:r.version||"",provider:r.provider||"",tips:`${e}["plugins"]["${o}"]`,path:(0,tools_1.normalizePath)(path_1.default.posix.join(t,r.path))})}};if(i(t,"",""),e)for(let o=0;o<e.length;o++){const t=e[o];i(t,t.root||"",`["subPackages"][${o}]`)}if(!(a.length<=0))for(const t of a)checkLocalPlugin(o,t)}function checkPlugins(o,t){const{project:e,filePath:a}=o,i=[],r=t.plugins||{};function n(o,t){const{appid:r}=e,n=isPluginMode(e),c=(0,projectconfig_1.getProjectConfigJSON)(e),s=(null==c?void 0:c.pluginAppid)||r;if(n||"dev"!==o.version)if(n&&"dev"===o.version&&o.provider!==s)i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["provider"]',s));else if("dev"!==o.version||"string"!=typeof o.path){if("dev"===o.version||"latest"===o.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(o.version)||/^dev-[A-Za-z0-9]+$/.test(o.version))return o.path&&(0,common_1.checkPath)({value:o.path,tips:t+'["path"]',filePath:a}),!0;i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT))}else i.push(locales_1.default.config.GAME_DEV_PLUGIN_SHOULD_NOT_USE_LOCAL_PATH.format(t,t+'["path"]'));else i.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(t+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}const c={},s={};for(const o in r){if(!r.hasOwnProperty(o))continue;const t=r[o];n(t,`["plugins"]["${o}"]`)&&(c[t.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${o}"]`,c[t.provider].tips,"provider")):c[t.provider]=s[o]={provider:t.provider,version:t.version,alias:o,path:t.path||"",tips:`["plugins"]["${o}"]`})}const _=t.subPackages||t.subpackages;if(Array.isArray(_))for(let o=0,t=_.length;o<t;o++){const t=_[o];if(!t.plugins)continue;const e=`["subPackages"][${o}]["plugins"]`;for(const o in t.plugins){const a=t.plugins[o],r=`${e}["${o}"]`;n(a,r)&&(c[a.provider]?i.push(locales_1.default.config.SAME_ITEM.format(r,c[a.provider].tips,"provider")):s[o]?i.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(r,s[o].tips)):c[a.provider]=s[o]={provider:a.provider,version:a.version,alias:o,path:a.path||"",tips:r})}}i.length>0&&(0,common_1.throwError)({msg:i.join("\n"),filePath:a})}function checkSubpackages(o,t){const{root:e,project:a,filePath:i}=o,r=[];let n='["subPackages"]';if(t.subpackages&&(n='["subpackages"]',t.subPackages=t.subpackages,delete t.subpackages),t.subPackages){const o=a.attrSync(),{setting:c}=o;t.subPackages.length>c.MaxSubPackageLimit&&(0,common_1.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([n,c.MaxSubPackageLimit]),filePath:i});const s={},_={};for(let o=0,i=t.subPackages.length;o<i;o++){const i=t.subPackages[o];if(i.name){if(i.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(i.name===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}s[i.name]&&r.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,s[i.name],"name")),s[i.name]=`${n}[${o}]`}if(i.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(i.root===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}if(i.root===config_1.MINI_GAME_WORKERS_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_WORKERS_PACKAGE_ROOT));continue}if(i.root==="/"+config_1.MINI_GAME_WORKERS_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,"/"+config_1.MINI_GAME_WORKERS_PACKAGE_ROOT));continue}if(i.root.startsWith(".")){r.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"."));continue}if(i.root.startsWith("__wx__")){r.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"__wx__"));continue}i.root.startsWith("/")||(i.root=(0,tools_1.normalizePath)("/"+i.root)),i.root.endsWith(".js")?i.root=(0,tools_1.normalizePath)(i.root):i.root=(0,tools_1.normalizePath)(i.root+"/"),_[i.root]&&r.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,_[i.root],"root")),_[i.root]=`${n}[${o}]`;const c=a.stat(e,i.root);if(c){if(c.isDirectory){i.root.endsWith("/")||(i.root+="/");const t=path_1.default.posix.join(i.root,"./game.js"),c=a.stat(e,t);c&&c.isFile||r.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`${n}[${o}]["root"]`,t))}}else r.push(locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`${n}[${o}]["root"]`))}}r.length>0&&(0,common_1.throwError)({msg:r.join("\n"),filePath:i})}function checkLoadingImageUrl(o,t){const{project:e,root:a,filePath:i}=o,{loadingImageInfo:r}=t;if(!r)return;(0,common_1.checkPath)({tips:'["loadingImageInfo"]["path"]',value:r.path,filePath:i});const n=e.stat(a,r.path);n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`["loadingImageInfo"]["path"]: "${r.path}"`),filePath:i}),r.progressBarColor&&!(0,tools_1.isHexColor)(r.progressBarColor)&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["loadingImageInfo"]["progressBarColor"]: "${r.progressBarColor}"`,"HexColor"),filePath:i})}function checkWorkers(o,t){const{project:e,root:a,filePath:i}=o,{workers:r}=t;if(void 0===r)return;const n=(0,tools_1.getWorkersPath)(r);(0,common_1.checkPath)({tips:'["workers"]',value:n,filePath:i});const c=e.stat(a,n);c&&!c.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["workers"]',locales_1.default.config.DIRECTORY]),filePath:i})}function checkOpenDataContext(o,t){const{project:e,root:a,filePath:i}=o,{openDataContext:r}=t;if(void 0===r)return;(0,common_1.checkPath)({value:r,tips:'["openDataContext"]',filePath:i});const n=e.stat(a,r);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:i});const c=path_1.default.posix.join(r,"./index.js"),s=e.stat(a,c);s&&s.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',c),filePath:i}),t.openDataContext=(0,tools_1.normalizePath)(r+"/")}function checkGameJSON(o){const{project:t,root:e,filePath:a}=o;t.stat(e,"game.json")||(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(path_1.default.posix.join(a)),filePath:a,code:config_1.FILE_NOT_FOUND});const i=t.getFile(e,"game.json"),r=(0,common_2.checkJSONFormat)((0,common_1.checkUTF8)(i,a),a),n=(0,schemaValidate_1.schemaValidate)("game",r);return n.warning&&(r.__warning__=locales_1.default.config.INVALID.format(n.warning)),(0,schemaValidate_1.transValidateResult)(a,n),checkOpenDataContext(o,r),checkPlugins(o,r),checkSubpackages(o,r),checkPluginPath(o,r),checkLoadingImageUrl(o,r),checkWorkers(o,r),r}const getGameJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.GAME_JSON,o=>{const t=(0,projectconfig_1.getProjectConfigJSON)(o).miniprogramRoot||"";return checkGameJSON({project:o,root:t,filePath:(0,tools_1.normalizePath)(path_1.default.posix.join(t,"game.json"))})});exports.default=getGameJSON;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.abortTask=exports.runTask=void 0;const tslib_1=require("tslib"),logger_1=require("../utils/logger"),workerManager_1=require("./workerManager"),childprocessManager_1=require("./childprocessManager"),index_1=tslib_1.__importDefault(require("./task/index")),env_1=require("../../../../utils/env");tslib_1.__exportStar(require("./config"),exports);const isDevtools=void 0!==(null===process||void 0===process?void 0:process.env.__nwjs);async function runTask(r,e,o=(()=>{})){var s;if(logger_1.logger.info("runTask",r,e.filePath),global.__MINIPROGRAM_CI_TEST__||"true"===(null===(s=null===process||void 0===process?void 0:process.env)||void 0===s?void 0:s.__MINIPROGRAM_CI_TEST__))return(0,index_1.default)(r,e);try{if((null===process||void 0===process?void 0:process.__nwjs)&&"wechatwebdevtools"===nw.App.manifest.appname)return await childprocessManager_1.childProcessManager.runTask(r,e,o);const s=(0,workerManager_1.getWorkerManager)(isDevtools);return await s.runTask(r,e,o)}catch(o){if(env_1.isWebIDE)throw o;if(o===workerManager_1.AbortEvent)throw o;if(logger_1.logger.error(`runTask ${r}, ${e.filePath} catch error ${o}`),o instanceof childprocessManager_1.ChildProcessCrashedError)throw new Error(`runTask ${r}, ${e.filePath} catch error ${o}`);return(0,index_1.default)(r,e)}}function abortTask(r){(0,workerManager_1.getWorkerManager)(isDevtools).abort(r)}exports.runTask=runTask,exports.abortTask=abortTask;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.abortTask=exports.runTask=void 0;const tslib_1=require("tslib"),logger_1=require("../utils/logger"),workerManager_1=require("./workerManager"),childprocessManager_1=require("./childprocessManager"),index_1=tslib_1.__importDefault(require("./task/index")),env_1=require("../../../../utils/env");tslib_1.__exportStar(require("./config"),exports);const isDevtools=void 0!==(null===process||void 0===process?void 0:process.env.__nwjs);async function runTask(r,e,o=(()=>{})){var s,a;if(logger_1.logger.info("runTask",r,e.filePath),global.__MINIPROGRAM_CI_TEST__||"true"===(null===(s=null===process||void 0===process?void 0:process.env)||void 0===s?void 0:s.__MINIPROGRAM_CI_TEST__))return(0,index_1.default)(r,e);try{if((null===process||void 0===process?void 0:process.__nwjs)&&"wechatwebdevtools"===nw.App.manifest.appname||(null===(a=null===process||void 0===process?void 0:process.versions)||void 0===a?void 0:a.electron))return await childprocessManager_1.childProcessManager.runTask(r,e,o);const s=(0,workerManager_1.getWorkerManager)(isDevtools);return await s.runTask(r,e,o)}catch(o){if(env_1.isWebIDE)throw o;if(o===workerManager_1.AbortEvent)throw o;if(logger_1.logger.error(`runTask ${r}, ${e.filePath} catch error ${o}`),o instanceof childprocessManager_1.ChildProcessCrashedError)throw new Error(`runTask ${r}, ${e.filePath} catch error ${o}`);return(0,index_1.default)(r,e)}}function abortTask(r){(0,workerManager_1.getWorkerManager)(isDevtools).abort(r)}exports.runTask=runTask,exports.abortTask=abortTask;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.minifyWXML=exports.StyleAttrValueTokenizer=exports.TemplateTokenizer=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),log=tslib_1.__importStar(require("../../../../../utils/log")),config_1=require("../../../../../config/config");function getCharCode(T){return T.charCodeAt(0)>=256?BASE_STATE.OTHERS:T.charCodeAt(0)}function trimStringLeft(T,E=!0){return E?T.trimLeft():T.split("\n").map(T=>T.replace(/^[ \t]*/g,"")).join("\n")}function trimStringRight(T,E=!0){return E?T.trimRight():T.split("\n").map(T=>T.replace(/[ \t]*$/,"")).join("\n")}var TokenType,BASE_STATE,STATE,TEMPLATE_STATE,STYLE_ATTR_VALUE_STATE,ACTION;!function(T){T[T.ATTR=0]="ATTR",T[T.TAG=1]="TAG",T[T.LEFT_ANGLE_BRACKET=2]="LEFT_ANGLE_BRACKET",T[T.RIGHT_ANGLE_BRACKET=3]="RIGHT_ANGLE_BRACKET",T[T.END_LEFT_ANGLE_BRACKET=4]="END_LEFT_ANGLE_BRACKET",T[T.STRING1=5]="STRING1",T[T.STRING2=6]="STRING2",T[T.ATTR_VALUE=7]="ATTR_VALUE",T[T.TEXT_VALUE=8]="TEXT_VALUE",T[T.TAG_TEXT_VALUE=9]="TAG_TEXT_VALUE",T[T.TEMPLATE_START=10]="TEMPLATE_START",T[T.TEMPLATE_END=11]="TEMPLATE_END",T[T.TEMPLATE_ITEM=12]="TEMPLATE_ITEM",T[T.TEMPLATE_STRING=13]="TEMPLATE_STRING",T[T.SELF_CLOSE=14]="SELF_CLOSE",T[T.WXS_VALUE=15]="WXS_VALUE",T[T.STYLE_KEY=16]="STYLE_KEY",T[T.TAG_EQ=17]="TAG_EQ",T[T.STYLE_VALUE=18]="STYLE_VALUE",T[T.STYLE_ATTR_VALUE=19]="STYLE_ATTR_VALUE",T[T.CLASS_ATTR_VALUE=20]="CLASS_ATTR_VALUE",T[T.OTHERS=21]="OTHERS"}(TokenType||(TokenType={})),function(T){T[T.ERROR=-1]="ERROR",T[T.NOT_SET=0]="NOT_SET",T[T.START=1]="START",T[T.OTHERS=2]="OTHERS",T[T.END=3]="END",T[T.MAX_STATE=4]="MAX_STATE"}(BASE_STATE||(BASE_STATE={})),function(T){T[T.IN_TAG_TEXT=5]="IN_TAG_TEXT",T[T.TAG_START=6]="TAG_START",T[T.IN_TAG_WORD=7]="IN_TAG_WORD",T[T.TAG_EQ=8]="TAG_EQ",T[T.IN_TAG_ATTR_WORD=9]="IN_TAG_ATTR_WORD",T[T.IN_TAG_ATTR_VALUE_STRING=10]="IN_TAG_ATTR_VALUE_STRING",T[T.IN_TAG_ATTR_VALUE_STRING_ESCAPE=11]="IN_TAG_ATTR_VALUE_STRING_ESCAPE",T[T.IN_TAG_ATTR_VALUE_STRING_SINGLE=12]="IN_TAG_ATTR_VALUE_STRING_SINGLE",T[T.IN_TAG_ATTR_VALUE_STRING_SINGLE_ESCAPE=13]="IN_TAG_ATTR_VALUE_STRING_SINGLE_ESCAPE",T[T.WAIT_TEMPLATE_START=14]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE=15]="IN_TEMPLATE",T[T.WAIT_TEMPLATE_END=16]="WAIT_TEMPLATE_END",T[T.TEMPLATE_END_CHECK=17]="TEMPLATE_END_CHECK",T[T.IN_TEMPLATE_STRING=18]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=19]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=20]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=21]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_RIGHT_BRACKET=22]="WAIT_FOR_RIGHT_BRACKET",T[T.IN_WXS=23]="IN_WXS",T[T.IN_WXS_STRING=24]="IN_WXS_STRING",T[T.IN_WXS_STRING_ESCAPE=25]="IN_WXS_STRING_ESCAPE",T[T.IN_WXS_STRING_SINGLE=26]="IN_WXS_STRING_SINGLE",T[T.IN_WXS_STRING_SINGLE_ESCAPE=27]="IN_WXS_STRING_SINGLE_ESCAPE",T[T.WXS_END_STEP=28]="WXS_END_STEP",T[T.IN_COMMENT_BEGIN1=29]="IN_COMMENT_BEGIN1",T[T.IN_COMMENT_BEGIN2=30]="IN_COMMENT_BEGIN2",T[T.IN_COMMENT=31]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END1=32]="WAIT_FOR_COMMENT_END1",T[T.WAIT_FOR_COMMENT_END2=33]="WAIT_FOR_COMMENT_END2",T[T.IN_TEXT=34]="IN_TEXT",T[T.IN_END_TAG=35]="IN_END_TAG",T[T.IN_END_TAG_WORD=36]="IN_END_TAG_WORD",T[T.MAX_STATE=37]="MAX_STATE"}(STATE||(STATE={})),function(T){T[T.WAIT_TEMPLATE_START=5]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE_ITEM=6]="IN_TEMPLATE_ITEM",T[T.WAIT_TEMPLATE_END=7]="WAIT_TEMPLATE_END",T[T.SPACE_AFTER_WAIT_TEMPLATE_END=8]="SPACE_AFTER_WAIT_TEMPLATE_END",T[T.IN_TEMPLATE_STRING=9]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=10]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=11]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=12]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_COMMENT_START=13]="WAIT_FOR_COMMENT_START",T[T.IN_COMMENT=14]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END=15]="WAIT_FOR_COMMENT_END",T[T.IN_TEMPLATE_SPACE=16]="IN_TEMPLATE_SPACE",T[T.MAX_STATE=17]="MAX_STATE"}(TEMPLATE_STATE||(TEMPLATE_STATE={})),function(T){T[T.WAIT_KEY=5]="WAIT_KEY",T[T.IN_KEY=6]="IN_KEY",T[T.WAIT_KEY_VALUE_SAPERATE=7]="WAIT_KEY_VALUE_SAPERATE",T[T.IN_KEY_VALUE_SAPERATE=8]="IN_KEY_VALUE_SAPERATE",T[T.WAIT_VALUE=9]="WAIT_VALUE",T[T.IN_VALUE=10]="IN_VALUE",T[T.WAIT_ITEM_SAPERATE=11]="WAIT_ITEM_SAPERATE",T[T.IN_ITEM_SAPERATE=12]="IN_ITEM_SAPERATE",T[T.IN_STRING=13]="IN_STRING",T[T.IN_STRING_ESCAPE=14]="IN_STRING_ESCAPE",T[T.IN_STRING2=15]="IN_STRING2",T[T.IN_STRING2_ESCAPE=16]="IN_STRING2_ESCAPE",T[T.WAIT_TEMPLATE_START=17]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE=18]="IN_TEMPLATE",T[T.WAIT_TEMPLATE_END=19]="WAIT_TEMPLATE_END",T[T.IN_TEMPLATE_STRING=20]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=21]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=22]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=23]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_COMMENT_START=24]="WAIT_FOR_COMMENT_START",T[T.IN_COMMENT=25]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END=26]="WAIT_FOR_COMMENT_END",T[T.MAX_STATE=27]="MAX_STATE"}(STYLE_ATTR_VALUE_STATE||(STYLE_ATTR_VALUE_STATE={})),function(T){T[T.NOTHING=0]="NOTHING",T[T.DO_ACTION=65536]="DO_ACTION",T[T.STORE_TOKEN_EXCLUDE=131072]="STORE_TOKEN_EXCLUDE",T[T.STORE_TOKEN_INCLUDE=262144]="STORE_TOKEN_INCLUDE",T[T.IGNORE=524288]="IGNORE",T[T.REFEED=1048576]="REFEED",T[T.STORE_TOKEN_FIRST=2097152]="STORE_TOKEN_FIRST",T[T.STORE_ONE_SPACE=4194304]="STORE_ONE_SPACE",T[T.STORE_ONE_LINE_BREAK=8388608]="STORE_ONE_LINE_BREAK",T[T.GET_STATE_BEFORE=16777216]="GET_STATE_BEFORE",T[T.STORE_STATE_BEFORE=33554432]="STORE_STATE_BEFORE",T[T.SET_WXS_STATE=67108864]="SET_WXS_STATE",T[T.RECORD_IN_TEMPLATE_OBJECT=134217728]="RECORD_IN_TEMPLATE_OBJECT",T[T.CHECK_IN_TEMPLATE_OBJECT=268435456]="CHECK_IN_TEMPLATE_OBJECT"}(ACTION||(ACTION={}));class Token{constructor(T,E){this.type=T,this.value=E}}class MachineState{constructor(){this.cur_pos=0,this.last_pos=0,this.line=1,this.col=1,this.mark_pos=0,this.mark_col=0,this.last_line=this.line,this.last_col=1,this.state=BASE_STATE.START,this.in_template_object_count=0}}const ALPHA="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-:",DIGIT="0123456789.",WHITECHARS=" \n\t\r";class BaseMachine{constructor(T,E){this.mState=new MachineState,this.storedStates=[],this.oldState=BASE_STATE.START,this.tokens=[],this.mPath=T,this.mSrc=E}FillTT(T,E,_,A){for(const S of A)this.TT[T][getCharCode(S)]=E|_}Reset(){return this.mState.cur_pos=0,this.mState.last_pos=0,this.mState.mark_pos=0,this.mState.line=1,this.mState.col=1,this.mState.last_col=1,this.mState.mark_col=1,this.mState.last_line=this.mState.line,this.mState.state=BASE_STATE.START,0}refeed(T){let E=this.TT[this.mState.state][getCharCode(T)];if(E===BASE_STATE.NOT_SET&&(E=this.TT[this.mState.state][BASE_STATE.OTHERS]),E===BASE_STATE.NOT_SET)throw{col:this.mState.col,line:this.mState.line,message:"BAD STATE MACHINE!"};if(E<0){if("\0"!==T)throw{col:this.mState.col,line:this.mState.line,message:`unexpected character \`${T.replace(/\n/g,"\\n")}\``};throw{col:this.mState.col,line:this.mState.line,message:"unexpected end"}}const _=E,A=65535&E,S=this.mState.state;_&ACTION.STORE_STATE_BEFORE&&(this.storedStates.push(S),this.mState.mark_pos=this.mState.cur_pos,this.mState.mark_col=this.mState.mark_col),this.mState.state=A,this.doAction(T,S,_)}Feed(T){"\n"===T&&(this.mState.line++,this.mState.col=0),this.refeed(T)}FillTT_template_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[T][getCharCode(_)]=E,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}updatePosition(){this.mState.last_pos=this.mState.cur_pos,this.mState.last_col=this.mState.col,this.mState.last_line=this.mState.line}processPosition(){this.mState.cur_pos++,this.mState.col++}doAction(T,E,_){if(_&ACTION.STORE_TOKEN_FIRST&&this.mState.mark_pos>this.mState.last_pos){const T=this.mSrc.substring(this.mState.last_pos,this.mState.mark_pos);this.doExcludeAction(this.storedStates[this.storedStates.length-1],T),this.mState.last_pos=this.mState.mark_pos,this.mState.last_col=this.mState.mark_col}if(_&ACTION.STORE_ONE_LINE_BREAK&&(this.appendToken(TokenType.OTHERS,"\n"),this.updatePosition()),_&ACTION.STORE_ONE_SPACE&&(this.appendToken(TokenType.OTHERS," "),this.updatePosition()),_&ACTION.STORE_TOKEN_EXCLUDE){const T=this.mState.cur_pos,_=this.mState.last_pos;if(T>=_){const A=this.mSrc.substring(_,T);this.doExcludeAction(E,A),this.updatePosition()}}if(_&ACTION.RECORD_IN_TEMPLATE_OBJECT&&this.mState.in_template_object_count++,_&ACTION.CHECK_IN_TEMPLATE_OBJECT&&this.mState.in_template_object_count>0&&(this.mState.in_template_object_count--,this.mState.state=STATE.IN_TEMPLATE),_&ACTION.REFEED){if(_&ACTION.IGNORE&&this.updatePosition(),_&ACTION.GET_STATE_BEFORE){const T=this.storedStates.pop();T&&(this.mState.state=T)}this.refeed(T)}else{if(this.processPosition(),_&ACTION.STORE_TOKEN_INCLUDE){const _=this.mSrc.substring(this.mState.last_pos,this.mState.cur_pos);this.doIncludeAction(T,E,_),this.updatePosition()}if(_&ACTION.IGNORE&&this.updatePosition(),_&ACTION.GET_STATE_BEFORE){const T=this.storedStates.pop();T&&(this.mState.state=T)}}}}class StyleAttrValueMachine extends BaseMachine{get TT(){return StyleAttrValueMachine._TT||this.InitTransitTable(),StyleAttrValueMachine._TT}constructor(T,E){super(T,E),this.mState.state=BASE_STATE.START}getTokens(){return[...this.tokens]}appendToken(T,E){T===TokenType.STYLE_VALUE&&(E=E.replace(/[ \t]+/g," ")),this.tokens.push(new Token(T,E))}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case STYLE_ATTR_VALUE_STATE.IN_KEY:_=TokenType.STYLE_KEY;break;case STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE:_=TokenType.OTHERS;break;case STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE:_=TokenType.OTHERS,E=";";break;case STYLE_ATTR_VALUE_STATE.IN_VALUE:_=TokenType.STYLE_VALUE}this.appendToken(_,E)}doIncludeAction(T,E,_){let A=TokenType.OTHERS;switch(E){case STYLE_ATTR_VALUE_STATE.IN_STRING:A=TokenType.STRING1;break;case STYLE_ATTR_VALUE_STATE.IN_STRING2:A=TokenType.STRING2;break;case STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END:A=TokenType.TEMPLATE_ITEM,_=new TemplateTokenizer(_,this.mPath).toString();break;case STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START:this.doExcludeAction(this.storedStates[this.storedStates.length-1],_.replace(/\/\*$/,"")),A=TokenType.OTHERS,_="/*";break;case STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END:A=TokenType.OTHERS,_="*/"}this.appendToken(A,_)}FillTT_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[T][getCharCode("\n")]=BASE_STATE.ERROR,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[A][getCharCode("\n")]=E|ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE,this.TT[T][getCharCode(_)]=E|ACTION.STORE_TOKEN_INCLUDE,this.TT[T][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}InitTransitTable(){StyleAttrValueMachine._TT=new Array(STYLE_ATTR_VALUE_STATE.MAX_STATE);for(let T=0;T<STYLE_ATTR_VALUE_STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.END,this.FillTT(BASE_STATE.START,BASE_STATE.START,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.START][getCharCode(":")]=BASE_STATE.ERROR,this.TT[BASE_STATE.START][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[BASE_STATE.START][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_KEY,STYLE_ATTR_VALUE_STATE.WAIT_KEY,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode(":")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_KEY,STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("'")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.WAIT_KEY|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_VALUE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED|ACTION.STORE_TOKEN_EXCLUDE,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_VALUE,STYLE_ATTR_VALUE_STATE.WAIT_VALUE,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode(":")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("\0")]=BASE_STATE.END,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_STRING|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_STRING2|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_KEY,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("'")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.STORE_TOKEN_FIRST,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=ACTION.GET_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("}")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("\\")]=BASE_STATE.ERROR,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,ACTION.NOTHING," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][0]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][getCharCode("}")]=ACTION.GET_STATE_BEFORE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING|ACTION.NOTHING,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING2|ACTION.NOTHING,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START][getCharCode("*")]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START][BASE_STATE.OTHERS]=ACTION.GET_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_COMMENT][getCharCode("*")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END,this.TT[STYLE_ATTR_VALUE_STATE.IN_COMMENT][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.IGNORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END][getCharCode("/")]=ACTION.GET_STATE_BEFORE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.NOTHING,this.FillTT_template_string(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.NOTHING,'"'),this.FillTT_template_string(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING2,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.NOTHING,"'"),this.FillTT_string(STYLE_ATTR_VALUE_STATE.IN_STRING,ACTION.GET_STATE_BEFORE,'"'),this.FillTT_string(STYLE_ATTR_VALUE_STATE.IN_STRING2,ACTION.GET_STATE_BEFORE,"'")}}class TemplateMachine extends BaseMachine{get TT(){return TemplateMachine._TT||this.InitTransitTable(),TemplateMachine._TT}constructor(T,E){super(T,E),this.mState.state=BASE_STATE.START}getTokens(){return[...this.tokens]}appendToken(T,E){this.tokens.push(new Token(T,E))}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case TEMPLATE_STATE.IN_TEMPLATE_ITEM:case TEMPLATE_STATE.WAIT_TEMPLATE_END:_=TokenType.TEMPLATE_ITEM}this.appendToken(_,E)}doIncludeAction(T,E,_){let A=TokenType.OTHERS;switch(E){case TEMPLATE_STATE.WAIT_TEMPLATE_START:A=TokenType.TEMPLATE_START;break;case TEMPLATE_STATE.WAIT_TEMPLATE_END:A=TokenType.TEMPLATE_END}this.appendToken(A,_)}InitTransitTable(){TemplateMachine._TT=new Array(TEMPLATE_STATE.MAX_STATE);for(let T=0;T<TEMPLATE_STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.FillTT(BASE_STATE.START,BASE_STATE.START,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.START][getCharCode("{")]=TEMPLATE_STATE.WAIT_TEMPLATE_START,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_START][getCharCode("{")]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE,this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(TEMPLATE_STATE.IN_TEMPLATE_SPACE,TEMPLATE_STATE.IN_TEMPLATE_SPACE,ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode('"')]=TEMPLATE_STATE.IN_TEMPLATE_STRING|ACTION.STORE_STATE_BEFORE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("'")]=TEMPLATE_STATE.IN_TEMPLATE_STRING2|ACTION.STORE_STATE_BEFORE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("/")]=TEMPLATE_STATE.WAIT_FOR_COMMENT_START,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.FillTT(TEMPLATE_STATE.IN_TEMPLATE_ITEM,TEMPLATE_STATE.IN_TEMPLATE_SPACE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("\\")]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode('"')]=TEMPLATE_STATE.IN_TEMPLATE_STRING|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("'")]=TEMPLATE_STATE.IN_TEMPLATE_STRING2|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][0]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_START][getCharCode("*")]=TEMPLATE_STATE.IN_COMMENT,this.FillTT(TEMPLATE_STATE.WAIT_FOR_COMMENT_START,TEMPLATE_STATE.IN_TEMPLATE_ITEM,ACTION.REFEED," \n\t\r"),this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_START][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.TT[TEMPLATE_STATE.IN_COMMENT][getCharCode("*")]=TEMPLATE_STATE.WAIT_FOR_COMMENT_END,this.TT[TEMPLATE_STATE.IN_COMMENT][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_COMMENT,this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_END][getCharCode("/")]=TEMPLATE_STATE.IN_TEMPLATE_SPACE|ACTION.IGNORE,this.FillTT_template_string(TEMPLATE_STATE.IN_TEMPLATE_STRING,TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE|ACTION.GET_STATE_BEFORE,'"'),this.FillTT_template_string(TEMPLATE_STATE.IN_TEMPLATE_STRING2,TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE|ACTION.GET_STATE_BEFORE,"'"),this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_END][getCharCode("}")]=BASE_STATE.END|ACTION.STORE_TOKEN_INCLUDE,this.FillTT(TEMPLATE_STATE.WAIT_TEMPLATE_END,TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,ACTION.STORE_TOKEN_EXCLUDE," \n\t\r"),this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.REFEED,this.FillTT(TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END|ACTION.STORE_ONE_SPACE,this.TT[TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.IGNORE|ACTION.REFEED,this.FillTT(BASE_STATE.END,BASE_STATE.END,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.END][getCharCode("\0")]=BASE_STATE.END,this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.ERROR}}class TemplateTokenizer{constructor(T,E){this.machine=new TemplateMachine(E,T),this.m_pSrc=T,this.path=E}toString(){this.tokens||(this.tokens=this.generateTokens());return this.tokens.map(T=>T.value).join("")}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}return this.machine.Feed("\0"),this.machine.getTokens()}}exports.TemplateTokenizer=TemplateTokenizer;class StyleAttrValueTokenizer{constructor(T,E){this.machine=new StyleAttrValueMachine(E,T),this.m_pSrc=T,this.path=E}toString(){return this.tokens||(this.tokens=this.generateTokens()),this.tokens.map(T=>T.value).join("")}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}return this.machine.Feed("\0"),this.machine.getTokens()}}exports.StyleAttrValueTokenizer=StyleAttrValueTokenizer;class Machine extends BaseMachine{get TT(){return Machine._TT||this.InitTransitTable(),Machine._TT}constructor(T,E){super(T,E),this.tagStack=[],this.InitTransitTable(),this.mPath=T,this.mSrc=E}get wxsState(){return"wxs"===this.tagStack[this.tagStack.length-1]}get textState(){return"text"===this.tagStack[this.tagStack.length-1]}getTokens(){return[...this.tokens]}checkLastTokenIfTypeMatch(T){var E;return(null===(E=this.tokens[this.tokens.length-1])||void 0===E?void 0:E.type)===T?this.tokens[this.tokens.length-1]:void 0}getLastTokenIfTypeMatch(T){if(0!==this.tokens.length)for(let E=this.tokens.length-1;E>=0;E--){const _=this.tokens[E];if(_.type===T)return _}}canBeOmittedTokenType(T){return T===TokenType.WXS_VALUE}appendToken(T,E){if(this.canBeOmittedTokenType(T)&&(E=this.transTagTextTokenValue(E)),T===TokenType.ATTR_VALUE){const T=this.getLastTokenIfTypeMatch(TokenType.ATTR);"style"===(null==T?void 0:T.value)&&(E=this.trySlimStyleAttrValue(E))}E&&this.tokens.push(new Token(T,E))}transTagTextTokenValue(T){return this.wxsState?T=T.split("\n").map(T=>T.trim()).join("\n"):T}trySlimStyleAttrValue(T){const E=[];try{if(T.length<=1)return T;for(let T=this.tokens.length-1;T>=0;T--){if(this.tokens[T].type===TokenType.TAG_EQ)break;E.unshift(this.tokens.pop())}const _=`${E.map(T=>null==T?void 0:T.value).join("")}${T}`,A=_.startsWith('"')||_.startsWith("'"),S=_.endsWith('"')||_.endsWith("'"),t=new StyleAttrValueTokenizer(_.replace(/^['"]/,"").replace(/['"]$/,""),this.mPath).toString();return`${A?_.substr(0,1):""}${t}${S?_.substr(_.length-1,1):""}`}catch(T){this.tokens.push(...E)}return T}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case STATE.IN_TAG_ATTR_VALUE_STRING:case STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE:_=TokenType.ATTR_VALUE;break;case STATE.IN_TAG_WORD:_=TokenType.TAG,this.tagStack.push(E);break;case STATE.IN_END_TAG_WORD:_=TokenType.TAG;if(this.tagStack.pop()!==E)throw{col:this.mState.col-E.length,line:this.mState.line,message:"unexpected end tag: "+E};break;case STATE.IN_WXS:_=TokenType.WXS_VALUE;break;case STATE.IN_TEXT:_=TokenType.TEXT_VALUE;break;case STATE.IN_TAG_TEXT:_=TokenType.TAG_TEXT_VALUE;break;case STATE.IN_TAG_ATTR_WORD:_=TokenType.ATTR;break;case STATE.TAG_START:_=TokenType.LEFT_ANGLE_BRACKET;break;case STATE.IN_TEMPLATE:_=TokenType.TEMPLATE_ITEM;break;case STATE.TAG_EQ:_=TokenType.TAG_EQ;break;case STATE.TEMPLATE_END_CHECK:{const T=this.mState.cur_pos;if("}"===this.mSrc.substring(T-3,T-2))throw{col:this.mState.col-3,line:this.mState.line,message:"unexpected end tag: }. } should not be followed by }} direactly, add a space and change it to } }}"};this.appendToken(TokenType.TEMPLATE_ITEM,""+new TemplateTokenizer(E,this.mPath)),_=TokenType.TEMPLATE_END,E=""}}this.appendToken(_,E)}doIncludeAction(T,E,_){const A=this.mState.state;let S;E===STATE.WXS_END_STEP?(this.appendToken(TokenType.WXS_VALUE,_.substr(0,_.length-2)),S=TokenType.END_LEFT_ANGLE_BRACKET,_="</"):E===STATE.IN_WXS_STRING||E===STATE.IN_WXS_STRING_SINGLE?S=TokenType.WXS_VALUE:E===STATE.IN_TAG_ATTR_VALUE_STRING||E===STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE?S=TokenType.ATTR_VALUE:E===STATE.TAG_START&&A===STATE.IN_END_TAG?S=TokenType.END_LEFT_ANGLE_BRACKET:E===STATE.WAIT_FOR_RIGHT_BRACKET?(S=TokenType.SELF_CLOSE,this.tagStack.pop()):S=TokenType.OTHERS,">"!==T||E!==STATE.IN_TAG_WORD&&E!==STATE.IN_TAG_ATTR_WORD&&E!==STATE.IN_TAG_ATTR_VALUE_STRING&&E!==STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE&&E!==STATE.IN_END_TAG_WORD||(S=TokenType.RIGHT_ANGLE_BRACKET),this.appendToken(S,_)}Feed(T){super.Feed(T),this.wxsState&&this.mState.state===STATE.IN_TAG_TEXT&&(this.mState.state=STATE.IN_WXS),this.textState&&this.mState.state===STATE.IN_TAG_TEXT&&(this.mState.state=STATE.IN_TEXT)}FillTT_attr_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[T][getCharCode("\n")]=BASE_STATE.ERROR,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[A][getCharCode("\n")]=E|ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE,this.TT[T][getCharCode(_)]=E|ACTION.STORE_TOKEN_INCLUDE,this.TT[T][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}InitTransitTable(){Machine._TT=new Array(STATE.MAX_STATE);for(let T=0;T<STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.END,this.TT[BASE_STATE.START][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.NOTHING,this.TT[BASE_STATE.START][0]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_TEXT][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_STATE_BEFORE,this.TT[STATE.IN_TAG_TEXT][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STATE.IN_TAG_TEXT][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.NOTHING,this.TT[STATE.IN_TAG_TEXT][0]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_TEXT][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT,this.TT[STATE.WAIT_TEMPLATE_START][getCharCode("{")]=STATE.IN_TEMPLATE|ACTION.STORE_TOKEN_FIRST,this.TT[STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.GET_STATE_BEFORE,this.TT[STATE.IN_TEMPLATE][getCharCode("{")]=STATE.IN_TEMPLATE|ACTION.RECORD_IN_TEMPLATE_OBJECT,this.TT[STATE.IN_TEMPLATE][getCharCode("}")]=STATE.WAIT_TEMPLATE_END|ACTION.CHECK_IN_TEMPLATE_OBJECT,this.TT[STATE.IN_TEMPLATE][getCharCode("\\")]=BASE_STATE.ERROR,this.FillTT(STATE.IN_TEMPLATE,STATE.IN_TEMPLATE,ACTION.NOTHING," \n\t\r"),this.TT[STATE.IN_TEMPLATE][BASE_STATE.OTHERS]=STATE.IN_TEMPLATE,this.TT[STATE.IN_TEMPLATE][0]=BASE_STATE.ERROR,this.TT[STATE.WAIT_TEMPLATE_END][getCharCode("}")]=STATE.TEMPLATE_END_CHECK,this.TT[STATE.TEMPLATE_END_CHECK][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.REFEED|ACTION.STORE_TOKEN_EXCLUDE|ACTION.GET_STATE_BEFORE,this.TT[STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=STATE.IN_TEMPLATE|ACTION.REFEED,this.TT[STATE.IN_TEMPLATE][getCharCode('"')]=STATE.IN_TEMPLATE_STRING|ACTION.NOTHING,this.TT[STATE.IN_TEMPLATE][getCharCode("'")]=STATE.IN_TEMPLATE_STRING2|ACTION.NOTHING,this.FillTT_template_string(STATE.IN_TEMPLATE_STRING,STATE.IN_TEMPLATE|ACTION.NOTHING,'"'),this.FillTT_template_string(STATE.IN_TEMPLATE_STRING2,STATE.IN_TEMPLATE|ACTION.NOTHING,"'"),this.FillTT(STATE.TAG_START,STATE.TAG_START,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.TAG_START,STATE.IN_TAG_WORD,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.TAG_START][getCharCode("/")]=STATE.IN_END_TAG|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.TAG_START][getCharCode("!")]=STATE.IN_COMMENT_BEGIN1,this.TT[STATE.TAG_START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT_BEGIN1][getCharCode("-")]=STATE.IN_COMMENT_BEGIN2,this.TT[STATE.IN_COMMENT_BEGIN1][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT_BEGIN2][getCharCode("-")]=STATE.IN_COMMENT,this.TT[STATE.IN_COMMENT_BEGIN2][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END1,this.TT[STATE.IN_COMMENT][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.TT[STATE.WAIT_FOR_COMMENT_END1][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END2,this.TT[STATE.WAIT_FOR_COMMENT_END1][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.TT[STATE.WAIT_FOR_COMMENT_END2][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.IGNORE|ACTION.GET_STATE_BEFORE,this.TT[STATE.WAIT_FOR_COMMENT_END2][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END2,this.TT[STATE.WAIT_FOR_COMMENT_END2][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_TAG_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_TAG_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_WORD][0]=BASE_STATE.ERROR,this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode("=")]=STATE.TAG_EQ|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_ATTR_WORD][0]=BASE_STATE.ERROR,this.FillTT(STATE.TAG_EQ,STATE.TAG_EQ,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.TAG_EQ,STATE.IN_TAG_ATTR_VALUE_STRING,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.TAG_EQ][getCharCode('"')]=STATE.IN_TAG_ATTR_VALUE_STRING|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.TAG_EQ][getCharCode("'")]=STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.TAG_EQ][0]=BASE_STATE.ERROR,this.TT[STATE.TAG_EQ][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.IN_END_TAG,STATE.IN_END_TAG,ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.IN_END_TAG,STATE.IN_END_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_END_TAG,BASE_STATE.ERROR,ACTION.NOTHING,DIGIT),this.TT[STATE.IN_END_TAG][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_END_TAG][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_END_TAG_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_END_TAG_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_END_TAG_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.WAIT_FOR_RIGHT_BRACKET,STATE.IN_TAG_WORD,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.WAIT_FOR_RIGHT_BRACKET][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.WAIT_FOR_RIGHT_BRACKET][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT_attr_string(STATE.IN_TAG_ATTR_VALUE_STRING,STATE.IN_TAG_ATTR_WORD,'"'),this.FillTT_attr_string(STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE,STATE.IN_TAG_ATTR_WORD,"'"),this.TT[STATE.IN_WXS][getCharCode("<")]=STATE.WXS_END_STEP,this.TT[STATE.IN_WXS][getCharCode('"')]=STATE.IN_WXS_STRING|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_WXS][getCharCode("'")]=STATE.IN_WXS_STRING_SINGLE|ACTION.STORE_TOKEN_EXCLUDE,this.FillTT_attr_string(STATE.IN_WXS_STRING,STATE.IN_WXS,'"'),this.FillTT_attr_string(STATE.IN_WXS_STRING_SINGLE,STATE.IN_WXS,"'"),this.TT[STATE.IN_WXS][BASE_STATE.OTHERS]=STATE.IN_WXS,this.TT[STATE.WXS_END_STEP][getCharCode("/")]=STATE.IN_END_TAG|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.WXS_END_STEP][BASE_STATE.OTHERS]=STATE.IN_WXS,this.TT[STATE.IN_TEXT][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TEXT][BASE_STATE.OTHERS]=STATE.IN_TEXT,this.TT[STATE.IN_TEXT][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE}}class Tokenizer{constructor(T,E){this.machine=new Machine(E,T),this.m_pSrc=T,this.path=E}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];try{for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}this.machine.Feed("\0")}catch(T){throw new Error(`${T.line}:${T.col}:${T.message}`)}return this.machine.getTokens()}}function generateWXMLFromTokens(T,E={collapseWhitespace:!0,conservativeCollapse:!1,preserveLineBreaks:!1}){const{collapseWhitespace:_,conservativeCollapse:A,preserveLineBreaks:S}=E,t=[];for(let E=0;E<T.length;E++){const e=T[E];let N=e.value;const R=e.type;if(R===TokenType.ATTR&&(N=" "+N),R===TokenType.TAG_TEXT_VALUE){S||(N=N.replace(/\n/g," ")),_&&(N=N.replace(/([ \t])+/g," "));const t=T[E-1];t&&t.type!==TokenType.RIGHT_ANGLE_BRACKET&&t.type!==TokenType.SELF_CLOSE||_&&!A&&(N=trimStringLeft(N,!1)),(null==t?void 0:t.type)===TokenType.TAG_TEXT_VALUE&&((null==t?void 0:t.value.endsWith(" "))||(null==t?void 0:t.value.endsWith("\n")))&&_&&(N=trimStringLeft(N,!1))}if(R===TokenType.LEFT_ANGLE_BRACKET||R===TokenType.END_LEFT_ANGLE_BRACKET){const S=T[E-1];if((null==S?void 0:S.type)===TokenType.TAG_TEXT_VALUE&&_&&!A){const T=t.pop()||"";t.push(trimStringRight(T,!1))}}t.push(N)}return t.join("")}async function minifyWXML(T){const{filePath:E,root:_=""}=T,A=T.code instanceof Buffer?T.code.toString():T.code,S=Object.assign({collapseWhitespace:!0,conservativeCollapse:!1,preserveLineBreaks:!1},T.setting),t=path_1.default.posix.join(_,E);if(A.length>0)try{const T=new Tokenizer(A.replace(/\r\n/g,"\n"),t);return{error:null,code:generateWXMLFromTokens(T.generateTokens(),S)}}catch(T){return log.error("minifywxml error @ "+t),log.error(T.message),{error:{code:config_1.MINIFY_WXML_ERR,path:t,message:T.message}}}return{error:null,code:A.replace(/\r\n/g,"\n")}}exports.minifyWXML=minifyWXML;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.minifyWXML=exports.StyleAttrValueTokenizer=exports.TemplateTokenizer=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),log=tslib_1.__importStar(require("../../../../../utils/log")),config_1=require("../../../../../config/config");function getCharCode(T){return T.charCodeAt(0)>=256?BASE_STATE.OTHERS:T.charCodeAt(0)}function trimStringLeft(T,E=!0){return E?T.trimLeft():T.split("\n").map(T=>T.replace(/^[ \t]*/g,"")).join("\n")}function trimStringRight(T,E=!0){return E?T.trimRight():T.split("\n").map(T=>T.replace(/[ \t]*$/,"")).join("\n")}var TokenType,BASE_STATE,STATE,TEMPLATE_STATE,STYLE_ATTR_VALUE_STATE,ACTION;!function(T){T[T.ATTR=0]="ATTR",T[T.TAG=1]="TAG",T[T.LEFT_ANGLE_BRACKET=2]="LEFT_ANGLE_BRACKET",T[T.RIGHT_ANGLE_BRACKET=3]="RIGHT_ANGLE_BRACKET",T[T.END_LEFT_ANGLE_BRACKET=4]="END_LEFT_ANGLE_BRACKET",T[T.STRING1=5]="STRING1",T[T.STRING2=6]="STRING2",T[T.ATTR_VALUE=7]="ATTR_VALUE",T[T.TEXT_VALUE=8]="TEXT_VALUE",T[T.TAG_TEXT_VALUE=9]="TAG_TEXT_VALUE",T[T.TEMPLATE_START=10]="TEMPLATE_START",T[T.TEMPLATE_END=11]="TEMPLATE_END",T[T.TEMPLATE_ITEM=12]="TEMPLATE_ITEM",T[T.TEMPLATE_STRING=13]="TEMPLATE_STRING",T[T.SELF_CLOSE=14]="SELF_CLOSE",T[T.WXS_VALUE=15]="WXS_VALUE",T[T.STYLE_KEY=16]="STYLE_KEY",T[T.TAG_EQ=17]="TAG_EQ",T[T.STYLE_VALUE=18]="STYLE_VALUE",T[T.STYLE_ATTR_VALUE=19]="STYLE_ATTR_VALUE",T[T.CLASS_ATTR_VALUE=20]="CLASS_ATTR_VALUE",T[T.OTHERS=21]="OTHERS"}(TokenType||(TokenType={})),function(T){T[T.ERROR=-1]="ERROR",T[T.NOT_SET=0]="NOT_SET",T[T.START=1]="START",T[T.OTHERS=2]="OTHERS",T[T.END=3]="END",T[T.MAX_STATE=4]="MAX_STATE"}(BASE_STATE||(BASE_STATE={})),function(T){T[T.IN_TAG_TEXT=5]="IN_TAG_TEXT",T[T.TAG_START=6]="TAG_START",T[T.IN_TAG_WORD=7]="IN_TAG_WORD",T[T.TAG_EQ=8]="TAG_EQ",T[T.IN_TAG_ATTR_WORD=9]="IN_TAG_ATTR_WORD",T[T.IN_TAG_ATTR_VALUE_STRING=10]="IN_TAG_ATTR_VALUE_STRING",T[T.IN_TAG_ATTR_VALUE_STRING_ESCAPE=11]="IN_TAG_ATTR_VALUE_STRING_ESCAPE",T[T.IN_TAG_ATTR_VALUE_STRING_SINGLE=12]="IN_TAG_ATTR_VALUE_STRING_SINGLE",T[T.IN_TAG_ATTR_VALUE_STRING_SINGLE_ESCAPE=13]="IN_TAG_ATTR_VALUE_STRING_SINGLE_ESCAPE",T[T.WAIT_TEMPLATE_START=14]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE=15]="IN_TEMPLATE",T[T.WAIT_TEMPLATE_END=16]="WAIT_TEMPLATE_END",T[T.TEMPLATE_END_CHECK=17]="TEMPLATE_END_CHECK",T[T.IN_TEMPLATE_STRING=18]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=19]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=20]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=21]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_RIGHT_BRACKET=22]="WAIT_FOR_RIGHT_BRACKET",T[T.IN_WXS=23]="IN_WXS",T[T.IN_WXS_STRING=24]="IN_WXS_STRING",T[T.IN_WXS_STRING_ESCAPE=25]="IN_WXS_STRING_ESCAPE",T[T.IN_WXS_STRING_SINGLE=26]="IN_WXS_STRING_SINGLE",T[T.IN_WXS_STRING_SINGLE_ESCAPE=27]="IN_WXS_STRING_SINGLE_ESCAPE",T[T.WXS_END_STEP=28]="WXS_END_STEP",T[T.IN_COMMENT_BEGIN1=29]="IN_COMMENT_BEGIN1",T[T.IN_COMMENT_BEGIN2=30]="IN_COMMENT_BEGIN2",T[T.IN_COMMENT=31]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END1=32]="WAIT_FOR_COMMENT_END1",T[T.WAIT_FOR_COMMENT_END2=33]="WAIT_FOR_COMMENT_END2",T[T.IN_TEXT=34]="IN_TEXT",T[T.IN_END_TAG=35]="IN_END_TAG",T[T.IN_END_TAG_WORD=36]="IN_END_TAG_WORD",T[T.MAX_STATE=37]="MAX_STATE"}(STATE||(STATE={})),function(T){T[T.WAIT_TEMPLATE_START=5]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE_ITEM=6]="IN_TEMPLATE_ITEM",T[T.WAIT_TEMPLATE_END=7]="WAIT_TEMPLATE_END",T[T.SPACE_AFTER_WAIT_TEMPLATE_END=8]="SPACE_AFTER_WAIT_TEMPLATE_END",T[T.IN_TEMPLATE_STRING=9]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=10]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=11]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=12]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_COMMENT_START=13]="WAIT_FOR_COMMENT_START",T[T.IN_COMMENT=14]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END=15]="WAIT_FOR_COMMENT_END",T[T.IN_TEMPLATE_SPACE=16]="IN_TEMPLATE_SPACE",T[T.MAX_STATE=17]="MAX_STATE"}(TEMPLATE_STATE||(TEMPLATE_STATE={})),function(T){T[T.WAIT_KEY=5]="WAIT_KEY",T[T.IN_KEY=6]="IN_KEY",T[T.WAIT_KEY_VALUE_SAPERATE=7]="WAIT_KEY_VALUE_SAPERATE",T[T.IN_KEY_VALUE_SAPERATE=8]="IN_KEY_VALUE_SAPERATE",T[T.WAIT_VALUE=9]="WAIT_VALUE",T[T.IN_VALUE=10]="IN_VALUE",T[T.WAIT_ITEM_SAPERATE=11]="WAIT_ITEM_SAPERATE",T[T.IN_ITEM_SAPERATE=12]="IN_ITEM_SAPERATE",T[T.IN_STRING=13]="IN_STRING",T[T.IN_STRING_ESCAPE=14]="IN_STRING_ESCAPE",T[T.IN_STRING2=15]="IN_STRING2",T[T.IN_STRING2_ESCAPE=16]="IN_STRING2_ESCAPE",T[T.WAIT_TEMPLATE_START=17]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE=18]="IN_TEMPLATE",T[T.WAIT_TEMPLATE_END=19]="WAIT_TEMPLATE_END",T[T.IN_TEMPLATE_STRING=20]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=21]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=22]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=23]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_COMMENT_START=24]="WAIT_FOR_COMMENT_START",T[T.IN_COMMENT=25]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END=26]="WAIT_FOR_COMMENT_END",T[T.MAX_STATE=27]="MAX_STATE"}(STYLE_ATTR_VALUE_STATE||(STYLE_ATTR_VALUE_STATE={})),function(T){T[T.NOTHING=0]="NOTHING",T[T.DO_ACTION=65536]="DO_ACTION",T[T.STORE_TOKEN_EXCLUDE=131072]="STORE_TOKEN_EXCLUDE",T[T.STORE_TOKEN_INCLUDE=262144]="STORE_TOKEN_INCLUDE",T[T.IGNORE=524288]="IGNORE",T[T.REFEED=1048576]="REFEED",T[T.STORE_TOKEN_FIRST=2097152]="STORE_TOKEN_FIRST",T[T.STORE_ONE_SPACE=4194304]="STORE_ONE_SPACE",T[T.STORE_ONE_LINE_BREAK=8388608]="STORE_ONE_LINE_BREAK",T[T.GET_STATE_BEFORE=16777216]="GET_STATE_BEFORE",T[T.STORE_STATE_BEFORE=33554432]="STORE_STATE_BEFORE",T[T.SET_WXS_STATE=67108864]="SET_WXS_STATE",T[T.RECORD_IN_TEMPLATE_OBJECT=134217728]="RECORD_IN_TEMPLATE_OBJECT",T[T.CHECK_IN_TEMPLATE_OBJECT=268435456]="CHECK_IN_TEMPLATE_OBJECT"}(ACTION||(ACTION={}));class Token{constructor(T,E){this.type=T,this.value=E}}class MachineState{constructor(){this.cur_pos=0,this.last_pos=0,this.line=1,this.col=1,this.mark_pos=0,this.mark_col=0,this.last_line=this.line,this.last_col=1,this.state=BASE_STATE.START,this.in_template_object_count=0}}const ALPHA="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-:",DIGIT="0123456789.",WHITECHARS=" \n\t\r";class BaseMachine{constructor(T,E){this.mState=new MachineState,this.storedStates=[],this.oldState=BASE_STATE.START,this.tokens=[],this.mPath=T,this.mSrc=E}FillTT(T,E,_,A){for(const S of A)this.TT[T][getCharCode(S)]=E|_}Reset(){return this.mState.cur_pos=0,this.mState.last_pos=0,this.mState.mark_pos=0,this.mState.line=1,this.mState.col=1,this.mState.last_col=1,this.mState.mark_col=1,this.mState.last_line=this.mState.line,this.mState.state=BASE_STATE.START,0}refeed(T){let E=this.TT[this.mState.state][getCharCode(T)];if(E===BASE_STATE.NOT_SET&&(E=this.TT[this.mState.state][BASE_STATE.OTHERS]),E===BASE_STATE.NOT_SET)throw{col:this.mState.col,line:this.mState.line,message:"BAD STATE MACHINE!"};if(E<0){if("\0"!==T)throw{col:this.mState.col,line:this.mState.line,message:`unexpected character \`${T.replace(/\n/g,"\\n")}\``};throw{col:this.mState.col,line:this.mState.line,message:"unexpected end"}}const _=E,A=65535&E,S=this.mState.state;_&ACTION.STORE_STATE_BEFORE&&(this.storedStates.push(S),this.mState.mark_pos=this.mState.cur_pos,this.mState.mark_col=this.mState.mark_col),this.mState.state=A,this.doAction(T,S,_)}Feed(T){"\n"===T&&(this.mState.line++,this.mState.col=0),this.refeed(T)}FillTT_template_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[T][getCharCode(_)]=E,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}updatePosition(){this.mState.last_pos=this.mState.cur_pos,this.mState.last_col=this.mState.col,this.mState.last_line=this.mState.line}processPosition(){this.mState.cur_pos++,this.mState.col++}doAction(T,E,_){if(_&ACTION.STORE_TOKEN_FIRST&&this.mState.mark_pos>this.mState.last_pos){const T=this.mSrc.substring(this.mState.last_pos,this.mState.mark_pos);this.doExcludeAction(this.storedStates[this.storedStates.length-1],T),this.mState.last_pos=this.mState.mark_pos,this.mState.last_col=this.mState.mark_col}if(_&ACTION.STORE_ONE_LINE_BREAK&&(this.appendToken(TokenType.OTHERS,"\n"),this.updatePosition()),_&ACTION.STORE_ONE_SPACE&&(this.appendToken(TokenType.OTHERS," "),this.updatePosition()),_&ACTION.STORE_TOKEN_EXCLUDE){const T=this.mState.cur_pos,_=this.mState.last_pos;if(T>=_){const A=this.mSrc.substring(_,T);this.doExcludeAction(E,A),this.updatePosition()}}if(_&ACTION.RECORD_IN_TEMPLATE_OBJECT&&this.mState.in_template_object_count++,_&ACTION.CHECK_IN_TEMPLATE_OBJECT&&this.mState.in_template_object_count>0&&(this.mState.in_template_object_count--,this.mState.state=STATE.IN_TEMPLATE),_&ACTION.REFEED){if(_&ACTION.IGNORE&&this.updatePosition(),_&ACTION.GET_STATE_BEFORE){const T=this.storedStates.pop();T&&(this.mState.state=T)}this.refeed(T)}else{if(this.processPosition(),_&ACTION.STORE_TOKEN_INCLUDE){const _=this.mSrc.substring(this.mState.last_pos,this.mState.cur_pos);this.doIncludeAction(T,E,_),this.updatePosition()}if(_&ACTION.IGNORE&&this.updatePosition(),_&ACTION.GET_STATE_BEFORE){const T=this.storedStates.pop();T&&(this.mState.state=T)}}}}class StyleAttrValueMachine extends BaseMachine{get TT(){return StyleAttrValueMachine._TT||this.InitTransitTable(),StyleAttrValueMachine._TT}constructor(T,E){super(T,E),this.mState.state=BASE_STATE.START}getTokens(){return[...this.tokens]}appendToken(T,E){T===TokenType.STYLE_VALUE&&(E=E.replace(/[ \t]+/g," ")),this.tokens.push(new Token(T,E))}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case STYLE_ATTR_VALUE_STATE.IN_KEY:_=TokenType.STYLE_KEY;break;case STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE:_=TokenType.OTHERS;break;case STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE:_=TokenType.OTHERS,E=";";break;case STYLE_ATTR_VALUE_STATE.IN_VALUE:_=TokenType.STYLE_VALUE}this.appendToken(_,E)}doIncludeAction(T,E,_){let A=TokenType.OTHERS;switch(E){case STYLE_ATTR_VALUE_STATE.IN_STRING:A=TokenType.STRING1;break;case STYLE_ATTR_VALUE_STATE.IN_STRING2:A=TokenType.STRING2;break;case STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END:A=TokenType.TEMPLATE_ITEM,_=new TemplateTokenizer(_,this.mPath).toString();break;case STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START:this.doExcludeAction(this.storedStates[this.storedStates.length-1],_.replace(/\/\*$/,"")),A=TokenType.OTHERS,_="/*";break;case STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END:A=TokenType.OTHERS,_="*/"}this.appendToken(A,_)}FillTT_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[T][getCharCode("\n")]=BASE_STATE.ERROR,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[A][getCharCode("\n")]=E|ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE,this.TT[T][getCharCode(_)]=E|ACTION.STORE_TOKEN_INCLUDE,this.TT[T][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}InitTransitTable(){StyleAttrValueMachine._TT=new Array(STYLE_ATTR_VALUE_STATE.MAX_STATE);for(let T=0;T<STYLE_ATTR_VALUE_STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.END,this.FillTT(BASE_STATE.START,BASE_STATE.START,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.START][getCharCode(":")]=BASE_STATE.ERROR,this.TT[BASE_STATE.START][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[BASE_STATE.START][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_KEY,STYLE_ATTR_VALUE_STATE.WAIT_KEY,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode(":")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_KEY,STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("'")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.WAIT_KEY|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_VALUE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED|ACTION.STORE_TOKEN_EXCLUDE,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_VALUE,STYLE_ATTR_VALUE_STATE.WAIT_VALUE,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode(":")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("\0")]=BASE_STATE.END,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_STRING|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_STRING2|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_KEY,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("'")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.STORE_TOKEN_FIRST,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=ACTION.GET_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("}")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("\\")]=BASE_STATE.ERROR,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,ACTION.NOTHING," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][0]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][getCharCode("}")]=ACTION.GET_STATE_BEFORE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING|ACTION.NOTHING,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING2|ACTION.NOTHING,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START][getCharCode("*")]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START][BASE_STATE.OTHERS]=ACTION.GET_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_COMMENT][getCharCode("*")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END,this.TT[STYLE_ATTR_VALUE_STATE.IN_COMMENT][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.IGNORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END][getCharCode("/")]=ACTION.GET_STATE_BEFORE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.NOTHING,this.FillTT_template_string(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.NOTHING,'"'),this.FillTT_template_string(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING2,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.NOTHING,"'"),this.FillTT_string(STYLE_ATTR_VALUE_STATE.IN_STRING,ACTION.GET_STATE_BEFORE,'"'),this.FillTT_string(STYLE_ATTR_VALUE_STATE.IN_STRING2,ACTION.GET_STATE_BEFORE,"'")}}class TemplateMachine extends BaseMachine{get TT(){return TemplateMachine._TT||this.InitTransitTable(),TemplateMachine._TT}constructor(T,E){super(T,E),this.mState.state=BASE_STATE.START}getTokens(){return[...this.tokens]}appendToken(T,E){this.tokens.push(new Token(T,E))}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case TEMPLATE_STATE.IN_TEMPLATE_ITEM:case TEMPLATE_STATE.WAIT_TEMPLATE_END:_=TokenType.TEMPLATE_ITEM}this.appendToken(_,E)}doIncludeAction(T,E,_){let A=TokenType.OTHERS;switch(E){case TEMPLATE_STATE.WAIT_TEMPLATE_START:A=TokenType.TEMPLATE_START;break;case TEMPLATE_STATE.WAIT_TEMPLATE_END:A=TokenType.TEMPLATE_END}this.appendToken(A,_)}InitTransitTable(){TemplateMachine._TT=new Array(TEMPLATE_STATE.MAX_STATE);for(let T=0;T<TEMPLATE_STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.FillTT(BASE_STATE.START,BASE_STATE.START,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.START][getCharCode("{")]=TEMPLATE_STATE.WAIT_TEMPLATE_START,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_START][getCharCode("{")]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE,this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(TEMPLATE_STATE.IN_TEMPLATE_SPACE,TEMPLATE_STATE.IN_TEMPLATE_SPACE,ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode('"')]=TEMPLATE_STATE.IN_TEMPLATE_STRING|ACTION.STORE_STATE_BEFORE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("'")]=TEMPLATE_STATE.IN_TEMPLATE_STRING2|ACTION.STORE_STATE_BEFORE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("/")]=TEMPLATE_STATE.WAIT_FOR_COMMENT_START,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.FillTT(TEMPLATE_STATE.IN_TEMPLATE_ITEM,TEMPLATE_STATE.IN_TEMPLATE_SPACE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("\\")]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode('"')]=TEMPLATE_STATE.IN_TEMPLATE_STRING|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("'")]=TEMPLATE_STATE.IN_TEMPLATE_STRING2|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][0]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_START][getCharCode("*")]=TEMPLATE_STATE.IN_COMMENT,this.FillTT(TEMPLATE_STATE.WAIT_FOR_COMMENT_START,TEMPLATE_STATE.IN_TEMPLATE_ITEM,ACTION.REFEED," \n\t\r"),this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_START][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.TT[TEMPLATE_STATE.IN_COMMENT][getCharCode("*")]=TEMPLATE_STATE.WAIT_FOR_COMMENT_END,this.TT[TEMPLATE_STATE.IN_COMMENT][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_COMMENT,this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_END][getCharCode("/")]=TEMPLATE_STATE.IN_TEMPLATE_SPACE|ACTION.IGNORE,this.FillTT_template_string(TEMPLATE_STATE.IN_TEMPLATE_STRING,TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE|ACTION.GET_STATE_BEFORE,'"'),this.FillTT_template_string(TEMPLATE_STATE.IN_TEMPLATE_STRING2,TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE|ACTION.GET_STATE_BEFORE,"'"),this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_END][getCharCode("}")]=BASE_STATE.END|ACTION.STORE_TOKEN_INCLUDE,this.FillTT(TEMPLATE_STATE.WAIT_TEMPLATE_END,TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,ACTION.STORE_TOKEN_EXCLUDE," \n\t\r"),this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.REFEED,this.FillTT(TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END|ACTION.STORE_ONE_SPACE,this.TT[TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.IGNORE|ACTION.REFEED,this.FillTT(BASE_STATE.END,BASE_STATE.END,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.END][getCharCode("\0")]=BASE_STATE.END,this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.ERROR}}class TemplateTokenizer{constructor(T,E){this.machine=new TemplateMachine(E,T),this.m_pSrc=T,this.path=E}toString(){this.tokens||(this.tokens=this.generateTokens());return this.tokens.map(T=>T.value).join("")}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}return this.machine.Feed("\0"),this.machine.getTokens()}}exports.TemplateTokenizer=TemplateTokenizer;class StyleAttrValueTokenizer{constructor(T,E){this.machine=new StyleAttrValueMachine(E,T),this.m_pSrc=T,this.path=E}toString(){return this.tokens||(this.tokens=this.generateTokens()),this.tokens.map(T=>T.value).join("")}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}return this.machine.Feed("\0"),this.machine.getTokens()}}exports.StyleAttrValueTokenizer=StyleAttrValueTokenizer;class Machine extends BaseMachine{get TT(){return Machine._TT||this.InitTransitTable(),Machine._TT}constructor(T,E){super(T,E),this.tagStack=[],this.InitTransitTable(),this.mPath=T,this.mSrc=E}get wxsState(){return"wxs"===this.tagStack[this.tagStack.length-1]}get textState(){return"text"===this.tagStack[this.tagStack.length-1]}getTokens(){return[...this.tokens]}checkLastTokenIfTypeMatch(T){var E;return(null===(E=this.tokens[this.tokens.length-1])||void 0===E?void 0:E.type)===T?this.tokens[this.tokens.length-1]:void 0}getLastTokenIfTypeMatch(T){if(0!==this.tokens.length)for(let E=this.tokens.length-1;E>=0;E--){const _=this.tokens[E];if(_.type===T)return _}}canBeOmittedTokenType(T){return T===TokenType.WXS_VALUE}appendToken(T,E){if(this.canBeOmittedTokenType(T)&&(E=this.transTagTextTokenValue(E)),T===TokenType.ATTR_VALUE){const T=this.getLastTokenIfTypeMatch(TokenType.ATTR);"style"===(null==T?void 0:T.value)&&(E=this.trySlimStyleAttrValue(E))}E&&this.tokens.push(new Token(T,E))}transTagTextTokenValue(T){return this.wxsState?T=T.split("\n").map(T=>T.trim()).join("\n"):T}trySlimStyleAttrValue(T){const E=[];try{if(T.length<=1)return T;for(let T=this.tokens.length-1;T>=0;T--){if(this.tokens[T].type===TokenType.TAG_EQ)break;E.unshift(this.tokens.pop())}const _=`${E.map(T=>null==T?void 0:T.value).join("")}${T}`,A=_.startsWith('"')||_.startsWith("'"),S=_.endsWith('"')||_.endsWith("'"),t=new StyleAttrValueTokenizer(_.replace(/^['"]/,"").replace(/['"]$/,""),this.mPath).toString();return`${A?_.substr(0,1):""}${t}${S?_.substr(_.length-1,1):""}`}catch(T){this.tokens.push(...E)}return T}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case STATE.IN_TAG_ATTR_VALUE_STRING:case STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE:_=TokenType.ATTR_VALUE;break;case STATE.IN_TAG_WORD:_=TokenType.TAG,this.tagStack.push(E);break;case STATE.IN_END_TAG_WORD:_=TokenType.TAG;if(this.tagStack.pop()!==E)throw{col:this.mState.col-E.length,line:this.mState.line,message:"unexpected end tag: "+E};break;case STATE.IN_WXS:_=TokenType.WXS_VALUE;break;case STATE.IN_TEXT:_=TokenType.TEXT_VALUE;break;case STATE.IN_TAG_TEXT:_=TokenType.TAG_TEXT_VALUE;break;case STATE.IN_TAG_ATTR_WORD:_=TokenType.ATTR;break;case STATE.TAG_START:_=TokenType.LEFT_ANGLE_BRACKET;break;case STATE.IN_TEMPLATE:_=TokenType.TEMPLATE_ITEM;break;case STATE.TAG_EQ:_=TokenType.TAG_EQ;break;case STATE.TEMPLATE_END_CHECK:{const T=this.mState.cur_pos;if("}"===this.mSrc.substring(T-3,T-2))throw{col:this.mState.col-3,line:this.mState.line,message:"unexpected end tag: }. } should not be followed by }} direactly, add a space and change it to } }}"};this.appendToken(TokenType.TEMPLATE_ITEM,""+new TemplateTokenizer(E,this.mPath)),_=TokenType.TEMPLATE_END,E=""}}this.appendToken(_,E)}doIncludeAction(T,E,_){const A=this.mState.state;let S;E===STATE.WXS_END_STEP?(this.appendToken(TokenType.WXS_VALUE,_.substr(0,_.length-2)),S=TokenType.END_LEFT_ANGLE_BRACKET,_="</"):E===STATE.IN_WXS_STRING||E===STATE.IN_WXS_STRING_SINGLE?S=TokenType.WXS_VALUE:E===STATE.IN_TAG_ATTR_VALUE_STRING||E===STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE?S=TokenType.ATTR_VALUE:E===STATE.TAG_START&&A===STATE.IN_END_TAG?S=TokenType.END_LEFT_ANGLE_BRACKET:E===STATE.WAIT_FOR_RIGHT_BRACKET?(S=TokenType.SELF_CLOSE,this.tagStack.pop()):S=TokenType.OTHERS,">"!==T||E!==STATE.IN_TAG_WORD&&E!==STATE.IN_TAG_ATTR_WORD&&E!==STATE.IN_TAG_ATTR_VALUE_STRING&&E!==STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE&&E!==STATE.IN_END_TAG_WORD||(S=TokenType.RIGHT_ANGLE_BRACKET),this.appendToken(S,_)}Feed(T){super.Feed(T),this.wxsState&&this.mState.state===STATE.IN_TAG_TEXT&&(this.mState.state=STATE.IN_WXS),this.textState&&this.mState.state===STATE.IN_TAG_TEXT&&(this.mState.state=STATE.IN_TEXT)}FillTT_attr_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[A][getCharCode("\n")]=E|ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE,this.TT[T][getCharCode(_)]=E|ACTION.STORE_TOKEN_INCLUDE,this.TT[T][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}InitTransitTable(){Machine._TT=new Array(STATE.MAX_STATE);for(let T=0;T<STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.END,this.TT[BASE_STATE.START][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.NOTHING,this.TT[BASE_STATE.START][0]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_TEXT][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_STATE_BEFORE,this.TT[STATE.IN_TAG_TEXT][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STATE.IN_TAG_TEXT][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.NOTHING,this.TT[STATE.IN_TAG_TEXT][0]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_TEXT][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT,this.TT[STATE.WAIT_TEMPLATE_START][getCharCode("{")]=STATE.IN_TEMPLATE|ACTION.STORE_TOKEN_FIRST,this.TT[STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.GET_STATE_BEFORE,this.TT[STATE.IN_TEMPLATE][getCharCode("{")]=STATE.IN_TEMPLATE|ACTION.RECORD_IN_TEMPLATE_OBJECT,this.TT[STATE.IN_TEMPLATE][getCharCode("}")]=STATE.WAIT_TEMPLATE_END|ACTION.CHECK_IN_TEMPLATE_OBJECT,this.TT[STATE.IN_TEMPLATE][getCharCode("\\")]=BASE_STATE.ERROR,this.FillTT(STATE.IN_TEMPLATE,STATE.IN_TEMPLATE,ACTION.NOTHING," \n\t\r"),this.TT[STATE.IN_TEMPLATE][BASE_STATE.OTHERS]=STATE.IN_TEMPLATE,this.TT[STATE.IN_TEMPLATE][0]=BASE_STATE.ERROR,this.TT[STATE.WAIT_TEMPLATE_END][getCharCode("}")]=STATE.TEMPLATE_END_CHECK,this.TT[STATE.TEMPLATE_END_CHECK][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.REFEED|ACTION.STORE_TOKEN_EXCLUDE|ACTION.GET_STATE_BEFORE,this.TT[STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=STATE.IN_TEMPLATE|ACTION.REFEED,this.TT[STATE.IN_TEMPLATE][getCharCode('"')]=STATE.IN_TEMPLATE_STRING|ACTION.NOTHING,this.TT[STATE.IN_TEMPLATE][getCharCode("'")]=STATE.IN_TEMPLATE_STRING2|ACTION.NOTHING,this.FillTT_template_string(STATE.IN_TEMPLATE_STRING,STATE.IN_TEMPLATE|ACTION.NOTHING,'"'),this.FillTT_template_string(STATE.IN_TEMPLATE_STRING2,STATE.IN_TEMPLATE|ACTION.NOTHING,"'"),this.FillTT(STATE.TAG_START,STATE.TAG_START,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.TAG_START,STATE.IN_TAG_WORD,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.TAG_START][getCharCode("/")]=STATE.IN_END_TAG|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.TAG_START][getCharCode("!")]=STATE.IN_COMMENT_BEGIN1,this.TT[STATE.TAG_START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT_BEGIN1][getCharCode("-")]=STATE.IN_COMMENT_BEGIN2,this.TT[STATE.IN_COMMENT_BEGIN1][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT_BEGIN2][getCharCode("-")]=STATE.IN_COMMENT,this.TT[STATE.IN_COMMENT_BEGIN2][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END1,this.TT[STATE.IN_COMMENT][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.TT[STATE.WAIT_FOR_COMMENT_END1][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END2,this.TT[STATE.WAIT_FOR_COMMENT_END1][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.TT[STATE.WAIT_FOR_COMMENT_END2][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.IGNORE|ACTION.GET_STATE_BEFORE,this.TT[STATE.WAIT_FOR_COMMENT_END2][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END2,this.TT[STATE.WAIT_FOR_COMMENT_END2][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_TAG_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_TAG_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_WORD][0]=BASE_STATE.ERROR,this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode("=")]=STATE.TAG_EQ|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_ATTR_WORD][0]=BASE_STATE.ERROR,this.FillTT(STATE.TAG_EQ,STATE.TAG_EQ,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.TAG_EQ,STATE.IN_TAG_ATTR_VALUE_STRING,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.TAG_EQ][getCharCode('"')]=STATE.IN_TAG_ATTR_VALUE_STRING|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.TAG_EQ][getCharCode("'")]=STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.TAG_EQ][0]=BASE_STATE.ERROR,this.TT[STATE.TAG_EQ][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.IN_END_TAG,STATE.IN_END_TAG,ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.IN_END_TAG,STATE.IN_END_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_END_TAG,BASE_STATE.ERROR,ACTION.NOTHING,DIGIT),this.TT[STATE.IN_END_TAG][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_END_TAG][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_END_TAG_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_END_TAG_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_END_TAG_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.WAIT_FOR_RIGHT_BRACKET,STATE.IN_TAG_WORD,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.WAIT_FOR_RIGHT_BRACKET][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.WAIT_FOR_RIGHT_BRACKET][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT_attr_string(STATE.IN_TAG_ATTR_VALUE_STRING,STATE.IN_TAG_ATTR_WORD,'"'),this.FillTT_attr_string(STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE,STATE.IN_TAG_ATTR_WORD,"'"),this.TT[STATE.IN_WXS][getCharCode("<")]=STATE.WXS_END_STEP,this.TT[STATE.IN_WXS][getCharCode('"')]=STATE.IN_WXS_STRING|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_WXS][getCharCode("'")]=STATE.IN_WXS_STRING_SINGLE|ACTION.STORE_TOKEN_EXCLUDE,this.FillTT_attr_string(STATE.IN_WXS_STRING,STATE.IN_WXS,'"'),this.FillTT_attr_string(STATE.IN_WXS_STRING_SINGLE,STATE.IN_WXS,"'"),this.TT[STATE.IN_WXS][BASE_STATE.OTHERS]=STATE.IN_WXS,this.TT[STATE.WXS_END_STEP][getCharCode("/")]=STATE.IN_END_TAG|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.WXS_END_STEP][BASE_STATE.OTHERS]=STATE.IN_WXS,this.TT[STATE.IN_TEXT][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TEXT][BASE_STATE.OTHERS]=STATE.IN_TEXT,this.TT[STATE.IN_TEXT][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE}}class Tokenizer{constructor(T,E){this.machine=new Machine(E,T),this.m_pSrc=T,this.path=E}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];try{for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}this.machine.Feed("\0")}catch(T){throw new Error(`${T.line}:${T.col}:${T.message}`)}return this.machine.getTokens()}}function generateWXMLFromTokens(T,E={collapseWhitespace:!0,conservativeCollapse:!1,preserveLineBreaks:!1}){const{collapseWhitespace:_,conservativeCollapse:A,preserveLineBreaks:S}=E,t=[];for(let E=0;E<T.length;E++){const e=T[E];let N=e.value;const R=e.type;if(R===TokenType.ATTR&&(N=" "+N),R===TokenType.TAG_TEXT_VALUE){S||(N=N.replace(/\n/g," ")),_&&(N=N.replace(/([ \t])+/g," "));const t=T[E-1];t&&t.type!==TokenType.RIGHT_ANGLE_BRACKET&&t.type!==TokenType.SELF_CLOSE||_&&!A&&(N=trimStringLeft(N,!1)),(null==t?void 0:t.type)===TokenType.TAG_TEXT_VALUE&&((null==t?void 0:t.value.endsWith(" "))||(null==t?void 0:t.value.endsWith("\n")))&&_&&(N=trimStringLeft(N,!1))}if(R===TokenType.LEFT_ANGLE_BRACKET||R===TokenType.END_LEFT_ANGLE_BRACKET){const S=T[E-1];if((null==S?void 0:S.type)===TokenType.TAG_TEXT_VALUE&&_&&!A){const T=t.pop()||"";t.push(trimStringRight(T,!1))}}t.push(N)}return t.join("")}async function minifyWXML(T){const{filePath:E,root:_=""}=T,A=T.code instanceof Buffer?T.code.toString():T.code,S=Object.assign({collapseWhitespace:!0,conservativeCollapse:!1,preserveLineBreaks:!1},T.setting),t=path_1.default.posix.join(_,E);if(A.length>0)try{const T=new Tokenizer(A.replace(/\r\n/g,"\n"),t);return{error:null,code:generateWXMLFromTokens(T.generateTokens(),S)}}catch(T){return log.error("minifywxml error @ "+t),log.error(T.message),{error:{code:config_1.MINIFY_WXML_ERR,path:t,message:T.message}}}return{error:null,code:A.replace(/\r\n/g,"\n")}}exports.minifyWXML=minifyWXML;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OriginalCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),baseCompiler_1=require("./baseCompiler"),original_1=require("./original"),tools_1=require("../../utils/tools");class OriginalCompiler extends baseCompiler_1.BaseCoreCompiler{constructor(e){super(e),this.isSummer=!1,this.ready()}destroy(){this._checkReadyTask=void 0,this.compileManager=void 0}async init(){this.compileManager=new original_1.OriginalCompileManager(this.project)}async isGameApp(){if(!this.project)return!1;const e=await this.project.attr();return null==e?void 0:e.gameApp}checkProject(){}async getExtJSON(){return await this.compileManager.getExtJSON()}async getAppJSON(){return this.checkProject(),await this.compileManager.getAppJSON()}async getSiteMapJSON(){const e=await this.compileManager.getSiteMapJSON();return lodash_1.default.cloneDeep(e)}async getPageJSON(e){this.checkProject();return await this.compileManager.getPageJSON({miniprogramRoot:this.project.miniprogramRoot,pagePath:e})}async getGameJSON(){return this.checkProject(),this.compileManager.getGameJSON()}async getPluginJSON(e=""){return this.checkProject(),await this.compileManager.getPluginJSON(e)}async getPluginPageJSON(e){this.checkProject();return await this.compileManager.getPluginPageJSON({root:this.project.pluginRoot,project:this.project,filePath:path_1.default.posix.join(this.project.pluginRoot||"",e+".json")})}async getPluginComponents(){var e;const t=this.getPluginJSONFileList(),o=[];for(let i=0,r=t.length;i<r;i++){const r=t[i].replace(/\.json$/,"");"plugin"!==path_1.default.normalize(r)&&(this.isValidComponent(null===(e=this.project)||void 0===e?void 0:e.pluginRoot,r)&&o.push(r))}return o}getWxssMap(e,t){throw new Error("Method not implemented.")}async getPluginJSFiles(){const e=this.getPluginJSFileList();return{jsFiles:e,content:e.reduce((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e},{})}}async getPluginWxssFiles(){const e=this.getPluginWXSSFileList();return{wxssFiles:e,content:e.reduce((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e},{})}}async getPluginWxmlAndWxsFiles(){const e=this.getPluginWXSFileList(),t=this.getPluginWXMLFileList(),o=e.concat(t);return{wxsFiles:e,wxmlFiles:t,content:o.reduce((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e},{})}}async getMPFileInfo(){var e,t;const o=null===(e=this.project)||void 0===e?void 0:e.miniprogramRoot;return this.excludeKeyRoot(this.getAllFileInfo(null===(t=this.project)||void 0===t?void 0:t.miniprogramRoot),o)}async getPluginFileInfo(){var e,t;const o=null===(e=this.project)||void 0===e?void 0:e.pluginRoot;return this.excludeKeyRoot(this.getAllFileInfo(null===(t=this.project)||void 0===t?void 0:t.pluginRoot),o)}async checkThemeJSON(e){return this.checkProject(),await this.compileManager.checkThemeJSON(e)}async compile(e){return this.checkProject(),await this.compileManager.compile({nameMapping:e.nameMapping||{},setting:e.setting,onProgressUpdate:e.onProgressUpdate,__compileDebugInfo__:e.__compileDebugInfo__,compilePages:e.compilePages,analyzer:e.analyzer,devToolsCompileCache:e.devToolsCompileCache,disableSpreadingUsingComponents:e.disableSpreadingUsingComponents,resultType:e.resultType})}async compileJS(e){this.checkProject();const{root:t,filePath:o,babelRoot:i="@babel/runtime"}=e;try{return await this.compileManager.compileJS(o,{root:t,sourceCode:e.sourceCode,setting:Object.assign({},e.setting),babelRoot:i,onProgressUpdate:e.onProgressUpdate})}catch(e){throw e}}setLocale(e){this.compileManager.setLocale(e)}clearCache(){this.compileManager.clearCache()}async getPackageWxssFileList(e){return[]}async getPackageWxssFiles(e){return{}}async getPackageWxmlAndWxsFiles(e){return{}}async getAllWxmlAndWxsFiles(){return{}}getAllSortedJSFiles(){throw new Error("Method not implemented.")}getMainPkgSortedJSFiles(){throw new Error("Method not implemented.")}async getPackageFiles(e,t){if(this.isGameType(e)){const e=await this.getGameJSON(),o=this.getMPFileList();let i=e.workers||"";i="string"==typeof i?i:i.path;const r=e.openDataContext,n={__APP__:[],[r]:[]};i&&(n[i]=[]);for(const t of o)if(r&&(0,tools_1.isLeftSubPathOfRight)(t,r))n[r].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:r,isBabelIgnore:!1});else if(i&&(0,tools_1.isLeftSubPathOfRight)(t,i))n[i].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:"object"==typeof e.workers&&e.workers.isSubpackage?i:"",isBabelIgnore:!1});else{if(e.subPackages){let o=!1;for(const i of e.subPackages){const e=i.root.replace(/^\//,"");if((0,tools_1.isLeftSubPathOfRight)(t,e)){n[i.root]||(n[e]=[]),n[e].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:i.independent?e:"",isBabelIgnore:!1}),o=!0;break}}if(o)continue}n.__APP__.push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:"",isBabelIgnore:!1})}return n[t]||[]}throw new Error("Method not implemented.")}getSubPkgSortedJSFiles(e){throw new Error("Method not implemented.")}getCompAndPagesOfConf(){throw new Error("Method not implemented.")}async getAllPageAndComponent(){var e;const t=this.getMPJSONFileList(),o=[];for(let i=0,r=t.length;i<r;i++){const r=t[i].replace(/\.json$/,"");this.isValidComponent(null===(e=this.project)||void 0===e?void 0:e.miniprogramRoot,r)&&o.push(r)}return o}}exports.OriginalCompiler=OriginalCompiler;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OriginalCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),baseCompiler_1=require("./baseCompiler"),original_1=require("./original"),tools_1=require("../../utils/tools");class OriginalCompiler extends baseCompiler_1.BaseCoreCompiler{async waitSubProcessReady(){}constructor(e){super(e),this.isSummer=!1,this.ready()}destroy(){this._checkReadyTask=void 0,this.compileManager=void 0}async init(){this.compileManager=new original_1.OriginalCompileManager(this.project)}async isGameApp(){if(!this.project)return!1;const e=await this.project.attr();return null==e?void 0:e.gameApp}checkProject(){}async getExtJSON(){return await this.compileManager.getExtJSON()}async getAppJSON(){return this.checkProject(),await this.compileManager.getAppJSON()}async getSiteMapJSON(){const e=await this.compileManager.getSiteMapJSON();return lodash_1.default.cloneDeep(e)}async getPageJSON(e){this.checkProject();return await this.compileManager.getPageJSON({miniprogramRoot:this.project.miniprogramRoot,pagePath:e})}async getGameJSON(){return this.checkProject(),this.compileManager.getGameJSON()}async getPluginJSON(e=""){return this.checkProject(),await this.compileManager.getPluginJSON(e)}async getPluginPageJSON(e){this.checkProject();return await this.compileManager.getPluginPageJSON({root:this.project.pluginRoot,project:this.project,filePath:path_1.default.posix.join(this.project.pluginRoot||"",e+".json")})}async getPluginComponents(){var e;const t=this.getPluginJSONFileList(),o=[];for(let i=0,r=t.length;i<r;i++){const r=t[i].replace(/\.json$/,"");"plugin"!==path_1.default.normalize(r)&&(this.isValidComponent(null===(e=this.project)||void 0===e?void 0:e.pluginRoot,r)&&o.push(r))}return o}getWxssMap(e,t){throw new Error("Method not implemented.")}async getPluginJSFiles(){const e=this.getPluginJSFileList();return{jsFiles:e,content:e.reduce((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e},{})}}async getPluginWxssFiles(){const e=this.getPluginWXSSFileList();return{wxssFiles:e,content:e.reduce((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e},{})}}async getPluginWxmlAndWxsFiles(){const e=this.getPluginWXSFileList(),t=this.getPluginWXMLFileList(),o=e.concat(t);return{wxsFiles:e,wxmlFiles:t,content:o.reduce((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e},{})}}async getMPFileInfo(){var e,t;const o=null===(e=this.project)||void 0===e?void 0:e.miniprogramRoot;return this.excludeKeyRoot(this.getAllFileInfo(null===(t=this.project)||void 0===t?void 0:t.miniprogramRoot),o)}async getPluginFileInfo(){var e,t;const o=null===(e=this.project)||void 0===e?void 0:e.pluginRoot;return this.excludeKeyRoot(this.getAllFileInfo(null===(t=this.project)||void 0===t?void 0:t.pluginRoot),o)}async checkThemeJSON(e){return this.checkProject(),await this.compileManager.checkThemeJSON(e)}async compile(e){return this.checkProject(),await this.compileManager.compile({nameMapping:e.nameMapping||{},setting:e.setting,onProgressUpdate:e.onProgressUpdate,__compileDebugInfo__:e.__compileDebugInfo__,compilePages:e.compilePages,analyzer:e.analyzer,devToolsCompileCache:e.devToolsCompileCache,disableSpreadingUsingComponents:e.disableSpreadingUsingComponents,resultType:e.resultType})}async compileJS(e){this.checkProject();const{root:t,filePath:o,babelRoot:i="@babel/runtime"}=e;try{return await this.compileManager.compileJS(o,{root:t,sourceCode:e.sourceCode,setting:Object.assign({},e.setting),babelRoot:i,onProgressUpdate:e.onProgressUpdate})}catch(e){throw e}}setLocale(e){this.compileManager.setLocale(e)}clearCache(){this.compileManager.clearCache()}async getPackageWxssFileList(e){return[]}async getPackageWxssFiles(e){return{}}async getPackageWxmlAndWxsFiles(e){return{}}async getAllWxmlAndWxsFiles(){return{}}getAllSortedJSFiles(){throw new Error("Method not implemented.")}getMainPkgSortedJSFiles(){throw new Error("Method not implemented.")}async getPackageFiles(e,t){if(this.isGameType(e)){const e=await this.getGameJSON(),o=this.getMPFileList();let i=e.workers||"";i="string"==typeof i?i:i.path;const r=e.openDataContext,n={__APP__:[],[r]:[]};i&&(n[i]=[]);for(const t of o)if(r&&(0,tools_1.isLeftSubPathOfRight)(t,r))n[r].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:r,isBabelIgnore:!1});else if(i&&(0,tools_1.isLeftSubPathOfRight)(t,i))n[i].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:"object"==typeof e.workers&&e.workers.isSubpackage?i:"",isBabelIgnore:!1});else{if(e.subPackages){let o=!1;for(const i of e.subPackages){const e=i.root.replace(/^\//,"");if((0,tools_1.isLeftSubPathOfRight)(t,e)){n[i.root]||(n[e]=[]),n[e].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:i.independent?e:"",isBabelIgnore:!1}),o=!0;break}}if(o)continue}n.__APP__.push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:"",isBabelIgnore:!1})}return n[t]||[]}throw new Error("Method not implemented.")}getSubPkgSortedJSFiles(e){throw new Error("Method not implemented.")}getCompAndPagesOfConf(){throw new Error("Method not implemented.")}async getAllPageAndComponent(){var e;const t=this.getMPJSONFileList(),o=[];for(let i=0,r=t.length;i<r;i++){const r=t[i].replace(/\.json$/,"");this.isValidComponent(null===(e=this.project)||void 0===e?void 0:e.miniprogramRoot,r)&&o.push(r)}return o}}exports.OriginalCompiler=OriginalCompiler;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.messageHandler=exports.onMessage=exports.destroy=exports.initHandler=void 0;const summerCPProject_1=require("../../project/summerCPProject"),index_1=require("../precompiler/index"),progressRecorder_1=require("../../utils/progressRecorder"),index_2=require("./original/index"),summer_1=require("./summer/summer"),debug_1=require("../../utils/debug"),getProcess_1=require("../../utils/subprocess/getProcess");let summercompileManager,summerProject,preCompiler,precompileProject,inited=!1;async function processSend(e){await(0,debug_1.shouldRunInMainProcess)()?emiter.emit("message",e):(0,getProcess_1.getProcess)().send(e)}async function initHandler(e){const{passData:r,projectInfo:t,options:o}=e.data;if(inited)return;summerProject=new summerCPProject_1.SummerCPProject(t),await summerProject.ready();const{targetPlatform:s,targetPlatformDefines:a}=t;preCompiler=new index_1.PreCompiler(summerProject,{showBuildLog:(e,r,t)=>{processSend({type:"log",id:e,status:r,text:t})}},void 0),precompileProject=await preCompiler.getPreCompileProject({targetPlatform:s,targetPlatformDefines:a,runEnv:"summer cp"});const{cachePath:i}=r;summercompileManager=new summer_1.SummerCompiler(precompileProject,i,o),inited=!0}async function getCodeFiles(e,r,t){let o={};"getDevCodeByFileList"===e?o=await r.run("getDevCodeByFileList-"+t.graphId,()=>summercompileManager.getDevCodeByFileList(t,r)):"getCode"===e&&(o=await r.run(`getCode-${t.graphId}-${t.package}`,()=>summercompileManager.getCode(t,r)));const{cacheMd5:s}=t;for(const e of Object.keys(s)){const r=o[e];r?"error"in r||r.md5!==s[e]||delete o[e]:o[e]={path:e,md5:"",code:""}}for(const e of Object.values(o))"error"in e&&e.error instanceof Error&&(e.error={code:e.error.code||-1,message:e.error.message,stack:e.error.stack,path:e.path});return o}async function destroy(){null==summercompileManager||summercompileManager.destroy(),summercompileManager=void 0,inited=!1,preCompiler=void 0,summerProject=void 0,precompileProject=void 0}exports.initHandler=initHandler,exports.destroy=destroy;const emiter=function(){const e={};return{on:(r,t)=>{e.hasOwnProperty(r)||(e[r]=[]),e[r].push(t)},off:(r,t)=>{var o;e[r]=(null===(o=e[r])||void 0===o?void 0:o.filter(e=>e!==t))||[]},emit:(r,...t)=>{const o=e[r];if((null==o?void 0:o.length)>0)for(const e of o)try{e(...t)}catch(e){}}}}(),onMessage=e=>{emiter.on("message",e)};async function messageHandler(e){if("event"===e.type)if("fileChange"===e.name){const{type:r,targetPath:t}=e.data;summerProject.onFileChange(r,t)}else if("updateOptions"===e.name){const r=e.data;summerProject.updateOptions(r),summercompileManager.updateOptions(r)}else if("precompileOptionsChange"===e.name){const r=e.data;precompileProject.updateConditionCompileOptions(r)}if("request"===e.type){const{id:r,name:t,data:o}=e,s=r,a=new progressRecorder_1.Recorder((e,r,t)=>{processSend({type:"progress",id:e,taskId:s,status:r,message:t})});try{let e;if("getCode"===t||"getDevCodeByFileList"===t)e=await getCodeFiles(t,a,o);else if("getPackageFiles"===t)e=await summercompileManager.getPackageFiles(o,a);else if("getConf"===t)e=await summercompileManager.getConf(o,a);else if("getLocalFileList"===t)e=await summercompileManager.getLocalFileList(o);else if("compile"===t)e=await summercompileManager.compile(o,a);else if("compileNewLogic"===t)e=await summercompileManager.compileNewLogic(o,a);else if("compileSingleCode"===t)e=await summercompileManager.compileSingleCode(o,a);else if("setLocale"===t)(0,index_2.setLocale)(o);else if("clearCache"===t)summercompileManager.clearCache();else{if("loadStatus"!==t)throw new Error("unknown command "+t);e=summercompileManager.getStatus()}processSend({type:"response",id:r,data:e})}catch(e){processSend({type:"response",id:r,data:null,error:{code:e.code||-1,message:e.message,stack:e.stack,path:e.path||""}})}}}exports.onMessage=onMessage,exports.messageHandler=messageHandler;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.messageHandler=exports.onMessage=exports.destroy=exports.initHandler=void 0;const summerCPProject_1=require("../../project/summerCPProject"),index_1=require("../precompiler/index"),progressRecorder_1=require("../../utils/progressRecorder"),index_2=require("./original/index"),summer_1=require("./summer/summer"),debug_1=require("../../utils/debug"),getProcess_1=require("../../utils/subprocess/getProcess"),env_1=require("../../utils/env");let summercompileManager,summerProject,preCompiler,precompileProject,inited=!1;const MEMORY_THRESHOLD=500;async function processSend(e){await(0,debug_1.shouldRunInMainProcess)()?emiter.emit("message",e):(0,getProcess_1.getProcess)().send(e)}async function initHandler(e){const{passData:r,projectInfo:o,options:t}=e.data;if(inited)return;summerProject=new summerCPProject_1.SummerCPProject(o),await summerProject.ready();const{targetPlatform:s,targetPlatformDefines:a}=o;preCompiler=new index_1.PreCompiler(summerProject,{showBuildLog:(e,r,o)=>{processSend({type:"log",id:e,status:r,text:o})}},void 0),precompileProject=await preCompiler.getPreCompileProject({targetPlatform:s,targetPlatformDefines:a,runEnv:"summer cp"});const{cachePath:i}=r;summercompileManager=new summer_1.SummerCompiler(precompileProject,i,t),checkMemoryAndGC(),inited=!0}async function checkMemoryAndGC(){(0,env_1.isElectron)()&&process.memoryUsage&&global.gc&&setInterval(()=>{process.memoryUsage().heapTotal>524288e3&&(console.time("[summer-compiler checkMemoryAndGC] gc"),global.gc(),console.timeEnd("[summer-compiler checkMemoryAndGC] gc"))},3e3)}async function getCodeFiles(e,r,o){let t={};"getDevCodeByFileList"===e?t=await r.run("getDevCodeByFileList-"+o.graphId,()=>summercompileManager.getDevCodeByFileList(o,r)):"getCode"===e&&(t=await r.run(`getCode-${o.graphId}-${o.package}`,()=>summercompileManager.getCode(o,r)));const{cacheMd5:s}=o;for(const e of Object.keys(s)){const r=t[e];r?"error"in r||r.md5!==s[e]||delete t[e]:t[e]={path:e,md5:"",code:""}}for(const e of Object.values(t))"error"in e&&e.error instanceof Error&&(e.error={code:e.error.code||-1,message:e.error.message,stack:e.error.stack,path:e.path});return t}async function destroy(){null==summercompileManager||summercompileManager.destroy(),summercompileManager=void 0,inited=!1,preCompiler=void 0,summerProject=void 0,precompileProject=void 0}exports.initHandler=initHandler,exports.destroy=destroy;const emiter=function(){const e={};return{on:(r,o)=>{e.hasOwnProperty(r)||(e[r]=[]),e[r].push(o)},off:(r,o)=>{var t;e[r]=(null===(t=e[r])||void 0===t?void 0:t.filter(e=>e!==o))||[]},emit:(r,...o)=>{const t=e[r];if((null==t?void 0:t.length)>0)for(const e of t)try{e(...o)}catch(e){}}}}(),onMessage=e=>{emiter.on("message",e)};async function messageHandler(e){if("event"===e.type)if("fileChange"===e.name){const{type:r,targetPath:o}=e.data;summerProject.onFileChange(r,o)}else if("updateOptions"===e.name){const r=e.data;summerProject.updateOptions(r),summercompileManager.updateOptions(r)}else if("precompileOptionsChange"===e.name){const r=e.data;precompileProject.updateConditionCompileOptions(r)}if("request"===e.type){const{id:r,name:o,data:t}=e,s=r,a=new progressRecorder_1.Recorder((e,r,o)=>{processSend({type:"progress",id:e,taskId:s,status:r,message:o})});try{let e;if("getCode"===o||"getDevCodeByFileList"===o)e=await getCodeFiles(o,a,t);else if("getPackageFiles"===o)e=await summercompileManager.getPackageFiles(t,a);else if("getConf"===o)e=await summercompileManager.getConf(t,a);else if("getLocalFileList"===o)e=await summercompileManager.getLocalFileList(t);else if("compile"===o)e=await summercompileManager.compile(t,a);else if("compileNewLogic"===o)e=await summercompileManager.compileNewLogic(t,a);else if("compileSingleCode"===o)e=await summercompileManager.compileSingleCode(t,a);else if("setLocale"===o)(0,index_2.setLocale)(t);else if("clearCache"===o)summercompileManager.clearCache();else{if("loadStatus"!==o)throw new Error("unknown command "+o);e=summercompileManager.getStatus()}processSend({type:"response",id:r,data:e})}catch(e){processSend({type:"response",id:r,data:null,error:{code:e.code||-1,message:e.message,stack:e.stack,path:e.path||""}})}}}exports.onMessage=onMessage,exports.messageHandler=messageHandler;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseGraph=exports.JSONType=exports.FileType=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),pluginDriver_1=require("../pluginDriver"),module_1=tslib_1.__importDefault(require("../module")),config_1=require("../../../../config/config"),resolver_1=require("../resolver"),common_1=require("../../original/compile/common"),packOptionsHelper_1=tslib_1.__importDefault(require("../../../../utils/packOptionsHelper")),tools_1=require("../../../../utils/tools"),babel_helper_1=require("../../../../utils/babel_helper"),helper_util_1=require("../../../../utils/helper_util"),progressRecorder_1=require("../../../../utils/progressRecorder"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),customError_1=require("../../../../utils/customError"),taskmanager_1=tslib_1.__importDefault(require("../../../../utils/taskmanager")),pluginconfig_1=require("../pluginconfig");var FileType,JSONType;function getFileType(e){let t=path_1.default.extname(e);if(t.startsWith(".")){if(t=t.slice(1),t===FileType.JS)return FileType.JS;if(t===FileType.WXML)return FileType.WXML;if(t===FileType.WXSS)return FileType.WXSS;if(t===FileType.WXS)return FileType.WXS;if(t===FileType.JSON)return FileType.JSON}throw Error("unknown the filetype of "+e)}!function(e){e.JSON="json",e.WXML="wxml",e.WXSS="wxss",e.WXS="wxs",e.JS="js"}(FileType=exports.FileType||(exports.FileType={})),function(e){e.APP="app",e.Page="page",e.EXT="ext",e.SITEMAP="sitemap",e.THEME="theme"}(JSONType=exports.JSONType||(exports.JSONType={}));class BaseGraph{constructor(e){var t;this.invalidated=!0,this.running=!1,this.onFileChange=(e,t)=>{t.startsWith(this.root)&&(t=t.replace(new RegExp("^"+this.root),""),this.resolver.onFileChange(e,t),"change"!==e&&"unlink"!==e||this.invalidateModules(t),this.onFileChangeForGraph(e,t))},this.getCodeFileTask=async(e,t,i={useCache:!0,resultType:"dev"})=>{const o=this.loadModuleFromFile(e,t,i),s=await o.toCodeFile(i.resultType||"dev");if(!("error"in s)&&"dev"!==i.resultType){const e=await o.toGenerateResult(i.resultType||"dev");if(!("error"in e)){const t=await this.optimize(e,i),o=await this.compress(t,i);s.code=o.target.code,s.map=o.target.map}}return{file:e,codeFile:s,process:await o.getProcessInfo(i.resultType||"dev")||[]}},this.type=e.type,this.root=e.root,this.rootPath=(0,tools_1.joinPath)(e.compiler.project.projectPath,this.root),this.persistCache=e.persistCache,this.compiler=e.compiler,this.project=this.compiler.project,this.cachedModules=new Map,this.pluginDriver=new pluginDriver_1.PluginDriver(this,e),this.modulesByPath=new Map,this.resolver=new resolver_1.Resolver(this,this.root,this.pluginDriver.resolveExtConf),this.compiler.proxyProject.addResolver(this.resolver),null===(t=this.project.event)||void 0===t||t.on("fileChange",this.onFileChange)}destroy(){var e;this.compiler.proxyProject.removeResolver(this.resolver),null===(e=this.project.event)||void 0===e||e.off("fileChange",this.onFileChange)}clearCache(){this.modulesByPath.clear()}async ensureConf(e){this.conf||await this.getConf(e)}async getPackageFile(e){await this.ensureConf(progressRecorder_1.silentRecorder);const t=[];for(const[i,o]of this.resolver.resolveInfoMap.entries())e!==config_1.FullPkg&&this.checkFilePackage(i)!==e||t.push(o);return t.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path),isBabelIgnore:this.isBabelSettingIgnore(e)}))}invalidateModules(e){for(const t of this.modulesByPath.values())(t.sourcePath===e||t.depFiles.includes(e))&&this.modulesByPath.delete(t.path)}loadModuleFromFile(e,t,i){let o=this.modulesByPath.get(e.path),s=!o||o.sourcePath!==e.source||o.independentRoot!==e.independentRoot;if(!s&&(null==o?void 0:o.getError(i.resultType))){if(o.getGeneratedTS(i.resultType)+1e3>Date.now())return o;s=!0}if(s){const t=getFileType(e.path);o=new module_1.default(this,e.path,e.source,t),o.independentRoot=e.independentRoot,e.isBabelIgnore&&(o.isBabelIgnore=!0),this.modulesByPath.set(e.path,o)}let r=o.getLoadingPromise();void 0===r&&(r=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),()=>this.loadSourceForModule(o,i)),o.setLoadingPromise(r));let a=o.getGeneratingPromise(i.resultType);return void 0===a&&(a=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),async()=>{const e=await o.getLoadingPromise();return this.generate(e,o,i)}),o.setGeneratingPromise(i.resultType,a)),o}async loadSourceForModule(e,t){try{const i=(0,tools_1.joinPath)(this.rootPath,e.sourcePath),o=t=>Object.assign(Object.assign({},t),{rootPath:this.rootPath,addWatchFile:t=>{const i=(0,tools_1.normalizePath)(t);if(!i.startsWith(this.rootPath))throw(0,customError_1.makeCustomError)(`The file (${t}) required by ${e.sourcePath} is outside the project`,customError_1.CustomErrors.SUMMER_PLUGIN_CODE_ERR,e.path);e.addWatchFile(path_1.default.posix.relative(this.rootPath,i))}});let s=await this.pluginDriver.hookFirst("load",[e.path,i,Object.assign(Object.assign({},t),{independentRoot:e.independentRoot,isBabelIgnore:e.isBabelIgnore||!1})],o);if(!s){const t=Date.now(),o=await this.readFile(i);s={targetPath:e.path,source:{sourceCode:o},process:[{cost:Date.now()-t,pluginName:"readFile",action:"load"}]}}return await this.tranform(s,e,o,t)}catch(i){throw i.path=(0,tools_1.joinPath)(this.root,e.sourcePath),e.setError(t.resultType,i),i}}async doCompileSingleCode(e,t){const i=this.loadModuleFromFile(e,progressRecorder_1.silentRecorder,{resultType:"dev"}),o=i.getError("dev");if(o)throw o;return await i.toCodeFile("dev")}async getCodeFiles(e,t,i={useCache:!0,resultType:"dev"}){var o;const s=Date.now(),r={},a=new taskmanager_1.default({poolLimit:10,breakWhenError:!0});for(const o of e)a.addTask(this.getCodeFileTask,o,t,i);const n=await a.runAllAsync();for(const e of n)r[e.file.path]=e.codeFile,(null===(o=e.codeFile.jsTag)||void 0===o?void 0:o.isLargeFile)&&t.message("warn",locales_1.default.config.LARGEFILE_WARNING.format(e.file.path,config_1.MAX_CODE_LENGTH/1024));return console.info(`getCodeFiles: count: ${e.length}, cost: ${Date.now()-s}ms.`),r}async readFile(e){const t=path_1.default.relative(this.project.projectPath,e);return this.project.getFile("",t).toString()}async tranform(e,t,i,o){return await this.pluginDriver.hookReduceArg0("transform",[e,t.path,t.sourcePath,Object.assign(Object.assign({},o),{independentRoot:t.independentRoot,isBabelIgnore:t.isBabelIgnore||!1})],(function(e,t){return void 0===t?e:t}),i)}async generate(e,t,i){const o=await this.pluginDriver.hookFirst("generate",[e,t.path,t.sourcePath,Object.assign(Object.assign({},i),{independentRoot:t.independentRoot,isBabelIgnore:t.isBabelIgnore||!1})]);return void 0===o||(0,lodash_1.isNull)(o)?Object.assign(Object.assign({},e),{target:{code:e.source.sourceCode,map:e.source.inputMap}}):o}async optimize(e,t){return await this.pluginDriver.hookReduceArg0("optimize",[e,t],(e,t)=>t,e=>e)}async compress(e,t){return await this.pluginDriver.hookReduceArg0("compress",[e,t],(e,t)=>t,e=>e)}async compile(e,t){const{jsons:i}=await t.run(locales_1.default.config.SUMMER_COMPILE_JSON.format(),()=>this.compileJSON(e,t)),o=await this.compileCodeWithoutJSON(e,t),s=await t.run(locales_1.default.config.SUMMER_PACK_FILES.format(),()=>this.compileOther(Object.keys(i),t)),r=Object.assign(Object.assign(Object.assign({},s),o),i);return await t.run(locales_1.default.config.SUMMER_SEAL_PACK.format(),()=>this.pluginDriver.hookParallel("sealed",[r])),r}async compileWithFileList(e,t){const i=e.fileList,{jsons:o}=await t.run(locales_1.default.config.SUMMER_COMPILE_JSON.format(),()=>this.compileJSONWithFileList(Object.assign(Object.assign({},e),{fileList:i.filter(e=>e.endsWith(".json"))}),t)),s=i.filter(e=>!e.endsWith(".json")),r=await this.compileCodeWithoutJSONWithFileList(Object.assign(Object.assign({},e),{fileList:s}),t),a=Object.assign(Object.assign({},r),o);return await t.run(locales_1.default.config.SUMMER_SEAL_PACK.format(),()=>this.pluginDriver.hookParallel("sealed",[a])),a}async getLocalFileList(){const e=this.getLocalCodeFileList(),t=new Set(this.resolver.allExts.map(e=>"."+e)),i=await this.getWhiteListConfig(),o=this.project.getFileList(this.root,"").filter(e=>{const o=path_1.default.posix.extname(e);return i.has(o)&&!t.has(o)}).map(e=>e.replace(new RegExp("^"+this.root),"")),s={};for(const t of e.concat(o)){const e=this.project.stat(this.root,t);s[t]=e}return s}async compileOther(e,t=progressRecorder_1.silentRecorder){const i=new Set(this.resolver.allExts.map(e=>"."+e));i.delete(".json");const o=await this.getWhiteListConfig(),s=this.project.getFileList(this.root,"").filter(s=>{const r=path_1.default.posix.extname(s),a=path_1.default.posix.relative(this.root,s);if(!o.has(r)||i.has(r)||e.includes(a))return!1;return!packOptionsHelper_1.default.isIgnoredByRules(s)||(t.message("warn",s+" is ignored by project.config.json packOptions.ignore setting"),!1)}),r=await(0,common_1.compileOther)(this.project,s,{onProgressUpdate:()=>{}}),a={};for(const e in r){a[path_1.default.posix.relative(this.root,e)]=r[e]}return a}async compileCodeWithoutJSON(e,t){var i;const o={},s=await this.getProdCode(t,Object.assign(Object.assign({},e),{package:config_1.FullPkg})),r=new Set;for(const e in s){const t=s[e];if("error"in t)throw t.error;if(t.path.endsWith(".js")){((null===(i=t.jsTag)||void 0===i?void 0:i.helpers)||[]).forEach(e=>{r.add(e)}),o[e]=t.code;const s=t.map&&(0,tools_1.formatSourceMap)(t.map);s&&(o[e+".map"]=s)}else o[e]=t.code}return await t.run(locales_1.default.config.SUMMER_APPEND_BABEL_HELPERS.format((0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?"swc":"babel"),()=>(0,helper_util_1.appendHelpers)(this.project,r,"",o)),o}async compileCodeWithoutJSONWithFileList(e,t){var i;const o={},s=await this.getProdCodeByFileList(t,e),r=new Set;for(const e in s){const t=s[e];if("error"in t)throw t.error;if(t.path.endsWith(".js")){((null===(i=t.jsTag)||void 0===i?void 0:i.helpers)||[]).forEach(e=>{r.add(e)}),o[e]=t.code;const s=t.map&&(0,tools_1.formatSourceMap)(t.map);s&&(o[e+".map"]=s)}else o[e]=t.code}return await t.run(locales_1.default.config.SUMMER_APPEND_BABEL_HELPERS.format((0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?"swc":"babel"),()=>(0,helper_util_1.appendHelpers)(this.project,r,"",o)),o}isBabelSettingIgnore(e){var t,i;let o=!1;if(e.path.endsWith(".js")){const s=(0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?null===(t=this.compiler.getSWCSetting())||void 0===t?void 0:t.ignore:null===(i=this.compiler.getBabelSetting())||void 0===i?void 0:i.ignore;s&&(o=(0,babel_helper_1.isIgnore)(s,e.source))}return o}async getDevCodeByFileList(e,t){let i=await this.getPackageFile(config_1.FullPkg);return i=i.filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(i,e)}async getProdCodeByFileList(e,t){let i=await this.getPackageFile(config_1.FullPkg);return i=i.filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(i,e,{useCache:!1,resultType:t.resultType||"prod"})}}exports.BaseGraph=BaseGraph;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseGraph=exports.JSONType=exports.FileType=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),pluginDriver_1=require("../pluginDriver"),module_1=tslib_1.__importDefault(require("../module")),config_1=require("../../../../config/config"),resolver_1=require("../resolver"),common_1=require("../../original/compile/common"),packOptionsHelper_1=tslib_1.__importDefault(require("../../../../utils/packOptionsHelper")),tools_1=require("../../../../utils/tools"),babel_helper_1=require("../../../../utils/babel_helper"),helper_util_1=require("../../../../utils/helper_util"),progressRecorder_1=require("../../../../utils/progressRecorder"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),customError_1=require("../../../../utils/customError"),taskmanager_1=tslib_1.__importDefault(require("../../../../utils/taskmanager")),pluginconfig_1=require("../pluginconfig");var FileType,JSONType;function getFileType(e){let t=path_1.default.extname(e);if(t.startsWith(".")){if(t=t.slice(1),t===FileType.JS)return FileType.JS;if(t===FileType.WXML)return FileType.WXML;if(t===FileType.WXSS)return FileType.WXSS;if(t===FileType.WXS)return FileType.WXS;if(t===FileType.JSON)return FileType.JSON}throw Error("unknown the filetype of "+e)}!function(e){e.JSON="json",e.WXML="wxml",e.WXSS="wxss",e.WXS="wxs",e.JS="js"}(FileType=exports.FileType||(exports.FileType={})),function(e){e.APP="app",e.Page="page",e.EXT="ext",e.SITEMAP="sitemap",e.THEME="theme"}(JSONType=exports.JSONType||(exports.JSONType={}));class BaseGraph{constructor(e){var t;this.invalidated=!0,this.running=!1,this.onFileChange=(e,t)=>{t.startsWith(this.root)&&(t=t.replace(new RegExp("^"+this.root),""),this.resolver.onFileChange(e,t),"change"!==e&&"unlink"!==e||this.invalidateModules(t),this.onFileChangeForGraph(e,t))},this.getCodeFileTask=async(e,t,o={useCache:!0,resultType:"dev"})=>{const i=this.loadModuleFromFile(e,t,o);if(i.sourcePath.endsWith(".js")||i.sourcePath.endsWith(".ts")){return{file:e,codeFile:await i.toCodeFile2(o.resultType||"dev"),process:[]}}const r=await i.toCodeFile(o.resultType||"dev");if(!("error"in r)&&"dev"!==o.resultType){const e=await i.toGenerateResult(o.resultType||"dev");if(!("error"in e)){const t=await this.optimize(e,o),i=await this.compress(t,o);r.code=i.target.code,r.map=i.target.map}}return{file:e,codeFile:r,process:await i.getProcessInfo(o.resultType||"dev")||[]}},this.type=e.type,this.root=e.root,this.rootPath=(0,tools_1.joinPath)(e.compiler.project.projectPath,this.root),this.persistCache=e.persistCache,this.compiler=e.compiler,this.project=this.compiler.project,this.cachedModules=new Map,this.pluginDriver=new pluginDriver_1.PluginDriver(this,e),this.modulesByPath=new Map,this.resolver=new resolver_1.Resolver(this,this.root,this.pluginDriver.resolveExtConf),this.compiler.proxyProject.addResolver(this.resolver),null===(t=this.project.event)||void 0===t||t.on("fileChange",this.onFileChange)}destroy(){var e;this.compiler.proxyProject.removeResolver(this.resolver),null===(e=this.project.event)||void 0===e||e.off("fileChange",this.onFileChange)}clearCache(){this.modulesByPath.clear()}async ensureConf(e){this.conf||await this.getConf(e)}async getPackageFile(e){await this.ensureConf(progressRecorder_1.silentRecorder);const t=[];for(const[o,i]of this.resolver.resolveInfoMap.entries())e!==config_1.FullPkg&&this.checkFilePackage(o)!==e||t.push(i);return t.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path),isBabelIgnore:this.isBabelSettingIgnore(e)}))}invalidateModules(e){for(const t of this.modulesByPath.values())(t.sourcePath===e||t.depFiles.includes(e))&&this.modulesByPath.delete(t.path)}loadModuleFromFile(e,t,o){let i=this.modulesByPath.get(e.path),r=!i||i.sourcePath!==e.source||i.independentRoot!==e.independentRoot;if(!r&&(null==i?void 0:i.getError(o.resultType))){if(i.getGeneratedTS(o.resultType)+1e3>Date.now())return i;r=!0}if(r){const t=getFileType(e.path);i=new module_1.default(e.path,e.source,t),i.independentRoot=e.independentRoot,e.isBabelIgnore&&(i.isBabelIgnore=!0),this.modulesByPath.set(e.path,i)}if(e.path.endsWith(".ts")||e.path.endsWith(".js")){let r=i.getLoadingPromise();void 0===r&&(r=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),()=>this.loadSourceForModuleWithoutTransform(i,o)),i.setLoadingPromise(r));let s=i.getCompilePromise(o.resultType);return void 0===s&&(s=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),async()=>{const e=await i.getLoadingPromise();return this.compileCode(e,i,o)}),i.setCompilePromise(o.resultType,s)),i}let s=i.getLoadingPromise();void 0===s&&(s=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),()=>this.loadSourceForModule(i,o)),i.setLoadingPromise(s));let a=i.getGeneratingPromise(o.resultType);return void 0===a&&(a=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),async()=>{const e=await i.getLoadingPromise();return this.generate(e,i,o)}),i.setGeneratingPromise(o.resultType,a)),i}async loadSourceForModuleWithoutTransform(e,t){try{const o=(0,tools_1.joinPath)(this.rootPath,e.sourcePath),i=t=>Object.assign(Object.assign({},t),{rootPath:this.rootPath,addWatchFile:t=>{const o=(0,tools_1.normalizePath)(t);if(!o.startsWith(this.rootPath))throw(0,customError_1.makeCustomError)(`The file (${t}) required by ${e.sourcePath} is outside the project`,customError_1.CustomErrors.SUMMER_PLUGIN_CODE_ERR,e.path);e.addWatchFile(path_1.default.posix.relative(this.rootPath,o))}});let r=await this.pluginDriver.hookFirst("load",[e.path,o,Object.assign(Object.assign({},t),{independentRoot:e.independentRoot,isBabelIgnore:e.isBabelIgnore||!1})],i);if(!r){const t=Date.now(),i=await this.readFile(o);r={targetPath:e.path,source:{sourceCode:i},process:[{cost:Date.now()-t,pluginName:"readFile",action:"load"}]}}return r}catch(o){throw o.path=(0,tools_1.joinPath)(this.root,e.sourcePath),e.setError(t.resultType,o),o}}async loadSourceForModule(e,t){try{const o=await this.loadSourceForModuleWithoutTransform(e,t);return await this.tranform(o,e,t)}catch(o){throw o.path=(0,tools_1.joinPath)(this.root,e.sourcePath),e.setError(t.resultType,o),o}}async doCompileSingleCode(e,t){const o=this.loadModuleFromFile(e,progressRecorder_1.silentRecorder,{resultType:"dev"}),i=o.getError("dev");if(i)throw i;return await o.toCodeFile("dev")}async getCodeFiles(e,t,o={useCache:!0,resultType:"dev"}){var i;const r=Date.now(),s={},a=new taskmanager_1.default({poolLimit:10,breakWhenError:!0});for(const i of e)a.addTask(this.getCodeFileTask,i,t,o);const n=await a.runAllAsync();for(const e of n)s[e.file.path]=e.codeFile,(null===(i=e.codeFile.jsTag)||void 0===i?void 0:i.isLargeFile)&&t.message("warn",locales_1.default.config.LARGEFILE_WARNING.format(e.file.path,config_1.MAX_CODE_LENGTH/1024));return console.info(`getCodeFiles: count: ${e.length}, cost: ${Date.now()-r}ms.`),s}async readFile(e){const t=path_1.default.relative(this.project.projectPath,e);return this.project.getFile("",t).toString()}async tranform(e,t,o){return await this.pluginDriver.hookReduceArg0("transform",[e,t.path,t.sourcePath,Object.assign(Object.assign({},o),{independentRoot:t.independentRoot,isBabelIgnore:t.isBabelIgnore||!1})],(function(e,t){return void 0===t?e:t}))}async generate(e,t,o){const i=await this.pluginDriver.hookFirst("generate",[e,t.path,t.sourcePath,Object.assign(Object.assign({},o),{independentRoot:t.independentRoot,isBabelIgnore:t.isBabelIgnore||!1})]);return void 0===i||(0,lodash_1.isNull)(i)?Object.assign(Object.assign({},e),{target:{code:e.source.sourceCode,map:e.source.inputMap}}):i}async compileCode(e,t,o){const i=await this.pluginDriver.hookFirst("compile",[t.path,t.sourcePath,e,Object.assign(Object.assign({},o),{independentRoot:t.independentRoot,isBabelIgnore:t.isBabelIgnore||!1})]);if(!i)throw new Error("not handle for "+t.sourcePath);return i}async optimize(e,t){return await this.pluginDriver.hookReduceArg0("optimize",[e,t],(e,t)=>t,e=>e)}async compress(e,t){return await this.pluginDriver.hookReduceArg0("compress",[e,t],(e,t)=>t,e=>e)}async compile(e,t){const{jsons:o}=await t.run(locales_1.default.config.SUMMER_COMPILE_JSON.format(),()=>this.compileJSON(e,t)),i=await this.compileCodeWithoutJSON(e,t),r=await t.run(locales_1.default.config.SUMMER_PACK_FILES.format(),()=>this.compileOther(Object.keys(o),t)),s=Object.assign(Object.assign(Object.assign({},r),i),o);return await t.run(locales_1.default.config.SUMMER_SEAL_PACK.format(),()=>this.pluginDriver.hookParallel("sealed",[s])),s}async compileWithFileList(e,t){const o=e.fileList,{jsons:i}=await t.run(locales_1.default.config.SUMMER_COMPILE_JSON.format(),()=>this.compileJSONWithFileList(Object.assign(Object.assign({},e),{fileList:o.filter(e=>e.endsWith(".json"))}),t)),r=o.filter(e=>!e.endsWith(".json")),s=await this.compileCodeWithoutJSONWithFileList(Object.assign(Object.assign({},e),{fileList:r}),t),a=Object.assign(Object.assign({},s),i);return await t.run(locales_1.default.config.SUMMER_SEAL_PACK.format(),()=>this.pluginDriver.hookParallel("sealed",[a])),a}async getLocalFileList(){const e=this.getLocalCodeFileList(),t=new Set(this.resolver.allExts.map(e=>"."+e)),o=await this.getWhiteListConfig(),i=this.project.getFileList(this.root,"").filter(e=>{const i=path_1.default.posix.extname(e);return o.has(i)&&!t.has(i)}).map(e=>e.replace(new RegExp("^"+this.root),"")),r={};for(const t of e.concat(i)){const e=this.project.stat(this.root,t);r[t]=e}return r}async compileOther(e,t=progressRecorder_1.silentRecorder){const o=new Set(this.resolver.allExts.map(e=>"."+e));o.delete(".json");const i=await this.getWhiteListConfig(),r=this.project.getFileList(this.root,"").filter(r=>{const s=path_1.default.posix.extname(r),a=path_1.default.posix.relative(this.root,r);if(!i.has(s)||o.has(s)||e.includes(a))return!1;return!packOptionsHelper_1.default.isIgnoredByRules(r)||(t.message("warn",r+" is ignored by project.config.json packOptions.ignore setting"),!1)}),s=await(0,common_1.compileOther)(this.project,r,{onProgressUpdate:()=>{}}),a={};for(const e in s){a[path_1.default.posix.relative(this.root,e)]=s[e]}return a}async compileCodeWithoutJSON(e,t){var o;const i={},r=await this.getProdCode(t,Object.assign(Object.assign({},e),{package:config_1.FullPkg})),s=new Set;for(const e in r){const t=r[e];if("error"in t)throw t.error;if(t.path.endsWith(".js")){((null===(o=t.jsTag)||void 0===o?void 0:o.helpers)||[]).forEach(e=>{s.add(e)}),i[e]=t.code;const r=t.map&&(0,tools_1.formatSourceMap)(t.map);r&&(i[e+".map"]=r)}else i[e]=t.code}return await t.run(locales_1.default.config.SUMMER_APPEND_BABEL_HELPERS.format((0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?"swc":"babel"),()=>(0,helper_util_1.appendHelpers)(this.project,s,"",i)),i}async compileCodeWithoutJSONWithFileList(e,t){var o;const i={},r=await this.getProdCodeByFileList(t,e),s=new Set;for(const e in r){const t=r[e];if("error"in t)throw t.error;if(t.path.endsWith(".js")){((null===(o=t.jsTag)||void 0===o?void 0:o.helpers)||[]).forEach(e=>{s.add(e)}),i[e]=t.code;const r=t.map&&(0,tools_1.formatSourceMap)(t.map);r&&(i[e+".map"]=r)}else i[e]=t.code}return await t.run(locales_1.default.config.SUMMER_APPEND_BABEL_HELPERS.format((0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?"swc":"babel"),()=>(0,helper_util_1.appendHelpers)(this.project,s,"",i)),i}isBabelSettingIgnore(e){var t,o;let i=!1;if(e.path.endsWith(".js")){const r=(0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?null===(t=this.compiler.getSWCSetting())||void 0===t?void 0:t.ignore:null===(o=this.compiler.getBabelSetting())||void 0===o?void 0:o.ignore;r&&(i=(0,babel_helper_1.isIgnore)(r,e.source))}return i}async getDevCodeByFileList(e,t){let o=await this.getPackageFile(config_1.FullPkg);return o=o.filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(o,e)}async getProdCodeByFileList(e,t){let o=await this.getPackageFile(config_1.FullPkg);return o=o.filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(o,e,{useCache:!1,resultType:t.resultType||"prod"})}}exports.BaseGraph=BaseGraph;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tools_1=require("../../../utils/tools"),customError_1=require("../../../utils/customError"),basegraph_1=require("./graph/basegraph");class JsTag{constructor(){this.isLargeFile=!1,this.isBabelIgnore=!1,this.helpers=[],this.resultType="dev"}setBabelIgnore(){this.isBabelIgnore=!0}setLargeFile(){this.isLargeFile=!0}addHelpers(e){for(const t of e)this.helpers.includes(t)||this.helpers.push(t)}setResultType(e="dev"){this.resultType=e}toJSON(){return{isLargeFile:this.isLargeFile,isBabelIgnore:this.isBabelIgnore,helpers:this.helpers}}}class Module{constructor(e,t,s,r){this.graph=e,this.path=t,this.sourcePath=s,this.fileType=r,this._error={},this.generateResultPromise={},this.depFiles=[],this.independentRoot="",this.isBabelIgnore=!1,this.generatedTS={}}transResultType(e){return this.fileType===basegraph_1.FileType.JS||this.fileType===basegraph_1.FileType.WXML?e:"common"}getGeneratedTS(e){return this.generatedTS[this.transResultType(e)]||0}setError(e,t){const s=this.transResultType(e);this._error[s]=t,this.generatedTS[s]=Date.now()}getError(e){const t=this.transResultType(e);return this._error[t]}async getJsTag(){if(this.fileType!==basegraph_1.FileType.JS)return;if(this._jsTag)return this._jsTag;const e=new JsTag;(await this.getSource()).largeFile&&e.setLargeFile();const t=await this.generateResultPromise.common;return t.target&&(e.addHelpers(t.target.helpers||[]),e.setResultType(t.target.resultType)),this.isBabelIgnore&&e.setBabelIgnore(),this._jsTag=e,e}async getSource(){return(await this.getLoadingPromise()).source}async getMd5(){const e=await this.getSource();return(0,tools_1.generateMD5)(e.sourceCode)}setLoadingPromise(e){this.loadResult=e}getLoadingPromise(){return this.loadResult}setGeneratingPromise(e,t){const s=this.transResultType(e);this.generateResultPromise[s]=t,this.generateResultPromise.common=t,t.then(()=>{this.generatedTS[s]=Date.now()})}getGeneratingPromise(e){const t=this.transResultType(e);return this.generateResultPromise[t]}async getProcessInfo(e){var t;const s=this.getGeneratingPromise(e);return null===(t=await s)||void 0===t?void 0:t.process}async toCodeFile(e){const t=this.getError(e);if(t)return t instanceof customError_1.CustomError?{path:this.path,error:t.toJSON()}:{path:this.path,error:this._error};const s=this.getGeneratingPromise(e);if(void 0===s)return{path:this.path,error:"empty result"};const r=await this.getJsTag(),i=await this.getSource();try{return Object.assign({path:this.path,md5:await this.getMd5(),jsTag:null==r?void 0:r.toJSON(),mtime:i.mtime},(await s).target)}catch(e){return{path:this.path,error:e}}}async toGenerateResult(e){const t=this.getGeneratingPromise(e);if(void 0===t)return{path:this.path,error:"empty result"};const s=await t;return{targetPath:this.path,source:await this.getSource(),target:s.target,process:s.process||[]}}toJSON(){return{code:"",map:void 0,path:this.path,sourcePath:this.sourcePath,depFileIds:this.depFiles}}addWatchFile(e){-1===this.depFiles.indexOf(e)&&this.depFiles.push(e)}}exports.default=Module;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tools_1=require("../../../utils/tools"),customError_1=require("../../../utils/customError"),basegraph_1=require("./graph/basegraph"),env_1=require("../../../utils/env");class JsTag{constructor(){this.isLargeFile=!1,this.isBabelIgnore=!1,this.helpers=[],this.resultType="dev"}setBabelIgnore(){this.isBabelIgnore=!0}setLargeFile(){this.isLargeFile=!0}addHelpers(e){for(const t of e)this.helpers.includes(t)||this.helpers.push(t)}setResultType(e="dev"){this.resultType=e}toJSON(){return{isLargeFile:this.isLargeFile,isBabelIgnore:this.isBabelIgnore,helpers:this.helpers}}}class Module{constructor(e,t,s){this.path=e,this.sourcePath=t,this.fileType=s,this._error={},this.generateResultPromise={},this.compileResultPromise={},this.depFiles=[],this.independentRoot="",this.isBabelIgnore=!1,this.generatedTS={}}transResultType(e){return this.fileType===basegraph_1.FileType.JS||this.fileType===basegraph_1.FileType.WXML?e:"common"}getGeneratedTS(e){return this.generatedTS[this.transResultType(e)]||0}setError(e,t){const s=this.transResultType(e);this._error[s]=t,this.generatedTS[s]=Date.now()}getError(e){const t=this.transResultType(e);return this._error[t]}async getJsTag(){if(this.fileType!==basegraph_1.FileType.JS)return;if(this._jsTag)return this._jsTag;const e=new JsTag;(await this.getSource()).largeFile&&e.setLargeFile();const t=await this.generateResultPromise.common;return t.target&&(e.addHelpers(t.target.helpers||[]),e.setResultType(t.target.resultType)),this.isBabelIgnore&&e.setBabelIgnore(),this._jsTag=e,e}async getJsTag2(){if(this.fileType!==basegraph_1.FileType.JS)return;if(this._jsTag)return this._jsTag;const e=new JsTag;(await this.getSource()).largeFile&&e.setLargeFile();const t=await this.compileResultPromise.common;return t.target&&(e.addHelpers(t.target.helpers||[]),e.setResultType(t.target.resultType)),this.isBabelIgnore&&e.setBabelIgnore(),this._jsTag=e,e}async getSource(){return(await this.getLoadingPromise()).source}async getMd5(){const e=await this.getSource();return(0,tools_1.generateMD5)(e.sourceCode)}setLoadingPromise(e){this.loadResult=e}async clearUselessCache(){if((0,env_1.isElectron)()&&this.path.endsWith(".js")){const e=await this.loadResult;if(e){const t=e.source;delete t.astInfo,delete t.inputMap}for(const e in this.generateResultPromise){const t=e;if(void 0!==this.generateResultPromise[t]){delete(await this.generateResultPromise[t]).source}}}}getLoadingPromise(){return this.loadResult}setGeneratingPromise(e,t){const s=this.transResultType(e);this.generateResultPromise[s]=t,this.generateResultPromise.common=t,t.then(()=>{this.generatedTS[s]=Date.now()})}getGeneratingPromise(e){const t=this.transResultType(e);return this.generateResultPromise[t]}getCompilePromise(e){const t=this.transResultType(e);return this.compileResultPromise[t]}setCompilePromise(e,t){const s=this.transResultType(e);this.compileResultPromise[s]=t,this.compileResultPromise.common=t}async getProcessInfo(e){var t;const s=this.getGeneratingPromise(e);return null===(t=await s)||void 0===t?void 0:t.process}async toCodeFile(e){const t=this.getError(e);if(t)return t instanceof customError_1.CustomError?{path:this.path,error:t.toJSON()}:{path:this.path,error:this._error};const s=this.getGeneratingPromise(e);if(void 0===s)return{path:this.path,error:"empty result"};const r=await this.getJsTag(),i=await this.getSource();try{return Object.assign({path:this.path,md5:await this.getMd5(),jsTag:null==r?void 0:r.toJSON(),mtime:i.mtime},(await s).target)}catch(e){return{path:this.path,error:e}}}async toCodeFile2(e){const t=this.getError(e);if(t)return t instanceof customError_1.CustomError?{path:this.path,error:t.toJSON()}:{path:this.path,error:this._error};const s=await this.getJsTag2(),r=await this.getSource(),i=this.getCompilePromise(e);if(void 0===i)return{path:this.path,error:"empty result"};const a=await i;try{return Object.assign({path:this.path,md5:await this.getMd5(),jsTag:null==s?void 0:s.toJSON(),mtime:r.mtime},a.target)}catch(e){return{path:this.path,error:e}}}async toGenerateResult(e){const t=this.getGeneratingPromise(e);if(void 0===t)return{path:this.path,error:"empty result"};const s=await t;return{targetPath:this.path,source:await this.getSource(),target:s.target,process:s.process||[]}}toJSON(){return{code:"",map:void 0,path:this.path,sourcePath:this.sourcePath,depFileIds:this.depFiles}}addWatchFile(e){-1===this.depFiles.indexOf(e)&&this.depFiles.push(e)}}exports.default=Module;
@@ -1 +1 @@
1
- "use strict";function couldUseSWCMode(e){if(e.compileWorklet)return!1;return!1===e.disableSWC||null===e.disableSWC&&(e.es6||e.enhance)||void 0===e.disableSWC&&1==e.swc}function getSummerPluginConfig(e){const i=new Set,{disableUseStrict:s}=e;return couldUseSWCMode(e)?i.add(["swc",{disableUseStrict:s}]):(i.add("javascript"),i.add(["es6module",{disableUseStrict:s}]),e.enhance||e.es6?i.add(["enhance",{disableUseStrict:s}]):e.compileWorklet&&i.add("worklet"),e.minified&&i.add("terser")),(e.minifyWXSS||e.postcss)&&i.add("wxss"),e.minifyWXML&&i.add("minifywxml"),e.useCompilerPlugins&&e.useCompilerPlugins.forEach(e=>{if("string"==typeof e)i.add(e);else{if(!Array.isArray(e))throw new Error("invalid useCompilerPlugins options: "+JSON.stringify(e));if("string"!=typeof e[0]||void 0===e[1])throw new Error("invalid useCompilerPlugins options: "+JSON.stringify(e));i.add(e)}}),Array.from(i)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSummerPluginConfig=exports.couldUseSWCMode=void 0,exports.couldUseSWCMode=couldUseSWCMode,exports.getSummerPluginConfig=getSummerPluginConfig;
1
+ "use strict";function couldUseSWCMode(e){if(e.compileWorklet)return!1;return!1===e.disableSWC||null===e.disableSWC&&(e.es6||e.enhance)||void 0===e.disableSWC&&1==e.swc}function getSummerPluginConfig(e){const i=new Set,{disableUseStrict:r}=e;return i.add(["script",{disableUseStrict:r}]),(e.minifyWXSS||e.postcss)&&i.add("wxss"),e.minifyWXML&&i.add("minifywxml"),e.useCompilerPlugins&&e.useCompilerPlugins.forEach(e=>{if("string"==typeof e)"typescript"!==e&&i.add(e);else{if(!Array.isArray(e))throw new Error("invalid useCompilerPlugins options: "+JSON.stringify(e));if("string"!=typeof e[0]||void 0===e[1])throw new Error("invalid useCompilerPlugins options: "+JSON.stringify(e));"typescript"!==e[0]&&i.add(e)}}),Array.from(i)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSummerPluginConfig=exports.couldUseSWCMode=void 0,exports.couldUseSWCMode=couldUseSWCMode,exports.getSummerPluginConfig=getSummerPluginConfig;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.transformES6ModuleAndGenCode=exports.getBabelRoot=void 0;const config_1=require("../../../../../config/config"),babel_helper_1=require("../../../../../utils/babel_helper"),tools_1=require("../../../../../utils/tools"),pluginTransformModulesCommonjs=()=>require("@babel/plugin-transform-modules-commonjs"),babel7=()=>require("@babel/core");function getES6ModulePluginsList(e){return[[require("@babel/plugin-transform-modules-commonjs"),{allowTopLevelThis:e,importInterop:e=>e.startsWith("@babel/runtime/helpers/")?"node":"babel"}]]}function getBabelRoot(e){return""===e?"@babel/runtime":(0,tools_1.normalizePath)(e+"/@babel/runtime")}function transformES6ModuleAndGenCode(e,o,t){const r=t.disableUseStrict||/^\s*\/\/\s?use strict disable;/i.test(o.sourceCode||"");let s;try{const t={babelrc:!1,plugins:getES6ModulePluginsList(r),filename:e,sourceFileName:e,sourceMaps:!0,inputSourceMap:o.inputMap,configFile:!1,code:!0,cloneInputAst:!0},n=require("@babel/core");if(!o.astInfo)throw new Error("source.astInfo is not exist");if(o.astInfo.type!==config_1.AstType.Babel)throw new Error("ast type is not babel");s=n.transformFromAstSync(o.astInfo.ast,o.sourceCode,t)}catch(o){throw o.code=config_1.BABEL_TRANS_JS_ERR,o.message=`file: ${e}\n ${o.message}`,o.path=e,o}if(!s)throw new Error("no trans result for callPostEnhance");let n=s.code;const a=s.map;r&&(n=n.replace(/^"use strict";/,""));const l=(0,babel_helper_1.collectBabelHelpers)(o.sourceCode),i=(0,babel_helper_1.replaceBabelHelpers)(n,l,e,t.babelRoot);return{code:i.transformCode,map:a,helpers:i.helpers}}function default_1(e,o){return{name:"summer-es6module",workerMethods:{async doGenerate(e,o,t){const r=await transformES6ModuleAndGenCode(e,o,t);return Object.assign(Object.assign({},r),{resultType:t.resultType})}},async generate(e,t,r,{independentRoot:s,isBabelIgnore:n,resultType:a}){const l=Date.now(),{source:i}=e;if(t.endsWith(".js")&&!i.largeFile&&!n){if(!i.astInfo){if(null===i.sourceCode)throw new Error("source.sourceCode is null");return Object.assign(Object.assign({},e),{target:{code:i.sourceCode,map:i.inputMap,helpers:[],resultType:a||"prod"},process:[...e.process,{cost:Date.now()-l,pluginName:"summer-es6module",action:"generate"}]})}const t={babelRoot:getBabelRoot(s),disableUseStrict:o.disableUseStrict,resultType:a},n=await this.runWorkerMethod("doGenerate",r,i,t);return Object.assign(Object.assign({},e),{target:n,process:[...e.process,{cost:Date.now()-l,pluginName:"summer-es6module",action:"generate",options:t}]})}}}}exports.getBabelRoot=getBabelRoot,exports.transformES6ModuleAndGenCode=transformES6ModuleAndGenCode,exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const babel_script_task_1=require("../script_task/babel_script_task");function default_1(e,t){return{name:"summer-es6module",workerMethods:{async doGenerate(e,t,s){const r=await(0,babel_script_task_1.transformES6ModuleAndGenCode)(e,t,s);return Object.assign(Object.assign({},r),{resultType:s.resultType})}},async generate(e,s,r,{independentRoot:o,isBabelIgnore:a,resultType:n}){const c=Date.now(),{source:i}=e;if(s.endsWith(".js")&&!i.largeFile&&!a){if(!i.astInfo){if(null===i.sourceCode)throw new Error("source.sourceCode is null");return Object.assign(Object.assign({},e),{target:{code:i.sourceCode,map:i.inputMap,helpers:[],resultType:n||"prod"},process:[...e.process,{cost:Date.now()-c,pluginName:"summer-es6module",action:"generate"}]})}const s={babelRoot:(0,babel_script_task_1.getBabelRoot)(o),disableUseStrict:t.disableUseStrict,resultType:n},a=await this.runWorkerMethod("doGenerate",r,i,s);return Object.assign(Object.assign({},e),{target:a,process:[...e.process,{cost:Date.now()-c,pluginName:"summer-es6module",action:"generate",options:s}]})}}}}exports.default=default_1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),config_1=require("../../../../../config/config"),inputsourcemap_1=require("../../utils/inputsourcemap");var config_2=require("../../../../../config/config");function default_1(e){return{name:"summer-javascript",async load(t,r){if(r.endsWith(".js")){const i=Date.now(),o=path_1.default.relative(e.projectPath,r),a=e.getFile("",o).toString(),n=e.stat("",o),u=await(0,inputsourcemap_1.tryGetInputSourceMap)(a,r);return{targetPath:t,source:{sourceCode:a,inputMap:null!=u?u:void 0,astInfo:void 0,largeFile:a.length>=config_1.MAX_CODE_LENGTH,mtime:null==n?void 0:n.mtimeMs},process:[{cost:Date.now()-i,pluginName:"summer-javascript",action:"load"}]}}}}}Object.defineProperty(exports,"MAX_CODE_LENGTH",{enumerable:!0,get:function(){return config_2.MAX_CODE_LENGTH}}),exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=void 0;const load_script_task_1=require("../script_task/load_script_task");var config_1=require("../../../../../config/config");function default_1(e){return{name:"summer-javascript",async load(t,r){if(r.endsWith(".js"))return await(0,load_script_task_1.loadScriptFile)(e,t,r,"summer-javascript")}}}Object.defineProperty(exports,"MAX_CODE_LENGTH",{enumerable:!0,get:function(){return config_1.MAX_CODE_LENGTH}}),exports.default=default_1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSWCRoot=exports.MAX_CODE_LENGTH=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),config_1=require("../../../../../config/config"),tools_1=require("../../../../../utils/tools"),swc_helper_1=require("../../../../../utils/swc_helper"),inputsourcemap_1=require("../../utils/inputsourcemap"),swc=()=>require("@swc/core");var config_2=require("../../../../../config/config");function getSWCRoot(e,t){const r=(0,swc_helper_1.getSWCOutputPath)(e.setting);return""===t?r:(0,tools_1.normalizePath)(`${t}/${r}`)}function default_1(e,t){return{name:"summer-swc",workerMethods:{async doGenerate(e,t,r,s){var o,i;const n=s.disableUseStrict||/^\s*\/\/\s?use strict disable;/i.test(e.sourceCode||""),a=require("@swc/core").transformSync(e.sourceCode,{jsc:{parser:Object.assign(Object.assign({},null===(o=s.rc)||void 0===o?void 0:o.parser),{syntax:t.endsWith("ts")?"typescript":"ecmascript"}),target:s.target,externalHelpers:!0,loose:!1,minify:{compress:{drop_console:!1,drop_debugger:!1},toplevel:!0}},module:Object.assign({type:"commonjs",strictMode:!n,noInterop:!0,allowTopLevelThis:n},null===(i=s.rc)||void 0===i?void 0:i.module),inputSourceMap:e.inputMap?JSON.stringify(e.inputMap):void 0,sourceMaps:!0,filename:t,minify:"dev"!==s.resultType&&s.minify}),c=(0,swc_helper_1.replaceSWCHelpers)(a.code,t,r);return{code:c.transformCode,map:a.map?JSON.parse(a.map):void 0,helpers:c.helpers,resultType:s.resultType}}},async load(t,r){if(!t.endsWith(".js"))return;const s=Date.now(),o=path_1.default.relative(e.projectPath,r),i=e.getFile("",o).toString(),n=e.stat("",o),a=await(0,inputsourcemap_1.tryGetInputSourceMap)(i,r);return{targetPath:t,source:{sourceCode:i,inputMap:null!=a?a:void 0,astInfo:void 0,largeFile:i.length>=config_1.MAX_CODE_LENGTH,mtime:null==n?void 0:n.mtimeMs},process:[{cost:Date.now()-s,pluginName:"summer-swc",action:"load"}]}},async generate(r,s,o,{independentRoot:i,isBabelIgnore:n,resultType:a}){var c;if(!s.endsWith(".js")||n)return;const u=Date.now(),p=getSWCRoot(e,i),l={disableUseStrict:t.disableUseStrict,target:e.setting.enhance||e.setting.es6?"es5":"es2022",rc:null===(c=e.setting.swcSetting)||void 0===c?void 0:c.rc,minify:e.setting.minified,resultType:a},d=await this.runWorkerMethod("doGenerate",r.source,o,p,l);return Object.assign(Object.assign({},r),{target:d,process:[...r.process,{cost:Date.now()-u,pluginName:"summer-swc",action:"transform",options:l}]})}}}Object.defineProperty(exports,"MAX_CODE_LENGTH",{enumerable:!0,get:function(){return config_2.MAX_CODE_LENGTH}}),exports.getSWCRoot=getSWCRoot,exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSWCRoot=exports.MAX_CODE_LENGTH=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),config_1=require("../../../../../config/config"),tools_1=require("../../../../../utils/tools"),swc_helper_1=require("../../../../../utils/swc_helper"),inputsourcemap_1=require("../../utils/inputsourcemap"),swc_task_1=require("../script_task/swc_task");var config_2=require("../../../../../config/config");function getSWCRoot(e,t){const s=(0,swc_helper_1.getSWCOutputPath)(e.setting);return""===t?s:(0,tools_1.normalizePath)(`${t}/${s}`)}function default_1(e,t){return{name:"summer-swc",workerMethods:{async doGenerate(e,t,s,r){const o=await(0,swc_task_1.swcCompileTask)(t,e,Object.assign(Object.assign({},r),{swcRoot:s}));return{code:o.code,map:o.map,helpers:o.helpers,resultType:r.resultType}}},async load(t,s){if(!t.endsWith(".js"))return;const r=Date.now(),o=path_1.default.relative(e.projectPath,s),i=e.getFile("",o).toString(),n=e.stat("",o),a=await(0,inputsourcemap_1.tryGetInputSourceMap)(i,s);return{targetPath:t,source:{sourceCode:i,inputMap:null!=a?a:void 0,astInfo:void 0,largeFile:i.length>=config_1.MAX_CODE_LENGTH,mtime:null==n?void 0:n.mtimeMs},process:[{cost:Date.now()-r,pluginName:"summer-swc",action:"load"}]}},async generate(s,r,o,{independentRoot:i,isBabelIgnore:n,resultType:a}){var c;if(!r.endsWith(".js")||n)return;const u=Date.now(),l=getSWCRoot(e,i),p={disableUseStrict:t.disableUseStrict,target:e.setting.enhance||e.setting.es6?"es5":"es2022",rc:null===(c=e.setting.swcSetting)||void 0===c?void 0:c.rc,minify:e.setting.minified,resultType:a},_=await this.runWorkerMethod("doGenerate",s.source,o,l,p);return Object.assign(Object.assign({},s),{target:_,process:[...s.process,{cost:Date.now()-u,pluginName:"summer-swc",action:"transform",options:p}]})}}}Object.defineProperty(exports,"MAX_CODE_LENGTH",{enumerable:!0,get:function(){return config_2.MAX_CODE_LENGTH}}),exports.getSWCRoot=getSWCRoot,exports.default=default_1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const config_1=require("../../../../config/config"),babel_helper_1=require("../../../../utils/babel_helper"),es6module_1=require("./base/es6module"),_transformRuntimeCustom=()=>require("../../../../utils/babel_transform_plugin"),_pluginTransformRuntime=()=>require("@babel/plugin-transform-runtime"),_pluginTransformWorklet=()=>require("../../../../utils/babel_plugin_worklet"),babel7=()=>require("@babel/core"),_presetEnv=()=>require("@babel/preset-env");function getEnhancePluginsList(e){const r=[[require("../../../../utils/babel_transform_plugin")],[require("@babel/plugin-transform-runtime"),{corejs:!1,helpers:!0,regenerator:!0,version:"7.21.0"}]].concat((0,babel_helper_1.getCustomPlugins)([]));return e.supportWorklet&&r.push([require("../../../../utils/babel_plugin_worklet")]),r}const enhance=(e,r)=>{const t=babel7(),s=e.sourceCode.includes('"worklet"')||e.sourceCode.includes("'worklet'");let o;try{const n={presets:[[require("@babel/preset-env"),{targets:{chrome:53,ios:8},modules:!1,include:["@babel/plugin-transform-computed-properties"]}]],babelrc:!1,plugins:getEnhancePluginsList({supportWorklet:s}),sourceFileName:r,inputSourceMap:!1,configFile:!1,code:!1,ast:!0,cloneInputAst:!1};if(e.astInfo){if(e.astInfo.type!==config_1.AstType.Babel)throw new Error("ast type is not babel");o=t.transformFromAstSync(e.astInfo.ast,e.sourceCode,n)}else{if(null===e.sourceCode)throw new Error("source.targetCode is null");o=babel7().transform(e.sourceCode,n)}}catch(e){const t=`file: ${r}\n ${e.message}`,s=new Error(t);throw s.code=config_1.BABEL_TRANS_JS_ERR,s}return{sourceCode:e.sourceCode,inputMap:e.inputMap,astInfo:{ast:o.ast,type:config_1.AstType.Babel}}};function default_1(e,r){return{name:"summer-enhance",workerMethods:{doTransform:(e,r,t,s)=>enhance(e,r)},async transform(e,t,s,{independentRoot:o,isBabelIgnore:n}){const{source:u}=e;if(t.endsWith(".js")&&!u.largeFile&&!n){const t=Date.now(),n=(0,es6module_1.getBabelRoot)(o),a=await this.runWorkerMethod("doTransform",u,s,n,r.disableUseStrict);return Object.assign(Object.assign({},e),{source:Object.assign(Object.assign({},e.source),a),process:[...e.process,{cost:Date.now()-t,pluginName:"summer-enhance",action:"transform"}]})}return e}}}exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const babel_script_task_1=require("./script_task/babel_script_task");function default_1(e,s){return{name:"summer-enhance",workerMethods:{doTransform:async(e,s,t,r)=>await(0,babel_script_task_1.babelTransformJS)(e,s)},async transform(e,t,r,{independentRoot:a,isBabelIgnore:n}){const{source:o}=e;if(t.endsWith(".js")&&!o.largeFile&&!n){const t=Date.now(),n=(0,babel_script_task_1.getBabelRoot)(a),c=await this.runWorkerMethod("doTransform",o,r,n,s.disableUseStrict);return Object.assign(Object.assign({},e),{source:Object.assign(Object.assign({},e.source),c),process:[...e.process,{cost:Date.now()-t,pluginName:"summer-enhance",action:"transform"}]})}return e}}}exports.default=default_1;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSWCRoot=exports.MAX_CODE_LENGTH=void 0;const pluginconfig_1=require("../../pluginconfig"),tools_1=require("../../../../../utils/tools"),swc_helper_1=require("../../../../../utils/swc_helper"),swc_task_1=require("../script_task/swc_task"),load_script_task_1=require("../script_task/load_script_task"),babel_script_task_1=require("../script_task/babel_script_task"),minify_script_task_1=require("../script_task/minify_script_task");var config_1=require("../../../../../config/config");function getSWCRoot(e,t){const s=(0,swc_helper_1.getSWCOutputPath)(e.setting);return""===t?s:(0,tools_1.normalizePath)(`${t}/${s}`)}function useCompilerPlugin(e,t){if(!e.setting.useCompilerPlugins)return!1;for(const s of e.setting.useCompilerPlugins){if("string"==typeof s&&s===t)return!0;if(Array.isArray(s)&&"string"==typeof s[0]&&void 0!==s[1]&&s[0]===t)return!0}return!1}function default_1(e,t){const s=e.setting.minified,r=e.setting.enhance||e.setting.es6,o=useCompilerPlugin(e,"typescript"),i=(0,pluginconfig_1.couldUseSWCMode)(e.setting);return{name:"script",resolveExt:o?{js:"ts"}:{},workerMethods:{async doSwcTask(e,t,s){const r=await(0,swc_task_1.swcCompileTask)(e,t,s);return{code:r.code,map:r.map,helpers:r.helpers,resultType:s.resultType}},async doBabelTask(e,t,s){const r=await(0,babel_script_task_1.bableCompile)(e,t,{typescript:s.typescript,enhance:s.enhance,babelRoot:s.babelRoot,disableUseStrict:s.disableUseStrict});if(s.minify){const t=await(0,minify_script_task_1.doCompress)(e,{code:r.code,map:r.map});return{code:t.code,map:t.map,helpers:r.helpers,resultType:s.resultType}}return{code:r.code,map:r.map,helpers:r.helpers,resultType:s.resultType}}},async load(t,s){if(t.endsWith(".js"))return await(0,load_script_task_1.loadScriptFile)(e,t,s,"script")},async compile(c,a,n,p){var l;if(!c.endsWith(".js"))return;const{independentRoot:u,isBabelIgnore:_,resultType:d}=p;if(_)return{targetPath:c,source:n.source,target:{code:n.source.sourceCode,map:n.source.inputMap,helpers:[],resultType:d},process:n.process};const g=Date.now();if(i){const o={swcRoot:getSWCRoot(e,u),minify:s,resultType:d,rc:null===(l=e.setting.swcSetting)||void 0===l?void 0:l.rc,disableUseStrict:t.disableUseStrict,target:r?"es5":"es2022"},i=await this.runWorkerMethod("doSwcTask",a,n.source,o);return{targetPath:c,source:n.source,target:i,process:[...n.process,{cost:Date.now()-g,pluginName:"script",action:"compile",options:o}]}}const f={babelRoot:(0,babel_script_task_1.getBabelRoot)(u),disableUseStrict:t.disableUseStrict,resultType:d,minify:s,enhance:r,typescript:o},m=await this.runWorkerMethod("doBabelTask",a,n.source,f);return{targetPath:c,source:n.source,target:m,process:[...n.process,{cost:Date.now()-g,pluginName:"script",action:"compile",options:f}]}}}}Object.defineProperty(exports,"MAX_CODE_LENGTH",{enumerable:!0,get:function(){return config_1.MAX_CODE_LENGTH}}),exports.getSWCRoot=getSWCRoot,exports.default=default_1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const typescript=()=>require("./typescript"),sass=()=>require("./sass"),less=()=>require("./less"),enhance=()=>require("./enhance"),terser=()=>require("./terser"),javascript=()=>require("./base/javascript"),wxss=()=>require("./base/wxss"),es6module=()=>require("./base/es6module"),minifywxml=()=>require("./minifywxml"),worklet=()=>require("./worklet"),swc=()=>require("./base/swc"),plugins={typescript:typescript,javascript:javascript,es6module:es6module,less:less,sass:sass,wxss:wxss,enhance:enhance,terser:terser,minifywxml:minifywxml,worklet:worklet,swc:swc};exports.default={load:e=>e in plugins?plugins[e]().default:null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const sass=()=>require("./sass"),less=()=>require("./less"),wxss=()=>require("./base/wxss"),minifywxml=()=>require("./minifywxml"),script=()=>require("./filetask/script"),plugins={less:less,sass:sass,wxss:wxss,script:script,minifywxml:minifywxml};exports.default={load:s=>s in plugins?plugins[s]().default:null};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importWxssCssReg=exports.importWxssReg=void 0;const tslib_1=require("tslib"),tools_1=require("../../../../utils/tools"),customError_1=require("../../../../utils/customError"),path_1=tslib_1.__importDefault(require("path")),less=()=>require("less");function default_1(s,e){return{name:"summer-less",resolveExt:{wxss:"less"},async load(t,r){var o;if(r.endsWith(".less")){const a=Date.now(),i=(0,tools_1.pathRelative)(s.projectPath,r);let l=s.getFile("",i).toString();if(i!==s.getTargetPath(s.miniprogramRoot,"app")+".less"&&s.exists(s.miniprogramRoot,"app.less")){const e=(0,tools_1.pathRelative)(s.miniprogramRoot,path_1.default.dirname(i))||".";l=`@import (optional, reference) '${"."===e?".":(0,tools_1.pathRelative)(e,"./")}/app.less';\n${l}`}const p=[];l=l.replace(exports.importWxssReg,(s,e,t)=>(p.push(t),s.replace(t,t+"?css")));try{const i=await require("less").render(l,{sourceMap:{outputSourceFiles:!0},paths:this.rootPath?[this.rootPath]:[],filename:r,globalVars:null!==(o=null==e?void 0:e.globalVars)&&void 0!==o?o:{}}),u=i.css.replace(exports.importWxssCssReg,(s,e,t)=>{const r=t.slice(0,-4);return p.includes(r)?s.replace(t,r):s});if(i.imports.length)for(const s of i.imports)this.addWatchFile(s);let c=void 0;return i.map&&(c=JSON.parse(i.map),c.sources=c.sources.map(e=>path_1.default.posix.relative(s.projectPath,e))),{targetPath:t,source:{sourceCode:u,inputMap:c},process:[{cost:Date.now()-a,pluginName:"summer-less",action:"load"}]}}catch(s){throw(0,customError_1.makeCustomError)(s,customError_1.CustomErrors.SUMMER_PLUGIN_CODE_ERR)}}}}}exports.importWxssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.wxss)\1(?:\s*);/g,exports.importWxssCssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.wxss\?css)\1(?:\s*);/g,exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importWxssCssReg=exports.importWxssReg=void 0;const tslib_1=require("tslib"),tools_1=require("../../../../utils/tools"),customError_1=require("../../../../utils/customError"),path_1=tslib_1.__importDefault(require("path")),less=()=>require("less");function default_1(s,t){return{name:"summer-less",resolveExt:{wxss:"less"},async load(e,o){var r,i,a;if(o.endsWith(".less")){const l=Date.now(),p=(0,tools_1.pathRelative)(s.projectPath,o);let u=s.getFile("",p).toString();if(p!==s.getTargetPath(s.miniprogramRoot,"app")+".less"){const t=(null===(i=null===(r=s.setting)||void 0===r?void 0:r.lessSetting)||void 0===i?void 0:i.commonUseFilePath)||"app.less";if(s.exists(s.miniprogramRoot,t)){const e=(0,tools_1.pathRelative)(s.miniprogramRoot,path_1.default.dirname(p))||".";u=`@import (optional, reference) '${"."===e?".":(0,tools_1.pathRelative)(e,"./")}/${t}';\n${u}`}}const c=[];u=u.replace(exports.importWxssReg,(s,t,e)=>(c.push(e),s.replace(e,e+"?css")));try{const r=await require("less").render(u,{sourceMap:{outputSourceFiles:!0},paths:this.rootPath?[this.rootPath]:[],filename:o,globalVars:null!==(a=null==t?void 0:t.globalVars)&&void 0!==a?a:{}}),i=r.css.replace(exports.importWxssCssReg,(s,t,e)=>{const o=e.slice(0,-4);return c.includes(o)?s.replace(e,o):s});if(r.imports.length)for(const s of r.imports)this.addWatchFile(s);let p=void 0;return r.map&&(p=JSON.parse(r.map),p.sources=p.sources.map(t=>path_1.default.posix.relative(s.projectPath,t))),{targetPath:e,source:{sourceCode:i,inputMap:p},process:[{cost:Date.now()-l,pluginName:"summer-less",action:"load"}]}}catch(s){throw(0,customError_1.makeCustomError)(s,customError_1.CustomErrors.SUMMER_PLUGIN_CODE_ERR)}}}}}exports.importWxssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.wxss)\1(?:\s*);/g,exports.importWxssCssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.wxss\?css)\1(?:\s*);/g,exports.default=default_1;