mirror of
https://github.com/quinton-ashley/java2js
synced 2024-12-29 10:11:54 +01:00
1.2.10
This commit is contained in:
parent
bafdc47b1d
commit
84a01e3215
13
jdk.js
13
jdk.js
@ -49,6 +49,9 @@
|
|||||||
|
|
||||||
async init(root) {
|
async init(root) {
|
||||||
this.root = root || './jdk';
|
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.java = {};
|
this.java = {};
|
||||||
let pkgs = ['com', 'io', 'lang', 'org', 'security', 'time', 'util'];
|
let pkgs = ['com', 'io', 'lang', 'org', 'security', 'time', 'util'];
|
||||||
for (let pkg of pkgs) {
|
for (let pkg of pkgs) {
|
||||||
@ -222,10 +225,8 @@
|
|||||||
let packageName = (file.match(/package\s+([^;]+)/gm) || [])[1] || 'default';
|
let packageName = (file.match(/package\s+([^;]+)/gm) || [])[1] || 'default';
|
||||||
|
|
||||||
let trans;
|
let trans;
|
||||||
|
if (this.workerPath) {
|
||||||
let workerPath = this.root.split('/').slice(0, -1).join('/') + '/transpile_worker.js';
|
let worker = new Worker(this.workerPath);
|
||||||
try {
|
|
||||||
let worker = new Worker(workerPath);
|
|
||||||
worker.postMessage(file);
|
worker.postMessage(file);
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
worker.onmessage = (e) => {
|
worker.onmessage = (e) => {
|
||||||
@ -233,9 +234,9 @@
|
|||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} catch (ror) {
|
} else {
|
||||||
console.warn(
|
console.warn(
|
||||||
'Due to a likely CORS error, java2js was unable to transpile with multithreaded worker: ' + workerPath
|
"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"
|
||||||
);
|
);
|
||||||
trans = java_to_javascript(file);
|
trans = java_to_javascript(file);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "java2js",
|
"name": "java2js",
|
||||||
"version": "1.2.9",
|
"version": "1.2.10",
|
||||||
"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": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user