diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 8ba00bfb..76fdb2f4 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -43,14 +43,14 @@ class MiaoScriptCore { console.i18n("ms.core.plugin.initialize") this.pluginManager.scan(this.pluginFolder) this.pluginManager.build() - this.pluginManager.load() - this.pluginManager.enable() + this.pluginManager.load(this.pluginManager.getPlugins()) + this.pluginManager.enable(this.pluginManager.getPlugins()) console.i18n("ms.core.plugin.completed", { time: (new Date().getTime() - loadPluginStartTime) / 1000 }) } disable() { console.i18n("ms.core.engine.disable") - this.pluginManager.disable() + this.pluginManager.disable(this.pluginManager.getPlugins()) this.taskManager.disable() //@ts-ignore require.disable() diff --git a/packages/ployfill/src/xml-http-request.ts b/packages/ployfill/src/xml-http-request.ts index 3c7567d2..fb3d97c7 100644 --- a/packages/ployfill/src/xml-http-request.ts +++ b/packages/ployfill/src/xml-http-request.ts @@ -87,6 +87,7 @@ export class XMLHttpRequest { private _status: number = 0; private _statusText: string = null; private _response: any; + private _responseText: any; private _responseURL: string; private _responseHeaders: HttpHeader = {}; @@ -115,10 +116,10 @@ export class XMLHttpRequest { return this._statusText; } get response() { - return this._response ? JSON.parse(this._response) : this._response; + return this._response || this.get(); } get responseText() { - return this._response; + return this._responseText; } get responseXML() { return this._response; @@ -181,14 +182,17 @@ export class XMLHttpRequest { return future; } get() { - switch (this._responseType) { - case "json": - return this.response; - case "text": - return this.responseText; - default: - throw Error(`Unsupport ResponseType: ${this._responseType} !`) + if (this._response === undefined) { + switch (this._responseType) { + case "json": + return this._response = JSON.parse(this._responseText); + case "text": + return this._response = this._responseText; + default: + throw Error(`Unsupport ResponseType: ${this._responseType} !`) + } } + return this._response; } abort() { this._connection.disconnect(); @@ -211,11 +215,11 @@ export class XMLHttpRequest { this._status = this._connection.getResponseCode(); this._statusText = this._connection.getResponseMessage(); if (this._status >= 0 && this._status < 300) { - this._response = this.readOutput(this._connection.getInputStream()); + this._responseText = this.readOutput(this._connection.getInputStream()); } else if (this._status >= 300 && this._status < 400) { this._responseURL = this.getResponseHeader('Location'); } else { - this._response = this.readOutput(this._connection.getErrorStream()); + this._responseText = this.readOutput(this._connection.getErrorStream()); } this.setResponseHeaders(this._connection.getHeaderFields()); this.onloadend && this.onloadend(); diff --git a/packages/plugin/src/manager.ts b/packages/plugin/src/manager.ts index faa86e28..f4af10aa 100644 --- a/packages/plugin/src/manager.ts +++ b/packages/plugin/src/manager.ts @@ -123,7 +123,7 @@ export class PluginManagerImpl implements plugin.PluginManager { } private checkAndGet(name: string | interfaces.Plugin | undefined | any): Map | interfaces.Plugin[] { - if (name == undefined) { return this.pluginInstanceMap } + if (name == this.pluginInstanceMap) { return this.pluginInstanceMap } if (typeof name == 'string' && this.pluginInstanceMap.has(name)) { return [this.pluginInstanceMap.get(name)] } if (name instanceof interfaces.Plugin) { return [name as interfaces.Plugin] } if (name.description || name.description.name) { return [name as interfaces.Plugin] }