vite-uni-dev-tool 0.0.11 → 0.0.13

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 (180) hide show
  1. package/README.md +55 -1
  2. package/dist/const.d.ts +133 -0
  3. package/dist/const.d.ts.map +1 -0
  4. package/dist/const.js +36 -0
  5. package/dist/core.d.ts +52 -0
  6. package/dist/core.d.ts.map +1 -0
  7. package/dist/core.js +80 -0
  8. package/dist/devConsole/index.d.ts +169 -0
  9. package/dist/devConsole/index.d.ts.map +1 -0
  10. package/dist/devConsole/index.js +270 -0
  11. package/dist/devEvent/index.d.ts +286 -0
  12. package/dist/devEvent/index.d.ts.map +1 -0
  13. package/dist/devEvent/index.js +435 -0
  14. package/dist/devEventBus/index.d.ts +42 -0
  15. package/dist/devEventBus/index.d.ts.map +1 -0
  16. package/dist/devEventBus/index.js +70 -0
  17. package/dist/devIntercept/index.d.ts +119 -0
  18. package/dist/devIntercept/index.d.ts.map +1 -0
  19. package/dist/devIntercept/index.js +582 -0
  20. package/dist/devRunJS/index.d.ts +67 -0
  21. package/dist/devRunJS/index.d.ts.map +1 -0
  22. package/dist/devStore/index.d.ts +178 -0
  23. package/dist/devStore/index.d.ts.map +1 -0
  24. package/dist/devStore/index.js +395 -0
  25. package/dist/devToolInfo/index.d.ts +17 -0
  26. package/dist/devToolInfo/index.d.ts.map +1 -0
  27. package/dist/devToolInfo/index.js +15 -0
  28. package/{dev → dist}/plugins/uniDevTool/uniDevTool.d.ts +15 -1
  29. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
  30. package/dist/plugins/uniDevTool/uniDevTool.js +35 -0
  31. package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -7
  32. package/{dev → dist}/plugins/utils/index.d.ts +3 -0
  33. package/{dev → dist}/plugins/utils/index.d.ts.map +1 -1
  34. package/dist/plugins/utils/index.js +1 -0
  35. package/dist/type.d.ts +264 -0
  36. package/dist/type.d.ts.map +1 -0
  37. package/dist/utils/array.d.ts +2 -0
  38. package/dist/utils/array.d.ts.map +1 -0
  39. package/dist/utils/array.js +12 -0
  40. package/dist/utils/date.d.ts +19 -0
  41. package/dist/utils/date.d.ts.map +1 -0
  42. package/dist/utils/date.js +40 -0
  43. package/dist/utils/file.d.ts +11 -0
  44. package/dist/utils/file.d.ts.map +1 -0
  45. package/dist/utils/file.js +87 -0
  46. package/dist/utils/function.d.ts +28 -0
  47. package/dist/utils/function.d.ts.map +1 -0
  48. package/dist/utils/function.js +46 -0
  49. package/dist/utils/index.d.ts +11 -0
  50. package/dist/utils/index.d.ts.map +1 -0
  51. package/dist/utils/index.js +55 -0
  52. package/dist/utils/ip.d.ts +5 -0
  53. package/dist/utils/ip.d.ts.map +1 -0
  54. package/dist/utils/ip.js +21 -0
  55. package/dist/utils/language.d.ts +29 -0
  56. package/dist/utils/language.d.ts.map +1 -0
  57. package/dist/utils/language.js +50 -0
  58. package/dist/utils/object.d.ts +49 -0
  59. package/dist/utils/object.d.ts.map +1 -0
  60. package/dist/utils/object.js +118 -0
  61. package/dist/utils/page.d.ts +7 -0
  62. package/dist/utils/page.d.ts.map +1 -0
  63. package/dist/utils/page.js +7 -0
  64. package/dist/utils/platform.d.ts +4 -0
  65. package/dist/utils/platform.d.ts.map +1 -0
  66. package/dist/utils/platform.js +14 -0
  67. package/dist/utils/string.d.ts +45 -0
  68. package/dist/utils/string.d.ts.map +1 -0
  69. package/dist/utils/string.js +88 -0
  70. package/dist/utils/utils.d.ts +16 -0
  71. package/dist/utils/utils.d.ts.map +1 -0
  72. package/dist/v2/AutoSizer/utils.d.ts +5 -0
  73. package/dist/v2/AutoSizer/utils.d.ts.map +1 -0
  74. package/dist/v2/JsonPretty/hooks/useClipboard.d.ts +4 -0
  75. package/dist/v2/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
  76. package/dist/v2/JsonPretty/hooks/useError.d.ts +8 -0
  77. package/dist/v2/JsonPretty/hooks/useError.d.ts.map +1 -0
  78. package/dist/v2/JsonPretty/type.d.ts +93 -0
  79. package/dist/v2/JsonPretty/type.d.ts.map +1 -0
  80. package/dist/v3/AutoSizer/utils.d.ts +5 -0
  81. package/dist/v3/AutoSizer/utils.d.ts.map +1 -0
  82. package/dist/v3/ConsoleList/staticTips.d.ts +13 -0
  83. package/dist/v3/ConsoleList/staticTips.d.ts.map +1 -0
  84. package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +4 -0
  85. package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
  86. package/dist/v3/JsonPretty/hooks/useError.d.ts +8 -0
  87. package/dist/v3/JsonPretty/hooks/useError.d.ts.map +1 -0
  88. package/dist/v3/JsonPretty/type.d.ts +93 -0
  89. package/dist/v3/JsonPretty/type.d.ts.map +1 -0
  90. package/dist/v3/JsonPretty/utils/index.d.ts +10 -0
  91. package/dist/v3/JsonPretty/utils/index.d.ts.map +1 -0
  92. package/package.json +5 -5
  93. package/dev/components/AppInfo/index.vue +0 -36
  94. package/dev/components/AutoSizer/index.vue +0 -193
  95. package/dev/components/AutoSizer/index1.vue +0 -186
  96. package/dev/components/AutoSizer/utils.ts +0 -49
  97. package/dev/components/Button/index.vue +0 -34
  98. package/dev/components/CaptureScreen/index.vue +0 -62
  99. package/dev/components/Checkbox/index.vue +0 -40
  100. package/dev/components/CloseButton/index.vue +0 -26
  101. package/dev/components/Code/index.vue +0 -230
  102. package/dev/components/Connection/index.vue +0 -88
  103. package/dev/components/ConsoleList/Code.vue +0 -227
  104. package/dev/components/ConsoleList/ConsoleItem.vue +0 -186
  105. package/dev/components/ConsoleList/RunJSInput.vue +0 -235
  106. package/dev/components/ConsoleList/index.vue +0 -130
  107. package/dev/components/ConsoleList/staticTips.ts +0 -1145
  108. package/dev/components/DevTool/index.vue +0 -182
  109. package/dev/components/DevToolButton/index.vue +0 -213
  110. package/dev/components/DevToolTitle/index.vue +0 -21
  111. package/dev/components/DevToolWindow/index.vue +0 -1037
  112. package/dev/components/DeviceInfo/index.vue +0 -32
  113. package/dev/components/Empty/empty.png +0 -0
  114. package/dev/components/Empty/index.vue +0 -28
  115. package/dev/components/FilterInput/index.vue +0 -86
  116. package/dev/components/JsonPretty/components/Brackets/index.vue +0 -23
  117. package/dev/components/JsonPretty/components/Carets/index.vue +0 -59
  118. package/dev/components/JsonPretty/components/CheckController/index.vue +0 -125
  119. package/dev/components/JsonPretty/components/TreeNode/index.vue +0 -349
  120. package/dev/components/JsonPretty/hooks/useClipboard.ts +0 -21
  121. package/dev/components/JsonPretty/hooks/useError.ts +0 -21
  122. package/dev/components/JsonPretty/index.vue +0 -474
  123. package/dev/components/JsonPretty/type.ts +0 -125
  124. package/dev/components/JsonPretty/utils/index.ts +0 -172
  125. package/dev/components/NetworkList/NetworkDetail.vue +0 -197
  126. package/dev/components/NetworkList/NetworkItem.vue +0 -106
  127. package/dev/components/NetworkList/index.vue +0 -115
  128. package/dev/components/PiniaList/index.vue +0 -64
  129. package/dev/components/RouteList/index.vue +0 -110
  130. package/dev/components/RunJS/index.vue +0 -128
  131. package/dev/components/SettingList/index.vue +0 -225
  132. package/dev/components/StorageList/index.vue +0 -170
  133. package/dev/components/SystemInfo/index.vue +0 -34
  134. package/dev/components/Tabs/index.vue +0 -123
  135. package/dev/components/Tag/index.vue +0 -89
  136. package/dev/components/UniEvent/UniEventItem.vue +0 -124
  137. package/dev/components/UniEvent/index.vue +0 -94
  138. package/dev/components/UploadList/UploadDetail.vue +0 -208
  139. package/dev/components/UploadList/UploadItem.vue +0 -111
  140. package/dev/components/UploadList/index.vue +0 -104
  141. package/dev/components/VirtualList/index.vue +0 -112
  142. package/dev/components/VirtualListPro/AutoSize.vue +0 -43
  143. package/dev/components/VirtualListPro/index.vue +0 -175
  144. package/dev/components/VirtualListPro/readme.md +0 -40
  145. package/dev/components/VuexList/index.vue +0 -54
  146. package/dev/components/WebSocket/WebSocketItem.vue +0 -98
  147. package/dev/components/WebSocket/WebSocketList.vue +0 -176
  148. package/dev/components/WebSocket/index.vue +0 -111
  149. package/dev/components/WindowInfo/index.vue +0 -33
  150. package/dev/const.ts +0 -166
  151. package/dev/core.ts +0 -118
  152. package/dev/devConsole/index.ts +0 -350
  153. package/dev/devEvent/index.ts +0 -806
  154. package/dev/devEventBus/index.ts +0 -94
  155. package/dev/devIntercept/index.ts +0 -745
  156. package/dev/devRunJS/index.ts +0 -170
  157. package/dev/devStore/index.ts +0 -718
  158. package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
  159. package/dev/plugins/uniDevTool/uniDevTool.js +0 -36
  160. package/dev/plugins/utils/index.js +0 -1
  161. package/dev/shims-uni.d.ts +0 -43
  162. package/dev/type.ts +0 -264
  163. package/dev/utils/array.ts +0 -15
  164. package/dev/utils/date.ts +0 -75
  165. package/dev/utils/file.ts +0 -121
  166. package/dev/utils/function.ts +0 -192
  167. package/dev/utils/index.d.ts +0 -6
  168. package/dev/utils/index.ts +0 -46
  169. package/dev/utils/ip.ts +0 -79
  170. package/dev/utils/language.ts +0 -72
  171. package/dev/utils/object.ts +0 -298
  172. package/dev/utils/page.ts +0 -13
  173. package/dev/utils/platform.ts +0 -14
  174. package/dev/utils/string.ts +0 -133
  175. package/dev/utils/utils.ts +0 -198
  176. /package/{dev → dist}/index.d.ts +0 -0
  177. /package/{dev → dist}/index.d.ts.map +0 -0
  178. /package/{dev → dist}/index.js +0 -0
  179. /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -0
  180. /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -0
