1
0
mirror of https://github.com/quinton-ashley/java2js synced 2024-12-29 10:11:54 +01:00
This commit is contained in:
Quinton Ashley 2022-04-29 15:49:34 -05:00
parent ebb55a8601
commit 1395f8239a
4 changed files with 9 additions and 3 deletions

View File

@ -72,6 +72,12 @@ Runs the main method
- jvmArgs: (optional) String array of JVM arguments. - jvmArgs: (optional) String array of JVM arguments.
### jdk.workerPath
java2js might cause the main thread to stall when transpiling a large Java file. This can cause your website to appear unresponsive/frozen. You can (optionally) utilize the java2js worker script to transpile Java asynchronously in a seperate JS thread. However due to CORS security 'jav2js_worker.js' must be hosted on your own domain, define 'jdk.workerPath' to be the location of that file.
By default workerPath is undefined unless you are using java2js on a local server, in that case workerPath is the parent folder of jdk.root
## Known limitations ## Known limitations
- not very good error reporting - not very good error reporting

4
jdk.js
View File

@ -50,7 +50,7 @@
async init(root) { async init(root) {
this.root = root || './jdk'; this.root = root || './jdk';
if (location.hostname == 'localhost' || location.hostname == '127.0.0.1') { if (location.hostname == 'localhost' || location.hostname == '127.0.0.1') {
this.workerPath = this.root.split('/').slice(0, -1).join('/') + '/java2js_transpile_worker.js'; this.workerPath = this.root.split('/').slice(0, -1).join('/') + '/java2js_worker.js';
} }
this.java = {}; this.java = {};
let pkgs = ['com', 'io', 'lang', 'org', 'security', 'time', 'util']; let pkgs = ['com', 'io', 'lang', 'org', 'security', 'time', 'util'];
@ -240,7 +240,7 @@
}); });
} else { } else {
console.warn( console.warn(
"If you'd like java2js to transpile with the multithreaded worker (faster), due to CORS security block 'jav2js_transpile_worker.js' must be loaded from your own domain" "java2js might cause the main thread to stall when transpiling a large Java file. This can cause your website to appear unresponsive/frozen. You can utilize the java2js worker script to transpile Java asynchronously in a seperate JS thread. However due to CORS security 'jav2js_worker.js' must be hosted on your own domain, define 'jdk.workerPath' to be the location of that file."
); );
trans = java_to_javascript(file); trans = java_to_javascript(file);
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "java2js", "name": "java2js",
"version": "1.2.13", "version": "1.2.14",
"description": "Converts Java to JavaScript and runs it with a JS JDK", "description": "Converts Java to JavaScript and runs it with a JS JDK",
"main": "jdk.js", "main": "jdk.js",
"scripts": { "scripts": {