@nuxt/devtools 0.5.4 → 0.6.0

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.
Files changed (147) hide show
  1. package/dist/chunks/module-main.mjs +134 -29
  2. package/dist/chunks/vscode.mjs +5 -2
  3. package/dist/client/200.html +2 -2
  4. package/dist/client/404.html +2 -2
  5. package/dist/client/__blank/index.html +7 -0
  6. package/dist/client/_nuxt/{Badge.ade65c69.js → Badge.bb04dbdf.js} +1 -1
  7. package/dist/client/_nuxt/CodeSnippets.vue.b3f0f3dc.js +1 -0
  8. package/dist/client/_nuxt/DrawerRight.vue.48c2c3d6.js +1 -0
  9. package/dist/client/_nuxt/DurationDisplay.vue.1f2b63ce.js +1 -0
  10. package/dist/client/_nuxt/FilepathItem.vue.67a3bac2.js +1 -0
  11. package/dist/client/_nuxt/{HelpFab.vue.1ab4e4f1.js → HelpFab.vue.e0c5b3b9.js} +1 -1
  12. package/dist/client/_nuxt/LaunchPage.vue.a3f71c42.js +1 -0
  13. package/dist/client/_nuxt/NCheckbox.vue.56878d59.js +1 -0
  14. package/dist/client/_nuxt/NCodeBlock.vue.2f00c5a7.js +2 -0
  15. package/dist/client/_nuxt/NIconButton.vue.afd698ce.js +1 -0
  16. package/dist/client/_nuxt/NIconTitle.vue.025b1812.js +1 -0
  17. package/dist/client/_nuxt/NLink.vue.efbf2660.js +1 -0
  18. package/dist/client/_nuxt/NMarkdown.vue.4a55718e.js +1 -0
  19. package/dist/client/_nuxt/{NPanelGrids.24e40025.js → NPanelGrids.e209861e.js} +1 -1
  20. package/dist/client/_nuxt/NSectionBlock.012f83f1.css +1 -0
  21. package/dist/client/_nuxt/NSectionBlock.a9d6a8bd.js +1 -0
  22. package/dist/client/_nuxt/NSelect.vue.0258c4d8.js +1 -0
  23. package/dist/client/_nuxt/NSwitch.vue.774134ee.js +1 -0
  24. package/dist/client/_nuxt/NTip.vue.b7996913.js +1 -0
  25. package/dist/client/_nuxt/{Navbar.vue.12ff05d9.js → Navbar.vue.97a344a8.js} +1 -1
  26. package/dist/client/_nuxt/NpmVersionCheck.vue.5857e84f.js +1 -0
  27. package/dist/client/_nuxt/{PanelLeftRight.vue.0d3c5a22.js → PanelLeftRight.vue.4252eb45.js} +1 -1
  28. package/dist/client/_nuxt/StateEditor.vue.a6af1a3f.js +1 -0
  29. package/dist/client/_nuxt/__blank.f74f0354.js +1 -0
  30. package/dist/client/_nuxt/analyze-build.d8530c6c.js +1 -0
  31. package/dist/client/_nuxt/assets.e5e05d1f.js +16 -0
  32. package/dist/client/_nuxt/{client.d93a636c.js → client.c658398a.js} +1 -1
  33. package/dist/client/_nuxt/{components.060d9fd5.js → components.c29053f6.js} +27 -27
  34. package/dist/client/_nuxt/custom-_name_.85ea5a6a.js +1 -0
  35. package/dist/client/_nuxt/{default.6eda7699.js → default.a568b6bd.js} +1 -1
  36. package/dist/client/_nuxt/editor.beb173d9.js +1 -0
  37. package/dist/client/_nuxt/entry.ea777320.css +1 -0
  38. package/dist/client/_nuxt/entry.eb90118b.js +19 -0
  39. package/dist/client/_nuxt/{error-404.7bcf1a44.js → error-404.47f56ae7.js} +1 -1
  40. package/dist/client/_nuxt/{error-500.b67f8091.js → error-500.3d8abd19.js} +1 -1
  41. package/dist/client/_nuxt/{error-component.5479d89e.js → error-component.97bd3af7.js} +2 -2
  42. package/dist/client/_nuxt/{full.89a525fd.js → full.039e8e59.js} +1 -1
  43. package/dist/client/_nuxt/hooks.4df47b77.js +1 -0
  44. package/dist/client/_nuxt/imports.dd38df5c.js +1 -0
  45. package/dist/client/_nuxt/{index.b8d7fad0.js → index.2d500b42.js} +1 -1
  46. package/dist/client/_nuxt/{index.a348e979.js → index.ee7015bb.js} +1 -1
  47. package/dist/client/_nuxt/json-editor-vue.6b7715bf.js +137 -0
  48. package/dist/client/_nuxt/{middleware.61ccc755.js → middleware.a6f1dc81.js} +1 -1
  49. package/dist/client/_nuxt/modules.8de52693.js +4 -0
  50. package/dist/client/_nuxt/{none.566b9a55.js → none.7a55d586.js} +1 -1
  51. package/dist/client/_nuxt/nuxt-docs.100caa70.js +1 -0
  52. package/dist/client/_nuxt/open-graph.ba654e1e.js +3 -0
  53. package/dist/client/_nuxt/overview.4725a261.js +1 -0
  54. package/dist/client/_nuxt/pages.46157a67.js +1 -0
  55. package/dist/client/_nuxt/payload.b59c0588.js +1 -0
  56. package/dist/client/_nuxt/plugins.6a2cae7a.js +1 -0
  57. package/dist/client/_nuxt/runtime-configs.4a7ef849.js +1 -0
  58. package/dist/client/_nuxt/server-routes.2d06f2c7.js +9 -0
  59. package/dist/client/_nuxt/settings.1b865c96.js +1 -0
  60. package/dist/client/_nuxt/state-components.ed0b4287.js +1 -0
  61. package/dist/client/_nuxt/storage.b18c38a9.js +1 -0
  62. package/dist/client/_nuxt/terminals.195d8588.js +9 -0
  63. package/dist/client/_nuxt/{terminals.d1dcf297.css → terminals.ae8c3544.css} +1 -1
  64. package/dist/client/_nuxt/{unocss-runtime.a821baa9.js → unocss-runtime.032bcb78.js} +2 -2
  65. package/dist/client/_nuxt/{virtual-files.2fc42163.js → virtual-files.5f7c5d81.js} +1 -1
  66. package/dist/client/index.html +2 -2
  67. package/dist/client/modules/analyze-build/index.html +2 -2
  68. package/dist/client/modules/assets/index.html +2 -2
  69. package/dist/client/modules/components/index.html +2 -2
  70. package/dist/client/modules/hooks/index.html +2 -2
  71. package/dist/client/modules/imports/index.html +2 -2
  72. package/dist/client/modules/middleware/index.html +2 -2
  73. package/dist/client/modules/modules/index.html +2 -2
  74. package/dist/client/modules/open-graph/index.html +2 -2
  75. package/dist/client/modules/overview/index.html +2 -2
  76. package/dist/client/modules/pages/index.html +2 -2
  77. package/dist/client/modules/payload/index.html +2 -2
  78. package/dist/client/modules/plugins/index.html +2 -2
  79. package/dist/client/modules/runtime-configs/index.html +2 -2
  80. package/dist/client/modules/server-routes/index.html +2 -2
  81. package/dist/client/modules/storage/index.html +2 -2
  82. package/dist/client/modules/terminals/index.html +2 -2
  83. package/dist/client/modules/virtual-files/index.html +2 -2
  84. package/dist/client/settings/index.html +2 -2
  85. package/dist/module.json +1 -1
  86. package/dist/module.mjs +1 -1
  87. package/dist/runtime/auth/index.html +71 -0
  88. package/dist/runtime/nitro/inline.d.ts +3 -0
  89. package/dist/runtime/nitro/inline.mjs +6 -0
  90. package/dist/runtime/plugins/devtools.client.d.ts +8 -0
  91. package/dist/runtime/plugins/devtools.client.mjs +73 -8
  92. package/dist/runtime/plugins/devtools.server.d.ts +2 -0
  93. package/dist/runtime/plugins/devtools.server.mjs +8 -0
  94. package/dist/runtime/plugins/view/Frame.vue +31 -228
  95. package/dist/runtime/plugins/view/FrameBox.vue +167 -0
  96. package/dist/runtime/plugins/view/Main.vue +360 -0
  97. package/dist/runtime/plugins/view/client.d.ts +3 -0
  98. package/dist/runtime/plugins/view/client.mjs +45 -0
  99. package/dist/runtime/plugins/view/state.d.ts +2 -3
  100. package/dist/runtime/plugins/view/state.mjs +12 -9
  101. package/dist/runtime/plugins/view/utils.d.ts +1 -0
  102. package/dist/runtime/plugins/view/utils.mjs +9 -0
  103. package/dist/shared/{devtools.345c630c.mjs → devtools.7ab40af4.mjs} +3 -1
  104. package/dist/types.d.ts +1 -1
  105. package/package.json +30 -29
  106. package/dist/client/__inspecting/index.html +0 -7
  107. package/dist/client/_nuxt/CodeSnippets.vue.0933ada7.js +0 -1
  108. package/dist/client/_nuxt/DrawerRight.vue.7bc0ac9b.js +0 -1
  109. package/dist/client/_nuxt/DurationDisplay.vue.d2a5c09b.js +0 -1
  110. package/dist/client/_nuxt/FilepathItem.vue.a3a55bfd.js +0 -1
  111. package/dist/client/_nuxt/LaunchPage.vue.dff3dd39.js +0 -1
  112. package/dist/client/_nuxt/NCheckbox.vue.cd1637b2.js +0 -1
  113. package/dist/client/_nuxt/NCodeBlock.vue.d5b2e85d.js +0 -2
  114. package/dist/client/_nuxt/NIconButton.vue.3defcade.js +0 -1
  115. package/dist/client/_nuxt/NIconTitle.vue.62b2ff0a.js +0 -1
  116. package/dist/client/_nuxt/NLink.vue.be635eca.js +0 -1
  117. package/dist/client/_nuxt/NMarkdown.vue.00fc3014.js +0 -1
  118. package/dist/client/_nuxt/NSectionBlock.63c19da9.css +0 -1
  119. package/dist/client/_nuxt/NSectionBlock.eb96beb4.js +0 -1
  120. package/dist/client/_nuxt/NSelect.vue.7652516b.js +0 -1
  121. package/dist/client/_nuxt/NSwitch.vue.c07ff0b7.js +0 -1
  122. package/dist/client/_nuxt/NTip.vue.3fd9b115.js +0 -1
  123. package/dist/client/_nuxt/NpmVersionCheck.vue.7bc4775a.js +0 -1
  124. package/dist/client/_nuxt/StateEditor.vue.6e8c107a.js +0 -1
  125. package/dist/client/_nuxt/__inspecting.137e909d.js +0 -1
  126. package/dist/client/_nuxt/analyze-build.790e4c36.js +0 -1
  127. package/dist/client/_nuxt/assets.1c0d54b4.js +0 -16
  128. package/dist/client/_nuxt/custom-_name_.e88f914e.js +0 -1
  129. package/dist/client/_nuxt/editor.4380b623.js +0 -1
  130. package/dist/client/_nuxt/entry.34446c1f.js +0 -19
  131. package/dist/client/_nuxt/entry.bf8a0e33.css +0 -1
  132. package/dist/client/_nuxt/hooks.99ea2107.js +0 -1
  133. package/dist/client/_nuxt/imports.29e62250.js +0 -1
  134. package/dist/client/_nuxt/json-editor-vue.62f947e8.js +0 -137
  135. package/dist/client/_nuxt/modules.f8953fab.js +0 -4
  136. package/dist/client/_nuxt/open-graph.26d327ec.js +0 -3
  137. package/dist/client/_nuxt/overview.4326006b.js +0 -1
  138. package/dist/client/_nuxt/pages.b234eacb.js +0 -1
  139. package/dist/client/_nuxt/payload.fbf9b90d.js +0 -1
  140. package/dist/client/_nuxt/plugins.9c9f9450.js +0 -1
  141. package/dist/client/_nuxt/runtime-configs.cf5a4a0c.js +0 -1
  142. package/dist/client/_nuxt/server-routes.7185e439.js +0 -9
  143. package/dist/client/_nuxt/settings.8603972f.js +0 -1
  144. package/dist/client/_nuxt/state-components.f564bfa7.js +0 -1
  145. package/dist/client/_nuxt/storage.4b5872ff.js +0 -1
  146. package/dist/client/_nuxt/terminals.d263a781.js +0 -9
  147. package/dist/runtime/plugins/view/Container.vue +0 -97
