spacedrive/interface/index.tsx
Vítor Vasconcellos 5a103fb21b
[ENG-1472] Frontend bug fixes and dependencies update (#2137)
* Fix onboarding sometimes not redirecting to Explorer on prod builds
 - Fix failure trying to compile landing prod builds outside Vercel
 - Fix Server docker failing to restart due to some incorrecting logic for creating the unprivileged users erroring out
 - Fix Storybook failing to build due to updates to Vite
 - Update Storybook dependencies
 - Remove unused Inter font dependency
 - Fix some incorrect references to NodeJS types inside web code
 - Fix $libraryId index using the incorrect redirect function
 - Improve error handling for the $libraryId index route
 - Fix Prism not being correctly loaded, and failing to register its plugins
 - Improve Prism loading error handling
 - Small improvement to the text highlight logic
 - Fix SCSS deprecation for untyped hsl values
 - Fix library query cache incorrectly saving empty values, which lead to the onboarding redirect bug
 - Patch contentLayer to fix an error during the final part of it's build process
 - Update most dev dependencies
 - Update publish-artifact to be compatible with new @actions/artifact
 - Fix issue with new vite-plugin-solid failing to build our .ts files due to the removal of the typescript plugin
 - Fix pnpm overrides not applying due to incorrect placement in package.json
 - Replace deprecated react-tsparticles and updated three used by the Bubbles background in the landing page
 - Rework Bubbles background to be compatible with new @tsparticles/react
 - Update @sd/config dependencies
 - Update @sd/scripts dependencies

* Implement suggestions
 - Replace mobile JS node setup with custom setup-pnpm action
 - Handle GITHUB_SECRET default value in code and throw a warning when it is not set
 - Fix pnpm now resolving the correct node version when building Spacedrive server docker
 - Add missing getent command to spacedrive server docker
 - Fix typo in entrypoint.sh
 - Implement a more robust check if the user is already in a group
 - Fix adduser failing due to missing default group
 - Disconnect IntersectionObserver on component unmount
 - Improve prism import comment

* Implement more suggestions
 - Pin genent version to latest stable release of UClibc
 - Add checksum checks for all ADD clauses in Spacedrive server Dockerfile

* Increase Maestro timeout to reduce CI failures due to slow simulator startup

* Dowgrade maestro to workaround CI timeout

* Improvements to the script that run maestro mobile tests
 - Increase the amount of retries for a maestro test run to 6
 - Increase Maestro driver startup timeout to 2 minutes

* Let run-maestro-tests.sh decide how to run itself

* ¯\_(ツ)_/¯
2024-02-28 23:52:24 +00:00

111 lines
3 KiB
TypeScript

import dayjs from 'dayjs';
import advancedFormat from 'dayjs/plugin/advancedFormat';
import duration from 'dayjs/plugin/duration';
import relativeTime from 'dayjs/plugin/relativeTime';
import { PropsWithChildren, Suspense } from 'react';
import { I18nextProvider } from 'react-i18next';
import { RouterProvider, RouterProviderProps } from 'react-router-dom';
import {
InteropProviderReact,
P2PContextProvider,
useBridgeSubscription,
useInvalidateQuery,
useLoadBackendFeatureFlags
} from '@sd/client';
import { toast, TooltipProvider } from '@sd/ui';
import { createRoutes } from './app';
import { SpacedropProvider } from './app/$libraryId/Spacedrop';
import i18n from './app/I18n';
import { useP2PErrorToast } from './app/p2p';
import { Devtools } from './components/Devtools';
import { WithPrismTheme } from './components/TextViewer/prism';
import ErrorFallback, { BetterErrorBoundary } from './ErrorFallback';
import { useTheme } from './hooks';
import { RouterContext, RoutingContext } from './RoutingContext';
export * from './app';
export { ErrorPage } from './ErrorFallback';
export * from './TabsContext';
export * from './util/keybind';
export * from './util/Platform';
dayjs.extend(advancedFormat);
dayjs.extend(relativeTime);
dayjs.extend(duration);
import('@sentry/browser').then(({ init, Integrations }) => {
init({
dsn: 'https://2fb2450aabb9401b92f379b111402dbc@o1261130.ingest.sentry.io/4504053670412288',
environment: import.meta.env.MODE,
defaultIntegrations: false,
integrations: [new Integrations.HttpContext(), new Integrations.Dedupe()]
});
});
export type Router = RouterProviderProps['router'];
export function SpacedriveRouterProvider(props: {
routing: {
routes: ReturnType<typeof createRoutes>;
visible: boolean;
router: Router;
currentIndex: number;
tabId: string;
maxIndex: number;
};
}) {
return (
<RouterContext.Provider value={props.routing.router}>
<RoutingContext.Provider
value={{
routes: props.routing.routes,
visible: props.routing.visible,
currentIndex: props.routing.currentIndex,
tabId: props.routing.tabId,
maxIndex: props.routing.maxIndex
}}
>
<RouterProvider
router={props.routing.router}
future={{
v7_startTransition: true
}}
/>
</RoutingContext.Provider>
</RouterContext.Provider>
);
}
export function SpacedriveInterfaceRoot({ children }: PropsWithChildren) {
useLoadBackendFeatureFlags();
useP2PErrorToast();
useInvalidateQuery();
useTheme();
useBridgeSubscription(['notifications.listen'], {
onData({ data: { title, content, kind }, expires }) {
toast({ title, body: content }, { type: kind });
}
});
return (
<Suspense>
<I18nextProvider i18n={i18n}>
<BetterErrorBoundary FallbackComponent={ErrorFallback}>
<InteropProviderReact>
<TooltipProvider>
<P2PContextProvider>
<Devtools />
<WithPrismTheme />
<SpacedropProvider />
{children}
</P2PContextProvider>
</TooltipProvider>
</InteropProviderReact>
</BetterErrorBoundary>
</I18nextProvider>
</Suspense>
);
}