added two apps, and better implementation
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
setTimeout(() => {
|
||||
window.stop();
|
||||
console.log("window stopped");
|
||||
}, 4 * 1000);
|
||||
Reference in New Issue
Block a user