@@ -1,57 +1,17 @@
1
1
  <script setup lang="ts">
2
- import type { VueInspectorClient } from 'vite-plugin-vue-inspector'
3
- import type { PropType } from 'vue'
4
- import { computed, ref, watch, watchEffect } from 'vue'
5
- import type { NuxtDevtoolsHostClient, NuxtDevtoolsIframeClient, NuxtDevtoolsGlobal as NuxtDevtoolsViewGlobal } from '../../../types'
6
- import { PANEL_MAX, PANEL_MIN, PANEL_PADDING, closePanel, state, viewMode } from './state'
2
+ import { computed, onMounted, ref, watch, watchEffect } from 'vue'
3
+ import type { NuxtDevtoolsHostClient, NuxtDevtoolsGlobal as NuxtDevtoolsViewGlobal } from '../../../types'
4
+ import { closePanel, state } from './state'
7
5
  import { useEventListener } from './utils'
8
6
 
9
- // Can't use reactivity transform here because this file is shipped as-is,
10
- // where we can't guarantee that the user has the reactivity transform enabled.
11
- // Same for not using auto imports.
12
- const props = defineProps({
13
- client: Object as PropType<NuxtDevtoolsHostClient>,
14
- })
7
+ const props = defineProps<{
8
+ client: NuxtDevtoolsHostClient
9
+ }>()
15
10
 
