mirror of
https://github.com/SteamDeckHomebrew/decky-frontend-lib.git
synced 2026-05-20 10:00:08 +02:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27e1a9c8b0 | ||
|
|
55bd06a5ee | ||
|
|
58550b1f6e | ||
|
|
c25fe58f08 | ||
|
|
ef147c6715 | ||
|
|
43e9417303 | ||
|
|
cf137c43b4 | ||
|
|
8167be7642 | ||
|
|
a09af357c7 | ||
|
|
e48180d7bb | ||
|
|
490a1f77fa |
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
|
||||
}
|
||||
]
|
||||
}
|
||||
29
CHANGELOG.md
29
CHANGELOG.md
@@ -1,3 +1,32 @@
|
||||
## [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)
|
||||
|
||||
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "decky-frontend-lib",
|
||||
"version": "1.7.6",
|
||||
"version": "1.8.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "decky-frontend-lib",
|
||||
"version": "1.7.6",
|
||||
"version": "1.8.1",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"dependencies": {
|
||||
"minimist": "^1.2.6"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "decky-frontend-lib",
|
||||
"version": "1.7.6",
|
||||
"version": "1.8.1",
|
||||
"description": "A library for building decky plugins",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
||||
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';
|
||||
|
||||
export interface SingleDropdownOption {
|
||||
data: number;
|
||||
label: string;
|
||||
data: any;
|
||||
label: ReactNode;
|
||||
|
||||
options?: never;
|
||||
}
|
||||
|
||||
export interface MultiDropdownOption {
|
||||
label: string;
|
||||
label: ReactNode;
|
||||
options: DropdownOption[];
|
||||
|
||||
data?: never;
|
||||
@@ -21,7 +21,7 @@ export type DropdownOption = SingleDropdownOption | MultiDropdownOption;
|
||||
|
||||
export interface DropdownProps {
|
||||
rgOptions: DropdownOption[];
|
||||
selectedOption: number | null;
|
||||
selectedOption: any;
|
||||
disabled?: boolean;
|
||||
onMenuWillOpen?(showMenu: () => void): void;
|
||||
onMenuOpened?(): void;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { FC, HTMLAttributes, ReactNode, RefAttributes } from 'react';
|
||||
import { findModuleChild } from '../webpack';
|
||||
import { FooterLegendProps } from './FooterLegend';
|
||||
|
||||
export interface FieldProps extends HTMLAttributes<HTMLDivElement> {
|
||||
export interface FieldProps extends HTMLAttributes<HTMLDivElement>, FooterLegendProps {
|
||||
label?: string | ReactNode;
|
||||
bottomSeparator?: boolean;
|
||||
description?: string | ReactNode;
|
||||
disabled?: boolean;
|
||||
icon?: ReactNode;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { HTMLAttributes, ReactNode, RefAttributes, VFC } from "react";
|
||||
import { findModuleChild } from "../webpack";
|
||||
import { FooterLegendProps } from "./FooterLegend";
|
||||
|
||||
export interface FocusableProps extends HTMLAttributes<HTMLDivElement> {
|
||||
export interface FocusableProps extends HTMLAttributes<HTMLDivElement>, FooterLegendProps {
|
||||
children: ReactNode;
|
||||
"flow-children"?: 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;
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
export * from './Button';
|
||||
export * from './ButtonItem';
|
||||
export * from './Carousel';
|
||||
export * from './Dropdown';
|
||||
export * from './Field';
|
||||
export * from './Focusable';
|
||||
export * from './FooterLegend';
|
||||
export * from './Menu';
|
||||
export * from './Modal';
|
||||
export * from './Panel';
|
||||
|
||||
@@ -165,6 +165,50 @@ type QuickAccessControlsClasses = Record<
|
||||
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) => {
|
||||
if (typeof mod !== 'object') return false;
|
||||
|
||||
@@ -204,3 +248,13 @@ export const quickAccessControlsClasses: QuickAccessControlsClasses = findModule
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
export function wrapReactType(node: any, prop?: any) {
|
||||
return node[prop || "type"] = {...node[prop || "type"]};
|
||||
export function wrapReactType(node: any, prop: any = 'type') {
|
||||
return node[prop] = {...node[prop]};
|
||||
}
|
||||
|
||||
export function wrapReactClass(node: any, prop?: any) {
|
||||
const cls = node[prop || "type"];
|
||||
export function wrapReactClass(node: any, prop: any = 'type') {
|
||||
const cls = node[prop];
|
||||
const wrappedCls = class extends cls {};
|
||||
Object.getOwnPropertyNames(cls.prototype).forEach((prop: any) => {
|
||||
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;
|
||||
return node[prop] = wrappedCls;
|
||||
}
|
||||
|
||||
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
|
||||
walkable: [ 'props', 'children', 'child', 'sibling' ]
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user