summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-06-30 15:28:20 +0200
committerRaindropsSys <contact@minteck.org>2023-06-30 15:28:20 +0200
commit4fdf74f2539d76ca4fb14e89f2e0a28f668d43fa (patch)
treefb05f463234a63a4a3f2e0eae0ad65fa0f6e2e71
parent8f654c94413fb639018431e2ef666931c1b232b1 (diff)
downloadkirinos-4fdf74f2539d76ca4fb14e89f2e0a28f668d43fa.tar.gz
kirinos-4fdf74f2539d76ca4fb14e89f2e0a28f668d43fa.tar.bz2
kirinos-4fdf74f2539d76ca4fb14e89f2e0a28f668d43fa.zip
Updated 8 files and added 4 files (automated)
-rw-r--r--ROADMAP.md2
-rw-r--r--apps/I like mangoes.mpi/app.json1
-rw-r--r--apps/I like mangoes.mpi/index.html10
-rw-r--r--core/about/index.html139
-rw-r--r--core/desktop/index.html99
-rw-r--r--core/desktop/wm.js65
-rw-r--r--core/launcher/icons/about.svg1
-rw-r--r--core/launcher/index.html22
-rw-r--r--demo/test.html9
-rw-r--r--init.sh3
-rw-r--r--lib/mangokit/index.js5
-rw-r--r--main.js1
12 files changed, 345 insertions, 12 deletions
diff --git a/ROADMAP.md b/ROADMAP.md
index bda794d..aa08c89 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -67,6 +67,8 @@
* [ ] Helper libraries **- Raindrops**
* [x] <s>`libmangoaudio` **- Raindrops**</s>
* *More if needed*
+* [ ] UI Toolkit **- Raindrops**
+ * *TBD*
* [ ] System apps
* [ ] Calculator
* [ ] System Monitor
diff --git a/apps/I like mangoes.mpi/app.json b/apps/I like mangoes.mpi/app.json
new file mode 100644
index 0000000..9e26dfe
--- /dev/null
+++ b/apps/I like mangoes.mpi/app.json
@@ -0,0 +1 @@
+{} \ No newline at end of file
diff --git a/apps/I like mangoes.mpi/index.html b/apps/I like mangoes.mpi/index.html
new file mode 100644
index 0000000..fac32f9
--- /dev/null
+++ b/apps/I like mangoes.mpi/index.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <title>Title</title>
+</head>
+<body>
+ <h1>mango</h1>
+</body>
+</html> \ No newline at end of file
diff --git a/core/about/index.html b/core/about/index.html
new file mode 100644
index 0000000..3b9231e
--- /dev/null
+++ b/core/about/index.html
@@ -0,0 +1,139 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <title>mango-about</title>
+ <script>
+ const si = require('systeminformation');
+ const release = require('../../release.json');
+
+ function formatSize(size) {
+ if (size > 1024) {
+ if (size > 1024**2) {
+ if (size > 1024**3) {
+ if (size > 1024**4) {
+ return Math.round(size / 1024**4) + " TB";
+ } else {
+ return Math.round(size / 1024**3) + " GB";
+ }
+ } else {
+ return Math.round(size / 1024**2) + " MB";
+ }
+ } else {
+ return Math.round(size / 1024) + " KB";
+ }
+ } else {
+ return size + " bytes";
+ }
+ }
+ </script>
+ <style>
+ * {
+ font-family: "Inter", sans-serif;
+ user-select: none;
+ user-focus: none;
+ outline: none;
+ }
+
+ ::-webkit-scrollbar {
+ width: 7px;
+ }
+
+ ::-webkit-scrollbar-track {
+ background: transparent;
+ }
+
+ ::-webkit-scrollbar-thumb {
+ background: rgba(0, 0, 0, .25);
+ border-radius: 999px;
+ }
+
+ ::-webkit-scrollbar-thumb:hover {
+ background: rgba(0, 0, 0, .35);
+ }
+
+ ::-webkit-scrollbar-thumb:active {
+ background: rgba(0, 0, 0, .5);
+ }
+
+ code {
+ font-family: "Roboto Mono", monospace !important;
+ }
+ </style>
+</head>
+<body>
+ <div style="position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;">
+ <div>
+ <div>
+ <img alt="" src="../../logo.svg" style="width: 96px; display: block; margin-left: auto; margin-right: auto;">
+ <span style="font-size: 24px; font-weight: bold; margin-top: 20px; margin-bottom: 20px; display: block; text-align: center;">mangoOS</span>
+ </div>
+ <table style="font-size: 12px;">
+ <tr>
+ <td style="opacity: .75; text-align: right; padding-right: 10px;">CPU</td>
+ <td style="opacity: .5;" id="about-cpu">-</td>
+ </tr>
+ <tr>
+ <td style="opacity: .75; text-align: right; padding-right: 10px;">Memory</td>
+ <td style="opacity: .5;" id="about-memory">-</td>
+ </tr>
+ <tr>
+ <td style="opacity: .75; text-align: right; padding-right: 10px;">Storage</td>
+ <td style="opacity: .5;" id="about-storage">-</td>
+ </tr>
+ <tr>
+ <td style="opacity: .75; text-align: right; padding-right: 10px;">Graphics</td>
+ <td style="opacity: .5;" id="about-gpu">-</td>
+ </tr>
+ <tr>
+ <td style="opacity: .75; text-align: right; padding-right: 10px;">mangoOS</td>
+ <td style="opacity: .5; line-height: 12px;" id="about-mangoos" onclick="changeVersion();">-</td>
+ </tr>
+ </table>
+ </div>
+
+ <script>
+ const child_process = require("child_process");
+
+ (async () => {
+ document.getElementById("about-mangoos").innerText = release['version'];
+
+ try {
+ document.getElementById("about-cpu").innerText = (await si.cpu()).brand;
+ } catch (e) {
+ document.getElementById("about-cpu").innerText = "-";
+ }
+
+ try {
+ document.getElementById("about-memory").innerText = formatSize((await si.mem()).total);
+ } catch (e) {
+ document.getElementById("about-memory").innerText = "-";
+ }
+
+ try {
+ let gpu = (await si.graphics())['controllers'][0];
+ if (gpu.vramDynamic) {
+ document.getElementById("about-gpu").innerText = gpu['model'];
+ } else {
+ document.getElementById("about-gpu").innerText = gpu['model'] + " " + formatSize(gpu.vram * 1024**2);
+ }
+ } catch (e) {
+ document.getElementById("about-gpu").innerText = "-";
+ }
+
+ try {
+ let systemPartition = (await si.blockDevices()).filter(i => i.mount === "/")[0];
+ let systemDisk = (await si.blockDevices()).filter(i => i.name === child_process.execSync("lsblk -no pkname " + systemPartition['device']).toString().trim().split("\n")[0].trim())[0];
+ document.getElementById("about-storage").innerText = formatSize(systemDisk.size) + " " + systemDisk.model;
+ } catch (e) {
+ document.getElementById("about-storage").innerText = "-";
+ }
+ })();
+
+ function changeVersion() {
+ document.getElementById("about-mangoos").innerHTML = release['shortVersion'] + " (<code>" + release['build'] + "</code>)";
+ }
+ </script>
+ </div>
+</body>
+</html> \ No newline at end of file
diff --git a/core/desktop/index.html b/core/desktop/index.html
index a57feb1..5a2111f 100644
--- a/core/desktop/index.html
+++ b/core/desktop/index.html
@@ -91,6 +91,11 @@
border: 1px solid rgba(0, 0, 0, .1);
}
+ .window.window-rounded {
+ border-bottom-left-radius: 7px;
+ border-bottom-right-radius: 7px;
+ }
+
.window-titlebar {
height: 32px;
border-top-left-radius: 7px;
@@ -122,6 +127,7 @@
}
.window-maximised {
+ border: none !important;
border-radius: 0 !important;
left: 0 !important;
right: 0 !important;
@@ -131,8 +137,7 @@
}
.window-titlebar-control-disabled {
- opacity: .5;
- pointer-events: none;
+ display: none !important;
}
.window.window-inactive .window-titlebar, .window.window-inactive .window-contents {
@@ -182,11 +187,73 @@
bottom: -5px;
cursor: nwse-resize;
}
+
+ .window-titlebar-frameless {
+ border: none !important;
+ background: none;
+ position: relative;
+ z-index: 999;
+ }
+
+ .window-titlebar-frameless .window-titlebar-title {
+ opacity: 0 !important;
+ }
+
+ .window-frameless .window-contents {
+ margin-top: -33px !important;
+ height: 100% !important;
+ }
+
+ #full-message {
+ backdrop-filter: blur(50px);
+ position: fixed;
+ inset: 0;
+ z-index: 9999999;
+ background: rgba(0, 0, 0, .25);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+
+ .full-message-item {
+ border: 1px solid rgba(0, 0, 0, .05);
+ border-radius: 7px;
+ box-shadow: 0 0 20px 7px rgba(0, 0, 0, .3);
+ background-color: rgba(255, 255, 255, .5);
+ width: 512px;
+ padding: 20px;
+ }
+
+ .full-message-button:hover {
+ background-color: rgba(255, 255, 255, .25) !important;
+ }
+
+ .full-message-button:active {
+ background-color: rgba(255, 255, 255, .1) !important;
+ }
</style>
</head>
<body>
<div id="bg"></div>
+ <div id="full-message" style="display: none;">
+ <div id="full-message-crash" class="full-message-item" style="display: none;">
+ <span style="display: block; font-size: 24px; text-align: center;"><b id="full-message-crash-app">App</b> quit unexpectedly</span>
+ <span style="display: block; max-width: 75%; margin: 20px auto;text-align: center;">This application has encountered an error and needs to close, unsaved data will be lost.</span>
+ <span style="width: max-content; margin: 0 auto; display: block; padding: 5px 10px; border-radius: 5px; background-color: rgba(255, 255, 255, .5); text-align: center;" class="full-message-button" onclick="document.getElementById('full-message').style.display='none';">Close</span>
+ </div>
+ <div id="full-message-invalid" class="full-message-item" style="display: none;">
+ <span style="display: block; font-size: 24px; text-align: center;"><b id="full-message-invalid-app">App</b> cannot start</span>
+ <span style="display: block; max-width: 75%; margin: 20px auto;text-align: center;">This application is corrupted or cannot run on this version of mangoOS.</span>
+ <span style="width: max-content; margin: 0 auto; display: block; padding: 5px 10px; border-radius: 5px; background-color: rgba(255, 255, 255, .5); text-align: center;" class="full-message-button" onclick="document.getElementById('full-message').style.display='none';">Close</span>
+ </div>
+ <div id="full-message-system" class="full-message-item" style="display: none;">
+ <span style="display: block; font-size: 24px; text-align: center;">mangoOS encountered an error</span>
+ <span style="display: block; max-width: 75%; margin: 20px auto;text-align: center;">Sorry, a system error occurred and your device needs to restart.</span>
+ <span style="width: max-content; margin: 0 auto; display: block; padding: 5px 10px; border-radius: 5px; background-color: rgba(255, 255, 255, .5); text-align: center;" class="full-message-button" onclick="reboot();">Restart</span>
+ </div>
+ </div>
+
<div id="status-outer">
<iframe style="display: flex; height: 100%; width: 100%;" id="status" src="../status/index.html"></iframe>
</div>
@@ -214,10 +281,11 @@
<script src="./wm.js"></script>
<script>
- const wm = new WindowManager();
+ const wm = window.wm = new WindowManager();
wm.createWindow({
title: "Test Window",
- sandbox: false,
+ sandbox: true,
+ frameless: false,
debuggable: true,
isolatedPath: "/mango/demo",
url: "file:///mango/demo/test.html"
@@ -281,6 +349,29 @@
document.body.style.pointerEvents = "none";
location.href = "../login/index.html";
}
+
+ function startApp(file) {
+ let name = path.basename(file, path.extname(file));
+
+ try {
+ let config = JSON.parse(fs.readFileSync(file + "/app.json").toString());
+ if (!fs.existsSync(file + "/index.html")) throw new Error("No index.html found");
+
+ config['application'] = file;
+ config['title'] = name;
+ config['sandbox'] = true;
+ config['isolatedPath'] = file;
+ config['url'] = "file://" + file + "/index.html";
+
+ wm.createWindow(config);
+ } catch (e) {
+ console.error(e);
+ document.getElementById("full-message-invalid-app").innerText = name;
+ Array.from(document.getElementsByClassName("full-message-item")).forEach(i => i.style.display = "none");
+ document.getElementById("full-message-invalid").style.display = "";
+ document.getElementById("full-message").style.display = "";
+ }
+ }
</script>
</body>
</html> \ No newline at end of file
diff --git a/core/desktop/wm.js b/core/desktop/wm.js
index 1281494..35dc7bf 100644
--- a/core/desktop/wm.js
+++ b/core/desktop/wm.js
@@ -218,6 +218,8 @@ class WindowManager {
this.#properties[id] = {
title: options['title'] ?? "(none)",
isolatedPath: options['isolatedPath'] ?? "",
+ frameless: options['frameless'] ?? false,
+ rounded: options['rounded'] ?? false,
minWidth: options['minWidth'] ?? 64,
minHeight: options['minHeight'] ?? 64,
maxWidth: options['maxWidth'] ?? Infinity,
@@ -244,14 +246,14 @@ class WindowManager {
}
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 onmousedown="wm.focusWindow('${id}');" class="window ${this.#properties[id]['frameless'] ? "window-frameless" : ""} ${this.#properties[id]['rounded'] ? "window-rounded" : ""}" 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 ${this.#properties[id]['frameless'] ? "window-titlebar-frameless" : ""}" id="window-${id}-titlebar">
<div class="window-titlebar-controls" id="window-${id}-titlebar-controls">
<a onclick="wm.closeWindow('${id}');" class="window-titlebar-control window-titlebar-control-close ${!this.#properties[id]['closable'] ? "window-titlebar-control-disabled" : ""}" id="window-${id}-titlebar-control-close" style="padding: 4px; vertical-align: middle; width: 24px; height: 24px; display: inline-block;border-top-left-radius: 7px;">
<img src="./icons/close.svg" style="width: 24px; vertical-align: middle;">
- </a><a onclick="wm.toggleMinimisedWindow('${id}');" class="window-titlebar-control window-titlebar-control-minimise ${!this.#properties[id]['maximizable'] ? "window-titlebar-control-disabled" : ""}" id="window-${id}-titlebar-control-minimise" style="padding: 4px; vertical-align: middle; width: 24px; height: 24px; display: inline-block;">
+ </a><a onclick="wm.toggleMinimisedWindow('${id}');" class="window-titlebar-control window-titlebar-control-minimise ${!this.#properties[id]['minimizable'] ? "window-titlebar-control-disabled" : ""}" id="window-${id}-titlebar-control-minimise" style="padding: 4px; vertical-align: middle; width: 24px; height: 24px; display: inline-block;">
<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;">
+ </a><a onclick="wm.toggleMaximisedWindow('${id}');" class="window-titlebar-control window-titlebar-control-maximise ${!this.#properties[id]['maximizable'] ? "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>${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;">
@@ -260,7 +262,7 @@ class WindowManager {
<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 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>
+ <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 webpreferences=\"contextIsolation=no,sandbox=no\"" : "webpreferences=\"sandbox=no\""}></webview>
</div>
${this.#properties[id]['resizable'] ? `
<div class="window-anchors" id="window-${id}-anchors">
@@ -282,6 +284,27 @@ class WindowManager {
let webContents = i.#properties[id].webContents = require("@electron/remote").webContents.fromId(document.getElementById("window-" + id + "-contents-webview").getWebContentsId());
let isolatedPath = i.#properties[id].isolatedPath;
+ let name = i.#properties[id]['application'] ?? i.#properties[id]['title'];
+
+ document.getElementById("window-" + id + "-contents-webview").addEventListener('page-title-updated', (event) => {
+ console.info("Updated title for " + id + ": " + event['title'] + " (" + event['explicitSet'] + ")");
+
+ if (event['explicitSet']) {
+ wm.getWindow(id).title = event['title'];
+ } else {
+ wm.getWindow(id).title = name;
+ }
+ });
+
+ document.getElementById("window-" + id + "-contents-webview").addEventListener('ipc-message', (event) => {
+ if (event.channel === "crash") {
+ wm.closeWindow(id);
+ document.getElementById("full-message-crash-app").innerText = name;
+ Array.from(document.getElementsByClassName("full-message-item")).forEach(i => i.style.display = "none");
+ document.getElementById("full-message-crash").style.display = "";
+ document.getElementById("full-message").style.display = "";
+ }
+ });
webContents.session.on('will-download', (event, item, webContents) => {
item.cancel()
@@ -297,6 +320,8 @@ class WindowManager {
webContents.devToolsWebContents.focus();
});
+ let systemPath = "/mango/shared";
+
webContents.session.webRequest.onBeforeRequest({
urls: [
"file://*/*",
@@ -306,7 +331,7 @@ class WindowManager {
"wss://*/*"
]
}, (details, cb) => {
- if (details.url.startsWith("file://") && !details.url.startsWith("file://" + isolatedPath + "/")) {
+ if (details.url.startsWith("file://") && !details.url.startsWith("file://" + isolatedPath + "/") && !details.url.startsWith("file://" + systemPath + "/")) {
console.error("Prevented " + id + " from accessing " + details.url + ", application is limited to files within file://" + isolatedPath + "/");
cb({
@@ -340,6 +365,20 @@ class WindowManager {
cancel: true
});
}
+ } else if (details.url.startsWith("file://" + systemPath + "/")) {
+ if (path.resolve(systemPath + details.url.substring(7)).startsWith(systemPath + "/")) {
+ 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);
@@ -354,6 +393,20 @@ class WindowManager {
cancel: true
});
}
+ } else if (details.url.startsWith("shared://")) {
+ if (path.resolve(systemPath + details.url.substring(6)).startsWith(systemPath + "/")) {
+ console.error("Serving " + id + " with " + details.url);
+
+ cb({
+ redirectURL: "file://" + systemPath + 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");
diff --git a/core/launcher/icons/about.svg b/core/launcher/icons/about.svg
new file mode 100644
index 0000000..cb0add7
--- /dev/null
+++ b/core/launcher/icons/about.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M453-280h60v-240h-60v240Zm26.982-314q14.018 0 23.518-9.2T513-626q0-14.45-9.482-24.225-9.483-9.775-23.5-9.775-14.018 0-23.518 9.775T447-626q0 13.6 9.482 22.8 9.483 9.2 23.5 9.2Zm.284 514q-82.734 0-155.5-31.5t-127.266-86q-54.5-54.5-86-127.341Q80-397.681 80-480.5q0-82.819 31.5-155.659Q143-709 197.5-763t127.341-85.5Q397.681-880 480.5-880q82.819 0 155.659 31.5Q709-817 763-763t85.5 127Q880-563 880-480.266q0 82.734-31.5 155.5T763-197.684q-54 54.316-127 86Q563-80 480.266-80Zm.234-60Q622-140 721-239.5t99-241Q820-622 721.188-721 622.375-820 480-820q-141 0-240.5 98.812Q140-622.375 140-480q0 141 99.5 240.5t241 99.5Zm-.5-340Z"/></svg> \ No newline at end of file
diff --git a/core/launcher/index.html b/core/launcher/index.html
index 6e1f29d..0087835 100644
--- a/core/launcher/index.html
+++ b/core/launcher/index.html
@@ -62,6 +62,9 @@
</div>
<div></div>
<div style="margin: 16px 8px;">
+ <a onclick="parent.closeMenu(); openAbout();" id="icon-about" style="display: flex; align-items: center; justify-content: center; margin-left: auto; margin-right: auto; height: 32px; width: 32px; vertical-align: middle;" class="icon">
+ <img src="./icons/about.svg" alt="" style="width: 24px; height: 24px; vertical-align: middle;">
+ </a>
<a id="icon-settings" style="display: flex; align-items: center; justify-content: center; margin-left: auto; margin-right: auto; height: 32px; width: 32px; vertical-align: middle;" class="icon">
<img src="./icons/settings.svg" alt="" style="width: 24px; height: 24px; vertical-align: middle;">
</a>
@@ -94,5 +97,24 @@
</script>
</div>
</div>
+
+ <script>
+ function openAbout() {
+ parent.wm.createWindow({
+ title: "About mangoOS",
+ sandbox: false,
+ frameless: true,
+ debuggable: false,
+ resizable: false,
+ rounded: true,
+ width: 288,
+ height: 384,
+ minimizable: false,
+ maximizable: false,
+ isolatedPath: "/mango",
+ url: "file:///mango/core/about/index.html"
+ });
+ }
+ </script>
</body>
</html> \ No newline at end of file
diff --git a/demo/test.html b/demo/test.html
index f8b9504..488e8cc 100644
--- a/demo/test.html
+++ b/demo/test.html
@@ -5,8 +5,17 @@
<title>test</title>
</head>
<body>
+ <script>
+ window.addEventListener('error', (event, source, lineno, colno, error) => {
+ MangoKit._crash();
+ return false;
+ });
+ </script>
+
<h1>Test app</h1>
<p>Hello, I am a test application</p>
+ <button onclick="thisDoesNotExist();">Crash</button>
+ <button onclick="document.title='hello :)';">Title</button>
<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>
diff --git a/init.sh b/init.sh
index c258294..8021625 100644
--- a/init.sh
+++ b/init.sh
@@ -5,4 +5,5 @@ xset -dpms
xset s off
openbox&
./node_modules/electron/dist/electron --no-sandbox main.js > mango.log
-xterm \ No newline at end of file
+xterm
+
diff --git a/lib/mangokit/index.js b/lib/mangokit/index.js
index a13a386..493f2ba 100644
--- a/lib/mangokit/index.js
+++ b/lib/mangokit/index.js
@@ -1,5 +1,8 @@
-const { contextBridge } = require('electron');
+const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld("MangoKit", {
+ _crash: () => {
+ ipcRenderer.sendToHost("crash");
+ }
// TODO: Add stuff
}); \ No newline at end of file
diff --git a/main.js b/main.js
index 551e9bc..fa7d208 100644
--- a/main.js
+++ b/main.js
@@ -14,6 +14,7 @@ const createWindow = () => {
maximizable: true,
fullscreenable: false,
webPreferences: {
+ sandbox: false,
webviewTag: true,
nodeIntegration: true,
contextIsolation: false,