2023-10-11 13:36:54 +11:00
|
|
|
import { useMachine } from '@xstate/react'
|
|
|
|
import React, { createContext, useEffect, useRef } from 'react'
|
|
|
|
import {
|
|
|
|
AnyStateMachine,
|
|
|
|
ContextFrom,
|
|
|
|
InterpreterFrom,
|
|
|
|
Prop,
|
|
|
|
StateFrom,
|
|
|
|
assign,
|
|
|
|
} from 'xstate'
|
|
|
|
import { SetSelections, modelingMachine } from 'machines/modelingMachine'
|
|
|
|
import { useSetupEngineManager } from 'hooks/useSetupEngineManager'
|
2024-03-11 20:26:13 -04:00
|
|
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
2023-10-11 15:12:29 +11:00
|
|
|
import { isCursorInSketchCommandRange } from 'lang/util'
|
2023-10-11 13:36:54 +11:00
|
|
|
import { engineCommandManager } from 'lang/std/engineConnection'
|
2024-02-11 12:59:00 +11:00
|
|
|
import { kclManager, useKclContext } from 'lang/KclSingleton'
|
2023-10-11 13:36:54 +11:00
|
|
|
import { applyConstraintHorzVertDistance } from './Toolbar/SetHorzVertDistance'
|
2023-12-01 20:18:51 +11:00
|
|
|
import {
|
|
|
|
angleBetweenInfo,
|
|
|
|
applyConstraintAngleBetween,
|
|
|
|
} from './Toolbar/SetAngleBetween'
|
2023-10-11 13:36:54 +11:00
|
|
|
import { applyConstraintAngleLength } from './Toolbar/setAngleLength'
|
|
|
|
import { pathMapToSelections } from 'lang/util'
|
2023-10-16 21:20:05 +11:00
|
|
|
import { useStore } from 'useStore'
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
import {
|
|
|
|
canExtrudeSelection,
|
|
|
|
handleSelectionBatch,
|
|
|
|
handleSelectionWithShift,
|
|
|
|
isSelectionLastLine,
|
|
|
|
isSketchPipe,
|
|
|
|
} from 'lib/selections'
|
2023-10-16 08:54:38 +11:00
|
|
|
import { applyConstraintIntersect } from './Toolbar/Intersect'
|
2023-12-01 20:18:51 +11:00
|
|
|
import { applyConstraintAbsDistance } from './Toolbar/SetAbsDistance'
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
import useStateMachineCommands from 'hooks/useStateMachineCommands'
|
|
|
|
import { modelingMachineConfig } from 'lib/commandBarConfigs/modelingCommandConfig'
|
2024-02-14 08:03:20 +11:00
|
|
|
import { sceneInfra } from 'clientSideScene/sceneInfra'
|
|
|
|
import { getSketchQuaternion } from 'clientSideScene/sceneEntities'
|
2024-02-11 12:59:00 +11:00
|
|
|
import { startSketchOnDefault } from 'lang/modifyAst'
|
2024-02-14 05:35:05 +11:00
|
|
|
import { Program } from 'lang/wasm'
|
2024-02-19 17:23:03 +11:00
|
|
|
import { isSingleCursorInPipe } from 'lang/queryAst'
|
2024-03-04 16:06:43 -05:00
|
|
|
import { TEST } from 'env'
|
|
|
|
import { exportFromEngine } from 'lib/exportFromEngine'
|
|
|
|
import { Models } from '@kittycad/lib/dist/types/src'
|
|
|
|
import toast from 'react-hot-toast'
|
2023-10-11 13:36:54 +11:00
|
|
|
|
|
|
|
type MachineContext<T extends AnyStateMachine> = {
|
|
|
|
state: StateFrom<T>
|
|
|
|
context: ContextFrom<T>
|
|
|
|
send: Prop<InterpreterFrom<T>, 'send'>
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ModelingMachineContext = createContext(
|
|
|
|
{} as MachineContext<typeof modelingMachine>
|
|
|
|
)
|
|
|
|
|
|
|
|
export const ModelingMachineProvider = ({
|
|
|
|
children,
|
|
|
|
}: {
|
|
|
|
children: React.ReactNode
|
|
|
|
}) => {
|
2024-03-04 16:06:43 -05:00
|
|
|
const {
|
|
|
|
auth,
|
|
|
|
settings: {
|
|
|
|
context: { baseUnit },
|
|
|
|
},
|
2024-03-11 20:26:13 -04:00
|
|
|
} = useSettingsAuthContext()
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
const { code } = useKclContext()
|
2023-10-11 13:36:54 +11:00
|
|
|
const token = auth?.context?.token
|
|
|
|
const streamRef = useRef<HTMLDivElement>(null)
|
|
|
|
useSetupEngineManager(streamRef, token)
|
|
|
|
|
|
|
|
const { isShiftDown, editorView } = useStore((s) => ({
|
|
|
|
isShiftDown: s.isShiftDown,
|
|
|
|
editorView: s.editorView,
|
|
|
|
}))
|
|
|
|
|
|
|
|
// Settings machine setup
|
|
|
|
// const retrievedSettings = useRef(
|
|
|
|
// localStorage?.getItem(MODELING_PERSIST_KEY) || '{}'
|
|
|
|
// )
|
|
|
|
|
|
|
|
// What should we persist from modeling state? Nothing?
|
|
|
|
// const persistedSettings = Object.assign(
|
|
|
|
// settingsMachine.initialState.context,
|
|
|
|
// JSON.parse(retrievedSettings.current) as Partial<
|
|
|
|
// (typeof settingsMachine)['context']
|
|
|
|
// >
|
|
|
|
// )
|
|
|
|
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
const [modelingState, modelingSend, modelingActor] = useMachine(
|
|
|
|
modelingMachine,
|
|
|
|
{
|
|
|
|
actions: {
|
|
|
|
'sketch exit execute': () => {
|
2024-02-11 12:59:00 +11:00
|
|
|
kclManager.executeAst()
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
},
|
|
|
|
'Set selection': assign(({ selectionRanges }, event) => {
|
|
|
|
if (event.type !== 'Set selection') return {} // this was needed for ts after adding 'Set selection' action to on done modal events
|
|
|
|
const setSelections = event.data
|
|
|
|
if (!editorView) return {}
|
|
|
|
if (setSelections.selectionType === 'mirrorCodeMirrorSelections')
|
|
|
|
return { selectionRanges: setSelections.selection }
|
|
|
|
else if (setSelections.selectionType === 'otherSelection') {
|
|
|
|
const {
|
|
|
|
codeMirrorSelection,
|
|
|
|
selectionRangeTypeMap,
|
|
|
|
otherSelections,
|
|
|
|
} = handleSelectionWithShift({
|
|
|
|
otherSelection: setSelections.selection,
|
|
|
|
currentSelections: selectionRanges,
|
|
|
|
isShiftDown,
|
|
|
|
})
|
2023-10-16 21:20:05 +11:00
|
|
|
setTimeout(() => {
|
|
|
|
editorView.dispatch({
|
|
|
|
selection: codeMirrorSelection,
|
|
|
|
})
|
|
|
|
})
|
2023-12-01 20:18:51 +11:00
|
|
|
return {
|
|
|
|
selectionRangeTypeMap,
|
|
|
|
selectionRanges: {
|
|
|
|
codeBasedSelections: selectionRanges.codeBasedSelections,
|
|
|
|
otherSelections,
|
|
|
|
},
|
|
|
|
}
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
} else if (setSelections.selectionType === 'singleCodeCursor') {
|
|
|
|
// This DOES NOT set the `selectionRanges` in xstate context
|
|
|
|
// instead it updates/dispatches to the editor, which in turn updates the xstate context
|
|
|
|
// I've found this the best way to deal with the editor without causing an infinite loop
|
|
|
|
// and really we want the editor to be in charge of cursor positions and for `selectionRanges` mirror it
|
|
|
|
// because we want to respect the user manually placing the cursor too.
|
|
|
|
|
|
|
|
// for more details on how selections see `src/lib/selections.ts`.
|
|
|
|
|
|
|
|
const {
|
|
|
|
codeMirrorSelection,
|
|
|
|
selectionRangeTypeMap,
|
2023-12-01 20:18:51 +11:00
|
|
|
otherSelections,
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
} = handleSelectionWithShift({
|
|
|
|
codeSelection: setSelections.selection,
|
|
|
|
currentSelections: selectionRanges,
|
|
|
|
isShiftDown,
|
|
|
|
})
|
|
|
|
if (codeMirrorSelection) {
|
|
|
|
setTimeout(() => {
|
|
|
|
editorView.dispatch({
|
|
|
|
selection: codeMirrorSelection,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if (!setSelections.selection) {
|
|
|
|
return {
|
|
|
|
selectionRangeTypeMap,
|
|
|
|
selectionRanges: {
|
|
|
|
codeBasedSelections: selectionRanges.codeBasedSelections,
|
|
|
|
otherSelections,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
selectionRangeTypeMap,
|
|
|
|
selectionRanges: {
|
|
|
|
codeBasedSelections: selectionRanges.codeBasedSelections,
|
|
|
|
otherSelections,
|
|
|
|
},
|
|
|
|
}
|
2023-12-01 20:18:51 +11:00
|
|
|
}
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
// This DOES NOT set the `selectionRanges` in xstate context
|
|
|
|
// same as comment above
|
|
|
|
const { codeMirrorSelection, selectionRangeTypeMap } =
|
|
|
|
handleSelectionBatch({
|
|
|
|
selections: setSelections.selection,
|
2023-10-16 21:20:05 +11:00
|
|
|
})
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
if (codeMirrorSelection) {
|
|
|
|
setTimeout(() => {
|
|
|
|
editorView.dispatch({
|
|
|
|
selection: codeMirrorSelection,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return { selectionRangeTypeMap }
|
|
|
|
}),
|
2024-03-04 16:06:43 -05:00
|
|
|
'Engine export': (_, event) => {
|
|
|
|
if (event.type !== 'Export' || TEST) return
|
|
|
|
const format = {
|
|
|
|
...event.data,
|
|
|
|
} as Partial<Models['OutputFormat_type']>
|
|
|
|
|
|
|
|
// Set all the un-configurable defaults here.
|
|
|
|
if (format.type === 'gltf') {
|
|
|
|
format.presentation = 'pretty'
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
format.type === 'obj' ||
|
|
|
|
format.type === 'ply' ||
|
|
|
|
format.type === 'step' ||
|
|
|
|
format.type === 'stl'
|
|
|
|
) {
|
|
|
|
// Set the default coords.
|
|
|
|
// In the future we can make this configurable.
|
|
|
|
// But for now, its probably best to keep it consistent with the
|
|
|
|
// UI.
|
|
|
|
format.coords = {
|
|
|
|
forward: {
|
|
|
|
axis: 'y',
|
|
|
|
direction: 'negative',
|
|
|
|
},
|
|
|
|
up: {
|
|
|
|
axis: 'z',
|
|
|
|
direction: 'positive',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
format.type === 'obj' ||
|
|
|
|
format.type === 'stl' ||
|
|
|
|
format.type === 'ply'
|
|
|
|
) {
|
|
|
|
format.units = baseUnit
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format.type === 'ply' || format.type === 'stl') {
|
|
|
|
format.selection = { type: 'default_scene' }
|
|
|
|
}
|
|
|
|
|
|
|
|
exportFromEngine({
|
|
|
|
source_unit: baseUnit,
|
|
|
|
format: format as Models['OutputFormat_type'],
|
|
|
|
}).catch((e) => toast.error('Error while exporting', e)) // TODO I think we need to throw the error from engineCommandManager
|
|
|
|
},
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
guards: {
|
|
|
|
'has valid extrude selection': ({ selectionRanges }) => {
|
|
|
|
// A user can begin extruding if they either have 1+ faces selected or nothing selected
|
|
|
|
// TODO: I believe this guard only allows for extruding a single face at a time
|
|
|
|
if (selectionRanges.codeBasedSelections.length < 1) return false
|
|
|
|
const isPipe = isSketchPipe(selectionRanges)
|
|
|
|
|
|
|
|
if (isSelectionLastLine(selectionRanges, code)) return true
|
|
|
|
if (!isPipe) return false
|
|
|
|
|
|
|
|
return canExtrudeSelection(selectionRanges)
|
|
|
|
},
|
2024-02-19 17:23:03 +11:00
|
|
|
'Selection is on face': ({ selectionRanges }, { data }) => {
|
|
|
|
if (data?.forceNewSketch) return false
|
|
|
|
if (!isSingleCursorInPipe(selectionRanges, kclManager.ast))
|
|
|
|
return false
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
return !!isCursorInSketchCommandRange(
|
|
|
|
engineCommandManager.artifactMap,
|
|
|
|
selectionRanges
|
|
|
|
)
|
|
|
|
},
|
2024-03-04 16:06:43 -05:00
|
|
|
'Has exportable geometry': () =>
|
|
|
|
kclManager.kclErrors.length === 0 && kclManager.ast.body.length > 0,
|
2023-10-11 13:36:54 +11:00
|
|
|
},
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
services: {
|
2024-02-14 05:35:05 +11:00
|
|
|
'AST-undo-startSketchOn': async ({ sketchPathToNode }) => {
|
|
|
|
if (!sketchPathToNode) return
|
|
|
|
const newAst: Program = JSON.parse(JSON.stringify(kclManager.ast))
|
|
|
|
const varDecIndex = sketchPathToNode[1][0]
|
|
|
|
// remove body item at varDecIndex
|
|
|
|
newAst.body = newAst.body.filter((_, i) => i !== varDecIndex)
|
|
|
|
await kclManager.executeAstMock(newAst, { updates: 'code' })
|
2024-02-14 08:03:20 +11:00
|
|
|
sceneInfra.setCallbacks({
|
2024-02-14 05:35:05 +11:00
|
|
|
onClick: () => {},
|
2024-02-19 12:41:36 +11:00
|
|
|
onDrag: () => {},
|
2024-02-14 05:35:05 +11:00
|
|
|
})
|
|
|
|
},
|
2024-02-11 12:59:00 +11:00
|
|
|
'animate-to-face': async (_, { data: { plane, normal } }) => {
|
|
|
|
const { modifiedAst, pathToNode } = startSketchOnDefault(
|
|
|
|
kclManager.ast,
|
|
|
|
plane
|
|
|
|
)
|
|
|
|
await kclManager.updateAst(modifiedAst, false)
|
|
|
|
const quaternion = getSketchQuaternion(pathToNode, normal)
|
2024-02-26 19:53:44 +11:00
|
|
|
await sceneInfra.camControls.tweenCameraToQuaternion(quaternion)
|
2024-02-11 12:59:00 +11:00
|
|
|
return {
|
|
|
|
sketchPathToNode: pathToNode,
|
|
|
|
sketchNormalBackUp: normal,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'animate-to-sketch': async ({
|
|
|
|
sketchPathToNode,
|
|
|
|
sketchNormalBackUp,
|
|
|
|
}) => {
|
|
|
|
const quaternion = getSketchQuaternion(
|
|
|
|
sketchPathToNode || [],
|
|
|
|
sketchNormalBackUp
|
|
|
|
)
|
2024-02-26 19:53:44 +11:00
|
|
|
await sceneInfra.camControls.tweenCameraToQuaternion(quaternion)
|
2024-02-11 12:59:00 +11:00
|
|
|
},
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
'Get horizontal info': async ({
|
2023-12-01 20:18:51 +11:00
|
|
|
selectionRanges,
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
}): Promise<SetSelections> => {
|
|
|
|
const { modifiedAst, pathToNodeMap } =
|
|
|
|
await applyConstraintHorzVertDistance({
|
|
|
|
constraint: 'setHorzDistance',
|
2023-12-01 20:18:51 +11:00
|
|
|
selectionRanges,
|
|
|
|
})
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
await kclManager.updateAst(modifiedAst, true)
|
|
|
|
return {
|
|
|
|
selectionType: 'completeSelection',
|
|
|
|
selection: pathMapToSelections(
|
|
|
|
kclManager.ast,
|
2023-12-01 20:18:51 +11:00
|
|
|
selectionRanges,
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
pathToNodeMap
|
|
|
|
),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'Get vertical info': async ({
|
2023-10-16 08:54:38 +11:00
|
|
|
selectionRanges,
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
}): Promise<SetSelections> => {
|
|
|
|
const { modifiedAst, pathToNodeMap } =
|
|
|
|
await applyConstraintHorzVertDistance({
|
|
|
|
constraint: 'setVertDistance',
|
|
|
|
selectionRanges,
|
|
|
|
})
|
|
|
|
await kclManager.updateAst(modifiedAst, true)
|
|
|
|
return {
|
|
|
|
selectionType: 'completeSelection',
|
|
|
|
selection: pathMapToSelections(
|
|
|
|
kclManager.ast,
|
|
|
|
selectionRanges,
|
|
|
|
pathToNodeMap
|
|
|
|
),
|
2023-12-01 20:18:51 +11:00
|
|
|
}
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
},
|
|
|
|
'Get angle info': async ({
|
|
|
|
selectionRanges,
|
|
|
|
}): Promise<SetSelections> => {
|
|
|
|
const { modifiedAst, pathToNodeMap } = await (angleBetweenInfo({
|
2023-12-01 20:18:51 +11:00
|
|
|
selectionRanges,
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
}).enabled
|
|
|
|
? applyConstraintAngleBetween({
|
|
|
|
selectionRanges,
|
|
|
|
})
|
|
|
|
: applyConstraintAngleLength({
|
|
|
|
selectionRanges,
|
|
|
|
angleOrLength: 'setAngle',
|
|
|
|
}))
|
|
|
|
await kclManager.updateAst(modifiedAst, true)
|
|
|
|
return {
|
|
|
|
selectionType: 'completeSelection',
|
|
|
|
selection: pathMapToSelections(
|
|
|
|
kclManager.ast,
|
|
|
|
selectionRanges,
|
|
|
|
pathToNodeMap
|
|
|
|
),
|
2023-12-01 20:18:51 +11:00
|
|
|
}
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
},
|
|
|
|
'Get length info': async ({
|
|
|
|
selectionRanges,
|
|
|
|
}): Promise<SetSelections> => {
|
|
|
|
const { modifiedAst, pathToNodeMap } =
|
|
|
|
await applyConstraintAngleLength({ selectionRanges })
|
|
|
|
await kclManager.updateAst(modifiedAst, true)
|
|
|
|
return {
|
|
|
|
selectionType: 'completeSelection',
|
|
|
|
selection: pathMapToSelections(
|
|
|
|
kclManager.ast,
|
|
|
|
selectionRanges,
|
|
|
|
pathToNodeMap
|
|
|
|
),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'Get perpendicular distance info': async ({
|
|
|
|
selectionRanges,
|
|
|
|
}): Promise<SetSelections> => {
|
|
|
|
const { modifiedAst, pathToNodeMap } = await applyConstraintIntersect(
|
|
|
|
{
|
|
|
|
selectionRanges,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
await kclManager.updateAst(modifiedAst, true)
|
|
|
|
return {
|
|
|
|
selectionType: 'completeSelection',
|
|
|
|
selection: pathMapToSelections(
|
|
|
|
kclManager.ast,
|
|
|
|
selectionRanges,
|
|
|
|
pathToNodeMap
|
|
|
|
),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'Get ABS X info': async ({
|
|
|
|
selectionRanges,
|
|
|
|
}): Promise<SetSelections> => {
|
|
|
|
const { modifiedAst, pathToNodeMap } =
|
|
|
|
await applyConstraintAbsDistance({
|
|
|
|
constraint: 'xAbs',
|
|
|
|
selectionRanges,
|
|
|
|
})
|
|
|
|
await kclManager.updateAst(modifiedAst, true)
|
|
|
|
return {
|
|
|
|
selectionType: 'completeSelection',
|
|
|
|
selection: pathMapToSelections(
|
|
|
|
kclManager.ast,
|
|
|
|
selectionRanges,
|
|
|
|
pathToNodeMap
|
|
|
|
),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'Get ABS Y info': async ({
|
|
|
|
selectionRanges,
|
|
|
|
}): Promise<SetSelections> => {
|
|
|
|
const { modifiedAst, pathToNodeMap } =
|
|
|
|
await applyConstraintAbsDistance({
|
|
|
|
constraint: 'yAbs',
|
|
|
|
selectionRanges,
|
|
|
|
})
|
|
|
|
await kclManager.updateAst(modifiedAst, true)
|
|
|
|
return {
|
|
|
|
selectionType: 'completeSelection',
|
|
|
|
selection: pathMapToSelections(
|
|
|
|
kclManager.ast,
|
|
|
|
selectionRanges,
|
|
|
|
pathToNodeMap
|
|
|
|
),
|
|
|
|
}
|
|
|
|
},
|
2023-12-01 20:18:51 +11:00
|
|
|
},
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
devTools: true,
|
|
|
|
}
|
|
|
|
)
|
2023-10-11 13:36:54 +11:00
|
|
|
|
2023-10-18 08:03:02 +11:00
|
|
|
useEffect(() => {
|
|
|
|
kclManager.registerExecuteCallback(() => {
|
|
|
|
modelingSend({ type: 'Re-execute' })
|
|
|
|
})
|
|
|
|
}, [modelingSend])
|
|
|
|
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
useStateMachineCommands({
|
|
|
|
machineId: 'modeling',
|
|
|
|
state: modelingState,
|
|
|
|
send: modelingSend,
|
|
|
|
actor: modelingActor,
|
|
|
|
commandBarConfig: modelingMachineConfig,
|
2024-02-26 21:02:33 +11:00
|
|
|
allCommandsRequireNetwork: true,
|
2024-02-11 12:59:00 +11:00
|
|
|
onCancel: () => modelingSend({ type: 'Cancel' }),
|
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
|
|
|
})
|
2023-10-11 13:36:54 +11:00
|
|
|
|
|
|
|
return (
|
|
|
|
<ModelingMachineContext.Provider
|
|
|
|
value={{
|
|
|
|
state: modelingState,
|
|
|
|
context: modelingState.context,
|
|
|
|
send: modelingSend,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{/* TODO #818: maybe pass reff down to children/app.ts or render app.tsx directly?
|
|
|
|
since realistically it won't ever have generic children that isn't app.tsx */}
|
|
|
|
<div className="h-screen overflow-hidden select-none" ref={streamRef}>
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
</ModelingMachineContext.Provider>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ModelingMachineProvider
|