summaryrefslogtreecommitdiff
path: root/frontend/src/index.tsx
diff options
context:
space:
mode:
authorAAGaming <aa@mail.catvibers.me>2023-05-12 02:02:04 +0000
committerGitHub <noreply@github.com>2023-05-11 22:02:04 -0400
commitd99f332523c1e70df8ed1f0d024cc6dd77607433 (patch)
tree3ef4eef72996abb2fc15dcfbee2ece3f6968dcfd /frontend/src/index.tsx
parent0c83c9a2b507567fd49803f1df3f7d9c013c971c (diff)
downloaddecky-loader-d99f332523c1e70df8ed1f0d024cc6dd77607433.tar.gz
decky-loader-d99f332523c1e70df8ed1f0d024cc6dd77607433.zip
Initial implementation of global DFL instance (#451)v2.9.0-pre1
Diffstat (limited to 'frontend/src/index.tsx')
-rw-r--r--frontend/src/index.tsx95
1 files changed, 0 insertions, 95 deletions
diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx
deleted file mode 100644
index b9edc0b1..00000000
--- a/frontend/src/index.tsx
+++ /dev/null
@@ -1,95 +0,0 @@
-import { Navigation, Router, sleep } from 'decky-frontend-lib';
-import i18n from 'i18next';
-import Backend from 'i18next-http-backend';
-import { initReactI18next } from 'react-i18next';
-
-import PluginLoader from './plugin-loader';
-import { DeckyUpdater } from './updater';
-
-declare global {
- interface Window {
- DeckyPluginLoader: PluginLoader;
- DeckyUpdater?: DeckyUpdater;
- importDeckyPlugin: Function;
- syncDeckyPlugins: Function;
- deckyHasLoaded: boolean;
- deckyHasConnectedRDT?: boolean;
- deckyAuthToken: string;
- DFL?: any;
- }
-}
-
-(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 () => {
- window.deckyAuthToken = await fetch('http://127.0.0.1:1337/auth/token').then((r) => r.text());
-
- i18n
- .use(Backend)
- .use(initReactI18next)
- .init({
- load: 'currentOnly',
- detection: {
- order: ['querystring', 'navigator'],
- lookupQuerystring: 'lng',
- },
- //debug: true,
- lng: navigator.language,
- fallbackLng: 'en-US',
- interpolation: {
- escapeValue: true,
- },
- returnEmptyString: false,
- backend: {
- loadPath: 'http://127.0.0.1:1337/locales/{{lng}}.json',
- customHeaders: {
- Authentication: window.deckyAuthToken,
- },
- requestOptions: {
- credentials: 'include',
- },
- },
- });
-
- window.DeckyPluginLoader?.dismountAll();
- window.DeckyPluginLoader?.deinit();
- window.DeckyPluginLoader = new PluginLoader();
- window.DeckyPluginLoader.init();
- window.importDeckyPlugin = function (name: string, version: string) {
- window.DeckyPluginLoader?.importPlugin(name, version);
- };
-
- window.syncDeckyPlugins = async function () {
- const plugins = await (
- await fetch('http://127.0.0.1:1337/plugins', {
- credentials: 'include',
- headers: { Authentication: window.deckyAuthToken },
- })
- ).json();
- for (const plugin of plugins) {
- if (!window.DeckyPluginLoader.hasPlugin(plugin.name))
- window.DeckyPluginLoader?.importPlugin(plugin.name, plugin.version);
- }
-
- window.DeckyPluginLoader.checkPluginUpdates();
- };
-
- setTimeout(() => window.syncDeckyPlugins(), 5000);
-})();
-
-export default i18n;