/** * Renderer bundle generation check. * * `index.html` and the hashed chunks under `dist/assets/` are ONE generation: * every `lazy()` route resolves to a filename baked into that generation's * module graph. A self-update that replaces the package while its files are * locked (antivirus, a still-running instance, an interrupted Windows replace) * can leave the two copies electron-builder ships — inside `app.asar` and, * because `asarUnpack` lists `dist/**`, beside it in `app.asar.unpacked` — * from DIFFERENT generations. The window then loads an `index.html` whose * chunks are gone and dies on the first lazy import: * * Failed to fetch dynamically imported module: * …/app.asar/dist/assets/shiki-block-COiz1pEN.js * * The app looks permanently broken (every relaunch reloads the same torn copy), * yet the OTHER copy is usually intact. This makes that checkable, so the * loader can prefer a complete generation and only report a repair when both * are torn. * * Pure + injectable so it is testable without booting Electron. `fs` here is * Electron's asar-aware fs: paths inside `app.asar` read like real files. */ import fs from 'node:fs' import path from 'node:path' // The modules the browser fetches before any app code runs: Vite emits them as // `