Compare commits

...

5 Commits

Author SHA1 Message Date
semantic-release-bot
4cdcca0b5a chore(release): 3.7.4 [CI SKIP] 2022-10-26 00:16:38 +00:00
AAGaming
f16e0b29f8 fix(tabs): fix on stable 2022-10-25 20:16:06 -04:00
AAGaming
37a6658b95 chore(docs): how did i manage to do this 2022-10-24 20:45:01 -04:00
AAGaming
ed0b92de2e fix(docs): change arg format 2022-10-24 20:43:53 -04:00
AAGaming
dcba5c22f8 chore(docs): fix it 2022-10-24 20:42:47 -04:00
5 changed files with 66 additions and 41 deletions

View File

@@ -29,12 +29,13 @@ jobs:
- name: Setup | Dependencies
run: |
cd lib
npm ci
npm i -g pnpm
pnpm i --frozen-lockfile
- name: Build Docs
run: |
cd lib
npm run docs -- --out ../wiki/api-docs/decky-frontend-lib
pnpm run docs --out ../wiki/api-docs/decky-frontend-lib
- name: Commit files
run: |

View File

@@ -1,3 +1,11 @@
## [3.7.4](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.7.3...v3.7.4) (2022-10-26)
### Bug Fixes
* **docs:** change arg format ([ed0b92d](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/ed0b92de2ec13a585f6524b45eef0ab538d87448))
* **tabs:** fix on stable ([f16e0b2](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/f16e0b29f8e1de500e8f436db659d1ad99d4eaa6))
## [3.7.3](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v3.7.2...v3.7.3) (2022-10-25)

View File

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

View File

@@ -1,6 +1,7 @@
import { createElement, FC, ReactNode, useEffect, useState } from 'react';
import { FC, ReactNode, createElement, useEffect, useState } from 'react';
import { fakeRenderComponent, findInReactTree, sleep } from '../utils';
import { findModule } from '../webpack';
import { FooterLegendProps } from './FooterLegend';
import { SteamSpinner } from './SteamSpinner';
@@ -73,47 +74,62 @@ declare global {
let tabsComponent: any;
const getTabs = async () => {
if (tabsComponent) return tabsComponent
while (!window?.DeckyPluginLoader?.routerHook?.routes) {
console.debug("[DFL:Tabs]: Waiting for Decky router...")
await sleep(500);
if (tabsComponent) return tabsComponent;
while (!window?.DeckyPluginLoader?.routerHook?.routes) {
console.debug('[DFL:Tabs]: Waiting for Decky router...');
await sleep(500);
}
return (tabsComponent = fakeRenderComponent(
() => {
return findInReactTree(
findInReactTree(
window.DeckyPluginLoader.routerHook.routes
.find((x: any) => x.props.path == '/library/app/:appid/achievements')
.props.children.type(),
(x) => x?.props?.scrollTabsTop,
).type({ appid: 1 }),
(x) => x?.props?.tabs,
).type;
},
{
useRef: () => ({ current: { reaction: { track: () => {} } } }),
useContext: () => ({ match: { params: { appid: 1 } } }),
useMemo: () => ({ data: {} }),
},
));
};
let oldTabs: any;
try {
const oldTabsModule = findModule((m: any) => {
if (typeof m !== 'object') return false;
for (let prop in m) {
if (m[prop]?.Unbleed) return true;
}
return tabsComponent = fakeRenderComponent(
() => {
return findInReactTree(
findInReactTree(
window.DeckyPluginLoader.routerHook.routes
.find((x: any) => x.props.path == '/library/app/:appid/achievements')
.props.children.type(),
(x) => x?.props?.scrollTabsTop,
).type({ appid: 1 }),
(x) => x?.props?.tabs,
).type;
},
{
useRef: () => ({ current: { reaction: { track: () => {} } } }),
useContext: () => ({ match: { params: { appid: 1 } } }),
useMemo: () => ({ data: {} }),
},
);
return false;
});
if (oldTabsModule) oldTabs = Object.values(oldTabsModule).find((x: any) => x?.type?.toString()?.includes("((function(") && x?.type?.toString()?.includes("[\"tabs\""));
} catch (e) {
console.error("Error finding oldTabs:", e)
}
/**
* 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 = ((props: TabsProps) => {
const found = tabsComponent;
const [tc, setTC] = useState<FC<TabsProps>>(found);
useEffect(() => {
if (found) return;
(async()=> {
console.debug("[DFL:Tabs]: Finding component...")
const t = await getTabs();
console.debug("[DFL:Tabs]: Found!")
setTC(t);
})();
}, [])
console.log("tc", tc);
return tc ? createElement(tc, props) : <SteamSpinner/>;
export const Tabs = oldTabs || ((props: TabsProps) => {
const found = tabsComponent;
const [tc, setTC] = useState<FC<TabsProps>>(found);
useEffect(() => {
if (found) return;
(async () => {
console.debug('[DFL:Tabs]: Finding component...');
const t = await getTabs();
console.debug('[DFL:Tabs]: Found!');
setTC(t);
})();
}, []);
console.log('tc', tc);
return tc ? createElement(tc, props) : <SteamSpinner />;
}) as FC<TabsProps>;

View File

@@ -10,7 +10,7 @@ export function sleep(ms: number) {
}
/**
* Finds the SP window, since it is a render target as of {10-19-2022}'s beta
* 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)