2024-09-12 22:06:50 -04:00
|
|
|
import { useEffect, useMemo, useRef } from 'react'
|
2023-02-21 10:28:34 +11:00
|
|
|
import { useHotKeyListener } from './hooks/useHotKeyListener'
|
2023-03-06 20:13:34 +11:00
|
|
|
import { Stream } from './components/Stream'
|
2023-07-13 07:22:08 -04:00
|
|
|
import { AppHeader } from './components/AppHeader'
|
2023-08-06 21:29:26 -04:00
|
|
|
import { useHotkeys } from 'react-hotkeys-hook'
|
2024-02-12 18:11:47 -05:00
|
|
|
import { useLoaderData, useNavigate } from 'react-router-dom'
|
|
|
|
import { type IndexLoaderData } from 'lib/types'
|
2024-08-09 02:47:25 -04:00
|
|
|
import { PATHS } from 'lib/paths'
|
2024-03-11 20:26:13 -04:00
|
|
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
2024-02-11 12:59:00 +11:00
|
|
|
import { onboardingPaths } from 'routes/Onboarding/paths'
|
2023-09-15 04:35:48 -07:00
|
|
|
import { useEngineConnectionSubscriptions } from 'hooks/useEngineConnectionSubscriptions'
|
2024-08-14 17:56:28 -07:00
|
|
|
import { codeManager, engineCommandManager } from 'lib/singletons'
|
2024-02-12 18:11:47 -05:00
|
|
|
import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath'
|
2024-08-16 07:15:42 -04:00
|
|
|
import { isDesktop } from 'lib/isDesktop'
|
2024-03-11 17:50:31 -07:00
|
|
|
import { useLspContext } from 'components/LspProvider'
|
2024-04-02 10:29:34 -04:00
|
|
|
import { useRefreshSettings } from 'hooks/useRefreshSettings'
|
2024-04-15 12:04:17 -04:00
|
|
|
import { ModelingSidebar } from 'components/ModelingSidebar/ModelingSidebar'
|
2024-04-19 10:50:58 -04:00
|
|
|
import { LowerRightControls } from 'components/LowerRightControls'
|
2024-04-18 20:09:40 -07:00
|
|
|
import ModalContainer from 'react-modal-promise'
|
2024-05-20 20:52:33 -07:00
|
|
|
import useHotkeyWrapper from 'lib/hotkeyWrapper'
|
2024-05-24 13:00:15 +10:00
|
|
|
import Gizmo from 'components/Gizmo'
|
2024-06-28 18:06:40 -07:00
|
|
|
import { CoreDumpManager } from 'lib/coredump'
|
2024-07-05 18:40:43 -04:00
|
|
|
import { UnitsMenu } from 'components/UnitsMenu'
|
2022-11-22 09:06:08 +11:00
|
|
|
|
2023-06-22 16:43:33 +10:00
|
|
|
export function App() {
|
2023-11-07 14:29:50 +11:00
|
|
|
const { project, file } = useLoaderData() as IndexLoaderData
|
2024-08-16 07:15:42 -04:00
|
|
|
useRefreshSettings(PATHS.FILE + 'SETTINGS')
|
2024-02-12 18:11:47 -05:00
|
|
|
const navigate = useNavigate()
|
|
|
|
const filePath = useAbsoluteFilePath()
|
2024-03-11 17:50:31 -07:00
|
|
|
const { onProjectOpen } = useLspContext()
|
2024-04-11 13:15:49 -07:00
|
|
|
// We need the ref for the outermost div so we can screenshot the app for
|
|
|
|
// the coredump.
|
|
|
|
const ref = useRef<HTMLDivElement>(null)
|
2024-03-11 17:50:31 -07:00
|
|
|
|
2024-03-12 23:57:43 -07:00
|
|
|
const projectName = project?.name || null
|
|
|
|
const projectPath = project?.path || null
|
2024-03-11 17:50:31 -07:00
|
|
|
useEffect(() => {
|
2024-03-12 23:57:43 -07:00
|
|
|
onProjectOpen({ name: projectName, path: projectPath }, file || null)
|
|
|
|
}, [projectName, projectPath])
|
2023-09-09 01:38:36 -04:00
|
|
|
|
2023-02-21 10:28:34 +11:00
|
|
|
useHotKeyListener()
|
2024-04-11 13:15:49 -07:00
|
|
|
|
2024-06-28 18:06:40 -07:00
|
|
|
const { auth, settings } = useSettingsAuthContext()
|
|
|
|
const token = auth?.context?.token
|
|
|
|
|
2024-07-03 09:22:46 +10:00
|
|
|
const coreDumpManager = useMemo(
|
2024-08-14 17:56:28 -07:00
|
|
|
() => new CoreDumpManager(engineCommandManager, codeManager, token),
|
2024-07-03 09:22:46 +10:00
|
|
|
[]
|
|
|
|
)
|
2024-06-28 18:06:40 -07:00
|
|
|
|
2024-04-02 10:29:34 -04:00
|
|
|
const {
|
2024-04-15 12:04:17 -04:00
|
|
|
app: { onboardingStatus },
|
2024-04-02 10:29:34 -04:00
|
|
|
} = settings.context
|
2023-08-06 21:29:26 -04:00
|
|
|
|
2024-02-15 14:25:26 -05:00
|
|
|
useHotkeys('backspace', (e) => {
|
|
|
|
e.preventDefault()
|
|
|
|
})
|
2024-05-20 20:52:33 -07:00
|
|
|
useHotkeyWrapper(
|
2024-08-16 07:15:42 -04:00
|
|
|
[isDesktop() ? 'mod + ,' : 'shift + mod + ,'],
|
2024-08-09 02:47:25 -04:00
|
|
|
() => navigate(filePath + PATHS.SETTINGS),
|
2024-02-12 18:11:47 -05:00
|
|
|
{
|
|
|
|
splitKey: '|',
|
|
|
|
}
|
|
|
|
)
|
2023-08-06 21:29:26 -04:00
|
|
|
|
2023-09-15 22:37:40 -04:00
|
|
|
const paneOpacity = [onboardingPaths.CAMERA, onboardingPaths.STREAMING].some(
|
2024-04-02 10:29:34 -04:00
|
|
|
(p) => p === onboardingStatus.current
|
2023-09-15 22:37:40 -04:00
|
|
|
)
|
|
|
|
? 'opacity-20'
|
|
|
|
: ''
|
2023-08-06 21:29:26 -04:00
|
|
|
|
2023-09-15 04:35:48 -07:00
|
|
|
useEngineConnectionSubscriptions()
|
2023-07-31 06:33:10 -04:00
|
|
|
|
2022-11-12 13:11:54 +11:00
|
|
|
return (
|
2024-09-12 22:06:50 -04:00
|
|
|
<div className="relative h-full flex flex-col" ref={ref}>
|
2023-08-06 21:29:26 -04:00
|
|
|
<AppHeader
|
2024-09-12 22:06:50 -04:00
|
|
|
className={'transition-opacity transition-duration-75 ' + paneOpacity}
|
2023-10-16 13:28:41 -04:00
|
|
|
project={{ project, file }}
|
2023-08-18 10:27:01 -04:00
|
|
|
enableMenu={true}
|
2023-08-06 21:29:26 -04:00
|
|
|
/>
|
2024-04-18 20:09:40 -07:00
|
|
|
<ModalContainer />
|
2024-04-15 12:04:17 -04:00
|
|
|
<ModelingSidebar paneOpacity={paneOpacity} />
|
2024-06-18 16:08:41 +10:00
|
|
|
<Stream />
|
2024-02-11 12:59:00 +11:00
|
|
|
{/* <CamToggle /> */}
|
2024-06-28 18:06:40 -07:00
|
|
|
<LowerRightControls coreDumpManager={coreDumpManager}>
|
2024-07-05 18:40:43 -04:00
|
|
|
<UnitsMenu />
|
2024-05-24 13:00:15 +10:00
|
|
|
<Gizmo />
|
|
|
|
</LowerRightControls>
|
2022-11-12 13:11:54 +11:00
|
|
|
</div>
|
2022-11-26 08:34:23 +11:00
|
|
|
)
|
2022-11-12 13:11:54 +11:00
|
|
|
}
|