diff options
| author | AAGaming <aagaming@riseup.net> | 2024-08-05 14:07:10 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-05 14:07:10 -0400 |
| commit | 131f0961ff451ec47376483178e092c8d7403b27 (patch) | |
| tree | 4d2ea34e8220e14c4b820cc1ad38face7193f6fe /frontend/src/index.ts | |
| parent | 75aa1e4851445646994ba3a61ff41325403359fb (diff) | |
| download | decky-loader-131f0961ff451ec47376483178e092c8d7403b27.tar.gz decky-loader-131f0961ff451ec47376483178e092c8d7403b27.zip | |
Rewrite router/tabs/toaster hooks (#661)
Diffstat (limited to 'frontend/src/index.ts')
| -rw-r--r-- | frontend/src/index.ts | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/frontend/src/index.ts b/frontend/src/index.ts index 4ea22318..029a731c 100644 --- a/frontend/src/index.ts +++ b/frontend/src/index.ts @@ -5,13 +5,26 @@ interface Window { } (async () => { - // Wait for react to definitely be loaded - while (!window.webpackChunksteamui || window.webpackChunksteamui <= 3) { + // Wait for main webpack chunks to definitely be loaded + console.time('[Decky:Boot] Waiting for main Webpack chunks...'); + while (!window.webpackChunksteamui || window.webpackChunksteamui.length < 8) { await new Promise((r) => setTimeout(r, 10)); // Can't use DFL sleep here. } + console.timeEnd('[Decky:Boot] Waiting for main Webpack chunks...'); + + // Wait for the React root to be mounted + console.time('[Decky:Boot] Waiting for React root mount...'); + let root; + while ( + !(root = document.getElementById('root')) || + !(root as any)[Object.keys(root).find((k) => k.startsWith('__reactContainer$')) as string] + ) { + await new Promise((r) => setTimeout(r, 10)); // Can't use DFL sleep here. + } + console.timeEnd('[Decky:Boot] Waiting for React root mount...'); if (!window.SP_REACT) { - console.debug('[Decky:Boot] Setting up React globals...'); + console.debug('[Decky:Boot] Setting up Webpack & React globals...'); // deliberate partial import const DFLWebpack = await import('@decky/ui/dist/webpack'); window.SP_REACT = DFLWebpack.findModule((m) => m.Component && m.PureComponent && m.useLayoutEffect); |
