@maz-ui/nuxt 4.0.0-beta.21 → 4.0.0-beta.23
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 +1 -1
- package/dist/module.json +2 -2
- package/dist/runtime/plugins/theme.js +25 -23
- package/package.json +8 -8
package/dist/module.d.mts
CHANGED
|
@@ -10,7 +10,7 @@ interface MazUiNuxtThemeOptions extends MazUiThemeOptions {
|
|
|
10
10
|
* @description Inject full CSS on server-side to prevent FOUC on client-side
|
|
11
11
|
* @default true
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
injectAllCSSOnServer?: boolean;
|
|
14
14
|
}
|
|
15
15
|
interface MazUiNuxtOptions {
|
|
16
16
|
/**
|
package/dist/module.json
CHANGED
|
@@ -21,7 +21,7 @@ function getServerInitialColorMode(colorMode) {
|
|
|
21
21
|
}
|
|
22
22
|
return "auto";
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function injectThemeCSS({
|
|
25
25
|
mode,
|
|
26
26
|
preset,
|
|
27
27
|
config
|
|
@@ -31,16 +31,19 @@ function injectThemeCSSOnServer({
|
|
|
31
31
|
darkSelectorStrategy: config.darkModeStrategy ?? "class",
|
|
32
32
|
prefix: "maz"
|
|
33
33
|
};
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
34
|
+
const shouldInjectCriticalCSSOnServer = config.injectCriticalCSS && import.meta.server;
|
|
35
|
+
const criticalCSSAlreadyInjected = import.meta.client && document.getElementById(CSS_IDS.CRITICAL);
|
|
36
|
+
const shouldInjectCriticalCSSOnClient = config.injectCriticalCSS && import.meta.client && !criticalCSSAlreadyInjected;
|
|
37
|
+
if (shouldInjectCriticalCSSOnServer || shouldInjectCriticalCSSOnClient) {
|
|
38
|
+
const criticalCSS = generateCriticalCSS(preset, cssOptions);
|
|
39
|
+
useHead({
|
|
40
|
+
style: [{ innerHTML: criticalCSS, id: CSS_IDS.CRITICAL }]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const shouldInjectFullCSSOnServer = config.injectAllCSSOnServer && import.meta.server;
|
|
44
|
+
const fullCSSAlreadyInjected = import.meta.client && document.getElementById(CSS_IDS.FULL);
|
|
45
|
+
const shouldInjectFullCSSOnClient = config.injectFullCSS && import.meta.client && !fullCSSAlreadyInjected;
|
|
46
|
+
if (shouldInjectFullCSSOnServer || shouldInjectFullCSSOnClient) {
|
|
44
47
|
const fullCSS = generateFullCSS(preset, cssOptions);
|
|
45
48
|
useHead({
|
|
46
49
|
style: [{ innerHTML: fullCSS, id: CSS_IDS.FULL }]
|
|
@@ -53,15 +56,15 @@ export default defineNuxtPlugin(async ({ vueApp, $config }) => {
|
|
|
53
56
|
if (options?.overrides) {
|
|
54
57
|
preset = mergePresets(preset, options.overrides);
|
|
55
58
|
}
|
|
56
|
-
const isClientSideRendering = import.meta.client && !document.getElementById(CSS_IDS.CRITICAL);
|
|
57
59
|
const config = {
|
|
58
60
|
strategy: "hybrid",
|
|
59
61
|
darkModeStrategy: "class",
|
|
60
62
|
colorMode: options.mode && options.mode !== "both" ? options.mode : options.colorMode ?? "auto",
|
|
61
63
|
mode: "both",
|
|
62
|
-
|
|
64
|
+
injectAllCSSOnServer: false,
|
|
63
65
|
injectCriticalCSS: true,
|
|
64
66
|
injectFullCSS: true,
|
|
67
|
+
overrides: {},
|
|
65
68
|
...options,
|
|
66
69
|
preset
|
|
67
70
|
};
|
|
@@ -74,19 +77,18 @@ export default defineNuxtPlugin(async ({ vueApp, $config }) => {
|
|
|
74
77
|
}
|
|
75
78
|
});
|
|
76
79
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
});
|
|
83
|
-
}
|
|
80
|
+
injectThemeCSS({
|
|
81
|
+
mode: config.mode,
|
|
82
|
+
preset: config.preset,
|
|
83
|
+
config
|
|
84
|
+
});
|
|
84
85
|
MazUiTheme.install(vueApp, {
|
|
85
|
-
...config,
|
|
86
86
|
colorMode,
|
|
87
|
+
preset: config.preset,
|
|
87
88
|
strategy: config.strategy,
|
|
88
89
|
darkModeStrategy: config.darkModeStrategy,
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
mode: config.mode,
|
|
91
|
+
injectFullCSS: false,
|
|
92
|
+
injectCriticalCSS: false
|
|
91
93
|
});
|
|
92
94
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maz-ui/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.23",
|
|
5
5
|
"description": "Nuxt module for Maz-UI",
|
|
6
6
|
"author": "Louis Mazel <me@loicmazuel.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -53,24 +53,24 @@
|
|
|
53
53
|
"typecheck": "nuxi typecheck"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@maz-ui/themes": "4.0.0-beta.
|
|
56
|
+
"@maz-ui/themes": "4.0.0-beta.22",
|
|
57
57
|
"@maz-ui/translations": "4.0.0-beta.21",
|
|
58
|
-
"@nuxt/kit": "^4.0.
|
|
58
|
+
"@nuxt/kit": "^4.0.2",
|
|
59
59
|
"defu": "^6.1.4",
|
|
60
|
-
"maz-ui": "4.0.0-beta.
|
|
60
|
+
"maz-ui": "4.0.0-beta.23"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@nuxt/devtools": "^2.6.2",
|
|
64
64
|
"@nuxt/eslint-config": "^1.7.1",
|
|
65
|
-
"@nuxt/module-builder": "^1.0.
|
|
66
|
-
"@nuxt/schema": "^4.0.
|
|
65
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
66
|
+
"@nuxt/schema": "^4.0.2",
|
|
67
67
|
"@nuxt/test-utils": "^3.19.2",
|
|
68
|
-
"nuxt": "^4.0.
|
|
68
|
+
"nuxt": "^4.0.2",
|
|
69
69
|
"typescript": "~5.8.3",
|
|
70
70
|
"vitest": "^3.2.4"
|
|
71
71
|
},
|
|
72
72
|
"lint-staged": {
|
|
73
73
|
"*.{js,ts,mjs,mts,cjs,md,yml,json}": "cross-env NODE_ENV=production eslint --fix"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "89d18c1c23e4d60a53695a5f477c9e6d23a1b00c"
|
|
76
76
|
}
|