Compare commits

...

3 Commits

Author SHA1 Message Date
Jonas Dellinger
f101e23c1c 0.0.6 2022-06-02 17:58:18 +02:00
Jonas Dellinger
5b3ea8f63f 0.0.5 2022-06-02 17:57:48 +02:00
AAGaming
07ccceb990 add modal support, showModal->showContextMenu and new showModal 2022-06-01 17:51:17 -04:00
7 changed files with 44 additions and 17 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "decky-frontend-lib",
"version": "0.0.4",
"version": "0.0.6",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "decky-frontend-lib",
"version": "0.0.4",
"version": "0.0.6",
"license": "GPL-2.0-or-later",
"devDependencies": {
"@types/jest": "^27.4.1",

View File

@@ -1,6 +1,6 @@
{
"name": "decky-frontend-lib",
"version": "0.0.4",
"version": "0.0.6",
"description": "A library for building decky plugins",
"main": "dist/index.js",
"types": "dist/index.d.ts",

11
src/deck-components/Menu.tsx Normal file → Executable file
View File

@@ -1,7 +1,16 @@
import { FC } from 'react';
import { FC, ReactNode } from 'react';
import { findModuleChild } from '../webpack';
export const showContextMenu: (children: ReactNode, parent?: EventTarget) => void = findModuleChild((m) => {
if (typeof m !== 'object') return undefined;
for (let prop in m) {
if (typeof m[prop] === 'function' && m[prop].toString().includes('stopPropagation))')) {
return m[prop];
}
}
});
interface MenuProps {
label: string;
onCancel?(): void;

24
src/deck-components/Modal.tsx Normal file → Executable file
View File

@@ -1,12 +1,28 @@
import { ReactNode } from 'react';
import { FC, ReactNode } from 'react';
import { findModuleChild } from '../webpack';
export const showModal: (children: ReactNode, parent: EventTarget) => void = findModuleChild((m) => {
// TODO: there is another argument, figure out what it does
export const showModal: (children: ReactNode, parent?: EventTarget) => void = findModuleChild((m) => {
if (typeof m !== 'object') return undefined;
for (let prop in m) {
if (typeof m[prop] === 'function' && m[prop].toString().includes('stopPropagation))')) {
if (typeof m[prop] === 'function' && m[prop].toString().includes('bHideMainWindowForPopouts:!0')) {
return m[prop];
}
}
});
interface ModalRootProps {
onMiddleButton?(): void,
onCancel?(): void;
onOK?(): void;
bAllowFullSize?: boolean;
}
export const ModalRoot = findModuleChild(m => {
if (typeof m !== "object") return undefined;
for (let prop in m) {
if (!m[prop]?.prototype?.OK && m[prop]?.prototype?.Cancel && m[prop]?.prototype?.render) {
return m[prop];
}
}
}) as FC<ModalRootProps>;

10
src/deck-components/Spinner.tsx Normal file → Executable file
View File

@@ -2,15 +2,7 @@ import { FC } from 'react';
import { IconsModule } from '../webpack';
// interface ButtonProps {
// label?: string;
// description?: string;
// layout?: 'below';
// onClick?(e: MouseEvent): void;
// disabled?: boolean;
// bottomSeparator?: boolean;
// }
// TODO type this and other icons?
export const Spinner = Object.values(IconsModule).find((mod: any) =>
mod?.toString && /Spinner\)}\),.\.createElement\(\"path\",{d:\"M18 /.test(mod.toString())
) as FC<{}>;

View File

@@ -0,0 +1,9 @@
import { FC } from 'react';
import { findModuleChild } from '../webpack';
export const SteamSpinner = findModuleChild((m) => {
if (typeof m !== "object") return undefined;
for (let prop in m) {
if (m[prop]?.toString()?.includes("Steam Spinner") && m[prop].toString().includes("PreloadThrobber")) return m[prop]
}
}) as FC<{}>;

1
src/deck-components/index.ts Normal file → Executable file
View File

@@ -4,6 +4,7 @@ export * from './Menu';
export * from './Modal';
export * from './Panel';
export * from './Slider';
export * from './SteamSpinner';
export * from './Spinner';
export * from './static-classes';
export * from './Toggle';