Skip to content
Open
Show file tree
Hide file tree
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
31 changes: 29 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
"@types/decompress": "4.2.7",
"@types/file-saver": "2.0.7",
"@types/lodash": "4.17.24",
"@types/lodash.isequal": "4.5.8",
"@types/md5": "2.3.6",
"@types/node": "24.13.3",
"@types/semver": "7.7.1",
"check-node-version": "4.2.1",
"copy-webpack-plugin": "14.0.0",
"cross-env": "10.1.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/mcumgr/src/util/cbor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ export function decode(data: ArrayBuffer | SharedArrayBuffer, tagger?: Function,
let offset = 0;

if (typeof tagger !== "function")
tagger = function(value) { return value; };
tagger = function(value: unknown): unknown { return value; };
if (typeof simpleValue !== "function")
simpleValue = function() { return undefined; };
simpleValue = function(): undefined { return undefined; };

function commitRead<T extends number | Uint8Array>(length: number, value: T): T {
offset += length;
Expand Down Expand Up @@ -364,7 +364,7 @@ export function decode(data: ArrayBuffer | SharedArrayBuffer, tagger?: Function,
}

case 5: {
const retObject = {};
const retObject: Record<string | number, unknown> = {};
for (i = 0; i < length || length < 0 && !readBreak(); ++i) {
const key = decodeItem() as string | number;
retObject[key] = decodeItem();
Expand Down
2 changes: 1 addition & 1 deletion packages/uhk-agent/src/electron-menu.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { app, BrowserWindow, Menu, MenuItemConstructorOptions, systemPreferences } from 'electron';

export const setMenu = (win: BrowserWindow, allowDevTools): void => {
export const setMenu = (win: BrowserWindow, allowDevTools: boolean): void => {
if (!allowDevTools && process.platform !== 'darwin') {
win.setMenuBarVisibility(false);

Expand Down
14 changes: 7 additions & 7 deletions packages/uhk-agent/src/services/device.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export class DeviceService {
logService.misc('[DeviceService] init success');
}

public async areBleAddressesPaired(event: Electron.IpcMainEvent, args): Promise<void> {
public async areBleAddressesPaired(event: Electron.IpcMainEvent, args: [string[]]): Promise<void> {
this.logService.misc('[DeviceService] Check BLE Addresses are paired');

const response: AreBleAddressesPairedIpcResponse = {
Expand Down Expand Up @@ -365,7 +365,7 @@ export class DeviceService {
* Return with the actual UserConfiguration from UHK Device
* @returns {Promise<Buffer>}
*/
public async loadConfigurations(event: Electron.IpcMainEvent, args): Promise<void> {
public async loadConfigurations(event: Electron.IpcMainEvent, args: []): Promise<void> {
this.logService.misc('[DeviceService] load user configuration');

let response: ConfigurationReply;
Expand Down Expand Up @@ -839,7 +839,7 @@ export class DeviceService {
event.sender.send(IpcEvents.device.updateFirmwareReply, response);
}

public async recoveryDevice(event: Electron.IpcMainEvent, args): Promise<void> {
public async recoveryDevice(event: Electron.IpcMainEvent, args: [{ deviceId: UHK_DEVICE_IDS_TYPE, userConfig: Object }]): Promise<void> {
const response: FirmwareUpgradeIpcResponse = {
success: false,
};
Expand Down Expand Up @@ -895,7 +895,7 @@ export class DeviceService {
this.startPollUhkDevice();
}

public async recoveryModule(event: Electron.IpcMainEvent, args): Promise<void> {
public async recoveryModule(event: Electron.IpcMainEvent, args: [number]): Promise<void> {
const response: FirmwareUpgradeIpcResponse = {
success: false,
};
Expand Down Expand Up @@ -1161,7 +1161,7 @@ export class DeviceService {
}
}

private async changeKeyboardLayout(event: Electron.IpcMainEvent, args): Promise<void> {
private async changeKeyboardLayout(event: Electron.IpcMainEvent, args: [KeyboardLayout, unknown]): Promise<void> {
const layout: KeyboardLayout = args[0];
const hardwareConfiguration: HardwareConfiguration = new HardwareConfiguration().fromJsonObject(args[1]);
const layoutName = layout === KeyboardLayout.ISO ? 'iso': 'ansi';
Expand Down Expand Up @@ -1444,7 +1444,7 @@ export class DeviceService {
event.sender.send(IpcEvents.device.deleteUserConfigHistoryReply, response);
}

private async toggleI2cDebugging(_: Electron.IpcMainEvent, [enabled]): Promise<void> {
private async toggleI2cDebugging(_: Electron.IpcMainEvent, [enabled]: [boolean]): Promise<void> {
this.logService.misc('[DeviceService] Toggle I2C debugging =>', enabled);

this.isI2cDebuggingEnabled = enabled;
Expand All @@ -1465,7 +1465,7 @@ export class DeviceService {
}
}

private async toggleRightHalfZephyrLogging(_: Electron.IpcMainEvent, [enabled]): Promise<void> {
private async toggleRightHalfZephyrLogging(_: Electron.IpcMainEvent, [enabled]: [boolean]): Promise<void> {
this.logService.misc('[DeviceService] Toggle Right Half zephyr logging =>', enabled);

try {
Expand Down
3 changes: 2 additions & 1 deletion packages/uhk-agent/src/services/logger.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export class ElectronLogService extends LogService {
}
}

usbOps(...args) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
usbOps(...args: any[]): void {
if (!this._options.usbOps) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/uhk-agent/src/services/smart-macro-doc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class SmartMacroDocService {
event.sender.send(IpcEvents.smartMacroDoc.serviceListening, this.port);
}

private async handleDownloadDocumentation(event: Electron.IpcMainEvent, args): Promise<void> {
private async handleDownloadDocumentation(event: Electron.IpcMainEvent, args: [FirmwareRepoInfo]): Promise<void> {
try {
const firmwareRepoInfo: FirmwareRepoInfo = args[0];
if (!firmwareRepoInfo.firmwareGitRepo || !firmwareRepoInfo.firmwareGitTag) {
Expand Down
11 changes: 11 additions & 0 deletions packages/uhk-agent/src/types/decompress-plugins.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
declare module 'decompress-tarbz2' {
export default function decompressTarbz2(): unknown;
}

declare module 'decompress-targz' {
export default function decompressTargz(): unknown;
}

declare module 'decompress-unzip' {
export default function decompressUnzip(): unknown;
}
2 changes: 1 addition & 1 deletion packages/uhk-common/src/config-serializer/assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function assertEnum<E>(enumerated: E) {
}

if (this[priv] !== newVal) {
if (enumerated[newVal] === undefined) {
if (enumerated[newVal as keyof E] === undefined) {
throw new Error(`${target.constructor.name}.${key}: ${newVal} is not enum`);
}
this[priv] = newVal;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { UHK_80_USER_CONFIG } from '../../user-config-80.js';
import { fromStringUnsafe } from '../../util/from-string-unsafe.js';

import { AdvancedSecondaryRoleConfiguration } from './advanced-secondary-role-configuration';
import { SecondaryRoleAdvancedStrategyTimeoutAction } from './secondary-role-advanced-strategy-timeout-action.js';
Expand Down Expand Up @@ -39,9 +40,9 @@ export const SIMPLE_ADVANCED_SECONDARY_ROLE_CONFIGURATION_PRESET: AdvancedSecond
configuration: {
secondaryRoleAdvancedStrategyTimeout: UHK_80_USER_CONFIG.secondaryRoleAdvancedStrategyTimeout, // TODO: Firngrod, can the timeout be disabled with the new implementation?
secondaryRoleAdvancedStrategyMinimumHoldTime: UHK_80_USER_CONFIG.secondaryRoleAdvancedStrategyMinimumHoldTime,
secondaryRoleAdvancedStrategyTimeoutAction: SecondaryRoleAdvancedStrategyTimeoutAction[UHK_80_USER_CONFIG.secondaryRoleAdvancedStrategyTimeoutAction],
secondaryRoleAdvancedStrategyTimeoutType: SecondaryRoleAdvancedStrategyTimeoutType[UHK_80_USER_CONFIG.secondaryRoleAdvancedStrategyTimeoutType],
secondaryRoleAdvancedStrategyTrigger: SecondaryRoleAdvancedStrategyTriggeringEvent[UHK_80_USER_CONFIG.secondaryRoleAdvancedStrategyTrigger],
secondaryRoleAdvancedStrategyTimeoutAction: fromStringUnsafe(SecondaryRoleAdvancedStrategyTimeoutAction, UHK_80_USER_CONFIG.secondaryRoleAdvancedStrategyTimeoutAction),
secondaryRoleAdvancedStrategyTimeoutType: fromStringUnsafe(SecondaryRoleAdvancedStrategyTimeoutType, UHK_80_USER_CONFIG.secondaryRoleAdvancedStrategyTimeoutType),
secondaryRoleAdvancedStrategyTrigger: fromStringUnsafe(SecondaryRoleAdvancedStrategyTriggeringEvent, UHK_80_USER_CONFIG.secondaryRoleAdvancedStrategyTrigger),
secondaryRoleAdvancedStrategySafetyMargin: UHK_80_USER_CONFIG.secondaryRoleAdvancedStrategySafetyMargin,
secondaryRoleAdvancedStrategyDoubletapToPrimary: UHK_80_USER_CONFIG.secondaryRoleAdvancedStrategyDoubletapToPrimary,
secondaryRoleAdvancedStrategyTriggerByMouse: UHK_80_USER_CONFIG.secondaryRoleAdvancedStrategyTriggerByMouse,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fromStringUnsafe } from '../../util/from-string-unsafe.js';
import { assertEnum } from '../assert.js';
import { UhkBuffer } from '../uhk-buffer.js';
import { isSerialisationInfoLt } from './serialisation-info.js';
Expand Down Expand Up @@ -193,7 +194,7 @@ export class HostConnection {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
private fromJsonObjectV8(jsonObject: any, serialisationInfo: SerialisationInfo): HostConnection {
this.type = HostConnections[<string>jsonObject.type];
this.type = fromStringUnsafe(HostConnections, jsonObject.type);
if (this.hasAddress()) {
this.address = jsonObject.address;

Expand All @@ -220,7 +221,7 @@ export class HostConnection {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
private fromJsonObjectV9(jsonObject: any, serialisationInfo: SerialisationInfo): HostConnection {
this.type = HostConnections[<string>jsonObject.type];
this.type = fromStringUnsafe(HostConnections, jsonObject.type);
if (this.hasAddress()) {
this.address = jsonObject.address;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fromStringUnsafe } from '../../../util/from-string-unsafe.js';
import { assertEnum, assertUInt8 } from '../../assert.js';
import { UhkBuffer } from '../../uhk-buffer.js';
import { SerialisationInfo } from '../serialisation-info.js';
Expand Down Expand Up @@ -31,7 +32,7 @@ export class ConnectionsAction extends KeyAction {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
fromJsonObject(jsonObject: any, serialisationInfo: SerialisationInfo): ConnectionsAction {
this.assertKeyActionType(jsonObject);
this.command = ConnectionCommands[<string>jsonObject.command]
this.command = fromStringUnsafe(ConnectionCommands, jsonObject.command)
if (this.hasHostConnectionId()) {
this.hostConnectionId = jsonObject.hostConnectionId;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defaultRgbColor, RgbColorInterface } from '../../../models/rgb-color-interface.js';
import { fromStringUnsafe } from '../../../util/from-string-unsafe.js';
import { assertUInt8 } from '../../assert.js';
import { Macro } from '../macro.js';
import { UhkBuffer } from '../../uhk-buffer.js';
Expand Down Expand Up @@ -61,7 +62,7 @@ export abstract class KeyAction implements RgbColorInterface {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
assertKeyActionType(jsObject: any): void {
const keyActionClassname: string = this.getName();
const keyActionTypeString: string = keyActionType[keyActionClassname];
const keyActionTypeString: string = keyActionType[keyActionClassname as keyof typeof keyActionType];
if (jsObject.keyActionType !== keyActionTypeString) {
throw new Error(`Invalid ${keyActionClassname}.keyActionType: ${jsObject.keyActionType}`);
}
Expand All @@ -70,7 +71,7 @@ export abstract class KeyAction implements RgbColorInterface {
readAndAssertKeyActionId(buffer: UhkBuffer): KeyActionId {
const classname: string = this.getName();
const readKeyActionId: number = buffer.readUInt8();
const keyActionId: number = KeyActionId[classname];
const keyActionId: number = fromStringUnsafe(KeyActionId, classname);
if (keyActionId === KeyActionId.KeystrokeAction) {
if (readKeyActionId < KeyActionId.KeystrokeAction || readKeyActionId > KeyActionId.LastKeystrokeAction) {
throw new Error(`Invalid ${classname} first byte: ${readKeyActionId}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fromStringUnsafe } from '../../../util/from-string-unsafe.js';
import { assertEnum, assertUInt8 } from '../../assert.js';
import { UhkBuffer } from '../../uhk-buffer.js';
import { KeyModifiers } from '../key-modifiers.js';
Expand Down Expand Up @@ -251,12 +252,12 @@ export class KeystrokeAction extends KeyAction {
if (jsonObject.type === 'media') {
this.type = jsonObject.scancode < 256 ? KeystrokeType.shortMedia : KeystrokeType.longMedia;
} else {
this.type = KeystrokeType[jsonObject.type];
this.type = fromStringUnsafe(KeystrokeType, jsonObject.type);
}

this._scancode = jsonObject.scancode;
this.modifierMask = jsonObject.modifierMask;
this.secondaryRoleAction = SecondaryRoleAction[jsonObject.secondaryRoleAction];
this.secondaryRoleAction = fromStringUnsafe(SecondaryRoleAction, jsonObject.secondaryRoleAction);
}

private fromJsonObjectV6(jsonObject: JsonObjectKeystrokeAction, serialisationInfo: SerialisationInfo): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fromStringUnsafe } from '../../../util/from-string-unsafe.js';
import { assertEnum } from '../../assert.js';
import { UhkBuffer } from '../../uhk-buffer.js';
import { SerialisationInfo } from '../serialisation-info.js';
Expand Down Expand Up @@ -133,7 +134,7 @@ export class MouseAction extends KeyAction {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private fromJsonObjectV1(jsObject: any): MouseAction {
this.assertKeyActionType(jsObject);
this.mouseAction = MouseActionParam[<string>jsObject.mouseAction];
this.mouseAction = fromStringUnsafe(MouseActionParam, jsObject.mouseAction);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fromStringUnsafe } from '../../../util/from-string-unsafe.js';
import { assertEnum } from '../../assert.js';
import { UhkBuffer } from '../../uhk-buffer.js';
import { SerialisationInfo } from '../serialisation-info.js';
Expand All @@ -24,7 +25,7 @@ export class OtherAction extends KeyAction {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
fromJsonObject(jsonObject: any, serialisationInfo: SerialisationInfo): OtherAction {
this.assertKeyActionType(jsonObject);
this.actionSubtype = OtherActionSubTypes[<string>jsonObject.actionSubtype];
this.actionSubtype = fromStringUnsafe(OtherActionSubTypes, jsonObject.actionSubtype);
this.rgbColorFromJson(jsonObject, serialisationInfo);

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class PlayMacroAction extends KeyAction {
this.rgbColorFromJson(jsonObject, serialisationInfo);

if (Array.isArray(jsonObject.macroArguments)) {
this.macroArguments = jsonObject.macroArguments.map(macroArgument => {
this.macroArguments = jsonObject.macroArguments.map((macroArgument: unknown) => {
const argument = new MacroArgumentAction();
argument.fromJsonObject(macroArgument);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fromStringUnsafe } from '../../../util/from-string-unsafe.js';
import { assertEnum } from '../../assert.js';
import { UhkBuffer } from '../../uhk-buffer.js';
import { SerialisationInfo } from '../serialisation-info.js';
Expand Down Expand Up @@ -144,7 +145,7 @@ export class SwitchLayerAction extends KeyAction {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private fromJsonObjectV1(jsonObject: any): void {
this.assertKeyActionType(jsonObject);
this.layer = LayerName[<string>jsonObject.layer];
this.layer = fromStringUnsafe(LayerName, jsonObject.layer);

// Backward compatibility when "switchLayerMode" was a boolean type as "toggle"
if (typeof jsonObject.toggle === 'boolean') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export class Keymap {
this.abbreviation = jsonObject.abbreviation;
this.name = jsonObject.name;
this.description = jsonObject.description;
this.layers = jsonObject.layers.map((layer) => new Layer().fromJsonObject(layer, macros, serialisationInfo));
this.layers = jsonObject.layers.map((layer: unknown) =>new Layer().fromJsonObject(layer, macros, serialisationInfo));
}

private fromBinaryV1(buffer: UhkBuffer, macros: Macro[], serialisationInfo: SerialisationInfo): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fromStringUnsafe } from '../../util/from-string-unsafe.js';
import { UhkBuffer } from '../uhk-buffer.js';
import { assertEnum } from '../assert.js';

Expand Down Expand Up @@ -126,7 +127,7 @@ export class Layer {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
fromJsonObjectV1(jsonObject: any, macros: Macro[], serialisationInfo: SerialisationInfo): void {
this.modules = jsonObject.modules.map((module) => {
this.modules = jsonObject.modules.map((module: unknown) => {
return new Module().fromJsonObject(module, macros, serialisationInfo);
});
}
Expand All @@ -139,8 +140,8 @@ export class Layer {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
fromJsonObjectV5(jsonObject: any, macros: Macro[], serialisationInfo: SerialisationInfo): void {
this.id = LayerName[<string>jsonObject.id];
this.modules = jsonObject.modules.map((module) => {
this.id = fromStringUnsafe(LayerName, jsonObject.id);
this.modules = jsonObject.modules.map((module: unknown) => {
return new Module().fromJsonObject(module, macros, serialisationInfo);
});
}
Expand Down
Loading
Loading