vuetify-nuxt-module 0.8.0 → 0.9.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
@@ -5,5 +5,5 @@
5
5
  "nuxt": "^3.6.5",
6
6
  "bridge": false
7
7
  },
8
- "version": "0.8.0"
8
+ "version": "0.9.1"
9
9
  }
package/dist/module.mjs CHANGED
@@ -14,7 +14,7 @@ import { parseQuery, parseURL } from 'ufo';
14
14
  import destr from 'destr';
15
15
  import { transformAssetUrls } from 'vite-plugin-vuetify';
16
16
 
17
- const version = "0.8.0";
17
+ const version = "0.9.1";
18
18
 
19
19
  const VIRTUAL_VUETIFY_CONFIGURATION = "virtual:vuetify-configuration";
20
20
  const RESOLVED_VIRTUAL_VUETIFY_CONFIGURATION = `/@nuxt-vuetify-configuration/${VIRTUAL_VUETIFY_CONFIGURATION.slice("virtual:".length)}`;
@@ -1,9 +1,9 @@
1
1
  import { ssrClientHintsConfiguration } from "virtual:vuetify-ssr-client-hints-configuration";
2
- import { reactive, watch } from "vue";
2
+ import { reactive, ref, watch } from "vue";
3
3
  import { VuetifyHTTPClientHints } from "./client-hints.mjs";
4
4
  import { defineNuxtPlugin, useNuxtApp, useState } from "#imports";
5
5
  const plugin = defineNuxtPlugin((nuxtApp) => {
6
- const state = useState(VuetifyHTTPClientHints);
6
+ const state = useSSRClientHints();
7
7
  const {
8
8
  firstRequest,
9
9
  prefersColorSchemeAvailable,
@@ -88,3 +88,33 @@ const plugin = defineNuxtPlugin((nuxtApp) => {
88
88
  };
89
89
  });
90
90
  export default plugin;
91
+ function defaultClientValues() {
92
+ return {
93
+ firstRequest: false,
94
+ prefersColorSchemeAvailable: false,
95
+ prefersReducedMotionAvailable: false,
96
+ viewportHeightAvailable: true,
97
+ viewportWidthAvailable: true,
98
+ viewportHeight: window.innerHeight,
99
+ viewportWidth: window.innerWidth
100
+ };
101
+ }
102
+ function useSSRClientHints() {
103
+ const state = useState(VuetifyHTTPClientHints);
104
+ if (state.value)
105
+ return state;
106
+ const initial = ref(defaultClientValues());
107
+ if (!ssrClientHintsConfiguration.prefersColorScheme || !ssrClientHintsConfiguration.prefersColorSchemeOptions)
108
+ return initial;
109
+ const {
110
+ baseUrl,
111
+ cookieName,
112
+ defaultTheme
113
+ } = ssrClientHintsConfiguration.prefersColorSchemeOptions;
114
+ const cookieNamePrefix = `${cookieName}=`;
115
+ initial.value.colorSchemeFromCookie = document.cookie?.split(";")?.find((c) => c.trim().startsWith(cookieNamePrefix))?.split("=")[1] ?? defaultTheme;
116
+ const date = /* @__PURE__ */ new Date();
117
+ const expires = new Date(date.setDate(date.getDate() + 365));
118
+ initial.value.colorSchemeCookie = `${cookieName}=${initial.value.colorSchemeFromCookie}; Path=${baseUrl}; Expires=${expires.toUTCString()}; SameSite=Lax`;
119
+ return initial;
120
+ }
@@ -1,12 +1,14 @@
1
1
  import { configureVuetify } from "./config.mjs";
2
- import { defineNuxtPlugin, useNuxtApp } from "#imports";
2
+ import { defineNuxtPlugin } from "#imports";
3
3
  const plugin = defineNuxtPlugin({
4
4
  name: "vuetify:configuration:plugin",
5
5
  enforce: "post",
6
- // i18n runtime plugin is async
6
+ // @ts-expect-error i18n plugin missing on build time
7
+ dependsOn: ["i18n:plugin"],
8
+ // i18n runtime plugin can be async
7
9
  parallel: false,
8
- setup() {
9
- useNuxtApp().hook("app:created", configureVuetify);
10
+ async setup() {
11
+ await configureVuetify();
10
12
  }
11
13
  });
12
14
  export default plugin;
@@ -1,10 +1,10 @@
1
1
  import { configureVuetify } from "./config.mjs";
2
- import { defineNuxtPlugin, useNuxtApp } from "#imports";
2
+ import { defineNuxtPlugin } from "#imports";
3
3
  const plugin = defineNuxtPlugin({
4
4
  name: "vuetify:configuration:plugin",
5
5
  enforce: "post",
6
- setup() {
7
- useNuxtApp().hook("app:created", configureVuetify);
6
+ async setup() {
7
+ await configureVuetify();
8
8
  }
9
9
  });
10
10
  export default plugin;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "vuetify-nuxt-module",
3
3
  "type": "module",
4
- "version": "0.8.0",
5
- "packageManager": "pnpm@8.13.1",
4
+ "version": "0.9.1",
5
+ "packageManager": "pnpm@8.14.1",
6
6
  "description": "Zero-Config Nuxt Module for Vuetify",
7
7
  "author": "userquin <userquin@gmail.com>",
8
8
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  "*.mjs"
43
43
  ],
44
44
  "scripts": {
45
- "prepack": "nuxt-module-build prepare && nuxt-module-build build && jiti scripts/postbuild.ts",
45
+ "prepack": "nuxt-module-build prepare && nuxt-module-build build",
46
46
  "dev": "nuxi dev playground",
47
47
  "dev:multiple-json": "MULTIPLE_LANG_FILES=true nuxi dev playground",
48
48
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
@@ -87,7 +87,7 @@
87
87
  "@iconify-json/mdi": "^1.1.55",
88
88
  "@mdi/js": "^7.3.67",
89
89
  "@nuxt/devtools": "^1.0.6",
90
- "@nuxt/module-builder": "^0.5.4",
90
+ "@nuxt/module-builder": "^0.5.5",
91
91
  "@nuxt/schema": "^3.9.0",
92
92
  "@nuxt/test-utils": "^3.9.0",
93
93
  "@nuxtjs/i18n": "^8.0.0",