@hap-toolkit/debugger 2.0.6-beta.1 → 2.0.6-beta.4
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/lib/adb/module.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _adbDevicesEmitter=_interopRequireDefault(require("adb-devices-emitter")),_adbCommander=_interopRequireDefault(require("adb-commander")),_sharedUtils=require("@hap-toolkit/shared-utils"),_debuglog=_interopRequireDefault(require("./debuglog"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const REMOTE_REVERSE_PORT=12306,REMOTE_UP_FORWARD_PORT=39517;class ADBModule{constructor(e){this.option=e,this.currentDeviceMap=new Map,this.cachedDeviceMap=new Map,this.DEBUG=(process.env.NODE_DEBUG||"").split(",").includes("adb"),this._localUpForwardPort=39517,this.commander=_adbCommander.default,this.devicesEmitter=_adbDevicesEmitter.default,this._lastPromise=null,this.emulators=new Map,this.init()}init(){(0,_debuglog.default)("init(): start"),this.devicesEmitter.addEventListener("deviceAdded",(e=>{this._listen(e,this.onDeviceAdded.bind(this))})),this.devicesEmitter.addEventListener("deviceRemoved",(e=>{this._listen(e,this.onDeviceRemoved.bind(this))})),this.devicesEmitter.start()}_listen(e,r){this._lastPromise?this._lastPromise=this._lastPromise.then((()=>r(e)),(()=>r(e))):this._lastPromise=r(e)}_getNextLocalForwardPort(){return this._localUpForwardPort++}async onDeviceAdded(e){const{sn:r}=e;_sharedUtils.colorconsole.info(`### App Server ### 设备"${r}"被连入`);const{result:t}=await this.commander.getProp(r);t&&this.emulators.set(t.trim(),r);const o=this.option.localReversePort;if((await this.establishADBProxyLink("reverse",[r,o,12306])).err)return void _sharedUtils.colorconsole.error(`### App Server ### onDeviceAdded(): (${r})建立adb reverse失败(local port: ${o}, remote port: 12306)`);let i=this.cachedDeviceMap.get(r);(0,_debuglog.default)(`onDeviceAdded():(${r})\ncachedDevice:\t${JSON.stringify(i)}\ncachedDeviceList:\t${JSON.stringify(Array.from(this.cachedDeviceMap.entries()))}`),i&&i.upForwardPortPair||(i={upForwardPortPair:[this._getNextLocalForwardPort(),39517]});if((await this.establishADBProxyLink("forward",[r].concat(i.upForwardPortPair))).err)_sharedUtils.colorconsole.error(`### App Server ### onDeviceAdded(): (${r})建立adb forward失败(local port: ${i.upForwardPortPair[0]}, remote port: ${i.upForwardPortPair[1]}) `);
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _adbDevicesEmitter=_interopRequireDefault(require("adb-devices-emitter")),_adbCommander=_interopRequireDefault(require("adb-commander")),_sharedUtils=require("@hap-toolkit/shared-utils"),_debuglog=_interopRequireDefault(require("./debuglog"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const REMOTE_REVERSE_PORT=12306,REMOTE_UP_FORWARD_PORT=39517;class ADBModule{constructor(e){this.option=e,this.currentDeviceMap=new Map,this.cachedDeviceMap=new Map,this.DEBUG=(process.env.NODE_DEBUG||"").split(",").includes("adb"),this._localUpForwardPort=39517,this.commander=_adbCommander.default,this.devicesEmitter=_adbDevicesEmitter.default,this._lastPromise=null,this.emulators=new Map,this.init()}init(){(0,_debuglog.default)("init(): start"),this.devicesEmitter.addEventListener("deviceAdded",(e=>{this._listen(e,this.onDeviceAdded.bind(this))})),this.devicesEmitter.addEventListener("deviceRemoved",(e=>{this._listen(e,this.onDeviceRemoved.bind(this))})),this.devicesEmitter.start()}_listen(e,r){this._lastPromise?this._lastPromise=this._lastPromise.then((()=>r(e)),(()=>r(e))):this._lastPromise=r(e)}_getNextLocalForwardPort(){return this._localUpForwardPort++}async onDeviceAdded(e){const{sn:r}=e;_sharedUtils.colorconsole.info(`### App Server ### 设备"${r}"被连入`);const{result:t}=await this.commander.getProp(r);t&&this.emulators.set(t.trim(),r);const o=this.option.localReversePort;if((await this.establishADBProxyLink("reverse",[r,o,12306])).err)return void _sharedUtils.colorconsole.error(`### App Server ### onDeviceAdded(): (${r})建立adb reverse失败(local port: ${o}, remote port: 12306)`);let i=this.cachedDeviceMap.get(r);(0,_debuglog.default)(`onDeviceAdded():(${r})\ncachedDevice:\t${JSON.stringify(i)}\ncachedDeviceList:\t${JSON.stringify(Array.from(this.cachedDeviceMap.entries()))}`),i&&i.upForwardPortPair||(i={upForwardPortPair:[this._getNextLocalForwardPort(),39517]});if((await this.establishADBProxyLink("forward",[r].concat(i.upForwardPortPair))).err)return void _sharedUtils.colorconsole.error(`### App Server ### onDeviceAdded(): (${r})建立adb forward失败(local port: ${i.upForwardPortPair[0]}, remote port: ${i.upForwardPortPair[1]}) `);if(i.wsPortPair){(await this.establishADBProxyLink("forward",[r,i.wsPortPair[0],i.wsPortPair[1]])).err&&(_sharedUtils.colorconsole.warn(`### App Server ### onDeviceAdded():(${r}) 建立adb forward失败(local port: ${i.wsPortPair[0]}, remote port: ${i.wsPortPair[1]})`),i.wsPortPair=void 0)}this.currentDeviceMap.set(r,i),this.cachedDeviceMap.set(r,i);const s={};s[i.upForwardPortPair[1]]=i.upForwardPortPair[0],await this._writeClientLogFile({sn:r,ip:"127.0.0.1",port:i.upForwardPortPair[0],remote2local:s}),(0,_debuglog.default)(`onDeviceAdded():(${r}) end`),this.onCheckDeviceReverse(e)}async getForwardPort(e,r){let t=e.remote2local;if(!t)return e.port;let o=t[r];return o||(o=await this.addForwardPort(e,r)),o}async addForwardPort(e,r){const t=this._getNextLocalForwardPort();(0,_debuglog.default)(`addForwardPort():(${e.sn}) (local port: ${t}, remote port: ${r}) start`);if(!(await this.establishADBProxyLink("forward",[e.sn].concat([t,r]))).err)return e.remote2local[r]=t,await this._writeClientLogFile(e),(0,_debuglog.default)(`addForwardPort():(${e.sn}) (local port: ${t}, remote port: ${r}) end`),t;_sharedUtils.colorconsole.error(`### App Server ### addForwardPort(): (${e.sn})建立adb forward失败(local port: ${t}, remote port: ${r}) `)}onCheckDeviceReverse(e){const{sn:r}=e;try{setTimeout((async()=>{const{result:e}=await this.commander._commandFactory(`adb -s ${r} reverse --list`);e&&-1!==e.indexOf(this.option.localReversePort)?_sharedUtils.colorconsole.info(`### App Server ### onCheckDeviceReverse(): (${r})建立adb reverse成功 )`):_sharedUtils.colorconsole.error(`### App Server ### onCheckDeviceReverse(): (${r})建立adb reverse失败,请重新运行命令调试 )`)}),6e3)}catch(e){_sharedUtils.colorconsole.error("### App Server ### onCheckDeviceReverse(): adb reverse连接检测失败")}}async onDeviceRemoved(e){const{sn:r}=e;_sharedUtils.colorconsole.info(`### App Server ### 手机设备(${r})被拔出`),this.currentDeviceMap.delete(r),this.DEBUG&&((0,_debuglog.default)(`deviceRemoved():(${r}) cachedDeviceList: ${JSON.stringify(Array.from(this.cachedDeviceMap.entries()))}`),await this.commander.print(`adb -s ${r} reverse --list`),await this.commander.print(`adb -s ${r} forward --list`)),await this._removeItemFromClientLogFile(r),(0,_debuglog.default)(`deviceRemoved():(${r}) end`)}async _writeClientLogFile(e){try{const{clientRecordPath:r}=_sharedUtils.globalConfig;(0,_sharedUtils.recordClient)(r,e,(e=>{(0,_debuglog.default)(e)}))}catch(e){_sharedUtils.colorconsole.error(`### App Server ### writeClientLogFile(): 写入hap-toolkit-client-records.json文件出错: ${e.message}`)}}async _removeItemFromClientLogFile(e){try{const{clientRecordPath:r}=_sharedUtils.globalConfig;(0,_sharedUtils.removeClientBySn)(r,e,(e=>{(0,_debuglog.default)(e)}))}catch(e){_sharedUtils.colorconsole.error(`### App Server ### _removeItemFromClientLogFile(): 移除hap-toolkit-client-records.json设备信息出错: ${e.message}`)}}async forwardForWsChannel(e,r){let t=this.currentDeviceMap.get(e);const o=r;if(!t){const r=this.emulators.get(e);_sharedUtils.colorconsole.warn(`### App Server ### 通过(${e})查找到设备${r}`),t=this.currentDeviceMap.get(r),t&&(e=r)}if(!t)return _sharedUtils.colorconsole.error(`### App Server ### 获取(${e})设备信息失败`),{localWsPort:o};const i=t.wsPortPair;if(i&&i[0]===o&&i[1]===r)return{localWsPort:o};const{err:s}=await this.establishADBProxyLink("forward",[e,o,r]);return s?(_sharedUtils.colorconsole.error("### AppApp Server ### forwardForWsChannel(): 创建WebSocket端口映射失败"),t.wsPortPair=void 0,{err:s}):(t.wsPortPair=[o,r],{localWsPort:o})}async establishADBProxyLink(e,r){const t=await this.commander[e](...r);return this.DEBUG&&((0,_debuglog.default)(`establishADBReverseLink(): (${r[0]}) adb ${e} setup result: ${JSON.stringify(t)}`),await this.commander.print(`adb -s ${r[0]} ${e} --list`)),t}_stop(){_sharedUtils.colorconsole.log("### ADB stop"),this.devicesEmitter.stop()}}var _default=ADBModule;exports.default=_default;
|
|
2
2
|
//# sourceMappingURL=module.js.map
|
package/lib/client/index.html
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>调试器</title><link href="./index-
|
|
1
|
+
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>调试器</title><link href="./index-ac63e241.css" rel="stylesheet"></head><body class="bd-bg"><section class="qr-code-wrapper"><div><div class="qr-code-panel"><div class="qr-img"><img src="" id="j-qr-icon" class="qr-icon"></div><div class="block alert alert-warning updatetip"><div class="block"><h2 class="block-title" title="在设备上预览">手机预览</h2><p>1. 扫码安装rpk包</p><p>2. 在手机的调试器上点击 <button class="btn btn-default">开始调试</button> ,启动调试界面</p></div><div class="block"><h2 class="block-title" title="在浏览器中预览">web 预览</h2><p><a href="/preview" target="_blank">打开 web 预览</a></p></div></div></div></div></section><section class="inform-tip-wrapper"></section><section class="result inspector-link-panel hide"><div class="panel panel-default"><div class="panel-heading">调试</div><div class="panel-body"><table class="table tunning"><tbody></tbody></table></div></div></section><script type="text/template" id="j-tpl-appinfo"><tr>
|
|
2
2
|
<td class="tname">{{data_app_name}}</td>
|
|
3
3
|
<td class="tlink"><a href='{{data_href_value}}' target='_blank' class="label label-info">{{data_href_name}}</a>
|
|
4
4
|
</td>
|
|
5
5
|
</tr></script><script type="text/template" id="j-tpl-updatetip"><div class="alert alert-warning updatetip">
|
|
6
6
|
<p>调试器已有重要更新,请更新调试器</p>
|
|
7
|
-
</div></script><script src="/socket.io/socket.io.js"></script><script defer="defer" src="index-
|
|
7
|
+
</div></script><script src="/socket.io/socket.io.js"></script><script defer="defer" src="index-ac63e241.js"></script></body></html>
|
package/lib/router/routes.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0,exports.saveSkeletonFile=saveSkeletonFile,exports.searchSn=searchSn,exports.startDebug=startDebug;var _path=_interopRequireDefault(require("path")),_fs=_interopRequireDefault(require("fs")),_qrImage=_interopRequireDefault(require("qr-image")),_sharedUtils=require("@hap-toolkit/shared-utils"),_utils=require("../utils"),_service=require("./service");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}async function index(e,t){const r=_path.default.resolve(__dirname,"../client/index.html");try{_fs.default.existsSync(r)?(e.set("Content-Type","text/html;charset=utf8"),e.body=_fs.default.createReadStream(r)):(await t(),e.throw("404",`无法找到${r}文件`))}catch(t){_sharedUtils.colorconsole.error(`### App Server ### 无法获取${r}文件: ${t}`),e.body=`404 Not found ${r}`}}async function register(e,t){_sharedUtils.colorconsole.info(`### App Server ### 收到App注册信息, 格式:\n${JSON.stringify(e.request.body)}\n`),await t();const{ws:r,application:s}=e.request.body,{serverPort:o}=e.conf.defaults,a=(0,_service.getInspectorUrl)({ws:r,serverPort:o});emitWSEvent(e.io,"appRegistered",{inspectorUrl:a,application:s}),_sharedUtils.colorconsole.info(`请访问以下链接进行调试:\n\n${a}\n`)}async function adapterForBackwardComp(e,t){try{const r=e.request.body,{method:s,path:o}=e,a="ws"in r&&r.ws.indexOf("inspector")>=0,i="application"in r&&r.application.indexOf("hybrid.loader")>=0;if("post"===s.toLowerCase()&&"/"===o&&a&&i){_sharedUtils.colorconsole.warn("调试器已有重要更新,请更新调试器"),emitWSEvent(e.io,"informUpdate");const{ws:t,application:s}=r,{serverPort:o}=e.conf.defaults,a=(0,_service.getInspectorUrl)({ws:t,serverPort:o});emitWSEvent(e.io,"appRegistered",{inspectorUrl:a,application:s}),_sharedUtils.colorconsole.info(`请访问以下链接进行调试:\n\n${a}\n`)}else await t()}catch(e){_sharedUtils.colorconsole.error(`### App Server ### 出错信息: ${e.message}`),_sharedUtils.colorconsole.error("### App Server ### 当前调试器与toolkit不兼容,请更新调试器。"),await t()}}async function qrCode(e,t){const{serverPort:r}=e.conf.defaults,s=`http://${(0,_sharedUtils.getServerIPAndPort)(r)}`,o=_qrImage.default.image(s,{size:9});await t(),e.type="image/png",e.body=o}async function searchSn(e,t){e.status=200;const r=_sharedUtils.globalConfig.clientRecordPath;try{if(_fs.default.existsSync(r)){const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0,exports.saveSkeletonFile=saveSkeletonFile,exports.searchSn=searchSn,exports.startDebug=startDebug;var _path=_interopRequireDefault(require("path")),_fs=_interopRequireDefault(require("fs")),_qrImage=_interopRequireDefault(require("qr-image")),_sharedUtils=require("@hap-toolkit/shared-utils"),_utils=require("../utils"),_service=require("./service");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}async function index(e,t){const r=_path.default.resolve(__dirname,"../client/index.html");try{_fs.default.existsSync(r)?(e.set("Content-Type","text/html;charset=utf8"),e.body=_fs.default.createReadStream(r)):(await t(),e.throw("404",`无法找到${r}文件`))}catch(t){_sharedUtils.colorconsole.error(`### App Server ### 无法获取${r}文件: ${t}`),e.body=`404 Not found ${r}`}}async function register(e,t){_sharedUtils.colorconsole.info(`### App Server ### 收到App注册信息, 格式:\n${JSON.stringify(e.request.body)}\n`),await t();const{ws:r,application:s}=e.request.body,{serverPort:o}=e.conf.defaults,a=(0,_service.getInspectorUrl)({ws:r,serverPort:o});emitWSEvent(e.io,"appRegistered",{inspectorUrl:a,application:s}),_sharedUtils.colorconsole.info(`请访问以下链接进行调试:\n\n${a}\n`)}async function adapterForBackwardComp(e,t){try{const r=e.request.body,{method:s,path:o}=e,a="ws"in r&&r.ws.indexOf("inspector")>=0,i="application"in r&&r.application.indexOf("hybrid.loader")>=0;if("post"===s.toLowerCase()&&"/"===o&&a&&i){_sharedUtils.colorconsole.warn("调试器已有重要更新,请更新调试器"),emitWSEvent(e.io,"informUpdate");const{ws:t,application:s}=r,{serverPort:o}=e.conf.defaults,a=(0,_service.getInspectorUrl)({ws:t,serverPort:o});emitWSEvent(e.io,"appRegistered",{inspectorUrl:a,application:s}),_sharedUtils.colorconsole.info(`请访问以下链接进行调试:\n\n${a}\n`)}else await t()}catch(e){_sharedUtils.colorconsole.error(`### App Server ### 出错信息: ${e.message}`),_sharedUtils.colorconsole.error("### App Server ### 当前调试器与toolkit不兼容,请更新调试器。"),await t()}}async function qrCode(e,t){const{serverPort:r}=e.conf.defaults,s=`http://${(0,_sharedUtils.getServerIPAndPort)(r)}`,o=_qrImage.default.image(s,{size:9});await t(),e.type="image/png",e.body=o}async function searchSn(e,t){e.status=200;const r=_sharedUtils.globalConfig.clientRecordPath;try{if(_fs.default.existsSync(r)){const t=(0,_sharedUtils.getRecords)(r),s=(0,_sharedUtils.getProjectClients)(t);if(s.length>0){const t=e.request.query.port;_sharedUtils.colorconsole.log("### App Loader ### 通知设备开始下发SN");for(const r of s)if("127.0.0.1"===r.ip)if(t){const s=await e.adbDebugger.getForwardPort(r,t);(0,_service.callDeviceWithOwnSn)(r,s)}else(0,_sharedUtils.getDeviceInfo)(r,((e,t)=>{e||t.sn||(0,_service.callDeviceWithOwnSn)(r)}))}}else await t(),e.throw("404","无法获取设备SN")}catch(e){_sharedUtils.colorconsole.warn(`### App Server ### 没有记录设备信息,请尝试重新连接: ${e}`)}}async function startDebug(e,t){e.status=200;const r=(0,_service.getDebugInfoFromRequest)(e.request),{sn:s,linkMode:o,devicePort:a,application:i,target:n,traceId:l}=r;let c=r.ws;if(process.env.TRACE_ID=l||"NULL",(0,_utils.trackDebug)(_utils.eventAlias.h_re_std,{DEVICE_SN:s,DEVICE_PORT:a}),o===_service.LINK_MODE.ADB){const{localWsPort:r,err:o}=await e.adbDebugger.forwardForWsChannel(s,a);if(console.error(`startDebug(): adb forward 端口映射: sn=${s},devicePort=${a}`),o)return console.error(`startDebug(): adb forward 端口映射失败: ${o.message}`),(0,_utils.trackDebug)(_utils.eventAlias.h_forward_err),void await t();c=c.replace(a,r)}const{serverPort:d}=e.conf.defaults,u=(0,_service.getInspectorUrl)({ws:c,serverPort:d,traceId:l});emitWSEvent(e.io,"appRegistered",{inspectorUrl:u,application:i}),_sharedUtils.colorconsole.info(`请访问以下链接进行调试:\n\n${u}\n`);const p=e.conf.options.callback;if(p&&"function"==typeof p){p({url:u,action:"openDebugWin",target:n})}(0,_utils.trackDebug)(_utils.eventAlias.h_ins_url,{inspectorUrl:u}),!1!==e.conf.options.openDebugger&&await(0,_utils.startChrome)(u,{chromePath:e.conf.options.chromePath}),await t()}async function saveSkeletonFile(e,t){e.status=200;try{const{page:r,code:s,file:o}=e.request.body,a=_path.default.join(_sharedUtils.globalConfig.projectPath,"src/skeleton");_fs.default.existsSync(a)||_fs.default.mkdirSync(a);const i=_path.default.join(a,"config.json");let n;_fs.default.existsSync(i)?(n=(0,_sharedUtils.readJson)(i),n.singleMap[r]||(n.singleMap[r]=o)):n={singleMap:{[r]:o}},_fs.default.writeFileSync(i,JSON.stringify(n,null,2));const l=_path.default.join(a,"page");_fs.default.existsSync(l)||_fs.default.mkdirSync(l);const c=_path.default.join(l,o);_fs.default.writeFileSync(c,s),e.body={code:0,msg:c},await t()}catch(r){e.body={code:1,msg:r.message},await t()}}function emitWSEvent(e,t,r){e.sockets.emit(t,r||{})}var _default={index:index,register:register,adapterForBackwardComp:adapterForBackwardComp,qrCode:qrCode,searchSn:searchSn,startDebug:startDebug,saveSkeletonFile:saveSkeletonFile};exports.default=_default;
|
|
2
2
|
//# sourceMappingURL=routes.js.map
|
package/lib/router/service.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LINK_MODE=void 0,exports.callDeviceWithOwnSn=callDeviceWithOwnSn,exports.getDebugInfoFromRequest=getDebugInfoFromRequest,exports.getInspectorUrl=getInspectorUrl;var _http=_interopRequireDefault(require("http")),_sharedUtils=require("@hap-toolkit/shared-utils");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const LINK_MODE={NULL:0,WIFI:1,ADB:2};function getInspectorUrl({ws:e,serverPort:t,traceId:r}){return`${`http://${(0,_sharedUtils.getServerIPAndPort)(t)}`}/inspector/inspector.html${`?ws=${encodeURI(e)}&remoteFrontend=true&dockSide=undocked&traceId=${r}`}`}function getClientFromRequest(e){const t=(0,_sharedUtils.getClientIPAddress)(e),r=(0,_sharedUtils.getIPv4IPAddress)(),o=e.header["device-serial-number"];let n=LINK_MODE.NULL;return"127.0.0.1"===t&&o?n=LINK_MODE.ADB:"127.0.0.1"!==t&&t!==r&&(n=LINK_MODE.WIFI),{clientIp:t,sn:o,linkMode:n}}function getDebugInfoFromRequest(e){const{sn:t,linkMode:r}=getClientFromRequest(e),{ws:o,application:n,target:s,traceId:i}=e.body,l=o.split(":")[1].split("/")[0];return{sn:t,linkMode:r,ws:o,application:n,devicePort:l,target:s,traceId:i}}function callDeviceWithOwnSn(e){const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LINK_MODE=void 0,exports.callDeviceWithOwnSn=callDeviceWithOwnSn,exports.getDebugInfoFromRequest=getDebugInfoFromRequest,exports.getInspectorUrl=getInspectorUrl;var _http=_interopRequireDefault(require("http")),_sharedUtils=require("@hap-toolkit/shared-utils");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const LINK_MODE={NULL:0,WIFI:1,ADB:2};function getInspectorUrl({ws:e,serverPort:t,traceId:r}){return`${`http://${(0,_sharedUtils.getServerIPAndPort)(t)}`}/inspector/inspector.html${`?ws=${encodeURI(e)}&remoteFrontend=true&dockSide=undocked&traceId=${r}`}`}function getClientFromRequest(e){const t=(0,_sharedUtils.getClientIPAddress)(e),r=(0,_sharedUtils.getIPv4IPAddress)(),o=e.header["device-serial-number"];let n=LINK_MODE.NULL;return"127.0.0.1"===t&&o?n=LINK_MODE.ADB:"127.0.0.1"!==t&&t!==r&&(n=LINK_MODE.WIFI),{clientIp:t,sn:o,linkMode:n}}function getDebugInfoFromRequest(e){const{sn:t,linkMode:r}=getClientFromRequest(e),{ws:o,application:n,target:s,traceId:i}=e.body,l=o.split(":")[1].split("/")[0];return{sn:t,linkMode:r,ws:o,application:n,devicePort:l,target:s,traceId:i}}function callDeviceWithOwnSn(e,t){t||(t=e.port);const r={host:e.ip,port:t,path:"/reportsn",headers:{"device-serial-number":e.sn},timeout:3e3},o=_http.default.request(r,(()=>{_sharedUtils.colorconsole.log(`### App Server ### 通知手机设备(${e.sn}) port ${t} 下发SN成功`)})).on("error",(r=>{_sharedUtils.colorconsole.warn(`### App Server ### 通知手机设备(${e.sn}) port ${t} 下发SN失败 错误信息: ${r.message}`)})).on("timeout",(function(){_sharedUtils.colorconsole.warn(`### App Server ### 通知手机设备(${e.sn})下发SN失败`),o.abort()}));o.end()}exports.LINK_MODE=LINK_MODE;
|
|
2
2
|
//# sourceMappingURL=service.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hap-toolkit/debugger",
|
|
3
|
-
"version": "2.0.6-beta.
|
|
3
|
+
"version": "2.0.6-beta.4",
|
|
4
4
|
"description": "@hap-toolkit/debugger",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=14.0.0"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@hap-toolkit/chrome-devtools-frontend": "^1.1.2",
|
|
32
|
-
"@hap-toolkit/shared-utils": "2.0.6-beta.
|
|
32
|
+
"@hap-toolkit/shared-utils": "2.0.6-beta.4",
|
|
33
33
|
"@jayfate/path": "^0.0.13",
|
|
34
34
|
"@sentry/node": "^5.26.0",
|
|
35
35
|
"adb-commander": "^0.1.9",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"mini-css-extract-plugin": "^1.3.0",
|
|
51
51
|
"mkdirp": "^0.5.5"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "9fbf8ec01cc7fbd44a4908ecdc407a5022e89e7e"
|
|
54
54
|
}
|
|
File without changes
|
|
File without changes
|