1
0
Fork 0
mirror of https://gitlab.com/futo-org/fcast.git synced 2025-06-24 21:25:23 +00:00

webOS: Ported receiver to Electron 2.1.0 changes

This commit is contained in:
Michael Hollister 2025-05-09 10:44:26 -05:00
parent 61c1e9a9c1
commit e3c437a280
16 changed files with 2402 additions and 978 deletions

View file

@ -1,6 +1,13 @@
import { Opcode } from 'common/Packets';
import { Logger, LoggerType } from 'common/Logger';
// Required for webOS since preload declared interface is not available on the backend
declare global {
interface Window {
targetAPI: any;
}
}
// Window might be re-created while devices are still connected
export function setUiUpdateCallbacks(callbacks: any) {
const logger = window.targetAPI.logger;

View file

@ -157,7 +157,14 @@ export class Logger {
// @ts-ignore
} else if (TARGET === 'webOS' || TARGET === 'tizenOS') {
this.funcTable = {
trace: (message?: any, ...optionalParams: any[]) => console.trace(message, ...optionalParams),
debug: (message?: any, ...optionalParams: any[]) => console.log(message, ...optionalParams),
info: (message?: any, ...optionalParams: any[]) => console.log(message, ...optionalParams),
warn: (message?: any, ...optionalParams: any[]) => console.warn(message, ...optionalParams),
error: (message?: any, ...optionalParams: any[]) => console.error(message, ...optionalParams),
fatal: (message?: any, ...optionalParams: any[]) => console.error(message, ...optionalParams),
};
} else {
// @ts-ignore
console.warn(`Attempting to initialize logger on unsupported target: ${TARGET}`);

View file

@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Opcode } from 'common/Packets';
import { Logger, LoggerType } from 'common/Logger';
const logger = new Logger('MainWindow', LoggerType.FRONTEND);
@ -55,7 +54,14 @@ if (TARGET === 'electron') {
window.targetAPI = {
onDeviceInfo: (callback: () => void) => preloadData.onDeviceInfoCb = callback,
getDeviceInfo: () => preloadData.deviceInfo,
getSessions: (callback: () => any) => preloadData.getSessionsCb = callback,
getSessions: (callback?: () => Promise<[any]>) => {
if (callback) {
preloadData.getSessionsCb = callback;
}
else {
return preloadData.getSessionsCb();
}
},
onConnect: (callback: (_, value: any) => void) => preloadData.onConnectCb = callback,
onDisconnect: (callback: (_, value: any) => void) => preloadData.onDisconnectCb = callback,
logger: loggerInterface,

View file

@ -75,7 +75,14 @@ if (TARGET === 'electron') {
onSeek: (callback: any) => { preloadData.onSeekCb = callback; },
onSetVolume: (callback: any) => { preloadData.onSetVolumeCb = callback; },
onSetSpeed: (callback: any) => { preloadData.onSetSpeedCb = callback; },
getSessions: (callback: any) => { preloadData.getSessionsCb = callback; },
getSessions: (callback?: () => Promise<[any]>) => {
if (callback) {
preloadData.getSessionsCb = callback;
}
else {
return preloadData.getSessionsCb();
}
},
onConnect: (callback: any) => { preloadData.onConnectCb = callback; },
onDisconnect: (callback: any) => { preloadData.onDisconnectCb = callback; },
logger: loggerInterface,