miniprogram-ci 2.0.8 → 2.0.9

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 (62) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +2 -0
  3. package/dist/@types/ci/utils/tools.d.ts +1 -0
  4. package/dist/@types/common/code-analyse/index.d.ts +16 -1
  5. package/dist/@types/config/config.d.ts +8 -1
  6. package/dist/@types/index.d.ts +2 -1
  7. package/dist/@types/modules/corecompiler/baseCompiler.d.ts +6 -0
  8. package/dist/@types/modules/corecompiler/originalCompiler.d.ts +1 -0
  9. package/dist/@types/modules/corecompiler/processHandler.d.ts +4 -3
  10. package/dist/@types/modules/corecompiler/summer/graph/appconf.d.ts +4 -0
  11. package/dist/@types/modules/corecompiler/summer/graph/appgraph.d.ts +6 -3
  12. package/dist/@types/modules/corecompiler/summer/graph/basegraph.d.ts +12 -3
  13. package/dist/@types/modules/corecompiler/summer/graph/gamegraph.d.ts +6 -3
  14. package/dist/@types/modules/corecompiler/summer/graph/gameplugingraph.d.ts +5 -4
  15. package/dist/@types/modules/corecompiler/summer/graph/plugingraph.d.ts +5 -4
  16. package/dist/@types/modules/corecompiler/summer/plugins/base/javascript.d.ts +1 -1
  17. package/dist/@types/modules/corecompiler/summer/plugins/base/swc.d.ts +1 -1
  18. package/dist/@types/modules/corecompiler/summer/summer.d.ts +5 -1
  19. package/dist/@types/modules/corecompiler/summerCompiler.d.ts +15 -2
  20. package/dist/@types/modules/createSummer.d.ts +3 -2
  21. package/dist/@types/modules/index.d.ts +4 -0
  22. package/dist/@types/types/ci.d.ts +2 -1
  23. package/dist/@types/types/core.d.ts +21 -2
  24. package/dist/@types/types/devtools.d.ts +6 -6
  25. package/dist/@types/types/miniprogram-json/app.d.ts +16 -6
  26. package/dist/@types/utils/locales/locales.d.ts +5 -0
  27. package/dist/@types/utils/locales/zh.d.ts +5 -0
  28. package/dist/@types/utils/messageHub.d.ts +1 -1
  29. package/dist/@types/utils/packOptionsHelper.d.ts +15 -2
  30. package/dist/@types/utils/progressRecorder.d.ts +1 -1
  31. package/dist/@types/utils/tools.d.ts +4 -0
  32. package/dist/ci/utils/filterUnusedFile.js +1 -1
  33. package/dist/ci/utils/tools.js +1 -1
  34. package/dist/common/code-analyse/index.js +1 -1
  35. package/dist/config/config.js +1 -1
  36. package/dist/index.js +1 -1
  37. package/dist/modules/corecompiler/baseCompiler.js +1 -1
  38. package/dist/modules/corecompiler/original/compile/common.js +1 -1
  39. package/dist/modules/corecompiler/original/workerThread/task/compilejs.js +1 -1
  40. package/dist/modules/corecompiler/originalCompiler.js +1 -1
  41. package/dist/modules/corecompiler/processHandler.js +1 -1
  42. package/dist/modules/corecompiler/summer/graph/appconf.js +1 -1
  43. package/dist/modules/corecompiler/summer/graph/appgraph.js +1 -1
  44. package/dist/modules/corecompiler/summer/graph/basegraph.js +1 -1
  45. package/dist/modules/corecompiler/summer/graph/gamegraph.js +1 -1
  46. package/dist/modules/corecompiler/summer/graph/gameplugingraph.js +1 -1
  47. package/dist/modules/corecompiler/summer/graph/plugingraph.js +1 -1
  48. package/dist/modules/corecompiler/summer/plugins/base/javascript.js +1 -1
  49. package/dist/modules/corecompiler/summer/plugins/base/swc.js +1 -1
  50. package/dist/modules/corecompiler/summer/summer.js +1 -1
  51. package/dist/modules/corecompiler/summerCompiler.js +1 -1
  52. package/dist/modules/createSummer.js +1 -1
  53. package/dist/modules/index.js +1 -1
  54. package/dist/project/advance/precompileProject.js +1 -1
  55. package/dist/project/baseProject.js +1 -1
  56. package/dist/utils/locales/en.js +1 -1
  57. package/dist/utils/locales/zh.js +1 -1
  58. package/dist/utils/packOptionsHelper.js +1 -1
  59. package/dist/utils/progressRecorder.js +1 -1
  60. package/dist/utils/subprocess/processManager.js +1 -1
  61. package/dist/utils/tools.js +1 -1
  62. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";var COMPILE_TYPE,AstType;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.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.0.8",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={}));
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.0.9",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;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.miniappBuilder=exports.iosDeviceUtils=exports.adroidDeviceUtils=exports.getSummerPluginConfig=exports.escapeScript=exports.escapeQuot=exports.getBabelHelperDepMap=exports.getBabelHelperVersion=exports.getHelperDeps=exports.getHelperContent=exports.getHelperName=exports.isValidHelperFunc=exports.getHelperOutputPath=exports.checkIsInSubPackage=exports.normalizePath=exports.mkdirSync=exports.generateMD5=exports.compileTypeConfig=exports.JSON_CONTENT_ERR=exports.DefaultProjectAttr=exports.isHexColor=exports.locales=exports.proxy=exports.getWhiteExtList=exports.workletVersion=exports.Builder=exports.SummerCompiler=exports.OriginalCompiler=exports.BaseCoreCompiler=exports.PreCompileProject=exports.WebProject=exports.DevtoolsProject=exports.CIProject=exports.Project=exports.BaseProject=void 0;const tslib_1=require("tslib"),baseProject_1=require("./project/baseProject");Object.defineProperty(exports,"BaseProject",{enumerable:!0,get:function(){return baseProject_1.BaseProject}});const ciProject_1=require("./project/ciProject");Object.defineProperty(exports,"Project",{enumerable:!0,get:function(){return ciProject_1.CIProject}}),Object.defineProperty(exports,"CIProject",{enumerable:!0,get:function(){return ciProject_1.CIProject}});const devtoolsProject_1=require("./project/devtoolsProject");Object.defineProperty(exports,"DevtoolsProject",{enumerable:!0,get:function(){return devtoolsProject_1.DevtoolsProject}});const webProject_1=require("./project/webProject");Object.defineProperty(exports,"WebProject",{enumerable:!0,get:function(){return webProject_1.WebProject}});const precompileProject_1=require("./project/advance/precompileProject");Object.defineProperty(exports,"PreCompileProject",{enumerable:!0,get:function(){return precompileProject_1.PreCompileProject}});const baseCompiler_1=require("./modules/corecompiler/baseCompiler");Object.defineProperty(exports,"BaseCoreCompiler",{enumerable:!0,get:function(){return baseCompiler_1.BaseCoreCompiler}});const originalCompiler_1=require("./modules/corecompiler/originalCompiler");Object.defineProperty(exports,"OriginalCompiler",{enumerable:!0,get:function(){return originalCompiler_1.OriginalCompiler}});const summerCompiler_1=require("./modules/corecompiler/summerCompiler");Object.defineProperty(exports,"SummerCompiler",{enumerable:!0,get:function(){return summerCompiler_1.SummerCompiler}});const modules_1=require("./modules");Object.defineProperty(exports,"Builder",{enumerable:!0,get:function(){return modules_1.Builder}});const white_ext_list_1=require("./utils/white_ext_list");Object.defineProperty(exports,"getWhiteExtList",{enumerable:!0,get:function(){return white_ext_list_1.getWhiteExtList}});const request_1=require("./utils/request");Object.defineProperty(exports,"proxy",{enumerable:!0,get:function(){return request_1.setCiProxy}});const locales_1=tslib_1.__importDefault(require("./utils/locales/locales"));exports.locales=locales_1.default;const tools_1=require("./utils/tools");Object.defineProperty(exports,"checkIsInSubPackage",{enumerable:!0,get:function(){return tools_1.checkIsInSubPackage}}),Object.defineProperty(exports,"escapeQuot",{enumerable:!0,get:function(){return tools_1.escapeQuot}}),Object.defineProperty(exports,"escapeScript",{enumerable:!0,get:function(){return tools_1.escapeScript}}),Object.defineProperty(exports,"generateMD5",{enumerable:!0,get:function(){return tools_1.generateMD5}}),Object.defineProperty(exports,"isHexColor",{enumerable:!0,get:function(){return tools_1.isHexColor}}),Object.defineProperty(exports,"mkdirSync",{enumerable:!0,get:function(){return tools_1.mkdirSync}}),Object.defineProperty(exports,"normalizePath",{enumerable:!0,get:function(){return tools_1.normalizePath}});const config_1=require("./config/config");Object.defineProperty(exports,"DefaultProjectAttr",{enumerable:!0,get:function(){return config_1.DefaultProjectAttr}}),Object.defineProperty(exports,"JSON_CONTENT_ERR",{enumerable:!0,get:function(){return config_1.JSON_CONTENT_ERR}}),Object.defineProperty(exports,"compileTypeConfig",{enumerable:!0,get:function(){return config_1.compileTypeConfig}});const babel_helper_1=require("./utils/babel_helper");Object.defineProperty(exports,"getBabelHelperVersion",{enumerable:!0,get:function(){return babel_helper_1.getBabelHelperVersion}}),Object.defineProperty(exports,"getBabelHelperDepMap",{enumerable:!0,get:function(){return babel_helper_1.getBabelHelperDepMap}});const pluginconfig_1=require("./modules/corecompiler/summer/pluginconfig");Object.defineProperty(exports,"getSummerPluginConfig",{enumerable:!0,get:function(){return pluginconfig_1.getSummerPluginConfig}});const helper_util_1=require("./utils/helper_util");Object.defineProperty(exports,"getHelperOutputPath",{enumerable:!0,get:function(){return helper_util_1.getHelperOutputPath}}),Object.defineProperty(exports,"getHelperDeps",{enumerable:!0,get:function(){return helper_util_1.getHelperDeps}}),Object.defineProperty(exports,"isValidHelperFunc",{enumerable:!0,get:function(){return helper_util_1.isValidHelperFunc}}),Object.defineProperty(exports,"getHelperContent",{enumerable:!0,get:function(){return helper_util_1.getHelperContent}}),Object.defineProperty(exports,"getHelperName",{enumerable:!0,get:function(){return helper_util_1.getHelperName}});const adroidDeviceUtils=tslib_1.__importStar(require("./modules/nativecompiler/android/device"));exports.adroidDeviceUtils=adroidDeviceUtils;const iosDeviceUtils=tslib_1.__importStar(require("./modules/nativecompiler/ios/device"));exports.iosDeviceUtils=iosDeviceUtils;const miniappBuilder=tslib_1.__importStar(require("./utils/miniapp-builder"));exports.miniappBuilder=miniappBuilder,tslib_1.__exportStar(require("./modules/corecompiler/original"),exports),exports.workletVersion=require("./utils/babel_plugin_worklet").version,tslib_1.__exportStar(require("./ci/index"),exports);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.miniappBuilder=exports.iosDeviceUtils=exports.adroidDeviceUtils=exports.packOptionsHelper=exports.getSummerPluginConfig=exports.escapeScript=exports.escapeQuot=exports.getBabelHelperDepMap=exports.getBabelHelperVersion=exports.getHelperDeps=exports.getHelperContent=exports.getHelperName=exports.isValidHelperFunc=exports.getHelperOutputPath=exports.checkIsInSubPackage=exports.normalizePath=exports.mkdirSync=exports.generateMD5=exports.compileTypeConfig=exports.JSON_CONTENT_ERR=exports.DefaultProjectAttr=exports.isHexColor=exports.locales=exports.proxy=exports.getWhiteExtList=exports.workletVersion=exports.Builder=exports.SummerCompiler=exports.OriginalCompiler=exports.BaseCoreCompiler=exports.PreCompileProject=exports.WebProject=exports.DevtoolsProject=exports.CIProject=exports.Project=exports.BaseProject=void 0;const tslib_1=require("tslib"),baseProject_1=require("./project/baseProject");Object.defineProperty(exports,"BaseProject",{enumerable:!0,get:function(){return baseProject_1.BaseProject}});const ciProject_1=require("./project/ciProject");Object.defineProperty(exports,"Project",{enumerable:!0,get:function(){return ciProject_1.CIProject}}),Object.defineProperty(exports,"CIProject",{enumerable:!0,get:function(){return ciProject_1.CIProject}});const devtoolsProject_1=require("./project/devtoolsProject");Object.defineProperty(exports,"DevtoolsProject",{enumerable:!0,get:function(){return devtoolsProject_1.DevtoolsProject}});const webProject_1=require("./project/webProject");Object.defineProperty(exports,"WebProject",{enumerable:!0,get:function(){return webProject_1.WebProject}});const precompileProject_1=require("./project/advance/precompileProject");Object.defineProperty(exports,"PreCompileProject",{enumerable:!0,get:function(){return precompileProject_1.PreCompileProject}});const baseCompiler_1=require("./modules/corecompiler/baseCompiler");Object.defineProperty(exports,"BaseCoreCompiler",{enumerable:!0,get:function(){return baseCompiler_1.BaseCoreCompiler}});const originalCompiler_1=require("./modules/corecompiler/originalCompiler");Object.defineProperty(exports,"OriginalCompiler",{enumerable:!0,get:function(){return originalCompiler_1.OriginalCompiler}});const summerCompiler_1=require("./modules/corecompiler/summerCompiler");Object.defineProperty(exports,"SummerCompiler",{enumerable:!0,get:function(){return summerCompiler_1.SummerCompiler}});const modules_1=require("./modules");Object.defineProperty(exports,"Builder",{enumerable:!0,get:function(){return modules_1.Builder}});const white_ext_list_1=require("./utils/white_ext_list");Object.defineProperty(exports,"getWhiteExtList",{enumerable:!0,get:function(){return white_ext_list_1.getWhiteExtList}});const request_1=require("./utils/request");Object.defineProperty(exports,"proxy",{enumerable:!0,get:function(){return request_1.setCiProxy}});const locales_1=tslib_1.__importDefault(require("./utils/locales/locales"));exports.locales=locales_1.default;const tools_1=require("./utils/tools");Object.defineProperty(exports,"checkIsInSubPackage",{enumerable:!0,get:function(){return tools_1.checkIsInSubPackage}}),Object.defineProperty(exports,"escapeQuot",{enumerable:!0,get:function(){return tools_1.escapeQuot}}),Object.defineProperty(exports,"escapeScript",{enumerable:!0,get:function(){return tools_1.escapeScript}}),Object.defineProperty(exports,"generateMD5",{enumerable:!0,get:function(){return tools_1.generateMD5}}),Object.defineProperty(exports,"isHexColor",{enumerable:!0,get:function(){return tools_1.isHexColor}}),Object.defineProperty(exports,"mkdirSync",{enumerable:!0,get:function(){return tools_1.mkdirSync}}),Object.defineProperty(exports,"normalizePath",{enumerable:!0,get:function(){return tools_1.normalizePath}});const config_1=require("./config/config");Object.defineProperty(exports,"DefaultProjectAttr",{enumerable:!0,get:function(){return config_1.DefaultProjectAttr}}),Object.defineProperty(exports,"JSON_CONTENT_ERR",{enumerable:!0,get:function(){return config_1.JSON_CONTENT_ERR}}),Object.defineProperty(exports,"compileTypeConfig",{enumerable:!0,get:function(){return config_1.compileTypeConfig}});const babel_helper_1=require("./utils/babel_helper");Object.defineProperty(exports,"getBabelHelperVersion",{enumerable:!0,get:function(){return babel_helper_1.getBabelHelperVersion}}),Object.defineProperty(exports,"getBabelHelperDepMap",{enumerable:!0,get:function(){return babel_helper_1.getBabelHelperDepMap}});const pluginconfig_1=require("./modules/corecompiler/summer/pluginconfig");Object.defineProperty(exports,"getSummerPluginConfig",{enumerable:!0,get:function(){return pluginconfig_1.getSummerPluginConfig}});const helper_util_1=require("./utils/helper_util");Object.defineProperty(exports,"getHelperOutputPath",{enumerable:!0,get:function(){return helper_util_1.getHelperOutputPath}}),Object.defineProperty(exports,"getHelperDeps",{enumerable:!0,get:function(){return helper_util_1.getHelperDeps}}),Object.defineProperty(exports,"isValidHelperFunc",{enumerable:!0,get:function(){return helper_util_1.isValidHelperFunc}}),Object.defineProperty(exports,"getHelperContent",{enumerable:!0,get:function(){return helper_util_1.getHelperContent}}),Object.defineProperty(exports,"getHelperName",{enumerable:!0,get:function(){return helper_util_1.getHelperName}});const adroidDeviceUtils=tslib_1.__importStar(require("./modules/nativecompiler/android/device"));exports.adroidDeviceUtils=adroidDeviceUtils;const iosDeviceUtils=tslib_1.__importStar(require("./modules/nativecompiler/ios/device"));exports.iosDeviceUtils=iosDeviceUtils;const miniappBuilder=tslib_1.__importStar(require("./utils/miniapp-builder"));exports.miniappBuilder=miniappBuilder;const packOptionsHelper_1=tslib_1.__importDefault(require("./utils/packOptionsHelper"));exports.packOptionsHelper=packOptionsHelper_1.default,tslib_1.__exportStar(require("./modules/corecompiler/original"),exports),exports.workletVersion=require("./utils/babel_plugin_worklet").version,tslib_1.__exportStar(require("./ci/index"),exports);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseCoreCompiler=void 0;const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),index_1=require("./original/index"),singletontask_1=require("../../utils/singletontask"),config_1=require("../../config/config");class BaseCoreCompiler{isGameType(t){return t===config_1.COMPILE_TYPE.miniGame||t===config_1.COMPILE_TYPE.miniGamePlugin}isPluginType(t){return t===config_1.COMPILE_TYPE.miniGame||t===config_1.COMPILE_TYPE.miniGamePlugin}get projectPath(){return this.project.projectPath}get srcPath(){return this.project.srcPath||this.project.projectPath}get pluginSrcPath(){return this.project.pluginSrcPath}constructor(t){this.isSummer=!1,this.project=t}async ready(){return this._checkReadyTask||(this._checkReadyTask=new singletontask_1.SingletonTask(this.init.bind(this))),await this._checkReadyTask.getResult(!0)}watch(t){this.project.event.on("fileChange",t)}unwatch(t){this.project.event.off("fileChange",t)}compileJS(t){throw new Error("no implement compileJS")}compile(t){throw new Error("no implement compile")}clearCache(){throw new Error("no implement clearCache")}async uglifyFileNames(t,e,i){throw new Error("no implement uglifyFileNames")}async packNpm(t){var e;const i=(null===(e=this.project)||void 0===e?void 0:e.setting)||{};if(!i.packNpmManually)return await(0,index_1.packNpm)(this.project,t);if(!i.packNpmRelationList)throw new Error("project.config.json setting.packNpmRelationList 必须存在");const{projectPath:r}=this.project;for(const t of i.packNpmRelationList){if(!t.packageJsonPath||"string"!=typeof t.packageJsonPath||!t.packageJsonPath.endsWith("package.json"))throw new Error(locales_1.default.config.PACKAGE_JSON_PATH_IN_VALID.format(t.packageJsonPath));const e=path_1.default.join(r,t.packageJsonPath);if(!fs_1.default.existsSync(e))throw new Error(locales_1.default.config.NOT_FOUND.format(e));const i=path_1.default.join(r,t.packageJsonPath,"../node_modules");if(!fs_1.default.existsSync(i))throw new Error(locales_1.default.config.RELATED_NODE_MODULES_NOT_FOUND.format(e,path_1.default.join(e,"..")));const o=path_1.default.join(r,t.miniprogramNpmDistDir);if(!fs_1.default.existsSync(o))throw new Error(locales_1.default.config.NOT_FOUND.format(o))}const o=lodash_1.default.cloneDeep(i.packNpmRelationList);return o.forEach(t=>{t.packageJsonPath=path_1.default.join(r,t.packageJsonPath),t.miniprogramNpmDistDir=path_1.default.join(r,t.miniprogramNpmDistDir)}),await this.packNpmManually(o)}async packNpmManually(t){const e={miniProgramPackNum:0,otherNpmPackNum:0,warnList:[]};for(const i of t){const t=await(0,index_1.packNpmManually)(i);e.miniProgramPackNum+=t.miniProgramPackNum,e.otherNpmPackNum+=t.otherNpmPackNum,e.warnList=e.warnList.concat(t.warnList)}return e.warnList}stat(t="",e=""){return this.project.stat(t,e)}exists(t="",e=""){return this.project.exists(t,e)}excludeRoot(t=[],e=""){return e?t.map(t=>path_1.default.posix.relative(e,t)):t}excludeKeyRoot(t,e=""){if(!e)return t;const i={};let r="";for(const o in t)r=path_1.default.posix.relative(e,o),i[r]=t[o];return i}getFile(t="",e=""){return this.project.getFile(t,e)}getFileString(t="",e=""){return this.project.getFile(t,e).toString()}getMPFileWithDir(t=""){var e;const{files:i=[],dirs:r=[]}=(null===(e=this.project)||void 0===e?void 0:e.getFilesAndDirs())||{};return t=this.project.miniprogramRoot?path_1.default.posix.join(this.project.miniprogramRoot,t):t,this.excludeRoot(i.concat(r),this.project.miniprogramRoot||"")}getMPFileList(t="",e=""){return t=this.project.miniprogramRoot?path_1.default.posix.join(this.project.miniprogramRoot||"",t):t,this.excludeRoot(this.project.getFileList(t,e),this.project.miniprogramRoot||"")}getMPWXMLFileList(t=""){return this.getMPFileList(t,".wxml")}getMPWXSFileList(t=""){return this.getMPFileList(t,".wxs")}getMPJSFileList(t=""){return this.getMPFileList(t,".js")}getMPWXSSFileList(t=""){return this.getMPFileList(t,".wxss")}getMPJSONFileList(t=""){return this.getMPFileList(t,".json")}getPluginFileList(t="",e=""){return t=path_1.default.posix.join(this.project.pluginRoot||"",t),this.excludeRoot(this.project.getFileList(t,e),this.project.pluginRoot)}getPluginWXMLFileList(t=""){return this.getPluginFileList(t,".wxml")}getPluginWXSFileList(t=""){return this.getPluginFileList(t,".wxs")}getPluginJSFileList(t=""){return this.getPluginFileList(t,".js")}getPluginWXSSFileList(t=""){return this.getPluginFileList(t,".wxss")}getPluginJSONFileList(t=""){return this.getPluginFileList(t,".json")}isValidComponent(t="",e){const i=this.excludeRoot(this.project.getFileList(t),t),r=i.some(t=>t===e+".json"),o=i.some(t=>t===e+".wxml"),s=i.some(t=>t===e+".js"||t===e+".ts");return r&&o&&s}getAllFileInfo(t=""){const e=this.project.getFileList(t),i={};return e.forEach(t=>{i[t]=this.stat("",t)||{}}),i}}exports.BaseCoreCompiler=BaseCoreCompiler;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseCoreCompiler=void 0;const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),index_1=require("./original/index"),singletontask_1=require("../../utils/singletontask"),config_1=require("../../config/config");class BaseCoreCompiler{isGameType(t){return t===config_1.COMPILE_TYPE.miniGame||t===config_1.COMPILE_TYPE.miniGamePlugin}isPluginType(t){return t===config_1.COMPILE_TYPE.miniProgramPlugin||t===config_1.COMPILE_TYPE.miniGamePlugin}get projectPath(){return this.project.projectPath}get srcPath(){return this.project.srcPath||this.project.projectPath}get pluginSrcPath(){return this.project.pluginSrcPath}constructor(t){this.isSummer=!1,this.project=t}async ready(){return this._checkReadyTask||(this._checkReadyTask=new singletontask_1.SingletonTask(this.init.bind(this))),await this._checkReadyTask.getResult(!0)}watch(t){this.project.event.on("fileChange",t)}unwatch(t){this.project.event.off("fileChange",t)}compileJS(t){throw new Error("no implement compileJS")}compile(t){throw new Error("no implement compile")}clearCache(){throw new Error("no implement clearCache")}async uglifyFileNames(t,e,i){throw new Error("no implement uglifyFileNames")}async packNpm(t){var e;const i=(null===(e=this.project)||void 0===e?void 0:e.setting)||{};if(!i.packNpmManually)return await(0,index_1.packNpm)(this.project,t);if(!i.packNpmRelationList)throw new Error("project.config.json setting.packNpmRelationList 必须存在");const{projectPath:r}=this.project;for(const t of i.packNpmRelationList){if(!t.packageJsonPath||"string"!=typeof t.packageJsonPath||!t.packageJsonPath.endsWith("package.json"))throw new Error(locales_1.default.config.PACKAGE_JSON_PATH_IN_VALID.format(t.packageJsonPath));const e=path_1.default.join(r,t.packageJsonPath);if(!fs_1.default.existsSync(e))throw new Error(locales_1.default.config.NOT_FOUND.format(e));const i=path_1.default.join(r,t.packageJsonPath,"../node_modules");if(!fs_1.default.existsSync(i))throw new Error(locales_1.default.config.RELATED_NODE_MODULES_NOT_FOUND.format(e,path_1.default.join(e,"..")));const o=path_1.default.join(r,t.miniprogramNpmDistDir);if(!fs_1.default.existsSync(o))throw new Error(locales_1.default.config.NOT_FOUND.format(o))}const o=lodash_1.default.cloneDeep(i.packNpmRelationList);return o.forEach(t=>{t.packageJsonPath=path_1.default.join(r,t.packageJsonPath),t.miniprogramNpmDistDir=path_1.default.join(r,t.miniprogramNpmDistDir)}),await this.packNpmManually(o)}async packNpmManually(t){const e={miniProgramPackNum:0,otherNpmPackNum:0,warnList:[]};for(const i of t){const t=await(0,index_1.packNpmManually)(i);e.miniProgramPackNum+=t.miniProgramPackNum,e.otherNpmPackNum+=t.otherNpmPackNum,e.warnList=e.warnList.concat(t.warnList)}return e.warnList}stat(t="",e=""){return this.project.stat(t,e)}exists(t="",e=""){return this.project.exists(t,e)}excludeRoot(t=[],e=""){return e?t.map(t=>path_1.default.posix.relative(e,t)):t}excludeKeyRoot(t,e=""){if(!e)return t;const i={};let r="";for(const o in t)r=path_1.default.posix.relative(e,o),i[r]=t[o];return i}getFile(t="",e=""){return this.project.getFile(t,e)}getFileString(t="",e=""){return this.project.getFile(t,e).toString()}getMPFileWithDir(t=""){var e;const{files:i=[],dirs:r=[]}=(null===(e=this.project)||void 0===e?void 0:e.getFilesAndDirs())||{};return t=this.project.miniprogramRoot?path_1.default.posix.join(this.project.miniprogramRoot,t):t,this.excludeRoot(i.concat(r),this.project.miniprogramRoot||"")}getMPFileList(t="",e=""){return t=this.project.miniprogramRoot?path_1.default.posix.join(this.project.miniprogramRoot||"",t):t,this.excludeRoot(this.project.getFileList(t,e),this.project.miniprogramRoot||"")}getMPWXMLFileList(t=""){return this.getMPFileList(t,".wxml")}getMPWXSFileList(t=""){return this.getMPFileList(t,".wxs")}getMPJSFileList(t=""){return this.getMPFileList(t,".js")}getMPWXSSFileList(t=""){return this.getMPFileList(t,".wxss")}getMPJSONFileList(t=""){return this.getMPFileList(t,".json")}async getFiltedFileListReason(t){return[]}getPluginFileList(t="",e=""){return t=path_1.default.posix.join(this.project.pluginRoot||"",t),this.excludeRoot(this.project.getFileList(t,e),this.project.pluginRoot)}getPluginWXMLFileList(t=""){return this.getPluginFileList(t,".wxml")}getPluginWXSFileList(t=""){return this.getPluginFileList(t,".wxs")}getPluginJSFileList(t=""){return this.getPluginFileList(t,".js")}getPluginWXSSFileList(t=""){return this.getPluginFileList(t,".wxss")}getPluginJSONFileList(t=""){return this.getPluginFileList(t,".json")}isValidComponent(t="",e){const i=this.excludeRoot(this.project.getFileList(t),t),r=i.some(t=>t===e+".json"),o=i.some(t=>t===e+".wxml"),s=i.some(t=>t===e+".js"||t===e+".ts");return r&&o&&s}getAllFileInfo(t=""){const e=this.project.getFileList(t),i={};return e.forEach(t=>{i[t]=this.stat("",t)||{}}),i}}exports.BaseCoreCompiler=BaseCoreCompiler;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getUploadProjectConfig=exports.compileWXMLFiles=exports.compileWXSSFiles=exports.compileJSFiles=exports.compileOther=exports.isNotIgnoredByProjectConfig=exports.getBabelRoot=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../../../utils/tools"),taskstatus_1=require("../../../../utils/taskstatus"),index_1=require("../workerThread/index"),helper_util_1=require("../../../../utils/helper_util"),projectconfig_1=require("../json/projectconfig"),game_1=tslib_1.__importDefault(require("../json/game")),signaturejson_1=require("../json/signaturejson"),config_1=require("../../../../config/config"),wxml_1=require("./handler/wxml"),wxss_1=require("./handler/wxss"),js_1=require("./handler/js");async function getBabelRoot(o){var t,e;const i=(0,projectconfig_1.getProjectConfigJSON)(o);let s=null===(e=null===(t=null==i?void 0:i.setting)||void 0===t?void 0:t.babelSetting)||void 0===e?void 0:e.outputPath;return s?(s=(0,tools_1.normalizePath)(s),s.replace(/(^[./\\])|(\/$)/g,""),s):"@babel/runtime"}function isNotIgnoredByProjectConfig(o,t,e){var i,s;const n=path_1.default.posix.relative(t,e),l=(null===(i=o.packOptions)||void 0===i?void 0:i.include)||[];if((0,tools_1.isFileIncluded)(n,l))return!0;const r=(null===(s=o.packOptions)||void 0===s?void 0:s.ignore)||[];return!(0,tools_1.isFileIgnored)(path_1.default.posix.relative(t,e),r)}async function copyFile(o,t){return{filePath:t,code:o.getFile("",t)}}async function compileOther(o,t,e){const{onProgressUpdate:i=(()=>{})}=e,s=new taskstatus_1.TaskStatus("compiling other files");i(s);const n=[];for(const e of t)n.push(copyFile(o,e));const l=await Promise.all(n),r={};for(const o of l){const{code:t,filePath:e}=o;t&&(r[e]=t)}return s.done(),i(s),r}async function canWeCompileJS(o,t,e){let i;for(const o of t)if((0,tools_1.normalizePath)(e).startsWith((0,tools_1.normalizePath)((0,signaturejson_1.trailing)(o.fullPath,"/")))){i=o;break}if(i){return i.signature.findIndex(o=>(0,tools_1.normalizePath)(o.fullPath)===(0,tools_1.normalizePath)(e))>=0}return!0}async function compileJSFiles(o,t,e,i){const{setting:s={}}=i;let n="@babel/runtime";s.enhance&&(n=await getBabelRoot(o));const l=[];if(o.type===config_1.COMPILE_TYPE.miniGame||o.type===config_1.COMPILE_TYPE.miniGamePlugin){const s=await(0,signaturejson_1.getAllPluginSignatures)(o);for(const r of t){const t=path_1.default.join(o.projectPath,e,r);await canWeCompileJS(o,s,t)&&l.push((0,js_1.compileJS)(o,r,Object.assign(Object.assign({},i),{babelRoot:n,root:e})))}}else for(const s of t)l.push((0,js_1.compileJS)(o,s,Object.assign(Object.assign({},i),{babelRoot:n,root:e})));let r=[];try{r=await Promise.all(l)}catch(o){throw(0,index_1.abortTask)(index_1.TASK_NAME.COMPILE_JS),o}const a={},c=new Set;for(const o of r){const{filePath:t,map:i,code:s,helpers:n}=o,l=(0,tools_1.formatSourceMap)(i);void 0!==s&&(a[path_1.default.posix.normalize(path_1.default.posix.join(e,t))]=s),l&&(a[path_1.default.posix.normalize(path_1.default.posix.join(e,t+".map"))]=l),n.length>0&&n.forEach(o=>{c.add(o)})}return await(0,helper_util_1.appendHelpers)(o,c,path_1.default.join(e),a),a}async function compileWXSSFiles(o,t,e,i){const s=[];for(const n of t)s.push((0,wxss_1.compileWXSS)(o,n,Object.assign(Object.assign({},i),{root:e})));let n=[];try{n=await Promise.all(s)}catch(o){throw(0,index_1.abortTask)(index_1.TASK_NAME.COMPILE_WXSS),o}const l={};for(const o of n){const{filePath:t,code:i}=o;void 0!==i&&(l[path_1.default.posix.normalize(path_1.default.posix.join(e,t))]=i)}return l}async function compileWXMLFiles(o,t,e,i){const s=[];for(const n of t)s.push((0,wxml_1.compileWXML)(o,n,Object.assign(Object.assign({},i),{root:e})));let n=[];try{n=await Promise.all(s)}catch(o){throw(0,index_1.abortTask)(index_1.TASK_NAME.MINIFY_WXML),o}const l={};for(const o of n){const{filePath:t,code:i}=o;void 0!==i&&(l[path_1.default.posix.normalize(path_1.default.posix.join(e,t))]=i)}return l}async function getUploadProjectConfig(o,t){const e={miniprogramRoot:t.miniprogramRoot,localPlugins:[]};t.pluginRoot&&(e.pluginRoot=t.pluginRoot);const i=(0,game_1.default)(o),s=(o,t="")=>{const i=e.localPlugins||[];for(const e in o)if(o.hasOwnProperty(e)&&o[e]&&"string"==typeof o[e].path){const s=o[e],n=path_1.default.posix.normalize(path_1.default.posix.join(t,s.path.replace(/\\/g,"/")).replace(/^\/+/,""));i.push({alias:e,provider:s.provider,path:n})}e.localPlugins=i};if(i.plugins){const{plugins:o}=i;s(o)}const n=i.subpackages||i.subPackages;if(Array.isArray(n))for(const o of n)(null==o?void 0:o.plugins)&&s(o.plugins,o.root||"");return e}exports.getBabelRoot=getBabelRoot,exports.isNotIgnoredByProjectConfig=isNotIgnoredByProjectConfig,exports.compileOther=compileOther,exports.compileJSFiles=compileJSFiles,exports.compileWXSSFiles=compileWXSSFiles,exports.compileWXMLFiles=compileWXMLFiles,exports.getUploadProjectConfig=getUploadProjectConfig;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getUploadProjectConfig=exports.compileWXMLFiles=exports.compileWXSSFiles=exports.compileJSFiles=exports.compileOther=exports.isNotIgnoredByProjectConfig=exports.getBabelRoot=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../../../utils/tools"),taskstatus_1=require("../../../../utils/taskstatus"),index_1=require("../workerThread/index"),helper_util_1=require("../../../../utils/helper_util"),projectconfig_1=require("../json/projectconfig"),game_1=tslib_1.__importDefault(require("../json/game")),signaturejson_1=require("../json/signaturejson"),config_1=require("../../../../config/config"),taskmanager_1=tslib_1.__importDefault(require("../../../../utils/taskmanager")),wxml_1=require("./handler/wxml"),wxss_1=require("./handler/wxss"),js_1=require("./handler/js");async function getBabelRoot(o){var t,e;const i=(0,projectconfig_1.getProjectConfigJSON)(o);let s=null===(e=null===(t=null==i?void 0:i.setting)||void 0===t?void 0:t.babelSetting)||void 0===e?void 0:e.outputPath;return s?(s=(0,tools_1.normalizePath)(s),s.replace(/(^[./\\])|(\/$)/g,""),s):"@babel/runtime"}function isNotIgnoredByProjectConfig(o,t,e){var i,s;const n=path_1.default.posix.relative(t,e),a=(null===(i=o.packOptions)||void 0===i?void 0:i.include)||[];if((0,tools_1.isFileIncluded)(n,a))return!0;const r=(null===(s=o.packOptions)||void 0===s?void 0:s.ignore)||[];return!(0,tools_1.isFileIgnored)(path_1.default.posix.relative(t,e),r)}async function copyFile(o,t){return{filePath:t,code:o.getFile("",t)}}async function compileOther(o,t,e){const{onProgressUpdate:i=(()=>{})}=e,s=new taskstatus_1.TaskStatus("compiling other files");i(s);const n=new taskmanager_1.default;for(const e of t)n.addTask(copyFile,o,e);const a=await n.runAllAsync(),r={};for(const o of a){const{code:t,filePath:e}=o;t&&(r[e]=t)}return s.done(),i(s),r}async function canWeCompileJS(o,t,e){let i;for(const o of t)if((0,tools_1.normalizePath)(e).startsWith((0,tools_1.normalizePath)((0,signaturejson_1.trailing)(o.fullPath,"/")))){i=o;break}if(i){return i.signature.findIndex(o=>(0,tools_1.normalizePath)(o.fullPath)===(0,tools_1.normalizePath)(e))>=0}return!0}async function compileJSFiles(o,t,e,i){const{setting:s={}}=i;let n="@babel/runtime";s.enhance&&(n=await getBabelRoot(o));const a=[];if(o.type===config_1.COMPILE_TYPE.miniGame||o.type===config_1.COMPILE_TYPE.miniGamePlugin){const s=await(0,signaturejson_1.getAllPluginSignatures)(o);for(const r of t){const t=path_1.default.join(o.projectPath,e,r);await canWeCompileJS(o,s,t)&&a.push((0,js_1.compileJS)(o,r,Object.assign(Object.assign({},i),{babelRoot:n,root:e})))}}else for(const s of t)a.push((0,js_1.compileJS)(o,s,Object.assign(Object.assign({},i),{babelRoot:n,root:e})));let r=[];try{r=await Promise.all(a)}catch(o){throw(0,index_1.abortTask)(index_1.TASK_NAME.COMPILE_JS),o}const l={},c=new Set;for(const o of r){const{filePath:t,map:i,code:s,helpers:n}=o,a=(0,tools_1.formatSourceMap)(i);void 0!==s&&(l[path_1.default.posix.normalize(path_1.default.posix.join(e,t))]=s),a&&(l[path_1.default.posix.normalize(path_1.default.posix.join(e,t+".map"))]=a),n.length>0&&n.forEach(o=>{c.add(o)})}return await(0,helper_util_1.appendHelpers)(o,c,path_1.default.join(e),l),l}async function compileWXSSFiles(o,t,e,i){const s=[];for(const n of t)s.push((0,wxss_1.compileWXSS)(o,n,Object.assign(Object.assign({},i),{root:e})));let n=[];try{n=await Promise.all(s)}catch(o){throw(0,index_1.abortTask)(index_1.TASK_NAME.COMPILE_WXSS),o}const a={};for(const o of n){const{filePath:t,code:i}=o;void 0!==i&&(a[path_1.default.posix.normalize(path_1.default.posix.join(e,t))]=i)}return a}async function compileWXMLFiles(o,t,e,i){const s=[];for(const n of t)s.push((0,wxml_1.compileWXML)(o,n,Object.assign(Object.assign({},i),{root:e})));let n=[];try{n=await Promise.all(s)}catch(o){throw(0,index_1.abortTask)(index_1.TASK_NAME.MINIFY_WXML),o}const a={};for(const o of n){const{filePath:t,code:i}=o;void 0!==i&&(a[path_1.default.posix.normalize(path_1.default.posix.join(e,t))]=i)}return a}async function getUploadProjectConfig(o,t){const e={miniprogramRoot:t.miniprogramRoot,localPlugins:[]};t.pluginRoot&&(e.pluginRoot=t.pluginRoot);const i=(0,game_1.default)(o),s=(o,t="")=>{const i=e.localPlugins||[];for(const e in o)if(o.hasOwnProperty(e)&&o[e]&&"string"==typeof o[e].path){const s=o[e],n=path_1.default.posix.normalize(path_1.default.posix.join(t,s.path.replace(/\\/g,"/")).replace(/^\/+/,""));i.push({alias:e,provider:s.provider,path:n})}e.localPlugins=i};if(i.plugins){const{plugins:o}=i;s(o)}const n=i.subpackages||i.subPackages;if(Array.isArray(n))for(const o of n)(null==o?void 0:o.plugins)&&s(o.plugins,o.root||"");return e}exports.getBabelRoot=getBabelRoot,exports.isNotIgnoredByProjectConfig=isNotIgnoredByProjectConfig,exports.compileOther=compileOther,exports.compileJSFiles=compileJSFiles,exports.compileWXSSFiles=compileWXSSFiles,exports.compileWXMLFiles=compileWXMLFiles,exports.getUploadProjectConfig=getUploadProjectConfig;
@@ -1 +1 @@
1
- "use strict";const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),tools_1=require("../../../../../utils/tools"),config_1=require("../../../../../config/config"),log=tslib_1.__importStar(require("../../../../../utils/log")),babel_helper_1=require("../../../../../utils/babel_helper"),jsonParse_1=require("../../../../../utils/jsonParse"),call_func_1=require("./call_func"),sourcemap=()=>require("source-map"),enhanceCompile=()=>require("../../js/enhance"),workletCompile=()=>require("../../js/workletCompile"),es6Compile=()=>require("../../js/es6Transform"),minifyJS=()=>require("../../js/minifyjs"),minifyJSAfterWrap=()=>require("../../js/minifyjsAfterWrap"),MAX_CODE_LENGTH=2048e3;async function tryGetInputSourceMap(e,r){try{const t=/\/\/[#|@] sourceMappingURL=[\s]*(\S*)[\s]*$/m.exec(e),s=path_1.default.posix.dirname(r),o=path_1.default.posix.basename(r);let i;if(null==t?void 0:t[1])if(t[1].endsWith(".js.map"))i=await(0,call_func_1.call)("readFileAsync",path_1.default.posix.join(s,t[1]),"utf-8");else{const e=t[1].split("base64,")[1];i=Buffer.from(e,"base64").toString()}else{const e=path_1.default.posix.join(s,o+".map");fs_1.default.existsSync(e)&&(i=await(0,call_func_1.call)("readFileAsync",e,"utf-8"))}if(i){const e=(0,jsonParse_1.jsonParse)(i);new(require("source-map").SourceMapConsumer)(e);return await insertSourcesContent(e,r),e}}catch(e){log.log(`try to get input sourcemap of ${r} catch error ${e}`)}}const insertSourcesContent=async(e,r)=>{if(Array.isArray(e.sources)&&!Array.isArray(e.sourcesContent)){const t=e.sourcesContent;try{const t=path_1.default.posix.dirname(r),s=[],{sources:o}=e;for(const e of o){const r=await(0,call_func_1.call)("readFileAsync",path_1.default.posix.join(t,e),"utf-8");s.push(r)}e.sourcesContent=s}catch(r){e.sourcesContent=t}}};async function compileJS(e){const{code:r,filePath:t,projectPath:s,setting:o,babelRoot:i="@babel/runtime",root:a="",babelIgnore:n=[]}=e,{enhance:l,es6:c,disableUseStrict:u,compileWorklet:p}=o,f="string"==typeof r?r:(0,tools_1.bufferToUtf8String)(Buffer.from(r)),_=path_1.default.posix.join(a,t),m=o.minified;if(void 0===f)return{error:{code:config_1.FILE_NOT_UTF8,path:_,message:locales_1.default.config.FILE_NOT_UTF8.format(_)}};const b=f.length>=2048e3;let h=!1;l&&(h=(0,babel_helper_1.isIgnore)(n,t));const d=await tryGetInputSourceMap(f,path_1.default.posix.join(s,a,t));if(b||h)return{error:null,isLargeFile:b,isBabelIgnore:h,map:"object"==typeof d?JSON.stringify(d):d,code:f,helpers:[]};let g=f,j=d,y=[];if(l){const e=await require("../../js/enhance")({code:f,babelRoot:i,filePath:t,disableUseStrict:u,inputSourceMap:d});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map,y=e.helpers||[]}else if(c){const e=require("../../js/es6Transform")({code:f,filePath:t,inputSourceMap:d});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map}else if(p){if(f.includes('"worklet"')||f.includes("'worklet'")){const e=await require("../../js/workletCompile")({code:f,babelRoot:i,filePath:t,disableUseStrict:u,inputSourceMap:d});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map,y=e.helpers||[]}}if(m){if(!c&&!l){const e=require("../../js/minifyjsAfterWrap")({filePath:t,code:g,inputSourceMap:j});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code,j=e.map}else{const e=require("../../js/minifyjs")({filePath:t,code:g,useTerser:!!l,inputSourceMap:j});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code,j=e.map}}if("string"!=typeof j)try{(null==j?void 0:j.sourcesContent)&&(j.sourcesContent=j.sourcesContent.map(e=>e.replace(/\r\n/g,"\n"))),j=JSON.stringify(j)}catch(e){j=""}else j=j.replace(/\\r\\n/g,"\\n");return{error:null,isLargeFile:b,isBabelIgnore:h,map:j,code:g.replace(/\r\n/g,"\n"),helpers:y||[]}}module.exports=compileJS;
1
+ "use strict";const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),tools_1=require("../../../../../utils/tools"),config_1=require("../../../../../config/config"),log=tslib_1.__importStar(require("../../../../../utils/log")),babel_helper_1=require("../../../../../utils/babel_helper"),jsonParse_1=require("../../../../../utils/jsonParse"),call_func_1=require("./call_func"),sourcemap=()=>require("source-map"),enhanceCompile=()=>require("../../js/enhance"),workletCompile=()=>require("../../js/workletCompile"),es6Compile=()=>require("../../js/es6Transform"),minifyJS=()=>require("../../js/minifyjs"),minifyJSAfterWrap=()=>require("../../js/minifyjsAfterWrap");async function tryGetInputSourceMap(e,r){try{const t=/\/\/[#|@] sourceMappingURL=[\s]*(\S*)[\s]*$/m.exec(e),s=path_1.default.posix.dirname(r),o=path_1.default.posix.basename(r);let i;if(null==t?void 0:t[1])if(t[1].endsWith(".js.map"))i=await(0,call_func_1.call)("readFileAsync",path_1.default.posix.join(s,t[1]),"utf-8");else{const e=t[1].split("base64,")[1];i=Buffer.from(e,"base64").toString()}else{const e=path_1.default.posix.join(s,o+".map");fs_1.default.existsSync(e)&&(i=await(0,call_func_1.call)("readFileAsync",e,"utf-8"))}if(i){const e=(0,jsonParse_1.jsonParse)(i);new(require("source-map").SourceMapConsumer)(e);return await insertSourcesContent(e,r),e}}catch(e){log.log(`try to get input sourcemap of ${r} catch error ${e}`)}}const insertSourcesContent=async(e,r)=>{if(Array.isArray(e.sources)&&!Array.isArray(e.sourcesContent)){const t=e.sourcesContent;try{const t=path_1.default.posix.dirname(r),s=[],{sources:o}=e;for(const e of o){const r=await(0,call_func_1.call)("readFileAsync",path_1.default.posix.join(t,e),"utf-8");s.push(r)}e.sourcesContent=s}catch(r){e.sourcesContent=t}}};async function compileJS(e){const{code:r,filePath:t,projectPath:s,setting:o,babelRoot:i="@babel/runtime",root:a="",babelIgnore:n=[]}=e,{enhance:c,es6:l,disableUseStrict:u,compileWorklet:p}=o,f="string"==typeof r?r:(0,tools_1.bufferToUtf8String)(Buffer.from(r)),_=path_1.default.posix.join(a,t),m=o.minified;if(void 0===f)return{error:{code:config_1.FILE_NOT_UTF8,path:_,message:locales_1.default.config.FILE_NOT_UTF8.format(_)}};const b=f.length>=config_1.MAX_CODE_LENGTH;let h=!1;c&&(h=(0,babel_helper_1.isIgnore)(n,t));const d=await tryGetInputSourceMap(f,path_1.default.posix.join(s,a,t));if(b||h)return{error:null,isLargeFile:b,isBabelIgnore:h,map:"object"==typeof d?JSON.stringify(d):d,code:f,helpers:[]};let g=f,j=d,y=[];if(c){const e=await require("../../js/enhance")({code:f,babelRoot:i,filePath:t,disableUseStrict:u,inputSourceMap:d});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map,y=e.helpers||[]}else if(l){const e=require("../../js/es6Transform")({code:f,filePath:t,inputSourceMap:d});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map}else if(p){if(f.includes('"worklet"')||f.includes("'worklet'")){const e=await require("../../js/workletCompile")({code:f,babelRoot:i,filePath:t,disableUseStrict:u,inputSourceMap:d});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map,y=e.helpers||[]}}if(m){if(!l&&!c){const e=require("../../js/minifyjsAfterWrap")({filePath:t,code:g,inputSourceMap:j});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code,j=e.map}else{const e=require("../../js/minifyjs")({filePath:t,code:g,useTerser:!!c,inputSourceMap:j});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code,j=e.map}}if("string"!=typeof j)try{(null==j?void 0:j.sourcesContent)&&(j.sourcesContent=j.sourcesContent.map(e=>e.replace(/\r\n/g,"\n"))),j=JSON.stringify(j)}catch(e){j=""}else j=j.replace(/\\r\\n/g,"\\n");return{error:null,isLargeFile:b,isBabelIgnore:h,map:j,code:g.replace(/\r\n/g,"\n"),helpers:y||[]}}module.exports=compileJS;
@@ -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,n=t.length;i<n;i++){const n=t[i].replace(/\.json$/,"");"plugin"!==path_1.default.normalize(n)&&(this.isValidComponent(null===(e=this.project)||void 0===e?void 0:e.pluginRoot,n)&&o.push(n))}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})}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 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 n=e.openDataContext,r={__APP__:[],[n]:[]};i&&(r[i]=[]);for(const t of o)if(n&&(0,tools_1.isLeftSubPathOfRight)(t,n))r[n].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:n,isBabelIgnore:!1});else if(i&&(0,tools_1.isLeftSubPathOfRight)(t,i))r[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)){r[i.root]||(r[e]=[]),r[e].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:i.independent?e:"",isBabelIgnore:!1}),o=!0;break}}if(o)continue}r.__APP__.push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:"",isBabelIgnore:!1})}return r[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,n=t.length;i<n;i++){const n=t[i].replace(/\.json$/,"");this.isValidComponent(null===(e=this.project)||void 0===e?void 0:e.miniprogramRoot,n)&&o.push(n)}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{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,n=t.length;i<n;i++){const n=t[i].replace(/\.json$/,"");"plugin"!==path_1.default.normalize(n)&&(this.isValidComponent(null===(e=this.project)||void 0===e?void 0:e.pluginRoot,n)&&o.push(n))}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})}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 n=e.openDataContext,r={__APP__:[],[n]:[]};i&&(r[i]=[]);for(const t of o)if(n&&(0,tools_1.isLeftSubPathOfRight)(t,n))r[n].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:n,isBabelIgnore:!1});else if(i&&(0,tools_1.isLeftSubPathOfRight)(t,i))r[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)){r[i.root]||(r[e]=[]),r[e].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:i.independent?e:"",isBabelIgnore:!1}),o=!0;break}}if(o)continue}r.__APP__.push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:"",isBabelIgnore:!1})}return r[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,n=t.length;i<n;i++){const n=t[i].replace(/\.json$/,"");this.isValidComponent(null===(e=this.project)||void 0===e?void 0:e.miniprogramRoot,n)&&o.push(n)}return o}}exports.OriginalCompiler=OriginalCompiler;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.messageHandler=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");let summercompileManager,preCompiler,summerProject,precompileProject,inited=!1;function processSend(e){if((0,debug_1.shouldRunInMainProcess)())return e;process.send(e)}async function initHandler(e){const{passData:r,projectInfo:t,options:a}=e.data;if(inited)return;summerProject=new summerCPProject_1.SummerCPProject(t),await summerProject.ready();const{targetPlatform:o,targetPlatformDefines:s}=t;preCompiler=new index_1.PreCompiler(summerProject),precompileProject=await preCompiler.getPreCompileProject({targetPlatform:o,targetPlatformDefines:s,runEnv:"summer cp"});const{cachePath:i}=r;summercompileManager=new summer_1.SummerCompiler(precompileProject,i,a),inited=!0}async function getCodeFiles(e,r,t){let a={};"getDevCodeByFileList"===e?a=await r.run(`getDevCodeByFileList-${t.graphId}-${t.package}`,()=>summercompileManager.getDevCodeByFileList(t,r)):"getCode"===e&&(a=await r.run(`getCode-${t.graphId}-${t.package}`,()=>summercompileManager.getCode(t,r)));const{cacheMd5:o}=t;for(const e of Object.keys(o)){const r=a[e];r?"error"in r||r.md5!==o[e]||delete a[e]:a[e]={path:e,md5:"",code:""}}for(const e of Object.values(a))"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 a}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:a}=e,o=r,s=new progressRecorder_1.Recorder((e,r,t)=>{processSend({type:"progress",id:e,taskId:o,status:r,message:t})});try{let e;if("getCode"===t||"getDevCodeByFileList"===t)e=await getCodeFiles(t,s,a);else if("getPackageFiles"===t)e=await summercompileManager.getPackageFiles(a);else if("getConf"===t)e=await summercompileManager.getConf(a,s);else if("getLocalFileList"===t)e=await summercompileManager.getLocalFileList(a);else if("compile"===t)e=await summercompileManager.compile(a,s);else if("compileSingleCode"===t)e=await summercompileManager.compileSingleCode(a,s);else if("setLocale"===t)(0,index_2.setLocale)(a);else if("clearCache"===t)summercompileManager.clearCache();else{if("loadStatus"!==t)throw new Error("unknown command "+t);e=summercompileManager.getStatus()}return processSend({type:"response",id:r,data:e})}catch(e){return processSend({type:"response",id:r,data:null,error:{code:e.code||-1,message:e.message,stack:e.stack,path:e.path||""}})}}}exports.initHandler=initHandler,exports.messageHandler=messageHandler;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.messageHandler=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");let summercompileManager,summerProject,preCompiler,precompileProject,inited=!1;function processSend(e){if((0,debug_1.shouldRunInMainProcess)())return e;process.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:a,targetPlatformDefines:s}=t;preCompiler=new index_1.PreCompiler(summerProject),precompileProject=await preCompiler.getPreCompileProject({targetPlatform:a,targetPlatformDefines:s,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:a}=t;for(const e of Object.keys(a)){const r=o[e];r?"error"in r||r.md5!==a[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}async function messageHandler(e,r){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:t,name:o,data:a}=e,s=t,i=new progressRecorder_1.Recorder((e,t,o)=>{processSend({type:"progress",id:e,taskId:s,status:t,message:o}),null==r||r(e,t,o)});try{let e;if("getCode"===o||"getDevCodeByFileList"===o)e=await getCodeFiles(o,i,a);else if("getPackageFiles"===o)e=await summercompileManager.getPackageFiles(a,i);else if("getConf"===o)e=await summercompileManager.getConf(a,i);else if("getLocalFileList"===o)e=await summercompileManager.getLocalFileList(a);else if("compile"===o)e=await summercompileManager.compile(a,i);else if("compileNewLogic"===o)e=await summercompileManager.compileNewLogic(a,i);else if("compileSingleCode"===o)e=await summercompileManager.compileSingleCode(a,i);else if("setLocale"===o)(0,index_2.setLocale)(a);else if("clearCache"===o)summercompileManager.clearCache();else{if("loadStatus"!==o)throw new Error("unknown command "+o);e=summercompileManager.getStatus()}return processSend({type:"response",id:t,data:e})}catch(e){return processSend({type:"response",id:t,data:null,error:{code:e.code||-1,message:e.message,stack:e.stack,path:e.path||""}})}}}exports.initHandler=initHandler,exports.destroy=destroy,exports.messageHandler=messageHandler;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppConf=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),baseconf_1=require("./baseconf"),original_1=require("../../original"),common_1=require("../../original/json/common"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),getPageJSON_1=require("../../original/json/page/getPageJSON"),util_1=require("./util");class AppConf extends baseconf_1.MiniProgramBaseConf{constructor(){super(...arguments),this.packages=new Map,this.pages=new Map,this.comps=new Map,this.onFileChange=(t,o)=>{}}destroy(){}async getConf(t){return await this.build(t),{app:this.app,packages:Object.fromEntries(this.packages.entries()),pages:Object.fromEntries(this.pages.entries()),comps:Object.fromEntries(this.comps.entries()),sitemap:this.sitemap,theme:this.theme}}async buildPagesAndCompsForUpload(t,o=!1){const a={},e={};return await Promise.all(Array.from(this.pages.keys()).map(async t=>{const e=await(o?getPageJSON_1.getPageJSONWithDisableSpreading:original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});a[t+".json"]=JSON.stringify(e)})),await Promise.all(Array.from(this.comps.keys()).map(async t=>{const a=await(o?getPageJSON_1.getPageJSONWithDisableSpreading:original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});e[t+".json"]=JSON.stringify(a)})),{pageResults:a,componentResults:e}}async resetState(){this.app=void 0,this.packages.clear(),this.pages.clear(),this.comps.clear(),this.sitemap=void 0,this.theme=void 0}async load(t){const o=await t.run(locales_1.default.config.SUMMER_COMPILE.format("app.json"),()=>(0,original_1.getAppJSON)(this.proxyProject));this.app=o;const a=new Set;for(const t of o.pages)a.add(t);const e=o.subPackages||[];for(const t of e){const o=t.root;this.packages.set(o,t);for(const e of t.pages)a.add(path_1.default.posix.join(o,e))}await t.run(locales_1.default.config.SUMMER_COMPILE_PAGE_JSON.format(a.size),async()=>{var t;for(const[t]of a.entries())(0,util_1.isPluginPath)(t)||await this.loadPage(t);for(const t of Object.values(o.usingComponents||{}))if(!t.startsWith("plugin://")&&!(0,util_1.isPluginPath)(t)){const o=(0,util_1.resolvePath)("app.json",t);await this.loadComp(o,t,"app.json")}if(null===(t=o.tabBar)||void 0===t?void 0:t.custom){const t=(0,util_1.resolvePath)("app.json","custom-tab-bar/index");this.proxyProject.stat(this.root,t+".json")&&await this.loadComp(t,"custom-tab-bar/index","app.json")}if(o.appBar){const t=(0,util_1.resolvePath)("app.json","app-bar/index");this.proxyProject.stat(this.root,t+".json")&&await this.loadComp(t,"app-bar/index","app.json")}if(o.plugins)for(const t of Object.values(o.plugins))t.genericsImplementation&&Object.values(t.genericsImplementation).forEach(t=>{Object.values(t).map(async t=>{const o=(0,util_1.resolvePath)("app.json",t);return await this.loadComp(o,t,"app.json")})})}),o.themeLocation&&await t.run(locales_1.default.config.SUMMER_COMPILE.format(o.themeLocation),()=>this.loadTheme(o.themeLocation)),o.accountCardPackage&&await t.run(locales_1.default.config.SUMMER_COMPILE.format(o.themeLocation),async()=>{for(const t of o.accountCardPackage.cardList){const a=path_1.default.posix.join(o.accountCardPackage.root,t.componentPath);await this.loadComp(a,a,"app.json")}})}async loadPage(t){const o=await(0,original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});this.pages.set(t,o);const a=async o=>{if((0,util_1.isPluginPath)(o))return;const a=(0,util_1.resolvePath)(t,o);await this.loadComp(a,o,t)};if(o.usingComponents)for(const t of Object.values(o.usingComponents))await a(t);if(o.componentGenerics)for(const t of Object.values(o.componentGenerics)){const o=t.default;o&&await a(o)}}async loadComp(t,o,a){if(await this.isExtendedLibComp(t,a))return;if(this.comps.has(t))return;if(!this.proxyProject.stat(this.root,t+".json"))throw new Error(`[summer-compiler] Couldn't found the '${o}.json' file relative to '${a}'`);const e=await(0,original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});this.comps.set(t,e);const s=async o=>{if((0,util_1.isPluginPath)(o))return;const a=(0,util_1.resolvePath)(t,o);await this.loadComp(a,o,t)};if(e.usingComponents)for(const t of Object.values(e.usingComponents))await s(t);if(e.componentGenerics)for(const t of Object.values(e.componentGenerics)){const o=t.default;o&&await s(o)}}async loadTheme(t){const o=await(0,original_1.checkThemeJSON)(this.proxyProject,{themeLocation:t});this.theme=o}async isExtendedLibComp(t,o){if(t.startsWith("miniprogram_npm/")){const a=(0,common_1.getUseExtendLib)(this.proxyProject,o);if(a.length>0){const o=a.map(t=>"miniprogram_npm/"+t);for(const a of o)if(t.startsWith(a))return!0}}return!1}}exports.AppConf=AppConf;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppConf=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),baseconf_1=require("./baseconf"),original_1=require("../../original"),common_1=require("../../original/json/common"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),getPageJSON_1=require("../../original/json/page/getPageJSON"),util_1=require("./util"),taskmanager_1=tslib_1.__importDefault(require("../../../../utils/taskmanager"));class AppConf extends baseconf_1.MiniProgramBaseConf{constructor(){super(...arguments),this.packages=new Map,this.pages=new Map,this.comps=new Map,this.onFileChange=(t,o)=>{}}destroy(){}async getConf(t){return await this.build(t),{app:this.app,packages:Object.fromEntries(this.packages.entries()),pages:Object.fromEntries(this.pages.entries()),comps:Object.fromEntries(this.comps.entries()),sitemap:this.sitemap,theme:this.theme}}async buildPagesAndCompsForUpload(t,o=!1){const a={},e={};return await Promise.all(Array.from(this.pages.keys()).map(async t=>{const e=await(o?getPageJSON_1.getPageJSONWithDisableSpreading:original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});a[t+".json"]=JSON.stringify(e)})),await Promise.all(Array.from(this.comps.keys()).map(async t=>{const a=await(o?getPageJSON_1.getPageJSONWithDisableSpreading:original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});e[t+".json"]=JSON.stringify(a)})),{pageResults:a,componentResults:e}}async buildPagesAndCompsWithFileListForUpload(t,o,a=!1){const e={},s={},i=new taskmanager_1.default;for(const t of Array.from(this.pages.keys()))if(o.includes(t+".json")){const o=async t=>{const o=await(a?getPageJSON_1.getPageJSONWithDisableSpreading:original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});e[t+".json"]=JSON.stringify(o)};i.addTask(o,t)}for(const t of Array.from(this.comps.keys()))if(o.includes(t+".json")){const o=async t=>{const o=await(a?getPageJSON_1.getPageJSONWithDisableSpreading:original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});s[t+".json"]=JSON.stringify(o)};i.addTask(o,t)}return await i.runAllAsync(),{pageResults:e,componentResults:s}}async resetState(){this.app=void 0,this.packages.clear(),this.pages.clear(),this.comps.clear(),this.sitemap=void 0,this.theme=void 0}async load(t){const o=await t.run(locales_1.default.config.SUMMER_COMPILE.format("app.json"),()=>(0,original_1.getAppJSON)(this.proxyProject));this.app=o;const a=new Set;for(const t of o.pages)a.add(t);const e=o.subPackages||[];for(const t of e){const o=t.root;this.packages.set(o,t);for(const e of t.pages)a.add(path_1.default.posix.join(o,e))}await t.run(locales_1.default.config.SUMMER_COMPILE_PAGE_JSON.format(a.size),async()=>{var t;for(const[t]of a.entries())(0,util_1.isPluginPath)(t)||await this.loadPage(t);for(const t of Object.values(o.usingComponents||{}))if(!t.startsWith("plugin://")&&!(0,util_1.isPluginPath)(t)){const o=(0,util_1.resolvePath)("app.json",t);await this.loadComp(o,t,"app.json")}if(null===(t=o.tabBar)||void 0===t?void 0:t.custom){const t=(0,util_1.resolvePath)("app.json","custom-tab-bar/index");this.proxyProject.stat(this.root,t+".json")&&await this.loadComp(t,"custom-tab-bar/index","app.json")}if(o.appBar){const t=(0,util_1.resolvePath)("app.json","app-bar/index");this.proxyProject.stat(this.root,t+".json")&&await this.loadComp(t,"app-bar/index","app.json")}if(o.plugins)for(const t of Object.values(o.plugins))t.genericsImplementation&&Object.values(t.genericsImplementation).forEach(t=>{Object.values(t).map(async t=>{const o=(0,util_1.resolvePath)("app.json",t);return await this.loadComp(o,t,"app.json")})})}),o.themeLocation&&await t.run(locales_1.default.config.SUMMER_COMPILE.format(o.themeLocation),()=>this.loadTheme(o.themeLocation)),o.accountCardPackage&&await t.run(locales_1.default.config.SUMMER_COMPILE.format(o.themeLocation),async()=>{for(const t of o.accountCardPackage.cardList){const a=path_1.default.posix.join(o.accountCardPackage.root,t.componentPath);await this.loadComp(a,a,"app.json")}})}async loadPage(t){const o=await(0,original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});this.pages.set(t,o);const a=async o=>{if((0,util_1.isPluginPath)(o))return;const a=(0,util_1.resolvePath)(t,o);await this.loadComp(a,o,t)};if(o.usingComponents)for(const t of Object.values(o.usingComponents))await a(t);if(o.componentGenerics)for(const t of Object.values(o.componentGenerics)){const o=t.default;o&&await a(o)}}async loadComp(t,o,a){if(await this.isExtendedLibComp(t,a))return;if(this.comps.has(t))return;if(!this.proxyProject.stat(this.root,t+".json"))throw new Error(`[summer-compiler] Couldn't found the '${o}.json' file relative to '${a}'`);const e=await(0,original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});this.comps.set(t,e);const s=async o=>{if((0,util_1.isPluginPath)(o))return;const a=(0,util_1.resolvePath)(t,o);await this.loadComp(a,o,t)};if(e.usingComponents)for(const t of Object.values(e.usingComponents))await s(t);if(e.componentGenerics)for(const t of Object.values(e.componentGenerics)){const o=t.default;o&&await s(o)}}async loadTheme(t){const o=await(0,original_1.checkThemeJSON)(this.proxyProject,{themeLocation:t});this.theme=o}async isExtendedLibComp(t,o){if(t.startsWith("miniprogram_npm/")){const a=(0,common_1.getUseExtendLib)(this.proxyProject,o);if(a.length>0){const o=a.map(t=>"miniprogram_npm/"+t);for(const a of o)if(t.startsWith(a))return!0}}return!1}}exports.AppConf=AppConf;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppGraph=void 0;const tools_1=require("../../../../utils/tools"),mpjson_1=require("../../original/compile/handler/mpjson"),config_1=require("../../../../config/config"),progressRecorder_1=require("../../../../utils/progressRecorder"),white_ext_list_1=require("../../../../utils/white_ext_list"),appconf_1=require("./appconf"),basegraph_1=require("./basegraph");class AppGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.appConf=new appconf_1.AppConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.MiniProgramWhiteList}return this._whiteListConfig}destroy(){this.appConf.destroy(),super.destroy()}async getConf(e){return this.conf=await this.appConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const s=this.resolver.resolveInfoMap.get(e);if(s)return super.doCompileSingleCode(Object.assign(Object.assign({},s),{independentRoot:this.getIndependentRoot(s.path),isBabelIgnore:this.isBabelSettingIgnore(s)}),t);throw new Error("file not found")}async getDevCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e)}async getDevCodeByFileList(e,t){let s=await this.getPackageFile(config_1.FullPkg);return s=s.filter(e=>!e.path.endsWith("json")).filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(s,e)}async getProdCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e,Object.assign(Object.assign({},t),{useCache:!1}))}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){this.appConf.onFileChange(e,t)}getIndependentRoot(e){for(const t of Object.values(this.conf.packages))if(!0===t.independent){const s=t.root.replace(/^\//,"");if(e.startsWith(s))return s}if("object"==typeof this.conf.app.functionalPages&&!0===this.conf.app.functionalPages.independent&&e.startsWith("functional-pages/"))return"functional-pages";if("string"==typeof this.conf.app.openDataContext&&e.startsWith(this.conf.app.openDataContext))return this.conf.app.openDataContext;const t=this.conf.app.workers&&(0,tools_1.getWorkersPath)(this.conf.app.workers);return t&&e.startsWith(t)?t:""}checkFilePackage(e){for(const t of Object.keys(this.conf.packages))if(e.startsWith(t))return t;return config_1.MainPkg}async compileJSON(e,t){const s=await this.getConf(progressRecorder_1.silentRecorder),o={};o["app.json"]=JSON.stringify(s.app);const{pageResults:i,componentResults:n}=await this.appConf.buildPagesAndCompsForUpload(progressRecorder_1.silentRecorder,e.disableSpreadingUsingComponents);return(0,mpjson_1.addSkylineRendererToComponents)(i,n),{conf:s,jsons:Object.assign(Object.assign(Object.assign({},o),i),n)}}}exports.AppGraph=AppGraph;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppGraph=void 0;const tools_1=require("../../../../utils/tools"),mpjson_1=require("../../original/compile/handler/mpjson"),config_1=require("../../../../config/config"),progressRecorder_1=require("../../../../utils/progressRecorder"),white_ext_list_1=require("../../../../utils/white_ext_list"),appconf_1=require("./appconf"),basegraph_1=require("./basegraph");class AppGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.appConf=new appconf_1.AppConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.MiniProgramWhiteList}return this._whiteListConfig}destroy(){this.appConf.destroy(),super.destroy()}async getConf(e){return this.conf=await this.appConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const s=this.resolver.resolveInfoMap.get(e);if(s)return super.doCompileSingleCode(Object.assign(Object.assign({},s),{independentRoot:this.getIndependentRoot(s.path),isBabelIgnore:this.isBabelSettingIgnore(s)}),t);throw new Error("file not found")}async getDevCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e)}async getProdCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e,Object.assign(Object.assign({},t),{useCache:!1,resultType:"prod"}))}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){this.appConf.onFileChange(e,t)}getIndependentRoot(e){for(const t of Object.values(this.conf.packages))if(!0===t.independent){const s=t.root.replace(/^\//,"");if(e.startsWith(s))return s}if("object"==typeof this.conf.app.functionalPages&&!0===this.conf.app.functionalPages.independent&&e.startsWith("functional-pages/"))return"functional-pages";if("string"==typeof this.conf.app.openDataContext&&e.startsWith(this.conf.app.openDataContext))return this.conf.app.openDataContext;const t=this.conf.app.workers&&(0,tools_1.getWorkersPath)(this.conf.app.workers);return t&&e.startsWith(t)?t:""}checkFilePackage(e){for(const t of Object.keys(this.conf.packages))if(e.startsWith(t))return t;return config_1.MainPkg}async compileJSON(e,t){const s=await this.getConf(progressRecorder_1.silentRecorder),o={};o["app.json"]=JSON.stringify(s.app);const{pageResults:n,componentResults:i}=await this.appConf.buildPagesAndCompsForUpload(progressRecorder_1.silentRecorder,e.disableSpreadingUsingComponents);return(0,mpjson_1.addSkylineRendererToComponents)(n,i),{conf:s,jsons:Object.assign(Object.assign(Object.assign({},o),n),i)}}async compileJSONWithFileList(e,t){const s=await this.getConf(progressRecorder_1.silentRecorder),o={};o["app.json"]=JSON.stringify(s.app);const{pageResults:n,componentResults:i}=await this.appConf.buildPagesAndCompsWithFileListForUpload(progressRecorder_1.silentRecorder,e.fileList,e.disableSpreadingUsingComponents);return(0,mpjson_1.addSkylineRendererToComponents)(n,i),{conf:s,jsons:Object.assign(Object.assign(Object.assign({},o),n),i)}}}exports.AppGraph=AppGraph;
@@ -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"),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.onFileAndDirChange=()=>{this.resolver.updateFileAndDirs()},this.getCodeFileTask=async(e,t,o={useCache:!0})=>{const i=await this.loadModuleFromFile(e,t,o),r=i.toCodeFile();if(!("error"in r)&&"prod"===o.resultType){const e=i.toGenerateResult(),t=await this.optimize(e,o),s=await this.compress(t,o);r.code=s.target.code,r.map=s.target.map}return{file:e,codeFile:r,process:i.processInfo||[]}},this.type=e.type,this.root=e.root,this.rootPath=path_1.default.posix.join(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)}async loadModuleFromFile(e,t,o={}){var i;let r=this.modulesByPath.get(e.path);if(null==r?void 0:r.loadingPromise)return await r.loadingPromise,this.loadModuleFromFile(e,t,o);let s=!r||r.sourcePath!==e.source||r.independentRoot!==e.independentRoot;if(!s&&(null==r?void 0:r.error)){if(r.loadEnd+1e3>Date.now())return r;s=!0}if(s){const s=getFileType(e.path);r=new module_1.default(this,e.path,e.source,s),r.independentRoot=e.independentRoot,e.isBabelIgnore&&(null===(i=r.jsTag)||void 0===i||i.setBabelIgnore()),this.modulesByPath.set(e.path,r),r.loadingPromise=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),()=>this.loadSourceForModule(r,o)),await r.loadingPromise,r.loadingPromise=void 0}return r}async loadSourceForModule(e,t={}){var o,i;try{const r=path_1.default.posix.join(this.rootPath,e.sourcePath),s=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))}}),a=null!==(i=await this.pluginDriver.hookFirst("load",[e.path,r,Object.assign(Object.assign({},t),{independentRoot:e.independentRoot,isBabelIgnore:(null===(o=e.jsTag)||void 0===o?void 0:o.isBabelIgnore)||!1})],s))&&void 0!==i?i:{targetPath:e.path,source:{sourceCode:await this.readFile(r)},process:[{pluginName:"readFile",action:"load"}]},n=await this.tranform(a,e,s,t),l=await this.generate(n,e,s,t);return e.setResult(l),!0}catch(t){return t.path=path_1.default.posix.join(this.root,e.sourcePath),e.setError(t),!1}}async doCompileSingleCode(e,t){const o=getFileType(e.path),i=new module_1.default(this,e.path,e.source,o);if(await this.loadSourceForModule(i),i.error)throw i.error;return i.toCodeFile()}async getCodeFiles(e,t,o={useCache:!0,resultType:"dev"}){const i=Date.now(),r={},s=new taskmanager_1.default({poolLimit:10,breakWhenError:!0});for(const i of e)s.addTask(this.getCodeFileTask,i,t,o);const a=await s.runAllAsync();for(const e of a)r[e.file.path]=e.codeFile;return console.info("!!!",`getCodeFiles: count: ${e.length}, cost: ${Date.now()-i}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,o,i={}){var r;return await this.pluginDriver.hookReduceArg0("transform",[e,t.path,t.sourcePath,Object.assign(Object.assign({},i),{independentRoot:t.independentRoot,isBabelIgnore:(null===(r=t.jsTag)||void 0===r?void 0:r.isBabelIgnore)||!1})],(function(e,t){return void 0===t?e:t}),o)}async generate(e,t,o,i={}){var r;const s=await this.pluginDriver.hookFirst("generate",[e,t.path,t.sourcePath,Object.assign(Object.assign({},i),{independentRoot:t.independentRoot,isBabelIgnore:(null===(r=t.jsTag)||void 0===r?void 0:r.isBabelIgnore)||!1})]);return void 0===s||(0,lodash_1.isNull)(s)?Object.assign(Object.assign({},e),{target:{code:e.source.sourceCode,map:e.source.inputMap}}):s}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))),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 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){const t=new Set(this.resolver.allExts.map(e=>"."+e));t.delete(".json");const 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)}),r=await(0,common_1.compileOther)(this.project,i,{onProgressUpdate:()=>{}}),s={};for(const t in r){const o=path_1.default.posix.relative(this.root,t);e.includes(o)||(s[o]=r[t])}return s}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}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}}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,i={useCache:!0,resultType:"dev"})=>{const o=await this.loadModuleFromFile(e,t,i),s=o.toCodeFile();if(!("error"in s)&&"prod"===i.resultType){const e=o.toGenerateResult(),t=await this.optimize(e,i),r=await this.compress(t,i);s.code=r.target.code,s.map=r.target.map}return{file:e,codeFile:s,process:o.processInfo||[]}},this.type=e.type,this.root=e.root,this.rootPath=path_1.default.posix.join(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)}async loadModuleFromFile(e,t,i={}){var o;let s=this.modulesByPath.get(e.path);if(null==s?void 0:s.loadingPromise)return await s.loadingPromise,this.loadModuleFromFile(e,t,i);let r=!s||s.sourcePath!==e.source||s.independentRoot!==e.independentRoot;if(!r&&(null==s?void 0:s.error)){if(s.loadEnd+1e3>Date.now())return s;r=!0}if(r){const r=getFileType(e.path);s=new module_1.default(this,e.path,e.source,r),s.independentRoot=e.independentRoot,e.isBabelIgnore&&(null===(o=s.jsTag)||void 0===o||o.setBabelIgnore()),this.modulesByPath.set(e.path,s),s.loadingPromise=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),()=>this.loadSourceForModule(s,i)),await s.loadingPromise,s.loadingPromise=void 0}return s}async loadSourceForModule(e,t={}){var i,o;try{const s=path_1.default.posix.join(this.rootPath,e.sourcePath),r=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))}}),a=null!==(o=await this.pluginDriver.hookFirst("load",[e.path,s,Object.assign(Object.assign({},t),{independentRoot:e.independentRoot,isBabelIgnore:(null===(i=e.jsTag)||void 0===i?void 0:i.isBabelIgnore)||!1})],r))&&void 0!==o?o:{targetPath:e.path,source:{sourceCode:await this.readFile(s)},process:[{pluginName:"readFile",action:"load"}]},l=await this.tranform(a,e,r,t),n=await this.generate(l,e,r,t);return e.setResult(n),!0}catch(t){return t.path=path_1.default.posix.join(this.root,e.sourcePath),e.setError(t),!1}}async doCompileSingleCode(e,t){const i=getFileType(e.path),o=new module_1.default(this,e.path,e.source,i);if(await this.loadSourceForModule(o),o.error)throw o.error;return o.toCodeFile()}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 l=await a.runAllAsync();for(const e of l)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={}){var s;return await this.pluginDriver.hookReduceArg0("transform",[e,t.path,t.sourcePath,Object.assign(Object.assign({},o),{independentRoot:t.independentRoot,isBabelIgnore:(null===(s=t.jsTag)||void 0===s?void 0:s.isBabelIgnore)||!1})],(function(e,t){return void 0===t?e:t}),i)}async generate(e,t,i,o={}){var s;const r=await this.pluginDriver.hookFirst("generate",[e,t.path,t.sourcePath,Object.assign(Object.assign({},o),{independentRoot:t.independentRoot,isBabelIgnore:(null===(s=t.jsTag)||void 0===s?void 0:s.isBabelIgnore)||!1})]);return void 0===r||(0,lodash_1.isNull)(r)?Object.assign(Object.assign({},e),{target:{code:e.source.sourceCode,map:e.source.inputMap}}):r}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:"prod"})}}exports.BaseGraph=BaseGraph;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GameGraph=void 0;const tools_1=require("../../../../utils/tools"),config_1=require("../../../../config/config"),white_ext_list_1=require("../../../../utils/white_ext_list"),progressRecorder_1=require("../../../../utils/progressRecorder"),gameconf_1=require("./gameconf"),basegraph_1=require("./basegraph");class GameGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.appConf=new gameconf_1.GameConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.GameWhiteList}return this._whiteListConfig}destroy(){this.appConf.destroy(),super.destroy()}async getConf(e){return this.conf=await this.appConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const s=this.resolver.resolveInfoMap.get(e);if(s)return super.doCompileSingleCode(Object.assign(Object.assign({},s),{independentRoot:this.getIndependentRoot(s.path),isBabelIgnore:this.isBabelSettingIgnore(s)}),t);throw new Error("file not found")}async getDevCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e)}async getDevCodeByFileList(e,t){let s=await this.getPackageFile(config_1.FullPkg);return s=s.filter(e=>!e.path.endsWith("json")).filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(s,e)}async getProdCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e,Object.assign(Object.assign({},t),{useCache:!1}))}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){this.appConf.onFileChange(e,t)}getIndependentRoot(e){for(const t of Object.values(this.conf.packages))if(!0===t.independent){const s=t.root.replace(/^\//,"");if(e.startsWith(s))return s}if("string"==typeof this.conf.app.openDataContext&&e.startsWith(this.conf.app.openDataContext))return this.conf.app.openDataContext;const t=this.conf.app.workers&&(0,tools_1.getWorkersPath)(this.conf.app.workers);return t&&e.startsWith(t)?t:""}checkFilePackage(e){for(const t of Object.keys(this.conf.packages))if(e.startsWith(t))return t;return config_1.MainPkg}async compileJSON(e,t){const s=await this.getConf(progressRecorder_1.silentRecorder),i={};return i["game.json"]=JSON.stringify(s.app),{conf:s,jsons:Object.assign({},i)}}}exports.GameGraph=GameGraph;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GameGraph=void 0;const tools_1=require("../../../../utils/tools"),config_1=require("../../../../config/config"),white_ext_list_1=require("../../../../utils/white_ext_list"),progressRecorder_1=require("../../../../utils/progressRecorder"),gameconf_1=require("./gameconf"),basegraph_1=require("./basegraph");class GameGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.appConf=new gameconf_1.GameConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.GameWhiteList}return this._whiteListConfig}destroy(){this.appConf.destroy(),super.destroy()}async getConf(e){return this.conf=await this.appConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const s=this.resolver.resolveInfoMap.get(e);if(s)return super.doCompileSingleCode(Object.assign(Object.assign({},s),{independentRoot:this.getIndependentRoot(s.path),isBabelIgnore:this.isBabelSettingIgnore(s)}),t);throw new Error("file not found")}async getDevCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e)}async getProdCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e,Object.assign(Object.assign({},t),{useCache:!1}))}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){this.appConf.onFileChange(e,t)}getIndependentRoot(e){for(const t of Object.values(this.conf.packages))if(!0===t.independent){const s=t.root.replace(/^\//,"");if(e.startsWith(s))return s}if("string"==typeof this.conf.app.openDataContext&&e.startsWith(this.conf.app.openDataContext))return this.conf.app.openDataContext;const t=this.conf.app.workers&&(0,tools_1.getWorkersPath)(this.conf.app.workers);return t&&e.startsWith(t)?t:""}checkFilePackage(e){for(const t of Object.keys(this.conf.packages))if(e.startsWith(t))return t;return config_1.MainPkg}async compileJSON(e,t){const s=await this.getConf(progressRecorder_1.silentRecorder),o={};return o["game.json"]=JSON.stringify(s.app),{conf:s,jsons:Object.assign({},o)}}async compileJSONWithFileList(e,t){return this.compileJSON(e,t)}}exports.GameGraph=GameGraph;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GamePluginGraph=void 0;const progressRecorder_1=require("../../../../utils/progressRecorder"),white_ext_list_1=require("../../../../utils/white_ext_list"),basegraph_1=require("./basegraph"),gamepluginconf_1=require("./gamepluginconf"),config_1=require("../../../../config/config");class GamePluginGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.pluginConf=new gamepluginconf_1.GamePluginConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.GameWhiteList}return this._whiteListConfig}destroy(){this.pluginConf.destroy(),super.destroy()}async getConf(e){if("plugin"!==this.type)throw new Error("Couldn't call getAppConf without plugin type");return this.conf=await this.pluginConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const i=this.resolver.resolveInfoMap.get(e);if(i)return super.doCompileSingleCode(Object.assign(Object.assign({},i),{independentRoot:this.getIndependentRoot(i.path),isBabelIgnore:this.isBabelSettingIgnore(i)}),t);throw new Error("file not found")}async getDevCode(e){let t=await this.getPackageFile();return t=t.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(t,e)}async getDevCodeByFileList(e,t){let i=await this.getPackageFile();return i=i.filter(e=>!e.path.endsWith("json")).filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(i,e)}async getProdCode(e,t){let i=await this.getPackageFile();return i=i.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(i,e,{useCache:!1,resultType:t.resultType})}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){}async getPackageFile(){await this.ensureConf(progressRecorder_1.silentRecorder);const e=[];for(const[t,i]of this.resolver.resolveInfoMap.entries())e.push(i);return e.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path),isBabelIgnore:this.isBabelSettingIgnore(e)}))}checkFilePackage(e){return config_1.MainPkg}getIndependentRoot(e){const t=this.conf.plugin;return"string"==typeof t.workers&&e.startsWith(t.workers)?t.workers:""}async compileJSON(){const e=await this.getConf(progressRecorder_1.silentRecorder),t={};return t["plugin.json"]=JSON.stringify(e.plugin),{conf:e,jsons:t}}}exports.GamePluginGraph=GamePluginGraph;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GamePluginGraph=void 0;const progressRecorder_1=require("../../../../utils/progressRecorder"),white_ext_list_1=require("../../../../utils/white_ext_list"),basegraph_1=require("./basegraph"),gamepluginconf_1=require("./gamepluginconf"),config_1=require("../../../../config/config");class GamePluginGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.pluginConf=new gamepluginconf_1.GamePluginConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.GameWhiteList}return this._whiteListConfig}destroy(){this.pluginConf.destroy(),super.destroy()}async getConf(e){if("plugin"!==this.type)throw new Error("Couldn't call getAppConf without plugin type");return this.conf=await this.pluginConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const i=this.resolver.resolveInfoMap.get(e);if(i)return super.doCompileSingleCode(Object.assign(Object.assign({},i),{independentRoot:this.getIndependentRoot(i.path),isBabelIgnore:this.isBabelSettingIgnore(i)}),t);throw new Error("file not found")}async getDevCode(e){let t=await this.getPackageFile(config_1.FullPkg);return t=t.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(t,e)}async getProdCode(e,t){let i=await this.getPackageFile(config_1.FullPkg);return i=i.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(i,e,{useCache:!1,resultType:t.resultType})}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){}async getPackageFile(e){await this.ensureConf(progressRecorder_1.silentRecorder);const t=[];for(const[e,i]of this.resolver.resolveInfoMap.entries())t.push(i);return t.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path),isBabelIgnore:this.isBabelSettingIgnore(e)}))}checkFilePackage(e){return config_1.MainPkg}getIndependentRoot(e){const t=this.conf.plugin;return"string"==typeof t.workers&&e.startsWith(t.workers)?t.workers:""}async compileJSON(){const e=await this.getConf(progressRecorder_1.silentRecorder),t={};return t["plugin.json"]=JSON.stringify(e.plugin),{conf:e,jsons:t}}async compileJSONWithFileList(){return this.compileJSON()}}exports.GamePluginGraph=GamePluginGraph;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PluginGraph=void 0;const progressRecorder_1=require("../../../../utils/progressRecorder"),white_ext_list_1=require("../../../../utils/white_ext_list"),basegraph_1=require("./basegraph"),pluginconf_1=require("./pluginconf"),config_1=require("../../../../config/config");class PluginGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.pluginConf=new pluginconf_1.PluginConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.MiniProgramWhiteList}return this._whiteListConfig}destroy(){this.pluginConf.destroy(),super.destroy()}async getConf(e){if("plugin"!==this.type)throw new Error("Couldn't call getAppConf without plugin type");return this.conf=await this.pluginConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const i=this.resolver.resolveInfoMap.get(e);if(i)return super.doCompileSingleCode(Object.assign(Object.assign({},i),{independentRoot:this.getIndependentRoot(i.path),isBabelIgnore:this.isBabelSettingIgnore(i)}),t);throw new Error("file not found")}async getDevCode(e){let t=await this.getPackageFile();return t=t.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(t,e)}async getDevCodeByFileList(e,t){let i=await this.getPackageFile();return i=i.filter(e=>!e.path.endsWith("json")).filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(i,e)}async getProdCode(e,t){let i=await this.getPackageFile();return i=i.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(i,e,{useCache:!1,resultType:t.resultType})}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){}async getPackageFile(){await this.ensureConf(progressRecorder_1.silentRecorder);const e=[];for(const[t,i]of this.resolver.resolveInfoMap.entries())e.push(i);return e.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path),isBabelIgnore:this.isBabelSettingIgnore(e)}))}getIndependentRoot(e){const t=this.conf.plugin;return"string"==typeof t.workers&&e.startsWith(t.workers)?t.workers:""}checkFilePackage(e){return config_1.MainPkg}async compileJSON(){const e=await this.getConf(progressRecorder_1.silentRecorder),t={};t["plugin.json"]=JSON.stringify(e.plugin);for(const i in e.pages)t[i+".json"]=JSON.stringify(e.pages[i]);for(const i in e.comps)t[i+".json"]=JSON.stringify(e.comps[i]);return{conf:e,jsons:t}}}exports.PluginGraph=PluginGraph;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PluginGraph=void 0;const progressRecorder_1=require("../../../../utils/progressRecorder"),white_ext_list_1=require("../../../../utils/white_ext_list"),basegraph_1=require("./basegraph"),pluginconf_1=require("./pluginconf"),config_1=require("../../../../config/config");class PluginGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.pluginConf=new pluginconf_1.PluginConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.MiniProgramWhiteList}return this._whiteListConfig}destroy(){this.pluginConf.destroy(),super.destroy()}async getConf(e){if("plugin"!==this.type)throw new Error("Couldn't call getAppConf without plugin type");return this.conf=await this.pluginConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const i=this.resolver.resolveInfoMap.get(e);if(i)return super.doCompileSingleCode(Object.assign(Object.assign({},i),{independentRoot:this.getIndependentRoot(i.path),isBabelIgnore:this.isBabelSettingIgnore(i)}),t);throw new Error("file not found")}async getDevCode(e){let t=await this.getPackageFile(config_1.FullPkg);return t=t.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(t,e)}async getProdCode(e,t){let i=await this.getPackageFile(config_1.FullPkg);return i=i.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(i,e,{useCache:!1,resultType:t.resultType})}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){}async getPackageFile(e){await this.ensureConf(progressRecorder_1.silentRecorder);const t=[];for(const[e,i]of this.resolver.resolveInfoMap.entries())t.push(i);return t.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path),isBabelIgnore:this.isBabelSettingIgnore(e)}))}getIndependentRoot(e){const t=this.conf.plugin;return"string"==typeof t.workers&&e.startsWith(t.workers)?t.workers:""}checkFilePackage(e){return config_1.MainPkg}async compileJSON(){const e=await this.getConf(progressRecorder_1.silentRecorder),t={};t["plugin.json"]=JSON.stringify(e.plugin);for(const i in e.pages)t[i+".json"]=JSON.stringify(e.pages[i]);for(const i in e.comps)t[i+".json"]=JSON.stringify(e.comps[i]);return{conf:e,jsons:t}}async compileJSONWithFileList(){return this.compileJSON()}}exports.PluginGraph=PluginGraph;
@@ -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")),inputsourcemap_1=require("../../utils/inputsourcemap");function default_1(e){return{name:"summer-javascript",async load(t,r){if(r.endsWith(".js")){const a=path_1.default.relative(e.projectPath,r),u=e.getFile("",a).toString(),i=await(0,inputsourcemap_1.tryGetInputSourceMap)(u,r);return{targetPath:t,source:{sourceCode:u,inputMap:null!=i?i:void 0,astInfo:void 0,largeFile:u.length>=exports.MAX_CODE_LENGTH},process:[{pluginName:"summer-javascript",action:"load"}]}}}}}exports.MAX_CODE_LENGTH=2048e3,exports.default=default_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=path_1.default.relative(e.projectPath,r),o=e.getFile("",i).toString(),u=await(0,inputsourcemap_1.tryGetInputSourceMap)(o,r);return{targetPath:t,source:{sourceCode:o,inputMap:null!=u?u:void 0,astInfo:void 0,largeFile:o.length>=config_1.MAX_CODE_LENGTH},process:[{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 +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")),tools_1=require("../../../../../utils/tools"),swc_helper_1=require("../../../../../utils/swc_helper"),inputsourcemap_1=require("../../utils/inputsourcemap"),swc=()=>require("@swc/core");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){var o,i;const n=r.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=r.rc)||void 0===o?void 0:o.parser),{syntax:t.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:!n,noInterop:!0,allowTopLevelThis:n},null===(i=r.rc)||void 0===i?void 0:i.module),inputSourceMap:e.inputMap?JSON.stringify(e.inputMap):void 0,sourceMaps:!0,filename:t,minify:r.minify}),c=(0,swc_helper_1.replaceSWCHelpers)(a.code,t,s);return{code:c.transformCode,map:a.map?JSON.parse(a.map):void 0,helpers:c.helpers,resultType:r.resultType}}},async load(t,s){if(!t.endsWith(".js"))return;const r=path_1.default.relative(e.projectPath,s),o=e.getFile("",r).toString(),i=await(0,inputsourcemap_1.tryGetInputSourceMap)(o,s);return{targetPath:t,source:{sourceCode:o,inputMap:null!=i?i:void 0,astInfo:void 0,largeFile:o.length>=exports.MAX_CODE_LENGTH},process:[{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 p=getSWCRoot(e,i),u={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},l=await this.runWorkerMethod("doGenerate",s.source,o,p,u);return Object.assign(Object.assign({},s),{target:l,process:[...s.process,{pluginName:"summer-swc",action:"transform",options:u}]})}}}exports.MAX_CODE_LENGTH=2048e3,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=()=>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: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=path_1.default.relative(e.projectPath,r),o=e.getFile("",s).toString(),i=await(0,inputsourcemap_1.tryGetInputSourceMap)(o,r);return{targetPath:t,source:{sourceCode:o,inputMap:null!=i?i:void 0,astInfo:void 0,largeFile:o.length>=config_1.MAX_CODE_LENGTH},process:[{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=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},l=await this.runWorkerMethod("doGenerate",r.source,o,u,p);return Object.assign(Object.assign({},r),{target:l,process:[...r.process,{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}),exports.SummerCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(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");let proxyProject;function initProxyProjectForJSON(i){if(proxyProject&&proxyProject.projectPath!==i.projectPath&&(proxyProject.clearResolver(),proxyProject=void 0),!proxyProject){let t={};function e(e,r){const o=i.stat(e,r);if(o)return o;const p=i.getTargetPath(e,r);for(const i in t)if(p.startsWith(i))return t[i].stat(path_1.default.posix.relative(i,p))}proxyProject=new Proxy(i,{get:(i,t,r)=>"stat"===t?e:Reflect.get(i,t,r)}),proxyProject.addResolver=i=>{(0,reactiveCache_1.cleanReactiveCache)(),t[i.root]=i},proxyProject.removeResolver=i=>{(0,reactiveCache_1.cleanReactiveCache)(),delete t[i.root]},proxyProject.clearResolver=()=>{t={},(0,reactiveCache_1.cleanReactiveCache)()}}return proxyProject}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.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}){var t;return this.isPluginType(i)?null===(t=this.pluginGraph)||void 0===t?void 0:t.getPackageFile():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 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[path_1.default.posix.join(this.project.miniprogramRoot,i)]=t[i]}),Object.keys(o).forEach(i=>{r[path_1.default.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.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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),request_1=require("../../utils/request"),progressRecorder_1=require("../../utils/progressRecorder"),tools_1=require("../../utils/tools"),config_1=require("../../config/config"),processManager_1=require("../../utils/subprocess/processManager"),messageHub_1=require("../../utils/messageHub"),uglifyfilenames_1=require("./original/protect/uglifyfilenames"),index_1=require("./original/index"),baseCompiler_1=require("./baseCompiler"),miniProgram=config_1.COMPILE_TYPE.miniProgram,miniGame=config_1.COMPILE_TYPE.miniGame,miniProgramPlugin=config_1.COMPILE_TYPE.miniProgramPlugin,miniGamePlugin=config_1.COMPILE_TYPE.miniGamePlugin;function performanceMark(e,t){}class SummerCompiler extends baseCompiler_1.BaseCoreCompiler{constructor(e,t,i,s){super(e),this.project=e,this.cachePath=t,this.projectInfo=i,this.devtoolMessagehub=s,this.isSummer=!0,this.codeCache=new Map,this.promiseCache=new Map,this._status=void 0,this._eventAdded=!1,this._locale="",this.codeCacheByPath=new Map,this.onFileChange=(e,t)=>{if("change"!==e||t.endsWith(".json"))for(const e of this.promiseCache.keys())e.startsWith("getConf-")&&this.promiseCache.delete(e);if("change"!==e)for(const e of this.promiseCache.keys())e.startsWith("getPackageFiles-")&&this.promiseCache.delete(e);this.invalidCodeCache(t),this.subProcessManager.sendEvent("fileChange",{type:e,targetPath:t})},this.onPreCompileOptionsChange=async e=>{await this.clearCache(),this.subProcessManager.sendEvent("precompileOptionsChange",e)},this.onProgressUpdate=(e,t,i)=>{const s="doing"===t?"doing":"done"===t?"success":"error";this.messageHub.showBuildLog(""+e,s,i)},performanceMark("create summer compiler"),this.messageHub=new messageHub_1.MessageHub(s),this.ready()}get status(){return this._status}async init(){performanceMark("init summer compiler");const e=path_1.default.posix.join(__dirname,"./summerEntryProcess.js");this.subProcessManager=new processManager_1.SubProcessProxy(this.project,e,{cachePath:this.cachePath},this.projectInfo,8891),this.addProjectListener(),this.loadStatus(),performanceMark("init summer compiler",!0)}async loadStatus(){this._status=await this.subProcessManager.runTask("loadStatus")}destroy(){var e;null===(e=this.subProcessManager)||void 0===e||e.destroy(),this.removeProjectListener(),this._checkReadyTask=void 0}async clearCache(){var e;await(null===(e=this.subProcessManager)||void 0===e?void 0:e.runTask("clearCache")),this.codeCache.clear(),this.promiseCache.clear(),this.codeCacheByPath.clear()}updateOptions(e){var t;lodash_1.default.isEqual(e,this.projectInfo)||(this.projectInfo=e,this.promiseCache.clear(),this.codeCache.clear(),this.codeCacheByPath.clear(),null===(t=this.subProcessManager)||void 0===t||t.sendEvent("updateOptions",e),this.loadStatus())}addProjectListener(){var e,t;this._eventAdded&&this.removeProjectListener(),null===(e=this.project.event)||void 0===e||e.on("fileChange",this.onFileChange),null===(t=this.project.event)||void 0===t||t.on("precompileOptionsChange",this.onPreCompileOptionsChange),this._eventAdded=!0}removeProjectListener(){var e,t;null===(e=this.project.event)||void 0===e||e.off("fileChange",this.onFileChange),null===(t=this.project.event)||void 0===t||t.off("precompileOptionsChange",this.onPreCompileOptionsChange),this._eventAdded=!1}invalidCodeCache(e){for(const e of this.codeCache.values())e.isValid=!1;this.codeCacheByPath.delete((0,tools_1.sourcePathToTargetPath)(e))}async getConf(e){var t,i;const s="getConf-"+e;if(this.promiseCache.has(s))return(null===(t=process.env)||void 0===t?void 0:t.isDevtools)&&console.log(s,"hit cache"),this.promiseCache.get(s);(null===(i=process.env)||void 0===i?void 0:i.isDevtools)&&console.log(s,"do request"),performanceMark("request get conf");const o={graphId:e},r=this.subProcessManager.runTask("getConf",o,this.onProgressUpdate);return this.promiseCache.set(s,r),performanceMark("request get conf",!0),r}async getPackageFiles(e,t){var i,s;const o=`getPackageFiles-${e}-${t}`;if(this.promiseCache.has(o))return(null===(i=process.env)||void 0===i?void 0:i.isDevtools)&&console.log(o,"hit cache"),this.promiseCache.get(o);(null===(s=process.env)||void 0===s?void 0:s.isDevtools)&&console.log(o,"do request"),performanceMark("request get getPackageFiles");const r=this.subProcessManager.runTask("getPackageFiles",{graphId:e,root:t},this.onProgressUpdate);return this.promiseCache.set(o,r),performanceMark("request get getPackageFiles",!0),r}async getCodeByFileList(e,t){const i={},s={},o=this.isPluginType(e)?this.project.pluginRoot:this.project.miniprogramRoot;for(const e of t){const t=this.codeCacheByPath.get(path_1.default.posix.join(o,e));t&&("error"in t||(i[e]=t.md5,s[e]=t))}const r=await this.subProcessManager.runTask("getDevCodeByFileList",{graphId:e,fileList:t,cacheMd5:i},this.onProgressUpdate);console.error(r);for(const e in r){const t=r[e],i=path_1.default.posix.join(o,e);"error"in t||""!==t.md5?this.codeCacheByPath.set(i,t):this.codeCacheByPath.delete(i),s[e]=t}return s}async getCode(e,t){var i,s,o;const r=`getCode-${e}${t?"-"+t.package:""}`;if(this.promiseCache.has(r))return(null===(i=process.env)||void 0===i?void 0:i.isDevtools)&&console.log(r,"hit promise cache"),this.promiseCache.get(r);const a=this.codeCache.get(r);if(null==a?void 0:a.isValid)return a.codeFiles;(null===(s=process.env)||void 0===s?void 0:s.isDevtools)&&console.log(r,"do request");const n={};if(a){const{codeFiles:e}=a;for(const t of Object.keys(e)){const i=e[t];"error"in i||(n[t]=i.md5)}}const c={graphId:e,cacheMd5:n,package:null==t?void 0:t.package};performanceMark("request get code");const l=Date.now();(null===(o=process.env)||void 0===o?void 0:o.isDevtools)&&(console.time("[summer-compiler] runTask "+r),console.log(`[summer-compiler] [${(0,progressRecorder_1.getPrintTime)()}] runTask ${r}`));const g=this.subProcessManager.runTask("getCode",c,this.onProgressUpdate).then(e=>{var t,i;(null===(t=process.env)||void 0===t?void 0:t.isDevtools)&&console.timeEnd("[summer-compiler] runTask "+r);const s=(null===(i=this.codeCache.get(r))||void 0===i?void 0:i.codeFiles)||{};for(const t of Object.keys(e)){const i=e[t];"error"in i||""!==i.md5?s[t]=i:delete s[t]}return this.codeCache.set(r,{isValid:!0,codeFiles:s}),s},e=>{throw e.code?console.error(e):console.error("Unexpected error when getCode",e),e});return g.finally(()=>{var e;performanceMark("request get code",!0),(null===(e=process.env)||void 0===e?void 0:e.isDevtools)&&console.log(`[summer-compiler] [${(0,progressRecorder_1.getPrintTime)()}] [cost ${Date.now()-l}ms] runTask ${r}`),this.promiseCache.delete(r)}),this.promiseCache.set(r,g),g}async getExtJSON(){return await(0,index_1.getExtJSON)(this.project)}async getAppJSON(){return(await this.getConf(miniProgram)).app}async getGameJSON(){return(await this.getConf(miniGame)).app}async getSiteMapJSON(){return(await this.getConf(miniProgram)).sitemap}async getPageJSON(e){const t=await this.getConf(miniProgram),i=t.pages[e]||t.comps[e];if(!i)throw new Error("summer-compiler 收集json配置有遗漏, "+e);return i}async getAllPageAndComponent(){const e=await this.getConf(miniProgram);return Object.keys(e.pages).concat(Object.keys(e.comps))}async getAllSortedJSFiles(){const e=await this.getConf(miniProgram),t=Object.keys(e.pages),i=Object.keys(e.comps),s=t.filter(e=>!i.includes(e)).map(e=>e+".js"),o=i.map(e=>e+".js"),r=await this.getCode(miniProgram,{package:config_1.FullPkg}),a=Object.keys(r).filter(e=>e.endsWith(".js")&&"app.js"!==e&&!s.includes(e)&&!o.includes(e));return{jsPagesFiles:s,components:o,otherJsFiles:a}}async getAllWxmlAndWxsFiles(){const e=await this.getCode(miniProgram,{package:config_1.FullPkg}),t=Object.keys(e).filter(e=>e.endsWith(".wxml")),i=Object.keys(e).filter(e=>e.endsWith(".wxs"));return{wxmlFiles:t,wxsFiles:i,content:t.concat(i).reduce((t,i)=>{const s=e[i];if("error"in s)throw s.error;return t[i]=s.code,t["./"+i]=s.code,t},{})}}async getPackageWxmlAndWxsFiles(e){let t=(await this.getPackageFiles(miniProgram,e)).map(e=>e.path);if(e!==config_1.MainPkg){const e=(await this.getPackageFiles(miniProgram,config_1.MainPkg)).map(e=>e.path);t=t.concat(e)}const i=t.filter(e=>e.endsWith(".wxml")),s=t.filter(e=>e.endsWith(".wxs")),o=await this.getCodeByFileList(miniProgram,i.concat(s));return{wxmlFiles:i,wxsFiles:s,content:i.concat(s).reduce((e,t)=>{const i=o[t];if(!i)throw`lack of ${t} code`;if("error"in i)throw i.error;return e[t]=i.code,e["./"+t]=i.code,e},{})}}async getPackageWxssFiles(e){let t=(await this.getPackageFiles(miniProgram,e)).map(e=>e.path);if(e!==config_1.MainPkg){const e=(await this.getPackageFiles(miniProgram,config_1.MainPkg)).map(e=>e.path);t=t.concat(e)}const i=t.filter(e=>e.endsWith(".wxss")),s=await this.getCodeByFileList(miniProgram,i);return{wxssFiles:i,content:i.reduce((e,t)=>{const i=s[t];if(!i)throw`lack of ${t} code`;if("error"in i)throw i.error;return e[t]=i.code,e["./"+t]=i.code,e},{})}}getWxssMap(e,t){t=(0,tools_1.normalizePath)(t);for(const[i,s]of this.codeCache.entries())if(i.startsWith("getCode-"+e)){const e=s.codeFiles[t];if(e&&!("error"in e))return e.map}}async getMainPkgSortedJSFiles(){const e=await this.getConf(miniProgram),t=(await this.getPackageFiles(miniProgram,config_1.MainPkg)).map(e=>e.path).filter(e=>e.endsWith(".js")),i=[],s=[],o=[],r=[],a=[];let n=!1;const c={},l=t=>Object.keys(e.packages).find(e=>t.startsWith(e))||config_1.MainPkg;e.app.functionalPages&&t.forEach(e=>{if(e.startsWith("functional-pages/")){const t=e.replace(/\.js$/,"");if(c[t])return;c[t]=!0,a.push(encodeURI(t))}}),e.app.workers&&t.forEach(t=>{if(t.startsWith((0,tools_1.getWorkersPath)(e.app.workers))){const e=t.replace(/\.js$/,"");if(c[e])return;c[e]=!0,r.push(e)}});Object.keys(e.comps).filter(e=>l(e)===config_1.MainPkg).forEach(t=>{if((t.startsWith("miniprogram_npm/weui-miniprogram")||t.startsWith("weui-miniprogram"))&&e.app.useExtendedLib&&e.app.useExtendedLib.weui)return;if(c[t])return;c[t]=!0;const i=encodeURI(t);o.push(""+i)});Object.keys(e.pages).filter(e=>l(e)===config_1.MainPkg).forEach(e=>{if(c[e])return;c[e]=!0;const t=encodeURI(e);i.push(""+t)}),t.forEach(e=>{const t=e.replace(/\.js$/,"");c[t]||(c[t]=!0,"app.js"!==e?s.push(""+encodeURI(t)):n=!0)});const g=[...s,...o,...i];return n&&g.push("app"),{hasAppJS:n,allFiles:g,pageFiles:i,componentFiles:o,workerFiles:r,functionalPageFiles:a,otherFiles:s}}async getSubPkgSortedJSFiles(e){const t=await this.getConf(miniProgram),i=(await this.getPackageFiles(miniProgram,e)).map(e=>e.path).filter(e=>e.endsWith(".js")),s=[],o=[],r=[],a={},n=e=>Object.keys(t.packages).find(t=>e.startsWith(t))||config_1.MainPkg;Object.keys(t.comps).filter(t=>n(t)===e).forEach(e=>{if((e.startsWith("miniprogram_npm/weui-miniprogram")||e.startsWith("weui-miniprogram"))&&t.app.useExtendedLib&&t.app.useExtendedLib.weui)return;if(a[e])return;a[e]=!0;const i=encodeURI(e);r.push(""+i)});Object.keys(t.pages).filter(t=>n(t)===e).forEach(e=>{if(a[e])return;a[e]=!0;const t=encodeURI(e);s.push(""+t)});let c=t.packages[e].entry||"";c&&(c=path_1.default.join(e,c),c=c.replace(/\.js$/,"")),i.forEach(e=>{const t=e.replace(/\.js$/,"");a[t]||(a[t]=!0,t!==c&&o.push(""+encodeURI(t)))});const l=i.map(e=>""+encodeURI(e.replace(/\.js$/,"")));return{entryJS:c,allFiles:l,pageFiles:s,componentFiles:r,otherFiles:o}}async compileJSList(e){const t=this.project.type;let i=config_1.COMPILE_TYPE.miniProgram;i=e.root===this.project.miniprogramRoot?this.isGameType(t)?config_1.COMPILE_TYPE.miniGame:config_1.COMPILE_TYPE.miniProgram:this.isGameType(t)?config_1.COMPILE_TYPE.miniGamePlugin:miniProgramPlugin;const s=await this.getCodeByFileList(i,e.fileList),o=[];for(const e in s){const t=s[e];if("error"in t)throw t.error;o.push(Object.assign({filePath:e,code:t.code,map:t.map},t.jsTag))}return o}async compileJS(e){const t=this.project.type;let i;if(e.root===this.project.miniprogramRoot){i=(await this.getCodeByFileList(this.isGameType(t)?config_1.COMPILE_TYPE.miniGame:config_1.COMPILE_TYPE.miniProgram,[e.filePath]))[e.filePath]}else{i=(await this.getCodeByFileList(this.isGameType(t)?config_1.COMPILE_TYPE.miniGamePlugin:miniProgramPlugin,[e.filePath]))[e.filePath]}if(!i){const t=new Error(`summer-compiler miss ${e.root} js file, ${e.filePath}`);throw t.code="ENOENT",t}if("error"in i)throw i.error;return Object.assign({filePath:e.filePath,code:i.code,map:i.map},i.jsTag)}async compile(e){const t=await this.subProcessManager.runTask("compile",e,(t,i,s)=>{var o;null===(o=e.onProgressUpdate)||void 0===o||o.call(e,{id:t.toString(),status:i,message:s})});for(const e of Object.keys(t))"object"==typeof t[e]&&"Buffer"===t[e].type&&(t[e]=Buffer.from(t[e].data));return t}async getPluginJSON(e=""){return(await this.getConf(this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin)).plugin}async getPluginPageJSON(e){const t=await this.getConf(miniProgramPlugin),i=t.pages[e]||t.comps[e];if(!i)throw new Error("summer-compiler 收集plugin json配置有遗漏, "+e);return i}async getPluginComponents(){const e=await this.getConf(miniProgramPlugin),t=new Set(Object.keys(e.pages).concat(Object.keys(e.comps)));return Array.from(t)}async getPluginJSFiles(){const e=this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin,t=(await this.getPackageFiles(e,config_1.FullPkg)).map(e=>e.path).filter(e=>e.endsWith(".js")),i=await this.getCodeByFileList(e,t);return{jsFiles:t,content:t.reduce((e,t)=>{const s=i[t];if(!s)throw`lack of ${t} code`;if("error"in s)throw s.error;return e[t]=s.code,e["./"+t]=s.code,e},{})}}async getPluginWxssFiles(){const e=(await this.getPackageFiles(miniProgramPlugin,config_1.FullPkg)).map(e=>e.path).filter(e=>e.endsWith(".wxss")),t=await this.getCodeByFileList(miniProgramPlugin,e);return{wxssFiles:e,content:e.reduce((e,i)=>{const s=t[i];if(!s)throw`lack of ${i} code`;if("error"in s)throw s.error;return e[i]=s.code,e["./"+i]=s.code,e},{})}}async getPluginWxmlAndWxsFiles(){const e=(await this.getPackageFiles(miniProgramPlugin,config_1.FullPkg)).map(e=>e.path),t=e.filter(e=>e.endsWith(".wxml")),i=e.filter(e=>e.endsWith(".wxs")),s=await this.getCodeByFileList(miniProgramPlugin,t.concat(i));return{wxmlFiles:t,wxsFiles:i,content:t.concat(i).reduce((e,t)=>{const i=s[t];if(!i)throw`lack of ${t} code`;if("error"in i)throw i.error;return e[t]=i.code,e["./"+t]=i.code,e},{})}}async checkThemeJSON(e){return(await this.getConf(miniProgram)).theme}setProxy(e){(0,request_1.setCiProxy)(e)}setLocale(e){this._locale!==e&&(this._locale=e,this.subProcessManager.runTask("setLocale",e))}async uglifyFileNames(e,t,i){return await(0,uglifyfilenames_1.uglifyFileNames)(e,t,i)}async getMPFileInfo(){return this.subProcessManager.runTask("getLocalFileList",miniProgram)}async getPluginFileInfo(){return this.subProcessManager.runTask("getLocalFileList",miniProgramPlugin)}async getCompAndPagesOfConf(){const e=await this.getConf(miniProgram);return{pages:e.pages,comps:e.comps}}}exports.SummerCompiler=SummerCompiler;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),request_1=require("../../utils/request"),progressRecorder_1=require("../../utils/progressRecorder"),common_1=require("./original/compile/common"),tools_1=require("../../utils/tools"),white_ext_list_1=require("../../utils/white_ext_list"),config_1=require("../../config/config"),processManager_1=require("../../utils/subprocess/processManager"),messageHub_1=require("../../utils/messageHub"),singletontask_1=require("../../utils/singletontask"),uglifyfilenames_1=require("./original/protect/uglifyfilenames"),index_1=require("./original/index"),baseCompiler_1=require("./baseCompiler"),packOptionsHelper_1=tslib_1.__importDefault(require("../../utils/packOptionsHelper")),miniProgram=config_1.COMPILE_TYPE.miniProgram,miniGame=config_1.COMPILE_TYPE.miniGame,miniProgramPlugin=config_1.COMPILE_TYPE.miniProgramPlugin,miniGamePlugin=config_1.COMPILE_TYPE.miniGamePlugin;function performanceMark(e,t){}class SummerCompiler extends baseCompiler_1.BaseCoreCompiler{constructor(e,t,i,s,o,r){super(e),this.project=e,this.cachePath=t,this.projectInfo=i,this.devtoolMessagehub=s,this.analyzer=o,this._filterFactory=r,this.isSummer=!0,this.codeCache=new Map,this.promiseCache=new Map,this._taskCache=new Map,this._status=void 0,this._eventAdded=!1,this._locale="",this.codeCacheByPath=new Map,this.onFileChange=(e,t)=>{if("change"!==e||t.endsWith(".json"))for(const e of this.promiseCache.keys())e.startsWith("getConf-")&&this.promiseCache.delete(e);if("change"!==e){for(const e of this.promiseCache.keys())e.startsWith("getPackageFiles-")&&this.promiseCache.delete(e);for(const e of this._taskCache.keys())e.startsWith("getPackageFiles-")&&this._taskCache.delete(e)}this.invalidCodeCache(t),this.subProcessManager.sendEvent("fileChange",{type:e,targetPath:t})},this.onPreCompileOptionsChange=async e=>{await this.clearCache(),this.subProcessManager.sendEvent("precompileOptionsChange",e)},this.onProgressUpdate=(e,t,i)=>{const s="warn"===t?"warn":"doing"===t?"doing":"done"===t?"success":"error";this.messageHub.showBuildLog(""+e,s,i)},this._getPackageFiles=async(e,t,i="dev")=>{performanceMark("request get getPackageFiles");const s=await this.subProcessManager.runTask("getPackageFiles",{graphId:e,root:t},this.onProgressUpdate);performanceMark("request get getPackageFiles",!0);const o=this.isPluginType(e)?this.project.pluginRoot:this.project.miniprogramRoot,r=await this.filterFactory(i),a={},n=s.filter(t=>{const i=path_1.default.posix.join(o,t.path),s=r(e,i);return s!==config_1.EFilterCode.Include&&(a[s]||(a[s]=[]),a[s].push(i)),s===config_1.EFilterCode.Include}),c={[config_1.EFilterCode.AnalyseNoUse]:locales_1.default.config.UNUSE_FILE_LIST,[config_1.EFilterCode.PackOptionsIgnore]:locales_1.default.config.PACK_OPTIONS_IGNORE_LIST,[config_1.EFilterCode.PartialCompileNoUse]:locales_1.default.config.PARTIAL_COMPILE_IGNORE_LIST};for(const e in a)c[e]?this.onProgressUpdate(e,"warn",c[e].format(a[e].join(","))):this.onProgressUpdate(e,"warn",locales_1.default.config.UNKNOWN_REASON_INGORE_LIST.format(e,a[e].join(",")));return n},performanceMark("create summer compiler"),this.messageHub=new messageHub_1.MessageHub(s),this.ready()}get status(){return this._status}async init(){performanceMark("init summer compiler");const e=path_1.default.posix.join(__dirname,"./summerEntryProcess.js");this.subProcessManager=new processManager_1.SubProcessProxy(this.project,e,{cachePath:this.cachePath},this.projectInfo,8891),this.addProjectListener(),this.loadStatus(),performanceMark("init summer compiler",!0)}async loadStatus(){this._status=await this.subProcessManager.runTask("loadStatus")}destroy(){var e;null===(e=this.subProcessManager)||void 0===e||e.destroy(),this.removeProjectListener(),this._checkReadyTask=void 0}async clearCache(){var e;await(null===(e=this.subProcessManager)||void 0===e?void 0:e.runTask("clearCache")),this.codeCache.clear(),this.promiseCache.clear(),this.codeCacheByPath.clear(),this._taskCache.clear()}updateOptions(e){var t;lodash_1.default.isEqual(e,this.projectInfo)||(this.projectInfo=e,this.promiseCache.clear(),this.codeCache.clear(),this.codeCacheByPath.clear(),null===(t=this.subProcessManager)||void 0===t||t.sendEvent("updateOptions",e),this.loadStatus(),this.project.updateOptions(e))}addProjectListener(){var e,t;this._eventAdded&&this.removeProjectListener(),null===(e=this.project.event)||void 0===e||e.on("fileChange",this.onFileChange),null===(t=this.project.event)||void 0===t||t.on("precompileOptionsChange",this.onPreCompileOptionsChange),this._eventAdded=!0}removeProjectListener(){var e,t;null===(e=this.project.event)||void 0===e||e.off("fileChange",this.onFileChange),null===(t=this.project.event)||void 0===t||t.off("precompileOptionsChange",this.onPreCompileOptionsChange),this._eventAdded=!1}invalidCodeCache(e){for(const e of this.codeCache.values())e.isValid=!1;this.codeCacheByPath.delete((0,tools_1.sourcePathToTargetPath)(e))}async getConf(e){var t,i;const s="getConf-"+e;if(this.promiseCache.has(s))return(null===(t=process.env)||void 0===t?void 0:t.isDevtools)&&console.log(s,"hit cache"),this.promiseCache.get(s);(null===(i=process.env)||void 0===i?void 0:i.isDevtools)&&console.log(s,"do request"),performanceMark("request get conf");const o={graphId:e},r=this.subProcessManager.runTask("getConf",o,this.onProgressUpdate);return this.promiseCache.set(s,r),performanceMark("request get conf",!0),r}async getPackageFiles(e,t,i="dev",s=!0){const o=`getPackageFiles-${e}-${t}-${i}`;if(this._taskCache.has(o)&&s){const e=this._taskCache.get(o);return null==e?void 0:e.getResult(!0)}const r=new singletontask_1.SingletonTask(this._getPackageFiles.bind(this,e,t,i),o);return this._taskCache.set(o,r),null==r?void 0:r.getResult(!0)}async filterFactory(e){packOptionsHelper_1.default.updateState(this.project),this.onProgressUpdate("initUnusedFiles","doing","analyzing codes..."),await packOptionsHelper_1.default.initUnusedFiles(this.project,this.analyzer,"prod"===e),this.onProgressUpdate("initUnusedFiles","done","analyzing codes success");const t=this._filterFactory?await this._filterFactory(e):()=>0;return(i,s)=>"mini-android"!==this.project.targetPlatform&&"mini-ios"!==this.project.targetPlatform||path_1.default.posix.join(this.project.miniprogramRoot,"app.miniapp.json")!==s?i===miniProgram&&packOptionsHelper_1.default.isIgnoreByUnusedFiles(s,"prod"===e)?config_1.EFilterCode.AnalyseNoUse:packOptionsHelper_1.default.isIgnoredByRules(s)?config_1.EFilterCode.PackOptionsIgnore:t(i,s):config_1.EFilterCode.Include}async getCodeByFileList(e,t){const i={},s={},o=this.isPluginType(e)?this.project.pluginRoot:this.project.miniprogramRoot;for(const e of t){const t=this.codeCacheByPath.get(path_1.default.posix.join(o,e));t&&("error"in t||(i[e]=t.md5,s[e]=t))}const r=await this.subProcessManager.runTask("getDevCodeByFileList",{graphId:e,fileList:t,cacheMd5:i},this.onProgressUpdate);console.error(r);for(const e in r){const t=r[e],i=path_1.default.posix.join(o,e);"error"in t||""!==t.md5?this.codeCacheByPath.set(i,t):this.codeCacheByPath.delete(i),s[e]=t}return s}async getCode(e,t){var i,s,o;const r=`getCode-${e}${t?"-"+t.package:""}`;if(this.promiseCache.has(r))return(null===(i=process.env)||void 0===i?void 0:i.isDevtools)&&console.log(r,"hit promise cache"),this.promiseCache.get(r);const a=this.codeCache.get(r);if(null==a?void 0:a.isValid)return a.codeFiles;(null===(s=process.env)||void 0===s?void 0:s.isDevtools)&&console.log(r,"do request");const n={};if(a){const{codeFiles:e}=a;for(const t of Object.keys(e)){const i=e[t];"error"in i||(n[t]=i.md5)}}const c={graphId:e,cacheMd5:n,package:null==t?void 0:t.package};performanceMark("request get code");const l=Date.now();(null===(o=process.env)||void 0===o?void 0:o.isDevtools)&&(console.time("[summer-compiler] runTask "+r),console.log(`[summer-compiler] [${(0,progressRecorder_1.getPrintTime)()}] runTask ${r}`));const g=this.subProcessManager.runTask("getCode",c,this.onProgressUpdate).then(e=>{var t,i;(null===(t=process.env)||void 0===t?void 0:t.isDevtools)&&console.timeEnd("[summer-compiler] runTask "+r);const s=(null===(i=this.codeCache.get(r))||void 0===i?void 0:i.codeFiles)||{};for(const t of Object.keys(e)){const i=e[t];"error"in i||""!==i.md5?s[t]=i:delete s[t]}return this.codeCache.set(r,{isValid:!0,codeFiles:s}),s},e=>{throw e.code?console.error(e):console.error("Unexpected error when getCode",e),e});return g.finally(()=>{var e;performanceMark("request get code",!0),(null===(e=process.env)||void 0===e?void 0:e.isDevtools)&&console.log(`[summer-compiler] [${(0,progressRecorder_1.getPrintTime)()}] [cost ${Date.now()-l}ms] runTask ${r}`),this.promiseCache.delete(r)}),this.promiseCache.set(r,g),g}async getExtJSON(){return await(0,index_1.getExtJSON)(this.project)}async getAppJSON(){return(await this.getConf(miniProgram)).app}async getGameJSON(){return(await this.getConf(miniGame)).app}async getSiteMapJSON(){return(await this.getConf(miniProgram)).sitemap}async getPageJSON(e){const t=await this.getConf(miniProgram),i=t.pages[e]||t.comps[e];if(!i)throw new Error("summer-compiler 收集json配置有遗漏, "+e);return i}async getAllPageAndComponent(){const e=await this.getConf(miniProgram),t=(await this.getPackageFiles(miniProgram,config_1.FullPkg)).map(e=>e.path).filter(e=>e.endsWith(".json"));return Object.keys(e.pages).concat(Object.keys(e.comps)).filter(e=>t.includes(e+".json"))}async getAllSortedJSFiles(){const e=await this.getConf(miniProgram),t=Object.keys(e.pages),i=Object.keys(e.comps),s=(await this.getPackageFiles(miniProgram,config_1.FullPkg)).map(e=>e.path).filter(e=>e.endsWith(".js")),o=t.filter(e=>!i.includes(e)).map(e=>e+".js").filter(e=>s.includes(e)),r=i.map(e=>e+".js").filter(e=>s.includes(e)),a=s.filter(e=>e.endsWith(".js")&&"app.js"!==e&&!o.includes(e)&&!r.includes(e));return{jsPagesFiles:o,components:r,otherJsFiles:a}}async getAllWxmlAndWxsFiles(){const e=await this.getCode(miniProgram,{package:config_1.FullPkg}),t=Object.keys(e).filter(e=>e.endsWith(".wxml")),i=Object.keys(e).filter(e=>e.endsWith(".wxs"));return{wxmlFiles:t,wxsFiles:i,content:t.concat(i).reduce((t,i)=>{const s=e[i];if("error"in s)throw s.error;return t[i]=s.code,t["./"+i]=s.code,t},{})}}async getPackageWxmlAndWxsFiles(e){let t=(await this.getPackageFiles(miniProgram,e)).map(e=>e.path);if(e!==config_1.MainPkg&&e!==config_1.FullPkg){const e=(await this.getPackageFiles(miniProgram,config_1.MainPkg)).map(e=>e.path);t=t.concat(e)}const i=t.filter(e=>e.endsWith(".wxml")),s=t.filter(e=>e.endsWith(".wxs")),o=await this.getCodeByFileList(miniProgram,i.concat(s));return{wxmlFiles:i,wxsFiles:s,content:i.concat(s).reduce((e,t)=>{const i=o[t];if(!i)throw`lack of ${t} code`;if("error"in i)throw i.error;return e[t]=i.code,e["./"+t]=i.code,e},{})}}async getPackageWxssFileList(e){let t=(await this.getPackageFiles(miniProgram,e)).map(e=>e.path);if(e!==config_1.MainPkg&&e!==config_1.FullPkg){const e=(await this.getPackageFiles(miniProgram,config_1.MainPkg)).map(e=>e.path);t=t.concat(e)}return t.filter(e=>e.endsWith(".wxss"))}async getPackageWxssFiles(e){const t=await this.getPackageWxssFileList(e),i=await this.getCodeByFileList(miniProgram,t);return{wxssFiles:t,content:t.reduce((e,t)=>{const s=i[t];if(!s)throw`lack of ${t} code`;if("error"in s)throw s.error;return e[t]=s.code,e["./"+t]=s.code,e},{})}}getWxssMap(e,t){t=(0,tools_1.normalizePath)(t);for(const[i,s]of this.codeCache.entries())if(i.startsWith("getCode-"+e)){const e=s.codeFiles[t];if(e&&!("error"in e))return e.map}}async getMainPkgSortedJSFiles(){const e=await this.getConf(miniProgram),t=(await this.getPackageFiles(miniProgram,config_1.MainPkg)).map(e=>e.path).filter(e=>e.endsWith(".js")),i=[],s=[],o=[],r=[],a=[];let n=!1;const c={},l=t=>Object.keys(e.packages).find(e=>t.startsWith(e))||config_1.MainPkg;e.app.functionalPages&&t.forEach(e=>{if(e.startsWith("functional-pages/")){const t=e.replace(/\.js$/,"");if(c[t])return;c[t]=!0,a.push(encodeURI(t))}}),e.app.workers&&t.forEach(t=>{if(t.startsWith((0,tools_1.getWorkersPath)(e.app.workers))){const e=t.replace(/\.js$/,"");if(c[e])return;c[e]=!0,r.push(e)}});Object.keys(e.comps).filter(e=>l(e)===config_1.MainPkg).forEach(t=>{if((t.startsWith("miniprogram_npm/weui-miniprogram")||t.startsWith("weui-miniprogram"))&&e.app.useExtendedLib&&e.app.useExtendedLib.weui)return;if(c[t])return;c[t]=!0;const i=encodeURI(t);o.push(""+i)});Object.keys(e.pages).filter(e=>l(e)===config_1.MainPkg).forEach(e=>{if(c[e])return;c[e]=!0;const t=encodeURI(e);i.push(""+t)}),t.forEach(e=>{const t=e.replace(/\.js$/,"");c[t]||(c[t]=!0,"app.js"!==e?s.push(""+encodeURI(t)):n=!0)});const g=[...s,...o,...i];return n&&g.push("app"),{hasAppJS:n,allFiles:g,pageFiles:i,componentFiles:o,workerFiles:r,functionalPageFiles:a,otherFiles:s}}async getSubPkgSortedJSFiles(e){const t=await this.getConf(miniProgram),i=(await this.getPackageFiles(miniProgram,e)).map(e=>e.path).filter(e=>e.endsWith(".js")),s=[],o=[],r=[],a={},n=e=>Object.keys(t.packages).find(t=>e.startsWith(t))||config_1.MainPkg;Object.keys(t.comps).filter(t=>n(t)===e).forEach(e=>{if((e.startsWith("miniprogram_npm/weui-miniprogram")||e.startsWith("weui-miniprogram"))&&t.app.useExtendedLib&&t.app.useExtendedLib.weui)return;if(a[e])return;a[e]=!0;const i=encodeURI(e);r.push(""+i)});Object.keys(t.pages).filter(t=>n(t)===e).forEach(e=>{if(a[e])return;a[e]=!0;const t=encodeURI(e);s.push(""+t)});let c=t.packages[e].entry||"";c&&(c=path_1.default.join(e,c),c=c.replace(/\.js$/,"")),i.forEach(e=>{const t=e.replace(/\.js$/,"");a[t]||(a[t]=!0,t!==c&&o.push(""+encodeURI(t)))});const l=i.map(e=>""+encodeURI(e.replace(/\.js$/,"")));return{entryJS:c,allFiles:l,pageFiles:s,componentFiles:r,otherFiles:o}}async compileJSList(e){const t=this.project.type;let i=config_1.COMPILE_TYPE.miniProgram;i=e.root===this.project.miniprogramRoot?this.isGameType(t)?config_1.COMPILE_TYPE.miniGame:config_1.COMPILE_TYPE.miniProgram:this.isGameType(t)?config_1.COMPILE_TYPE.miniGamePlugin:miniProgramPlugin;const s=await this.getCodeByFileList(i,e.fileList),o=[];for(const e in s){const t=s[e];if("error"in t)throw t.error;o.push(Object.assign({filePath:e,code:t.code,map:t.map},t.jsTag))}return o}async compileJS(e){const t=this.project.type;let i;if(e.root===this.project.miniprogramRoot){i=(await this.getCodeByFileList(this.isGameType(t)?config_1.COMPILE_TYPE.miniGame:config_1.COMPILE_TYPE.miniProgram,[e.filePath]))[e.filePath]}else{i=(await this.getCodeByFileList(this.isGameType(t)?config_1.COMPILE_TYPE.miniGamePlugin:miniProgramPlugin,[e.filePath]))[e.filePath]}if(!i){const t=new Error(`summer-compiler miss ${e.root} js file, ${e.filePath}`);throw t.code="ENOENT",t}if("error"in i)throw i.error;return Object.assign({filePath:e.filePath,code:i.code,map:i.map},i.jsTag)}async compile(e){Date.now();const t=(await this.getPackageFiles(this.isGameType(this.project.type)?miniGame:miniProgram,config_1.FullPkg,e.resultType,e.useCache)).map(e=>e.path),i=await this.subProcessManager.runTask("compileNewLogic",Object.assign(Object.assign({},e),{fileList:t}),this.onProgressUpdate),s=i.app,o=Object.keys(s).filter(e=>e.endsWith(".json"));this.onProgressUpdate(111,"doing","打包资源文件");const r=await this.compileOther(this.isGameType(this.project.type)?miniGame:miniProgram,e.resultType||"prod",o);let a={};if(this.isPluginType(this.project.type)){const t=i.plugin,o=Object.keys(t).filter(e=>e.endsWith(".json")),n=await this.compileOther(this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin,e.resultType||"prod",o);Object.keys(r).forEach(e=>{a[path_1.default.posix.join("miniprogram",e)]=r[e]}),Object.keys(n).forEach(e=>{a[path_1.default.posix.join("plugin",e)]=n[e]}),Object.keys(s).forEach(e=>{a[path_1.default.posix.join("miniprogram",e)]=s[e]}),Object.keys(t).forEach(e=>{a[path_1.default.posix.join("plugin",e)]=t[e]}),a["project.config.json"]=JSON.stringify({miniprogramRoot:"miniprogram",pluginRoot:"plugin",__compileDebugInfo__:{useSummer:!0}})}else a=Object.assign(Object.assign({},r),s),a["project.config.json"]=JSON.stringify({miniprogramRoot:"",__compileDebugInfo__:{useSummer:!0}});this.onProgressUpdate(111,"done","打包资源文件完成");for(const e of Object.keys(a))"object"==typeof a[e]&&"Buffer"===a[e].type&&(a[e]=Buffer.from(a[e].data));return a}async compileOther(e,t,i){const s=(0,tools_1.getSupportCodeFileExtSet)(this.project);s.delete(".json");const o=await(0,white_ext_list_1.getWhiteExtList)();let r=o.MiniProgramWhiteList;this.isGameType(this.project.type)&&(r=o.GameWhiteList);const a=this.isPluginType(e)?this.project.pluginRoot:this.project.miniprogramRoot,n=await this.filterFactory(t),c=this.project.getFileList(a,"").filter(t=>{const o=path_1.default.posix.extname(t),c=path_1.default.posix.relative(a,t);return!(!r.has(o)||s.has(o)||i.includes(c))&&n(e,t)===config_1.EFilterCode.Include}),l=await(0,common_1.compileOther)(this.project,c,{onProgressUpdate:()=>{}}),g={};for(const e in l){g[path_1.default.posix.relative(a,e)]=l[e]}return g}async compile2(e){const t=await this.subProcessManager.runTask("compile",e,(t,i,s)=>{var o;null===(o=e.onProgressUpdate)||void 0===o||o.call(e,{id:t.toString(),status:i,message:s})});for(const e of Object.keys(t))"object"==typeof t[e]&&"Buffer"===t[e].type&&(t[e]=Buffer.from(t[e].data));return t}async getPluginJSON(e=""){return(await this.getConf(this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin)).plugin}async getPluginPageJSON(e){const t=await this.getConf(miniProgramPlugin),i=t.pages[e]||t.comps[e];if(!i)throw new Error("summer-compiler 收集plugin json配置有遗漏, "+e);return i}async getPluginComponents(){const e=await this.getConf(miniProgramPlugin),t=new Set(Object.keys(e.pages).concat(Object.keys(e.comps)));return Array.from(t)}async getPluginJSFiles(){const e=this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin,t=(await this.getPackageFiles(e,config_1.FullPkg)).map(e=>e.path).filter(e=>e.endsWith(".js")),i=await this.getCodeByFileList(e,t);return{jsFiles:t,content:t.reduce((e,t)=>{const s=i[t];if(!s)throw`lack of ${t} code`;if("error"in s)throw s.error;return e[t]=s.code,e["./"+t]=s.code,e},{})}}async getPluginWxssFiles(){const e=(await this.getPackageFiles(miniProgramPlugin,config_1.FullPkg)).map(e=>e.path).filter(e=>e.endsWith(".wxss")),t=await this.getCodeByFileList(miniProgramPlugin,e);return{wxssFiles:e,content:e.reduce((e,i)=>{const s=t[i];if(!s)throw`lack of ${i} code`;if("error"in s)throw s.error;return e[i]=s.code,e["./"+i]=s.code,e},{})}}async getPluginWxmlAndWxsFiles(){const e=(await this.getPackageFiles(miniProgramPlugin,config_1.FullPkg)).map(e=>e.path),t=e.filter(e=>e.endsWith(".wxml")),i=e.filter(e=>e.endsWith(".wxs")),s=await this.getCodeByFileList(miniProgramPlugin,t.concat(i));return{wxmlFiles:t,wxsFiles:i,content:t.concat(i).reduce((e,t)=>{const i=s[t];if(!i)throw`lack of ${t} code`;if("error"in i)throw i.error;return e[t]=i.code,e["./"+t]=i.code,e},{})}}async checkThemeJSON(e){return(await this.getConf(miniProgram)).theme}setProxy(e){(0,request_1.setCiProxy)(e)}setLocale(e){this._locale!==e&&(this._locale=e,this.subProcessManager.runTask("setLocale",e))}async uglifyFileNames(e,t,i){return await(0,uglifyfilenames_1.uglifyFileNames)(e,t,i)}async getMPFileInfo(){return this.subProcessManager.runTask("getLocalFileList",miniProgram)}async getPluginFileInfo(){return this.subProcessManager.runTask("getLocalFileList",miniProgramPlugin)}async getCompAndPagesOfConf(){const e=await this.getConf(miniProgram);return{pages:e.pages,comps:e.comps}}async getFiltedFileListReason(e){const t=this.project.getFileList(this.project.miniprogramRoot),i=[],s=await this.filterFactory(e),o=this.isGameType(this.project.type)?miniGame:miniProgram;for(const e of t){const t=s(o,e);t!==config_1.EFilterCode.Include&&i.push({file:e,code:t})}if(this.isPluginType(this.project.type)){const e=this.project.getFileList(this.project.pluginRoot),t=this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin;for(const o of e){const e=s(t,o);e!==config_1.EFilterCode.Include&&i.push({file:o,code:e})}}return i}}exports.SummerCompiler=SummerCompiler;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSummerCompiler=exports.summerCompilerFactory=exports.SummerCompilerFactory=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),config_1=require("../config/config"),ciProject_1=require("../project/ciProject"),tools_1=require("../utils/tools"),locales_1=tslib_1.__importDefault(require("../utils/locales/locales")),packOptionsHelper_1=tslib_1.__importDefault(require("../utils/packOptionsHelper")),summerCompiler_1=require("./corecompiler/summerCompiler"),pluginconfig_1=require("./corecompiler/summer/pluginconfig"),WeappCompileCache="";class SummerCompilerFactory{constructor(){this.summerCompiler=null,this.project=null,this.createPromise=null,this.releaseCbs=[]}async getSummerCompiler(e){return this.shouldCreate(e)?(this.releaseLastCompiler(),this.project=e,this.summerCompiler=null,this.createPromise=this.createSummerCompiler(e),this.summerCompiler=await this.createPromise,this.summerCompiler.setLocale(locales_1.default.getLocale())):(this.summerCompiler||(this.summerCompiler=await this.createPromise),this.summerCompiler.updateOptions(this.getSummerOptions(e))),this.summerCompiler}shouldCreate(e){var r,t,i,o,s;if(!this.project)return!0;if(this.project.projectPath!==e.projectPath)return!0;if(!lodash_1.default.isEqual(this.project.packOptions,e.packOptions))return!0;const l=["es6","minified","postcss","uglifyFileName","compileWorklet","enhance","minifyWXML","minifyWXSS","disableUseStrict","swc","useCompilerPlugins","babelSetting","swcSetting","condition"],m=null!==(t=null===(r=this.project)||void 0===r?void 0:r.setting)&&void 0!==t?t:{},p=null!==(i=e.setting)&&void 0!==i?i:{};for(const e of l){const r=m[e],t=p[e];if(!lodash_1.default.isEqual(r,t))return console.info(`shouldCreate return true, project.setting.${e}, before: ${JSON.stringify(r)}, after: ${JSON.stringify(t)}`),!0}return(null===(o=this.project)||void 0===o?void 0:o.miniprogramRoot)!==e.miniprogramRoot||(null===(s=this.project)||void 0===s?void 0:s.pluginRoot)!==e.pluginRoot}async releaseLastCompiler(){const{releaseCbs:e}=this;if(this.releaseCbs=[],this.createPromise)try{(await this.createPromise).destroy(),e.forEach(e=>{try{e()}catch(e){console.error("[SummerCompilerFactory] releaseLastCompiler release cb execute error: "+e)}})}catch(e){console.error("[SummerCompilerFactory] releaseLastCompiler error: "+e)}}ensureCacheDir(){const e=path_1.default.join("",(0,tools_1.generateMD5)(this.project.projectPath+"|summer"));return(0,tools_1.mkdirSync)(e),e}async createSummerCompiler(e){const r=new ciProject_1.CIProject(e);await r.ready();const t=this.ensureCacheDir(),i=this.getSummerOptions(e),o=new summerCompiler_1.SummerCompiler(r,t,i,{showBuildLog:()=>{}});return await o.ready(),o}getFileFilter(e){packOptionsHelper_1.default.updateState(e);return r=>{const t=r.startsWith(e.miniprogramRoot)&&packOptionsHelper_1.default.isIgnoredByRules(r.slice(e.miniprogramRoot.length)),i=e.pluginRoot&&r.startsWith(e.pluginRoot)&&packOptionsHelper_1.default.isIgnoredByRules(r.slice(e.pluginRoot.length));return!t&&!i}}getSummerOptions(e){const r=(0,pluginconfig_1.getSummerPluginConfig)(e.setting),t={[config_1.compileTypeConfig.weapp]:"miniProgram",[config_1.compileTypeConfig.plugin]:"miniProgramPlugin",[config_1.compileTypeConfig.game]:"miniGame",[config_1.compileTypeConfig.gamePlugin]:"miniGamePlugin"}[e.compileType];return{appid:e.appid,attr:e.attr,projectArchitecture:e.projectArchitecture,miniprogramRoot:e.miniprogramRoot,pluginRoot:e.pluginRoot,compileType:t,summerPlugins:r,setting:Object.assign({},e.setting)}}}exports.SummerCompilerFactory=SummerCompilerFactory,exports.summerCompilerFactory=new SummerCompilerFactory,exports.getSummerCompiler=exports.summerCompilerFactory.getSummerCompiler.bind(exports.summerCompilerFactory);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSummerCompiler=exports.summerCompilerFactory=exports.SummerCompilerFactory=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),config_1=require("../config/config"),ciProject_1=require("../project/ciProject"),tools_1=require("../utils/tools"),locales_1=tslib_1.__importDefault(require("../utils/locales/locales")),packOptionsHelper_1=tslib_1.__importDefault(require("../utils/packOptionsHelper")),summerCompiler_1=require("./corecompiler/summerCompiler"),pluginconfig_1=require("./corecompiler/summer/pluginconfig"),WeappCompileCache="";class SummerCompilerFactory{constructor(){this.summerCompiler=null,this.project=null,this.createPromise=null,this.releaseCbs=[]}async getSummerCompiler(e,r){return this.shouldCreate(e)?(this.releaseLastCompiler(),this.project=e,this.summerCompiler=null,this.createPromise=this.createSummerCompiler(e,r),this.summerCompiler=await this.createPromise,this.summerCompiler.setLocale(locales_1.default.getLocale())):(this.summerCompiler||(this.summerCompiler=await this.createPromise),this.summerCompiler.updateOptions(this.getSummerOptions(e))),this.summerCompiler}shouldCreate(e){var r,t,i,o,s;if(!this.project)return!0;if(this.project.projectPath!==e.projectPath)return!0;if(!lodash_1.default.isEqual(this.project.packOptions,e.packOptions))return!0;const l=["es6","minified","postcss","uglifyFileName","compileWorklet","enhance","minifyWXML","minifyWXSS","disableUseStrict","swc","useCompilerPlugins","babelSetting","swcSetting","condition"],m=null!==(t=null===(r=this.project)||void 0===r?void 0:r.setting)&&void 0!==t?t:{},p=null!==(i=e.setting)&&void 0!==i?i:{};for(const e of l){const r=m[e],t=p[e];if(!lodash_1.default.isEqual(r,t))return console.info(`shouldCreate return true, project.setting.${e}, before: ${JSON.stringify(r)}, after: ${JSON.stringify(t)}`),!0}return(null===(o=this.project)||void 0===o?void 0:o.miniprogramRoot)!==e.miniprogramRoot||(null===(s=this.project)||void 0===s?void 0:s.pluginRoot)!==e.pluginRoot}async releaseLastCompiler(){const{releaseCbs:e}=this;if(this.releaseCbs=[],this.createPromise)try{(await this.createPromise).destroy(),e.forEach(e=>{try{e()}catch(e){console.error("[SummerCompilerFactory] releaseLastCompiler release cb execute error: "+e)}})}catch(e){console.error("[SummerCompilerFactory] releaseLastCompiler error: "+e)}}ensureCacheDir(){const e=path_1.default.join("",(0,tools_1.generateMD5)(this.project.projectPath+"|summer"));return(0,tools_1.mkdirSync)(e),e}async createSummerCompiler(e,r){const t=new ciProject_1.CIProject(e);await t.ready();const i=this.ensureCacheDir(),o=this.getSummerOptions(e),s=new summerCompiler_1.SummerCompiler(t,i,o,{showBuildLog:()=>{}},r);return await s.ready(),s}getFileFilter(e){packOptionsHelper_1.default.updateState(e);return r=>{const t=r.startsWith(e.miniprogramRoot)&&packOptionsHelper_1.default.isIgnoredByRules(r.slice(e.miniprogramRoot.length)),i=e.pluginRoot&&r.startsWith(e.pluginRoot)&&packOptionsHelper_1.default.isIgnoredByRules(r.slice(e.pluginRoot.length));return!t&&!i}}getSummerOptions(e){const r=(0,pluginconfig_1.getSummerPluginConfig)(e.setting),t={[config_1.compileTypeConfig.weapp]:"miniProgram",[config_1.compileTypeConfig.plugin]:"miniProgramPlugin",[config_1.compileTypeConfig.game]:"miniGame",[config_1.compileTypeConfig.gamePlugin]:"miniGamePlugin"}[e.compileType];return{appid:e.appid,attr:e.attr,projectArchitecture:e.projectArchitecture,miniprogramRoot:e.miniprogramRoot,pluginRoot:e.pluginRoot,compileType:t,summerPlugins:r,setting:Object.assign({},e.setting)}}}exports.SummerCompilerFactory=SummerCompilerFactory,exports.summerCompilerFactory=new SummerCompilerFactory,exports.getSummerCompiler=exports.summerCompilerFactory.getSummerCompiler.bind(exports.summerCompilerFactory);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Builder=void 0;const index_1=require("./precompiler/index"),nativecompiler_1=require("./nativecompiler"),createSummer_1=require("./createSummer"),singletontask_1=require("../utils/singletontask");class Builder{constructor(e,t){this._getSummerCompiler=async()=>{if(!this._summerCompiler){const{summerCompilerClass:e,projectInfo:t,cachePath:i="",devtoolMessagehub:r}=this._options,o=await this.getPreCompileProject();e?(this._summerCompiler=new e(o,i,t,r),await this._summerCompiler.ready()):this._summerCompiler=await(0,createSummer_1.getSummerCompiler)(o)}return this._summerCompiler},this.originProject=e,this._options=t}async getCompiler(){return this.getSummerCompiler()}async getPreCompileProject(){if(!this._precompileProject){const{targetPlatform:e,targetPlatformDefines:t}=this._options,i=await this.getPreCompiler();this._precompileProject=await i.getPreCompileProject({targetPlatform:e,targetPlatformDefines:t,runEnv:"main process"}),await this._precompileProject.ready()}return this._precompileProject}async getPreCompiler(){if(!this._preCompiler){const{devtoolMessagehub:e}=this._options;this._preCompiler=new index_1.PreCompiler(this.originProject,e)}return this._preCompiler}async getSummerCompiler(){var e;return this._getSummerCompilerTask||(this._getSummerCompilerTask=new singletontask_1.SingletonTask(this._getSummerCompiler)),null===(e=this._getSummerCompilerTask)||void 0===e?void 0:e.getResult(!0)}async ready(){return this._checkReadyTask||(this._checkReadyTask=new singletontask_1.SingletonTask(this.init.bind(this,this._options))),await this._checkReadyTask.getResult()}async init(){}async getNativeCompiler(){return this._nativeCompiler||await this.initNativeCompiler(this._options),this._nativeCompiler}async initNativeCompiler(e){if("multiPlatform"!==this.originProject.projectArchitecture)return;const{miniappDirPath:t,devtoolsVersion:i,devtoolMessagehub:r}=e;this._nativeCompiler=new nativecompiler_1.NativeCompiler({project:this._precompileProject,devtoolMessagehub:r,devtoolsVersion:i,miniappDirPath:t}),await this._nativeCompiler.ready()}getPreCompileOptions(){var e,t;return{targetPlatform:null===(e=this._precompileProject)||void 0===e?void 0:e.targetPlatform,targetPlatformDefines:null===(t=this._precompileProject)||void 0===t?void 0:t.targetPlatformDefines}}async changePreCompileOptions(e){var t;await this.getPreCompileProject(),(null===(t=this._precompileProject)||void 0===t?void 0:t.targetPlatform)!==e.targetPlatform&&(this._precompileProject.updateConditionCompileOptions(e),await new Promise(e=>setTimeout(e,500)))}async setLocale(e){(await this.getSummerCompiler()).setLocale(e)}destroy(){var e,t;(null===(e=this._summerCompiler)||void 0===e?void 0:e.isSummer)&&this._summerCompiler.destroy(),null===(t=this._nativeCompiler)||void 0===t||t.destroy()}}exports.Builder=Builder;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Builder=void 0;const tslib_1=require("tslib"),nodePath=tslib_1.__importStar(require("path")),index_1=require("./precompiler/index"),nativecompiler_1=require("./nativecompiler"),createSummer_1=require("./createSummer"),singletontask_1=require("../utils/singletontask"),code_analyse_1=require("../common/code-analyse"),tools_1=require("../utils/tools");class CodeDataFileHelper{constructor(e){var t;this.project=e,this._listeners=[],this.onFileChange=()=>{this._listeners.forEach(e=>{e()})},null===(t=e.event)||void 0===t||t.on("fileChange",this.onFileChange)}destroy(){var e;null===(e=this.project.event)||void 0===e||e.off("fileChange",this.onFileChange)}get prefix(){return"miniProgram"===this.project.type?this.project.miniprogramRoot:"miniProgramPlugin"===this.project.type?this.project.pluginRoot:""}stat(e){const t=this.project.stat(this.prefix,e),i=!!(null==t?void 0:t.isFile),r=!!(null==t?void 0:t.isDirectory);if(!i&&!r)return;return{isFile:i,isDirectory:r,size:null==t?void 0:t.size,mtime:(null==t?void 0:t.mtimeMs)||0}}mtime(e){const t=this.stat(e);return t?t.mtime:0}exist(e){return this.project.exists(this.prefix,e)}existDir(e){if(this.exist(e)){const t=this.stat(e);return!!(null==t?void 0:t.isDirectory)}return!1}existFile(e){if(this.exist(e)){const t=this.stat(e);return!!(null==t?void 0:t.isFile)}return!1}getFileList(e="",t=""){const i=this.project.getFileList(this.prefix,t);return this.excludeRoot(i,this.prefix)}excludeRoot(e=[],t=""){return t?e.map(e=>nodePath.posix.relative(t,e)):e}async getString(e){return this.project.getFile(this.prefix,e).toString()}async getLocalFileString(e){return this.project.getFile(this.prefix,e).toString("utf-8")}async getJSON(e){const t=await this.getString(e);try{return JSON.parse(t)}catch(e){return null}}async readdir(e){const{files:t,dirs:i}=this.project.getFilesAndDirs();e.endsWith("/")||(e+="/");const r=t.filter(t=>t.startsWith(e));return i.filter(t=>t.startsWith(e)).concat(r).filter(t=>t.slice(e.length).indexOf("/")<0).map(t=>t.slice(e.length))}watchFileChange(e){this._listeners.push(e)}}class Builder{constructor(e,t){this._getSummerCompiler=async()=>{if(!this._summerCompiler){const{summerCompilerClass:e,projectInfo:t,cachePath:i="",devtoolMessagehub:r}=this._options,s=await this.getPreCompileProject(),o=await this.getAnalyzer();e?(this._summerCompiler=new e(s,i,t,r,o,this._options.filterFactory),await this._summerCompiler.ready()):this._summerCompiler=await(0,createSummer_1.getSummerCompiler)(s,o)}return this._summerCompiler},this.originProject=e,this._options=t}async getCompiler(){return this.getSummerCompiler()}async getAnalyzer(){if(this._analyzer)return this._analyzer;const e=await this.getPreCompileProject();return this._analyzer=new code_analyse_1.Analyzer({root:nodePath.join(e.projectPath,e.miniprogramRoot),type:"miniprogram",fileHelper:new CodeDataFileHelper(e),compilerPlugins:(0,tools_1.getCompilerPlugins)(e)}),this._analyzer}async getPreCompileProject(){if(!this._precompileProject){const{targetPlatform:e,targetPlatformDefines:t}=this._options,i=await this.getPreCompiler();this._precompileProject=await i.getPreCompileProject({targetPlatform:e,targetPlatformDefines:t,runEnv:"main process"}),await this._precompileProject.ready()}return this._precompileProject}async getPreCompiler(){if(!this._preCompiler){const{devtoolMessagehub:e}=this._options;this._preCompiler=new index_1.PreCompiler(this.originProject,e)}return this._preCompiler}async getSummerCompiler(){var e;return this._getSummerCompilerTask||(this._getSummerCompilerTask=new singletontask_1.SingletonTask(this._getSummerCompiler)),null===(e=this._getSummerCompilerTask)||void 0===e?void 0:e.getResult(!0)}async ready(){return this._checkReadyTask||(this._checkReadyTask=new singletontask_1.SingletonTask(this.init.bind(this,this._options))),await this._checkReadyTask.getResult()}async init(){}async getNativeCompiler(){return this._nativeCompiler||await this.initNativeCompiler(this._options),this._nativeCompiler}async initNativeCompiler(e){if("multiPlatform"!==this.originProject.projectArchitecture)return;const{miniappDirPath:t,devtoolsVersion:i,devtoolMessagehub:r}=e;this._nativeCompiler=new nativecompiler_1.NativeCompiler({project:this._precompileProject,devtoolMessagehub:r,devtoolsVersion:i,miniappDirPath:t}),await this._nativeCompiler.ready()}getPreCompileOptions(){var e,t;return{targetPlatform:null===(e=this._precompileProject)||void 0===e?void 0:e.targetPlatform,targetPlatformDefines:null===(t=this._precompileProject)||void 0===t?void 0:t.targetPlatformDefines}}async changePreCompileOptions(e){var t;await this.getPreCompileProject(),(null===(t=this._precompileProject)||void 0===t?void 0:t.targetPlatform)!==e.targetPlatform&&(this._precompileProject.updateConditionCompileOptions(e),await new Promise(e=>setTimeout(e,500)))}async setLocale(e){(await this.getSummerCompiler()).setLocale(e)}destroy(){var e,t,i,r,s;(null===(e=this._summerCompiler)||void 0===e?void 0:e.isSummer)&&this._summerCompiler.destroy(),null===(t=this._analyzer)||void 0===t||t.destroy(),this._analyzer=void 0,null===(i=this._nativeCompiler)||void 0===i||i.destroy(),null===(s=null===(r=this.originProject)||void 0===r?void 0:r.destroy)||void 0===s||s.call(r)}}exports.Builder=Builder;