fix types
This commit is contained in:
@ -101,7 +101,6 @@ test.describe('Sketch tests', () => {
|
||||
page,
|
||||
scene,
|
||||
homePage,
|
||||
scene,
|
||||
}) => {
|
||||
const u = await getUtils(page)
|
||||
await page.addInitScript(async () => {
|
||||
|
@ -124,14 +124,7 @@ export const ClientSideScene = ({
|
||||
'mouseup',
|
||||
toSync(sceneInfra.onMouseUp, reportRejection)
|
||||
)
|
||||
sceneEntitiesManager
|
||||
.tearDownSketch()
|
||||
.then(() => {
|
||||
// no op
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e)
|
||||
})
|
||||
sceneEntitiesManager.tearDownSketch({ removeAxis: true })
|
||||
}
|
||||
}, [])
|
||||
|
||||
|
@ -724,7 +724,7 @@ export class SceneEntities {
|
||||
}
|
||||
const startRange = _node1.node.start
|
||||
const endRange = _node1.node.end
|
||||
const sourceRange: SourceRange = [startRange, endRange, true]
|
||||
const sourceRange: SourceRange = [startRange, endRange, 0]
|
||||
const selection: Selections = computeSelectionFromSourceRangeAndAST(
|
||||
sourceRange,
|
||||
maybeModdedAst
|
||||
@ -793,7 +793,7 @@ export class SceneEntities {
|
||||
) => {
|
||||
if (trap(modifiedAst)) return Promise.reject(modifiedAst)
|
||||
const nextAst = await kclManager.updateAst(modifiedAst, false)
|
||||
await this.tearDownSketch({ removeAxis: false })
|
||||
this.tearDownSketch({ removeAxis: false })
|
||||
sceneInfra.resetMouseListeners()
|
||||
await this.setupSketch({
|
||||
sketchEntryNodePath,
|
||||
@ -859,7 +859,7 @@ export class SceneEntities {
|
||||
|
||||
const draftExpressionsIndices = { start: index, end: index }
|
||||
|
||||
if (shouldTearDown) await this.tearDownSketch({ removeAxis: false })
|
||||
if (shouldTearDown) this.tearDownSketch({ removeAxis: false })
|
||||
sceneInfra.resetMouseListeners()
|
||||
|
||||
const { truncatedAst, programMemoryOverride } = await this.setupSketch({
|
||||
@ -1797,7 +1797,7 @@ export class SceneEntities {
|
||||
sceneInfra.setCallbacks({
|
||||
onDragEnd: async () => {
|
||||
if (addingNewSegmentStatus !== 'nothing') {
|
||||
await this.tearDownSketch({ removeAxis: false })
|
||||
this.tearDownSketch({ removeAxis: false })
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.setupSketch({
|
||||
sketchEntryNodePath,
|
||||
@ -1868,7 +1868,7 @@ export class SceneEntities {
|
||||
if (trap(mod)) return
|
||||
|
||||
await kclManager.executeAstMock(mod.modifiedAst)
|
||||
await this.tearDownSketch({ removeAxis: false })
|
||||
this.tearDownSketch({ removeAxis: false })
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.setupSketch({
|
||||
sketchEntryNodePath: pathToNode,
|
||||
@ -2289,7 +2289,7 @@ export class SceneEntities {
|
||||
removeSketchGrid() {
|
||||
if (this.axisGroup) this.scene.remove(this.axisGroup)
|
||||
}
|
||||
async tearDownSketch({ removeAxis = true }: { removeAxis?: boolean }) {
|
||||
tearDownSketch({ removeAxis = true }: { removeAxis?: boolean }) {
|
||||
// Remove all draft groups
|
||||
this.draftPointGroups.forEach((draftPointGroup) => {
|
||||
this.scene.remove(draftPointGroup)
|
||||
|
@ -767,8 +767,9 @@ export const ModelingMachineProvider = ({
|
||||
sketchPathToNode: sketchPathToNode || [],
|
||||
})
|
||||
if (err(sketchPaths)) return Promise.reject(sketchPaths)
|
||||
if (!plane.codeRef)
|
||||
return Promise.reject(new Error('No plane codeRef'))
|
||||
const noCodeRefErr = new Error('No plane codeRef')
|
||||
if (!('codeRef' in plane)) return Promise.reject(noCodeRefErr)
|
||||
if (!plane.codeRef) return Promise.reject(noCodeRefErr)
|
||||
return {
|
||||
sketchEntryNodePath: sketchPathToNode || [],
|
||||
sketchNodePaths: sketchPaths,
|
||||
@ -1314,7 +1315,7 @@ export const ModelingMachineProvider = ({
|
||||
async ({ input: { sketchDetails, data } }) => {
|
||||
if (!sketchDetails || !data)
|
||||
return reject('No sketch details or data')
|
||||
await sceneEntitiesManager.tearDownSketch({ removeAxis: false })
|
||||
sceneEntitiesManager.tearDownSketch({ removeAxis: false })
|
||||
|
||||
const result = await sceneEntitiesManager.setupDraftCircle(
|
||||
sketchDetails.sketchEntryNodePath,
|
||||
@ -1335,7 +1336,7 @@ export const ModelingMachineProvider = ({
|
||||
async ({ input: { sketchDetails, data } }) => {
|
||||
if (!sketchDetails || !data)
|
||||
return reject('No sketch details or data')
|
||||
await sceneEntitiesManager.tearDownSketch({ removeAxis: false })
|
||||
sceneEntitiesManager.tearDownSketch({ removeAxis: false })
|
||||
|
||||
const result =
|
||||
await sceneEntitiesManager.setupDraftCircleThreePoint(
|
||||
@ -1358,7 +1359,7 @@ export const ModelingMachineProvider = ({
|
||||
async ({ input: { sketchDetails, data } }) => {
|
||||
if (!sketchDetails || !data)
|
||||
return reject('No sketch details or data')
|
||||
await sceneEntitiesManager.tearDownSketch({ removeAxis: false })
|
||||
sceneEntitiesManager.tearDownSketch({ removeAxis: false })
|
||||
|
||||
const result = await sceneEntitiesManager.setupDraftRectangle(
|
||||
sketchDetails.sketchEntryNodePath,
|
||||
@ -1379,7 +1380,7 @@ export const ModelingMachineProvider = ({
|
||||
async ({ input: { sketchDetails, data } }) => {
|
||||
if (!sketchDetails || !data)
|
||||
return reject('No sketch details or data')
|
||||
await sceneEntitiesManager.tearDownSketch({ removeAxis: false })
|
||||
sceneEntitiesManager.tearDownSketch({ removeAxis: false })
|
||||
const result = await sceneEntitiesManager.setupDraftCenterRectangle(
|
||||
sketchDetails.sketchEntryNodePath,
|
||||
sketchDetails.sketchNodePaths,
|
||||
|
@ -379,12 +379,7 @@ export class KclManager {
|
||||
}
|
||||
this.ast = { ...ast }
|
||||
// updateArtifactGraph relies on updated executeState/programMemory
|
||||
await this.engineCommandManager.updateArtifactGraph(
|
||||
this.ast,
|
||||
execState.artifactCommands,
|
||||
execState.artifacts,
|
||||
args.isPartialExecution
|
||||
)
|
||||
await this.engineCommandManager.updateArtifactGraph(execState.artifactGraph)
|
||||
this._executeCallback()
|
||||
if (!isInterrupted)
|
||||
sceneInfra.modelingSend({ type: 'code edit during sketch' })
|
||||
|
@ -950,10 +950,10 @@ extrude001 = extrude(5, part001)
|
||||
const ast = assertParse(codeBefore)
|
||||
|
||||
const codeOfInterest = `startSketchOn('XZ')`
|
||||
const range: [number, number, boolean] = [
|
||||
const range: [number, number, number] = [
|
||||
codeBefore.indexOf(codeOfInterest),
|
||||
codeBefore.indexOf(codeOfInterest) + codeOfInterest.length,
|
||||
true,
|
||||
0,
|
||||
]
|
||||
const pathToPipe = getNodePathFromSourceRange(ast, range)
|
||||
|
||||
@ -977,10 +977,10 @@ extrude001 = extrude(5, part001)
|
||||
const ast = assertParse(codeBefore)
|
||||
|
||||
const codeOfInterest = `startProfileAt([1, 2], sketch001)`
|
||||
const range: [number, number, boolean] = [
|
||||
const range: [number, number, number] = [
|
||||
codeBefore.indexOf(codeOfInterest),
|
||||
codeBefore.indexOf(codeOfInterest) + codeOfInterest.length,
|
||||
true,
|
||||
0,
|
||||
]
|
||||
const pathToPipe = getNodePathFromSourceRange(ast, range)
|
||||
|
||||
|
@ -28,7 +28,9 @@ export function revolveSketch(
|
||||
ast: Node<Program>,
|
||||
pathToSketchNode: PathToNode,
|
||||
angle: Expr = createLiteral(4),
|
||||
axis: Selections,
|
||||
axisOrEdge: string,
|
||||
axis: string,
|
||||
edge: Selections,
|
||||
artifact?: Artifact
|
||||
):
|
||||
| {
|
||||
|
@ -21,6 +21,7 @@ import {
|
||||
VariableDeclaration,
|
||||
VariableDeclarator,
|
||||
recast,
|
||||
ArtifactGraph,
|
||||
} from './wasm'
|
||||
import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils'
|
||||
import { createIdentifier, splitPathAtLastIndex } from './modifyAst'
|
||||
@ -33,7 +34,7 @@ import {
|
||||
} from './std/sketchcombos'
|
||||
import { err, Reason } from 'lib/trap'
|
||||
import { Node } from 'wasm-lib/kcl/bindings/Node'
|
||||
import { ArtifactGraph, codeRefFromRange } from './std/artifactGraph'
|
||||
import { codeRefFromRange } from './std/artifactGraph'
|
||||
import { FunctionExpression } from 'wasm-lib/kcl/bindings/FunctionExpression'
|
||||
|
||||
/**
|
||||
|
@ -240,6 +240,7 @@ export function expandSegment(
|
||||
if (err(path)) return path
|
||||
if (err(surf)) return surf
|
||||
if (err(edgeCut)) return edgeCut
|
||||
if (!surf) return new Error('Segment does not have a surface')
|
||||
|
||||
return {
|
||||
type: 'segment',
|
||||
@ -435,7 +436,7 @@ function getPlaneFromSegment(
|
||||
return getPlaneFromPath(path, graph)
|
||||
}
|
||||
function getPlaneFromSolid2D(
|
||||
solid2D: Solid2DArtifact,
|
||||
solid2D: Solid2D,
|
||||
graph: ArtifactGraph
|
||||
): PlaneArtifact | WallArtifact | CapArtifact | Error {
|
||||
const path = getArtifactOfTypes(
|
||||
@ -490,7 +491,7 @@ export function getPlaneFromArtifact(
|
||||
if (artifact.type === 'plane') return artifact
|
||||
if (artifact.type === 'path') return getPlaneFromPath(artifact, graph)
|
||||
if (artifact.type === 'segment') return getPlaneFromSegment(artifact, graph)
|
||||
if (artifact.type === 'solid2D') return getPlaneFromSolid2D(artifact, graph)
|
||||
if (artifact.type === 'solid2d') return getPlaneFromSolid2D(artifact, graph)
|
||||
if (artifact.type === 'cap') return getPlaneFromCap(artifact, graph)
|
||||
if (artifact.type === 'wall') return getPlaneFromWall(artifact, graph)
|
||||
if (artifact.type === 'sweepEdge')
|
||||
|
@ -1304,7 +1304,7 @@ export const circleThreePoint: SketchLineHelper = {
|
||||
sourceRange: [
|
||||
p1Details.expr.elements[0].start,
|
||||
p1Details.expr.elements[0].end,
|
||||
true,
|
||||
0,
|
||||
],
|
||||
pathToNode: pathToP1XArg,
|
||||
value: code.slice(
|
||||
@ -1325,7 +1325,7 @@ export const circleThreePoint: SketchLineHelper = {
|
||||
sourceRange: [
|
||||
p1Details.expr.elements[1].start,
|
||||
p1Details.expr.elements[1].end,
|
||||
true,
|
||||
0,
|
||||
],
|
||||
pathToNode: pathToP1YArg,
|
||||
value: code.slice(
|
||||
@ -1346,7 +1346,7 @@ export const circleThreePoint: SketchLineHelper = {
|
||||
sourceRange: [
|
||||
p2Details.expr.elements[0].start,
|
||||
p2Details.expr.elements[0].end,
|
||||
true,
|
||||
0,
|
||||
],
|
||||
pathToNode: pathToP2XArg,
|
||||
value: code.slice(
|
||||
@ -1367,7 +1367,7 @@ export const circleThreePoint: SketchLineHelper = {
|
||||
sourceRange: [
|
||||
p2Details.expr.elements[1].start,
|
||||
p2Details.expr.elements[1].end,
|
||||
true,
|
||||
0,
|
||||
],
|
||||
pathToNode: pathToP2YArg,
|
||||
value: code.slice(
|
||||
@ -1388,7 +1388,7 @@ export const circleThreePoint: SketchLineHelper = {
|
||||
sourceRange: [
|
||||
p3Details.expr.elements[0].start,
|
||||
p3Details.expr.elements[0].end,
|
||||
true,
|
||||
0,
|
||||
],
|
||||
pathToNode: pathToP3XArg,
|
||||
value: code.slice(
|
||||
@ -1409,7 +1409,7 @@ export const circleThreePoint: SketchLineHelper = {
|
||||
sourceRange: [
|
||||
p3Details.expr.elements[1].start,
|
||||
p3Details.expr.elements[1].end,
|
||||
true,
|
||||
0,
|
||||
],
|
||||
pathToNode: pathToP3YArg,
|
||||
value: code.slice(
|
||||
|
@ -56,7 +56,7 @@ export type ModelingCommandSchema = {
|
||||
Revolve: {
|
||||
selection: Selections
|
||||
angle: KclCommandValue
|
||||
axisOrEdge: string
|
||||
axisOrEdge: 'Axis' | 'Edge'
|
||||
axis: string
|
||||
edge: Selections
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ export function getEventForSegmentSelection(
|
||||
artifact,
|
||||
codeRef: {
|
||||
pathToNode: group?.userData?.pathToNode,
|
||||
range: [node.node.start, node.node.end, true],
|
||||
range: [node.node.start, node.node.end, 0],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -700,7 +700,8 @@ export const modelingMachine = setup({
|
||||
: angle.valueAst,
|
||||
axisOrEdge,
|
||||
axis,
|
||||
edge
|
||||
edge,
|
||||
selection.graphSelections[0]?.artifact
|
||||
)
|
||||
if (trap(revolveSketchRes)) return
|
||||
const { modifiedAst, pathToRevolveArg } = revolveSketchRes
|
||||
@ -1604,7 +1605,6 @@ export const modelingMachine = setup({
|
||||
if (!input) return Promise.reject('No input provided')
|
||||
const { selection, distance } = input
|
||||
let ast = structuredClone(kclManager.ast)
|
||||
let extrudeName: string | undefined = undefined
|
||||
|
||||
const pathToNode = getNodePathFromSourceRange(
|
||||
ast,
|
||||
@ -1614,7 +1614,7 @@ export const modelingMachine = setup({
|
||||
const extrudeSketchRes = extrudeSketch(
|
||||
ast,
|
||||
pathToNode,
|
||||
false,
|
||||
selection.graphSelections[0].artifact,
|
||||
'variableName' in distance
|
||||
? distance.variableIdentifierAst
|
||||
: distance.valueAst
|
||||
|
Reference in New Issue
Block a user