2026-02-19 13:18:15 +08:00
|
|
|
import { contextBridge, ipcRenderer, webUtils } from 'electron';
|
2023-04-24 19:42:49 +00:00
|
|
|
|
|
|
|
|
// dev uses http://localhost, prod uses file://...index.html
|
2023-12-16 16:49:26 +00:00
|
|
|
const isDev = window.location.protocol === 'http:';
|
2023-04-24 19:42:49 +00:00
|
|
|
|
|
|
|
|
const defaultPlebbitOptions = {
|
2023-12-16 16:49:26 +00:00
|
|
|
plebbitRpcClientsOptions: ['ws://localhost:9138'],
|
2025-05-22 13:15:40 +02:00
|
|
|
httpRoutersOptions: ['https://peers.pleb.bot', 'https://routing.lol', 'https://peers.forumindex.com', 'https://peers.plebpubsub.xyz'],
|
2023-12-16 16:49:26 +00:00
|
|
|
};
|
2023-04-24 19:42:49 +00:00
|
|
|
|
2024-10-11 17:24:35 +02:00
|
|
|
contextBridge.exposeInMainWorld('isElectron', true);
|
2023-12-16 16:49:26 +00:00
|
|
|
contextBridge.exposeInMainWorld('defaultPlebbitOptions', defaultPlebbitOptions);
|
2024-06-20 15:35:28 +02:00
|
|
|
contextBridge.exposeInMainWorld('defaultMediaIpfsGatewayUrl', 'http://localhost:6473');
|
2023-04-24 19:42:49 +00:00
|
|
|
|
2024-06-20 15:35:28 +02:00
|
|
|
// receive plebbit rpc auth key from main
|
|
|
|
|
ipcRenderer.on('plebbit-rpc-auth-key', (event, plebbitRpcAuthKey) => contextBridge.exposeInMainWorld('plebbitRpcAuthKey', plebbitRpcAuthKey));
|
|
|
|
|
ipcRenderer.send('get-plebbit-rpc-auth-key');
|
2025-05-22 17:42:04 +02:00
|
|
|
|
2026-02-18 18:51:02 +08:00
|
|
|
contextBridge.exposeInMainWorld('electronApi', {
|
2025-06-03 22:11:17 +02:00
|
|
|
isElectron: true,
|
|
|
|
|
copyToClipboard: (text) => ipcRenderer.invoke('copy-to-clipboard', text),
|
|
|
|
|
getPlatform: () => ipcRenderer.invoke('get-platform'),
|
2026-02-18 18:51:02 +08:00
|
|
|
automateUploadMedia: (options) => ipcRenderer.invoke('automate-upload-media', options),
|
2026-02-19 13:18:15 +08:00
|
|
|
getPathForFile: (file) => {
|
|
|
|
|
try {
|
|
|
|
|
return webUtils.getPathForFile(file);
|
|
|
|
|
} catch {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
},
|
2026-02-18 18:51:02 +08:00
|
|
|
});
|