Client application runtimes
IPTVnator delivers one player workspace through desktop and browser runtimes. Both runtimes let users connect IPTV sources, browse live and on-demand content, play streams, manage settings, and keep viewing state. The runtime supplies the environment-specific path for network access, storage, playback, updates, and device features.
Runtime model
The shared Angular client owns the product experience. Runtime services hide whether a request uses the Electron host, browser APIs, or the browser backend. Electron desktop runtime explains the native host. Browser client explains the web application. Browser backend explains the server path used by browser deployments.
Shared application experience
The shared client provides the workspace for sources, provider content, guide data, playback, settings, personal collections, and viewing history. It restores saved state before opening work that depends on it, and it keeps settings and recovery paths available when source data is not ready. Global favorites and recent items can combine content from several source types while opening the matching portal detail view only when needed. Shell actions also provide common entry points for adding sources, searching, opening recent items, and viewing account data without coupling those actions to one runtime. apps/…/app.component.ts• L171-215, apps/…/global-collection-route.component.ts• L197-285, apps/…/workspace-shell-actions.service.ts• L21-100
The client prepares the preferred language before the first render. Date locale data loads on demand, and a later language request wins if language changes overlap. This prevents an early date render from using missing locale data or an older choice from replacing the newest one. apps/…/main.ts• L21-31, apps/…/app-date-locales.ts• L12-54, apps/…/app-date-locale-data.ts• L42-80
The workspace route waits for settings, server access, parental-lock state, and source readiness. Child routes select the first available workspace and redirect away from features that the active runtime cannot provide. apps/…/app.routes.ts• L15-231, apps/…/app.config.ts• L95-177
References: apps/…/app.component.ts• L171-215 apps/…/global-collection-route.component.ts• L197-285 apps/…/workspace-shell-actions.service.ts• L21-100 apps/…/main.ts• L21-31 apps/…/app-date-locales.ts• L12-54 apps/…/app-date-locale-data.ts• L42-80 apps/…/app.routes.ts• L15-231
Playback activity
Playback activity is an optional shared record of viewing starts, progress, and resets for a selected source server. It lets users carry resume state between devices while keeping a local usable position when delivery is disabled, offline, or unsafe to send. apps/…/activity-sync-runtime.ts• L196-249, apps/…/activity-position-adapter.ts• L52-149
The client protects each position from stale work. A local record is bound to the source instance and keeps an unacknowledged position until delivery succeeds. A write fence prevents a delayed fallback or native checkpoint from overwriting a newer action. apps/…/activity-local-only-positions.ts• L31-83, apps/…/activity-position-write-fence.ts• L13-67
Browser and Android-shell playback use the same activity boundary. The Android shell sends validated checkpoints to the page, which accepts only the current source profile and newer position. When shared delivery is paused or fails, the client mirrors state into the local playback store and exposes pending, conflict, offline, and recovery states in settings. apps/…/android-playback-checkpoint.ts• L29-137, apps/…/activity-sync-runtime.ts• L126-170, apps/…/activity-position-adapter.ts• L130-146
References: apps/…/activity-sync-runtime.ts• L196-249 apps/…/activity-position-adapter.ts• L52-149 apps/…/activity-local-only-positions.ts• L31-83 apps/…/activity-position-write-fence.ts• L13-67 apps/…/android-playback-checkpoint.ts• L29-137
Favorites synchronization
Favorites synchronization is an optional shared record of favorite membership for a selected source server. Each runtime keeps a local view for fast and offline use, then exchanges changes only when consent and server capability allow it. The same source identity rules keep favorites from one source from being applied to another. apps/…/favorites-sync-runtime.ts• L61-105, apps/…/favorites-runtime-client.ts• L19-88
Settings gives users control over consent, refresh, pending changes, conflicts, local import, and backup. A disabled profile keeps local choices without authorizing network writes. apps/…/settings-favorites-section.component.html• L1-184, apps/…/favorites-backup-restore.ts• L14-81
References: apps/…/favorites-sync-runtime.ts• L61-105 apps/…/favorites-runtime-client.ts• L19-88 apps/…/settings-favorites-section.component.html• L1-184 apps/…/favorites-backup-restore.ts• L14-81
Settings workspace
The settings workspace is one control surface for appearance, startup, playback, guide data, provider metadata, parental protection, remote control, backup, source-server access, shared records, and updates. Runtime capability checks hide controls that the active environment cannot support. apps/…/settings.component.html• L54-263, apps/…/settings.component.ts• L180-259
Settings uses staged edits. It compares the form with the saved snapshot, marks affected sections, and lets users save, discard, or stay when leaving with edits. A save writes only the changed settings over the current stored values, so changes made by another surface are not silently lost. The form also keeps unfinished guide-source and metadata writes available for retry when storage or runtime application fails. apps/…/settings-form.facade.ts• L48-99, apps/…/settings-form.facade.ts• L288-378, apps/…/settings-form-rebase.ts• L32-179, apps/…/settings-form-writes.ts• L7-114
The desktop About section also coordinates update channels with the shared save flow. A channel change can require saving before the updater checks the new channel, while an existing download remains tied to the channel that produced it. Browser and Android-shell settings expose their own supported controls instead of pretending that desktop actions are available. apps/…/settings-about-section.component.ts• L47-185, apps/…/settings-about-section.component.html• L45-251, apps/…/settings-general-section.component.ts• L43-87
Settings also provides recovery for shared data. A browser can move local playlists into server storage after startup, and the settings page can reconnect, disconnect, preview, or forget a source server. Removing all playlists uses the active storage path and clears local locks when that path owns them. apps/…/server-migration-prompt.service.ts• L12-49, apps/…/server-migration-dialog.component.html• L10-73, apps/…/settings-server-section.component.ts• L149-258, apps/…/settings-playlist-reset.facade.ts• L97-159
The visual system applies shared theme roles across Material components and utility styles. This keeps light, dark, and named theme presets consistent across the workspace and overlay surfaces. apps/…/m3-theme.scss• L29-175, apps/…/styles.scss• L105-164, apps/…/tailwind.config.js• L8-56
References: apps/…/settings.component.html• L54-263 apps/…/settings.component.ts• L180-259 apps/…/settings-form.facade.ts• L288-378 apps/…/settings-form-rebase.ts• L32-179 apps/…/settings-form-writes.ts• L7-114 apps/…/settings-about-section.component.ts• L47-185 apps/…/settings-about-section.component.html• L45-251 apps/…/server-migration-prompt.service.ts• L12-49 apps/…/settings-server-section.component.ts• L149-258 apps/…/settings-playlist-reset.facade.ts• L97-159 apps/…/m3-theme.scss• L29-175
Shared source synchronization
Source synchronization gives desktop and browser clients an optional shared source workspace. The server owns source definitions and revisions. Each client projects them into its local playlist view, while personal favorites and activity remain local unless the user separately enables shared delivery.
Source server connection
The source server is selected before the Angular app starts. Electron receives it from its host. A browser reads a saved connection or discovers a compatible server from its configured backend. The selected server instance defines the boundary for source, favorite, and activity data. apps/…/main.ts• L25-31, libs/…/source-connection.ts• L47-131, libs/…/source-profile-user-data.ts• L7-44
Settings lets users connect, refresh, disconnect, forget, and preview local sources for import. Offline or locked states keep a recovery path instead of removing the source controls. apps/…/settings-server-section.component.ts• L149-287, apps/…/source-sync-status-view.component.ts• L15-141
References: apps/…/main.ts• L25-31 libs/…/source-connection.ts• L47-131 libs/…/source-profile-user-data.ts• L7-44 apps/…/settings-server-section.component.ts• L149-287 apps/…/source-sync-status-view.component.ts• L15-141
Source inventory lifecycle
After connection, the client checks the server instance and source inventory, projects changed definitions into local playlists, and reports the result through the shared playlist store. It refreshes on focus, network recovery, visibility changes, and a timer. Removed sources leave open routes, and changed source routes are rebuilt from current data. libs/…/source-sync.service.ts• L150-291, libs/…/synced-playlist-store.ts• L101-247, apps/…/source-sync-runtime.ts• L9-56
References: libs/…/source-sync.service.ts• L150-291 libs/…/synced-playlist-store.ts• L101-247 apps/…/source-sync-runtime.ts• L9-56
Source authorization boundary
Source synchronization verifies the selected server instance before sending protected requests. The browser adds source authorization only to requests for that server and invalidates the proof after an outage, an unauthorized response, or an instance change. libs/…/source-authorization.ts• L9-47, apps/…/source-proxy.ts• L18-79
Provider traffic follows the same boundary. Browser requests restore source verification when needed and then use the HTTP path. Electron keeps the equivalent request behind its native host. Browser connectivity-guard resets are bounded and best effort, so a stuck backend reset does not block the request that needs to retry. apps/…/pwa.service.ts• L152-201, apps/…/pwa.service.ts• L595-643, apps/…/electron.service.ts• L157-212
References: libs/…/source-authorization.ts• L9-47 apps/…/source-proxy.ts• L18-79 apps/…/pwa.service.ts• L152-201 apps/…/pwa.service.ts• L595-643 apps/…/electron.service.ts• L157-212
Runtime service boundary
The runtime service boundary turns shared application requests into environment-specific work. Electron sends native, provider, playlist, guide, download, database, window, and playback actions to the host. The browser sends provider and playlist requests to the browser backend and uses browser storage and browser capabilities for the rest. apps/…/app.config.ts• L85-93, apps/…/electron.service.ts• L159-282, apps/…/pwa.service.ts• L105-149
Provider results distinguish success, cancellation, authorization failure, connection failure, and provider failure. Shared features can then choose retry, source repair, local fallback, or a user message without knowing the transport. apps/…/pwa-xtream-request.ts• L129-213
Playlist refresh follows the same boundary. The browser downloads the new definition through its backend path, writes it to the local playlist store, refreshes guide data, and reports failure without replacing the old playlist. Electron performs the equivalent work through its native host and keeps the source busy until the refresh finishes. apps/…/pwa-playlist-refresh.ts• L13-64, apps/…/pwa.service.ts• L203-237, apps/…/electron.service.ts• L187-208
Each runtime keeps environment-specific failures visible. Desktop-only player and native-window errors stay in the Electron service. Browser update failures stay in the browser service. Favorites and activity preserve local data when shared delivery fails. apps/…/electron.service.ts• L97-131, apps/…/pwa-update.service.ts• L11-107, apps/…/favorites-sync-runtime.ts• L238-251
References: apps/…/app.config.ts• L85-93 apps/…/electron.service.ts• L159-282 apps/…/pwa.service.ts• L105-149 apps/…/pwa-xtream-request.ts• L129-213 apps/…/pwa-playlist-refresh.ts• L13-64 apps/…/pwa-update.service.ts• L11-107
Desktop delivery
Desktop delivery combines the Angular client with an Electron main process. The main process owns the application window and native services. A preload bridge exposes approved capabilities to the renderer, while workers keep database and guide work outside the main thread. apps/…/main.ts• L130-205, apps/…/main.preload.ts• L288-481
Electron host
The Electron host controls the desktop window lifecycle and limits renderer access to approved bridge actions. It loads the local client in development and the bundled client in a packaged app. Navigation stays inside trusted application pages, while approved external links open in the system browser. apps/…/app.ts• L47-84, apps/…/app.ts• L356-383, apps/…/app.ts• L643-659
The bridge covers window control, provider calls, playlist files, local data, downloads, playback, guide work, updates, favorites, and activity storage. It also carries native events back to the renderer. External player launch and runtime errors are converted into user-visible desktop feedback without changing the shared browser path. apps/…/main.preload.ts• L288-481, apps/…/main.preload.ts• L509-769, apps/…/electron.service.ts• L97-131
References: apps/…/main.ts• L130-205 apps/…/app.ts• L47-84 apps/…/main.preload.ts• L288-481 apps/…/main.preload.ts• L509-769 apps/…/electron.service.ts• L97-131
Desktop coordination
Desktop coordination registers native handlers before it loads the renderer. It coordinates playlists, portals, playback, settings, guide data, storage, downloads, remote control, source synchronization, favorites, and activity. It also stops native work during shutdown. apps/…/main.ts• L145-234, apps/…/main.ts• L298-309
The desktop client accepts playlist files from operating-system actions. The host queues those requests until the renderer is ready, and the renderer imports them in order. Packaged updates use a separate flow for checking, downloading, and installing a release. Settings are first stored by the shared form and then mirrored to the desktop runtime; a failed mirror keeps the edits available instead of reporting a false save. apps/…/playlist-open-request.service.ts• L16-131, apps/…/app-update.service.ts• L108-127, apps/…/settings-form.facade.ts• L288-378
References: apps/…/main.ts• L145-234 apps/…/playlist-open-request.service.ts• L16-131 apps/…/app-update.service.ts• L108-127 apps/…/settings-form.facade.ts• L288-378
Browser delivery
Browser delivery serves the same Angular client without Electron. Browser services provide provider access, playlist import, service-worker updates, source-server synchronization, and browser persistence. Production browser builds can run as a progressive web app. apps/…/main.ts• L1-43, apps/…/app.config.ts• L111-140
Browser client
The browser client is the user-facing part of a browser deployment. Its entry point restores the preferred locale, route state, player loading, and source connection before Angular starts. Runtime configuration lets one bundle use different backend deployments. The backend URL can come from a selected source server, runtime configuration, or the build fallback. apps/…/index.html• L1-77, apps/…/main.ts• L9-43, apps/…/runtime-config.ts• L4-22
Browser favorites and activity use browser persistence and remain bound to the verified source-server instance. Browser playlist refresh updates the stored playlist and guide state only after a successful download. Browser updates use service-worker version events and a reload path rather than the desktop updater. The service worker is enabled only for supported production browser contexts, not Electron, file URLs, or the bundled TV shell. apps/…/activity-runtime-client.ts• L25-50, apps/…/pwa-playlist-refresh.ts• L13-64, apps/…/pwa-update.service.ts• L11-107, apps/…/runtime-config.ts• L24-58
References: apps/…/index.html• L1-77 apps/…/main.ts• L9-43 apps/…/runtime-config.ts• L4-22 apps/…/runtime-config.ts• L24-58 apps/…/activity-runtime-client.ts• L25-50 apps/…/pwa-playlist-refresh.ts• L13-64 apps/…/pwa-update.service.ts• L11-107
Browser backend
The browser backend is the network boundary for browser clients. It provides runtime configuration and health endpoints, registers provider targets, fetches remote playlists and guide data, and proxies Xtream and Stalker requests so browser pages do not need direct cross-origin access to provider systems. apps/…/web-backend-app.ts• L102-410
Before contacting a provider, the backend checks the provider URL, applies origin rules, limits request time, and tracks repeated host failures. The browser registers a provider URL once and uses the returned target identity for later proxy calls. A browser retry can ask the backend to clear a host failure record, but that reset has a short limit and does not replace the provider request's own result. apps/…/web-backend-app.ts• L91-116, apps/…/web-backend-app.ts• L415-464, apps/…/pwa.service.ts• L152-201
References: apps/…/web-backend-app.ts• L91-116 apps/…/web-backend-app.ts• L102-410 apps/…/web-backend-app.ts• L415-464 apps/…/pwa.service.ts• L152-201
Request and startup flows
The two runtimes follow the same product request path but use different transport paths. The diagram shows how a shared client action reaches either the Electron host or the browser backend before it reaches a provider or local resource.
flowchart LR
U[User action] --> C[Shared Angular client]
C --> R{Runtime}
R -->|Electron| E[Electron service]
E --> I[Preload bridge and IPC]
I --> M[Electron main process]
M --> N[Provider, local store, or native player]
R -->|Browser| P[Browser service]
P --> H[Browser backend over HTTP]
H --> V[Provider APIs, source server, or guide sources]
Startup prepares the runtime boundary before the workspace becomes active. Desktop registers native handlers before the renderer loads. Browser startup prepares locale data, route recovery, player loading, and the optional source connection before Angular starts. The shared client then restores settings, playlists, and supported source, favorite, and activity work. apps/…/main.ts• L138-205, apps/…/main.ts• L9-41, apps/…/app.component.ts• L171-215
If source or playlist loading fails, the same shell changes to a recovery state. It exposes retry and settings paths without requiring the user to reach the main library. apps/…/app-startup-status.component.ts• L138-173, apps/…/app-startup-recovery.component.ts• L64-79, apps/…/source-sync-status-view.component.ts• L15-141
References: apps/…/main.ts• L138-205 apps/…/main.ts• L9-41 apps/…/app.component.ts• L171-215 apps/…/app-startup-status.component.ts• L138-173 apps/…/source-sync-status-view.component.ts• L15-141
Cross-runtime contracts
Cross-runtime contracts keep the same product behavior available through different transports. Shared interfaces describe bridge payloads and result shapes. The preload bridge and browser services then present the matching capability boundary to the shared client. libs/…/electron-api.interface.ts• L603-727, apps/…/main.preload.ts• L288-481, apps/…/app.config.ts• L142-176
New shared features must use injected runtime services instead of assuming Electron IPC or browser HTTP. Source-aware features must use source authorization. Playback features must use the activity and position contracts so native checkpoints, local fallback, consent, and shared delivery remain consistent. Settings features must use capability gates and the staged save boundary so browser-only and desktop-only behavior stays explicit. apps/…/source-proxy.ts• L21-65, apps/…/activity-sync.providers.ts• L16-61, apps/…/portal-playback-positions.service.ts• L20-129, apps/…/settings-form.facade.ts• L288-378
References: libs/…/electron-api.interface.ts• L603-727 apps/…/main.preload.ts• L288-481 apps/…/app.config.ts• L142-176 apps/…/source-proxy.ts• L21-65 apps/…/activity-sync.providers.ts• L16-61 apps/…/portal-playback-positions.service.ts• L20-129 apps/…/settings-form.facade.ts• L288-378
Change checklist
When these files or sections are changed, remember to consider these:
- When a runtime service contract changes, update the Electron bridge and browser service together. Preserve the result shapes expected by shared features.
- When a browser backend route or response changes, update provider target registration and the matching browser request. Later proxy calls use the registered target identity.
- When a desktop bridge capability changes, update the shared contract, preload exposure, main handler, and renderer service as one boundary.
- When source connection or authorization changes, keep selected instance identity, request authorization, verification, and recovery state aligned.
- When playback activity changes, preserve source incarnation, consent generation, local fallback ownership, write ordering, and native checkpoint freshness.
- When settings controls change, update capability gates, staged form values, changed-path selection, rebase rules, runtime mirroring, restart notices, update-channel state, and translated labels together.
- When settings storage or backup flows change, preserve outside changes and unfinished guide-source or metadata writes during rebase and retry.
- When language support changes, keep app-language normalization, lazy Angular date locale loaders, translation files, and first-render startup ordering aligned.
- When browser or desktop update handling changes, keep service-worker notices separate from native update status and install behavior.
- When service-worker eligibility changes, keep production checks separate from Electron, file-origin, and TV-shell detection.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A locale chunk finishes after a newer language request | The UI can switch back to an older language or render dates with missing locale data | Register date data before switching language and apply only the latest request. apps/…/app-date-locales.ts• L39-54 |
| A native Android checkpoint belongs to another source profile | Old device progress can overwrite the current source | Check the active profile, checkpoint identity, timestamp, and content bounds before saving. apps/…/android-playback-checkpoint.ts• L68-137 |
| A delayed local activity write completes after a newer action | Older progress can replace newer progress | Keep source-scoped write fences and durable local snapshots. apps/…/activity-position-write-fence.ts• L13-67, apps/…/activity-local-only-positions.ts• L146-225 |
| Browser client points to a backend that rejects its origin | Provider calls fail at the browser boundary | Keep runtime configuration and backend origin rules aligned. apps/…/web-backend-app.ts• L103-116 |
| Browser provider request skips target registration | The backend rejects the request before contacting the provider | Register the provider URL before proxy calls. apps/…/pwa-xtream-request.ts• L91-127 |
| Browser sends source authorization to another backend | A source token can be exposed to or rejected by the wrong server | Attach authorization only after instance verification. libs/…/source-authorization.ts• L26-47 |
| Source inventory is not ready before workspace activation | The workspace can show stale or incomplete sources | Keep source readiness in startup gates and expose recovery pages. apps/…/app-startup-status.component.ts• L156-169 |
| A settings control has no capability or save mapping | The user can change a value that has no effect | Keep capability gates, form paths, changed-path selection, and runtime status aligned. apps/…/settings-form.facade.ts• L288-378 |
| Settings change elsewhere while the page has a staged edit | A save can overwrite a newer value or discard a restored guide source | Rebase the form against the current store and retain unsettled writes. apps/…/settings-form-rebase.ts• L94-179, apps/…/settings-form-writes.ts• L47-114 |
| Settings storage or desktop runtime rejects a save | The UI can claim success or lose edits that did not apply | Keep the form dirty, show the matching failure, and allow retry. apps/…/settings.component.ts• L463-483, apps/…/settings.component.storage-failure.spec.ts• L72-93 |
| Electron renderer loads before native handlers are ready | Early application actions call an unavailable bridge | Register handlers before loading the window. apps/…/main.ts• L170-199 |
| A PWA update is treated as a desktop update | The client can use an unavailable native install path | Keep service-worker and Electron update flows separate. apps/…/pwa-update.service.ts• L11-107, apps/…/settings-about-section.component.html• L45-130 |
| A browser connectivity-guard reset waits on a stalled backend | Retry appears to hang before the provider request starts | Bound the reset call and let the provider request report the real result. apps/…/pwa.service.ts• L152-201 |
Key files
| File | Why to read it |
|---|---|
| apps/…/main.ts | Shows browser pre-bootstrap work, locale setup, route recovery, and source connection setup. |
| apps/…/app.config.ts | Shows shared Angular composition and runtime service selection. |
| apps/…/app.component.ts | Shows common startup, playlist loading, language application, and guide freshness work. |
| apps/…/global-collection-route.component.ts | Shows shared favorites and recent collections across source types. |
| apps/…/workspace-shell-actions.service.ts | Shows runtime-neutral shell actions for search, source import, recent items, and account views. |
| apps/…/activity-sync-runtime.ts | Shows shared playback activity, consent, conflicts, and local fallback. |
| apps/…/android-playback-checkpoint.ts | Shows how Android-shell progress enters the shared playback boundary. |
| apps/…/activity-position-adapter.ts | Shows how local and shared playback positions are combined. |
| apps/…/settings.component.ts | Shows settings capability gates, staged saves, failure handling, and runtime lifecycle. |
| apps/…/settings-form.facade.ts | Shows how staged settings are saved and mirrored to the desktop runtime. |
| apps/…/settings-form-rebase.ts | Shows how settings keep outside changes and staged edits consistent. |
| apps/…/settings-about-section.component.ts | Shows desktop update channels and browser update status decisions. |
| apps/…/electron.service.ts | Shows how shared requests cross into the desktop bridge and how native errors return. |
| apps/…/pwa.service.ts | Shows browser backend calls, provider request handling, and bounded retry reset. |
| apps/…/pwa-update.service.ts | Shows browser service-worker update states and reload behavior. |
| apps/…/pwa-playlist-refresh.ts | Shows browser playlist refresh and guide-store update behavior. |
| apps/…/runtime-config.ts | Shows backend selection and service-worker eligibility. |
| apps/…/source-proxy.ts | Shows browser source authorization and verification. |
| libs/…/source-sync.service.ts | Shows the source inventory lifecycle and sync states. |
| apps/…/server-migration-prompt.service.ts | Shows the browser startup offer for moving local sources to server storage. |
| apps/…/settings-playlist-reset.facade.ts | Shows runtime-specific deletion of all playlists and local lock cleanup. |
| apps/…/main.ts | Shows Electron setup order, lifecycle, and shutdown. |
| apps/…/main.preload.ts | Shows the native capability bridge and renderer events. |
| apps/…/web-backend-app.ts | Shows the browser backend boundary and provider request flow. |