Skip to content

Commit 2b59342

Browse files
authored
feat: disable toggleComboKey option (#46)
1 parent e2898a1 commit 2b59342

File tree

6 files changed

+12
-21
lines changed

6 files changed

+12
-21
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ interface VitePluginInspectorOptions {
122122
* examples: control-shift, control-o, control-alt-s meta-x control-meta
123123
* Some keys have native behavior (e.g. alt-s opens history menu on firefox).
124124
* To avoid conflicts or accidentally typing into inputs, modifier only combinations are recommended.
125+
* You can also disable it by setting `false`.
125126
*/
126-
toggleComboKey?: string
127+
toggleComboKey?: string | false
127128

128129
/**
129130
* Toggle button visibility

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"play:vue3": "pnpm run -r --filter=./packages/playground/vue3 dev",
1616
"play:vue2": "pnpm run -r --filter=./packages/playground/vue2 dev",
1717
"lint": "eslint --fix --ext .js,.ts,.vue .",
18-
"stub": "pnpm run -r --filter=./packages/core stub",
18+
"dev": "pnpm run -r --filter=./packages/core dev",
1919
"build": "pnpm run -r --filter=./packages/{core,unplugin} build",
2020
"release": "pnpm build && changeset && changeset version && changeset publish"
2121
},
@@ -28,7 +28,6 @@
2828
"tsup": "^5.12.1",
2929
"tsx": "^3.12.2",
3030
"typescript": "^4.9.4",
31-
"unbuild": "^1.1.1",
3231
"vite": "^4.0.3",
3332
"vue": "^3.2.45"
3433
},

packages/core/package.json

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
],
3939
"scripts": {
4040
"lint": "eslint --fix --ext .js,.ts,.vue .",
41-
"stub": "unbuild",
41+
"dev": "tsup --watch",
4242
"build": "tsup"
4343
},
4444
"peerDependencies": {
@@ -58,15 +58,5 @@
5858
"devDependencies": {
5959
"@types/babel__core": "^7.1.20",
6060
"unplugin": "^1.0.1"
61-
},
62-
"unbuild": {
63-
"entries": [
64-
"./src/index"
65-
],
66-
"clean": true,
67-
"declaration": true,
68-
"rollup": {
69-
"emitCJS": true
70-
}
7161
}
7262
}

packages/core/src/Overlay.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default {
1818
containerRef: null,
1919
floatsRef: null,
2020
enabled: inspectorOptions.enabled,
21-
toggleCombo: inspectorOptions.toggleComboKey?.toLowerCase().split('-'),
21+
toggleCombo: inspectorOptions.toggleComboKey?.toLowerCase?.()?.split?.('-') ?? false,
2222
overlayVisible: false,
2323
position: {
2424
x: 0,

packages/core/src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ export interface VitePluginInspectorOptions {
4747
* examples: control-shift, control-o, control-alt-s meta-x control-meta
4848
* Some keys have native behavior (e.g. alt-s opens history menu on firefox).
4949
* To avoid conflicts or accidentally typing into inputs, modifier only combinations are recommended.
50+
* You can also disable it by setting `false`.
5051
*/
51-
toggleComboKey?: string
52+
toggleComboKey?: string | false
5253

5354
/**
5455
* Toggle button visibility
@@ -149,13 +150,13 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
149150
},
150151
configureServer(server) {
151152
const _printUrls = server.printUrls
153+
const { toggleComboKey } = normalizedOptions
152154

153-
server.printUrls = () => {
154-
const { toggleComboKey } = normalizedOptions
155+
toggleComboKey && (server.printUrls = () => {
155156
const keys = normalizeComboKeyPrint(toggleComboKey)
156157
_printUrls()
157158
console.log(` ${green('➜')} ${bold('Vue Inspector')}: ${green(`Press ${yellow(keys)} in App to toggle the Inspector`)}\n`)
158-
}
159+
})
159160
},
160161
transformIndexHtml(html) {
161162
if (normalizedOptions.appendTo)

packages/unplugin/src/nuxt.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ export default (options: Options, nuxt: any) => {
1313
})
1414
let printed = false
1515
nuxt.hook('vite:serverCreated', () => {
16-
if (printed)
17-
return
1816
const normalizedOptions = { ...DEFAULT_INSPECTOR_OPTIONS, ...options }
1917
const { toggleComboKey } = normalizedOptions
18+
if (printed || !toggleComboKey)
19+
return
2020
const keys = normalizeComboKeyPrint(toggleComboKey)
2121
console.log(` ${'> Vue Inspector'}: ${green(`Press ${yellow(keys)} in App to toggle the Inspector`)}\n`)
2222
printed = true

0 commit comments

Comments
 (0)