vite-uni-dev-tool 1.2.0 → 1.2.2

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.
Files changed (104) hide show
  1. package/README.md +17 -1
  2. package/dist/const.cjs +1 -1
  3. package/dist/const.d.ts +1 -1
  4. package/dist/const.js +1 -1
  5. package/dist/core-shared.d.ts +2 -3
  6. package/dist/core.d.ts +8 -8
  7. package/dist/core.js +1 -1
  8. package/dist/i18n/index.d.ts +0 -1
  9. package/dist/i18n/instance.d.ts +0 -1
  10. package/dist/i18n/locales/en.cjs +1 -1
  11. package/dist/i18n/locales/en.d.ts +1 -1
  12. package/dist/i18n/locales/en.js +1 -1
  13. package/dist/i18n/locales/zh-Hans.cjs +1 -1
  14. package/dist/i18n/locales/zh-Hans.d.ts +1 -1
  15. package/dist/i18n/locales/zh-Hans.js +1 -1
  16. package/dist/index.d.ts +0 -1
  17. package/dist/modules/devConsole/index.cjs +4 -4
  18. package/dist/modules/devConsole/index.d.ts +6 -107
  19. package/dist/modules/devConsole/index.js +4 -4
  20. package/dist/modules/devEvent/index.cjs +3 -3
  21. package/dist/modules/devEvent/index.d.ts +2 -3
  22. package/dist/modules/devEvent/index.js +3 -3
  23. package/dist/modules/devIntercept/index.cjs +14 -14
  24. package/dist/modules/devIntercept/index.d.ts +33 -5
  25. package/dist/modules/devIntercept/index.js +14 -14
  26. package/dist/modules/devStore/index.cjs +1 -1
  27. package/dist/modules/devStore/index.d.ts +48 -40
  28. package/dist/modules/devStore/index.js +1 -1
  29. package/dist/modules/devToolInfo/index.cjs +1 -1
  30. package/dist/modules/devToolInfo/index.d.ts +6 -25
  31. package/dist/modules/devToolInfo/index.js +1 -1
  32. package/dist/plugins/uniDevTool/transform/transformApp.d.ts +0 -1
  33. package/dist/plugins/uniDevTool/transform/transformMain.d.ts +0 -1
  34. package/dist/plugins/uniDevTool/transform/transformVue.d.ts +0 -1
  35. package/dist/plugins/uniDevTool/uniDevTool.d.ts +0 -1
  36. package/dist/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -1
  37. package/dist/plugins/utils/index.d.ts +0 -1
  38. package/dist/shims-uni.d.ts +26 -22
  39. package/dist/type.d.ts +44 -43
  40. package/dist/utils/array.d.ts +0 -1
  41. package/dist/utils/date.d.ts +0 -1
  42. package/dist/utils/file.d.ts +0 -1
  43. package/dist/utils/function.d.ts +0 -1
  44. package/dist/utils/index.d.ts +0 -1
  45. package/dist/utils/ip.d.ts +0 -1
  46. package/dist/utils/language.d.ts +14 -15
  47. package/dist/utils/object.cjs +1 -1
  48. package/dist/utils/object.d.ts +7 -8
  49. package/dist/utils/object.js +1 -1
  50. package/dist/utils/openLink.d.ts +0 -1
  51. package/dist/utils/page.d.ts +0 -1
  52. package/dist/utils/platform.d.ts +0 -1
  53. package/dist/utils/string.d.ts +0 -1
  54. package/dist/utils/utils.d.ts +0 -1
  55. package/dist/v3/DevTool/components/DevToolButton/index.vue +42 -6
  56. package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolData.ts +36 -12
  57. package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolHandlers.ts +16 -1
  58. package/dist/v3/DevTool/components/DevToolWindow/index.vue +27 -64
  59. package/dist/v3/DevTool/components/Instance/transformTree.ts +156 -138
  60. package/dist/v3/DevTool/components/SettingList/index.vue +8 -0
  61. package/dist/v3/DevTool/components/SettingList/modules/SettingBarrage.vue +16 -0
  62. package/dist/v3/DevTool/index.vue +87 -138
  63. package/dist/v3/components/AppTransition/index.vue +33 -53
  64. package/dist/v3/components/Barrage/BarrageItem.vue +66 -9
  65. package/dist/v3/components/Barrage/index.vue +3 -0
  66. package/dist/v3/components/DevErrorBoundary/index.vue +13 -5
  67. package/dist/v3/components/DraggableContainer/index.vue +186 -73
  68. package/dist/v3/components/MovableContainer/index.vue +2 -0
  69. package/dist/v3/components/Pick/index.vue +29 -30
  70. package/dist/v3/hooks/useContainerStyle.ts +15 -73
  71. package/package.json +4 -1
  72. package/dist/const.d.ts.map +0 -1
  73. package/dist/core-shared.d.ts.map +0 -1
  74. package/dist/core.d.ts.map +0 -1
  75. package/dist/i18n/index.d.ts.map +0 -1
  76. package/dist/i18n/instance.d.ts.map +0 -1
  77. package/dist/i18n/locales/en.d.ts.map +0 -1
  78. package/dist/i18n/locales/zh-Hans.d.ts.map +0 -1
  79. package/dist/index.d.ts.map +0 -1
  80. package/dist/modules/devConsole/index.d.ts.map +0 -1
  81. package/dist/modules/devEvent/index.d.ts.map +0 -1
  82. package/dist/modules/devIntercept/index.d.ts.map +0 -1
  83. package/dist/modules/devStore/index.d.ts.map +0 -1
  84. package/dist/modules/devToolInfo/index.d.ts.map +0 -1
  85. package/dist/plugins/uniDevTool/transform/transformApp.d.ts.map +0 -1
  86. package/dist/plugins/uniDevTool/transform/transformMain.d.ts.map +0 -1
  87. package/dist/plugins/uniDevTool/transform/transformVue.d.ts.map +0 -1
  88. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
  89. package/dist/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -1
  90. package/dist/plugins/utils/index.d.ts.map +0 -1
  91. package/dist/type.d.ts.map +0 -1
  92. package/dist/utils/array.d.ts.map +0 -1
  93. package/dist/utils/date.d.ts.map +0 -1
  94. package/dist/utils/file.d.ts.map +0 -1
  95. package/dist/utils/function.d.ts.map +0 -1
  96. package/dist/utils/index.d.ts.map +0 -1
  97. package/dist/utils/ip.d.ts.map +0 -1
  98. package/dist/utils/language.d.ts.map +0 -1
  99. package/dist/utils/object.d.ts.map +0 -1
  100. package/dist/utils/openLink.d.ts.map +0 -1
  101. package/dist/utils/page.d.ts.map +0 -1
  102. package/dist/utils/platform.d.ts.map +0 -1
  103. package/dist/utils/string.d.ts.map +0 -1
  104. package/dist/utils/utils.d.ts.map +0 -1
