Browser client
The browser client is the web form of IPTVnator. It starts the shared Angular application in a browser, combines workspace and UI libraries into one experience, and sends playlist and provider work through the browser backend. It uses browser storage by default and can use a self-hosted server for shared storage or source data. It shares product flows with the Electron desktop runtime while using browser transport and PWA services instead of native services. It is one of the client applications.
Browser application model
The browser application keeps most product behavior in shared workspace and portal libraries. The web layer supplies startup wiring, browser transport, browser-safe capability choices, settings access, and the visual system that turns those libraries into a usable page.
Startup sequence
The startup sequence changes the first page load from a blank document into a ready workspace. The page shows a small loading surface first. The browser entry point restores carried route context, prepares the player and source connection, loads the preferred date locale, probes the configured backend, and selects the correct storage mode before it starts the Angular root component. The root then restores settings and playlist state and starts browser-wide services. apps/…/main.ts• L8-43, apps/…/renderer-reload.ts• L7-39, apps/…/player-loading-rollback.ts• L1-22, apps/…/app.component.ts• L118-177, libs/…/source-connection.ts• L48-125
The client keeps the route hidden until settings, parental-lock state, the first route, playlist state, and XMLTV source reconciliation are ready. AppStartupStatusComponent gives this wait a clear state and offers a retry when playlist loading fails. Server sign-in and settings remain reachable when source inventory fails. A separate source status surface can also expose a failed first inventory or an offline cached library without hiding recovery behind the normal workspace. apps/…/app-startup-status.component.ts• L22-173, apps/…/app-startup-recovery.component.ts• L14-79, apps/…/source-sync-status.component.ts• L10-40, apps/…/source-sync-status-view.component.ts• L15-141
After startup state is available, the root applies language and theme, starts guide work only for stale sources, refreshes playlists when needed, and starts wake-lock and parental-lock behavior. It then opens the dashboard, sources view, or a valid saved workspace view. Desktop menu and operating-system playlist-open listeners are attached through safe browser checks, so they do nothing when no desktop bridge exists. Startup playlist refresh reports complete, partial, failed, and skipped outcomes instead of treating a mixed result as full success. apps/…/app.component.ts• L183-325, apps/…/pwa-playlist-refresh.ts• L13-64, apps/…/app-menu-actions.ts• L4-21, apps/…/playlist-open-request.service.ts• L16-141
The first render can use a small browser-storage language hint before settings load. The full settings record remains the source of truth. Date locale data loads on demand in separate locale chunks, failed locale loads fall back to English, and only the latest overlapping language choice wins. The document language follows the active translation. apps/…/app.config.ts• L68-80, apps/…/app-date-locale-data.ts• L9-80, apps/…/app-date-locales.ts• L12-54, apps/…/app-language-preference.ts• L3-21, apps/…/document-language.ts• L7-48
References: apps/…/index.html• L1-80 apps/…/main.ts• L8-43 apps/…/renderer-reload.ts• L7-39 apps/…/player-loading-rollback.ts• L1-22 libs/…/source-connection.ts• L48-125 apps/…/app.component.ts• L118-325 apps/…/app-startup-status.component.ts• L22-173 apps/…/app-startup-recovery.component.ts• L14-79 apps/…/source-sync-status.component.ts• L10-40 apps/…/source-sync-status-view.component.ts• L15-141 apps/…/pwa-playlist-refresh.ts• L13-64 apps/…/app-menu-actions.ts• L4-21 apps/…/playlist-open-request.service.ts• L16-141 apps/…/app-date-locale-data.ts• L9-80 apps/…/app-date-locales.ts• L12-54 apps/…/app-language-preference.ts• L3-21 apps/…/document-language.ts• L7-48
Browser runtime configuration
The browser runtime selects its backend URL from the active source-server connection when one is present outside Electron. Otherwise it uses the page-level setting and then the build-time URL as a fallback. One bundle can therefore serve a hosted deployment, a self-hosted backend, or a selected source server. The resolved URL controls capability checks and provider transport. apps/…/app-config.js• L1, apps/…/runtime-config.ts• L3-21, apps/…/main.ts• L24-29, apps/…/environment.prod.ts• L3-8
The page keeps assets/app-config.js outside the service-worker asset cache. A deployment can change the backend target without a new application bundle. The page also defines the browser resource policy for application and provider media paths. apps/…/index.html• L10-27, ngsw-config.json• L19-29
References: apps/…/app-config.js• L1 apps/…/runtime-config.ts• L3-21 apps/…/main.ts• L24-29 apps/…/index.html• L10-27 ngsw-config.json• L19-29
Server storage mode
Server storage mode lets a browser use the data store belonging to a self-hosted backend instead of creating a separate local library. Before Angular starts, the client asks the configured backend for instance details. A supported server enables server-storage providers and a session. An older or unsupported backend leaves the client in normal browser mode. apps/…/main.ts• L24-29, apps/…/server-instance-probe.ts• L26-79, apps/…/server-storage.providers.ts• L17-42
The client remembers the server instance per backend identity. If the server is temporarily unreachable, a browser that used it before can start in offline server mode. If the backend answers as a different instance or has no server storage, the client clears the old token and does not mix data between stores. A first switch to server storage can offer a one-time move of local playlists. The migration waits until the first route settles, uses a non-dismissible dialog with explicit Move or Not now actions, and reloads after a successful move so the server library becomes the active source. apps/…/server-storage-start.ts• L19-64, apps/…/server-migration-prompt.service.ts• L12-49, apps/…/server-migration-dialog.component.html• L1-74
This diagram shows how backend capability checks select the browser data store and how local data can move into a server library.
flowchart LR
U[Resolved backend URL] --> P[Server capability probe]
P -->|Supported| S[Server storage session]
P -->|Unsupported| B[Browser storage]
S --> M{Local playlists need move?}
M -->|Yes| R[Migration and reload]
M -->|No| A[Shared Angular application]
R --> A
S --> O[Offline server start when identity is remembered]
O --> A
B --> A
References: apps/…/main.ts• L24-29 apps/…/server-instance-probe.ts• L5-79 apps/…/server-storage-start.ts• L19-64 apps/…/server-migration-prompt.service.ts• L12-49 apps/…/server-migration-dialog.component.html• L1-74
Source server mode
Source server mode lets the browser use a selected server as the shared source inventory. The client keeps a verified connection and profile-specific user data, then reloads shared playlist state when the server reports a source change. Local favorites and other personal state remain separate by default. Optional activity, history, and favorites profiles can share selected user data with that source-server instance. apps/…/source-sync.providers.ts• L20-53, apps/…/source-sync-runtime.ts• L9-49, apps/…/activity-consent.ts• L3-19, apps/…/favorites-consent.ts• L1-19
The browser verifies the source-server instance before it sends source or provider credentials. Requests carry a short-lived token only after that check. A network or gateway outage revokes the proof, and the next request probes without credentials before access resumes. This prevents secrets from reaching a replacement server at the same address. apps/…/source-proxy.ts• L18-79, apps/…/pwa.service.ts• L587-641
The server settings page supports connect, refresh, disconnect, forget, and a preview before import. Local sources can be copied as new shared definitions without moving local favorites or recent history. The browser validates and normalizes the server address before contact. A connected hosted-server runtime can offer a local server shortcut. apps/…/settings-server-section.component.html• L1-272, apps/…/settings-server-section.component.ts• L69-307
The source status banner stays outside the routed workspace. It can show a failed first inventory, a locked connection, a connecting state, or an offline cached library. It can lead to server settings, retry the connection, or be dismissed when cached data remains usable. apps/…/source-sync-status.component.ts• L10-40, apps/…/source-sync-status-view.component.ts• L15-141
References: apps/…/source-sync.providers.ts• L20-53 apps/…/source-sync-runtime.ts• L9-49 apps/…/source-proxy.ts• L18-79 apps/…/pwa.service.ts• L587-641 apps/…/settings-server-section.component.html• L1-272 apps/…/settings-server-section.component.ts• L69-307 apps/…/source-sync-status.component.ts• L10-40 apps/…/source-sync-status-view.component.ts• L15-141 apps/…/activity-consent.ts• L3-19 apps/…/favorites-consent.ts• L1-19
Build profiles
The web project has separate profiles for hosted production, PWA, local development, Electron test runs, and performance runs. Production and PWA profiles use optimized output and can enable the service worker. Development and Electron profiles keep PWA behavior off. Diagnostic choices stay at the build boundary and do not change workspace features. apps/…/project.json• L54-205, apps/…/app.config.ts• L108-126
References: apps/…/project.json• L13-25 apps/…/project.json• L54-152 apps/…/project.json• L177-205 apps/…/app.config.ts• L108-126
Service worker lifecycle
The service worker is the browser client's PWA worker. Production builds enable it only when the browser supports service workers and the page is not running through the Electron bridge, the Android TV or hosted-access shell, or a file: URL. Electron and the Android TV client can use the same web bundle without using this worker. apps/…/app.config.ts• L123-126, apps/…/runtime-config.ts• L24-69
The worker registers after the application is stable or after a 30-second wait. It preloads the application shell, loads other assets when needed, and detects new application versions. The browser exposes a persistent update notice in Settings and in the application surface. A ready or unrecoverable update offers reload, while a failed check offers retry. The notice can be dismissed and returns focus to the workspace content. Workspace work uses the normal application services rather than a separate custom worker. apps/…/app.config.ts• L123-126, apps/…/project.json• L31-35, ngsw-config.json• L1-31, apps/…/pwa-update.service.ts• L11-107, apps/…/pwa-update-notification.component.ts• L6-71
References: apps/…/app.config.ts• L123-126 apps/…/runtime-config.ts• L24-69 apps/…/project.json• L31-35 ngsw-config.json• L1-31 apps/…/pwa-update.service.ts• L11-107 apps/…/pwa-update-notification.component.ts• L6-71
Workspace experience
The workspace is the main browser surface. It gives the user one place to manage sources, browse provider content, search, view favorites and recent items, inspect downloads, play media, and change settings.
Workspace shell
The workspace shell supplies the stable frame around routed content. It combines navigation, the header, a context sidebar, the content outlet, import and drop surfaces, keyboard actions, and the playback dock. Routed features appear inside this frame instead of rebuilding common controls for each provider. On a phone, the context sidebar becomes a modal drawer and the hidden workspace stays inert while the drawer is open. libs/…/workspace-shell.component.ts• L33-58, libs/…/workspace-shell.component.html• L1-137
The browser supplies shell actions through one application contract. Search and recent items use workspace routes. Playlist import and provider account details open lazy dialogs only when requested. Desktop menu actions use the same settings and update flow without adding desktop update work to normal browser launch. apps/…/workspace-shell-actions.service.ts• L14-103, apps/…/app-menu-actions.ts• L4-21, apps/…/app-maintenance.service.ts• L16-36
References: libs/…/workspace-shell.component.ts• L33-58 libs/…/workspace-shell.component.html• L1-137 apps/…/workspace-shell-actions.service.ts• L14-103 apps/…/app-menu-actions.ts• L4-21 apps/…/app-maintenance.service.ts• L16-36
Workspace routes
The route tree maps the workspace frame to product areas and loads those areas only when needed. It includes the dashboard, sources, M3U player, Xtream and Stalker views, global favorites, recent items, search, downloads, recording details, and settings. Provider routes stay inside the same shell. Guards make startup readiness and runtime capability part of navigation. apps/…/app.routes.ts• L11-70, apps/…/app.routes.ts• L72-207
References: apps/…/app.routes.ts• L11-70 apps/…/app.routes.ts• L72-207
Browser settings
Browser settings let the user shape playback, layout, startup, language, theme, guide display, update behavior, remote control, provider metadata, server access, activity sharing, backup, parental lock, and local data from one routed area. The page groups choices by app, library, and device concerns, then hides controls that the current runtime cannot support. Browser builds show PWA update checks and reload actions, while desktop update controls stay outside the browser path. apps/…/settings.component.ts• L174-196, apps/…/settings-options.ts• L145-191, apps/…/settings-general-section.component.ts• L43-54, apps/…/settings-about-section.component.html• L45-130
The settings form remains alive while the user changes sections. It stages edits until Save and gives one save bar for changes from all sections. Route changes, reloads, window close, and app quit use the same save, discard, or stay choice. Invalid staged values cannot be saved from the leave dialog. Leaf-level change tracking lets navigation mark affected sections, while restart notices describe saved values that the running app cannot use yet. When another surface changes settings while the page is open, the form rebases its saved view without dropping the user's staged edits. apps/…/settings.component.ts• L270-505, apps/…/settings-unsaved-changes-dialog.component.ts• L11-107, apps/…/settings-form.facade.ts• L239-391, apps/…/settings-form-rebase.ts• L32-179
The appearance area offers named visual presets, a System pair for light and dark device modes, an optional accent color, cover size, and cover-title display. A preset applies at once for preview. The form saves it only after the user chooses Save, and Discard restores the stored appearance. Accent tokens adapt their brightness to the active surfaces so selection, progress, Material controls, and focus remain readable. apps/…/settings-appearance-section.component.html• L7-233, apps/…/settings-appearance-section.component.ts• L53-129, apps/…/settings-theme-preview.ts• L21-63, apps/…/settings.service.ts• L44-153, apps/…/theme-accent-tokens.ts• L54-105
The sections cover general appearance and startup, playback, EPG, dashboard rails, TMDB metadata, parental lock, remote control, backup and data, server access, activity sharing, and About. Browser playback settings expose only controls supported by the selected player. They can shape web-player controls, ambient mode, captions, trailers, series autoplay, up-next surfaces, fullscreen channel controls, and web-player VOD failover. Desktop-only external player paths, recording folders, embedded MPV options, and self-update channel controls remain hidden from the browser. apps/…/settings.component.html• L64-226, apps/…/settings-form.utils.ts• L64-176, apps/…/settings-options.ts• L114-165, apps/…/settings-about-section.component.ts• L103-157
TMDB settings can test a key, show and clear the local metadata cache, choose the age-rating country, and transfer a saved key through a connected source server. The transfer uses a short-lived session and applies the received key only while the same server instance and expected local key remain current. Storage failures stay visible instead of silently turning the form into defaults. apps/…/settings-tmdb-section.component.html• L25-265, apps/…/settings-tmdb-section.component.ts• L103-204, apps/…/settings-tmdb-transfer-dialog.component.html• L1-149, apps/…/settings-snackbar.service.ts• L21-56
EPG display settings remain available when XMLTV source management is not. Backup import reports a summary and reloads playlist state when the library changes. Browser export downloads a JSON file, while a complete desktop bridge can save the same backup through a native file dialog. Activity-aware export presents local and shared playback positions in the same backup flow. Delete-all clearly separates local deletion from server-wide deletion and shows its effect on favorites, recent history, playback positions, and Xtream cache. apps/…/settings-epg.facade.ts• L13-158, apps/…/settings-backup.facade.ts• L48-208, apps/…/settings-playlist-reset.facade.ts• L66-159
The About section keeps the installed version and build identity visible from the start. Browser PWA builds can check for a new cached application version and reload when it is ready. Desktop builds can select stable or nightly update channels, compare the installed version with the chosen release service, and download or install a supported update. apps/…/settings-about-section.component.html• L7-130, apps/…/settings-about-section.component.ts• L49-157, apps/…/settings-app-update.facade.ts• L21-239, apps/…/pwa-update.service.ts• L11-107
References: apps/…/settings.component.ts• L174-259 apps/…/settings.component.ts• L270-505 apps/…/settings.component.html• L51-272 apps/…/settings-form.facade.ts• L121-391 apps/…/settings-form.utils.ts• L38-176 apps/…/settings-form-rebase.ts• L32-179 apps/…/settings-form-writes.ts• L7-114 apps/…/settings-unsaved-changes-dialog.component.ts• L11-107 apps/…/settings-appearance-section.component.html• L7-233 apps/…/settings-appearance-section.component.ts• L53-129 apps/…/settings.service.ts• L44-218 apps/…/theme-accent-tokens.ts• L54-119 apps/…/settings-general-section.component.ts• L43-87 apps/…/settings-about-section.component.ts• L49-292 apps/…/settings-about-section.component.html• L7-130 apps/…/settings-epg.facade.ts• L13-158 apps/…/settings-backup.facade.ts• L48-208 apps/…/settings-playlist-reset.facade.ts• L66-159 apps/…/settings-app-update.facade.ts• L21-239 apps/…/pwa-update.service.ts• L11-107
Parental lock
The parental lock hides selected categories and their content until the user enters a PIN. Its actions are immediate and PIN-protected rather than part of the staged settings form. The lock protects the workspace view and catalog state. It does not protect readable local data files. apps/…/parental-lock-prompt.service.ts• L10-63, apps/…/settings-form.utils.ts• L263-278
References: apps/…/app.routes.ts• L11-21 apps/…/parental-lock-prompt.service.ts• L10-63 apps/…/settings-form.utils.ts• L263-278
Workspace views
The sources view turns stored playlists into the starting point for provider work. The dashboard turns recent activity, favorites, guide data, source status, and optional discovery data into rails that lead back to the same provider routes. Shared state means a source or playback change can update the source list, dashboard, and portal views together. libs/…/workspace-sources.component.ts• L25-193, libs/…/workspace-dashboard-rails.component.ts• L109-144, libs/…/workspace-dashboard-rails.component.ts• L223-503
Global favorites and recent views use one collection surface across playlist types. When an item needs provider-specific detail, the browser loads the matching Xtream or Stalker detail surface on demand and passes the current series resume target into it. The host shows loading state, ignores an obsolete load, and forwards close requests back to the collection page. apps/…/global-collection-route.component.ts• L81-220
References: libs/…/workspace-sources.component.ts• L25-193 libs/…/workspace-dashboard-rails.component.ts• L109-144 libs/…/workspace-dashboard-rails.component.ts• L223-503 apps/…/global-collection-route.component.ts• L81-220
Global search
Global search gives the workspace one search entry point for provider catalogs. It combines the shared Xtream result surface with Stalker results grouped by source, while applying media filters, hidden-item rules, and the current parental-lock state. Search starts only when the query is long enough and a matching source exists. Failed Stalker source searches can be retried one source at a time. apps/…/global-search-route.component.ts• L49-115
Selecting a Stalker result builds a detail route with its source, media type, category, item state, and return location. This keeps a result opened from search connected to the same provider detail flow used elsewhere in the workspace. apps/…/global-search-route.component.ts• L117-137
References: apps/…/global-search-route.component.ts• L1-139 apps/…/global-search-route.component.html• L1-200 apps/…/stalker-global-search.service.ts• L1-220 apps/…/xtream-search-results.lazy.ts• L1-120
Library composition
The browser client is an assembly point for shared libraries. Its configuration provides common state, translation, browser persistence, portal data sources, playback contracts, workspace actions, source synchronization, and optional favorites, history, activity, and native playback checkpoint synchronization. Feature routes then load library-owned screens that use those contracts.
Shared state and storage
The client provides the playlist store and effects for application-wide source state. It provides browser persistence for playlists and settings, then restores settings before dependent routes render. Server storage providers can replace the user-data store with a backend session. Source-server mode keeps profile-specific local user data while the shared source inventory comes from the server. These modes keep one state contract without mixing their data. apps/…/app.config.ts• L111-177, apps/…/app.component.ts• L171-215, apps/…/server-storage.providers.ts• L24-41, apps/…/source-sync.providers.ts• L29-45
History and favorites use separate optional bridges at this composition boundary. A source-server profile can enable shared view history or shared favorites without changing ordinary local writes. Disabled or unset profiles keep the local path. Playback positions use the shared browser data source, so continue-watching and player views use the same saved positions. apps/…/history-sync.providers.ts• L4-20, libs/…/history-events.ts• L7-27, apps/…/favorites-sync.providers.ts• L4-25, libs/…/favorites-events.ts• L3-25, libs/…/playlist-history.ts• L1-183, apps/…/portal-playback-positions.service.ts• L18-130
References: apps/…/app.config.ts• L111-177 apps/…/app.component.ts• L171-215 apps/…/server-storage.providers.ts• L24-41 apps/…/source-sync.providers.ts• L29-45 apps/…/history-sync.providers.ts• L4-20 libs/…/history-events.ts• L7-27 apps/…/favorites-sync.providers.ts• L4-25 libs/…/favorites-events.ts• L3-25 libs/…/playlist-history.ts• L1-183 apps/…/portal-playback-positions.service.ts• L18-130
Activity synchronization
Activity synchronization is an opt-in service for sharing playback progress across browser or desktop clients connected to the same source-server instance. Consent is bound to that server instance and device profile. The client checks server capability before enabling delivery, keeps pending and conflicting activity visible, and falls back to local playback storage when the server is unavailable. Local fallback records are bound to the source identity so an old server or source cannot claim them. apps/…/activity-consent.ts• L3-19, apps/…/activity-consent-transition.ts• L37-117, apps/…/activity-runtime-client.ts• L18-106, apps/…/activity-local-only-positions.ts• L31-125
The runtime starts lazily and refreshes activity for active playlist sources. Playback events enter the activity service, while position reads and writes combine local records, shared records, resets, and durable local-only work. A write fence and per-item queue stop delayed offline work from replacing a newer user action. Settings can send or keep parked activity, choose the local or server side of a conflict, and import local positions. apps/…/activity-sync-runtime.ts• L119-249, apps/…/activity-position-adapter.ts• L49-183, apps/…/activity-local-only-positions.ts• L170-285, apps/…/activity-position-write-fence.ts• L13-67, apps/…/settings-activity-section.component.html• L18-201
This diagram shows how playback activity stays local by default and crosses the source-server boundary only after consent and capability checks.
flowchart LR
P[Playback event or position change] --> C{Activity consent enabled?}
C -->|No| L[Local playback storage]
C -->|Yes| R[Activity runtime]
R --> V[Verified source-server profile]
V -->|Delivered| S[Shared activity state]
V -->|Offline or pending| F[Durable local fallback]
S --> M[Workspace and portal views]
F --> M
References: apps/…/app.config.ts• L154-175 apps/…/activity-consent.ts• L3-19 apps/…/activity-runtime-client.ts• L18-106 apps/…/activity-sync-runtime.ts• L119-249 apps/…/activity-position-adapter.ts• L49-183 apps/…/activity-local-only-positions.ts• L31-285 apps/…/activity-position-write-fence.ts• L13-67 apps/…/settings-activity-section.component.ts• L35-119
Native playback checkpoints
The browser client can restore playback progress from an Android TV shell when that shell exposes the TvShell bridge. The bridge sends validated checkpoints to the browser, which saves only a newer position for the active source profile and acknowledges the checkpoint after persistence. A failed save leaves the checkpoint pending for a later retry. apps/…/android-playback-checkpoint.providers.ts• L9-31, apps/…/android-playback-checkpoint.ts• L19-137
The checkpoint bridge is optional and does not change ordinary browser startup. The provider installs it only when the Android shell exists. It also keeps native reset markers until the matching shell launch confirms that no checkpoint remains, so a stale native position cannot replace a later clear or newer playback action. apps/…/android-playback-checkpoint.ts• L40-137, apps/…/android-playback-checkpoint.ts• L140-217
References: apps/…/app.config.ts• L155-156 apps/…/android-playback-checkpoint.providers.ts• L9-31 apps/…/android-playback-checkpoint.ts• L19-217 apps/…/portal-playback-positions.service.ts• L28-48
UI and playback libraries
The UI libraries provide visible building blocks for workspace and portal pages. Shared components cover content details, dialogs, lists, playback docks, portal shells, and controls. The playback library provides embedded players and recovery behavior. The EPG library provides guide timelines, lists, program views, and progress surfaces. libs/…/index.ts• L1-30, libs/…/index.ts• L1-18, libs/…/index.ts• L1-25
The app configuration connects these libraries through small contracts. The player token points to the browser player service. Workspace actions connect commands such as adding a playlist, opening search, and opening account details to browser routes and lazy dialogs. Playback positions, provider data sources, source synchronization, favorites, activity events, native playback checkpoints, and the parental-lock prompt are supplied at the same boundary. apps/…/app.config.ts• L143-177, apps/…/player.service.ts• L18-149, apps/…/workspace-shell-actions.service.ts• L20-103
The player service keeps browser playback inside the shared player contract. Embedded playback remains in the page, while MPV and VLC sessions cross the desktop data-service boundary and are not launched by the browser runtime. The browser can still share activity information for playback requests without depending on native player launch. apps/…/player.service.ts• L28-149, apps/…/electron.service.ts• L187-282
References: libs/…/index.ts• L1-30 libs/…/index.ts• L1-18 libs/…/index.ts• L1-25 apps/…/app.config.ts• L143-177 apps/…/player.service.ts• L18-149 apps/…/workspace-shell-actions.service.ts• L20-103 apps/…/electron.service.ts• L187-282
Browser visual system
The browser build applies one visual system across workspace and library components. Angular Material supplies the component theme. The app adds shared font, light and dark surface tokens, responsive rules, theme-aware controls and overlays, focus behavior, settings surfaces, and Tailwind utilities that resolve to the same Material surface roles. The overlay layer follows the fullscreen surface so menus, tooltips, and dialogs remain usable during fullscreen playback. apps/…/m3-theme.scss• L10-175, apps/…/styles.scss• L1-81, apps/…/tailwind.config.js• L1-56, apps/…/_theme-palettes.scss• L1-446, apps/…/_dark-variant-themes.scss• L1-155, apps/…/_settings-theme.scss• L11-120, apps/…/app.config.ts• L94-114
The root applies the saved theme or follows the operating system when no explicit theme exists. Document-level theme classes and tokens also reach overlays and content outside the root component. Cover size is a browser-wide display preference that shared grids and rails read. The appearance picker previews the same palette tokens that the application uses, without changing the active theme until the user selects it. apps/…/app.component.ts• L192-215, apps/…/settings.service.ts• L44-190, apps/…/settings-appearance-section.component.ts• L81-124, apps/…/_theme-picker.scss• L4-26, apps/…/styles.scss• L112-234
Theme tests check that each preset supplies readable text, selection, progress, and focus colors. Accent tests check contrast across light and dark surfaces and Material roles. These tests protect the visual contract shared by the application and its previews. apps/…/m3-theme.spec.ts• L68-304, apps/…/theme-accent-tokens.spec.ts• L52-139
References: apps/…/m3-theme.scss• L10-374 apps/…/styles.scss• L1-361 apps/…/tailwind.config.js• L1-56 apps/…/_theme-palettes.scss• L1-446 apps/…/_dark-variant-themes.scss• L1-155 apps/…/_theme-picker.scss• L1-329 apps/…/_settings-theme.scss• L11-120 apps/…/app.config.ts• L94-114 apps/…/app.component.ts• L192-215 apps/…/settings.service.ts• L44-218 apps/…/theme-accent-tokens.ts• L54-247 apps/…/m3-theme.spec.ts• L68-304 apps/…/theme-accent-tokens.spec.ts• L52-139
Browser data flow
The browser client keeps provider network access behind the browser backend. Shared portal and workspace features ask the injected data service for work. In the browser, that service registers provider targets and sends HTTP requests to the configured backend instead of contacting provider hosts directly.
Runtime service boundary
The app chooses PwaService when no Electron bridge is present. PwaService maps shared playlist, Xtream, Stalker, and connectivity actions to browser requests. ElectronService keeps the same action boundary while routing desktop-only work through the Electron bridge. Feature code can therefore use one data-service contract without knowing the transport. apps/…/app.config.ts• L85-115, apps/…/pwa.service.ts• L57-149, apps/…/electron.service.ts• L187-282
The browser HTTP boundary selects Fetch when the hosted-access API is present and XHR otherwise. It also applies the source authorization interceptor. This lets hosted browser shells use their access path while ordinary browser requests keep the same shared data-service contract. apps/…/app.config.ts• L112-115
The browser service registers a provider URL once and receives a target identifier. Later parsing and provider requests use that identifier with the backend. The registration cache shares pending registrations, evicts old targets, and retries once when the backend no longer knows a target. It carries provider metadata and credentials through the backend contract. Source-server requests add a separately verified authorization header through the source proxy. apps/…/provider-target-client.ts• L11-91, apps/…/pwa.service.ts• L69-87, apps/…/pwa.service.ts• L375-641, apps/…/source-proxy.ts• L21-79
Xtream requests are browser-only transport work loaded outside the Electron startup payload. Each caller can cancel its own wait and HTTP request without cancelling another caller's shared provider registration. Background actions keep failures in debug output. User-facing actions return an error result and show a translated snackbar. apps/…/pwa-xtream-request.ts• L60-75, apps/…/pwa-xtream-request.ts• L91-133, apps/…/pwa-xtream-request.ts• L137-212
Playlist refresh uses the same shared boundary but keeps the source busy until both the remote download and the local write finish. The browser updates shared state only after storage succeeds. A download, persistence, or provider failure therefore does not publish a partial catalog. apps/…/pwa.service.ts• L203-235, apps/…/pwa-playlist-refresh.ts• L13-64
References: apps/…/app.config.ts• L85-115 apps/…/pwa.service.ts• L57-149 apps/…/provider-target-client.ts• L11-91 apps/…/pwa.service.ts• L203-235 apps/…/pwa.service.ts• L375-641 apps/…/source-proxy.ts• L21-79 apps/…/electron.service.ts• L187-282 apps/…/pwa-xtream-request.ts• L60-212 apps/…/pwa-playlist-refresh.ts• L13-64
Request flow
The request flow moves from a shared user action to a browser backend operation and then to a provider or playlist source. The result returns through the same service contract to the workspace or portal feature.
This diagram shows how a browser action crosses the shared data contract and backend boundary before its result returns to the user interface.
flowchart LR
U[User action] --> W[Workspace or portal feature]
W --> D[Shared data service contract]
D --> P[PwaService]
P --> R[Configured browser backend]
R --> V[Provider or playlist source]
V --> R
R --> P
P --> W
The browser transport keeps provider errors, connectivity failures, and endpoint failures distinct. A retry can ask the backend to clear its host guard with a bounded wait. Stalker discovery can bypass that guard for expected probe failures, while ordinary requests remain guarded. apps/…/pwa.service.ts• L152-201, apps/…/pwa.service.ts• L375-527, apps/…/provider-target-client.ts• L17-60
References: apps/…/pwa.service.ts• L152-201 apps/…/pwa.service.ts• L375-527 apps/…/pwa.service.ts• L529-641 apps/…/provider-target-client.ts• L17-60 apps/…/pwa-xtream-request.ts• L91-212
Browser persistence and playback
Browser persistence keeps playlists, settings, and playback state available across page loads. The client loads settings and playlists during startup, then lets workspace and portal features read shared state. Playback positions feed continue-watching views and portal playback without a desktop database. Activity sharing can merge verified shared progress with local fallback records. Android playback checkpoints use the same portal position contract when an Android TV shell restores native progress. apps/…/app.component.ts• L171-215, apps/…/portal-playback-positions.service.ts• L27-123, apps/…/activity-position-adapter.ts• L286-345, apps/…/android-playback-checkpoint.ts• L68-137, libs/…/workspace-dashboard-rails.component.ts• L223-235
Browser backup gives the user a portable JSON copy of playlist data. Import merges the backup through the shared backup service and reloads playlist state when changes are made. Export uses a browser download unless the runtime supplies the desktop file-save boundary. Activity-aware export presents local and shared playback positions in the same backup flow. apps/…/settings-backup.facade.ts• L52-171, apps/…/activity-sync-settings.ts• L48-75
References: apps/…/app.component.ts• L171-215 apps/…/portal-playback-positions.service.ts• L27-123 apps/…/activity-position-adapter.ts• L286-345 apps/…/android-playback-checkpoint.ts• L68-137 apps/…/settings-backup.facade.ts• L52-171 apps/…/activity-sync-settings.ts• L48-75
Change checklist
When these files or sections are changed, remember to consider these:
- When startup changes, keep route visibility, settings readiness, parental-lock initialization, playlist retry, guide reconciliation, language sync, automatic refresh, carried-route restoration, player preparation, storage selection, source synchronization, and optional native checkpoint setup aligned.
- When the backend URL contract changes, keep page settings, build fallback, source-server selection, service-worker exclusion, provider-target registration, capability probing, HTTP transport choice, and token scope aligned.
- When server storage changes, keep backend identity matching, offline start, token clearing, migration timing, reload behavior, retry behavior, and translation keys aligned.
- When source-server synchronization changes, keep instance verification, token lifetime, profile storage, source-change reloads, recovery routes, address validation, local-source import, and status messages aligned.
- When source status changes, keep the startup-safe fallback, cached-library dismissal, retry behavior, settings route, and deferred Material surface aligned.
- When activity, history, or favorites synchronization changes, keep consent, server instance binding, source ownership, local fallback, pending work, conflicts, and explicit mutation paths aligned.
- When native playback checkpoint handling changes, keep Android shell detection, source-profile checks, reset markers, timestamp ordering, persistence, retry, and acknowledgement aligned.
- When a shared data-service action changes, update both browser and Electron paths. Preserve provider registration, credentials, connectivity reset, cancellation, and error shapes.
- When Xtream transport changes, preserve per-caller cancellation, shared registration, silent background failures, translated user errors, and provider target recovery.
- When playlist refresh changes, keep the busy state, persistence order, store publication, EPG refresh, saved User-Agent, and complete/partial/skipped feedback aligned.
- When settings change, keep the section registry, route cases, capability visibility, search anchors, leaf change tracking, normalizer, preserved values, restart notices, outside-change rebasing, and translation keys aligned.
- When appearance changes, keep preset IDs, light/dark System pairing, live preview and discard behavior, Material roles, accent contrast, focus tokens, cover-size propagation, utility-class tokens, and preview styles aligned.
- When TMDB settings change, keep key testing, cache state, age-rating choice, transfer session expiry, server-instance checks, expected-key checks, and saved-key hydration aligned.
- When playback settings change, keep visible controls aligned with the selected player and runtime capabilities. Do not expose a switch with no active consumer.
- When the service worker changes, keep runtime configuration outside the cache and keep Electron, Android TV or hosted-access shell, and
file:contexts outside PWA update behavior. - When PWA update behavior changes, keep service-worker events, manual checks, retry and reload actions, persistent notification placement, dismissal focus, About status, and translation keys aligned.
- When global search changes, keep Xtream and Stalker result shapes, query limits, source grouping, parental-lock filtering, retry state, detail navigation, and return routes aligned.
- When translation keys change, keep all supported language files aligned with startup, settings, playback, collections, EPG, backup, update, source-server, activity, Android shell, and transfer states.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Startup marks the route ready before settings, lock state, playlists, guide reconciliation, or source inventory are ready | Users see a partly initialized or unprotected workspace | Resolve startup dependencies before workspace activation and keep retry and recovery in the startup surface. apps/…/app-startup-status.component.ts• L146-173 |
| A source-server outage leaves the old identity proof active | Source or provider secrets can reach a replacement server | Revoke authorization on network or gateway outage and verify the instance anonymously before retry. apps/…/source-proxy.ts• L26-79 |
| Runtime backend configuration is cached with the app shell | A deployment can leave the browser pointed at an old backend | Exclude assets/app-config.js from the service-worker asset group. ngsw-config.json• L19-29 |
Service worker runs in Electron, Android TV or hosted-access shell, or on a file: page | The renderer uses the wrong cache and update path | Enable the worker only for supported production browser contexts. apps/…/runtime-config.ts• L45-69 |
| A locale switch changes translations before its date data is ready | Date formatting can fail or show the wrong language | Register the locale before switching translations and discard older overlapping requests. apps/…/app-date-locales.ts• L29-54 |
| An Android checkpoint is accepted for another source profile | Native playback can overwrite progress belonging to another data store | Require the active source profile and acknowledge only after the matching position is saved. apps/…/android-playback-checkpoint.ts• L68-137 |
| One Xtream caller cancels shared registration for all callers | Unrelated provider actions fail or wait forever | Scope cancellation to the caller's request and its own HTTP subscription. apps/…/pwa-xtream-request.ts• L91-133 |
| A background Xtream action shows a user snackbar for an expected probe or refresh failure | Routine background work interrupts the user | Keep silent actions in debug output and reserve snackbars for user-facing actions. apps/…/pwa-xtream-request.ts• L137-212 |
| A playlist refresh publishes the downloaded catalog before the local write finishes | The screen can show data that will disappear after reload | Keep source work busy through persistence and dispatch only the saved playlist. apps/…/pwa-playlist-refresh.ts• L24-55 |
| A lazy feature expects a provider token that the browser app did not provide | The feature fails only when its route opens | Keep player, data-source, workspace-action, lock, source-sync, favorites, activity, and checkpoint providers together in app configuration. apps/…/app.config.ts• L143-177 |
| Settings save replaces the whole stored object after another surface changes it | A user's unrelated change disappears | Write only changed paths and rebase the form against current store values. apps/…/settings-form-rebase.ts• L26-57, apps/…/settings-form.facade.ts• L289-378 |
| Settings save writes a normalized value but leaves change tracking or restart state stale | The save bar or restart notice gives the wrong state | Update the saved snapshot, leaf paths, running values, and section marks together. apps/…/settings-form.facade.ts• L270-323, apps/…/settings-change-tracking.ts• L65-100 |
| Settings storage fails and the form silently falls back to defaults | Users believe values will survive a restart when they will not | Show a dismissible load or save warning and keep edits available for retry. apps/…/settings-snackbar.service.ts• L29-56, apps/…/settings.component.ts• L463-482 |
| A preset or accent omits a surface role or loses contrast | Selection, focus, Material controls, or theme previews become hard to read | Keep palette roles together and run preset and accent contrast checks. apps/…/m3-theme.spec.ts• L141-304, apps/…/theme-accent-tokens.spec.ts• L52-139 |
| A TMDB transfer completes after the source-server instance or local key changes | A key from an old session overwrites current settings | Check session age, connection identity, and expected key before claim and save. apps/…/settings-tmdb-transfer-dialog.component.ts• L161-199, apps/…/settings-tmdb-transfer-dialog.component.ts• L284-331 |
| Activity delivery fails after a newer local position or disable request | A newer position can be lost or sharing can stop before local state is safe | Keep durable local snapshots, serialize writes, fence stale operations, and mirror before disable. apps/…/activity-position-adapter.ts• L64-145, apps/…/activity-sync-runtime.ts• L126-170 |
| A PWA update failure is treated as a reload-ready update | The user reloads into the same broken worker state or loses the retry path | Keep failed checks on Retry and reserve reload for ready or unrecoverable states. apps/…/pwa-update.service.ts• L21-107 |
| Global search opens a Stalker result without its source or return state | The detail page cannot load the item or cannot return to search | Build navigation from the grouped result and preserve the current search URL. apps/…/global-search-route.component.ts• L117-137 |
Key files
| File | Why to read it |
|---|---|
| apps/…/main.ts | Shows the browser entry point, player and source preparation, locale loading, storage selection, and route handoff. |
| apps/…/app.config.ts | Shows how browser services, HTTP transport, state, storage, translations, playback, workspace contracts, synchronization, and native checkpoint recovery are composed. |
| apps/…/app.component.ts | Shows startup state loading, guide freshness work, theme and language setup, playlist auto-refresh, and browser-wide services. |
| apps/…/app-startup-status.component.ts | Shows the startup gate, retry state, and recovery surface. |
| apps/…/runtime-config.ts | Shows backend selection and service-worker eligibility. |
| apps/…/app-date-locale-data.ts | Shows the lazy locale chunks used for browser date formatting. |
| apps/…/app-date-locales.ts | Shows locale readiness and latest-request language selection. |
| apps/…/server-storage-start.ts | Shows online, offline, and browser storage startup decisions. |
| apps/…/server-migration-prompt.service.ts | Shows when the browser offers local playlist migration into server storage. |
| apps/…/source-sync-runtime.ts | Shows source-change refresh, activity startup, and recovery after a source disappears. |
| apps/…/settings.component.ts | Shows settings routing, capability gates, hydration, and save or leave behavior. |
| apps/…/settings-form.facade.ts | Shows settings hydration, leaf change tracking, persistence, rebasing, and restart state. |
| apps/…/pwa-update.service.ts | Shows PWA update checks, retry states, reload states, and worker event handling. |
| apps/…/pwa-update-notification.component.ts | Shows the browser update notice, dismissal behavior, and reload or retry action. |
| apps/…/global-collection-route.component.ts | Shows the shared favorites and recent surface and its lazy provider detail handoff. |
| apps/…/global-search-route.component.ts | Shows search state, grouped Stalker search, Xtream result composition, and detail navigation. |
| apps/…/app.routes.ts | Shows workspace routes, startup readiness, and capability redirects. |
| libs/…/index.ts | Shows the shared UI surfaces used by workspace and portal features. |
| apps/…/m3-theme.scss | Shows Material role composition and per-preset theme boundaries. |
| apps/…/styles.scss | Shows global browser surfaces, focus behavior, overlays, and theme-aware shared styles. |
| apps/…/tailwind.config.js | Shows how utility classes use the browser's Material surface roles. |
| ngsw-config.json | Shows the PWA worker's app-shell and asset cache boundary. |