veza/apps/web/scripts
senke 45c130c856
Some checks failed
Veza CI / Notify on failure (push) Blocked by required conditions
Veza CI / Rust (Stream Server) (push) Successful in 5m12s
Security Scan / Secret Scanning (gitleaks) (push) Failing after 48s
Veza CI / Backend (Go) (push) Failing after 8m51s
E2E Playwright / e2e (full) (push) Has been cancelled
Veza CI / Frontend (Web) (push) Has been cancelled
feat(pwa): tighten sw.js to roadmap strategy spec + version stamper (W4 Day 16)
Service worker now applies the strategies the roadmap asks for :
  * Static assets : StaleWhileRevalidate (already in place)
  * HLS segments  : CacheFirst, max-age 7d, max 50 entries
  * API GET       : NetworkFirst, 3s timeout

Stayed on the hand-rolled fetch handlers rather than migrating to
Workbox — the existing implementation already covers push notifications
+ background sync + notificationclick, and Workbox would bring 200+ KB
of runtime + a build-step dependency for a feature set we already have.

Changes
- public/sw.js
  * HLS_CACHE_MAX_ENTRIES (50) + HLS_CACHE_MAX_AGE_MS (7d) +
    NETWORK_FIRST_TIMEOUT_MS (3s) tunable at the top of the file.
  * cacheAudio : reads the cached response's date header to skip
    stale entries (>7d), and prunes the cache FIFO after every put
    so the entry count never exceeds 50. Network-down path still
    serves stale entries (the offline-playback acceptance).
  * networkFirst : races the network against a 3s timer ; if the
    timer fires AND a cached entry exists, serve cached + let the
    network keep updating in the background. Timeout without a
    cached fallback lets the network race continue.
  * isAudioRequest now matches .ts and .m4s segments too (HLS).

- scripts/stamp-sw-version.mjs (new) : postbuild step that replaces
  the literal __BUILD_VERSION__ placeholder in dist/sw.js with
  YYYYMMDDHHMM-<short-sha>. Pre-Day 16 the placeholder shipped
  literally — same string across every deploy meant browser caches
  were never invalidated. Wired into npm run build + build:ci.

- tests/e2e/31-sw-offline-cache.spec.ts : 2 tests gated behind
  E2E_SW_TESTS=1 (SW only registers in prod builds — dev server
  skips registration via import.meta.env.DEV check). When enabled :
  (1) registration + activation, (2) cached resource served while
  context.setOffline(true).

Acceptance (Day 16) : strategies match spec ; offline playback works
once the user has played the segment once before going offline. The
e2e self-skips on dev unless E2E_SW_TESTS=1 is set against vite preview.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 09:43:09 +02:00
..
analyze-errors.js chore(dx): add .cursorrules and design system audit documentation 2026-02-05 14:20:06 +01:00
audit-storybook.js chore(v0.102): consolidate remaining changes — docs, frontend, backend 2026-02-20 13:02:12 +01:00
capture-visual-baseline.mjs ui(storybook): add allowedHosts config and update DESIGN_TOKENS docs 2026-02-08 22:49:24 +01:00
check-bundle-size.mjs stabilisation commit: while implementing v0.10.5 2026-03-09 19:36:33 +01:00
check-types-sync.sh chore(web): drop legacy openapi-generator-cli — orval is the single source (v1.0.8 B9) 2026-04-26 00:02:58 +02:00
check_backend.sh fix(MVP-006): Standardize environment variable names (VITE_API_BASE_URL → VITE_API_URL) 2025-12-22 22:56:37 +01:00
codemod-typography-arbitrary.mjs docs: add UI/UX audit reports and design system documentation 2026-02-08 22:49:40 +01:00
compare-visual.mjs feat(web): UI premium Discord/Spotify-like — tokens, shadows, focus, layout 2026-02-08 17:15:58 +01:00
debug-story.js chore(dx): add .cursorrules and design system audit documentation 2026-02-05 14:20:06 +01:00
fix-failing-tests.sh chore: resolve property mismatches and type conflicts for snake_case alignment 2026-01-07 11:15:48 +01:00
fix-ui-imports.sh chore: resolve property mismatches and type conflicts for snake_case alignment 2026-01-07 11:15:48 +01:00
fix-unused-vars.sh chore: resolve property mismatches and type conflicts for snake_case alignment 2026-01-07 11:15:48 +01:00
generate-types.sh chore(web): drop legacy openapi-generator-cli — orval is the single source (v1.0.8 B9) 2026-04-26 00:02:58 +02:00
generate-visual-report.mjs feat(web): UI premium Discord/Spotify-like — tokens, shadows, focus, layout 2026-02-08 17:15:58 +01:00
replace-console-logs.sh [LOGGING] Fix #10: Erreurs silencieuses - Ajout de logs avec contexte pour toutes les erreurs dans core/auth et core/track 2026-01-04 01:44:15 +01:00
report-arbitrary-values.mjs feat(web): UI premium Discord/Spotify-like — tokens, shadows, focus, layout 2026-02-08 17:15:58 +01:00
serve-storybook-static.cjs test(storybook): Playwright suite for full Storybook + Spotify/Discord polish 2026-02-07 20:30:49 +01:00
stamp-sw-version.mjs feat(pwa): tighten sw.js to roadmap strategy spec + version stamper (W4 Day 16) 2026-04-29 09:43:09 +02:00
start-backend-and-dev.sh chore: playwright workflow, docs, rapports audit, visual-tests, tmt unit 2026-02-11 22:19:34 +01:00
start_lab.sh fix(MVP-006): Standardize environment variable names (VITE_API_BASE_URL → VITE_API_URL) 2025-12-22 22:56:37 +01:00
storybook-coverage.sh stabilisation: fix commit 2026-02-03 09:56:11 +01:00
validate-storybook.cjs feat(web): add validate:storybook script (build, serve 6007, audit) 2026-02-14 14:02:57 +01:00
visual-diff.js feat(e2e): Playwright + pixelmatch stack for pixel-perfect visual regression 2026-02-07 20:01:30 +01:00
wrap_msw_handlers.py chore(dx): add .cursorrules and design system audit documentation 2026-02-05 14:20:06 +01:00