mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 18:12:00 +00:00
Initial implementation of global DFL instance (#451)
This commit is contained in:
@@ -11,7 +11,7 @@ import externalGlobals from 'rollup-plugin-external-globals';
|
|||||||
const hiddenWarnings = ['THIS_IS_UNDEFINED', 'EVAL'];
|
const hiddenWarnings = ['THIS_IS_UNDEFINED', 'EVAL'];
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
input: 'src/index.tsx',
|
input: 'src/index.ts',
|
||||||
plugins: [
|
plugins: [
|
||||||
del({ targets: '../backend/static/*', force: true }),
|
del({ targets: '../backend/static/*', force: true }),
|
||||||
commonjs(),
|
commonjs(),
|
||||||
|
|||||||
@@ -1,23 +1,4 @@
|
|||||||
import {
|
import { findModuleChild, sleep } from 'decky-frontend-lib';
|
||||||
Navigation,
|
|
||||||
ReactRouter,
|
|
||||||
Router,
|
|
||||||
fakeRenderComponent,
|
|
||||||
findInReactTree,
|
|
||||||
findInTree,
|
|
||||||
findModule,
|
|
||||||
findModuleChild,
|
|
||||||
gamepadDialogClasses,
|
|
||||||
gamepadSliderClasses,
|
|
||||||
playSectionClasses,
|
|
||||||
quickAccessControlsClasses,
|
|
||||||
quickAccessMenuClasses,
|
|
||||||
scrollClasses,
|
|
||||||
scrollPanelClasses,
|
|
||||||
sleep,
|
|
||||||
staticClasses,
|
|
||||||
updaterFieldClasses,
|
|
||||||
} from 'decky-frontend-lib';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { FaReact } from 'react-icons/fa';
|
import { FaReact } from 'react-icons/fa';
|
||||||
|
|
||||||
@@ -80,29 +61,4 @@ export async function startup() {
|
|||||||
|
|
||||||
if ((isRDTEnabled && !window.deckyHasConnectedRDT) || (!isRDTEnabled && window.deckyHasConnectedRDT))
|
if ((isRDTEnabled && !window.deckyHasConnectedRDT) || (!isRDTEnabled && window.deckyHasConnectedRDT))
|
||||||
setShouldConnectToReactDevTools(isRDTEnabled);
|
setShouldConnectToReactDevTools(isRDTEnabled);
|
||||||
|
|
||||||
logger.log('Exposing decky-frontend-lib APIs as DFL');
|
|
||||||
window.DFL = {
|
|
||||||
findModuleChild,
|
|
||||||
findModule,
|
|
||||||
Navigation,
|
|
||||||
Router,
|
|
||||||
ReactRouter,
|
|
||||||
ReactUtils: {
|
|
||||||
fakeRenderComponent,
|
|
||||||
findInReactTree,
|
|
||||||
findInTree,
|
|
||||||
},
|
|
||||||
classes: {
|
|
||||||
scrollClasses,
|
|
||||||
staticClasses,
|
|
||||||
playSectionClasses,
|
|
||||||
scrollPanelClasses,
|
|
||||||
updaterFieldClasses,
|
|
||||||
gamepadDialogClasses,
|
|
||||||
gamepadSliderClasses,
|
|
||||||
quickAccessMenuClasses,
|
|
||||||
quickAccessControlsClasses,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// Sets up DFL, then loads start.ts which starts up the loader
|
||||||
|
(async () => {
|
||||||
|
console.debug('Setting up decky-frontend-lib...');
|
||||||
|
window.DFL = await import('decky-frontend-lib');
|
||||||
|
await import('./start');
|
||||||
|
})();
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import { Navigation, Router, sleep } from 'decky-frontend-lib';
|
|
||||||
import i18n from 'i18next';
|
import i18n from 'i18next';
|
||||||
import Backend from 'i18next-http-backend';
|
import Backend from 'i18next-http-backend';
|
||||||
import { initReactI18next } from 'react-i18next';
|
import { initReactI18next } from 'react-i18next';
|
||||||
@@ -19,23 +18,6 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
if (!Router.NavigateToAppProperties || !Router.NavigateToLibraryTab || !Router.NavigateToInvites) {
|
|
||||||
while (!Navigation.NavigateToAppProperties) await sleep(100);
|
|
||||||
const shims = {
|
|
||||||
NavigateToAppProperties: Navigation.NavigateToAppProperties,
|
|
||||||
NavigateToInvites: Navigation.NavigateToInvites,
|
|
||||||
NavigateToLibraryTab: Navigation.NavigateToLibraryTab,
|
|
||||||
};
|
|
||||||
(Router as unknown as any).deckyShim = true;
|
|
||||||
Object.assign(Router, shims);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error('[DECKY]: Error initializing Navigation interface shims', e);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
window.deckyAuthToken = await fetch('http://127.0.0.1:1337/auth/token').then((r) => r.text());
|
window.deckyAuthToken = await fetch('http://127.0.0.1:1337/auth/token').then((r) => r.text());
|
||||||
|
|
||||||
Reference in New Issue
Block a user