mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-09 01:16:15 -08:00
Add a new HttpServer class that serves the built remote-control-web static assets and provides a simple REST/API routing layer for remote control endpoints. Key changes: - Implement server lifecycle: start, stop, updateSettings with port and enabled handling. - Resolve distribution path depending on electron packaging (dev vs production). - Serve static files with basic security (normalize path to prevent traversal) and SPA fallback to index.html for client-side routing. - Provide registration API for remote control handlers mapped to /api/remote-control/* endpoints. - Log server status and listening URL on start, and on stop. These changes enable the Electron backend to host the remote control web app and route API calls without external web servers, simplifying development and packaging.
174 lines
6.3 KiB
TypeScript
174 lines
6.3 KiB
TypeScript
import 'jest-extended';
|
|
import { Playlist } from './libs/shared/interfaces/src/lib/playlist.interface';
|
|
|
|
declare module 'video.js' {
|
|
export interface VideoJsPlayer {
|
|
hlsQualitySelector(options?: Record<string, unknown>): void;
|
|
}
|
|
}
|
|
|
|
declare global {
|
|
interface Window {
|
|
electron: {
|
|
getAppVersion: () => Promise<string>;
|
|
platform: string;
|
|
fetchPlaylistByUrl: (
|
|
url: string,
|
|
title?: string
|
|
) => Promise<Playlist>;
|
|
updatePlaylistFromFilePath: (
|
|
filePath: string,
|
|
title: string
|
|
) => Promise<Playlist>;
|
|
openPlaylistFromFile: () => Promise<Playlist>;
|
|
saveFileDialog: (
|
|
defaultPath: string,
|
|
filters?: { name: string; extensions: string[] }[]
|
|
) => Promise<string | null>;
|
|
writeFile: (
|
|
filePath: string,
|
|
content: string
|
|
) => Promise<{ success: boolean }>;
|
|
setUserAgent: (userAgent: string, referer?: string) => void;
|
|
openInMpv: (
|
|
url: string,
|
|
title: string,
|
|
userAgent: string,
|
|
referer?: string,
|
|
origin?: string
|
|
) => void;
|
|
openInVlc: (
|
|
url: string,
|
|
title: string,
|
|
userAgent: string,
|
|
referer?: string,
|
|
origin?: string
|
|
) => void;
|
|
autoUpdatePlaylists: (playlists: Playlist[]) => Promise<Playlist[]>;
|
|
fetchEpg: (
|
|
urls: string[]
|
|
) => Promise<{ success: boolean; message?: string }>;
|
|
getChannelPrograms: (channelId: string) => Promise<any>;
|
|
getEpgChannels: () => Promise<any>;
|
|
getEpgChannelsByRange: (
|
|
skip: number,
|
|
limit: number
|
|
) => Promise<any>;
|
|
forceFetchEpg: (
|
|
url: string
|
|
) => Promise<{ success: boolean; message?: string }>;
|
|
updateSettings: (settings: any) => Promise<void>;
|
|
setMpvPlayerPath: (mpvPlayerPath: string) => Promise<void>;
|
|
setVlcPlayerPath: (vlcPlayerPath: string) => Promise<void>;
|
|
stalkerRequest: (payload: {
|
|
url: string;
|
|
macAddress: string;
|
|
params: Record<string, string>;
|
|
}) => Promise<any>;
|
|
xtreamRequest: (payload: {
|
|
url: string;
|
|
params: Record<string, string>;
|
|
}) => Promise<{ payload: any; action: string }>;
|
|
// Database operations
|
|
dbCreatePlaylist: (playlist: any) => Promise<{ success: boolean }>;
|
|
dbGetPlaylist: (playlistId: string) => Promise<any>;
|
|
dbUpdatePlaylist: (
|
|
playlistId: string,
|
|
updates: any
|
|
) => Promise<{ success: boolean }>;
|
|
dbDeletePlaylist: (
|
|
playlistId: string
|
|
) => Promise<{ success: boolean }>;
|
|
dbDeleteXtreamContent: (
|
|
playlistId: string
|
|
) => Promise<{
|
|
success: boolean;
|
|
favoritedXtreamIds: number[];
|
|
recentlyViewedXtreamIds: { xtreamId: number; viewedAt: string }[];
|
|
}>;
|
|
dbRestoreXtreamUserData: (
|
|
playlistId: string,
|
|
favoritedXtreamIds: number[],
|
|
recentlyViewedXtreamIds: { xtreamId: number; viewedAt: string }[]
|
|
) => Promise<{ success: boolean }>;
|
|
dbHasCategories: (
|
|
playlistId: string,
|
|
type: string
|
|
) => Promise<boolean>;
|
|
dbGetCategories: (
|
|
playlistId: string,
|
|
type: string
|
|
) => Promise<any[]>;
|
|
dbSaveCategories: (
|
|
playlistId: string,
|
|
categories: any[],
|
|
type: string
|
|
) => Promise<{ success: boolean }>;
|
|
dbHasContent: (
|
|
playlistId: string,
|
|
type: string
|
|
) => Promise<boolean>;
|
|
dbGetContent: (playlistId: string, type: string) => Promise<any[]>;
|
|
dbSaveContent: (
|
|
playlistId: string,
|
|
streams: any[],
|
|
type: string
|
|
) => Promise<{ success: boolean; count: number }>;
|
|
dbSearchContent: (
|
|
playlistId: string,
|
|
searchTerm: string,
|
|
types: string[]
|
|
) => Promise<any[]>;
|
|
dbGlobalSearch: (
|
|
searchTerm: string,
|
|
types: string[]
|
|
) => Promise<any[]>;
|
|
dbGetRecentlyViewed: () => Promise<any[]>;
|
|
dbClearRecentlyViewed: () => Promise<{ success: boolean }>;
|
|
// Favorites
|
|
dbAddFavorite: (
|
|
contentId: number,
|
|
playlistId: string
|
|
) => Promise<{ success: boolean }>;
|
|
dbRemoveFavorite: (
|
|
contentId: number,
|
|
playlistId: string
|
|
) => Promise<{ success: boolean }>;
|
|
dbIsFavorite: (
|
|
contentId: number,
|
|
playlistId: string
|
|
) => Promise<boolean>;
|
|
dbGetFavorites: (playlistId: string) => Promise<any[]>;
|
|
// Recently viewed (playlist-specific)
|
|
dbGetRecentItems: (playlistId: string) => Promise<any[]>;
|
|
dbAddRecentItem: (
|
|
contentId: number,
|
|
playlistId: string
|
|
) => Promise<{ success: boolean }>;
|
|
dbClearPlaylistRecentItems: (
|
|
playlistId: string
|
|
) => Promise<{ success: boolean }>;
|
|
dbRemoveRecentItem: (
|
|
contentId: number,
|
|
playlistId: string
|
|
) => Promise<{ success: boolean }>;
|
|
dbGetContentByXtreamId: (
|
|
xtreamId: number,
|
|
playlistId: string
|
|
) => Promise<any | null>;
|
|
// Remote control
|
|
onChannelChange?: (
|
|
callback: (data: { direction: 'up' | 'down' }) => void
|
|
) => void;
|
|
};
|
|
process: NodeJS.Process;
|
|
require: NodeRequire;
|
|
}
|
|
}
|
|
|
|
// SystemJS module definition
|
|
declare const nodeModule: NodeModule;
|
|
interface NodeModule {
|
|
id: string;
|
|
}
|