@movk/nuxt 1.6.0 → 1.7.0
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/dist/module.d.mts +15 -13
- package/dist/module.json +1 -1
- package/dist/module.mjs +54 -5
- package/dist/runtime/components/theme-picker/ThemePicker.vue +0 -30
- package/dist/runtime/composables/useTheme.d.ts +0 -3
- package/dist/runtime/composables/useTheme.js +3 -27
- package/dist/runtime/domains/theme/theme-font.d.ts +28 -13
- package/dist/runtime/domains/theme/theme-font.js +40 -21
- package/dist/runtime/index.css +1 -1
- package/dist/runtime/plugins/theme.js +0 -23
- package/dist/runtime/utils/theme-defaults.d.ts +0 -5
- package/dist/runtime/utils/theme-defaults.js +1 -13
- package/dist/shared/{nuxt.DJKBap-S.mjs → nuxt.BT5mXYjs.mjs} +81 -11
- package/dist/unplugin.d.mts +2 -1
- package/dist/unplugin.mjs +30 -1
- package/dist/vite.d.mts +1 -0
- package/dist/vite.mjs +3 -1
- package/package.json +12 -13
package/dist/module.d.mts
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
import { MovkApiFullConfig } from '../dist/runtime/types/api/module.js';
|
|
3
|
+
import { MovkFontFamily, ThemeFontOption } from '../dist/runtime/domains/theme/theme-font.js';
|
|
3
4
|
import { ModuleOptions as ModuleOptions$1 } from '@nuxt/ui';
|
|
4
5
|
export * from '../dist/runtime/types/index.js';
|
|
5
6
|
|
|
6
|
-
interface ThemeFontConfig {
|
|
7
|
-
/** 字体名称 */
|
|
8
|
-
name: string;
|
|
9
|
-
/**
|
|
10
|
-
* 字体 CSS 文件的完整 URL;未提供时运行时回退到 Google Fonts URL
|
|
11
|
-
* @example 'https://cdn.mhaibaraai.cn/fonts/alibaba-puhuiti.css'
|
|
12
|
-
*/
|
|
13
|
-
href?: string;
|
|
14
|
-
}
|
|
15
7
|
type StrictUiTheme = {
|
|
16
8
|
[K in keyof NonNullable<ModuleOptions$1['theme']>]?: Exclude<NonNullable<ModuleOptions$1['theme']>[K], null>;
|
|
17
9
|
};
|
|
@@ -23,6 +15,16 @@ interface ModuleOptions {
|
|
|
23
15
|
prefix?: string;
|
|
24
16
|
/** API 模块配置 */
|
|
25
17
|
api?: MovkApiFullConfig;
|
|
18
|
+
/** 图标模块配置 */
|
|
19
|
+
icon?: {
|
|
20
|
+
/**
|
|
21
|
+
* 是否把 movk 组件与内置图标集用到的图标注入 `@nuxt/icon` 的构建期图标包。
|
|
22
|
+
* 关闭后这些图标改为运行时按需请求
|
|
23
|
+
* @defaultValue true
|
|
24
|
+
* @see https://ui.nuxt.com/docs/getting-started/integrations/icons/nuxt
|
|
25
|
+
*/
|
|
26
|
+
clientBundle?: boolean;
|
|
27
|
+
};
|
|
26
28
|
/** 主题模块配置 */
|
|
27
29
|
theme?: {
|
|
28
30
|
/**
|
|
@@ -50,13 +52,13 @@ interface ModuleOptions {
|
|
|
50
52
|
*/
|
|
51
53
|
prefix?: StrictUiTheme['prefix'];
|
|
52
54
|
/**
|
|
53
|
-
*
|
|
55
|
+
* 全局字体。内置字体给名字即可,模块在构建期注入样式表与带中文回退栈的 `--font-sans`;
|
|
56
|
+
* 自托管字体用 `{ name, href }` 形式补上入口 CSS 地址。
|
|
54
57
|
* 缺省时不注入 `--font-sans`,字体由项目 CSS 的 `@theme` 决定
|
|
55
58
|
* @example 'Alibaba PuHuiTi'
|
|
59
|
+
* @see https://github.com/mhaibaraai/movk-fonts
|
|
56
60
|
*/
|
|
57
|
-
font?: string;
|
|
58
|
-
/** ThemePicker 字体可选项;提供时完整替换内置列表 */
|
|
59
|
-
fonts?: ThemeFontConfig[];
|
|
61
|
+
font?: MovkFontFamily | (string & {}) | ThemeFontOption;
|
|
60
62
|
/**
|
|
61
63
|
* 默认圆角(单位 rem)。缺省时不注入 `--ui-radius`,
|
|
62
64
|
* 沿用 `@nuxt/ui` 的默认值或项目 CSS 的声明
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,15 +1,35 @@
|
|
|
1
|
-
import { addPlugin, defineNuxtModule, createResolver, addComponentsDir, addImportsDir } from '@nuxt/kit';
|
|
1
|
+
import { resolveAlias, useLogger, addPlugin, defineNuxtModule, createResolver, addComponentsDir, addImportsDir } from '@nuxt/kit';
|
|
2
2
|
import defu, { defu as defu$1 } from 'defu';
|
|
3
|
-
import { U as UI_COMPONENTS, a as addTemplates } from './shared/nuxt.
|
|
3
|
+
import { U as UI_COMPONENTS, r as resolveMovkIcons, f as formatMissingCollections, a as addTemplates } from './shared/nuxt.BT5mXYjs.mjs';
|
|
4
4
|
import { getPackageJsonMetadata } from '../dist/runtime/utils/meta.js';
|
|
5
5
|
import { kebabCase } from 'scule';
|
|
6
6
|
import { updateSiteConfig } from 'nuxt-site-config/kit';
|
|
7
|
+
import { readFile } from 'node:fs/promises';
|
|
7
8
|
import { getDefaultConfig } from '../dist/runtime/utils/theme-defaults.js';
|
|
9
|
+
import { resolveFontSource, resolveFontLinks, resolveFontWarning } from '../dist/runtime/domains/theme/theme-font.js';
|
|
8
10
|
export * from '../dist/runtime/types/index.js';
|
|
9
11
|
import 'node:url';
|
|
12
|
+
import 'node:fs';
|
|
13
|
+
import 'node:module';
|
|
14
|
+
import 'pathe';
|
|
15
|
+
import 'tinyglobby';
|
|
10
16
|
|
|
11
17
|
const name = "@movk/nuxt";
|
|
12
|
-
const version = "1.
|
|
18
|
+
const version = "1.7.0";
|
|
19
|
+
|
|
20
|
+
const MOVK_CSS_IMPORT = /@import\s+["']@movk\/nuxt["']/;
|
|
21
|
+
async function checkMovkCss(nuxt) {
|
|
22
|
+
for (const entry of nuxt.options.css || []) {
|
|
23
|
+
if (entry === "@movk/nuxt") return;
|
|
24
|
+
try {
|
|
25
|
+
if (MOVK_CSS_IMPORT.test(await readFile(resolveAlias(entry), "utf-8"))) return;
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
useLogger("movk").warn(
|
|
30
|
+
'Movk styles are not imported. Add `@import "@movk/nuxt";` after `@import "tailwindcss";` in your main CSS file, and register that file in `nuxt.config.ts` under `css`.'
|
|
31
|
+
);
|
|
32
|
+
}
|
|
13
33
|
|
|
14
34
|
function getDefaultApiConfig(apiConfig) {
|
|
15
35
|
const publicEndpoints = {};
|
|
@@ -75,6 +95,9 @@ const defaultOptions = {
|
|
|
75
95
|
prefix: "M",
|
|
76
96
|
theme: {
|
|
77
97
|
enabled: true
|
|
98
|
+
},
|
|
99
|
+
icon: {
|
|
100
|
+
clientBundle: true
|
|
78
101
|
}
|
|
79
102
|
};
|
|
80
103
|
|
|
@@ -85,6 +108,7 @@ function addTheme(nuxt, resolve, theme) {
|
|
|
85
108
|
{ charset: "utf-8" },
|
|
86
109
|
{ name: "viewport", content: "width=device-width, initial-scale=1" }
|
|
87
110
|
);
|
|
111
|
+
addFontLinks(nuxt, theme?.font);
|
|
88
112
|
nuxt.options.app.head.htmlAttrs = defu(nuxt.options.app.head.htmlAttrs || {}, {
|
|
89
113
|
dir: "ltr"
|
|
90
114
|
});
|
|
@@ -111,6 +135,17 @@ function addTheme(nuxt, resolve, theme) {
|
|
|
111
135
|
mode: "all"
|
|
112
136
|
});
|
|
113
137
|
}
|
|
138
|
+
function addFontLinks(nuxt, font) {
|
|
139
|
+
const source = resolveFontSource(font);
|
|
140
|
+
if (!source) return;
|
|
141
|
+
const links = resolveFontLinks(source);
|
|
142
|
+
if (!links.length) {
|
|
143
|
+
useLogger("movk").warn(resolveFontWarning(source.name));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
nuxt.options.app.head.link = nuxt.options.app.head.link || [];
|
|
147
|
+
nuxt.options.app.head.link.push(...links);
|
|
148
|
+
}
|
|
114
149
|
|
|
115
150
|
const module$1 = defineNuxtModule({
|
|
116
151
|
meta: {
|
|
@@ -131,8 +166,6 @@ const module$1 = defineNuxtModule({
|
|
|
131
166
|
const { resolve } = createResolver(import.meta.url);
|
|
132
167
|
nuxt.options.movk = options;
|
|
133
168
|
nuxt.options.alias["#movk"] = resolve("./runtime");
|
|
134
|
-
nuxt.options.css = nuxt.options.css || [];
|
|
135
|
-
nuxt.options.css.unshift(resolve("runtime/index.css"));
|
|
136
169
|
const movkUiDeps = UI_COMPONENTS.map((name2) => name2.slice(1));
|
|
137
170
|
const uiOptions = nuxt.options;
|
|
138
171
|
const ui = uiOptions.ui ??= {};
|
|
@@ -154,6 +187,21 @@ const module$1 = defineNuxtModule({
|
|
|
154
187
|
ignore: componentIgnore
|
|
155
188
|
});
|
|
156
189
|
addImportsDir(resolve("runtime/composables"));
|
|
190
|
+
if (options.icon?.clientBundle !== false) {
|
|
191
|
+
nuxt.hook("icon:clientBundleIcons", (icons) => {
|
|
192
|
+
const { icons: bundled, missing } = resolveMovkIcons(resolve("runtime"), {
|
|
193
|
+
theme: options.theme?.enabled !== false,
|
|
194
|
+
paths: [nuxt.options.rootDir, nuxt.options.workspaceDir].filter(Boolean)
|
|
195
|
+
});
|
|
196
|
+
for (const icon of bundled) {
|
|
197
|
+
icons.add(icon);
|
|
198
|
+
}
|
|
199
|
+
const logger = useLogger("movk");
|
|
200
|
+
const { warn, debug } = formatMissingCollections(missing);
|
|
201
|
+
if (warn) logger.warn(warn);
|
|
202
|
+
if (debug) logger.debug(debug);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
157
205
|
const apiConfig = options.api ?? {};
|
|
158
206
|
if (apiConfig.enabled !== false) {
|
|
159
207
|
const { publicConfig, privateConfig } = getDefaultApiConfig(apiConfig);
|
|
@@ -178,6 +226,7 @@ const module$1 = defineNuxtModule({
|
|
|
178
226
|
options.theme = defu$1(options.theme || {}, themeDefaults);
|
|
179
227
|
addTheme(nuxt, resolve, options.theme);
|
|
180
228
|
await addTemplates(options, nuxt);
|
|
229
|
+
await checkMovkCss(nuxt);
|
|
181
230
|
});
|
|
182
231
|
nuxt.hook("prepare:types", ({ references }) => {
|
|
183
232
|
references.push({ path: resolve("./runtime/types/app.config.d.ts") });
|
|
@@ -30,8 +30,6 @@ const {
|
|
|
30
30
|
setBlackAsPrimary,
|
|
31
31
|
radiuses,
|
|
32
32
|
radius,
|
|
33
|
-
fonts,
|
|
34
|
-
font,
|
|
35
33
|
icon,
|
|
36
34
|
icons,
|
|
37
35
|
modes,
|
|
@@ -150,34 +148,6 @@ const {
|
|
|
150
148
|
</div>
|
|
151
149
|
</fieldset>
|
|
152
150
|
|
|
153
|
-
<fieldset>
|
|
154
|
-
<legend class="text-[11px] leading-none font-semibold mb-2 select-none flex items-center gap-1">
|
|
155
|
-
Font
|
|
156
|
-
|
|
157
|
-
<UButton
|
|
158
|
-
to="https://ui.nuxt.com/docs/getting-started/integrations/fonts"
|
|
159
|
-
size="xs"
|
|
160
|
-
color="neutral"
|
|
161
|
-
variant="link"
|
|
162
|
-
icon="i-lucide-help-circle"
|
|
163
|
-
class="p-0 -my-0.5"
|
|
164
|
-
:ui="{ leadingIcon: 'size-3' }"
|
|
165
|
-
/>
|
|
166
|
-
</legend>
|
|
167
|
-
|
|
168
|
-
<div class="-mx-2">
|
|
169
|
-
<USelect
|
|
170
|
-
v-model="font"
|
|
171
|
-
size="sm"
|
|
172
|
-
color="neutral"
|
|
173
|
-
icon="i-lucide-type"
|
|
174
|
-
:items="fonts"
|
|
175
|
-
class="w-full ring-default rounded-sm hover:bg-elevated/50 text-[11px] data-[state=open]:bg-elevated/50"
|
|
176
|
-
:ui="{ trailingIcon: 'group-data-[state=open]:rotate-180 transition-transform duration-200' }"
|
|
177
|
-
/>
|
|
178
|
-
</div>
|
|
179
|
-
</fieldset>
|
|
180
|
-
|
|
181
151
|
<fieldset>
|
|
182
152
|
<legend class="text-[11px] leading-none font-semibold mb-2 select-none flex items-center gap-1">
|
|
183
153
|
Icons
|
|
@@ -6,7 +6,6 @@ export declare function useTheme(): {
|
|
|
6
6
|
id: string;
|
|
7
7
|
tagPriority: number;
|
|
8
8
|
}[];
|
|
9
|
-
link: import("vue").ComputedRef<import("../domains/theme/theme-font").ThemeFontLink[]>;
|
|
10
9
|
neutralColors: string[];
|
|
11
10
|
neutral: import("vue").WritableComputedRef<string, string>;
|
|
12
11
|
primaryColors: string[];
|
|
@@ -15,8 +14,6 @@ export declare function useTheme(): {
|
|
|
15
14
|
setBlackAsPrimary: (value: boolean) => void;
|
|
16
15
|
radiuses: number[];
|
|
17
16
|
radius: import("vue").WritableComputedRef<number, number>;
|
|
18
|
-
fonts: string[];
|
|
19
|
-
font: import("vue").WritableComputedRef<string, string>;
|
|
20
17
|
icon: import("vue").WritableComputedRef<IconSet, IconSet>;
|
|
21
18
|
icons: {
|
|
22
19
|
label: string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useAppConfig, useColorMode, useSiteConfig } from "#imports";
|
|
2
2
|
import { resolveThemeIcons, themeIcons } from "../domains/theme/theme-icons.js";
|
|
3
|
-
import { resolveActiveFont, resolveFontLinks, resolveFontStyle } from "../domains/theme/theme-font.js";
|
|
4
3
|
import { resolveActiveRadius, resolveRadiusStyle } from "../domains/theme/theme-radius.js";
|
|
5
4
|
import { omit, kebabCase } from "@movk/core";
|
|
6
5
|
import { useLocalStorage } from "@vueuse/core";
|
|
@@ -15,12 +14,8 @@ export function useTheme() {
|
|
|
15
14
|
const color = computed(() => colorMode.value === "dark" ? colors[ui.colors.neutral][900] : "white");
|
|
16
15
|
const defaultConfig = getDefaultConfig();
|
|
17
16
|
const _radius = useLocalStorage(`${name}-ui-radius`, null, { writeDefaults: false });
|
|
18
|
-
const _font = useLocalStorage(`${name}-ui-font`, "", { writeDefaults: false });
|
|
19
17
|
const _iconSet = useLocalStorage(`${name}-ui-icons`, movk?.icons ?? defaultConfig.icons);
|
|
20
18
|
const _blackAsPrimary = useLocalStorage(`${name}-ui-black-as-primary`, defaultConfig.blackAsPrimary);
|
|
21
|
-
const pickerFonts = movk?.picker?.fonts ?? [];
|
|
22
|
-
const configuredFont = movk?.font ?? defaultConfig.font;
|
|
23
|
-
const activeFont = computed(() => resolveActiveFont(_font.value, configuredFont));
|
|
24
19
|
const configuredRadius = movk?.radius ?? defaultConfig.radius;
|
|
25
20
|
const activeRadius = computed(() => resolveActiveRadius(_radius.value, configuredRadius));
|
|
26
21
|
const neutralColors = movk?.picker?.neutralColors ?? [];
|
|
@@ -54,15 +49,6 @@ export function useTheme() {
|
|
|
54
49
|
_radius.value = option;
|
|
55
50
|
}
|
|
56
51
|
});
|
|
57
|
-
const fonts = pickerFonts.map((f) => f.name);
|
|
58
|
-
const font = computed({
|
|
59
|
-
get() {
|
|
60
|
-
return activeFont.value;
|
|
61
|
-
},
|
|
62
|
-
set(option) {
|
|
63
|
-
_font.value = option;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
52
|
const icons = [
|
|
67
53
|
{ label: "Lucide", icon: "i-lucide-feather", value: "lucide" },
|
|
68
54
|
{ label: "Phosphor", icon: "i-ph-phosphor-logo", value: "phosphor" },
|
|
@@ -96,15 +82,12 @@ export function useTheme() {
|
|
|
96
82
|
}
|
|
97
83
|
const radiusStyle = computed(() => resolveRadiusStyle(activeRadius.value));
|
|
98
84
|
const blackAsPrimaryStyle = computed(() => _blackAsPrimary.value ? `:root { --ui-primary: black; } .dark { --ui-primary: white; }` : ":root {}");
|
|
99
|
-
const fontStyle = computed(() => resolveFontStyle(activeFont.value));
|
|
100
|
-
const link = computed(() => resolveFontLinks(activeFont.value, pickerFonts));
|
|
101
85
|
const style = [
|
|
102
86
|
{ innerHTML: radiusStyle, id: `nuxt-ui-radius`, tagPriority: -2 },
|
|
103
|
-
{ innerHTML: blackAsPrimaryStyle, id: `nuxt-ui-black-as-primary`, tagPriority: -2 }
|
|
104
|
-
{ innerHTML: fontStyle, id: `nuxt-ui-font`, tagPriority: -2 }
|
|
87
|
+
{ innerHTML: blackAsPrimaryStyle, id: `nuxt-ui-black-as-primary`, tagPriority: -2 }
|
|
105
88
|
];
|
|
106
89
|
const hasCSSChanges = computed(() => {
|
|
107
|
-
return activeRadius.value !== configuredRadius || _blackAsPrimary.value
|
|
90
|
+
return activeRadius.value !== configuredRadius || _blackAsPrimary.value;
|
|
108
91
|
});
|
|
109
92
|
const hasConfigChanges = computed(() => {
|
|
110
93
|
return ui.colors.primary !== "blue" || ui.colors.neutral !== "slate" || _iconSet.value !== (movk?.icons ?? defaultConfig.icons);
|
|
@@ -112,11 +95,8 @@ export function useTheme() {
|
|
|
112
95
|
function exportCSS() {
|
|
113
96
|
const lines = [
|
|
114
97
|
'@import "tailwindcss";',
|
|
115
|
-
'@import "@nuxt
|
|
98
|
+
'@import "@movk/nuxt";'
|
|
116
99
|
];
|
|
117
|
-
if (activeFont.value && activeFont.value !== configuredFont) {
|
|
118
|
-
lines.push("", "@theme {", ` --font-sans: ${JSON.stringify(activeFont.value)}, sans-serif;`, "}");
|
|
119
|
-
}
|
|
120
100
|
const rootLines = [];
|
|
121
101
|
if (activeRadius.value !== void 0 && activeRadius.value !== configuredRadius) {
|
|
122
102
|
rootLines.push(` --ui-radius: ${activeRadius.value}rem;`);
|
|
@@ -168,7 +148,6 @@ export function useTheme() {
|
|
|
168
148
|
ui.colors.neutral = defaultNeutral;
|
|
169
149
|
window.localStorage.removeItem(`${name}-ui-neutral`);
|
|
170
150
|
_radius.value = null;
|
|
171
|
-
_font.value = "";
|
|
172
151
|
_iconSet.value = defaultIcon;
|
|
173
152
|
ui.icons = resolveThemeIcons(defaultIcon, ui.icons);
|
|
174
153
|
_blackAsPrimary.value = movk?.blackAsPrimary ?? defaultConfig.blackAsPrimary;
|
|
@@ -176,7 +155,6 @@ export function useTheme() {
|
|
|
176
155
|
return {
|
|
177
156
|
color,
|
|
178
157
|
style,
|
|
179
|
-
link,
|
|
180
158
|
neutralColors,
|
|
181
159
|
neutral,
|
|
182
160
|
primaryColors,
|
|
@@ -185,8 +163,6 @@ export function useTheme() {
|
|
|
185
163
|
setBlackAsPrimary,
|
|
186
164
|
radiuses,
|
|
187
165
|
radius,
|
|
188
|
-
fonts,
|
|
189
|
-
font,
|
|
190
166
|
icon,
|
|
191
167
|
icons,
|
|
192
168
|
modes,
|
|
@@ -1,29 +1,44 @@
|
|
|
1
1
|
export interface ThemeFontOption {
|
|
2
|
+
/** `@font-face` 声明的 `font-family`,须与字体样式表逐字一致 */
|
|
2
3
|
name: string;
|
|
4
|
+
/** 字体样式表地址;内置字体可省略,自托管字体填入口 CSS 的路径 */
|
|
3
5
|
href?: string;
|
|
4
6
|
}
|
|
5
7
|
export type ThemeFontLink = {
|
|
8
|
+
rel: 'preconnect';
|
|
9
|
+
href: string;
|
|
10
|
+
crossorigin: '';
|
|
11
|
+
} | {
|
|
6
12
|
rel: 'stylesheet';
|
|
7
13
|
href: string;
|
|
8
14
|
id: string;
|
|
9
15
|
};
|
|
10
|
-
|
|
16
|
+
/**
|
|
17
|
+
* cdn.mhaibaraai.cn 提供的字体,key 即 `@font-face` 的 `font-family`。
|
|
18
|
+
* 新增字体须同时更新 movk-fonts 仓库的 `scripts/fonts.config.ts`,两处的名字必须逐字相同。
|
|
19
|
+
* @see https://github.com/mhaibaraai/movk-fonts
|
|
20
|
+
*/
|
|
21
|
+
export declare const MOVK_FONTS: {
|
|
22
|
+
readonly 'Alibaba PuHuiTi': "https://cdn.mhaibaraai.cn/fonts/alibaba-puhuiti.css";
|
|
23
|
+
readonly 'OPPO Sans': "https://cdn.mhaibaraai.cn/fonts/oppo-sans.css";
|
|
24
|
+
};
|
|
25
|
+
export type MovkFontFamily = keyof typeof MOVK_FONTS;
|
|
11
26
|
export declare function resolveFontId(name: string): string;
|
|
12
27
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
28
|
+
* 归一化 `theme.font`:字符串按内置清单查地址,对象形式用于自托管字体。
|
|
29
|
+
* 未登记且未给 `href` 的名字仍会产出 `--font-sans` 但不发请求——
|
|
30
|
+
* 其 `@font-face` 由项目自己提供,模块无从猜测来源。
|
|
15
31
|
*/
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function resolveFontLinks(name: string | undefined, fonts: ThemeFontOption[]): ThemeFontLink[];
|
|
32
|
+
export declare function resolveFontSource(font?: string | ThemeFontOption): ThemeFontOption | undefined;
|
|
18
33
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
34
|
+
* 构建期写入 `<head>` 的字体资源。preconnect 必须带 `crossorigin`:
|
|
35
|
+
* woff2 经 CSS 加载是 anonymous CORS 请求,属性不匹配的预热连接不会被复用。
|
|
21
36
|
*/
|
|
22
|
-
export declare function
|
|
37
|
+
export declare function resolveFontLinks(source?: ThemeFontOption): ThemeFontLink[];
|
|
23
38
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
39
|
+
* 未登记且未给 `href` 的字体只注入 `--font-sans`、不发请求时的提示。
|
|
40
|
+
* 两种模式共用同一份文案;不含前缀,由调用方按各自的 logger 补。
|
|
26
41
|
*/
|
|
27
|
-
export declare function
|
|
28
|
-
/**
|
|
29
|
-
export declare function
|
|
42
|
+
export declare function resolveFontWarning(name: string): string;
|
|
43
|
+
/** 拼接 `--font-sans` 的取值:首选字体在前,系统中文字体兜底在后 */
|
|
44
|
+
export declare function resolveFontFamily(name: string): string;
|
|
@@ -1,29 +1,48 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export const MOVK_FONTS = {
|
|
2
|
+
"Alibaba PuHuiTi": "https://cdn.mhaibaraai.cn/fonts/alibaba-puhuiti.css",
|
|
3
|
+
"OPPO Sans": "https://cdn.mhaibaraai.cn/fonts/oppo-sans.css"
|
|
4
|
+
};
|
|
5
|
+
const FALLBACK_STACK = [
|
|
6
|
+
"ui-sans-serif",
|
|
7
|
+
"system-ui",
|
|
8
|
+
"-apple-system",
|
|
9
|
+
'"PingFang SC"',
|
|
10
|
+
'"Hiragino Sans GB"',
|
|
11
|
+
'"Microsoft YaHei"',
|
|
12
|
+
'"Noto Sans CJK SC"',
|
|
13
|
+
"sans-serif"
|
|
14
|
+
];
|
|
4
15
|
export function resolveFontId(name) {
|
|
5
16
|
return `font-${name.toLowerCase().replace(/\s+/g, "-")}`;
|
|
6
17
|
}
|
|
7
|
-
export function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
18
|
+
export function resolveFontSource(font) {
|
|
19
|
+
if (typeof font === "string") {
|
|
20
|
+
if (!font) return void 0;
|
|
21
|
+
const href = MOVK_FONTS[font];
|
|
22
|
+
return href ? { name: font, href } : { name: font };
|
|
23
|
+
}
|
|
24
|
+
if (!font?.name) return void 0;
|
|
25
|
+
return font.href ? { name: font.name, href: font.href } : { name: font.name };
|
|
11
26
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
27
|
+
function resolveOrigin(href) {
|
|
28
|
+
try {
|
|
29
|
+
return new URL(href).origin;
|
|
30
|
+
} catch {
|
|
31
|
+
return void 0;
|
|
32
|
+
}
|
|
17
33
|
}
|
|
18
|
-
export function
|
|
19
|
-
if (!
|
|
20
|
-
|
|
34
|
+
export function resolveFontLinks(source) {
|
|
35
|
+
if (!source?.href) return [];
|
|
36
|
+
const origin = resolveOrigin(source.href);
|
|
37
|
+
const preconnect = origin ? [{ rel: "preconnect", href: origin, crossorigin: "" }] : [];
|
|
38
|
+
return [
|
|
39
|
+
...preconnect,
|
|
40
|
+
{ rel: "stylesheet", href: source.href, id: resolveFontId(source.name) }
|
|
41
|
+
];
|
|
21
42
|
}
|
|
22
|
-
export function
|
|
23
|
-
return
|
|
43
|
+
export function resolveFontWarning(name) {
|
|
44
|
+
return `Font "${name}" is not a built-in family and has no href, so only --font-sans is injected and no stylesheet is loaded. Use a built-in family name, or pass { name, href } with the stylesheet URL.`;
|
|
24
45
|
}
|
|
25
|
-
export function
|
|
26
|
-
return
|
|
27
|
-
fonts.map((f) => [f.name, f.href ?? googleFontsHref(f.name)])
|
|
28
|
-
);
|
|
46
|
+
export function resolveFontFamily(name) {
|
|
47
|
+
return [JSON.stringify(name), ...FALLBACK_STACK].join(", ");
|
|
29
48
|
}
|
package/dist/runtime/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@import "
|
|
1
|
+
@import "@nuxt/ui";@import "#build/movk-ui.css";@source "./components";@layer base{[role=button]:not(:disabled),button:not(:disabled){cursor:pointer}}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { kebabCase } from "@movk/core";
|
|
2
2
|
import { defineNuxtPlugin, useAppConfig, useHead, useSiteConfig } from "#imports";
|
|
3
3
|
import { resolveThemeIcons } from "../domains/theme/theme-icons.js";
|
|
4
|
-
import { resolveFontHrefMap } from "../domains/theme/theme-font.js";
|
|
5
4
|
export default defineNuxtPlugin({
|
|
6
5
|
enforce: "post",
|
|
7
6
|
setup() {
|
|
@@ -17,8 +16,6 @@ export default defineNuxtPlugin({
|
|
|
17
16
|
if (icons) appConfig.ui.icons = resolveThemeIcons(icons, appConfig.ui.icons);
|
|
18
17
|
}
|
|
19
18
|
if (import.meta.server) {
|
|
20
|
-
const pickerFonts = appConfig.movk?.picker?.fonts ?? [];
|
|
21
|
-
const fontHrefMapJson = JSON.stringify(resolveFontHrefMap(pickerFonts));
|
|
22
19
|
useHead({
|
|
23
20
|
script: [{
|
|
24
21
|
innerHTML: `
|
|
@@ -78,26 +75,6 @@ export default defineNuxtPlugin({
|
|
|
78
75
|
document.documentElement.style.setProperty('--ui-primary', isDark ? 'white' : 'black');
|
|
79
76
|
}
|
|
80
77
|
`.replace(/\s+/g, " ")
|
|
81
|
-
}, {
|
|
82
|
-
innerHTML: [
|
|
83
|
-
`var font = localStorage.getItem('${name}-ui-font');`,
|
|
84
|
-
`if (font) {`,
|
|
85
|
-
`var fontEl = document.querySelector('style#nuxt-ui-font');`,
|
|
86
|
-
// textContent 而非 innerHTML:字体名来自 localStorage,避免被当作标记解析
|
|
87
|
-
`if (fontEl) { fontEl.textContent = ':root { --font-sans: ' + JSON.stringify(font) + ', sans-serif; }'; }`,
|
|
88
|
-
`var fontMap = ${fontHrefMapJson};`,
|
|
89
|
-
`var href = fontMap[font];`,
|
|
90
|
-
`var id = 'font-' + font.toLowerCase().replace(/\\s+/g, '-');`,
|
|
91
|
-
// 未登记的字体不猜测来源;已由 SSR 输出的 link 不重复插入
|
|
92
|
-
`if (href && !document.getElementById(id)) {`,
|
|
93
|
-
`var lnk = document.createElement('link');`,
|
|
94
|
-
`lnk.rel = 'stylesheet';`,
|
|
95
|
-
`lnk.href = href;`,
|
|
96
|
-
`lnk.id = id;`,
|
|
97
|
-
`document.head.appendChild(lnk);`,
|
|
98
|
-
`}`,
|
|
99
|
-
`}`
|
|
100
|
-
].join(" ")
|
|
101
78
|
}]
|
|
102
79
|
});
|
|
103
80
|
}
|
|
@@ -8,7 +8,6 @@ export declare function getDefaultConfig(theme?: ModuleOptions['theme']): {
|
|
|
8
8
|
dir: Direction;
|
|
9
9
|
radius: number | undefined;
|
|
10
10
|
blackAsPrimary: boolean;
|
|
11
|
-
font: string;
|
|
12
11
|
icons: string;
|
|
13
12
|
prefix: string | undefined;
|
|
14
13
|
tv: {
|
|
@@ -17,10 +16,6 @@ export declare function getDefaultConfig(theme?: ModuleOptions['theme']): {
|
|
|
17
16
|
};
|
|
18
17
|
};
|
|
19
18
|
picker: {
|
|
20
|
-
fonts: {
|
|
21
|
-
name: string;
|
|
22
|
-
href?: string;
|
|
23
|
-
}[];
|
|
24
19
|
radiuses: number[];
|
|
25
20
|
neutralColors: string[];
|
|
26
21
|
};
|
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
export function getDefaultConfig(theme) {
|
|
2
|
-
const pickerFonts = theme?.fonts ?? [
|
|
3
|
-
{ name: "Alibaba PuHuiTi", href: "https://cdn.mhaibaraai.cn/fonts/alibaba-puhuiti.css" },
|
|
4
|
-
{ name: "Public Sans" },
|
|
5
|
-
{ name: "DM Sans" },
|
|
6
|
-
{ name: "Geist" },
|
|
7
|
-
{ name: "Inter" },
|
|
8
|
-
{ name: "Poppins" },
|
|
9
|
-
{ name: "Outfit" },
|
|
10
|
-
{ name: "Raleway" }
|
|
11
|
-
];
|
|
12
2
|
const pickerRadiuses = theme?.radiuses ?? [0, 0.125, 0.25, 0.375, 0.5];
|
|
13
3
|
const pickerNeutralColors = theme?.neutralColors ?? ["slate", "gray", "zinc", "neutral", "stone", "taupe", "mauve", "mist", "olive"];
|
|
14
4
|
return {
|
|
@@ -16,8 +6,6 @@ export function getDefaultConfig(theme) {
|
|
|
16
6
|
// 缺省不指定圆角:运行时不注入 --ui-radius,沿用 @nuxt/ui 默认值或项目 CSS
|
|
17
7
|
radius: theme?.radius,
|
|
18
8
|
blackAsPrimary: false,
|
|
19
|
-
// 缺省不指定字体:运行时不注入 --font-sans,交由项目 CSS 的 @theme 决定
|
|
20
|
-
font: theme?.font ?? "",
|
|
21
9
|
icons: "lucide",
|
|
22
10
|
prefix: theme?.prefix,
|
|
23
11
|
tv: {
|
|
@@ -25,6 +13,6 @@ export function getDefaultConfig(theme) {
|
|
|
25
13
|
prefix: theme?.prefix
|
|
26
14
|
}
|
|
27
15
|
},
|
|
28
|
-
picker: {
|
|
16
|
+
picker: { radiuses: pickerRadiuses, neutralColors: pickerNeutralColors }
|
|
29
17
|
};
|
|
30
18
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import 'node:url';
|
|
2
2
|
import { kebabCase } from 'scule';
|
|
3
3
|
import { addTypeTemplate, addTemplate, getLayerDirectories } from '@nuxt/kit';
|
|
4
|
+
import { resolveFontSource, resolveFontFamily } from '../../dist/runtime/domains/theme/theme-font.js';
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
import { join } from 'pathe';
|
|
8
|
+
import { globSync } from 'tinyglobby';
|
|
4
9
|
|
|
5
10
|
const popconfirm = () => ({
|
|
6
11
|
slots: {
|
|
@@ -539,14 +544,21 @@ function getTemplates(options, nuxt) {
|
|
|
539
544
|
sources.push('@source "./movk-ui";');
|
|
540
545
|
return sources.join("\n");
|
|
541
546
|
}
|
|
547
|
+
function generateFontTheme() {
|
|
548
|
+
if (options.theme?.enabled === false) return "";
|
|
549
|
+
const source = resolveFontSource(options.theme?.font);
|
|
550
|
+
if (!source) return "";
|
|
551
|
+
return `@theme {
|
|
552
|
+
--font-sans: ${resolveFontFamily(source.name)};
|
|
553
|
+
}`;
|
|
554
|
+
}
|
|
542
555
|
templates.push({
|
|
543
556
|
filename: "movk-ui.css",
|
|
544
557
|
write: true,
|
|
545
558
|
getContents: async () => {
|
|
546
559
|
const sources = await generateSources();
|
|
547
560
|
const inlineSafelist = '@source inline("{,sm:,md:,lg:,xl:}grid-cols-{1,2,3,4,5,6,7,8,9,10,11,12}");';
|
|
548
|
-
return
|
|
549
|
-
${inlineSafelist}`;
|
|
561
|
+
return [sources, inlineSafelist, generateFontTheme()].filter(Boolean).join("\n");
|
|
550
562
|
}
|
|
551
563
|
});
|
|
552
564
|
templates.push({
|
|
@@ -567,24 +579,16 @@ import type { HookResult } from '@nuxt/schema'
|
|
|
567
579
|
import type { FetchContext } from 'ofetch'
|
|
568
580
|
|
|
569
581
|
type Radius = 0 | 0.125 | 0.25 | 0.375 | 0.5
|
|
570
|
-
type FontFamily = 'Alibaba PuHuiTi' | 'Public Sans' | 'DM Sans' | 'Geist' | 'Inter' | 'Poppins' | 'Outfit' | 'Raleway'
|
|
571
582
|
type Icons = 'lucide' | 'phosphor' | 'tabler'
|
|
572
583
|
|
|
573
|
-
interface PickerFontEntry {
|
|
574
|
-
name: string
|
|
575
|
-
href?: string
|
|
576
|
-
}
|
|
577
|
-
|
|
578
584
|
type AppConfigUI = {
|
|
579
585
|
dir?: Direction,
|
|
580
586
|
radius?: Radius | (number & {})
|
|
581
587
|
blackAsPrimary?: boolean
|
|
582
|
-
font?: FontFamily | (string & {})
|
|
583
588
|
icons?: Icons | (string & {})
|
|
584
589
|
prefix?: string
|
|
585
590
|
tv?: typeof defaultConfig
|
|
586
591
|
picker?: {
|
|
587
|
-
fonts?: PickerFontEntry[]
|
|
588
592
|
radiuses?: number[]
|
|
589
593
|
neutralColors?: string[]
|
|
590
594
|
}
|
|
@@ -672,6 +676,72 @@ async function addTemplates(options, nuxt) {
|
|
|
672
676
|
}
|
|
673
677
|
}
|
|
674
678
|
|
|
679
|
+
const DEFAULT_ICON_COLLECTION = "lucide";
|
|
680
|
+
const ICON_SOURCE_GLOB = ["**/*.{vue,ts,js,mjs}"];
|
|
681
|
+
const ICON_RE = /i-(lucide|ph|tabler)-([a-z\d]+(?:-[a-z\d]+)*)/g;
|
|
682
|
+
function scanMovkIcons(runtimeDir, options = {}) {
|
|
683
|
+
const ignore = options.theme === false ? ["domains/theme/**", "components/theme-picker/**"] : [];
|
|
684
|
+
const files = globSync(ICON_SOURCE_GLOB, { cwd: runtimeDir, ignore, absolute: true });
|
|
685
|
+
const icons = /* @__PURE__ */ new Set();
|
|
686
|
+
for (const file of files) {
|
|
687
|
+
let code;
|
|
688
|
+
try {
|
|
689
|
+
code = readFileSync(file, "utf-8");
|
|
690
|
+
} catch {
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
693
|
+
for (const match of code.matchAll(ICON_RE)) {
|
|
694
|
+
icons.add(`${match[1]}:${match[2]}`);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
return [...icons].sort();
|
|
698
|
+
}
|
|
699
|
+
function isCollectionInstalled(prefix, paths) {
|
|
700
|
+
for (const dir of paths) {
|
|
701
|
+
try {
|
|
702
|
+
createRequire(join(dir, "index.js")).resolve(`@iconify-json/${prefix}/icons.json`);
|
|
703
|
+
return true;
|
|
704
|
+
} catch {
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
return false;
|
|
708
|
+
}
|
|
709
|
+
function filterResolvableIcons(icons, paths) {
|
|
710
|
+
const installed = /* @__PURE__ */ new Map();
|
|
711
|
+
const missing = /* @__PURE__ */ new Set();
|
|
712
|
+
const kept = [];
|
|
713
|
+
for (const icon of icons) {
|
|
714
|
+
const prefix = icon.split(":")[0];
|
|
715
|
+
if (!installed.has(prefix)) {
|
|
716
|
+
installed.set(prefix, isCollectionInstalled(prefix, paths));
|
|
717
|
+
}
|
|
718
|
+
if (installed.get(prefix)) {
|
|
719
|
+
kept.push(icon);
|
|
720
|
+
} else {
|
|
721
|
+
missing.add(prefix);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
return { icons: kept, missing: [...missing] };
|
|
725
|
+
}
|
|
726
|
+
function resolveMovkIcons(runtimeDir, options) {
|
|
727
|
+
return filterResolvableIcons(
|
|
728
|
+
scanMovkIcons(runtimeDir, { theme: options.theme }),
|
|
729
|
+
options.paths
|
|
730
|
+
);
|
|
731
|
+
}
|
|
732
|
+
function formatMissingCollections(missing) {
|
|
733
|
+
const hint = (prefixes) => {
|
|
734
|
+
const packages = prefixes.map((prefix) => `@iconify-json/${prefix}`);
|
|
735
|
+
return `Missing ${packages.map((pkg) => `\`${pkg}\``).join(", ")}, so Movk icons from these collections are loaded at runtime. Install to bundle them at build time: \`npx nypm add -D ${packages.join(" ")}\``;
|
|
736
|
+
};
|
|
737
|
+
const required = missing.filter((prefix) => prefix === DEFAULT_ICON_COLLECTION);
|
|
738
|
+
const optional = missing.filter((prefix) => prefix !== DEFAULT_ICON_COLLECTION);
|
|
739
|
+
return {
|
|
740
|
+
warn: required.length ? hint(required) : void 0,
|
|
741
|
+
debug: optional.length ? hint(optional) : void 0
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
|
|
675
745
|
const UI_COMPONENTS = [
|
|
676
746
|
"UAccordion",
|
|
677
747
|
"UButton",
|
|
@@ -708,4 +778,4 @@ const UI_COMPONENTS = [
|
|
|
708
778
|
"UTree"
|
|
709
779
|
];
|
|
710
780
|
|
|
711
|
-
export { UI_COMPONENTS as U, addTemplates as a, getTemplates as g };
|
|
781
|
+
export { UI_COMPONENTS as U, addTemplates as a, formatMissingCollections as f, getTemplates as g, resolveMovkIcons as r };
|
package/dist/unplugin.d.mts
CHANGED
|
@@ -3,13 +3,14 @@ import { NuxtUIOptions } from '@nuxt/ui/unplugin';
|
|
|
3
3
|
import { ModuleOptions } from './module.mjs';
|
|
4
4
|
import '@nuxt/schema';
|
|
5
5
|
import '../dist/runtime/types/api/module.js';
|
|
6
|
+
import '../dist/runtime/domains/theme/theme-font.js';
|
|
6
7
|
import '@nuxt/ui';
|
|
7
8
|
import '../dist/runtime/types/index.js';
|
|
8
9
|
|
|
9
10
|
/** movk 组件层从 `#components` 具名导入的 @nuxt/ui 组件(去 U 前缀映射到 @nuxt/ui/components/<Name>.vue) */
|
|
10
11
|
declare const UI_COMPONENTS: readonly ["UAccordion", "UButton", "UBadge", "UCheckbox", "UCollapsible", "UForm", "UDropdownMenu", "UIcon", "UInput", "UModal", "UPagination", "USelect", "UPopover", "UCalendar", "UColorPicker", "UTable", "UFormField", "UTooltip", "UInputNumber", "USwitch", "UTextarea", "USlider", "UPinInput", "UInputTags", "UFileUpload", "USelectMenu", "UInputMenu", "UCheckboxGroup", "URadioGroup", "UInputDate", "UInputTime", "UListbox", "UTree"];
|
|
11
12
|
|
|
12
|
-
interface MovkUIOptions extends Pick<ModuleOptions, 'prefix' | 'theme'> {
|
|
13
|
+
interface MovkUIOptions extends Pick<ModuleOptions, 'prefix' | 'theme' | 'icon'> {
|
|
13
14
|
/** 站点信息,注入 app.config.movkSite;name 作为主题 localStorage key 前缀 */
|
|
14
15
|
site?: {
|
|
15
16
|
url?: string;
|
package/dist/unplugin.mjs
CHANGED
|
@@ -8,11 +8,13 @@ import MagicString from 'magic-string';
|
|
|
8
8
|
import { resolvePathSync } from 'mlly';
|
|
9
9
|
import fs from 'node:fs';
|
|
10
10
|
import path from 'node:path';
|
|
11
|
-
import { U as UI_COMPONENTS, g as getTemplates } from './shared/nuxt.
|
|
11
|
+
import { U as UI_COMPONENTS, g as getTemplates, r as resolveMovkIcons, f as formatMissingCollections } from './shared/nuxt.BT5mXYjs.mjs';
|
|
12
12
|
import { kebabCase } from 'scule';
|
|
13
13
|
import { getDefaultConfig } from '../dist/runtime/utils/theme-defaults.js';
|
|
14
14
|
import { getPackageJsonMetadata } from '../dist/runtime/utils/meta.js';
|
|
15
|
+
import { resolveFontSource, resolveFontLinks, resolveFontWarning } from '../dist/runtime/domains/theme/theme-font.js';
|
|
15
16
|
import '@nuxt/kit';
|
|
17
|
+
import 'node:module';
|
|
16
18
|
|
|
17
19
|
function resolveRouterMode(options) {
|
|
18
20
|
if (options.ui?.router === false) return "none";
|
|
@@ -201,6 +203,19 @@ function MovkPluginsPlugin(options) {
|
|
|
201
203
|
};
|
|
202
204
|
}
|
|
203
205
|
|
|
206
|
+
function MovkFontPlugin(options) {
|
|
207
|
+
const source = options.theme?.enabled === false ? void 0 : resolveFontSource(options.theme?.font);
|
|
208
|
+
const links = resolveFontLinks(source);
|
|
209
|
+
if (source && !links.length) {
|
|
210
|
+
console.warn(`[movk] ${resolveFontWarning(source.name)}`);
|
|
211
|
+
}
|
|
212
|
+
const tags = links.map((link) => ({ tag: "link", attrs: link, injectTo: "head" }));
|
|
213
|
+
return {
|
|
214
|
+
name: "movk:font",
|
|
215
|
+
vite: { transformIndexHtml: () => tags }
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
204
219
|
const runtimeDir = normalize(fileURLToPath(new URL("./runtime", import.meta.url)));
|
|
205
220
|
const MOVK_COMPOSABLES = {
|
|
206
221
|
useAutoForm: ["useAutoForm", "defineControl", "DEFAULT_CONTROLS", "getAutoFormMetadata"],
|
|
@@ -208,6 +223,16 @@ const MOVK_COMPOSABLES = {
|
|
|
208
223
|
useDateFormatter: ["useDateFormatter", "CalendarDate"],
|
|
209
224
|
useMessageBox: ["useMessageBox"]
|
|
210
225
|
};
|
|
226
|
+
function resolveMovkClientBundleIcons(options) {
|
|
227
|
+
if (options.icon?.clientBundle === false) return [];
|
|
228
|
+
const { icons, missing } = resolveMovkIcons(runtimeDir, {
|
|
229
|
+
theme: options.theme?.enabled !== false,
|
|
230
|
+
paths: [options.ui?.root || process.cwd()]
|
|
231
|
+
});
|
|
232
|
+
const { warn } = formatMissingCollections(missing);
|
|
233
|
+
if (warn) console.warn(`[movk] ${warn}`);
|
|
234
|
+
return icons;
|
|
235
|
+
}
|
|
211
236
|
function createMovkComponentSource(cwd, prefix, ignore = []) {
|
|
212
237
|
const files = globSync("**/*.vue", { cwd, ignore: ignore.filter(Boolean) });
|
|
213
238
|
const paths = new Map(files.map((c) => {
|
|
@@ -227,10 +252,13 @@ const MovkPlugin = createUnplugin((_options = {}, meta) => {
|
|
|
227
252
|
const componentIgnore = options.theme?.enabled === false ? ["theme-picker/**"] : [];
|
|
228
253
|
const movkComponents = createMovkComponentSource(join(runtimeDir, "components"), options.prefix, componentIgnore);
|
|
229
254
|
const ui = options.ui || {};
|
|
255
|
+
const movkIcons = resolveMovkClientBundleIcons(options);
|
|
230
256
|
const uiOptions = defu(
|
|
231
257
|
{
|
|
232
258
|
prefix: "U",
|
|
233
259
|
// movk 强制 U 前缀(U* shim 依赖),不可被 ui.prefix 覆盖
|
|
260
|
+
// movk 组件与内置图标集的图标进构建期图标包(ui.icon.clientBundle 为 false 时整体让位)
|
|
261
|
+
icon: movkIcons.length ? defu(ui.icon, { clientBundle: { icons: movkIcons } }) : ui.icon,
|
|
234
262
|
// 把 movk 非服务端 composables 注入 @nuxt/ui 的 unplugin-auto-import 单实例(避免第二实例)
|
|
235
263
|
autoImport: ui.autoImport === false ? false : defu(ui.autoImport, {
|
|
236
264
|
// 对齐 Nuxt:允许在 <template> 内使用自动导入(如复用页里 :data="makePeople(30)")
|
|
@@ -251,6 +279,7 @@ const MovkPlugin = createUnplugin((_options = {}, meta) => {
|
|
|
251
279
|
MovkAppConfigPlugin(options),
|
|
252
280
|
...Array.isArray(uiPlugins) ? uiPlugins : [uiPlugins],
|
|
253
281
|
MovkTemplatePlugin(options),
|
|
282
|
+
MovkFontPlugin(options),
|
|
254
283
|
MovkPluginsPlugin(options)
|
|
255
284
|
].flat(1);
|
|
256
285
|
});
|
package/dist/vite.d.mts
CHANGED
package/dist/vite.mjs
CHANGED
|
@@ -9,9 +9,11 @@ import 'magic-string';
|
|
|
9
9
|
import 'mlly';
|
|
10
10
|
import 'node:fs';
|
|
11
11
|
import 'node:path';
|
|
12
|
-
import './shared/nuxt.
|
|
12
|
+
import './shared/nuxt.BT5mXYjs.mjs';
|
|
13
13
|
import 'scule';
|
|
14
14
|
import '@nuxt/kit';
|
|
15
|
+
import '../dist/runtime/domains/theme/theme-font.js';
|
|
16
|
+
import 'node:module';
|
|
15
17
|
import '../dist/runtime/utils/theme-defaults.js';
|
|
16
18
|
import '../dist/runtime/utils/meta.js';
|
|
17
19
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@movk/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
5
|
-
"packageManager": "pnpm@11.
|
|
4
|
+
"version": "1.7.0",
|
|
5
|
+
"packageManager": "pnpm@11.20.0",
|
|
6
6
|
"description": "An engineering suite built on Nuxt UI: schema-driven AutoForm (Zod v4), a full-featured DataTable, standalone UI components and composables. Get the full capabilities — including API integration with auth & progress — in Nuxt 4, and use its UI, forms, tables and theming in plain Vue + Vite via the Vite plugin.",
|
|
7
7
|
"author": "YiXuan <mhaibaraai@gmail.com>",
|
|
8
8
|
"license": "MIT",
|
|
@@ -124,10 +124,7 @@
|
|
|
124
124
|
"test:vue": "vitest --project vue"
|
|
125
125
|
},
|
|
126
126
|
"dependencies": {
|
|
127
|
-
"@
|
|
128
|
-
"@iconify-json/ph": "^1.2.2",
|
|
129
|
-
"@iconify-json/tabler": "^1.2.38",
|
|
130
|
-
"@internationalized/date": "^3.12.2",
|
|
127
|
+
"@internationalized/date": "^3.12.3",
|
|
131
128
|
"@movk/core": "^1.4.1",
|
|
132
129
|
"@nuxt/image": "^2.1.0",
|
|
133
130
|
"@nuxt/ui": "^4.10.0",
|
|
@@ -139,19 +136,21 @@
|
|
|
139
136
|
"magic-string": "^1.1.0",
|
|
140
137
|
"maska": "^3.2.0",
|
|
141
138
|
"mlly": "^1.8.2",
|
|
142
|
-
"nuxt-auth-utils": "^0.5.
|
|
143
|
-
"nuxt-site-config": "^4.1.
|
|
139
|
+
"nuxt-auth-utils": "^0.5.30",
|
|
140
|
+
"nuxt-site-config": "^4.1.5",
|
|
144
141
|
"pathe": "^2.0.3",
|
|
145
142
|
"reka-ui": "2.10.1",
|
|
146
143
|
"scule": "^1.3.0",
|
|
147
|
-
"tailwind-variants": "^3.3.
|
|
144
|
+
"tailwind-variants": "^3.3.1",
|
|
148
145
|
"tailwindcss": "^4.3.3",
|
|
149
146
|
"tinyglobby": "^0.2.17",
|
|
150
|
-
"unifont": "^0.7.4",
|
|
151
147
|
"unplugin": "^3.3.0",
|
|
152
148
|
"zod": "^4.4.3"
|
|
153
149
|
},
|
|
154
150
|
"devDependencies": {
|
|
151
|
+
"@iconify-json/lucide": "^1.2.121",
|
|
152
|
+
"@iconify-json/ph": "^1.2.2",
|
|
153
|
+
"@iconify-json/tabler": "^1.2.38",
|
|
155
154
|
"@nuxt/eslint-config": "^1.16.0",
|
|
156
155
|
"@nuxt/kit": "^4.5.1",
|
|
157
156
|
"@nuxt/module-builder": "^1.0.3",
|
|
@@ -160,13 +159,13 @@
|
|
|
160
159
|
"eslint": "^10.8.0",
|
|
161
160
|
"happy-dom": "^20.11.1",
|
|
162
161
|
"nuxt": "^4.5.1",
|
|
163
|
-
"release-it": "^21.0.
|
|
162
|
+
"release-it": "^21.0.1",
|
|
164
163
|
"typescript": "^6.0.3",
|
|
165
164
|
"unbuild": "^3.6.1",
|
|
166
|
-
"unplugin-auto-import": "^21.
|
|
165
|
+
"unplugin-auto-import": "^21.1.0",
|
|
167
166
|
"unplugin-vue-components": "^32.1.0",
|
|
168
167
|
"vitest": "^4.1.10",
|
|
169
168
|
"vue": "^3.5.40",
|
|
170
|
-
"vue-tsc": "^3.3.
|
|
169
|
+
"vue-tsc": "^3.3.9"
|
|
171
170
|
}
|
|
172
171
|
}
|