Cleanup
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { Editor } from "../../webapp/src/editor";
|
||||
import { HttpRemoteSpace } from "../../webapp/src/space";
|
||||
|
||||
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 {
|
||||
let editor = new Editor(
|
||||
new HttpRemoteSpace(`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);
|
||||
});
|
||||
} catch (e: any) {
|
||||
console.error("Got an error", e.message);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Page</title>
|
||||
<style>
|
||||
@import "../../webapp/src/styles/main.scss";
|
||||
</style>
|
||||
<script type="module" src="boot.ts"></script>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module">
|
||||
import "./boot";
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user