/* Build-time service worker injection. After Vite writes the bundle, the hashed asset URLs referenced by dist/index.html and a content-derived revision are written into dist/sw.js, so the offline shell is complete right after install and every release ships a new worker with fresh caches. Build tooling only — never imported by the app bundle. */ import { createHash } from "node:crypto"; import { readFileSync, writeFileSync } from "node:fs"; import { resolve } from "node:path"; import type { Plugin } from "vite"; export const REVISION_MARKER = "__NQ_BUILD_REVISION__"; const PRECACHE_PLACEHOLDER = "const PRECACHE_ASSETS = [];"; // Unhashed files sw.js precaches by fixed URL, relative to the build output. export const STATIC_PRECACHE_FILES = [ "manifest.webmanifest", "icons/icon-192.png", "icons/icon-512.png", "icons/icon-maskable-512.png", ]; export interface PrecacheFile { path: string; bytes: string | Uint8Array; } // Every same-origin URL an index.html loads via