@@ -0,0 +1,435 @@
1
+ import { backup as s } from "../core.js";
2
+ import { DEV_APP_MESSAGE as a, DEV_WINDOW_VISIBLE as n, DEV_BUTTON_VISIBLE as p, DEV_OPTION_SEND as l, DEV_WINDOW_MESSAGE as h, DEV_CONSOLE_CLEAR as u, DEV_NETWORK_CLEAR as c, DEV_WEBSOCKET_CLEAR as D, DEV_UPLOAD_CLEAR as v, DEV_STORAGE_CLEAR as E, DEV_STORAGE_REFRESH as g, DEV_STORAGE_REMOVE as T, DEV_STORAGE_ADD as _, DEV_STORAGE_UPDATE as S, DEV_PAGE_JUMP as d, DEV_BUTTON_SHOW_OR_HIDE as f, DEV_RESTART_DEBUGGER as y, DEV_RESTART_APP as m, DEV_EXPORT_LOG as L, DEV_VUEX_CHANGE as R, DEV_PINIA_CHANGE as I, DEV_LOG_CACHE_CLEAR as V, DEV_DESTROY as C, DEV_WINDOW_OPEN as A, DEV_WINDOW_CLOSE as O, DEV_ROUTE_REFRESH as M, DEV_OPTION_GET as w, DEV_UNI_EVENT_CLEAR as U, DEV_RUN_JS as P, DEV_CAPTURE_SCREEN_CLEAR as x } from "../const.js";
3
+ import "../utils/index.js";
4
+ import { throttle as N } from "../utils/function.js";
5
+ import { calculateObjectSize as W, formatStorageSize as B, parseValue as G } from "../utils/object.js";
6
+ import { saveTextFileH5 as k } from "../utils/file.js";
7
+ import { getCurrentDate as r } from "../utils/date.js";
8
+ import { transformValueToView as b } from "../utils/language.js";
9
+ class Y {
10
+ constructor({ store: e, eventBus: t }) {
11
+ this.postMessage = N(this.postMessageFn, 1e3), this.store = e, this.eventBus = t, this.acceptMessage();
12
+ }
13
+ /**
14
+ * 发送数据
15
+ *
16
+ * @param {DevTool.WindowData} data
17
+ * @memberof DevEvent
18
+ */
19
+ async postMessageFn() {
20
+ var i;
21
+ if (this.getDevToolDestroy())
22
+ return;
23
+ const e = await this.store.getDevData(), t = W(e), o = B(t);
24
+ e.size = t, e.sizeFormat = o, this.eventBus.emit(a, e), t > this.store.cacheMaxSize && ((i = this.store) == null || i.clearDevCache());
25
+ }
26
+ /**
27
+ * 创建调试器
28
+ *
29
+ * @return {*}
30
+ * @memberof DevEvent
31
+ */
32
+ createDevTool() {
33
+ if (!this.getDevToolDestroy()) {
34
+ console.warn("[DevTool] 调试器已存在,不在重新创建");
35
+ return;
36
+ }
37
+ this.store.setDevToolDestroy(!1), console.log("[DevTool] 调试器创建成功");
38
+ }
39
+ /**
40
+ * 销毁调试器
41
+ *
42
+ * @return {*}
43
+ * @memberof DevEvent
44
+ */
45
+ destroyDevTool() {
46
+ if (this.getDevToolDestroy()) {
47
+ console.warn("[DevTool] 调试器已经销毁了,不在重新销毁");
48
+ return;
49
+ }
50
+ this.store.setRequestIndex(-1), this.store.setUploadIndex(-1), this.store.clearAll(), this.hideDevToolButton(), this.closeDevToolWindow(), this.resetInterceptAppConsole(), this.resetInterceptPromiseReject(), this.resetInterceptErrorApp(), this.resetInterceptWarnApp(), this.resetInterceptStorage(), this.resetInterceptUpload(), this.resetInterceptRequest(), this.resetInterceptNavigateTo(), this.resetInterceptSwitchTab(), this.resetUniEvent(), this.store.setDevToolDestroy(!0), console.warn("[DevTool] 调试器已销毁");
51
+ }
52
+ /**
53
+ * 重启调试器
54
+ *
55
+ * @memberof DevEvent
56
+ */
57
+ restartDevTool() {
58
+ this.destroyDevTool(), this.createDevTool(), this.openDevToolWindow();
59
+ }
60
+ /**
61
+ * 打开调试器窗口
62
+ *
63
+ * @memberof DevEvent
64
+ */
65
+ openDevToolWindow() {
66
+ this.getDevToolDestroy() || (setTimeout(async () => {
67
+ this.postMessage();
68
+ }, 100), this.eventBus.emit(n, !0));
69
+ }
70
+ /**
71
+ * 关闭调试器窗口
72
+ *
73
+ * @memberof DevEvent
74
+ */
75
+ closeDevToolWindow() {
76
+ this.getDevToolDestroy() || this.eventBus.emit(n, !1);
77
+ }
78
+ /**
79
+ * 显示调试按钮
80
+ *
81
+ * @export
82
+ */
83
+ showDevToolButton() {
84
+ this.getDevToolDestroy() || (this.eventBus.emit(p, !0), this.store.setDevToolVisible(!0));
85
+ }
86
+ /**
87
+ * 隐藏调试按钮
88
+ *
89
+ * @return {*}
90
+ */
91
+ hideDevToolButton() {
92
+ this.getDevToolDestroy() || (this.eventBus.emit(p, !1), this.store.setDevToolVisible(!1));
93
+ }
94
+ exportLog(e) {
95
+ const t = this.store.getExportData(e);
96
+ k(JSON.stringify(t, null, 2), "dev-tool-log");
97
+ }
98
+ /**
99
+ * 切换页面
100
+ *
101
+ * @param {string} path
102
+ * @memberof DevEvent
103
+ */
104
+ switchTo(e) {
105
+ this.closeDevToolWindow(), uni.switchTab({
106
+ url: e
107
+ });
108
+ }
109
+ /**
110
+ * 跳转页面
111
+ *
112
+ * @param {string} path
113
+ * @memberof DevEvent
114
+ */
115
+ navigateTo(e) {
116
+ this.closeDevToolWindow(), uni.navigateTo({
117
+ url: e
118
+ });
119
+ }
120
+ /**
121
+ * 重启app
122
+ *
123
+ * @memberof DevEvent
124
+ */
125
+ restartApp() {
126
+ window.location.reload();
127
+ }
128
+ refreshRouteList() {
129
+ this.store.getRouteList(), this.postMessage();
130
+ }
131
+ sendDevToolOption() {
132
+ const e = this.store.getDevToolOptions();
133
+ this.eventBus.emit(l, e);
134
+ }
135
+ /**
136
+ * 接受消息
137
+ *
138
+ * @memberof DevEvent
139
+ */
140
+ acceptMessage() {
141
+ this.eventBus.on(
142
+ h,
143
+ (e) => {
144
+ var t;
145
+ e.type === u ? this.store.clearConsoleList() : e.type === c ? this.store.clearNetworkList() : e.type === D ? this.store.clearWsList() : e.type === v ? this.store.clearUploadList() : e.type === E ? this.store.clearStorageList() : e.type === g ? (this.store.refreshStore(), this.postMessage()) : e.type === T ? (this.store.removeStorage(e.data.key + ""), this.postMessage()) : e.type === _ ? (this.store.addStorage(e.data), this.postMessage()) : e.type === S ? (this.store.updateStore(e.data), this.postMessage()) : e.type === d ? ((t = e.data) == null ? void 0 : t.type) === "nav" ? this.switchTo(e.data.path ?? "") : this.navigateTo(e.data.path ?? "") : e.type === f ? (e.data.show ? this.showDevToolButton() : this.hideDevToolButton(), this.postMessage()) : e.type === y ? this.restartDevTool() : e.type === m ? this.restartApp() : e.type === L ? this.exportLog(e.data) : e.type === R ? (this.store.updateVuexStore(e.data), this.postMessage()) : e.type === I ? (this.store.updatePiniaStore(e.data), this.postMessage()) : e.type === V ? this.store.clearDevCache() : e.type === C ? this.destroyDevTool() : e.type === A ? this.openDevToolWindow() : e.type === O ? this.closeDevToolWindow() : e.type === M ? this.refreshRouteList() : e.type === w ? this.sendDevToolOption() : e.type === U ? this.uniEventClear() : e.type === P ? this.devRunJS(e.data.code) : e.type === x && this.store.clearCaptureScreenList();
146
+ }
147
+ );
148
+ }
149
+ /**
150
+ * 重置拦截 promise reject
151
+ *
152
+ * @memberof DevEvent
153
+ */
154
+ resetInterceptPromiseReject() {
155
+ Object.defineProperty(Promise, "reject", {
156
+ value: function(e) {
157
+ return s.reject.call(Promise, e);
158
+ }
159
+ });
160
+ }
161
+ /**
162
+ * 重置劫持 app 错误
163
+ *
164
+ * @memberof DevEvent
165
+ */
166
+ resetInterceptErrorApp() {
167
+ }
168
+ /**
169
+ * 重置劫持 app 警告
170
+ *
171
+ * @memberof DevEvent
172
+ */
173
+ resetInterceptWarnApp() {
174
+ }
175
+ /**
176
+ * 更新路由信息
177
+ *
178
+ * @param {string} path
179
+ * @memberof DevEvent
180
+ */
181
+ updateCurrentPagePath(e) {
182
+ this.store.updateCurrentPagePath(e), this.postMessage();
183
+ }
184
+ /**
185
+ * 重置 nav 跳转
186
+ *
187
+ * @memberof DevEvent
188
+ */
189
+ resetInterceptSwitchTab() {
190
+ uni.removeInterceptor("switchTab");
191
+ }
192
+ /**
193
+ * 重置页面跳转
194
+ *
195
+ * @memberof DevEvent
196
+ */
197
+ resetInterceptNavigateTo() {
198
+ uni.removeInterceptor("navigateTo");
199
+ }
200
+ /**
201
+ * 清除console日志
202
+ *
203
+ * @memberof DevEvent
204
+ */
205
+ clearConsoleList() {
206
+ this.store.clearConsoleList(), this.postMessage();
207
+ }
208
+ /**
209
+ * 更新控制台日志
210
+ *
211
+ * @param {DevTool.ConsoleItem[]} addItems
212
+ * @param {number} [index]
213
+ * @memberof DevEvent
214
+ */
215
+ updateConsoleList(e, t) {
216
+ this.store.updateConsoleList(e, t), this.postMessage();
217
+ }
218
+ /**
219
+ * 重置console
220
+ *
221
+ * @memberof DevEvent
222
+ */
223
+ resetInterceptAppConsole() {
224
+ uni.__log__ && (uni.__log__ = s.__log__);
225
+ }
226
+ /**
227
+ * 更新网络日志
228
+ *
229
+ * @param {DevTool.NetworkItem[]} addItems
230
+ * @param {number} [index]
231
+ * @memberof DevEvent
232
+ */
233
+ updateNetworkList(e, t) {
234
+ this.store.updateNetworkList(e, t), this.postMessage();
235
+ }
236
+ /**
237
+ * 重置网络监听
238
+ *
239
+ * @memberof DevEvent
240
+ */
241
+ resetInterceptRequest() {
242
+ uni.removeInterceptor("request");
243
+ }
244
+ /**
245
+ * 更新websocket日志
246
+ *
247
+ * @param {DevTool.WS} item
248
+ * @memberof DevEvent
249
+ */
250
+ updateWsList(e) {
251
+ this.store.updateWsList(e), this.postMessage();
252
+ }
253
+ /**
254
+ * 重置websocket
255
+ *
256
+ * @memberof DevEvent
257
+ */
258
+ resetWebSocket() {
259
+ uni.connectSocket = s.connectSocket;
260
+ }
261
+ /**
262
+ * 更新状态存储
263
+ *
264
+ * @param {DevTool.StorageItem[]} addItems
265
+ * @memberof DevEvent
266
+ */
267
+ updateStoreList(e) {
268
+ this.store.updateStoreList(e), this.postMessage();
269
+ }
270
+ /**
271
+ * 移除状态
272
+ *
273
+ * @param {string} key
274
+ * @memberof DevEvent
275
+ */
276
+ removeStorage(e) {
277
+ this.store.removeStorage(e), this.postMessage();
278
+ }
279
+ /**
280
+ * 清除缓存
281
+ *
282
+ * @memberof DevEvent
283
+ */
284
+ clearStorage() {
285
+ this.store.clearStorageList();
286
+ }
287
+ /**
288
+ * 重置 storage 函数
289
+ *
290
+ * @memberof DevEvent
291
+ */
292
+ resetInterceptStorage() {
293
+ uni.setStorage = s.setStorage, uni.setStorageSync = s.setStorageSync, uni.clearStorage = s.clearStorage, uni.clearStorageSync = s.clearStorageSync, uni.removeStorage = s.removeStorage, uni.removeStorageSync = s.removeStorageSync;
294
+ }
295
+ /**
296
+ * 更新上传日志
297
+ *
298
+ * @param {DevTool.UploadItem[]} addItems
299
+ * @param {number} [index]
300
+ * @memberof DevEvent
301
+ */
302
+ updateUploadList(e, t) {
303
+ this.store.updateUploadList(e, t), this.postMessage();
304
+ }
305
+ /**
306
+ * 移除上传任务
307
+ *
308
+ * @param {(number | string)} index
309
+ * @memberof DevEvent
310
+ */
311
+ removeUploadTask(e) {
312
+ this.store.removeUploadTask(e);
313
+ }
314
+ /**
315
+ * 新增上传任务
316
+ *
317
+ * @param {(number | string)} index
318
+ * @param {UniApp.UploadTask} task
319
+ * @memberof DevEvent
320
+ */
321
+ addUploadTask(e, t) {
322
+ this.store.addUploadTask(e, t);
323
+ }
324
+ /**
325
+ * 重置 uni.uploadFile
326
+ *
327
+ * @memberof DevEvent
328
+ */
329
+ resetInterceptUpload() {
330
+ uni.uploadFile = s.uploadFile;
331
+ }
332
+ setRequestIndex(e) {
333
+ return this.store.setRequestIndex(e);
334
+ }
335
+ getRequestIndex() {
336
+ return this.store.getRequestIndex();
337
+ }
338
+ setUploadIndex(e) {
339
+ return this.store.setUploadIndex(e);
340
+ }
341
+ getUploadIndex() {
342
+ return this.store.getUploadIndex();
343
+ }
344
+ setVuexList(e) {
345
+ this.store.setVuexList(e);
346
+ }
347
+ setPiniaList(e) {
348
+ this.store.setPiniaList(e);
349
+ }
350
+ setPiniaStore(e) {
351
+ this.store.setPiniaStore(e);
352
+ }
353
+ getDevToolDestroy() {
354
+ return this.store.getDevToolDestroy();
355
+ }
356
+ updateUniEventCount(e) {
357
+ this.store.updateUniEventCount(e), this.postMessage();
358
+ }
359
+ updateUniEventList(e) {
360
+ this.store.updateUniEventList(e), this.postMessage();
361
+ }
362
+ uniEventClear() {
363
+ this.store.uniEventClear();
364
+ }
365
+ resetUniEvent() {
366
+ uni.$on = s.$on, uni.$once = s.$once, uni.$emit = s.$emit, uni.$off = s.$off;
367
+ }
368
+ execute(e) {
369
+ const t = "_e_v_a_l_".replace(
370
+ /_/g,
371
+ ""
372
+ );
373
+ return globalThis != null && globalThis[t] ? Promise.resolve(globalThis == null ? void 0 : globalThis[t](e)) : Promise.reject(
374
+ new Error("[DevTool] DevRunJS 当前环境不支持执行js")
375
+ );
376
+ }
377
+ /**
378
+ * 运行js
379
+ *
380
+ * @param {string} code
381
+ * @memberof DevEvent
382
+ */
383
+ devRunJS(e) {
384
+ const t = Date.now(), o = {
385
+ type: "log",
386
+ args: [
387
+ {
388
+ type: "string",
389
+ value: e
390
+ }
391
+ ],
392
+ position: "dev/devEvent/index.ts",
393
+ time: r(),
394
+ stack: "http://usr/devRunJS",
395
+ mode: "input"
396
+ };
397
+ console.log(e), this.store.updateConsoleList([{ ...o }]), this.postMessageFn(), this.execute(e).then((i) => {
398
+ o.args = [
399
+ {
400
+ type: b(i),
401
+ value: G(i)
402
+ }
403
+ ], o.position = `dev/devEvent/index.ts ${Date.now() - t}ms`, o.time = r(), o.mode = "output";
404
+ }).catch((i) => {
405
+ console.error(i), o.args = [
406
+ {
407
+ type: "string",
408
+ value: i.message
409
+ }
410
+ ], o.position = `dev/devEvent/index.ts ${Date.now() - t}ms`, o.time = r(), o.type = "error", o.mode = "output";
411
+ }).finally(() => {
412
+ this.store.updateConsoleList([{ ...o }]), this.postMessageFn();
413
+ });
414
+ }
415
+ /**
416
+ * 更新截屏列表
417
+ *
418
+ * @param {DevTool.CaptureScreenItem[]} list
419
+ * @memberof DevEvent
420
+ */
421
+ updateCaptureScreenList(e) {
422
+ this.store.updateCaptureScreenList(e), this.postMessage();
423
+ }
424
+ /**
425
+ * 清空截屏列表
426
+ *
427
+ * @memberof DevEvent
428
+ */
429
+ clearCaptureScreenList() {
430
+ this.store.clearCaptureScreenList();
431
+ }
432
+ }
433
+ export {
434
+ Y as DevEvent
435
+ };
@@ -0,0 +1,42 @@
1
+ type EventHandler<T = any> = (payload: T) => void;
2
+ export declare class EventBus {
3
+ private events;
4
+ /**
5
+ * 订阅事件
6
+ * @param eventName 事件名称
7
+ * @param handler 事件处理函数
8
+ * @returns 返回一个取消订阅的函数
9
+ */
10
+ on<T = any>(eventName: string, handler: EventHandler<T>): () => void;
11
+ /**
12
+ * 发布事件
13
+ * @param eventName 事件名称
14
+ * @param payload 事件携带的数据
15
+ */
16
+ emit<T = any>(eventName: string, payload: T): void;
17
+ /**
18
+ * 取消订阅事件
19
+ * @param eventName 事件名称
20
+ * @param handler 要取消的事件处理函数
21
+ */
22
+ off<T = any>(eventName: string, handler: EventHandler<T>): void;
23
+ /**
24
+ * 只订阅一次事件,触发后自动取消订阅
25
+ * @param eventName 事件名称
26
+ * @param handler 事件处理函数
27
+ */
28
+ once<T = any>(eventName: string, handler: EventHandler<T>): void;
29
+ /**
30
+ * 清除指定事件的所有订阅者,如果未提供事件名称,则清除所有事件
31
+ * @param eventName 可选的事件名称
32
+ */
33
+ clear(eventName?: string): void;
34
+ /**
35
+ * 获取指定事件的订阅者数量,如果未提供事件名称,则返回所有事件的订阅者总数
36
+ * @param eventName 可选的事件名称
37
+ * @returns 订阅者数量
38
+ */
39
+ count(eventName?: string): number;
40
+ }
41
+ export {};
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../dev/devEventBus/index.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC;AAElD,qBAAa,QAAQ;IAEnB,OAAO,CAAC,MAAM,CAA0C;IAExD;;;;;OAKG;IACH,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAapE;;;;OAIG;IACH,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI;IAOlD;;;;OAIG;IACH,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI;IAU/D;;;;OAIG;IACH,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI;IAQhE;;;OAGG;IACH,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAQ/B;;;;OAIG;IACH,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;CAWlC"}
@@ -0,0 +1,70 @@
1
+ class n {
2
+ constructor() {
3
+ this.events = /* @__PURE__ */ new Map();
4
+ }
5
+ /**
6
+ * 订阅事件
7
+ * @param eventName 事件名称
8
+ * @param handler 事件处理函数
9
+ * @returns 返回一个取消订阅的函数
10
+ */
11
+ on(s, t) {
12
+ return this.events.has(s) || this.events.set(s, []), this.events.get(s).push(t), () => {
13
+ this.off(s, t);
14
+ };
15
+ }
16
+ /**
17
+ * 发布事件
18
+ * @param eventName 事件名称
19
+ * @param payload 事件携带的数据
20
+ */
21
+ emit(s, t) {
22
+ this.events.has(s) && [...this.events.get(s)].forEach((h) => h(t));
23
+ }
24
+ /**
25
+ * 取消订阅事件
26
+ * @param eventName 事件名称
27
+ * @param handler 要取消的事件处理函数
28
+ */
29
+ off(s, t) {
30
+ if (this.events.has(s)) {
31
+ const e = this.events.get(s);
32
+ this.events.set(
33
+ s,
34
+ e.filter((h) => h !== t)
35
+ );
36
+ }
37
+ }
38
+ /**
39
+ * 只订阅一次事件,触发后自动取消订阅
40
+ * @param eventName 事件名称
41
+ * @param handler 事件处理函数
42
+ */
43
+ once(s, t) {
44
+ const e = (h) => {
45
+ t(h), this.off(s, e);
46
+ };
47
+ this.on(s, e);
48
+ }
49
+ /**
50
+ * 清除指定事件的所有订阅者,如果未提供事件名称,则清除所有事件
51
+ * @param eventName 可选的事件名称
52
+ */
53
+ clear(s) {
54
+ s ? this.events.delete(s) : this.events.clear();
55
+ }
56
+ /**
57
+ * 获取指定事件的订阅者数量,如果未提供事件名称,则返回所有事件的订阅者总数
58
+ * @param eventName 可选的事件名称
59
+ * @returns 订阅者数量
60
+ */
61
+ count(s) {
62
+ return s ? this.events.has(s) ? this.events.get(s).length : 0 : Array.from(this.events.values()).reduce(
63
+ (t, e) => t + e.length,
64
+ 0
65
+ );
66
+ }
67
+ }
68
+ export {
69
+ n as EventBus
70
+ };
@@ -0,0 +1,119 @@
1
+ import { DevTool } from '../type';
2
+
3
+ /**
4
+ * 拦截器
5
+ *
6
+ * @export
7
+ * @class DevIntercept
8
+ */
9
+ export declare class DevIntercept {
10
+ private event;
11
+ initPinia: boolean;
12
+ cache$on: Map<any, any>;
13
+ cache$once: Map<any, any>;
14
+ cache$emit: Map<any, any>;
15
+ cache$off: Map<any, any>;
16
+ constructor(options: DevTool.DevInterceptOptions);
17
+ init(options: DevTool.DevInterceptOptions): void;
18
+ /**
19
+ * app 中拦截 console
20
+ * app
21
+ * @memberof DevIntercept
22
+ */
23
+ interceptAppConsole(): void;
24
+ /**
25
+ * 拦截 vue3 信息
26
+ *
27
+ * @memberof DevIntercept
28
+ */
29
+ interceptVue3(vue3instance: any): void;
30
+ /**
31
+ * app 中捕获全局错误
32
+ *
33
+ * @memberof DevIntercept
34
+ */
35
+ interceptAppError(): void;
36
+ /**
37
+ * 拦截 app 错误
38
+ *
39
+ * @param {*} error
40
+ * @memberof DevIntercept
41
+ */
42
+ interceptErrorVue3(error: Error): void;
43
+ preWarn: any;
44
+ /**
45
+ * 拦截 app 警告
46
+ *
47
+ * @param {*} warn
48
+ * @return {*}
49
+ * @memberof DevIntercept
50
+ */
51
+ interceptWarnVue3(warn: string): void;
52
+ /**
53
+ * 拦截 promise reject
54
+ *
55
+ * @memberof DevIntercept
56
+ */
57
+ interceptPromiseReject(): void;
58
+ /**
59
+ * 拦截 nav 跳转
60
+ *
61
+ * @memberof DevIntercept
62
+ */
63
+ interceptSwitchTab(): void;
64
+ /**
65
+ * 拦截页面跳转
66
+ *
67
+ * @memberof DevIntercept
68
+ */
69
+ interceptNavigateTo(): void;
70
+ /**
71
+ * 拦截网络请求
72
+ *
73
+ * @memberof DevIntercept
74
+ */
75
+ interceptRequest(): void;
76
+ /**
77
+ * 拦截 websocket
78
+ *
79
+ * @memberof DevIntercept
80
+ */
81
+ interceptSocket(): void;
82
+ /**
83
+ * 拦截 uni.setStorageSync 和 uni.setStorage
84
+ *
85
+ * @memberof DevIntercept
86
+ */
87
+ interceptSetStorage(): void;
88
+ /**
89
+ * 拦截 uni.clearStorageSync 和 uni.clearStorage
90
+ *
91
+ * @memberof DevIntercept
92
+ */
93
+ interceptClearStorage(): void;
94
+ /**
95
+ * 拦截 uni.removeStorageSync 和 uni.removeStorage
96
+ *
97
+ * @memberof DevIntercept
98
+ */
99
+ interceptRemoveStorage(): void;
100
+ /** 拦截vuex */
101
+ interceptVuexStorage(store: any): void;
102
+ /** 拦截pinia */
103
+ interceptPiniaStore(context: any): any;
104
+ /**
105
+ * 拦截 uni.uploadFile
106
+ *
107
+ * @memberof DevIntercept
108
+ */
109
+ interceptUploadFile(): void;
110
+ interceptUniEventFactory(type: DevTool.EventCountKey): void;
111
+ interceptUniEvent(): void;
112
+ /**
113
+ * 监听截屏
114
+ *
115
+ * @memberof DevIntercept
116
+ */
117
+ interceptCaptureScreen(): void;
118
+ }
119
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../dev/devIntercept/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AASvC;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAW;IAExB,SAAS,UAAS;IAElB,QAAQ,gBAAa;IACrB,UAAU,gBAAa;IACvB,UAAU,gBAAa;IACvB,SAAS,gBAAa;gBAEV,OAAO,EAAE,OAAO,CAAC,mBAAmB;IAKhD,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,mBAAmB;IAqBzC;;;;OAIG;IACH,mBAAmB;IA8BnB;;;;OAIG;IACH,aAAa,CAAC,YAAY,EAAE,GAAG;IA2B/B;;;;OAIG;IACH,iBAAiB;IA0BjB;;;;;OAKG;IACH,kBAAkB,CAAC,KAAK,EAAE,KAAK;IAuB/B,OAAO,EAAE,GAAG,CAAC;IACb;;;;;;OAMG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM;IAgC9B;;;;OAIG;IACH,sBAAsB;IAStB;;;;OAIG;IACH,kBAAkB;IAelB;;;;OAIG;IACH,mBAAmB;IAcnB;;;;OAIG;IACH,gBAAgB;IA+DhB;;;;OAIG;IACH,eAAe;IAmKf;;;;OAIG;IACH,mBAAmB;IA8BnB;;;;OAIG;IACH,qBAAqB;IAWrB;;;;OAIG;IACH,sBAAsB;IAatB,aAAa;IACb,oBAAoB,CAAC,KAAK,EAAE,GAAG;IAQ/B,cAAc;IACd,mBAAmB,CAAC,OAAO,EAAE,GAAG;IAgBhC;;;;OAIG;IACH,mBAAmB;IAyFnB,wBAAwB,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa;IAqBpD,iBAAiB;IAQjB;;;;OAIG;IACH,sBAAsB;CAYvB"}