vite-plugin-vue-devtools 0.0.10 → 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.
Files changed (32) hide show
  1. package/dist/client/assets/{VCard-c441f774.js → VCard-7914da83.js} +1 -1
  2. package/dist/client/assets/{VIcon.vue_vue_type_script_setup_true_lang-4c2278af.js → VIcon.vue_vue_type_script_setup_true_lang-26cb9d64.js} +1 -1
  3. package/dist/client/assets/VIconButton.vue_vue_type_script_setup_true_lang-dab4dc71.js +39 -0
  4. package/dist/client/assets/{VIconTitle.vue_vue_type_script_setup_true_lang-3789570c.js → VIconTitle.vue_vue_type_script_setup_true_lang-1bbb2033.js} +1 -1
  5. package/dist/client/assets/{VPanelGrids-3484ea9d.js → VPanelGrids-733278d6.js} +1 -1
  6. package/dist/client/assets/{VTextInput.vue_vue_type_script_setup_true_lang-9d53f290.js → VTextInput.vue_vue_type_script_setup_true_lang-dede00e7.js} +3 -3
  7. package/dist/client/assets/{__inspecting-bbaec4fe.js → __inspecting-ac57cfe2.js} +2 -2
  8. package/dist/client/assets/{assets-facbb582.js → assets-40310f26.js} +18 -34
  9. package/dist/client/assets/{components-dfc74ac0.js → components-8abb94d8.js} +7 -6
  10. package/dist/client/assets/documentations-ab483662.js +207 -0
  11. package/dist/client/assets/{graph-736aa653.js → graph-45c33d8f.js} +2 -2
  12. package/dist/client/assets/{index-9285098c.js → index-7930cd83.js} +1 -1
  13. package/dist/client/assets/{index-359dd67c.js → index-d7f947d1.js} +271 -73
  14. package/dist/client/assets/{index-62a10721.css → index-ea632118.css} +13 -1
  15. package/dist/client/assets/{inspect-115c7185.js → inspect-95be8b35.js} +2 -2
  16. package/dist/client/assets/{overview-17f2d4a9.js → overview-f2a16196.js} +5 -5
  17. package/dist/client/assets/{pages-f46ac6f6.js → pages-52fb2c5c.js} +4 -4
  18. package/dist/client/assets/{pinia-9a9e9407.js → pinia-69e3497c.js} +5 -4
  19. package/dist/client/assets/pinia-7ed2c830.svg +1 -0
  20. package/dist/client/assets/{routes-2c268c33.js → routes-f32e8bb5.js} +7 -6
  21. package/dist/client/assets/{rpc-5a46e853.js → rpc-5116c57e.js} +1 -1
  22. package/dist/client/assets/{settings-391a112a.js → settings-a4c43db5.js} +5 -5
  23. package/dist/client/assets/{splitpanes.es-f1d0c1c1.js → splitpanes.es-09f32a7b.js} +22 -6
  24. package/dist/client/assets/{timeline-7c8f87a4.js → timeline-9da4ec07.js} +7 -6
  25. package/dist/client/assets/vue-5d4e674c.svg +1 -0
  26. package/dist/client/assets/vueuse-995374f6.svg +1 -0
  27. package/dist/client/index.html +3 -3
  28. package/dist/index.cjs +24 -1
  29. package/dist/index.mjs +24 -1
  30. package/package.json +9 -1
  31. package/src/node/Container.vue +150 -123
  32. package/src/node/app.js +1 -25
@@ -1,9 +1,10 @@
1
- import { g, M, _ as _sfc_main$2 } from './splitpanes.es-f1d0c1c1.js';
2
- import { _ as __unplugin_components_0 } from './VPanelGrids-3484ea9d.js';
3
- import { _ as __unplugin_components_7 } from './VCard-c441f774.js';
4
- import { p as pushScopeId, a as popScopeId, n as nextTick, o as openBlock, c as createBlock, w as withScopeId, m as markRaw, s as shallowReactive, r as resolveComponent, b as resolveDirective, d as withDirectives, e as createElementBlock, f as renderSlot, g as createCommentVNode, h as withCtx, F as Fragment, i as renderList, j as resolveDynamicComponent, k as mergeProps, t as toHandlers, l as normalizeStyle, q as normalizeClass, u as createVNode, v as defineComponent, x as createBaseVNode, y as toDisplayString, z as unref, A as timelineLayer, B as activeTimelineEvents, C as activeTimelineEventIndex, D as toggleTimelineEventIndex, E as timelineEventDetails, G as activeLayerId, H as toggleTimelineLayer } from './index-359dd67c.js';
5
- import './VIcon.vue_vue_type_script_setup_true_lang-4c2278af.js';
6
- import './index-9285098c.js';
1
+ import { g, M, _ as _sfc_main$2 } from './splitpanes.es-09f32a7b.js';
2
+ import { _ as __unplugin_components_0 } from './VPanelGrids-733278d6.js';
3
+ import { _ as __unplugin_components_7 } from './VCard-7914da83.js';
4
+ import { p as pushScopeId, a as popScopeId, n as nextTick, o as openBlock, c as createBlock, w as withScopeId, m as markRaw, s as shallowReactive, r as resolveComponent, b as resolveDirective, d as withDirectives, e as createElementBlock, f as renderSlot, g as createCommentVNode, h as withCtx, F as Fragment, i as renderList, j as resolveDynamicComponent, k as mergeProps, t as toHandlers, l as normalizeStyle, q as normalizeClass, u as createVNode, v as defineComponent, x as createBaseVNode, y as toDisplayString, z as unref, A as timelineLayer, B as activeTimelineEvents, C as activeTimelineEventIndex, D as toggleTimelineEventIndex, E as timelineEventDetails, G as activeLayerId, H as toggleTimelineLayer } from './index-d7f947d1.js';
5
+ import './VIcon.vue_vue_type_script_setup_true_lang-26cb9d64.js';
6
+ import './index-7930cd83.js';
7
+ import './VIconButton.vue_vue_type_script_setup_true_lang-dab4dc71.js';
7
8
 
