diff --git a/pom.xml b/pom.xml
index aff84f1..9e713cd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
pw.yumc
MiaoScript
- 0.11.0
+ 0.11.1
502647092
diff --git a/src/main/resources/bios.js b/src/main/resources/bios.js
index 62b39e8..6beed3a 100644
--- a/src/main/resources/bios.js
+++ b/src/main/resources/bios.js
@@ -57,12 +57,12 @@ var global = this;
global.start = function (future) {
if (!future.isDone()) {
- logger.info("Waiting MiaoScript booted...")
+ log.info("Waiting MiaoScript booted...")
future.get()
}
- logger.info("MiaoScript booted starting...")
+ log.info("MiaoScript booted starting...")
global.engineDisableImpl = require(java.lang.System.getenv("MS_NODE_CORE_MODULE") || (global.scope + '/core')).default || function () {
- logger.info('Error: abnormal Initialization MiaoScript Engine. Skip disable step...')
+ log.info('Error: abnormal Initialization MiaoScript Engine. Skip disable step...')
}
}
diff --git a/src/main/resources/core/require.js b/src/main/resources/core/require.js
index 8a6b0a1..ff01885 100644
--- a/src/main/resources/core/require.js
+++ b/src/main/resources/core/require.js
@@ -52,6 +52,10 @@
// @ts-ignore
var URL = Java.type('java.net.URL')
// @ts-ignore
+ var Thread = Java.type('java.net.URL')
+ // @ts-ignore
+ var FutureTask = Java.type('java.util.concurrent.FutureTask')
+ // @ts-ignore
var JavaString = Java.type('java.lang.String')
var separatorChar = File.separatorChar
@@ -301,15 +305,19 @@
var info = fetchPackageInfo(module_name)
var url = info.versions[ModulesVersionLock[module_name] || info['dist-tags']['latest']].dist.tarball
console.log('fetch node_module ' + module_name + ' from ' + url + ' waiting...')
- var tis = new TarInputStream(new BufferedInputStream(new GZIPInputStream(new URL(url).openStream())))
- // @ts-ignore
- var entry
- while ((entry = tis.getNextEntry()) != null) {
- var targetPath = Paths.get(target + separatorChar + entry.getName().substring(8))
- targetPath.toFile().getParentFile().mkdirs()
- Files.copy(tis, targetPath, StandardCopyOption.REPLACE_EXISTING)
- }
- return name
+ var future = new FutureTask(function () {
+ var tis = new TarInputStream(new BufferedInputStream(new GZIPInputStream(new URL(url).openStream())))
+ // @ts-ignore
+ var entry
+ while ((entry = tis.getNextEntry()) != null) {
+ var targetPath = Paths.get(target + separatorChar + entry.getName().substring(8))
+ targetPath.toFile().getParentFile().mkdirs()
+ Files.copy(tis, targetPath, StandardCopyOption.REPLACE_EXISTING)
+ }
+ return name
+ })
+ new Thread(future, "MiaoScript download thread").start()
+ return future.get()
}
/**
@@ -327,10 +335,14 @@
}
function fetchContent(url, name) {
- var tempFile = Files.createTempFile(name.replace('/', '_'), '.json')
- Files.copy(new URL(url).openStream(), tempFile, StandardCopyOption.REPLACE_EXISTING)
- tempFile.toFile().deleteOnExit()
- return new JavaString(Files.readAllBytes(tempFile), 'UTF-8')
+ var future = new FutureTask(function () {
+ var tempFile = Files.createTempFile(name.replace('/', '_'), '.json')
+ Files.copy(new URL(url).openStream(), tempFile, StandardCopyOption.REPLACE_EXISTING)
+ tempFile.toFile().deleteOnExit()
+ return new JavaString(Files.readAllBytes(tempFile), 'UTF-8')
+ })
+ new Thread(future, "MiaoScript require thread").start()
+ return future.get()
}
var lastModule = ''