vite-uni-dev-tool 0.0.5 → 0.0.6

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 CHANGED
@@ -81,7 +81,7 @@ uni.__dev__console.log('hello vite-uni-dev-tool');
81
81
 
82
82
  ### 安全性声明
83
83
 
84
- 插件不收收集任何信息,只开发人员调试使用
84
+ 插件不收收集任何信息,只供开发人员调试使用
85
85
 
86
86
  - 插件中使用到了 `fs`,用于栈信息获取源代码文件
87
87
  - 插件使用了 `uni.request` ,用于栈信息获取源代码文件
@@ -148,3 +148,29 @@ uni.__dev__console.log('hello vite-uni-dev-tool');
148
148
  - setting 页,支持重启,导出日志(h5,app)
149
149
 
150
150
  ![image.png](https://gitee.com/cloud_l/vite-uni-dev-tool/raw/master/packages/docs/public/setting.jpg)
151
+
152
+ ## 更新日志
153
+
154
+ ### 0.0.6
155
+ - 修复 app 查看 source 重启
156
+
157
+ ### 0.0.5
158
+
159
+ - 修复 路由支持跳转 subPackages
160
+ - 增加栈位置查看(实验中功能)
161
+
162
+ ### 0.0.4
163
+
164
+ - 修复初始启用状态
165
+
166
+ ### 0.0.3
167
+
168
+ - 文档调整
169
+
170
+ ### 0.0.2
171
+
172
+ - 文档调整
173
+
174
+ ### 0.0.1
175
+
176
+ - 初始版本发布
@@ -21,7 +21,7 @@
21
21
  v-for="(code, index) in codes"
22
22
  :id="`dev-tool-code-item-${index}`"
23
23
  :key="index"
24
- :class="`dev-tool-code-item ${index === activeRowCol.row ? 'dev-tool-code-item-active' : ''}`"
24
+ :class="`dev-tool-code-item ${index === activeRowCol.activeRow ? 'dev-tool-code-item-active' : ''}`"
25
25
  >
26
26
  <view class="dev-tool-code-item-index"> {{ index + 1 }}</view>
27
27
 
@@ -49,11 +49,12 @@ const emit = defineEmits<{ (e: 'close'): void }>();
49
49
  const modelValue = ref('');
50
50
  const scrollTop = ref(0);
51
51
  const fileName = computed(() => {
52
- const name = props?.url?.split('/')?.pop() ?? '文件名称未知';
52
+ const name =
53
+ props?.url?.split('/')?.pop()?.replace(/\)|\(/, '') ?? '文件名称未知';
53
54
  return name;
54
55
  });
55
56
 
56
- const activeRowCol = ref({ row: -1, col: -1 });
57
+ const activeRowCol = ref({ row: -1, col: -1, activeRow: -1 });
57
58
 
58
59
  let backupCodes: string[] = [];
59
60
 
@@ -101,10 +102,22 @@ function getCode(url: string, i: number = 0) {
101
102
  .toString()
102
103
  .split('\n');
103
104
 
104
- codes.value = backupCodes;
105
+ const start =
106
+ activeRowCol.value.row - 20 > 0 ? activeRowCol.value.row - 20 : 0;
107
+
108
+ const end =
109
+ activeRowCol.value.row + 20 > backupCodes.length
110
+ ? backupCodes.length
111
+ : activeRowCol.value.row + 20;
112
+
113
+ // backupCodes.slice(start, end);
114
+
115
+ codes.value = backupCodes.slice(start, end);
116
+
117
+ activeRowCol.value.activeRow = activeRowCol.value.row - start;
105
118
 
106
119
  nextTick(() => {
107
- scrollIntoView.value = `dev-tool-code-item-${activeRowCol.value.row}`;
120
+ scrollIntoView.value = `dev-tool-code-item-${activeRowCol.value.activeRow}`;
108
121
  });
109
122
  }
110
123
  },