8
9
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
9
10
 
@@ -0,0 +1 @@
1
+ <svg version="1.1" viewBox="0 0 261.76 226.69" xmlns="http://www.w3.org/2000/svg"><g transform="matrix(1.3333 0 0 -1.3333 -76.311 313.34)"><g transform="translate(178.06 235.01)"><path d="m0 0-22.669-39.264-22.669 39.264h-75.491l98.16-170.02 98.16 170.02z" fill="#41b883"/></g><g transform="translate(178.06 235.01)"><path d="m0 0-22.669-39.264-22.669 39.264h-36.227l58.896-102.01 58.896 102.01z" fill="#34495e"/></g></g></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><defs><style>.a{fill:#35495e;}.b{fill:#41b883;}</style></defs><path class="a" d="M735.07,67.05V531.58c0,129.83-105.24,235.07-235.07,235.07S264.93,661.41,264.93,531.58V67.05h166.3V531.58a68.77,68.77,0,1,0,137.54,0V67.05Z"/><path class="b" d="M901.36,67.05V531.58C901.36,753.25,721.67,933,500,933S98.64,753.25,98.64,531.58V67.05H264.93V531.58c0,129.83,105.25,235.07,235.07,235.07S735.07,661.41,735.07,531.58V67.05Z"/></svg>
@@ -4,9 +4,9 @@
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <link rel="icon" href="/favicon.svg" type="image/svg+xml">
7
- <title>Vue Devtools</title>
8
- <script type="module" crossorigin src="./assets/index-359dd67c.js"></script>
9
- <link rel="stylesheet" href="./assets/index-62a10721.css">
7
+ <title>Vue DevTools</title>
8
+ <script type="module" crossorigin src="./assets/index-d7f947d1.js"></script>
9
+ <link rel="stylesheet" href="./assets/index-ea632118.css">
10
10
  </head>
11
11
  <body>
12
12
  <div id="app"></div>
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-vue-devtools",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "packageManager": "pnpm@8.4.0",
5
5
  "description": "A vite plugin for Vue Devtools",
6
6
  "author": "webfansplz",
@@ -84,12 +84,14 @@
84
84
  "floating-vue": "2.0.0-beta.20",
85
85
  "fuse.js": "^6.6.2",
86
86
  "image-meta": "^0.1.1",
87
+ "lint-staged": "^13.2.2",
87
88
  "npm-run-all": "^4.1.5",
88
89
  "ohash": "^1.1.2",
89
90
  "pathe": "^1.1.0",
90
91
  "pinia": "^2.0.35",
91
92
  "pnpm": "^8.4.0",
92
93
  "rimraf": "^5.0.0",
94
+ "simple-git-hooks": "^2.8.1",
93
95
  "typescript": "^5.0.4",
94
96
  "unbuild": "^1.2.1",
95
97
  "unocss": "^0.51.12",
@@ -102,5 +104,11 @@
102
104
  "vite-plugin-pages": "^0.29.0",
103
105
  "vue": "^3.2.47",
104
106
  "vue-virtual-scroller": "2.0.0-beta.8"
107
+ },
108
+ "simple-git-hooks": {
109
+ "pre-commit": "pnpm lint-staged"
110
+ },
111
+ "lint-staged": {
112
+ "*": "eslint --fix"
105
113
  }
106
114
  }
@@ -1,14 +1,23 @@
1
1
  <script setup>
2
2
  import { computed, onMounted, ref } from 'vue'
3
- import vueDevtoolsOptions from 'virtual:vue-devtools-options'
3
+ import vueDevToolsOptions from 'virtual:vue-devtools-options'
4
4
 
