27 lines
787 B
TypeScript
27 lines
787 B
TypeScript
// All of the Node.js APIs are available in the preload process.
|
|
// It has the same sandbox as a Chrome extension.
|
|
import ipcRenderer from "electron";
|
|
|
|
process.once("loaded", () => {
|
|
window.addEventListener("message", event => {
|
|
// do something with custom event
|
|
const message = event.data;
|
|
|
|
if (message.myTypeField === "handle-audio-stream") {
|
|
ipcRenderer.send("audio-stream", message);
|
|
}
|
|
});
|
|
});
|
|
|
|
window.addEventListener("DOMContentLoaded", () => {
|
|
const replaceText = (selector: string, text: string) => {
|
|
const element = document.getElementById(selector);
|
|
if (element) {
|
|
element.innerText = text;
|
|
}
|
|
};
|
|
|
|
for (const type of ["chrome", "node", "electron"]) {
|
|
replaceText(`${type}-version`, (process.versions as any)[type]);
|
|
}
|
|
});
|