diff --git a/README.md b/README.md index 352f349..580ac79 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,12 @@ Runs the main method - 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 - not very good error reporting diff --git a/java2js_transpile_worker.js b/java2js_worker.js similarity index 100% rename from java2js_transpile_worker.js rename to java2js_worker.js diff --git a/jdk.js b/jdk.js index e1fccfb..be85ca7 100755 --- a/jdk.js +++ b/jdk.js @@ -50,7 +50,7 @@ async init(root) { this.root = root || './jdk'; 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 = {}; let pkgs = ['com', 'io', 'lang', 'org', 'security', 'time', 'util']; @@ -240,7 +240,7 @@ }); } else { 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); } diff --git a/package.json b/package.json index fe5e0fc..c28c9ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "java2js", - "version": "1.2.13", + "version": "1.2.14", "description": "Converts Java to JavaScript and runs it with a JS JDK", "main": "jdk.js", "scripts": {