|
@@ -437,9 +437,11 @@ class ExistedImportedPluginPackageError extends Error {
|
|
|
/**
|
|
|
* Host plugin for local
|
|
|
*/
|
|
|
-class PluginLocal extends EventEmitter<
|
|
|
- 'loaded' | 'unloaded' | 'beforeunload' | 'error' | string
|
|
|
-> {
|
|
|
+class PluginLocal extends EventEmitter<'loaded'
|
|
|
+ | 'unloaded'
|
|
|
+ | 'beforeunload'
|
|
|
+ | 'error'
|
|
|
+ | string> {
|
|
|
private _sdk: Partial<PluginLocalSDKMetadata> = {}
|
|
|
private _disposes: Array<() => Promise<any>> = []
|
|
|
private _id: PluginLocalIdentity
|
|
@@ -573,7 +575,7 @@ class PluginLocal extends EventEmitter<
|
|
|
const localRoot = (this._localRoot = safetyPathNormalize(url))
|
|
|
const logseq: Partial<LSPluginPkgConfig> = pkg.logseq || {}
|
|
|
|
|
|
- // Pick legal attrs
|
|
|
+ // Pick legal attrs
|
|
|
;[
|
|
|
'name',
|
|
|
'author',
|
|
@@ -681,10 +683,10 @@ class PluginLocal extends EventEmitter<
|
|
|
<meta charset="UTF-8">
|
|
|
<title>logseq plugin entry</title>
|
|
|
${
|
|
|
- IS_DEV
|
|
|
- ? `<script src="${sdkPathRoot}/lsplugin.user.js?v=${tag}"></script>`
|
|
|
- : `<script src="https://cdn.jsdelivr.net/npm/@logseq/libs/dist/lsplugin.user.min.js?v=${tag}"></script>`
|
|
|
- }
|
|
|
+ IS_DEV
|
|
|
+ ? `<script src="${sdkPathRoot}/lsplugin.user.js?v=${tag}"></script>`
|
|
|
+ : `<script src="https://cdn.jsdelivr.net/npm/@logseq/libs/dist/lsplugin.user.min.js?v=${tag}"></script>`
|
|
|
+ }
|
|
|
|
|
|
</head>
|
|
|
<body>
|
|
@@ -1119,8 +1121,7 @@ class PluginLocal extends EventEmitter<
|
|
|
* Host plugin core
|
|
|
*/
|
|
|
class LSPluginCore
|
|
|
- extends EventEmitter<
|
|
|
- | 'beforeenable'
|
|
|
+ extends EventEmitter<'beforeenable'
|
|
|
| 'enabled'
|
|
|
| 'beforedisable'
|
|
|
| 'disabled'
|
|
@@ -1133,10 +1134,8 @@ class LSPluginCore
|
|
|
| 'settings-changed'
|
|
|
| 'unlink-plugin'
|
|
|
| 'beforereload'
|
|
|
- | 'reloaded'
|
|
|
- >
|
|
|
- implements ILSPluginThemeManager
|
|
|
-{
|
|
|
+ | 'reloaded'>
|
|
|
+ implements ILSPluginThemeManager {
|
|
|
private _isRegistering = false
|
|
|
private _readyIndicator?: DeferredActor
|
|
|
private readonly _hostMountedActor: DeferredActor = deferred()
|
|
@@ -1150,10 +1149,8 @@ class LSPluginCore
|
|
|
externals: [],
|
|
|
}
|
|
|
private readonly _registeredThemes = new Map<PluginLocalIdentity, Theme[]>()
|
|
|
- private readonly _registeredPlugins = new Map<
|
|
|
- PluginLocalIdentity,
|
|
|
- PluginLocal
|
|
|
- >()
|
|
|
+ private readonly _registeredPlugins = new Map<PluginLocalIdentity,
|
|
|
+ PluginLocal>()
|
|
|
private _currentTheme: {
|
|
|
pid: PluginLocalIdentity
|
|
|
opt: Theme | LegacyTheme
|
|
@@ -1229,21 +1226,22 @@ class LSPluginCore
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- const perfTable = new Map<
|
|
|
- string,
|
|
|
- { o: PluginLocal; s: number; e: number }
|
|
|
- >()
|
|
|
+ const perfTable = new Map<string,
|
|
|
+ { o: PluginLocal; s: number; e: number }>()
|
|
|
const debugPerfInfo = () => {
|
|
|
- const data = Array.from(perfTable.values()).reduce((ac, it) => {
|
|
|
- const { options, status, disabled } = it.o
|
|
|
-
|
|
|
- ac[it.o.id] = {
|
|
|
- name: options.name,
|
|
|
- entry: options.entry,
|
|
|
- status: status,
|
|
|
- enabled:
|
|
|
- typeof disabled === 'boolean' ? (!disabled ? '🟢' : '⚫️') : '🔴',
|
|
|
- perf: !it.e ? it.o.loadErr : `${(it.e - it.s).toFixed(2)}ms`,
|
|
|
+ const data: any = Array.from(perfTable.values()).reduce((ac, it) => {
|
|
|
+ const { id, options, status, disabled } = it.o
|
|
|
+
|
|
|
+ if (disabled !== true &&
|
|
|
+ (options.entry || (!options.name && !options.entry))) {
|
|
|
+ ac[id] = {
|
|
|
+ name: options.name,
|
|
|
+ entry: options.entry,
|
|
|
+ status: status,
|
|
|
+ enabled:
|
|
|
+ typeof disabled === 'boolean' ? (!disabled ? '🟢' : '⚫️') : '🔴',
|
|
|
+ perf: !it.e ? it.o.loadErr : `${(it.e - it.s).toFixed(2)}ms`,
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return ac
|
|
@@ -1554,12 +1552,12 @@ class LSPluginCore
|
|
|
await this.saveUserPreferences(
|
|
|
theme.mode
|
|
|
? {
|
|
|
- themes: {
|
|
|
- ...this._userPreferences.themes,
|
|
|
- mode: theme.mode,
|
|
|
- [theme.mode]: theme,
|
|
|
- },
|
|
|
- }
|
|
|
+ themes: {
|
|
|
+ ...this._userPreferences.themes,
|
|
|
+ mode: theme.mode,
|
|
|
+ [theme.mode]: theme,
|
|
|
+ },
|
|
|
+ }
|
|
|
: { theme: theme }
|
|
|
)
|
|
|
}
|