mirror of
https://github.com/danbulant/Mangades
synced 2026-05-19 04:08:46 +00:00
51 lines
No EOL
1.3 KiB
JavaScript
51 lines
No EOL
1.3 KiB
JavaScript
import HMR from '@roxi/routify/hmr'
|
|
import App from './App.svelte';
|
|
import { logs } from './util/logs';
|
|
|
|
function display(formatted, type) {
|
|
const displayed = {
|
|
text: formatted,
|
|
type
|
|
};
|
|
|
|
logs.update(toDisplay => {
|
|
toDisplay.push(displayed);
|
|
return toDisplay;
|
|
});
|
|
|
|
if(type !== "error") {
|
|
setTimeout(() => {
|
|
logs.update(toDisplay => {
|
|
const i = toDisplay.indexOf(displayed);
|
|
toDisplay.splice(i, 1);
|
|
return toDisplay;
|
|
});
|
|
}, 1000);
|
|
}
|
|
}
|
|
|
|
const error = console.error.bind(console);
|
|
window.console.error = (...args) => {
|
|
error(...args);
|
|
args = args.map(arg => {
|
|
if(typeof arg === "string") return arg;
|
|
if(arg instanceof Error) return arg.message + "\n" + arg.stack;
|
|
return JSON.stringify(arg);
|
|
});
|
|
display(args.join("\n"), "error");
|
|
}
|
|
|
|
window.onerror = (event, SourceBuffer, line, col, error) => {
|
|
error(error);
|
|
display(error.message + "\n" + error.stack, "error");
|
|
}
|
|
|
|
// const log = console.log.bind(console);
|
|
// window.console.log = (...args) => {
|
|
// log(...args);
|
|
// display(JSON.stringify(args), "log");
|
|
//}
|
|
|
|
const app = HMR(App, { target: document.body }, 'routify-app')
|
|
|
|
export default app; |