draggables, ipc stuff
This commit is contained in:
@ -1,6 +1,10 @@
|
||||
// Disable no-unused-vars, broken for spread args
|
||||
/* eslint no-unused-vars: off */
|
||||
import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron';
|
||||
import FileChannels from '../ipc/audio/channels';
|
||||
import { LoadAudioBufferArgs, ReadTextArgs } from '../ipc/audio/types';
|
||||
import AudioChannels from '../ipc/audio/channels';
|
||||
// import '../ipc/file/preload'; // Import file API preload to ensure it runs and exposes the API
|
||||
|
||||
export type Channels = 'ipc-example';
|
||||
|
||||
@ -22,11 +26,27 @@ const electronHandler = {
|
||||
ipcRenderer.once(channel, (_event, ...args) => func(...args));
|
||||
},
|
||||
|
||||
loadAudioBuffer: (filePath: string) =>
|
||||
ipcRenderer.invoke('load-audio-buffer', filePath),
|
||||
invoke: (event: string, ...args: unknown[]) =>
|
||||
ipcRenderer.invoke(event, ...args),
|
||||
},
|
||||
};
|
||||
|
||||
contextBridge.exposeInMainWorld('electron', electronHandler);
|
||||
|
||||
export type ElectronHandler = typeof electronHandler;
|
||||
|
||||
const audioHandler = {
|
||||
loadAudioBuffer: (filePath: string) =>
|
||||
ipcRenderer.invoke(AudioChannels.LOAD_AUDIO_BUFFER, {
|
||||
filePath,
|
||||
} satisfies LoadAudioBufferArgs),
|
||||
|
||||
readText: (filePath: string) =>
|
||||
ipcRenderer.invoke(AudioChannels.READ_TEXT, {
|
||||
filePath,
|
||||
} satisfies ReadTextArgs),
|
||||
};
|
||||
|
||||
contextBridge.exposeInMainWorld('audio', audioHandler);
|
||||
|
||||
export type AudioHandler = typeof audioHandler;
|
||||
|
||||
Reference in New Issue
Block a user