Cursors should stay after a code-mod (#113)
* setup to get path to nodes back from ast-mods * fix cursor setting for constraint buttons that use transformSecondarySketchLinesTagFirst * fix cursors for constraints that use transformAstSketchLines
This commit is contained in:
@ -93,7 +93,7 @@ export const Toolbar = () => {
|
||||
ast,
|
||||
pathToNode
|
||||
)
|
||||
updateAst(modifiedAst, pathToExtrudeArg)
|
||||
updateAst(modifiedAst, { focusPath: pathToExtrudeArg })
|
||||
}}
|
||||
className="border m-1 px-1 rounded text-xs"
|
||||
>
|
||||
@ -111,7 +111,7 @@ export const Toolbar = () => {
|
||||
pathToNode,
|
||||
false
|
||||
)
|
||||
updateAst(modifiedAst, pathToExtrudeArg)
|
||||
updateAst(modifiedAst, { focusPath: pathToExtrudeArg })
|
||||
}}
|
||||
className="border m-1 px-1 rounded text-xs"
|
||||
>
|
||||
|
@ -11,17 +11,18 @@ import {
|
||||
transformSecondarySketchLinesTagFirst,
|
||||
getTransformInfos,
|
||||
} from '../../lang/std/sketchcombos'
|
||||
import { updateCursors } from '../../lang/util'
|
||||
|
||||
export const EqualAngle = () => {
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst } = useStore(
|
||||
(s) => ({
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst, setCursor } =
|
||||
useStore((s) => ({
|
||||
guiMode: s.guiMode,
|
||||
ast: s.ast,
|
||||
updateAst: s.updateAst,
|
||||
selectionRanges: s.selectionRanges,
|
||||
programMemory: s.programMemory,
|
||||
})
|
||||
)
|
||||
setCursor: s.setCursor,
|
||||
}))
|
||||
const [enableEqual, setEnableEqual] = useState(false)
|
||||
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
|
||||
useEffect(() => {
|
||||
@ -72,18 +73,19 @@ export const EqualAngle = () => {
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={() =>
|
||||
transformInfos &&
|
||||
ast &&
|
||||
updateAst(
|
||||
onClick={async () => {
|
||||
if (!(transformInfos && ast)) return
|
||||
const { modifiedAst, pathToNodeMap } =
|
||||
transformSecondarySketchLinesTagFirst({
|
||||
ast,
|
||||
selectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
})?.modifiedAst
|
||||
)
|
||||
}
|
||||
})
|
||||
updateAst(modifiedAst, {
|
||||
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
|
||||
})
|
||||
}}
|
||||
className={`border m-1 px-1 rounded text-xs ${
|
||||
enableEqual ? 'bg-gray-50 text-gray-800' : 'bg-gray-200 text-gray-400'
|
||||
}`}
|
||||
|
@ -11,17 +11,18 @@ import {
|
||||
transformSecondarySketchLinesTagFirst,
|
||||
getTransformInfos,
|
||||
} from '../../lang/std/sketchcombos'
|
||||
import { updateCursors } from '../../lang/util'
|
||||
|
||||
export const EqualLength = () => {
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst } = useStore(
|
||||
(s) => ({
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst, setCursor } =
|
||||
useStore((s) => ({
|
||||
guiMode: s.guiMode,
|
||||
ast: s.ast,
|
||||
updateAst: s.updateAst,
|
||||
selectionRanges: s.selectionRanges,
|
||||
programMemory: s.programMemory,
|
||||
})
|
||||
)
|
||||
setCursor: s.setCursor,
|
||||
}))
|
||||
const [enableEqual, setEnableEqual] = useState(false)
|
||||
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
|
||||
useEffect(() => {
|
||||
@ -72,18 +73,19 @@ export const EqualLength = () => {
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={() =>
|
||||
transformInfos &&
|
||||
ast &&
|
||||
updateAst(
|
||||
onClick={() => {
|
||||
if (!(transformInfos && ast)) return
|
||||
const { modifiedAst, pathToNodeMap } =
|
||||
transformSecondarySketchLinesTagFirst({
|
||||
ast,
|
||||
selectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
})?.modifiedAst
|
||||
)
|
||||
}
|
||||
})
|
||||
updateAst(modifiedAst, {
|
||||
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
|
||||
})
|
||||
}}
|
||||
className={`border m-1 px-1 rounded text-xs ${
|
||||
enableEqual ? 'bg-gray-50 text-gray-800' : 'bg-gray-200 text-gray-400'
|
||||
}`}
|
||||
|
@ -10,21 +10,22 @@ import {
|
||||
getTransformInfos,
|
||||
transformAstSketchLines,
|
||||
} from '../../lang/std/sketchcombos'
|
||||
import { updateCursors } from '../../lang/util'
|
||||
|
||||
export const HorzVert = ({
|
||||
horOrVert,
|
||||
}: {
|
||||
horOrVert: 'vertical' | 'horizontal'
|
||||
}) => {
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst } = useStore(
|
||||
(s) => ({
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst, setCursor } =
|
||||
useStore((s) => ({
|
||||
guiMode: s.guiMode,
|
||||
ast: s.ast,
|
||||
updateAst: s.updateAst,
|
||||
selectionRanges: s.selectionRanges,
|
||||
programMemory: s.programMemory,
|
||||
})
|
||||
)
|
||||
setCursor: s.setCursor,
|
||||
}))
|
||||
const [enableHorz, setEnableHorz] = useState(false)
|
||||
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
|
||||
useEffect(() => {
|
||||
@ -51,19 +52,19 @@ export const HorzVert = ({
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={() =>
|
||||
transformInfos &&
|
||||
ast &&
|
||||
updateAst(
|
||||
transformAstSketchLines({
|
||||
ast,
|
||||
selectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
referenceSegName: '',
|
||||
})?.modifiedAst
|
||||
)
|
||||
}
|
||||
onClick={() => {
|
||||
if (!transformInfos || !ast) return
|
||||
const { modifiedAst, pathToNodeMap } = transformAstSketchLines({
|
||||
ast,
|
||||
selectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
referenceSegName: '',
|
||||
})
|
||||
updateAst(modifiedAst, {
|
||||
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
|
||||
})
|
||||
}}
|
||||
className={`border m-1 px-1 rounded text-xs ${
|
||||
enableHorz ? 'bg-gray-50 text-gray-800' : 'bg-gray-200 text-gray-400'
|
||||
}`}
|
||||
|
@ -20,19 +20,20 @@ import {
|
||||
import { GetInfoModal } from '../SetHorVertDistanceModal'
|
||||
import { createVariableDeclaration } from '../../lang/modifyAst'
|
||||
import { removeDoubleNegatives } from '../AvailableVarsHelpers'
|
||||
import { updateCursors } from '../../lang/util'
|
||||
|
||||
const getModalInfo = create(GetInfoModal as any)
|
||||
|
||||
export const Intersect = () => {
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst } = useStore(
|
||||
(s) => ({
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst, setCursor } =
|
||||
useStore((s) => ({
|
||||
guiMode: s.guiMode,
|
||||
ast: s.ast,
|
||||
updateAst: s.updateAst,
|
||||
selectionRanges: s.selectionRanges,
|
||||
programMemory: s.programMemory,
|
||||
})
|
||||
)
|
||||
setCursor: s.setCursor,
|
||||
}))
|
||||
const [enable, setEnable] = useState(false)
|
||||
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
|
||||
const [forecdSelectionRanges, setForcedSelectionRanges] =
|
||||
@ -125,63 +126,66 @@ export const Intersect = () => {
|
||||
return (
|
||||
<button
|
||||
onClick={async () => {
|
||||
if (transformInfos && ast && forecdSelectionRanges) {
|
||||
const { modifiedAst, tagInfo, valueUsedInTransform } =
|
||||
if (!(transformInfos && ast && forecdSelectionRanges)) return
|
||||
const { modifiedAst, tagInfo, valueUsedInTransform, pathToNodeMap } =
|
||||
transformSecondarySketchLinesTagFirst({
|
||||
ast: JSON.parse(JSON.stringify(ast)),
|
||||
selectionRanges: forecdSelectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
})
|
||||
const {
|
||||
segName,
|
||||
value,
|
||||
valueNode,
|
||||
variableName,
|
||||
newVariableInsertIndex,
|
||||
sign,
|
||||
}: {
|
||||
segName: string
|
||||
value: number
|
||||
valueNode: Value
|
||||
variableName?: string
|
||||
newVariableInsertIndex: number
|
||||
sign: number
|
||||
} = await getModalInfo({
|
||||
segName: tagInfo?.tag,
|
||||
isSegNameEditable: !tagInfo?.isTagExisting,
|
||||
value: valueUsedInTransform,
|
||||
initialVariableName: 'offset',
|
||||
} as any)
|
||||
if (segName === tagInfo?.tag && value === valueUsedInTransform) {
|
||||
updateAst(modifiedAst, {
|
||||
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
|
||||
})
|
||||
} else {
|
||||
// transform again but forcing certain values
|
||||
const finalValue = removeDoubleNegatives(
|
||||
valueNode as BinaryPart,
|
||||
sign,
|
||||
variableName
|
||||
)
|
||||
const { modifiedAst: _modifiedAst, pathToNodeMap } =
|
||||
transformSecondarySketchLinesTagFirst({
|
||||
ast: JSON.parse(JSON.stringify(ast)),
|
||||
ast,
|
||||
selectionRanges: forecdSelectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
forceSegName: segName,
|
||||
forceValueUsedInTransform: finalValue,
|
||||
})
|
||||
const {
|
||||
segName,
|
||||
value,
|
||||
valueNode,
|
||||
variableName,
|
||||
newVariableInsertIndex,
|
||||
sign,
|
||||
}: {
|
||||
segName: string
|
||||
value: number
|
||||
valueNode: Value
|
||||
variableName?: string
|
||||
newVariableInsertIndex: number
|
||||
sign: number
|
||||
} = await getModalInfo({
|
||||
segName: tagInfo?.tag,
|
||||
isSegNameEditable: !tagInfo?.isTagExisting,
|
||||
value: valueUsedInTransform,
|
||||
initialVariableName: 'offset',
|
||||
} as any)
|
||||
if (segName === tagInfo?.tag && value === valueUsedInTransform) {
|
||||
updateAst(modifiedAst)
|
||||
} else {
|
||||
// transform again but forcing certain values
|
||||
const finalValue = removeDoubleNegatives(
|
||||
valueNode as BinaryPart,
|
||||
sign,
|
||||
variableName
|
||||
if (variableName) {
|
||||
const newBody = [..._modifiedAst.body]
|
||||
newBody.splice(
|
||||
newVariableInsertIndex,
|
||||
0,
|
||||
createVariableDeclaration(variableName, valueNode)
|
||||
)
|
||||
const { modifiedAst: _modifiedAst } =
|
||||
transformSecondarySketchLinesTagFirst({
|
||||
ast,
|
||||
selectionRanges: forecdSelectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
forceSegName: segName,
|
||||
forceValueUsedInTransform: finalValue,
|
||||
})
|
||||
if (variableName) {
|
||||
const newBody = [..._modifiedAst.body]
|
||||
newBody.splice(
|
||||
newVariableInsertIndex,
|
||||
0,
|
||||
createVariableDeclaration(variableName, valueNode)
|
||||
)
|
||||
_modifiedAst.body = newBody
|
||||
}
|
||||
updateAst(_modifiedAst)
|
||||
_modifiedAst.body = newBody
|
||||
}
|
||||
updateAst(_modifiedAst, {
|
||||
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
|
||||
})
|
||||
}
|
||||
}}
|
||||
className={`border m-1 px-1 rounded text-xs ${
|
||||
|
@ -10,17 +10,18 @@ import {
|
||||
getRemoveConstraintsTransforms,
|
||||
transformAstSketchLines,
|
||||
} from '../../lang/std/sketchcombos'
|
||||
import { updateCursors } from '../../lang/util'
|
||||
|
||||
export const RemoveConstrainingValues = () => {
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst } = useStore(
|
||||
(s) => ({
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst, setCursor } =
|
||||
useStore((s) => ({
|
||||
guiMode: s.guiMode,
|
||||
ast: s.ast,
|
||||
updateAst: s.updateAst,
|
||||
selectionRanges: s.selectionRanges,
|
||||
programMemory: s.programMemory,
|
||||
})
|
||||
)
|
||||
setCursor: s.setCursor,
|
||||
}))
|
||||
const [enableHorz, setEnableHorz] = useState(false)
|
||||
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
|
||||
useEffect(() => {
|
||||
@ -55,19 +56,19 @@ export const RemoveConstrainingValues = () => {
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={() =>
|
||||
transformInfos &&
|
||||
ast &&
|
||||
updateAst(
|
||||
transformAstSketchLines({
|
||||
ast,
|
||||
selectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
referenceSegName: '',
|
||||
})?.modifiedAst
|
||||
)
|
||||
}
|
||||
onClick={() => {
|
||||
if (!transformInfos || !ast) return
|
||||
const { modifiedAst, pathToNodeMap } = transformAstSketchLines({
|
||||
ast,
|
||||
selectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
referenceSegName: '',
|
||||
})
|
||||
updateAst(modifiedAst, {
|
||||
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
|
||||
})
|
||||
}}
|
||||
className={`border m-1 px-1 rounded text-xs ${
|
||||
enableHorz ? 'bg-gray-50 text-gray-800' : 'bg-gray-200 text-gray-400'
|
||||
}`}
|
||||
|
@ -18,6 +18,7 @@ import {
|
||||
createVariableDeclaration,
|
||||
} from '../../lang/modifyAst'
|
||||
import { removeDoubleNegatives } from '../AvailableVarsHelpers'
|
||||
import { updateCursors } from '../../lang/util'
|
||||
|
||||
const getModalInfo = create(SetAngleLengthModal as any)
|
||||
|
||||
@ -26,19 +27,15 @@ export const SetAbsDistance = ({
|
||||
}: {
|
||||
buttonType: 'xAbs' | 'yAbs' | 'snapToYAxis' | 'snapToXAxis'
|
||||
}) => {
|
||||
const {
|
||||
guiMode,
|
||||
selectionRanges: selections,
|
||||
ast,
|
||||
programMemory,
|
||||
updateAst,
|
||||
} = useStore((s) => ({
|
||||
guiMode: s.guiMode,
|
||||
ast: s.ast,
|
||||
updateAst: s.updateAst,
|
||||
selectionRanges: s.selectionRanges,
|
||||
programMemory: s.programMemory,
|
||||
}))
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst, setCursor } =
|
||||
useStore((s) => ({
|
||||
guiMode: s.guiMode,
|
||||
ast: s.ast,
|
||||
updateAst: s.updateAst,
|
||||
selectionRanges: s.selectionRanges,
|
||||
programMemory: s.programMemory,
|
||||
setCursor: s.setCursor,
|
||||
}))
|
||||
const disType: ConstraintType =
|
||||
buttonType === 'xAbs' || buttonType === 'yAbs'
|
||||
? buttonType
|
||||
@ -49,7 +46,7 @@ export const SetAbsDistance = ({
|
||||
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
|
||||
useEffect(() => {
|
||||
if (!ast) return
|
||||
const paths = selections.codeBasedSelections.map(({ range }) =>
|
||||
const paths = selectionRanges.codeBasedSelections.map(({ range }) =>
|
||||
getNodePathFromSourceRange(ast, range)
|
||||
)
|
||||
const nodes = paths.map(
|
||||
@ -62,25 +59,25 @@ export const SetAbsDistance = ({
|
||||
toolTips.includes(node.callee.name as any)
|
||||
)
|
||||
|
||||
const theTransforms = getTransformInfos(selections, ast, disType)
|
||||
const theTransforms = getTransformInfos(selectionRanges, ast, disType)
|
||||
setTransformInfos(theTransforms)
|
||||
|
||||
const enableY =
|
||||
disType === 'yAbs' &&
|
||||
selections.otherSelections.length === 1 &&
|
||||
selections.otherSelections[0] === 'x-axis' // select the x axis to set the distance from it i.e. y
|
||||
selectionRanges.otherSelections.length === 1 &&
|
||||
selectionRanges.otherSelections[0] === 'x-axis' // select the x axis to set the distance from it i.e. y
|
||||
const enableX =
|
||||
disType === 'xAbs' &&
|
||||
selections.otherSelections.length === 1 &&
|
||||
selections.otherSelections[0] === 'y-axis' // select the y axis to set the distance from it i.e. x
|
||||
selectionRanges.otherSelections.length === 1 &&
|
||||
selectionRanges.otherSelections[0] === 'y-axis' // select the y axis to set the distance from it i.e. x
|
||||
|
||||
const _enableHorz =
|
||||
isAllTooltips &&
|
||||
theTransforms.every(Boolean) &&
|
||||
selections.codeBasedSelections.length === 1 &&
|
||||
selectionRanges.codeBasedSelections.length === 1 &&
|
||||
(enableX || enableY)
|
||||
setEnableAngLen(_enableHorz)
|
||||
}, [guiMode, selections])
|
||||
}, [guiMode, selectionRanges])
|
||||
if (guiMode.mode !== 'sketch') return null
|
||||
|
||||
const isAlign = buttonType === 'snapToYAxis' || buttonType === 'snapToXAxis'
|
||||
@ -91,7 +88,7 @@ export const SetAbsDistance = ({
|
||||
if (!(transformInfos && ast)) return
|
||||
const { valueUsedInTransform } = transformAstSketchLines({
|
||||
ast: JSON.parse(JSON.stringify(ast)),
|
||||
selectionRanges: selections,
|
||||
selectionRanges: selectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
referenceSegName: '',
|
||||
@ -108,14 +105,15 @@ export const SetAbsDistance = ({
|
||||
? createIdentifier('_0')
|
||||
: removeDoubleNegatives(valueNode, sign, variableName)
|
||||
|
||||
const { modifiedAst: _modifiedAst } = transformAstSketchLines({
|
||||
ast: JSON.parse(JSON.stringify(ast)),
|
||||
selectionRanges: selections,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
referenceSegName: '',
|
||||
forceValueUsedInTransform: finalValue,
|
||||
})
|
||||
const { modifiedAst: _modifiedAst, pathToNodeMap } =
|
||||
transformAstSketchLines({
|
||||
ast: JSON.parse(JSON.stringify(ast)),
|
||||
selectionRanges: selectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
referenceSegName: '',
|
||||
forceValueUsedInTransform: finalValue,
|
||||
})
|
||||
if (variableName) {
|
||||
const newBody = [..._modifiedAst.body]
|
||||
newBody.splice(
|
||||
@ -126,7 +124,9 @@ export const SetAbsDistance = ({
|
||||
_modifiedAst.body = newBody
|
||||
}
|
||||
|
||||
updateAst(_modifiedAst)
|
||||
updateAst(_modifiedAst, {
|
||||
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
|
||||
})
|
||||
} catch (e) {
|
||||
console.log('e', e)
|
||||
}
|
||||
|
@ -19,19 +19,20 @@ import {
|
||||
import { GetInfoModal } from '../SetHorVertDistanceModal'
|
||||
import { createVariableDeclaration } from '../../lang/modifyAst'
|
||||
import { removeDoubleNegatives } from '../AvailableVarsHelpers'
|
||||
import { updateCursors } from '../../lang/util'
|
||||
|
||||
const getModalInfo = create(GetInfoModal as any)
|
||||
|
||||
export const SetAngleBetween = () => {
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst } = useStore(
|
||||
(s) => ({
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst, setCursor } =
|
||||
useStore((s) => ({
|
||||
guiMode: s.guiMode,
|
||||
ast: s.ast,
|
||||
updateAst: s.updateAst,
|
||||
selectionRanges: s.selectionRanges,
|
||||
programMemory: s.programMemory,
|
||||
})
|
||||
)
|
||||
setCursor: s.setCursor,
|
||||
}))
|
||||
const [enable, setEnable] = useState(false)
|
||||
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
|
||||
useEffect(() => {
|
||||
@ -83,63 +84,66 @@ export const SetAngleBetween = () => {
|
||||
return (
|
||||
<button
|
||||
onClick={async () => {
|
||||
if (transformInfos && ast) {
|
||||
const { modifiedAst, tagInfo, valueUsedInTransform } =
|
||||
if (!(transformInfos && ast)) return
|
||||
const { modifiedAst, tagInfo, valueUsedInTransform, pathToNodeMap } =
|
||||
transformSecondarySketchLinesTagFirst({
|
||||
ast: JSON.parse(JSON.stringify(ast)),
|
||||
selectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
})
|
||||
const {
|
||||
segName,
|
||||
value,
|
||||
valueNode,
|
||||
variableName,
|
||||
newVariableInsertIndex,
|
||||
sign,
|
||||
}: {
|
||||
segName: string
|
||||
value: number
|
||||
valueNode: Value
|
||||
variableName?: string
|
||||
newVariableInsertIndex: number
|
||||
sign: number
|
||||
} = await getModalInfo({
|
||||
segName: tagInfo?.tag,
|
||||
isSegNameEditable: !tagInfo?.isTagExisting,
|
||||
value: valueUsedInTransform,
|
||||
initialVariableName: 'angle',
|
||||
} as any)
|
||||
if (segName === tagInfo?.tag && value === valueUsedInTransform) {
|
||||
updateAst(modifiedAst, {
|
||||
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
|
||||
})
|
||||
} else {
|
||||
const finalValue = removeDoubleNegatives(
|
||||
valueNode as BinaryPart,
|
||||
sign,
|
||||
variableName
|
||||
)
|
||||
// transform again but forcing certain values
|
||||
const { modifiedAst: _modifiedAst, pathToNodeMap } =
|
||||
transformSecondarySketchLinesTagFirst({
|
||||
ast: JSON.parse(JSON.stringify(ast)),
|
||||
ast,
|
||||
selectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
forceSegName: segName,
|
||||
forceValueUsedInTransform: finalValue,
|
||||
})
|
||||
const {
|
||||
segName,
|
||||
value,
|
||||
valueNode,
|
||||
variableName,
|
||||
newVariableInsertIndex,
|
||||
sign,
|
||||
}: {
|
||||
segName: string
|
||||
value: number
|
||||
valueNode: Value
|
||||
variableName?: string
|
||||
newVariableInsertIndex: number
|
||||
sign: number
|
||||
} = await getModalInfo({
|
||||
segName: tagInfo?.tag,
|
||||
isSegNameEditable: !tagInfo?.isTagExisting,
|
||||
value: valueUsedInTransform,
|
||||
initialVariableName: 'angle',
|
||||
} as any)
|
||||
if (segName === tagInfo?.tag && value === valueUsedInTransform) {
|
||||
updateAst(modifiedAst)
|
||||
} else {
|
||||
const finalValue = removeDoubleNegatives(
|
||||
valueNode as BinaryPart,
|
||||
sign,
|
||||
variableName
|
||||
if (variableName) {
|
||||
const newBody = [..._modifiedAst.body]
|
||||
newBody.splice(
|
||||
newVariableInsertIndex,
|
||||
0,
|
||||
createVariableDeclaration(variableName, valueNode)
|
||||
)
|
||||
// transform again but forcing certain values
|
||||
const { modifiedAst: _modifiedAst } =
|
||||
transformSecondarySketchLinesTagFirst({
|
||||
ast,
|
||||
selectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
forceSegName: segName,
|
||||
forceValueUsedInTransform: finalValue,
|
||||
})
|
||||
if (variableName) {
|
||||
const newBody = [..._modifiedAst.body]
|
||||
newBody.splice(
|
||||
newVariableInsertIndex,
|
||||
0,
|
||||
createVariableDeclaration(variableName, valueNode)
|
||||
)
|
||||
_modifiedAst.body = newBody
|
||||
}
|
||||
updateAst(_modifiedAst)
|
||||
_modifiedAst.body = newBody
|
||||
}
|
||||
updateAst(_modifiedAst, {
|
||||
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
|
||||
})
|
||||
}
|
||||
}}
|
||||
className={`border m-1 px-1 rounded text-xs ${
|
||||
|
@ -20,6 +20,7 @@ import {
|
||||
import { GetInfoModal } from '../SetHorVertDistanceModal'
|
||||
import { createLiteral, createVariableDeclaration } from '../../lang/modifyAst'
|
||||
import { removeDoubleNegatives } from '../AvailableVarsHelpers'
|
||||
import { updateCursors } from '../../lang/util'
|
||||
|
||||
const getModalInfo = create(GetInfoModal as any)
|
||||
|
||||
@ -32,15 +33,15 @@ export const SetHorzVertDistance = ({
|
||||
| 'alignEndsHorizontally'
|
||||
| 'alignEndsVertically'
|
||||
}) => {
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst } = useStore(
|
||||
(s) => ({
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst, setCursor } =
|
||||
useStore((s) => ({
|
||||
guiMode: s.guiMode,
|
||||
ast: s.ast,
|
||||
updateAst: s.updateAst,
|
||||
selectionRanges: s.selectionRanges,
|
||||
programMemory: s.programMemory,
|
||||
})
|
||||
)
|
||||
setCursor: s.setCursor,
|
||||
}))
|
||||
const constraint: ConstraintType =
|
||||
buttonType === 'setHorzDistance' || buttonType === 'setVertDistance'
|
||||
? buttonType
|
||||
@ -105,67 +106,66 @@ export const SetHorzVertDistance = ({
|
||||
return (
|
||||
<button
|
||||
onClick={async () => {
|
||||
if (transformInfos && ast) {
|
||||
const { modifiedAst, tagInfo, valueUsedInTransform } =
|
||||
if (!(transformInfos && ast)) return
|
||||
const { modifiedAst, tagInfo, valueUsedInTransform, pathToNodeMap } =
|
||||
transformSecondarySketchLinesTagFirst({
|
||||
ast: JSON.parse(JSON.stringify(ast)),
|
||||
selectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
})
|
||||
const {
|
||||
segName,
|
||||
value,
|
||||
valueNode,
|
||||
variableName,
|
||||
newVariableInsertIndex,
|
||||
sign,
|
||||
}: {
|
||||
segName: string
|
||||
value: number
|
||||
valueNode: Value
|
||||
variableName?: string
|
||||
newVariableInsertIndex: number
|
||||
sign: number
|
||||
} = await (!isAlign &&
|
||||
getModalInfo({
|
||||
segName: tagInfo?.tag,
|
||||
isSegNameEditable: !tagInfo?.isTagExisting,
|
||||
value: valueUsedInTransform,
|
||||
initialVariableName:
|
||||
constraint === 'setHorzDistance' ? 'xDis' : 'yDis',
|
||||
} as any))
|
||||
if (segName === tagInfo?.tag && value === valueUsedInTransform) {
|
||||
updateAst(modifiedAst, {
|
||||
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
|
||||
})
|
||||
} else {
|
||||
let finalValue = isAlign
|
||||
? createLiteral(0)
|
||||
: removeDoubleNegatives(valueNode as BinaryPart, sign, variableName)
|
||||
// transform again but forcing certain values
|
||||
const { modifiedAst: _modifiedAst, pathToNodeMap } =
|
||||
transformSecondarySketchLinesTagFirst({
|
||||
ast: JSON.parse(JSON.stringify(ast)),
|
||||
ast,
|
||||
selectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
forceSegName: segName,
|
||||
forceValueUsedInTransform: finalValue,
|
||||
})
|
||||
const {
|
||||
segName,
|
||||
value,
|
||||
valueNode,
|
||||
variableName,
|
||||
newVariableInsertIndex,
|
||||
sign,
|
||||
}: {
|
||||
segName: string
|
||||
value: number
|
||||
valueNode: Value
|
||||
variableName?: string
|
||||
newVariableInsertIndex: number
|
||||
sign: number
|
||||
} = await (!isAlign &&
|
||||
getModalInfo({
|
||||
segName: tagInfo?.tag,
|
||||
isSegNameEditable: !tagInfo?.isTagExisting,
|
||||
value: valueUsedInTransform,
|
||||
initialVariableName:
|
||||
constraint === 'setHorzDistance' ? 'xDis' : 'yDis',
|
||||
} as any))
|
||||
if (segName === tagInfo?.tag && value === valueUsedInTransform) {
|
||||
updateAst(modifiedAst)
|
||||
} else {
|
||||
let finalValue = isAlign
|
||||
? createLiteral(0)
|
||||
: removeDoubleNegatives(
|
||||
valueNode as BinaryPart,
|
||||
sign,
|
||||
variableName
|
||||
)
|
||||
// transform again but forcing certain values
|
||||
const { modifiedAst: _modifiedAst } =
|
||||
transformSecondarySketchLinesTagFirst({
|
||||
ast,
|
||||
selectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
forceSegName: segName,
|
||||
forceValueUsedInTransform: finalValue,
|
||||
})
|
||||
if (variableName) {
|
||||
const newBody = [..._modifiedAst.body]
|
||||
newBody.splice(
|
||||
newVariableInsertIndex,
|
||||
0,
|
||||
createVariableDeclaration(variableName, valueNode)
|
||||
)
|
||||
_modifiedAst.body = newBody
|
||||
}
|
||||
updateAst(_modifiedAst)
|
||||
if (variableName) {
|
||||
const newBody = [..._modifiedAst.body]
|
||||
newBody.splice(
|
||||
newVariableInsertIndex,
|
||||
0,
|
||||
createVariableDeclaration(variableName, valueNode)
|
||||
)
|
||||
_modifiedAst.body = newBody
|
||||
}
|
||||
updateAst(_modifiedAst, {
|
||||
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
|
||||
})
|
||||
}
|
||||
}}
|
||||
className={`border m-1 px-1 rounded text-xs ${
|
||||
|
@ -19,6 +19,7 @@ import {
|
||||
} from '../../lang/modifyAst'
|
||||
import { removeDoubleNegatives } from '../AvailableVarsHelpers'
|
||||
import { normaliseAngle } from '../../lib/utils'
|
||||
import { updateCursors } from '../../lang/util'
|
||||
|
||||
const getModalInfo = create(SetAngleLengthModal as any)
|
||||
|
||||
@ -27,15 +28,15 @@ export const SetAngleLength = ({
|
||||
}: {
|
||||
angleOrLength: 'setAngle' | 'setLength'
|
||||
}) => {
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst } = useStore(
|
||||
(s) => ({
|
||||
const { guiMode, selectionRanges, ast, programMemory, updateAst, setCursor } =
|
||||
useStore((s) => ({
|
||||
guiMode: s.guiMode,
|
||||
ast: s.ast,
|
||||
updateAst: s.updateAst,
|
||||
selectionRanges: s.selectionRanges,
|
||||
programMemory: s.programMemory,
|
||||
})
|
||||
)
|
||||
setCursor: s.setCursor,
|
||||
}))
|
||||
const [enableAngLen, setEnableAngLen] = useState(false)
|
||||
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
|
||||
useEffect(() => {
|
||||
@ -116,14 +117,15 @@ export const SetAngleLength = ({
|
||||
])
|
||||
}
|
||||
|
||||
const { modifiedAst: _modifiedAst } = transformAstSketchLines({
|
||||
ast: JSON.parse(JSON.stringify(ast)),
|
||||
selectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
referenceSegName: '',
|
||||
forceValueUsedInTransform: finalValue,
|
||||
})
|
||||
const { modifiedAst: _modifiedAst, pathToNodeMap } =
|
||||
transformAstSketchLines({
|
||||
ast: JSON.parse(JSON.stringify(ast)),
|
||||
selectionRanges,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
referenceSegName: '',
|
||||
forceValueUsedInTransform: finalValue,
|
||||
})
|
||||
if (variableName) {
|
||||
const newBody = [..._modifiedAst.body]
|
||||
newBody.splice(
|
||||
@ -134,7 +136,9 @@ export const SetAngleLength = ({
|
||||
_modifiedAst.body = newBody
|
||||
}
|
||||
|
||||
updateAst(_modifiedAst)
|
||||
updateAst(_modifiedAst, {
|
||||
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
|
||||
})
|
||||
} catch (e) {
|
||||
console.log('e', e)
|
||||
}
|
||||
|
@ -668,7 +668,7 @@ function makeArrayExpression(
|
||||
expression: ArrayExpression
|
||||
lastIndex: number
|
||||
} {
|
||||
// should be called array opening brace '[' index
|
||||
// should be called with index to an array opening brace '['
|
||||
const openingBraceToken = tokens[index]
|
||||
const firstElementToken = nextMeaningfulToken(tokens, index)
|
||||
const { elements, lastIndex } = makeArrayElements(
|
||||
|
@ -536,10 +536,16 @@ export function giveSketchFnCallTag(
|
||||
ast: Program,
|
||||
range: Selection['range'],
|
||||
tag?: string
|
||||
): { modifiedAst: Program; tag: string; isTagExisting: boolean } {
|
||||
): {
|
||||
modifiedAst: Program
|
||||
tag: string
|
||||
isTagExisting: boolean
|
||||
pathToNode: PathToNode
|
||||
} {
|
||||
const path = getNodePathFromSourceRange(ast, range)
|
||||
const { node: primaryCallExp } = getNodeFromPath<CallExpression>(
|
||||
ast,
|
||||
getNodePathFromSourceRange(ast, range),
|
||||
path,
|
||||
'CallExpression'
|
||||
)
|
||||
const firstArg = getFirstArg(primaryCallExp)
|
||||
@ -557,6 +563,7 @@ export function giveSketchFnCallTag(
|
||||
modifiedAst: ast,
|
||||
tag: tagStr,
|
||||
isTagExisting,
|
||||
pathToNode: path,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ import {
|
||||
VariableDeclaration,
|
||||
ReturnStatement,
|
||||
ArrayExpression,
|
||||
Identifier,
|
||||
} from './abstractSyntaxTree'
|
||||
import { createIdentifier, splitPathAtLastIndex } from './modifyAst'
|
||||
import { getSketchSegmentFromSourceRange } from './std/sketchConstraints'
|
||||
|
@ -1392,14 +1392,18 @@ export function replaceSketchLine({
|
||||
from: [number, number]
|
||||
createCallback: TransformCallback
|
||||
referencedSegment?: Path
|
||||
}): { modifiedAst: Program; valueUsedInTransform?: number } {
|
||||
}): {
|
||||
modifiedAst: Program
|
||||
valueUsedInTransform?: number
|
||||
pathToNode: PathToNode
|
||||
} {
|
||||
if (![...toolTips, 'intersect'].includes(fnName))
|
||||
throw new Error('not a tooltip')
|
||||
const _node = { ...node }
|
||||
const thePath = getNodePathFromSourceRange(_node, sourceRange)
|
||||
|
||||
const { add } = sketchLineHelperMap[fnName]
|
||||
const { modifiedAst, valueUsedInTransform } = add({
|
||||
const { modifiedAst, valueUsedInTransform, pathToNode } = add({
|
||||
node: _node,
|
||||
previousProgramMemory: programMemory,
|
||||
pathToNode: thePath,
|
||||
@ -1409,7 +1413,7 @@ export function replaceSketchLine({
|
||||
replaceExisting: true,
|
||||
createCallback,
|
||||
})
|
||||
return { modifiedAst, valueUsedInTransform }
|
||||
return { modifiedAst, valueUsedInTransform, pathToNode }
|
||||
}
|
||||
|
||||
export function addTagForSketchOnFace(
|
||||
|
@ -25,7 +25,7 @@ import {
|
||||
giveSketchFnCallTag,
|
||||
} from '../modifyAst'
|
||||
import { createFirstArg, getFirstArg, replaceSketchLine } from './sketch'
|
||||
import { ProgramMemory } from '../executor'
|
||||
import { PathToNode, ProgramMemory } from '../executor'
|
||||
import { getSketchSegmentFromSourceRange } from './sketchConstraints'
|
||||
import { getAngle, roundOff, normaliseAngle } from '../../lib/utils'
|
||||
|
||||
@ -785,6 +785,10 @@ const transformMap: TransformMap = {
|
||||
tooltip: 'angledLine',
|
||||
createNode: basicAngledLineCreateNode('len', 'ang', 'len'),
|
||||
},
|
||||
equalAngle: {
|
||||
tooltip: 'angledLine',
|
||||
createNode: basicAngledLineCreateNode('ang', 'len', 'len'),
|
||||
},
|
||||
},
|
||||
},
|
||||
angledLineOfXLength: {
|
||||
@ -1319,6 +1323,8 @@ export function getRemoveConstraintsTransforms(
|
||||
return theTransforms
|
||||
}
|
||||
|
||||
type PathToNodeMap = { [key: number]: PathToNode }
|
||||
|
||||
export function transformSecondarySketchLinesTagFirst({
|
||||
ast,
|
||||
selectionRanges,
|
||||
@ -1336,6 +1342,7 @@ export function transformSecondarySketchLinesTagFirst({
|
||||
}): {
|
||||
modifiedAst: Program
|
||||
valueUsedInTransform?: number
|
||||
pathToNodeMap: PathToNodeMap
|
||||
tagInfo: {
|
||||
tag: string
|
||||
isTagExisting: boolean
|
||||
@ -1344,25 +1351,30 @@ export function transformSecondarySketchLinesTagFirst({
|
||||
// let node = JSON.parse(JSON.stringify(ast))
|
||||
const primarySelection = selectionRanges.codeBasedSelections[0].range
|
||||
|
||||
const { modifiedAst, tag, isTagExisting } = giveSketchFnCallTag(
|
||||
const { modifiedAst, tag, isTagExisting, pathToNode } = giveSketchFnCallTag(
|
||||
ast,
|
||||
primarySelection,
|
||||
forceSegName
|
||||
)
|
||||
|
||||
const result = transformAstSketchLines({
|
||||
ast: modifiedAst,
|
||||
selectionRanges: {
|
||||
...selectionRanges,
|
||||
codeBasedSelections: selectionRanges.codeBasedSelections.slice(1),
|
||||
},
|
||||
referencedSegmentRange: primarySelection,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
referenceSegName: tag,
|
||||
forceValueUsedInTransform,
|
||||
})
|
||||
const updatedPathToNodeMap = incrementPathToNodeMap(result.pathToNodeMap)
|
||||
updatedPathToNodeMap[0] = pathToNode
|
||||
|
||||
return {
|
||||
...transformAstSketchLines({
|
||||
ast: modifiedAst,
|
||||
selectionRanges: {
|
||||
...selectionRanges,
|
||||
codeBasedSelections: selectionRanges.codeBasedSelections.slice(1),
|
||||
},
|
||||
referencedSegmentRange: primarySelection,
|
||||
transformInfos,
|
||||
programMemory,
|
||||
referenceSegName: tag,
|
||||
forceValueUsedInTransform,
|
||||
}),
|
||||
...result,
|
||||
pathToNodeMap: updatedPathToNodeMap,
|
||||
tagInfo: {
|
||||
tag,
|
||||
isTagExisting,
|
||||
@ -1370,6 +1382,17 @@ export function transformSecondarySketchLinesTagFirst({
|
||||
}
|
||||
}
|
||||
|
||||
function incrementPathToNodeMap(
|
||||
pathToNodeMap: PathToNodeMap,
|
||||
increment = 1
|
||||
): PathToNodeMap {
|
||||
const newMap: PathToNodeMap = {}
|
||||
Object.entries(pathToNodeMap).forEach(([key, path]) => {
|
||||
newMap[Number(key) + increment] = path
|
||||
})
|
||||
return newMap
|
||||
}
|
||||
|
||||
export function transformAstSketchLines({
|
||||
ast,
|
||||
selectionRanges,
|
||||
@ -1386,10 +1409,15 @@ export function transformAstSketchLines({
|
||||
referenceSegName: string
|
||||
forceValueUsedInTransform?: Value
|
||||
referencedSegmentRange?: Selection['range']
|
||||
}): { modifiedAst: Program; valueUsedInTransform?: number } {
|
||||
}): {
|
||||
modifiedAst: Program
|
||||
valueUsedInTransform?: number
|
||||
pathToNodeMap: PathToNodeMap
|
||||
} {
|
||||
// deep clone since we are mutating in a loop, of which any could fail
|
||||
let node = JSON.parse(JSON.stringify(ast))
|
||||
let _valueUsedInTransform // TODO should this be an array?
|
||||
const pathToNodeMap: PathToNodeMap = {}
|
||||
|
||||
selectionRanges.codeBasedSelections.forEach(({ range }, index) => {
|
||||
const callBack = transformInfos?.[index].createNode
|
||||
@ -1428,29 +1456,36 @@ export function transformAstSketchLines({
|
||||
.segment
|
||||
: sketchGroup.value.find((path) => path.name === _referencedSegmentName)
|
||||
const { to, from } = seg
|
||||
const { modifiedAst, valueUsedInTransform } = replaceSketchLine({
|
||||
node: node,
|
||||
programMemory,
|
||||
sourceRange: range,
|
||||
referencedSegment,
|
||||
fnName: transformTo || (callExp.callee.name as TooTip),
|
||||
to,
|
||||
from,
|
||||
createCallback: callBack({
|
||||
referenceSegName: _referencedSegmentName,
|
||||
varValA,
|
||||
varValB,
|
||||
tag: callBackTag,
|
||||
forceValueUsedInTransform,
|
||||
}),
|
||||
})
|
||||
const { modifiedAst, valueUsedInTransform, pathToNode } = replaceSketchLine(
|
||||
{
|
||||
node: node,
|
||||
programMemory,
|
||||
sourceRange: range,
|
||||
referencedSegment,
|
||||
fnName: transformTo || (callExp.callee.name as TooTip),
|
||||
to,
|
||||
from,
|
||||
createCallback: callBack({
|
||||
referenceSegName: _referencedSegmentName,
|
||||
varValA,
|
||||
varValB,
|
||||
tag: callBackTag,
|
||||
forceValueUsedInTransform,
|
||||
}),
|
||||
}
|
||||
)
|
||||
|
||||
node = modifiedAst
|
||||
pathToNodeMap[index] = pathToNode
|
||||
if (typeof valueUsedInTransform === 'number') {
|
||||
_valueUsedInTransform = valueUsedInTransform
|
||||
}
|
||||
})
|
||||
return { modifiedAst: node, valueUsedInTransform: _valueUsedInTransform }
|
||||
return {
|
||||
modifiedAst: node,
|
||||
valueUsedInTransform: _valueUsedInTransform,
|
||||
pathToNodeMap,
|
||||
}
|
||||
}
|
||||
|
||||
function createSegLen(referenceSegName: string): Value {
|
||||
|
28
src/lang/util.ts
Normal file
28
src/lang/util.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { Selections, StoreState } from '../useStore'
|
||||
import { Program } from './abstractSyntaxTree'
|
||||
import { PathToNode } from './executor'
|
||||
import { getNodeFromPath } from './queryAst'
|
||||
|
||||
export function updateCursors(
|
||||
setCursor: StoreState['setCursor'],
|
||||
selectionRanges: Selections,
|
||||
pathToNodeMap: { [key: number]: PathToNode }
|
||||
): (newAst: Program) => void {
|
||||
return (newAst: Program) => {
|
||||
const newSelections: Selections = {
|
||||
...selectionRanges,
|
||||
codeBasedSelections: [],
|
||||
}
|
||||
Object.entries(pathToNodeMap).forEach(([index, path]) => {
|
||||
const node = getNodeFromPath(newAst, path).node as any
|
||||
const type = selectionRanges.codeBasedSelections[Number(index)].type
|
||||
if (node) {
|
||||
newSelections.codeBasedSelections.push({
|
||||
range: [node.start, node.end],
|
||||
type: type || 'default',
|
||||
})
|
||||
}
|
||||
})
|
||||
setCursor(newSelections)
|
||||
}
|
||||
}
|
@ -88,7 +88,7 @@ export type GuiModes =
|
||||
position: Position
|
||||
}
|
||||
|
||||
interface StoreState {
|
||||
export interface StoreState {
|
||||
editorView: EditorView | null
|
||||
setEditorView: (editorView: EditorView) => void
|
||||
highlightRange: [number, number]
|
||||
@ -105,7 +105,13 @@ interface StoreState {
|
||||
resetLogs: () => void
|
||||
ast: Program | null
|
||||
setAst: (ast: Program | null) => void
|
||||
updateAst: (ast: Program, focusPath?: PathToNode) => void
|
||||
updateAst: (
|
||||
ast: Program,
|
||||
optionalParams?: {
|
||||
focusPath?: PathToNode
|
||||
callBack?: (ast: Program) => void
|
||||
}
|
||||
) => void
|
||||
updateAstAsync: (ast: Program, focusPath?: PathToNode) => void
|
||||
code: string
|
||||
setCode: (code: string) => void
|
||||
@ -185,11 +191,12 @@ export const useStore = create<StoreState>()(
|
||||
setAst: (ast) => {
|
||||
set({ ast })
|
||||
},
|
||||
updateAst: async (ast, focusPath) => {
|
||||
updateAst: async (ast, { focusPath, callBack = () => {} } = {}) => {
|
||||
const newCode = recast(ast)
|
||||
const astWithUpdatedSource = abstractSyntaxTree(
|
||||
await asyncLexer(newCode)
|
||||
)
|
||||
callBack(astWithUpdatedSource)
|
||||
|
||||
set({ ast: astWithUpdatedSource, code: newCode })
|
||||
if (focusPath) {
|
||||
@ -216,7 +223,7 @@ export const useStore = create<StoreState>()(
|
||||
// setup a new update
|
||||
pendingAstUpdates.push(
|
||||
setTimeout(() => {
|
||||
get().updateAst(ast, focusPath)
|
||||
get().updateAst(ast, { focusPath })
|
||||
}, 100) as unknown as number
|
||||
)
|
||||
},
|
||||
|
Reference in New Issue
Block a user