diff --git a/package.json b/package.json index 48aaa955f..82fa3bac1 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "@fortawesome/react-fontawesome": "^0.2.0", "@headlessui/react": "^1.7.13", "@headlessui/tailwindcss": "^0.2.0", - "@kittycad/lib": "^0.0.38", + "@kittycad/lib": "^0.0.39", "@lezer/javascript": "^1.4.7", "@open-rpc/client-js": "^1.8.1", "@react-hook/resize-observer": "^1.2.6", @@ -27,6 +27,7 @@ "@uiw/react-codemirror": "^4.21.13", "@xstate/react": "^3.2.2", "crypto-js": "^4.1.1", + "debounce": "^1.2.1", "debounce-promise": "^3.1.2", "formik": "^2.4.3", "fuse.js": "^6.6.2", diff --git a/src/App.tsx b/src/App.tsx index beec95624..6313e8d08 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -31,6 +31,7 @@ import { TextEditor } from 'components/TextEditor' import { Themes, getSystemTheme } from 'lib/theme' import { useSetupEngineManager } from 'hooks/useSetupEngineManager' import { useEngineConnectionSubscriptions } from 'hooks/useEngineConnectionSubscriptions' +import { engineCommandManager } from './lang/std/engineConnection' export function App() { const { code: loadedCode, project } = useLoaderData() as IndexLoaderData @@ -39,7 +40,6 @@ export function App() { useHotKeyListener() const { setCode, - engineCommandManager, buttonDownInStream, openPanes, setOpenPanes, @@ -52,7 +52,6 @@ export function App() { guiMode: s.guiMode, setGuiMode: s.setGuiMode, setCode: s.setCode, - engineCommandManager: s.engineCommandManager, buttonDownInStream: s.buttonDownInStream, openPanes: s.openPanes, setOpenPanes: s.setOpenPanes, @@ -91,12 +90,12 @@ export function App() { if (guiMode.sketchMode === 'sketchEdit') { // TODO: share this with Toolbar's "Exit sketch" button // exiting sketch should be done consistently across all exits - engineCommandManager?.sendSceneCommand({ + engineCommandManager.sendSceneCommand({ type: 'modeling_cmd_req', cmd_id: uuidv4(), cmd: { type: 'edit_mode_exit' }, }) - engineCommandManager?.sendSceneCommand({ + engineCommandManager.sendSceneCommand({ type: 'modeling_cmd_req', cmd_id: uuidv4(), cmd: { type: 'default_camera_disable_sketch_mode' }, @@ -107,7 +106,7 @@ export function App() { // when exiting sketch mode in the future executeAst() } else { - engineCommandManager?.sendSceneCommand({ + engineCommandManager.sendSceneCommand({ type: 'modeling_cmd_req', cmd_id: uuidv4(), cmd: { @@ -156,7 +155,7 @@ export function App() { useEngineConnectionSubscriptions() const debounceSocketSend = throttle((message) => { - engineCommandManager?.sendSceneCommand(message) + engineCommandManager.sendSceneCommand(message) }, 16) const handleMouseMove: MouseEventHandler = (e) => { e.nativeEvent.preventDefault() diff --git a/src/Toolbar.tsx b/src/Toolbar.tsx index 1e57f2206..3e873bcb9 100644 --- a/src/Toolbar.tsx +++ b/src/Toolbar.tsx @@ -18,6 +18,7 @@ import styles from './Toolbar.module.css' import { v4 as uuidv4 } from 'uuid' import { useAppMode } from 'hooks/useAppMode' import { ActionIcon } from 'components/ActionIcon' +import { engineCommandManager } from './lang/std/engineConnection' export const sketchButtonClassnames = { background: @@ -50,7 +51,6 @@ export const Toolbar = () => { ast, updateAst, programMemory, - engineCommandManager, executeAst, } = useStore((s) => ({ guiMode: s.guiMode, @@ -59,7 +59,6 @@ export const Toolbar = () => { ast: s.ast, updateAst: s.updateAst, programMemory: s.programMemory, - engineCommandManager: s.engineCommandManager, executeAst: s.executeAst, })) useAppMode() @@ -169,12 +168,12 @@ export const Toolbar = () => { {guiMode.mode === 'sketch' && (