vite-uni-dev-tool 1.1.0 → 1.2.0
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 +8 -0
- package/dist/const.cjs +1 -1
- package/dist/const.d.ts +1 -0
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js +1 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +2 -2
- package/dist/i18n/locales/en.cjs +1 -1
- package/dist/i18n/locales/en.d.ts +5 -0
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +1 -1
- package/dist/i18n/locales/zh-Hans.cjs +1 -1
- package/dist/i18n/locales/zh-Hans.d.ts +5 -0
- package/dist/i18n/locales/zh-Hans.d.ts.map +1 -1
- package/dist/i18n/locales/zh-Hans.js +1 -1
- package/dist/modules/devIntercept/index.cjs +9 -9
- package/dist/modules/devIntercept/index.d.ts +1 -1
- package/dist/modules/devIntercept/index.d.ts.map +1 -1
- package/dist/modules/devIntercept/index.js +9 -9
- package/dist/modules/devStore/index.cjs +1 -1
- package/dist/modules/devStore/index.d.ts.map +1 -1
- package/dist/modules/devStore/index.js +1 -1
- package/dist/plugins/uniDevTool/transform/transformMain.cjs +3 -3
- package/dist/plugins/uniDevTool/transform/transformMain.d.ts +2 -1
- package/dist/plugins/uniDevTool/transform/transformMain.d.ts.map +1 -1
- package/dist/plugins/uniDevTool/transform/transformMain.js +3 -3
- package/dist/plugins/uniDevTool/transform/transformVue.cjs +31 -25
- package/dist/plugins/uniDevTool/transform/transformVue.d.ts +2 -1
- package/dist/plugins/uniDevTool/transform/transformVue.d.ts.map +1 -1
- package/dist/plugins/uniDevTool/transform/transformVue.js +30 -24
- package/dist/plugins/uniDevTool/uniDevTool.cjs +3 -3
- package/dist/plugins/uniDevTool/uniDevTool.d.ts +3 -1
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
- package/dist/plugins/uniDevTool/uniDevTool.js +3 -3
- package/dist/type.d.ts +3 -0
- package/dist/type.d.ts.map +1 -1
- package/dist/v3/DevTool/components/BluetoothList/BluetoothItem.vue +199 -199
- package/dist/v3/DevTool/components/BluetoothList/BluetoothTool.vue +730 -730
- package/dist/v3/DevTool/components/BluetoothList/index.vue +167 -167
- package/dist/v3/DevTool/components/CaptureScreen/index.vue +109 -109
- package/dist/v3/DevTool/components/ConsoleList/ConsoleItem.vue +230 -225
- package/dist/v3/DevTool/components/ConsoleList/RunJSInput.vue +247 -247
- package/dist/v3/DevTool/components/ConsoleList/index.vue +171 -171
- package/dist/v3/DevTool/components/ConsoleList/staticTips.ts +1145 -1145
- package/dist/v3/DevTool/components/DevToolTitle/index.vue +24 -24
- package/dist/v3/DevTool/components/DevToolWindow/DevToolOverlay.vue +197 -197
- package/dist/v3/DevTool/components/DevToolWindow/hooks/dataUtils.ts +48 -48
- package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolData.ts +387 -387
- package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolHandlers.ts +629 -629
- package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolOverlay.ts +201 -197
- package/dist/v3/DevTool/components/ElEvent/ElEventItem.vue +105 -105
- package/dist/v3/DevTool/components/ElEvent/index.vue +106 -106
- package/dist/v3/DevTool/components/Instance/components/InstanceTreeNode.vue +265 -265
- package/dist/v3/DevTool/components/Instance/flatten.ts +226 -226
- package/dist/v3/DevTool/components/Instance/index.vue +94 -94
- package/dist/v3/DevTool/components/Instance/registry.ts +49 -49
- package/dist/v3/DevTool/components/Instance/transformTree.ts +375 -375
- package/dist/v3/DevTool/components/Instance/transformTreeCtx.ts +268 -268
- package/dist/v3/DevTool/components/Instance/typing.d.ts +43 -43
- package/dist/v3/DevTool/components/InstanceDetail/index.vue +485 -485
- package/dist/v3/DevTool/components/JsonDetail/index.vue +70 -70
- package/dist/v3/DevTool/components/NFCList/NFCItem.vue +112 -112
- package/dist/v3/DevTool/components/NFCList/NFCTool.vue +454 -454
- package/dist/v3/DevTool/components/NFCList/const.ts +56 -56
- package/dist/v3/DevTool/components/NFCList/index.vue +94 -94
- package/dist/v3/DevTool/components/NetworkList/InterceptConfig.vue +624 -624
- package/dist/v3/DevTool/components/NetworkList/InterceptItem.vue +140 -140
- package/dist/v3/DevTool/components/NetworkList/NetworkDetail.vue +287 -287
- package/dist/v3/DevTool/components/NetworkList/NetworkIntercept.vue +88 -88
- package/dist/v3/DevTool/components/NetworkList/NetworkItem.vue +163 -163
- package/dist/v3/DevTool/components/NetworkList/NetworkSend.vue +589 -589
- package/dist/v3/DevTool/components/NetworkList/const.ts +4 -4
- package/dist/v3/DevTool/components/NetworkList/hooks/useNetworkForm.ts +86 -86
- package/dist/v3/DevTool/components/NetworkList/index.vue +160 -160
- package/dist/v3/DevTool/components/NetworkList/utils.ts +101 -101
- package/dist/v3/DevTool/components/Performance/index.vue +498 -498
- package/dist/v3/DevTool/components/Performance/modules/PerformanceMetrics.vue +153 -153
- package/dist/v3/DevTool/components/Performance/modules/usePerformanceChart.ts +460 -460
- package/dist/v3/DevTool/components/Performance/modules/usePerformanceData.ts +258 -258
- package/dist/v3/DevTool/components/PiniaList/index.vue +93 -93
- package/dist/v3/DevTool/components/RunJS/index.vue +148 -148
- package/dist/v3/DevTool/components/ScanCodeList/ScanCodeItem.vue +97 -97
- package/dist/v3/DevTool/components/ScanCodeList/index.vue +100 -100
- package/dist/v3/DevTool/components/SettingButton/index.vue +45 -45
- package/dist/v3/DevTool/components/SettingList/index.vue +218 -218
- package/dist/v3/DevTool/components/SettingList/modules/SettingBarrage.vue +304 -304
- package/dist/v3/DevTool/components/SettingList/modules/SettingDevTool.vue +212 -212
- package/dist/v3/DevTool/components/SettingList/modules/SettingInfo.vue +157 -157
- package/dist/v3/DevTool/components/SettingList/modules/SettingLanguage.vue +74 -74
- package/dist/v3/DevTool/components/SettingList/modules/SettingLog.vue +230 -230
- package/dist/v3/DevTool/components/SettingList/typing.d.ts +2 -2
- package/dist/v3/DevTool/components/SourceCode/Line.vue +127 -127
- package/dist/v3/DevTool/components/SourceCode/parseCode.ts +609 -609
- package/dist/v3/DevTool/components/StorageList/index.vue +174 -174
- package/dist/v3/DevTool/components/TransferList/TransferDetail.vue +268 -268
- package/dist/v3/DevTool/components/VuexList/index.vue +84 -84
- package/dist/v3/DevTool/index.vue +1 -0
- package/dist/v3/components/AppTransition/index.vue +176 -176
- package/dist/v3/components/AutoSizer/index.vue +192 -192
- package/dist/v3/components/AutoSizer/index1.vue +184 -184
- package/dist/v3/components/AutoSizer/utils.ts +49 -49
- package/dist/v3/components/Barrage/BarrageItem.vue +137 -137
- package/dist/v3/components/Barrage/index.vue +202 -202
- package/dist/v3/components/CircularButton/index.vue +84 -84
- package/dist/v3/components/CustomSwiper/CustomSwiperItem.vue +49 -49
- package/dist/v3/components/CustomSwiper/index.vue +104 -104
- package/dist/v3/components/DevErrorBoundary/index.vue +380 -0
- package/dist/v3/components/Empty/index.vue +29 -29
- package/dist/v3/components/FilterSelect/index.vue +179 -179
- package/dist/v3/components/JsonPretty/components/Brackets/index.vue +27 -27
- package/dist/v3/components/JsonPretty/components/Carets/index.vue +59 -59
- package/dist/v3/components/JsonPretty/components/CheckController/index.vue +136 -136
- package/dist/v3/components/JsonPretty/components/TreeNode/index.vue +387 -387
- package/dist/v3/components/JsonPretty/hooks/useClipboard.ts +21 -21
- package/dist/v3/components/JsonPretty/hooks/useError.ts +21 -21
- package/dist/v3/components/JsonPretty/type.ts +127 -127
- package/dist/v3/components/JsonPretty/utils/index.ts +169 -169
- package/dist/v3/components/MovableContainer/index.vue +8 -4
- package/dist/v3/components/Pick/index.vue +322 -322
- package/dist/v3/components/Tag/index.vue +113 -113
- package/dist/v3/components/VirtualList/AutoSize.vue +40 -40
- package/dist/v3/components/VirtualList/index.vue +416 -416
- package/dist/v3/hooks/useBluetooth/index.ts +561 -561
- package/dist/v3/hooks/useContainerStyle.ts +153 -153
- package/dist/v3/hooks/useNFC/index.ts +107 -107
- package/dist/v3/hooks/useNFC/typing.d.ts +396 -396
- package/dist/v3/hooks/useNFC/useNFCAndroid.ts +966 -966
- package/dist/v3/hooks/useNFC/useNFCMpWeiXin.ts +812 -812
- package/dist/v3/hooks/useNFC/utils.ts +754 -754
- package/dist/v3/hooks/useRequest/index.ts +586 -586
- package/dist/v3/hooks/useRequest/utils.ts +267 -267
- package/dist/v3/hooks/useScanCode/index.ts +206 -206
- package/dist/v3/hooks/useWebsocket/index.ts +253 -253
- package/dist/v3/styles/theme.ts +12 -12
- package/package.json +9 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../core-shared.cjs"),
|
|
2
|
-
`).map(n=>n.trim()).filter(Boolean);return t.find(n=>{const s=n.toLowerCase();return s.includes("at ")&&!s.includes("devintercept")&&!s.includes("devconsole")&&!s.includes("core-shared")&&!s.includes("core.ts")})||t[0]||""}reportError({type:e="error",msg:t="",stack:r="",source:n="System",itemType:s="string"}){if(this.hooks.getDevToolDestroy()||this.isReporting)return;const c=Date.now();if(t===this.lastReportMsg&&c-this.lastReportTime<100)return;this.lastReportMsg=t,this.lastReportTime=c;const h=this.formatStack(r);this.isReporting=!0;try{const a=[];if(s==="object"||s==="array"){const u=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../core-shared.cjs"),j=require("../../const.cjs");require("../../utils/index.cjs");const R=require("../../utils/date.cjs"),I=require("../../utils/page.cjs"),w=require("../../utils/object.cjs"),T=require("../../utils/language.cjs"),M=require("../../utils/string.cjs");class B{constructor(e){this.initPinia=!1,this.isReporting=!1,this.lastReportMsg="",this.lastReportTime=0,this.captureScreen=t=>{if(!this.hooks.getDevToolDestroy()){const r=this.hooks.getScreenIndex(),n=this.hooks.setScreenIndex(r+1);this.hooks.updateScreen([{index:n,position:I.getCurrentPagePath(),startTime:R.getCurrentDate(),endTime:R.getCurrentDate(),type:"captureScreen",path:(t==null?void 0:t.path)??""}])}},this.hooks=e.hooks,typeof uni<"u"&&(uni.$on(j.DEV_TOOL_ON_INIT,t=>this.init(t)),uni.$on(j.DEV_TOOL_ON_DESTROY,()=>this.reset()))}safeDefineProperty(e,t,r){if(!e)return!1;try{const n=Object.getOwnPropertyDescriptor(e,t);return n&&n.configurable===!1?(console.warn(`[DevTool] ${t} 属性不可配置,已跳过拦截`),!1):(Object.defineProperty(e,t,{...r,configurable:!0}),!0)}catch(n){return console.warn(`[DevTool] 拦截 ${t} 失败,环境可能受限:`,n),!1}}formatStack(e){if(!e)return"";const t=e.split(`
|
|
2
|
+
`).map(n=>n.trim()).filter(Boolean);return t.find(n=>{const s=n.toLowerCase();return s.includes("at ")&&!s.includes("devintercept")&&!s.includes("devconsole")&&!s.includes("core-shared")&&!s.includes("core.ts")})||t[0]||""}reportError({type:e="error",msg:t="",stack:r="",source:n="System",itemType:s="string"}){if(this.hooks.getDevToolDestroy()||this.isReporting)return;const c=Date.now();if(t===this.lastReportMsg&&c-this.lastReportTime<100)return;this.lastReportMsg=t,this.lastReportTime=c;const h=this.formatStack(r);this.isReporting=!0;try{const a=[];if(s==="object"||s==="array"){const u=w.parseValue(t);a.push({type:s,value:u,shortValue:T.transformValueToShortString(u,s)})}else a.push({type:s,value:`[${n}] ${t}`});this.hooks.updateConsole([{type:e,args:a,position:I.getCurrentPagePath(),time:R.getCurrentDate(),stack:h}])}finally{this.isReporting=!1}}init({enableCaptureScreen:e,enableInterceptPromiseReject:t}){this.enableCaptureScreen=e,this.enableInterceptPromiseReject=t,this.interceptAppConsole(),this.interceptAppError(),this.interceptSetStorage(),this.interceptRemoveStorage(),this.interceptClearStorage(),this.interceptRequest(),this.interceptSocket(),this.interceptUploadFile(),this.interceptDownloadFile(),this.interceptSwitchTab(),this.interceptRedirectTo(),this.interceptReLaunch(),this.interceptNavigateBack(),this.interceptNavigateTo(),this.interceptUniEvent(),this.interceptScanCode(),this.enableCaptureScreen&&this.interceptCaptureScreen(),this.interceptScreenRecording(),this.enableInterceptPromiseReject&&this.interceptPromiseReject()}reset(){this.resetInterceptAppConsole(),this.resetInterceptErrorApp(),this.resetInterceptPromiseReject(),this.resetInterceptStorage(),this.resetInterceptRemoveStorage(),this.resetInterceptClearStorage(),this.resetInterceptRequest(),this.resetInterceptSocket(),this.resetInterceptUploadFile(),this.resetInterceptDownloadFile(),this.resetInterceptSwitchTab(),this.resetInterceptRedirectTo(),this.resetInterceptReLaunch(),this.resetInterceptNavigateBack(),this.resetInterceptNavigateTo(),this.resetUniEvent(),this.resetInterceptScanCode(),this.enableCaptureScreen&&this.resetInterceptCaptureScreen(),this.resetInterceptScreenRecording()}interceptAppConsole(){const e=this;uni.__log__&&this.safeDefineProperty(uni,"__log__",{writable:!1,value:function(r,n,...s){d.backup.__log__(r,n,...s);const c=I.getCurrentPagePath();e.hooks.updateConsole([{type:r,position:c,time:R.getCurrentDate(),args:s.map(h=>{const a=T.transformValueToView(h),u=w.parseValue(h),l=a==="object"||a==="array"?T.transformValueToShortString(u,a):"";return{type:a,value:u,shortValue:l}}),stack:n}])}}),["log","info","debug","error","warn","time","timeEnd","count","clear"].forEach(r=>{this.safeDefineProperty(console,r,{value:function(...n){if(["time","timeEnd","count","clear"].includes(r))return d.consoleProxy[r](...n);d.backup.originalConsole[r](...n);const s=n.map(h=>{const a=T.transformValueToView(h),u=w.parseValue(h),l=a==="object"||a==="array"?T.transformValueToShortString(u,a):"";return{type:a,value:u,shortValue:l}}),c=e.formatStack(new Error().stack||"");n.length>0&&e.hooks.updateConsole([{type:r,args:s,position:I.getCurrentPagePath(),time:R.getCurrentDate(),stack:c}])}})})}resetInterceptAppConsole(){uni.__log__&&this.safeDefineProperty(uni,"__log__",{writable:!0,value:d.backup.__log__}),["log","info","debug","error","warn","time","timeEnd","count","clear"].forEach(t=>{this.safeDefineProperty(console,t,{value:d.backup.originalConsole[t]})})}interceptVue(e){if(!e)return;const t=(n,s,c)=>{this.hooks.getDevToolDestroy()||this.interceptErrorVue(n,c)},r=(n,s,c)=>{this.hooks.getDevToolDestroy()||this.interceptWarnVue(n+`
|
|
3
3
|
`+c)};e.appContext?(e.appContext.config.errorHandler=t,e.appContext.config.warnHandler=r):(e.config.errorHandler=t,e.config.warnHandler=r)}interceptAppError(){this.onErrorHandler=e=>{var n;const t=typeof e=="string"?e:(e==null?void 0:e.message)||String(e)||"",r=(e==null?void 0:e.stack)||((n=t==null?void 0:t.split(`
|
|
4
|
-
`))==null?void 0:n[1])||"";this.reportError({msg:t,stack:r,source:"AppError"})},uni.onError(this.onErrorHandler),uni.onUnhandledRejection&&(this.onUnhandledRejectionHandler=e=>{var n;let t="Unhandled Promise Rejection",r="";e.reason&&(t=typeof e.reason=="string"?e.reason:e.reason.message||String(e.reason)||t,r=((n=e.reason)==null?void 0:n.stack)||""),this.reportError({msg:t,stack:r,source:"UnhandledRejection"})},uni.onUnhandledRejection(this.onUnhandledRejectionHandler)),typeof window<"u"&&window.addEventListener&&(this.boundWindowError=e=>{var n,s;if(e.target!==window)return;const t=e.message||((n=e.error)==null?void 0:n.message)||String(e),r=((s=e.error)==null?void 0:s.stack)||"";this.reportError({msg:t,stack:r,source:"WindowError"})},this.boundWindowRejection=e=>{let t="Unhandled Promise Rejection",r="";e.reason&&(t=typeof e.reason=="string"?e.reason:e.reason.message||String(e.reason),r=e.reason.stack||""),this.reportError({msg:t,stack:r,source:"WindowRejection"})},this.resourceErrorHandler=e=>{if(e instanceof ErrorEvent&&e.target===window)return;const t=e.target;if(!t||t===window)return;const r=String(t.tagName||"").toUpperCase(),n=t.src||t.href||t.currentSrc||t.getAttribute&&t.getAttribute("src");(["IMG","SCRIPT","LINK","VIDEO","AUDIO","SOURCE","UNI-IMAGE"].includes(r)||n)&&this.reportError({type:"error",msg:`Resource Load Failed: ${n||"unknown source"}`,source:"Resource"})},window.addEventListener("error",this.boundWindowError),window.addEventListener("unhandledrejection",this.boundWindowRejection),window.addEventListener("error",this.resourceErrorHandler,!0))}resetInterceptErrorApp(){uni.offError&&this.onErrorHandler&&uni.offError(this.onErrorHandler),uni.offUnhandledRejection&&this.onUnhandledRejectionHandler&&uni.offUnhandledRejection(this.onUnhandledRejectionHandler),typeof window<"u"&&window.removeEventListener&&(this.boundWindowError&&window.removeEventListener("error",this.boundWindowError),this.boundWindowRejection&&window.removeEventListener("unhandledrejection",this.boundWindowRejection),this.resourceErrorHandler&&window.removeEventListener("error",this.resourceErrorHandler,!0))}interceptErrorVue(e){var
|
|
5
|
-
`),
|
|
4
|
+
`))==null?void 0:n[1])||"";this.reportError({msg:t,stack:r,source:"AppError"})},uni.onError(this.onErrorHandler),uni.onUnhandledRejection&&(this.onUnhandledRejectionHandler=e=>{var n;let t="Unhandled Promise Rejection",r="";e.reason&&(t=typeof e.reason=="string"?e.reason:e.reason.message||String(e.reason)||t,r=((n=e.reason)==null?void 0:n.stack)||""),this.reportError({msg:t,stack:r,source:"UnhandledRejection"})},uni.onUnhandledRejection(this.onUnhandledRejectionHandler)),typeof window<"u"&&window.addEventListener&&(this.boundWindowError=e=>{var n,s;if(e.target!==window)return;const t=e.message||((n=e.error)==null?void 0:n.message)||String(e),r=((s=e.error)==null?void 0:s.stack)||"";this.reportError({msg:t,stack:r,source:"WindowError"})},this.boundWindowRejection=e=>{let t="Unhandled Promise Rejection",r="";e.reason&&(t=typeof e.reason=="string"?e.reason:e.reason.message||String(e.reason),r=e.reason.stack||""),this.reportError({msg:t,stack:r,source:"WindowRejection"})},this.resourceErrorHandler=e=>{if(e instanceof ErrorEvent&&e.target===window)return;const t=e.target;if(!t||t===window)return;const r=String(t.tagName||"").toUpperCase(),n=t.src||t.href||t.currentSrc||t.getAttribute&&t.getAttribute("src");(["IMG","SCRIPT","LINK","VIDEO","AUDIO","SOURCE","UNI-IMAGE"].includes(r)||n)&&this.reportError({type:"error",msg:`Resource Load Failed: ${n||"unknown source"}`,source:"Resource"})},window.addEventListener("error",this.boundWindowError),window.addEventListener("unhandledrejection",this.boundWindowRejection),window.addEventListener("error",this.resourceErrorHandler,!0))}resetInterceptErrorApp(){uni.offError&&this.onErrorHandler&&uni.offError(this.onErrorHandler),uni.offUnhandledRejection&&this.onUnhandledRejectionHandler&&uni.offUnhandledRejection(this.onUnhandledRejectionHandler),typeof window<"u"&&window.removeEventListener&&(this.boundWindowError&&window.removeEventListener("error",this.boundWindowError),this.boundWindowRejection&&window.removeEventListener("unhandledrejection",this.boundWindowRejection),this.resourceErrorHandler&&window.removeEventListener("error",this.resourceErrorHandler,!0))}interceptErrorVue(e,t){var c;const r=(c=e==null?void 0:e.stack)==null?void 0:c.split(`
|
|
5
|
+
`),n=(r==null?void 0:r[1])||(e==null?void 0:e.stack)||"",s=(e==null?void 0:e.message)||(e==null?void 0:e.toString())||"Unknown Error";d.backup.originalConsole.error(e),uni.$emit(j.DEV_ERROR_BOUNDARY_TRIGGER,{err:e,info:t}),this.reportError({msg:s,stack:n,source:"VueError"})}interceptWarnVue(e){var s,c,h,a;if(this.preWarn===e)return;this.preWarn=e;const t=(c=(s=new Error)==null?void 0:s.stack)==null?void 0:c.split(`
|
|
6
6
|
`),r=((h=t==null?void 0:t.slice(2))==null?void 0:h[0])||"";d.backup.originalConsole.warn(e);const n=(a=e.split(`
|
|
7
|
-
`))==null?void 0:a.map(u
|
|
7
|
+
`))==null?void 0:a.map(u=>M.escapeHTML(u)).join(`
|
|
8
8
|
`);this.reportError({type:"warn",msg:n,stack:r,source:"VueWarn"})}interceptPromiseReject(){const e=this;this.safeDefineProperty(Promise,"reject",{configurable:!0,value:function(t){var s,c;const r=(t==null?void 0:t.toString())||"Promise Reject",n=((c=(s=t==null?void 0:t.stack)==null?void 0:s.split(`
|
|
9
|
-
`))==null?void 0:c[1])??"";return e.reportError({msg:r,stack:n,source:"Promise.reject"}),d.backup.reject.call(Promise,t)}})}resetInterceptPromiseReject(){this.safeDefineProperty(Promise,"reject",{configurable:!0,value:function(e){return d.backup.reject.call(Promise,e)}})}interceptSetStorage(){const e=this;this.safeDefineProperty(uni,"setStorageSync",{configurable:!0,value:function(t,r){d.backup.setStorageSync(t.toString(),r),e.hooks.updateStorage([{key:t.toString(),_oldKey:t.toString(),value:r}])}}),uni.addInterceptor("setStorage",{invoke(t){const r=t.complete;t.complete=function(n){var s,c;r&&r(n),e.hooks.updateStorage([{key:(s=t.key)==null?void 0:s.toString(),_oldKey:(c=t.key)==null?void 0:c.toString(),value:t.data}])}}})}resetInterceptStorage(){uni.removeInterceptor("setStorage"),this.safeDefineProperty(uni,"setStorageSync",{configurable:!0,value:d.backup.setStorageSync}),uni.removeInterceptor("clearStorage"),this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:d.backup.clearStorageSync}),uni.removeInterceptor("removeStorage"),this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:d.backup.removeStorageSync})}interceptClearStorage(){const e=this;this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:function(){d.backup.clearStorageSync(),e.hooks.clearStorage()}}),uni.addInterceptor("clearStorage",{invoke(){e.hooks.clearStorage()}})}resetInterceptClearStorage(){this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:d.backup.clearStorageSync}),uni.removeInterceptor("clearStorage")}interceptRemoveStorage(){const e=this;this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:function(t){d.backup.removeStorageSync(t),e.hooks.removeStorage(t)}}),uni.addInterceptor("removeStorage",{invoke(t){const r=t.complete;t.complete=function(n){r&&r(n),e.hooks.removeStorage(t.key)}}})}resetInterceptRemoveStorage(){this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:d.backup.removeStorageSync}),uni.removeInterceptor("removeStorage")}interceptVuexStorage(e){var r;this.hooks.getDevToolDestroy()||(this.hooks.setVuexList(e.state),this.hooks.setVueStore(e),(r=e==null?void 0:e.subscribe)==null||r.call(e,(n,s)=>{this.hooks.setVuexList(s)}))}interceptPiniaStore(e){var r;if(this.initPinia||(this.initPinia=!0,this.hooks.setPiniaStore(e.pinia)),this.hooks.setPiniaList(e.pinia.state.value),!this.hooks.getDevToolDestroy())return(r=e==null?void 0:e.store)==null||r.$subscribe(()=>{this.hooks.setPiniaList({[e.store.$id]:e.store.$state})}),e.pinia}interceptRequest(){const e=this;uni.addInterceptor("request",{invoke(t){var
|
|
10
|
-
`),g=uni.__dev_tool_platform__==="app"?u==null?void 0:u[2]:u==null?void 0:u[5],l=e.hooks.getInterceptNetworkMap(),o=`${(
|
|
9
|
+
`))==null?void 0:c[1])??"";return e.reportError({msg:r,stack:n,source:"Promise.reject"}),d.backup.reject.call(Promise,t)}})}resetInterceptPromiseReject(){this.safeDefineProperty(Promise,"reject",{configurable:!0,value:function(e){return d.backup.reject.call(Promise,e)}})}interceptSetStorage(){const e=this;this.safeDefineProperty(uni,"setStorageSync",{configurable:!0,value:function(t,r){d.backup.setStorageSync(t.toString(),r),e.hooks.updateStorage([{key:t.toString(),_oldKey:t.toString(),value:r}])}}),uni.addInterceptor("setStorage",{invoke(t){const r=t.complete;t.complete=function(n){var s,c;r&&r(n),e.hooks.updateStorage([{key:(s=t.key)==null?void 0:s.toString(),_oldKey:(c=t.key)==null?void 0:c.toString(),value:t.data}])}}})}resetInterceptStorage(){uni.removeInterceptor("setStorage"),this.safeDefineProperty(uni,"setStorageSync",{configurable:!0,value:d.backup.setStorageSync}),uni.removeInterceptor("clearStorage"),this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:d.backup.clearStorageSync}),uni.removeInterceptor("removeStorage"),this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:d.backup.removeStorageSync})}interceptClearStorage(){const e=this;this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:function(){d.backup.clearStorageSync(),e.hooks.clearStorage()}}),uni.addInterceptor("clearStorage",{invoke(){e.hooks.clearStorage()}})}resetInterceptClearStorage(){this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:d.backup.clearStorageSync}),uni.removeInterceptor("clearStorage")}interceptRemoveStorage(){const e=this;this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:function(t){d.backup.removeStorageSync(t),e.hooks.removeStorage(t)}}),uni.addInterceptor("removeStorage",{invoke(t){const r=t.complete;t.complete=function(n){r&&r(n),e.hooks.removeStorage(t.key)}}})}resetInterceptRemoveStorage(){this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:d.backup.removeStorageSync}),uni.removeInterceptor("removeStorage")}interceptVuexStorage(e){var r;this.hooks.getDevToolDestroy()||(this.hooks.setVuexList(e.state),this.hooks.setVueStore(e),(r=e==null?void 0:e.subscribe)==null||r.call(e,(n,s)=>{this.hooks.setVuexList(s)}))}interceptPiniaStore(e){var r;if(this.initPinia||(this.initPinia=!0,this.hooks.setPiniaStore(e.pinia)),this.hooks.setPiniaList(e.pinia.state.value),!this.hooks.getDevToolDestroy())return(r=e==null?void 0:e.store)==null||r.$subscribe(()=>{this.hooks.setPiniaList({[e.store.$id]:e.store.$state})}),e.pinia}interceptRequest(){const e=this;uni.addInterceptor("request",{invoke(t){var D,_,V,H,W,F,U;const r=e.hooks.getRequestIndex(),n=e.hooks.setRequestIndex(r+1),s=t.url,c=(D=s==null?void 0:s.split("?"))==null?void 0:D[0],h=c==null?void 0:c.lastIndexOf("/"),a=(c==null?void 0:c.slice(h+1))??"",u=(V=(_=new Error)==null?void 0:_.stack)==null?void 0:V.split(`
|
|
10
|
+
`),g=uni.__dev_tool_platform__==="app"?u==null?void 0:u[2]:u==null?void 0:u[5],l=e.hooks.getInterceptNetworkMap(),o=`${(H=t.method)==null?void 0:H.toUpperCase()}|${c}`,i=l==null?void 0:l.get(o),f=Object.keys(t.header??{}).includes("dev-tool-sponsor")?"dev_tool":"user";t.header={...w.omit(t.header,["dev-tool-sponsor"])};const p={index:n,stack:g,url:t.url,name:a,startTime:Date.now(),endTime:0,time:"-",headers:{requestHeader:Object.entries(t.header??{}).map(([S,k])=>({key:S,value:k})),responseHeader:[]},method:t.method||"GET",status:"pending",payload:t!=null&&t.data?JSON.stringify(t.data):"",response:{data:void 0,statusCode:0,header:{},cookies:[],errMsg:""},size:"",sponsor:f};i&&(p.headers.requestHeader={...p.headers.requestHeader,...i.headers.requestHeader},p.payload={...i.payload},p.intercepted=!0,Object.assign(t,{timeout:i.timeout})),e.hooks.updateNetwork([p]);const m={errMsg:""};let b=!0;i&&(m.statusCode=i.status,(F=(W=i==null?void 0:i.status)==null?void 0:W.toString())!=null&&F.startsWith("2")?(b=!0,m.errMsg="request:ok",m.header=(U=i.headers.responseHeader)==null?void 0:U.reduce((S,k)=>({...S,[k.key]:k.value}),{}),m.data=i.response.data):(b=!1,m.errMsg="request:fail"));const y=t.fail,v=t.success,E=t.complete;t.fail=function(S){const k=()=>{i?b?v==null||v(m):y==null||y(m):y==null||y(S)};i&&i.delay&&i.delay>0?setTimeout(k,i.delay):k()},t.success=function(S){const k=()=>{i?b?v==null||v(m):y==null||y(m):v==null||v(S)};i&&i.delay&&i.delay>0?setTimeout(k,i.delay):k()},t.complete=function(S){const k=()=>{var q,x;const P=Date.now()-p.startTime;p.time=P<1e3?P+"ms":P/1e3+"s",p.endTime=Date.now();const C=((q=S==null?void 0:S.header)==null?void 0:q["Content-Length"])||((x=S==null?void 0:S.header)==null?void 0:x["content-length"])||0;p.size=C>1024?(C/1024).toFixed(2)+"k":C+"b",i?(E==null||E(m),p.status=i.status,p.response=m,p.headers.responseHeader=i.headers.responseHeader):(E==null||E(S),p.status=S.statusCode??"error",p.response=S,p.headers.responseHeader=Object.entries(S.header??{}).map(([$,L])=>({key:$,value:L}))),e.hooks.updateNetwork([p],n)};i&&i.delay&&i.delay>0?setTimeout(k,i.delay):k()}}})}resetInterceptRequest(){uni.removeInterceptor("request")}interceptSocket(){const e=this,t=function(r){const n=r.url,s=Object.entries(r.header??{}).map(([o,i])=>({key:o,value:i})),c=(r.method??"GET").toLowerCase(),h=r.protocols??[];e.hooks.updateWs({url:n,headers:s,method:c,protocols:h,readyState:"connection",message:[]});const a=d.backup.connectSocket({...r,multiple:!0,complete:o=>{var i;(i=r==null?void 0:r.complete)==null||i.call(r,o)}});e.hooks.addWsTask(n,a);function u(o,i,f,p){let m=o;if(typeof o=="string")try{const D=JSON.parse(o);typeof D=="object"&&D!==null&&(m=D)}catch{}const b=T.transformValueToView(m),y=w.parseValue(m),E=b==="object"||b==="array"?T.transformValueToShortString(y,b):"";e.hooks.updateWs({url:n,readyState:f,headers:s,protocols:h,message:[{value:y,valueType:b,shortValue:E,status:p,time:Date.now(),type:i}]})}const g=a.send;a.send=o=>{let i=o.data;if(typeof i=="object"&&i!==null)try{i=JSON.stringify(i)}catch{}g.call(a,{...o,data:i,fail:f=>{var p;(p=o==null?void 0:o.fail)==null||p.call(o,f),u(o.data,"send","error","error")},success:f=>{var p;(p=o==null?void 0:o.success)==null||p.call(o,f),u(o.data,"send","open","success")},complete:f=>{var p;(p=o==null?void 0:o.complete)==null||p.call(o,f)}})};const l=a.close;return a.close=o=>{e.hooks.updateWs({url:n,readyState:"closing",headers:s,protocols:h,message:[]}),l.call(a,{...o,fail:i=>{var f;(f=o==null?void 0:o.fail)==null||f.call(o,i),u(i,"send","closing","error")},success:i=>{var f;(f=o==null?void 0:o.success)==null||f.call(o,i),u(i,"send","closed","success")},complete:i=>{var f;(f=o==null?void 0:o.complete)==null||f.call(o,i)}})},a.onOpen(()=>{e.hooks.updateWs({url:n,readyState:"open",headers:s,protocols:h,message:[]})}),a.onError(o=>{u(o,"receive","error","error")}),a.onMessage(o=>{u(o.data,"receive","open","success")}),a.onClose(o=>{u(o,"receive","closed","success"),e.hooks.removeWsTask(n)}),a};this.safeDefineProperty(uni,"connectSocket",{configurable:!0,value:t})}resetInterceptSocket(){this.safeDefineProperty(uni,"connectSocket",{configurable:!0,value:d.backup.connectSocket})}interceptUploadFile(){const e=this,t=r=>{var u,g;const n=e.hooks.getTransferIndex(),s=e.hooks.setTransferIndex(n+1),c=(g=(u=new Error)==null?void 0:u.stack)==null?void 0:g.split(`
|
|
11
11
|
`),h=c==null?void 0:c[2];e.hooks.updateTransfer([{index:s,type:"upload",stack:h,name:r.name,url:r.url,filePath:r.filePath,fileType:r.fileType,headers:{requestHeader:Object.entries(r.header||{}).map(([l,o])=>({key:l,value:o})),responseHeader:[]},formData:r.formData,status:"pending",progress:0,totalBytesSent:0,totalBytesExpectedToSend:0,startTime:Date.now()}],s);const a=d.backup.uploadFile({...r,success:l=>{var o;(o=r==null?void 0:r.success)==null||o.call(r,l),e.hooks.updateTransfer([{index:s,type:"upload",status:"success",endTime:Date.now(),response:{...l,data:JSON.parse(l.data)}}],s),e.hooks.removeTransferTask(s)},fail:l=>{var o;(o=r==null?void 0:r.fail)==null||o.call(r,l),e.hooks.updateTransfer([{index:s,type:"upload",status:"error",response:l,endTime:Date.now()}],s),e.hooks.removeTransferTask(s)}});return a.onProgressUpdate(l=>{e.hooks.updateTransfer([{index:s,type:"upload",progress:l.progress,totalBytesSent:l.totalBytesSent,totalBytesExpectedToSend:l.totalBytesExpectedToSend,status:"uploading"}],s)}),e.hooks.addTransferTask(s,a),a};this.safeDefineProperty(uni,"uploadFile",{configurable:!0,value:t})}resetInterceptUploadFile(){this.safeDefineProperty(uni,"uploadFile",{configurable:!0,value:d.backup.uploadFile})}interceptDownloadFile(){const e=this,t=r=>{var u,g;const n=e.hooks.getTransferIndex(),s=e.hooks.setTransferIndex(n+1),c=(g=(u=new Error)==null?void 0:u.stack)==null?void 0:g.split(`
|
|
12
12
|
`),h=c==null?void 0:c[2];e.hooks.updateTransfer([{index:s,type:"download",stack:h,url:r.url,filePath:r.filePath,headers:{requestHeader:Object.entries(r.header||{}).map(([l,o])=>({key:l,value:o})),responseHeader:[]},status:"pending",progress:0,totalBytesWritten:0,totalBytesExpectedToWrite:0,startTime:Date.now()}],s);const a=d.backup.downloadFile({...r,success:l=>{var o;(o=r==null?void 0:r.success)==null||o.call(r,l),e.hooks.updateTransfer([{index:s,type:"download",status:"success",endTime:Date.now(),response:{...l,statusCode:l.statusCode,tempFilePath:l.tempFilePath}}],s),e.hooks.removeTransferTask(s)},fail:l=>{var o;(o=r==null?void 0:r.fail)==null||o.call(r,l),e.hooks.updateTransfer([{index:s,type:"download",status:"error",response:l,endTime:Date.now()}],s),e.hooks.removeTransferTask(s)}});return a.onProgressUpdate(l=>{e.hooks.updateTransfer([{index:s,type:"download",progress:l.progress,totalBytesWritten:l.totalBytesWritten,totalBytesExpectedToWrite:l.totalBytesExpectedToWrite,status:"downloading"}],s)}),e.hooks.addTransferTask(s,a),a};this.safeDefineProperty(uni,"downloadFile",{configurable:!0,value:t})}resetInterceptDownloadFile(){this.safeDefineProperty(uni,"downloadFile",{configurable:!0,value:d.backup.downloadFile})}interceptRouterMethod(e){const t=this;uni.addInterceptor(e,{invoke(r){const n=r.complete;r.complete=function(s){var h,a,u;n==null||n(s);const c=((u=(a=(h=r.url)==null?void 0:h.slice(1))==null?void 0:a.split("?"))==null?void 0:u[0])||"/";t.hooks.updateRoute(c),t.hooks.closeWindow()}}})}interceptSwitchTab(){this.interceptRouterMethod("switchTab")}resetInterceptSwitchTab(){uni.removeInterceptor("switchTab")}interceptRedirectTo(){this.interceptRouterMethod("redirectTo")}resetInterceptRedirectTo(){uni.removeInterceptor("redirectTo")}interceptReLaunch(){this.interceptRouterMethod("reLaunch")}resetInterceptReLaunch(){uni.removeInterceptor("reLaunch")}interceptNavigateBack(){this.interceptRouterMethod("navigateBack")}resetInterceptNavigateBack(){uni.removeInterceptor("navigateBack")}interceptNavigateTo(){this.interceptRouterMethod("navigateTo")}resetInterceptNavigateTo(){uni.removeInterceptor("navigateTo")}uniEventFactory(e,t=!0){const r=`$${e}`,n=this;Object.defineProperty(uni,r,{configurable:!0,value:function(s,...c){var h,a,u,g;if((a=(h=d.backup)==null?void 0:h[r])==null||a.call(h,s,...c),t&&!s.startsWith("dev-")&&!s.startsWith("perf-")){const l=(g=(u=new Error)==null?void 0:u.stack)==null?void 0:g.split(`
|
|
13
|
-
`),o=l==null?void 0:l[2];n.hooks.updateUniEvent([{eventName:s,timer:
|
|
14
|
-
`),s=n==null?void 0:n[5];t.complete=function(a){r&&r(a);let u={},g="";try{u=JSON.parse(a==null?void 0:a.result);const l=T.transformValueToView(u);g=T.transformValueToShortString(u,l)}catch{u={},g=T.transformValueToShortString(a==null?void 0:a.result,"string")}e.hooks.updateScanCode([{timer:Date.now(),charSet:a==null?void 0:a.charSet,rawData:a==null?void 0:a.rawData,result:a==null?void 0:a.result,resultObject:u,scanType:a==null?void 0:a.scanType,errMsg:a==null?void 0:a.errMsg,path:
|
|
13
|
+
`),o=l==null?void 0:l[2];n.hooks.updateUniEvent([{eventName:s,timer:R.getCurrentDate(),stack:o,type:e}]),n.hooks.updateUniEventCount(e)}}})}interceptUniEvent(){this.uniEventFactory("on"),this.uniEventFactory("once"),this.uniEventFactory("emit"),this.uniEventFactory("off")}resetUniEvent(){Object.defineProperty(uni,"$on",{configurable:!0,value:d.backup.$on}),Object.defineProperty(uni,"$once",{configurable:!0,value:d.backup.$once}),Object.defineProperty(uni,"$emit",{configurable:!0,value:d.backup.$emit}),Object.defineProperty(uni,"$off",{configurable:!0,value:d.backup.$off})}interceptScanCode(){const e=this;uni.addInterceptor("scanCode",{invoke(t){var c,h;const r=t.complete,n=(h=(c=new Error)==null?void 0:c.stack)==null?void 0:h.split(`
|
|
14
|
+
`),s=n==null?void 0:n[5];t.complete=function(a){r&&r(a);let u={},g="";try{u=JSON.parse(a==null?void 0:a.result);const l=T.transformValueToView(u);g=T.transformValueToShortString(u,l)}catch{u={},g=T.transformValueToShortString(a==null?void 0:a.result,"string")}e.hooks.updateScanCode([{timer:Date.now(),charSet:a==null?void 0:a.charSet,rawData:a==null?void 0:a.rawData,result:a==null?void 0:a.result,resultObject:u,scanType:a==null?void 0:a.scanType,errMsg:a==null?void 0:a.errMsg,path:I.getCurrentPagePath(),stack:s,shortValue:g}])}}})}resetInterceptScanCode(){uni.removeInterceptor("scanCode")}interceptCaptureScreen(){uni.__dev_tool_platform__!=="web"&&uni.onUserCaptureScreen(this.captureScreen)}resetInterceptCaptureScreen(){uni.__dev_tool_platform__!=="web"&&uni.offUserCaptureScreen(this.captureScreen)}listenerScreenRecording(e){const{state:t}=e,r=this.hooks.getScreenIndex(),n=this.hooks.setScreenIndex(r+1),s={index:n,position:I.getCurrentPagePath(),startTime:R.getCurrentDate(),endTime:"",type:"recordingScreen"};t==="start"?this.hooks.updateScreen([s]):(s.endTime=R.getCurrentDate(),this.hooks.updateScreen([s],n))}interceptScreenRecording(){uni.onScreenRecordingStateChanged&&(this.boundListenerScreenRecording=this.listenerScreenRecording.bind(this),uni.onScreenRecordingStateChanged(this.boundListenerScreenRecording))}resetInterceptScreenRecording(){uni.offScreenRecordingStateChanged&&this.boundListenerScreenRecording&&uni.offScreenRecordingStateChanged(this.boundListenerScreenRecording)}}exports.DevIntercept=B;
|
|
@@ -44,7 +44,7 @@ export declare class DevIntercept implements DevTool.DevInterceptInterface {
|
|
|
44
44
|
interceptVue(vueInstance: any): void;
|
|
45
45
|
interceptAppError(): void;
|
|
46
46
|
resetInterceptErrorApp(): void;
|
|
47
|
-
interceptErrorVue(error: Error): void;
|
|
47
|
+
interceptErrorVue(error: Error, info?: string): void;
|
|
48
48
|
interceptWarnVue(warn: string): void;
|
|
49
49
|
interceptPromiseReject(): void;
|
|
50
50
|
resetInterceptPromiseReject(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/devIntercept/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/devIntercept/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAgB1C;;;;;GAKG;AACH,qBAAa,YAAa,YAAW,OAAO,CAAC,qBAAqB;IAChE,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,4BAA4B,CAAsB;IAC1D,OAAO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AqGrB,0BAA0B;IAQ1B,OAAO,CAAC,qBAAqB;IAsB7B,kBAAkB;IAGlB,uBAAuB;IAIvB,mBAAmB;IAGnB,wBAAwB;IAIxB,iBAAiB;IAGjB,sBAAsB;IAItB,qBAAqB;IAGrB,0BAA0B;IAI1B,mBAAmB;IAGnB,wBAAwB;IAKxB,OAAO,CAAC,eAAe;IAyBvB,iBAAiB;IAOjB,aAAa;IAoBb,iBAAiB;IAwCjB,sBAAsB;IAKtB,OAAO,CAAC,aAAa,CAgBnB;IAEF,sBAAsB;IAMtB,2BAA2B;IAM3B,OAAO,CAAC,uBAAuB;IAqB/B,wBAAwB;IASxB,6BAA6B;CAU9B"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{backup as f,consoleProxy as B}from"../../core-shared.js";import{DEV_TOOL_ON_INIT as N,DEV_TOOL_ON_DESTROY as q}from"../../const.js";import"../../utils/index.js";import{getCurrentDate as
|
|
2
|
-
`).map(n=>n.trim()).filter(Boolean);return t.find(n=>{const s=n.toLowerCase();return s.includes("at ")&&!s.includes("devintercept")&&!s.includes("devconsole")&&!s.includes("core-shared")&&!s.includes("core.ts")})||t[0]||""}reportError({type:e="error",msg:t="",stack:r="",source:n="System",itemType:s="string"}){if(this.hooks.getDevToolDestroy()||this.isReporting)return;const c=Date.now();if(t===this.lastReportMsg&&c-this.lastReportTime<100)return;this.lastReportMsg=t,this.lastReportTime=c;const h=this.formatStack(r);this.isReporting=!0;try{const i=[];if(s==="object"||s==="array"){const u=D(t);i.push({type:s,value:u,shortValue:w(u,s)})}else i.push({type:s,value:`[${n}] ${t}`});this.hooks.updateConsole([{type:e,args:i,position:b(),time:
|
|
1
|
+
import{backup as f,consoleProxy as B}from"../../core-shared.js";import{DEV_TOOL_ON_INIT as N,DEV_TOOL_ON_DESTROY as q,DEV_ERROR_BOUNDARY_TRIGGER as A}from"../../const.js";import"../../utils/index.js";import{getCurrentDate as R}from"../../utils/date.js";import{getCurrentPagePath as b}from"../../utils/page.js";import{parseValue as D,omit as G}from"../../utils/object.js";import{transformValueToShortString as w,transformValueToView as P}from"../../utils/language.js";import{escapeHTML as J}from"../../utils/string.js";class re{constructor(e){this.initPinia=!1,this.isReporting=!1,this.lastReportMsg="",this.lastReportTime=0,this.captureScreen=t=>{if(!this.hooks.getDevToolDestroy()){const r=this.hooks.getScreenIndex(),n=this.hooks.setScreenIndex(r+1);this.hooks.updateScreen([{index:n,position:b(),startTime:R(),endTime:R(),type:"captureScreen",path:(t==null?void 0:t.path)??""}])}},this.hooks=e.hooks,typeof uni<"u"&&(uni.$on(N,t=>this.init(t)),uni.$on(q,()=>this.reset()))}safeDefineProperty(e,t,r){if(!e)return!1;try{const n=Object.getOwnPropertyDescriptor(e,t);return n&&n.configurable===!1?(console.warn(`[DevTool] ${t} 属性不可配置,已跳过拦截`),!1):(Object.defineProperty(e,t,{...r,configurable:!0}),!0)}catch(n){return console.warn(`[DevTool] 拦截 ${t} 失败,环境可能受限:`,n),!1}}formatStack(e){if(!e)return"";const t=e.split(`
|
|
2
|
+
`).map(n=>n.trim()).filter(Boolean);return t.find(n=>{const s=n.toLowerCase();return s.includes("at ")&&!s.includes("devintercept")&&!s.includes("devconsole")&&!s.includes("core-shared")&&!s.includes("core.ts")})||t[0]||""}reportError({type:e="error",msg:t="",stack:r="",source:n="System",itemType:s="string"}){if(this.hooks.getDevToolDestroy()||this.isReporting)return;const c=Date.now();if(t===this.lastReportMsg&&c-this.lastReportTime<100)return;this.lastReportMsg=t,this.lastReportTime=c;const h=this.formatStack(r);this.isReporting=!0;try{const i=[];if(s==="object"||s==="array"){const u=D(t);i.push({type:s,value:u,shortValue:w(u,s)})}else i.push({type:s,value:`[${n}] ${t}`});this.hooks.updateConsole([{type:e,args:i,position:b(),time:R(),stack:h}])}finally{this.isReporting=!1}}init({enableCaptureScreen:e,enableInterceptPromiseReject:t}){this.enableCaptureScreen=e,this.enableInterceptPromiseReject=t,this.interceptAppConsole(),this.interceptAppError(),this.interceptSetStorage(),this.interceptRemoveStorage(),this.interceptClearStorage(),this.interceptRequest(),this.interceptSocket(),this.interceptUploadFile(),this.interceptDownloadFile(),this.interceptSwitchTab(),this.interceptRedirectTo(),this.interceptReLaunch(),this.interceptNavigateBack(),this.interceptNavigateTo(),this.interceptUniEvent(),this.interceptScanCode(),this.enableCaptureScreen&&this.interceptCaptureScreen(),this.interceptScreenRecording(),this.enableInterceptPromiseReject&&this.interceptPromiseReject()}reset(){this.resetInterceptAppConsole(),this.resetInterceptErrorApp(),this.resetInterceptPromiseReject(),this.resetInterceptStorage(),this.resetInterceptRemoveStorage(),this.resetInterceptClearStorage(),this.resetInterceptRequest(),this.resetInterceptSocket(),this.resetInterceptUploadFile(),this.resetInterceptDownloadFile(),this.resetInterceptSwitchTab(),this.resetInterceptRedirectTo(),this.resetInterceptReLaunch(),this.resetInterceptNavigateBack(),this.resetInterceptNavigateTo(),this.resetUniEvent(),this.resetInterceptScanCode(),this.enableCaptureScreen&&this.resetInterceptCaptureScreen(),this.resetInterceptScreenRecording()}interceptAppConsole(){const e=this;uni.__log__&&this.safeDefineProperty(uni,"__log__",{writable:!1,value:function(r,n,...s){f.__log__(r,n,...s);const c=b();e.hooks.updateConsole([{type:r,position:c,time:R(),args:s.map(h=>{const i=P(h),u=D(h),l=i==="object"||i==="array"?w(u,i):"";return{type:i,value:u,shortValue:l}}),stack:n}])}}),["log","info","debug","error","warn","time","timeEnd","count","clear"].forEach(r=>{this.safeDefineProperty(console,r,{value:function(...n){if(["time","timeEnd","count","clear"].includes(r))return B[r](...n);f.originalConsole[r](...n);const s=n.map(h=>{const i=P(h),u=D(h),l=i==="object"||i==="array"?w(u,i):"";return{type:i,value:u,shortValue:l}}),c=e.formatStack(new Error().stack||"");n.length>0&&e.hooks.updateConsole([{type:r,args:s,position:b(),time:R(),stack:c}])}})})}resetInterceptAppConsole(){uni.__log__&&this.safeDefineProperty(uni,"__log__",{writable:!0,value:f.__log__}),["log","info","debug","error","warn","time","timeEnd","count","clear"].forEach(t=>{this.safeDefineProperty(console,t,{value:f.originalConsole[t]})})}interceptVue(e){if(!e)return;const t=(n,s,c)=>{this.hooks.getDevToolDestroy()||this.interceptErrorVue(n,c)},r=(n,s,c)=>{this.hooks.getDevToolDestroy()||this.interceptWarnVue(n+`
|
|
3
3
|
`+c)};e.appContext?(e.appContext.config.errorHandler=t,e.appContext.config.warnHandler=r):(e.config.errorHandler=t,e.config.warnHandler=r)}interceptAppError(){this.onErrorHandler=e=>{var n;const t=typeof e=="string"?e:(e==null?void 0:e.message)||String(e)||"",r=(e==null?void 0:e.stack)||((n=t==null?void 0:t.split(`
|
|
4
|
-
`))==null?void 0:n[1])||"";this.reportError({msg:t,stack:r,source:"AppError"})},uni.onError(this.onErrorHandler),uni.onUnhandledRejection&&(this.onUnhandledRejectionHandler=e=>{var n;let t="Unhandled Promise Rejection",r="";e.reason&&(t=typeof e.reason=="string"?e.reason:e.reason.message||String(e.reason)||t,r=((n=e.reason)==null?void 0:n.stack)||""),this.reportError({msg:t,stack:r,source:"UnhandledRejection"})},uni.onUnhandledRejection(this.onUnhandledRejectionHandler)),typeof window<"u"&&window.addEventListener&&(this.boundWindowError=e=>{var n,s;if(e.target!==window)return;const t=e.message||((n=e.error)==null?void 0:n.message)||String(e),r=((s=e.error)==null?void 0:s.stack)||"";this.reportError({msg:t,stack:r,source:"WindowError"})},this.boundWindowRejection=e=>{let t="Unhandled Promise Rejection",r="";e.reason&&(t=typeof e.reason=="string"?e.reason:e.reason.message||String(e.reason),r=e.reason.stack||""),this.reportError({msg:t,stack:r,source:"WindowRejection"})},this.resourceErrorHandler=e=>{if(e instanceof ErrorEvent&&e.target===window)return;const t=e.target;if(!t||t===window)return;const r=String(t.tagName||"").toUpperCase(),n=t.src||t.href||t.currentSrc||t.getAttribute&&t.getAttribute("src");(["IMG","SCRIPT","LINK","VIDEO","AUDIO","SOURCE","UNI-IMAGE"].includes(r)||n)&&this.reportError({type:"error",msg:`Resource Load Failed: ${n||"unknown source"}`,source:"Resource"})},window.addEventListener("error",this.boundWindowError),window.addEventListener("unhandledrejection",this.boundWindowRejection),window.addEventListener("error",this.resourceErrorHandler,!0))}resetInterceptErrorApp(){uni.offError&&this.onErrorHandler&&uni.offError(this.onErrorHandler),uni.offUnhandledRejection&&this.onUnhandledRejectionHandler&&uni.offUnhandledRejection(this.onUnhandledRejectionHandler),typeof window<"u"&&window.removeEventListener&&(this.boundWindowError&&window.removeEventListener("error",this.boundWindowError),this.boundWindowRejection&&window.removeEventListener("unhandledrejection",this.boundWindowRejection),this.resourceErrorHandler&&window.removeEventListener("error",this.resourceErrorHandler,!0))}interceptErrorVue(e){var
|
|
5
|
-
`),
|
|
4
|
+
`))==null?void 0:n[1])||"";this.reportError({msg:t,stack:r,source:"AppError"})},uni.onError(this.onErrorHandler),uni.onUnhandledRejection&&(this.onUnhandledRejectionHandler=e=>{var n;let t="Unhandled Promise Rejection",r="";e.reason&&(t=typeof e.reason=="string"?e.reason:e.reason.message||String(e.reason)||t,r=((n=e.reason)==null?void 0:n.stack)||""),this.reportError({msg:t,stack:r,source:"UnhandledRejection"})},uni.onUnhandledRejection(this.onUnhandledRejectionHandler)),typeof window<"u"&&window.addEventListener&&(this.boundWindowError=e=>{var n,s;if(e.target!==window)return;const t=e.message||((n=e.error)==null?void 0:n.message)||String(e),r=((s=e.error)==null?void 0:s.stack)||"";this.reportError({msg:t,stack:r,source:"WindowError"})},this.boundWindowRejection=e=>{let t="Unhandled Promise Rejection",r="";e.reason&&(t=typeof e.reason=="string"?e.reason:e.reason.message||String(e.reason),r=e.reason.stack||""),this.reportError({msg:t,stack:r,source:"WindowRejection"})},this.resourceErrorHandler=e=>{if(e instanceof ErrorEvent&&e.target===window)return;const t=e.target;if(!t||t===window)return;const r=String(t.tagName||"").toUpperCase(),n=t.src||t.href||t.currentSrc||t.getAttribute&&t.getAttribute("src");(["IMG","SCRIPT","LINK","VIDEO","AUDIO","SOURCE","UNI-IMAGE"].includes(r)||n)&&this.reportError({type:"error",msg:`Resource Load Failed: ${n||"unknown source"}`,source:"Resource"})},window.addEventListener("error",this.boundWindowError),window.addEventListener("unhandledrejection",this.boundWindowRejection),window.addEventListener("error",this.resourceErrorHandler,!0))}resetInterceptErrorApp(){uni.offError&&this.onErrorHandler&&uni.offError(this.onErrorHandler),uni.offUnhandledRejection&&this.onUnhandledRejectionHandler&&uni.offUnhandledRejection(this.onUnhandledRejectionHandler),typeof window<"u"&&window.removeEventListener&&(this.boundWindowError&&window.removeEventListener("error",this.boundWindowError),this.boundWindowRejection&&window.removeEventListener("unhandledrejection",this.boundWindowRejection),this.resourceErrorHandler&&window.removeEventListener("error",this.resourceErrorHandler,!0))}interceptErrorVue(e,t){var c;const r=(c=e==null?void 0:e.stack)==null?void 0:c.split(`
|
|
5
|
+
`),n=(r==null?void 0:r[1])||(e==null?void 0:e.stack)||"",s=(e==null?void 0:e.message)||(e==null?void 0:e.toString())||"Unknown Error";f.originalConsole.error(e),uni.$emit(A,{err:e,info:t}),this.reportError({msg:s,stack:n,source:"VueError"})}interceptWarnVue(e){var s,c,h,i;if(this.preWarn===e)return;this.preWarn=e;const t=(c=(s=new Error)==null?void 0:s.stack)==null?void 0:c.split(`
|
|
6
6
|
`),r=((h=t==null?void 0:t.slice(2))==null?void 0:h[0])||"";f.originalConsole.warn(e);const n=(i=e.split(`
|
|
7
|
-
`))==null?void 0:i.map(u=>
|
|
7
|
+
`))==null?void 0:i.map(u=>J(u)).join(`
|
|
8
8
|
`);this.reportError({type:"warn",msg:n,stack:r,source:"VueWarn"})}interceptPromiseReject(){const e=this;this.safeDefineProperty(Promise,"reject",{configurable:!0,value:function(t){var s,c;const r=(t==null?void 0:t.toString())||"Promise Reject",n=((c=(s=t==null?void 0:t.stack)==null?void 0:s.split(`
|
|
9
|
-
`))==null?void 0:c[1])??"";return e.reportError({msg:r,stack:n,source:"Promise.reject"}),f.reject.call(Promise,t)}})}resetInterceptPromiseReject(){this.safeDefineProperty(Promise,"reject",{configurable:!0,value:function(e){return f.reject.call(Promise,e)}})}interceptSetStorage(){const e=this;this.safeDefineProperty(uni,"setStorageSync",{configurable:!0,value:function(t,r){f.setStorageSync(t.toString(),r),e.hooks.updateStorage([{key:t.toString(),_oldKey:t.toString(),value:r}])}}),uni.addInterceptor("setStorage",{invoke(t){const r=t.complete;t.complete=function(n){var s,c;r&&r(n),e.hooks.updateStorage([{key:(s=t.key)==null?void 0:s.toString(),_oldKey:(c=t.key)==null?void 0:c.toString(),value:t.data}])}}})}resetInterceptStorage(){uni.removeInterceptor("setStorage"),this.safeDefineProperty(uni,"setStorageSync",{configurable:!0,value:f.setStorageSync}),uni.removeInterceptor("clearStorage"),this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:f.clearStorageSync}),uni.removeInterceptor("removeStorage"),this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:f.removeStorageSync})}interceptClearStorage(){const e=this;this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:function(){f.clearStorageSync(),e.hooks.clearStorage()}}),uni.addInterceptor("clearStorage",{invoke(){e.hooks.clearStorage()}})}resetInterceptClearStorage(){this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:f.clearStorageSync}),uni.removeInterceptor("clearStorage")}interceptRemoveStorage(){const e=this;this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:function(t){f.removeStorageSync(t),e.hooks.removeStorage(t)}}),uni.addInterceptor("removeStorage",{invoke(t){const r=t.complete;t.complete=function(n){r&&r(n),e.hooks.removeStorage(t.key)}}})}resetInterceptRemoveStorage(){this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:f.removeStorageSync}),uni.removeInterceptor("removeStorage")}interceptVuexStorage(e){var r;this.hooks.getDevToolDestroy()||(this.hooks.setVuexList(e.state),this.hooks.setVueStore(e),(r=e==null?void 0:e.subscribe)==null||r.call(e,(n,s)=>{this.hooks.setVuexList(s)}))}interceptPiniaStore(e){var r;if(this.initPinia||(this.initPinia=!0,this.hooks.setPiniaStore(e.pinia)),this.hooks.setPiniaList(e.pinia.state.value),!this.hooks.getDevToolDestroy())return(r=e==null?void 0:e.store)==null||r.$subscribe(()=>{this.hooks.setPiniaList({[e.store.$id]:e.store.$state})}),e.pinia}interceptRequest(){const e=this;uni.addInterceptor("request",{invoke(t){var
|
|
10
|
-
`),g=uni.__dev_tool_platform__==="app"?u==null?void 0:u[2]:u==null?void 0:u[5],l=e.hooks.getInterceptNetworkMap(),o=`${(W=t.method)==null?void 0:W.toUpperCase()}|${c}`,a=l==null?void 0:l.get(o),p=Object.keys(t.header??{}).includes("dev-tool-sponsor")?"dev_tool":"user";t.header={...
|
|
9
|
+
`))==null?void 0:c[1])??"";return e.reportError({msg:r,stack:n,source:"Promise.reject"}),f.reject.call(Promise,t)}})}resetInterceptPromiseReject(){this.safeDefineProperty(Promise,"reject",{configurable:!0,value:function(e){return f.reject.call(Promise,e)}})}interceptSetStorage(){const e=this;this.safeDefineProperty(uni,"setStorageSync",{configurable:!0,value:function(t,r){f.setStorageSync(t.toString(),r),e.hooks.updateStorage([{key:t.toString(),_oldKey:t.toString(),value:r}])}}),uni.addInterceptor("setStorage",{invoke(t){const r=t.complete;t.complete=function(n){var s,c;r&&r(n),e.hooks.updateStorage([{key:(s=t.key)==null?void 0:s.toString(),_oldKey:(c=t.key)==null?void 0:c.toString(),value:t.data}])}}})}resetInterceptStorage(){uni.removeInterceptor("setStorage"),this.safeDefineProperty(uni,"setStorageSync",{configurable:!0,value:f.setStorageSync}),uni.removeInterceptor("clearStorage"),this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:f.clearStorageSync}),uni.removeInterceptor("removeStorage"),this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:f.removeStorageSync})}interceptClearStorage(){const e=this;this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:function(){f.clearStorageSync(),e.hooks.clearStorage()}}),uni.addInterceptor("clearStorage",{invoke(){e.hooks.clearStorage()}})}resetInterceptClearStorage(){this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:f.clearStorageSync}),uni.removeInterceptor("clearStorage")}interceptRemoveStorage(){const e=this;this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:function(t){f.removeStorageSync(t),e.hooks.removeStorage(t)}}),uni.addInterceptor("removeStorage",{invoke(t){const r=t.complete;t.complete=function(n){r&&r(n),e.hooks.removeStorage(t.key)}}})}resetInterceptRemoveStorage(){this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:f.removeStorageSync}),uni.removeInterceptor("removeStorage")}interceptVuexStorage(e){var r;this.hooks.getDevToolDestroy()||(this.hooks.setVuexList(e.state),this.hooks.setVueStore(e),(r=e==null?void 0:e.subscribe)==null||r.call(e,(n,s)=>{this.hooks.setVuexList(s)}))}interceptPiniaStore(e){var r;if(this.initPinia||(this.initPinia=!0,this.hooks.setPiniaStore(e.pinia)),this.hooks.setPiniaList(e.pinia.state.value),!this.hooks.getDevToolDestroy())return(r=e==null?void 0:e.store)==null||r.$subscribe(()=>{this.hooks.setPiniaList({[e.store.$id]:e.store.$state})}),e.pinia}interceptRequest(){const e=this;uni.addInterceptor("request",{invoke(t){var I,_,H,W,F,U,x;const r=e.hooks.getRequestIndex(),n=e.hooks.setRequestIndex(r+1),s=t.url,c=(I=s==null?void 0:s.split("?"))==null?void 0:I[0],h=c==null?void 0:c.lastIndexOf("/"),i=(c==null?void 0:c.slice(h+1))??"",u=(H=(_=new Error)==null?void 0:_.stack)==null?void 0:H.split(`
|
|
10
|
+
`),g=uni.__dev_tool_platform__==="app"?u==null?void 0:u[2]:u==null?void 0:u[5],l=e.hooks.getInterceptNetworkMap(),o=`${(W=t.method)==null?void 0:W.toUpperCase()}|${c}`,a=l==null?void 0:l.get(o),p=Object.keys(t.header??{}).includes("dev-tool-sponsor")?"dev_tool":"user";t.header={...G(t.header,["dev-tool-sponsor"])};const d={index:n,stack:g,url:t.url,name:i,startTime:Date.now(),endTime:0,time:"-",headers:{requestHeader:Object.entries(t.header??{}).map(([m,k])=>({key:m,value:k})),responseHeader:[]},method:t.method||"GET",status:"pending",payload:t!=null&&t.data?JSON.stringify(t.data):"",response:{data:void 0,statusCode:0,header:{},cookies:[],errMsg:""},size:"",sponsor:p};a&&(d.headers.requestHeader={...d.headers.requestHeader,...a.headers.requestHeader},d.payload={...a.payload},d.intercepted=!0,Object.assign(t,{timeout:a.timeout})),e.hooks.updateNetwork([d]);const S={errMsg:""};let T=!0;a&&(S.statusCode=a.status,(U=(F=a==null?void 0:a.status)==null?void 0:F.toString())!=null&&U.startsWith("2")?(T=!0,S.errMsg="request:ok",S.header=(x=a.headers.responseHeader)==null?void 0:x.reduce((m,k)=>({...m,[k.key]:k.value}),{}),S.data=a.response.data):(T=!1,S.errMsg="request:fail"));const y=t.fail,v=t.success,E=t.complete;t.fail=function(m){const k=()=>{a?T?v==null||v(S):y==null||y(S):y==null||y(m)};a&&a.delay&&a.delay>0?setTimeout(k,a.delay):k()},t.success=function(m){const k=()=>{a?T?v==null||v(S):y==null||y(S):v==null||v(m)};a&&a.delay&&a.delay>0?setTimeout(k,a.delay):k()},t.complete=function(m){const k=()=>{var V,$;const C=Date.now()-d.startTime;d.time=C<1e3?C+"ms":C/1e3+"s",d.endTime=Date.now();const j=((V=m==null?void 0:m.header)==null?void 0:V["Content-Length"])||(($=m==null?void 0:m.header)==null?void 0:$["content-length"])||0;d.size=j>1024?(j/1024).toFixed(2)+"k":j+"b",a?(E==null||E(S),d.status=a.status,d.response=S,d.headers.responseHeader=a.headers.responseHeader):(E==null||E(m),d.status=m.statusCode??"error",d.response=m,d.headers.responseHeader=Object.entries(m.header??{}).map(([L,M])=>({key:L,value:M}))),e.hooks.updateNetwork([d],n)};a&&a.delay&&a.delay>0?setTimeout(k,a.delay):k()}}})}resetInterceptRequest(){uni.removeInterceptor("request")}interceptSocket(){const e=this,t=function(r){const n=r.url,s=Object.entries(r.header??{}).map(([o,a])=>({key:o,value:a})),c=(r.method??"GET").toLowerCase(),h=r.protocols??[];e.hooks.updateWs({url:n,headers:s,method:c,protocols:h,readyState:"connection",message:[]});const i=f.connectSocket({...r,multiple:!0,complete:o=>{var a;(a=r==null?void 0:r.complete)==null||a.call(r,o)}});e.hooks.addWsTask(n,i);function u(o,a,p,d){let S=o;if(typeof o=="string")try{const I=JSON.parse(o);typeof I=="object"&&I!==null&&(S=I)}catch{}const T=P(S),y=D(S),E=T==="object"||T==="array"?w(y,T):"";e.hooks.updateWs({url:n,readyState:p,headers:s,protocols:h,message:[{value:y,valueType:T,shortValue:E,status:d,time:Date.now(),type:a}]})}const g=i.send;i.send=o=>{let a=o.data;if(typeof a=="object"&&a!==null)try{a=JSON.stringify(a)}catch{}g.call(i,{...o,data:a,fail:p=>{var d;(d=o==null?void 0:o.fail)==null||d.call(o,p),u(o.data,"send","error","error")},success:p=>{var d;(d=o==null?void 0:o.success)==null||d.call(o,p),u(o.data,"send","open","success")},complete:p=>{var d;(d=o==null?void 0:o.complete)==null||d.call(o,p)}})};const l=i.close;return i.close=o=>{e.hooks.updateWs({url:n,readyState:"closing",headers:s,protocols:h,message:[]}),l.call(i,{...o,fail:a=>{var p;(p=o==null?void 0:o.fail)==null||p.call(o,a),u(a,"send","closing","error")},success:a=>{var p;(p=o==null?void 0:o.success)==null||p.call(o,a),u(a,"send","closed","success")},complete:a=>{var p;(p=o==null?void 0:o.complete)==null||p.call(o,a)}})},i.onOpen(()=>{e.hooks.updateWs({url:n,readyState:"open",headers:s,protocols:h,message:[]})}),i.onError(o=>{u(o,"receive","error","error")}),i.onMessage(o=>{u(o.data,"receive","open","success")}),i.onClose(o=>{u(o,"receive","closed","success"),e.hooks.removeWsTask(n)}),i};this.safeDefineProperty(uni,"connectSocket",{configurable:!0,value:t})}resetInterceptSocket(){this.safeDefineProperty(uni,"connectSocket",{configurable:!0,value:f.connectSocket})}interceptUploadFile(){const e=this,t=r=>{var u,g;const n=e.hooks.getTransferIndex(),s=e.hooks.setTransferIndex(n+1),c=(g=(u=new Error)==null?void 0:u.stack)==null?void 0:g.split(`
|
|
11
11
|
`),h=c==null?void 0:c[2];e.hooks.updateTransfer([{index:s,type:"upload",stack:h,name:r.name,url:r.url,filePath:r.filePath,fileType:r.fileType,headers:{requestHeader:Object.entries(r.header||{}).map(([l,o])=>({key:l,value:o})),responseHeader:[]},formData:r.formData,status:"pending",progress:0,totalBytesSent:0,totalBytesExpectedToSend:0,startTime:Date.now()}],s);const i=f.uploadFile({...r,success:l=>{var o;(o=r==null?void 0:r.success)==null||o.call(r,l),e.hooks.updateTransfer([{index:s,type:"upload",status:"success",endTime:Date.now(),response:{...l,data:JSON.parse(l.data)}}],s),e.hooks.removeTransferTask(s)},fail:l=>{var o;(o=r==null?void 0:r.fail)==null||o.call(r,l),e.hooks.updateTransfer([{index:s,type:"upload",status:"error",response:l,endTime:Date.now()}],s),e.hooks.removeTransferTask(s)}});return i.onProgressUpdate(l=>{e.hooks.updateTransfer([{index:s,type:"upload",progress:l.progress,totalBytesSent:l.totalBytesSent,totalBytesExpectedToSend:l.totalBytesExpectedToSend,status:"uploading"}],s)}),e.hooks.addTransferTask(s,i),i};this.safeDefineProperty(uni,"uploadFile",{configurable:!0,value:t})}resetInterceptUploadFile(){this.safeDefineProperty(uni,"uploadFile",{configurable:!0,value:f.uploadFile})}interceptDownloadFile(){const e=this,t=r=>{var u,g;const n=e.hooks.getTransferIndex(),s=e.hooks.setTransferIndex(n+1),c=(g=(u=new Error)==null?void 0:u.stack)==null?void 0:g.split(`
|
|
12
12
|
`),h=c==null?void 0:c[2];e.hooks.updateTransfer([{index:s,type:"download",stack:h,url:r.url,filePath:r.filePath,headers:{requestHeader:Object.entries(r.header||{}).map(([l,o])=>({key:l,value:o})),responseHeader:[]},status:"pending",progress:0,totalBytesWritten:0,totalBytesExpectedToWrite:0,startTime:Date.now()}],s);const i=f.downloadFile({...r,success:l=>{var o;(o=r==null?void 0:r.success)==null||o.call(r,l),e.hooks.updateTransfer([{index:s,type:"download",status:"success",endTime:Date.now(),response:{...l,statusCode:l.statusCode,tempFilePath:l.tempFilePath}}],s),e.hooks.removeTransferTask(s)},fail:l=>{var o;(o=r==null?void 0:r.fail)==null||o.call(r,l),e.hooks.updateTransfer([{index:s,type:"download",status:"error",response:l,endTime:Date.now()}],s),e.hooks.removeTransferTask(s)}});return i.onProgressUpdate(l=>{e.hooks.updateTransfer([{index:s,type:"download",progress:l.progress,totalBytesWritten:l.totalBytesWritten,totalBytesExpectedToWrite:l.totalBytesExpectedToWrite,status:"downloading"}],s)}),e.hooks.addTransferTask(s,i),i};this.safeDefineProperty(uni,"downloadFile",{configurable:!0,value:t})}resetInterceptDownloadFile(){this.safeDefineProperty(uni,"downloadFile",{configurable:!0,value:f.downloadFile})}interceptRouterMethod(e){const t=this;uni.addInterceptor(e,{invoke(r){const n=r.complete;r.complete=function(s){var h,i,u;n==null||n(s);const c=((u=(i=(h=r.url)==null?void 0:h.slice(1))==null?void 0:i.split("?"))==null?void 0:u[0])||"/";t.hooks.updateRoute(c),t.hooks.closeWindow()}}})}interceptSwitchTab(){this.interceptRouterMethod("switchTab")}resetInterceptSwitchTab(){uni.removeInterceptor("switchTab")}interceptRedirectTo(){this.interceptRouterMethod("redirectTo")}resetInterceptRedirectTo(){uni.removeInterceptor("redirectTo")}interceptReLaunch(){this.interceptRouterMethod("reLaunch")}resetInterceptReLaunch(){uni.removeInterceptor("reLaunch")}interceptNavigateBack(){this.interceptRouterMethod("navigateBack")}resetInterceptNavigateBack(){uni.removeInterceptor("navigateBack")}interceptNavigateTo(){this.interceptRouterMethod("navigateTo")}resetInterceptNavigateTo(){uni.removeInterceptor("navigateTo")}uniEventFactory(e,t=!0){const r=`$${e}`,n=this;Object.defineProperty(uni,r,{configurable:!0,value:function(s,...c){var h,i,u,g;if((i=(h=f)==null?void 0:h[r])==null||i.call(h,s,...c),t&&!s.startsWith("dev-")&&!s.startsWith("perf-")){const l=(g=(u=new Error)==null?void 0:u.stack)==null?void 0:g.split(`
|
|
13
|
-
`),o=l==null?void 0:l[2];n.hooks.updateUniEvent([{eventName:s,timer:
|
|
14
|
-
`),s=n==null?void 0:n[5];t.complete=function(i){r&&r(i);let u={},g="";try{u=JSON.parse(i==null?void 0:i.result);const l=P(u);g=w(u,l)}catch{u={},g=w(i==null?void 0:i.result,"string")}e.hooks.updateScanCode([{timer:Date.now(),charSet:i==null?void 0:i.charSet,rawData:i==null?void 0:i.rawData,result:i==null?void 0:i.result,resultObject:u,scanType:i==null?void 0:i.scanType,errMsg:i==null?void 0:i.errMsg,path:b(),stack:s,shortValue:g}])}}})}resetInterceptScanCode(){uni.removeInterceptor("scanCode")}interceptCaptureScreen(){uni.__dev_tool_platform__!=="web"&&uni.onUserCaptureScreen(this.captureScreen)}resetInterceptCaptureScreen(){uni.__dev_tool_platform__!=="web"&&uni.offUserCaptureScreen(this.captureScreen)}listenerScreenRecording(e){const{state:t}=e,r=this.hooks.getScreenIndex(),n=this.hooks.setScreenIndex(r+1),s={index:n,position:b(),startTime:
|
|
13
|
+
`),o=l==null?void 0:l[2];n.hooks.updateUniEvent([{eventName:s,timer:R(),stack:o,type:e}]),n.hooks.updateUniEventCount(e)}}})}interceptUniEvent(){this.uniEventFactory("on"),this.uniEventFactory("once"),this.uniEventFactory("emit"),this.uniEventFactory("off")}resetUniEvent(){Object.defineProperty(uni,"$on",{configurable:!0,value:f.$on}),Object.defineProperty(uni,"$once",{configurable:!0,value:f.$once}),Object.defineProperty(uni,"$emit",{configurable:!0,value:f.$emit}),Object.defineProperty(uni,"$off",{configurable:!0,value:f.$off})}interceptScanCode(){const e=this;uni.addInterceptor("scanCode",{invoke(t){var c,h;const r=t.complete,n=(h=(c=new Error)==null?void 0:c.stack)==null?void 0:h.split(`
|
|
14
|
+
`),s=n==null?void 0:n[5];t.complete=function(i){r&&r(i);let u={},g="";try{u=JSON.parse(i==null?void 0:i.result);const l=P(u);g=w(u,l)}catch{u={},g=w(i==null?void 0:i.result,"string")}e.hooks.updateScanCode([{timer:Date.now(),charSet:i==null?void 0:i.charSet,rawData:i==null?void 0:i.rawData,result:i==null?void 0:i.result,resultObject:u,scanType:i==null?void 0:i.scanType,errMsg:i==null?void 0:i.errMsg,path:b(),stack:s,shortValue:g}])}}})}resetInterceptScanCode(){uni.removeInterceptor("scanCode")}interceptCaptureScreen(){uni.__dev_tool_platform__!=="web"&&uni.onUserCaptureScreen(this.captureScreen)}resetInterceptCaptureScreen(){uni.__dev_tool_platform__!=="web"&&uni.offUserCaptureScreen(this.captureScreen)}listenerScreenRecording(e){const{state:t}=e,r=this.hooks.getScreenIndex(),n=this.hooks.setScreenIndex(r+1),s={index:n,position:b(),startTime:R(),endTime:"",type:"recordingScreen"};t==="start"?this.hooks.updateScreen([s]):(s.endTime=R(),this.hooks.updateScreen([s],n))}interceptScreenRecording(){uni.onScreenRecordingStateChanged&&(this.boundListenerScreenRecording=this.listenerScreenRecording.bind(this),uni.onScreenRecordingStateChanged(this.boundListenerScreenRecording))}resetInterceptScreenRecording(){uni.offScreenRecordingStateChanged&&this.boundListenerScreenRecording&&uni.offScreenRecordingStateChanged(this.boundListenerScreenRecording)}}export{re as DevIntercept};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("../../const.cjs");require("../../utils/index.cjs");const o=require("../devToolInfo/index.cjs"),C=require("../../utils/function.cjs"),D=require("../../utils/language.cjs"),y=require("../../utils/object.cjs"),b=require("../../utils/page.cjs"),x=require("../../utils/ip.cjs");class z{constructor(){if(this.consoleList=[],this.consoleMaxSize=1e3,this.totalConsoleCount=0,this.networkList=[],this.networkMaxSize=1e3,this.totalNetworkCount=0,this.interceptNetworkMap=new Map,this.requestIndex=-1,this.storageList=[],this.vuexList={},this.piniaList={},this.routeList=[],this.prePath="",this.wsList=[],this.wsDataMaxSize=1e3,this.wsTaskMap=new Map,this.transferList=[],this.transferMaxSize=1e3,this.transferIndex=-1,this.transferTaskMap=new Map,this.elEventList=[],this.uniEventList=[],this.eventCount={on:0,once:0,emit:0,off:0},this.elEventListMaxSize=1e3,this.uniEventListMaxSize=1e3,this.screenList=[],this.scanCodeList=[],this.nfcList=[],this.bluetoothList=[],this.screenIndex=-1,this.screenMaxSize=1e3,this.scanCodeListMaxSize=1e3,this.nfcListMaxSize=1e3,this.systemInfo={},this.deviceInfo={},this.windowInfo={},this.netWorkStatus={},this.devToolVersion="0.0.0",this.devToolBuildTime="",this.devToolGit="",this.devToolVisible=!1,this.devToolDestroy=!1,this.cacheInterceptConfig=!0,this.useTransition=!0,this.cacheNetworkLog=!1,this.cacheConsoleLog=!1,this.baseFontSize=12,this.tagFontSize=10,this.tipsFontSize=10,this.fontFamily="",this.fontWeight="normal",this.barrageVisible=!0,this.barrageMaxTracks=10,this.barrageTrackHeight=36,this.barrageStartTop=40,this.barrageDuration=6,this.barrageMaxLength=100,this.barrageTypes=["log","info","warn","error","network","transfer","websocket"],this.barrageShowWhenOpen=!1,this.saveConsoleLogThrottled=C.throttle(()=>{this.cacheConsoleLog&&o.setDevToolConsoleList(this.consoleList)},1e3),this.saveNetworkLogThrottled=C.throttle(()=>{this.cacheNetworkLog&&o.setDevToolNetworkList(this.networkList)},1e3),this.cacheMaxSize=8*1024*1024*10,typeof uni<"u"){const{devToolDestroy:t=!1,devToolButtonVisible:e=!1,cacheInterceptConfig:s=!0,cacheNetworkLog:n=!1,cacheConsoleLog:i=!1,useTransition:l=!0,baseFontSize:r=12,tagFontSize:L=10,tipsFontSize:p=10,fontFamily:a="",fontWeight:c="normal",barrageVisible:v=!0,barrageMaxTracks:d=10,barrageTrackHeight:h=36,barrageStartTop:f=40,barrageDuration:g=6,barrageMaxLength:S=100,barrageTypes:u=["log","info","warn","error","network","transfer","websocket"],barrageShowWhenOpen:T=!1,interceptNetworkList:w=[]}=uni.getStorageSync(M.DEV_TOOL_INFO)||{};this.devToolDestroy=t,this.devToolVisible=e,this.cacheInterceptConfig=s,this.cacheNetworkLog=n,this.cacheConsoleLog=i,this.useTransition=l,this.baseFontSize=r,this.tagFontSize=L,this.tipsFontSize=p,this.fontFamily=a,this.fontWeight=c,this.barrageVisible=v,this.barrageMaxTracks=d,this.barrageTrackHeight=h,this.barrageStartTop=f,this.barrageDuration=g,this.barrageMaxLength=S,this.barrageTypes=u,this.barrageShowWhenOpen=T,this.updateInterceptNetworkList(w),this.cacheNetworkLog&&(this.networkList=o.getDevToolNetworkList(),this.requestIndex=Math.max(...this.networkList.map(k=>k.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=o.getDevToolConsoleList()),this.totalConsoleCount=this.consoleList.length,this.totalNetworkCount=this.networkList.length}}updateHasUpload(){this.consoleList=this.consoleList.map(t=>({...t,hasUpload:!0})),this.networkList=this.networkList.map(t=>({...t,hasUpload:!0})),this.transferList=this.transferList.map(t=>({...t,hasUpload:!0})),this.elEventList=this.elEventList.map(t=>({...t,hasUpload:!0})),this.uniEventList=this.uniEventList.map(t=>({...t,hasUpload:!0})),this.screenList=this.screenList.map(t=>({...t,hasUpload:!0}))}setDevToolVisible(t){this.devToolVisible=t,o.setDevToolInfo({devToolButtonVisible:t})}getDevToolVisible(){return this.devToolVisible}setDevToolDestroy(t){this.devToolDestroy=t,o.setDevToolInfo({devToolDestroy:t})}getDevToolDestroy(){return this.devToolDestroy}setCacheInterceptConfig(t){this.cacheInterceptConfig=t,o.setDevToolInfo({cacheInterceptConfig:t})}getCacheNetworkLog(){return this.cacheNetworkLog}setUseTransition(t){this.useTransition=t,o.setDevToolInfo({useTransition:t})}setBaseFontSize(t){this.baseFontSize=t,o.setDevToolInfo({baseFontSize:t})}setTagFontSize(t){this.tagFontSize=t,o.setDevToolInfo({tagFontSize:t})}setTipsFontSize(t){this.tipsFontSize=t,o.setDevToolInfo({tipsFontSize:t})}setFontFamily(t){this.fontFamily=t,o.setDevToolInfo({fontFamily:t})}setFontWeight(t){this.fontWeight=t,o.setDevToolInfo({fontWeight:t})}setBarrageVisible(t){this.barrageVisible=t,o.setDevToolInfo({barrageVisible:t})}setBarrageMaxTracks(t){this.barrageMaxTracks=t,o.setDevToolInfo({barrageMaxTracks:t})}setBarrageTrackHeight(t){this.barrageTrackHeight=t,o.setDevToolInfo({barrageTrackHeight:t})}setBarrageStartTop(t){this.barrageStartTop=t,o.setDevToolInfo({barrageStartTop:t})}setBarrageDuration(t){this.barrageDuration=t,o.setDevToolInfo({barrageDuration:t})}setBarrageMaxLength(t){this.barrageMaxLength=t,o.setDevToolInfo({barrageMaxLength:t})}setBarrageTypes(t){this.barrageTypes=t,o.setDevToolInfo({barrageTypes:t})}setBarrageShowWhenOpen(t){this.barrageShowWhenOpen=t,o.setDevToolInfo({barrageShowWhenOpen:t})}setCacheConsoleLog(t){this.cacheConsoleLog=t,o.setDevToolInfo({cacheConsoleLog:t}),t?o.setDevToolConsoleList(this.consoleList):o.setDevToolConsoleList([])}setCacheNetworkLog(t){this.cacheNetworkLog=t,o.setDevToolInfo({cacheNetworkLog:t}),t?o.setDevToolNetworkList(this.networkList):o.setDevToolNetworkList([])}getConsoleList(){return this.consoleList}updateConsoleList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.consoleList[e]&&(this.consoleList[e]=t[0]):(this.consoleList.push(...t),this.totalConsoleCount+=t.length,this.consoleList.length>this.consoleMaxSize&&(this.consoleList=this.consoleList.slice(-this.consoleMaxSize))),this.saveConsoleLogThrottled()}clearConsoleList(){this.consoleList=[],this.totalConsoleCount=0,this.cacheConsoleLog&&o.setDevToolConsoleList([])}getNetworkList(){return this.networkList}updateNetworkList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.networkList[e]&&(this.networkList[e]=t[0]):(this.networkList.push(...t),this.totalNetworkCount+=t.length,this.networkList.length>this.networkMaxSize&&(this.networkList=this.networkList.slice(-this.networkMaxSize))),this.saveNetworkLogThrottled()}clearNetworkList(){this.networkList=[],this.totalNetworkCount=0,this.cacheNetworkLog&&o.setDevToolNetworkList([])}getInterceptNetworkMap(){return this.interceptNetworkMap}getRequestIndex(){return this.requestIndex}setRequestIndex(t){return this.requestIndex=t,this.requestIndex}updateInterceptNetworkList(t){this.interceptNetworkMap.clear(),t.forEach(e=>{var n;const s=`${(n=e.method)==null?void 0:n.toUpperCase()}|${e.url}`;this.interceptNetworkMap.set(s,e)})}clearInterceptNetworkList(){this.clearNetworkList()}getStorageList(){return this.storageList}setStorageList(t){return this.storageList=t,this.storageList}getVuexList(){return this.vuexList}getPiniaList(){return this.piniaList}setVuexStore(t){this.vuexStore=t}setVuexList(t){this.vuexList=t}setPiniaStore(t){this.piniaStore=t}setPiniaList(t){this.piniaList={...this.piniaList||{},...t}}updateStore(t){const{key:e,_oldKey:s,value:n}=t;return s===e&&(uni.removeStorageSync(s),this.storageList=this.storageList.filter(i=>i.key!==s)),uni.setStorageSync(e,n),this.storageList}updateVuexStore(t){var e,s;try{Object.assign(((e=this.vuexStore)==null?void 0:e.state)??{},t)}catch(n){console.error("[DevTool] updateVuexStore error",n)}return this.setVuexList({...((s=this.vuexStore)==null?void 0:s.state)??{}}),this.vuexList}updatePiniaStore(t){try{if(!this.piniaStore)return{};const[e,s]=Object.entries(t)[0];if(D.isNil(e))return{};y.setValueByPath(this.piniaStore.state.value,e,s),this.setPiniaList({...this.piniaStore.state.value??{}})}catch(e){console.error("[DevTool] updatePiniaStore error",e)}return this.piniaList}clearStorageList(t){return this.storageList=[],t&&uni.clearStorage(),this.storageList}removeStorage(t,e){return this.storageList=this.storageList.filter(s=>s.key!==t),e&&uni.removeStorageSync(t),this.storageList}addStorage(t,e){const{key:s,value:n}=t;return this.storageList.unshift({key:s,_oldKey:s,value:n}),e&&uni.setStorageSync(s,n),this.storageList}refreshStore(){const{keys:t}=uni.getStorageInfoSync();return this.storageList=t.map(e=>{const s=uni.getStorageSync(e);return{key:e,_oldKey:e,value:s}}),this.storageList}updateStoreList(t){const e=t[0],s=this.storageList.findIndex(n=>n.key===e._oldKey);return s>-1&&t.length===1?this.storageList[s]=t[0]:this.storageList.push(...t),this.storageList}getRouteList(){return this.routeList}setRouteList(t,e){var n;const s=e||((n=t==null?void 0:t[0])==null?void 0:n.path)||"";return this.routeList=t.map((i,l)=>({...i,name:i.style.navigationBarTitleText||"无名",uvList:[],index:i.path===s&&l===0?4:i.path===s?3:l===0?2:1})),this.routeList}updateRouteList(t){const e=t?t==="/"?b.getCurrentPagePath():t:b.getCurrentPagePath(),s=this.prePath;this.routeList=this.routeList.map((r,L)=>({...r,index:r.path===e&&L===0?4:r.path===e?3:L===0?2:1}));const n=(r,L,p)=>{var v,d;if(!r[L])return r;r[L].uvList||(r[L].uvList=[]);const a=r[L],c=a.uvList??[];if(c.length){const h=c.length-1,f=c[h];if(f&&f.inTime&&!f.outTime){const g=Date.now();a.outTime=g,c[h].outTime=g,c[h].duration=g-f.inTime,a.duration=c[h].duration,a.totalDuration=c.reduce((S,u)=>S+(u.duration||0),0),p&&(a.visitTimes=c.length)}else{const g=Date.now();a.inTime=g,a.outTime=0,a.duration=0,(v=a.uvList)==null||v.push({index:h+1,inTime:g,outTime:0,duration:0}),p&&(a.visitTimes=(d=a.uvList)==null?void 0:d.length)}}else{const h=Date.now();a.inTime=h,a.outTime=0,a.duration=0,a.totalDuration=0,a.visitTimes=1,a.uvList=[{index:0,inTime:h,outTime:0,duration:0}]}return r},i=this.routeList.findIndex(r=>r.path===s),l=this.routeList.findIndex(r=>r.path===e);return i>-1&&n(this.routeList,i),l>-1&&n(this.routeList,l,!0),this.prePath=e,this.routeList}getWsList(){return this.wsList}updateWsList(t){var s,n;const e=this.wsList.findIndex(i=>i.url===t.url);if(e>-1){const i=this.wsList[e];i.headers=t.headers??i.headers,i.readyState=t.readyState??i.readyState,i.method=t.method??i.method,i.protocols=t.protocols??i.protocols,i.message=[...i.message??[],...t.message??[]];const l=this.wsDataMaxSize,r=((s=i.message)==null?void 0:s.length)??0;r>l&&((n=i.message)==null||n.splice(0,r-l))}else this.wsList.push(t);return this.wsList}clearWsList(){this.wsList=[]}clearWsMessage(t){const e=this.wsList.findIndex(s=>s.url===t);e>-1&&(this.wsList[e].message=[])}addWsTask(t,e){this.wsTaskMap.set(t,e)}removeWsTask(t){this.wsTaskMap.delete(t)}getWsTask(t){const e=this.wsTaskMap.get(t);if(e)return e;if(!t)return;let s;return this.wsTaskMap.forEach((n,i)=>{s||i&&(i.includes(t)||t.includes(i))&&(s=n)}),s}getTransferList(){return this.transferList}updateTransferList(t,e){if(typeof e=="number"&&e>-1&&t.length===1){const s=t[0],n=this.transferList.findIndex(i=>i.index===e);n>-1?this.transferList[n]={...this.transferList[n],...s}:this.transferList.push(s)}else this.transferList.length+t.length>this.transferMaxSize&&(this.transferList=[]),this.transferList.push(...t)}getTransferIndex(){return this.transferIndex}setTransferIndex(t){return this.transferIndex=t,this.transferIndex}addTransferTask(t,e){this.transferTaskMap.set(t,e)}removeTransferTask(t){this.transferTaskMap.delete(t)}clearTransferTask(){this.transferTaskMap.clear()}getElEventList(){return this.elEventList}getUniEventList(){return this.uniEventList}getEventCount(){return this.eventCount}addElEvent(t){this.elEventList.length>=this.elEventListMaxSize&&this.elEventList.shift(),this.elEventList.push(t)}clearElEventList(){this.elEventList=[]}updateUniEventList(t){this.uniEventList.length+t.length>this.uniEventListMaxSize&&(this.uniEventList=[]),this.uniEventList.push(...t)}updateUniEventCount(t){this.eventCount[t]++}clearUniEventList(){this.uniEventList=[],this.eventCount={on:0,once:0,emit:0,off:0}}getScreenList(){return this.screenList}getScanCodeList(){return this.scanCodeList}getNfcList(){return this.nfcList}getScreenIndex(){return this.screenIndex}setScreenIndex(t){return this.screenIndex=t,this.screenIndex}getSystemInfo(){return this.systemInfo}getDeviceInfo(){return this.deviceInfo}getWindowInfo(){return this.windowInfo}setSystemInfo(t){this.systemInfo=t}setDeviceInfo(t){this.deviceInfo=t}setWindowInfo(t){this.windowInfo=t}setNetWorkStatus(t){this.netWorkStatus=t}updateScreenList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.screenList[e]&&(this.screenList[e]=t[0]):(this.screenList.length+t.length>this.screenMaxSize&&(this.screenList=[]),this.screenList.push(...t))}updateScanCodeList(t){this.scanCodeList.length+t.length>this.scanCodeListMaxSize&&(this.scanCodeList=[]),this.scanCodeList.push(...t)}updateNfcList(t){this.nfcList.length+t.length>this.nfcListMaxSize&&(this.nfcList=[]),this.nfcList.push(...t)}updateBluetoothList(t){this.bluetoothList=t}clearScanCodeList(){this.scanCodeList=[]}clearNfcList(){this.nfcList=[]}clearBluetoothList(){this.bluetoothList=[]}getDevToolOptions(){return this.devToolOptions}setDevToolOptions(t){var f,g,S;this.devToolOptions=t,this.transferMaxSize=t.uploadMaxSize||1e3,this.consoleMaxSize=t.consoleMaxSize||1e3,this.networkMaxSize=t.networkMaxSize||1e3,this.wsDataMaxSize=t.wsDataMaxSize||1e3,this.elEventListMaxSize=t.elEventListMaxSize||1e3,this.uniEventListMaxSize=t.uniEventListMaxSize||1e3,this.screenMaxSize=t.screenMaxSize||1e3,this.scanCodeListMaxSize=t.scanCodeListMaxSize||1e3,this.nfcListMaxSize=t.nfcListMaxSize||1e3,this.devToolVersion=t.devToolVersion??"0.0.0",this.devToolBuildTime=t.devToolBuildTime??"",this.devToolGit=t.devToolGit??"";const{devToolButtonVisible:e,useTransition:s=!0,baseFontSize:n=12,tagFontSize:i=10,tipsFontSize:l=10,fontFamily:r="",fontWeight:L="normal",cacheInterceptConfig:p=!0,cacheNetworkLog:a=!1,cacheConsoleLog:c=!1,barrageVisible:v=!0,barrageShowWhenOpen:d=!1}=o.getDevToolInfo();this.devToolVisible=D.isBoolean(e)?e:t.initShowDevTool??!0,this.useTransition=s,this.baseFontSize=n,this.tagFontSize=i,this.tipsFontSize=l,this.fontFamily=r,this.fontWeight=L,this.cacheInterceptConfig=p,this.cacheNetworkLog=a,this.cacheConsoleLog=c,this.barrageVisible=v,this.barrageShowWhenOpen=d,this.cacheNetworkLog&&(this.networkList=o.getDevToolNetworkList(),this.requestIndex=Math.max(...this.networkList.map(u=>u.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=o.getDevToolConsoleList()),this.setDevToolVisible(this.devToolVisible),this.setDevToolDestroy(!this.devToolVisible);const h=((f=t.pagesJson)==null?void 0:f.pages.map(u=>{var T,w,k;return{...u,type:(k=(w=(T=t.pagesJson)==null?void 0:T.tabBar)==null?void 0:w.list)!=null&&k.some(I=>I.pagePath===u.path)?"nav":"main"}}))??[];(S=(g=t.pagesJson)==null?void 0:g.subPackages)==null||S.forEach(u=>{u.pages.forEach(T=>{h.push({...T,path:`${u.root}/${T.path}`,type:"sub",uvList:[]})})}),this.setRouteList(h)}async getDevData(){const t=await uni.getNetworkType()||{};this.setNetWorkStatus(t);let e="0.0.0.0";try{uni.__dev_tool_platform__==="app"?e=x.getWifiIp()||x.getLanIp()||"0.0.0.0":uni.__dev_tool_platform__==="mp-weixin"&&(e=await x.getMicroAppIp())}catch(s){console.error("[DevTool] Get IP error",s)}return{consoleList:this.consoleList,networkList:this.networkList,storageList:this.storageList,routeList:this.routeList,vuexList:this.vuexList,piniaList:this.piniaList,wsList:this.wsList,transferList:this.transferList,elEventList:this.elEventList,uniEventList:this.uniEventList,eventCount:this.eventCount,screenList:this.screenList,scanCodeList:this.scanCodeList,nfcList:this.nfcList,bluetoothList:this.bluetoothList,systemInfo:this.systemInfo,deviceInfo:this.deviceInfo,windowInfo:this.windowInfo,netWorkStatus:{ip:e,...t,isConnected:t.networkType!=="none"},devToolVisible:this.getDevToolVisible(),cacheInterceptConfig:this.cacheInterceptConfig,cacheNetworkLog:this.cacheNetworkLog,cacheConsoleLog:this.cacheConsoleLog,useTransition:this.useTransition,baseFontSize:this.baseFontSize,tagFontSize:this.tagFontSize,tipsFontSize:this.tipsFontSize,fontFamily:this.fontFamily,fontWeight:this.fontWeight,barrageVisible:this.barrageVisible,barrageMaxTracks:this.barrageMaxTracks,barrageTrackHeight:this.barrageTrackHeight,barrageStartTop:this.barrageStartTop,barrageDuration:this.barrageDuration,barrageMaxLength:this.barrageMaxLength,barrageTypes:[...this.barrageTypes],barrageShowWhenOpen:this.barrageShowWhenOpen,devToolVersion:this.devToolVersion,devToolBuildTime:this.devToolBuildTime,devToolGit:this.devToolGit,totalConsoleCount:this.totalConsoleCount,totalNetworkCount:this.totalNetworkCount}}getExportData(t){const e={};return t.exportLog&&(e.consoleList=this.consoleList),t.exportNetwork&&(e.networkList=this.networkList),t.exportStorage&&(e.storageList=this.storageList,e.vuexList=this.vuexList,e.piniaList=this.piniaList),t.exportTransfer&&(e.transferList=this.transferList),t.exportWebSocket&&(e.wsList=this.wsList),t.exportWindow&&(e.windowInfo=uni.getWindowInfo?uni.getWindowInfo():{errMsg:"not supported"}),t.exportDevice&&(e.deviceInfo=uni.getDeviceInfo?uni.getDeviceInfo():{errMsg:"not supported"}),t.exportSystem&&(e.systemInfo=uni.getSystemInfo?uni.getSystemInfo():{errMsg:"not supported"}),t.exportUniEvent&&(e.uniEventList=this.uniEventList),t.exportElEvent&&(e.elEventList=this.elEventList),t.exportScanCodeList&&(e.scanCodeList=this.scanCodeList),t.exportNfcList&&(e.nfcList=this.nfcList),e}clearDevCache(){this.consoleList=[],this.networkList=[],this.wsList=[],this.transferList=[],this.elEventList=[],this.uniEventList=[],this.screenList=[],this.scanCodeList=[],this.nfcList=[],this.bluetoothList=[],this.cacheConsoleLog&&o.setDevToolConsoleList([]),this.cacheNetworkLog&&o.setDevToolNetworkList([])}clearAll(){this.clearDevCache(),this.storageList=[],this.routeList=[],this.interceptNetworkMap.clear()}getCurrentPagePath(){return b.getCurrentPagePath()}}exports.DevStore=z;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("../../const.cjs");require("../../utils/index.cjs");const o=require("../devToolInfo/index.cjs"),C=require("../../utils/function.cjs"),D=require("../../utils/language.cjs"),y=require("../../utils/object.cjs"),b=require("../../utils/page.cjs"),x=require("../../utils/ip.cjs");class z{constructor(){if(this.consoleList=[],this.consoleMaxSize=1e3,this.totalConsoleCount=0,this.networkList=[],this.networkMaxSize=1e3,this.totalNetworkCount=0,this.interceptNetworkMap=new Map,this.requestIndex=-1,this.storageList=[],this.vuexList={},this.piniaList={},this.routeList=[],this.prePath="",this.wsList=[],this.wsDataMaxSize=1e3,this.wsTaskMap=new Map,this.transferList=[],this.transferMaxSize=1e3,this.transferIndex=-1,this.transferTaskMap=new Map,this.elEventList=[],this.uniEventList=[],this.eventCount={on:0,once:0,emit:0,off:0},this.elEventListMaxSize=1e3,this.uniEventListMaxSize=1e3,this.screenList=[],this.scanCodeList=[],this.nfcList=[],this.bluetoothList=[],this.screenIndex=-1,this.screenMaxSize=1e3,this.scanCodeListMaxSize=1e3,this.nfcListMaxSize=1e3,this.systemInfo={},this.deviceInfo={},this.windowInfo={},this.netWorkStatus={},this.devToolVersion="0.0.0",this.devToolBuildTime="",this.devToolGit="",this.devToolVisible=!1,this.devToolDestroy=!1,this.cacheInterceptConfig=!0,this.useTransition=!0,this.cacheNetworkLog=!1,this.cacheConsoleLog=!1,this.baseFontSize=12,this.tagFontSize=10,this.tipsFontSize=10,this.fontFamily="",this.fontWeight="normal",this.barrageVisible=!0,this.barrageMaxTracks=10,this.barrageTrackHeight=36,this.barrageStartTop=40,this.barrageDuration=6,this.barrageMaxLength=100,this.barrageTypes=["log","info","warn","error","network","transfer","websocket"],this.barrageShowWhenOpen=!1,this.saveConsoleLogThrottled=C.throttle(()=>{this.cacheConsoleLog&&o.setDevToolConsoleList(this.consoleList)},1e3),this.saveNetworkLogThrottled=C.throttle(()=>{this.cacheNetworkLog&&o.setDevToolNetworkList(this.networkList)},1e3),this.cacheMaxSize=8*1024*1024*10,typeof uni<"u"){const{devToolDestroy:t=!1,devToolButtonVisible:e=!1,cacheInterceptConfig:s=!0,cacheNetworkLog:n=!1,cacheConsoleLog:i=!1,useTransition:h=!0,baseFontSize:r=12,tagFontSize:L=10,tipsFontSize:p=10,fontFamily:a="",fontWeight:c="normal",barrageVisible:v=!0,barrageMaxTracks:d=10,barrageTrackHeight:l=36,barrageStartTop:f=40,barrageDuration:u=6,barrageMaxLength:S=100,barrageTypes:g=["log","info","warn","error","network","transfer","websocket"],barrageShowWhenOpen:T=!1,interceptNetworkList:w=[]}=uni.getStorageSync(M.DEV_TOOL_INFO)||{};this.devToolDestroy=t,this.devToolVisible=e,this.cacheInterceptConfig=s,this.cacheNetworkLog=n,this.cacheConsoleLog=i,this.useTransition=h,this.baseFontSize=r,this.tagFontSize=L,this.tipsFontSize=p,this.fontFamily=a,this.fontWeight=c,this.barrageVisible=v,this.barrageMaxTracks=d,this.barrageTrackHeight=l,this.barrageStartTop=f,this.barrageDuration=u,this.barrageMaxLength=S,this.barrageTypes=g,this.barrageShowWhenOpen=T,this.updateInterceptNetworkList(w),this.cacheNetworkLog&&(this.networkList=o.getDevToolNetworkList(),this.requestIndex=Math.max(...this.networkList.map(k=>k.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=o.getDevToolConsoleList()),this.totalConsoleCount=this.consoleList.length,this.totalNetworkCount=this.networkList.length}}updateHasUpload(){this.consoleList=this.consoleList.map(t=>({...t,hasUpload:!0})),this.networkList=this.networkList.map(t=>({...t,hasUpload:!0})),this.transferList=this.transferList.map(t=>({...t,hasUpload:!0})),this.elEventList=this.elEventList.map(t=>({...t,hasUpload:!0})),this.uniEventList=this.uniEventList.map(t=>({...t,hasUpload:!0})),this.screenList=this.screenList.map(t=>({...t,hasUpload:!0}))}setDevToolVisible(t){this.devToolVisible=t,o.setDevToolInfo({devToolButtonVisible:t})}getDevToolVisible(){return this.devToolVisible}setDevToolDestroy(t){this.devToolDestroy=t,o.setDevToolInfo({devToolDestroy:t})}getDevToolDestroy(){return this.devToolDestroy}setCacheInterceptConfig(t){this.cacheInterceptConfig=t,o.setDevToolInfo({cacheInterceptConfig:t})}getCacheNetworkLog(){return this.cacheNetworkLog}setUseTransition(t){this.useTransition=t,o.setDevToolInfo({useTransition:t})}setBaseFontSize(t){this.baseFontSize=t,o.setDevToolInfo({baseFontSize:t})}setTagFontSize(t){this.tagFontSize=t,o.setDevToolInfo({tagFontSize:t})}setTipsFontSize(t){this.tipsFontSize=t,o.setDevToolInfo({tipsFontSize:t})}setFontFamily(t){this.fontFamily=t,o.setDevToolInfo({fontFamily:t})}setFontWeight(t){this.fontWeight=t,o.setDevToolInfo({fontWeight:t})}setBarrageVisible(t){this.barrageVisible=t,o.setDevToolInfo({barrageVisible:t})}setBarrageMaxTracks(t){this.barrageMaxTracks=t,o.setDevToolInfo({barrageMaxTracks:t})}setBarrageTrackHeight(t){this.barrageTrackHeight=t,o.setDevToolInfo({barrageTrackHeight:t})}setBarrageStartTop(t){this.barrageStartTop=t,o.setDevToolInfo({barrageStartTop:t})}setBarrageDuration(t){this.barrageDuration=t,o.setDevToolInfo({barrageDuration:t})}setBarrageMaxLength(t){this.barrageMaxLength=t,o.setDevToolInfo({barrageMaxLength:t})}setBarrageTypes(t){this.barrageTypes=t,o.setDevToolInfo({barrageTypes:t})}setBarrageShowWhenOpen(t){this.barrageShowWhenOpen=t,o.setDevToolInfo({barrageShowWhenOpen:t})}setCacheConsoleLog(t){this.cacheConsoleLog=t,o.setDevToolInfo({cacheConsoleLog:t}),t?o.setDevToolConsoleList(this.consoleList):o.setDevToolConsoleList([])}setCacheNetworkLog(t){this.cacheNetworkLog=t,o.setDevToolInfo({cacheNetworkLog:t}),t?o.setDevToolNetworkList(this.networkList):o.setDevToolNetworkList([])}getConsoleList(){return this.consoleList}updateConsoleList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.consoleList[e]&&(this.consoleList[e]=t[0]):(this.consoleList.push(...t),this.totalConsoleCount+=t.length,this.consoleList.length>this.consoleMaxSize&&(this.consoleList=this.consoleList.slice(-this.consoleMaxSize))),this.saveConsoleLogThrottled()}clearConsoleList(){this.consoleList=[],this.totalConsoleCount=0,this.cacheConsoleLog&&o.setDevToolConsoleList([])}getNetworkList(){return this.networkList}updateNetworkList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.networkList[e]&&(this.networkList[e]=t[0]):(this.networkList.push(...t),this.totalNetworkCount+=t.length,this.networkList.length>this.networkMaxSize&&(this.networkList=this.networkList.slice(-this.networkMaxSize))),this.saveNetworkLogThrottled()}clearNetworkList(){this.networkList=[],this.totalNetworkCount=0,this.cacheNetworkLog&&o.setDevToolNetworkList([])}getInterceptNetworkMap(){return this.interceptNetworkMap}getRequestIndex(){return this.requestIndex}setRequestIndex(t){return this.requestIndex=t,this.requestIndex}updateInterceptNetworkList(t){this.interceptNetworkMap.clear(),t.forEach(e=>{var n;const s=`${(n=e.method)==null?void 0:n.toUpperCase()}|${e.url}`;this.interceptNetworkMap.set(s,e)})}clearInterceptNetworkList(){this.clearNetworkList()}getStorageList(){return this.storageList}setStorageList(t){return this.storageList=t,this.storageList}getVuexList(){return this.vuexList}getPiniaList(){return this.piniaList}setVuexStore(t){this.vuexStore=t}setVuexList(t){this.vuexList=t}setPiniaStore(t){this.piniaStore=t}setPiniaList(t){this.piniaList={...this.piniaList||{},...t}}updateStore(t){const{key:e,_oldKey:s,value:n}=t;return s===e&&(uni.removeStorageSync(s),this.storageList=this.storageList.filter(i=>i.key!==s)),uni.setStorageSync(e,n),this.storageList}updateVuexStore(t){var e,s;try{Object.assign(((e=this.vuexStore)==null?void 0:e.state)??{},t)}catch(n){console.error("[DevTool] updateVuexStore error",n)}return this.setVuexList({...((s=this.vuexStore)==null?void 0:s.state)??{}}),this.vuexList}updatePiniaStore(t){try{if(!this.piniaStore)return{};const[e,s]=Object.entries(t)[0];if(D.isNil(e))return{};y.setValueByPath(this.piniaStore.state.value,e,s),this.setPiniaList({...this.piniaStore.state.value??{}})}catch(e){console.error("[DevTool] updatePiniaStore error",e)}return this.piniaList}clearStorageList(t){return this.storageList=[],t&&uni.clearStorage(),this.storageList}removeStorage(t,e){return this.storageList=this.storageList.filter(s=>s.key!==t),e&&uni.removeStorageSync(t),this.storageList}addStorage(t,e){const{key:s,value:n}=t;return this.storageList.unshift({key:s,_oldKey:s,value:n}),e&&uni.setStorageSync(s,n),this.storageList}refreshStore(){const{keys:t}=uni.getStorageInfoSync();return this.storageList=t.map(e=>{const s=uni.getStorageSync(e);return{key:e,_oldKey:e,value:s}}),this.storageList}updateStoreList(t){const e=t[0],s=this.storageList.findIndex(n=>n.key===e._oldKey);return s>-1&&t.length===1?this.storageList[s]=t[0]:this.storageList.push(...t),this.storageList}getRouteList(){return this.routeList}setRouteList(t,e){var n;const s=e||((n=t==null?void 0:t[0])==null?void 0:n.path)||"";return this.routeList=t.map((i,h)=>({...i,name:i.style.navigationBarTitleText||"无名",uvList:[],index:i.path===s&&h===0?4:i.path===s?3:h===0?2:1})),this.routeList}updateRouteList(t){const e=t?t==="/"?b.getCurrentPagePath():t:b.getCurrentPagePath(),s=this.prePath;this.routeList=this.routeList.map((r,L)=>({...r,index:r.path===e&&L===0?4:r.path===e?3:L===0?2:1}));const n=(r,L,p)=>{var v,d;if(!r[L])return r;r[L].uvList||(r[L].uvList=[]);const a=r[L],c=a.uvList??[];if(c.length){const l=c.length-1,f=c[l];if(f&&f.inTime&&!f.outTime){const u=Date.now();a.outTime=u,c[l].outTime=u,c[l].duration=u-f.inTime,a.duration=c[l].duration,a.totalDuration=c.reduce((S,g)=>S+(g.duration||0),0),p&&(a.visitTimes=c.length)}else{const u=Date.now();a.inTime=u,a.outTime=0,a.duration=0,(v=a.uvList)==null||v.push({index:l+1,inTime:u,outTime:0,duration:0}),p&&(a.visitTimes=(d=a.uvList)==null?void 0:d.length)}}else{const l=Date.now();a.inTime=l,a.outTime=0,a.duration=0,a.totalDuration=0,a.visitTimes=1,a.uvList=[{index:0,inTime:l,outTime:0,duration:0}]}return r},i=this.routeList.findIndex(r=>r.path===s),h=this.routeList.findIndex(r=>r.path===e);return i>-1&&n(this.routeList,i),h>-1&&n(this.routeList,h,!0),this.prePath=e,this.routeList}getWsList(){return this.wsList}updateWsList(t){var s,n;const e=this.wsList.findIndex(i=>i.url===t.url);if(e>-1){const i=this.wsList[e];i.headers=t.headers??i.headers,i.readyState=t.readyState??i.readyState,i.method=t.method??i.method,i.protocols=t.protocols??i.protocols,i.message=[...i.message??[],...t.message??[]];const h=this.wsDataMaxSize,r=((s=i.message)==null?void 0:s.length)??0;r>h&&((n=i.message)==null||n.splice(0,r-h))}else this.wsList.push(t);return this.wsList}clearWsList(){this.wsList=[]}clearWsMessage(t){const e=this.wsList.findIndex(s=>s.url===t);e>-1&&(this.wsList[e].message=[])}addWsTask(t,e){this.wsTaskMap.set(t,e)}removeWsTask(t){this.wsTaskMap.delete(t)}getWsTask(t){const e=this.wsTaskMap.get(t);if(e)return e;if(!t)return;let s;return this.wsTaskMap.forEach((n,i)=>{s||i&&(i.includes(t)||t.includes(i))&&(s=n)}),s}getTransferList(){return this.transferList}updateTransferList(t,e){if(typeof e=="number"&&e>-1&&t.length===1){const s=t[0],n=this.transferList.findIndex(i=>i.index===e);n>-1?this.transferList[n]={...this.transferList[n],...s}:this.transferList.push(s)}else this.transferList.length+t.length>this.transferMaxSize&&(this.transferList=[]),this.transferList.push(...t)}getTransferIndex(){return this.transferIndex}setTransferIndex(t){return this.transferIndex=t,this.transferIndex}addTransferTask(t,e){this.transferTaskMap.set(t,e)}removeTransferTask(t){this.transferTaskMap.delete(t)}clearTransferTask(){this.transferTaskMap.clear()}getElEventList(){return this.elEventList}getUniEventList(){return this.uniEventList}getEventCount(){return this.eventCount}addElEvent(t){this.elEventList.length>=this.elEventListMaxSize&&this.elEventList.shift(),this.elEventList.push(t)}clearElEventList(){this.elEventList=[]}updateUniEventList(t){this.uniEventList.length+t.length>this.uniEventListMaxSize&&(this.uniEventList=[]),this.uniEventList.push(...t)}updateUniEventCount(t){this.eventCount[t]++}clearUniEventList(){this.uniEventList=[],this.eventCount={on:0,once:0,emit:0,off:0}}getScreenList(){return this.screenList}getScanCodeList(){return this.scanCodeList}getNfcList(){return this.nfcList}getScreenIndex(){return this.screenIndex}setScreenIndex(t){return this.screenIndex=t,this.screenIndex}getSystemInfo(){return this.systemInfo}getDeviceInfo(){return this.deviceInfo}getWindowInfo(){return this.windowInfo}setSystemInfo(t){this.systemInfo=t}setDeviceInfo(t){this.deviceInfo=t}setWindowInfo(t){this.windowInfo=t}setNetWorkStatus(t){this.netWorkStatus=t}updateScreenList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.screenList[e]&&(this.screenList[e]=t[0]):(this.screenList.length+t.length>this.screenMaxSize&&(this.screenList=[]),this.screenList.push(...t))}updateScanCodeList(t){this.scanCodeList.length+t.length>this.scanCodeListMaxSize&&(this.scanCodeList=[]),this.scanCodeList.push(...t)}updateNfcList(t){this.nfcList.length+t.length>this.nfcListMaxSize&&(this.nfcList=[]),this.nfcList.push(...t)}updateBluetoothList(t){this.bluetoothList=t}clearScanCodeList(){this.scanCodeList=[]}clearNfcList(){this.nfcList=[]}clearBluetoothList(){this.bluetoothList=[]}getDevToolOptions(){return this.devToolOptions}setDevToolOptions(t){var f,u,S;this.devToolOptions=t,this.transferMaxSize=t.uploadMaxSize||1e3,this.consoleMaxSize=t.consoleMaxSize||1e3,this.networkMaxSize=t.networkMaxSize||1e3,this.wsDataMaxSize=t.wsDataMaxSize||1e3,this.elEventListMaxSize=t.elEventListMaxSize||1e3,this.uniEventListMaxSize=t.uniEventListMaxSize||1e3,this.screenMaxSize=t.screenMaxSize||1e3,this.scanCodeListMaxSize=t.scanCodeListMaxSize||1e3,this.nfcListMaxSize=t.nfcListMaxSize||1e3,this.devToolVersion=t.devToolVersion??"0.0.0",this.devToolBuildTime=t.devToolBuildTime??"",this.devToolGit=t.devToolGit??"";const{devToolButtonVisible:e,useTransition:s=!0,baseFontSize:n=12,tagFontSize:i=10,tipsFontSize:h=10,fontFamily:r="",fontWeight:L="normal",cacheInterceptConfig:p=!0,cacheNetworkLog:a=!1,cacheConsoleLog:c=!1,barrageVisible:v=!0,barrageShowWhenOpen:d=!1}=o.getDevToolInfo();this.devToolVisible=D.isBoolean(e)?e:t.initShowDevTool??!0,this.useTransition=s,this.baseFontSize=n,this.tagFontSize=i,this.tipsFontSize=h,this.fontFamily=r,this.fontWeight=L,this.cacheInterceptConfig=p,this.cacheNetworkLog=a,this.cacheConsoleLog=c,this.barrageVisible=v,this.barrageShowWhenOpen=d,this.cacheNetworkLog&&(this.networkList=o.getDevToolNetworkList(),this.requestIndex=Math.max(...this.networkList.map(g=>g.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=o.getDevToolConsoleList()),this.setDevToolVisible(this.devToolVisible),this.setDevToolDestroy(!this.devToolVisible);const l=((f=t.pagesJson)==null?void 0:f.pages.map(g=>{var T,w,k;return{...g,type:(k=(w=(T=t.pagesJson)==null?void 0:T.tabBar)==null?void 0:w.list)!=null&&k.some(I=>I.pagePath===g.path)?"nav":"main"}}))??[];(S=(u=t.pagesJson)==null?void 0:u.subPackages)==null||S.forEach(g=>{g.pages.forEach(T=>{l.push({...T,path:`${g.root}/${T.path}`,type:"sub",uvList:[]})})}),this.setRouteList(l)}async getDevData(){var s,n,i,h;const t=await uni.getNetworkType()||{};this.setNetWorkStatus(t);let e="0.0.0.0";try{uni.__dev_tool_platform__==="app"?e=x.getWifiIp()||x.getLanIp()||"0.0.0.0":uni.__dev_tool_platform__==="mp-weixin"&&(e=await x.getMicroAppIp())}catch(r){console.error("[DevTool] Get IP error",r)}return{consoleList:this.consoleList,networkList:this.networkList,storageList:this.storageList,routeList:this.routeList,vuexList:this.vuexList,piniaList:this.piniaList,wsList:this.wsList,transferList:this.transferList,elEventList:this.elEventList,uniEventList:this.uniEventList,eventCount:this.eventCount,screenList:this.screenList,scanCodeList:this.scanCodeList,nfcList:this.nfcList,bluetoothList:this.bluetoothList,systemInfo:this.systemInfo,deviceInfo:this.deviceInfo,windowInfo:this.windowInfo,netWorkStatus:{ip:e,...t,isConnected:t.networkType!=="none"},devToolVisible:this.getDevToolVisible(),cacheInterceptConfig:this.cacheInterceptConfig,cacheNetworkLog:this.cacheNetworkLog,cacheConsoleLog:this.cacheConsoleLog,useTransition:this.useTransition,baseFontSize:this.baseFontSize,tagFontSize:this.tagFontSize,tipsFontSize:this.tipsFontSize,fontFamily:this.fontFamily,fontWeight:this.fontWeight,barrageVisible:this.barrageVisible,barrageMaxTracks:this.barrageMaxTracks,barrageTrackHeight:this.barrageTrackHeight,barrageStartTop:this.barrageStartTop,barrageDuration:this.barrageDuration,barrageMaxLength:this.barrageMaxLength,barrageTypes:[...this.barrageTypes],barrageShowWhenOpen:this.barrageShowWhenOpen,devToolVersion:this.devToolVersion,devToolBuildTime:this.devToolBuildTime,devToolGit:this.devToolGit,sourceFileServers:(s=this.devToolOptions)==null?void 0:s.sourceFileServers,mode:(n=this.devToolOptions)==null?void 0:n.mode,useDevSource:(i=this.devToolOptions)==null?void 0:i.useDevSource,zIndex:(h=this.devToolOptions)==null?void 0:h.zIndex,totalConsoleCount:this.totalConsoleCount,totalNetworkCount:this.totalNetworkCount}}getExportData(t){const e={};return t.exportLog&&(e.consoleList=this.consoleList),t.exportNetwork&&(e.networkList=this.networkList),t.exportStorage&&(e.storageList=this.storageList,e.vuexList=this.vuexList,e.piniaList=this.piniaList),t.exportTransfer&&(e.transferList=this.transferList),t.exportWebSocket&&(e.wsList=this.wsList),t.exportWindow&&(e.windowInfo=uni.getWindowInfo?uni.getWindowInfo():{errMsg:"not supported"}),t.exportDevice&&(e.deviceInfo=uni.getDeviceInfo?uni.getDeviceInfo():{errMsg:"not supported"}),t.exportSystem&&(e.systemInfo=uni.getSystemInfo?uni.getSystemInfo():{errMsg:"not supported"}),t.exportUniEvent&&(e.uniEventList=this.uniEventList),t.exportElEvent&&(e.elEventList=this.elEventList),t.exportScanCodeList&&(e.scanCodeList=this.scanCodeList),t.exportNfcList&&(e.nfcList=this.nfcList),e}clearDevCache(){this.consoleList=[],this.networkList=[],this.wsList=[],this.transferList=[],this.elEventList=[],this.uniEventList=[],this.screenList=[],this.scanCodeList=[],this.nfcList=[],this.bluetoothList=[],this.cacheConsoleLog&&o.setDevToolConsoleList([]),this.cacheNetworkLog&&o.setDevToolNetworkList([])}clearAll(){this.clearDevCache(),this.storageList=[],this.routeList=[],this.interceptNetworkMap.clear()}getCurrentPagePath(){return b.getCurrentPagePath()}}exports.DevStore=z;
|
|
@@ -1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AAW;IAOpC,gBAAgB;IAIhB,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,YAAY,EAAE;IAOhD,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa;IAI/C,iBAAiB;IAMjB,aAAa;IAIb,eAAe;IAIf,UAAU;IAIV,cAAc;IAId,cAAc,CAAC,KAAK,EAAE,MAAM;IAK5B,aAAa;IAIb,aAAa;IAIb,aAAa;IAIb,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAIvC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAIvC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAIvC,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAI1C,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM;IAU/D,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,EAAE;IAMnD,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE;IAMzC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,aAAa,EAAE;IAIrD,iBAAiB;IAIjB,YAAY;IAIZ,kBAAkB;IAKlB,iBAAiB;IAIjB,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc;IAqF3C,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;IAqE/C,aAAa,CAAC,OAAO,EAAE,GAAG;IA+B1B,aAAa;IAqBb,QAAQ;IAOR,kBAAkB;CAGnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DEV_TOOL_INFO as I}from"../../const.js";import"../../utils/index.js";import{setDevToolConsoleList as w,setDevToolNetworkList as k,getDevToolNetworkList as M,getDevToolConsoleList as m,setDevToolInfo as a,getDevToolInfo as D}from"../devToolInfo/index.js";import{throttle as y}from"../../utils/function.js";import{isNil as E,isBoolean as N}from"../../utils/language.js";import{setValueByPath as F}from"../../utils/object.js";import{getCurrentPagePath as C}from"../../utils/page.js";import{getWifiIp as W,getLanIp as V,getMicroAppIp as B}from"../../utils/ip.js";class J{constructor(){if(this.consoleList=[],this.consoleMaxSize=1e3,this.totalConsoleCount=0,this.networkList=[],this.networkMaxSize=1e3,this.totalNetworkCount=0,this.interceptNetworkMap=new Map,this.requestIndex=-1,this.storageList=[],this.vuexList={},this.piniaList={},this.routeList=[],this.prePath="",this.wsList=[],this.wsDataMaxSize=1e3,this.wsTaskMap=new Map,this.transferList=[],this.transferMaxSize=1e3,this.transferIndex=-1,this.transferTaskMap=new Map,this.elEventList=[],this.uniEventList=[],this.eventCount={on:0,once:0,emit:0,off:0},this.elEventListMaxSize=1e3,this.uniEventListMaxSize=1e3,this.screenList=[],this.scanCodeList=[],this.nfcList=[],this.bluetoothList=[],this.screenIndex=-1,this.screenMaxSize=1e3,this.scanCodeListMaxSize=1e3,this.nfcListMaxSize=1e3,this.systemInfo={},this.deviceInfo={},this.windowInfo={},this.netWorkStatus={},this.devToolVersion="0.0.0",this.devToolBuildTime="",this.devToolGit="",this.devToolVisible=!1,this.devToolDestroy=!1,this.cacheInterceptConfig=!0,this.useTransition=!0,this.cacheNetworkLog=!1,this.cacheConsoleLog=!1,this.baseFontSize=12,this.tagFontSize=10,this.tipsFontSize=10,this.fontFamily="",this.fontWeight="normal",this.barrageVisible=!0,this.barrageMaxTracks=10,this.barrageTrackHeight=36,this.barrageStartTop=40,this.barrageDuration=6,this.barrageMaxLength=100,this.barrageTypes=["log","info","warn","error","network","transfer","websocket"],this.barrageShowWhenOpen=!1,this.saveConsoleLogThrottled=y(()=>{this.cacheConsoleLog&&w(this.consoleList)},1e3),this.saveNetworkLogThrottled=y(()=>{this.cacheNetworkLog&&k(this.networkList)},1e3),this.cacheMaxSize=8*1024*1024*10,typeof uni<"u"){const{devToolDestroy:t=!1,devToolButtonVisible:e=!1,cacheInterceptConfig:s=!0,cacheNetworkLog:o=!1,cacheConsoleLog:i=!1,useTransition:c=!0,baseFontSize:r=12,tagFontSize:l=10,tipsFontSize:T=10,fontFamily:n="",fontWeight:L="normal",barrageVisible:d=!0,barrageMaxTracks:S=10,barrageTrackHeight:h=36,barrageStartTop:f=40,barrageDuration:g=6,barrageMaxLength:v=100,barrageTypes:u=["log","info","warn","error","network","transfer","websocket"],barrageShowWhenOpen:p=!1,interceptNetworkList:b=[]}=uni.getStorageSync(I)||{};this.devToolDestroy=t,this.devToolVisible=e,this.cacheInterceptConfig=s,this.cacheNetworkLog=o,this.cacheConsoleLog=i,this.useTransition=c,this.baseFontSize=r,this.tagFontSize=l,this.tipsFontSize=T,this.fontFamily=n,this.fontWeight=L,this.barrageVisible=d,this.barrageMaxTracks=S,this.barrageTrackHeight=h,this.barrageStartTop=f,this.barrageDuration=g,this.barrageMaxLength=v,this.barrageTypes=u,this.barrageShowWhenOpen=p,this.updateInterceptNetworkList(b),this.cacheNetworkLog&&(this.networkList=M(),this.requestIndex=Math.max(...this.networkList.map(x=>x.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=m()),this.totalConsoleCount=this.consoleList.length,this.totalNetworkCount=this.networkList.length}}updateHasUpload(){this.consoleList=this.consoleList.map(t=>({...t,hasUpload:!0})),this.networkList=this.networkList.map(t=>({...t,hasUpload:!0})),this.transferList=this.transferList.map(t=>({...t,hasUpload:!0})),this.elEventList=this.elEventList.map(t=>({...t,hasUpload:!0})),this.uniEventList=this.uniEventList.map(t=>({...t,hasUpload:!0})),this.screenList=this.screenList.map(t=>({...t,hasUpload:!0}))}setDevToolVisible(t){this.devToolVisible=t,a({devToolButtonVisible:t})}getDevToolVisible(){return this.devToolVisible}setDevToolDestroy(t){this.devToolDestroy=t,a({devToolDestroy:t})}getDevToolDestroy(){return this.devToolDestroy}setCacheInterceptConfig(t){this.cacheInterceptConfig=t,a({cacheInterceptConfig:t})}getCacheNetworkLog(){return this.cacheNetworkLog}setUseTransition(t){this.useTransition=t,a({useTransition:t})}setBaseFontSize(t){this.baseFontSize=t,a({baseFontSize:t})}setTagFontSize(t){this.tagFontSize=t,a({tagFontSize:t})}setTipsFontSize(t){this.tipsFontSize=t,a({tipsFontSize:t})}setFontFamily(t){this.fontFamily=t,a({fontFamily:t})}setFontWeight(t){this.fontWeight=t,a({fontWeight:t})}setBarrageVisible(t){this.barrageVisible=t,a({barrageVisible:t})}setBarrageMaxTracks(t){this.barrageMaxTracks=t,a({barrageMaxTracks:t})}setBarrageTrackHeight(t){this.barrageTrackHeight=t,a({barrageTrackHeight:t})}setBarrageStartTop(t){this.barrageStartTop=t,a({barrageStartTop:t})}setBarrageDuration(t){this.barrageDuration=t,a({barrageDuration:t})}setBarrageMaxLength(t){this.barrageMaxLength=t,a({barrageMaxLength:t})}setBarrageTypes(t){this.barrageTypes=t,a({barrageTypes:t})}setBarrageShowWhenOpen(t){this.barrageShowWhenOpen=t,a({barrageShowWhenOpen:t})}setCacheConsoleLog(t){this.cacheConsoleLog=t,a({cacheConsoleLog:t}),t?w(this.consoleList):w([])}setCacheNetworkLog(t){this.cacheNetworkLog=t,a({cacheNetworkLog:t}),t?k(this.networkList):k([])}getConsoleList(){return this.consoleList}updateConsoleList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.consoleList[e]&&(this.consoleList[e]=t[0]):(this.consoleList.push(...t),this.totalConsoleCount+=t.length,this.consoleList.length>this.consoleMaxSize&&(this.consoleList=this.consoleList.slice(-this.consoleMaxSize))),this.saveConsoleLogThrottled()}clearConsoleList(){this.consoleList=[],this.totalConsoleCount=0,this.cacheConsoleLog&&w([])}getNetworkList(){return this.networkList}updateNetworkList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.networkList[e]&&(this.networkList[e]=t[0]):(this.networkList.push(...t),this.totalNetworkCount+=t.length,this.networkList.length>this.networkMaxSize&&(this.networkList=this.networkList.slice(-this.networkMaxSize))),this.saveNetworkLogThrottled()}clearNetworkList(){this.networkList=[],this.totalNetworkCount=0,this.cacheNetworkLog&&k([])}getInterceptNetworkMap(){return this.interceptNetworkMap}getRequestIndex(){return this.requestIndex}setRequestIndex(t){return this.requestIndex=t,this.requestIndex}updateInterceptNetworkList(t){this.interceptNetworkMap.clear(),t.forEach(e=>{var o;const s=`${(o=e.method)==null?void 0:o.toUpperCase()}|${e.url}`;this.interceptNetworkMap.set(s,e)})}clearInterceptNetworkList(){this.clearNetworkList()}getStorageList(){return this.storageList}setStorageList(t){return this.storageList=t,this.storageList}getVuexList(){return this.vuexList}getPiniaList(){return this.piniaList}setVuexStore(t){this.vuexStore=t}setVuexList(t){this.vuexList=t}setPiniaStore(t){this.piniaStore=t}setPiniaList(t){this.piniaList={...this.piniaList||{},...t}}updateStore(t){const{key:e,_oldKey:s,value:o}=t;return s===e&&(uni.removeStorageSync(s),this.storageList=this.storageList.filter(i=>i.key!==s)),uni.setStorageSync(e,o),this.storageList}updateVuexStore(t){var e,s;try{Object.assign(((e=this.vuexStore)==null?void 0:e.state)??{},t)}catch(o){console.error("[DevTool] updateVuexStore error",o)}return this.setVuexList({...((s=this.vuexStore)==null?void 0:s.state)??{}}),this.vuexList}updatePiniaStore(t){try{if(!this.piniaStore)return{};const[e,s]=Object.entries(t)[0];if(E(e))return{};F(this.piniaStore.state.value,e,s),this.setPiniaList({...this.piniaStore.state.value??{}})}catch(e){console.error("[DevTool] updatePiniaStore error",e)}return this.piniaList}clearStorageList(t){return this.storageList=[],t&&uni.clearStorage(),this.storageList}removeStorage(t,e){return this.storageList=this.storageList.filter(s=>s.key!==t),e&&uni.removeStorageSync(t),this.storageList}addStorage(t,e){const{key:s,value:o}=t;return this.storageList.unshift({key:s,_oldKey:s,value:o}),e&&uni.setStorageSync(s,o),this.storageList}refreshStore(){const{keys:t}=uni.getStorageInfoSync();return this.storageList=t.map(e=>{const s=uni.getStorageSync(e);return{key:e,_oldKey:e,value:s}}),this.storageList}updateStoreList(t){const e=t[0],s=this.storageList.findIndex(o=>o.key===e._oldKey);return s>-1&&t.length===1?this.storageList[s]=t[0]:this.storageList.push(...t),this.storageList}getRouteList(){return this.routeList}setRouteList(t,e){var o;const s=e||((o=t==null?void 0:t[0])==null?void 0:o.path)||"";return this.routeList=t.map((i,c)=>({...i,name:i.style.navigationBarTitleText||"无名",uvList:[],index:i.path===s&&c===0?4:i.path===s?3:c===0?2:1})),this.routeList}updateRouteList(t){const e=t?t==="/"?C():t:C(),s=this.prePath;this.routeList=this.routeList.map((r,l)=>({...r,index:r.path===e&&l===0?4:r.path===e?3:l===0?2:1}));const o=(r,l,T)=>{var d,S;if(!r[l])return r;r[l].uvList||(r[l].uvList=[]);const n=r[l],L=n.uvList??[];if(L.length){const h=L.length-1,f=L[h];if(f&&f.inTime&&!f.outTime){const g=Date.now();n.outTime=g,L[h].outTime=g,L[h].duration=g-f.inTime,n.duration=L[h].duration,n.totalDuration=L.reduce((v,u)=>v+(u.duration||0),0),T&&(n.visitTimes=L.length)}else{const g=Date.now();n.inTime=g,n.outTime=0,n.duration=0,(d=n.uvList)==null||d.push({index:h+1,inTime:g,outTime:0,duration:0}),T&&(n.visitTimes=(S=n.uvList)==null?void 0:S.length)}}else{const h=Date.now();n.inTime=h,n.outTime=0,n.duration=0,n.totalDuration=0,n.visitTimes=1,n.uvList=[{index:0,inTime:h,outTime:0,duration:0}]}return r},i=this.routeList.findIndex(r=>r.path===s),c=this.routeList.findIndex(r=>r.path===e);return i>-1&&o(this.routeList,i),c>-1&&o(this.routeList,c,!0),this.prePath=e,this.routeList}getWsList(){return this.wsList}updateWsList(t){var s,o;const e=this.wsList.findIndex(i=>i.url===t.url);if(e>-1){const i=this.wsList[e];i.headers=t.headers??i.headers,i.readyState=t.readyState??i.readyState,i.method=t.method??i.method,i.protocols=t.protocols??i.protocols,i.message=[...i.message??[],...t.message??[]];const c=this.wsDataMaxSize,r=((s=i.message)==null?void 0:s.length)??0;r>c&&((o=i.message)==null||o.splice(0,r-c))}else this.wsList.push(t);return this.wsList}clearWsList(){this.wsList=[]}clearWsMessage(t){const e=this.wsList.findIndex(s=>s.url===t);e>-1&&(this.wsList[e].message=[])}addWsTask(t,e){this.wsTaskMap.set(t,e)}removeWsTask(t){this.wsTaskMap.delete(t)}getWsTask(t){const e=this.wsTaskMap.get(t);if(e)return e;if(!t)return;let s;return this.wsTaskMap.forEach((o,i)=>{s||i&&(i.includes(t)||t.includes(i))&&(s=o)}),s}getTransferList(){return this.transferList}updateTransferList(t,e){if(typeof e=="number"&&e>-1&&t.length===1){const s=t[0],o=this.transferList.findIndex(i=>i.index===e);o>-1?this.transferList[o]={...this.transferList[o],...s}:this.transferList.push(s)}else this.transferList.length+t.length>this.transferMaxSize&&(this.transferList=[]),this.transferList.push(...t)}getTransferIndex(){return this.transferIndex}setTransferIndex(t){return this.transferIndex=t,this.transferIndex}addTransferTask(t,e){this.transferTaskMap.set(t,e)}removeTransferTask(t){this.transferTaskMap.delete(t)}clearTransferTask(){this.transferTaskMap.clear()}getElEventList(){return this.elEventList}getUniEventList(){return this.uniEventList}getEventCount(){return this.eventCount}addElEvent(t){this.elEventList.length>=this.elEventListMaxSize&&this.elEventList.shift(),this.elEventList.push(t)}clearElEventList(){this.elEventList=[]}updateUniEventList(t){this.uniEventList.length+t.length>this.uniEventListMaxSize&&(this.uniEventList=[]),this.uniEventList.push(...t)}updateUniEventCount(t){this.eventCount[t]++}clearUniEventList(){this.uniEventList=[],this.eventCount={on:0,once:0,emit:0,off:0}}getScreenList(){return this.screenList}getScanCodeList(){return this.scanCodeList}getNfcList(){return this.nfcList}getScreenIndex(){return this.screenIndex}setScreenIndex(t){return this.screenIndex=t,this.screenIndex}getSystemInfo(){return this.systemInfo}getDeviceInfo(){return this.deviceInfo}getWindowInfo(){return this.windowInfo}setSystemInfo(t){this.systemInfo=t}setDeviceInfo(t){this.deviceInfo=t}setWindowInfo(t){this.windowInfo=t}setNetWorkStatus(t){this.netWorkStatus=t}updateScreenList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.screenList[e]&&(this.screenList[e]=t[0]):(this.screenList.length+t.length>this.screenMaxSize&&(this.screenList=[]),this.screenList.push(...t))}updateScanCodeList(t){this.scanCodeList.length+t.length>this.scanCodeListMaxSize&&(this.scanCodeList=[]),this.scanCodeList.push(...t)}updateNfcList(t){this.nfcList.length+t.length>this.nfcListMaxSize&&(this.nfcList=[]),this.nfcList.push(...t)}updateBluetoothList(t){this.bluetoothList=t}clearScanCodeList(){this.scanCodeList=[]}clearNfcList(){this.nfcList=[]}clearBluetoothList(){this.bluetoothList=[]}getDevToolOptions(){return this.devToolOptions}setDevToolOptions(t){var f,g,v;this.devToolOptions=t,this.transferMaxSize=t.uploadMaxSize||1e3,this.consoleMaxSize=t.consoleMaxSize||1e3,this.networkMaxSize=t.networkMaxSize||1e3,this.wsDataMaxSize=t.wsDataMaxSize||1e3,this.elEventListMaxSize=t.elEventListMaxSize||1e3,this.uniEventListMaxSize=t.uniEventListMaxSize||1e3,this.screenMaxSize=t.screenMaxSize||1e3,this.scanCodeListMaxSize=t.scanCodeListMaxSize||1e3,this.nfcListMaxSize=t.nfcListMaxSize||1e3,this.devToolVersion=t.devToolVersion??"0.0.0",this.devToolBuildTime=t.devToolBuildTime??"",this.devToolGit=t.devToolGit??"";const{devToolButtonVisible:e,useTransition:s=!0,baseFontSize:o=12,tagFontSize:i=10,tipsFontSize:c=10,fontFamily:r="",fontWeight:l="normal",cacheInterceptConfig:T=!0,cacheNetworkLog:n=!1,cacheConsoleLog:L=!1,barrageVisible:d=!0,barrageShowWhenOpen:S=!1}=D();this.devToolVisible=N(e)?e:t.initShowDevTool??!0,this.useTransition=s,this.baseFontSize=o,this.tagFontSize=i,this.tipsFontSize=c,this.fontFamily=r,this.fontWeight=l,this.cacheInterceptConfig=T,this.cacheNetworkLog=n,this.cacheConsoleLog=L,this.barrageVisible=d,this.barrageShowWhenOpen=S,this.cacheNetworkLog&&(this.networkList=M(),this.requestIndex=Math.max(...this.networkList.map(u=>u.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=m()),this.setDevToolVisible(this.devToolVisible),this.setDevToolDestroy(!this.devToolVisible);const h=((f=t.pagesJson)==null?void 0:f.pages.map(u=>{var p,b,x;return{...u,type:(x=(b=(p=t.pagesJson)==null?void 0:p.tabBar)==null?void 0:b.list)!=null&&x.some(z=>z.pagePath===u.path)?"nav":"main"}}))??[];(v=(g=t.pagesJson)==null?void 0:g.subPackages)==null||v.forEach(u=>{u.pages.forEach(p=>{h.push({...p,path:`${u.root}/${p.path}`,type:"sub",uvList:[]})})}),this.setRouteList(h)}async getDevData(){const t=await uni.getNetworkType()||{};this.setNetWorkStatus(t);let e="0.0.0.0";try{uni.__dev_tool_platform__==="app"?e=W()||V()||"0.0.0.0":uni.__dev_tool_platform__==="mp-weixin"&&(e=await B())}catch(s){console.error("[DevTool] Get IP error",s)}return{consoleList:this.consoleList,networkList:this.networkList,storageList:this.storageList,routeList:this.routeList,vuexList:this.vuexList,piniaList:this.piniaList,wsList:this.wsList,transferList:this.transferList,elEventList:this.elEventList,uniEventList:this.uniEventList,eventCount:this.eventCount,screenList:this.screenList,scanCodeList:this.scanCodeList,nfcList:this.nfcList,bluetoothList:this.bluetoothList,systemInfo:this.systemInfo,deviceInfo:this.deviceInfo,windowInfo:this.windowInfo,netWorkStatus:{ip:e,...t,isConnected:t.networkType!=="none"},devToolVisible:this.getDevToolVisible(),cacheInterceptConfig:this.cacheInterceptConfig,cacheNetworkLog:this.cacheNetworkLog,cacheConsoleLog:this.cacheConsoleLog,useTransition:this.useTransition,baseFontSize:this.baseFontSize,tagFontSize:this.tagFontSize,tipsFontSize:this.tipsFontSize,fontFamily:this.fontFamily,fontWeight:this.fontWeight,barrageVisible:this.barrageVisible,barrageMaxTracks:this.barrageMaxTracks,barrageTrackHeight:this.barrageTrackHeight,barrageStartTop:this.barrageStartTop,barrageDuration:this.barrageDuration,barrageMaxLength:this.barrageMaxLength,barrageTypes:[...this.barrageTypes],barrageShowWhenOpen:this.barrageShowWhenOpen,devToolVersion:this.devToolVersion,devToolBuildTime:this.devToolBuildTime,devToolGit:this.devToolGit,totalConsoleCount:this.totalConsoleCount,totalNetworkCount:this.totalNetworkCount}}getExportData(t){const e={};return t.exportLog&&(e.consoleList=this.consoleList),t.exportNetwork&&(e.networkList=this.networkList),t.exportStorage&&(e.storageList=this.storageList,e.vuexList=this.vuexList,e.piniaList=this.piniaList),t.exportTransfer&&(e.transferList=this.transferList),t.exportWebSocket&&(e.wsList=this.wsList),t.exportWindow&&(e.windowInfo=uni.getWindowInfo?uni.getWindowInfo():{errMsg:"not supported"}),t.exportDevice&&(e.deviceInfo=uni.getDeviceInfo?uni.getDeviceInfo():{errMsg:"not supported"}),t.exportSystem&&(e.systemInfo=uni.getSystemInfo?uni.getSystemInfo():{errMsg:"not supported"}),t.exportUniEvent&&(e.uniEventList=this.uniEventList),t.exportElEvent&&(e.elEventList=this.elEventList),t.exportScanCodeList&&(e.scanCodeList=this.scanCodeList),t.exportNfcList&&(e.nfcList=this.nfcList),e}clearDevCache(){this.consoleList=[],this.networkList=[],this.wsList=[],this.transferList=[],this.elEventList=[],this.uniEventList=[],this.screenList=[],this.scanCodeList=[],this.nfcList=[],this.bluetoothList=[],this.cacheConsoleLog&&w([]),this.cacheNetworkLog&&k([])}clearAll(){this.clearDevCache(),this.storageList=[],this.routeList=[],this.interceptNetworkMap.clear()}getCurrentPagePath(){return C()}}export{J as DevStore};
|
|
1
|
+
import{DEV_TOOL_INFO as I}from"../../const.js";import"../../utils/index.js";import{setDevToolConsoleList as w,setDevToolNetworkList as k,getDevToolNetworkList as M,getDevToolConsoleList as m,setDevToolInfo as a,getDevToolInfo as D}from"../devToolInfo/index.js";import{throttle as z}from"../../utils/function.js";import{isNil as E,isBoolean as N}from"../../utils/language.js";import{setValueByPath as F}from"../../utils/object.js";import{getCurrentPagePath as C}from"../../utils/page.js";import{getWifiIp as W,getLanIp as V,getMicroAppIp as B}from"../../utils/ip.js";class J{constructor(){if(this.consoleList=[],this.consoleMaxSize=1e3,this.totalConsoleCount=0,this.networkList=[],this.networkMaxSize=1e3,this.totalNetworkCount=0,this.interceptNetworkMap=new Map,this.requestIndex=-1,this.storageList=[],this.vuexList={},this.piniaList={},this.routeList=[],this.prePath="",this.wsList=[],this.wsDataMaxSize=1e3,this.wsTaskMap=new Map,this.transferList=[],this.transferMaxSize=1e3,this.transferIndex=-1,this.transferTaskMap=new Map,this.elEventList=[],this.uniEventList=[],this.eventCount={on:0,once:0,emit:0,off:0},this.elEventListMaxSize=1e3,this.uniEventListMaxSize=1e3,this.screenList=[],this.scanCodeList=[],this.nfcList=[],this.bluetoothList=[],this.screenIndex=-1,this.screenMaxSize=1e3,this.scanCodeListMaxSize=1e3,this.nfcListMaxSize=1e3,this.systemInfo={},this.deviceInfo={},this.windowInfo={},this.netWorkStatus={},this.devToolVersion="0.0.0",this.devToolBuildTime="",this.devToolGit="",this.devToolVisible=!1,this.devToolDestroy=!1,this.cacheInterceptConfig=!0,this.useTransition=!0,this.cacheNetworkLog=!1,this.cacheConsoleLog=!1,this.baseFontSize=12,this.tagFontSize=10,this.tipsFontSize=10,this.fontFamily="",this.fontWeight="normal",this.barrageVisible=!0,this.barrageMaxTracks=10,this.barrageTrackHeight=36,this.barrageStartTop=40,this.barrageDuration=6,this.barrageMaxLength=100,this.barrageTypes=["log","info","warn","error","network","transfer","websocket"],this.barrageShowWhenOpen=!1,this.saveConsoleLogThrottled=z(()=>{this.cacheConsoleLog&&w(this.consoleList)},1e3),this.saveNetworkLogThrottled=z(()=>{this.cacheNetworkLog&&k(this.networkList)},1e3),this.cacheMaxSize=8*1024*1024*10,typeof uni<"u"){const{devToolDestroy:t=!1,devToolButtonVisible:e=!1,cacheInterceptConfig:s=!0,cacheNetworkLog:o=!1,cacheConsoleLog:i=!1,useTransition:h=!0,baseFontSize:r=12,tagFontSize:l=10,tipsFontSize:d=10,fontFamily:n="",fontWeight:L="normal",barrageVisible:T=!0,barrageMaxTracks:S=10,barrageTrackHeight:c=36,barrageStartTop:f=40,barrageDuration:g=6,barrageMaxLength:v=100,barrageTypes:u=["log","info","warn","error","network","transfer","websocket"],barrageShowWhenOpen:p=!1,interceptNetworkList:b=[]}=uni.getStorageSync(I)||{};this.devToolDestroy=t,this.devToolVisible=e,this.cacheInterceptConfig=s,this.cacheNetworkLog=o,this.cacheConsoleLog=i,this.useTransition=h,this.baseFontSize=r,this.tagFontSize=l,this.tipsFontSize=d,this.fontFamily=n,this.fontWeight=L,this.barrageVisible=T,this.barrageMaxTracks=S,this.barrageTrackHeight=c,this.barrageStartTop=f,this.barrageDuration=g,this.barrageMaxLength=v,this.barrageTypes=u,this.barrageShowWhenOpen=p,this.updateInterceptNetworkList(b),this.cacheNetworkLog&&(this.networkList=M(),this.requestIndex=Math.max(...this.networkList.map(x=>x.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=m()),this.totalConsoleCount=this.consoleList.length,this.totalNetworkCount=this.networkList.length}}updateHasUpload(){this.consoleList=this.consoleList.map(t=>({...t,hasUpload:!0})),this.networkList=this.networkList.map(t=>({...t,hasUpload:!0})),this.transferList=this.transferList.map(t=>({...t,hasUpload:!0})),this.elEventList=this.elEventList.map(t=>({...t,hasUpload:!0})),this.uniEventList=this.uniEventList.map(t=>({...t,hasUpload:!0})),this.screenList=this.screenList.map(t=>({...t,hasUpload:!0}))}setDevToolVisible(t){this.devToolVisible=t,a({devToolButtonVisible:t})}getDevToolVisible(){return this.devToolVisible}setDevToolDestroy(t){this.devToolDestroy=t,a({devToolDestroy:t})}getDevToolDestroy(){return this.devToolDestroy}setCacheInterceptConfig(t){this.cacheInterceptConfig=t,a({cacheInterceptConfig:t})}getCacheNetworkLog(){return this.cacheNetworkLog}setUseTransition(t){this.useTransition=t,a({useTransition:t})}setBaseFontSize(t){this.baseFontSize=t,a({baseFontSize:t})}setTagFontSize(t){this.tagFontSize=t,a({tagFontSize:t})}setTipsFontSize(t){this.tipsFontSize=t,a({tipsFontSize:t})}setFontFamily(t){this.fontFamily=t,a({fontFamily:t})}setFontWeight(t){this.fontWeight=t,a({fontWeight:t})}setBarrageVisible(t){this.barrageVisible=t,a({barrageVisible:t})}setBarrageMaxTracks(t){this.barrageMaxTracks=t,a({barrageMaxTracks:t})}setBarrageTrackHeight(t){this.barrageTrackHeight=t,a({barrageTrackHeight:t})}setBarrageStartTop(t){this.barrageStartTop=t,a({barrageStartTop:t})}setBarrageDuration(t){this.barrageDuration=t,a({barrageDuration:t})}setBarrageMaxLength(t){this.barrageMaxLength=t,a({barrageMaxLength:t})}setBarrageTypes(t){this.barrageTypes=t,a({barrageTypes:t})}setBarrageShowWhenOpen(t){this.barrageShowWhenOpen=t,a({barrageShowWhenOpen:t})}setCacheConsoleLog(t){this.cacheConsoleLog=t,a({cacheConsoleLog:t}),t?w(this.consoleList):w([])}setCacheNetworkLog(t){this.cacheNetworkLog=t,a({cacheNetworkLog:t}),t?k(this.networkList):k([])}getConsoleList(){return this.consoleList}updateConsoleList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.consoleList[e]&&(this.consoleList[e]=t[0]):(this.consoleList.push(...t),this.totalConsoleCount+=t.length,this.consoleList.length>this.consoleMaxSize&&(this.consoleList=this.consoleList.slice(-this.consoleMaxSize))),this.saveConsoleLogThrottled()}clearConsoleList(){this.consoleList=[],this.totalConsoleCount=0,this.cacheConsoleLog&&w([])}getNetworkList(){return this.networkList}updateNetworkList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.networkList[e]&&(this.networkList[e]=t[0]):(this.networkList.push(...t),this.totalNetworkCount+=t.length,this.networkList.length>this.networkMaxSize&&(this.networkList=this.networkList.slice(-this.networkMaxSize))),this.saveNetworkLogThrottled()}clearNetworkList(){this.networkList=[],this.totalNetworkCount=0,this.cacheNetworkLog&&k([])}getInterceptNetworkMap(){return this.interceptNetworkMap}getRequestIndex(){return this.requestIndex}setRequestIndex(t){return this.requestIndex=t,this.requestIndex}updateInterceptNetworkList(t){this.interceptNetworkMap.clear(),t.forEach(e=>{var o;const s=`${(o=e.method)==null?void 0:o.toUpperCase()}|${e.url}`;this.interceptNetworkMap.set(s,e)})}clearInterceptNetworkList(){this.clearNetworkList()}getStorageList(){return this.storageList}setStorageList(t){return this.storageList=t,this.storageList}getVuexList(){return this.vuexList}getPiniaList(){return this.piniaList}setVuexStore(t){this.vuexStore=t}setVuexList(t){this.vuexList=t}setPiniaStore(t){this.piniaStore=t}setPiniaList(t){this.piniaList={...this.piniaList||{},...t}}updateStore(t){const{key:e,_oldKey:s,value:o}=t;return s===e&&(uni.removeStorageSync(s),this.storageList=this.storageList.filter(i=>i.key!==s)),uni.setStorageSync(e,o),this.storageList}updateVuexStore(t){var e,s;try{Object.assign(((e=this.vuexStore)==null?void 0:e.state)??{},t)}catch(o){console.error("[DevTool] updateVuexStore error",o)}return this.setVuexList({...((s=this.vuexStore)==null?void 0:s.state)??{}}),this.vuexList}updatePiniaStore(t){try{if(!this.piniaStore)return{};const[e,s]=Object.entries(t)[0];if(E(e))return{};F(this.piniaStore.state.value,e,s),this.setPiniaList({...this.piniaStore.state.value??{}})}catch(e){console.error("[DevTool] updatePiniaStore error",e)}return this.piniaList}clearStorageList(t){return this.storageList=[],t&&uni.clearStorage(),this.storageList}removeStorage(t,e){return this.storageList=this.storageList.filter(s=>s.key!==t),e&&uni.removeStorageSync(t),this.storageList}addStorage(t,e){const{key:s,value:o}=t;return this.storageList.unshift({key:s,_oldKey:s,value:o}),e&&uni.setStorageSync(s,o),this.storageList}refreshStore(){const{keys:t}=uni.getStorageInfoSync();return this.storageList=t.map(e=>{const s=uni.getStorageSync(e);return{key:e,_oldKey:e,value:s}}),this.storageList}updateStoreList(t){const e=t[0],s=this.storageList.findIndex(o=>o.key===e._oldKey);return s>-1&&t.length===1?this.storageList[s]=t[0]:this.storageList.push(...t),this.storageList}getRouteList(){return this.routeList}setRouteList(t,e){var o;const s=e||((o=t==null?void 0:t[0])==null?void 0:o.path)||"";return this.routeList=t.map((i,h)=>({...i,name:i.style.navigationBarTitleText||"无名",uvList:[],index:i.path===s&&h===0?4:i.path===s?3:h===0?2:1})),this.routeList}updateRouteList(t){const e=t?t==="/"?C():t:C(),s=this.prePath;this.routeList=this.routeList.map((r,l)=>({...r,index:r.path===e&&l===0?4:r.path===e?3:l===0?2:1}));const o=(r,l,d)=>{var T,S;if(!r[l])return r;r[l].uvList||(r[l].uvList=[]);const n=r[l],L=n.uvList??[];if(L.length){const c=L.length-1,f=L[c];if(f&&f.inTime&&!f.outTime){const g=Date.now();n.outTime=g,L[c].outTime=g,L[c].duration=g-f.inTime,n.duration=L[c].duration,n.totalDuration=L.reduce((v,u)=>v+(u.duration||0),0),d&&(n.visitTimes=L.length)}else{const g=Date.now();n.inTime=g,n.outTime=0,n.duration=0,(T=n.uvList)==null||T.push({index:c+1,inTime:g,outTime:0,duration:0}),d&&(n.visitTimes=(S=n.uvList)==null?void 0:S.length)}}else{const c=Date.now();n.inTime=c,n.outTime=0,n.duration=0,n.totalDuration=0,n.visitTimes=1,n.uvList=[{index:0,inTime:c,outTime:0,duration:0}]}return r},i=this.routeList.findIndex(r=>r.path===s),h=this.routeList.findIndex(r=>r.path===e);return i>-1&&o(this.routeList,i),h>-1&&o(this.routeList,h,!0),this.prePath=e,this.routeList}getWsList(){return this.wsList}updateWsList(t){var s,o;const e=this.wsList.findIndex(i=>i.url===t.url);if(e>-1){const i=this.wsList[e];i.headers=t.headers??i.headers,i.readyState=t.readyState??i.readyState,i.method=t.method??i.method,i.protocols=t.protocols??i.protocols,i.message=[...i.message??[],...t.message??[]];const h=this.wsDataMaxSize,r=((s=i.message)==null?void 0:s.length)??0;r>h&&((o=i.message)==null||o.splice(0,r-h))}else this.wsList.push(t);return this.wsList}clearWsList(){this.wsList=[]}clearWsMessage(t){const e=this.wsList.findIndex(s=>s.url===t);e>-1&&(this.wsList[e].message=[])}addWsTask(t,e){this.wsTaskMap.set(t,e)}removeWsTask(t){this.wsTaskMap.delete(t)}getWsTask(t){const e=this.wsTaskMap.get(t);if(e)return e;if(!t)return;let s;return this.wsTaskMap.forEach((o,i)=>{s||i&&(i.includes(t)||t.includes(i))&&(s=o)}),s}getTransferList(){return this.transferList}updateTransferList(t,e){if(typeof e=="number"&&e>-1&&t.length===1){const s=t[0],o=this.transferList.findIndex(i=>i.index===e);o>-1?this.transferList[o]={...this.transferList[o],...s}:this.transferList.push(s)}else this.transferList.length+t.length>this.transferMaxSize&&(this.transferList=[]),this.transferList.push(...t)}getTransferIndex(){return this.transferIndex}setTransferIndex(t){return this.transferIndex=t,this.transferIndex}addTransferTask(t,e){this.transferTaskMap.set(t,e)}removeTransferTask(t){this.transferTaskMap.delete(t)}clearTransferTask(){this.transferTaskMap.clear()}getElEventList(){return this.elEventList}getUniEventList(){return this.uniEventList}getEventCount(){return this.eventCount}addElEvent(t){this.elEventList.length>=this.elEventListMaxSize&&this.elEventList.shift(),this.elEventList.push(t)}clearElEventList(){this.elEventList=[]}updateUniEventList(t){this.uniEventList.length+t.length>this.uniEventListMaxSize&&(this.uniEventList=[]),this.uniEventList.push(...t)}updateUniEventCount(t){this.eventCount[t]++}clearUniEventList(){this.uniEventList=[],this.eventCount={on:0,once:0,emit:0,off:0}}getScreenList(){return this.screenList}getScanCodeList(){return this.scanCodeList}getNfcList(){return this.nfcList}getScreenIndex(){return this.screenIndex}setScreenIndex(t){return this.screenIndex=t,this.screenIndex}getSystemInfo(){return this.systemInfo}getDeviceInfo(){return this.deviceInfo}getWindowInfo(){return this.windowInfo}setSystemInfo(t){this.systemInfo=t}setDeviceInfo(t){this.deviceInfo=t}setWindowInfo(t){this.windowInfo=t}setNetWorkStatus(t){this.netWorkStatus=t}updateScreenList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.screenList[e]&&(this.screenList[e]=t[0]):(this.screenList.length+t.length>this.screenMaxSize&&(this.screenList=[]),this.screenList.push(...t))}updateScanCodeList(t){this.scanCodeList.length+t.length>this.scanCodeListMaxSize&&(this.scanCodeList=[]),this.scanCodeList.push(...t)}updateNfcList(t){this.nfcList.length+t.length>this.nfcListMaxSize&&(this.nfcList=[]),this.nfcList.push(...t)}updateBluetoothList(t){this.bluetoothList=t}clearScanCodeList(){this.scanCodeList=[]}clearNfcList(){this.nfcList=[]}clearBluetoothList(){this.bluetoothList=[]}getDevToolOptions(){return this.devToolOptions}setDevToolOptions(t){var f,g,v;this.devToolOptions=t,this.transferMaxSize=t.uploadMaxSize||1e3,this.consoleMaxSize=t.consoleMaxSize||1e3,this.networkMaxSize=t.networkMaxSize||1e3,this.wsDataMaxSize=t.wsDataMaxSize||1e3,this.elEventListMaxSize=t.elEventListMaxSize||1e3,this.uniEventListMaxSize=t.uniEventListMaxSize||1e3,this.screenMaxSize=t.screenMaxSize||1e3,this.scanCodeListMaxSize=t.scanCodeListMaxSize||1e3,this.nfcListMaxSize=t.nfcListMaxSize||1e3,this.devToolVersion=t.devToolVersion??"0.0.0",this.devToolBuildTime=t.devToolBuildTime??"",this.devToolGit=t.devToolGit??"";const{devToolButtonVisible:e,useTransition:s=!0,baseFontSize:o=12,tagFontSize:i=10,tipsFontSize:h=10,fontFamily:r="",fontWeight:l="normal",cacheInterceptConfig:d=!0,cacheNetworkLog:n=!1,cacheConsoleLog:L=!1,barrageVisible:T=!0,barrageShowWhenOpen:S=!1}=D();this.devToolVisible=N(e)?e:t.initShowDevTool??!0,this.useTransition=s,this.baseFontSize=o,this.tagFontSize=i,this.tipsFontSize=h,this.fontFamily=r,this.fontWeight=l,this.cacheInterceptConfig=d,this.cacheNetworkLog=n,this.cacheConsoleLog=L,this.barrageVisible=T,this.barrageShowWhenOpen=S,this.cacheNetworkLog&&(this.networkList=M(),this.requestIndex=Math.max(...this.networkList.map(u=>u.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=m()),this.setDevToolVisible(this.devToolVisible),this.setDevToolDestroy(!this.devToolVisible);const c=((f=t.pagesJson)==null?void 0:f.pages.map(u=>{var p,b,x;return{...u,type:(x=(b=(p=t.pagesJson)==null?void 0:p.tabBar)==null?void 0:b.list)!=null&&x.some(y=>y.pagePath===u.path)?"nav":"main"}}))??[];(v=(g=t.pagesJson)==null?void 0:g.subPackages)==null||v.forEach(u=>{u.pages.forEach(p=>{c.push({...p,path:`${u.root}/${p.path}`,type:"sub",uvList:[]})})}),this.setRouteList(c)}async getDevData(){var s,o,i,h;const t=await uni.getNetworkType()||{};this.setNetWorkStatus(t);let e="0.0.0.0";try{uni.__dev_tool_platform__==="app"?e=W()||V()||"0.0.0.0":uni.__dev_tool_platform__==="mp-weixin"&&(e=await B())}catch(r){console.error("[DevTool] Get IP error",r)}return{consoleList:this.consoleList,networkList:this.networkList,storageList:this.storageList,routeList:this.routeList,vuexList:this.vuexList,piniaList:this.piniaList,wsList:this.wsList,transferList:this.transferList,elEventList:this.elEventList,uniEventList:this.uniEventList,eventCount:this.eventCount,screenList:this.screenList,scanCodeList:this.scanCodeList,nfcList:this.nfcList,bluetoothList:this.bluetoothList,systemInfo:this.systemInfo,deviceInfo:this.deviceInfo,windowInfo:this.windowInfo,netWorkStatus:{ip:e,...t,isConnected:t.networkType!=="none"},devToolVisible:this.getDevToolVisible(),cacheInterceptConfig:this.cacheInterceptConfig,cacheNetworkLog:this.cacheNetworkLog,cacheConsoleLog:this.cacheConsoleLog,useTransition:this.useTransition,baseFontSize:this.baseFontSize,tagFontSize:this.tagFontSize,tipsFontSize:this.tipsFontSize,fontFamily:this.fontFamily,fontWeight:this.fontWeight,barrageVisible:this.barrageVisible,barrageMaxTracks:this.barrageMaxTracks,barrageTrackHeight:this.barrageTrackHeight,barrageStartTop:this.barrageStartTop,barrageDuration:this.barrageDuration,barrageMaxLength:this.barrageMaxLength,barrageTypes:[...this.barrageTypes],barrageShowWhenOpen:this.barrageShowWhenOpen,devToolVersion:this.devToolVersion,devToolBuildTime:this.devToolBuildTime,devToolGit:this.devToolGit,sourceFileServers:(s=this.devToolOptions)==null?void 0:s.sourceFileServers,mode:(o=this.devToolOptions)==null?void 0:o.mode,useDevSource:(i=this.devToolOptions)==null?void 0:i.useDevSource,zIndex:(h=this.devToolOptions)==null?void 0:h.zIndex,totalConsoleCount:this.totalConsoleCount,totalNetworkCount:this.totalNetworkCount}}getExportData(t){const e={};return t.exportLog&&(e.consoleList=this.consoleList),t.exportNetwork&&(e.networkList=this.networkList),t.exportStorage&&(e.storageList=this.storageList,e.vuexList=this.vuexList,e.piniaList=this.piniaList),t.exportTransfer&&(e.transferList=this.transferList),t.exportWebSocket&&(e.wsList=this.wsList),t.exportWindow&&(e.windowInfo=uni.getWindowInfo?uni.getWindowInfo():{errMsg:"not supported"}),t.exportDevice&&(e.deviceInfo=uni.getDeviceInfo?uni.getDeviceInfo():{errMsg:"not supported"}),t.exportSystem&&(e.systemInfo=uni.getSystemInfo?uni.getSystemInfo():{errMsg:"not supported"}),t.exportUniEvent&&(e.uniEventList=this.uniEventList),t.exportElEvent&&(e.elEventList=this.elEventList),t.exportScanCodeList&&(e.scanCodeList=this.scanCodeList),t.exportNfcList&&(e.nfcList=this.nfcList),e}clearDevCache(){this.consoleList=[],this.networkList=[],this.wsList=[],this.transferList=[],this.elEventList=[],this.uniEventList=[],this.screenList=[],this.scanCodeList=[],this.nfcList=[],this.bluetoothList=[],this.cacheConsoleLog&&w([]),this.cacheNetworkLog&&k([])}clearAll(){this.clearDevCache(),this.storageList=[],this.routeList=[],this.interceptNetworkMap.clear()}getCurrentPagePath(){return C()}}export{J as DevStore};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`),t=
|
|
3
|
-
`),map:null}}catch(e){return console.error("[DevTool] 转换 main 文件时出错:",e),{code:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../utils/index.cjs");function p(r){const{lines:s,useErrorBoundary:e}=r,n=[...s],t=c.findInsertionIndex(n,o=>o.trim().startsWith("import")||o.trim().startsWith("export"));if(t!==-1){const o=["import DevTool from 'vite-uni-dev-tool/dist/v3/DevTool/index.vue';","import { recordInstance } from 'vite-uni-dev-tool/dist/v3/DevTool/components/Instance/registry';"];e&&o.push("import DevErrorBoundary from 'vite-uni-dev-tool/dist/v3/components/DevErrorBoundary/index.vue';"),n.splice(t,0,...o)}const i=c.findInsertionIndex(n,o=>o.includes("const app = createSSRApp(App)"));if(i!==-1){const o=[" app.mixin({ "," mounted() { recordInstance(this.$); },"," updated() { recordInstance(this.$); }"," });"," app.component('DevTool', DevTool);"];e&&o.push(" app.component('DevErrorBoundary', DevErrorBoundary);"),n.splice(i+1,0,...o)}return n}const d=({code:r,useErrorBoundary:s})=>{try{const e=r.split(`
|
|
2
|
+
`),t=p({lines:e,useErrorBoundary:!!s});return t.length===e.length&&t.every((i,o)=>i===e[o])?{code:r,map:null}:{code:t.join(`
|
|
3
|
+
`),map:null}}catch(e){return console.error("[DevTool] 转换 main 文件时出错:",e),{code:r,map:null}}};exports.transformMain=d;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
interface TransformMainOptions {
|
|
2
2
|
code: string;
|
|
3
|
+
useErrorBoundary: boolean;
|
|
3
4
|
}
|
|
4
5
|
/**
|
|
5
6
|
* 转换 main.ts|js 文件
|
|
@@ -15,7 +16,7 @@ interface TransformMainOptions {
|
|
|
15
16
|
* map: any;
|
|
16
17
|
* }}
|
|
17
18
|
*/
|
|
18
|
-
export declare const transformMain: ({ code, }: TransformMainOptions) => {
|
|
19
|
+
export declare const transformMain: ({ code, useErrorBoundary, }: TransformMainOptions) => {
|
|
19
20
|
code: string;
|
|
20
21
|
map: any;
|
|
21
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformMain.d.ts","sourceRoot":"","sources":["../../../../src/plugins/uniDevTool/transform/transformMain.ts"],"names":[],"mappings":"AAEA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"transformMain.d.ts","sourceRoot":"","sources":["../../../../src/plugins/uniDevTool/transform/transformMain.ts"],"names":[],"mappings":"AAEA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AA8FD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,gCAGvB,oBAAoB;UACf,MAAM;SACP,GAAG;CAgCT,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{findInsertionIndex as
|
|
2
|
-
`),
|
|
3
|
-
`),map:null}}catch(
|
|
1
|
+
import{findInsertionIndex as p}from"../../utils/index.js";function c(r){const{lines:s,useErrorBoundary:e}=r,t=[...s],n=p(t,o=>o.trim().startsWith("import")||o.trim().startsWith("export"));if(n!==-1){const o=["import DevTool from 'vite-uni-dev-tool/dist/v3/DevTool/index.vue';","import { recordInstance } from 'vite-uni-dev-tool/dist/v3/DevTool/components/Instance/registry';"];e&&o.push("import DevErrorBoundary from 'vite-uni-dev-tool/dist/v3/components/DevErrorBoundary/index.vue';"),t.splice(n,0,...o)}const i=p(t,o=>o.includes("const app = createSSRApp(App)"));if(i!==-1){const o=[" app.mixin({ "," mounted() { recordInstance(this.$); },"," updated() { recordInstance(this.$); }"," });"," app.component('DevTool', DevTool);"];e&&o.push(" app.component('DevErrorBoundary', DevErrorBoundary);"),t.splice(i+1,0,...o)}return t}const u=({code:r,useErrorBoundary:s})=>{try{const e=r.split(`
|
|
2
|
+
`),n=c({lines:e,useErrorBoundary:!!s});return n.length===e.length&&n.every((i,o)=>i===e[o])?{code:r,map:null}:{code:n.join(`
|
|
3
|
+
`),map:null}}catch(e){return console.error("[DevTool] 转换 main 文件时出错:",e),{code:r,map:null}}};export{u as transformMain};
|