export interface ServiceWorkerRegisterOptions { /** URL to the SW script. Default: '/jorvel-sw.js'. */ url?: string; /** Scope. Default: '/'. */ scope?: string; /** Enable registration. Default: process.env.NODE_ENV === 'production'. */ enabled?: boolean; /** Called when a new SW is waiting to activate. */ onUpdateReady?: (registration: ServiceWorkerRegistration) => void; /** Called when the SW first takes control. */ onReady?: (registration: ServiceWorkerRegistration) => void; /** Auto-skip waiting when an update is ready. Default: false. */ autoActivate?: boolean; } export declare function registerJorvelServiceWorker(opts?: ServiceWorkerRegisterOptions): Promise; export declare function unregisterJorvelServiceWorker(): Promise; /** Inline SW script source — bundlers can emit via `import sw from './jorvel-sw-source?raw'`. */ export declare const JORVEL_SERVICE_WORKER_SOURCE = "/* generated by @jorvel/runtime */\nconst CACHE = 'jorvel-v1';\nconst REMOTE_CACHE = 'jorvel-remotes-v1';\nconst APP_SHELL = ['/', '/index.html'];\n\nself.addEventListener('install', (event) => {\n event.waitUntil(caches.open(CACHE).then((c) => c.addAll(APP_SHELL).catch(() => undefined)));\n self.skipWaiting();\n});\n\nself.addEventListener('activate', (event) => {\n event.waitUntil((async () => {\n const keys = await caches.keys();\n await Promise.all(keys.filter((k) => k !== CACHE && k !== REMOTE_CACHE).map((k) => caches.delete(k)));\n await self.clients.claim();\n })());\n});\n\nself.addEventListener('message', (event) => {\n if (event.data && event.data.type === 'SKIP_WAITING') self.skipWaiting();\n});\n\nself.addEventListener('fetch', (event) => {\n const req = event.request;\n if (req.method !== 'GET') return;\n const url = new URL(req.url);\n\n // remoteEntry.js and federation chunks \u2192 stale-while-revalidate\n if (/remoteEntry\\.js$/.test(url.pathname) || /\\/jorvel\\/remotes\\//.test(url.pathname)) {\n event.respondWith(staleWhileRevalidate(REMOTE_CACHE, req));\n return;\n }\n\n // Fingerprinted assets \u2192 cache-first\n if (/\\.[a-f0-9]{8,}\\.(js|css|woff2?|png|svg|jpg|jpeg|webp)$/.test(url.pathname)) {\n event.respondWith(cacheFirst(CACHE, req));\n return;\n }\n\n // HTML documents \u2192 network-first with offline fallback\n if (req.destination === 'document' || req.headers.get('accept')?.includes('text/html')) {\n event.respondWith(networkFirst(CACHE, req));\n return;\n }\n});\n\nasync function cacheFirst(name, req) {\n const cache = await caches.open(name);\n const hit = await cache.match(req);\n if (hit) return hit;\n const res = await fetch(req);\n if (res.ok) cache.put(req, res.clone());\n return res;\n}\n\nasync function networkFirst(name, req) {\n const cache = await caches.open(name);\n try {\n const res = await fetch(req);\n if (res.ok) cache.put(req, res.clone());\n return res;\n } catch {\n const hit = await cache.match(req);\n if (hit) return hit;\n // cache.match returns a Promise (always truthy) \u2014 must await it, else\n // respondWith resolves to the Promise object / undefined and the offline\n // navigation fails instead of serving the cached shell.\n const shell = await cache.match('/');\n return shell || Response.error();\n }\n}\n\nasync function staleWhileRevalidate(name, req) {\n const cache = await caches.open(name);\n const hit = await cache.match(req);\n const fetchPromise = fetch(req).then((res) => {\n if (res.ok) cache.put(req, res.clone());\n return res;\n }).catch(() => hit);\n return hit || fetchPromise;\n}\n"; //# sourceMappingURL=service-worker.d.ts.map