vite-plugin-vue-devtools 0.0.1-alpha.0 → 0.0.1-alpha.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.
Files changed (30) hide show
  1. package/dist/client/assets/VCard-07e53519.js +15 -0
  2. package/dist/client/assets/VIcon.vue_vue_type_script_setup_true_lang-c622c694.js +19 -0
  3. package/dist/client/assets/VIconTitle.vue_vue_type_script_setup_true_lang-5f26c7d7.js +30 -0
  4. package/dist/client/assets/VPanelGrids-2e4d7603.js +15 -0
  5. package/dist/client/assets/VTextInput-52804693.css +18 -0
  6. package/dist/client/assets/VTextInput.vue_vue_type_script_setup_true_lang-11aa9678.js +145 -0
  7. package/dist/client/assets/__inspecting-ca212e33.js +51 -0
  8. package/dist/client/assets/assets-7d94be21.js +1403 -0
  9. package/dist/client/assets/components-f04eb68e.js +699 -0
  10. package/dist/client/assets/fuse.esm-c317b696.js +1782 -0
  11. package/dist/client/assets/graph-b9e504aa.js +52260 -0
  12. package/dist/client/assets/index-ab9e9151.js +15372 -0
  13. package/dist/client/assets/index-f0fa9f81.css +454 -0
  14. package/dist/client/assets/inspect-d697adb8.js +96 -0
  15. package/dist/client/assets/overview-afb7d69a.js +305 -0
  16. package/dist/client/assets/pages-43ddf646.js +21 -0
  17. package/dist/client/assets/pages-4aa45253.js +320 -0
  18. package/dist/client/assets/pinia-178be7b6.js +139 -0
  19. package/dist/client/assets/routes-cd4e8e50.js +129 -0
  20. package/dist/client/assets/rpc-c07563d7.js +136 -0
  21. package/dist/client/assets/settings-c9f4467d.js +299 -0
  22. package/dist/client/assets/splitpanes.es-f2ab0d30.js +725 -0
  23. package/dist/client/assets/timeline-6da2fbae.js +209 -0
  24. package/dist/client/index.html +23 -0
  25. package/dist/index.cjs +7764 -0
  26. package/dist/index.d.ts +5 -0
  27. package/dist/index.mjs +7748 -0
  28. package/package.json +92 -8
  29. package/src/node/Container.vue +298 -0
  30. package/src/node/app.js +41 -0
