mirror of
https://github.com/SteamDeckHomebrew/decky-frontend-lib.git
synced 2026-05-21 18:38:47 +02:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27e1a9c8b0 | ||
|
|
55bd06a5ee | ||
|
|
58550b1f6e | ||
|
|
c25fe58f08 | ||
|
|
ef147c6715 | ||
|
|
43e9417303 | ||
|
|
cf137c43b4 | ||
|
|
8167be7642 | ||
|
|
a09af357c7 | ||
|
|
e48180d7bb | ||
|
|
490a1f77fa | ||
|
|
d1b47d21ed | ||
|
|
af98a76b86 | ||
|
|
d18b1ba1ed | ||
|
|
6be06446f2 | ||
|
|
bb8a6df115 | ||
|
|
a672230b00 |
15
.vscode/tasks.json
vendored
Normal file
15
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "npm",
|
||||||
|
"script": "dev",
|
||||||
|
"problemMatcher": [
|
||||||
|
"$tsc-watch"
|
||||||
|
],
|
||||||
|
"label": "npm: dev",
|
||||||
|
"detail": "tsc -b -w",
|
||||||
|
"isBackground": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
50
CHANGELOG.md
50
CHANGELOG.md
@@ -1,3 +1,53 @@
|
|||||||
|
## [1.8.1](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v1.8.0...v1.8.1) (2022-08-26)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **utils:** update wrapReactClass impl. and defaults for prop argument ([#17](https://github.com/SteamDeckHomebrew/decky-frontend-lib/issues/17)) ([55bd06a](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/55bd06a5ee9468f572aed8f78be4d0acaaffe45a))
|
||||||
|
|
||||||
|
# [1.8.0](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v1.7.8...v1.8.0) (2022-08-26)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **components:** add Carousel component ([cf137c4](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/cf137c43b4962977650e6ce0fad554b6ae966e43))
|
||||||
|
* **Focusable:** add FooterLegend props to Focusable and Field ([c25fe58](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/c25fe58f082d70a34443ac3c8b32b4528a4b01fb))
|
||||||
|
|
||||||
|
## [1.7.8](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v1.7.7...v1.7.8) (2022-08-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **Dropdown:** correct Dropdown types ([#15](https://github.com/SteamDeckHomebrew/decky-frontend-lib/issues/15)) ([a09af35](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/a09af357c7e750377feefad86ab417b19484cb60))
|
||||||
|
|
||||||
|
## [1.7.7](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v1.7.6...v1.7.7) (2022-08-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **FieldProps:** Add "bottomSeparator" option ([#16](https://github.com/SteamDeckHomebrew/decky-frontend-lib/issues/16)) ([490a1f7](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/490a1f77fa98a988f0cae61d74370bf3fa96336c))
|
||||||
|
|
||||||
|
## [1.7.6](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v1.7.5...v1.7.6) (2022-08-18)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **TextFieldProps:** Add "disabled" option to TextFieldProps ([#14](https://github.com/SteamDeckHomebrew/decky-frontend-lib/issues/14)) ([af98a76](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/af98a76b86fb05942b9554adb369adbeaf27e70f))
|
||||||
|
|
||||||
|
## [1.7.5](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v1.7.4...v1.7.5) (2022-08-18)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **ButtonItem:** update to account for both prop settings ([6be0644](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/6be06446f2a7e0357b830be116fd25810c427dd5))
|
||||||
|
|
||||||
|
## [1.7.4](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v1.7.3...v1.7.4) (2022-08-18)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* updates for webpack v5 ([a672230](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/a672230b0051dd942988554ec663ea7bfcd61cfe))
|
||||||
|
|
||||||
## [1.7.3](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v1.7.2...v1.7.3) (2022-08-17)
|
## [1.7.3](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v1.7.2...v1.7.3) (2022-08-17)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "decky-frontend-lib",
|
"name": "decky-frontend-lib",
|
||||||
"version": "1.7.3",
|
"version": "1.8.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "decky-frontend-lib",
|
"name": "decky-frontend-lib",
|
||||||
"version": "1.7.3",
|
"version": "1.8.1",
|
||||||
"license": "GPL-2.0-or-later",
|
"license": "GPL-2.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"minimist": "^1.2.6"
|
"minimist": "^1.2.6"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "decky-frontend-lib",
|
"name": "decky-frontend-lib",
|
||||||
"version": "1.7.3",
|
"version": "1.8.1",
|
||||||
"description": "A library for building decky plugins",
|
"description": "A library for building decky plugins",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ export interface ButtonItemProps extends ItemProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const ButtonItem = Object.values(CommonUIModule).find((mod: any) =>
|
export const ButtonItem = Object.values(CommonUIModule).find((mod: any) =>
|
||||||
mod?.render?.toString()?.includes('childrenContainerWidth:"min"'),
|
mod?.render?.toString()?.includes('"highlightOnFocus","childrenContainerWidth"') || mod?.render?.toString()?.includes('childrenContainerWidth:"min"'),
|
||||||
) as FC<ButtonItemProps>;
|
) as FC<ButtonItemProps>;
|
||||||
|
|||||||
28
src/deck-components/Carousel.ts
Normal file
28
src/deck-components/Carousel.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { HTMLAttributes, ReactNode, RefAttributes, VFC } from "react";
|
||||||
|
import { findModuleChild } from "../webpack";
|
||||||
|
|
||||||
|
export interface CarouselProps extends HTMLAttributes<HTMLDivElement> {
|
||||||
|
autoFocus?: boolean;
|
||||||
|
enableBumperPaging?: boolean;
|
||||||
|
fnDoesItemTakeFocus?: (...unknown: any[]) => boolean;
|
||||||
|
fnGetColumnWidth?: (...unknown: any[]) => number;
|
||||||
|
fnGetId?: (id: number) => number;
|
||||||
|
fnItemRenderer?: (id: number, ...unknown: any[]) => ReactNode;
|
||||||
|
fnUpdateArrows?: (...unknown: any[]) => any;
|
||||||
|
initialColumn?: number;
|
||||||
|
nHeight?: number;
|
||||||
|
nIndexLeftmost?: number;
|
||||||
|
nItemHeight?: number;
|
||||||
|
nItemMarginX?: number;
|
||||||
|
nNumItems?: number;
|
||||||
|
name?: string;
|
||||||
|
scrollToAlignment?: 'center';
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Carousel = findModuleChild((m) => {
|
||||||
|
if (typeof m !== 'object') return undefined;
|
||||||
|
for (let prop in m) {
|
||||||
|
if (m[prop]?.render?.toString().includes("setFocusedColumn:"))
|
||||||
|
return m[prop];
|
||||||
|
}
|
||||||
|
}) as VFC<CarouselProps & RefAttributes<HTMLDivElement>>;
|
||||||
@@ -4,14 +4,14 @@ import { CommonUIModule } from '../webpack';
|
|||||||
import { ItemProps } from './Item';
|
import { ItemProps } from './Item';
|
||||||
|
|
||||||
export interface SingleDropdownOption {
|
export interface SingleDropdownOption {
|
||||||
data: number;
|
data: any;
|
||||||
label: string;
|
label: ReactNode;
|
||||||
|
|
||||||
options?: never;
|
options?: never;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MultiDropdownOption {
|
export interface MultiDropdownOption {
|
||||||
label: string;
|
label: ReactNode;
|
||||||
options: DropdownOption[];
|
options: DropdownOption[];
|
||||||
|
|
||||||
data?: never;
|
data?: never;
|
||||||
@@ -21,7 +21,7 @@ export type DropdownOption = SingleDropdownOption | MultiDropdownOption;
|
|||||||
|
|
||||||
export interface DropdownProps {
|
export interface DropdownProps {
|
||||||
rgOptions: DropdownOption[];
|
rgOptions: DropdownOption[];
|
||||||
selectedOption: number | null;
|
selectedOption: any;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
onMenuWillOpen?(showMenu: () => void): void;
|
onMenuWillOpen?(showMenu: () => void): void;
|
||||||
onMenuOpened?(): void;
|
onMenuOpened?(): void;
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { FC, HTMLAttributes, ReactNode, RefAttributes } from 'react';
|
import { FC, HTMLAttributes, ReactNode, RefAttributes } from 'react';
|
||||||
import { findModuleChild } from '../webpack';
|
import { findModuleChild } from '../webpack';
|
||||||
|
import { FooterLegendProps } from './FooterLegend';
|
||||||
|
|
||||||
export interface FieldProps extends HTMLAttributes<HTMLDivElement> {
|
export interface FieldProps extends HTMLAttributes<HTMLDivElement>, FooterLegendProps {
|
||||||
label?: string | ReactNode;
|
label?: string | ReactNode;
|
||||||
|
bottomSeparator?: boolean;
|
||||||
description?: string | ReactNode;
|
description?: string | ReactNode;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
icon?: ReactNode;
|
icon?: ReactNode;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { HTMLAttributes, ReactNode, RefAttributes, VFC } from "react";
|
import { HTMLAttributes, ReactNode, RefAttributes, VFC } from "react";
|
||||||
import { findModuleChild } from "../webpack";
|
import { findModuleChild } from "../webpack";
|
||||||
|
import { FooterLegendProps } from "./FooterLegend";
|
||||||
|
|
||||||
export interface FocusableProps extends HTMLAttributes<HTMLDivElement> {
|
export interface FocusableProps extends HTMLAttributes<HTMLDivElement>, FooterLegendProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
"flow-children"?: string;
|
"flow-children"?: string;
|
||||||
focusClassName?: string;
|
focusClassName?: string;
|
||||||
|
|||||||
18
src/deck-components/FooterLegend.ts
Normal file
18
src/deck-components/FooterLegend.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
export interface FooterLegendProps {
|
||||||
|
actionDescriptionMap?: unknown;
|
||||||
|
onOKActionDescription?: string;
|
||||||
|
onCancelActionDescription?: string;
|
||||||
|
onSecondaryActionDescription?: string;
|
||||||
|
onOptionsActionDescription?: string;
|
||||||
|
onMenuActionDescription?: string;
|
||||||
|
onButtonDown?: () => void;
|
||||||
|
onButtonUp?: () => void;
|
||||||
|
onOKButton?: () => void;
|
||||||
|
onCancelButton?: () => void;
|
||||||
|
onSecondaryButton?: () => void;
|
||||||
|
onOptionsButton?: () => void;
|
||||||
|
onGamepadDirection?: () => void;
|
||||||
|
onGamepadFocus?: () => void;
|
||||||
|
onGamepadBlur?: () => void;
|
||||||
|
onMenuButton?: () => void;
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ export interface TextFieldProps {
|
|||||||
label?: ReactNode;
|
label?: ReactNode;
|
||||||
requiredLabel?: ReactNode;
|
requiredLabel?: ReactNode;
|
||||||
description?: ReactNode;
|
description?: ReactNode;
|
||||||
|
disabled?: boolean;
|
||||||
bShowCopyAction?: boolean;
|
bShowCopyAction?: boolean;
|
||||||
bShowClearAction?: boolean;
|
bShowClearAction?: boolean;
|
||||||
bAlwaysShowClearAction?: boolean;
|
bAlwaysShowClearAction?: boolean;
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
export * from './Button';
|
export * from './Button';
|
||||||
export * from './ButtonItem';
|
export * from './ButtonItem';
|
||||||
|
export * from './Carousel';
|
||||||
export * from './Dropdown';
|
export * from './Dropdown';
|
||||||
export * from './Field';
|
export * from './Field';
|
||||||
export * from './Focusable';
|
export * from './Focusable';
|
||||||
|
export * from './FooterLegend';
|
||||||
export * from './Menu';
|
export * from './Menu';
|
||||||
export * from './Modal';
|
export * from './Modal';
|
||||||
export * from './Panel';
|
export * from './Panel';
|
||||||
|
|||||||
@@ -165,6 +165,50 @@ type QuickAccessControlsClasses = Record<
|
|||||||
string
|
string
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
type UpdaterFieldClasses = Record<
|
||||||
|
| "duration-app-launch"
|
||||||
|
| "OOBEUpdateStatusContainer"
|
||||||
|
| "UpdateScreen"
|
||||||
|
| "UpdatePanel"
|
||||||
|
| "CurrentStatus"
|
||||||
|
| "TotalUpdateSize"
|
||||||
|
| "ProgressInfoContainer"
|
||||||
|
| "TimeRemaining"
|
||||||
|
| "BatteryLowWarning"
|
||||||
|
| "fadeInAnimation"
|
||||||
|
| "ProgressStatus"
|
||||||
|
| "UpdateStatusContainer"
|
||||||
|
| "UpdaterFieldStatusSuccess"
|
||||||
|
| "UpdaterFieldStatusApplying"
|
||||||
|
| "TextContainer"
|
||||||
|
| "ApplyingText"
|
||||||
|
| "UpdateBytesRemaining"
|
||||||
|
| "Label"
|
||||||
|
| "Numerator"
|
||||||
|
| "Separator"
|
||||||
|
| "Denominator"
|
||||||
|
| "PatchNotes"
|
||||||
|
| "PostedTime"
|
||||||
|
| "EventDetailTitle"
|
||||||
|
| "EventDetailsSubTitle"
|
||||||
|
| "EventDetailsBody"
|
||||||
|
| "InsufficientBatteryText"
|
||||||
|
| "UnsupportedHardwareWarning"
|
||||||
|
| "Title"
|
||||||
|
| "Text"
|
||||||
|
| "Body"
|
||||||
|
| "ItemFocusAnim-darkerGrey-nocolor"
|
||||||
|
| "ItemFocusAnim-darkerGrey"
|
||||||
|
| "ItemFocusAnim-darkGrey"
|
||||||
|
| "ItemFocusAnim-grey"
|
||||||
|
| "ItemFocusAnimBorder-darkGrey"
|
||||||
|
| "ItemFocusAnim-green"
|
||||||
|
| "focusAnimation"
|
||||||
|
| "hoverAnimation",
|
||||||
|
string
|
||||||
|
>;
|
||||||
|
|
||||||
|
|
||||||
export const staticClasses: StaticClasses = findModule((mod) => {
|
export const staticClasses: StaticClasses = findModule((mod) => {
|
||||||
if (typeof mod !== 'object') return false;
|
if (typeof mod !== 'object') return false;
|
||||||
|
|
||||||
@@ -204,3 +248,13 @@ export const quickAccessControlsClasses: QuickAccessControlsClasses = findModule
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const updaterFieldClasses: UpdaterFieldClasses = findModule((mod) => {
|
||||||
|
if (typeof mod !== 'object') return false;
|
||||||
|
|
||||||
|
if (mod.PatchNotes && mod.PostedTime) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|||||||
23
src/utils.ts
23
src/utils.ts
@@ -82,25 +82,14 @@ export function unpatch(obj: any, name: any): void {
|
|||||||
obj[name] = obj[name].__deckyOrig;
|
obj[name] = obj[name].__deckyOrig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function wrapReactType(node: any, prop?: any) {
|
export function wrapReactType(node: any, prop: any = 'type') {
|
||||||
return node[prop || "type"] = {...node[prop || "type"]};
|
return node[prop] = {...node[prop]};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function wrapReactClass(node: any, prop?: any) {
|
export function wrapReactClass(node: any, prop: any = 'type') {
|
||||||
const cls = node[prop || "type"];
|
const cls = node[prop];
|
||||||
const wrappedCls = class extends cls {};
|
const wrappedCls = class extends cls {};
|
||||||
Object.getOwnPropertyNames(cls.prototype).forEach((prop: any) => {
|
return node[prop] = wrappedCls;
|
||||||
try {
|
|
||||||
wrappedCls.prototype[prop] = cls.prototype[prop]
|
|
||||||
} catch (e) {}
|
|
||||||
});
|
|
||||||
Object.getOwnPropertyNames(cls).forEach((prop: any) => {
|
|
||||||
try {
|
|
||||||
if (prop != "prototype") wrappedCls[prop] = cls[prop]
|
|
||||||
} catch (e) {}
|
|
||||||
});
|
|
||||||
wrappedCls.prototype.__proto__ = cls.prototype.__proto__;
|
|
||||||
return node[prop || "type"] = wrappedCls;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getReactInstance(o: HTMLElement | Element | Node) {
|
export function getReactInstance(o: HTMLElement | Element | Node) {
|
||||||
@@ -142,4 +131,4 @@ export const findInTree = (parent: any, filter: findInTreeFilter, opts: findInTr
|
|||||||
|
|
||||||
export const findInReactTree = (node: any, filter: findInTreeFilter) => findInTree(node, filter, { // Specialised findInTree for React nodes
|
export const findInReactTree = (node: any, filter: findInTreeFilter) => findInTree(node, filter, { // Specialised findInTree for React nodes
|
||||||
walkable: [ 'props', 'children', 'child', 'sibling' ]
|
walkable: [ 'props', 'children', 'child', 'sibling' ]
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
webpackJsonp: any;
|
webpackJsonp: any;
|
||||||
|
webpackChunksteamui: any;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9,14 +10,33 @@ export type Module = any;
|
|||||||
type FilterFn = (module: any) => boolean;
|
type FilterFn = (module: any) => boolean;
|
||||||
type FindFn = (module: any) => any;
|
type FindFn = (module: any) => any;
|
||||||
|
|
||||||
const wpRequire = window.webpackJsonp.push([
|
export let webpackCache: any = {};
|
||||||
[],
|
let hasWebpack5 = false;
|
||||||
{ get_require: (mod: any, _exports: any, wpRequire: any) => (mod.exports = wpRequire) },
|
|
||||||
[['get_require']],
|
|
||||||
]);
|
|
||||||
|
|
||||||
export const allModules: Module[] = Object.keys(wpRequire.c)
|
if (window.webpackJsonp && !window.webpackJsonp.deckyShimmed) {
|
||||||
.map((x) => wpRequire.c[x].exports)
|
// Webpack 4, currently on stable
|
||||||
|
const wpRequire = window.webpackJsonp.push([
|
||||||
|
[],
|
||||||
|
{ get_require: (mod: any, _exports: any, wpRequire: any) => (mod.exports = wpRequire) },
|
||||||
|
[['get_require']],
|
||||||
|
]);
|
||||||
|
|
||||||
|
delete wpRequire.m.get_require;
|
||||||
|
delete wpRequire.c.get_require;
|
||||||
|
webpackCache = wpRequire.c;
|
||||||
|
} else {
|
||||||
|
// Webpack 5, currently on beta
|
||||||
|
hasWebpack5 = true;
|
||||||
|
const id = Math.random();
|
||||||
|
let initReq: any;
|
||||||
|
window.webpackChunksteamui.push([[ id ], {}, (r: any) => { initReq = r }]);
|
||||||
|
for (let i of Object.keys(initReq.m)) {
|
||||||
|
webpackCache[i] = initReq(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const allModules: Module[] = hasWebpack5 ? Object.values(webpackCache).filter((x) => x) : Object.keys(webpackCache)
|
||||||
|
.map((x) => webpackCache[x].exports)
|
||||||
.filter((x) => x);
|
.filter((x) => x);
|
||||||
|
|
||||||
export const findModule = (filter: FilterFn) => {
|
export const findModule = (filter: FilterFn) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user