Open jasonm23 opened 8 years ago
Definitely an interesting idea! I’m not sure how hard or easy this would be to implement...
I'd like to have a crack at it, hopefully I'll have some time this weekend.
Ok, nice! Let me know what you discover.
This will probably require a completely different CLI-binary and creating a new context that can read from the standard input and write to the standard output interactively. This would obviously mean splitting the core into a separate framework to avoid duplicated code. I would guess implementing this would need quit a bit of work.
I was thinking this might be do-able using a socket, didn't get time over the last couple of weekends, hopefully the christmas period will gift me some spare time ;)
i think react native uses a socket to chrome web dev tools for this sort of thing.
Amazing idea, when I use awesome in Linux, I love the console.
Just wanted to chime in and say that I implemented a REPL as a modal, if anyone is interested:
https://github.com/metakirby5/.dots/blob/master/osx/.phoenix.js#L1046
I think I’ll add a small socket server to Phoenix that will listen and consume data as a stream. It can then evaluate that into the current context and return the last value generated. Then, I can write a small bash script and include it in the app bundle that will act as an interactive console client.
This should also make #140 possible.
I just updated to 2.6.1 and noticed that the Phoenix JSContext is picked up by the web inspector now:
This is basiically a REPL :). The only reason I noticed it is that I have the option set to automatically launch them:
Maybe this could be used or improved? For example, I noticed my config isn't available in the inspector.
Then again, maybe not suitable as an official REPL since it requires enabling Safari developer options, etc.
I noticed that too, but for some reason I was only able to get it to show up in debug builds. I was thinking of writing a Wiki page about it, if I could get it working properly.
Interesting, I just pulled in mine from brew cask and it popped up 😅.
Maybe it was just conflicting since I had the older release build running or then something has been fixed in the newer app bundle and it only works in 2.6.1. 😄
Yes, it indeed seems to work out of the box with 2.6.1! 🎉
Super sweet!
I now noticed that the reason I can't access my config is because I use webpack, so everything has it's own scope. But I can enter debugger;
statements in my code and have Phoenix pause there, pretty neat!
One thing missing is being able to view the config as a source file though. And it would be super awesome to get source maps working. If you have any ideas I'm all ears, otherwise I might try to hack around a bit this weekend 😄.
PS. Do you think there might be any security implications from always exposing the context, considering that Phoenix has accessibility access, etc?
@jasonm23 Congratulations, phoenix is on Github trending today.
Wrote a short tutorial in the Wiki about how to use the Web Inspector to debug Phoenix. https://github.com/kasper/phoenix/wiki/Attaching-to-Web-Inspector-for-Debugging/
I was trying to do this today, but after building and running the Debug release from source, I only see this in Safari > Develop > machine-name
...
I've tried:
Is there anything I need to do?
@jasonm23 Ah, I think I forgot to add com.apple.security.get-task-allow
to the debug entitlements (https://github.com/kasper/phoenix/blob/master/Phoenix/PhoenixDebug.entitlements) when I was refactoring. That needs to be fixed. Good catch!
Cool I'll try adding it locally to get moving
My debug entitlements now look like this...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.get-task-allow</key>
<true/>
</dict>
</plist>
Am I doing it right? Safari still doesn't see JSContext
@jasonm23 It should be right, maybe Apple has introduced some other entitlements as well? 🤔 I need to test it out.
Thank you
I'll try rebooting.. https://developer.apple.com/forums/thread/67689
Got some downtime, reboot didn't fix anything :(
It would be nice if there was a REPL/CLI/Interactive Console to assist people who are getting to grips with the api.
Any feelings about this? @kasper