feat: update to 0.6.0 rename scope to ccms
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
351183ab3c
commit
d0de120867
6
pom.xml
6
pom.xml
@ -1,9 +1,8 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>MiaoScript</artifactId>
|
||||
<version>0.5.0</version>
|
||||
<version>0.6.0</version>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>502647092</id>
|
||||
@ -54,6 +53,7 @@
|
||||
<properties>
|
||||
<env.GIT_COMMIT>DEV</env.GIT_COMMIT>
|
||||
<update.changes>
|
||||
§620-05-02 §afeat: 调整 scope 为 @ccms;
|
||||
§620-04-10 §afeat: 默认从 classpath 加载内建的js模块;
|
||||
§620-04-07 §afeat: 默认初始化 内建 nodejs 模块;
|
||||
§620-04-03 §afeat: 优化 框架卸载逻辑;
|
||||
|
@ -1,17 +1,15 @@
|
||||
'use strict';
|
||||
var log;
|
||||
var boot;
|
||||
var engineDisable;
|
||||
var global = this;
|
||||
/**
|
||||
* Init MiaoScriptEngine Runtime
|
||||
*/
|
||||
(function() {
|
||||
(function () {
|
||||
var loader;
|
||||
boot = function(root, logger) {
|
||||
log = logger;
|
||||
global.boot = function (root, logger) {
|
||||
global.scope = "@ccms";
|
||||
global.log = logger;
|
||||
// Development Env Detect
|
||||
root = root || "src/main/resources";
|
||||
global.root = root || "src/main/resources";
|
||||
if (__FILE__.indexOf('!') === -1) {
|
||||
logger.info('Loading custom BIOS file ' + __FILE__);
|
||||
global.debug = true;
|
||||
@ -27,10 +25,10 @@ var global = this;
|
||||
// Check Class Loader, Sometimes Server will can't found plugin.yml file
|
||||
loader = checkClassLoader();
|
||||
// Async Loading MiaoScript Engine
|
||||
new java.lang.Thread(function() {
|
||||
new java.lang.Thread(function () {
|
||||
java.lang.Thread.currentThread().contextClassLoader = loader;
|
||||
load('classpath:core/ployfill.js')(root, logger);
|
||||
engineDisable = require('@ms/core').default || function() { logger.info('Error: abnormal Initialization MiaoScript Engine. Skip disable step...') };
|
||||
global.engineDisable = require(global.scope + '/core').default || function () { logger.info('Error: abnormal Initialization MiaoScript Engine. Skip disable step...') };
|
||||
}, "MiaoScript thread").start()
|
||||
};
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
/**
|
||||
* @param {{ info: (arg0: string) => void; }} logger
|
||||
*/
|
||||
function(logger) {
|
||||
function (logger) {
|
||||
function log() {
|
||||
logger.info(Array.prototype.join.call(arguments, ' '))
|
||||
}
|
||||
@ -11,7 +11,7 @@
|
||||
* @param {string} prefix
|
||||
*/
|
||||
function _proxy(prefix) {
|
||||
return function() {
|
||||
return function () {
|
||||
log('[' + prefix + ']', Array.prototype.join.call(arguments, ' '))
|
||||
}
|
||||
}
|
||||
|
@ -3,20 +3,20 @@
|
||||
* @param {string} root
|
||||
* @param {any} logger
|
||||
*/
|
||||
function(root, logger) {
|
||||
function (root, logger) {
|
||||
// Init Global Value
|
||||
global.root = root;
|
||||
global.logger = logger;
|
||||
global.NashornEngineStartTime = new Date().getTime()
|
||||
global.engineLoad = load;
|
||||
global.noop = global.engineDisable = engineDisable = function() { };
|
||||
global.noop = global.engineDisable = engineDisable = function () { };
|
||||
global.load = load = function __PreventGlobalLoadFunction__() { throw new Error('Internal engine system not allow use `load` function!'); }
|
||||
global.setGlobal = function(key, value) { global[key] = value; };
|
||||
global.setGlobal = function (key, value) { global[key] = value; };
|
||||
// Init console and require
|
||||
global.console = engineLoad('classpath:core/console.js')(logger);
|
||||
console.log("Loading Engine at Thread", java.lang.Thread.currentThread().name)
|
||||
global.require = engineLoad('classpath:core/require.js')(root);
|
||||
require('@ms/ployfill')
|
||||
require('@ms/nodejs')
|
||||
require(global.scope + '/ployfill')
|
||||
require(global.scope + '/nodejs')
|
||||
}
|
||||
)
|
||||
|
@ -25,24 +25,33 @@
|
||||
* 暂不支持 4. 如果 xx/index.msm 是一个文件 则使用MScript解析器解析 并停止执行
|
||||
*/
|
||||
// @ts-check
|
||||
/// <reference types="@ms/nashorn" />
|
||||
(
|
||||
/**
|
||||
* @param {any} parent
|
||||
*/
|
||||
function(parent) {
|
||||
function (parent) {
|
||||
'use strict';
|
||||
// @ts-ignore
|
||||
var File = Java.type('java.io.File');
|
||||
// @ts-ignore
|
||||
var Paths = Java.type('java.nio.file.Paths');
|
||||
// @ts-ignore
|
||||
var Files = Java.type('java.nio.file.Files');
|
||||
// @ts-ignore
|
||||
var StandardCopyOption = Java.type('java.nio.file.StandardCopyOption');
|
||||
// @ts-ignore
|
||||
var FileNotFoundException = Java.type('java.io.FileNotFoundException');
|
||||
|
||||
// @ts-ignore
|
||||
var TarInputStream = Java.type('org.kamranzafar.jtar.TarInputStream');
|
||||
// @ts-ignore
|
||||
var GZIPInputStream = Java.type('java.util.zip.GZIPInputStream');
|
||||
// @ts-ignore
|
||||
var BufferedInputStream = Java.type('java.io.BufferedInputStream');
|
||||
|
||||
// @ts-ignore
|
||||
var URL = Java.type('java.net.URL')
|
||||
// @ts-ignore
|
||||
var JavaString = Java.type('java.lang.String')
|
||||
var separatorChar = File.separatorChar;
|
||||
|
||||
@ -258,9 +267,10 @@
|
||||
* @param {string} name 包名称
|
||||
*/
|
||||
function download(name) {
|
||||
// handle name es6-map/implement => es6-map @ms/common/dist/reflect => @ms/common
|
||||
// handle name es6-map/implement => es6-map @ccms/common/dist/reflect => @ccms/common
|
||||
var name_arr = name.split('/');
|
||||
var module_name = name.startsWith('@') ? name_arr[0] + '/' + name_arr[1] : name_arr[0];
|
||||
// @ts-ignore
|
||||
var target = root + separatorChar + 'node_modules' + separatorChar + module_name;
|
||||
var _package = new File(target, 'package.json');
|
||||
if (_package.exists()) { return }
|
||||
@ -279,6 +289,9 @@
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} module_name
|
||||
*/
|
||||
function fetchPackageInfo(module_name) {
|
||||
var tempFile = Files.createTempFile(module_name.replace('/', '_'), '.json');
|
||||
try {
|
||||
@ -291,17 +304,23 @@
|
||||
return JSON.parse(new JavaString(Files.readAllBytes(tempFile), 'UTF-8'));
|
||||
}
|
||||
|
||||
var lastModule = ''
|
||||
/**
|
||||
* 检查核心模块
|
||||
* @param {string} name
|
||||
*/
|
||||
function checkCoreModule(name, path) {
|
||||
if (name.startsWith('@ms') && lastModule.endsWith('.js')) {
|
||||
console.warn(lastModule + ' load deprecated module ' + name + ' auto replace to ' + name.replace('@ms', '@ccms') + '...')
|
||||
} else {
|
||||
lastModule = name
|
||||
}
|
||||
if (CoreModules.indexOf(name) != -1) {
|
||||
var newName = '@ms/nodejs/dist/' + name
|
||||
var newName = '@ccms/nodejs/dist/' + name
|
||||
if (resolve(newName, path) !== undefined) {
|
||||
return newName;
|
||||
}
|
||||
throw new Error("Can't load nodejs core module " + name + " . maybe later will auto replace to @ms/nodejs/" + name + ' to compatible...')
|
||||
throw new Error("Can't load nodejs core module " + name + " . maybe later will auto replace to @ccms/nodejs/" + name + ' to compatible...')
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user