Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

builder-debug-utils

Package Overview
Dependencies
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

builder-debug-utils - npm Package Compare versions

Comparing version 2.2.1 to 3.0.0

lib/config-provider.d.ts

163

CHANGELOG.md

@@ -0,17 +1,161 @@

## 3.0.0
- boatman cube 支持
## 2.5.11
- boatman 0.9.0
## 2.5.10
- tinybugme 0.0.71
## 2.5.9
- tinybugme 0.0.70
## 2.5.8
- tinybugme 0.0.69
## 2.5.7
- boatman 0.8.0
## 2.5.6
- tinybugme 0.0.68
## 2.5.5
- tinybugme 0.0.67
## 2.5.4
- tinybugme 0.0.66
## 2.5.3
- tinybugme 0.0.65
- boatman 0.7.10
## 2.5.2
- boatman 0.7.9
## 2.5.1
- boatman 0.7.8
## 2.5.0
- SDK 化重构
- 支持外部设置 offline 目录位置
## 2.4.14
- tinybugme 0.0.64 bugmeWRemote
## 2.4.13
- tinybugme 0.0.64 bugmeRRemote
## 2.4.12
- tinybugme 0.0.63
## 2.4.11
- tinybugme 0.0.62
- boatman 0.7.7
## 2.4.10
- tinybugme 0.0.59
## 2.4.9
- boatman 0.7.5
## 2.4.8
- tinybugme 0.0.58
## 2.4.7
- boatman 0.7.4
## 2.4.6
- tinybugme 0.0.55
## 2.4.5
- boatman 0.7.2
## 2.4.4
- boatman 0.7.1
## 2.4.3
- boatman 0.7.0
## 2.4.2
- boatman 0.6.0
## 2.4.1
- boatman 0.5.1
## 2.4.0
- boatman 0.5.0
- tinybugme 0.0.53
- boatman_mini 中包含 tinybugme worker-remote
## 2.3.4
- boatman 0.4.2
## 2.3.3
- tinybugme 0.0.52
- boatman 0.4.0
## 2.3.2
- boatman 0.3.8
## 2.3.1
- tinybugme 0.0.51
## 2.3.0
- 增加 RemtoexLite 模式支持 IDE 无插桩调试
## 2.2.1
- tinybugme 0.0.48
## 2.2.0
- Boatman
## 2.1.2
- LegecyRemote htmlTop 注入 bugmeRRemote
## 2.1.0
- tinybugme 0.0.38
## 2.0.0-alpha.13
- tinybugme 0.0.31
## 2.0.0-alpha.12
- tinybugme 0.0.23

@@ -21,11 +165,15 @@ - tyro 48a39846f1a310babc60d07344786f1ee65bf63c

## 2.0.0-alpha.11
- tinybugme 0.0.20
## 2.0.0-alpha.10
- Render 不使用 bugme/assets 加载脚本,直接打包源码
## 2.0.0-alpha.9
- fix onSocketOpen
## 2.0.0-alpha.8
- 使用 uniweb

@@ -35,11 +183,15 @@ - tinybugme 0.0.13

## 2.0.0-alpha.7
- bugmeRPreview 2.0 不注入
## 2.0.0-alpha.5
- 区分 BugmeRender Preview/Remote 两种脚本
## 2.0.0-alpha.4
- 兼容 SimulatorWithTyro mode
## 2.0.0
- 同时支持 Appx1.0/2.0 的版本

@@ -50,2 +202,3 @@ - bugmeWRemote/bugmeWPreview 分开注入

## 1.0.3
- 更新 assets: fix console in iOS9 5edcab66bcbf9ea761cac8dcb2f5294db403262b

@@ -55,2 +208,3 @@ - 更新 tyro-assets: fix console in iOS9 cee63b712436033aba0d1df331b0330c2c6adedf

## 1.0.2
- 更新 assets: 2de4c2ae7d3e5a3fecb7426808b4e72daea89d64

@@ -61,17 +215,23 @@ - 兼容 JSI

## 1.0.1
- 更新 assets: 兼容钉钉不存在 callSync 方法 1da33830f8b4a15c9a25a6a36d9cbaa79e064463
## 1.0.0
- 支持同/异步调用,重新设计对外接口
## 0.4.3
- 使用更轻量的 bent 替换 liburl
## 0.4.2
- 增加 generateInjectCode 方法,直接返回 Assets JSON;
## 0.4.1
- 更新 assets: 断线重连及清理连接 4621c1598645e76fe71c864104a18171df6db4c6
## 0.4.0
- 去除时间纬度的缓存,通过比较本地资源决定是否更新

@@ -82,8 +242,11 @@ - 增加 readonly 兜底文件损坏

## 0.3.7
- 增加 compilePlugin 入参,只对插件产物注入 TyroAgent
## 0.3.6
- 废弃
## 0.3.5
- 更新 assets: 支持插件插桩调试

2

