fix: we are so back
This commit is contained in:
@ -9,23 +9,15 @@ import {
|
|||||||
} from 'react-router-dom'
|
} from 'react-router-dom'
|
||||||
|
|
||||||
import { App } from '@src/App'
|
import { App } from '@src/App'
|
||||||
import { AppStateProvider } from '@src/AppState'
|
|
||||||
import { Auth } from '@src/Auth'
|
import { Auth } from '@src/Auth'
|
||||||
import { CommandBar } from '@src/components/CommandBar/CommandBar'
|
import { CommandBar } from '@src/components/CommandBar/CommandBar'
|
||||||
import DownloadAppBanner from '@src/components/DownloadAppBanner'
|
import DownloadAppBanner from '@src/components/DownloadAppBanner'
|
||||||
import { ErrorPage } from '@src/components/ErrorPage'
|
import { ErrorPage } from '@src/components/ErrorPage'
|
||||||
import FileMachineProvider from '@src/components/FileMachineProvider'
|
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 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 { WasmErrBanner } from '@src/components/WasmErrBanner'
|
||||||
import { NetworkContext } from '@src/hooks/useNetworkContext'
|
import { NetworkContext } from '@src/hooks/useNetworkContext'
|
||||||
import { useNetworkStatus } from '@src/hooks/useNetworkStatus'
|
import { useNetworkStatus } from '@src/hooks/useNetworkStatus'
|
||||||
import { KclContextProvider } from '@src/lang/KclProvider'
|
|
||||||
import { coreDump } from '@src/lang/wasm'
|
import { coreDump } from '@src/lang/wasm'
|
||||||
import {
|
import {
|
||||||
ASK_TO_OPEN_QUERY_PARAM,
|
ASK_TO_OPEN_QUERY_PARAM,
|
||||||
@ -44,23 +36,23 @@ import {
|
|||||||
} from '@src/lib/singletons'
|
} from '@src/lib/singletons'
|
||||||
import { reportRejection } from '@src/lib/trap'
|
import { reportRejection } from '@src/lib/trap'
|
||||||
import { useToken } from '@src/machines/appMachine'
|
import { useToken } from '@src/machines/appMachine'
|
||||||
|
import RootLayout from '@src/Root'
|
||||||
import Home from '@src/routes/Home'
|
import Home from '@src/routes/Home'
|
||||||
import Onboarding, { onboardingRoutes } from '@src/routes/Onboarding'
|
import Onboarding, { onboardingRoutes } from '@src/routes/Onboarding'
|
||||||
import { Settings } from '@src/routes/Settings'
|
import { Settings } from '@src/routes/Settings'
|
||||||
import SignIn from '@src/routes/SignIn'
|
import SignIn from '@src/routes/SignIn'
|
||||||
import { Telemetry } from '@src/routes/Telemetry'
|
import { Telemetry } from '@src/routes/Telemetry'
|
||||||
import RootLayout from "@src/Root"
|
|
||||||
|
|
||||||
const createRouter = isDesktop() ? createHashRouter : createBrowserRouter
|
const createRouter = isDesktop() ? createHashRouter : createBrowserRouter
|
||||||
|
|
||||||
const router = createRouter([
|
const router = createRouter([
|
||||||
{
|
{
|
||||||
id: PATHS.INDEX,
|
id: PATHS.INDEX,
|
||||||
element: <RootLayout/>,
|
element: <RootLayout />,
|
||||||
errorElement: <ErrorPage />,
|
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: PATHS.INDEX,
|
path: PATHS.INDEX,
|
||||||
|
errorElement: <ErrorPage />,
|
||||||
loader: async ({ request }) => {
|
loader: async ({ request }) => {
|
||||||
const onDesktop = isDesktop()
|
const onDesktop = isDesktop()
|
||||||
const url = new URL(request.url)
|
const url = new URL(request.url)
|
||||||
@ -81,6 +73,7 @@ const router = createRouter([
|
|||||||
loader: fileLoader,
|
loader: fileLoader,
|
||||||
id: PATHS.FILE,
|
id: PATHS.FILE,
|
||||||
path: PATHS.FILE + '/:id',
|
path: PATHS.FILE + '/:id',
|
||||||
|
errorElement: <ErrorPage />,
|
||||||
element: (
|
element: (
|
||||||
<Auth>
|
<Auth>
|
||||||
<FileMachineProvider>
|
<FileMachineProvider>
|
||||||
@ -127,6 +120,7 @@ const router = createRouter([
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: PATHS.HOME,
|
path: PATHS.HOME,
|
||||||
|
errorElement: <ErrorPage />,
|
||||||
element: (
|
element: (
|
||||||
<Auth>
|
<Auth>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
@ -155,6 +149,7 @@ const router = createRouter([
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: PATHS.SIGN_IN,
|
path: PATHS.SIGN_IN,
|
||||||
|
errorElement: <ErrorPage />,
|
||||||
element: <SignIn />,
|
element: <SignIn />,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -229,7 +229,7 @@ const ProjectsContextDesktop = ({
|
|||||||
const newPathName = `${PATHS.FILE}/${encodeURIComponent(
|
const newPathName = `${PATHS.FILE}/${encodeURIComponent(
|
||||||
projectPath
|
projectPath
|
||||||
)}`
|
)}`
|
||||||
console.log(newPathName,'asdf')
|
console.log(newPathName, 'asdf')
|
||||||
navigate(newPathName)
|
navigate(newPathName)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -3,25 +3,26 @@ import { systemIOActor } from '@src/machines/appMachine'
|
|||||||
import { useSelector } from '@xstate/react'
|
import { useSelector } from '@xstate/react'
|
||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
import {
|
export const useRequestedProjectName = () =>
|
||||||
NO_PROJECT_DIRECTORY,
|
useSelector(systemIOActor, (state) => state.context.requestedProjectName)
|
||||||
SystemIOMachineEvents
|
export const useProjectDirectoryPath = () =>
|
||||||
} from '@src/machines/systemIO/utils'
|
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() {
|
export function SystemIOMachineLogicListener() {
|
||||||
const requestedProjectName = useRequestedProjectName()
|
const requestedProjectName = useRequestedProjectName()
|
||||||
const projectDirectoryPath = useProjectDirectoryPath()
|
const projectDirectoryPath = useProjectDirectoryPath()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!requestedProjectName.name) {return}
|
if (!requestedProjectName.name) {
|
||||||
|
return
|
||||||
|
}
|
||||||
let projectPathWithoutSpecificKCLFile =
|
let projectPathWithoutSpecificKCLFile =
|
||||||
projectDirectoryPath + window.electron.path.sep + requestedProjectName.name
|
projectDirectoryPath +
|
||||||
|
window.electron.path.sep +
|
||||||
|
requestedProjectName.name
|
||||||
const requestedPath = `${PATHS.FILE}/${encodeURIComponent(
|
const requestedPath = `${PATHS.FILE}/${encodeURIComponent(
|
||||||
projectPathWithoutSpecificKCLFile
|
projectPathWithoutSpecificKCLFile
|
||||||
)}`
|
)}`
|
||||||
navigate(requestedPath)
|
navigate(requestedPath)
|
||||||
}, [requestedProjectName])
|
}, [requestedProjectName])
|
||||||
return null
|
return null
|
||||||
|
@ -13,7 +13,7 @@ import { settingsMachine } from '@src/machines/settingsMachine'
|
|||||||
import { systemIOMachineDesktop } from '@src/machines/systemIO/systemIOMachineDesktop'
|
import { systemIOMachineDesktop } from '@src/machines/systemIO/systemIOMachineDesktop'
|
||||||
import { SystemIOMachineEvents } from '@src/machines/systemIO/utils'
|
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 = {
|
const appMachineActors = {
|
||||||
[AUTH]: authMachine,
|
[AUTH]: authMachine,
|
||||||
[SETTINGS]: settingsMachine,
|
[SETTINGS]: settingsMachine,
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { DEFAULT_PROJECT_NAME } from '@src/lib/constants'
|
import { DEFAULT_PROJECT_NAME } from '@src/lib/constants'
|
||||||
import type { Project } from '@src/lib/project'
|
import type { Project } from '@src/lib/project'
|
||||||
import type {
|
import type { SystemIOContext } from '@src/machines/systemIO/utils'
|
||||||
SystemIOContext} from '@src/machines/systemIO/utils'
|
|
||||||
import {
|
import {
|
||||||
NO_PROJECT_DIRECTORY,
|
NO_PROJECT_DIRECTORY,
|
||||||
SystemIOMachineActions,
|
SystemIOMachineActions,
|
||||||
@ -37,7 +36,7 @@ export const systemIOMachine = setup({
|
|||||||
| {
|
| {
|
||||||
type: SystemIOMachineEvents.openProject
|
type: SystemIOMachineEvents.openProject
|
||||||
data: { requestedProjectName: string }
|
data: { requestedProjectName: string }
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
[SystemIOMachineActions.setFolders]: assign({
|
[SystemIOMachineActions.setFolders]: assign({
|
||||||
@ -58,7 +57,7 @@ export const systemIOMachine = setup({
|
|||||||
[SystemIOMachineActions.setRequestedProjectName]: assign({
|
[SystemIOMachineActions.setRequestedProjectName]: assign({
|
||||||
requestedProjectName: ({ event }) => {
|
requestedProjectName: ({ event }) => {
|
||||||
assertEvent(event, SystemIOMachineEvents.openProject)
|
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,
|
defaultProjectFolderName: DEFAULT_PROJECT_NAME,
|
||||||
projectDirectoryPath: NO_PROJECT_DIRECTORY,
|
projectDirectoryPath: NO_PROJECT_DIRECTORY,
|
||||||
hasListedProjects: false,
|
hasListedProjects: false,
|
||||||
requestedProjectName: {name:NO_PROJECT_DIRECTORY},
|
requestedProjectName: { name: NO_PROJECT_DIRECTORY },
|
||||||
}),
|
}),
|
||||||
states: {
|
states: {
|
||||||
[SystemIOMachineStates.idle]: {
|
[SystemIOMachineStates.idle]: {
|
||||||
@ -112,8 +111,7 @@ export const systemIOMachine = setup({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[SystemIOMachineStates.openingProject] : {
|
[SystemIOMachineStates.openingProject]: {},
|
||||||
}
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { getProjectInfo, mkdirOrNOOP } from '@src/lib/desktop'
|
import { getProjectInfo, mkdirOrNOOP } from '@src/lib/desktop'
|
||||||
import type { Project } from '@src/lib/project'
|
import type { Project } from '@src/lib/project'
|
||||||
import { systemIOMachine } from '@src/machines/systemIO/systemIOMachine'
|
import { systemIOMachine } from '@src/machines/systemIO/systemIOMachine'
|
||||||
import type {
|
import type { SystemIOContext } from '@src/machines/systemIO/utils'
|
||||||
SystemIOContext} from '@src/machines/systemIO/utils'
|
|
||||||
import {
|
import {
|
||||||
NO_PROJECT_DIRECTORY,
|
NO_PROJECT_DIRECTORY,
|
||||||
SystemIOMachineActors,
|
SystemIOMachineActors,
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
import type { Project } from '@src/lib/project'
|
import type { Project } from '@src/lib/project'
|
||||||
import { systemIOMachine } from '@src/machines/systemIO/systemIOMachine'
|
import { systemIOMachine } from '@src/machines/systemIO/systemIOMachine'
|
||||||
import type {
|
import type { SystemIOContext } from '@src/machines/systemIO/utils'
|
||||||
SystemIOContext} from '@src/machines/systemIO/utils'
|
import { SystemIOMachineActors } from '@src/machines/systemIO/utils'
|
||||||
import {
|
|
||||||
SystemIOMachineActors,
|
|
||||||
} from '@src/machines/systemIO/utils'
|
|
||||||
import { fromPromise } from 'xstate'
|
import { fromPromise } from 'xstate'
|
||||||
|
|
||||||
export const systemIOMachineWeb = systemIOMachine.provide({
|
export const systemIOMachineWeb = systemIOMachine.provide({
|
||||||
|
@ -9,7 +9,7 @@ export enum SystemIOMachineStates {
|
|||||||
idle = 'idle',
|
idle = 'idle',
|
||||||
readingFolders = 'readingFolders',
|
readingFolders = 'readingFolders',
|
||||||
settingProjectDirectoryPath = 'settingProjectDirectoryPath',
|
settingProjectDirectoryPath = 'settingProjectDirectoryPath',
|
||||||
openingProject = 'openingProject'
|
openingProject = 'openingProject',
|
||||||
}
|
}
|
||||||
|
|
||||||
const donePrefix = 'xstate.done.actor.'
|
const donePrefix = 'xstate.done.actor.'
|
||||||
@ -41,5 +41,5 @@ export type SystemIOContext = {
|
|||||||
// has the application gone through the initialiation of systemIOMachine at least once.
|
// has the application gone through the initialiation of systemIOMachine at least once.
|
||||||
// this is required to prevent chokidar from spamming invalid events during initialization.
|
// this is required to prevent chokidar from spamming invalid events during initialization.
|
||||||
hasListedProjects: boolean
|
hasListedProjects: boolean
|
||||||
requestedProjectName: {name: string}
|
requestedProjectName: { name: string }
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user