Are there already some JSInterop repositories available somewhere?

256 views
Skip to first unread message

Bruno Salmon

unread,
Aug 23, 2016, 11:27:51 AM8/23/16
to GWT Users
hi,

I haven't used JSInterop yet but in all examples I watched, people are writing all their interfaces themselves including the DOM API...

I guess this is a temporary situation because JSInterop is new and that some JSInterop repositories will appear in the future so we will have most of JS libraries API automatically ported into JSInterop. This step will really open GWT to the whole JS ecosystem. It would be great to have something similar to what JSweet did with more than 1000 well-typed JavaScript libraries available.

Does anybody know if this is part of the GWT project itself or if the idea is to delegete this job to some other third-party projects?

Do some such projects already exist? I found a project called JsInterop.xyz that started in that direction but it doesn't seem to be active.

Any info about this?
Thanks

Jens

unread,
Aug 23, 2016, 11:55:16 AM8/23/16
to GWT Users
Take a look at Elemental 2: https://groups.google.com/d/msg/google-web-toolkit-contributors/6ycG2nm0OSM/RW3psRrqAAAJ

Its experimental but covers all browser APIs (auto generated from closure externs: https://github.com/google/closure-compiler/tree/master/externs). Its the JsInterop version of Elemental 1.0 that is part of GWT SDK.

-- J.

Bruno Salmon

unread,
Aug 23, 2016, 12:49:53 PM8/23/16
to GWT Users
Thanks but Elemental only gives the basics (such as the DOM API and some HTML5 features). I'm more asking about a project that would expose many JS libraries.

A kind of set like this one offered by JSweet.

I would like for example use the pixi.js graphical library in a GWT project without having to rewrite myself the whole pixi API in JSInterop.

Jens

unread,
Aug 23, 2016, 1:16:19 PM8/23/16
to GWT Users
A post from the thread I linked before:


So once the elemental2 generator is open source and supports typescript definition files, you should be able to use everything that https://github.com/DefinitelyTyped/DefinitelyTyped provides (which is what JSweet also uses)

For the time being there is no such generator, you would need to write the bindings yourself. Also the author of jsinterop.xyz has not published its generator (at least not at the time I looked at it).

-- J.

Bruno Salmon

unread,
Aug 23, 2016, 3:26:45 PM8/23/16
to GWT Users
I didn't know there was a DefinitelyTyped to JSInterop generator project in the pipeline, glad to hear about it, it's exactly what I was looking for :-)

Thank you. 

Vassilis Virvilis

unread,
Aug 24, 2016, 7:37:03 AM8/24/16
to google-we...@googlegroups.com
Bruno thanks for the links. I didn't know about jsweet and jsinterop.xyz.

It would be really cool if GWT could tap on all of these js libraries (candies) offered by jsweet. Then of course the differences between GWT and jsweet become hard to see.

jsinterop.xyz is of also interesting. Isn't this the same thing as elemental2 - DOM and window APis are exposed via jsinterop - what's the difference?
The only difference I can spot is the fact that jsinterop.xyz looks like hand crafted as opposed to the automated elementa2.

    Vassilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsub...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.



--
Vassilis Virvilis

Bruno Salmon

unread,
Aug 24, 2016, 9:54:43 AM8/24/16
to GWT Users
There is still a big difference between JSweet and GWT because although JSweet supports Java 8 syntax, it doesn't do any JRE emulation. So JSweet is much simpler and it can be a good choice if you just want to write your JS code from Java (with all the advantage provided by your Java IDE like auto completion, refactoring, etc...) and if you don't need to refer to any JRE class (List, Map, etc...) in your code. With JSweet your code is only a Java (better) view of your JS code. But if you want to use the JRE emulation or share some Java code between your frontend and your backend (client and/or server), JSweet can't do it whereas GWT can.

The candies are a big advantage of JSweet but yes GWT will soon fill the gap and offer exactly the same so, as you said, it's really cool.

My understanding is that JsInterop.xyz is not hand crafted and has a generator. But it is an individual initiative (and not sure it is still active) whereas Elemental2 and its generator are more official (and active) parts of the GWT project.

It seems we don't know yet exactly when the Elemental2 generator will be out. Very exciting stuff but let's be patient first...
To post to this group, send email to google-we...@googlegroups.com.



--
Vassilis Virvilis

Renaud Pawlak

unread,
Aug 25, 2016, 2:30:25 AM8/25/16
to GWT Users

True, JSweet is not a Java emulation, so there are some limitations (for example, no runtime distinction between int and double). However, it is not accurate that you cannot share code between a Java server and a web client. If your code only uses the Java APIs as defined in J4TS (it is actually a fork of the GWT JRE emulation dropping the emulation part), then you can share code. It will work as well in the JRE and in a JS container. No problem as long as you understand well JSweet semantics and the small differences with Java. For more information, visit the version 1.1 announcement: http://www.jsweet.org/jsweet-version-1-1-is-now-available/.

For information, I have suggested to some Google GWT team members that we could collaborate on the candies topic. But I had no actual answer, so I guess they want to do it on their own.

/Renaud (JSweet dev)
Reply all
Reply to author
Forward
0 new messages