dist/index.js

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("fs-extra"),t=require("os"),o=require("path"),a=require("bent"),n=require("crypto");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(e),s=r(t),l=r(o),d=r(a),u=r(n),c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function f(e,t){return e(t={exports:{}},t.exports),t.exports}var m=f((function(e,t){var o,a;Object.defineProperty(t,"__esModule",{value:!0}),t.ECompileModeType=t.ECompileTargetType=void 0,(o=t.ECompileTargetType||(t.ECompileTargetType={})).Mini="Mini",o.Cube="Cube",(a=t.ECompileModeType||(t.ECompileModeType={})).Remote="Remote",a.Remotex="Remotex",a.Preview="Preview",a.SimulatorWithTyro="SimulatorWithTyro",a.RemoteBoatman="RemoteBoatman"}));p(m),m.ECompileModeType,m.ECompileTargetType;var g=f((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default={assetsQueryJSON:"https://render.alipay.com/p/s/h5data/prod/h5config/builder-debug-h5data.json",injectCodePath:l.default.join(s.default.tmpdir(),"./builder_debug_output_v2"),assetsMapPath:l.default.join(__dirname,"../offline/assets_map"),assetsMapReadOnlyPath:l.default.join(__dirname,"../readonly/assets_map"),logTag:"builder-debug-utils",boatmanPath:{[m.ECompileTargetType.Mini]:l.default.join(__dirname,"../offline/boatman_mini"),[m.ECompileTargetType.Cube]:l.default.join(__dirname,"../offline/boatman_mini")},boatmanReadOnlyPath:{[m.ECompileTargetType.Mini]:l.default.join(__dirname,"../readonly/boatman_mini"),[m.ECompileTargetType.Cube]:l.default.join(__dirname,"../readonly/boatman_mini")}}}));p(g);var y=f((function(e,t){var o=c&&c.__awaiter||function(e,t,o,a){return new(o||(o=Promise))((function(n,r){function i(e){try{l(a.next(e))}catch(e){r(e)}}function s(e){try{l(a.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(i,s)}l((a=a.apply(e,t||[])).next())}))},a=c&&c.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getGlobaleAssetsManager=t.getAssetsMap=t.getAssetsMapSync=void 0;const n=a(d.default),r=a(i.default),s=a(u.default),l=a(g),p=n.default("json"),f=n.default("buffer");class m{updateOfflineAssetsToday(){return o(this,void 0,void 0,(function*(){!function(e){return o(this,void 0,void 0,(function*(){try{const t=yield r.default.stat(e),o=new Date(parseInt(""+t.mtimeMs,10));return(new Date).toLocaleDateString()===o.toLocaleDateString()}catch(e){return!1}}))}(l.default.assetsMapPath)?(console.log(`[${l.default.logTag}] local assets are outdated, start to download new debug assets`),yield this.updateOfflineAssets()):console.log(`[${l.default.logTag}] local assets are in the period of validity`)}))}updateOfflineAssets(){return o(this,void 0,void 0,(function*(){if(this.updatingTask)return this.updatingTask;this.updatingTask=this.runUpdateTask();try{yield this.updatingTask,this.updatingTask=null}catch(e){throw this.updatingTask=null,e}}))}runUpdateTask(){return o(this,void 0,void 0,(function*(){yield Promise.all([this.updateLocalFile(l.default.assetsMapPath,"url_v2","integrity_v2"),this.updateLocalFile(l.default.boatmanPath.Mini,"url_boatman_mini","integrity_boatman_mini")])}))}updateLocalFile(e,t,a){return o(this,void 0,void 0,(function*(){const o=`[${l.default.logTag}] ${t}`;let n,i;try{n=yield p(l.default.assetsQueryJSON)}catch(e){throw new Error(`${o} network error ${e.message}`)}if(!n[t]||!n[a])throw new Error(o+" online config error");try{const t=yield r.default.readFile(e);if(s.default.createHash("sha256").update(t).digest("base64")===n[a])return void console.log(o+" local is up to date, stop updating")}catch(e){}console.log(o+" local is outdated, start to download");try{i=yield f(n[t])}catch(e){throw new Error(`${o} download error ${e.message}`)}if(s.default.createHash("sha256").update(i).digest("base64")!==n[a])throw new Error(`${o} ${a} is not verified`);yield r.default.writeFile(e,i),console.log(o+" update successfully")}))}}let y;t.getAssetsMapSync=function(){let e=r.default.readJSONSync(l.default.assetsMapPath,{throws:!1});return e||(console.log(`[${l.default.logTag}] offline assets_map file was damaged, fallback to readonly file`),e=r.default.readJSONSync(l.default.assetsMapReadOnlyPath)),e},t.getAssetsMap=function(){return o(this,void 0,void 0,(function*(){let e;try{e=yield r.default.readJSON(l.default.assetsMapPath,{throws:!1})}catch(e){}return e||(console.log(`[${l.default.logTag}] offline assets_map file was damaged, fallback to readonly file`),e=yield r.default.readJSON(l.default.assetsMapReadOnlyPath)),e}))},t.getGlobaleAssetsManager=function(){return y||(y=new m),y}}));p(y),y.getGlobaleAssetsManager,y.getAssetsMap,y.getAssetsMapSync;var h=f((function(e,t){var o=c&&c.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.composeAssetsByCompileMode=void 0;const a=o(g);function n(...e){return e.join("\n")}function r(e,t){return{workerTop:e.bugmeWPreview,htmlTop:"<script>window.__BUGME_ENV__='preview';<\/script>"+e.bugmeRPreview}}function i(e,t){return{htmlTop:e.bugmeRRemote}}function s(e,t){return t.compilePlugin?{workerTop:e.bugmeWRemote,pluginWorkerTop:e.tyroAgent,htmlTop:e.bugmeRRemote}:{workerTop:n(e.tyroAgent,e.bugmeWRemote),htmlTop:e.bugmeRRemote}}function l(e,t){const o="https://gw.alipayobjects.com/os/antfincdn/6PIsYVRjrS/bugmeR.js";return t.compilePlugin?{workerTop:e.bugmeWRemote,pluginWorkerTop:e.tyroAgent,htmlTop:`<script>window.__BUGME_ENV__='simulator';<\/script><script src="${o}"><\/script>`}:{workerTop:n(e.tyroAgent,e.bugmeWRemote),htmlTop:`<script>window.__BUGME_ENV__='simulator';<\/script><script src="${o}"><\/script>`}}function d(e,t){return{workerTop:e.bugmeWRemote,htmlTop:e.bugmeRRemote}}t.composeAssetsByCompileMode=function(e,t){let o;switch(t.mode){case m.ECompileModeType.Preview:o=r;break;case m.ECompileModeType.Remote:o=i;break;case m.ECompileModeType.Remotex:o=s;break;case m.ECompileModeType.RemoteBoatman:o=d;break;case m.ECompileModeType.SimulatorWithTyro:o=l;break;default:throw new Error(`[${a.default.logTag}] unknown compile mode: ${t.mode}`)}return o(e,t)}}));p(h),h.composeAssetsByCompileMode;var T=f((function(e,t){var o=c&&c.__awaiter||function(e,t,o,a){return new(o||(o=Promise))((function(n,r){function i(e){try{l(a.next(e))}catch(e){r(e)}}function s(e){try{l(a.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(i,s)}l((a=a.apply(e,t||[])).next())}))},a=c&&c.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getBoatmanBundlePathSync=t.getBoatmanBundlePath=t.updateInjectCodeAssets=t.generateInjectCodePathSync=t.generateInjectCodePath=t.generateInjectCodeSync=t.generateInjectCode=void 0;const n=a(i.default),r=a(g);var s=m;function l(e){const t=Object.assign({},e);if(!t.mode||-1===Object.keys(m.ECompileModeType).indexOf(t.mode))throw new Error(`[${r.default.logTag}] invalid 'mode' option: ${t.mode}`);return t.target&&-1!==Object.keys(m.ECompileTargetType).indexOf(t.target)||(t.target=m.ECompileTargetType.Mini),e}function d(e){return o(this,void 0,void 0,(function*(){e=l(e);const t=yield y.getAssetsMap();return h.composeAssetsByCompileMode(t,e)}))}function u(e){e=l(e);const t=y.getAssetsMapSync();return h.composeAssetsByCompileMode(t,e)}function p(e){const t=Object.assign({},e);return t.target&&-1!==Object.keys(m.ECompileTargetType).indexOf(t.target)||(t.target=m.ECompileTargetType.Mini),t}Object.defineProperty(t,"ECompileModeType",{enumerable:!0,get:function(){return s.ECompileModeType}}),Object.defineProperty(t,"ECompileTargetType",{enumerable:!0,get:function(){return s.ECompileTargetType}}),t.generateInjectCode=d,t.generateInjectCodeSync=u,t.generateInjectCodePath=function(e){return o(this,void 0,void 0,(function*(){const t=yield d(e);return yield n.default.writeJSON(r.default.injectCodePath,t),r.default.injectCodePath}))},t.generateInjectCodePathSync=function(e){const t=u(e);return n.default.writeJSONSync(r.default.injectCodePath,t),r.default.injectCodePath},t.updateInjectCodeAssets=function(e={}){return o(this,void 0,void 0,(function*(){e.cacheToday?yield y.getGlobaleAssetsManager().updateOfflineAssetsToday():yield y.getGlobaleAssetsManager().updateOfflineAssets()}))},t.getBoatmanBundlePath=function(e={}){return o(this,void 0,void 0,(function*(){const t=p(e);try{return yield n.default.access(r.default.boatmanPath[t.target],n.default.constants.R_OK),r.default.boatmanPath[t.target]}catch(e){return r.default.boatmanReadOnlyPath[t.target]}}))},t.getBoatmanBundlePathSync=function(e={}){const t=p(e);try{return n.default.accessSync(r.default.boatmanPath[t.target],n.default.constants.R_OK),r.default.boatmanPath[t.target]}catch(e){return r.default.boatmanReadOnlyPath[t.target]}}})),b=p(T),_=T.getBoatmanBundlePathSync,C=T.getBoatmanBundlePath,w=T.updateInjectCodeAssets,v=T.generateInjectCodePathSync,M=T.generateInjectCodePath,P=T.generateInjectCodeSync,j=T.generateInjectCode,E=T.ECompileModeType,O=T.ECompileTargetType;exports.ECompileModeType=E,exports.ECompileTargetType=O,exports.default=b,exports.generateInjectCode=j,exports.generateInjectCodePath=M,exports.generateInjectCodePathSync=v,exports.generateInjectCodeSync=P,exports.getBoatmanBundlePath=C,exports.getBoatmanBundlePathSync=_,exports.updateInjectCodeAssets=w;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("fs-extra")),n=e(require("bent")),o=e(require("crypto")),a=e(require("os")),i=e(require("path")),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function l(e,t){return e(t={exports:{}},t.exports),t.exports}var d=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Mini="Mini",e.Cube="Cube"}(t.ECompileTargetType||(t.ECompileTargetType={})),function(e){e.Remote="Remote",e.Remotex="Remotex",e.RemotexLite="RemotexLite",e.Preview="Preview",e.RemoteBoatman="RemoteBoatman"}(t.ECompileModeType||(t.ECompileModeType={}))}));s(d);d.ECompileTargetType,d.ECompileModeType;var u=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.defaultConfig={assetsQueryUrl:"https://render.alipay.com/p/s/h5data/prod/h5config/builder-debug-h5data.json",injectCodeTempPath:i.join(a.tmpdir(),"./builder_debug_output_v2"),offlineDirectoryPath:i.join(__dirname,"../offline"),readonlyDirectoryPath:i.join(__dirname,"../readonly"),assetsMapFilename:"assets_map",boatmanFilename:{[d.ECompileTargetType.Mini]:"boatman_mini",[d.ECompileTargetType.Cube]:"boatman_cube"}},t.libName="builder-debug-utils"}));s(u);u.defaultConfig,u.libName;var c=l((function(e,a){var i=r&&r.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(a,i){function r(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,s)}l((o=o.apply(e,t||[])).next())}))},s=r&&r.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(a,"__esModule",{value:!0});const l=s(n),c=s(t),p=s(o),f=l.default("json"),h=l.default("buffer"),g=`[${u.libName}]`;a.AssetsUpdater=class{constructor(e){this.context=e}updateOfflineAssetsToday(){return i(this,void 0,void 0,(function*(){!function(e){return i(this,void 0,void 0,(function*(){try{const t=yield c.default.stat(e),n=new Date(parseInt(""+t.mtimeMs,10));return(new Date).toLocaleDateString()===n.toLocaleDateString()}catch(e){return!1}}))}(this.context.getAssetsMapFilePath())?(console.log(g+" local assets are outdated, start to download new debug assets"),yield this.updateOfflineAssets()):console.log(g+" local assets are in the period of validity")}))}updateOfflineAssets(){return i(this,void 0,void 0,(function*(){if(this.updatingTask)return this.updatingTask;this.updatingTask=this.runUpdateTask();try{yield this.updatingTask,this.updatingTask=null}catch(e){throw this.updatingTask=null,e}}))}runUpdateTask(){return i(this,void 0,void 0,(function*(){let e;try{e=yield f(u.defaultConfig.assetsQueryUrl)}catch(e){throw new Error("Failed to request online config")}yield Promise.all([this.updateLocalFile(this.context.getAssetsMapFilePath(),e.url_v2,e.integrity_v2),this.updateLocalFile(this.context.getBoatmanFilePath(d.ECompileTargetType.Mini),e.url_boatman_mini,e.integrity_boatman_mini),this.updateLocalFile(this.context.getBoatmanFilePath(d.ECompileTargetType.Cube),e.url_boatman_cube,e.integrity_boatman_cube)])}))}updateLocalFile(e,t,n){return i(this,void 0,void 0,(function*(){if(!t||!n)return void console.error(g+" Empty key in config");try{const t=yield c.default.readFile(e);if(p.default.createHash("sha256").update(t).digest("base64")===n)return void console.log(g+" Local is latested")}catch(e){}let o;console.log(g+" Start to update local");try{o=yield h(t)}catch(e){return void console.error(`${g} Download error ${e.message}`)}if(p.default.createHash("sha256").update(o).digest("base64")!==n)throw new Error("Failed to verify");yield c.default.writeFile(e,o),console.log(g+" Updated")}))}}}));s(c);c.AssetsUpdater;var p=l((function(e,t){function n(...e){return e.join("\n")}function o(e,t){return t.target===d.ECompileTargetType.Cube?void 0:{workerTop:e.bugmeWPreview,htmlTop:"<script>window.__BUGME_ENV__='preview';<\/script>"+e.bugmeRPreview}}function a(e,t){return{htmlTop:e.bugmeRRemote}}function i(e,t){return t.compilePlugin?{workerTop:e.bugmeWRemote,pluginWorkerTop:e.tyroAgent,htmlTop:e.bugmeRRemote}:{workerTop:n(e.tyroAgent,e.bugmeWRemote),htmlTop:e.bugmeRRemote}}function r(e,t){return{workerTop:n("var __BUGME_CONSOLE_ENABLE__=true;",e.bugmeWRemote),htmlTop:e.bugmeRRemote}}function s(e,t){if(t.target===d.ECompileTargetType.Cube)return{};{const n={htmlTop:e.bugmeRRemote};return t.compilePlugin&&(n.workerTop=e.bugmeWRemote),n}}Object.defineProperty(t,"__esModule",{value:!0}),t.composeAssetsByCompileMode=function(e,t){let n;switch(t.mode){case d.ECompileModeType.Preview:n=o;break;case d.ECompileModeType.Remote:n=a;break;case d.ECompileModeType.Remotex:n=i;break;case d.ECompileModeType.RemotexLite:n=r;break;case d.ECompileModeType.RemoteBoatman:n=s;break;default:throw new Error(`[${u.libName}] unknown compile mode: ${t.mode}`)}return n(e,t)}}));s(p);p.composeAssetsByCompileMode;var f=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});t.BuilderDebugContext=class{constructor(e){this.assetsQueryUrl="",this.injectCodeTempPath="",this.offlineDirectoryPath="",this.readonlyDirectoryPath="",this.assetsMapFilename="",this.assetsQueryUrl=e.assetsQueryUrl,this.injectCodeTempPath=e.injectCodeTempPath,this.offlineDirectoryPath=e.offlineDirectoryPath,this.readonlyDirectoryPath=e.readonlyDirectoryPath,this.assetsMapFilename=e.assetsMapFilename,this.boatmanFilename=e.boatmanFilename}getAssetsMapFilePath(){return i.join(this.offlineDirectoryPath,this.assetsMapFilename)}getBoatmanFilePath(e){return i.join(this.offlineDirectoryPath,this.boatmanFilename[e])}getReadonlyAssetsMapFilePath(){return i.join(this.readonlyDirectoryPath,this.assetsMapFilename)}getReadonlyBoatmanFilePath(e){return i.join(this.readonlyDirectoryPath,this.boatmanFilename[e])}}}));s(f);f.BuilderDebugContext;var h=l((function(e,n){var o=r&&r.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(a,i){function r(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,s)}l((o=o.apply(e,t||[])).next())}))},a=r&&r.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0});const i=a(t);function s(e){const t=Object.assign({},e);return t.target&&-1!==Object.keys(d.ECompileTargetType).indexOf(t.target)||(t.target=d.ECompileTargetType.Mini),t}function l(e){const t=Object.assign({},e);if(!t.mode||-1===Object.keys(d.ECompileModeType).indexOf(t.mode))throw new Error(`[${u.libName}] invalid 'mode' option: ${t.mode}`);return t.target&&-1!==Object.keys(d.ECompileTargetType).indexOf(t.target)||(t.target=d.ECompileTargetType.Mini),e}function h(e){let t=i.default.readJSONSync(e.getAssetsMapFilePath(),{throws:!1});return t||(console.log(`[${u.libName}] offline assets_map file was damaged, fallback to readonly file`),t=i.default.readJSONSync(e.getReadonlyAssetsMapFilePath())),t}function g(e){return o(this,void 0,void 0,(function*(){let t;try{t=yield i.default.readJSON(e.getAssetsMapFilePath(),{throws:!1})}catch(e){}return t||(console.log(`[${u.libName}] offline assets_map file was damaged, fallback to readonly file`),t=yield i.default.readJSON(e.getReadonlyAssetsMapFilePath())),t}))}n.BuilderDebugClient=class{constructor(e){this.context=new f.BuilderDebugContext(Object.assign(Object.assign({},u.defaultConfig),e))}updateOfflineAssets(e){return o(this,void 0,void 0,(function*(){this.assetsUpdater||(this.assetsUpdater=new c.AssetsUpdater(this.context)),e.cacheToday?yield this.assetsUpdater.updateOfflineAssetsToday():yield this.assetsUpdater.updateOfflineAssets()}))}generateInjectCode(e){return o(this,void 0,void 0,(function*(){e=l(e);const t=yield g(this.context);return p.composeAssetsByCompileMode(t,e)}))}generateInjectCodeSync(e){e=l(e);const t=h(this.context);return p.composeAssetsByCompileMode(t,e)}generateInjectCodePath(e){return o(this,void 0,void 0,(function*(){const t=yield this.generateInjectCode(e);return yield i.default.writeJSON(u.defaultConfig.injectCodeTempPath,t),u.defaultConfig.injectCodeTempPath}))}generateInjectCodePathSync(e){const t=this.generateInjectCodeSync(e);return i.default.writeJSONSync(u.defaultConfig.injectCodeTempPath,t),u.defaultConfig.injectCodeTempPath}getBoatmanBundlePath(e){return o(this,void 0,void 0,(function*(){const t=s(e);try{const e=this.context.getBoatmanFilePath(t.target);return yield i.default.access(e,i.default.constants.R_OK),e}catch(e){return this.context.getReadonlyBoatmanFilePath(t.target)}}))}getBoatmanBundlePathSync(e){const t=s(e);try{const e=this.context.getBoatmanFilePath(t.target);return i.default.accessSync(e,i.default.constants.R_OK),e}catch(e){return this.context.getReadonlyBoatmanFilePath(t.target)}}},n.readAssetsMapSync=h,n.readAssetsMap=g}));s(h);h.BuilderDebugClient,h.readAssetsMapSync,h.readAssetsMap;var g=l((function(e,t){var n=r&&r.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(a,i){function r(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,s)}l((o=o.apply(e,t||[])).next())}))};let o;function a(){return o||(o=new h.BuilderDebugClient),o}Object.defineProperty(t,"__esModule",{value:!0}),t.updateInjectCodeAssets=function(e={}){return n(this,void 0,void 0,(function*(){return a().updateOfflineAssets(e)}))},t.generateInjectCode=function(e){return n(this,void 0,void 0,(function*(){return a().generateInjectCode(e)}))},t.generateInjectCodeSync=function(e){return a().generateInjectCodeSync(e)},t.generateInjectCodePath=function(e){return n(this,void 0,void 0,(function*(){return a().generateInjectCodePath(e)}))},t.generateInjectCodePathSync=function(e){return a().generateInjectCodePathSync(e)},t.getBoatmanBundlePath=function(e={}){return n(this,void 0,void 0,(function*(){return a().getBoatmanBundlePath(e)}))},t.getBoatmanBundlePathSync=function(e={}){return a().getBoatmanBundlePathSync(e)},t.loadConfig=function(e){o=new h.BuilderDebugClient(e)}}));s(g);g.updateInjectCodeAssets,g.generateInjectCode,g.generateInjectCodeSync,g.generateInjectCodePath,g.generateInjectCodePathSync,g.getBoatmanBundlePath,g.getBoatmanBundlePathSync,g.loadConfig;var m=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ECompileModeType=d.ECompileModeType,t.ECompileTargetType=d.ECompileTargetType,t.BuilderDebugClient=h.BuilderDebugClient,t.updateInjectCodeAssets=g.updateInjectCodeAssets,t.generateInjectCode=g.generateInjectCode,t.generateInjectCodeSync=g.generateInjectCodeSync,t.generateInjectCodePath=g.generateInjectCodePath,t.generateInjectCodePathSync=g.generateInjectCodePathSync,t.getBoatmanBundlePath=g.getBoatmanBundlePath,t.getBoatmanBundlePathSync=g.getBoatmanBundlePathSync,t.loadConfig=g.loadConfig})),y=s(m),C=m.ECompileModeType,b=m.ECompileTargetType,P=m.BuilderDebugClient,T=m.updateInjectCodeAssets,j=m.generateInjectCode,v=m.generateInjectCodeSync,_=m.generateInjectCodePath,B=m.generateInjectCodePathSync,w=m.getBoatmanBundlePath,M=m.getBoatmanBundlePathSync,x=m.loadConfig;exports.BuilderDebugClient=P,exports.ECompileModeType=C,exports.ECompileTargetType=b,exports.default=y,exports.generateInjectCode=j,exports.generateInjectCodePath=_,exports.generateInjectCodePathSync=B,exports.generateInjectCodeSync=v,exports.getBoatmanBundlePath=w,exports.getBoatmanBundlePathSync=M,exports.loadConfig=x,exports.updateInjectCodeAssets=T;

