Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(client): show a startup splash screen instead of a white screen
Claude64574dd08907
diff --git a/apps/client/index.html b/apps/client/index.htmlindex 12f653666f..943f9f4d43 100644--- a/apps/client/index.html+++ b/apps/client/index.html@@ -8,11 +8,121 @@<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover, interactive-widget=resizes-content" /><link rel="manifest" crossorigin="use-credentials" href="manifest.webmanifest"><title>Trilium Notes</title>+ <style>+ /* Startup splash. Inline so it renders before any script or stylesheet is fetched;+ apps/client/src/services/splash.ts drives the status line and removes the element+ once the application has loaded. */+ #splash {+ position: fixed;+ inset: 0;+ z-index: 10000;+ display: flex;+ align-items: center;+ justify-content: center;+ background: #ffffff;+ color: #666666;+ font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;+ transition: opacity 0.4s ease;+ }+ #splash.splash-hidden {+ opacity: 0;+ pointer-events: none;+ }+ #splash .splash-content {+ display: flex;+ flex-direction: column;+ align-items: center;+ /* Fades in after a delay, so a fast startup shows a blank page instead of a+ flash of logo. */+ opacity: 0;+ animation: splash-appear 0.4s ease 0.3s forwards;+ }+ #splash .splash-logo {+ width: 96px;+ height: 96px;+ }+ #splash .splash-title {+ margin-top: 16px;+ font-size: 22px;+ font-weight: 600;+ letter-spacing: 0.02em;+ color: #333333;+ }+ #splash .splash-bar {+ width: 176px;+ height: 3px;+ margin-top: 24px;+ border-radius: 2px;+ overflow: hidden;+ background: rgba(128, 128, 128, 0.2);+ }+ #splash .splash-bar-fill {+ width: 40%;+ height: 100%;+ border-radius: 2px;+ background: #72b755;+ animation: splash-slide 1.4s ease-in-out infinite;+ }+ #splash-status {+ min-height: 1.5em;+ margin-top: 12px;+ font-size: 13px;+ text-align: center;+ }+ #splash.splash-error .splash-bar {+ display: none;+ }+ #splash.splash-error #splash-status {+ max-width: min(480px, 85vw);+ color: #e33f3b;+ }+ @keyframes splash-appear {+ to { opacity: 1; }+ }+ @keyframes splash-slide {+ 0% { transform: translateX(-110%); }+ 100% { transform: translateX(260%); }+ }+ @keyframes splash-pulse {+ 0%, 100% { opacity: 0.3; }+ 50% { opacity: 1; }+ }+ @media (prefers-color-scheme: dark) {+ #splash { background: #242424; color: #999999; }+ #splash .splash-title { color: #cccccc; }+ }+ @media (prefers-reduced-motion: reduce) {+ #splash .splash-content { opacity: 1; animation: none; }+ #splash .splash-bar-fill { width: 100%; animation: splash-pulse 1.8s ease-in-out infinite; }+ }+ @media print {+ #splash { display: none; }+ }+ </style></head><body id="trilium-app"><noscript>Trilium requires JavaScript to be enabled.</noscript>+ <div id="splash" role="status">+ <div class="splash-content">+ <svg class="splash-logo" viewBox="0 0 256 256" aria-hidden="true">+ <path fill="#95C980" d="m202.9 112.7c-22.5 16.1-54.5 12.8-74.9 6.3l14.8-11.8 14.1-11.3 49.1-39.3-51.2 35.9-14.3 10-14.9 10.5c0.7-21.2 7-49.9 28.6-65.4 1.8-1.3 3.9-2.6 6.1-3.8 2.7-1.5 5.7-2.9 8.8-4.1 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.9 65.9-2.4 2.8-4.9 5.4-7.4 7.8-3.4 3.5-6.8 6.4-10.1 8.8z"/>+ <path fill="#72B755" d="m213.1 104c-22.2 12.6-51.4 9.3-70.3 3.2l14.1-11.3 49.1-39.3-51.2 35.9-14.3 10c0.5-18.1 4.9-42.1 19.7-58.6 2.7-1.5 5.7-2.9 8.8-4.1 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.9 65.9-2.3 2.8-4.8 5.4-7.2 7.8z"/>+ <path fill="#4FA52B" d="m220.5 96.2c-21.1 8.6-46.6 5.3-63.7-0.2l49.2-39.4-51.2 35.9c0.3-15.8 3.5-36.6 14.3-52.8 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.8 66z"/>+ <path fill="#EE8C89" d="m106.7 179c-5.8-21 5.2-43.8 15.5-57.2l4.8 14.2 4.5 13.4 15.9 47-12.8-47.6-3.6-13.2-3.7-13.9c15.5 6.2 35.1 18.6 40.7 38.8 0.5 1.7 0.9 3.6 1.2 5.5 0.4 2.4 0.6 5 0.7 7.7 0.9 23.1-7.1 54.9-15.9 65.7-12-4.3-29.3-24-39.7-42.8-1.4-2.6-2.7-5.1-3.8-7.6-1.6-3.5-2.9-6.8-3.8-10z"/>+ <path fill="#E96562" d="m110.4 188.9c-3.4-19.8 6.9-40.5 16.6-52.9l4.5 13.4 15.9 47-12.8-47.6-3.6-13.2c13.3 5.2 29.9 15 38.1 30.4 0.4 2.4 0.6 5 0.7 7.7 0.9 23.1-7.1 54.9-15.9 65.7-12-4.3-29.3-24-39.7-42.8-1.4-2.6-2.7-5.2-3.8-7.7z"/>+ <path fill="#E33F3B" d="m114.2 196.5c-0.7-18 8.6-35.9 17.3-47.1l15.9 47-12.8-47.6c11.6 4.4 26.1 12.4 35.2 24.8 0.9 23.1-7.1 54.9-15.9 65.7-12-4.3-29.3-24-39.7-42.8z"/>+ <path fill="#EFB075" d="m86.3 59.1c21.7 10.9 32.4 36.6 35.8 54.9l-15.2-6.6-14.5-6.3-50.6-22 48.8 24.9 13.6 6.9 14.3 7.3c-16.6 7.9-41.3 14.5-62.1 4.1-1.8-0.9-3.6-1.9-5.4-3.2-2.3-1.5-4.5-3.2-6.8-5.1-19.9-16.4-40.3-46.4-42.7-61.5 12.4-6.5 41.5-5.8 64.8-0.3 3.2 0.8 6.2 1.6 9.1 2.5 4 1.3 7.6 2.8 10.9 4.4z"/>+ <path fill="#E99547" d="m75.4 54.8c18.9 12 28.4 35.6 31.6 52.6l-14.5-6.3-50.6-22 48.7 24.9 13.6 6.9c-14.1 6.8-34.5 13-53.3 8.2-2.3-1.5-4.5-3.2-6.8-5.1-19.8-16.4-40.2-46.4-42.6-61.5 12.4-6.5 41.5-5.8 64.8-0.3 3.1 0.8 6.2 1.6 9.1 2.6z"/>+ <path fill="#E47B19" d="m66.3 52.2c15.3 12.8 23.3 33.6 26.1 48.9l-50.6-22 48.8 24.9c-12.2 6-29.6 11.8-46.5 10-19.8-16.4-40.2-46.4-42.6-61.5 12.4-6.5 41.5-5.8 64.8-0.3z"/>+ </svg>+ <div class="splash-title">Trilium Notes</div>+ <div class="splash-bar"><div class="splash-bar-fill"></div></div>+ <div id="splash-status"></div>+ </div>+ </div>+<div id="context-menu-cover"></div><div class="dropdown-menu dropdown-menu-sm" id="context-menu-container" style="display: none"></div>diff --git a/apps/client/src/index.ts b/apps/client/src/index.tsindex bc7f9d6d9a..9d0df69a9b 100644--- a/apps/client/src/index.ts+++ b/apps/client/src/index.ts@@ -1,8 +1,11 @@import { createFontStylesheetLink } from "./services/font";+import { hideSplash, showSplashError, updateSplashStatus } from "./services/splash";import { buildThemeStylesheetRefs, createStylesheetLink, getThemeStyle, initThemeChangeNotifier, StylesheetRef } from "./services/theme";async function bootstrap() {- showSplash();+ // The splash from index.html covers the page until hideSplash(). In standalone mode this+ // fetch waits for the SQLite worker to open the database, which can take a while.+ updateSplashStatus("Opening your notes…");await setupGlob();await Promise.all([initJQuery(),@@ -12,6 +15,7 @@ async function bootstrap() {initThemeChangeNotifier();loadIcons();setBodyAttributes();+ updateSplashStatus("Loading the application…");await loadScripts();hideSplash();}@@ -170,13 +174,8 @@ async function loadScripts() {}}-function showSplash() {- // hide body to reduce flickering on the startup. This is done through JS and not CSS to not hide <noscript>- document.body.style.display = "none";-}--function hideSplash() {- document.body.style.display = "block";-}--bootstrap();+bootstrap().catch((err) => {+ console.error("Trilium failed to start:", err);+ const message = err instanceof Error ? err.message : String(err);+ showSplashError(`Trilium failed to start: ${message} — reload the page to try again.`);+});diff --git a/apps/client/src/services/splash.spec.ts b/apps/client/src/services/splash.spec.tsnew file mode 100644index 0000000000..bebb7fb179--- /dev/null+++ b/apps/client/src/services/splash.spec.ts@@ -0,0 +1,52 @@+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";++import { hideSplash, showSplashError, updateSplashStatus } from "./splash";++function renderSplash() {+ document.body.innerHTML = `+ <div id="splash">+ <div class="splash-bar"></div>+ <div id="splash-status"></div>+ </div>`;+}++beforeEach(() => {+ vi.useFakeTimers();+});++afterEach(() => {+ vi.useRealTimers();+ document.body.innerHTML = "";+});++describe("splash", () => {+ it("updates the status line and switches to the error state", () => {+ renderSplash();++ updateSplashStatus("Opening your notes…");+ expect(document.getElementById("splash-status")?.textContent).toBe("Opening your notes…");++ showSplashError("something broke");+ expect(document.getElementById("splash")?.classList.contains("splash-error")).toBe(true);+ expect(document.getElementById("splash-status")?.textContent).toBe("something broke");+ });++ it("fades the splash out and removes it once the transition has run", () => {+ renderSplash();++ hideSplash();+ const splash = document.getElementById("splash");+ expect(splash?.classList.contains("splash-hidden")).toBe(true);++ vi.runAllTimers();+ expect(document.getElementById("splash")).toBeNull();+ });++ it("does nothing when the splash is not in the document", () => {+ expect(() => {+ updateSplashStatus("status");+ showSplashError("error");+ hideSplash();+ }).not.toThrow();+ });+});diff --git a/apps/client/src/services/splash.ts b/apps/client/src/services/splash.tsnew file mode 100644index 0000000000..6bce3ba02d--- /dev/null+++ b/apps/client/src/services/splash.ts@@ -0,0 +1,40 @@+/**+ * Drives the startup splash screen that index.html renders inline, before any script or+ * stylesheet is fetched. Status strings are English-only, as in the standalone error overlay:+ * the splash runs while the backend that serves the translation catalogues is still starting,+ * so no catalogue can be loaded yet.+ *+ * Kept free of imports: index.ts loads it before setupGlob() populates window.glob, which most+ * client modules read at module scope.+ */++/** Matches the `#splash` opacity transition in index.html. */+const SPLASH_FADE_MS = 400;++/** Replaces the status line under the progress bar. */+export function updateSplashStatus(status: string): void {+ const statusEl = document.getElementById("splash-status");+ if (statusEl) {+ statusEl.textContent = status;+ }+}++/** Switches the splash to its error state: the progress bar goes away and the message shows. */+export function showSplashError(message: string): void {+ const splashEl = document.getElementById("splash");+ if (!splashEl) {+ return;+ }+ splashEl.classList.add("splash-error");+ updateSplashStatus(message);+}++/** Fades the splash out and removes it, revealing the application behind it. */+export function hideSplash(): void {+ const splashEl = document.getElementById("splash");+ if (!splashEl) {+ return;+ }+ splashEl.classList.add("splash-hidden");+ setTimeout(() => splashEl.remove(), SPLASH_FADE_MS);+}diff --git a/apps/standalone/src/error-overlay.spec.ts b/apps/standalone/src/error-overlay.spec.tsindex 4c9f5e3ea4..0bfa63f126 100644--- a/apps/standalone/src/error-overlay.spec.ts+++ b/apps/standalone/src/error-overlay.spec.ts@@ -9,7 +9,6 @@ async function freshOverlay(): Promise<typeof import("./error-overlay.js")> {beforeEach(() => {document.body.innerHTML = "";- document.body.style.display = "";});afterEach(() => {@@ -17,9 +16,9 @@ afterEach(() => {});describe("showErrorOverlay", () => {- it("renders the title, message, detail and a reload button, and reveals the body", async () => {+ it("renders title, message, detail and a reload button, and removes the splash", async () => {const { showErrorOverlay } = await freshOverlay();- document.body.style.display = "none";+ document.body.innerHTML = `<div id="splash"></div>`;showErrorOverlay("Trilium couldn't start", "MIME type wrong", "at worker.js:1");@@ -29,8 +28,8 @@ describe("showErrorOverlay", () => {expect(overlay?.textContent).toContain("MIME type wrong");expect(overlay?.querySelector("pre")?.textContent).toBe("at worker.js:1");expect(overlay?.querySelector("button")?.textContent).toBe("Reload");- // The pre-client shell may hide the body; the overlay must un-hide it.- expect(document.body.style.display).toBe("block");+ // The startup splash sits above everything and would cover the overlay.+ expect(document.getElementById("splash")).toBeNull();});it("omits the detail block when no detail is given", async () => {diff --git a/apps/standalone/src/error-overlay.ts b/apps/standalone/src/error-overlay.tsindex e312d232cf..90cc9c4223 100644--- a/apps/standalone/src/error-overlay.ts+++ b/apps/standalone/src/error-overlay.ts@@ -31,9 +31,8 @@ export function showErrorOverlay(title: string, message: string, detail?: string}shown = true;- // The pre-client shell may still be hiding the body; reveal it so the- // overlay is actually visible (mirrors main.ts's bootstrap catch).- document.body.style.display = "block";+ // The startup splash sits above everything and would cover the overlay.+ document.getElementById("splash")?.remove();// Defensive: never stack two overlays if one was somehow left behind.document.getElementById(OVERLAY_ID)?.remove();diff --git a/apps/standalone/src/index.html b/apps/standalone/src/index.htmlindex 23b5a1fe34..eedf279c59 100644--- a/apps/standalone/src/index.html+++ b/apps/standalone/src/index.html@@ -8,11 +8,121 @@<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover" /><link rel="manifest" crossorigin="use-credentials" href="manifest.webmanifest"><title>Trilium Notes</title>+ <style>+ /* Startup splash. Inline so it renders before any script or stylesheet is fetched;+ apps/client/src/services/splash.ts drives the status line and removes the element+ once the application has loaded. */+ #splash {+ position: fixed;+ inset: 0;+ z-index: 10000;+ display: flex;+ align-items: center;+ justify-content: center;+ background: #ffffff;+ color: #666666;+ font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;+ transition: opacity 0.4s ease;+ }+ #splash.splash-hidden {+ opacity: 0;+ pointer-events: none;+ }+ #splash .splash-content {+ display: flex;+ flex-direction: column;+ align-items: center;+ /* Fades in after a delay, so a fast startup shows a blank page instead of a+ flash of logo. */+ opacity: 0;+ animation: splash-appear 0.4s ease 0.3s forwards;+ }+ #splash .splash-logo {+ width: 96px;+ height: 96px;+ }+ #splash .splash-title {+ margin-top: 16px;+ font-size: 22px;+ font-weight: 600;+ letter-spacing: 0.02em;+ color: #333333;+ }+ #splash .splash-bar {+ width: 176px;+ height: 3px;+ margin-top: 24px;+ border-radius: 2px;+ overflow: hidden;+ background: rgba(128, 128, 128, 0.2);+ }+ #splash .splash-bar-fill {+ width: 40%;+ height: 100%;+ border-radius: 2px;+ background: #72b755;+ animation: splash-slide 1.4s ease-in-out infinite;+ }+ #splash-status {+ min-height: 1.5em;+ margin-top: 12px;+ font-size: 13px;+ text-align: center;+ }+ #splash.splash-error .splash-bar {+ display: none;+ }+ #splash.splash-error #splash-status {+ max-width: min(480px, 85vw);+ color: #e33f3b;+ }+ @keyframes splash-appear {+ to { opacity: 1; }+ }+ @keyframes splash-slide {+ 0% { transform: translateX(-110%); }+ 100% { transform: translateX(260%); }+ }+ @keyframes splash-pulse {+ 0%, 100% { opacity: 0.3; }+ 50% { opacity: 1; }+ }+ @media (prefers-color-scheme: dark) {+ #splash { background: #242424; color: #999999; }+ #splash .splash-title { color: #cccccc; }+ }+ @media (prefers-reduced-motion: reduce) {+ #splash .splash-content { opacity: 1; animation: none; }+ #splash .splash-bar-fill { width: 100%; animation: splash-pulse 1.8s ease-in-out infinite; }+ }+ @media print {+ #splash { display: none; }+ }+ </style></head><body id="trilium-app"><noscript>Trilium requires JavaScript to be enabled.</noscript>+ <div id="splash" role="status">+ <div class="splash-content">+ <svg class="splash-logo" viewBox="0 0 256 256" aria-hidden="true">+ <path fill="#95C980" d="m202.9 112.7c-22.5 16.1-54.5 12.8-74.9 6.3l14.8-11.8 14.1-11.3 49.1-39.3-51.2 35.9-14.3 10-14.9 10.5c0.7-21.2 7-49.9 28.6-65.4 1.8-1.3 3.9-2.6 6.1-3.8 2.7-1.5 5.7-2.9 8.8-4.1 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.9 65.9-2.4 2.8-4.9 5.4-7.4 7.8-3.4 3.5-6.8 6.4-10.1 8.8z"/>+ <path fill="#72B755" d="m213.1 104c-22.2 12.6-51.4 9.3-70.3 3.2l14.1-11.3 49.1-39.3-51.2 35.9-14.3 10c0.5-18.1 4.9-42.1 19.7-58.6 2.7-1.5 5.7-2.9 8.8-4.1 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.9 65.9-2.3 2.8-4.8 5.4-7.2 7.8z"/>+ <path fill="#4FA52B" d="m220.5 96.2c-21.1 8.6-46.6 5.3-63.7-0.2l49.2-39.4-51.2 35.9c0.3-15.8 3.5-36.6 14.3-52.8 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.8 66z"/>+ <path fill="#EE8C89" d="m106.7 179c-5.8-21 5.2-43.8 15.5-57.2l4.8 14.2 4.5 13.4 15.9 47-12.8-47.6-3.6-13.2-3.7-13.9c15.5 6.2 35.1 18.6 40.7 38.8 0.5 1.7 0.9 3.6 1.2 5.5 0.4 2.4 0.6 5 0.7 7.7 0.9 23.1-7.1 54.9-15.9 65.7-12-4.3-29.3-24-39.7-42.8-1.4-2.6-2.7-5.1-3.8-7.6-1.6-3.5-2.9-6.8-3.8-10z"/>+ <path fill="#E96562" d="m110.4 188.9c-3.4-19.8 6.9-40.5 16.6-52.9l4.5 13.4 15.9 47-12.8-47.6-3.6-13.2c13.3 5.2 29.9 15 38.1 30.4 0.4 2.4 0.6 5 0.7 7.7 0.9 23.1-7.1 54.9-15.9 65.7-12-4.3-29.3-24-39.7-42.8-1.4-2.6-2.7-5.2-3.8-7.7z"/>+ <path fill="#E33F3B" d="m114.2 196.5c-0.7-18 8.6-35.9 17.3-47.1l15.9 47-12.8-47.6c11.6 4.4 26.1 12.4 35.2 24.8 0.9 23.1-7.1 54.9-15.9 65.7-12-4.3-29.3-24-39.7-42.8z"/>+ <path fill="#EFB075" d="m86.3 59.1c21.7 10.9 32.4 36.6 35.8 54.9l-15.2-6.6-14.5-6.3-50.6-22 48.8 24.9 13.6 6.9 14.3 7.3c-16.6 7.9-41.3 14.5-62.1 4.1-1.8-0.9-3.6-1.9-5.4-3.2-2.3-1.5-4.5-3.2-6.8-5.1-19.9-16.4-40.3-46.4-42.7-61.5 12.4-6.5 41.5-5.8 64.8-0.3 3.2 0.8 6.2 1.6 9.1 2.5 4 1.3 7.6 2.8 10.9 4.4z"/>+ <path fill="#E99547" d="m75.4 54.8c18.9 12 28.4 35.6 31.6 52.6l-14.5-6.3-50.6-22 48.7 24.9 13.6 6.9c-14.1 6.8-34.5 13-53.3 8.2-2.3-1.5-4.5-3.2-6.8-5.1-19.8-16.4-40.2-46.4-42.6-61.5 12.4-6.5 41.5-5.8 64.8-0.3 3.1 0.8 6.2 1.6 9.1 2.6z"/>+ <path fill="#E47B19" d="m66.3 52.2c15.3 12.8 23.3 33.6 26.1 48.9l-50.6-22 48.8 24.9c-12.2 6-29.6 11.8-46.5 10-19.8-16.4-40.2-46.4-42.6-61.5 12.4-6.5 41.5-5.8 64.8-0.3z"/>+ </svg>+ <div class="splash-title">Trilium Notes</div>+ <div class="splash-bar"><div class="splash-bar-fill"></div></div>+ <div id="splash-status"></div>+ </div>+ </div>+<div id="context-menu-cover"></div><div class="dropdown-menu dropdown-menu-sm" id="context-menu-container" style="display: none"></div>diff --git a/apps/standalone/src/main.spec.ts b/apps/standalone/src/main.spec.tsindex c34bf4d932..fccf2955a0 100644--- a/apps/standalone/src/main.spec.ts+++ b/apps/standalone/src/main.spec.ts@@ -117,6 +117,19 @@ describe("bootstrap", () => {expect(document.body.innerHTML).toBe("");});+ it("reports progress on the splash while the SW installs", async () => {+ document.body.innerHTML = `<div id="splash"><div id="splash-status"></div></div>`;+ const sw: ServiceWorkerLike = {+ controller: null, register: vi.fn(), ready: Promise.resolve()+ };+ sw.register.mockImplementation(async () => { sw.controller = {}; });+ setServiceWorker(sw);+ await runBootstrap();+ await vi.waitFor(() => expect(sw.register).toHaveBeenCalled());+ expect(document.getElementById("splash-status")?.textContent)+ .toBe("Setting up offline support…");+ });+it("reloads the page when the SW installs but does not take control", async () => {setServiceWorker({ controller: null, register: vi.fn().mockResolvedValue(undefined), ready: Promise.resolve() });await runBootstrap();diff --git a/apps/standalone/src/main.ts b/apps/standalone/src/main.tsindex 2c1af48419..1ac24f4891 100644--- a/apps/standalone/src/main.ts+++ b/apps/standalone/src/main.ts@@ -1,3 +1,4 @@+import { updateSplashStatus } from "../../client/src/services/splash.js";import { showErrorOverlay } from "./error-overlay.js";import { installIosInterceptors } from "./ios-interceptors.js";import { claimLeadership } from "./leader_election.js";@@ -27,6 +28,7 @@ async function waitForServiceWorkerControl(): Promise<void> {}console.log("[Bootstrap] Waiting for service worker to take control...");+ updateSplashStatus("Setting up offline support…");await navigator.serviceWorker.register("./sw.js", { scope: "/" });await navigator.serviceWorker.ready;