vite-uni-dev-tool 0.0.5 → 0.0.7
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 +35 -1
- package/dev/components/Connection/index.vue +11 -21
- package/dev/components/ConsoleList/Code.vue +22 -9
- package/dev/components/DevTool/index.vue +9 -8
- package/dev/components/DevToolTitle/index.vue +21 -0
- package/dev/components/DevToolWindow/index.vue +41 -3
- package/dev/components/SettingList/index.vue +9 -19
- package/dev/components/UniEvent/UniEventItem.vue +55 -0
- package/dev/components/UniEvent/index.vue +85 -0
- package/dev/const.ts +4 -2
- package/dev/core.ts +12 -1
- package/dev/devEvent/index.ts +38 -8
- package/dev/devEventBus/index.ts +94 -0
- package/dev/devIntercept/index.ts +37 -0
- package/dev/devStore/index.ts +73 -0
- package/dev/index.d.ts +4 -4
- package/dev/index.js +1 -1
- package/dev/plugins/uniDevTool/uniDevTool.d.ts +71 -71
- package/dev/plugins/uniDevTool/uniDevTool.js +38 -38
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +32 -32
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.js +9 -9
- package/dev/plugins/utils/index.d.ts +52 -52
- package/dev/plugins/utils/index.js +1 -1
- package/dev/type.ts +21 -0
- package/package.json +1 -1
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { Plugin } from 'vite';
|
|
2
|
-
/**
|
|
3
|
-
* uni-global-components 插件,用于在页面中添加全局组件
|
|
4
|
-
*
|
|
5
|
-
* 该插件会在每个页面的template中添加全局组件,以达到全局组件的效果。
|
|
6
|
-
*
|
|
7
|
-
* 如果组件不是用 template 定义的,则不会被该插件添加。
|
|
8
|
-
*
|
|
9
|
-
* @export
|
|
10
|
-
* @param {{
|
|
11
|
-
* pages: { pages: { path: string }[] };
|
|
12
|
-
* components: string[];
|
|
13
|
-
* }} {
|
|
14
|
-
* pages,
|
|
15
|
-
* components
|
|
16
|
-
* }
|
|
17
|
-
* @return {*} {Plugin}
|
|
18
|
-
*/
|
|
19
|
-
export default function uniGlobalComponents({ pages, components, }: {
|
|
20
|
-
pages: {
|
|
21
|
-
pages: {
|
|
22
|
-
path: string;
|
|
23
|
-
}[];
|
|
24
|
-
subPackages?: {
|
|
25
|
-
root: string;
|
|
26
|
-
pages: {
|
|
27
|
-
path: string;
|
|
28
|
-
}[];
|
|
29
|
-
}[];
|
|
30
|
-
};
|
|
31
|
-
components: string[];
|
|
32
|
-
}): Plugin;
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* uni-global-components 插件,用于在页面中添加全局组件
|
|
4
|
+
*
|
|
5
|
+
* 该插件会在每个页面的template中添加全局组件,以达到全局组件的效果。
|
|
6
|
+
*
|
|
7
|
+
* 如果组件不是用 template 定义的,则不会被该插件添加。
|
|
8
|
+
*
|
|
9
|
+
* @export
|
|
10
|
+
* @param {{
|
|
11
|
+
* pages: { pages: { path: string }[] };
|
|
12
|
+
* components: string[];
|
|
13
|
+
* }} {
|
|
14
|
+
* pages,
|
|
15
|
+
* components
|
|
16
|
+
* }
|
|
17
|
+
* @return {*} {Plugin}
|
|
18
|
+
*/
|
|
19
|
+
export default function uniGlobalComponents({ pages, components, }: {
|
|
20
|
+
pages: {
|
|
21
|
+
pages: {
|
|
22
|
+
path: string;
|
|
23
|
+
}[];
|
|
24
|
+
subPackages?: {
|
|
25
|
+
root: string;
|
|
26
|
+
pages: {
|
|
27
|
+
path: string;
|
|
28
|
+
}[];
|
|
29
|
+
}[];
|
|
30
|
+
};
|
|
31
|
+
components: string[];
|
|
32
|
+
}): Plugin;
|
|
33
33
|
//# sourceMappingURL=uniGlobalComponents.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";const d=require("path"),g=require("fs"),f=require("../utils/index.js");function _(s){const a=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(a,e,r.get?r:{enumerable:!0,get:()=>s[e]})}}return a.default=s,Object.freeze(a)}const h=_(d),y=_(g),m=/<template[^>]*>([\s\S]*?)<\/template>/;function $({pages:s,components:a}){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 l=e.config.root,u=h.join(l,o),p=y.readFileSync(u,"utf-8");c.setHeader("Content-Type",f.getContentType(u)),c.end(p)}catch{i()}}else i()}),(r=e.httpServer)==null||r.once("listening",()=>{var i;const t=(i=e.httpServer)==null?void 0:i.address(),c=f.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(l=>r.includes(`${o.root}/${l.path}`)));if((i||n)&&c){const o=e.match(m);if(o&&o[1]){const u=`${o[1].trim()}
|
|
6
|
-
${a.join(`
|
|
7
|
-
`)}`;return{code:e.replace(m,`<template>
|
|
8
|
-
${u}
|
|
9
|
-
</template>`),map:null}}}}return{code:e,map:null}}}}module.exports=$;
|
|
1
|
+
"use strict";const d=require("path"),g=require("fs"),f=require("../utils/index.js");function _(s){const a=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(a,e,r.get?r:{enumerable:!0,get:()=>s[e]})}}return a.default=s,Object.freeze(a)}const h=_(d),y=_(g),m=/<template[^>]*>([\s\S]*?)<\/template>/;function $({pages:s,components:a}){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 l=e.config.root,u=h.join(l,o),p=y.readFileSync(u,"utf-8");c.setHeader("Content-Type",f.getContentType(u)),c.end(p)}catch{i()}}else i()}),(r=e.httpServer)==null||r.once("listening",()=>{var i;const t=(i=e.httpServer)==null?void 0:i.address(),c=f.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(l=>r.includes(`${o.root}/${l.path}`)));if((i||n)&&c){const o=e.match(m);if(o&&o[1]){const u=`${o[1].trim()}
|
|
6
|
+
${a.join(`
|
|
7
|
+
`)}`;return{code:e.replace(m,`<template>
|
|
8
|
+
${u}
|
|
9
|
+
</template>`),map:null}}}}return{code:e,map:null}}}}module.exports=$;
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
export declare function findInsertionIndex(lines: string[], condition: (p: string) => boolean): number;
|
|
2
|
-
export declare function getContentType(filePath: string): string;
|
|
3
|
-
export declare function getLocalIPs(): string[];
|
|
4
|
-
export declare function hasImportOnLaunch(str: string): boolean;
|
|
5
|
-
export declare function hasImportCurrentInstance(str: string): boolean;
|
|
6
|
-
export declare function hasImportConsole(str: string): boolean;
|
|
7
|
-
export declare function hasUseConsole(str: string): boolean;
|
|
8
|
-
/**
|
|
9
|
-
* 解析栈信息
|
|
10
|
-
*
|
|
11
|
-
* @export
|
|
12
|
-
* @param {string} stock
|
|
13
|
-
* @return {*}
|
|
14
|
-
*/
|
|
15
|
-
export declare function parseStock(stock: string): {
|
|
16
|
-
info: string;
|
|
17
|
-
path: string;
|
|
18
|
-
row: number;
|
|
19
|
-
col: number;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* 在字符串中获取url
|
|
23
|
-
*
|
|
24
|
-
* @export
|
|
25
|
-
* @param {string} text
|
|
26
|
-
* @return {*}
|
|
27
|
-
*/
|
|
28
|
-
export declare function extractUrl(text: string): string;
|
|
29
|
-
/**
|
|
30
|
-
* 在字符串中获取路径
|
|
31
|
-
*
|
|
32
|
-
* @export
|
|
33
|
-
* @param {string} text
|
|
34
|
-
* @return {*}
|
|
35
|
-
*/
|
|
36
|
-
export declare function extractPath(text: string): string;
|
|
37
|
-
/**
|
|
38
|
-
* 获取文件内的行内sourcemap
|
|
39
|
-
*
|
|
40
|
-
* @export
|
|
41
|
-
* @param {string} text
|
|
42
|
-
* @return {*}
|
|
43
|
-
*/
|
|
44
|
-
export declare function extractSourceMap(text: string): string;
|
|
45
|
-
/**
|
|
46
|
-
* 解析url中的参数
|
|
47
|
-
*
|
|
48
|
-
* @export
|
|
49
|
-
* @param {string} queryString
|
|
50
|
-
* @return {*}
|
|
51
|
-
*/
|
|
52
|
-
export declare function parseQueryString(queryString: string): any;
|
|
1
|
+
export declare function findInsertionIndex(lines: string[], condition: (p: string) => boolean): number;
|
|
2
|
+
export declare function getContentType(filePath: string): string;
|
|
3
|
+
export declare function getLocalIPs(): string[];
|
|
4
|
+
export declare function hasImportOnLaunch(str: string): boolean;
|
|
5
|
+
export declare function hasImportCurrentInstance(str: string): boolean;
|
|
6
|
+
export declare function hasImportConsole(str: string): boolean;
|
|
7
|
+
export declare function hasUseConsole(str: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* 解析栈信息
|
|
10
|
+
*
|
|
11
|
+
* @export
|
|
12
|
+
* @param {string} stock
|
|
13
|
+
* @return {*}
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseStock(stock: string): {
|
|
16
|
+
info: string;
|
|
17
|
+
path: string;
|
|
18
|
+
row: number;
|
|
19
|
+
col: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 在字符串中获取url
|
|
23
|
+
*
|
|
24
|
+
* @export
|
|
25
|
+
* @param {string} text
|
|
26
|
+
* @return {*}
|
|
27
|
+
*/
|
|
28
|
+
export declare function extractUrl(text: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* 在字符串中获取路径
|
|
31
|
+
*
|
|
32
|
+
* @export
|
|
33
|
+
* @param {string} text
|
|
34
|
+
* @return {*}
|
|
35
|
+
*/
|
|
36
|
+
export declare function extractPath(text: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* 获取文件内的行内sourcemap
|
|
39
|
+
*
|
|
40
|
+
* @export
|
|
41
|
+
* @param {string} text
|
|
42
|
+
* @return {*}
|
|
43
|
+
*/
|
|
44
|
+
export declare function extractSourceMap(text: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* 解析url中的参数
|
|
47
|
+
*
|
|
48
|
+
* @export
|
|
49
|
+
* @param {string} queryString
|
|
50
|
+
* @return {*}
|
|
51
|
+
*/
|
|
52
|
+
export declare function parseQueryString(queryString: string): any;
|
|
53
53
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("path"),a=require("os");function r(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 u=r(c),i=r(a);function p(t,n){for(let e=0;e<t.length;e++)if(n(t[e]))return e+1;return-1}function f(t){const n=u.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 l(){const t=i.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(s=>{s.family==="IPv4"&&!s.internal&&n.push(s.address)}))}),n.push("localhost"),n}const g=/import\s*\{[^}]*onLaunch[^}]*\}\s*from\s+['"]@dcloudio\/uni-app['"];?/;function m(t){return g.test(t)}const h=/import\s*\{[^}]*getCurrentInstance[^}]*\}\s*from\s+['"]vue['"];?/;function I(t){return h.test(t)}const d=/import\s*\{[^}]*console[^}]*\}\s*from\s+['"]vite-uni-dev-tool['"];?/;function y(t){return d.test(t)}const j=/console\.\w+\(/;function C(t){return j.test(t)}exports.findInsertionIndex=p;exports.getContentType=f;exports.getLocalIPs=l;exports.hasImportConsole=y;exports.hasImportCurrentInstance=I;exports.hasImportOnLaunch=m;exports.hasUseConsole=C;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("path"),a=require("os");function r(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 u=r(c),i=r(a);function p(t,n){for(let e=0;e<t.length;e++)if(n(t[e]))return e+1;return-1}function f(t){const n=u.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 l(){const t=i.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(s=>{s.family==="IPv4"&&!s.internal&&n.push(s.address)}))}),n.push("localhost"),n}const g=/import\s*\{[^}]*onLaunch[^}]*\}\s*from\s+['"]@dcloudio\/uni-app['"];?/;function m(t){return g.test(t)}const h=/import\s*\{[^}]*getCurrentInstance[^}]*\}\s*from\s+['"]vue['"];?/;function I(t){return h.test(t)}const d=/import\s*\{[^}]*console[^}]*\}\s*from\s+['"]vite-uni-dev-tool['"];?/;function y(t){return d.test(t)}const j=/console\.\w+\(/;function C(t){return j.test(t)}exports.findInsertionIndex=p;exports.getContentType=f;exports.getLocalIPs=l;exports.hasImportConsole=y;exports.hasImportCurrentInstance=I;exports.hasImportOnLaunch=m;exports.hasUseConsole=C;
|
package/dev/type.ts
CHANGED
|
@@ -175,6 +175,25 @@ export declare namespace DevTool {
|
|
|
175
175
|
totalBytesExpectedToSend?: number;
|
|
176
176
|
};
|
|
177
177
|
|
|
178
|
+
type EventCount = {
|
|
179
|
+
on: number;
|
|
180
|
+
once: number;
|
|
181
|
+
emit: number;
|
|
182
|
+
off: number;
|
|
183
|
+
};
|
|
184
|
+
type EventCountKey = keyof EventCount;
|
|
185
|
+
|
|
186
|
+
type EventItem = {
|
|
187
|
+
/** 事件名称 */
|
|
188
|
+
eventName?: string;
|
|
189
|
+
/** 触发事件 */
|
|
190
|
+
timer?: string;
|
|
191
|
+
/** 调用位置 */
|
|
192
|
+
stock?: string;
|
|
193
|
+
/** 事件类型 */
|
|
194
|
+
type?: string;
|
|
195
|
+
};
|
|
196
|
+
|
|
178
197
|
type WindowData = {
|
|
179
198
|
devToolVisible?: boolean;
|
|
180
199
|
consoleList?: ConsoleItem[];
|
|
@@ -191,6 +210,8 @@ export declare namespace DevTool {
|
|
|
191
210
|
size?: number;
|
|
192
211
|
sizeFormat?: string;
|
|
193
212
|
uploadList?: UploadItem[];
|
|
213
|
+
eventCount?: EventCount;
|
|
214
|
+
eventList?: EventItem[];
|
|
194
215
|
};
|
|
195
216
|
|
|
196
217
|
type DevInterceptOptions = {
|