feat: move global declare to @ms/ployfill

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2020-02-01 02:44:23 +08:00
parent cacde0627b
commit 606bbb3991
4 changed files with 30 additions and 13 deletions

View File

@ -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() {

View File

@ -1,4 +1,4 @@
/// <reference path="./typings/global.ts" />
import '@ms/ployfill'
export * from './task'
export * from './event'

View File

@ -1,33 +0,0 @@
import { XMLHttpRequest as xhr } from '@ms/ployfill'
declare global {
namespace NodeJS {
interface Global {
logger: any;
debug: boolean;
noop: Function;
console: Console;
XMLHttpRequest: typeof xhr;
}
}
var root: string;
var base: Core;
var XMLHttpRequest: typeof xhr;
var ScriptEngineContextHolder: any;
function engineLoad(str: string): any;
interface Core {
getClass(name: String): any;
getProxyClass(): any;
getInstance(): any;
read(path: string): string;
save(path: string, content: string): void;
delete(path: string): void;
}
interface Console {
ex(err: Error): void;
stack(err: Error): string[];
sender(...args: any): void;
console(...args: any): void;
}
}
export { }