vuetify-nuxt-module 0.5.16 → 0.6.1
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.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -2,17 +2,20 @@ import { addVitePlugin, extendWebpackConfig, addImports, addPlugin, useLogger, d
|
|
|
2
2
|
import defu from 'defu';
|
|
3
3
|
import { debounce } from 'perfect-debounce';
|
|
4
4
|
import { existsSync, statSync } from 'node:fs';
|
|
5
|
-
import { resolve, dirname } from 'node:path';
|
|
5
|
+
import { resolve, dirname, extname } from 'node:path';
|
|
6
6
|
import process from 'node:process';
|
|
7
7
|
import { createConfigLoader } from 'unconfig';
|
|
8
8
|
import { readFile, utimes } from 'node:fs/promises';
|
|
9
9
|
import { isPackageExists } from 'local-pkg';
|
|
10
|
-
import { resolveVuetifyBase, normalizePath, writeStyles, cacheDir } from '@vuetify/loader-shared';
|
|
11
|
-
import vuetify, { transformAssetUrls } from 'vite-plugin-vuetify';
|
|
10
|
+
import { resolveVuetifyBase, normalizePath, writeStyles, cacheDir, generateImports } from '@vuetify/loader-shared';
|
|
12
11
|
import { isAbsolute, join, relative } from 'pathe';
|
|
13
12
|
import { normalizePath as normalizePath$1 } from 'vite';
|
|
13
|
+
import { pathToFileURL } from 'node:url';
|
|
14
|
+
import { parseQuery, parseURL } from 'ufo';
|
|
15
|
+
import destr from 'destr';
|
|
16
|
+
import { transformAssetUrls } from 'vite-plugin-vuetify';
|
|
14
17
|
|
|
15
|
-
const version = "0.
|
|
18
|
+
const version = "0.6.1";
|
|
16
19
|
|
|
17
20
|
const VIRTUAL_VUETIFY_CONFIGURATION = "virtual:vuetify-configuration";
|
|
18
21
|
const RESOLVED_VIRTUAL_VUETIFY_CONFIGURATION = `/@nuxt-vuetify-configuration/${VIRTUAL_VUETIFY_CONFIGURATION.slice("virtual:".length)}`;
|
|
@@ -1192,6 +1195,40 @@ function vuetifySSRClientHintsPlugin(ctx) {
|
|
|
1192
1195
|
};
|
|
1193
1196
|
}
|
|
1194
1197
|
|
|
1198
|
+
function parseId2(id) {
|
|
1199
|
+
id = id.replace(/^(virtual:nuxt:|virtual:)/, "");
|
|
1200
|
+
return parseURL(decodeURIComponent(isAbsolute(id) ? pathToFileURL(id).href : id));
|
|
1201
|
+
}
|
|
1202
|
+
function parseId(id) {
|
|
1203
|
+
const { search, pathname } = parseId2(id);
|
|
1204
|
+
const query = parseQuery(search);
|
|
1205
|
+
const urlProps = query.props ? destr(query.props) : void 0;
|
|
1206
|
+
return {
|
|
1207
|
+
query: urlProps,
|
|
1208
|
+
path: pathname ?? id
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
function vuetifyImportPlugin() {
|
|
1212
|
+
return {
|
|
1213
|
+
name: "vuetify:import",
|
|
1214
|
+
configResolved(config) {
|
|
1215
|
+
if (config.plugins.findIndex((plugin) => plugin.name === "vuetify:import") < config.plugins.findIndex((plugin) => plugin.name === "vite:vue"))
|
|
1216
|
+
throw new Error("Vuetify plugin must be loaded after the vue plugin");
|
|
1217
|
+
},
|
|
1218
|
+
async transform(code, id) {
|
|
1219
|
+
const { query, path } = parseId(id);
|
|
1220
|
+
if ((!query || !("vue" in query)) && extname(path) === ".vue" && !/^import { render as _sfc_render } from ".*"$/m.test(code) || query && "vue" in query && (query.type === "template" || query.type === "script" && query.setup === "true")) {
|
|
1221
|
+
const { code: imports, source } = generateImports(code);
|
|
1222
|
+
return {
|
|
1223
|
+
code: source + imports,
|
|
1224
|
+
map: null
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1227
|
+
return null;
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1195
1232
|
function configureVite(configKey, nuxt, ctx) {
|
|
1196
1233
|
nuxt.hook("vite:extend", ({ config }) => checkVuetifyPlugins(config));
|
|
1197
1234
|
nuxt.hook("vite:extendConfig", (viteInlineConfig) => {
|
|
@@ -1205,7 +1242,7 @@ function configureVite(configKey, nuxt, ctx) {
|
|
|
1205
1242
|
configKey
|
|
1206
1243
|
];
|
|
1207
1244
|
}
|
|
1208
|
-
viteInlineConfig.plugins.push(
|
|
1245
|
+
viteInlineConfig.plugins.push(vuetifyImportPlugin());
|
|
1209
1246
|
viteInlineConfig.plugins.push(vuetifyStylesPlugin({ styles: ctx.moduleOptions.styles }, ctx.logger));
|
|
1210
1247
|
viteInlineConfig.plugins.push(vuetifyConfigurationPlugin(ctx));
|
|
1211
1248
|
viteInlineConfig.plugins.push(vuetifyIconsPlugin(ctx));
|
|
@@ -5,7 +5,7 @@ export interface ClientHintRequestFeatures {
|
|
|
5
5
|
viewportHeightAvailable: boolean;
|
|
6
6
|
viewportWidthAvailable: boolean;
|
|
7
7
|
}
|
|
8
|
-
export interface
|
|
8
|
+
export interface SSRClientHints extends ClientHintRequestFeatures {
|
|
9
9
|
prefersColorScheme?: 'dark' | 'light' | 'no-preference';
|
|
10
10
|
prefersReducedMotion?: 'no-preference' | 'reduce';
|
|
11
11
|
viewportHeight?: number;
|
|
@@ -13,7 +13,4 @@ export interface ClientHintsRequest extends ClientHintRequestFeatures {
|
|
|
13
13
|
colorSchemeFromCookie?: string;
|
|
14
14
|
colorSchemeCookie?: string;
|
|
15
15
|
}
|
|
16
|
-
export interface SSRClientHints {
|
|
17
|
-
ssrClientHints: ClientHintsRequest;
|
|
18
|
-
}
|
|
19
16
|
export declare const VuetifyHTTPClientHints = "vuetify:nuxt:ssr-client-hints";
|
|
@@ -10,7 +10,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
10
10
|
prefersReducedMotionAvailable,
|
|
11
11
|
viewportHeightAvailable,
|
|
12
12
|
viewportWidthAvailable
|
|
13
|
-
} = state.value
|
|
13
|
+
} = state.value;
|
|
14
14
|
const {
|
|
15
15
|
reloadOnFirstRequest,
|
|
16
16
|
viewportSize,
|
|
@@ -20,12 +20,12 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
20
20
|
} = ssrClientHintsConfiguration;
|
|
21
21
|
if (firstRequest && reloadOnFirstRequest) {
|
|
22
22
|
if (prefersColorScheme) {
|
|
23
|
-
const themeCookie = state.value.
|
|
23
|
+
const themeCookie = state.value.colorSchemeCookie;
|
|
24
24
|
if (prefersColorSchemeOptions && themeCookie) {
|
|
25
25
|
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
26
26
|
const cookieName = prefersColorSchemeOptions.cookieName;
|
|
27
27
|
const parseCookieName = `${cookieName}=`;
|
|
28
|
-
const cookieEntry = `${parseCookieName}${state.value.
|
|
28
|
+
const cookieEntry = `${parseCookieName}${state.value.colorSchemeFromCookie ?? prefersColorSchemeOptions.defaultTheme};`;
|
|
29
29
|
const newThemeName = prefersDark ? prefersColorSchemeOptions.darkThemeName : prefersColorSchemeOptions.lightThemeName;
|
|
30
30
|
document.cookie = themeCookie.replace(cookieEntry, `${cookieName}=${newThemeName};`);
|
|
31
31
|
window.location.reload();
|
|
@@ -43,24 +43,24 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
43
43
|
if (viewportSize || prefersColorScheme && prefersColorSchemeOptions) {
|
|
44
44
|
nuxtApp.hook("vuetify:before-create", ({ vuetifyOptions }) => {
|
|
45
45
|
if (viewportSize) {
|
|
46
|
-
const clientWidth = state.value.
|
|
47
|
-
const clientHeight = state.value.
|
|
46
|
+
const clientWidth = state.value.viewportWidth;
|
|
47
|
+
const clientHeight = state.value.viewportHeight;
|
|
48
48
|
vuetifyOptions.ssr = typeof clientWidth === "number" ? {
|
|
49
49
|
clientWidth,
|
|
50
50
|
clientHeight
|
|
51
51
|
} : true;
|
|
52
52
|
}
|
|
53
53
|
if (prefersColorScheme && prefersColorSchemeOptions)
|
|
54
|
-
vuetifyOptions.theme.defaultTheme = state.value.
|
|
54
|
+
vuetifyOptions.theme.defaultTheme = state.value.colorSchemeFromCookie ?? prefersColorSchemeOptions.defaultTheme;
|
|
55
55
|
});
|
|
56
56
|
if (prefersColorScheme && prefersColorSchemeOptions) {
|
|
57
|
-
const themeCookie = state.value.
|
|
57
|
+
const themeCookie = state.value.colorSchemeCookie;
|
|
58
58
|
if (themeCookie) {
|
|
59
59
|
nuxtApp.hook("app:beforeMount", () => {
|
|
60
60
|
const vuetify = useNuxtApp().$vuetify;
|
|
61
61
|
const cookieName = prefersColorSchemeOptions.cookieName;
|
|
62
62
|
const parseCookieName = `${cookieName}=`;
|
|
63
|
-
const cookieEntry = `${parseCookieName}${state.value.
|
|
63
|
+
const cookieEntry = `${parseCookieName}${state.value.colorSchemeFromCookie ?? prefersColorSchemeOptions.defaultTheme};`;
|
|
64
64
|
watch(vuetify.theme.global.name, (newThemeName) => {
|
|
65
65
|
document.cookie = themeCookie.replace(cookieEntry, `${cookieName}=${newThemeName};`);
|
|
66
66
|
});
|
|
@@ -21,10 +21,8 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
21
21
|
const userAgent = userAgentHeader ? parseUserAgent(userAgentHeader) : null;
|
|
22
22
|
const clientHintsRequest = collectClientHints(userAgent, ssrClientHintsConfiguration, requestHeaders);
|
|
23
23
|
writeClientHintsResponseHeaders(clientHintsRequest, ssrClientHintsConfiguration, response);
|
|
24
|
-
state.value =
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
state.value.ssrClientHints.colorSchemeCookie = writeThemeCookie(
|
|
24
|
+
state.value = clientHintsRequest;
|
|
25
|
+
state.value.colorSchemeCookie = writeThemeCookie(
|
|
28
26
|
clientHintsRequest,
|
|
29
27
|
ssrClientHintsConfiguration
|
|
30
28
|
);
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vuetify-nuxt-module",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"packageManager": "pnpm@8.
|
|
4
|
+
"version": "0.6.1",
|
|
5
|
+
"packageManager": "pnpm@8.10.2",
|
|
6
6
|
"description": "Zero-Config Nuxt Module for Vuetify",
|
|
7
7
|
"author": "userquin <userquin@gmail.com>",
|
|
8
8
|
"license": "MIT",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"perfect-debounce": "^1.0.0",
|
|
70
70
|
"unconfig": "^0.3.9",
|
|
71
71
|
"vite-plugin-vuetify": "^1.0.2",
|
|
72
|
-
"vuetify": "^3.3.
|
|
72
|
+
"vuetify": "^3.3.23"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@antfu/eslint-config": "^0.41.0",
|
|
@@ -104,6 +104,7 @@
|
|
|
104
104
|
"node:child_process",
|
|
105
105
|
"node:fs",
|
|
106
106
|
"consola",
|
|
107
|
+
"destr",
|
|
107
108
|
"esbuild",
|
|
108
109
|
"local-pkg",
|
|
109
110
|
"pathe",
|