@@ -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,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
- `+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,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
- `),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=>J(u)).join(`
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 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
- `),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
- `),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: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
+ import{backup as p,consoleProxy as $}from"../../core-shared.js";import{DEV_TOOL_ON_INIT as B,DEV_TOOL_ON_DESTROY as q,DEV_ERROR_BOUNDARY_TRIGGER as A}from"../../const.js";import"../../utils/index.js";import{getCurrentDate as I}from"../../utils/date.js";import{getCurrentPagePath as w}from"../../utils/page.js";import{parseValue as C,omit as G}from"../../utils/object.js";import{transformValueToShortString as P,transformValueToView as _}from"../../utils/language.js";import{escapeHTML as J}from"../../utils/string.js";class re{constructor(e){this.preWarn="",this.initPinia=!1,this.isReporting=!1,this.lastReportMsg="",this.lastReportTime=0,this.captureScreen=t=>{if(!this.hooks.getDevToolDestroy()){const r=this.hooks.getScreenIndex(),s=this.hooks.setScreenIndex(r+1);this.hooks.updateScreen([{index:s,position:w(),startTime:I(),endTime:I(),type:"captureScreen",path:(t==null?void 0:t.path)??""}])}},this.hooks=e.hooks,typeof uni<"u"&&(uni.$on(B,t=>this.init(t)),uni.$on(q,()=>this.reset()))}safeDefineProperty(e,t,r){if(!e)return!1;try{const s=Object.getOwnPropertyDescriptor(e,t);return s&&s.configurable===!1?(console.warn(`[DevTool] ${t} 属性不可配置,已跳过拦截`),!1):(Object.defineProperty(e,t,{...r,configurable:!0}),!0)}catch(s){return console.warn(`[DevTool] 拦截 ${t} 失败,环境可能受限:`,s),!1}}formatStack(e){if(!e)return"";const t=e.split(`
2
+ `).map(s=>s.trim()).filter(Boolean);return t.find(s=>{const n=s.toLowerCase();return n.includes("at ")&&!n.includes("devintercept")&&!n.includes("devconsole")&&!n.includes("core-shared")&&!n.includes("core.ts")})||t[0]||""}reportError({type:e="error",msg:t="",stack:r="",source:s="System",itemType:n="string"}){if(this.hooks.getDevToolDestroy()||this.isReporting)return;const u=Date.now();if(t===this.lastReportMsg&&u-this.lastReportTime<100)return;this.lastReportMsg=t,this.lastReportTime=u;const h=this.formatStack(r);this.isReporting=!0;try{const c=[];if(n==="object"||n==="array"){const i=C(t);c.push({type:n,value:i,shortValue:P(i,n)})}else c.push({type:n,value:`[${s}] ${t}`});this.hooks.updateConsole([{type:e,args:c,position:w(),time:I(),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(){["InterceptAppConsole","InterceptErrorApp","InterceptPromiseReject","InterceptStorage","InterceptRemoveStorage","InterceptClearStorage","InterceptRequest","InterceptSocket","InterceptUploadFile","InterceptDownloadFile","InterceptSwitchTab","InterceptRedirectTo","InterceptReLaunch","InterceptNavigateBack","InterceptNavigateTo","UniEvent","InterceptScanCode","InterceptScreenRecording"].forEach(e=>{var t;return(t=this[`reset${e}`])==null?void 0:t.call(this)}),this.enableCaptureScreen&&this.resetInterceptCaptureScreen()}interceptAppConsole(){const e=this;uni.__log__&&this.safeDefineProperty(uni,"__log__",{writable:!1,value:function(r,s,...n){var h,c;(c=(h=p).__log__)==null||c.call(h,r,s,...n);const u=w();e.hooks.updateConsole([{type:r,position:u,time:I(),args:n.map(i=>{const d=_(i),l=C(i),a=d==="object"||d==="array"?P(l,d):"";return{type:d,value:l,shortValue:a}}),stack:s}])}}),["log","info","debug","error","warn","time","timeEnd","count","clear"].forEach(r=>{this.safeDefineProperty(console,r,{value:function(...s){var h,c;if(["time","timeEnd","count","clear"].includes(r)&&r in $)return $[r](...s);(c=(h=p.originalConsole)[r])==null||c.call(h,...s);const n=s.map(i=>{const d=_(i),l=C(i),a=d==="object"||d==="array"?P(l,d):"";return{type:d,value:l,shortValue:a}}),u=e.formatStack(new Error().stack||"");s.length>0&&e.hooks.updateConsole([{type:r,args:n,position:w(),time:I(),stack:u}])}})})}resetInterceptAppConsole(){uni.__log__&&this.safeDefineProperty(uni,"__log__",{writable:!0,value:p.__log__}),["log","info","debug","error","warn","time","timeEnd","count","clear"].forEach(t=>{this.safeDefineProperty(console,t,{value:p.originalConsole[t]})})}interceptVue(e){if(!e)return;const t=(s,n,u)=>{this.hooks.getDevToolDestroy()||this.interceptErrorVue(s,u)},r=(s,n,u)=>{this.hooks.getDevToolDestroy()||this.interceptWarnVue(s+`
3
+ `+u)};e.appContext?(e.appContext.config.errorHandler=t,e.appContext.config.warnHandler=r):(e.config.errorHandler=t,e.config.warnHandler=r)}interceptAppError(){if(this.onErrorHandler=e=>{var s;const t=typeof e=="string"?e:(e==null?void 0:e.message)||String(e)||"",r=(e==null?void 0:e.stack)||(typeof t=="string"?(s=t.split(`
4
+ `))==null?void 0:s[1]:"")||"";this.reportError({msg:t,stack:r,source:"AppError"})},this.onErrorHandler&&uni.onError(this.onErrorHandler),uni.onUnhandledRejection){this.onUnhandledRejectionHandler=t=>{var n;let r="Unhandled Promise Rejection",s="";t.reason&&(r=typeof t.reason=="string"?t.reason:t.reason.message||String(t.reason)||r,s=((n=t.reason)==null?void 0:n.stack)||""),this.reportError({msg:r,stack:s,source:"UnhandledRejection"})};const e=uni;this.onUnhandledRejectionHandler&&e.onUnhandledRejection&&e.onUnhandledRejection(this.onUnhandledRejectionHandler)}typeof window<"u"&&window.addEventListener&&(this.boundWindowError=e=>{var s,n;if(e.target!==window)return;const t=e.message||((s=e.error)==null?void 0:s.message)||String(e),r=((n=e.error)==null?void 0:n.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(),s=t.src||t.href||t.currentSrc||t.getAttribute&&t.getAttribute("src");(["IMG","SCRIPT","LINK","VIDEO","AUDIO","SOURCE","UNI-IMAGE"].includes(r)||s)&&this.reportError({type:"error",msg:`Resource Load Failed: ${s||"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);const e=uni;e.offUnhandledRejection&&this.onUnhandledRejectionHandler&&e.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 u;const r=(u=e==null?void 0:e.stack)==null?void 0:u.split(`
5
+ `),s=(r==null?void 0:r[1])||(e==null?void 0:e.stack)||"",n=(e==null?void 0:e.message)||(e==null?void 0:e.toString())||"Unknown Error";p.originalConsole.error(e),uni.$emit(A,{err:e,info:t}),this.reportError({msg:n,stack:s,source:"VueError"})}interceptWarnVue(e){var n,u,h,c;if(this.preWarn===e)return;this.preWarn=e;const t=(u=(n=new Error)==null?void 0:n.stack)==null?void 0:u.split(`
6
+ `),r=((h=t==null?void 0:t.slice(2))==null?void 0:h[0])||"";p.originalConsole.warn(e);const s=(c=e.split(`
7
+ `))==null?void 0:c.map(i=>J(i)).join(`
8
+ `);this.reportError({type:"warn",msg:s,stack:r,source:"VueWarn"})}interceptPromiseReject(){const e=this;this.safeDefineProperty(Promise,"reject",{configurable:!0,value:function(t){var n,u;const r=(t==null?void 0:t.toString())||"Promise Reject",s=((u=(n=t==null?void 0:t.stack)==null?void 0:n.split(`
9
+ `))==null?void 0:u[1])??"";return e.reportError({msg:r,stack:s,source:"Promise.reject"}),p.reject.call(Promise,t)}})}resetInterceptPromiseReject(){this.safeDefineProperty(Promise,"reject",{configurable:!0,value:function(e){return p.reject.call(Promise,e)}})}interceptSetStorage(){const e=this;this.safeDefineProperty(uni,"setStorageSync",{configurable:!0,value:function(t,r){p.setStorageSync(t,r),e.hooks.updateStorage([{key:t.toString(),_oldKey:t.toString(),value:r}])}}),uni.addInterceptor("setStorage",{invoke(t){const r=t.complete;t.complete=function(s){var n,u;r&&r(s),e.hooks.updateStorage([{key:(n=t.key)==null?void 0:n.toString(),_oldKey:(u=t.key)==null?void 0:u.toString(),value:t.data}])}}})}resetInterceptStorage(){uni.removeInterceptor("setStorage"),this.safeDefineProperty(uni,"setStorageSync",{configurable:!0,value:p.setStorageSync}),uni.removeInterceptor("clearStorage"),this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:p.clearStorageSync}),uni.removeInterceptor("removeStorage"),this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:p.removeStorageSync})}interceptClearStorage(){const e=this;this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:function(){p.clearStorageSync(),e.hooks.clearStorage()}}),uni.addInterceptor("clearStorage",{invoke(){e.hooks.clearStorage()}})}resetInterceptClearStorage(){this.safeDefineProperty(uni,"clearStorageSync",{configurable:!0,value:p.clearStorageSync}),uni.removeInterceptor("clearStorage")}interceptRemoveStorage(){const e=this;this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:function(t){p.removeStorageSync(t),e.hooks.removeStorage(t)}}),uni.addInterceptor("removeStorage",{invoke(t){const r=t.complete;t.complete=function(s){r&&r(s),e.hooks.removeStorage(t.key)}}})}resetInterceptRemoveStorage(){this.safeDefineProperty(uni,"removeStorageSync",{configurable:!0,value:p.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,(s,n)=>{this.hooks.setVuexList(n)}))}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 R,H,U,W,F,x,V;const r=e.hooks.getRequestIndex(),s=e.hooks.setRequestIndex(r+1),n=t.url,u=(R=n==null?void 0:n.split("?"))==null?void 0:R[0],h=u==null?void 0:u.lastIndexOf("/"),c=(u==null?void 0:u.slice(h+1))??"",i=(U=(H=new Error)==null?void 0:H.stack)==null?void 0:U.split(`
10
+ `),d=uni.__dev_tool_platform__==="app"?i==null?void 0:i[2]:i==null?void 0:i[5],l=e.hooks.getInterceptNetworkMap(),o=`${(W=t.method)==null?void 0:W.toUpperCase()}|${u}`,a=l==null?void 0:l.get(o),g=Object.keys(t.header??{}).includes("dev-tool-sponsor")?"dev_tool":"user";t.header={...G(t.header,["dev-tool-sponsor"])};const f={index:s,stack:d,url:t.url,name:c,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:g};a&&(f.headers.requestHeader=[...f.headers.requestHeader,...a.headers.requestHeader||[]],f.payload=a.payload,f.intercepted=!0,Object.assign(t,{timeout:a.timeout})),e.hooks.updateNetwork([f]);const m={errMsg:""};let T=!0;a&&(m.statusCode=a.status,(x=(F=a==null?void 0:a.status)==null?void 0:F.toString())!=null&&x.startsWith("2")?(T=!0,m.errMsg="request:ok",m.header=(V=a.headers.responseHeader)==null?void 0:V.reduce((S,k)=>({...S,[k.key]:k.value}),{}),m.data=a.response.data):(T=!1,m.errMsg="request:fail"));const y=t.fail,v=t.success,E=t.complete;t.fail=function(S){const k=()=>{a?T?v==null||v(m):y==null||y(m):y==null||y(S)};a&&a.delay&&a.delay>0?setTimeout(k,a.delay):k()},t.success=function(S){const k=D=>{a?T?v==null||v(m):y==null||y(m):v==null||v(D)};a&&a.delay?setTimeout(()=>k(S),Number(a.delay)):k(S)},t.complete=function(S){const k=()=>{const D=Date.now()-f.startTime;f.time=D<1e3?D+"ms":D/1e3+"s",f.endTime=Date.now();const b=S.header||{},L=(b==null?void 0:b["Content-Length"])||(b==null?void 0:b["content-length"])||"0",j=Number(L)||0;f.size=j>1024?(j/1024).toFixed(2)+"k":j+"b",a?(E==null||E(m),f.status=a.status,f.response=m,f.headers.responseHeader=a.headers.responseHeader):(E==null||E(S),f.status=S.statusCode??"error",f.response=S,f.headers.responseHeader=Object.entries(S.header??{}).map(([N,M])=>({key:N,value:M}))),e.hooks.updateNetwork([f],s)};a&&a.delay&&a.delay>0?setTimeout(k,a.delay):k()}}})}resetInterceptRequest(){uni.removeInterceptor("request")}interceptSocket(){const e=this,t=function(r){const s=r.url,n=Object.entries(r.header??{}).map(([o,a])=>({key:o,value:a})),u=(r.method??"GET").toLowerCase(),h=r.protocols??[];e.hooks.updateWs({url:s,headers:n,method:u,protocols:h,readyState:"connection",message:[]});const c=p.connectSocket({...r,multiple:!0,complete:o=>{var a;(a=r==null?void 0:r.complete)==null||a.call(r,o)}});e.hooks.addWsTask(s,c);function i(o,a,g,f){let m=o;if(typeof o=="string")try{const R=JSON.parse(o);typeof R=="object"&&R!==null&&(m=R)}catch{}const T=_(m),y=C(m),E=T==="object"||T==="array"?P(y,T):"";e.hooks.updateWs({url:s,readyState:g,headers:n,protocols:h,message:[{value:y,valueType:T,shortValue:E,status:f,time:Date.now(),type:a}]})}const d=c.send;c.send=o=>{let a=o.data;if(typeof a=="object"&&a!==null)try{a=JSON.stringify(a)}catch{}d.call(c,{...o,data:a,fail:g=>{var f;(f=o==null?void 0:o.fail)==null||f.call(o,g),i(o.data,"send","error","error")},success:g=>{var f;(f=o==null?void 0:o.success)==null||f.call(o,g),i(o.data,"send","open","success")},complete:g=>{var f;(f=o==null?void 0:o.complete)==null||f.call(o,g)}})};const l=c.close;return c.close=o=>{e.hooks.updateWs({url:s,readyState:"closing",headers:n,protocols:h,message:[]}),l.call(c,{...o,fail:a=>{var g;(g=o==null?void 0:o.fail)==null||g.call(o,a),i(a,"send","closing","error")},success:a=>{var g;(g=o==null?void 0:o.success)==null||g.call(o,a),i(a,"send","closed","success")},complete:a=>{var g;(g=o==null?void 0:o.complete)==null||g.call(o,a)}})},c.onOpen(()=>{e.hooks.updateWs({url:s,readyState:"open",headers:n,protocols:h,message:[]})}),c.onError(o=>{i(o,"receive","error","error")}),c.onMessage(o=>{i(o.data,"receive","open","success")}),c.onClose(o=>{i(o,"receive","closed","success"),e.hooks.removeWsTask(s)}),c};this.safeDefineProperty(uni,"connectSocket",{configurable:!0,value:t})}resetInterceptSocket(){this.safeDefineProperty(uni,"connectSocket",{configurable:!0,value:p.connectSocket})}interceptUploadFile(){const e=this,t=r=>{var i,d;const s=e.hooks.getTransferIndex(),n=e.hooks.setTransferIndex(s+1),u=(d=(i=new Error)==null?void 0:i.stack)==null?void 0:d.split(`
11
+ `),h=u==null?void 0:u[2];e.hooks.updateTransfer([{index:n,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()}],n);const c=p.uploadFile({...r,success:l=>{var o;(o=r==null?void 0:r.success)==null||o.call(r,l),e.hooks.updateTransfer([{index:n,type:"upload",status:"success",endTime:Date.now(),response:{...l,data:JSON.parse(l.data)}}],n),e.hooks.removeTransferTask(n)},fail:l=>{var o;(o=r==null?void 0:r.fail)==null||o.call(r,l),e.hooks.updateTransfer([{index:n,type:"upload",status:"error",response:l,endTime:Date.now()}],n),e.hooks.removeTransferTask(n)}});return c.onProgressUpdate(l=>{e.hooks.updateTransfer([{index:n,type:"upload",progress:l.progress,totalBytesSent:l.totalBytesSent,totalBytesExpectedToSend:l.totalBytesExpectedToSend,status:"uploading"}],n)}),e.hooks.addTransferTask(n,c),c};this.safeDefineProperty(uni,"uploadFile",{configurable:!0,value:t})}resetInterceptUploadFile(){this.safeDefineProperty(uni,"uploadFile",{configurable:!0,value:p.uploadFile})}interceptDownloadFile(){const e=this,t=r=>{var i,d;const s=e.hooks.getTransferIndex(),n=e.hooks.setTransferIndex(s+1),u=(d=(i=new Error)==null?void 0:i.stack)==null?void 0:d.split(`
12
+ `),h=u==null?void 0:u[2];e.hooks.updateTransfer([{index:n,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()}],n);const c=p.downloadFile({...r,success:l=>{var o;(o=r==null?void 0:r.success)==null||o.call(r,l),e.hooks.updateTransfer([{index:n,type:"download",status:"success",endTime:Date.now(),response:{...l,statusCode:l.statusCode,tempFilePath:l.tempFilePath}}],n),e.hooks.removeTransferTask(n)},fail:l=>{var o;(o=r==null?void 0:r.fail)==null||o.call(r,l),e.hooks.updateTransfer([{index:n,type:"download",status:"error",response:l,endTime:Date.now()}],n),e.hooks.removeTransferTask(n)}});return c.onProgressUpdate(l=>{e.hooks.updateTransfer([{index:n,type:"download",progress:l.progress,totalBytesWritten:l.totalBytesWritten,totalBytesExpectedToWrite:l.totalBytesExpectedToWrite,status:"downloading"}],n)}),e.hooks.addTransferTask(n,c),c};this.safeDefineProperty(uni,"downloadFile",{configurable:!0,value:t})}resetInterceptDownloadFile(){this.safeDefineProperty(uni,"downloadFile",{configurable:!0,value:p.downloadFile})}interceptRouterMethod(e){const t=this;uni.addInterceptor(e,{invoke(r){const s=r.complete;r.complete=function(n){var h,c,i;s==null||s(n);const u=((i=(c=(h=r.url)==null?void 0:h.slice(1))==null?void 0:c.split("?"))==null?void 0:i[0])||"/";t.hooks.updateRoute(u),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}`,s=this;Object.defineProperty(uni,r,{configurable:!0,value:function(n,...u){var h,c,i,d;if((c=(h=p)==null?void 0:h[r])==null||c.call(h,n,...u),t&&!n.startsWith("dev-")&&!n.startsWith("perf-")){const l=(d=(i=new Error)==null?void 0:i.stack)==null?void 0:d.split(`
13
+ `),o=l==null?void 0:l[2];s.hooks.updateUniEvent([{eventName:n,timer:I(),stack:o,type:e}]),s.hooks.updateUniEventCount(e)}}})}interceptUniEvent(){this.uniEventFactory("on"),this.uniEventFactory("once"),this.uniEventFactory("emit"),this.uniEventFactory("off")}resetUniEvent(){Object.defineProperty(uni,"$on",{configurable:!0,value:p.$on}),Object.defineProperty(uni,"$once",{configurable:!0,value:p.$once}),Object.defineProperty(uni,"$emit",{configurable:!0,value:p.$emit}),Object.defineProperty(uni,"$off",{configurable:!0,value:p.$off})}interceptScanCode(){const e=this;uni.addInterceptor("scanCode",{invoke(t){var u,h;const r=t.complete,s=(h=(u=new Error)==null?void 0:u.stack)==null?void 0:h.split(`
14
+ `),n=s==null?void 0:s[5];t.complete=function(c){r&&r(c);const i=c;let d={},l="";try{d=JSON.parse((i==null?void 0:i.result)||"{}"),l=P(d,"object")}catch{d=i==null?void 0:i.result,l=String((i==null?void 0:i.result)||"")}e.hooks.updateScanCode([{timer:Date.now(),charSet:(i==null?void 0:i.charSet)||"",rawData:(c==null?void 0:c.rawData)||"",result:(i==null?void 0:i.result)||"",resultObject:d,scanType:(i==null?void 0:i.scanType)||"",errMsg:(c==null?void 0:c.errMsg)||"",path:w(),stack:n,shortValue:l}])}}})}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(),s=this.hooks.setScreenIndex(r+1),n=I();this.hooks.updateScreen([{index:s,position:w(),startTime:n,endTime:n,type:"screenRecording:"+t}])}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: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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("../../const.cjs");require("../../utils/index.cjs");const h=require("../devToolInfo/index.cjs"),C=require("../../utils/function.cjs"),y=require("../../utils/language.cjs"),I=require("../../utils/object.cjs"),w=require("../../utils/page.cjs"),k=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.devToolButtonVisible=!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.barrageAllowDrag=!0,this.barrageTypes=["log","info","warn","error","network","transfer","websocket"],this.barrageShowWhenOpen=!1,this.saveConsoleLogThrottled=C.throttle(()=>{this.cacheConsoleLog&&h.setDevToolConsoleList(this.consoleList)},1e3),this.saveNetworkLogThrottled=C.throttle(()=>{this.cacheNetworkLog&&h.setDevToolNetworkList(this.networkList)},1e3),this.cacheMaxSize=8*1024*1024*10,typeof uni>"u")return;const t=uni.getStorageSync(D.DEV_TOOL_INFO)||{};Object.assign(this,t),this.devToolButtonVisible=t.devToolButtonVisible??!1,t.interceptNetworkList&&this.updateInterceptNetworkList(t.interceptNetworkList),this.cacheNetworkLog&&(this.networkList=h.getDevToolNetworkList(),this.requestIndex=Math.max(...this.networkList.map(e=>e.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=h.getDevToolConsoleList()),this.totalConsoleCount=this.consoleList.length,this.totalNetworkCount=this.networkList.length}updateHasUpload(){[this.consoleList,this.networkList,this.transferList,this.elEventList,this.uniEventList,this.screenList].forEach(e=>e.forEach(s=>s.hasUpload=!0))}setAndSync(t,e,s){this[t]=e,h.setDevToolInfo({[s||t]:e})}setDevToolButtonVisible(t){this.setAndSync("devToolButtonVisible",t)}getDevToolButtonVisible(){return this.devToolButtonVisible}setDevToolDestroy(t){this.setAndSync("devToolDestroy",t)}getDevToolDestroy(){return this.devToolDestroy}setCacheInterceptConfig(t){this.setAndSync("cacheInterceptConfig",t)}getCacheNetworkLog(){return this.cacheNetworkLog}setUseTransition(t){this.setAndSync("useTransition",t)}setBaseFontSize(t){this.setAndSync("baseFontSize",t)}setTagFontSize(t){this.setAndSync("tagFontSize",t)}setTipsFontSize(t){this.setAndSync("tipsFontSize",t)}setFontFamily(t){this.setAndSync("fontFamily",t)}setFontWeight(t){this.setAndSync("fontWeight",t)}setBarrageVisible(t){this.setAndSync("barrageVisible",t)}setBarrageMaxTracks(t){this.setAndSync("barrageMaxTracks",t)}setBarrageTrackHeight(t){this.setAndSync("barrageTrackHeight",t)}setBarrageStartTop(t){this.setAndSync("barrageStartTop",t)}setBarrageDuration(t){this.setAndSync("barrageDuration",t)}setBarrageMaxLength(t){this.setAndSync("barrageMaxLength",t)}setBarrageAllowDrag(t){this.setAndSync("barrageAllowDrag",t)}setBarrageTypes(t){this.setAndSync("barrageTypes",t)}setBarrageShowWhenOpen(t){this.setAndSync("barrageShowWhenOpen",t)}setCacheConsoleLog(t){this.cacheConsoleLog=t,h.setDevToolInfo({cacheConsoleLog:t}),h.setDevToolConsoleList(t?this.consoleList:[])}setCacheNetworkLog(t){this.cacheNetworkLog=t,h.setDevToolInfo({cacheNetworkLog:t}),h.setDevToolNetworkList(t?this.networkList:[])}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&&h.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&&h.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 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(y.isNil(e))return{};I.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: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,a)=>({...i,name:i.style.navigationBarTitleText||"无名",uvList:[],index:i.path===s&&a===0?4:i.path===s?3:a===0?2:1})),this.routeList}updateRouteList(t){const e=t?t==="/"?w.getCurrentPagePath():t:w.getCurrentPagePath(),s=this.prePath;this.routeList=this.routeList.map((n,u)=>({...n,index:n.path===e&&u===0?4:n.path===e?3:u===0?2:1}));const o=(n,u,p)=>{var v,S;if(!n[u])return n;n[u].uvList||(n[u].uvList=[]);const r=n[u],l=r.uvList??[];if(l.length){const c=l.length-1,f=l[c];if(f&&f.inTime&&!f.outTime){const L=Date.now();r.outTime=L,l[c].outTime=L,l[c].duration=L-f.inTime,r.duration=l[c].duration,r.totalDuration=l.reduce((T,g)=>T+(g.duration||0),0),p&&(r.visitTimes=l.length)}else{const L=Date.now();r.inTime=L,r.outTime=0,r.duration=0,(v=r.uvList)==null||v.push({index:c+1,inTime:L,outTime:0,duration:0}),p&&(r.visitTimes=(S=r.uvList)==null?void 0:S.length)}}else{const c=Date.now();r.inTime=c,r.outTime=0,r.duration=0,r.totalDuration=0,r.visitTimes=1,r.uvList=[{index:0,inTime:c,outTime:0,duration:0}]}return n},i=this.routeList.findIndex(n=>n.path===s),a=this.routeList.findIndex(n=>n.path===e);return i>-1&&o(this.routeList,i),a>-1&&o(this.routeList,a,!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 a=this.wsDataMaxSize,n=((s=i.message)==null?void 0:s.length)??0;n>a&&((o=i.message)==null||o.splice(0,n-a))}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,L,T;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:a=10,fontFamily:n="",fontWeight:u="normal",cacheInterceptConfig:p=!0,cacheNetworkLog:r=!1,cacheConsoleLog:l=!1,barrageVisible:v=!0,barrageShowWhenOpen:S=!1}=h.getDevToolInfo();this.devToolButtonVisible=y.isBoolean(e)?e:t.initShowDevTool??!0,this.useTransition=s,this.baseFontSize=o,this.tagFontSize=i,this.tipsFontSize=a,this.fontFamily=n,this.fontWeight=u,this.cacheInterceptConfig=p,this.cacheNetworkLog=r,this.cacheConsoleLog=l,this.barrageVisible=v,this.barrageShowWhenOpen=S,this.cacheNetworkLog&&(this.networkList=h.getDevToolNetworkList(),this.requestIndex=Math.max(...this.networkList.map(g=>g.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=h.getDevToolConsoleList()),this.setDevToolButtonVisible(this.devToolButtonVisible),this.setDevToolDestroy(!this.devToolButtonVisible);const c=((f=t.pagesJson)==null?void 0:f.pages.map(g=>{var d,x,b;return{...g,type:(b=(x=(d=t.pagesJson)==null?void 0:d.tabBar)==null?void 0:x.list)!=null&&b.some(M=>M.pagePath===g.path)?"nav":"main"}}))??[];(T=(L=t.pagesJson)==null?void 0:L.subPackages)==null||T.forEach(g=>{g.pages.forEach(d=>{c.push({...d,path:`${g.root}/${d.path}`,type:"sub",uvList:[]})})}),this.setRouteList(c)}async getDevData(){var s,o,i,a;const t=await uni.getNetworkType()||{};this.setNetWorkStatus(t);let e="0.0.0.0";try{uni.__dev_tool_platform__==="app"?e=k.getWifiIp()||k.getLanIp()||"0.0.0.0":uni.__dev_tool_platform__==="mp-weixin"&&(e=await k.getMicroAppIp())}catch(n){console.error("[DevTool] Get IP error",n)}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.getDevToolButtonVisible(),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,barrageAllowDrag:this.barrageAllowDrag,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:(a=this.devToolOptions)==null?void 0:a.zIndex,totalConsoleCount:this.totalConsoleCount,totalNetworkCount:this.totalNetworkCount}}getExportData(t){const e={};return Object.entries({exportLog:["consoleList"],exportNetwork:["networkList"],exportTransfer:["transferList"],exportWebSocket:["wsList"],exportUniEvent:["uniEventList"],exportElEvent:["elEventList"],exportScanCodeList:["scanCodeList"],exportNfcList:["nfcList"],exportStorage:["storageList","vuexList","piniaList"]}).forEach(([i,a])=>{t[i]&&a.forEach(n=>{e[n]=this[n]})}),Object.entries({Window:"windowInfo",Device:"deviceInfo",System:"systemInfo"}).forEach(([i,a])=>{var n;t[`export${i}`]&&(e[a]=((n=uni[`get${i}Info`])==null?void 0:n.call(uni))||{errMsg:"not supported"})}),e}clearDevCache(){["consoleList","networkList","wsList","transferList","elEventList","uniEventList","screenList","scanCodeList","nfcList","bluetoothList"].forEach(e=>{this[e]=[]}),this.cacheConsoleLog&&h.setDevToolConsoleList([]),this.cacheNetworkLog&&h.setDevToolNetworkList([])}clearAll(){this.clearDevCache(),this.storageList=[],this.routeList=[],this.interceptNetworkMap.clear()}getCurrentPagePath(){return w.getCurrentPagePath()}}exports.DevStore=z;
@@ -13,8 +13,8 @@ export declare class DevStore {
13
13
  private storageList;
14
14
  private vuexList;
15
15
  private piniaList;
16
- private vuexStore;
17
- private piniaStore;
16
+ private vuexStore?;
17
+ private piniaStore?;
18
18
  private routeList;
19
19
  private prePath;
20
20
  private wsList;
@@ -45,7 +45,7 @@ export declare class DevStore {
45
45
  devToolBuildTime: string;
46
46
  devToolGit: string;
47
47
  private devToolOptions;
48
- private devToolVisible;
48
+ private devToolButtonVisible;
49
49
  private devToolDestroy;
50
50
  private cacheInterceptConfig;
51
51
  private useTransition;
@@ -62,6 +62,7 @@ export declare class DevStore {
62
62
  private barrageStartTop;
63
63
  private barrageDuration;
64
64
  private barrageMaxLength;
65
+ private barrageAllowDrag;
65
66
  private barrageTypes;
66
67
  private barrageShowWhenOpen;
67
68
  private saveConsoleLogThrottled;
@@ -69,26 +70,28 @@ export declare class DevStore {
69
70
  cacheMaxSize: number;
70
71
  constructor();
71
72
  updateHasUpload(): void;
72
- setDevToolVisible(visible: boolean): void;
73
- getDevToolVisible(): boolean;
74
- setDevToolDestroy(destroy: boolean): void;
73
+ private setAndSync;
74
+ setDevToolButtonVisible(v: boolean): void;
75
+ getDevToolButtonVisible(): boolean;
76
+ setDevToolDestroy(v: boolean): void;
75
77
  getDevToolDestroy(): boolean;
76
- setCacheInterceptConfig(value: boolean): void;
78
+ setCacheInterceptConfig(v: boolean): void;
77
79
  getCacheNetworkLog(): boolean;
78
- setUseTransition(value: boolean): void;
79
- setBaseFontSize(value: number): void;
80
- setTagFontSize(value: number): void;
81
- setTipsFontSize(value: number): void;
82
- setFontFamily(value: string): void;
83
- setFontWeight(value: string): void;
84
- setBarrageVisible(value: boolean): void;
85
- setBarrageMaxTracks(value: number): void;
86
- setBarrageTrackHeight(value: number): void;
87
- setBarrageStartTop(value: number): void;
88
- setBarrageDuration(value: number): void;
89
- setBarrageMaxLength(value: number): void;
90
- setBarrageTypes(value: string[]): void;
91
- setBarrageShowWhenOpen(value: boolean): void;
80
+ setUseTransition(v: boolean): void;
81
+ setBaseFontSize(v: number): void;
82
+ setTagFontSize(v: number): void;
83
+ setTipsFontSize(v: number): void;
84
+ setFontFamily(v: string): void;
85
+ setFontWeight(v: string): void;
86
+ setBarrageVisible(v: boolean): void;
87
+ setBarrageMaxTracks(v: number): void;
88
+ setBarrageTrackHeight(v: number): void;
89
+ setBarrageStartTop(v: number): void;
90
+ setBarrageDuration(v: number): void;
91
+ setBarrageMaxLength(v: number): void;
92
+ setBarrageAllowDrag(v: boolean): void;
93
+ setBarrageTypes(v: string[]): void;
94
+ setBarrageShowWhenOpen(v: boolean): void;
92
95
  setCacheConsoleLog(value: boolean): void;
93
96
  setCacheNetworkLog(value: boolean): void;
94
97
  getConsoleList(): DevTool.ConsoleItem[];
@@ -104,24 +107,30 @@ export declare class DevStore {
104
107
  clearInterceptNetworkList(): void;
105
108
  getStorageList(): DevTool.StorageItem[];
106
109
  setStorageList(items: DevTool.StorageItem[]): DevTool.StorageItem[];
107
- getVuexList(): Record<string, any>;
108
- getPiniaList(): Record<string, any>;
109
- setVuexStore(store: any): void;
110
- setVuexList(list: Record<string, any>): void;
111
- setPiniaStore(store: any): void;
112
- setPiniaList(list: Record<string, any>): void;
110
+ getVuexList(): Record<string, unknown>;
111
+ getPiniaList(): Record<string, unknown>;
112
+ setVuexStore(store: {
113
+ state: Record<string, unknown>;
114
+ }): void;
115
+ setVuexList(list: Record<string, unknown>): void;
116
+ setPiniaStore(store: {
117
+ state: {
118
+ value: Record<string, unknown>;
119
+ };
120
+ }): void;
121
+ setPiniaList(list: Record<string, unknown>): void;
113
122
  updateStore(data: {
114
123
  key: string;
115
124
  _oldKey: string;
116
- value: any;
125
+ value: unknown;
117
126
  }): DevTool.StorageItem[];
118
- updateVuexStore(data: Record<string, any>): Record<string, any>;
119
- updatePiniaStore(data: Record<string, any>): Record<string, any>;
127
+ updateVuexStore(data: Record<string, unknown>): Record<string, unknown>;
128
+ updatePiniaStore(data: Record<string, unknown>): Record<string, unknown>;
120
129
  clearStorageList(local?: boolean): DevTool.StorageItem[];
121
130
  removeStorage(key: string, local?: boolean): DevTool.StorageItem[];
122
131
  addStorage(data: {
123
132
  key: string;
124
- value: any;
133
+ value: unknown;
125
134
  }, local?: boolean): DevTool.StorageItem[];
126
135
  refreshStore(): DevTool.StorageItem[];
127
136
  updateStoreList(addItems: DevTool.StorageItem[]): DevTool.StorageItem[];
@@ -155,13 +164,13 @@ export declare class DevStore {
155
164
  getNfcList(): DevTool.NFCItem[];
156
165
  getScreenIndex(): number;
157
166
  setScreenIndex(index: number): number;
158
- getSystemInfo(): Record<string, any>;
159
- getDeviceInfo(): Record<string, any>;
160
- getWindowInfo(): Record<string, any>;
161
- setSystemInfo(info: Record<string, any>): void;
162
- setDeviceInfo(info: Record<string, any>): void;
163
- setWindowInfo(info: Record<string, any>): void;
164
- setNetWorkStatus(info: Record<string, any>): void;
167
+ getSystemInfo(): Record<string, unknown>;
168
+ getDeviceInfo(): Record<string, unknown>;
169
+ getWindowInfo(): Record<string, unknown>;
170
+ setSystemInfo(info: Record<string, unknown>): void;
171
+ setDeviceInfo(info: Record<string, unknown>): void;
172
+ setWindowInfo(info: Record<string, unknown>): void;
173
+ setNetWorkStatus(info: Record<string, unknown>): void;
165
174
  updateScreenList(addItems: DevTool.ScreenItem[], index?: number): void;
166
175
  updateScanCodeList(addItems: DevTool.ScanCodeItem[]): void;
167
176
  updateNfcList(addItems: DevTool.NFCItem[]): void;
@@ -172,9 +181,8 @@ export declare class DevStore {
172
181
  getDevToolOptions(): DevTool.DevToolOptions | undefined;
173
182
  setDevToolOptions(options: DevTool.DevToolOptions): void;
174
183
  getDevData(): Promise<DevTool.WindowData>;
175
- getExportData(exports: any): DevTool.WindowData;
184
+ getExportData(exports: Record<string, boolean>): DevTool.WindowData;
176
185
  clearDevCache(): void;
177
186
  clearAll(): void;
178
187
  getCurrentPagePath(): string;
179
188
  }
180
- //# sourceMappingURL=index.d.ts.map
@@ -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 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
+ import{DEV_TOOL_INFO as I}from"../../const.js";import"../../utils/index.js";import{setDevToolConsoleList as T,setDevToolNetworkList as w,getDevToolNetworkList as y,getDevToolConsoleList as M,setDevToolInfo as k,getDevToolInfo as D}from"../devToolInfo/index.js";import{throttle as m}from"../../utils/function.js";import{isNil as E,isBoolean as N}from"../../utils/language.js";import{setValueByPath as B}from"../../utils/object.js";import{getCurrentPagePath as x}from"../../utils/page.js";import{getWifiIp as F,getLanIp as V,getMicroAppIp as W}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.devToolButtonVisible=!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.barrageAllowDrag=!0,this.barrageTypes=["log","info","warn","error","network","transfer","websocket"],this.barrageShowWhenOpen=!1,this.saveConsoleLogThrottled=m(()=>{this.cacheConsoleLog&&T(this.consoleList)},1e3),this.saveNetworkLogThrottled=m(()=>{this.cacheNetworkLog&&w(this.networkList)},1e3),this.cacheMaxSize=8*1024*1024*10,typeof uni>"u")return;const t=uni.getStorageSync(I)||{};Object.assign(this,t),this.devToolButtonVisible=t.devToolButtonVisible??!1,t.interceptNetworkList&&this.updateInterceptNetworkList(t.interceptNetworkList),this.cacheNetworkLog&&(this.networkList=y(),this.requestIndex=Math.max(...this.networkList.map(e=>e.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=M()),this.totalConsoleCount=this.consoleList.length,this.totalNetworkCount=this.networkList.length}updateHasUpload(){[this.consoleList,this.networkList,this.transferList,this.elEventList,this.uniEventList,this.screenList].forEach(e=>e.forEach(s=>s.hasUpload=!0))}setAndSync(t,e,s){this[t]=e,k({[s||t]:e})}setDevToolButtonVisible(t){this.setAndSync("devToolButtonVisible",t)}getDevToolButtonVisible(){return this.devToolButtonVisible}setDevToolDestroy(t){this.setAndSync("devToolDestroy",t)}getDevToolDestroy(){return this.devToolDestroy}setCacheInterceptConfig(t){this.setAndSync("cacheInterceptConfig",t)}getCacheNetworkLog(){return this.cacheNetworkLog}setUseTransition(t){this.setAndSync("useTransition",t)}setBaseFontSize(t){this.setAndSync("baseFontSize",t)}setTagFontSize(t){this.setAndSync("tagFontSize",t)}setTipsFontSize(t){this.setAndSync("tipsFontSize",t)}setFontFamily(t){this.setAndSync("fontFamily",t)}setFontWeight(t){this.setAndSync("fontWeight",t)}setBarrageVisible(t){this.setAndSync("barrageVisible",t)}setBarrageMaxTracks(t){this.setAndSync("barrageMaxTracks",t)}setBarrageTrackHeight(t){this.setAndSync("barrageTrackHeight",t)}setBarrageStartTop(t){this.setAndSync("barrageStartTop",t)}setBarrageDuration(t){this.setAndSync("barrageDuration",t)}setBarrageMaxLength(t){this.setAndSync("barrageMaxLength",t)}setBarrageAllowDrag(t){this.setAndSync("barrageAllowDrag",t)}setBarrageTypes(t){this.setAndSync("barrageTypes",t)}setBarrageShowWhenOpen(t){this.setAndSync("barrageShowWhenOpen",t)}setCacheConsoleLog(t){this.cacheConsoleLog=t,k({cacheConsoleLog:t}),T(t?this.consoleList:[])}setCacheNetworkLog(t){this.cacheNetworkLog=t,k({cacheNetworkLog:t}),w(t?this.networkList:[])}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&&T([])}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&&w([])}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{};B(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,a)=>({...i,name:i.style.navigationBarTitleText||"无名",uvList:[],index:i.path===s&&a===0?4:i.path===s?3:a===0?2:1})),this.routeList}updateRouteList(t){const e=t?t==="/"?x():t:x(),s=this.prePath;this.routeList=this.routeList.map((n,l)=>({...n,index:n.path===e&&l===0?4:n.path===e?3:l===0?2:1}));const o=(n,l,p)=>{var d,S;if(!n[l])return n;n[l].uvList||(n[l].uvList=[]);const r=n[l],c=r.uvList??[];if(c.length){const h=c.length-1,g=c[h];if(g&&g.inTime&&!g.outTime){const L=Date.now();r.outTime=L,c[h].outTime=L,c[h].duration=L-g.inTime,r.duration=c[h].duration,r.totalDuration=c.reduce((v,u)=>v+(u.duration||0),0),p&&(r.visitTimes=c.length)}else{const L=Date.now();r.inTime=L,r.outTime=0,r.duration=0,(d=r.uvList)==null||d.push({index:h+1,inTime:L,outTime:0,duration:0}),p&&(r.visitTimes=(S=r.uvList)==null?void 0:S.length)}}else{const h=Date.now();r.inTime=h,r.outTime=0,r.duration=0,r.totalDuration=0,r.visitTimes=1,r.uvList=[{index:0,inTime:h,outTime:0,duration:0}]}return n},i=this.routeList.findIndex(n=>n.path===s),a=this.routeList.findIndex(n=>n.path===e);return i>-1&&o(this.routeList,i),a>-1&&o(this.routeList,a,!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 a=this.wsDataMaxSize,n=((s=i.message)==null?void 0:s.length)??0;n>a&&((o=i.message)==null||o.splice(0,n-a))}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 g,L,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:a=10,fontFamily:n="",fontWeight:l="normal",cacheInterceptConfig:p=!0,cacheNetworkLog:r=!1,cacheConsoleLog:c=!1,barrageVisible:d=!0,barrageShowWhenOpen:S=!1}=D();this.devToolButtonVisible=N(e)?e:t.initShowDevTool??!0,this.useTransition=s,this.baseFontSize=o,this.tagFontSize=i,this.tipsFontSize=a,this.fontFamily=n,this.fontWeight=l,this.cacheInterceptConfig=p,this.cacheNetworkLog=r,this.cacheConsoleLog=c,this.barrageVisible=d,this.barrageShowWhenOpen=S,this.cacheNetworkLog&&(this.networkList=y(),this.requestIndex=Math.max(...this.networkList.map(u=>u.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=M()),this.setDevToolButtonVisible(this.devToolButtonVisible),this.setDevToolDestroy(!this.devToolButtonVisible);const h=((g=t.pagesJson)==null?void 0:g.pages.map(u=>{var f,b,C;return{...u,type:(C=(b=(f=t.pagesJson)==null?void 0:f.tabBar)==null?void 0:b.list)!=null&&C.some(z=>z.pagePath===u.path)?"nav":"main"}}))??[];(v=(L=t.pagesJson)==null?void 0:L.subPackages)==null||v.forEach(u=>{u.pages.forEach(f=>{h.push({...f,path:`${u.root}/${f.path}`,type:"sub",uvList:[]})})}),this.setRouteList(h)}async getDevData(){var s,o,i,a;const t=await uni.getNetworkType()||{};this.setNetWorkStatus(t);let e="0.0.0.0";try{uni.__dev_tool_platform__==="app"?e=F()||V()||"0.0.0.0":uni.__dev_tool_platform__==="mp-weixin"&&(e=await W())}catch(n){console.error("[DevTool] Get IP error",n)}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.getDevToolButtonVisible(),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,barrageAllowDrag:this.barrageAllowDrag,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:(a=this.devToolOptions)==null?void 0:a.zIndex,totalConsoleCount:this.totalConsoleCount,totalNetworkCount:this.totalNetworkCount}}getExportData(t){const e={};return Object.entries({exportLog:["consoleList"],exportNetwork:["networkList"],exportTransfer:["transferList"],exportWebSocket:["wsList"],exportUniEvent:["uniEventList"],exportElEvent:["elEventList"],exportScanCodeList:["scanCodeList"],exportNfcList:["nfcList"],exportStorage:["storageList","vuexList","piniaList"]}).forEach(([i,a])=>{t[i]&&a.forEach(n=>{e[n]=this[n]})}),Object.entries({Window:"windowInfo",Device:"deviceInfo",System:"systemInfo"}).forEach(([i,a])=>{var n;t[`export${i}`]&&(e[a]=((n=uni[`get${i}Info`])==null?void 0:n.call(uni))||{errMsg:"not supported"})}),e}clearDevCache(){["consoleList","networkList","wsList","transferList","elEventList","uniEventList","screenList","scanCodeList","nfcList","bluetoothList"].forEach(e=>{this[e]=[]}),this.cacheConsoleLog&&T([]),this.cacheNetworkLog&&w([])}clearAll(){this.clearDevCache(),this.storageList=[],this.routeList=[],this.interceptNetworkMap.clear()}getCurrentPagePath(){return x()}}export{j as DevStore};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../const.cjs"),n="dev-tool-network-list",i="dev-tool-console-list";function u(e){if(typeof uni>"u")return;const t=uni.getStorageSync(o.DEV_TOOL_INFO)||{};uni.setStorageSync(o.DEV_TOOL_INFO,{...t,...e})}function s(){return typeof uni>"u"?{}:uni.getStorageSync(o.DEV_TOOL_INFO)}function r(e){if(typeof uni>"u")return;const t=e.slice(-200);uni.setStorageSync(n,t)}function f(){return typeof uni>"u"?[]:uni.getStorageSync(n)||[]}function c(e){if(typeof uni>"u")return;const t=e.slice(-200);uni.setStorageSync(i,t)}function l(){return typeof uni>"u"?[]:uni.getStorageSync(i)||[]}exports.getDevToolConsoleList=l;exports.getDevToolInfo=s;exports.getDevToolNetworkList=f;exports.setDevToolConsoleList=c;exports.setDevToolInfo=u;exports.setDevToolNetworkList=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../const.cjs"),l="dev-tool-network-list",i="dev-tool-console-list",s=o=>({set:e=>uni==null?void 0:uni.setStorageSync(o,e.slice(-200)),get:()=>(uni==null?void 0:uni.getStorageSync(o))||[]}),n=s(l),c=s(i),T=o=>{const e=(uni==null?void 0:uni.getStorageSync(t.DEV_TOOL_INFO))||{};uni==null||uni.setStorageSync(t.DEV_TOOL_INFO,{...e,...o})},g=()=>(uni==null?void 0:uni.getStorageSync(t.DEV_TOOL_INFO))||{},r=n.set,D=n.get,O=c.set,v=c.get;exports.getDevToolConsoleList=v;exports.getDevToolInfo=g;exports.getDevToolNetworkList=D;exports.setDevToolConsoleList=O;exports.setDevToolInfo=T;exports.setDevToolNetworkList=r;
@@ -1,27 +1,8 @@
1
1
  import { DevTool } from '../../type';
