feat(share): outline multi platform share functionality

This commit is contained in:
Johannes Millan 2025-10-22 13:19:14 +02:00
parent 242bc25ac4
commit 9574dd4f19
14 changed files with 1568 additions and 59 deletions

View file

@ -70,6 +70,13 @@ export interface ElectronAPI {
data: string,
): Promise<{ success: boolean; path?: string }>;
shareNative(payload: {
text?: string;
url?: string;
title?: string;
files?: string[];
}): Promise<{ success: boolean; error?: string }>;
isLinux(): boolean;
isMacOS(): boolean;

View file

@ -79,6 +79,17 @@ export const initIpcInterfaces = (): void => {
return { success: false };
});
ipcMain.handle(IPC.SHARE_NATIVE, async (ev, payload) => {
// TODO: Implement native share for macOS (NSSharingService) and Windows (WinRT Share UI)
// For now, return false to fall back to web-based sharing
// Native implementation would require:
// - macOS: Swift/Objective-C bridge using NSSharingServicePicker
// - Windows: C#/C++ bridge using Windows.ApplicationModel.DataTransfer.DataTransferManager
// - Linux: No native share, always use fallback
log('Native share requested but not implemented, falling back to web share');
return { success: false, error: 'Native share not yet implemented' };
});
ipcMain.on(IPC.LOCK_SCREEN, () => {
if ((app as any).isLocked) {
return;

View file

@ -80,6 +80,16 @@ const ea: ElectronAPI = {
success: boolean;
path?: string;
}>,
shareNative: (payload: {
text?: string;
url?: string;
title?: string;
files?: string[];
}) =>
_invoke('SHARE_NATIVE', payload) as Promise<{
success: boolean;
error?: string;
}>,
scheduleRegisterBeforeClose: (id) => _send('REGISTER_BEFORE_CLOSE', { id }),
unscheduleRegisterBeforeClose: (id) => _send('UNREGISTER_BEFORE_CLOSE', { id }),
setDoneRegisterBeforeClose: (id) => _send('BEFORE_CLOSE_DONE', { id }),

View file

@ -63,6 +63,8 @@ export enum IPC {
SAVE_FILE_DIALOG = 'SAVE_FILE_DIALOG',
SHARE_NATIVE = 'SHARE_NATIVE',
// Plugin Node Execution
PLUGIN_EXEC_NODE_SCRIPT = 'PLUGIN_EXEC_NODE_SCRIPT',