vite-uni-dev-tool 0.0.48 → 1.0.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 (292) hide show
  1. package/README.md +20 -0
  2. package/dist/const.cjs +1 -0
  3. package/dist/const.d.ts +78 -161
  4. package/dist/const.d.ts.map +1 -1
  5. package/dist/const.js +1 -47
  6. package/dist/core-shared.d.ts +44 -0
  7. package/dist/core-shared.d.ts.map +1 -0
  8. package/dist/core-shared.js +1 -0
  9. package/dist/core.d.ts +2 -40
  10. package/dist/core.d.ts.map +1 -1
  11. package/dist/core.js +4 -159
  12. package/dist/i18n/index.cjs +1 -0
  13. package/dist/i18n/index.d.ts +9 -0
  14. package/dist/i18n/index.d.ts.map +1 -0
  15. package/dist/i18n/index.js +1 -0
  16. package/dist/i18n/instance.cjs +1 -0
  17. package/dist/i18n/instance.d.ts +15 -0
  18. package/dist/i18n/instance.d.ts.map +1 -0
  19. package/dist/i18n/instance.js +1 -0
  20. package/dist/i18n/locales/en.cjs +1 -0
  21. package/dist/i18n/locales/en.d.ts +470 -0
  22. package/dist/i18n/locales/en.d.ts.map +1 -0
  23. package/dist/i18n/locales/en.js +1 -0
  24. package/dist/i18n/locales/zh-Hans.cjs +1 -0
  25. package/dist/i18n/locales/zh-Hans.d.ts +476 -0
  26. package/dist/i18n/locales/zh-Hans.d.ts.map +1 -0
  27. package/dist/i18n/locales/zh-Hans.js +1 -0
  28. package/dist/index.cjs +1 -0
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +1 -1
  31. package/dist/modules/devConsole/index.cjs +4 -0
  32. package/dist/{devConsole → modules/devConsole}/index.d.ts +1 -1
  33. package/dist/modules/devConsole/index.d.ts.map +1 -0
  34. package/dist/modules/devConsole/index.js +4 -0
  35. package/dist/modules/devEvent/index.cjs +5 -0
  36. package/dist/modules/devEvent/index.d.ts +115 -0
  37. package/dist/modules/devEvent/index.d.ts.map +1 -0
  38. package/dist/modules/devEvent/index.js +5 -0
  39. package/dist/modules/devIntercept/index.cjs +13 -0
  40. package/dist/modules/devIntercept/index.d.ts +71 -0
  41. package/dist/modules/devIntercept/index.d.ts.map +1 -0
  42. package/dist/modules/devIntercept/index.js +13 -0
  43. package/dist/modules/devStore/index.cjs +1 -0
  44. package/dist/modules/devStore/index.d.ts +159 -0
  45. package/dist/modules/devStore/index.d.ts.map +1 -0
  46. package/dist/modules/devStore/index.js +1 -0
  47. package/dist/modules/devToolInfo/index.cjs +1 -0
  48. package/dist/modules/devToolInfo/index.d.ts +27 -0
  49. package/dist/modules/devToolInfo/index.d.ts.map +1 -0
  50. package/dist/modules/devToolInfo/index.js +1 -0
  51. package/dist/plugins/uniDevTool/transform/transformApp.cjs +44 -0
  52. package/dist/plugins/uniDevTool/transform/transformApp.d.ts.map +1 -1
  53. package/dist/plugins/uniDevTool/transform/transformApp.js +17 -17
  54. package/dist/plugins/uniDevTool/transform/transformMain.cjs +3 -0
  55. package/dist/plugins/uniDevTool/transform/transformMain.d.ts.map +1 -1
  56. package/dist/plugins/uniDevTool/transform/transformMain.js +3 -3
  57. package/dist/plugins/uniDevTool/transform/transformVue.cjs +41 -0
  58. package/dist/plugins/uniDevTool/transform/transformVue.d.ts +1 -2
  59. package/dist/plugins/uniDevTool/transform/transformVue.d.ts.map +1 -1
  60. package/dist/plugins/uniDevTool/transform/transformVue.js +32 -19
  61. package/dist/plugins/uniDevTool/uniDevTool.cjs +5 -0
  62. package/dist/plugins/uniDevTool/uniDevTool.d.ts +3 -11
  63. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
  64. package/dist/plugins/uniDevTool/uniDevTool.js +3 -3
  65. package/dist/plugins/uniGlobalComponents/uniGlobalComponents.cjs +19 -0
  66. package/dist/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +1 -1
  67. package/dist/plugins/uniGlobalComponents/uniGlobalComponents.js +11 -19
  68. package/dist/plugins/uniParseStock/index.d.ts +10 -0
  69. package/dist/plugins/uniParseStock/index.d.ts.map +1 -0
  70. package/dist/plugins/utils/index.cjs +2 -0
  71. package/dist/plugins/utils/index.d.ts +1 -3
  72. package/dist/plugins/utils/index.d.ts.map +1 -1
  73. package/dist/plugins/utils/index.js +2 -2
  74. package/dist/shims-uni.d.ts +140 -0
  75. package/dist/type.d.ts +174 -16
  76. package/dist/type.d.ts.map +1 -1
  77. package/dist/utils/array.cjs +1 -0
  78. package/dist/utils/array.d.ts.map +1 -1
  79. package/dist/utils/array.js +1 -12
  80. package/dist/utils/date.cjs +1 -0
  81. package/dist/utils/date.d.ts.map +1 -1
  82. package/dist/utils/date.js +1 -59
  83. package/dist/utils/file.cjs +1 -0
  84. package/dist/utils/file.d.ts.map +1 -1
  85. package/dist/utils/file.js +1 -85
  86. package/dist/utils/function.cjs +1 -0
  87. package/dist/utils/function.d.ts +13 -0
  88. package/dist/utils/function.d.ts.map +1 -1
  89. package/dist/utils/function.js +1 -68
  90. package/dist/utils/index.cjs +1 -0
  91. package/dist/utils/index.d.ts.map +1 -1
  92. package/dist/utils/index.js +1 -63
  93. package/dist/utils/ip.cjs +1 -0
  94. package/dist/utils/ip.d.ts +1 -1
  95. package/dist/utils/ip.d.ts.map +1 -1
  96. package/dist/utils/ip.js +1 -45
  97. package/dist/utils/language.cjs +1 -0
  98. package/dist/utils/language.d.ts +2 -1
  99. package/dist/utils/language.d.ts.map +1 -1
  100. package/dist/utils/language.js +1 -63
  101. package/dist/utils/object.cjs +1 -0
  102. package/dist/utils/object.d.ts +4 -5
  103. package/dist/utils/object.d.ts.map +1 -1
  104. package/dist/utils/object.js +1 -136
  105. package/dist/utils/openLink.cjs +1 -0
  106. package/dist/utils/openLink.d.ts.map +1 -1
  107. package/dist/utils/openLink.js +1 -28
  108. package/dist/utils/page.cjs +1 -0
  109. package/dist/utils/page.d.ts.map +1 -1
  110. package/dist/utils/page.js +1 -7
  111. package/dist/utils/platform.cjs +1 -0
  112. package/dist/utils/platform.d.ts.map +1 -1
  113. package/dist/utils/platform.js +1 -17
  114. package/dist/utils/string.cjs +1 -0
  115. package/dist/utils/string.d.ts.map +1 -1
  116. package/dist/utils/string.js +1 -114
  117. package/dist/utils/utils.cjs +1 -0
  118. package/dist/utils/utils.d.ts +1 -1
  119. package/dist/utils/utils.d.ts.map +1 -1
  120. package/dist/utils/utils.js +1 -126
  121. package/dist/v3/AppTransition/index.vue +170 -0
  122. package/dist/v3/AutoSizer/index.vue +4 -5
  123. package/dist/v3/AutoSizer/index1.vue +4 -6
  124. package/dist/v3/AutoSizer/utils.ts +1 -1
  125. package/dist/v3/CaptureScreen/index.vue +19 -8
  126. package/dist/v3/CircularButton/index.vue +64 -13
  127. package/dist/v3/ConsoleList/ConsoleItem.vue +56 -5
  128. package/dist/v3/ConsoleList/RunJSInput.vue +10 -6
  129. package/dist/v3/ConsoleList/index.vue +51 -35
  130. package/dist/v3/CustomSwiper/CustomSwiperItem.vue +49 -0
  131. package/dist/v3/CustomSwiper/index.vue +104 -0
  132. package/dist/v3/DevTool/fps-collector.render.ts +148 -0
  133. package/dist/v3/DevTool/index.vue +209 -102
  134. package/dist/v3/DevToolButton/index.vue +40 -59
  135. package/dist/v3/DevToolTitle/index.vue +4 -1
  136. package/dist/v3/DevToolWindow/DevToolOverlay.vue +182 -0
  137. package/dist/v3/DevToolWindow/const.ts +47 -69
  138. package/dist/v3/DevToolWindow/hooks/dataUtils.ts +48 -0
  139. package/dist/v3/DevToolWindow/hooks/useDevToolData.ts +338 -0
  140. package/dist/v3/DevToolWindow/hooks/useDevToolHandlers.ts +549 -0
  141. package/dist/v3/DevToolWindow/hooks/useDevToolOverlay.ts +184 -0
  142. package/dist/v3/DevToolWindow/index.css +89 -0
  143. package/dist/v3/DevToolWindow/index.vue +800 -1450
  144. package/dist/v3/DraggableContainer/index.vue +456 -0
  145. package/dist/v3/ElEvent/ElEventItem.vue +4 -3
  146. package/dist/v3/ElEvent/index.vue +26 -9
  147. package/dist/v3/Empty/index.vue +1 -0
  148. package/dist/v3/FilterInput/index.vue +8 -22
  149. package/dist/v3/FilterSelect/index.vue +37 -24
  150. package/dist/v3/Instance/components/InstanceTreeNode.vue +265 -0
  151. package/dist/v3/Instance/flatten.ts +226 -0
  152. package/dist/v3/Instance/index.vue +94 -0
  153. package/dist/v3/Instance/registry.ts +49 -0
  154. package/dist/v3/Instance/transformTree.ts +375 -0
  155. package/dist/v3/Instance/transformTreeCtx.ts +268 -0
  156. package/dist/v3/{InstanceTree → Instance}/typing.d.ts +15 -2
  157. package/dist/v3/InstanceDetail/index.vue +433 -44
  158. package/dist/v3/JsonDetail/index.vue +12 -8
  159. package/dist/v3/JsonPretty/components/Brackets/index.vue +1 -0
  160. package/dist/v3/JsonPretty/components/Carets/index.vue +2 -1
  161. package/dist/v3/JsonPretty/components/CheckController/index.vue +26 -15
  162. package/dist/v3/JsonPretty/components/TreeNode/index.vue +42 -20
  163. package/dist/v3/JsonPretty/index.vue +60 -37
  164. package/dist/v3/JsonPretty/utils/index.ts +41 -44
  165. package/dist/v3/MovableContainer/index.vue +89 -0
  166. package/dist/v3/NFCList/NFCItem.vue +14 -14
  167. package/dist/v3/NFCList/NFCTool.vue +99 -81
  168. package/dist/v3/NFCList/index.vue +14 -10
  169. package/dist/v3/NetworkList/InterceptConfig.vue +154 -364
  170. package/dist/v3/NetworkList/InterceptItem.vue +14 -6
  171. package/dist/v3/NetworkList/NetworkDetail.vue +34 -29
  172. package/dist/v3/NetworkList/NetworkIntercept.vue +11 -8
  173. package/dist/v3/NetworkList/NetworkItem.vue +27 -11
  174. package/dist/v3/NetworkList/NetworkSend.vue +132 -290
  175. package/dist/v3/NetworkList/hooks/useNetworkForm.ts +86 -0
  176. package/dist/v3/NetworkList/index.vue +32 -24
  177. package/dist/v3/NetworkList/utils.ts +101 -0
  178. package/dist/v3/Performance/index.vue +495 -0
  179. package/dist/v3/Performance/modules/PerformanceMetrics.vue +153 -0
  180. package/dist/v3/Performance/modules/PerformanceWidget.vue +249 -0
  181. package/dist/v3/Performance/modules/usePerformanceChart.ts +460 -0
  182. package/dist/v3/Performance/modules/usePerformanceData.ts +258 -0
  183. package/dist/v3/Pick/index.vue +322 -0
  184. package/dist/v3/PiniaList/index.vue +38 -17
  185. package/dist/v3/RouteList/index.vue +32 -15
  186. package/dist/v3/RunJS/index.vue +30 -10
  187. package/dist/v3/ScanCodeList/ScanCodeItem.vue +2 -9
  188. package/dist/v3/ScanCodeList/index.vue +12 -9
  189. package/dist/v3/SettingButton/index.vue +45 -0
  190. package/dist/v3/SettingList/index.css +120 -0
  191. package/dist/v3/SettingList/index.vue +96 -537
  192. package/dist/v3/SettingList/modules/SettingDevTool.vue +208 -0
  193. package/dist/v3/SettingList/modules/SettingInfo.vue +119 -0
  194. package/dist/v3/SettingList/modules/SettingLanguage.vue +74 -0
  195. package/dist/v3/SettingList/modules/SettingLog.vue +230 -0
  196. package/dist/v3/SettingList/modules/SettingNetwork.vue +120 -0
  197. package/dist/v3/SettingList/modules/SettingTheme.vue +312 -0
  198. package/dist/v3/SourceCode/Line.vue +15 -2
  199. package/dist/v3/SourceCode/index.vue +25 -24
  200. package/dist/v3/SourceCode/parseCode.ts +114 -56
  201. package/dist/v3/StorageList/index.vue +33 -33
  202. package/dist/v3/Tabs/index.vue +31 -28
  203. package/dist/v3/Tag/index.vue +39 -20
  204. package/dist/v3/TransferList/TransferDetail.vue +268 -0
  205. package/dist/v3/TransferList/TransferItem.vue +125 -0
  206. package/dist/v3/TransferList/index.vue +181 -0
  207. package/dist/v3/UniEvent/UniEventItem.vue +1 -0
  208. package/dist/v3/UniEvent/index.vue +28 -29
  209. package/dist/v3/{VirtualListPro → VirtualList}/AutoSize.vue +1 -1
  210. package/dist/v3/VirtualList/index.vue +382 -82
  211. package/dist/v3/VuexList/index.vue +38 -17
  212. package/dist/v3/WebSocket/WebSocketDetail.vue +142 -80
  213. package/dist/v3/WebSocket/WebSocketItem.vue +10 -4
  214. package/dist/v3/WebSocket/index.vue +44 -30
  215. package/dist/v3/hooks/useNFC/index.ts +6 -6
  216. package/dist/v3/hooks/useNFC/typing.d.ts +2 -2
  217. package/dist/v3/hooks/useNFC/useNFCAndroid.ts +215 -626
  218. package/dist/v3/hooks/useNFC/useNFCMpWeiXin.ts +54 -85
  219. package/dist/v3/hooks/useNFC/utils.ts +3 -3
  220. package/dist/v3/hooks/useRequest/index.ts +2 -2
  221. package/dist/v3/hooks/useScanCode/index.ts +10 -8
  222. package/dist/v3/styles/theme.css +290 -0
  223. package/dist/v3/styles/theme.ts +12 -0
  224. package/package.json +25 -5
  225. package/dist/devConsole/index.d.ts.map +0 -1
  226. package/dist/devConsole/index.js +0 -273
  227. package/dist/devEvent/index.d.ts +0 -328
  228. package/dist/devEvent/index.d.ts.map +0 -1
  229. package/dist/devEvent/index.js +0 -697
  230. package/dist/devEventBus/index.d.ts +0 -42
  231. package/dist/devEventBus/index.d.ts.map +0 -1
  232. package/dist/devEventBus/index.js +0 -70
  233. package/dist/devIntercept/index.d.ts +0 -281
  234. package/dist/devIntercept/index.d.ts.map +0 -1
  235. package/dist/devIntercept/index.js +0 -949
  236. package/dist/devRunJS/index.d.ts +0 -67
  237. package/dist/devRunJS/index.d.ts.map +0 -1
  238. package/dist/devStore/index.d.ts +0 -199
  239. package/dist/devStore/index.d.ts.map +0 -1
  240. package/dist/devStore/index.js +0 -562
  241. package/dist/devToolInfo/index.d.ts +0 -17
  242. package/dist/devToolInfo/index.d.ts.map +0 -1
  243. package/dist/devToolInfo/index.js +0 -15
  244. package/dist/v3/AutoSizer/utils.d.ts +0 -5
  245. package/dist/v3/AutoSizer/utils.d.ts.map +0 -1
  246. package/dist/v3/ConsoleList/staticTips.d.ts +0 -13
  247. package/dist/v3/ConsoleList/staticTips.d.ts.map +0 -1
  248. package/dist/v3/DevToolWindow/const.d.ts +0 -46
  249. package/dist/v3/DevToolWindow/const.d.ts.map +0 -1
  250. package/dist/v3/InstanceTree/components/InstanceTreeNode.vue +0 -81
  251. package/dist/v3/InstanceTree/flatten.d.ts +0 -10
  252. package/dist/v3/InstanceTree/flatten.d.ts.map +0 -1
  253. package/dist/v3/InstanceTree/flatten.ts +0 -75
  254. package/dist/v3/InstanceTree/index.vue +0 -51
  255. package/dist/v3/InstanceTree/transformTree.d.ts +0 -17
  256. package/dist/v3/InstanceTree/transformTree.d.ts.map +0 -1
  257. package/dist/v3/InstanceTree/transformTree.ts +0 -237
  258. package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +0 -4
  259. package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +0 -1
  260. package/dist/v3/JsonPretty/hooks/useError.d.ts +0 -8
  261. package/dist/v3/JsonPretty/hooks/useError.d.ts.map +0 -1
  262. package/dist/v3/JsonPretty/type.d.ts +0 -94
  263. package/dist/v3/JsonPretty/type.d.ts.map +0 -1
  264. package/dist/v3/JsonPretty/utils/index.d.ts +0 -10
  265. package/dist/v3/JsonPretty/utils/index.d.ts.map +0 -1
  266. package/dist/v3/NFCList/const.d.ts +0 -13
  267. package/dist/v3/NFCList/const.d.ts.map +0 -1
  268. package/dist/v3/NetworkList/const.d.ts +0 -5
  269. package/dist/v3/NetworkList/const.d.ts.map +0 -1
  270. package/dist/v3/SourceCode/parseCode.d.ts +0 -27
  271. package/dist/v3/SourceCode/parseCode.d.ts.map +0 -1
  272. package/dist/v3/UploadList/UploadDetail.vue +0 -255
  273. package/dist/v3/UploadList/UploadItem.vue +0 -122
  274. package/dist/v3/UploadList/index.vue +0 -125
  275. package/dist/v3/VirtualListPro/index.vue +0 -229
  276. package/dist/v3/hooks/useContainerStyle.d.ts +0 -15
  277. package/dist/v3/hooks/useContainerStyle.d.ts.map +0 -1
  278. package/dist/v3/hooks/useNFC/index.d.ts +0 -5
  279. package/dist/v3/hooks/useNFC/index.d.ts.map +0 -1
  280. package/dist/v3/hooks/useNFC/useNFCAndroid.d.ts +0 -2
  281. package/dist/v3/hooks/useNFC/useNFCAndroid.d.ts.map +0 -1
  282. package/dist/v3/hooks/useNFC/useNFCMpWeiXin.d.ts +0 -2
  283. package/dist/v3/hooks/useNFC/useNFCMpWeiXin.d.ts.map +0 -1
  284. package/dist/v3/hooks/useNFC/utils.d.ts +0 -95
  285. package/dist/v3/hooks/useNFC/utils.d.ts.map +0 -1
  286. package/dist/v3/hooks/useRequest/index.d.ts +0 -126
  287. package/dist/v3/hooks/useRequest/index.d.ts.map +0 -1
  288. package/dist/v3/hooks/useRequest/utils.d.ts +0 -35
  289. package/dist/v3/hooks/useRequest/utils.d.ts.map +0 -1
  290. package/dist/v3/hooks/useScanCode/index.d.ts +0 -36
  291. package/dist/v3/hooks/useScanCode/index.d.ts.map +0 -1
  292. /package/dist/v3/{VirtualListPro → VirtualList}/readme.md +0 -0
