@dargmuesli/nuxt-vio 23.0.0-beta.4 → 23.0.0-beta.5
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/package.json +1 -1
- package/server/utils/testing.ts +11 -1
package/package.json
CHANGED
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"url": "git+https://github.com/dargmuesli/vio.git"
|
|
105
105
|
},
|
|
106
106
|
"type": "module",
|
|
107
|
-
"version": "23.0.0-beta.
|
|
107
|
+
"version": "23.0.0-beta.5",
|
|
108
108
|
"scripts": {
|
|
109
109
|
"build": "pnpm run build:node",
|
|
110
110
|
"build:node": "NUXT_PUBLIC_I18N_BASE_URL=https://app.localhost:3001 nuxt build playground",
|
package/server/utils/testing.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { H3Event } from 'h3'
|
|
2
2
|
|
|
3
|
+
// `useEvent()` throws whenever there is no Nitro request context, which is the case for everything that runs at startup, such as a Nitro plugin's hooks.
|
|
4
|
+
// Testing detection still works there through the runtime config, so fall back to no event rather than letting that error escape.
|
|
5
|
+
const tryUseEvent = () => {
|
|
6
|
+
try {
|
|
7
|
+
return useEvent()
|
|
8
|
+
} catch {
|
|
9
|
+
return undefined
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
3
13
|
export const useIsTesting = ({
|
|
4
14
|
isCookieEnabled = true,
|
|
5
15
|
}:
|
|
@@ -7,7 +17,7 @@ export const useIsTesting = ({
|
|
|
7
17
|
isCookieEnabled?: boolean
|
|
8
18
|
}
|
|
9
19
|
| undefined = {}) => {
|
|
10
|
-
const event =
|
|
20
|
+
const event = tryUseEvent()
|
|
11
21
|
const runtimeConfig = useRuntimeConfig()
|
|
12
22
|
|
|
13
23
|
return getIsTesting({ event, isCookieEnabled, runtimeConfig })
|