diff options
author | Minteck <contact@minteck.org> | 2022-05-18 18:50:12 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-05-18 18:50:12 +0200 |
commit | 0bd45cb2cae3af05adaad3f38d129bb67c3e0ec0 (patch) | |
tree | 97a7e15187fe7fcb5b8775e03a62f62ac8fc5c61 /kartik/crash | |
parent | d4805039b8ea7b30f5e78cf53caf8fd3f267256a (diff) | |
download | arcade-0bd45cb2cae3af05adaad3f38d129bb67c3e0ec0.tar.gz arcade-0bd45cb2cae3af05adaad3f38d129bb67c3e0ec0.tar.bz2 arcade-0bd45cb2cae3af05adaad3f38d129bb67c3e0ec0.zip |
Diffstat (limited to 'kartik/crash')
-rwxr-xr-x | kartik/crash/artwork.jpg | bin | 0 -> 83347 bytes | |||
-rwxr-xr-x | kartik/crash/client.js | 140 | ||||
-rwxr-xr-x | kartik/crash/crash.html | 72 | ||||
-rwxr-xr-x | kartik/crash/wrapper.js | 39 |
4 files changed, 251 insertions, 0 deletions
diff --git a/kartik/crash/artwork.jpg b/kartik/crash/artwork.jpg Binary files differnew file mode 100755 index 0000000..a999d22 --- /dev/null +++ b/kartik/crash/artwork.jpg diff --git a/kartik/crash/client.js b/kartik/crash/client.js new file mode 100755 index 0000000..95cc342 --- /dev/null +++ b/kartik/crash/client.js @@ -0,0 +1,140 @@ +taglines = [ + "Who set us up the engine?", + "Everything's going as planned. No, really, that was supposed to happen.", + "Uh... Did I do that? (oops)", + "Oops.", + "Why did you do that?", + "I feel sad now :(", + "My bad.", + "I'm sorry, Dave. I'm afraid I can't do that.", + "I let you down. Sorry :(", + "On the bright side, I bought you a teddy bear!", + "Oh - I know what I did wrong!", + "Hey, that tickles! Hehehe!", + "I blame Microsoft.", + "Don't be sad. I'll do better next time, pinky swear!", + "Don't be sad, have a hug! <3", + "I just don't know what went wrong :(", + "Shall we play a game?", + "Quite honestly, I wouldn't worry myself about that.", + "Sorry :(", + "Surprise! Haha. Well, this is awkward.", + "Would you like a cupcake?", + "Hi. I'm Kartik, and I'm a crashaholic.", + "Ooh. Shiny.", + "This doesn't make any sense!", + "Why is it breaking :(", + "Don't do that.", + "Ouch. That hurt :(", + "You're mean.", + "But it works on my machine.", + "Welp, I guess it's broken now.", + "¯\\_(ツ)_/¯", + "*boop*" +] + +if (native) { + function crash(error) { + id = new Date().toISOString().replaceAll(":", "-"); + + try { + global.pkg = require('./package.json'); + } catch (e) { + console.warn(e); + global.pkg = require('../package.json'); + + } + + try { + pubver = require('../package.json').version; + } catch (e) { + pubver = require('./package.json').version; + } + pvpart = pubver.split("."); + if (pvpart.length === 3) { + intver = pvpart[0] + "." + pvpart[1]; + } else { + intver = "unknown"; + } + + if (require('@electron/remote').getCurrentWindow().mods.length > 0) { + release = "mods+" + require('@electron/remote').getCurrentWindow().mods.length; + } else { + release = "official"; + } + + report = "---- Kartik Crash Report ----\n"; + report += "// " + taglines[Math.floor(Math.random() * taglines.length)] + "\n\n" + + report += "Time: " + new Date().toUTCString() + "\n\n"; + error.stack.split("\n").forEach((line) => { + report += line + "\n"; + }) + + report += "\n\n\nA detailed walkthrough of the error, its code path and all known details is as follows:\n" + + "---------------------------------------------------------------------------------------\n\n"; + + report += "-- Head --\nThread: Renderer #" + process.pid + "\n\n" + + report += "-- Initialization --\nDetails: " + require('@electron/remote').getCurrentWindow().cmdlineargs.join(" ") + "\n\n" + + report += "-- System Details --\nDetails: \n"; + + report += " Kartik Version: " + pkg.version + "\n"; + try { + channel = require('../package.json').channel; + } catch (e) { + channel = require('./package.json').channel; + } + report += " Kartik Version ID: " + intver + "/" + channel + "+" + release + "\n"; + report += " Kartik Version SKU: " + pkg.serial + "\n"; + report += " Operating System: " + require('os').type() + " (" + require('os').arch() + ") version " + require('os').release() + "\n"; + report += " Electron Version: " + process.versions.electron + "\n"; + report += " Electron VM Version: " + process.versions.v8 + "\n"; + report += " Node Version: " + process.versions.node + "\n"; + report += " Memory: " + process.memoryUsage().heapUsed + " bytes (" + Math.round(process.memoryUsage().heapUsed / 1000000) + " MB) / " + process.memoryUsage().heapTotal + " bytes (" + Math.round(process.memoryUsage().heapTotal / 1000000) + " MB) up to " + process.memoryUsage().rss + " bytes (" + Math.round(process.memoryUsage().rss / 1000000) + " MB)\n"; + report += " CPUs: " + require('os').cpus().length + "\n"; + if (require('@electron/remote').getCurrentWindow().mods.length > 0) { + report += " KMP Mods:\n"; + for (mod of require('@electron/remote').getCurrentWindow().mods) { + report += " " + mod + "\n"; + } + } + report += " Is Modded: "; + if (require('@electron/remote').getCurrentWindow().mods.length > 0) { + report += "Definitely; Client brand changed to 'kmp-client'" + } else if (require('@electron/remote').getCurrentWindow().invalidfiles.length > 0) { + if (require('@electron/remote').getCurrentWindow().invalidfiles.length > 1) { + report += "Very likely; " + require('@electron/remote').getCurrentWindow().invalidfiles.length + " signatures invalidated"; + } else { + report += "Very likely; " + require('@electron/remote').getCurrentWindow().invalidfiles.length + " signature invalidated"; + } + } else { + report += "Probably not. All signatures remains and client brand is untouched."; + } + report += "\n"; + report += " CPU: " + require('os').cpus().length + "x " + require('os').cpus()[0].model.trim() + "\n"; + + require('fs').copyFileSync(homedir + "/.kartik/current.kfn", homedir + "/.kartik/crashed.kfn"); + require('fs').writeFileSync(require('os').userInfo().homedir + "/.kartik/crashes/" + id + ".txt", report); + require('@electron/remote').getCurrentWindow().webContents.send("crashreport", report); + } + + window.onerror = (_a, _b, _c, _d, error) => { + if (typeof error != "undefined") { + crash(error); + } else { + error("CrashManager", "An exception was thrown without details about it"); + crash(new Error("Unknown error")); + } + } + + process.on('uncaughtException', (error) => { + if (typeof error != "undefined") { + crash(error); + } else { + error("CrashManager", "An exception was thrown without details about it"); + crash(new Error("Unknown error")); + } + }) +} diff --git a/kartik/crash/crash.html b/kartik/crash/crash.html new file mode 100755 index 0000000..ec4e5ca --- /dev/null +++ b/kartik/crash/crash.html @@ -0,0 +1,72 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <script src="../lang/loader.js"></script> + <meta charset="UTF-8"> + <script>document.title = lang.crash.title;</script> + <link rel="stylesheet" href="../views/common/fonts.css"> + <style> + + * { + font-family: -apple-system, sans-serif; + cursor: default !important; + font-family: "Comfortaa", -apple-system, sans-serif !important; + } + + button { + border: 1px solid #00b763; + padding: 10px 20px; + border-radius: 999px; + background: #fff; + color: black; + outline: none; + } + + button:hover { + color: white; + border: 1px solid #007b42; + background: #00b763; + } + + button:active { + color: white; + border: 1px solid #00502b; + background: #007b42; + } + + </style> +</head> +<body style="display:grid;grid-template-columns: 1fr 1fr;height:100%;width:100%;margin:0;overflow:hidden;"> + <div> + <img src="./artwork.jpg" style="height: 100vh;"> + </div> + <div style="padding:8px;"> + <h2><script>document.write(lang.crash.head);</script></h2> + <p><script>document.write(lang.crash.intro);</script></p> + <p><script> + document.write(lang.crash.report[0]); + if (require('os').platform() === "win32") { + document.write(require('os').userInfo().homedir + "\\.kartik\\crashes"); + } else { + document.write(require('os').userInfo().homedir + "/.kartik/crashes"); + } + document.write(lang.crash.report[1]); + </script></p> + <p><button onclick="restart();"><script>document.write(lang.crash.close);</script></button> <button onclick="resetrestart();"><script>document.write(lang.crash.reset);</script></button></p> + </div> + + <script> + function restart() { + window.close(); + require('@electron/remote').getCurrentWindow().hide(); + require('@electron/remote').getCurrentWindow().destroy(); + require('@electron/remote').getCurrentWindow().close(); + } + function resetrestart() { + require('fs').rmdirSync(require('os').userInfo().homedir + "/.kartik/config", {recursive:true}); + window.close(); + require('@electron/remote').getCurrentWindow().close(); + } + </script> +</body> +</html> diff --git a/kartik/crash/wrapper.js b/kartik/crash/wrapper.js new file mode 100755 index 0000000..16ecfd9 --- /dev/null +++ b/kartik/crash/wrapper.js @@ -0,0 +1,39 @@ +const { app, BrowserWindow } = require('electron') + +lp = "en"; + +function createWindow () { + const win = new BrowserWindow({ + width: 800, + height: 375, + resizeable: false, + resizable: false, + maximizable: false, + bgColor: "#ffffff", + title: "Kartik", + webPreferences: { + nodeIntegration: true, + contextIsolation: false, + enableRemoteModule: true, + webviewTag: true + } + }) + + win.lp = lp; + win.loadFile('crash.html') + win.setMenu(null); +} + +app.whenReady().then(createWindow) + +app.on('window-all-closed', () => { + if (process.platform !== 'darwin') { + app.quit() + } +}) + +app.on('activate', () => { + if (BrowserWindow.getAllWindows().length === 0) { + createWindow() + } +})
\ No newline at end of file |