在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:cincheo/jsweet开源软件地址:https://github.com/cincheo/jsweet开源编程语言:Java 79.2%开源软件介绍:JSweet: a Java to JavaScript transpilerJSweet leverages TypeScript to write rich and responsive Web applications in Java through the use of JavaScript libraries and frameworks. With JSweet, Java programs are transpiled (source-to-source compiled) to TypeScript and JavaScript for being run in browsers, mobile Web views, or in Node.js.
How does it work? JSweet depends on well-typed descriptions of JavaScript APIs, so-called "candies", most of them being automatically generated from TypeScript definition files. These API descriptions in Java can be seen as headers (similarly to *.h header files in C) to bridge JavaSript libraries from Java. There are several sources of candies for existing libraries and you can easily build a candy for any library out there (see more details). With JSweet, you take advantage of all the Java tooling (IDE's, Maven, ...) to program real JavaScript applications using the latest JavaScript libraries. Java -> TypeScript -> JavaScriptHere is a first taste of what you get by using JSweet. Consider this simple Java program: package org.jsweet;
import static jsweet.dom.Globals.*;
/**
* This is a very simple example that just shows an alert.
*/
public class HelloWorld {
public static void main(String[] args) {
alert("Hi there!");
}
} Transpiling with JSweet gives the following TypeScript program: namespace org.jsweet {
/**
* This is a very simple example that just shows an alert.
*/
export class HelloWorld {
public static main(args : string[]) {
alert("Hi there!");
}
}
}
org.jsweet.HelloWorld.main(null); Which in turn produces the following JavaScript output: var org;
(function (org) {
var jsweet;
(function (jsweet) {
/**
* This is a very simple example that just shows an alert.
*/
var HelloWorld = (function () {
function HelloWorld() {
}
HelloWorld.main = function (args) {
alert("Hi there!");
};
return HelloWorld;
}());
jsweet.HelloWorld = HelloWorld;
})(jsweet = org.jsweet || (org.jsweet = {}));
})(org || (org = {}));
org.jsweet.HelloWorld.main(null); More with the live sandbox. Features
For more details, go to the language specifications (PDF). Getting started
$ git clone https://github.com/cincheo/jsweet-quickstart.git
$ cd jsweet-quickstart
$ mvn generate-sources
$ firefox webapp/index.html
More info at http://www.jsweet.org. Examples
Sub-projectsThis repository is organized in sub-projects. Each sub-project has its own build process.
Additionally, some tools for JSweet are available in external repositories. How to buildPlease check each sub-project README file. ContributingJSweet uses Git Flow.
You can fork this repository. Default branch is develop. Please use LicensePlease read the LICENSE file. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论