vite-uni-dev-tool 0.0.9 → 0.0.11
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 +18 -0
- package/dev/components/AppInfo/index.vue +36 -0
- package/dev/components/AutoSizer/index.vue +193 -0
- package/dev/components/AutoSizer/index1.vue +186 -0
- package/dev/components/AutoSizer/utils.ts +49 -0
- package/dev/components/CaptureScreen/index.vue +62 -0
- package/dev/components/Code/index.vue +7 -4
- package/dev/components/ConsoleList/RunJSInput.vue +177 -1
- package/dev/components/ConsoleList/index.vue +29 -19
- package/dev/components/ConsoleList/staticTips.ts +1145 -0
- package/dev/components/DevToolWindow/index.vue +225 -101
- package/dev/components/JsonPretty/components/Carets/index.vue +10 -14
- package/dev/components/JsonPretty/index.vue +50 -41
- package/dev/components/NetworkList/index.vue +16 -9
- package/dev/components/RouteList/index.vue +31 -19
- package/dev/components/Tabs/index.vue +23 -10
- package/dev/components/UploadList/index.vue +15 -5
- package/dev/components/VirtualListPro/AutoSize.vue +43 -0
- package/dev/components/VirtualListPro/index.vue +175 -0
- package/dev/components/VirtualListPro/readme.md +40 -0
- package/dev/components/WebSocket/index.vue +16 -4
- package/dev/const.ts +2 -4
- package/dev/devEvent/index.ts +29 -2
- package/dev/devIntercept/index.ts +18 -0
- package/dev/devStore/index.ts +33 -0
- package/dev/plugins/uniDevTool/uniDevTool.js +36 -36
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -7
- package/dev/type.ts +7 -0
- package/dev/utils/array.ts +15 -0
- package/dev/utils/index.ts +3 -0
- package/dev/utils/string.ts +12 -0
- package/package.json +1 -1
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
"use strict";const C=require("path"),I=require("fs"),u=require("../utils/index.js");function _(a){const v=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(v,l,e.get?e:{enumerable:!0,get:()=>a[l]})}}return v.default=a,Object.freeze(v)}const $=_(C),S=_(I),h=/<script[^>]*>([\s\S]*?)<\/script>/,g={isReady:!1,urls:[]};function D({pages:a,sourceFileServers:v,...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??[],...v??[]].map(d=>`'${d}'`)}
|
|
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 d=`
|
|
29
|
-
import { console } from 'vite-uni-dev-tool/dev/core';
|
|
30
|
-
${o[1]}
|
|
31
|
-
`;e=e.replace(h,`
|
|
32
|
-
<script lang="ts" setup>
|
|
33
|
-
${d}
|
|
34
|
-
<\/script>`)}}if((t||r)&&n){const o=u.getTemplateContent(e);let f=e;if(o){const d=`<view>${o}
|
|
35
|
-
${i.join(`
|
|
36
|
-
`)}</view>`;f=e.replace(o,d)}return{code:f,map:null}}}return{code:e,map:null}}}}module.exports=D;
|
|
1
|
+
"use strict";const C=require("path"),I=require("fs"),u=require("../utils/index.js");function _(a){const v=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(v,l,e.get?e:{enumerable:!0,get:()=>a[l]})}}return v.default=a,Object.freeze(v)}const $=_(C),S=_(I),h=/<script[^>]*>([\s\S]*?)<\/script>/,g={isReady:!1,urls:[]};function D({pages:a,sourceFileServers:v,...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??[],...v??[]].map(d=>`'${d}'`)}
|
|
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 d=`
|
|
29
|
+
import { console } from 'vite-uni-dev-tool/dev/core';
|
|
30
|
+
${o[1]}
|
|
31
|
+
`;e=e.replace(h,`
|
|
32
|
+
<script lang="ts" setup>
|
|
33
|
+
${d}
|
|
34
|
+
<\/script>`)}}if((t||r)&&n){const o=u.getTemplateContent(e);let f=e;if(o){const d=`<view>${o}
|
|
35
|
+
${i.join(`
|
|
36
|
+
`)}</view>`;f=e.replace(o,d)}return{code:f,map:null}}}return{code:e,map:null}}}}module.exports=D;
|
|
@@ -1,7 +1,7 @@
|
|
|
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 v({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=`<view>${o}
|
|
6
|
-
${u.join(`
|
|
7
|
-
`)}</view>`;return{code:e.replace(o,a),map:null}}}}return{code:e,map:null}}}}module.exports=v;
|
|
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 v({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=`<view>${o}
|
|
6
|
+
${u.join(`
|
|
7
|
+
`)}</view>`;return{code:e.replace(o,a),map:null}}}}return{code:e,map:null}}}}module.exports=v;
|
package/dev/type.ts
CHANGED
|
@@ -230,6 +230,11 @@ export declare namespace DevTool {
|
|
|
230
230
|
mode?: 'input' | 'output';
|
|
231
231
|
};
|
|
232
232
|
|
|
233
|
+
type CaptureScreenItem = {
|
|
234
|
+
position: string;
|
|
235
|
+
timer: string;
|
|
236
|
+
};
|
|
237
|
+
|
|
233
238
|
type WindowData = {
|
|
234
239
|
devToolVisible?: boolean;
|
|
235
240
|
consoleList?: ConsoleItem[];
|
|
@@ -242,12 +247,14 @@ export declare namespace DevTool {
|
|
|
242
247
|
deviceInfo?: Record<string, any>;
|
|
243
248
|
windowInfo?: Record<string, any>;
|
|
244
249
|
netWorkStatus?: Record<string, any>;
|
|
250
|
+
appInfo?: Record<string, any>;
|
|
245
251
|
wsList?: WS[];
|
|
246
252
|
size?: number;
|
|
247
253
|
sizeFormat?: string;
|
|
248
254
|
uploadList?: UploadItem[];
|
|
249
255
|
eventCount?: EventCount;
|
|
250
256
|
eventList?: EventItem[];
|
|
257
|
+
captureScreenList?: CaptureScreenItem[];
|
|
251
258
|
};
|
|
252
259
|
|
|
253
260
|
type DevInterceptOptions = {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function chunk<T>(array: T[], size = 1): T[][] {
|
|
2
|
+
if (!Array.isArray(array) || size <= 0) {
|
|
3
|
+
return [];
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const result: T[][] = [];
|
|
7
|
+
let index = 0;
|
|
8
|
+
|
|
9
|
+
while (index < array.length) {
|
|
10
|
+
result.push(array.slice(index, index + size));
|
|
11
|
+
index += size;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return result;
|
|
15
|
+
}
|
package/dev/utils/index.ts
CHANGED
|
@@ -36,8 +36,11 @@ export {
|
|
|
36
36
|
extractRowAndCol,
|
|
37
37
|
parseStock,
|
|
38
38
|
isMockWX,
|
|
39
|
+
uniqueId,
|
|
39
40
|
} from './string';
|
|
40
41
|
|
|
41
42
|
export { getWifiIp, getDeviceMac, getLanIp, getMicroAppIp } from './ip';
|
|
42
43
|
|
|
43
44
|
export { isAndroid, isH5, isWX } from './platform';
|
|
45
|
+
|
|
46
|
+
export { chunk } from './array';
|
package/dev/utils/string.ts
CHANGED
|
@@ -119,3 +119,15 @@ const mockWXReg = /https?:\/\/usr/;
|
|
|
119
119
|
export function isMockWX(stack: string) {
|
|
120
120
|
return mockWXReg.test(stack);
|
|
121
121
|
}
|
|
122
|
+
|
|
123
|
+
export function uniqueId(
|
|
124
|
+
pre: string = '',
|
|
125
|
+
length = 16,
|
|
126
|
+
chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
|
|
127
|
+
): string {
|
|
128
|
+
let result = '';
|
|
129
|
+
for (let i = 0; i < length; i++) {
|
|
130
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
131
|
+
}
|
|
132
|
+
return pre + result;
|
|
133
|
+
}
|