miniprogram-ci 2.1.29 → 2.1.30

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 (55) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +2 -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/types/devtools.d.ts +9 -0
  18. package/dist/@types/types/summer.d.ts +7 -2
  19. package/dist/@types/utils/env.d.ts +1 -0
  20. package/dist/@types/utils/helper_util.d.ts +1 -1
  21. package/dist/@types/utils/packOptionsHelper.d.ts +1 -0
  22. package/dist/@types/utils/subprocess/processManager.d.ts +1 -1
  23. package/dist/ci/android-miniapp-toolkit/dist/index.js +1 -1
  24. package/dist/ci/build-apk.js +1 -1
  25. package/dist/config/config.js +1 -1
  26. package/dist/modules/corecompiler/original/json/game.js +1 -1
  27. package/dist/modules/corecompiler/originalCompiler.js +1 -1
  28. package/dist/modules/corecompiler/processHandler.js +1 -1
  29. package/dist/modules/corecompiler/summer/graph/basegraph.js +1 -1
  30. package/dist/modules/corecompiler/summer/module.js +1 -1
  31. package/dist/modules/corecompiler/summer/pluginconfig.js +1 -1
  32. package/dist/modules/corecompiler/summer/plugins/base/es6module.js +1 -1
  33. package/dist/modules/corecompiler/summer/plugins/base/javascript.js +1 -1
  34. package/dist/modules/corecompiler/summer/plugins/base/swc.js +1 -1
  35. package/dist/modules/corecompiler/summer/plugins/enhance.js +1 -1
  36. package/dist/modules/corecompiler/summer/plugins/filetask/script.js +1 -0
  37. package/dist/modules/corecompiler/summer/plugins/index.js +1 -1
  38. package/dist/modules/corecompiler/summer/plugins/less.js +1 -1
  39. package/dist/modules/corecompiler/summer/plugins/sass.js +1 -1
  40. package/dist/modules/corecompiler/summer/plugins/script_task/babel_script_task.js +1 -0
  41. package/dist/modules/corecompiler/summer/plugins/script_task/load_script_task.js +1 -0
  42. package/dist/modules/corecompiler/summer/plugins/script_task/minify_script_task.js +1 -0
  43. package/dist/modules/corecompiler/summer/plugins/script_task/swc_task.js +1 -0
  44. package/dist/modules/corecompiler/summer/plugins/terser.js +1 -1
  45. package/dist/modules/corecompiler/summer/plugins/typescript.js +1 -1
  46. package/dist/modules/corecompiler/summer/summer.js +1 -1
  47. package/dist/modules/corecompiler/summerCompiler.js +1 -1
  48. package/dist/modules/createSummer.js +1 -1
  49. package/dist/modules/nativecompiler/ios/buildCloud.js +1 -1
  50. package/dist/utils/cosUpload.js +1 -1
  51. package/dist/utils/env.js +1 -1
  52. package/dist/utils/packOptionsHelper.js +1 -1
  53. package/dist/utils/subprocess/processManager.js +1 -1
  54. package/dist/utils/subprocess/processService.js +1 -1
  55. package/package.json +1 -1
