vite-uni-dev-tool 0.0.7 → 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 +9 -1
- package/dev/components/Code/index.vue +227 -0
- 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 +1 -1
- package/dev/components/DevToolButton/index.vue +10 -10
- package/dev/components/DevToolWindow/index.vue +21 -2
- 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 +1 -1
- package/dev/components/UniEvent/UniEventItem.vue +72 -3
- package/dev/components/UniEvent/index.vue +10 -1
- 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 +97 -26
- package/dev/core.ts +0 -2
- package/dev/devConsole/index.ts +21 -4
- package/dev/devEvent/index.ts +85 -1
- package/dev/devIntercept/index.ts +27 -21
- package/dev/devRunJS/index.ts +170 -0
- package/dev/devStore/index.ts +13 -3
- 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 +38 -2
- 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
|
@@ -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
|
@@ -49,7 +49,9 @@ export class DevStore {
|
|
|
49
49
|
/** ws数据最大值 */
|
|
50
50
|
private wsDataMaxSize = 1000;
|
|
51
51
|
/** 事件列表最大值 */
|
|
52
|
-
private
|
|
52
|
+
private eventListMaxSize = 1000;
|
|
53
|
+
/** js 最大运行条数 */
|
|
54
|
+
private runJsMaxSize = 1000;
|
|
53
55
|
|
|
54
56
|
/** 缓存最大值 */
|
|
55
57
|
cacheMaxSize = 8 * 1024 * 1024 * 10;
|
|
@@ -90,6 +92,7 @@ export class DevStore {
|
|
|
90
92
|
setWindowInfo(windowInfo: Record<string, any>) {
|
|
91
93
|
this.state.windowInfo = windowInfo;
|
|
92
94
|
}
|
|
95
|
+
|
|
93
96
|
setDeviceInfo(deviceInfo: Record<string, any>) {
|
|
94
97
|
this.state.deviceInfo = deviceInfo;
|
|
95
98
|
}
|
|
@@ -142,6 +145,7 @@ export class DevStore {
|
|
|
142
145
|
this.networkMaxSize = options.networkMaxSize || 1000;
|
|
143
146
|
this.wsDataMaxSize = options.wsDataMaxSize || 1000;
|
|
144
147
|
this.cacheMaxSize = options.cacheMaxSize || 8 * 1024 * 1024 * 10;
|
|
148
|
+
this.eventListMaxSize = options.eventListMaxSize || 1000;
|
|
145
149
|
|
|
146
150
|
const devToolVisible = uni.getStorageSync(EVENT_DEV_BUTTON);
|
|
147
151
|
this.devToolVisible = isBoolean(devToolVisible)
|
|
@@ -310,6 +314,13 @@ export class DevStore {
|
|
|
310
314
|
this.state.networkList = [];
|
|
311
315
|
this.state.wsList = [];
|
|
312
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
|
+
};
|
|
313
324
|
}
|
|
314
325
|
|
|
315
326
|
clearAll() {
|
|
@@ -652,13 +663,12 @@ export class DevStore {
|
|
|
652
663
|
|
|
653
664
|
updateUniEventList(evenList: DevTool.EventItem[]) {
|
|
654
665
|
const len = this.state.eventList?.length ?? 0;
|
|
655
|
-
const max = this.
|
|
666
|
+
const max = this.eventListMaxSize;
|
|
656
667
|
|
|
657
668
|
if (len + evenList.length > max) {
|
|
658
669
|
this.state.eventList?.splice(0, len - max - evenList.length);
|
|
659
670
|
}
|
|
660
671
|
this.state.eventList?.push(...evenList);
|
|
661
|
-
console.log('this.state.eventList: ', this.state.eventList);
|
|
662
672
|
|
|
663
673
|
return this.state.eventList;
|
|
664
674
|
}
|
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;
|
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 = {
|
|
@@ -189,11 +211,25 @@ export declare namespace DevTool {
|
|
|
189
211
|
/** 触发事件 */
|
|
190
212
|
timer?: string;
|
|
191
213
|
/** 调用位置 */
|
|
192
|
-
|
|
214
|
+
stack?: string;
|
|
193
215
|
/** 事件类型 */
|
|
194
216
|
type?: string;
|
|
195
217
|
};
|
|
196
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
|
+
|
|
197
233
|
type WindowData = {
|
|
198
234
|
devToolVisible?: boolean;
|
|
199
235
|
consoleList?: ConsoleItem[];
|
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
|
+
}
|