vite-uni-dev-tool 0.0.6 → 0.0.8
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 +16 -0
- package/dev/components/Code/index.vue +227 -0
- package/dev/components/Connection/index.vue +11 -21
- package/dev/components/ConsoleList/Code.vue +1 -1
- package/dev/components/ConsoleList/ConsoleItem.vue +38 -12
- package/dev/components/ConsoleList/RunJSInput.vue +59 -0
- package/dev/components/ConsoleList/index.vue +24 -8
- package/dev/components/DevTool/index.vue +10 -9
- package/dev/components/DevToolButton/index.vue +10 -10
- package/dev/components/DevToolTitle/index.vue +21 -0
- package/dev/components/DevToolWindow/index.vue +62 -5
- package/dev/components/FilterInput/index.vue +1 -1
- package/dev/components/JsonPretty/components/CheckController/index.vue +22 -5
- package/dev/components/JsonPretty/components/TreeNode/index.vue +16 -15
- package/dev/components/JsonPretty/index.vue +77 -75
- package/dev/components/JsonPretty/type.ts +2 -0
- package/dev/components/NetworkList/NetworkDetail.vue +1 -1
- package/dev/components/RunJS/index.vue +128 -0
- package/dev/components/SettingList/index.vue +10 -20
- package/dev/components/UniEvent/UniEventItem.vue +124 -0
- package/dev/components/UniEvent/index.vue +94 -0
- package/dev/components/UploadList/UploadDetail.vue +1 -1
- package/dev/components/VirtualList/index.vue +112 -0
- package/dev/components/WebSocket/WebSocketList.vue +1 -1
- package/dev/const.ts +101 -28
- package/dev/core.ts +12 -3
- package/dev/devConsole/index.ts +21 -4
- package/dev/devEvent/index.ts +122 -8
- package/dev/devEventBus/index.ts +94 -0
- package/dev/devIntercept/index.ts +61 -18
- package/dev/devRunJS/index.ts +170 -0
- package/dev/devStore/index.ts +83 -0
- package/dev/index.d.ts +3 -2
- package/dev/index.js +1 -1
- package/dev/plugins/uniDevTool/uniDevTool.d.ts +2 -1
- package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
- package/dev/plugins/uniDevTool/uniDevTool.js +36 -38
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +2 -1
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +1 -1
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -9
- package/dev/plugins/utils/index.d.ts +10 -2
- package/dev/plugins/utils/index.d.ts.map +1 -1
- package/dev/plugins/utils/index.js +1 -1
- package/dev/type.ts +58 -1
- package/dev/utils/index.ts +10 -1
- package/dev/utils/language.ts +53 -0
- package/dev/utils/object.ts +64 -1
- package/dev/utils/string.ts +5 -5
- package/package.json +2 -2
package/dev/type.ts
CHANGED
|
@@ -58,6 +58,8 @@ export declare namespace DevTool {
|
|
|
58
58
|
uploadMaxSize?: number;
|
|
59
59
|
/** 最大的套接字消息条数 */
|
|
60
60
|
wsDataMaxSize?: number;
|
|
61
|
+
/** 最大的时间列表条数 */
|
|
62
|
+
eventListMaxSize?: number;
|
|
61
63
|
/** 最大占用缓存空间 */
|
|
62
64
|
cacheMaxSize?: number;
|
|
63
65
|
/** 所有路由信息 */
|
|
@@ -141,12 +143,32 @@ export declare namespace DevTool {
|
|
|
141
143
|
| 'profileEnd'
|
|
142
144
|
| 'timeStamp';
|
|
143
145
|
|
|
146
|
+
type ValueType =
|
|
147
|
+
| 'number'
|
|
148
|
+
| 'string'
|
|
149
|
+
| 'boolean'
|
|
150
|
+
| 'null'
|
|
151
|
+
| 'undefined'
|
|
152
|
+
| 'symbol'
|
|
153
|
+
| 'array'
|
|
154
|
+
| 'object';
|
|
155
|
+
|
|
156
|
+
type Arg = {
|
|
157
|
+
type: ValueType;
|
|
158
|
+
value: any;
|
|
159
|
+
};
|
|
160
|
+
|
|
144
161
|
type ConsoleItem = {
|
|
145
162
|
type: string;
|
|
146
|
-
args:
|
|
163
|
+
args: Arg[];
|
|
147
164
|
position: string;
|
|
148
165
|
time: string;
|
|
149
166
|
stack?: string;
|
|
167
|
+
/**
|
|
168
|
+
* input 输入
|
|
169
|
+
* output 输出
|
|
170
|
+
*/
|
|
171
|
+
mode?: 'input' | 'output';
|
|
150
172
|
};
|
|
151
173
|
|
|
152
174
|
type UploadItem = {
|
|
@@ -175,6 +197,39 @@ export declare namespace DevTool {
|
|
|
175
197
|
totalBytesExpectedToSend?: number;
|
|
176
198
|
};
|
|
177
199
|
|
|
200
|
+
type EventCount = {
|
|
201
|
+
on: number;
|
|
202
|
+
once: number;
|
|
203
|
+
emit: number;
|
|
204
|
+
off: number;
|
|
205
|
+
};
|
|
206
|
+
type EventCountKey = keyof EventCount;
|
|
207
|
+
|
|
208
|
+
type EventItem = {
|
|
209
|
+
/** 事件名称 */
|
|
210
|
+
eventName?: string;
|
|
211
|
+
/** 触发事件 */
|
|
212
|
+
timer?: string;
|
|
213
|
+
/** 调用位置 */
|
|
214
|
+
stack?: string;
|
|
215
|
+
/** 事件类型 */
|
|
216
|
+
type?: string;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
type RunJSItem = {
|
|
220
|
+
/** 代码 */
|
|
221
|
+
code?: string;
|
|
222
|
+
/** 结果 */
|
|
223
|
+
result?: any;
|
|
224
|
+
/** 开始时间 */
|
|
225
|
+
timer?: string;
|
|
226
|
+
/** 执行用时 */
|
|
227
|
+
duration?: number;
|
|
228
|
+
/** 执行状态 */
|
|
229
|
+
type?: string;
|
|
230
|
+
mode?: 'input' | 'output';
|
|
231
|
+
};
|
|
232
|
+
|
|
178
233
|
type WindowData = {
|
|
179
234
|
devToolVisible?: boolean;
|
|
180
235
|
consoleList?: ConsoleItem[];
|
|
@@ -191,6 +246,8 @@ export declare namespace DevTool {
|
|
|
191
246
|
size?: number;
|
|
192
247
|
sizeFormat?: string;
|
|
193
248
|
uploadList?: UploadItem[];
|
|
249
|
+
eventCount?: EventCount;
|
|
250
|
+
eventList?: EventItem[];
|
|
194
251
|
};
|
|
195
252
|
|
|
196
253
|
type DevInterceptOptions = {
|
package/dev/utils/index.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {
|
|
2
|
+
isNil,
|
|
3
|
+
isBoolean,
|
|
4
|
+
isNumber,
|
|
5
|
+
isObject,
|
|
6
|
+
isArray,
|
|
7
|
+
getValueType,
|
|
8
|
+
transformValueToView,
|
|
9
|
+
} from './language';
|
|
2
10
|
export {
|
|
3
11
|
setValueByPath,
|
|
4
12
|
getValueByPath,
|
|
5
13
|
calculateObjectSize,
|
|
6
14
|
formatStorageSize,
|
|
7
15
|
serializeCircular,
|
|
16
|
+
parseValue,
|
|
8
17
|
} from './object';
|
|
9
18
|
|
|
10
19
|
export { throttle, debounce } from './function';
|
package/dev/utils/language.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DevTool } from '../type';
|
|
1
2
|
export function isNil(value: any): value is null | undefined {
|
|
2
3
|
return value === null || value === undefined;
|
|
3
4
|
}
|
|
@@ -17,3 +18,55 @@ export function isObject(value: any): value is object {
|
|
|
17
18
|
export function isArray(value: any): value is any[] {
|
|
18
19
|
return Array.isArray(value);
|
|
19
20
|
}
|
|
21
|
+
|
|
22
|
+
export function isString(value: any): value is string {
|
|
23
|
+
return typeof value === 'string';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function isNull(value: any): value is null {
|
|
27
|
+
return value === null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function isUndefined(value: any): value is undefined {
|
|
31
|
+
return value === undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function isSymbol(value: any): value is symbol {
|
|
35
|
+
return typeof value === 'symbol';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
*
|
|
41
|
+
* @export
|
|
42
|
+
* @param {*} value
|
|
43
|
+
* @return {*} {DevTool.ValueType}
|
|
44
|
+
*/
|
|
45
|
+
export function getValueType(value: any): DevTool.ValueType {
|
|
46
|
+
if (isNull(value)) return 'null';
|
|
47
|
+
if (isUndefined(value)) return 'undefined';
|
|
48
|
+
if (isNumber(value)) return 'number';
|
|
49
|
+
if (isString(value)) return 'string';
|
|
50
|
+
if (isArray(value)) return 'array';
|
|
51
|
+
if (isObject(value)) return 'object';
|
|
52
|
+
if (isSymbol(value)) return 'symbol';
|
|
53
|
+
return 'string';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 将 console 入参转vue 可视值
|
|
58
|
+
*
|
|
59
|
+
* @export
|
|
60
|
+
* @param {*} value
|
|
61
|
+
* @return {*} {DevTool.ValueType}
|
|
62
|
+
*/
|
|
63
|
+
export function transformValueToView(value: any): DevTool.ValueType {
|
|
64
|
+
if (isNull(value)) return 'string';
|
|
65
|
+
if (isUndefined(value)) return 'string';
|
|
66
|
+
if (isString(value)) return 'string';
|
|
67
|
+
if (isNumber(value)) return 'number';
|
|
68
|
+
if (isArray(value)) return 'array';
|
|
69
|
+
if (isObject(value)) return 'object';
|
|
70
|
+
if (isSymbol(value)) return 'symbol';
|
|
71
|
+
return 'string';
|
|
72
|
+
}
|
package/dev/utils/object.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isNil, isObject, isString } from './language';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* 自定义set函数 - 安全地设置嵌套对象属性
|
|
3
5
|
* @param obj 目标对象
|
|
@@ -66,6 +68,7 @@ export function getValueByPath(obj: any, path: string, defaultValue?: any) {
|
|
|
66
68
|
* @returns 对象的近似大小(以字节为单位)
|
|
67
69
|
*/
|
|
68
70
|
export function calculateObjectSize(obj: any): number {
|
|
71
|
+
obj = parseValue(obj);
|
|
69
72
|
// 处理基本类型
|
|
70
73
|
if (obj === null || obj === undefined) {
|
|
71
74
|
return 0;
|
|
@@ -118,7 +121,7 @@ export function calculateObjectSize(obj: any): number {
|
|
|
118
121
|
} else {
|
|
119
122
|
// 计算对象每个属性的大小
|
|
120
123
|
for (const key in obj) {
|
|
121
|
-
if (obj
|
|
124
|
+
if (obj?.hasOwnProperty?.(key)) {
|
|
122
125
|
// 属性名的大小(假设每个字符占2字节)
|
|
123
126
|
totalSize += key.length * 2;
|
|
124
127
|
// 属性引用(假设每个引用占8字节)
|
|
@@ -233,3 +236,63 @@ export function serializeCircular(
|
|
|
233
236
|
|
|
234
237
|
return `{${serializedProps.join(', ')}}`;
|
|
235
238
|
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* 处理value
|
|
242
|
+
* 基础类型数据直接返回value
|
|
243
|
+
* 引用类型数据判断 value 是否存在循环引用的情况,存在则将循环引用的第二次赋值为 [Circular]
|
|
244
|
+
* 最大处理 deep 层数
|
|
245
|
+
*
|
|
246
|
+
* @export
|
|
247
|
+
* @param {*} value
|
|
248
|
+
* @param {number} [deep=6]
|
|
249
|
+
*/
|
|
250
|
+
export function parseValue(value: any, deep: number = 6) {
|
|
251
|
+
const seen = new WeakMap<object, string[]>(); // 存储对象及其路径
|
|
252
|
+
|
|
253
|
+
function process(value: any, currentDeep: number, path: string[] = []): any {
|
|
254
|
+
if (isString(value)) {
|
|
255
|
+
return `"${value}"`;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (isNil(value)) {
|
|
259
|
+
return `${value}`;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// 处理基本类型
|
|
263
|
+
if (!isObject(value)) {
|
|
264
|
+
return value;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// 检查是否达到最大深度
|
|
268
|
+
if (currentDeep <= 0) {
|
|
269
|
+
return '[MaxDepth]';
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// 检查循环引用
|
|
273
|
+
if (seen.has(value)) {
|
|
274
|
+
const circularPath = seen.get(value)!.join('.');
|
|
275
|
+
return `[Circular: ${circularPath}]`;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// 标记当前对象为已访问,并记录路径
|
|
279
|
+
seen.set(value, [...path]);
|
|
280
|
+
|
|
281
|
+
// 处理数组
|
|
282
|
+
if (Array.isArray(value)) {
|
|
283
|
+
return value.map((item, index) =>
|
|
284
|
+
process(item, currentDeep - 1, [...path, String(index)]),
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// 处理对象
|
|
289
|
+
const result: Record<string, any> = {};
|
|
290
|
+
for (const [key, val] of Object.entries(value)) {
|
|
291
|
+
result[key] = process(val, currentDeep - 1, [...path, key]);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return result;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return process(value, deep);
|
|
298
|
+
}
|
package/dev/utils/string.ts
CHANGED
|
@@ -102,11 +102,11 @@ const stockReg =
|
|
|
102
102
|
* 解析栈信息
|
|
103
103
|
*
|
|
104
104
|
* @export
|
|
105
|
-
* @param {string}
|
|
105
|
+
* @param {string} stack
|
|
106
106
|
* @return {*}
|
|
107
107
|
*/
|
|
108
|
-
export function parseStock(
|
|
109
|
-
const match =
|
|
108
|
+
export function parseStock(stack: string) {
|
|
109
|
+
const match = stack.match(stockReg);
|
|
110
110
|
return {
|
|
111
111
|
info: match?.[1] ?? '',
|
|
112
112
|
path: match?.[2] ?? '',
|
|
@@ -116,6 +116,6 @@ export function parseStock(stock: string) {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
const mockWXReg = /https?:\/\/usr/;
|
|
119
|
-
export function isMockWX(
|
|
120
|
-
return mockWXReg.test(
|
|
119
|
+
export function isMockWX(stack: string) {
|
|
120
|
+
return mockWXReg.test(stack);
|
|
121
121
|
}
|
package/package.json
CHANGED