@@ -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.30",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.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;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.random=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../../../utils/tools"),customError_1=require("../../../../utils/customError"),debug_1=require("../../../../utils/debug");let runInMainProcess=void 0;const sass=async()=>{if(void 0===runInMainProcess&&(runInMainProcess=await(0,debug_1.shouldRunInMainProcess)()),runInMainProcess){process.versions.electron="0.54.0";const s=require("sass");return delete process.versions.electron,s}return require("sass")};function random(){return(0,tools_1.generateMD5)(`${Math.random()}${Date.now()}`)}exports.random=random;const importWxssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.wxss)\1(?:\s*);/g,importCssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.css)\1(?:\s*);/g;async function sassRender(s,e){if("undefined"!=typeof WEBIDE_WEBPECK_DEFINE_PLUGIN);else{(await sass()).render(s,e)}}function default_1(s){return{name:"summer-sass",resolveExt:{wxss:["sass","scss"]},async load(e,t){if(t.endsWith(".scss")||t.endsWith(".sass")){const o=(0,tools_1.pathRelative)(s.projectPath,t);let r=s.getFile("",o).toString();const a=s.getTargetPath(s.miniprogramRoot,"global");if(o!==a+".scss"&&o!==a+".sass"){let e=path_1.default.extname(o);const t=(0,tools_1.pathRelative)(s.miniprogramRoot,path_1.default.dirname(o))||".";s.exists(s.miniprogramRoot,"global"+e)||(e=".sass"===e?".scss":".sass"),s.exists(s.miniprogramRoot,"global"+e)&&(r=".sass"===e?`@use '${"."===t?".":(0,tools_1.pathRelative)(t,"./")}/global${e}'\n${r}`:`@use '${"."===t?".":(0,tools_1.pathRelative)(t,"./")}/global${e}';\n${r}`)}const n=[];r=r.replace(importWxssReg,(s,e,t)=>(n.push(t),s.replace(t,t.slice(0,-4)+"css")));const i=path_1.default.posix.dirname((0,tools_1.pathRelative)(s.projectPath,t));return new Promise((s,o)=>{const a=Date.now();sassRender({file:t,data:r,sourceMap:!0,sourceMapContents:!0,omitSourceMapUrl:!0,outFile:t.slice(0,-5)+".wxss",includePaths:this.rootPath?[this.rootPath]:[]},(r,l)=>{if(r){const s=(0,customError_1.makeCustomError)(r,customError_1.CustomErrors.SUMMER_PLUGIN_CODE_ERR);return void o(s)}if(!l)return void o(new Error("no result"));const u=l.css.toString("utf-8").replace(importCssReg,(s,e,t)=>{const o=t.slice(0,-3)+"wxss";return n.includes(o)?s.replace(t,o):s});if(l.stats.includedFiles.length>0)for(const s of l.stats.includedFiles)s!==t&&this.addWatchFile(s);const c=l.map?JSON.parse(l.map.toString("utf-8")):void 0;c&&(c.sourceRoot=i),s({targetPath:e,source:{sourceCode:u,inputMap:c},process:[{cost:Date.now()-a,pluginName:"summer-sass",action:"load"}]})})})}}}}exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.random=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../../../utils/tools"),customError_1=require("../../../../utils/customError"),debug_1=require("../../../../utils/debug");let runInMainProcess=void 0;const sass=async()=>{if(void 0===runInMainProcess&&(runInMainProcess=await(0,debug_1.shouldRunInMainProcess)()),runInMainProcess){process.versions.electron="0.54.0";const s=require("sass");return delete process.versions.electron,s}return require("sass")};function random(){return(0,tools_1.generateMD5)(`${Math.random()}${Date.now()}`)}exports.random=random;const importWxssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.wxss)\1(?:\s*);/g,importCssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.css)\1(?:\s*);/g;async function sassRender(s,e){if("undefined"!=typeof WEBIDE_WEBPECK_DEFINE_PLUGIN);else{(await sass()).render(s,e)}}function default_1(s){return{name:"summer-sass",resolveExt:{wxss:["sass","scss"]},async load(e,t){var o,r,a,i;if(t.endsWith(".scss")||t.endsWith(".sass")){const n=(0,tools_1.pathRelative)(s.projectPath,t);let l=s.getFile("",n).toString();const u=s.getTargetPath(s.miniprogramRoot,"global");if(n!==u+".scss"&&n!==u+".sass"){const e=path_1.default.extname(n),t=(null===(r=null===(o=s.setting)||void 0===o?void 0:o.sassSetting)||void 0===r?void 0:r.sassCommonUseFilePath)||"global.sass",u=(null===(i=null===(a=s.setting)||void 0===a?void 0:a.sassSetting)||void 0===i?void 0:i.scssCommonUseFilePath)||"global.scss";let c=".sass"===e?t:u;const d=(0,tools_1.pathRelative)(s.miniprogramRoot,path_1.default.dirname(n))||".";s.exists(s.miniprogramRoot,c)||(c=".sass"===e?u:t),s.exists(s.miniprogramRoot,c)&&(l=".sass"===e?`@use '${"."===d?".":(0,tools_1.pathRelative)(d,"./")}/${c}'\n${l}`:`@use '${"."===d?".":(0,tools_1.pathRelative)(d,"./")}/${c}';\n${l}`)}const c=[];l=l.replace(importWxssReg,(s,e,t)=>(c.push(t),s.replace(t,t.slice(0,-4)+"css")));const d=path_1.default.posix.dirname((0,tools_1.pathRelative)(s.projectPath,t));return new Promise((s,o)=>{const r=Date.now();sassRender({file:t,data:l,sourceMap:!0,sourceMapContents:!0,omitSourceMapUrl:!0,outFile:t.slice(0,-5)+".wxss",includePaths:this.rootPath?[this.rootPath]:[]},(a,i)=>{if(a){const s=(0,customError_1.makeCustomError)(a,customError_1.CustomErrors.SUMMER_PLUGIN_CODE_ERR);return void o(s)}if(!i)return void o(new Error("no result"));const n=i.css.toString("utf-8").replace(importCssReg,(s,e,t)=>{const o=t.slice(0,-3)+"wxss";return c.includes(o)?s.replace(t,o):s});if(i.stats.includedFiles.length>0)for(const s of i.stats.includedFiles)s!==t&&this.addWatchFile(s);const l=i.map?JSON.parse(i.map.toString("utf-8")):void 0;l&&(l.sourceRoot=d),s({targetPath:e,source:{sourceCode:n,inputMap:l},process:[{cost:Date.now()-r,pluginName:"summer-sass",action:"load"}]})})})}}}}exports.default=default_1;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.bableCompile=exports.babelTransformTS=exports.transformES6ModuleAndGenCode=exports.babelTransformJS=exports.getBabelRoot=void 0;const config_1=require("../../../../../config/config"),babel_helper_1=require("../../../../../utils/babel_helper"),tools_1=require("../../../../../utils/tools"),customError_1=require("../../../../../utils/customError"),_transformRuntimeCustom=()=>require("../../../../../utils/babel_transform_plugin"),_pluginTransformRuntime=()=>require("@babel/plugin-transform-runtime"),_pluginTransformWorklet=()=>require("../../../../../utils/babel_plugin_worklet"),_pluginTransformModulesCommonjs=()=>require("@babel/plugin-transform-modules-commonjs"),babel7=()=>require("@babel/core"),_presetEnv=()=>require("@babel/preset-env"),_pluginTransformTypescript=()=>require("@babel/plugin-transform-typescript"),pluginReplaceTsExportAssignment=e=>{const r=e.template("\n module.exports = ASSIGNMENT;\n ");return{name:"replace-ts-export-assignment",visitor:{TSExportAssignment(e){e.replaceWith(r({ASSIGNMENT:e.node.expression}))}}}},pluginReplaceTsImportEqualsDeclaration=e=>{const r=e.template("\n const ID = require(SOURCE);\n ");return{name:"replace-ts-import-equals-declaration",visitor:{TSImportEqualsDeclaration(e){e.replaceWith(r({ID:e.node.id,SOURCE:e.node.moduleReference.expression}))}}}};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([_pluginTransformWorklet()]),r}function getCommonPresets(){return[[require("@babel/preset-env"),{targets:{chrome:53,ios:8},modules:!1,include:["@babel/plugin-transform-computed-properties"]}]]}function getTSTransformPluginsList(){return[[pluginReplaceTsImportEqualsDeclaration,{}],[pluginReplaceTsExportAssignment,{}],[require("@babel/plugin-transform-typescript"),{}]]}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")}async function babelTransformJS(e,r){const o=babel7(),t=e.sourceCode.includes('"worklet"')||e.sourceCode.includes("'worklet'");let s;try{const n={babelrc:!1,sourceFileName:r,configFile:!1,presets:getCommonPresets(),plugins:getEnhancePluginsList({supportWorklet:t}),inputSourceMap:!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");s=await o.transformFromAstAsync(e.astInfo.ast,e.sourceCode,n)}else{if(null===e.sourceCode)throw new Error("source.sourceCode is null");s=await babel7().transformAsync(e.sourceCode,n)}}catch(e){console.error(e,e.stack);const o=`file: ${r}\n ${e.message}`,t=new Error(o);throw t.code=config_1.BABEL_TRANS_JS_ERR,t}return{sourceCode:e.sourceCode,inputMap:e.inputMap,astInfo:{ast:s.ast,type:config_1.AstType.Babel}}}async function transformES6ModuleAndGenCode(e,r,o){const t=o.disableUseStrict||/^\s*\/\/\s?use strict disable;/i.test(r.sourceCode||"");let s;try{const o={babelrc:!1,sourceFileName:e,configFile:!1,plugins:getES6ModulePluginsList(t),filename:e,sourceMaps:!0,inputSourceMap:r.inputMap,code:!0,cloneInputAst:!0},n=babel7();if(!r.astInfo)throw new Error("source.astInfo is not exist");if(r.astInfo.type!==config_1.AstType.Babel)throw new Error("ast type is not babel");s=await n.transformFromAstAsync(r.astInfo.ast,r.sourceCode,o)}catch(r){throw r.code=config_1.BABEL_TRANS_JS_ERR,r.message=`file: ${e}\n ${r.message}`,r.path=e,r}if(!s)throw new Error("no trans result for callPostEnhance");let n=s.code;const l=s.map;t&&(n=n.replace(/^"use strict";/,""));const a=(0,babel_helper_1.collectBabelHelpers)(r.sourceCode),i=(0,babel_helper_1.replaceBabelHelpers)(n,a,e,o.babelRoot);return{code:i.transformCode,map:l,helpers:i.helpers}}async function babelTransformTS(e,r){let o;console.log("[backend] summer-typescript workerMethod");try{o=await babel7().transformAsync(e.sourceCode,{babelrc:!1,plugins:getTSTransformPluginsList(),sourceFileName:r,sourceMaps:!1,ast:!0,configFile:!1,code:!1})}catch(e){throw(0,customError_1.makeCustomError)(e,customError_1.CustomErrors.SUMMER_PLUGIN_CODE_ERR,r)}return{sourceCode:e.sourceCode,inputMap:e.inputMap,astInfo:{ast:o.ast,type:config_1.AstType.Babel}}}async function bableCompile(e,r,o){const t=babel7(),s=r.sourceCode.includes('"worklet"')||r.sourceCode.includes("'worklet'"),n=o.disableUseStrict||/^\s*\/\/\s?use strict disable;/i.test(r.sourceCode||""),l=[];e.endsWith(".ts")&&o.typescript&&l.push(...getTSTransformPluginsList()),s&&l.push([_pluginTransformWorklet()]),o.enhance&&l.push(...getEnhancePluginsList({})),l.push(...getES6ModulePluginsList(n));const a={babelrc:!1,sourceFileName:e,filename:e,configFile:!1,presets:o.enhance?getCommonPresets():[],plugins:l,inputSourceMap:r.inputMap,sourceMaps:!0,code:!0,ast:!1,cloneInputAst:!1};let i;try{i=await t.transformAsync(r.sourceCode,a)}catch(r){console.error(r,r.stack);const o=`file: ${e}\n ${r.message}`,t=new Error(o);throw t.code=config_1.BABEL_TRANS_JS_ERR,t}if(!i||!i.code)throw new Error("no trans result for bableCompile");let u=i.code;const c=i.map;n&&(u=u.replace(/^"use strict";/,""));const p=(0,babel_helper_1.collectBabelHelpers)(r.sourceCode),b=(0,babel_helper_1.replaceBabelHelpers)(u,p,e,o.babelRoot);return{code:b.transformCode,map:c,helpers:b.helpers}}exports.getBabelRoot=getBabelRoot,exports.babelTransformJS=babelTransformJS,exports.transformES6ModuleAndGenCode=transformES6ModuleAndGenCode,exports.babelTransformTS=babelTransformTS,exports.bableCompile=bableCompile;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.loadScriptFile=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),config_1=require("../../../../../config/config"),inputsourcemap_1=require("../../utils/inputsourcemap");async function loadScriptFile(t,e,i,o){const r=Date.now(),a=path_1.default.relative(t.projectPath,i),l=t.getFile("",a).toString(),u=t.stat("",a),n=await(0,inputsourcemap_1.tryGetInputSourceMap)(l,i);return{targetPath:e,source:{sourceCode:l,inputMap:null!=n?n:void 0,astInfo:void 0,largeFile:l.length>=config_1.MAX_CODE_LENGTH,mtime:null==u?void 0:u.mtimeMs},process:[{cost:Date.now()-r,pluginName:o,action:"load"}]}}exports.loadScriptFile=loadScriptFile;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.doCompress=void 0;const config_1=require("../../../../../config/config"),customError_1=require("../../../../../utils/customError"),terser=()=>require("terser"),babelCodeFrame=()=>require("babel-code-frame");async function doCompress(e,r){const{code:o,map:s}=r,c=s?{includeSources:!0,content:"string"==typeof s?JSON.parse(s):s,filename:e}:{includeSources:!0,content:void 0,filename:e},t=require("terser").minify(o,{toplevel:!0,compress:{drop_console:!1,drop_debugger:!1},sourceMap:c});if(t.error){const r=t.error,s=`file: ${e}\n ${t.error.message}\n ${require("babel-code-frame")(o,r.line,r.col>0?r.col:1)}`;throw(0,customError_1.makeCustomError)(s,config_1.UGLIFY_JS_ERR,e)}return{code:t.code,map:t.map}}exports.doCompress=doCompress;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.swcCompileTask=void 0;const swc_helper_1=require("../../../../../utils/swc_helper"),swc=()=>require("@swc/core");async function swcCompileTask(e,s,r){var o,t;const i=r.disableUseStrict||/^\s*\/\/\s?use strict disable;/i.test(s.sourceCode||""),{swcRoot:c}=r,p=await require("@swc/core").transform(s.sourceCode,{jsc:{parser:Object.assign(Object.assign({},null===(o=r.rc)||void 0===o?void 0:o.parser),{syntax:e.endsWith("ts")?"typescript":"ecmascript"}),target:r.target,externalHelpers:!0,loose:!1,minify:{compress:{drop_console:!1,drop_debugger:!1},toplevel:!0}},module:Object.assign({type:"commonjs",strictMode:!i,noInterop:!0,allowTopLevelThis:i},null===(t=r.rc)||void 0===t?void 0:t.module),inputSourceMap:s.inputMap?JSON.stringify(s.inputMap):void 0,sourceMaps:!0,filename:e,minify:"dev"!==r.resultType&&r.minify}),a=(0,swc_helper_1.replaceSWCHelpers)(p.code,e,c);return{code:a.transformCode,map:p.map?JSON.parse(p.map):void 0,helpers:a.helpers}}exports.swcCompileTask=swcCompileTask;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const config_1=require("../../../../config/config"),customError_1=require("../../../../utils/customError"),terser=()=>require("terser"),babelCodeFrame=()=>require("babel-code-frame");function default_1(e){const r=e.setting.minified;return{name:"summer-terser",workerMethods:{doCompress:async(e,r)=>require("terser").minify(e,{toplevel:!0,compress:{drop_console:!1,drop_debugger:!1},sourceMap:r})},async compress(e,o){const t=e.targetPath;if(!r||"dev"===o.resultType||!t.endsWith(".js"))return e;const s=Date.now(),{map:n}=e.target,c=n?{includeSources:!0,content:"string"==typeof n?JSON.parse(n):n,filename:t}:{includeSources:!0,content:void 0,filename:t},i=e.target.code,a=await this.runWorkerMethod("doCompress",i,c);if(a.error){const e=a.error,r=`file: ${t}\n ${a.error.message}\n ${require("babel-code-frame")(i,e.line,e.col>0?e.col:1)}`;throw(0,customError_1.makeCustomError)(r,config_1.UGLIFY_JS_ERR,t)}return Object.assign(Object.assign({},e),{target:Object.assign(Object.assign({},e.target),{code:a.code,map:a.map}),process:[...e.process,{cost:Date.now()-s,pluginName:"summer-terser",action:"compress"}]})}}}exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const minify_script_task_1=require("./script_task/minify_script_task");function default_1(e){const t=e.setting.minified;return{name:"summer-terser",workerMethods:{doCompress:minify_script_task_1.doCompress},async compress(e,s){const r=e.targetPath;if(!t||"dev"===s.resultType||!r.endsWith(".js"))return e;const o=Date.now(),a=await this.runWorkerMethod("doCompress",r,{code:e.target.code,map:e.target.map});return Object.assign(Object.assign({},e),{target:Object.assign(Object.assign({},e.target),{code:a.code,map:a.map}),process:[...e.process,{cost:Date.now()-o,pluginName:"summer-terser",action:"compress"}]})}}}exports.default=default_1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),customError_1=require("../../../../utils/customError"),config_1=require("../../../../config/config"),pluginconfig_1=require("../pluginconfig"),babel7=()=>require("@babel/core"),pluginTransformTypescript=()=>require("@babel/plugin-transform-typescript"),pluginReplaceTsExportAssignment=e=>{const t=e.template("\n module.exports = ASSIGNMENT;\n ");return{name:"replace-ts-export-assignment",visitor:{TSExportAssignment(e){e.replaceWith(t({ASSIGNMENT:e.node.expression}))}}}},pluginReplaceTsImportEqualsDeclaration=e=>{const t=e.template("\n const ID = require(SOURCE);\n ");return{name:"replace-ts-import-equals-declaration",visitor:{TSImportEqualsDeclaration(e){e.replaceWith(t({ID:e.node.id,SOURCE:e.node.moduleReference.expression}))}}}};function default_1(e){return{name:"summer-typescript",resolveExt:{js:"ts"},workerMethods:{doLoad(e,t,r){let o;console.log("[backend] summer-typescript workerMethod");try{o=require("@babel/core").transform(e,{babelrc:!1,plugins:[[pluginReplaceTsImportEqualsDeclaration,{}],[pluginReplaceTsExportAssignment,{}],[require("@babel/plugin-transform-typescript"),{}]],sourceFileName:t,sourceMaps:!1,ast:!0,configFile:!1,code:!1})}catch(e){throw(0,customError_1.makeCustomError)(e,customError_1.CustomErrors.SUMMER_PLUGIN_CODE_ERR,t)}return{sourceCode:e,inputMap:r,astInfo:{ast:o.ast,type:config_1.AstType.Babel}}}},async load(t,r){if(!(0,pluginconfig_1.couldUseSWCMode)(e.setting)&&r.endsWith(".ts")){const o=Date.now(),s=path_1.default.relative(e.projectPath,r),i=e.getFile("",s).toString(),n=e.stat("",s),a=await this.runWorkerMethod("doLoad",i,r);return{targetPath:t,source:Object.assign(Object.assign({},a),{mtime:null==n?void 0:n.mtimeMs}),process:[{cost:Date.now()-o,pluginName:"summer-typescript",action:"load"}]}}}}}exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),pluginconfig_1=require("../pluginconfig"),babel_script_task_1=require("./script_task/babel_script_task");function default_1(t){return{name:"summer-typescript",resolveExt:{js:"ts"},workerMethods:{async doLoad(t,e,s){const r={sourceCode:t,inputMap:s};return await(0,babel_script_task_1.babelTransformTS)(r,e)}},async load(e,s){if(!(0,pluginconfig_1.couldUseSWCMode)(t.setting)&&s.endsWith(".ts")){const r=Date.now(),a=path_1.default.relative(t.projectPath,s),i=t.getFile("",a).toString(),o=t.stat("",a),n=await this.runWorkerMethod("doLoad",i,s);return{targetPath:e,source:Object.assign(Object.assign({},n),{mtime:null==o?void 0:o.mtimeMs}),process:[{cost:Date.now()-r,pluginName:"summer-typescript",action:"load"}]}}}}}exports.default=default_1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=void 0;const tslib_1=require("tslib"),nodePath=tslib_1.__importStar(require("path")),lodash_1=require("lodash"),reactiveCache_1=require("../original/json/reactiveCache"),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),tools_1=require("../../../utils/tools"),plugingraph_1=require("./graph/plugingraph"),gameplugingraph_1=require("./graph/gameplugingraph"),appgraph_1=require("./graph/appgraph"),initPlugin_1=require("./initPlugin"),pluginDriver_1=require("./pluginDriver"),persistCache_1=tslib_1.__importDefault(require("./persistCache")),babel_helper_1=require("../../../utils/babel_helper"),config_1=require("../../../config/config"),gamegraph_1=require("./graph/gamegraph");function initProxyProjectForJSON(i){let e={};function t(t,r){const o=i.stat(t,r);if(o)return o;const s=i.getTargetPath(t,r);for(const i in e)if(s.startsWith(i))return e[i].stat(nodePath.posix.relative(i,s))}const r=new Proxy(i,{get:(i,e,r)=>"stat"===e?t:Reflect.get(i,e,r)});return r.addResolver=i=>{(0,reactiveCache_1.cleanReactiveCache)(),e[i.root]=i},r.removeResolver=i=>{(0,reactiveCache_1.cleanReactiveCache)(),delete e[i.root]},r.clearResolver=()=>{e={},(0,reactiveCache_1.cleanReactiveCache)()},r}function getCacheBaseKey(i){const e=["es6","minified","postcss","uglifyFileName","compileWorklet","enhance","swc","minifyWXSS","minifyWXML","disableUseStrict"],t=[i.miniprogramRoot,i.pluginRoot,i.compileType,i.projectArchitecture,...i.summerPlugins,(0,babel_helper_1.getBabelHelperVersion)(),JSON.stringify(i.setting.swcSetting),JSON.stringify(i.setting.minifyWXMLSetting),JSON.stringify(i.setting.babelSetting)];for(const r of e)t.push(i.setting[r]?"1":"0");return(0,tools_1.generateMD5)(t.join("|"))}class SummerCompiler{constructor(i,e,t){this.project=i,this.cachePath=e,this.devtoolsProject=t,this.proxyProject=initProxyProjectForJSON(i),this.projectPath=i.projectPath,this.persistCache=new persistCache_1.default(this.proxyProject,e,getCacheBaseKey(t)),this.initPlugins(),this.initAppGraph(),this.isPluginType(i.type)&&this.initPluginGraph()}getBabelSetting(){return this.devtoolsProject.setting.babelSetting}getSWCSetting(){return this.devtoolsProject.setting.swcSetting}initPlugins(){this.plugins=this.devtoolsProject.summerPlugins.map(i=>{let e,t={};return"string"==typeof i?e=i:(e=i[0],t=i[1]),(0,initPlugin_1.initPlugin)(e,this.project,t)})}isGameType(i){return i===config_1.COMPILE_TYPE.miniGame||i===config_1.COMPILE_TYPE.miniGamePlugin}isPluginType(i){return i===config_1.COMPILE_TYPE.miniProgramPlugin||i===config_1.COMPILE_TYPE.miniGamePlugin}initAppGraph(){var i;null===(i=this.appGraph)||void 0===i||i.destroy(),this.isGameType(this.project.type)?this.appGraph=new gamegraph_1.GameGraph({type:"minigame",root:this.project.miniprogramRoot,persistCache:this.persistCache,plugins:this.plugins,compiler:this}):this.appGraph=new appgraph_1.AppGraph({type:"miniprogram",root:this.project.miniprogramRoot,persistCache:this.persistCache,plugins:this.plugins,compiler:this})}initPluginGraph(){var i;null===(i=this.pluginGraph)||void 0===i||i.destroy(),this.devtoolsProject.compileType===config_1.COMPILE_TYPE.miniGamePlugin?this.pluginGraph=new gameplugingraph_1.GamePluginGraph({type:"plugin",root:this.project.pluginRoot,persistCache:this.persistCache,plugins:this.plugins,compiler:this}):this.pluginGraph=new plugingraph_1.PluginGraph({type:"plugin",root:this.project.pluginRoot,persistCache:this.persistCache,plugins:this.plugins,compiler:this})}updateOptions(i){var e;const t=this.devtoolsProject;if(this.devtoolsProject=i,this.persistCache.updateBaseCacheKey(getCacheBaseKey(i)),!(0,lodash_1.isEqual)(i.setting,t.setting)||!(0,lodash_1.isEqual)(this.devtoolsProject.summerPlugins,t.summerPlugins))return this.project.setting=i.setting,this.initPlugins(),this.initAppGraph(),void("miniProgramPlugin"===this.devtoolsProject.compileType&&this.initPluginGraph());this.devtoolsProject.compileType!==t.compileType&&("miniProgramPlugin"===this.devtoolsProject.compileType?this.initPluginGraph():(null===(e=this.pluginGraph)||void 0===e||e.destroy(),this.pluginGraph=void 0)),this.appGraph.root!==this.project.miniprogramRoot&&this.initAppGraph(),this.pluginGraph&&this.pluginGraph.root!==this.project.pluginRoot&&this.initPluginGraph()}destroy(){var i,e;null===(i=this.appGraph)||void 0===i||i.destroy(),null===(e=this.pluginGraph)||void 0===e||e.destroy(),this.proxyProject.clearResolver()}getStatus(){const i=(0,pluginDriver_1.genResovleExtConf)(this.plugins),e={},t=new Set;for(const r of["json","js","wxml","wxss","wxs"])e[r]={exts:i[r].reverse()},i[r].forEach(i=>{t.add(i)});return{codeExts:Array.from(t.keys()),codeConf:e}}clearCache(){var i,e,t;null===(e=(i=this.project).clearCache)||void 0===e||e.call(i),this.appGraph.clearCache(),null===(t=this.pluginGraph)||void 0===t||t.clearCache(),this.persistCache.clean(),(0,reactiveCache_1.cleanReactiveCache)()}async getPackageFiles({graphId:i,root:e},t){var r;return this.isPluginType(i)?await(null===(r=this.pluginGraph)||void 0===r?void 0:r.getPackageFile()):await this.appGraph.getPackageFile(e)}async getConf({graphId:i},e){if(i===config_1.COMPILE_TYPE.miniProgram||i===config_1.COMPILE_TYPE.miniGame){return await this.appGraph.getConf(e)}if(this.isPluginType(i)){return await this.pluginGraph.getConf(e)}throw new Error("no support getConf for "+i)}async getCode(i,e){if(i.graphId===config_1.COMPILE_TYPE.miniProgram||i.graphId===config_1.COMPILE_TYPE.miniGame){return await this.appGraph.getDevCode(e,{package:i.package})}if(this.isPluginType(i.graphId)){return await this.pluginGraph.getDevCode(e)}throw new Error("no support getCode for "+i.graphId)}async getDevCodeByFileList(i,e){if(i.graphId===config_1.COMPILE_TYPE.miniProgram||i.graphId===config_1.COMPILE_TYPE.miniGame){return await this.appGraph.getDevCodeByFileList(e,{fileList:i.fileList})}if(this.isPluginType(i.graphId)){return await this.pluginGraph.getDevCodeByFileList(e,{fileList:i.fileList})}throw new Error("no support getDevCodeByFileList for "+i.graphId)}async getLocalFileList(i){if(i===config_1.COMPILE_TYPE.miniProgram||i===config_1.COMPILE_TYPE.miniGame)return await this.appGraph.getLocalFileList();if(this.isPluginType(i))return await this.pluginGraph.getLocalFileList();throw new Error("no support getCode for "+i)}async compileSingleCode(i,e){if(i.graphId===config_1.COMPILE_TYPE.miniProgram||i.graphId===config_1.COMPILE_TYPE.miniGame){return await this.appGraph.compileSingleCode(i.filePath,i.sourceCode)}if(this.isPluginType(i.graphId)){return await this.pluginGraph.compileSingleCode(i.filePath,i.sourceCode)}throw new Error("no support getCode for "+i.graphId)}async compileNewLogic(i,e){const t=await e.run(this.isGameType(this.project.type)?locales_1.default.config.SUMMER_COMPILE_MINIGAME.format():locales_1.default.config.SUMMER_COMPILE_MINIPROGRAM.format(),()=>this.appGraph.compileWithFileList(i,e));if(this.project.type===config_1.COMPILE_TYPE.miniProgram||this.project.type===config_1.COMPILE_TYPE.miniGame)return{app:t};if(this.isPluginType(this.project.type)){return{app:t,plugin:await e.run(locales_1.default.config.SUMMER_COMPILE_PLUGIN.format(),()=>this.pluginGraph.compile(i,e))}}throw new Error("no support compile for "+this.project.type)}async compile(i,e){const t=await e.run(this.isGameType(this.project.type)?locales_1.default.config.SUMMER_COMPILE_MINIGAME.format():locales_1.default.config.SUMMER_COMPILE_MINIPROGRAM.format(),()=>this.appGraph.compile(i,e));if(this.project.type===config_1.COMPILE_TYPE.miniProgram||this.project.type===config_1.COMPILE_TYPE.miniGame)return t["project.config.json"]=JSON.stringify({miniprogramRoot:"",__compileDebugInfo__:{useSummer:!0}}),t;if(this.isPluginType(this.project.type)){const r={},o=await e.run(locales_1.default.config.SUMMER_COMPILE_PLUGIN.format(),()=>this.pluginGraph.compile(i,e));return Object.keys(t).forEach(i=>{r[nodePath.posix.join(this.project.miniprogramRoot,i)]=t[i]}),Object.keys(o).forEach(i=>{r[nodePath.posix.join(this.project.pluginRoot,i)]=o[i]}),r["project.config.json"]=JSON.stringify({miniprogramRoot:this.project.miniprogramRoot,pluginRoot:this.project.pluginRoot,__compileDebugInfo__:{useSummer:!0}}),r}throw new Error("no support compile for "+this.project.type)}}exports.SummerCompiler=SummerCompiler;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=void 0;const tslib_1=require("tslib"),nodePath=tslib_1.__importStar(require("path")),lodash_1=require("lodash"),reactiveCache_1=require("../original/json/reactiveCache"),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),tools_1=require("../../../utils/tools"),plugingraph_1=require("./graph/plugingraph"),gameplugingraph_1=require("./graph/gameplugingraph"),appgraph_1=require("./graph/appgraph"),initPlugin_1=require("./initPlugin"),pluginDriver_1=require("./pluginDriver"),persistCache_1=tslib_1.__importDefault(require("./persistCache")),babel_helper_1=require("../../../utils/babel_helper"),config_1=require("../../../config/config"),gamegraph_1=require("./graph/gamegraph");function initProxyProjectForJSON(i){let e={};function t(t,r){const o=i.stat(t,r);if(o)return o;const s=i.getTargetPath(t,r);for(const i in e)if(s.startsWith(i))return e[i].stat(nodePath.posix.relative(i,s))}const r=new Proxy(i,{get:(i,e,r)=>"stat"===e?t:Reflect.get(i,e,r)});return r.addResolver=i=>{(0,reactiveCache_1.cleanReactiveCache)(),e[i.root]=i},r.removeResolver=i=>{(0,reactiveCache_1.cleanReactiveCache)(),delete e[i.root]},r.clearResolver=()=>{e={},(0,reactiveCache_1.cleanReactiveCache)()},r}function getCacheBaseKey(i){const e=["es6","minified","postcss","uglifyFileName","compileWorklet","enhance","swc","minifyWXSS","minifyWXML","disableUseStrict"],t=[i.miniprogramRoot,i.pluginRoot,i.compileType,i.projectArchitecture,...i.summerPlugins,(0,babel_helper_1.getBabelHelperVersion)(),JSON.stringify(i.setting.swcSetting),JSON.stringify(i.setting.sassSetting),JSON.stringify(i.setting.lessSetting),JSON.stringify(i.setting.minifyWXMLSetting),JSON.stringify(i.setting.babelSetting)];for(const r of e)t.push(i.setting[r]?"1":"0");return(0,tools_1.generateMD5)(t.join("|"))}class SummerCompiler{constructor(i,e,t){this.project=i,this.cachePath=e,this.devtoolsProject=t,this.proxyProject=initProxyProjectForJSON(i),this.projectPath=i.projectPath,this.persistCache=new persistCache_1.default(this.proxyProject,e,getCacheBaseKey(t)),this.initPlugins(),this.initAppGraph(),this.isPluginType(i.type)&&this.initPluginGraph()}getBabelSetting(){return this.devtoolsProject.setting.babelSetting}getSWCSetting(){return this.devtoolsProject.setting.swcSetting}initPlugins(){this.plugins=this.devtoolsProject.summerPlugins.map(i=>{let e,t={};return"string"==typeof i?e=i:(e=i[0],t=i[1]),(0,initPlugin_1.initPlugin)(e,this.project,t)})}isGameType(i){return i===config_1.COMPILE_TYPE.miniGame||i===config_1.COMPILE_TYPE.miniGamePlugin}isPluginType(i){return i===config_1.COMPILE_TYPE.miniProgramPlugin||i===config_1.COMPILE_TYPE.miniGamePlugin}initAppGraph(){var i;null===(i=this.appGraph)||void 0===i||i.destroy(),this.isGameType(this.project.type)?this.appGraph=new gamegraph_1.GameGraph({type:"minigame",root:this.project.miniprogramRoot,persistCache:this.persistCache,plugins:this.plugins,compiler:this}):this.appGraph=new appgraph_1.AppGraph({type:"miniprogram",root:this.project.miniprogramRoot,persistCache:this.persistCache,plugins:this.plugins,compiler:this})}initPluginGraph(){var i;null===(i=this.pluginGraph)||void 0===i||i.destroy(),this.devtoolsProject.compileType===config_1.COMPILE_TYPE.miniGamePlugin?this.pluginGraph=new gameplugingraph_1.GamePluginGraph({type:"plugin",root:this.project.pluginRoot,persistCache:this.persistCache,plugins:this.plugins,compiler:this}):this.pluginGraph=new plugingraph_1.PluginGraph({type:"plugin",root:this.project.pluginRoot,persistCache:this.persistCache,plugins:this.plugins,compiler:this})}updateOptions(i){var e;const t=this.devtoolsProject;if(this.devtoolsProject=i,this.persistCache.updateBaseCacheKey(getCacheBaseKey(i)),!(0,lodash_1.isEqual)(i.setting,t.setting)||!(0,lodash_1.isEqual)(this.devtoolsProject.summerPlugins,t.summerPlugins))return this.project.setting=i.setting,this.initPlugins(),this.initAppGraph(),void("miniProgramPlugin"===this.devtoolsProject.compileType&&this.initPluginGraph());this.devtoolsProject.compileType!==t.compileType&&("miniProgramPlugin"===this.devtoolsProject.compileType?this.initPluginGraph():(null===(e=this.pluginGraph)||void 0===e||e.destroy(),this.pluginGraph=void 0)),this.appGraph.root!==this.project.miniprogramRoot&&this.initAppGraph(),this.pluginGraph&&this.pluginGraph.root!==this.project.pluginRoot&&this.initPluginGraph()}destroy(){var i,e;null===(i=this.appGraph)||void 0===i||i.destroy(),null===(e=this.pluginGraph)||void 0===e||e.destroy(),this.proxyProject.clearResolver()}getStatus(){const i=(0,pluginDriver_1.genResovleExtConf)(this.plugins),e={},t=new Set;for(const r of["json","js","wxml","wxss","wxs"])e[r]={exts:i[r].reverse()},i[r].forEach(i=>{t.add(i)});return{codeExts:Array.from(t.keys()),codeConf:e}}clearCache(){var i,e,t;null===(e=(i=this.project).clearCache)||void 0===e||e.call(i),this.appGraph.clearCache(),null===(t=this.pluginGraph)||void 0===t||t.clearCache(),this.persistCache.clean(),(0,reactiveCache_1.cleanReactiveCache)()}async getPackageFiles({graphId:i,root:e},t){var r;return this.isPluginType(i)?await(null===(r=this.pluginGraph)||void 0===r?void 0:r.getPackageFile()):await this.appGraph.getPackageFile(e)}async getConf({graphId:i},e){if(i===config_1.COMPILE_TYPE.miniProgram||i===config_1.COMPILE_TYPE.miniGame){return await this.appGraph.getConf(e)}if(this.isPluginType(i)){return await this.pluginGraph.getConf(e)}throw new Error("no support getConf for "+i)}async getCode(i,e){if(i.graphId===config_1.COMPILE_TYPE.miniProgram||i.graphId===config_1.COMPILE_TYPE.miniGame){return await this.appGraph.getDevCode(e,{package:i.package})}if(this.isPluginType(i.graphId)){return await this.pluginGraph.getDevCode(e)}throw new Error("no support getCode for "+i.graphId)}async getDevCodeByFileList(i,e){if(i.graphId===config_1.COMPILE_TYPE.miniProgram||i.graphId===config_1.COMPILE_TYPE.miniGame){return await this.appGraph.getDevCodeByFileList(e,{fileList:i.fileList})}if(this.isPluginType(i.graphId)){return await this.pluginGraph.getDevCodeByFileList(e,{fileList:i.fileList})}throw new Error("no support getDevCodeByFileList for "+i.graphId)}async getLocalFileList(i){if(i===config_1.COMPILE_TYPE.miniProgram||i===config_1.COMPILE_TYPE.miniGame)return await this.appGraph.getLocalFileList();if(this.isPluginType(i))return await this.pluginGraph.getLocalFileList();throw new Error("no support getCode for "+i)}async compileSingleCode(i,e){if(i.graphId===config_1.COMPILE_TYPE.miniProgram||i.graphId===config_1.COMPILE_TYPE.miniGame){return await this.appGraph.compileSingleCode(i.filePath,i.sourceCode)}if(this.isPluginType(i.graphId)){return await this.pluginGraph.compileSingleCode(i.filePath,i.sourceCode)}throw new Error("no support getCode for "+i.graphId)}async compileNewLogic(i,e){const t=await e.run(this.isGameType(this.project.type)?locales_1.default.config.SUMMER_COMPILE_MINIGAME.format():locales_1.default.config.SUMMER_COMPILE_MINIPROGRAM.format(),()=>this.appGraph.compileWithFileList(i,e));if(this.project.type===config_1.COMPILE_TYPE.miniProgram||this.project.type===config_1.COMPILE_TYPE.miniGame)return{app:t};if(this.isPluginType(this.project.type)){return{app:t,plugin:await e.run(locales_1.default.config.SUMMER_COMPILE_PLUGIN.format(),()=>this.pluginGraph.compile(i,e))}}throw new Error("no support compile for "+this.project.type)}async compile(i,e){const t=await e.run(this.isGameType(this.project.type)?locales_1.default.config.SUMMER_COMPILE_MINIGAME.format():locales_1.default.config.SUMMER_COMPILE_MINIPROGRAM.format(),()=>this.appGraph.compile(i,e));if(this.project.type===config_1.COMPILE_TYPE.miniProgram||this.project.type===config_1.COMPILE_TYPE.miniGame)return t["project.config.json"]=JSON.stringify({miniprogramRoot:"",__compileDebugInfo__:{useSummer:!0}}),t;if(this.isPluginType(this.project.type)){const r={},o=await e.run(locales_1.default.config.SUMMER_COMPILE_PLUGIN.format(),()=>this.pluginGraph.compile(i,e));return Object.keys(t).forEach(i=>{r[nodePath.posix.join(this.project.miniprogramRoot,i)]=t[i]}),Object.keys(o).forEach(i=>{r[nodePath.posix.join(this.project.pluginRoot,i)]=o[i]}),r["project.config.json"]=JSON.stringify({miniprogramRoot:this.project.miniprogramRoot,pluginRoot:this.project.pluginRoot,__compileDebugInfo__:{useSummer:!0}}),r}throw new Error("no support compile for "+this.project.type)}}exports.SummerCompiler=SummerCompiler;