Compare commits
18 Commits
nightly-v2
...
pierremtb/
Author | SHA1 | Date | |
---|---|---|---|
2a415012d7 | |||
d39dd5697c | |||
c9f7275bc4 | |||
4297dc43ae | |||
935b4ee7f5 | |||
2523242bb1 | |||
309e4fadf0 | |||
842054de09 | |||
af146284b6 | |||
5ac40e6849 | |||
d3e0625e8a | |||
484da28374 | |||
fa9e6ccea9 | |||
77fbb68419 | |||
253a7910b0 | |||
88c6be810f | |||
2860926571 | |||
fb81c02877 |
3
.github/workflows/build-and-store-wasm.yml
vendored
@ -22,6 +22,9 @@ jobs:
|
|||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
workspaces: './src/wasm-lib'
|
workspaces: './src/wasm-lib'
|
||||||
|
- uses: taiki-e/install-action@2dbeb927f58939d3aa13bf06ba0c0a34b76b9bfb
|
||||||
|
with:
|
||||||
|
tool: wasm-pack
|
||||||
- name: build wasm
|
- name: build wasm
|
||||||
run: yarn build:wasm
|
run: yarn build:wasm
|
||||||
|
|
||||||
|
15
.github/workflows/build-apps.yml
vendored
@ -32,7 +32,6 @@ jobs:
|
|||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version-file: '.nvmrc'
|
node-version-file: '.nvmrc'
|
||||||
cache: 'yarn'
|
|
||||||
|
|
||||||
- run: yarn install
|
- run: yarn install
|
||||||
|
|
||||||
@ -44,6 +43,10 @@ jobs:
|
|||||||
workspaces: './src/wasm-lib'
|
workspaces: './src/wasm-lib'
|
||||||
|
|
||||||
# TODO: see if we can fetch from main instead if no diff at src/wasm-lib
|
# TODO: see if we can fetch from main instead if no diff at src/wasm-lib
|
||||||
|
- uses: taiki-e/install-action@2dbeb927f58939d3aa13bf06ba0c0a34b76b9bfb
|
||||||
|
with:
|
||||||
|
tool: wasm-pack
|
||||||
|
|
||||||
- name: Run build:wasm
|
- name: Run build:wasm
|
||||||
run: "yarn build:wasm"
|
run: "yarn build:wasm"
|
||||||
|
|
||||||
@ -120,15 +123,13 @@ jobs:
|
|||||||
cp prepared-files/assets/icon.ico assets/icon.ico
|
cp prepared-files/assets/icon.ico assets/icon.ico
|
||||||
cp prepared-files/assets/icon.png assets/icon.png
|
cp prepared-files/assets/icon.png assets/icon.png
|
||||||
|
|
||||||
- name: Sync node version and setup cache
|
- uses: actions/setup-node@v4
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
with:
|
||||||
node-version-file: '.nvmrc'
|
node-version-file: '.nvmrc'
|
||||||
cache: 'yarn' # Set this to npm, yarn or pnpm.
|
|
||||||
|
|
||||||
- name: yarn install
|
- name: yarn install
|
||||||
# Windows is picky sometimes and fails on fetch. Step takes about ~30s
|
# Windows is picky sometimes and fails on fetch. Step takes about ~30s
|
||||||
uses: nick-fields/retry@v3.0.0
|
uses: nick-fields/retry@v3.0.1
|
||||||
with:
|
with:
|
||||||
timeout_minutes: 2
|
timeout_minutes: 2
|
||||||
max_attempts: 3
|
max_attempts: 3
|
||||||
@ -179,7 +180,7 @@ jobs:
|
|||||||
WINDOWS_CERTIFICATE_THUMBPRINT: ${{ secrets.WINDOWS_CERTIFICATE_THUMBPRINT }}
|
WINDOWS_CERTIFICATE_THUMBPRINT: ${{ secrets.WINDOWS_CERTIFICATE_THUMBPRINT }}
|
||||||
DEBUG: "electron-notarize*"
|
DEBUG: "electron-notarize*"
|
||||||
# TODO: Fix electron-notarize flakes. The logs above should help gather more data on failures
|
# TODO: Fix electron-notarize flakes. The logs above should help gather more data on failures
|
||||||
uses: nick-fields/retry@v3.0.0
|
uses: nick-fields/retry@v3.0.1
|
||||||
with:
|
with:
|
||||||
timeout_minutes: 10
|
timeout_minutes: 10
|
||||||
max_attempts: 3
|
max_attempts: 3
|
||||||
@ -240,7 +241,7 @@ jobs:
|
|||||||
WINDOWS_CERTIFICATE_THUMBPRINT: ${{ secrets.WINDOWS_CERTIFICATE_THUMBPRINT }}
|
WINDOWS_CERTIFICATE_THUMBPRINT: ${{ secrets.WINDOWS_CERTIFICATE_THUMBPRINT }}
|
||||||
DEBUG: "electron-notarize*"
|
DEBUG: "electron-notarize*"
|
||||||
# TODO: Fix electron-notarize flakes. The logs above should help gather more data on failures
|
# TODO: Fix electron-notarize flakes. The logs above should help gather more data on failures
|
||||||
uses: nick-fields/retry@v3.0.0
|
uses: nick-fields/retry@v3.0.1
|
||||||
with:
|
with:
|
||||||
timeout_minutes: 10
|
timeout_minutes: 10
|
||||||
max_attempts: 3
|
max_attempts: 3
|
||||||
|
5
.github/workflows/e2e-tests.yml
vendored
@ -89,6 +89,9 @@ jobs:
|
|||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
- name: Setup Rust
|
- name: Setup Rust
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
- uses: taiki-e/install-action@2dbeb927f58939d3aa13bf06ba0c0a34b76b9bfb
|
||||||
|
with:
|
||||||
|
tool: wasm-pack
|
||||||
- name: Cache Wasm (because rust diff)
|
- name: Cache Wasm (because rust diff)
|
||||||
if: needs.check-rust-changes.outputs.rust-changed == 'true'
|
if: needs.check-rust-changes.outputs.rust-changed == 'true'
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
@ -200,7 +203,7 @@ jobs:
|
|||||||
- name: Run playwright/electron flow (with retries)
|
- name: Run playwright/electron flow (with retries)
|
||||||
id: retry
|
id: retry
|
||||||
if: ${{ !cancelled() && (success() || failure()) }}
|
if: ${{ !cancelled() && (success() || failure()) }}
|
||||||
uses: nick-fields/retry@v3.0.0
|
uses: nick-fields/retry@v3.0.1
|
||||||
with:
|
with:
|
||||||
command: .github/ci-cd-scripts/playwright-electron.sh ${{matrix.shardIndex}} ${{matrix.shardTotal}} ${{matrix.os}}
|
command: .github/ci-cd-scripts/playwright-electron.sh ${{matrix.shardIndex}} ${{matrix.shardTotal}} ${{matrix.os}}
|
||||||
timeout_minutes: 30
|
timeout_minutes: 30
|
||||||
|
12
.github/workflows/static-analysis.yml
vendored
@ -37,6 +37,9 @@ jobs:
|
|||||||
node-version-file: '.nvmrc'
|
node-version-file: '.nvmrc'
|
||||||
cache: 'yarn'
|
cache: 'yarn'
|
||||||
- run: yarn install
|
- run: yarn install
|
||||||
|
- uses: taiki-e/install-action@2dbeb927f58939d3aa13bf06ba0c0a34b76b9bfb
|
||||||
|
with:
|
||||||
|
tool: wasm-pack
|
||||||
- run: yarn build:wasm
|
- run: yarn build:wasm
|
||||||
|
|
||||||
yarn-tsc:
|
yarn-tsc:
|
||||||
@ -53,6 +56,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
workspaces: './src/wasm-lib'
|
workspaces: './src/wasm-lib'
|
||||||
|
|
||||||
|
- uses: taiki-e/install-action@2dbeb927f58939d3aa13bf06ba0c0a34b76b9bfb
|
||||||
|
with:
|
||||||
|
tool: wasm-pack
|
||||||
- run: yarn build:wasm
|
- run: yarn build:wasm
|
||||||
- run: yarn tsc
|
- run: yarn tsc
|
||||||
|
|
||||||
@ -92,6 +98,9 @@ jobs:
|
|||||||
cache: 'yarn'
|
cache: 'yarn'
|
||||||
|
|
||||||
- run: yarn install
|
- run: yarn install
|
||||||
|
- uses: taiki-e/install-action@2dbeb927f58939d3aa13bf06ba0c0a34b76b9bfb
|
||||||
|
with:
|
||||||
|
tool: wasm-pack
|
||||||
- run: yarn build:wasm
|
- run: yarn build:wasm
|
||||||
|
|
||||||
- run: yarn simpleserver:bg
|
- run: yarn simpleserver:bg
|
||||||
@ -118,6 +127,9 @@ jobs:
|
|||||||
cache: 'yarn'
|
cache: 'yarn'
|
||||||
|
|
||||||
- run: yarn install
|
- run: yarn install
|
||||||
|
- uses: taiki-e/install-action@2dbeb927f58939d3aa13bf06ba0c0a34b76b9bfb
|
||||||
|
with:
|
||||||
|
tool: wasm-pack
|
||||||
- run: yarn build:wasm
|
- run: yarn build:wasm
|
||||||
|
|
||||||
- run: yarn simpleserver:bg
|
- run: yarn simpleserver:bg
|
||||||
|
2
.gitignore
vendored
@ -24,7 +24,7 @@ yarn-debug.log*
|
|||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
|
||||||
.idea
|
.idea
|
||||||
.vscode
|
# .vscode
|
||||||
.helix
|
.helix
|
||||||
src/wasm-lib/.idea
|
src/wasm-lib/.idea
|
||||||
src/wasm-lib/.vscode
|
src/wasm-lib/.vscode
|
||||||
|
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"rust-analyzer.linkedProjects": [
|
||||||
|
"src/wasm-lib/Cargo.toml"
|
||||||
|
]
|
||||||
|
}
|
41
README.md
@ -48,22 +48,49 @@ We recommend downloading the latest application binary from [our Releases page](
|
|||||||
|
|
||||||
## Running a development build
|
## Running a development build
|
||||||
|
|
||||||
First, [install Rust via `rustup`](https://www.rust-lang.org/tools/install). This project uses a lot of Rust compiled to [WASM](https://webassembly.org/) within it. We always use the latest stable version of Rust, so you may need to run `rustup update stable`. Then, run:
|
Install a node version manager such as [fnm](https://github.com/Schniz/fnm?tab=readme-ov-#installation).
|
||||||
|
|
||||||
|
On Windows, it's also recommended to [upgrade your PowerShell version](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.5#winget), we're using 7.
|
||||||
|
|
||||||
|
Then in the repo run the following to install and use the node version specified in `.nvmrc`. You might need to specify your processor architecture with `--arch arm64` or `--arch x64` if it's not autodetected.
|
||||||
|
```
|
||||||
|
fnm install --corepack-enabled
|
||||||
|
fnm use
|
||||||
|
```
|
||||||
|
|
||||||
|
Install the NPM dependencies with:
|
||||||
```
|
```
|
||||||
yarn install
|
yarn install
|
||||||
```
|
```
|
||||||
|
|
||||||
followed by:
|
This project uses a lot of Rust compiled to [WASM](https://webassembly.org/) within it. We have package scripts to run rustup, see `package.json` for reference:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
# macOS/Linux
|
||||||
|
yarn install:rust
|
||||||
|
yarn install:wasm-pack:sh
|
||||||
|
|
||||||
|
# Windows
|
||||||
|
yarn install:rust:windows
|
||||||
|
yarn install:wasm-pack:cargo
|
||||||
|
```
|
||||||
|
|
||||||
|
Then to build the WASM layer, run:
|
||||||
|
```
|
||||||
|
# macOS/Linux
|
||||||
yarn build:wasm
|
yarn build:wasm
|
||||||
|
|
||||||
|
# Windows
|
||||||
|
yarn build:wasm:windows
|
||||||
```
|
```
|
||||||
|
|
||||||
or if you have the gh cli installed
|
Or if you have the `gh` cli installed and want to download the latest main wasm bundle. Note that on Windows, you need to associate .ps1 files with PowerShell, which can be done via the right click menu, selecting `C:\Program Files\PowerShell\7\pwsh.exe`, and you can install tools like `gh` via `yarn install:tools:windows`.
|
||||||
|
|
||||||
```
|
```
|
||||||
./get-latest-wasm-bundle.sh # this will download the latest main wasm bundle
|
# macOS/Linux
|
||||||
|
yarn fetch:wasm
|
||||||
|
|
||||||
|
# Windows
|
||||||
|
yarn fetch:wasm:windows
|
||||||
```
|
```
|
||||||
|
|
||||||
That will build the WASM binary and put in the `public` dir (though gitignored).
|
That will build the WASM binary and put in the `public` dir (though gitignored).
|
||||||
@ -74,7 +101,7 @@ Finally, to run the web app only, run:
|
|||||||
yarn start
|
yarn start
|
||||||
```
|
```
|
||||||
|
|
||||||
If you're not an KittyCAD employee you won't be able to access the dev environment, you should copy everything from `.env.production` to `.env.development` to make it point to production instead, then when you navigate to `localhost:3000` the easiest way to sign in is to paste `localStorage.setItem('TOKEN_PERSIST_KEY', "your-token-from-https://zoo.dev/account/api-tokens")` replacing the with a real token from https://zoo.dev/account/api-tokens of course, then navigate to localhost:3000 again. Note that navigating to `localhost:3000/signin` removes your token so you will need to set the token again.
|
If you're not a Zoo employee you won't be able to access the dev environment, you should copy everything from `.env.production` to `.env.development` to make it point to production instead, then when you navigate to `localhost:3000` the easiest way to sign in is to paste `localStorage.setItem('TOKEN_PERSIST_KEY', "your-token-from-https://zoo.dev/account/api-tokens")` replacing the with a real token from https://zoo.dev/account/api-tokens of course, then navigate to localhost:3000 again. Note that navigating to `localhost:3000/signin` removes your token so you will need to set the token again.
|
||||||
|
|
||||||
### Development environment variables
|
### Development environment variables
|
||||||
|
|
||||||
@ -101,7 +128,7 @@ This will start the application and hot-reload on changes.
|
|||||||
|
|
||||||
Devtools can be opened with the usual Cmd-Opt-I (Mac) or Ctrl-Shift-I (Linux and Windows).
|
Devtools can be opened with the usual Cmd-Opt-I (Mac) or Ctrl-Shift-I (Linux and Windows).
|
||||||
|
|
||||||
To build with electron-builder, run `yarn tronb:package:dev` (or `yarn tronb:package:prod` to point to the .env.production variables)
|
To package the app for your platform with electron-builder, run `yarn tronb:package:dev` (or `yarn tronb:package:prod` to point to the .env.production variables)
|
||||||
|
|
||||||
## Checking out commits / Bisecting
|
## Checking out commits / Bisecting
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Set the appearance of a solid. This only works on solids, not sketches or indivi
|
|||||||
This will work on any solid, including extruded solids, revolved solids, and shelled solids.
|
This will work on any solid, including extruded solids, revolved solids, and shelled solids.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
appearance(solid_set: SolidSet, color: String, metalness?: number, roughness?: number) -> SolidSet
|
appearance(solidSet: SolidSet, color: String, metalness?: number, roughness?: number) -> SolidSet
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ appearance(solid_set: SolidSet, color: String, metalness?: number, roughness?: n
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `solid_set` | [`SolidSet`](/docs/kcl/types/SolidSet) | The solid(s) whose appearance is being set | Yes |
|
| `solidSet` | [`SolidSet`](/docs/kcl/types/SolidSet) | The solid(s) whose appearance is being set | Yes |
|
||||||
| `color` | `String` | Color of the new material, a hex string like '#ff0000' | Yes |
|
| `color` | `String` | Color of the new material, a hex string like '#ff0000' | Yes |
|
||||||
| `metalness` | `number` | Metalness of the new material, a percentage like 95.7. | No |
|
| `metalness` | `number` | Metalness of the new material, a percentage like 95.7. | No |
|
||||||
| `roughness` | `number` | Roughness of the new material, a percentage like 95.7. | No |
|
| `roughness` | `number` | Roughness of the new material, a percentage like 95.7. | No |
|
||||||
|
@ -9,7 +9,7 @@ Construct a 2-dimensional circle, of the specified radius, centered at
|
|||||||
the provided (x, y) origin point.
|
the provided (x, y) origin point.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
circle(data: CircleData, sketch_surface_or_group: SketchOrSurface, tag?: TagDeclarator) -> Sketch
|
circle(data: CircleData, sketchSurfaceOrGroup: SketchOrSurface, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ circle(data: CircleData, sketch_surface_or_group: SketchOrSurface, tag?: TagDecl
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`CircleData`](/docs/kcl/types/CircleData) | Data for drawing an circle | Yes |
|
| `data` | [`CircleData`](/docs/kcl/types/CircleData) | Data for drawing an circle | Yes |
|
||||||
| `sketch_surface_or_group` | [`SketchOrSurface`](/docs/kcl/types/SketchOrSurface) | A sketch surface or a sketch. | Yes |
|
| `sketchSurfaceOrGroup` | [`SketchOrSurface`](/docs/kcl/types/SketchOrSurface) | A sketch surface or a sketch. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
@ -9,7 +9,7 @@ Construct a circle derived from 3 points.
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
circleThreePoint(p1: [number], p2: [number], p3: [number], sketch_surface_or_group: SketchOrSurface, tag?: TagDeclarator) -> Sketch
|
circleThreePoint(p1: [number], p2: [number], p3: [number], sketchSurfaceOrGroup: SketchOrSurface, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ circleThreePoint(p1: [number], p2: [number], p3: [number], sketch_surface_or_gro
|
|||||||
| `p1` | `[number]` | 1st point to derive the circle. | Yes |
|
| `p1` | `[number]` | 1st point to derive the circle. | Yes |
|
||||||
| `p2` | `[number]` | 2nd point to derive the circle. | Yes |
|
| `p2` | `[number]` | 2nd point to derive the circle. | Yes |
|
||||||
| `p3` | `[number]` | 3rd point to derive the circle. | Yes |
|
| `p3` | `[number]` | 3rd point to derive the circle. | Yes |
|
||||||
| `sketch_surface_or_group` | [`SketchOrSurface`](/docs/kcl/types/SketchOrSurface) | Plane or surface to sketch on. | Yes |
|
| `sketchSurfaceOrGroup` | [`SketchOrSurface`](/docs/kcl/types/SketchOrSurface) | Plane or surface to sketch on. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | Identifier for the circle to reference elsewhere. | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | Identifier for the circle to reference elsewhere. | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
---
|
|
||||||
title: "std::prelude::HALF_TURN"
|
|
||||||
excerpt: ""
|
|
||||||
layout: manual
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```js
|
|
||||||
std::prelude::HALF_TURN: number(deg) = 180deg
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
---
|
|
||||||
title: "std::prelude::QUARTER_TURN"
|
|
||||||
excerpt: ""
|
|
||||||
layout: manual
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```js
|
|
||||||
std::prelude::QUARTER_TURN: number(deg) = 90deg
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
---
|
|
||||||
title: "std::prelude::THREE_QUARTER_TURN"
|
|
||||||
excerpt: ""
|
|
||||||
layout: manual
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```js
|
|
||||||
std::prelude::THREE_QUARTER_TURN: number(deg) = 270deg
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
---
|
|
||||||
title: "std::prelude::ZERO"
|
|
||||||
excerpt: ""
|
|
||||||
layout: manual
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```js
|
|
||||||
std::prelude::ZERO: number = 0
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
15
docs/kcl/const_std-HALF_TURN.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
title: "std::HALF_TURN"
|
||||||
|
excerpt: ""
|
||||||
|
layout: manual
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```js
|
||||||
|
std::HALF_TURN: number(deg) = 180deg
|
||||||
|
```
|
||||||
|
|
||||||
|
|
15
docs/kcl/const_std-QUARTER_TURN.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
title: "std::QUARTER_TURN"
|
||||||
|
excerpt: ""
|
||||||
|
layout: manual
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```js
|
||||||
|
std::QUARTER_TURN: number(deg) = 90deg
|
||||||
|
```
|
||||||
|
|
||||||
|
|
15
docs/kcl/const_std-THREE_QUARTER_TURN.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
title: "std::THREE_QUARTER_TURN"
|
||||||
|
excerpt: ""
|
||||||
|
layout: manual
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```js
|
||||||
|
std::THREE_QUARTER_TURN: number(deg) = 270deg
|
||||||
|
```
|
||||||
|
|
||||||
|
|
15
docs/kcl/const_std-ZERO.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
title: "std::ZERO"
|
||||||
|
excerpt: ""
|
||||||
|
layout: manual
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```js
|
||||||
|
std::ZERO: number = 0
|
||||||
|
```
|
||||||
|
|
||||||
|
|
@ -9,7 +9,7 @@ Extend a 2-dimensional sketch through a third dimension in order to
|
|||||||
create new 3-dimensional volume, or if extruded into an existing volume, cut into an existing solid.
|
create new 3-dimensional volume, or if extruded into an existing volume, cut into an existing solid.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
extrude(sketch_set: SketchSet, length: number) -> SolidSet
|
extrude(sketchSet: SketchSet, length: number) -> SolidSet
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ extrude(sketch_set: SketchSet, length: number) -> SolidSet
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `sketch_set` | [`SketchSet`](/docs/kcl/types/SketchSet) | Which sketches should be extruded | Yes |
|
| `sketchSet` | [`SketchSet`](/docs/kcl/types/SketchSet) | Which sketches should be extruded | Yes |
|
||||||
| `length` | `number` | How far to extrude the given sketches | Yes |
|
| `length` | `number` | How far to extrude the given sketches | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
@ -9,7 +9,7 @@ Create a helix.
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
helix(revolutions: number, angle_start: number, ccw?: bool, radius: number, axis: Axis3dOrEdgeReference, length?: number) -> HelixValue
|
helix(revolutions: number, angleStart: number, ccw?: bool, radius: number, axis: Axis3dOrEdgeReference, length?: number) -> HelixValue
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ helix(revolutions: number, angle_start: number, ccw?: bool, radius: number, axis
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `revolutions` | `number` | Number of revolutions. | Yes |
|
| `revolutions` | `number` | Number of revolutions. | Yes |
|
||||||
| `angle_start` | `number` | Start angle (in degrees). | Yes |
|
| `angleStart` | `number` | Start angle (in degrees). | Yes |
|
||||||
| `ccw` | `bool` | Is the helix rotation counter clockwise? The default is `false`. | No |
|
| `ccw` | `bool` | Is the helix rotation counter clockwise? The default is `false`. | No |
|
||||||
| `radius` | `number` | Radius of the helix. | Yes |
|
| `radius` | `number` | Radius of the helix. | Yes |
|
||||||
| `axis` | [`Axis3dOrEdgeReference`](/docs/kcl/types/Axis3dOrEdgeReference) | Axis to use for the helix. | Yes |
|
| `axis` | [`Axis3dOrEdgeReference`](/docs/kcl/types/Axis3dOrEdgeReference) | Axis to use for the helix. | Yes |
|
||||||
|
@ -9,7 +9,7 @@ Use a 2-dimensional sketch to cut a hole in another 2-dimensional sketch.
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
hole(hole_sketch: SketchSet, sketch: Sketch) -> Sketch
|
hole(holeSketch: SketchSet, sketch: Sketch) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ hole(hole_sketch: SketchSet, sketch: Sketch) -> Sketch
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `hole_sketch` | [`SketchSet`](/docs/kcl/types/SketchSet) | A sketch or a group of sketches. | Yes |
|
| `holeSketch` | [`SketchSet`](/docs/kcl/types/SketchSet) | A sketch or a group of sketches. | Yes |
|
||||||
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | A sketch is a collection of paths. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
@ -15,7 +15,7 @@ For formats lacking unit data (such as STL, OBJ, or PLY files), the default unit
|
|||||||
Note: The import command currently only works when using the native Modeling App.
|
Note: The import command currently only works when using the native Modeling App.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import(file_path: String, options?: ImportFormat) -> ImportedGeometry
|
import(filePath: String, options?: ImportFormat) -> ImportedGeometry
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ import(file_path: String, options?: ImportFormat) -> ImportedGeometry
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `file_path` | `String` | | Yes |
|
| `filePath` | `String` | | Yes |
|
||||||
| `options` | [`ImportFormat`](/docs/kcl/types/ImportFormat) | Import format specifier | No |
|
| `options` | [`ImportFormat`](/docs/kcl/types/ImportFormat) | Import format specifier | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
@ -10,6 +10,10 @@ layout: manual
|
|||||||
* [Modules](kcl/modules)
|
* [Modules](kcl/modules)
|
||||||
* [Known Issues](kcl/KNOWN-ISSUES)
|
* [Known Issues](kcl/KNOWN-ISSUES)
|
||||||
* **`std`**
|
* **`std`**
|
||||||
|
* [`HALF_TURN`](kcl/const_std-HALF_TURN)
|
||||||
|
* [`QUARTER_TURN`](kcl/const_std-QUARTER_TURN)
|
||||||
|
* [`THREE_QUARTER_TURN`](kcl/const_std-THREE_QUARTER_TURN)
|
||||||
|
* [`ZERO`](kcl/const_std-ZERO)
|
||||||
* [`abs`](kcl/abs)
|
* [`abs`](kcl/abs)
|
||||||
* [`acos`](kcl/acos)
|
* [`acos`](kcl/acos)
|
||||||
* [`angleToMatchLengthX`](kcl/angleToMatchLengthX)
|
* [`angleToMatchLengthX`](kcl/angleToMatchLengthX)
|
||||||
@ -118,8 +122,3 @@ layout: manual
|
|||||||
* [`cos`](kcl/std-math-cos)
|
* [`cos`](kcl/std-math-cos)
|
||||||
* [`sin`](kcl/std-math-sin)
|
* [`sin`](kcl/std-math-sin)
|
||||||
* [`tan`](kcl/std-math-tan)
|
* [`tan`](kcl/std-math-tan)
|
||||||
* **`std::prelude`**
|
|
||||||
* [`HALF_TURN`](kcl/const_std-prelude-HALF_TURN)
|
|
||||||
* [`QUARTER_TURN`](kcl/const_std-prelude-QUARTER_TURN)
|
|
||||||
* [`THREE_QUARTER_TURN`](kcl/const_std-prelude-THREE_QUARTER_TURN)
|
|
||||||
* [`ZERO`](kcl/const_std-prelude-ZERO)
|
|
||||||
|
@ -9,7 +9,7 @@ Extend the current sketch with a new straight line.
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
line(sketch: Sketch, end_absolute?: [number], end?: [number], tag?: TagDeclarator) -> Sketch
|
line(sketch: Sketch, endAbsolute?: [number], end?: [number], tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ line(sketch: Sketch, end_absolute?: [number], end?: [number], tag?: TagDeclarato
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | Which sketch should this path be added to? | Yes |
|
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | Which sketch should this path be added to? | Yes |
|
||||||
| `end_absolute` | `[number]` | Which absolute point should this line go to? Incompatible with `end`. | No |
|
| `endAbsolute` | `[number]` | Which absolute point should this line go to? Incompatible with `end`. | No |
|
||||||
| `end` | `[number]` | How far away (along the X and Y axes) should this line go? Incompatible with `endAbsolute`. | No |
|
| `end` | `[number]` | How far away (along the X and Y axes) should this line go? Incompatible with `endAbsolute`. | No |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | Create a new tag which refers to this line | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | Create a new tag which refers to this line | No |
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Create a 3D surface or solid by interpolating between two or more sketches.
|
|||||||
The sketches need to closed and on the same plane.
|
The sketches need to closed and on the same plane.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
loft(sketches: [Sketch], v_degree: NonZeroU32, bez_approximate_rational: bool, base_curve_index?: integer, tolerance?: number) -> Solid
|
loft(sketches: [Sketch], vDegree: NonZeroU32, bezApproximateRational: bool, baseCurveIndex?: integer, tolerance?: number) -> Solid
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,9 +18,9 @@ loft(sketches: [Sketch], v_degree: NonZeroU32, bez_approximate_rational: bool, b
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `sketches` | [`[Sketch]`](/docs/kcl/types/Sketch) | Which sketches to loft. Must include at least 2 sketches. | Yes |
|
| `sketches` | [`[Sketch]`](/docs/kcl/types/Sketch) | Which sketches to loft. Must include at least 2 sketches. | Yes |
|
||||||
| `v_degree` | `NonZeroU32` | Degree of the interpolation. Must be greater than zero. For example, use 2 for quadratic, or 3 for cubic interpolation in the V direction. This defaults to 2, if not specified. | Yes |
|
| `vDegree` | `NonZeroU32` | Degree of the interpolation. Must be greater than zero. For example, use 2 for quadratic, or 3 for cubic interpolation in the V direction. This defaults to 2, if not specified. | Yes |
|
||||||
| `bez_approximate_rational` | `bool` | Attempt to approximate rational curves (such as arcs) using a bezier. This will remove banding around interpolations between arcs and non-arcs. It may produce errors in other scenarios Over time, this field won't be necessary. | Yes |
|
| `bezApproximateRational` | `bool` | Attempt to approximate rational curves (such as arcs) using a bezier. This will remove banding around interpolations between arcs and non-arcs. It may produce errors in other scenarios Over time, this field won't be necessary. | Yes |
|
||||||
| `base_curve_index` | `integer` | This can be set to override the automatically determined topological base curve, which is usually the first section encountered. | No |
|
| `baseCurveIndex` | `integer` | This can be set to override the automatically determined topological base curve, which is usually the first section encountered. | No |
|
||||||
| `tolerance` | `number` | Tolerance for the loft operation. | No |
|
| `tolerance` | `number` | Tolerance for the loft operation. | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
@ -9,7 +9,7 @@ Apply a function to every element of a list.
|
|||||||
Given a list like `[a, b, c]`, and a function like `f`, returns `[f(a), f(b), f(c)]`
|
Given a list like `[a, b, c]`, and a function like `f`, returns `[f(a), f(b), f(c)]`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
map(array: [KclValue], map_fn: FunctionSource) -> [KclValue]
|
map(array: [KclValue], mapFn: FunctionSource) -> [KclValue]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ map(array: [KclValue], map_fn: FunctionSource) -> [KclValue]
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `array` | [`[KclValue]`](/docs/kcl/types/KclValue) | | Yes |
|
| `array` | [`[KclValue]`](/docs/kcl/types/KclValue) | | Yes |
|
||||||
| `map_fn` | `FunctionSource` | | Yes |
|
| `mapFn` | `FunctionSource` | | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ Only works on unclosed sketches for now.
|
|||||||
Mirror occurs around a local sketch axis rather than a global axis.
|
Mirror occurs around a local sketch axis rather than a global axis.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
mirror2d(data: Mirror2dData, sketch_set: SketchSet) -> [Sketch]
|
mirror2d(data: Mirror2dData, sketchSet: SketchSet) -> [Sketch]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ mirror2d(data: Mirror2dData, sketch_set: SketchSet) -> [Sketch]
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`Mirror2dData`](/docs/kcl/types/Mirror2dData) | Data for a mirror. | Yes |
|
| `data` | [`Mirror2dData`](/docs/kcl/types/Mirror2dData) | Data for a mirror. | Yes |
|
||||||
| `sketch_set` | [`SketchSet`](/docs/kcl/types/SketchSet) | A sketch or a group of sketches. | Yes |
|
| `sketchSet` | [`SketchSet`](/docs/kcl/types/SketchSet) | A sketch or a group of sketches. | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Repeat a 2-dimensional sketch some number of times along a partial or
|
|||||||
complete circle some specified number of times. Each object may additionally be rotated along the circle, ensuring orentation of the solid with respect to the center of the circle is maintained.
|
complete circle some specified number of times. Each object may additionally be rotated along the circle, ensuring orentation of the solid with respect to the center of the circle is maintained.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
patternCircular2d(sketch_set: SketchSet, instances: integer, center: [number], arc_degrees: number, rotate_duplicates: bool, use_original?: bool) -> [Sketch]
|
patternCircular2d(sketchSet: SketchSet, instances: integer, center: [number], arcDegrees: number, rotateDuplicates: bool, useOriginal?: bool) -> [Sketch]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,12 +17,12 @@ patternCircular2d(sketch_set: SketchSet, instances: integer, center: [number], a
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `sketch_set` | [`SketchSet`](/docs/kcl/types/SketchSet) | Which sketch(es) to pattern | Yes |
|
| `sketchSet` | [`SketchSet`](/docs/kcl/types/SketchSet) | Which sketch(es) to pattern | Yes |
|
||||||
| `instances` | `integer` | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
|
| `instances` | `integer` | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
|
||||||
| `center` | `[number]` | The center about which to make the pattern. This is a 2D vector. | Yes |
|
| `center` | `[number]` | The center about which to make the pattern. This is a 2D vector. | Yes |
|
||||||
| `arc_degrees` | `number` | The arc angle (in degrees) to place the repetitions. Must be greater than 0. | Yes |
|
| `arcDegrees` | `number` | The arc angle (in degrees) to place the repetitions. Must be greater than 0. | Yes |
|
||||||
| `rotate_duplicates` | `bool` | Whether or not to rotate the duplicates as they are copied. | Yes |
|
| `rotateDuplicates` | `bool` | Whether or not to rotate the duplicates as they are copied. | Yes |
|
||||||
| `use_original` | `bool` | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false. | No |
|
| `useOriginal` | `bool` | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false. | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Repeat a 3-dimensional solid some number of times along a partial or
|
|||||||
complete circle some specified number of times. Each object may additionally be rotated along the circle, ensuring orentation of the solid with respect to the center of the circle is maintained.
|
complete circle some specified number of times. Each object may additionally be rotated along the circle, ensuring orentation of the solid with respect to the center of the circle is maintained.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
patternCircular3d(solid_set: SolidSet, instances: integer, axis: [number], center: [number], arc_degrees: number, rotate_duplicates: bool, use_original?: bool) -> [Solid]
|
patternCircular3d(solidSet: SolidSet, instances: integer, axis: [number], center: [number], arcDegrees: number, rotateDuplicates: bool, useOriginal?: bool) -> [Solid]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,13 +17,13 @@ patternCircular3d(solid_set: SolidSet, instances: integer, axis: [number], cente
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `solid_set` | [`SolidSet`](/docs/kcl/types/SolidSet) | Which solid(s) to pattern | Yes |
|
| `solidSet` | [`SolidSet`](/docs/kcl/types/SolidSet) | Which solid(s) to pattern | Yes |
|
||||||
| `instances` | `integer` | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
|
| `instances` | `integer` | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
|
||||||
| `axis` | `[number]` | The axis around which to make the pattern. This is a 3D vector | Yes |
|
| `axis` | `[number]` | The axis around which to make the pattern. This is a 3D vector | Yes |
|
||||||
| `center` | `[number]` | The center about which to make the pattern. This is a 3D vector. | Yes |
|
| `center` | `[number]` | The center about which to make the pattern. This is a 3D vector. | Yes |
|
||||||
| `arc_degrees` | `number` | The arc angle (in degrees) to place the repetitions. Must be greater than 0. | Yes |
|
| `arcDegrees` | `number` | The arc angle (in degrees) to place the repetitions. Must be greater than 0. | Yes |
|
||||||
| `rotate_duplicates` | `bool` | Whether or not to rotate the duplicates as they are copied. | Yes |
|
| `rotateDuplicates` | `bool` | Whether or not to rotate the duplicates as they are copied. | Yes |
|
||||||
| `use_original` | `bool` | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false. | No |
|
| `useOriginal` | `bool` | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false. | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Repeat a 2-dimensional sketch along some dimension, with a dynamic amount
|
|||||||
of distance between each repetition, some specified number of times.
|
of distance between each repetition, some specified number of times.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
patternLinear2d(sketch_set: SketchSet, instances: integer, distance: number, axis: [number], use_original?: bool) -> [Sketch]
|
patternLinear2d(sketchSet: SketchSet, instances: integer, distance: number, axis: [number], useOriginal?: bool) -> [Sketch]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,11 +17,11 @@ patternLinear2d(sketch_set: SketchSet, instances: integer, distance: number, axi
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `sketch_set` | [`SketchSet`](/docs/kcl/types/SketchSet) | The sketch(es) to duplicate | Yes |
|
| `sketchSet` | [`SketchSet`](/docs/kcl/types/SketchSet) | The sketch(es) to duplicate | Yes |
|
||||||
| `instances` | `integer` | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
|
| `instances` | `integer` | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
|
||||||
| `distance` | `number` | Distance between each repetition. Also known as 'spacing'. | Yes |
|
| `distance` | `number` | Distance between each repetition. Also known as 'spacing'. | Yes |
|
||||||
| `axis` | `[number]` | The axis of the pattern. A 2D vector. | Yes |
|
| `axis` | `[number]` | The axis of the pattern. A 2D vector. | Yes |
|
||||||
| `use_original` | `bool` | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false. | No |
|
| `useOriginal` | `bool` | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false. | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Repeat a 3-dimensional solid along a linear path, with a dynamic amount
|
|||||||
of distance between each repetition, some specified number of times.
|
of distance between each repetition, some specified number of times.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
patternLinear3d(solid_set: SolidSet, instances: integer, distance: number, axis: [number], use_original?: bool) -> [Solid]
|
patternLinear3d(solidSet: SolidSet, instances: integer, distance: number, axis: [number], useOriginal?: bool) -> [Solid]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,11 +17,11 @@ patternLinear3d(solid_set: SolidSet, instances: integer, distance: number, axis:
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `solid_set` | [`SolidSet`](/docs/kcl/types/SolidSet) | The solid(s) to duplicate | Yes |
|
| `solidSet` | [`SolidSet`](/docs/kcl/types/SolidSet) | The solid(s) to duplicate | Yes |
|
||||||
| `instances` | `integer` | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
|
| `instances` | `integer` | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
|
||||||
| `distance` | `number` | Distance between each repetition. Also known as 'spacing'. | Yes |
|
| `distance` | `number` | Distance between each repetition. Also known as 'spacing'. | Yes |
|
||||||
| `axis` | `[number]` | The axis of the pattern. A 2D vector. | Yes |
|
| `axis` | `[number]` | The axis of the pattern. A 2D vector. | Yes |
|
||||||
| `use_original` | `bool` | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false. | No |
|
| `useOriginal` | `bool` | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false. | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ The transform function returns a transform object. All properties of the object
|
|||||||
- `rotation.origin` (either "local" i.e. rotate around its own center, "global" i.e. rotate around the scene's center, or a 3D point, defaults to "local")
|
- `rotation.origin` (either "local" i.e. rotate around its own center, "global" i.e. rotate around the scene's center, or a 3D point, defaults to "local")
|
||||||
|
|
||||||
```js
|
```js
|
||||||
patternTransform(solid_set: SolidSet, instances: integer, transform: FunctionSource, use_original?: bool) -> [Solid]
|
patternTransform(solidSet: SolidSet, instances: integer, transform: FunctionSource, useOriginal?: bool) -> [Solid]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -43,10 +43,10 @@ patternTransform(solid_set: SolidSet, instances: integer, transform: FunctionSou
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `solid_set` | [`SolidSet`](/docs/kcl/types/SolidSet) | The solid(s) to duplicate | Yes |
|
| `solidSet` | [`SolidSet`](/docs/kcl/types/SolidSet) | The solid(s) to duplicate | Yes |
|
||||||
| `instances` | `integer` | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
|
| `instances` | `integer` | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
|
||||||
| `transform` | `FunctionSource` | How each replica should be transformed. The transform function takes a single parameter: an integer representing which number replication the transform is for. E.g. the first replica to be transformed will be passed the argument `1`. This simplifies your math: the transform function can rely on id `0` being the original instance passed into the `patternTransform`. See the examples. | Yes |
|
| `transform` | `FunctionSource` | How each replica should be transformed. The transform function takes a single parameter: an integer representing which number replication the transform is for. E.g. the first replica to be transformed will be passed the argument `1`. This simplifies your math: the transform function can rely on id `0` being the original instance passed into the `patternTransform`. See the examples. | Yes |
|
||||||
| `use_original` | `bool` | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false. | No |
|
| `useOriginal` | `bool` | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false. | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Just like patternTransform, but works on 2D sketches not 3D solids.
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
patternTransform2d(sketch_set: SketchSet, instances: integer, transform: FunctionSource, use_original?: bool) -> [Sketch]
|
patternTransform2d(sketchSet: SketchSet, instances: integer, transform: FunctionSource, useOriginal?: bool) -> [Sketch]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,10 +17,10 @@ patternTransform2d(sketch_set: SketchSet, instances: integer, transform: Functio
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `sketch_set` | [`SketchSet`](/docs/kcl/types/SketchSet) | The sketch(es) to duplicate | Yes |
|
| `sketchSet` | [`SketchSet`](/docs/kcl/types/SketchSet) | The sketch(es) to duplicate | Yes |
|
||||||
| `instances` | `integer` | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
|
| `instances` | `integer` | The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect. | Yes |
|
||||||
| `transform` | `FunctionSource` | How each replica should be transformed. The transform function takes a single parameter: an integer representing which number replication the transform is for. E.g. the first replica to be transformed will be passed the argument `1`. This simplifies your math: the transform function can rely on id `0` being the original instance passed into the `patternTransform`. See the examples. | Yes |
|
| `transform` | `FunctionSource` | How each replica should be transformed. The transform function takes a single parameter: an integer representing which number replication the transform is for. E.g. the first replica to be transformed will be passed the argument `1`. This simplifies your math: the transform function can rely on id `0` being the original instance passed into the `patternTransform`. See the examples. | Yes |
|
||||||
| `use_original` | `bool` | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false. | No |
|
| `useOriginal` | `bool` | If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false. | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Create a regular polygon with the specified number of sides that is either inscr
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
polygon(data: PolygonData, sketch_surface_or_group: SketchOrSurface, tag?: TagDeclarator) -> Sketch
|
polygon(data: PolygonData, sketchSurfaceOrGroup: SketchOrSurface, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ polygon(data: PolygonData, sketch_surface_or_group: SketchOrSurface, tag?: TagDe
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `data` | [`PolygonData`](/docs/kcl/types/PolygonData) | Data for drawing a polygon | Yes |
|
| `data` | [`PolygonData`](/docs/kcl/types/PolygonData) | Data for drawing a polygon | Yes |
|
||||||
| `sketch_surface_or_group` | [`SketchOrSurface`](/docs/kcl/types/SketchOrSurface) | A sketch surface or a sketch. | Yes |
|
| `sketchSurfaceOrGroup` | [`SketchOrSurface`](/docs/kcl/types/SketchOrSurface) | A sketch surface or a sketch. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
@ -9,7 +9,7 @@ Take a starting value. Then, for each element of an array, calculate the next va
|
|||||||
using the previous value and the element.
|
using the previous value and the element.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
reduce(array: [KclValue], start: KclValue, reduce_fn: FunctionSource) -> KclValue
|
reduce(array: [KclValue], start: KclValue, reduceFn: FunctionSource) -> KclValue
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ reduce(array: [KclValue], start: KclValue, reduce_fn: FunctionSource) -> KclValu
|
|||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `array` | [`[KclValue]`](/docs/kcl/types/KclValue) | | Yes |
|
| `array` | [`[KclValue]`](/docs/kcl/types/KclValue) | | Yes |
|
||||||
| `start` | [`KclValue`](/docs/kcl/types/KclValue) | Any KCL value. | Yes |
|
| `start` | [`KclValue`](/docs/kcl/types/KclValue) | Any KCL value. | Yes |
|
||||||
| `reduce_fn` | `FunctionSource` | | Yes |
|
| `reduceFn` | `FunctionSource` | | Yes |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Remove volume from a 3-dimensional shape such that a wall of the
|
|||||||
provided thickness remains, taking volume starting at the provided face, leaving it open in that direction.
|
provided thickness remains, taking volume starting at the provided face, leaving it open in that direction.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
shell(solid_set: SolidSet, thickness: number, faces: [FaceTag]) -> SolidSet
|
shell(solidSet: SolidSet, thickness: number, faces: [FaceTag]) -> SolidSet
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ shell(solid_set: SolidSet, thickness: number, faces: [FaceTag]) -> SolidSet
|
|||||||
|
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `solid_set` | [`SolidSet`](/docs/kcl/types/SolidSet) | Which solid (or solids) to shell out | Yes |
|
| `solidSet` | [`SolidSet`](/docs/kcl/types/SolidSet) | Which solid (or solids) to shell out | Yes |
|
||||||
| `thickness` | `number` | The thickness of the shell | Yes |
|
| `thickness` | `number` | The thickness of the shell | Yes |
|
||||||
| `faces` | [`[FaceTag]`](/docs/kcl/types/FaceTag) | The faces you want removed | Yes |
|
| `faces` | [`[FaceTag]`](/docs/kcl/types/FaceTag) | The faces you want removed | Yes |
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Start a new profile at a given point.
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
startProfileAt(to: [number], sketch_surface: SketchSurface, tag?: TagDeclarator) -> Sketch
|
startProfileAt(to: [number], sketchSurface: SketchSurface, tag?: TagDeclarator) -> Sketch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ startProfileAt(to: [number], sketch_surface: SketchSurface, tag?: TagDeclarator)
|
|||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
|----------|------|-------------|----------|
|
|----------|------|-------------|----------|
|
||||||
| `to` | `[number]` | | Yes |
|
| `to` | `[number]` | | Yes |
|
||||||
| `sketch_surface` | [`SketchSurface`](/docs/kcl/types/SketchSurface) | A sketch type. | Yes |
|
| `sketchSurface` | [`SketchSurface`](/docs/kcl/types/SketchSurface) | A sketch type. | Yes |
|
||||||
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
| `tag` | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No |
|
||||||
|
|
||||||
### Returns
|
### Returns
|
||||||
|
@ -38863,7 +38863,7 @@
|
|||||||
"keywordArguments": true,
|
"keywordArguments": true,
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
"name": "solid_set",
|
"name": "solidSet",
|
||||||
"type": "SolidSet",
|
"type": "SolidSet",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -70936,7 +70936,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sketch_surface_or_group",
|
"name": "sketchSurfaceOrGroup",
|
||||||
"type": "SketchOrSurface",
|
"type": "SketchOrSurface",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -75887,7 +75887,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sketch_surface_or_group",
|
"name": "sketchSurfaceOrGroup",
|
||||||
"type": "SketchOrSurface",
|
"type": "SketchOrSurface",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -85796,7 +85796,7 @@
|
|||||||
"keywordArguments": true,
|
"keywordArguments": true,
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
"name": "sketch_set",
|
"name": "sketchSet",
|
||||||
"type": "SketchSet",
|
"type": "SketchSet",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -104094,7 +104094,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "angle_start",
|
"name": "angleStart",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -110158,7 +110158,7 @@
|
|||||||
"keywordArguments": false,
|
"keywordArguments": false,
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
"name": "hole_sketch",
|
"name": "holeSketch",
|
||||||
"type": "SketchSet",
|
"type": "SketchSet",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -118587,7 +118587,7 @@
|
|||||||
"keywordArguments": false,
|
"keywordArguments": false,
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
"name": "file_path",
|
"name": "filePath",
|
||||||
"type": "String",
|
"type": "String",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -124304,7 +124304,7 @@
|
|||||||
"labelRequired": false
|
"labelRequired": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "end_absolute",
|
"name": "endAbsolute",
|
||||||
"type": "[number]",
|
"type": "[number]",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -132449,7 +132449,7 @@
|
|||||||
"labelRequired": false
|
"labelRequired": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "v_degree",
|
"name": "vDegree",
|
||||||
"type": "NonZeroU32",
|
"type": "NonZeroU32",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -134051,7 +134051,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "bez_approximate_rational",
|
"name": "bezApproximateRational",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -135651,7 +135651,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "base_curve_index",
|
"name": "baseCurveIndex",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -143301,7 +143301,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "map_fn",
|
"name": "mapFn",
|
||||||
"type": "FunctionSource",
|
"type": "FunctionSource",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -149807,7 +149807,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sketch_set",
|
"name": "sketchSet",
|
||||||
"type": "SketchSet",
|
"type": "SketchSet",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -153703,7 +153703,7 @@
|
|||||||
"keywordArguments": true,
|
"keywordArguments": true,
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
"name": "sketch_set",
|
"name": "sketchSet",
|
||||||
"type": "SketchSet",
|
"type": "SketchSet",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -158613,7 +158613,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "arc_degrees",
|
"name": "arcDegrees",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -160214,7 +160214,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "rotate_duplicates",
|
"name": "rotateDuplicates",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -161814,7 +161814,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "use_original",
|
"name": "useOriginal",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -165030,7 +165030,7 @@
|
|||||||
"keywordArguments": true,
|
"keywordArguments": true,
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
"name": "solid_set",
|
"name": "solidSet",
|
||||||
"type": "SolidSet",
|
"type": "SolidSet",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -171550,7 +171550,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "arc_degrees",
|
"name": "arcDegrees",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -173151,7 +173151,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "rotate_duplicates",
|
"name": "rotateDuplicates",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -174751,7 +174751,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "use_original",
|
"name": "useOriginal",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -177967,7 +177967,7 @@
|
|||||||
"keywordArguments": true,
|
"keywordArguments": true,
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
"name": "sketch_set",
|
"name": "sketchSet",
|
||||||
"type": "SketchSet",
|
"type": "SketchSet",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -184478,7 +184478,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "use_original",
|
"name": "useOriginal",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -187694,7 +187694,7 @@
|
|||||||
"keywordArguments": true,
|
"keywordArguments": true,
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
"name": "solid_set",
|
"name": "solidSet",
|
||||||
"type": "SolidSet",
|
"type": "SolidSet",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -194209,7 +194209,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "use_original",
|
"name": "useOriginal",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -197425,7 +197425,7 @@
|
|||||||
"keywordArguments": true,
|
"keywordArguments": true,
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
"name": "solid_set",
|
"name": "solidSet",
|
||||||
"type": "SolidSet",
|
"type": "SolidSet",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -202333,7 +202333,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "use_original",
|
"name": "useOriginal",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -205554,7 +205554,7 @@
|
|||||||
"keywordArguments": true,
|
"keywordArguments": true,
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
"name": "sketch_set",
|
"name": "sketchSet",
|
||||||
"type": "SketchSet",
|
"type": "SketchSet",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -210458,7 +210458,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "use_original",
|
"name": "useOriginal",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -214182,7 +214182,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sketch_surface_or_group",
|
"name": "sketchSurfaceOrGroup",
|
||||||
"type": "SketchOrSurface",
|
"type": "SketchOrSurface",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -244378,7 +244378,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "reduce_fn",
|
"name": "reduceFn",
|
||||||
"type": "FunctionSource",
|
"type": "FunctionSource",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -263874,7 +263874,7 @@
|
|||||||
"keywordArguments": true,
|
"keywordArguments": true,
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
"name": "solid_set",
|
"name": "solidSet",
|
||||||
"type": "SolidSet",
|
"type": "SolidSet",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
@ -270603,7 +270603,7 @@
|
|||||||
"labelRequired": true
|
"labelRequired": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sketch_surface",
|
"name": "sketchSurface",
|
||||||
"type": "SketchSurface",
|
"type": "SketchSurface",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
|
||||||
|
@ -59,18 +59,25 @@ export interface Fixtures {
|
|||||||
homePage: HomePageFixture
|
homePage: HomePageFixture
|
||||||
}
|
}
|
||||||
export class AuthenticatedTronApp {
|
export class AuthenticatedTronApp {
|
||||||
public readonly _page: Page
|
public originalPage: Page
|
||||||
public page: Page
|
public page: Page
|
||||||
|
public browserContext: BrowserContext
|
||||||
public context: BrowserContext
|
public context: BrowserContext
|
||||||
public readonly testInfo: TestInfo
|
public readonly testInfo: TestInfo
|
||||||
public electronApp: ElectronApplication | undefined
|
public electronApp: ElectronApplication | undefined
|
||||||
public readonly viewPortSize = { width: 1200, height: 500 }
|
public readonly viewPortSize = { width: 1200, height: 500 }
|
||||||
public dir: string = ''
|
public dir: string = ''
|
||||||
|
|
||||||
constructor(context: BrowserContext, page: Page, testInfo: TestInfo) {
|
constructor(
|
||||||
this._page = page
|
browserContext: BrowserContext,
|
||||||
this.page = page
|
originalPage: Page,
|
||||||
this.context = context
|
testInfo: TestInfo
|
||||||
|
) {
|
||||||
|
this.page = originalPage
|
||||||
|
this.originalPage = originalPage
|
||||||
|
this.browserContext = browserContext
|
||||||
|
// Will be overwritten in the initializer
|
||||||
|
this.context = browserContext
|
||||||
this.testInfo = testInfo
|
this.testInfo = testInfo
|
||||||
}
|
}
|
||||||
async initialise(
|
async initialise(
|
||||||
@ -86,9 +93,17 @@ export class AuthenticatedTronApp {
|
|||||||
folderSetupFn: arg.folderSetupFn,
|
folderSetupFn: arg.folderSetupFn,
|
||||||
cleanProjectDir: arg.cleanProjectDir,
|
cleanProjectDir: arg.cleanProjectDir,
|
||||||
appSettings: arg.appSettings,
|
appSettings: arg.appSettings,
|
||||||
|
viewport: this.viewPortSize,
|
||||||
})
|
})
|
||||||
this.page = page
|
this.page = page
|
||||||
|
|
||||||
|
// These assignments "fix" some brokenness in the Playwright Workbench when
|
||||||
|
// running against electron applications.
|
||||||
|
// The timeline is still broken but failure screenshots work again.
|
||||||
this.context = context
|
this.context = context
|
||||||
|
// TODO: try to get this to work again for screenshots, but it messed with test ends when enabled
|
||||||
|
// Object.assign(this.browserContext, this.context)
|
||||||
|
|
||||||
this.electronApp = electronApp
|
this.electronApp = electronApp
|
||||||
this.dir = dir
|
this.dir = dir
|
||||||
|
|
||||||
|
@ -1064,7 +1064,7 @@ openSketch = startSketchOn('XY')
|
|||||||
0
|
0
|
||||||
)
|
)
|
||||||
await operationButton.click({ button: 'left' })
|
await operationButton.click({ button: 'left' })
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
await scene.expectPixelColor([50, 51, 96], testPoint, 15)
|
await scene.expectPixelColor([50, 51, 96], testPoint, 15)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -1125,11 +1125,53 @@ openSketch = startSketchOn('XY')
|
|||||||
await scene.expectPixelColor([250, 250, 250], testPoint, 15)
|
await scene.expectPixelColor([250, 250, 250], testPoint, 15)
|
||||||
})
|
})
|
||||||
|
|
||||||
await test.step('Delete offset plane via feature tree selection', async () => {
|
await test.step(`Edit helix through the feature tree`, async () => {
|
||||||
|
await editor.closePane()
|
||||||
|
const operationButton = await toolbar.getFeatureTreeOperation('Helix', 0)
|
||||||
|
await operationButton.dblclick()
|
||||||
|
const initialInput = '5'
|
||||||
|
const newInput = '50'
|
||||||
|
await cmdBar.expectState({
|
||||||
|
commandName: 'Helix',
|
||||||
|
stage: 'arguments',
|
||||||
|
currentArgKey: 'length',
|
||||||
|
currentArgValue: initialInput,
|
||||||
|
headerArguments: {
|
||||||
|
AngleStart: '360',
|
||||||
|
Axis: 'X',
|
||||||
|
CounterClockWise: '',
|
||||||
|
Length: initialInput,
|
||||||
|
Radius: '5',
|
||||||
|
Revolutions: '1',
|
||||||
|
},
|
||||||
|
highlightedHeaderArg: 'length',
|
||||||
|
})
|
||||||
|
await expect(cmdBar.currentArgumentInput).toBeVisible()
|
||||||
|
await cmdBar.currentArgumentInput.locator('.cm-content').fill(newInput)
|
||||||
|
await cmdBar.progressCmdBar()
|
||||||
|
await cmdBar.expectState({
|
||||||
|
stage: 'review',
|
||||||
|
headerArguments: {
|
||||||
|
AngleStart: '360',
|
||||||
|
Axis: 'X',
|
||||||
|
CounterClockWise: '',
|
||||||
|
Length: newInput,
|
||||||
|
Radius: '5',
|
||||||
|
Revolutions: '1',
|
||||||
|
},
|
||||||
|
commandName: 'Helix',
|
||||||
|
})
|
||||||
|
await cmdBar.progressCmdBar()
|
||||||
|
await toolbar.closeFeatureTreePane()
|
||||||
|
await editor.openPane()
|
||||||
|
await editor.expectEditor.toContain('length = ' + newInput)
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('Delete helix via feature tree selection', async () => {
|
||||||
await editor.closePane()
|
await editor.closePane()
|
||||||
const operationButton = await toolbar.getFeatureTreeOperation('Helix', 0)
|
const operationButton = await toolbar.getFeatureTreeOperation('Helix', 0)
|
||||||
await operationButton.click({ button: 'left' })
|
await operationButton.click({ button: 'left' })
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
// Red plane is back
|
// Red plane is back
|
||||||
await scene.expectPixelColor([96, 52, 52], testPoint, 15)
|
await scene.expectPixelColor([96, 52, 52], testPoint, 15)
|
||||||
})
|
})
|
||||||
@ -1221,7 +1263,7 @@ openSketch = startSketchOn('XY')
|
|||||||
await editor.closePane()
|
await editor.closePane()
|
||||||
const operationButton = await toolbar.getFeatureTreeOperation('Loft', 0)
|
const operationButton = await toolbar.getFeatureTreeOperation('Loft', 0)
|
||||||
await operationButton.click({ button: 'left' })
|
await operationButton.click({ button: 'left' })
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
await scene.expectPixelColor([254, 254, 254], testPoint, 15)
|
await scene.expectPixelColor([254, 254, 254], testPoint, 15)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -1264,7 +1306,7 @@ loft001 = loft([sketch001, sketch002])
|
|||||||
await expect(page.locator('.cm-activeLine')).toHaveText(`
|
await expect(page.locator('.cm-activeLine')).toHaveText(`
|
||||||
|> circle({ center = [0, 0], radius = 30 }, %)
|
|> circle({ center = [0, 0], radius = 30 }, %)
|
||||||
`)
|
`)
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
// Check for sketch 1
|
// Check for sketch 1
|
||||||
await scene.expectPixelColor([254, 254, 254], testPoint, 15)
|
await scene.expectPixelColor([254, 254, 254], testPoint, 15)
|
||||||
})
|
})
|
||||||
@ -1275,7 +1317,7 @@ loft001 = loft([sketch001, sketch002])
|
|||||||
await expect(page.locator('.cm-activeLine')).toHaveText(`
|
await expect(page.locator('.cm-activeLine')).toHaveText(`
|
||||||
|> circle({ center = [0, 0], radius = 20 }, %)
|
|> circle({ center = [0, 0], radius = 20 }, %)
|
||||||
`)
|
`)
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
// Check for plane001
|
// Check for plane001
|
||||||
await scene.expectPixelColor([228, 228, 228], testPoint, 15)
|
await scene.expectPixelColor([228, 228, 228], testPoint, 15)
|
||||||
})
|
})
|
||||||
@ -1286,7 +1328,7 @@ loft001 = loft([sketch001, sketch002])
|
|||||||
await expect(page.locator('.cm-activeLine')).toHaveText(`
|
await expect(page.locator('.cm-activeLine')).toHaveText(`
|
||||||
plane001 = offsetPlane('XZ', offset = 50)
|
plane001 = offsetPlane('XZ', offset = 50)
|
||||||
`)
|
`)
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
// Check for sketch 1
|
// Check for sketch 1
|
||||||
await scene.expectPixelColor([254, 254, 254], testPoint, 15)
|
await scene.expectPixelColor([254, 254, 254], testPoint, 15)
|
||||||
})
|
})
|
||||||
@ -1380,7 +1422,7 @@ sketch002 = startSketchOn('XZ')
|
|||||||
await page.waitForTimeout(500)
|
await page.waitForTimeout(500)
|
||||||
const operationButton = await toolbar.getFeatureTreeOperation('Sweep', 0)
|
const operationButton = await toolbar.getFeatureTreeOperation('Sweep', 0)
|
||||||
await operationButton.click({ button: 'left' })
|
await operationButton.click({ button: 'left' })
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
await page.waitForTimeout(500)
|
await page.waitForTimeout(500)
|
||||||
await toolbar.closePane('feature-tree')
|
await toolbar.closePane('feature-tree')
|
||||||
await scene.expectPixelColor([53, 53, 53], testPoint, 15)
|
await scene.expectPixelColor([53, 53, 53], testPoint, 15)
|
||||||
@ -1686,7 +1728,7 @@ extrude001 = extrude(sketch001, length = -12)
|
|||||||
1
|
1
|
||||||
)
|
)
|
||||||
await operationButton.click({ button: 'left' })
|
await operationButton.click({ button: 'left' })
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
await page.waitForTimeout(500)
|
await page.waitForTimeout(500)
|
||||||
await scene.expectPixelColor(edgeColorWhite, secondEdgeLocation, 15) // deleted
|
await scene.expectPixelColor(edgeColorWhite, secondEdgeLocation, 15) // deleted
|
||||||
await editor.expectEditor.not.toContain(secondFilletDeclaration)
|
await editor.expectEditor.not.toContain(secondFilletDeclaration)
|
||||||
@ -1788,7 +1830,7 @@ fillet04 = fillet(extrude001, radius = 5, tags = [getOppositeEdge(seg02)])
|
|||||||
0
|
0
|
||||||
)
|
)
|
||||||
await operationButton.click({ button: 'left' })
|
await operationButton.click({ button: 'left' })
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
await page.waitForTimeout(500)
|
await page.waitForTimeout(500)
|
||||||
})
|
})
|
||||||
await test.step('Verify piped fillet is deleted but other fillets are not (in the editor)', async () => {
|
await test.step('Verify piped fillet is deleted but other fillets are not (in the editor)', async () => {
|
||||||
@ -1818,7 +1860,7 @@ fillet04 = fillet(extrude001, radius = 5, tags = [getOppositeEdge(seg02)])
|
|||||||
1
|
1
|
||||||
)
|
)
|
||||||
await operationButton.click({ button: 'left' })
|
await operationButton.click({ button: 'left' })
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
await page.waitForTimeout(500)
|
await page.waitForTimeout(500)
|
||||||
})
|
})
|
||||||
await test.step('Verify non-piped fillet is deleted but other two fillets are not (in the editor)', async () => {
|
await test.step('Verify non-piped fillet is deleted but other two fillets are not (in the editor)', async () => {
|
||||||
@ -2057,7 +2099,7 @@ extrude001 = extrude(sketch001, length = -12)
|
|||||||
1
|
1
|
||||||
)
|
)
|
||||||
await operationButton.click({ button: 'left' })
|
await operationButton.click({ button: 'left' })
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
await page.waitForTimeout(500)
|
await page.waitForTimeout(500)
|
||||||
await scene.expectPixelColor(edgeColorWhite, secondEdgeLocation, 15) // deleted
|
await scene.expectPixelColor(edgeColorWhite, secondEdgeLocation, 15) // deleted
|
||||||
await scene.expectPixelColor(chamferColor, firstEdgeLocation, 15) // stayed
|
await scene.expectPixelColor(chamferColor, firstEdgeLocation, 15) // stayed
|
||||||
@ -2160,7 +2202,7 @@ chamfer04 = chamfer(extrude001, length = 5, tags = [getOppositeEdge(seg02)])
|
|||||||
0
|
0
|
||||||
)
|
)
|
||||||
await operationButton.click({ button: 'left' })
|
await operationButton.click({ button: 'left' })
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
await page.waitForTimeout(500)
|
await page.waitForTimeout(500)
|
||||||
})
|
})
|
||||||
await test.step('Verify piped chamfer is deleted but other chamfers are not (in the editor)', async () => {
|
await test.step('Verify piped chamfer is deleted but other chamfers are not (in the editor)', async () => {
|
||||||
@ -2192,7 +2234,7 @@ chamfer04 = chamfer(extrude001, length = 5, tags = [getOppositeEdge(seg02)])
|
|||||||
1
|
1
|
||||||
)
|
)
|
||||||
await operationButton.click({ button: 'left' })
|
await operationButton.click({ button: 'left' })
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
await page.waitForTimeout(500)
|
await page.waitForTimeout(500)
|
||||||
})
|
})
|
||||||
await test.step('Verify non-piped chamfer is deleted but other two chamfers are not (in the editor)', async () => {
|
await test.step('Verify non-piped chamfer is deleted but other two chamfers are not (in the editor)', async () => {
|
||||||
@ -2396,7 +2438,7 @@ extrude001 = extrude(sketch001, length = 40)
|
|||||||
await editor.closePane()
|
await editor.closePane()
|
||||||
const operationButton = await toolbar.getFeatureTreeOperation('Shell', 0)
|
const operationButton = await toolbar.getFeatureTreeOperation('Shell', 0)
|
||||||
await operationButton.click({ button: 'left' })
|
await operationButton.click({ button: 'left' })
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
await scene.expectPixelColor([99, 99, 99], testPoint, 15)
|
await scene.expectPixelColor([99, 99, 99], testPoint, 15)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -2535,7 +2577,7 @@ profile001 = startProfileAt([-20, 20], sketch001)
|
|||||||
const deleteOperation = async (operationButton: Locator) => {
|
const deleteOperation = async (operationButton: Locator) => {
|
||||||
if (shouldUseKeyboard) {
|
if (shouldUseKeyboard) {
|
||||||
await operationButton.click({ button: 'left' })
|
await operationButton.click({ button: 'left' })
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
} else {
|
} else {
|
||||||
await operationButton.click({ button: 'right' })
|
await operationButton.click({ button: 'right' })
|
||||||
const editButton = page.getByTestId('context-menu-delete')
|
const editButton = page.getByTestId('context-menu-delete')
|
||||||
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 143 KiB After Width: | Height: | Size: 145 KiB |
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 129 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
@ -937,11 +937,16 @@ export async function setupElectron({
|
|||||||
testInfo,
|
testInfo,
|
||||||
cleanProjectDir = true,
|
cleanProjectDir = true,
|
||||||
appSettings,
|
appSettings,
|
||||||
|
viewport,
|
||||||
}: {
|
}: {
|
||||||
testInfo: TestInfo
|
testInfo: TestInfo
|
||||||
folderSetupFn?: (projectDirName: string) => Promise<void>
|
folderSetupFn?: (projectDirName: string) => Promise<void>
|
||||||
cleanProjectDir?: boolean
|
cleanProjectDir?: boolean
|
||||||
appSettings?: Partial<SaveSettingsPayload>
|
appSettings?: Partial<SaveSettingsPayload>
|
||||||
|
viewport: {
|
||||||
|
width: number
|
||||||
|
height: number
|
||||||
|
}
|
||||||
}): Promise<{
|
}): Promise<{
|
||||||
electronApp: ElectronApplication
|
electronApp: ElectronApplication
|
||||||
context: BrowserContext
|
context: BrowserContext
|
||||||
@ -972,6 +977,14 @@ export async function setupElectron({
|
|||||||
...(process.env.ELECTRON_OVERRIDE_DIST_PATH
|
...(process.env.ELECTRON_OVERRIDE_DIST_PATH
|
||||||
? { executablePath: process.env.ELECTRON_OVERRIDE_DIST_PATH + 'electron' }
|
? { executablePath: process.env.ELECTRON_OVERRIDE_DIST_PATH + 'electron' }
|
||||||
: {}),
|
: {}),
|
||||||
|
...(process.env.PLAYWRIGHT_RECORD_VIDEO
|
||||||
|
? {
|
||||||
|
recordVideo: {
|
||||||
|
dir: testInfo.snapshotPath(),
|
||||||
|
size: viewport,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do this once and then reuse window on subsequent calls.
|
// Do this once and then reuse window on subsequent calls.
|
||||||
|
@ -94,6 +94,8 @@ test.describe('Testing Camera Movement', { tag: ['@skipWin'] }, () => {
|
|||||||
await bakeInRetries(async () => {
|
await bakeInRetries(async () => {
|
||||||
await page.mouse.move(700, 200)
|
await page.mouse.move(700, 200)
|
||||||
await page.mouse.down({ button: 'right' })
|
await page.mouse.down({ button: 'right' })
|
||||||
|
await page.waitForTimeout(100)
|
||||||
|
|
||||||
const appLogoBBox = await page.getByTestId('app-logo').boundingBox()
|
const appLogoBBox = await page.getByTestId('app-logo').boundingBox()
|
||||||
expect(appLogoBBox).not.toBeNull()
|
expect(appLogoBBox).not.toBeNull()
|
||||||
if (!appLogoBBox) throw new Error('app logo not found')
|
if (!appLogoBBox) throw new Error('app logo not found')
|
||||||
@ -101,7 +103,9 @@ test.describe('Testing Camera Movement', { tag: ['@skipWin'] }, () => {
|
|||||||
appLogoBBox.x + appLogoBBox.width / 2,
|
appLogoBBox.x + appLogoBBox.width / 2,
|
||||||
appLogoBBox.y + appLogoBBox.height / 2
|
appLogoBBox.y + appLogoBBox.height / 2
|
||||||
)
|
)
|
||||||
|
await page.waitForTimeout(100)
|
||||||
await page.mouse.move(600, 303)
|
await page.mouse.move(600, 303)
|
||||||
|
await page.waitForTimeout(100)
|
||||||
await page.mouse.up({ button: 'right' })
|
await page.mouse.up({ button: 'right' })
|
||||||
}, [4, -10.5, -120])
|
}, [4, -10.5, -120])
|
||||||
|
|
||||||
|
@ -382,7 +382,7 @@ profile003 = startProfileAt([40.16, -120.48], sketch006)
|
|||||||
'|> line(end = [0, -pipeLength])'
|
'|> line(end = [0, -pipeLength])'
|
||||||
)
|
)
|
||||||
await u.clearCommandLogs()
|
await u.clearCommandLogs()
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
await u.expectCmdLog('[data-message-type="execution-done"]', 10_000)
|
await u.expectCmdLog('[data-message-type="execution-done"]', 10_000)
|
||||||
await page.waitForTimeout(200)
|
await page.waitForTimeout(200)
|
||||||
|
|
||||||
@ -439,7 +439,7 @@ profile003 = startProfileAt([40.16, -120.48], sketch006)
|
|||||||
'|> startProfileAt([23.24, 136.52], %)'
|
'|> startProfileAt([23.24, 136.52], %)'
|
||||||
)
|
)
|
||||||
await u.clearCommandLogs()
|
await u.clearCommandLogs()
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
await u.expectCmdLog('[data-message-type="execution-done"]', 10_000)
|
await u.expectCmdLog('[data-message-type="execution-done"]', 10_000)
|
||||||
await page.waitForTimeout(200)
|
await page.waitForTimeout(200)
|
||||||
await expect(u.codeLocator).not.toContainText(`sketch005 = startSketchOn({`)
|
await expect(u.codeLocator).not.toContainText(`sketch005 = startSketchOn({`)
|
||||||
@ -453,7 +453,7 @@ profile003 = startProfileAt([40.16, -120.48], sketch006)
|
|||||||
' |> line(end = [20.91, -28.61])'
|
' |> line(end = [20.91, -28.61])'
|
||||||
)
|
)
|
||||||
await u.clearCommandLogs()
|
await u.clearCommandLogs()
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
await u.expectCmdLog('[data-message-type="execution-done"]', 10_000)
|
await u.expectCmdLog('[data-message-type="execution-done"]', 10_000)
|
||||||
await page.waitForTimeout(200)
|
await page.waitForTimeout(200)
|
||||||
await expect(u.codeLocator).not.toContainText(codeToBeDeletedSnippet)
|
await expect(u.codeLocator).not.toContainText(codeToBeDeletedSnippet)
|
||||||
@ -518,7 +518,7 @@ profile003 = startProfileAt([40.16, -120.48], sketch006)
|
|||||||
'|> line(end = [170.36, -121.61], tag = $seg01)'
|
'|> line(end = [170.36, -121.61], tag = $seg01)'
|
||||||
)
|
)
|
||||||
await u.clearCommandLogs()
|
await u.clearCommandLogs()
|
||||||
await page.keyboard.press('Backspace')
|
await page.keyboard.press('Delete')
|
||||||
|
|
||||||
await expect(page.getByText('Unable to delete selection')).toBeVisible()
|
await expect(page.getByText('Unable to delete selection')).toBeVisible()
|
||||||
}
|
}
|
||||||
|
@ -68,13 +68,6 @@ type PWFunction = (
|
|||||||
|
|
||||||
let firstUrl = ''
|
let firstUrl = ''
|
||||||
|
|
||||||
// The below error is due to the extreme type spaghetti going on. playwright/
|
|
||||||
// types/test.d.ts does not export 2 functions (below is one of them) but tsc
|
|
||||||
// is trying to use a interface name it can't see.
|
|
||||||
// e2e/playwright/zoo-test.ts:64:14 - error TS4023: Exported variable 'test' has
|
|
||||||
// or is using name 'TestFunction' from external module
|
|
||||||
// "/home/lee/Code/Zoo/modeling-app/dirty2/node_modules/playwright/types/test"
|
|
||||||
// but cannot be named.
|
|
||||||
export const test = (
|
export const test = (
|
||||||
desc: string,
|
desc: string,
|
||||||
objOrFn: PWFunction | TestDetails,
|
objOrFn: PWFunction | TestDetails,
|
||||||
|
21
package.json
@ -40,7 +40,7 @@
|
|||||||
"codemirror": "^6.0.1",
|
"codemirror": "^6.0.1",
|
||||||
"decamelize": "^6.0.0",
|
"decamelize": "^6.0.0",
|
||||||
"diff": "^7.0.0",
|
"diff": "^7.0.0",
|
||||||
"electron-updater": "^6.5.0",
|
"electron-updater": "^6.6.0",
|
||||||
"fuse.js": "^7.0.0",
|
"fuse.js": "^7.0.0",
|
||||||
"html2canvas-pro": "^1.5.8",
|
"html2canvas-pro": "^1.5.8",
|
||||||
"isomorphic-fetch": "^3.0.0",
|
"isomorphic-fetch": "^3.0.0",
|
||||||
@ -69,10 +69,15 @@
|
|||||||
"yargs": "^17.7.2"
|
"yargs": "^17.7.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"install:rust": "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y",
|
||||||
|
"install:rust:windows": "winget install Microsoft.VisualStudio.2022.Community --silent --override \"--wait --quiet --add ProductLang En-us --add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended\" && winget install Rustlang.Rustup",
|
||||||
|
"install:wasm-pack:sh": ". $HOME/.cargo/env && curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -y",
|
||||||
|
"install:wasm-pack:cargo": "cargo install wasm-pack",
|
||||||
|
"install:tools:windows": "winget install jqlang.jq MikeFarah.yq GitHub.cli",
|
||||||
"start": "vite --port=3000 --host=0.0.0.0",
|
"start": "vite --port=3000 --host=0.0.0.0",
|
||||||
"start:prod": "vite preview --port=3000",
|
"start:prod": "vite preview --port=3000",
|
||||||
"serve": "vite serve --port=3000",
|
"serve": "vite serve --port=3000",
|
||||||
"build": "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && source \"$HOME/.cargo/env\" && curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -y && yarn build:wasm && vite build",
|
"build": "yarn install:rust && . $HOME/.cargo/env && yarn install:wasm-pack:sh && yarn build:wasm && vite build",
|
||||||
"build:local": "vite build",
|
"build:local": "vite build",
|
||||||
"build:both": "vite build",
|
"build:both": "vite build",
|
||||||
"build:both:local": "yarn build:wasm && vite build",
|
"build:both:local": "yarn build:wasm && vite build",
|
||||||
@ -84,11 +89,13 @@
|
|||||||
"simpleserver:stop": "kill-port 3000",
|
"simpleserver:stop": "kill-port 3000",
|
||||||
"fmt": "prettier --write ./src *.ts *.json *.js ./e2e ./packages",
|
"fmt": "prettier --write ./src *.ts *.json *.js ./e2e ./packages",
|
||||||
"fmt-check": "prettier --check ./src *.ts *.json *.js ./e2e ./packages",
|
"fmt-check": "prettier --check ./src *.ts *.json *.js ./e2e ./packages",
|
||||||
"fetch:wasm": "./get-latest-wasm-bundle.sh",
|
"fetch:wasm": "./scripts/get-latest-wasm-bundle.sh",
|
||||||
|
"fetch:wasm:windows": "./scripts/get-latest-wasm-bundle.ps1",
|
||||||
"fetch:samples": "echo \"Fetching latest KCL samples...\" && curl -o public/kcl-samples-manifest-fallback.json https://raw.githubusercontent.com/KittyCAD/next/manifest.json",
|
"fetch:samples": "echo \"Fetching latest KCL samples...\" && curl -o public/kcl-samples-manifest-fallback.json https://raw.githubusercontent.com/KittyCAD/next/manifest.json",
|
||||||
"isomorphic-copy-wasm": "(copy src/wasm-lib/pkg/wasm_lib_bg.wasm public || cp src/wasm-lib/pkg/wasm_lib_bg.wasm public)",
|
|
||||||
"build:wasm-dev": "yarn wasm-prep && (cd src/wasm-lib && wasm-pack build --dev --target web --out-dir pkg && cargo test -p kcl-lib export_bindings) && yarn isomorphic-copy-wasm && yarn fmt",
|
"build:wasm-dev": "yarn wasm-prep && (cd src/wasm-lib && wasm-pack build --dev --target web --out-dir pkg && cargo test -p kcl-lib export_bindings) && yarn isomorphic-copy-wasm && yarn fmt",
|
||||||
"build:wasm": "yarn wasm-prep && cd src/wasm-lib && wasm-pack build --release --target web --out-dir pkg && cargo test -p kcl-lib export_bindings && cd ../.. && yarn isomorphic-copy-wasm && yarn fmt",
|
"build:wasm:nocopy": "yarn wasm-prep && cd src/wasm-lib && wasm-pack build --release --target web --out-dir pkg && cargo test -p kcl-lib export_bindings",
|
||||||
|
"build:wasm": "yarn build:wasm:nocopy && cp src/wasm-lib/pkg/wasm_lib_bg.wasm public && yarn fmt",
|
||||||
|
"build:wasm:windows": "yarn install:wasm-pack:cargo && yarn build:wasm:nocopy && copy src\\wasm-lib\\pkg\\wasm_lib_bg.wasm public && yarn fmt",
|
||||||
"remove-importmeta": "sed -i 's/import.meta.url/window.location.origin/g' \"./src/wasm-lib/pkg/wasm_lib.js\"; sed -i '' 's/import.meta.url/window.location.origin/g' \"./src/wasm-lib/pkg/wasm_lib.js\" || echo \"sed for both mac and linux\"",
|
"remove-importmeta": "sed -i 's/import.meta.url/window.location.origin/g' \"./src/wasm-lib/pkg/wasm_lib.js\"; sed -i '' 's/import.meta.url/window.location.origin/g' \"./src/wasm-lib/pkg/wasm_lib.js\" || echo \"sed for both mac and linux\"",
|
||||||
"wasm-prep": "rimraf src/wasm-lib/pkg && mkdirp src/wasm-lib/pkg && rimraf src/wasm-lib/kcl/bindings",
|
"wasm-prep": "rimraf src/wasm-lib/pkg && mkdirp src/wasm-lib/pkg && rimraf src/wasm-lib/kcl/bindings",
|
||||||
"lint-fix": "eslint --fix --ext .ts --ext .tsx src e2e packages/codemirror-lsp-client/src",
|
"lint-fix": "eslint --fix --ext .ts --ext .tsx src e2e packages/codemirror-lsp-client/src",
|
||||||
@ -96,6 +103,7 @@
|
|||||||
"files:set-version": "echo \"$(jq --arg v \"$VERSION\" '.version=$v' package.json --indent 2)\" > package.json",
|
"files:set-version": "echo \"$(jq --arg v \"$VERSION\" '.version=$v' package.json --indent 2)\" > package.json",
|
||||||
"files:set-notes": "./scripts/set-files-notes.sh",
|
"files:set-notes": "./scripts/set-files-notes.sh",
|
||||||
"files:flip-to-nightly": "./scripts/flip-files-to-nightly.sh",
|
"files:flip-to-nightly": "./scripts/flip-files-to-nightly.sh",
|
||||||
|
"files:flip-to-nightly:windows": "./scripts/flip-files-to-nightly.ps1",
|
||||||
"files:invalidate-bucket": "./scripts/invalidate-files-bucket.sh",
|
"files:invalidate-bucket": "./scripts/invalidate-files-bucket.sh",
|
||||||
"files:invalidate-bucket:nightly": "./scripts/invalidate-files-bucket.sh --nightly",
|
"files:invalidate-bucket:nightly": "./scripts/invalidate-files-bucket.sh --nightly",
|
||||||
"postinstall": "yarn fetch:samples && yarn xstate:typegen && ./node_modules/.bin/electron-rebuild",
|
"postinstall": "yarn fetch:samples && yarn xstate:typegen && ./node_modules/.bin/electron-rebuild",
|
||||||
@ -198,7 +206,7 @@
|
|||||||
"postinstall-postinstall": "^2.1.0",
|
"postinstall-postinstall": "^2.1.0",
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^2.8.8",
|
||||||
"setimmediate": "^1.0.5",
|
"setimmediate": "^1.0.5",
|
||||||
"tailwindcss": "^3.4.1",
|
"tailwindcss": "^3.4.17",
|
||||||
"ts-node": "^10.0.0",
|
"ts-node": "^10.0.0",
|
||||||
"typescript": "^5.7.3",
|
"typescript": "^5.7.3",
|
||||||
"typescript-eslint": "^8.23.0",
|
"typescript-eslint": "^8.23.0",
|
||||||
@ -207,7 +215,6 @@
|
|||||||
"vite-tsconfig-paths": "^4.3.2",
|
"vite-tsconfig-paths": "^4.3.2",
|
||||||
"vitest": "^1.6.1",
|
"vitest": "^1.6.1",
|
||||||
"vitest-webgl-canvas-mock": "^1.1.0",
|
"vitest-webgl-canvas-mock": "^1.1.0",
|
||||||
"wasm-pack": "^0.13.1",
|
|
||||||
"ws": "^8.17.0",
|
"ws": "^8.17.0",
|
||||||
"yarn": "^1.22.22"
|
"yarn": "^1.22.22"
|
||||||
},
|
},
|
||||||
|
20
scripts/flip-files-to-nightly.ps1
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
$VERSION=$(Get-Date -Format "yy.M.d")
|
||||||
|
$COMMIT=$(git rev-parse --short HEAD)
|
||||||
|
$PRODUCT_NAME="Zoo Modeling App (Nightly)"
|
||||||
|
|
||||||
|
# package.json
|
||||||
|
yq -i '.version = env(VERSION)' -p=json -o=json package.json
|
||||||
|
yq -i '.productName = env(PRODUCT_NAME)' -p=json -o=json package.json
|
||||||
|
yq -i '.name = "zoo-modeling-app-nightly"' -p=json -o=json package.json
|
||||||
|
|
||||||
|
# electron-builder.yml
|
||||||
|
yq -i '.publish[0].url = "https://dl.zoo.dev/releases/modeling-app/nightly"' electron-builder.yml
|
||||||
|
yq -i '.appId = "dev.zoo.modeling-app-nightly"' electron-builder.yml
|
||||||
|
yq -i '.nsis.include = "./scripts/installer-nightly.nsh"' electron-builder.yml
|
||||||
|
|
||||||
|
# Release notes
|
||||||
|
echo "Nightly build $VERSION (commit $COMMIT)" > release-notes.md
|
||||||
|
|
||||||
|
# icons
|
||||||
|
cp assets/icon-nightly.png assets/icon.png
|
||||||
|
cp assets/icon-nightly.ico assets/icon.ico
|
13
scripts/get-latest-wasm-bundle.ps1
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
$REPO_OWNER = "KittyCAD"
|
||||||
|
$REPO_NAME = "modeling-app"
|
||||||
|
$WORKFLOW_NAME = "build-and-store-wasm.yml"
|
||||||
|
$ARTIFACT_NAME = "wasm-bundle"
|
||||||
|
|
||||||
|
# Fetch the latest completed workflow run ID for the specified workflow
|
||||||
|
$RUN_ID = (gh run list -w $WORKFLOW_NAME --repo $REPO_OWNER/$REPO_NAME --limit 1 --json databaseId -s completed --jq 'first | .databaseId') -join [Environment]::NewLine
|
||||||
|
|
||||||
|
$PKG_PATH="./src/wasm-lib/pkg/"
|
||||||
|
rm -r $PKG_PATH/*
|
||||||
|
gh run download $RUN_ID --repo $REPO_OWNER/$REPO_NAME --name $ARTIFACT_NAME --dir $PKG_PATH
|
||||||
|
cp $PKG_PATH/wasm_lib_bg.wasm public
|
||||||
|
echo "latest wasm copied to public folder"
|
0
get-latest-wasm-bundle.sh → scripts/get-latest-wasm-bundle.sh
Executable file → Normal file
@ -133,9 +133,11 @@ function DisplayObj({
|
|||||||
}}
|
}}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
const range = topLevelRange(obj?.start || 0, obj.end || 0)
|
const range = topLevelRange(obj?.start || 0, obj.end || 0)
|
||||||
const idInfo = codeToIdSelections([
|
const idInfo = codeToIdSelections(
|
||||||
{ codeRef: codeRefFromRange(range, kclManager.ast) },
|
[{ codeRef: codeRefFromRange(range, kclManager.ast) }],
|
||||||
])[0]
|
engineCommandManager.artifactGraph,
|
||||||
|
engineCommandManager.artifactIndex
|
||||||
|
)[0]
|
||||||
const artifact = engineCommandManager.artifactGraph.get(
|
const artifact = engineCommandManager.artifactGraph.get(
|
||||||
idInfo?.id || ''
|
idInfo?.id || ''
|
||||||
)
|
)
|
||||||
|
@ -110,6 +110,7 @@ import { commandBarActor } from 'machines/commandBarMachine'
|
|||||||
import { useToken } from 'machines/appMachine'
|
import { useToken } from 'machines/appMachine'
|
||||||
import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils'
|
import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils'
|
||||||
import { useSettings } from 'machines/appMachine'
|
import { useSettings } from 'machines/appMachine'
|
||||||
|
import { isDesktop } from 'lib/isDesktop'
|
||||||
|
|
||||||
type MachineContext<T extends AnyStateMachine> = {
|
type MachineContext<T extends AnyStateMachine> = {
|
||||||
state: StateFrom<T>
|
state: StateFrom<T>
|
||||||
@ -802,7 +803,7 @@ export const ModelingMachineProvider = ({
|
|||||||
engineCommandManager.artifactGraph
|
engineCommandManager.artifactGraph
|
||||||
)
|
)
|
||||||
if (err(plane)) return Promise.reject(plane)
|
if (err(plane)) return Promise.reject(plane)
|
||||||
// if the user selected a segment, make sure we enter the right sketch as there can be multiple on a plan
|
// if the user selected a segment, make sure we enter the right sketch as there can be multiple on a plane
|
||||||
// but still works if the user selected a plane/face by defaulting to the first path
|
// but still works if the user selected a plane/face by defaulting to the first path
|
||||||
const mainPath =
|
const mainPath =
|
||||||
artifact?.type === 'segment' || artifact?.type === 'solid2d'
|
artifact?.type === 'segment' || artifact?.type === 'solid2d'
|
||||||
@ -1717,8 +1718,12 @@ export const ModelingMachineProvider = ({
|
|||||||
previousAllowOrbitInSketchMode.current = allowOrbitInSketchMode.current
|
previousAllowOrbitInSketchMode.current = allowOrbitInSketchMode.current
|
||||||
}, [allowOrbitInSketchMode])
|
}, [allowOrbitInSketchMode])
|
||||||
|
|
||||||
// Allow using the delete key to delete solids
|
// Allow using the delete key to delete solids. Backspace only on macOS as Windows and Linux have dedicated Delete
|
||||||
useHotkeys(['backspace', 'delete', 'del'], () => {
|
const deleteKeys =
|
||||||
|
isDesktop() && window.electron.os.isMac
|
||||||
|
? ['backspace', 'delete', 'del']
|
||||||
|
: ['delete', 'del']
|
||||||
|
useHotkeys(deleteKeys, () => {
|
||||||
modelingSend({ type: 'Delete selection' })
|
modelingSend({ type: 'Delete selection' })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -374,6 +374,7 @@ export default class EditorManager {
|
|||||||
selectionRanges: this._selectionRanges,
|
selectionRanges: this._selectionRanges,
|
||||||
isShiftDown: this._isShiftDown,
|
isShiftDown: this._isShiftDown,
|
||||||
ast: kclManager.ast,
|
ast: kclManager.ast,
|
||||||
|
artifactGraph: engineCommandManager.artifactGraph,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!eventInfo) {
|
if (!eventInfo) {
|
||||||
|
@ -717,6 +717,8 @@ export function addHelix({
|
|||||||
radius,
|
radius,
|
||||||
axis,
|
axis,
|
||||||
length,
|
length,
|
||||||
|
insertIndex,
|
||||||
|
variableName,
|
||||||
}: {
|
}: {
|
||||||
node: Node<Program>
|
node: Node<Program>
|
||||||
revolutions: Expr
|
revolutions: Expr
|
||||||
@ -725,9 +727,12 @@ export function addHelix({
|
|||||||
radius: Expr
|
radius: Expr
|
||||||
axis: string
|
axis: string
|
||||||
length: Expr
|
length: Expr
|
||||||
|
insertIndex?: number
|
||||||
|
variableName?: string
|
||||||
}): { modifiedAst: Node<Program>; pathToNode: PathToNode } {
|
}): { modifiedAst: Node<Program>; pathToNode: PathToNode } {
|
||||||
const modifiedAst = structuredClone(node)
|
const modifiedAst = structuredClone(node)
|
||||||
const name = findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.HELIX)
|
const name =
|
||||||
|
variableName ?? findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.HELIX)
|
||||||
const variable = createVariableDeclaration(
|
const variable = createVariableDeclaration(
|
||||||
name,
|
name,
|
||||||
createCallExpressionStdLibKw(
|
createCallExpressionStdLibKw(
|
||||||
@ -744,12 +749,20 @@ export function addHelix({
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: figure out smart insertion than just appending at the end
|
const insertAt =
|
||||||
|
insertIndex !== undefined
|
||||||
|
? insertIndex
|
||||||
|
: modifiedAst.body.length
|
||||||
|
? modifiedAst.body.length
|
||||||
|
: 0
|
||||||
|
|
||||||
|
modifiedAst.body.length
|
||||||
|
? modifiedAst.body.splice(insertAt, 0, variable)
|
||||||
|
: modifiedAst.body.push(variable)
|
||||||
const argIndex = 0
|
const argIndex = 0
|
||||||
modifiedAst.body.push(variable)
|
|
||||||
const pathToNode: PathToNode = [
|
const pathToNode: PathToNode = [
|
||||||
['body', ''],
|
['body', ''],
|
||||||
[modifiedAst.body.length - 1, 'index'],
|
[insertAt, 'index'],
|
||||||
['declaration', 'VariableDeclaration'],
|
['declaration', 'VariableDeclaration'],
|
||||||
['init', 'VariableDeclarator'],
|
['init', 'VariableDeclarator'],
|
||||||
['arguments', 'CallExpressionKw'],
|
['arguments', 'CallExpressionKw'],
|
||||||
|
@ -31,6 +31,8 @@ import { markOnce } from 'lib/performance'
|
|||||||
import { MachineManager } from 'components/MachineManagerProvider'
|
import { MachineManager } from 'components/MachineManagerProvider'
|
||||||
import { DefaultPlaneStr } from 'lib/planes'
|
import { DefaultPlaneStr } from 'lib/planes'
|
||||||
import { defaultPlaneStrToKey } from 'lib/planes'
|
import { defaultPlaneStrToKey } from 'lib/planes'
|
||||||
|
import { buildArtifactIndex } from 'lib/artifactIndex'
|
||||||
|
import { ArtifactIndex } from 'lib/artifactIndex'
|
||||||
|
|
||||||
// TODO(paultag): This ought to be tweakable.
|
// TODO(paultag): This ought to be tweakable.
|
||||||
const pingIntervalMs = 5_000
|
const pingIntervalMs = 5_000
|
||||||
@ -1407,6 +1409,7 @@ export class EngineCommandManager extends EventTarget {
|
|||||||
* see: src/lang/std/artifactGraph-README.md for a full explanation.
|
* see: src/lang/std/artifactGraph-README.md for a full explanation.
|
||||||
*/
|
*/
|
||||||
artifactGraph: ArtifactGraph = new Map()
|
artifactGraph: ArtifactGraph = new Map()
|
||||||
|
artifactIndex: ArtifactIndex = []
|
||||||
/**
|
/**
|
||||||
* The pendingCommands object is a map of the commands that have been sent to the engine that are still waiting on a reply
|
* The pendingCommands object is a map of the commands that have been sent to the engine that are still waiting on a reply
|
||||||
*/
|
*/
|
||||||
@ -2184,6 +2187,7 @@ export class EngineCommandManager extends EventTarget {
|
|||||||
}
|
}
|
||||||
updateArtifactGraph(execStateArtifactGraph: ExecState['artifactGraph']) {
|
updateArtifactGraph(execStateArtifactGraph: ExecState['artifactGraph']) {
|
||||||
this.artifactGraph = execStateArtifactGraph
|
this.artifactGraph = execStateArtifactGraph
|
||||||
|
this.artifactIndex = buildArtifactIndex(execStateArtifactGraph)
|
||||||
// TODO check if these still need to be deferred once e2e tests are working again.
|
// TODO check if these still need to be deferred once e2e tests are working again.
|
||||||
if (this.artifactGraph.size) {
|
if (this.artifactGraph.size) {
|
||||||
this.deferredArtifactEmptied(null)
|
this.deferredArtifactEmptied(null)
|
||||||
|
29
src/lib/artifactIndex.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { ArtifactGraph, ArtifactId, SourceRange, Artifact } from 'lang/wasm'
|
||||||
|
import { getFaceCodeRef } from 'lang/std/artifactGraph'
|
||||||
|
|
||||||
|
// Index artifacts in an ordered list for binary search
|
||||||
|
export type ArtifactEntry = { artifact: Artifact; id: ArtifactId }
|
||||||
|
/** Index artifacts by their codeRef range, ordered by start position */
|
||||||
|
export type ArtifactIndex = Array<{
|
||||||
|
range: SourceRange
|
||||||
|
entry: ArtifactEntry
|
||||||
|
}>
|
||||||
|
|
||||||
|
/** Creates an array of artifacts, only those with codeRefs, orders them by start range,
|
||||||
|
* to be used later by binary search */
|
||||||
|
export function buildArtifactIndex(
|
||||||
|
artifactGraph: ArtifactGraph
|
||||||
|
): ArtifactIndex {
|
||||||
|
const index: ArtifactIndex = []
|
||||||
|
|
||||||
|
Array.from(artifactGraph).forEach(([id, artifact]) => {
|
||||||
|
const codeRef = getFaceCodeRef(artifact)
|
||||||
|
if (!codeRef?.range) return
|
||||||
|
|
||||||
|
const entry = { artifact, id }
|
||||||
|
index.push({ range: codeRef.range, entry })
|
||||||
|
})
|
||||||
|
|
||||||
|
// Sort by start position for binary search
|
||||||
|
return index.sort((a, b) => a.range[0] - b.range[0])
|
||||||
|
}
|
@ -83,6 +83,9 @@ export type ModelingCommandSchema = {
|
|||||||
distance: KclCommandValue
|
distance: KclCommandValue
|
||||||
}
|
}
|
||||||
Helix: {
|
Helix: {
|
||||||
|
// Enables editing workflow
|
||||||
|
nodeToEdit?: PathToNode
|
||||||
|
// KCL stdlib arguments
|
||||||
revolutions: KclCommandValue
|
revolutions: KclCommandValue
|
||||||
angleStart: KclCommandValue
|
angleStart: KclCommandValue
|
||||||
counterClockWise: boolean
|
counterClockWise: boolean
|
||||||
@ -472,6 +475,13 @@ export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
|
|||||||
status: 'development',
|
status: 'development',
|
||||||
needsReview: true,
|
needsReview: true,
|
||||||
args: {
|
args: {
|
||||||
|
nodeToEdit: {
|
||||||
|
description:
|
||||||
|
'Path to the node in the AST to edit. Never shown to the user.',
|
||||||
|
skip: true,
|
||||||
|
inputType: 'text',
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
revolutions: {
|
revolutions: {
|
||||||
inputType: 'kcl',
|
inputType: 'kcl',
|
||||||
defaultValue: '1',
|
defaultValue: '1',
|
||||||
@ -487,9 +497,10 @@ export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
|
|||||||
counterClockWise: {
|
counterClockWise: {
|
||||||
inputType: 'options',
|
inputType: 'options',
|
||||||
required: true,
|
required: true,
|
||||||
|
defaultValue: false,
|
||||||
options: [
|
options: [
|
||||||
{ name: 'True', isCurrent: false, value: true },
|
{ name: 'False', value: false },
|
||||||
{ name: 'False', isCurrent: true, value: false },
|
{ name: 'True', value: true },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
radius: {
|
radius: {
|
||||||
@ -500,10 +511,11 @@ export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
|
|||||||
axis: {
|
axis: {
|
||||||
inputType: 'options',
|
inputType: 'options',
|
||||||
required: true,
|
required: true,
|
||||||
|
defaultValue: 'X',
|
||||||
options: [
|
options: [
|
||||||
{ name: 'X Axis', isCurrent: true, value: 'X' },
|
{ name: 'X Axis', value: 'X' },
|
||||||
{ name: 'Y Axis', isCurrent: false, value: 'Y' },
|
{ name: 'Y Axis', value: 'Y' },
|
||||||
{ name: 'Z Axis', isCurrent: false, value: 'Z' },
|
{ name: 'Z Axis', value: 'Z' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
length: {
|
length: {
|
||||||
|
@ -191,6 +191,114 @@ const prepareToEditOffsetPlane: PrepareToEditCallback = async ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const prepareToEditHelix: PrepareToEditCallback = async ({ operation }) => {
|
||||||
|
const baseCommand = {
|
||||||
|
name: 'Helix',
|
||||||
|
groupId: 'modeling',
|
||||||
|
}
|
||||||
|
if (operation.type !== 'StdLibCall' || !operation.labeledArgs) {
|
||||||
|
return baseCommand
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: find a way to loop over the arguments while keeping it safe
|
||||||
|
// revolutions kcl arg
|
||||||
|
if (
|
||||||
|
!('revolutions' in operation.labeledArgs) ||
|
||||||
|
!operation.labeledArgs.revolutions
|
||||||
|
)
|
||||||
|
return baseCommand
|
||||||
|
const revolutions = await stringToKclExpression(
|
||||||
|
codeManager.code.slice(
|
||||||
|
operation.labeledArgs.revolutions.sourceRange[0],
|
||||||
|
operation.labeledArgs.revolutions.sourceRange[1]
|
||||||
|
),
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
if (err(revolutions) || 'errors' in revolutions) return baseCommand
|
||||||
|
|
||||||
|
// angleStart kcl arg
|
||||||
|
if (
|
||||||
|
!('angleStart' in operation.labeledArgs) ||
|
||||||
|
!operation.labeledArgs.angleStart
|
||||||
|
)
|
||||||
|
return baseCommand
|
||||||
|
const angleStart = await stringToKclExpression(
|
||||||
|
codeManager.code.slice(
|
||||||
|
operation.labeledArgs.angleStart.sourceRange[0],
|
||||||
|
operation.labeledArgs.angleStart.sourceRange[1]
|
||||||
|
),
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
if (err(angleStart) || 'errors' in angleStart) return baseCommand
|
||||||
|
|
||||||
|
// counterClockWise options boolean arg
|
||||||
|
if (
|
||||||
|
!('counterClockWise' in operation.labeledArgs) ||
|
||||||
|
!operation.labeledArgs.counterClockWise
|
||||||
|
)
|
||||||
|
return baseCommand
|
||||||
|
const counterClockWise =
|
||||||
|
codeManager.code.slice(
|
||||||
|
operation.labeledArgs.counterClockWise.sourceRange[0],
|
||||||
|
operation.labeledArgs.counterClockWise.sourceRange[1]
|
||||||
|
) === 'true'
|
||||||
|
|
||||||
|
// radius kcl arg
|
||||||
|
if (!('radius' in operation.labeledArgs) || !operation.labeledArgs.radius)
|
||||||
|
return baseCommand
|
||||||
|
const radius = await stringToKclExpression(
|
||||||
|
codeManager.code.slice(
|
||||||
|
operation.labeledArgs.radius.sourceRange[0],
|
||||||
|
operation.labeledArgs.radius.sourceRange[1]
|
||||||
|
),
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
if (err(radius) || 'errors' in radius) return baseCommand
|
||||||
|
|
||||||
|
// axis options string arg
|
||||||
|
if (!('axis' in operation.labeledArgs) || !operation.labeledArgs.axis)
|
||||||
|
return baseCommand
|
||||||
|
const axis = codeManager.code
|
||||||
|
.slice(
|
||||||
|
operation.labeledArgs.axis.sourceRange[0],
|
||||||
|
operation.labeledArgs.axis.sourceRange[1]
|
||||||
|
)
|
||||||
|
.replaceAll("'", '') // TODO: fix this crap
|
||||||
|
|
||||||
|
// length kcl arg
|
||||||
|
if (!('length' in operation.labeledArgs) || !operation.labeledArgs.length)
|
||||||
|
return baseCommand
|
||||||
|
const length = await stringToKclExpression(
|
||||||
|
codeManager.code.slice(
|
||||||
|
operation.labeledArgs.length.sourceRange[0],
|
||||||
|
operation.labeledArgs.length.sourceRange[1]
|
||||||
|
),
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
if (err(length) || 'errors' in length) return baseCommand
|
||||||
|
|
||||||
|
// Assemble the default argument values for the Offset Plane command,
|
||||||
|
// with `nodeToEdit` set, which will let the Offset Plane actor know
|
||||||
|
// to edit the node that corresponds to the StdLibCall.
|
||||||
|
const argDefaultValues: ModelingCommandSchema['Helix'] = {
|
||||||
|
revolutions,
|
||||||
|
angleStart,
|
||||||
|
counterClockWise,
|
||||||
|
radius,
|
||||||
|
axis,
|
||||||
|
length,
|
||||||
|
nodeToEdit: getNodePathFromSourceRange(
|
||||||
|
kclManager.ast,
|
||||||
|
sourceRangeFromRust(operation.sourceRange)
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...baseCommand,
|
||||||
|
argDefaultValues,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A map of standard library calls to their corresponding information
|
* A map of standard library calls to their corresponding information
|
||||||
* for use in the feature tree UI.
|
* for use in the feature tree UI.
|
||||||
@ -214,6 +322,7 @@ export const stdLibMap: Record<string, StdLibCallInfo> = {
|
|||||||
helix: {
|
helix: {
|
||||||
label: 'Helix',
|
label: 'Helix',
|
||||||
icon: 'helix',
|
icon: 'helix',
|
||||||
|
prepareToEdit: prepareToEditHelix,
|
||||||
},
|
},
|
||||||
hole: {
|
hole: {
|
||||||
label: 'Hole',
|
label: 'Hole',
|
||||||
|
1298
src/lib/selections.test.ts
Normal file
@ -11,6 +11,7 @@ import {
|
|||||||
Expr,
|
Expr,
|
||||||
defaultSourceRange,
|
defaultSourceRange,
|
||||||
topLevelRange,
|
topLevelRange,
|
||||||
|
ArtifactGraph,
|
||||||
} from 'lang/wasm'
|
} from 'lang/wasm'
|
||||||
import { ModelingMachineEvent } from 'machines/modelingMachine'
|
import { ModelingMachineEvent } from 'machines/modelingMachine'
|
||||||
import { isNonNullable, uuidv4 } from 'lib/utils'
|
import { isNonNullable, uuidv4 } from 'lib/utils'
|
||||||
@ -31,19 +32,13 @@ import { PathToNodeMap } from 'lang/std/sketchcombos'
|
|||||||
import { err } from 'lib/trap'
|
import { err } from 'lib/trap'
|
||||||
import {
|
import {
|
||||||
Artifact,
|
Artifact,
|
||||||
getArtifactOfTypes,
|
|
||||||
getArtifactsOfTypes,
|
|
||||||
getCapCodeRef,
|
|
||||||
getSweepEdgeCodeRef,
|
|
||||||
getSolid2dCodeRef,
|
|
||||||
getWallCodeRef,
|
|
||||||
CodeRef,
|
CodeRef,
|
||||||
getCodeRefsByArtifactId,
|
getCodeRefsByArtifactId,
|
||||||
ArtifactId,
|
ArtifactId,
|
||||||
getFaceCodeRef,
|
|
||||||
} from 'lang/std/artifactGraph'
|
} from 'lang/std/artifactGraph'
|
||||||
import { Node } from 'wasm-lib/kcl/bindings/Node'
|
import { Node } from 'wasm-lib/kcl/bindings/Node'
|
||||||
import { DefaultPlaneStr } from './planes'
|
import { DefaultPlaneStr } from './planes'
|
||||||
|
import { ArtifactEntry, ArtifactIndex } from './artifactIndex'
|
||||||
|
|
||||||
export const X_AXIS_UUID = 'ad792545-7fd3-482a-a602-a93924e3055b'
|
export const X_AXIS_UUID = 'ad792545-7fd3-482a-a602-a93924e3055b'
|
||||||
export const Y_AXIS_UUID = '680fd157-266f-4b8a-984f-cdf46b8bdf01'
|
export const Y_AXIS_UUID = '680fd157-266f-4b8a-984f-cdf46b8bdf01'
|
||||||
@ -54,38 +49,7 @@ export type DefaultPlaneSelection = {
|
|||||||
id: string
|
id: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @deprecated Use {@link Artifact} instead. */
|
|
||||||
type Selection__old =
|
|
||||||
| {
|
|
||||||
type:
|
|
||||||
| 'default'
|
|
||||||
| 'line-end'
|
|
||||||
| 'line-mid'
|
|
||||||
| 'extrude-wall'
|
|
||||||
| 'solid2d'
|
|
||||||
| 'start-cap'
|
|
||||||
| 'end-cap'
|
|
||||||
| 'point'
|
|
||||||
| 'edge'
|
|
||||||
| 'adjacent-edge'
|
|
||||||
| 'line'
|
|
||||||
| 'arc'
|
|
||||||
| 'all'
|
|
||||||
range: SourceRange
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: 'opposite-edgeCut' | 'adjacent-edgeCut' | 'base-edgeCut'
|
|
||||||
range: SourceRange
|
|
||||||
// TODO this is a temporary measure that well be made redundant with: https://github.com/KittyCAD/modeling-app/pull/3836
|
|
||||||
secondaryRange: SourceRange
|
|
||||||
}
|
|
||||||
export type NonCodeSelection = Axis | DefaultPlaneSelection
|
export type NonCodeSelection = Axis | DefaultPlaneSelection
|
||||||
|
|
||||||
/** @deprecated Use {@link Selection} instead. */
|
|
||||||
export type Selections__old = {
|
|
||||||
otherSelections: NonCodeSelection[]
|
|
||||||
codeBasedSelections: Selection__old[]
|
|
||||||
}
|
|
||||||
export interface Selection {
|
export interface Selection {
|
||||||
artifact?: Artifact
|
artifact?: Artifact
|
||||||
codeRef: CodeRef
|
codeRef: CodeRef
|
||||||
@ -95,76 +59,6 @@ export type Selections = {
|
|||||||
graphSelections: Array<Selection>
|
graphSelections: Array<Selection>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @deprecated If you're writing a new function, it should use {@link Selection} and not {@link Selection__old}
|
|
||||||
* this function should only be used for backwards compatibility with old functions.
|
|
||||||
*/
|
|
||||||
function convertSelectionToOld(selection: Selection): Selection__old | null {
|
|
||||||
// return {} as Selection__old
|
|
||||||
// TODO implementation
|
|
||||||
const _artifact = selection.artifact
|
|
||||||
if (_artifact?.type === 'solid2d') {
|
|
||||||
const codeRef = getSolid2dCodeRef(
|
|
||||||
_artifact,
|
|
||||||
engineCommandManager.artifactGraph
|
|
||||||
)
|
|
||||||
if (err(codeRef)) return null
|
|
||||||
return { range: codeRef.range, type: 'solid2d' }
|
|
||||||
}
|
|
||||||
if (_artifact?.type === 'cap') {
|
|
||||||
const codeRef = getCapCodeRef(_artifact, engineCommandManager.artifactGraph)
|
|
||||||
if (err(codeRef)) return null
|
|
||||||
return {
|
|
||||||
range: codeRef.range,
|
|
||||||
type: _artifact?.subType === 'end' ? 'end-cap' : 'start-cap',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (_artifact?.type === 'wall') {
|
|
||||||
const codeRef = getWallCodeRef(
|
|
||||||
_artifact,
|
|
||||||
engineCommandManager.artifactGraph
|
|
||||||
)
|
|
||||||
if (err(codeRef)) return null
|
|
||||||
return { range: codeRef.range, type: 'extrude-wall' }
|
|
||||||
}
|
|
||||||
if (_artifact?.type === 'segment' || _artifact?.type === 'path') {
|
|
||||||
return { range: _artifact.codeRef.range, type: 'default' }
|
|
||||||
}
|
|
||||||
if (_artifact?.type === 'sweepEdge') {
|
|
||||||
const codeRef = getSweepEdgeCodeRef(
|
|
||||||
_artifact,
|
|
||||||
engineCommandManager.artifactGraph
|
|
||||||
)
|
|
||||||
if (err(codeRef)) return null
|
|
||||||
if (_artifact?.subType === 'adjacent') {
|
|
||||||
return { range: codeRef.range, type: 'adjacent-edge' }
|
|
||||||
}
|
|
||||||
return { range: codeRef.range, type: 'edge' }
|
|
||||||
}
|
|
||||||
if (_artifact?.type === 'edgeCut') {
|
|
||||||
const codeRef = _artifact.codeRef
|
|
||||||
return { range: codeRef.range, type: 'default' }
|
|
||||||
}
|
|
||||||
if (selection?.codeRef?.range) {
|
|
||||||
return { range: selection.codeRef.range, type: 'default' }
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
/** @deprecated If you're writing a new function, it should use {@link Selection} and not {@link Selection__old}
|
|
||||||
* this function should only be used for backwards compatibility with old functions.
|
|
||||||
*/
|
|
||||||
export function convertSelectionsToOld(selection: Selections): Selections__old {
|
|
||||||
const selections: Selection__old[] = []
|
|
||||||
for (const artifact of selection.graphSelections) {
|
|
||||||
const converted = convertSelectionToOld(artifact)
|
|
||||||
if (converted) selections.push(converted)
|
|
||||||
}
|
|
||||||
const selectionsOld: Selections__old = {
|
|
||||||
otherSelections: selection.otherSelections,
|
|
||||||
codeBasedSelections: selections,
|
|
||||||
}
|
|
||||||
return selectionsOld
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getEventForSelectWithPoint({
|
export async function getEventForSelectWithPoint({
|
||||||
data,
|
data,
|
||||||
}: Extract<
|
}: Extract<
|
||||||
@ -310,7 +204,6 @@ export function handleSelectionBatch({
|
|||||||
selections.graphSelections.forEach(({ artifact }) => {
|
selections.graphSelections.forEach(({ artifact }) => {
|
||||||
artifact?.id &&
|
artifact?.id &&
|
||||||
selectionToEngine.push({
|
selectionToEngine.push({
|
||||||
type: 'default',
|
|
||||||
id: artifact?.id,
|
id: artifact?.id,
|
||||||
range:
|
range:
|
||||||
getCodeRefsByArtifactId(
|
getCodeRefsByArtifactId(
|
||||||
@ -350,7 +243,6 @@ export function handleSelectionBatch({
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SelectionToEngine = {
|
type SelectionToEngine = {
|
||||||
type: Selection__old['type']
|
|
||||||
id?: string
|
id?: string
|
||||||
range: SourceRange
|
range: SourceRange
|
||||||
}
|
}
|
||||||
@ -360,11 +252,13 @@ export function processCodeMirrorRanges({
|
|||||||
selectionRanges,
|
selectionRanges,
|
||||||
isShiftDown,
|
isShiftDown,
|
||||||
ast,
|
ast,
|
||||||
|
artifactGraph,
|
||||||
}: {
|
}: {
|
||||||
codeMirrorRanges: readonly SelectionRange[]
|
codeMirrorRanges: readonly SelectionRange[]
|
||||||
selectionRanges: Selections
|
selectionRanges: Selections
|
||||||
isShiftDown: boolean
|
isShiftDown: boolean
|
||||||
ast: Program
|
ast: Program
|
||||||
|
artifactGraph: ArtifactGraph
|
||||||
}): null | {
|
}): null | {
|
||||||
modelingEvent: ModelingMachineEvent
|
modelingEvent: ModelingMachineEvent
|
||||||
engineEvents: Models['WebSocketRequest_type'][]
|
engineEvents: Models['WebSocketRequest_type'][]
|
||||||
@ -392,8 +286,11 @@ export function processCodeMirrorRanges({
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const idBasedSelections: SelectionToEngine[] =
|
const idBasedSelections: SelectionToEngine[] = codeToIdSelections(
|
||||||
codeToIdSelections(codeBasedSelections)
|
codeBasedSelections,
|
||||||
|
artifactGraph,
|
||||||
|
engineCommandManager.artifactIndex
|
||||||
|
)
|
||||||
const selections: Selection[] = []
|
const selections: Selection[] = []
|
||||||
for (const { id, range } of idBasedSelections) {
|
for (const { id, range } of idBasedSelections) {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
@ -406,11 +303,8 @@ export function processCodeMirrorRanges({
|
|||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
const artifact = engineCommandManager.artifactGraph.get(id)
|
const artifact = artifactGraph.get(id)
|
||||||
const codeRefs = getCodeRefsByArtifactId(
|
const codeRefs = getCodeRefsByArtifactId(id, artifactGraph)
|
||||||
id,
|
|
||||||
engineCommandManager.artifactGraph
|
|
||||||
)
|
|
||||||
if (artifact && codeRefs) {
|
if (artifact && codeRefs) {
|
||||||
selections.push({ artifact, codeRef: codeRefs[0] })
|
selections.push({ artifact, codeRef: codeRefs[0] })
|
||||||
} else if (codeRefs) {
|
} else if (codeRefs) {
|
||||||
@ -601,234 +495,150 @@ export function canSubmitSelectionArg(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function codeToIdSelections(
|
/**
|
||||||
selections: Selection[]
|
* Find the index of the last range where range[0] < targetStart
|
||||||
): SelectionToEngine[] {
|
* This is used as a starting point for linear search of overlapping ranges
|
||||||
const selectionsOld = convertSelectionsToOld({
|
* @param index The sorted array of ranges to search through
|
||||||
graphSelections: selections,
|
* @param targetStart The start position to compare against
|
||||||
otherSelections: [],
|
* @returns The index of the last range where range[0] < targetStart
|
||||||
}).codeBasedSelections
|
*/
|
||||||
return selectionsOld
|
export function findLastRangeStartingBefore(
|
||||||
.flatMap((selection): null | SelectionToEngine[] => {
|
index: ArtifactIndex,
|
||||||
const { type } = selection
|
targetStart: number
|
||||||
// TODO #868: loops over all artifacts will become inefficient at a large scale
|
): number {
|
||||||
const overlappingEntries = Array.from(engineCommandManager.artifactGraph)
|
let left = 0
|
||||||
.map(([id, artifact]) => {
|
let right = index.length - 1
|
||||||
const codeRef = getFaceCodeRef(artifact)
|
let lastValidIndex = 0
|
||||||
if (!codeRef) return null
|
|
||||||
return isOverlap(codeRef.range, selection.range)
|
|
||||||
? {
|
|
||||||
artifact,
|
|
||||||
selection,
|
|
||||||
id,
|
|
||||||
}
|
|
||||||
: null
|
|
||||||
})
|
|
||||||
.filter(isNonNullable)
|
|
||||||
|
|
||||||
/** TODO refactor
|
while (left <= right) {
|
||||||
* selections in our app is a sourceRange plus some metadata
|
const mid = left + Math.floor((right - left) / 2)
|
||||||
* The metadata is just a union type string of different types of artifacts or 3d features 'extrude-wall' 'segment' etc
|
const midRange = index[mid].range
|
||||||
* Because the source range is not enough to figure out what the user selected, so here we're using filtering through all the artifacts
|
|
||||||
* to find something that matches both the source range and the metadata.
|
|
||||||
*
|
|
||||||
* What we should migrate to is just storing what the user selected by what it matched in the artifactGraph it will simply the below a lot.
|
|
||||||
*
|
|
||||||
* In the case of a user moving the cursor them, we will still need to figure out what artifact from the graph matches best, but we will just need sane defaults
|
|
||||||
* and most of the time we can expect the user to be clicking in the 3d scene instead.
|
|
||||||
*/
|
|
||||||
let bestCandidate:
|
|
||||||
| {
|
|
||||||
id: ArtifactId
|
|
||||||
artifact: unknown
|
|
||||||
selection: Selection__old
|
|
||||||
}
|
|
||||||
| undefined
|
|
||||||
overlappingEntries.forEach((entry) => {
|
|
||||||
// TODO probably need to remove much of the `type === 'xyz'` below
|
|
||||||
if (type === 'default' && entry.artifact.type === 'segment') {
|
|
||||||
bestCandidate = entry
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (entry.artifact.type === 'path') {
|
|
||||||
const artifact = engineCommandManager.artifactGraph.get(
|
|
||||||
entry.artifact.solid2dId || ''
|
|
||||||
)
|
|
||||||
if (artifact?.type !== 'solid2d') {
|
|
||||||
bestCandidate = {
|
|
||||||
artifact: entry.artifact,
|
|
||||||
selection,
|
|
||||||
id: entry.id,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!entry.artifact.solid2dId) {
|
|
||||||
console.error(
|
|
||||||
'Expected PathArtifact to have solid2dId, but none found'
|
|
||||||
)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
bestCandidate = {
|
|
||||||
artifact: artifact,
|
|
||||||
selection,
|
|
||||||
id: entry.artifact.solid2dId,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (entry.artifact.type === 'plane') {
|
|
||||||
bestCandidate = {
|
|
||||||
artifact: entry.artifact,
|
|
||||||
selection,
|
|
||||||
id: entry.id,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (entry.artifact.type === 'cap') {
|
|
||||||
bestCandidate = {
|
|
||||||
artifact: entry.artifact,
|
|
||||||
selection,
|
|
||||||
id: entry.id,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (entry.artifact.type === 'wall') {
|
|
||||||
bestCandidate = {
|
|
||||||
artifact: entry.artifact,
|
|
||||||
selection,
|
|
||||||
id: entry.id,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (type === 'extrude-wall' && entry.artifact.type === 'segment') {
|
|
||||||
if (!entry.artifact.surfaceId) return
|
|
||||||
const wall = engineCommandManager.artifactGraph.get(
|
|
||||||
entry.artifact.surfaceId
|
|
||||||
)
|
|
||||||
if (wall?.type !== 'wall') return
|
|
||||||
bestCandidate = {
|
|
||||||
artifact: wall,
|
|
||||||
selection,
|
|
||||||
id: entry.artifact.surfaceId,
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (type === 'edge' && entry.artifact.type === 'segment') {
|
|
||||||
const edges = getArtifactsOfTypes(
|
|
||||||
{ keys: entry.artifact.edgeIds, types: ['sweepEdge'] },
|
|
||||||
engineCommandManager.artifactGraph
|
|
||||||
)
|
|
||||||
const edge = [...edges].find(([_, edge]) => edge.type === 'sweepEdge')
|
|
||||||
if (!edge) return
|
|
||||||
bestCandidate = {
|
|
||||||
artifact: edge[1],
|
|
||||||
selection,
|
|
||||||
id: edge[0],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (type === 'adjacent-edge' && entry.artifact.type === 'segment') {
|
|
||||||
const edges = getArtifactsOfTypes(
|
|
||||||
{ keys: entry.artifact.edgeIds, types: ['sweepEdge'] },
|
|
||||||
engineCommandManager.artifactGraph
|
|
||||||
)
|
|
||||||
const edge = [...edges].find(
|
|
||||||
([_, edge]) =>
|
|
||||||
edge.type === 'sweepEdge' && edge.subType === 'adjacent'
|
|
||||||
)
|
|
||||||
if (!edge) return
|
|
||||||
bestCandidate = {
|
|
||||||
artifact: edge[1],
|
|
||||||
selection,
|
|
||||||
id: edge[0],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
(type === 'end-cap' || type === 'start-cap') &&
|
|
||||||
entry.artifact.type === 'path'
|
|
||||||
) {
|
|
||||||
if (!entry.artifact.sweepId) return
|
|
||||||
const extrusion = getArtifactOfTypes(
|
|
||||||
{
|
|
||||||
key: entry.artifact.sweepId,
|
|
||||||
types: ['sweep'],
|
|
||||||
},
|
|
||||||
engineCommandManager.artifactGraph
|
|
||||||
)
|
|
||||||
if (err(extrusion)) return
|
|
||||||
const caps = getArtifactsOfTypes(
|
|
||||||
{ keys: extrusion.surfaceIds, types: ['cap'] },
|
|
||||||
engineCommandManager.artifactGraph
|
|
||||||
)
|
|
||||||
const cap = [...caps].find(
|
|
||||||
([_, cap]) => cap.subType === (type === 'end-cap' ? 'end' : 'start')
|
|
||||||
)
|
|
||||||
if (!cap) return
|
|
||||||
bestCandidate = {
|
|
||||||
artifact: entry.artifact,
|
|
||||||
selection,
|
|
||||||
id: cap[0],
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (entry.artifact.type === 'edgeCut') {
|
|
||||||
const consumedEdge = getArtifactOfTypes(
|
|
||||||
{
|
|
||||||
key: entry.artifact.consumedEdgeId,
|
|
||||||
types: ['segment', 'sweepEdge'],
|
|
||||||
},
|
|
||||||
engineCommandManager.artifactGraph
|
|
||||||
)
|
|
||||||
if (err(consumedEdge)) return
|
|
||||||
if (
|
|
||||||
consumedEdge.type === 'segment' &&
|
|
||||||
type === 'base-edgeCut' &&
|
|
||||||
isOverlap(
|
|
||||||
consumedEdge.codeRef.range,
|
|
||||||
selection.secondaryRange || [0, 0]
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
bestCandidate = {
|
|
||||||
artifact: entry.artifact,
|
|
||||||
selection,
|
|
||||||
id: entry.id,
|
|
||||||
}
|
|
||||||
} else if (
|
|
||||||
consumedEdge.type === 'sweepEdge' &&
|
|
||||||
((type === 'adjacent-edgeCut' &&
|
|
||||||
consumedEdge.subType === 'adjacent') ||
|
|
||||||
(type === 'opposite-edgeCut' &&
|
|
||||||
consumedEdge.subType === 'opposite'))
|
|
||||||
) {
|
|
||||||
const seg = getArtifactOfTypes(
|
|
||||||
{ key: consumedEdge.segId, types: ['segment'] },
|
|
||||||
engineCommandManager.artifactGraph
|
|
||||||
)
|
|
||||||
if (err(seg)) return
|
|
||||||
if (
|
|
||||||
isOverlap(seg.codeRef.range, selection.secondaryRange || [0, 0])
|
|
||||||
) {
|
|
||||||
bestCandidate = {
|
|
||||||
artifact: entry.artifact,
|
|
||||||
selection,
|
|
||||||
id: entry.id,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entry.artifact.type === 'sweep') {
|
if (midRange[0] < targetStart) {
|
||||||
bestCandidate = {
|
// This range starts before our selection, look in right half for later ones
|
||||||
artifact: entry.artifact,
|
lastValidIndex = mid
|
||||||
selection,
|
left = mid + 1
|
||||||
id: entry.id,
|
} else {
|
||||||
}
|
// This range starts at or after our selection, look in left half
|
||||||
}
|
right = mid - 1
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (bestCandidate) {
|
return lastValidIndex
|
||||||
return [
|
}
|
||||||
{
|
|
||||||
type,
|
function findOverlappingArtifactsFromIndex(
|
||||||
id: bestCandidate.id,
|
selection: Selection,
|
||||||
range: bestCandidate.selection.range,
|
index: ArtifactIndex
|
||||||
},
|
): ArtifactEntry[] {
|
||||||
]
|
if (!selection.codeRef?.range) {
|
||||||
|
console.warn('Selection missing code reference range')
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectionRange = selection.codeRef.range
|
||||||
|
const results: ArtifactEntry[] = []
|
||||||
|
|
||||||
|
// Binary search to find the last range where range[0] < selectionRange[0]
|
||||||
|
// This search does not take into consideration the end range, so it's possible
|
||||||
|
// the index it finds dose not have any overlap (depending on the end range)
|
||||||
|
// but it's main purpose is to act as a starting point for the linear part of the search
|
||||||
|
// so a tiny loss in efficiency is acceptable to keep the code simple
|
||||||
|
const startIndex = findLastRangeStartingBefore(index, selectionRange[0])
|
||||||
|
|
||||||
|
// Check all potential overlaps from the found position
|
||||||
|
for (let i = startIndex; i < index.length; i++) {
|
||||||
|
const { range, entry } = index[i]
|
||||||
|
// Stop if we've gone past possible overlaps
|
||||||
|
if (range[0] > selectionRange[1]) break
|
||||||
|
|
||||||
|
if (isOverlap(range, selectionRange)) {
|
||||||
|
results.push(entry)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBestCandidate(
|
||||||
|
entries: ArtifactEntry[],
|
||||||
|
artifactGraph: ArtifactGraph
|
||||||
|
): ArtifactEntry | undefined {
|
||||||
|
if (!entries.length) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const entry of entries) {
|
||||||
|
// Segments take precedence
|
||||||
|
if (entry.artifact.type === 'segment') {
|
||||||
|
return entry
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle paths and their solid2d references
|
||||||
|
if (entry.artifact.type === 'path') {
|
||||||
|
const solid2dId = entry.artifact.solid2dId
|
||||||
|
if (!solid2dId) {
|
||||||
|
return entry
|
||||||
}
|
}
|
||||||
return [selection]
|
const solid2d = artifactGraph.get(solid2dId)
|
||||||
|
if (solid2d?.type === 'solid2d') {
|
||||||
|
return { id: solid2dId, artifact: solid2d }
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Other valid artifact types
|
||||||
|
if (['plane', 'cap', 'wall', 'sweep'].includes(entry.artifact.type)) {
|
||||||
|
return entry
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
function createSelectionToEngine(
|
||||||
|
selection: Selection,
|
||||||
|
candidateId?: ArtifactId
|
||||||
|
): SelectionToEngine {
|
||||||
|
return {
|
||||||
|
...(candidateId && { id: candidateId }),
|
||||||
|
range: selection.codeRef.range,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function codeToIdSelections(
|
||||||
|
selections: Selection[],
|
||||||
|
artifactGraph: ArtifactGraph,
|
||||||
|
artifactIndex: ArtifactIndex
|
||||||
|
): SelectionToEngine[] {
|
||||||
|
if (!selections?.length) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!artifactGraph) {
|
||||||
|
console.warn('Artifact graph is missing or empty')
|
||||||
|
return selections.map((selection) => createSelectionToEngine(selection))
|
||||||
|
}
|
||||||
|
|
||||||
|
return selections
|
||||||
|
.flatMap((selection): SelectionToEngine[] => {
|
||||||
|
if (!selection) {
|
||||||
|
console.warn('Null or undefined selection encountered')
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
// Direct artifact case
|
||||||
|
if (selection.artifact?.id) {
|
||||||
|
return [createSelectionToEngine(selection, selection.artifact.id)]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find matching artifacts by code range overlap
|
||||||
|
const overlappingEntries = findOverlappingArtifactsFromIndex(
|
||||||
|
selection,
|
||||||
|
artifactIndex
|
||||||
|
)
|
||||||
|
const bestCandidate = getBestCandidate(overlappingEntries, artifactGraph)
|
||||||
|
|
||||||
|
return [createSelectionToEngine(selection, bestCandidate?.id)]
|
||||||
})
|
})
|
||||||
.filter(isNonNullable)
|
.filter(isNonNullable)
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
|||||||
}),
|
}),
|
||||||
icon: 'sparkles',
|
icon: 'sparkles',
|
||||||
status: 'available',
|
status: 'available',
|
||||||
title: 'Text-to-CAD',
|
title: 'Create with AI',
|
||||||
description: 'Generate geometry from a text prompt.',
|
description: 'Generate geometry from a text prompt.',
|
||||||
links: [
|
links: [
|
||||||
{
|
{
|
||||||
@ -330,7 +330,7 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
|||||||
}),
|
}),
|
||||||
icon: 'sparkles',
|
icon: 'sparkles',
|
||||||
status: 'available',
|
status: 'available',
|
||||||
title: 'Prompt-to-Edit',
|
title: 'Edit with AI',
|
||||||
description: 'Edit geometry based on a text prompt.',
|
description: 'Edit geometry based on a text prompt.',
|
||||||
links: [],
|
links: [],
|
||||||
},
|
},
|
||||||
|
@ -5,7 +5,6 @@ import {
|
|||||||
CommandArgumentWithName,
|
CommandArgumentWithName,
|
||||||
KclCommandValue,
|
KclCommandValue,
|
||||||
} from 'lib/commandTypes'
|
} from 'lib/commandTypes'
|
||||||
import { Selections__old } from 'lib/selections'
|
|
||||||
import { getCommandArgumentKclValuesOnly } from 'lib/commandUtils'
|
import { getCommandArgumentKclValuesOnly } from 'lib/commandUtils'
|
||||||
import { MachineManager } from 'components/MachineManagerProvider'
|
import { MachineManager } from 'components/MachineManagerProvider'
|
||||||
import toast from 'react-hot-toast'
|
import toast from 'react-hot-toast'
|
||||||
@ -16,7 +15,6 @@ export type CommandBarContext = {
|
|||||||
commands: Command[]
|
commands: Command[]
|
||||||
selectedCommand?: Command
|
selectedCommand?: Command
|
||||||
currentArgument?: CommandArgument<unknown> & { name: string }
|
currentArgument?: CommandArgument<unknown> & { name: string }
|
||||||
selectionRanges: Selections__old
|
|
||||||
argumentsToSubmit: { [x: string]: unknown }
|
argumentsToSubmit: { [x: string]: unknown }
|
||||||
machineManager: MachineManager
|
machineManager: MachineManager
|
||||||
}
|
}
|
||||||
|
@ -1801,8 +1801,32 @@ export const modelingMachine = setup({
|
|||||||
radius,
|
radius,
|
||||||
axis,
|
axis,
|
||||||
length,
|
length,
|
||||||
|
nodeToEdit,
|
||||||
} = input
|
} = input
|
||||||
|
|
||||||
|
let opInsertIndex: number | undefined = undefined
|
||||||
|
let opVariableName: string | undefined = undefined
|
||||||
|
|
||||||
|
// If this is an edit flow, first we're going to remove the old one
|
||||||
|
if (nodeToEdit && typeof nodeToEdit[1][0] === 'number') {
|
||||||
|
// Extract the old name from the node to edit
|
||||||
|
const oldNode = getNodeFromPath<VariableDeclaration>(
|
||||||
|
ast,
|
||||||
|
nodeToEdit,
|
||||||
|
'VariableDeclaration'
|
||||||
|
)
|
||||||
|
if (err(oldNode)) {
|
||||||
|
console.error('Error extracting plane name')
|
||||||
|
} else {
|
||||||
|
opVariableName = oldNode.node.declaration.id.name
|
||||||
|
}
|
||||||
|
|
||||||
|
const newBody = [...ast.body]
|
||||||
|
newBody.splice(nodeToEdit[1][0], 1)
|
||||||
|
ast.body = newBody
|
||||||
|
opInsertIndex = nodeToEdit[1][0]
|
||||||
|
}
|
||||||
|
|
||||||
for (const variable of [revolutions, angleStart, radius, length]) {
|
for (const variable of [revolutions, angleStart, radius, length]) {
|
||||||
// Insert the variable if it exists
|
// Insert the variable if it exists
|
||||||
if (
|
if (
|
||||||
@ -1833,6 +1857,8 @@ export const modelingMachine = setup({
|
|||||||
radius: valueOrVariable(radius),
|
radius: valueOrVariable(radius),
|
||||||
axis,
|
axis,
|
||||||
length: valueOrVariable(length),
|
length: valueOrVariable(length),
|
||||||
|
insertIndex: opInsertIndex,
|
||||||
|
variableName: opVariableName,
|
||||||
})
|
})
|
||||||
|
|
||||||
const updateAstResult = await kclManager.updateAst(
|
const updateAstResult = await kclManager.updateAst(
|
||||||
|
@ -538,7 +538,16 @@ export const settingsMachine = setup({
|
|||||||
src: 'loadUserSettings',
|
src: 'loadUserSettings',
|
||||||
onDone: {
|
onDone: {
|
||||||
target: 'idle',
|
target: 'idle',
|
||||||
actions: 'setAllSettings',
|
actions: [
|
||||||
|
'setAllSettings',
|
||||||
|
'setThemeClass',
|
||||||
|
'setEngineTheme',
|
||||||
|
'setClientSideSceneUnits',
|
||||||
|
'setThemeColor',
|
||||||
|
'setClientTheme',
|
||||||
|
'setAllowOrbitInSketchMode',
|
||||||
|
'sendThemeToWatcher',
|
||||||
|
],
|
||||||
},
|
},
|
||||||
onError: {
|
onError: {
|
||||||
target: 'idle',
|
target: 'idle',
|
||||||
@ -561,8 +570,14 @@ export const settingsMachine = setup({
|
|||||||
target: 'idle',
|
target: 'idle',
|
||||||
actions: [
|
actions: [
|
||||||
'setAllSettings',
|
'setAllSettings',
|
||||||
|
'setThemeClass',
|
||||||
|
'setEngineTheme',
|
||||||
|
'setClientSideSceneUnits',
|
||||||
'setThemeColor',
|
'setThemeColor',
|
||||||
'Execute AST',
|
'Execute AST',
|
||||||
|
'setClientTheme',
|
||||||
|
'setAllowOrbitInSketchMode',
|
||||||
|
'sendThemeToWatcher',
|
||||||
sendTo('registerCommands', { type: 'update' }),
|
sendTo('registerCommands', { type: 'update' }),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
24
src/wasm-lib/Cargo.lock
generated
@ -122,9 +122,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.95"
|
version = "1.0.96"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
|
checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
]
|
]
|
||||||
@ -1858,9 +1858,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kittycad-modeling-cmds"
|
name = "kittycad-modeling-cmds"
|
||||||
version = "0.2.97"
|
version = "0.2.99"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6c37ad10b8a2afdcd1852d027f123cf4e38864ea93e0fda5c7ee1e8a49af49fb"
|
checksum = "828a0c74476533e6258ea7dd70cfc7d63a5df4b37753d30ef198e0689eaac4eb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
@ -3245,9 +3245,9 @@ checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.217"
|
version = "1.0.218"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70"
|
checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
@ -3263,9 +3263,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.217"
|
version = "1.0.218"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0"
|
checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -3285,9 +3285,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.138"
|
version = "1.0.139"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949"
|
checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap 2.7.1",
|
"indexmap 2.7.1",
|
||||||
"itoa",
|
"itoa",
|
||||||
@ -4208,9 +4208,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
version = "1.13.1"
|
version = "1.14.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ced87ca4be083373936a67f8de945faa23b6b42384bd5b64434850802c6dccd0"
|
checksum = "93d59ca99a559661b96bf898d8fce28ed87935fd2bea9f05983c1464dd6c71b1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.3.1",
|
"getrandom 0.3.1",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
|
@ -80,7 +80,7 @@ members = [
|
|||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
http = "1"
|
http = "1"
|
||||||
kittycad = { version = "0.3.28", default-features = false, features = ["js", "requests"] }
|
kittycad = { version = "0.3.28", default-features = false, features = ["js", "requests"] }
|
||||||
kittycad-modeling-cmds = { version = "0.2.97", features = [
|
kittycad-modeling-cmds = { version = "0.2.99", features = [
|
||||||
"ts-rs",
|
"ts-rs",
|
||||||
"websocket",
|
"websocket",
|
||||||
] }
|
] }
|
||||||
|
@ -9,7 +9,7 @@ mod unbox;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use convert_case::Casing;
|
use convert_case::Casing;
|
||||||
use inflector::Inflector;
|
use inflector::{cases::camelcase::to_camel_case, Inflector};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use quote::{format_ident, quote, quote_spanned, ToTokens};
|
use quote::{format_ident, quote, quote_spanned, ToTokens};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
@ -326,13 +326,14 @@ fn do_stdlib_inner(
|
|||||||
};
|
};
|
||||||
let include_in_snippet = required || arg_meta.map(|arg| arg.include_in_snippet).unwrap_or_default();
|
let include_in_snippet = required || arg_meta.map(|arg| arg.include_in_snippet).unwrap_or_default();
|
||||||
let label_required = !(i == 0 && metadata.unlabeled_first);
|
let label_required = !(i == 0 && metadata.unlabeled_first);
|
||||||
|
let camel_case_arg_name = to_camel_case(&arg_name);
|
||||||
if ty_string != "ExecState" && ty_string != "Args" {
|
if ty_string != "ExecState" && ty_string != "Args" {
|
||||||
let schema = quote! {
|
let schema = quote! {
|
||||||
#docs_crate::cleanup_number_tuples_root(generator.root_schema_for::<#ty_ident>())
|
#docs_crate::cleanup_number_tuples_root(generator.root_schema_for::<#ty_ident>())
|
||||||
};
|
};
|
||||||
arg_types.push(quote! {
|
arg_types.push(quote! {
|
||||||
#docs_crate::StdLibFnArg {
|
#docs_crate::StdLibFnArg {
|
||||||
name: #arg_name.to_string(),
|
name: #camel_case_arg_name.to_string(),
|
||||||
type_: #ty_string.to_string(),
|
type_: #ty_string.to_string(),
|
||||||
schema: #schema,
|
schema: #schema,
|
||||||
required: #required,
|
required: #required,
|
||||||
|
@ -457,7 +457,7 @@ fn generate_const_from_kcl(cnst: &ConstData, file_name: String) -> Result<()> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let output = hbs.render("const", &data)?;
|
let output = hbs.render("const", &data)?;
|
||||||
expectorate::assert_contents(format!("../../../docs/kcl/const_{}.md", file_name), &output);
|
expectorate::assert_contents(format!("../../../docs/kcl/{}.md", file_name), &output);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -49,12 +49,15 @@ impl CollectionVisitor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
crate::parsing::ast::types::BodyItem::VariableDeclaration(var) if !var.visibility.is_default() => {
|
crate::parsing::ast::types::BodyItem::VariableDeclaration(var) if !var.visibility.is_default() => {
|
||||||
|
let qual_name = if self.name == "prelude" {
|
||||||
|
"std::".to_owned()
|
||||||
|
} else {
|
||||||
|
format!("std::{}::", self.name)
|
||||||
|
};
|
||||||
let mut dd = match var.kind {
|
let mut dd = match var.kind {
|
||||||
// TODO metadata for args
|
// TODO metadata for args
|
||||||
VariableKind::Fn => DocData::Fn(FnData::from_ast(var, format!("std::{}::", self.name))),
|
VariableKind::Fn => DocData::Fn(FnData::from_ast(var, qual_name)),
|
||||||
VariableKind::Const => {
|
VariableKind::Const => DocData::Const(ConstData::from_ast(var, qual_name)),
|
||||||
DocData::Const(ConstData::from_ast(var, format!("std::{}::", self.name)))
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME this association of metadata with items is pretty flaky.
|
// FIXME this association of metadata with items is pretty flaky.
|
||||||
@ -359,6 +362,7 @@ impl FnData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::literal_string_with_formatting_args)]
|
||||||
fn to_autocomplete_snippet(&self) -> String {
|
fn to_autocomplete_snippet(&self) -> String {
|
||||||
if self.name == "loft" {
|
if self.name == "loft" {
|
||||||
return "loft([${0:sketch000}, ${1:sketch001}])${}".to_owned();
|
return "loft([${0:sketch000}, ${1:sketch001}])${}".to_owned();
|
||||||
|
@ -473,6 +473,7 @@ pub trait StdLibFn: std::fmt::Debug + Send + Sync {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::literal_string_with_formatting_args)]
|
||||||
fn to_autocomplete_snippet(&self) -> Result<String> {
|
fn to_autocomplete_snippet(&self) -> Result<String> {
|
||||||
if self.name() == "loft" {
|
if self.name() == "loft" {
|
||||||
return Ok("loft([${0:sketch000}, ${1:sketch001}])${}".to_string());
|
return Ok("loft([${0:sketch000}, ${1:sketch001}])${}".to_string());
|
||||||
@ -926,6 +927,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::literal_string_with_formatting_args)]
|
||||||
fn get_autocomplete_snippet_line() {
|
fn get_autocomplete_snippet_line() {
|
||||||
let line_fn: Box<dyn StdLibFn> = Box::new(crate::std::sketch::Line);
|
let line_fn: Box<dyn StdLibFn> = Box::new(crate::std::sketch::Line);
|
||||||
let snippet = line_fn.to_autocomplete_snippet().unwrap();
|
let snippet = line_fn.to_autocomplete_snippet().unwrap();
|
||||||
@ -933,6 +935,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::literal_string_with_formatting_args)]
|
||||||
fn get_autocomplete_snippet_extrude() {
|
fn get_autocomplete_snippet_extrude() {
|
||||||
let extrude_fn: Box<dyn StdLibFn> = Box::new(crate::std::extrude::Extrude);
|
let extrude_fn: Box<dyn StdLibFn> = Box::new(crate::std::extrude::Extrude);
|
||||||
let snippet = extrude_fn.to_autocomplete_snippet().unwrap();
|
let snippet = extrude_fn.to_autocomplete_snippet().unwrap();
|
||||||
@ -940,6 +943,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::literal_string_with_formatting_args)]
|
||||||
fn get_autocomplete_snippet_fillet() {
|
fn get_autocomplete_snippet_fillet() {
|
||||||
let fillet_fn: Box<dyn StdLibFn> = Box::new(crate::std::fillet::Fillet);
|
let fillet_fn: Box<dyn StdLibFn> = Box::new(crate::std::fillet::Fillet);
|
||||||
let snippet = fillet_fn.to_autocomplete_snippet().unwrap();
|
let snippet = fillet_fn.to_autocomplete_snippet().unwrap();
|
||||||
@ -957,13 +961,14 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::literal_string_with_formatting_args)]
|
||||||
fn get_autocomplete_snippet_pattern_circular_3d() {
|
fn get_autocomplete_snippet_pattern_circular_3d() {
|
||||||
// We test this one specifically because it has ints and floats and strings.
|
// We test this one specifically because it has ints and floats and strings.
|
||||||
let pattern_fn: Box<dyn StdLibFn> = Box::new(crate::std::patterns::PatternCircular3D);
|
let pattern_fn: Box<dyn StdLibFn> = Box::new(crate::std::patterns::PatternCircular3D);
|
||||||
let snippet = pattern_fn.to_autocomplete_snippet().unwrap();
|
let snippet = pattern_fn.to_autocomplete_snippet().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
snippet,
|
snippet,
|
||||||
r#"patternCircular3d(${0:%}, instances = ${1:10}, axis = [${2:3.14}, ${3:3.14}, ${4:3.14}], center = [${5:3.14}, ${6:3.14}, ${7:3.14}], arc_degrees = ${8:3.14}, rotate_duplicates = ${9:false})${}"#
|
r#"patternCircular3d(${0:%}, instances = ${1:10}, axis = [${2:3.14}, ${3:3.14}, ${4:3.14}], center = [${5:3.14}, ${6:3.14}, ${7:3.14}], arcDegrees = ${8:3.14}, rotateDuplicates = ${9:false})${}"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -980,6 +985,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::literal_string_with_formatting_args)]
|
||||||
fn get_autocomplete_snippet_circle() {
|
fn get_autocomplete_snippet_circle() {
|
||||||
let circle_fn: Box<dyn StdLibFn> = Box::new(crate::std::shapes::Circle);
|
let circle_fn: Box<dyn StdLibFn> = Box::new(crate::std::shapes::Circle);
|
||||||
let snippet = circle_fn.to_autocomplete_snippet().unwrap();
|
let snippet = circle_fn.to_autocomplete_snippet().unwrap();
|
||||||
@ -993,6 +999,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::literal_string_with_formatting_args)]
|
||||||
fn get_autocomplete_snippet_arc() {
|
fn get_autocomplete_snippet_arc() {
|
||||||
let arc_fn: Box<dyn StdLibFn> = Box::new(crate::std::sketch::Arc);
|
let arc_fn: Box<dyn StdLibFn> = Box::new(crate::std::sketch::Arc);
|
||||||
let snippet = arc_fn.to_autocomplete_snippet().unwrap();
|
let snippet = arc_fn.to_autocomplete_snippet().unwrap();
|
||||||
@ -1014,6 +1021,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::literal_string_with_formatting_args)]
|
||||||
fn get_autocomplete_snippet_pattern_linear_2d() {
|
fn get_autocomplete_snippet_pattern_linear_2d() {
|
||||||
let pattern_fn: Box<dyn StdLibFn> = Box::new(crate::std::patterns::PatternLinear2D);
|
let pattern_fn: Box<dyn StdLibFn> = Box::new(crate::std::patterns::PatternLinear2D);
|
||||||
let snippet = pattern_fn.to_autocomplete_snippet().unwrap();
|
let snippet = pattern_fn.to_autocomplete_snippet().unwrap();
|
||||||
@ -1034,6 +1042,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::literal_string_with_formatting_args)]
|
||||||
fn get_autocomplete_snippet_loft() {
|
fn get_autocomplete_snippet_loft() {
|
||||||
let loft_fn: Box<dyn StdLibFn> = Box::new(crate::std::loft::Loft);
|
let loft_fn: Box<dyn StdLibFn> = Box::new(crate::std::loft::Loft);
|
||||||
let snippet = loft_fn.to_autocomplete_snippet().unwrap();
|
let snippet = loft_fn.to_autocomplete_snippet().unwrap();
|
||||||
@ -1041,6 +1050,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::literal_string_with_formatting_args)]
|
||||||
fn get_autocomplete_snippet_sweep() {
|
fn get_autocomplete_snippet_sweep() {
|
||||||
let sweep_fn: Box<dyn StdLibFn> = Box::new(crate::std::sweep::Sweep);
|
let sweep_fn: Box<dyn StdLibFn> = Box::new(crate::std::sweep::Sweep);
|
||||||
let snippet = sweep_fn.to_autocomplete_snippet().unwrap();
|
let snippet = sweep_fn.to_autocomplete_snippet().unwrap();
|
||||||
@ -1048,6 +1058,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::literal_string_with_formatting_args)]
|
||||||
fn get_autocomplete_snippet_hole() {
|
fn get_autocomplete_snippet_hole() {
|
||||||
let hole_fn: Box<dyn StdLibFn> = Box::new(crate::std::sketch::Hole);
|
let hole_fn: Box<dyn StdLibFn> = Box::new(crate::std::sketch::Hole);
|
||||||
let snippet = hole_fn.to_autocomplete_snippet().unwrap();
|
let snippet = hole_fn.to_autocomplete_snippet().unwrap();
|
||||||
@ -1055,16 +1066,18 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::literal_string_with_formatting_args)]
|
||||||
fn get_autocomplete_snippet_helix() {
|
fn get_autocomplete_snippet_helix() {
|
||||||
let helix_fn: Box<dyn StdLibFn> = Box::new(crate::std::helix::Helix);
|
let helix_fn: Box<dyn StdLibFn> = Box::new(crate::std::helix::Helix);
|
||||||
let snippet = helix_fn.to_autocomplete_snippet().unwrap();
|
let snippet = helix_fn.to_autocomplete_snippet().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
snippet,
|
snippet,
|
||||||
r#"helix(revolutions = ${0:3.14}, angle_start = ${1:3.14}, radius = ${2:3.14}, axis = ${3:"X"}, length = ${4:3.14})${}"#
|
r#"helix(revolutions = ${0:3.14}, angleStart = ${1:3.14}, radius = ${2:3.14}, axis = ${3:"X"}, length = ${4:3.14})${}"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::literal_string_with_formatting_args)]
|
||||||
fn get_autocomplete_snippet_helix_revolutions() {
|
fn get_autocomplete_snippet_helix_revolutions() {
|
||||||
let helix_fn: Box<dyn StdLibFn> = Box::new(crate::std::helix::HelixRevolutions);
|
let helix_fn: Box<dyn StdLibFn> = Box::new(crate::std::helix::HelixRevolutions);
|
||||||
let snippet = helix_fn.to_autocomplete_snippet().unwrap();
|
let snippet = helix_fn.to_autocomplete_snippet().unwrap();
|
||||||
|
@ -15,7 +15,7 @@ pub(super) const SIGNIFICANT_ATTRS: [&str; 2] = [SETTINGS, NO_PRELUDE];
|
|||||||
pub(crate) const SETTINGS: &str = "settings";
|
pub(crate) const SETTINGS: &str = "settings";
|
||||||
pub(crate) const SETTINGS_UNIT_LENGTH: &str = "defaultLengthUnit";
|
pub(crate) const SETTINGS_UNIT_LENGTH: &str = "defaultLengthUnit";
|
||||||
pub(crate) const SETTINGS_UNIT_ANGLE: &str = "defaultAngleUnit";
|
pub(crate) const SETTINGS_UNIT_ANGLE: &str = "defaultAngleUnit";
|
||||||
pub(super) const NO_PRELUDE: &str = "no_prelude";
|
pub(super) const NO_PRELUDE: &str = "no_std";
|
||||||
|
|
||||||
pub(super) const IMPORT_FORMAT: &str = "format";
|
pub(super) const IMPORT_FORMAT: &str = "format";
|
||||||
pub(super) const IMPORT_FORMAT_VALUES: [&str; 9] = ["fbx", "gltf", "glb", "obj", "ply", "sldprt", "stp", "step", "stl"];
|
pub(super) const IMPORT_FORMAT_VALUES: [&str; 9] = ["fbx", "gltf", "glb", "obj", "ply", "sldprt", "stp", "step", "stl"];
|
||||||
|
@ -6,7 +6,7 @@ use itertools::{EitherOrBoth, Itertools};
|
|||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
execution::{annotations, memory::ProgramMemory, ExecState, ExecutorSettings},
|
execution::{annotations, memory::ProgramMemory, EnvironmentRef, ExecState, ExecutorSettings},
|
||||||
parsing::ast::types::{Annotation, Node, Program},
|
parsing::ast::types::{Annotation, Node, Program},
|
||||||
walk::Node as WalkNode,
|
walk::Node as WalkNode,
|
||||||
};
|
};
|
||||||
@ -65,6 +65,7 @@ pub struct OldAstState {
|
|||||||
pub exec_state: ExecState,
|
pub exec_state: ExecState,
|
||||||
/// The last settings used for execution.
|
/// The last settings used for execution.
|
||||||
pub settings: crate::execution::ExecutorSettings,
|
pub settings: crate::execution::ExecutorSettings,
|
||||||
|
pub result_env: EnvironmentRef,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The result of a cache check.
|
/// The result of a cache check.
|
||||||
@ -267,7 +268,7 @@ firstSketch = startSketchOn('XY')
|
|||||||
// Remove the end face for the extrusion.
|
// Remove the end face for the extrusion.
|
||||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||||
|
|
||||||
let (program, ctx, _) = parse_execute(new).await.unwrap();
|
let (program, _, ctx, _) = parse_execute(new).await.unwrap();
|
||||||
|
|
||||||
let result = get_changed_program(
|
let result = get_changed_program(
|
||||||
CacheInformation {
|
CacheInformation {
|
||||||
@ -310,7 +311,7 @@ firstSketch = startSketchOn('XY')
|
|||||||
// Remove the end face for the extrusion.
|
// Remove the end face for the extrusion.
|
||||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||||
|
|
||||||
let (program_old, ctx, _) = parse_execute(old).await.unwrap();
|
let (program_old, _, ctx, _) = parse_execute(old).await.unwrap();
|
||||||
|
|
||||||
let program_new = crate::Program::parse_no_errs(new).unwrap();
|
let program_new = crate::Program::parse_no_errs(new).unwrap();
|
||||||
|
|
||||||
@ -355,7 +356,7 @@ firstSketch = startSketchOn('XY')
|
|||||||
// Remove the end face for the extrusion.
|
// Remove the end face for the extrusion.
|
||||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||||
|
|
||||||
let (program, ctx, _) = parse_execute(old).await.unwrap();
|
let (program, _, ctx, _) = parse_execute(old).await.unwrap();
|
||||||
|
|
||||||
let program_new = crate::Program::parse_no_errs(new).unwrap();
|
let program_new = crate::Program::parse_no_errs(new).unwrap();
|
||||||
|
|
||||||
@ -404,7 +405,7 @@ firstSketch = startSketchOn('XY')
|
|||||||
// Remove the end face for the extrusion.
|
// Remove the end face for the extrusion.
|
||||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||||
|
|
||||||
let (program, ctx, _) = parse_execute(old).await.unwrap();
|
let (program, _, ctx, _) = parse_execute(old).await.unwrap();
|
||||||
|
|
||||||
let program_new = crate::Program::parse_no_errs(new).unwrap();
|
let program_new = crate::Program::parse_no_errs(new).unwrap();
|
||||||
|
|
||||||
@ -438,7 +439,7 @@ firstSketch = startSketchOn('XY')
|
|||||||
// Remove the end face for the extrusion.
|
// Remove the end face for the extrusion.
|
||||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||||
|
|
||||||
let (program, mut ctx, _) = parse_execute(new).await.unwrap();
|
let (program, _, mut ctx, _) = parse_execute(new).await.unwrap();
|
||||||
|
|
||||||
// Change the settings to cm.
|
// Change the settings to cm.
|
||||||
ctx.settings.units = crate::UnitLength::Cm;
|
ctx.settings.units = crate::UnitLength::Cm;
|
||||||
@ -480,7 +481,7 @@ firstSketch = startSketchOn('XY')
|
|||||||
// Remove the end face for the extrusion.
|
// Remove the end face for the extrusion.
|
||||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||||
|
|
||||||
let (program, mut ctx, _) = parse_execute(new).await.unwrap();
|
let (program, _, mut ctx, _) = parse_execute(new).await.unwrap();
|
||||||
|
|
||||||
// Change the settings.
|
// Change the settings.
|
||||||
ctx.settings.show_grid = !ctx.settings.show_grid;
|
ctx.settings.show_grid = !ctx.settings.show_grid;
|
||||||
@ -515,7 +516,7 @@ firstSketch = startSketchOn('XY')
|
|||||||
// Remove the end face for the extrusion.
|
// Remove the end face for the extrusion.
|
||||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||||
|
|
||||||
let (program, mut ctx, _) = parse_execute(new).await.unwrap();
|
let (program, _, mut ctx, _) = parse_execute(new).await.unwrap();
|
||||||
|
|
||||||
// Change the settings.
|
// Change the settings.
|
||||||
ctx.settings.highlight_edges = !ctx.settings.highlight_edges;
|
ctx.settings.highlight_edges = !ctx.settings.highlight_edges;
|
||||||
@ -582,7 +583,7 @@ startSketchOn('XY')
|
|||||||
startSketchOn('XY')
|
startSketchOn('XY')
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
let (program, ctx, _) = parse_execute(old_code).await.unwrap();
|
let (program, _, ctx, _) = parse_execute(old_code).await.unwrap();
|
||||||
|
|
||||||
let mut new_program = crate::Program::parse_no_errs(new_code).unwrap();
|
let mut new_program = crate::Program::parse_no_errs(new_code).unwrap();
|
||||||
new_program.compute_digest();
|
new_program.compute_digest();
|
||||||
|
@ -53,7 +53,7 @@ impl ExecutorContext {
|
|||||||
let mut no_prelude = false;
|
let mut no_prelude = false;
|
||||||
for annotation in annotations {
|
for annotation in annotations {
|
||||||
if annotation.name() == Some(annotations::SETTINGS) {
|
if annotation.name() == Some(annotations::SETTINGS) {
|
||||||
if matches!(body_type, BodyType::Root(_)) {
|
if matches!(body_type, BodyType::Root) {
|
||||||
let old_units = exec_state.length_unit();
|
let old_units = exec_state.length_unit();
|
||||||
exec_state.mod_local.settings.update_from_annotation(annotation)?;
|
exec_state.mod_local.settings.update_from_annotation(annotation)?;
|
||||||
let new_units = exec_state.length_unit();
|
let new_units = exec_state.length_unit();
|
||||||
@ -69,12 +69,12 @@ impl ExecutorContext {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
} else if annotation.name() == Some(annotations::NO_PRELUDE) {
|
} else if annotation.name() == Some(annotations::NO_PRELUDE) {
|
||||||
if matches!(body_type, BodyType::Root(_)) {
|
if matches!(body_type, BodyType::Root) {
|
||||||
no_prelude = true;
|
no_prelude = true;
|
||||||
} else {
|
} else {
|
||||||
exec_state.err(CompilationError::err(
|
exec_state.err(CompilationError::err(
|
||||||
annotation.as_source_range(),
|
annotation.as_source_range(),
|
||||||
"Prelude can only be skipped at the top level scope of a file",
|
"The standard library can only be skipped at the top level scope of a file",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -87,51 +87,56 @@ impl ExecutorContext {
|
|||||||
Ok(no_prelude)
|
Ok(no_prelude)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(super) async fn exec_module_body(
|
||||||
|
&self,
|
||||||
|
program: &Node<Program>,
|
||||||
|
exec_state: &mut ExecState,
|
||||||
|
exec_kind: ExecutionKind,
|
||||||
|
preserve_mem: bool,
|
||||||
|
) -> Result<(Option<KclValue>, EnvironmentRef), KclError> {
|
||||||
|
let old_units = exec_state.length_unit();
|
||||||
|
|
||||||
|
let no_prelude = self
|
||||||
|
.handle_annotations(program.inner_attrs.iter(), crate::execution::BodyType::Root, exec_state)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
if !preserve_mem {
|
||||||
|
exec_state.mut_memory().push_new_root_env(!no_prelude);
|
||||||
|
}
|
||||||
|
let original_execution = self.engine.replace_execution_kind(exec_kind).await;
|
||||||
|
|
||||||
|
let result = self
|
||||||
|
.exec_block(program, exec_state, crate::execution::BodyType::Root)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let new_units = exec_state.length_unit();
|
||||||
|
let env_ref = if preserve_mem {
|
||||||
|
exec_state.mut_memory().pop_and_preserve_env()
|
||||||
|
} else {
|
||||||
|
exec_state.mut_memory().pop_env()
|
||||||
|
};
|
||||||
|
if !exec_kind.is_isolated() && new_units != old_units {
|
||||||
|
self.engine.set_units(old_units.into(), Default::default()).await?;
|
||||||
|
}
|
||||||
|
self.engine.replace_execution_kind(original_execution).await;
|
||||||
|
|
||||||
|
result.map(|result| (result, env_ref))
|
||||||
|
}
|
||||||
|
|
||||||
/// Execute an AST's program.
|
/// Execute an AST's program.
|
||||||
#[async_recursion]
|
#[async_recursion]
|
||||||
pub(super) async fn exec_program<'a>(
|
pub(super) async fn exec_block<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
program: NodeRef<'a, crate::parsing::ast::types::Program>,
|
program: NodeRef<'a, crate::parsing::ast::types::Program>,
|
||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
body_type: BodyType,
|
body_type: BodyType,
|
||||||
) -> Result<Option<KclValue>, KclError> {
|
) -> Result<Option<KclValue>, KclError> {
|
||||||
let no_prelude = self
|
|
||||||
.handle_annotations(program.inner_attrs.iter(), body_type, exec_state)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
if !no_prelude && body_type == BodyType::Root(true) {
|
|
||||||
// Import std::prelude
|
|
||||||
let prelude_range = SourceRange::from(program).start_as_range();
|
|
||||||
let id = self
|
|
||||||
.open_module(
|
|
||||||
&ImportPath::Std {
|
|
||||||
path: vec!["std".to_owned(), "prelude".to_owned()],
|
|
||||||
},
|
|
||||||
&[],
|
|
||||||
exec_state,
|
|
||||||
prelude_range,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
let (module_memory, module_exports) = self
|
|
||||||
.exec_module_for_items(id, exec_state, ExecutionKind::Isolated, prelude_range)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
for name in module_exports {
|
|
||||||
let item = exec_state
|
|
||||||
.memory()
|
|
||||||
.get_from(&name, module_memory, prelude_range)
|
|
||||||
.cloned()
|
|
||||||
.unwrap();
|
|
||||||
exec_state.mut_memory().add(name, item, prelude_range)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut last_expr = None;
|
let mut last_expr = None;
|
||||||
// Iterate over the body of the program.
|
// Iterate over the body of the program.
|
||||||
for statement in &program.body {
|
for statement in &program.body {
|
||||||
match statement {
|
match statement {
|
||||||
BodyItem::ImportStatement(import_stmt) => {
|
BodyItem::ImportStatement(import_stmt) => {
|
||||||
if !matches!(body_type, BodyType::Root(_)) {
|
if !matches!(body_type, BodyType::Root) {
|
||||||
return Err(KclError::Semantic(KclErrorDetails {
|
return Err(KclError::Semantic(KclErrorDetails {
|
||||||
message: "Imports are only supported at the top-level of a file.".to_owned(),
|
message: "Imports are only supported at the top-level of a file.".to_owned(),
|
||||||
source_ranges: vec![import_stmt.into()],
|
source_ranges: vec![import_stmt.into()],
|
||||||
@ -262,7 +267,7 @@ impl ExecutorContext {
|
|||||||
BodyItem::ReturnStatement(return_statement) => {
|
BodyItem::ReturnStatement(return_statement) => {
|
||||||
let metadata = Metadata::from(return_statement);
|
let metadata = Metadata::from(return_statement);
|
||||||
|
|
||||||
if matches!(body_type, BodyType::Root(_)) {
|
if matches!(body_type, BodyType::Root) {
|
||||||
return Err(KclError::Semantic(KclErrorDetails {
|
return Err(KclError::Semantic(KclErrorDetails {
|
||||||
message: "Cannot return from outside a function.".to_owned(),
|
message: "Cannot return from outside a function.".to_owned(),
|
||||||
source_ranges: vec![metadata.source_range],
|
source_ranges: vec![metadata.source_range],
|
||||||
@ -292,7 +297,7 @@ impl ExecutorContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches!(body_type, BodyType::Root(_)) {
|
if matches!(body_type, BodyType::Root) {
|
||||||
// Flush the batch queue.
|
// Flush the batch queue.
|
||||||
self.engine
|
self.engine
|
||||||
.flush_batch(
|
.flush_batch(
|
||||||
@ -307,7 +312,7 @@ impl ExecutorContext {
|
|||||||
Ok(last_expr)
|
Ok(last_expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn open_module(
|
pub(super) async fn open_module(
|
||||||
&self,
|
&self,
|
||||||
path: &ImportPath,
|
path: &ImportPath,
|
||||||
attrs: &[Node<Annotation>],
|
attrs: &[Node<Annotation>],
|
||||||
@ -357,7 +362,7 @@ impl ExecutorContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn exec_module_for_items(
|
pub(super) async fn exec_module_for_items(
|
||||||
&self,
|
&self,
|
||||||
module_id: ModuleId,
|
module_id: ModuleId,
|
||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
@ -424,25 +429,14 @@ impl ExecutorContext {
|
|||||||
exec_kind: ExecutionKind,
|
exec_kind: ExecutionKind,
|
||||||
source_range: SourceRange,
|
source_range: SourceRange,
|
||||||
) -> Result<(Option<KclValue>, EnvironmentRef, Vec<String>), KclError> {
|
) -> Result<(Option<KclValue>, EnvironmentRef, Vec<String>), KclError> {
|
||||||
let old_units = exec_state.length_unit();
|
|
||||||
let mut local_state = ModuleState::new(&self.settings, path.std_path());
|
|
||||||
exec_state.global.mod_loader.enter_module(path);
|
exec_state.global.mod_loader.enter_module(path);
|
||||||
|
let mut local_state = ModuleState::new(&self.settings, path.std_path());
|
||||||
std::mem::swap(&mut exec_state.mod_local, &mut local_state);
|
std::mem::swap(&mut exec_state.mod_local, &mut local_state);
|
||||||
exec_state.mut_memory().push_new_root_env();
|
|
||||||
let original_execution = self.engine.replace_execution_kind(exec_kind).await;
|
|
||||||
|
|
||||||
let result = self
|
let result = self.exec_module_body(program, exec_state, exec_kind, false).await;
|
||||||
.exec_program(program, exec_state, crate::execution::BodyType::Root(true))
|
|
||||||
.await;
|
|
||||||
|
|
||||||
let new_units = exec_state.length_unit();
|
|
||||||
std::mem::swap(&mut exec_state.mod_local, &mut local_state);
|
std::mem::swap(&mut exec_state.mod_local, &mut local_state);
|
||||||
let env_ref = exec_state.mut_memory().pop_env();
|
|
||||||
exec_state.global.mod_loader.leave_module(path);
|
exec_state.global.mod_loader.leave_module(path);
|
||||||
if !exec_kind.is_isolated() && new_units != old_units {
|
|
||||||
self.engine.set_units(old_units.into(), Default::default()).await?;
|
|
||||||
}
|
|
||||||
self.engine.replace_execution_kind(original_execution).await;
|
|
||||||
|
|
||||||
result
|
result
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
@ -460,7 +454,7 @@ impl ExecutorContext {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map(|result| (result, env_ref, local_state.module_exports))
|
.map(|(val, env)| (val, env, local_state.module_exports))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_recursion]
|
#[async_recursion]
|
||||||
@ -1483,7 +1477,7 @@ impl Node<IfExpression> {
|
|||||||
.await?
|
.await?
|
||||||
.get_bool()?;
|
.get_bool()?;
|
||||||
if cond {
|
if cond {
|
||||||
let block_result = ctx.exec_program(&self.then_val, exec_state, BodyType::Block).await?;
|
let block_result = ctx.exec_block(&self.then_val, exec_state, BodyType::Block).await?;
|
||||||
// Block must end in an expression, so this has to be Some.
|
// Block must end in an expression, so this has to be Some.
|
||||||
// Enforced by the parser.
|
// Enforced by the parser.
|
||||||
// See https://github.com/KittyCAD/modeling-app/issues/4015
|
// See https://github.com/KittyCAD/modeling-app/issues/4015
|
||||||
@ -1503,7 +1497,7 @@ impl Node<IfExpression> {
|
|||||||
.await?
|
.await?
|
||||||
.get_bool()?;
|
.get_bool()?;
|
||||||
if cond {
|
if cond {
|
||||||
let block_result = ctx.exec_program(&else_if.then_val, exec_state, BodyType::Block).await?;
|
let block_result = ctx.exec_block(&else_if.then_val, exec_state, BodyType::Block).await?;
|
||||||
// Block must end in an expression, so this has to be Some.
|
// Block must end in an expression, so this has to be Some.
|
||||||
// Enforced by the parser.
|
// Enforced by the parser.
|
||||||
// See https://github.com/KittyCAD/modeling-app/issues/4015
|
// See https://github.com/KittyCAD/modeling-app/issues/4015
|
||||||
@ -1512,7 +1506,7 @@ impl Node<IfExpression> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run the final `else` branch.
|
// Run the final `else` branch.
|
||||||
ctx.exec_program(&self.final_else, exec_state, BodyType::Block)
|
ctx.exec_block(&self.final_else, exec_state, BodyType::Block)
|
||||||
.await
|
.await
|
||||||
.map(|expr| expr.unwrap())
|
.map(|expr| expr.unwrap())
|
||||||
}
|
}
|
||||||
@ -1745,7 +1739,7 @@ pub(crate) async fn call_user_defined_function(
|
|||||||
|
|
||||||
// Execute the function body using the memory we just created.
|
// Execute the function body using the memory we just created.
|
||||||
let result = ctx
|
let result = ctx
|
||||||
.exec_program(&function_expression.body, exec_state, BodyType::Block)
|
.exec_block(&function_expression.body, exec_state, BodyType::Block)
|
||||||
.await;
|
.await;
|
||||||
let result = result.map(|_| {
|
let result = result.map(|_| {
|
||||||
exec_state
|
exec_state
|
||||||
@ -1778,7 +1772,7 @@ pub(crate) async fn call_user_defined_function_kw(
|
|||||||
|
|
||||||
// Execute the function body using the memory we just created.
|
// Execute the function body using the memory we just created.
|
||||||
let result = ctx
|
let result = ctx
|
||||||
.exec_program(&function_expression.body, exec_state, BodyType::Block)
|
.exec_block(&function_expression.body, exec_state, BodyType::Block)
|
||||||
.await;
|
.await;
|
||||||
let result = result.map(|_| {
|
let result = result.map(|_| {
|
||||||
exec_state
|
exec_state
|
||||||
@ -1873,6 +1867,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
fn additional_program_memory(items: &[(String, KclValue)]) -> ProgramMemory {
|
fn additional_program_memory(items: &[(String, KclValue)]) -> ProgramMemory {
|
||||||
let mut program_memory = ProgramMemory::new();
|
let mut program_memory = ProgramMemory::new();
|
||||||
|
program_memory.init_for_tests();
|
||||||
for (name, item) in items {
|
for (name, item) in items {
|
||||||
program_memory
|
program_memory
|
||||||
.add(name.clone(), item.clone(), SourceRange::default())
|
.add(name.clone(), item.clone(), SourceRange::default())
|
||||||
@ -1882,7 +1877,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
// Declare the test cases.
|
// Declare the test cases.
|
||||||
for (test_name, params, args, expected) in [
|
for (test_name, params, args, expected) in [
|
||||||
("empty", Vec::new(), Vec::new(), Ok(ProgramMemory::new())),
|
("empty", Vec::new(), Vec::new(), Ok(additional_program_memory(&[]))),
|
||||||
(
|
(
|
||||||
"all params required, and all given, should be OK",
|
"all params required, and all given, should be OK",
|
||||||
vec![req_param("x")],
|
vec![req_param("x")],
|
||||||
@ -1950,6 +1945,7 @@ mod test {
|
|||||||
});
|
});
|
||||||
let args = args.into_iter().map(Arg::synthetic).collect();
|
let args = args.into_iter().map(Arg::synthetic).collect();
|
||||||
let mut exec_state = ExecState::new(&Default::default());
|
let mut exec_state = ExecState::new(&Default::default());
|
||||||
|
exec_state.mut_memory().init_for_tests();
|
||||||
let actual = assign_args_to_params(func_expr, args, &mut exec_state).map(|_| exec_state.global.memory);
|
let actual = assign_args_to_params(func_expr, args, &mut exec_state).map(|_| exec_state.global.memory);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
actual, expected,
|
actual, expected,
|
||||||
|
@ -4,7 +4,7 @@ use anyhow::Result;
|
|||||||
use kcmc::{
|
use kcmc::{
|
||||||
coord::{System, KITTYCAD},
|
coord::{System, KITTYCAD},
|
||||||
each_cmd as mcmd,
|
each_cmd as mcmd,
|
||||||
format::InputFormat,
|
format::InputFormat3d,
|
||||||
ok_response::OkModelingCmdResponse,
|
ok_response::OkModelingCmdResponse,
|
||||||
shared::FileImportFormat,
|
shared::FileImportFormat,
|
||||||
units::UnitLength,
|
units::UnitLength,
|
||||||
@ -32,7 +32,7 @@ pub const ZOO_COORD_SYSTEM: System = *KITTYCAD;
|
|||||||
|
|
||||||
pub async fn import_foreign(
|
pub async fn import_foreign(
|
||||||
file_path: &Path,
|
file_path: &Path,
|
||||||
format: Option<InputFormat>,
|
format: Option<InputFormat3d>,
|
||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
ctxt: &ExecutorContext,
|
ctxt: &ExecutorContext,
|
||||||
source_range: SourceRange,
|
source_range: SourceRange,
|
||||||
@ -98,7 +98,7 @@ pub async fn import_foreign(
|
|||||||
|
|
||||||
// In the case of a gltf importing a bin file we need to handle that! and figure out where the
|
// In the case of a gltf importing a bin file we need to handle that! and figure out where the
|
||||||
// file is relative to our current file.
|
// file is relative to our current file.
|
||||||
if let InputFormat::Gltf(..) = format {
|
if let InputFormat3d::Gltf(..) = format {
|
||||||
// Check if the file is a binary gltf file, in that case we don't need to import the bin
|
// Check if the file is a binary gltf file, in that case we don't need to import the bin
|
||||||
// file.
|
// file.
|
||||||
if !file_contents.starts_with(b"glTF") {
|
if !file_contents.starts_with(b"glTF") {
|
||||||
@ -158,7 +158,7 @@ pub(super) fn format_from_annotations(
|
|||||||
annotations: &[Node<Annotation>],
|
annotations: &[Node<Annotation>],
|
||||||
path: &Path,
|
path: &Path,
|
||||||
import_source_range: SourceRange,
|
import_source_range: SourceRange,
|
||||||
) -> Result<Option<InputFormat>, KclError> {
|
) -> Result<Option<InputFormat3d>, KclError> {
|
||||||
if annotations.is_empty() {
|
if annotations.is_empty() {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
@ -220,7 +220,7 @@ pub(super) fn format_from_annotations(
|
|||||||
Ok(Some(result))
|
Ok(Some(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_coords(fmt: &mut InputFormat, coords_str: &str, source_range: SourceRange) -> Result<(), KclError> {
|
fn set_coords(fmt: &mut InputFormat3d, coords_str: &str, source_range: SourceRange) -> Result<(), KclError> {
|
||||||
let mut coords = None;
|
let mut coords = None;
|
||||||
for (name, val) in annotations::IMPORT_COORDS_VALUES {
|
for (name, val) in annotations::IMPORT_COORDS_VALUES {
|
||||||
if coords_str == name {
|
if coords_str == name {
|
||||||
@ -243,9 +243,9 @@ fn set_coords(fmt: &mut InputFormat, coords_str: &str, source_range: SourceRange
|
|||||||
};
|
};
|
||||||
|
|
||||||
match fmt {
|
match fmt {
|
||||||
InputFormat::Obj(opts) => opts.coords = coords,
|
InputFormat3d::Obj(opts) => opts.coords = coords,
|
||||||
InputFormat::Ply(opts) => opts.coords = coords,
|
InputFormat3d::Ply(opts) => opts.coords = coords,
|
||||||
InputFormat::Stl(opts) => opts.coords = coords,
|
InputFormat3d::Stl(opts) => opts.coords = coords,
|
||||||
_ => {
|
_ => {
|
||||||
return Err(KclError::Semantic(KclErrorDetails {
|
return Err(KclError::Semantic(KclErrorDetails {
|
||||||
message: format!(
|
message: format!(
|
||||||
@ -260,13 +260,13 @@ fn set_coords(fmt: &mut InputFormat, coords_str: &str, source_range: SourceRange
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_length_unit(fmt: &mut InputFormat, units_str: &str, source_range: SourceRange) -> Result<(), KclError> {
|
fn set_length_unit(fmt: &mut InputFormat3d, units_str: &str, source_range: SourceRange) -> Result<(), KclError> {
|
||||||
let units = UnitLen::from_str(units_str, source_range)?;
|
let units = UnitLen::from_str(units_str, source_range)?;
|
||||||
|
|
||||||
match fmt {
|
match fmt {
|
||||||
InputFormat::Obj(opts) => opts.units = units.into(),
|
InputFormat3d::Obj(opts) => opts.units = units.into(),
|
||||||
InputFormat::Ply(opts) => opts.units = units.into(),
|
InputFormat3d::Ply(opts) => opts.units = units.into(),
|
||||||
InputFormat::Stl(opts) => opts.units = units.into(),
|
InputFormat3d::Stl(opts) => opts.units = units.into(),
|
||||||
_ => {
|
_ => {
|
||||||
return Err(KclError::Semantic(KclErrorDetails {
|
return Err(KclError::Semantic(KclErrorDetails {
|
||||||
message: format!(
|
message: format!(
|
||||||
@ -320,7 +320,7 @@ pub async fn send_to_engine(pre: PreImportedGeometry, ctxt: &ExecutorContext) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the source format from the extension.
|
/// Get the source format from the extension.
|
||||||
fn get_import_format_from_extension(ext: &str) -> Result<InputFormat> {
|
fn get_import_format_from_extension(ext: &str) -> Result<InputFormat3d> {
|
||||||
let format = match FileImportFormat::from_str(ext) {
|
let format = match FileImportFormat::from_str(ext) {
|
||||||
Ok(format) => format,
|
Ok(format) => format,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
@ -343,44 +343,44 @@ fn get_import_format_from_extension(ext: &str) -> Result<InputFormat> {
|
|||||||
// * Up: +Z
|
// * Up: +Z
|
||||||
// * Handedness: Right
|
// * Handedness: Right
|
||||||
match format {
|
match format {
|
||||||
FileImportFormat::Step => Ok(InputFormat::Step(kcmc::format::step::import::Options {
|
FileImportFormat::Step => Ok(InputFormat3d::Step(kcmc::format::step::import::Options {
|
||||||
split_closed_faces: false,
|
split_closed_faces: false,
|
||||||
})),
|
})),
|
||||||
FileImportFormat::Stl => Ok(InputFormat::Stl(kcmc::format::stl::import::Options {
|
FileImportFormat::Stl => Ok(InputFormat3d::Stl(kcmc::format::stl::import::Options {
|
||||||
coords: ZOO_COORD_SYSTEM,
|
coords: ZOO_COORD_SYSTEM,
|
||||||
units: ul,
|
units: ul,
|
||||||
})),
|
})),
|
||||||
FileImportFormat::Obj => Ok(InputFormat::Obj(kcmc::format::obj::import::Options {
|
FileImportFormat::Obj => Ok(InputFormat3d::Obj(kcmc::format::obj::import::Options {
|
||||||
coords: ZOO_COORD_SYSTEM,
|
coords: ZOO_COORD_SYSTEM,
|
||||||
units: ul,
|
units: ul,
|
||||||
})),
|
})),
|
||||||
FileImportFormat::Gltf => Ok(InputFormat::Gltf(kcmc::format::gltf::import::Options {})),
|
FileImportFormat::Gltf => Ok(InputFormat3d::Gltf(kcmc::format::gltf::import::Options {})),
|
||||||
FileImportFormat::Ply => Ok(InputFormat::Ply(kcmc::format::ply::import::Options {
|
FileImportFormat::Ply => Ok(InputFormat3d::Ply(kcmc::format::ply::import::Options {
|
||||||
coords: ZOO_COORD_SYSTEM,
|
coords: ZOO_COORD_SYSTEM,
|
||||||
units: ul,
|
units: ul,
|
||||||
})),
|
})),
|
||||||
FileImportFormat::Fbx => Ok(InputFormat::Fbx(kcmc::format::fbx::import::Options {})),
|
FileImportFormat::Fbx => Ok(InputFormat3d::Fbx(kcmc::format::fbx::import::Options {})),
|
||||||
FileImportFormat::Sldprt => Ok(InputFormat::Sldprt(kcmc::format::sldprt::import::Options {
|
FileImportFormat::Sldprt => Ok(InputFormat3d::Sldprt(kcmc::format::sldprt::import::Options {
|
||||||
split_closed_faces: false,
|
split_closed_faces: false,
|
||||||
})),
|
})),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate_extension_format(ext: InputFormat, given: InputFormat) -> Result<()> {
|
fn validate_extension_format(ext: InputFormat3d, given: InputFormat3d) -> Result<()> {
|
||||||
if let InputFormat::Stl(_) = ext {
|
if let InputFormat3d::Stl(_) = ext {
|
||||||
if let InputFormat::Stl(_) = given {
|
if let InputFormat3d::Stl(_) = given {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let InputFormat::Obj(_) = ext {
|
if let InputFormat3d::Obj(_) = ext {
|
||||||
if let InputFormat::Obj(_) = given {
|
if let InputFormat3d::Obj(_) = given {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let InputFormat::Ply(_) = ext {
|
if let InputFormat3d::Ply(_) = ext {
|
||||||
if let InputFormat::Ply(_) = given {
|
if let InputFormat3d::Ply(_) = given {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -396,15 +396,15 @@ fn validate_extension_format(ext: InputFormat, given: InputFormat) -> Result<()>
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_name_of_format(type_: InputFormat) -> &'static str {
|
fn get_name_of_format(type_: InputFormat3d) -> &'static str {
|
||||||
match type_ {
|
match type_ {
|
||||||
InputFormat::Fbx(_) => "fbx",
|
InputFormat3d::Fbx(_) => "fbx",
|
||||||
InputFormat::Gltf(_) => "gltf",
|
InputFormat3d::Gltf(_) => "gltf",
|
||||||
InputFormat::Obj(_) => "obj",
|
InputFormat3d::Obj(_) => "obj",
|
||||||
InputFormat::Ply(_) => "ply",
|
InputFormat3d::Ply(_) => "ply",
|
||||||
InputFormat::Sldprt(_) => "sldprt",
|
InputFormat3d::Sldprt(_) => "sldprt",
|
||||||
InputFormat::Step(_) => "step",
|
InputFormat3d::Step(_) => "step",
|
||||||
InputFormat::Stl(_) => "stl",
|
InputFormat3d::Stl(_) => "stl",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,7 +430,7 @@ mod test {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
fmt,
|
fmt,
|
||||||
InputFormat::Gltf(kittycad_modeling_cmds::format::gltf::import::Options {})
|
InputFormat3d::Gltf(kittycad_modeling_cmds::format::gltf::import::Options {})
|
||||||
);
|
);
|
||||||
|
|
||||||
// format, no options
|
// format, no options
|
||||||
@ -442,7 +442,7 @@ mod test {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
fmt,
|
fmt,
|
||||||
InputFormat::Gltf(kittycad_modeling_cmds::format::gltf::import::Options {})
|
InputFormat3d::Gltf(kittycad_modeling_cmds::format::gltf::import::Options {})
|
||||||
);
|
);
|
||||||
|
|
||||||
// format, no extension (wouldn't parse but might some day)
|
// format, no extension (wouldn't parse but might some day)
|
||||||
@ -451,7 +451,7 @@ mod test {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
fmt,
|
fmt,
|
||||||
InputFormat::Gltf(kittycad_modeling_cmds::format::gltf::import::Options {})
|
InputFormat3d::Gltf(kittycad_modeling_cmds::format::gltf::import::Options {})
|
||||||
);
|
);
|
||||||
|
|
||||||
// format, options
|
// format, options
|
||||||
@ -463,7 +463,7 @@ mod test {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
fmt,
|
fmt,
|
||||||
InputFormat::Obj(kittycad_modeling_cmds::format::obj::import::Options {
|
InputFormat3d::Obj(kittycad_modeling_cmds::format::obj::import::Options {
|
||||||
coords: *kittycad_modeling_cmds::coord::VULKAN,
|
coords: *kittycad_modeling_cmds::coord::VULKAN,
|
||||||
units: kittycad_modeling_cmds::units::UnitLength::Feet,
|
units: kittycad_modeling_cmds::units::UnitLength::Feet,
|
||||||
})
|
})
|
||||||
@ -478,7 +478,7 @@ mod test {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
fmt,
|
fmt,
|
||||||
InputFormat::Obj(kittycad_modeling_cmds::format::obj::import::Options {
|
InputFormat3d::Obj(kittycad_modeling_cmds::format::obj::import::Options {
|
||||||
coords: *kittycad_modeling_cmds::coord::VULKAN,
|
coords: *kittycad_modeling_cmds::coord::VULKAN,
|
||||||
units: kittycad_modeling_cmds::units::UnitLength::Feet,
|
units: kittycad_modeling_cmds::units::UnitLength::Feet,
|
||||||
})
|
})
|
||||||
|
@ -161,6 +161,8 @@ pub(crate) struct ProgramMemory {
|
|||||||
environments: Vec<Environment>,
|
environments: Vec<Environment>,
|
||||||
/// Invariant: current_env.1.is_none()
|
/// Invariant: current_env.1.is_none()
|
||||||
current_env: EnvironmentRef,
|
current_env: EnvironmentRef,
|
||||||
|
/// Memory for the std prelude.
|
||||||
|
std: Option<EnvironmentRef>,
|
||||||
/// Invariant: forall er in call_stack: er.1.is_none()
|
/// Invariant: forall er in call_stack: er.1.is_none()
|
||||||
call_stack: Vec<EnvironmentRef>,
|
call_stack: Vec<EnvironmentRef>,
|
||||||
/// Statistics about the memory, should not be used for anything other than meta-info.
|
/// Statistics about the memory, should not be used for anything other than meta-info.
|
||||||
@ -195,22 +197,41 @@ impl ProgramMemory {
|
|||||||
#[allow(clippy::new_without_default)]
|
#[allow(clippy::new_without_default)]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
environments: vec![Environment::new_root()],
|
environments: vec![],
|
||||||
current_env: EnvironmentRef::root(),
|
current_env: EnvironmentRef::dummy(),
|
||||||
|
std: None,
|
||||||
call_stack: Vec::new(),
|
call_stack: Vec::new(),
|
||||||
stats: MemoryStats::default(),
|
stats: MemoryStats::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the env var used for the standard library prelude.
|
||||||
|
pub fn set_std(&mut self, std: EnvironmentRef) {
|
||||||
|
self.std = Some(std);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Whether this memory still needs to be initialised with its standard library prelude.
|
||||||
|
pub fn requires_std(&self) -> bool {
|
||||||
|
self.std.is_none()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
/// If you're using ProgramMemory directly for testing it must be initialized first.
|
||||||
|
pub fn init_for_tests(&mut self) {
|
||||||
|
self.push_new_root_env(false);
|
||||||
|
self.std = Some(self.current_env);
|
||||||
|
}
|
||||||
|
|
||||||
/// Push a new (standard KCL) stack frame on to the call stack.
|
/// Push a new (standard KCL) stack frame on to the call stack.
|
||||||
///
|
///
|
||||||
/// `parent` is the environment where the function being called is declared (not the caller's
|
/// `parent` is the environment where the function being called is declared (not the caller's
|
||||||
/// environment, which is probably `self.current_env`).
|
/// environment, which is probably `self.current_env`).
|
||||||
pub fn push_new_env_for_call(&mut self, parent: EnvironmentRef) {
|
pub fn push_new_env_for_call(&mut self, parent: EnvironmentRef) {
|
||||||
|
assert!(parent.1 .0 < usize::MAX);
|
||||||
self.stats.env_count += 1;
|
self.stats.env_count += 1;
|
||||||
|
|
||||||
self.call_stack.push(self.current_env);
|
self.call_stack.push(self.current_env);
|
||||||
let new_env = Environment::new(parent);
|
let new_env = Environment::new(parent, false);
|
||||||
self.current_env = EnvironmentRef(self.environments.len(), SnapshotRef::none());
|
self.current_env = EnvironmentRef(self.environments.len(), SnapshotRef::none());
|
||||||
self.environments.push(new_env);
|
self.environments.push(new_env);
|
||||||
}
|
}
|
||||||
@ -221,6 +242,7 @@ impl ProgramMemory {
|
|||||||
pub fn push_new_env_for_scope(&mut self) {
|
pub fn push_new_env_for_scope(&mut self) {
|
||||||
self.stats.env_count += 1;
|
self.stats.env_count += 1;
|
||||||
|
|
||||||
|
// We want to use the current env as the parent.
|
||||||
// We need to snapshot in case there is a function decl in the new scope.
|
// We need to snapshot in case there is a function decl in the new scope.
|
||||||
let snapshot = self.snapshot();
|
let snapshot = self.snapshot();
|
||||||
self.push_new_env_for_call(snapshot);
|
self.push_new_env_for_call(snapshot);
|
||||||
@ -245,15 +267,27 @@ impl ProgramMemory {
|
|||||||
/// Push a new stack frame on to the call stack with no connection to a parent environment.
|
/// Push a new stack frame on to the call stack with no connection to a parent environment.
|
||||||
///
|
///
|
||||||
/// Suitable for executing a separate module.
|
/// Suitable for executing a separate module.
|
||||||
pub fn push_new_root_env(&mut self) {
|
/// Precondition: include_prelude -> !self.requires_std()
|
||||||
|
pub fn push_new_root_env(&mut self, include_prelude: bool) {
|
||||||
self.stats.env_count += 1;
|
self.stats.env_count += 1;
|
||||||
|
|
||||||
self.call_stack.push(self.current_env);
|
self.call_stack.push(self.current_env);
|
||||||
let new_env = Environment::new_root();
|
let new_env = if include_prelude {
|
||||||
|
Environment::new(self.std.unwrap(), true)
|
||||||
|
} else {
|
||||||
|
Environment::new_no_prelude()
|
||||||
|
};
|
||||||
self.current_env = EnvironmentRef(self.environments.len(), SnapshotRef::none());
|
self.current_env = EnvironmentRef(self.environments.len(), SnapshotRef::none());
|
||||||
self.environments.push(new_env);
|
self.environments.push(new_env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Push a previously used environment on to the call stack.
|
||||||
|
pub fn restore_env(&mut self, env: EnvironmentRef) {
|
||||||
|
assert!(env.1.is_none());
|
||||||
|
self.call_stack.push(self.current_env);
|
||||||
|
self.current_env = env;
|
||||||
|
}
|
||||||
|
|
||||||
/// Pop a frame from the call stack and return a reference to the popped environment. The popped
|
/// Pop a frame from the call stack and return a reference to the popped environment. The popped
|
||||||
/// environment is preserved if it may be referenced (so the returned reference will remain valid).
|
/// environment is preserved if it may be referenced (so the returned reference will remain valid).
|
||||||
///
|
///
|
||||||
@ -263,7 +297,7 @@ impl ProgramMemory {
|
|||||||
let old = self.current_env;
|
let old = self.current_env;
|
||||||
self.current_env = self.call_stack.pop().unwrap();
|
self.current_env = self.call_stack.pop().unwrap();
|
||||||
|
|
||||||
if !old.is_rust_env() {
|
if !old.skip_env() {
|
||||||
self.environments[old.index()].compact();
|
self.environments[old.index()].compact();
|
||||||
|
|
||||||
if self.environments[old.index()].is_empty() {
|
if self.environments[old.index()].is_empty() {
|
||||||
@ -292,7 +326,10 @@ impl ProgramMemory {
|
|||||||
/// Merges the specified environment with the current environment, rewriting any environment refs
|
/// Merges the specified environment with the current environment, rewriting any environment refs
|
||||||
/// taking snapshots into account. Deletes (if possible) or clears the squashed environment.
|
/// taking snapshots into account. Deletes (if possible) or clears the squashed environment.
|
||||||
pub fn squash_env(&mut self, old: EnvironmentRef) {
|
pub fn squash_env(&mut self, old: EnvironmentRef) {
|
||||||
assert!(!old.is_rust_env());
|
assert!(!old.skip_env());
|
||||||
|
if self.current_env.skip_env() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let mut old_env = if old.index() == self.environments.len() - 1 {
|
let mut old_env = if old.index() == self.environments.len() - 1 {
|
||||||
// Common case and efficient
|
// Common case and efficient
|
||||||
@ -301,7 +338,10 @@ impl ProgramMemory {
|
|||||||
} else {
|
} else {
|
||||||
// Should basically never happen in normal usage.
|
// Should basically never happen in normal usage.
|
||||||
self.stats.skipped_env_gcs += 1;
|
self.stats.skipped_env_gcs += 1;
|
||||||
std::mem::replace(&mut self.environments[old.index()], Environment::new(self.current_env))
|
std::mem::replace(
|
||||||
|
&mut self.environments[old.index()],
|
||||||
|
Environment::new(self.current_env, false),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Map of any old env refs to the current env.
|
// Map of any old env refs to the current env.
|
||||||
@ -367,12 +407,12 @@ impl ProgramMemory {
|
|||||||
|
|
||||||
/// Get a key from the first KCL (i.e., non-Rust) stack frame on the call stack.
|
/// Get a key from the first KCL (i.e., non-Rust) stack frame on the call stack.
|
||||||
pub fn get_from_call_stack(&self, key: &str, source_range: SourceRange) -> Result<&KclValue, KclError> {
|
pub fn get_from_call_stack(&self, key: &str, source_range: SourceRange) -> Result<&KclValue, KclError> {
|
||||||
if !self.current_env.is_rust_env() {
|
if !self.current_env.skip_env() {
|
||||||
return self.get(key, source_range);
|
return self.get(key, source_range);
|
||||||
}
|
}
|
||||||
|
|
||||||
for env in self.call_stack.iter().rev() {
|
for env in self.call_stack.iter().rev() {
|
||||||
if !env.is_rust_env() {
|
if !env.skip_env() {
|
||||||
return self.get_from(key, *env, source_range);
|
return self.get_from(key, *env, source_range);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -408,7 +448,18 @@ impl ProgramMemory {
|
|||||||
&'a self,
|
&'a self,
|
||||||
pred: impl Fn(&KclValue) -> bool + 'a,
|
pred: impl Fn(&KclValue) -> bool + 'a,
|
||||||
) -> impl Iterator<Item = (&'a String, &'a KclValue)> {
|
) -> impl Iterator<Item = (&'a String, &'a KclValue)> {
|
||||||
self.environments[self.current_env.index()].find_all_by(pred)
|
self.find_all_in_env(self.current_env, pred)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Iterate over all key/value pairs in the specified environment which satisfy the provided
|
||||||
|
/// predicate.
|
||||||
|
pub fn find_all_in_env<'a>(
|
||||||
|
&'a self,
|
||||||
|
env: EnvironmentRef,
|
||||||
|
pred: impl Fn(&KclValue) -> bool + 'a,
|
||||||
|
) -> impl Iterator<Item = (&'a String, &'a KclValue)> {
|
||||||
|
assert!(!env.skip_env());
|
||||||
|
self.environments[env.index()].find_all_by(pred)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Walk all values accessible from any environment in the call stack.
|
/// Walk all values accessible from any environment in the call stack.
|
||||||
@ -418,7 +469,7 @@ impl ProgramMemory {
|
|||||||
pub fn walk_call_stack(&self) -> impl Iterator<Item = &KclValue> {
|
pub fn walk_call_stack(&self) -> impl Iterator<Item = &KclValue> {
|
||||||
let mut cur_env = self.current_env;
|
let mut cur_env = self.current_env;
|
||||||
let mut stack_index = self.call_stack.len();
|
let mut stack_index = self.call_stack.len();
|
||||||
while cur_env.is_rust_env() {
|
while cur_env.skip_env() {
|
||||||
stack_index -= 1;
|
stack_index -= 1;
|
||||||
cur_env = self.call_stack[stack_index];
|
cur_env = self.call_stack[stack_index];
|
||||||
}
|
}
|
||||||
@ -455,7 +506,7 @@ impl<'a> Iterator for CallStackIterator<'a> {
|
|||||||
self.cur_values.as_ref()?;
|
self.cur_values.as_ref()?;
|
||||||
|
|
||||||
// Loop over each frame in the call stack.
|
// Loop over each frame in the call stack.
|
||||||
loop {
|
'outer: loop {
|
||||||
// Loop over each environment in the tree of scopes of which the current stack frame is a leaf.
|
// Loop over each environment in the tree of scopes of which the current stack frame is a leaf.
|
||||||
loop {
|
loop {
|
||||||
// `unwrap` is OK since we check for None at the start of the function, and if we update
|
// `unwrap` is OK since we check for None at the start of the function, and if we update
|
||||||
@ -478,11 +529,13 @@ impl<'a> Iterator for CallStackIterator<'a> {
|
|||||||
loop {
|
loop {
|
||||||
self.stack_index -= 1;
|
self.stack_index -= 1;
|
||||||
let env_ref = self.mem.call_stack[self.stack_index];
|
let env_ref = self.mem.call_stack[self.stack_index];
|
||||||
// We'll eventually hit this condition since we can't start executing in Rust.
|
|
||||||
if !env_ref.is_rust_env() {
|
if !env_ref.skip_env() {
|
||||||
self.cur_env = env_ref;
|
self.cur_env = env_ref;
|
||||||
self.init_iter();
|
self.init_iter();
|
||||||
break;
|
break;
|
||||||
|
} else if self.stack_index == 0 {
|
||||||
|
break 'outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -507,15 +560,15 @@ impl PartialEq for ProgramMemory {
|
|||||||
pub struct EnvironmentRef(usize, SnapshotRef);
|
pub struct EnvironmentRef(usize, SnapshotRef);
|
||||||
|
|
||||||
impl EnvironmentRef {
|
impl EnvironmentRef {
|
||||||
fn root() -> Self {
|
fn dummy() -> Self {
|
||||||
Self(0, SnapshotRef::none())
|
Self(usize::MAX, SnapshotRef(usize::MAX))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn index(&self) -> usize {
|
fn index(&self) -> usize {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_rust_env(&self) -> bool {
|
fn skip_env(&self) -> bool {
|
||||||
self.0 == usize::MAX
|
self.0 == usize::MAX
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -576,6 +629,7 @@ mod env {
|
|||||||
snapshots: Vec<Snapshot>,
|
snapshots: Vec<Snapshot>,
|
||||||
// An outer scope, if one exists.
|
// An outer scope, if one exists.
|
||||||
parent: Option<EnvironmentRef>,
|
parent: Option<EnvironmentRef>,
|
||||||
|
is_root_env: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Environment {
|
impl fmt::Display for Environment {
|
||||||
@ -624,28 +678,31 @@ mod env {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Environment {
|
impl Environment {
|
||||||
/// Create a new root environment (new program or module)
|
/// Create a new environment, parent points to it's surrounding lexical scope or the std
|
||||||
pub(super) fn new_root() -> Self {
|
/// env if it's a root scope.
|
||||||
Self {
|
pub(super) fn new(parent: EnvironmentRef, is_root_env: bool) -> Self {
|
||||||
bindings: IndexMap::new(),
|
assert!(!parent.skip_env());
|
||||||
snapshots: Vec::new(),
|
|
||||||
parent: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a new child environment, parent points to it's surrounding lexical scope.
|
|
||||||
pub(super) fn new(parent: EnvironmentRef) -> Self {
|
|
||||||
assert!(!parent.is_rust_env());
|
|
||||||
Self {
|
Self {
|
||||||
bindings: IndexMap::new(),
|
bindings: IndexMap::new(),
|
||||||
snapshots: Vec::new(),
|
snapshots: Vec::new(),
|
||||||
parent: Some(parent),
|
parent: Some(parent),
|
||||||
|
is_root_env,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a new root environment with no prelude as parent.
|
||||||
|
pub(super) fn new_no_prelude() -> Self {
|
||||||
|
Self {
|
||||||
|
bindings: IndexMap::new(),
|
||||||
|
snapshots: Vec::new(),
|
||||||
|
parent: None,
|
||||||
|
is_root_env: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// True if the env is empty and not a root env.
|
// True if the env is empty and not a root env.
|
||||||
pub(super) fn is_empty(&self) -> bool {
|
pub(super) fn is_empty(&self) -> bool {
|
||||||
self.snapshots.is_empty() && self.bindings.is_empty() && self.parent.is_some()
|
self.snapshots.is_empty() && self.bindings.is_empty() && !self.is_root_env
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Possibly compress this environment by deleting the memory.
|
/// Possibly compress this environment by deleting the memory.
|
||||||
@ -657,7 +714,7 @@ mod env {
|
|||||||
/// See module docs for more details.
|
/// See module docs for more details.
|
||||||
pub(super) fn compact(&mut self) {
|
pub(super) fn compact(&mut self) {
|
||||||
// Don't compress if there might be a closure or import referencing us.
|
// Don't compress if there might be a closure or import referencing us.
|
||||||
if !self.snapshots.is_empty() || self.parent.is_none() {
|
if !self.snapshots.is_empty() || self.is_root_env {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -881,6 +938,7 @@ mod test {
|
|||||||
// Follows test_pattern_transform_function_cannot_access_future_definitions
|
// Follows test_pattern_transform_function_cannot_access_future_definitions
|
||||||
|
|
||||||
let mem = &mut ProgramMemory::new();
|
let mem = &mut ProgramMemory::new();
|
||||||
|
mem.init_for_tests();
|
||||||
let transform = mem.snapshot();
|
let transform = mem.snapshot();
|
||||||
mem.add("transform".to_owned(), val(1), sr()).unwrap();
|
mem.add("transform".to_owned(), val(1), sr()).unwrap();
|
||||||
let layer = mem.snapshot();
|
let layer = mem.snapshot();
|
||||||
@ -898,6 +956,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn simple_snapshot() {
|
fn simple_snapshot() {
|
||||||
let mem = &mut ProgramMemory::new();
|
let mem = &mut ProgramMemory::new();
|
||||||
|
mem.init_for_tests();
|
||||||
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
||||||
assert_get(mem, "a", 1);
|
assert_get(mem, "a", 1);
|
||||||
mem.add("a".to_owned(), val(2), sr()).unwrap_err();
|
mem.add("a".to_owned(), val(2), sr()).unwrap_err();
|
||||||
@ -915,6 +974,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn multiple_snapshot() {
|
fn multiple_snapshot() {
|
||||||
let mem = &mut ProgramMemory::new();
|
let mem = &mut ProgramMemory::new();
|
||||||
|
mem.init_for_tests();
|
||||||
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
||||||
|
|
||||||
let sn1 = mem.snapshot();
|
let sn1 = mem.snapshot();
|
||||||
@ -938,6 +998,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn simple_call_env() {
|
fn simple_call_env() {
|
||||||
let mem = &mut ProgramMemory::new();
|
let mem = &mut ProgramMemory::new();
|
||||||
|
mem.init_for_tests();
|
||||||
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
||||||
mem.add("b".to_owned(), val(3), sr()).unwrap();
|
mem.add("b".to_owned(), val(3), sr()).unwrap();
|
||||||
|
|
||||||
@ -962,6 +1023,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn multiple_call_env() {
|
fn multiple_call_env() {
|
||||||
let mem = &mut ProgramMemory::new();
|
let mem = &mut ProgramMemory::new();
|
||||||
|
mem.init_for_tests();
|
||||||
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
||||||
mem.add("b".to_owned(), val(3), sr()).unwrap();
|
mem.add("b".to_owned(), val(3), sr()).unwrap();
|
||||||
|
|
||||||
@ -986,10 +1048,11 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn root_env() {
|
fn root_env() {
|
||||||
let mem = &mut ProgramMemory::new();
|
let mem = &mut ProgramMemory::new();
|
||||||
|
mem.init_for_tests();
|
||||||
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
||||||
mem.add("b".to_owned(), val(3), sr()).unwrap();
|
mem.add("b".to_owned(), val(3), sr()).unwrap();
|
||||||
|
|
||||||
mem.push_new_root_env();
|
mem.push_new_root_env(false);
|
||||||
mem.get("b", sr()).unwrap_err();
|
mem.get("b", sr()).unwrap_err();
|
||||||
mem.add("b".to_owned(), val(4), sr()).unwrap();
|
mem.add("b".to_owned(), val(4), sr()).unwrap();
|
||||||
mem.add("c".to_owned(), val(5), sr()).unwrap();
|
mem.add("c".to_owned(), val(5), sr()).unwrap();
|
||||||
@ -1008,6 +1071,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn rust_env() {
|
fn rust_env() {
|
||||||
let mem = &mut ProgramMemory::new();
|
let mem = &mut ProgramMemory::new();
|
||||||
|
mem.init_for_tests();
|
||||||
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
||||||
mem.add("b".to_owned(), val(3), sr()).unwrap();
|
mem.add("b".to_owned(), val(3), sr()).unwrap();
|
||||||
let sn = mem.snapshot();
|
let sn = mem.snapshot();
|
||||||
@ -1026,6 +1090,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn deep_call_env() {
|
fn deep_call_env() {
|
||||||
let mem = &mut ProgramMemory::new();
|
let mem = &mut ProgramMemory::new();
|
||||||
|
mem.init_for_tests();
|
||||||
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
||||||
mem.add("b".to_owned(), val(3), sr()).unwrap();
|
mem.add("b".to_owned(), val(3), sr()).unwrap();
|
||||||
|
|
||||||
@ -1058,6 +1123,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn snap_env() {
|
fn snap_env() {
|
||||||
let mem = &mut ProgramMemory::new();
|
let mem = &mut ProgramMemory::new();
|
||||||
|
mem.init_for_tests();
|
||||||
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
||||||
|
|
||||||
let sn = mem.snapshot();
|
let sn = mem.snapshot();
|
||||||
@ -1078,6 +1144,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn snap_env2() {
|
fn snap_env2() {
|
||||||
let mem = &mut ProgramMemory::new();
|
let mem = &mut ProgramMemory::new();
|
||||||
|
mem.init_for_tests();
|
||||||
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
||||||
|
|
||||||
let sn1 = mem.snapshot();
|
let sn1 = mem.snapshot();
|
||||||
@ -1104,6 +1171,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn snap_env_two_updates() {
|
fn snap_env_two_updates() {
|
||||||
let mem = &mut ProgramMemory::new();
|
let mem = &mut ProgramMemory::new();
|
||||||
|
mem.init_for_tests();
|
||||||
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
||||||
|
|
||||||
let sn1 = mem.snapshot();
|
let sn1 = mem.snapshot();
|
||||||
@ -1146,6 +1214,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn snap_env_clear() {
|
fn snap_env_clear() {
|
||||||
let mem = &mut ProgramMemory::new();
|
let mem = &mut ProgramMemory::new();
|
||||||
|
mem.init_for_tests();
|
||||||
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
||||||
|
|
||||||
mem.add("b".to_owned(), val(3), sr()).unwrap();
|
mem.add("b".to_owned(), val(3), sr()).unwrap();
|
||||||
@ -1169,6 +1238,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn snap_env_clear2() {
|
fn snap_env_clear2() {
|
||||||
let mem = &mut ProgramMemory::new();
|
let mem = &mut ProgramMemory::new();
|
||||||
|
mem.init_for_tests();
|
||||||
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
||||||
mem.add("b".to_owned(), val(3), sr()).unwrap();
|
mem.add("b".to_owned(), val(3), sr()).unwrap();
|
||||||
let sn1 = mem.snapshot();
|
let sn1 = mem.snapshot();
|
||||||
@ -1199,6 +1269,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn squash_env() {
|
fn squash_env() {
|
||||||
let mem = &mut ProgramMemory::new();
|
let mem = &mut ProgramMemory::new();
|
||||||
|
mem.init_for_tests();
|
||||||
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
mem.add("a".to_owned(), val(1), sr()).unwrap();
|
||||||
let sn1 = mem.snapshot();
|
let sn1 = mem.snapshot();
|
||||||
mem.push_new_env_for_call(sn1);
|
mem.push_new_env_for_call(sn1);
|
||||||
|
@ -21,14 +21,13 @@ use crate::{
|
|||||||
execution::{
|
execution::{
|
||||||
artifact::build_artifact_graph,
|
artifact::build_artifact_graph,
|
||||||
cache::{CacheInformation, CacheResult},
|
cache::{CacheInformation, CacheResult},
|
||||||
memory::ProgramMemory,
|
|
||||||
},
|
},
|
||||||
fs::FileManager,
|
fs::FileManager,
|
||||||
parsing::ast::types::{Expr, Node, NodeRef, Program},
|
parsing::ast::types::{Expr, ImportPath, Node, NodeRef, Program},
|
||||||
settings::types::UnitLength,
|
settings::types::UnitLength,
|
||||||
source_range::SourceRange,
|
source_range::SourceRange,
|
||||||
std::StdLib,
|
std::StdLib,
|
||||||
CompilationError, ExecError, KclErrorWithOutputs,
|
CompilationError, ExecError, ExecutionKind, KclErrorWithOutputs,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use artifact::{Artifact, ArtifactCommand, ArtifactGraph, ArtifactId};
|
pub use artifact::{Artifact, ArtifactCommand, ArtifactGraph, ArtifactId};
|
||||||
@ -150,7 +149,7 @@ pub struct TagEngineInfo {
|
|||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Copy, Clone, Deserialize, Serialize, PartialEq)]
|
||||||
pub enum BodyType {
|
pub enum BodyType {
|
||||||
Root(bool),
|
Root,
|
||||||
Block,
|
Block,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,6 +487,14 @@ impl ExecutorContext {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn prepare_mem(&self, exec_state: &mut ExecState) -> Result<(), KclErrorWithOutputs> {
|
||||||
|
self.eval_prelude(exec_state, SourceRange::synthetic())
|
||||||
|
.await
|
||||||
|
.map_err(KclErrorWithOutputs::no_outputs)?;
|
||||||
|
exec_state.mut_memory().push_new_root_env(true);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn run_mock(
|
pub async fn run_mock(
|
||||||
&self,
|
&self,
|
||||||
program: crate::Program,
|
program: crate::Program,
|
||||||
@ -497,58 +504,60 @@ impl ExecutorContext {
|
|||||||
assert!(self.is_mock());
|
assert!(self.is_mock());
|
||||||
|
|
||||||
let mut exec_state = ExecState::new(&self.settings);
|
let mut exec_state = ExecState::new(&self.settings);
|
||||||
let (mut mem, init_mem) = if use_prev_memory {
|
if use_prev_memory {
|
||||||
cache::read_old_memory()
|
match cache::read_old_memory().await {
|
||||||
.await
|
Some(mem) => *exec_state.mut_memory() = mem,
|
||||||
.map(|m| (m, false))
|
None => self.prepare_mem(&mut exec_state).await?,
|
||||||
.unwrap_or_else(|| (ProgramMemory::new(), true))
|
}
|
||||||
} else {
|
} else {
|
||||||
(ProgramMemory::new(), true)
|
self.prepare_mem(&mut exec_state).await?
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add any extra variables to memory
|
|
||||||
let mut to_restore = Vec::new();
|
let mut to_restore = Vec::new();
|
||||||
for (k, v) in variables {
|
{
|
||||||
to_restore.push((k.clone(), mem.get(&k, SourceRange::default()).ok().cloned()));
|
let mem = exec_state.mut_memory();
|
||||||
mem.add(k, v, SourceRange::synthetic())
|
|
||||||
.map_err(KclErrorWithOutputs::no_outputs)?;
|
// Push a scope so that old variables can be overwritten (since we might be re-executing some
|
||||||
|
// part of the scene).
|
||||||
|
mem.push_new_env_for_scope();
|
||||||
|
|
||||||
|
// Add any extra variables to memory (we want to remove these variables after execution, but
|
||||||
|
// can't do this using scopes because we want to keep the results of computation in other cases).
|
||||||
|
for (k, v) in variables {
|
||||||
|
to_restore.push((k.clone(), mem.get(&k, SourceRange::default()).ok().cloned()));
|
||||||
|
mem.add(k, v, SourceRange::synthetic())
|
||||||
|
.map_err(KclErrorWithOutputs::no_outputs)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push a scope so that old variables can be overwritten (since we might be re-executing some
|
let result = self.inner_run(&program.ast, &mut exec_state, true).await?;
|
||||||
// part of the scene).
|
|
||||||
mem.push_new_env_for_scope();
|
|
||||||
|
|
||||||
*exec_state.mut_memory() = mem;
|
|
||||||
|
|
||||||
self.inner_run(&program.ast, &mut exec_state, init_mem).await?;
|
|
||||||
|
|
||||||
// Restore any temporary variables, then save any newly created variables back to
|
// Restore any temporary variables, then save any newly created variables back to
|
||||||
// memory in case another run wants to use them. Note this is just saved to the preserved
|
// memory in case another run wants to use them. Note this is just saved to the preserved
|
||||||
// memory, not to the exec_state which is not cached for mock execution.
|
// memory, not to the exec_state which is not cached for mock execution.
|
||||||
let mut mem = exec_state.memory().clone();
|
let mut mem = exec_state.memory().clone();
|
||||||
|
|
||||||
let top = mem.pop_and_preserve_env();
|
mem.squash_env(result.0);
|
||||||
for (k, v) in to_restore {
|
for (k, v) in to_restore {
|
||||||
match v {
|
match v {
|
||||||
Some(v) => mem.insert_or_update(k, v),
|
Some(v) => mem.insert_or_update(k, v),
|
||||||
None => mem.clear(k),
|
None => mem.clear(k),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mem.squash_env(top);
|
|
||||||
|
|
||||||
cache::write_old_memory(mem).await;
|
cache::write_old_memory(mem).await;
|
||||||
|
|
||||||
let outcome = exec_state.to_mock_wasm_outcome();
|
let outcome = exec_state.to_mock_wasm_outcome(result.0);
|
||||||
Ok(outcome)
|
Ok(outcome)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run_with_caching(&self, program: crate::Program) -> Result<ExecOutcome, KclErrorWithOutputs> {
|
pub async fn run_with_caching(&self, program: crate::Program) -> Result<ExecOutcome, KclErrorWithOutputs> {
|
||||||
assert!(!self.is_mock());
|
assert!(!self.is_mock());
|
||||||
|
|
||||||
let (program, mut exec_state, init_mem) = if let Some(OldAstState {
|
let (program, mut exec_state, preserve_mem) = if let Some(OldAstState {
|
||||||
ast: old_ast,
|
ast: old_ast,
|
||||||
exec_state: old_state,
|
exec_state: mut old_state,
|
||||||
settings: old_settings,
|
settings: old_settings,
|
||||||
|
result_env,
|
||||||
}) = cache::read_old_ast().await
|
}) = cache::read_old_ast().await
|
||||||
{
|
{
|
||||||
let old = CacheInformation {
|
let old = CacheInformation {
|
||||||
@ -591,17 +600,18 @@ impl ExecutorContext {
|
|||||||
ast: old_ast,
|
ast: old_ast,
|
||||||
exec_state: old_state.clone(),
|
exec_state: old_state.clone(),
|
||||||
settings: self.settings.clone(),
|
settings: self.settings.clone(),
|
||||||
|
result_env,
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
return Ok(old_state.to_wasm_outcome());
|
return Ok(old_state.to_wasm_outcome(result_env));
|
||||||
}
|
}
|
||||||
(true, program.ast)
|
(true, program.ast)
|
||||||
}
|
}
|
||||||
CacheResult::NoAction(false) => return Ok(old_state.to_wasm_outcome()),
|
CacheResult::NoAction(false) => return Ok(old_state.to_wasm_outcome(result_env)),
|
||||||
};
|
};
|
||||||
|
|
||||||
let exec_state = if clear_scene {
|
let (exec_state, preserve_mem) = if clear_scene {
|
||||||
// Pop the execution state, since we are starting fresh.
|
// Pop the execution state, since we are starting fresh.
|
||||||
let mut exec_state = old_state;
|
let mut exec_state = old_state;
|
||||||
exec_state.reset(&self.settings);
|
exec_state.reset(&self.settings);
|
||||||
@ -612,38 +622,40 @@ impl ExecutorContext {
|
|||||||
.await
|
.await
|
||||||
.map_err(KclErrorWithOutputs::no_outputs)?;
|
.map_err(KclErrorWithOutputs::no_outputs)?;
|
||||||
|
|
||||||
exec_state
|
(exec_state, false)
|
||||||
} else {
|
} else {
|
||||||
old_state
|
old_state.mut_memory().restore_env(result_env);
|
||||||
|
(old_state, true)
|
||||||
};
|
};
|
||||||
|
|
||||||
(program, exec_state, clear_scene)
|
(program, exec_state, preserve_mem)
|
||||||
} else {
|
} else {
|
||||||
let mut exec_state = ExecState::new(&self.settings);
|
let mut exec_state = ExecState::new(&self.settings);
|
||||||
self.send_clear_scene(&mut exec_state, Default::default())
|
self.send_clear_scene(&mut exec_state, Default::default())
|
||||||
.await
|
.await
|
||||||
.map_err(KclErrorWithOutputs::no_outputs)?;
|
.map_err(KclErrorWithOutputs::no_outputs)?;
|
||||||
(program.ast, exec_state, true)
|
(program.ast, exec_state, false)
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = self.inner_run(&program, &mut exec_state, init_mem).await;
|
let result = self.inner_run(&program, &mut exec_state, preserve_mem).await;
|
||||||
|
|
||||||
if result.is_err() {
|
if result.is_err() {
|
||||||
cache::bust_cache().await;
|
cache::bust_cache().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Throw the error.
|
// Throw the error.
|
||||||
result?;
|
let result = result?;
|
||||||
|
|
||||||
// Save this as the last successful execution to the cache.
|
// Save this as the last successful execution to the cache.
|
||||||
cache::write_old_ast(OldAstState {
|
cache::write_old_ast(OldAstState {
|
||||||
ast: program,
|
ast: program,
|
||||||
exec_state: exec_state.clone(),
|
exec_state: exec_state.clone(),
|
||||||
settings: self.settings.clone(),
|
settings: self.settings.clone(),
|
||||||
|
result_env: result.0,
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Ok(exec_state.to_wasm_outcome())
|
Ok(exec_state.to_wasm_outcome(result.0))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Perform the execution of a program.
|
/// Perform the execution of a program.
|
||||||
@ -656,7 +668,7 @@ impl ExecutorContext {
|
|||||||
&self,
|
&self,
|
||||||
program: &crate::Program,
|
program: &crate::Program,
|
||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
) -> Result<Option<ModelingSessionData>, KclError> {
|
) -> Result<(EnvironmentRef, Option<ModelingSessionData>), KclError> {
|
||||||
self.run_with_ui_outputs(program, exec_state)
|
self.run_with_ui_outputs(program, exec_state)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
@ -673,11 +685,11 @@ impl ExecutorContext {
|
|||||||
&self,
|
&self,
|
||||||
program: &crate::Program,
|
program: &crate::Program,
|
||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
) -> Result<Option<ModelingSessionData>, KclErrorWithOutputs> {
|
) -> Result<(EnvironmentRef, Option<ModelingSessionData>), KclErrorWithOutputs> {
|
||||||
self.send_clear_scene(exec_state, Default::default())
|
self.send_clear_scene(exec_state, Default::default())
|
||||||
.await
|
.await
|
||||||
.map_err(KclErrorWithOutputs::no_outputs)?;
|
.map_err(KclErrorWithOutputs::no_outputs)?;
|
||||||
self.inner_run(&program.ast, exec_state, true).await
|
self.inner_run(&program.ast, exec_state, false).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Perform the execution of a program. Accept all possible parameters and
|
/// Perform the execution of a program. Accept all possible parameters and
|
||||||
@ -686,8 +698,8 @@ impl ExecutorContext {
|
|||||||
&self,
|
&self,
|
||||||
program: &Node<Program>,
|
program: &Node<Program>,
|
||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
init_mem: bool,
|
preserve_mem: bool,
|
||||||
) -> Result<Option<ModelingSessionData>, KclErrorWithOutputs> {
|
) -> Result<(EnvironmentRef, Option<ModelingSessionData>), KclErrorWithOutputs> {
|
||||||
let _stats = crate::log::LogPerfStats::new("Interpretation");
|
let _stats = crate::log::LogPerfStats::new("Interpretation");
|
||||||
|
|
||||||
// Re-apply the settings, in case the cache was busted.
|
// Re-apply the settings, in case the cache was busted.
|
||||||
@ -696,7 +708,8 @@ impl ExecutorContext {
|
|||||||
.await
|
.await
|
||||||
.map_err(KclErrorWithOutputs::no_outputs)?;
|
.map_err(KclErrorWithOutputs::no_outputs)?;
|
||||||
|
|
||||||
self.execute_and_build_graph(program, exec_state, init_mem)
|
let env_ref = self
|
||||||
|
.execute_and_build_graph(program, exec_state, preserve_mem)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
KclErrorWithOutputs::new(
|
KclErrorWithOutputs::new(
|
||||||
@ -708,7 +721,9 @@ impl ExecutorContext {
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
if !self.is_mock() {
|
if !self.is_mock() {
|
||||||
cache::write_old_memory(exec_state.memory().clone()).await;
|
let mut mem = exec_state.memory().clone();
|
||||||
|
mem.restore_env(env_ref);
|
||||||
|
cache::write_old_memory(mem).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
crate::log::log(format!(
|
crate::log::log(format!(
|
||||||
@ -716,7 +731,7 @@ impl ExecutorContext {
|
|||||||
exec_state.memory().stats
|
exec_state.memory().stats
|
||||||
));
|
));
|
||||||
let session_data = self.engine.get_session_data().await;
|
let session_data = self.engine.get_session_data().await;
|
||||||
Ok(session_data)
|
Ok((env_ref, session_data))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Execute an AST's program and build auxiliary outputs like the artifact
|
/// Execute an AST's program and build auxiliary outputs like the artifact
|
||||||
@ -725,11 +740,18 @@ impl ExecutorContext {
|
|||||||
&self,
|
&self,
|
||||||
program: NodeRef<'_, crate::parsing::ast::types::Program>,
|
program: NodeRef<'_, crate::parsing::ast::types::Program>,
|
||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
init_mem: bool,
|
preserve_mem: bool,
|
||||||
) -> Result<Option<KclValue>, KclError> {
|
) -> Result<EnvironmentRef, KclError> {
|
||||||
// Don't early return! We need to build other outputs regardless of
|
// Don't early return! We need to build other outputs regardless of
|
||||||
// whether execution failed.
|
// whether execution failed.
|
||||||
let exec_result = self.exec_program(program, exec_state, BodyType::Root(init_mem)).await;
|
|
||||||
|
self.eval_prelude(exec_state, SourceRange::from(program).start_as_range())
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let exec_result = self
|
||||||
|
.exec_module_body(program, exec_state, ExecutionKind::Normal, preserve_mem)
|
||||||
|
.await;
|
||||||
|
|
||||||
// Move the artifact commands and responses to simplify cache management
|
// Move the artifact commands and responses to simplify cache management
|
||||||
// and error creation.
|
// and error creation.
|
||||||
exec_state
|
exec_state
|
||||||
@ -749,7 +771,7 @@ impl ExecutorContext {
|
|||||||
) {
|
) {
|
||||||
Ok(artifact_graph) => {
|
Ok(artifact_graph) => {
|
||||||
exec_state.global.artifact_graph = artifact_graph;
|
exec_state.global.artifact_graph = artifact_graph;
|
||||||
exec_result
|
exec_result.map(|(_, env_ref)| env_ref)
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Prefer the exec error.
|
// Prefer the exec error.
|
||||||
@ -758,6 +780,30 @@ impl ExecutorContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 'Import' std::prelude as the outermost scope.
|
||||||
|
async fn eval_prelude(&self, exec_state: &mut ExecState, source_range: SourceRange) -> Result<(), KclError> {
|
||||||
|
if exec_state.memory().requires_std() {
|
||||||
|
let id = self
|
||||||
|
.open_module(
|
||||||
|
&ImportPath::Std {
|
||||||
|
path: vec!["std".to_owned(), "prelude".to_owned()],
|
||||||
|
},
|
||||||
|
&[],
|
||||||
|
exec_state,
|
||||||
|
source_range,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
let (module_memory, _) = self
|
||||||
|
.exec_module_for_items(id, exec_state, ExecutionKind::Isolated, source_range)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
exec_state.mut_memory().set_std(module_memory);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Update the units for the executor.
|
/// Update the units for the executor.
|
||||||
pub(crate) fn update_units(&mut self, units: UnitLength) {
|
pub(crate) fn update_units(&mut self, units: UnitLength) {
|
||||||
self.settings.units = units;
|
self.settings.units = units;
|
||||||
@ -809,7 +855,7 @@ impl ExecutorContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
async fn parse_execute(code: &str) -> Result<(crate::Program, ExecutorContext, ExecState)> {
|
async fn parse_execute(code: &str) -> Result<(crate::Program, EnvironmentRef, ExecutorContext, ExecState)> {
|
||||||
let program = crate::Program::parse_no_errs(code)?;
|
let program = crate::Program::parse_no_errs(code)?;
|
||||||
|
|
||||||
let ctx = ExecutorContext {
|
let ctx = ExecutorContext {
|
||||||
@ -820,9 +866,9 @@ async fn parse_execute(code: &str) -> Result<(crate::Program, ExecutorContext, E
|
|||||||
context_type: ContextType::Mock,
|
context_type: ContextType::Mock,
|
||||||
};
|
};
|
||||||
let mut exec_state = ExecState::new(&ctx.settings);
|
let mut exec_state = ExecState::new(&ctx.settings);
|
||||||
ctx.run(&program, &mut exec_state).await?;
|
let result = ctx.run(&program, &mut exec_state).await?;
|
||||||
|
|
||||||
Ok((program, ctx, exec_state))
|
Ok((program, result.0, ctx, exec_state))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -834,14 +880,14 @@ mod tests {
|
|||||||
|
|
||||||
/// Convenience function to get a JSON value from memory and unwrap.
|
/// Convenience function to get a JSON value from memory and unwrap.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn mem_get_json(memory: &ProgramMemory, name: &str) -> KclValue {
|
fn mem_get_json(memory: &ProgramMemory, env: EnvironmentRef, name: &str) -> KclValue {
|
||||||
memory.get(name, SourceRange::default()).unwrap().to_owned()
|
memory.get_from(name, env, SourceRange::default()).unwrap().to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn test_execute_warn() {
|
async fn test_execute_warn() {
|
||||||
let text = "@blah";
|
let text = "@blah";
|
||||||
let (_, _, exec_state) = parse_execute(text).await.unwrap();
|
let (_, _, _, exec_state) = parse_execute(text).await.unwrap();
|
||||||
let errs = exec_state.errors();
|
let errs = exec_state.errors();
|
||||||
assert_eq!(errs.len(), 1);
|
assert_eq!(errs.len(), 1);
|
||||||
assert_eq!(errs[0].severity, crate::errors::Severity::Warning);
|
assert_eq!(errs[0].severity, crate::errors::Severity::Warning);
|
||||||
@ -855,7 +901,7 @@ mod tests {
|
|||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn test_warn_on_deprecated() {
|
async fn test_warn_on_deprecated() {
|
||||||
let text = "p = pi()";
|
let text = "p = pi()";
|
||||||
let (_, _, exec_state) = parse_execute(text).await.unwrap();
|
let (_, _, _, exec_state) = parse_execute(text).await.unwrap();
|
||||||
let errs = exec_state.errors();
|
let errs = exec_state.errors();
|
||||||
assert_eq!(errs.len(), 1);
|
assert_eq!(errs.len(), 1);
|
||||||
assert_eq!(errs[0].severity, crate::errors::Severity::Warning);
|
assert_eq!(errs[0].severity, crate::errors::Severity::Warning);
|
||||||
@ -1229,6 +1275,14 @@ const answer = returnX()"#;
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_override_prelude() {
|
||||||
|
let text = "PI = 3.0";
|
||||||
|
let (_, _, _, exec_state) = parse_execute(text).await.unwrap();
|
||||||
|
let errs = exec_state.errors();
|
||||||
|
assert!(errs.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn test_cannot_shebang_in_fn() {
|
async fn test_cannot_shebang_in_fn() {
|
||||||
let ast = r#"
|
let ast = r#"
|
||||||
@ -1291,48 +1345,51 @@ let shape = layer() |> patternTransform(instances = 10, transform = transform)
|
|||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn test_math_execute_with_functions() {
|
async fn test_math_execute_with_functions() {
|
||||||
let ast = r#"const myVar = 2 + min(100, -1 + legLen(5, 3))"#;
|
let ast = r#"const myVar = 2 + min(100, -1 + legLen(5, 3))"#;
|
||||||
let (_, _, exec_state) = parse_execute(ast).await.unwrap();
|
let (_, env, _, exec_state) = parse_execute(ast).await.unwrap();
|
||||||
assert_eq!(5.0, mem_get_json(exec_state.memory(), "myVar").as_f64().unwrap());
|
assert_eq!(5.0, mem_get_json(exec_state.memory(), env, "myVar").as_f64().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn test_math_execute() {
|
async fn test_math_execute() {
|
||||||
let ast = r#"const myVar = 1 + 2 * (3 - 4) / -5 + 6"#;
|
let ast = r#"const myVar = 1 + 2 * (3 - 4) / -5 + 6"#;
|
||||||
let (_, _, exec_state) = parse_execute(ast).await.unwrap();
|
let (_, env, _, exec_state) = parse_execute(ast).await.unwrap();
|
||||||
assert_eq!(7.4, mem_get_json(exec_state.memory(), "myVar").as_f64().unwrap());
|
assert_eq!(7.4, mem_get_json(exec_state.memory(), env, "myVar").as_f64().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn test_math_execute_start_negative() {
|
async fn test_math_execute_start_negative() {
|
||||||
let ast = r#"const myVar = -5 + 6"#;
|
let ast = r#"const myVar = -5 + 6"#;
|
||||||
let (_, _, exec_state) = parse_execute(ast).await.unwrap();
|
let (_, env, _, exec_state) = parse_execute(ast).await.unwrap();
|
||||||
assert_eq!(1.0, mem_get_json(exec_state.memory(), "myVar").as_f64().unwrap());
|
assert_eq!(1.0, mem_get_json(exec_state.memory(), env, "myVar").as_f64().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn test_math_execute_with_pi() {
|
async fn test_math_execute_with_pi() {
|
||||||
let ast = r#"const myVar = PI * 2"#;
|
let ast = r#"const myVar = PI * 2"#;
|
||||||
let (_, _, exec_state) = parse_execute(ast).await.unwrap();
|
let (_, env, _, exec_state) = parse_execute(ast).await.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
std::f64::consts::TAU,
|
std::f64::consts::TAU,
|
||||||
mem_get_json(exec_state.memory(), "myVar").as_f64().unwrap()
|
mem_get_json(exec_state.memory(), env, "myVar").as_f64().unwrap()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn test_math_define_decimal_without_leading_zero() {
|
async fn test_math_define_decimal_without_leading_zero() {
|
||||||
let ast = r#"let thing = .4 + 7"#;
|
let ast = r#"let thing = .4 + 7"#;
|
||||||
let (_, _, exec_state) = parse_execute(ast).await.unwrap();
|
let (_, env, _, exec_state) = parse_execute(ast).await.unwrap();
|
||||||
assert_eq!(7.4, mem_get_json(exec_state.memory(), "thing").as_f64().unwrap());
|
assert_eq!(7.4, mem_get_json(exec_state.memory(), env, "thing").as_f64().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn test_unit_default() {
|
async fn test_unit_default() {
|
||||||
let ast = r#"const inMm = 25.4 * mm()
|
let ast = r#"const inMm = 25.4 * mm()
|
||||||
const inInches = 1.0 * inch()"#;
|
const inInches = 1.0 * inch()"#;
|
||||||
let (_, _, exec_state) = parse_execute(ast).await.unwrap();
|
let (_, env, _, exec_state) = parse_execute(ast).await.unwrap();
|
||||||
assert_eq!(25.4, mem_get_json(exec_state.memory(), "inMm").as_f64().unwrap());
|
assert_eq!(25.4, mem_get_json(exec_state.memory(), env, "inMm").as_f64().unwrap());
|
||||||
assert_eq!(25.4, mem_get_json(exec_state.memory(), "inInches").as_f64().unwrap());
|
assert_eq!(
|
||||||
|
25.4,
|
||||||
|
mem_get_json(exec_state.memory(), env, "inInches").as_f64().unwrap()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
@ -1340,9 +1397,15 @@ const inInches = 1.0 * inch()"#;
|
|||||||
let ast = r#"@settings(defaultLengthUnit = inch)
|
let ast = r#"@settings(defaultLengthUnit = inch)
|
||||||
const inMm = 25.4 * mm()
|
const inMm = 25.4 * mm()
|
||||||
const inInches = 1.0 * inch()"#;
|
const inInches = 1.0 * inch()"#;
|
||||||
let (_, _, exec_state) = parse_execute(ast).await.unwrap();
|
let (_, env, _, exec_state) = parse_execute(ast).await.unwrap();
|
||||||
assert_eq!(1.0, mem_get_json(exec_state.memory(), "inMm").as_f64().unwrap().round());
|
assert_eq!(
|
||||||
assert_eq!(1.0, mem_get_json(exec_state.memory(), "inInches").as_f64().unwrap());
|
1.0,
|
||||||
|
mem_get_json(exec_state.memory(), env, "inMm").as_f64().unwrap().round()
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
1.0,
|
||||||
|
mem_get_json(exec_state.memory(), env, "inInches").as_f64().unwrap()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
@ -1350,9 +1413,15 @@ const inInches = 1.0 * inch()"#;
|
|||||||
let ast = r#"@settings(defaultLengthUnit = in)
|
let ast = r#"@settings(defaultLengthUnit = in)
|
||||||
const inMm = 25.4 * mm()
|
const inMm = 25.4 * mm()
|
||||||
const inInches = 2.0 * inch()"#;
|
const inInches = 2.0 * inch()"#;
|
||||||
let (_, _, exec_state) = parse_execute(ast).await.unwrap();
|
let (_, env, _, exec_state) = parse_execute(ast).await.unwrap();
|
||||||
assert_eq!(1.0, mem_get_json(exec_state.memory(), "inMm").as_f64().unwrap().round());
|
assert_eq!(
|
||||||
assert_eq!(2.0, mem_get_json(exec_state.memory(), "inInches").as_f64().unwrap());
|
1.0,
|
||||||
|
mem_get_json(exec_state.memory(), env, "inMm").as_f64().unwrap().round()
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
2.0,
|
||||||
|
mem_get_json(exec_state.memory(), env, "inInches").as_f64().unwrap()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
@ -1391,11 +1460,17 @@ fn check = (x) => {
|
|||||||
}
|
}
|
||||||
check(false)
|
check(false)
|
||||||
"#;
|
"#;
|
||||||
let (_, _, exec_state) = parse_execute(ast).await.unwrap();
|
let (_, env, _, exec_state) = parse_execute(ast).await.unwrap();
|
||||||
assert_eq!(false, mem_get_json(exec_state.memory(), "notTrue").as_bool().unwrap());
|
assert_eq!(
|
||||||
assert_eq!(true, mem_get_json(exec_state.memory(), "notFalse").as_bool().unwrap());
|
false,
|
||||||
assert_eq!(true, mem_get_json(exec_state.memory(), "c").as_bool().unwrap());
|
mem_get_json(exec_state.memory(), env, "notTrue").as_bool().unwrap()
|
||||||
assert_eq!(false, mem_get_json(exec_state.memory(), "d").as_bool().unwrap());
|
);
|
||||||
|
assert_eq!(
|
||||||
|
true,
|
||||||
|
mem_get_json(exec_state.memory(), env, "notFalse").as_bool().unwrap()
|
||||||
|
);
|
||||||
|
assert_eq!(true, mem_get_json(exec_state.memory(), env, "c").as_bool().unwrap());
|
||||||
|
assert_eq!(false, mem_get_json(exec_state.memory(), env, "d").as_bool().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
@ -1749,4 +1824,44 @@ let w = f() + f()
|
|||||||
// Ensure the settings are as expected.
|
// Ensure the settings are as expected.
|
||||||
assert_eq!(settings_state, ctx.settings);
|
assert_eq!(settings_state, ctx.settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn mock_variables() {
|
||||||
|
let ctx = ExecutorContext::new_mock().await;
|
||||||
|
|
||||||
|
let program = crate::Program::parse_no_errs("x = y").unwrap();
|
||||||
|
let mut vars = IndexMap::new();
|
||||||
|
vars.insert(
|
||||||
|
"y".to_owned(),
|
||||||
|
KclValue::Number {
|
||||||
|
value: 2.0,
|
||||||
|
ty: kcl_value::NumericType::Unknown,
|
||||||
|
meta: Vec::new(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
let result = ctx.run_mock(program, true, vars).await.unwrap();
|
||||||
|
assert_eq!(result.variables.get("x").unwrap().as_f64().unwrap(), 2.0);
|
||||||
|
cache::read_old_memory()
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
.get("y", SourceRange::default())
|
||||||
|
.unwrap_err();
|
||||||
|
|
||||||
|
let program2 = crate::Program::parse_no_errs("z = x + 1").unwrap();
|
||||||
|
let result = ctx.run_mock(program2, true, IndexMap::new()).await.unwrap();
|
||||||
|
assert_eq!(result.variables.get("z").unwrap().as_f64().unwrap(), 3.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn mock_after_not_mock() {
|
||||||
|
let ctx = ExecutorContext::new_with_default_client(UnitLength::Mm).await.unwrap();
|
||||||
|
let program = crate::Program::parse_no_errs("x = 2").unwrap();
|
||||||
|
let result = ctx.run_with_caching(program).await.unwrap();
|
||||||
|
assert_eq!(result.variables.get("x").unwrap().as_f64().unwrap(), 2.0);
|
||||||
|
|
||||||
|
let ctx2 = ExecutorContext::new_mock().await;
|
||||||
|
let program2 = crate::Program::parse_no_errs("z = x + 1").unwrap();
|
||||||
|
let result = ctx2.run_mock(program2, true, IndexMap::new()).await.unwrap();
|
||||||
|
assert_eq!(result.variables.get("z").unwrap().as_f64().unwrap(), 3.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ use crate::{
|
|||||||
CompilationError,
|
CompilationError,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use super::EnvironmentRef;
|
||||||
|
|
||||||
/// State for executing a program.
|
/// State for executing a program.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ExecState {
|
pub struct ExecState {
|
||||||
@ -108,13 +110,13 @@ impl ExecState {
|
|||||||
/// Convert to execution outcome when running in WebAssembly. We want to
|
/// Convert to execution outcome when running in WebAssembly. We want to
|
||||||
/// reduce the amount of data that crosses the WASM boundary as much as
|
/// reduce the amount of data that crosses the WASM boundary as much as
|
||||||
/// possible.
|
/// possible.
|
||||||
pub fn to_wasm_outcome(self) -> ExecOutcome {
|
pub fn to_wasm_outcome(self, main_ref: EnvironmentRef) -> ExecOutcome {
|
||||||
// Fields are opt-in so that we don't accidentally leak private internal
|
// Fields are opt-in so that we don't accidentally leak private internal
|
||||||
// state when we add more to ExecState.
|
// state when we add more to ExecState.
|
||||||
ExecOutcome {
|
ExecOutcome {
|
||||||
variables: self
|
variables: self
|
||||||
.memory()
|
.memory()
|
||||||
.find_all_in_current_env(|_| true)
|
.find_all_in_env(main_ref, |_| true)
|
||||||
.map(|(k, v)| (k.clone(), v.clone()))
|
.map(|(k, v)| (k.clone(), v.clone()))
|
||||||
.collect(),
|
.collect(),
|
||||||
operations: self.mod_local.operations,
|
operations: self.mod_local.operations,
|
||||||
@ -125,13 +127,13 @@ impl ExecState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_mock_wasm_outcome(self) -> ExecOutcome {
|
pub fn to_mock_wasm_outcome(self, main_ref: EnvironmentRef) -> ExecOutcome {
|
||||||
// Fields are opt-in so that we don't accidentally leak private internal
|
// Fields are opt-in so that we don't accidentally leak private internal
|
||||||
// state when we add more to ExecState.
|
// state when we add more to ExecState.
|
||||||
ExecOutcome {
|
ExecOutcome {
|
||||||
variables: self
|
variables: self
|
||||||
.memory()
|
.memory()
|
||||||
.find_all_in_current_env(|_| true)
|
.find_all_in_env(main_ref, |_| true)
|
||||||
.map(|(k, v)| (k.clone(), v.clone()))
|
.map(|(k, v)| (k.clone(), v.clone()))
|
||||||
.collect(),
|
.collect(),
|
||||||
operations: Default::default(),
|
operations: Default::default(),
|
||||||
|
@ -93,7 +93,7 @@ async fn execute(test_name: &str, render_to_png: bool) {
|
|||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
match exec_res {
|
match exec_res {
|
||||||
Ok((exec_state, png)) => {
|
Ok((exec_state, env_ref, png)) => {
|
||||||
let fail_path_str = format!("tests/{test_name}/execution_error.snap");
|
let fail_path_str = format!("tests/{test_name}/execution_error.snap");
|
||||||
let fail_path = Path::new(&fail_path_str);
|
let fail_path = Path::new(&fail_path_str);
|
||||||
if std::fs::exists(fail_path).unwrap() {
|
if std::fs::exists(fail_path).unwrap() {
|
||||||
@ -102,7 +102,7 @@ async fn execute(test_name: &str, render_to_png: bool) {
|
|||||||
if render_to_png {
|
if render_to_png {
|
||||||
twenty_twenty::assert_image(format!("tests/{test_name}/rendered_model.png"), &png, 0.99);
|
twenty_twenty::assert_image(format!("tests/{test_name}/rendered_model.png"), &png, 0.99);
|
||||||
}
|
}
|
||||||
let outcome = exec_state.to_wasm_outcome();
|
let outcome = exec_state.to_wasm_outcome(env_ref);
|
||||||
assert_common_snapshots(
|
assert_common_snapshots(
|
||||||
test_name,
|
test_name,
|
||||||
outcome.operations,
|
outcome.operations,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use derive_docs::stdlib;
|
use derive_docs::stdlib;
|
||||||
use kcmc::{coord::System, format::InputFormat, units::UnitLength};
|
use kcmc::{coord::System, format::InputFormat3d, units::UnitLength};
|
||||||
use kittycad_modeling_cmds as kcmc;
|
use kittycad_modeling_cmds as kcmc;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -64,26 +64,26 @@ pub enum ImportFormat {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ImportFormat> for InputFormat {
|
impl From<ImportFormat> for InputFormat3d {
|
||||||
fn from(format: ImportFormat) -> Self {
|
fn from(format: ImportFormat) -> Self {
|
||||||
match format {
|
match format {
|
||||||
ImportFormat::Fbx {} => InputFormat::Fbx(Default::default()),
|
ImportFormat::Fbx {} => InputFormat3d::Fbx(Default::default()),
|
||||||
ImportFormat::Gltf {} => InputFormat::Gltf(Default::default()),
|
ImportFormat::Gltf {} => InputFormat3d::Gltf(Default::default()),
|
||||||
ImportFormat::Obj { coords, units } => InputFormat::Obj(kcmc::format::obj::import::Options {
|
ImportFormat::Obj { coords, units } => InputFormat3d::Obj(kcmc::format::obj::import::Options {
|
||||||
coords: coords.unwrap_or(ZOO_COORD_SYSTEM),
|
coords: coords.unwrap_or(ZOO_COORD_SYSTEM),
|
||||||
units,
|
units,
|
||||||
}),
|
}),
|
||||||
ImportFormat::Ply { coords, units } => InputFormat::Ply(kcmc::format::ply::import::Options {
|
ImportFormat::Ply { coords, units } => InputFormat3d::Ply(kcmc::format::ply::import::Options {
|
||||||
coords: coords.unwrap_or(ZOO_COORD_SYSTEM),
|
coords: coords.unwrap_or(ZOO_COORD_SYSTEM),
|
||||||
units,
|
units,
|
||||||
}),
|
}),
|
||||||
ImportFormat::Sldprt {} => InputFormat::Sldprt(kcmc::format::sldprt::import::Options {
|
ImportFormat::Sldprt {} => InputFormat3d::Sldprt(kcmc::format::sldprt::import::Options {
|
||||||
split_closed_faces: false,
|
split_closed_faces: false,
|
||||||
}),
|
}),
|
||||||
ImportFormat::Step {} => InputFormat::Step(kcmc::format::step::import::Options {
|
ImportFormat::Step {} => InputFormat3d::Step(kcmc::format::step::import::Options {
|
||||||
split_closed_faces: false,
|
split_closed_faces: false,
|
||||||
}),
|
}),
|
||||||
ImportFormat::Stl { coords, units } => InputFormat::Stl(kcmc::format::stl::import::Options {
|
ImportFormat::Stl { coords, units } => InputFormat3d::Stl(kcmc::format::stl::import::Options {
|
||||||
coords: coords.unwrap_or(ZOO_COORD_SYSTEM),
|
coords: coords.unwrap_or(ZOO_COORD_SYSTEM),
|
||||||
units,
|
units,
|
||||||
}),
|
}),
|
||||||
@ -165,7 +165,7 @@ async fn inner_import(
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
let format = options.map(InputFormat::from);
|
let format = options.map(InputFormat3d::from);
|
||||||
send_import_to_engine(
|
send_import_to_engine(
|
||||||
import_foreign(
|
import_foreign(
|
||||||
std::path::Path::new(&file_path),
|
std::path::Path::new(&file_path),
|
||||||
|
@ -5,7 +5,7 @@ use std::path::PathBuf;
|
|||||||
use crate::{
|
use crate::{
|
||||||
engine::new_zoo_client,
|
engine::new_zoo_client,
|
||||||
errors::ExecErrorWithState,
|
errors::ExecErrorWithState,
|
||||||
execution::{ExecState, ExecutorContext, ExecutorSettings},
|
execution::{EnvironmentRef, ExecState, ExecutorContext, ExecutorSettings},
|
||||||
settings::types::UnitLength,
|
settings::types::UnitLength,
|
||||||
ConnectionError, ExecError, KclError, KclErrorWithOutputs, Program,
|
ConnectionError, ExecError, KclError, KclErrorWithOutputs, Program,
|
||||||
};
|
};
|
||||||
@ -28,7 +28,7 @@ pub async fn execute_and_snapshot(
|
|||||||
let program = Program::parse_no_errs(code).map_err(KclErrorWithOutputs::no_outputs)?;
|
let program = Program::parse_no_errs(code).map_err(KclErrorWithOutputs::no_outputs)?;
|
||||||
let res = do_execute_and_snapshot(&ctx, program)
|
let res = do_execute_and_snapshot(&ctx, program)
|
||||||
.await
|
.await
|
||||||
.map(|(_state, snap)| snap)
|
.map(|(_, _, snap)| snap)
|
||||||
.map_err(|err| err.error);
|
.map_err(|err| err.error);
|
||||||
ctx.close().await;
|
ctx.close().await;
|
||||||
res
|
res
|
||||||
@ -40,7 +40,7 @@ pub async fn execute_and_snapshot_ast(
|
|||||||
ast: Program,
|
ast: Program,
|
||||||
units: UnitLength,
|
units: UnitLength,
|
||||||
current_file: Option<PathBuf>,
|
current_file: Option<PathBuf>,
|
||||||
) -> Result<(ExecState, image::DynamicImage), ExecErrorWithState> {
|
) -> Result<(ExecState, EnvironmentRef, image::DynamicImage), ExecErrorWithState> {
|
||||||
let ctx = new_context(units, true, current_file).await?;
|
let ctx = new_context(units, true, current_file).await?;
|
||||||
let res = do_execute_and_snapshot(&ctx, ast).await;
|
let res = do_execute_and_snapshot(&ctx, ast).await;
|
||||||
ctx.close().await;
|
ctx.close().await;
|
||||||
@ -51,12 +51,12 @@ pub async fn execute_and_snapshot_no_auth(
|
|||||||
code: &str,
|
code: &str,
|
||||||
units: UnitLength,
|
units: UnitLength,
|
||||||
current_file: Option<PathBuf>,
|
current_file: Option<PathBuf>,
|
||||||
) -> Result<image::DynamicImage, ExecError> {
|
) -> Result<(image::DynamicImage, EnvironmentRef), ExecError> {
|
||||||
let ctx = new_context(units, false, current_file).await?;
|
let ctx = new_context(units, false, current_file).await?;
|
||||||
let program = Program::parse_no_errs(code).map_err(KclErrorWithOutputs::no_outputs)?;
|
let program = Program::parse_no_errs(code).map_err(KclErrorWithOutputs::no_outputs)?;
|
||||||
let res = do_execute_and_snapshot(&ctx, program)
|
let res = do_execute_and_snapshot(&ctx, program)
|
||||||
.await
|
.await
|
||||||
.map(|(_state, snap)| snap)
|
.map(|(_, env_ref, snap)| (snap, env_ref))
|
||||||
.map_err(|err| err.error);
|
.map_err(|err| err.error);
|
||||||
ctx.close().await;
|
ctx.close().await;
|
||||||
res
|
res
|
||||||
@ -65,9 +65,10 @@ pub async fn execute_and_snapshot_no_auth(
|
|||||||
async fn do_execute_and_snapshot(
|
async fn do_execute_and_snapshot(
|
||||||
ctx: &ExecutorContext,
|
ctx: &ExecutorContext,
|
||||||
program: Program,
|
program: Program,
|
||||||
) -> Result<(ExecState, image::DynamicImage), ExecErrorWithState> {
|
) -> Result<(ExecState, EnvironmentRef, image::DynamicImage), ExecErrorWithState> {
|
||||||
let mut exec_state = ExecState::new(&ctx.settings);
|
let mut exec_state = ExecState::new(&ctx.settings);
|
||||||
ctx.run_with_ui_outputs(&program, &mut exec_state)
|
let result = ctx
|
||||||
|
.run_with_ui_outputs(&program, &mut exec_state)
|
||||||
.await
|
.await
|
||||||
.map_err(|err| ExecErrorWithState::new(err.into(), exec_state.clone()))?;
|
.map_err(|err| ExecErrorWithState::new(err.into(), exec_state.clone()))?;
|
||||||
for e in exec_state.errors() {
|
for e in exec_state.errors() {
|
||||||
@ -94,7 +95,7 @@ async fn do_execute_and_snapshot(
|
|||||||
|
|
||||||
ctx.close().await;
|
ctx.close().await;
|
||||||
|
|
||||||
Ok((exec_state, img))
|
Ok((exec_state, result.0, img))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn new_context(
|
pub async fn new_context(
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@no_prelude
|
@no_std
|
||||||
|
|
||||||
/// The value of `pi`, Archimedes’ constant (π).
|
/// The value of `pi`, Archimedes’ constant (π).
|
||||||
///
|
///
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
@no_prelude
|
@no_std
|
||||||
|
|
||||||
|
// Note that everything in the prelude is treated as exported.
|
||||||
|
|
||||||
export import * from "std::math"
|
export import * from "std::math"
|
||||||
|
|
||||||
export ZERO = 0
|
export ZERO = 0
|
||||||
|
@ -3,145 +3,6 @@ source: kcl/src/simulation_tests.rs
|
|||||||
description: Variables in memory after executing add_lots.kcl
|
description: Variables in memory after executing add_lots.kcl
|
||||||
---
|
---
|
||||||
{
|
{
|
||||||
"E": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 2.718281828459045,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
651,
|
|
||||||
689,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"HALF_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 180.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
109,
|
|
||||||
115,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"PI": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 3.141592653589793,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
290,
|
|
||||||
328,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 90.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
84,
|
|
||||||
89,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"TAU": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 6.283185307179586,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1042,
|
|
||||||
1080,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"THREE_QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 270.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
144,
|
|
||||||
150,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ZERO": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 0.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Default",
|
|
||||||
"len": {
|
|
||||||
"type": "Mm"
|
|
||||||
},
|
|
||||||
"angle": {
|
|
||||||
"type": "Degrees"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
60,
|
|
||||||
61,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"cos": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1446,
|
|
||||||
1478,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"f": {
|
"f": {
|
||||||
"type": "Function",
|
"type": "Function",
|
||||||
"__meta": [
|
"__meta": [
|
||||||
@ -154,30 +15,6 @@ description: Variables in memory after executing add_lots.kcl
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sin": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1844,
|
|
||||||
1876,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"tan": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
2234,
|
|
||||||
2266,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"x": {
|
"x": {
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
"value": 10100.0,
|
"value": 10100.0,
|
||||||
|
@ -3,145 +3,6 @@ source: kcl/src/simulation_tests.rs
|
|||||||
description: Variables in memory after executing angled_line.kcl
|
description: Variables in memory after executing angled_line.kcl
|
||||||
---
|
---
|
||||||
{
|
{
|
||||||
"E": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 2.718281828459045,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
651,
|
|
||||||
689,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"HALF_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 180.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
109,
|
|
||||||
115,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"PI": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 3.141592653589793,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
290,
|
|
||||||
328,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 90.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
84,
|
|
||||||
89,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"TAU": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 6.283185307179586,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1042,
|
|
||||||
1080,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"THREE_QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 270.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
144,
|
|
||||||
150,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ZERO": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 0.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Default",
|
|
||||||
"len": {
|
|
||||||
"type": "Mm"
|
|
||||||
},
|
|
||||||
"angle": {
|
|
||||||
"type": "Degrees"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
60,
|
|
||||||
61,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"cos": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1446,
|
|
||||||
1478,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"part001": {
|
"part001": {
|
||||||
"type": "Solid",
|
"type": "Solid",
|
||||||
"value": {
|
"value": {
|
||||||
@ -579,29 +440,5 @@ description: Variables in memory after executing angled_line.kcl
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"sin": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1844,
|
|
||||||
1876,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"tan": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
2234,
|
|
||||||
2266,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,133 +3,6 @@ source: kcl/src/simulation_tests.rs
|
|||||||
description: Variables in memory after executing array_elem_pop.kcl
|
description: Variables in memory after executing array_elem_pop.kcl
|
||||||
---
|
---
|
||||||
{
|
{
|
||||||
"E": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 2.718281828459045,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
651,
|
|
||||||
689,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"HALF_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 180.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
109,
|
|
||||||
115,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"PI": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 3.141592653589793,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
290,
|
|
||||||
328,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 90.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
84,
|
|
||||||
89,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"TAU": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 6.283185307179586,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1042,
|
|
||||||
1080,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"THREE_QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 270.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
144,
|
|
||||||
150,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ZERO": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 0.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Default",
|
|
||||||
"len": {
|
|
||||||
"type": "Mm"
|
|
||||||
},
|
|
||||||
"angle": {
|
|
||||||
"type": "Degrees"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
60,
|
|
||||||
61,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"arr": {
|
"arr": {
|
||||||
"type": "Array",
|
"type": "Array",
|
||||||
"value": [
|
"value": [
|
||||||
@ -210,18 +83,6 @@ description: Variables in memory after executing array_elem_pop.kcl
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"cos": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1446,
|
|
||||||
1478,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"new_arr1": {
|
"new_arr1": {
|
||||||
"type": "Array",
|
"type": "Array",
|
||||||
"value": [
|
"value": [
|
||||||
@ -328,29 +189,5 @@ description: Variables in memory after executing array_elem_pop.kcl
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"sin": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1844,
|
|
||||||
1876,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"tan": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
2234,
|
|
||||||
2266,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,133 +3,6 @@ source: kcl/src/simulation_tests.rs
|
|||||||
description: Variables in memory after executing array_elem_push.kcl
|
description: Variables in memory after executing array_elem_push.kcl
|
||||||
---
|
---
|
||||||
{
|
{
|
||||||
"E": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 2.718281828459045,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
651,
|
|
||||||
689,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"HALF_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 180.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
109,
|
|
||||||
115,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"PI": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 3.141592653589793,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
290,
|
|
||||||
328,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 90.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
84,
|
|
||||||
89,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"TAU": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 6.283185307179586,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1042,
|
|
||||||
1080,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"THREE_QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 270.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
144,
|
|
||||||
150,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ZERO": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 0.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Default",
|
|
||||||
"len": {
|
|
||||||
"type": "Mm"
|
|
||||||
},
|
|
||||||
"angle": {
|
|
||||||
"type": "Degrees"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
60,
|
|
||||||
61,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"arr": {
|
"arr": {
|
||||||
"type": "Array",
|
"type": "Array",
|
||||||
"value": [
|
"value": [
|
||||||
@ -210,18 +83,6 @@ description: Variables in memory after executing array_elem_push.kcl
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"cos": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1446,
|
|
||||||
1478,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"new_arr1": {
|
"new_arr1": {
|
||||||
"type": "Array",
|
"type": "Array",
|
||||||
"value": [
|
"value": [
|
||||||
@ -447,29 +308,5 @@ description: Variables in memory after executing array_elem_push.kcl
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"sin": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1844,
|
|
||||||
1876,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"tan": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
2234,
|
|
||||||
2266,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,145 +3,6 @@ source: kcl/src/simulation_tests.rs
|
|||||||
description: Variables in memory after executing array_range_expr.kcl
|
description: Variables in memory after executing array_range_expr.kcl
|
||||||
---
|
---
|
||||||
{
|
{
|
||||||
"E": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 2.718281828459045,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
651,
|
|
||||||
689,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"HALF_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 180.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
109,
|
|
||||||
115,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"PI": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 3.141592653589793,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
290,
|
|
||||||
328,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 90.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
84,
|
|
||||||
89,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"TAU": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 6.283185307179586,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1042,
|
|
||||||
1080,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"THREE_QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 270.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
144,
|
|
||||||
150,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ZERO": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 0.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Default",
|
|
||||||
"len": {
|
|
||||||
"type": "Mm"
|
|
||||||
},
|
|
||||||
"angle": {
|
|
||||||
"type": "Degrees"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
60,
|
|
||||||
61,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"cos": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1446,
|
|
||||||
1478,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"five": {
|
"five": {
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
"value": 5.0,
|
"value": 5.0,
|
||||||
@ -582,30 +443,6 @@ description: Variables in memory after executing array_range_expr.kcl
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sin": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1844,
|
|
||||||
1876,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"tan": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
2234,
|
|
||||||
2266,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"zero": {
|
"zero": {
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
"value": 0.0,
|
"value": 0.0,
|
||||||
|
@ -3,169 +3,6 @@ source: kcl/src/simulation_tests.rs
|
|||||||
description: Variables in memory after executing array_range_negative_expr.kcl
|
description: Variables in memory after executing array_range_negative_expr.kcl
|
||||||
---
|
---
|
||||||
{
|
{
|
||||||
"E": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 2.718281828459045,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
651,
|
|
||||||
689,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"HALF_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 180.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
109,
|
|
||||||
115,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"PI": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 3.141592653589793,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
290,
|
|
||||||
328,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 90.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
84,
|
|
||||||
89,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"TAU": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 6.283185307179586,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1042,
|
|
||||||
1080,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"THREE_QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 270.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
144,
|
|
||||||
150,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ZERO": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 0.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Default",
|
|
||||||
"len": {
|
|
||||||
"type": "Mm"
|
|
||||||
},
|
|
||||||
"angle": {
|
|
||||||
"type": "Degrees"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
60,
|
|
||||||
61,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"cos": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1446,
|
|
||||||
1478,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"sin": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1844,
|
|
||||||
1876,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"tan": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
2234,
|
|
||||||
2266,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"xs": {
|
"xs": {
|
||||||
"type": "Array",
|
"type": "Array",
|
||||||
"value": [
|
"value": [
|
||||||
|
@ -1,148 +1,8 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/simulation_tests.rs
|
source: kcl/src/simulation_tests.rs
|
||||||
description: Variables in memory after executing artifact_graph_example_code1.kcl
|
description: Variables in memory after executing artifact_graph_example_code1.kcl
|
||||||
snapshot_kind: text
|
|
||||||
---
|
---
|
||||||
{
|
{
|
||||||
"E": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 2.718281828459045,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
651,
|
|
||||||
689,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"HALF_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 180.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
109,
|
|
||||||
115,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"PI": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 3.141592653589793,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
290,
|
|
||||||
328,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 90.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
84,
|
|
||||||
89,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"TAU": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 6.283185307179586,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1042,
|
|
||||||
1080,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"THREE_QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 270.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
144,
|
|
||||||
150,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ZERO": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 0.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Default",
|
|
||||||
"len": {
|
|
||||||
"type": "Mm"
|
|
||||||
},
|
|
||||||
"angle": {
|
|
||||||
"type": "Degrees"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
60,
|
|
||||||
61,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"cos": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1446,
|
|
||||||
1478,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"extrude001": {
|
"extrude001": {
|
||||||
"type": "Solid",
|
"type": "Solid",
|
||||||
"value": {
|
"value": {
|
||||||
@ -1313,18 +1173,6 @@ snapshot_kind: text
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sin": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1844,
|
|
||||||
1876,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"sketch001": {
|
"sketch001": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
@ -2228,17 +2076,5 @@ snapshot_kind: text
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"tan": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
2234,
|
|
||||||
2266,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,145 +3,6 @@ source: kcl/src/simulation_tests.rs
|
|||||||
description: Variables in memory after executing artifact_graph_example_code_no_3d.kcl
|
description: Variables in memory after executing artifact_graph_example_code_no_3d.kcl
|
||||||
---
|
---
|
||||||
{
|
{
|
||||||
"E": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 2.718281828459045,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
651,
|
|
||||||
689,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"HALF_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 180.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
109,
|
|
||||||
115,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"PI": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 3.141592653589793,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
290,
|
|
||||||
328,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 90.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
84,
|
|
||||||
89,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"TAU": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 6.283185307179586,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1042,
|
|
||||||
1080,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"THREE_QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 270.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
144,
|
|
||||||
150,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ZERO": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 0.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Default",
|
|
||||||
"len": {
|
|
||||||
"type": "Mm"
|
|
||||||
},
|
|
||||||
"angle": {
|
|
||||||
"type": "Degrees"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
60,
|
|
||||||
61,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"cos": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1446,
|
|
||||||
1478,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"rectangleSegmentA001": {
|
"rectangleSegmentA001": {
|
||||||
"type": "TagIdentifier",
|
"type": "TagIdentifier",
|
||||||
"type": "TagIdentifier",
|
"type": "TagIdentifier",
|
||||||
@ -286,18 +147,6 @@ description: Variables in memory after executing artifact_graph_example_code_no_
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sin": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1844,
|
|
||||||
1876,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"sketch003": {
|
"sketch003": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
@ -799,17 +648,5 @@ description: Variables in memory after executing artifact_graph_example_code_no_
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"tan": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
2234,
|
|
||||||
2266,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,145 +3,6 @@ source: kcl/src/simulation_tests.rs
|
|||||||
description: Variables in memory after executing artifact_graph_example_code_offset_planes.kcl
|
description: Variables in memory after executing artifact_graph_example_code_offset_planes.kcl
|
||||||
---
|
---
|
||||||
{
|
{
|
||||||
"E": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 2.718281828459045,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
651,
|
|
||||||
689,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"HALF_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 180.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
109,
|
|
||||||
115,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"PI": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 3.141592653589793,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
290,
|
|
||||||
328,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 90.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
84,
|
|
||||||
89,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"TAU": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 6.283185307179586,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1042,
|
|
||||||
1080,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"THREE_QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 270.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
144,
|
|
||||||
150,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ZERO": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 0.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Default",
|
|
||||||
"len": {
|
|
||||||
"type": "Mm"
|
|
||||||
},
|
|
||||||
"angle": {
|
|
||||||
"type": "Degrees"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
60,
|
|
||||||
61,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"cos": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1446,
|
|
||||||
1478,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"offsetPlane001": {
|
"offsetPlane001": {
|
||||||
"type": "Plane",
|
"type": "Plane",
|
||||||
"value": {
|
"value": {
|
||||||
@ -238,18 +99,6 @@ description: Variables in memory after executing artifact_graph_example_code_off
|
|||||||
"__meta": []
|
"__meta": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sin": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1844,
|
|
||||||
1876,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"sketch002": {
|
"sketch002": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
@ -347,17 +196,5 @@ description: Variables in memory after executing artifact_graph_example_code_off
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"tan": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
2234,
|
|
||||||
2266,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,145 +3,6 @@ source: kcl/src/simulation_tests.rs
|
|||||||
description: Variables in memory after executing artifact_graph_sketch_on_face_etc.kcl
|
description: Variables in memory after executing artifact_graph_sketch_on_face_etc.kcl
|
||||||
---
|
---
|
||||||
{
|
{
|
||||||
"E": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 2.718281828459045,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
651,
|
|
||||||
689,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"HALF_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 180.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
109,
|
|
||||||
115,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"PI": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 3.141592653589793,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
290,
|
|
||||||
328,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 90.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
84,
|
|
||||||
89,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"TAU": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 6.283185307179586,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Count"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1042,
|
|
||||||
1080,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"THREE_QUARTER_TURN": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 270.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Known",
|
|
||||||
"type": "Angle",
|
|
||||||
"type": "Degrees"
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
144,
|
|
||||||
150,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ZERO": {
|
|
||||||
"type": "Number",
|
|
||||||
"value": 0.0,
|
|
||||||
"ty": {
|
|
||||||
"type": "Default",
|
|
||||||
"len": {
|
|
||||||
"type": "Mm"
|
|
||||||
},
|
|
||||||
"angle": {
|
|
||||||
"type": "Degrees"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
60,
|
|
||||||
61,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"cos": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1446,
|
|
||||||
1478,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"extrude001": {
|
"extrude001": {
|
||||||
"type": "Solid",
|
"type": "Solid",
|
||||||
"value": {
|
"value": {
|
||||||
@ -2932,18 +2793,6 @@ description: Variables in memory after executing artifact_graph_sketch_on_face_e
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sin": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
1844,
|
|
||||||
1876,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"sketch001": {
|
"sketch001": {
|
||||||
"type": "Sketch",
|
"type": "Sketch",
|
||||||
"value": {
|
"value": {
|
||||||
@ -5377,17 +5226,5 @@ description: Variables in memory after executing artifact_graph_sketch_on_face_e
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"tan": {
|
|
||||||
"type": "Function",
|
|
||||||
"__meta": [
|
|
||||||
{
|
|
||||||
"sourceRange": [
|
|
||||||
2234,
|
|
||||||
2266,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|