summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-06-28 19:38:49 +0200
committerRaindropsSys <contact@minteck.org>2023-06-28 19:38:49 +0200
commit8f654c94413fb639018431e2ef666931c1b232b1 (patch)
tree69d9045db10172cf2cb3166a7e9b6f2efeeb1e52
parent08edb928a9a93dcc1e3a07fff4955770c2e05986 (diff)
downloadkirinos-8f654c94413fb639018431e2ef666931c1b232b1.tar.gz
kirinos-8f654c94413fb639018431e2ef666931c1b232b1.tar.bz2
kirinos-8f654c94413fb639018431e2ef666931c1b232b1.zip
Updated 8 files, added 33 files and renamed test.html (automated)
-rw-r--r--core/desktop/icons/devtools.svg1
-rw-r--r--core/desktop/index.html4
-rw-r--r--core/desktop/wm.js393
-rw-r--r--demo/lorem.html28
-rw-r--r--demo/test.html (renamed from test.html)0
-rw-r--r--docs/Debugging-mangoOS.md18
-rw-r--r--docs/Why-run-as-root.md11
-rw-r--r--init.sh2
-rw-r--r--main.js17
-rw-r--r--node_modules/.package-lock.json8
-rw-r--r--node_modules/@electron/remote/LICENSE20
-rw-r--r--node_modules/@electron/remote/README.md348
-rw-r--r--node_modules/@electron/remote/dist/src/common/get-electron-binding.d.ts1
-rw-r--r--node_modules/@electron/remote/dist/src/common/get-electron-binding.js15
-rw-r--r--node_modules/@electron/remote/dist/src/common/ipc-messages.d.ts18
-rw-r--r--node_modules/@electron/remote/dist/src/common/ipc-messages.js2
-rw-r--r--node_modules/@electron/remote/dist/src/common/module-names.d.ts2
-rw-r--r--node_modules/@electron/remote/dist/src/common/module-names.js53
-rw-r--r--node_modules/@electron/remote/dist/src/common/type-utils.d.ts4
-rw-r--r--node_modules/@electron/remote/dist/src/common/type-utils.js112
-rw-r--r--node_modules/@electron/remote/dist/src/main/index.d.ts1
-rw-r--r--node_modules/@electron/remote/dist/src/main/index.js6
-rw-r--r--node_modules/@electron/remote/dist/src/main/objects-registry.d.ts16
-rw-r--r--node_modules/@electron/remote/dist/src/main/objects-registry.js117
-rw-r--r--node_modules/@electron/remote/dist/src/main/server.d.ts4
-rw-r--r--node_modules/@electron/remote/dist/src/main/server.js498
-rw-r--r--node_modules/@electron/remote/dist/src/renderer/callbacks-registry.d.ts11
-rw-r--r--node_modules/@electron/remote/dist/src/renderer/callbacks-registry.js64
-rw-r--r--node_modules/@electron/remote/dist/src/renderer/index.d.ts1
-rw-r--r--node_modules/@electron/remote/dist/src/renderer/index.js15
-rw-r--r--node_modules/@electron/remote/dist/src/renderer/remote.d.ts6
-rw-r--r--node_modules/@electron/remote/dist/src/renderer/remote.js403
-rw-r--r--node_modules/@electron/remote/index.d.ts65
-rw-r--r--node_modules/@electron/remote/main/index.d.ts1
-rw-r--r--node_modules/@electron/remote/main/index.js1
-rw-r--r--node_modules/@electron/remote/package.json46
-rw-r--r--node_modules/@electron/remote/renderer/index.d.ts1
-rw-r--r--node_modules/@electron/remote/renderer/index.js1
-rw-r--r--out.html28
-rw-r--r--package-lock.json9
-rw-r--r--package.json1
-rw-r--r--setup/rc.xml13
42 files changed, 2241 insertions, 124 deletions
diff --git a/core/desktop/icons/devtools.svg b/core/desktop/icons/devtools.svg
new file mode 100644
index 0000000..bc28e35
--- /dev/null
+++ b/core/desktop/icons/devtools.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M320-242 80-482l242-242 43 43-199 199 197 197-43 43Zm318 2-43-43 199-199-197-197 43-43 240 240-242 242Z"/></svg> \ No newline at end of file
diff --git a/core/desktop/index.html b/core/desktop/index.html
index 6e72485..a57feb1 100644
--- a/core/desktop/index.html
+++ b/core/desktop/index.html
@@ -218,7 +218,9 @@
wm.createWindow({
title: "Test Window",
sandbox: false,
- url: "file:///mango/test.html"
+ debuggable: true,
+ isolatedPath: "/mango/demo",
+ url: "file:///mango/demo/test.html"
});
</script>
diff --git a/core/desktop/wm.js b/core/desktop/wm.js
index b9abb00..1281494 100644
--- a/core/desktop/wm.js
+++ b/core/desktop/wm.js
@@ -1,4 +1,6 @@
const uuid = require('uuid-v4');
+const { ipcRenderer } = require('electron');
+const path = require("path");
class WindowManager {
#stack;
@@ -136,18 +138,57 @@ class WindowManager {
set resizable(val) {
if (typeof val !== "boolean") return;
properties[id]["resizable"] = val;
+
+ if (val) {
+ document.getElementById("window-" + id + "-anchors").style.display = "none";
+ } else {
+ document.getElementById("window-" + id + "-anchors").style.display = "";
+ }
},
set closable(val) {
if (typeof val !== "boolean") return;
properties[id]["closable"] = val;
+
+
+ if (val) {
+ document.getElementById("window-" + id + "-titlebar-control-close").classList.add("window-titlebar-control-disabled");
+ } else {
+ document.getElementById("window-" + id + "-titlebar-control-close").classList.add("window-titlebar-control-disabled");
+ }
+ },
+ set debuggable(val) {
+ if (typeof val !== "boolean") return;
+ properties[id]["debuggable"] = val;
+
+ if (val) {
+ document.getElementById("window-" + id + "-titlebar-control-devtools").style.display = "none";
+ } else {
+ document.getElementById("window-" + id + "-titlebar-control-devtools").style.display = "inline-block";
+ }
},
set maximizable(val) {
if (typeof val !== "boolean") return;
properties[id]["maximizable"] = val;
+
+ if (val) {
+ document.getElementById("window-" + id + "-titlebar-control-maximise").classList.add("window-titlebar-control-disabled");
+ } else {
+ document.getElementById("window-" + id + "-titlebar-control-maximise").classList.add("window-titlebar-control-disabled");
+
+ wm.restoreWindow(id);
+ }
},
set minimizable(val) {
if (typeof val !== "boolean") return;
properties[id]["minimizable"] = val;
+
+ if (val) {
+ document.getElementById("window-" + id + "-titlebar-control-minimise").classList.add("window-titlebar-control-disabled");
+ } else {
+ document.getElementById("window-" + id + "-titlebar-control-minimise").classList.add("window-titlebar-control-disabled");
+
+ wm.unminimiseWindow(id);
+ }
},
set minimised(val) {
if (typeof val !== "boolean") return;
@@ -171,35 +212,38 @@ class WindowManager {
}
createWindow(options) {
- let id = uuid();
-
- this.#properties[id] = {
- title: options['title'] ?? "(none)",
- minWidth: options['minWidth'] ?? 64,
- minHeight: options['minHeight'] ?? 64,
- maxWidth: options['maxWidth'] ?? Infinity,
- maxHeight: options['maxHeight'] ?? Infinity,
- width: options['width'] ?? 256,
- height: options['height'] ?? 256,
- x: options['x'] ?? 0,
- y: options['y'] ?? 0,
- centered: options['centered'] ?? true,
- movable: options['movable'] ?? true,
- closable: options['closable'] ?? true,
- maximizable: options['maximizable'] ?? true,
- minimizable: options['minimizable'] ?? true,
- focused: options['focused'] ?? true,
- resizable: options['resizable'] ?? true,
- minimised: options['minimised'] ?? false,
- maximised: options['maximised'] ?? false
- }
+ return new Promise((res, rej) => {
+ let id = uuid();
+
+ this.#properties[id] = {
+ title: options['title'] ?? "(none)",
+ isolatedPath: options['isolatedPath'] ?? "",
+ minWidth: options['minWidth'] ?? 64,
+ minHeight: options['minHeight'] ?? 64,
+ maxWidth: options['maxWidth'] ?? Infinity,
+ maxHeight: options['maxHeight'] ?? Infinity,
+ width: options['width'] ?? 256,
+ height: options['height'] ?? 256,
+ x: options['x'] ?? 0,
+ y: options['y'] ?? 0,
+ centered: options['centered'] ?? true,
+ movable: options['movable'] ?? true,
+ closable: options['closable'] ?? true,
+ maximizable: options['maximizable'] ?? true,
+ minimizable: options['minimizable'] ?? true,
+ debuggable: options['debuggable'] ?? false,
+ focused: options['focused'] ?? true,
+ resizable: options['resizable'] ?? true,
+ minimised: options['minimised'] ?? false,
+ maximised: options['maximised'] ?? false
+ }
- if (this.#properties[id].centered) {
- this.#properties[id]['x'] = window.innerWidth / 2 - this.#properties[id]['width'] / 2;
- this.#properties[id]['y'] = window.innerHeight / 2 - this.#properties[id]['height'] / 2;
- }
+ if (this.#properties[id].centered) {
+ this.#properties[id]['x'] = window.innerWidth / 2 - this.#properties[id]['width'] / 2;
+ this.#properties[id]['y'] = window.innerHeight / 2 - this.#properties[id]['height'] / 2;
+ }
- document.getElementById("window-container").insertAdjacentHTML("beforeend", `
+ document.getElementById("window-container").insertAdjacentHTML("beforeend", `
<div onmousedown="wm.focusWindow('${id}');" class="window" id="window-${id}" style="width: ${this.#properties[id]['width']}px; height: ${this.#properties[id]['height']}px; top: ${this.#properties[id]['y']}px; left: ${this.#properties[id]['x']}px;">
<div class="window-titlebar" id="window-${id}-titlebar">
<div class="window-titlebar-controls" id="window-${id}-titlebar-controls">
@@ -209,15 +253,17 @@ class WindowManager {
<img src="./icons/minimise.svg" style="width: 24px; vertical-align: middle;">
</a><a onclick="wm.toggleMaximisedWindow('${id}');" class="window-titlebar-control window-titlebar-control-maximise ${!this.#properties[id]['minimizable'] ? "window-titlebar-control-disabled" : ""}" id="window-${id}-titlebar-control-maximise" style="padding: 4px; vertical-align: middle; width: 24px; height: 24px; display: inline-block;">
<img src="./icons/maximise.svg" style="width: 24px; vertical-align: middle;">
- </a>
+ </a>${this.#properties[id]['debuggable'] ? `<a onclick="wm.toggleDevTools('${id}');" class="window-titlebar-control window-titlebar-control-devtools" id="window-${id}-titlebar-control-devtools" style="padding: 4px; vertical-align: middle; width: 24px; height: 24px; display: inline-block;">
+ <img src="./icons/devtools.svg" style="width: 24px; vertical-align: middle;">
+ </a>` : ``}
</div>
<div class="window-titlebar-title" id="window-${id}-titlebar-title" style="white-space: nowrap;overflow: hidden !important;text-overflow: ellipsis;">${this.#properties[id]['title']}</div>
</div>
<div class="window-contents" id="window-${id}-contents" style="height: calc(100% - 33px);">
- <webview id="window-${id}-contents-webview" class="window-contents-webview" style="display: flex; height: 100%; width: 100%;" src="${options['url']}" preload="file:///mango/lib/mangokit/index.js" ${options['sandbox'] === false ? "nodeintegration" : ""}></webview>
+ <webview partition="${id}" id="window-${id}-contents-webview" class="window-contents-webview" style="display: flex; height: 100%; width: 100%;" src="${options['url']}" preload="file:///mango/lib/mangokit/index.js" ${options['sandbox'] === false ? "nodeintegration" : ""}></webview>
</div>
${this.#properties[id]['resizable'] ? `
- <div class="window-anchors">
+ <div class="window-anchors" id="window-${id}-anchors">
<div class="window-anchor window-anchor-top-left"></div>
<div class="window-anchor window-anchor-top-right"></div>
<div class="window-anchor window-anchor-bottom-left"></div>
@@ -227,96 +273,202 @@ class WindowManager {
</div>
`);
- let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
-
- document.getElementById("window-" + id + "-titlebar-title").onmousedown = (e) => {
- document.querySelector('#window-' + id + ' .window-contents-webview').style.pointerEvents = "none";
-
- e.preventDefault();
- pos3 = e.clientX;
- pos4 = e.clientY;
-
- document.onmouseup = () => {
- document.onmouseup = null;
- document.onmousemove = null;
- document.querySelector('#window-' + id + ' .window-contents-webview').style.pointerEvents = "";
- }
-
- document.onmousemove = (e) => {
- e.preventDefault();
- pos1 = pos3 - e.clientX;
- pos2 = pos4 - e.clientY;
- pos3 = e.clientX;
- pos4 = e.clientY;
-
- this.moveWindow(id, document.getElementById("window-" + id).offsetLeft - pos1, document.getElementById("window-" + id).offsetTop - pos2);
- }
- }
-
- if (this.#properties[id].resizable) {
- const resizers = document.querySelectorAll('#window-' + id + ' .window-anchor');
- const element = document.getElementById("window-" + id);
-
- const minimum_size_x = this.#properties[id].minWidth;
- const minimum_size_y = this.#properties[id].minHeight;
- let original_width = 0;
- let original_height = 0;
- let original_x = 0;
- let original_y = 0;
- let original_mouse_x = 0;
- let original_mouse_y = 0;
-
- for (let i = 0;i < resizers.length; i++) {
- const currentResizer = resizers[i];
- currentResizer.addEventListener('mousedown', function(e) {
- document.querySelector('#window-' + id + ' .window-contents-webview').style.pointerEvents = "none";
-
- e.preventDefault()
- original_width = parseFloat(getComputedStyle(element, null).getPropertyValue('width').replace('px', ''));
- original_height = parseFloat(getComputedStyle(element, null).getPropertyValue('height').replace('px', ''));
- original_x = element.getBoundingClientRect().left;
- original_y = element.getBoundingClientRect().top;
- original_mouse_x = e.pageX;
- original_mouse_y = e.pageY;
- window.addEventListener('mousemove', resize)
- window.addEventListener('mouseup', stopResize)
- })
-
- function resize(e) {
- if (currentResizer.classList.contains('window-anchor-bottom-right')) {
- const width = original_width + (e.pageX - original_mouse_x);
- const height = original_height + (e.pageY - original_mouse_y)
-
- wm.resizeWindow(id, width, height, null, null);
- } else if (currentResizer.classList.contains('window-anchor-bottom-left')) {
- const height = original_height + (e.pageY - original_mouse_y)
- const width = original_width - (e.pageX - original_mouse_x)
-
- wm.resizeWindow(id, width, height, original_x + (e.pageX - original_mouse_x), null);
- } else if (currentResizer.classList.contains('window-anchor-top-right')) {
- const width = original_width + (e.pageX - original_mouse_x)
- const height = original_height - (e.pageY - original_mouse_y)
-
- wm.resizeWindow(id, width, height, null, original_y + (e.pageY - original_mouse_y));
- } else {
- const width = original_width - (e.pageX - original_mouse_x)
- const height = original_height - (e.pageY - original_mouse_y)
-
- wm.resizeWindow(id, width, height, original_x + (e.pageX - original_mouse_x), original_y + (e.pageY - original_mouse_y));
+ let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
+
+ function proceed(i) {
+ let c = setInterval(() => {
+ if (document.getElementById("window-" + id + "-contents-webview").getWebContentsId) {
+ clearInterval(c);
+ let webContents = i.#properties[id].webContents = require("@electron/remote").webContents.fromId(document.getElementById("window-" + id + "-contents-webview").getWebContentsId());
+
+ let isolatedPath = i.#properties[id].isolatedPath;
+
+ webContents.session.on('will-download', (event, item, webContents) => {
+ item.cancel()
+ });
+
+ webContents.setWindowOpenHandler((details) => {
+ return {
+ action: 'deny'
+ };
+ });
+
+ webContents.on('devtools-opened', () => {
+ webContents.devToolsWebContents.focus();
+ });
+
+ webContents.session.webRequest.onBeforeRequest({
+ urls: [
+ "file://*/*",
+ "http://*/*",
+ "https://*/*",
+ "ws://*/*",
+ "wss://*/*"
+ ]
+ }, (details, cb) => {
+ if (details.url.startsWith("file://") && !details.url.startsWith("file://" + isolatedPath + "/")) {
+ console.error("Prevented " + id + " from accessing " + details.url + ", application is limited to files within file://" + isolatedPath + "/");
+
+ cb({
+ cancel: true
+ });
+ } else if (details.url.startsWith("file:///app/")) {
+ if (path.resolve(isolatedPath + details.url.substring(11)).startsWith(isolatedPath + "/")) {
+ console.info("Serving " + id + " with " + details.url);
+
+ cb({
+ redirectURL: "file://" + isolatedPath + details.url.substring(6)
+ });
+ } else {
+ console.error("Prevented " + id + " from accessing " + details.url + ", application is limited to files within file://" + isolatedPath + "/");
+
+ cb({
+ cancel: true
+ });
+ }
+ } else if (details.url.startsWith("file://" + isolatedPath + "/")) {
+ if (path.resolve(isolatedPath + details.url.substring(7)).startsWith(isolatedPath + "/")) {
+ console.info("Serving " + id + " with " + details.url);
+
+ cb({
+ cancel: false
+ });
+ } else {
+ console.error("Prevented " + id + " from accessing " + details.url + ", application is limited to files within file://" + isolatedPath + "/");
+
+ cb({
+ cancel: true
+ });
+ }
+ } else if (details.url.startsWith("app://")) {
+ if (path.resolve(isolatedPath + details.url.substring(6)).startsWith(isolatedPath + "/")) {
+ console.error("Serving " + id + " with " + details.url);
+
+ cb({
+ redirectURL: "file://" + isolatedPath + details.url.substring(6)
+ });
+ } else {
+ console.error("Prevented " + id + " from accessing " + details.url);
+
+ cb({
+ cancel: true
+ });
+ }
+ } else if (details.url.startsWith("http://") || details.url.startsWith("https://") || details.url.startsWith("ws://") || details.url.startsWith("wss://")) {
+ console.error("Prevented " + id + " from accessing " + details.url + ", application does not have internet access");
+
+ cb({
+ cancel: true
+ });
+ } else {
+ console.error("Prevented " + id + " from accessing " + details.url + ", unknown request");
+
+ cb({
+ cancel: true
+ });
+ }
+ });
+
+ document.getElementById("window-" + id + "-titlebar-title").onmousedown = (e) => {
+ document.querySelector('#window-' + id + ' .window-contents-webview').style.pointerEvents = "none";
+
+ e.preventDefault();
+ pos3 = e.clientX;
+ pos4 = e.clientY;
+
+ document.onmouseup = () => {
+ document.onmouseup = null;
+ document.onmousemove = null;
+ document.querySelector('#window-' + id + ' .window-contents-webview').style.pointerEvents = "";
+ }
+
+ document.onmousemove = (e) => {
+ e.preventDefault();
+ pos1 = pos3 - e.clientX;
+ pos2 = pos4 - e.clientY;
+ pos3 = e.clientX;
+ pos4 = e.clientY;
+
+ i.moveWindow(id, document.getElementById("window-" + id).offsetLeft - pos1, document.getElementById("window-" + id).offsetTop - pos2);
+ }
+ }
+
+ if (i.#properties[id].resizable) {
+ const resizers = document.querySelectorAll('#window-' + id + ' .window-anchor');
+ const element = document.getElementById("window-" + id);
+
+ const minimum_size_x = i.#properties[id].minWidth;
+ const minimum_size_y = i.#properties[id].minHeight;
+ let original_width = 0;
+ let original_height = 0;
+ let original_x = 0;
+ let original_y = 0;
+ let original_mouse_x = 0;
+ let original_mouse_y = 0;
+
+ for (let i = 0; i < resizers.length; i++) {
+ const currentResizer = resizers[i];
+ currentResizer.addEventListener('mousedown', function (e) {
+ document.querySelector('#window-' + id + ' .window-contents-webview').style.pointerEvents = "none";
+
+ e.preventDefault()
+ original_width = parseFloat(getComputedStyle(element, null).getPropertyValue('width').replace('px', ''));
+ original_height = parseFloat(getComputedStyle(element, null).getPropertyValue('height').replace('px', ''));
+ original_x = element.getBoundingClientRect().left;
+ original_y = element.getBoundingClientRect().top;
+ original_mouse_x = e.pageX;
+ original_mouse_y = e.pageY;
+ window.addEventListener('mousemove', resize)
+ window.addEventListener('mouseup', stopResize)
+ })
+
+ function resize(e) {
+ if (currentResizer.classList.contains('window-anchor-bottom-right')) {
+ const width = original_width + (e.pageX - original_mouse_x);
+ const height = original_height + (e.pageY - original_mouse_y)
+
+ wm.resizeWindow(id, width, height, null, null);
+ } else if (currentResizer.classList.contains('window-anchor-bottom-left')) {
+ const height = original_height + (e.pageY - original_mouse_y)
+ const width = original_width - (e.pageX - original_mouse_x)
+
+ wm.resizeWindow(id, width, height, original_x + (e.pageX - original_mouse_x), null);
+ } else if (currentResizer.classList.contains('window-anchor-top-right')) {
+ const width = original_width + (e.pageX - original_mouse_x)
+ const height = original_height - (e.pageY - original_mouse_y)
+
+ wm.resizeWindow(id, width, height, null, original_y + (e.pageY - original_mouse_y));
+ } else {
+ const width = original_width - (e.pageX - original_mouse_x)
+ const height = original_height - (e.pageY - original_mouse_y)
+
+ wm.resizeWindow(id, width, height, original_x + (e.pageX - original_mouse_x), original_y + (e.pageY - original_mouse_y));
+ }
+ }
+
+ function stopResize() {
+ document.querySelector('#window-' + id + ' .window-contents-webview').style.pointerEvents = "";
+ window.removeEventListener('mousemove', resize)
+ }
+ }
+ }
+
+ i.#stack.unshift(id);
+ i.#list.push(id);
+
+ i.#updateFocus();
}
- }
+ });
- function stopResize() {
- document.querySelector('#window-' + id + ' .window-contents-webview').style.pointerEvents = "";
- window.removeEventListener('mousemove', resize)
- }
+ document.getElementById("window-" + id + "-contents-webview").removeEventListener('dom-ready', () => {
+ proceed(this);
+ });
}
- }
- this.#stack.unshift(id);
- this.#list.push(id);
-
- this.#updateFocus();
+ document.getElementById("window-" + id + "-contents-webview").addEventListener('dom-ready', () => {
+ proceed(this);
+ });
+ });
}
moveWindow(id, x, y) {
@@ -337,8 +489,6 @@ class WindowManager {
}
resizeWindow(id, width, height, x, y) {
- console.log(id, width, height, x, y);
-
if (width > this.#properties[id].minWidth && width > 96 && ((this.#properties[id].maxWidth > 0 && width < this.#properties[id].maxWidth) || this.#properties[id].maxWidth < 0) && width < window.innerWidth) {
this.#properties[id].width = width;
document.getElementById("window-" + id).style.width = width + 'px';
@@ -400,6 +550,13 @@ class WindowManager {
// TODO: Broadcast a minimise event to the client
}
+ toggleDevTools(id) {
+ if (!this.#properties[id].webContents) return;
+ document.getElementById("window-" + id + "-contents-webview").closeDevTools();
+ document.getElementById("window-" + id + "-contents-webview").openDevTools();
+ ipcRenderer.send("blur");
+ }
+
focusWindow(id) {
if (!document.getElementById("window-" + id).classList.contains("window-inactive")) return;
delete this.#stack[this.#stack.indexOf(id)];
diff --git a/demo/lorem.html b/demo/lorem.html
new file mode 100644
index 0000000..d87dad4
--- /dev/null
+++ b/demo/lorem.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <title>test</title>
+</head>
+<body>
+ <h1>Test app (again)</h1>
+ <p>Hello, I am the other page of a test application</p>
+ <h2>Scroll me</h2>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+</body>
+</html> \ No newline at end of file
diff --git a/test.html b/demo/test.html
index f8b9504..f8b9504 100644
--- a/test.html
+++ b/demo/test.html
diff --git a/docs/Debugging-mangoOS.md b/docs/Debugging-mangoOS.md
new file mode 100644
index 0000000..1f46f85
--- /dev/null
+++ b/docs/Debugging-mangoOS.md
@@ -0,0 +1,18 @@
+# Debugging mangoOS
+
+mangoOS runs on Electron, which is a framework to use Web technologies to build native applications. mangoOS has little to no debugging infrastructure other than what Electron provides.
+
+## Debugging the OS itself
+
+> **IMPORTANT SECURITY NOTICE:** These options are for debugging and debugging **ONLY**. If anyone, even a mangoOS developer, asks you to enter code in Chrome Dev Tools, make sure you **ABSOLUTELY** know what this code does before executing it.
+
+The following keyboard shortcuts are available to debug mangoOS:
+* `Ctrl+Alt+Tab`: cycle through the open Chrome Dev Tools windows
+ * Note: `Alt+Tab` alone is used to cycle through mangoOS windows
+* `Ctrl+Shift+I`: open Chrome Dev Tools for the main mangoOS window
+* `Ctrl+R`: reload the main mangoOS window
+* `Ctrl+Q`: exit mangoOS and open a `root` terminal
+
+## Debugging applications
+
+mangoOS comes with options to debug your applications. You can set the `debuggable` option in your application's metadata to add a debugging option to the title bar that, when clicked, opens Chrome Dev Tools for this application. \ No newline at end of file
diff --git a/docs/Why-run-as-root.md b/docs/Why-run-as-root.md
new file mode 100644
index 0000000..f717428
--- /dev/null
+++ b/docs/Why-run-as-root.md
@@ -0,0 +1,11 @@
+# Why run as `root`?
+
+The mangoOS system software runs as `root` on the underlying Linux system. While you might argue this is insecure and puts users at an unnecessary risk, using the `root` user is perfectly justified.
+
+1. All the applications running on mangoOS are running in a sandbox, except for a few system applications (e.g. System Settings). This means they don't have access to the underlying system at all; they don't even have access to core mangoOS components. As long as the sandbox used in Chromium is not compromised, the OS remains secure.
+
+2. Using another user would be as insecure, because privilege elevation would be required for some system components to run (e.g. `libmangoaudio`). While we could have a special program that can run only a few specific commands; or only use `sudo`, this would be inconvenient and make programming with mangoOS more difficult.
+
+3. Not running as `root` will break some system extensions. System extensions expect to have full system access, so that they can, for example, provide a file system driver. Using a system such as the one mentioned in #2 would mean system modifications are required when installing system extensions, effectively reducing some of their "extension" sense.
+
+In a future version, we might implement a better solution that makes use of another user, although this is yet to be done. Until then, do not worry about the security of mangoOS as long as you make sure to install updates as they are made available. \ No newline at end of file
diff --git a/init.sh b/init.sh
index 52ccc16..c258294 100644
--- a/init.sh
+++ b/init.sh
@@ -4,5 +4,5 @@ chmod -R +x *
xset -dpms
xset s off
openbox&
-./node_modules/electron/dist/electron --no-sandbox main.js
+./node_modules/electron/dist/electron --no-sandbox main.js > mango.log
xterm \ No newline at end of file
diff --git a/main.js b/main.js
index a307dae..551e9bc 100644
--- a/main.js
+++ b/main.js
@@ -1,6 +1,8 @@
const { app, BrowserWindow, globalShortcut, ipcMain } = require('electron');
const path = require('path');
+require('@electron/remote/main').initialize();
+
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
const createWindow = () => {
@@ -8,16 +10,25 @@ const createWindow = () => {
backgroundColor: "#ed9464",
frame: false,
show: false,
- fullscreen: true,
- fullscreenable: true,
+ fullscreen: false,
+ maximizable: true,
+ fullscreenable: false,
webPreferences: {
webviewTag: true,
nodeIntegration: true,
- contextIsolation: false
+ contextIsolation: false,
+ enableRemoteModule: true
}
});
+ mainWindow.maximize();
+
+ ipcMain.on('blur', () => {
+ mainWindow.blur();
+ });
+
mainWindow.loadFile('./core/startup/index.html');
+ require("@electron/remote/main").enable(mainWindow.webContents);
mainWindow.on('ready-to-show', () => {
mainWindow.show();
diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json
index c1c86f5..b66a7af 100644
--- a/node_modules/.package-lock.json
+++ b/node_modules/.package-lock.json
@@ -23,6 +23,14 @@
"global-agent": "^3.0.0"
}
},
+ "node_modules/@electron/remote": {
+ "version": "2.0.10",
+ "resolved": "https://registry.npmjs.org/@electron/remote/-/remote-2.0.10.tgz",
+ "integrity": "sha512-3SFKKaQXcyWgwmibud+UqJl/XlHOgLcI3fwtB9pNelPSJAcTxocOJrF6FaxBIQaj1+R05Di6xuAswZpXAW7xhA==",
+ "peerDependencies": {
+ "electron": ">= 13.0.0"
+ }
+ },
"node_modules/@sindresorhus/is": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz",
diff --git a/node_modules/@electron/remote/LICENSE b/node_modules/@electron/remote/LICENSE
new file mode 100644
index 0000000..6e6d65e
--- /dev/null
+++ b/node_modules/@electron/remote/LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2019-2022 Electron contributors
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/@electron/remote/README.md b/node_modules/@electron/remote/README.md
new file mode 100644
index 0000000..1ac6be3
--- /dev/null
+++ b/node_modules/@electron/remote/README.md
@@ -0,0 +1,348 @@
+# @electron/remote
+
+[![CircleCI build status](https://circleci.com/gh/electron/remote/tree/main.svg?style=shield)](https://circleci.com/gh/electron/remote/tree/main)
+[![npm version](http://img.shields.io/npm/v/@electron/remote.svg)](https://npmjs.org/package/@electron/remote)
+
+`@electron/remote` is an [Electron](https://electronjs.org) module that bridges
+JavaScript objects from the main process to the renderer process. This lets you
+access main-process-only objects as if they were available in the renderer
+process.
+
+> ⚠️ **Warning!** This module has [many subtle
+> pitfalls][remote-considered-harmful]. There is almost always a better way to
+> accomplish your task than using this module. For example, [`ipcRenderer.invoke`](https://www.electronjs.org/docs/latest/api/ipc-renderer#ipcrendererinvokechannel-args) can serve many common use cases.
+
+`@electron/remote` is a replacement for the built-in `remote` module in
+Electron, which is deprecated and will eventually be removed.
+
+## Migrating from `remote`
+
+> **NOTE:** `@electron/remote` requires Electron 10 or higher.
+
+There are three things you need to do to migrate from the built-in `remote`
+module to `@electron/remote`.
+
+First, you need to install it from NPM:
+
+```shell
+$ npm install --save @electron/remote
+```
+
+Second, `@electron/remote/main` must be initialized in the main
+process before it can be used from the renderer:
+
+```javascript
+// in the main process:
+require('@electron/remote/main').initialize()
+```
+
+Third, `require('electron').remote` in the renderer process must be
+replaced with `require('@electron/remote')`.
+
+```javascript
+// in the renderer process:
+
+// Before
+const { BrowserWindow } = require('electron').remote
+
+// After
+const { BrowserWindow } = require('@electron/remote')
+```
+
+**Note:** Since this is requiring a module through npm rather than a built-in
+module, if you're using `remote` from a sandboxed process, you'll need to
+configure your bundler appropriately to package the code of `@electron/remote`
+in the preload script. Of course, [using `@electron/remote` makes the sandbox
+much less effective][remote-considered-harmful].
+
+**Note:** In `electron >= 14.0.0`, you must use the new `enable` API to enable the remote module for each desired `WebContents` separately: `require("@electron/remote/main").enable(webContents)`.
+
+In `electron < 14.0.0`, `@electron/remote` respects the `enableRemoteModule` WebPreferences
+value. You must pass `{ webPreferences: { enableRemoteModule: true } }` to
+the constructor of `BrowserWindow`s that should be granted permission to use
+`@electron/remote`.
+
+# API Reference
+
+The `remote` module provides a simple way to do inter-process communication
+(IPC) between the renderer process (web page) and the main process.
+
+In Electron, GUI-related modules (such as `dialog`, `menu` etc.) are only
+available in the main process, not in the renderer process. In order to use them
+from the renderer process, the `ipc` module is necessary to send inter-process
+messages to the main process. With the `remote` module, you can invoke methods
+of the main process object without explicitly sending inter-process messages,
+similar to Java's [RMI][rmi]. An example of creating a browser window from a
+renderer process:
+
+```javascript
+const { BrowserWindow } = require('@electron/remote')
+let win = new BrowserWindow({ width: 800, height: 600 })
+win.loadURL('https://github.com')
+```
+
+In order for this to work, you first need to initialize the main-process side
+of the remote module:
+
+```javascript
+// in the main process:
+require('@electron/remote/main').initialize()
+```
+
+**Note:** In `electron >= 14.0.0` the remote module is disabled by default for any `WebContents` instance and is only enabled for specified `WebContents` after explicitly calling `require("@electron/remote/main").enable(webContents)`.
+
+In `electron < 14.0.0` the remote module can be disabled for security reasons in the following contexts:
+- [`BrowserWindow`](https://www.electronjs.org/docs/latest/api/browser-window) - by setting the `enableRemoteModule` option to `false`.
+- [`<webview>`](https://www.electronjs.org/docs/latest/api/webview-tag) - by setting the `enableremotemodule` attribute to `false`.
+
+## Remote Objects
+
+Each object (including functions) returned by the `remote` module represents an
+object in the main process (we call it a remote object or remote function).
+When you invoke methods of a remote object, call a remote function, or create
+a new object with the remote constructor (function), you are actually sending
+synchronous inter-process messages.
+
+In the example above, both `BrowserWindow` and `win` were remote objects and
+`new BrowserWindow` didn't create a `BrowserWindow` object in the renderer
+process. Instead, it created a `BrowserWindow` object in the main process and
+returned the corresponding remote object in the renderer process, namely the
+`win` object.
+
+**Note:** Only [enumerable properties][enumerable-properties] which are present
+when the remote object is first referenced are accessible via remote.
+
+**Note:** Arrays and Buffers are copied over IPC when accessed via the `remote`
+module. Modifying them in the renderer process does not modify them in the main
+process and vice versa.
+
+## Lifetime of Remote Objects
+
+Electron makes sure that as long as the remote object in the renderer process
+lives (in other words, has not been garbage collected), the corresponding object
+in the main process will not be released. When the remote object has been
+garbage collected, the corresponding object in the main process will be
+dereferenced.
+
+If the remote object is leaked in the renderer process (e.g. stored in a map but
+never freed), the corresponding object in the main process will also be leaked,
+so you should be very careful not to leak remote objects.
+
+Primary value types like strings and numbers, however, are sent by copy.
+
+## Passing callbacks to the main process
+
+Code in the main process can accept callbacks from the renderer - for instance
+the `remote` module - but you should be extremely careful when using this
+feature.
+
+First, in order to avoid deadlocks, the callbacks passed to the main process
+are called asynchronously. You should not expect the main process to
+get the return value of the passed callbacks.
+
+For instance you can't use a function from the renderer process in an
+`Array.map` called in the main process:
+
+```javascript
+// main process mapNumbers.js
+exports.withRendererCallback = (mapper) => {
+ return [1, 2, 3].map(mapper)
+}
+
+exports.withLocalCallback = () => {
+ return [1, 2, 3].map(x => x + 1)
+}
+```
+
+```javascript
+// renderer process
+const mapNumbers = require('@electron/remote').require('./mapNumbers')
+const withRendererCb = mapNumbers.withRendererCallback(x => x + 1)
+const withLocalCb = mapNumbers.withLocalCallback()
+
+console.log(withRendererCb, withLocalCb)
+// [undefined, undefined, undefined], [2, 3, 4]
+```
+
+As you can see, the renderer callback's synchronous return value was not as
+expected, and didn't match the return value of an identical callback that lives
+in the main process.
+
+Second, the callbacks passed to the main process will persist until the
+main process garbage-collects them.
+
+For example, the following code seems innocent at first glance. It installs a
+callback for the `close` event on a remote object:
+
+```javascript
+require('@electron/remote').getCurrentWindow().on('close', () => {
+ // window was closed...
+})
+```
+
+But remember the callback is referenced by the main process until you
+explicitly uninstall it. If you do not, each time you reload your window the
+callback will be installed again, leaking one callback for each restart.
+
+To make things worse, since the context of previously installed callbacks has
+been released, exceptions will be raised in the main process when the `close`
+event is emitted.
+
+To avoid this problem, ensure you clean up any references to renderer callbacks
+passed to the main process. This involves cleaning up event handlers, or
+ensuring the main process is explicitly told to dereference callbacks that came
+from a renderer process that is exiting.
+
+## Accessing built-in modules in the main process
+
+The built-in modules in the main process are added as getters in the `remote`
+module, so you can use them directly like the `electron` module.
+
+```javascript
+const app = require('@electron/remote').app
+console.log(app)
+```
+
+## Methods
+
+The `remote` module has the following methods:
+
+### `remote.require(module)`
+
+* `module` String
+
+Returns `any` - The object returned by `require(module)` in the main process.
+Modules specified by their relative path will resolve relative to the entrypoint
+of the main process.
+
+e.g.
+
+```sh
+project/
+├── main
+│ ├── foo.js
+│ └── index.js
+├── package.json
+└── renderer
+ └── index.js
+```
+
+```js
+// main process: main/index.js
+const { app } = require('@electron/remote')
+app.whenReady().then(() => { /* ... */ })
+```
+
+```js
+// some relative module: main/foo.js
+module.exports = 'bar'
+```
+
+```js
+// renderer process: renderer/index.js
+const foo = require('@electron/remote').require('./foo') // bar
+```
+
+### `remote.getCurrentWindow()`
+
+Returns `BrowserWindow` - The window to which this web page belongs.
+
+**Note:** Do not use `removeAllListeners` on `BrowserWindow`. Use of this can
+remove all [`blur`](https://developer.mozilla.org/en-US/docs/Web/Events/blur)
+listeners, disable click events on touch bar buttons, and other unintended
+consequences.
+
+### `remote.getCurrentWebContents()`
+
+Returns `WebContents` - The web contents of this web page.
+
+### `remote.getGlobal(name)`
+
+* `name` String
+
+Returns `any` - The global variable of `name` (e.g. `global[name]`) in the main
+process.
+
+## Properties
+
+### `remote.process` _Readonly_
+
+A `NodeJS.Process` object. The `process` object in the main process. This is the same as
+`remote.getGlobal('process')` but is cached.
+
+# Overriding exposed objects
+
+Without filtering, `@electron/remote` will provide access to any JavaScript
+object that any renderer requests. In order to control what can be accessed,
+`@electron/remote` provides an opportunity to the app to return a custom result
+for any of `getGlobal`, `require`, `getCurrentWindow`, `getCurrentWebContents`,
+or any of the builtin module properties.
+
+The following events will be emitted first on the `app` Electron module, and
+then on the specific `WebContents` which requested the object. When emitted on
+the `app` module, the first parameter after the `Event` object will be the
+`WebContents` which originated the request. If any handler calls
+`preventDefault`, the request will be denied. If a `returnValue` parameter is
+set on the result, then that value will be returned to the renderer instead of
+the default.
+
+## Events
+
+### Event: 'remote-require'
+
+Returns:
+
+* `event` Event
+* `moduleName` String
+
+Emitted when `remote.require()` is called in the renderer process of `webContents`.
+Calling `event.preventDefault()` will prevent the module from being returned.
+Custom value can be returned by setting `event.returnValue`.
+
+### Event: 'remote-get-global'
+
+Returns:
+
+* `event` Event
+* `globalName` String
+
+Emitted when `remote.getGlobal()` is called in the renderer process of `webContents`.
+Calling `event.preventDefault()` will prevent the global from being returned.
+Custom value can be returned by setting `event.returnValue`.
+
+### Event: 'remote-get-builtin'
+
+Returns:
+
+* `event` Event
+* `moduleName` String
+
+Emitted when `remote.getBuiltin()` is called in the renderer process of
+`webContents`, including when a builtin module is accessed as a property (e.g.
+`require("@electron/remote").BrowserWindow`).
+Calling `event.preventDefault()` will prevent the module from being returned.
+Custom value can be returned by setting `event.returnValue`.
+
+### Event: 'remote-get-current-window'
+
+Returns:
+
+* `event` Event
+
+Emitted when `remote.getCurrentWindow()` is called in the renderer process of `webContents`.
+Calling `event.preventDefault()` will prevent the object from being returned.
+Custom value can be returned by setting `event.returnValue`.
+
+### Event: 'remote-get-current-web-contents'
+
+Returns:
+
+* `event` Event
+
+Emitted when `remote.getCurrentWebContents()` is called in the renderer process of `webContents`.
+Calling `event.preventDefault()` will prevent the object from being returned.
+Custom value can be returned by setting `event.returnValue`.
+
+[rmi]: https://en.wikipedia.org/wiki/Java_remote_method_invocation
+[enumerable-properties]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties
+[remote-considered-harmful]: https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31
diff --git a/node_modules/@electron/remote/dist/src/common/get-electron-binding.d.ts b/node_modules/@electron/remote/dist/src/common/get-electron-binding.d.ts
new file mode 100644
index 0000000..b72cc7a
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/common/get-electron-binding.d.ts
@@ -0,0 +1 @@
+export declare const getElectronBinding: typeof process.electronBinding;
diff --git a/node_modules/@electron/remote/dist/src/common/get-electron-binding.js b/node_modules/@electron/remote/dist/src/common/get-electron-binding.js
new file mode 100644
index 0000000..8c9ca47
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/common/get-electron-binding.js
@@ -0,0 +1,15 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.getElectronBinding = void 0;
+const getElectronBinding = (name) => {
+ if (process._linkedBinding) {
+ return process._linkedBinding('electron_common_' + name);
+ }
+ else if (process.electronBinding) {
+ return process.electronBinding(name);
+ }
+ else {
+ return null;
+ }
+};
+exports.getElectronBinding = getElectronBinding;
diff --git a/node_modules/@electron/remote/dist/src/common/ipc-messages.d.ts b/node_modules/@electron/remote/dist/src/common/ipc-messages.d.ts
new file mode 100644
index 0000000..6d8ec68
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/common/ipc-messages.d.ts
@@ -0,0 +1,18 @@
+export declare const enum IPC_MESSAGES {
+ BROWSER_REQUIRE = "REMOTE_BROWSER_REQUIRE",
+ BROWSER_GET_BUILTIN = "REMOTE_BROWSER_GET_BUILTIN",
+ BROWSER_GET_GLOBAL = "REMOTE_BROWSER_GET_GLOBAL",
+ BROWSER_GET_CURRENT_WINDOW = "REMOTE_BROWSER_GET_CURRENT_WINDOW",
+ BROWSER_GET_CURRENT_WEB_CONTENTS = "REMOTE_BROWSER_GET_CURRENT_WEB_CONTENTS",
+ BROWSER_CONSTRUCTOR = "REMOTE_BROWSER_CONSTRUCTOR",
+ BROWSER_FUNCTION_CALL = "REMOTE_BROWSER_FUNCTION_CALL",
+ BROWSER_MEMBER_CONSTRUCTOR = "REMOTE_BROWSER_MEMBER_CONSTRUCTOR",
+ BROWSER_MEMBER_CALL = "REMOTE_BROWSER_MEMBER_CALL",
+ BROWSER_MEMBER_GET = "REMOTE_BROWSER_MEMBER_GET",
+ BROWSER_MEMBER_SET = "REMOTE_BROWSER_MEMBER_SET",
+ BROWSER_DEREFERENCE = "REMOTE_BROWSER_DEREFERENCE",
+ BROWSER_CONTEXT_RELEASE = "REMOTE_BROWSER_CONTEXT_RELEASE",
+ BROWSER_WRONG_CONTEXT_ERROR = "REMOTE_BROWSER_WRONG_CONTEXT_ERROR",
+ RENDERER_CALLBACK = "REMOTE_RENDERER_CALLBACK",
+ RENDERER_RELEASE_CALLBACK = "REMOTE_RENDERER_RELEASE_CALLBACK"
+}
diff --git a/node_modules/@electron/remote/dist/src/common/ipc-messages.js b/node_modules/@electron/remote/dist/src/common/ipc-messages.js
new file mode 100644
index 0000000..c8ad2e5
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/common/ipc-messages.js
@@ -0,0 +1,2 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/node_modules/@electron/remote/dist/src/common/module-names.d.ts b/node_modules/@electron/remote/dist/src/common/module-names.d.ts
new file mode 100644
index 0000000..d8a0d87
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/common/module-names.d.ts
@@ -0,0 +1,2 @@
+export declare const commonModuleNames: string[];
+export declare const browserModuleNames: string[];
diff --git a/node_modules/@electron/remote/dist/src/common/module-names.js b/node_modules/@electron/remote/dist/src/common/module-names.js
new file mode 100644
index 0000000..f7f7a91
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/common/module-names.js
@@ -0,0 +1,53 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.browserModuleNames = exports.commonModuleNames = void 0;
+const get_electron_binding_1 = require("./get-electron-binding");
+exports.commonModuleNames = [
+ 'clipboard',
+ 'nativeImage',
+ 'shell',
+];
+exports.browserModuleNames = [
+ 'app',
+ 'autoUpdater',
+ 'BaseWindow',
+ 'BrowserView',
+ 'BrowserWindow',
+ 'contentTracing',
+ 'crashReporter',
+ 'dialog',
+ 'globalShortcut',
+ 'ipcMain',
+ 'inAppPurchase',
+ 'Menu',
+ 'MenuItem',
+ 'nativeTheme',
+ 'net',
+ 'netLog',
+ 'MessageChannelMain',
+ 'Notification',
+ 'powerMonitor',
+ 'powerSaveBlocker',
+ 'protocol',
+ 'pushNotifications',
+ 'safeStorage',
+ 'screen',
+ 'session',
+ 'ShareMenu',
+ 'systemPreferences',
+ 'TopLevelWindow',
+ 'TouchBar',
+ 'Tray',
+ 'utilityProcess',
+ 'View',
+ 'webContents',
+ 'WebContentsView',
+ 'webFrameMain',
+].concat(exports.commonModuleNames);
+const features = get_electron_binding_1.getElectronBinding('features');
+if (!features || !features.isDesktopCapturerEnabled || features.isDesktopCapturerEnabled()) {
+ exports.browserModuleNames.push('desktopCapturer');
+}
+if (!features || features.isViewApiEnabled()) {
+ exports.browserModuleNames.push('ImageView');
+}
diff --git a/node_modules/@electron/remote/dist/src/common/type-utils.d.ts b/node_modules/@electron/remote/dist/src/common/type-utils.d.ts
new file mode 100644
index 0000000..9e67173
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/common/type-utils.d.ts
@@ -0,0 +1,4 @@
+export declare function isPromise(val: any): any;
+export declare function isSerializableObject(value: any): boolean;
+export declare function serialize(value: any): any;
+export declare function deserialize(value: any): any;
diff --git a/node_modules/@electron/remote/dist/src/common/type-utils.js b/node_modules/@electron/remote/dist/src/common/type-utils.js
new file mode 100644
index 0000000..9ab250d
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/common/type-utils.js
@@ -0,0 +1,112 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.deserialize = exports.serialize = exports.isSerializableObject = exports.isPromise = void 0;
+const electron_1 = require("electron");
+function isPromise(val) {
+ return (val &&
+ val.then &&
+ val.then instanceof Function &&
+ val.constructor &&
+ val.constructor.reject &&
+ val.constructor.reject instanceof Function &&
+ val.constructor.resolve &&
+ val.constructor.resolve instanceof Function);
+}
+exports.isPromise = isPromise;
+const serializableTypes = [
+ Boolean,
+ Number,
+ String,
+ Date,
+ Error,
+ RegExp,
+ ArrayBuffer
+];
+// https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#Supported_types
+function isSerializableObject(value) {
+ return value === null || ArrayBuffer.isView(value) || serializableTypes.some(type => value instanceof type);
+}
+exports.isSerializableObject = isSerializableObject;
+const objectMap = function (source, mapper) {
+ const sourceEntries = Object.entries(source);
+ const targetEntries = sourceEntries.map(([key, val]) => [key, mapper(val)]);
+ return Object.fromEntries(targetEntries);
+};
+function serializeNativeImage(image) {
+ const representations = [];
+ const scaleFactors = image.getScaleFactors();
+ // Use Buffer when there's only one representation for better perf.
+ // This avoids compressing to/from PNG where it's not necessary to
+ // ensure uniqueness of dataURLs (since there's only one).
+ if (scaleFactors.length === 1) {
+ const scaleFactor = scaleFactors[0];
+ const size = image.getSize(scaleFactor);
+ const buffer = image.toBitmap({ scaleFactor });
+ representations.push({ scaleFactor, size, buffer });
+ }
+ else {
+ // Construct from dataURLs to ensure that they are not lost in creation.
+ for (const scaleFactor of scaleFactors) {
+ const size = image.getSize(scaleFactor);
+ const dataURL = image.toDataURL({ scaleFactor });
+ representations.push({ scaleFactor, size, dataURL });
+ }
+ }
+ return { __ELECTRON_SERIALIZED_NativeImage__: true, representations };
+}
+function deserializeNativeImage(value) {
+ const image = electron_1.nativeImage.createEmpty();
+ // Use Buffer when there's only one representation for better perf.
+ // This avoids compressing to/from PNG where it's not necessary to
+ // ensure uniqueness of dataURLs (since there's only one).
+ if (value.representations.length === 1) {
+ const { buffer, size, scaleFactor } = value.representations[0];
+ const { width, height } = size;
+ image.addRepresentation({ buffer, scaleFactor, width, height });
+ }
+ else {
+ // Construct from dataURLs to ensure that they are not lost in creation.
+ for (const rep of value.representations) {
+ const { dataURL, size, scaleFactor } = rep;
+ const { width, height } = size;
+ image.addRepresentation({ dataURL, scaleFactor, width, height });
+ }
+ }
+ return image;
+}
+function serialize(value) {
+ if (value && value.constructor && value.constructor.name === 'NativeImage') {
+ return serializeNativeImage(value);
+ }
+ if (Array.isArray(value)) {
+ return value.map(serialize);
+ }
+ else if (isSerializableObject(value)) {
+ return value;
+ }
+ else if (value instanceof Object) {
+ return objectMap(value, serialize);
+ }
+ else {
+ return value;
+ }
+}
+exports.serialize = serialize;
+function deserialize(value) {
+ if (value && value.__ELECTRON_SERIALIZED_NativeImage__) {
+ return deserializeNativeImage(value);
+ }
+ else if (Array.isArray(value)) {
+ return value.map(deserialize);
+ }
+ else if (isSerializableObject(value)) {
+ return value;
+ }
+ else if (value instanceof Object) {
+ return objectMap(value, deserialize);
+ }
+ else {
+ return value;
+ }
+}
+exports.deserialize = deserialize;
diff --git a/node_modules/@electron/remote/dist/src/main/index.d.ts b/node_modules/@electron/remote/dist/src/main/index.d.ts
new file mode 100644
index 0000000..d06177a
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/main/index.d.ts
@@ -0,0 +1 @@
+export { initialize, enable } from "./server";
diff --git a/node_modules/@electron/remote/dist/src/main/index.js b/node_modules/@electron/remote/dist/src/main/index.js
new file mode 100644
index 0000000..d045311
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/main/index.js
@@ -0,0 +1,6 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.enable = exports.initialize = void 0;
+var server_1 = require("./server");
+Object.defineProperty(exports, "initialize", { enumerable: true, get: function () { return server_1.initialize; } });
+Object.defineProperty(exports, "enable", { enumerable: true, get: function () { return server_1.enable; } });
diff --git a/node_modules/@electron/remote/dist/src/main/objects-registry.d.ts b/node_modules/@electron/remote/dist/src/main/objects-registry.d.ts
new file mode 100644
index 0000000..b4afabb
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/main/objects-registry.d.ts
@@ -0,0 +1,16 @@
+import { WebContents } from 'electron';
+declare class ObjectsRegistry {
+ private nextId;
+ private storage;
+ private owners;
+ private electronIds;
+ add(webContents: WebContents, contextId: string, obj: any): number;
+ get(id: number): any;
+ remove(webContents: WebContents, contextId: string, id: number): void;
+ clear(webContents: WebContents, contextId: string): void;
+ private saveToStorage;
+ private dereference;
+ private registerDeleteListener;
+}
+declare const _default: ObjectsRegistry;
+export default _default;
diff --git a/node_modules/@electron/remote/dist/src/main/objects-registry.js b/node_modules/@electron/remote/dist/src/main/objects-registry.js
new file mode 100644
index 0000000..3ff5bae
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/main/objects-registry.js
@@ -0,0 +1,117 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const getOwnerKey = (webContents, contextId) => {
+ return `${webContents.id}-${contextId}`;
+};
+class ObjectsRegistry {
+ constructor() {
+ this.nextId = 0;
+ // Stores all objects by ref-counting.
+ // (id) => {object, count}
+ this.storage = {};
+ // Stores the IDs + refCounts of objects referenced by WebContents.
+ // (ownerKey) => { id: refCount }
+ this.owners = {};
+ this.electronIds = new WeakMap();
+ }
+ // Register a new object and return its assigned ID. If the object is already
+ // registered then the already assigned ID would be returned.
+ add(webContents, contextId, obj) {
+ // Get or assign an ID to the object.
+ const id = this.saveToStorage(obj);
+ // Add object to the set of referenced objects.
+ const ownerKey = getOwnerKey(webContents, contextId);
+ let owner = this.owners[ownerKey];
+ if (!owner) {
+ owner = this.owners[ownerKey] = new Map();
+ this.registerDeleteListener(webContents, contextId);
+ }
+ if (!owner.has(id)) {
+ owner.set(id, 0);
+ // Increase reference count if not referenced before.
+ this.storage[id].count++;
+ }
+ owner.set(id, owner.get(id) + 1);
+ return id;
+ }
+ // Get an object according to its ID.
+ get(id) {
+ const pointer = this.storage[id];
+ if (pointer != null)
+ return pointer.object;
+ }
+ // Dereference an object according to its ID.
+ // Note that an object may be double-freed (cleared when page is reloaded, and
+ // then garbage collected in old page).
+ remove(webContents, contextId, id) {
+ const ownerKey = getOwnerKey(webContents, contextId);
+ const owner = this.owners[ownerKey];
+ if (owner && owner.has(id)) {
+ const newRefCount = owner.get(id) - 1;
+ // Only completely remove if the number of references GCed in the
+ // renderer is the same as the number of references we sent them
+ if (newRefCount <= 0) {
+ // Remove the reference in owner.
+ owner.delete(id);
+ // Dereference from the storage.
+ this.dereference(id);
+ }
+ else {
+ owner.set(id, newRefCount);
+ }
+ }
+ }
+ // Clear all references to objects refrenced by the WebContents.
+ clear(webContents, contextId) {
+ const ownerKey = getOwnerKey(webContents, contextId);
+ const owner = this.owners[ownerKey];
+ if (!owner)
+ return;
+ for (const id of owner.keys())
+ this.dereference(id);
+ delete this.owners[ownerKey];
+ }
+ // Saves the object into storage and assigns an ID for it.
+ saveToStorage(object) {
+ let id = this.electronIds.get(object);
+ if (!id) {
+ id = ++this.nextId;
+ this.storage[id] = {
+ count: 0,
+ object: object
+ };
+ this.electronIds.set(object, id);
+ }
+ return id;
+ }
+ // Dereference the object from store.
+ dereference(id) {
+ const pointer = this.storage[id];
+ if (pointer == null) {
+ return;
+ }
+ pointer.count -= 1;
+ if (pointer.count === 0) {
+ this.electronIds.delete(pointer.object);
+ delete this.storage[id];
+ }
+ }
+ // Clear the storage when renderer process is destroyed.
+ registerDeleteListener(webContents, contextId) {
+ // contextId => ${processHostId}-${contextCount}
+ const processHostId = contextId.split('-')[0];
+ const listener = (_, deletedProcessHostId) => {
+ if (deletedProcessHostId &&
+ deletedProcessHostId.toString() === processHostId) {
+ webContents.removeListener('render-view-deleted', listener);
+ this.clear(webContents, contextId);
+ }
+ };
+ // Note that the "render-view-deleted" event may not be emitted on time when
+ // the renderer process get destroyed because of navigation, we rely on the
+ // renderer process to send "ELECTRON_BROWSER_CONTEXT_RELEASE" message to
+ // guard this situation.
+ webContents.on('render-view-deleted', listener);
+ }
+}
+exports.default = new ObjectsRegistry();
diff --git a/node_modules/@electron/remote/dist/src/main/server.d.ts b/node_modules/@electron/remote/dist/src/main/server.d.ts
new file mode 100644
index 0000000..30c9ab0
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/main/server.d.ts
@@ -0,0 +1,4 @@
+import { WebContents } from 'electron';
+export declare const isRemoteModuleEnabled: (contents: WebContents) => boolean | undefined;
+export declare function enable(contents: WebContents): void;
+export declare function initialize(): void;
diff --git a/node_modules/@electron/remote/dist/src/main/server.js b/node_modules/@electron/remote/dist/src/main/server.js
new file mode 100644
index 0000000..d4c535a
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/main/server.js
@@ -0,0 +1,498 @@
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.initialize = exports.enable = exports.isRemoteModuleEnabled = void 0;
+const events_1 = require("events");
+const objects_registry_1 = __importDefault(require("./objects-registry"));
+const type_utils_1 = require("../common/type-utils");
+const electron_1 = require("electron");
+const get_electron_binding_1 = require("../common/get-electron-binding");
+const { Promise } = global;
+const v8Util = get_electron_binding_1.getElectronBinding('v8_util');
+const hasWebPrefsRemoteModuleAPI = (() => {
+ var _a, _b;
+ const electronVersion = Number((_b = (_a = process.versions.electron) === null || _a === void 0 ? void 0 : _a.split(".")) === null || _b === void 0 ? void 0 : _b[0]);
+ return Number.isNaN(electronVersion) || electronVersion < 14;
+})();
+// The internal properties of Function.
+const FUNCTION_PROPERTIES = [
+ 'length', 'name', 'arguments', 'caller', 'prototype'
+];
+// The remote functions in renderer processes.
+const rendererFunctionCache = new Map();
+// eslint-disable-next-line no-undef
+const finalizationRegistry = new FinalizationRegistry((fi) => {
+ const mapKey = fi.id[0] + '~' + fi.id[1];
+ const ref = rendererFunctionCache.get(mapKey);
+ if (ref !== undefined && ref.deref() === undefined) {
+ rendererFunctionCache.delete(mapKey);
+ if (!fi.webContents.isDestroyed()) {
+ try {
+ fi.webContents.sendToFrame(fi.frameId, "REMOTE_RENDERER_RELEASE_CALLBACK" /* RENDERER_RELEASE_CALLBACK */, fi.id[0], fi.id[1]);
+ }
+ catch (error) {
+ console.warn(`sendToFrame() failed: ${error}`);
+ }
+ }
+ }
+});
+function getCachedRendererFunction(id) {
+ const mapKey = id[0] + '~' + id[1];
+ const ref = rendererFunctionCache.get(mapKey);
+ if (ref !== undefined) {
+ const deref = ref.deref();
+ if (deref !== undefined)
+ return deref;
+ }
+}
+function setCachedRendererFunction(id, wc, frameId, value) {
+ // eslint-disable-next-line no-undef
+ const wr = new WeakRef(value);
+ const mapKey = id[0] + '~' + id[1];
+ rendererFunctionCache.set(mapKey, wr);
+ finalizationRegistry.register(value, {
+ id,
+ webContents: wc,
+ frameId
+ });
+ return value;
+}
+const locationInfo = new WeakMap();
+// Return the description of object's members:
+const getObjectMembers = function (object) {
+ let names = Object.getOwnPropertyNames(object);
+ // For Function, we should not override following properties even though they
+ // are "own" properties.
+ if (typeof object === 'function') {
+ names = names.filter((name) => {
+ return !FUNCTION_PROPERTIES.includes(name);
+ });
+ }
+ // Map properties to descriptors.
+ return names.map((name) => {
+ const descriptor = Object.getOwnPropertyDescriptor(object, name);
+ let type;
+ let writable = false;
+ if (descriptor.get === undefined && typeof object[name] === 'function') {
+ type = 'method';
+ }
+ else {
+ if (descriptor.set || descriptor.writable)
+ writable = true;
+ type = 'get';
+ }
+ return { name, enumerable: descriptor.enumerable, writable, type };
+ });
+};
+// Return the description of object's prototype.
+const getObjectPrototype = function (object) {
+ const proto = Object.getPrototypeOf(object);
+ if (proto === null || proto === Object.prototype)
+ return null;
+ return {
+ members: getObjectMembers(proto),
+ proto: getObjectPrototype(proto)
+ };
+};
+// Convert a real value into meta data.
+const valueToMeta = function (sender, contextId, value, optimizeSimpleObject = false) {
+ // Determine the type of value.
+ let type;
+ switch (typeof value) {
+ case 'object':
+ // Recognize certain types of objects.
+ if (value instanceof Buffer) {
+ type = 'buffer';
+ }
+ else if (value && value.constructor && value.constructor.name === 'NativeImage') {
+ type = 'nativeimage';
+ }
+ else if (Array.isArray(value)) {
+ type = 'array';
+ }
+ else if (value instanceof Error) {
+ type = 'error';
+ }
+ else if (type_utils_1.isSerializableObject(value)) {
+ type = 'value';
+ }
+ else if (type_utils_1.isPromise(value)) {
+ type = 'promise';
+ }
+ else if (Object.prototype.hasOwnProperty.call(value, 'callee') && value.length != null) {
+ // Treat the arguments object as array.
+ type = 'array';
+ }
+ else if (optimizeSimpleObject && v8Util.getHiddenValue(value, 'simple')) {
+ // Treat simple objects as value.
+ type = 'value';
+ }
+ else {
+ type = 'object';
+ }
+ break;
+ case 'function':
+ type = 'function';
+ break;
+ default:
+ type = 'value';
+ break;
+ }
+ // Fill the meta object according to value's type.
+ if (type === 'array') {
+ return {
+ type,
+ members: value.map((el) => valueToMeta(sender, contextId, el, optimizeSimpleObject))
+ };
+ }
+ else if (type === 'nativeimage') {
+ return { type, value: type_utils_1.serialize(value) };
+ }
+ else if (type === 'object' || type === 'function') {
+ return {
+ type,
+ name: value.constructor ? value.constructor.name : '',
+ // Reference the original value if it's an object, because when it's
+ // passed to renderer we would assume the renderer keeps a reference of
+ // it.
+ id: objects_registry_1.default.add(sender, contextId, value),
+ members: getObjectMembers(value),
+ proto: getObjectPrototype(value)
+ };
+ }
+ else if (type === 'buffer') {
+ return { type, value };
+ }
+ else if (type === 'promise') {
+ // Add default handler to prevent unhandled rejections in main process
+ // Instead they should appear in the renderer process
+ value.then(function () { }, function () { });
+ return {
+ type,
+ then: valueToMeta(sender, contextId, function (onFulfilled, onRejected) {
+ value.then(onFulfilled, onRejected);
+ })
+ };
+ }
+ else if (type === 'error') {
+ return {
+ type,
+ value,
+ members: Object.keys(value).map(name => ({
+ name,
+ value: valueToMeta(sender, contextId, value[name])
+ }))
+ };
+ }
+ else {
+ return {
+ type: 'value',
+ value
+ };
+ }
+};
+const throwRPCError = function (message) {
+ const error = new Error(message);
+ error.code = 'EBADRPC';
+ error.errno = -72;
+ throw error;
+};
+const removeRemoteListenersAndLogWarning = (sender, callIntoRenderer) => {
+ const location = locationInfo.get(callIntoRenderer);
+ let message = 'Attempting to call a function in a renderer window that has been closed or released.' +
+ `\nFunction provided here: ${location}`;
+ if (sender instanceof events_1.EventEmitter) {
+ const remoteEvents = sender.eventNames().filter((eventName) => {
+ return sender.listeners(eventName).includes(callIntoRenderer);
+ });
+ if (remoteEvents.length > 0) {
+ message += `\nRemote event names: ${remoteEvents.join(', ')}`;
+ remoteEvents.forEach((eventName) => {
+ sender.removeListener(eventName, callIntoRenderer);
+ });
+ }
+ }
+ console.warn(message);
+};
+const fakeConstructor = (constructor, name) => new Proxy(Object, {
+ get(target, prop, receiver) {
+ if (prop === 'name') {
+ return name;
+ }
+ else {
+ return Reflect.get(target, prop, receiver);
+ }
+ }
+});
+// Convert array of meta data from renderer into array of real values.
+const unwrapArgs = function (sender, frameId, contextId, args) {
+ const metaToValue = function (meta) {
+ switch (meta.type) {
+ case 'nativeimage':
+ return type_utils_1.deserialize(meta.value);
+ case 'value':
+ return meta.value;
+ case 'remote-object':
+ return objects_registry_1.default.get(meta.id);
+ case 'array':
+ return unwrapArgs(sender, frameId, contextId, meta.value);
+ case 'buffer':
+ return Buffer.from(meta.value.buffer, meta.value.byteOffset, meta.value.byteLength);
+ case 'promise':
+ return Promise.resolve({
+ then: metaToValue(meta.then)
+ });
+ case 'object': {
+ const ret = meta.name !== 'Object' ? Object.create({
+ constructor: fakeConstructor(Object, meta.name)
+ }) : {};
+ for (const { name, value } of meta.members) {
+ ret[name] = metaToValue(value);
+ }
+ return ret;
+ }
+ case 'function-with-return-value': {
+ const returnValue = metaToValue(meta.value);
+ return function () {
+ return returnValue;
+ };
+ }
+ case 'function': {
+ // Merge contextId and meta.id, since meta.id can be the same in
+ // different webContents.
+ const objectId = [contextId, meta.id];
+ // Cache the callbacks in renderer.
+ const cachedFunction = getCachedRendererFunction(objectId);
+ if (cachedFunction !== undefined) {
+ return cachedFunction;
+ }
+ const callIntoRenderer = function (...args) {
+ let succeed = false;
+ if (!sender.isDestroyed()) {
+ try {
+ succeed = sender.sendToFrame(frameId, "REMOTE_RENDERER_CALLBACK" /* RENDERER_CALLBACK */, contextId, meta.id, valueToMeta(sender, contextId, args)) !== false;
+ }
+ catch (error) {
+ console.warn(`sendToFrame() failed: ${error}`);
+ }
+ }
+ if (!succeed) {
+ removeRemoteListenersAndLogWarning(this, callIntoRenderer);
+ }
+ };
+ locationInfo.set(callIntoRenderer, meta.location);
+ Object.defineProperty(callIntoRenderer, 'length', { value: meta.length });
+ setCachedRendererFunction(objectId, sender, frameId, callIntoRenderer);
+ return callIntoRenderer;
+ }
+ default:
+ throw new TypeError(`Unknown type: ${meta.type}`);
+ }
+ };
+ return args.map(metaToValue);
+};
+const isRemoteModuleEnabledImpl = function (contents) {
+ const webPreferences = contents.getLastWebPreferences() || {};
+ return webPreferences.enableRemoteModule != null ? !!webPreferences.enableRemoteModule : false;
+};
+const isRemoteModuleEnabledCache = new WeakMap();
+const isRemoteModuleEnabled = function (contents) {
+ if (hasWebPrefsRemoteModuleAPI && !isRemoteModuleEnabledCache.has(contents)) {
+ isRemoteModuleEnabledCache.set(contents, isRemoteModuleEnabledImpl(contents));
+ }
+ return isRemoteModuleEnabledCache.get(contents);
+};
+exports.isRemoteModuleEnabled = isRemoteModuleEnabled;
+function enable(contents) {
+ isRemoteModuleEnabledCache.set(contents, true);
+}
+exports.enable = enable;
+const handleRemoteCommand = function (channel, handler) {
+ electron_1.ipcMain.on(channel, (event, contextId, ...args) => {
+ let returnValue;
+ if (!exports.isRemoteModuleEnabled(event.sender)) {
+ event.returnValue = {
+ type: 'exception',
+ value: valueToMeta(event.sender, contextId, new Error('@electron/remote is disabled for this WebContents. Call require("@electron/remote/main").enable(webContents) to enable it.'))
+ };
+ return;
+ }
+ try {
+ returnValue = handler(event, contextId, ...args);
+ }
+ catch (error) {
+ returnValue = {
+ type: 'exception',
+ value: valueToMeta(event.sender, contextId, error),
+ };
+ }
+ if (returnValue !== undefined) {
+ event.returnValue = returnValue;
+ }
+ });
+};
+const emitCustomEvent = function (contents, eventName, ...args) {
+ const event = { sender: contents, returnValue: undefined, defaultPrevented: false };
+ electron_1.app.emit(eventName, event, contents, ...args);
+ contents.emit(eventName, event, ...args);
+ return event;
+};
+const logStack = function (contents, code, stack) {
+ if (stack) {
+ console.warn(`WebContents (${contents.id}): ${code}`, stack);
+ }
+};
+let initialized = false;
+function initialize() {
+ if (initialized)
+ throw new Error('@electron/remote has already been initialized');
+ initialized = true;
+ handleRemoteCommand("REMOTE_BROWSER_WRONG_CONTEXT_ERROR" /* BROWSER_WRONG_CONTEXT_ERROR */, function (event, contextId, passedContextId, id) {
+ const objectId = [passedContextId, id];
+ const cachedFunction = getCachedRendererFunction(objectId);
+ if (cachedFunction === undefined) {
+ // Do nothing if the error has already been reported before.
+ return;
+ }
+ removeRemoteListenersAndLogWarning(event.sender, cachedFunction);
+ });
+ handleRemoteCommand("REMOTE_BROWSER_REQUIRE" /* BROWSER_REQUIRE */, function (event, contextId, moduleName, stack) {
+ logStack(event.sender, `remote.require('${moduleName}')`, stack);
+ const customEvent = emitCustomEvent(event.sender, 'remote-require', moduleName);
+ if (customEvent.returnValue === undefined) {
+ if (customEvent.defaultPrevented) {
+ throw new Error(`Blocked remote.require('${moduleName}')`);
+ }
+ else {
+ customEvent.returnValue = process.mainModule.require(moduleName);
+ }
+ }
+ return valueToMeta(event.sender, contextId, customEvent.returnValue);
+ });
+ handleRemoteCommand("REMOTE_BROWSER_GET_BUILTIN" /* BROWSER_GET_BUILTIN */, function (event, contextId, moduleName, stack) {
+ logStack(event.sender, `remote.getBuiltin('${moduleName}')`, stack);
+ const customEvent = emitCustomEvent(event.sender, 'remote-get-builtin', moduleName);
+ if (customEvent.returnValue === undefined) {
+ if (customEvent.defaultPrevented) {
+ throw new Error(`Blocked remote.getBuiltin('${moduleName}')`);
+ }
+ else {
+ customEvent.returnValue = require('electron')[moduleName];
+ }
+ }
+ return valueToMeta(event.sender, contextId, customEvent.returnValue);
+ });
+ handleRemoteCommand("REMOTE_BROWSER_GET_GLOBAL" /* BROWSER_GET_GLOBAL */, function (event, contextId, globalName, stack) {
+ logStack(event.sender, `remote.getGlobal('${globalName}')`, stack);
+ const customEvent = emitCustomEvent(event.sender, 'remote-get-global', globalName);
+ if (customEvent.returnValue === undefined) {
+ if (customEvent.defaultPrevented) {
+ throw new Error(`Blocked remote.getGlobal('${globalName}')`);
+ }
+ else {
+ customEvent.returnValue = global[globalName];
+ }
+ }
+ return valueToMeta(event.sender, contextId, customEvent.returnValue);
+ });
+ handleRemoteCommand("REMOTE_BROWSER_GET_CURRENT_WINDOW" /* BROWSER_GET_CURRENT_WINDOW */, function (event, contextId, stack) {
+ logStack(event.sender, 'remote.getCurrentWindow()', stack);
+ const customEvent = emitCustomEvent(event.sender, 'remote-get-current-window');
+ if (customEvent.returnValue === undefined) {
+ if (customEvent.defaultPrevented) {
+ throw new Error('Blocked remote.getCurrentWindow()');
+ }
+ else {
+ customEvent.returnValue = event.sender.getOwnerBrowserWindow();
+ }
+ }
+ return valueToMeta(event.sender, contextId, customEvent.returnValue);
+ });
+ handleRemoteCommand("REMOTE_BROWSER_GET_CURRENT_WEB_CONTENTS" /* BROWSER_GET_CURRENT_WEB_CONTENTS */, function (event, contextId, stack) {
+ logStack(event.sender, 'remote.getCurrentWebContents()', stack);
+ const customEvent = emitCustomEvent(event.sender, 'remote-get-current-web-contents');
+ if (customEvent.returnValue === undefined) {
+ if (customEvent.defaultPrevented) {
+ throw new Error('Blocked remote.getCurrentWebContents()');
+ }
+ else {
+ customEvent.returnValue = event.sender;
+ }
+ }
+ return valueToMeta(event.sender, contextId, customEvent.returnValue);
+ });
+ handleRemoteCommand("REMOTE_BROWSER_CONSTRUCTOR" /* BROWSER_CONSTRUCTOR */, function (event, contextId, id, args) {
+ args = unwrapArgs(event.sender, event.frameId, contextId, args);
+ const constructor = objects_registry_1.default.get(id);
+ if (constructor == null) {
+ throwRPCError(`Cannot call constructor on missing remote object ${id}`);
+ }
+ return valueToMeta(event.sender, contextId, new constructor(...args));
+ });
+ handleRemoteCommand("REMOTE_BROWSER_FUNCTION_CALL" /* BROWSER_FUNCTION_CALL */, function (event, contextId, id, args) {
+ args = unwrapArgs(event.sender, event.frameId, contextId, args);
+ const func = objects_registry_1.default.get(id);
+ if (func == null) {
+ throwRPCError(`Cannot call function on missing remote object ${id}`);
+ }
+ try {
+ return valueToMeta(event.sender, contextId, func(...args), true);
+ }
+ catch (error) {
+ const err = new Error(`Could not call remote function '${func.name || "anonymous"}'. Check that the function signature is correct. Underlying error: ${error}\n` +
+ (error instanceof Error ? `Underlying stack: ${error.stack}\n` : ""));
+ err.cause = error;
+ throw err;
+ }
+ });
+ handleRemoteCommand("REMOTE_BROWSER_MEMBER_CONSTRUCTOR" /* BROWSER_MEMBER_CONSTRUCTOR */, function (event, contextId, id, method, args) {
+ args = unwrapArgs(event.sender, event.frameId, contextId, args);
+ const object = objects_registry_1.default.get(id);
+ if (object == null) {
+ throwRPCError(`Cannot call constructor '${method}' on missing remote object ${id}`);
+ }
+ return valueToMeta(event.sender, contextId, new object[method](...args));
+ });
+ handleRemoteCommand("REMOTE_BROWSER_MEMBER_CALL" /* BROWSER_MEMBER_CALL */, function (event, contextId, id, method, args) {
+ args = unwrapArgs(event.sender, event.frameId, contextId, args);
+ const object = objects_registry_1.default.get(id);
+ if (object == null) {
+ throwRPCError(`Cannot call method '${method}' on missing remote object ${id}`);
+ }
+ try {
+ return valueToMeta(event.sender, contextId, object[method](...args), true);
+ }
+ catch (error) {
+ const err = new Error(`Could not call remote method '${method}'. Check that the method signature is correct. Underlying error: ${error}` +
+ (error instanceof Error ? `Underlying stack: ${error.stack}\n` : ""));
+ err.cause = error;
+ throw err;
+ }
+ });
+ handleRemoteCommand("REMOTE_BROWSER_MEMBER_SET" /* BROWSER_MEMBER_SET */, function (event, contextId, id, name, args) {
+ args = unwrapArgs(event.sender, event.frameId, contextId, args);
+ const obj = objects_registry_1.default.get(id);
+ if (obj == null) {
+ throwRPCError(`Cannot set property '${name}' on missing remote object ${id}`);
+ }
+ obj[name] = args[0];
+ return null;
+ });
+ handleRemoteCommand("REMOTE_BROWSER_MEMBER_GET" /* BROWSER_MEMBER_GET */, function (event, contextId, id, name) {
+ const obj = objects_registry_1.default.get(id);
+ if (obj == null) {
+ throwRPCError(`Cannot get property '${name}' on missing remote object ${id}`);
+ }
+ return valueToMeta(event.sender, contextId, obj[name]);
+ });
+ handleRemoteCommand("REMOTE_BROWSER_DEREFERENCE" /* BROWSER_DEREFERENCE */, function (event, contextId, id) {
+ objects_registry_1.default.remove(event.sender, contextId, id);
+ });
+ handleRemoteCommand("REMOTE_BROWSER_CONTEXT_RELEASE" /* BROWSER_CONTEXT_RELEASE */, (event, contextId) => {
+ objects_registry_1.default.clear(event.sender, contextId);
+ return null;
+ });
+}
+exports.initialize = initialize;
diff --git a/node_modules/@electron/remote/dist/src/renderer/callbacks-registry.d.ts b/node_modules/@electron/remote/dist/src/renderer/callbacks-registry.d.ts
new file mode 100644
index 0000000..f67bb12
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/renderer/callbacks-registry.d.ts
@@ -0,0 +1,11 @@
+export declare class CallbacksRegistry {
+ private nextId;
+ private callbacks;
+ private callbackIds;
+ private locationInfo;
+ add(callback: Function): number;
+ get(id: number): Function;
+ getLocation(callback: Function): string | undefined;
+ apply(id: number, ...args: any[]): any;
+ remove(id: number): void;
+}
diff --git a/node_modules/@electron/remote/dist/src/renderer/callbacks-registry.js b/node_modules/@electron/remote/dist/src/renderer/callbacks-registry.js
new file mode 100644
index 0000000..393a041
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/renderer/callbacks-registry.js
@@ -0,0 +1,64 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.CallbacksRegistry = void 0;
+class CallbacksRegistry {
+ constructor() {
+ this.nextId = 0;
+ this.callbacks = {};
+ this.callbackIds = new WeakMap();
+ this.locationInfo = new WeakMap();
+ }
+ add(callback) {
+ // The callback is already added.
+ let id = this.callbackIds.get(callback);
+ if (id != null)
+ return id;
+ id = this.nextId += 1;
+ this.callbacks[id] = callback;
+ this.callbackIds.set(callback, id);
+ // Capture the location of the function and put it in the ID string,
+ // so that release errors can be tracked down easily.
+ const regexp = /at (.*)/gi;
+ const stackString = (new Error()).stack;
+ if (!stackString)
+ return id;
+ let filenameAndLine;
+ let match;
+ while ((match = regexp.exec(stackString)) !== null) {
+ const location = match[1];
+ if (location.includes('(native)'))
+ continue;
+ if (location.includes('(<anonymous>)'))
+ continue;
+ if (location.includes('callbacks-registry.js'))
+ continue;
+ if (location.includes('remote.js'))
+ continue;
+ if (location.includes('@electron/remote/dist'))
+ continue;
+ const ref = /([^/^)]*)\)?$/gi.exec(location);
+ if (ref)
+ filenameAndLine = ref[1];
+ break;
+ }
+ this.locationInfo.set(callback, filenameAndLine);
+ return id;
+ }
+ get(id) {
+ return this.callbacks[id] || function () { };
+ }
+ getLocation(callback) {
+ return this.locationInfo.get(callback);
+ }
+ apply(id, ...args) {
+ return this.get(id).apply(global, ...args);
+ }
+ remove(id) {
+ const callback = this.callbacks[id];
+ if (callback) {
+ this.callbackIds.delete(callback);
+ delete this.callbacks[id];
+ }
+ }
+}
+exports.CallbacksRegistry = CallbacksRegistry;
diff --git a/node_modules/@electron/remote/dist/src/renderer/index.d.ts b/node_modules/@electron/remote/dist/src/renderer/index.d.ts
new file mode 100644
index 0000000..32d2db9
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/renderer/index.d.ts
@@ -0,0 +1 @@
+export * from './remote';
diff --git a/node_modules/@electron/remote/dist/src/renderer/index.js b/node_modules/@electron/remote/dist/src/renderer/index.js
new file mode 100644
index 0000000..786e6a6
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/renderer/index.js
@@ -0,0 +1,15 @@
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __exportStar = (this && this.__exportStar) || function(m, exports) {
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+if (process.type === 'browser')
+ throw new Error(`"@electron/remote" cannot be required in the browser process. Instead require("@electron/remote/main").`);
+__exportStar(require("./remote"), exports);
diff --git a/node_modules/@electron/remote/dist/src/renderer/remote.d.ts b/node_modules/@electron/remote/dist/src/renderer/remote.d.ts
new file mode 100644
index 0000000..3bf0c03
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/renderer/remote.d.ts
@@ -0,0 +1,6 @@
+import { BrowserWindow, WebContents } from 'electron';
+export declare function getBuiltin(module: string): any;
+export declare function getCurrentWindow(): BrowserWindow;
+export declare function getCurrentWebContents(): WebContents;
+export declare function getGlobal<T = any>(name: string): T;
+export declare function createFunctionWithReturnValue<T>(returnValue: T): () => T;
diff --git a/node_modules/@electron/remote/dist/src/renderer/remote.js b/node_modules/@electron/remote/dist/src/renderer/remote.js
new file mode 100644
index 0000000..86219ce
--- /dev/null
+++ b/node_modules/@electron/remote/dist/src/renderer/remote.js
@@ -0,0 +1,403 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.createFunctionWithReturnValue = exports.getGlobal = exports.getCurrentWebContents = exports.getCurrentWindow = exports.getBuiltin = void 0;
+const callbacks_registry_1 = require("./callbacks-registry");
+const type_utils_1 = require("../common/type-utils");
+const electron_1 = require("electron");
+const module_names_1 = require("../common/module-names");
+const get_electron_binding_1 = require("../common/get-electron-binding");
+const { Promise } = global;
+const callbacksRegistry = new callbacks_registry_1.CallbacksRegistry();
+const remoteObjectCache = new Map();
+const finalizationRegistry = new FinalizationRegistry((id) => {
+ const ref = remoteObjectCache.get(id);
+ if (ref !== undefined && ref.deref() === undefined) {
+ remoteObjectCache.delete(id);
+ electron_1.ipcRenderer.send("REMOTE_BROWSER_DEREFERENCE" /* BROWSER_DEREFERENCE */, contextId, id, 0);
+ }
+});
+const electronIds = new WeakMap();
+const isReturnValue = new WeakSet();
+function getCachedRemoteObject(id) {
+ const ref = remoteObjectCache.get(id);
+ if (ref !== undefined) {
+ const deref = ref.deref();
+ if (deref !== undefined)
+ return deref;
+ }
+}
+function setCachedRemoteObject(id, value) {
+ const wr = new WeakRef(value);
+ remoteObjectCache.set(id, wr);
+ finalizationRegistry.register(value, id);
+ return value;
+}
+function getContextId() {
+ const v8Util = get_electron_binding_1.getElectronBinding('v8_util');
+ if (v8Util) {
+ return v8Util.getHiddenValue(global, 'contextId');
+ }
+ else {
+ throw new Error('Electron >=v13.0.0-beta.6 required to support sandboxed renderers');
+ }
+}
+// An unique ID that can represent current context.
+const contextId = process.contextId || getContextId();
+// Notify the main process when current context is going to be released.
+// Note that when the renderer process is destroyed, the message may not be
+// sent, we also listen to the "render-view-deleted" event in the main process
+// to guard that situation.
+process.on('exit', () => {
+ const command = "REMOTE_BROWSER_CONTEXT_RELEASE" /* BROWSER_CONTEXT_RELEASE */;
+ electron_1.ipcRenderer.send(command, contextId);
+});
+const IS_REMOTE_PROXY = Symbol('is-remote-proxy');
+// Convert the arguments object into an array of meta data.
+function wrapArgs(args, visited = new Set()) {
+ const valueToMeta = (value) => {
+ // Check for circular reference.
+ if (visited.has(value)) {
+ return {
+ type: 'value',
+ value: null
+ };
+ }
+ if (value && value.constructor && value.constructor.name === 'NativeImage') {
+ return { type: 'nativeimage', value: type_utils_1.serialize(value) };
+ }
+ else if (Array.isArray(value)) {
+ visited.add(value);
+ const meta = {
+ type: 'array',
+ value: wrapArgs(value, visited)
+ };
+ visited.delete(value);
+ return meta;
+ }
+ else if (value instanceof Buffer) {
+ return {
+ type: 'buffer',
+ value
+ };
+ }
+ else if (type_utils_1.isSerializableObject(value)) {
+ return {
+ type: 'value',
+ value
+ };
+ }
+ else if (typeof value === 'object') {
+ if (type_utils_1.isPromise(value)) {
+ return {
+ type: 'promise',
+ then: valueToMeta(function (onFulfilled, onRejected) {
+ value.then(onFulfilled, onRejected);
+ })
+ };
+ }
+ else if (electronIds.has(value)) {
+ return {
+ type: 'remote-object',
+ id: electronIds.get(value)
+ };
+ }
+ const meta = {
+ type: 'object',
+ name: value.constructor ? value.constructor.name : '',
+ members: []
+ };
+ visited.add(value);
+ for (const prop in value) { // eslint-disable-line guard-for-in
+ meta.members.push({
+ name: prop,
+ value: valueToMeta(value[prop])
+ });
+ }
+ visited.delete(value);
+ return meta;
+ }
+ else if (typeof value === 'function' && isReturnValue.has(value)) {
+ return {
+ type: 'function-with-return-value',
+ value: valueToMeta(value())
+ };
+ }
+ else if (typeof value === 'function') {
+ return {
+ type: 'function',
+ id: callbacksRegistry.add(value),
+ location: callbacksRegistry.getLocation(value),
+ length: value.length
+ };
+ }
+ else {
+ return {
+ type: 'value',
+ value
+ };
+ }
+ };
+ return args.map(valueToMeta);
+}
+// Populate object's members from descriptors.
+// The |ref| will be kept referenced by |members|.
+// This matches |getObjectMemebers| in rpc-server.
+function setObjectMembers(ref, object, metaId, members) {
+ if (!Array.isArray(members))
+ return;
+ for (const member of members) {
+ if (Object.prototype.hasOwnProperty.call(object, member.name))
+ continue;
+ const descriptor = { enumerable: member.enumerable };
+ if (member.type === 'method') {
+ const remoteMemberFunction = function (...args) {
+ let command;
+ if (this && this.constructor === remoteMemberFunction) {
+ command = "REMOTE_BROWSER_MEMBER_CONSTRUCTOR" /* BROWSER_MEMBER_CONSTRUCTOR */;
+ }
+ else {
+ command = "REMOTE_BROWSER_MEMBER_CALL" /* BROWSER_MEMBER_CALL */;
+ }
+ const ret = electron_1.ipcRenderer.sendSync(command, contextId, metaId, member.name, wrapArgs(args));
+ return metaToValue(ret);
+ };
+ let descriptorFunction = proxyFunctionProperties(remoteMemberFunction, metaId, member.name);
+ descriptor.get = () => {
+ descriptorFunction.ref = ref; // The member should reference its object.
+ return descriptorFunction;
+ };
+ // Enable monkey-patch the method
+ descriptor.set = (value) => {
+ descriptorFunction = value;
+ return value;
+ };
+ descriptor.configurable = true;
+ }
+ else if (member.type === 'get') {
+ descriptor.get = () => {
+ const command = "REMOTE_BROWSER_MEMBER_GET" /* BROWSER_MEMBER_GET */;
+ const meta = electron_1.ipcRenderer.sendSync(command, contextId, metaId, member.name);
+ return metaToValue(meta);
+ };
+ if (member.writable) {
+ descriptor.set = (value) => {
+ const args = wrapArgs([value]);
+ const command = "REMOTE_BROWSER_MEMBER_SET" /* BROWSER_MEMBER_SET */;
+ const meta = electron_1.ipcRenderer.sendSync(command, contextId, metaId, member.name, args);
+ if (meta != null)
+ metaToValue(meta);
+ return value;
+ };
+ }
+ }
+ Object.defineProperty(object, member.name, descriptor);
+ }
+}
+// Populate object's prototype from descriptor.
+// This matches |getObjectPrototype| in rpc-server.
+function setObjectPrototype(ref, object, metaId, descriptor) {
+ if (descriptor === null)
+ return;
+ const proto = {};
+ setObjectMembers(ref, proto, metaId, descriptor.members);
+ setObjectPrototype(ref, proto, metaId, descriptor.proto);
+ Object.setPrototypeOf(object, proto);
+}
+// Wrap function in Proxy for accessing remote properties
+function proxyFunctionProperties(remoteMemberFunction, metaId, name) {
+ let loaded = false;
+ // Lazily load function properties
+ const loadRemoteProperties = () => {
+ if (loaded)
+ return;
+ loaded = true;
+ const command = "REMOTE_BROWSER_MEMBER_GET" /* BROWSER_MEMBER_GET */;
+ const meta = electron_1.ipcRenderer.sendSync(command, contextId, metaId, name);
+ setObjectMembers(remoteMemberFunction, remoteMemberFunction, meta.id, meta.members);
+ };
+ return new Proxy(remoteMemberFunction, {
+ set: (target, property, value) => {
+ if (property !== 'ref')
+ loadRemoteProperties();
+ target[property] = value;
+ return true;
+ },
+ get: (target, property) => {
+ if (property === IS_REMOTE_PROXY)
+ return true;
+ if (!Object.prototype.hasOwnProperty.call(target, property))
+ loadRemoteProperties();
+ const value = target[property];
+ if (property === 'toString' && typeof value === 'function') {
+ return value.bind(target);
+ }
+ return value;
+ },
+ ownKeys: (target) => {
+ loadRemoteProperties();
+ return Object.getOwnPropertyNames(target);
+ },
+ getOwnPropertyDescriptor: (target, property) => {
+ const descriptor = Object.getOwnPropertyDescriptor(target, property);
+ if (descriptor)
+ return descriptor;
+ loadRemoteProperties();
+ return Object.getOwnPropertyDescriptor(target, property);
+ }
+ });
+}
+// Convert meta data from browser into real value.
+function metaToValue(meta) {
+ if (meta.type === 'value') {
+ return meta.value;
+ }
+ else if (meta.type === 'array') {
+ return meta.members.map((member) => metaToValue(member));
+ }
+ else if (meta.type === 'nativeimage') {
+ return type_utils_1.deserialize(meta.value);
+ }
+ else if (meta.type === 'buffer') {
+ return Buffer.from(meta.value.buffer, meta.value.byteOffset, meta.value.byteLength);
+ }
+ else if (meta.type === 'promise') {
+ return Promise.resolve({ then: metaToValue(meta.then) });
+ }
+ else if (meta.type === 'error') {
+ return metaToError(meta);
+ }
+ else if (meta.type === 'exception') {
+ if (meta.value.type === 'error') {
+ throw metaToError(meta.value);
+ }
+ else {
+ throw new Error(`Unexpected value type in exception: ${meta.value.type}`);
+ }
+ }
+ else {
+ let ret;
+ if ('id' in meta) {
+ const cached = getCachedRemoteObject(meta.id);
+ if (cached !== undefined) {
+ return cached;
+ }
+ }
+ // A shadow class to represent the remote function object.
+ if (meta.type === 'function') {
+ const remoteFunction = function (...args) {
+ let command;
+ if (this && this.constructor === remoteFunction) {
+ command = "REMOTE_BROWSER_CONSTRUCTOR" /* BROWSER_CONSTRUCTOR */;
+ }
+ else {
+ command = "REMOTE_BROWSER_FUNCTION_CALL" /* BROWSER_FUNCTION_CALL */;
+ }
+ const obj = electron_1.ipcRenderer.sendSync(command, contextId, meta.id, wrapArgs(args));
+ return metaToValue(obj);
+ };
+ ret = remoteFunction;
+ }
+ else {
+ ret = {};
+ }
+ setObjectMembers(ret, ret, meta.id, meta.members);
+ setObjectPrototype(ret, ret, meta.id, meta.proto);
+ if (ret.constructor && ret.constructor[IS_REMOTE_PROXY]) {
+ Object.defineProperty(ret.constructor, 'name', { value: meta.name });
+ }
+ // Track delegate obj's lifetime & tell browser to clean up when object is GCed.
+ electronIds.set(ret, meta.id);
+ setCachedRemoteObject(meta.id, ret);
+ return ret;
+ }
+}
+function metaToError(meta) {
+ const obj = meta.value;
+ for (const { name, value } of meta.members) {
+ obj[name] = metaToValue(value);
+ }
+ return obj;
+}
+function handleMessage(channel, handler) {
+ electron_1.ipcRenderer.on(channel, (event, passedContextId, id, ...args) => {
+ if (event.senderId !== 0) {
+ console.error(`Message ${channel} sent by unexpected WebContents (${event.senderId})`);
+ return;
+ }
+ if (passedContextId === contextId) {
+ handler(id, ...args);
+ }
+ else {
+ // Message sent to an un-exist context, notify the error to main process.
+ electron_1.ipcRenderer.send("REMOTE_BROWSER_WRONG_CONTEXT_ERROR" /* BROWSER_WRONG_CONTEXT_ERROR */, contextId, passedContextId, id);
+ }
+ });
+}
+const enableStacks = process.argv.includes('--enable-api-filtering-logging');
+function getCurrentStack() {
+ const target = { stack: undefined };
+ if (enableStacks) {
+ Error.captureStackTrace(target, getCurrentStack);
+ }
+ return target.stack;
+}
+// Browser calls a callback in renderer.
+handleMessage("REMOTE_RENDERER_CALLBACK" /* RENDERER_CALLBACK */, (id, args) => {
+ callbacksRegistry.apply(id, metaToValue(args));
+});
+// A callback in browser is released.
+handleMessage("REMOTE_RENDERER_RELEASE_CALLBACK" /* RENDERER_RELEASE_CALLBACK */, (id) => {
+ callbacksRegistry.remove(id);
+});
+exports.require = (module) => {
+ const command = "REMOTE_BROWSER_REQUIRE" /* BROWSER_REQUIRE */;
+ const meta = electron_1.ipcRenderer.sendSync(command, contextId, module, getCurrentStack());
+ return metaToValue(meta);
+};
+// Alias to remote.require('electron').xxx.
+function getBuiltin(module) {
+ const command = "REMOTE_BROWSER_GET_BUILTIN" /* BROWSER_GET_BUILTIN */;
+ const meta = electron_1.ipcRenderer.sendSync(command, contextId, module, getCurrentStack());
+ return metaToValue(meta);
+}
+exports.getBuiltin = getBuiltin;
+function getCurrentWindow() {
+ const command = "REMOTE_BROWSER_GET_CURRENT_WINDOW" /* BROWSER_GET_CURRENT_WINDOW */;
+ const meta = electron_1.ipcRenderer.sendSync(command, contextId, getCurrentStack());
+ return metaToValue(meta);
+}
+exports.getCurrentWindow = getCurrentWindow;
+// Get current WebContents object.
+function getCurrentWebContents() {
+ const command = "REMOTE_BROWSER_GET_CURRENT_WEB_CONTENTS" /* BROWSER_GET_CURRENT_WEB_CONTENTS */;
+ const meta = electron_1.ipcRenderer.sendSync(command, contextId, getCurrentStack());
+ return metaToValue(meta);
+}
+exports.getCurrentWebContents = getCurrentWebContents;
+// Get a global object in browser.
+function getGlobal(name) {
+ const command = "REMOTE_BROWSER_GET_GLOBAL" /* BROWSER_GET_GLOBAL */;
+ const meta = electron_1.ipcRenderer.sendSync(command, contextId, name, getCurrentStack());
+ return metaToValue(meta);
+}
+exports.getGlobal = getGlobal;
+// Get the process object in browser.
+Object.defineProperty(exports, 'process', {
+ enumerable: true,
+ get: () => exports.getGlobal('process')
+});
+// Create a function that will return the specified value when called in browser.
+function createFunctionWithReturnValue(returnValue) {
+ const func = () => returnValue;
+ isReturnValue.add(func);
+ return func;
+}
+exports.createFunctionWithReturnValue = createFunctionWithReturnValue;
+const addBuiltinProperty = (name) => {
+ Object.defineProperty(exports, name, {
+ enumerable: true,
+ get: () => exports.getBuiltin(name)
+ });
+};
+module_names_1.browserModuleNames
+ .forEach(addBuiltinProperty);
diff --git a/node_modules/@electron/remote/index.d.ts b/node_modules/@electron/remote/index.d.ts
new file mode 100644
index 0000000..26836fb
--- /dev/null
+++ b/node_modules/@electron/remote/index.d.ts
@@ -0,0 +1,65 @@
+import * as Electron from 'electron';
+
+export {
+ ClientRequest,
+ CommandLine,
+ Cookies,
+ Debugger,
+ Dock,
+ DownloadItem,
+ IncomingMessage,
+ MessagePortMain,
+ ServiceWorkers,
+ TouchBarButton,
+ TouchBarColorPicker,
+ TouchBarGroup,
+ TouchBarLabel,
+ TouchBarOtherItemsProxy,
+ TouchBarPopover,
+ TouchBarScrubber,
+ TouchBarSegmentedControl,
+ TouchBarSlider,
+ TouchBarSpacer,
+ WebRequest,
+} from 'electron/main';
+
+// Taken from `RemoteMainInterface`
+export var app: Electron.App;
+export var autoUpdater: Electron.AutoUpdater;
+export var BrowserView: typeof Electron.BrowserView;
+export var BrowserWindow: typeof Electron.BrowserWindow;
+export var clipboard: Electron.Clipboard;
+export var contentTracing: Electron.ContentTracing;
+export var crashReporter: Electron.CrashReporter;
+export var desktopCapturer: Electron.DesktopCapturer;
+export var dialog: Electron.Dialog;
+export var globalShortcut: Electron.GlobalShortcut;
+export var inAppPurchase: Electron.InAppPurchase;
+export var ipcMain: Electron.IpcMain;
+export var Menu: typeof Electron.Menu;
+export var MenuItem: typeof Electron.MenuItem;
+export var MessageChannelMain: typeof Electron.MessageChannelMain;
+export var nativeImage: typeof Electron.nativeImage;
+export var nativeTheme: Electron.NativeTheme;
+export var net: Electron.Net;
+export var netLog: Electron.NetLog;
+export var Notification: typeof Electron.Notification;
+export var powerMonitor: Electron.PowerMonitor;
+export var powerSaveBlocker: Electron.PowerSaveBlocker;
+export var protocol: Electron.Protocol;
+export var screen: Electron.Screen;
+export var session: typeof Electron.session;
+export var ShareMenu: typeof Electron.ShareMenu;
+export var shell: Electron.Shell;
+export var systemPreferences: Electron.SystemPreferences;
+export var TouchBar: typeof Electron.TouchBar;
+export var Tray: typeof Electron.Tray;
+export var webContents: typeof Electron.webContents;
+export var webFrameMain: typeof Electron.webFrameMain;
+
+// Taken from `Remote`
+export function getCurrentWebContents(): Electron.WebContents;
+export function getCurrentWindow(): Electron.BrowserWindow;
+export function getGlobal(name: string): any;
+export var process: NodeJS.Process;
+export var require: NodeJS.Require;
diff --git a/node_modules/@electron/remote/main/index.d.ts b/node_modules/@electron/remote/main/index.d.ts
new file mode 100644
index 0000000..ca7794d
--- /dev/null
+++ b/node_modules/@electron/remote/main/index.d.ts
@@ -0,0 +1 @@
+export * from '../dist/src/main';
diff --git a/node_modules/@electron/remote/main/index.js b/node_modules/@electron/remote/main/index.js
new file mode 100644
index 0000000..db95b8b
--- /dev/null
+++ b/node_modules/@electron/remote/main/index.js
@@ -0,0 +1 @@
+module.exports = require('../dist/src/main')
diff --git a/node_modules/@electron/remote/package.json b/node_modules/@electron/remote/package.json
new file mode 100644
index 0000000..b869d6a
--- /dev/null
+++ b/node_modules/@electron/remote/package.json
@@ -0,0 +1,46 @@
+{
+ "name": "@electron/remote",
+ "version": "2.0.10",
+ "main": "renderer/index.js",
+ "license": "MIT",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/electron/remote"
+ },
+ "peerDependencies": {
+ "electron": ">= 13.0.0"
+ },
+ "devDependencies": {
+ "@continuous-auth/semantic-release-npm": "^3.0.0",
+ "@types/chai": "^4.2.11",
+ "@types/chai-as-promised": "^7.1.2",
+ "@types/dirty-chai": "^2.0.2",
+ "@types/mocha": "^7.0.2",
+ "@types/node": "^14.17.0",
+ "chai": "^4.2.0",
+ "chai-as-promised": "^7.1.1",
+ "dirty-chai": "^2.0.1",
+ "electron": "22.x",
+ "mocha": "^10.1.0",
+ "mocha-junit-reporter": "^1.23.3",
+ "mocha-multi-reporters": "^1.1.7",
+ "ts-node": "^8.10.2",
+ "typescript": "^4.1.3",
+ "walkdir": "^0.4.1",
+ "yargs": "^15.3.1"
+ },
+ "scripts": {
+ "prepare": "tsc",
+ "test": "electron test --extension=ts --require=ts-node/register --exit --js-flags=--expose_gc",
+ "test:ci": "yarn test --reporter=mocha-multi-reporters --reporter-options=configFile=.circleci/mocha-reporter-config.json"
+ },
+ "files": [
+ "README.md",
+ "package.json",
+ "main",
+ "renderer",
+ "dist/src",
+ "index.d.ts"
+ ],
+ "types": "index.d.ts"
+}
diff --git a/node_modules/@electron/remote/renderer/index.d.ts b/node_modules/@electron/remote/renderer/index.d.ts
new file mode 100644
index 0000000..5ef2eaf
--- /dev/null
+++ b/node_modules/@electron/remote/renderer/index.d.ts
@@ -0,0 +1 @@
+export * from '../dist/src/renderer';
diff --git a/node_modules/@electron/remote/renderer/index.js b/node_modules/@electron/remote/renderer/index.js
new file mode 100644
index 0000000..dea07f1
--- /dev/null
+++ b/node_modules/@electron/remote/renderer/index.js
@@ -0,0 +1 @@
+module.exports = require('../dist/src/renderer')
diff --git a/out.html b/out.html
new file mode 100644
index 0000000..4320a68
--- /dev/null
+++ b/out.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <title>test</title>
+</head>
+<body>
+ <h1>Test app (shouldn't work)</h1>
+ <p>Hello, I am a page of a test application that you shouldn't be able to load</p>
+ <h2>Scroll me</h2>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias atque consectetur deserunt ducimus earum eum expedita ipsa itaque laudantium magnam nostrum, nulla pariatur quo repellat rerum saepe, ut vel voluptate.</p>
+</body>
+</html> \ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 465642b..a9b023f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5,6 +5,7 @@
"packages": {
"": {
"dependencies": {
+ "@electron/remote": "^2.0.10",
"electron": "^25.1.1",
"node-wifi": "^2.0.16",
"systeminformation": "^5.18.3",
@@ -31,6 +32,14 @@
"global-agent": "^3.0.0"
}
},
+ "node_modules/@electron/remote": {
+ "version": "2.0.10",
+ "resolved": "https://registry.npmjs.org/@electron/remote/-/remote-2.0.10.tgz",
+ "integrity": "sha512-3SFKKaQXcyWgwmibud+UqJl/XlHOgLcI3fwtB9pNelPSJAcTxocOJrF6FaxBIQaj1+R05Di6xuAswZpXAW7xhA==",
+ "peerDependencies": {
+ "electron": ">= 13.0.0"
+ }
+ },
"node_modules/@sindresorhus/is": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz",
diff --git a/package.json b/package.json
index 475e015..040beaa 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,6 @@
{
"dependencies": {
+ "@electron/remote": "^2.0.10",
"electron": "^25.1.1",
"node-wifi": "^2.0.16",
"systeminformation": "^5.18.3",
diff --git a/setup/rc.xml b/setup/rc.xml
index 53987e5..15d1a21 100644
--- a/setup/rc.xml
+++ b/setup/rc.xml
@@ -2,9 +2,20 @@
<openbox_config xmlns="http://openbox.org/3.4/rc"
xmlns:xi="http://www.w3.org/2001/XInclude">
+ <applications>
+ <application name="electron" role="devtools">
+ <layer>above</layer>
+ <decor>yes</decor>
+ </application>
+ <application name="electron" role="browser-window">
+ <layer>below</layer>
+ <decor>no</decor>
+ </application>
+ </applications>
+
<keyboard>
<chainQuitKey />
- <keybind key="A-Tab">
+ <keybind key="C-A-Tab">
<action name="NextWindow">
<finalactions>
<action name="Focus"/>