added two apps, and better implementation

This commit is contained in:
David Meincke
2022-03-22 18:20:26 +01:00
parent bb44e0e92d
commit 33b3f2e5cc
47 changed files with 486 additions and 151 deletions
+7
View File
@@ -0,0 +1,7 @@
import { NotificationBubbles } from "../../codeeditor-app/elements/notification-bubbles/notification-bubbles";
export function setOnErrorListener(fn: (type: 'syntax-error', value: any) => void) {
window.onerror = function (error) {
fn('syntax-error', error);
}
}
+12
View File
@@ -0,0 +1,12 @@
import { NotificationBubbles } from "../../codeeditor-app/elements/notification-bubbles/notification-bubbles";
export function tryCatch(fn: Function) {
try {
fn();
}
catch (err) {
var bubbles = <NotificationBubbles>parent.document.body.getElementsByTagName("notification-bubbles")[0];
//@ts-ignore
bubbles.add(err, 'syntax-error');
}
}
+28
View File
@@ -0,0 +1,28 @@
import { NotificationBubbles } from "../../codeeditor-app/elements/notification-bubbles/notification-bubbles";
export function watchConsole(fn: (type: 'log' | 'info' | 'warn' | 'error', value: any) => void) {
// define a new console
var console: any = (function (oldCons) {
return {
log: function (text: any) {
oldCons.log(text);
fn('log', text);
},
info: function (text: any) {
oldCons.info(text);
fn('info', text);
},
warn: function (text: any) {
oldCons.warn(text);
fn('warn', text);
},
error: function (text: any) {
oldCons.error(text);
fn('error', text);
}
};
}(window.console));
//Then redefine the old console
window.console = console;
}
+4
View File
@@ -0,0 +1,4 @@
setTimeout(() => {
window.stop();
console.log("window stopped");
}, 4 * 1000);