-
-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Keyboard shortcut to reopen the browser without restarting the dev command #1211
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
No worries, if you push code to the same branch, you don't need to open a new PR with every change. We'll just use this one now instead of #1206. I'll to go this later today, woke up and going to work now lol. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of recommendations:
- Let's move
createKeyboardShortcuts
into it's own file for better organization,src/core/keyboard-shortcuts.ts
- Instead of using a global variable, we should put the
isWatching
variable inside thecreateKeyboardShortcuts
function so it's not global, but state for a single instance of thekeyboardShortcuts
object. - Related to 2, we should only create 1 keyboard shortcut object outside the
server
object. You mentioned you weren't sure where to put it so it has access to the server? I'd recommend putting it here: https://github.com/nishu-murmu/wxt/blob/88d15a2b715c93e89b09923b70875bf46dcb3bd4/packages/wxt/src/core/create-server.ts#L153
…o particular browser." This reverts commit 7f1beb7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, code looks good, other than the capitalization @Timeraa mentioned.
Tested it out on Mac, but I can no longer use ctrl+C
to stop the server. It does nothing when I press those keys, when it should stop the process. Reloading works really well though!
I did some snooping around Vite's code, and they don't use raw input mode:
Should we also use readline.createInterface
?
The first thing I did I saw the vite's code. Initially I tried that code itself Then I tried the raw input mode which was working. Do you any idea regarding this? |
My main concern here is there's more than just Is there a library we can use for this? |
Doesn't seem like there is. I prefer to use Vite's approach and require pressing enter over trying to implement a perfect raw input mode. Vite's help message makes it really easy to see that you need to press enter. We should add a log telling people to "Type o + enter to open the browser". Until we have a second keyboard shortcut, we don't need a full help menu. |
Yeah we can do that. I'm on with showing the log approach. |
Thanks for the insight @aklinker1, still getting used to the code structure and APIs.
First time actually contributing to open source project. 😓
Will look into it.
But I was also suggesting that, we can map few keys for various server related functionality.
Like the reference you gave
https://github.com/vitejs/vite/blob/bf1e9c2fd7b05f84d05e59f72b3fc26ca22807bb/packages/vite/src/node/shortcuts.ts
Had various key mapped to certain functionality.
We can do so?
I've added the code for removing and registering the listeners.
Can you check if it correct implementation?
Edit:
Sorry, Accidently closed the actual PR.