@@ -139,10 +152,8 @@ onMounted(() => {
139
152
  url = path;
140
153
  }
141
154
 
142
- activeRowCol.value = {
143
- col,
144
- row,
145
- };
155
+ activeRowCol.value.col = col;
156
+ activeRowCol.value.row = row;
146
157
 
147
158
  if (props.mode === 'development') {
148
159
  // 开发环境查看源码
@@ -185,6 +196,8 @@ onMounted(() => {
185
196
  margin-bottom: 4px;
186
197
  border-bottom: 1px solid var(--dev-tool-border-color);
187
198
  box-sizing: border-box;
199
+ white-space: nowrap;
200
+ overflow: auto;
188
201
  }
189
202
 
190
203
  .dev-tool-code-list {
package/dev/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { default as uniGlobalComponents } from './plugins/uniGlobalComponents/uniGlobalComponents';
2
- import { default as uniDevTool } from './plugins/uniDevTool/uniDevTool';
3
- export { uniDevTool, uniGlobalComponents };
4
- export default uniDevTool;
1
+ import { default as uniGlobalComponents } from './plugins/uniGlobalComponents/uniGlobalComponents';
2
+ import { default as uniDevTool } from './plugins/uniDevTool/uniDevTool';
3
+ export { uniDevTool, uniGlobalComponents };
4
+ export default uniDevTool;
5
5
  //# 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,72 +1,72 @@
1
- import { Plugin } from 'vite';
2
- /**
3
- * vite-uni-dev-tool 插件
4
- *
5
- * 自动在 main.ts 中注入调试插件,并在每个页面的模板中注入 DevTool 组件。
6
- *
7
- * 如果组件不是用 template 定义的,则不会被该插件添加。
8
- *
9
- *
10
- * @export
11
- * @param {{
12
- * pages: {
13
- * pages: {
14
- * path: string;
15
- * }[];
16
- * };
17
- * }} {
18
- * pages,
19
- * }
20
- * @return {*} {Plugin}
21
- */
22
- export default function uniDevTool({ pages, sourceFileServers, ...reset }: {
23
- /** 是否拦截Promise.reject 最好不要拦截 默认禁用 */
24
- enableInterceptPromiseReject?: boolean;
25
- /** 打开窗口时隐藏按钮 */
26
- openWindowHideButton?: boolean;
27
- /** 最大的console条数 */
28
- consoleMaxSize?: number;
29
- /** 最大的网络请求条数 */
30
- networkMaxSize?: number;
31
- /** 最大的上传文件条数 */
32
- uploadMaxSize?: number;
33
- /** 最大的套接字消息条数 */
34
- wsDataMaxSize?: number;
35
- /** 最大占用缓存空间 bytes */
36
- cacheMaxSize?: number;
37
- /** 按钮大小 */
38
- buttonSize?: number;
39
- /** 按钮文本 */
40
- buttonText?: string;
41
- /** 按钮文本颜色 */
42
- buttonColor?: string;
43
- /** 按钮字体大小 */
44
- buttonFontSize?: string;
45
- /** 按钮背景颜色 */
46
- buttonBackgroundColor?: string;
47
- /** 初始化时是否显示调试按钮,默认显示 */
48
- initShowDevTool?: boolean;
49
- /**
50
- * 该属性处于实验当中,谨慎使用
51
- * 读取开发环境 source file,source map,默认 禁用
52
- */
53
- useDevSource?: boolean;
54
- /**
55
- * 该属性处于实验当中,谨慎使用
56
- * 开发环境 source file 服务器地址,默认 [] ,配合 useDevSource 使用
57
- */
58
- sourceFileServers?: string[];
59
- /** 页面配置 用于读取路由 */
60
- pages: {
61
- pages: {
62
- path: string;
63
- }[];
64
- subPackages?: {
65
- root: string;
66
- pages: {
67
- path: string;
68
- }[];
69
- }[];
70
- };
71
- }): Plugin;
1
+ import { Plugin } from 'vite';
2
+ /**
3
+ * vite-uni-dev-tool 插件
4
+ *
5
+ * 自动在 main.ts 中注入调试插件,并在每个页面的模板中注入 DevTool 组件。
6
+ *
7
+ * 如果组件不是用 template 定义的,则不会被该插件添加。
8
+ *
9
+ *
10
+ * @export
11
+ * @param {{
12
+ * pages: {
13
+ * pages: {
14
+ * path: string;
15
+ * }[];
16
+ * };
17
+ * }} {
18
+ * pages,
19
+ * }
20
+ * @return {*} {Plugin}
21
+ */
22
+ export default function uniDevTool({ pages, sourceFileServers, ...reset }: {
23
+ /** 是否拦截Promise.reject 最好不要拦截 默认禁用 */
24
+ enableInterceptPromiseReject?: boolean;
25
+ /** 打开窗口时隐藏按钮 */
26
+ openWindowHideButton?: boolean;
27
+ /** 最大的console条数 */
28
+ consoleMaxSize?: number;
29
+ /** 最大的网络请求条数 */
30
+ networkMaxSize?: number;
31
+ /** 最大的上传文件条数 */
32
+ uploadMaxSize?: number;
33
+ /** 最大的套接字消息条数 */
34
+ wsDataMaxSize?: number;
35
+ /** 最大占用缓存空间 bytes */
36
+ cacheMaxSize?: number;
37
+ /** 按钮大小 */
38
+ buttonSize?: number;
39
+ /** 按钮文本 */
40
+ buttonText?: string;
41
+ /** 按钮文本颜色 */
42
+ buttonColor?: string;
43
+ /** 按钮字体大小 */
44
+ buttonFontSize?: string;
45
+ /** 按钮背景颜色 */
46
+ buttonBackgroundColor?: string;
47
+ /** 初始化时是否显示调试按钮,默认显示 */
48
+ initShowDevTool?: boolean;
49
+ /**
50
+ * 该属性处于实验当中,谨慎使用
51
+ * 读取开发环境 source file,source map,默认 禁用
52
+ */
53
+ useDevSource?: boolean;
54
+ /**
55
+ * 该属性处于实验当中,谨慎使用
56
+ * 开发环境 source file 服务器地址,默认 [] ,配合 useDevSource 使用
57
+ */
58
+ sourceFileServers?: string[];
59
+ /** 页面配置 用于读取路由 */
60
+ pages: {
61
+ pages: {
62
+ path: string;
63
+ }[];
64
+ subPackages?: {
65
+ root: string;
66
+ pages: {
67
+ path: string;
68
+ }[];
69
+ }[];
70
+ };
71
+ }): Plugin;
72
72
  //# sourceMappingURL=uniDevTool.d.ts.map
@@ -1,38 +1,38 @@
1
- "use strict";const I=require("path"),S=require("fs"),l=require("../utils/index.js");function C(a){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const u in a)if(u!=="default"){const e=Object.getOwnPropertyDescriptor(a,u);Object.defineProperty(d,u,e.get?e:{enumerable:!0,get:()=>a[u]})}}return d.default=a,Object.freeze(d)}const D=C(I),y=C(S),_=/<template[^>]*>([\s\S]*?)<\/template>/,h=/<script[^>]*>([\s\S]*?)<\/script>/,g={isReady:!1,urls:[]};function T({pages:a,sourceFileServers:d,...u}){return{name:"vite-uni-dev-tool",enforce:"pre",configureServer(e){var p;e.middlewares.use((s,n,t)=>{const{originalUrl:r}=s;if(u.useDevSource&&(r!=null&&r.includes("__dev_sourcefile__"))){const i=r.replace("/__dev_sourcefile__","");try{const c=e.config.root,m=D.join(c,i),o=y.readFileSync(m,"utf-8");n.setHeader("Content-Type",l.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=l.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=l.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=l.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=l.hasImportCurrentInstance(t),i=l.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: ${u.useDevSource},
21
- ...${JSON.stringify(u)},
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=l.hasImportConsole(e),m=l.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=e.match(_);let f=e;if(o&&o[1]){const $=`${o[1].trim()}
35
- ${i.join(`
36
- `)}`;f=e.replace(_,`<template>
37
- ${$}
38
- </template>`)}return{code:f,map:null}}}return{code:e,map:null}}}}module.exports=T;
1
+ "use strict";const I=require("path"),S=require("fs"),l=require("../utils/index.js");function C(a){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const u in a)if(u!=="default"){const e=Object.getOwnPropertyDescriptor(a,u);Object.defineProperty(d,u,e.get?e:{enumerable:!0,get:()=>a[u]})}}return d.default=a,Object.freeze(d)}const D=C(I),y=C(S),_=/<template[^>]*>([\s\S]*?)<\/template>/,h=/<script[^>]*>([\s\S]*?)<\/script>/,g={isReady:!1,urls:[]};function T({pages:a,sourceFileServers:d,...u}){return{name:"vite-uni-dev-tool",enforce:"pre",configureServer(e){var p;e.middlewares.use((s,n,t)=>{const{originalUrl:r}=s;if(u.useDevSource&&(r!=null&&r.includes("__dev_sourcefile__"))){const i=r.replace("/__dev_sourcefile__","");try{const c=e.config.root,m=D.join(c,i),o=y.readFileSync(m,"utf-8");n.setHeader("Content-Type",l.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=l.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=l.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=l.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=l.hasImportCurrentInstance(t),i=l.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: ${u.useDevSource},
21
+ ...${JSON.stringify(u)},
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=l.hasImportConsole(e),m=l.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=e.match(_);let f=e;if(o&&o[1]){const $=`${o[1].trim()}
35
+ ${i.join(`
36
+ `)}`;f=e.replace(_,`<template>
37
+ ${$}
38
+ </template>`)}return{code:f,map:null}}}return{code:e,map:null}}}}module.exports=T;
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-uni-dev-tool",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "vite-uni-dev-tool, debug, uni-app, 一处编写,到处调试",
5
5
  "keywords": [
6
6
  "vite",