Compare commits
38 Commits
achalmers/
...
nadro/adho
Author | SHA1 | Date | |
---|---|---|---|
ac938e1f23 | |||
bf9dd893f1 | |||
03a13fd741 | |||
d567de1e5f | |||
66970d674d | |||
07d899e884 | |||
86e6590f4d | |||
340c503633 | |||
7abc119993 | |||
34494f3bba | |||
4102249bd8 | |||
df6256266c | |||
e5d082f441 | |||
d4d3e179b1 | |||
3929f2e9fb | |||
bab98ab5c9 | |||
8dc1b156ff | |||
693fd8eb31 | |||
14a72344e2 | |||
e5d1cd847d | |||
01d294a8bb | |||
aa460d631d | |||
23e609443b | |||
d3aa09a20b | |||
eba91e85ea | |||
74f6e338f7 | |||
529c619fb5 | |||
195000b50c | |||
7993b5f4e8 | |||
fb8acbefe7 | |||
8f2a2391d1 | |||
4f4c44e7c7 | |||
e2247669f0 | |||
1b75020686 | |||
fba62dab98 | |||
a85a534d6b | |||
6ddbb7a31d | |||
051bb0589e |
@ -3,18 +3,17 @@
|
||||
NODE_ENV=development
|
||||
DEV=true
|
||||
|
||||
# App
|
||||
VITE_KC_API_WS_MODELING_URL=wss://api.dev.zoo.dev/ws/modeling/commands
|
||||
VITE_KC_API_BASE_URL=https://api.dev.zoo.dev
|
||||
VITE_KITTYCAD_API_BASE_URL=https://api.dev.zoo.dev
|
||||
VITE_KC_SITE_BASE_URL=https://dev.zoo.dev
|
||||
VITE_KC_SITE_APP_URL=https://app.dev.zoo.dev
|
||||
VITE_KC_SKIP_AUTH=false
|
||||
VITE_KC_CONNECTION_TIMEOUT_MS=5000
|
||||
#VITE_WASM_URL="optional way of overriding the wasm url, particular for unit tests which need this if you running not on the default 3000 port"
|
||||
#VITE_KC_DEV_TOKEN="optional token to skip auth in the app"
|
||||
#token="required token for playwright. TODO: clean up env vars in #3973"
|
||||
#VITE_WASM_URL="optional override of Wasm URL if not on default port 3000"
|
||||
#VITE_KITTYCAD_API_TOKEN="required for testing, optional to skip auth in the app"
|
||||
FAIL_ON_CONSOLE_ERRORS=true
|
||||
|
||||
# KCL
|
||||
RUST_BACKTRACE=1
|
||||
PYO3_PYTHON=/usr/local/bin/python3
|
||||
#KITTYCAD_API_TOKEN="required token for engine testing"
|
||||
|
||||
FAIL_ON_CONSOLE_ERRORS=true
|
||||
#KITTYCAD_API_TOKEN=$VITE_KITTYCAD_API_TOKEN
|
||||
|
@ -1,7 +1,8 @@
|
||||
NODE_ENV=production
|
||||
|
||||
# App
|
||||
VITE_KC_API_WS_MODELING_URL=wss://api.zoo.dev/ws/modeling/commands
|
||||
VITE_KC_API_BASE_URL=https://api.zoo.dev
|
||||
VITE_KITTYCAD_API_BASE_URL=https://api.zoo.dev
|
||||
VITE_KC_SITE_BASE_URL=https://zoo.dev
|
||||
VITE_KC_SITE_APP_URL=https://app.zoo.dev
|
||||
VITE_KC_SKIP_AUTH=false
|
||||
VITE_KC_CONNECTION_TIMEOUT_MS=15000
|
||||
|
8
.github/workflows/e2e-tests.yml
vendored
8
.github/workflows/e2e-tests.yml
vendored
@ -157,7 +157,7 @@ jobs:
|
||||
timeout_minutes: 5
|
||||
max_attempts: 5
|
||||
env:
|
||||
token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
|
||||
VITE_KITTYCAD_API_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
|
||||
TAB_API_URL: ${{ secrets.TAB_API_URL }}
|
||||
TAB_API_KEY: ${{ secrets.TAB_API_KEY }}
|
||||
CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
@ -169,7 +169,7 @@ jobs:
|
||||
if: always()
|
||||
run: npm run test:snapshots -- --last-failed --update-snapshots
|
||||
env:
|
||||
token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
|
||||
VITE_KITTYCAD_API_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
|
||||
TAB_API_URL: ${{ secrets.TAB_API_URL }}
|
||||
TAB_API_KEY: ${{ secrets.TAB_API_KEY }}
|
||||
CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
@ -284,7 +284,7 @@ jobs:
|
||||
timeout_minutes: 5
|
||||
max_attempts: 5
|
||||
env:
|
||||
token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
|
||||
VITE_KITTYCAD_API_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
|
||||
TAB_API_URL: ${{ secrets.TAB_API_URL }}
|
||||
TAB_API_KEY: ${{ secrets.TAB_API_KEY }}
|
||||
CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
@ -410,7 +410,7 @@ jobs:
|
||||
max_attempts: 9
|
||||
env:
|
||||
FAIL_ON_CONSOLE_ERRORS: true
|
||||
token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
|
||||
VITE_KITTYCAD_API_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
|
||||
TAB_API_URL: ${{ secrets.TAB_API_URL }}
|
||||
TAB_API_KEY: ${{ secrets.TAB_API_KEY }}
|
||||
CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
|
2
.github/workflows/unit-tests.yml
vendored
2
.github/workflows/unit-tests.yml
vendored
@ -62,7 +62,7 @@ jobs:
|
||||
if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }}
|
||||
run: xvfb-run -a npm run test:unit
|
||||
env:
|
||||
VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
|
||||
VITE_KITTYCAD_API_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
|
||||
|
||||
- name: Check for changes
|
||||
if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }}
|
||||
|
@ -65,7 +65,7 @@ If you're not a Zoo employee you won't be able to access the dev environment, yo
|
||||
|
||||
### Development environment variables
|
||||
|
||||
The Copilot LSP plugin in the editor requires a Zoo API token to run. In production, we authenticate this with a token via cookie in the browser and device auth token in the desktop environment, but this token is inaccessible in the dev browser version because the cookie is considered "cross-site" (from `localhost` to `zoo.dev`). There is an optional environment variable called `VITE_KC_DEV_TOKEN` that you can populate with a dev token in a `.env.development.local` file to not check it into Git, which will use that token instead of other methods for the LSP service.
|
||||
The Copilot LSP plugin in the editor requires a Zoo API token to run. In production, we authenticate this with a token via cookie in the browser and device auth token in the desktop environment, but this token is inaccessible in the dev browser version because the cookie is considered "cross-site" (from `localhost` to `zoo.dev`). There is an optional environment variable called `VITE_KITTYCAD_API_TOKEN` that you can populate with a dev token in a `.env.development.local` file to not check it into Git, which will use that token instead of other methods for the LSP service.
|
||||
|
||||
### Developing in Chrome
|
||||
|
||||
@ -96,7 +96,7 @@ To package the app for your platform with electron-builder, run `npm run tronb:p
|
||||
|
||||
Prepare these system dependencies:
|
||||
|
||||
- Set $token from https://zoo.dev/account/api-tokens
|
||||
- Set `$VITE_KITTYCAD_API_TOKEN` from https://zoo.dev/account/api-tokens
|
||||
|
||||
#### Snapshot tests (Google Chrome on Ubuntu only)
|
||||
|
||||
@ -259,7 +259,7 @@ If the application needs to overwrite the known file on disk use this pattern. T
|
||||
- `npm run circular-deps:overwrite`
|
||||
- `npm run url-checker:overwrite`
|
||||
|
||||
#### Diff baseline and current
|
||||
#### Diff baseline and current
|
||||
|
||||
These commands will write a /tmp/ file on disk and compare it to the known file in the repository. This command will also be used in the CI CD pipeline for automated checks
|
||||
|
||||
|
55
docs/kcl-std/functions/std-sketch-rectangle.md
Normal file
55
docs/kcl-std/functions/std-sketch-rectangle.md
Normal file
File diff suppressed because one or more lines are too long
@ -72,6 +72,7 @@ layout: manual
|
||||
* [`profileStart`](/docs/kcl-std/functions/std-sketch-profileStart)
|
||||
* [`profileStartX`](/docs/kcl-std/functions/std-sketch-profileStartX)
|
||||
* [`profileStartY`](/docs/kcl-std/functions/std-sketch-profileStartY)
|
||||
* [`rectangle`](/docs/kcl-std/functions/std-sketch-rectangle)
|
||||
* [`revolve`](/docs/kcl-std/functions/std-sketch-revolve)
|
||||
* [`segAng`](/docs/kcl-std/functions/std-sketch-segAng)
|
||||
* [`segEnd`](/docs/kcl-std/functions/std-sketch-segEnd)
|
||||
|
@ -37,6 +37,7 @@ This module contains functions for creating and manipulating sketches, and makin
|
||||
* [`profileStart`](/docs/kcl-std/functions/std-sketch-profileStart)
|
||||
* [`profileStartX`](/docs/kcl-std/functions/std-sketch-profileStartX)
|
||||
* [`profileStartY`](/docs/kcl-std/functions/std-sketch-profileStartY)
|
||||
* [`rectangle`](/docs/kcl-std/functions/std-sketch-rectangle)
|
||||
* [`revolve`](/docs/kcl-std/functions/std-sketch-revolve)
|
||||
* [`segAng`](/docs/kcl-std/functions/std-sketch-segAng)
|
||||
* [`segEnd`](/docs/kcl-std/functions/std-sketch-segEnd)
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { expect, test } from '@e2e/playwright/zoo-test'
|
||||
|
||||
// test file is for testing auth functionality
|
||||
test.describe('Authentication tests', () => {
|
||||
test(
|
||||
`The user can sign out and back in`,
|
||||
@ -13,22 +12,12 @@ test.describe('Authentication tests', () => {
|
||||
await page.setBodyDimensions({ width: 1000, height: 500 })
|
||||
await homePage.projectSection.waitFor()
|
||||
|
||||
// This is only needed as an override to test-utils' setup() for this test
|
||||
await page.addInitScript(() => {
|
||||
localStorage.setItem('TOKEN_PERSIST_KEY', '')
|
||||
})
|
||||
|
||||
await test.step('Click on sign out and expect sign in page', async () => {
|
||||
await toolbar.userSidebarButton.click()
|
||||
await toolbar.signOutButton.click()
|
||||
await expect(signInPage.signInButton).toBeVisible()
|
||||
})
|
||||
|
||||
await test.step("Refresh doesn't log the user back in", async () => {
|
||||
await page.reload()
|
||||
await expect(signInPage.signInButton).toBeVisible()
|
||||
})
|
||||
|
||||
await test.step('Click on sign in and cancel, click again and expect different code', async () => {
|
||||
await signInPage.signInButton.click()
|
||||
await expect(signInPage.userCode).toBeVisible()
|
||||
|
@ -17,7 +17,7 @@ import dotenv from 'dotenv'
|
||||
|
||||
const NODE_ENV = process.env.NODE_ENV || 'development'
|
||||
dotenv.config({ path: [`.env.${NODE_ENV}.local`, `.env.${NODE_ENV}`] })
|
||||
export const token = process.env.token || ''
|
||||
export const token = process.env.VITE_KITTYCAD_API_TOKEN || ''
|
||||
|
||||
import type { ProjectConfiguration } from '@rust/kcl-lib/bindings/ProjectConfiguration'
|
||||
|
||||
|
7
interface.d.ts
vendored
7
interface.d.ts
vendored
@ -72,16 +72,13 @@ export interface IElectronAPI {
|
||||
}
|
||||
process: {
|
||||
env: {
|
||||
BASE_URL: string
|
||||
IS_PLAYWRIGHT: string
|
||||
VITE_KC_DEV_TOKEN: string
|
||||
VITE_KITTYCAD_API_TOKEN: string
|
||||
VITE_KC_API_WS_MODELING_URL: string
|
||||
VITE_KC_API_BASE_URL: string
|
||||
VITE_KITTYCAD_API_BASE_URL: string
|
||||
VITE_KC_SITE_BASE_URL: string
|
||||
VITE_KC_SITE_APP_URL: string
|
||||
VITE_KC_SKIP_AUTH: string
|
||||
VITE_KC_CONNECTION_TIMEOUT_MS: string
|
||||
VITE_KC_DEV_TOKEN: string
|
||||
NODE_ENV: string
|
||||
PROD: string
|
||||
DEV: string
|
||||
|
20
rust/Cargo.lock
generated
20
rust/Cargo.lock
generated
@ -1814,7 +1814,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-bumper"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@ -1825,7 +1825,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-derive-docs"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -1834,7 +1834,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-directory-test-macro"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"proc-macro2",
|
||||
@ -1844,7 +1844,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-language-server"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@ -1865,7 +1865,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-language-server-release"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@ -1885,7 +1885,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-lib"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"approx 0.5.1",
|
||||
@ -1962,7 +1962,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-python-bindings"
|
||||
version = "0.3.83"
|
||||
version = "0.3.84"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"kcl-lib",
|
||||
@ -1977,7 +1977,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-test-server"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"hyper 0.14.32",
|
||||
@ -1990,7 +1990,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-to-core"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -2004,7 +2004,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-wasm-lib"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bson",
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
[package]
|
||||
name = "kcl-bumper"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
edition = "2021"
|
||||
repository = "https://github.com/KittyCAD/modeling-api"
|
||||
rust-version = "1.76"
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-derive-docs"
|
||||
description = "A tool for generating documentation from Rust derive macros"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
|
@ -100,6 +100,8 @@ pub const TEST_NAMES: &[&str] = &[
|
||||
"std-sketch-planeOf-0",
|
||||
"std-sketch-circle-0",
|
||||
"std-sketch-circle-1",
|
||||
"std-sketch-rectangle-0",
|
||||
"std-sketch-rectangle-1",
|
||||
"std-sketch-patternTransform2d-0",
|
||||
"std-sketch-revolve-0",
|
||||
"std-sketch-revolve-1",
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-directory-test-macro"
|
||||
description = "A tool for generating tests from a directory of kcl files"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "kcl-language-server-release"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
edition = "2021"
|
||||
authors = ["KittyCAD Inc <kcl@kittycad.io>"]
|
||||
publish = false
|
||||
|
@ -2,7 +2,7 @@
|
||||
name = "kcl-language-server"
|
||||
description = "A language server for KCL."
|
||||
authors = ["KittyCAD Inc <kcl@kittycad.io>"]
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-lib"
|
||||
description = "KittyCAD Language implementation and tools"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
|
@ -10,71 +10,76 @@ DATA;
|
||||
NAMED_UNIT(*)
|
||||
SI_UNIT($, .METRE.)
|
||||
);
|
||||
#2 = UNCERTAINTY_MEASURE_WITH_UNIT(0.00001, #1, 'DISTANCE_ACCURACY_VALUE', $);
|
||||
#3 = (
|
||||
#2 = (
|
||||
NAMED_UNIT(*)
|
||||
PLANE_ANGLE_UNIT()
|
||||
SI_UNIT($, .RADIAN.)
|
||||
);
|
||||
#3 = UNCERTAINTY_MEASURE_WITH_UNIT(0.00001, #1, 'DISTANCE_ACCURACY_VALUE', $);
|
||||
#4 = (
|
||||
GEOMETRIC_REPRESENTATION_CONTEXT(3)
|
||||
GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#2))
|
||||
GLOBAL_UNIT_ASSIGNED_CONTEXT((#1))
|
||||
GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#3))
|
||||
GLOBAL_UNIT_ASSIGNED_CONTEXT((#1, #2))
|
||||
REPRESENTATION_CONTEXT('', '3D')
|
||||
);
|
||||
#4 = CARTESIAN_POINT('NONE', (0.015, -0.01, -0.005));
|
||||
#5 = VERTEX_POINT('NONE', #4);
|
||||
#6 = CARTESIAN_POINT('NONE', (0.015, 0, -0.005));
|
||||
#7 = VERTEX_POINT('NONE', #6);
|
||||
#8 = DIRECTION('NONE', (1, 0, -0));
|
||||
#9 = DIRECTION('NONE', (0, 1, 0));
|
||||
#10 = CARTESIAN_POINT('NONE', (0.005, -0.01, -0.005));
|
||||
#11 = AXIS2_PLACEMENT_3D('NONE', #10, #9, #8);
|
||||
#12 = CIRCLE('NONE', #11, 0.01);
|
||||
#13 = DIRECTION('NONE', (0, 1, 0));
|
||||
#14 = VECTOR('NONE', #13, 1);
|
||||
#15 = CARTESIAN_POINT('NONE', (0.015, -0.01, -0.005));
|
||||
#16 = LINE('NONE', #15, #14);
|
||||
#17 = DIRECTION('NONE', (1, 0, -0));
|
||||
#18 = DIRECTION('NONE', (0, 1, 0));
|
||||
#19 = CARTESIAN_POINT('NONE', (0.005, 0, -0.005));
|
||||
#20 = AXIS2_PLACEMENT_3D('NONE', #19, #18, #17);
|
||||
#21 = CIRCLE('NONE', #20, 0.01);
|
||||
#22 = EDGE_CURVE('NONE', #5, #5, #12, .T.);
|
||||
#23 = EDGE_CURVE('NONE', #5, #7, #16, .T.);
|
||||
#24 = EDGE_CURVE('NONE', #7, #7, #21, .T.);
|
||||
#25 = CARTESIAN_POINT('NONE', (0.005, -0.005, -0.005));
|
||||
#26 = DIRECTION('NONE', (0, 1, 0));
|
||||
#27 = DIRECTION('NONE', (1, 0, -0));
|
||||
#28 = AXIS2_PLACEMENT_3D('NONE', #25, #26, #27);
|
||||
#29 = CYLINDRICAL_SURFACE('NONE', #28, 0.01);
|
||||
#30 = CARTESIAN_POINT('NONE', (0, -0.01, -0));
|
||||
#31 = DIRECTION('NONE', (0, 1, 0));
|
||||
#32 = AXIS2_PLACEMENT_3D('NONE', #30, #31, $);
|
||||
#33 = PLANE('NONE', #32);
|
||||
#34 = CARTESIAN_POINT('NONE', (0, 0, -0));
|
||||
#35 = DIRECTION('NONE', (0, 1, 0));
|
||||
#36 = AXIS2_PLACEMENT_3D('NONE', #34, #35, $);
|
||||
#37 = PLANE('NONE', #36);
|
||||
#38 = ORIENTED_EDGE('NONE', *, *, #22, .T.);
|
||||
#39 = ORIENTED_EDGE('NONE', *, *, #24, .F.);
|
||||
#40 = EDGE_LOOP('NONE', (#38));
|
||||
#41 = FACE_BOUND('NONE', #40, .T.);
|
||||
#42 = EDGE_LOOP('NONE', (#39));
|
||||
#43 = FACE_BOUND('NONE', #42, .T.);
|
||||
#44 = ADVANCED_FACE('NONE', (#41, #43), #29, .T.);
|
||||
#45 = ORIENTED_EDGE('NONE', *, *, #22, .F.);
|
||||
#46 = EDGE_LOOP('NONE', (#45));
|
||||
#47 = FACE_BOUND('NONE', #46, .T.);
|
||||
#48 = ADVANCED_FACE('NONE', (#47), #33, .F.);
|
||||
#49 = ORIENTED_EDGE('NONE', *, *, #24, .T.);
|
||||
#50 = EDGE_LOOP('NONE', (#49));
|
||||
#51 = FACE_BOUND('NONE', #50, .T.);
|
||||
#52 = ADVANCED_FACE('NONE', (#51), #37, .T.);
|
||||
#53 = CLOSED_SHELL('NONE', (#44, #48, #52));
|
||||
#54 = MANIFOLD_SOLID_BREP('NONE', #53);
|
||||
#55 = APPLICATION_CONTEXT('configuration controlled 3D design of mechanical parts and assemblies');
|
||||
#56 = PRODUCT_DEFINITION_CONTEXT('part definition', #55, 'design');
|
||||
#57 = PRODUCT('UNIDENTIFIED_PRODUCT', 'NONE', $, ());
|
||||
#58 = PRODUCT_DEFINITION_FORMATION('', $, #57);
|
||||
#59 = PRODUCT_DEFINITION('design', $, #58, #56);
|
||||
#60 = PRODUCT_DEFINITION_SHAPE('NONE', $, #59);
|
||||
#61 = ADVANCED_BREP_SHAPE_REPRESENTATION('NONE', (#54), #3);
|
||||
#62 = SHAPE_DEFINITION_REPRESENTATION(#60, #61);
|
||||
#5 = CARTESIAN_POINT('NONE', (0.015, -0.01, -0.005));
|
||||
#6 = VERTEX_POINT('NONE', #5);
|
||||
#7 = CARTESIAN_POINT('NONE', (0.015, 0, -0.005));
|
||||
#8 = VERTEX_POINT('NONE', #7);
|
||||
#9 = DIRECTION('NONE', (1, 0, -0));
|
||||
#10 = DIRECTION('NONE', (0, 1, 0));
|
||||
#11 = CARTESIAN_POINT('NONE', (0.005, -0.01, -0.005));
|
||||
#12 = AXIS2_PLACEMENT_3D('NONE', #11, #10, #9);
|
||||
#13 = CIRCLE('NONE', #12, 0.01);
|
||||
#14 = DIRECTION('NONE', (0, 1, 0));
|
||||
#15 = VECTOR('NONE', #14, 1);
|
||||
#16 = CARTESIAN_POINT('NONE', (0.015, -0.01, -0.005));
|
||||
#17 = LINE('NONE', #16, #15);
|
||||
#18 = DIRECTION('NONE', (1, 0, -0));
|
||||
#19 = DIRECTION('NONE', (0, 1, 0));
|
||||
#20 = CARTESIAN_POINT('NONE', (0.005, 0, -0.005));
|
||||
#21 = AXIS2_PLACEMENT_3D('NONE', #20, #19, #18);
|
||||
#22 = CIRCLE('NONE', #21, 0.01);
|
||||
#23 = EDGE_CURVE('NONE', #6, #6, #13, .T.);
|
||||
#24 = EDGE_CURVE('NONE', #6, #8, #17, .T.);
|
||||
#25 = EDGE_CURVE('NONE', #8, #8, #22, .T.);
|
||||
#26 = CARTESIAN_POINT('NONE', (0.005, -0.005, -0.005));
|
||||
#27 = DIRECTION('NONE', (0, 1, 0));
|
||||
#28 = DIRECTION('NONE', (1, 0, -0));
|
||||
#29 = AXIS2_PLACEMENT_3D('NONE', #26, #27, #28);
|
||||
#30 = CYLINDRICAL_SURFACE('NONE', #29, 0.01);
|
||||
#31 = CARTESIAN_POINT('NONE', (0, -0.01, -0));
|
||||
#32 = DIRECTION('NONE', (0, 1, 0));
|
||||
#33 = AXIS2_PLACEMENT_3D('NONE', #31, #32, $);
|
||||
#34 = PLANE('NONE', #33);
|
||||
#35 = CARTESIAN_POINT('NONE', (0, 0, -0));
|
||||
#36 = DIRECTION('NONE', (0, 1, 0));
|
||||
#37 = AXIS2_PLACEMENT_3D('NONE', #35, #36, $);
|
||||
#38 = PLANE('NONE', #37);
|
||||
#39 = ORIENTED_EDGE('NONE', *, *, #23, .T.);
|
||||
#40 = ORIENTED_EDGE('NONE', *, *, #25, .F.);
|
||||
#41 = EDGE_LOOP('NONE', (#39));
|
||||
#42 = FACE_BOUND('NONE', #41, .T.);
|
||||
#43 = EDGE_LOOP('NONE', (#40));
|
||||
#44 = FACE_BOUND('NONE', #43, .T.);
|
||||
#45 = ADVANCED_FACE('NONE', (#42, #44), #30, .T.);
|
||||
#46 = ORIENTED_EDGE('NONE', *, *, #23, .F.);
|
||||
#47 = EDGE_LOOP('NONE', (#46));
|
||||
#48 = FACE_BOUND('NONE', #47, .T.);
|
||||
#49 = ADVANCED_FACE('NONE', (#48), #34, .F.);
|
||||
#50 = ORIENTED_EDGE('NONE', *, *, #25, .T.);
|
||||
#51 = EDGE_LOOP('NONE', (#50));
|
||||
#52 = FACE_BOUND('NONE', #51, .T.);
|
||||
#53 = ADVANCED_FACE('NONE', (#52), #38, .T.);
|
||||
#54 = CLOSED_SHELL('NONE', (#45, #49, #53));
|
||||
#55 = MANIFOLD_SOLID_BREP('NONE', #54);
|
||||
#56 = APPLICATION_CONTEXT('configuration controlled 3D design of mechanical parts and assemblies');
|
||||
#57 = PRODUCT_DEFINITION_CONTEXT('part definition', #56, 'design');
|
||||
#58 = PRODUCT('UNIDENTIFIED_PRODUCT', 'NONE', $, ());
|
||||
#59 = PRODUCT_DEFINITION_FORMATION('', $, #58);
|
||||
#60 = PRODUCT_DEFINITION('design', $, #59, #57);
|
||||
#61 = PRODUCT_DEFINITION_SHAPE('NONE', $, #60);
|
||||
#62 = ADVANCED_BREP_SHAPE_REPRESENTATION('NONE', (#55), #4);
|
||||
#63 = SHAPE_DEFINITION_REPRESENTATION(#61, #62);
|
||||
ENDSEC;
|
||||
END-ISO-10303-21;
|
||||
|
@ -864,6 +864,9 @@ impl BinaryPart {
|
||||
BinaryPart::CallExpressionKw(call_expression) => call_expression.execute(exec_state, ctx).await,
|
||||
BinaryPart::UnaryExpression(unary_expression) => unary_expression.get_result(exec_state, ctx).await,
|
||||
BinaryPart::MemberExpression(member_expression) => member_expression.get_result(exec_state, ctx).await,
|
||||
BinaryPart::ArrayExpression(e) => e.execute(exec_state, ctx).await,
|
||||
BinaryPart::ArrayRangeExpression(e) => e.execute(exec_state, ctx).await,
|
||||
BinaryPart::ObjectExpression(e) => e.execute(exec_state, ctx).await,
|
||||
BinaryPart::IfExpression(e) => e.get_result(exec_state, ctx).await,
|
||||
BinaryPart::AscribedExpression(e) => e.get_result(exec_state, ctx).await,
|
||||
}
|
||||
@ -991,6 +994,39 @@ impl Node<MemberExpression> {
|
||||
|
||||
// Check the property and object match -- e.g. ints for arrays, strs for objects.
|
||||
match (object, property, self.computed) {
|
||||
(KclValue::Plane { value: plane }, Property::String(property), false) => match property.as_str() {
|
||||
"yAxis" => {
|
||||
let (p, u) = plane.info.y_axis.as_3_dims();
|
||||
Ok(KclValue::array_from_point3d(
|
||||
p,
|
||||
NumericType::Known(crate::exec::UnitType::Length(u)),
|
||||
vec![meta],
|
||||
))
|
||||
}
|
||||
"xAxis" => {
|
||||
let (p, u) = plane.info.x_axis.as_3_dims();
|
||||
Ok(KclValue::array_from_point3d(
|
||||
p,
|
||||
NumericType::Known(crate::exec::UnitType::Length(u)),
|
||||
vec![meta],
|
||||
))
|
||||
}
|
||||
"origin" => {
|
||||
let (p, u) = plane.info.origin.as_3_dims();
|
||||
Ok(KclValue::array_from_point3d(
|
||||
p,
|
||||
NumericType::Known(crate::exec::UnitType::Length(u)),
|
||||
vec![meta],
|
||||
))
|
||||
}
|
||||
other => Err(KclError::new_undefined_value(
|
||||
KclErrorDetails::new(
|
||||
format!("Property '{other}' not found in plane"),
|
||||
vec![self.clone().into()],
|
||||
),
|
||||
None,
|
||||
)),
|
||||
},
|
||||
(KclValue::Object { value: map, meta: _ }, Property::String(property), false) => {
|
||||
if let Some(value) = map.get(&property) {
|
||||
Ok(value.to_owned())
|
||||
@ -1010,7 +1046,22 @@ impl Node<MemberExpression> {
|
||||
vec![self.clone().into()],
|
||||
)))
|
||||
}
|
||||
(KclValue::Object { .. }, p, _) => {
|
||||
(KclValue::Object { value: map, .. }, p @ Property::UInt(i), _) => {
|
||||
if i == 0
|
||||
&& let Some(value) = map.get("x")
|
||||
{
|
||||
return Ok(value.to_owned());
|
||||
}
|
||||
if i == 1
|
||||
&& let Some(value) = map.get("y")
|
||||
{
|
||||
return Ok(value.to_owned());
|
||||
}
|
||||
if i == 2
|
||||
&& let Some(value) = map.get("z")
|
||||
{
|
||||
return Ok(value.to_owned());
|
||||
}
|
||||
let t = p.type_name();
|
||||
let article = article_for(t);
|
||||
Err(KclError::new_semantic(KclErrorDetails::new(
|
||||
@ -1046,6 +1097,16 @@ impl Node<MemberExpression> {
|
||||
(KclValue::Solid { value }, Property::String(prop), false) if prop == "sketch" => Ok(KclValue::Sketch {
|
||||
value: Box::new(value.sketch),
|
||||
}),
|
||||
(geometry @ KclValue::Solid { .. }, Property::String(prop), false) if prop == "tags" => {
|
||||
// This is a common mistake.
|
||||
Err(KclError::new_semantic(KclErrorDetails::new(
|
||||
format!(
|
||||
"Property `{prop}` not found on {}. You can get a solid's tags through its sketch, as in, `exampleSolid.sketch.tags`.",
|
||||
geometry.human_friendly_type()
|
||||
),
|
||||
vec![self.clone().into()],
|
||||
)))
|
||||
}
|
||||
(KclValue::Sketch { value: sk }, Property::String(prop), false) if prop == "tags" => Ok(KclValue::Object {
|
||||
meta: vec![Metadata {
|
||||
source_range: SourceRange::from(self.clone()),
|
||||
@ -1056,6 +1117,12 @@ impl Node<MemberExpression> {
|
||||
.map(|(k, tag)| (k.to_owned(), KclValue::TagIdentifier(Box::new(tag.to_owned()))))
|
||||
.collect(),
|
||||
}),
|
||||
(geometry @ (KclValue::Sketch { .. } | KclValue::Solid { .. }), Property::String(property), false) => {
|
||||
Err(KclError::new_semantic(KclErrorDetails::new(
|
||||
format!("Property `{property}` not found on {}", geometry.human_friendly_type()),
|
||||
vec![self.clone().into()],
|
||||
)))
|
||||
}
|
||||
(being_indexed, _, _) => Err(KclError::new_semantic(KclErrorDetails::new(
|
||||
format!(
|
||||
"Only arrays can be indexed, but you're trying to index {}",
|
||||
@ -2186,4 +2253,12 @@ y = x[0mm + 1]
|
||||
"#;
|
||||
parse_execute(ast).await.unwrap_err();
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn getting_property_of_plane() {
|
||||
// let ast = include_str!("../../tests/inputs/planestuff.kcl");
|
||||
let ast = std::fs::read_to_string("tests/inputs/planestuff.kcl").unwrap();
|
||||
|
||||
parse_execute(&ast).await.unwrap();
|
||||
}
|
||||
}
|
||||
|
@ -921,6 +921,12 @@ impl Point3d {
|
||||
units: UnitLen::Unknown,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_3_dims(&self) -> ([f64; 3], UnitLen) {
|
||||
let p = [self.x, self.y, self.z];
|
||||
let u = self.units;
|
||||
(p, u)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<[TyF64; 3]> for Point3d {
|
||||
@ -1031,7 +1037,7 @@ pub struct GeoMeta {
|
||||
#[ts(export)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum Path {
|
||||
/// A path that goes to a point.
|
||||
/// A straight line which ends at the given point.
|
||||
ToPoint {
|
||||
#[serde(flatten)]
|
||||
base: BasePath,
|
||||
|
@ -458,6 +458,31 @@ impl KclValue {
|
||||
}
|
||||
}
|
||||
|
||||
/// Put the point into a KCL point.
|
||||
pub fn array_from_point3d(p: [f64; 3], ty: NumericType, meta: Vec<Metadata>) -> Self {
|
||||
let [x, y, z] = p;
|
||||
Self::HomArray {
|
||||
value: vec![
|
||||
Self::Number {
|
||||
value: x,
|
||||
meta: meta.clone(),
|
||||
ty,
|
||||
},
|
||||
Self::Number {
|
||||
value: y,
|
||||
meta: meta.clone(),
|
||||
ty,
|
||||
},
|
||||
Self::Number {
|
||||
value: z,
|
||||
meta: meta.clone(),
|
||||
ty,
|
||||
},
|
||||
],
|
||||
ty: ty.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn as_usize(&self) -> Option<usize> {
|
||||
match self {
|
||||
KclValue::Number { value, .. } => crate::try_f64_to_usize(*value),
|
||||
|
@ -149,6 +149,9 @@ impl BinaryPart {
|
||||
BinaryPart::UnaryExpression(unary_expression) => {
|
||||
unary_expression.get_hover_value_for_position(pos, code, opts)
|
||||
}
|
||||
BinaryPart::ArrayExpression(e) => e.get_hover_value_for_position(pos, code, opts),
|
||||
BinaryPart::ArrayRangeExpression(e) => e.get_hover_value_for_position(pos, code, opts),
|
||||
BinaryPart::ObjectExpression(e) => e.get_hover_value_for_position(pos, code, opts),
|
||||
BinaryPart::IfExpression(e) => e.get_hover_value_for_position(pos, code, opts),
|
||||
BinaryPart::AscribedExpression(e) => e.expr.get_hover_value_for_position(pos, code, opts),
|
||||
BinaryPart::MemberExpression(member_expression) => {
|
||||
|
@ -161,6 +161,9 @@ impl BinaryPart {
|
||||
BinaryPart::CallExpressionKw(ce) => ce.compute_digest(),
|
||||
BinaryPart::UnaryExpression(ue) => ue.compute_digest(),
|
||||
BinaryPart::MemberExpression(me) => me.compute_digest(),
|
||||
BinaryPart::ArrayExpression(e) => e.compute_digest(),
|
||||
BinaryPart::ArrayRangeExpression(e) => e.compute_digest(),
|
||||
BinaryPart::ObjectExpression(e) => e.compute_digest(),
|
||||
BinaryPart::IfExpression(e) => e.compute_digest(),
|
||||
BinaryPart::AscribedExpression(e) => e.compute_digest(),
|
||||
}
|
||||
|
@ -51,6 +51,9 @@ impl BinaryPart {
|
||||
BinaryPart::CallExpressionKw(call_expression) => call_expression.module_id,
|
||||
BinaryPart::UnaryExpression(unary_expression) => unary_expression.module_id,
|
||||
BinaryPart::MemberExpression(member_expression) => member_expression.module_id,
|
||||
BinaryPart::ArrayExpression(e) => e.module_id,
|
||||
BinaryPart::ArrayRangeExpression(e) => e.module_id,
|
||||
BinaryPart::ObjectExpression(e) => e.module_id,
|
||||
BinaryPart::IfExpression(e) => e.module_id,
|
||||
BinaryPart::AscribedExpression(e) => e.module_id,
|
||||
}
|
||||
|
@ -1214,6 +1214,9 @@ impl From<&BinaryPart> for Expr {
|
||||
BinaryPart::CallExpressionKw(call_expression) => Expr::CallExpressionKw(call_expression.clone()),
|
||||
BinaryPart::UnaryExpression(unary_expression) => Expr::UnaryExpression(unary_expression.clone()),
|
||||
BinaryPart::MemberExpression(member_expression) => Expr::MemberExpression(member_expression.clone()),
|
||||
BinaryPart::ArrayExpression(e) => Expr::ArrayExpression(e.clone()),
|
||||
BinaryPart::ArrayRangeExpression(e) => Expr::ArrayRangeExpression(e.clone()),
|
||||
BinaryPart::ObjectExpression(e) => Expr::ObjectExpression(e.clone()),
|
||||
BinaryPart::IfExpression(e) => Expr::IfExpression(e.clone()),
|
||||
BinaryPart::AscribedExpression(e) => Expr::AscribedExpression(e.clone()),
|
||||
}
|
||||
@ -1281,6 +1284,9 @@ pub enum BinaryPart {
|
||||
CallExpressionKw(BoxNode<CallExpressionKw>),
|
||||
UnaryExpression(BoxNode<UnaryExpression>),
|
||||
MemberExpression(BoxNode<MemberExpression>),
|
||||
ArrayExpression(BoxNode<ArrayExpression>),
|
||||
ArrayRangeExpression(BoxNode<ArrayRangeExpression>),
|
||||
ObjectExpression(BoxNode<ObjectExpression>),
|
||||
IfExpression(BoxNode<IfExpression>),
|
||||
AscribedExpression(BoxNode<AscribedExpression>),
|
||||
}
|
||||
@ -1307,6 +1313,9 @@ impl BinaryPart {
|
||||
BinaryPart::CallExpressionKw(call_expression) => call_expression.get_constraint_level(),
|
||||
BinaryPart::UnaryExpression(unary_expression) => unary_expression.get_constraint_level(),
|
||||
BinaryPart::MemberExpression(member_expression) => member_expression.get_constraint_level(),
|
||||
BinaryPart::ArrayExpression(e) => e.get_constraint_level(),
|
||||
BinaryPart::ArrayRangeExpression(e) => e.get_constraint_level(),
|
||||
BinaryPart::ObjectExpression(e) => e.get_constraint_level(),
|
||||
BinaryPart::IfExpression(e) => e.get_constraint_level(),
|
||||
BinaryPart::AscribedExpression(e) => e.expr.get_constraint_level(),
|
||||
}
|
||||
@ -1320,6 +1329,9 @@ impl BinaryPart {
|
||||
BinaryPart::CallExpressionKw(call_expression) => call_expression.replace_value(source_range, new_value),
|
||||
BinaryPart::UnaryExpression(unary_expression) => unary_expression.replace_value(source_range, new_value),
|
||||
BinaryPart::MemberExpression(_) => {}
|
||||
BinaryPart::ArrayExpression(e) => e.replace_value(source_range, new_value),
|
||||
BinaryPart::ArrayRangeExpression(e) => e.replace_value(source_range, new_value),
|
||||
BinaryPart::ObjectExpression(e) => e.replace_value(source_range, new_value),
|
||||
BinaryPart::IfExpression(e) => e.replace_value(source_range, new_value),
|
||||
BinaryPart::AscribedExpression(e) => e.expr.replace_value(source_range, new_value),
|
||||
}
|
||||
@ -1333,6 +1345,9 @@ impl BinaryPart {
|
||||
BinaryPart::CallExpressionKw(call_expression) => call_expression.start,
|
||||
BinaryPart::UnaryExpression(unary_expression) => unary_expression.start,
|
||||
BinaryPart::MemberExpression(member_expression) => member_expression.start,
|
||||
BinaryPart::ArrayExpression(e) => e.start,
|
||||
BinaryPart::ArrayRangeExpression(e) => e.start,
|
||||
BinaryPart::ObjectExpression(e) => e.start,
|
||||
BinaryPart::IfExpression(e) => e.start,
|
||||
BinaryPart::AscribedExpression(e) => e.start,
|
||||
}
|
||||
@ -1346,6 +1361,9 @@ impl BinaryPart {
|
||||
BinaryPart::CallExpressionKw(call_expression) => call_expression.end,
|
||||
BinaryPart::UnaryExpression(unary_expression) => unary_expression.end,
|
||||
BinaryPart::MemberExpression(member_expression) => member_expression.end,
|
||||
BinaryPart::ArrayExpression(e) => e.end,
|
||||
BinaryPart::ArrayRangeExpression(e) => e.end,
|
||||
BinaryPart::ObjectExpression(e) => e.end,
|
||||
BinaryPart::IfExpression(e) => e.end,
|
||||
BinaryPart::AscribedExpression(e) => e.end,
|
||||
}
|
||||
@ -1360,6 +1378,9 @@ impl BinaryPart {
|
||||
BinaryPart::CallExpressionKw(call_expression) => call_expression.rename_identifiers(old_name, new_name),
|
||||
BinaryPart::UnaryExpression(unary_expression) => unary_expression.rename_identifiers(old_name, new_name),
|
||||
BinaryPart::MemberExpression(member_expression) => member_expression.rename_identifiers(old_name, new_name),
|
||||
BinaryPart::ArrayExpression(e) => e.rename_identifiers(old_name, new_name),
|
||||
BinaryPart::ArrayRangeExpression(e) => e.rename_identifiers(old_name, new_name),
|
||||
BinaryPart::ObjectExpression(e) => e.rename_identifiers(old_name, new_name),
|
||||
BinaryPart::IfExpression(if_expression) => if_expression.rename_identifiers(old_name, new_name),
|
||||
BinaryPart::AscribedExpression(e) => e.expr.rename_identifiers(old_name, new_name),
|
||||
}
|
||||
|
@ -624,9 +624,6 @@ fn operand(i: &mut TokenSlice) -> ModalResult<BinaryPart> {
|
||||
Expr::FunctionExpression(_)
|
||||
| Expr::PipeExpression(_)
|
||||
| Expr::PipeSubstitution(_)
|
||||
| Expr::ArrayExpression(_)
|
||||
| Expr::ArrayRangeExpression(_)
|
||||
| Expr::ObjectExpression(_)
|
||||
| Expr::LabelledExpression(..) => return Err(CompilationError::fatal(source_range, TODO_783)),
|
||||
Expr::None(_) => {
|
||||
return Err(CompilationError::fatal(
|
||||
@ -652,6 +649,9 @@ fn operand(i: &mut TokenSlice) -> ModalResult<BinaryPart> {
|
||||
Expr::BinaryExpression(x) => BinaryPart::BinaryExpression(x),
|
||||
Expr::CallExpressionKw(x) => BinaryPart::CallExpressionKw(x),
|
||||
Expr::MemberExpression(x) => BinaryPart::MemberExpression(x),
|
||||
Expr::ArrayExpression(x) => BinaryPart::ArrayExpression(x),
|
||||
Expr::ArrayRangeExpression(x) => BinaryPart::ArrayRangeExpression(x),
|
||||
Expr::ObjectExpression(x) => BinaryPart::ObjectExpression(x),
|
||||
Expr::IfExpression(x) => BinaryPart::IfExpression(x),
|
||||
Expr::AscribedExpression(x) => BinaryPart::AscribedExpression(x),
|
||||
};
|
||||
@ -2115,6 +2115,8 @@ fn possible_operands(i: &mut TokenSlice) -> ModalResult<Expr> {
|
||||
literal.map(Expr::Literal),
|
||||
fn_call_kw.map(Box::new).map(Expr::CallExpressionKw),
|
||||
name.map(Box::new).map(Expr::Name),
|
||||
array,
|
||||
object.map(Box::new).map(Expr::ObjectExpression),
|
||||
binary_expr_in_parens.map(Box::new).map(Expr::BinaryExpression),
|
||||
unnecessarily_bracketed,
|
||||
))
|
||||
@ -3398,6 +3400,27 @@ mod tests {
|
||||
operand.parse(tokens).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_binary_operator_on_array() {
|
||||
let tokens = crate::parsing::token::lex("[0] + 1", ModuleId::default()).unwrap();
|
||||
let tokens = tokens.as_slice();
|
||||
binary_expression.parse(tokens).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_binary_operator_on_object() {
|
||||
let tokens = crate::parsing::token::lex("{ a = 1 } + 2", ModuleId::default()).unwrap();
|
||||
let tokens = tokens.as_slice();
|
||||
binary_expression.parse(tokens).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_call_array_operator() {
|
||||
let tokens = crate::parsing::token::lex("f([0] + 1)", ModuleId::default()).unwrap();
|
||||
let tokens = tokens.as_slice();
|
||||
fn_call_kw.parse(tokens).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weird_program_just_a_pipe() {
|
||||
let tokens = crate::parsing::token::lex("|", ModuleId::default()).unwrap();
|
||||
|
@ -779,6 +779,27 @@ mod add_lots {
|
||||
super::execute(TEST_NAME, false).await
|
||||
}
|
||||
}
|
||||
mod add_arrays {
|
||||
const TEST_NAME: &str = "add_arrays";
|
||||
|
||||
/// Test parsing KCL.
|
||||
#[test]
|
||||
fn parse() {
|
||||
super::parse(TEST_NAME)
|
||||
}
|
||||
|
||||
/// Test that parsing and unparsing KCL produces the original KCL input.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn unparse() {
|
||||
super::unparse(TEST_NAME).await
|
||||
}
|
||||
|
||||
/// Test that KCL is executed correctly.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_execute() {
|
||||
super::execute(TEST_NAME, false).await
|
||||
}
|
||||
}
|
||||
mod argument_error {
|
||||
//! The argument error points to the problematic argument in the call site,
|
||||
//! not the function definition that the variable points to.
|
||||
@ -887,6 +908,27 @@ mod invalid_index_fractional {
|
||||
super::execute(TEST_NAME, false).await
|
||||
}
|
||||
}
|
||||
mod property_access_not_found_on_solid {
|
||||
const TEST_NAME: &str = "property_access_not_found_on_solid";
|
||||
|
||||
/// Test parsing KCL.
|
||||
#[test]
|
||||
fn parse() {
|
||||
super::parse(TEST_NAME)
|
||||
}
|
||||
|
||||
/// Test that parsing and unparsing KCL produces the original KCL input.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn unparse() {
|
||||
super::unparse(TEST_NAME).await
|
||||
}
|
||||
|
||||
/// Test that KCL is executed correctly.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_execute() {
|
||||
super::execute(TEST_NAME, true).await
|
||||
}
|
||||
}
|
||||
mod invalid_member_object {
|
||||
const TEST_NAME: &str = "invalid_member_object";
|
||||
|
||||
@ -3632,6 +3674,48 @@ mod non_english_identifiers {
|
||||
super::execute(TEST_NAME, true).await
|
||||
}
|
||||
}
|
||||
mod rect {
|
||||
const TEST_NAME: &str = "rect";
|
||||
|
||||
/// Test parsing KCL.
|
||||
#[test]
|
||||
fn parse() {
|
||||
super::parse(TEST_NAME)
|
||||
}
|
||||
|
||||
/// Test that parsing and unparsing KCL produces the original KCL input.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn unparse() {
|
||||
super::unparse(TEST_NAME).await
|
||||
}
|
||||
|
||||
/// Test that KCL is executed correctly.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_execute() {
|
||||
super::execute(TEST_NAME, true).await
|
||||
}
|
||||
}
|
||||
mod rect_helper {
|
||||
const TEST_NAME: &str = "rect_helper";
|
||||
|
||||
/// Test parsing KCL.
|
||||
#[test]
|
||||
fn parse() {
|
||||
super::parse(TEST_NAME)
|
||||
}
|
||||
|
||||
/// Test that parsing and unparsing KCL produces the original KCL input.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn unparse() {
|
||||
super::unparse(TEST_NAME).await
|
||||
}
|
||||
|
||||
/// Test that KCL is executed correctly.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_execute() {
|
||||
super::execute(TEST_NAME, true).await
|
||||
}
|
||||
}
|
||||
mod plane_of {
|
||||
const TEST_NAME: &str = "plane_of";
|
||||
|
||||
|
@ -256,6 +256,10 @@ pub(crate) fn std_fn(path: &str, fn_name: &str) -> (crate::std::StdFn, StdFnProp
|
||||
|e, a| Box::pin(crate::std::shapes::circle(e, a)),
|
||||
StdFnProps::default("std::sketch::circle"),
|
||||
),
|
||||
("sketch", "rectangle") => (
|
||||
|e, a| Box::pin(crate::std::shapes::rectangle(e, a)),
|
||||
StdFnProps::default("std::sketch::rectangle"),
|
||||
),
|
||||
("sketch", "planeOf") => (
|
||||
|e, a| Box::pin(crate::std::planes::plane_of(e, a)),
|
||||
StdFnProps::default("std::sketch::planeOf"),
|
||||
|
@ -38,6 +38,119 @@ pub enum SketchOrSurface {
|
||||
Sketch(Box<Sketch>),
|
||||
}
|
||||
|
||||
/// Sketch a rectangle.
|
||||
pub async fn rectangle(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let sketch_or_surface =
|
||||
args.get_unlabeled_kw_arg("sketchOrSurface", &RuntimeType::sketch_or_surface(), exec_state)?;
|
||||
let center = args.get_kw_arg_opt("center", &RuntimeType::point2d(), exec_state)?;
|
||||
let corner = args.get_kw_arg_opt("corner", &RuntimeType::point2d(), exec_state)?;
|
||||
let width: TyF64 = args.get_kw_arg("width", &RuntimeType::length(), exec_state)?;
|
||||
let height: TyF64 = args.get_kw_arg("height", &RuntimeType::length(), exec_state)?;
|
||||
|
||||
inner_rectangle(sketch_or_surface, center, corner, width, height, exec_state, args)
|
||||
.await
|
||||
.map(Box::new)
|
||||
.map(|value| KclValue::Sketch { value })
|
||||
}
|
||||
|
||||
async fn inner_rectangle(
|
||||
sketch_or_surface: SketchOrSurface,
|
||||
center: Option<[TyF64; 2]>,
|
||||
corner: Option<[TyF64; 2]>,
|
||||
width: TyF64,
|
||||
height: TyF64,
|
||||
exec_state: &mut ExecState,
|
||||
args: Args,
|
||||
) -> Result<Sketch, KclError> {
|
||||
let sketch_surface = match sketch_or_surface {
|
||||
SketchOrSurface::SketchSurface(surface) => surface,
|
||||
SketchOrSurface::Sketch(s) => s.on,
|
||||
};
|
||||
|
||||
// Find the corner in the negative quadrant
|
||||
let (ty, corner) = match (center, corner) {
|
||||
(Some(center), None) => (
|
||||
center[0].ty,
|
||||
[center[0].n - width.n / 2.0, center[1].n - height.n / 2.0],
|
||||
),
|
||||
(None, Some(corner)) => (corner[0].ty, [corner[0].n, corner[1].n]),
|
||||
(None, None) => {
|
||||
return Err(KclError::new_semantic(KclErrorDetails::new(
|
||||
"You must supply either `corner` or `center` arguments, but not both".to_string(),
|
||||
vec![args.source_range],
|
||||
)));
|
||||
}
|
||||
(Some(_), Some(_)) => {
|
||||
return Err(KclError::new_semantic(KclErrorDetails::new(
|
||||
"You must supply either `corner` or `center` arguments, but not both".to_string(),
|
||||
vec![args.source_range],
|
||||
)));
|
||||
}
|
||||
};
|
||||
let units = ty.expect_length();
|
||||
let corner_t = [TyF64::new(corner[0], ty), TyF64::new(corner[1], ty)];
|
||||
|
||||
// Start the sketch then draw the 4 lines.
|
||||
let sketch =
|
||||
crate::std::sketch::inner_start_profile(sketch_surface, corner_t, None, exec_state, args.clone()).await?;
|
||||
let sketch_id = sketch.id;
|
||||
let deltas = [[width.n, 0.0], [0.0, height.n], [-width.n, 0.0], [0.0, -height.n]];
|
||||
let ids = [
|
||||
exec_state.next_uuid(),
|
||||
exec_state.next_uuid(),
|
||||
exec_state.next_uuid(),
|
||||
exec_state.next_uuid(),
|
||||
];
|
||||
for (id, delta) in ids.iter().copied().zip(deltas) {
|
||||
exec_state
|
||||
.batch_modeling_cmd(
|
||||
ModelingCmdMeta::from_args_id(&args, id),
|
||||
ModelingCmd::from(mcmd::ExtendPath {
|
||||
path: sketch.id.into(),
|
||||
segment: PathSegment::Line {
|
||||
end: KPoint2d::from(untyped_point_to_mm(delta, units))
|
||||
.with_z(0.0)
|
||||
.map(LengthUnit),
|
||||
relative: true,
|
||||
},
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
exec_state
|
||||
.batch_modeling_cmd(
|
||||
ModelingCmdMeta::from_args_id(&args, sketch_id),
|
||||
ModelingCmd::from(mcmd::ClosePath { path_id: sketch.id }),
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Update the sketch in KCL memory.
|
||||
let mut new_sketch = sketch.clone();
|
||||
fn add(a: [f64; 2], b: [f64; 2]) -> [f64; 2] {
|
||||
[a[0] + b[0], a[1] + b[1]]
|
||||
}
|
||||
let a = (corner, add(corner, deltas[0]));
|
||||
let b = (a.1, add(a.1, deltas[1]));
|
||||
let c = (b.1, add(b.1, deltas[2]));
|
||||
let d = (c.1, add(c.1, deltas[3]));
|
||||
for (id, (from, to)) in ids.into_iter().zip([a, b, c, d]) {
|
||||
let current_path = Path::ToPoint {
|
||||
base: BasePath {
|
||||
from,
|
||||
to,
|
||||
tag: None,
|
||||
units,
|
||||
geo_meta: GeoMeta {
|
||||
id,
|
||||
metadata: args.source_range.into(),
|
||||
},
|
||||
},
|
||||
};
|
||||
new_sketch.paths.push(current_path);
|
||||
}
|
||||
Ok(new_sketch)
|
||||
}
|
||||
|
||||
/// Sketch a circle.
|
||||
pub async fn circle(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let sketch_or_surface =
|
||||
|
@ -363,6 +363,9 @@ impl BinaryPart {
|
||||
BinaryPart::MemberExpression(member_expression) => {
|
||||
member_expression.recast(options, indentation_level, ctxt)
|
||||
}
|
||||
BinaryPart::ArrayExpression(e) => e.recast(options, indentation_level, ctxt),
|
||||
BinaryPart::ArrayRangeExpression(e) => e.recast(options, indentation_level, ctxt),
|
||||
BinaryPart::ObjectExpression(e) => e.recast(options, indentation_level, ctxt),
|
||||
BinaryPart::IfExpression(e) => e.recast(options, indentation_level, ExprContext::Other),
|
||||
BinaryPart::AscribedExpression(e) => e.recast(options, indentation_level, ExprContext::Other),
|
||||
}
|
||||
@ -745,6 +748,9 @@ impl UnaryExpression {
|
||||
BinaryPart::Literal(_)
|
||||
| BinaryPart::Name(_)
|
||||
| BinaryPart::MemberExpression(_)
|
||||
| BinaryPart::ArrayExpression(_)
|
||||
| BinaryPart::ArrayRangeExpression(_)
|
||||
| BinaryPart::ObjectExpression(_)
|
||||
| BinaryPart::IfExpression(_)
|
||||
| BinaryPart::AscribedExpression(_)
|
||||
| BinaryPart::CallExpressionKw(_) => {
|
||||
|
@ -220,6 +220,9 @@ impl<'tree> From<&'tree types::BinaryPart> for Node<'tree> {
|
||||
types::BinaryPart::CallExpressionKw(ce) => ce.as_ref().into(),
|
||||
types::BinaryPart::UnaryExpression(ue) => ue.as_ref().into(),
|
||||
types::BinaryPart::MemberExpression(me) => me.as_ref().into(),
|
||||
types::BinaryPart::ArrayExpression(e) => e.as_ref().into(),
|
||||
types::BinaryPart::ArrayRangeExpression(e) => e.as_ref().into(),
|
||||
types::BinaryPart::ObjectExpression(e) => e.as_ref().into(),
|
||||
types::BinaryPart::IfExpression(e) => e.as_ref().into(),
|
||||
types::BinaryPart::AscribedExpression(e) => e.as_ref().into(),
|
||||
}
|
||||
|
@ -234,6 +234,39 @@ export fn startProfile(
|
||||
tag?: TagDecl,
|
||||
): Sketch {}
|
||||
|
||||
/// Sketch a rectangle.
|
||||
///
|
||||
/// ```
|
||||
/// exampleSketch = startSketchOn(-XZ)
|
||||
/// |> rectangle(center = [0, 0], width = 10, height = 5)
|
||||
// |> extrude(length = 2)
|
||||
/// ```
|
||||
///
|
||||
/// ```
|
||||
/// exampleSketch = startSketchOn(-XZ)
|
||||
/// |> rectangle(corner = [0, 0], width = 10, height = 5)
|
||||
// |> extrude(length = 2)
|
||||
/// ```
|
||||
@(impl = std_rust)
|
||||
export fn rectangle(
|
||||
/// Sketch to extend, or plane or surface to sketch on.
|
||||
@sketchOrSurface: Sketch | Plane | Face,
|
||||
/// Rectangle's width along X axis.
|
||||
width: number(Length),
|
||||
/// Rectangle's height along Y axis.
|
||||
height: number(Length),
|
||||
/// The center of the rectangle.
|
||||
/// Incompatible with `corner`.
|
||||
@(snippetArray = ["0", "0"])
|
||||
center?: Point2d,
|
||||
/// The corner of the rectangle.
|
||||
/// Incompatible with `center`.
|
||||
/// This will be the corner which is most negative on
|
||||
/// both X and Y axes.
|
||||
@(snippetArray = ["0", "0"])
|
||||
corner?: Point2d,
|
||||
): Sketch {}
|
||||
|
||||
/// Construct a 2-dimensional circle, of the specified radius, centered at
|
||||
/// the provided (x, y) origin point.
|
||||
///
|
||||
|
18
rust/kcl-lib/tests/add_arrays/artifact_commands.snap
Normal file
18
rust/kcl-lib/tests/add_arrays/artifact_commands.snap
Normal file
@ -0,0 +1,18 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Artifact commands add_arrays.kcl
|
||||
---
|
||||
{
|
||||
"rust/kcl-lib/tests/add_arrays/input.kcl": [],
|
||||
"std::appearance": [],
|
||||
"std::array": [],
|
||||
"std::math": [],
|
||||
"std::prelude": [],
|
||||
"std::sketch": [],
|
||||
"std::solid": [],
|
||||
"std::sweep": [],
|
||||
"std::transform": [],
|
||||
"std::turns": [],
|
||||
"std::types": [],
|
||||
"std::units": []
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Artifact graph flowchart add_arrays.kcl
|
||||
extension: md
|
||||
snapshot_kind: binary
|
||||
---
|
@ -0,0 +1,3 @@
|
||||
```mermaid
|
||||
flowchart LR
|
||||
```
|
106
rust/kcl-lib/tests/add_arrays/ast.snap
Normal file
106
rust/kcl-lib/tests/add_arrays/ast.snap
Normal file
@ -0,0 +1,106 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Result of parsing add_arrays.kcl
|
||||
---
|
||||
{
|
||||
"Ok": {
|
||||
"body": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "answer",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"left": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "0",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 0.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "1",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 1.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
"moduleId": 0,
|
||||
"operator": "+",
|
||||
"right": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "2",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 2.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
"start": 0,
|
||||
"type": "BinaryExpression",
|
||||
"type": "BinaryExpression"
|
||||
},
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 0,
|
||||
"kind": "const",
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0
|
||||
}
|
||||
}
|
12
rust/kcl-lib/tests/add_arrays/execution_error.snap
Normal file
12
rust/kcl-lib/tests/add_arrays/execution_error.snap
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Error from executing add_arrays.kcl
|
||||
---
|
||||
KCL Semantic error
|
||||
|
||||
× semantic: Expected a number, but found an array of `number`, `number`
|
||||
╭────
|
||||
1 │ answer = [0, 1] + [2]
|
||||
· ───┬──
|
||||
· ╰── tests/add_arrays/input.kcl
|
||||
╰────
|
1
rust/kcl-lib/tests/add_arrays/input.kcl
Normal file
1
rust/kcl-lib/tests/add_arrays/input.kcl
Normal file
@ -0,0 +1 @@
|
||||
answer = [0, 1] + [2]
|
96
rust/kcl-lib/tests/add_arrays/ops.snap
Normal file
96
rust/kcl-lib/tests/add_arrays/ops.snap
Normal file
@ -0,0 +1,96 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Operations executed add_arrays.kcl
|
||||
---
|
||||
{
|
||||
"rust/kcl-lib/tests/add_arrays/input.kcl": [],
|
||||
"std::appearance": [],
|
||||
"std::array": [],
|
||||
"std::math": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "PI",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 3.141592653589793,
|
||||
"ty": {
|
||||
"type": "Unknown"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "E",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 2.718281828459045,
|
||||
"ty": {
|
||||
"type": "Known",
|
||||
"type": "Count"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "TAU",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 6.283185307179586,
|
||||
"ty": {
|
||||
"type": "Known",
|
||||
"type": "Count"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::prelude": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "START",
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "start"
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "END",
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "end"
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::sketch": [],
|
||||
"std::solid": [],
|
||||
"std::sweep": [],
|
||||
"std::transform": [],
|
||||
"std::turns": [],
|
||||
"std::types": [],
|
||||
"std::units": []
|
||||
}
|
5
rust/kcl-lib/tests/add_arrays/unparsed.snap
Normal file
5
rust/kcl-lib/tests/add_arrays/unparsed.snap
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Result of unparsing add_arrays.kcl
|
||||
---
|
||||
answer = [0, 1] + [2]
|
60
rust/kcl-lib/tests/inputs/planestuff.kcl
Normal file
60
rust/kcl-lib/tests/inputs/planestuff.kcl
Normal file
@ -0,0 +1,60 @@
|
||||
// There are 3 ways to define a plane in KCL, according to https://zoo.dev/docs/kcl-std/types/std-types-Plane
|
||||
// - A default plane
|
||||
// - Modifying a default plane e.g. via offsetPlane
|
||||
// - Defining your own struct
|
||||
// This file tests they all work equivalently.
|
||||
|
||||
// Define a plane using struct representation.
|
||||
myPlane = {
|
||||
origin = { x = 0, y = 0, z = 0 },
|
||||
xAxis = { x = 1, y = 0, z = 0 },
|
||||
yAxis = { x = 0, y = 1, z = 0 },
|
||||
}
|
||||
|
||||
// Prove we can get its axes and origin.
|
||||
ax = myPlane.xAxis
|
||||
assert(ax[0], isEqualTo = 1)
|
||||
assert(ax[1], isEqualTo = 0)
|
||||
assert(ax[2], isEqualTo = 0)
|
||||
ay = myPlane.yAxis
|
||||
assert(ay[0], isEqualTo = 0)
|
||||
assert(ay[1], isEqualTo = 1)
|
||||
assert(ay[2], isEqualTo = 0)
|
||||
aorigin = myPlane.origin
|
||||
assert(aorigin[0], isEqualTo = 0)
|
||||
assert(aorigin[1], isEqualTo = 0)
|
||||
assert(aorigin[2], isEqualTo = 0)
|
||||
|
||||
// Define a plane using standard planes.
|
||||
myOtherPlane = XY
|
||||
|
||||
// Prove we can get its axes and origin.
|
||||
axOther = myOtherPlane.xAxis
|
||||
assert(axOther[0], isEqualTo = 1)
|
||||
assert(axOther[1], isEqualTo = 0)
|
||||
assert(axOther[2], isEqualTo = 0)
|
||||
ayOther = myOtherPlane.yAxis
|
||||
assert(ayOther[0], isEqualTo = 0)
|
||||
assert(ayOther[1], isEqualTo = 1)
|
||||
assert(ayOther[2], isEqualTo = 0)
|
||||
aoriginOther = myOtherPlane.origin
|
||||
assert(aoriginOther[0], isEqualTo = 0)
|
||||
assert(aoriginOther[1], isEqualTo = 0)
|
||||
assert(aoriginOther[2], isEqualTo = 0)
|
||||
|
||||
// Define a plane using a plane-modifying function like offsetPlane.
|
||||
myAlternatePlane = offsetPlane(XY, offset = 0)
|
||||
|
||||
// Prove we can get its axes and origin.
|
||||
axAlternate = myAlternatePlane.xAxis
|
||||
assert(axAlternate[0], isEqualTo = 1)
|
||||
assert(axAlternate[1], isEqualTo = 0)
|
||||
assert(axAlternate[2], isEqualTo = 0)
|
||||
ayAlternate = myAlternatePlane.yAxis
|
||||
assert(ayAlternate[0], isEqualTo = 0)
|
||||
assert(ayAlternate[1], isEqualTo = 1)
|
||||
assert(ayAlternate[2], isEqualTo = 0)
|
||||
aoriginAlternate = myAlternatePlane.origin
|
||||
assert(aoriginAlternate[0], isEqualTo = 0)
|
||||
assert(aoriginAlternate[1], isEqualTo = 0)
|
||||
assert(aoriginAlternate[2], isEqualTo = 0)
|
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
@ -0,0 +1,206 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Artifact commands property_access_not_found_on_solid.kcl
|
||||
---
|
||||
{
|
||||
"rust/kcl-lib/tests/property_access_not_found_on_solid/input.kcl": [
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "make_plane",
|
||||
"origin": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"x_axis": {
|
||||
"x": 1.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"y_axis": {
|
||||
"x": 0.0,
|
||||
"y": 1.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"size": 60.0,
|
||||
"clobber": false,
|
||||
"hide": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "enable_sketch_mode",
|
||||
"entity_id": "[uuid]",
|
||||
"ortho": false,
|
||||
"animated": false,
|
||||
"adjust_camera": false,
|
||||
"planar_normal": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 1.0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "start_path"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "move_path_pen",
|
||||
"path": "[uuid]",
|
||||
"to": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "sketch_mode_disable"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": 10.0,
|
||||
"y": 10.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": -20.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": 10.0,
|
||||
"y": -10.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "close_path",
|
||||
"path_id": "[uuid]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "enable_sketch_mode",
|
||||
"entity_id": "[uuid]",
|
||||
"ortho": false,
|
||||
"animated": false,
|
||||
"adjust_camera": false,
|
||||
"planar_normal": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 1.0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extrude",
|
||||
"target": "[uuid]",
|
||||
"distance": 5.0,
|
||||
"faces": null,
|
||||
"opposite": "None"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "sketch_mode_disable"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "object_bring_to_front",
|
||||
"object_id": "[uuid]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "solid3d_get_extrusion_face_info",
|
||||
"object_id": "[uuid]",
|
||||
"edge_id": "[uuid]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "solid3d_get_adjacency_info",
|
||||
"object_id": "[uuid]",
|
||||
"edge_id": "[uuid]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"std::appearance": [],
|
||||
"std::array": [],
|
||||
"std::math": [],
|
||||
"std::prelude": [],
|
||||
"std::sketch": [],
|
||||
"std::solid": [],
|
||||
"std::sweep": [],
|
||||
"std::transform": [],
|
||||
"std::turns": [],
|
||||
"std::types": [],
|
||||
"std::units": []
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Artifact graph flowchart property_access_not_found_on_solid.kcl
|
||||
extension: md
|
||||
snapshot_kind: binary
|
||||
---
|
@ -0,0 +1,78 @@
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph path2 [Path]
|
||||
2["Path<br>[52, 77, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, FunctionExpressionBody, FunctionExpressionBodyItem { index: 0 }, ReturnStatementArg, PipeBodyItem { index: 1 }]
|
||||
3["Segment<br>[85, 119, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, FunctionExpressionBody, FunctionExpressionBodyItem { index: 0 }, ReturnStatementArg, PipeBodyItem { index: 2 }]
|
||||
4["Segment<br>[127, 147, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, FunctionExpressionBody, FunctionExpressionBodyItem { index: 0 }, ReturnStatementArg, PipeBodyItem { index: 3 }]
|
||||
5["Segment<br>[155, 176, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, FunctionExpressionBody, FunctionExpressionBodyItem { index: 0 }, ReturnStatementArg, PipeBodyItem { index: 4 }]
|
||||
6["Segment<br>[184, 191, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, FunctionExpressionBody, FunctionExpressionBodyItem { index: 0 }, ReturnStatementArg, PipeBodyItem { index: 5 }]
|
||||
7[Solid2d]
|
||||
end
|
||||
1["Plane<br>[27, 44, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, FunctionExpressionBody, FunctionExpressionBodyItem { index: 0 }, ReturnStatementArg, PipeBodyItem { index: 0 }]
|
||||
8["Sweep Extrusion<br>[199, 235, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, FunctionExpressionBody, FunctionExpressionBodyItem { index: 0 }, ReturnStatementArg, PipeBodyItem { index: 6 }]
|
||||
9[Wall]
|
||||
%% face_code_ref=Missing NodePath
|
||||
10[Wall]
|
||||
%% face_code_ref=Missing NodePath
|
||||
11[Wall]
|
||||
%% face_code_ref=Missing NodePath
|
||||
12["Cap Start"]
|
||||
%% face_code_ref=Missing NodePath
|
||||
13["Cap End"]
|
||||
%% face_code_ref=Missing NodePath
|
||||
14["SweepEdge Opposite"]
|
||||
15["SweepEdge Adjacent"]
|
||||
16["SweepEdge Opposite"]
|
||||
17["SweepEdge Adjacent"]
|
||||
18["SweepEdge Opposite"]
|
||||
19["SweepEdge Adjacent"]
|
||||
1 --- 2
|
||||
2 --- 3
|
||||
2 --- 4
|
||||
2 --- 5
|
||||
2 --- 6
|
||||
2 --- 7
|
||||
2 ---- 8
|
||||
3 --- 9
|
||||
3 x--> 12
|
||||
3 --- 14
|
||||
3 --- 15
|
||||
4 --- 10
|
||||
4 x--> 12
|
||||
4 --- 16
|
||||
4 --- 17
|
||||
5 --- 11
|
||||
5 x--> 12
|
||||
5 --- 18
|
||||
5 --- 19
|
||||
8 --- 9
|
||||
8 --- 10
|
||||
8 --- 11
|
||||
8 --- 12
|
||||
8 --- 13
|
||||
8 --- 14
|
||||
8 --- 15
|
||||
8 --- 16
|
||||
8 --- 17
|
||||
8 --- 18
|
||||
8 --- 19
|
||||
9 --- 14
|
||||
9 --- 15
|
||||
19 <--x 9
|
||||
15 <--x 10
|
||||
10 --- 16
|
||||
10 --- 17
|
||||
17 <--x 11
|
||||
11 --- 18
|
||||
11 --- 19
|
||||
14 <--x 13
|
||||
16 <--x 13
|
||||
18 <--x 13
|
||||
```
|
780
rust/kcl-lib/tests/property_access_not_found_on_solid/ast.snap
Normal file
780
rust/kcl-lib/tests/property_access_not_found_on_solid/ast.snap
Normal file
@ -0,0 +1,780 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Result of parsing property_access_not_found_on_solid.kcl
|
||||
---
|
||||
{
|
||||
"Ok": {
|
||||
"body": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "myFunction",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"body": {
|
||||
"body": [
|
||||
{
|
||||
"argument": {
|
||||
"body": [
|
||||
{
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "startSketchOn",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "XY",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "at",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "0",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 0.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "0",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 0.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "startProfile",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "end",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "10",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 10.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "10",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 10.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "tag",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "TagDeclarator",
|
||||
"type": "TagDeclarator",
|
||||
"value": "seg01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "line",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "end",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"argument": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "20",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 20.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"operator": "-",
|
||||
"start": 0,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
},
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "0",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 0.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "line",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "end",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "10",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 10.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
{
|
||||
"argument": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "10",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 10.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"operator": "-",
|
||||
"start": 0,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "line",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "close",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "length",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "5",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 5.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "tagEnd",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "TagDeclarator",
|
||||
"type": "TagDeclarator",
|
||||
"value": "end01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "extrude",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "PipeExpression",
|
||||
"type": "PipeExpression"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ReturnStatement",
|
||||
"type": "ReturnStatement"
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"params": [],
|
||||
"start": 0,
|
||||
"type": "FunctionExpression",
|
||||
"type": "FunctionExpression"
|
||||
},
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 0,
|
||||
"kind": "fn",
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
},
|
||||
{
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "myShape",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "myFunction",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 0,
|
||||
"kind": "const",
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
},
|
||||
{
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "sketch001",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "face",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"computed": false,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"object": {
|
||||
"commentStart": 0,
|
||||
"computed": false,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"object": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "myShape",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
},
|
||||
"property": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "tags",
|
||||
"start": 0,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 0,
|
||||
"type": "MemberExpression",
|
||||
"type": "MemberExpression"
|
||||
},
|
||||
"property": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "seg01",
|
||||
"start": 0,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 0,
|
||||
"type": "MemberExpression",
|
||||
"type": "MemberExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "startSketchOn",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "myShape",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
},
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 0,
|
||||
"kind": "const",
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"nonCodeMeta": {
|
||||
"nonCodeNodes": {
|
||||
"0": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "newLine"
|
||||
}
|
||||
}
|
||||
],
|
||||
"1": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "newLine"
|
||||
}
|
||||
}
|
||||
],
|
||||
"2": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "newLine"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"startNodes": []
|
||||
},
|
||||
"start": 0
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Error from executing property_access_not_found_on_solid.kcl
|
||||
---
|
||||
KCL Semantic error
|
||||
|
||||
× semantic: Property `tags` not found on a solid. You can get a solid's tags
|
||||
│ through its sketch, as in, `exampleSolid.sketch.tags`.
|
||||
╭─[13:43]
|
||||
12 │
|
||||
13 │ sketch001 = startSketchOn(myShape, face = myShape.tags.seg01)
|
||||
· ──────┬─────
|
||||
· ╰── tests/property_access_not_found_on_solid/input.kcl
|
||||
14 │
|
||||
╰────
|
@ -0,0 +1,14 @@
|
||||
fn myFunction() {
|
||||
return startSketchOn(XY)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(end = [10, 10], tag = $seg01)
|
||||
|> line(end = [-20, 0])
|
||||
|> line(end = [10, -10])
|
||||
|> close()
|
||||
|> extrude(length = 5, tagEnd = $end01)
|
||||
}
|
||||
|
||||
myShape = myFunction()
|
||||
|
||||
sketch001 = startSketchOn(myShape, face = myShape.tags.seg01)
|
||||
|
233
rust/kcl-lib/tests/property_access_not_found_on_solid/ops.snap
Normal file
233
rust/kcl-lib/tests/property_access_not_found_on_solid/ops.snap
Normal file
@ -0,0 +1,233 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Operations executed property_access_not_found_on_solid.kcl
|
||||
---
|
||||
{
|
||||
"rust/kcl-lib/tests/property_access_not_found_on_solid/input.kcl": [
|
||||
{
|
||||
"type": "GroupBegin",
|
||||
"group": {
|
||||
"type": "FunctionCall",
|
||||
"name": "myFunction",
|
||||
"functionSourceRange": [],
|
||||
"unlabeledArg": null,
|
||||
"labeledArgs": {}
|
||||
},
|
||||
"nodePath": {
|
||||
"steps": [
|
||||
{
|
||||
"type": "ProgramBodyItem",
|
||||
"index": 1
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationDeclaration"
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationInit"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "StdLibCall",
|
||||
"name": "startSketchOn",
|
||||
"unlabeledArg": {
|
||||
"value": {
|
||||
"type": "Plane",
|
||||
"artifact_id": "[uuid]"
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
"labeledArgs": {},
|
||||
"nodePath": {
|
||||
"steps": [
|
||||
{
|
||||
"type": "ProgramBodyItem",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationDeclaration"
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationInit"
|
||||
},
|
||||
{
|
||||
"type": "FunctionExpressionBody"
|
||||
},
|
||||
{
|
||||
"type": "FunctionExpressionBodyItem",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"type": "ReturnStatementArg"
|
||||
},
|
||||
{
|
||||
"type": "PipeBodyItem",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "StdLibCall",
|
||||
"name": "extrude",
|
||||
"unlabeledArg": {
|
||||
"value": {
|
||||
"type": "Sketch",
|
||||
"value": {
|
||||
"artifactId": "[uuid]"
|
||||
}
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
"labeledArgs": {
|
||||
"length": {
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 5.0,
|
||||
"ty": {
|
||||
"type": "Default",
|
||||
"len": {
|
||||
"type": "Mm"
|
||||
},
|
||||
"angle": {
|
||||
"type": "Degrees"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
"tagEnd": {
|
||||
"value": {
|
||||
"type": "TagDeclarator",
|
||||
"name": "end01"
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
},
|
||||
"nodePath": {
|
||||
"steps": [
|
||||
{
|
||||
"type": "ProgramBodyItem",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationDeclaration"
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationInit"
|
||||
},
|
||||
{
|
||||
"type": "FunctionExpressionBody"
|
||||
},
|
||||
{
|
||||
"type": "FunctionExpressionBodyItem",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"type": "ReturnStatementArg"
|
||||
},
|
||||
{
|
||||
"type": "PipeBodyItem",
|
||||
"index": 6
|
||||
}
|
||||
]
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "GroupEnd"
|
||||
}
|
||||
],
|
||||
"std::appearance": [],
|
||||
"std::array": [],
|
||||
"std::math": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "PI",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 3.141592653589793,
|
||||
"ty": {
|
||||
"type": "Unknown"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "E",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 2.718281828459045,
|
||||
"ty": {
|
||||
"type": "Known",
|
||||
"type": "Count"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "TAU",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 6.283185307179586,
|
||||
"ty": {
|
||||
"type": "Known",
|
||||
"type": "Count"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::prelude": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "START",
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "start"
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "END",
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "end"
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::sketch": [],
|
||||
"std::solid": [],
|
||||
"std::sweep": [],
|
||||
"std::transform": [],
|
||||
"std::turns": [],
|
||||
"std::types": [],
|
||||
"std::units": []
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Result of unparsing property_access_not_found_on_solid.kcl
|
||||
---
|
||||
fn myFunction() {
|
||||
return startSketchOn(XY)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(end = [10, 10], tag = $seg01)
|
||||
|> line(end = [-20, 0])
|
||||
|> line(end = [10, -10])
|
||||
|> close()
|
||||
|> extrude(length = 5, tagEnd = $end01)
|
||||
}
|
||||
|
||||
myShape = myFunction()
|
||||
|
||||
sketch001 = startSketchOn(myShape, face = myShape.tags.seg01)
|
163
rust/kcl-lib/tests/rect/artifact_commands.snap
Normal file
163
rust/kcl-lib/tests/rect/artifact_commands.snap
Normal file
@ -0,0 +1,163 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Artifact commands rect.kcl
|
||||
---
|
||||
{
|
||||
"rust/kcl-lib/tests/rect/input.kcl": [
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "make_plane",
|
||||
"origin": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"x_axis": {
|
||||
"x": 1.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"y_axis": {
|
||||
"x": 0.0,
|
||||
"y": 1.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"size": 60.0,
|
||||
"clobber": false,
|
||||
"hide": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "enable_sketch_mode",
|
||||
"entity_id": "[uuid]",
|
||||
"ortho": false,
|
||||
"animated": false,
|
||||
"adjust_camera": false,
|
||||
"planar_normal": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 1.0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "start_path"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "move_path_pen",
|
||||
"path": "[uuid]",
|
||||
"to": {
|
||||
"x": -2.0,
|
||||
"y": -1.0,
|
||||
"z": 0.0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "sketch_mode_disable"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": 3.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": 0.00000000000000012246467991473532,
|
||||
"y": 2.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": -3.0,
|
||||
"y": -0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": -2.0,
|
||||
"y": -1.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "close_path",
|
||||
"path_id": "[uuid]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"std::appearance": [],
|
||||
"std::array": [],
|
||||
"std::math": [],
|
||||
"std::prelude": [],
|
||||
"std::sketch": [],
|
||||
"std::solid": [],
|
||||
"std::sweep": [],
|
||||
"std::transform": [],
|
||||
"std::turns": [],
|
||||
"std::types": [],
|
||||
"std::units": []
|
||||
}
|
6
rust/kcl-lib/tests/rect/artifact_graph_flowchart.snap
Normal file
6
rust/kcl-lib/tests/rect/artifact_graph_flowchart.snap
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Artifact graph flowchart rect.kcl
|
||||
extension: md
|
||||
snapshot_kind: binary
|
||||
---
|
27
rust/kcl-lib/tests/rect/artifact_graph_flowchart.snap.md
Normal file
27
rust/kcl-lib/tests/rect/artifact_graph_flowchart.snap.md
Normal file
@ -0,0 +1,27 @@
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph path2 [Path]
|
||||
2["Path<br>[27, 54, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 1 }]
|
||||
3["Segment<br>[60, 103, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 2 }]
|
||||
4["Segment<br>[109, 155, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 3 }]
|
||||
5["Segment<br>[161, 211, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 4 }]
|
||||
6["Segment<br>[217, 273, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 5 }]
|
||||
7["Segment<br>[279, 286, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 6 }]
|
||||
8[Solid2d]
|
||||
end
|
||||
1["Plane<br>[4, 21, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 0 }]
|
||||
1 --- 2
|
||||
2 --- 3
|
||||
2 --- 4
|
||||
2 --- 5
|
||||
2 --- 6
|
||||
2 --- 7
|
||||
2 --- 8
|
||||
```
|
701
rust/kcl-lib/tests/rect/ast.snap
Normal file
701
rust/kcl-lib/tests/rect/ast.snap
Normal file
@ -0,0 +1,701 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Result of parsing rect.kcl
|
||||
---
|
||||
{
|
||||
"Ok": {
|
||||
"body": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "x",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"body": [
|
||||
{
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "startSketchOn",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "XY",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "at",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"argument": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "2",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 2.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"operator": "-",
|
||||
"start": 0,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
},
|
||||
{
|
||||
"argument": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "1",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 1.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"operator": "-",
|
||||
"start": 0,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "startProfile",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "angle",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "0",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 0.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "length",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "3",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 3.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "tag",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "TagDeclarator",
|
||||
"type": "TagDeclarator",
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "angledLine",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "angle",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"left": {
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "segAng",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "a",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
},
|
||||
"moduleId": 0,
|
||||
"operator": "+",
|
||||
"right": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "90",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 90.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"start": 0,
|
||||
"type": "BinaryExpression",
|
||||
"type": "BinaryExpression"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "length",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "2",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 2.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "angledLine",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "angle",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "segAng",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "a",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "length",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"argument": {
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "segLen",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "a",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"operator": "-",
|
||||
"start": 0,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "angledLine",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "endAbsolute",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "profileStartX",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
},
|
||||
{
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "profileStartY",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "line",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "close",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "PipeExpression",
|
||||
"type": "PipeExpression"
|
||||
},
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 0,
|
||||
"kind": "const",
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0
|
||||
}
|
||||
}
|
7
rust/kcl-lib/tests/rect/input.kcl
Normal file
7
rust/kcl-lib/tests/rect/input.kcl
Normal file
@ -0,0 +1,7 @@
|
||||
x = startSketchOn(XY)
|
||||
|> startProfile(at = [-2, -1])
|
||||
|> angledLine(angle = 0, length = 3, tag = $a)
|
||||
|> angledLine(angle = segAng(a) + 90, length = 2)
|
||||
|> angledLine(angle = segAng(a), length = -segLen(a))
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
128
rust/kcl-lib/tests/rect/ops.snap
Normal file
128
rust/kcl-lib/tests/rect/ops.snap
Normal file
@ -0,0 +1,128 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Operations executed rect.kcl
|
||||
---
|
||||
{
|
||||
"rust/kcl-lib/tests/rect/input.kcl": [
|
||||
{
|
||||
"type": "StdLibCall",
|
||||
"name": "startSketchOn",
|
||||
"unlabeledArg": {
|
||||
"value": {
|
||||
"type": "Plane",
|
||||
"artifact_id": "[uuid]"
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
"labeledArgs": {},
|
||||
"nodePath": {
|
||||
"steps": [
|
||||
{
|
||||
"type": "ProgramBodyItem",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationDeclaration"
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationInit"
|
||||
},
|
||||
{
|
||||
"type": "PipeBodyItem",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::appearance": [],
|
||||
"std::array": [],
|
||||
"std::math": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "PI",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 3.141592653589793,
|
||||
"ty": {
|
||||
"type": "Unknown"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "E",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 2.718281828459045,
|
||||
"ty": {
|
||||
"type": "Known",
|
||||
"type": "Count"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "TAU",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 6.283185307179586,
|
||||
"ty": {
|
||||
"type": "Known",
|
||||
"type": "Count"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::prelude": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "START",
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "start"
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "END",
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "end"
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::sketch": [],
|
||||
"std::solid": [],
|
||||
"std::sweep": [],
|
||||
"std::transform": [],
|
||||
"std::turns": [],
|
||||
"std::types": [],
|
||||
"std::units": []
|
||||
}
|
181
rust/kcl-lib/tests/rect/program_memory.snap
Normal file
181
rust/kcl-lib/tests/rect/program_memory.snap
Normal file
@ -0,0 +1,181 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Variables in memory after executing rect.kcl
|
||||
---
|
||||
{
|
||||
"a": {
|
||||
"type": "TagIdentifier",
|
||||
"type": "TagIdentifier",
|
||||
"value": "a"
|
||||
},
|
||||
"x": {
|
||||
"type": "Sketch",
|
||||
"value": {
|
||||
"type": "Sketch",
|
||||
"id": "[uuid]",
|
||||
"paths": [
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"tag": {
|
||||
"commentStart": 100,
|
||||
"end": 102,
|
||||
"moduleId": 0,
|
||||
"start": 100,
|
||||
"type": "TagDeclarator",
|
||||
"value": "a"
|
||||
},
|
||||
"to": [
|
||||
1.0,
|
||||
-1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
1.0,
|
||||
-1.0
|
||||
],
|
||||
"tag": null,
|
||||
"to": [
|
||||
1.0000000000000002,
|
||||
1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
1.0000000000000002,
|
||||
1.0
|
||||
],
|
||||
"tag": null,
|
||||
"to": [
|
||||
-1.9999999999999998,
|
||||
1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
-1.9999999999999998,
|
||||
1.0
|
||||
],
|
||||
"tag": null,
|
||||
"to": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"tag": null,
|
||||
"to": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
}
|
||||
],
|
||||
"on": {
|
||||
"artifactId": "[uuid]",
|
||||
"id": "[uuid]",
|
||||
"origin": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
"type": "plane",
|
||||
"value": "XY",
|
||||
"xAxis": {
|
||||
"x": 1.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"units": {
|
||||
"type": "Unknown"
|
||||
}
|
||||
},
|
||||
"yAxis": {
|
||||
"x": 0.0,
|
||||
"y": 1.0,
|
||||
"z": 0.0,
|
||||
"units": {
|
||||
"type": "Unknown"
|
||||
}
|
||||
}
|
||||
},
|
||||
"start": {
|
||||
"from": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"to": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
},
|
||||
"tag": null,
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
}
|
||||
},
|
||||
"tags": {
|
||||
"a": {
|
||||
"type": "TagIdentifier",
|
||||
"value": "a"
|
||||
}
|
||||
},
|
||||
"artifactId": "[uuid]",
|
||||
"originalId": "[uuid]",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
rust/kcl-lib/tests/rect/rendered_model.png
Normal file
BIN
rust/kcl-lib/tests/rect/rendered_model.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
11
rust/kcl-lib/tests/rect/unparsed.snap
Normal file
11
rust/kcl-lib/tests/rect/unparsed.snap
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Result of unparsing rect.kcl
|
||||
---
|
||||
x = startSketchOn(XY)
|
||||
|> startProfile(at = [-2, -1])
|
||||
|> angledLine(angle = 0, length = 3, tag = $a)
|
||||
|> angledLine(angle = segAng(a) + 90, length = 2)
|
||||
|> angledLine(angle = segAng(a), length = -segLen(a))
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
163
rust/kcl-lib/tests/rect_helper/artifact_commands.snap
Normal file
163
rust/kcl-lib/tests/rect_helper/artifact_commands.snap
Normal file
@ -0,0 +1,163 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Artifact commands rect_helper.kcl
|
||||
---
|
||||
{
|
||||
"rust/kcl-lib/tests/rect_helper/input.kcl": [
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "make_plane",
|
||||
"origin": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"x_axis": {
|
||||
"x": 1.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"y_axis": {
|
||||
"x": 0.0,
|
||||
"y": 1.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"size": 60.0,
|
||||
"clobber": false,
|
||||
"hide": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "enable_sketch_mode",
|
||||
"entity_id": "[uuid]",
|
||||
"ortho": false,
|
||||
"animated": false,
|
||||
"adjust_camera": false,
|
||||
"planar_normal": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 1.0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "start_path"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "move_path_pen",
|
||||
"path": "[uuid]",
|
||||
"to": {
|
||||
"x": -2.0,
|
||||
"y": -1.0,
|
||||
"z": 0.0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "sketch_mode_disable"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": 3.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": 0.0,
|
||||
"y": 2.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": -3.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": 0.0,
|
||||
"y": -2.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "close_path",
|
||||
"path_id": "[uuid]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"std::appearance": [],
|
||||
"std::array": [],
|
||||
"std::math": [],
|
||||
"std::prelude": [],
|
||||
"std::sketch": [],
|
||||
"std::solid": [],
|
||||
"std::sweep": [],
|
||||
"std::transform": [],
|
||||
"std::turns": [],
|
||||
"std::types": [],
|
||||
"std::units": []
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Artifact graph flowchart rect_helper.kcl
|
||||
extension: md
|
||||
snapshot_kind: binary
|
||||
---
|
@ -0,0 +1,24 @@
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph path2 [Path]
|
||||
2["Path<br>[25, 76, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 1 }]
|
||||
3["Segment<br>[25, 76, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 1 }]
|
||||
4["Segment<br>[25, 76, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 1 }]
|
||||
5["Segment<br>[25, 76, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 1 }]
|
||||
6["Segment<br>[25, 76, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 1 }]
|
||||
7[Solid2d]
|
||||
end
|
||||
1["Plane<br>[4, 21, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 0 }]
|
||||
1 --- 2
|
||||
2 --- 3
|
||||
2 --- 4
|
||||
2 --- 5
|
||||
2 --- 6
|
||||
2 --- 7
|
||||
```
|
233
rust/kcl-lib/tests/rect_helper/ast.snap
Normal file
233
rust/kcl-lib/tests/rect_helper/ast.snap
Normal file
@ -0,0 +1,233 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Result of parsing rect_helper.kcl
|
||||
---
|
||||
{
|
||||
"Ok": {
|
||||
"body": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "x",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"body": [
|
||||
{
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "startSketchOn",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "XY",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "width",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "3",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 3.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "height",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "2",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 2.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "corner",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"argument": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "2",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 2.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"operator": "-",
|
||||
"start": 0,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
},
|
||||
{
|
||||
"argument": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "1",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 1.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"operator": "-",
|
||||
"start": 0,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "rectangle",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "PipeExpression",
|
||||
"type": "PipeExpression"
|
||||
},
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 0,
|
||||
"kind": "const",
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0
|
||||
}
|
||||
}
|
2
rust/kcl-lib/tests/rect_helper/input.kcl
Normal file
2
rust/kcl-lib/tests/rect_helper/input.kcl
Normal file
@ -0,0 +1,2 @@
|
||||
x = startSketchOn(XY)
|
||||
|> rectangle(width = 3, height = 2, corner = [-2, -1])
|
128
rust/kcl-lib/tests/rect_helper/ops.snap
Normal file
128
rust/kcl-lib/tests/rect_helper/ops.snap
Normal file
@ -0,0 +1,128 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Operations executed rect_helper.kcl
|
||||
---
|
||||
{
|
||||
"rust/kcl-lib/tests/rect_helper/input.kcl": [
|
||||
{
|
||||
"type": "StdLibCall",
|
||||
"name": "startSketchOn",
|
||||
"unlabeledArg": {
|
||||
"value": {
|
||||
"type": "Plane",
|
||||
"artifact_id": "[uuid]"
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
"labeledArgs": {},
|
||||
"nodePath": {
|
||||
"steps": [
|
||||
{
|
||||
"type": "ProgramBodyItem",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationDeclaration"
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationInit"
|
||||
},
|
||||
{
|
||||
"type": "PipeBodyItem",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::appearance": [],
|
||||
"std::array": [],
|
||||
"std::math": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "PI",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 3.141592653589793,
|
||||
"ty": {
|
||||
"type": "Unknown"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "E",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 2.718281828459045,
|
||||
"ty": {
|
||||
"type": "Known",
|
||||
"type": "Count"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "TAU",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 6.283185307179586,
|
||||
"ty": {
|
||||
"type": "Known",
|
||||
"type": "Count"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::prelude": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "START",
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "start"
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "END",
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "end"
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::sketch": [],
|
||||
"std::solid": [],
|
||||
"std::sweep": [],
|
||||
"std::transform": [],
|
||||
"std::turns": [],
|
||||
"std::types": [],
|
||||
"std::units": []
|
||||
}
|
144
rust/kcl-lib/tests/rect_helper/program_memory.snap
Normal file
144
rust/kcl-lib/tests/rect_helper/program_memory.snap
Normal file
@ -0,0 +1,144 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Variables in memory after executing rect_helper.kcl
|
||||
---
|
||||
{
|
||||
"x": {
|
||||
"type": "Sketch",
|
||||
"value": {
|
||||
"type": "Sketch",
|
||||
"id": "[uuid]",
|
||||
"paths": [
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"tag": null,
|
||||
"to": [
|
||||
1.0,
|
||||
-1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
1.0,
|
||||
-1.0
|
||||
],
|
||||
"tag": null,
|
||||
"to": [
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"tag": null,
|
||||
"to": [
|
||||
-2.0,
|
||||
1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
-2.0,
|
||||
1.0
|
||||
],
|
||||
"tag": null,
|
||||
"to": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
}
|
||||
],
|
||||
"on": {
|
||||
"artifactId": "[uuid]",
|
||||
"id": "[uuid]",
|
||||
"origin": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
"type": "plane",
|
||||
"value": "XY",
|
||||
"xAxis": {
|
||||
"x": 1.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"units": {
|
||||
"type": "Unknown"
|
||||
}
|
||||
},
|
||||
"yAxis": {
|
||||
"x": 0.0,
|
||||
"y": 1.0,
|
||||
"z": 0.0,
|
||||
"units": {
|
||||
"type": "Unknown"
|
||||
}
|
||||
}
|
||||
},
|
||||
"start": {
|
||||
"from": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"to": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
},
|
||||
"tag": null,
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
}
|
||||
},
|
||||
"artifactId": "[uuid]",
|
||||
"originalId": "[uuid]",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
rust/kcl-lib/tests/rect_helper/rendered_model.png
Normal file
BIN
rust/kcl-lib/tests/rect_helper/rendered_model.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
6
rust/kcl-lib/tests/rect_helper/unparsed.snap
Normal file
6
rust/kcl-lib/tests/rect_helper/unparsed.snap
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Result of unparsing rect_helper.kcl
|
||||
---
|
||||
x = startSketchOn(XY)
|
||||
|> rectangle(width = 3, height = 2, corner = [-2, -1])
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "kcl-python-bindings"
|
||||
version = "0.3.83"
|
||||
version = "0.3.84"
|
||||
edition = "2021"
|
||||
repository = "https://github.com/kittycad/modeling-app"
|
||||
exclude = ["tests/*", "files/*", "venv/*"]
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-test-server"
|
||||
description = "A test server for KCL"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-to-core"
|
||||
description = "Utility methods to convert kcl to engine core executable tests"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "kcl-wasm-lib"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
edition = "2021"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
rust-version = "1.83"
|
||||
|
@ -4,6 +4,11 @@
|
||||
|
||||
URL STATUS
|
||||
000 https://${BASE_URL}
|
||||
405 https://api.dev.zoo.dev/oauth2/token/revoke
|
||||
401 https://api.dev.zoo.dev/users
|
||||
401 https://dev.zoo.dev
|
||||
401 https://dev.zoo.dev/docs
|
||||
401 https://dev.zoo.dev/docs/kcl-samples/car-wheel-assembly
|
||||
301 https://discord.gg/JQEpHR7Nt2
|
||||
404 https://github.com/KittyCAD/engine/issues/3528
|
||||
404 https://github.com/KittyCAD/modeling-app/commit/${ref}
|
||||
@ -17,5 +22,4 @@ URL STATUS
|
||||
302 https://stackoverflow.com/a/58436959/22753272
|
||||
303 https://text-to-cad.zoo.dev/dashboard
|
||||
307 https://zoo.dev/
|
||||
308 https://zoo.dev/docs/api/ml/generate-a-cad-model-from-text
|
||||
308 https://zoo.dev/docs/kcl
|
||||
|
@ -53,7 +53,6 @@ import {
|
||||
WASM_INIT_FAILED_TOAST_ID,
|
||||
} from '@src/lib/constants'
|
||||
import { isPlaywright } from '@src/lib/isPlaywright'
|
||||
import { VITE_KC_SITE_BASE_URL } from '@src/env'
|
||||
import { useNetworkHealthStatus } from '@src/components/NetworkHealthIndicator'
|
||||
import { useNetworkMachineStatus } from '@src/components/NetworkMachineIndicator'
|
||||
import {
|
||||
@ -65,6 +64,7 @@ import { useModelingContext } from '@src/hooks/useModelingContext'
|
||||
import { xStateValueToString } from '@src/lib/xStateValueToString'
|
||||
import { getSelectionTypeDisplayText } from '@src/lib/selections'
|
||||
import type { StatusBarItemType } from '@src/components/StatusBar/statusBarTypes'
|
||||
import { withSiteBaseURL } from '@src/lib/withBaseURL'
|
||||
|
||||
// CYCLIC REF
|
||||
sceneInfra.camControls.engineStreamActor = engineStreamActor
|
||||
@ -189,7 +189,8 @@ export function App() {
|
||||
() =>
|
||||
DownloadAppToast({
|
||||
onAccept: () => {
|
||||
openWindow(`${VITE_KC_SITE_BASE_URL}/${APP_DOWNLOAD_PATH}`)
|
||||
const url = withSiteBaseURL(`/${APP_DOWNLOAD_PATH}`)
|
||||
openWindow(url)
|
||||
.then(() => {
|
||||
toast.dismiss(DOWNLOAD_APP_TOAST_ID)
|
||||
})
|
||||
|
@ -5,8 +5,8 @@ import {
|
||||
BillingRemaining,
|
||||
BillingRemainingMode,
|
||||
} from '@src/components/BillingRemaining'
|
||||
|
||||
import { type BillingActor } from '@src/machines/billingMachine'
|
||||
import { withSiteBaseURL } from '@src/lib/withBaseURL'
|
||||
|
||||
export const BillingDialog = (props: { billingActor: BillingActor }) => {
|
||||
const billingContext = useSelector(
|
||||
@ -42,7 +42,7 @@ export const BillingDialog = (props: { billingActor: BillingActor }) => {
|
||||
{!hasUnlimited && (
|
||||
<a
|
||||
className="bg-ml-black text-ml-white rounded-lg text-center p-1 cursor-pointer"
|
||||
href="https://zoo.dev/design-studio-pricing"
|
||||
href={withSiteBaseURL('/design-studio-pricing')}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
data-testid="billing-upgrade-button"
|
||||
|
@ -15,6 +15,7 @@ import {
|
||||
import { onboardingStartPath } from '@src/lib/onboardingPaths'
|
||||
import { reportRejection } from '@src/lib/trap'
|
||||
import { isDesktop } from '@src/lib/isDesktop'
|
||||
import { withSiteBaseURL } from '@src/lib/withBaseURL'
|
||||
|
||||
const HelpMenuDivider = () => (
|
||||
<div className="h-[1px] bg-chalkboard-110 dark:bg-chalkboard-80" />
|
||||
@ -89,7 +90,7 @@ export function HelpMenu() {
|
||||
<HelpMenuDivider />
|
||||
<HelpMenuItem
|
||||
as="a"
|
||||
href="https://zoo.dev/docs/kcl-samples"
|
||||
href={withSiteBaseURL('/docs/kcl-samples')}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
@ -97,7 +98,7 @@ export function HelpMenu() {
|
||||
</HelpMenuItem>
|
||||
<HelpMenuItem
|
||||
as="a"
|
||||
href="https://zoo.dev/docs/kcl-lang"
|
||||
href={withSiteBaseURL('/docs/kcl-lang')}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
LanguageServerClient,
|
||||
LspWorkerEventType,
|
||||
} from '@kittycad/codemirror-lsp-client'
|
||||
import { TEST, VITE_KC_API_BASE_URL } from '@src/env'
|
||||
import env from '@src/env'
|
||||
import React, { createContext, useContext, useMemo, useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import type * as LSP from 'vscode-languageserver-protocol'
|
||||
@ -28,6 +28,7 @@ import type { FileEntry } from '@src/lib/project'
|
||||
import { codeManager } from '@src/lib/singletons'
|
||||
import { err } from '@src/lib/trap'
|
||||
import { useToken } from '@src/lib/singletons'
|
||||
import { withAPIBaseURL } from '@src/lib/withBaseURL'
|
||||
|
||||
function getWorkspaceFolders(): LSP.WorkspaceFolder[] {
|
||||
return []
|
||||
@ -77,7 +78,7 @@ export const LspProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
// But the server happens async so we break this into two parts.
|
||||
// Below is the client and server promise.
|
||||
const { lspClient: kclLspClient } = useMemo(() => {
|
||||
if (!token || token === '' || TEST) {
|
||||
if (!token || token === '' || env().TEST) {
|
||||
return { lspClient: null }
|
||||
}
|
||||
|
||||
@ -85,7 +86,7 @@ export const LspProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
const initEvent: KclWorkerOptions = {
|
||||
wasmUrl: wasmUrl(),
|
||||
token: token,
|
||||
apiBaseUrl: VITE_KC_API_BASE_URL,
|
||||
apiBaseUrl: withAPIBaseURL(''),
|
||||
}
|
||||
lspWorker.postMessage({
|
||||
worker: LspWorker.Kcl,
|
||||
@ -136,7 +137,7 @@ export const LspProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
// We do not want to restart the server, its just wasteful.
|
||||
const kclLSP = useMemo(() => {
|
||||
let plugin = null
|
||||
if (isKclLspReady && !TEST && kclLspClient) {
|
||||
if (isKclLspReady && !env().TEST && kclLspClient) {
|
||||
// Set up the lsp plugin.
|
||||
const lsp = kcl({
|
||||
documentUri: `file:///${PROJECT_ENTRYPOINT}`,
|
||||
@ -170,7 +171,7 @@ export const LspProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
}, [kclLspClient, isKclLspReady])
|
||||
|
||||
const { lspClient: copilotLspClient } = useMemo(() => {
|
||||
if (!token || token === '' || TEST) {
|
||||
if (!token || token === '' || env().TEST) {
|
||||
return { lspClient: null }
|
||||
}
|
||||
|
||||
@ -178,7 +179,7 @@ export const LspProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
const initEvent: CopilotWorkerOptions = {
|
||||
wasmUrl: wasmUrl(),
|
||||
token: token,
|
||||
apiBaseUrl: VITE_KC_API_BASE_URL,
|
||||
apiBaseUrl: withAPIBaseURL(''),
|
||||
}
|
||||
lspWorker.postMessage({
|
||||
worker: LspWorker.Copilot,
|
||||
@ -212,7 +213,7 @@ export const LspProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
// We do not want to restart the server, its just wasteful.
|
||||
const copilotLSP = useMemo(() => {
|
||||
let plugin = null
|
||||
if (isCopilotLspReady && !TEST && copilotLspClient) {
|
||||
if (isCopilotLspReady && !env().TEST && copilotLspClient) {
|
||||
// Set up the lsp plugin.
|
||||
const lsp = copilotPlugin({
|
||||
documentUri: `file:///${PROJECT_ENTRYPOINT}`,
|
||||
|
@ -12,6 +12,7 @@ import { reportRejection } from '@src/lib/trap'
|
||||
import { commandBarActor, settingsActor } from '@src/lib/singletons'
|
||||
|
||||
import styles from './KclEditorMenu.module.css'
|
||||
import { withSiteBaseURL } from '@src/lib/withBaseURL'
|
||||
|
||||
export const KclEditorMenu = ({ children }: PropsWithChildren) => {
|
||||
const { enable: convertToVarEnabled, handleClick: handleConvertToVarClick } =
|
||||
@ -67,7 +68,7 @@ export const KclEditorMenu = ({ children }: PropsWithChildren) => {
|
||||
<Menu.Item>
|
||||
<a
|
||||
className={styles.button}
|
||||
href="https://zoo.dev/docs/kcl-lang"
|
||||
href={withSiteBaseURL('/docs/kcl-lang')}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
onClick={openExternalBrowserIfDesktop()}
|
||||
@ -108,7 +109,7 @@ export const KclEditorMenu = ({ children }: PropsWithChildren) => {
|
||||
<Menu.Item>
|
||||
<a
|
||||
className={styles.button}
|
||||
href="https://zoo.dev/docs/kcl-samples"
|
||||
href={withSiteBaseURL('/docs/kcl-samples')}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
onClick={openExternalBrowserIfDesktop()}
|
||||
|
@ -35,7 +35,7 @@ import {
|
||||
rectangularSelection,
|
||||
} from '@codemirror/view'
|
||||
import interact from '@replit/codemirror-interact'
|
||||
import { TEST } from '@src/env'
|
||||
import env from '@src/env'
|
||||
import { useSelector } from '@xstate/react'
|
||||
import { useEffect, useMemo, useRef } from 'react'
|
||||
|
||||
@ -149,7 +149,7 @@ export const KclEditorPane = () => {
|
||||
if (copilotLSP) extensions.push(copilotLSP)
|
||||
|
||||
// These extensions have proven to mess with vitest
|
||||
if (!TEST) {
|
||||
if (!env().TEST) {
|
||||
extensions.push(
|
||||
lintGutter(),
|
||||
lineNumbers(),
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { Transition } from '@headlessui/react'
|
||||
import { VITE_KC_SITE_BASE_URL } from '@src/env'
|
||||
import { useSearchParams } from 'react-router-dom'
|
||||
import { base64ToString } from '@src/lib/base64'
|
||||
|
||||
@ -16,6 +15,7 @@ import { platform } from '@src/lib/utils'
|
||||
import { codeManager } from '@src/lib/singletons'
|
||||
import { Logo } from '@src/components/Logo'
|
||||
import { useEffect } from 'react'
|
||||
import { withSiteBaseURL } from '@src/lib/withBaseURL'
|
||||
|
||||
/**
|
||||
* This component is a handler that checks if a certain query parameter
|
||||
@ -98,7 +98,7 @@ export const OpenInDesktopAppHandler = (props: React.PropsWithChildren) => {
|
||||
>
|
||||
<Transition.Child
|
||||
as="div"
|
||||
className={`max-w-3xl py-6 px-10 flex flex-col items-center gap-12
|
||||
className={`max-w-3xl py-6 px-10 flex flex-col items-center gap-12
|
||||
mx-auto border rounded-lg shadow-lg bg-chalkboard-10 dark:bg-chalkboard-100`}
|
||||
enter="ease-out duration-300"
|
||||
enterFrom="opacity-0 scale-95"
|
||||
@ -133,7 +133,7 @@ export const OpenInDesktopAppHandler = (props: React.PropsWithChildren) => {
|
||||
buttonClasses +
|
||||
' text-sm border-transparent justify-center dark:bg-transparent'
|
||||
}
|
||||
to={`${VITE_KC_SITE_BASE_URL}/${APP_DOWNLOAD_PATH}`}
|
||||
to={withSiteBaseURL(`/${APP_DOWNLOAD_PATH}`)}
|
||||
iconEnd={{ icon: 'link', bgClassName: '!bg-transparent' }}
|
||||
>
|
||||
Download desktop app
|
||||
|
@ -12,9 +12,9 @@ import { Popover } from '@headlessui/react'
|
||||
import Tooltip from '@src/components/Tooltip'
|
||||
import { HelpMenu } from '@src/components/HelpMenu'
|
||||
import { isDesktop } from '@src/lib/isDesktop'
|
||||
import { VITE_KC_SITE_BASE_URL } from '@src/env'
|
||||
import { APP_DOWNLOAD_PATH } from '@src/lib/constants'
|
||||
import { desktopAppPitchMessage } from '@src/components/DownloadAppToast'
|
||||
import { withSiteBaseURL } from '@src/lib/withBaseURL'
|
||||
|
||||
export const defaultGlobalStatusBarItems = ({
|
||||
location,
|
||||
@ -37,7 +37,7 @@ export const defaultGlobalStatusBarItems = ({
|
||||
id: 'download-desktop-app',
|
||||
element: 'externalLink',
|
||||
label: 'Download the app',
|
||||
href: `${VITE_KC_SITE_BASE_URL}/${APP_DOWNLOAD_PATH}`,
|
||||
href: withSiteBaseURL(`/${APP_DOWNLOAD_PATH}`),
|
||||
icon: 'download',
|
||||
toolTip: {
|
||||
children: desktopAppPitchMessage,
|
||||
|
@ -13,6 +13,7 @@ import { isDesktop } from '@src/lib/isDesktop'
|
||||
import { PATHS } from '@src/lib/paths'
|
||||
import { authActor } from '@src/lib/singletons'
|
||||
import { reportRejection } from '@src/lib/trap'
|
||||
import { withSiteBaseURL } from '@src/lib/withBaseURL'
|
||||
|
||||
type User = Models['User_type']
|
||||
|
||||
@ -62,7 +63,7 @@ const UserSidebarMenu = ({ user }: { user?: User }) => {
|
||||
{
|
||||
id: 'account',
|
||||
Element: 'externalLink',
|
||||
to: 'https://zoo.dev/account',
|
||||
to: withSiteBaseURL('/account'),
|
||||
children: (
|
||||
<>
|
||||
<span className="flex-1">Manage account</span>
|
||||
|
126
src/env.test.ts
Normal file
126
src/env.test.ts
Normal file
@ -0,0 +1,126 @@
|
||||
import env from '@src/env'
|
||||
import { vi } from 'vitest'
|
||||
import { viteEnv, windowElectronProcessEnv, processEnv } from '@src/env'
|
||||
|
||||
describe('@src/env', () => {
|
||||
describe('default export', () => {
|
||||
it('should run the process.env workflow', () => {
|
||||
// vite > node.js
|
||||
const expected = {
|
||||
NODE_ENV: 'test',
|
||||
VITE_KC_API_WS_MODELING_URL:
|
||||
'wss://api.dev.zoo.dev/ws/modeling/commands',
|
||||
VITE_KITTYCAD_API_BASE_URL: 'https://api.dev.zoo.dev',
|
||||
VITE_KC_SITE_BASE_URL: 'https://dev.zoo.dev',
|
||||
VITE_KC_SITE_APP_URL: 'https://app.dev.zoo.dev',
|
||||
VITE_KC_CONNECTION_TIMEOUT_MS: '5000',
|
||||
VITE_KITTYCAD_API_TOKEN: 'redacted',
|
||||
PROD: undefined,
|
||||
TEST: 'true',
|
||||
DEV: '1',
|
||||
CI: 'true',
|
||||
}
|
||||
const actual = env()
|
||||
expect(typeof actual.VITE_KITTYCAD_API_TOKEN).toBe('string')
|
||||
//@ts-ignore I do not want this token in our logs for any reason.
|
||||
actual.VITE_KITTYCAD_API_TOKEN = 'redacted'
|
||||
//@ts-ignore need to hard code this for localhost and CI
|
||||
actual.CI = 'true'
|
||||
expect(actual).toStrictEqual(expected)
|
||||
})
|
||||
})
|
||||
describe('viteEnv', () => {
|
||||
it('should match the EnvironmentVariables key types*', () => {
|
||||
// Do not print entire object or compare, it contains a ton of ENV vars.
|
||||
// We only need to match against EnvironmentVariables
|
||||
const actual = viteEnv()
|
||||
expect(typeof actual.NODE_ENV).toBe('string')
|
||||
// Not passed in during tests?
|
||||
expect(typeof actual.VITE_KC_WS_MODELING_URL).toBe('undefined')
|
||||
expect(typeof actual.VITE_KITTYCAD_API_BASE_URL).toBe('string')
|
||||
expect(typeof actual.VITE_KC_SITE_BASE_URL).toBe('string')
|
||||
// Not passed in during tests?
|
||||
expect(typeof actual.VITE_KC_SITE_API_URL).toBe('undefined')
|
||||
expect(typeof actual.VITE_KC_CONNECTION_TIMEOUT_MS).toBe('string')
|
||||
expect(typeof actual.VITE_KITTYCAD_API_TOKEN).toBe('string')
|
||||
expect(typeof actual.PROD).toBe('boolean')
|
||||
expect(typeof actual.TEST).toBe('string')
|
||||
expect(typeof actual.DEV).toBe('boolean')
|
||||
// Don't check CI...
|
||||
})
|
||||
})
|
||||
describe('windowElectronProcessEnv', () => {
|
||||
it('should return undefined in vitest runtime', () => {
|
||||
const expected = undefined
|
||||
const actual = windowElectronProcessEnv()
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
describe('When mocking window', () => {
|
||||
it('should match the EnvironmentVariable key types*', () => {
|
||||
vi.stubGlobal('electron', {
|
||||
process: {
|
||||
env: {
|
||||
NODE_ENV: 'test',
|
||||
VITE_KC_API_WS_MODELING_URL:
|
||||
'wss://api.dev.zoo.dev/ws/modeling/commands',
|
||||
VITE_KITTYCAD_API_BASE_URL: 'https://api.dev.zoo.dev',
|
||||
VITE_KC_SITE_BASE_URL: 'https://dev.zoo.dev',
|
||||
VITE_KC_SITE_APP_URL: 'https://app.dev.zoo.dev',
|
||||
VITE_KC_CONNECTION_TIMEOUT_MS: '5000',
|
||||
VITE_KITTYCAD_API_TOKEN: 'redacted',
|
||||
PROD: undefined,
|
||||
TEST: 'true',
|
||||
DEV: '1',
|
||||
CI: undefined,
|
||||
},
|
||||
},
|
||||
})
|
||||
const expected = {
|
||||
NODE_ENV: 'test',
|
||||
VITE_KC_API_WS_MODELING_URL:
|
||||
'wss://api.dev.zoo.dev/ws/modeling/commands',
|
||||
VITE_KITTYCAD_API_BASE_URL: 'https://api.dev.zoo.dev',
|
||||
VITE_KC_SITE_BASE_URL: 'https://dev.zoo.dev',
|
||||
VITE_KC_SITE_APP_URL: 'https://app.dev.zoo.dev',
|
||||
VITE_KC_CONNECTION_TIMEOUT_MS: '5000',
|
||||
VITE_KITTYCAD_API_TOKEN: 'redacted',
|
||||
PROD: undefined,
|
||||
TEST: 'true',
|
||||
DEV: '1',
|
||||
CI: undefined,
|
||||
}
|
||||
const actual = windowElectronProcessEnv()
|
||||
expect(actual).toStrictEqual(expected)
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
})
|
||||
it('should fail on missing window.electron', () => {
|
||||
// someone didn't clean up their test if this fails!
|
||||
const expected = undefined
|
||||
const actual = windowElectronProcessEnv()
|
||||
expect(actual).toBe(expected)
|
||||
expect(window.electron).toBe(expected)
|
||||
})
|
||||
})
|
||||
describe('processEnv', () => {
|
||||
it('should match the EnvironmentVariables key types*', () => {
|
||||
// Do not print entire object or compare, it contains a ton of ENV vars.
|
||||
// We only need to match against EnvironmentVariables
|
||||
const actual = processEnv()
|
||||
expect(!!actual).toBe(true)
|
||||
expect(typeof actual?.NODE_ENV).toBe('string')
|
||||
// Not passed in during tests?
|
||||
expect(typeof actual?.VITE_KC_WS_MODELING_URL).toBe('undefined')
|
||||
expect(typeof actual?.VITE_KITTYCAD_API_BASE_URL).toBe('string')
|
||||
expect(typeof actual?.VITE_KC_SITE_BASE_URL).toBe('string')
|
||||
// Not passed in during tests?
|
||||
expect(typeof actual?.VITE_KC_SITE_API_URL).toBe('undefined')
|
||||
expect(typeof actual?.VITE_KC_CONNECTION_TIMEOUT_MS).toBe('string')
|
||||
expect(typeof actual?.VITE_KITTYCAD_API_TOKEN).toBe('string')
|
||||
expect(typeof actual?.PROD).toBe('string')
|
||||
expect(typeof actual?.TEST).toBe('string')
|
||||
expect(typeof actual?.DEV).toBe('string')
|
||||
// Don't check CI...
|
||||
})
|
||||
})
|
||||
})
|
107
src/env.ts
107
src/env.ts
@ -1,21 +1,88 @@
|
||||
// It turns out import.meta.env is a really fucky env var passing method.
|
||||
// It's purely generated by Vite and nothing else.
|
||||
// For Jest tests, we use babel to deal with it (it's a Syntax error otherwise)
|
||||
// @ts-ignore: TS1343
|
||||
const env = window.electron?.process.env ?? import.meta.env
|
||||
type EnvironmentVariables = {
|
||||
readonly NODE_ENV: string | undefined
|
||||
readonly VITE_KC_API_WS_MODELING_URL: string | undefined
|
||||
readonly VITE_KITTYCAD_API_BASE_URL: string | undefined
|
||||
readonly VITE_KC_SITE_BASE_URL: string | undefined
|
||||
readonly VITE_KC_SITE_APP_URL: string | undefined
|
||||
readonly VITE_KC_CONNECTION_TIMEOUT_MS: string | undefined
|
||||
readonly VITE_KITTYCAD_API_TOKEN: string | undefined
|
||||
readonly PROD: string | undefined
|
||||
readonly TEST: string | undefined
|
||||
readonly DEV: string | undefined
|
||||
readonly CI: string | undefined
|
||||
}
|
||||
|
||||
export const NODE_ENV = env.NODE_ENV as string | undefined
|
||||
export const VITE_KC_API_WS_MODELING_URL = env.VITE_KC_API_WS_MODELING_URL as
|
||||
| string
|
||||
| undefined
|
||||
export const VITE_KC_API_BASE_URL = env.VITE_KC_API_BASE_URL
|
||||
export const VITE_KC_SITE_BASE_URL = env.VITE_KC_SITE_BASE_URL
|
||||
export const VITE_KC_SITE_APP_URL = env.VITE_KC_SITE_APP_URL
|
||||
export const VITE_KC_SKIP_AUTH = env.VITE_KC_SKIP_AUTH as string | undefined
|
||||
export const VITE_KC_CONNECTION_TIMEOUT_MS =
|
||||
env.VITE_KC_CONNECTION_TIMEOUT_MS as string | undefined
|
||||
export const VITE_KC_DEV_TOKEN = env.VITE_KC_DEV_TOKEN as string | undefined
|
||||
export const PROD = env.PROD as string | undefined
|
||||
export const TEST = env.TEST as string | undefined
|
||||
export const DEV = env.DEV as string | undefined
|
||||
export const CI = env.CI as string | undefined
|
||||
export const viteEnv = () => {
|
||||
// It turns out import.meta.env is a really fucky env var passing method.
|
||||
// It's purely generated by Vite and nothing else.
|
||||
// For Jest tests, we use babel to deal with it (it's a Syntax error otherwise)
|
||||
// @ts-ignore: TS1343
|
||||
return import.meta.env
|
||||
}
|
||||
|
||||
export const windowElectronProcessEnv = () => {
|
||||
return typeof window !== 'undefined' && typeof window.electron !== 'undefined'
|
||||
? window?.electron?.process?.env
|
||||
: undefined
|
||||
}
|
||||
|
||||
export const processEnv = () => {
|
||||
if (typeof process === 'undefined') {
|
||||
// Web, no window.process or process
|
||||
return undefined
|
||||
} else if (
|
||||
typeof process !== 'undefined' &&
|
||||
typeof window !== 'undefined' &&
|
||||
process.env.TEST === 'false'
|
||||
) {
|
||||
// Web, you made window.process, why :(, need process.env.TEST to make sure the frontend gets evaluated.
|
||||
// The frontend can spoof this too :(
|
||||
return undefined
|
||||
}
|
||||
|
||||
return process.env
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will work in any runtime. Note that we shouldn't be using this for any values outside of the
|
||||
* EnvironmentVariables type. This is not going to replace process.env.
|
||||
*
|
||||
* Vite -> node.js -> bridge -> javascript
|
||||
* We want to have the node.js and javascript runtime share the same code for getting these important configurations.
|
||||
*/
|
||||
export default (): EnvironmentVariables => {
|
||||
// Compute the possible environment variables, order operation is important
|
||||
// runtime (TODO) > process.env > window.electron.process.env > import.meta.env
|
||||
|
||||
const viteOnly = viteEnv()
|
||||
const windowElectronProcessEnvOnly = windowElectronProcessEnv()
|
||||
const processEnvOnly = processEnv()
|
||||
const env = processEnvOnly || windowElectronProcessEnvOnly || viteOnly
|
||||
// Vite uses Booleans and process.env uses strings
|
||||
let PROD = env.PROD
|
||||
if (typeof PROD === 'boolean') {
|
||||
PROD = Number(PROD).toString()
|
||||
}
|
||||
let DEV = env.DEV
|
||||
if (typeof DEV === 'boolean') {
|
||||
DEV = Number(DEV).toString()
|
||||
}
|
||||
const environmentVariables: EnvironmentVariables = {
|
||||
NODE_ENV: (env.NODE_ENV as string) || undefined,
|
||||
VITE_KC_API_WS_MODELING_URL:
|
||||
(env.VITE_KC_API_WS_MODELING_URL as string) || undefined,
|
||||
VITE_KITTYCAD_API_BASE_URL:
|
||||
(env.VITE_KITTYCAD_API_BASE_URL as string) || undefined,
|
||||
VITE_KC_SITE_BASE_URL: (env.VITE_KC_SITE_BASE_URL as string) || undefined,
|
||||
VITE_KC_SITE_APP_URL: (env.VITE_KC_SITE_APP_URL as string) || undefined,
|
||||
VITE_KC_CONNECTION_TIMEOUT_MS:
|
||||
(env.VITE_KC_CONNECTION_TIMEOUT_MS as string) || undefined,
|
||||
VITE_KITTYCAD_API_TOKEN:
|
||||
(env.VITE_KITTYCAD_API_TOKEN as string) || undefined,
|
||||
PROD: PROD || undefined,
|
||||
TEST: (env.TEST as string) || undefined,
|
||||
DEV: DEV || undefined,
|
||||
CI: (env.CI as string) || undefined,
|
||||
}
|
||||
return environmentVariables
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { VITE_KC_DEV_TOKEN } from '@src/env'
|
||||
import env from '@src/env'
|
||||
|
||||
import { createLiteral } from '@src/lang/create'
|
||||
import type {
|
||||
@ -40,10 +40,9 @@ import { isOverlap } from '@src/lib/utils'
|
||||
beforeAll(async () => {
|
||||
await initPromise
|
||||
|
||||
// THESE TEST WILL FAIL without VITE_KC_DEV_TOKEN set in .env.development.local
|
||||
await new Promise((resolve) => {
|
||||
engineCommandManager.start({
|
||||
token: VITE_KC_DEV_TOKEN,
|
||||
token: env().VITE_KITTYCAD_API_TOKEN,
|
||||
width: 256,
|
||||
height: 256,
|
||||
setMediaStream: () => {},
|
||||
|
@ -4,16 +4,15 @@ import { initPromise } from '@src/lang/wasmUtils'
|
||||
import { err } from '@src/lib/trap'
|
||||
import type { Selection } from '@src/lib/selections'
|
||||
import { engineCommandManager, kclManager } from '@src/lib/singletons'
|
||||
import { VITE_KC_DEV_TOKEN } from '@src/env'
|
||||
import env from '@src/env'
|
||||
import { modifyAstWithTagsForSelection } from '@src/lang/modifyAst/tagManagement'
|
||||
|
||||
beforeAll(async () => {
|
||||
await initPromise
|
||||
|
||||
// THESE TEST WILL FAIL without VITE_KC_DEV_TOKEN set in .env.development.local
|
||||
await new Promise((resolve) => {
|
||||
engineCommandManager.start({
|
||||
token: VITE_KC_DEV_TOKEN,
|
||||
token: env().VITE_KITTYCAD_API_TOKEN,
|
||||
width: 256,
|
||||
height: 256,
|
||||
setMediaStream: () => {},
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { Models } from '@kittycad/lib'
|
||||
import { VITE_KC_API_WS_MODELING_URL, VITE_KC_DEV_TOKEN } from '@src/env'
|
||||
import env from '@src/env'
|
||||
import { jsAppSettings } from '@src/lib/settings/settingsUtils'
|
||||
import { BSON } from 'bson'
|
||||
|
||||
@ -387,7 +387,7 @@ class EngineConnection extends EventTarget {
|
||||
|
||||
// SHOULD ONLY BE USED FOR VITESTS
|
||||
connectLite(callback: () => void) {
|
||||
const url = `${VITE_KC_API_WS_MODELING_URL}?video_res_width=${256}&video_res_height=${256}`
|
||||
const url = `${env().VITE_KC_API_WS_MODELING_URL}?video_res_width=${256}&video_res_height=${256}`
|
||||
|
||||
this.websocket = new WebSocket(url, [])
|
||||
this.websocket.binaryType = 'arraybuffer'
|
||||
@ -400,7 +400,7 @@ class EngineConnection extends EventTarget {
|
||||
this.send({
|
||||
type: 'headers',
|
||||
headers: {
|
||||
Authorization: `Bearer ${VITE_KC_DEV_TOKEN}`,
|
||||
Authorization: `Bearer ${env().VITE_KITTYCAD_API_TOKEN}`,
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -1531,7 +1531,7 @@ export class EngineCommandManager extends EventTarget {
|
||||
additionalSettings +=
|
||||
'&show_grid=' + (this.settings.showScaleGrid ? 'true' : 'false')
|
||||
const pool = !this.settings.pool ? '' : `&pool=${this.settings.pool}`
|
||||
const url = `${VITE_KC_API_WS_MODELING_URL}?video_res_width=${width}&video_res_height=${height}${additionalSettings}${pool}`
|
||||
const url = `${env().VITE_KC_API_WS_MODELING_URL}?video_res_width=${width}&video_res_height=${height}${additionalSettings}${pool}`
|
||||
this.engineConnection = new EngineConnection({
|
||||
engineCommandManager: this,
|
||||
url,
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { VITE_KC_API_BASE_URL } from '@src/env'
|
||||
import { UAParser } from 'ua-parser-js'
|
||||
|
||||
import type { OsInfo } from '@rust/kcl-lib/bindings/OsInfo'
|
||||
@ -11,6 +10,7 @@ import { isDesktop } from '@src/lib/isDesktop'
|
||||
import type RustContext from '@src/lib/rustContext'
|
||||
import screenshot from '@src/lib/screenshot'
|
||||
import { APP_VERSION } from '@src/routes/utils'
|
||||
import { withAPIBaseURL } from '@src/lib/withBaseURL'
|
||||
|
||||
/* eslint-disable suggest-no-throw/suggest-no-throw --
|
||||
* All the throws in CoreDumpManager are intentional and should be caught and handled properly
|
||||
@ -35,7 +35,7 @@ export class CoreDumpManager {
|
||||
codeManager: CodeManager
|
||||
rustContext: RustContext
|
||||
token: string | undefined
|
||||
baseUrl: string = VITE_KC_API_BASE_URL
|
||||
baseUrl: string = withAPIBaseURL('')
|
||||
|
||||
constructor(
|
||||
engineCommandManager: EngineCommandManager,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { DEV } from '@src/env'
|
||||
import env from '@src/env'
|
||||
import type {
|
||||
Actor,
|
||||
AnyStateMachine,
|
||||
@ -89,7 +89,8 @@ export function createMachineCommand<
|
||||
} else if ('status' in commandConfig) {
|
||||
const { status } = commandConfig
|
||||
if (status === 'inactive') return null
|
||||
if (status === 'development' && !(DEV || IS_STAGING_OR_DEBUG)) return null
|
||||
if (status === 'development' && !(env().DEV || IS_STAGING_OR_DEBUG))
|
||||
return null
|
||||
}
|
||||
|
||||
const icon = ('icon' in commandConfig && commandConfig.icon) || undefined
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { DEV } from '@src/env'
|
||||
import env from '@src/env'
|
||||
import isomorphicFetch from 'isomorphic-fetch'
|
||||
import { isDesktop } from '@src/lib/isDesktop'
|
||||
|
||||
@ -28,7 +28,7 @@ export default async function crossPlatformFetch<T>(
|
||||
// Add credentials: 'include' to options
|
||||
// We send the token with the headers only in development mode, DO NOT
|
||||
// DO THIS IN PRODUCTION, as it is a security risk.
|
||||
opts.headers = headers(DEV ? token : undefined)
|
||||
opts.headers = headers(env().DEV ? token : undefined)
|
||||
opts.credentials = 'include'
|
||||
response = await fetch(url, opts)
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import { err } from '@src/lib/trap'
|
||||
import type { DeepPartial } from '@src/lib/types'
|
||||
import { getInVariableCase } from '@src/lib/utils'
|
||||
import { IS_STAGING } from '@src/routes/utils'
|
||||
import { withAPIBaseURL } from '@src/lib/withBaseURL'
|
||||
|
||||
export async function renameProjectDirectory(
|
||||
projectPath: string,
|
||||
@ -697,7 +698,9 @@ export const readTokenFile = async () => {
|
||||
export const writeTokenFile = async (token: string) => {
|
||||
const tokenFilePath = await getTokenFilePath()
|
||||
if (err(token)) return Promise.reject(token)
|
||||
return window.electron.writeFile(tokenFilePath, token)
|
||||
const result = window.electron.writeFile(tokenFilePath, token)
|
||||
console.log('token written to disk')
|
||||
return result
|
||||
}
|
||||
|
||||
export const writeTelemetryFile = async (content: string) => {
|
||||
@ -722,12 +725,9 @@ export const setState = async (state: Project | undefined): Promise<void> => {
|
||||
appStateStore = state
|
||||
}
|
||||
|
||||
export const getUser = async (
|
||||
token: string,
|
||||
hostname: string
|
||||
): Promise<Models['User_type']> => {
|
||||
export const getUser = async (token: string): Promise<Models['User_type']> => {
|
||||
try {
|
||||
const user = await fetch(`${hostname}/users/me`, {
|
||||
const user = await fetch(withAPIBaseURL('/users/me'), {
|
||||
headers: new Headers({
|
||||
Authorization: `Bearer ${token}`,
|
||||
}),
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { VITE_KC_SITE_APP_URL } from '@src/env'
|
||||
import env from '@src/env'
|
||||
|
||||
import { createCreateFileUrl } from '@src/lib/links'
|
||||
|
||||
@ -9,7 +9,7 @@ describe(`link creation tests`, () => {
|
||||
|
||||
// Converted with external online tools
|
||||
const expectedEncodedCode = `ZXh0cnVzaW9uRGlzdGFuY2UgPSAxMg%3D%3D`
|
||||
const expectedLink = `${VITE_KC_SITE_APP_URL}/?create-file=true&name=test&code=${expectedEncodedCode}&ask-open-desktop=true`
|
||||
const expectedLink = `${env().VITE_KC_SITE_APP_URL}/?create-file=true&name=test&code=${expectedEncodedCode}&ask-open-desktop=true`
|
||||
|
||||
const result = createCreateFileUrl({ code, name, isRestrictedToOrg: false })
|
||||
expect(result.toString()).toBe(expectedLink)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { VITE_KC_API_BASE_URL, VITE_KC_SITE_APP_URL } from '@src/env'
|
||||
import env from '@src/env'
|
||||
import toast from 'react-hot-toast'
|
||||
|
||||
import { stringToBase64 } from '@src/lib/base64'
|
||||
@ -7,6 +7,7 @@ import {
|
||||
CREATE_FILE_URL_PARAM,
|
||||
} from '@src/lib/constants'
|
||||
import { err } from '@src/lib/trap'
|
||||
import { withAPIBaseURL } from '@src/lib/withBaseURL'
|
||||
|
||||
export interface FileLinkParams {
|
||||
code: string
|
||||
@ -57,7 +58,7 @@ export async function copyFileShareLink(
|
||||
* open the URL in the desktop app.
|
||||
*/
|
||||
export function createCreateFileUrl({ code, name }: FileLinkParams) {
|
||||
let origin = VITE_KC_SITE_APP_URL
|
||||
let origin = env().VITE_KC_SITE_APP_URL
|
||||
const searchParams = new URLSearchParams({
|
||||
[CREATE_FILE_URL_PARAM]: String(true),
|
||||
name,
|
||||
@ -96,7 +97,7 @@ export async function createShortlink(
|
||||
if (password) {
|
||||
body.password = password
|
||||
}
|
||||
const response = await fetch(`${VITE_KC_API_BASE_URL}/user/shortlinks`, {
|
||||
const response = await fetch(withAPIBaseURL('/user/shortlinks'), {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-type': 'application/json',
|
||||
|
@ -1,7 +1,6 @@
|
||||
import type { SelectionRange } from '@codemirror/state'
|
||||
import { EditorSelection, Transaction } from '@codemirror/state'
|
||||
import type { Models } from '@kittycad/lib'
|
||||
import { VITE_KC_API_BASE_URL, VITE_KC_SITE_BASE_URL } from '@src/env'
|
||||
import { diffLines } from 'diff'
|
||||
import toast from 'react-hot-toast'
|
||||
import type { TextToCadMultiFileIteration_type } from '@kittycad/lib/dist/types/src/models'
|
||||
@ -28,6 +27,8 @@ import { uuidv4 } from '@src/lib/utils'
|
||||
import type { File as KittyCadLibFile } from '@kittycad/lib/dist/types/src/models'
|
||||
import type { FileMeta } from '@src/lib/types'
|
||||
import type { RequestedKCLFile } from '@src/machines/systemIO/utils'
|
||||
import { withAPIBaseURL, withSiteBaseURL } from '@src/lib/withBaseURL'
|
||||
import env from '@src/env'
|
||||
|
||||
type KclFileMetaMap = {
|
||||
[execStateFileNamesIndex: number]: Extract<FileMeta, { type: 'kcl' }>
|
||||
@ -77,7 +78,7 @@ async function submitTextToCadRequest(
|
||||
})
|
||||
|
||||
const response = await fetch(
|
||||
`${VITE_KC_API_BASE_URL}/ml/text-to-cad/multi-file/iteration`,
|
||||
withAPIBaseURL('/ml/text-to-cad/multi-file/iteration'),
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@ -304,7 +305,7 @@ export async function getPromptToEditResult(
|
||||
id: string,
|
||||
token?: string
|
||||
): Promise<Models['TextToCadMultiFileIteration_type'] | Error> {
|
||||
const url = VITE_KC_API_BASE_URL + '/async/operations/' + id
|
||||
const url = withAPIBaseURL(`/async/operations/${id}`)
|
||||
const data: Models['TextToCadMultiFileIteration_type'] | Error =
|
||||
await crossPlatformFetch(
|
||||
url,
|
||||
@ -340,7 +341,7 @@ export async function doPromptEdit({
|
||||
;(window as any).process = {
|
||||
env: {
|
||||
ZOO_API_TOKEN: token,
|
||||
ZOO_HOST: VITE_KC_API_BASE_URL,
|
||||
ZOO_HOST: withAPIBaseURL(''),
|
||||
},
|
||||
}
|
||||
try {
|
||||
@ -438,7 +439,7 @@ export async function promptToEditFlow({
|
||||
return Promise.reject(result)
|
||||
}
|
||||
const oldCodeWebAppOnly = codeManager.code
|
||||
const downloadLink = `${VITE_KC_SITE_BASE_URL}/${APP_DOWNLOAD_PATH}`
|
||||
const downloadLink = withSiteBaseURL(`/${APP_DOWNLOAD_PATH}`)
|
||||
|
||||
if (!isDesktop() && Object.values(result.outputs).length > 1) {
|
||||
const toastId = uuidv4()
|
||||
|
@ -2,7 +2,7 @@ import type { Configuration } from '@rust/kcl-lib/bindings/Configuration'
|
||||
import type { NamedView } from '@rust/kcl-lib/bindings/NamedView'
|
||||
import type { ProjectConfiguration } from '@rust/kcl-lib/bindings/ProjectConfiguration'
|
||||
import { default_app_settings } from '@rust/kcl-wasm-lib/pkg/kcl_wasm_lib'
|
||||
import { TEST } from '@src/env'
|
||||
import env from '@src/env'
|
||||
|
||||
import {
|
||||
defaultAppSettings,
|
||||
@ -545,7 +545,7 @@ export function getSettingInputType(setting: Setting) {
|
||||
|
||||
export const jsAppSettings = async (): Promise<DeepPartial<Configuration>> => {
|
||||
let jsAppSettings = default_app_settings()
|
||||
if (!TEST) {
|
||||
if (!env().TEST) {
|
||||
// TODO: https://github.com/KittyCAD/modeling-app/issues/6445
|
||||
const settings = await import('@src/lib/singletons').then((module) =>
|
||||
module.getSettings()
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { VITE_KC_API_BASE_URL } from '@src/env'
|
||||
import { withAPIBaseURL } from '@src/lib/withBaseURL'
|
||||
|
||||
import EditorManager from '@src/editor/manager'
|
||||
import { KclManager } from '@src/lang/KclSingleton'
|
||||
@ -171,7 +171,7 @@ const appMachine = setup({
|
||||
systemId: BILLING,
|
||||
input: {
|
||||
...BILLING_CONTEXT_DEFAULTS,
|
||||
urlUserService: VITE_KC_API_BASE_URL,
|
||||
urlUserService: withAPIBaseURL(''),
|
||||
},
|
||||
}),
|
||||
],
|
||||
|
@ -1,5 +1,4 @@
|
||||
import type { Models } from '@kittycad/lib'
|
||||
import { VITE_KC_API_BASE_URL } from '@src/env'
|
||||
import toast from 'react-hot-toast'
|
||||
import type { NavigateFunction } from 'react-router-dom'
|
||||
import {
|
||||
@ -19,6 +18,7 @@ import { err, reportRejection } from '@src/lib/trap'
|
||||
import { toSync } from '@src/lib/utils'
|
||||
import { getAllSubDirectoriesAtProjectRoot } from '@src/machines/systemIO/snapshotContext'
|
||||
import { joinOSPaths } from '@src/lib/paths'
|
||||
import { withAPIBaseURL } from '@src/lib/withBaseURL'
|
||||
|
||||
export async function submitTextToCadPrompt(
|
||||
prompt: string,
|
||||
@ -32,7 +32,7 @@ export async function submitTextToCadPrompt(
|
||||
kcl_version: kclManager.kclVersion,
|
||||
}
|
||||
// Glb has a smaller footprint than gltf, should we want to render it.
|
||||
const url = VITE_KC_API_BASE_URL + '/ai/text-to-cad/glb?kcl=true'
|
||||
const url = withAPIBaseURL('/ai/text-to-cad/glb?kcl=true')
|
||||
const data: Models['TextToCad_type'] | Error = await crossPlatformFetch(
|
||||
url,
|
||||
{
|
||||
@ -58,7 +58,7 @@ export async function getTextToCadResult(
|
||||
id: string,
|
||||
token?: string
|
||||
): Promise<Models['TextToCad_type'] | Error> {
|
||||
const url = VITE_KC_API_BASE_URL + '/user/text-to-cad/' + id
|
||||
const url = withAPIBaseURL(`/user/text-to-cad/${id}`)
|
||||
const data: Models['TextToCad_type'] | Error = await crossPlatformFetch(
|
||||
url,
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user