mirror of
https://github.com/SteamDeckHomebrew/decky-frontend-lib.git
synced 2026-06-05 17:16:55 +02:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93c59d8026 | ||
|
|
0f9fb5a3b8 | ||
|
|
8c6043b5a7 | ||
|
|
3aa07dc9ce | ||
|
|
3f335b3583 | ||
|
|
4c97097757 | ||
|
|
1ee43e86d6 | ||
|
|
db6ab9c448 |
2
.github/workflows/release.yaml
vendored
2
.github/workflows/release.yaml
vendored
@@ -4,7 +4,7 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- v4-dev
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
|
|||||||
21
CHANGELOG.md
21
CHANGELOG.md
@@ -1,3 +1,24 @@
|
|||||||
|
## [4.7.3](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v4.7.2...v4.7.3) (2024-10-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **components:** fix missing components on oct 2 2024 beta ([0f9fb5a](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/0f9fb5a3b8ef4f9978025a28323ab080fb0e7a4c))
|
||||||
|
|
||||||
|
## [4.7.2](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v4.7.1...v4.7.2) (2024-09-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **utils:** fix potential race condition in findSP ([3aa07dc](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/3aa07dc9ce798ff8d1148424ee9e8a8bf2ba78c6))
|
||||||
|
|
||||||
|
## [4.7.1](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v4.7.0...v4.7.1) (2024-08-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **utils/react:** fix potential race condition in injectFCTrampoline ([4c97097](https://github.com/SteamDeckHomebrew/decky-frontend-lib/commit/4c97097757919580a380b70785e6c161de6b03cc))
|
||||||
|
|
||||||
# [4.7.0](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v4.6.0...v4.7.0) (2024-07-28)
|
# [4.7.0](https://github.com/SteamDeckHomebrew/decky-frontend-lib/compare/v4.6.0...v4.7.0) (2024-07-28)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@decky/ui",
|
"name": "@decky/ui",
|
||||||
"version": "4.7.0",
|
"version": "4.7.3",
|
||||||
"description": "A library for interacting with the Steam frontend in Decky plugins and elsewhere.",
|
"description": "A library for interacting with the Steam frontend in Decky plugins and elsewhere.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -28,9 +28,12 @@ export const DialogCheckbox = Object.values(
|
|||||||
}),
|
}),
|
||||||
).find(
|
).find(
|
||||||
(m: any) =>
|
(m: any) =>
|
||||||
m.contextType &&
|
|
||||||
m.prototype?.render.toString().includes('fallback:') &&
|
|
||||||
m?.prototype?.SetChecked &&
|
m?.prototype?.SetChecked &&
|
||||||
m?.prototype?.Toggle &&
|
m?.prototype?.Toggle &&
|
||||||
m?.prototype?.GetPanelElementProps,
|
m?.prototype?.GetPanelElementProps &&
|
||||||
|
// beta || stable as of oct 2 2024
|
||||||
|
(m?.prototype?.render?.toString().includes('="DialogCheckbox"') || (
|
||||||
|
m.contextType &&
|
||||||
|
m.prototype?.render.toString().includes('fallback:')
|
||||||
|
))
|
||||||
) as FC<DialogCheckboxProps>;
|
) as FC<DialogCheckboxProps>;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { FC, ReactNode } from 'react';
|
import { FC, ReactNode } from 'react';
|
||||||
|
|
||||||
import { findSP } from '../utils';
|
import { findSP } from '../utils';
|
||||||
import { Export, findModule, findModuleByExport, findModuleExport } from '../webpack';
|
import { Export, findModule, findModuleDetailsByExport, findModuleExport } from '../webpack';
|
||||||
|
|
||||||
// All of the popout options + strTitle are related. Proper usage is not yet known...
|
// All of the popout options + strTitle are related. Proper usage is not yet known...
|
||||||
export interface ShowModalProps {
|
export interface ShowModalProps {
|
||||||
@@ -105,7 +105,7 @@ interface SimpleModalProps {
|
|||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ModalModule = findModuleByExport((e: Export) => e?.toString().includes('.ModalPosition,fallback:'), 5);
|
const [ModalModule, _ModalPosition] = findModuleDetailsByExport((e: Export) => e?.toString().includes('.ModalPosition'), 5)
|
||||||
|
|
||||||
const ModalModuleProps = ModalModule ? Object.values(ModalModule) : [];
|
const ModalModuleProps = ModalModule ? Object.values(ModalModule) : [];
|
||||||
|
|
||||||
@@ -114,6 +114,4 @@ export const SimpleModal = ModalModuleProps.find((prop) => {
|
|||||||
return string?.includes('.ShowPortalModal()') && string?.includes('.OnElementReadyCallbacks.Register(');
|
return string?.includes('.ShowPortalModal()') && string?.includes('.OnElementReadyCallbacks.Register(');
|
||||||
}) as FC<SimpleModalProps>;
|
}) as FC<SimpleModalProps>;
|
||||||
|
|
||||||
export const ModalPosition = ModalModuleProps.find((prop) =>
|
export const ModalPosition = _ModalPosition as FC<SimpleModalProps>;
|
||||||
prop?.toString().includes('.ModalPosition,fallback:'),
|
|
||||||
) as FC<SimpleModalProps>;
|
|
||||||
|
|||||||
@@ -29,5 +29,6 @@ export interface SliderFieldProps extends ItemProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const SliderField = Object.values(CommonUIModule).find((mod: any) =>
|
export const SliderField = Object.values(CommonUIModule).find((mod: any) =>
|
||||||
mod?.toString()?.includes('SliderField,fallback'),
|
// stable || beta as of oct 2 2024
|
||||||
|
mod?.toString()?.includes('SliderField,fallback') || mod?.toString()?.includes("SliderField\",")
|
||||||
) as FC<SliderFieldProps>;
|
) as FC<SliderFieldProps>;
|
||||||
|
|||||||
@@ -11,5 +11,6 @@ export interface ToggleFieldProps extends ItemProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const ToggleField = Object.values(CommonUIModule).find((mod: any) =>
|
export const ToggleField = Object.values(CommonUIModule).find((mod: any) =>
|
||||||
mod?.render?.toString()?.includes('ToggleField,fallback'),
|
// stable || beta as of oct 2 2024
|
||||||
|
mod?.render?.toString()?.includes('ToggleField,fallback') || mod?.render?.toString()?.includes("ToggleField\",")
|
||||||
) as FC<ToggleFieldProps>;
|
) as FC<ToggleFieldProps>;
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ export interface Navigation {
|
|||||||
OpenQuickAccessMenu(quickAccessTab?: QuickAccessTab): void;
|
OpenQuickAccessMenu(quickAccessTab?: QuickAccessTab): void;
|
||||||
OpenMainMenu(): void;
|
OpenMainMenu(): void;
|
||||||
OpenPowerMenu(unknown?: any): void;
|
OpenPowerMenu(unknown?: any): void;
|
||||||
|
/** if calling this to perform navigation, call it after Navigate to prevent a race condition in desktop Big Picture mode that hides the overlay unintentionally */
|
||||||
CloseSideMenus(): void;
|
CloseSideMenus(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export function findSP(): Window {
|
|||||||
if (document.title == 'SP') return window;
|
if (document.title == 'SP') return window;
|
||||||
// new (SP as popup)
|
// new (SP as popup)
|
||||||
const navTrees = getGamepadNavigationTrees();
|
const navTrees = getGamepadNavigationTrees();
|
||||||
return navTrees?.find((x: any) => x.m_ID == 'root_1_').Root.Element.ownerDocument.defaultView;
|
return navTrees?.find((x: any) => x.m_ID == 'root_1_')?.Root?.Element?.ownerDocument?.defaultView;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,6 +40,6 @@ export function getFocusNavController(): any {
|
|||||||
*/
|
*/
|
||||||
export function getGamepadNavigationTrees(): any {
|
export function getGamepadNavigationTrees(): any {
|
||||||
const focusNav = getFocusNavController();
|
const focusNav = getFocusNavController();
|
||||||
const context = focusNav.m_ActiveContext || focusNav.m_LastActiveContext;
|
const context = focusNav?.m_ActiveContext || focusNav?.m_LastActiveContext;
|
||||||
return context?.m_rgGamepadNavigationTrees;
|
return context?.m_rgGamepadNavigationTrees;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export function injectFCTrampoline(component: FC, customHooks?: any): FCTrampoli
|
|||||||
// we have to redirect this to return an object with component's prototype as a constructor returning a value overrides its prototype
|
// we have to redirect this to return an object with component's prototype as a constructor returning a value overrides its prototype
|
||||||
window.SP_REACT.createElement = () => {
|
window.SP_REACT.createElement = () => {
|
||||||
loggingEnabled && logger.debug("createElement hook called");
|
loggingEnabled && logger.debug("createElement hook called");
|
||||||
|
loggingEnabled && console.trace("createElement trace");
|
||||||
return Object.create(component.prototype);
|
return Object.create(component.prototype);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -66,12 +67,16 @@ export function injectFCTrampoline(component: FC, customHooks?: any): FCTrampoli
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let renderHookStep = 0;
|
||||||
|
|
||||||
// Accessed two times, once directly before class instantiation, and again in some extra logic we don't need to worry about that we hanlde below just in case.
|
// Accessed two times, once directly before class instantiation, and again in some extra logic we don't need to worry about that we hanlde below just in case.
|
||||||
Object.defineProperty(component, "contextType", {
|
Object.defineProperty(component, "contextType", {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
get: function () {
|
get: function () {
|
||||||
loggingEnabled && logger.debug("get contexttype", this, stubsApplied);
|
loggingEnabled && logger.debug("get contexttype", this, stubsApplied, renderHookStep);
|
||||||
applyStubsIfNeeded();
|
loggingEnabled && console.trace("contextType trace");
|
||||||
|
if (renderHookStep == 0) renderHookStep = 1;
|
||||||
|
else if (renderHookStep == 3) renderHookStep = 4;
|
||||||
return this._contextType;
|
return this._contextType;
|
||||||
},
|
},
|
||||||
set: function (value) {
|
set: function (value) {
|
||||||
@@ -79,16 +84,20 @@ export function injectFCTrampoline(component: FC, customHooks?: any): FCTrampoli
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Undoes the second contextType access we can't detect shortly before render before it's able to cause any damage
|
// Always accessed directly after contextType for the path we want to catch.
|
||||||
Object.defineProperty(component, "getDerivedStateFromProps", {
|
Object.defineProperty(component, "contextTypes", {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
get: function () {
|
get: function () {
|
||||||
loggingEnabled && logger.debug("get getDerivedStateFromProps", this, stubsApplied);
|
loggingEnabled && logger.debug("get contexttypes", this, stubsApplied, renderHookStep);
|
||||||
removeStubsIfNeeded();
|
loggingEnabled && console.trace("contextTypes trace");
|
||||||
return this._getDerivedStateFromProps;
|
if (renderHookStep == 1) {
|
||||||
|
renderHookStep = 2;
|
||||||
|
applyStubsIfNeeded();
|
||||||
|
};
|
||||||
|
return this._contextTypes;
|
||||||
},
|
},
|
||||||
set: function (value) {
|
set: function (value) {
|
||||||
this._getDerivedStateFromProps = value;
|
this._contextTypes = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -99,11 +108,32 @@ export function injectFCTrampoline(component: FC, customHooks?: any): FCTrampoli
|
|||||||
return this._updater;
|
return this._updater;
|
||||||
},
|
},
|
||||||
set: function (value) {
|
set: function (value) {
|
||||||
loggingEnabled && logger.debug("set updater", this, value, stubsApplied);
|
loggingEnabled && logger.debug("set updater", this, value, stubsApplied, renderHookStep);
|
||||||
removeStubsIfNeeded();
|
loggingEnabled && console.trace("updater trace");
|
||||||
|
if (renderHookStep == 2) {
|
||||||
|
renderHookStep = 0;
|
||||||
|
removeStubsIfNeeded();
|
||||||
|
}
|
||||||
return this._updater = value;
|
return this._updater = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Prevents the second contextType+contextTypes access from leaving its hooks around
|
||||||
|
Object.defineProperty(component, "getDerivedStateFromProps", {
|
||||||
|
configurable: true,
|
||||||
|
get: function () {
|
||||||
|
loggingEnabled && logger.debug("get getDerivedStateFromProps", this, stubsApplied, renderHookStep);
|
||||||
|
loggingEnabled && console.trace("getDerivedStateFromProps trace");
|
||||||
|
if (renderHookStep == 2) {
|
||||||
|
renderHookStep = 0;
|
||||||
|
removeStubsIfNeeded();
|
||||||
|
}
|
||||||
|
return this._getDerivedStateFromProps;
|
||||||
|
},
|
||||||
|
set: function (value) {
|
||||||
|
this._getDerivedStateFromProps = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return userComponent;
|
return userComponent;
|
||||||
}
|
}
|
||||||
@@ -104,19 +104,15 @@ export function wrapReactClass(node: any, prop: any = 'type') {
|
|||||||
|
|
||||||
export function getReactRoot(o: HTMLElement | Element | Node) {
|
export function getReactRoot(o: HTMLElement | Element | Node) {
|
||||||
return (
|
return (
|
||||||
// @ts-expect-error 7053
|
(o as any)[Object.keys(o).find((k) => k.startsWith('__reactContainer$')) as string] ||
|
||||||
o[Object.keys(o).find((k) => k.startsWith('__reactContainer$')) as string] ||
|
(o as any)['_reactRootContainer']?._internalRoot?.current
|
||||||
// @ts-expect-error 7053
|
|
||||||
o['_reactRootContainer']?._internalRoot?.current
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getReactInstance(o: HTMLElement | Element | Node) {
|
export function getReactInstance(o: HTMLElement | Element | Node) {
|
||||||
return (
|
return (
|
||||||
// @ts-expect-error 7053
|
(o as any)[Object.keys(o).find((k) => k.startsWith('__reactFiber')) as string] ||
|
||||||
o[Object.keys(o).find((k) => k.startsWith('__reactFiber')) as string] ||
|
(o as any)[Object.keys(o).find((k) => k.startsWith('__reactInternalInstance')) as string]
|
||||||
// @ts-expect-error 7053
|
|
||||||
o[Object.keys(o).find((k) => k.startsWith('__reactInternalInstance')) as string]
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user