mfikes / ambly

ClojureScript REPL into embedded JavaScriptCore
http://ambly.fikesfarm.com
Eclipse Public License 1.0
541 stars 21 forks source link

Support REPL against real device, and sort out how `require` works #6

Closed mfikes closed 9 years ago

mfikes commented 9 years ago

The current implementation of require simply reads from a fully-qualified filename on the hosting OS X filesystem, which wouldn't work on a real device.

It currently appears that all of the files that get required come from the output-dir in the project, so perhaps one approach would involve having the require implementation essentially fetch across the TCP socket used by the REPL.

Another approach is DropBox.

Interestingly, React Native's strategy for on-device dev hasn't been fully sorted out (but can work now because it has the app connect to the packaging server via TCP).

swannodette commented 9 years ago

The obvious downside withe DropBox approach is that it requires a DropBox account. Another alternative approach would be to use something like GCDWebServer. Users could then use the ClojureScript compiler to write to some output directory that is bundled with the application. During REPL development the compiler could switch to a simple HTTP based protocol (note that GCDWebServer ships with WebDAV support) to update the build over the wire.

mfikes commented 9 years ago

WebDAV is interesting. That architecture also sounds promising, considering a potential future Android variant of all of this stuff.

mfikes commented 9 years ago

Convenience link to potentially relevant compiler change: http://dev.clojure.org/jira/browse/CLJS-901

mfikes commented 9 years ago

@swannodette I took a quick peek at GCDWebServer. Looks cool.

I imagine you are looking into what it might take to have the ClojureScript compiler output have hooks into a WebDav client, potentially uploading after writing to :output-dir, as well as the big picture of how this would hook into the iOS side.

I suppose this ticket serves as a good place for discussing design concepts, or the ticket could become overly clogged with dialog (or a wiki page or IRC might be better if you prefer).

Here are some superficial thoughts after my quick look:

If a file is uploaded via its delegate method and we require the uploaded file, one thing of interest is that when we load JavaScript source text into JavaScriptCore, we have control over the actual path via the withSourceURL parameter, thus making stack traces work out properly.

Additionally, it would be interesting to somehow have the REPL analyze the revised CLJS source. (You probably have a much clearer view on this aspect—I'm assuming that we need to tell the REPL about new symbols so it doesn't warn. I think Figwheel does something along these lines to keep the REPL "up to date" with things.) The thing that is not clear to me is that the REPL "proper" is on the development OS X host, so maybe some connection needs to exist to it as well? (That's not a well thought out idea.)

swannodette commented 9 years ago

Collected my thoughts here. Feel free to modify/improve!

mfikes commented 9 years ago

Cool. Looking good. Sorting out my thoughts and spending them at the bottom of that page for now.

mfikes commented 9 years ago

Regardless of the ultimate outcome of CLJS-901, Ambly is now addressing this ticket.