nuxtseo-layer-devtools 0.3.5 → 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.
package/composables/rpc.ts
CHANGED
|
@@ -24,34 +24,34 @@ 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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
options.onConnected?.(client)
|
|
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
|
+
)
|
|
36
|
+
})
|
|
37
|
+
devtools.value = client.devtools
|
|
38
|
+
options.onConnected?.(client)
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
if (options.onRouteChange) {
|
|
41
|
+
const $route = client.host?.nuxt?.vueApp?.config?.globalProperties?.$route
|
|
42
|
+
if ($route)
|
|
45
43
|
options.onRouteChange($route)
|
|
46
|
-
|
|
44
|
+
const $router = client.host?.nuxt?.$router
|
|
45
|
+
if ($router) {
|
|
46
|
+
const removeAfterEach = $router.afterEach((route: any) => {
|
|
47
47
|
options.onRouteChange!(route)
|
|
48
48
|
})
|
|
49
49
|
// Clean up when devtools client disconnects
|
|
50
50
|
// @ts-expect-error app:unmount exists at runtime but is not in RuntimeNuxtHooks
|
|
51
51
|
client.host.nuxt.hook('app:unmount', removeAfterEach)
|
|
52
52
|
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
55
|
|
|
56
56
|
// Standalone mode: create appFetch from manually entered URL
|
|
57
57
|
watch(() => standaloneUrl.value, (url) => {
|
package/package.json
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
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
|
-
const props = client.host
|
|
5
|
-
base.value = props?.$router?.options?.history?.base || client.host
|
|
11
|
+
const props = client.host?.nuxt?.vueApp?.config?.globalProperties
|
|
12
|
+
base.value = props?.$router?.options?.history?.base || client.host?.app?.baseURL || '/'
|
|
6
13
|
const $route = props?.$route
|
|
7
14
|
if ($route) {
|
|
8
15
|
path.value = $route.path || '/'
|