[ANN] JSCall.jl

Hi,
in order to make it easier to create the Makie WebGL backend, I put together JSCall.
By overloading getproperty and wrapping Javascript objects in Julia reference objects, it makes it very simple to call Javascript libraries.
It’s still an early prototype, but should already work pretty well - the main remaining work will likely happen behind the scenes, to improve performance and polish the implementation.
Simple demo:

# wrap a JS library and get the reference to the JS module and context:
JS, document, window = JSModule(
  :JSModuleName,
  "url/to/js/dependency/JS.js",
)
jsobject = JS.somefunc(1, "hi")
jlvalue(jsobject) # fetches the julia value from a js object
new_func = JS.somefunc(jsobject) # you can pass js objects to other functions
# you can call functions on any jsobject (of course only if they exist on the js side)
new_func([1,2,3])
# this works nicely for nested class/function calls:
JS.SomeClass.somefunc()

Complex demo:
Calling ThreeJS

Btw, this builds on WebIO by @shashi, which was heavily revamped to work more reliably by @travigd.

42 Likes

This is awesome Simon :clap::clap::clap::raised_hands::raised_hands::raised_hands:

I’m looking forward to Makie-driven web apps :+1::blush:

1 Like