vite-uni-dev-tool 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +120 -0
- package/dev/components/Button/index.vue +34 -0
- package/dev/components/Checkbox/index.vue +40 -0
- package/dev/components/CloseButton/index.vue +25 -0
- package/dev/components/Connection/index.vue +98 -0
- package/dev/components/ConsoleList/ConsoleItem.vue +89 -0
- package/dev/components/ConsoleList/index.vue +98 -0
- package/dev/components/DevTool/index.vue +165 -0
- package/dev/components/DevToolButton/index.vue +213 -0
- package/dev/components/DevToolWindow/index.vue +847 -0
- package/dev/components/DeviceInfo/index.vue +32 -0
- package/dev/components/Empty/empty.png +0 -0
- package/dev/components/Empty/index.vue +28 -0
- package/dev/components/FilterInput/index.vue +86 -0
- package/dev/components/JsonPretty/components/Brackets/index.vue +23 -0
- package/dev/components/JsonPretty/components/Carets/index.vue +63 -0
- package/dev/components/JsonPretty/components/CheckController/index.vue +108 -0
- package/dev/components/JsonPretty/components/TreeNode/index.vue +348 -0
- package/dev/components/JsonPretty/hooks/useClipboard.ts +21 -0
- package/dev/components/JsonPretty/hooks/useError.ts +21 -0
- package/dev/components/JsonPretty/index.vue +463 -0
- package/dev/components/JsonPretty/type.ts +123 -0
- package/dev/components/JsonPretty/utils/index.ts +172 -0
- package/dev/components/NetworkList/NetworkDetail.vue +197 -0
- package/dev/components/NetworkList/NetworkItem.vue +106 -0
- package/dev/components/NetworkList/index.vue +108 -0
- package/dev/components/PiniaList/index.vue +64 -0
- package/dev/components/RouteList/index.vue +98 -0
- package/dev/components/SettingList/index.vue +235 -0
- package/dev/components/StorageList/index.vue +170 -0
- package/dev/components/SystemInfo/index.vue +34 -0
- package/dev/components/Tabs/index.vue +110 -0
- package/dev/components/Tag/index.vue +89 -0
- package/dev/components/UploadList/UploadDetail.vue +208 -0
- package/dev/components/UploadList/UploadItem.vue +111 -0
- package/dev/components/UploadList/index.vue +94 -0
- package/dev/components/VuexList/index.vue +54 -0
- package/dev/components/WebSocket/WebSocketItem.vue +98 -0
- package/dev/components/WebSocket/WebSocketList.vue +176 -0
- package/dev/components/WebSocket/index.vue +99 -0
- package/dev/components/WindowInfo/index.vue +33 -0
- package/dev/const.ts +95 -0
- package/dev/core.ts +103 -0
- package/dev/devConsole/index.ts +334 -0
- package/dev/devEvent/index.ts +665 -0
- package/dev/devIntercept/index.ts +629 -0
- package/dev/devStore/index.ts +581 -0
- package/dev/index.d.ts +6 -0
- package/dev/index.d.ts.map +1 -0
- package/dev/index.js +1 -0
- package/dev/plugins/uniDevTool/uniDevTool.d.ts +66 -0
- package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
- package/dev/plugins/uniDevTool/uniDevTool.js +13 -0
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +28 -0
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +1 -0
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.js +5 -0
- package/dev/shims-uni.d.ts +43 -0
- package/dev/type.ts +188 -0
- package/dev/utils/date.ts +75 -0
- package/dev/utils/file.ts +121 -0
- package/dev/utils/function.ts +192 -0
- package/dev/utils/index.ts +25 -0
- package/dev/utils/ip.ts +79 -0
- package/dev/utils/language.ts +19 -0
- package/dev/utils/object.ts +235 -0
- package/dev/utils/page.ts +13 -0
- package/dev/utils/string.ts +23 -0
- package/dev/utils/utils.ts +198 -0
- package/package.json +34 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { DevEvent } from '../devEvent';
|
|
2
|
+
import type { DevTool } from '../type';
|
|
3
|
+
import {
|
|
4
|
+
getCurrentDate,
|
|
5
|
+
getCurrentPagePath,
|
|
6
|
+
isArray,
|
|
7
|
+
serializeCircular,
|
|
8
|
+
} from '../utils/index';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* DevTool 包装之后的 console 类
|
|
12
|
+
*
|
|
13
|
+
* 用于记录 console 日志
|
|
14
|
+
*
|
|
15
|
+
* 覆盖 console 将会导致难以预料的事情发生,因此不建议覆盖 console
|
|
16
|
+
*
|
|
17
|
+
* @export
|
|
18
|
+
* @class DevConsole
|
|
19
|
+
*/
|
|
20
|
+
export class DevConsole {
|
|
21
|
+
event: DevEvent;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 时间戳记录
|
|
25
|
+
*
|
|
26
|
+
* @memberof DevConsole
|
|
27
|
+
*/
|
|
28
|
+
timeMap = new Map<string, number>();
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 计数器记录
|
|
32
|
+
*
|
|
33
|
+
* @memberof DevConsole
|
|
34
|
+
*/
|
|
35
|
+
countMap = new Map<string, number>();
|
|
36
|
+
|
|
37
|
+
constructor(event: DevEvent) {
|
|
38
|
+
this.event = event;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 包装之后的 console 方法
|
|
43
|
+
*
|
|
44
|
+
* @param {DevTool.ConsoleType} type
|
|
45
|
+
* @param {any[]} args
|
|
46
|
+
* @memberof DevConsole
|
|
47
|
+
*/
|
|
48
|
+
factory(type: DevTool.ConsoleType, args: any[]) {
|
|
49
|
+
console[type](...args);
|
|
50
|
+
|
|
51
|
+
const isDestroy = this.event.getDevToolDestroy();
|
|
52
|
+
|
|
53
|
+
if (isDestroy) return;
|
|
54
|
+
|
|
55
|
+
const position = getCurrentPagePath();
|
|
56
|
+
const time = getCurrentDate();
|
|
57
|
+
// 获取调用栈(从第4行开始,跳过 console.log 和 wrapper 函数)
|
|
58
|
+
const stackList = new Error()?.stack?.split('\n');
|
|
59
|
+
|
|
60
|
+
const stack = stackList?.slice(3)?.[0];
|
|
61
|
+
|
|
62
|
+
let argList = args?.map((item) => serializeCircular(item));
|
|
63
|
+
|
|
64
|
+
if (isArray(args) && args.length > 0) {
|
|
65
|
+
this.event.updateConsoleList([
|
|
66
|
+
{
|
|
67
|
+
type,
|
|
68
|
+
position,
|
|
69
|
+
time,
|
|
70
|
+
args: argList,
|
|
71
|
+
stack,
|
|
72
|
+
},
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* DevTool 包装之后的 console.log 方法
|
|
79
|
+
*
|
|
80
|
+
* @param {...any[]} args
|
|
81
|
+
* @memberof DevConsole
|
|
82
|
+
*/
|
|
83
|
+
log(...args: any[]) {
|
|
84
|
+
this.factory('log', args);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* DevTool 包装之后的 console.info 方法
|
|
89
|
+
*
|
|
90
|
+
* @param {...any[]} args
|
|
91
|
+
* @memberof DevConsole
|
|
92
|
+
*/
|
|
93
|
+
info(...args: any[]) {
|
|
94
|
+
this.factory('info', args);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* DevTool 包装之后的 console.warn 方法
|
|
99
|
+
*
|
|
100
|
+
* @param {...any[]} args
|
|
101
|
+
* @memberof DevConsole
|
|
102
|
+
*/
|
|
103
|
+
warn(...args: any[]) {
|
|
104
|
+
this.factory('warn', args);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* DevTool 包装之后的 console.error 方法
|
|
109
|
+
*
|
|
110
|
+
* @param {...any[]} args
|
|
111
|
+
* @memberof DevConsole
|
|
112
|
+
*/
|
|
113
|
+
error(...args: any[]) {
|
|
114
|
+
this.factory('error', args);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* DevTool 包装之后的 console.time 方法
|
|
119
|
+
*
|
|
120
|
+
* @param {string} label
|
|
121
|
+
* @memberof DevConsole
|
|
122
|
+
*/
|
|
123
|
+
time(label: string) {
|
|
124
|
+
console.time(label);
|
|
125
|
+
this.timeMap.set(label, Date.now());
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* DevTool 包装之后的 console.timeEnd 方法
|
|
130
|
+
*
|
|
131
|
+
* @param {string} label
|
|
132
|
+
* @memberof DevConsole
|
|
133
|
+
*/
|
|
134
|
+
timeEnd(label: string) {
|
|
135
|
+
this.factory('timeEnd', [label]);
|
|
136
|
+
|
|
137
|
+
const isDestroy = this.event.getDevToolDestroy();
|
|
138
|
+
|
|
139
|
+
if (isDestroy) return;
|
|
140
|
+
|
|
141
|
+
const position = getCurrentPagePath();
|
|
142
|
+
const time = getCurrentDate();
|
|
143
|
+
// 获取调用栈(从第4行开始,跳过 console.log 和 wrapper 函数)
|
|
144
|
+
const stackList = new Error()?.stack?.split('\n');
|
|
145
|
+
|
|
146
|
+
const stack = stackList?.slice(3)?.[0];
|
|
147
|
+
|
|
148
|
+
const startTime = this.timeMap.get(label);
|
|
149
|
+
|
|
150
|
+
if (startTime) {
|
|
151
|
+
const duration = Date.now() - startTime;
|
|
152
|
+
this.event.updateConsoleList([
|
|
153
|
+
{
|
|
154
|
+
type: 'log',
|
|
155
|
+
position,
|
|
156
|
+
time,
|
|
157
|
+
args: [`${label ?? '[DevTool timeEnd error]'}: ${duration}ms`],
|
|
158
|
+
stack,
|
|
159
|
+
},
|
|
160
|
+
]);
|
|
161
|
+
}
|
|
162
|
+
this.timeMap.delete(label);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* DevTool 包装之后的 console.clear 方法
|
|
167
|
+
*
|
|
168
|
+
* @memberof DevConsole
|
|
169
|
+
*/
|
|
170
|
+
clear() {
|
|
171
|
+
this.factory('clear', []);
|
|
172
|
+
this.event.updateConsoleList([]);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* DevTool 包装之后的 console.count 方法
|
|
177
|
+
*
|
|
178
|
+
* @param {string} [label='']
|
|
179
|
+
* @memberof DevConsole
|
|
180
|
+
*/
|
|
181
|
+
count(label: string = '') {
|
|
182
|
+
this.factory('count', [label]);
|
|
183
|
+
|
|
184
|
+
const isDestroy = this.event.getDevToolDestroy();
|
|
185
|
+
|
|
186
|
+
if (isDestroy) return;
|
|
187
|
+
|
|
188
|
+
this.countMap.set(label, (this.countMap.get(label) || 0) + 1);
|
|
189
|
+
|
|
190
|
+
// 获取调用栈(从第4行开始,跳过 console.log 和 wrapper 函数)
|
|
191
|
+
const stackList = new Error()?.stack?.split('\n');
|
|
192
|
+
|
|
193
|
+
const stack = stackList?.slice(3)?.[0];
|
|
194
|
+
|
|
195
|
+
this.event.updateConsoleList([
|
|
196
|
+
{
|
|
197
|
+
type: 'log',
|
|
198
|
+
position: getCurrentPagePath(),
|
|
199
|
+
time: getCurrentDate(),
|
|
200
|
+
args: [`${label}: ${this.countMap.get(label)}`],
|
|
201
|
+
stack,
|
|
202
|
+
},
|
|
203
|
+
]);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* DevTool 包装之后的 console.countReset 方法
|
|
208
|
+
*
|
|
209
|
+
* @param {string} [label='']
|
|
210
|
+
* @memberof DevConsole
|
|
211
|
+
*/
|
|
212
|
+
countReset(label: string = '') {
|
|
213
|
+
this.countMap.delete(label);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* 原始 console.assert 方法
|
|
218
|
+
*
|
|
219
|
+
* @param {...any[]} args
|
|
220
|
+
* @memberof DevConsole
|
|
221
|
+
*/
|
|
222
|
+
assert(...args: any[]) {
|
|
223
|
+
console.assert(...args);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* 原始 console.debug 方法
|
|
228
|
+
*
|
|
229
|
+
* @param {...any[]} args
|
|
230
|
+
* @memberof DevConsole
|
|
231
|
+
*/
|
|
232
|
+
debug(...args: any[]) {
|
|
233
|
+
console.debug(...args);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* 原始 console.dir 方法
|
|
238
|
+
*
|
|
239
|
+
* @param {...any[]} args
|
|
240
|
+
* @memberof DevConsole
|
|
241
|
+
*/
|
|
242
|
+
dir(...args: any[]) {
|
|
243
|
+
console.dir(...args);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* 原始 console.dirxml 方法
|
|
248
|
+
*
|
|
249
|
+
* @param {...any[]} args
|
|
250
|
+
* @memberof DevConsole
|
|
251
|
+
*/
|
|
252
|
+
dirxml(...args: any[]) {
|
|
253
|
+
console.dirxml(...args);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* 原始 console.group 方法
|
|
258
|
+
*
|
|
259
|
+
* @param {...any[]} args
|
|
260
|
+
* @memberof DevConsole
|
|
261
|
+
*/
|
|
262
|
+
group(...args: any[]) {
|
|
263
|
+
console.group(args);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* 原始 console.groupCollapsed 方法
|
|
268
|
+
*
|
|
269
|
+
* @param {...any[]} args
|
|
270
|
+
* @memberof DevConsole
|
|
271
|
+
*/
|
|
272
|
+
groupCollapsed(...args: any[]) {
|
|
273
|
+
console.groupCollapsed(...args);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* 原始 console.groupEnd 方法
|
|
278
|
+
*
|
|
279
|
+
* @memberof DevConsole
|
|
280
|
+
*/
|
|
281
|
+
groupEnd() {
|
|
282
|
+
console.groupEnd();
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* 原始 console.table 方法
|
|
287
|
+
*
|
|
288
|
+
* @param {...any[]} args
|
|
289
|
+
* @memberof DevConsole
|
|
290
|
+
*/
|
|
291
|
+
table(...args: any[]) {
|
|
292
|
+
console.table(...args);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* 原始 console.timeStamp 方法
|
|
297
|
+
*
|
|
298
|
+
* @param {...any[]} args
|
|
299
|
+
* @memberof DevConsole
|
|
300
|
+
*/
|
|
301
|
+
timeStamp(...args: any[]) {
|
|
302
|
+
console.timeStamp(...args);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* 原始 console.profile 方法
|
|
307
|
+
*
|
|
308
|
+
* @param {...any[]} args
|
|
309
|
+
* @memberof DevConsole
|
|
310
|
+
*/
|
|
311
|
+
trace(...args: any[]) {
|
|
312
|
+
console?.trace?.(...args);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* 原始 console.profile 方法
|
|
317
|
+
*
|
|
318
|
+
* @param {string} label
|
|
319
|
+
* @memberof DevConsole
|
|
320
|
+
*/
|
|
321
|
+
// profile(label?: string) {
|
|
322
|
+
// console?.profile?.(label);
|
|
323
|
+
// }
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* 原始 console.profileEnd 方法
|
|
327
|
+
*
|
|
328
|
+
* @param {string} [label]
|
|
329
|
+
* @memberof DevConsole
|
|
330
|
+
*/
|
|
331
|
+
// profileEnd(label?: string) {
|
|
332
|
+
// console?.profileEnd?.(label);
|
|
333
|
+
// }
|
|
334
|
+
}
|