1
0
silverbullet/web/boot.ts

41 lines
1.0 KiB
TypeScript
Raw Normal View History

import { safeRun } from "../common/util.ts";
import { Editor } from "./editor.tsx";
safeRun(async () => {
console.log("Booting");
const editor = new Editor(
document.getElementById("sb-root")!,
);
window.editor = editor;
2022-10-25 16:50:07 +00:00
await editor.init();
});
if (navigator.serviceWorker) {
navigator.serviceWorker
2022-11-24 11:04:00 +00:00
.register(new URL("/service_worker.js", location.href), {
type: "module",
})
2022-11-24 15:55:30 +00:00
.then(() => {
console.log("Service worker registered...");
});
navigator.serviceWorker.ready.then((registration) => {
registration.active!.postMessage({
type: "config",
config: window.silverBulletConfig,
});
});
} else {
console.warn(
"Not launching service worker, likely because not running from localhost or over HTTPs. This means SilverBullet will not be available offline.",
);
}
2023-05-24 03:42:24 +00:00
if (!globalThis.indexedDB) {
alert(
"SilverBullet requires IndexedDB to operate and it is not available in your browser. Please use a recent version of Chrome, Firefox (not in private mode) or Safari.",
);
}