Compare commits

...

8 Commits

Author SHA1 Message Date
semantic-release-bot
2e52cca8a2 chore(release): 3.7.2 [CI SKIP] 2022-10-24 14:59:05 +00:00
AAGaming
3dbca1a056 fix(tabs): unkill build 2022-10-24 10:58:35 -04:00
semantic-release-bot
c6692138c6 chore(release): 3.7.1 [CI SKIP] 2022-10-24 05:01:13 +00:00
AAGaming
25c33b2a05 fix(Tabs): temp remove until we have a way to grab it on beta 2022-10-24 01:00:44 -04:00
semantic-release-bot
00d27d1373 chore(release): 3.7.0 [CI SKIP] 2022-10-24 00:22:31 +00:00
AAGaming
5f0470c351 feat(modal): support for latest steamos preview 2022-10-23 20:22:04 -04:00
semantic-release-bot
c77d6edaae chore(release): 3.6.1 [CI SKIP] 2022-10-19 19:57:14 +00:00
Lukas Senionis
c44c66facd fix(plugin): export RoutePatch (#39) 2022-10-19 15:44:13 -04:00
8 changed files with 123 additions and 78 deletions

View File

@@ -1,3 +1,31 @@
## [3.7.2](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.7.1...v3.7.2) (2022-10-24)
### Bug Fixes
* **tabs:** unkill build ([3dbca1a](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/3dbca1a0567592a597e70ce5e9bef157f709c765))
## [3.7.1](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.7.0...v3.7.1) (2022-10-24)
### Bug Fixes
* **Tabs:** temp remove until we have a way to grab it on beta ([25c33b2](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/25c33b2a05a30c3c72008c5f459c3b77f819db5a))
# [3.7.0](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.6.1...v3.7.0) (2022-10-24)
### Features
* **modal:** support for latest steamos preview ([5f0470c](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/5f0470c351dc4ecb24ea3e928ff0b0199c399fa4))
## [3.6.1](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.6.0...v3.6.1) (2022-10-19)
### Bug Fixes
* **plugin:** export RoutePatch ([#39](https://github.com/SteamDeckHomebrew/decky-frontend-lib/issues/39)) ([c44c66f](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/c44c66facd4e158aa4fe0a69f62a2ca3add805c1))
# [3.6.0](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.5.6...v3.6.0) (2022-10-15)

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "decky-frontend-lib",
"version": "3.6.0",
"version": "3.7.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "decky-frontend-lib",
"version": "3.6.0",
"version": "3.7.2",
"license": "LGPL-2.1",
"dependencies": {
"minimist": "^1.2.6"

View File

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

View File

@@ -1,4 +1,5 @@
import { FC, ReactNode } from 'react';
import { findSP } from '../utils';
import { findModuleChild } from '../webpack';
// All of the popout options + strTitle are related. Proper usage is not yet known...
@@ -27,7 +28,7 @@ export interface ShowModalResult {
Update: (modal: ReactNode) => void;
}
export const showModal: (modal: ReactNode, parent?: EventTarget, props?: ShowModalProps) => Promise<ShowModalResult> = findModuleChild((m) => {
const showModalRaw: (modal: ReactNode, parent?: EventTarget, props?: ShowModalProps) => Promise<ShowModalResult> = findModuleChild((m) => {
if (typeof m !== 'object') return undefined;
for (let prop in m) {
if (typeof m[prop] === 'function' && m[prop].toString().includes('bHideMainWindowForPopouts:!0')) {
@@ -36,6 +37,10 @@ export const showModal: (modal: ReactNode, parent?: EventTarget, props?: ShowMod
}
});
export const showModal = (modal: ReactNode, parent?: EventTarget, props?: ShowModalProps): Promise<ShowModalResult> => {
return showModalRaw(modal, parent || findSP(), props)
}
export interface ModalRootProps {
children?: ReactNode;
onCancel?(): void;

View File

@@ -1,74 +1,74 @@
import { FC, ReactNode } from 'react';
import { findModule } from '../webpack';
import { FooterLegendProps } from './FooterLegend';
// import { FC, ReactNode } from 'react';
// import { findModule } from '../webpack';
// import { FooterLegendProps } from './FooterLegend';
/**
* Individual tab objects for the Tabs component
*
* `id` ID of this tab, can be used with activeTab to auto-focus a given tab
* `title` Title shown in the header bar
* `renderTabAddon` Return a {@link ReactNode} to render it next to the tab title, i.e. the counts for each tab on the Media page
* `content` Content of the tab
* `footer` Sets up button handlers and labels
*/
export interface Tab {
id: string;
title: string;
renderTabAddon?: () => ReactNode;
content: ReactNode;
footer?: FooterLegendProps;
}
// /**
// * Individual tab objects for the Tabs component
// *
// * `id` ID of this tab, can be used with activeTab to auto-focus a given tab
// * `title` Title shown in the header bar
// * `renderTabAddon` Return a {@link ReactNode} to render it next to the tab title, i.e. the counts for each tab on the Media page
// * `content` Content of the tab
// * `footer` Sets up button handlers and labels
// */
// export interface Tab {
// id: string;
// title: string;
// renderTabAddon?: () => ReactNode;
// content: ReactNode;
// footer?: FooterLegendProps;
// }
/**
* Props for the {@link Tabs}
*
* `tabs` array of {@link Tab}
* `activeTab` tab currently active, needs to be one of the tabs {@link Tab.id}, must be set using a `useState` in the `onShowTab` handler
* `onShowTab` Called when the active tab should change, needs to set `activeTab`. See example.
* `autoFocusContents` Whether to automatically focus the tab contents or not.
* `footer` Sets up button handlers and labels
*
* @example
* const Component: FC = () => {
* const [currentTab, setCurrentTab] = useState<string>("Tab1");
*
* return (
* <Tabs
* title="Theme Manager"
* activeTab={currentTabRoute}
* onShowTab={(tabID: string) => {
* setCurrentTabRoute(tabID);
* }}
* tabs={[
* {
* title: "Tab 1",
* content: <Tab1Component />,
* id: "Tab1",
* },
* {
* title: "Tab 2",
* content: <Tab2Component />,
* id: "Tab2",
* },
* ]}
* />
* );
* };
*/
export interface TabsProps {
tabs: Tab[];
activeTab: string;
onShowTab: (tab: string) => void;
autoFocusContents?: boolean;
}
// /**
// * Props for the {@link Tabs}
// *
// * `tabs` array of {@link Tab}
// * `activeTab` tab currently active, needs to be one of the tabs {@link Tab.id}, must be set using a `useState` in the `onShowTab` handler
// * `onShowTab` Called when the active tab should change, needs to set `activeTab`. See example.
// * `autoFocusContents` Whether to automatically focus the tab contents or not.
// * `footer` Sets up button handlers and labels
// *
// * @example
// * const Component: FC = () => {
// * const [currentTab, setCurrentTab] = useState<string>("Tab1");
// *
// * return (
// * <Tabs
// * title="Theme Manager"
// * activeTab={currentTabRoute}
// * onShowTab={(tabID: string) => {
// * setCurrentTabRoute(tabID);
// * }}
// * tabs={[
// * {
// * title: "Tab 1",
// * content: <Tab1Component />,
// * id: "Tab1",
// * },
// * {
// * title: "Tab 2",
// * content: <Tab2Component />,
// * id: "Tab2",
// * },
// * ]}
// * />
// * );
// * };
// */
// export interface TabsProps {
// tabs: Tab[];
// activeTab: string;
// onShowTab: (tab: string) => void;
// autoFocusContents?: boolean;
// }
/**
* Tabs component as used in the library and media tabs. See {@link TabsProps}
*/
export const Tabs = Object.values(findModule((m) => {
if (typeof m !== 'object') return false;
for (let prop in m) {
if (m[prop]?.Unbleed) return true;
}
return false;
})).find((x: any) => x?.type?.toString()?.includes("((function(){")) as FC<TabsProps>;
// /**
// * Tabs component as used in the library and media tabs. See {@link TabsProps}
// */
// export const Tabs = Object.values(findModule((m) => {
// if (typeof m !== 'object') return false;
// for (let prop in m) {
// if (m[prop]?.Unbleed) return true;
// }
// return false;
// })).find((x: any) => x?.type?.toString()?.includes("((function(") && x?.type?.toString()?.includes("[\"tabs\"")) as FC<TabsProps>;

View File

@@ -17,7 +17,7 @@ export * from './SliderField';
export * from './Spinner';
export * from './static-classes';
export * from './SteamSpinner';
export * from './Tabs';
//export * from './Tabs';
export * from './TextField';
export * from './Toggle';
export * from './ToggleField';

View File

@@ -21,7 +21,7 @@ interface ServerResponseError {
export type ServerResponse<TRes> = ServerResponseSuccess<TRes> | ServerResponseError;
type RoutePatch = (route: RouteProps) => RouteProps;
export type RoutePatch = (route: RouteProps) => RouteProps;
export interface RouterHook {
addRoute(path: string, component: ComponentType, props?: Omit<RouteProps, 'path' | 'children'>): void;

View File

@@ -7,4 +7,16 @@ export function joinClassNames(...classes: string[]): string {
export function sleep(ms: number) {
return new Promise(res => setTimeout(res, ms));
}
}
/**
* Finds the SP window, since it is a render target as of {10-19-2022}'s beta
*/
export function findSP(): Window {
// old (SP as host)
if (document.title == 'SP') return window;
// new (SP as popup)
return FocusNavController.m_ActiveContext.m_rgGamepadNavigationTrees.find((x: any) => x.m_ID == 'root_1_').Root
.Element.ownerDocument.defaultView;
}