Files
5chan/electron/preload.mjs
T
Tommaso CasaburiandGitHub 56894700c1 feat(oekaki): add drawing flow for /i/ (#1144)
* feat(oekaki): add drawing flow for /i/

* fix(oekaki): address review feedback

* fix(oekaki): reset Tegaki edit sessions

* fix(oekaki): block drawing during export

* fix(oekaki): destroy Tegaki on preload errors

* fix(oekaki): preserve drawing on export failure

* fix(oekaki): unlock controls after export failure
2026-05-30 15:06:47 +07:00

34 lines
1.4 KiB
JavaScript

import { contextBridge, ipcRenderer, webUtils } from 'electron';
// dev uses http://localhost, prod uses file://...index.html
const isDev = window.location.protocol === 'http:';
const defaultPkcOptions = {
pkcRpcClientsOptions: ['ws://localhost:9138'],
httpRoutersOptions: ['https://peers.pleb.bot', 'https://routing.lol', 'https://peers.forumindex.com', 'https://peers.plebpubsub.xyz'],
};
contextBridge.exposeInMainWorld('isElectron', true);
contextBridge.exposeInMainWorld('defaultPkcOptions', defaultPkcOptions);
contextBridge.exposeInMainWorld('defaultMediaIpfsGatewayUrl', 'http://localhost:6473');
// receive PKC RPC auth key from main
ipcRenderer.on('pkc-rpc-auth-key', (event, pkcRpcAuthKey) => contextBridge.exposeInMainWorld('pkcRpcAuthKey', pkcRpcAuthKey));
ipcRenderer.send('get-pkc-rpc-auth-key');
contextBridge.exposeInMainWorld('electronApi', {
isElectron: true,
copyToClipboard: (text) => ipcRenderer.invoke('copy-to-clipboard', text),
getPlatform: () => ipcRenderer.invoke('get-platform'),
automateUploadMedia: (options) => ipcRenderer.invoke('automate-upload-media', options),
automateUploadGeneratedMedia: (options) => ipcRenderer.invoke('automate-upload-generated-media', options),
downloadAndInstallUpdate: (options) => ipcRenderer.invoke('download-and-install-update', options),
getPathForFile: (file) => {
try {
return webUtils.getPathForFile(file);
} catch {
return null;
}
},
});