@@ -15,3 +15,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getGlobaleAssetsManager = exports.getAssetsMap = exports.getAssetsMapSync = void 0;
const bent_1 = __importDefault(require("bent"));

@@ -18,0 +17,0 @@ const fs_extra_1 = __importDefault(require("fs-extra"));

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.composeAssetsByCompileMode = void 0;
const interface_1 = require("./interface");
const config_1 = __importDefault(require("./config"));
const config_1 = require("./config");
function concatSource(...argv) {

@@ -24,10 +20,10 @@ return argv.join('\n');

break;
case interface_1.ECompileModeType.RemotexLite:
composeMethod = composeAssets4RemotexLite;
break;
case interface_1.ECompileModeType.RemoteBoatman:
composeMethod = composeAssets4RemoteBoatman;
break;
case interface_1.ECompileModeType.SimulatorWithTyro:
composeMethod = SimulatorWithTyro;
break;
default:
throw new Error(`[${config_1.default.logTag}] unknown compile mode: ${options.mode}`);
throw new Error(`[${config_1.libName}] unknown compile mode: ${options.mode}`);
}

@@ -38,6 +34,11 @@ return composeMethod(assetsMap, options);

function composeAssets4Preview(assetsMap, options) {
return {
workerTop: assetsMap.bugmeWPreview,
htmlTop: `<script>window.__BUGME_ENV__='preview';</script>${assetsMap.bugmeRPreview}`,
};
if (options.target === interface_1.ECompileTargetType.Cube) {
return;
}
else {
return {
workerTop: assetsMap.bugmeWPreview,
htmlTop: `<script>window.__BUGME_ENV__='preview';</script>${assetsMap.bugmeRPreview}`,
};
}
}

