mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
refactor(epg): route renderer calls through runtime bridge
Add typed EPG runtime bridge, split EPG runtime capabilities, migrate renderer EPG callers away from direct window.electron access, and address Greptile review feedback.
This commit is contained in:
1 parent
87c1c6240d
commit
697eab6e73
20 files changed
+767
-285
No files matched your search
@@ -34,6 +34,15 @@ describe('RuntimeCapabilitiesService', () => {
|
||||
expect(service.supportsDesktopFileSave).toBe(false);
|
||||
expect(service.supportsRemoteControl).toBe(false);
|
||||
expect(service.supportsXtreamSectionNavigation).toBe(true);
|
||||
expect(service.supportsEpgImport).toBe(false);
|
||||
expect(service.supportsEpgProgress).toBe(false);
|
||||
expect(service.supportsEpgProgramLookup).toBe(false);
|
||||
expect(service.supportsEpgCurrentProgramBatch).toBe(false);
|
||||
expect(service.supportsEpgChannelMetadata).toBe(false);
|
||||
expect(service.supportsEpgSourceFreshness).toBe(false);
|
||||
expect(service.supportsEpgDataManagement).toBe(false);
|
||||
expect(service.supportsEpgChannelBrowser).toBe(false);
|
||||
expect(service.supportsEpgProgramSearch).toBe(false);
|
||||
});
|
||||
|
||||
it('reports Electron capabilities from the available preload bridge methods', () => {
|
||||
@@ -111,7 +120,10 @@ describe('RuntimeCapabilitiesService', () => {
|
||||
xtreamRequest: jest.fn(),
|
||||
fetchEpg: jest.fn(),
|
||||
getChannelPrograms: jest.fn(),
|
||||
getCurrentProgramsBatch: jest.fn(),
|
||||
getEpgChannelMetadata: jest.fn(),
|
||||
checkEpgFreshness: jest.fn(),
|
||||
onEpgProgress: jest.fn(),
|
||||
forceFetchEpg: jest.fn(),
|
||||
clearEpgData: jest.fn(),
|
||||
getEpgChannelsByRange: jest.fn(),
|
||||
@@ -139,6 +151,15 @@ describe('RuntimeCapabilitiesService', () => {
|
||||
expect(service.supportsDesktopFileSave).toBe(true);
|
||||
expect(service.supportsRemoteControl).toBe(true);
|
||||
expect(service.supportsXtreamSectionNavigation).toBe(true);
|
||||
expect(service.supportsEpgImport).toBe(true);
|
||||
expect(service.supportsEpgProgress).toBe(true);
|
||||
expect(service.supportsEpgProgramLookup).toBe(true);
|
||||
expect(service.supportsEpgCurrentProgramBatch).toBe(true);
|
||||
expect(service.supportsEpgChannelMetadata).toBe(true);
|
||||
expect(service.supportsEpgSourceFreshness).toBe(true);
|
||||
expect(service.supportsEpgDataManagement).toBe(true);
|
||||
expect(service.supportsEpgChannelBrowser).toBe(true);
|
||||
expect(service.supportsEpgProgramSearch).toBe(true);
|
||||
});
|
||||
|
||||
it('keeps feature-specific capabilities false when an Electron bridge is partial', () => {
|
||||
@@ -165,6 +186,15 @@ describe('RuntimeCapabilitiesService', () => {
|
||||
expect(service.supportsDesktopFileSave).toBe(false);
|
||||
expect(service.supportsRemoteControl).toBe(false);
|
||||
expect(service.supportsXtreamSectionNavigation).toBe(false);
|
||||
expect(service.supportsEpgImport).toBe(false);
|
||||
expect(service.supportsEpgProgress).toBe(false);
|
||||
expect(service.supportsEpgProgramLookup).toBe(false);
|
||||
expect(service.supportsEpgCurrentProgramBatch).toBe(false);
|
||||
expect(service.supportsEpgChannelMetadata).toBe(false);
|
||||
expect(service.supportsEpgSourceFreshness).toBe(false);
|
||||
expect(service.supportsEpgDataManagement).toBe(false);
|
||||
expect(service.supportsEpgChannelBrowser).toBe(false);
|
||||
expect(service.supportsEpgProgramSearch).toBe(false);
|
||||
});
|
||||
|
||||
it('reads the bridge dynamically so tests and late preload setup stay accurate', () => {
|
||||
@@ -275,6 +305,44 @@ describe('RuntimeCapabilitiesService', () => {
|
||||
expect(service.supportsEpg).toBe(true);
|
||||
});
|
||||
|
||||
it('exposes EPG capabilities by the specific preload surface they need', () => {
|
||||
testWindow.electron = {
|
||||
fetchEpg: jest.fn(),
|
||||
onEpgProgress: jest.fn(),
|
||||
getChannelPrograms: jest.fn(),
|
||||
checkEpgFreshness: jest.fn(),
|
||||
forceFetchEpg: jest.fn(),
|
||||
clearEpgData: jest.fn(),
|
||||
getEpgChannelsByRange: jest.fn(),
|
||||
searchEpgPrograms: jest.fn(),
|
||||
};
|
||||
|
||||
const service = new RuntimeCapabilitiesService();
|
||||
|
||||
expect(service.supportsEpg).toBe(true);
|
||||
expect(service.supportsEpgImport).toBe(true);
|
||||
expect(service.supportsEpgProgress).toBe(true);
|
||||
expect(service.supportsEpgProgramLookup).toBe(true);
|
||||
expect(service.supportsEpgCurrentProgramBatch).toBe(false);
|
||||
expect(service.supportsEpgChannelMetadata).toBe(false);
|
||||
expect(service.supportsEpgSourceFreshness).toBe(true);
|
||||
expect(service.supportsEpgDataManagement).toBe(true);
|
||||
expect(service.supportsEpgChannelBrowser).toBe(true);
|
||||
expect(service.supportsEpgProgramSearch).toBe(true);
|
||||
|
||||
testWindow.electron = {
|
||||
checkEpgFreshness: jest.fn(),
|
||||
};
|
||||
|
||||
expect(service.supportsEpg).toBe(false);
|
||||
expect(service.supportsEpgSourceFreshness).toBe(true);
|
||||
expect(service.supportsEpgImport).toBe(false);
|
||||
expect(service.supportsEpgProgramLookup).toBe(false);
|
||||
expect(service.supportsEpgDataManagement).toBe(false);
|
||||
expect(service.supportsEpgChannelBrowser).toBe(false);
|
||||
expect(service.supportsEpgProgramSearch).toBe(false);
|
||||
});
|
||||
|
||||
it('requires the complete downloads preload surface', () => {
|
||||
testWindow.electron = {
|
||||
downloadsGetList: jest.fn(),
|
||||
|
||||
@@ -32,15 +32,53 @@ export class RuntimeCapabilitiesService {
|
||||
}
|
||||
|
||||
get supportsEpg(): boolean {
|
||||
return [
|
||||
'fetchEpg',
|
||||
'getChannelPrograms',
|
||||
'checkEpgFreshness',
|
||||
'forceFetchEpg',
|
||||
'clearEpgData',
|
||||
'getEpgChannelsByRange',
|
||||
'searchEpgPrograms',
|
||||
].every((methodName) => this.hasElectronMethod(methodName));
|
||||
return (
|
||||
this.supportsEpgImport &&
|
||||
this.supportsEpgProgramLookup &&
|
||||
this.supportsEpgSourceFreshness &&
|
||||
this.supportsEpgDataManagement &&
|
||||
this.supportsEpgChannelBrowser &&
|
||||
this.supportsEpgProgramSearch
|
||||
);
|
||||
}
|
||||
|
||||
get supportsEpgImport(): boolean {
|
||||
return this.hasElectronMethod('fetchEpg');
|
||||
}
|
||||
|
||||
get supportsEpgProgress(): boolean {
|
||||
return this.hasElectronMethod('onEpgProgress');
|
||||
}
|
||||
|
||||
get supportsEpgProgramLookup(): boolean {
|
||||
return this.hasElectronMethod('getChannelPrograms');
|
||||
}
|
||||
|
||||
get supportsEpgCurrentProgramBatch(): boolean {
|
||||
return this.hasElectronMethod('getCurrentProgramsBatch');
|
||||
}
|
||||
|
||||
get supportsEpgChannelMetadata(): boolean {
|
||||
return this.hasElectronMethod('getEpgChannelMetadata');
|
||||
}
|
||||
|
||||
get supportsEpgSourceFreshness(): boolean {
|
||||
return this.hasElectronMethod('checkEpgFreshness');
|
||||
}
|
||||
|
||||
get supportsEpgDataManagement(): boolean {
|
||||
return (
|
||||
this.hasElectronMethod('forceFetchEpg') &&
|
||||
this.hasElectronMethod('clearEpgData')
|
||||
);
|
||||
}
|
||||
|
||||
get supportsEpgChannelBrowser(): boolean {
|
||||
return this.hasElectronMethod('getEpgChannelsByRange');
|
||||
}
|
||||
|
||||
get supportsEpgProgramSearch(): boolean {
|
||||
return this.hasElectronMethod('searchEpgPrograms');
|
||||
}
|
||||
|
||||
get supportsSqlite(): boolean {
|
||||
|
||||
Reference in new issue
Block a user