Initial commit

This commit is contained in:
Arne
2023-04-02 20:35:10 +02:00
parent 80ffb8b70c
commit 7611f10b1c
55 changed files with 1678 additions and 683 deletions

View File

@@ -0,0 +1,32 @@
/**
* This file will automatically be loaded by webpack and run in the "renderer" context.
* To learn more about the differences between the "main" and the "renderer" context in
* Electron, visit:
*
* https://electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes
*
* By default, Node.js integration in this file is disabled. When enabling Node.js integration
* in a renderer process, please be aware of potential security implications. You can read
* more about security risks here:
*
* https://electronjs.org/docs/tutorial/security
*
* To enable Node.js integration in this file, open up `main.js` and enable the `nodeIntegration`
* flag:
*
* ```
* // Create the browser window.
* mainWindow = new BrowserWindow({
* width: 800,
* height: 600,
* webPreferences: {
* nodeIntegration: true
* }
* });
* ```
*/
import './index.css';
console.log(
'👋 This message is being logged by "renderer.js", included via webpack'
);
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../workspaces/electron-app/renderer/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,aAAa,CAAC;AAErB,OAAO,CAAC,GAAG,CAAC,wEAAwE,CAAC,CAAC"}

View File

@@ -0,0 +1,53 @@
/*/ To secure user platform when running renderer process stuff,
// Node.JS and Electron APIs are only available in this script
import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron';
import { WindowApi, WindowApiConst } from 'shared-lib';
// So we expose protected methods that allow the renderer process
// to use the ipcRenderer without exposing the entire object
const windowApi: WindowApi = {
send: <In>(channel: string, input: In) => {
if (WindowApiConst.SENDING_SAFE_CHANNELS.includes(channel)) {
ipcRenderer.send(channel, input);
}
},
receive: <Out>(channel: string, callback: (output: Out) => void) => {
if (WindowApiConst.RECEIVING_SAFE_CHANNELS.includes(channel)) {
// Deliberately strip event as it includes `sender`
ipcRenderer.on(
channel,
(_event: IpcRendererEvent, ...parameters: any[]) =>
callback(parameters[0])
);
}
},
};
declare const window: Window;
if (process.env.X_NODE_ENV === 'e2e-test') {
// Injecting windowApi directly
window.api = windowApi;
} else {
// ContextBridge API can only be used when contextIsolation is enabled
// which is normally the case except in e2e test mode
contextBridge.exposeInMainWorld('api', windowApi);
}*/
import { contextBridge, ipcRenderer } from 'electron';
import { WindowApiConst } from 'shared-lib';
contextBridge.exposeInMainWorld('api', {
node: () => process.versions.node,
chrome: () => process.versions.chrome,
electron: () => process.versions.electron,
send: (channel, input) => {
if (WindowApiConst.SENDING_SAFE_CHANNELS.includes(channel)) {
ipcRenderer.send(channel, input);
}
},
receive: (channel, callback) => {
// Deliberately strip event as it includes `sender`
ipcRenderer.on(channel, (_event, ...parameters) => callback(parameters[0]));
},
// we can also expose variables, not just functions
});
console.log('The preload script has been injected successfully.');
//# sourceMappingURL=preload.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"preload.js","sourceRoot":"","sources":["../../../workspaces/electron-app/renderer/preload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAoB,MAAM,UAAU,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,aAAa,CAAC,iBAAiB,CAAC,KAAK,EAAE;IACtC,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACjC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACrC,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzC,IAAI,EAAE,CAAK,OAAe,EAAE,KAAS,EAAE,EAAE;QACxC,IAAI,cAAc,CAAC,qBAAqB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC3D,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;SACjC;IACF,CAAC;IACD,OAAO,EAAE,CAAM,OAAe,EAAE,QAA+B,EAAE,EAAE;QAClE,mDAAmD;QACnD,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,MAAwB,EAAE,GAAG,UAAiB,EAAE,EAAE,CAC1E,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CACvB,CAAC;IACH,CAAC;IACD,mDAAmD;CACnD,CAAC,CAAC;AAEH,OAAO,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAC"}