@dargmuesli/nuxt-vio 3.4.0 → 3.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,8 @@ export const useAppLayout = () => {
2
2
  const appConfig = useAppConfig()
3
3
  const siteConfig = useSiteConfig()
4
4
 
5
- useServerHeadSafe({
5
+ // TODO: replace with `useServerHeadSafe`
6
+ useHeadSafe({
6
7
  ...useLocaleHead({ addSeoAttributes: true }).value,
7
8
  bodyAttrs: {
8
9
  class:
@@ -11,7 +12,7 @@ export const useAppLayout = () => {
11
12
  })
12
13
 
13
14
  // TODO: convert to `useServerHeadSafe` (https://github.com/harlan-zw/nuxt-seo-kit/issues/98)
14
- useServerSeoMeta({
15
+ useSeoMeta({
15
16
  titleTemplate: (title) =>
16
17
  title && title !== siteConfig.name
17
18
  ? `${title} ${siteConfig.titleSeparator} ${siteConfig.name}`
@@ -19,11 +20,13 @@ export const useAppLayout = () => {
19
20
  })
20
21
 
21
22
  if (appConfig.vio.seoMeta) {
22
- useServerSeoMeta(appConfig.vio.seoMeta)
23
+ // TODO: replace with `useServerSeoMeta`
24
+ useSeoMeta(appConfig.vio.seoMeta)
23
25
  }
24
26
 
25
27
  if (appConfig.vio.themeColor) {
26
- useServerSeoMeta({
28
+ // TODO: replace with `useServerSeoMeta`
29
+ useSeoMeta({
27
30
  msapplicationTileColor: appConfig.vio.themeColor,
28
31
  themeColor: appConfig.vio.themeColor,
29
32
  })
@@ -1,11 +1,10 @@
1
1
  import { Dayjs } from 'dayjs'
2
2
 
3
3
  export const useDateTime = () => {
4
- const event = useRequestEvent()
5
- const { $dayjs } = useNuxtApp()
4
+ const { $dayjs, ssrContext } = useNuxtApp()
6
5
  const timezoneCookie = useCookie(TIMEZONE_COOKIE_NAME)
7
6
 
8
- const timezoneHeader = event?.node.req.headers[TIMEZONE_HEADER_KEY]
7
+ const timezoneHeader = ssrContext?.event.node.req.headers[TIMEZONE_HEADER_KEY]
9
8
  const timezone =
10
9
  timezoneHeader && !Array.isArray(timezoneHeader)
11
10
  ? timezoneHeader
@@ -1,7 +1,8 @@
1
1
  export const useFavicons = () => {
2
2
  const appConfig = useAppConfig()
3
3
 
4
- useServerHeadSafe({
4
+ // TODO: replace with `useServerHeadSafe`
5
+ useHeadSafe({
5
6
  link: [
6
7
  {
7
8
  href: `/assets/static/favicon/site.webmanifest?v=${CACHE_VERSION}`,
@@ -17,5 +17,5 @@ export const useHeadDefault = ({
17
17
  twitterTitle: title,
18
18
  }
19
19
 
20
- useServerSeoMeta(defu(extension, defaults))
20
+ useSeoMeta(defu(extension, defaults)) // TODO: replace with `useServerSeoMeta`
21
21
  }
@@ -1,8 +1,8 @@
1
1
  export const useHost = () => {
2
- if (process.server) {
3
- const event = useRequestEvent()
2
+ const { ssrContext } = useNuxtApp()
4
3
 
5
- return getHost(event.node.req)
4
+ if (ssrContext) {
5
+ return getHost(ssrContext.event)
6
6
  } else {
7
7
  return location.host
8
8
  }
@@ -1,8 +1,12 @@
1
+ import { POLYFILLS } from '../utils/constants'
2
+
1
3
  export const usePolyfills = () => {
2
- const polyfills =
3
- 'https://polyfill.io/v3/polyfill.min.js?features=Promise&flags=gated'
4
+ const polyfills = `https://polyfill.io/v3/polyfill.min.js?features=${POLYFILLS.join(
5
+ '%2C',
6
+ )}&flags=gated`
4
7
 
5
- useServerHead({
8
+ // TODO: replace with `useServerHead`
9
+ useHead({
6
10
  link: [
7
11
  {
8
12
  rel: 'preload',
package/error.vue CHANGED
@@ -20,7 +20,9 @@ const errorProp = toRef(() => props.error)
20
20
 
21
21
  // initialization
22
22
  useAppLayout()
23
- useServerHeadSafe({
23
+
24
+ // TODO: replace with `useServerHeadSafe`
25
+ useHeadSafe({
24
26
  title: `${errorProp.value.statusCode} - ${errorProp.value.message}`,
25
27
  })
26
28
  </script>
package/nuxt.config.ts CHANGED
@@ -6,6 +6,7 @@ import { defu } from 'defu'
6
6
  import {
7
7
  BASE_URL,
8
8
  I18N_COOKIE_NAME,
9
+ I18N_MODULE_CONFIG,
9
10
  SITE_NAME,
10
11
  TIMEZONE_COOKIE_NAME,
11
12
  VIO_NUXT_BASE_CONFIG,
@@ -160,7 +161,10 @@ export default defineNuxtConfig(
160
161
  titleSeparator: '·',
161
162
  },
162
163
  sitemap: {
163
- exclude: ['/api/pages/**'],
164
+ exclude: I18N_MODULE_CONFIG.locales.map(
165
+ (locale) =>
166
+ `/${locale.code !== 'en' ? `${locale.code}/` : ''}api/pages/**`,
167
+ ),
164
168
  },
165
169
  tailwindcss: {
166
170
  cssPath: join(currentDir, './assets/css/tailwind.css'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dargmuesli/nuxt-vio",
3
- "version": "3.4.0",
3
+ "version": "3.5.1",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -41,16 +41,16 @@
41
41
  "prepare": "nuxt prepare .playground",
42
42
  "preview": "nuxt preview .playground",
43
43
  "start": "PORT=3001 node .playground/.output/server/index.mjs",
44
- "test:e2e": "playwright test",
45
- "test:e2e:dev": "cross-env NUXT_PUBLIC_IS_TESTING=1 WAIT_ON_TIMEOUT=100000 pnpm test:e2e",
46
- "test:e2e:prod": "cross-env NUXT_PUBLIC_IS_TESTING=1 WAIT_ON_TIMEOUT=10000 NODE_ENV=production pnpm test:e2e",
47
- "test:e2e:docker:build": "docker build -t test-e2e_base --build-arg UID=$(id -u) --build-arg GID=$(id -g) --target test-e2e_base ..",
48
- "test:e2e:docker:run": "docker run --rm -v \"$PWD/..:/srv/app\" -v \"$(pnpm store path):/srv/.pnpm-store\" test-e2e_base",
44
+ "test:e2e:dev": "cross-env NUXT_PUBLIC_IS_TESTING=1 pnpm test:e2e",
49
45
  "test:e2e:docker:br": "pnpm test:e2e:docker:build && pnpm test:e2e:docker:run",
50
- "test:e2e:docker:dev": "pnpm test:e2e:docker:br pnpm --dir src run test:e2e:dev",
46
+ "test:e2e:docker:build": "docker build -t test-e2e_base --build-arg UID=$(id -u) --build-arg GID=$(id -g) --target test-e2e_base ..",
51
47
  "test:e2e:docker:dev:update": "pnpm test:e2e:docker:dev --update-snapshots",
48
+ "test:e2e:docker:dev": "pnpm test:e2e:docker:br pnpm --dir src run test:e2e:dev",
49
+ "test:e2e:docker:prod:update": "pnpm test:e2e:docker:prod --update-snapshots",
52
50
  "test:e2e:docker:prod": "pnpm test:e2e:docker:br pnpm --dir src run test:e2e:prod",
53
- "test:e2e:docker:prod:update": "pnpm test:e2e:docker:prod --update-snapshots"
51
+ "test:e2e:docker:run": "docker run --rm -v \"$PWD/..:/srv/app\" -v \"$(pnpm store path):/srv/.pnpm-store\" test-e2e_base",
52
+ "test:e2e:prod": "cross-env NUXT_PUBLIC_IS_TESTING=1 NODE_ENV=production pnpm test:e2e",
53
+ "test:e2e": "playwright test"
54
54
  },
55
55
  "dependencies": {
56
56
  "@axe-core/playwright": "4.7.3",
@@ -61,7 +61,7 @@
61
61
  "@nuxtjs/html-validator": "1.5.2",
62
62
  "@nuxtjs/i18n": "8.0.0-rc.4",
63
63
  "@nuxtjs/tailwindcss": "6.8.0",
64
- "@nuxtseo/module": "2.0.0-beta.25",
64
+ "@nuxtseo/module": "2.0.0-beta.26",
65
65
  "@pinia/nuxt": "0.4.11",
66
66
  "@playwright/test": "1.37.1",
67
67
  "@tailwindcss/forms": "0.5.6",
@@ -78,12 +78,13 @@
78
78
  "cookie": "0.5.0",
79
79
  "dayjs": "2.0.0-alpha.4",
80
80
  "is-https": "4.0.0",
81
+ "jiti": "1.19.3",
81
82
  "jose": "4.14.6",
82
83
  "lodash-es": "4.17.21",
83
84
  "pinia": "2.1.6",
84
85
  "sweetalert2": "11.7.27",
85
86
  "vue-gtag": "2.0.1",
86
- "vue-tsc": "1.8.8"
87
+ "vue-tsc": "1.8.10"
87
88
  },
88
89
  "devDependencies": {
89
90
  "@intlify/eslint-plugin-vue-i18n": "3.0.0-next.3",
package/utils/auth.ts CHANGED
@@ -69,9 +69,8 @@ export const jwtStore = async ({
69
69
  }
70
70
 
71
71
  export const useJwtStore = () => {
72
- const { $urqlReset } = useNuxtApp()
72
+ const { $urqlReset, ssrContext } = useNuxtApp()
73
73
  const store = useVioAuthStore()
74
- const event = useRequestEvent()
75
74
 
76
75
  if (typeof $urqlReset !== 'function')
77
76
  throw new Error('`$urqlReset` is not a function!')
@@ -81,7 +80,7 @@ export const useJwtStore = () => {
81
80
  await jwtStore({
82
81
  $urqlReset,
83
82
  store,
84
- res: process.server ? event.node.res : undefined,
83
+ res: ssrContext ? ssrContext.event.node.res : undefined,
85
84
  jwt,
86
85
  })
87
86
  },
@@ -99,9 +98,8 @@ export const signOut = async ({
99
98
  }) => await jwtStore({ $urqlReset, store, res })
100
99
 
101
100
  export const useSignOut = () => {
102
- const { $urqlReset } = useNuxtApp()
101
+ const { $urqlReset, ssrContext } = useNuxtApp()
103
102
  const store = useVioAuthStore()
104
- const event = useRequestEvent()
105
103
 
106
104
  if (typeof $urqlReset !== 'function')
107
105
  throw new Error('`$urqlReset` is not a function!')
@@ -111,7 +109,7 @@ export const useSignOut = () => {
111
109
  await signOut({
112
110
  $urqlReset,
113
111
  store,
114
- res: process.server ? event.node.res : undefined,
112
+ res: ssrContext ? ssrContext.event.node.res : undefined,
115
113
  })
116
114
  },
117
115
  }
@@ -40,6 +40,7 @@ export const I18N_VUE_CONFIG = {
40
40
  }
41
41
  export const JWT_NAME = () =>
42
42
  `${process.env.NODE_ENV === 'production' ? '__Secure-' : ''}jwt`
43
+ export const POLYFILLS = ['Promise']
43
44
  export const REGEX_UUID =
44
45
  /^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/
45
46
  export const TIMEZONE_COOKIE_NAME = [COOKIE_PREFIX, 'tz'].join(COOKIE_SEPARATOR)
@@ -1,5 +1,3 @@
1
- import { IncomingMessage } from 'node:http'
2
-
3
1
  import { CombinedError } from '@urql/core'
4
2
  import { H3Event, getCookie } from 'h3'
5
3
 
@@ -79,10 +77,12 @@ export const getDomainTldPort = (host: string) => {
79
77
  return `${hostParts[hostParts.length - 2]}.${hostParts[hostParts.length - 1]}`
80
78
  }
81
79
 
82
- export const getHost = (req: IncomingMessage) => {
83
- if (!req.headers.host) throw new Error('Host header is not given!')
80
+ export const getHost = (event: H3Event) => {
81
+ const host = event.node.req.headers.host
82
+
83
+ if (!host) throw new Error('Host header is not given!')
84
84
 
85
- return req.headers.host
85
+ return host
86
86
  }
87
87
 
88
88
  export const getServiceHref = ({