16
11
  const CLIENT_PATH = '/__nuxt_devtools__/client'
17
12
 
18
13
  const initialUrl = CLIENT_PATH + state.value.route
19
14
  const iframe = ref<HTMLIFrameElement>()
20
- const isDragging = ref<false | 'vertical' | 'horizontal' | 'both'>(false)
21
-
22
- const frameStyle = computed(() => {
23
- if (viewMode.value === 'component-inspector') {
24
- return {
25
- bottom: `${PANEL_PADDING}px`,
26
- left: '50%',
27
- transform: 'translateX(-50%)',
28
- height: '80px',
29
- width: '400px',
30
- }
31
- }
32
-
33
- const height = `calc(${state.value.height}vh - ${PANEL_PADDING * 2}px)`
34
- const width = `calc(${state.value.width}vw - ${PANEL_PADDING * 2}px)`
35
-
36
- if (state.value.position === 'left' || state.value.position === 'right') {
37
- return {
38
- [state.value.position]: `${PANEL_PADDING}px`,
39
- borderRadius: '0.5rem',
40
- top: `calc(${(100 - state.value.height) / 2}vh + ${PANEL_PADDING}px)`,
41
- height,
42
- width,
43
- }
44
- }
45
- else {
46
- return {
47
- [state.value.position || 'bottom']: `${PANEL_PADDING}px`,
48
- borderRadius: '0.5rem',
49
- left: `calc(${(100 - state.value.width) / 2}vw + ${PANEL_PADDING}px)`,
50
- height,
51
- width,
52
- }
53
- }
54
- })
55
15
 
