vite-plugin-vue-devtools 0.3.2 → 0.4.2
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/dist/client/assets/{IframeView.vue_vue_type_script_setup_true_lang-73bb0458.js → IframeView.vue_vue_type_script_setup_true_lang-3efd85cd.js} +1 -1
- package/dist/client/assets/{StateFields.vue_vue_type_script_setup_true_lang-7733bfe8.js → StateFields.vue_vue_type_script_setup_true_lang-71b04a17.js} +4 -4
- package/dist/client/assets/{VIcon.vue_vue_type_script_setup_true_lang-844d8389.js → VIcon.vue_vue_type_script_setup_true_lang-bbd0395c.js} +1 -1
- package/dist/client/assets/{VIconButton.vue_vue_type_script_setup_true_lang-a2115df4.js → VIconButton.vue_vue_type_script_setup_true_lang-6f019c5b.js} +2 -2
- package/dist/client/assets/{VIconTitle.vue_vue_type_script_setup_true_lang-64110af4.js → VIconTitle.vue_vue_type_script_setup_true_lang-6c2f93bc.js} +1 -1
- package/dist/client/assets/{VPanelGrids-3a29966d.js → VPanelGrids-3d676ac1.js} +1 -1
- package/dist/client/assets/{VSectionBlock-b2b47991.js → VSectionBlock-ce3de44c.js} +3 -3
- package/dist/client/assets/{VTextInput.vue_vue_type_script_setup_true_lang-4ab475b0.js → VTextInput.vue_vue_type_script_setup_true_lang-387f21cb.js} +2 -2
- package/dist/client/assets/{__eyedropper-6c4f6cec.js → __eyedropper-e1877d6a.js} +2 -2
- package/dist/client/assets/{assets-c9b4a91c.js → assets-04d079f5.js} +8 -8
- package/dist/client/assets/{component-docs-f1e0f42d.js → component-docs-cb9ad5a2.js} +5 -5
- package/dist/client/assets/{components-8ce879b4.js → components-733e029a.js} +7 -7
- package/dist/client/assets/{documentations-8713b916.js → documentations-7d8323ed.js} +3 -3
- package/dist/client/assets/{graph-e31a8b10.js → graph-586e0cca.js} +2 -2
- package/dist/client/assets/{index-bfd864c8.js → index-5bdd8c01.js} +1 -1
- package/dist/client/assets/{index-5b7de771.css → index-99f31726.css} +1 -1
- package/dist/client/assets/{index-c8859523.js → index-fab050dd.js} +37 -49
- package/dist/client/assets/{inspect-0a6da43a.js → inspect-7b1f893a.js} +3 -3
- package/dist/client/assets/{npm-e3775c67.js → npm-068b3ea8.js} +6 -6
- package/dist/client/assets/{overview-d353d21c.js → overview-44a22030.js} +5 -5
- package/dist/client/assets/{pages-ce241043.js → pages-635198da.js} +5 -5
- package/dist/client/assets/{pinia-0dfabc87.js → pinia-f7635d5a.js} +6 -6
- package/dist/client/assets/{routes-2d8be0cc.js → routes-78f604b2.js} +7 -7
- package/dist/client/assets/{rpc-b60055dd.js → rpc-a4b59d16.js} +1 -1
- package/dist/client/assets/{settings-a79cec1c.js → settings-1082abbf.js} +3 -3
- package/dist/client/assets/{splitpanes.es-292c6c8e.js → splitpanes.es-8025e7b0.js} +1 -1
- package/dist/client/assets/{timeline-24b68a77.js → timeline-2dc5c96b.js} +7 -7
- package/dist/client/index.html +2 -2
- package/package.json +2 -1
- package/src/node/app.js +1 -1
- package/src/node/views/FrameBox.vue +212 -0
- package/src/node/views/Main.vue +382 -0
- package/src/node/views/composables.ts +402 -0
- package/src/node/views/utils.ts +204 -0
- package/dist/client/assets/__inspecting-27cecddb.js +0 -51
- package/src/node/Container.vue +0 -604
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
// @ts-expect-error virtual module
|
|
5
|
+
import vueDevToolsOptions from 'virtual:vue-devtools-options'
|
|
6
|
+
import Frame from './FrameBox.vue'
|
|
7
|
+
import { useIframe, useInspector, usePanelVisible, usePiPMode, usePosition } from './composables'
|
|
8
|
+
import { checkIsSafari, useColorScheme, usePreferredColorScheme } from './utils'
|
|
9
|
+
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
hook: {
|
|
12
|
+
type: Object,
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const hook = props.hook
|
|
18
|
+
|
|
19
|
+
const DevToolsHooks = {
|
|
20
|
+
APP_INIT: 'app:init',
|
|
21
|
+
COMPONENT_UPDATED: 'component:updated',
|
|
22
|
+
COMPONENT_ADDED: 'component:added',
|
|
23
|
+
COMPONENT_REMOVED: 'component:removed',
|
|
24
|
+
COMPONENT_EMIT: 'component:emit',
|
|
25
|
+
PERF_START: 'perf:start',
|
|
26
|
+
PERF_END: 'perf:end',
|
|
27
|
+
ADD_ROUTE: 'router:add-route',
|
|
28
|
+
REMOVE_ROUTE: 'router:remove-route',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const hookBuffer: [string, { args: any[] }][] = []
|
|
32
|
+
|
|
33
|
+
let isAppCreated = false
|
|
34
|
+
const panelState = ref<{
|
|
35
|
+
viewMode: 'default' | 'xs'
|
|
36
|
+
}>({
|
|
37
|
+
viewMode: 'default',
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const { togglePanelVisible, closePanel, panelVisible } = usePanelVisible()
|
|
41
|
+
const panelEl = ref<HTMLDivElement>()
|
|
42
|
+
const { onPointerDown, anchorStyle, iframeStyle, isDragging, isVertical } = usePosition(panelEl)
|
|
43
|
+
const vars = computed(() => {
|
|
44
|
+
const colorScheme = useColorScheme()
|
|
45
|
+
const dark = colorScheme.value === 'auto'
|
|
46
|
+
? usePreferredColorScheme().value === 'dark'
|
|
47
|
+
: colorScheme.value === 'dark'
|
|
48
|
+
return {
|
|
49
|
+
'--vue-devtools-widget-bg': dark ? '#111' : '#ffffff',
|
|
50
|
+
'--vue-devtools-widget-fg': dark ? '#F5F5F5' : '#111',
|
|
51
|
+
'--vue-devtools-widget-border': dark ? '#3336' : '#efefef',
|
|
52
|
+
'--vue-devtools-widget-shadow': dark ? 'rgba(0,0,0,0.3)' : 'rgba(128,128,128,0.1)',
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
function waitForClientInjection(iframe: HTMLIFrameElement, retry = 50, timeout = 200): Promise<void> | void {
|
|
57
|
+
const test = () => !!iframe?.contentWindow?.__VUE_DEVTOOLS_VIEW__ && isAppCreated
|
|
58
|
+
|
|
59
|
+
if (test())
|
|
60
|
+
return
|
|
61
|
+
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
const interval = setInterval(() => {
|
|
64
|
+
if (test()) {
|
|
65
|
+
clearInterval(interval)
|
|
66
|
+
resolve()
|
|
67
|
+
}
|
|
68
|
+
else if (retry-- <= 0) {
|
|
69
|
+
clearInterval(interval)
|
|
70
|
+
reject(Error('Vue Devtools client injection failed'))
|
|
71
|
+
}
|
|
72
|
+
}, timeout)
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const {
|
|
77
|
+
toggleInspector, inspectorLoaded,
|
|
78
|
+
inspectorEnabled, disableInspector,
|
|
79
|
+
} = useInspector()
|
|
80
|
+
|
|
81
|
+
const clientUrl = `${vueDevToolsOptions.base || '/'}__devtools__/`
|
|
82
|
+
const { iframe, getIframe } = useIframe(clientUrl, async () => {
|
|
83
|
+
const iframe = getIframe()
|
|
84
|
+
await waitForClientInjection(iframe)
|
|
85
|
+
setupClient(iframe)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
// Picture-in-Picture mode
|
|
89
|
+
const { popup } = usePiPMode(getIframe, hook)
|
|
90
|
+
|
|
91
|
+
function setupClient(iframe: HTMLIFrameElement) {
|
|
92
|
+
const injection: any = iframe?.contentWindow?.__VUE_DEVTOOLS_VIEW__
|
|
93
|
+
injection.setClient({
|
|
94
|
+
hook,
|
|
95
|
+
hookBuffer,
|
|
96
|
+
// inspector: {
|
|
97
|
+
// enable: enableInspector,
|
|
98
|
+
// disable: disableInspector,
|
|
99
|
+
// },
|
|
100
|
+
panel: {
|
|
101
|
+
toggleViewMode: () => {
|
|
102
|
+
if (panelState.value.viewMode === 'xs')
|
|
103
|
+
panelState.value.viewMode = 'default'
|
|
104
|
+
else
|
|
105
|
+
panelState.value.viewMode = 'xs'
|
|
106
|
+
},
|
|
107
|
+
toggle: togglePanelVisible,
|
|
108
|
+
togglePosition(position) {
|
|
109
|
+
if (position === 'popup')
|
|
110
|
+
popup()
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function updateHookBuffer(type, args) {
|
|
117
|
+
hookBuffer.push([type, args])
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function collectDynamicRoute(app) {
|
|
121
|
+
const router = app?.config?.globalProperties?.$router
|
|
122
|
+
if (!router)
|
|
123
|
+
return
|
|
124
|
+
|
|
125
|
+
const _addRoute = router.addRoute
|
|
126
|
+
router.addRoute = (...args) => {
|
|
127
|
+
const res = _addRoute(...args)
|
|
128
|
+
|
|
129
|
+
if (!iframe.value?.contentWindow?.__VUE_DEVTOOLS_VIEW__?.loaded) {
|
|
130
|
+
updateHookBuffer(DevToolsHooks.ADD_ROUTE, {
|
|
131
|
+
args: [...args],
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return res
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const _removeRoute = router.removeRoute
|
|
139
|
+
router.removeRoute = (...args) => {
|
|
140
|
+
const res = _removeRoute(...args)
|
|
141
|
+
|
|
142
|
+
if (!iframe.value?.contentWindow?.__VUE_DEVTOOLS_VIEW__?.loaded) {
|
|
143
|
+
updateHookBuffer(DevToolsHooks.REMOVE_ROUTE, {
|
|
144
|
+
args: [...args],
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return res
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function collectHookBuffer() {
|
|
153
|
+
// const sortId = 0
|
|
154
|
+
|
|
155
|
+
function stopCollect(component) {
|
|
156
|
+
return component?.root?.type?.devtools?.hide || iframe.value?.contentWindow?.__VUE_DEVTOOLS_VIEW__?.loaded
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
hook.on(DevToolsHooks.APP_INIT, (app) => {
|
|
160
|
+
if (!app || app._instance.type?.devtools?.hide)
|
|
161
|
+
return
|
|
162
|
+
|
|
163
|
+
collectDynamicRoute(app)
|
|
164
|
+
updateHookBuffer(DevToolsHooks.APP_INIT, {
|
|
165
|
+
app,
|
|
166
|
+
})
|
|
167
|
+
setTimeout(() => {
|
|
168
|
+
isAppCreated = true
|
|
169
|
+
}, 80)
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// close perf to avoid performance issue (#9)
|
|
173
|
+
// hook.on(DevToolsHooks.PERF_START, (app, uid, component, type, time) => {
|
|
174
|
+
// if (stopCollect(component))
|
|
175
|
+
// return
|
|
176
|
+
|
|
177
|
+
// updateHookBuffer(DevToolsHooks.COMPONENT_EMIT, {
|
|
178
|
+
// now: Date.now(),
|
|
179
|
+
// app,
|
|
180
|
+
// uid,
|
|
181
|
+
// component,
|
|
182
|
+
// type,
|
|
183
|
+
// time,
|
|
184
|
+
// sortId: sortId++,
|
|
185
|
+
// })
|
|
186
|
+
// })
|
|
187
|
+
// hook.on(DevToolsHooks.PERF_END, (app, uid, component, type, time) => {
|
|
188
|
+
// if (stopCollect(component))
|
|
189
|
+
// return
|
|
190
|
+
|
|
191
|
+
// updateHookBuffer(DevToolsHooks.PERF_END, {
|
|
192
|
+
// now: Date.now(),
|
|
193
|
+
// app,
|
|
194
|
+
// uid,
|
|
195
|
+
// component,
|
|
196
|
+
// type,
|
|
197
|
+
// time,
|
|
198
|
+
// sortId: sortId++,
|
|
199
|
+
// })
|
|
200
|
+
// })
|
|
201
|
+
|
|
202
|
+
[
|
|
203
|
+
DevToolsHooks.COMPONENT_UPDATED,
|
|
204
|
+
DevToolsHooks.COMPONENT_ADDED,
|
|
205
|
+
DevToolsHooks.COMPONENT_REMOVED,
|
|
206
|
+
DevToolsHooks.COMPONENT_EMIT,
|
|
207
|
+
].forEach((item) => {
|
|
208
|
+
hook.on(item, (app, uid, parentUid, component) => {
|
|
209
|
+
if (!app || (typeof uid !== 'number' && !uid) || !component || stopCollect(component))
|
|
210
|
+
return
|
|
211
|
+
|
|
212
|
+
updateHookBuffer(item, {
|
|
213
|
+
app, uid, parentUid, component,
|
|
214
|
+
})
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// init
|
|
220
|
+
collectHookBuffer()
|
|
221
|
+
</script>
|
|
222
|
+
|
|
223
|
+
<template>
|
|
224
|
+
<div
|
|
225
|
+
id="vue-devtools-anchor"
|
|
226
|
+
:style="[anchorStyle, vars]"
|
|
227
|
+
:class="{ 'vue-devtools-vertical': isVertical }"
|
|
228
|
+
>
|
|
229
|
+
<!-- toggle button -->
|
|
230
|
+
<div v-if="!checkIsSafari()" class="vue-devtools-glowing" :style="isDragging ? 'opacity: 0.6 !important' : ''" />
|
|
231
|
+
<div ref="panelEl" class="vue-devtools-button-panel" @pointerdown="onPointerDown">
|
|
232
|
+
<button
|
|
233
|
+
class="vue-devtools-icon-button vue-devtools-vue-button"
|
|
234
|
+
title="Toggle Vue DevTools" aria-label="Toggle devtools panel"
|
|
235
|
+
:style="panelVisible ? '' : 'filter:saturate(0)'"
|
|
236
|
+
@click="togglePanelVisible"
|
|
237
|
+
>
|
|
238
|
+
<svg viewBox="0 0 256 198" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
239
|
+
<path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z" />
|
|
240
|
+
<path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z" />
|
|
241
|
+
<path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z" />
|
|
242
|
+
</svg>
|
|
243
|
+
</button>
|
|
244
|
+
<div style="border-left: 1px solid #8883;width:1px;height:10px;" />
|
|
245
|
+
<button
|
|
246
|
+
class="vue-devtools-icon-button vue-devtools-inspector-button"
|
|
247
|
+
:class="{ disabled: !inspectorLoaded }"
|
|
248
|
+
:disabled="!inspectorLoaded"
|
|
249
|
+
title="Toggle Component Inspector" @click="toggleInspector"
|
|
250
|
+
>
|
|
251
|
+
<svg
|
|
252
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
253
|
+
style="height: 1.1em; width: 1.1em; opacity:0.5;"
|
|
254
|
+
:style="inspectorEnabled ? 'opacity:1;color:#00dc82' : ''"
|
|
255
|
+
viewBox="0 0 24 24"
|
|
256
|
+
>
|
|
257
|
+
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><circle cx="12" cy="12" r=".5" fill="currentColor" /><path d="M5 12a7 7 0 1 0 14 0a7 7 0 1 0-14 0m7-9v2m-9 7h2m7 7v2m7-9h2" /></g>
|
|
258
|
+
</svg>
|
|
259
|
+
</button>
|
|
260
|
+
</div>
|
|
261
|
+
<!-- iframe -->
|
|
262
|
+
<Frame
|
|
263
|
+
:style="iframeStyle" :is-dragging="isDragging"
|
|
264
|
+
:client="{
|
|
265
|
+
close: closePanel,
|
|
266
|
+
inspector: {
|
|
267
|
+
disable: disableInspector,
|
|
268
|
+
isEnabled: ref(inspectorEnabled),
|
|
269
|
+
},
|
|
270
|
+
getIFrame: getIframe,
|
|
271
|
+
}"
|
|
272
|
+
:view-mode="panelState.viewMode"
|
|
273
|
+
/>
|
|
274
|
+
</div>
|
|
275
|
+
</template>
|
|
276
|
+
|
|
277
|
+
<style scoped>
|
|
278
|
+
#vue-devtools-anchor {
|
|
279
|
+
position: fixed;
|
|
280
|
+
z-index: 2147483645;
|
|
281
|
+
transform-origin: center center;
|
|
282
|
+
transform: translate(-50%, -50%) rotate(0);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
#vue-devtools-anchor button {
|
|
286
|
+
border: none;
|
|
287
|
+
background: none;
|
|
288
|
+
padding: 0;
|
|
289
|
+
margin: 0;
|
|
290
|
+
cursor: pointer;
|
|
291
|
+
outline: none;
|
|
292
|
+
color: inherit;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
#vue-devtools-anchor .vue-devtools-glowing {
|
|
296
|
+
position: absolute;
|
|
297
|
+
left: 0;
|
|
298
|
+
top: 0;
|
|
299
|
+
transform: translate(-50%, -50%);
|
|
300
|
+
width: 160px;
|
|
301
|
+
height: 160px;
|
|
302
|
+
opacity: 0;
|
|
303
|
+
transition: all 0.8s ease;
|
|
304
|
+
pointer-events: none;
|
|
305
|
+
z-index: -1;
|
|
306
|
+
border-radius: 9999px;
|
|
307
|
+
background-image: linear-gradient(45deg,#00dc82,#36e4da,#0047e1);
|
|
308
|
+
filter: blur(60px);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
#vue-devtools-anchor .vue-devtools-icon-button {
|
|
312
|
+
border-radius: 100%;
|
|
313
|
+
border-width: 0;
|
|
314
|
+
width: 30px;
|
|
315
|
+
height: 30px;
|
|
316
|
+
display: flex;
|
|
317
|
+
justify-content: center;
|
|
318
|
+
align-items: center;
|
|
319
|
+
opacity: 0.8;
|
|
320
|
+
transition: opacity 0.2s ease-in-out;
|
|
321
|
+
}
|
|
322
|
+
#vue-devtools-anchor .vue-devtools-icon-button:hover {
|
|
323
|
+
opacity: 1;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
#vue-devtools-anchor .vue-devtools-icon-button svg {
|
|
327
|
+
width: 14px;
|
|
328
|
+
height: 14px;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
#vue-devtools-anchor:hover .vue-devtools-glowing {
|
|
332
|
+
opacity: 0.6;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
#vue-devtools-anchor .vue-devtools-button-panel {
|
|
336
|
+
position: absolute;
|
|
337
|
+
left: 0;
|
|
338
|
+
top: 0;
|
|
339
|
+
transform: translate(-50%, -50%);
|
|
340
|
+
display: flex;
|
|
341
|
+
justify-content: center;
|
|
342
|
+
align-items: center;
|
|
343
|
+
gap: 2px;
|
|
344
|
+
height: 20px;
|
|
345
|
+
padding: 4px 4px 4px 5px;
|
|
346
|
+
border: 1px solid var(--vue-devtools-widget-border);
|
|
347
|
+
border-radius: 20px;
|
|
348
|
+
background-color: var(--vue-devtools-widget-bg);
|
|
349
|
+
backdrop-filter: blur(10px);
|
|
350
|
+
color: var(--vue-devtools-widget-fg);
|
|
351
|
+
box-shadow: 2px 2px 8px var(--vue-devtools-widget-shadow);
|
|
352
|
+
transition: background 0.2s ease;
|
|
353
|
+
user-select: none;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
#vue-devtools-anchor.vue-devtools-vertical .vue-devtools-vue-button {
|
|
357
|
+
transform: rotate(-90deg);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
#vue-devtools-anchor.vue-devtools-vertical .vue-devtools-button-panel {
|
|
361
|
+
transform: translate(-50%, -50%) rotate(90deg);
|
|
362
|
+
box-shadow: 2px -2px 8px var(--nuxt-devtools-widget-shadow);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
#vue-devtools-anchor .vue-devtools-inspector-button.disabled {
|
|
366
|
+
opacity: 0.2;
|
|
367
|
+
cursor: not-allowed;
|
|
368
|
+
animation: blink 1.5s linear infinite;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
@keyframes blink {
|
|
372
|
+
0% {
|
|
373
|
+
opacity: 0.2;
|
|
374
|
+
}
|
|
375
|
+
50% {
|
|
376
|
+
opacity: 0.6;
|
|
377
|
+
}
|
|
378
|
+
100% {
|
|
379
|
+
opacity: 0.2;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
</style>
|