Skip to content

Faza 3: modularizarea stratului DOM (script.ts → 10 module)#42

Merged
adyz merged 2 commits into
masterfrom
faza3-modularizare
Jul 3, 2026
Merged

Faza 3: modularizarea stratului DOM (script.ts → 10 module)#42
adyz merged 2 commits into
masterfrom
faza3-modularizare

Conversation

@adyz

@adyz adyz commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Ce face

Faza 3 din planul de migrare (plan.md): script.ts (757 de linii, monolit) devine 10 module cu responsabilitate unică. Mutare pură de cod — zero schimbări de comportament, dovedită de suita e2e neatinsă.

Modul Responsabilitate
main.ts entry point — doar wiring, aceeași ordine de execuție
dom.ts helper el<T>() + referințele DOM partajate
labels.ts textele user-facing (sursă unică)
cloudinary.ts URL-uri imagini status + pre-cache offline
storage.ts persistența ultimului post
soundEffects.ts audioInstance (blob preload, warmUp, ensure) + cache sunete
mediaSession.ts metadata/handlers Now Playing + re-înregistrarea pentru iOS
serviceWorker.ts înregistrare + reload amânat la idle
theme.ts theme color pe prefers-color-scheme
stationSelector.ts listbox-ul accesibil, raportează prin onSelect()

Cusături demne de menționat:

  • Ciclul core ↔ mediaSession e rezolvat prin injectare explicită (initMediaSession înainte de createRadioCore, connectMediaSessionCore după) — fără let core global mutabil.
  • mediaSession nu mai știe de serviceWorker: main compune updateMediaSession + maybeReloadForPendingServiceWorkerUpdate în deps, în aceeași ordine ca înainte.
  • Bundle-ul rămâne un singur chunk js/index.jsAPP_SHELL din sw.js neschimbat, fără bump de cache.

Verificare

  • tsc --noEmit curat • ✅ Unit 63/63 (neatinse) • ✅ E2E 37/37 — suita neatinsă, dovada refactorului • ✅ Build (structură identică) • ✅ Smoke complet pe vite preview
  • De verificat pe preview: un smoke rapid pe telefon (MediaSession e zona cea mai sensibilă la ordinea de inițializare, deși ordinea e păstrată 1:1)

🤖 Generated with Claude Code

Pure code movement — no behavior change, proven by the untouched e2e
suite. script.ts (757 lines) becomes:

- dom.ts             el<T>() helper + shared element references
- labels.ts          user-facing texts (single source of truth)
- cloudinary.ts      status image URLs + offline pre-cache
- storage.ts         last-station persistence
- soundEffects.ts    audioInstance (blob preload, warmUp, ensure) + cache
- mediaSession.ts    Now Playing metadata/handlers + iOS re-registration
- serviceWorker.ts   registration + deferred idle-time reload
- theme.ts           prefers-color-scheme theme color
- stationSelector.ts accessible listbox, reports picks via onSelect()
- main.ts            entry point: wiring only, same execution order

Notable seams:
- the core<->mediaSession cycle is resolved by explicit injection
  (initMediaSession before createRadioCore, connectMediaSessionCore
  after) instead of a mutable let;
- mediaSession no longer calls into serviceWorker — main composes
  updateMediaSession + maybeReloadForPendingServiceWorkerUpdate in the
  deps, preserving the original order.

Bundle output unchanged (single js/index.js chunk), so sw.js APP_SHELL
needs no bump. Typecheck clean, 63/63 unit, 37/37 e2e untouched, full
production-preview smoke passing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
radio Ready Ready Preview, Comment Jul 3, 2026 2:42pm

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

CI Summary

Check Status Result
Typecheck PASS tsc --noEmit clean
Unit tests PASS 63/63 passed; Coverage: Lines 99.72%, Branches 84.07%, Functions 93.10%, Statements 99.72%
Build PASS Build completed
Playwright browser PASS Chromium installed
E2E tests PASS 37/37 passed

…channel)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@adyz adyz merged commit 334c9e1 into master Jul 3, 2026
3 checks passed
@adyz adyz deleted the faza3-modularizare branch July 3, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant