nuxtseo-layer-devtools 0.3.5 → 0.3.6

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.
@@ -24,34 +24,30 @@ export interface DevtoolsConnectionOptions {
24
24
  * - **Standalone**: running directly in a browser tab with a manual dev server URL
25
25
  */
26
26
  export function useDevtoolsConnection(options: DevtoolsConnectionOptions = {}): void {
27
- const inIframe = window.parent !== window
28
-
29
27
  // Embedded mode: connect via devtools-kit iframe client
30
- if (inIframe) {
31
- onDevtoolsClientConnected(async (client) => {
32
- isConnected.value = true
33
- // @ts-expect-error untyped
34
- appFetch.value = client.host.app.$fetch
35
- watchEffect(() => {
36
- colorMode.value = client.host.app.colorMode?.value ?? (
37
- window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
38
- )
39
- })
40
- devtools.value = client.devtools
41
- options.onConnected?.(client)
42
-
43
- if (options.onRouteChange) {
44
- const $route = client.host.nuxt.vueApp.config.globalProperties?.$route
45
- options.onRouteChange($route)
46
- const removeAfterEach = client.host.nuxt.$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
- }
28
+ onDevtoolsClientConnected(async (client) => {
29
+ isConnected.value = true
30
+ // @ts-expect-error untyped
31
+ appFetch.value = client.host.app.$fetch
32
+ watchEffect(() => {
33
+ colorMode.value = client.host.app.colorMode?.value ?? (
34
+ window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
35
+ )
53
36
  })
54
- }
37
+ devtools.value = client.devtools
38
+ options.onConnected?.(client)
39
+
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)
49
+ }
50
+ })
55
51
 
56
52
  // Standalone mode: create appFetch from manually entered URL
57
53
  watch(() => standaloneUrl.value, (url) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxtseo-layer-devtools",
3
3
  "type": "module",
4
- "version": "0.3.5",
4
+ "version": "0.3.6",
5
5
  "description": "Shared Nuxt layer for Nuxt SEO devtools clients.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -1,4 +1,11 @@
1
1
  export default defineNuxtPlugin(() => {
2
+ const inIframe = window.parent !== window
3
+
4
+ // When served from the dev server directly (not in iframe), auto-connect to same origin
5
+ if (!inIframe && !standaloneUrl.value) {
6
+ standaloneUrl.value = window.location.origin
7
+ }
8
+
2
9
  useDevtoolsConnection({
3
10
  onConnected(client) {
4
11
  const props = client.host.nuxt.vueApp.config.globalProperties