mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-02 11:26:46 +02:00
Linting
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { isFullVersion } from "@macros/build" with {type: "macro"};
|
||||
import { isFullVersion } from "@macros/build" with { type: "macro" };
|
||||
|
||||
import { ControllerShortcut } from "@/modules/controller-shortcut";
|
||||
import { BxEvent } from "@utils/bx-event";
|
||||
|
@@ -8,7 +8,7 @@ export type BxFlags = {
|
||||
SafariWorkaround: boolean;
|
||||
|
||||
ForceNativeMkbTitles: string[];
|
||||
FeatureGates: {[key: string]: boolean} | null,
|
||||
FeatureGates: { [key: string]: boolean } | null,
|
||||
|
||||
DeviceInfo: {
|
||||
deviceType: 'android' | 'android-tv' | 'android-handheld' | 'webos' | 'unknown',
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { CE } from "@utils/html";
|
||||
import { compressCss, renderStylus } from "@macros/build" with {type: "macro"};
|
||||
import { compressCss, renderStylus } from "@macros/build" with { type: "macro" };
|
||||
import { UiSection } from "@/enums/pref-values";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "./settings-storages/global-settings-storage";
|
||||
|
@@ -3,7 +3,7 @@ import { BX_FLAGS } from "./bx-flags";
|
||||
import { getPref } from "./settings-storages/global-settings-storage";
|
||||
import { NativeMkbMode } from "@/enums/pref-values";
|
||||
|
||||
export let FeatureGates: {[key: string]: boolean} = {
|
||||
export let FeatureGates: { [key: string]: boolean } = {
|
||||
PwaPrompt: false,
|
||||
EnableWifiWarnings: false,
|
||||
EnableUpdateRequiredPage: false,
|
||||
|
@@ -31,7 +31,7 @@ export function showGamepadToast(gamepad: Gamepad) {
|
||||
status = t('disconnected');
|
||||
}
|
||||
|
||||
Toast.show(text, status, {instant: false});
|
||||
Toast.show(text, status, { instant: false });
|
||||
}
|
||||
|
||||
export function getUniqueGamepadNames() {
|
||||
|
@@ -47,7 +47,7 @@ export const STATES: BxStates = {
|
||||
pointerServerPort: 9269,
|
||||
};
|
||||
|
||||
export const STORAGE: {[key: string]: BaseSettingsStore} = {};
|
||||
export const STORAGE: { [key: string]: BaseSettingsStore } = {};
|
||||
|
||||
export function deepClone(obj: any): typeof obj | {} {
|
||||
if (!obj) {
|
||||
|
@@ -47,7 +47,7 @@ export type BxButtonOptions = Partial<{
|
||||
disabled: boolean;
|
||||
onClick: EventListener;
|
||||
tabIndex: number;
|
||||
attributes: {[key: string]: any},
|
||||
attributes: { [key: string]: any },
|
||||
}>;
|
||||
|
||||
export type SettingsRowOptions = Partial<{
|
||||
@@ -186,7 +186,7 @@ export function createSettingRow(label: string, $control: HTMLElement | false |
|
||||
let $label: HTMLElement;
|
||||
|
||||
const $row = CE<HTMLLabelElement>('label', { class: 'bx-settings-row' },
|
||||
$label = CE('span', {class: 'bx-settings-label'},
|
||||
$label = CE('span', { class: 'bx-settings-label' },
|
||||
label,
|
||||
options.$note,
|
||||
),
|
||||
|
@@ -55,11 +55,11 @@ export class BaseLocalTable<T extends BaseRecord> {
|
||||
return this.call(table.get.bind(table), ...arguments);
|
||||
}
|
||||
|
||||
async getAll(): Promise<{[key: string]: T}> {
|
||||
async getAll(): Promise<{ [key: string]: T }> {
|
||||
const table = await this.prepareTable();
|
||||
// @ts-ignore
|
||||
const all = await (this.call(table.getAll.bind(table), ...arguments) as Promise<T[]>);
|
||||
const results: {[key: string]: T} = {};
|
||||
const results: { [key: string]: T } = {};
|
||||
|
||||
all.forEach(item => {
|
||||
results[item.id as T['id']] = item;
|
||||
|
@@ -23,9 +23,13 @@ export class ControllerSettingsTable extends BaseLocalTable<ControllerSettingsRe
|
||||
|
||||
async getControllersData() {
|
||||
const all = await this.getAll();
|
||||
const results: {[key: string]: ControllerSettingsRecord['data']} = {};
|
||||
const results: { [key: string]: ControllerSettingsRecord['data'] } = {};
|
||||
|
||||
for (const key in all) {
|
||||
if (!all[key]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const settings = all[key].data;
|
||||
// Pre-calculate virabtionIntensity
|
||||
settings.vibrationIntensity /= 100;
|
||||
|
@@ -50,7 +50,7 @@ export function patchVideoApi() {
|
||||
const $parent = this.parentElement!!;
|
||||
// Video tag is stream player
|
||||
if (!this.src && $parent.dataset.testid === 'media-container') {
|
||||
this.addEventListener('loadedmetadata', showFunc, {once: true});
|
||||
this.addEventListener('loadedmetadata', showFunc, { once: true });
|
||||
}
|
||||
|
||||
return nativePlay.apply(this);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { isFullVersion } from "@macros/build" with {type: "macro"};
|
||||
import { isFullVersion } from "@macros/build" with { type: "macro" };
|
||||
|
||||
import { BX_FLAGS, NATIVE_FETCH } from "@utils/bx-flags";
|
||||
import { TouchController } from "@modules/touch-controller";
|
||||
@@ -39,7 +39,7 @@ function clearAllLogs() {
|
||||
clearDbLogs('XCloudAppLogs', 'logs');
|
||||
}
|
||||
|
||||
function updateIceCandidates(candidates: any, options: {preferIpv6Server: boolean, consoleAddrs?: RemotePlayConsoleAddresses}) {
|
||||
function updateIceCandidates(candidates: any, options: { preferIpv6Server: boolean, consoleAddrs?: RemotePlayConsoleAddresses }) {
|
||||
const pattern = new RegExp(/a=candidate:(?<foundation>\d+) (?<component>\d+) UDP (?<priority>\d+) (?<ip>[^\s]+) (?<port>\d+) (?<the_rest>.*)/);
|
||||
|
||||
const lst = [];
|
||||
@@ -48,7 +48,7 @@ function updateIceCandidates(candidates: any, options: {preferIpv6Server: boolea
|
||||
continue;
|
||||
}
|
||||
|
||||
const groups: {[index: string]: string | number} = pattern.exec(item.candidate)!.groups!;
|
||||
const groups: { [index: string]: string | number } = pattern.exec(item.candidate)!.groups!;
|
||||
lst.push(groups);
|
||||
}
|
||||
|
||||
|
@@ -89,7 +89,7 @@ export class RootDialogObserver {
|
||||
}
|
||||
}
|
||||
});
|
||||
observer.observe($root, {subtree: true, childList: true});
|
||||
observer.observe($root, { subtree: true, childList: true });
|
||||
}
|
||||
|
||||
public static waitForRootDialog() {
|
||||
@@ -107,6 +107,6 @@ export class RootDialogObserver {
|
||||
}
|
||||
};
|
||||
});
|
||||
observer.observe(document.documentElement, {subtree: true, childList: true});
|
||||
observer.observe(document.documentElement, { subtree: true, childList: true });
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ export class ScreenshotManager {
|
||||
|
||||
this.$download = CE<HTMLAnchorElement>('a');
|
||||
|
||||
this.$canvas = CE<HTMLCanvasElement>('canvas', {'class': 'bx-gone'});
|
||||
this.$canvas = CE<HTMLCanvasElement>('canvas', { class: 'bx-gone' });
|
||||
this.canvasContext = this.$canvas.getContext('2d', {
|
||||
alpha: false,
|
||||
willReadFrequently: false,
|
||||
|
@@ -41,7 +41,7 @@ export class SettingElement {
|
||||
for (let value in setting.options) {
|
||||
const label = setting.options[value];
|
||||
|
||||
const $option = CE<HTMLOptionElement>('option', {value: value}, label);
|
||||
const $option = CE<HTMLOptionElement>('option', { value }, label);
|
||||
$parent.appendChild($option);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ export class SettingElement {
|
||||
for (const value in setting.multipleOptions) {
|
||||
const label = setting.multipleOptions[value];
|
||||
|
||||
const $option = CE<HTMLOptionElement>('option', {value: value}, label) as HTMLOptionElement;
|
||||
const $option = CE<HTMLOptionElement>('option', { value }, label) as HTMLOptionElement;
|
||||
$option.selected = currentValue.indexOf(value) > -1;
|
||||
|
||||
$option.addEventListener('mousedown', function(e) {
|
||||
@@ -111,7 +111,7 @@ export class SettingElement {
|
||||
}
|
||||
|
||||
private static renderCheckbox(key: string, setting: PreferenceSetting, currentValue: any, onChange: any) {
|
||||
const $control = CE('input', {type: 'checkbox', tabindex: 0}) as HTMLInputElement;
|
||||
const $control = CE('input', { type: 'checkbox', tabindex: 0 }) as HTMLInputElement;
|
||||
$control.checked = currentValue;
|
||||
|
||||
onChange && $control.addEventListener('input', e => {
|
||||
|
@@ -89,7 +89,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
},
|
||||
[PrefKey.SERVER_REGION]: {
|
||||
label: t('region'),
|
||||
note: CE('a', {target: '_blank', href: 'https://umap.openstreetmap.fr/en/map/xbox-cloud-gaming-servers_1135022'}, t('server-locations')),
|
||||
note: CE('a', { target: '_blank', href: 'https://umap.openstreetmap.fr/en/map/xbox-cloud-gaming-servers_1135022' }, t('server-locations')),
|
||||
default: 'default',
|
||||
},
|
||||
[PrefKey.SERVER_BYPASS_RESTRICTION]: {
|
||||
|
@@ -24,9 +24,9 @@ export class Toast {
|
||||
private constructor() {
|
||||
BxLogger.info(this.LOG_TAG, 'constructor()');
|
||||
|
||||
this.$wrapper = CE('div', {class: 'bx-toast bx-offscreen'},
|
||||
this.$msg = CE('span', {class: 'bx-toast-msg'}),
|
||||
this.$status = CE('span', {class: 'bx-toast-status'}),
|
||||
this.$wrapper = CE('div', { class: 'bx-toast bx-offscreen' },
|
||||
this.$msg = CE('span', { class: 'bx-toast-msg' }),
|
||||
this.$status = CE('span', { class: 'bx-toast-status' }),
|
||||
);
|
||||
|
||||
this.$wrapper.addEventListener('transitionend', e => {
|
||||
|
@@ -9,12 +9,12 @@ type UserAgentConfig = {
|
||||
|
||||
const SMART_TV_UNIQUE_ID = 'FC4A1DA2-711C-4E9C-BC7F-047AF8A672EA';
|
||||
|
||||
let CHROMIUM_VERSION = '123.0.0.0';
|
||||
let CHROMIUM_VERSION = '125.0.0.0';
|
||||
if (!!(window as any).chrome || window.navigator.userAgent.includes('Chrome')) {
|
||||
// Get Chromium version in the original User-Agent value
|
||||
const match = window.navigator.userAgent.match(/\s(?:Chrome|Edg)\/([\d\.]+)/);
|
||||
if (match) {
|
||||
CHROMIUM_VERSION = match[1];
|
||||
CHROMIUM_VERSION = match[1] as string;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -102,11 +102,11 @@ export function roundToNearest(value: number, interval: number): number {
|
||||
export async function copyToClipboard(text: string, showToast=true): Promise<boolean> {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
showToast && Toast.show('Copied to clipboard', '', {instant: true});
|
||||
showToast && Toast.show('Copied to clipboard', '', { instant: true });
|
||||
return true;
|
||||
} catch (err) {
|
||||
console.error('Failed to copy: ', err);
|
||||
showToast && Toast.show('Failed to copy', '', {instant: true});
|
||||
showToast && Toast.show('Failed to copy', '', { instant: true });
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -128,10 +128,10 @@ export function parseDetailsPath(path: string) {
|
||||
return;
|
||||
}
|
||||
|
||||
const titleSlug = matches.groups.titleSlug.replaceAll('\%' + '7C', '-');
|
||||
const titleSlug = matches.groups.titleSlug!.replaceAll('\%' + '7C', '-');
|
||||
const productId = matches.groups.productId;
|
||||
|
||||
return {titleSlug, productId};
|
||||
return { titleSlug, productId };
|
||||
}
|
||||
|
||||
export function clearAllData() {
|
||||
|
@@ -3,7 +3,7 @@ import { NATIVE_FETCH } from "./bx-flags"
|
||||
export class XboxApi {
|
||||
private static CACHED_TITLES: Record<string, string> = {};
|
||||
|
||||
static async getProductTitle(xboxTitleId: number | string): Promise<string | null> {
|
||||
static async getProductTitle(xboxTitleId: number | string): Promise<string | undefined> {
|
||||
xboxTitleId = xboxTitleId.toString();
|
||||
if (XboxApi.CACHED_TITLES[xboxTitleId]) {
|
||||
return XboxApi.CACHED_TITLES[xboxTitleId];
|
||||
@@ -20,6 +20,6 @@ export class XboxApi {
|
||||
return productTitle;
|
||||
} catch (e) {}
|
||||
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -7,21 +7,21 @@ export class XcloudApi {
|
||||
public static getInstance = () => XcloudApi.instance ?? (XcloudApi.instance = new XcloudApi());
|
||||
private readonly LOG_TAG = 'XcloudApi';
|
||||
|
||||
private CACHE_TITLES: {[key: string]: XcloudTitleInfo} = {};
|
||||
private CACHE_WAIT_TIME: {[key: string]: XcloudWaitTimeInfo} = {};
|
||||
private CACHE_TITLES: { [key: string]: XcloudTitleInfo } = {};
|
||||
private CACHE_WAIT_TIME: { [key: string]: XcloudWaitTimeInfo } = {};
|
||||
|
||||
private constructor() {
|
||||
BxLogger.info(this.LOG_TAG, 'constructor()');
|
||||
}
|
||||
|
||||
async getTitleInfo(id: string): Promise<XcloudTitleInfo | null> {
|
||||
async getTitleInfo(id: string): Promise<XcloudTitleInfo | undefined> {
|
||||
if (id in this.CACHE_TITLES) {
|
||||
return this.CACHE_TITLES[id];
|
||||
}
|
||||
|
||||
const baseUri = STATES.selectedRegion.baseUri;
|
||||
if (!baseUri || !STATES.gsToken) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
let json;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { isFullVersion } from "@macros/build" with {type: "macro"};
|
||||
import { isFullVersion } from "@macros/build" with { type: "macro" };
|
||||
|
||||
import { LoadingScreen } from "@modules/loading-screen";
|
||||
import { RemotePlayManager } from "@/modules/remote-play-manager";
|
||||
@@ -116,7 +116,7 @@ export class XcloudInterceptor {
|
||||
|
||||
let match = serverRegex.exec(region.baseUri);
|
||||
if (match) {
|
||||
shortName = match[1];
|
||||
shortName = match[1] as string;
|
||||
if (serverExtra[regionName]) {
|
||||
shortName = serverExtra[regionName][0] + ' ' + shortName;
|
||||
region.contintent = serverExtra[regionName][1];
|
||||
@@ -155,10 +155,10 @@ export class XcloudInterceptor {
|
||||
const url = (typeof request === 'string') ? request : (request as Request).url;
|
||||
const parsedUrl = new URL(url);
|
||||
|
||||
let badgeRegion: string = parsedUrl.host.split('.', 1)[0];
|
||||
let badgeRegion: string = parsedUrl.host.split('.', 1)[0] as string;
|
||||
for (let regionName in STATES.serverRegions) {
|
||||
const region = STATES.serverRegions[regionName];
|
||||
if (parsedUrl.origin == region.baseUri) {
|
||||
if (region && parsedUrl.origin === region.baseUri) {
|
||||
badgeRegion = regionName;
|
||||
break;
|
||||
}
|
||||
@@ -168,7 +168,7 @@ export class XcloudInterceptor {
|
||||
const clone = (request as Request).clone();
|
||||
const body = await clone.json();
|
||||
|
||||
const headers: {[index: string]: string} = {};
|
||||
const headers: { [index: string]: string } = {};
|
||||
for (const pair of (clone.headers as any).entries()) {
|
||||
headers[pair[0]] = pair[1];
|
||||
}
|
||||
|
@@ -90,7 +90,7 @@ export class XhomeInterceptor {
|
||||
XhomeInterceptor.consoleAddrs = {};
|
||||
for (const pair of pairs) {
|
||||
const [keyAddr, keyPort] = pair;
|
||||
if (serverDetails[keyAddr]) {
|
||||
if (keyAddr && keyPort && serverDetails[keyAddr]) {
|
||||
const port = serverDetails[keyPort];
|
||||
// Add port 9002 to the list of ports
|
||||
const ports = new Set<number>();
|
||||
@@ -107,7 +107,7 @@ export class XhomeInterceptor {
|
||||
return response;
|
||||
}
|
||||
|
||||
private static async handleInputConfigs(request: Request | URL, opts: {[index: string]: any}) {
|
||||
private static async handleInputConfigs(request: Request | URL, opts: { [index: string]: any }) {
|
||||
const response = await NATIVE_FETCH(request);
|
||||
|
||||
if (getPref<TouchControllerMode>(PrefKey.TOUCH_CONTROLLER_MODE) !== TouchControllerMode.ALL) {
|
||||
@@ -147,7 +147,7 @@ export class XhomeInterceptor {
|
||||
private static async handleTitles(request: Request) {
|
||||
const clone = request.clone();
|
||||
|
||||
const headers: {[index: string]: any} = {};
|
||||
const headers: { [index: string]: any } = {};
|
||||
for (const pair of (clone.headers as any).entries()) {
|
||||
headers[pair[0]] = pair[1];
|
||||
}
|
||||
@@ -183,7 +183,7 @@ export class XhomeInterceptor {
|
||||
|
||||
const clone = request.clone();
|
||||
|
||||
const headers: {[index: string]: string} = {};
|
||||
const headers: { [index: string]: string } = {};
|
||||
for (const pair of (clone.headers as any).entries()) {
|
||||
headers[pair[0]] = pair[1];
|
||||
}
|
||||
|
Reference in New Issue
Block a user