2023-05-24 02:53:53 +08:00
|
|
|
import { safeRun } from "../common/util.ts";
|
2022-10-10 20:50:21 +08:00
|
|
|
import { Editor } from "./editor.tsx";
|
|
|
|
|
|
|
|
safeRun(async () => {
|
2023-05-24 02:53:53 +08:00
|
|
|
console.log("Booting");
|
2022-10-10 20:50:21 +08:00
|
|
|
|
|
|
|
const editor = new Editor(
|
|
|
|
document.getElementById("sb-root")!,
|
|
|
|
);
|
2023-05-24 02:53:53 +08:00
|
|
|
|
2022-10-10 20:50:21 +08:00
|
|
|
window.editor = editor;
|
2022-10-26 00:50:07 +08:00
|
|
|
|
|
|
|
await editor.init();
|
2022-10-10 20:50:21 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
if (navigator.serviceWorker) {
|
|
|
|
navigator.serviceWorker
|
2022-11-24 19:04:00 +08:00
|
|
|
.register(new URL("/service_worker.js", location.href), {
|
2022-10-10 20:50:21 +08:00
|
|
|
type: "module",
|
|
|
|
})
|
2022-11-24 23:55:30 +08:00
|
|
|
.then(() => {
|
2022-10-10 20:50:21 +08:00
|
|
|
console.log("Service worker registered...");
|
|
|
|
});
|
2023-05-24 02:53:53 +08:00
|
|
|
navigator.serviceWorker.ready.then((registration) => {
|
|
|
|
registration.active!.postMessage({
|
|
|
|
type: "config",
|
|
|
|
config: window.silverBulletConfig,
|
|
|
|
});
|
|
|
|
});
|
2022-10-10 20:50:21 +08:00
|
|
|
} else {
|
2023-05-24 02:53:53 +08:00
|
|
|
console.warn(
|
|
|
|
"Not launching service worker, likely because not running from localhost or over HTTPs. This means SilverBullet will not be available offline.",
|
2022-10-10 20:50:21 +08:00
|
|
|
);
|
|
|
|
}
|