The counter example gains a sw.js exercising bankai's injected-precache build. e2e proves both bankai paths in real Chromium: the built app serves, hydrates and runs with zero console errors and zero mismatch warnings (and choo consumed window.initialState), and the dev server's Vite-transformed virtual entry hydrates the same way. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014NgfSjHE11oFpoSnLVKLXd
29 lines
818 B
JavaScript
29 lines
818 B
JavaScript
/* global __BANKAI_ASSETS__ */
|
|
// Service worker built by `bankai build`: the precache list is injected
|
|
// at build time from the asset manifest (the choo-service-worker
|
|
// convention, manifest edition). Register it from your app with
|
|
// navigator.serviceWorker.register('/sw.js').
|
|
|
|
const CACHE = 'counter-v1'
|
|
const ASSETS = __BANKAI_ASSETS__
|
|
|
|
self.addEventListener('install', (event) => {
|
|
event.waitUntil(
|
|
caches.open(CACHE).then((cache) => cache.addAll(ASSETS))
|
|
)
|
|
})
|
|
|
|
self.addEventListener('activate', (event) => {
|
|
event.waitUntil(
|
|
caches.keys().then((keys) =>
|
|
Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))
|
|
)
|
|
)
|
|
})
|
|
|
|
self.addEventListener('fetch', (event) => {
|
|
event.respondWith(
|
|
caches.match(event.request).then((hit) => hit || fetch(event.request))
|
|
)
|
|
})
|