mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
refactor: project tsconfig & abstract infra type (#2721)
This commit is contained in:
@@ -4,10 +4,10 @@ import type {
|
||||
DialogHandlerManager,
|
||||
ExportHandlerManager,
|
||||
UIHandlerManager,
|
||||
UnwrapManagerHandlerToServerSide,
|
||||
UpdaterHandlerManager,
|
||||
WorkspaceHandlerManager,
|
||||
} from '@toeverything/infra';
|
||||
import type { HandlerManager, PrimitiveHandlers } from '@toeverything/infra';
|
||||
import { ipcMain } from 'electron';
|
||||
|
||||
import { dbHandlers } from './db';
|
||||
@@ -27,24 +27,35 @@ export const debugHandlers = {
|
||||
},
|
||||
};
|
||||
|
||||
type UnwrapManagerHandler<
|
||||
Manager extends HandlerManager<string, Record<string, PrimitiveHandlers>>
|
||||
> = {
|
||||
[K in keyof Manager['handlers']]: Manager['handlers'][K] extends (
|
||||
...args: infer Args
|
||||
) => Promise<infer R>
|
||||
? (event: Electron.IpcMainInvokeEvent, ...args: Args) => Promise<R>
|
||||
: never;
|
||||
};
|
||||
|
||||
type AllHandlers = {
|
||||
db: UnwrapManagerHandler<DBHandlerManager>;
|
||||
debug: UnwrapManagerHandler<DebugHandlerManager>;
|
||||
dialog: UnwrapManagerHandler<DialogHandlerManager>;
|
||||
export: UnwrapManagerHandler<ExportHandlerManager>;
|
||||
ui: UnwrapManagerHandler<UIHandlerManager>;
|
||||
updater: UnwrapManagerHandler<UpdaterHandlerManager>;
|
||||
workspace: UnwrapManagerHandler<WorkspaceHandlerManager>;
|
||||
db: UnwrapManagerHandlerToServerSide<
|
||||
Electron.IpcMainInvokeEvent,
|
||||
DBHandlerManager
|
||||
>;
|
||||
debug: UnwrapManagerHandlerToServerSide<
|
||||
Electron.IpcMainInvokeEvent,
|
||||
DebugHandlerManager
|
||||
>;
|
||||
dialog: UnwrapManagerHandlerToServerSide<
|
||||
Electron.IpcMainInvokeEvent,
|
||||
DialogHandlerManager
|
||||
>;
|
||||
export: UnwrapManagerHandlerToServerSide<
|
||||
Electron.IpcMainInvokeEvent,
|
||||
ExportHandlerManager
|
||||
>;
|
||||
ui: UnwrapManagerHandlerToServerSide<
|
||||
Electron.IpcMainInvokeEvent,
|
||||
UIHandlerManager
|
||||
>;
|
||||
updater: UnwrapManagerHandlerToServerSide<
|
||||
Electron.IpcMainInvokeEvent,
|
||||
UpdaterHandlerManager
|
||||
>;
|
||||
workspace: UnwrapManagerHandlerToServerSide<
|
||||
Electron.IpcMainInvokeEvent,
|
||||
WorkspaceHandlerManager
|
||||
>;
|
||||
};
|
||||
|
||||
// Note: all of these handlers will be the single-source-of-truth for the apis exposed to the renderer process
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
"@types/fs-extra": "^11.0.1",
|
||||
"@types/uuid": "^9.0.1",
|
||||
"cross-env": "7.0.3",
|
||||
"electron": "25.0.1",
|
||||
"electron": "=25.0.1",
|
||||
"electron-log": "^5.0.0-beta.24",
|
||||
"electron-squirrel-startup": "1.0.0",
|
||||
"electron-window-state": "^5.0.3",
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./lib",
|
||||
"baseUrl": ".",
|
||||
"noEmit": true,
|
||||
"target": "ESNext"
|
||||
},
|
||||
"references": [{ "path": "../../../tests/kit" }],
|
||||
"include": ["**.spec.ts", "**.test.ts"]
|
||||
"include": ["**.spec.ts", "**.test.ts", "fixture.ts"],
|
||||
"exclude": ["lib"]
|
||||
}
|
||||
|
||||
@@ -11,20 +11,19 @@
|
||||
"outDir": "dist",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"noImplicitOverride": true,
|
||||
"noEmit": false
|
||||
"noImplicitOverride": true
|
||||
},
|
||||
"include": ["**/*.ts", "**/*.tsx"],
|
||||
"include": ["./layers"],
|
||||
"exclude": ["node_modules", "out", "dist"],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.node.json"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/native"
|
||||
"path": "./tests/tsconfig.json"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/env"
|
||||
"path": "../../packages/native"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/infra"
|
||||
|
||||
@@ -17,16 +17,15 @@
|
||||
"incremental": true,
|
||||
"experimentalDecorators": true
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
"src/types/types.d.ts",
|
||||
"../../packages/graphql",
|
||||
"../electron/layers"
|
||||
],
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "src/types/types.d.ts"],
|
||||
"exclude": ["node_modules"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../packages/plugin-infra"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/infra"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/env"
|
||||
},
|
||||
@@ -44,6 +43,17 @@
|
||||
},
|
||||
{
|
||||
"path": "../../packages/hooks"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/graphql"
|
||||
},
|
||||
|
||||
// Plugins
|
||||
{
|
||||
"path": "../../plugins/bookmark-block"
|
||||
},
|
||||
{
|
||||
"path": "../../plugins/copilot"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user