miniprogram-ci 2.1.35 → 2.1.37

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 CHANGED
@@ -1,3 +1,7 @@
1
+ #### 2.1.37
2
+ - `new` 支持获取超大 sourcemap 的情况
3
+ #### 2.1.36
4
+ - `fix` 修复不编译代码的情况下代码体积依然变大的问题
1
5
  #### 2.1.35
2
6
  - `fix` 依赖分析升级
3
7
  #### 2.1.34
package/README.md CHANGED
@@ -7,6 +7,10 @@ miniprogram-ci 是从[微信开发者工具](https://developers.weixin.qq.com/mi
7
7
  miniprogram-ci 从 1.0.28 开始支持第三方平台开发的上传和预览,调用方式与普通开发模式无异。[查看详情](#第三方平台开发)
8
8
 
9
9
  ## 最近变更
10
+ #### 2.1.37
11
+ - `new` 支持获取超大 sourcemap 的情况
12
+ #### 2.1.36
13
+ - `fix` 修复不编译代码的情况下代码体积依然变大的问题
10
14
  #### 2.1.35
11
15
  - `fix` 依赖分析升级
12
16
  #### 2.1.34
@@ -1,8 +1,14 @@
1
1
  import { IProject } from '../types';
2
+ export interface ISourceMapProgress {
3
+ totalSize: number;
4
+ downloadedSize: number;
5
+ percentage: number;
6
+ }
2
7
  export interface IGetDevSourceMapOption {
3
8
  project: IProject;
4
9
  robot: number;
5
10
  sourceMapSavePath: string;
6
11
  streaming?: boolean;
12
+ onProgress?: (info: ISourceMapProgress) => void;
7
13
  }
8
14
  export declare function getDevSourceMap(options: IGetDevSourceMapOption): Promise<any>;
@@ -1,5 +1,5 @@
1
1
  import { IProject } from '../types';
2
- export declare const CI_VERSION = "2.1.35";
2
+ export declare const CI_VERSION = "2.1.37";
3
3
  export declare const PARAM_ERROR = 10000;
4
4
  export declare const WXML_NOT_FOUND = 10007;
5
5
  export declare const JS_NOT_FOUND = 10008;
@@ -5,6 +5,7 @@ export declare const GET_WHITE_EXT_LIST = "https://servicewechat.com/wxa/ci/getw
5
5
  export declare const GET_ONLINE_SCHEMA = "https://servicewechat.com/wxa/ci/getonlineschema";
6
6
  export declare const GET_RAND_STRING = "https://servicewechat.com/wxa/ci/getrandstr";
7
7
  export declare const GET_DEV_SOURCE_MAP = "https://servicewechat.com/wxa/ci/get_dev_sourcemap";
8
+ export declare const GET_DEV_SOURCE_MAP_INFO = "https://servicewechat.com/wxa/ci/get_dev_sourcemap_info";
8
9
  export declare const TRANSLATE_FILENAME = "https://servicewechat.com/wxa/ci/translate_filename";
9
10
  export declare const GET_CLOUD_API_SIGNATURE = "https://servicewechat.com/wxa/ci/getqcloudapisignature";
10
11
  export declare const GET_UPLOAD_TOKEN = "https://servicewechat.com/wxa/ci/getuploadtoken";
@@ -15,6 +15,7 @@ export declare function bableCompile(sourcePath: string, source: MiniProgramSumm
15
15
  enhance?: boolean;
16
16
  babelRoot: string;
17
17
  disableUseStrict: boolean;
18
+ compileWorklet?: boolean;
18
19
  }): Promise<{
19
20
  code: string;
20
21
  map: any;
@@ -119,6 +119,14 @@ export declare namespace AppJSON {
119
119
  miniApp?: {
120
120
  useAuthorizePage: boolean;
121
121
  };
122
+ agent: {
123
+ skills: {
124
+ name: string;
125
+ description: string;
126
+ path: string;
127
+ }[];
128
+ pageMetadata: string;
129
+ };
122
130
  }
123
131
  interface ISupportMaterial {
124
132
  materialType: string;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getDevSourceMap=getDevSourceMap;const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),path_1=tslib_1.__importDefault(require("path")),log=tslib_1.__importStar(require("../utils/log")),request_1=require("../utils/request"),url_config_1=require("../config/url.config"),sign_1=require("../utils/sign"),JsZip=require("jszip"),ERR_MSG_PREFIX="download source map failed:";async function getExtAppId(r){let e,t={};try{e=await r.getFile(r.miniprogramRoot,"ext.json"),t=JSON.parse(e.toString("utf-8"))}catch(r){}if(null==t?void 0:t.extEnable)return t.extAppid}async function getDevSourceMap(r){const{project:e,robot:t,streaming:o}=r;let{sourceMapSavePath:a}=r;if(!e){const r="params project is requried";throw log.error(r),r}if("number"!=typeof t||Math.round(t)>30||Math.round(t)<=0){const r="params robot is invalid";throw log.error(r),r}if(!a){const r="params sourceMapSavePath is invalid";throw log.error(r),r}path_1.default.isAbsolute(a)||(a=path_1.default.join(process.cwd(),a));const i=await(0,sign_1.getSignature)(e.privateKey,e.appid),s=await getExtAppId(e),{body:p}=await(0,request_1.request)({url:url_config_1.GET_DEV_SOURCE_MAP,method:"post",gzip:!0,body:JSON.stringify({appid:e.appid,signature:i,robot:t,extAppId:s,streaming:o}),headers:{"content-type":"application/json"}});let l,n;try{l=JSON.parse(p)}catch(r){const e=`${ERR_MSG_PREFIX} resp body is not a valid json`;throw log.error(e),e}if(o)n=l.sourcemap_list;else{if(0!==l.errCode)throw new Error(`request failed, errCode: ${l.errCode}, errMsg: ${l.errMsg}`);const r=l.data;if(!Array.isArray(r.sourcemap_list)){const e=`${ERR_MSG_PREFIX} respData.sourcemap_list, respData: ${JSON.stringify(r)}`;throw log.error(e),e}n=r.sourcemap_list}const u=n,c=new JsZip;try{u.forEach((r=>{c.folder(path_1.default.dirname(r.fullpath)).file(path_1.default.basename(r.fullpath),r.sourcemap)}))}catch(r){const e=`${ERR_MSG_PREFIX} source map add folder or add file error`;throw log.error(e),e}let _;try{_=await c.generateAsync({type:"nodebuffer"})}catch(r){const e=`${ERR_MSG_PREFIX} source map generate zip error`;throw log.error(e),e}try{fs_1.default.writeFileSync(a,_)}catch(r){const e=`${ERR_MSG_PREFIX} save source map to ${a} failed. Error detail: ${JSON.stringify(r)}`;throw log.error(e),e}return _}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getDevSourceMap=getDevSourceMap;const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),path_1=tslib_1.__importDefault(require("path")),log=tslib_1.__importStar(require("../utils/log")),request_1=require("../utils/request"),url_config_1=require("../config/url.config"),sign_1=require("../utils/sign"),JsZip=require("jszip"),ERR_MSG_PREFIX="download source map failed:";async function getExtAppId(e){let r,t={};try{r=await e.getFile(e.miniprogramRoot,"ext.json"),t=JSON.parse(r.toString("utf-8"))}catch(e){}if(null==t?void 0:t.extEnable)return t.extAppid}async function fetchSourceMapInfo(e,r,t,o){const{body:a}=await(0,request_1.request)({url:url_config_1.GET_DEV_SOURCE_MAP_INFO,method:"post",gzip:!0,body:JSON.stringify({appid:e,signature:r,robot:t,extAppId:o}),headers:{"content-type":"application/json"}});let i;try{i=JSON.parse(a)}catch(e){const r=`${ERR_MSG_PREFIX} info resp is not valid json`;throw log.error(r),new Error(r)}if(0!==i.errCode){const e=`${ERR_MSG_PREFIX} get info failed, errCode: ${i.errCode}, errMsg: ${i.errMsg}`;throw log.error(e),new Error(e)}return i.data}async function fetchChunk(e,r,t,o,a,i){var s,n;const{body:p}=await(0,request_1.request)({url:url_config_1.GET_DEV_SOURCE_MAP,method:"post",body:JSON.stringify({appid:e,signature:r,robot:t,extAppId:o,offset:a,limit:i}),headers:{"content-type":"application/json"}}),l=Buffer.isBuffer(p)?p.toString():p;let c="";try{const e=JSON.parse(l);if(0!==(null===(s=e.innerRequestResp)||void 0===s?void 0:s.errCode))throw new Error(`get-sourcemap-chunk fetch faield, errcode=${null===(n=e.innerRequestResp)||void 0===n?void 0:n.errCode}`);c=e.innerRequestResp.body}catch(e){throw new Error(`get-sourcemap-chunk failed: JSON.parse err ${e}, ${l}`)}return c}async function downloadChunked(e,r,t,o,a,i,s){const n=[];let p=0;for(let l=0;l<o;l+=a){let c=a;l+a>o&&(c=o-l),log.info(`downloading sourcemap chunk offset=${l}, limit=${c}`);const u=await i(),d=await fetchChunk(e,u,r,t,l,c);n.push(d),p+=d.length,s&&s({totalSize:o,downloadedSize:p,percentage:Math.min(100,Math.round(p/o*100))})}const l=n.join("");try{return{errCode:0,data:JSON.parse(l),errMsg:""}}catch(e){throw new Error(`downloadChunked JSON.parse(wholeChunk) failed ${e}`)}}async function getDevSourceMap(e){const{project:r,robot:t,onProgress:o}=e;let{streaming:a}=e;void 0===a&&(a=!0);let{sourceMapSavePath:i}=e;if(!r){const e="params project is requried";throw log.error(e),e}if("number"!=typeof t||Math.round(t)>30||Math.round(t)<=0){const e="params robot is invalid";throw log.error(e),e}if(!i){const e="params sourceMapSavePath is invalid";throw log.error(e),e}path_1.default.isAbsolute(i)||(i=path_1.default.join(process.cwd(),i));const s=await(0,sign_1.getSignature)(r.privateKey,r.appid),n=await getExtAppId(r);let p="",l={errCode:0,data:{},errMsg:""};if(a){log.info("fetching sourcemap info...");const e=await fetchSourceMapInfo(r.appid,s,t,n);log.info(`sourcemap total_size: ${e.total_size} bytes, chunk limit: ${e.limit} bytes`);const a=e.limit;l=await downloadChunked(r.appid,t,n,e.total_size,a,(async()=>await(0,sign_1.getSignature)(r.privateKey,r.appid)),o)}else p=(await(0,request_1.request)({url:url_config_1.GET_DEV_SOURCE_MAP,method:"post",gzip:!0,body:JSON.stringify({appid:r.appid,signature:s,robot:t,extAppId:n,streaming:!1}),headers:{"content-type":"application/json"}})).body;if("string"==typeof p&&p.length>0)try{l=JSON.parse(p)}catch(e){const r=`${ERR_MSG_PREFIX} resp body is not a valid json`;throw log.error(r),r}if(0!==l.errCode)throw new Error(`request failed, errCode: ${l.errCode}, errMsg: ${l.errMsg}`);const c=l.data;if(!Array.isArray(c.sourcemap_list)){const e=`${ERR_MSG_PREFIX} respData.sourcemap_list, respData: ${JSON.stringify(c)}`;throw log.error(e),e}const u=c.sourcemap_list,d=new JsZip;try{u.forEach((e=>{d.folder(path_1.default.dirname(e.fullpath)).file(path_1.default.basename(e.fullpath),e.sourcemap)}))}catch(e){const r=`${ERR_MSG_PREFIX} source map add folder or add file error`;throw log.error(r),r}let f;try{f=await d.generateAsync({type:"nodebuffer"})}catch(e){const r=`${ERR_MSG_PREFIX} source map generate zip error`;throw log.error(r),r}try{fs_1.default.writeFileSync(i,f)}catch(e){const r=`${ERR_MSG_PREFIX} save source map to ${i} failed. Error detail: ${JSON.stringify(e)}`;throw log.error(r),r}return f}
@@ -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.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.getDefaultIgnores=getDefaultIgnores,exports.CI_VERSION="2.1.35",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=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.compileTypeConfig={weapp:"weapp",game:"game",plugin:"plugin",gamePlugin:"gamePlugin"},function(e){e.Babel="babel",e.Acorn="acorn"}(AstType||(exports.AstType=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=EFilterCode={})),exports.MAX_CODE_LENGTH=2048e3;
1
+ "use strict";var COMPILE_TYPE,AstType,EFilterCode;function getDefaultIgnores(e){const _=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];return"multiPlatform"===e.projectArchitecture&&_.push(`${exports.multiPlatformRoot}/**/*`),_}Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=exports.EFilterCode=exports.AstType=exports.compileTypeConfig=exports.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.getDefaultIgnores=getDefaultIgnores,exports.CI_VERSION="2.1.37",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=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.compileTypeConfig={weapp:"weapp",game:"game",plugin:"plugin",gamePlugin:"gamePlugin"},function(e){e.Babel="babel",e.Acorn="acorn"}(AstType||(exports.AstType=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=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_UPLOAD_SIGN=exports.GET_UPLOAD_INFO=exports.GET_PLUG_PKG_CHECK_USERVERSION=exports.GET_PLUG_PKG_GET_URL=exports.GET_PLUG_PKG_GET_LIST=exports.GET_MULTI_COS_UPLOAD_SIGN=exports.GET_MULTI_COS_UPLOAD_INFO=exports.GET_MULTI_COS_ASYNC_RESULT=exports.GET_GAME_PKG_UPLOAD_SIGN=exports.GET_GAME_PKG_UPLOAD_INFO=exports.GET_GAME_PKG_ASYNC_RESULT=exports.GAME_PKG_UPLOAD_URL=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.GAME_PKG_UPLOAD_URL=`${Domain}/wxa/ci/gamepkgupload`,exports.GET_GAME_PKG_ASYNC_RESULT=`${Domain}/wxa/ci/getgamepkgasyncresult`,exports.GET_GAME_PKG_UPLOAD_INFO=`${Domain}/wxa/ci/getgamepkguploadinfo`,exports.GET_GAME_PKG_UPLOAD_SIGN=`${Domain}/wxa/ci/getgamepkguploadsign`,exports.GET_MULTI_COS_ASYNC_RESULT=`${Domain}/wxa/ci/getmulticosasyncresult`,exports.GET_MULTI_COS_UPLOAD_INFO=`${Domain}/wxa/ci/getmulticosuploadinfo`,exports.GET_MULTI_COS_UPLOAD_SIGN=`${Domain}/wxa/ci/getmulticosuploadsign`,exports.GET_PLUG_PKG_GET_LIST=`${Domain}/wxa/ci/apkpluggetlist`,exports.GET_PLUG_PKG_GET_URL=`${Domain}/wxa/ci/apkpluggeturl`,exports.GET_PLUG_PKG_CHECK_USERVERSION=`${Domain}/wxa/ci/apkplugcheckuserversion`,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`;
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_PLUG_PKG_CHECK_USERVERSION=exports.GET_PLUG_PKG_GET_URL=exports.GET_PLUG_PKG_GET_LIST=exports.GET_MULTI_COS_UPLOAD_SIGN=exports.GET_MULTI_COS_UPLOAD_INFO=exports.GET_MULTI_COS_ASYNC_RESULT=exports.GET_GAME_PKG_UPLOAD_SIGN=exports.GET_GAME_PKG_UPLOAD_INFO=exports.GET_GAME_PKG_ASYNC_RESULT=exports.GAME_PKG_UPLOAD_URL=exports.GET_ASYNC_RESULT=exports.GET_UPLOAD_TOKEN=exports.GET_CLOUD_API_SIGNATURE=exports.TRANSLATE_FILENAME=exports.GET_DEV_SOURCE_MAP_INFO=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.GET_DEV_SOURCE_MAP_INFO=`${Domain}/wxa/ci/get_dev_sourcemap_info`,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.GAME_PKG_UPLOAD_URL=`${Domain}/wxa/ci/gamepkgupload`,exports.GET_GAME_PKG_ASYNC_RESULT=`${Domain}/wxa/ci/getgamepkgasyncresult`,exports.GET_GAME_PKG_UPLOAD_INFO=`${Domain}/wxa/ci/getgamepkguploadinfo`,exports.GET_GAME_PKG_UPLOAD_SIGN=`${Domain}/wxa/ci/getgamepkguploadsign`,exports.GET_MULTI_COS_ASYNC_RESULT=`${Domain}/wxa/ci/getmulticosasyncresult`,exports.GET_MULTI_COS_UPLOAD_INFO=`${Domain}/wxa/ci/getmulticosuploadinfo`,exports.GET_MULTI_COS_UPLOAD_SIGN=`${Domain}/wxa/ci/getmulticosuploadsign`,exports.GET_PLUG_PKG_GET_LIST=`${Domain}/wxa/ci/apkpluggetlist`,exports.GET_PLUG_PKG_GET_URL=`${Domain}/wxa/ci/apkpluggeturl`,exports.GET_PLUG_PKG_CHECK_USERVERSION=`${Domain}/wxa/ci/apkplugcheckuserversion`,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`;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.tryTranslateSingleFile=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),parser=tslib_1.__importStar(require("@babel/parser")),traverse_1=tslib_1.__importDefault(require("@babel/traverse")),sourcemap=tslib_1.__importStar(require("source-map")),babel_code_frame_1=tslib_1.__importDefault(require("babel-code-frame"));class TranslateResult{constructor(){this.translated=!0,this.errMsg="",this.debugs=[],this.translatedContent="",this.fullPath="",this.translatedSourceMap=""}}function getErrorCodeFrame(e,n,t,r){let i;try{i=new sourcemap.SourceMapConsumer(n||""),e=i.sourceContentFor(t)||e}catch(e){}const o=[];for(const n of r){let t={line:n.line,column:n.column>0?n.column:0};try{i&&(t=i.originalPositionFor({line:n.line,column:n.column}))}catch(e){}const r=(0,babel_code_frame_1.default)(e,t.line,t.column);o.push(`${n.reason}\n${r}`)}return o.join("\n\n")}function translateCode(e,n){const t=e.replace(/\r\n/g,"\n").split("\n");for(let e=0;e<t.length;e++){const r=t[e],i=n[e+1];if(i){const n=[];let o=0;for(const e in i){const t=i[e];n.push(r.substr(o,t.column-o+1)),n.push(t.toString),o=t.column+t.fromString.length+1}n.push(r.substr(o)),t[e]=n.join("")}}return t.join("\n")}function translateSourceMap(e,n,t){const r=new sourcemap.SourceMapConsumer(e),i=new sourcemap.SourceMapGenerator({file:n});let o;return r.eachMapping((e=>{if("number"!=typeof e.originalLine||"number"!=typeof e.originalColumn)return;const n={generated:{line:e.generatedLine,column:e.generatedColumn},source:e.source,name:e.name,original:{line:e.originalLine,column:e.originalColumn}};if(o&&o.line===e.generatedLine?n.generated.column+=o.offset:o=void 0,t[e.generatedLine]){const n=t[e.generatedLine][e.generatedColumn];n&&(o&&o.line===n.line?o.offset+=n.offset:o={line:n.line,offset:n.offset})}i.addMapping(n)})),i.toString()}function dirname(e){const n=e.split("/");return n.pop(),n.join("/")}function getNpmRequirePath(e,n,t){if(e.startsWith(".")||e.startsWith("/"))return!1;let r,i=n;for(;i;)if(i=dirname(i),r=e.endsWith(".js")?path_1.default.posix.join(i,"miniprogram_npm",e):path_1.default.posix.join(i,"miniprogram_npm",e,"index.js"),t.includes(r))return r;return!1}const tryTranslateSingleFile=e=>{var n,t;const r=new TranslateResult,{filePath:i,nameMapping:o,code:a,rootPath:l,miniProgramJSFiles:s}=e;let u=path_1.default.posix.dirname(path_1.default.posix.relative(l,i));"."===u&&(u="");const c=[];let p;try{p=parser.parse(a)}catch(o){return c.push({line:(null===(n=o.loc)||void 0===n?void 0:n.line)||1,column:(null===(t=o.loc)||void 0===t?void 0:t.column)||1,reason:o.message}),r.translated=!1,r.errMsg=`in ${path_1.default.posix.join(l,i)}\n${getErrorCodeFrame(a,e.sourceMap,e.sourceFileName,c)}`,r}const d={};if((0,traverse_1.default)(p,{AssignmentExpression(e){const n=e.node.loc.start;"Identifier"===e.node.left.type&&"require"===e.node.left.name&&c.push({line:n.line,column:n.column,reason:"assigning other name with 'require'"}),"Identifier"===e.node.right.type&&"require"===e.node.right.name&&c.push({line:n.line,column:n.column,reason:"'require' should not be renamed"})},VariableDeclarator(e){const n=e.node.loc.start;e.node.id&&"Identifier"===e.node.id.type&&"require"===e.node.id.name&&c.push({line:n.line,column:n.column,reason:"(init) assigning other name with 'require'"}),e.node.init&&"Identifier"===e.node.init.type&&"require"===e.node.init.name&&c.push({line:n.line,column:n.column,reason:"(init) 'require' should not be renamed"})},CallExpression(n){const t=n.node.loc.start;for(const e of n.node.arguments)"Identifier"===e.type&&"require"===e.name&&c.push({line:t.line,column:t.column,reason:"passing 'require' as a parameter is not a good taste"});if("Identifier"===n.node.callee.type&&"require"===n.node.callee.name&&(1===n.node.arguments.length&&"StringLiteral"===n.node.arguments[0].type||c.push({line:t.line,column:t.column,reason:"'require' requires one and only one static string literal"})),"require"===n.node.callee.name&&1===n.node.arguments.length&&"StringLiteral"===n.node.arguments[0].type){const t=n.node.arguments[0].loc.start,a=n.node.arguments[0].value,c=e.resolveAlias(a);let p;p=c?path_1.default.posix.join(l,c):path_1.default.posix.normalize(path_1.default.posix.join(u,a)),p.endsWith(".js")||(p+=".js"),p.startsWith("/")&&(p=p.replace(/^\//,""));let m=o[p];if(m)m=o[i]?path_1.default.posix.relative(path_1.default.posix.dirname(o[i]),m):path_1.default.posix.relative(u,m),d[t.line]||(d[t.line]={}),d[t.line][t.column]={line:t.line,column:t.column,fromString:a,toString:m,offset:m.length-a.length},r.debugs.push([i,a,"replace",[p,m]]);else{if(o[i]){const e=getNpmRequirePath(a,i,s);e&&(p=e),m=path_1.default.posix.relative(path_1.default.posix.dirname(o[i]),p),d[t.line]||(d[t.line]={}),d[t.line][t.column]={line:t.line,column:t.column,fromString:a,toString:m,offset:m.length-a.length},r.debugs.push([i,a,"replace",[p,m]])}r.debugs.push([i,a,"ignored"])}}},Identifier(e){const n=e.node.loc.start;if("require"===e.node.name){if("UnaryExpression"===e.parent.type&&"typeof"===e.parent.operator)return;"CallExpression"!==e.parent.type&&c.push({line:n.line,column:n.column,reason:`require is not being used properly in '${e.parent.type}'`})}}}),c.length>0)return r.translated=!1,r.errMsg=`in ${i}\n${getErrorCodeFrame(a,e.sourceMap,e.sourceFileName,c)}`,r;if(Object.keys(d).length>0){r.translatedContent=translateCode(a,d);try{r.translatedSourceMap=translateSourceMap(e.sourceMap||"",e.sourceFileName,d)}catch(e){}}else r.translatedContent=a,r.translatedSourceMap=e.sourceMap;return r};exports.tryTranslateSingleFile=tryTranslateSingleFile;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.tryTranslateSingleFile=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),parser=tslib_1.__importStar(require("@babel/parser")),traverse_1=tslib_1.__importDefault(require("@babel/traverse")),sourcemap=tslib_1.__importStar(require("source-map")),babel_code_frame_1=tslib_1.__importDefault(require("babel-code-frame"));class TranslateResult{constructor(){this.translated=!0,this.errMsg="",this.debugs=[],this.translatedContent="",this.fullPath="",this.translatedSourceMap=""}}function getErrorCodeFrame(e,n,t,r){let i;try{i=new sourcemap.SourceMapConsumer(n||""),e=i.sourceContentFor(t)||e}catch(e){}const o=[];for(const n of r){let t={line:n.line,column:n.column>0?n.column:0};try{i&&(t=i.originalPositionFor({line:n.line,column:n.column}))}catch(e){}const r=(0,babel_code_frame_1.default)(e,t.line,t.column);o.push(`${n.reason}\n${r}`)}return o.join("\n\n")}function translateCode(e,n){const t=e.replace(/\r\n/g,"\n").split("\n");for(let e=0;e<t.length;e++){const r=t[e],i=n[e+1];if(i){const n=[];let o=0;for(const e in i){const t=i[e];n.push(r.substr(o,t.column-o+1)),n.push(t.toString),o=t.column+t.fromString.length+1}n.push(r.substr(o)),t[e]=n.join("")}}return t.join("\n")}function translateSourceMap(e,n,t){const r=new sourcemap.SourceMapConsumer(e),i=new sourcemap.SourceMapGenerator({file:n});let o;return r.eachMapping((e=>{if("number"!=typeof e.originalLine||"number"!=typeof e.originalColumn)return;const n={generated:{line:e.generatedLine,column:e.generatedColumn},source:e.source,name:e.name,original:{line:e.originalLine,column:e.originalColumn}};if(o&&o.line===e.generatedLine?n.generated.column+=o.offset:o=void 0,t[e.generatedLine]){const n=t[e.generatedLine][e.generatedColumn];n&&(o&&o.line===n.line?o.offset+=n.offset:o={line:n.line,offset:n.offset})}i.addMapping(n)})),i.toString()}function dirname(e){const n=e.split("/");return n.pop(),n.join("/")}function getNpmRequirePath(e,n,t){if(e.startsWith(".")||e.startsWith("/"))return!1;let r,i=n;for(;i;)if(i=dirname(i),r=e.endsWith(".js")?path_1.default.posix.join(i,"miniprogram_npm",e):path_1.default.posix.join(i,"miniprogram_npm",e,"index.js"),t.includes(r))return r;return!1}const tryTranslateSingleFile=e=>{var n,t;const r=new TranslateResult,{filePath:i,nameMapping:o,code:a,rootPath:l,miniProgramJSFiles:s}=e;let u=path_1.default.posix.dirname(path_1.default.posix.relative(l,i));"."===u&&(u="");const p=[];let c;try{c=parser.parse(a)}catch(o){return p.push({line:(null===(n=o.loc)||void 0===n?void 0:n.line)||1,column:(null===(t=o.loc)||void 0===t?void 0:t.column)||1,reason:o.message}),r.translated=!1,r.errMsg=`in ${path_1.default.posix.join(l,i)}\n${getErrorCodeFrame(a,e.sourceMap,e.sourceFileName,p)}`,r}const d={};if((0,traverse_1.default)(c,{AssignmentExpression(e){const n=e.node.loc.start;"Identifier"===e.node.left.type&&"require"===e.node.left.name&&p.push({line:n.line,column:n.column,reason:"assigning other name with 'require'"}),"Identifier"===e.node.right.type&&"require"===e.node.right.name&&p.push({line:n.line,column:n.column,reason:"'require' should not be renamed"})},VariableDeclarator(e){const n=e.node.loc.start;e.node.id&&"Identifier"===e.node.id.type&&"require"===e.node.id.name&&p.push({line:n.line,column:n.column,reason:"(init) assigning other name with 'require'"}),e.node.init&&"Identifier"===e.node.init.type&&"require"===e.node.init.name&&p.push({line:n.line,column:n.column,reason:"(init) 'require' should not be renamed"})},CallExpression(n){const t=n.node.loc.start;for(const e of n.node.arguments)"Identifier"===e.type&&"require"===e.name&&p.push({line:t.line,column:t.column,reason:"passing 'require' as a parameter is not a good taste"});if("Identifier"===n.node.callee.type&&"require"===n.node.callee.name&&(1===n.node.arguments.length&&"StringLiteral"===n.node.arguments[0].type||p.push({line:t.line,column:t.column,reason:"'require' requires one and only one static string literal"})),"MemberExpression"===n.node.callee.type&&"Identifier"===n.node.callee.object.type&&"require"===n.node.callee.object.name&&"Identifier"===n.node.callee.property.type&&"async"===n.node.callee.property.name&&(1===n.node.arguments.length&&"StringLiteral"===n.node.arguments[0].type||p.push({line:t.line,column:t.column,reason:"'require.async' requires one and only one static string literal"})),"MemberExpression"===n.node.callee.type&&"Identifier"===n.node.callee.object.type&&"require"===n.node.callee.object.name&&"Identifier"===n.node.callee.property.type&&"async"===n.node.callee.property.name&&1===n.node.arguments.length&&"StringLiteral"===n.node.arguments[0].type){const t=n.node.arguments[0].loc.start,a=n.node.arguments[0].value,p=e.resolveAlias(a);let c;c=p?path_1.default.posix.join(l,p):path_1.default.posix.normalize(path_1.default.posix.join(u,a)),c.endsWith(".js")||(c+=".js"),c.startsWith("/")&&(c=c.replace(/^\//,""));let m=o[c];if(m)m=o[i]?path_1.default.posix.relative(path_1.default.posix.dirname(o[i]),m):path_1.default.posix.relative(u,m),d[t.line]||(d[t.line]={}),d[t.line][t.column]={line:t.line,column:t.column,fromString:a,toString:m,offset:m.length-a.length},r.debugs.push([i,a,"replace",[c,m]]);else{if(o[i]){const e=getNpmRequirePath(a,i,s);e&&(c=e),m=path_1.default.posix.relative(path_1.default.posix.dirname(o[i]),c),d[t.line]||(d[t.line]={}),d[t.line][t.column]={line:t.line,column:t.column,fromString:a,toString:m,offset:m.length-a.length},r.debugs.push([i,a,"replace",[c,m]])}r.debugs.push([i,a,"ignored"])}}if("require"===n.node.callee.name&&1===n.node.arguments.length&&"StringLiteral"===n.node.arguments[0].type){const t=n.node.arguments[0].loc.start,a=n.node.arguments[0].value,p=e.resolveAlias(a);let c;c=p?path_1.default.posix.join(l,p):path_1.default.posix.normalize(path_1.default.posix.join(u,a)),c.endsWith(".js")||(c+=".js"),c.startsWith("/")&&(c=c.replace(/^\//,""));let m=o[c];if(m)m=o[i]?path_1.default.posix.relative(path_1.default.posix.dirname(o[i]),m):path_1.default.posix.relative(u,m),d[t.line]||(d[t.line]={}),d[t.line][t.column]={line:t.line,column:t.column,fromString:a,toString:m,offset:m.length-a.length},r.debugs.push([i,a,"replace",[c,m]]);else{if(o[i]){const e=getNpmRequirePath(a,i,s);e&&(c=e),m=path_1.default.posix.relative(path_1.default.posix.dirname(o[i]),c),d[t.line]||(d[t.line]={}),d[t.line][t.column]={line:t.line,column:t.column,fromString:a,toString:m,offset:m.length-a.length},r.debugs.push([i,a,"replace",[c,m]])}r.debugs.push([i,a,"ignored"])}}},Identifier(e){const n=e.node.loc.start;if("require"===e.node.name){if("UnaryExpression"===e.parent.type&&"typeof"===e.parent.operator)return;if("MemberExpression"===e.parent.type&&"Identifier"===e.parent.property.type&&"async"===e.parent.property.name)return;"CallExpression"!==e.parent.type&&p.push({line:n.line,column:n.column,reason:`require is not being used properly in '${e.parent.type}'`})}}}),p.length>0)return r.translated=!1,r.errMsg=`in ${i}\n${getErrorCodeFrame(a,e.sourceMap,e.sourceFileName,p)}`,r;if(Object.keys(d).length>0){r.translatedContent=translateCode(a,d);try{r.translatedSourceMap=translateSourceMap(e.sourceMap||"",e.sourceFileName,d)}catch(e){}}else r.translatedContent=a,r.translatedSourceMap=e.sourceMap;return r};exports.tryTranslateSingleFile=tryTranslateSingleFile;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getGameNameMapping=exports.getNameMapping=void 0,exports.uglifyFileNames=uglifyFileNames;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),config_1=require("../../../../config/config"),error_1=require("../../../../utils/error"),tools_1=require("../../../../utils/tools"),game_1=tslib_1.__importDefault(require("../json/game")),app_1=require("../json/app"),url_config_1=require("../../../../config/url.config"),request_1=require("../../../../utils/request"),sign_1=require("../../../../utils/sign"),jsonParse_1=require("../../../../utils/jsonParse"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),config=tslib_1.__importStar(require("../../../../config/config")),common_1=require("../../../../utils/common"),fileFlatter_1=require("./fileFlatter");function checkPrefix(e,t){for(const a of t)if(e.startsWith(a))return a;return""}const getNameMapping=async(e,t)=>{if(process.env.isDevtools)return e.nameMappingFromDevtools||{};const a=e.getFileList(t,".js").map((e=>path_1.default.posix.relative(t,e)));try{let r={};if("miniProgram"===e.type){const o=(0,app_1.getAppJSON)(e);r=await getMiniProgramNameMapping(e,t,o,a)}if("miniGame"===e.type){const t=(0,game_1.default)(e);r=await(0,exports.getGameNameMapping)(e,t,a)}return r}catch(e){throw new error_1.CodeError(e.toString(),config_1.CODE_PROTECT_TRANSLATE_FILENAME)}};exports.getNameMapping=getNameMapping;const getMiniProgramNameMapping=async(e,t,a,r)=>{var o;const i=[{type:"file",value:"app.js"},{type:"regex",value:/\/miniprogram_npm\/|^miniprogram_npm\//},{type:"folder",value:"functional-pages/"}],s=e.getFileList(t,".wxml").map((e=>path_1.default.posix.relative(t,e)));for(const e of s)i.push({type:"file",value:`${e.replace(/\.wxml$/,".js")}`});let n=[];return a.subPackages&&(n=a.subPackages.map((e=>e.root))),(null===(o=null==a?void 0:a.widgets)||void 0===o?void 0:o.length)>0&&a.widgets.forEach((e=>{i.push({type:"folder",value:e.path.endsWith("/")?e.path:`${e.path}/`})})),a.workers&&i.push({type:"folder",value:(0,tools_1.getWorkersPath)(a.workers)}),a.openDataContext&&(i.push({type:"file",value:path_1.default.posix.join(a.openDataContext,"index.js")}),n.push(a.openDataContext)),await _getNameMapping(e,r,i,n)},getGameNameMapping=async(e,t,a)=>{const r=[{type:"file",value:"game.js"},{type:"regex",value:/\/miniprogram_npm\/|^miniprogram_npm\//}],o=[];if(t.subPackages&&t.subPackages.forEach((e=>{const t=e.root.replace(/^\//,"");t.endsWith(".js")?(r.push({type:"file",value:t}),o.push(path_1.default.posix.dirname(t))):(r.push({type:"file",value:path_1.default.posix.join(t,"./game.js")}),o.push(t))})),t.openDataContext&&(r.push({type:"file",value:path_1.default.posix.join(t.openDataContext,"index.js")}),o.push(t.openDataContext)),t.workers&&r.push({type:"folder",value:(0,tools_1.getWorkersPath)(t.workers)}),t.plugins)for(const e in t.plugins){const a=t.plugins[e];if(a.path){const e=a.path.replace(/^\//,"");r.push({type:"folder",value:e})}}return await _getNameMapping(e,a,r,o)};async function _getNameMapping(e,t,a,r=[]){const o={},i=[];for(const e of t){let t=!1;for(const r of a)if("file"===r.type&&r.value===e||"folder"===r.type&&e.startsWith(r.value)||"regex"===r.type&&r.value.test(e)){t=!0;break}t||i.push(e)}const s=await(0,sign_1.getSignature)(e.privateKey,e.appid),{body:n}=await(0,request_1.request)({url:url_config_1.TRANSLATE_FILENAME,method:"post",body:JSON.stringify({appid:e.appid,signature:s,arrPaths:i}),headers:{"content-type":"application/json"}}),p=(0,jsonParse_1.jsonRespParse)(n,url_config_1.TRANSLATE_FILENAME);if(0===p.errCode)return p.body.pairs.forEach((e=>{const t=checkPrefix(e.origin,r);o[e.origin]=(0,tools_1.normalizePath)(path_1.default.posix.join(t,`${e.translated}.js`))})),o;throw new Error(`errCode: ${p.errCode} errMsg: ${p.errMsg}`)}function genResolveAlias(e){if(e){const t=[];return Object.keys(e).forEach((a=>{let r=a;a.endsWith("*")&&(r=r.slice(0,-1));let o=e[a];e[a].endsWith("*")&&(o=o.slice(0,-1)),t.push({key:r,value:o})})),e=>{let a={key:"",value:""},r=!1;if(t.forEach((t=>{e.startsWith(t.key)&&a.key.length<t.key.length&&(a=t,r=!0)})),!r)return;let o=e.replace(a.key,a.value);return o.startsWith("/")&&(o=o.slice(1)),o}}return e=>{}}async function uglifyFileNames(e,t,a){let r={miniprogramRoot:""};try{r=JSON.parse(t["project.config.json"].toString())}catch(e){}let o=(0,tools_1.normalizePath)(r.miniprogramRoot);"."===o&&(o=""),a=a||await(0,exports.getNameMapping)(e,e.miniprogramRoot);const i=Object.keys(t).filter((e=>e.endsWith(".js"))),s={};let n,p=t[path_1.default.posix.join(o,"app.json")];p?(Buffer.isBuffer(p)&&(p=p.toString("utf-8")),p=JSON.parse(p),n=genResolveAlias(p.resolveAlias)):n=genResolveAlias(void 0);for(const e of i){if(/\/miniprogram_npm\/|^miniprogram_npm\//.test(e))continue;const r=e,p=t[e].toString(),l=t[`${e}.map`]||"";s[r]=(0,fileFlatter_1.tryTranslateSingleFile)({rootPath:o,code:p,nameMapping:a,check:!0,sourceFileName:e,sourceMap:l,filePath:e,miniProgramJSFiles:i,resolveAlias:n})}const l=Object.keys(t),u={};for(const e of l){u[(0,tools_1.normalizePath)(e)]=t[e]}for(const e in s){const t=(0,tools_1.normalizePath)(e);let r=t;const i=s[e];if(i.errMsg){if(!process.env.isDevtools)throw new Error(`\n${locales_1.default.config.COULD_NOT_USE_CODE_PROTECT}\n${i.errMsg}`);(0,common_1.throwError)({code:config.FILE_FLAT_ERR,msg:`${locales_1.default.config.COULD_NOT_USE_CODE_PROTECT}\n${i.errMsg}`,filePath:t})}const n=path_1.default.posix.relative(o,e);a[n]&&(r=(0,tools_1.normalizePath)(path_1.default.posix.join(o,a[n])),delete u[t],delete u[`${t}.map`]),u[r]=i.translatedContent,i.translatedSourceMap&&(u[`${r}.map`]=i.translatedSourceMap)}return u}exports.getGameNameMapping=getGameNameMapping;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getGameNameMapping=exports.getNameMapping=void 0,exports.uglifyFileNames=uglifyFileNames;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),config_1=require("../../../../config/config"),error_1=require("../../../../utils/error"),tools_1=require("../../../../utils/tools"),game_1=tslib_1.__importDefault(require("../json/game")),app_1=require("../json/app"),url_config_1=require("../../../../config/url.config"),request_1=require("../../../../utils/request"),sign_1=require("../../../../utils/sign"),jsonParse_1=require("../../../../utils/jsonParse"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),config=tslib_1.__importStar(require("../../../../config/config")),common_1=require("../../../../utils/common"),fileFlatter_1=require("./fileFlatter");function checkPrefix(e,t){for(const a of t)if(e.startsWith(a))return a;return""}const getNameMapping=async(e,t)=>{if(process.env.isDevtools)return e.nameMappingFromDevtools||{};const a=e.getFileList(t,".js").map((e=>path_1.default.posix.relative(t,e)));try{let o={};if("miniProgram"===e.type){const r=(0,app_1.getAppJSON)(e);o=await getMiniProgramNameMapping(e,t,r,a)}if("miniGame"===e.type){const t=(0,game_1.default)(e);o=await(0,exports.getGameNameMapping)(e,t,a)}return o}catch(e){throw new error_1.CodeError(e.toString(),config_1.CODE_PROTECT_TRANSLATE_FILENAME)}};exports.getNameMapping=getNameMapping;const getMiniProgramNameMapping=async(e,t,a,o)=>{var r,i,s;const n=[{type:"file",value:"app.js"},{type:"regex",value:/\/miniprogram_npm\/|^miniprogram_npm\//},{type:"folder",value:"functional-pages/"}],p=e.getFileList(t,".wxml").map((e=>path_1.default.posix.relative(t,e)));for(const e of p)n.push({type:"file",value:`${e.replace(/\.wxml$/,".js")}`});let l=[];return a.subPackages&&(l=a.subPackages.map((e=>e.root))),(null===(r=null==a?void 0:a.widgets)||void 0===r?void 0:r.length)>0&&a.widgets.forEach((e=>{n.push({type:"folder",value:e.path.endsWith("/")?e.path:`${e.path}/`})})),a.workers&&n.push({type:"folder",value:(0,tools_1.getWorkersPath)(a.workers)}),a.openDataContext&&(n.push({type:"file",value:path_1.default.posix.join(a.openDataContext,"index.js")}),l.push(a.openDataContext)),Array.isArray(null===(i=a.agent)||void 0===i?void 0:i.skills)&&(null===(s=a.agent)||void 0===s||s.skills.forEach((e=>{"string"==typeof e.path&&(n.push({type:"file",value:path_1.default.posix.join(e.path,"index.js")}),l.push(e.path))}))),await _getNameMapping(e,o,n,l)},getGameNameMapping=async(e,t,a)=>{const o=[{type:"file",value:"game.js"},{type:"regex",value:/\/miniprogram_npm\/|^miniprogram_npm\//}],r=[];if(t.subPackages&&t.subPackages.forEach((e=>{const t=e.root.replace(/^\//,"");t.endsWith(".js")?(o.push({type:"file",value:t}),r.push(path_1.default.posix.dirname(t))):(o.push({type:"file",value:path_1.default.posix.join(t,"./game.js")}),r.push(t))})),t.openDataContext&&(o.push({type:"file",value:path_1.default.posix.join(t.openDataContext,"index.js")}),r.push(t.openDataContext)),t.workers&&o.push({type:"folder",value:(0,tools_1.getWorkersPath)(t.workers)}),t.plugins)for(const e in t.plugins){const a=t.plugins[e];if(a.path){const e=a.path.replace(/^\//,"");o.push({type:"folder",value:e})}}return await _getNameMapping(e,a,o,r)};async function _getNameMapping(e,t,a,o=[]){const r={},i=[];for(const e of t){let t=!1;for(const o of a)if("file"===o.type&&o.value===e||"folder"===o.type&&e.startsWith(o.value)||"regex"===o.type&&o.value.test(e)){t=!0;break}t||i.push(e)}const s=await(0,sign_1.getSignature)(e.privateKey,e.appid),{body:n}=await(0,request_1.request)({url:url_config_1.TRANSLATE_FILENAME,method:"post",body:JSON.stringify({appid:e.appid,signature:s,arrPaths:i}),headers:{"content-type":"application/json"}}),p=(0,jsonParse_1.jsonRespParse)(n,url_config_1.TRANSLATE_FILENAME);if(0===p.errCode)return p.body.pairs.forEach((e=>{const t=checkPrefix(e.origin,o);r[e.origin]=(0,tools_1.normalizePath)(path_1.default.posix.join(t,`${e.translated}.js`))})),r;throw new Error(`errCode: ${p.errCode} errMsg: ${p.errMsg}`)}function genResolveAlias(e){if(e){const t=[];return Object.keys(e).forEach((a=>{let o=a;a.endsWith("*")&&(o=o.slice(0,-1));let r=e[a];e[a].endsWith("*")&&(r=r.slice(0,-1)),t.push({key:o,value:r})})),e=>{let a={key:"",value:""},o=!1;if(t.forEach((t=>{e.startsWith(t.key)&&a.key.length<t.key.length&&(a=t,o=!0)})),!o)return;let r=e.replace(a.key,a.value);return r.startsWith("/")&&(r=r.slice(1)),r}}return e=>{}}async function uglifyFileNames(e,t,a){let o={miniprogramRoot:""};try{o=JSON.parse(t["project.config.json"].toString())}catch(e){}let r=(0,tools_1.normalizePath)(o.miniprogramRoot);"."===r&&(r=""),a=a||await(0,exports.getNameMapping)(e,e.miniprogramRoot);const i=Object.keys(t).filter((e=>e.endsWith(".js"))),s={};let n,p=t[path_1.default.posix.join(r,"app.json")];p?(Buffer.isBuffer(p)&&(p=p.toString("utf-8")),p=JSON.parse(p),n=genResolveAlias(p.resolveAlias)):n=genResolveAlias(void 0);for(const e of i){if(/\/miniprogram_npm\/|^miniprogram_npm\//.test(e))continue;const o=e,p=t[e].toString(),l=t[`${e}.map`]||"";s[o]=(0,fileFlatter_1.tryTranslateSingleFile)({rootPath:r,code:p,nameMapping:a,check:!0,sourceFileName:e,sourceMap:l,filePath:e,miniProgramJSFiles:i,resolveAlias:n})}const l=Object.keys(t),u={};for(const e of l){u[(0,tools_1.normalizePath)(e)]=t[e]}for(const e in s){const t=(0,tools_1.normalizePath)(e);let o=t;const i=s[e];if(i.errMsg){if(!process.env.isDevtools)throw new Error(`\n${locales_1.default.config.COULD_NOT_USE_CODE_PROTECT}\n${i.errMsg}`);(0,common_1.throwError)({code:config.FILE_FLAT_ERR,msg:`${locales_1.default.config.COULD_NOT_USE_CODE_PROTECT}\n${i.errMsg}`,filePath:t})}const n=path_1.default.posix.relative(r,e);a[n]&&(o=(0,tools_1.normalizePath)(path_1.default.posix.join(r,a[n])),delete u[t],delete u[`${t}.map`]),u[o]=i.translatedContent,i.translatedSourceMap&&(u[`${o}.map`]=i.translatedSourceMap)}return u}exports.getGameNameMapping=getGameNameMapping;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=void 0,exports.getSWCRoot=getSWCRoot,exports.default=default_1;const pluginconfig_1=require("../../pluginconfig"),tools_1=require("../../../../../utils/tools"),swc_helper_1=require("../../../../../utils/swc_helper"),swc_task_1=require("../script_task/swc_task"),load_script_task_1=require("../script_task/load_script_task"),babel_script_task_1=require("../script_task/babel_script_task"),minify_script_task_1=require("../script_task/minify_script_task");var config_1=require("../../../../../config/config");function getSWCRoot(e,t){const s=(0,swc_helper_1.getSWCOutputPath)(e.setting);return""===t?s:(0,tools_1.normalizePath)(`${t}/${s}`)}function shouldMinify(e,t){return"dev"!==e&&!!t}function useCompilerPlugin(e,t){if(!e.setting.useCompilerPlugins)return!1;for(const s of e.setting.useCompilerPlugins){if("string"==typeof s&&s===t)return!0;if(Array.isArray(s)&&"string"==typeof s[0]&&void 0!==s[1]&&s[0]===t)return!0}return!1}function default_1(e,t){const s="script",r=e.setting.enhance||e.setting.es6,i=useCompilerPlugin(e,"typescript"),o=(0,pluginconfig_1.couldUseSWCMode)(e.setting);return{name:s,resolveExt:i?{js:"ts"}:{},workerMethods:{async doSwcTask(e,t,s){const r=await(0,swc_task_1.swcCompileTask)(e,t,s);return{code:r.code,map:r.map,helpers:r.helpers,resultType:s.resultType}},async doBabelTask(e,t,s){const r=await(0,babel_script_task_1.bableCompile)(e,t,{typescript:s.typescript,enhance:s.enhance,babelRoot:s.babelRoot,disableUseStrict:s.disableUseStrict});if(shouldMinify(s.resultType,s.minify)){const t=await(0,minify_script_task_1.doCompress)(e,{code:r.code,map:r.map});return{code:t.code,map:t.map,helpers:r.helpers,resultType:s.resultType}}return{code:r.code,map:r.map,helpers:r.helpers,resultType:s.resultType}}},async load(t,r){if(t.endsWith(".js"))return await(0,load_script_task_1.loadScriptFile)(e,t,r,s)},async compile(c,n,a,p){var l;if(!c.endsWith(".js"))return;const{independentRoot:u,isBabelIgnore:_,resultType:d}=p,g=a.source.largeFile;if(_||g)return{targetPath:c,source:a.source,target:{code:a.source.sourceCode,map:a.source.inputMap,helpers:[],resultType:d},process:a.process};const f=Date.now(),y=shouldMinify(d,e.setting.minified);if(o){const i={swcRoot:getSWCRoot(e,u),minify:y,resultType:d,rc:null===(l=e.setting.swcSetting)||void 0===l?void 0:l.rc,disableUseStrict:t.disableUseStrict,target:r?"es5":"es2022"},o=await this.runWorkerMethod("doSwcTask",n,a.source,i);return{targetPath:c,source:a.source,target:o,process:[...a.process,{cost:Date.now()-f,pluginName:s,action:"compile",options:i}]}}const m={babelRoot:(0,babel_script_task_1.getBabelRoot)(u),disableUseStrict:t.disableUseStrict,resultType:d,minify:y,enhance:r,typescript:i},b=await this.runWorkerMethod("doBabelTask",n,a.source,m);return{targetPath:c,source:a.source,target:b,process:[...a.process,{cost:Date.now()-f,pluginName:s,action:"compile",options:m}]}}}}Object.defineProperty(exports,"MAX_CODE_LENGTH",{enumerable:!0,get:function(){return config_1.MAX_CODE_LENGTH}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=void 0,exports.getSWCRoot=getSWCRoot,exports.default=default_1;const pluginconfig_1=require("../../pluginconfig"),tools_1=require("../../../../../utils/tools"),swc_helper_1=require("../../../../../utils/swc_helper"),swc_task_1=require("../script_task/swc_task"),load_script_task_1=require("../script_task/load_script_task"),babel_script_task_1=require("../script_task/babel_script_task"),minify_script_task_1=require("../script_task/minify_script_task");var config_1=require("../../../../../config/config");function getSWCRoot(e,t){const s=(0,swc_helper_1.getSWCOutputPath)(e.setting);return""===t?s:(0,tools_1.normalizePath)(`${t}/${s}`)}function shouldMinify(e,t){return"dev"!==e&&!!t}function useCompilerPlugin(e,t){if(!e.setting.useCompilerPlugins)return!1;for(const s of e.setting.useCompilerPlugins){if("string"==typeof s&&s===t)return!0;if(Array.isArray(s)&&"string"==typeof s[0]&&void 0!==s[1]&&s[0]===t)return!0}return!1}function default_1(e,t){const s="script",r=e.setting.enhance||e.setting.es6,o=e.setting.compileWorklet,i=useCompilerPlugin(e,"typescript"),c=(0,pluginconfig_1.couldUseSWCMode)(e.setting);return{name:s,resolveExt:i?{js:"ts"}:{},workerMethods:{async doSwcTask(e,t,s){const r=await(0,swc_task_1.swcCompileTask)(e,t,s);return{code:r.code,map:r.map,helpers:r.helpers,resultType:s.resultType}},async doBabelTask(e,t,s){const r=await(0,babel_script_task_1.bableCompile)(e,t,{typescript:s.typescript,enhance:s.enhance,babelRoot:s.babelRoot,disableUseStrict:s.disableUseStrict,compileWorklet:s.compileWorklet});if(shouldMinify(s.resultType,s.minify)){const t=await(0,minify_script_task_1.doCompress)(e,{code:r.code,map:r.map});return{code:t.code,map:t.map,helpers:r.helpers,resultType:s.resultType}}return{code:r.code,map:r.map,helpers:r.helpers,resultType:s.resultType}}},async load(t,r){if(t.endsWith(".js"))return await(0,load_script_task_1.loadScriptFile)(e,t,r,s)},async compile(n,a,p,l){var u;if(!n.endsWith(".js"))return;const{independentRoot:_,isBabelIgnore:d,resultType:g}=l,f=p.source.largeFile;if(d||f)return{targetPath:n,source:p.source,target:{code:p.source.sourceCode,map:p.source.inputMap,helpers:[],resultType:g},process:p.process};const m=Date.now(),y=shouldMinify(g,e.setting.minified);if(c){const o={swcRoot:getSWCRoot(e,_),minify:y,resultType:g,rc:null===(u=e.setting.swcSetting)||void 0===u?void 0:u.rc,disableUseStrict:t.disableUseStrict,target:r?"es5":"es2022"},i=await this.runWorkerMethod("doSwcTask",a,p.source,o);return{targetPath:n,source:p.source,target:i,process:[...p.process,{cost:Date.now()-m,pluginName:s,action:"compile",options:o}]}}const b={babelRoot:(0,babel_script_task_1.getBabelRoot)(_),disableUseStrict:t.disableUseStrict,resultType:g,minify:y,enhance:r,typescript:i,compileWorklet:o},h=await this.runWorkerMethod("doBabelTask",a,p.source,b);return{targetPath:n,source:p.source,target:h,process:[...p.process,{cost:Date.now()-m,pluginName:s,action:"compile",options:b}]}}}}Object.defineProperty(exports,"MAX_CODE_LENGTH",{enumerable:!0,get:function(){return config_1.MAX_CODE_LENGTH}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getBabelRoot=getBabelRoot,exports.babelTransformJS=babelTransformJS,exports.transformES6ModuleAndGenCode=transformES6ModuleAndGenCode,exports.babelTransformTS=babelTransformTS,exports.bableCompile=bableCompile;const config_1=require("../../../../../config/config"),babel_helper_1=require("../../../../../utils/babel_helper"),tools_1=require("../../../../../utils/tools"),customError_1=require("../../../../../utils/customError"),_transformRuntimeCustom=()=>require("../../../../../utils/babel_transform_plugin"),_pluginTransformRuntime=()=>require("@babel/plugin-transform-runtime"),_pluginTransformWorklet=()=>require("../../../../../utils/babel_plugin_worklet"),_pluginTransformModulesCommonjs=()=>require("@babel/plugin-transform-modules-commonjs"),babel7=()=>require("@babel/core"),_presetEnv=()=>require("@babel/preset-env"),_pluginTransformTypescript=()=>require("@babel/plugin-transform-typescript"),pluginReplaceTsExportAssignment=e=>{const r=e.template("\n module.exports = ASSIGNMENT;\n ");return{name:"replace-ts-export-assignment",visitor:{TSExportAssignment(e){e.replaceWith(r({ASSIGNMENT:e.node.expression}))}}}},pluginReplaceTsImportEqualsDeclaration=e=>{const r=e.template("\n const ID = require(SOURCE);\n ");return{name:"replace-ts-import-equals-declaration",visitor:{TSImportEqualsDeclaration(e){e.replaceWith(r({ID:e.node.id,SOURCE:e.node.moduleReference.expression}))}}}};function getEnhancePluginsList(e){const r=[[_transformRuntimeCustom()],[_pluginTransformRuntime(),{corejs:!1,helpers:!0,regenerator:!0,version:"7.21.0"}]].concat((0,babel_helper_1.getCustomPlugins)([]));return e.supportWorklet&&r.push([_pluginTransformWorklet()]),r}function getCommonPresets(){return[[_presetEnv(),{targets:{chrome:53,ios:8},modules:!1,include:["@babel/plugin-transform-computed-properties"]}]]}function getTSTransformPluginsList(){return[[pluginReplaceTsImportEqualsDeclaration,{}],[pluginReplaceTsExportAssignment,{}],[_pluginTransformTypescript(),{}]]}function getES6ModulePluginsList(e){return[[_pluginTransformModulesCommonjs(),{allowTopLevelThis:e,importInterop:e=>e.startsWith("@babel/runtime/helpers/")?"node":"babel"}]]}function getBabelRoot(e){const r="@babel/runtime";return""===e?r:(0,tools_1.normalizePath)(`${e}/${r}`)}async function babelTransformJS(e,r){const o=babel7(),s=e.sourceCode.includes('"worklet"')||e.sourceCode.includes("'worklet'");let t;try{const n={babelrc:!1,sourceFileName:r,configFile:!1,presets:getCommonPresets(),plugins:getEnhancePluginsList({supportWorklet:s}),inputSourceMap:!1,code:!1,ast:!0,cloneInputAst:!1};if(e.astInfo){if(e.astInfo.type!==config_1.AstType.Babel)throw new Error("ast type is not babel");t=await o.transformFromAstAsync(e.astInfo.ast,e.sourceCode,n)}else{if(null===e.sourceCode)throw new Error("source.sourceCode is null");t=await babel7().transformAsync(e.sourceCode,n)}}catch(e){console.error(e,e.stack);const o=`file: ${r}\n ${e.message}`,s=new Error(o);throw s.code=config_1.BABEL_TRANS_JS_ERR,s}return{sourceCode:e.sourceCode,inputMap:e.inputMap,astInfo:{ast:t.ast,type:config_1.AstType.Babel}}}async function transformES6ModuleAndGenCode(e,r,o){const s=o.disableUseStrict||/^\s*\/\/\s?use strict disable;/i.test(r.sourceCode||"");let t;try{const o={babelrc:!1,sourceFileName:e,configFile:!1,plugins:getES6ModulePluginsList(s),filename:e,sourceMaps:!0,inputSourceMap:r.inputMap,code:!0,cloneInputAst:!0},n=babel7();if(!r.astInfo)throw new Error("source.astInfo is not exist");if(r.astInfo.type!==config_1.AstType.Babel)throw new Error("ast type is not babel");t=await n.transformFromAstAsync(r.astInfo.ast,r.sourceCode,o)}catch(r){throw r.code=config_1.BABEL_TRANS_JS_ERR,r.message=`file: ${e}\n ${r.message}`,r.path=e,r}if(!t)throw new Error("no trans result for callPostEnhance");let n=t.code;const l=t.map;s&&(n=n.replace(/^"use strict";/,""));const a=(0,babel_helper_1.collectBabelHelpers)(r.sourceCode),i=(0,babel_helper_1.replaceBabelHelpers)(n,a,e,o.babelRoot);return{code:i.transformCode,map:l,helpers:i.helpers}}async function babelTransformTS(e,r){let o;console.log("[backend] summer-typescript workerMethod");try{o=await babel7().transformAsync(e.sourceCode,{babelrc:!1,plugins:getTSTransformPluginsList(),sourceFileName:r,sourceMaps:!1,ast:!0,configFile:!1,code:!1})}catch(e){throw(0,customError_1.makeCustomError)(e,customError_1.CustomErrors.SUMMER_PLUGIN_CODE_ERR,r)}return{sourceCode:e.sourceCode,inputMap:e.inputMap,astInfo:{ast:o.ast,type:config_1.AstType.Babel}}}async function bableCompile(e,r,o){const s=babel7(),t=r.sourceCode.includes('"worklet"')||r.sourceCode.includes("'worklet'"),n=o.disableUseStrict||/^\s*\/\/\s?use strict disable;/i.test(r.sourceCode||""),l=[];e.endsWith(".ts")&&o.typescript&&l.push(...getTSTransformPluginsList()),t&&l.push([_pluginTransformWorklet()]),o.enhance&&l.push(...getEnhancePluginsList({})),l.push(...getES6ModulePluginsList(n));const a={babelrc:!1,sourceFileName:e,filename:e,configFile:!1,presets:o.enhance?getCommonPresets():[],plugins:l,inputSourceMap:r.inputMap,sourceMaps:!0,code:!0,ast:!1,cloneInputAst:!1};let i;try{i=await s.transformAsync(r.sourceCode,a)}catch(r){console.error(r,r.stack);const o=`file: ${e}\n ${r.message}`,s=new Error(o);throw s.code=config_1.BABEL_TRANS_JS_ERR,s}if(!i||!i.code)throw new Error("no trans result for bableCompile");let c=i.code;const u=i.map;n&&(c=c.replace(/^"use strict";/,""));const p=(0,babel_helper_1.collectBabelHelpers)(r.sourceCode),m=(0,babel_helper_1.replaceBabelHelpers)(c,p,e,o.babelRoot);return{code:m.transformCode,map:u,helpers:m.helpers}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getBabelRoot=getBabelRoot,exports.babelTransformJS=babelTransformJS,exports.transformES6ModuleAndGenCode=transformES6ModuleAndGenCode,exports.babelTransformTS=babelTransformTS,exports.bableCompile=bableCompile;const config_1=require("../../../../../config/config"),babel_helper_1=require("../../../../../utils/babel_helper"),tools_1=require("../../../../../utils/tools"),customError_1=require("../../../../../utils/customError"),_transformRuntimeCustom=()=>require("../../../../../utils/babel_transform_plugin"),_pluginTransformRuntime=()=>require("@babel/plugin-transform-runtime"),_pluginTransformWorklet=()=>require("../../../../../utils/babel_plugin_worklet"),_pluginTransformModulesCommonjs=()=>require("@babel/plugin-transform-modules-commonjs"),babel7=()=>require("@babel/core"),_presetEnv=()=>require("@babel/preset-env"),_pluginTransformTypescript=()=>require("@babel/plugin-transform-typescript"),pluginReplaceTsExportAssignment=e=>{const r=e.template("\n module.exports = ASSIGNMENT;\n ");return{name:"replace-ts-export-assignment",visitor:{TSExportAssignment(e){e.replaceWith(r({ASSIGNMENT:e.node.expression}))}}}},pluginReplaceTsImportEqualsDeclaration=e=>{const r=e.template("\n const ID = require(SOURCE);\n ");return{name:"replace-ts-import-equals-declaration",visitor:{TSImportEqualsDeclaration(e){e.replaceWith(r({ID:e.node.id,SOURCE:e.node.moduleReference.expression}))}}}};function getEnhancePluginsList(e){const r=[[_transformRuntimeCustom()],[_pluginTransformRuntime(),{corejs:!1,helpers:!0,regenerator:!0,version:"7.21.0"}]].concat((0,babel_helper_1.getCustomPlugins)([]));return e.supportWorklet&&r.push([_pluginTransformWorklet()]),r}function getCommonPresets(){return[[_presetEnv(),{targets:{chrome:53,ios:8},modules:!1,include:["@babel/plugin-transform-computed-properties"]}]]}function getTSTransformPluginsList(){return[[pluginReplaceTsImportEqualsDeclaration,{}],[pluginReplaceTsExportAssignment,{}],[_pluginTransformTypescript(),{}]]}function getES6ModulePluginsList(e){return[[_pluginTransformModulesCommonjs(),{allowTopLevelThis:e,importInterop:e=>e.startsWith("@babel/runtime/helpers/")?"node":"babel"}]]}function getBabelRoot(e){const r="@babel/runtime";return""===e?r:(0,tools_1.normalizePath)(`${e}/${r}`)}async function babelTransformJS(e,r){const o=babel7(),s=e.sourceCode.includes('"worklet"')||e.sourceCode.includes("'worklet'");let t;try{const n={babelrc:!1,sourceFileName:r,configFile:!1,presets:getCommonPresets(),plugins:getEnhancePluginsList({supportWorklet:s}),inputSourceMap:!1,code:!1,ast:!0,cloneInputAst:!1};if(e.astInfo){if(e.astInfo.type!==config_1.AstType.Babel)throw new Error("ast type is not babel");t=await o.transformFromAstAsync(e.astInfo.ast,e.sourceCode,n)}else{if(null===e.sourceCode)throw new Error("source.sourceCode is null");t=await babel7().transformAsync(e.sourceCode,n)}}catch(e){console.error(e,e.stack);const o=`file: ${r}\n ${e.message}`,s=new Error(o);throw s.code=config_1.BABEL_TRANS_JS_ERR,s}return{sourceCode:e.sourceCode,inputMap:e.inputMap,astInfo:{ast:t.ast,type:config_1.AstType.Babel}}}async function transformES6ModuleAndGenCode(e,r,o){const s=o.disableUseStrict||/^\s*\/\/\s?use strict disable;/i.test(r.sourceCode||"");let t;try{const o={babelrc:!1,sourceFileName:e,configFile:!1,plugins:getES6ModulePluginsList(s),filename:e,sourceMaps:!0,inputSourceMap:r.inputMap,code:!0,cloneInputAst:!0},n=babel7();if(!r.astInfo)throw new Error("source.astInfo is not exist");if(r.astInfo.type!==config_1.AstType.Babel)throw new Error("ast type is not babel");t=await n.transformFromAstAsync(r.astInfo.ast,r.sourceCode,o)}catch(r){throw r.code=config_1.BABEL_TRANS_JS_ERR,r.message=`file: ${e}\n ${r.message}`,r.path=e,r}if(!t)throw new Error("no trans result for callPostEnhance");let n=t.code;const l=t.map;s&&(n=n.replace(/^"use strict";/,""));const a=(0,babel_helper_1.collectBabelHelpers)(r.sourceCode),i=(0,babel_helper_1.replaceBabelHelpers)(n,a,e,o.babelRoot);return{code:i.transformCode,map:l,helpers:i.helpers}}async function babelTransformTS(e,r){let o;console.log("[backend] summer-typescript workerMethod");try{o=await babel7().transformAsync(e.sourceCode,{babelrc:!1,plugins:getTSTransformPluginsList(),sourceFileName:r,sourceMaps:!1,ast:!0,configFile:!1,code:!1})}catch(e){throw(0,customError_1.makeCustomError)(e,customError_1.CustomErrors.SUMMER_PLUGIN_CODE_ERR,r)}return{sourceCode:e.sourceCode,inputMap:e.inputMap,astInfo:{ast:o.ast,type:config_1.AstType.Babel}}}async function bableCompile(e,r,o){const s=babel7(),t=o.compileWorklet&&(r.sourceCode.includes('"worklet"')||r.sourceCode.includes("'worklet'")),n=o.disableUseStrict||/^\s*\/\/\s?use strict disable;/i.test(r.sourceCode||""),l=e.endsWith(".ts")&&o.typescript,a=[];l&&a.push(...getTSTransformPluginsList()),t&&a.push([_pluginTransformWorklet()]),o.enhance&&a.push(...getEnhancePluginsList({})),a.push(...getES6ModulePluginsList(n));const i={babelrc:!1,sourceFileName:e,filename:e,configFile:!1,presets:o.enhance?getCommonPresets():[],plugins:a,inputSourceMap:r.inputMap,sourceMaps:!0,code:!0,ast:!1,cloneInputAst:!1};let c;if(!(l||o.enhance||t))return{code:r.sourceCode,map:r.inputMap,helpers:[]};try{c=await s.transformAsync(r.sourceCode,i)}catch(r){console.error(r,r.stack);const o=`file: ${e}\n ${r.message}`,s=new Error(o);throw s.code=config_1.BABEL_TRANS_JS_ERR,s}if(!c||!c.code)throw new Error("no trans result for bableCompile");let u=c.code;const p=c.map;n&&(u=u.replace(/^"use strict";/,""));const m=(0,babel_helper_1.collectBabelHelpers)(r.sourceCode),b=(0,babel_helper_1.replaceBabelHelpers)(u,m,e,o.babelRoot);return{code:b.transformCode,map:p,helpers:b.helpers}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miniprogram-ci",
3
- "version": "2.1.35",
3
+ "version": "2.1.37",
4
4
  "description": "Module that build miniprogram project for web or app extracted from WeChatDevtools.",
5
5
  "homepage": "https://developers.weixin.qq.com/community/homepage",
6
6
  "main": "dist/index.js",