Skip to content

Commit

Permalink
fix: electron preload script
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jul 2, 2024
1 parent 6ee2259 commit beed579
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion satellite/src/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ trayMenu.append(
height: 720,
autoHideMenuBar: isProduction,
webPreferences: {
preload: fileURLToPath(new URL('../dist/electronPreload.js', import.meta.url)),
preload: fileURLToPath(new URL('../dist/electronPreload.cjs', import.meta.url)),
},
})
configWindow.on('close', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { contextBridge, ipcRenderer } from 'electron'
const { contextBridge, ipcRenderer } = require('electron')
// @ts-expect-error
import type { ApiConfigData, ApiStatusResponse } from './apiTypes.js'

export const electronApi = {
const electronApi = {
rescanSurfaces: (): void => ipcRenderer.send('rescan'),
getStatus: async (): Promise<ApiStatusResponse> => ipcRenderer.invoke('getStatus'),
getConfig: async (): Promise<ApiConfigData> => ipcRenderer.invoke('getConfig'),
Expand All @@ -10,3 +11,5 @@ export const electronApi = {
}

contextBridge.exposeInMainWorld('electronApi', electronApi)

export type { electronApi }
2 changes: 1 addition & 1 deletion satellite/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "@tsconfig/node20/tsconfig.json",
"include": ["src/**/*.ts"],
"include": ["src/**/*.ts", "src/**/*.cts", "src/**/*.mts"],
"exclude": ["node_modules/**", "src/**/*spec.ts", "src/**/__tests__/*", "src/**/__mocks__/*"],
"compilerOptions": {
"outDir": "./dist",
Expand Down
2 changes: 1 addition & 1 deletion webui/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/// <reference types="vite/client" />

declare const electronApi: typeof import('../../dist/electronPreload').electronApi
declare const electronApi: typeof import('../../satellite/dist/electronPreload.cjs').electronApi
1 change: 1 addition & 0 deletions webui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default defineConfig({
input: {
main: resolve(__dirname, 'index.html'),
electron: resolve(__dirname, 'electron.html'),
// preload: resolve(__dirname, 'preload.ts'),
},
},
},
Expand Down

0 comments on commit beed579

Please sign in to comment.