Skip to content

Commit 2aea8f6

Browse files
committed
feat: support all frameworks
1 parent cb7bea3 commit 2aea8f6

8 files changed

Lines changed: 31 additions & 33 deletions

File tree

.changeset/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"updateInternalDependencies": "patch",
1010
"ignore": [
1111
"playground-vue2",
12-
"playground-vue3"
12+
"playground-vue3",
13+
"playground-react"
1314
]
1415
}

.eslintrc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
"rules":{
44
"no-console":0,
55
"prefer-const":0,
6-
"no-prototype-builtins":0,
7-
"vue/no-parsing-error": ["error", {
8-
"invalid-first-character-of-tag-name": false
9-
}]
6+
"no-prototype-builtins":0
107
}
118
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
## Introduction
33

4-
A vite plugin which provides the ability that to jump to the local IDE when you click the element of browser automatically. It supports Vue2 & 3 & SSR.
4+
A vite plugin which provides the ability that to jump to the local IDE when you click the element of browser automatically. It supports Vue2, Vue3, React, Svelte,Angular, SSR(All frameworks).
55

66
## Installation
77

packages/core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
## Introduction
33

4-
A vite plugin which provides the ability that to jump to the local IDE when you click the element of browser automatically. It supports Vue2 & 3 & SSR.
4+
A vite plugin which provides the ability that to jump to the local IDE when you click the element of browser automatically. It supports Vue2, Vue3, React, Svelte,Angular, SSR(All frameworks).
55

66
## Installation
77

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"src/overlay.js"
3434
],
3535
"scripts": {
36-
"lint": "eslint --fix --ext .js,.ts,.vue .",
36+
"lint": "eslint --fix --ext .js,.ts,.vue,.jsx .",
3737
"dev": "tsup --watch",
3838
"build": "tsup"
3939
},

packages/core/src/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import MagicString from 'magic-string'
99
import { compileSFCTemplate } from './compiler'
1010
import { idToFile, parseVueRequest } from './utils'
1111

