nuxtseo-layer-devtools 0.3.6 → 0.3.7

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.
@@ -28,9 +28,9 @@ export function useDevtoolsConnection(options: DevtoolsConnectionOptions = {}):
28
28
  onDevtoolsClientConnected(async (client) => {
29
29
  isConnected.value = true
30
30
  // @ts-expect-error untyped
31
- appFetch.value = client.host.app.$fetch
31
+ appFetch.value = client.host?.app?.$fetch
32
32
  watchEffect(() => {
33
- colorMode.value = client.host.app.colorMode?.value ?? (
33
+ colorMode.value = client.host?.app?.colorMode?.value ?? (
34
34
  window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
35
35
  )
36
36
  })
@@ -38,14 +38,18 @@ export function useDevtoolsConnection(options: DevtoolsConnectionOptions = {}):
38
38
  options.onConnected?.(client)
39
39
 
40
40
  if (options.onRouteChange) {
41
- const $route = client.host.nuxt.vueApp.config.globalProperties?.$route
42
- options.onRouteChange($route)
43
- const removeAfterEach = client.host.nuxt.$router.afterEach((route: any) => {
44
- options.onRouteChange!(route)
45
- })
46
- // Clean up when devtools client disconnects
47
- // @ts-expect-error app:unmount exists at runtime but is not in RuntimeNuxtHooks
48
- client.host.nuxt.hook('app:unmount', removeAfterEach)
41
+ const $route = client.host?.nuxt?.vueApp?.config?.globalProperties?.$route
42
+ if ($route)
43
+ options.onRouteChange($route)
44
+ const $router = client.host?.nuxt?.$router
45
+ if ($router) {
46
+ const removeAfterEach = $router.afterEach((route: any) => {
47
+ options.onRouteChange!(route)
48
+ })
49
+ // Clean up when devtools client disconnects
50
+ // @ts-expect-error app:unmount exists at runtime but is not in RuntimeNuxtHooks
51
+ client.host.nuxt.hook('app:unmount', removeAfterEach)
52
+ }
49
53
  }
50
54
  })
51
55
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxtseo-layer-devtools",
3
3
  "type": "module",
4
- "version": "0.3.6",
4
+ "version": "0.3.7",
5
5
  "description": "Shared Nuxt layer for Nuxt SEO devtools clients.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -8,8 +8,8 @@ export default defineNuxtPlugin(() => {
8
8
 
9
9
  useDevtoolsConnection({
10
10
  onConnected(client) {
11
- const props = client.host.nuxt.vueApp.config.globalProperties
12
- base.value = props?.$router?.options?.history?.base || client.host.app.baseURL || '/'
11
+ const props = client.host?.nuxt?.vueApp?.config?.globalProperties
12
+ base.value = props?.$router?.options?.history?.base || client.host?.app?.baseURL || '/'
13
13
  const $route = props?.$route
14
14
  if ($route) {
15
15
  path.value = $route.path || '/'