Repository navigation
Add Node.js Eval extension - #340
Conversation
988146c to
32450d5
Compare
fe9lix
left a comment
There was a problem hiding this comment.
Hey @selfish! Thanks for the contribution.
Evaluating arbitrary JS through the entire Node.js API (giving you access to any system-level operations) in typeahead-style is a bit scary. I'd suggest to at least make the evaluation explicit, i.e. after running the primary action in the action panel. That way, the user can also first finish typing the entire expression without intermediary errors and then run it through the shortcut.
(In the future it might be a good idea to show an alert on the first run but not yet possible through the API).
|
Hi @fe9lix, thanks for your input! I feel like the security aspect won't be improved by delaying the evaluation (I agree that the fact that eval is used is scary) - would you mind reconsidering the request? By the way, this was my first contribution to Raycast and was intended to be part of a series, which will similarly add a ruby interpreter, python, golang, and maybe more 🙏🏻 As for alerting the user, I would be more than happy to do that. Maybe even abuse the preferences API to force the user to read some text and enable the evaluation explicitly. Come to think of it, would you accept it if I implemented your suggestion, but allowed an alternative typehead option in the settings? Again, thanks for the feedback! |
|
Hey @selfish – I understand your point. I still believe that at least it prevents situations where somebody doesn't know exactly what's happening or even situations where a typo would lead to dangerous side effects. That being said I get that you like the realtime feedback, so your suggestion with making this a preference sounds good to me. (Please default to the explicit behavior of triggering evaluation by shortcut and make the preference non-required, so users who wish to enable the realtime feedback, should go to prefs and enable this...) |
|
Btw, I can think of another "scary" scenario if the typeahead behavior was enabled by default: Raycast allows you to set up an alias for a command and then directly jump into the command by typing the alias, pressing the space key and continue typing (or pasting from the clipboard...). So definitely better to make this an explicit option. |
|
Thanks, @fe9lix! |
|
Could the evaluation be limited to pure-js with no access to node apis? That should really help with security. Maybe using smth like this https://github.com/NeilFraser/JS-Interpreter |
|
@FezVrasta I reviewed the interpreter, and I'd rather not include the whole thing. It gets heavy. |
|
@fe9lix Updated with a new default mode as we spoke. |
fe9lix
left a comment
There was a problem hiding this comment.
Thanks for adding the option. One thing that I notice is that now on every keypress (regardless of the mode), the Action Panel primary action flashes, which is visually quite distracting. I guess it's because of the new list item entry that changes with the entered text and the list re-rendering on each keypress? Not sure if the issue was also present in the previous version.
|
Extra references and conversation regarding solutions here: I'll take a couple of days to rewrite this in a more correct way. |
|
Updating that this hasn't fallen stale. I've had to replace my mac and I'm pending a new one, so the delay is due to a lack of a development environment, but I intend to complete this. |
|
Thanks for the update @selfish, sorry for the very late reply 😄 |
|
Should we still leave this open @selfish? (Alternative we can close it for now and you can reopen it later...) |
|
@selfish cool extension. Hope to see this reach the store when your new mac arrives :) |
|
@fe9lix sorry to have missed your question. |
|
Ok, I see that It's taking me longer than I expected to finish. |
|
Okay, finally did it. |
|
Congratulation on your new Raycast extension! 🚀 We will review it shortly. Once the PR is approved and merged, the extension will be available on the Store. |
edf01c2 to
f827a6e
Compare
160f406 to
09a97e1
Compare
|
@selfish Thanks for the updates! Just quickly tested and when I type |
|
@fe9lix great catch, thanks! Unfortunately, both evals and type inference are terrible to deal with in JS. |
1d8d7b9 to
2c16d5d
Compare
2c16d5d to
06f8407
Compare
|
Published to the Raycast Store: |
|
🎉 |
|
I was testing it with |
|
@FezVrasta fixed in #1062 - thanks for reporting! |
Description
Adds Node.js Evaluate extension.
This extension will quickly evaluate Javascript code right inside Raycast, and allow copying of the code or evaluation.
This idea is based on a similar alfred extension
Type of change
Screencast
Settings screen:
Default evaluation mode:
Fast mode:
Screen.Recording.2021-11-12.at.2.15.02.AM.mov
Checklist
512x512