vite-uni-dev-tool 1.2.1 → 1.2.3
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/README.md +4 -0
- package/dist/core.js +1 -1
- package/dist/modules/devEvent/index.cjs +1 -1
- package/dist/modules/devEvent/index.js +2 -2
- package/dist/type.d.ts +0 -2
- package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolData.ts +0 -2
- package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolHandlers.ts +0 -13
- package/dist/v3/DevTool/components/DevToolWindow/index.vue +3 -15
- package/dist/v3/DevTool/components/NetworkList/NetworkIntercept.vue +1 -1
- package/dist/v3/DevTool/components/SourceCode/Line.vue +1 -1
- package/dist/v3/DevTool/index.vue +4 -1
- package/package.json +70 -70
package/README.md
CHANGED
package/dist/core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{DevStore as f}from"./modules/devStore/index.js";import{DevEvent as v}from"./modules/devEvent/index.js";import{DevIntercept as p}from"./modules/devIntercept/index.js";import{DevConsole as s}from"./modules/devConsole/index.js";import{getPlatform as T}from"./utils/utils.js";import"./utils/index.js";import{consoleProxy as d,setDevConsole as l}from"./core-shared.js";import{backup as H}from"./core-shared.js";import{i18n as D}from"./i18n/instance.js";import{sleep as g}from"./utils/date.js";const i=e=>D.t(e),c="1.2.
|
|
1
|
+
import{DevStore as f}from"./modules/devStore/index.js";import{DevEvent as v}from"./modules/devEvent/index.js";import{DevIntercept as p}from"./modules/devIntercept/index.js";import{DevConsole as s}from"./modules/devConsole/index.js";import{getPlatform as T}from"./utils/utils.js";import"./utils/index.js";import{consoleProxy as d,setDevConsole as l}from"./core-shared.js";import{backup as H}from"./core-shared.js";import{i18n as D}from"./i18n/instance.js";import{sleep as g}from"./utils/date.js";const i=e=>D.t(e),c="1.2.3",u="2026/3/10 15:43:22",m="https://gitee.com/cloud_l/vite-uni-dev-tool",r=new f,t=new v({store:r}),_={getDevToolDestroy:()=>t.getDevToolDestroy(),getDevToolOptions:()=>t.getDevToolOptions(),getRequestIndex:()=>t.getRequestIndex(),setRequestIndex:e=>t.setRequestIndex(e),getTransferIndex:()=>r.getTransferIndex(),setTransferIndex:e=>r.setTransferIndex(e),getScreenIndex:()=>r.getScreenIndex(),setScreenIndex:e=>r.setScreenIndex(e),getInterceptNetworkMap:()=>t.getInterceptNetworkMap(),updateConsole:e=>t.updateConsoleList(e),updateNetwork:(e,o)=>t.updateNetworkList(e,o),updateWs:e=>t.updateWsList(e),addWsTask:(e,o)=>t.addWsTask(e,o),removeWsTask:e=>t.removeWsTask(e),updateStorage:e=>t.updateStorage(e),updateTransfer:(e,o)=>t.updateTransfer(e,o),updateUniEvent:e=>t.updateUniEvent(e),updateScreen:(e,o)=>t.updateScreen(e,o),updateScanCode:e=>t.updateScanCode(e),updateNfc:e=>t.updateNfc(e),updateBluetooth:e=>t.updateBluetooth(e),updateRoute:e=>t.updateRouteList(e),updateUniEventCount:e=>t.updateUniEventCount(e),addTransferTask:(e,o)=>t.addTransferTask(e,o),removeTransferTask:e=>t.removeTransferTask(e),clearStorage:()=>t.clearStorage(!1),removeStorage:e=>t.removeStorage(e,!1),closeWindow:()=>t.closeDevToolWindow(),setVuexList:e=>t.setVuexList(e),setVueStore:e=>t.setVueStore(e),setPiniaList:e=>t.setPiniaList(e),setPiniaStore:e=>t.setPiniaStore(e)},n=new p({hooks:_});let a;t.setIntercept(n);function S(){if(typeof uni>"u")return;const e=T();try{const o=Object.getOwnPropertyDescriptor(uni,"__dev_tool_platform__");if(o&&o.configurable===!1)return;Object.defineProperty(uni,"__dev_tool_platform__",{value:e,configurable:!0})}catch{}}function y(e){if(!(typeof uni>"u"))try{const o=Object.getOwnPropertyDescriptor(uni,"__dev_tool_scan_code_collection__");if(o&&o.configurable===!1)return;Object.defineProperty(uni,"__dev_tool_scan_code_collection__",{value:e.devToolScanCode.bind(e),configurable:!0})}catch{}}function b(e){if(!(typeof uni>"u"))try{const o=Object.getOwnPropertyDescriptor(uni,"__dev_tool_nfc_collection__");if(o&&o.configurable===!1)return;Object.defineProperty(uni,"__dev_tool_nfc_collection__",{value:e.devToolNFC.bind(e),configurable:!0})}catch{}}function L(){return r.getDevToolOptions()}async function R(e){e!=null&&e.mode||d.error(`[DevTool] ${i("common.modeRequired")}`),S(),y(t),b(t),a=new s(t),l(a),r.setDevToolOptions({...e||{mode:""},zIndex:(e==null?void 0:e.zIndex)??998,devToolVersion:c,devToolBuildTime:u,devToolGit:m}),n.interceptVue(e==null?void 0:e.vueInstance),n.init({enableCaptureScreen:e==null?void 0:e.enableCaptureScreen,enableInterceptPromiseReject:e==null?void 0:e.enableInterceptPromiseReject}),r.getDevToolDestroy()||(t.addEventListener(),t.postMessage()),d.log(`[DevTool] ${i("common.initSuccess")}
|
|
2
2
|
${i("setting.devTool.currentVersion")}:${c}
|
|
3
3
|
${i("setting.devTool.buildTime")}:${u}
|
|
4
4
|
${i("common.debugSlogan")}`),t.startAbnormalUpload(),await g(100),t.updateRouteList()}function V(){r.getDevToolDestroy()||t.showDevToolButton()}function j(){r.getDevToolDestroy()||t.hideDevToolButton()}function N(){r.getDevToolDestroy()||t.openDevToolWindow()}function B(){r.getDevToolDestroy()||t.closeDevToolWindow()}function $(){r.getDevToolDestroy()&&(a=new s(t),l(a),t.createDevTool({devToolVersion:c,devToolBuildTime:u}))}function E(){r.getDevToolDestroy()||(t.destroyDevTool(),n.reset(),a=void 0,l(void 0))}function q(){r.getDevToolDestroy()||t.restartDevTool()}function A(){t.restartApp()}function U(e){return n.interceptVuexStorage(e)}function M(e){return n.interceptPiniaStore(e)}function z(e){t.uploadAbnormal(e)}export{H as backup,B as closeDevToolWindow,d as console,$ as createDevTool,E as destroyDevTool,L as getDevToolOptions,j as hideDevToolButton,R as initDevTool,M as interceptPiniaStore,U as interceptVuexStorage,N as openDevToolWindow,A as restartApp,q as restartDevTool,V as showDevToolButton,z as uploadAbnormal};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../const.cjs");require("../../utils/index.cjs");const f=require("../../core-shared.cjs"),_=require("../../utils/function.cjs"),d=require("../../utils/object.cjs"),u=require("../../utils/page.cjs"),S=require("../../utils/date.cjs"),D=require("../../utils/language.cjs"),C=require("../../utils/file.cjs");class m{constructor({store:t}){this.abnormalUploadCount=0,this.abnormalUploadTimer=null,this.isAbnormalUploadActive=!1,this.isListening=!1,this.postMessage=_.throttle(()=>{this.postMessageFn()},2e3),this.store=t,this.messageBound=e=>{try{const s=typeof e=="string"?JSON.parse(e):e;this.handleUIMessage(s)}catch(s){console.error("[DevEvent] Failed to parse UI message",s)}},this.tapEventBound=this.tapEvent.bind(this),this.throttleTouchStartEvent=_.throttle(this.touchStartEvent.bind(this),1e3),this.throttleTouchMoveEvent=_.throttle(this.touchMoveEvent.bind(this),1e3),this.throttleTouchEndEvent=_.throttle(this.touchEndEvent.bind(this),1e3)}setIntercept(t){this.intercept=t}emitToUI(t,e={}){try{const s=d.serializeCircular({type:t,data:e});if(s.length>500*1024){console.warn(`[DevTool] Data too large to emit (${(s.length/1024).toFixed(2)}KB). Dropped to prevent crash.`),uni.$emit(o.DEV_CORE_MESSAGE,JSON.stringify({type:t,data:{_warning:"Data too large, transmission dropped.",size:s.length}}));return}uni.$emit(o.DEV_CORE_MESSAGE,s)}catch(s){console.error("[DevTool] emitToUI bridge error",s);try{uni.$emit(o.DEV_CORE_MESSAGE,JSON.stringify({type:t,data:{}}))}catch{}}}addEventListener(){this.isListening||(uni.$on(o.DEV_UI_MESSAGE,this.messageBound),this.addCaptureEventListener(),this.isListening=!0)}removeEventListener(){this.isListening&&(uni.$off(o.DEV_UI_MESSAGE,this.messageBound),this.removeCaptureEventListener(),this.isListening=!1)}createDevTool(t){var s;if(!this.store.getDevToolDestroy()){console.log("[DevTool] 调试器已创建,不再创建");return}const e=this.store.getDevToolOptions();(s=this.intercept)==null||s.init({enableCaptureScreen:e==null?void 0:e.enableCaptureScreen,enableInterceptPromiseReject:e==null?void 0:e.enableInterceptPromiseReject}),this.store.setDevToolDestroy(!1),this.store.updateRouteList(),this.emitToUI(o.MSG_TYPE.BUTTON_VISIBLE,!0),this.store.setDevToolButtonVisible(!0),setTimeout(()=>{console.log(`[DevTool] 创建成功
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../const.cjs");require("../../utils/index.cjs");const f=require("../../core-shared.cjs"),_=require("../../utils/function.cjs"),d=require("../../utils/object.cjs"),u=require("../../utils/page.cjs"),S=require("../../utils/date.cjs"),D=require("../../utils/language.cjs"),C=require("../../utils/file.cjs");class m{constructor({store:t}){this.abnormalUploadCount=0,this.abnormalUploadTimer=null,this.isAbnormalUploadActive=!1,this.isListening=!1,this.postMessage=_.throttle(()=>{this.postMessageFn()},2e3),this.store=t,this.messageBound=e=>{try{const s=typeof e=="string"?JSON.parse(e):e;this.handleUIMessage(s)}catch(s){console.error("[DevEvent] Failed to parse UI message",s)}},this.tapEventBound=this.tapEvent.bind(this),this.throttleTouchStartEvent=_.throttle(this.touchStartEvent.bind(this),1e3),this.throttleTouchMoveEvent=_.throttle(this.touchMoveEvent.bind(this),1e3),this.throttleTouchEndEvent=_.throttle(this.touchEndEvent.bind(this),1e3)}setIntercept(t){this.intercept=t}emitToUI(t,e={}){if(!this.store.getDevToolDestroy())try{const s=d.serializeCircular({type:t,data:e});if(s.length>500*1024){console.warn(`[DevTool] Data too large to emit (${(s.length/1024).toFixed(2)}KB). Dropped to prevent crash.`),uni.$emit(o.DEV_CORE_MESSAGE,JSON.stringify({type:t,data:{_warning:"Data too large, transmission dropped.",size:s.length}}));return}uni.$emit(o.DEV_CORE_MESSAGE,s)}catch(s){console.error("[DevTool] emitToUI bridge error",s);try{uni.$emit(o.DEV_CORE_MESSAGE,JSON.stringify({type:t,data:{}}))}catch{}}}addEventListener(){this.isListening||(uni.$on(o.DEV_UI_MESSAGE,this.messageBound),this.addCaptureEventListener(),this.isListening=!0)}removeEventListener(){this.isListening&&(uni.$off(o.DEV_UI_MESSAGE,this.messageBound),this.removeCaptureEventListener(),this.isListening=!1)}createDevTool(t){var s;if(!this.store.getDevToolDestroy()){console.log("[DevTool] 调试器已创建,不再创建");return}const e=this.store.getDevToolOptions();(s=this.intercept)==null||s.init({enableCaptureScreen:e==null?void 0:e.enableCaptureScreen,enableInterceptPromiseReject:e==null?void 0:e.enableInterceptPromiseReject}),this.store.setDevToolDestroy(!1),this.store.updateRouteList(),this.emitToUI(o.MSG_TYPE.BUTTON_VISIBLE,!0),this.store.setDevToolButtonVisible(!0),setTimeout(()=>{console.log(`[DevTool] 创建成功
|
|
2
2
|
当前版本:${t==null?void 0:t.devToolVersion}
|
|
3
3
|
构建时间:${t==null?void 0:t.devToolBuildTime}
|
|
4
4
|
一处编写,到处调试 😂`)},500),this.addEventListener(),this.postMessage()}destroyDevTool(){var t;this.store.getDevToolDestroy()||(this.emitToUI(o.MSG_TYPE.BUTTON_VISIBLE,!1),this.store.setDevToolButtonVisible(!1),this.emitToUI(o.MSG_TYPE.WINDOW_VISIBLE,!1),this.store.setRequestIndex(-1),this.store.setTransferIndex(-1),this.store.setDevToolDestroy(!0),this.store.clearAll(),(t=this.intercept)==null||t.reset(),this.removeEventListener(),f.backup.originalConsole.log("[DevTool] 调试器已销毁"))}restartDevTool(){this.destroyDevTool(),this.createDevTool({devToolBuildTime:this.store.devToolBuildTime,devToolVersion:this.store.devToolVersion}),this.emitToUI(o.MSG_TYPE.WINDOW_VISIBLE,!0)}async postMessageFn(){if(this.store.getDevToolDestroy())return;const t=await this.store.getDevData(),e=d.calculateObjectSize(t),s=d.formatStorageSize(e);t.size=e,t.sizeFormat=s,this.emitToUI(o.MSG_TYPE.DATA_UPDATE,t),e>this.store.cacheMaxSize&&this.store.clearDevCache()}openDevToolWindow(){this.store.getDevToolDestroy()||(setTimeout(()=>this.postMessage(),100),this.emitToUI(o.MSG_TYPE.WINDOW_VISIBLE,!0))}closeDevToolWindow(){this.store.getDevToolDestroy()||this.emitToUI(o.MSG_TYPE.WINDOW_VISIBLE,!1)}showDevToolButton(){this.store.getDevToolDestroy()||(this.emitToUI(o.MSG_TYPE.BUTTON_VISIBLE,!0),this.store.setDevToolButtonVisible(!0))}hideDevToolButton(){this.store.getDevToolDestroy()||(this.emitToUI(o.MSG_TYPE.BUTTON_VISIBLE,!1),this.store.setDevToolButtonVisible(!1))}sendDevToolOption(){const t=this.store.getDevToolOptions();this.emitToUI(o.MSG_TYPE.OPTION_UPDATE,t)}devToolScanCode(t,e){this.updateScanCode([{timer:Date.now(),result:t,scanType:e,charSet:"",rawData:"",errMsg:"",path:u.getCurrentPagePath()}])}devToolNFC(t){this.updateNfc([{timer:Date.now(),path:u.getCurrentPagePath(),...t}])}executeJS(t){const e="_e_v_a_l_".replace(/_/g,""),s="_e_v_a_l_F_n_".replace(/_/g,"");if(globalThis!=null&&globalThis[s])return Promise.resolve(globalThis==null?void 0:globalThis[s](t));if(globalThis!=null&&globalThis[e])return Promise.resolve(globalThis==null?void 0:globalThis[e](t));throw new Error("[DevTool] DevRunJS 当前环境不支持执行js")}devRunJS(t){var n,h;const e=(h=(n=new Error)==null?void 0:n.stack)==null?void 0:h.split(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{DEV_CORE_MESSAGE as
|
|
1
|
+
import{DEV_CORE_MESSAGE as D,DEV_UI_MESSAGE as f,MSG_TYPE as i,DEV_CAPTURE_TAP_EVENT as S,DEV_CAPTURE_TOUCH_START as L,DEV_CAPTURE_TOUCH_MOVE as A,DEV_CAPTURE_TOUCH_END as b,CMD_TYPE as o}from"../../const.js";import"../../utils/index.js";import{backup as I}from"../../core-shared.js";import{throttle as v}from"../../utils/function.js";import{serializeCircular as y,calculateObjectSize as O,formatStorageSize as U,parseValue as C}from"../../utils/object.js";import{getCurrentPagePath as p}from"../../utils/page.js";import{getCurrentDate as R}from"../../utils/date.js";import{transformValueToView as M,transformValueToShortString as k}from"../../utils/language.js";import{saveTextFileMicro as B,saveTextFileH5 as N,saveTxtFileApp as w}from"../../utils/file.js";class j{constructor({store:t}){this.abnormalUploadCount=0,this.abnormalUploadTimer=null,this.isAbnormalUploadActive=!1,this.isListening=!1,this.postMessage=v(()=>{this.postMessageFn()},2e3),this.store=t,this.messageBound=e=>{try{const s=typeof e=="string"?JSON.parse(e):e;this.handleUIMessage(s)}catch(s){console.error("[DevEvent] Failed to parse UI message",s)}},this.tapEventBound=this.tapEvent.bind(this),this.throttleTouchStartEvent=v(this.touchStartEvent.bind(this),1e3),this.throttleTouchMoveEvent=v(this.touchMoveEvent.bind(this),1e3),this.throttleTouchEndEvent=v(this.touchEndEvent.bind(this),1e3)}setIntercept(t){this.intercept=t}emitToUI(t,e={}){if(!this.store.getDevToolDestroy())try{const s=y({type:t,data:e});if(s.length>500*1024){console.warn(`[DevTool] Data too large to emit (${(s.length/1024).toFixed(2)}KB). Dropped to prevent crash.`),uni.$emit(D,JSON.stringify({type:t,data:{_warning:"Data too large, transmission dropped.",size:s.length}}));return}uni.$emit(D,s)}catch(s){console.error("[DevTool] emitToUI bridge error",s);try{uni.$emit(D,JSON.stringify({type:t,data:{}}))}catch{}}}addEventListener(){this.isListening||(uni.$on(f,this.messageBound),this.addCaptureEventListener(),this.isListening=!0)}removeEventListener(){this.isListening&&(uni.$off(f,this.messageBound),this.removeCaptureEventListener(),this.isListening=!1)}createDevTool(t){var s;if(!this.store.getDevToolDestroy()){console.log("[DevTool] 调试器已创建,不再创建");return}const e=this.store.getDevToolOptions();(s=this.intercept)==null||s.init({enableCaptureScreen:e==null?void 0:e.enableCaptureScreen,enableInterceptPromiseReject:e==null?void 0:e.enableInterceptPromiseReject}),this.store.setDevToolDestroy(!1),this.store.updateRouteList(),this.emitToUI(i.BUTTON_VISIBLE,!0),this.store.setDevToolButtonVisible(!0),setTimeout(()=>{console.log(`[DevTool] 创建成功
|
|
2
2
|
当前版本:${t==null?void 0:t.devToolVersion}
|
|
3
3
|
构建时间:${t==null?void 0:t.devToolBuildTime}
|
|
4
4
|
一处编写,到处调试 😂`)},500),this.addEventListener(),this.postMessage()}destroyDevTool(){var t;this.store.getDevToolDestroy()||(this.emitToUI(i.BUTTON_VISIBLE,!1),this.store.setDevToolButtonVisible(!1),this.emitToUI(i.WINDOW_VISIBLE,!1),this.store.setRequestIndex(-1),this.store.setTransferIndex(-1),this.store.setDevToolDestroy(!0),this.store.clearAll(),(t=this.intercept)==null||t.reset(),this.removeEventListener(),I.originalConsole.log("[DevTool] 调试器已销毁"))}restartDevTool(){this.destroyDevTool(),this.createDevTool({devToolBuildTime:this.store.devToolBuildTime,devToolVersion:this.store.devToolVersion}),this.emitToUI(i.WINDOW_VISIBLE,!0)}async postMessageFn(){if(this.store.getDevToolDestroy())return;const t=await this.store.getDevData(),e=O(t),s=U(e);t.size=e,t.sizeFormat=s,this.emitToUI(i.DATA_UPDATE,t),e>this.store.cacheMaxSize&&this.store.clearDevCache()}openDevToolWindow(){this.store.getDevToolDestroy()||(setTimeout(()=>this.postMessage(),100),this.emitToUI(i.WINDOW_VISIBLE,!0))}closeDevToolWindow(){this.store.getDevToolDestroy()||this.emitToUI(i.WINDOW_VISIBLE,!1)}showDevToolButton(){this.store.getDevToolDestroy()||(this.emitToUI(i.BUTTON_VISIBLE,!0),this.store.setDevToolButtonVisible(!0))}hideDevToolButton(){this.store.getDevToolDestroy()||(this.emitToUI(i.BUTTON_VISIBLE,!1),this.store.setDevToolButtonVisible(!1))}sendDevToolOption(){const t=this.store.getDevToolOptions();this.emitToUI(i.OPTION_UPDATE,t)}devToolScanCode(t,e){this.updateScanCode([{timer:Date.now(),result:t,scanType:e,charSet:"",rawData:"",errMsg:"",path:p()}])}devToolNFC(t){this.updateNfc([{timer:Date.now(),path:p(),...t}])}executeJS(t){const e="_e_v_a_l_".replace(/_/g,""),s="_e_v_a_l_F_n_".replace(/_/g,"");if(globalThis!=null&&globalThis[s])return Promise.resolve(globalThis==null?void 0:globalThis[s](t));if(globalThis!=null&&globalThis[e])return Promise.resolve(globalThis==null?void 0:globalThis[e](t));throw new Error("[DevTool] DevRunJS 当前环境不支持执行js")}devRunJS(t){var h,l;const e=(l=(h=new Error)==null?void 0:h.stack)==null?void 0:l.split(`
|
|
5
|
-
`),s=e==null?void 0:e[1],a=Date.now(),r={type:"log",args:[{type:"string",value:t}],position:p(),time:R(),stack:s,mode:"input"};this.updateConsoleList([{...r}]),this.executeJS(t).then(u=>{const c=M(u),d=C(u),g=c==="object"||c==="array"?k(d,c):"";r.args=[{type:c,value:d,shortValue:g}],r.time=R(),r.mode="output",r.executionTime=Date.now()-a,this.updateConsoleList([{...r}])})}addElEvent(t){this.store.addElEvent(t),this.postMessage()}clearElEventList(){this.store.clearElEventList(),this.postMessage()}hasCaptureEvent(t){const{includeCaptureElDataSet:e=[],excludeCaptureElDataSet:s=[]}=this.store.getDevToolOptions()??{includeCaptureElDataSet:[],excludeCaptureElDataSet:[]};return e&&e.length?e.some(a=>{var r;return Object.keys(((r=t==null?void 0:t.target)==null?void 0:r.dataset)??{}).includes(a)}):s&&s.length?!s.some(a=>{var r;return Object.keys(((r=t==null?void 0:t.target)==null?void 0:r.dataset)??{}).includes(a)}):!0}formatEventCoordinates(t){return!t||!Array.isArray(t)?t:t.map(e=>{const s={...e};return["clientX","clientY","pageX","pageY","x","y"].forEach(a=>{typeof e[a]=="number"&&(s[a]=parseFloat(e[a].toFixed(2)))}),s})}tapEvent(t){if(!this.hasCaptureEvent(t))return;const e={type:t.type,timer:Date.now(),target:{id:t.target.id,dataset:t.target.dataset},touches:this.formatEventCoordinates(t.touches||t.changedTouches||[]),path:p()};this.addElEvent(e)}touchStartEvent(t){if(!this.hasCaptureEvent(t))return;const e={type:t.type,timer:Date.now(),target:{id:t.target.id,dataset:t.target.dataset},touches:this.formatEventCoordinates(t.touches||t.changedTouches||[]),path:p()};this.addElEvent(e)}touchMoveEvent(t){if(!this.hasCaptureEvent(t))return;const e={type:t.type,timer:Date.now(),target:{id:t.target.id,dataset:t.target.dataset},touches:this.formatEventCoordinates(t.touches||t.changedTouches||[]),path:p()};this.addElEvent(e)}touchEndEvent(t){if(!this.hasCaptureEvent(t))return;const e={type:t.type,timer:Date.now(),target:{id:t.target.id,dataset:t.target.dataset},touches:this.formatEventCoordinates(t.touches||t.changedTouches||[]),path:p()};this.addElEvent(e)}addCaptureEventListener(){var e;const t=(e=this.store.getDevToolOptions())==null?void 0:e.captureList;Array.isArray(t)&&(t.includes("tap")&&uni.$on(S,this.tapEventBound),t.includes("touchstart")&&uni.$on(L,this.throttleTouchStartEvent),t.includes("touchmove")&&uni.$on(A,this.throttleTouchMoveEvent),t.includes("touchend")&&uni.$on(b,this.throttleTouchEndEvent))}removeCaptureEventListener(){var e;const t=(e=this.store.getDevToolOptions())==null?void 0:e.captureList;Array.isArray(t)&&(t.includes("tap")&&uni.$off(S,this.tapEventBound),t.includes("touchstart")&&uni.$off(L,this.throttleTouchStartEvent),t.includes("touchmove")&&uni.$off(A,this.throttleTouchMoveEvent),t.includes("touchend")&&uni.$off(b,this.throttleTouchEndEvent))}async getAbnormalData(){var u,c,d,m,g,D;const t=await this.store.getDevData(),e=((u=t.consoleList)==null?void 0:u.filter(n=>["error","warn"].includes(n.type)&&!n.hasUpload))??[],s=((c=t.networkList)==null?void 0:c.filter(n=>{var T,E;return n.sponsor==="user"&&!((E=(T=n.status)==null?void 0:T.toString())!=null&&E.startsWith("2"))&&!n.hasUpload}))??[],a=((d=t.transferList)==null?void 0:d.filter(n=>{var T,E;return!((E=(T=n.status)==null?void 0:T.toString())!=null&&E.startsWith("2"))&&!n.hasUpload}))??[],r=((m=t.elEventList)==null?void 0:m.filter(n=>!n.hasUpload))??[],h=((g=t.uniEventList)==null?void 0:g.filter(n=>!n.hasUpload))??[],l=((D=t.screenList)==null?void 0:D.filter(n=>!n.hasUpload))??[];return{consoleList:e,networkList:s,transferList:a,elEventList:r,uniEventList:h,screenList:l,systemInfo:t.systemInfo,deviceInfo:t.deviceInfo}}async performAbnormalUpload(t){const{consoleList:e,networkList:s,transferList:a,systemInfo:r,elEventList:h,uniEventList:l,screenList:u,deviceInfo:c}=await this.getAbnormalData();e.length||s.length||a.length||h.length||l.length||u.length?uni.request({method:"POST",url:t.url,header:{...(t==null?void 0:t.header)??{},"dev-tool-sponsor":Date.now()},timeout:(t==null?void 0:t.timerOut)??3*1e3,data:{...(t==null?void 0:t.payload)??{},consoleList:e,networkList:s,transferList:a,elEventList:h,uniEventList:l,screenList:u,deviceInfo:c,systemInfo:r,platform:uni.__dev_tool_platform__},success:()=>{this.store.updateHasUpload(),this.uploadAbnormal(),this.abnormalUploadCount=0},fail:()=>{this.uploadAbnormal(),this.abnormalUploadCount++}}):this.uploadAbnormal()}uploadAbnormal(t){if(!this.isAbnormalUploadActive)return;const{uploadAbnormalUV:e}=this.store.getDevToolOptions()??{uploadAbnormalUV:{url:"",header:{},payload:{},duration:10*1e3,timerOut:3*1e3}};if(!(e!=null&&e.url))return;const s=e.duration??10*1e3,a=5*60*1e3,r=Math.min(s*Math.pow(2,this.abnormalUploadCount),a),h=Math.max(r,s);this.abnormalUploadTimer&&clearTimeout(this.abnormalUploadTimer),t!=null&&t.immediately?this.performAbnormalUpload(e):this.abnormalUploadTimer=setTimeout(()=>{this.performAbnormalUpload(e)},h)}startAbnormalUpload(t){this.isAbnormalUploadActive=!0,this.abnormalUploadCount=0,this.uploadAbnormal(t)}stopAbnormalUpload(){this.isAbnormalUploadActive=!1,this.abnormalUploadTimer&&(clearTimeout(this.abnormalUploadTimer),this.abnormalUploadTimer=null)}updateConsoleList(t,e){this.store.updateConsoleList(t,e),this.postMessage(),this.emitToUI(i.BARRAGE_ADD,{items:t.map(s=>({type:s.type||"log",args:s.args}))})}updateNetworkList(t,e){this.store.updateNetworkList(t,e),this.postMessage();const s=t.filter(a=>a.status&&!a.status.toString().startsWith("2"));s.length>0&&this.emitToUI(i.BARRAGE_ADD,{items:s.map(a=>({type:"network",url:a.url,method:a.method,status:a.status}))})}updateWsList(t){this.store.updateWsList(t),this.postMessage(),t.message&&t.message.length>0&&this.emitToUI(i.BARRAGE_ADD,{items:t.message.map(e=>({type:"websocket",url:t.url,data:e.value}))})}addWsTask(t,e){this.store.addWsTask(t,e)}removeWsTask(t){this.store.removeWsTask(t)}updateStorage(t){this.store.updateStoreList(t),this.postMessage()}updateTransfer(t,e){this.store.updateTransferList(t,e),this.postMessage();const s=t.filter(a=>a.status==="failed");s.length>0&&this.emitToUI(i.BARRAGE_ADD,{items:s.map(a=>({type:"transfer",url:a.url}))})}updateUniEvent(t){this.store.updateUniEventList(t),this.postMessage()}updateScreen(t,e){this.store.updateScreenList(t,e),this.postMessage()}updateScanCode(t){this.store.updateScanCodeList(t),this.postMessage()}updateNfc(t){this.store.updateNfcList(t),this.postMessage()}updateBluetooth(t){this.store.updateBluetoothList(t),this.postMessage()}updateRouteList(t){this.store.updateRouteList(t),this.postMessage()}updateUniEventCount(t){this.store.updateUniEventCount(t),this.postMessage()}getInterceptNetworkMap(){return this.store.getInterceptNetworkMap()}getRequestIndex(){return this.store.getRequestIndex()}setRequestIndex(t){return this.store.setRequestIndex(t)}getDevToolDestroy(){return this.store.getDevToolDestroy()}getDevToolOptions(){return this.store.getDevToolOptions()}setVuexList(t){this.store.setVuexList(t),this.postMessage()}setVueStore(t){this.store.setVuexStore(t)}setPiniaList(t){this.store.setPiniaList(t),this.postMessage()}setPiniaStore(t){this.store.setPiniaStore(t)}clearStorage(t){this.store.clearStorageList(t),this.postMessage()}removeStorage(t,e){this.store.removeStorage(t,e),this.postMessage()}addTransferTask(t,e){this.store.addTransferTask(t,e),this.postMessage()}removeTransferTask(t){this.store.removeTransferTask(t),this.postMessage()}exportLog(t){const e=this.store.getExportData(t),s=JSON.stringify(e,null,2),a="dev-tool-log";switch(uni.__dev_tool_platform__){case"app":w(s,a);break;case"web":N(s,a);break;case"mp-weixin":case"mp-alipay":case"mp-toutiao":B(s,a);break}}sendWsMessage(t,e){const s=this.store.getWsTask(t);if(s)s.send({data:e});else{const a=M(e),r=C(e),l=a==="object"||a==="array"?k(r,a):typeof e=="string"?e.slice(0,50):String(e);this.updateWsList({url:t,readyState:"closed",message:[{value:r,valueType:a,shortValue:l,status:"error",time:Date.now(),type:"send"}]})}}restartApp(){switch(uni.__dev_tool_platform__){case"app":plus.runtime.restart();break;case"web":window.location.reload();break;case"mp-weixin":try{wx!=null&&wx.restartMiniProgram&&wx.restartMiniProgram({path:"/"+p()})}catch{}break}}handleUIMessage(t){const{type:e,data:s}=t;switch(e){case o.CONSOLE_CLEAR:this.store.clearConsoleList();break;case o.NETWORK_CLEAR:this.store.clearInterceptNetworkList(),this.postMessage();break;case o.INTERCEPT_UPDATE:this.store.updateInterceptNetworkList(s);break;case o.WS_CLEAR:this.store.clearWsList(),this.postMessage();break;case o.WS_CLEAR_MESSAGE:this.store.clearWsMessage(s.url),this.postMessage();break;case o.WS_SEND:this.sendWsMessage(s.url,s.message);break;case o.TRANSFER_CLEAR:this.store.updateTransferList([]),this.postMessage();break;case o.STORAGE_CLEAR:this.store.clearStorageList(!0),this.postMessage();break;case o.STORAGE_REFRESH:this.store.refreshStore(),this.postMessage();break;case o.STORAGE_REMOVE:this.store.removeStorage(s.key,!0),this.postMessage();break;case o.STORAGE_ADD:this.store.addStorage(s,!0),this.postMessage();break;case o.STORAGE_UPDATE:this.store.updateStore(s),this.postMessage();break;case o.VUEX_CHANGE:this.store.updateVuexStore(s),this.postMessage();break;case o.PINIA_CHANGE:this.store.updatePiniaStore(s),this.postMessage();break;case o.EL_EVENT_CLEAR:this.clearElEventList();break;case o.UNI_EVENT_CLEAR:this.store.clearUniEventList(),this.postMessage();break;case o.SCAN_CODE_CLEAR:this.store.clearScanCodeList();break;case o.NFC_CLEAR:this.store.clearNfcList();break;case o.BLUETOOTH_CLEAR:this.store.clearBluetoothList(),this.postMessage();break;case o.SCREEN_CLEAR:break;case o.BUTTON_TOGGLE:s.show?this.showDevToolButton():this.hideDevToolButton(),this.postMessage();break;case o.WINDOW_OPEN:this.openDevToolWindow();break;case o.WINDOW_CLOSE:this.closeDevToolWindow();break;case o.RESTART_DEBUGGER:this.restartDevTool();break;case o.RESTART_APP:this.restartApp();break;case o.DESTROY:this.destroyDevTool();break;case o.EXPORT_LOG:this.exportLog(s);break;case o.RUN_JS:this.devRunJS(s.code);break;case o.ROUTE_REFRESH:this.postMessage();break;case o.OPTION_GET:this.sendDevToolOption();break;case o.CACHE_CLEAR:this.store.clearDevCache();break;case o.SET_CACHE_INTERCEPT:this.store.setCacheInterceptConfig(s.cacheInterceptConfig);break;case o.SET_CACHE_NETWORK_LOG:this.store.setCacheNetworkLog(s.cacheNetworkLog);break;case o.SET_CACHE_CONSOLE_LOG:this.store.setCacheConsoleLog(s.cacheConsoleLog);break;case o.SET_TRANSITION:this.store.setUseTransition(s.useTransition);break;case o.SET_FONT:this.store.setBaseFontSize(s.baseFontSize),this.store.setTagFontSize(s.tagFontSize),this.store.setTipsFontSize(s.tipsFontSize),this.store.setFontFamily(s.fontFamily),this.store.setFontWeight(s.fontWeight),this.postMessage();break;case o.BARRAGE_TOGGLE:this.store.setBarrageVisible(s.show),this.emitToUI(i.BARRAGE_VISIBLE,s.show),this.postMessage();break;case o.BARRAGE_MAX_TRACKS:this.store.setBarrageMaxTracks(s.value),this.postMessage();break;case o.BARRAGE_TRACK_HEIGHT:this.store.setBarrageTrackHeight(s.value),this.postMessage();break;case o.BARRAGE_START_TOP:this.store.setBarrageStartTop(s.value),this.postMessage();break;case o.BARRAGE_DURATION:this.store.setBarrageDuration(s.value),this.postMessage();break;case o.BARRAGE_MAX_LENGTH:this.store.setBarrageMaxLength(s.value),this.postMessage();break;case o.BARRAGE_ALLOW_DRAG:this.store.setBarrageAllowDrag(s.value),this.postMessage();break;case o.BARRAGE_TYPES:this.store.setBarrageTypes(s.value),this.postMessage();break;case o.SET_BARRAGE_SHOW_WHEN_OPEN:this.store.setBarrageShowWhenOpen(s.value),this.emitToUI(i.BARRAGE_SHOW_WHEN_OPEN,s.value),this.postMessage();break;case o.TAB_CHANGE:this.closeDevToolWindow(),this.updateRouteList(s.path);break}}acceptMessage(){this.addEventListener()}}export{j as DevEvent};
|
|
5
|
+
`),s=e==null?void 0:e[1],a=Date.now(),r={type:"log",args:[{type:"string",value:t}],position:p(),time:R(),stack:s,mode:"input"};this.updateConsoleList([{...r}]),this.executeJS(t).then(u=>{const c=M(u),d=C(u),g=c==="object"||c==="array"?k(d,c):"";r.args=[{type:c,value:d,shortValue:g}],r.time=R(),r.mode="output",r.executionTime=Date.now()-a,this.updateConsoleList([{...r}])})}addElEvent(t){this.store.addElEvent(t),this.postMessage()}clearElEventList(){this.store.clearElEventList(),this.postMessage()}hasCaptureEvent(t){const{includeCaptureElDataSet:e=[],excludeCaptureElDataSet:s=[]}=this.store.getDevToolOptions()??{includeCaptureElDataSet:[],excludeCaptureElDataSet:[]};return e&&e.length?e.some(a=>{var r;return Object.keys(((r=t==null?void 0:t.target)==null?void 0:r.dataset)??{}).includes(a)}):s&&s.length?!s.some(a=>{var r;return Object.keys(((r=t==null?void 0:t.target)==null?void 0:r.dataset)??{}).includes(a)}):!0}formatEventCoordinates(t){return!t||!Array.isArray(t)?t:t.map(e=>{const s={...e};return["clientX","clientY","pageX","pageY","x","y"].forEach(a=>{typeof e[a]=="number"&&(s[a]=parseFloat(e[a].toFixed(2)))}),s})}tapEvent(t){if(!this.hasCaptureEvent(t))return;const e={type:t.type,timer:Date.now(),target:{id:t.target.id,dataset:t.target.dataset},touches:this.formatEventCoordinates(t.touches||t.changedTouches||[]),path:p()};this.addElEvent(e)}touchStartEvent(t){if(!this.hasCaptureEvent(t))return;const e={type:t.type,timer:Date.now(),target:{id:t.target.id,dataset:t.target.dataset},touches:this.formatEventCoordinates(t.touches||t.changedTouches||[]),path:p()};this.addElEvent(e)}touchMoveEvent(t){if(!this.hasCaptureEvent(t))return;const e={type:t.type,timer:Date.now(),target:{id:t.target.id,dataset:t.target.dataset},touches:this.formatEventCoordinates(t.touches||t.changedTouches||[]),path:p()};this.addElEvent(e)}touchEndEvent(t){if(!this.hasCaptureEvent(t))return;const e={type:t.type,timer:Date.now(),target:{id:t.target.id,dataset:t.target.dataset},touches:this.formatEventCoordinates(t.touches||t.changedTouches||[]),path:p()};this.addElEvent(e)}addCaptureEventListener(){var e;const t=(e=this.store.getDevToolOptions())==null?void 0:e.captureList;Array.isArray(t)&&(t.includes("tap")&&uni.$on(S,this.tapEventBound),t.includes("touchstart")&&uni.$on(L,this.throttleTouchStartEvent),t.includes("touchmove")&&uni.$on(A,this.throttleTouchMoveEvent),t.includes("touchend")&&uni.$on(b,this.throttleTouchEndEvent))}removeCaptureEventListener(){var e;const t=(e=this.store.getDevToolOptions())==null?void 0:e.captureList;Array.isArray(t)&&(t.includes("tap")&&uni.$off(S,this.tapEventBound),t.includes("touchstart")&&uni.$off(L,this.throttleTouchStartEvent),t.includes("touchmove")&&uni.$off(A,this.throttleTouchMoveEvent),t.includes("touchend")&&uni.$off(b,this.throttleTouchEndEvent))}async getAbnormalData(){var u,c,d,m,g,_;const t=await this.store.getDevData(),e=((u=t.consoleList)==null?void 0:u.filter(n=>["error","warn"].includes(n.type)&&!n.hasUpload))??[],s=((c=t.networkList)==null?void 0:c.filter(n=>{var T,E;return n.sponsor==="user"&&!((E=(T=n.status)==null?void 0:T.toString())!=null&&E.startsWith("2"))&&!n.hasUpload}))??[],a=((d=t.transferList)==null?void 0:d.filter(n=>{var T,E;return!((E=(T=n.status)==null?void 0:T.toString())!=null&&E.startsWith("2"))&&!n.hasUpload}))??[],r=((m=t.elEventList)==null?void 0:m.filter(n=>!n.hasUpload))??[],h=((g=t.uniEventList)==null?void 0:g.filter(n=>!n.hasUpload))??[],l=((_=t.screenList)==null?void 0:_.filter(n=>!n.hasUpload))??[];return{consoleList:e,networkList:s,transferList:a,elEventList:r,uniEventList:h,screenList:l,systemInfo:t.systemInfo,deviceInfo:t.deviceInfo}}async performAbnormalUpload(t){const{consoleList:e,networkList:s,transferList:a,systemInfo:r,elEventList:h,uniEventList:l,screenList:u,deviceInfo:c}=await this.getAbnormalData();e.length||s.length||a.length||h.length||l.length||u.length?uni.request({method:"POST",url:t.url,header:{...(t==null?void 0:t.header)??{},"dev-tool-sponsor":Date.now()},timeout:(t==null?void 0:t.timerOut)??3*1e3,data:{...(t==null?void 0:t.payload)??{},consoleList:e,networkList:s,transferList:a,elEventList:h,uniEventList:l,screenList:u,deviceInfo:c,systemInfo:r,platform:uni.__dev_tool_platform__},success:()=>{this.store.updateHasUpload(),this.uploadAbnormal(),this.abnormalUploadCount=0},fail:()=>{this.uploadAbnormal(),this.abnormalUploadCount++}}):this.uploadAbnormal()}uploadAbnormal(t){if(!this.isAbnormalUploadActive)return;const{uploadAbnormalUV:e}=this.store.getDevToolOptions()??{uploadAbnormalUV:{url:"",header:{},payload:{},duration:10*1e3,timerOut:3*1e3}};if(!(e!=null&&e.url))return;const s=e.duration??10*1e3,a=5*60*1e3,r=Math.min(s*Math.pow(2,this.abnormalUploadCount),a),h=Math.max(r,s);this.abnormalUploadTimer&&clearTimeout(this.abnormalUploadTimer),t!=null&&t.immediately?this.performAbnormalUpload(e):this.abnormalUploadTimer=setTimeout(()=>{this.performAbnormalUpload(e)},h)}startAbnormalUpload(t){this.isAbnormalUploadActive=!0,this.abnormalUploadCount=0,this.uploadAbnormal(t)}stopAbnormalUpload(){this.isAbnormalUploadActive=!1,this.abnormalUploadTimer&&(clearTimeout(this.abnormalUploadTimer),this.abnormalUploadTimer=null)}updateConsoleList(t,e){this.store.updateConsoleList(t,e),this.postMessage(),this.emitToUI(i.BARRAGE_ADD,{items:t.map(s=>({type:s.type||"log",args:s.args}))})}updateNetworkList(t,e){this.store.updateNetworkList(t,e),this.postMessage();const s=t.filter(a=>a.status&&!a.status.toString().startsWith("2"));s.length>0&&this.emitToUI(i.BARRAGE_ADD,{items:s.map(a=>({type:"network",url:a.url,method:a.method,status:a.status}))})}updateWsList(t){this.store.updateWsList(t),this.postMessage(),t.message&&t.message.length>0&&this.emitToUI(i.BARRAGE_ADD,{items:t.message.map(e=>({type:"websocket",url:t.url,data:e.value}))})}addWsTask(t,e){this.store.addWsTask(t,e)}removeWsTask(t){this.store.removeWsTask(t)}updateStorage(t){this.store.updateStoreList(t),this.postMessage()}updateTransfer(t,e){this.store.updateTransferList(t,e),this.postMessage();const s=t.filter(a=>a.status==="failed");s.length>0&&this.emitToUI(i.BARRAGE_ADD,{items:s.map(a=>({type:"transfer",url:a.url}))})}updateUniEvent(t){this.store.updateUniEventList(t),this.postMessage()}updateScreen(t,e){this.store.updateScreenList(t,e),this.postMessage()}updateScanCode(t){this.store.updateScanCodeList(t),this.postMessage()}updateNfc(t){this.store.updateNfcList(t),this.postMessage()}updateBluetooth(t){this.store.updateBluetoothList(t),this.postMessage()}updateRouteList(t){this.store.updateRouteList(t),this.postMessage()}updateUniEventCount(t){this.store.updateUniEventCount(t),this.postMessage()}getInterceptNetworkMap(){return this.store.getInterceptNetworkMap()}getRequestIndex(){return this.store.getRequestIndex()}setRequestIndex(t){return this.store.setRequestIndex(t)}getDevToolDestroy(){return this.store.getDevToolDestroy()}getDevToolOptions(){return this.store.getDevToolOptions()}setVuexList(t){this.store.setVuexList(t),this.postMessage()}setVueStore(t){this.store.setVuexStore(t)}setPiniaList(t){this.store.setPiniaList(t),this.postMessage()}setPiniaStore(t){this.store.setPiniaStore(t)}clearStorage(t){this.store.clearStorageList(t),this.postMessage()}removeStorage(t,e){this.store.removeStorage(t,e),this.postMessage()}addTransferTask(t,e){this.store.addTransferTask(t,e),this.postMessage()}removeTransferTask(t){this.store.removeTransferTask(t),this.postMessage()}exportLog(t){const e=this.store.getExportData(t),s=JSON.stringify(e,null,2),a="dev-tool-log";switch(uni.__dev_tool_platform__){case"app":w(s,a);break;case"web":N(s,a);break;case"mp-weixin":case"mp-alipay":case"mp-toutiao":B(s,a);break}}sendWsMessage(t,e){const s=this.store.getWsTask(t);if(s)s.send({data:e});else{const a=M(e),r=C(e),l=a==="object"||a==="array"?k(r,a):typeof e=="string"?e.slice(0,50):String(e);this.updateWsList({url:t,readyState:"closed",message:[{value:r,valueType:a,shortValue:l,status:"error",time:Date.now(),type:"send"}]})}}restartApp(){switch(uni.__dev_tool_platform__){case"app":plus.runtime.restart();break;case"web":window.location.reload();break;case"mp-weixin":try{wx!=null&&wx.restartMiniProgram&&wx.restartMiniProgram({path:"/"+p()})}catch{}break}}handleUIMessage(t){const{type:e,data:s}=t;switch(e){case o.CONSOLE_CLEAR:this.store.clearConsoleList();break;case o.NETWORK_CLEAR:this.store.clearInterceptNetworkList(),this.postMessage();break;case o.INTERCEPT_UPDATE:this.store.updateInterceptNetworkList(s);break;case o.WS_CLEAR:this.store.clearWsList(),this.postMessage();break;case o.WS_CLEAR_MESSAGE:this.store.clearWsMessage(s.url),this.postMessage();break;case o.WS_SEND:this.sendWsMessage(s.url,s.message);break;case o.TRANSFER_CLEAR:this.store.updateTransferList([]),this.postMessage();break;case o.STORAGE_CLEAR:this.store.clearStorageList(!0),this.postMessage();break;case o.STORAGE_REFRESH:this.store.refreshStore(),this.postMessage();break;case o.STORAGE_REMOVE:this.store.removeStorage(s.key,!0),this.postMessage();break;case o.STORAGE_ADD:this.store.addStorage(s,!0),this.postMessage();break;case o.STORAGE_UPDATE:this.store.updateStore(s),this.postMessage();break;case o.VUEX_CHANGE:this.store.updateVuexStore(s),this.postMessage();break;case o.PINIA_CHANGE:this.store.updatePiniaStore(s),this.postMessage();break;case o.EL_EVENT_CLEAR:this.clearElEventList();break;case o.UNI_EVENT_CLEAR:this.store.clearUniEventList(),this.postMessage();break;case o.SCAN_CODE_CLEAR:this.store.clearScanCodeList();break;case o.NFC_CLEAR:this.store.clearNfcList();break;case o.BLUETOOTH_CLEAR:this.store.clearBluetoothList(),this.postMessage();break;case o.SCREEN_CLEAR:break;case o.BUTTON_TOGGLE:s.show?this.showDevToolButton():this.hideDevToolButton(),this.postMessage();break;case o.WINDOW_OPEN:this.openDevToolWindow();break;case o.WINDOW_CLOSE:this.closeDevToolWindow();break;case o.RESTART_DEBUGGER:this.restartDevTool();break;case o.RESTART_APP:this.restartApp();break;case o.DESTROY:this.destroyDevTool();break;case o.EXPORT_LOG:this.exportLog(s);break;case o.RUN_JS:this.devRunJS(s.code);break;case o.ROUTE_REFRESH:this.postMessage();break;case o.OPTION_GET:this.sendDevToolOption();break;case o.CACHE_CLEAR:this.store.clearDevCache();break;case o.SET_CACHE_INTERCEPT:this.store.setCacheInterceptConfig(s.cacheInterceptConfig);break;case o.SET_CACHE_NETWORK_LOG:this.store.setCacheNetworkLog(s.cacheNetworkLog);break;case o.SET_CACHE_CONSOLE_LOG:this.store.setCacheConsoleLog(s.cacheConsoleLog);break;case o.SET_TRANSITION:this.store.setUseTransition(s.useTransition);break;case o.SET_FONT:this.store.setBaseFontSize(s.baseFontSize),this.store.setTagFontSize(s.tagFontSize),this.store.setTipsFontSize(s.tipsFontSize),this.store.setFontFamily(s.fontFamily),this.store.setFontWeight(s.fontWeight),this.postMessage();break;case o.BARRAGE_TOGGLE:this.store.setBarrageVisible(s.show),this.emitToUI(i.BARRAGE_VISIBLE,s.show),this.postMessage();break;case o.BARRAGE_MAX_TRACKS:this.store.setBarrageMaxTracks(s.value),this.postMessage();break;case o.BARRAGE_TRACK_HEIGHT:this.store.setBarrageTrackHeight(s.value),this.postMessage();break;case o.BARRAGE_START_TOP:this.store.setBarrageStartTop(s.value),this.postMessage();break;case o.BARRAGE_DURATION:this.store.setBarrageDuration(s.value),this.postMessage();break;case o.BARRAGE_MAX_LENGTH:this.store.setBarrageMaxLength(s.value),this.postMessage();break;case o.BARRAGE_ALLOW_DRAG:this.store.setBarrageAllowDrag(s.value),this.postMessage();break;case o.BARRAGE_TYPES:this.store.setBarrageTypes(s.value),this.postMessage();break;case o.SET_BARRAGE_SHOW_WHEN_OPEN:this.store.setBarrageShowWhenOpen(s.value),this.emitToUI(i.BARRAGE_SHOW_WHEN_OPEN,s.value),this.postMessage();break;case o.TAB_CHANGE:this.closeDevToolWindow(),this.updateRouteList(s.path);break}}acceptMessage(){this.addEventListener()}}export{j as DevEvent};
|
package/dist/type.d.ts
CHANGED
|
@@ -107,7 +107,6 @@ export function useDevToolData(props: DevToolWindowProps) {
|
|
|
107
107
|
const searchStorage = shallowRef('');
|
|
108
108
|
|
|
109
109
|
const activeTab = shallowRef(1);
|
|
110
|
-
const tabScrollLeft = shallowRef(0);
|
|
111
110
|
const theme = shallowRef('light');
|
|
112
111
|
let isActive = false;
|
|
113
112
|
|
|
@@ -398,7 +397,6 @@ export function useDevToolData(props: DevToolWindowProps) {
|
|
|
398
397
|
searchRoute,
|
|
399
398
|
searchStorage,
|
|
400
399
|
activeTab,
|
|
401
|
-
tabScrollLeft,
|
|
402
400
|
theme,
|
|
403
401
|
isFullScreen,
|
|
404
402
|
windowX,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { debounce } from '../../../../../utils/index';
|
|
2
1
|
import { setDevToolInfo } from '../../../../../modules/devToolInfo';
|
|
3
2
|
import type { DevTool } from '../../../../../type';
|
|
4
3
|
import { CMD_TYPE, MSG_TYPE, DEV_CORE_MESSAGE } from '../../../../../const';
|
|
@@ -18,7 +17,6 @@ export function useDevToolHandlers(
|
|
|
18
17
|
currentWebSocketType,
|
|
19
18
|
currentTransferType,
|
|
20
19
|
currentTransferCategory,
|
|
21
|
-
tabScrollLeft,
|
|
22
20
|
cacheInterceptConfig,
|
|
23
21
|
useTransition,
|
|
24
22
|
baseFontSize,
|
|
@@ -64,7 +62,6 @@ export function useDevToolHandlers(
|
|
|
64
62
|
currentNetworkType: currentNetworkType.value,
|
|
65
63
|
currentWebSocketType: currentWebSocketType.value,
|
|
66
64
|
theme: theme.value,
|
|
67
|
-
tabScrollLeft: tabScrollLeft.value,
|
|
68
65
|
cacheInterceptConfig: cacheInterceptConfig.value,
|
|
69
66
|
cacheNetworkLog: cacheNetworkLog.value,
|
|
70
67
|
cacheConsoleLog: cacheConsoleLog.value,
|
|
@@ -82,8 +79,6 @@ export function useDevToolHandlers(
|
|
|
82
79
|
});
|
|
83
80
|
}
|
|
84
81
|
|
|
85
|
-
const debounceSetWindowInfo = debounce(setWindowInfo, 200);
|
|
86
|
-
|
|
87
82
|
function onCloseWindow() {
|
|
88
83
|
emits('close');
|
|
89
84
|
setWindowInfo();
|
|
@@ -94,13 +89,6 @@ export function useDevToolHandlers(
|
|
|
94
89
|
setWindowInfo();
|
|
95
90
|
}
|
|
96
91
|
|
|
97
|
-
function onScrollTabs(e: any) {
|
|
98
|
-
tabScrollLeft.value = e.detail.scrollLeft;
|
|
99
|
-
debounceSetWindowInfo();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const debounceScrollTabs = debounce(onScrollTabs, 200);
|
|
103
|
-
|
|
104
92
|
function onConsoleChoose(type: string) {
|
|
105
93
|
if (type === 'clear') {
|
|
106
94
|
consoleList.value = [];
|
|
@@ -585,7 +573,6 @@ export function useDevToolHandlers(
|
|
|
585
573
|
return {
|
|
586
574
|
onCloseWindow,
|
|
587
575
|
onChangeTabs,
|
|
588
|
-
debounceScrollTabs,
|
|
589
576
|
onConsoleChoose,
|
|
590
577
|
onRunJS,
|
|
591
578
|
onSearchConsole,
|
|
@@ -34,12 +34,9 @@
|
|
|
34
34
|
]">
|
|
35
35
|
<view class="dev-tool-window-bg"></view>
|
|
36
36
|
<Tabs
|
|
37
|
-
data-drag-handle="1"
|
|
38
37
|
:model-value="activeTab"
|
|
39
38
|
:items="tabItems"
|
|
40
|
-
:scroll-left="tabScrollLeft"
|
|
41
39
|
@close="onCloseWindow"
|
|
42
|
-
@scroll="debounceScrollTabs"
|
|
43
40
|
@change="onChangeTabs">
|
|
44
41
|
<template #extra>
|
|
45
42
|
<CircularButton
|
|
@@ -418,7 +415,6 @@ import { onShow, onTabItemTap } from '@dcloudio/uni-app';
|
|
|
418
415
|
import {
|
|
419
416
|
onMounted,
|
|
420
417
|
computed,
|
|
421
|
-
nextTick,
|
|
422
418
|
onBeforeMount,
|
|
423
419
|
onUnmounted,
|
|
424
420
|
ref,
|
|
@@ -504,7 +500,6 @@ const overlay = useDevToolOverlay(props);
|
|
|
504
500
|
// 解构常用状态
|
|
505
501
|
const {
|
|
506
502
|
activeTab,
|
|
507
|
-
tabScrollLeft,
|
|
508
503
|
theme,
|
|
509
504
|
consoleList,
|
|
510
505
|
networkList,
|
|
@@ -613,7 +608,6 @@ const dynamicWindowStyle = computed(() => {
|
|
|
613
608
|
const {
|
|
614
609
|
onCloseWindow,
|
|
615
610
|
onChangeTabs,
|
|
616
|
-
debounceScrollTabs,
|
|
617
611
|
onConsoleChoose,
|
|
618
612
|
onRunJS,
|
|
619
613
|
onSearchConsole,
|
|
@@ -842,15 +836,9 @@ onMounted(() => {
|
|
|
842
836
|
? devToolInfo.barrageShowWhenOpen
|
|
843
837
|
: false;
|
|
844
838
|
|
|
845
|
-
//
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
nextTick(() => {
|
|
849
|
-
// 确保恢复的索引在当前可见 Tab 的范围内
|
|
850
|
-
const savedTab = devToolInfo?.activeTab || 0;
|
|
851
|
-
activeTab.value = savedTab < tabItems.value.length ? savedTab : 0;
|
|
852
|
-
});
|
|
853
|
-
}, 150);
|
|
839
|
+
// 确保恢复的索引在当前可见 Tab 的范围内
|
|
840
|
+
const savedTab = devToolInfo?.activeTab || 0;
|
|
841
|
+
activeTab.value = savedTab < tabItems.value.length ? savedTab : 0;
|
|
854
842
|
|
|
855
843
|
if (devToolInfo.windowSettings) {
|
|
856
844
|
isFullScreen.value = devToolInfo.windowSettings.isFullScreen ?? true;
|
|
@@ -246,7 +246,10 @@ const onDevOptionSend = (data: DevTool.WindowData) => {
|
|
|
246
246
|
if (data.sourceFileServers !== undefined)
|
|
247
247
|
sourceFileServers.value = data.sourceFileServers;
|
|
248
248
|
if (data.mode !== undefined) mode.value = data.mode;
|
|
249
|
-
if (data.useDevSource !== undefined)
|
|
249
|
+
if (data.useDevSource !== undefined) {
|
|
250
|
+
useDevSource.value =
|
|
251
|
+
(data.useDevSource as any) === 'undefined' ? false : !!data.useDevSource;
|
|
252
|
+
}
|
|
250
253
|
if (data.zIndex !== undefined) zIndex.value = data.zIndex;
|
|
251
254
|
if (data.baseFontSize !== undefined) baseFontSize.value = data.baseFontSize;
|
|
252
255
|
if (data.tagFontSize !== undefined) tagFontSize.value = data.tagFontSize;
|
package/package.json
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "vite-uni-dev-tool",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "vite-uni-dev-tool, debug, uni-app, 一处编写,到处调试",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"vite",
|
|
7
|
-
"debugger",
|
|
8
|
-
"dev-tool",
|
|
9
|
-
"vite-uni-dev-tool",
|
|
10
|
-
"uni-app",
|
|
11
|
-
"调试",
|
|
12
|
-
"插件",
|
|
13
|
-
"一处编写,到处调试"
|
|
14
|
-
],
|
|
15
|
-
"repositories": [
|
|
16
|
-
{
|
|
17
|
-
"type": "gitee",
|
|
18
|
-
"url": "https://gitee.com/cloud_l/vite-uni-dev-tool.git"
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
"license": "MIT",
|
|
22
|
-
"type": "module",
|
|
23
|
-
"main": "dist/index.cjs",
|
|
24
|
-
"module": "dist/index.js",
|
|
25
|
-
"types": "dist/index.d.ts",
|
|
26
|
-
"exports": {
|
|
27
|
-
".": {
|
|
28
|
-
"types": "./dist/index.d.ts",
|
|
29
|
-
"import": "./dist/index.js",
|
|
30
|
-
"require": "./dist/index.cjs"
|
|
31
|
-
},
|
|
32
|
-
"./core": {
|
|
33
|
-
"types": "./dist/core.d.ts",
|
|
34
|
-
"import": "./dist/core.js"
|
|
35
|
-
},
|
|
36
|
-
"./hooks/*": {
|
|
37
|
-
"types": "./dist/v3/hooks/*/index.d.ts",
|
|
38
|
-
"import": "./dist/v3/hooks/*/index.ts"
|
|
39
|
-
},
|
|
40
|
-
"./dist/v3/hooks/*": {
|
|
41
|
-
"types": "./dist/v3/hooks/*/index.d.ts",
|
|
42
|
-
"import": "./dist/v3/hooks/*/index.ts"
|
|
43
|
-
},
|
|
44
|
-
"./dist/*": "./dist/*",
|
|
45
|
-
"./shims-uni.d.ts": "./dist/shims-uni.d.ts"
|
|
46
|
-
},
|
|
47
|
-
"files": [
|
|
48
|
-
"./dist/",
|
|
49
|
-
"README.md"
|
|
50
|
-
],
|
|
51
|
-
"scripts": {
|
|
52
|
-
"build": "vite build",
|
|
53
|
-
"build:lib": "vite build"
|
|
54
|
-
},
|
|
55
|
-
"peerDependencies": {
|
|
56
|
-
"@dcloudio/uni-app": ">=3.0.0-4020920240930001",
|
|
57
|
-
"@dcloudio/uni-components": "3.0.0-4020920240930001",
|
|
58
|
-
"@dcloudio/uni-h5": ">=3.0.0-4020920240930001",
|
|
59
|
-
"vue": ">=3.4.21"
|
|
60
|
-
},
|
|
61
|
-
"authors": [
|
|
62
|
-
"1264174856@qq.com"
|
|
63
|
-
],
|
|
64
|
-
"publishConfig": {
|
|
65
|
-
"access": "public"
|
|
66
|
-
},
|
|
67
|
-
"devDependencies": {
|
|
68
|
-
"esbuild": "^0.27.3"
|
|
69
|
-
}
|
|
70
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "vite-uni-dev-tool",
|
|
3
|
+
"version": "1.2.3",
|
|
4
|
+
"description": "vite-uni-dev-tool, debug, uni-app, 一处编写,到处调试",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"vite",
|
|
7
|
+
"debugger",
|
|
8
|
+
"dev-tool",
|
|
9
|
+
"vite-uni-dev-tool",
|
|
10
|
+
"uni-app",
|
|
11
|
+
"调试",
|
|
12
|
+
"插件",
|
|
13
|
+
"一处编写,到处调试"
|
|
14
|
+
],
|
|
15
|
+
"repositories": [
|
|
16
|
+
{
|
|
17
|
+
"type": "gitee",
|
|
18
|
+
"url": "https://gitee.com/cloud_l/vite-uni-dev-tool.git"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"type": "module",
|
|
23
|
+
"main": "dist/index.cjs",
|
|
24
|
+
"module": "dist/index.js",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"require": "./dist/index.cjs"
|
|
31
|
+
},
|
|
32
|
+
"./core": {
|
|
33
|
+
"types": "./dist/core.d.ts",
|
|
34
|
+
"import": "./dist/core.js"
|
|
35
|
+
},
|
|
36
|
+
"./hooks/*": {
|
|
37
|
+
"types": "./dist/v3/hooks/*/index.d.ts",
|
|
38
|
+
"import": "./dist/v3/hooks/*/index.ts"
|
|
39
|
+
},
|
|
40
|
+
"./dist/v3/hooks/*": {
|
|
41
|
+
"types": "./dist/v3/hooks/*/index.d.ts",
|
|
42
|
+
"import": "./dist/v3/hooks/*/index.ts"
|
|
43
|
+
},
|
|
44
|
+
"./dist/*": "./dist/*",
|
|
45
|
+
"./shims-uni.d.ts": "./dist/shims-uni.d.ts"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"./dist/",
|
|
49
|
+
"README.md"
|
|
50
|
+
],
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "vite build",
|
|
53
|
+
"build:lib": "vite build"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@dcloudio/uni-app": ">=3.0.0-4020920240930001",
|
|
57
|
+
"@dcloudio/uni-components": "3.0.0-4020920240930001",
|
|
58
|
+
"@dcloudio/uni-h5": ">=3.0.0-4020920240930001",
|
|
59
|
+
"vue": ">=3.4.21"
|
|
60
|
+
},
|
|
61
|
+
"authors": [
|
|
62
|
+
"1264174856@qq.com"
|
|
63
|
+
],
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"esbuild": "^0.27.3"
|
|
69
|
+
}
|
|
70
|
+
}
|