package/package.json CHANGED
@@ -1,18 +1,102 @@
1
1
  {
2
2
  "name": "vite-plugin-vue-devtools",
3
- "version": "0.0.1-alpha.0",
4
- "description": "Vue Devtools",
5
- "scripts": {
6
- },
3
+ "version": "0.0.1-alpha.2",
4
+ "packageManager": "pnpm@7.30.0",
5
+ "description": "A vite plugin for Vue Devtools",
6
+ "author": "webfansplz",
7
+ "license": "MIT",
8
+ "homepage": "https://github.com/webfansplz/vite-plugin-vue-devtools#readme",
7
9
  "repository": {
8
10
  "type": "git",
9
11
  "url": "git+https://github.com/webfansplz/vite-plugin-vue-devtools.git"
10
12
  },
11
- "keywords": [],
12
- "author": "",
13
- "license": "MIT",
14
13
  "bugs": {
15
14
  "url": "https://github.com/webfansplz/vite-plugin-vue-devtools/issues"
16
15
  },
17
- "homepage": "https://github.com/webfansplz/vite-plugin-vue-devtools#readme"
16
+ "keywords": [
17
+ "vue-devtools",
18
+ "vite-plugin",
19
+ "vite-plugin-vue-devtools",
20
+ "vue",
21
+ "vite"
22
+ ],
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "require": "./dist/index.cjs",
27
+ "import": "./dist/index.mjs"
28
+ },
29
+ "./*": "./*"
30
+ },
31
+ "main": "dist/index.cjs",
32
+ "module": "dist/index.mjs",
33
+ "types": "dist/index.d.ts",
34
+ "files": [
35
+ "dist",
36
+ "src/node/app.js",
37
+ "src/node/Container.vue",
38
+ "*.d.ts"
39
+ ],
40
+ "engines": {
41
+ "node": ">=14"
42
+ },
43
+ "scripts": {
44
+ "build": "rimraf dist && run-s build:*",
45
+ "build:client": "vite build src/client",
46
+ "build:js": "unbuild",
47
+ "dev": "nr stub && vite src/client",
48
+ "dev:client": "vite build src/client --watch",
49
+ "play": "nr -C playground dev",
50
+ "stub": "unbuild --stub",
51
+ "lint": "eslint . --fix",
52
+ "prepublishOnly": "npm run build",
53
+ "release": "bumpp && npm publish"
54
+ },
55
+ "dependencies": {
56
+ "@vueuse/core": "^10.1.2",
57
+ "nanoid": "^4.0.2",
58
+ "sirv": "^2.0.2",
59
+ "splitpanes": "^3.1.5",
60
+ "vite-hot-client": "^0.2.1",
61
+ "vite-plugin-vue-inspector": "^3.4.1",
62
+ "vue-router": "^4.1.6"
63
+ },
64
+ "devDependencies": {
65
+ "@antfu/eslint-config": "^0.38.5",
66
+ "@antfu/ni": "^0.21.3",
67
+ "@iconify/json": "^2.2.52",
68
+ "@nuxt/devtools-ui-kit": "^0.4.1",
69
+ "@types/codemirror": "^5.60.7",
70
+ "@types/node": "^18.15.13",
71
+ "@types/splitpanes": "^2.2.1",
72
+ "@unocss/eslint-config": "^0.51.5",
73
+ "@unocss/reset": "^0.51.5",
74
+ "@vitejs/plugin-vue": "^4.1.0",
75
+ "bumpp": "^9.1.0",
76
+ "codemirror": "^6.0.1",
77
+ "codemirror-theme-vars": "^0.1.2",
78
+ "dayjs": "^1.11.7",
79
+ "eslint": "^8.38.0",
80
+ "fast-glob": "^3.2.12",
81
+ "floating-vue": "2.0.0-beta.20",
82
+ "fuse.js": "^6.6.2",
83
+ "image-meta": "^0.1.1",
84
+ "npm-run-all": "^4.1.5",
85
+ "ohash": "^1.1.2",
86
+ "pathe": "^1.1.0",
87
+ "pinia": "^2.0.35",
88
+ "rimraf": "^5.0.0",
89
+ "typescript": "^5.0.4",
90
+ "unbuild": "^1.2.1",
91
+ "unocss": "^0.51.5",
92
+ "unplugin-auto-import": "^0.15.3",
93
+ "unplugin-vue-components": "^0.24.1",
94
+ "vis-data": "^7.1.6",
95
+ "vis-network": "^9.1.6",
96
+ "vite": "^4.3.1",
97
+ "vite-dev-rpc": "^0.1.2",
98
+ "vite-plugin-inspect": "^0.7.23",
99
+ "vite-plugin-pages": "^0.29.0",
100
+ "vue": "^3.2.47"
101
+ }
18
102
  }