@@ -61,25 +62,23 @@ function composeAssets4Remote(assetsMap, options) {

}
/**
* WebIDE 模拟器接入,Worker 类似 Remotex 注入插桩+bugme, Renderer 则自己建立 WebSocket
* @param options
*/
function SimulatorWithTyro(assetsMap, options) {
// tiny-bugme 版本 bugmeRender
const legacyBugmeR = 'https://gw.alipayobjects.com/os/antfincdn/6PIsYVRjrS/bugmeR.js';
return options.compilePlugin
? {
workerTop: assetsMap.bugmeWRemote,
pluginWorkerTop: assetsMap.tyroAgent,
htmlTop: `<script>window.__BUGME_ENV__='simulator';</script><script src="${legacyBugmeR}"></script>`,
}
: {
workerTop: concatSource(assetsMap.tyroAgent, assetsMap.bugmeWRemote),
htmlTop: `<script>window.__BUGME_ENV__='simulator';</script><script src="${legacyBugmeR}"></script>`,
};
}
function composeAssets4RemoteBoatman(assetsMap, options) {
function composeAssets4RemotexLite(assetsMap, options) {
return {
workerTop: assetsMap.bugmeWRemote,
workerTop: concatSource('var __BUGME_CONSOLE_ENABLE__=true;', assetsMap.bugmeWRemote),
htmlTop: assetsMap.bugmeRRemote,
};
}
function composeAssets4RemoteBoatman(assetsMap, options) {
if (options.target === interface_1.ECompileTargetType.Cube) {
return {};
}
else {
// Boatman 模式下 tinybugme 会跟随 boatman_mini 一起注入到 worker 中
const points = {
htmlTop: assetsMap.bugmeRRemote,
};
// 插件模式下 boatman_mini 注入到插件上下文中,tinybugme 不会生效,因此需要额外注入到宿主 worker 中
if (options.compilePlugin) {
points.workerTop = assetsMap.bugmeWRemote;
}
return points;
}
}

@@ -1,17 +0,3 @@

import { ECompileTargetType } from './interface';
declare const _default: {
assetsQueryJSON: string;
injectCodePath: string;
assetsMapPath: string;
assetsMapReadOnlyPath: string;
logTag: string;
boatmanPath: {
Mini: string;
Cube: string;
};
boatmanReadOnlyPath: {
Mini: string;
Cube: string;
};
};
export default _default;
import { IBuilderDebugConfig } from './interface';
export declare const defaultConfig: IBuilderDebugConfig;
export declare const libName = "builder-debug-utils";

@@ -6,17 +6,14 @@ "use strict";

const interface_1 = require("./interface");
exports.default = {
assetsQueryJSON: 'https://render.alipay.com/p/s/h5data/prod/h5config/builder-debug-h5data.json',
injectCodePath: path_1.join(os_1.tmpdir(), './builder_debug_output_v2'),
assetsMapPath: path_1.join(__dirname, '../offline/assets_map'),
assetsMapReadOnlyPath: path_1.join(__dirname, '../readonly/assets_map'),
logTag: 'builder-debug-utils',
boatmanPath: {
[interface_1.ECompileTargetType.Mini]: path_1.join(__dirname, '../offline/boatman_mini'),
exports.defaultConfig = {
assetsQueryUrl: 'https://render.alipay.com/p/s/h5data/prod/h5config/builder-debug-h5data.json',
injectCodeTempPath: path_1.join(os_1.tmpdir(), './builder_debug_output_v2'),
offlineDirectoryPath: path_1.join(__dirname, '../offline'),
readonlyDirectoryPath: path_1.join(__dirname, '../readonly'),
assetsMapFilename: 'assets_map',
boatmanFilename: {
[interface_1.ECompileTargetType.Mini]: 'boatman_mini',
// Cube 未支持,先占位
[interface_1.ECompileTargetType.Cube]: path_1.join(__dirname, '../offline/boatman_mini'),
[interface_1.ECompileTargetType.Cube]: 'boatman_cube',
},
boatmanReadOnlyPath: {
[interface_1.ECompileTargetType.Mini]: path_1.join(__dirname, '../readonly/boatman_mini'),
[interface_1.ECompileTargetType.Cube]: path_1.join(__dirname, '../readonly/boatman_mini'),
},
};
exports.libName = 'builder-debug-utils';

@@ -1,18 +0,3 @@

import { IGenerateInjectCodeOptions, IInjectionPoints, IGetBoatmanBundleOptions, IUpdateAssetsOptions } from './interface';
export { ECompileModeType, ECompileTargetType } from './interface';
/**
* 根据构建入参生成 injectCode 对象,并返回
*/
export declare function generateInjectCode(options: IGenerateInjectCodeOptions): Promise<IInjectionPoints>;
export declare function generateInjectCodeSync(options: IGenerateInjectCodeOptions): IInjectionPoints;
/**
* 根据构建入参生成 injectCode 文件,返回路径
*/
export declare function generateInjectCodePath(options: IGenerateInjectCodeOptions): Promise<string>;
export declare function generateInjectCodePathSync(options: IGenerateInjectCodeOptions): string;
/**
* 检查资源文件更新
*/
export declare function updateInjectCodeAssets(options?: IUpdateAssetsOptions): Promise<void>;
export declare function getBoatmanBundlePath(options?: IGetBoatmanBundleOptions): Promise<string>;
export declare function getBoatmanBundlePathSync(options?: IGetBoatmanBundleOptions): string;
export { ECompileModeType, ECompileTargetType, IBuilderDebugClient, IBuilderDebugClientOptions } from './interface';
export { BuilderDebugClient } from './sdk';
export { updateInjectCodeAssets, generateInjectCode, generateInjectCodeSync, generateInjectCodePath, generateInjectCodePathSync, getBoatmanBundlePath, getBoatmanBundlePathSync, loadConfig, } from './utils';
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBoatmanBundlePathSync = exports.getBoatmanBundlePath = exports.updateInjectCodeAssets = exports.generateInjectCodePathSync = exports.generateInjectCodePath = exports.generateInjectCodeSync = exports.generateInjectCode = void 0;
const fs_extra_1 = __importDefault(require("fs-extra"));
const interface_1 = require("./interface");
const config_1 = __importDefault(require("./config"));
const assets_1 = require("./assets");
const compose_1 = require("./compose");
// export * 导出 commonjs 会多一层 default
var interface_2 = require("./interface");
Object.defineProperty(exports, "ECompileModeType", { enumerable: true, get: function () { return interface_2.ECompileModeType; } });
Object.defineProperty(exports, "ECompileTargetType", { enumerable: true, get: function () { return interface_2.ECompileTargetType; } });
function getInjectCodeOptions(options) {
const opt = Object.assign({}, options);
if (!opt.mode || Object.keys(interface_1.ECompileModeType).indexOf(opt.mode) === -1) {
throw new Error(`[${config_1.default.logTag}] invalid 'mode' option: ${opt.mode}`);
}
if (!opt.target || Object.keys(interface_1.ECompileTargetType).indexOf(opt.target) === -1) {
opt.target = interface_1.ECompileTargetType.Mini;
}
return options;
}
/**
* 根据构建入参生成 injectCode 对象,并返回
*/
function generateInjectCode(options) {
return __awaiter(this, void 0, void 0, function* () {
options = getInjectCodeOptions(options);
const assetsMap = yield assets_1.getAssetsMap();
return compose_1.composeAssetsByCompileMode(assetsMap, options);
});
}
exports.generateInjectCode = generateInjectCode;
function generateInjectCodeSync(options) {
options = getInjectCodeOptions(options);
const assetsMap = assets_1.getAssetsMapSync();
return compose_1.composeAssetsByCompileMode(assetsMap, options);
}
exports.generateInjectCodeSync = generateInjectCodeSync;
/**
* 根据构建入参生成 injectCode 文件,返回路径
*/
function generateInjectCodePath(options) {
return __awaiter(this, void 0, void 0, function* () {
const injectCode = yield generateInjectCode(options);
yield fs_extra_1.default.writeJSON(config_1.default.injectCodePath, injectCode);
return config_1.default.injectCodePath;
});
}
exports.generateInjectCodePath = generateInjectCodePath;
function generateInjectCodePathSync(options) {
const injectCode = generateInjectCodeSync(options);
fs_extra_1.default.writeJSONSync(config_1.default.injectCodePath, injectCode);
return config_1.default.injectCodePath;
}
exports.generateInjectCodePathSync = generateInjectCodePathSync;
/**
* 检查资源文件更新
*/
function updateInjectCodeAssets(options = {}) {
return __awaiter(this, void 0, void 0, function* () {
if (options.cacheToday) {
yield assets_1.getGlobaleAssetsManager().updateOfflineAssetsToday();
}
else {
yield assets_1.getGlobaleAssetsManager().updateOfflineAssets();
}
});
}
exports.updateInjectCodeAssets = updateInjectCodeAssets;
function getGetBoatmanBundleOptions(options) {
const opt = Object.assign({}, options);
if (!opt.target || Object.keys(interface_1.ECompileTargetType).indexOf(opt.target) === -1) {
opt.target = interface_1.ECompileTargetType.Mini;
}
return opt;
}
function getBoatmanBundlePath(options = {}) {
return __awaiter(this, void 0, void 0, function* () {
const opt = getGetBoatmanBundleOptions(options);
// 若文件不存在降级到 readonly 备份
try {
yield fs_extra_1.default.access(config_1.default.boatmanPath[opt.target], fs_extra_1.default.constants.R_OK);
return config_1.default.boatmanPath[opt.target];
}
catch (error) {
return config_1.default.boatmanReadOnlyPath[opt.target];
}
});
}
exports.getBoatmanBundlePath = getBoatmanBundlePath;
function getBoatmanBundlePathSync(options = {}) {
const opt = getGetBoatmanBundleOptions(options);
try {
fs_extra_1.default.accessSync(config_1.default.boatmanPath[opt.target], fs_extra_1.default.constants.R_OK);
return config_1.default.boatmanPath[opt.target];
}
catch (error) {
return config_1.default.boatmanReadOnlyPath[opt.target];
}
}
exports.getBoatmanBundlePathSync = getBoatmanBundlePathSync;
var interface_1 = require("./interface");
exports.ECompileModeType = interface_1.ECompileModeType;
exports.ECompileTargetType = interface_1.ECompileTargetType;
var sdk_1 = require("./sdk");
exports.BuilderDebugClient = sdk_1.BuilderDebugClient;
var utils_1 = require("./utils");
exports.updateInjectCodeAssets = utils_1.updateInjectCodeAssets;
exports.generateInjectCode = utils_1.generateInjectCode;
exports.generateInjectCodeSync = utils_1.generateInjectCodeSync;
exports.generateInjectCodePath = utils_1.generateInjectCodePath;
exports.generateInjectCodePathSync = utils_1.generateInjectCodePathSync;
exports.getBoatmanBundlePath = utils_1.getBoatmanBundlePath;
exports.getBoatmanBundlePathSync = utils_1.getBoatmanBundlePathSync;
exports.loadConfig = utils_1.loadConfig;

@@ -8,4 +8,4 @@ export declare enum ECompileTargetType {

Remotex = "Remotex",
RemotexLite = "RemotexLite",
Preview = "Preview",
SimulatorWithTyro = "SimulatorWithTyro",
RemoteBoatman = "RemoteBoatman"

@@ -38,2 +38,4 @@ }

integrity_boatman_mini: string;
url_boatman_cube?: string;
integrity_boatman_cube: string;
}

@@ -47,1 +49,49 @@ export interface IAssetsMap {

}
export interface IBuilderDebugClientOptions extends IBuilderDebugConfig {
}
export interface IBuilderDebugConfig {
assetsQueryUrl: string;
injectCodeTempPath: string;
offlineDirectoryPath: string;
readonlyDirectoryPath: string;
assetsMapFilename: string;
boatmanFilename: Record<ECompileTargetType, string>;
}
export interface IBuilderDebugContext {
assetsQueryUrl: string;
injectCodeTempPath: string;
getAssetsMapFilePath(): string;
getBoatmanFilePath(target: ECompileTargetType): string;
getReadonlyAssetsMapFilePath(): string;
getReadonlyBoatmanFilePath(target: ECompileTargetType): string;
}
export interface IBuilderDebugClient {
/**
* 检查更新本地 offline 目录下的资源文件
*/
updateOfflineAssets(options: IUpdateAssetsOptions): Promise<void>;
/**
* 生成构建器消费的 InjectCode 注入点对象
*/
generateInjectCode(options: IGenerateInjectCodeOptions): Promise<IInjectionPoints>;
/**
* generateInjectCode 同步方法
*/
generateInjectCodeSync(options: IGenerateInjectCodeOptions): IInjectionPoints;
/**
* 生成构建器消费的 InjectCode JSON 文件,并返回路径
*/
generateInjectCodePath(options: IGenerateInjectCodeOptions): Promise<string>;
/**
* generateInjectCodePath 同步方法
*/
generateInjectCodePathSync(options: IGenerateInjectCodeOptions): string;
/**
* 获取本地 boatman 文件资源路径
*/
getBoatmanBundlePath(options: IGetBoatmanBundleOptions): Promise<string>;
/**
* getBoatmanBundlePath 同步方法
*/
getBoatmanBundlePathSync(options: IGetBoatmanBundleOptions): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ECompileModeType = exports.ECompileTargetType = void 0;
var ECompileTargetType;

@@ -13,5 +12,5 @@ (function (ECompileTargetType) {

ECompileModeType["Remotex"] = "Remotex";
ECompileModeType["RemotexLite"] = "RemotexLite";
ECompileModeType["Preview"] = "Preview";
ECompileModeType["SimulatorWithTyro"] = "SimulatorWithTyro";
ECompileModeType["RemoteBoatman"] = "RemoteBoatman";
})(ECompileModeType = exports.ECompileModeType || (exports.ECompileModeType = {}));
{
"name": "builder-debug-utils",
"version": "2.2.1",
"version": "3.0.0",
"main": "dist/index.js",

@@ -13,3 +13,3 @@ "types": "lib/index.d.ts",

"scripts": {
"build": "tsc -p ./tsconfig.json && yarn run build:dist",
"build": "tsc -p ./tsconfig.json && tnpm run build:dist",
"build:dist": "rollup -c rollup.config.js",

@@ -19,8 +19,7 @@ "watch": "tsc-watch -p ./tsconfig.json --onSuccess 'tnpm run build:dist'",

"lint:fix": "tslint --fix --project ./tsconfig.json",
"generate": "node scripts/generator.js"
"prepublishOnly": "tnpm run build",
"generate": "node scripts/generator.js",
"test": "jest --coverage",
"ci": "tnpm run lint && tnpm run build && tnpm run test"
},
"tnpm": {
"mode": "yarn",
"lockfile": "enable"
},
"devDependencies": {

@@ -30,5 +29,8 @@ "@rollup/plugin-commonjs": "^11.1.0",

"@types/fs-extra": "^8.1.0",
"@types/jest": "^26.0.23",
"@types/node": "^13.11.1",
"jest": "^26.6.3",
"rollup": "^2.10.3",
"rollup-plugin-terser": "^5.3.0",
"ts-jest": "^26.5.6",
"tsc-watch": "^4.2.9",

@@ -41,9 +43,3 @@ "tslint": "^6.1.1",

"fs-extra": "^9.0.0"
},
"volans_build_asar": {
"enable": true,
"exclude": [
"offline/**"
]
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc