feat: createBackend, createPreload, createRenderer

Introduced the mentioned helper methods in order to help split big plugins into manageable chunks.
This commit is contained in:
Angelos Bouklis
2023-11-28 00:06:52 +02:00
parent eaaf170cc8
commit 04d7b32d3f
4 changed files with 219 additions and 134 deletions

View File

@ -0,0 +1,28 @@
import prompt from 'custom-electron-prompt';
import promptOptions from '@/providers/prompt-options';
import { createBackend } from '@/utils';
export default createBackend({
start({ ipc: { handle }, window }) {
handle(
'captionsSelector',
async (captionLabels: Record<string, string>, currentIndex: string) =>
await prompt(
{
title: 'Choose Caption',
label: `Current Caption: ${captionLabels[currentIndex] || 'None'}`,
type: 'select',
value: currentIndex,
selectOptions: captionLabels,
resizable: true,
...promptOptions(),
},
window,
),
);
},
stop({ ipc: { removeHandler } }) {
removeHandler('captionsSelector');
},
});