stellar-ui-plus 1.23.14 → 1.23.16

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.
@@ -1,26 +1,26 @@
1
- import { onLoad } from '@dcloudio/uni-app';
2
-
3
- /**
4
- * 手动注册需要调试的变量。
5
- * 在需要调试的页面的 <script setup> 中调用此函数。
6
- *
7
- * @param data 包含需要调试的变量的对象。
8
- */
9
- export function useStellarDebug(data: Record<string, any>) {
10
- onLoad(() => {
11
- if (process.env.NODE_ENV !== 'development') {
12
- return;
13
- }
14
-
15
- const pages = getCurrentPages();
16
- if (!pages.length) return;
17
-
18
- const currentPage = pages[pages.length - 1];
19
- const route = currentPage.route;
20
-
21
- if (route && (globalThis as any).stellarDebugRegistry) {
22
- (globalThis as any).stellarDebugRegistry.set(route, data);
23
- console.log(`%c[StellarUI Debug] 成功为页面 ${route} 手动注册调试变量。`, 'color: #67C23A;');
24
- }
25
- });
26
- }
1
+ import { onLoad } from '@dcloudio/uni-app';
2
+
3
+ /**
4
+ * 手动注册需要调试的变量。
5
+ * 在需要调试的页面的 <script setup> 中调用此函数。
6
+ *
7
+ * @param data 包含需要调试的变量的对象。
8
+ */
9
+ export function useStellarDebug(data: Record<string, any>) {
10
+ onLoad(() => {
11
+ if (process.env.NODE_ENV !== 'development') {
12
+ return;
13
+ }
14
+
15
+ const pages = getCurrentPages();
16
+ if (!pages.length) return;
17
+
18
+ const currentPage = pages[pages.length - 1];
19
+ const route = currentPage.route;
20
+
21
+ if (route && (globalThis as any).stellarDebugRegistry) {
22
+ (globalThis as any).stellarDebugRegistry.set(route, data);
23
+ console.log(`%c[StellarUI Debug] 成功为页面 ${route} 手动注册调试变量。`, 'color: #67C23A;');
24
+ }
25
+ });
26
+ }
@@ -1,66 +1,66 @@
1
- import { parse, compileScript } from '@vue/compiler-sfc';
2
-
3
- export default function autoDebugPlugin(dirName) {
4
- return {
5
- name: 'vite-plugin-auto-debug',
6
- enforce: 'pre',
7
- transform(code, id) {
8
- const isPage = id.endsWith('.vue') && (id.includes('/src/pages/') || id.includes('/src/subPackages') || (dirName && id.includes(dirName)));
9
-
10
- if (!isPage) return null;
11
-
12
- const { descriptor } = parse(code);
13
-
14
- if (!descriptor.scriptSetup) {
15
- return null;
16
- }
17
-
18
- let scriptContent = descriptor.scriptSetup.content;
19
- let scriptLang = descriptor.scriptSetup.lang || 'js';
20
-
21
- const { bindings } = compileScript(descriptor, { id });
22
-
23
- if (!bindings) {
24
- return null;
25
- }
26
-
27
- const debugVars = Object.keys(bindings).filter(key => ['setup-ref', 'setup-reactive-const', 'setup-computed', 'setup-shallow-ref'].includes(bindings[key]));
28
-
29
- if (debugVars.length === 0) {
30
- return null;
31
- }
32
-
33
- const injectionCall = `
34
- import { useStellarDebug } from 'stellar-ui-plus/common/auto-debug/useStellarDebug';
35
- useStellarDebug({ ${debugVars.join(', ')} });
36
- `;
37
-
38
- let newScriptContent = scriptContent + injectionCall;
39
-
40
- let newCode = '';
41
-
42
- if (descriptor.template) {
43
- const attrs = Object.keys(descriptor.template.attrs)
44
- .map(key => `${key}="${key === 'lang' ? descriptor.template.attrs[key] : descriptor.template.attrs[key]}"`)
45
- .join(' ');
46
- newCode += `<template ${attrs ? ` ${attrs}` : ''}>\n${descriptor.template.content}\n</template>\n`;
47
- }
48
-
49
- newCode += `<script setup${scriptLang ? ` lang="${scriptLang}"` : ''}>\n${newScriptContent}\n</script>\n`;
50
-
51
- if (descriptor.styles) {
52
- descriptor.styles.forEach(style => {
53
- const attrs = Object.keys(style.attrs)
54
- .map(key => `${key}="${key === 'lang' ? style.attrs[key] : style.attrs[key]}"`)
55
- .join(' ');
56
- newCode += `<style${attrs ? ` ${attrs}` : ''}>\n${style.content}\n</style>\n`;
57
- });
58
- }
59
-
60
- return {
61
- code: newCode,
62
- map: null,
63
- };
64
- },
65
- };
66
- }
1
+ import { parse, compileScript } from '@vue/compiler-sfc';
2
+
3
+ export default function autoDebugPlugin(dirName) {
4
+ return {
5
+ name: 'vite-plugin-auto-debug',
6
+ enforce: 'pre',
7
+ transform(code, id) {
8
+ const isPage = id.endsWith('.vue') && (id.includes('/src/pages/') || id.includes('/src/subPackages') || (dirName && id.includes(dirName)));
9
+
10
+ if (!isPage) return null;
11
+
12
+ const { descriptor } = parse(code);
13
+
14
+ if (!descriptor.scriptSetup) {
15
+ return null;
16
+ }
17
+
18
+ let scriptContent = descriptor.scriptSetup.content;
19
+ let scriptLang = descriptor.scriptSetup.lang || 'js';
20
+
21
+ const { bindings } = compileScript(descriptor, { id });
22
+
23
+ if (!bindings) {
24
+ return null;
25
+ }
26
+
27
+ const debugVars = Object.keys(bindings).filter(key => ['setup-ref', 'setup-reactive-const', 'setup-computed', 'setup-shallow-ref'].includes(bindings[key]));
28
+
29
+ if (debugVars.length === 0) {
30
+ return null;
31
+ }
32
+
33
+ const injectionCall = `
34
+ import { useStellarDebug } from 'stellar-ui-plus/common/auto-debug/useStellarDebug';
35
+ useStellarDebug({ ${debugVars.join(', ')} });
36
+ `;
37
+
38
+ let newScriptContent = scriptContent + injectionCall;
39
+
40
+ let newCode = '';
41
+
42
+ if (descriptor.template) {
43
+ const attrs = Object.keys(descriptor.template.attrs)
44
+ .map(key => `${key}="${key === 'lang' ? descriptor.template.attrs[key] : descriptor.template.attrs[key]}"`)
45
+ .join(' ');
46
+ newCode += `<template ${attrs ? ` ${attrs}` : ''}>\n${descriptor.template.content}\n</template>\n`;
47
+ }
48
+
49
+ newCode += `<script setup${scriptLang ? ` lang="${scriptLang}"` : ''}>\n${newScriptContent}\n</script>\n`;
50
+
51
+ if (descriptor.styles) {
52
+ descriptor.styles.forEach(style => {
53
+ const attrs = Object.keys(style.attrs)
54
+ .map(key => `${key}="${key === 'lang' ? style.attrs[key] : style.attrs[key]}"`)
55
+ .join(' ');
56
+ newCode += `<style${attrs ? ` ${attrs}` : ''}>\n${style.content}\n</style>\n`;
57
+ });
58
+ }
59
+
60
+ return {
61
+ code: newCode,
62
+ map: null,
63
+ };
64
+ },
65
+ };
66
+ }