Merge branch 'main' into franknoirot/xstate-toolbar

This commit is contained in:
Frank Noirot
2023-09-13 14:51:24 -04:00
50 changed files with 2767 additions and 633 deletions

View File

@ -54,9 +54,12 @@ export type TooTip =
| 'yLineTo'
| 'angledLineThatIntersects'
export const toolTips: TooTip[] = [
'lineTo',
export const toolTips = [
'sketch_line',
'move',
// original tooltips
'line',
'lineTo',
'angledLine',
'angledLineOfXLength',
'angledLineOfYLength',
@ -67,7 +70,7 @@ export const toolTips: TooTip[] = [
'xLineTo',
'yLineTo',
'angledLineThatIntersects',
]
] as any as TooTip[]
export type GuiModes =
| {
@ -77,6 +80,7 @@ export type GuiModes =
mode: 'sketch'
sketchMode: TooTip
isTooltip: true
waitingFirstClick: boolean
rotation: Rotation
position: Position
id?: string
@ -95,6 +99,7 @@ export type GuiModes =
}
| {
mode: 'canEditSketch'
pathId: string
pathToNode: PathToNode
rotation: Rotation
position: Position
@ -133,8 +138,8 @@ export interface StoreState {
kclErrors: KCLError[]
addKCLError: (err: KCLError) => void
resetKCLErrors: () => void
ast: Program | null
setAst: (ast: Program | null) => void
ast: Program
setAst: (ast: Program) => void
updateAst: (
ast: Program,
optionalParams?: {
@ -233,12 +238,13 @@ export const useStore = create<StoreState>()(
}
})
setTimeout(() => {
editorView.dispatch({
selection: EditorSelection.create(
ranges,
selections.codeBasedSelections.length - 1
),
})
ranges.length &&
editorView.dispatch({
selection: EditorSelection.create(
ranges,
selections.codeBasedSelections.length - 1
),
})
})
},
setCursor2: (codeSelections) => {
@ -292,7 +298,15 @@ export const useStore = create<StoreState>()(
resetKCLErrors: () => {
set({ kclErrors: [] })
},
ast: null,
ast: {
start: 0,
end: 0,
body: [],
nonCodeMeta: {
noneCodeNodes: {},
start: null,
},
},
setAst: (ast) => {
set({ ast })
},
@ -301,7 +315,11 @@ export const useStore = create<StoreState>()(
const astWithUpdatedSource = parser_wasm(newCode)
callBack(astWithUpdatedSource)
set({ ast: astWithUpdatedSource, code: newCode })
set({
ast: astWithUpdatedSource,
code: newCode,
defferedCode: newCode,
})
if (focusPath) {
const { node } = getNodeFromPath<any>(
astWithUpdatedSource,
@ -353,7 +371,7 @@ export const useStore = create<StoreState>()(
setError: (error = '') => {
set({ errorState: { isError: !!error, error } })
},
programMemory: { root: {}, pendingMemory: {} },
programMemory: { root: {}, return: null },
setProgramMemory: (programMemory) => set({ programMemory }),
isShiftDown: false,
setIsShiftDown: (isShiftDown) => set({ isShiftDown }),