Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified AppPayload type checking #452

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 1 addition & 51 deletions src/core/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,41 +87,6 @@ export const defaultDeviceInfo: DeviceInfo = {
platform: platform,
};

export function isDeviceInfo(value: any): value is DeviceInfo {
return (
value &&
typeof value.developerId === "string" &&
typeof value.friendlyName === "string" &&
typeof value.deviceModel === "string" &&
typeof value.firmwareVersion === "string" &&
typeof value.clientId === "string" &&
typeof value.RIDA === "string" &&
typeof value.countryCode === "string" &&
typeof value.timeZone === "string" &&
typeof value.locale === "string" &&
typeof value.captionLanguage === "string" &&
typeof value.clockFormat === "string" &&
typeof value.displayMode === "string" &&
typeof value.defaultFont === "string" &&
typeof value.fontPath === "string" &&
(value.fonts instanceof Map || value.fonts === undefined) &&
typeof value.maxSimulStreams === "number" &&
Array.isArray(value.customFeatures) &&
isConnectionInfo(value.connectionInfo) &&
Array.isArray(value.localIps) &&
typeof value.startTime === "number" &&
typeof value.audioVolume === "number" &&
typeof value.maxFps === "number" &&
(value.registry instanceof Map || value.registry === undefined) &&
(value.audioCodecs instanceof Array || value.audioCodecs === undefined) &&
(value.videoFormats instanceof Map || value.videoFormats === undefined) &&
(value.appList instanceof Array || value.appList === undefined) &&
(typeof value.entryPoint === "boolean" || value.entryPoint === undefined) &&
(typeof value.stopOnCrash === "boolean" || value.stopOnCrash === undefined) &&
(value.runContext instanceof Object || value.runContext === undefined)
);
}

/* Execution Payload Interface
*
* This interface is used to provide information to the interpreter about the
Expand All @@ -147,7 +112,7 @@ export type AppPayload = {
export function isAppPayload(value: any): value is AppPayload {
return (
value &&
isDeviceInfo(value.device) &&
typeof value.device === "object" &&
typeof value.launchTime === "number" &&
value.manifest instanceof Map &&
value.deepLink instanceof Map &&
Expand Down Expand Up @@ -316,21 +281,6 @@ export type ConnectionInfo = {
protocol?: string;
ssid?: string;
};
// Function to check if a value is a ConnectionInfo object
export function isConnectionInfo(value: any): value is ConnectionInfo {
return (
value &&
typeof value.type === "string" &&
["WiFiConnection", "WiredConnection", ""].includes(value.type) &&
typeof value.name === "string" &&
typeof value.ip === "string" &&
typeof value.gateway === "string" &&
["Excellent", "Good", "Fair", "Poor"].includes(value.quality) &&
(value.dns instanceof Array || value.dns === undefined) &&
(typeof value.protocol === "string" || value.protocol === undefined) &&
(typeof value.ssid === "string" || value.ssid === undefined)
);
}

// Shared array data types enumerator
export enum DataType {
Expand Down
Loading