vite-uni-dev-tool 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/README.md +54 -0
  2. package/dist/const.cjs +1 -1
  3. package/dist/const.d.ts +13 -0
  4. package/dist/const.d.ts.map +1 -1
  5. package/dist/const.js +1 -1
  6. package/dist/core-shared.d.ts +1 -1
  7. package/dist/core-shared.d.ts.map +1 -1
  8. package/dist/core-shared.js +1 -1
  9. package/dist/core.d.ts +10 -3
  10. package/dist/core.d.ts.map +1 -1
  11. package/dist/core.js +2 -2
  12. package/dist/i18n/locales/en.cjs +1 -1
  13. package/dist/i18n/locales/en.d.ts +86 -0
  14. package/dist/i18n/locales/en.d.ts.map +1 -1
  15. package/dist/i18n/locales/en.js +1 -1
  16. package/dist/i18n/locales/zh-Hans.cjs +1 -1
  17. package/dist/i18n/locales/zh-Hans.d.ts +87 -1
  18. package/dist/i18n/locales/zh-Hans.d.ts.map +1 -1
  19. package/dist/i18n/locales/zh-Hans.js +1 -1
  20. package/dist/modules/devConsole/index.cjs +1 -1
  21. package/dist/modules/devConsole/index.js +3 -3
  22. package/dist/modules/devEvent/index.cjs +3 -3
  23. package/dist/modules/devEvent/index.d.ts +1 -0
  24. package/dist/modules/devEvent/index.d.ts.map +1 -1
  25. package/dist/modules/devEvent/index.js +3 -3
  26. package/dist/modules/devIntercept/index.cjs +14 -13
  27. package/dist/modules/devIntercept/index.d.ts +20 -1
  28. package/dist/modules/devIntercept/index.d.ts.map +1 -1
  29. package/dist/modules/devIntercept/index.js +14 -13
  30. package/dist/modules/devStore/index.cjs +1 -1
  31. package/dist/modules/devStore/index.d.ts +21 -0
  32. package/dist/modules/devStore/index.d.ts.map +1 -1
  33. package/dist/modules/devStore/index.js +1 -1
  34. package/dist/plugins/uniDevTool/transform/transformMain.cjs +3 -3
  35. package/dist/plugins/uniDevTool/transform/transformMain.d.ts +2 -1
  36. package/dist/plugins/uniDevTool/transform/transformMain.d.ts.map +1 -1
  37. package/dist/plugins/uniDevTool/transform/transformMain.js +3 -3
  38. package/dist/plugins/uniDevTool/transform/transformVue.cjs +31 -25
  39. package/dist/plugins/uniDevTool/transform/transformVue.d.ts +2 -1
  40. package/dist/plugins/uniDevTool/transform/transformVue.d.ts.map +1 -1
  41. package/dist/plugins/uniDevTool/transform/transformVue.js +30 -24
  42. package/dist/plugins/uniDevTool/uniDevTool.cjs +3 -3
  43. package/dist/plugins/uniDevTool/uniDevTool.d.ts +3 -1
  44. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
  45. package/dist/plugins/uniDevTool/uniDevTool.js +3 -3
  46. package/dist/type.d.ts +50 -2
  47. package/dist/type.d.ts.map +1 -1
  48. package/dist/utils/language.cjs +1 -1
  49. package/dist/utils/language.d.ts.map +1 -1
  50. package/dist/utils/language.js +1 -1
  51. package/dist/utils/object.cjs +1 -1
  52. package/dist/utils/object.d.ts.map +1 -1
  53. package/dist/utils/object.js +1 -1
  54. package/dist/v3/DevTool/components/BluetoothList/BluetoothItem.vue +199 -0
  55. package/dist/v3/DevTool/components/BluetoothList/BluetoothTool.vue +730 -0
  56. package/dist/v3/DevTool/components/BluetoothList/index.vue +167 -0
  57. package/dist/v3/{CaptureScreen → DevTool/components/CaptureScreen}/index.vue +4 -4
  58. package/dist/v3/{ConsoleList → DevTool/components/ConsoleList}/ConsoleItem.vue +22 -16
  59. package/dist/v3/{ConsoleList → DevTool/components/ConsoleList}/RunJSInput.vue +4 -6
  60. package/dist/v3/{ConsoleList → DevTool/components/ConsoleList}/index.vue +21 -10
  61. package/dist/v3/{DevToolButton → DevTool/components/DevToolButton}/index.vue +7 -4
  62. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/DevToolOverlay.vue +17 -2
  63. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/const.ts +28 -5
  64. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/hooks/dataUtils.ts +1 -1
  65. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/hooks/useDevToolData.ts +55 -6
  66. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/hooks/useDevToolHandlers.ts +85 -5
  67. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/hooks/useDevToolOverlay.ts +25 -8
  68. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/index.vue +67 -16
  69. package/dist/v3/{ElEvent → DevTool/components/ElEvent}/ElEventItem.vue +3 -3
  70. package/dist/v3/{ElEvent → DevTool/components/ElEvent}/index.vue +10 -13
  71. package/dist/v3/{Instance → DevTool/components/Instance}/index.vue +1 -1
  72. package/dist/v3/{Instance → DevTool/components/Instance}/transformTree.ts +1 -1
  73. package/dist/v3/{Instance → DevTool/components/Instance}/transformTreeCtx.ts +1 -1
  74. package/dist/v3/{InstanceDetail → DevTool/components/InstanceDetail}/index.vue +4 -4
  75. package/dist/v3/{JsonDetail → DevTool/components/JsonDetail}/index.vue +4 -4
  76. package/dist/v3/{NFCList → DevTool/components/NFCList}/NFCItem.vue +4 -5
  77. package/dist/v3/{NFCList → DevTool/components/NFCList}/NFCTool.vue +33 -57
  78. package/dist/v3/{NFCList → DevTool/components/NFCList}/index.vue +12 -16
  79. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/InterceptConfig.vue +20 -4
  80. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/InterceptItem.vue +3 -3
  81. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/NetworkDetail.vue +18 -27
  82. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/NetworkIntercept.vue +11 -16
  83. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/NetworkItem.vue +10 -14
  84. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/NetworkSend.vue +67 -34
  85. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/index.vue +8 -8
  86. package/dist/v3/{Performance → DevTool/components/Performance}/index.vue +7 -4
  87. package/dist/v3/{Performance → DevTool/components/Performance}/modules/PerformanceWidget.vue +12 -9
  88. package/dist/v3/{Performance → DevTool/components/Performance}/modules/usePerformanceChart.ts +1 -1
  89. package/dist/v3/{Performance → DevTool/components/Performance}/modules/usePerformanceData.ts +2 -2
  90. package/dist/v3/{PiniaList → DevTool/components/PiniaList}/index.vue +5 -6
  91. package/dist/v3/{RouteList → DevTool/components/RouteList}/index.vue +21 -24
  92. package/dist/v3/{RunJS → DevTool/components/RunJS}/index.vue +3 -3
  93. package/dist/v3/{ScanCodeList → DevTool/components/ScanCodeList}/ScanCodeItem.vue +3 -4
  94. package/dist/v3/{ScanCodeList → DevTool/components/ScanCodeList}/index.vue +12 -16
  95. package/dist/v3/{SettingList → DevTool/components/SettingList}/index.vue +68 -0
  96. package/dist/v3/DevTool/components/SettingList/modules/SettingBarrage.vue +304 -0
  97. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingDevTool.vue +8 -4
  98. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingInfo.vue +47 -9
  99. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingLanguage.vue +2 -2
  100. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingLog.vue +2 -2
  101. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingNetwork.vue +3 -3
  102. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingTheme.vue +37 -7
  103. package/dist/v3/{SourceCode → DevTool/components/SourceCode}/Line.vue +22 -11
  104. package/dist/v3/{SourceCode → DevTool/components/SourceCode}/index.vue +8 -8
  105. package/dist/v3/{SourceCode → DevTool/components/SourceCode}/parseCode.ts +136 -228
  106. package/dist/v3/{StorageList → DevTool/components/StorageList}/index.vue +7 -7
  107. package/dist/v3/{TransferList → DevTool/components/TransferList}/TransferDetail.vue +6 -6
  108. package/dist/v3/{TransferList → DevTool/components/TransferList}/TransferItem.vue +4 -4
  109. package/dist/v3/{TransferList → DevTool/components/TransferList}/index.vue +8 -8
  110. package/dist/v3/{UniEvent → DevTool/components/UniEvent}/UniEventItem.vue +6 -7
  111. package/dist/v3/{UniEvent → DevTool/components/UniEvent}/index.vue +6 -6
  112. package/dist/v3/{VuexList → DevTool/components/VuexList}/index.vue +3 -3
  113. package/dist/v3/{WebSocket → DevTool/components/WebSocket}/WebSocketDetail.vue +8 -8
  114. package/dist/v3/{WebSocket → DevTool/components/WebSocket}/WebSocketItem.vue +4 -4
  115. package/dist/v3/{WebSocket → DevTool/components/WebSocket}/index.vue +8 -8
  116. package/dist/v3/DevTool/index.vue +179 -4
  117. package/dist/v3/{AppTransition → components/AppTransition}/index.vue +6 -0
  118. package/dist/v3/components/Barrage/BarrageItem.vue +137 -0
  119. package/dist/v3/components/Barrage/index.vue +202 -0
  120. package/dist/v3/components/DevErrorBoundary/index.vue +380 -0
  121. package/dist/v3/{DraggableContainer → components/DraggableContainer}/index.vue +1 -1
  122. package/dist/v3/{FilterInput → components/FilterInput}/index.vue +1 -1
  123. package/dist/v3/{JsonPretty → components/JsonPretty}/components/CheckController/index.vue +1 -1
  124. package/dist/v3/{JsonPretty → components/JsonPretty}/components/TreeNode/index.vue +11 -5
  125. package/dist/v3/{JsonPretty → components/JsonPretty}/index.vue +16 -13
  126. package/dist/v3/{JsonPretty → components/JsonPretty}/type.ts +1 -0
  127. package/dist/v3/{JsonPretty → components/JsonPretty}/utils/index.ts +1 -1
  128. package/dist/v3/{MovableContainer → components/MovableContainer}/index.vue +9 -5
  129. package/dist/v3/{Pick → components/Pick}/index.vue +1 -1
  130. package/dist/v3/{Tabs → components/Tabs}/index.vue +30 -4
  131. package/dist/v3/{VirtualList → components/VirtualList}/AutoSize.vue +1 -1
  132. package/dist/v3/{VirtualList → components/VirtualList}/index.vue +4 -0
  133. package/dist/v3/hooks/useBluetooth/index.ts +561 -0
  134. package/dist/v3/hooks/useRequest/index.ts +33 -20
  135. package/dist/v3/hooks/useWebsocket/README.md +79 -0
  136. package/dist/v3/hooks/useWebsocket/index.ts +253 -0
  137. package/dist/v3/styles/theme.css +17 -10
  138. package/package.json +67 -64
  139. package/dist/plugins/uniParseStock/index.d.ts +0 -10
  140. package/dist/plugins/uniParseStock/index.d.ts.map +0 -1
  141. /package/dist/v3/{ConsoleList → DevTool/components/ConsoleList}/staticTips.ts +0 -0
  142. /package/dist/v3/{DevToolTitle → DevTool/components/DevToolTitle}/index.vue +0 -0
  143. /package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/index.css +0 -0
  144. /package/dist/v3/{Instance → DevTool/components/Instance}/components/InstanceTreeNode.vue +0 -0
  145. /package/dist/v3/{Instance → DevTool/components/Instance}/flatten.ts +0 -0
  146. /package/dist/v3/{Instance → DevTool/components/Instance}/registry.ts +0 -0
  147. /package/dist/v3/{Instance → DevTool/components/Instance}/typing.d.ts +0 -0
  148. /package/dist/v3/{NFCList → DevTool/components/NFCList}/const.ts +0 -0
  149. /package/dist/v3/{NetworkList → DevTool/components/NetworkList}/const.ts +0 -0
  150. /package/dist/v3/{NetworkList → DevTool/components/NetworkList}/hooks/useNetworkForm.ts +0 -0
  151. /package/dist/v3/{NetworkList → DevTool/components/NetworkList}/utils.ts +0 -0
  152. /package/dist/v3/{Performance → DevTool/components/Performance}/modules/PerformanceMetrics.vue +0 -0
  153. /package/dist/v3/{SettingButton → DevTool/components/SettingButton}/index.vue +0 -0
  154. /package/dist/v3/{SettingList → DevTool/components/SettingList}/index.css +0 -0
  155. /package/dist/v3/{SettingList → DevTool/components/SettingList}/typing.d.ts +0 -0
  156. /package/dist/v3/{AutoSizer → components/AutoSizer}/index.vue +0 -0
  157. /package/dist/v3/{AutoSizer → components/AutoSizer}/index1.vue +0 -0
  158. /package/dist/v3/{AutoSizer → components/AutoSizer}/utils.ts +0 -0
  159. /package/dist/v3/{CircularButton → components/CircularButton}/index.vue +0 -0
  160. /package/dist/v3/{CustomSwiper → components/CustomSwiper}/CustomSwiperItem.vue +0 -0
  161. /package/dist/v3/{CustomSwiper → components/CustomSwiper}/index.vue +0 -0
  162. /package/dist/v3/{Empty → components/Empty}/empty.png +0 -0
  163. /package/dist/v3/{Empty → components/Empty}/index.vue +0 -0
  164. /package/dist/v3/{FilterSelect → components/FilterSelect}/index.vue +0 -0
  165. /package/dist/v3/{JsonPretty → components/JsonPretty}/components/Brackets/index.vue +0 -0
  166. /package/dist/v3/{JsonPretty → components/JsonPretty}/components/Carets/index.vue +0 -0
  167. /package/dist/v3/{JsonPretty → components/JsonPretty}/hooks/useClipboard.ts +0 -0
  168. /package/dist/v3/{JsonPretty → components/JsonPretty}/hooks/useError.ts +0 -0
  169. /package/dist/v3/{Tag → components/Tag}/index.vue +0 -0
  170. /package/dist/v3/{VirtualList → components/VirtualList}/readme.md +0 -0