@@ -0,0 +1,298 @@
1
+ <script setup>
2
+ import { computed, defineProps, ref } from 'vue'
3
+ import vueDevtoolsOptions from 'virtual:vue-devtools-options'
4
+
5
+ const props = defineProps({
6
+ hook: {
7
+ type: Object,
8
+ },
9
+ })
10
+
11
+ window.__VUE_DEVTOOLS_GLOBAL_HOOKS__ = function () {
12
+ return props.hook
13
+ }
14
+
15
+ const clientUrl = `${vueDevtoolsOptions.base || '/'}__devtools/`
16
+ const iframe = ref()
17
+ const panelState = ref({
18
+ position: 'bottom',
19
+ viewMode: 'default',
20
+ })
21
+ const panelVisible = ref(false)
22
+ const hookBuffer = []
23
+ const panelStyle = computed(() => {
24
+ if (panelState.value.viewMode === 'component-inspector') {
25
+ return {
26
+ bottom: '10px',
27
+ left: '50%',
28
+ transform: 'translateX(-50%)',
29
+ height: '80px',
30
+ width: '400px',
31
+ }
32
+ }
33
+
34
+ if (panelState.value.position === 'bottom') {
35
+ return {
36
+ transform: 'translateX(-50%)',
37
+ bottom: '10px',
38
+ left: '50%',
39
+ }
40
+ }
41
+ else if (panelState.value.position === 'top') {
42
+ return {
43
+ transform: 'translateX(-50%)',
44
+ top: '10px',
45
+ left: '50%',
46
+ }
47
+ }
48
+ else if (panelState.value.position === 'left') {
49
+ return {
50
+ transform: 'translateY(-50%)',
51
+ top: '50%',
52
+ left: '10px',
53
+ }
54
+ }
55
+ else {
56
+ return {
57
+ transform: 'translateY(-50%)',
58
+ top: '50%',
59
+ right: '10px',
60
+ }
61
+ }
62
+ })
63
+ const toggleButtonPosition = computed(() => {
64
+ if (panelState.value.position === 'left') {
65
+ return {
66
+ 'left': '-8px',
67
+ 'top': 'calc(50% - 25px)',
68
+ 'height': '35px',
69
+ 'width': '35px',
70
+ 'borderRadius': '0 100px 100px 0',
71
+ '--hover-translate': 'translateX(3px)',
72
+ }
73
+ }
74
+ if (panelState.value.position === 'right') {
75
+ return {
76
+ 'right': '-8px',
77
+ 'top': 'calc(50% - 25px)',
78
+ 'height': '35px',
79
+ 'width': '35px',
80
+ 'borderRadius': '100px 0 0 100px',
81
+ '--hover-translate': 'translateX(-3px)',
82
+ }
83
+ }
84
+ if (panelState.value.position === 'top') {
85
+ return {
86
+ 'top': '-3px',
87
+ 'left': 'calc(50% - 25px)',
88
+ 'borderRadius': '0 0 100px 100px',
89
+ 'height': '30px',
90
+ 'width': '40px',
91
+ '--hover-translate': 'translate(0, 3px)',
92
+ }
93
+ }
94
+ return {
95
+ 'bottom': '-5px',
96
+ 'left': 'calc(50% - 25px)',
97
+ 'borderRadius': '100px 100px 0 0',
98
+ 'height': '30px',
99
+ 'width': '40px',
100
+ '--hover-translate': 'translate(0, -3px)',
101
+ }
102
+ })
103
+ const panelPosition = computed(() => panelVisible.value ? panelStyle.value : { zIndex: -100000 })
104
+
105
+ function togglePanel() {
106
+ panelVisible.value = !panelVisible.value
107
+ }
108
+
109
+ function enableComponentInspector() {
110
+ window.__VUE_INSPECTOR__?.enable()
111
+ panelState.value.viewMode = 'component-inspector'
112
+ }
113
+
114
+ function disableComponentInspector() {
115
+ window.__VUE_INSPECTOR__?.disable()
116
+ props.hook.emit('host:inspector:close')
117
+ if (panelState.value.viewMode === 'component-inspector')
118
+ panelState.value.viewMode = 'default'
119
+ }
120
+
121
+ function waitForClientInjection(retry = 10, timeout = 200) {
122
+ const test = () => !!iframe.value?.contentWindow?.__VUE_DEVTOOLS_VIEW__
123
+
124
+ if (test())
125
+ return
126
+
127
+ return new Promise((resolve, reject) => {
128
+ const interval = setInterval(() => {
129
+ if (test()) {
130
+ clearInterval(interval)
131
+ resolve()
132
+ }
133
+ else if (retry-- <= 0) {
134
+ console.log(iframe.value.contentWindow.__VUE_DEVTOOLS_VIEW__)
135
+ clearInterval(interval)
136
+ // eslint-disable-next-line prefer-promise-reject-errors
137
+ reject('Vue Devtools client injection failed')
138
+ }
139
+ }, timeout)
140
+ })
141
+ }
142
+
143
+ async function onLoad() {
144
+ await waitForClientInjection()
145
+ setupClient()
146
+ }
147
+
148
+ function setupClient() {
149
+ const injection = iframe.value?.contentWindow?.__VUE_DEVTOOLS_VIEW__
150
+ const componentInspector = window.__VUE_INSPECTOR__
151
+ if (componentInspector) {
152
+ const _openInEditor = componentInspector.openInEditor
153
+ componentInspector.openInEditor = async (...params) => {
154
+ disableComponentInspector()
155
+ _openInEditor(...params)
156
+ }
157
+ }
158
+ injection.setClient({
159
+ hook: props.hook,
160
+ hookBuffer,
161
+ inspector: {
162
+ enable: enableComponentInspector,
163
+ disable: disableComponentInspector,
164
+ },
165
+ panel: {
166
+ toggle(position) {
167
+ panelState.value.position = position
168
+ },
169
+ },
170
+ })
171
+ }
172
+
173
+ function initPanelPosition() {
174
+ const frameState = localStorage.getItem('__vue-devtools-frame-state__')
175
+ if (frameState) {
176
+ const parsedFrameState = JSON.parse(frameState)
177
+ panelState.value.position = parsedFrameState.position
178
+ }
179
+ }
180
+
181
+ function collectHookBuffer() {
182
+ let sortId = 0
183
+ const DevtoolsHooks = {
184
+ COMPONENT_INIT: 'app:init',
185
+ COMPONENT_UPDATED: 'component:updated',
186
+ COMPONENT_ADDED: 'component:added',
187
+ COMPONENT_REMOVED: 'component:removed',
188
+ COMPONENT_EMIT: 'component:emit',
189
+ PERF_START: 'perf:start',
190
+ PERF_END: 'perf:end',
191
+ }
192
+
193
+ function skipCollect(component) {
194
+ return component?.root.type?.devtools?.hide || iframe.value?.contentWindow?.__VUE_DEVTOOLS_VIEW__
195
+ }
196
+ props.hook.on(DevtoolsHooks.PERF_START, (app, uid, component, type, time) => {
197
+ if (skipCollect(component))
198
+ return
199
+
200
+ hookBuffer.push([DevtoolsHooks.PERF_START, {
201
+ now: Date.now(),
202
+ app,
203
+ uid,
204
+ component,
205
+ type,
206
+ time,
207
+ sortId: sortId++,
208
+ }])
209
+ })
210
+ props.hook.on(DevtoolsHooks.PERF_END, (app, uid, component, type, time) => {
211
+ if (skipCollect(component))
212
+ return
213
+
214
+ hookBuffer.push([DevtoolsHooks.PERF_END, {
215
+ now: Date.now(),
216
+ app,
217
+ uid,
218
+ component,
219
+ type,
220
+ time,
221
+ sortId: sortId++,
222
+ }])
223
+ });
224
+
225
+ [
226
+ DevtoolsHooks.COMPONENT_UPDATED,
227
+ DevtoolsHooks.COMPONENT_ADDED,
228
+ DevtoolsHooks.COMPONENT_REMOVED,
229
+ DevtoolsHooks.COMPONENT_EMIT,
230
+ ].forEach((item) => {
231
+ props.hook.on(item, (app, uid, parentUid, component) => {
232
+ if (!app || (typeof uid !== 'number' && !uid) || !component || skipCollect(component))
233
+ return
234
+ hookBuffer.push([item, {
235
+ app, uid, parentUid, component,
236
+ }])
237
+ })
238
+ })
239
+ }
240
+
241
+ collectHookBuffer()
242
+ initPanelPosition()
243
+ </script>
244
+
245
+ <template>
246
+ <div class="vue-devtools-panel" :style="panelPosition">
247
+ <iframe ref="iframe" :src="clientUrl" @load="onLoad" />
248
+ </div>
249
+ <button class="vue-devtools-toggle" aria-label="Toggle devtools panel" :style="toggleButtonPosition" @click.prevent="togglePanel">
250
+ <svg viewBox="0 0 256 198" fill="none" xmlns="http://www.w3.org/2000/svg">
251
+ <path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z" />
252
+ <path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z" />
253
+ <path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z" />
254
+ </svg>
255
+ </button>
256
+ </template>
257
+
258
+ <style scoped>
259
+ .vue-devtools-panel {
260
+ position: fixed;
261
+ width: calc(80vw - 20px);
262
+ height: calc(60vh - 20px);
263
+ }
264
+
265
+ .vue-devtools-panel iframe {
266
+ width: 100%;
267
+ height: 100%;
268
+ outline: 0;
269
+ border:1px solid rgba(125,125,125,0.2);
270
+ border-radius: 8px;
271
+ }
272
+
273
+ .vue-devtools-toggle {
274
+ position: fixed;
275
+ background: #0C0C0C;
276
+ border: 1px solid rgba(125,125,125,0.2);
277
+ box-shadow: 3px 5px 10px rgba(0,0,0,0.1);
278
+ z-index: 2147483647;
279
+ cursor: pointer;
280
+ opacity: 0.8;
281
+ padding: 0;
282
+ align-items: center;
283
+ transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
284
+ outline: 0;
285
+ }
286
+
287
+ .vue-devtools-toggle:hover {
288
+ transform: var(--hover-translate);
289
+ opacity: 1;
290
+ }
291
+
292
+ .vue-devtools-toggle svg {
293
+ width: 16px;
294
+ height: 16px;
295
+ margin: auto;
296
+ margin-top:3px;
297
+ }
298
+ </style>
@@ -0,0 +1,41 @@
1
+ import { createApp, h } from 'vue'
2
+ import App from 'virtual:vue-devtools-path:Container.vue'
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
+ function load() {
20
+ const CONTAINER_ID = '__vue-devtools-container__'
21
+ const el = document.createElement('div')
22
+ el.setAttribute('id', CONTAINER_ID)
23
+ el.setAttribute('data-v-inspector-ignore', 'true')
24
+ document.getElementsByTagName('body')[0].appendChild(el)
25
+ createApp({
26
+ render: () => h(App, { hook }),
27
+ devtools: {
28
+ hide: true,
29
+ },
30
+ }).mount(`#${CONTAINER_ID}`)
31
+ }
32
+ 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
+ })