vuetify-nuxt-module 0.9.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.9.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.9.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
+ }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "vuetify-nuxt-module",
3
3
  "type": "module",
4
- "version": "0.9.0",
5
- "packageManager": "pnpm@8.14.0",
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",