mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-16 06:06:18 -08:00
* perf(web): take the Material snack-bar off the startup path The seven services and the app shell created with the app injected MatSnackBar, and snack-bar.mjs statically imports Material's button, the icon button chunk, ripple and the CDK a11y module, so about 110 KB sat in the initial bundle although a toast shows only after an event. A root LazySnackBar (@iptvnator/services/lazy-snack-bar) resolves the snack-bar from a dynamic import the way LazyMatDialog does, retrying after a failed chunk load, and opens text toasts with MatSnackBar.open's arguments; a failed load is logged without the message. The eager importers open their toasts through it with unchanged messages, actions, durations and panel classes; lazy code keeps injecting MatSnackBar. The startup status defers its Retry button, the other eager importer of the button chunk, with a native button as the error fallback. Local production build: renderer.initialBytes 1,349,048 -> 1,236,918 (-112,130, -8.3%); no Material module is in the initial bundle any more. The CDK overlay, scrolling and portal chunks (about 78 KB) stay through the FullscreenOverlayContainer provider in app.config.ts. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(web): keep a native Retry while the startup button chunk loads Greptile (local round 1): the failure screen had no Retry button until the deferred Material button chunk arrived. One native button, drawn in the flat button's shape with theme colours, is now the placeholder and the error view of the defer block, so a retry is possible while the chunk downloads and after a failed load. Baseline and docs follow the re-measured value, 1,237,440 bytes. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * docs(perf): point the initialBytes evidence at the opened pull request The baseline and the performance doc named the predicted number; the pull request opened as #1939. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * test(web): cover the toast actions behind the lazy snack-bar Greptile (PR round 1): the Refresh and Trust-host actions now run after LazySnackBar.open resolves, and no test exercised them. The PWA update toast test holds the toast promise, then resolves it and picks Refresh; the page reload is a field the spec substitutes, as jsdom's location cannot be spied on. The Electron test does the same for the TLS trust toast: the confirmation opens only once the toast is up, approving it records the host and retries the fetch. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * test(web): type the stubbed toast ref as Observable<undefined> CI's spec typecheck rejected `typeof EMPTY` (Observable<never>) for a stub that returns `of(undefined)`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * perf(web): lower the initialBytes baseline to the merged measurement Merged with #1938 the branch measures 1,231,455 bytes on a local production build (the radio play control's fab tokens left the stylesheet); the baseline follows it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * perf(web): lower the initialBytes baseline to the zoneless merged measurement Merged with #1929, #1936 and #1938 the branch measures 1,178,109 bytes on a local production build; the baseline follows it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * perf(web): re-measure initialBytes after merging #1903 and #1942 Merged with #1903 (self-hosted server storage, which raised master's baseline by 7,245 bytes on purpose) and #1942 the branch measures 1,187,983 bytes on a local production build, below master's 1,285,523; no Material module is in the initial bundle. The new favorites effect spec provides the LazySnackBar stub the merged effect injects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf(xtream): open favorites toasts through LazySnackBar #1934 gave the Xtream store's favorites feature a static MatSnackBar injection. The store exists from startup, so that one import put Material's snack-bar, button, icon-button and ripple chunks (about 95 KB) back on the renderer's initial path. The feature now opens its two toasts through LazySnackBar with the same messages and durations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(perf): count statically imported chunks in renderer.initialBytes Angular's builder emits at most ten modulepreload hints. Once the startup graph passed ten chunks, the rest were fetched through main.js's own imports but never counted, so the counter stopped growing and an eager MatSnackBar import on master went unnoticed. The script now follows the static import graph of every counted script (dynamic import() targets stay lazy; a missing imported file is an error), which matches the bundler's metafile closure exactly: 1,196,205 bytes for this branch, where the old counter read 1,098,535. The baseline follows the new measurement and its note now explains the current limit (Greptile). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(perf): parse startup imports and count them per request URL Codex (PR round): the regexes also matched import-shaped text in strings, templates and comments, which could count a lazy chunk or fail on a file that does not exist. Static declarations are now read from TypeScript's syntax tree (top-level import/export-from statements only). Imports are also deduplicated by request URL, like the index.html references, so a preload of chunk.js?v=1 no longer hides an import of ./chunk.js. The real build still measures 1,196,205 bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
369 lines
12 KiB
TypeScript
369 lines
12 KiB
TypeScript
import {
|
|
ChangeDetectionStrategy,
|
|
Component,
|
|
computed,
|
|
inject,
|
|
input,
|
|
} from '@angular/core';
|
|
import { NgTemplateOutlet } from '@angular/common';
|
|
import { toSignal } from '@angular/core/rxjs-interop';
|
|
import { MatButton } from '@angular/material/button';
|
|
import { NavigationEnd, Router } from '@angular/router';
|
|
import { Store } from '@ngrx/store';
|
|
import { TranslatePipe } from '@ngx-translate/core';
|
|
import { filter, map } from 'rxjs';
|
|
import {
|
|
PlaylistActions,
|
|
selectPlaylistsLoadFailed,
|
|
selectPlaylistsLoadingFlag,
|
|
} from '@iptvnator/m3u-state';
|
|
import { SERVER_SIGN_IN_PATH } from '@iptvnator/services';
|
|
|
|
/** The first route also waits for settings and XMLTV source reconciliation. */
|
|
@Component({
|
|
selector: 'app-startup-status',
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
imports: [MatButton, NgTemplateOutlet, TranslatePipe],
|
|
template: `
|
|
@if (!complete()) {
|
|
<section
|
|
[attr.role]="failed() ? 'alert' : 'status'"
|
|
aria-live="polite"
|
|
>
|
|
<svg
|
|
class="startup-watermark"
|
|
viewBox="0 0 256 256"
|
|
aria-hidden="true"
|
|
focusable="false"
|
|
>
|
|
<g fill="none" stroke="currentColor" stroke-width="5">
|
|
<rect x="46" y="53" width="166" height="115" rx="2" />
|
|
<path d="M128 168v32M67 200h122" />
|
|
<path
|
|
d="M94 101Q129 72 165 101M101 109Q129 85 158 109M108 117Q129 99 151 117"
|
|
/>
|
|
</g>
|
|
<path
|
|
d="M119 126Q129 120 139 126L129 138Z"
|
|
fill="currentColor"
|
|
/>
|
|
</svg>
|
|
@if (!failed()) {
|
|
<div class="startup-spinner" aria-hidden="true">
|
|
<div class="startup-spinner__container">
|
|
<div class="startup-spinner__layer">
|
|
<div
|
|
class="startup-spinner__clipper startup-spinner__clipper--left"
|
|
>
|
|
<svg
|
|
viewBox="0 0 25.2 25.2"
|
|
focusable="false"
|
|
>
|
|
<circle r="11" cx="50%" cy="50%" />
|
|
</svg>
|
|
</div>
|
|
<div class="startup-spinner__gap">
|
|
<svg
|
|
viewBox="0 0 25.2 25.2"
|
|
focusable="false"
|
|
>
|
|
<circle r="11" cx="50%" cy="50%" />
|
|
</svg>
|
|
</div>
|
|
<div
|
|
class="startup-spinner__clipper startup-spinner__clipper--right"
|
|
>
|
|
<svg
|
|
viewBox="0 0 25.2 25.2"
|
|
focusable="false"
|
|
>
|
|
<circle r="11" cx="50%" cy="50%" />
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
<h1>
|
|
{{
|
|
(failed() ? 'STARTUP.FAILED' : 'STARTUP.PREPARING')
|
|
| translate
|
|
}}
|
|
</h1>
|
|
<p>
|
|
{{
|
|
(failed()
|
|
? 'STARTUP.FAILED_DETAIL'
|
|
: 'STARTUP.PREPARING_DETAIL'
|
|
) | translate
|
|
}}
|
|
</p>
|
|
@if (failed()) {
|
|
<!--
|
|
Material's button loads with the failure branch so the
|
|
first screen does not carry the button chunk. A native
|
|
button retries while the chunk downloads and stays when
|
|
the load fails.
|
|
-->
|
|
@defer (on immediate) {
|
|
<button mat-flat-button type="button" (click)="retry()">
|
|
{{ 'RETRY' | translate }}
|
|
</button>
|
|
} @placeholder {
|
|
<ng-container [ngTemplateOutlet]="nativeRetry" />
|
|
} @error {
|
|
<ng-container [ngTemplateOutlet]="nativeRetry" />
|
|
}
|
|
<ng-template #nativeRetry>
|
|
<button
|
|
class="startup-retry-native"
|
|
type="button"
|
|
(click)="retry()"
|
|
>
|
|
{{ 'RETRY' | translate }}
|
|
</button>
|
|
</ng-template>
|
|
}
|
|
</section>
|
|
}
|
|
`,
|
|
styles: `
|
|
:host {
|
|
display: contents;
|
|
}
|
|
section {
|
|
app-region: drag;
|
|
position: relative;
|
|
isolation: isolate;
|
|
overflow: clip;
|
|
min-height: 100dvh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 12px;
|
|
padding: 48px 24px;
|
|
box-sizing: border-box;
|
|
background: var(--app-content-bg);
|
|
color: var(--app-heading-color);
|
|
text-align: center;
|
|
}
|
|
.startup-watermark {
|
|
position: absolute;
|
|
right: -14%;
|
|
bottom: -34%;
|
|
width: clamp(420px, 76vw, 960px);
|
|
height: auto;
|
|
opacity: 0.07;
|
|
transform: rotate(-14deg);
|
|
mask-image: linear-gradient(135deg, transparent 15%, #000 78%);
|
|
pointer-events: none;
|
|
z-index: 0;
|
|
}
|
|
section > :not(svg) {
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
h1 {
|
|
margin: 0;
|
|
font-size: 18px;
|
|
font-weight: 500;
|
|
}
|
|
p {
|
|
margin: 0;
|
|
max-width: 420px;
|
|
color: var(--app-body-color);
|
|
line-height: 1.5;
|
|
}
|
|
button {
|
|
margin-top: 8px;
|
|
app-region: no-drag;
|
|
}
|
|
/* The flat button's shape in the theme's colours, until the
|
|
Material button loads. */
|
|
.startup-retry-native {
|
|
height: 40px;
|
|
padding: 0 24px;
|
|
border: 0;
|
|
border-radius: 20px;
|
|
background: var(--mat-sys-primary);
|
|
color: var(--mat-sys-on-primary);
|
|
font: inherit;
|
|
font-weight: 500;
|
|
cursor: pointer;
|
|
}
|
|
|
|
/*
|
|
* The same drawing as an indeterminate <mat-spinner diameter="32">
|
|
* (two clipped half circles plus a gap patch, Material's durations,
|
|
* curves and keyframes, a 10% stroke on a 25.2 viewBox around an
|
|
* r=11 circle, 1.25x slower under reduced motion), as static markup:
|
|
* the component would load the progress-spinner chunk before the
|
|
* app's first screen and set every attribute after insertion.
|
|
*/
|
|
.startup-spinner {
|
|
--startup-spinner-multiplier: 1;
|
|
position: relative;
|
|
width: 32px;
|
|
height: 32px;
|
|
overflow: hidden;
|
|
line-height: 0;
|
|
direction: ltr;
|
|
}
|
|
@media (prefers-reduced-motion: reduce) {
|
|
.startup-spinner {
|
|
--startup-spinner-multiplier: 1.25;
|
|
}
|
|
}
|
|
.startup-spinner__container,
|
|
.startup-spinner__layer,
|
|
.startup-spinner svg {
|
|
position: absolute;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
.startup-spinner__container {
|
|
animation: startup-spinner-container-rotate
|
|
calc(1568.2352941176ms * var(--startup-spinner-multiplier))
|
|
linear infinite;
|
|
}
|
|
.startup-spinner__layer {
|
|
animation: startup-spinner-layer-rotate
|
|
calc(5332ms * var(--startup-spinner-multiplier))
|
|
cubic-bezier(0.4, 0, 0.2, 1) infinite both;
|
|
}
|
|
.startup-spinner__clipper {
|
|
display: inline-flex;
|
|
position: relative;
|
|
width: 50%;
|
|
height: 100%;
|
|
overflow: hidden;
|
|
}
|
|
.startup-spinner__clipper svg {
|
|
width: 200%;
|
|
}
|
|
.startup-spinner__clipper--left svg {
|
|
animation: startup-spinner-left-spin
|
|
calc(1333ms * var(--startup-spinner-multiplier))
|
|
cubic-bezier(0.4, 0, 0.2, 1) infinite both;
|
|
}
|
|
.startup-spinner__clipper--right svg {
|
|
left: -100%;
|
|
animation: startup-spinner-right-spin
|
|
calc(1333ms * var(--startup-spinner-multiplier))
|
|
cubic-bezier(0.4, 0, 0.2, 1) infinite both;
|
|
}
|
|
.startup-spinner__gap {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 47.5%;
|
|
box-sizing: border-box;
|
|
width: 5%;
|
|
height: 100%;
|
|
overflow: hidden;
|
|
}
|
|
.startup-spinner__gap svg {
|
|
left: -900%;
|
|
width: 2000%;
|
|
transform: rotate(180deg);
|
|
}
|
|
.startup-spinner svg {
|
|
fill: transparent;
|
|
}
|
|
.startup-spinner circle {
|
|
stroke: var(--mat-sys-primary);
|
|
stroke-width: 10%;
|
|
stroke-dasharray: 69.11503837897544px;
|
|
stroke-dashoffset: 34.55751918948772px;
|
|
}
|
|
@media (forced-colors: active) {
|
|
.startup-spinner circle {
|
|
stroke: CanvasText;
|
|
}
|
|
}
|
|
@keyframes startup-spinner-container-rotate {
|
|
to {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
@keyframes startup-spinner-layer-rotate {
|
|
12.5% {
|
|
transform: rotate(135deg);
|
|
}
|
|
25% {
|
|
transform: rotate(270deg);
|
|
}
|
|
37.5% {
|
|
transform: rotate(405deg);
|
|
}
|
|
50% {
|
|
transform: rotate(540deg);
|
|
}
|
|
62.5% {
|
|
transform: rotate(675deg);
|
|
}
|
|
75% {
|
|
transform: rotate(810deg);
|
|
}
|
|
87.5% {
|
|
transform: rotate(945deg);
|
|
}
|
|
100% {
|
|
transform: rotate(1080deg);
|
|
}
|
|
}
|
|
@keyframes startup-spinner-left-spin {
|
|
from {
|
|
transform: rotate(265deg);
|
|
}
|
|
50% {
|
|
transform: rotate(130deg);
|
|
}
|
|
to {
|
|
transform: rotate(265deg);
|
|
}
|
|
}
|
|
@keyframes startup-spinner-right-spin {
|
|
from {
|
|
transform: rotate(-265deg);
|
|
}
|
|
50% {
|
|
transform: rotate(-130deg);
|
|
}
|
|
to {
|
|
transform: rotate(-265deg);
|
|
}
|
|
}
|
|
`,
|
|
})
|
|
export class AppStartupStatusComponent {
|
|
private readonly store = inject(Store);
|
|
readonly routeReady = input(false);
|
|
private readonly sourcesReady = this.store.selectSignal(
|
|
selectPlaylistsLoadingFlag
|
|
);
|
|
readonly failed = this.store.selectSignal(selectPlaylistsLoadFailed);
|
|
private readonly router = inject(Router);
|
|
private readonly url = toSignal(
|
|
this.router.events.pipe(
|
|
filter((event) => event instanceof NavigationEnd),
|
|
map((event) => event.urlAfterRedirects)
|
|
),
|
|
{ initialValue: this.router.url }
|
|
);
|
|
/**
|
|
* Server storage asking for a token: the playlists cannot load, and the
|
|
* sign-in page must stay up whatever its check reports.
|
|
*/
|
|
private readonly onSignInPage = computed(() =>
|
|
this.url().startsWith(SERVER_SIGN_IN_PATH)
|
|
);
|
|
readonly complete = computed(
|
|
() => this.routeReady() && (this.sourcesReady() || this.onSignInPage())
|
|
);
|
|
|
|
retry(): void {
|
|
this.store.dispatch(PlaylistActions.loadPlaylists());
|
|
}
|
|
}
|