Fix to preserve types using structuredClone (#3113)

This commit is contained in:
Jonathan Tran
2024-07-25 20:11:46 -04:00
committed by GitHub
parent 0e5d88df0b
commit e3b8807d6f
17 changed files with 76 additions and 87 deletions

View File

@ -495,7 +495,7 @@ export const ModelingMachineProvider = ({
if (kclManager.ast.body.length) {
// this assumes no changes have been made to the sketch besides what we did when entering the sketch
// i.e. doesn't account for user's adding code themselves, maybe we need store a flag userEditedSinceSketchMode?
const newAst: Program = JSON.parse(JSON.stringify(kclManager.ast))
const newAst = structuredClone(kclManager.ast)
const varDecIndex = sketchDetails.sketchPathToNode[1][0]
// remove body item at varDecIndex
newAst.body = newAst.body.filter((_, i) => i !== varDecIndex)

View File

@ -145,7 +145,7 @@ export async function applyConstraintIntersect({
const { transforms, forcedSelectionRanges } = info
const transform1 = transformSecondarySketchLinesTagFirst({
ast: JSON.parse(JSON.stringify(kclManager.ast)),
ast: structuredClone(kclManager.ast),
selectionRanges: forcedSelectionRanges,
transformInfos: transforms,
programMemory: kclManager.programMemory,

View File

@ -106,7 +106,7 @@ export async function applyConstraintAbsDistance({
const transformInfos = info.transforms
const transform1 = transformAstSketchLines({
ast: JSON.parse(JSON.stringify(kclManager.ast)),
ast: structuredClone(kclManager.ast),
selectionRanges: selectionRanges,
transformInfos,
programMemory: kclManager.programMemory,
@ -128,7 +128,7 @@ export async function applyConstraintAbsDistance({
)
const transform2 = transformAstSketchLines({
ast: JSON.parse(JSON.stringify(kclManager.ast)),
ast: structuredClone(kclManager.ast),
selectionRanges: selectionRanges,
transformInfos,
programMemory: kclManager.programMemory,
@ -176,7 +176,7 @@ export function applyConstraintAxisAlign({
let finalValue = createIdentifier('ZERO')
return transformAstSketchLines({
ast: JSON.parse(JSON.stringify(kclManager.ast)),
ast: structuredClone(kclManager.ast),
selectionRanges: selectionRanges,
transformInfos,
programMemory: kclManager.programMemory,

View File

@ -100,7 +100,7 @@ export async function applyConstraintAngleBetween({
const transformInfos = info.transforms
const transformed1 = transformSecondarySketchLinesTagFirst({
ast: JSON.parse(JSON.stringify(kclManager.ast)),
ast: structuredClone(kclManager.ast),
selectionRanges,
transformInfos,
programMemory: kclManager.programMemory,

View File

@ -108,7 +108,7 @@ export async function applyConstraintHorzVertDistance({
if (err(info)) return Promise.reject(info)
const transformInfos = info.transforms
const transformed = transformSecondarySketchLinesTagFirst({
ast: JSON.parse(JSON.stringify(kclManager.ast)),
ast: structuredClone(kclManager.ast),
selectionRanges,
transformInfos,
programMemory: kclManager.programMemory,

View File

@ -84,7 +84,7 @@ export async function applyConstraintAngleLength({
const { transforms } = angleLength
const sketched = transformAstSketchLines({
ast: JSON.parse(JSON.stringify(kclManager.ast)),
ast: structuredClone(kclManager.ast),
selectionRanges,
transformInfos: transforms,
programMemory: kclManager.programMemory,
@ -139,7 +139,7 @@ export async function applyConstraintAngleLength({
}
const retval = transformAstSketchLines({
ast: JSON.parse(JSON.stringify(kclManager.ast)),
ast: structuredClone(kclManager.ast),
selectionRanges,
transformInfos: transforms,
programMemory: kclManager.programMemory,