refactor(runtime): enable pwa xtream section navigation

This commit is contained in:
4gray committed 2026-05-22 13:38:53 +03:00
1 parent 676e8bb5da
commit b4fd93354e
3 files changed
+23 -4

No files matched your search

+3 -1
View File
@@ -74,7 +74,9 @@ from one shared boundary. `supportsSqlite` requires the complete playlist
storage preload API surface used by `PlaylistsService`, `supportsDownloads`
requires the complete downloads preload API surface used by `DownloadsService`,
`supportsPlaylistRefresh` requires the native playlist refresh/cancel/progress
bridge, and
bridge, `supportsXtreamSectionNavigation` is available in PWA and in Electron
when either the SQLite Xtream data source or the Xtream API transport is
available, and
`supportsManagedExternalPlayers` requires the MPV and VLC preload launch methods
(`openInMpv` and `openInVlc`); a partial Electron bridge must not expose
desktop-only actions in the PWA/shared UI.
@@ -30,7 +30,7 @@ describe('RuntimeCapabilitiesService', () => {
expect(service.supportsEmbeddedMpv).toBe(false);
expect(service.supportsDesktopFileSave).toBe(false);
expect(service.supportsRemoteControl).toBe(false);
expect(service.supportsXtreamSectionNavigation).toBe(false);
expect(service.supportsXtreamSectionNavigation).toBe(true);
});
it('reports Electron capabilities from the available preload bridge methods', () => {
@@ -103,6 +103,7 @@ describe('RuntimeCapabilitiesService', () => {
updateRemoteControlStatus: jest.fn(),
onChannelChange: jest.fn(),
onRemoteControlCommand: jest.fn(),
xtreamRequest: jest.fn(),
};
const service = new RuntimeCapabilitiesService();
@@ -145,7 +146,7 @@ describe('RuntimeCapabilitiesService', () => {
expect(service.supportsEmbeddedMpv).toBe(false);
expect(service.supportsDesktopFileSave).toBe(false);
expect(service.supportsRemoteControl).toBe(false);
expect(service.supportsXtreamSectionNavigation).toBe(true);
expect(service.supportsXtreamSectionNavigation).toBe(false);
});
it('reads the bridge dynamically so tests and late preload setup stay accurate', () => {
@@ -251,6 +252,18 @@ describe('RuntimeCapabilitiesService', () => {
expect(service.supportsSqlite).toBe(true);
});
it('supports Xtream section navigation in Electron when Xtream API transport is available', () => {
testWindow.electron = {
xtreamRequest: jest.fn(),
};
const service = new RuntimeCapabilitiesService();
expect(service.isElectron).toBe(true);
expect(service.supportsXtreamSqliteDataSource).toBe(false);
expect(service.supportsXtreamSectionNavigation).toBe(true);
});
});
function createPlaylistStorageBridge(): Record<string, jest.Mock> {
@@ -156,7 +156,11 @@ export class RuntimeCapabilitiesService {
}
get supportsXtreamSectionNavigation(): boolean {
return this.isElectron;
return (
this.isPwa ||
this.supportsXtreamSqliteDataSource ||
this.hasElectronMethod('xtreamRequest')
);
}
private hasElectronMethod(methodName: string): boolean {