mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-11-17 12:03:10 -05:00
Delete old front routing
This commit is contained in:
parent
9bc30ab62d
commit
ebaf6d2177
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { DownloadPage } from "@kyoo/ui";
|
||||
|
||||
export default DownloadPage;
|
||||
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { HomePage } from "@kyoo/ui";
|
||||
import { withRoute } from "../../utils";
|
||||
|
||||
export default withRoute(HomePage, {
|
||||
options: { headerTransparent: true, headerStyle: { backgroundColor: "transparent" } },
|
||||
statusBar: { barStyle: "light-content" },
|
||||
});
|
||||
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { AdminPage } from "@kyoo/ui";
|
||||
|
||||
export default AdminPage;
|
||||
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { CollectionPage } from "@kyoo/ui";
|
||||
import { withRoute } from "../../../utils";
|
||||
|
||||
export default withRoute(CollectionPage, {
|
||||
options: { headerTransparent: true, headerStyle: { backgroundColor: "transparent" } },
|
||||
statusBar: { barStyle: "light-content" },
|
||||
});
|
||||
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { MovieDetails } from "@kyoo/ui";
|
||||
import { withRoute } from "../../../utils";
|
||||
|
||||
export default withRoute(MovieDetails, {
|
||||
options: { headerTransparent: true, headerStyle: { backgroundColor: "transparent" } },
|
||||
statusBar: { barStyle: "light-content" },
|
||||
});
|
||||
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Player } from "@kyoo/ui";
|
||||
import { withRoute } from "../../../utils";
|
||||
|
||||
export default withRoute(
|
||||
Player,
|
||||
{
|
||||
options: {
|
||||
headerShown: false,
|
||||
navigationBarHidden: true,
|
||||
},
|
||||
statusBar: { hidden: true },
|
||||
fullscreen: true,
|
||||
},
|
||||
{ type: "movie" },
|
||||
);
|
||||
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { SearchPage } from "@kyoo/ui";
|
||||
import { Stack, useLocalSearchParams } from "expo-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { createParam } from "solito";
|
||||
import { useRouter } from "solito/router";
|
||||
import { useTheme } from "yoshiki/native";
|
||||
|
||||
const { useParam } = createParam<{ q?: string }>();
|
||||
|
||||
const Search = () => {
|
||||
const theme = useTheme();
|
||||
const { back } = useRouter();
|
||||
const { t } = useTranslation();
|
||||
const [query, setQuery] = useParam("q");
|
||||
const routeParams = useLocalSearchParams();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerTitle: () => null,
|
||||
// TODO: this shouuld not be null but since the header right is on the left of the search bar. shrug
|
||||
headerRight: () => null,
|
||||
headerSearchBarOptions: {
|
||||
autoFocus: true,
|
||||
headerIconColor: theme.colors.white,
|
||||
hintTextColor: theme.light.overlay1,
|
||||
textColor: theme.paragraph,
|
||||
placeholder: t("navbar.search")!,
|
||||
onClose: () => back(),
|
||||
onChangeText: (e) => setQuery(e.nativeEvent.text),
|
||||
},
|
||||
}}
|
||||
/>
|
||||
<SearchPage {...routeParams} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Search;
|
||||
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { SettingsPage } from "@kyoo/ui";
|
||||
|
||||
export default SettingsPage;
|
||||
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ShowDetails } from "@kyoo/ui";
|
||||
import { withRoute } from "../../utils";
|
||||
|
||||
export default withRoute(ShowDetails, {
|
||||
options: { headerTransparent: true, headerStyle: { backgroundColor: "transparent" } },
|
||||
statusBar: { barStyle: "light-content" },
|
||||
});
|
||||
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Player } from "@kyoo/ui";
|
||||
import { withRoute } from "../../utils";
|
||||
|
||||
export default withRoute(
|
||||
Player,
|
||||
{
|
||||
options: {
|
||||
headerShown: false,
|
||||
navigationBarHidden: true,
|
||||
},
|
||||
statusBar: { hidden: true },
|
||||
fullscreen: true,
|
||||
},
|
||||
{ type: "episode" },
|
||||
);
|
||||
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { type Account, ConnectionErrorContext, useAccount } from "@kyoo/models";
|
||||
import { NavbarProfile, NavbarTitle } from "@kyoo/ui";
|
||||
import { Redirect, Stack } from "expo-router";
|
||||
import { useContext, useRef } from "react";
|
||||
import { useTheme } from "yoshiki/native";
|
||||
|
||||
export default function PublicLayout() {
|
||||
const theme = useTheme();
|
||||
const account = useAccount();
|
||||
const { error } = useContext(ConnectionErrorContext);
|
||||
const oldAccount = useRef<Account | null>(account);
|
||||
|
||||
if (account && !error && account !== oldAccount.current) return <Redirect href="/" />;
|
||||
oldAccount.current = account;
|
||||
|
||||
return (
|
||||
<Stack
|
||||
screenOptions={{
|
||||
headerTitle: () => <NavbarTitle />,
|
||||
headerRight: () => <NavbarProfile />,
|
||||
contentStyle: {
|
||||
backgroundColor: theme.background,
|
||||
},
|
||||
headerStyle: {
|
||||
backgroundColor: theme.accent,
|
||||
},
|
||||
headerTintColor: theme.colors.white,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ConnectionError } from "@kyoo/ui";
|
||||
|
||||
export default ConnectionError;
|
||||
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { OidcCallbackPage } from "@kyoo/ui";
|
||||
import { withRoute } from "../../utils";
|
||||
|
||||
export default withRoute(OidcCallbackPage);
|
||||
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { LoginPage } from "@kyoo/ui";
|
||||
import { withRoute } from "../../utils";
|
||||
|
||||
export default withRoute(LoginPage);
|
||||
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RegisterPage } from "@kyoo/ui";
|
||||
import { withRoute } from "../../utils";
|
||||
|
||||
export default withRoute(RegisterPage);
|
||||
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ServerUrlPage } from "@kyoo/ui";
|
||||
|
||||
export default ServerUrlPage;
|
||||
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { SettingsPage } from "@kyoo/ui";
|
||||
|
||||
export default SettingsPage;
|
||||
@ -1,156 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import "react-native-reanimated";
|
||||
|
||||
import {
|
||||
Poppins_300Light,
|
||||
Poppins_400Regular,
|
||||
Poppins_900Black,
|
||||
useFonts,
|
||||
} from "@expo-google-fonts/poppins";
|
||||
import { PortalProvider } from "@gorhom/portal";
|
||||
import { AccountProvider, createQueryClient, storage, useUserTheme } from "@kyoo/models";
|
||||
import { SnackbarProvider, ThemeSelector } from "@kyoo/primitives";
|
||||
import { DownloadProvider } from "@kyoo/ui";
|
||||
import { ThemeProvider as RNThemeProvider } from "@react-navigation/native";
|
||||
import { createSyncStoragePersister } from "@tanstack/query-sync-storage-persister";
|
||||
import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client";
|
||||
import { getLocales } from "expo-localization";
|
||||
import { Slot } from "expo-router";
|
||||
import * as SplashScreen from "expo-splash-screen";
|
||||
import i18next from "i18next";
|
||||
import "intl-pluralrules";
|
||||
import { type ReactNode, useEffect, useState } from "react";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
import { useColorScheme } from "react-native";
|
||||
import resources from "../../../translations";
|
||||
|
||||
import NetInfo from "@react-native-community/netinfo";
|
||||
import { onlineManager } from "@tanstack/react-query";
|
||||
import { useTheme } from "yoshiki/native";
|
||||
|
||||
onlineManager.setEventListener((setOnline) => {
|
||||
return NetInfo.addEventListener((state) => {
|
||||
setOnline(!!state.isConnected);
|
||||
});
|
||||
});
|
||||
|
||||
const clientStorage = {
|
||||
setItem: (key, value) => {
|
||||
storage.set(key, value);
|
||||
},
|
||||
getItem: (key) => {
|
||||
const value = storage.getString(key);
|
||||
return value === undefined ? null : value;
|
||||
},
|
||||
removeItem: (key) => {
|
||||
storage.delete(key);
|
||||
},
|
||||
} satisfies Partial<Storage>;
|
||||
|
||||
export const clientPersister = createSyncStoragePersister({ storage: clientStorage });
|
||||
|
||||
const sysLang = getLocales()[0].languageCode ?? "en";
|
||||
i18next.use(initReactI18next).init({
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
},
|
||||
returnEmptyString: false,
|
||||
fallbackLng: "en",
|
||||
lng: storage.getString("language") ?? sysLang,
|
||||
resources,
|
||||
});
|
||||
// @ts-expect-error Manually added value
|
||||
i18next.systemLanguage = sysLang;
|
||||
|
||||
const NavigationThemeProvider = ({ children }: { children: ReactNode }) => {
|
||||
const theme = useTheme();
|
||||
return (
|
||||
<RNThemeProvider
|
||||
value={{
|
||||
dark: theme.mode === "dark",
|
||||
colors: {
|
||||
primary: theme.accent,
|
||||
card: theme.variant.background,
|
||||
text: theme.paragraph,
|
||||
border: theme.background,
|
||||
notification: theme.background,
|
||||
background: theme.background,
|
||||
},
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</RNThemeProvider>
|
||||
);
|
||||
};
|
||||
|
||||
SplashScreen.preventAutoHideAsync();
|
||||
|
||||
export default function Root() {
|
||||
const [queryClient] = useState(() => createQueryClient());
|
||||
let theme = useUserTheme();
|
||||
const systemTheme = useColorScheme();
|
||||
const [fontsLoaded] = useFonts({ Poppins_300Light, Poppins_400Regular, Poppins_900Black });
|
||||
|
||||
if (theme === "auto") theme = systemTheme ?? "light";
|
||||
|
||||
useEffect(() => {
|
||||
if (fontsLoaded) SplashScreen.hideAsync();
|
||||
}, [fontsLoaded]);
|
||||
|
||||
if (!fontsLoaded) return null;
|
||||
return (
|
||||
<PersistQueryClientProvider
|
||||
client={queryClient}
|
||||
persistOptions={{
|
||||
persister: clientPersister,
|
||||
// Only dehydrate mutations, queries are not json serializable anyways.
|
||||
dehydrateOptions: { shouldDehydrateQuery: () => false },
|
||||
}}
|
||||
onSuccess={async () => {
|
||||
await queryClient.resumePausedMutations();
|
||||
queryClient.invalidateQueries();
|
||||
}}
|
||||
>
|
||||
<ThemeSelector
|
||||
theme={theme}
|
||||
font={{
|
||||
normal: "Poppins_400Regular",
|
||||
"300": "Poppins_300Light",
|
||||
"400": "Poppins_400Regular",
|
||||
"900": "Poppins_900Black",
|
||||
}}
|
||||
>
|
||||
<PortalProvider>
|
||||
<AccountProvider>
|
||||
<DownloadProvider>
|
||||
<NavigationThemeProvider>
|
||||
<SnackbarProvider>
|
||||
<Slot />
|
||||
</SnackbarProvider>
|
||||
</NavigationThemeProvider>
|
||||
</DownloadProvider>
|
||||
</AccountProvider>
|
||||
</PortalProvider>
|
||||
</ThemeSelector>
|
||||
</PersistQueryClientProvider>
|
||||
);
|
||||
}
|
||||
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { type QueryPage, useHasPermission } from "@kyoo/models";
|
||||
import { Unauthorized } from "@kyoo/ui";
|
||||
import arrayShuffle from "array-shuffle";
|
||||
import * as NavigationBar from "expo-navigation-bar";
|
||||
import { Stack, useLocalSearchParams } from "expo-router";
|
||||
import * as ScreenOrientation from "expo-screen-orientation";
|
||||
import { type ComponentType, useEffect } from "react";
|
||||
import { StatusBar, type StatusBarProps } from "react-native";
|
||||
|
||||
const FullscreenProvider = () => {
|
||||
useEffect(() => {
|
||||
ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE);
|
||||
NavigationBar.setVisibilityAsync("hidden");
|
||||
return () => {
|
||||
ScreenOrientation.unlockAsync();
|
||||
NavigationBar.setVisibilityAsync("visible");
|
||||
};
|
||||
}, []);
|
||||
return null;
|
||||
};
|
||||
|
||||
export const withRoute = <Props,>(
|
||||
Component: ComponentType<Props>,
|
||||
options?: Parameters<typeof Stack.Screen>[0] & {
|
||||
statusBar?: StatusBarProps;
|
||||
fullscreen?: boolean;
|
||||
},
|
||||
defaultProps?: Partial<Props>,
|
||||
) => {
|
||||
const { statusBar, fullscreen, ...routeOptions } = options ?? {};
|
||||
const WithUseRoute = (props: any) => {
|
||||
const routeParams = useLocalSearchParams();
|
||||
const hasPermissions = useHasPermission((Component as QueryPage).requiredPermissions ?? []);
|
||||
|
||||
if (!hasPermissions)
|
||||
return <Unauthorized missing={(Component as QueryPage).requiredPermissions!} />;
|
||||
|
||||
return (
|
||||
<>
|
||||
{routeOptions && <Stack.Screen {...routeOptions} />}
|
||||
{statusBar && <StatusBar {...statusBar} />}
|
||||
{fullscreen && <FullscreenProvider />}
|
||||
<Component
|
||||
{...defaultProps}
|
||||
randomItems={arrayShuffle((Component as QueryPage).randomItems ?? [])}
|
||||
{...routeParams}
|
||||
{...props}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const { ...all } = Component;
|
||||
Object.assign(WithUseRoute, { ...all });
|
||||
return WithUseRoute;
|
||||
};
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.5 KiB |
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const { getDefaultConfig } = require("expo/metro-config");
|
||||
const path = require("node:path");
|
||||
|
||||
const projectRoot = __dirname;
|
||||
const defaultConfig = getDefaultConfig(projectRoot);
|
||||
|
||||
function addMonorepoSupport(config) {
|
||||
const workspaceRoot = path.resolve(projectRoot, "../..");
|
||||
|
||||
return {
|
||||
...config,
|
||||
watchFolders: [...config.watchFolders, workspaceRoot],
|
||||
resolver: {
|
||||
...config.resolver,
|
||||
nodeModulesPaths: [
|
||||
...config.resolver.nodeModulesPaths,
|
||||
path.resolve(projectRoot, "node_modules"),
|
||||
path.resolve(workspaceRoot, "node_modules"),
|
||||
],
|
||||
disableHierarchicalLookup: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function addSvgTransformer(config) {
|
||||
return {
|
||||
...config,
|
||||
transformer: {
|
||||
...config.transformer,
|
||||
babelTransformerPath: require.resolve("react-native-svg-transformer"),
|
||||
},
|
||||
resolver: {
|
||||
...config.resolver,
|
||||
assetExts: config.resolver.assetExts.filter((ext) => ext !== "svg"),
|
||||
sourceExts: [...config.resolver.sourceExts, "svg"],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = addMonorepoSupport(
|
||||
addSvgTransformer({
|
||||
...defaultConfig,
|
||||
resolver: {
|
||||
...defaultConfig.resolver,
|
||||
requireCycleIgnorePatterns: [...defaultConfig.resolver.requireCycleIgnorePatterns, /.*/],
|
||||
},
|
||||
}),
|
||||
);
|
||||
@ -1,12 +0,0 @@
|
||||
{
|
||||
"extends": "expo/tsconfig.base",
|
||||
"compilerOptions": {
|
||||
"strict": true
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
"../../packages/ui/src/i18n-d.d.ts",
|
||||
"../../packages/ui/src/svg.d.ts"
|
||||
]
|
||||
}
|
||||
@ -1,137 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const path = require("node:path");
|
||||
const CopyPlugin = require("copy-webpack-plugin");
|
||||
const DefinePlugin = require("webpack").DefinePlugin;
|
||||
|
||||
const suboctopus = path.resolve(path.dirname(require.resolve("jassub")), "../dist");
|
||||
|
||||
/**
|
||||
* @type {import("next").NextConfig}
|
||||
*/
|
||||
const nextConfig = {
|
||||
swcMinify: true,
|
||||
// can't be true since we would run hls cleanup twice and run on race conditions
|
||||
reactStrictMode: false,
|
||||
output: "standalone",
|
||||
webpack: (config) => {
|
||||
config.plugins = [
|
||||
...config.plugins,
|
||||
new CopyPlugin({
|
||||
patterns: [
|
||||
{
|
||||
context: suboctopus,
|
||||
from: "*",
|
||||
filter: (filepath) => !filepath.endsWith(".es.js"),
|
||||
to: "static/chunks/",
|
||||
},
|
||||
],
|
||||
}),
|
||||
];
|
||||
config.resolve = {
|
||||
...config.resolve,
|
||||
alias: {
|
||||
...config.resolve.alias,
|
||||
"react-native$": "react-native-web",
|
||||
// "react-native/Libraries/Image/AssetRegistry$":
|
||||
// "react-native-web/dist/modules/AssetRegistry",
|
||||
"react-native/Libraries/EventEmitter/RCTDeviceEventEmitter$":
|
||||
"react-native-web/dist/vendor/react-native/NativeEventEmitter/RCTDeviceEventEmitter",
|
||||
"react-native/Libraries/vendor/emitter/EventEmitter$":
|
||||
"react-native-web/dist/vendor/react-native/emitter/EventEmitter",
|
||||
"react-native/Libraries/EventEmitter/NativeEventEmitter$":
|
||||
"react-native-web/dist/vendor/react-native/NativeEventEmitter",
|
||||
},
|
||||
extensions: [".web.ts", ".web.tsx", ".web.js", ".web.jsx", ...config.resolve.extensions],
|
||||
};
|
||||
|
||||
if (!config.plugins) config.plugins = [];
|
||||
config.plugins.push(
|
||||
new DefinePlugin({
|
||||
__DEV__: JSON.stringify(process.env.NODE_ENV !== "production"),
|
||||
}),
|
||||
);
|
||||
|
||||
config.module.rules.push({
|
||||
test: /\.svg$/i,
|
||||
issuer: /\.[jt]sx?$/,
|
||||
use: [
|
||||
{
|
||||
loader: "@svgr/webpack",
|
||||
options: {
|
||||
native: true,
|
||||
svgoConfig: {
|
||||
plugins: [
|
||||
{
|
||||
name: "removeViewBox",
|
||||
active: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
return config;
|
||||
},
|
||||
i18n: {
|
||||
locales: ["en", "fr"],
|
||||
defaultLocale: "en",
|
||||
},
|
||||
transpilePackages: [
|
||||
"@kyoo/ui",
|
||||
"@kyoo/primitives",
|
||||
"@kyoo/models",
|
||||
"@react-native/assets-registry",
|
||||
"solito",
|
||||
"react-native",
|
||||
"react-native-web",
|
||||
"react-native-svg",
|
||||
"react-native-reanimated",
|
||||
"react-native-mmkv",
|
||||
"moti",
|
||||
"yoshiki",
|
||||
"@expo/vector-icons",
|
||||
"@expo/html-elements",
|
||||
"expo-font",
|
||||
"expo-asset",
|
||||
"expo-av",
|
||||
"expo-modules-core",
|
||||
"expo-linear-gradient",
|
||||
"expo-image-picker",
|
||||
],
|
||||
experimental: {
|
||||
outputFileTracingRoot: path.join(__dirname, "../../"),
|
||||
},
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
nextConfig.rewrites = async () => [
|
||||
{
|
||||
source: "/api/:path*",
|
||||
destination: process.env.KYOO_URL
|
||||
? `${process.env.KYOO_URL}/:path*`
|
||||
: "http://localhost:5000/:path*",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
module.exports = nextConfig;
|
||||
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { readCookie } from "@kyoo/models/src/account-internal";
|
||||
import i18next, { type InitOptions } from "i18next";
|
||||
import type { AppContext, AppInitialProps, AppProps } from "next/app";
|
||||
import { type ComponentType, useState } from "react";
|
||||
import { I18nextProvider } from "react-i18next";
|
||||
import resources from "../../../translations";
|
||||
|
||||
export const withTranslations = (
|
||||
AppToTranslate: ComponentType<AppProps> & {
|
||||
getInitialProps: (ctx: AppContext) => Promise<AppInitialProps>;
|
||||
},
|
||||
) => {
|
||||
const i18n = i18next.createInstance();
|
||||
const commonOptions: InitOptions = {
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
},
|
||||
returnEmptyString: false,
|
||||
fallbackLng: "en",
|
||||
resources,
|
||||
};
|
||||
|
||||
const AppWithTranslations = (props: AppProps) => {
|
||||
const [li18n] = useState(() => {
|
||||
if (typeof window === "undefined") return i18n;
|
||||
i18next.init({
|
||||
...commonOptions,
|
||||
lng: props.pageProps.__lang,
|
||||
});
|
||||
i18next.systemLanguage = props.pageProps?.__sysLang;
|
||||
return i18next;
|
||||
});
|
||||
|
||||
return (
|
||||
<I18nextProvider i18n={li18n}>
|
||||
<AppToTranslate {...props} />
|
||||
</I18nextProvider>
|
||||
);
|
||||
};
|
||||
AppWithTranslations.getInitialProps = async (ctx: AppContext) => {
|
||||
const props: AppInitialProps = await AppToTranslate.getInitialProps(ctx);
|
||||
const sysLng = ctx.router.locale || ctx.router.defaultLocale || "en";
|
||||
const lng = readCookie(ctx.ctx.req?.headers.cookie, "language") || sysLng;
|
||||
await i18n.init({
|
||||
...commonOptions,
|
||||
lng,
|
||||
});
|
||||
i18n.systemLanguage = sysLng;
|
||||
props.pageProps ??= {};
|
||||
props.pageProps.__lang = lng;
|
||||
props.pageProps.__sysLang = sysLng;
|
||||
return props;
|
||||
};
|
||||
|
||||
return AppWithTranslations;
|
||||
};
|
||||
@ -1,227 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import "../polyfill";
|
||||
|
||||
import { PortalProvider } from "@gorhom/portal";
|
||||
import {
|
||||
AccountP,
|
||||
AccountProvider,
|
||||
ConnectionErrorContext,
|
||||
type QueryIdentifier,
|
||||
type QueryPage,
|
||||
type ServerInfo,
|
||||
ServerInfoP,
|
||||
SetupStep,
|
||||
UserP,
|
||||
createQueryClient,
|
||||
fetchQuery,
|
||||
getTokenWJ,
|
||||
setSsrApiUrl,
|
||||
useFetch,
|
||||
useUserTheme,
|
||||
} from "@kyoo/models";
|
||||
import { getCurrentAccount, readCookie, updateAccount } from "@kyoo/models/src/account-internal";
|
||||
import {
|
||||
HiddenIfNoJs,
|
||||
SkeletonCss,
|
||||
SnackbarProvider,
|
||||
ThemeSelector,
|
||||
TouchOnlyCss,
|
||||
} from "@kyoo/primitives";
|
||||
import { WebTooltip } from "@kyoo/primitives/src/tooltip.web";
|
||||
import { ConnectionError } from "@kyoo/ui";
|
||||
import { HydrationBoundary, QueryClientProvider, dehydrate } from "@tanstack/react-query";
|
||||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
||||
import arrayShuffle from "array-shuffle";
|
||||
import NextApp, { type AppContext, type AppProps } from "next/app";
|
||||
import { Poppins } from "next/font/google";
|
||||
import Head from "next/head";
|
||||
import { type NextRouter, useRouter } from "next/router";
|
||||
import { type ComponentType, useContext, useEffect, useState } from "react";
|
||||
import { Tooltip } from "react-tooltip";
|
||||
import superjson from "superjson";
|
||||
import { StyleRegistryProvider, useMobileHover, useStyleRegistry, useTheme } from "yoshiki/web";
|
||||
import { withTranslations } from "../i18n";
|
||||
|
||||
const font = Poppins({ weight: ["300", "400", "900"], subsets: ["latin"], display: "swap" });
|
||||
|
||||
const YoshikiDebug = ({ children }: { children: JSX.Element }) => {
|
||||
if (typeof window === "undefined") return children;
|
||||
const registry = useStyleRegistry();
|
||||
return <StyleRegistryProvider registry={registry}>{children}</StyleRegistryProvider>;
|
||||
};
|
||||
|
||||
const ConnectionErrorVerifier = ({
|
||||
children,
|
||||
skipErrors,
|
||||
}: {
|
||||
children: JSX.Element;
|
||||
skipErrors?: boolean;
|
||||
}) => {
|
||||
const { error } = useContext(ConnectionErrorContext);
|
||||
|
||||
if (!error || skipErrors) return children;
|
||||
return <WithLayout Component={ConnectionError} />;
|
||||
};
|
||||
|
||||
const SetupChecker = () => {
|
||||
const { data } = useFetch({ path: ["info"], parser: ServerInfoP });
|
||||
const router = useRouter();
|
||||
|
||||
const step = data?.setupStatus;
|
||||
|
||||
useEffect(() => {
|
||||
if (!step) return;
|
||||
if (step !== SetupStep.Done && !SetupChecker.isRouteAllowed(router, step))
|
||||
router.push(`/setup?step=${step}`);
|
||||
if (step === SetupStep.Done && router.route === "/setup") router.replace("/");
|
||||
}, [router.route, step, router]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
SetupChecker.isRouteAllowed = (router: NextRouter, step: SetupStep) =>
|
||||
(router.route === "/setup" && router.query.step === step) ||
|
||||
router.route === "/register" ||
|
||||
router.route.startsWith("/login") ||
|
||||
router.route === "/settings";
|
||||
|
||||
const WithLayout = ({ Component, ...props }: { Component: ComponentType }) => {
|
||||
const layoutInfo = (Component as QueryPage).getLayout ?? (({ page }) => page);
|
||||
const { Layout, props: layoutProps } =
|
||||
typeof layoutInfo === "function" ? { Layout: layoutInfo, props: {} } : layoutInfo;
|
||||
return <Layout page={<Component {...props} />} randomItems={[]} {...layoutProps} />;
|
||||
};
|
||||
|
||||
const App = ({ Component, pageProps }: AppProps) => {
|
||||
const [queryClient] = useState(() => createQueryClient());
|
||||
const { queryState, ssrError, token, randomItems, account, theme, ...props } =
|
||||
superjson.deserialize<any>(pageProps ?? { json: {} });
|
||||
const userTheme = useUserTheme(theme);
|
||||
useMobileHover();
|
||||
|
||||
// Set the auth from the server (if the token was refreshed during SSR).
|
||||
if (typeof window !== "undefined" && token) {
|
||||
const account = getCurrentAccount();
|
||||
if (account) updateAccount(account.id, { ...account, token });
|
||||
}
|
||||
|
||||
return (
|
||||
<YoshikiDebug>
|
||||
<>
|
||||
<Head>
|
||||
<title>Kyoo</title>
|
||||
<meta name="description" content="A portable and vast media library solution." />
|
||||
</Head>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<AccountProvider ssrAccount={account} ssrError={ssrError}>
|
||||
<HydrationBoundary state={queryState}>
|
||||
<ThemeSelector theme={userTheme} font={{ normal: "inherit" }}>
|
||||
<PortalProvider>
|
||||
<SnackbarProvider>
|
||||
<GlobalCssTheme />
|
||||
<ConnectionErrorVerifier skipErrors={(Component as QueryPage).isPublic}>
|
||||
<WithLayout
|
||||
Component={Component}
|
||||
randomItems={
|
||||
randomItems[Component.displayName!] ??
|
||||
arrayShuffle((Component as QueryPage).randomItems ?? [])
|
||||
}
|
||||
{...props}
|
||||
/>
|
||||
</ConnectionErrorVerifier>
|
||||
<Tooltip id="tooltip" style={{ zIndex: 10 }} positionStrategy={"fixed"} />
|
||||
<SetupChecker />
|
||||
</SnackbarProvider>
|
||||
</PortalProvider>
|
||||
</ThemeSelector>
|
||||
</HydrationBoundary>
|
||||
</AccountProvider>
|
||||
<ReactQueryDevtools initialIsOpen={false} />
|
||||
</QueryClientProvider>
|
||||
</>
|
||||
</YoshikiDebug>
|
||||
);
|
||||
};
|
||||
|
||||
App.getInitialProps = async (ctx: AppContext) => {
|
||||
const appProps = await NextApp.getInitialProps(ctx);
|
||||
const Component = ctx.Component as QueryPage;
|
||||
|
||||
const items = arrayShuffle(Component.randomItems ?? []);
|
||||
appProps.pageProps.randomItems = {
|
||||
[Component.displayName!]: items,
|
||||
};
|
||||
|
||||
if (typeof window !== "undefined") return { pageProps: superjson.serialize(appProps.pageProps) };
|
||||
|
||||
try {
|
||||
const getUrl = Component.getFetchUrls;
|
||||
const getLayoutUrl =
|
||||
Component.getLayout && "Layout" in Component.getLayout
|
||||
? Component.getLayout.Layout.getFetchUrls
|
||||
: Component.getLayout?.getFetchUrls;
|
||||
const urls: QueryIdentifier[] = [
|
||||
...(getUrl ? getUrl(ctx.router.query as any, items) : []),
|
||||
...(getLayoutUrl ? getLayoutUrl(ctx.router.query as any, items) : []),
|
||||
// always include server info for guest permissions.
|
||||
{ path: ["info"], parser: ServerInfoP },
|
||||
];
|
||||
|
||||
setSsrApiUrl();
|
||||
|
||||
appProps.pageProps.theme = readCookie(ctx.ctx.req?.headers.cookie, "theme") ?? "auto";
|
||||
|
||||
const account = readCookie(ctx.ctx.req?.headers.cookie, "account", AccountP);
|
||||
if (account) urls.push({ path: ["auth", "me"], parser: UserP });
|
||||
const [authToken, token, error] = await getTokenWJ(account);
|
||||
if (error) appProps.pageProps.ssrError = error;
|
||||
const client = (await fetchQuery(urls, authToken))!;
|
||||
appProps.pageProps.queryState = dehydrate(client);
|
||||
if (account) {
|
||||
appProps.pageProps.token = token;
|
||||
appProps.pageProps.account = {
|
||||
...client.getQueryData(["auth", "me"]),
|
||||
...account,
|
||||
};
|
||||
}
|
||||
|
||||
const info = client.getQueryData<ServerInfo>(["info"]);
|
||||
if (
|
||||
info!.setupStatus !== SetupStep.Done &&
|
||||
!SetupChecker.isRouteAllowed(ctx.router, info!.setupStatus)
|
||||
) {
|
||||
ctx.ctx.res!.writeHead(307, { Location: `/setup?step=${info!.setupStatus}` });
|
||||
ctx.ctx.res!.end();
|
||||
return { pageProps: {} };
|
||||
}
|
||||
if (info!.setupStatus === SetupStep.Done && ctx.router.route === "/setup") {
|
||||
ctx.ctx.res!.writeHead(307, { Location: "/" });
|
||||
ctx.ctx.res!.end();
|
||||
return { pageProps: {} };
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("SSR error, disabling it.");
|
||||
}
|
||||
return { pageProps: superjson.serialize(appProps.pageProps) };
|
||||
};
|
||||
|
||||
export default withTranslations(App);
|
||||
@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { type DocumentContext, Head, Html, Main, NextScript } from "next/document";
|
||||
import { AppRegistry } from "react-native";
|
||||
import { StyleRegistryProvider, createStyleRegistry } from "yoshiki/web";
|
||||
|
||||
export const style = `
|
||||
/**
|
||||
* Building on the RNWeb reset:
|
||||
* https://github.com/necolas/react-native-web/blob/master/packages/react-native-web/src/exports/StyleSheet/initialRules.js
|
||||
*/
|
||||
html, body, #__next {
|
||||
width: 100%;
|
||||
/* To smooth any scrolling behavior */
|
||||
-webkit-overflow-scrolling: touch;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
/* Allows content to fill the viewport and go beyond the bottom */
|
||||
min-height: 100%;
|
||||
}
|
||||
#__next {
|
||||
flex-shrink: 0;
|
||||
flex-basis: auto;
|
||||
flex-direction: column;
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
/* Prevent text size change on orientation change https://gist.github.com/tfausak/2222823#file-ios-8-web-app-html-L138 */
|
||||
-webkit-text-size-adjust: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
body {
|
||||
display: flex;
|
||||
/* Allows you to scroll below the viewport; default value is visible */
|
||||
overflow-y: auto;
|
||||
overscroll-behavior-y: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
-ms-overflow-style: scrollbar;
|
||||
}
|
||||
`;
|
||||
|
||||
const Document = () => {
|
||||
return (
|
||||
<Html>
|
||||
<Head>
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/icon-16x16.png" />
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/icon-32x32.png" />
|
||||
<link rel="icon" type="image/png" sizes="64x64" href="/icon-64x64.png" />
|
||||
<link rel="icon" type="image/png" sizes="128x128" href="/icon-128x128.png" />
|
||||
<link rel="icon" type="image/png" sizes="256x256" href="/icon-256x256.png" />
|
||||
</Head>
|
||||
<body className="hoverEnabled">
|
||||
<Main />
|
||||
<NextScript />
|
||||
</body>
|
||||
</Html>
|
||||
);
|
||||
};
|
||||
|
||||
Document.getInitialProps = async (ctx: DocumentContext) => {
|
||||
const renderPage = ctx.renderPage;
|
||||
const registry = createStyleRegistry();
|
||||
|
||||
ctx.renderPage = () =>
|
||||
renderPage({
|
||||
enhanceApp: (App) => (props) => {
|
||||
return (
|
||||
<StyleRegistryProvider registry={registry}>
|
||||
<App {...props} />
|
||||
</StyleRegistryProvider>
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
const props = await ctx.defaultGetInitialProps(ctx);
|
||||
|
||||
AppRegistry.registerComponent("Main", () => Main);
|
||||
// @ts-ignore React native web missing type.
|
||||
const { getStyleElement } = AppRegistry.getApplication("Main");
|
||||
const page = await ctx.renderPage();
|
||||
|
||||
return {
|
||||
...props,
|
||||
...page,
|
||||
styles: (
|
||||
<>
|
||||
{props.styles}
|
||||
{page.styles}
|
||||
<style>{style}</style>
|
||||
{getStyleElement()}
|
||||
{registry.flushToComponent()}
|
||||
</>
|
||||
),
|
||||
};
|
||||
};
|
||||
export default Document;
|
||||
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { AdminPage } from "@kyoo/ui";
|
||||
import { withRoute } from "~/router";
|
||||
|
||||
export default withRoute(AdminPage);
|
||||
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { BrowsePage } from "@kyoo/ui";
|
||||
import { withRoute } from "~/router";
|
||||
|
||||
export default withRoute(BrowsePage);
|
||||
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { CollectionPage } from "@kyoo/ui";
|
||||
import { withRoute } from "~/router";
|
||||
|
||||
export default withRoute(CollectionPage);
|
||||
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { HomePage } from "@kyoo/ui";
|
||||
|
||||
export default HomePage;
|
||||
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { OidcCallbackPage } from "@kyoo/ui";
|
||||
import { withRoute } from "~/router";
|
||||
|
||||
export default withRoute(OidcCallbackPage);
|
||||
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { LoginPage } from "@kyoo/ui";
|
||||
import { withRoute } from "~/router";
|
||||
|
||||
export default withRoute(LoginPage);
|
||||
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { MovieDetails } from "@kyoo/ui";
|
||||
import { withRoute } from "~/router";
|
||||
|
||||
export default withRoute(MovieDetails);
|
||||
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Player } from "@kyoo/ui";
|
||||
import { withRoute } from "~/router";
|
||||
|
||||
export default withRoute(Player, { type: "movie" });
|
||||
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RegisterPage } from "@kyoo/ui";
|
||||
import { withRoute } from "~/router";
|
||||
|
||||
export default withRoute(RegisterPage);
|
||||
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { SearchPage } from "@kyoo/ui";
|
||||
import { withRoute } from "~/router";
|
||||
|
||||
export default withRoute(SearchPage);
|
||||
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { SettingsPage } from "@kyoo/ui";
|
||||
import { withRoute } from "~/router";
|
||||
|
||||
export default withRoute(SettingsPage);
|
||||
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { SetupPage } from "@kyoo/ui";
|
||||
import { withRoute } from "~/router";
|
||||
|
||||
export default withRoute(SetupPage);
|
||||
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ShowDetails } from "@kyoo/ui";
|
||||
import { withRoute } from "~/router";
|
||||
|
||||
export default withRoute(ShowDetails);
|
||||
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Player } from "@kyoo/ui";
|
||||
import { withRoute } from "~/router";
|
||||
|
||||
export default withRoute(Player, { type: "episode" });
|
||||
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// import "raf/polyfill";
|
||||
// import "setimmediate";
|
||||
// import "react-native-reanimated";
|
||||
import React from "react";
|
||||
|
||||
// // FIXME need reanimated update, see https://github.com/software-mansion/react-native-reanimated/issues/3355
|
||||
// if (typeof window !== "undefined") {
|
||||
// // @ts-ignore
|
||||
// window._frameTimestamp = null;
|
||||
// }
|
||||
// Simply silence a SSR warning (see https://github.com/facebook/react/issues/14927 for more details)
|
||||
if (typeof window === "undefined") {
|
||||
React.useLayoutEffect = React.useEffect;
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { type QueryPage, useHasPermission } from "@kyoo/models";
|
||||
import { Unauthorized } from "@kyoo/ui";
|
||||
import { useRouter } from "next/router";
|
||||
import type { ComponentType } from "react";
|
||||
|
||||
export const withRoute = <Props,>(
|
||||
Component: ComponentType<Props>,
|
||||
defaultProps?: Partial<Props>,
|
||||
) => {
|
||||
const WithUseRoute = (props: Props) => {
|
||||
const router = useRouter();
|
||||
const hasPermissions = useHasPermission((Component as QueryPage).requiredPermissions ?? []);
|
||||
|
||||
if (!hasPermissions)
|
||||
return <Unauthorized missing={(Component as QueryPage).requiredPermissions!} />;
|
||||
return <Component {...defaultProps} {...router.query} {...(props as any)} />;
|
||||
};
|
||||
|
||||
const { ...all } = Component;
|
||||
Object.assign(WithUseRoute, { ...all });
|
||||
if ("getFetchUrls" in Component) {
|
||||
const oldGet = Component.getFetchUrls as (obj: object) => object;
|
||||
WithUseRoute.getFetchUrls = (props: object) => oldGet({ ...defaultProps, ...props });
|
||||
}
|
||||
|
||||
return WithUseRoute;
|
||||
};
|
||||
@ -1,24 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"~/*": ["src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "../../packages/ui/src/i18n-d.d.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Kyoo - A portable and vast media library solution.
|
||||
* Copyright (c) Kyoo.
|
||||
*
|
||||
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
*
|
||||
* Kyoo is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Kyoo is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { type LibraryItem, LibraryItemP, type QueryIdentifier, type QueryPage } from "@kyoo/models";
|
||||
import { usePageStyle } from "@kyoo/primitives";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { createParam } from "solito";
|
||||
import { createFilterString, getMediaTypeFromParam, itemMap } from "../browse";
|
||||
import { ItemGrid } from "../browse/grid";
|
||||
import { BrowseSettings } from "../browse/header";
|
||||
import { ItemList } from "../browse/list";
|
||||
import { Layout, type MediaType, MediaTypes, SearchSort, SortOrd } from "../browse/types";
|
||||
import { InfiniteFetch } from "../fetch-infinite";
|
||||
import { DefaultLayout } from "../layout";
|
||||
|
||||
const { useParam } = createParam<{ sortBy?: string; mediaType?: string }>();
|
||||
|
||||
const query = (
|
||||
mediaType: MediaType,
|
||||
query?: string,
|
||||
sortKey?: SearchSort,
|
||||
sortOrd?: SortOrd,
|
||||
): QueryIdentifier<LibraryItem> => ({
|
||||
parser: LibraryItemP,
|
||||
path: ["search", "items"],
|
||||
infinite: true,
|
||||
params: {
|
||||
q: query,
|
||||
filter: createFilterString(mediaType),
|
||||
sortBy:
|
||||
sortKey && sortKey !== SearchSort.Relevance ? `${sortKey}:${sortOrd ?? "asc"}` : undefined,
|
||||
},
|
||||
});
|
||||
|
||||
export const SearchPage: QueryPage<{ q?: string }> = ({ q }) => {
|
||||
const pageStyle = usePageStyle();
|
||||
const { t } = useTranslation();
|
||||
const [sort, setSort] = useParam("sortBy");
|
||||
const [mediaTypeParam, setMediaTypeParam] = useParam("mediaType");
|
||||
const sortKey = (sort?.split(":")[0] as SearchSort) || SearchSort.Relevance;
|
||||
const sortOrd = (sort?.split(":")[1] as SortOrd) || SortOrd.Asc;
|
||||
const [layout, setLayout] = useState(Layout.Grid);
|
||||
|
||||
const mediaType = getMediaTypeFromParam(mediaTypeParam);
|
||||
const LayoutComponent = layout === Layout.Grid ? ItemGrid : ItemList;
|
||||
|
||||
return (
|
||||
<InfiniteFetch
|
||||
query={query(mediaType, q, sortKey, sortOrd)}
|
||||
layout={LayoutComponent.layout}
|
||||
empty={t("search.empty")}
|
||||
incremental
|
||||
Header={
|
||||
<BrowseSettings
|
||||
availableSorts={Object.values(SearchSort)}
|
||||
sortKey={sortKey}
|
||||
sortOrd={sortOrd}
|
||||
setSort={(key, ord) => {
|
||||
setSort(`${key}:${ord}`);
|
||||
}}
|
||||
mediaType={mediaType}
|
||||
availableMediaTypes={MediaTypes}
|
||||
setMediaType={(mediaType) => {
|
||||
setMediaTypeParam(mediaType.key);
|
||||
}}
|
||||
layout={layout}
|
||||
setLayout={setLayout}
|
||||
/>
|
||||
}
|
||||
contentContainerStyle={pageStyle}
|
||||
Render={({ item }) => <LayoutComponent {...itemMap(item)} />}
|
||||
Loader={LayoutComponent.Loader}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
SearchPage.getLayout = DefaultLayout;
|
||||
SearchPage.getFetchUrls = ({ q, sortBy, mediaType }) => {
|
||||
const mediaTypeObj = getMediaTypeFromParam(mediaType);
|
||||
return [
|
||||
query(mediaTypeObj, q, sortBy?.split("-")[0] as SearchSort, sortBy?.split("-")[1] as SortOrd),
|
||||
];
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user