2023-01-20 03:32:35 +00:00
|
|
|
import '@fontsource/inter/variable.css';
|
2023-09-11 15:26:44 +00:00
|
|
|
|
2022-10-01 17:37:35 +00:00
|
|
|
import dayjs from 'dayjs';
|
|
|
|
import advancedFormat from 'dayjs/plugin/advancedFormat';
|
|
|
|
import duration from 'dayjs/plugin/duration';
|
|
|
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
2023-11-25 00:16:26 +00:00
|
|
|
import { PropsWithChildren, Suspense } from 'react';
|
2023-03-15 16:11:47 +00:00
|
|
|
import { RouterProvider, RouterProviderProps } from 'react-router-dom';
|
2023-08-29 17:54:58 +00:00
|
|
|
import {
|
|
|
|
P2PContextProvider,
|
2023-12-19 09:28:57 +00:00
|
|
|
useBridgeSubscription,
|
2023-11-16 15:14:47 +00:00
|
|
|
useInvalidateQuery,
|
2023-08-29 17:54:58 +00:00
|
|
|
useLoadBackendFeatureFlags
|
|
|
|
} from '@sd/client';
|
2023-12-19 09:28:57 +00:00
|
|
|
import { toast, TooltipProvider } from '@sd/ui';
|
2023-09-11 15:26:44 +00:00
|
|
|
|
2023-11-25 00:16:26 +00:00
|
|
|
import { createRoutes } from './app';
|
2024-01-08 06:42:17 +00:00
|
|
|
import { SpacedropProvider } from './app/$libraryId/Spacedrop';
|
2023-11-13 07:02:03 +00:00
|
|
|
import { P2P, useP2PErrorToast } from './app/p2p';
|
2023-12-05 13:16:03 +00:00
|
|
|
import { Devtools } from './components/Devtools';
|
2023-10-03 16:18:16 +00:00
|
|
|
import { WithPrismTheme } from './components/TextViewer/prism';
|
2023-10-30 00:44:33 +00:00
|
|
|
import ErrorFallback, { BetterErrorBoundary } from './ErrorFallback';
|
2023-11-16 15:14:47 +00:00
|
|
|
import { useTheme } from './hooks';
|
2024-01-05 08:51:08 +00:00
|
|
|
import { RouterContext, RoutingContext } from './RoutingContext';
|
2023-02-28 05:29:48 +00:00
|
|
|
|
2023-03-15 16:11:47 +00:00
|
|
|
export * from './app';
|
2023-12-19 09:28:57 +00:00
|
|
|
export { ErrorPage } from './ErrorFallback';
|
2023-11-16 15:14:47 +00:00
|
|
|
export * from './TabsContext';
|
2023-12-19 09:28:57 +00:00
|
|
|
export * from './util/keybind';
|
|
|
|
export * from './util/Platform';
|
2022-04-27 01:14:39 +00:00
|
|
|
|
2022-10-01 17:37:35 +00:00
|
|
|
dayjs.extend(advancedFormat);
|
|
|
|
dayjs.extend(relativeTime);
|
|
|
|
dayjs.extend(duration);
|
|
|
|
|
2024-01-02 06:26:28 +00:00
|
|
|
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()]
|
|
|
|
});
|
2022-10-29 09:06:09 +00:00
|
|
|
});
|
|
|
|
|
2023-11-16 15:14:47 +00:00
|
|
|
export type Router = RouterProviderProps['router'];
|
|
|
|
|
2023-11-25 00:16:26 +00:00
|
|
|
export function SpacedriveRouterProvider(props: {
|
2023-11-16 15:14:47 +00:00
|
|
|
routing: {
|
2023-11-25 00:16:26 +00:00
|
|
|
routes: ReturnType<typeof createRoutes>;
|
|
|
|
visible: boolean;
|
2023-11-16 15:14:47 +00:00
|
|
|
router: Router;
|
|
|
|
currentIndex: number;
|
|
|
|
maxIndex: number;
|
|
|
|
};
|
2023-11-25 00:16:26 +00:00
|
|
|
}) {
|
|
|
|
return (
|
2024-01-05 08:51:08 +00:00
|
|
|
<RouterContext.Provider value={props.routing.router}>
|
|
|
|
<RoutingContext.Provider
|
|
|
|
value={{
|
|
|
|
routes: props.routing.routes,
|
|
|
|
visible: props.routing.visible,
|
|
|
|
currentIndex: props.routing.currentIndex,
|
|
|
|
maxIndex: props.routing.maxIndex
|
2023-11-25 00:16:26 +00:00
|
|
|
}}
|
2024-01-05 08:51:08 +00:00
|
|
|
>
|
|
|
|
<RouterProvider
|
|
|
|
router={props.routing.router}
|
|
|
|
future={{
|
|
|
|
v7_startTransition: true
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</RoutingContext.Provider>
|
|
|
|
</RouterContext.Provider>
|
2023-11-25 00:16:26 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function SpacedriveInterfaceRoot({ children }: PropsWithChildren) {
|
2023-08-29 17:54:58 +00:00
|
|
|
useLoadBackendFeatureFlags();
|
2023-11-13 07:02:03 +00:00
|
|
|
useP2PErrorToast();
|
2023-11-16 15:14:47 +00:00
|
|
|
useInvalidateQuery();
|
|
|
|
useTheme();
|
2023-08-29 17:54:58 +00:00
|
|
|
|
2023-12-19 09:28:57 +00:00
|
|
|
useBridgeSubscription(['notifications.listen'], {
|
|
|
|
onData({ data: { title, content, kind }, expires }) {
|
|
|
|
toast({ title, body: content }, { type: kind });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-02-28 05:29:48 +00:00
|
|
|
return (
|
2023-11-25 00:16:26 +00:00
|
|
|
<Suspense>
|
|
|
|
<BetterErrorBoundary FallbackComponent={ErrorFallback}>
|
|
|
|
<TooltipProvider>
|
|
|
|
<P2PContextProvider>
|
2023-12-19 09:28:57 +00:00
|
|
|
<P2P />
|
|
|
|
<Devtools />
|
|
|
|
<WithPrismTheme />
|
2024-01-08 06:42:17 +00:00
|
|
|
<SpacedropProvider />
|
2023-12-19 09:28:57 +00:00
|
|
|
{children}
|
2023-11-25 00:16:26 +00:00
|
|
|
</P2PContextProvider>
|
|
|
|
</TooltipProvider>
|
|
|
|
</BetterErrorBoundary>
|
|
|
|
</Suspense>
|
2023-02-28 05:29:48 +00:00
|
|
|
);
|
2023-11-25 00:16:26 +00:00
|
|
|
}
|