5
- const props = defineProps({
6
- hook: {
7
- type: Object,
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 DevtoolsHooks = {
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 = `${vueDevtoolsOptions.base || '/'}__devtools/`
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(${panelHight.value}vh - ${PANEL_PADDING}px)`
56
- const width = `calc(${panelWidth.value}vw - ${PANEL_PADDING}px)`
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
- panelHight.value = Math.min(PANEL_MAX, Math.max(PANEL_MIN, value))
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
- panelWidth.value = Math.min(PANEL_MAX, Math.max(PANEL_MIN, value))
198
+ panelState.value.width = Math.min(PANEL_MAX, Math.max(PANEL_MIN, value))
176
199
  }
177
200
  })
201
+ /** -----resize end-----**/
178
202
 
179
- function togglePanel() {
180
- panelVisible.value = !panelVisible.value
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
- props.hook.emit('host:inspector:close')
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
- // eslint-disable-next-line prefer-promise-reject-errors
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: props.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 initPanelPosition() {
248
- const frameState = localStorage.getItem('__vue-devtools-frame-state__')
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 captureDynamicRoute(app) {
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
- hookBuffer.push([DevtoolsHooks.ADD_ROUTE, {
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
- hookBuffer.push([DevtoolsHooks.REMOVE_ROUTE, {
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
- let sortId = 0
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
- props.hook.on(DevtoolsHooks.APP_INIT, (app) => {
311
+ hook.on(DevToolsHooks.APP_INIT, (app) => {
295
312
  if (!app || app._instance.type?.devtools?.hide)
296
313
  return
297
314
 
298
- captureDynamicRoute(app)
299
- hookBuffer.push([DevtoolsHooks.APP_INIT, {
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
- DevtoolsHooks.COMPONENT_UPDATED,
338
- DevtoolsHooks.COMPONENT_ADDED,
339
- DevtoolsHooks.COMPONENT_REMOVED,
340
- DevtoolsHooks.COMPONENT_EMIT,
355
+ DevToolsHooks.COMPONENT_UPDATED,
356
+ DevToolsHooks.COMPONENT_ADDED,
357
+ DevToolsHooks.COMPONENT_REMOVED,
358
+ DevToolsHooks.COMPONENT_EMIT,
341
359
  ].forEach((item) => {
342
- props.hook.on(item, (app, uid, parentUid, component) => {
360
+ hook.on(item, (app, uid, parentUid, component) => {
343
361
  if (!app || (typeof uid !== 'number' && !uid) || !component || stopCollect(component))
344
362
  return
345
- hookBuffer.push([item, {
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
- <div v-if="panelState.position !== 'top'" class="vue-devtools-resize-handle vue-devtools-resize-handle-horizontal"
370
- :style="{ top: 0 }" @mousedown.prevent="() => isDragging = 'horizontal'" />
371
- <div v-if="panelState.position !== 'bottom'"
372
- class="vue-devtools-resize-handle vue-devtools-resize-handle-horizontal" :style="{ bottom: 0 }"
373
- @mousedown.prevent="() => isDragging = 'horizontal'" />
374
- <div v-if="panelState.position !== 'left'" class="vue-devtools-resize-handle vue-devtools-resize-handle-vertical"
375
- :style="{ left: 0 }" @mousedown.prevent="() => isDragging = 'vertical'" />
376
- <div v-if="panelState.position !== 'right'" class="vue-devtools-resize-handle vue-devtools-resize-handle-vertical"
377
- :style="{ right: 0 }" @mousedown.prevent="() => isDragging = 'vertical'" />
378
- <div v-if="panelState.position !== 'top' && panelState.position !== 'left'"
379
- class="vue-devtools-resize-handle vue-devtools-resize-handle-corner"
380
- :style="{ top: 0, left: 0, cursor: 'nwse-resize' }" @mousedown.prevent="() => isDragging = 'both'" />
381
- <div v-if="panelState.position !== 'top' && panelState.position !== 'right'"
382
- class="vue-devtools-resize-handle vue-devtools-resize-handle-corner"
383
- :style="{ top: 0, right: 0, cursor: 'nesw-resize' }" @mousedown.prevent="() => isDragging = 'both'" />
384
- <div v-if="panelState.position !== 'bottom' && panelState.position !== 'right'"
385
- class="vue-devtools-resize-handle vue-devtools-resize-handle-corner"
386
- :style="{ bottom: 0, right: 0, cursor: 'nwse-resize' }" @mousedown.prevent="() => isDragging = 'both'" />
387
- <div v-if="panelState.position !== 'bottom' && panelState.position !== 'left'"
388
- class="vue-devtools-resize-handle vue-devtools-resize-handle-corner"
389
- :style="{ bottom: 0, left: 0, cursor: 'nesw-resize' }" @mousedown.prevent="() => isDragging = 'both'" />
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">
@@ -402,7 +430,7 @@ initPanelPosition()
402
430
  <style scoped>
403
431
  .vue-devtools-panel {
404
432
  position: fixed;
405
- z-index: 2147483647;
433
+ z-index: 2147483645;
406
434
  width: calc(80vw - 20px);
407
435
  height: calc(60vh - 20px);
408
436
  }
@@ -420,11 +448,10 @@ initPanelPosition()
420
448
  background: #0C0C0C;
421
449
  border: 1px solid rgba(125, 125, 125, 0.2);
422
450
  box-shadow: 3px 5px 10px rgba(0, 0, 0, 0.1);
423
- z-index: 2147483647;
451
+ z-index: 2147483645;
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, { hook }),
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
- // })