* Get electron building something at all * Merge Frank test setup work (#3418) * Working window.electron.getPath * Loading project-specific settings in electron tests * Simplify test until we can get snapshots/traces working in electron tests * test tweaks --------- Co-authored-by: Frank Noirot <frank@kittycad.io> * add test #3375 and #3420 * put kcl files together * move files * can sort projects #3362 * File in the file pane should open with a single click #3385 * pressing delete on home screen should do nothing #3387 * add aria labels to icons * Rename and delete projects, also spam arrow keys when renaming #3364 #3365 #3259 * Fix up paths * Update flake.nix to support Electron * Remove a layer of indirection * Work without a web server * Fix settings#projectDir link on home * Fix login (requires new @kittycad/lib WHICH IS NOT INCLUDED HERE) * Lee: Tests are broken because auth skip needs to happen * get setting override envs passed through * tweak eletron CI * yml tweak * fmt * NUKE tauri shit post merge with main * another test auth tweak * Revert "another test auth tweak" This reverts commitb2254b10af
. * try CI again * CI tweaks * SKIP_AUTH true now on playwright * Skipping auth when NODE_ENV=development now * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * Use BASE_URL() * fix exists Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix foldername for macos Signed-off-by: Jess Frazelle <github@jessfraz.com> * update for windows Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix version in lower right Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup unused imports Signed-off-by: Jess Frazelle <github@jessfraz.com> * progress on is playwright Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix test folders Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove tauri from actions bullshit Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove tauri dir Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixups the coredump async shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * node env dev Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix cancellable Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup unnessary things Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix Signed-off-by: Jess Frazelle <github@jessfraz.com> * env vars Signed-off-by: Jess Frazelle <github@jessfraz.com> * Bring back fix for NOT using hardcoded main.kcl * env Signed-off-by: Jess Frazelle <github@jessfraz.com> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * Revert "updates" This reverts commit da5d9f1043eb94404e8b3f8044088e990e34a4ef. * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove tauri clippuy Signed-off-by: Jess Frazelle <github@jessfraz.com> * less retries for now, no debug Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * tsconfig Signed-off-by: Jess Frazelle <github@jessfraz.com> * small tsc fix * update some tsc Signed-off-by: Jess Frazelle <github@jessfraz.com> * tsc env Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix other tsc Signed-off-by: Jess Frazelle <github@jessfraz.com> * small change for routeLoaders * rm old screenshot Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix auth Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix last onew Signed-off-by: Jess Frazelle <github@jessfraz.com> * auth clean up * fix package.json Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix Signed-off-by: Jess Frazelle <github@jessfraz.com> * dissmissed screen on tests * add waits between files being written * put back retried Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix weird programMemory Map issue * put private back * Revert "put private back" This reverts commitd311b978ca
. * Revert "fix weird programMemory Map issue" This reverts commit6c387bdf62
. * remove serde-wasm-bindgen Signed-off-by: Jess Frazelle <github@jessfraz.com> * add env Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fix tests * more test tweaks * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * another tweak * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * more test tweaks * more tweaks * increase macos timeout * try fix macos * disable macos playwright tests --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch> Co-authored-by: Frank Noirot <frank@kittycad.io> Co-authored-by: Adam Sunderland <iterion@gmail.com> Co-authored-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
136 lines
4.3 KiB
TypeScript
136 lines
4.3 KiB
TypeScript
import { MouseEventHandler, useEffect, useMemo, useRef } from 'react'
|
|
import { uuidv4 } from 'lib/utils'
|
|
import { useHotKeyListener } from './hooks/useHotKeyListener'
|
|
import { Stream } from './components/Stream'
|
|
import { EngineCommand } from 'lang/std/artifactGraph'
|
|
import { throttle } from './lib/utils'
|
|
import { AppHeader } from './components/AppHeader'
|
|
import { useHotkeys } from 'react-hotkeys-hook'
|
|
import { getNormalisedCoordinates } from './lib/utils'
|
|
import { useLoaderData, useNavigate } from 'react-router-dom'
|
|
import { type IndexLoaderData } from 'lib/types'
|
|
import { PATHS } from 'lib/paths'
|
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
|
import { onboardingPaths } from 'routes/Onboarding/paths'
|
|
import { useEngineConnectionSubscriptions } from 'hooks/useEngineConnectionSubscriptions'
|
|
import { codeManager, engineCommandManager } from 'lib/singletons'
|
|
import { useModelingContext } from 'hooks/useModelingContext'
|
|
import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath'
|
|
import { isDesktop } from 'lib/isDesktop'
|
|
import { useLspContext } from 'components/LspProvider'
|
|
import { useRefreshSettings } from 'hooks/useRefreshSettings'
|
|
import { ModelingSidebar } from 'components/ModelingSidebar/ModelingSidebar'
|
|
import { LowerRightControls } from 'components/LowerRightControls'
|
|
import ModalContainer from 'react-modal-promise'
|
|
import useHotkeyWrapper from 'lib/hotkeyWrapper'
|
|
import Gizmo from 'components/Gizmo'
|
|
import { CoreDumpManager } from 'lib/coredump'
|
|
import { UnitsMenu } from 'components/UnitsMenu'
|
|
|
|
export function App() {
|
|
const { project, file } = useLoaderData() as IndexLoaderData
|
|
useRefreshSettings(PATHS.FILE + 'SETTINGS')
|
|
const navigate = useNavigate()
|
|
const filePath = useAbsoluteFilePath()
|
|
const { onProjectOpen } = useLspContext()
|
|
// We need the ref for the outermost div so we can screenshot the app for
|
|
// the coredump.
|
|
const ref = useRef<HTMLDivElement>(null)
|
|
|
|
const projectName = project?.name || null
|
|
const projectPath = project?.path || null
|
|
useEffect(() => {
|
|
onProjectOpen({ name: projectName, path: projectPath }, file || null)
|
|
}, [projectName, projectPath])
|
|
|
|
useHotKeyListener()
|
|
const { context, state } = useModelingContext()
|
|
|
|
const { auth, settings } = useSettingsAuthContext()
|
|
const token = auth?.context?.token
|
|
|
|
const coreDumpManager = useMemo(
|
|
() => new CoreDumpManager(engineCommandManager, codeManager, token),
|
|
[]
|
|
)
|
|
|
|
const {
|
|
app: { onboardingStatus },
|
|
} = settings.context
|
|
|
|
useHotkeys('backspace', (e) => {
|
|
e.preventDefault()
|
|
})
|
|
useHotkeyWrapper(
|
|
[isDesktop() ? 'mod + ,' : 'shift + mod + ,'],
|
|
() => navigate(filePath + PATHS.SETTINGS),
|
|
{
|
|
splitKey: '|',
|
|
}
|
|
)
|
|
|
|
const paneOpacity = [onboardingPaths.CAMERA, onboardingPaths.STREAMING].some(
|
|
(p) => p === onboardingStatus.current
|
|
)
|
|
? 'opacity-20'
|
|
: context.store?.didDragInStream
|
|
? 'opacity-40'
|
|
: ''
|
|
|
|
useEngineConnectionSubscriptions()
|
|
|
|
const debounceSocketSend = throttle<EngineCommand>((message) => {
|
|
engineCommandManager.sendSceneCommand(message)
|
|
}, 1000 / 15)
|
|
const handleMouseMove: MouseEventHandler<HTMLDivElement> = (e) => {
|
|
if (state.matches('Sketch')) {
|
|
return
|
|
}
|
|
|
|
const { x, y } = getNormalisedCoordinates({
|
|
clientX: e.clientX,
|
|
clientY: e.clientY,
|
|
el: e.currentTarget,
|
|
...context.store?.streamDimensions,
|
|
})
|
|
|
|
const newCmdId = uuidv4()
|
|
if (state.matches('idle.showPlanes')) return
|
|
if (context.store?.buttonDownInStream !== undefined) return
|
|
debounceSocketSend({
|
|
type: 'modeling_cmd_req',
|
|
cmd: {
|
|
type: 'highlight_set_entity',
|
|
selected_at_window: { x, y },
|
|
},
|
|
cmd_id: newCmdId,
|
|
})
|
|
}
|
|
|
|
return (
|
|
<div
|
|
className="relative h-full flex flex-col"
|
|
onMouseMove={handleMouseMove}
|
|
ref={ref}
|
|
>
|
|
<AppHeader
|
|
className={
|
|
'transition-opacity transition-duration-75 ' +
|
|
paneOpacity +
|
|
(context.store?.buttonDownInStream ? ' pointer-events-none' : '')
|
|
}
|
|
project={{ project, file }}
|
|
enableMenu={true}
|
|
/>
|
|
<ModalContainer />
|
|
<ModelingSidebar paneOpacity={paneOpacity} />
|
|
<Stream />
|
|
{/* <CamToggle /> */}
|
|
<LowerRightControls coreDumpManager={coreDumpManager}>
|
|
<UnitsMenu />
|
|
<Gizmo />
|
|
</LowerRightControls>
|
|
</div>
|
|
)
|
|
}
|