refactor(electron): move electron-api to framework (#8601)

fix AF-1394
This commit is contained in:
pengx17
2024-10-30 09:16:20 +00:00
parent 50bae9c3e6
commit a791481ac8
81 changed files with 788 additions and 567 deletions

View File

@@ -7,13 +7,13 @@ import type {
handlers as mainHandlers,
} from '@affine/electron/main/exposed';
import type { appInfo as exposedAppInfo } from '@affine/electron/preload/electron-api';
import type { sharedStorage as exposedSharedStorage } from '@affine/electron/preload/shared-storage';
import type { SharedStorage } from '@affine/electron/preload/shared-storage';
type MainHandlers = typeof mainHandlers;
type HelperHandlers = typeof helperHandlers;
type HelperEvents = typeof helperEvents;
type MainEvents = typeof mainEvents;
type ClientHandler = {
export type ClientHandler = {
[namespace in keyof MainHandlers]: {
[method in keyof MainHandlers[namespace]]: MainHandlers[namespace][method] extends (
arg0: any,
@@ -27,17 +27,19 @@ type ClientHandler = {
: never;
};
} & HelperHandlers;
type ClientEvents = MainEvents & HelperEvents;
export type ClientEvents = MainEvents & HelperEvents;
export const appInfo = (globalThis as any).__appInfo as
| typeof exposedAppInfo
| null;
export const apis = (globalThis as any).__apis as ClientHandler | null;
export const events = (globalThis as any).__events as ClientEvents | null;
export const apis = (globalThis as any).__apis as ClientHandler | undefined;
export const events = (globalThis as any).__events as ClientEvents | undefined;
export const sharedStorage = (globalThis as any).__sharedStorage as
| typeof exposedSharedStorage
| null;
| SharedStorage
| undefined;
export type { SharedStorage };
export type { UpdateMeta } from '@affine/electron/main/updater/event';
export {