perf(playback): keep the history gate off the initial bundle

The `@iptvnator/services` barrel ships in the initial bundle, so adding
PlaybackHistoryGate there (and subscribing to it from the app-wide
ExternalPlaybackService) grew renderer.initialBytes by 1,141 bytes.

- Move the gate to a new lazy-only `playback-data-access` project
  (`@iptvnator/playback/data-access`; scope:shared, domain:playback,
  type:data-access) and register it in the coverage policy.
- The gate subscribes to MPV/VLC session updates itself; it is created by
  the first deferred write, which precedes the launch it waits for.
  ExternalPlaybackService is back to master.
- The Xtream "playlist switched before confirmation" check moves to the
  lazy helper; the initial-path store only takes a `skipListRefresh` flag.

Net effect on this branch: +27 bytes over master (master itself is
108 bytes over the ratchet baseline already).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
4grayandClaude Opus 5.5 committed 2026-09-27 13:41:31 +02:00
1 parent 671a0cb1ec
commit e41bcb9f65
34 files changed
+250 -128

No files matched your search

@@ -1,5 +1,3 @@
import { TestBed } from '@angular/core/testing';
import { PlaybackHistoryGate } from '@iptvnator/services';
import { ExternalPlayerSession } from '@iptvnator/shared/interfaces';
import { ExternalPlaybackService } from './external-playback.service';
@@ -42,36 +40,7 @@ describe('ExternalPlaybackService', () => {
},
});
service = TestBed.runInInjectionContext(
() => new ExternalPlaybackService()
);
});
it('commits deferred history once the external player has opened', () => {
const commit = jest.fn();
TestBed.inject(PlaybackHistoryGate).defer(
{ streamUrls: ['https://example.com/video.m3u8'] },
commit
);
listener?.(createSession({ status: 'launching' }));
expect(commit).not.toHaveBeenCalled();
listener?.(createSession({ status: 'opened' }));
expect(commit).toHaveBeenCalledTimes(1);
});
it('does not commit history for a launch that failed', () => {
const commit = jest.fn();
TestBed.inject(PlaybackHistoryGate).defer(
{ streamUrls: ['https://example.com/video.m3u8'] },
commit
);
listener?.(createSession({ status: 'launching' }));
listener?.(createSession({ status: 'error', error: 'not found' }));
expect(commit).not.toHaveBeenCalled();
service = new ExternalPlaybackService();
});
it('tracks the latest launch and hides dismissed sessions until the next launch', () => {
@@ -1,5 +1,4 @@
import { computed, inject, Injectable, signal } from '@angular/core';
import { PlaybackHistoryGate } from '@iptvnator/services';
import { computed, Injectable, signal } from '@angular/core';
import {
ExternalPlayerSession,
PlayerContentInfo,
@@ -9,7 +8,6 @@ import {
providedIn: 'root',
})
export class ExternalPlaybackService {
private readonly historyGate = inject(PlaybackHistoryGate);
readonly activeSession = signal<ExternalPlayerSession | null>(null);
private readonly dismissedSessionId = signal<string | null>(null);
@@ -104,12 +102,6 @@ export class ExternalPlaybackService {
}
private handleSessionUpdate(session: ExternalPlayerSession): void {
// MPV/VLC cannot report whether a live stream really plays, so a
// successful launch is what commits the deferred history write.
if (session.status === 'opened' || session.status === 'playing') {
this.historyGate.confirm({ streamUrls: [session.streamUrl] });
}
const current = this.activeSession();
const restoresCurrentReplacement =
current?.id === session.restoredFromSessionId;