vuetify-nuxt-module 0.5.15 → 0.6.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.ts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +57 -2
- package/dist/runtime/plugins/client-hints.d.ts +1 -4
- package/dist/runtime/plugins/vuetify-client-hints.client.mjs +8 -8
- package/dist/runtime/plugins/vuetify-client-hints.server.mjs +2 -4
- package/package.json +2 -2
package/dist/module.d.ts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import vuetify, { transformAssetUrls } from 'vite-plugin-vuetify';
|
|
|
12
12
|
import { isAbsolute, join, relative } from 'pathe';
|
|
13
13
|
import { normalizePath as normalizePath$1 } from 'vite';
|
|
14
14
|
|
|
15
|
-
const version = "0.
|
|
15
|
+
const version = "0.6.0";
|
|
16
16
|
|
|
17
17
|
const VIRTUAL_VUETIFY_CONFIGURATION = "virtual:vuetify-configuration";
|
|
18
18
|
const RESOLVED_VIRTUAL_VUETIFY_CONFIGURATION = `/@nuxt-vuetify-configuration/${VIRTUAL_VUETIFY_CONFIGURATION.slice("virtual:".length)}`;
|
|
@@ -670,6 +670,59 @@ function toKebabCase(str = "") {
|
|
|
670
670
|
return kebab;
|
|
671
671
|
}
|
|
672
672
|
toKebabCase.cache = /* @__PURE__ */ new Map();
|
|
673
|
+
function camelize(str) {
|
|
674
|
+
if (camelize.cache.has(str))
|
|
675
|
+
return camelize.cache.get(str);
|
|
676
|
+
const camel = str.replace(/-([a-z0-9])/g, (g) => g[1].toUpperCase());
|
|
677
|
+
camelize.cache.set(str, camel);
|
|
678
|
+
return camel;
|
|
679
|
+
}
|
|
680
|
+
camelize.cache = /* @__PURE__ */ new Map();
|
|
681
|
+
function pascalize(str) {
|
|
682
|
+
if (pascalize.cache.has(str))
|
|
683
|
+
return pascalize.cache.get(str);
|
|
684
|
+
let pascal = camelize(str);
|
|
685
|
+
pascal = pascal.slice(0, 1).toUpperCase() + pascal.slice(1);
|
|
686
|
+
pascalize.cache.set(str, pascal);
|
|
687
|
+
return pascal;
|
|
688
|
+
}
|
|
689
|
+
pascalize.cache = /* @__PURE__ */ new Map();
|
|
690
|
+
function normalizeTransformAssetUrls(transformAssetUrls) {
|
|
691
|
+
const names = new Set(Object.keys(transformAssetUrls));
|
|
692
|
+
let kebab;
|
|
693
|
+
let pascal;
|
|
694
|
+
for (const name of names) {
|
|
695
|
+
transformAssetUrls[name] = normalizeTransformAssetUrlsAttrs(transformAssetUrls[name]);
|
|
696
|
+
kebab = toKebabCase(name);
|
|
697
|
+
pascal = pascalize(name);
|
|
698
|
+
if (!names.has(kebab))
|
|
699
|
+
transformAssetUrls[kebab] = [...transformAssetUrls[name]];
|
|
700
|
+
if (!names.has(pascal))
|
|
701
|
+
transformAssetUrls[pascal] = [...transformAssetUrls[name]];
|
|
702
|
+
}
|
|
703
|
+
return transformAssetUrls;
|
|
704
|
+
}
|
|
705
|
+
function normalizeTransformAssetUrlsAttrs(attrs) {
|
|
706
|
+
const result = /* @__PURE__ */ new Set();
|
|
707
|
+
let kebab;
|
|
708
|
+
let camel;
|
|
709
|
+
let bind;
|
|
710
|
+
let idx;
|
|
711
|
+
for (const attr of attrs) {
|
|
712
|
+
result.add(attr);
|
|
713
|
+
idx = attr.indexOf(":");
|
|
714
|
+
if (idx > 0)
|
|
715
|
+
continue;
|
|
716
|
+
bind = idx === 0;
|
|
717
|
+
kebab = toKebabCase(bind ? attr.slice(1) : attr);
|
|
718
|
+
camel = camelize(bind ? attr.slice(1) : attr);
|
|
719
|
+
result.add(kebab);
|
|
720
|
+
result.add(camel);
|
|
721
|
+
result.add(`:${kebab}`);
|
|
722
|
+
result.add(`:${camel}`);
|
|
723
|
+
}
|
|
724
|
+
return [...result];
|
|
725
|
+
}
|
|
673
726
|
|
|
674
727
|
function vuetifyConfigurationPlugin(ctx) {
|
|
675
728
|
return {
|
|
@@ -1185,7 +1238,9 @@ function configureNuxt(configKey, nuxt, ctx) {
|
|
|
1185
1238
|
if (includeTransformAssetsUrls && typeof nuxt.options.vite.vue?.template?.transformAssetUrls === "undefined") {
|
|
1186
1239
|
(_b = nuxt.options.vite).vue ?? (_b.vue = {});
|
|
1187
1240
|
(_c = nuxt.options.vite.vue).template ?? (_c.template = {});
|
|
1188
|
-
nuxt.options.vite.vue.template.transformAssetUrls =
|
|
1241
|
+
nuxt.options.vite.vue.template.transformAssetUrls = normalizeTransformAssetUrls(
|
|
1242
|
+
typeof includeTransformAssetsUrls === "object" ? defu(includeTransformAssetsUrls, transformAssetUrls) : transformAssetUrls
|
|
1243
|
+
);
|
|
1189
1244
|
}
|
|
1190
1245
|
extendWebpackConfig(() => {
|
|
1191
1246
|
throw new Error("Webpack is not supported: vuetify-nuxt-module module can only be used with Vite!");
|
|
@@ -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.9.
|
|
4
|
+
"version": "0.6.0",
|
|
5
|
+
"packageManager": "pnpm@8.9.2",
|
|
6
6
|
"description": "Zero-Config Nuxt Module for Vuetify",
|
|
7
7
|
"author": "userquin <userquin@gmail.com>",
|
|
8
8
|
"license": "MIT",
|