12-
export interface VueInspectorClient {
12+
export interface DevInspectorClient {
1313
enabled: boolean
1414
position: {
1515
x: number
@@ -167,19 +167,19 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
167167
async resolveId(importee: string) {
168168
// console.log('resolveId', importee)
169169

170-
if (importee.startsWith('virtual:vue-inspector-options')) {
170+
if (importee.startsWith('virtual:dev-inspector-options')) {
171171
return importee
172172
}
173-
else if (importee.startsWith('virtual:vue-inspector-path:')) {
174-
const resolved = importee.replace('virtual:vue-inspector-path:', `${inspectorPath}/`)
173+
else if (importee.startsWith('virtual:dev-inspector-path:')) {
174+
const resolved = importee.replace('virtual:dev-inspector-path:', `${inspectorPath}/`)
175175
return resolved
176176
}
177177
},
178178

179179
async load(id) {
180180
// console.log('load', id)
181181

182-
if (id === 'virtual:vue-inspector-options') {
182+
if (id === 'virtual:dev-inspector-options') {
183183
return `export default ${JSON.stringify({ ...normalizedOptions, base: config.base })}`
184184
}
185185
else if (id.startsWith(inspectorPath)) {
@@ -191,7 +191,7 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
191191
if (fs.existsSync(file))
192192
return await fs.promises.readFile(file, 'utf-8')
193193
else
194-
console.error(`failed to find file for vue-inspector: ${file}, referenced by id ${id}.`)
194+
console.error(`failed to find file for dev-inspector: ${file}, referenced by id ${id}.`)
195195
}
196196
},
197197
transform(code, id) {
@@ -208,7 +208,7 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
208208

209209
if ((typeof appendTo === 'string' && filename.endsWith(appendTo))
210210
|| (appendTo instanceof RegExp && appendTo.test(filename)))
211-
return { code: `${code}\nimport 'virtual:vue-inspector-path:load.js'` }
211+
return { code: `${code}\nimport 'virtual:dev-inspector-path:load.js'` }
212212
},
213213
configureServer(server) {
214214
const _printUrls = server.printUrls
@@ -231,7 +231,7 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
231231
injectTo: 'head',
232232
attrs: {
233233
type: 'module',
234-
src: `${config.base || '/'}@id/virtual:vue-inspector-path:load.js`,
234+
src: `${config.base || '/'}@id/virtual:dev-inspector-path:load.js`,
235235
},
236236
},
237237
],

packages/core/src/load.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import inspectorOptions from 'virtual:vue-inspector-options'
1+
import inspectorOptions from 'virtual:dev-inspector-options'
22

33
import './overlay.js' // import Custom Element
44

5-
const CONTAINER_ID = 'vue-inspector-container'
5+
const CONTAINER_ID = 'dev-inspector-container'
66

77
function createInspectorContainer() {
88
if (document.getElementById(CONTAINER_ID) != null)

packages/core/src/overlay.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import inspectorOptions from 'virtual:vue-inspector-options'
1+
import inspectorOptions from 'virtual:dev-inspector-options'
22

33
const base = inspectorOptions.base
44

@@ -15,7 +15,7 @@ template.innerHTML = `<style>
1515
box-sizing: border-box;
1616
}
1717
18-
.vue-inspector-container {
18+
.dev-inspector-container {
1919
cursor: pointer;
2020
position: fixed;
2121
text-align: center;
@@ -25,7 +25,7 @@ template.innerHTML = `<style>
2525
right: 15px;
2626
}
2727
28-
.vue-inspector-card {
28+
.dev-inspector-card {
2929
font-family: Arial, Helvetica, sans-serif;
3030
padding: 5px 8px;
3131
border-radius: 4px;
@@ -36,15 +36,15 @@ template.innerHTML = `<style>
3636
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
3737
}
3838
39-
.vue-inspector-floats {
39+
.dev-inspector-floats {
4040
z-index: 9999;
4141
position: fixed;
4242
transform: translateX(-50%);
4343
transition: all 0.1s ease-in;
4444
pointer-events: none;
4545
}
4646
47-
.vue-inspector-size-indicator {
47+
.dev-inspector-size-indicator {
4848
z-index: 9999;
4949
position: fixed;
5050
background-color:#42b88325;
@@ -54,29 +54,29 @@ template.innerHTML = `<style>
5454
pointer-events: none;
5555
}
5656
57-
.vue-inspector-button {
57+
.dev-inspector-button {
5858
color: #e4c9c9;
5959
}
6060
61-
.vue-inspector-button--active {
61+
.dev-inspector-button--active {
6262
color: #42b883;
6363
}
6464
</style>
6565
6666
<div data-v-inspector-ignore="true">
6767
<div
68-
class="vue-inspector-container"
68+
class="dev-inspector-container"
6969
id="toggle-inspector-container"
7070
>
71-
<div class="vue-inspector-button" id="inspector-btn">
71+
<div class="dev-inspector-button" id="inspector-btn">
7272
Code Inspector
7373
</div>
7474
</div>
7575
7676
<div id="overlay-container">
7777
<div
7878
ref="floatsRef"
79-
class="vue-inspector-floats vue-inspector-card"
79+
class="dev-inspector-floats dev-inspector-card"
8080
id="floatsRef"
8181
>
8282
<div id="overlay-content"></div>
@@ -85,7 +85,7 @@ template.innerHTML = `<style>
8585
</div>
8686
</div>
8787
<div
88-
class="vue-inspector-size-indicator"
88+
class="dev-inspector-size-indicator"
8989
:style="sizeIndicatorStyle"
9090
/>
9191
</div>
@@ -119,7 +119,7 @@ class DevInspector extends HTMLElement {
119119

120120
switchBtnVisible = () => {
121121
const toggleInspectorContainer = this.root.querySelector('#toggle-inspector-container')
122-
!this.enabled && toggleInspectorContainer.classList.add('vue-inspector-container--disabled')
122+
!this.enabled && toggleInspectorContainer.classList.add('dev-inspector-container--disabled')
123123
}
124124

125125
toggleEventListener = () => {
@@ -143,9 +143,9 @@ class DevInspector extends HTMLElement {
143143
toggleBtnVisible = () => {
144144
const btn = this.root.querySelector('#inspector-btn')
145145
if (this.enabled)
146-
btn.classList.add('vue-inspector-button--active')
146+
btn.classList.add('dev-inspector-button--active')
147147
else
148-
btn.classList.remove('vue-inspector-button--active')
148+
btn.classList.remove('dev-inspector-button--active')
149149
}
150150

151151
toggleEnabled = () => {
@@ -256,7 +256,7 @@ class DevInspector extends HTMLElement {
256256

257257
// update size indicator style
258258
sizeIndicatorStyle = () => {
259-
const targetNode = this.root.querySelector('.vue-inspector-size-indicator')
259+
const targetNode = this.root.querySelector('.dev-inspector-size-indicator')
260260
targetNode.style.left = `${this.position.x}px`
261261
targetNode.style.top = `${this.position.y}px`
262262
targetNode.style.width = `${this.position.width}px`

0 commit comments

Comments
 (0)