miniprogram-ci 2.1.6 → 2.1.8
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.
- package/CHANGELOG.md +2 -0
- package/README.md +2 -0
- package/dist/@types/ci/cos-upload.d.ts +5 -0
- package/dist/@types/common/cloud-api/src/apis/tcb/tcb.apis.d.ts +7 -1
- package/dist/@types/common/cloud-api/src/transaction/contracts/tcb.contracts.d.ts +7 -1
- package/dist/@types/common/cloud-api/src/transaction/transactor.d.ts +1 -0
- package/dist/@types/common/cloud-api/src/transaction/validations/billing.validations.d.ts +2 -0
- package/dist/@types/common/cloud-api/src/transaction/validations/common.validations.d.ts +8 -1
- package/dist/@types/common/cloud-api/src/transaction/validations/tcb.validations.d.ts +7 -1
- package/dist/@types/common/cloud-api/src/transaction/validations/validations.d.ts +1 -0
- package/dist/@types/config/config.d.ts +1 -1
- package/dist/@types/config/url.config.d.ts +2 -0
- package/dist/@types/index.d.ts +2 -1
- package/dist/@types/modules/corecompiler/summer/graph/appconf.d.ts +2 -0
- package/dist/@types/modules/corecompiler/summerCompiler.d.ts +1 -0
- package/dist/@types/modules/createSummer.d.ts +0 -1
- package/dist/@types/modules/nativecompiler/ios/buildCloud.d.ts +4 -2
- package/dist/@types/project/baseProject.d.ts +2 -0
- package/dist/@types/schema/@types/appjson.d.ts +1 -1
- package/dist/@types/types/ci.d.ts +2 -0
- package/dist/@types/types/devtools.d.ts +2 -0
- package/dist/@types/types/miniapp/index.d.ts +1 -0
- package/dist/@types/utils/cosUpload.d.ts +37 -0
- package/dist/@types/utils/miniapp-builder.d.ts +1 -0
- package/dist/@types/utils/miniappJson.d.ts +124 -82
- package/dist/@types/utils/officialDonutPlugin.d.ts +3 -0
- package/dist/@types/utils/packOptionsHelper.d.ts +3 -1
- package/dist/@types/utils/tools.d.ts +2 -0
- package/dist/ci/android-miniapp-toolkit/dist/index.js +1 -1
- package/dist/ci/cos-upload.js +1 -1
- package/dist/ci/miniapp/archive.js +1 -1
- package/dist/ci/miniapp/checkBuildArgument.js +1 -1
- package/dist/ci/miniapp/upload.js +1 -1
- package/dist/ci/upload.js +1 -1
- package/dist/common/cloud-api/src/apis/tcb/tcb.apis.js +1 -1
- package/dist/common/cloud-api/src/transaction/contracts/tcb.contracts.js +1 -1
- package/dist/common/cloud-api/src/transaction/validations/billing.validations.js +1 -0
- package/dist/common/cloud-api/src/transaction/validations/common.validations.js +1 -1
- package/dist/common/cloud-api/src/transaction/validations/tcb.validations.js +1 -1
- package/dist/common/cloud-api/src/transaction/validations/validations.js +1 -1
- package/dist/common/code-analyse/index.js +1 -1
- package/dist/config/config.js +1 -1
- package/dist/config/url.config.js +1 -1
- package/dist/index.js +1 -1
- package/dist/modules/corecompiler/original/npm/packnpm.js +1 -1
- package/dist/modules/corecompiler/summer/graph/appconf.js +1 -1
- package/dist/modules/corecompiler/summer/graph/appgraph.js +1 -1
- package/dist/modules/corecompiler/summerCompiler.js +1 -1
- package/dist/modules/createSummer.js +1 -1
- package/dist/modules/fullcompiler/trans/wcc/build/darwin_arm64/wcc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/darwin_arm64/wcsc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/darwin_x64/wcc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/darwin_x64/wcsc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_arm64_release/wcc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_arm64_release/wcsc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_x64_release/wcc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_x64_release/wcsc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/win32_ia32/wcc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/win32_ia32/wcsc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/win32_x64/wcc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/win32_x64/wcsc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/lib/addonVersion.js +19 -0
- package/dist/modules/fullcompiler/trans/wcc/lib/index.js +4 -0
- package/dist/modules/fullcompiler/trans/wcc/lib/util.js +1134 -0
- package/dist/modules/fullcompiler/trans/wcc/lib/wcc.js +94 -0
- package/dist/modules/fullcompiler/trans/wcc/lib/wcsc.js +93 -0
- package/dist/modules/index.js +1 -1
- package/dist/modules/nativecompiler/ios/buildCloud.js +1 -1
- package/dist/modules/nativecompiler/ios/index.js +1 -1
- package/dist/project/baseProject.js +1 -1
- package/dist/schema/dist/app.js +2 -1
- package/dist/schema/dist/ext.js +4 -1
- package/dist/schema/dist/game.js +1 -1
- package/dist/schema/dist/page.js +3 -1
- package/dist/schema/dist/plugin.js +1 -1
- package/dist/schema/dist/pluginpage.js +1 -1
- package/dist/schema/dist/projectconfig.js +1 -1
- package/dist/schema/dist/projectprivateconfig.js +1 -1
- package/dist/schema/dist/sitemap.js +1 -1
- package/dist/schema/dist/theme.js +1 -1
- package/dist/static/scripts/resignIpa +17 -1
- package/dist/utils/cosUpload.js +1 -0
- package/dist/utils/miniapp-builder.js +1 -1
- package/dist/utils/miniappJson.js +1 -1
- package/dist/utils/officialDonutPlugin.js +1 -0
- package/dist/utils/packOptionsHelper.js +1 -1
- package/dist/utils/tools.js +1 -1
- package/package.json +3 -2
package/dist/config/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var COMPILE_TYPE,AstType,EFilterCode;function getDefaultIgnores(e){const _=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];return"multiPlatform"===e.projectArchitecture&&_.push(exports.multiPlatformRoot+"/**/*"),_}Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=exports.EFilterCode=exports.AstType=exports.compileTypeConfig=exports.getDefaultIgnores=exports.FullPkg=exports.MainPkg=exports.multiPlatformRoot=exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_WORKERS_PACKAGE_ROOT=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.CI_VERSION="2.
|
|
1
|
+
"use strict";var COMPILE_TYPE,AstType,EFilterCode;function getDefaultIgnores(e){const _=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];return"multiPlatform"===e.projectArchitecture&&_.push(exports.multiPlatformRoot+"/**/*"),_}Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=exports.EFilterCode=exports.AstType=exports.compileTypeConfig=exports.getDefaultIgnores=exports.FullPkg=exports.MainPkg=exports.multiPlatformRoot=exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_WORKERS_PACKAGE_ROOT=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.CI_VERSION="2.1.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={})),function(e){e[e.Include=0]="Include",e[e.PackOptionsIgnore=1]="PackOptionsIgnore",e[e.AnalyseNoUse=2]="AnalyseNoUse",e[e.PartialCompileNoUse=3]="PartialCompileNoUse"}(EFilterCode=exports.EFilterCode||(exports.EFilterCode={})),exports.MAX_CODE_LENGTH=2048e3;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getUsedPluginVersionInfo=exports.downloadMiniAppPlugin=exports.getPkgWxapkg=exports.miniappUpload=exports.getCloudBuildPkgUrl=exports.getCloudBuildTaskList=exports.uploadCloudBuildResourcePack=exports.getSdkIntInfo=exports.getAsyncResult=exports.testSourceNewFeatureURL=exports.testSourceURL=exports.getUploadToken=exports.commitSourceURL=exports.commitSourceNewFeatureURL=exports.tcbTencentCloudUrl=exports.dbTencentCloudUrl=exports.scfTencentCloudUrl=exports.cloudCosUploadURL=exports.get3rdCloudCodeSecret=exports.cloudAPIAgentURL=exports.GET_LATEST_VERSION=exports.UPLOAD_JS_SERVER=exports.GET_ASYNC_RESULT=exports.GET_UPLOAD_TOKEN=exports.GET_CLOUD_API_SIGNATURE=exports.TRANSLATE_FILENAME=exports.GET_DEV_SOURCE_MAP=exports.GET_RAND_STRING=exports.GET_ONLINE_SCHEMA=exports.GET_WHITE_EXT_LIST=exports.TEST_SOURCE_URL=exports.UPLOAD_URL=exports.GET_ATTR_URL=void 0;const Domain="https://servicewechat.com";exports.GET_ATTR_URL=Domain+"/wxa/ci/getattr",exports.UPLOAD_URL=Domain+"/wxa/ci/upload",exports.TEST_SOURCE_URL=Domain+"/wxa/ci/testSourceURL",exports.GET_WHITE_EXT_LIST=Domain+"/wxa/ci/getwhiteextlist",exports.GET_ONLINE_SCHEMA=Domain+"/wxa/ci/getonlineschema",exports.GET_RAND_STRING=Domain+"/wxa/ci/getrandstr",exports.GET_DEV_SOURCE_MAP=Domain+"/wxa/ci/get_dev_sourcemap",exports.TRANSLATE_FILENAME=Domain+"/wxa/ci/translate_filename",exports.GET_CLOUD_API_SIGNATURE=Domain+"/wxa/ci/getqcloudapisignature",exports.GET_UPLOAD_TOKEN=Domain+"/wxa/ci/getuploadtoken",exports.GET_ASYNC_RESULT=Domain+"/wxa/ci/getasyncresult",exports.UPLOAD_JS_SERVER=Domain+"/wxa/ci/uploadjsserver",exports.GET_LATEST_VERSION=Domain+"/wxa/ci/getlatestversion",exports.cloudAPIAgentURL=Domain+"/wxa/ci/cloudapihttpagent",exports.get3rdCloudCodeSecret=Domain+"/wxa/ci/getcloudcodesecret",exports.cloudCosUploadURL=Domain+"/wxa/ci/cloudcosupload",exports.scfTencentCloudUrl="https://scf.tencentcloudapi.com",exports.dbTencentCloudUrl="https://flexdb.tencentcloudapi.com",exports.tcbTencentCloudUrl="https://tcb.tencentcloudapi.com",exports.commitSourceNewFeatureURL=Domain+"wxa-dev-new/commitsource",exports.commitSourceURL=Domain+"wxa-dev/commitsource",exports.getUploadToken=Domain+"wxa-dev/getuploadtoken",exports.testSourceURL=Domain+"wxa-dev/testsource",exports.testSourceNewFeatureURL=Domain+"wxa-dev-new/testsource",exports.getAsyncResult=Domain+"wxa-dev/getasyncresult",exports.getSdkIntInfo=Domain+"/wxa/ci/getsdkinitinfo",exports.uploadCloudBuildResourcePack=Domain+"/wxa/ci/uploadcloudbuildresourcepack",exports.getCloudBuildTaskList=Domain+"/wxa/ci/getcloudbuildtasklist",exports.getCloudBuildPkgUrl=Domain+"/wxa/ci/getcloudbuildpkgurl",exports.miniappUpload=Domain+"/wxa/ci/miniappupload",exports.getPkgWxapkg=Domain+"/wxa/ci/downloadpackage",exports.downloadMiniAppPlugin=Domain+"/wxa/ci/downloadcpfplugin",exports.getUsedPluginVersionInfo=Domain+"/wxa/ci/getcpfusedpluginversioninfo";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getUsedPluginVersionInfo=exports.downloadMiniAppPlugin=exports.getPkgWxapkg=exports.miniappUpload=exports.getCloudBuildPkgUrl=exports.getCloudBuildTaskList=exports.uploadCloudBuildResourcePack=exports.getSdkIntInfo=exports.getAsyncResult=exports.testSourceNewFeatureURL=exports.testSourceURL=exports.getUploadToken=exports.commitSourceURL=exports.commitSourceNewFeatureURL=exports.tcbTencentCloudUrl=exports.dbTencentCloudUrl=exports.scfTencentCloudUrl=exports.cloudCosUploadURL=exports.get3rdCloudCodeSecret=exports.cloudAPIAgentURL=exports.GET_LATEST_VERSION=exports.UPLOAD_JS_SERVER=exports.GET_UPLOAD_SIGN=exports.GET_UPLOAD_INFO=exports.GET_ASYNC_RESULT=exports.GET_UPLOAD_TOKEN=exports.GET_CLOUD_API_SIGNATURE=exports.TRANSLATE_FILENAME=exports.GET_DEV_SOURCE_MAP=exports.GET_RAND_STRING=exports.GET_ONLINE_SCHEMA=exports.GET_WHITE_EXT_LIST=exports.TEST_SOURCE_URL=exports.UPLOAD_URL=exports.GET_ATTR_URL=void 0;const Domain="https://servicewechat.com";exports.GET_ATTR_URL=Domain+"/wxa/ci/getattr",exports.UPLOAD_URL=Domain+"/wxa/ci/upload",exports.TEST_SOURCE_URL=Domain+"/wxa/ci/testSourceURL",exports.GET_WHITE_EXT_LIST=Domain+"/wxa/ci/getwhiteextlist",exports.GET_ONLINE_SCHEMA=Domain+"/wxa/ci/getonlineschema",exports.GET_RAND_STRING=Domain+"/wxa/ci/getrandstr",exports.GET_DEV_SOURCE_MAP=Domain+"/wxa/ci/get_dev_sourcemap",exports.TRANSLATE_FILENAME=Domain+"/wxa/ci/translate_filename",exports.GET_CLOUD_API_SIGNATURE=Domain+"/wxa/ci/getqcloudapisignature",exports.GET_UPLOAD_TOKEN=Domain+"/wxa/ci/getuploadtoken",exports.GET_ASYNC_RESULT=Domain+"/wxa/ci/getasyncresult",exports.GET_UPLOAD_INFO=Domain+"/wxa/ci/getuploadinfo",exports.GET_UPLOAD_SIGN=Domain+"/wxa/ci/getuploadsign",exports.UPLOAD_JS_SERVER=Domain+"/wxa/ci/uploadjsserver",exports.GET_LATEST_VERSION=Domain+"/wxa/ci/getlatestversion",exports.cloudAPIAgentURL=Domain+"/wxa/ci/cloudapihttpagent",exports.get3rdCloudCodeSecret=Domain+"/wxa/ci/getcloudcodesecret",exports.cloudCosUploadURL=Domain+"/wxa/ci/cloudcosupload",exports.scfTencentCloudUrl="https://scf.tencentcloudapi.com",exports.dbTencentCloudUrl="https://flexdb.tencentcloudapi.com",exports.tcbTencentCloudUrl="https://tcb.tencentcloudapi.com",exports.commitSourceNewFeatureURL=Domain+"wxa-dev-new/commitsource",exports.commitSourceURL=Domain+"wxa-dev/commitsource",exports.getUploadToken=Domain+"wxa-dev/getuploadtoken",exports.testSourceURL=Domain+"wxa-dev/testsource",exports.testSourceNewFeatureURL=Domain+"wxa-dev-new/testsource",exports.getAsyncResult=Domain+"wxa-dev/getasyncresult",exports.getSdkIntInfo=Domain+"/wxa/ci/getsdkinitinfo",exports.uploadCloudBuildResourcePack=Domain+"/wxa/ci/uploadcloudbuildresourcepack",exports.getCloudBuildTaskList=Domain+"/wxa/ci/getcloudbuildtasklist",exports.getCloudBuildPkgUrl=Domain+"/wxa/ci/getcloudbuildpkgurl",exports.miniappUpload=Domain+"/wxa/ci/miniappupload",exports.getPkgWxapkg=Domain+"/wxa/ci/downloadpackage",exports.downloadMiniAppPlugin=Domain+"/wxa/ci/downloadcpfplugin",exports.getUsedPluginVersionInfo=Domain+"/wxa/ci/getcpfusedpluginversioninfo";
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MiniAppJson=exports.MiniAppI18N=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");tslib_1.__exportStar(require("./ci/index"),exports);const 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;const miniAppI18N_1=tslib_1.__importDefault(require("./utils/miniAppI18N"));exports.MiniAppI18N=miniAppI18N_1.default;const MiniAppJson=tslib_1.__importStar(require("./utils/miniappJson"));exports.MiniAppJson=MiniAppJson,tslib_1.__exportStar(require("./modules/corecompiler/original"),exports),exports.workletVersion=require("./utils/common").workletVersion;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MiniAppJson=exports.MiniAppI18N=exports.miniappBuilder=exports.iosDeviceUtils=exports.adroidDeviceUtils=exports.cosUpload=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");tslib_1.__exportStar(require("./ci/index"),exports);const 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;const miniAppI18N_1=tslib_1.__importDefault(require("./utils/miniAppI18N"));exports.MiniAppI18N=miniAppI18N_1.default;const MiniAppJson=tslib_1.__importStar(require("./utils/miniappJson"));exports.MiniAppJson=MiniAppJson;const cosUpload=tslib_1.__importStar(require("./utils/cosUpload"));exports.cosUpload=cosUpload,tslib_1.__exportStar(require("./modules/corecompiler/original"),exports),exports.workletVersion=require("./utils/common").workletVersion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.packNpmManually=exports.packNpm=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),fs_1=tslib_1.__importDefault(require("fs")),rimraf_1=tslib_1.__importDefault(require("rimraf")),lodash_1=tslib_1.__importDefault(require("lodash")),glob_1=tslib_1.__importDefault(require("glob")),source_map_1=tslib_1.__importDefault(require("source-map")),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),error_1=require("../../../../utils/error"),log=tslib_1.__importStar(require("../../../../utils/log")),projectconfig_1=require("../json/projectconfig"),config_1=require("../../../../config/config"),filterdeps_1=tslib_1.__importDefault(require("./filterdeps")),acorn=require("acorn"),NPM_RECORD={start_time:Date.now(),pack_time:0,miniprogram_pack_num:0,other_pack_num:0,warn_not_found_num:0,warn_require_var_num:0,warn_require_rename_num:0,extra1:"",extra2:"",extra3:""},REPORT_LIST=["pack_time","miniprogram_pack_num","other_pack_num","warn_not_found_num","warn_require_var_num","warn_require_rename_num","extra1","extra2","extra3"];function wrap(e,t){return function(...a){if(a.length){const e=a.pop();"function"!=typeof e&&a.push(e)}return new Promise((r,n)=>{a.push((e,t)=>{e?n(e):r(t)}),e.apply(t||null,a)})}}const statSync=wrap(fs_1.default.stat),mkdirSync=wrap(fs_1.default.mkdir),readFileSync=wrap(fs_1.default.readFile),writeFileSync=wrap(fs_1.default.writeFile),accessSync=wrap(fs_1.default.access),renameSync=wrap(fs_1.default.rename),globSync=wrap(glob_1.default);let seed=+new Date;function getId(){return++seed}function startRecord(){NPM_RECORD.start_time=Date.now(),REPORT_LIST.forEach(e=>NPM_RECORD[e]=e.startsWith("extra")?"":0)}function endRecord(e){NPM_RECORD.pack_time=Date.now()-NPM_RECORD.start_time;const t={};REPORT_LIST.forEach(e=>t[e]=NPM_RECORD[e]);try{null==e||e(t)}catch(e){}}async function recursiveMkdir(e){const t=path_1.default.posix.dirname(e);try{await accessSync(t)}catch(e){await recursiveMkdir(t)}try{await accessSync(e);const t=await statSync(e);t&&!t.isDirectory()&&(await renameSync(e,e+".bak"),log.warn(e+" already exists but is not a directory, so it will be rename to a file with the suffix ending in '.bak'"),await mkdirSync(e))}catch(t){await mkdirSync(e)}}async function copyFile(e,t){const a=await readFileSync(e);await writeFile(a,t)}async function writeFile(e,t){await recursiveMkdir(path_1.default.posix.dirname(t)),await writeFileSync(t,e)}function walkNode(e,t){t(e),Object.keys(e).forEach(a=>{const r=e[a];Array.isArray(r)&&r.forEach(e=>{(null==e?void 0:e.type)&&walkNode(e,t)}),(null==r?void 0:r.type)&&walkNode(r,t)})}function parseDeps(e,t,a){const r=[];let n,o=[];try{n=acorn.parse(e,{sourceType:"module",locations:!0,allowHashBang:!0,onComment(t,a,r,n){t||"#"!==e[r]||o.push({start:r,end:n,adjustContent:""})}})}catch(e){const a=`parse js file (${t}) failed: ${e.message}`;throw console.error(a),e.message=a,e}return walkNode(n,n=>{const{callee:i}=n,s=n.arguments;if("CallExpression"===n.type&&i&&"Identifier"===i.type&&"require"===i.name&&s&&1===s.length&&("Literal"===s[0].type?r.push(s[0].value):(a.push({jsPath:t,code:e.substring(n.start,n.end),startLine:n.loc.start.line,endLine:n.loc.end.line,tips:"require variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_VAR.format()}),NPM_RECORD.warn_require_var_num++)),"ExpressionStatement"===n.type&&n.expression&&"use strict"===n.expression.value&&o.push({start:n.start,end:n.end,adjustContent:""}),"ImportDeclaration"===n.type){const{source:e}=n,{specifiers:t}=n,a={start:n.start,end:n.end,adjustContent:""},i=[];e&&"Literal"===e.type&&(r.push(e.value),i.push(`var __TEMP__ = require('${e.value}');`)),t&&Array.isArray(t)&&t.forEach(e=>{if("ImportSpecifier"===e.type){const{local:t}=e,{imported:a}=e;"Identifier"===t.type&&"Identifier"===a.type&&i.push(`var ${t.name} = __TEMP__['${a.name}'];`)}else if("ImportDefaultSpecifier"===e.type){const{local:t}=e;"Identifier"===t.type&&i.push(`var ${t.name} = __REQUIRE_DEFAULT__(__TEMP__);`)}else if("ImportNamespaceSpecifier"===e.type){const{local:t}=e;"Identifier"===t.type&&i.push(`var ${t.name} = __REQUIRE_WILDCARD__(__TEMP__);`)}}),a.adjustContent=i.join(""),o.push(a)}if("ExportNamedDeclaration"===n.type){const{source:t}=n,{specifiers:a}=n,{declaration:i}=n;let s=!1;const p={start:n.start,end:n.end,adjustContent:""},c=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];if(t&&"Literal"===t.type&&(r.push(t.value),c.push(`var __TEMP__ = require('${t.value}');`),s=!0),i){if("VariableDeclaration"===i.type){const{declarations:t}=i;t&&Array.isArray(t)&&t.forEach(t=>{if("VariableDeclarator"===t.type){const{id:a}=t,{init:r}=t;a&&"Identifier"===a.type&&(p.notAddLines=!0,c.push(`var ${a.name} = exports.${a.name} = ${r?e.substring(r.start,r.end):"undefined"};`))}})}else if("FunctionDeclaration"===i.type){const{id:t}=i;t&&"Identifier"===t.type&&(p.notAddLines=!0,c.push(`${e.substring(i.start,i.end)};exports.${t.name} = ${t.name}`))}else if("ClassDeclaration"===i.type){const{id:t}=i;t&&"Identifier"===t.type&&(p.notAddLines=!0,c.push(`${e.substring(i.start,i.end)};exports.${t.name} = ${t.name}`))}}else;a&&Array.isArray(a)&&a.forEach(e=>{if("ExportSpecifier"===e.type){const{local:t}=e,{exported:a}=e;"Identifier"===t.type&&"Identifier"===a.type&&c.push(`Object.defineProperty(exports, '${a.name}', { enumerable: true, configurable: true, get: function() { return ${s?"__TEMP__.":""}${t.name}; } });`)}}),p.adjustContent=c.join(""),o.push(p)}else if("ExportAllDeclaration"===n.type){const{source:e}=n,t={start:n.start,end:n.end,adjustContent:""},a=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];e&&"Literal"===e.type&&(r.push(e.value),a.push(`var __TEMP__ = require('${e.value}');`)),a.push('Object.keys(__TEMP__).forEach(function(k) { if (k === "default" || k === "__esModule") return; Object.defineProperty(exports, k, { enumerable: true, configurable: true, get: function() { return __TEMP__[k]; } }); });'),t.adjustContent=a.join(""),o.push(t)}else if("ExportDefaultDeclaration"===n.type){const{declaration:t}=n,a={start:n.start,end:n.end,adjustContent:""},r=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];if(t)if(a.notAddLines=!0,t.id){const{id:a}=t;r.push(`${e.substring(t.start,t.end)};exports.default = ${a.name}`)}else r.push(`exports.default = ${e.substring(t.start,t.end)};`);a.adjustContent=r.join(""),o.push(a)}const{expression:p}=n;"ExpressionStatement"===n.type&&p&&"AssignmentExpression"===p.type&&"Identifier"===p.right.type&&"require"===p.right.name&&(a.push({jsPath:t,code:e.substring(n.start,n.end),startLine:n.loc.start.line,endLine:n.loc.end.line,tips:"assign require function to a variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_ASSIGN.format()}),NPM_RECORD.warn_require_rename_num++);const{declarations:c}=n;"VariableDeclaration"===n.type&&c.length>0&&c.forEach(r=>{const{init:o}=r;"VariableDeclarator"===r.type&&o&&"Identifier"===o.type&&"require"===o.name&&(a.push({jsPath:t,code:e.substring(n.start,n.end),startLine:n.loc.start.line,endLine:n.loc.end.line,tips:"assign require function to a variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_ASSIGN.format()}),NPM_RECORD.warn_require_rename_num++)})}),o=o.sort((e,t)=>t.start-e.start),o.forEach(t=>{const a=e.substring(t.start,t.end),r=t.notAddLines?0:a.split("\n").length;e=e.substring(0,t.start)+t.adjustContent+new Array(r).join("\n")+e.substring(t.end)}),{deps:r,parsedContent:e}}async function parseJs(e,t,a,r,n,o){if(n[t=path_1.default.posix.normalize(t)])return n[t];const i=await readFileSync(t,"utf8"),s=getId(),p=path_1.default.posix.relative(e,t);if(t.endsWith(".json")){const e={id:s,name:p,content:"module.exports = "+i,deps:[],depsMap:{}};return n[t]=s,r.push(e),s}const{deps:c,parsedContent:_}=parseDeps(i,t,o),u={id:s,name:p,content:_,deps:c,depsMap:{}};n[t]=s,r.push(u);for(const i of c){let s,p=path_1.default.posix.join(path_1.default.posix.dirname(t),i);if(!p.endsWith(".js")&&!p.endsWith(".json")){const e=p+".js";try{await accessSync(e),p=e}catch(e){}}try{const e=await statSync(p);(null==e?void 0:e.isDirectory())&&(p=path_1.default.posix.join(p,"index.js"))}catch(e){}p.endsWith(".js")||p.endsWith(".json")||(p+=".js");try{await accessSync(p),s=await parseJs(e,p,a,r,n,o)}catch(e){}s&&(u.depsMap[i]=s)}return s}function addJsToMap(e,t,a,r){const n=t.split("\n").length;for(let o=1;o<=n;o++)e.addMapping({generated:{line:r+o,column:0},original:{line:o,column:0},source:a}),e.setSourceContent(a,t)}function findOutsideDeps(e){const t=new Set;return e.forEach(e=>{e.deps.forEach(a=>{Object.keys(e.depsMap).includes(a)||t.add(a)})}),Array.from(t)}async function packJs(e,t,a){try{const t=await statSync(e);(null==t?void 0:t.isDirectory())&&(e=path_1.default.posix.join(e,"index.js"))}catch(e){}e.endsWith(".js")||e.endsWith(".json")||(e+=".js");try{await accessSync(e)}catch(t){return a.push({jsPath:e,code:"",tips:"entry file is not found",msg:locales_1.default.config.NOT_FOUND_NPM_ENTRY.format()}),void NPM_RECORD.warn_not_found_num++}const r=new source_map_1.default.SourceMapGenerator({file:"index.js"}),n=[];await parseJs(path_1.default.posix.dirname(e),e,t,n,{},a);const o=findOutsideDeps(n),i=["module.exports = (function() {","var __MODS__ = {};","var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };",'var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };',"var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };","var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };"];if(n.length){const e=n.shift();i.push(`__DEFINE__(${e.id}, function(require, module, exports) {`),addJsToMap(r,e.content,e.name,i.length),i.push(e.content),i.push(`}, function(modId) {var map = ${JSON.stringify(e.depsMap)}; return __REQUIRE__(map[modId], modId); })`);for(const e of n)i.push(`__DEFINE__(${e.id}, function(require, module, exports) {`),addJsToMap(r,e.content,e.name,i.length),i.push(e.content),i.push(`}, function(modId) { var map = ${JSON.stringify(e.depsMap)}; return __REQUIRE__(map[modId], modId); })`);i.push(`return __REQUIRE__(${e.id});`)}return i.push("})()"),i.push("//miniprogram-npm-outsideDeps="+JSON.stringify(o)),i.push("//# sourceMappingURL=index.js.map"),{js:i.join("\n"),map:r.toString()}}async function checkIsMiniprogramPack(e,t){let a="miniprogram_dist";t.miniprogram&&"string"==typeof t.miniprogram&&(a=t.miniprogram);try{const t=path_1.default.posix.join(e,a);await accessSync(t);const r=await statSync(t);if(null==r?void 0:r.isDirectory())return t}catch(e){}return""}async function packNpm(e,t={}){const{projectPath:a}=e,r=e.type,n=await(0,projectconfig_1.getProjectConfigJSON)(e),o=n.pluginRoot||"",i=n.miniprogramRoot||"",s="miniProgramPlugin"===r||"miniGamePlugin"===r,{ignores:p,reporter:c}=t;if(!a)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format("projectPath"),config_1.PARAM_ERROR);if("miniProgramPlugin"===r&&!o)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('project.config.json "pluginRoot"'),config_1.PARAM_ERROR);startRecord();const _=path_1.default.isAbsolute(a)?a:path_1.default.posix.join(process.cwd(),a),u=[{searchRoot:path_1.default.posix.join(_,i),paths:await globSync("**/package.json",{cwd:path_1.default.posix.join(_,i),nodir:!0,dot:!0,ignore:(p||[]).concat("**/node_modules/**")})}];s&&u.push({searchRoot:path_1.default.posix.join(_,o),paths:await globSync("**/package.json",{cwd:path_1.default.posix.join(_,o),nodir:!0,dot:!0,ignore:(p||[]).concat("**/node_modules/**")})});lodash_1.default.flattenDeep(u.map(e=>e.paths.map(t=>path_1.default.posix.join(e.searchRoot,path_1.default.dirname(t),"miniprogram_npm")))).forEach(e=>rimraf_1.default.sync(e));const l=[];for(const e of u)for(const t of e.paths){const a=path_1.default.dirname(path_1.default.posix.join(e.searchRoot,t)),r=lodash_1.default.xorWith(e.paths,[t]).map(e=>path_1.default.posix.join(path_1.default.posix.dirname(e),"/**")).filter(e=>"**"!==e);let n=await globSync("**/package.json",{cwd:a.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:(p||[]).concat(r).concat(["node_modules/@types/**"])});if(n=await(0,filterdeps_1.default)(a,n),n&&n.length)for(const e of n){const t=path_1.default.posix.join(a,e);let r=await readFileSync(t,"utf8");const n=path_1.default.dirname(t);let o=n.replace(/([\b/\\])node_modules([\b/\\])/g,(e,t,a)=>`${t}miniprogram_npm${a}`),i=path_1.default.basename(o);const s=i.split("@");s.length&&(i=s.pop()||""),o=o.replace(path_1.default.basename(o),i),r=JSON.parse(r);const p=path_1.default.posix.join(n,r.main||"index.js"),c=await checkIsMiniprogramPack(n,r);if(c){const e=await globSync("**/*",{cwd:c.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:"**/node_modules/**"});for(const t of e)await copyFile(path_1.default.posix.join(c,t),path_1.default.posix.join(o,t));NPM_RECORD.miniprogram_pack_num++}else{const e=await packJs(p,o,l);if(!e)continue;await writeFile(e.js,path_1.default.posix.join(o,"./index.js")),await writeFile(e.map,path_1.default.posix.join(o,"./index.js.map")),NPM_RECORD.other_pack_num++}}}if(endRecord(c),NPM_RECORD.miniprogram_pack_num+NPM_RECORD.other_pack_num<=0)throw new Error("__NO_NODE_MODULES__ "+locales_1.default.config.NOT_FOUND_NODE_MODULES.format());return"function"==typeof e.updateFileAndDirs&&e.updateFileAndDirs(),l}async function packNpmManually(e){let{packageJsonPath:t,miniprogramNpmDistDir:a}=e;const r=e.ignores||[],n={pack_time:0,miniprogram_pack_num:0,other_pack_num:0,warn_not_found_num:0,warn_require_var_num:0,warn_require_rename_num:0},o=[];if(!a)throw new Error("param miniprogramNpmDistDir is required");if(!t)throw new Error("param packageJsonPath is required");if(path_1.default.isAbsolute(a)||(a=path_1.default.join(process.cwd(),a)),path_1.default.isAbsolute(t)||(t=path_1.default.join(process.cwd(),t)),!fs_1.default.existsSync(t))throw new Error(`param packageJsonPath: ${t} file is not exited`);const i=path_1.default.dirname(t);let s=await globSync("**/package.json",{cwd:i.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:(r||[]).concat(["node_modules/@types/**"])});if(s=await(0,filterdeps_1.default)(i,s),!s||!s.length)return log.warn("No miniprogram_npm package was built."),{miniProgramPackNum:0,otherNpmPackNum:0,warnList:[]};s=s.filter(e=>e.startsWith("node_modules"));for(const e of s){const t=path_1.default.posix.join(i,e);let r=await readFileSync(t,"utf8");const s=path_1.default.dirname(t);let p=s.replace(/([\b/\\])node_modules([\b/\\])/g,(e,t,a)=>`${t}miniprogram_npm${a}`);p=path_1.default.posix.normalize(path_1.default.posix.join(a,"miniprogram_npm",p.split(/[/\\]miniprogram_npm[/\\]/)[1]));let c=path_1.default.basename(p);const _=c.split("@");_.length&&(c=_.pop()||""),p=p.replace(path_1.default.basename(p),c),r=JSON.parse(r);const u=path_1.default.posix.join(s,r.main||"index.js"),l=await checkIsMiniprogramPack(s,r);if(l){const e=await globSync("**/*",{cwd:l.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:"**/node_modules/**"});for(const t of e)await copyFile(path_1.default.posix.join(l,t),path_1.default.posix.join(p,t));n.miniprogram_pack_num++}else{const e=await packJs(u,p,o);if(!e)continue;await writeFile(e.js,path_1.default.posix.join(p,"./index.js")),await writeFile(e.map,path_1.default.posix.join(p,"./index.js.map")),n.other_pack_num++}}return{miniProgramPackNum:n.miniprogram_pack_num,otherNpmPackNum:n.other_pack_num,warnList:o}}exports.packNpm=packNpm,exports.packNpmManually=packNpmManually;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.packNpmManually=exports.packNpm=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),fs_1=tslib_1.__importDefault(require("fs")),rimraf_1=tslib_1.__importDefault(require("rimraf")),lodash_1=tslib_1.__importDefault(require("lodash")),glob_1=tslib_1.__importDefault(require("glob")),source_map_1=tslib_1.__importDefault(require("source-map")),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),error_1=require("../../../../utils/error"),log=tslib_1.__importStar(require("../../../../utils/log")),projectconfig_1=require("../json/projectconfig"),config_1=require("../../../../config/config"),filterdeps_1=tslib_1.__importDefault(require("./filterdeps")),acorn=require("acorn"),NPM_RECORD={start_time:Date.now(),pack_time:0,miniprogram_pack_num:0,other_pack_num:0,warn_not_found_num:0,warn_require_var_num:0,warn_require_rename_num:0,extra1:"",extra2:"",extra3:""},REPORT_LIST=["pack_time","miniprogram_pack_num","other_pack_num","warn_not_found_num","warn_require_var_num","warn_require_rename_num","extra1","extra2","extra3"];function wrap(e,t){return function(...a){if(a.length){const e=a.pop();"function"!=typeof e&&a.push(e)}return new Promise((n,r)=>{a.push((e,t)=>{e?r(e):n(t)}),e.apply(t||null,a)})}}const statSync=wrap(fs_1.default.stat),mkdirSync=wrap(fs_1.default.mkdir),readFileSync=wrap(fs_1.default.readFile),writeFileSync=wrap(fs_1.default.writeFile),accessSync=wrap(fs_1.default.access),renameSync=wrap(fs_1.default.rename),globSync=wrap(glob_1.default);let seed=+new Date;function getId(){return++seed}function startRecord(){NPM_RECORD.start_time=Date.now(),REPORT_LIST.forEach(e=>NPM_RECORD[e]=e.startsWith("extra")?"":0)}function endRecord(e){NPM_RECORD.pack_time=Date.now()-NPM_RECORD.start_time;const t={};REPORT_LIST.forEach(e=>t[e]=NPM_RECORD[e]);try{null==e||e(t)}catch(e){}}async function recursiveMkdir(e){const t=path_1.default.posix.dirname(e);try{await accessSync(t)}catch(e){await recursiveMkdir(t)}try{await accessSync(e);const t=await statSync(e);t&&!t.isDirectory()&&(await renameSync(e,e+".bak"),log.warn(e+" already exists but is not a directory, so it will be rename to a file with the suffix ending in '.bak'"),await mkdirSync(e))}catch(t){await mkdirSync(e)}}async function copyFile(e,t){const a=await readFileSync(e);await writeFile(a,t)}async function writeFile(e,t){await recursiveMkdir(path_1.default.posix.dirname(t)),await writeFileSync(t,e)}function walkNode(e,t){t(e),Object.keys(e).forEach(a=>{const n=e[a];Array.isArray(n)&&n.forEach(e=>{(null==e?void 0:e.type)&&walkNode(e,t)}),(null==n?void 0:n.type)&&walkNode(n,t)})}function parseDeps(e,t,a){const n=[];let r,o=[];try{r=acorn.parse(e,{sourceType:"module",locations:!0,allowHashBang:!0,onComment(t,a,n,r){t||"#"!==e[n]||o.push({start:n,end:r,adjustContent:""})}})}catch(e){const a=`parse js file (${t}) failed: ${e.message}`;throw console.error(a),e.message=a,e}return walkNode(r,r=>{const{callee:i}=r,s=r.arguments;if("CallExpression"===r.type&&i&&"Identifier"===i.type&&"require"===i.name&&s&&1===s.length&&("Literal"===s[0].type?n.push(s[0].value):(a.push({jsPath:t,code:e.substring(r.start,r.end),startLine:r.loc.start.line,endLine:r.loc.end.line,tips:"require variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_VAR.format()}),NPM_RECORD.warn_require_var_num++)),"ExpressionStatement"===r.type&&r.expression&&"use strict"===r.expression.value&&o.push({start:r.start,end:r.end,adjustContent:""}),"ImportDeclaration"===r.type){const{source:e}=r,{specifiers:t}=r,a={start:r.start,end:r.end,adjustContent:""},i=[];e&&"Literal"===e.type&&(n.push(e.value),i.push(`var __TEMP__ = require('${e.value}');`)),t&&Array.isArray(t)&&t.forEach(e=>{if("ImportSpecifier"===e.type){const{local:t}=e,{imported:a}=e;"Identifier"===t.type&&"Identifier"===a.type&&i.push(`var ${t.name} = __TEMP__['${a.name}'];`)}else if("ImportDefaultSpecifier"===e.type){const{local:t}=e;"Identifier"===t.type&&i.push(`var ${t.name} = __REQUIRE_DEFAULT__(__TEMP__);`)}else if("ImportNamespaceSpecifier"===e.type){const{local:t}=e;"Identifier"===t.type&&i.push(`var ${t.name} = __REQUIRE_WILDCARD__(__TEMP__);`)}}),a.adjustContent=i.join(""),o.push(a)}if("ExportNamedDeclaration"===r.type){const{source:t}=r,{specifiers:a}=r,{declaration:i}=r;let s=!1;const p={start:r.start,end:r.end,adjustContent:""},c=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];if(t&&"Literal"===t.type&&(n.push(t.value),c.push(`var __TEMP__ = require('${t.value}');`),s=!0),i){if("VariableDeclaration"===i.type){const{declarations:t}=i;t&&Array.isArray(t)&&t.forEach(t=>{if("VariableDeclarator"===t.type){const{id:a}=t,{init:n}=t;a&&"Identifier"===a.type&&(p.notAddLines=!0,c.push(`var ${a.name} = exports.${a.name} = ${n?e.substring(n.start,n.end):"undefined"};`))}})}else if("FunctionDeclaration"===i.type){const{id:t}=i;t&&"Identifier"===t.type&&(p.notAddLines=!0,c.push(`${e.substring(i.start,i.end)};exports.${t.name} = ${t.name}`))}else if("ClassDeclaration"===i.type){const{id:t}=i;t&&"Identifier"===t.type&&(p.notAddLines=!0,c.push(`${e.substring(i.start,i.end)};exports.${t.name} = ${t.name}`))}}else;a&&Array.isArray(a)&&a.forEach(e=>{if("ExportSpecifier"===e.type){const{local:t}=e,{exported:a}=e;"Identifier"===t.type&&"Identifier"===a.type&&c.push(`Object.defineProperty(exports, '${a.name}', { enumerable: true, configurable: true, get: function() { return ${s?"__TEMP__.":""}${t.name}; } });`)}}),p.adjustContent=c.join(""),o.push(p)}else if("ExportAllDeclaration"===r.type){const{source:e}=r,t={start:r.start,end:r.end,adjustContent:""},a=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];e&&"Literal"===e.type&&(n.push(e.value),a.push(`var __TEMP__ = require('${e.value}');`)),a.push('Object.keys(__TEMP__).forEach(function(k) { if (k === "default" || k === "__esModule") return; Object.defineProperty(exports, k, { enumerable: true, configurable: true, get: function() { return __TEMP__[k]; } }); });'),t.adjustContent=a.join(""),o.push(t)}else if("ExportDefaultDeclaration"===r.type){const{declaration:t}=r,a={start:r.start,end:r.end,adjustContent:""},n=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];if(t)if(a.notAddLines=!0,t.id){const{id:a}=t;n.push(`${e.substring(t.start,t.end)};exports.default = ${a.name}`)}else n.push(`exports.default = ${e.substring(t.start,t.end)};`);a.adjustContent=n.join(""),o.push(a)}const{expression:p}=r;"ExpressionStatement"===r.type&&p&&"AssignmentExpression"===p.type&&"Identifier"===p.right.type&&"require"===p.right.name&&(a.push({jsPath:t,code:e.substring(r.start,r.end),startLine:r.loc.start.line,endLine:r.loc.end.line,tips:"assign require function to a variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_ASSIGN.format()}),NPM_RECORD.warn_require_rename_num++);const{declarations:c}=r;"VariableDeclaration"===r.type&&c.length>0&&c.forEach(n=>{const{init:o}=n;"VariableDeclarator"===n.type&&o&&"Identifier"===o.type&&"require"===o.name&&(a.push({jsPath:t,code:e.substring(r.start,r.end),startLine:r.loc.start.line,endLine:r.loc.end.line,tips:"assign require function to a variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_ASSIGN.format()}),NPM_RECORD.warn_require_rename_num++)})}),o=o.sort((e,t)=>t.start-e.start),o.forEach(t=>{const a=e.substring(t.start,t.end),n=t.notAddLines?0:a.split("\n").length;e=e.substring(0,t.start)+t.adjustContent+new Array(n).join("\n")+e.substring(t.end)}),{deps:n,parsedContent:e}}async function parseJs(e,t,a,n,r,o){if(r[t=path_1.default.posix.normalize(t)])return r[t];const i=await readFileSync(t,"utf8"),s=getId(),p=path_1.default.posix.relative(e,t);if(t.endsWith(".json")){const e={id:s,name:p,content:"module.exports = "+i,deps:[],depsMap:{}};return r[t]=s,n.push(e),s}const{deps:c,parsedContent:_}=parseDeps(i,t,o),u={id:s,name:p,content:_,deps:c,depsMap:{}};r[t]=s,n.push(u);for(const i of c){let s,p=path_1.default.posix.join(path_1.default.posix.dirname(t),i);if(!p.endsWith(".js")&&!p.endsWith(".json")){const e=p+".js";try{await accessSync(e),p=e}catch(e){}}try{const e=await statSync(p);(null==e?void 0:e.isDirectory())&&(p=path_1.default.posix.join(p,"index.js"))}catch(e){}p.endsWith(".js")||p.endsWith(".json")||(p+=".js");try{await accessSync(p),s=await parseJs(e,p,a,n,r,o)}catch(e){}s&&(u.depsMap[i]=s)}return s}function addJsToMap(e,t,a,n){const r=t.split("\n").length;for(let o=1;o<=r;o++)e.addMapping({generated:{line:n+o,column:0},original:{line:o,column:0},source:a}),e.setSourceContent(a,t)}function findOutsideDeps(e){const t=new Set;return e.forEach(e=>{e.deps.forEach(a=>{Object.keys(e.depsMap).includes(a)||t.add(a)})}),Array.from(t)}async function packJs(e,t,a){try{const t=await statSync(e);(null==t?void 0:t.isDirectory())&&(e=path_1.default.posix.join(e,"index.js"))}catch(e){}e.endsWith(".js")||e.endsWith(".json")||(e+=".js");try{await accessSync(e)}catch(t){return a.push({jsPath:e,code:"",tips:"entry file is not found",msg:locales_1.default.config.NOT_FOUND_NPM_ENTRY.format()}),void NPM_RECORD.warn_not_found_num++}const n=new source_map_1.default.SourceMapGenerator({file:"index.js"}),r=[];await parseJs(path_1.default.posix.dirname(e),e,t,r,{},a);const o=findOutsideDeps(r),i=["module.exports = (function() {","var __MODS__ = {};","var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };",'var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };',"var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };","var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };"];if(r.length){const e=r.shift();i.push(`__DEFINE__(${e.id}, function(require, module, exports) {`),addJsToMap(n,e.content,e.name,i.length),i.push(e.content),i.push(`}, function(modId) {var map = ${JSON.stringify(e.depsMap)}; return __REQUIRE__(map[modId], modId); })`);for(const e of r)i.push(`__DEFINE__(${e.id}, function(require, module, exports) {`),addJsToMap(n,e.content,e.name,i.length),i.push(e.content),i.push(`}, function(modId) { var map = ${JSON.stringify(e.depsMap)}; return __REQUIRE__(map[modId], modId); })`);i.push(`return __REQUIRE__(${e.id});`)}return i.push("})()"),i.push("//miniprogram-npm-outsideDeps="+JSON.stringify(o)),i.push("//# sourceMappingURL=index.js.map"),{js:i.join("\n"),map:n.toString()}}async function checkIsMiniprogramPack(e,t){let a="miniprogram_dist";t.miniprogram&&"string"==typeof t.miniprogram&&(a=t.miniprogram);try{const t=path_1.default.posix.join(e,a);await accessSync(t);const n=await statSync(t);if(null==n?void 0:n.isDirectory())return t}catch(e){}return""}async function packNpm(e,t={}){const{projectPath:a}=e,n=e.type,r=await(0,projectconfig_1.getProjectConfigJSON)(e),o=r.pluginRoot||"",i=r.miniprogramRoot||"",s="miniProgramPlugin"===n||"miniGamePlugin"===n,{ignores:p,reporter:c}=t;if(!a)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format("projectPath"),config_1.PARAM_ERROR);if("miniProgramPlugin"===n&&!o)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('project.config.json "pluginRoot"'),config_1.PARAM_ERROR);startRecord();const _=path_1.default.isAbsolute(a)?a:path_1.default.posix.join(process.cwd(),a),u=[{searchRoot:path_1.default.posix.join(_,i),paths:await globSync("**/package.json",{cwd:path_1.default.posix.join(_,i),nodir:!0,dot:!0,ignore:(p||[]).concat("**/node_modules/**")})}];s&&u.push({searchRoot:path_1.default.posix.join(_,o),paths:await globSync("**/package.json",{cwd:path_1.default.posix.join(_,o),nodir:!0,dot:!0,ignore:(p||[]).concat("**/node_modules/**")})});lodash_1.default.flattenDeep(u.map(e=>e.paths.map(t=>path_1.default.posix.join(e.searchRoot,path_1.default.dirname(t),"miniprogram_npm")))).forEach(e=>rimraf_1.default.sync(e));const l=[];for(const e of u)for(const t of e.paths){const a=path_1.default.dirname(path_1.default.posix.join(e.searchRoot,t)),n=lodash_1.default.xorWith(e.paths,[t]).map(e=>path_1.default.posix.join(path_1.default.posix.dirname(e),"/**")).filter(e=>"**"!==e);let r=await globSync("**/package.json",{cwd:a.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:(p||[]).concat(n).concat(["node_modules/@types/**"])});if(r=await(0,filterdeps_1.default)(a,r),r&&r.length)for(const e of r){const t=path_1.default.posix.join(a,e);let n=await readFileSync(t,"utf8");const r=path_1.default.dirname(t);let o=r.replace(/([\b/\\])node_modules([\b/\\])/g,(e,t,a)=>`${t}miniprogram_npm${a}`),i=path_1.default.basename(o);const s=i.split("@");s.length&&(i=s.pop()||""),o=o.replace(path_1.default.basename(o),i),n=JSON.parse(n);const p=path_1.default.posix.join(r,n.main||"index.js"),c=await checkIsMiniprogramPack(r,n);if(c){const e=await globSync("**/*",{cwd:c.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:"**/node_modules/**"});for(const t of e)await copyFile(path_1.default.posix.join(c,t),path_1.default.posix.join(o,t));NPM_RECORD.miniprogram_pack_num++}else{const e=await packJs(p,o,l);if(!e)continue;await writeFile(e.js,path_1.default.posix.join(o,"./index.js")),await writeFile(e.map,path_1.default.posix.join(o,"./index.js.map")),NPM_RECORD.other_pack_num++}}}if(endRecord(c),NPM_RECORD.miniprogram_pack_num+NPM_RECORD.other_pack_num<=0)throw new Error("__NO_NODE_MODULES__ "+locales_1.default.config.NOT_FOUND_NODE_MODULES.format());return"function"==typeof e.updateFileAndDirs&&e.updateFileAndDirs(),l}async function packNpmManually(e){let{packageJsonPath:t,miniprogramNpmDistDir:a}=e;const n=e.ignores||[],r={pack_time:0,miniprogram_pack_num:0,other_pack_num:0,warn_not_found_num:0,warn_require_var_num:0,warn_require_rename_num:0},o=[];if(!a)throw new Error("param miniprogramNpmDistDir is required");if(!t)throw new Error("param packageJsonPath is required");if(path_1.default.isAbsolute(a)||(a=path_1.default.join(process.cwd(),a)),path_1.default.isAbsolute(t)||(t=path_1.default.join(process.cwd(),t)),!fs_1.default.existsSync(t))throw new Error(`param packageJsonPath: ${t} file is not exited`);const i=path_1.default.dirname(t);let s=await globSync("**/package.json",{cwd:i.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:(n||[]).concat(["node_modules/@types/**"])});if(s=await(0,filterdeps_1.default)(i,s),!s||!s.length){const e={jsPath:i,code:"",tips:"",msg:"No miniprogram_npm package was found, please check package.json -> dependencies."};return log.warn(e.msg),o.push(e),{miniProgramPackNum:0,otherNpmPackNum:0,warnList:o}}s=s.filter(e=>e.startsWith("node_modules"));for(const e of s){const t=path_1.default.posix.join(i,e);let n=await readFileSync(t,"utf8");const s=path_1.default.dirname(t);let p=s.replace(/([\b/\\])node_modules([\b/\\])/g,(e,t,a)=>`${t}miniprogram_npm${a}`);p=path_1.default.posix.normalize(path_1.default.posix.join(a,"miniprogram_npm",p.split(/[/\\]miniprogram_npm[/\\]/)[1]));let c=path_1.default.basename(p);const _=c.split("@");_.length&&(c=_.pop()||""),p=p.replace(path_1.default.basename(p),c),n=JSON.parse(n);const u=path_1.default.posix.join(s,n.main||"index.js"),l=await checkIsMiniprogramPack(s,n);if(l){const e=await globSync("**/*",{cwd:l.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:"**/node_modules/**"});for(const t of e)await copyFile(path_1.default.posix.join(l,t),path_1.default.posix.join(p,t));r.miniprogram_pack_num++}else{const e=await packJs(u,p,o);if(!e)continue;await writeFile(e.js,path_1.default.posix.join(p,"./index.js")),await writeFile(e.map,path_1.default.posix.join(p,"./index.js.map")),r.other_pack_num++}}return{miniProgramPackNum:r.miniprogram_pack_num,otherNpmPackNum:r.other_pack_num,warnList:o}}exports.packNpm=packNpm,exports.packNpmManually=packNpmManually;
|
|
@@ -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"),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)
|
|
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,ext:this.ext,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.ext=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=await t.run(locales_1.default.config.SUMMER_COMPILE.format("ext.json"),()=>(0,original_1.getExtJSON)(this.proxyProject));this.ext=a;const{project:e}=this.proxyProject,s=new Set;for(const t of o.pages)s.add(t);for(const t of e.injectedPages)s.add((0,util_1.resolvePath)("app.json",t));const i=o.subPackages||[];for(const t of i){const o=t.root;this.packages.set(o,t);for(const a of t.pages)s.add(path_1.default.posix.join(o,a))}await t.run(locales_1.default.config.SUMMER_COMPILE_PAGE_JSON.format(s.size),async()=>{var t;for(const[t]of s.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 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:t.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
|
+
"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:t.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),s.ext&&(o["ext.json"]=JSON.stringify(s.ext));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),s.ext&&(o["ext.json"]=JSON.stringify(s.ext));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.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"),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,a){super(e),this.project=e,this.cachePath=t,this.projectInfo=i,this.devtoolMessagehub=s,this.analyzer=o,this._filterFactory=a,this.isSummer=!0,this.promiseCache=new Map,this._taskCache=new Map,this._status=void 0,this._eventAdded=!1,this._locale="",this.devCodeCacheByPath=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)=>{var s;this.messageHub.showBuildLog(""+e,t,i),null===(s=this.progressUpdateFromCompileOptions)||void 0===s||s.call(this,{id:e.toString(),message:i,status:t})},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,a=await this.filterFactory(i),r={},n=s.filter(t=>{const i=path_1.default.posix.join(o,t.path),s=a(e,i);return s!==config_1.EFilterCode.Include&&(r[s]||(r[s]=[]),r[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 r)c[e]?this.onProgressUpdate(e,"warn",c[e].format(r[e].join(","))):this.onProgressUpdate(e,"warn",locales_1.default.config.UNKNOWN_REASON_INGORE_LIST.format(e,r[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.onProgressUpdate),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.promiseCache.clear(),this.devCodeCacheByPath.clear(),this._taskCache.clear()}updateOptions(e){var t;lodash_1.default.isEqual(e,this.projectInfo)||(this.projectInfo=e,this.promiseCache.clear(),this.devCodeCacheByPath.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){const t=this.devCodeCacheByPath.get((0,tools_1.sourcePathToTargetPath)(e));t&&(t.isValid=!1)}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},a=this.subProcessManager.runTask("getConf",o,this.onProgressUpdate);return this.promiseCache.set(s,a),performanceMark("request get conf",!0),a}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 a=new singletontask_1.SingletonTask(this._getPackageFiles.bind(this,e,t,i),o);return this._taskCache.set(o,a),null==a?void 0:a.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),0!==packOptionsHelper_1.default.getUnusedFiles().size&&this.onProgressUpdate("initUnusedFiles","doing","ignoring files: "+Array.from(packOptionsHelper_1.default.getUnusedFiles()).join(",")),this.onProgressUpdate("initUnusedFiles","success","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,a=[];for(const e of t){const t=this.devCodeCacheByPath.get(path_1.default.posix.join(o,e)),r=null==t?void 0:t.codeFile;let n=!1;t&&t.isValid&&r&&!("error"in r)||(n=!0,a.push(e)),r&&!("error"in r)&&(n&&(i[e]=r.md5),s[e]=r)}if(a.length>0){const t=await this.subProcessManager.runTask("getDevCodeByFileList",{graphId:e,fileList:a,cacheMd5:i},this.onProgressUpdate);for(const e in t){const i=t[e],a=path_1.default.posix.join(o,e);"error"in i||""!==i.md5?this.devCodeCacheByPath.set(a,{isValid:!0,codeFile:i}):this.devCodeCacheByPath.delete(a),s[e]=i}}return s}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)),a=i.map(e=>e+".js").filter(e=>s.includes(e)),r=s.filter(e=>e.endsWith(".js")&&"app.js"!==e&&!o.includes(e)&&!a.includes(e));return{jsPagesFiles:o,components:a,otherJsFiles:r}}async getAllWxmlAndWxsFiles(){const e=(await this.getPackageFiles(miniProgram,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(miniProgram,t.concat(i));return{wxmlFiles:t,wxsFiles:i,content:t.concat(i).reduce((e,t)=>{const i=s[t];if("error"in i)throw i.error;return e[t]=i.code,e["./"+t]=i.code,e},{})}}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),e===miniProgram?t=path_1.default.posix.join(this.project.miniprogramRoot,t):e===miniProgramPlugin&&(t=path_1.default.posix.join(this.project.pluginRoot,t));const i=this.devCodeCacheByPath.get(t),s=null==i?void 0:i.codeFile;if(s&&!("error"in s))return s.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=[],a=[],r=[];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,r.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,a.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:a,functionalPageFiles:r,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=[],a=[],r={},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(r[e])return;r[e]=!0;const i=encodeURI(e);a.push(""+i)});Object.keys(t.pages).filter(t=>n(t)===e).forEach(e=>{if(r[e])return;r[e]=!0;const t=encodeURI(e);s.push(""+t)});let c=t.packages[e].entry||"";c&&(c=path_1.default.posix.join(e,c),c=c.replace(/\.js$/,"")),i.forEach(e=>{const t=e.replace(/\.js$/,"");r[t]||(r[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:a,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,mtime:t.mtime},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,mtime:i.mtime},i.jsTag)}async compile(e){Date.now();this.progressUpdateFromCompileOptions=e.onProgressUpdate;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,analyzer:void 0}),this.onProgressUpdate),s=i.app,o=Object.keys(s).filter(e=>e.endsWith(".json"));this.onProgressUpdate(111,"doing",locales_1.default.config.SUMMER_PACK_FILES.format());const a=await this.compileOther(this.isGameType(this.project.type)?miniGame:miniProgram,e.resultType||"prod",o);let r={};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(a).forEach(e=>{r[path_1.default.posix.join("miniprogram",e)]=a[e]}),Object.keys(n).forEach(e=>{r[path_1.default.posix.join("plugin",e)]=n[e]}),Object.keys(s).forEach(e=>{r[path_1.default.posix.join("miniprogram",e)]=s[e]}),Object.keys(t).forEach(e=>{r[path_1.default.posix.join("plugin",e)]=t[e]}),r["project.config.json"]=JSON.stringify({miniprogramRoot:"miniprogram",pluginRoot:"plugin",__compileDebugInfo__:{useSummer:!0}})}else r=Object.assign(Object.assign({},a),s),r["project.config.json"]=JSON.stringify({miniprogramRoot:"",__compileDebugInfo__:{useSummer:!0}});this.onProgressUpdate(111,"success",locales_1.default.config.SUMMER_PACK_FILES_FINISH.format());for(const e of Object.keys(r))"object"==typeof r[e]&&"Buffer"===r[e].type&&(r[e]=Buffer.from(r[e].data));return r}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 a=o.MiniProgramWhiteList;this.isGameType(this.project.type)&&(a=o.GameWhiteList);const r=this.isPluginType(e)?this.project.pluginRoot:this.project.miniprogramRoot,n=await this.filterFactory(t),c=this.project.getFileList(r,"").filter(t=>{const o=path_1.default.posix.extname(t),c=path_1.default.posix.relative(r,t);return!(!a.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(r,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
|
+
"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"),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"),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,a){super(e),this.project=e,this.cachePath=t,this.projectInfo=i,this.devtoolMessagehub=s,this.analyzer=o,this._filterFactory=a,this.isSummer=!0,this.promiseCache=new Map,this._taskCache=new Map,this._status=void 0,this._eventAdded=!1,this._locale="",this.devCodeCacheByPath=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)=>{var s;this.messageHub.showBuildLog(""+e,t,i),null===(s=this.progressUpdateFromCompileOptions)||void 0===s||s.call(this,{id:e.toString(),message:i,status:t})},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,a=await this.filterFactory(i),r={},n=s.filter(t=>{const i=path_1.default.posix.join(o,t.source),s=a(e,i);return s!==config_1.EFilterCode.Include&&(r[s]||(r[s]=[]),r[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 r)c[e]?this.onProgressUpdate(e,"warn",c[e].format(r[e].join(","))):this.onProgressUpdate(e,"warn",locales_1.default.config.UNKNOWN_REASON_INGORE_LIST.format(e,r[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.onProgressUpdate),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.promiseCache.clear(),this.devCodeCacheByPath.clear(),this._taskCache.clear()}updateOptions(e){var t;lodash_1.default.isEqual(e,this.projectInfo)||(this.projectInfo=e,this.promiseCache.clear(),this.devCodeCacheByPath.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){const t=this.devCodeCacheByPath.get((0,tools_1.sourcePathToTargetPath)(e));t&&(t.isValid=!1)}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},a=this.subProcessManager.runTask("getConf",o,this.onProgressUpdate);return this.promiseCache.set(s,a),performanceMark("request get conf",!0),a}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 a=new singletontask_1.SingletonTask(this._getPackageFiles.bind(this,e,t,i),o);return this._taskCache.set(o,a),null==a?void 0:a.getResult(!0)}isMiniappPlatformInclude(e){const t=path_1.default.posix.join(this.project.miniprogramRoot,"app.miniapp.json");return(0,tools_1.isMiniappPlatform)(this.project.targetPlatform)&&t===e}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),0!==packOptionsHelper_1.default.getUnusedFiles().size&&this.onProgressUpdate("initUnusedFiles","doing","ignoring files: "+Array.from(packOptionsHelper_1.default.getUnusedFiles()).join(",")),this.onProgressUpdate("initUnusedFiles","success","analyzing codes success");const t=this._filterFactory?await this._filterFactory(e):()=>0;return(i,s)=>{const o=packOptionsHelper_1.default.relativePath(s);return this.isMiniappPlatformInclude(s)||packOptionsHelper_1.default.isFileIncluded(o)?config_1.EFilterCode.Include:packOptionsHelper_1.default.isIgnoredByRules(o)?config_1.EFilterCode.PackOptionsIgnore:i===miniProgram&&packOptionsHelper_1.default.isIgnoreByUnusedFiles(s,"prod"===e)?config_1.EFilterCode.AnalyseNoUse:t(i,s)}}async getCodeByFileList(e,t){const i={},s={},o=this.isPluginType(e)?this.project.pluginRoot:this.project.miniprogramRoot,a=[];for(const e of t){const t=this.devCodeCacheByPath.get(path_1.default.posix.join(o,e)),r=null==t?void 0:t.codeFile;let n=!1;t&&t.isValid&&r&&!("error"in r)||(n=!0,a.push(e)),r&&!("error"in r)&&(n&&(i[e]=r.md5),s[e]=r)}if(a.length>0){const t=await this.subProcessManager.runTask("getDevCodeByFileList",{graphId:e,fileList:a,cacheMd5:i},this.onProgressUpdate);for(const e in t){const i=t[e],a=path_1.default.posix.join(o,e);"error"in i||""!==i.md5?this.devCodeCacheByPath.set(a,{isValid:!0,codeFile:i}):this.devCodeCacheByPath.delete(a),s[e]=i}}return s}async getExtJSON(){return(await this.getConf(miniProgram)).ext}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)),a=i.map(e=>e+".js").filter(e=>s.includes(e)),r=s.filter(e=>e.endsWith(".js")&&"app.js"!==e&&!o.includes(e)&&!a.includes(e));return{jsPagesFiles:o,components:a,otherJsFiles:r}}async getAllWxmlAndWxsFiles(){const e=(await this.getPackageFiles(miniProgram,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(miniProgram,t.concat(i));return{wxmlFiles:t,wxsFiles:i,content:t.concat(i).reduce((e,t)=>{const i=s[t];if("error"in i)throw i.error;return e[t]=i.code,e["./"+t]=i.code,e},{})}}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),e===miniProgram?t=path_1.default.posix.join(this.project.miniprogramRoot,t):e===miniProgramPlugin&&(t=path_1.default.posix.join(this.project.pluginRoot,t));const i=this.devCodeCacheByPath.get(t),s=null==i?void 0:i.codeFile;if(s&&!("error"in s))return s.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=[],a=[],r=[];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,r.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,a.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:a,functionalPageFiles:r,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=[],a=[],r={},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(r[e])return;r[e]=!0;const i=encodeURI(e);a.push(""+i)});Object.keys(t.pages).filter(t=>n(t)===e).forEach(e=>{if(r[e])return;r[e]=!0;const t=encodeURI(e);s.push(""+t)});let c=t.packages[e].entry||"";c&&(c=path_1.default.posix.join(e,c),c=c.replace(/\.js$/,"")),i.forEach(e=>{const t=e.replace(/\.js$/,"");r[t]||(r[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:a,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,mtime:t.mtime},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,mtime:i.mtime},i.jsTag)}async compile(e){Date.now();this.progressUpdateFromCompileOptions=e.onProgressUpdate;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,analyzer:void 0}),this.onProgressUpdate),s=i.app,o=Object.keys(s).filter(e=>e.endsWith(".json")),a=await this.compileOther(this.isGameType(this.project.type)?miniGame:miniProgram,e.resultType||"prod",o);let r={};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(a).forEach(e=>{r[path_1.default.posix.join("miniprogram",e)]=a[e]}),Object.keys(n).forEach(e=>{r[path_1.default.posix.join("plugin",e)]=n[e]}),Object.keys(s).forEach(e=>{r[path_1.default.posix.join("miniprogram",e)]=s[e]}),Object.keys(t).forEach(e=>{r[path_1.default.posix.join("plugin",e)]=t[e]}),r["project.config.json"]=JSON.stringify({miniprogramRoot:"miniprogram",pluginRoot:"plugin",__compileDebugInfo__:{useSummer:!0}})}else r=Object.assign(Object.assign({},a),s),r["project.config.json"]=JSON.stringify({miniprogramRoot:"",__compileDebugInfo__:{useSummer:!0}});this.onProgressUpdate(111,"success",locales_1.default.config.SUMMER_PACK_FILES_FINISH.format());for(const e of Object.keys(r))"object"==typeof r[e]&&"Buffer"===r[e].type&&(r[e]=Buffer.from(r[e].data));return r}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 a=o.MiniProgramWhiteList;this.isGameType(this.project.type)&&(a=o.GameWhiteList);const r=this.isPluginType(e)?this.project.pluginRoot:this.project.miniprogramRoot,n=await this.filterFactory(t),c=this.project.getFileList(r,"").filter(t=>{const o=path_1.default.posix.extname(t),c=path_1.default.posix.relative(r,t);return!(!a.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(r,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")),
|
|
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")),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,i,t,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 m=["es6","minified","postcss","uglifyFileName","compileWorklet","enhance","minifyWXML","minifyWXSS","disableUseStrict","swc","useCompilerPlugins","babelSetting","swcSetting","minifyWXMLSetting","condition","targetPlatform"],l=null!==(i=null===(r=this.project)||void 0===r?void 0:r.setting)&&void 0!==i?i:{},c=null!==(t=e.setting)&&void 0!==t?t:{};for(const e of m){const r=l[e],i=c[e];if(!lodash_1.default.isEqual(r,i))return console.info(`shouldCreate return true, project.setting.${e}, before: ${JSON.stringify(r)}, after: ${JSON.stringify(i)}`),!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 i=new ciProject_1.CIProject(e);await i.ready();const t=this.ensureCacheDir(),o=this.getSummerOptions(e),s=new summerCompiler_1.SummerCompiler(i,t,o,{showBuildLog:()=>{}},r);return await s.ready(),s}getSummerOptions(e){const r=(0,pluginconfig_1.getSummerPluginConfig)(e.setting),i={[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:i,summerPlugins:r,setting:Object.assign({},e.setting),injectedPages:[]}}}exports.SummerCompilerFactory=SummerCompilerFactory,exports.summerCompilerFactory=new SummerCompilerFactory,exports.getSummerCompiler=exports.summerCompilerFactory.getSummerCompiler.bind(exports.summerCompilerFactory);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const os = require('os');
|
|
2
|
+
let platform = null;
|
|
3
|
+
const { arch } = process;
|
|
4
|
+
if (os.type() == 'Windows_NT') {
|
|
5
|
+
platform = 'win32';
|
|
6
|
+
} else if (os.type() == 'Darwin') {
|
|
7
|
+
platform = 'darwin';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
getAddonRelativePath(type) {
|
|
12
|
+
if (type === 'wcc'
|
|
13
|
+
|| type === 'wcsc') {
|
|
14
|
+
if (platform) {
|
|
15
|
+
return `../build/${platform}_${arch}/${type}.node`;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
};
|