vite-plugin-vue-devtools 0.0.11 → 0.0.12
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/{VCard-1be3aeea.js → VCard-7914da83.js} +1 -1
- package/dist/client/assets/{VIcon.vue_vue_type_script_setup_true_lang-1695d8db.js → VIcon.vue_vue_type_script_setup_true_lang-26cb9d64.js} +1 -1
- package/dist/client/assets/{VIconButton.vue_vue_type_script_setup_true_lang-2270abf3.js → VIconButton.vue_vue_type_script_setup_true_lang-dab4dc71.js} +2 -2
- package/dist/client/assets/{VIconTitle.vue_vue_type_script_setup_true_lang-572a0964.js → VIconTitle.vue_vue_type_script_setup_true_lang-1bbb2033.js} +1 -1
- package/dist/client/assets/{VPanelGrids-e35ca1b2.js → VPanelGrids-733278d6.js} +1 -1
- package/dist/client/assets/{VTextInput.vue_vue_type_script_setup_true_lang-3b579cad.js → VTextInput.vue_vue_type_script_setup_true_lang-dede00e7.js} +3 -3
- package/dist/client/assets/{__inspecting-a5f31235.js → __inspecting-ac57cfe2.js} +2 -2
- package/dist/client/assets/{assets-fa06fb0b.js → assets-40310f26.js} +8 -8
- package/dist/client/assets/{components-82b9b93b.js → components-8abb94d8.js} +7 -7
- package/dist/client/assets/documentations-ab483662.js +207 -0
- package/dist/client/assets/{graph-c19b9cea.js → graph-45c33d8f.js} +2 -2
- package/dist/client/assets/{index-462602ed.js → index-7930cd83.js} +1 -1
- package/dist/client/assets/{index-35968ba5.js → index-d7f947d1.js} +44 -29
- package/dist/client/assets/{index-80cdb5c4.css → index-ea632118.css} +1 -1
- package/dist/client/assets/{inspect-bb122b4f.js → inspect-95be8b35.js} +2 -2
- package/dist/client/assets/{overview-b83e2480.js → overview-f2a16196.js} +5 -5
- package/dist/client/assets/{pages-968ac2c8.js → pages-52fb2c5c.js} +4 -4
- package/dist/client/assets/{pinia-745e8151.js → pinia-69e3497c.js} +5 -5
- package/dist/client/assets/pinia-7ed2c830.svg +1 -0
- package/dist/client/assets/{routes-7fb87fa2.js → routes-f32e8bb5.js} +7 -7
- package/dist/client/assets/{rpc-1f60df18.js → rpc-5116c57e.js} +1 -1
- package/dist/client/assets/{settings-ff419377.js → settings-a4c43db5.js} +3 -3
- package/dist/client/assets/{splitpanes.es-fcdb2062.js → splitpanes.es-09f32a7b.js} +4 -4
- package/dist/client/assets/{timeline-53aba586.js → timeline-9da4ec07.js} +7 -7
- package/dist/client/assets/vue-5d4e674c.svg +1 -0
- package/dist/client/assets/vueuse-995374f6.svg +1 -0
- package/dist/client/index.html +3 -3
- package/dist/index.cjs +24 -1
- package/dist/index.mjs +24 -1
- package/package.json +1 -1
- package/src/node/Container.vue +148 -121
- package/src/node/app.js +1 -25
package/dist/index.cjs
CHANGED
|
@@ -13,6 +13,7 @@ const require$$0$1 = require('util');
|
|
|
13
13
|
const require$$0$2 = require('stream');
|
|
14
14
|
const require$$0$4 = require('events');
|
|
15
15
|
const require$$0$3 = require('fs');
|
|
16
|
+
const node_fs = require('node:fs');
|
|
16
17
|
|
|
17
18
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
18
19
|
|
|
@@ -7690,6 +7691,27 @@ async function getTextAssetContent(filepath, limit = 300) {
|
|
|
7690
7691
|
}
|
|
7691
7692
|
}
|
|
7692
7693
|
|
|
7694
|
+
async function getPackages(root) {
|
|
7695
|
+
const pkgPath = resolve(root, "package.json");
|
|
7696
|
+
const data = JSON.parse(await node_fs.promises.readFile(pkgPath, "utf-8").catch(() => "{}"));
|
|
7697
|
+
const categorizedPackages = {};
|
|
7698
|
+
const packages = {};
|
|
7699
|
+
for (const type of ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"]) {
|
|
7700
|
+
if (!data[type])
|
|
7701
|
+
continue;
|
|
7702
|
+
categorizedPackages[type] = data[type];
|
|
7703
|
+
}
|
|
7704
|
+
for (const type in categorizedPackages) {
|
|
7705
|
+
for (const name in categorizedPackages[type]) {
|
|
7706
|
+
const version = categorizedPackages[type][name];
|
|
7707
|
+
packages[name] = version;
|
|
7708
|
+
}
|
|
7709
|
+
}
|
|
7710
|
+
return {
|
|
7711
|
+
packages
|
|
7712
|
+
};
|
|
7713
|
+
}
|
|
7714
|
+
|
|
7693
7715
|
const NAME = "vite-plugin-vue-devtools";
|
|
7694
7716
|
function getVueDevtoolsPath() {
|
|
7695
7717
|
const pluginPath = vite.normalizePath(p__default.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href)))));
|
|
@@ -7712,7 +7734,8 @@ function PluginVueDevtools() {
|
|
|
7712
7734
|
inspectClientUrl: () => `${config.base || "/"}__inspect/`,
|
|
7713
7735
|
staticAssets: () => getStaticAssets(config),
|
|
7714
7736
|
getImageMeta,
|
|
7715
|
-
getTextAssetContent
|
|
7737
|
+
getTextAssetContent,
|
|
7738
|
+
getPackages: () => getPackages(config.root)
|
|
7716
7739
|
});
|
|
7717
7740
|
}
|
|
7718
7741
|
const plugin = {
|
package/dist/index.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import require$$0$1 from 'util';
|
|
|
11
11
|
import require$$0$2 from 'stream';
|
|
12
12
|
import require$$0$4 from 'events';
|
|
13
13
|
import require$$0$3 from 'fs';
|
|
14
|
+
import { promises } from 'node:fs';
|
|
14
15
|
|
|
15
16
|
const DEFAULT_TIMEOUT = 6e4;
|
|
16
17
|
function defaultSerialize(i) {
|
|
@@ -7674,6 +7675,27 @@ async function getTextAssetContent(filepath, limit = 300) {
|
|
|
7674
7675
|
}
|
|
7675
7676
|
}
|
|
7676
7677
|
|
|
7678
|
+
async function getPackages(root) {
|
|
7679
|
+
const pkgPath = resolve(root, "package.json");
|
|
7680
|
+
const data = JSON.parse(await promises.readFile(pkgPath, "utf-8").catch(() => "{}"));
|
|
7681
|
+
const categorizedPackages = {};
|
|
7682
|
+
const packages = {};
|
|
7683
|
+
for (const type of ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"]) {
|
|
7684
|
+
if (!data[type])
|
|
7685
|
+
continue;
|
|
7686
|
+
categorizedPackages[type] = data[type];
|
|
7687
|
+
}
|
|
7688
|
+
for (const type in categorizedPackages) {
|
|
7689
|
+
for (const name in categorizedPackages[type]) {
|
|
7690
|
+
const version = categorizedPackages[type][name];
|
|
7691
|
+
packages[name] = version;
|
|
7692
|
+
}
|
|
7693
|
+
}
|
|
7694
|
+
return {
|
|
7695
|
+
packages
|
|
7696
|
+
};
|
|
7697
|
+
}
|
|
7698
|
+
|
|
7677
7699
|
const NAME = "vite-plugin-vue-devtools";
|
|
7678
7700
|
function getVueDevtoolsPath() {
|
|
7679
7701
|
const pluginPath = normalizePath(p.dirname(fileURLToPath(import.meta.url)));
|
|
@@ -7696,7 +7718,8 @@ function PluginVueDevtools() {
|
|
|
7696
7718
|
inspectClientUrl: () => `${config.base || "/"}__inspect/`,
|
|
7697
7719
|
staticAssets: () => getStaticAssets(config),
|
|
7698
7720
|
getImageMeta,
|
|
7699
|
-
getTextAssetContent
|
|
7721
|
+
getTextAssetContent,
|
|
7722
|
+
getPackages: () => getPackages(config.root)
|
|
7700
7723
|
});
|
|
7701
7724
|
}
|
|
7702
7725
|
const plugin = {
|
package/package.json
CHANGED
package/src/node/Container.vue
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, onMounted, ref } from 'vue'
|
|
3
|
-
import
|
|
3
|
+
import vueDevToolsOptions from 'virtual:vue-devtools-options'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
// Reuse @vuejs/devtools instance first
|
|
6
|
+
const hook = window.__VUE_DEVTOOLS_GLOBAL_HOOK__ ??= {
|
|
7
|
+
events: new Map(),
|
|
8
|
+
on(event, fn) {
|
|
9
|
+
if (!this.events.has(event))
|
|
10
|
+
this.events.set(event, [])
|
|
11
|
+
|
|
12
|
+
this.events.get(event).push(fn)
|
|
8
13
|
},
|
|
9
|
-
|
|
14
|
+
emit(event, ...payload) {
|
|
15
|
+
if (this.events.has(event))
|
|
16
|
+
this.events.get(event).forEach(fn => fn(...payload))
|
|
17
|
+
},
|
|
18
|
+
}
|
|
10
19
|
|
|
11
|
-
const
|
|
20
|
+
const DevToolsHooks = {
|
|
12
21
|
APP_INIT: 'app:init',
|
|
13
22
|
COMPONENT_UPDATED: 'component:updated',
|
|
14
23
|
COMPONENT_ADDED: 'component:added',
|
|
@@ -20,40 +29,27 @@ const DevtoolsHooks = {
|
|
|
20
29
|
REMOVE_ROUTE: 'router:remove-route',
|
|
21
30
|
}
|
|
22
31
|
|
|
23
|
-
window.__VUE_DEVTOOLS_GLOBAL_HOOKS__ = function () {
|
|
24
|
-
return props.hook
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const isDragging = ref(false)
|
|
28
|
-
|
|
29
|
-
document.addEventListener('mouseup', () => {
|
|
30
|
-
isDragging.value = false
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
document.addEventListener('mouseleave', () => {
|
|
34
|
-
isDragging.value = false
|
|
35
|
-
})
|
|
36
|
-
|
|
37
32
|
const PANEL_MIN = 15
|
|
38
33
|
const PANEL_MAX = 100
|
|
39
34
|
const PANEL_PADDING = 10
|
|
40
35
|
|
|
41
|
-
const clientUrl = `${
|
|
36
|
+
const clientUrl = `${vueDevToolsOptions.base || '/'}__devtools/`
|
|
42
37
|
const iframe = ref()
|
|
38
|
+
|
|
39
|
+
const hookBuffer = []
|
|
40
|
+
let isAppCreated = false
|
|
41
|
+
|
|
42
|
+
/** -----panel start-----**/
|
|
43
|
+
const panelVisible = ref(false)
|
|
43
44
|
const panelState = ref({
|
|
44
45
|
position: 'bottom',
|
|
45
46
|
viewMode: 'default',
|
|
47
|
+
width: 80,
|
|
48
|
+
height: 60,
|
|
46
49
|
})
|
|
47
|
-
const panelVisible = ref(false)
|
|
48
|
-
const hookBuffer = []
|
|
49
|
-
let isAppCreated = false
|
|
50
|
-
|
|
51
|
-
const panelHight = ref(60)
|
|
52
|
-
const panelWidth = ref(80)
|
|
53
|
-
|
|
54
50
|
const panelStyle = computed(() => {
|
|
55
|
-
const height = `calc(${
|
|
56
|
-
const width = `calc(${
|
|
51
|
+
const height = `calc(${panelState.value.height}vh - ${PANEL_PADDING}px)`
|
|
52
|
+
const width = `calc(${panelState.value.width}vw - ${PANEL_PADDING}px)`
|
|
57
53
|
if (panelState.value.viewMode === 'component-inspector') {
|
|
58
54
|
return {
|
|
59
55
|
bottom: `${PANEL_PADDING}px`,
|
|
@@ -147,6 +143,33 @@ const panelPosition = computed(() =>
|
|
|
147
143
|
: { zIndex: -100000, left: '-9999px', top: '-9999px' },
|
|
148
144
|
)
|
|
149
145
|
|
|
146
|
+
function togglePanel() {
|
|
147
|
+
panelVisible.value = !panelVisible.value
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function initPanelPosition() {
|
|
151
|
+
const frameState = localStorage.getItem('__vue-devtools-frame-state__')
|
|
152
|
+
if (frameState) {
|
|
153
|
+
const parsedFrameState = JSON.parse(frameState)
|
|
154
|
+
panelState.value.position = parsedFrameState.position
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** -----resize start-----**/
|
|
159
|
+
const isDragging = ref(false)
|
|
160
|
+
const resizeBaseClassName = 'vue-devtools-resize-handle'
|
|
161
|
+
const resizeVerticalClassName = [resizeBaseClassName, `${resizeBaseClassName}-vertical`]
|
|
162
|
+
const resizeHorizontalClassName = [resizeBaseClassName, `${resizeBaseClassName}-horizontal`]
|
|
163
|
+
const resizeCornerClassName = [resizeBaseClassName, `${resizeBaseClassName}-corner`]
|
|
164
|
+
function toggleDragging(direction) {
|
|
165
|
+
isDragging.value = direction
|
|
166
|
+
}
|
|
167
|
+
document.addEventListener('mouseup', () => {
|
|
168
|
+
isDragging.value = false
|
|
169
|
+
})
|
|
170
|
+
document.addEventListener('mouseleave', () => {
|
|
171
|
+
isDragging.value = false
|
|
172
|
+
})
|
|
150
173
|
document.addEventListener('mousemove', (e) => {
|
|
151
174
|
if (!isDragging.value)
|
|
152
175
|
return
|
|
@@ -161,7 +184,7 @@ document.addEventListener('mousemove', (e) => {
|
|
|
161
184
|
const value = alignSide
|
|
162
185
|
? (Math.abs(y - (window.innerHeight / 2))) / boxHeight * 100 * 2
|
|
163
186
|
: (window.innerHeight - y) / boxHeight * 100
|
|
164
|
-
|
|
187
|
+
panelState.value.height = Math.min(PANEL_MAX, Math.max(PANEL_MIN, value))
|
|
165
188
|
}
|
|
166
189
|
|
|
167
190
|
if (isDragging.value === 'vertical' || isDragging.value === 'both') {
|
|
@@ -172,13 +195,14 @@ document.addEventListener('mousemove', (e) => {
|
|
|
172
195
|
const value = alignSide
|
|
173
196
|
? (window.innerWidth - x) / boxWidth * 100
|
|
174
197
|
: (Math.abs(x - (window.innerWidth / 2))) / boxWidth * 100 * 2
|
|
175
|
-
|
|
198
|
+
panelState.value.width = Math.min(PANEL_MAX, Math.max(PANEL_MIN, value))
|
|
176
199
|
}
|
|
177
200
|
})
|
|
201
|
+
/** -----resize end-----**/
|
|
178
202
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
203
|
+
/** -----panel end-----**/
|
|
204
|
+
|
|
205
|
+
/** -----inspector end-----**/
|
|
182
206
|
|
|
183
207
|
function enableComponentInspector() {
|
|
184
208
|
window.__VUE_INSPECTOR__?.enable()
|
|
@@ -187,11 +211,13 @@ function enableComponentInspector() {
|
|
|
187
211
|
|
|
188
212
|
function disableComponentInspector() {
|
|
189
213
|
window.__VUE_INSPECTOR__?.disable()
|
|
190
|
-
|
|
214
|
+
hook.emit('host:inspector:close')
|
|
191
215
|
if (panelState.value.viewMode === 'component-inspector')
|
|
192
216
|
panelState.value.viewMode = 'default'
|
|
193
217
|
}
|
|
218
|
+
/** -----inspector end-----**/
|
|
194
219
|
|
|
220
|
+
/** -----client start-----**/
|
|
195
221
|
function waitForClientInjection(retry = 50, timeout = 200) {
|
|
196
222
|
const test = () => !!iframe.value?.contentWindow?.__VUE_DEVTOOLS_VIEW__ && isAppCreated
|
|
197
223
|
|
|
@@ -206,18 +232,12 @@ function waitForClientInjection(retry = 50, timeout = 200) {
|
|
|
206
232
|
}
|
|
207
233
|
else if (retry-- <= 0) {
|
|
208
234
|
clearInterval(interval)
|
|
209
|
-
|
|
210
|
-
reject('Vue Devtools client injection failed')
|
|
235
|
+
reject(Error('Vue Devtools client injection failed'))
|
|
211
236
|
}
|
|
212
237
|
}, timeout)
|
|
213
238
|
})
|
|
214
239
|
}
|
|
215
240
|
|
|
216
|
-
async function onLoad() {
|
|
217
|
-
await waitForClientInjection()
|
|
218
|
-
setupClient()
|
|
219
|
-
}
|
|
220
|
-
|
|
221
241
|
function setupClient() {
|
|
222
242
|
const injection = iframe.value?.contentWindow?.__VUE_DEVTOOLS_VIEW__
|
|
223
243
|
const componentInspector = window.__VUE_INSPECTOR__
|
|
@@ -229,7 +249,7 @@ function setupClient() {
|
|
|
229
249
|
}
|
|
230
250
|
}
|
|
231
251
|
injection.setClient({
|
|
232
|
-
hook
|
|
252
|
+
hook,
|
|
233
253
|
hookBuffer,
|
|
234
254
|
inspector: {
|
|
235
255
|
enable: enableComponentInspector,
|
|
@@ -243,16 +263,13 @@ function setupClient() {
|
|
|
243
263
|
},
|
|
244
264
|
})
|
|
245
265
|
}
|
|
266
|
+
/** -----client end-----**/
|
|
246
267
|
|
|
247
|
-
function
|
|
248
|
-
|
|
249
|
-
if (frameState) {
|
|
250
|
-
const parsedFrameState = JSON.parse(frameState)
|
|
251
|
-
panelState.value.position = parsedFrameState.position
|
|
252
|
-
}
|
|
268
|
+
function updateHookBuffer(type, args) {
|
|
269
|
+
hookBuffer.push([type, args])
|
|
253
270
|
}
|
|
254
271
|
|
|
255
|
-
function
|
|
272
|
+
function collectDynamicRoute(app) {
|
|
256
273
|
const router = app?.config?.globalProperties?.$router
|
|
257
274
|
if (!router)
|
|
258
275
|
return
|
|
@@ -262,9 +279,9 @@ function captureDynamicRoute(app) {
|
|
|
262
279
|
const res = _addRoute(...args)
|
|
263
280
|
|
|
264
281
|
if (!iframe.value?.contentWindow?.__VUE_DEVTOOLS_VIEW__?.loaded) {
|
|
265
|
-
|
|
282
|
+
updateHookBuffer(DevToolsHooks.ADD_ROUTE, {
|
|
266
283
|
args: [...args],
|
|
267
|
-
}
|
|
284
|
+
})
|
|
268
285
|
}
|
|
269
286
|
|
|
270
287
|
return res
|
|
@@ -275,9 +292,9 @@ function captureDynamicRoute(app) {
|
|
|
275
292
|
const res = _removeRoute(...args)
|
|
276
293
|
|
|
277
294
|
if (!iframe.value?.contentWindow?.__VUE_DEVTOOLS_VIEW__?.loaded) {
|
|
278
|
-
|
|
295
|
+
updateHookBuffer(DevToolsHooks.REMOVE_ROUTE, {
|
|
279
296
|
args: [...args],
|
|
280
|
-
}
|
|
297
|
+
})
|
|
281
298
|
}
|
|
282
299
|
|
|
283
300
|
return res
|
|
@@ -285,110 +302,121 @@ function captureDynamicRoute(app) {
|
|
|
285
302
|
}
|
|
286
303
|
|
|
287
304
|
function collectHookBuffer() {
|
|
288
|
-
|
|
305
|
+
// const sortId = 0
|
|
289
306
|
|
|
290
307
|
function stopCollect(component) {
|
|
291
308
|
return component?.root?.type?.devtools?.hide || iframe.value?.contentWindow?.__VUE_DEVTOOLS_VIEW__?.loaded
|
|
292
309
|
}
|
|
293
310
|
|
|
294
|
-
|
|
311
|
+
hook.on(DevToolsHooks.APP_INIT, (app) => {
|
|
295
312
|
if (!app || app._instance.type?.devtools?.hide)
|
|
296
313
|
return
|
|
297
314
|
|
|
298
|
-
|
|
299
|
-
|
|
315
|
+
collectDynamicRoute(app)
|
|
316
|
+
updateHookBuffer(DevToolsHooks.APP_INIT, {
|
|
300
317
|
app,
|
|
301
|
-
}
|
|
318
|
+
})
|
|
302
319
|
setTimeout(() => {
|
|
303
320
|
isAppCreated = true
|
|
304
321
|
}, 80)
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
props.hook.on(DevtoolsHooks.PERF_START, (app, uid, component, type, time) => {
|
|
308
|
-
if (stopCollect(component))
|
|
309
|
-
return
|
|
310
|
-
|
|
311
|
-
hookBuffer.push([DevtoolsHooks.PERF_START, {
|
|
312
|
-
now: Date.now(),
|
|
313
|
-
app,
|
|
314
|
-
uid,
|
|
315
|
-
component,
|
|
316
|
-
type,
|
|
317
|
-
time,
|
|
318
|
-
sortId: sortId++,
|
|
319
|
-
}])
|
|
320
|
-
})
|
|
321
|
-
props.hook.on(DevtoolsHooks.PERF_END, (app, uid, component, type, time) => {
|
|
322
|
-
if (stopCollect(component))
|
|
323
|
-
return
|
|
324
|
-
|
|
325
|
-
hookBuffer.push([DevtoolsHooks.PERF_END, {
|
|
326
|
-
now: Date.now(),
|
|
327
|
-
app,
|
|
328
|
-
uid,
|
|
329
|
-
component,
|
|
330
|
-
type,
|
|
331
|
-
time,
|
|
332
|
-
sortId: sortId++,
|
|
333
|
-
}])
|
|
334
322
|
});
|
|
335
323
|
|
|
324
|
+
// close perf to avoid performance issue (#9)
|
|
325
|
+
// hook.on(DevToolsHooks.PERF_START, (app, uid, component, type, time) => {
|
|
326
|
+
// if (stopCollect(component))
|
|
327
|
+
// return
|
|
328
|
+
|
|
329
|
+
// updateHookBuffer(DevToolsHooks.COMPONENT_EMIT, {
|
|
330
|
+
// now: Date.now(),
|
|
331
|
+
// app,
|
|
332
|
+
// uid,
|
|
333
|
+
// component,
|
|
334
|
+
// type,
|
|
335
|
+
// time,
|
|
336
|
+
// sortId: sortId++,
|
|
337
|
+
// })
|
|
338
|
+
// })
|
|
339
|
+
// hook.on(DevToolsHooks.PERF_END, (app, uid, component, type, time) => {
|
|
340
|
+
// if (stopCollect(component))
|
|
341
|
+
// return
|
|
342
|
+
|
|
343
|
+
// updateHookBuffer(DevToolsHooks.PERF_END, {
|
|
344
|
+
// now: Date.now(),
|
|
345
|
+
// app,
|
|
346
|
+
// uid,
|
|
347
|
+
// component,
|
|
348
|
+
// type,
|
|
349
|
+
// time,
|
|
350
|
+
// sortId: sortId++,
|
|
351
|
+
// })
|
|
352
|
+
// })
|
|
353
|
+
|
|
336
354
|
[
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
355
|
+
DevToolsHooks.COMPONENT_UPDATED,
|
|
356
|
+
DevToolsHooks.COMPONENT_ADDED,
|
|
357
|
+
DevToolsHooks.COMPONENT_REMOVED,
|
|
358
|
+
DevToolsHooks.COMPONENT_EMIT,
|
|
341
359
|
].forEach((item) => {
|
|
342
|
-
|
|
360
|
+
hook.on(item, (app, uid, parentUid, component) => {
|
|
343
361
|
if (!app || (typeof uid !== 'number' && !uid) || !component || stopCollect(component))
|
|
344
362
|
return
|
|
345
|
-
|
|
363
|
+
|
|
364
|
+
updateHookBuffer(item, {
|
|
346
365
|
app, uid, parentUid, component,
|
|
347
|
-
}
|
|
366
|
+
})
|
|
348
367
|
})
|
|
349
368
|
})
|
|
350
369
|
}
|
|
351
370
|
|
|
371
|
+
// init
|
|
372
|
+
collectHookBuffer()
|
|
373
|
+
initPanelPosition()
|
|
374
|
+
|
|
375
|
+
async function onLoad() {
|
|
376
|
+
await waitForClientInjection()
|
|
377
|
+
setupClient()
|
|
378
|
+
}
|
|
379
|
+
|
|
352
380
|
onMounted(() => {
|
|
353
381
|
window.addEventListener('keydown', (e) => {
|
|
354
382
|
if (e.code === 'KeyD' && e.altKey && e.shiftKey)
|
|
355
383
|
togglePanel()
|
|
356
384
|
})
|
|
357
385
|
})
|
|
358
|
-
|
|
359
|
-
collectHookBuffer()
|
|
360
|
-
initPanelPosition()
|
|
361
386
|
</script>
|
|
362
387
|
|
|
363
388
|
<template>
|
|
364
389
|
<div class="vue-devtools-panel" :style="panelPosition">
|
|
390
|
+
<!-- client -->
|
|
365
391
|
<iframe ref="iframe" :src="clientUrl" :style="{
|
|
366
392
|
'pointer-events': isDragging ? 'none' : 'auto',
|
|
367
393
|
}" @load="onLoad" />
|
|
394
|
+
<!-- resize -->
|
|
368
395
|
<template v-if="panelState.viewMode === 'default'">
|
|
369
|
-
<
|
|
370
|
-
:style="{ top: 0 }" @mousedown.prevent="(
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
396
|
+
<template v-if="panelState.position !== 'top'">
|
|
397
|
+
<div :class="resizeHorizontalClassName" :style="{ top: 0 }" @mousedown.prevent="toggleDragging('horizontal')" />
|
|
398
|
+
<div v-if="panelState.position !== 'left'" :class="resizeCornerClassName"
|
|
399
|
+
:style="{ top: 0, left: 0, cursor: 'nwse-resize' }" @mousedown.prevent="toggleDragging('both')" />
|
|
400
|
+
<div v-if="panelState.position !== 'right'" :class="resizeCornerClassName"
|
|
401
|
+
:style="{ top: 0, right: 0, cursor: 'nesw-resize' }" @mousedown.prevent="toggleDragging('both')" />
|
|
402
|
+
</template>
|
|
403
|
+
|
|
404
|
+
<template v-if="panelState.position !== 'bottom'">
|
|
405
|
+
<div :class="resizeHorizontalClassName" :style="{ bottom: 0 }"
|
|
406
|
+
@mousedown.prevent="toggleDragging('horizontal')" />
|
|
407
|
+
<div v-if="panelState.position !== 'right'" :class="resizeCornerClassName"
|
|
408
|
+
:style="{ bottom: 0, right: 0, cursor: 'nwse-resize' }" @mousedown.prevent="toggleDragging('both')" />
|
|
409
|
+
<div v-if="panelState.position !== 'left'" :class="resizeCornerClassName"
|
|
410
|
+
:style="{ bottom: 0, left: 0, cursor: 'nesw-resize' }" @mousedown.prevent="toggleDragging('both')" />
|
|
411
|
+
</template>
|
|
412
|
+
|
|
413
|
+
<div v-if="panelState.position !== 'left'" :class="resizeVerticalClassName" :style="{ left: 0 }"
|
|
414
|
+
@mousedown.prevent="toggleDragging('vertical')" />
|
|
415
|
+
<div v-if="panelState.position !== 'right'" :class="resizeVerticalClassName" :style="{ right: 0 }"
|
|
416
|
+
@mousedown.prevent="toggleDragging('vertical')" />
|
|
390
417
|
</template>
|
|
391
418
|
</div>
|
|
419
|
+
<!-- toggle button -->
|
|
392
420
|
<button class="vue-devtools-toggle" aria-label="Toggle devtools panel" :style="toggleButtonPosition"
|
|
393
421
|
@click.prevent="togglePanel">
|
|
394
422
|
<svg viewBox="0 0 256 198" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -424,7 +452,6 @@ initPanelPosition()
|
|
|
424
452
|
cursor: pointer;
|
|
425
453
|
opacity: 0.8;
|
|
426
454
|
padding: 0;
|
|
427
|
-
align-items: center;
|
|
428
455
|
transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
|
|
429
456
|
outline: 0;
|
|
430
457
|
}
|
package/src/node/app.js
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
import { createApp, h } from 'vue'
|
|
2
2
|
import App from 'virtual:vue-devtools-path:Container.vue'
|
|
3
3
|
|
|
4
|
-
// reuse __VUE_DEVTOOLS_ (@vuejs/devtools) instance first
|
|
5
|
-
const hook = window.__VUE_DEVTOOLS_GLOBAL_HOOK__ ??= {
|
|
6
|
-
events: new Map(),
|
|
7
|
-
on(event, fn) {
|
|
8
|
-
if (!this.events.has(event))
|
|
9
|
-
this.events.set(event, [])
|
|
10
|
-
|
|
11
|
-
this.events.get(event).push(fn)
|
|
12
|
-
},
|
|
13
|
-
emit(event, ...payload) {
|
|
14
|
-
if (this.events.has(event))
|
|
15
|
-
this.events.get(event).forEach(fn => fn(...payload))
|
|
16
|
-
},
|
|
17
|
-
}
|
|
18
|
-
|
|
19
4
|
function load() {
|
|
20
5
|
const CONTAINER_ID = '__vue-devtools-container__'
|
|
21
6
|
const el = document.createElement('div')
|
|
@@ -23,19 +8,10 @@ function load() {
|
|
|
23
8
|
el.setAttribute('data-v-inspector-ignore', 'true')
|
|
24
9
|
document.getElementsByTagName('body')[0].appendChild(el)
|
|
25
10
|
createApp({
|
|
26
|
-
render: () => h(App
|
|
11
|
+
render: () => h(App),
|
|
27
12
|
devtools: {
|
|
28
13
|
hide: true,
|
|
29
14
|
},
|
|
30
15
|
}).mount(el)
|
|
31
16
|
}
|
|
32
17
|
load()
|
|
33
|
-
|
|
34
|
-
// print for iframe console
|
|
35
|
-
window.print = (...s) => {
|
|
36
|
-
console.log('print', ...s)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// hook.on('app:init', (app) => {
|
|
40
|
-
// console.log('init', app)
|
|
41
|
-
// })
|