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
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
escapeHTML,
|
|
6
6
|
getCurrentDate,
|
|
7
7
|
getCurrentPagePath,
|
|
8
|
-
|
|
8
|
+
parseValue,
|
|
9
9
|
} from '../utils/index';
|
|
10
|
-
import {
|
|
10
|
+
import { transformValueToView } from '../utils/language';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* 拦截器
|
|
@@ -20,6 +20,11 @@ export class DevIntercept {
|
|
|
20
20
|
|
|
21
21
|
initPinia = false;
|
|
22
22
|
|
|
23
|
+
cache$on = new Map();
|
|
24
|
+
cache$once = new Map();
|
|
25
|
+
cache$emit = new Map();
|
|
26
|
+
cache$off = new Map();
|
|
27
|
+
|
|
23
28
|
constructor(options: DevTool.DevInterceptOptions) {
|
|
24
29
|
this.event = options.event;
|
|
25
30
|
this.init(options);
|
|
@@ -41,6 +46,8 @@ export class DevIntercept {
|
|
|
41
46
|
this.interceptSwitchTab();
|
|
42
47
|
this.interceptNavigateTo();
|
|
43
48
|
|
|
49
|
+
this.interceptUniEvent();
|
|
50
|
+
|
|
44
51
|
options.enableInterceptPromiseReject && this.interceptPromiseReject();
|
|
45
52
|
}
|
|
46
53
|
|
|
@@ -67,19 +74,11 @@ export class DevIntercept {
|
|
|
67
74
|
position: path,
|
|
68
75
|
time: getCurrentDate(),
|
|
69
76
|
args: args.map((item: any) => {
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
item === undefined ||
|
|
76
|
-
isNaN(item) ||
|
|
77
|
-
item === Infinity
|
|
78
|
-
) {
|
|
79
|
-
return item + '';
|
|
80
|
-
} else {
|
|
81
|
-
return item;
|
|
82
|
-
}
|
|
77
|
+
// 处理 item 循环引用的问题
|
|
78
|
+
return {
|
|
79
|
+
type: transformValueToView(item),
|
|
80
|
+
value: parseValue(item),
|
|
81
|
+
};
|
|
83
82
|
}),
|
|
84
83
|
stack: line,
|
|
85
84
|
},
|
|
@@ -136,7 +135,12 @@ export class DevIntercept {
|
|
|
136
135
|
this.event.updateConsoleList([
|
|
137
136
|
{
|
|
138
137
|
type: 'error',
|
|
139
|
-
args: [
|
|
138
|
+
args: [
|
|
139
|
+
{
|
|
140
|
+
type: 'string',
|
|
141
|
+
value: info,
|
|
142
|
+
},
|
|
143
|
+
],
|
|
140
144
|
position: getCurrentPagePath(),
|
|
141
145
|
time: getCurrentDate(),
|
|
142
146
|
stack,
|
|
@@ -161,7 +165,12 @@ export class DevIntercept {
|
|
|
161
165
|
this.event.updateConsoleList([
|
|
162
166
|
{
|
|
163
167
|
type: 'error',
|
|
164
|
-
args: [
|
|
168
|
+
args: [
|
|
169
|
+
{
|
|
170
|
+
type: 'string',
|
|
171
|
+
value: error.toString(),
|
|
172
|
+
},
|
|
173
|
+
],
|
|
165
174
|
position: getCurrentPagePath(),
|
|
166
175
|
time: getCurrentDate(),
|
|
167
176
|
stack,
|
|
@@ -196,7 +205,12 @@ export class DevIntercept {
|
|
|
196
205
|
this.event.updateConsoleList([
|
|
197
206
|
{
|
|
198
207
|
type: 'warn',
|
|
199
|
-
args: [
|
|
208
|
+
args: [
|
|
209
|
+
{
|
|
210
|
+
type: 'string',
|
|
211
|
+
value: args,
|
|
212
|
+
},
|
|
213
|
+
],
|
|
200
214
|
position: path,
|
|
201
215
|
time: getCurrentDate(),
|
|
202
216
|
stack,
|
|
@@ -681,4 +695,33 @@ export class DevIntercept {
|
|
|
681
695
|
};
|
|
682
696
|
uni.uploadFile = uploadFile.bind(uni);
|
|
683
697
|
}
|
|
698
|
+
|
|
699
|
+
interceptUniEventFactory(type: DevTool.EventCountKey) {
|
|
700
|
+
const key = `$${type}` as '$on' | '$emit' | '$once' | '$off';
|
|
701
|
+
|
|
702
|
+
uni[`$${type}`] = (eventName: string, callback: (result: any) => void) => {
|
|
703
|
+
const stockList = new Error()?.stack?.split('\n');
|
|
704
|
+
const stack = stockList?.[2];
|
|
705
|
+
backup?.[key]?.(eventName, callback);
|
|
706
|
+
|
|
707
|
+
this.event.updateUniEventList([
|
|
708
|
+
{
|
|
709
|
+
eventName,
|
|
710
|
+
timer: getCurrentDate(),
|
|
711
|
+
stack,
|
|
712
|
+
type,
|
|
713
|
+
},
|
|
714
|
+
]);
|
|
715
|
+
|
|
716
|
+
this.event.updateUniEventCount(type);
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
interceptUniEvent() {
|
|
721
|
+
// 判断是否是相同的位置注册,相同的位置注册只算一次
|
|
722
|
+
this.interceptUniEventFactory('on');
|
|
723
|
+
this.interceptUniEventFactory('once');
|
|
724
|
+
this.interceptUniEventFactory('emit');
|
|
725
|
+
this.interceptUniEventFactory('off');
|
|
726
|
+
}
|
|
684
727
|
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import type { DevConsole } from '../devConsole';
|
|
2
|
+
|
|
3
|
+
type SandboxOptions = {
|
|
4
|
+
console: DevConsole;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export class DevRunJS {
|
|
8
|
+
private context: Record<string, any> = {};
|
|
9
|
+
|
|
10
|
+
private isDestroyed = false;
|
|
11
|
+
|
|
12
|
+
constructor(options: SandboxOptions) {
|
|
13
|
+
this.createContext(options.console);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 创建context
|
|
18
|
+
*
|
|
19
|
+
* @private
|
|
20
|
+
* @param {DevConsole} [console]
|
|
21
|
+
* @memberof DevRunJs
|
|
22
|
+
*/
|
|
23
|
+
createContext(console?: DevConsole): void {
|
|
24
|
+
// 基础全局对象
|
|
25
|
+
this.context.Math = Math;
|
|
26
|
+
this.context.Date = Date;
|
|
27
|
+
this.context.Array = Array;
|
|
28
|
+
this.context.Object = Object;
|
|
29
|
+
this.context.String = String;
|
|
30
|
+
this.context.Number = Number;
|
|
31
|
+
this.context.Boolean = Boolean;
|
|
32
|
+
|
|
33
|
+
// 这里是为了给运行环境添加调用入口
|
|
34
|
+
this.context.console = console;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 估算对象大小(简化版)
|
|
38
|
+
estimateObjectSize(obj: any): number {
|
|
39
|
+
if (obj === null) return 0;
|
|
40
|
+
|
|
41
|
+
const seen = new Set();
|
|
42
|
+
let bytes = 0;
|
|
43
|
+
|
|
44
|
+
const sizeOf = (o: any): number => {
|
|
45
|
+
if (seen.has(o)) return 0;
|
|
46
|
+
seen.add(o);
|
|
47
|
+
|
|
48
|
+
if (typeof o === 'boolean') return 4;
|
|
49
|
+
if (typeof o === 'number') return 8;
|
|
50
|
+
if (typeof o === 'string') return o.length * 2;
|
|
51
|
+
if (typeof o === 'function') return 0; // 函数大小不计
|
|
52
|
+
|
|
53
|
+
if (Array.isArray(o)) {
|
|
54
|
+
return o.reduce((sum, item) => sum + sizeOf(item), 0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (typeof o === 'object') {
|
|
58
|
+
return Object.keys(o).reduce((sum, key) => sum + sizeOf(o[key]), 0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return 0;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return sizeOf(obj) / (1024 * 1024); // 转换为 MB
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 注入外部变量,方法
|
|
69
|
+
*
|
|
70
|
+
* @param {string} name
|
|
71
|
+
* @param {*} value
|
|
72
|
+
* @return {*} {this}
|
|
73
|
+
* @memberof DevRunJs
|
|
74
|
+
*/
|
|
75
|
+
setVariable(name: string, value: any): this {
|
|
76
|
+
if (this.isDestroyed) {
|
|
77
|
+
throw new Error('[DevTool] DevRunJS 已经被销毁');
|
|
78
|
+
}
|
|
79
|
+
this.context[name] = value;
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 批量注入
|
|
85
|
+
*
|
|
86
|
+
* @param {Record<string, any>} variables
|
|
87
|
+
* @return {*} {this}
|
|
88
|
+
* @memberof DevRunJs
|
|
89
|
+
*/
|
|
90
|
+
setVariables(variables: Record<string, any>): this {
|
|
91
|
+
if (this.isDestroyed) {
|
|
92
|
+
throw new Error('[DevTool] DevRunJS 已经被销毁');
|
|
93
|
+
}
|
|
94
|
+
Object.assign(this.context, variables);
|
|
95
|
+
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
*
|
|
101
|
+
* TODO
|
|
102
|
+
* code 中存在 var, let, const, function 等关键字定义的变量或方法时,应该存入 context 中,允许下一次运行 js 调用
|
|
103
|
+
* 局部定义的不加入 context
|
|
104
|
+
*
|
|
105
|
+
* @memberof DevRunJs
|
|
106
|
+
*/
|
|
107
|
+
matchingGlobalVarAndFunc(code: string) {}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* TODO
|
|
111
|
+
* 清空客户端注入的context
|
|
112
|
+
*/
|
|
113
|
+
clearGlobalVarAndFunc() {}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 执行 code
|
|
117
|
+
*
|
|
118
|
+
* @param {string} code
|
|
119
|
+
* @return {*} {Promise<any>}
|
|
120
|
+
* @memberof DevRunJs
|
|
121
|
+
*/
|
|
122
|
+
execute(code: string): Promise<any> {
|
|
123
|
+
if (this.isDestroyed) {
|
|
124
|
+
return Promise.reject(new Error('[DevTool] DevRunJS 已经被销毁'));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
// 创建执行环境
|
|
129
|
+
const wrapper = new Function(
|
|
130
|
+
'context',
|
|
131
|
+
`
|
|
132
|
+
// 'use strict';
|
|
133
|
+
with (context) {
|
|
134
|
+
return (function() {
|
|
135
|
+
try {
|
|
136
|
+
${code}
|
|
137
|
+
} catch (e) {
|
|
138
|
+
return e;
|
|
139
|
+
}
|
|
140
|
+
})();
|
|
141
|
+
}
|
|
142
|
+
`,
|
|
143
|
+
);
|
|
144
|
+
return Promise.resolve(wrapper(this.context));
|
|
145
|
+
} catch (error) {
|
|
146
|
+
return Promise.reject(
|
|
147
|
+
new Error(`[DevTool] DevRunJS 执行错误: ${(error as Error).message}`),
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 销毁
|
|
154
|
+
*
|
|
155
|
+
* @return {*} {void}
|
|
156
|
+
* @memberof DevRunJs
|
|
157
|
+
*/
|
|
158
|
+
destroy(): void {
|
|
159
|
+
if (this.isDestroyed) return;
|
|
160
|
+
|
|
161
|
+
// 清除上下文
|
|
162
|
+
for (const key in this.context) {
|
|
163
|
+
delete this.context[key];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// 释放资源
|
|
167
|
+
this.context = {};
|
|
168
|
+
this.isDestroyed = true;
|
|
169
|
+
}
|
|
170
|
+
}
|
package/dev/devStore/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
getWifiIp,
|
|
12
12
|
isBoolean,
|
|
13
13
|
} from '../utils/index';
|
|
14
|
+
import { backup } from '../core';
|
|
14
15
|
|
|
15
16
|
/** 数据存储中心 */
|
|
16
17
|
export class DevStore {
|
|
@@ -28,6 +29,13 @@ export class DevStore {
|
|
|
28
29
|
wsList: [],
|
|
29
30
|
netWorkStatus: {},
|
|
30
31
|
uploadList: [],
|
|
32
|
+
eventList: [],
|
|
33
|
+
eventCount: {
|
|
34
|
+
on: 0,
|
|
35
|
+
once: 0,
|
|
36
|
+
emit: 0,
|
|
37
|
+
off: 0,
|
|
38
|
+
},
|
|
31
39
|
};
|
|
32
40
|
|
|
33
41
|
/** 调试配置 */
|
|
@@ -40,6 +48,11 @@ export class DevStore {
|
|
|
40
48
|
private networkMaxSize = 1000;
|
|
41
49
|
/** ws数据最大值 */
|
|
42
50
|
private wsDataMaxSize = 1000;
|
|
51
|
+
/** 事件列表最大值 */
|
|
52
|
+
private eventListMaxSize = 1000;
|
|
53
|
+
/** js 最大运行条数 */
|
|
54
|
+
private runJsMaxSize = 1000;
|
|
55
|
+
|
|
43
56
|
/** 缓存最大值 */
|
|
44
57
|
cacheMaxSize = 8 * 1024 * 1024 * 10;
|
|
45
58
|
|
|
@@ -79,6 +92,7 @@ export class DevStore {
|
|
|
79
92
|
setWindowInfo(windowInfo: Record<string, any>) {
|
|
80
93
|
this.state.windowInfo = windowInfo;
|
|
81
94
|
}
|
|
95
|
+
|
|
82
96
|
setDeviceInfo(deviceInfo: Record<string, any>) {
|
|
83
97
|
this.state.deviceInfo = deviceInfo;
|
|
84
98
|
}
|
|
@@ -131,6 +145,7 @@ export class DevStore {
|
|
|
131
145
|
this.networkMaxSize = options.networkMaxSize || 1000;
|
|
132
146
|
this.wsDataMaxSize = options.wsDataMaxSize || 1000;
|
|
133
147
|
this.cacheMaxSize = options.cacheMaxSize || 8 * 1024 * 1024 * 10;
|
|
148
|
+
this.eventListMaxSize = options.eventListMaxSize || 1000;
|
|
134
149
|
|
|
135
150
|
const devToolVisible = uni.getStorageSync(EVENT_DEV_BUTTON);
|
|
136
151
|
this.devToolVisible = isBoolean(devToolVisible)
|
|
@@ -299,6 +314,13 @@ export class DevStore {
|
|
|
299
314
|
this.state.networkList = [];
|
|
300
315
|
this.state.wsList = [];
|
|
301
316
|
this.state.uploadList = [];
|
|
317
|
+
this.state.eventList = [];
|
|
318
|
+
this.state.eventCount = {
|
|
319
|
+
on: 0,
|
|
320
|
+
once: 0,
|
|
321
|
+
emit: 0,
|
|
322
|
+
off: 0,
|
|
323
|
+
};
|
|
302
324
|
}
|
|
303
325
|
|
|
304
326
|
clearAll() {
|
|
@@ -314,6 +336,14 @@ export class DevStore {
|
|
|
314
336
|
this.state.windowInfo = {};
|
|
315
337
|
this.state.systemInfo = {};
|
|
316
338
|
this.state.netWorkStatus = {};
|
|
339
|
+
|
|
340
|
+
this.state.eventList = [];
|
|
341
|
+
this.state.eventCount = {
|
|
342
|
+
on: 0,
|
|
343
|
+
once: 0,
|
|
344
|
+
emit: 0,
|
|
345
|
+
off: 0,
|
|
346
|
+
};
|
|
317
347
|
}
|
|
318
348
|
|
|
319
349
|
addUploadTask(index: number | string, task: UniApp.UploadTask) {
|
|
@@ -599,4 +629,57 @@ export class DevStore {
|
|
|
599
629
|
}
|
|
600
630
|
return '';
|
|
601
631
|
}
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* 新增事件
|
|
635
|
+
*
|
|
636
|
+
* @param {DevTool.EventItem} event
|
|
637
|
+
* @memberof DevStore
|
|
638
|
+
*/
|
|
639
|
+
addEventItem(event: DevTool.EventItem) {
|
|
640
|
+
if (!this.state.eventList) {
|
|
641
|
+
this.state.eventList = [];
|
|
642
|
+
}
|
|
643
|
+
this.state.eventList?.push(event);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* 增加注册事件的数量
|
|
648
|
+
*
|
|
649
|
+
* @param {DevTool.EventCountKey} type
|
|
650
|
+
* @memberof DevStore
|
|
651
|
+
*/
|
|
652
|
+
updateUniEventCount(type: DevTool.EventCountKey) {
|
|
653
|
+
if (!this.state.eventCount) {
|
|
654
|
+
this.state.eventCount = {
|
|
655
|
+
on: 0,
|
|
656
|
+
once: 0,
|
|
657
|
+
emit: 0,
|
|
658
|
+
off: 0,
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
this.state.eventCount[type] = this.state.eventCount[type] + 1;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
updateUniEventList(evenList: DevTool.EventItem[]) {
|
|
665
|
+
const len = this.state.eventList?.length ?? 0;
|
|
666
|
+
const max = this.eventListMaxSize;
|
|
667
|
+
|
|
668
|
+
if (len + evenList.length > max) {
|
|
669
|
+
this.state.eventList?.splice(0, len - max - evenList.length);
|
|
670
|
+
}
|
|
671
|
+
this.state.eventList?.push(...evenList);
|
|
672
|
+
|
|
673
|
+
return this.state.eventList;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
uniEventClear() {
|
|
677
|
+
this.state.eventCount = {
|
|
678
|
+
on: 0,
|
|
679
|
+
once: 0,
|
|
680
|
+
emit: 0,
|
|
681
|
+
off: 0,
|
|
682
|
+
};
|
|
683
|
+
this.state.eventList = [];
|
|
684
|
+
}
|
|
602
685
|
}
|
package/dev/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { default as uniGlobalComponents } from './plugins/uniGlobalComponents/uniGlobalComponents';
|
|
2
|
-
import { default as uniDevTool } from './plugins/uniDevTool/uniDevTool';
|
|
1
|
+
import { default as uniGlobalComponents } from './plugins/uniGlobalComponents/uniGlobalComponents';
|
|
2
|
+
import { default as uniDevTool } from './plugins/uniDevTool/uniDevTool';
|
|
3
|
+
|
|
3
4
|
export { uniDevTool, uniGlobalComponents };
|
|
4
5
|
export default uniDevTool;
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dev/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("./plugins/uniGlobalComponents/uniGlobalComponents.js"),e=require("./plugins/uniDevTool/uniDevTool.js");exports.uniGlobalComponents=o;exports.default=e;exports.uniDevTool=e;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("./plugins/uniGlobalComponents/uniGlobalComponents.js"),e=require("./plugins/uniDevTool/uniDevTool.js");exports.uniGlobalComponents=o;exports.default=e;exports.uniDevTool=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniDevTool.d.ts","sourceRoot":"","sources":["../../../../plugins/src/plugins/uniDevTool/uniDevTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"uniDevTool.d.ts","sourceRoot":"","sources":["../../../../plugins/src/plugins/uniDevTool/uniDevTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAqBnC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,KAAK,EACL,iBAAiB,EACjB,GAAG,KAAK,EACT,EAAE;IACD,qCAAqC;IACrC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,gBAAgB;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa;IACb,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,wBAAwB;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,kBAAkB;IAClB,KAAK,EAAE;QACL,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC1B,WAAW,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAA;aAAE,EAAE,CAAA;SAAE,EAAE,CAAC;KAC7D,CAAC;CACH,GAAG,MAAM,CAyNT"}
|
|
@@ -1,38 +1,36 @@
|
|
|
1
|
-
"use strict";const
|
|
2
|
-
⚡️ vite-uni-dev-tool source file server running at:
|
|
3
|
-
${n.map(i=>`➜ Source File Network: http://${i}:${s==null?void 0:s.port}/__dev_sourcefile__`).join(`
|
|
4
|
-
`)}
|
|
5
|
-
`)}})},transform(e,p){var s;if(p.endsWith("/src/main.ts"))try{const n=e.split(`
|
|
6
|
-
`);let t=[...n];const r=
|
|
7
|
-
`),map:null}}catch(n){return console.error("[DevTool] 转换 main 文件时出错:",n),{code:e,map:null}}if(p.endsWith("/src/App.vue")){const n=e.match(h);if(n&&n[1]){const t=n[1].trim(),r=
|
|
8
|
-
import { initDevTool, console } from 'vite-uni-dev-tool/dev/core';
|
|
9
|
-
import pagesJson from './pages.json';
|
|
10
|
-
${t}
|
|
11
|
-
onLaunch(() => {
|
|
12
|
-
const vue3instance = getCurrentInstance();
|
|
13
|
-
initDevTool({
|
|
14
|
-
pagesJson,
|
|
15
|
-
vue3instance,
|
|
16
|
-
mode: import.meta.env.MODE,
|
|
17
|
-
sourceFileServers: [
|
|
18
|
-
${[...g.urls??[],...d??[]].map(v=>`'${v}'`)}
|
|
19
|
-
],
|
|
20
|
-
useDevSource: ${
|
|
21
|
-
...${JSON.stringify(
|
|
22
|
-
});
|
|
23
|
-
});`;return{code:e.replace(h,`
|
|
24
|
-
<script lang="ts" setup>
|
|
25
|
-
${c}
|
|
26
|
-
${m}
|
|
27
|
-
${o}
|
|
28
|
-
<\/script>`),map:null}}return{code:e,map:null}}if(p.endsWith(".vue")){const n=e.includes("<template>"),t=a.pages.some(o=>p.includes(o.path)),r=(s=a.subPackages)==null?void 0:s.some(o=>o.pages.some(f=>p.includes(`${o.root}/${f.path}`))),i=["<DevTool />"],c=
|
|
29
|
-
import { console } from 'vite-uni-dev-tool/dev/core';
|
|
30
|
-
${o[1]}
|
|
31
|
-
`;e=e.replace(h,`
|
|
32
|
-
<script lang="ts" setup>
|
|
33
|
-
${v}
|
|
34
|
-
<\/script>`)}}if((t||r)&&n){const o=
|
|
35
|
-
${i.join(`
|
|
36
|
-
`)}`;f=e.replace(
|
|
37
|
-
${$}
|
|
38
|
-
</template>`)}return{code:f,map:null}}}return{code:e,map:null}}}}module.exports=T;
|
|
1
|
+
"use strict";const C=require("path"),I=require("fs"),u=require("../utils/index.js");function _(a){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const l in a)if(l!=="default"){const e=Object.getOwnPropertyDescriptor(a,l);Object.defineProperty(d,l,e.get?e:{enumerable:!0,get:()=>a[l]})}}return d.default=a,Object.freeze(d)}const $=_(C),S=_(I),h=/<script[^>]*>([\s\S]*?)<\/script>/,g={isReady:!1,urls:[]};function D({pages:a,sourceFileServers:d,...l}){return{name:"vite-uni-dev-tool",enforce:"pre",configureServer(e){var p;e.middlewares.use((s,n,t)=>{const{originalUrl:r}=s;if(l.useDevSource&&(r!=null&&r.includes("__dev_sourcefile__"))){const i=r.replace("/__dev_sourcefile__","");try{const c=e.config.root,m=$.join(c,i),o=S.readFileSync(m,"utf-8");n.setHeader("Content-Type",u.getContentType(m)),n.end(o)}catch{t()}}else t()}),(p=e.httpServer)==null||p.once("listening",()=>{var t;const s=(t=e.httpServer)==null?void 0:t.address(),n=u.getLocalIPs();if(s&&!Array.isArray(s)&&typeof s!="string"){const r=n.map(i=>`http://${i}:${s.port}/__dev_sourcefile__`);g.isReady=!0,g.urls=r,console.warn(`
|
|
2
|
+
⚡️ vite-uni-dev-tool source file server running at:
|
|
3
|
+
${n.map(i=>`➜ Source File Network: http://${i}:${s==null?void 0:s.port}/__dev_sourcefile__`).join(`
|
|
4
|
+
`)}
|
|
5
|
+
`)}})},transform(e,p){var s;if(p.endsWith("/src/main.ts"))try{const n=e.split(`
|
|
6
|
+
`);let t=[...n];const r=u.findInsertionIndex(t,c=>c.trim().startsWith("import")||c.trim().startsWith("export"));r!==-1&&t.splice(r,0,"import DevTool from 'vite-uni-dev-tool/dev/components/DevTool/index.vue';");const i=u.findInsertionIndex(t,c=>c.includes(".mount(")||c.includes("createApp("));if(i!==-1&&t.splice(i+1,0," app.component('DevTool', DevTool);"),t.length!==n.length)return{code:t.join(`
|
|
7
|
+
`),map:null}}catch(n){return console.error("[DevTool] 转换 main 文件时出错:",n),{code:e,map:null}}if(p.endsWith("/src/App.vue")){const n=e.match(h);if(n&&n[1]){const t=n[1].trim(),r=u.hasImportCurrentInstance(t),i=u.hasImportOnLaunch(t),c=r?"":"import { getCurrentInstance } from 'vue'",m=i?"":"import { onLaunch } from '@dcloudio/uni-app'",o=`
|
|
8
|
+
import { initDevTool, console } from 'vite-uni-dev-tool/dev/core';
|
|
9
|
+
import pagesJson from './pages.json';
|
|
10
|
+
${t}
|
|
11
|
+
onLaunch(() => {
|
|
12
|
+
const vue3instance = getCurrentInstance();
|
|
13
|
+
initDevTool({
|
|
14
|
+
pagesJson,
|
|
15
|
+
vue3instance,
|
|
16
|
+
mode: import.meta.env.MODE,
|
|
17
|
+
sourceFileServers: [
|
|
18
|
+
${[...g.urls??[],...d??[]].map(v=>`'${v}'`)}
|
|
19
|
+
],
|
|
20
|
+
useDevSource: ${l.useDevSource},
|
|
21
|
+
...${JSON.stringify(l)},
|
|
22
|
+
});
|
|
23
|
+
});`;return{code:e.replace(h,`
|
|
24
|
+
<script lang="ts" setup>
|
|
25
|
+
${c}
|
|
26
|
+
${m}
|
|
27
|
+
${o}
|
|
28
|
+
<\/script>`),map:null}}return{code:e,map:null}}if(p.endsWith(".vue")){const n=e.includes("<template>"),t=a.pages.some(o=>p.includes(o.path)),r=(s=a.subPackages)==null?void 0:s.some(o=>o.pages.some(f=>p.includes(`${o.root}/${f.path}`))),i=["<DevTool />"],c=u.hasImportConsole(e),m=u.hasUseConsole(e);if(!c&&m&&!p.endsWith("/src/App.vue")){const o=e.match(h);if(o&&o[1]){const v=`
|
|
29
|
+
import { console } from 'vite-uni-dev-tool/dev/core';
|
|
30
|
+
${o[1]}
|
|
31
|
+
`;e=e.replace(h,`
|
|
32
|
+
<script lang="ts" setup>
|
|
33
|
+
${v}
|
|
34
|
+
<\/script>`)}}if((t||r)&&n){const o=u.getTemplateContent(e);let f=e;if(o){const v=`${o}
|
|
35
|
+
${i.join(`
|
|
36
|
+
`)}`;f=e.replace(o,v)}return{code:f,map:null}}}return{code:e,map:null}}}}module.exports=D;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniGlobalComponents.d.ts","sourceRoot":"","sources":["../../../../plugins/src/plugins/uniGlobalComponents/uniGlobalComponents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"uniGlobalComponents.d.ts","sourceRoot":"","sources":["../../../../plugins/src/plugins/uniGlobalComponents/uniGlobalComponents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAanC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,KAAK,EACL,UAAU,GACX,EAAE;IACD,KAAK,EAAE;QACL,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC1B,WAAW,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAA;aAAE,EAAE,CAAA;SAAE,EAAE,CAAC;KAC7D,CAAC;IACF,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,GAAG,MAAM,CA+ET"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
"use strict";const d=require("path"),
|
|
2
|
-
⚡️ vite-uni-dev-tool source file server running at:
|
|
3
|
-
${c.map(n=>`➜ Source File Network: http://${n}:${t==null?void 0:t.port}/__dev_sourcefile__`).join(`
|
|
4
|
-
`)}
|
|
5
|
-
`))})},transform(e,r){var t;if(r.endsWith(".vue")){const c=e.includes("<template>"),i=s.pages.some(o=>r.includes(o.path)),n=(t=s.subPackages)==null?void 0:t.some(o=>o.pages.some(
|
|
6
|
-
${
|
|
7
|
-
`)}`;return{code:e.replace(
|
|
8
|
-
${u}
|
|
9
|
-
</template>`),map:null}}}}return{code:e,map:null}}}}module.exports=$;
|
|
1
|
+
"use strict";const d=require("path"),m=require("fs"),p=require("../utils/index.js");function f(s){const u=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const e in s)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(s,e);Object.defineProperty(u,e,r.get?r:{enumerable:!0,get:()=>s[e]})}}return u.default=s,Object.freeze(u)}const g=f(d),h=f(m);function y({pages:s,components:u}){return{name:"uni-global-components",enforce:"pre",configureServer(e){var r;e.middlewares.use((t,c,i)=>{const{originalUrl:n}=t;if(n!=null&&n.includes("__dev_sourcefile__")){const o=n.replace("/__dev_sourcefile__","");try{const a=e.config.root,l=g.join(a,o),_=h.readFileSync(l,"utf-8");c.setHeader("Content-Type",p.getContentType(l)),c.end(_)}catch{i()}}else i()}),(r=e.httpServer)==null||r.once("listening",()=>{var i;const t=(i=e.httpServer)==null?void 0:i.address(),c=p.getLocalIPs();t&&!Array.isArray(t)&&typeof t!="string"&&(c.map(n=>`http://${n}:${t.port}/__dev_sourcefile__`),console.warn(`
|
|
2
|
+
⚡️ vite-uni-dev-tool source file server running at:
|
|
3
|
+
${c.map(n=>`➜ Source File Network: http://${n}:${t==null?void 0:t.port}/__dev_sourcefile__`).join(`
|
|
4
|
+
`)}
|
|
5
|
+
`))})},transform(e,r){var t;if(r.endsWith(".vue")){const c=e.includes("<template>"),i=s.pages.some(o=>r.includes(o.path)),n=(t=s.subPackages)==null?void 0:t.some(o=>o.pages.some(a=>r.includes(`${o.root}/${a.path}`)));if((i||n)&&c){const o=p.getTemplateContent(e);if(o){const a=`${o}
|
|
6
|
+
${u.join(`
|
|
7
|
+
`)}`;return{code:e.replace(o,a),map:null}}}}return{code:e,map:null}}}}module.exports=y;
|
|
@@ -9,10 +9,10 @@ export declare function hasUseConsole(str: string): boolean;
|
|
|
9
9
|
* 解析栈信息
|
|
10
10
|
*
|
|
11
11
|
* @export
|
|
12
|
-
* @param {string}
|
|
12
|
+
* @param {string} stack
|
|
13
13
|
* @return {*}
|
|
14
14
|
*/
|
|
15
|
-
export declare function parseStock(
|
|
15
|
+
export declare function parseStock(stack: string): {
|
|
16
16
|
info: string;
|
|
17
17
|
path: string;
|
|
18
18
|
row: number;
|
|
@@ -50,4 +50,12 @@ export declare function extractSourceMap(text: string): string;
|
|
|
50
50
|
* @return {*}
|
|
51
51
|
*/
|
|
52
52
|
export declare function parseQueryString(queryString: string): any;
|
|
53
|
+
/**
|
|
54
|
+
* 获取 template 中的内容
|
|
55
|
+
*
|
|
56
|
+
* @export
|
|
57
|
+
* @param {string} code
|
|
58
|
+
* @return {*}
|
|
59
|
+
*/
|
|
60
|
+
export declare function getTemplateContent(code: string): string;
|
|
53
61
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../plugins/src/plugins/utils/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GAChC,MAAM,CAOR;AAGD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,UAe9C;AAGD,wBAAgB,WAAW,aAiB1B;AAKD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEtD;AAKD,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE7D;AAID,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAErD;AAGD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAElD;AAID;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM;;;;;EAQvC;AAGD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,UAGtC;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAGvC;AAID;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,UAG5C;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,OA4BnD"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../plugins/src/plugins/utils/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GAChC,MAAM,CAOR;AAGD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,UAe9C;AAGD,wBAAgB,WAAW,aAiB1B;AAKD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEtD;AAKD,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE7D;AAID,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAErD;AAGD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAElD;AAID;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM;;;;;EAQvC;AAGD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,UAGtC;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAGvC;AAID;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,UAG5C;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,OA4BnD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,UAqD9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("path"),f=require("os");function i(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,o.get?o:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const m=i(g),h=i(f);function d(t,n){for(let e=0;e<t.length;e++)if(n(t[e]))return e+1;return-1}function x(t){const n=m.extname(t).toLowerCase();return{".html":"text/html",".js":"text/javascript",".css":"text/css",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".woff":"font/woff",".woff2":"font/woff2"}[n]||"text/plain"}function I(){const t=h.networkInterfaces(),n=[];return Object.keys(t).forEach(e=>{var o;t!=null&&t[e]&&Array.isArray(t==null?void 0:t[e])&&((o=t==null?void 0:t[e])==null||o.forEach(r=>{r.family==="IPv4"&&!r.internal&&n.push(r.address)}))}),n.push("localhost"),n}const y=/import\s*\{[^}]*onLaunch[^}]*\}\s*from\s+['"]@dcloudio\/uni-app['"];?/;function C(t){return y.test(t)}const j=/import\s*\{[^}]*getCurrentInstance[^}]*\}\s*from\s+['"]vue['"];?/;function b(t){return j.test(t)}const w=/import\s*\{[^}]*console[^}]*\}\s*from\s+['"]vite-uni-dev-tool['"];?/;function v(t){return w.test(t)}const O=/console\.\w+\(/;function T(t){return O.test(t)}function L(t){let n=0,e=-1,o=-1,r="";const l=/<template(\s[^>]*)?>/g,p=/<\/template>/g,c=[];let a;for(;(a=l.exec(t))!==null;)c.push({index:a.index,type:"start",length:a[0].length});for(;(a=p.exec(t))!==null;)c.push({index:a.index,type:"end",length:a[0].length});c.sort((s,u)=>s.index-u.index);for(const s of c)if(s.type==="start")n===0&&(e=s.index+s.length),n++;else if(s.type==="end"&&(n--,n===0)){o=s.index,r=t.substring(e,o);break}return r.trim()}exports.findInsertionIndex=d;exports.getContentType=x;exports.getLocalIPs=I;exports.getTemplateContent=L;exports.hasImportConsole=v;exports.hasImportCurrentInstance=b;exports.hasImportOnLaunch=C;exports.hasUseConsole=T;
|