feat: plugin system with isolated bundles (#2660)

(cherry picked from commit 94d20f1bdc)
This commit is contained in:
Himself65
2023-06-02 16:28:47 +08:00
committed by himself65
parent 66653d1d8a
commit bb8bfd0c9e
19 changed files with 147 additions and 28 deletions
+9 -8
View File
@@ -1,10 +1,17 @@
import { join } from 'node:path';
import { app, BrowserWindow, nativeTheme } from 'electron';
import type { NamespaceHandlers } from '../type';
import { isMacOS } from '../utils';
import { getMetaData } from './get-meta-data';
import { getGoogleOauthCode } from './google-auth';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const handlers = require(join(
process.env.PLUGIN_DIR ?? '../../plugins',
'./bookmark-block/server'
)) as NamespaceHandlers;
export const uiHandlers = {
handleThemeChange: async (_, theme: (typeof nativeTheme)['themeSource']) => {
nativeTheme.themeSource = theme;
@@ -40,11 +47,5 @@ export const uiHandlers = {
getGoogleOauthCode: async () => {
return getGoogleOauthCode();
},
getBookmarkDataByLink: async (_, url: string) => {
return getMetaData(url, {
shouldReGetHTML: metaData => {
return !metaData.title && !metaData.description;
},
});
},
...handlers,
} satisfies NamespaceHandlers;