1
0
silverbullet/mobile/html/boot.ts

49 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-03-07 09:21:02 +00:00
import { Editor } from "../../webapp/src/editor";
2022-03-15 13:03:00 +00:00
import { Space } from "../../webapp/src/space";
2022-03-07 09:21:02 +00:00
declare namespace window {
var ReactNativeWebView: any;
var receiveMessage: any;
}
function safeRun(fn: () => Promise<void>) {
fn().catch((e) => {
console.error(e);
});
}
window.receiveMessage = (msg: string) => {
console.log("Received message", msg);
};
// @ts-ignore
window.onerror = (msg, source, lineno, colno, error) => {
console.error("Error", msg, source, lineno, error);
};
console.log = (...args) => {
window.ReactNativeWebView.postMessage(
JSON.stringify({ type: "console.log", args: args })
);
};
console.error = (...args) => {
window.ReactNativeWebView.postMessage(
JSON.stringify({ type: "console.error", args: args })
);
};
try {
2022-03-15 13:03:00 +00:00
// let editor = new Editor(
// new Space(`http://192.168.2.22:3000/fs`, null),
// document.getElementById("root")!
// );
// console.log("Initing editor");
// safeRun(async () => {
// await editor.loadPageList();
// await editor.loadPlugs();
// editor.focus();
// console.log("Inited", editor.viewState);
// });
2022-03-07 09:21:02 +00:00
} catch (e: any) {
console.error("Got an error", e.message);
}