Skip to content

Commit 8eb0a27

Browse files
committed
chore: prepare electron wrapper
1 parent 736fd2b commit 8eb0a27

77 files changed

Lines changed: 11293 additions & 1 deletion

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

oxlint.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,10 @@
198198
}
199199
},
200200
{
201-
"files": ["packages/backend/**/*.ts"],
201+
"files": [
202+
"packages/backend/**/*.ts",
203+
"packages/frontend/electron/**/*.ts"
204+
],
202205
"rules": {
203206
"typescript/consistent-type-imports": "off"
204207
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"af": "yarn oa",
1919
"oa": "r oa.ts",
2020
"dev:web": "yarn workspace @afk/app dev",
21+
"dev:electron": "yarn workspace @afk/electron dev",
2122
"dev:server": "yarn oa server dev",
2223
"dev": "concurrently --kill-others --success first \"yarn dev:web\" \"yarn dev:server\"",
2324
"build": "yarn oa build",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "@afk/electron-api",
3+
"version": "0.0.1",
4+
"type": "module",
5+
"private": true,
6+
"main": "./src/index.ts",
7+
"exports": {
8+
".": "./src/index.ts"
9+
}
10+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { ElectronApis } from './ipc-api-types.gen';
2+
import type { ElectronEvents } from './ipc-event-types.gen';
3+
4+
declare global {
5+
// oxlint-disable-next-line no-var
6+
var __appInfo: {
7+
electron: boolean;
8+
scheme: string;
9+
windowName: string;
10+
};
11+
// oxlint-disable-next-line no-var
12+
var __apis: ClientHandler;
13+
// oxlint-disable-next-line no-var
14+
var __events: ClientEvents;
15+
}
16+
17+
export type ClientEvents = ElectronEvents;
18+
export type ClientHandler = ElectronApis & {
19+
getPathForFile: (file: File) => Promise<string>;
20+
};
21+
22+
export const apis = globalThis.__apis as ClientHandler;
23+
export const events = globalThis.__events as ClientEvents;
24+
25+
export * from './ipc-api-types.gen';
26+
export * from './ipc-event-types.gen';
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// AUTO-GENERATED FILE. DO NOT EDIT MANUALLY.
2+
// Generated by: packages/frontend/apps/electron/scripts/generate-types.ts
3+
/* eslint-disable @typescript-eslint/no-explicit-any */
4+
5+
// Utility type: remove trailing IpcMainInvokeEvent param and ensure Promise return
6+
type EnsurePromise<T> = T extends Promise<any> ? T : Promise<T>;
7+
export type ApiMethod<T> = T extends (...args: infer P) => infer R ? (...args: P) => EnsurePromise<R> : never;
8+
9+
export interface ElectronApis {
10+
helper: {
11+
test: ApiMethod<import('@afk/electron/entries/helper/test/test').TestService['test']>;
12+
};
13+
appState: {
14+
handleGetState: ApiMethod<import('@afk/electron/entries/main/state/state.service').StateService['handleGetState']>;
15+
handleUpdateState: ApiMethod<import('@afk/electron/entries/main/state/state.service').StateService['handleUpdateState']>;
16+
handleResetState: ApiMethod<import('@afk/electron/entries/main/state/state.service').StateService['handleResetState']>;
17+
handleFlushState: ApiMethod<import('@afk/electron/entries/main/state/state.service').StateService['handleFlushState']>;
18+
};
19+
ui: {
20+
showMainWindow: ApiMethod<import('@afk/electron/entries/main/windows/main-window.service').MainWindowManager['show']>;
21+
handleThemeChange: ApiMethod<import('@afk/electron/entries/main/windows/main-window.service').MainWindowManager['handleThemeChange']>;
22+
isFullScreen: ApiMethod<import('@afk/electron/entries/main/windows/main-window.service').MainWindowManager['isFullScreen']>;
23+
isMaximized: ApiMethod<import('@afk/electron/entries/main/windows/main-window.service').MainWindowManager['isMaximized']>;
24+
handleMinimizeApp: ApiMethod<import('@afk/electron/entries/main/windows/main-window.service').MainWindowManager['handleMinimizeApp']>;
25+
handleHideApp: ApiMethod<import('@afk/electron/entries/main/windows/main-window.service').MainWindowManager['handleHideApp']>;
26+
handleMaximizeApp: ApiMethod<import('@afk/electron/entries/main/windows/main-window.service').MainWindowManager['handleMaximizeApp']>;
27+
};
28+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// AUTO-GENERATED FILE. DO NOT EDIT MANUALLY.
2+
// Generated by: packages/frontend/apps/electron/scripts/generate-types.ts
3+
/* eslint-disable @typescript-eslint/no-explicit-any */
4+
5+
import type { Observable } from 'rxjs';
6+
7+
type ToSubscribe<T extends Observable<unknown>> = T extends Observable<infer P> ? (callback: (payload: P) => void) => () => void : never;
8+
9+
export interface ElectronEvents {
10+
appState: {
11+
onState: ToSubscribe<import('@afk/electron/entries/main/state/state.service').StateService['state$']>;
12+
};
13+
ui: {
14+
onMaximized: ToSubscribe<import('@afk/electron/entries/main/windows/main-window.service').MainWindowManager['maximized$']>;
15+
onFullScreen: ToSubscribe<import('@afk/electron/entries/main/windows/main-window.service').MainWindowManager['fullScreen$']>;
16+
};
17+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "../../../tsconfig.web.json",
3+
"include": ["./src"],
4+
"compilerOptions": {
5+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
6+
"paths": {
7+
"@afk/electron/*": ["../electron/src/*"]
8+
},
9+
"baseUrl": "."
10+
},
11+
"references": [{ "path": "../electron" }]
12+
}

packages/frontend/electron/.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22.16.0
743 KB
Binary file not shown.

packages/frontend/electron/.yarn/releases/yarn-4.9.1.cjs

Lines changed: 948 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)