Compare commits
17 Commits
jtran/disa
...
v0.24.6
Author | SHA1 | Date | |
---|---|---|---|
19a93e8deb | |||
b8c623e1ec | |||
4006c28479 | |||
8c932fdb8d | |||
a74c715c01 | |||
1ac39d95f2 | |||
41b1ec94fa | |||
525c803888 | |||
2ee1c78aad | |||
dc21034b86 | |||
1684786659 | |||
12505b4398 | |||
115f2fdea2 | |||
0df28abc4b | |||
1e07ea4986 | |||
f34c23d203 | |||
5295f0ae7d |
@ -4179,12 +4179,15 @@ test.describe('Sketch tests', () => {
|
|||||||
await page.setViewportSize({ width: 1200, height: 500 })
|
await page.setViewportSize({ width: 1200, height: 500 })
|
||||||
|
|
||||||
await u.waitForAuthSkipAppStart()
|
await u.waitForAuthSkipAppStart()
|
||||||
await page.getByText('tangentialArcTo([24.95, -5.38], %)').click()
|
|
||||||
|
|
||||||
await expect(
|
await expect(async () => {
|
||||||
page.getByRole('button', { name: 'Edit Sketch' })
|
await page.mouse.click(700, 200)
|
||||||
).toBeEnabled()
|
await page.getByText('tangentialArcTo([24.95, -5.38], %)').click()
|
||||||
await page.getByRole('button', { name: 'Edit Sketch' }).click()
|
await expect(
|
||||||
|
page.getByRole('button', { name: 'Edit Sketch' })
|
||||||
|
).toBeEnabled({ timeout: 1000 })
|
||||||
|
await page.getByRole('button', { name: 'Edit Sketch' }).click()
|
||||||
|
}).toPass({ timeout: 40_000, intervals: [1_000] })
|
||||||
|
|
||||||
await page.waitForTimeout(600) // wait for animation
|
await page.waitForTimeout(600) // wait for animation
|
||||||
|
|
||||||
@ -7290,15 +7293,15 @@ test.describe('Test network and connection issues', () => {
|
|||||||
.toHaveText(`const sketch001 = startSketchOn('XZ')
|
.toHaveText(`const sketch001 = startSketchOn('XZ')
|
||||||
|> startProfileAt(${commonPoints.startAt}, %)
|
|> startProfileAt(${commonPoints.startAt}, %)
|
||||||
|> line([${commonPoints.num1}, 0], %)
|
|> line([${commonPoints.num1}, 0], %)
|
||||||
|> line([-9.16, 8.81], %)`)
|
|> line([-8.84, 8.75], %)`)
|
||||||
await page.waitForTimeout(100)
|
await page.waitForTimeout(100)
|
||||||
await page.mouse.click(startXPx, 500 - PUR * 20)
|
await page.mouse.click(startXPx, 500 - PUR * 20)
|
||||||
await expect(page.locator('.cm-content'))
|
await expect(page.locator('.cm-content'))
|
||||||
.toHaveText(`const sketch001 = startSketchOn('XZ')
|
.toHaveText(`const sketch001 = startSketchOn('XZ')
|
||||||
|> startProfileAt(${commonPoints.startAt}, %)
|
|> startProfileAt(${commonPoints.startAt}, %)
|
||||||
|> line([${commonPoints.num1}, 0], %)
|
|> line([${commonPoints.num1}, 0], %)
|
||||||
|> line([-9.16, 8.81], %)
|
|> line([-8.84, 8.75], %)
|
||||||
|> line([-5.28, 0], %)`)
|
|> line([-5.6, 0], %)`)
|
||||||
|
|
||||||
// Unequip line tool
|
// Unequip line tool
|
||||||
await page.keyboard.press('Escape')
|
await page.keyboard.press('Escape')
|
||||||
@ -8094,3 +8097,34 @@ test('Sketch on face', async ({ page }) => {
|
|||||||
const sketch002 = extrude(${[5, 5]} + 7, sketch002)`
|
const sketch002 = extrude(${[5, 5]} + 7, sketch002)`
|
||||||
await expect(page.locator('.cm-content')).toHaveText(result2.regExp)
|
await expect(page.locator('.cm-content')).toHaveText(result2.regExp)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('Typing KCL errors induces a badge on the error logs pane button', async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
const u = await getUtils(page)
|
||||||
|
|
||||||
|
// Load the app with the working starter code
|
||||||
|
await page.addInitScript((code) => {
|
||||||
|
localStorage.setItem('persistCode', code)
|
||||||
|
}, bracket)
|
||||||
|
|
||||||
|
await page.setViewportSize({ width: 1200, height: 500 })
|
||||||
|
await u.waitForAuthSkipAppStart()
|
||||||
|
|
||||||
|
// wait for execution done
|
||||||
|
await u.openDebugPanel()
|
||||||
|
await u.expectCmdLog('[data-message-type="execution-done"]')
|
||||||
|
await u.closeDebugPanel()
|
||||||
|
|
||||||
|
// Ensure no badge is present
|
||||||
|
const errorLogsButton = page.getByRole('button', { name: 'KCL Errors pane' })
|
||||||
|
await expect(errorLogsButton).not.toContainText('notification')
|
||||||
|
|
||||||
|
// Delete a character to break the KCL
|
||||||
|
await u.openKclCodePanel()
|
||||||
|
await page.getByText('extrude(').click()
|
||||||
|
await page.keyboard.press('Backspace')
|
||||||
|
|
||||||
|
// Ensure that a badge appears on the button
|
||||||
|
await expect(errorLogsButton).toContainText('notification')
|
||||||
|
})
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 39 KiB |
@ -266,7 +266,7 @@ export async function getUtils(page: Page) {
|
|||||||
getSegmentBodyCoords: async (locator: string, px = 30) => {
|
getSegmentBodyCoords: async (locator: string, px = 30) => {
|
||||||
const overlay = page.locator(locator)
|
const overlay = page.locator(locator)
|
||||||
const bbox = await overlay
|
const bbox = await overlay
|
||||||
.boundingBox()
|
.boundingBox({ timeout: 5000 })
|
||||||
.then((box) => ({ ...box, x: box?.x || 0, y: box?.y || 0 }))
|
.then((box) => ({ ...box, x: box?.x || 0, y: box?.y || 0 }))
|
||||||
const angle = Number(await overlay.getAttribute('data-overlay-angle'))
|
const angle = Number(await overlay.getAttribute('data-overlay-angle'))
|
||||||
const angleXOffset = Math.cos(((angle - 180) * Math.PI) / 180) * px
|
const angleXOffset = Math.cos(((angle - 180) * Math.PI) / 180) * px
|
||||||
|
340
openapi/machine-api.json
Normal file
340
openapi/machine-api.json
Normal file
@ -0,0 +1,340 @@
|
|||||||
|
{
|
||||||
|
"components": {
|
||||||
|
"responses": {
|
||||||
|
"Error": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/Error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "Error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"schemas": {
|
||||||
|
"Error": {
|
||||||
|
"description": "Error information from a response.",
|
||||||
|
"properties": {
|
||||||
|
"error_code": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"message": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"request_id": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"message",
|
||||||
|
"request_id"
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"Machine": {
|
||||||
|
"description": "Details for a 3d printer connected over USB.",
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"description": "Details for a 3d printer connected over USB.",
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"manufacturer": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"model": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"port": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"UsbPrinter"
|
||||||
|
],
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"manufacturer",
|
||||||
|
"model",
|
||||||
|
"port",
|
||||||
|
"type"
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Details for a 3d printer connected over USB.",
|
||||||
|
"properties": {
|
||||||
|
"hostname": {
|
||||||
|
"description": "The hostname of the printer.",
|
||||||
|
"nullable": true,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"ip": {
|
||||||
|
"description": "The IP address of the printer.",
|
||||||
|
"format": "ip",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"manufacturer": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/NetworkPrinterManufacturer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "The manufacturer of the printer."
|
||||||
|
},
|
||||||
|
"model": {
|
||||||
|
"description": "The model of the printer.",
|
||||||
|
"nullable": true,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"port": {
|
||||||
|
"description": "The port of the printer.",
|
||||||
|
"format": "uint16",
|
||||||
|
"minimum": 0,
|
||||||
|
"nullable": true,
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"serial": {
|
||||||
|
"description": "The serial number of the printer.",
|
||||||
|
"nullable": true,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"NetworkPrinter"
|
||||||
|
],
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"ip",
|
||||||
|
"manufacturer",
|
||||||
|
"type"
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"NetworkPrinterManufacturer": {
|
||||||
|
"description": "Network printer manufacturer.",
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"description": "Bambu.",
|
||||||
|
"enum": [
|
||||||
|
"Bambu"
|
||||||
|
],
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Formlabs.",
|
||||||
|
"enum": [
|
||||||
|
"Formlabs"
|
||||||
|
],
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Pong": {
|
||||||
|
"description": "The response from the `/ping` endpoint.",
|
||||||
|
"properties": {
|
||||||
|
"message": {
|
||||||
|
"description": "The pong response.",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"message"
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"PrintJobResponse": {
|
||||||
|
"description": "The response from the `/print` endpoint.",
|
||||||
|
"properties": {
|
||||||
|
"job_id": {
|
||||||
|
"description": "The job id used for this print.",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"parameters": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/PrintParameters"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "The parameters used for this print."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"job_id",
|
||||||
|
"parameters"
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"PrintParameters": {
|
||||||
|
"description": "Parameters for printing.",
|
||||||
|
"properties": {
|
||||||
|
"machine_id": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"machine_id"
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"info": {
|
||||||
|
"contact": {
|
||||||
|
"email": "machine-api@zoo.dev",
|
||||||
|
"url": "https://zoo.dev"
|
||||||
|
},
|
||||||
|
"description": "",
|
||||||
|
"title": "machine-api",
|
||||||
|
"version": "0.1.0"
|
||||||
|
},
|
||||||
|
"openapi": "3.0.3",
|
||||||
|
"paths": {
|
||||||
|
"/": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "api_get_schema",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "successful operation"
|
||||||
|
},
|
||||||
|
"4XX": {
|
||||||
|
"$ref": "#/components/responses/Error"
|
||||||
|
},
|
||||||
|
"5XX": {
|
||||||
|
"$ref": "#/components/responses/Error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"summary": "Return the OpenAPI schema in JSON format.",
|
||||||
|
"tags": [
|
||||||
|
"meta"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/machines": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "get_machines",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"additionalProperties": {
|
||||||
|
"$ref": "#/components/schemas/Machine"
|
||||||
|
},
|
||||||
|
"title": "Map_of_Machine",
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "successful operation"
|
||||||
|
},
|
||||||
|
"4XX": {
|
||||||
|
"$ref": "#/components/responses/Error"
|
||||||
|
},
|
||||||
|
"5XX": {
|
||||||
|
"$ref": "#/components/responses/Error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"summary": "List available machines and their statuses",
|
||||||
|
"tags": [
|
||||||
|
"print"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/ping": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "ping",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/Pong"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "successful operation"
|
||||||
|
},
|
||||||
|
"4XX": {
|
||||||
|
"$ref": "#/components/responses/Error"
|
||||||
|
},
|
||||||
|
"5XX": {
|
||||||
|
"$ref": "#/components/responses/Error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"summary": "Return pong.",
|
||||||
|
"tags": [
|
||||||
|
"meta"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/print": {
|
||||||
|
"post": {
|
||||||
|
"operationId": "print_file",
|
||||||
|
"requestBody": {
|
||||||
|
"content": {
|
||||||
|
"multipart/form-data": {
|
||||||
|
"schema": {
|
||||||
|
"format": "binary",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/PrintJobResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "successful operation"
|
||||||
|
},
|
||||||
|
"4XX": {
|
||||||
|
"$ref": "#/components/responses/Error"
|
||||||
|
},
|
||||||
|
"5XX": {
|
||||||
|
"$ref": "#/components/responses/Error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"summary": "Print a given file. File must be a sliceable 3D model.",
|
||||||
|
"tags": [
|
||||||
|
"print"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"description": "Meta information about the API.",
|
||||||
|
"externalDocs": {
|
||||||
|
"url": "https://docs.zoo.dev/api/meta"
|
||||||
|
},
|
||||||
|
"name": "meta"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Utilities for printing and discovering printers.",
|
||||||
|
"externalDocs": {
|
||||||
|
"url": "https://docs.zoo.dev/api/print"
|
||||||
|
},
|
||||||
|
"name": "print"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "untitled-app",
|
"name": "untitled-app",
|
||||||
"version": "0.24.4",
|
"version": "0.24.6",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codemirror/autocomplete": "^6.17.0",
|
"@codemirror/autocomplete": "^6.17.0",
|
||||||
|
25
src-tauri/Cargo.lock
generated
25
src-tauri/Cargo.lock
generated
@ -648,6 +648,12 @@ version = "1.5.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "byteorder-lite"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
@ -2399,6 +2405,18 @@ dependencies = [
|
|||||||
"unicode-normalization",
|
"unicode-normalization",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "image"
|
||||||
|
version = "0.25.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "99314c8a2152b8ddb211f924cdae532d8c5e4c8bb54728e12fff1b0cd5963a10"
|
||||||
|
dependencies = [
|
||||||
|
"bytemuck",
|
||||||
|
"byteorder-lite",
|
||||||
|
"num-traits",
|
||||||
|
"png",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "1.9.3"
|
version = "1.9.3"
|
||||||
@ -2571,7 +2589,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kcl-lib"
|
name = "kcl-lib"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"approx",
|
"approx",
|
||||||
@ -2589,6 +2607,7 @@ dependencies = [
|
|||||||
"futures",
|
"futures",
|
||||||
"git_rev",
|
"git_rev",
|
||||||
"gltf-json",
|
"gltf-json",
|
||||||
|
"image",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"kittycad",
|
"kittycad",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
@ -3520,9 +3539,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "phonenumber"
|
name = "phonenumber"
|
||||||
version = "0.3.5+8.13.36"
|
version = "0.3.6+8.13.36"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f174c8db59b620032bd52b655fc97000458850fec0db35fcd4e802b668517ec0"
|
checksum = "11756237b57b8cc5e97dc8b1e70ea436324d30e7075de63b14fd15073a8f692a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"either",
|
"either",
|
||||||
|
@ -80,5 +80,5 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"productName": "Zoo Modeling App",
|
"productName": "Zoo Modeling App",
|
||||||
"version": "0.24.4"
|
"version": "0.24.6"
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import {
|
|||||||
defaultPlaneColor,
|
defaultPlaneColor,
|
||||||
getSceneScale,
|
getSceneScale,
|
||||||
INTERSECTION_PLANE_LAYER,
|
INTERSECTION_PLANE_LAYER,
|
||||||
|
OnClickCallbackArgs,
|
||||||
OnMouseEnterLeaveArgs,
|
OnMouseEnterLeaveArgs,
|
||||||
RAYCASTABLE_PLANE,
|
RAYCASTABLE_PLANE,
|
||||||
SEGMENT_LENGTH_LABEL,
|
SEGMENT_LENGTH_LABEL,
|
||||||
@ -78,6 +79,7 @@ import {
|
|||||||
} from 'lang/std/sketch'
|
} from 'lang/std/sketch'
|
||||||
import { isOverlap, normaliseAngle, roundOff, throttle } from 'lib/utils'
|
import { isOverlap, normaliseAngle, roundOff, throttle } from 'lib/utils'
|
||||||
import {
|
import {
|
||||||
|
addStartProfileAt,
|
||||||
createArrayExpression,
|
createArrayExpression,
|
||||||
createCallExpressionStdLib,
|
createCallExpressionStdLib,
|
||||||
createLiteral,
|
createLiteral,
|
||||||
@ -296,6 +298,51 @@ export class SceneEntities {
|
|||||||
if (intersectionPlane) this.scene.remove(intersectionPlane)
|
if (intersectionPlane) this.scene.remove(intersectionPlane)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupNoPointsListener({
|
||||||
|
sketchDetails,
|
||||||
|
afterClick,
|
||||||
|
}: {
|
||||||
|
sketchDetails: SketchDetails
|
||||||
|
afterClick: (args: OnClickCallbackArgs) => void
|
||||||
|
}) {
|
||||||
|
// Create a THREEjs plane to raycast clicks onto
|
||||||
|
this.createIntersectionPlane()
|
||||||
|
const quaternion = quaternionFromUpNForward(
|
||||||
|
new Vector3(...sketchDetails.yAxis),
|
||||||
|
new Vector3(...sketchDetails.zAxis)
|
||||||
|
)
|
||||||
|
|
||||||
|
// Position the click raycast plane
|
||||||
|
if (this.intersectionPlane) {
|
||||||
|
this.intersectionPlane.setRotationFromQuaternion(quaternion)
|
||||||
|
this.intersectionPlane.position.copy(
|
||||||
|
new Vector3(...(sketchDetails?.origin || [0, 0, 0]))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
sceneInfra.setCallbacks({
|
||||||
|
onClick: async (args) => {
|
||||||
|
if (!args) return
|
||||||
|
if (args.mouseEvent.which !== 1) return
|
||||||
|
const { intersectionPoint } = args
|
||||||
|
if (!intersectionPoint?.twoD || !sketchDetails?.sketchPathToNode) return
|
||||||
|
const addStartProfileAtRes = addStartProfileAt(
|
||||||
|
kclManager.ast,
|
||||||
|
sketchDetails.sketchPathToNode,
|
||||||
|
[intersectionPoint.twoD.x, intersectionPoint.twoD.y]
|
||||||
|
)
|
||||||
|
|
||||||
|
if (trap(addStartProfileAtRes)) return
|
||||||
|
const { modifiedAst } = addStartProfileAtRes
|
||||||
|
|
||||||
|
await kclManager.updateAst(modifiedAst, false)
|
||||||
|
this.removeIntersectionPlane()
|
||||||
|
|
||||||
|
// Now perform the caller-specified action
|
||||||
|
afterClick(args)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async setupSketch({
|
async setupSketch({
|
||||||
sketchPathToNode,
|
sketchPathToNode,
|
||||||
forward,
|
forward,
|
||||||
@ -672,21 +719,6 @@ export class SceneEntities {
|
|||||||
...this.mouseEnterLeaveCallbacks(),
|
...this.mouseEnterLeaveCallbacks(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
setupRectangleOriginListener = () => {
|
|
||||||
sceneInfra.setCallbacks({
|
|
||||||
onClick: (args) => {
|
|
||||||
const twoD = args.intersectionPoint?.twoD
|
|
||||||
if (!twoD) {
|
|
||||||
console.warn(`This click didn't have a 2D intersection`, args)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
sceneInfra.modelingSend({
|
|
||||||
type: 'Add rectangle origin',
|
|
||||||
data: [twoD.x, twoD.y],
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
setupDraftRectangle = async (
|
setupDraftRectangle = async (
|
||||||
sketchPathToNode: PathToNode,
|
sketchPathToNode: PathToNode,
|
||||||
forward: [number, number, number],
|
forward: [number, number, number],
|
||||||
@ -704,6 +736,8 @@ export class SceneEntities {
|
|||||||
if (trap(_node1)) return Promise.reject(_node1)
|
if (trap(_node1)) return Promise.reject(_node1)
|
||||||
const variableDeclarationName =
|
const variableDeclarationName =
|
||||||
_node1.node?.declarations?.[0]?.id?.name || ''
|
_node1.node?.declarations?.[0]?.id?.name || ''
|
||||||
|
const startSketchOn = _node1.node?.declarations
|
||||||
|
const startSketchOnInit = startSketchOn?.[0]?.init
|
||||||
|
|
||||||
const tags: [string, string, string] = [
|
const tags: [string, string, string] = [
|
||||||
findUniqueName(_ast, 'rectangleSegmentA'),
|
findUniqueName(_ast, 'rectangleSegmentA'),
|
||||||
@ -711,15 +745,6 @@ export class SceneEntities {
|
|||||||
findUniqueName(_ast, 'rectangleSegmentC'),
|
findUniqueName(_ast, 'rectangleSegmentC'),
|
||||||
]
|
]
|
||||||
|
|
||||||
const _node2 = getNodeFromPath<VariableDeclaration>(
|
|
||||||
_ast,
|
|
||||||
sketchPathToNode || [],
|
|
||||||
'VariableDeclaration'
|
|
||||||
)
|
|
||||||
if (trap(_node2)) return Promise.reject(_node2)
|
|
||||||
const startSketchOn = _node2.node?.declarations
|
|
||||||
|
|
||||||
const startSketchOnInit = startSketchOn?.[0]?.init
|
|
||||||
startSketchOn[0].init = createPipeExpression([
|
startSketchOn[0].init = createPipeExpression([
|
||||||
startSketchOnInit,
|
startSketchOnInit,
|
||||||
...getRectangleCallExpressions(rectangleOrigin, tags),
|
...getRectangleCallExpressions(rectangleOrigin, tags),
|
||||||
|
@ -72,7 +72,7 @@ interface OnDragCallbackArgs extends OnMouseEnterLeaveArgs {
|
|||||||
}
|
}
|
||||||
intersects: Intersection<Object3D<Object3DEventMap>>[]
|
intersects: Intersection<Object3D<Object3DEventMap>>[]
|
||||||
}
|
}
|
||||||
interface OnClickCallbackArgs {
|
export interface OnClickCallbackArgs {
|
||||||
mouseEvent: MouseEvent
|
mouseEvent: MouseEvent
|
||||||
intersectionPoint?: {
|
intersectionPoint?: {
|
||||||
twoD: Vector2
|
twoD: Vector2
|
||||||
|
@ -142,7 +142,9 @@ export const ModelingMachineProvider = ({
|
|||||||
kclManager.executeCode().then(() => {
|
kclManager.executeCode().then(() => {
|
||||||
if (engineCommandManager.engineConnection?.idleMode) return
|
if (engineCommandManager.engineConnection?.idleMode) return
|
||||||
|
|
||||||
store.videoElement?.play()
|
store.videoElement?.play().catch((e) => {
|
||||||
|
console.warn('Video playing was prevented', e)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})()
|
})()
|
||||||
},
|
},
|
||||||
|
@ -14,6 +14,7 @@ import { MemoryPane, MemoryPaneMenu } from './MemoryPane'
|
|||||||
import { KclErrorsPane, LogsPane } from './LoggingPanes'
|
import { KclErrorsPane, LogsPane } from './LoggingPanes'
|
||||||
import { DebugPane } from './DebugPane'
|
import { DebugPane } from './DebugPane'
|
||||||
import { FileTreeInner, FileTreeMenu } from 'components/FileTree'
|
import { FileTreeInner, FileTreeMenu } from 'components/FileTree'
|
||||||
|
import { useKclContext } from 'lang/KclProvider'
|
||||||
|
|
||||||
export type SidebarType =
|
export type SidebarType =
|
||||||
| 'code'
|
| 'code'
|
||||||
@ -25,6 +26,14 @@ export type SidebarType =
|
|||||||
| 'lspMessages'
|
| 'lspMessages'
|
||||||
| 'variables'
|
| 'variables'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface can be extended as more context is needed for the panes
|
||||||
|
* to determine if they should show their badges or not.
|
||||||
|
*/
|
||||||
|
interface PaneCallbackProps {
|
||||||
|
kclContext: ReturnType<typeof useKclContext>
|
||||||
|
}
|
||||||
|
|
||||||
export type SidebarPane = {
|
export type SidebarPane = {
|
||||||
id: SidebarType
|
id: SidebarType
|
||||||
title: string
|
title: string
|
||||||
@ -33,6 +42,7 @@ export type SidebarPane = {
|
|||||||
Content: ReactNode | React.FC
|
Content: ReactNode | React.FC
|
||||||
Menu?: ReactNode | React.FC
|
Menu?: ReactNode | React.FC
|
||||||
hideOnPlatform?: 'desktop' | 'web'
|
hideOnPlatform?: 'desktop' | 'web'
|
||||||
|
showBadge?: (props: PaneCallbackProps) => boolean | number
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sidebarPanes: SidebarPane[] = [
|
export const sidebarPanes: SidebarPane[] = [
|
||||||
@ -74,6 +84,7 @@ export const sidebarPanes: SidebarPane[] = [
|
|||||||
icon: faExclamationCircle,
|
icon: faExclamationCircle,
|
||||||
Content: KclErrorsPane,
|
Content: KclErrorsPane,
|
||||||
keybinding: 'Shift + E',
|
keybinding: 'Shift + E',
|
||||||
|
showBadge: ({ kclContext }) => kclContext.errors.length,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'debug',
|
id: 'debug',
|
||||||
|
@ -12,6 +12,7 @@ import { useModelingContext } from 'hooks/useModelingContext'
|
|||||||
import { CustomIconName } from 'components/CustomIcon'
|
import { CustomIconName } from 'components/CustomIcon'
|
||||||
import { useCommandsContext } from 'hooks/useCommandsContext'
|
import { useCommandsContext } from 'hooks/useCommandsContext'
|
||||||
import { IconDefinition } from '@fortawesome/free-solid-svg-icons'
|
import { IconDefinition } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
import { useKclContext } from 'lang/KclProvider'
|
||||||
|
|
||||||
interface ModelingSidebarProps {
|
interface ModelingSidebarProps {
|
||||||
paneOpacity: '' | 'opacity-20' | 'opacity-40'
|
paneOpacity: '' | 'opacity-20' | 'opacity-40'
|
||||||
@ -19,6 +20,7 @@ interface ModelingSidebarProps {
|
|||||||
|
|
||||||
export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) {
|
export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) {
|
||||||
const { commandBarSend } = useCommandsContext()
|
const { commandBarSend } = useCommandsContext()
|
||||||
|
const kclContext = useKclContext()
|
||||||
const { settings } = useSettingsAuthContext()
|
const { settings } = useSettingsAuthContext()
|
||||||
const onboardingStatus = settings.context.app.onboardingStatus
|
const onboardingStatus = settings.context.app.onboardingStatus
|
||||||
const { send, context } = useModelingContext()
|
const { send, context } = useModelingContext()
|
||||||
@ -62,6 +64,15 @@ export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) {
|
|||||||
[sidebarPanes, showDebugPanel.current]
|
[sidebarPanes, showDebugPanel.current]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const paneBadgeMap: Record<SidebarType, number | boolean> = useMemo(() => {
|
||||||
|
return filteredPanes.reduce((acc, pane) => {
|
||||||
|
if (pane.showBadge) {
|
||||||
|
acc[pane.id] = pane.showBadge({ kclContext })
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}, {} as Record<SidebarType, number | boolean>)
|
||||||
|
}, [kclContext.errors])
|
||||||
|
|
||||||
const togglePane = useCallback(
|
const togglePane = useCallback(
|
||||||
(newPane: SidebarType) => {
|
(newPane: SidebarType) => {
|
||||||
send({
|
send({
|
||||||
@ -120,6 +131,7 @@ export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) {
|
|||||||
paneIsOpen={context.store?.openPanes.includes(pane.id)}
|
paneIsOpen={context.store?.openPanes.includes(pane.id)}
|
||||||
onClick={() => togglePane(pane.id)}
|
onClick={() => togglePane(pane.id)}
|
||||||
aria-pressed={context.store?.openPanes.includes(pane.id)}
|
aria-pressed={context.store?.openPanes.includes(pane.id)}
|
||||||
|
showBadge={paneBadgeMap[pane.id]}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
@ -186,12 +198,14 @@ interface ModelingPaneButtonProps
|
|||||||
}
|
}
|
||||||
onClick: () => void
|
onClick: () => void
|
||||||
paneIsOpen?: boolean
|
paneIsOpen?: boolean
|
||||||
|
showBadge?: boolean | number
|
||||||
}
|
}
|
||||||
|
|
||||||
function ModelingPaneButton({
|
function ModelingPaneButton({
|
||||||
paneConfig,
|
paneConfig,
|
||||||
onClick,
|
onClick,
|
||||||
paneIsOpen,
|
paneIsOpen,
|
||||||
|
showBadge,
|
||||||
...props
|
...props
|
||||||
}: ModelingPaneButtonProps) {
|
}: ModelingPaneButtonProps) {
|
||||||
useHotkeys(paneConfig.keybinding, onClick, {
|
useHotkeys(paneConfig.keybinding, onClick, {
|
||||||
@ -223,6 +237,23 @@ function ModelingPaneButton({
|
|||||||
{paneConfig.title}
|
{paneConfig.title}
|
||||||
{paneIsOpen !== undefined ? ` pane` : ''}
|
{paneIsOpen !== undefined ? ` pane` : ''}
|
||||||
</span>
|
</span>
|
||||||
|
{!!showBadge && (
|
||||||
|
<p
|
||||||
|
className={
|
||||||
|
'absolute m-0 p-0 -top-1 -right-1 w-3 h-3 flex items-center justify-center text-[10px] font-semibold text-white bg-primary hue-rotate-90 rounded-full border border-chalkboard-10 dark:border-chalkboard-80'
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span className="sr-only"> has </span>
|
||||||
|
{typeof showBadge === 'number' ? (
|
||||||
|
<span>{showBadge}</span>
|
||||||
|
) : (
|
||||||
|
<span className="sr-only">a</span>
|
||||||
|
)}
|
||||||
|
<span className="sr-only">
|
||||||
|
notification{Number(showBadge) > 1 ? 's' : ''}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
<Tooltip
|
<Tooltip
|
||||||
position="right"
|
position="right"
|
||||||
contentClassName="max-w-none flex items-center gap-4"
|
contentClassName="max-w-none flex items-center gap-4"
|
||||||
|
@ -175,11 +175,35 @@ export const SettingsAuthProviderBase = ({
|
|||||||
id: `${event.type}.success`,
|
id: `${event.type}.success`,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
'Execute AST': () => {
|
'Execute AST': (context, event) => {
|
||||||
kclManager.isFirstRender = true
|
try {
|
||||||
kclManager.executeCode(true).then(() => {
|
const allSettingsIncludesUnitChange =
|
||||||
kclManager.isFirstRender = false
|
event.type === 'Set all settings' &&
|
||||||
})
|
event.settings?.modeling?.defaultUnit?.current !==
|
||||||
|
context.modeling.defaultUnit.current
|
||||||
|
const resetSettingsIncludesUnitChange =
|
||||||
|
event.type === 'Reset settings' &&
|
||||||
|
context.modeling.defaultUnit.current !==
|
||||||
|
settings?.modeling?.defaultUnit?.default
|
||||||
|
|
||||||
|
if (
|
||||||
|
event.type === 'set.modeling.defaultUnit' ||
|
||||||
|
allSettingsIncludesUnitChange ||
|
||||||
|
resetSettingsIncludesUnitChange
|
||||||
|
) {
|
||||||
|
kclManager.isFirstRender = true
|
||||||
|
kclManager.executeCode(true).then(() => {
|
||||||
|
kclManager.isFirstRender = false
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// For any future logging we'd like to do
|
||||||
|
// console.log(
|
||||||
|
// 'Not re-executing AST because the settings change did not affect the code interpretation'
|
||||||
|
// )
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error executing AST after settings change', e)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
services: {
|
services: {
|
||||||
|
@ -156,7 +156,13 @@ export const Stream = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsFirstRender(kclManager.isFirstRender)
|
setIsFirstRender(kclManager.isFirstRender)
|
||||||
if (!kclManager.isFirstRender) videoRef.current?.play()
|
if (!kclManager.isFirstRender)
|
||||||
|
setTimeout(() =>
|
||||||
|
// execute in the next event loop
|
||||||
|
videoRef.current?.play().catch((e) => {
|
||||||
|
console.warn('Video playing was prevented', e, videoRef.current)
|
||||||
|
})
|
||||||
|
)
|
||||||
setIsFreezeFrame(!kclManager.isFirstRender)
|
setIsFreezeFrame(!kclManager.isFirstRender)
|
||||||
}, [kclManager.isFirstRender])
|
}, [kclManager.isFirstRender])
|
||||||
|
|
||||||
@ -170,8 +176,12 @@ export const Stream = () => {
|
|||||||
if (!mediaStream) return
|
if (!mediaStream) return
|
||||||
|
|
||||||
// Do not immediately play the stream!
|
// Do not immediately play the stream!
|
||||||
videoRef.current.srcObject = mediaStream
|
try {
|
||||||
videoRef.current.pause()
|
videoRef.current.srcObject = mediaStream
|
||||||
|
videoRef.current.pause()
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Attempted to pause stream while play was still loading', e)
|
||||||
|
}
|
||||||
|
|
||||||
send({
|
send({
|
||||||
type: 'Set context',
|
type: 'Set context',
|
||||||
|
@ -186,6 +186,7 @@ export function useSetupEngineManager(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDimensions(streamWidth?: number, streamHeight?: number) {
|
function getDimensions(streamWidth?: number, streamHeight?: number) {
|
||||||
|
const factorOf = 4
|
||||||
const maxResolution = 2000
|
const maxResolution = 2000
|
||||||
const width = streamWidth ? streamWidth : 0
|
const width = streamWidth ? streamWidth : 0
|
||||||
const height = streamHeight ? streamHeight : 0
|
const height = streamHeight ? streamHeight : 0
|
||||||
@ -193,7 +194,7 @@ function getDimensions(streamWidth?: number, streamHeight?: number) {
|
|||||||
Math.min(maxResolution / width, maxResolution / height),
|
Math.min(maxResolution / width, maxResolution / height),
|
||||||
1.0
|
1.0
|
||||||
)
|
)
|
||||||
const quadWidth = Math.round((width * ratio) / 4) * 4
|
const quadWidth = Math.round((width * ratio) / factorOf) * factorOf
|
||||||
const quadHeight = Math.round((height * ratio) / 4) * 4
|
const quadHeight = Math.round((height * ratio) / factorOf) * factorOf
|
||||||
return { width: quadWidth, height: quadHeight }
|
return { width: quadWidth, height: quadHeight }
|
||||||
}
|
}
|
||||||
|
@ -224,6 +224,7 @@ export class KclManager {
|
|||||||
|
|
||||||
sceneInfra.modelingSend({ type: 'code edit during sketch' })
|
sceneInfra.modelingSend({ type: 'code edit during sketch' })
|
||||||
defaultSelectionFilter(programMemory, this.engineCommandManager)
|
defaultSelectionFilter(programMemory, this.engineCommandManager)
|
||||||
|
await this.engineCommandManager.waitForAllCommands()
|
||||||
|
|
||||||
if (zoomToFit) {
|
if (zoomToFit) {
|
||||||
let zoomObjectId: string | undefined = ''
|
let zoomObjectId: string | undefined = ''
|
||||||
@ -243,6 +244,15 @@ export class KclManager {
|
|||||||
padding: 0.1, // padding around the objects
|
padding: 0.1, // padding around the objects
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
await this.engineCommandManager.sendSceneCommand({
|
||||||
|
type: 'modeling_cmd_req',
|
||||||
|
cmd_id: uuidv4(),
|
||||||
|
cmd: {
|
||||||
|
type: 'zoom_to_fit',
|
||||||
|
object_ids: zoomObjectId ? [zoomObjectId] : [], // leave empty to zoom to all objects
|
||||||
|
padding: 0.1, // padding around the objects
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isExecuting = false
|
this.isExecuting = false
|
||||||
|
@ -24,13 +24,6 @@ export const getRectangleCallExpressions = (
|
|||||||
rectangleOrigin: [number, number],
|
rectangleOrigin: [number, number],
|
||||||
tags: [string, string, string]
|
tags: [string, string, string]
|
||||||
) => [
|
) => [
|
||||||
createCallExpressionStdLib('startProfileAt', [
|
|
||||||
createArrayExpression([
|
|
||||||
createLiteral(roundOff(rectangleOrigin[0])),
|
|
||||||
createLiteral(roundOff(rectangleOrigin[1])),
|
|
||||||
]),
|
|
||||||
createPipeSubstitution(),
|
|
||||||
]),
|
|
||||||
createCallExpressionStdLib('angledLine', [
|
createCallExpressionStdLib('angledLine', [
|
||||||
createArrayExpression([
|
createArrayExpression([
|
||||||
createLiteral(0), // 0 deg
|
createLiteral(0), // 0 deg
|
||||||
|
@ -1082,7 +1082,9 @@ export const modelingMachine = createMachine(
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
if (!engineCommandManager.engineConnection?.idleMode) {
|
if (!engineCommandManager.engineConnection?.idleMode) {
|
||||||
store.videoElement?.play()
|
store.videoElement?.play().catch((e) => {
|
||||||
|
console.warn('Video playing was prevented', e)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
if (updatedAst?.selections) {
|
if (updatedAst?.selections) {
|
||||||
editorManager.selectRange(updatedAst?.selections)
|
editorManager.selectRange(updatedAst?.selections)
|
||||||
@ -1238,7 +1240,20 @@ export const modelingMachine = createMachine(
|
|||||||
},
|
},
|
||||||
'listen for rectangle origin': ({ sketchDetails }) => {
|
'listen for rectangle origin': ({ sketchDetails }) => {
|
||||||
if (!sketchDetails) return
|
if (!sketchDetails) return
|
||||||
sceneEntitiesManager.setupRectangleOriginListener()
|
sceneEntitiesManager.setupNoPointsListener({
|
||||||
|
sketchDetails,
|
||||||
|
afterClick: (args) => {
|
||||||
|
const twoD = args.intersectionPoint?.twoD
|
||||||
|
if (twoD) {
|
||||||
|
sceneInfra.modelingSend({
|
||||||
|
type: 'Add rectangle origin',
|
||||||
|
data: [twoD.x, twoD.y],
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.error('No intersection point found')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
},
|
},
|
||||||
'set up draft rectangle': ({ sketchDetails }, { data }) => {
|
'set up draft rectangle': ({ sketchDetails }, { data }) => {
|
||||||
if (!sketchDetails || !data) return
|
if (!sketchDetails || !data) return
|
||||||
@ -1268,39 +1283,10 @@ export const modelingMachine = createMachine(
|
|||||||
},
|
},
|
||||||
'setup noPoints onClick listener': ({ sketchDetails }) => {
|
'setup noPoints onClick listener': ({ sketchDetails }) => {
|
||||||
if (!sketchDetails) return
|
if (!sketchDetails) return
|
||||||
sceneEntitiesManager.createIntersectionPlane()
|
|
||||||
const quaternion = quaternionFromUpNForward(
|
|
||||||
new Vector3(...sketchDetails.yAxis),
|
|
||||||
new Vector3(...sketchDetails.zAxis)
|
|
||||||
)
|
|
||||||
sceneEntitiesManager.intersectionPlane &&
|
|
||||||
sceneEntitiesManager.intersectionPlane.setRotationFromQuaternion(
|
|
||||||
quaternion
|
|
||||||
)
|
|
||||||
sceneEntitiesManager.intersectionPlane &&
|
|
||||||
sceneEntitiesManager.intersectionPlane.position.copy(
|
|
||||||
new Vector3(...(sketchDetails?.origin || [0, 0, 0]))
|
|
||||||
)
|
|
||||||
sceneInfra.setCallbacks({
|
|
||||||
onClick: async (args) => {
|
|
||||||
if (!args) return
|
|
||||||
if (args.mouseEvent.which !== 1) return
|
|
||||||
const { intersectionPoint } = args
|
|
||||||
if (!intersectionPoint?.twoD || !sketchDetails?.sketchPathToNode)
|
|
||||||
return
|
|
||||||
const addStartProfileAtRes = addStartProfileAt(
|
|
||||||
kclManager.ast,
|
|
||||||
sketchDetails.sketchPathToNode,
|
|
||||||
[intersectionPoint.twoD.x, intersectionPoint.twoD.y]
|
|
||||||
)
|
|
||||||
|
|
||||||
if (trap(addStartProfileAtRes)) return
|
sceneEntitiesManager.setupNoPointsListener({
|
||||||
const { modifiedAst } = addStartProfileAtRes
|
sketchDetails,
|
||||||
|
afterClick: () => sceneInfra.modelingSend('Add start point'),
|
||||||
await kclManager.updateAst(modifiedAst, false)
|
|
||||||
sceneEntitiesManager.removeIntersectionPlane()
|
|
||||||
sceneInfra.modelingSend('Add start point')
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
'add axis n grid': ({ sketchDetails }) => {
|
'add axis n grid': ({ sketchDetails }) => {
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
# Each test can have at most 4 threads, but if its name contains "serial_test_", then it
|
|
||||||
# also requires 4 threads.
|
|
||||||
# This means such tests run one at a time, with 4 threads.
|
|
||||||
|
|
||||||
[test-groups]
|
[test-groups]
|
||||||
serial-integration = { max-threads = 4 }
|
# If a test uses the engine, we want to limit the number that can run in parallel.
|
||||||
|
# This way we don't start and stop too many engine instances, putting pressure on our cloud.
|
||||||
|
uses-engine = { max-threads = 4 }
|
||||||
|
|
||||||
[profile.default]
|
[profile.default]
|
||||||
slow-timeout = { period = "30s", terminate-after = 1 }
|
slow-timeout = { period = "30s", terminate-after = 1 }
|
||||||
@ -12,13 +10,15 @@ slow-timeout = { period = "30s", terminate-after = 1 }
|
|||||||
slow-timeout = { period = "50s", terminate-after = 5 }
|
slow-timeout = { period = "50s", terminate-after = 5 }
|
||||||
|
|
||||||
[[profile.default.overrides]]
|
[[profile.default.overrides]]
|
||||||
filter = "test(serial_test_)"
|
# If a test starts with kcl_test_, then it uses the engine. So, limit its parallelism.
|
||||||
test-group = "serial-integration"
|
filter = "test(kcl_test_)"
|
||||||
|
test-group = "uses-engine"
|
||||||
threads-required = 2
|
threads-required = 2
|
||||||
|
|
||||||
[[profile.ci.overrides]]
|
[[profile.ci.overrides]]
|
||||||
filter = "test(serial_test_)"
|
# If a test starts with kcl_test_, then it uses the engine. So, limit its parallelism.
|
||||||
test-group = "serial-integration"
|
filter = "test(kcl_test_)"
|
||||||
|
test-group = "uses-engine"
|
||||||
threads-required = 2
|
threads-required = 2
|
||||||
|
|
||||||
[[profile.default.overrides]]
|
[[profile.default.overrides]]
|
||||||
|
30
src/wasm-lib/Cargo.lock
generated
30
src/wasm-lib/Cargo.lock
generated
@ -406,9 +406,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.5.11"
|
version = "4.5.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3"
|
checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap_builder",
|
"clap_builder",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
@ -416,9 +416,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_builder"
|
name = "clap_builder"
|
||||||
version = "4.5.11"
|
version = "4.5.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa"
|
checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstream",
|
"anstream",
|
||||||
"anstyle",
|
"anstyle",
|
||||||
@ -430,9 +430,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap_derive"
|
||||||
version = "4.5.11"
|
version = "4.5.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5d029b67f89d30bbb547c89fd5161293c0aec155fc691d7924b64550662db93e"
|
checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck 0.5.0",
|
"heck 0.5.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@ -3128,9 +3128,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "0.8.16"
|
version = "0.8.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "81967dd0dd2c1ab0bc3468bd7caecc32b8a4aa47d0c8c695d8c2b2108168d62c"
|
checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_spanned",
|
"serde_spanned",
|
||||||
@ -3140,24 +3140,24 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_datetime"
|
name = "toml_datetime"
|
||||||
version = "0.6.7"
|
version = "0.6.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db"
|
checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_edit"
|
name = "toml_edit"
|
||||||
version = "0.22.17"
|
version = "0.22.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8d9f8729f5aea9562aac1cc0441f5d6de3cff1ee0c5d67293eeca5eb36ee7c16"
|
checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap 2.2.5",
|
"indexmap 2.2.5",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_spanned",
|
"serde_spanned",
|
||||||
"toml_datetime",
|
"toml_datetime",
|
||||||
"winnow 0.6.5",
|
"winnow 0.6.18",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3851,9 +3851,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winnow"
|
name = "winnow"
|
||||||
version = "0.6.5"
|
version = "0.6.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8"
|
checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
@ -11,13 +11,13 @@ crate-type = ["cdylib"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bson = { version = "2.11.0", features = ["uuid-1", "chrono"] }
|
bson = { version = "2.11.0", features = ["uuid-1", "chrono"] }
|
||||||
clap = "4.5.11"
|
clap = "4.5.13"
|
||||||
gloo-utils = "0.2.0"
|
gloo-utils = "0.2.0"
|
||||||
kcl-lib = { path = "kcl" }
|
kcl-lib = { path = "kcl" }
|
||||||
kittycad.workspace = true
|
kittycad.workspace = true
|
||||||
serde_json = "1.0.121"
|
serde_json = "1.0.121"
|
||||||
tokio = { version = "1.39.2", features = ["sync"] }
|
tokio = { version = "1.39.2", features = ["sync"] }
|
||||||
toml = "0.8.16"
|
toml = "0.8.19"
|
||||||
uuid = { version = "1.10.0", features = ["v4", "js", "serde"] }
|
uuid = { version = "1.10.0", features = ["v4", "js", "serde"] }
|
||||||
wasm-bindgen = "0.2.91"
|
wasm-bindgen = "0.2.91"
|
||||||
wasm-bindgen-futures = "0.4.42"
|
wasm-bindgen-futures = "0.4.42"
|
||||||
|
@ -766,85 +766,10 @@ fn generate_code_block_test(fn_name: &str, code_block: &str, index: usize) -> pr
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn #test_name() {
|
async fn #test_name() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = #code_block;
|
||||||
let http_client = reqwest::Client::builder()
|
// Note, `crate` must be kcl_lib
|
||||||
.user_agent(user_agent)
|
let result = crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm).await.unwrap();
|
||||||
// For file conversions we need this to be long.
|
twenty_twenty::assert_image(&format!("tests/outputs/{}.png", #test_name_str), &result, 0.99);
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
// For file conversions we need this to be long.
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
|
|
||||||
// Create the client.
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
// Set a local engine address if it's set.
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens = crate::token::lexer(#code_block).unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default()).await.unwrap();
|
|
||||||
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
|
|
||||||
// Ensure it lints.
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Zoom to fit.
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await.unwrap();
|
|
||||||
|
|
||||||
// Send a snapshot request to the engine.
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await.unwrap();
|
|
||||||
|
|
||||||
// Create a temporary file to write the output to.
|
|
||||||
let output_file = std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
// Save the snapshot locally.
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Read the output file.
|
|
||||||
let actual = image::io::Reader::open(output_file).unwrap().decode().unwrap();
|
|
||||||
twenty_twenty::assert_image(&format!("tests/outputs/{}.png", #test_name_str), &actual, 0.99);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,76 +21,14 @@ mod test_examples_someFn {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_someFn0() {
|
async fn serial_test_example_someFn0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = "someFn()";
|
||||||
let http_client = reqwest::Client::builder()
|
let result =
|
||||||
.user_agent(user_agent)
|
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
.await
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
.unwrap();
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens = crate::token::lexer("someFn()").unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let output_file =
|
|
||||||
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let actual = image::io::Reader::open(output_file)
|
|
||||||
.unwrap()
|
|
||||||
.decode()
|
|
||||||
.unwrap();
|
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
&format!("tests/outputs/{}.png", "serial_test_example_someFn0"),
|
&format!("tests/outputs/{}.png", "serial_test_example_someFn0"),
|
||||||
&actual,
|
&result,
|
||||||
0.99,
|
0.99,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -21,76 +21,14 @@ mod test_examples_someFn {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_someFn0() {
|
async fn serial_test_example_someFn0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = "someFn()";
|
||||||
let http_client = reqwest::Client::builder()
|
let result =
|
||||||
.user_agent(user_agent)
|
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
.await
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
.unwrap();
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens = crate::token::lexer("someFn()").unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let output_file =
|
|
||||||
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let actual = image::io::Reader::open(output_file)
|
|
||||||
.unwrap()
|
|
||||||
.decode()
|
|
||||||
.unwrap();
|
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
&format!("tests/outputs/{}.png", "serial_test_example_someFn0"),
|
&format!("tests/outputs/{}.png", "serial_test_example_someFn0"),
|
||||||
&actual,
|
&result,
|
||||||
0.99,
|
0.99,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -21,76 +21,14 @@ mod test_examples_show {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_show0() {
|
async fn serial_test_example_show0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = "This is another code block.\nyes sirrr.\nshow";
|
||||||
let http_client = reqwest::Client::builder()
|
let result =
|
||||||
.user_agent(user_agent)
|
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
.await
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
.unwrap();
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens = crate::token::lexer("This is another code block.\nyes sirrr.\nshow").unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let output_file =
|
|
||||||
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let actual = image::io::Reader::open(output_file)
|
|
||||||
.unwrap()
|
|
||||||
.decode()
|
|
||||||
.unwrap();
|
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
&format!("tests/outputs/{}.png", "serial_test_example_show0"),
|
&format!("tests/outputs/{}.png", "serial_test_example_show0"),
|
||||||
&actual,
|
&result,
|
||||||
0.99,
|
0.99,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -116,76 +54,14 @@ mod test_examples_show {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_show1() {
|
async fn serial_test_example_show1() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = "This is code.\nIt does other shit.\nshow";
|
||||||
let http_client = reqwest::Client::builder()
|
let result =
|
||||||
.user_agent(user_agent)
|
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
.await
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
.unwrap();
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let output_file =
|
|
||||||
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let actual = image::io::Reader::open(output_file)
|
|
||||||
.unwrap()
|
|
||||||
.decode()
|
|
||||||
.unwrap();
|
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
&format!("tests/outputs/{}.png", "serial_test_example_show1"),
|
&format!("tests/outputs/{}.png", "serial_test_example_show1"),
|
||||||
&actual,
|
&result,
|
||||||
0.99,
|
0.99,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -21,76 +21,14 @@ mod test_examples_show {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_show0() {
|
async fn serial_test_example_show0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = "This is code.\nIt does other shit.\nshow";
|
||||||
let http_client = reqwest::Client::builder()
|
let result =
|
||||||
.user_agent(user_agent)
|
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
.await
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
.unwrap();
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let output_file =
|
|
||||||
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let actual = image::io::Reader::open(output_file)
|
|
||||||
.unwrap()
|
|
||||||
.decode()
|
|
||||||
.unwrap();
|
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
&format!("tests/outputs/{}.png", "serial_test_example_show0"),
|
&format!("tests/outputs/{}.png", "serial_test_example_show0"),
|
||||||
&actual,
|
&result,
|
||||||
0.99,
|
0.99,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -22,77 +22,14 @@ mod test_examples_my_func {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_my_func0() {
|
async fn serial_test_example_my_func0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = "This is another code block.\nyes sirrr.\nmyFunc";
|
||||||
let http_client = reqwest::Client::builder()
|
let result =
|
||||||
.user_agent(user_agent)
|
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
.await
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
.unwrap();
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens =
|
|
||||||
crate::token::lexer("This is another code block.\nyes sirrr.\nmyFunc").unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let output_file =
|
|
||||||
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let actual = image::io::Reader::open(output_file)
|
|
||||||
.unwrap()
|
|
||||||
.decode()
|
|
||||||
.unwrap();
|
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
&format!("tests/outputs/{}.png", "serial_test_example_my_func0"),
|
&format!("tests/outputs/{}.png", "serial_test_example_my_func0"),
|
||||||
&actual,
|
&result,
|
||||||
0.99,
|
0.99,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -118,76 +55,14 @@ mod test_examples_my_func {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_my_func1() {
|
async fn serial_test_example_my_func1() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = "This is code.\nIt does other shit.\nmyFunc";
|
||||||
let http_client = reqwest::Client::builder()
|
let result =
|
||||||
.user_agent(user_agent)
|
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
.await
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
.unwrap();
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nmyFunc").unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let output_file =
|
|
||||||
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let actual = image::io::Reader::open(output_file)
|
|
||||||
.unwrap()
|
|
||||||
.decode()
|
|
||||||
.unwrap();
|
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
&format!("tests/outputs/{}.png", "serial_test_example_my_func1"),
|
&format!("tests/outputs/{}.png", "serial_test_example_my_func1"),
|
||||||
&actual,
|
&result,
|
||||||
0.99,
|
0.99,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -22,77 +22,14 @@ mod test_examples_line_to {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_line_to0() {
|
async fn serial_test_example_line_to0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = "This is another code block.\nyes sirrr.\nlineTo";
|
||||||
let http_client = reqwest::Client::builder()
|
let result =
|
||||||
.user_agent(user_agent)
|
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
.await
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
.unwrap();
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens =
|
|
||||||
crate::token::lexer("This is another code block.\nyes sirrr.\nlineTo").unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let output_file =
|
|
||||||
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let actual = image::io::Reader::open(output_file)
|
|
||||||
.unwrap()
|
|
||||||
.decode()
|
|
||||||
.unwrap();
|
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
&format!("tests/outputs/{}.png", "serial_test_example_line_to0"),
|
&format!("tests/outputs/{}.png", "serial_test_example_line_to0"),
|
||||||
&actual,
|
&result,
|
||||||
0.99,
|
0.99,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -118,76 +55,14 @@ mod test_examples_line_to {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_line_to1() {
|
async fn serial_test_example_line_to1() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = "This is code.\nIt does other shit.\nlineTo";
|
||||||
let http_client = reqwest::Client::builder()
|
let result =
|
||||||
.user_agent(user_agent)
|
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
.await
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
.unwrap();
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nlineTo").unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let output_file =
|
|
||||||
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let actual = image::io::Reader::open(output_file)
|
|
||||||
.unwrap()
|
|
||||||
.decode()
|
|
||||||
.unwrap();
|
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
&format!("tests/outputs/{}.png", "serial_test_example_line_to1"),
|
&format!("tests/outputs/{}.png", "serial_test_example_line_to1"),
|
||||||
&actual,
|
&result,
|
||||||
0.99,
|
0.99,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -21,76 +21,14 @@ mod test_examples_min {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_min0() {
|
async fn serial_test_example_min0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = "This is another code block.\nyes sirrr.\nmin";
|
||||||
let http_client = reqwest::Client::builder()
|
let result =
|
||||||
.user_agent(user_agent)
|
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
.await
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
.unwrap();
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens = crate::token::lexer("This is another code block.\nyes sirrr.\nmin").unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let output_file =
|
|
||||||
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let actual = image::io::Reader::open(output_file)
|
|
||||||
.unwrap()
|
|
||||||
.decode()
|
|
||||||
.unwrap();
|
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
&format!("tests/outputs/{}.png", "serial_test_example_min0"),
|
&format!("tests/outputs/{}.png", "serial_test_example_min0"),
|
||||||
&actual,
|
&result,
|
||||||
0.99,
|
0.99,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -116,76 +54,14 @@ mod test_examples_min {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_min1() {
|
async fn serial_test_example_min1() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = "This is code.\nIt does other shit.\nmin";
|
||||||
let http_client = reqwest::Client::builder()
|
let result =
|
||||||
.user_agent(user_agent)
|
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
.await
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
.unwrap();
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nmin").unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let output_file =
|
|
||||||
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let actual = image::io::Reader::open(output_file)
|
|
||||||
.unwrap()
|
|
||||||
.decode()
|
|
||||||
.unwrap();
|
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
&format!("tests/outputs/{}.png", "serial_test_example_min1"),
|
&format!("tests/outputs/{}.png", "serial_test_example_min1"),
|
||||||
&actual,
|
&result,
|
||||||
0.99,
|
0.99,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -21,76 +21,14 @@ mod test_examples_show {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_show0() {
|
async fn serial_test_example_show0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = "This is code.\nIt does other shit.\nshow";
|
||||||
let http_client = reqwest::Client::builder()
|
let result =
|
||||||
.user_agent(user_agent)
|
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
.await
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
.unwrap();
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let output_file =
|
|
||||||
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let actual = image::io::Reader::open(output_file)
|
|
||||||
.unwrap()
|
|
||||||
.decode()
|
|
||||||
.unwrap();
|
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
&format!("tests/outputs/{}.png", "serial_test_example_show0"),
|
&format!("tests/outputs/{}.png", "serial_test_example_show0"),
|
||||||
&actual,
|
&result,
|
||||||
0.99,
|
0.99,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -21,76 +21,14 @@ mod test_examples_import {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_import0() {
|
async fn serial_test_example_import0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = "This is code.\nIt does other shit.\nimport";
|
||||||
let http_client = reqwest::Client::builder()
|
let result =
|
||||||
.user_agent(user_agent)
|
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
.await
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
.unwrap();
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nimport").unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let output_file =
|
|
||||||
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let actual = image::io::Reader::open(output_file)
|
|
||||||
.unwrap()
|
|
||||||
.decode()
|
|
||||||
.unwrap();
|
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
&format!("tests/outputs/{}.png", "serial_test_example_import0"),
|
&format!("tests/outputs/{}.png", "serial_test_example_import0"),
|
||||||
&actual,
|
&result,
|
||||||
0.99,
|
0.99,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -21,76 +21,14 @@ mod test_examples_import {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_import0() {
|
async fn serial_test_example_import0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = "This is code.\nIt does other shit.\nimport";
|
||||||
let http_client = reqwest::Client::builder()
|
let result =
|
||||||
.user_agent(user_agent)
|
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
.await
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
.unwrap();
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nimport").unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let output_file =
|
|
||||||
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let actual = image::io::Reader::open(output_file)
|
|
||||||
.unwrap()
|
|
||||||
.decode()
|
|
||||||
.unwrap();
|
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
&format!("tests/outputs/{}.png", "serial_test_example_import0"),
|
&format!("tests/outputs/{}.png", "serial_test_example_import0"),
|
||||||
&actual,
|
&result,
|
||||||
0.99,
|
0.99,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -21,76 +21,14 @@ mod test_examples_import {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_import0() {
|
async fn serial_test_example_import0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = "This is code.\nIt does other shit.\nimport";
|
||||||
let http_client = reqwest::Client::builder()
|
let result =
|
||||||
.user_agent(user_agent)
|
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
.await
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
.unwrap();
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nimport").unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let output_file =
|
|
||||||
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let actual = image::io::Reader::open(output_file)
|
|
||||||
.unwrap()
|
|
||||||
.decode()
|
|
||||||
.unwrap();
|
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
&format!("tests/outputs/{}.png", "serial_test_example_import0"),
|
&format!("tests/outputs/{}.png", "serial_test_example_import0"),
|
||||||
&actual,
|
&result,
|
||||||
0.99,
|
0.99,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -21,76 +21,14 @@ mod test_examples_show {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
||||||
async fn serial_test_example_show0() {
|
async fn serial_test_example_show0() {
|
||||||
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
let code = "This is code.\nIt does other shit.\nshow";
|
||||||
let http_client = reqwest::Client::builder()
|
let result =
|
||||||
.user_agent(user_agent)
|
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
.await
|
||||||
.connect_timeout(std::time::Duration::from_secs(60));
|
.unwrap();
|
||||||
let ws_client = reqwest::Client::builder()
|
|
||||||
.user_agent(user_agent)
|
|
||||||
.timeout(std::time::Duration::from_secs(600))
|
|
||||||
.connect_timeout(std::time::Duration::from_secs(60))
|
|
||||||
.connection_verbose(true)
|
|
||||||
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
||||||
.http1_only();
|
|
||||||
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
|
||||||
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
||||||
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
||||||
client.set_base_url(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap();
|
|
||||||
let parser = crate::parser::Parser::new(tokens);
|
|
||||||
let program = parser.ast().unwrap();
|
|
||||||
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.run(&program, None).await.unwrap();
|
|
||||||
let results = program.lint_all().unwrap();
|
|
||||||
if !results.is_empty() {
|
|
||||||
panic!("Linting failed: {:?}", results);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::ZoomToFit {
|
|
||||||
object_ids: Default::default(),
|
|
||||||
padding: 0.1,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let resp = ctx
|
|
||||||
.engine
|
|
||||||
.send_modeling_cmd(
|
|
||||||
uuid::Uuid::new_v4(),
|
|
||||||
crate::executor::SourceRange::default(),
|
|
||||||
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
||||||
format: kittycad::types::ImageFormat::Png,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let output_file =
|
|
||||||
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
||||||
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
||||||
} = &resp
|
|
||||||
{
|
|
||||||
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
||||||
} else {
|
|
||||||
panic!("Unexpected response from engine: {:?}", resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let actual = image::io::Reader::open(output_file)
|
|
||||||
.unwrap()
|
|
||||||
.decode()
|
|
||||||
.unwrap();
|
|
||||||
twenty_twenty::assert_image(
|
twenty_twenty::assert_image(
|
||||||
&format!("tests/outputs/{}.png", "serial_test_example_show0"),
|
&format!("tests/outputs/{}.png", "serial_test_example_show0"),
|
||||||
&actual,
|
&result,
|
||||||
0.99,
|
0.99,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ async-recursion = "1.1.1"
|
|||||||
async-trait = "0.1.81"
|
async-trait = "0.1.81"
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
chrono = "0.4.38"
|
chrono = "0.4.38"
|
||||||
clap = { version = "4.5.11", default-features = false, optional = true }
|
clap = { version = "4.5.13", default-features = false, optional = true }
|
||||||
convert_case = "0.6.0"
|
convert_case = "0.6.0"
|
||||||
dashmap = "6.0.1"
|
dashmap = "6.0.1"
|
||||||
databake = { version = "0.1.8", features = ["derive"] }
|
databake = { version = "0.1.8", features = ["derive"] }
|
||||||
@ -25,6 +25,7 @@ form_urlencoded = "1.2.1"
|
|||||||
futures = { version = "0.3.30" }
|
futures = { version = "0.3.30" }
|
||||||
git_rev = "0.1.0"
|
git_rev = "0.1.0"
|
||||||
gltf-json = "1.4.1"
|
gltf-json = "1.4.1"
|
||||||
|
image = { version = "0.25.1", default-features = false, features = ["png"] }
|
||||||
kittycad = { workspace = true, features = ["clap"] }
|
kittycad = { workspace = true, features = ["clap"] }
|
||||||
lazy_static = "1.5.0"
|
lazy_static = "1.5.0"
|
||||||
mime_guess = "2.0.5"
|
mime_guess = "2.0.5"
|
||||||
@ -38,7 +39,7 @@ serde_json = "1.0.121"
|
|||||||
sha2 = "0.10.8"
|
sha2 = "0.10.8"
|
||||||
tabled = { version = "0.15.0", optional = true }
|
tabled = { version = "0.15.0", optional = true }
|
||||||
thiserror = "1.0.63"
|
thiserror = "1.0.63"
|
||||||
toml = "0.8.16"
|
toml = "0.8.19"
|
||||||
ts-rs = { version = "9.0.1", features = ["uuid-impl", "url-impl", "chrono-impl", "no-serde-warnings", "serde-json-impl"] }
|
ts-rs = { version = "9.0.1", features = ["uuid-impl", "url-impl", "chrono-impl", "no-serde-warnings", "serde-json-impl"] }
|
||||||
url = { version = "2.5.2", features = ["serde"] }
|
url = { version = "2.5.2", features = ["serde"] }
|
||||||
uuid = { version = "1.10.0", features = ["v4", "js", "serde"] }
|
uuid = { version = "1.10.0", features = ["v4", "js", "serde"] }
|
||||||
|
@ -26,6 +26,7 @@ pub mod lsp;
|
|||||||
pub mod parser;
|
pub mod parser;
|
||||||
pub mod settings;
|
pub mod settings;
|
||||||
pub mod std;
|
pub mod std;
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
pub mod test_server;
|
pub mod test_server;
|
||||||
pub mod thread;
|
pub mod thread;
|
||||||
pub mod token;
|
pub mod token;
|
||||||
|
@ -1,8 +1,70 @@
|
|||||||
//! Types used to send data to the test server.
|
//! Types used to send data to the test server.
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
executor::{ExecutorContext, ExecutorSettings},
|
||||||
|
settings::types::UnitLength,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(serde::Deserialize, serde::Serialize)]
|
#[derive(serde::Deserialize, serde::Serialize)]
|
||||||
pub struct RequestBody {
|
pub struct RequestBody {
|
||||||
pub kcl_program: String,
|
pub kcl_program: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub test_name: String,
|
pub test_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Executes a kcl program and takes a snapshot of the result.
|
||||||
|
/// This returns the bytes of the snapshot.
|
||||||
|
pub async fn execute_and_snapshot(code: &str, units: UnitLength) -> anyhow::Result<image::DynamicImage> {
|
||||||
|
let ctx = new_context(units).await?;
|
||||||
|
let tokens = crate::token::lexer(code)?;
|
||||||
|
let parser = crate::parser::Parser::new(tokens);
|
||||||
|
let program = parser.ast()?;
|
||||||
|
|
||||||
|
let snapshot = ctx.execute_and_prepare_snapshot(&program).await?;
|
||||||
|
|
||||||
|
// Create a temporary file to write the output to.
|
||||||
|
let output_file = std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
||||||
|
// Save the snapshot locally, to that temporary file.
|
||||||
|
std::fs::write(&output_file, snapshot.contents.0)?;
|
||||||
|
// Decode the snapshot, return it.
|
||||||
|
let img = image::io::Reader::open(output_file).unwrap().decode()?;
|
||||||
|
Ok(img)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn new_context(units: UnitLength) -> anyhow::Result<ExecutorContext> {
|
||||||
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
||||||
|
let http_client = reqwest::Client::builder()
|
||||||
|
.user_agent(user_agent)
|
||||||
|
// For file conversions we need this to be long.
|
||||||
|
.timeout(std::time::Duration::from_secs(600))
|
||||||
|
.connect_timeout(std::time::Duration::from_secs(60));
|
||||||
|
let ws_client = reqwest::Client::builder()
|
||||||
|
.user_agent(user_agent)
|
||||||
|
// For file conversions we need this to be long.
|
||||||
|
.timeout(std::time::Duration::from_secs(600))
|
||||||
|
.connect_timeout(std::time::Duration::from_secs(60))
|
||||||
|
.connection_verbose(true)
|
||||||
|
.tcp_keepalive(std::time::Duration::from_secs(600))
|
||||||
|
.http1_only();
|
||||||
|
|
||||||
|
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
||||||
|
|
||||||
|
// Create the client.
|
||||||
|
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
||||||
|
// Set a local engine address if it's set.
|
||||||
|
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
||||||
|
client.set_base_url(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
let ctx = ExecutorContext::new(
|
||||||
|
&client,
|
||||||
|
ExecutorSettings {
|
||||||
|
units,
|
||||||
|
highlight_edges: true,
|
||||||
|
enable_ssao: false,
|
||||||
|
show_grid: false,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(ctx)
|
||||||
|
}
|
||||||
|
9
src/wasm-lib/tests/executor/inputs/angled_line.kcl
Normal file
9
src/wasm-lib/tests/executor/inputs/angled_line.kcl
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
const part001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([4.83, 12.56], %)
|
||||||
|
|> line([15.1, 2.48], %)
|
||||||
|
|> line([3.15, -9.85], %, $seg01)
|
||||||
|
|> line([-15.17, -4.1], %)
|
||||||
|
|> angledLine([segAng(seg01), 12.35], %)
|
||||||
|
|> line([-13.02, 10.03], %)
|
||||||
|
|> close(%)
|
||||||
|
|> extrude(4, %)
|
9
src/wasm-lib/tests/executor/inputs/close_arc.kcl
Normal file
9
src/wasm-lib/tests/executor/inputs/close_arc.kcl
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
const center = [0,0]
|
||||||
|
const radius = 40
|
||||||
|
const height = 3
|
||||||
|
|
||||||
|
const body = startSketchOn('XY')
|
||||||
|
|> startProfileAt([center[0]+radius, center[1]], %)
|
||||||
|
|> arc({angle_end: 360, angle_start: 0, radius: radius}, %)
|
||||||
|
|> close(%)
|
||||||
|
|> extrude(height, %)
|
7
src/wasm-lib/tests/executor/inputs/dimensions_match.kcl
Normal file
7
src/wasm-lib/tests/executor/inputs/dimensions_match.kcl
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
const part001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([-10, -10], %)
|
||||||
|
|> line([20, 0], %)
|
||||||
|
|> line([0, 20], %)
|
||||||
|
|> line([-20, 0], %)
|
||||||
|
|> close(%)
|
||||||
|
|> extrude(10, %)
|
4
src/wasm-lib/tests/executor/inputs/helix_ccw.kcl
Normal file
4
src/wasm-lib/tests/executor/inputs/helix_ccw.kcl
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
const part001 = startSketchOn('XY')
|
||||||
|
|> circle([5, 5], 10, %)
|
||||||
|
|> extrude(10, %)
|
||||||
|
|> helix({revolutions: 16, angle_start: 0, ccw: true}, %)
|
4
src/wasm-lib/tests/executor/inputs/helix_defaults.kcl
Normal file
4
src/wasm-lib/tests/executor/inputs/helix_defaults.kcl
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
const part001 = startSketchOn('XY')
|
||||||
|
|> circle([5, 5], 10, %)
|
||||||
|
|> extrude(10, %)
|
||||||
|
|> helix({revolutions: 16, angle_start: 0}, %)
|
@ -0,0 +1,4 @@
|
|||||||
|
const part001 = startSketchOn('XY')
|
||||||
|
|> circle([5, 5], 10, %)
|
||||||
|
|> extrude(-10, %)
|
||||||
|
|> helix({revolutions: 16, angle_start: 0}, %)
|
4
src/wasm-lib/tests/executor/inputs/helix_with_length.kcl
Normal file
4
src/wasm-lib/tests/executor/inputs/helix_with_length.kcl
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
const part001 = startSketchOn('XY')
|
||||||
|
|> circle([5, 5], 10, %)
|
||||||
|
|> extrude(10, %)
|
||||||
|
|> helix({revolutions: 16, angle_start: 0, length: 3}, %)
|
@ -0,0 +1,17 @@
|
|||||||
|
fn cube = (pos, scale) => {
|
||||||
|
const sg = startSketchOn('XY')
|
||||||
|
|> startProfileAt(pos, %)
|
||||||
|
|> line([0, scale], %)
|
||||||
|
|> line([scale, 0], %)
|
||||||
|
|> line([0, -scale], %)
|
||||||
|
|> close(%)
|
||||||
|
|
||||||
|
return sg
|
||||||
|
}
|
||||||
|
|
||||||
|
const b1 = cube([0,0], 10)
|
||||||
|
const b2 = cube([3,3], 4)
|
||||||
|
|> extrude(10, %)
|
||||||
|
|
||||||
|
const pt1 = b1.value[0]
|
||||||
|
const pt2 = b2.value[0]
|
19
src/wasm-lib/tests/executor/inputs/negative_args.kcl
Normal file
19
src/wasm-lib/tests/executor/inputs/negative_args.kcl
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
const width = 5
|
||||||
|
const height = 10
|
||||||
|
const length = 12
|
||||||
|
|
||||||
|
fn box = (sk1, sk2, scale) => {
|
||||||
|
const boxSketch = startSketchOn('XY')
|
||||||
|
|> startProfileAt([sk1, sk2], %)
|
||||||
|
|> line([0, scale], %)
|
||||||
|
|> line([scale, 0], %)
|
||||||
|
|> line([0, -scale], %)
|
||||||
|
|> close(%)
|
||||||
|
|> extrude(scale, %)
|
||||||
|
return boxSketch
|
||||||
|
}
|
||||||
|
|
||||||
|
box(0, 0, 5)
|
||||||
|
box(10, 23, 8)
|
||||||
|
let thing = box(-12, -15, 10)
|
||||||
|
box(-20, -5, 10)
|
18
src/wasm-lib/tests/executor/inputs/parametric.kcl
Normal file
18
src/wasm-lib/tests/executor/inputs/parametric.kcl
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
const sigmaAllow = 35000 // psi
|
||||||
|
const width = 9 // inch
|
||||||
|
const p = 150 // Force on shelf - lbs
|
||||||
|
const distance = 6 // inches
|
||||||
|
const FOS = 2
|
||||||
|
|
||||||
|
const leg1 = 5 // inches
|
||||||
|
const leg2 = 8 // inches
|
||||||
|
const thickness = sqrt(distance * p * FOS * 6 / sigmaAllow / width) // inches
|
||||||
|
const bracket = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|
|> line([0, leg1], %)
|
||||||
|
|> line([leg2, 0], %)
|
||||||
|
|> line([0, -thickness], %)
|
||||||
|
|> line([-leg2 + thickness, 0], %)
|
||||||
|
|> line([0, -leg1 + thickness], %)
|
||||||
|
|> close(%)
|
||||||
|
|> extrude(width, %)
|
@ -0,0 +1,26 @@
|
|||||||
|
const sigmaAllow = 15000 // psi
|
||||||
|
const width = 11 // inch
|
||||||
|
const p = 150 // Force on shelf - lbs
|
||||||
|
const distance = 12 // inches
|
||||||
|
const FOS = 2
|
||||||
|
const thickness = sqrt(distance * p * FOS * 6 / ( sigmaAllow * width ))
|
||||||
|
const filletR = thickness * 2
|
||||||
|
const shelfMountL = 9
|
||||||
|
const wallMountL = 8
|
||||||
|
|
||||||
|
const bracket = startSketchAt([0, 0])
|
||||||
|
|> line([0, wallMountL], %)
|
||||||
|
|> tangentialArc({
|
||||||
|
radius: filletR,
|
||||||
|
offset: 90
|
||||||
|
}, %)
|
||||||
|
|> line([-shelfMountL, 0], %)
|
||||||
|
|> line([0, -thickness], %)
|
||||||
|
|> line([shelfMountL, 0], %)
|
||||||
|
|> tangentialArc({
|
||||||
|
radius: filletR - thickness,
|
||||||
|
offset: -90
|
||||||
|
}, %)
|
||||||
|
|> line([0, -wallMountL], %)
|
||||||
|
|> close(%)
|
||||||
|
|> extrude(width, %)
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user