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;
|
||||
|
||||
private _name: string = '';
|
||||
private _level: LogLevel = global.debug ? LogLevel.DEBUG : LogLevel.INFO;
|
||||
private _level: LogLevel = LogLevel.INFO;
|
||||
|
||||
protected logger: any;
|
||||
protected prefix: string = '§6[§bMiaoScript§6]§r ';
|
||||
@ -25,6 +25,12 @@ export class MiaoScriptConsole implements Console {
|
||||
constructor(name?: string) {
|
||||
this.name = name;
|
||||
this.logger = global.logger;
|
||||
if (global.debug) {
|
||||
this._level = LogLevel.DEBUG
|
||||
}
|
||||
if (global.level?.toUpperCase() === "TRACE") {
|
||||
this._level = LogLevel.TRACE
|
||||
}
|
||||
}
|
||||
|
||||
get name() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/// <reference path="./typings/global.ts" />
|
||||
import '@ms/ployfill'
|
||||
|
||||
export * from './task'
|
||||
export * from './event'
|
||||
|
@ -1,13 +1,14 @@
|
||||
import { XMLHttpRequest as xhr } from '@ms/ployfill'
|
||||
|
||||
import { XMLHttpRequest as xhr } from './xml-http-request'
|
||||
declare global {
|
||||
namespace NodeJS {
|
||||
interface Global {
|
||||
logger: any;
|
||||
debug: boolean;
|
||||
noop: Function;
|
||||
level: string;
|
||||
NashornEngineStartTime: number;
|
||||
setGlobal: (key: string, value: any) => void;
|
||||
noop: () => void;
|
||||
console: Console;
|
||||
XMLHttpRequest: typeof xhr;
|
||||
}
|
||||
}
|
||||
var root: string;
|
@ -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;
|
||||
|
||||
export {
|
||||
XMLHttpRequest
|
||||
}
|
||||
let ployfillStartTime = new Date().getTime();
|
||||
console.info('Initialization Java Nashorn ployfill. Please wait...');
|
||||
// String contains ployfill
|
||||
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