Start providers setup

This commit is contained in:
Zoe Roux 2025-01-05 20:42:41 +01:00
parent 32c826e65d
commit 9b89b00b9f
No known key found for this signature in database
6 changed files with 90 additions and 5 deletions

View File

@ -1,5 +1,25 @@
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { Slot } from "one"; import { Slot } from "one";
import { Providers } from "~/providers";
export default function Layout() { export default function Layout() {
return <Slot />; return (
<>
{typeof document !== "undefined" && (
<>
<title>Kyoo</title>
<meta name="description" content="A portable and vast media library solution." />
<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" />
</>
)}
<Providers>
<Slot />
<ReactQueryDevtools initialIsOpen={false} />
</Providers>
</>
);
} }

View File

@ -3,6 +3,7 @@
"workspaces": { "workspaces": {
"": { "": {
"dependencies": { "dependencies": {
"@tanstack/react-query": "^5.62.15",
"expo": "~52.0.17", "expo": "~52.0.17",
"expo-build-properties": "^0.13.1", "expo-build-properties": "^0.13.1",
"expo-localization": "^16.0.0", "expo-localization": "^16.0.0",
@ -16,6 +17,9 @@
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "1.9.4", "@biomejs/biome": "1.9.4",
"@tanstack/react-query-devtools": "^5.62.15",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"typescript": "5.7.2", "typescript": "5.7.2",
"vite": "^6", "vite": "^6",
}, },
@ -616,6 +620,14 @@
"@tamagui/react-native-svg": ["@tamagui/react-native-svg@1.121.6", "", {}, "sha512-IMDW8Hl71I1brgu5b+6G9fs9lT3Wz+BcoYXhUvt0LI+C3N06q842Ph8d8hiol4oA77rRGBj2szVzRIpyMMO9ig=="], "@tamagui/react-native-svg": ["@tamagui/react-native-svg@1.121.6", "", {}, "sha512-IMDW8Hl71I1brgu5b+6G9fs9lT3Wz+BcoYXhUvt0LI+C3N06q842Ph8d8hiol4oA77rRGBj2szVzRIpyMMO9ig=="],
"@tanstack/query-core": ["@tanstack/query-core@5.62.15", "", {}, "sha512-wT20X14CxcWY8YLJ/1pnsXn/y1Q2uRJZYWW93PWRtZt+3/JlGZyiyTcO4pGnqycnP7CokCROAyatsraosqZsDA=="],
"@tanstack/query-devtools": ["@tanstack/query-devtools@5.62.9", "", {}, "sha512-b1NZzDLVf6laJsB1Cfm3ieuYzM+WqoO8qpm9v+3Etwd+Ph4zkhUMiT+wcWj5AhEPsXiRodKYiiW048VDNdBxNg=="],
"@tanstack/react-query": ["@tanstack/react-query@5.62.15", "", { "dependencies": { "@tanstack/query-core": "5.62.15" }, "peerDependencies": { "react": "^18 || ^19" } }, "sha512-Ny3xxsOWmEQCFyHiV3CF7t6+QAV+LpBEREiXyllKR4+tStyd8smOAa98ZHmEx0ZNy36M31K8enifB5wTSYAKJw=="],
"@tanstack/react-query-devtools": ["@tanstack/react-query-devtools@5.62.15", "", { "dependencies": { "@tanstack/query-devtools": "5.62.9" }, "peerDependencies": { "@tanstack/react-query": "^5.62.15", "react": "^18 || ^19" } }, "sha512-8aE7uD45NHZgNtHMVQC7PvM9f72mKK4bqcpHr9La8TsTRX7x8dy2Kdu2ReFNLCrdlEWkxdP5843tc/lHg+Q/rg=="],
"@tybys/wasm-util": ["@tybys/wasm-util@0.9.0", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw=="], "@tybys/wasm-util": ["@tybys/wasm-util@0.9.0", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw=="],
"@types/babel__core": ["@types/babel__core@7.20.5", "", { "dependencies": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", "@types/babel__generator": "*", "@types/babel__template": "*", "@types/babel__traverse": "*" } }, "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA=="], "@types/babel__core": ["@types/babel__core@7.20.5", "", { "dependencies": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", "@types/babel__generator": "*", "@types/babel__template": "*", "@types/babel__traverse": "*" } }, "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA=="],
@ -644,6 +656,10 @@
"@types/node-forge": ["@types/node-forge@1.3.11", "", { "dependencies": { "@types/node": "*" } }, "sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ=="], "@types/node-forge": ["@types/node-forge@1.3.11", "", { "dependencies": { "@types/node": "*" } }, "sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ=="],
"@types/react": ["@types/react@19.0.2", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-USU8ZI/xyKJwFTpjSVIrSeHBVAGagkHQKPNbxeWwql/vDmnTIBgx+TJnhFnj1NXgz8XfprU0egV2dROLGpsBEg=="],
"@types/react-dom": ["@types/react-dom@19.0.2", "", { "peerDependencies": { "@types/react": "^19.0.0" } }, "sha512-c1s+7TKFaDRRxr1TxccIX2u7sfCnc3RxkVyBIUA2lCpyqCF+QoAwQ/CBg7bsMdVwP120HEH143VQezKtef5nCg=="],
"@types/resolve": ["@types/resolve@1.20.2", "", {}, "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q=="], "@types/resolve": ["@types/resolve@1.20.2", "", {}, "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q=="],
"@types/stack-utils": ["@types/stack-utils@2.0.3", "", {}, "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw=="], "@types/stack-utils": ["@types/stack-utils@2.0.3", "", {}, "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw=="],
@ -902,6 +918,8 @@
"css-in-js-utils": ["css-in-js-utils@3.1.0", "", { "dependencies": { "hyphenate-style-name": "^1.0.3" } }, "sha512-fJAcud6B3rRu+KHYk+Bwf+WFL2MDCJJ1XG9x137tJQ0xYxor7XziQtuGFbWNdqrvF4Tk26O3H73nfVqXt/fW1A=="], "css-in-js-utils": ["css-in-js-utils@3.1.0", "", { "dependencies": { "hyphenate-style-name": "^1.0.3" } }, "sha512-fJAcud6B3rRu+KHYk+Bwf+WFL2MDCJJ1XG9x137tJQ0xYxor7XziQtuGFbWNdqrvF4Tk26O3H73nfVqXt/fW1A=="],
"csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
"cuint": ["cuint@0.2.2", "", {}, "sha512-d4ZVpCW31eWwCMe1YT3ur7mUDnTXbgwyzaL320DrcRT45rfjYxkt5QWLrmOJ+/UEAI2+fQgKe/fCjR8l4TpRgw=="], "cuint": ["cuint@0.2.2", "", {}, "sha512-d4ZVpCW31eWwCMe1YT3ur7mUDnTXbgwyzaL320DrcRT45rfjYxkt5QWLrmOJ+/UEAI2+fQgKe/fCjR8l4TpRgw=="],
"debug": ["debug@4.4.0", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA=="], "debug": ["debug@4.4.0", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA=="],

View File

@ -13,6 +13,7 @@
"format:fix": "biome format . --write" "format:fix": "biome format . --write"
}, },
"dependencies": { "dependencies": {
"@tanstack/react-query": "^5.62.15",
"expo": "~52.0.17", "expo": "~52.0.17",
"expo-build-properties": "^0.13.1", "expo-build-properties": "^0.13.1",
"expo-localization": "^16.0.0", "expo-localization": "^16.0.0",
@ -25,8 +26,11 @@
"react-native-web": "^0.19.12" "react-native-web": "^0.19.12"
}, },
"devDependencies": { "devDependencies": {
"vite": "^6",
"@biomejs/biome": "1.9.4", "@biomejs/biome": "1.9.4",
"typescript": "5.7.2" "@tanstack/react-query-devtools": "^5.62.15",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"typescript": "5.7.2",
"vite": "^6"
} }
} }

