Skip to content

Commit

Permalink
Fixed more static analysis issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lvcabral committed Dec 13, 2024
1 parent 7235f9f commit 912ee53
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/core/brsTypes/components/RoInputEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { Interpreter } from "../../interpreter";

export class RoInputEvent extends BrsComponent implements BrsValue {
readonly kind = ValueKind.Object;
private id: number;
private response?: BrsType;
readonly id: number;
readonly response?: BrsType;

constructor(response?: BrsType) {
super("roInputEvent");
Expand Down
6 changes: 3 additions & 3 deletions src/core/brsTypes/components/RoVideoPlayerEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { MediaEvent } from "../../common";

export class RoVideoPlayerEvent extends BrsComponent implements BrsValue {
readonly kind = ValueKind.Object;
private flags: number;
private index: number;
private message: string;
readonly flags: number;
readonly index: number;
readonly message: string;

constructor(flags: number, index: number) {
super("roVideoPlayerEvent");
Expand Down
47 changes: 21 additions & 26 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ export async function getReplInterpreter(payload: Partial<AppPayload>) {
if (payload.device.registry?.size) {
replInterpreter.setRegistry(payload.device.registry);
}
setupDeviceData(payload.device, replInterpreter);
setupDeviceFonts(payload.device, replInterpreter);
setupDeviceData(replInterpreter, payload.device);
setupDeviceFonts(replInterpreter, payload.device);
}
return replInterpreter;
}
Expand Down Expand Up @@ -374,9 +374,10 @@ function setupPayload(interpreter: Interpreter, payload: AppPayload): SourceResu
if (payload.device.registry?.size) {
interpreter.setRegistry(payload.device.registry);
}
setupDeviceData(payload.device, interpreter);
setupDeviceFonts(payload.device, interpreter);
return setupPackageFiles(payload, interpreter);
setupDeviceData(interpreter, payload.device);
setupDeviceFonts(interpreter, payload.device);
setupTranslations(interpreter);
return setupPackageFiles(interpreter, payload);
}

interface SerializedPCode {
Expand Down Expand Up @@ -413,10 +414,10 @@ function setupInputParams(
/**
* Updates the interpreter DeviceInfo Map with the provided data and
* initializes the common: file system with device internal libraries.
* @param device object with device info data
* @param interpreter the Interpreter instance to update
* @param device object with device info data
*/
function setupDeviceData(device: DeviceInfo, interpreter: Interpreter) {
function setupDeviceData(interpreter: Interpreter, device: DeviceInfo) {
Object.keys(device).forEach((key) => {
if (key !== "registry" && key !== "fonts") {
if (key === "developerId") {
Expand All @@ -442,10 +443,10 @@ function setupDeviceData(device: DeviceInfo, interpreter: Interpreter) {

/**
* Updates the interpreter `common:` volume with device internal fonts.
* @param device object with device info data
* @param interpreter the Interpreter instance to update
* @param device object with device info data
*/
function setupDeviceFonts(device: DeviceInfo, interpreter: Interpreter) {
function setupDeviceFonts(interpreter: Interpreter, device: DeviceInfo) {
let fontFamily = device.defaultFont ?? "Asap";
let fontPath = device.fontPath ?? "../fonts/";

Expand Down Expand Up @@ -494,12 +495,12 @@ function setupDeviceFonts(device: DeviceInfo, interpreter: Interpreter) {
/**
* Updates the interpreter pkg: file system with the provided package files and
* loads the translation data based on the configured locale.
* @param payload with the source code, manifest and all the assets of the app.
* @param interpreter the Interpreter instance to update
* @param payload with the source code, manifest and all the assets of the app.
*
* @returns a SourceResult object with the source map or the pcode data.
*/
function setupPackageFiles(payload: AppPayload, interpreter: Interpreter): SourceResult {
function setupPackageFiles(interpreter: Interpreter, payload: AppPayload): SourceResult {
const result: SourceResult = { sourceMap: new Map<string, string>() };
const fsys = interpreter.fileSystem;
if (!fsys || !Array.isArray(payload.paths)) {
Expand All @@ -513,24 +514,18 @@ function setupPackageFiles(payload: AppPayload, interpreter: Interpreter): Sourc
} else {
result.iv = fsys.readFileSync(`pkg:/${filePath.url}`, "utf8");
}
} else if (filePath.type === "source") {
if (
Array.isArray(payload.source) &&
typeof payload.source[filePath.id] === "string"
) {
result.sourceMap.set(filePath.url, payload.source[filePath.id]);
} else if (fsys.existsSync(`pkg:/${filePath.url}`)) {
result.sourceMap.set(
filePath.url,
fsys.readFileSync(`pkg:/${filePath.url}`, "utf8")
);
}
} else if (filePath.type === "source" && Array.isArray(payload.source)) {
result.sourceMap.set(filePath.url, payload.source[filePath.id]);
} else if (filePath.type === "source" && fsys.existsSync(`pkg:/${filePath.url}`)) {
result.sourceMap.set(
filePath.url,
fsys.readFileSync(`pkg:/${filePath.url}`, "utf8")
);
}
} catch (err: any) {
postMessage(`error,Error writing file ${filePath.url} - ${err.message}`);
postMessage(`error,Error accessing file ${filePath.url} - ${err.message}`);
}
}
loadTranslations(interpreter);
return result;
}

Expand All @@ -539,7 +534,7 @@ function setupPackageFiles(payload: AppPayload, interpreter: Interpreter): Sourc
* @param interpreter the Interpreter instance to update
*/

function loadTranslations(interpreter: Interpreter) {
function setupTranslations(interpreter: Interpreter) {
let xmlText = "";
let trType = "";
let trTarget = "";
Expand Down

0 comments on commit 912ee53

Please sign in to comment.