diff --git a/apps/stage-tamagotchi/src/main/services/electron/system-preferences.ts b/apps/stage-tamagotchi/src/main/services/electron/system-preferences.ts new file mode 100644 index 000000000..d0351c4fe --- /dev/null +++ b/apps/stage-tamagotchi/src/main/services/electron/system-preferences.ts @@ -0,0 +1,12 @@ +import type { createContext } from '@unbird/eventa/adapters/electron/main' +import type { BrowserWindow } from 'electron' + +import { defineInvokeHandler } from '@unbird/eventa' +import { systemPreferences } from 'electron' + +import { electron } from '../../../shared/eventa' + +export function createSystemPreferencesService(params: { context: ReturnType['context'], window: BrowserWindow }) { + defineInvokeHandler(params.context, electron.systemPreferences.getMediaAccessStatus, type => systemPreferences.getMediaAccessStatus(type)) + defineInvokeHandler(params.context, electron.systemPreferences.askForMediaAccess, type => systemPreferences.askForMediaAccess(type)) +} diff --git a/apps/stage-tamagotchi/src/shared/electron/index.ts b/apps/stage-tamagotchi/src/shared/electron/index.ts index 2760fd682..10a3149aa 100644 --- a/apps/stage-tamagotchi/src/shared/electron/index.ts +++ b/apps/stage-tamagotchi/src/shared/electron/index.ts @@ -1,7 +1,9 @@ import { screen } from './screen' +import { systemPreferences } from './system-preferences' import { window } from './window' export const electron = { screen, window, + systemPreferences, } diff --git a/apps/stage-tamagotchi/src/shared/electron/system-preferences.ts b/apps/stage-tamagotchi/src/shared/electron/system-preferences.ts new file mode 100644 index 000000000..c65b2bb0e --- /dev/null +++ b/apps/stage-tamagotchi/src/shared/electron/system-preferences.ts @@ -0,0 +1,11 @@ +import type { systemPreferences as electronSystemPreferences } from 'electron' + +import { defineInvokeEventa } from '@unbird/eventa' + +const getMediaAccessStatus = defineInvokeEventa, Parameters[0]>('eventa:invoke:electron:system-preferences:get-media-access-status') +const askForMediaAccess = defineInvokeEventa, Parameters[0]>('eventa:invoke:electron:system-preferences:ask-for-media-access') + +export const systemPreferences = { + getMediaAccessStatus, + askForMediaAccess, +}