improve(plugin): run installed plugin in isolated domain

This commit is contained in:
charlie
2021-08-25 16:24:56 +08:00
parent 1859479e42
commit d8d69c0e51
6 changed files with 98 additions and 51 deletions

View File

@@ -1,4 +1,4 @@
import { deepMerge } from './helpers'
import { deepMerge, safetyPathJoin } from './helpers'
import { LSPluginCaller } from './LSPlugin.caller'
import {
IAppProxy, IDBProxy,
@@ -271,6 +271,12 @@ export class LSPluginUser extends EventEmitter<LSPluginUserEvents> implements IL
}
}
ensureConnected () {
if (!this._connected) {
throw new Error('not connected')
}
}
beforeunload (callback: (e: any) => Promise<void>): void {
if (typeof callback !== 'function') return
this._beforeunloadCallback = callback
@@ -354,6 +360,13 @@ export class LSPluginUser extends EventEmitter<LSPluginUserEvents> implements IL
return this._caller
}
resolveResourceFullUrl (filePath: string) {
this.ensureConnected()
if (!filePath) return
filePath = filePath.replace(/^[.\\/]+/, '')
return safetyPathJoin(this._baseInfo.lsr, filePath)
}
/**
* @internal
*/