miniprogram-ci 1.9.13 → 1.9.15

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,9 @@
1
+ #### 1.9.15
2
+ - `fix` 修复 app.json 的 app-bar 配置未生效的 bug。
3
+
4
+ #### 1.9.14
5
+ - `new` 更新 `es6` 或者 `es7` 编译时,忽略编译的文件大小阈值由 500kb 改为 2MB,即大小超过 2MB 的 js 文件不会被编译。
6
+
1
7
  #### 1.9.11
2
8
  - `new` 新增 `checkCodeQuality` 代码质量检查能力。
3
9
 
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
+ #### 1.9.15
11
+ - `fix` 修复 app.json 的 app-bar 配置未生效的 bug。
12
+ #### 1.9.14
13
+ - `new` 更新 `es6` 或者 `es7` 编译时,忽略编译的文件大小阈值由 500kb 改为 2MB,即大小超过 2MB 的 js 文件不会被编译。
10
14
  #### 1.9.11
11
15
  - `new` 新增 `checkCodeQuality` 代码质量检查能力。
12
16
  #### 1.9.10
@@ -1,4 +1,4 @@
1
- export declare const CI_VERSION = "1.9.13";
1
+ export declare const CI_VERSION = "1.9.15";
2
2
  export declare const PARAM_ERROR = 10000;
3
3
  export declare const WXML_NOT_FOUND = 10007;
4
4
  export declare const JS_NOT_FOUND = 10008;
@@ -61,6 +61,7 @@ export declare namespace AppJSON {
61
61
  [key: string]: string;
62
62
  };
63
63
  tabBar?: ITabBar;
64
+ appBar?: {};
64
65
  requiredBackgroundModes?: Array<string>;
65
66
  navigateToMiniProgramAppIdList?: Array<string>;
66
67
  mimeTypeDeclarations?: {
@@ -101,6 +102,13 @@ export declare namespace AppJSON {
101
102
  [key: string]: string;
102
103
  };
103
104
  requiredPrivateInfos?: Array<requiredPrivateInfosValues>;
105
+ accountCardPackage?: {
106
+ root: string;
107
+ cardList: Array<{
108
+ type: number;
109
+ componentPath: string;
110
+ }>;
111
+ };
104
112
  }
