refactor: move from next js to vite and tanstack router

This commit is contained in:
Kacper
2025-12-17 20:11:16 +01:00
parent 9954feafd8
commit 5136c32b68
263 changed files with 11148 additions and 10276 deletions

42
apps/ui/src/preload.ts Normal file
View File

@@ -0,0 +1,42 @@
/**
* Electron preload script (TypeScript)
*
* Only exposes native features (dialogs, shell) and server URL.
* All other operations go through HTTP API.
*/
import { contextBridge, ipcRenderer, OpenDialogOptions, SaveDialogOptions } from "electron";
// Expose minimal API for native features
contextBridge.exposeInMainWorld("electronAPI", {
// Platform info
platform: process.platform,
isElectron: true,
// Connection check
ping: (): Promise<string> => ipcRenderer.invoke("ping"),
// Get server URL for HTTP client
getServerUrl: (): Promise<string> => ipcRenderer.invoke("server:getUrl"),
// Native dialogs - better UX than prompt()
openDirectory: (): Promise<Electron.OpenDialogReturnValue> =>
ipcRenderer.invoke("dialog:openDirectory"),
openFile: (options?: OpenDialogOptions): Promise<Electron.OpenDialogReturnValue> =>
ipcRenderer.invoke("dialog:openFile", options),
saveFile: (options?: SaveDialogOptions): Promise<Electron.SaveDialogReturnValue> =>
ipcRenderer.invoke("dialog:saveFile", options),
// Shell operations
openExternalLink: (url: string): Promise<{ success: boolean; error?: string }> =>
ipcRenderer.invoke("shell:openExternal", url),
openPath: (filePath: string): Promise<{ success: boolean; error?: string }> =>
ipcRenderer.invoke("shell:openPath", filePath),
// App info
getPath: (name: string): Promise<string> => ipcRenderer.invoke("app:getPath", name),
getVersion: (): Promise<string> => ipcRenderer.invoke("app:getVersion"),
isPackaged: (): Promise<boolean> => ipcRenderer.invoke("app:isPackaged"),
});
console.log("[Preload] Electron API exposed (TypeScript)");