2
2
 
3
- /**
4
- * 缓存调试工具信息到本地
5
- */
6
- export declare function setDevToolInfo(info: DevTool.DevToolInfo): void;
7
- /**
8
- * 获取本地缓存信息
9
- */
10
- export declare function getDevToolInfo(): DevTool.DevToolInfo;
11
- /**
12
- * 缓存网络日志
13
- */
14
- export declare function setDevToolNetworkList(list: DevTool.NetworkItem[]): void;
15
- /**
16
- * 获取缓存的网络日志
17
- */
18
- export declare function getDevToolNetworkList(): DevTool.NetworkItem[];
19
- /**
20
- * 缓存控制台日志
21
- */
22
- export declare function setDevToolConsoleList(list: DevTool.ConsoleItem[]): void;
23
- /**
24
- * 获取缓存的控制台日志
25
- */
26
- export declare function getDevToolConsoleList(): DevTool.ConsoleItem[];
27
- //# sourceMappingURL=index.d.ts.map
3
+ export declare const setDevToolInfo: (info: DevTool.DevToolInfo) => void;
4
+ export declare const getDevToolInfo: () => DevTool.DevToolInfo;
5
+ export declare const setDevToolNetworkList: (list: DevTool.NetworkItem[]) => void;
6
+ export declare const getDevToolNetworkList: () => DevTool.NetworkItem[];
7
+ export declare const setDevToolConsoleList: (list: DevTool.ConsoleItem[]) => void;
8
+ export declare const getDevToolConsoleList: () => DevTool.ConsoleItem[];
@@ -1 +1 @@
1
- import{DEV_TOOL_INFO as t}from"../../const.js";const o="dev-tool-network-list",i="dev-tool-console-list";function r(e){if(typeof uni>"u")return;const n=uni.getStorageSync(t)||{};uni.setStorageSync(t,{...n,...e})}function f(){return typeof uni>"u"?{}:uni.getStorageSync(t)}function c(e){if(typeof uni>"u")return;const n=e.slice(-200);uni.setStorageSync(o,n)}function s(){return typeof uni>"u"?[]:uni.getStorageSync(o)||[]}function S(e){if(typeof uni>"u")return;const n=e.slice(-200);uni.setStorageSync(i,n)}function d(){return typeof uni>"u"?[]:uni.getStorageSync(i)||[]}export{d as getDevToolConsoleList,f as getDevToolInfo,s as getDevToolNetworkList,S as setDevToolConsoleList,r as setDevToolInfo,c as setDevToolNetworkList};
1
+ import{DEV_TOOL_INFO as e}from"../../const.js";const l="dev-tool-network-list",g="dev-tool-console-list",s=o=>({set:t=>uni==null?void 0:uni.setStorageSync(o,t.slice(-200)),get:()=>(uni==null?void 0:uni.getStorageSync(o))||[]}),n=s(l),c=s(g),S=o=>{const t=(uni==null?void 0:uni.getStorageSync(e))||{};uni==null||uni.setStorageSync(e,{...t,...o})},r=()=>(uni==null?void 0:uni.getStorageSync(e))||{},T=n.set,L=n.get,O=c.set,v=c.get;export{v as getDevToolConsoleList,r as getDevToolInfo,L as getDevToolNetworkList,O as setDevToolConsoleList,S as setDevToolInfo,T as setDevToolNetworkList};
@@ -29,4 +29,3 @@ export declare const transformApp: ({ code, isSetup, importConsole, scriptRow, n
29
29
  map: any;
30
30
  };
31
31
  export {};
32
- //# sourceMappingURL=transformApp.d.ts.map
@@ -21,4 +21,3 @@ export declare const transformMain: ({ code, useErrorBoundary, }: TransformMainO
21
21
  map: any;
22
22
  };
23
23
  export {};
24
- //# sourceMappingURL=transformMain.d.ts.map
@@ -39,4 +39,3 @@ export declare const transformVue: ({ id, code, pages, scriptRow, importConsole,
39
39
  map: any;
40
40
  };
41
41
  export {};
42
- //# sourceMappingURL=transformVue.d.ts.map
@@ -112,4 +112,3 @@ export default function uniDevTool({ pages, sourceFileServers, importConsole, ex
112
112
  mode?: string;
113
113
  }): Plugin;
114
114
  export {};
115
- //# sourceMappingURL=uniDevTool.d.ts.map
@@ -31,4 +31,3 @@ export default function uniGlobalComponents({ pages, components, }: {
31
31
  };
32
32
  components: string[];
33
33
  }): Plugin;
34
- //# sourceMappingURL=uniGlobalComponents.d.ts.map
@@ -131,4 +131,3 @@ export declare const isMainFile: (id: string) => boolean;
131
131
  * @return {*}
132
132
  */
133
133
  export declare const isVueFile: (id: string) => boolean;
134
- //# sourceMappingURL=index.d.ts.map