|
@@ -19,7 +19,8 @@ import {
|
|
|
cleanInjectedScripts,
|
|
|
safeSnakeCase,
|
|
|
injectTheme,
|
|
|
- cleanInjectedUI, PluginLogger,
|
|
|
+ cleanInjectedUI,
|
|
|
+ PluginLogger,
|
|
|
} from './helpers'
|
|
|
import * as pluginHelpers from './helpers'
|
|
|
import Debug from 'debug'
|
|
@@ -914,23 +915,23 @@ class PluginLocal extends EventEmitter<'loaded'
|
|
|
|
|
|
const eventBeforeUnload = { unregister }
|
|
|
|
|
|
- // sync call
|
|
|
- try {
|
|
|
- await this._caller?.callUserModel(
|
|
|
- AWAIT_LSPMSGFn(LSPMSG_BEFORE_UNLOAD),
|
|
|
- eventBeforeUnload
|
|
|
- )
|
|
|
- this.emit('beforeunload', eventBeforeUnload)
|
|
|
- } catch (e) {
|
|
|
- console.error('[beforeunload Error]', e)
|
|
|
- }
|
|
|
+ if (this.loaded) {
|
|
|
+ try {
|
|
|
+ await this._caller?.callUserModel(
|
|
|
+ AWAIT_LSPMSGFn(LSPMSG_BEFORE_UNLOAD),
|
|
|
+ eventBeforeUnload
|
|
|
+ )
|
|
|
+ this.emit('beforeunload', eventBeforeUnload)
|
|
|
+ } catch (e) {
|
|
|
+ this.logger.error('[beforeunload Error]', e)
|
|
|
+ }
|
|
|
|
|
|
- await this.dispose()
|
|
|
+ await this.dispose()
|
|
|
+ }
|
|
|
|
|
|
this.emit('unloaded')
|
|
|
} catch (e) {
|
|
|
- debug('[plugin unload Error]', e)
|
|
|
- return false
|
|
|
+ this.logger.error('[unload Error]', e)
|
|
|
} finally {
|
|
|
this._status = PluginLocalLoadStatus.UNLOADED
|
|
|
}
|
|
@@ -1084,7 +1085,8 @@ class PluginLocal extends EventEmitter<'loaded'
|
|
|
* Host plugin core
|
|
|
*/
|
|
|
class LSPluginCore
|
|
|
- extends EventEmitter<'beforeenable'
|
|
|
+ extends EventEmitter<
|
|
|
+ | 'beforeenable'
|
|
|
| 'enabled'
|
|
|
| 'beforedisable'
|
|
|
| 'disabled'
|
|
@@ -1098,7 +1100,8 @@ class LSPluginCore
|
|
|
| 'settings-changed'
|
|
|
| 'unlink-plugin'
|
|
|
| 'beforereload'
|
|
|
- | 'reloaded'>
|
|
|
+ | 'reloaded'
|
|
|
+ >
|
|
|
implements ILSPluginThemeManager {
|
|
|
private _isRegistering = false
|
|
|
private _readyIndicator?: DeferredActor
|