35
front/src/providers.tsx Normal file
View File

@ -0,0 +1,35 @@
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ComponentType, ReactNode, useState } from "react";
const QueryProvider = ({ children }: { children: ReactNode }) => {
// const [queryClient] = useState(() => createQueryClient());
const [queryClient] = useState(() => new QueryClient({}));
return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>;
};
type ProviderComponent<P = {}> = ComponentType<{ children: ReactNode } & P>;
type Provider = ProviderComponent;
const withProviders = (
providers: Provider[],
): ComponentType<{
children: ReactNode;
}> => {
const ProviderImpl = ({ children }: { children: ReactNode }) => {
return providers.reduceRight((acc, Prov) => <Prov>{acc}</Prov>, children);
};
return ProviderImpl;
};
export const Providers = withProviders([
QueryProvider,
// AccountProvider,
// HydratationBoundary,
// [ThemeSelector, }],
// PortalProvider,
// SnackbarProvider
// ConnectionErrorVerifier
// DownloadProvider
// NavigationThemeProvider
// WithLayout
]);

View File

@ -3,7 +3,7 @@
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"~/*": [ "~/*": [
"./*" "./src/*"
] ]
}, },
"strict": true, "strict": true,
@ -14,7 +14,7 @@
"preserveSymlinks": true, "preserveSymlinks": true,
"skipLibCheck": true, "skipLibCheck": true,
"jsx": "react-jsx", "jsx": "react-jsx",
"noImplicitAny": false, "forceConsistentCasingInFileNames": true,
"types": [ "types": [
"node", "node",
"react", "react",
@ -25,6 +25,10 @@
"esnext" "esnext"
] ]
}, },
"include": [
"**/*.ts",
"**/*.tsx"
],
"exclude": [ "exclude": [
"node_modules", "node_modules",
".expo", ".expo",

View File

@ -3,5 +3,9 @@ import type { UserConfig } from "vite";
import { one } from "one/vite"; import { one } from "one/vite";
export default { export default {
ssr: {
// needed to fix ssr error of react-query
noExternal: true,
},
plugins: [one()], plugins: [one()],
} satisfies UserConfig; } satisfies UserConfig;