56
16
  async function onLoad() {
57
17
  await waitForClientInjection()
@@ -84,138 +44,50 @@ function refreshReactivity() {
84
44
  }
85
45
 
86
46
  function setupClient() {
87
- // trigger update for payload change
88
- watch(() => props.client?.nuxt.payload, () => {
47
+ const client = computed(() => props.client)
48
+
49
+ watch(() => [
50
+ client.value?.nuxt.payload,
51
+ client.value.colorMode.value,
52
+ client.value.loadingTimeMetrics,
53
+ ], () => {
89
54
  refreshReactivity()
90
55
  }, { deep: true })
91
56
 
92
57
  // trigger update for route change
93
- props.client?.nuxt.vueApp.config.globalProperties?.$router?.afterEach(() => {
58
+ client.value?.nuxt.vueApp.config.globalProperties?.$router?.afterEach(() => {
94
59
  refreshReactivity()
95
60
  })
96
61
 
97
62
  // trigger update for app mounted
98
- props.client?.nuxt.hook('app:mounted', () => {
63
+ client.value?.nuxt.hook('app:mounted', () => {
99
64
  refreshReactivity()
100
65
  })
101
66
 
102
67
  updateClient()
103
68
  }
104
69
 
105
- function updateClient() {
106
- const injection = iframe.value?.contentWindow?.__NUXT_DEVTOOLS_VIEW__ as NuxtDevtoolsViewGlobal
107
- const componentInspector = window.__VUE_INSPECTOR__ as VueInspectorClient
108
-
109
- if (componentInspector) {
110
- componentInspector.openInEditor = async (baseUrl, file, line, column) => {
111
- disableComponentInspector()
112
- await props.client!.hooks.callHook('host:inspector:click', baseUrl, file, line, column)
113
- }
114
- componentInspector.onUpdated = () => {
115
- props.client!.hooks.callHook('host:inspector:update', {
116
- ...componentInspector.linkParams,
117
- ...componentInspector.position,
118
- })
119
- }
120
- }
121
-
122
- injection?.setClient({
123
- ...props.client as any,
124
- inspector: {
125
- enable: enableComponentInspector,
126
- disable: disableComponentInspector,
127
- instance: componentInspector,
128
- },
129
- })
130
-
131
- props.client?.hooks.hook('devtools:navigate', (path) => {
70
+ onMounted(() => {
71
+ props.client.refreshState()
72
+ props.client.hooks.hook('devtools:navigate', (path) => {
132
73
  state.value.route = path
133
74
  })
134
- }
135
-
136
- function enableComponentInspector() {
137
- window.__VUE_INSPECTOR__?.enable()
138
- viewMode.value = 'component-inspector'
139
- }
140
-
141
- function disableComponentInspector() {
142
- if (!window.__VUE_INSPECTOR__?.enabled)
143
- return
144
-
145
- window.__VUE_INSPECTOR__?.disable()
146
- props.client?.hooks.callHook('host:inspector:close')
147
- if (viewMode.value === 'component-inspector')
148
- viewMode.value = 'default'
149
- }
150
-
151
- useEventListener(window, 'mousemove', (e: MouseEvent) => {
152
- if (!isDragging.value)
153
- return
154
-
155
- const alignSide = state.value.position === 'left' || state.value.position === 'right'
156
-
157
- if (isDragging.value === 'horizontal' || isDragging.value === 'both') {
158
- const y = state.value.position === 'top'
159
- ? window.innerHeight - e.clientY
160
- : e.clientY
161
- const boxHeight = window.innerHeight - PANEL_PADDING * 2
162
- const value = alignSide
163
- ? (Math.abs(y - (window.innerHeight / 2)) - PANEL_PADDING) / boxHeight * 100 * 2
164
- : (window.innerHeight - y - PANEL_PADDING) / boxHeight * 100
165
- state.value.height = Math.min(PANEL_MAX, Math.max(PANEL_MIN, value))
166
- }
167
-
168
- if (isDragging.value === 'vertical' || isDragging.value === 'both') {
169
- const x = state.value.position === 'left'
170
- ? window.innerWidth - e.clientX
171
- : e.clientX
172
- const boxWidth = window.innerWidth - PANEL_PADDING * 2
173
- const value = alignSide
174
- ? (window.innerWidth - x - PANEL_PADDING) / boxWidth * 100
175
- : (Math.abs(x - (window.innerWidth / 2)) - PANEL_PADDING) / boxWidth * 100 * 2
176
- state.value.width = Math.min(PANEL_MAX, Math.max(PANEL_MIN, value))
177
- }
178
- })
179
-
180
- useEventListener(window, 'mouseup', () => {
181
- isDragging.value = false
182
75
  })
183
76
 
184
- useEventListener(window, 'mouseleave', () => {
185
- isDragging.value = false
186
- })
77
+ function updateClient() {
78
+ const injection = iframe.value?.contentWindow?.__NUXT_DEVTOOLS_VIEW__ as NuxtDevtoolsViewGlobal
79
+ props.client.refreshState()
80
+ injection?.setClient(props.client)
81
+ }
187
82
 
188
83
  useEventListener(window, 'keydown', (e: KeyboardEvent) => {
189
- if (e.key === 'Escape' && (viewMode.value === 'component-inspector' || window.__VUE_INSPECTOR__?.enabled)) {
190
- disableComponentInspector()
84
+ if (e.key === 'Escape' && props.client.inspector?.isEnabled.value) {
85
+ e.preventDefault()
86
+ props.client.inspector?.disable()
191
87
  closePanel()
192
88
  }
193
89
  })
194
90
 
195
- // Close panel on outside click (when enabled)
196
- useEventListener(window, 'mousedown', (e: MouseEvent) => {
197
- if (!state.value.closeOnOutsideClick)
198
- return
199
- if (!state.value.open || isDragging.value || viewMode.value !== 'default')
200
- return
201
-
202
- const matched = e.composedPath().find((_el) => {
203
- const el = _el as HTMLElement
204
- return Array.from(el.classList || []).some(c => c.startsWith('nuxt-devtools-'))
205
- || el.tagName?.toLowerCase() === 'iframe'
206
- })
207
-
208
- if (!matched)
209
- state.value.open = false
210
- })
211
-
212
- watch(viewMode, (mode) => {
213
- if (mode === 'component-inspector')
214
- enableComponentInspector()
215
- else
216
- disableComponentInspector()
217
- }, { immediate: true })
218
-
219
91
  watchEffect(() => {
220
92
  if (!state.value.open)
221
93
  iframe.value?.blur()
@@ -224,79 +96,10 @@ watchEffect(() => {
224
96
  })
225
97
  </script>
226
98
 
227
- <script lang="ts">
228
- declare global {
229
- interface Window {
230
- __NUXT_DEVTOOLS_VIEW__?: NuxtDevtoolsViewGlobal
231
- __NUXT_DEVTOOLS__?: NuxtDevtoolsIframeClient
232
- __VUE_INSPECTOR__?: VueInspectorClient
233
- }
234
- }
235
- </script>
236
-
237
99
  <template>
238
- <div v-show="state.open" class="nuxt-devtools-frame" :style="frameStyle">
239
- <iframe
240
- ref="iframe"
241
- :src="initialUrl"
242
- :style="{
243
- 'pointer-events': isDragging ? 'none' : 'auto',
244
- }"
245
- @load="onLoad"
246
- />
247
- <template v-if="viewMode === 'default'">
248
- <div v-if="state.position !== 'top'" class="nuxt-devtools-resize-handle nuxt-devtools-resize-handle-horizontal" :style="{ top: 0 }" @mousedown.prevent="() => isDragging = 'horizontal'" />
249
- <div v-if="state.position !== 'bottom'" class="nuxt-devtools-resize-handle nuxt-devtools-resize-handle-horizontal" :style="{ bottom: 0 }" @mousedown.prevent="() => isDragging = 'horizontal'" />
250
- <div v-if="state.position !== 'left'" class="nuxt-devtools-resize-handle nuxt-devtools-resize-handle-vertical" :style="{ left: 0 }" @mousedown.prevent="() => isDragging = 'vertical'" />
251
- <div v-if="state.position !== 'right'" class="nuxt-devtools-resize-handle nuxt-devtools-resize-handle-vertical" :style="{ right: 0 }" @mousedown.prevent="() => isDragging = 'vertical'" />
252
- <div v-if="state.position !== 'top' && state.position !== 'left'" class="nuxt-devtools-resize-handle nuxt-devtools-resize-handle-corner" :style="{ top: 0, left: 0, cursor: 'nwse-resize' }" @mousedown.prevent="() => isDragging = 'both'" />
253
- <div v-if="state.position !== 'top' && state.position !== 'right'" class="nuxt-devtools-resize-handle nuxt-devtools-resize-handle-corner" :style="{ top: 0, right: 0, cursor: 'nesw-resize' }" @mousedown.prevent="() => isDragging = 'both'" />
254
- <div v-if="state.position !== 'bottom' && state.position !== 'right'" class="nuxt-devtools-resize-handle nuxt-devtools-resize-handle-corner" :style="{ bottom: 0, right: 0, cursor: 'nwse-resize' }" @mousedown.prevent="() => isDragging = 'both'" />
255
- <div v-if="state.position !== 'bottom' && state.position !== 'left'" class="nuxt-devtools-resize-handle nuxt-devtools-resize-handle-corner" :style="{ bottom: 0, left: 0, cursor: 'nesw-resize' }" @mousedown.prevent="() => isDragging = 'both'" />
256
- </template>
257
- </div>
100
+ <iframe
101
+ ref="iframe"
102
+ :src="initialUrl"
103
+ @load="onLoad"
104
+ />
258
105
  </template>
259
-
260
- <style scoped>
261
- .nuxt-devtools-frame {
262
- position: fixed;
263
- z-index: 2147483645;
264
- }
265
-
266
- .nuxt-devtools-frame iframe {
267
- width: 100%;
268
- height: 100%;
269
- outline: none;
270
- border: 1px solid rgba(125,125,125,0.2);
271
- border-radius: 10px;
272
- }
273
-
274
- .nuxt-devtools-resize-handle-horizontal {
275
- position: absolute;
276
- left: 6px;
277
- right: 6px;
278
- height: 10px;
279
- margin: -5px 0;
280
- cursor: ns-resize;
281
- border-radius: 5px;
282
- }
283
- .nuxt-devtools-resize-handle-vertical {
284
- position: absolute;
285
- top: 6px;
286
- bottom: 0;
287
- width: 10px;
288
- margin: 0 -5px;
289
- cursor: ew-resize;
290
- border-radius: 5px;
291
- }
292
- .nuxt-devtools-resize-handle-corner {
293
- position: absolute;
294
- width: 14px;
295
- height: 14px;
296
- margin: -6px;
297
- border-radius: 6px;
298
- }
299
- .nuxt-devtools-resize-handle:hover {
300
- background: rgba(125,125,125,0.1);
301
- }
302
- </style>
@@ -0,0 +1,167 @@
1
+ <script setup lang="ts">
2
+ import type { VueInspectorClient } from 'vite-plugin-vue-inspector'
3
+ import { computed, ref } from 'vue'
4
+ import type { NuxtDevtoolsHostClient, NuxtDevtoolsIframeClient, NuxtDevtoolsGlobal as NuxtDevtoolsViewGlobal } from '../../../types'
5
+ import { PANEL_MAX, PANEL_MIN, isInitialized, state } from './state'
6
+ import { useEventListener } from './utils'
7
+ import Frame from './Frame.vue'
8
+
9
+ const props = defineProps<{
10
+ client: NuxtDevtoolsHostClient
11
+ }>()
12
+
13
+ const frame = ref<InstanceType<typeof Frame>>()
14
+ const frameEl = computed(() => frame.value?.$el as HTMLElement | undefined)
15
+ const isDragging = ref<false | { top?: boolean; left?: boolean; right?: boolean; bottom?: boolean }>(false)
16
+
17
+ // Close panel on outside click (when enabled)
18
+ useEventListener(window, 'mousedown', (e: MouseEvent) => {
19
+ if (!state.value.closeOnOutsideClick)
20
+ return
21
+ if (!state.value.open || isDragging.value || props.client.inspector?.isEnabled.value)
22
+ return
23
+
24
+ const matched = e.composedPath().find((_el) => {
25
+ const el = _el as HTMLElement
26
+ return Array.from(el.classList || []).some(c => c.startsWith('nuxt-devtools-'))
27
+ || el.tagName?.toLowerCase() === 'iframe'
28
+ })
29
+
30
+ if (!matched)
31
+ state.value.open = false
32
+ })
33
+
34
+ useEventListener(window, 'mousemove', (e: MouseEvent) => {
35
+ if (!isDragging.value)
36
+ return
37
+
38
+ const box = frameEl.value?.getBoundingClientRect()
39
+
40
+ if (isDragging.value.right) {
41
+ const widthPx = Math.abs(e.clientX - (box?.left || 0))
42
+ const width = widthPx / window.innerWidth * 100
43
+ state.value.width = Math.min(PANEL_MAX, Math.max(PANEL_MIN, width))
44
+ }
45
+ else if (isDragging.value.left) {
46
+ const widthPx = Math.abs((box?.right || 0) - e.clientX)
47
+ const width = widthPx / window.innerWidth * 100
48
+ state.value.width = Math.min(PANEL_MAX, Math.max(PANEL_MIN, width))
49
+ }
50
+
51
+ if (isDragging.value.top) {
52
+ const heightPx = Math.abs((box?.bottom || 0) - e.clientY)
53
+ const height = heightPx / window.innerHeight * 100
54
+ state.value.height = Math.min(PANEL_MAX, Math.max(PANEL_MIN, height))
55
+ }
56
+ else if (isDragging.value.bottom) {
57
+ const heightPx = Math.abs(e.clientY - (box?.top || 0))
58
+ const height = heightPx / window.innerHeight * 100
59
+ state.value.height = Math.min(PANEL_MAX, Math.max(PANEL_MIN, height))
60
+ }
61
+ })
62
+
63
+ useEventListener(window, 'mouseup', () => {
64
+ isDragging.value = false
65
+ })
66
+
67
+ useEventListener(window, 'mouseleave', () => {
68
+ isDragging.value = false
69
+ })
70
+ </script>
71
+
72
+ <script lang="ts">
73
+ declare global {
74
+ interface Window {
75
+ __NUXT_DEVTOOLS_VIEW__?: NuxtDevtoolsViewGlobal
76
+ __NUXT_DEVTOOLS__?: NuxtDevtoolsIframeClient
77
+ __VUE_INSPECTOR__?: VueInspectorClient
78
+ }
79
+ }
80
+ </script>
81
+
82
+ <template>
83
+ <div v-show="state.open && !client.inspector?.isEnabled.value" class="nuxt-devtools-frame">
84
+ <Frame
85
+ v-if="isInitialized"
86
+ ref="frame"
87
+ :client="client"
88
+ :style="{
89
+ pointerEvents: isDragging ? 'none' : undefined,
90
+ }"
91
+ />
92
+ <!-- Handlers -->
93
+ <div v-if="state.position !== 'top'" class="nuxt-devtools-resize-handle nuxt-devtools-resize-handle-horizontal" :style="{ top: 0 }" @mousedown.prevent="() => isDragging = { top: true }" />
94
+ <div v-if="state.position !== 'bottom'" class="nuxt-devtools-resize-handle nuxt-devtools-resize-handle-horizontal" :style="{ bottom: 0 }" @mousedown.prevent="() => isDragging = { bottom: true }" />
95
+ <div v-if="state.position !== 'left'" class="nuxt-devtools-resize-handle nuxt-devtools-resize-handle-vertical" :style="{ left: 0 }" @mousedown.prevent="() => isDragging = { left: true }" />
96
+ <div v-if="state.position !== 'right'" class="nuxt-devtools-resize-handle nuxt-devtools-resize-handle-vertical" :style="{ right: 0 }" @mousedown.prevent="() => isDragging = { right: true }" />
97
+ <div
98
+ v-if="state.position !== 'top' && state.position !== 'left'"
99
+ class="nuxt-devtools-resize-handle nuxt-devtools-resize-handle-corner"
100
+ :style="{ top: 0, left: 0, cursor: 'nwse-resize' }"
101
+ @mousedown.prevent="() => isDragging = { top: true, left: true }"
102
+ />
103
+ <div
104
+ v-if="state.position !== 'top' && state.position !== 'right'"
105
+ class="nuxt-devtools-resize-handle nuxt-devtools-resize-handle-corner"
106
+ :style="{ top: 0, right: 0, cursor: 'nesw-resize' }"
107
+ @mousedown.prevent="() => isDragging = { top: true, right: true }"
108
+ />
109
+ <div
110
+ v-if="state.position !== 'bottom' && state.position !== 'left'"
111
+ class="nuxt-devtools-resize-handle nuxt-devtools-resize-handle-corner"
112
+ :style="{ bottom: 0, left: 0, cursor: 'nesw-resize' }"
113
+ @mousedown.prevent="() => isDragging = { bottom: true, left: true }"
114
+ />
115
+ <div
116
+ v-if="state.position !== 'bottom' && state.position !== 'right'"
117
+ class="nuxt-devtools-resize-handle nuxt-devtools-resize-handle-corner"
118
+ :style="{ bottom: 0, right: 0, cursor: 'nwse-resize' }"
119
+ @mousedown.prevent="() => isDragging = { bottom: true, right: true }"
120
+ />
121
+ </div>
122
+ </template>
123
+
124
+ <style scoped>
125
+ .nuxt-devtools-frame {
126
+ position: fixed;
127
+ z-index: 2147483645;
128
+ }
129
+
130
+ .nuxt-devtools-frame :deep(iframe) {
131
+ width: 100%;
132
+ height: 100%;
133
+ outline: none;
134
+ background: var(--nuxt-devtools-widget-bg);
135
+ border: 1px solid rgba(125,125,125,0.2);
136
+ border-radius: 10px;
137
+ }
138
+
139
+ .nuxt-devtools-resize-handle-horizontal {
140
+ position: absolute;
141
+ left: 6px;
142
+ right: 6px;
143
+ height: 10px;
144
+ margin: -5px 0;
145
+ cursor: ns-resize;
146
+ border-radius: 5px;
147
+ }
148
+ .nuxt-devtools-resize-handle-vertical {
149
+ position: absolute;
150
+ top: 6px;
151
+ bottom: 0;
152
+ width: 10px;
153
+ margin: 0 -5px;
154
+ cursor: ew-resize;
155
+ border-radius: 5px;
156
+ }
157
+ .nuxt-devtools-resize-handle-corner {
158
+ position: absolute;
159
+ width: 14px;
160
+ height: 14px;
161
+ margin: -6px;
162
+ border-radius: 6px;
163
+ }
164
+ .nuxt-devtools-resize-handle:hover {
165
+ background: rgba(125,125,125,0.1);
166
+ }
167
+ </style>