Compare commits
10 Commits
v0.18.1
...
franknoiro
Author | SHA1 | Date | |
---|---|---|---|
29070a9b04 | |||
e3861f9380 | |||
2d8d29b345 | |||
00da062586 | |||
aafbaf6c50 | |||
2894c84a4e | |||
c01084feb0 | |||
c461db5f54 | |||
03fcb73aca | |||
8065e7e51a |
@ -565,7 +565,9 @@ test('Auto complete works', async ({ page }) => {
|
||||
|
||||
await page.keyboard.press('Tab')
|
||||
await page.keyboard.type('12')
|
||||
await page.waitForTimeout(100)
|
||||
await page.keyboard.press('Tab')
|
||||
await page.waitForTimeout(100)
|
||||
await page.keyboard.press('Tab')
|
||||
await page.keyboard.press('Tab')
|
||||
await page.keyboard.press('Enter')
|
||||
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
8
src-tauri/Cargo.lock
generated
@ -2199,9 +2199,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kittycad"
|
||||
version = "0.2.67"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc460442c165c8e707b1154551cefd08938d10bb80c78940e10cd9869487c325"
|
||||
checksum = "ddc922f0da3abc22661bf49423c9bfcc02ce6ae92dae007ede6990874789545b"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -4641,9 +4641,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-fs"
|
||||
version = "2.0.0-beta.5"
|
||||
version = "2.0.0-beta.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c138126392c350aa68554e3461529b02680062c9146ab7b41d3ef97a2deaf93b"
|
||||
checksum = "609f53d90f08808679ecdd81455d9a4d0053291b92780695569f7400fdba27d5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"glob",
|
||||
|
@ -16,13 +16,13 @@ tauri-build = { version = "2.0.0-beta.12", features = [] }
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
kittycad = "0.2.67"
|
||||
kittycad = "0.3.0"
|
||||
oauth2 = "4.4.2"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
tauri = { version = "2.0.0-beta.15", features = [ "devtools", "unstable"] }
|
||||
tauri-plugin-dialog = { version = "2.0.0-beta.5" }
|
||||
tauri-plugin-fs = { version = "2.0.0-beta.5" }
|
||||
tauri-plugin-fs = { version = "2.0.0-beta.6" }
|
||||
tauri-plugin-http = { version = "2.0.0-beta.5" }
|
||||
tauri-plugin-os = { version = "2.0.0-beta.2" }
|
||||
tauri-plugin-process = { version = "2.0.0-beta.2" }
|
||||
|
@ -193,6 +193,35 @@ export const Toolbar = () => {
|
||||
Rectangle
|
||||
</ActionButton>
|
||||
</li>
|
||||
<li className="contents" key="circle-button">
|
||||
<ActionButton
|
||||
className={buttonClassName}
|
||||
Element="button"
|
||||
onClick={() =>
|
||||
state.matches('Sketch.Circle tool')
|
||||
? send('CancelSketch')
|
||||
: send('Equip circle tool')
|
||||
}
|
||||
aria-pressed={state.matches('Sketch.Circle tool')}
|
||||
icon={{
|
||||
icon: 'circle',
|
||||
iconClassName,
|
||||
bgClassName,
|
||||
}}
|
||||
disabled={
|
||||
(!state.can('Equip circle tool') &&
|
||||
!state.matches('Sketch.Circle tool')) ||
|
||||
disableAllButtons
|
||||
}
|
||||
title={
|
||||
state.can('Equip circle tool')
|
||||
? 'Circle'
|
||||
: 'Can only be used when a sketch is empty currently'
|
||||
}
|
||||
>
|
||||
Circle
|
||||
</ActionButton>
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{state.matches('Sketch.SketchIdle') &&
|
||||
|
@ -97,6 +97,7 @@ import {
|
||||
getRectangleCallExpressions,
|
||||
updateRectangleSketch,
|
||||
} from 'lib/rectangleTool'
|
||||
import { circleAsCallExpressions, updateCircleSketch } from 'lib/circleTool'
|
||||
|
||||
type DraftSegment = 'line' | 'tangentialArcTo'
|
||||
|
||||
@ -580,7 +581,7 @@ export class SceneEntities {
|
||||
...this.mouseEnterLeaveCallbacks(),
|
||||
})
|
||||
}
|
||||
setupRectangleOriginListener = () => {
|
||||
setupOriginListener = (type: 'circle' | 'rectangle') => {
|
||||
sceneInfra.setCallbacks({
|
||||
onClick: (args) => {
|
||||
const twoD = args.intersectionPoint?.twoD
|
||||
@ -589,7 +590,7 @@ export class SceneEntities {
|
||||
return
|
||||
}
|
||||
sceneInfra.modelingSend({
|
||||
type: 'Add rectangle origin',
|
||||
type: `Add ${type} origin`,
|
||||
data: [twoD.x, twoD.y],
|
||||
})
|
||||
},
|
||||
@ -747,6 +748,154 @@ export class SceneEntities {
|
||||
},
|
||||
})
|
||||
}
|
||||
setupDraftCircle = async (
|
||||
sketchPathToNode: PathToNode,
|
||||
forward: [number, number, number],
|
||||
up: [number, number, number],
|
||||
sketchOrigin: [number, number, number],
|
||||
circleOrigin: [x: number, y: number]
|
||||
) => {
|
||||
let _ast = JSON.parse(JSON.stringify(kclManager.ast))
|
||||
|
||||
const variableDeclarationName =
|
||||
getNodeFromPath<VariableDeclaration>(
|
||||
_ast,
|
||||
sketchPathToNode || [],
|
||||
'VariableDeclaration'
|
||||
)?.node?.declarations?.[0]?.id?.name || ''
|
||||
|
||||
const tags: [string] = [findUniqueName(_ast, 'circle')]
|
||||
|
||||
const startSketchOn = getNodeFromPath<VariableDeclaration>(
|
||||
_ast,
|
||||
sketchPathToNode || [],
|
||||
'VariableDeclaration'
|
||||
)?.node?.declarations
|
||||
|
||||
const startSketchOnInit = startSketchOn?.[0]?.init
|
||||
startSketchOn[0].init = createPipeExpression([
|
||||
startSketchOnInit,
|
||||
...circleAsCallExpressions(circleOrigin, tags),
|
||||
])
|
||||
|
||||
_ast = parse(recast(_ast))
|
||||
|
||||
const { programMemoryOverride, truncatedAst } = await this.setupSketch({
|
||||
sketchPathToNode,
|
||||
forward,
|
||||
up,
|
||||
position: sketchOrigin,
|
||||
maybeModdedAst: _ast,
|
||||
draftExpressionsIndices: { start: 0, end: 1 },
|
||||
})
|
||||
|
||||
sceneInfra.setCallbacks({
|
||||
onMove: async (args) => {
|
||||
// Update the radius of the draft rectangle
|
||||
const pathToNodeTwo = JSON.parse(JSON.stringify(sketchPathToNode))
|
||||
pathToNodeTwo[1][0] = 0
|
||||
|
||||
const sketchInit = getNodeFromPath<VariableDeclaration>(
|
||||
truncatedAst,
|
||||
pathToNodeTwo || [],
|
||||
'VariableDeclaration'
|
||||
)?.node?.declarations?.[0]?.init
|
||||
|
||||
const x = (args.intersectionPoint.twoD.x || 0) - circleOrigin[0]
|
||||
const y = (args.intersectionPoint.twoD.y || 0) - circleOrigin[1]
|
||||
|
||||
if (sketchInit.type === 'PipeExpression') {
|
||||
updateCircleSketch(sketchInit, x, y, tags[0])
|
||||
}
|
||||
|
||||
const { programMemory } = await executeAst({
|
||||
ast: truncatedAst,
|
||||
useFakeExecutor: true,
|
||||
engineCommandManager: this.engineCommandManager,
|
||||
programMemoryOverride,
|
||||
})
|
||||
this.sceneProgramMemory = programMemory
|
||||
const sketchGroup = programMemory.root[
|
||||
variableDeclarationName
|
||||
] as SketchGroup
|
||||
const sgPaths = sketchGroup.value
|
||||
const orthoFactor = orthoScale(sceneInfra.camControls.camera)
|
||||
|
||||
this.updateSegment(
|
||||
sketchGroup.start,
|
||||
0,
|
||||
0,
|
||||
_ast,
|
||||
orthoFactor,
|
||||
sketchGroup
|
||||
)
|
||||
sgPaths.forEach((seg, index) =>
|
||||
this.updateSegment(seg, index, 0, _ast, orthoFactor, sketchGroup)
|
||||
)
|
||||
},
|
||||
onClick: async (args) => {
|
||||
// Commit the circle to the full AST/code and return to sketch.idle
|
||||
const radiusPoint = args.intersectionPoint?.twoD
|
||||
if (!radiusPoint || args.mouseEvent.button !== 0) return
|
||||
|
||||
const x = roundOff((radiusPoint.x || 0) - circleOrigin[0])
|
||||
const y = roundOff((radiusPoint.y || 0) - circleOrigin[1])
|
||||
|
||||
const sketchInit = getNodeFromPath<VariableDeclaration>(
|
||||
_ast,
|
||||
sketchPathToNode || [],
|
||||
'VariableDeclaration'
|
||||
)?.node?.declarations?.[0]?.init
|
||||
|
||||
if (sketchInit.type === 'PipeExpression') {
|
||||
updateCircleSketch(sketchInit, x, y, tags[0])
|
||||
|
||||
_ast = parse(recast(_ast))
|
||||
|
||||
console.log('onClick', {
|
||||
sketchInit: sketchInit,
|
||||
_ast,
|
||||
x,
|
||||
y,
|
||||
truncatedAst,
|
||||
})
|
||||
|
||||
// Update the primary AST and unequip the rectangle tool
|
||||
await kclManager.executeAstMock(_ast)
|
||||
sceneInfra.modelingSend({ type: 'CancelSketch' })
|
||||
|
||||
const { programMemory } = await executeAst({
|
||||
ast: _ast,
|
||||
useFakeExecutor: true,
|
||||
engineCommandManager: this.engineCommandManager,
|
||||
programMemoryOverride,
|
||||
})
|
||||
|
||||
// Prepare to update the THREEjs scene
|
||||
this.sceneProgramMemory = programMemory
|
||||
const sketchGroup = programMemory.root[
|
||||
variableDeclarationName
|
||||
] as SketchGroup
|
||||
const sgPaths = sketchGroup.value
|
||||
const orthoFactor = orthoScale(sceneInfra.camControls.camera)
|
||||
|
||||
// Update the starting segment of the THREEjs scene
|
||||
this.updateSegment(
|
||||
sketchGroup.start,
|
||||
0,
|
||||
0,
|
||||
_ast,
|
||||
orthoFactor,
|
||||
sketchGroup
|
||||
)
|
||||
// Update the rest of the segments of the THREEjs scene
|
||||
sgPaths.forEach((seg, index) =>
|
||||
this.updateSegment(seg, index, 0, _ast, orthoFactor, sketchGroup)
|
||||
)
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
setupSketchIdleCallbacks = ({
|
||||
pathToNode,
|
||||
up,
|
||||
|
@ -61,6 +61,16 @@ const CustomIconMap = {
|
||||
/>
|
||||
</svg>
|
||||
),
|
||||
circle: (
|
||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
d="M10 2.5C9.01509 2.5 8.03982 2.69399 7.12988 3.0709C6.21994 3.44781 5.39314 4.00026 4.6967 4.6967C4.00026 5.39314 3.44782 6.21993 3.07091 7.12987C2.694 8.03981 2.5 9.01508 2.5 10C2.5 10.9849 2.69399 11.9602 3.0709 12.8701C3.44781 13.7801 4.00026 14.6069 4.6967 15.3033C5.39314 15.9997 6.21993 16.5522 7.12987 16.9291C8.03982 17.306 9.01509 17.5 10 17.5C10.9849 17.5 11.9602 17.306 12.8701 16.9291C13.7801 16.5522 14.6069 15.9997 15.3033 15.3033C15.9997 14.6069 16.5522 13.7801 16.9291 12.8701C17.306 11.9602 17.5 10.9849 17.5 10C17.5 9.01509 17.306 8.03982 16.9291 7.12988C16.5522 6.21993 15.9997 5.39314 15.3033 4.6967C14.6069 4.00026 13.7801 3.44781 12.8701 3.0709C11.9602 2.69399 10.9849 2.5 10 2.5ZM6.7472 2.14702C7.77847 1.71986 8.88377 1.5 10 1.5C11.1162 1.5 12.2215 1.71986 13.2528 2.14702C14.2841 2.57419 15.2211 3.20029 16.0104 3.98959C16.7997 4.77889 17.4258 5.71592 17.853 6.74719C18.2801 7.77846 18.5 8.88377 18.5 10C18.5 11.1162 18.2801 12.2215 17.853 13.2528C17.4258 14.2841 16.7997 15.2211 16.0104 16.0104C15.2211 16.7997 14.2841 17.4258 13.2528 17.853C12.2215 18.2801 11.1162 18.5 10 18.5C8.88376 18.5 7.77846 18.2801 6.74719 17.853C5.71592 17.4258 4.77889 16.7997 3.98959 16.0104C3.20029 15.2211 2.57419 14.2841 2.14702 13.2528C1.71986 12.2215 1.5 11.1162 1.5 10C1.5 8.88376 1.71986 7.77845 2.14703 6.74719C2.57419 5.71592 3.2003 4.77889 3.9896 3.98959C4.7789 3.20029 5.71593 2.57419 6.7472 2.14702Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
),
|
||||
clipboardCheckmark: (
|
||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
|
@ -16,7 +16,6 @@ import {
|
||||
EditorView,
|
||||
dropCursor,
|
||||
drawSelection,
|
||||
ViewUpdate,
|
||||
} from '@codemirror/view'
|
||||
import {
|
||||
indentWithTab,
|
||||
@ -191,9 +190,6 @@ export const KclEditorPane = () => {
|
||||
return extensions
|
||||
}, [kclLSP, copilotLSP, textWrapping.current, cursorBlinking.current])
|
||||
|
||||
let debounceTimer: ReturnType<typeof setTimeout> | null = null
|
||||
const updateDelay = 100
|
||||
|
||||
return (
|
||||
<div
|
||||
id="code-mirror-override"
|
||||
@ -206,17 +202,6 @@ export const KclEditorPane = () => {
|
||||
onCreateEditor={(_editorView) =>
|
||||
editorManager.setEditorView(_editorView)
|
||||
}
|
||||
onUpdate={(view: ViewUpdate) => {
|
||||
// debounce the view update.
|
||||
// otherwise it is laggy for typing.
|
||||
if (debounceTimer) {
|
||||
clearTimeout(debounceTimer)
|
||||
}
|
||||
|
||||
debounceTimer = setTimeout(() => {
|
||||
editorManager.handleOnViewUpdate(view)
|
||||
}, updateDelay)
|
||||
}}
|
||||
indentWithTab={false}
|
||||
basicSetup={false}
|
||||
/>
|
||||
|
@ -39,6 +39,8 @@ const CompletionItemKindMap = Object.fromEntries(
|
||||
) as Record<CompletionItemKind, string>
|
||||
|
||||
const changesDelay = 600
|
||||
let debounceTimer: ReturnType<typeof setTimeout> | null = null
|
||||
const updateDelay = 100
|
||||
|
||||
export class LanguageServerPlugin implements PluginValue {
|
||||
public client: LanguageServerClient
|
||||
@ -47,6 +49,7 @@ export class LanguageServerPlugin implements PluginValue {
|
||||
public workspaceFolders: LSP.WorkspaceFolder[]
|
||||
private documentVersion: number
|
||||
private foldingRanges: LSP.FoldingRange[] | null = null
|
||||
private viewUpdate: ViewUpdate | null = null
|
||||
private _defferer = deferExecution((code: string) => {
|
||||
try {
|
||||
// Update the state (not the editor) with the new code.
|
||||
@ -57,8 +60,9 @@ export class LanguageServerPlugin implements PluginValue {
|
||||
},
|
||||
contentChanges: [{ text: code }],
|
||||
})
|
||||
if (editorManager.editorView) {
|
||||
//editorManager.handleOnViewUpdate(editorManager.editorView)
|
||||
|
||||
if (this.viewUpdate) {
|
||||
editorManager.handleOnViewUpdate(this.viewUpdate)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
@ -83,14 +87,27 @@ export class LanguageServerPlugin implements PluginValue {
|
||||
})
|
||||
}
|
||||
|
||||
update({ docChanged }: ViewUpdate) {
|
||||
if (!docChanged) return
|
||||
update(viewUpdate: ViewUpdate) {
|
||||
this.viewUpdate = viewUpdate
|
||||
if (!viewUpdate.docChanged) {
|
||||
// debounce the view update.
|
||||
// otherwise it is laggy for typing.
|
||||
if (debounceTimer) {
|
||||
clearTimeout(debounceTimer)
|
||||
}
|
||||
|
||||
debounceTimer = setTimeout(() => {
|
||||
editorManager.handleOnViewUpdate(viewUpdate)
|
||||
}, updateDelay)
|
||||
return
|
||||
}
|
||||
|
||||
const newCode = this.view.state.doc.toString()
|
||||
|
||||
codeManager.code = newCode
|
||||
codeManager.writeToFile()
|
||||
kclManager.executeCode()
|
||||
|
||||
this.sendChange({
|
||||
documentText: newCode,
|
||||
})
|
||||
|
@ -266,9 +266,9 @@ const mySk1 = startSketchAt([0, 0])
|
||||
|
||||
|
||||
|> rx(45, %)
|
||||
/*
|
||||
one more for good measure
|
||||
*/
|
||||
/*
|
||||
one more for good measure
|
||||
*/
|
||||
`
|
||||
const { ast } = code2ast(code)
|
||||
const recasted = recast(ast)
|
||||
@ -285,7 +285,7 @@ const mySk1 = startSketchAt([0, 0])
|
||||
// and another with just white space between others below
|
||||
|> ry(45, %)
|
||||
|> rx(45, %)
|
||||
/* one more for good measure */
|
||||
/* one more for good measure */
|
||||
`)
|
||||
})
|
||||
})
|
||||
|
@ -102,7 +102,7 @@ describe('testing changeSketchArguments', () => {
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> ${line}
|
||||
|> lineTo([0.46, -5.82], %)
|
||||
// |> rx(45, %)
|
||||
// |> rx(45, %)
|
||||
`
|
||||
const code = genCode(lineToChange)
|
||||
const expectedCode = genCode(lineAfterChange)
|
||||
|
59
src/lib/circleTool.ts
Normal file
@ -0,0 +1,59 @@
|
||||
import {
|
||||
createArrayExpression,
|
||||
createBinaryExpression,
|
||||
createCallExpressionStdLib,
|
||||
createLiteral,
|
||||
createPipeSubstitution,
|
||||
} from 'lang/modifyAst'
|
||||
import { roundOff } from './utils'
|
||||
import {
|
||||
ArrayExpression,
|
||||
CallExpression,
|
||||
Literal,
|
||||
PipeExpression,
|
||||
} from 'lang/wasm'
|
||||
|
||||
/**
|
||||
* Returns AST expressions for this KCL code:
|
||||
* const yo = startSketchOn('XY')
|
||||
* |> circle([0, 0], 0, %)
|
||||
*/
|
||||
export const circleAsCallExpressions = (
|
||||
circleOrigin: [number, number],
|
||||
tags: [string]
|
||||
) => [
|
||||
createCallExpressionStdLib('circle', [
|
||||
createArrayExpression([
|
||||
createLiteral(roundOff(circleOrigin[0])),
|
||||
createLiteral(roundOff(circleOrigin[1])),
|
||||
]),
|
||||
createLiteral(10),
|
||||
createPipeSubstitution(),
|
||||
createLiteral(tags[0]),
|
||||
]),
|
||||
]
|
||||
|
||||
/**
|
||||
* Mutates the pipeExpression to update the circle sketch
|
||||
* @param pipeExpression
|
||||
* @param x
|
||||
* @param y
|
||||
* @param tag
|
||||
*/
|
||||
export function updateCircleSketch(
|
||||
pipeExpression: PipeExpression,
|
||||
x: number,
|
||||
y: number,
|
||||
tag: string
|
||||
) {
|
||||
const circle = pipeExpression.body[1] as CallExpression
|
||||
const origin = circle.arguments[0] as ArrayExpression
|
||||
const originX = (origin.elements[0] as Literal).value
|
||||
const originY = (origin.elements[1] as Literal).value
|
||||
|
||||
const radius = roundOff(
|
||||
Math.sqrt((x - Number(originX)) ** 2 + (y - Number(originY)) ** 2)
|
||||
)
|
||||
|
||||
;(circle.arguments[1] as Literal) = createLiteral(radius)
|
||||
}
|
28
src/wasm-lib/Cargo.lock
generated
@ -927,7 +927,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "derive-docs"
|
||||
version = "0.1.14"
|
||||
version = "0.1.16"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"anyhow",
|
||||
@ -1854,7 +1854,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-lib"
|
||||
version = "0.1.47"
|
||||
version = "0.1.49"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"approx 0.5.1",
|
||||
@ -1921,9 +1921,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kittycad"
|
||||
version = "0.2.67"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc460442c165c8e707b1154551cefd08938d10bb80c78940e10cd9869487c325"
|
||||
checksum = "ddc922f0da3abc22661bf49423c9bfcc02ce6ae92dae007ede6990874789545b"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -1959,9 +1959,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kittycad-execution-plan"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acf8ffb148bd09de8889a8a2b3075a23ee86446c3a6e1c6dcf66b40fdc778158"
|
||||
checksum = "ae99665cd699f8800da8ea4b01889c0c9c61619d2a9dc62d1d5028f1b21110bd"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"gltf-json",
|
||||
@ -2004,9 +2004,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kittycad-modeling-cmds"
|
||||
version = "0.2.19"
|
||||
version = "0.2.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35bb4946fa7bbcfd5270448e31834286c62e30e0f4599ef102a5b63e63b1f50b"
|
||||
checksum = "f93f7904109e445ab3dcfbaa4f0f4396d1df22c701075cdce4a7e491701796af"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@ -2044,9 +2044,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kittycad-modeling-session"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bae9bc47fcc3cc30727b35e738c35666b97e1e5f48f3f4c60ddaeccb69b66559"
|
||||
checksum = "241d45ca828af2953bf538f312a3e9d6fa7fe83055c90f6b6b9ffa76f53b6285"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"kittycad",
|
||||
@ -3963,18 +3963,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.58"
|
||||
version = "1.0.59"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297"
|
||||
checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.58"
|
||||
version = "1.0.59"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7"
|
||||
checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -61,12 +61,12 @@ members = [
|
||||
]
|
||||
|
||||
[workspace.dependencies]
|
||||
kittycad = { version = "0.2.67", default-features = false, features = ["js", "requests"] }
|
||||
kittycad-execution-plan = "0.1.4"
|
||||
kittycad = { version = "0.3.0", default-features = false, features = ["js", "requests"] }
|
||||
kittycad-execution-plan = "0.1.5"
|
||||
kittycad-execution-plan-macros = "0.1.9"
|
||||
kittycad-execution-plan-traits = "0.1.14"
|
||||
kittycad-modeling-cmds = "0.2.19"
|
||||
kittycad-modeling-session = "0.1.3"
|
||||
kittycad-modeling-cmds = "0.2.20"
|
||||
kittycad-modeling-session = "0.1.4"
|
||||
|
||||
[[test]]
|
||||
name = "executor"
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "derive-docs"
|
||||
description = "A tool for generating documentation from Rust derive macros"
|
||||
version = "0.1.14"
|
||||
version = "0.1.16"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
|
@ -788,17 +788,14 @@ fn generate_code_block_test(
|
||||
|
||||
ctx.run(program, None).await.unwrap();
|
||||
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
|
||||
// Zoom to fit.
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D { x: 0.0, y: 0.0, z: 0.0 },
|
||||
up: kittycad::types::Point3D { x: 0.0, y: 0.0, z: 1.0 },
|
||||
vantage: kittycad::types::Point3D { x: 0.0, y: -x, z: y },
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await.unwrap();
|
||||
|
@ -33,28 +33,13 @@ mod test_examples_show {
|
||||
.await
|
||||
.unwrap();
|
||||
ctx.run(program, None).await.unwrap();
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
},
|
||||
up: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 1.0,
|
||||
},
|
||||
vantage: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: -x,
|
||||
z: y,
|
||||
},
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
@ -125,28 +110,13 @@ mod test_examples_show {
|
||||
.await
|
||||
.unwrap();
|
||||
ctx.run(program, None).await.unwrap();
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
},
|
||||
up: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 1.0,
|
||||
},
|
||||
vantage: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: -x,
|
||||
z: y,
|
||||
},
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
@ -33,28 +33,13 @@ mod test_examples_show {
|
||||
.await
|
||||
.unwrap();
|
||||
ctx.run(program, None).await.unwrap();
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
},
|
||||
up: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 1.0,
|
||||
},
|
||||
vantage: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: -x,
|
||||
z: y,
|
||||
},
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
@ -34,28 +34,13 @@ mod test_examples_my_func {
|
||||
.await
|
||||
.unwrap();
|
||||
ctx.run(program, None).await.unwrap();
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
},
|
||||
up: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 1.0,
|
||||
},
|
||||
vantage: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: -x,
|
||||
z: y,
|
||||
},
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
@ -126,28 +111,13 @@ mod test_examples_my_func {
|
||||
.await
|
||||
.unwrap();
|
||||
ctx.run(program, None).await.unwrap();
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
},
|
||||
up: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 1.0,
|
||||
},
|
||||
vantage: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: -x,
|
||||
z: y,
|
||||
},
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
@ -35,28 +35,13 @@ mod test_examples_import {
|
||||
.await
|
||||
.unwrap();
|
||||
ctx.run(program, None).await.unwrap();
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
},
|
||||
up: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 1.0,
|
||||
},
|
||||
vantage: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: -x,
|
||||
z: y,
|
||||
},
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
@ -128,28 +113,13 @@ mod test_examples_import {
|
||||
.await
|
||||
.unwrap();
|
||||
ctx.run(program, None).await.unwrap();
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
},
|
||||
up: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 1.0,
|
||||
},
|
||||
vantage: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: -x,
|
||||
z: y,
|
||||
},
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
@ -34,28 +34,13 @@ mod test_examples_line_to {
|
||||
.await
|
||||
.unwrap();
|
||||
ctx.run(program, None).await.unwrap();
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
},
|
||||
up: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 1.0,
|
||||
},
|
||||
vantage: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: -x,
|
||||
z: y,
|
||||
},
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
@ -126,28 +111,13 @@ mod test_examples_line_to {
|
||||
.await
|
||||
.unwrap();
|
||||
ctx.run(program, None).await.unwrap();
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
},
|
||||
up: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 1.0,
|
||||
},
|
||||
vantage: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: -x,
|
||||
z: y,
|
||||
},
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
@ -33,28 +33,13 @@ mod test_examples_min {
|
||||
.await
|
||||
.unwrap();
|
||||
ctx.run(program, None).await.unwrap();
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
},
|
||||
up: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 1.0,
|
||||
},
|
||||
vantage: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: -x,
|
||||
z: y,
|
||||
},
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
@ -125,28 +110,13 @@ mod test_examples_min {
|
||||
.await
|
||||
.unwrap();
|
||||
ctx.run(program, None).await.unwrap();
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
},
|
||||
up: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 1.0,
|
||||
},
|
||||
vantage: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: -x,
|
||||
z: y,
|
||||
},
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
@ -33,28 +33,13 @@ mod test_examples_show {
|
||||
.await
|
||||
.unwrap();
|
||||
ctx.run(program, None).await.unwrap();
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
},
|
||||
up: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 1.0,
|
||||
},
|
||||
vantage: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: -x,
|
||||
z: y,
|
||||
},
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
@ -33,28 +33,13 @@ mod test_examples_import {
|
||||
.await
|
||||
.unwrap();
|
||||
ctx.run(program, None).await.unwrap();
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
},
|
||||
up: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 1.0,
|
||||
},
|
||||
vantage: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: -x,
|
||||
z: y,
|
||||
},
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
@ -33,28 +33,13 @@ mod test_examples_import {
|
||||
.await
|
||||
.unwrap();
|
||||
ctx.run(program, None).await.unwrap();
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
},
|
||||
up: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 1.0,
|
||||
},
|
||||
vantage: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: -x,
|
||||
z: y,
|
||||
},
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
@ -33,28 +33,13 @@ mod test_examples_import {
|
||||
.await
|
||||
.unwrap();
|
||||
ctx.run(program, None).await.unwrap();
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
},
|
||||
up: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 1.0,
|
||||
},
|
||||
vantage: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: -x,
|
||||
z: y,
|
||||
},
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
@ -33,28 +33,13 @@ mod test_examples_show {
|
||||
.await
|
||||
.unwrap();
|
||||
ctx.run(program, None).await.unwrap();
|
||||
let (x, y) = crate::std::utils::get_camera_zoom_magnitude_per_unit_length(units);
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
crate::executor::SourceRange::default(),
|
||||
kittycad::types::ModelingCmd::DefaultCameraLookAt {
|
||||
center: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
},
|
||||
up: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 1.0,
|
||||
},
|
||||
vantage: kittycad::types::Point3D {
|
||||
x: 0.0,
|
||||
y: -x,
|
||||
z: y,
|
||||
},
|
||||
sequence: None,
|
||||
kittycad::types::ModelingCmd::ZoomToFit {
|
||||
object_ids: Default::default(),
|
||||
padding: 0.1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
@ -14,7 +14,7 @@ kittycad-execution-plan-traits = { workspace = true }
|
||||
kittycad-execution-plan-macros = { workspace = true }
|
||||
kittycad-modeling-cmds = { workspace = true }
|
||||
kittycad-modeling-session = { workspace = true }
|
||||
thiserror = "1.0.58"
|
||||
thiserror = "1.0.59"
|
||||
tokio = { version = "1.37.0", features = ["macros", "rt"] }
|
||||
twenty-twenty = "0.7.0"
|
||||
uuid = "1.8"
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-lib"
|
||||
description = "KittyCAD Language implementation and tools"
|
||||
version = "0.1.47"
|
||||
version = "0.1.49"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
@ -19,7 +19,7 @@ chrono = "0.4.38"
|
||||
clap = { version = "4.5.4", features = ["cargo", "derive", "env", "unicode"], optional = true }
|
||||
dashmap = "5.5.3"
|
||||
databake = { version = "0.1.7", features = ["derive"] }
|
||||
derive-docs = { version = "0.1.14", path = "../derive-docs" }
|
||||
derive-docs = { version = "0.1.16", path = "../derive-docs" }
|
||||
form_urlencoded = "1.2.1"
|
||||
futures = { version = "0.3.30" }
|
||||
git_rev = "0.1.0"
|
||||
@ -36,7 +36,7 @@ schemars = { version = "0.8.16", features = ["impl_json_schema", "url", "uuid1"]
|
||||
serde = { version = "1.0.198", features = ["derive"] }
|
||||
serde_json = "1.0.116"
|
||||
sha2 = "0.10.8"
|
||||
thiserror = "1.0.58"
|
||||
thiserror = "1.0.59"
|
||||
ts-rs = { version = "7.1.1", features = ["uuid-impl", "url-impl"] }
|
||||
url = { version = "2.5.0", features = ["serde"] }
|
||||
uuid = { version = "1.8.0", features = ["v4", "js", "serde"] }
|
||||
|
@ -1864,7 +1864,13 @@ impl ObjectExpression {
|
||||
"{{ {} }}",
|
||||
self.properties
|
||||
.iter()
|
||||
.map(|prop| { format!("{}: {}", prop.key.name, prop.value.recast(options, 0, false)) })
|
||||
.map(|prop| {
|
||||
format!(
|
||||
"{}: {}",
|
||||
prop.key.name,
|
||||
prop.value.recast(options, indentation_level + 1, is_in_pipe)
|
||||
)
|
||||
})
|
||||
.collect::<Vec<String>>()
|
||||
.join(", ")
|
||||
);
|
||||
@ -1880,7 +1886,13 @@ impl ObjectExpression {
|
||||
inner_indentation,
|
||||
self.properties
|
||||
.iter()
|
||||
.map(|prop| { format!("{}: {}", prop.key.name, prop.value.recast(options, 0, false)) })
|
||||
.map(|prop| {
|
||||
format!(
|
||||
"{}: {}",
|
||||
prop.key.name,
|
||||
prop.value.recast(options, indentation_level + 1, is_in_pipe)
|
||||
)
|
||||
})
|
||||
.collect::<Vec<String>>()
|
||||
.join(format!(",\n{}", inner_indentation).as_str()),
|
||||
if is_in_pipe {
|
||||
@ -2657,7 +2669,12 @@ impl PipeExpression {
|
||||
let non_code_meta = self.non_code_meta.clone();
|
||||
if let Some(non_code_meta_value) = non_code_meta.non_code_nodes.get(&index) {
|
||||
for val in non_code_meta_value {
|
||||
let formatted = val.format(&indentation).trim_end_matches('\n').to_string();
|
||||
let formatted = if val.end == self.end {
|
||||
let indentation = options.get_indentation(indentation_level);
|
||||
val.format(&indentation).trim_end_matches('\n').to_string()
|
||||
} else {
|
||||
val.format(&indentation).trim_end_matches('\n').to_string()
|
||||
};
|
||||
if let NonCodeValue::BlockComment { .. } = val.value {
|
||||
s += "\n";
|
||||
s += &formatted;
|
||||
@ -3256,6 +3273,244 @@ fn ghi = (x) => {
|
||||
assert_eq!(recasted, r#""#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_recast_large_file() {
|
||||
let some_program_string = r#"// define constants
|
||||
const radius = 6.0
|
||||
const width = 144.0
|
||||
const length = 83.0
|
||||
const depth = 45.0
|
||||
const thk = 5
|
||||
const hole_diam = 5
|
||||
// define a rectangular shape func
|
||||
fn rectShape = (pos, w, l) => {
|
||||
const rr = startSketchOn('xy')
|
||||
|> startProfileAt([pos[0] - (w / 2), pos[1] - (l / 2)], %)
|
||||
|> lineTo([pos[0] + w / 2, pos[1] - (l / 2)], %, "edge1")
|
||||
|> lineTo([pos[0] + w / 2, pos[1] + l / 2], %, "edge2")
|
||||
|> lineTo([pos[0] - (w / 2), pos[1] + l / 2], %, "edge3")
|
||||
|> close(%, "edge4")
|
||||
return rr
|
||||
}
|
||||
// build the body of the focusrite scarlett solo gen 4
|
||||
// only used for visualization
|
||||
const scarlett_body = rectShape([0, 0], width, length)
|
||||
|> extrude(depth, %)
|
||||
|> fillet({
|
||||
radius: radius,
|
||||
tags: [
|
||||
getEdge("edge2", %),
|
||||
getEdge("edge4", %),
|
||||
getOppositeEdge("edge2", %),
|
||||
getOppositeEdge("edge4", %)
|
||||
]
|
||||
}, %)
|
||||
// build the bracket sketch around the body
|
||||
fn bracketSketch = (w, d, t) => {
|
||||
const s = startSketchOn({
|
||||
plane: {
|
||||
origin: { x: 0, y: length / 2 + thk, z: 0 },
|
||||
x_axis: { x: 1, y: 0, z: 0 },
|
||||
y_axis: { x: 0, y: 0, z: 1 },
|
||||
z_axis: { x: 0, y: 1, z: 0 }
|
||||
}
|
||||
})
|
||||
|> startProfileAt([-w / 2 - t, d + t], %)
|
||||
|> lineTo([-w / 2 - t, -t], %, "edge1")
|
||||
|> lineTo([w / 2 + t, -t], %, "edge2")
|
||||
|> lineTo([w / 2 + t, d + t], %, "edge3")
|
||||
|> lineTo([w / 2, d + t], %, "edge4")
|
||||
|> lineTo([w / 2, 0], %, "edge5")
|
||||
|> lineTo([-w / 2, 0], %, "edge6")
|
||||
|> lineTo([-w / 2, d + t], %, "edge7")
|
||||
|> close(%, "edge8")
|
||||
return s
|
||||
}
|
||||
// build the body of the bracket
|
||||
const bracket_body = bracketSketch(width, depth, thk)
|
||||
|> extrude(length + 10, %)
|
||||
|> fillet({
|
||||
radius: radius,
|
||||
tags: [
|
||||
getNextAdjacentEdge("edge7", %),
|
||||
getNextAdjacentEdge("edge2", %),
|
||||
getNextAdjacentEdge("edge3", %),
|
||||
getNextAdjacentEdge("edge6", %)
|
||||
]
|
||||
}, %)
|
||||
// build the tabs of the mounting bracket (right side)
|
||||
const tabs_r = startSketchOn({
|
||||
plane: {
|
||||
origin: { x: 0, y: 0, z: depth + thk },
|
||||
x_axis: { x: 1, y: 0, z: 0 },
|
||||
y_axis: { x: 0, y: 1, z: 0 },
|
||||
z_axis: { x: 0, y: 0, z: 1 }
|
||||
}
|
||||
})
|
||||
|> startProfileAt([width / 2 + thk, length / 2 + thk], %)
|
||||
|> line([10, -5], %)
|
||||
|> line([0, -10], %)
|
||||
|> line([-10, -5], %)
|
||||
|> close(%)
|
||||
|> hole(circle([
|
||||
width / 2 + thk + hole_diam,
|
||||
length / 2 - hole_diam
|
||||
], hole_diam / 2, %), %)
|
||||
|> extrude(-thk, %)
|
||||
|> patternLinear3d({
|
||||
axis: [0, -1, 0],
|
||||
repetitions: 1,
|
||||
distance: length - 10
|
||||
}, %)
|
||||
// build the tabs of the mounting bracket (left side)
|
||||
const tabs_l = startSketchOn({
|
||||
plane: {
|
||||
origin: { x: 0, y: 0, z: depth + thk },
|
||||
x_axis: { x: 1, y: 0, z: 0 },
|
||||
y_axis: { x: 0, y: 1, z: 0 },
|
||||
z_axis: { x: 0, y: 0, z: 1 }
|
||||
}
|
||||
})
|
||||
|> startProfileAt([-width / 2 - thk, length / 2 + thk], %)
|
||||
|> line([-10, -5], %)
|
||||
|> line([0, -10], %)
|
||||
|> line([10, -5], %)
|
||||
|> close(%)
|
||||
|> hole(circle([
|
||||
-width / 2 - thk - hole_diam,
|
||||
length / 2 - hole_diam
|
||||
], hole_diam / 2, %), %)
|
||||
|> extrude(-thk, %)
|
||||
|> patternLinear3d({
|
||||
axis: [0, -1, 0],
|
||||
repetitions: 1,
|
||||
distance: length - 10
|
||||
}, %)
|
||||
"#;
|
||||
let tokens = crate::token::lexer(some_program_string).unwrap();
|
||||
let parser = crate::parser::Parser::new(tokens);
|
||||
let program = parser.ast().unwrap();
|
||||
println!("{:#?}", program);
|
||||
|
||||
let recasted = program.recast(&Default::default(), 0);
|
||||
// Its VERY important this comes back with zero new lines.
|
||||
assert_eq!(
|
||||
recasted,
|
||||
r#"// define constants
|
||||
const radius = 6.0
|
||||
const width = 144.0
|
||||
const length = 83.0
|
||||
const depth = 45.0
|
||||
const thk = 5
|
||||
const hole_diam = 5
|
||||
// define a rectangular shape func
|
||||
fn rectShape = (pos, w, l) => {
|
||||
const rr = startSketchOn('xy')
|
||||
|> startProfileAt([pos[0] - (w / 2), pos[1] - (l / 2)], %)
|
||||
|> lineTo([pos[0] + w / 2, pos[1] - (l / 2)], %, "edge1")
|
||||
|> lineTo([pos[0] + w / 2, pos[1] + l / 2], %, "edge2")
|
||||
|> lineTo([pos[0] - (w / 2), pos[1] + l / 2], %, "edge3")
|
||||
|> close(%, "edge4")
|
||||
return rr
|
||||
}
|
||||
// build the body of the focusrite scarlett solo gen 4
|
||||
// only used for visualization
|
||||
const scarlett_body = rectShape([0, 0], width, length)
|
||||
|> extrude(depth, %)
|
||||
|> fillet({
|
||||
radius: radius,
|
||||
tags: [
|
||||
getEdge("edge2", %),
|
||||
getEdge("edge4", %),
|
||||
getOppositeEdge("edge2", %),
|
||||
getOppositeEdge("edge4", %)
|
||||
]
|
||||
}, %)
|
||||
// build the bracket sketch around the body
|
||||
fn bracketSketch = (w, d, t) => {
|
||||
const s = startSketchOn({
|
||||
plane: {
|
||||
origin: { x: 0, y: length / 2 + thk, z: 0 },
|
||||
x_axis: { x: 1, y: 0, z: 0 },
|
||||
y_axis: { x: 0, y: 0, z: 1 },
|
||||
z_axis: { x: 0, y: 1, z: 0 }
|
||||
}
|
||||
})
|
||||
|> startProfileAt([-w / 2 - t, d + t], %)
|
||||
|> lineTo([-w / 2 - t, -t], %, "edge1")
|
||||
|> lineTo([w / 2 + t, -t], %, "edge2")
|
||||
|> lineTo([w / 2 + t, d + t], %, "edge3")
|
||||
|> lineTo([w / 2, d + t], %, "edge4")
|
||||
|> lineTo([w / 2, 0], %, "edge5")
|
||||
|> lineTo([-w / 2, 0], %, "edge6")
|
||||
|> lineTo([-w / 2, d + t], %, "edge7")
|
||||
|> close(%, "edge8")
|
||||
return s
|
||||
}
|
||||
// build the body of the bracket
|
||||
const bracket_body = bracketSketch(width, depth, thk)
|
||||
|> extrude(length + 10, %)
|
||||
|> fillet({
|
||||
radius: radius,
|
||||
tags: [
|
||||
getNextAdjacentEdge("edge7", %),
|
||||
getNextAdjacentEdge("edge2", %),
|
||||
getNextAdjacentEdge("edge3", %),
|
||||
getNextAdjacentEdge("edge6", %)
|
||||
]
|
||||
}, %)
|
||||
// build the tabs of the mounting bracket (right side)
|
||||
const tabs_r = startSketchOn({
|
||||
plane: {
|
||||
origin: { x: 0, y: 0, z: depth + thk },
|
||||
x_axis: { x: 1, y: 0, z: 0 },
|
||||
y_axis: { x: 0, y: 1, z: 0 },
|
||||
z_axis: { x: 0, y: 0, z: 1 }
|
||||
}
|
||||
})
|
||||
|> startProfileAt([width / 2 + thk, length / 2 + thk], %)
|
||||
|> line([10, -5], %)
|
||||
|> line([0, -10], %)
|
||||
|> line([-10, -5], %)
|
||||
|> close(%)
|
||||
|> hole(circle([
|
||||
width / 2 + thk + hole_diam,
|
||||
length / 2 - hole_diam
|
||||
], hole_diam / 2, %), %)
|
||||
|> extrude(-thk, %)
|
||||
|> patternLinear3d({
|
||||
axis: [0, -1, 0],
|
||||
repetitions: 1,
|
||||
distance: length - 10
|
||||
}, %)
|
||||
// build the tabs of the mounting bracket (left side)
|
||||
const tabs_l = startSketchOn({
|
||||
plane: {
|
||||
origin: { x: 0, y: 0, z: depth + thk },
|
||||
x_axis: { x: 1, y: 0, z: 0 },
|
||||
y_axis: { x: 0, y: 1, z: 0 },
|
||||
z_axis: { x: 0, y: 0, z: 1 }
|
||||
}
|
||||
})
|
||||
|> startProfileAt([-width / 2 - thk, length / 2 + thk], %)
|
||||
|> line([-10, -5], %)
|
||||
|> line([0, -10], %)
|
||||
|> line([10, -5], %)
|
||||
|> close(%)
|
||||
|> hole(circle([
|
||||
-width / 2 - thk - hole_diam,
|
||||
length / 2 - hole_diam
|
||||
], hole_diam / 2, %), %)
|
||||
|> extrude(-thk, %)
|
||||
|> patternLinear3d({
|
||||
axis: [0, -1, 0],
|
||||
repetitions: 1,
|
||||
distance: length - 10
|
||||
}, %)
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_recast_nested_var_declaration_in_fn_body() {
|
||||
let some_program_string = r#"fn cube = (pos, scale) => {
|
||||
@ -3543,7 +3798,7 @@ const mySk1 = startSketchOn('XY')
|
||||
// and another with just white space between others below
|
||||
|> ry(45, %)
|
||||
|> rx(45, %)
|
||||
// one more for good measure
|
||||
// one more for good measure
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
@ -736,10 +736,12 @@ pub fn completion_item_from_enum_schema(
|
||||
anyhow::bail!("expected at least one enum value: {:#?}", o);
|
||||
}
|
||||
|
||||
let label = enum_values[0].to_string();
|
||||
let serde_json::Value::String(ref enum_value) = enum_values[0] else {
|
||||
anyhow::bail!("expected string enum value: {:#?}", enum_values[0]);
|
||||
};
|
||||
|
||||
Ok(CompletionItem {
|
||||
label,
|
||||
label: enum_value.to_string(),
|
||||
label_details: None,
|
||||
kind: Some(kind),
|
||||
detail: Some(description.to_string()),
|
||||
|
@ -124,7 +124,7 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static {
|
||||
let batched_requests = WebSocketRequest::ModelingCmdBatchReq {
|
||||
requests,
|
||||
batch_id: uuid::Uuid::new_v4(),
|
||||
responses: Some(false),
|
||||
responses: false,
|
||||
};
|
||||
|
||||
let final_req = if self.batch().lock().unwrap().len() == 1 {
|
||||
@ -365,6 +365,7 @@ pub fn is_cmd_with_return_values(cmd: &kittycad::types::ModelingCmd) -> bool {
|
||||
| kittycad::types::ModelingCmd::EntityGetDistance { .. }
|
||||
| kittycad::types::ModelingCmd::EntityLinearPattern { .. }
|
||||
| kittycad::types::ModelingCmd::EntityCircularPattern { .. }
|
||||
| kittycad::types::ModelingCmd::ZoomToFit { .. }
|
||||
| kittycad::types::ModelingCmd::Solid3DGetExtrusionFaceInfo { .. }) = cmd
|
||||
else {
|
||||
return false;
|
||||
|
@ -793,6 +793,56 @@ st"#
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_kcl_lsp_completions_const_raw() {
|
||||
let server = kcl_lsp_server(false).await.unwrap();
|
||||
|
||||
// Send open file.
|
||||
server
|
||||
.did_open(tower_lsp::lsp_types::DidOpenTextDocumentParams {
|
||||
text_document: tower_lsp::lsp_types::TextDocumentItem {
|
||||
uri: "file:///test.kcl".try_into().unwrap(),
|
||||
language_id: "kcl".to_string(),
|
||||
version: 1,
|
||||
text: r#"con"#.to_string(),
|
||||
},
|
||||
})
|
||||
.await;
|
||||
|
||||
// Send completion request.
|
||||
let completions = server
|
||||
.completion(tower_lsp::lsp_types::CompletionParams {
|
||||
text_document_position: tower_lsp::lsp_types::TextDocumentPositionParams {
|
||||
text_document: tower_lsp::lsp_types::TextDocumentIdentifier {
|
||||
uri: "file:///test.kcl".try_into().unwrap(),
|
||||
},
|
||||
position: tower_lsp::lsp_types::Position { line: 0, character: 2 },
|
||||
},
|
||||
context: None,
|
||||
partial_result_params: Default::default(),
|
||||
work_done_progress_params: Default::default(),
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
|
||||
// Check the completions.
|
||||
if let tower_lsp::lsp_types::CompletionResponse::Array(completions) = completions {
|
||||
assert!(completions.len() > 10);
|
||||
// Find the one with label "const".
|
||||
let const_completion = completions
|
||||
.iter()
|
||||
.find(|completion| completion.label == "const")
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
const_completion.kind,
|
||||
Some(tower_lsp::lsp_types::CompletionItemKind::KEYWORD)
|
||||
);
|
||||
} else {
|
||||
panic!("Expected array of completions");
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_kcl_lsp_on_hover() {
|
||||
let server = kcl_lsp_server(false).await.unwrap();
|
||||
|
@ -1517,12 +1517,12 @@ async fn inner_bezier_curve(
|
||||
ModelingCmd::ExtendPath {
|
||||
path: sketch_group.id,
|
||||
segment: kittycad::types::PathSegment::Bezier {
|
||||
control1: Point3D {
|
||||
control_1: Point3D {
|
||||
x: data.control1[0],
|
||||
y: data.control1[1],
|
||||
z: 0.0,
|
||||
},
|
||||
control2: Point3D {
|
||||
control_2: Point3D {
|
||||
x: data.control2[0],
|
||||
y: data.control2[1],
|
||||
z: 0.0,
|
||||
|
@ -838,24 +838,3 @@ pub fn get_tangent_point_from_previous_arc(
|
||||
tangential_angle.to_radians().sin() * 10.0 + last_arc_end[1],
|
||||
]
|
||||
}
|
||||
|
||||
fn unit_length_to_mm(base_unit: kittycad::types::UnitLength) -> f64 {
|
||||
match base_unit {
|
||||
kittycad::types::UnitLength::Mm => 1.0,
|
||||
kittycad::types::UnitLength::Cm => 10.0,
|
||||
kittycad::types::UnitLength::M => 1000.0,
|
||||
kittycad::types::UnitLength::In => 25.4,
|
||||
kittycad::types::UnitLength::Ft => 304.8,
|
||||
kittycad::types::UnitLength::Yd => 914.4,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_camera_zoom_magnitude_per_unit_length(unit: kittycad::types::UnitLength) -> (f64, f64) {
|
||||
let base_radius = 5.6_f64;
|
||||
let cam_height_distance_ratio = 0.5_f64;
|
||||
let length = unit_length_to_mm(unit) * base_radius * 20.0;
|
||||
let ang = cam_height_distance_ratio.atan();
|
||||
let x = ang.cos() * length;
|
||||
let y = ang.sin() * length;
|
||||
(x, y)
|
||||
}
|
||||
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 128 KiB |
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 127 KiB |
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 124 KiB |
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 109 KiB |
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 125 KiB |
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 126 KiB |
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 137 KiB |
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 131 KiB |
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 19 KiB |