@@ -1 +1 @@
1
- import{DEV_TOOL_INFO as M}from"../../const.js";import"../../utils/index.js";import{setDevToolConsoleList as S,setDevToolNetworkList as T,getDevToolNetworkList as m,getDevToolConsoleList as z,setDevToolInfo as u,getDevToolInfo as y}from"../devToolInfo/index.js";import{throttle as C}from"../../utils/function.js";import{isNil as E,isBoolean as D}from"../../utils/language.js";import{setValueByPath as N}from"../../utils/object.js";import{getCurrentPagePath as k}from"../../utils/page.js";import{getWifiIp as F,getLanIp as b,getMicroAppIp as W}from"../../utils/ip.js";class K{constructor(){if(this.consoleList=[],this.consoleMaxSize=1e3,this.networkList=[],this.networkMaxSize=1e3,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.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.saveConsoleLogThrottled=C(()=>{this.cacheConsoleLog&&S(this.consoleList)},1e3),this.saveNetworkLogThrottled=C(()=>{this.cacheNetworkLog&&T(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:a=!0,baseFontSize:n=12,tagFontSize:L=10,tipsFontSize:v=10,fontFamily:r="",fontWeight:c="normal",interceptNetworkList:f=[]}=uni.getStorageSync(M)||{};this.devToolDestroy=t,this.devToolVisible=e,this.cacheInterceptConfig=s,this.cacheNetworkLog=o,this.cacheConsoleLog=i,this.useTransition=a,this.baseFontSize=n,this.tagFontSize=L,this.tipsFontSize=v,this.fontFamily=r,this.fontWeight=c,this.updateInterceptNetworkList(f),this.cacheNetworkLog&&(this.networkList=m(),this.requestIndex=Math.max(...this.networkList.map(g=>g.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=z())}}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,u({devToolButtonVisible:t})}getDevToolVisible(){return this.devToolVisible}setDevToolDestroy(t){this.devToolDestroy=t,u({devToolDestroy:t})}getDevToolDestroy(){return this.devToolDestroy}setCacheInterceptConfig(t){this.cacheInterceptConfig=t,u({cacheInterceptConfig:t})}getCacheNetworkLog(){return this.cacheNetworkLog}setUseTransition(t){this.useTransition=t,u({useTransition:t})}setBaseFontSize(t){this.baseFontSize=t,u({baseFontSize:t})}setTagFontSize(t){this.tagFontSize=t,u({tagFontSize:t})}setTipsFontSize(t){this.tipsFontSize=t,u({tipsFontSize:t})}setFontFamily(t){this.fontFamily=t,u({fontFamily:t})}setFontWeight(t){this.fontWeight=t,u({fontWeight:t})}setCacheConsoleLog(t){this.cacheConsoleLog=t,u({cacheConsoleLog:t}),t?S(this.consoleList):S([])}setCacheNetworkLog(t){this.cacheNetworkLog=t,u({cacheNetworkLog:t}),t?T(this.networkList):T([])}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.consoleList.length>this.consoleMaxSize&&(this.consoleList=this.consoleList.slice(-this.consoleMaxSize))),this.saveConsoleLogThrottled()}clearConsoleList(){this.consoleList=[],this.cacheConsoleLog&&S([])}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.networkList.length>this.networkMaxSize&&(this.networkList=this.networkList.slice(-this.networkMaxSize))),this.saveNetworkLogThrottled()}clearNetworkList(){this.networkList=[],this.cacheNetworkLog&&T([])}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{};N(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==="/"?k():t:k(),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,v)=>{var f,g;if(!n[L])return n;n[L].uvList||(n[L].uvList=[]);const r=n[L],c=r.uvList??[];if(c.length){const l=c.length-1,p=c[l];if(p&&p.inTime&&!p.outTime){const h=Date.now();r.outTime=h,c[l].outTime=h,c[l].duration=h-p.inTime,r.duration=c[l].duration,r.totalDuration=c.reduce((d,w)=>d+(w.duration||0),0),v&&(r.visitTimes=c.length)}else{const h=Date.now();r.inTime=h,r.outTime=0,r.duration=0,(f=r.uvList)==null||f.push({index:l+1,inTime:h,outTime:0,duration:0}),v&&(r.visitTimes=(g=r.uvList)==null?void 0:g.length)}}else{const l=Date.now();r.inTime=l,r.outTime=0,r.duration=0,r.totalDuration=0,r.visitTimes=1,r.uvList=[{index:0,inTime:l,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;let s;return this.wsTaskMap.forEach((o,i)=>{s||(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)}clearScanCodeList(){this.scanCodeList=[]}clearNfcList(){this.nfcList=[]}getDevToolOptions(){return this.devToolOptions}setDevToolOptions(t){var g,l,p;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:v=!0,cacheNetworkLog:r=!1,cacheConsoleLog:c=!1}=y();this.devToolVisible=D(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=v,this.cacheNetworkLog=r,this.cacheConsoleLog=c,this.cacheNetworkLog&&(this.networkList=m(),this.requestIndex=Math.max(...this.networkList.map(h=>h.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=z()),this.setDevToolVisible(this.devToolVisible),this.setDevToolDestroy(!this.devToolVisible);const f=((g=t.pagesJson)==null?void 0:g.pages.map(h=>{var d,w,x;return{...h,type:(x=(w=(d=t.pagesJson)==null?void 0:d.tabBar)==null?void 0:w.list)!=null&&x.some(I=>I.pagePath===h.path)?"nav":"main"}}))??[];(p=(l=t.pagesJson)==null?void 0:l.subPackages)==null||p.forEach(h=>{h.pages.forEach(d=>{f.push({...d,path:`${h.root}/${d.path}`,type:"sub",uvList:[]})})}),this.setRouteList(f)}async getDevData(){const t=await uni.getNetworkType()||{};this.setNetWorkStatus(t);let e="0.0.0.0";try{uni.__dev_tool_platform__==="app"?e=F()||b()||"0.0.0.0":uni.__dev_tool_platform__==="mp-weixin"&&(e=await W())}catch(s){console.error("[DevTool] Get IP error",s)}return{consoleList:this.consoleList,networkList:this.networkList,storageList:this.storageList,routeList:this.routeList,vuexList:this.vuexList,piniaList:this.piniaList,wsList:this.wsList,transferList:this.transferList,elEventList:this.elEventList,uniEventList:this.uniEventList,eventCount:this.eventCount,screenList:this.screenList,scanCodeList:this.scanCodeList,nfcList:this.nfcList,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,devToolVersion:this.devToolVersion,devToolBuildTime:this.devToolBuildTime,devToolGit:this.devToolGit}}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.cacheConsoleLog&&S([]),this.cacheNetworkLog&&T([])}clearAll(){this.clearDevCache(),this.storageList=[],this.routeList=[],this.interceptNetworkMap.clear()}getCurrentPagePath(){return k()}}export{K as DevStore};
1
+ import{DEV_TOOL_INFO as I}from"../../const.js";import"../../utils/index.js";import{setDevToolConsoleList as w,setDevToolNetworkList as k,getDevToolNetworkList as M,getDevToolConsoleList as m,setDevToolInfo as a,getDevToolInfo as D}from"../devToolInfo/index.js";import{throttle as z}from"../../utils/function.js";import{isNil as E,isBoolean as N}from"../../utils/language.js";import{setValueByPath as F}from"../../utils/object.js";import{getCurrentPagePath as C}from"../../utils/page.js";import{getWifiIp as W,getLanIp as V,getMicroAppIp as B}from"../../utils/ip.js";class J{constructor(){if(this.consoleList=[],this.consoleMaxSize=1e3,this.totalConsoleCount=0,this.networkList=[],this.networkMaxSize=1e3,this.totalNetworkCount=0,this.interceptNetworkMap=new Map,this.requestIndex=-1,this.storageList=[],this.vuexList={},this.piniaList={},this.routeList=[],this.prePath="",this.wsList=[],this.wsDataMaxSize=1e3,this.wsTaskMap=new Map,this.transferList=[],this.transferMaxSize=1e3,this.transferIndex=-1,this.transferTaskMap=new Map,this.elEventList=[],this.uniEventList=[],this.eventCount={on:0,once:0,emit:0,off:0},this.elEventListMaxSize=1e3,this.uniEventListMaxSize=1e3,this.screenList=[],this.scanCodeList=[],this.nfcList=[],this.bluetoothList=[],this.screenIndex=-1,this.screenMaxSize=1e3,this.scanCodeListMaxSize=1e3,this.nfcListMaxSize=1e3,this.systemInfo={},this.deviceInfo={},this.windowInfo={},this.netWorkStatus={},this.devToolVersion="0.0.0",this.devToolBuildTime="",this.devToolGit="",this.devToolVisible=!1,this.devToolDestroy=!1,this.cacheInterceptConfig=!0,this.useTransition=!0,this.cacheNetworkLog=!1,this.cacheConsoleLog=!1,this.baseFontSize=12,this.tagFontSize=10,this.tipsFontSize=10,this.fontFamily="",this.fontWeight="normal",this.barrageVisible=!0,this.barrageMaxTracks=10,this.barrageTrackHeight=36,this.barrageStartTop=40,this.barrageDuration=6,this.barrageMaxLength=100,this.barrageTypes=["log","info","warn","error","network","transfer","websocket"],this.barrageShowWhenOpen=!1,this.saveConsoleLogThrottled=z(()=>{this.cacheConsoleLog&&w(this.consoleList)},1e3),this.saveNetworkLogThrottled=z(()=>{this.cacheNetworkLog&&k(this.networkList)},1e3),this.cacheMaxSize=8*1024*1024*10,typeof uni<"u"){const{devToolDestroy:t=!1,devToolButtonVisible:e=!1,cacheInterceptConfig:s=!0,cacheNetworkLog:o=!1,cacheConsoleLog:i=!1,useTransition:h=!0,baseFontSize:r=12,tagFontSize:l=10,tipsFontSize:d=10,fontFamily:n="",fontWeight:L="normal",barrageVisible:T=!0,barrageMaxTracks:S=10,barrageTrackHeight:c=36,barrageStartTop:f=40,barrageDuration:g=6,barrageMaxLength:v=100,barrageTypes:u=["log","info","warn","error","network","transfer","websocket"],barrageShowWhenOpen:p=!1,interceptNetworkList:b=[]}=uni.getStorageSync(I)||{};this.devToolDestroy=t,this.devToolVisible=e,this.cacheInterceptConfig=s,this.cacheNetworkLog=o,this.cacheConsoleLog=i,this.useTransition=h,this.baseFontSize=r,this.tagFontSize=l,this.tipsFontSize=d,this.fontFamily=n,this.fontWeight=L,this.barrageVisible=T,this.barrageMaxTracks=S,this.barrageTrackHeight=c,this.barrageStartTop=f,this.barrageDuration=g,this.barrageMaxLength=v,this.barrageTypes=u,this.barrageShowWhenOpen=p,this.updateInterceptNetworkList(b),this.cacheNetworkLog&&(this.networkList=M(),this.requestIndex=Math.max(...this.networkList.map(x=>x.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=m()),this.totalConsoleCount=this.consoleList.length,this.totalNetworkCount=this.networkList.length}}updateHasUpload(){this.consoleList=this.consoleList.map(t=>({...t,hasUpload:!0})),this.networkList=this.networkList.map(t=>({...t,hasUpload:!0})),this.transferList=this.transferList.map(t=>({...t,hasUpload:!0})),this.elEventList=this.elEventList.map(t=>({...t,hasUpload:!0})),this.uniEventList=this.uniEventList.map(t=>({...t,hasUpload:!0})),this.screenList=this.screenList.map(t=>({...t,hasUpload:!0}))}setDevToolVisible(t){this.devToolVisible=t,a({devToolButtonVisible:t})}getDevToolVisible(){return this.devToolVisible}setDevToolDestroy(t){this.devToolDestroy=t,a({devToolDestroy:t})}getDevToolDestroy(){return this.devToolDestroy}setCacheInterceptConfig(t){this.cacheInterceptConfig=t,a({cacheInterceptConfig:t})}getCacheNetworkLog(){return this.cacheNetworkLog}setUseTransition(t){this.useTransition=t,a({useTransition:t})}setBaseFontSize(t){this.baseFontSize=t,a({baseFontSize:t})}setTagFontSize(t){this.tagFontSize=t,a({tagFontSize:t})}setTipsFontSize(t){this.tipsFontSize=t,a({tipsFontSize:t})}setFontFamily(t){this.fontFamily=t,a({fontFamily:t})}setFontWeight(t){this.fontWeight=t,a({fontWeight:t})}setBarrageVisible(t){this.barrageVisible=t,a({barrageVisible:t})}setBarrageMaxTracks(t){this.barrageMaxTracks=t,a({barrageMaxTracks:t})}setBarrageTrackHeight(t){this.barrageTrackHeight=t,a({barrageTrackHeight:t})}setBarrageStartTop(t){this.barrageStartTop=t,a({barrageStartTop:t})}setBarrageDuration(t){this.barrageDuration=t,a({barrageDuration:t})}setBarrageMaxLength(t){this.barrageMaxLength=t,a({barrageMaxLength:t})}setBarrageTypes(t){this.barrageTypes=t,a({barrageTypes:t})}setBarrageShowWhenOpen(t){this.barrageShowWhenOpen=t,a({barrageShowWhenOpen:t})}setCacheConsoleLog(t){this.cacheConsoleLog=t,a({cacheConsoleLog:t}),t?w(this.consoleList):w([])}setCacheNetworkLog(t){this.cacheNetworkLog=t,a({cacheNetworkLog:t}),t?k(this.networkList):k([])}getConsoleList(){return this.consoleList}updateConsoleList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.consoleList[e]&&(this.consoleList[e]=t[0]):(this.consoleList.push(...t),this.totalConsoleCount+=t.length,this.consoleList.length>this.consoleMaxSize&&(this.consoleList=this.consoleList.slice(-this.consoleMaxSize))),this.saveConsoleLogThrottled()}clearConsoleList(){this.consoleList=[],this.totalConsoleCount=0,this.cacheConsoleLog&&w([])}getNetworkList(){return this.networkList}updateNetworkList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.networkList[e]&&(this.networkList[e]=t[0]):(this.networkList.push(...t),this.totalNetworkCount+=t.length,this.networkList.length>this.networkMaxSize&&(this.networkList=this.networkList.slice(-this.networkMaxSize))),this.saveNetworkLogThrottled()}clearNetworkList(){this.networkList=[],this.totalNetworkCount=0,this.cacheNetworkLog&&k([])}getInterceptNetworkMap(){return this.interceptNetworkMap}getRequestIndex(){return this.requestIndex}setRequestIndex(t){return this.requestIndex=t,this.requestIndex}updateInterceptNetworkList(t){this.interceptNetworkMap.clear(),t.forEach(e=>{var o;const s=`${(o=e.method)==null?void 0:o.toUpperCase()}|${e.url}`;this.interceptNetworkMap.set(s,e)})}clearInterceptNetworkList(){this.clearNetworkList()}getStorageList(){return this.storageList}setStorageList(t){return this.storageList=t,this.storageList}getVuexList(){return this.vuexList}getPiniaList(){return this.piniaList}setVuexStore(t){this.vuexStore=t}setVuexList(t){this.vuexList=t}setPiniaStore(t){this.piniaStore=t}setPiniaList(t){this.piniaList={...this.piniaList||{},...t}}updateStore(t){const{key:e,_oldKey:s,value:o}=t;return s===e&&(uni.removeStorageSync(s),this.storageList=this.storageList.filter(i=>i.key!==s)),uni.setStorageSync(e,o),this.storageList}updateVuexStore(t){var e,s;try{Object.assign(((e=this.vuexStore)==null?void 0:e.state)??{},t)}catch(o){console.error("[DevTool] updateVuexStore error",o)}return this.setVuexList({...((s=this.vuexStore)==null?void 0:s.state)??{}}),this.vuexList}updatePiniaStore(t){try{if(!this.piniaStore)return{};const[e,s]=Object.entries(t)[0];if(E(e))return{};F(this.piniaStore.state.value,e,s),this.setPiniaList({...this.piniaStore.state.value??{}})}catch(e){console.error("[DevTool] updatePiniaStore error",e)}return this.piniaList}clearStorageList(t){return this.storageList=[],t&&uni.clearStorage(),this.storageList}removeStorage(t,e){return this.storageList=this.storageList.filter(s=>s.key!==t),e&&uni.removeStorageSync(t),this.storageList}addStorage(t,e){const{key:s,value:o}=t;return this.storageList.unshift({key:s,_oldKey:s,value:o}),e&&uni.setStorageSync(s,o),this.storageList}refreshStore(){const{keys:t}=uni.getStorageInfoSync();return this.storageList=t.map(e=>{const s=uni.getStorageSync(e);return{key:e,_oldKey:e,value:s}}),this.storageList}updateStoreList(t){const e=t[0],s=this.storageList.findIndex(o=>o.key===e._oldKey);return s>-1&&t.length===1?this.storageList[s]=t[0]:this.storageList.push(...t),this.storageList}getRouteList(){return this.routeList}setRouteList(t,e){var o;const s=e||((o=t==null?void 0:t[0])==null?void 0:o.path)||"";return this.routeList=t.map((i,h)=>({...i,name:i.style.navigationBarTitleText||"无名",uvList:[],index:i.path===s&&h===0?4:i.path===s?3:h===0?2:1})),this.routeList}updateRouteList(t){const e=t?t==="/"?C():t:C(),s=this.prePath;this.routeList=this.routeList.map((r,l)=>({...r,index:r.path===e&&l===0?4:r.path===e?3:l===0?2:1}));const o=(r,l,d)=>{var T,S;if(!r[l])return r;r[l].uvList||(r[l].uvList=[]);const n=r[l],L=n.uvList??[];if(L.length){const c=L.length-1,f=L[c];if(f&&f.inTime&&!f.outTime){const g=Date.now();n.outTime=g,L[c].outTime=g,L[c].duration=g-f.inTime,n.duration=L[c].duration,n.totalDuration=L.reduce((v,u)=>v+(u.duration||0),0),d&&(n.visitTimes=L.length)}else{const g=Date.now();n.inTime=g,n.outTime=0,n.duration=0,(T=n.uvList)==null||T.push({index:c+1,inTime:g,outTime:0,duration:0}),d&&(n.visitTimes=(S=n.uvList)==null?void 0:S.length)}}else{const c=Date.now();n.inTime=c,n.outTime=0,n.duration=0,n.totalDuration=0,n.visitTimes=1,n.uvList=[{index:0,inTime:c,outTime:0,duration:0}]}return r},i=this.routeList.findIndex(r=>r.path===s),h=this.routeList.findIndex(r=>r.path===e);return i>-1&&o(this.routeList,i),h>-1&&o(this.routeList,h,!0),this.prePath=e,this.routeList}getWsList(){return this.wsList}updateWsList(t){var s,o;const e=this.wsList.findIndex(i=>i.url===t.url);if(e>-1){const i=this.wsList[e];i.headers=t.headers??i.headers,i.readyState=t.readyState??i.readyState,i.method=t.method??i.method,i.protocols=t.protocols??i.protocols,i.message=[...i.message??[],...t.message??[]];const h=this.wsDataMaxSize,r=((s=i.message)==null?void 0:s.length)??0;r>h&&((o=i.message)==null||o.splice(0,r-h))}else this.wsList.push(t);return this.wsList}clearWsList(){this.wsList=[]}clearWsMessage(t){const e=this.wsList.findIndex(s=>s.url===t);e>-1&&(this.wsList[e].message=[])}addWsTask(t,e){this.wsTaskMap.set(t,e)}removeWsTask(t){this.wsTaskMap.delete(t)}getWsTask(t){const e=this.wsTaskMap.get(t);if(e)return e;if(!t)return;let s;return this.wsTaskMap.forEach((o,i)=>{s||i&&(i.includes(t)||t.includes(i))&&(s=o)}),s}getTransferList(){return this.transferList}updateTransferList(t,e){if(typeof e=="number"&&e>-1&&t.length===1){const s=t[0],o=this.transferList.findIndex(i=>i.index===e);o>-1?this.transferList[o]={...this.transferList[o],...s}:this.transferList.push(s)}else this.transferList.length+t.length>this.transferMaxSize&&(this.transferList=[]),this.transferList.push(...t)}getTransferIndex(){return this.transferIndex}setTransferIndex(t){return this.transferIndex=t,this.transferIndex}addTransferTask(t,e){this.transferTaskMap.set(t,e)}removeTransferTask(t){this.transferTaskMap.delete(t)}clearTransferTask(){this.transferTaskMap.clear()}getElEventList(){return this.elEventList}getUniEventList(){return this.uniEventList}getEventCount(){return this.eventCount}addElEvent(t){this.elEventList.length>=this.elEventListMaxSize&&this.elEventList.shift(),this.elEventList.push(t)}clearElEventList(){this.elEventList=[]}updateUniEventList(t){this.uniEventList.length+t.length>this.uniEventListMaxSize&&(this.uniEventList=[]),this.uniEventList.push(...t)}updateUniEventCount(t){this.eventCount[t]++}clearUniEventList(){this.uniEventList=[],this.eventCount={on:0,once:0,emit:0,off:0}}getScreenList(){return this.screenList}getScanCodeList(){return this.scanCodeList}getNfcList(){return this.nfcList}getScreenIndex(){return this.screenIndex}setScreenIndex(t){return this.screenIndex=t,this.screenIndex}getSystemInfo(){return this.systemInfo}getDeviceInfo(){return this.deviceInfo}getWindowInfo(){return this.windowInfo}setSystemInfo(t){this.systemInfo=t}setDeviceInfo(t){this.deviceInfo=t}setWindowInfo(t){this.windowInfo=t}setNetWorkStatus(t){this.netWorkStatus=t}updateScreenList(t,e){typeof e=="number"&&e>-1&&t.length===1?this.screenList[e]&&(this.screenList[e]=t[0]):(this.screenList.length+t.length>this.screenMaxSize&&(this.screenList=[]),this.screenList.push(...t))}updateScanCodeList(t){this.scanCodeList.length+t.length>this.scanCodeListMaxSize&&(this.scanCodeList=[]),this.scanCodeList.push(...t)}updateNfcList(t){this.nfcList.length+t.length>this.nfcListMaxSize&&(this.nfcList=[]),this.nfcList.push(...t)}updateBluetoothList(t){this.bluetoothList=t}clearScanCodeList(){this.scanCodeList=[]}clearNfcList(){this.nfcList=[]}clearBluetoothList(){this.bluetoothList=[]}getDevToolOptions(){return this.devToolOptions}setDevToolOptions(t){var f,g,v;this.devToolOptions=t,this.transferMaxSize=t.uploadMaxSize||1e3,this.consoleMaxSize=t.consoleMaxSize||1e3,this.networkMaxSize=t.networkMaxSize||1e3,this.wsDataMaxSize=t.wsDataMaxSize||1e3,this.elEventListMaxSize=t.elEventListMaxSize||1e3,this.uniEventListMaxSize=t.uniEventListMaxSize||1e3,this.screenMaxSize=t.screenMaxSize||1e3,this.scanCodeListMaxSize=t.scanCodeListMaxSize||1e3,this.nfcListMaxSize=t.nfcListMaxSize||1e3,this.devToolVersion=t.devToolVersion??"0.0.0",this.devToolBuildTime=t.devToolBuildTime??"",this.devToolGit=t.devToolGit??"";const{devToolButtonVisible:e,useTransition:s=!0,baseFontSize:o=12,tagFontSize:i=10,tipsFontSize:h=10,fontFamily:r="",fontWeight:l="normal",cacheInterceptConfig:d=!0,cacheNetworkLog:n=!1,cacheConsoleLog:L=!1,barrageVisible:T=!0,barrageShowWhenOpen:S=!1}=D();this.devToolVisible=N(e)?e:t.initShowDevTool??!0,this.useTransition=s,this.baseFontSize=o,this.tagFontSize=i,this.tipsFontSize=h,this.fontFamily=r,this.fontWeight=l,this.cacheInterceptConfig=d,this.cacheNetworkLog=n,this.cacheConsoleLog=L,this.barrageVisible=T,this.barrageShowWhenOpen=S,this.cacheNetworkLog&&(this.networkList=M(),this.requestIndex=Math.max(...this.networkList.map(u=>u.index??-1),-1)),this.cacheConsoleLog&&(this.consoleList=m()),this.setDevToolVisible(this.devToolVisible),this.setDevToolDestroy(!this.devToolVisible);const c=((f=t.pagesJson)==null?void 0:f.pages.map(u=>{var p,b,x;return{...u,type:(x=(b=(p=t.pagesJson)==null?void 0:p.tabBar)==null?void 0:b.list)!=null&&x.some(y=>y.pagePath===u.path)?"nav":"main"}}))??[];(v=(g=t.pagesJson)==null?void 0:g.subPackages)==null||v.forEach(u=>{u.pages.forEach(p=>{c.push({...p,path:`${u.root}/${p.path}`,type:"sub",uvList:[]})})}),this.setRouteList(c)}async getDevData(){var s,o,i,h;const t=await uni.getNetworkType()||{};this.setNetWorkStatus(t);let e="0.0.0.0";try{uni.__dev_tool_platform__==="app"?e=W()||V()||"0.0.0.0":uni.__dev_tool_platform__==="mp-weixin"&&(e=await B())}catch(r){console.error("[DevTool] Get IP error",r)}return{consoleList:this.consoleList,networkList:this.networkList,storageList:this.storageList,routeList:this.routeList,vuexList:this.vuexList,piniaList:this.piniaList,wsList:this.wsList,transferList:this.transferList,elEventList:this.elEventList,uniEventList:this.uniEventList,eventCount:this.eventCount,screenList:this.screenList,scanCodeList:this.scanCodeList,nfcList:this.nfcList,bluetoothList:this.bluetoothList,systemInfo:this.systemInfo,deviceInfo:this.deviceInfo,windowInfo:this.windowInfo,netWorkStatus:{ip:e,...t,isConnected:t.networkType!=="none"},devToolVisible:this.getDevToolVisible(),cacheInterceptConfig:this.cacheInterceptConfig,cacheNetworkLog:this.cacheNetworkLog,cacheConsoleLog:this.cacheConsoleLog,useTransition:this.useTransition,baseFontSize:this.baseFontSize,tagFontSize:this.tagFontSize,tipsFontSize:this.tipsFontSize,fontFamily:this.fontFamily,fontWeight:this.fontWeight,barrageVisible:this.barrageVisible,barrageMaxTracks:this.barrageMaxTracks,barrageTrackHeight:this.barrageTrackHeight,barrageStartTop:this.barrageStartTop,barrageDuration:this.barrageDuration,barrageMaxLength:this.barrageMaxLength,barrageTypes:[...this.barrageTypes],barrageShowWhenOpen:this.barrageShowWhenOpen,devToolVersion:this.devToolVersion,devToolBuildTime:this.devToolBuildTime,devToolGit:this.devToolGit,sourceFileServers:(s=this.devToolOptions)==null?void 0:s.sourceFileServers,mode:(o=this.devToolOptions)==null?void 0:o.mode,useDevSource:(i=this.devToolOptions)==null?void 0:i.useDevSource,zIndex:(h=this.devToolOptions)==null?void 0:h.zIndex,totalConsoleCount:this.totalConsoleCount,totalNetworkCount:this.totalNetworkCount}}getExportData(t){const e={};return t.exportLog&&(e.consoleList=this.consoleList),t.exportNetwork&&(e.networkList=this.networkList),t.exportStorage&&(e.storageList=this.storageList,e.vuexList=this.vuexList,e.piniaList=this.piniaList),t.exportTransfer&&(e.transferList=this.transferList),t.exportWebSocket&&(e.wsList=this.wsList),t.exportWindow&&(e.windowInfo=uni.getWindowInfo?uni.getWindowInfo():{errMsg:"not supported"}),t.exportDevice&&(e.deviceInfo=uni.getDeviceInfo?uni.getDeviceInfo():{errMsg:"not supported"}),t.exportSystem&&(e.systemInfo=uni.getSystemInfo?uni.getSystemInfo():{errMsg:"not supported"}),t.exportUniEvent&&(e.uniEventList=this.uniEventList),t.exportElEvent&&(e.elEventList=this.elEventList),t.exportScanCodeList&&(e.scanCodeList=this.scanCodeList),t.exportNfcList&&(e.nfcList=this.nfcList),e}clearDevCache(){this.consoleList=[],this.networkList=[],this.wsList=[],this.transferList=[],this.elEventList=[],this.uniEventList=[],this.screenList=[],this.scanCodeList=[],this.nfcList=[],this.bluetoothList=[],this.cacheConsoleLog&&w([]),this.cacheNetworkLog&&k([])}clearAll(){this.clearDevCache(),this.storageList=[],this.routeList=[],this.interceptNetworkMap.clear()}getCurrentPagePath(){return C()}}export{J as DevStore};
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../utils/index.cjs");function c(i){const{lines:e}=i,n=[...e],t=s.findInsertionIndex(n,o=>o.trim().startsWith("import")||o.trim().startsWith("export"));t!==-1&&n.splice(t,0,"import DevTool from 'vite-uni-dev-tool/dist/v3/DevTool/index.vue';","import { recordInstance } from 'vite-uni-dev-tool/dist/v3/Instance/registry';");const r=s.findInsertionIndex(n,o=>o.includes("const app = createSSRApp(App)"));return r!==-1&&n.splice(r+1,0," app.mixin({ "," mounted() { recordInstance(this.$); },"," updated() { recordInstance(this.$); }"," });"," app.component('DevTool', DevTool);"),n}const p=({code:i})=>{try{const e=i.split(`
2
- `),t=c({lines:e});return t.length===e.length&&t.every((r,o)=>r===e[o])?{code:i,map:null}:{code:t.join(`
3
- `),map:null}}catch(e){return console.error("[DevTool] 转换 main 文件时出错:",e),{code:i,map:null}}};exports.transformMain=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../utils/index.cjs");function p(r){const{lines:s,useErrorBoundary:e}=r,n=[...s],t=c.findInsertionIndex(n,o=>o.trim().startsWith("import")||o.trim().startsWith("export"));if(t!==-1){const o=["import DevTool from 'vite-uni-dev-tool/dist/v3/DevTool/index.vue';","import { recordInstance } from 'vite-uni-dev-tool/dist/v3/DevTool/components/Instance/registry';"];e&&o.push("import DevErrorBoundary from 'vite-uni-dev-tool/dist/v3/components/DevErrorBoundary/index.vue';"),n.splice(t,0,...o)}const i=c.findInsertionIndex(n,o=>o.includes("const app = createSSRApp(App)"));if(i!==-1){const o=[" app.mixin({ "," mounted() { recordInstance(this.$); },"," updated() { recordInstance(this.$); }"," });"," app.component('DevTool', DevTool);"];e&&o.push(" app.component('DevErrorBoundary', DevErrorBoundary);"),n.splice(i+1,0,...o)}return n}const d=({code:r,useErrorBoundary:s})=>{try{const e=r.split(`
2
+ `),t=p({lines:e,useErrorBoundary:!!s});return t.length===e.length&&t.every((i,o)=>i===e[o])?{code:r,map:null}:{code:t.join(`
3
+ `),map:null}}catch(e){return console.error("[DevTool] 转换 main 文件时出错:",e),{code:r,map:null}}};exports.transformMain=d;
@@ -1,5 +1,6 @@
1
1
  interface TransformMainOptions {
2
2
  code: string;
3
+ useErrorBoundary: boolean;
3
4
  }
4
5
  /**
5
6
  * 转换 main.ts|js 文件
@@ -15,7 +16,7 @@ interface TransformMainOptions {
15
16
  * map: any;
16
17
  * }}
17
18
  */
18
- export declare const transformMain: ({ code, }: TransformMainOptions) => {
19
+ export declare const transformMain: ({ code, useErrorBoundary, }: TransformMainOptions) => {
19
20
  code: string;
20
21
  map: any;
21
22
  };
@@ -1 +1 @@
1
- {"version":3,"file":"transformMain.d.ts","sourceRoot":"","sources":["../../../../src/plugins/uniDevTool/transform/transformMain.ts"],"names":[],"mappings":"AAEA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd;AAqFD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,cAEvB,oBAAoB;UACf,MAAM;SACP,GAAG;CA6BT,CAAC"}
1
+ {"version":3,"file":"transformMain.d.ts","sourceRoot":"","sources":["../../../../src/plugins/uniDevTool/transform/transformMain.ts"],"names":[],"mappings":"AAEA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AA8FD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,gCAGvB,oBAAoB;UACf,MAAM;SACP,GAAG;CAgCT,CAAC"}
@@ -1,3 +1,3 @@
1
- import{findInsertionIndex as s}from"../../utils/index.js";function c(i){const{lines:t}=i,e=[...t],o=s(e,n=>n.trim().startsWith("import")||n.trim().startsWith("export"));o!==-1&&e.splice(o,0,"import DevTool from 'vite-uni-dev-tool/dist/v3/DevTool/index.vue';","import { recordInstance } from 'vite-uni-dev-tool/dist/v3/Instance/registry';");const r=s(e,n=>n.includes("const app = createSSRApp(App)"));return r!==-1&&e.splice(r+1,0," app.mixin({ "," mounted() { recordInstance(this.$); },"," updated() { recordInstance(this.$); }"," });"," app.component('DevTool', DevTool);"),e}const l=({code:i})=>{try{const t=i.split(`
2
- `),o=c({lines:t});return o.length===t.length&&o.every((r,n)=>r===t[n])?{code:i,map:null}:{code:o.join(`
3
- `),map:null}}catch(t){return console.error("[DevTool] 转换 main 文件时出错:",t),{code:i,map:null}}};export{l as transformMain};
1
+ import{findInsertionIndex as p}from"../../utils/index.js";function c(r){const{lines:s,useErrorBoundary:e}=r,t=[...s],n=p(t,o=>o.trim().startsWith("import")||o.trim().startsWith("export"));if(n!==-1){const o=["import DevTool from 'vite-uni-dev-tool/dist/v3/DevTool/index.vue';","import { recordInstance } from 'vite-uni-dev-tool/dist/v3/DevTool/components/Instance/registry';"];e&&o.push("import DevErrorBoundary from 'vite-uni-dev-tool/dist/v3/components/DevErrorBoundary/index.vue';"),t.splice(n,0,...o)}const i=p(t,o=>o.includes("const app = createSSRApp(App)"));if(i!==-1){const o=[" app.mixin({ "," mounted() { recordInstance(this.$); },"," updated() { recordInstance(this.$); }"," });"," app.component('DevTool', DevTool);"];e&&o.push(" app.component('DevErrorBoundary', DevErrorBoundary);"),t.splice(i+1,0,...o)}return t}const u=({code:r,useErrorBoundary:s})=>{try{const e=r.split(`
2
+ `),n=c({lines:e,useErrorBoundary:!!s});return n.length===e.length&&n.every((i,o)=>i===e[o])?{code:r,map:null}:{code:n.join(`
3
+ `),map:null}}catch(e){return console.error("[DevTool] 转换 main 文件时出错:",e),{code:r,map:null}}};export{u as transformMain};
@@ -1,41 +1,47 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../utils/index.cjs");function v(e,t){var c;const r=t.pages.some(o=>e.includes(o.path)),n=((c=t.subPackages)==null?void 0:c.some(o=>o.pages.some(u=>e.includes(`${o.root}/${u.path}`))))??!1;return{isPage:r,isSubPage:n}}function m(e,t,r,n){return{shouldInjectConsole:!!n,hasExistingConsoleImport:i.hasImportConsole(e),usesConsole:i.hasUseConsole(e),isExcludedFromConsole:!i.hasDirOrFile(t,r)}}function d(e,t,r,n){const{isPage:c,isSubPage:o}=v(e,r);return{isPageOrSubPage:c||o,hasTemplate:t.includes("<template>"),isExcludedFromDevTool:!i.hasDirOrFile(e,n)}}function h(e,t,r){const n=e.match(i.regScript);if(!n||!n[1])return e;const c=n[1];let o="";r&&(o="import { console } from 'vite-uni-dev-tool/dist/core';");const u=`
2
- ${o}
3
- ${c}
4
- `.trim();return e.replace(i.regScript,()=>`${t}
5
- ${u}
6
- <\/script>`)}function C(e,t){const r=e.match(i.regScript);if(!r||!r[1])return e;const n=r[1];if(n.includes("devCaptureTapEvent"))return e;const o=t.includes('lang="ts"')||t.includes('lang="typescript"')?": any":"",u=`
7
- function devCaptureTapEvent(e${o}) {
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../utils/index.cjs");let v=null;function m(e){var o;if(v)return v;const t=new Set;return e.pages.forEach(n=>t.add(n.path)),(o=e.subPackages)==null||o.forEach(n=>{n.pages.forEach(a=>t.add(`${n.root}/${a.path}`))}),v=t,t}function h(e,t){const o=m(t);return{isPage:Array.from(o).some(a=>e.includes(a.replace(/\\/g,"/"))),isSubPage:!1}}function f(e,t,o,n){return{shouldInjectConsole:!!n,hasExistingConsoleImport:c.hasImportConsole(e),usesConsole:c.hasUseConsole(e),isExcludedFromConsole:!c.hasDirOrFile(t,o)}}function C(e,t,o,n){const{isPage:a}=h(e,o);return a?{isPageOrSubPage:!0,hasTemplate:t.indexOf("<template>")!==-1,isExcludedFromDevTool:!c.hasDirOrFile(e,n)}:{isPageOrSubPage:!1,hasTemplate:!1,isExcludedFromDevTool:!0}}function g(e,t,o){const n=e.match(c.regScript);if(!n||!n[1])return e;const a=n[1];let r="";o&&(r="import { console } from 'vite-uni-dev-tool/dist/core';");const s=`
2
+ ${r}
3
+ ${a}
4
+ `.trim();return e.replace(c.regScript,()=>`${t}
5
+ ${s}
6
+ <\/script>`)}function T(e,t){const o=e.match(c.regScript);if(!o||!o[1])return e;const n=o[1];if(n.includes("devCaptureTapEvent"))return e;const r=t.includes('lang="ts"')||t.includes('lang="typescript"')?": any":"",s=`
7
+ function devCaptureTapEvent(e${r}) {
8
8
  uni?.$emit('dev-capture-tap-event', e);
9
9
  }
10
10
 
11
- function devCaptureTouchStartEvent(e${o}) {
11
+ function devCaptureTouchStartEvent(e${r}) {
12
12
  uni?.$emit('dev-capture-touch-start-event', e);
13
13
  }
14
14
 
15
- function devCaptureTouchMoveEvent(e${o}) {
15
+ function devCaptureTouchMoveEvent(e${r}) {
16
16
  uni?.$emit('dev-capture-touch-move-event', e);
17
17
  }
18
18
 
19
- function devCaptureTouchEndEvent(e${o}) {
19
+ function devCaptureTouchEndEvent(e${r}) {
20
20
  uni?.$emit('dev-capture-touch-end-event', e);
21
21
  }
22
- `,s=`
22
+ `,p=`
23
23
  ${n}
24
- ${u}
25
- `.trim();return e.replace(i.regScript,()=>`${t}
26
24
  ${s}
27
- <\/script>`)}function f(e){const t=i.getTemplateContent(e);if(!t)return e;const{pageMetas:r,resetContent:n}=i.extractTopLevelPageMeta(t),c=`
28
- ${r}
25
+ `.trim();return e.replace(c.regScript,()=>`${t}
26
+ ${p}
27
+ <\/script>`)}function E(e,t){const o=c.getTemplateContent(e);if(!o)return e;const{pageMetas:n,resetContent:a}=c.extractTopLevelPageMeta(o);let r=`
28
+ <view
29
+ data-dev-capture
30
+ @tap.capture="devCaptureTapEvent"
31
+ @touchstart.capture="devCaptureTouchStartEvent"
32
+ @touchmove.capture="devCaptureTouchMoveEvent"
33
+ @touchend.capture="devCaptureTouchEndEvent"
34
+ >
35
+ ${a}
36
+ </view>
37
+ `;t&&(r=`
38
+ <DevErrorBoundary>
39
+ ${r}
40
+ </DevErrorBoundary>
41
+ `);const s=`
42
+ ${n}
29
43
  <view data-dev-page>
30
- <view
31
- data-dev-capture
32
- @tap.capture="devCaptureTapEvent"
33
- @touchstart.capture="devCaptureTouchStartEvent"
34
- @touchmove.capture="devCaptureTouchMoveEvent"
35
- @touchend.capture="devCaptureTouchEndEvent"
36
- >
37
- ${n}
38
- </view>
44
+ ${r}
39
45
  <DevTool />
40
46
  </view>
41
- `;return e.replace(t,()=>c)}const g=({id:e,code:t,pages:r,scriptRow:n,importConsole:c,excludeImportConsole:o,excludeImportDevTool:u})=>{try{let s=t;const a=m(t,e,o,c),l=a.shouldInjectConsole&&!a.hasExistingConsoleImport&&a.usesConsole&&a.isExcludedFromConsole;l&&(s=h(s,n,l));const p=d(e,t,r,u);return p.isPageOrSubPage&&p.hasTemplate&&p.isExcludedFromDevTool&&(s=f(s),s=C(s,n)),{code:s,map:null}}catch(s){return console.error("[DevTool] 转换 Vue 文件时出错:",s),{code:t,map:null}}};exports.transformVue=g;
47
+ `;return e.replace(o,()=>s)}const $=({id:e,code:t,pages:o,scriptRow:n,importConsole:a,excludeImportConsole:r,excludeImportDevTool:s,useErrorBoundary:p})=>{try{let i=t;const u=f(t,e,r,a),d=u.shouldInjectConsole&&!u.hasExistingConsoleImport&&u.usesConsole&&u.isExcludedFromConsole;d&&(i=g(i,n,d));const l=C(e,t,o,s);return l.isPageOrSubPage&&l.hasTemplate&&l.isExcludedFromDevTool&&(i=E(i,p),i=T(i,n)),{code:i,map:null}}catch(i){return console.error("[DevTool] 转换 Vue 文件时出错:",i),{code:t,map:null}}};exports.transformVue=$;
@@ -16,6 +16,7 @@ interface TransformVueOptions {
16
16
  importConsole?: boolean;
17
17
  excludeImportConsole: string[];
18
18
  excludeImportDevTool: string[];
19
+ useErrorBoundary: boolean;
19
20
  }
20
21
  /**
21
22
  *
@@ -33,7 +34,7 @@ interface TransformVueOptions {
33
34
  * }
34
35
  * @return {*} {{ code: string; map: any }}
35
36
  */
36
- export declare const transformVue: ({ id, code, pages, scriptRow, importConsole, excludeImportConsole, excludeImportDevTool, }: TransformVueOptions) => {
37
+ export declare const transformVue: ({ id, code, pages, scriptRow, importConsole, excludeImportConsole, excludeImportDevTool, useErrorBoundary, }: TransformVueOptions) => {
37
38
  code: string;
38
39
  map: any;
39
40
  };
@@ -1 +1 @@
1
- {"version":3,"file":"transformVue.d.ts","sourceRoot":"","sources":["../../../../src/plugins/uniDevTool/transform/transformVue.ts"],"names":[],"mappings":"AASA,UAAU,mBAAmB;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE;QACL,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC1B,WAAW,CAAC,EAAE;YACZ,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAA;aAAE,EAAE,CAAC;SAC3B,EAAE,CAAC;KACL,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC;AAmND;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,YAAY,+FAQtB,mBAAmB;UAAW,MAAM;SAAO,GAAG;CAiDhD,CAAC"}
1
+ {"version":3,"file":"transformVue.d.ts","sourceRoot":"","sources":["../../../../src/plugins/uniDevTool/transform/transformVue.ts"],"names":[],"mappings":"AASA,UAAU,mBAAmB;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE;QACL,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC1B,WAAW,CAAC,EAAE;YACZ,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAA;aAAE,EAAE,CAAC;SAC3B,EAAE,CAAC;KACL,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAsPD;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,YAAY,iHAStB,mBAAmB;UAAW,MAAM;SAAO,GAAG;CAoDhD,CAAC"}
@@ -1,41 +1,47 @@
1
- import{hasDirOrFile as v,hasUseConsole as m,hasImportConsole as d,regScript as i,getTemplateContent as h,extractTopLevelPageMeta as C}from"../../utils/index.js";function f(e,t){var c;const r=t.pages.some(o=>e.includes(o.path)),n=((c=t.subPackages)==null?void 0:c.some(o=>o.pages.some(u=>e.includes(`${o.root}/${u.path}`))))??!1;return{isPage:r,isSubPage:n}}function T(e,t,r,n){return{shouldInjectConsole:!!n,hasExistingConsoleImport:d(e),usesConsole:m(e),isExcludedFromConsole:!v(t,r)}}function $(e,t,r,n){const{isPage:c,isSubPage:o}=f(e,r);return{isPageOrSubPage:c||o,hasTemplate:t.includes("<template>"),isExcludedFromDevTool:!v(e,n)}}function g(e,t,r){const n=e.match(i);if(!n||!n[1])return e;const c=n[1];let o="";r&&(o="import { console } from 'vite-uni-dev-tool/dist/core';");const u=`
2
- ${o}
3
- ${c}
1
+ import{hasDirOrFile as m,hasUseConsole as h,hasImportConsole as f,regScript as i,getTemplateContent as C,extractTopLevelPageMeta as g}from"../../utils/index.js";let v=null;function T(e){var o;if(v)return v;const t=new Set;return e.pages.forEach(n=>t.add(n.path)),(o=e.subPackages)==null||o.forEach(n=>{n.pages.forEach(a=>t.add(`${n.root}/${a.path}`))}),v=t,t}function E(e,t){const o=T(t);return{isPage:Array.from(o).some(a=>e.includes(a.replace(/\\/g,"/"))),isSubPage:!1}}function $(e,t,o,n){return{shouldInjectConsole:!!n,hasExistingConsoleImport:f(e),usesConsole:h(e),isExcludedFromConsole:!m(t,o)}}function S(e,t,o,n){const{isPage:a}=E(e,o);return a?{isPageOrSubPage:!0,hasTemplate:t.indexOf("<template>")!==-1,isExcludedFromDevTool:!m(e,n)}:{isPageOrSubPage:!1,hasTemplate:!1,isExcludedFromDevTool:!0}}function P(e,t,o){const n=e.match(i);if(!n||!n[1])return e;const a=n[1];let r="";o&&(r="import { console } from 'vite-uni-dev-tool/dist/core';");const s=`
2
+ ${r}
3
+ ${a}
4
4
  `.trim();return e.replace(i,()=>`${t}
5
- ${u}
6
- <\/script>`)}function E(e,t){const r=e.match(i);if(!r||!r[1])return e;const n=r[1];if(n.includes("devCaptureTapEvent"))return e;const o=t.includes('lang="ts"')||t.includes('lang="typescript"')?": any":"",u=`
7
- function devCaptureTapEvent(e${o}) {
5
+ ${s}
6
+ <\/script>`)}function x(e,t){const o=e.match(i);if(!o||!o[1])return e;const n=o[1];if(n.includes("devCaptureTapEvent"))return e;const r=t.includes('lang="ts"')||t.includes('lang="typescript"')?": any":"",s=`
7
+ function devCaptureTapEvent(e${r}) {
8
8
  uni?.$emit('dev-capture-tap-event', e);
9
9
  }
10
10
 
11
- function devCaptureTouchStartEvent(e${o}) {
11
+ function devCaptureTouchStartEvent(e${r}) {
12
12
  uni?.$emit('dev-capture-touch-start-event', e);
13
13
  }
14
14
 
15
- function devCaptureTouchMoveEvent(e${o}) {
15
+ function devCaptureTouchMoveEvent(e${r}) {
16
16
  uni?.$emit('dev-capture-touch-move-event', e);
17
17
  }
18
18
 
19
- function devCaptureTouchEndEvent(e${o}) {
19
+ function devCaptureTouchEndEvent(e${r}) {
20
20
  uni?.$emit('dev-capture-touch-end-event', e);
21
21
  }
22
- `,s=`
22
+ `,p=`
23
23
  ${n}
24
- ${u}
25
- `.trim();return e.replace(i,()=>`${t}
26
24
  ${s}
27
- <\/script>`)}function S(e){const t=h(e);if(!t)return e;const{pageMetas:r,resetContent:n}=C(t),c=`
28
- ${r}
25
+ `.trim();return e.replace(i,()=>`${t}
26
+ ${p}
27
+ <\/script>`)}function D(e,t){const o=C(e);if(!o)return e;const{pageMetas:n,resetContent:a}=g(o);let r=`
28
+ <view
29
+ data-dev-capture
30
+ @tap.capture="devCaptureTapEvent"
31
+ @touchstart.capture="devCaptureTouchStartEvent"
32
+ @touchmove.capture="devCaptureTouchMoveEvent"
33
+ @touchend.capture="devCaptureTouchEndEvent"
34
+ >
35
+ ${a}
36
+ </view>
37
+ `;t&&(r=`
38
+ <DevErrorBoundary>
39
+ ${r}
40
+ </DevErrorBoundary>
41
+ `);const s=`
42
+ ${n}
29
43
  <view data-dev-page>
30
- <view
31
- data-dev-capture
32
- @tap.capture="devCaptureTapEvent"
33
- @touchstart.capture="devCaptureTouchStartEvent"
34
- @touchmove.capture="devCaptureTouchMoveEvent"
35
- @touchend.capture="devCaptureTouchEndEvent"
36
- >
37
- ${n}
38
- </view>
44
+ ${r}
39
45
  <DevTool />
40
46
  </view>
41
- `;return e.replace(t,()=>c)}const x=({id:e,code:t,pages:r,scriptRow:n,importConsole:c,excludeImportConsole:o,excludeImportDevTool:u})=>{try{let s=t;const a=T(t,e,o,c),l=a.shouldInjectConsole&&!a.hasExistingConsoleImport&&a.usesConsole&&a.isExcludedFromConsole;l&&(s=g(s,n,l));const p=$(e,t,r,u);return p.isPageOrSubPage&&p.hasTemplate&&p.isExcludedFromDevTool&&(s=S(s),s=E(s,n)),{code:s,map:null}}catch(s){return console.error("[DevTool] 转换 Vue 文件时出错:",s),{code:t,map:null}}};export{x as transformVue};
47
+ `;return e.replace(o,()=>s)}const F=({id:e,code:t,pages:o,scriptRow:n,importConsole:a,excludeImportConsole:r,excludeImportDevTool:s,useErrorBoundary:p})=>{try{let c=t;const u=$(t,e,r,a),d=u.shouldInjectConsole&&!u.hasExistingConsoleImport&&u.usesConsole&&u.isExcludedFromConsole;d&&(c=P(c,n,d));const l=S(e,t,o,s);return l.isPageOrSubPage&&l.hasTemplate&&l.isExcludedFromDevTool&&(c=D(c,p),c=x(c,n)),{code:c,map:null}}catch(c){return console.error("[DevTool] 转换 Vue 文件时出错:",c),{code:t,map:null}}};export{F as transformVue};
@@ -1,5 +1,5 @@
1
- "use strict";const j=require("path"),b=require("fs"),o=require("../utils/index.cjs"),q=require("./transform/transformMain.cjs"),w=require("./transform/transformApp.cjs"),A=require("./transform/transformVue.cjs");function d(i){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const u in i)if(u!=="default"){const f=Object.getOwnPropertyDescriptor(i,u);Object.defineProperty(a,u,f.get?f:{enumerable:!0,get:()=>i[u]})}}return a.default=i,Object.freeze(a)}const T=d(j),L=d(b),p={isReady:!1,urls:[]};function O({pages:i,sourceFileServers:a,importConsole:u,excludeImportConsole:f=["uni_modules","node_modules","src/App.vue"],excludeImportDevTool:S=["uni_modules","node_modules"],captureList:v=[],injectDevTool:h=!0,..._}){return{name:"vite-uni-dev-tool",enforce:"pre",configureServer(t){var c;t.middlewares.use((n,s,r)=>{const{originalUrl:e}=n;if(_.useDevSource&&(e!=null&&e.includes("__dev_sourcefile__"))){const l=e.replace("/__dev_sourcefile__","");try{const m=t.config.root,g=T.join(m,l),y=L.readFileSync(g,"utf-8");s.setHeader("Content-Type",o.getContentType(g)),s.end(y)}catch{r()}}else r()}),(c=t.httpServer)==null||c.once("listening",()=>{var r;const n=(r=t.httpServer)==null?void 0:r.address(),s=o.getLocalIPs();if(n&&!Array.isArray(n)&&typeof n!="string"){const e=s.map(l=>`http://${l}:${n.port}/__dev_sourcefile__`);p.isReady=!0,p.urls=e,console.warn(`
1
+ "use strict";const A=require("path"),b=require("fs"),c=require("../utils/index.cjs"),q=require("./transform/transformMain.cjs"),w=require("./transform/transformApp.cjs"),T=require("./transform/transformVue.cjs");function v(a){const f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const l in a)if(l!=="default"){const _=Object.getOwnPropertyDescriptor(a,l);Object.defineProperty(f,l,_.get?_:{enumerable:!0,get:()=>a[l]})}}return f.default=a,Object.freeze(f)}const L=v(A),M=v(b),m={isReady:!1,urls:[]};function O({pages:a,sourceFileServers:f,importConsole:l,excludeImportConsole:_=["uni_modules","node_modules","src/App.vue"],excludeImportDevTool:S=["uni_modules","node_modules"],captureList:y=[],injectDevTool:h=!0,useErrorBoundary:g=!0,...d}){return{name:"vite-uni-dev-tool",enforce:"pre",configureServer(e){var t;e.middlewares.use((n,o,i)=>{const{originalUrl:r}=n;if(d.useDevSource&&(r!=null&&r.includes("__dev_sourcefile__"))){const u=r.replace("/__dev_sourcefile__","");try{const p=e.config.root,s=L.join(p,u),j=M.readFileSync(s,"utf-8");o.setHeader("Content-Type",c.getContentType(s)),o.end(j)}catch{i()}}else i()}),(t=e.httpServer)==null||t.once("listening",()=>{var i;const n=(i=e.httpServer)==null?void 0:i.address(),o=c.getLocalIPs();if(n&&!Array.isArray(n)&&typeof n!="string"){const r=o.map(u=>`http://${u}:${n.port}/__dev_sourcefile__`);m.isReady=!0,m.urls=r,console.warn(`
2
2
  ⚡️ vite-uni-dev-tool source file server running at:
3
- ${s.map(l=>`➜ Source File Network: http://${l}:${n==null?void 0:n.port}/__dev_sourcefile__`).join(`
3
+ ${o.map(u=>`➜ Source File Network: http://${u}:${n==null?void 0:n.port}/__dev_sourcefile__`).join(`
4
4
  `)}
5
- `)}})},transform(t,c){if(h){const n=o.hasLangTS(t),s=o.hasLangJS(t),r=o.hasSetup(t);let e="<script>";if(n&&r?e='<script lang="ts" setup>':s&&r?e='<script lang="js" setup>':s?e='<script lang="js">':n?e='<script lang="ts">':r&&(e="<script setup>"),o.isMainFile(c))return q.transformMain({code:t});if(o.isAppVue(c))return w.transformApp({code:t,isSetup:r,importConsole:u,scriptRow:e,netWorkInfo:p,sourceFileServers:a,reset:{..._,captureList:v}});if(o.isVueFile(c))return A.transformVue({id:c,code:t,pages:i,scriptRow:e,importConsole:u,excludeImportConsole:f,excludeImportDevTool:S})}return{code:t,map:null}}}}module.exports=O;
5
+ `)}})},transform(e,t){if(!h||t.includes("node_modules")||t.includes("?vue&type=style")||t.includes(".scss")||t.includes(".css")||t.includes(".json"))return;const n=c.isVueFile(t),o=c.isMainFile(t),i=c.isAppVue(t);if(!n&&!o&&!i)return;const r=c.hasLangTS(e),u=c.hasLangJS(e),p=c.hasSetup(e);let s="<script>";return r&&p?s='<script lang="ts" setup>':u&&p?s='<script lang="js" setup>':u?s='<script lang="js">':r?s='<script lang="ts">':p&&(s="<script setup>"),o?q.transformMain({code:e,useErrorBoundary:g}):i?w.transformApp({code:e,isSetup:p,importConsole:l,scriptRow:s,netWorkInfo:m,sourceFileServers:f,reset:{...d,captureList:y}}):n?T.transformVue({id:t,code:e,pages:a,scriptRow:s,importConsole:l,excludeImportConsole:_,excludeImportDevTool:S,useErrorBoundary:g}):{code:e,map:null}}}}module.exports=O;
@@ -43,7 +43,7 @@ type UploadAbnormalUV = {
43
43
  * }
44
44
  * @return {*} {Plugin}
45
45
  */
46
- export default function uniDevTool({ pages, sourceFileServers, importConsole, excludeImportConsole, excludeImportDevTool, captureList, injectDevTool, ...reset }: {
46
+ export default function uniDevTool({ pages, sourceFileServers, importConsole, excludeImportConsole, excludeImportDevTool, captureList, injectDevTool, useErrorBoundary, ...reset }: {
47
47
  /** 是否拦截Promise.reject 最好不要拦截 默认禁用 */
48
48
  enableInterceptPromiseReject?: boolean;
49
49
  /** 打开窗口时隐藏按钮 */
@@ -106,6 +106,8 @@ export default function uniDevTool({ pages, sourceFileServers, importConsole, ex
106
106
  injectDevTool?: boolean;
107
107
  /** 异常上报 */
108
108
  uploadAbnormalUV?: UploadAbnormalUV;
109
+ /** 是否开启错误边界,默认开启 */
110
+ useErrorBoundary?: boolean;
109
111
  /** 环境模式 */
110
112
  mode?: string;
111
113
  }): Plugin;
@@ -1 +1 @@
1
- {"version":3,"file":"uniDevTool.d.ts","sourceRoot":"","sources":["../../../src/plugins/uniDevTool/uniDevTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAsBnC,MAAM,MAAM,WAAW,GAAG,SAAS,CAC/B,KAAK,GACL,YAAY,GACZ,WAAW,GACX,UAAU,CACb,EAAE,CAAC;AAEJ,KAAK,gBAAgB,GAAG;IACtB,WAAW;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU;IACV,MAAM,CAAC,EAAE;QACP,kBAAkB,CAAC,EAAE,GAAG,CAAC;QACzB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;IACF,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE;QACR,uBAAuB;QACvB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,KAAK,EACL,iBAAiB,EACjB,aAAa,EACb,oBAAqE,EACrE,oBAAsD,EACtD,WAAgB,EAChB,aAAoB,EACpB,GAAG,KAAK,EACT,EAAE;IACD,qCAAqC;IACrC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,gBAAgB;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe;IACf,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,wBAAwB;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,8CAA8C;IAC9C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB;IAClB,KAAK,EAAE;QACL,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC1B,WAAW,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAA;aAAE,EAAE,CAAA;SAAE,EAAE,CAAC;KAC7D,CAAC;IACF,wBAAwB;IACxB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,wBAAwB;IACxB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,+DAA+D;IAC/D,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IACnC,qDAAqD;IACrD,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IACnC,uBAAuB;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW;IACX,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,WAAW;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,MAAM,CA2GT"}
1
+ {"version":3,"file":"uniDevTool.d.ts","sourceRoot":"","sources":["../../../src/plugins/uniDevTool/uniDevTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAsBnC,MAAM,MAAM,WAAW,GAAG,SAAS,CAC/B,KAAK,GACL,YAAY,GACZ,WAAW,GACX,UAAU,CACb,EAAE,CAAC;AAEJ,KAAK,gBAAgB,GAAG;IACtB,WAAW;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU;IACV,MAAM,CAAC,EAAE;QACP,kBAAkB,CAAC,EAAE,GAAG,CAAC;QACzB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;IACF,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE;QACR,uBAAuB;QACvB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,KAAK,EACL,iBAAiB,EACjB,aAAa,EACb,oBAAqE,EACrE,oBAAsD,EACtD,WAAgB,EAChB,aAAoB,EACpB,gBAAuB,EACvB,GAAG,KAAK,EACT,EAAE;IACD,qCAAqC;IACrC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,gBAAgB;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe;IACf,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,wBAAwB;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,8CAA8C;IAC9C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB;IAClB,KAAK,EAAE;QACL,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC1B,WAAW,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAA;aAAE,EAAE,CAAA;SAAE,EAAE,CAAC;KAC7D,CAAC;IACF,wBAAwB;IACxB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,wBAAwB;IACxB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,+DAA+D;IAC/D,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IACnC,qDAAqD;IACrD,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IACnC,uBAAuB;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW;IACX,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,oBAAoB;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,MAAM,CA6HT"}
@@ -1,5 +1,5 @@
1
- import*as h from"path";import*as y from"fs";import{hasLangTS as w,hasLangJS as A,hasSetup as L,isMainFile as T,isAppVue as $,isVueFile as j,getContentType as F,getLocalIPs as P}from"../utils/index.js";import{transformMain as R}from"./transform/transformMain.js";import{transformApp as V}from"./transform/transformApp.js";import{transformVue as k}from"./transform/transformVue.js";const u={isReady:!1,urls:[]};function M({pages:c,sourceFileServers:_,importConsole:a,excludeImportConsole:m=["uni_modules","node_modules","src/App.vue"],excludeImportDevTool:g=["uni_modules","node_modules"],captureList:d=[],injectDevTool:v=!0,...p}){return{name:"vite-uni-dev-tool",enforce:"pre",configureServer(t){var o;t.middlewares.use((r,n,s)=>{const{originalUrl:e}=r;if(p.useDevSource&&(e!=null&&e.includes("__dev_sourcefile__"))){const i=e.replace("/__dev_sourcefile__","");try{const l=t.config.root,f=h.join(l,i),S=y.readFileSync(f,"utf-8");n.setHeader("Content-Type",F(f)),n.end(S)}catch{s()}}else s()}),(o=t.httpServer)==null||o.once("listening",()=>{var s;const r=(s=t.httpServer)==null?void 0:s.address(),n=P();if(r&&!Array.isArray(r)&&typeof r!="string"){const e=n.map(i=>`http://${i}:${r.port}/__dev_sourcefile__`);u.isReady=!0,u.urls=e,console.warn(`
1
+ import*as y from"path";import*as A from"fs";import{isVueFile as j,isMainFile as w,isAppVue as L,hasLangTS as T,hasLangJS as $,hasSetup as F,getContentType as V,getLocalIPs as M}from"../utils/index.js";import{transformMain as P}from"./transform/transformMain.js";import{transformApp as R}from"./transform/transformApp.js";import{transformVue as k}from"./transform/transformVue.js";const c={isReady:!1,urls:[]};function H({pages:_,sourceFileServers:m,importConsole:p,excludeImportConsole:g=["uni_modules","node_modules","src/App.vue"],excludeImportDevTool:d=["uni_modules","node_modules"],captureList:v=[],injectDevTool:S=!0,useErrorBoundary:a=!0,...f}){return{name:"vite-uni-dev-tool",enforce:"pre",configureServer(e){var t;e.middlewares.use((s,o,i)=>{const{originalUrl:r}=s;if(f.useDevSource&&(r!=null&&r.includes("__dev_sourcefile__"))){const u=r.replace("/__dev_sourcefile__","");try{const l=e.config.root,n=y.join(l,u),h=A.readFileSync(n,"utf-8");o.setHeader("Content-Type",V(n)),o.end(h)}catch{i()}}else i()}),(t=e.httpServer)==null||t.once("listening",()=>{var i;const s=(i=e.httpServer)==null?void 0:i.address(),o=M();if(s&&!Array.isArray(s)&&typeof s!="string"){const r=o.map(u=>`http://${u}:${s.port}/__dev_sourcefile__`);c.isReady=!0,c.urls=r,console.warn(`
2
2
  ⚡️ vite-uni-dev-tool source file server running at:
3
- ${n.map(i=>`➜ Source File Network: http://${i}:${r==null?void 0:r.port}/__dev_sourcefile__`).join(`
3
+ ${o.map(u=>`➜ Source File Network: http://${u}:${s==null?void 0:s.port}/__dev_sourcefile__`).join(`
4
4
  `)}
5
- `)}})},transform(t,o){if(v){const r=w(t),n=A(t),s=L(t);let e="<script>";if(r&&s?e='<script lang="ts" setup>':n&&s?e='<script lang="js" setup>':n?e='<script lang="js">':r?e='<script lang="ts">':s&&(e="<script setup>"),T(o))return R({code:t});if($(o))return V({code:t,isSetup:s,importConsole:a,scriptRow:e,netWorkInfo:u,sourceFileServers:_,reset:{...p,captureList:d}});if(j(o))return k({id:o,code:t,pages:c,scriptRow:e,importConsole:a,excludeImportConsole:m,excludeImportDevTool:g})}return{code:t,map:null}}}}export{M as default};
5
+ `)}})},transform(e,t){if(!S||t.includes("node_modules")||t.includes("?vue&type=style")||t.includes(".scss")||t.includes(".css")||t.includes(".json"))return;const s=j(t),o=w(t),i=L(t);if(!s&&!o&&!i)return;const r=T(e),u=$(e),l=F(e);let n="<script>";return r&&l?n='<script lang="ts" setup>':u&&l?n='<script lang="js" setup>':u?n='<script lang="js">':r?n='<script lang="ts">':l&&(n="<script setup>"),o?P({code:e,useErrorBoundary:a}):i?R({code:e,isSetup:l,importConsole:p,scriptRow:n,netWorkInfo:c,sourceFileServers:m,reset:{...f,captureList:v}}):s?k({id:t,code:e,pages:_,scriptRow:n,importConsole:p,excludeImportConsole:g,excludeImportDevTool:d,useErrorBoundary:a}):{code:e,map:null}}}}export{H as default};
package/dist/type.d.ts CHANGED
@@ -75,6 +75,7 @@ export declare namespace DevTool {
75
75
  updateScreen(items: ScreenItem[], index?: number): void;
76
76
  updateScanCode(items: ScanCodeItem[]): void;
77
77
  updateNfc(items: NFCItem[]): void;
78
+ updateBluetooth(items: BluetoothItem[]): void;
78
79
  updateUniEventCount(type: EventCountKey): void;
79
80
  }
80
81
  type DevInterceptHooks = {
@@ -98,6 +99,7 @@ export declare namespace DevTool {
98
99
  updateScreen: (list: ScreenItem[], index?: number) => void;
99
100
  updateScanCode: (list: ScanCodeItem[]) => void;
100
101
  updateNfc: (list: NFCItem[]) => void;
102
+ updateBluetooth: (list: BluetoothItem[]) => void;
101
103
  updateRoute: (path?: string) => void;
102
104
  updateUniEventCount: (type: EventCountKey) => void;
103
105
  addTransferTask: (index: number | string, task: any) => void;
@@ -174,6 +176,8 @@ export declare namespace DevTool {
174
176
  scanCodeListMaxSize?: number;
175
177
  /** 最大NFC条数 */
176
178
  nfcListMaxSize?: number;
179
+ /** 最大蓝牙条数 */
180
+ bluetoothListMaxSize?: number;
177
181
  /** 最大占用缓存空间 */
178
182
  cacheMaxSize?: number;
179
183
  /** 所有路由信息 */
@@ -254,6 +258,8 @@ export declare namespace DevTool {
254
258
  left?: string;
255
259
  /** 超时配置 */
256
260
  timeout?: number;
261
+ /** 强制延迟配置(用于Mock网络卡顿)单位 ms */
262
+ delay?: number;
257
263
  /** 拦截次数 */
258
264
  interceptCount?: number;
259
265
  /** 是否被拦截 */
@@ -269,14 +275,15 @@ export declare namespace DevTool {
269
275
  value: string;
270
276
  };
271
277
  /** 调试工具目前支持处理的console类型 */
272
- type ConsoleType = 'log' | 'info' | 'warn' | 'error' | 'timeEnd' | 'time' | 'clear' | 'count';
278
+ type ConsoleType = 'log' | 'info' | 'warn' | 'error' | 'debug' | 'timeEnd' | 'time' | 'clear' | 'count';
273
279
  /** 不支持处理的console类型 */
274
- type OriginalConsoleType = 'assert' | 'count' | 'countReset' | 'debug' | 'dir' | 'dirxml' | 'group' | 'groupCollapsed' | 'groupEnd' | 'table' | 'trace' | 'profile' | 'profileEnd' | 'timeStamp';
280
+ type OriginalConsoleType = 'assert' | 'count' | 'countReset' | 'dir' | 'dirxml' | 'group' | 'groupCollapsed' | 'groupEnd' | 'table' | 'trace' | 'profile' | 'profileEnd' | 'timeStamp';
275
281
  type ValueType = 'number' | 'string' | 'boolean' | 'null' | 'undefined' | 'symbol' | 'array' | 'object' | 'link' | 'image';
276
282
  type Arg = {
277
283
  type: ValueType;
278
284
  value: any;
279
285
  shortValue?: string;
286
+ _valueHtml?: string;
280
287
  };
281
288
  type ConsoleItem = {
282
289
  type: string;
@@ -295,6 +302,8 @@ export declare namespace DevTool {
295
302
  executionTime?: number;
296
303
  /** 是否被上传 */
297
304
  hasUpload?: boolean;
305
+ _stackHtml?: string;
306
+ _positionHtml?: string;
298
307
  };
299
308
  type TransferItem = {
300
309
  type: 'upload' | 'download';
@@ -426,6 +435,24 @@ export declare namespace DevTool {
426
435
  stack?: string;
427
436
  shortValue?: string;
428
437
  };
438
+ type BluetoothItem = {
439
+ /** 蓝牙设备名称 */
440
+ name: string;
441
+ /** 蓝牙设备 id */
442
+ deviceId: string;
443
+ /** 信号强度 */
444
+ RSSI: number;
445
+ /** 广播数据 */
446
+ advertisData?: any;
447
+ /** 广播服务 UUIDs */
448
+ advertisServiceUUIDs?: any[];
449
+ /** 本地名称 */
450
+ localName?: string;
451
+ /** 广播数据段中的ServiceData数据段 */
452
+ serviceData?: any[];
453
+ /** 服务征求 UUIDs (部分平台支持) */
454
+ serviceSolicitationUUIDs?: string[];
455
+ };
429
456
  type NfcType = 'ISO-DEP' | 'MIFARE Classic' | 'MIFARE Ultralight' | 'NFC-A' | 'NFC-B' | 'NFC-F' | 'NFC-V' | 'Ndef' | 'Ndef Formatable' | '';
430
457
  type NFCItem = {
431
458
  timer: number;
@@ -473,6 +500,7 @@ export declare namespace DevTool {
473
500
  interceptNetworkMap?: Map<string, NetworkItem>;
474
501
  scanCodeList?: ScanCodeItem[];
475
502
  nfcList?: NFCItem[];
503
+ bluetoothList?: BluetoothItem[];
476
504
  /** 缓存网络配置到本地 */
477
505
  cacheInterceptConfig?: boolean;
478
506
  /** 缓存网络日志到本地 */
@@ -505,6 +533,7 @@ export declare namespace DevTool {
505
533
  performanceVisible?: boolean;
506
534
  performanceShowFps?: boolean;
507
535
  performanceShowCpu?: boolean;
536
+ barrageVisible?: boolean;
508
537
  performanceSettings?: {
509
538
  showFps?: boolean;
510
539
  showCpu?: boolean;
@@ -517,6 +546,15 @@ export declare namespace DevTool {
517
546
  width?: number;
518
547
  height?: number;
519
548
  };
549
+ totalConsoleCount?: number;
550
+ totalNetworkCount?: number;
551
+ barrageMaxTracks?: number;
552
+ barrageTrackHeight?: number;
553
+ barrageStartTop?: number;
554
+ barrageDuration?: number;
555
+ barrageMaxLength?: number;
556
+ barrageTypes?: string[];
557
+ barrageShowWhenOpen?: boolean;
520
558
  };
521
559
  type DevToolInfo = {
522
560
  /** 是否销毁 */
@@ -549,6 +587,8 @@ export declare namespace DevTool {
549
587
  cacheNetworkLog?: boolean;
550
588
  /** 缓存控制台日志到本地 */
551
589
  cacheConsoleLog?: boolean;
590
+ /** 记录安全区域蒙版显示状态 */
591
+ showingSafeArea?: boolean;
552
592
  /** 缓存网络日志列表 */
553
593
  networkList?: DevTool.NetworkItem[];
554
594
  /** 拦截配置 */
@@ -580,6 +620,14 @@ export declare namespace DevTool {
580
620
  showMemory?: boolean;
581
621
  enableMonitor?: boolean;
582
622
  };
623
+ barrageVisible?: boolean;
624
+ barrageMaxTracks?: number;
625
+ barrageTrackHeight?: number;
626
+ barrageStartTop?: number;
627
+ barrageDuration?: number;
628
+ barrageMaxLength?: number;
629
+ barrageTypes?: string[];
630
+ barrageShowWhenOpen?: boolean;
583
631
  /** 性能面板位置 */
584
632
  performancePosition?: {
585
633
  left: number;