diff --git a/src/Router.tsx b/src/Router.tsx index 031c0cd1a..c2836581d 100644 --- a/src/Router.tsx +++ b/src/Router.tsx @@ -9,23 +9,15 @@ import { } from 'react-router-dom' import { App } from '@src/App' -import { AppStateProvider } from '@src/AppState' import { Auth } from '@src/Auth' import { CommandBar } from '@src/components/CommandBar/CommandBar' import DownloadAppBanner from '@src/components/DownloadAppBanner' import { ErrorPage } from '@src/components/ErrorPage' import FileMachineProvider from '@src/components/FileMachineProvider' -import LspProvider from '@src/components/LspProvider' -import { MachineManagerProvider } from '@src/components/MachineManagerProvider' import ModelingMachineProvider from '@src/components/ModelingMachineProvider' -import { OpenInDesktopAppHandler } from '@src/components/OpenInDesktopAppHandler' -import { ProjectsContextProvider } from '@src/components/ProjectsContextProvider' -import { SystemIOMachineLogicListener } from '@src/components/Providers/SystemIOProviderDesktop' -import { RouteProvider } from '@src/components/RouteProvider' import { WasmErrBanner } from '@src/components/WasmErrBanner' import { NetworkContext } from '@src/hooks/useNetworkContext' import { useNetworkStatus } from '@src/hooks/useNetworkStatus' -import { KclContextProvider } from '@src/lang/KclProvider' import { coreDump } from '@src/lang/wasm' import { ASK_TO_OPEN_QUERY_PARAM, @@ -44,23 +36,23 @@ import { } from '@src/lib/singletons' import { reportRejection } from '@src/lib/trap' import { useToken } from '@src/machines/appMachine' +import RootLayout from '@src/Root' import Home from '@src/routes/Home' import Onboarding, { onboardingRoutes } from '@src/routes/Onboarding' import { Settings } from '@src/routes/Settings' import SignIn from '@src/routes/SignIn' import { Telemetry } from '@src/routes/Telemetry' -import RootLayout from "@src/Root" const createRouter = isDesktop() ? createHashRouter : createBrowserRouter const router = createRouter([ { id: PATHS.INDEX, - element: , - errorElement: , + element: , children: [ { path: PATHS.INDEX, + errorElement: , loader: async ({ request }) => { const onDesktop = isDesktop() const url = new URL(request.url) @@ -81,6 +73,7 @@ const router = createRouter([ loader: fileLoader, id: PATHS.FILE, path: PATHS.FILE + '/:id', + errorElement: , element: ( @@ -127,6 +120,7 @@ const router = createRouter([ }, { path: PATHS.HOME, + errorElement: , element: ( @@ -155,6 +149,7 @@ const router = createRouter([ }, { path: PATHS.SIGN_IN, + errorElement: , element: , }, ], diff --git a/src/components/ProjectsContextProvider.tsx b/src/components/ProjectsContextProvider.tsx index c889291d2..6a28a1fa2 100644 --- a/src/components/ProjectsContextProvider.tsx +++ b/src/components/ProjectsContextProvider.tsx @@ -229,7 +229,7 @@ const ProjectsContextDesktop = ({ const newPathName = `${PATHS.FILE}/${encodeURIComponent( projectPath )}` - console.log(newPathName,'asdf') + console.log(newPathName, 'asdf') navigate(newPathName) } }, diff --git a/src/components/Providers/SystemIOProviderDesktop.tsx b/src/components/Providers/SystemIOProviderDesktop.tsx index 5b3083ce0..cd9faa6d7 100644 --- a/src/components/Providers/SystemIOProviderDesktop.tsx +++ b/src/components/Providers/SystemIOProviderDesktop.tsx @@ -3,25 +3,26 @@ import { systemIOActor } from '@src/machines/appMachine' import { useSelector } from '@xstate/react' import { useEffect } from 'react' import { useNavigate } from 'react-router-dom' -import { - NO_PROJECT_DIRECTORY, - SystemIOMachineEvents -} from '@src/machines/systemIO/utils' -export const useRequestedProjectName = () => useSelector(systemIOActor, (state) => state.context.requestedProjectName) -export const useProjectDirectoryPath = () => useSelector(systemIOActor, (state) => state.context.projectDirectoryPath) - +export const useRequestedProjectName = () => + useSelector(systemIOActor, (state) => state.context.requestedProjectName) +export const useProjectDirectoryPath = () => + useSelector(systemIOActor, (state) => state.context.projectDirectoryPath) export function SystemIOMachineLogicListener() { const requestedProjectName = useRequestedProjectName() const projectDirectoryPath = useProjectDirectoryPath() const navigate = useNavigate() useEffect(() => { - if (!requestedProjectName.name) {return} + if (!requestedProjectName.name) { + return + } let projectPathWithoutSpecificKCLFile = - projectDirectoryPath + window.electron.path.sep + requestedProjectName.name + projectDirectoryPath + + window.electron.path.sep + + requestedProjectName.name const requestedPath = `${PATHS.FILE}/${encodeURIComponent( -projectPathWithoutSpecificKCLFile - )}` + projectPathWithoutSpecificKCLFile + )}` navigate(requestedPath) }, [requestedProjectName]) return null diff --git a/src/machines/appMachine.ts b/src/machines/appMachine.ts index 1fafc3cd3..69d346354 100644 --- a/src/machines/appMachine.ts +++ b/src/machines/appMachine.ts @@ -13,7 +13,7 @@ import { settingsMachine } from '@src/machines/settingsMachine' import { systemIOMachineDesktop } from '@src/machines/systemIO/systemIOMachineDesktop' import { SystemIOMachineEvents } from '@src/machines/systemIO/utils' -const { AUTH, SETTINGS, SYSTEM_IO, ENGINE_STREAM} = ACTOR_IDS +const { AUTH, SETTINGS, SYSTEM_IO, ENGINE_STREAM } = ACTOR_IDS const appMachineActors = { [AUTH]: authMachine, [SETTINGS]: settingsMachine, diff --git a/src/machines/systemIO/systemIOMachine.ts b/src/machines/systemIO/systemIOMachine.ts index ccd7e4fdb..f3097a9a6 100644 --- a/src/machines/systemIO/systemIOMachine.ts +++ b/src/machines/systemIO/systemIOMachine.ts @@ -1,7 +1,6 @@ import { DEFAULT_PROJECT_NAME } from '@src/lib/constants' import type { Project } from '@src/lib/project' -import type { - SystemIOContext} from '@src/machines/systemIO/utils' +import type { SystemIOContext } from '@src/machines/systemIO/utils' import { NO_PROJECT_DIRECTORY, SystemIOMachineActions, @@ -37,7 +36,7 @@ export const systemIOMachine = setup({ | { type: SystemIOMachineEvents.openProject data: { requestedProjectName: string } - } + }, }, actions: { [SystemIOMachineActions.setFolders]: assign({ @@ -58,7 +57,7 @@ export const systemIOMachine = setup({ [SystemIOMachineActions.setRequestedProjectName]: assign({ requestedProjectName: ({ event }) => { assertEvent(event, SystemIOMachineEvents.openProject) - return {name:event.data.requestedProjectName} + return { name: event.data.requestedProjectName } }, }), }, @@ -79,7 +78,7 @@ export const systemIOMachine = setup({ defaultProjectFolderName: DEFAULT_PROJECT_NAME, projectDirectoryPath: NO_PROJECT_DIRECTORY, hasListedProjects: false, - requestedProjectName: {name:NO_PROJECT_DIRECTORY}, + requestedProjectName: { name: NO_PROJECT_DIRECTORY }, }), states: { [SystemIOMachineStates.idle]: { @@ -112,8 +111,7 @@ export const systemIOMachine = setup({ }, }, }, - [SystemIOMachineStates.openingProject] : { - } + [SystemIOMachineStates.openingProject]: {}, }, }) diff --git a/src/machines/systemIO/systemIOMachineDesktop.ts b/src/machines/systemIO/systemIOMachineDesktop.ts index 868d60dc3..2913b6402 100644 --- a/src/machines/systemIO/systemIOMachineDesktop.ts +++ b/src/machines/systemIO/systemIOMachineDesktop.ts @@ -1,8 +1,7 @@ import { getProjectInfo, mkdirOrNOOP } from '@src/lib/desktop' import type { Project } from '@src/lib/project' import { systemIOMachine } from '@src/machines/systemIO/systemIOMachine' -import type { - SystemIOContext} from '@src/machines/systemIO/utils' +import type { SystemIOContext } from '@src/machines/systemIO/utils' import { NO_PROJECT_DIRECTORY, SystemIOMachineActors, diff --git a/src/machines/systemIO/systemIOMachineWeb.ts b/src/machines/systemIO/systemIOMachineWeb.ts index fe6fbe1aa..8b4cf4840 100644 --- a/src/machines/systemIO/systemIOMachineWeb.ts +++ b/src/machines/systemIO/systemIOMachineWeb.ts @@ -1,10 +1,7 @@ import type { Project } from '@src/lib/project' import { systemIOMachine } from '@src/machines/systemIO/systemIOMachine' -import type { - SystemIOContext} from '@src/machines/systemIO/utils' -import { - SystemIOMachineActors, -} from '@src/machines/systemIO/utils' +import type { SystemIOContext } from '@src/machines/systemIO/utils' +import { SystemIOMachineActors } from '@src/machines/systemIO/utils' import { fromPromise } from 'xstate' export const systemIOMachineWeb = systemIOMachine.provide({ diff --git a/src/machines/systemIO/utils.ts b/src/machines/systemIO/utils.ts index 3954a6374..d41251978 100644 --- a/src/machines/systemIO/utils.ts +++ b/src/machines/systemIO/utils.ts @@ -9,7 +9,7 @@ export enum SystemIOMachineStates { idle = 'idle', readingFolders = 'readingFolders', settingProjectDirectoryPath = 'settingProjectDirectoryPath', - openingProject = 'openingProject' + openingProject = 'openingProject', } const donePrefix = 'xstate.done.actor.' @@ -41,5 +41,5 @@ export type SystemIOContext = { // has the application gone through the initialiation of systemIOMachine at least once. // this is required to prevent chokidar from spamming invalid events during initialization. hasListedProjects: boolean - requestedProjectName: {name: string} + requestedProjectName: { name: string } }