105
113
  interface IPluginConfig {
106
114
  provider: string;
@@ -154,6 +154,7 @@ declare class GraphContext {
154
154
  };
155
155
  miniprogram: {
156
156
  useExtendedPackages: string[];
157
+ accountCardPackage?: IAppJSON['accountCardPackage'];
157
158
  };
158
159
  constructor(options: GraphOptions);
159
160
  private initMiniprogram;
@@ -202,9 +203,19 @@ declare interface IAppJSON {
202
203
  tabBar?: {
203
204
  custom?: boolean;
204
205
  };
206
+ appBar?: {
207
+ custom?: boolean;
208
+ };
205
209
  resolveAlias?: {
206
210
  [key: string]: string;
207
211
  };
212
+ accountCardPackage?: {
213
+ root: string;
214
+ cardList: Array<{
215
+ type: number;
216
+ componentPath: string;
217
+ }>;
218
+ };
208
219
  }
209
220
 
210
221
  export declare type ICompilerPlugin = 'typescript' | 'less' | 'sass';
package/dist/config.js CHANGED
@@ -1,3 +1,3 @@
1
1
  !function(require, directRequire){
2
- "use strict";var COMPILE_TYPE;Object.defineProperty(exports,"__esModule",{value:!0}),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="1.9.13",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(_){_.miniProgram="miniProgram",_.miniProgramPlugin="miniProgramPlugin",_.miniGame="miniGame",_.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"]}};
2
+ "use strict";var COMPILE_TYPE;Object.defineProperty(exports,"__esModule",{value:!0}),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="1.9.15",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(_){_.miniProgram="miniProgram",_.miniProgramPlugin="miniProgramPlugin",_.miniGame="miniGame",_.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"]}};
3
3
  }(require("licia/lazyImport")(require), require)
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "1.9.13",
3
- "buildTime": 1705999849886
2
+ "version": "1.9.15",
3
+ "buildTime": 1706514561761
4
4
  }
@@ -1,3 +1,3 @@
1
1
  !function(require, directRequire){
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppConf=exports.resolvePath=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),core_1=require("../../core"),common_1=require("../../core/json/common"),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales"));function resolvePath(t,o){const e=path_1.default.posix.dirname(t);let s=null;return s=o.startsWith("/")?o.replace(/^\//,""):path_1.default.posix.join(e,o),s}function isPluginPath(t){return t.startsWith("plugin://")||t.startsWith("plugin-private://")}exports.resolvePath=resolvePath;class AppConf{constructor(t,o){this.graph=o,this.packages=new Map,this.pages=new Map,this.comps=new Map,this.onFileChange=(t,o)=>{},this.proxyProject=t.proxyProject,this.proxyProject.addResolver(o.resolver)}destroy(){this.proxyProject.removeResolver(this.graph.resolver)}async build(t){this.resetState(),await this.loadApp(t)}async resetState(){this.app=void 0,this.packages.clear(),this.pages.clear(),this.comps.clear(),this.sitemap=void 0,this.theme=void 0}async loadApp(t){const o=await t.run(locales_1.default.config.SUMMER_COMPILE.format("app.json"),()=>(0,core_1.getAppJSON)(this.proxyProject));this.app=o;const e=new Set;for(const t of o.pages)e.add(t);const s=o.subPackages||[];for(const t of s){const o=t.root;this.packages.set(o,t);for(const s of t.pages)e.add(path_1.default.posix.join(o,s))}await t.run(locales_1.default.config.SUMMER_COMPILE_PAGE_JSON.format(e.size),async()=>{var t;for(const[t]of e.entries())isPluginPath(t)||await this.loadPage(t);for(const t of Object.values(o.usingComponents||{}))if(!isPluginPath(t)){const o=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=resolvePath("app.json","custom-tab-bar/index");await this.loadComp(t,"custom-tab-bar/index","app.json")}}),o.themeLocation&&await t.run(locales_1.default.config.SUMMER_COMPILE.format(o.themeLocation),()=>this.loadTheme(o.themeLocation))}async loadPage(t){const o=await(0,core_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.graph.root,pagePath:t});this.pages.set(t,o);const e=async o=>{if(isPluginPath(o))return;const e=resolvePath(t,o);await this.loadComp(e,o,t)};if(o.usingComponents)for(const t of Object.values(o.usingComponents))await e(t);if(o.componentGenerics)for(const t of Object.values(o.componentGenerics)){const o=t.default;o&&await e(o)}}async loadComp(t,o,e){if(await this.isExtendedLibComp(t,e))return;if(this.comps.has(t))return;if(!this.proxyProject.stat(this.graph.root,t+".json"))throw new Error(`[summer-compiler] Couldn't found the '${o}.json' file relative to '${e}.json'`);const s=await(0,core_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.graph.root,pagePath:t});this.comps.set(t,s);const a=async o=>{if(isPluginPath(o))return;const e=resolvePath(t,o);await this.loadComp(e,o,t)};if(s.usingComponents)for(const t of Object.values(s.usingComponents))await a(t);if(s.componentGenerics)for(const t of Object.values(s.componentGenerics)){const o=t.default;o&&await a(o)}}async loadTheme(t){const o=await(0,core_1.checkThemeJSON)(this.proxyProject,{themeLocation:t});this.theme=o}async isExtendedLibComp(t,o){if(t.startsWith("miniprogram_npm/")){const e=(0,common_1.getUseExtendLib)(this.proxyProject,o);if(e.length>0){const o=e.map(t=>"miniprogram_npm/"+t);for(const e of o)if(t.startsWith(e))return!0}}return!1}}exports.AppConf=AppConf;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppConf=exports.resolvePath=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),core_1=require("../../core"),common_1=require("../../core/json/common"),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales"));function resolvePath(t,o){const e=path_1.default.posix.dirname(t);let a=null;return a=o.startsWith("/")?o.replace(/^\//,""):path_1.default.posix.join(e,o),a}function isPluginPath(t){return t.startsWith("plugin://")||t.startsWith("plugin-private://")}exports.resolvePath=resolvePath;class AppConf{constructor(t,o){this.graph=o,this.packages=new Map,this.pages=new Map,this.comps=new Map,this.onFileChange=(t,o)=>{},this.proxyProject=t.proxyProject,this.proxyProject.addResolver(o.resolver)}destroy(){this.proxyProject.removeResolver(this.graph.resolver)}async build(t){this.resetState(),await this.loadApp(t)}async resetState(){this.app=void 0,this.packages.clear(),this.pages.clear(),this.comps.clear(),this.sitemap=void 0,this.theme=void 0}async loadApp(t){const o=await t.run(locales_1.default.config.SUMMER_COMPILE.format("app.json"),()=>(0,core_1.getAppJSON)(this.proxyProject));this.app=o;const e=new Set;for(const t of o.pages)e.add(t);const a=o.subPackages||[];for(const t of a){const o=t.root;this.packages.set(o,t);for(const a of t.pages)e.add(path_1.default.posix.join(o,a))}await t.run(locales_1.default.config.SUMMER_COMPILE_PAGE_JSON.format(e.size),async()=>{var t;for(const[t]of e.entries())isPluginPath(t)||await this.loadPage(t);for(const t of Object.values(o.usingComponents||{}))if(!isPluginPath(t)){const o=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=resolvePath("app.json","custom-tab-bar/index");await this.loadComp(t,"custom-tab-bar/index","app.json")}if(o.appBar){const t=resolvePath("app.json","app-bar/index");this.proxyProject.stat(this.graph.root,t+".json")&&await this.loadComp(t,"app-bar/index","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 e=path_1.default.posix.join(o.accountCardPackage.root,t.componentPath);await this.loadComp(e,e,"app.json")}})}async loadPage(t){const o=await(0,core_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.graph.root,pagePath:t});this.pages.set(t,o);const e=async o=>{if(isPluginPath(o))return;const e=resolvePath(t,o);await this.loadComp(e,o,t)};if(o.usingComponents)for(const t of Object.values(o.usingComponents))await e(t);if(o.componentGenerics)for(const t of Object.values(o.componentGenerics)){const o=t.default;o&&await e(o)}}async loadComp(t,o,e){if(await this.isExtendedLibComp(t,e))return;if(this.comps.has(t))return;if(!this.proxyProject.stat(this.graph.root,t+".json"))throw new Error(`[summer-compiler] Couldn't found the '${o}.json' file relative to '${e}.json'`);const a=await(0,core_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.graph.root,pagePath:t});this.comps.set(t,a);const s=async o=>{if(isPluginPath(o))return;const e=resolvePath(t,o);await this.loadComp(e,o,t)};if(a.usingComponents)for(const t of Object.values(a.usingComponents))await s(t);if(a.componentGenerics)for(const t of Object.values(a.componentGenerics)){const o=t.default;o&&await s(o)}}async loadTheme(t){const o=await(0,core_1.checkThemeJSON)(this.proxyProject,{themeLocation:t});this.theme=o}async isExtendedLibComp(t,o){if(t.startsWith("miniprogram_npm/")){const e=(0,common_1.getUseExtendLib)(this.proxyProject,o);if(e.length>0){const o=e.map(t=>"miniprogram_npm/"+t);for(const e of o)if(t.startsWith(e))return!0}}return!1}}exports.AppConf=AppConf;
3
3
  }(require("licia/lazyImport")(require), require)
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=void 0;const tslib_1=require("tslib"),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),path_1=tslib_1.__importDefault(require("path")),jsonParse_1=require("../../../utils/jsonParse"),sourcemap=()=>require("source-map");async function tryGetInputSourceMap(e,t){try{const s=/\/\/[#|@] sourceMappingURL=[\s]*(\S*)[\s]*$/m.exec(e),r=path_1.default.posix.dirname(t),a=path_1.default.posix.basename(t);let o;if(null==s?void 0:s[1])if(/\.js\.map$/.test(s[1]))o=await fs_extra_1.default.readFile(path_1.default.posix.join(r,s[1]),"utf-8");else{const e=s[1].split("base64,")[1];o=Buffer.from(e,"base64").toString()}else{const e=path_1.default.posix.join(r,a+".map");fs_extra_1.default.existsSync(e)&&(o=await fs_extra_1.default.readFile(e,"utf-8"))}if(o){const e=(0,jsonParse_1.jsonParse)(o);new(require("source-map").SourceMapConsumer)(e);return await insertSourcesContent(e,t),e}}catch(e){console.log(`try to get input sourcemap of ${t} catch error ${e}`)}}exports.MAX_CODE_LENGTH=512e3;const insertSourcesContent=async(e,t)=>{if(Array.isArray(e.sources)&&!Array.isArray(e.sourcesContent)){const s=e.sourcesContent;try{const s=path_1.default.posix.dirname(t),r=[],a=e.sources;for(const e of a){const t=await fs_extra_1.default.readFile(path_1.default.posix.join(s,e),"utf-8");r.push(t)}e.sourcesContent=r}catch(t){e.sourcesContent=s}}};function default_1(){return{name:"summer-javascript",async load(e,t){if(t.endsWith(".js")){const e=await fs_extra_1.default.readFile(t,{encoding:"utf-8"}),s=await tryGetInputSourceMap(e,t);return{sourceCode:e,inputMap:null!=s?s:void 0,astInfo:void 0,largeFile:e.length>=exports.MAX_CODE_LENGTH}}}}}exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=void 0;const tslib_1=require("tslib"),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),path_1=tslib_1.__importDefault(require("path")),jsonParse_1=require("../../../utils/jsonParse"),sourcemap=()=>require("source-map");async function tryGetInputSourceMap(e,t){try{const s=/\/\/[#|@] sourceMappingURL=[\s]*(\S*)[\s]*$/m.exec(e),r=path_1.default.posix.dirname(t),a=path_1.default.posix.basename(t);let o;if(null==s?void 0:s[1])if(/\.js\.map$/.test(s[1]))o=await fs_extra_1.default.readFile(path_1.default.posix.join(r,s[1]),"utf-8");else{const e=s[1].split("base64,")[1];o=Buffer.from(e,"base64").toString()}else{const e=path_1.default.posix.join(r,a+".map");fs_extra_1.default.existsSync(e)&&(o=await fs_extra_1.default.readFile(e,"utf-8"))}if(o){const e=(0,jsonParse_1.jsonParse)(o);new(require("source-map").SourceMapConsumer)(e);return await insertSourcesContent(e,t),e}}catch(e){console.log(`try to get input sourcemap of ${t} catch error ${e}`)}}exports.MAX_CODE_LENGTH=2048e3;const insertSourcesContent=async(e,t)=>{if(Array.isArray(e.sources)&&!Array.isArray(e.sourcesContent)){const s=e.sourcesContent;try{const s=path_1.default.posix.dirname(t),r=[],a=e.sources;for(const e of a){const t=await fs_extra_1.default.readFile(path_1.default.posix.join(s,e),"utf-8");r.push(t)}e.sourcesContent=r}catch(t){e.sourcesContent=s}}};function default_1(){return{name:"summer-javascript",async load(e,t){if(t.endsWith(".js")){const e=await fs_extra_1.default.readFile(t,{encoding:"utf-8"}),s=await tryGetInputSourceMap(e,t);return{sourceCode:e,inputMap:null!=s?s:void 0,astInfo:void 0,largeFile:e.length>=exports.MAX_CODE_LENGTH}}}}}exports.default=default_1;