2022-03-20 08:56:28 +00:00
|
|
|
import { Editor } from "./editor";
|
|
|
|
import { safeRun } from "./util";
|
2022-04-06 13:39:20 +00:00
|
|
|
import { WatchableSpace } from "./spaces/cache_space";
|
|
|
|
import { HttpRestSpace } from "./spaces/httprest_space";
|
2022-03-20 08:56:28 +00:00
|
|
|
|
2022-04-06 13:39:20 +00:00
|
|
|
// let localSpace = new WatchableSpace(new IndexedDBSpace("pages"), true);
|
|
|
|
// localSpace.watch();
|
|
|
|
let serverSpace = new WatchableSpace(new HttpRestSpace(""), true);
|
|
|
|
serverSpace.watch();
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
// window.syncer = async () => {
|
|
|
|
// let lastSync = +(localStorage.getItem("lastSync") || "0");
|
|
|
|
// let syncer = new SpaceSync(serverSpace, localSpace, lastSync, "_trash/");
|
|
|
|
// await syncer.syncPages(
|
|
|
|
// SpaceSync.primaryConflictResolver(serverSpace, localSpace)
|
|
|
|
// );
|
|
|
|
// localStorage.setItem("lastSync", "" + syncer.lastSync);
|
|
|
|
// console.log("Done!");
|
|
|
|
// };
|
|
|
|
let editor = new Editor(serverSpace, document.getElementById("root")!);
|
2022-03-20 08:56:28 +00:00
|
|
|
|
|
|
|
safeRun(async () => {
|
|
|
|
await editor.init();
|
|
|
|
});
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
window.editor = editor;
|
|
|
|
|
|
|
|
navigator.serviceWorker
|
|
|
|
.register(new URL("service_worker.ts", import.meta.url), { type: "module" })
|
|
|
|
.then((r) => {
|
2022-03-21 14:21:34 +00:00
|
|
|
// console.log("Service worker registered", r);
|
2022-03-20 08:56:28 +00:00
|
|
|
});
|