@@ -1,697 +0,0 @@
1
- import { console as p, backup as w } from "../core.js";
2
- import { DEV_APP_MESSAGE as M, DEV_WINDOW_VISIBLE as _, DEV_BUTTON_VISIBLE as f, DEV_OPTION_SEND as R, DEV_WINDOW_MESSAGE as I, DEV_CONSOLE_CLEAR as O, DEV_NETWORK_CLEAR as A, DEV_WEBSOCKET_CLEAR as N, DEV_WEBSOCKET_CLEAR_MESSAGE as U, DEV_UPLOAD_CLEAR as V, DEV_STORAGE_CLEAR as b, DEV_STORAGE_REFRESH as x, DEV_STORAGE_REMOVE as k, DEV_STORAGE_ADD as P, DEV_STORAGE_UPDATE as B, DEV_BUTTON_SHOW_OR_HIDE as W, DEV_RESTART_DEBUGGER as G, DEV_RESTART_APP as F, DEV_EXPORT_LOG as H, DEV_VUEX_CHANGE as j, DEV_PINIA_CHANGE as J, DEV_LOG_CACHE_CLEAR as z, DEV_DESTROY as q, DEV_WINDOW_OPEN as K, DEV_WINDOW_CLOSE as X, DEV_ROUTE_REFRESH as $, DEV_OPTION_GET as Y, DEV_EL_EVENT_CLEAR as Q, DEV_UNI_EVENT_CLEAR as Z, DEV_RUN_JS as tt, DEV_CAPTURE_SCREEN_CLEAR as et, DEV_INTERCEPT_NETWORK_UPDATE as st, DEV_INTERCEPT_NETWORK_REMOVE as ot, DEV_CHANGE_CACHE_INTERCEPT_CONFIG as it, DEV_BOTTOM_TAB_CHANGE as rt, DEV_SCAN_CODE_CLEAR as nt, DEV_NFC_CLEAR as at, DEV_CAPTURE_TAP_EVENT as m, DEV_CAPTURE_TOUCH_START as L, DEV_CAPTURE_TOUCH_MOVE as S, DEV_CAPTURE_TOUCH_END as C } from "../const.js";
3
- import "../utils/index.js";
4
- import { transformValueToView as ht, transformValueToShortString as lt } from "../utils/language.js";
5
- import { throttle as d } from "../utils/function.js";
6
- import { calculateObjectSize as pt, formatStorageSize as ct, parseValue as ut } from "../utils/object.js";
7
- import { saveTextFileMicro as Et, saveTextFileH5 as vt, saveTxtFileApp as dt } from "../utils/file.js";
8
- import { getCurrentDate as y } from "../utils/date.js";
9
- import { getCurrentPagePath as c } from "../utils/page.js";
10
- class wt {
11
- constructor({ store: t, eventBus: e }) {
12
- this.abnormalUploadCount = 0, this.abnormalUploadTimer = null, this.isAbnormalUploadActive = !1, this.postMessage = d(this.postMessageFn, 1e3), this.throttleAddElEvent = d(this.addElEvent, 1e3), this.throttleTouchStartEvent = d(this.touchStartEvent, 1e3), this.throttleTouchMoveEvent = d(this.touchMoveEvent, 1e3), this.throttleTouchEndEvent = d(this.touchEndEvent, 1e3), this.store = t, this.eventBus = e, this.acceptMessage();
13
- }
14
- setIntercept(t) {
15
- this.intercept = t;
16
- }
17
- /**
18
- * 发送数据
19
- *
20
- * @param {DevTool.WindowData} data
21
- * @memberof DevEvent
22
- */
23
- async postMessageFn() {
24
- var i;
25
- if (this.getDevToolDestroy())
26
- return;
27
- const t = await this.store.getDevData(), e = pt(t), s = ct(e);
28
- t.size = e, t.sizeFormat = s, this.eventBus.emit(M, t), e > this.store.cacheMaxSize && ((i = this.store) == null || i.clearDevCache());
29
- }
30
- /**
31
- * 创建调试器
32
- *
33
- * @return {*}
34
- * @memberof DevEvent
35
- */
36
- createDevTool(t) {
37
- var s;
38
- if (!this.getDevToolDestroy()) {
39
- p.warn("[DevTool] 调试器已创建,不再创建");
40
- return;
41
- }
42
- const e = this.store.getDevToolOptions();
43
- (s = this.intercept) == null || s.init({
44
- enableCaptureScreen: e == null ? void 0 : e.enableCaptureScreen,
45
- enableInterceptPromiseReject: e == null ? void 0 : e.enableInterceptPromiseReject
46
- }), this.addEventListener(), this.store.setDevToolDestroy(!1), this.updateRouteList(), this.showDevToolButton(), this.postMessage(), setTimeout(() => {
47
- p.warn(
48
- `[DevTool] 创建成功
49
- 当前版本:${t == null ? void 0 : t.devToolVersion}
50
- 构建时间:${t == null ? void 0 : t.devToolBuildTime}
51
- 一处编写,到处调试 😂
52
- 有问题前往反馈:https://gitee.com/cloud_l/vite-uni-dev-tool`
53
- );
54
- }, 500);
55
- }
56
- /**
57
- * 销毁调试器
58
- *
59
- * @return {*}
60
- * @memberof DevEvent
61
- */
62
- destroyDevTool() {
63
- var t;
64
- if (this.getDevToolDestroy()) {
65
- p.warn("[DevTool] 调试器已经销毁了,不再重新销毁");
66
- return;
67
- }
68
- this.hideDevToolButton(), this.closeDevToolWindow(), this.removeEventListener(), this.store.setRequestIndex(-1), this.store.setUploadIndex(-1), this.store.setDevToolDestroy(!0), this.store.clearAll(), (t = this.intercept) == null || t.reset(), this.stopAbnormalUpload(), p.warn("[DevTool] 调试器已销毁");
69
- }
70
- /**
71
- * 重启调试器
72
- *
73
- * @memberof DevEvent
74
- */
75
- restartDevTool() {
76
- this.destroyDevTool(), this.createDevTool({
77
- devToolBuildTime: this.store.devToolBuildTime,
78
- devToolVersion: this.store.devToolVersion
79
- }), this.openDevToolWindow(), this.restartAbnormalUpload();
80
- }
81
- /**
82
- * 打开调试器窗口
83
- *
84
- * @memberof DevEvent
85
- */
86
- openDevToolWindow() {
87
- if (this.getDevToolDestroy()) {
88
- p.warn("[DevTool] 调试器已销毁");
89
- return;
90
- }
91
- setTimeout(async () => {
92
- this.postMessage();
93
- }, 100), this.eventBus.emit(_, !0);
94
- }
95
- /**
96
- * 关闭调试器窗口
97
- *
98
- * @memberof DevEvent
99
- */
100
- closeDevToolWindow() {
101
- if (this.getDevToolDestroy()) {
102
- p.warn("[DevTool] 调试器已销毁");
103
- return;
104
- }
105
- this.eventBus.emit(_, !1);
106
- }
107
- /**
108
- * 显示调试按钮
109
- *
110
- * @export
111
- */
112
- showDevToolButton() {
113
- this.getDevToolDestroy() || (this.eventBus.emit(f, !0), this.store.setDevToolVisible(!0));
114
- }
115
- /**
116
- * 隐藏调试按钮
117
- *
118
- * @return {*}
119
- */
120
- hideDevToolButton() {
121
- this.getDevToolDestroy() || (this.eventBus.emit(f, !1), this.store.setDevToolVisible(!1));
122
- }
123
- exportLog(t) {
124
- const e = this.store.getExportData(t);
125
- switch (uni.__dev_tool_platform__) {
126
- case "app":
127
- dt(JSON.stringify(e, null, 2), "dev-tool-log");
128
- break;
129
- case "web":
130
- vt(JSON.stringify(e, null, 2), "dev-tool-log");
131
- break;
132
- case "mp-weixin":
133
- case "mp-alipay":
134
- case "mp-toutiao":
135
- Et(JSON.stringify(e, null, 2), "dev-tool-log");
136
- break;
137
- }
138
- }
139
- /**
140
- * 重启app
141
- *
142
- * @memberof DevEvent
143
- */
144
- restartApp() {
145
- var t;
146
- switch (uni.__dev_tool_platform__) {
147
- case "app":
148
- plus.runtime.restart();
149
- break;
150
- case "web":
151
- window.location.reload();
152
- break;
153
- case "mp-weixin":
154
- if (wx != null && wx.restartMiniProgram) {
155
- const e = "/" + this.store.getCurrentPagePath();
156
- (t = wx.restartMiniProgram) == null || t.call(wx, {
157
- path: e
158
- });
159
- }
160
- break;
161
- }
162
- }
163
- refreshRouteList() {
164
- this.store.getRouteList(), this.postMessage();
165
- }
166
- sendDevToolOption() {
167
- const t = this.store.getDevToolOptions();
168
- this.eventBus.emit(R, t);
169
- }
170
- /**
171
- * 接受消息
172
- *
173
- * @memberof DevEvent
174
- */
175
- acceptMessage() {
176
- this.eventBus.on(
177
- I,
178
- (t) => {
179
- t.type === O ? this.store.clearConsoleList() : t.type === A ? (this.store.clearNetworkList(), this.postMessage()) : t.type === N ? (this.store.clearWsList(), this.postMessage()) : t.type === U ? (p.log("data: ", t), this.store.clearWsMessage(t.data.url), this.postMessage()) : t.type === V ? (this.store.clearUploadList(), this.postMessage()) : t.type === b ? (this.store.clearStorageList(!0), this.postMessage()) : t.type === x ? (this.store.refreshStore(), this.postMessage()) : t.type === k ? (this.store.removeStorage(t.data.key + "", !0), this.postMessage()) : t.type === P ? (this.store.addStorage(t.data, !0), this.postMessage()) : t.type === B ? (this.store.updateStore(t.data), this.postMessage()) : t.type === W ? (t.data.show ? this.showDevToolButton() : this.hideDevToolButton(), this.postMessage()) : t.type === G ? this.restartDevTool() : t.type === F ? this.restartApp() : t.type === H ? this.exportLog(t.data) : t.type === j ? (this.store.updateVuexStore(t.data), this.postMessage()) : t.type === J ? (this.store.updatePiniaStore(t.data), this.postMessage()) : t.type === z ? this.store.clearDevCache() : t.type === q ? this.destroyDevTool() : t.type === K ? this.openDevToolWindow() : t.type === X ? this.closeDevToolWindow() : t.type === $ ? this.refreshRouteList() : t.type === Y ? this.sendDevToolOption() : t.type === Q ? this.clearElEventList() : t.type === Z ? this.clearUniEvent() : t.type === tt ? this.devRunJS(t.data.code) : t.type === et ? this.store.clearCaptureScreenList() : t.type === st ? this.updateInterceptNetworkList(t.data) : t.type === ot ? this.removeInterceptNetwork(t.data) : t.type === it ? this.changeCacheInterceptConfig(t.data) : t.type === rt ? (this.closeDevToolWindow(), this.updateRouteList(t.data.path)) : t.type === nt ? this.store.clearScanCodeList() : t.type === at && this.store.clearNfcList();
180
- }
181
- );
182
- }
183
- /**
184
- * 更新路由信息
185
- *
186
- * @param {string} path
187
- * @memberof DevEvent
188
- */
189
- updateRouteList(t) {
190
- this.store.updateRouteList(t), this.postMessage();
191
- }
192
- /**
193
- * 清除console日志
194
- *
195
- * @memberof DevEvent
196
- */
197
- clearConsoleList() {
198
- this.store.clearConsoleList(), this.postMessage();
199
- }
200
- /**
201
- * 更新控制台日志
202
- *
203
- * @param {DevTool.ConsoleItem[]} addItems
204
- * @param {number} [index]
205
- * @memberof DevEvent
206
- */
207
- updateConsoleList(t, e) {
208
- this.store.updateConsoleList(t, e), this.postMessage();
209
- }
210
- /**
211
- * 更新网络日志
212
- *
213
- * @param {DevTool.NetworkItem[]} addItems
214
- * @param {number} [index]
215
- * @memberof DevEvent
216
- */
217
- updateNetworkList(t, e) {
218
- this.store.updateNetworkList(t, e), this.postMessage();
219
- }
220
- /**
221
- * 更新websocket日志
222
- *
223
- * @param {DevTool.WS} item
224
- * @memberof DevEvent
225
- */
226
- updateWsList(t) {
227
- this.store.updateWsList(t), this.postMessage();
228
- }
229
- /**
230
- * 重置websocket
231
- *
232
- * @memberof DevEvent
233
- */
234
- resetWebSocket() {
235
- uni.connectSocket = w.connectSocket;
236
- }
237
- /**
238
- * 更新状态存储
239
- *
240
- * @param {DevTool.StorageItem[]} addItems
241
- * @memberof DevEvent
242
- */
243
- updateStoreList(t) {
244
- this.store.updateStoreList(t), this.postMessage();
245
- }
246
- /**
247
- * 移除状态
248
- *
249
- * @param {string} key
250
- * @memberof DevEvent
251
- */
252
- removeStorage(t, e) {
253
- this.store.removeStorage(t, e), this.postMessage();
254
- }
255
- /**
256
- * 清除缓存
257
- *
258
- * @memberof DevEvent
259
- */
260
- clearStorage(t) {
261
- this.store.clearStorageList(t), this.postMessage();
262
- }
263
- /**
264
- * 更新上传日志
265
- *
266
- * @param {DevTool.UploadItem[]} addItems
267
- * @param {number} [index]
268
- * @memberof DevEvent
269
- */
270
- updateUploadList(t, e) {
271
- this.store.updateUploadList(t, e), this.postMessage();
272
- }
273
- /**
274
- * 移除上传任务
275
- *
276
- * @param {(number | string)} index
277
- * @memberof DevEvent
278
- */
279
- removeUploadTask(t) {
280
- this.store.removeUploadTask(t), this.postMessage();
281
- }
282
- /**
283
- * 新增上传任务
284
- *
285
- * @param {(number | string)} index
286
- * @param {UniApp.UploadTask} task
287
- * @memberof DevEvent
288
- */
289
- addUploadTask(t, e) {
290
- this.store.addUploadTask(t, e), this.postMessage();
291
- }
292
- setRequestIndex(t) {
293
- return this.store.setRequestIndex(t);
294
- }
295
- getRequestIndex() {
296
- return this.store.getRequestIndex();
297
- }
298
- setUploadIndex(t) {
299
- return this.store.setUploadIndex(t);
300
- }
301
- getUploadIndex() {
302
- return this.store.getUploadIndex();
303
- }
304
- setScreenIndex(t) {
305
- return this.store.setScreenIndex(t);
306
- }
307
- getScreenIndex() {
308
- return this.store.getScreenIndex();
309
- }
310
- setVueStore(t) {
311
- this.store.setVuexStore(t);
312
- }
313
- setVuexList(t) {
314
- this.store.setVuexList(t);
315
- }
316
- setPiniaList(t) {
317
- this.store.setPiniaList(t);
318
- }
319
- setPiniaStore(t) {
320
- this.store.setPiniaStore(t);
321
- }
322
- getDevToolDestroy() {
323
- return this.store.getDevToolDestroy();
324
- }
325
- updateUniEventCount(t) {
326
- this.store.updateUniEventCount(t), this.postMessage();
327
- }
328
- updateUniEventList(t) {
329
- this.store.updateUniEventList(t), this.postMessage();
330
- }
331
- clearUniEvent() {
332
- this.store.clearUniEvent(), this.postMessage();
333
- }
334
- execute(t) {
335
- const e = "_e_v_a_l_".replace(
336
- /_/g,
337
- ""
338
- ), s = "_e_v_a_l_F_n_".replace(
339
- /_/g,
340
- ""
341
- );
342
- if (globalThis != null && globalThis[s])
343
- return Promise.resolve(globalThis == null ? void 0 : globalThis[s](t));
344
- if (globalThis != null && globalThis[e])
345
- return Promise.resolve(globalThis == null ? void 0 : globalThis[e](t));
346
- throw new Error("[DevTool] DevRunJS 当前环境不支持执行js");
347
- }
348
- /**
349
- * 运行js
350
- *
351
- * @param {string} code
352
- * @memberof DevEvent
353
- */
354
- devRunJS(t) {
355
- var n, h;
356
- const e = (h = (n = new Error()) == null ? void 0 : n.stack) == null ? void 0 : h.split(`
357
- `), s = e == null ? void 0 : e[1], i = Date.now(), o = {
358
- type: "log",
359
- args: [
360
- {
361
- type: "string",
362
- value: t
363
- }
364
- ],
365
- position: c(),
366
- time: y(),
367
- stack: s,
368
- mode: "input"
369
- };
370
- this.updateConsoleList([{ ...o }]), this.execute(t).then((a) => {
371
- const l = ht(a), u = ut(a), D = l === "object" || l === "array" ? lt(u, l) : "";
372
- o.args = [
373
- {
374
- type: l,
375
- value: u,
376
- shortValue: D
377
- }
378
- ], o.time = y(), o.mode = "output", o.executionTime = Date.now() - i, this.updateConsoleList([{ ...o }]);
379
- });
380
- }
381
- /**
382
- * 更新截屏列表
383
- *
384
- * @param {DevTool.ScreenItem[]} list
385
- * @memberof DevEvent
386
- */
387
- updateScreenList(t, e) {
388
- this.store.updateScreenList(t, e), this.postMessage();
389
- }
390
- /**
391
- * 清空截屏列表
392
- *
393
- * @memberof DevEvent
394
- */
395
- clearCaptureScreenList() {
396
- this.store.clearCaptureScreenList();
397
- }
398
- /**
399
- * 更新拦截的网络请求列表
400
- *
401
- * @param {DevTool.NetworkItem[]} list
402
- * @memberof DevEvent
403
- */
404
- updateInterceptNetworkList(t) {
405
- this.store.updateInterceptNetworkList(t), this.postMessage();
406
- }
407
- /**
408
- * 清空拦截的网络请求列表
409
- *
410
- * @memberof DevEvent
411
- */
412
- clearInterceptNetworkList() {
413
- this.store.clearInterceptNetworkList(), this.postMessage();
414
- }
415
- /**
416
- * 移除拦截的网络请求
417
- *
418
- * @param {DevTool.NetworkItem} item
419
- * @memberof DevEvent
420
- */
421
- removeInterceptNetwork(t) {
422
- this.store.removeInterceptNetwork(t), this.postMessage();
423
- }
424
- /**
425
- * 缓存网络请求到本地
426
- *
427
- * @param {{
428
- * cacheInterceptConfig: boolean;
429
- * }} {
430
- * cacheInterceptConfig,
431
- * }
432
- * @memberof DevEvent
433
- */
434
- changeCacheInterceptConfig({
435
- cacheInterceptConfig: t
436
- }) {
437
- this.store.changeCacheInterceptConfig(t);
438
- }
439
- getInterceptNetworkMap() {
440
- return this.store.getInterceptNetworkMap();
441
- }
442
- updateScanCodeList(t) {
443
- this.store.updateScanCodeList(t), this.postMessage();
444
- }
445
- /**
446
- * 外界扫描传入的code
447
- * @param code
448
- */
449
- devToolScanCode(t, e) {
450
- var h, a;
451
- if (this.getDevToolDestroy())
452
- return;
453
- let s = {};
454
- try {
455
- s = JSON.parse(t);
456
- } catch {
457
- }
458
- const i = (a = (h = new Error()) == null ? void 0 : h.stack) == null ? void 0 : a.split(`
459
- `), o = i == null ? void 0 : i[2], n = {
460
- timer: Date.now(),
461
- charSet: "utf-8",
462
- rawData: t,
463
- result: t,
464
- scanType: e,
465
- errMsg: "ok",
466
- resultObject: s,
467
- path: c(),
468
- stack: o
469
- };
470
- this.updateScanCodeList([n]);
471
- }
472
- updateNfcList(t) {
473
- this.store.updateNfcList(t), this.postMessage();
474
- }
475
- /** 外界 nfc 读取传入 */
476
- devToolNFC(t) {
477
- var o, n;
478
- const e = (n = (o = new Error()) == null ? void 0 : o.stack) == null ? void 0 : n.split(`
479
- `), s = e == null ? void 0 : e[1], i = {
480
- ...t,
481
- stack: s,
482
- timer: Date.now(),
483
- path: c()
484
- };
485
- this.updateNfcList([i]);
486
- }
487
- addElEvent(t) {
488
- this.store.addElEvent(t), this.postMessage();
489
- }
490
- clearElEventList() {
491
- this.store.clearElEventList(), this.postMessage();
492
- }
493
- hasCaptureEvent(t) {
494
- const {
495
- includeCaptureElDataSet: e = [],
496
- excludeCaptureElDataSet: s = []
497
- } = this.store.getDevToolOptions() ?? {
498
- includeCaptureElDataSet: [],
499
- excludeCaptureElDataSet: []
500
- };
501
- return e.length ? e.some((i) => {
502
- var o;
503
- return Object.keys(((o = t == null ? void 0 : t.target) == null ? void 0 : o.dataset) ?? {}).includes(i);
504
- }) : s.length ? !s.some((i) => {
505
- var o;
506
- return Object.keys(((o = t == null ? void 0 : t.target) == null ? void 0 : o.dataset) ?? {}).includes(i);
507
- }) : !0;
508
- }
509
- tapEvent(t) {
510
- if (!this.hasCaptureEvent(t))
511
- return;
512
- const e = {
513
- type: t.type,
514
- timer: Date.now(),
515
- target: t.target,
516
- touches: t.touches,
517
- path: c()
518
- };
519
- this.addElEvent(e);
520
- }
521
- touchStartEvent(t) {
522
- if (!this.hasCaptureEvent(t))
523
- return;
524
- const e = {
525
- type: t.type,
526
- timer: Date.now(),
527
- target: t.target,
528
- touches: t.touches,
529
- path: c()
530
- };
531
- this.addElEvent(e);
532
- }
533
- touchMoveEvent(t) {
534
- if (!this.hasCaptureEvent(t))
535
- return;
536
- const e = {
537
- type: t.type,
538
- timer: Date.now(),
539
- target: t.target,
540
- touches: t.touches,
541
- path: c()
542
- };
543
- this.addElEvent(e);
544
- }
545
- touchEndEvent(t) {
546
- if (!this.hasCaptureEvent(t))
547
- return;
548
- const e = {
549
- type: t.type,
550
- timer: Date.now(),
551
- target: t.target,
552
- touches: t.touches,
553
- path: c()
554
- };
555
- this.addElEvent(e);
556
- }
557
- /**
558
- * 添加事件监听
559
- */
560
- addEventListener() {
561
- const t = this.store.getCaptureList();
562
- t.includes("tap") && this.eventBus.on(m, this.tapEvent.bind(this)), t.includes("touchstart") && this.eventBus.on(
563
- L,
564
- this.throttleTouchStartEvent.bind(this)
565
- ), t.includes("touchmove") && this.eventBus.on(
566
- S,
567
- this.throttleTouchMoveEvent.bind(this)
568
- ), t.includes("touchend") && this.eventBus.on(
569
- C,
570
- this.throttleTouchEndEvent.bind(this)
571
- );
572
- }
573
- /**
574
- * 移除事件监听
575
- */
576
- removeEventListener() {
577
- const t = this.store.getCaptureList();
578
- t.includes("tap") && this.eventBus.off(m, this.tapEvent), t.includes("touchstart") && this.eventBus.off(L, this.throttleTouchStartEvent), t.includes("touchmove") && this.eventBus.off(S, this.throttleTouchMoveEvent), t.includes("touchend") && this.eventBus.off(C, this.throttleTouchEndEvent);
579
- }
580
- async getAbnormalData() {
581
- var a, l, u, T, D, g;
582
- const t = await this.store.getDevData(), e = ((a = t.consoleList) == null ? void 0 : a.filter(
583
- (r) => ["error", "warn"].includes(r.type) && !r.hasUpload
584
- )) ?? [], s = ((l = t.networkList) == null ? void 0 : l.filter(
585
- (r) => {
586
- var E, v;
587
- return r.sponsor === "user" && !((v = (E = r.status) == null ? void 0 : E.toString()) != null && v.startsWith("2")) && !r.hasUpload;
588
- }
589
- )) ?? [], i = ((u = t.uploadList) == null ? void 0 : u.filter(
590
- (r) => {
591
- var E, v;
592
- return !((v = (E = r.status) == null ? void 0 : E.toString()) != null && v.startsWith("2")) && !r.hasUpload;
593
- }
594
- )) ?? [], o = ((T = t.elEventList) == null ? void 0 : T.filter((r) => !r.hasUpload)) ?? [], n = ((D = t.uniEventList) == null ? void 0 : D.filter((r) => !r.hasUpload)) ?? [], h = ((g = t.screenList) == null ? void 0 : g.filter((r) => !r.hasUpload)) ?? [];
595
- return {
596
- consoleList: e,
597
- networkList: s,
598
- uploadList: i,
599
- elEventList: o,
600
- uniEventList: n,
601
- screenList: h,
602
- systemInfo: t.systemInfo,
603
- deviceInfo: t.deviceInfo
604
- };
605
- }
606
- async performAbnormalUpload(t) {
607
- const {
608
- consoleList: e,
609
- networkList: s,
610
- uploadList: i,
611
- systemInfo: o,
612
- elEventList: n,
613
- uniEventList: h,
614
- screenList: a,
615
- deviceInfo: l
616
- } = await this.getAbnormalData();
617
- (e.length || s.length || i.length || n.length || h.length || a.length) && uni.request({
618
- method: "POST",
619
- url: t == null ? void 0 : t.url,
620
- header: {
621
- ...(t == null ? void 0 : t.header) ?? {},
622
- "dev-tool-sponsor": Date.now()
623
- },
624
- timeout: (t == null ? void 0 : t.timerOut) ?? 3 * 1e3,
625
- data: {
626
- ...(t == null ? void 0 : t.payload) ?? {},
627
- consoleList: e,
628
- networkList: s,
629
- uploadList: i,
630
- elEventList: n,
631
- uniEventList: h,
632
- screenList: a,
633
- deviceInfo: l,
634
- systemInfo: o,
635
- platform: uni.__dev_tool_platform__
636
- },
637
- success: () => {
638
- this.store.updateHasUpload(), this.uploadAbnormal(), this.abnormalUploadCount = 0;
639
- },
640
- fail: () => {
641
- this.uploadAbnormal(), this.abnormalUploadCount++;
642
- }
643
- });
644
- }
645
- /**
646
- * 上报异常
647
- *
648
- * @memberof DevEvent
649
- */
650
- uploadAbnormal(t) {
651
- if (!this.isAbnormalUploadActive)
652
- return;
653
- const { uploadAbnormalUV: e } = this.store.getDevToolOptions() ?? {
654
- uploadAbnormalUV: {
655
- url: "",
656
- header: {
657
- "dev-tool-sponsor": Date.now()
658
- },
659
- payload: {},
660
- duration: 10 * 1e3,
661
- timerOut: 3 * 1e3
662
- }
663
- };
664
- if (!(e != null && e.url)) {
665
- p.log("[DevTool] 未配置异常上报地址,将不上报异常信息");
666
- return;
667
- }
668
- const s = e.duration ?? 10 * 1e3, i = 5 * 60 * 1e3, o = Math.min(
669
- s * Math.pow(2, this.abnormalUploadCount),
670
- i
671
- ), n = Math.max(o, s);
672
- this.abnormalUploadTimer && clearTimeout(this.abnormalUploadTimer), t != null && t.immediately && this.performAbnormalUpload(e), this.abnormalUploadTimer = setTimeout(() => {
673
- this.performAbnormalUpload(e);
674
- }, n);
675
- }
676
- /**
677
- * 启动异常上报
678
- */
679
- startAbnormalUpload(t) {
680
- this.isAbnormalUploadActive = !0, this.abnormalUploadCount = 0, this.uploadAbnormal(t);
681
- }
682
- /**
683
- * 停止异常上报
684
- */
685
- stopAbnormalUpload() {
686
- this.isAbnormalUploadActive = !1, this.abnormalUploadTimer && (clearTimeout(this.abnormalUploadTimer), this.abnormalUploadTimer = null);
687
- }
688
- /**
689
- * 重启异常上报
690
- */
691
- restartAbnormalUpload() {
692
- this.stopAbnormalUpload(), this.startAbnormalUpload();
693
- }
694
- }
695
- export {
696
- wt as DevEvent
697
- };