feat: move global declare to @ms/ployfill
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
39e899211b
commit
8c4f266356
@ -17,7 +17,7 @@ export class MiaoScriptConsole implements Console {
|
|||||||
Console: NodeJS.ConsoleConstructor;
|
Console: NodeJS.ConsoleConstructor;
|
||||||
|
|
||||||
private _name: string = '';
|
private _name: string = '';
|
||||||
private _level: LogLevel = global.debug ? LogLevel.DEBUG : LogLevel.INFO;
|
private _level: LogLevel = LogLevel.INFO;
|
||||||
|
|
||||||
protected logger: any;
|
protected logger: any;
|
||||||
protected prefix: string = '§6[§bMiaoScript§6]§r ';
|
protected prefix: string = '§6[§bMiaoScript§6]§r ';
|
||||||
@ -25,6 +25,12 @@ export class MiaoScriptConsole implements Console {
|
|||||||
constructor(name?: string) {
|
constructor(name?: string) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.logger = global.logger;
|
this.logger = global.logger;
|
||||||
|
if (global.debug) {
|
||||||
|
this._level = LogLevel.DEBUG
|
||||||
|
}
|
||||||
|
if (global.level?.toUpperCase() === "TRACE") {
|
||||||
|
this._level = LogLevel.TRACE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() {
|
get name() {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/// <reference path="./typings/global.ts" />
|
import '@ms/ployfill'
|
||||||
|
|
||||||
export * from './task'
|
export * from './task'
|
||||||
export * from './event'
|
export * from './event'
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import { XMLHttpRequest as xhr } from '@ms/ployfill'
|
import { XMLHttpRequest as xhr } from './xml-http-request'
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace NodeJS {
|
namespace NodeJS {
|
||||||
interface Global {
|
interface Global {
|
||||||
logger: any;
|
logger: any;
|
||||||
debug: boolean;
|
debug: boolean;
|
||||||
noop: Function;
|
level: string;
|
||||||
|
NashornEngineStartTime: number;
|
||||||
|
setGlobal: (key: string, value: any) => void;
|
||||||
|
noop: () => void;
|
||||||
console: Console;
|
console: Console;
|
||||||
XMLHttpRequest: typeof xhr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var root: string;
|
var root: string;
|
||||||
@ -30,4 +31,4 @@ declare global {
|
|||||||
console(...args: any): void;
|
console(...args: any): void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export { }
|
export { }
|
@ -1,7 +1,17 @@
|
|||||||
import { XMLHttpRequest as xhr } from './xml-http-request'
|
import './global'
|
||||||
|
import '@ms/nashorn'
|
||||||
|
import { XMLHttpRequest } from './xml-http-request'
|
||||||
|
|
||||||
var XMLHttpRequest = xhr;
|
let ployfillStartTime = new Date().getTime();
|
||||||
|
console.info('Initialization Java Nashorn ployfill. Please wait...');
|
||||||
export {
|
// String contains ployfill
|
||||||
XMLHttpRequest
|
Object.defineProperty(String.prototype, 'contains', {
|
||||||
}
|
value: function(searchString: string, position: number) {
|
||||||
|
return String.prototype.indexOf.call(this, searchString, position) > -1;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// ES6 Map Symbol ployfill
|
||||||
|
require('es6-map/implement');
|
||||||
|
require('es6-symbol/implement');
|
||||||
|
global.setGlobal('XMLHttpRequest', XMLHttpRequest)
|
||||||
|
console.info('Java Nashorn ployfill loading completed... Cost (' + (new Date().getTime() - ployfillStartTime) / 1000 + 's)!');
|
||||||
|
Loading…
Reference in New Issue
Block a user