From a7635b63053e2f83b1c7ef8bf85e532d771843b6 Mon Sep 17 00:00:00 2001 From: AAGaming Date: Sun, 12 May 2024 15:48:13 -0400 Subject: [PATCH] chore(*): run prettier --- .github/workflows/docs.yaml | 2 +- .releaserc.json | 6 +- .vscode/tasks.json | 26 +- README.md | 2 +- babel.config.js | 2 +- globals.d.ts | 8 +- src/class-mapper.ts | 54 ++-- src/components/ButtonItem.tsx | 11 +- src/components/Carousel.ts | 4 +- src/components/ControlsList.tsx | 8 +- src/components/Dialog.tsx | 14 +- src/components/DialogCheckbox.tsx | 27 +- src/components/Field.tsx | 4 +- src/components/FocusRing.ts | 4 +- src/components/Focusable.tsx | 4 +- src/components/FooterLegend.ts | 6 +- src/components/Marquee.tsx | 4 +- src/components/Panel.tsx | 4 +- src/components/ProgressBar.tsx | 12 +- src/components/Scroll.tsx | 10 +- src/components/SidebarNavigation.tsx | 4 +- src/components/SteamSpinner.tsx | 4 +- src/components/Tabs.tsx | 3 +- src/components/index.ts | 2 +- src/custom-hooks/useQuickAccessVisible.tsx | 5 +- src/globals/SteamClient.ts | 2 +- src/globals/index.ts | 4 +- src/logger.ts | 43 +-- src/modules/index.ts | 2 +- src/utils/react.ts | 6 +- src/utils/static-classes.ts | 296 ++++++++++----------- src/webpack.ts | 31 ++- typedoc.json | 6 +- 33 files changed, 318 insertions(+), 302 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 923483a..f3f52dd 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -51,4 +51,4 @@ jobs: ssh: true directory: ./wiki repository: SteamDeckHomebrew/wiki - branch: main \ No newline at end of file + branch: main diff --git a/.releaserc.json b/.releaserc.json index cb6bb00..deec87b 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -6,9 +6,9 @@ { "preset": "angular", "releaseRules": [ - {"type": "chore", "scope": "classes", "release": "patch"}, - {"type": "docs", "scope": "steamclient", "release": "patch"}, - {"type": "*", "scope": "docs", "release": false} + { "type": "chore", "scope": "classes", "release": "patch" }, + { "type": "docs", "scope": "steamclient", "release": "patch" }, + { "type": "*", "scope": "docs", "release": false } ] } ], diff --git a/.vscode/tasks.json b/.vscode/tasks.json index f79e23a..044e16d 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,15 +1,13 @@ { - "version": "2.0.0", - "tasks": [ - { - "type": "npm", - "script": "dev", - "problemMatcher": [ - "$tsc-watch" - ], - "label": "npm: dev", - "detail": "tsc -b -w", - "isBackground": true - } - ] -} \ No newline at end of file + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "dev", + "problemMatcher": ["$tsc-watch"], + "label": "npm: dev", + "detail": "tsc -b -w", + "isBackground": true + } + ] +} diff --git a/README.md b/README.md index 45d68b9..5dce244 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ This library can also theoretically be used to extend existing UI elements of th ### Getting Started (Developers) -If you would like a feature added to decky-frontend-lib, please request it via a Github issue. +If you would like a feature added to decky-frontend-lib, please request it via a Github issue. If you want to start making a plugin with decky-frontend-lib, please direct your attention to the [decky-plugin-template](https://github.com/SteamDeckHomebrew/decky-plugin-template) repository. diff --git a/babel.config.js b/babel.config.js index de3bb28..e6ffbd4 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,3 +1,3 @@ module.exports = { - presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript',], + presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'], }; diff --git a/globals.d.ts b/globals.d.ts index 0dfe9ff..ce33a8f 100644 --- a/globals.d.ts +++ b/globals.d.ts @@ -1,5 +1,5 @@ declare global { - interface Window { - SP_REACT: typeof React; - } -} \ No newline at end of file + interface Window { + SP_REACT: typeof React; + } +} diff --git a/src/class-mapper.ts b/src/class-mapper.ts index acd500a..86d8f62 100644 --- a/src/class-mapper.ts +++ b/src/class-mapper.ts @@ -1,34 +1,34 @@ -import { Module, findAllModules } from "./webpack"; +import { Module, findAllModules } from './webpack'; export interface ClassModule { - [name: string]: string -}; - -export const classMap: ClassModule[] = findAllModules((m: Module) => { - if (typeof m == "object" && !m.__esModule) { - const keys = Object.keys(m); - // special case some libraries - if (keys.length == 1 && m.version) return false; - // special case localization - if (keys.length > 1000 && m.AboutSettings) return false; - - return keys.length > 0 && keys.every(k => !Object.getOwnPropertyDescriptor(m, k)?.get && typeof m[k] == "string") - } - return false; -}); - -export function findClass(name: string): string | void { - return classMap.find(m => m?.[name])?.[name]; + [name: string]: string; } - -export function findClassModule(filter: (module: any) => boolean) : ClassModule | void { - return classMap.find(m => filter(m)); + +export const classMap: ClassModule[] = findAllModules((m: Module) => { + if (typeof m == 'object' && !m.__esModule) { + const keys = Object.keys(m); + // special case some libraries + if (keys.length == 1 && m.version) return false; + // special case localization + if (keys.length > 1000 && m.AboutSettings) return false; + + return keys.length > 0 && keys.every((k) => !Object.getOwnPropertyDescriptor(m, k)?.get && typeof m[k] == 'string'); + } + return false; +}); + +export function findClass(name: string): string | void { + return classMap.find((m) => m?.[name])?.[name]; +} + +export function findClassModule(filter: (module: any) => boolean): ClassModule | void { + return classMap.find((m) => filter(m)); } export function unminifyClass(minifiedClass: string): string | void { - for (let m of classMap) { - for (let className of Object.keys(m)) { - if (m[className] == minifiedClass) return className; - } + for (let m of classMap) { + for (let className of Object.keys(m)) { + if (m[className] == minifiedClass) return className; } -} \ No newline at end of file + } +} diff --git a/src/components/ButtonItem.tsx b/src/components/ButtonItem.tsx index bc6980a..76657af 100644 --- a/src/components/ButtonItem.tsx +++ b/src/components/ButtonItem.tsx @@ -7,9 +7,8 @@ export interface ButtonItemProps extends ItemProps { onClick?(e: MouseEvent): void; disabled?: boolean; } -export const ButtonItem = - Object.values(CommonUIModule).find( - (mod: any) => - mod?.render?.toString()?.includes('"highlightOnFocus","childrenContainerWidth"') || - mod?.render?.toString()?.includes('childrenContainerWidth:"min"'), - ) as FC; +export const ButtonItem = Object.values(CommonUIModule).find( + (mod: any) => + mod?.render?.toString()?.includes('"highlightOnFocus","childrenContainerWidth"') || + mod?.render?.toString()?.includes('childrenContainerWidth:"min"'), +) as FC; diff --git a/src/components/Carousel.ts b/src/components/Carousel.ts index f8311e8..a1bd7c3 100644 --- a/src/components/Carousel.ts +++ b/src/components/Carousel.ts @@ -20,4 +20,6 @@ export interface CarouselProps extends HTMLAttributes { scrollToAlignment?: 'center'; } -export const Carousel = findModuleExport((e: Export) => e.render?.toString().includes('setFocusedColumn:')) as VFC>; +export const Carousel = findModuleExport((e: Export) => e.render?.toString().includes('setFocusedColumn:')) as VFC< + CarouselProps & RefAttributes +>; diff --git a/src/components/ControlsList.tsx b/src/components/ControlsList.tsx index 9c3fa8f..34982de 100644 --- a/src/components/ControlsList.tsx +++ b/src/components/ControlsList.tsx @@ -1,9 +1,13 @@ -import { Export, findModuleExport } from '../webpack'; import { FC } from 'react'; +import { Export, findModuleExport } from '../webpack'; + export interface ControlsListProps { alignItems?: 'left' | 'right' | 'center'; spacing?: 'standard' | 'extra'; } -export const ControlsList: FC = findModuleExport((e: Export) => e?.toString && e.toString().includes('().ControlsListChild') && e.toString().includes('().ControlsListOuterPanel')); \ No newline at end of file +export const ControlsList: FC = findModuleExport( + (e: Export) => + e?.toString && e.toString().includes('().ControlsListChild') && e.toString().includes('().ControlsListOuterPanel'), +); diff --git a/src/components/Dialog.tsx b/src/components/Dialog.tsx index 2166481..9a76ac4 100644 --- a/src/components/Dialog.tsx +++ b/src/components/Dialog.tsx @@ -11,7 +11,7 @@ export interface DialogCommonProps extends RefAttributes { export interface DialogButtonProps extends DialogCommonProps, FooterLegendProps { /** * Enables/disables the focus around the button. - * + * * @note * Default value depends on context, so setting it to `false` will enable it. */ @@ -19,25 +19,25 @@ export interface DialogButtonProps extends DialogCommonProps, FooterLegendProps /** * Disables the button - assigned `on*` methods will not be invoked if clicked. - * + * * @note - * Depending on where it is, it might still get focus. In such case it can be + * Depending on where it is, it might still get focus. In such case it can be * partially disabled separately. - * + * * @see focusable. */ disabled?: boolean; /** * Enables/disables the navigation based focus on button - you won't be able to navigate to - * it via the gamepad or keyboard. - * + * it via the gamepad or keyboard. + * * @note * If set to `false`, it still can be clicked and **WILL** become focused until navigated away. * Depending on the context of where the button is, even a disabled button can focused. */ focusable?: boolean; - + onClick?(e: MouseEvent): void; onPointerDown?(e: PointerEvent): void; onPointerUp?(e: PointerEvent): void; diff --git a/src/components/DialogCheckbox.tsx b/src/components/DialogCheckbox.tsx index b16068d..d1bc2a5 100644 --- a/src/components/DialogCheckbox.tsx +++ b/src/components/DialogCheckbox.tsx @@ -18,16 +18,19 @@ export interface DialogCheckboxProps extends DialogCommonProps, FooterLegendProp onClick?(evt: Event): void; } -export const DialogCheckbox = Object.values(findModule((m: any) => { - if (typeof m !== 'object') return false; - for (const prop in m) { - if (m[prop]?.prototype?.GetPanelElementProps) return true; - } - return false; -})).find((m: any) => - m.contextType && - m.prototype?.render.toString().includes('fallback:') && - m?.prototype?.SetChecked && - m?.prototype?.Toggle && - m?.prototype?.GetPanelElementProps +export const DialogCheckbox = Object.values( + findModule((m: any) => { + if (typeof m !== 'object') return false; + for (const prop in m) { + if (m[prop]?.prototype?.GetPanelElementProps) return true; + } + return false; + }), +).find( + (m: any) => + m.contextType && + m.prototype?.render.toString().includes('fallback:') && + m?.prototype?.SetChecked && + m?.prototype?.Toggle && + m?.prototype?.GetPanelElementProps, ) as FC; diff --git a/src/components/Field.tsx b/src/components/Field.tsx index bc1877d..c056879 100644 --- a/src/components/Field.tsx +++ b/src/components/Field.tsx @@ -23,4 +23,6 @@ export interface FieldProps extends FooterLegendProps { onClick?: (e: CustomEvent | MouseEvent) => void; } -export const Field = findModuleExport((e: Export) => e?.render?.toString().includes('"shift-children-below"')) as FC>; +export const Field = findModuleExport((e: Export) => e?.render?.toString().includes('"shift-children-below"')) as FC< + FieldProps & RefAttributes +>; diff --git a/src/components/FocusRing.ts b/src/components/FocusRing.ts index 5313a0f..20f1ba5 100644 --- a/src/components/FocusRing.ts +++ b/src/components/FocusRing.ts @@ -10,4 +10,6 @@ export interface FocusRingProps { NavigationManager?: any; } -export const FocusRing = findModuleExport((e: Export) => e?.toString()?.includes('.GetShowDebugFocusRing())')) as FC; +export const FocusRing = findModuleExport((e: Export) => + e?.toString()?.includes('.GetShowDebugFocusRing())'), +) as FC; diff --git a/src/components/Focusable.tsx b/src/components/Focusable.tsx index 704f911..259bfc7 100644 --- a/src/components/Focusable.tsx +++ b/src/components/Focusable.tsx @@ -13,4 +13,6 @@ export interface FocusableProps extends HTMLAttributes, FooterLe onCancel?: (e: CustomEvent) => void; } -export const Focusable = findModuleExport((e: Export) => e?.render?.toString()?.includes('["flow-children","onActivate","onCancel","focusClassName",')) as VFC>; +export const Focusable = findModuleExport((e: Export) => + e?.render?.toString()?.includes('["flow-children","onActivate","onCancel","focusClassName",'), +) as VFC>; diff --git a/src/components/FooterLegend.ts b/src/components/FooterLegend.ts index a9a67ad..762e781 100644 --- a/src/components/FooterLegend.ts +++ b/src/components/FooterLegend.ts @@ -36,7 +36,7 @@ export declare enum NavEntryPositionPreferences { LAST, MAINTAIN_X, MAINTAIN_Y, - PREFERRED_CHILD + PREFERRED_CHILD, } export interface GamepadEventDetail { button: number; @@ -44,8 +44,8 @@ export interface GamepadEventDetail { source: number; } export declare type ActionDescriptionMap = { - [key in GamepadButton]?: ReactNode -} + [key in GamepadButton]?: ReactNode; +}; export declare type GamepadEvent = CustomEvent; export interface FooterLegendProps { actionDescriptionMap?: ActionDescriptionMap; diff --git a/src/components/Marquee.tsx b/src/components/Marquee.tsx index bf6aee9..a112006 100644 --- a/src/components/Marquee.tsx +++ b/src/components/Marquee.tsx @@ -15,4 +15,6 @@ export interface MarqueeProps { children: React.ReactNode; } -export const Marquee: FC = findModuleExport((e: Export) => e?.toString && e.toString().includes('.Marquee') && e.toString().includes('--fade-length')); +export const Marquee: FC = findModuleExport( + (e: Export) => e?.toString && e.toString().includes('.Marquee') && e.toString().includes('--fade-length'), +); diff --git a/src/components/Panel.tsx b/src/components/Panel.tsx index 8764751..cbddb0f 100644 --- a/src/components/Panel.tsx +++ b/src/components/Panel.tsx @@ -21,4 +21,6 @@ export const PanelSection = panelSection as FC; export interface PanelSectionRowProps { children?: ReactNode; } -export const PanelSectionRow = Object.values(mod).filter((exp: any) => !exp?.toString()?.includes('.PanelSection'))[0] as FC; +export const PanelSectionRow = Object.values(mod).filter( + (exp: any) => !exp?.toString()?.includes('.PanelSection'), +)[0] as FC; diff --git a/src/components/ProgressBar.tsx b/src/components/ProgressBar.tsx index a21b08f..eb0df55 100644 --- a/src/components/ProgressBar.tsx +++ b/src/components/ProgressBar.tsx @@ -22,8 +22,14 @@ export interface ProgressBarWithInfoProps extends ProgressBarItemProps { sOperationText?: ReactNode; } -export const ProgressBar = findModuleExport((e: Export) => e?.toString()?.includes('.ProgressBar,"standard"==')) as VFC; +export const ProgressBar = findModuleExport((e: Export) => + e?.toString()?.includes('.ProgressBar,"standard"=='), +) as VFC; -export const ProgressBarWithInfo = findModuleExport((e: Export) => e?.toString()?.includes('.ProgressBarFieldStatus},')) as VFC; +export const ProgressBarWithInfo = findModuleExport((e: Export) => + e?.toString()?.includes('.ProgressBarFieldStatus},'), +) as VFC; -export const ProgressBarItem = findModuleExport((e: Export) => e?.toString()?.includes('"indeterminate","nTransitionSec"')) as VFC; +export const ProgressBarItem = findModuleExport((e: Export) => + e?.toString()?.includes('"indeterminate","nTransitionSec"'), +) as VFC; diff --git a/src/components/Scroll.tsx b/src/components/Scroll.tsx index 84fe422..a0e731c 100644 --- a/src/components/Scroll.tsx +++ b/src/components/Scroll.tsx @@ -2,10 +2,14 @@ import { FC, ReactNode } from 'react'; import { Export, findModuleByExport, findModuleExport } from '../webpack'; -const ScrollingModule = findModuleByExport((e: Export) => e?.render?.toString?.().includes("{case\"x\":")); +const ScrollingModule = findModuleByExport((e: Export) => e?.render?.toString?.().includes('{case"x":')); const ScrollingModuleProps = ScrollingModule ? Object.values(ScrollingModule) : []; -export const ScrollPanel = ScrollingModuleProps.find((prop: any) => prop?.render?.toString?.().includes("{case\"x\":")) as FC<{ children?: ReactNode }>; +export const ScrollPanel = ScrollingModuleProps.find((prop: any) => + prop?.render?.toString?.().includes('{case"x":'), +) as FC<{ children?: ReactNode }>; -export const ScrollPanelGroup: FC<{ children?: ReactNode }> = findModuleExport((e: Export) => e?.render?.toString().includes(".FocusVisibleChild()),[])")); \ No newline at end of file +export const ScrollPanelGroup: FC<{ children?: ReactNode }> = findModuleExport((e: Export) => + e?.render?.toString().includes('.FocusVisibleChild()),[])'), +); diff --git a/src/components/SidebarNavigation.tsx b/src/components/SidebarNavigation.tsx index 95b7784..ba9db3a 100644 --- a/src/components/SidebarNavigation.tsx +++ b/src/components/SidebarNavigation.tsx @@ -23,4 +23,6 @@ export interface SidebarNavigationProps { onPageRequested?: (page: string) => void; } -export const SidebarNavigation = findModuleExport((e: Export) => e?.toString()?.includes('"disableRouteReporting"')) as VFC; +export const SidebarNavigation = findModuleExport((e: Export) => + e?.toString()?.includes('"disableRouteReporting"'), +) as VFC; diff --git a/src/components/SteamSpinner.tsx b/src/components/SteamSpinner.tsx index 96f82b0..345fed8 100755 --- a/src/components/SteamSpinner.tsx +++ b/src/components/SteamSpinner.tsx @@ -2,4 +2,6 @@ import { FC, SVGAttributes } from 'react'; import { Export, findModuleExport } from '../webpack'; -export const SteamSpinner = findModuleExport((e: Export) => e?.toString?.()?.includes('Steam Spinner') && e?.toString?.()?.includes('src')) as FC>; +export const SteamSpinner = findModuleExport( + (e: Export) => e?.toString?.()?.includes('Steam Spinner') && e?.toString?.()?.includes('src'), +) as FC>; diff --git a/src/components/Tabs.tsx b/src/components/Tabs.tsx index e5b2979..ed80a66 100644 --- a/src/components/Tabs.tsx +++ b/src/components/Tabs.tsx @@ -109,8 +109,7 @@ try { * Tabs component as used in the library and media tabs. See {@link TabsProps}. * Unlike other components in `decky-frontend-lib`, this requires Decky Loader to be running. */ -export const Tabs = - (oldTabs || +export const Tabs = (oldTabs || ((props: TabsProps) => { const found = tabsComponent; const [tc, setTC] = useState>(found); diff --git a/src/components/index.ts b/src/components/index.ts index da3f355..fa4cb43 100755 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -22,4 +22,4 @@ export * from './Tabs'; export * from './TextField'; export * from './Toggle'; export * from './ToggleField'; -export * from './Scroll'; \ No newline at end of file +export * from './Scroll'; diff --git a/src/custom-hooks/useQuickAccessVisible.tsx b/src/custom-hooks/useQuickAccessVisible.tsx index de43524..3b80730 100644 --- a/src/custom-hooks/useQuickAccessVisible.tsx +++ b/src/custom-hooks/useQuickAccessVisible.tsx @@ -1,9 +1,12 @@ import { useEffect, useState } from 'react'; + import { getGamepadNavigationTrees } from '../utils'; function getQuickAccessWindow(): Window | null { const navTrees = getGamepadNavigationTrees(); - return navTrees.find((tree: any) => tree?.id === 'QuickAccess-NA')?.m_Root?.m_element?.ownerDocument.defaultView ?? null; + return ( + navTrees.find((tree: any) => tree?.id === 'QuickAccess-NA')?.m_Root?.m_element?.ownerDocument.defaultView ?? null + ); } /** diff --git a/src/globals/SteamClient.ts b/src/globals/SteamClient.ts index 19db6ca..0c65707 100644 --- a/src/globals/SteamClient.ts +++ b/src/globals/SteamClient.ts @@ -227,7 +227,7 @@ export interface LogoPosition { pinnedPosition: LogoPinPositions; nWidthPct: number; nHeightPct: number; -}; +} export interface AppDetails { achievements: AppAchievements; diff --git a/src/globals/index.ts b/src/globals/index.ts index 6b483a7..c749319 100644 --- a/src/globals/index.ts +++ b/src/globals/index.ts @@ -1,2 +1,2 @@ -export * from "./SteamClient"; -export * from "./stores"; \ No newline at end of file +export * from './SteamClient'; +export * from './stores'; diff --git a/src/logger.ts b/src/logger.ts index 77517e3..46ed619 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -22,43 +22,26 @@ export const group = (name: string, ...args: any[]) => { export const groupEnd = (name: string, ...args: any[]) => { console.groupEnd(); - if (args?.length > 0) console.log( - `^ %c @decky/ui %c ${name} %c`, - bgStyle1, - 'background: #1abc9c; color: black;', - 'background: transparent;', - ...args, - ); + if (args?.length > 0) + console.log( + `^ %c @decky/ui %c ${name} %c`, + bgStyle1, + 'background: #1abc9c; color: black;', + 'background: transparent;', + ...args, + ); }; export const debug = (name: string, ...args: any[]) => { - console.debug( - `%c @decky/ui %c ${name} %c`, - bgStyle1, - 'background: #1abc9c; color: black;', - 'color: blue;', - ...args, - ); + console.debug(`%c @decky/ui %c ${name} %c`, bgStyle1, 'background: #1abc9c; color: black;', 'color: blue;', ...args); }; export const warn = (name: string, ...args: any[]) => { - console.warn( - `%c @decky/ui %c ${name} %c`, - bgStyle1, - 'background: #ffbb00; color: black;', - 'color: blue;', - ...args, - ); + console.warn(`%c @decky/ui %c ${name} %c`, bgStyle1, 'background: #ffbb00; color: black;', 'color: blue;', ...args); }; export const error = (name: string, ...args: any[]) => { - console.error( - `%c @decky/ui %c ${name} %c`, - bgStyle1, - 'background: #FF0000;', - 'background: transparent;', - ...args, - ); + console.error(`%c @decky/ui %c ${name} %c`, bgStyle1, 'background: #FF0000;', 'background: transparent;', ...args); }; class Logger { @@ -90,5 +73,5 @@ class Logger { groupEnd(this.name, ...args); } } - -export default Logger; \ No newline at end of file + +export default Logger; diff --git a/src/modules/index.ts b/src/modules/index.ts index 6478e35..44f7dc8 100644 --- a/src/modules/index.ts +++ b/src/modules/index.ts @@ -1 +1 @@ -export * from './Router'; \ No newline at end of file +export * from './Router'; diff --git a/src/utils/react.ts b/src/utils/react.ts index 6597553..765a9fb 100644 --- a/src/utils/react.ts +++ b/src/utils/react.ts @@ -68,14 +68,16 @@ export function wrapReactClass(node: any, prop: any = 'type') { export function getReactRoot(o: HTMLElement | Element | Node) { return ( // @ts-expect-error 7053 - o[Object.keys(o).find((k) => k.startsWith('__reactContainer$')) as string] || o['_reactRootContainer']?._internalRoot?.current + o[Object.keys(o).find((k) => k.startsWith('__reactContainer$')) as string] || + o['_reactRootContainer']?._internalRoot?.current ); } export function getReactInstance(o: HTMLElement | Element | Node) { return ( // @ts-expect-error 7053 - o[Object.keys(o).find((k) => k.startsWith('__reactFiber')) as string] || o[Object.keys(o).find((k) => k.startsWith('__reactInternalInstance')) as string] + o[Object.keys(o).find((k) => k.startsWith('__reactFiber')) as string] || + o[Object.keys(o).find((k) => k.startsWith('__reactInternalInstance')) as string] ); } diff --git a/src/utils/static-classes.ts b/src/utils/static-classes.ts index b4c64e6..77a044b 100644 --- a/src/utils/static-classes.ts +++ b/src/utils/static-classes.ts @@ -543,153 +543,153 @@ type GamepadTabbedPageClasses = Record< >; type GamepadContextMenuClasses = Record< - | "duration-app-launch" - | "BasicContextMenuModal" - | "BasicContextMenuHeader" - | "BasicContextMenuHeaderShrinkableSpacing" - | "BasicContextMenuContainer" - | "slideInAnimation" - | "contextMenu" - | "contextMenuContents" - | "hasSubMenu" - | "contextMenuFade" - | "contextMenuItem" - | "active" - | "Selected" - | "Focused" - | "Positive" - | "Emphasis" - | "Destructive" - | "Capitalized" - | "MenuSectionHeader" - | "UpperCase" - | "SubMenu" - | "ContextMenuSeparator" - | "Label" - | "Arrow" - | "ItemFocusAnim-darkerGrey-nocolor" - | "ItemFocusAnim-darkerGrey" - | "ItemFocusAnim-darkGrey" - | "ItemFocusAnim-grey" - | "ItemFocusAnimBorder-darkGrey" - | "ItemFocusAnim-green" - | "focusAnimation" - | "hoverAnimation", + | 'duration-app-launch' + | 'BasicContextMenuModal' + | 'BasicContextMenuHeader' + | 'BasicContextMenuHeaderShrinkableSpacing' + | 'BasicContextMenuContainer' + | 'slideInAnimation' + | 'contextMenu' + | 'contextMenuContents' + | 'hasSubMenu' + | 'contextMenuFade' + | 'contextMenuItem' + | 'active' + | 'Selected' + | 'Focused' + | 'Positive' + | 'Emphasis' + | 'Destructive' + | 'Capitalized' + | 'MenuSectionHeader' + | 'UpperCase' + | 'SubMenu' + | 'ContextMenuSeparator' + | 'Label' + | 'Arrow' + | 'ItemFocusAnim-darkerGrey-nocolor' + | 'ItemFocusAnim-darkerGrey' + | 'ItemFocusAnim-darkGrey' + | 'ItemFocusAnim-grey' + | 'ItemFocusAnimBorder-darkGrey' + | 'ItemFocusAnim-green' + | 'focusAnimation' + | 'hoverAnimation', string >; type AchievementClasses = Record< - | "nAchievementHeight" - | "nGlobalAchievementHeight" - | "nAchievementsListTitleHeight" - | "nAchievementGap" - | "AchievementList" - | "ListTitle" - | "AchievementListItemBase" - | "Container" - | "Content" - | "Right" - | "Footer" - | "AchievementTitle" - | "AchievementDescription" - | "AchievementGlobalPercentage" - | "InBody" - | "VerticalContent" - | "UnlockDate" - | "AlignEnd" - | "ProgressBar" - | "ProgressCount" - | "AchievementContent" - | "HiddenAchievementContent" - | "FriendAchievementFooter" - | "GlobalPercentage" - | "UserUnlockDateTime" - | "GlobalAchievementsListHeader" - | "SearchField" - | "Avatar" - | "HeaderText" - | "GlobalAchievementListItem" - | "UnlockContainer" - | "Info" - | "Title" - | "Description" - | "Percent" - | "ImageContainer" - | "ProgressFill" - | "SpoilerWarning" - | "Hidden" - | "ComparisonAchieverColumn" - | "ComparisonAchieverInfo" - | "ProgressContainer" - | "ProgressLabel" - | "Secondary" - | "AvatarContainer" - | "Unachieved", + | 'nAchievementHeight' + | 'nGlobalAchievementHeight' + | 'nAchievementsListTitleHeight' + | 'nAchievementGap' + | 'AchievementList' + | 'ListTitle' + | 'AchievementListItemBase' + | 'Container' + | 'Content' + | 'Right' + | 'Footer' + | 'AchievementTitle' + | 'AchievementDescription' + | 'AchievementGlobalPercentage' + | 'InBody' + | 'VerticalContent' + | 'UnlockDate' + | 'AlignEnd' + | 'ProgressBar' + | 'ProgressCount' + | 'AchievementContent' + | 'HiddenAchievementContent' + | 'FriendAchievementFooter' + | 'GlobalPercentage' + | 'UserUnlockDateTime' + | 'GlobalAchievementsListHeader' + | 'SearchField' + | 'Avatar' + | 'HeaderText' + | 'GlobalAchievementListItem' + | 'UnlockContainer' + | 'Info' + | 'Title' + | 'Description' + | 'Percent' + | 'ImageContainer' + | 'ProgressFill' + | 'SpoilerWarning' + | 'Hidden' + | 'ComparisonAchieverColumn' + | 'ComparisonAchieverInfo' + | 'ProgressContainer' + | 'ProgressLabel' + | 'Secondary' + | 'AvatarContainer' + | 'Unachieved', string >; type MainMenuAppRunningClasses = Record< - | "duration-app-launch" - | "ScrollMask" - | "HideMask" - | "MainMenuAppRunning" - | "MenuOpen" - | "NavigationColumn" - | "ControllerColumnFocused" - | "NavColumnFocused" - | "NavigationBox" - | "NavigationMenuItem" - | "ItemFocusAnim-darkerGrey" - | "Active" - | "Disabled" - | "SwitchAppsTitle" - | "SelectableAppWindow" - | "ActiveDot" - | "NavigationMenuItemSeparator" - | "AppColumn" - | "FocusedColumn" - | "AppColumnContent" - | "ActiveContent" - | "CurrentGameBackground" - | "CurrentGameLogo" - | "OverlayAchievements" - | "Container" - | "OverlayGuides" - | "OverlayNotes" - | "OverlayInplaceBrowser" - | "ItemFocusAnim-darkerGrey-nocolor" - | "ItemFocusAnim-darkGrey" - | "ItemFocusAnim-grey" - | "ItemFocusAnimBorder-darkGrey" - | "ItemFocusAnim-green" - | "focusAnimation" - | "hoverAnimation", + | 'duration-app-launch' + | 'ScrollMask' + | 'HideMask' + | 'MainMenuAppRunning' + | 'MenuOpen' + | 'NavigationColumn' + | 'ControllerColumnFocused' + | 'NavColumnFocused' + | 'NavigationBox' + | 'NavigationMenuItem' + | 'ItemFocusAnim-darkerGrey' + | 'Active' + | 'Disabled' + | 'SwitchAppsTitle' + | 'SelectableAppWindow' + | 'ActiveDot' + | 'NavigationMenuItemSeparator' + | 'AppColumn' + | 'FocusedColumn' + | 'AppColumnContent' + | 'ActiveContent' + | 'CurrentGameBackground' + | 'CurrentGameLogo' + | 'OverlayAchievements' + | 'Container' + | 'OverlayGuides' + | 'OverlayNotes' + | 'OverlayInplaceBrowser' + | 'ItemFocusAnim-darkerGrey-nocolor' + | 'ItemFocusAnim-darkGrey' + | 'ItemFocusAnim-grey' + | 'ItemFocusAnimBorder-darkGrey' + | 'ItemFocusAnim-green' + | 'focusAnimation' + | 'hoverAnimation', string >; type BasicAppDetailsSectionStylerClasses = Record< - | "duration-app-launch" - | "headerPadding" - | "Header" - | "AppDetailsContent" - | "AppDetailsContainer" - | "AppDetailsRoot" - | "GameInfoContainer" - | "GameInfoQuickLinks" - | "GameInfoCollections" - | "CollectionsHeader" - | "PlaySection" - | "ActionRow" - | "AppDetailSectionList" - | "AppActionButton" - | "ActionButtonAndStatusPanel" - | "AppButtons" - | "InvertFocusedIcon" - | "DeckVerifiedFeedbackContainer" - | "DeckVerifiedFeedbackConfirmationContainer" - | "DeckVerifiedFeedbackButton" - | "DeckVerifiedFeedbackQuestion" - | "DeckVerifiedFeedbackConfirmation", + | 'duration-app-launch' + | 'headerPadding' + | 'Header' + | 'AppDetailsContent' + | 'AppDetailsContainer' + | 'AppDetailsRoot' + | 'GameInfoContainer' + | 'GameInfoQuickLinks' + | 'GameInfoCollections' + | 'CollectionsHeader' + | 'PlaySection' + | 'ActionRow' + | 'AppDetailSectionList' + | 'AppActionButton' + | 'ActionButtonAndStatusPanel' + | 'AppButtons' + | 'InvertFocusedIcon' + | 'DeckVerifiedFeedbackContainer' + | 'DeckVerifiedFeedbackConfirmationContainer' + | 'DeckVerifiedFeedbackButton' + | 'DeckVerifiedFeedbackQuestion' + | 'DeckVerifiedFeedbackConfirmation', string >; @@ -700,9 +700,7 @@ export const quickAccessMenuClasses: QuickAccessMenuClasses = findModule( * @depreciated please use quickAccessMenuClasses instead */ export const staticClasses = quickAccessMenuClasses; -export const scrollPanelClasses: ScrollPanelClasses = findModule( - (mod) => typeof mod === 'object' && mod?.ScrollPanel, -); +export const scrollPanelClasses: ScrollPanelClasses = findModule((mod) => typeof mod === 'object' && mod?.ScrollPanel); /** * @depreciated please use scrollPanelClasses instead */ @@ -717,33 +715,27 @@ export const quickAccessControlsClasses: QuickAccessControlsClasses = findModule export const updaterFieldClasses: UpdaterFieldClasses = findModule( (mod) => typeof mod === 'object' && mod?.OOBEUpdateStatusContainer, ); -export const playSectionClasses: PlaySectionClasses = findModule( - (mod) => typeof mod === 'object' && mod?.Container, -); +export const playSectionClasses: PlaySectionClasses = findModule((mod) => typeof mod === 'object' && mod?.Container); export const gamepadSliderClasses: GamepadSliderClasses = findModule( (mod) => typeof mod === 'object' && mod?.SliderControlPanelGroup, ); export const appDetailsHeaderClasses: AppDetailsHeaderClasses = findModule( (mod) => typeof mod === 'object' && mod?.TopCapsule, ); -export const appDetailsClasses: AppDetailsClasses = findModule( - (mod) => typeof mod === 'object' && mod?.HeaderLoaded, -); -export const gamepadUIClasses: GamepadUIClasses = findModule( - (mod) => typeof mod === 'object' && mod?.BasicUiRoot, -); +export const appDetailsClasses: AppDetailsClasses = findModule((mod) => typeof mod === 'object' && mod?.HeaderLoaded); +export const gamepadUIClasses: GamepadUIClasses = findModule((mod) => typeof mod === 'object' && mod?.BasicUiRoot); export const gamepadTabbedPageClasses: GamepadTabbedPageClasses = findModule( - (mod) => typeof mod === 'object' && mod?.GamepadTabbedPage + (mod) => typeof mod === 'object' && mod?.GamepadTabbedPage, ); export const gamepadContextMenuClasses: GamepadContextMenuClasses = findModule( - (mod) => typeof mod === 'object' && mod?.BasicContextMenuModal + (mod) => typeof mod === 'object' && mod?.BasicContextMenuModal, ); export const achievementClasses: AchievementClasses = findModule( - (mod) => typeof mod === 'object' && mod?.AchievementListItemBase + (mod) => typeof mod === 'object' && mod?.AchievementListItemBase, ); export const mainMenuAppRunningClasses: MainMenuAppRunningClasses = findModule( - (mod) => typeof mod === 'object' && mod?.MainMenuAppRunning + (mod) => typeof mod === 'object' && mod?.MainMenuAppRunning, ); export const basicAppDetailsSectionStylerClasses: BasicAppDetailsSectionStylerClasses = findModule( - (mod) => typeof mod === 'object' && mod?.AppDetailsRoot + (mod) => typeof mod === 'object' && mod?.AppDetailsRoot, ); diff --git a/src/webpack.ts b/src/webpack.ts index 4b26dd3..5862c62 100644 --- a/src/webpack.ts +++ b/src/webpack.ts @@ -1,4 +1,4 @@ -import Logger from "./logger"; +import Logger from './logger'; declare global { interface Window { @@ -6,7 +6,7 @@ declare global { } } -const logger = new Logger("Webpack"); +const logger = new Logger('Webpack'); // In most case an object with getters for each property. Look for the first call to r.d in the module, usually near or at the top. export type Module = any; @@ -19,11 +19,11 @@ export let modules: any = []; function initModuleCache() { const startTime = performance.now(); - logger.group("Webpack Module Init"); + logger.group('Webpack Module Init'); // Webpack 5, currently on beta // Generate a fake module ID const id = Math.random(); // really should be an int and not a float but who cares - let webpackRequire!: ((id: any) => Module) & {m: object}; + let webpackRequire!: ((id: any) => Module) & { m: object }; // Insert our module in a new chunk. // The module will then be called with webpack's internal require function as its first argument window.webpackChunksteamui.push([ @@ -34,7 +34,9 @@ function initModuleCache() { }, ]); - logger.log("Initializing all modules. Errors here likely do not matter, as they are usually just failing module side effects."); + logger.log( + 'Initializing all modules. Errors here likely do not matter, as they are usually just failing module side effects.', + ); // Loop over every module ID for (let i of Object.keys(webpackRequire.m)) { @@ -44,7 +46,7 @@ function initModuleCache() { modules.push(module); } } catch (e) { - logger.debug("Ignoring require error for module", i, e); + logger.debug('Ignoring require error for module', i, e); } } @@ -60,7 +62,10 @@ export const findModule = (filter: FilterFn) => { } }; -export const findModuleDetailsByExport = (filter: ExportFilterFn, minExports?: number): [module: Module | undefined, moduleExport: any, exportName: any] => { +export const findModuleDetailsByExport = ( + filter: ExportFilterFn, + minExports?: number, +): [module: Module | undefined, moduleExport: any, exportName: any] => { for (const m of modules) { if (!m) continue; for (const mod of [m.default, m]) { @@ -79,15 +84,15 @@ export const findModuleDetailsByExport = (filter: ExportFilterFn, minExports?: n } } return [undefined, undefined, undefined]; -} +}; export const findModuleByExport = (filter: ExportFilterFn, minExports?: number) => { return findModuleDetailsByExport(filter, minExports)?.[0]; -} +}; export const findModuleExport = (filter: ExportFilterFn, minExports?: number) => { return findModuleDetailsByExport(filter, minExports)?.[1]; -} +}; /** * @deprecated use findModuleExport instead @@ -124,6 +129,8 @@ export const CommonUIModule = modules.find((m: Module) => { return false; }); -export const IconsModule = findModuleByExport(e => e?.toString && /Spinner\)}\),.\.createElement\(\"path\",{d:\"M18 /.test(e.toString())); +export const IconsModule = findModuleByExport( + (e) => e?.toString && /Spinner\)}\),.\.createElement\(\"path\",{d:\"M18 /.test(e.toString()), +); -export const ReactRouter = findModuleByExport(e => e.computeRootMatch); +export const ReactRouter = findModuleByExport((e) => e.computeRootMatch); diff --git a/typedoc.json b/typedoc.json index d87e758..0ed44db 100644 --- a/typedoc.json +++ b/typedoc.json @@ -1,4 +1,4 @@ { - "categorizeByGroup": false, - "excludeExternals": true -} \ No newline at end of file + "categorizeByGroup": false, + "excludeExternals": true +}