Compare commits
86 Commits
mike/relat
...
v0.10.0
Author | SHA1 | Date | |
---|---|---|---|
b17e61d963 | |||
d31d07d9c8 | |||
7aa2d63c21 | |||
e1081b0ee6 | |||
59223279b7 | |||
8a4e717565 | |||
80b542ca18 | |||
e4bfc863ea | |||
77ef255de4 | |||
64c3841079 | |||
c7bb6bc845 | |||
1af8a8c64f | |||
eb4776826b | |||
f3dd0469d5 | |||
deea74754d | |||
3fd798c704 | |||
cc9eaf2991 | |||
6f24031220 | |||
672bcd297f | |||
3bc182fe16 | |||
589cd39eec | |||
63feebef5c | |||
65037abd9a | |||
97bc339a62 | |||
4e9a6375a5 | |||
3d19dfb800 | |||
d2a7b84292 | |||
9e02bab155 | |||
7352de5a70 | |||
9797d0cb81 | |||
83907fa9db | |||
a367be4e2b | |||
056fa00adc | |||
4759fb2e6f | |||
45f497d9cd | |||
dc61bdebdf | |||
61943055e5 | |||
416fe0f644 | |||
708465d818 | |||
e706fb02d6 | |||
1bf7daa474 | |||
ffc47f8f40 | |||
768aaa84f6 | |||
f3a700eec8 | |||
c853637a9a | |||
9af30d9ef6 | |||
6164714a6b | |||
64ceb98eba | |||
2cbf260900 | |||
cfaaedf602 | |||
12b3717eb5 | |||
0bc685b0c4 | |||
9ee032771a | |||
c307ddd1b1 | |||
a30818ff2b | |||
53e763d938 | |||
8f74cd1d0c | |||
c271942897 | |||
a03d09b41d | |||
2971b7752b | |||
70e99eb00b | |||
5c66af59d2 | |||
6dda6daeef | |||
b5387f1220 | |||
fd5921b366 | |||
716ad938fc | |||
40136eb392 | |||
8d2b89fcd1 | |||
ad9fba3390 | |||
911c43af50 | |||
ab4e04f6c2 | |||
94aef05f74 | |||
d820cf2446 | |||
0c724c4971 | |||
b54ac4a694 | |||
27227092b1 | |||
04e1b92a5b | |||
0553cd4621 | |||
61a0c88af4 | |||
d5b0544437 | |||
6cc8af5c23 | |||
888104080e | |||
b6769889e3 | |||
a32258dac4 | |||
18dbbad244 | |||
b67c16cc9d |
3
.github/workflows/cargo-build.yml
vendored
3
.github/workflows/cargo-build.yml
vendored
@ -15,6 +15,9 @@ on:
|
|||||||
- '**/Cargo.lock'
|
- '**/Cargo.lock'
|
||||||
- '**/rust-toolchain.toml'
|
- '**/rust-toolchain.toml'
|
||||||
- .github/workflows/cargo-build.yml
|
- .github/workflows/cargo-build.yml
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||||
|
cancel-in-progress: true
|
||||||
name: cargo build
|
name: cargo build
|
||||||
jobs:
|
jobs:
|
||||||
cargobuild:
|
cargobuild:
|
||||||
|
5
.github/workflows/cargo-clippy.yml
vendored
5
.github/workflows/cargo-clippy.yml
vendored
@ -15,6 +15,9 @@ on:
|
|||||||
- '**/rust-toolchain.toml'
|
- '**/rust-toolchain.toml'
|
||||||
- '**.rs'
|
- '**.rs'
|
||||||
- .github/workflows/cargo-build.yml
|
- .github/workflows/cargo-build.yml
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||||
|
cancel-in-progress: true
|
||||||
name: cargo clippy
|
name: cargo clippy
|
||||||
jobs:
|
jobs:
|
||||||
cargoclippy:
|
cargoclippy:
|
||||||
@ -54,4 +57,4 @@ jobs:
|
|||||||
- name: Run clippy
|
- name: Run clippy
|
||||||
run: |
|
run: |
|
||||||
cd "${{ matrix.dir }}"
|
cd "${{ matrix.dir }}"
|
||||||
cargo clippy --all --tests -- -D warnings
|
cargo clippy --all --tests --benches -- -D warnings
|
||||||
|
40
.github/workflows/cargo-criterion.yml
vendored
Normal file
40
.github/workflows/cargo-criterion.yml
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- '**.rs'
|
||||||
|
- '**/Cargo.toml'
|
||||||
|
- '**/Cargo.lock'
|
||||||
|
- '**/rust-toolchain.toml'
|
||||||
|
- .github/workflows/cargo-criterion.yml
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- '**.rs'
|
||||||
|
- '**/Cargo.toml'
|
||||||
|
- '**/Cargo.lock'
|
||||||
|
- '**/rust-toolchain.toml'
|
||||||
|
- .github/workflows/cargo-criterion.yml
|
||||||
|
workflow_dispatch:
|
||||||
|
permissions: read-all
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
name: cargo criterion
|
||||||
|
jobs:
|
||||||
|
cargocriterion:
|
||||||
|
name: cargo criterion
|
||||||
|
runs-on: ubuntu-latest-8-cores
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
cargo install cargo-criterion
|
||||||
|
- name: Rust Cache
|
||||||
|
uses: Swatinem/rust-cache@v2.6.1
|
||||||
|
- name: Benchmark kcl library
|
||||||
|
shell: bash
|
||||||
|
run: |-
|
||||||
|
cd src/wasm-lib/kcl; cargo criterion
|
||||||
|
|
3
.github/workflows/cargo-fmt.yml
vendored
3
.github/workflows/cargo-fmt.yml
vendored
@ -18,6 +18,9 @@ on:
|
|||||||
permissions:
|
permissions:
|
||||||
packages: read
|
packages: read
|
||||||
contents: read
|
contents: read
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||||
|
cancel-in-progress: true
|
||||||
name: cargo fmt
|
name: cargo fmt
|
||||||
jobs:
|
jobs:
|
||||||
cargofmt:
|
cargofmt:
|
||||||
|
4
.github/workflows/cargo-test.yml
vendored
4
.github/workflows/cargo-test.yml
vendored
@ -17,6 +17,9 @@ on:
|
|||||||
- .github/workflows/cargo-test.yml
|
- .github/workflows/cargo-test.yml
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
permissions: read-all
|
permissions: read-all
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||||
|
cancel-in-progress: true
|
||||||
name: cargo test
|
name: cargo test
|
||||||
jobs:
|
jobs:
|
||||||
cargotest:
|
cargotest:
|
||||||
@ -58,4 +61,5 @@ jobs:
|
|||||||
cargo nextest run --workspace --no-fail-fast -P ci
|
cargo nextest run --workspace --no-fail-fast -P ci
|
||||||
env:
|
env:
|
||||||
KITTYCAD_API_TOKEN: ${{secrets.KITTYCAD_API_TOKEN}}
|
KITTYCAD_API_TOKEN: ${{secrets.KITTYCAD_API_TOKEN}}
|
||||||
|
RUST_MIN_STACK: 10485760000
|
||||||
|
|
||||||
|
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -8,6 +8,9 @@ on:
|
|||||||
release:
|
release:
|
||||||
types: [published]
|
types: [published]
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||||
|
cancel-in-progress: true
|
||||||
jobs:
|
jobs:
|
||||||
check-format:
|
check-format:
|
||||||
runs-on: 'ubuntu-20.04'
|
runs-on: 'ubuntu-20.04'
|
||||||
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -22,6 +22,11 @@ npm-debug.log*
|
|||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
src/wasm-lib/.idea
|
||||||
|
src/wasm-lib/.vscode
|
||||||
|
|
||||||
# rust
|
# rust
|
||||||
src/wasm-lib/target
|
src/wasm-lib/target
|
||||||
src/wasm-lib/bindings
|
src/wasm-lib/bindings
|
||||||
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2023 The KittyCAD Authors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
15
README.md
15
README.md
@ -123,13 +123,24 @@ Before you submit a contribution PR to this repo, please ensure that:
|
|||||||
|
|
||||||
## Release a new version
|
## Release a new version
|
||||||
|
|
||||||
1. Bump the versions in the .json files by creating a `Bump to v{x}.{y}.{z}` PR, committing the changes from
|
1. Bump the versions in the .json files by creating a `Cut release v{x}.{y}.{z}` PR, committing the changes from
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
VERSION=x.y.z yarn run bump-jsons
|
VERSION=x.y.z yarn run bump-jsons
|
||||||
```
|
```
|
||||||
|
|
||||||
The PR may serve as a place to discuss the human-readable changelog and extra QA.
|
The PR may serve as a place to discuss the human-readable changelog and extra QA. A quick way of getting PR's merged since the last bump is to [use this PR filter](https://github.com/KittyCAD/modeling-app/pulls?q=is%3Apr+sort%3Aupdated-desc+is%3Amerged+), open up the browser console and past in the following
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
console.log(
|
||||||
|
'- ' +
|
||||||
|
Array.from(
|
||||||
|
document.querySelectorAll('[data-hovercard-type="pull_request"]')
|
||||||
|
).map((a) => `[${a.innerText}](${a.href})`).join(`
|
||||||
|
- `)
|
||||||
|
)
|
||||||
|
```
|
||||||
|
grab the md list and delete any that are older than the last bump
|
||||||
|
|
||||||
2. Merge the PR
|
2. Merge the PR
|
||||||
|
|
||||||
|
3121
docs/kcl/std.json
3121
docs/kcl/std.json
File diff suppressed because it is too large
Load Diff
630
docs/kcl/std.md
630
docs/kcl/std.md
@ -48,8 +48,12 @@
|
|||||||
* [`show`](#show)
|
* [`show`](#show)
|
||||||
* [`sin`](#sin)
|
* [`sin`](#sin)
|
||||||
* [`sqrt`](#sqrt)
|
* [`sqrt`](#sqrt)
|
||||||
|
* [`startProfileAt`](#startProfileAt)
|
||||||
* [`startSketchAt`](#startSketchAt)
|
* [`startSketchAt`](#startSketchAt)
|
||||||
|
* [`startSketchOn`](#startSketchOn)
|
||||||
* [`tan`](#tan)
|
* [`tan`](#tan)
|
||||||
|
* [`tangentalArc`](#tangentalArc)
|
||||||
|
* [`tangentalArcTo`](#tangentalArcTo)
|
||||||
* [`tau`](#tau)
|
* [`tau`](#tau)
|
||||||
* [`xLine`](#xLine)
|
* [`xLine`](#xLine)
|
||||||
* [`xLineTo`](#xLineTo)
|
* [`xLineTo`](#xLineTo)
|
||||||
@ -118,6 +122,8 @@ angleToMatchLengthX(segment_name: string, to: number, sketch_group: SketchGroup)
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -202,6 +208,8 @@ angleToMatchLengthY(segment_name: string, to: number, sketch_group: SketchGroup)
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -296,6 +304,8 @@ angledLine(data: AngledLineData, sketch_group: SketchGroup) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -362,6 +372,8 @@ angledLine(data: AngledLineData, sketch_group: SketchGroup) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -452,6 +464,8 @@ angledLineOfXLength(data: AngledLineData, sketch_group: SketchGroup) -> SketchGr
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -518,6 +532,8 @@ angledLineOfXLength(data: AngledLineData, sketch_group: SketchGroup) -> SketchGr
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -608,6 +624,8 @@ angledLineOfYLength(data: AngledLineData, sketch_group: SketchGroup) -> SketchGr
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -674,6 +692,8 @@ angledLineOfYLength(data: AngledLineData, sketch_group: SketchGroup) -> SketchGr
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -765,6 +785,8 @@ angledLineThatIntersects(data: AngeledLineThatIntersectsData, sketch_group: Sket
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -831,6 +853,8 @@ angledLineThatIntersects(data: AngeledLineThatIntersectsData, sketch_group: Sket
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -921,6 +945,8 @@ angledLineToX(data: AngledLineToData, sketch_group: SketchGroup) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -987,6 +1013,8 @@ angledLineToX(data: AngledLineToData, sketch_group: SketchGroup) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -1077,6 +1105,8 @@ angledLineToY(data: AngledLineToData, sketch_group: SketchGroup) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -1143,6 +1173,8 @@ angledLineToY(data: AngledLineToData, sketch_group: SketchGroup) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -1260,6 +1292,8 @@ arc(data: ArcData, sketch_group: SketchGroup) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -1326,6 +1360,8 @@ arc(data: ArcData, sketch_group: SketchGroup) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -1465,6 +1501,8 @@ bezierCurve(data: BezierData, sketch_group: SketchGroup) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -1531,6 +1569,8 @@ bezierCurve(data: BezierData, sketch_group: SketchGroup) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -1629,6 +1669,8 @@ close(sketch_group: SketchGroup) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -1695,6 +1737,8 @@ close(sketch_group: SketchGroup) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -1813,6 +1857,8 @@ extrude(length: number, sketch_group: SketchGroup) -> ExtrudeGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -1994,6 +2040,8 @@ lastSegX(sketch_group: SketchGroup) -> number
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -2076,6 +2124,8 @@ lastSegY(sketch_group: SketchGroup) -> number
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -2231,6 +2281,8 @@ line(data: LineData, sketch_group: SketchGroup) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -2297,6 +2349,8 @@ line(data: LineData, sketch_group: SketchGroup) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -2385,6 +2439,8 @@ lineTo(data: LineToData, sketch_group: SketchGroup) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -2451,6 +2507,8 @@ lineTo(data: LineToData, sketch_group: SketchGroup) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -2691,6 +2749,8 @@ segAng(segment_name: string, sketch_group: SketchGroup) -> number
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -2774,6 +2834,8 @@ segEndX(segment_name: string, sketch_group: SketchGroup) -> number
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -2857,6 +2919,8 @@ segEndY(segment_name: string, sketch_group: SketchGroup) -> number
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -2940,6 +3004,8 @@ segLen(segment_name: string, sketch_group: SketchGroup) -> number
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -3022,6 +3088,8 @@ show(sketch: SketchGroup)
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -3123,14 +3191,14 @@ sqrt(num: number) -> number
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
### startSketchAt
|
### startProfileAt
|
||||||
|
|
||||||
Start a sketch at a given point.
|
Start a profile at a given point.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
startSketchAt(data: LineData) -> SketchGroup
|
startProfileAt(data: LineData, plane: Plane) -> SketchGroup
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Arguments
|
#### Arguments
|
||||||
@ -3145,6 +3213,40 @@ startSketchAt(data: LineData) -> SketchGroup
|
|||||||
} |
|
} |
|
||||||
[number]
|
[number]
|
||||||
```
|
```
|
||||||
|
* `plane`: `Plane` - A plane.
|
||||||
|
```
|
||||||
|
{
|
||||||
|
// The id of the plane.
|
||||||
|
id: uuid,
|
||||||
|
// Origin of the plane.
|
||||||
|
origin: {
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
z: number,
|
||||||
|
},
|
||||||
|
// Type for a plane.
|
||||||
|
value: string |
|
||||||
|
string,
|
||||||
|
// What should the plane’s X axis be?
|
||||||
|
xAxis: {
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
z: number,
|
||||||
|
},
|
||||||
|
// What should the plane’s Y axis be?
|
||||||
|
yAxis: {
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
z: number,
|
||||||
|
},
|
||||||
|
// The z-axis (normal).
|
||||||
|
zAxis: {
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
z: number,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
@ -3153,6 +3255,8 @@ startSketchAt(data: LineData) -> SketchGroup
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -3214,6 +3318,188 @@ startSketchAt(data: LineData) -> SketchGroup
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### startSketchAt
|
||||||
|
|
||||||
|
Start a sketch at a given point on the 'XY' plane.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
startSketchAt(data: LineData) -> SketchGroup
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Arguments
|
||||||
|
|
||||||
|
* `data`: `LineData` - Data to draw a line.
|
||||||
|
```
|
||||||
|
{
|
||||||
|
// The tag.
|
||||||
|
tag: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
} |
|
||||||
|
[number]
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
* `SketchGroup` - A sketch group is a collection of paths.
|
||||||
|
```
|
||||||
|
{
|
||||||
|
// The id of the sketch group.
|
||||||
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
|
// The position of the sketch group.
|
||||||
|
position: [number],
|
||||||
|
// The rotation of the sketch group.
|
||||||
|
rotation: [number],
|
||||||
|
// The starting path.
|
||||||
|
start: {
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
},
|
||||||
|
// The paths in the sketch group.
|
||||||
|
value: [{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
// The x coordinate.
|
||||||
|
x: number,
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
// The x coordinate.
|
||||||
|
x: number,
|
||||||
|
// The y coordinate.
|
||||||
|
y: number,
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### startSketchOn
|
||||||
|
|
||||||
|
Start a sketch at a given point.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
startSketchOn(data: PlaneData) -> Plane
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Arguments
|
||||||
|
|
||||||
|
* `data`: `PlaneData` - Data for a plane.
|
||||||
|
```
|
||||||
|
string |
|
||||||
|
string |
|
||||||
|
string |
|
||||||
|
string |
|
||||||
|
string |
|
||||||
|
string |
|
||||||
|
{
|
||||||
|
plane: {
|
||||||
|
// Origin of the plane.
|
||||||
|
origin: {
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
z: number,
|
||||||
|
},
|
||||||
|
// What should the plane’s X axis be?
|
||||||
|
x_axis: {
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
z: number,
|
||||||
|
},
|
||||||
|
// What should the plane’s Y axis be?
|
||||||
|
y_axis: {
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
z: number,
|
||||||
|
},
|
||||||
|
// The z-axis (normal).
|
||||||
|
z_axis: {
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
z: number,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
* `Plane` - A plane.
|
||||||
|
```
|
||||||
|
{
|
||||||
|
// The id of the plane.
|
||||||
|
id: uuid,
|
||||||
|
// Origin of the plane.
|
||||||
|
origin: {
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
z: number,
|
||||||
|
},
|
||||||
|
// Type for a plane.
|
||||||
|
value: string |
|
||||||
|
string,
|
||||||
|
// What should the plane’s X axis be?
|
||||||
|
xAxis: {
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
z: number,
|
||||||
|
},
|
||||||
|
// What should the plane’s Y axis be?
|
||||||
|
yAxis: {
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
z: number,
|
||||||
|
},
|
||||||
|
// The z-axis (normal).
|
||||||
|
zAxis: {
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
z: number,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### tan
|
### tan
|
||||||
|
|
||||||
Computes the tangent of a number (in radians).
|
Computes the tangent of a number (in radians).
|
||||||
@ -3234,6 +3520,328 @@ tan(num: number) -> number
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### tangentalArc
|
||||||
|
|
||||||
|
Draw an arc.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
tangentalArc(data: TangentalArcData, sketch_group: SketchGroup) -> SketchGroup
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Arguments
|
||||||
|
|
||||||
|
* `data`: `TangentalArcData` - Data to draw a tangental arc.
|
||||||
|
```
|
||||||
|
{
|
||||||
|
// Offset of the arc, in degrees.
|
||||||
|
offset: number,
|
||||||
|
// Radius of the arc. Not to be confused with Raiders of the Lost Ark.
|
||||||
|
radius: number,
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
// The tag.
|
||||||
|
tag: string,
|
||||||
|
// Where the arc should end. Must lie in the same plane as the current path pen position. Must not be colinear with current path pen position.
|
||||||
|
to: [number],
|
||||||
|
} |
|
||||||
|
[number]
|
||||||
|
```
|
||||||
|
* `sketch_group`: `SketchGroup` - A sketch group is a collection of paths.
|
||||||
|
```
|
||||||
|
{
|
||||||
|
// The id of the sketch group.
|
||||||
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
|
// The position of the sketch group.
|
||||||
|
position: [number],
|
||||||
|
// The rotation of the sketch group.
|
||||||
|
rotation: [number],
|
||||||
|
// The starting path.
|
||||||
|
start: {
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
},
|
||||||
|
// The paths in the sketch group.
|
||||||
|
value: [{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
// The x coordinate.
|
||||||
|
x: number,
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
// The x coordinate.
|
||||||
|
x: number,
|
||||||
|
// The y coordinate.
|
||||||
|
y: number,
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
* `SketchGroup` - A sketch group is a collection of paths.
|
||||||
|
```
|
||||||
|
{
|
||||||
|
// The id of the sketch group.
|
||||||
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
|
// The position of the sketch group.
|
||||||
|
position: [number],
|
||||||
|
// The rotation of the sketch group.
|
||||||
|
rotation: [number],
|
||||||
|
// The starting path.
|
||||||
|
start: {
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
},
|
||||||
|
// The paths in the sketch group.
|
||||||
|
value: [{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
// The x coordinate.
|
||||||
|
x: number,
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
// The x coordinate.
|
||||||
|
x: number,
|
||||||
|
// The y coordinate.
|
||||||
|
y: number,
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### tangentalArcTo
|
||||||
|
|
||||||
|
Draw an arc.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
tangentalArcTo(data: TangentalArcToData, sketch_group: SketchGroup) -> SketchGroup
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Arguments
|
||||||
|
|
||||||
|
* `data`: `TangentalArcToData` - Data to draw a tangental arc to a specific point.
|
||||||
|
```
|
||||||
|
{
|
||||||
|
// The tag.
|
||||||
|
tag: string,
|
||||||
|
// Where the arc should end. Must lie in the same plane as the current path pen position. Must not be colinear with current path pen position.
|
||||||
|
to: [number],
|
||||||
|
} |
|
||||||
|
[number]
|
||||||
|
```
|
||||||
|
* `sketch_group`: `SketchGroup` - A sketch group is a collection of paths.
|
||||||
|
```
|
||||||
|
{
|
||||||
|
// The id of the sketch group.
|
||||||
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
|
// The position of the sketch group.
|
||||||
|
position: [number],
|
||||||
|
// The rotation of the sketch group.
|
||||||
|
rotation: [number],
|
||||||
|
// The starting path.
|
||||||
|
start: {
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
},
|
||||||
|
// The paths in the sketch group.
|
||||||
|
value: [{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
// The x coordinate.
|
||||||
|
x: number,
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
// The x coordinate.
|
||||||
|
x: number,
|
||||||
|
// The y coordinate.
|
||||||
|
y: number,
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
* `SketchGroup` - A sketch group is a collection of paths.
|
||||||
|
```
|
||||||
|
{
|
||||||
|
// The id of the sketch group.
|
||||||
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
|
// The position of the sketch group.
|
||||||
|
position: [number],
|
||||||
|
// The rotation of the sketch group.
|
||||||
|
rotation: [number],
|
||||||
|
// The starting path.
|
||||||
|
start: {
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
},
|
||||||
|
// The paths in the sketch group.
|
||||||
|
value: [{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
// The x coordinate.
|
||||||
|
x: number,
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
// The x coordinate.
|
||||||
|
x: number,
|
||||||
|
// The y coordinate.
|
||||||
|
y: number,
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
// The from point.
|
||||||
|
from: [number],
|
||||||
|
// The name of the path.
|
||||||
|
name: string,
|
||||||
|
// The to point.
|
||||||
|
to: [number],
|
||||||
|
type: string,
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### tau
|
### tau
|
||||||
|
|
||||||
Return the value of `tau`. The full circle constant (τ). Equal to 2π.
|
Return the value of `tau`. The full circle constant (τ). Equal to 2π.
|
||||||
@ -3280,6 +3888,8 @@ number
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -3346,6 +3956,8 @@ number
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -3434,6 +4046,8 @@ number
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -3500,6 +4114,8 @@ number
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -3588,6 +4204,8 @@ number
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -3654,6 +4272,8 @@ number
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -3742,6 +4362,8 @@ number
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
@ -3808,6 +4430,8 @@ number
|
|||||||
{
|
{
|
||||||
// The id of the sketch group.
|
// The id of the sketch group.
|
||||||
id: uuid,
|
id: uuid,
|
||||||
|
// The plane id of the sketch group.
|
||||||
|
planeId: uuid,
|
||||||
// The position of the sketch group.
|
// The position of the sketch group.
|
||||||
position: [number],
|
position: [number],
|
||||||
// The rotation of the sketch group.
|
// The rotation of the sketch group.
|
||||||
|
15
package.json
15
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "untitled-app",
|
"name": "untitled-app",
|
||||||
"version": "0.8.2",
|
"version": "0.10.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codemirror/autocomplete": "^6.9.0",
|
"@codemirror/autocomplete": "^6.9.0",
|
||||||
@ -10,7 +10,7 @@
|
|||||||
"@fortawesome/react-fontawesome": "^0.2.0",
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
||||||
"@headlessui/react": "^1.7.13",
|
"@headlessui/react": "^1.7.13",
|
||||||
"@headlessui/tailwindcss": "^0.2.0",
|
"@headlessui/tailwindcss": "^0.2.0",
|
||||||
"@kittycad/lib": "^0.0.37",
|
"@kittycad/lib": "^0.0.43",
|
||||||
"@lezer/javascript": "^1.4.7",
|
"@lezer/javascript": "^1.4.7",
|
||||||
"@open-rpc/client-js": "^1.8.1",
|
"@open-rpc/client-js": "^1.8.1",
|
||||||
"@react-hook/resize-observer": "^1.2.6",
|
"@react-hook/resize-observer": "^1.2.6",
|
||||||
@ -27,11 +27,12 @@
|
|||||||
"@uiw/react-codemirror": "^4.21.13",
|
"@uiw/react-codemirror": "^4.21.13",
|
||||||
"@xstate/react": "^3.2.2",
|
"@xstate/react": "^3.2.2",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
|
"debounce-promise": "^3.1.2",
|
||||||
"formik": "^2.4.3",
|
"formik": "^2.4.3",
|
||||||
"fuse.js": "^6.6.2",
|
"fuse.js": "^6.6.2",
|
||||||
"http-server": "^14.1.1",
|
"http-server": "^14.1.1",
|
||||||
"json-rpc-2.0": "^1.6.0",
|
"json-rpc-2.0": "^1.6.0",
|
||||||
"re-resizable": "^6.9.9",
|
"re-resizable": "^6.9.11",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-hot-toast": "^2.4.1",
|
"react-hot-toast": "^2.4.1",
|
||||||
@ -47,7 +48,7 @@
|
|||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"typescript": "^4.4.2",
|
"typescript": "^4.4.2",
|
||||||
"uuid": "^9.0.0",
|
"uuid": "^9.0.0",
|
||||||
"vitest": "^0.34.1",
|
"vitest": "^0.34.6",
|
||||||
"vscode-jsonrpc": "^8.1.0",
|
"vscode-jsonrpc": "^8.1.0",
|
||||||
"vscode-languageserver-protocol": "^3.17.3",
|
"vscode-languageserver-protocol": "^3.17.3",
|
||||||
"wasm-pack": "^0.12.1",
|
"wasm-pack": "^0.12.1",
|
||||||
@ -65,7 +66,7 @@
|
|||||||
"pretest": "yarn remove-importmeta",
|
"pretest": "yarn remove-importmeta",
|
||||||
"test": "vitest --mode development",
|
"test": "vitest --mode development",
|
||||||
"test:nowatch": "vitest run --mode development",
|
"test:nowatch": "vitest run --mode development",
|
||||||
"test:rust": "(cd src/wasm-lib && cargo test --all && cargo clippy --all --tests)",
|
"test:rust": "(cd src/wasm-lib && cargo test --all && cargo clippy --all --tests --benches)",
|
||||||
"test:cov": "vitest run --coverage --mode development",
|
"test:cov": "vitest run --coverage --mode development",
|
||||||
"simpleserver:ci": "yarn pretest && http-server ./public --cors -p 3000 &",
|
"simpleserver:ci": "yarn pretest && http-server ./public --cors -p 3000 &",
|
||||||
"simpleserver": "yarn pretest && http-server ./public --cors -p 3000",
|
"simpleserver": "yarn pretest && http-server ./public --cors -p 3000",
|
||||||
@ -101,7 +102,7 @@
|
|||||||
"@babel/preset-env": "^7.22.9",
|
"@babel/preset-env": "^7.22.9",
|
||||||
"@tauri-apps/cli": "^1.3.1",
|
"@tauri-apps/cli": "^1.3.1",
|
||||||
"@types/crypto-js": "^4.1.1",
|
"@types/crypto-js": "^4.1.1",
|
||||||
"@types/debounce": "^1.2.1",
|
"@types/debounce-promise": "^3.1.6",
|
||||||
"@types/isomorphic-fetch": "^0.0.36",
|
"@types/isomorphic-fetch": "^0.0.36",
|
||||||
"@types/react-modal": "^3.16.0",
|
"@types/react-modal": "^3.16.0",
|
||||||
"@types/uuid": "^9.0.1",
|
"@types/uuid": "^9.0.1",
|
||||||
@ -115,7 +116,7 @@
|
|||||||
"eslint-plugin-css-modules": "^2.11.0",
|
"eslint-plugin-css-modules": "^2.11.0",
|
||||||
"happy-dom": "^10.8.0",
|
"happy-dom": "^10.8.0",
|
||||||
"husky": "^8.0.3",
|
"husky": "^8.0.3",
|
||||||
"postcss": "^8.4.19",
|
"postcss": "^8.4.31",
|
||||||
"prettier": "^2.8.0",
|
"prettier": "^2.8.0",
|
||||||
"setimmediate": "^1.0.5",
|
"setimmediate": "^1.0.5",
|
||||||
"tailwindcss": "^3.2.4",
|
"tailwindcss": "^3.2.4",
|
||||||
|
194
src-tauri/Cargo.lock
generated
194
src-tauri/Cargo.lock
generated
@ -84,7 +84,7 @@ dependencies = [
|
|||||||
"tauri-build",
|
"tauri-build",
|
||||||
"tauri-plugin-fs-extra",
|
"tauri-plugin-fs-extra",
|
||||||
"tokio",
|
"tokio",
|
||||||
"toml 0.8.0",
|
"toml 0.8.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -155,6 +155,20 @@ version = "0.21.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d"
|
checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bigdecimal"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "454bca3db10617b88b566f205ed190aedb0e0e6dd4cad61d3988a72e8c5594cb"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"libm",
|
||||||
|
"num-bigint",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bincode"
|
name = "bincode"
|
||||||
version = "1.3.3"
|
version = "1.3.3"
|
||||||
@ -1295,7 +1309,21 @@ checksum = "e5c13fb08e5d4dfc151ee5e88bae63f7773d61852f3bdc73c9f4b9e1bde03148"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"mac",
|
"mac",
|
||||||
"markup5ever",
|
"markup5ever 0.10.1",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "html5ever"
|
||||||
|
version = "0.26.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bea68cab48b8459f17cf1c944c67ddc572d272d9f2b274140f223ecb1da4a3b7"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"mac",
|
||||||
|
"markup5ever 0.11.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
@ -1630,13 +1658,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kittycad"
|
name = "kittycad"
|
||||||
version = "0.2.25"
|
version = "0.2.28"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d9cf962b1e81a0b4eb923a727e761b40672cbacc7f5f0b75e13579d346352bc7"
|
checksum = "35b2f9302648dbb06fd7121687f9505fc3179eba84111a06d76b246e3158f5dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.21.2",
|
"base64 0.21.2",
|
||||||
|
"bigdecimal",
|
||||||
"bytes",
|
"bytes",
|
||||||
"chrono",
|
"chrono",
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
@ -1671,7 +1700,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "1ea8e9c6e031377cff82ee3001dc8026cdf431ed4e2e6b51f98ab8c73484a358"
|
checksum = "1ea8e9c6e031377cff82ee3001dc8026cdf431ed4e2e6b51f98ab8c73484a358"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cssparser",
|
"cssparser",
|
||||||
"html5ever",
|
"html5ever 0.25.2",
|
||||||
|
"matches",
|
||||||
|
"selectors",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "kuchikiki"
|
||||||
|
version = "0.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f29e4755b7b995046f510a7520c42b2fed58b77bd94d5a87a8eb43d2fd126da8"
|
||||||
|
dependencies = [
|
||||||
|
"cssparser",
|
||||||
|
"html5ever 0.26.0",
|
||||||
|
"indexmap 1.9.3",
|
||||||
"matches",
|
"matches",
|
||||||
"selectors",
|
"selectors",
|
||||||
]
|
]
|
||||||
@ -1688,6 +1730,12 @@ version = "0.2.148"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
|
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libm"
|
||||||
|
version = "0.2.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "line-wrap"
|
name = "line-wrap"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
@ -1727,9 +1775,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.18"
|
version = "0.4.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de"
|
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
@ -1781,7 +1829,21 @@ checksum = "a24f40fb03852d1cdd84330cddcaf98e9ec08a7b7768e952fad3b4cf048ec8fd"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"phf 0.8.0",
|
"phf 0.8.0",
|
||||||
"phf_codegen",
|
"phf_codegen 0.8.0",
|
||||||
|
"string_cache",
|
||||||
|
"string_cache_codegen",
|
||||||
|
"tendril",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "markup5ever"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7a2629bb1404f3d34c2e921f21fd34ba00b206124c81f65c50b43b6aaefeb016"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"phf 0.10.1",
|
||||||
|
"phf_codegen 0.10.0",
|
||||||
"string_cache",
|
"string_cache",
|
||||||
"string_cache_codegen",
|
"string_cache_codegen",
|
||||||
"tendril",
|
"tendril",
|
||||||
@ -1959,6 +2021,17 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-bigint"
|
||||||
|
version = "0.4.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-integer"
|
name = "num-integer"
|
||||||
version = "0.1.45"
|
version = "0.1.45"
|
||||||
@ -1982,9 +2055,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.15"
|
version = "0.2.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
|
checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
]
|
]
|
||||||
@ -2342,6 +2415,16 @@ dependencies = [
|
|||||||
"phf_shared 0.8.0",
|
"phf_shared 0.8.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "phf_codegen"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd"
|
||||||
|
dependencies = [
|
||||||
|
"phf_generator 0.10.0",
|
||||||
|
"phf_shared 0.10.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "phf_generator"
|
name = "phf_generator"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
@ -2410,9 +2493,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "phonenumber"
|
name = "phonenumber"
|
||||||
version = "0.3.2+8.13.9"
|
version = "0.3.3+8.13.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "34749f64ea9d76f10cdc8a859588b57775f59177c7dd91f744d620bd62982d6f"
|
checksum = "635f3e6288e4f01c049d89332a031bd74f25d64b6fb94703ca966e819488cd06"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"either",
|
"either",
|
||||||
@ -2425,6 +2508,7 @@ dependencies = [
|
|||||||
"regex-cache",
|
"regex-cache",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
|
"strum",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -3021,10 +3105,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "schemars"
|
name = "schemars"
|
||||||
version = "0.8.13"
|
version = "0.8.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "763f8cd0d4c71ed8389c90cb8100cba87e763bd01a8e614d4f0af97bcd50a161"
|
checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"bigdecimal",
|
||||||
"bytes",
|
"bytes",
|
||||||
"chrono",
|
"chrono",
|
||||||
"dyn-clone",
|
"dyn-clone",
|
||||||
@ -3037,9 +3122,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "schemars_derive"
|
name = "schemars_derive"
|
||||||
version = "0.8.13"
|
version = "0.8.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ec0f696e21e10fa546b7ffb1c9672c6de8fbc7a81acf59524386d8639bf12737"
|
checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -3105,7 +3190,7 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"matches",
|
"matches",
|
||||||
"phf 0.8.0",
|
"phf 0.8.0",
|
||||||
"phf_codegen",
|
"phf_codegen 0.8.0",
|
||||||
"precomputed-hash",
|
"precomputed-hash",
|
||||||
"servo_arc",
|
"servo_arc",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
@ -3458,6 +3543,28 @@ dependencies = [
|
|||||||
"syn 2.0.33",
|
"syn 2.0.33",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strum"
|
||||||
|
version = "0.24.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f"
|
||||||
|
dependencies = [
|
||||||
|
"strum_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strum_macros"
|
||||||
|
version = "0.24.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59"
|
||||||
|
dependencies = [
|
||||||
|
"heck 0.4.1",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"rustversion",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.109"
|
version = "1.0.109"
|
||||||
@ -3605,9 +3712,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri"
|
name = "tauri"
|
||||||
version = "1.4.1"
|
version = "1.5.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7fbe522898e35407a8e60dc3870f7579fea2fc262a6a6072eccdd37ae1e1d91e"
|
checksum = "0238c5063bf9613054149a1b6bce4935922e532b7d8211f36989a490a79806be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64 0.21.2",
|
"base64 0.21.2",
|
||||||
@ -3661,12 +3768,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-build"
|
name = "tauri-build"
|
||||||
version = "1.4.0"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7d2edd6a259b5591c8efdeb9d5702cb53515b82a6affebd55c7fd6d3a27b7d1b"
|
checksum = "defbfc551bd38ab997e5f8e458f87396d2559d05ce32095076ad6c30f7fc5f9c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cargo_toml",
|
"cargo_toml",
|
||||||
|
"dirs-next",
|
||||||
"heck 0.4.1",
|
"heck 0.4.1",
|
||||||
"json-patch",
|
"json-patch",
|
||||||
"semver",
|
"semver",
|
||||||
@ -3674,13 +3782,14 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"tauri-utils",
|
"tauri-utils",
|
||||||
"tauri-winres",
|
"tauri-winres",
|
||||||
|
"walkdir",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-codegen"
|
name = "tauri-codegen"
|
||||||
version = "1.4.0"
|
version = "1.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "54ad2d49fdeab4a08717f5b49a163bdc72efc3b1950b6758245fcde79b645e1a"
|
checksum = "7b3475e55acec0b4a50fb96435f19631fb58cbcd31923e1a213de5c382536bbb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.21.2",
|
"base64 0.21.2",
|
||||||
"brotli",
|
"brotli",
|
||||||
@ -3704,9 +3813,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-macros"
|
name = "tauri-macros"
|
||||||
version = "1.4.0"
|
version = "1.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8eb12a2454e747896929338d93b0642144bb51e0dddbb36e579035731f0d76b7"
|
checksum = "613740228de92d9196b795ac455091d3a5fbdac2654abb8bb07d010b62ab43af"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck 0.4.1",
|
"heck 0.4.1",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@ -3719,7 +3828,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-plugin-fs-extra"
|
name = "tauri-plugin-fs-extra"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#5b814f56e6368fdec46c4ddb04a07e0923ff995a"
|
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#fa32d1afa97f52f74d814c5619b8d95da3268e3e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
@ -3730,9 +3839,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-runtime"
|
name = "tauri-runtime"
|
||||||
version = "0.14.0"
|
version = "0.14.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "108683199cb18f96d2d4134187bb789964143c845d2d154848dda209191fd769"
|
checksum = "07f8e9e53e00e9f41212c115749e87d5cd2a9eebccafca77a19722eeecd56d43"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gtk",
|
"gtk",
|
||||||
"http",
|
"http",
|
||||||
@ -3751,9 +3860,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-runtime-wry"
|
name = "tauri-runtime-wry"
|
||||||
version = "0.14.0"
|
version = "0.14.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0b7aa256a1407a3a091b5d843eccc1a5042289baf0a43d1179d9f0fcfea37c1b"
|
checksum = "8141d72b6b65f2008911e9ef5b98a68d1e3413b7a1464e8f85eb3673bb19a895"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cocoa",
|
"cocoa",
|
||||||
"gtk",
|
"gtk",
|
||||||
@ -3771,19 +3880,20 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-utils"
|
name = "tauri-utils"
|
||||||
version = "1.4.0"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "03fc02bb6072bb397e1d473c6f76c953cda48b4a2d0cce605df284aa74a12e84"
|
checksum = "34d55e185904a84a419308d523c2c6891d5e2dbcee740c4997eb42e75a7b0f46"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"brotli",
|
"brotli",
|
||||||
"ctor",
|
"ctor",
|
||||||
"dunce",
|
"dunce",
|
||||||
"glob",
|
"glob",
|
||||||
"heck 0.4.1",
|
"heck 0.4.1",
|
||||||
"html5ever",
|
"html5ever 0.26.0",
|
||||||
"infer",
|
"infer",
|
||||||
"json-patch",
|
"json-patch",
|
||||||
"kuchiki",
|
"kuchikiki",
|
||||||
|
"log",
|
||||||
"memchr",
|
"memchr",
|
||||||
"phf 0.10.1",
|
"phf 0.10.1",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@ -3968,14 +4078,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "0.8.0"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c226a7bba6d859b63c92c4b4fe69c5b6b72d0cb897dbc8e6012298e6154cb56e"
|
checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_spanned",
|
"serde_spanned",
|
||||||
"toml_datetime",
|
"toml_datetime",
|
||||||
"toml_edit 0.20.0",
|
"toml_edit 0.20.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -4002,9 +4112,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_edit"
|
name = "toml_edit"
|
||||||
version = "0.20.0"
|
version = "0.20.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8ff63e60a958cefbb518ae1fd6566af80d9d4be430a33f3723dfc47d1d411d95"
|
checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap 2.0.0",
|
"indexmap 2.0.0",
|
||||||
"serde",
|
"serde",
|
||||||
@ -4799,9 +4909,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wry"
|
name = "wry"
|
||||||
version = "0.24.3"
|
version = "0.24.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "33748f35413c8a98d45f7a08832d848c0c5915501803d1faade5a4ebcd258cea"
|
checksum = "88ef04bdad49eba2e01f06e53688c8413bd6a87b0bc14b72284465cf96e3578e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.13.1",
|
"base64 0.13.1",
|
||||||
"block",
|
"block",
|
||||||
@ -4813,7 +4923,7 @@ dependencies = [
|
|||||||
"gio",
|
"gio",
|
||||||
"glib",
|
"glib",
|
||||||
"gtk",
|
"gtk",
|
||||||
"html5ever",
|
"html5ever 0.25.2",
|
||||||
"http",
|
"http",
|
||||||
"kuchiki",
|
"kuchiki",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -12,18 +12,18 @@ rust-version = "1.60"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "1.4.0", features = [] }
|
tauri-build = { version = "1.5.0", features = [] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
kittycad = "0.2.25"
|
kittycad = "0.2.28"
|
||||||
oauth2 = "4.4.2"
|
oauth2 = "4.4.2"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
tauri = { version = "1.4.1", features = [ "os-all", "dialog-all", "fs-all", "http-request", "path-all", "shell-open", "shell-open-api", "updater", "devtools"] }
|
tauri = { version = "1.5.1", features = [ "os-all", "dialog-all", "fs-all", "http-request", "path-all", "shell-open", "shell-open-api", "updater", "devtools"] }
|
||||||
tauri-plugin-fs-extra = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-fs-extra = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
tokio = { version = "1.32.0", features = ["time"] }
|
tokio = { version = "1.32.0", features = ["time"] }
|
||||||
toml = "0.8.0"
|
toml = "0.8.2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# this feature is used for production builds or when `devPath` points to the filesystem and the built-in dev server is disabled.
|
# this feature is used for production builds or when `devPath` points to the filesystem and the built-in dev server is disabled.
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
},
|
},
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "kittycad-modeling",
|
"productName": "kittycad-modeling",
|
||||||
"version": "0.8.2"
|
"version": "0.10.0"
|
||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
import { render, screen } from '@testing-library/react'
|
import { render, screen } from '@testing-library/react'
|
||||||
import { App } from './App'
|
import { App } from './App'
|
||||||
import { describe, test, vi } from 'vitest'
|
import { describe, test, vi } from 'vitest'
|
||||||
import { BrowserRouter } from 'react-router-dom'
|
import {
|
||||||
|
Route,
|
||||||
|
RouterProvider,
|
||||||
|
createMemoryRouter,
|
||||||
|
createRoutesFromElements,
|
||||||
|
} from 'react-router-dom'
|
||||||
import { GlobalStateProvider } from './components/GlobalStateProvider'
|
import { GlobalStateProvider } from './components/GlobalStateProvider'
|
||||||
import CommandBarProvider from 'components/CommandBar'
|
import CommandBarProvider from 'components/CommandBar'
|
||||||
|
import { BROWSER_FILE_NAME } from 'Router'
|
||||||
|
|
||||||
let listener: ((rect: any) => void) | undefined = undefined
|
let listener: ((rect: any) => void) | undefined = undefined
|
||||||
;(global as any).ResizeObserver = class ResizeObserver {
|
;(global as any).ResizeObserver = class ResizeObserver {
|
||||||
@ -24,7 +30,7 @@ describe('App tests', () => {
|
|||||||
>
|
>
|
||||||
return {
|
return {
|
||||||
...actual,
|
...actual,
|
||||||
useParams: () => ({ id: 'new' }),
|
useParams: () => ({ id: BROWSER_FILE_NAME }),
|
||||||
useLoaderData: () => ({ code: null }),
|
useLoaderData: () => ({ code: null }),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -41,12 +47,24 @@ describe('App tests', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function TestWrap({ children }: { children: React.ReactNode }) {
|
function TestWrap({ children }: { children: React.ReactNode }) {
|
||||||
// wrap in router and xState context
|
// We have to use a memory router in the testing environment,
|
||||||
return (
|
// and we have to use the createMemoryRouter function instead of <MemoryRouter /> as of react-router v6.4:
|
||||||
<BrowserRouter>
|
// https://reactrouter.com/en/6.16.0/routers/picking-a-router#using-v64-data-apis
|
||||||
|
const router = createMemoryRouter(
|
||||||
|
createRoutesFromElements(
|
||||||
|
<Route
|
||||||
|
path="/file/:id"
|
||||||
|
element={
|
||||||
<CommandBarProvider>
|
<CommandBarProvider>
|
||||||
<GlobalStateProvider>{children}</GlobalStateProvider>
|
<GlobalStateProvider>{children}</GlobalStateProvider>
|
||||||
</CommandBarProvider>
|
</CommandBarProvider>
|
||||||
</BrowserRouter>
|
}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
{
|
||||||
|
initialEntries: ['/file/new'],
|
||||||
|
initialIndex: 0,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
return <RouterProvider router={router} />
|
||||||
}
|
}
|
||||||
|
12
src/App.tsx
12
src/App.tsx
@ -31,6 +31,7 @@ import { TextEditor } from 'components/TextEditor'
|
|||||||
import { Themes, getSystemTheme } from 'lib/theme'
|
import { Themes, getSystemTheme } from 'lib/theme'
|
||||||
import { useSetupEngineManager } from 'hooks/useSetupEngineManager'
|
import { useSetupEngineManager } from 'hooks/useSetupEngineManager'
|
||||||
import { useEngineConnectionSubscriptions } from 'hooks/useEngineConnectionSubscriptions'
|
import { useEngineConnectionSubscriptions } from 'hooks/useEngineConnectionSubscriptions'
|
||||||
|
import { engineCommandManager } from './lang/std/engineConnection'
|
||||||
|
|
||||||
export function App() {
|
export function App() {
|
||||||
const { code: loadedCode, project } = useLoaderData() as IndexLoaderData
|
const { code: loadedCode, project } = useLoaderData() as IndexLoaderData
|
||||||
@ -39,7 +40,6 @@ export function App() {
|
|||||||
useHotKeyListener()
|
useHotKeyListener()
|
||||||
const {
|
const {
|
||||||
setCode,
|
setCode,
|
||||||
engineCommandManager,
|
|
||||||
buttonDownInStream,
|
buttonDownInStream,
|
||||||
openPanes,
|
openPanes,
|
||||||
setOpenPanes,
|
setOpenPanes,
|
||||||
@ -52,7 +52,6 @@ export function App() {
|
|||||||
guiMode: s.guiMode,
|
guiMode: s.guiMode,
|
||||||
setGuiMode: s.setGuiMode,
|
setGuiMode: s.setGuiMode,
|
||||||
setCode: s.setCode,
|
setCode: s.setCode,
|
||||||
engineCommandManager: s.engineCommandManager,
|
|
||||||
buttonDownInStream: s.buttonDownInStream,
|
buttonDownInStream: s.buttonDownInStream,
|
||||||
openPanes: s.openPanes,
|
openPanes: s.openPanes,
|
||||||
setOpenPanes: s.setOpenPanes,
|
setOpenPanes: s.setOpenPanes,
|
||||||
@ -91,12 +90,12 @@ export function App() {
|
|||||||
if (guiMode.sketchMode === 'sketchEdit') {
|
if (guiMode.sketchMode === 'sketchEdit') {
|
||||||
// TODO: share this with Toolbar's "Exit sketch" button
|
// TODO: share this with Toolbar's "Exit sketch" button
|
||||||
// exiting sketch should be done consistently across all exits
|
// exiting sketch should be done consistently across all exits
|
||||||
engineCommandManager?.sendSceneCommand({
|
engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
cmd: { type: 'edit_mode_exit' },
|
cmd: { type: 'edit_mode_exit' },
|
||||||
})
|
})
|
||||||
engineCommandManager?.sendSceneCommand({
|
engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
cmd: { type: 'default_camera_disable_sketch_mode' },
|
cmd: { type: 'default_camera_disable_sketch_mode' },
|
||||||
@ -107,7 +106,7 @@ export function App() {
|
|||||||
// when exiting sketch mode in the future
|
// when exiting sketch mode in the future
|
||||||
executeAst()
|
executeAst()
|
||||||
} else {
|
} else {
|
||||||
engineCommandManager?.sendSceneCommand({
|
engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
cmd: {
|
cmd: {
|
||||||
@ -156,7 +155,7 @@ export function App() {
|
|||||||
useEngineConnectionSubscriptions()
|
useEngineConnectionSubscriptions()
|
||||||
|
|
||||||
const debounceSocketSend = throttle<EngineCommand>((message) => {
|
const debounceSocketSend = throttle<EngineCommand>((message) => {
|
||||||
engineCommandManager?.sendSceneCommand(message)
|
engineCommandManager.sendSceneCommand(message)
|
||||||
}, 16)
|
}, 16)
|
||||||
const handleMouseMove: MouseEventHandler<HTMLDivElement> = (e) => {
|
const handleMouseMove: MouseEventHandler<HTMLDivElement> = (e) => {
|
||||||
e.nativeEvent.preventDefault()
|
e.nativeEvent.preventDefault()
|
||||||
@ -216,7 +215,6 @@ export function App() {
|
|||||||
} else if (interactionGuards.zoom.dragCallback(eWithButton)) {
|
} else if (interactionGuards.zoom.dragCallback(eWithButton)) {
|
||||||
interaction = 'zoom'
|
interaction = 'zoom'
|
||||||
} else {
|
} else {
|
||||||
console.log('none')
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +94,8 @@ export const paths = {
|
|||||||
) as typeof onboardingPaths,
|
) as typeof onboardingPaths,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const BROWSER_FILE_NAME = 'new'
|
||||||
|
|
||||||
export type IndexLoaderData = {
|
export type IndexLoaderData = {
|
||||||
code: string | null
|
code: string | null
|
||||||
project?: ProjectWithEntryPointMetadata
|
project?: ProjectWithEntryPointMetadata
|
||||||
@ -129,7 +131,9 @@ const router = createBrowserRouter(
|
|||||||
{
|
{
|
||||||
path: paths.INDEX,
|
path: paths.INDEX,
|
||||||
loader: () =>
|
loader: () =>
|
||||||
isTauri() ? redirect(paths.HOME) : redirect(paths.FILE + '/new'),
|
isTauri()
|
||||||
|
? redirect(paths.HOME)
|
||||||
|
: redirect(paths.FILE + '/' + BROWSER_FILE_NAME),
|
||||||
errorElement: <ErrorPage />,
|
errorElement: <ErrorPage />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -167,7 +171,7 @@ const router = createBrowserRouter(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.id && params.id !== 'new') {
|
if (params.id && params.id !== BROWSER_FILE_NAME) {
|
||||||
// Note that PROJECT_ENTRYPOINT is hardcoded until we support multiple files
|
// Note that PROJECT_ENTRYPOINT is hardcoded until we support multiple files
|
||||||
const code = await readTextFile(params.id + '/' + PROJECT_ENTRYPOINT)
|
const code = await readTextFile(params.id + '/' + PROJECT_ENTRYPOINT)
|
||||||
const entrypoint_metadata = await metadata(
|
const entrypoint_metadata = await metadata(
|
||||||
@ -212,7 +216,7 @@ const router = createBrowserRouter(
|
|||||||
),
|
),
|
||||||
loader: async () => {
|
loader: async () => {
|
||||||
if (!isTauri()) {
|
if (!isTauri()) {
|
||||||
return redirect(paths.FILE + '/new')
|
return redirect(paths.FILE + '/' + BROWSER_FILE_NAME)
|
||||||
}
|
}
|
||||||
const fetchedStorage = localStorage?.getItem(SETTINGS_PERSIST_KEY)
|
const fetchedStorage = localStorage?.getItem(SETTINGS_PERSIST_KEY)
|
||||||
const persistedSettings = JSON.parse(fetchedStorage || '{}') as Partial<
|
const persistedSettings = JSON.parse(fetchedStorage || '{}') as Partial<
|
||||||
|
@ -10,7 +10,7 @@ import { SetHorzVertDistance } from './components/Toolbar/SetHorzVertDistance'
|
|||||||
import { SetAngleLength } from './components/Toolbar/setAngleLength'
|
import { SetAngleLength } from './components/Toolbar/setAngleLength'
|
||||||
import { SetAbsDistance } from './components/Toolbar/SetAbsDistance'
|
import { SetAbsDistance } from './components/Toolbar/SetAbsDistance'
|
||||||
import { SetAngleBetween } from './components/Toolbar/SetAngleBetween'
|
import { SetAngleBetween } from './components/Toolbar/SetAngleBetween'
|
||||||
import { Fragment, useEffect } from 'react'
|
import { Fragment, WheelEvent, useRef } from 'react'
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||||
import { faSearch, faX } from '@fortawesome/free-solid-svg-icons'
|
import { faSearch, faX } from '@fortawesome/free-solid-svg-icons'
|
||||||
import { Popover, Transition } from '@headlessui/react'
|
import { Popover, Transition } from '@headlessui/react'
|
||||||
@ -18,6 +18,7 @@ import styles from './Toolbar.module.css'
|
|||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import { useAppMode } from 'hooks/useAppMode'
|
import { useAppMode } from 'hooks/useAppMode'
|
||||||
import { ActionIcon } from 'components/ActionIcon'
|
import { ActionIcon } from 'components/ActionIcon'
|
||||||
|
import { engineCommandManager } from './lang/std/engineConnection'
|
||||||
|
|
||||||
export const sketchButtonClassnames = {
|
export const sketchButtonClassnames = {
|
||||||
background:
|
background:
|
||||||
@ -50,7 +51,6 @@ export const Toolbar = () => {
|
|||||||
ast,
|
ast,
|
||||||
updateAst,
|
updateAst,
|
||||||
programMemory,
|
programMemory,
|
||||||
engineCommandManager,
|
|
||||||
executeAst,
|
executeAst,
|
||||||
} = useStore((s) => ({
|
} = useStore((s) => ({
|
||||||
guiMode: s.guiMode,
|
guiMode: s.guiMode,
|
||||||
@ -59,18 +59,27 @@ export const Toolbar = () => {
|
|||||||
ast: s.ast,
|
ast: s.ast,
|
||||||
updateAst: s.updateAst,
|
updateAst: s.updateAst,
|
||||||
programMemory: s.programMemory,
|
programMemory: s.programMemory,
|
||||||
engineCommandManager: s.engineCommandManager,
|
|
||||||
executeAst: s.executeAst,
|
executeAst: s.executeAst,
|
||||||
}))
|
}))
|
||||||
useAppMode()
|
useAppMode()
|
||||||
|
const toolbarButtonsRef = useRef<HTMLSpanElement>(null)
|
||||||
|
|
||||||
useEffect(() => {
|
function handleToolbarButtonsWheelEvent(ev: WheelEvent<HTMLSpanElement>) {
|
||||||
console.log('guiMode', guiMode)
|
const span = toolbarButtonsRef.current
|
||||||
}, [guiMode])
|
if (!span) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
span.scrollLeft = span.scrollLeft += ev.deltaY
|
||||||
|
}
|
||||||
|
|
||||||
function ToolbarButtons({ className }: React.HTMLAttributes<HTMLElement>) {
|
function ToolbarButtons({ className }: React.HTMLAttributes<HTMLElement>) {
|
||||||
return (
|
return (
|
||||||
<span className={styles.toolbarButtons + ' ' + className}>
|
<span
|
||||||
|
ref={toolbarButtonsRef}
|
||||||
|
onWheel={handleToolbarButtonsWheelEvent}
|
||||||
|
className={styles.toolbarButtons + ' ' + className}
|
||||||
|
>
|
||||||
{guiMode.mode === 'default' && (
|
{guiMode.mode === 'default' && (
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@ -173,12 +182,12 @@ export const Toolbar = () => {
|
|||||||
{guiMode.mode === 'sketch' && (
|
{guiMode.mode === 'sketch' && (
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
engineCommandManager?.sendSceneCommand({
|
engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
cmd: { type: 'edit_mode_exit' },
|
cmd: { type: 'edit_mode_exit' },
|
||||||
})
|
})
|
||||||
engineCommandManager?.sendSceneCommand({
|
engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
cmd: { type: 'default_camera_disable_sketch_mode' },
|
cmd: { type: 'default_camera_disable_sketch_mode' },
|
||||||
@ -214,7 +223,7 @@ export const Toolbar = () => {
|
|||||||
<button
|
<button
|
||||||
key={sketchFnName}
|
key={sketchFnName}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
engineCommandManager?.sendSceneCommand({
|
engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
cmd: {
|
cmd: {
|
||||||
|
@ -23,10 +23,7 @@ type ActionButtonAsLink = BaseActionButtonProps &
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ActionButtonAsExternal = BaseActionButtonProps &
|
type ActionButtonAsExternal = BaseActionButtonProps &
|
||||||
Omit<
|
Omit<LinkProps, keyof BaseActionButtonProps> & {
|
||||||
React.AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
||||||
keyof BaseActionButtonProps
|
|
||||||
> & {
|
|
||||||
Element: 'externalLink'
|
Element: 'externalLink'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,12 +66,17 @@ export const ActionButton = (props: ActionButtonProps) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
case 'externalLink': {
|
case 'externalLink': {
|
||||||
const { Element, icon, children, className, ...rest } = props
|
const { Element, to, icon, children, className, ...rest } = props
|
||||||
return (
|
return (
|
||||||
<a className={classNames} {...rest}>
|
<Link
|
||||||
|
to={to || paths.INDEX}
|
||||||
|
className={classNames}
|
||||||
|
{...rest}
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
{icon && <ActionIcon {...icon} />}
|
{icon && <ActionIcon {...icon} />}
|
||||||
{children}
|
{children}
|
||||||
</a>
|
</Link>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import { useEffect, useState, useRef } from 'react'
|
import { useEffect, useState, useRef } from 'react'
|
||||||
import { parser_wasm } from '../lang/abstractSyntaxTree'
|
import { parse, BinaryPart, Value, executor } from '../lang/wasm'
|
||||||
import { BinaryPart, Value } from '../lang/abstractSyntaxTreeTypes'
|
|
||||||
import { executor } from '../lang/executor'
|
|
||||||
import {
|
import {
|
||||||
createIdentifier,
|
createIdentifier,
|
||||||
createLiteral,
|
createLiteral,
|
||||||
@ -10,6 +8,7 @@ import {
|
|||||||
} from '../lang/modifyAst'
|
} from '../lang/modifyAst'
|
||||||
import { findAllPreviousVariables, PrevVariable } from '../lang/queryAst'
|
import { findAllPreviousVariables, PrevVariable } from '../lang/queryAst'
|
||||||
import { useStore } from '../useStore'
|
import { useStore } from '../useStore'
|
||||||
|
import { engineCommandManager } from '../lang/std/engineConnection'
|
||||||
|
|
||||||
export const AvailableVars = ({
|
export const AvailableVars = ({
|
||||||
onVarClick,
|
onVarClick,
|
||||||
@ -92,12 +91,12 @@ export function useCalc({
|
|||||||
newVariableInsertIndex: number
|
newVariableInsertIndex: number
|
||||||
setNewVariableName: (a: string) => void
|
setNewVariableName: (a: string) => void
|
||||||
} {
|
} {
|
||||||
const { ast, programMemory, selectionRange, engineCommandManager } = useStore(
|
const { ast, programMemory, selectionRange, defaultPlanes } = useStore(
|
||||||
(s) => ({
|
(s) => ({
|
||||||
ast: s.ast,
|
ast: s.ast,
|
||||||
programMemory: s.programMemory,
|
programMemory: s.programMemory,
|
||||||
selectionRange: s.selectionRanges.codeBasedSelections[0].range,
|
selectionRange: s.selectionRanges.codeBasedSelections[0].range,
|
||||||
engineCommandManager: s.engineCommandManager,
|
defaultPlanes: s.defaultPlanes,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
const inputRef = useRef<HTMLInputElement>(null)
|
const inputRef = useRef<HTMLInputElement>(null)
|
||||||
@ -140,15 +139,16 @@ export function useCalc({
|
|||||||
}, [ast, programMemory, selectionRange])
|
}, [ast, programMemory, selectionRange])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!engineCommandManager) return
|
|
||||||
try {
|
try {
|
||||||
const code = `const __result__ = ${value}\nshow(__result__)`
|
const code = `const __result__ = ${value}\nshow(__result__)`
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const _programMem: any = { root: {}, return: null }
|
const _programMem: any = { root: {}, return: null }
|
||||||
availableVarInfo.variables.forEach(({ key, value }) => {
|
availableVarInfo.variables.forEach(({ key, value }) => {
|
||||||
_programMem.root[key] = { type: 'userVal', value, __meta: [] }
|
_programMem.root[key] = { type: 'userVal', value, __meta: [] }
|
||||||
})
|
})
|
||||||
executor(ast, _programMem, engineCommandManager).then((programMemory) => {
|
if (!defaultPlanes) return
|
||||||
|
executor(ast, _programMem, engineCommandManager, defaultPlanes!).then(
|
||||||
|
(programMemory) => {
|
||||||
const resultDeclaration = ast.body.find(
|
const resultDeclaration = ast.body.find(
|
||||||
(a) =>
|
(a) =>
|
||||||
a.type === 'VariableDeclaration' &&
|
a.type === 'VariableDeclaration' &&
|
||||||
@ -160,7 +160,8 @@ export function useCalc({
|
|||||||
const result = programMemory?.root?.__result__?.value
|
const result = programMemory?.root?.__result__?.value
|
||||||
setCalcResult(typeof result === 'number' ? String(result) : 'NAN')
|
setCalcResult(typeof result === 'number' ? String(result) : 'NAN')
|
||||||
init && setValueNode(init)
|
init && setValueNode(init)
|
||||||
})
|
}
|
||||||
|
)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setCalcResult('NAN')
|
setCalcResult('NAN')
|
||||||
setValueNode(null)
|
setValueNode(null)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { CollapsiblePanel, CollapsiblePanelProps } from './CollapsiblePanel'
|
import { CollapsiblePanel, CollapsiblePanelProps } from './CollapsiblePanel'
|
||||||
import { useStore } from '../useStore'
|
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import { EngineCommand } from '../lang/std/engineConnection'
|
import { EngineCommand } from '../lang/std/engineConnection'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
@ -7,6 +6,7 @@ import { ActionButton } from '../components/ActionButton'
|
|||||||
import { faCheck } from '@fortawesome/free-solid-svg-icons'
|
import { faCheck } from '@fortawesome/free-solid-svg-icons'
|
||||||
import { isReducedMotion } from 'lang/util'
|
import { isReducedMotion } from 'lang/util'
|
||||||
import { AstExplorer } from './AstExplorer'
|
import { AstExplorer } from './AstExplorer'
|
||||||
|
import { engineCommandManager } from '../lang/std/engineConnection'
|
||||||
|
|
||||||
type SketchModeCmd = Extract<
|
type SketchModeCmd = Extract<
|
||||||
Extract<EngineCommand, { type: 'modeling_cmd_req' }>['cmd'],
|
Extract<EngineCommand, { type: 'modeling_cmd_req' }>['cmd'],
|
||||||
@ -14,9 +14,6 @@ type SketchModeCmd = Extract<
|
|||||||
>
|
>
|
||||||
|
|
||||||
export const DebugPanel = ({ className, ...props }: CollapsiblePanelProps) => {
|
export const DebugPanel = ({ className, ...props }: CollapsiblePanelProps) => {
|
||||||
const { engineCommandManager } = useStore((s) => ({
|
|
||||||
engineCommandManager: s.engineCommandManager,
|
|
||||||
}))
|
|
||||||
const [sketchModeCmd, setSketchModeCmd] = useState<SketchModeCmd>({
|
const [sketchModeCmd, setSketchModeCmd] = useState<SketchModeCmd>({
|
||||||
type: 'default_camera_enable_sketch_mode',
|
type: 'default_camera_enable_sketch_mode',
|
||||||
origin: { x: 0, y: 0, z: 0 },
|
origin: { x: 0, y: 0, z: 0 },
|
||||||
@ -70,19 +67,18 @@ export const DebugPanel = ({ className, ...props }: CollapsiblePanelProps) => {
|
|||||||
className="w-16"
|
className="w-16"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={sketchModeCmd.ortho}
|
checked={sketchModeCmd.ortho}
|
||||||
onChange={(a) => {
|
onChange={(a) =>
|
||||||
console.log(a, (a as any).checked)
|
|
||||||
setSketchModeCmd({
|
setSketchModeCmd({
|
||||||
...sketchModeCmd,
|
...sketchModeCmd,
|
||||||
ortho: a.target.checked,
|
ortho: a.target.checked,
|
||||||
})
|
})
|
||||||
}}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<ActionButton
|
<ActionButton
|
||||||
Element="button"
|
Element="button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
engineCommandManager?.sendSceneCommand({
|
engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd: sketchModeCmd,
|
cmd: sketchModeCmd,
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
|
@ -47,11 +47,9 @@ export const ErrorPage = () => {
|
|||||||
Clear storage
|
Clear storage
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
<ActionButton
|
<ActionButton
|
||||||
Element="link"
|
Element="externalLink"
|
||||||
icon={{ icon: faBug }}
|
icon={{ icon: faBug }}
|
||||||
target="_blank"
|
to="https://github.com/KittyCAD/modeling-app/issues/new"
|
||||||
rel="noopener noreferrer"
|
|
||||||
to="https://discord.com/channels/915388055236509727/1138967922614743060"
|
|
||||||
>
|
>
|
||||||
Report Bug
|
Report Bug
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import { useStore } from '../useStore'
|
|
||||||
import { faFileExport, faXmark } from '@fortawesome/free-solid-svg-icons'
|
import { faFileExport, faXmark } from '@fortawesome/free-solid-svg-icons'
|
||||||
import { ActionButton } from './ActionButton'
|
import { ActionButton } from './ActionButton'
|
||||||
import Modal from 'react-modal'
|
import Modal from 'react-modal'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useFormik } from 'formik'
|
import { useFormik } from 'formik'
|
||||||
import { Models } from '@kittycad/lib'
|
import { Models } from '@kittycad/lib'
|
||||||
|
import { engineCommandManager } from '../lang/std/engineConnection'
|
||||||
|
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
||||||
|
|
||||||
type OutputFormat = Models['OutputFormat_type']
|
type OutputFormat = Models['OutputFormat_type']
|
||||||
|
type OutputTypeKey = OutputFormat['type']
|
||||||
|
type ExtractStorageTypes<T> = T extends { storage: infer U } ? U : never
|
||||||
|
type StorageUnion = ExtractStorageTypes<OutputFormat>
|
||||||
|
|
||||||
interface ExportButtonProps extends React.PropsWithChildren {
|
interface ExportButtonProps extends React.PropsWithChildren {
|
||||||
className?: {
|
className?: {
|
||||||
@ -18,14 +22,19 @@ interface ExportButtonProps extends React.PropsWithChildren {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const ExportButton = ({ children, className }: ExportButtonProps) => {
|
export const ExportButton = ({ children, className }: ExportButtonProps) => {
|
||||||
const { engineCommandManager } = useStore((s) => ({
|
|
||||||
engineCommandManager: s.engineCommandManager,
|
|
||||||
}))
|
|
||||||
|
|
||||||
const [modalIsOpen, setIsOpen] = React.useState(false)
|
const [modalIsOpen, setIsOpen] = React.useState(false)
|
||||||
|
const {
|
||||||
|
settings: {
|
||||||
|
state: {
|
||||||
|
context: { baseUnit },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} = useGlobalStateContext()
|
||||||
|
|
||||||
const defaultType = 'gltf'
|
const defaultType = 'gltf'
|
||||||
const [type, setType] = React.useState(defaultType)
|
const [type, setType] = React.useState<OutputTypeKey>(defaultType)
|
||||||
|
const defaultStorage = 'embedded'
|
||||||
|
const [storage, setStorage] = React.useState<StorageUnion>(defaultStorage)
|
||||||
|
|
||||||
function openModal() {
|
function openModal() {
|
||||||
setIsOpen(true)
|
setIsOpen(true)
|
||||||
@ -38,7 +47,7 @@ export const ExportButton = ({ children, className }: ExportButtonProps) => {
|
|||||||
// Default to gltf and embedded.
|
// Default to gltf and embedded.
|
||||||
const initialValues: OutputFormat = {
|
const initialValues: OutputFormat = {
|
||||||
type: defaultType,
|
type: defaultType,
|
||||||
storage: 'embedded',
|
storage: defaultStorage,
|
||||||
presentation: 'pretty',
|
presentation: 'pretty',
|
||||||
}
|
}
|
||||||
const formik = useFormik({
|
const formik = useFormik({
|
||||||
@ -66,7 +75,18 @@ export const ExportButton = ({ children, className }: ExportButtonProps) => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
engineCommandManager?.sendSceneCommand({
|
if (values.type === 'obj' || values.type === 'stl') {
|
||||||
|
values.units = baseUnit
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
values.type === 'ply' ||
|
||||||
|
values.type === 'stl' ||
|
||||||
|
values.type === 'gltf'
|
||||||
|
) {
|
||||||
|
// Set the storage type.
|
||||||
|
values.storage = storage
|
||||||
|
}
|
||||||
|
engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd: {
|
cmd: {
|
||||||
type: 'export',
|
type: 'export',
|
||||||
@ -75,6 +95,7 @@ export const ExportButton = ({ children, className }: ExportButtonProps) => {
|
|||||||
// in the scene to export. In that case, you'd pass the IDs thru here.
|
// in the scene to export. In that case, you'd pass the IDs thru here.
|
||||||
entity_ids: [],
|
entity_ids: [],
|
||||||
format: values,
|
format: values,
|
||||||
|
source_unit: baseUnit,
|
||||||
},
|
},
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
})
|
})
|
||||||
@ -109,7 +130,17 @@ export const ExportButton = ({ children, className }: ExportButtonProps) => {
|
|||||||
id="type"
|
id="type"
|
||||||
name="type"
|
name="type"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setType(e.target.value)
|
setType(e.target.value as OutputTypeKey)
|
||||||
|
if (e.target.value === 'gltf') {
|
||||||
|
// Set default to embedded.
|
||||||
|
setStorage('embedded')
|
||||||
|
} else if (e.target.value === 'ply') {
|
||||||
|
// Set default to ascii.
|
||||||
|
setStorage('ascii')
|
||||||
|
} else if (e.target.value === 'stl') {
|
||||||
|
// Set default to ascii.
|
||||||
|
setStorage('ascii')
|
||||||
|
}
|
||||||
formik.handleChange(e)
|
formik.handleChange(e)
|
||||||
}}
|
}}
|
||||||
className="bg-chalkboard-20 dark:bg-chalkboard-90 w-full"
|
className="bg-chalkboard-20 dark:bg-chalkboard-90 w-full"
|
||||||
@ -127,10 +158,10 @@ export const ExportButton = ({ children, className }: ExportButtonProps) => {
|
|||||||
<select
|
<select
|
||||||
id="storage"
|
id="storage"
|
||||||
name="storage"
|
name="storage"
|
||||||
onChange={formik.handleChange}
|
onChange={(e) => {
|
||||||
value={
|
setStorage(e.target.value as StorageUnion)
|
||||||
'storage' in formik.values ? formik.values.storage : ''
|
formik.handleChange(e)
|
||||||
}
|
}}
|
||||||
className="bg-chalkboard-20 dark:bg-chalkboard-90 w-full"
|
className="bg-chalkboard-20 dark:bg-chalkboard-90 w-full"
|
||||||
>
|
>
|
||||||
{type === 'gltf' && (
|
{type === 'gltf' && (
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { processMemory } from './MemoryPanel'
|
import { processMemory } from './MemoryPanel'
|
||||||
import { parser_wasm } from '../lang/abstractSyntaxTree'
|
|
||||||
import { enginelessExecutor } from '../lib/testHelpers'
|
import { enginelessExecutor } from '../lib/testHelpers'
|
||||||
import { initPromise } from '../lang/rust'
|
import { initPromise, parse } from '../lang/wasm'
|
||||||
|
|
||||||
beforeAll(() => initPromise)
|
beforeAll(() => initPromise)
|
||||||
|
|
||||||
@ -15,18 +14,20 @@ describe('processMemory', () => {
|
|||||||
}
|
}
|
||||||
const otherVar = myFn(5)
|
const otherVar = myFn(5)
|
||||||
|
|
||||||
const theExtrude = startSketchAt([0, 0])
|
const theExtrude = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> lineTo([-2.4, myVar], %)
|
|> lineTo([-2.4, myVar], %)
|
||||||
|> lineTo([-0.76, otherVar], %)
|
|> lineTo([-0.76, otherVar], %)
|
||||||
|> extrude(4, %)
|
|> extrude(4, %)
|
||||||
|
|
||||||
const theSketch = startSketchAt([0, 0])
|
const theSketch = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> lineTo([-3.35, 0.17], %)
|
|> lineTo([-3.35, 0.17], %)
|
||||||
|> lineTo([0.98, 5.16], %)
|
|> lineTo([0.98, 5.16], %)
|
||||||
|> lineTo([2.15, 4.32], %)
|
|> lineTo([2.15, 4.32], %)
|
||||||
// |> rx(90, %)
|
// |> rx(90, %)
|
||||||
show(theExtrude, theSketch)`
|
show(theExtrude, theSketch)`
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const programMemory = await enginelessExecutor(ast, {
|
const programMemory = await enginelessExecutor(ast, {
|
||||||
root: {},
|
root: {},
|
||||||
return: null,
|
return: null,
|
||||||
|
@ -2,7 +2,7 @@ import ReactJson from 'react-json-view'
|
|||||||
import { CollapsiblePanel, CollapsiblePanelProps } from './CollapsiblePanel'
|
import { CollapsiblePanel, CollapsiblePanelProps } from './CollapsiblePanel'
|
||||||
import { useStore } from '../useStore'
|
import { useStore } from '../useStore'
|
||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { ProgramMemory, Path, ExtrudeSurface } from '../lang/executor'
|
import { ProgramMemory, Path, ExtrudeSurface } from '../lang/wasm'
|
||||||
import { Themes } from '../lib/theme'
|
import { Themes } from '../lib/theme'
|
||||||
|
|
||||||
interface MemoryPanelProps extends CollapsiblePanelProps {
|
interface MemoryPanelProps extends CollapsiblePanelProps {
|
||||||
@ -50,7 +50,7 @@ export const MemoryPanel = ({
|
|||||||
|
|
||||||
export const processMemory = (programMemory: ProgramMemory) => {
|
export const processMemory = (programMemory: ProgramMemory) => {
|
||||||
const processedMemory: any = {}
|
const processedMemory: any = {}
|
||||||
Object.keys(programMemory.root).forEach((key) => {
|
Object.keys(programMemory?.root || {}).forEach((key) => {
|
||||||
const val = programMemory.root[key]
|
const val = programMemory.root[key]
|
||||||
if (typeof val.value !== 'function') {
|
if (typeof val.value !== 'function') {
|
||||||
if (val.type === 'SketchGroup') {
|
if (val.type === 'SketchGroup') {
|
||||||
|
@ -2,6 +2,8 @@ import { fireEvent, render, screen } from '@testing-library/react'
|
|||||||
import { BrowserRouter } from 'react-router-dom'
|
import { BrowserRouter } from 'react-router-dom'
|
||||||
import ProjectSidebarMenu from './ProjectSidebarMenu'
|
import ProjectSidebarMenu from './ProjectSidebarMenu'
|
||||||
import { ProjectWithEntryPointMetadata } from '../Router'
|
import { ProjectWithEntryPointMetadata } from '../Router'
|
||||||
|
import { GlobalStateProvider } from './GlobalStateProvider'
|
||||||
|
import CommandBarProvider from './CommandBar'
|
||||||
|
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const projectWellFormed = {
|
const projectWellFormed = {
|
||||||
@ -38,7 +40,11 @@ describe('ProjectSidebarMenu tests', () => {
|
|||||||
test('Renders the project name', () => {
|
test('Renders the project name', () => {
|
||||||
render(
|
render(
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
|
<CommandBarProvider>
|
||||||
|
<GlobalStateProvider>
|
||||||
<ProjectSidebarMenu project={projectWellFormed} />
|
<ProjectSidebarMenu project={projectWellFormed} />
|
||||||
|
</GlobalStateProvider>
|
||||||
|
</CommandBarProvider>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -55,7 +61,11 @@ describe('ProjectSidebarMenu tests', () => {
|
|||||||
test('Renders app name if given no project', () => {
|
test('Renders app name if given no project', () => {
|
||||||
render(
|
render(
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
|
<CommandBarProvider>
|
||||||
|
<GlobalStateProvider>
|
||||||
<ProjectSidebarMenu />
|
<ProjectSidebarMenu />
|
||||||
|
</GlobalStateProvider>
|
||||||
|
</CommandBarProvider>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -69,7 +79,14 @@ describe('ProjectSidebarMenu tests', () => {
|
|||||||
test('Renders as a link if set to do so', () => {
|
test('Renders as a link if set to do so', () => {
|
||||||
render(
|
render(
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<ProjectSidebarMenu project={projectWellFormed} renderAsLink={true} />
|
<CommandBarProvider>
|
||||||
|
<GlobalStateProvider>
|
||||||
|
<ProjectSidebarMenu
|
||||||
|
project={projectWellFormed}
|
||||||
|
renderAsLink={true}
|
||||||
|
/>
|
||||||
|
</GlobalStateProvider>
|
||||||
|
</CommandBarProvider>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Dialog, Transition } from '@headlessui/react'
|
import { Dialog, Transition } from '@headlessui/react'
|
||||||
import { Fragment, useState } from 'react'
|
import { Fragment, useState } from 'react'
|
||||||
import { Value } from '../lang/abstractSyntaxTreeTypes'
|
import { Value } from '../lang/wasm'
|
||||||
import {
|
import {
|
||||||
AvailableVars,
|
AvailableVars,
|
||||||
addToInputHelper,
|
addToInputHelper,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Dialog, Transition } from '@headlessui/react'
|
import { Dialog, Transition } from '@headlessui/react'
|
||||||
import { Fragment, useState } from 'react'
|
import { Fragment, useState } from 'react'
|
||||||
import { Value } from '../lang/abstractSyntaxTreeTypes'
|
import { Value } from '../lang/wasm'
|
||||||
import {
|
import {
|
||||||
AvailableVars,
|
AvailableVars,
|
||||||
addToInputHelper,
|
addToInputHelper,
|
||||||
|
@ -20,11 +20,15 @@ import {
|
|||||||
compareVec2Epsilon,
|
compareVec2Epsilon,
|
||||||
} from 'lang/std/sketch'
|
} from 'lang/std/sketch'
|
||||||
import { getNodeFromPath } from 'lang/queryAst'
|
import { getNodeFromPath } from 'lang/queryAst'
|
||||||
import { Program, VariableDeclarator } from 'lang/abstractSyntaxTreeTypes'
|
import {
|
||||||
import { modify_ast_for_sketch } from '../wasm-lib/pkg/wasm_lib'
|
Program,
|
||||||
|
VariableDeclarator,
|
||||||
|
rangeTypeFix,
|
||||||
|
modifyAstForSketch,
|
||||||
|
} from 'lang/wasm'
|
||||||
import { KCLError } from 'lang/errors'
|
import { KCLError } from 'lang/errors'
|
||||||
import { KclError as RustKclError } from '../wasm-lib/kcl/bindings/KclError'
|
import { KclError as RustKclError } from '../wasm-lib/kcl/bindings/KclError'
|
||||||
import { rangeTypeFix } from 'lang/abstractSyntaxTree'
|
import { engineCommandManager } from '../lang/std/engineConnection'
|
||||||
|
|
||||||
export const Stream = ({ className = '' }) => {
|
export const Stream = ({ className = '' }) => {
|
||||||
const [isLoading, setIsLoading] = useState(true)
|
const [isLoading, setIsLoading] = useState(true)
|
||||||
@ -32,7 +36,6 @@ export const Stream = ({ className = '' }) => {
|
|||||||
const videoRef = useRef<HTMLVideoElement>(null)
|
const videoRef = useRef<HTMLVideoElement>(null)
|
||||||
const {
|
const {
|
||||||
mediaStream,
|
mediaStream,
|
||||||
engineCommandManager,
|
|
||||||
setButtonDownInStream,
|
setButtonDownInStream,
|
||||||
didDragInStream,
|
didDragInStream,
|
||||||
setDidDragInStream,
|
setDidDragInStream,
|
||||||
@ -43,9 +46,10 @@ export const Stream = ({ className = '' }) => {
|
|||||||
updateAst,
|
updateAst,
|
||||||
setGuiMode,
|
setGuiMode,
|
||||||
programMemory,
|
programMemory,
|
||||||
|
defaultPlanes,
|
||||||
|
currentPlane,
|
||||||
} = useStore((s) => ({
|
} = useStore((s) => ({
|
||||||
mediaStream: s.mediaStream,
|
mediaStream: s.mediaStream,
|
||||||
engineCommandManager: s.engineCommandManager,
|
|
||||||
setButtonDownInStream: s.setButtonDownInStream,
|
setButtonDownInStream: s.setButtonDownInStream,
|
||||||
fileId: s.fileId,
|
fileId: s.fileId,
|
||||||
didDragInStream: s.didDragInStream,
|
didDragInStream: s.didDragInStream,
|
||||||
@ -57,6 +61,8 @@ export const Stream = ({ className = '' }) => {
|
|||||||
updateAst: s.updateAst,
|
updateAst: s.updateAst,
|
||||||
setGuiMode: s.setGuiMode,
|
setGuiMode: s.setGuiMode,
|
||||||
programMemory: s.programMemory,
|
programMemory: s.programMemory,
|
||||||
|
defaultPlanes: s.defaultPlanes,
|
||||||
|
currentPlane: s.currentPlane,
|
||||||
}))
|
}))
|
||||||
const {
|
const {
|
||||||
settings: {
|
settings: {
|
||||||
@ -73,7 +79,7 @@ export const Stream = ({ className = '' }) => {
|
|||||||
if (!videoRef.current) return
|
if (!videoRef.current) return
|
||||||
if (!mediaStream) return
|
if (!mediaStream) return
|
||||||
videoRef.current.srcObject = mediaStream
|
videoRef.current.srcObject = mediaStream
|
||||||
}, [mediaStream, engineCommandManager])
|
}, [mediaStream])
|
||||||
|
|
||||||
const handleMouseDown: MouseEventHandler<HTMLVideoElement> = (e) => {
|
const handleMouseDown: MouseEventHandler<HTMLVideoElement> = (e) => {
|
||||||
if (!videoRef.current) return
|
if (!videoRef.current) return
|
||||||
@ -107,7 +113,7 @@ export const Stream = ({ className = '' }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (guiMode.mode === 'sketch' && guiMode.sketchMode === ('move' as any)) {
|
if (guiMode.mode === 'sketch' && guiMode.sketchMode === ('move' as any)) {
|
||||||
engineCommandManager?.sendSceneCommand({
|
engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd: {
|
cmd: {
|
||||||
type: 'handle_mouse_drag_start',
|
type: 'handle_mouse_drag_start',
|
||||||
@ -121,7 +127,7 @@ export const Stream = ({ className = '' }) => {
|
|||||||
guiMode.sketchMode === ('sketch_line' as any)
|
guiMode.sketchMode === ('sketch_line' as any)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
engineCommandManager?.sendSceneCommand({
|
engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd: {
|
cmd: {
|
||||||
type: 'camera_drag_start',
|
type: 'camera_drag_start',
|
||||||
@ -139,7 +145,7 @@ export const Stream = ({ className = '' }) => {
|
|||||||
const handleScroll: WheelEventHandler<HTMLVideoElement> = (e) => {
|
const handleScroll: WheelEventHandler<HTMLVideoElement> = (e) => {
|
||||||
if (!cameraMouseDragGuards[cameraControls].zoom.scrollCallback(e)) return
|
if (!cameraMouseDragGuards[cameraControls].zoom.scrollCallback(e)) return
|
||||||
|
|
||||||
engineCommandManager?.sendSceneCommand({
|
engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd: {
|
cmd: {
|
||||||
type: 'default_camera_zoom',
|
type: 'default_camera_zoom',
|
||||||
@ -177,7 +183,7 @@ export const Stream = ({ className = '' }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!didDragInStream) {
|
if (!didDragInStream) {
|
||||||
engineCommandManager?.sendSceneCommand({
|
engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd: {
|
cmd: {
|
||||||
type: 'select_with_point',
|
type: 'select_with_point',
|
||||||
@ -214,7 +220,7 @@ export const Stream = ({ className = '' }) => {
|
|||||||
window: { x, y },
|
window: { x, y },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
engineCommandManager?.sendSceneCommand(command).then(async (resp) => {
|
engineCommandManager.sendSceneCommand(command).then(async (resp) => {
|
||||||
if (!(guiMode.mode === 'sketch')) return
|
if (!(guiMode.mode === 'sketch')) return
|
||||||
|
|
||||||
if (guiMode.sketchMode === 'selectFace') return
|
if (guiMode.sketchMode === 'selectFace') return
|
||||||
@ -240,9 +246,6 @@ export const Stream = ({ className = '' }) => {
|
|||||||
) {
|
) {
|
||||||
// Let's get the updated ast.
|
// Let's get the updated ast.
|
||||||
if (sketchGroupId === '') return
|
if (sketchGroupId === '') return
|
||||||
|
|
||||||
console.log('guiMode.pathId', guiMode.pathId)
|
|
||||||
|
|
||||||
// We have a problem if we do not have an id for the sketch group.
|
// We have a problem if we do not have an id for the sketch group.
|
||||||
if (
|
if (
|
||||||
guiMode.pathId === undefined ||
|
guiMode.pathId === undefined ||
|
||||||
@ -253,26 +256,30 @@ export const Stream = ({ className = '' }) => {
|
|||||||
|
|
||||||
let engineId = guiMode.pathId
|
let engineId = guiMode.pathId
|
||||||
|
|
||||||
try {
|
// Get the current plane string for plane we are on.
|
||||||
const updatedAst: Program = await modify_ast_for_sketch(
|
let currentPlaneString = ''
|
||||||
|
if (currentPlane === defaultPlanes?.xy) {
|
||||||
|
currentPlaneString = 'XY'
|
||||||
|
} else if (currentPlane === defaultPlanes?.yz) {
|
||||||
|
currentPlaneString = 'YZ'
|
||||||
|
} else if (currentPlane === defaultPlanes?.xz) {
|
||||||
|
currentPlaneString = 'XZ'
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not supporting editing/moving lines on a non-default plane.
|
||||||
|
// Eventually we can support this but for now we will just throw an
|
||||||
|
// error.
|
||||||
|
if (currentPlaneString === '') return
|
||||||
|
|
||||||
|
const updatedAst: Program = await modifyAstForSketch(
|
||||||
engineCommandManager,
|
engineCommandManager,
|
||||||
JSON.stringify(ast),
|
ast,
|
||||||
variableName,
|
variableName,
|
||||||
|
currentPlaneString,
|
||||||
engineId
|
engineId
|
||||||
)
|
)
|
||||||
|
|
||||||
updateAst(updatedAst, false)
|
updateAst(updatedAst, false)
|
||||||
} catch (e: any) {
|
|
||||||
const parsed: RustKclError = JSON.parse(e.toString())
|
|
||||||
const kclError = new KCLError(
|
|
||||||
parsed.kind,
|
|
||||||
parsed.msg,
|
|
||||||
rangeTypeFix(parsed.sourceRanges)
|
|
||||||
)
|
|
||||||
|
|
||||||
console.log(kclError)
|
|
||||||
throw kclError
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +292,7 @@ export const Stream = ({ className = '' }) => {
|
|||||||
guiMode.waitingFirstClick &&
|
guiMode.waitingFirstClick &&
|
||||||
!isEditingExistingSketch
|
!isEditingExistingSketch
|
||||||
) {
|
) {
|
||||||
const curve = await engineCommandManager?.sendSceneCommand({
|
const curve = await engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
cmd: {
|
cmd: {
|
||||||
@ -295,8 +302,46 @@ export const Stream = ({ className = '' }) => {
|
|||||||
})
|
})
|
||||||
const coords: { x: number; y: number }[] =
|
const coords: { x: number; y: number }[] =
|
||||||
curve.data.data.control_points
|
curve.data.data.control_points
|
||||||
|
|
||||||
|
// We need the normal for the plane we are on.
|
||||||
|
const plane = await engineCommandManager.sendSceneCommand({
|
||||||
|
type: 'modeling_cmd_req',
|
||||||
|
cmd_id: uuidv4(),
|
||||||
|
cmd: {
|
||||||
|
type: 'get_sketch_mode_plane',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const z_axis = plane.data.data.z_axis
|
||||||
|
|
||||||
|
// Get the current axis.
|
||||||
|
let currentAxis: 'xy' | 'xz' | 'yz' | '-xy' | '-xz' | '-yz' | null =
|
||||||
|
null
|
||||||
|
if (currentPlane === defaultPlanes?.xy) {
|
||||||
|
if (z_axis.z === -1) {
|
||||||
|
currentAxis = '-xy'
|
||||||
|
} else {
|
||||||
|
currentAxis = 'xy'
|
||||||
|
}
|
||||||
|
} else if (currentPlane === defaultPlanes?.yz) {
|
||||||
|
if (z_axis.x === -1) {
|
||||||
|
currentAxis = '-yz'
|
||||||
|
} else {
|
||||||
|
currentAxis = 'yz'
|
||||||
|
}
|
||||||
|
} else if (currentPlane === defaultPlanes?.xz) {
|
||||||
|
if (z_axis.y === -1) {
|
||||||
|
currentAxis = '-xz'
|
||||||
|
} else {
|
||||||
|
currentAxis = 'xz'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not support starting a new sketch on a non-default plane.
|
||||||
|
if (!currentAxis) return
|
||||||
|
|
||||||
const _addStartSketch = addStartSketch(
|
const _addStartSketch = addStartSketch(
|
||||||
ast,
|
ast,
|
||||||
|
currentAxis,
|
||||||
[roundOff(coords[0].x), roundOff(coords[0].y)],
|
[roundOff(coords[0].x), roundOff(coords[0].y)],
|
||||||
[
|
[
|
||||||
roundOff(coords[1].x - coords[0].x),
|
roundOff(coords[1].x - coords[0].x),
|
||||||
@ -326,7 +371,7 @@ export const Stream = ({ className = '' }) => {
|
|||||||
resp?.data?.data?.entities_modified?.length &&
|
resp?.data?.data?.entities_modified?.length &&
|
||||||
(!guiMode.waitingFirstClick || isEditingExistingSketch)
|
(!guiMode.waitingFirstClick || isEditingExistingSketch)
|
||||||
) {
|
) {
|
||||||
const curve = await engineCommandManager?.sendSceneCommand({
|
const curve = await engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
cmd: {
|
cmd: {
|
||||||
@ -371,12 +416,12 @@ export const Stream = ({ className = '' }) => {
|
|||||||
setGuiMode({
|
setGuiMode({
|
||||||
mode: 'default',
|
mode: 'default',
|
||||||
})
|
})
|
||||||
engineCommandManager?.sendSceneCommand({
|
engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
cmd: { type: 'edit_mode_exit' },
|
cmd: { type: 'edit_mode_exit' },
|
||||||
})
|
})
|
||||||
engineCommandManager?.sendSceneCommand({
|
engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
cmd: { type: 'default_camera_disable_sketch_mode' },
|
cmd: { type: 'default_camera_disable_sketch_mode' },
|
||||||
@ -415,6 +460,7 @@ export const Stream = ({ className = '' }) => {
|
|||||||
onWheel={handleScroll}
|
onWheel={handleScroll}
|
||||||
onPlay={() => setIsLoading(false)}
|
onPlay={() => setIsLoading(false)}
|
||||||
onMouseMoveCapture={handleMouseMove}
|
onMouseMoveCapture={handleMouseMove}
|
||||||
|
disablePictureInPicture
|
||||||
className={`w-full h-full ${isExecuting && 'blur-md'}`}
|
className={`w-full h-full ${isExecuting && 'blur-md'}`}
|
||||||
style={{ transitionDuration: '200ms', transitionProperty: 'filter' }}
|
style={{ transitionDuration: '200ms', transitionProperty: 'filter' }}
|
||||||
/>
|
/>
|
||||||
|
@ -30,6 +30,7 @@ import { isOverlap, roundOff } from 'lib/utils'
|
|||||||
import { kclErrToDiagnostic } from 'lang/errors'
|
import { kclErrToDiagnostic } from 'lang/errors'
|
||||||
import { CSSRuleObject } from 'tailwindcss/types/config'
|
import { CSSRuleObject } from 'tailwindcss/types/config'
|
||||||
import interact from '@replit/codemirror-interact'
|
import interact from '@replit/codemirror-interact'
|
||||||
|
import { engineCommandManager } from '../lang/std/engineConnection'
|
||||||
|
|
||||||
export const editorShortcutMeta = {
|
export const editorShortcutMeta = {
|
||||||
formatCode: {
|
formatCode: {
|
||||||
@ -52,7 +53,6 @@ export const TextEditor = ({
|
|||||||
code,
|
code,
|
||||||
deferredSetCode,
|
deferredSetCode,
|
||||||
editorView,
|
editorView,
|
||||||
engineCommandManager,
|
|
||||||
formatCode,
|
formatCode,
|
||||||
isLSPServerReady,
|
isLSPServerReady,
|
||||||
selectionRanges,
|
selectionRanges,
|
||||||
@ -64,7 +64,6 @@ export const TextEditor = ({
|
|||||||
code: s.code,
|
code: s.code,
|
||||||
deferredSetCode: s.deferredSetCode,
|
deferredSetCode: s.deferredSetCode,
|
||||||
editorView: s.editorView,
|
editorView: s.editorView,
|
||||||
engineCommandManager: s.engineCommandManager,
|
|
||||||
formatCode: s.formatCode,
|
formatCode: s.formatCode,
|
||||||
isLSPServerReady: s.isLSPServerReady,
|
isLSPServerReady: s.isLSPServerReady,
|
||||||
selectionRanges: s.selectionRanges,
|
selectionRanges: s.selectionRanges,
|
||||||
@ -173,7 +172,7 @@ export const TextEditor = ({
|
|||||||
const idBasedSelections = codeBasedSelections
|
const idBasedSelections = codeBasedSelections
|
||||||
.map(({ type, range }) => {
|
.map(({ type, range }) => {
|
||||||
const hasOverlap = Object.entries(
|
const hasOverlap = Object.entries(
|
||||||
engineCommandManager?.sourceRangeMap || {}
|
engineCommandManager.sourceRangeMap || {}
|
||||||
).filter(([_, sourceRange]) => {
|
).filter(([_, sourceRange]) => {
|
||||||
return isOverlap(sourceRange, range)
|
return isOverlap(sourceRange, range)
|
||||||
})
|
})
|
||||||
@ -186,7 +185,7 @@ export const TextEditor = ({
|
|||||||
})
|
})
|
||||||
.filter(Boolean) as any
|
.filter(Boolean) as any
|
||||||
|
|
||||||
engineCommandManager?.cusorsSelected({
|
engineCommandManager.cusorsSelected({
|
||||||
otherSelections: [],
|
otherSelections: [],
|
||||||
idBasedSelections,
|
idBasedSelections,
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { toolTips, useStore } from '../../useStore'
|
import { toolTips, useStore } from '../../useStore'
|
||||||
import { Value, VariableDeclarator } from '../../lang/abstractSyntaxTreeTypes'
|
import { Value, VariableDeclarator } from '../../lang/wasm'
|
||||||
import {
|
import {
|
||||||
getNodePathFromSourceRange,
|
getNodePathFromSourceRange,
|
||||||
getNodeFromPath,
|
getNodeFromPath,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { toolTips, useStore } from '../../useStore'
|
import { toolTips, useStore } from '../../useStore'
|
||||||
import { Value, VariableDeclarator } from '../../lang/abstractSyntaxTreeTypes'
|
import { Value, VariableDeclarator } from '../../lang/wasm'
|
||||||
import {
|
import {
|
||||||
getNodePathFromSourceRange,
|
getNodePathFromSourceRange,
|
||||||
getNodeFromPath,
|
getNodeFromPath,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { toolTips, useStore } from '../../useStore'
|
import { toolTips, useStore } from '../../useStore'
|
||||||
import { Value } from '../../lang/abstractSyntaxTreeTypes'
|
import { Value } from '../../lang/wasm'
|
||||||
import {
|
import {
|
||||||
getNodePathFromSourceRange,
|
getNodePathFromSourceRange,
|
||||||
getNodeFromPath,
|
getNodeFromPath,
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { create } from 'react-modal-promise'
|
import { create } from 'react-modal-promise'
|
||||||
import { toolTips, useStore } from '../../useStore'
|
import { toolTips, useStore } from '../../useStore'
|
||||||
import {
|
import { BinaryPart, Value, VariableDeclarator } from '../../lang/wasm'
|
||||||
BinaryPart,
|
|
||||||
Value,
|
|
||||||
VariableDeclarator,
|
|
||||||
} from '../../lang/abstractSyntaxTreeTypes'
|
|
||||||
import {
|
import {
|
||||||
getNodePathFromSourceRange,
|
getNodePathFromSourceRange,
|
||||||
getNodeFromPath,
|
getNodeFromPath,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { toolTips, useStore } from '../../useStore'
|
import { toolTips, useStore } from '../../useStore'
|
||||||
import { Value } from '../../lang/abstractSyntaxTreeTypes'
|
import { Value } from '../../lang/wasm'
|
||||||
import {
|
import {
|
||||||
getNodePathFromSourceRange,
|
getNodePathFromSourceRange,
|
||||||
getNodeFromPath,
|
getNodeFromPath,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { create } from 'react-modal-promise'
|
import { create } from 'react-modal-promise'
|
||||||
import { toolTips, useStore } from '../../useStore'
|
import { toolTips, useStore } from '../../useStore'
|
||||||
import { Value } from '../../lang/abstractSyntaxTreeTypes'
|
import { Value } from '../../lang/wasm'
|
||||||
import {
|
import {
|
||||||
getNodePathFromSourceRange,
|
getNodePathFromSourceRange,
|
||||||
getNodeFromPath,
|
getNodeFromPath,
|
||||||
@ -133,7 +133,7 @@ export const SetAbsDistance = ({ buttonType }: { buttonType: ButtonType }) => {
|
|||||||
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
|
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('e', e)
|
console.log('error', e)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
disabled={!enableAngLen}
|
disabled={!enableAngLen}
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { create } from 'react-modal-promise'
|
import { create } from 'react-modal-promise'
|
||||||
import { toolTips, useStore } from '../../useStore'
|
import { toolTips, useStore } from '../../useStore'
|
||||||
import {
|
import { BinaryPart, Value, VariableDeclarator } from '../../lang/wasm'
|
||||||
BinaryPart,
|
|
||||||
Value,
|
|
||||||
VariableDeclarator,
|
|
||||||
} from '../../lang/abstractSyntaxTreeTypes'
|
|
||||||
import {
|
import {
|
||||||
getNodePathFromSourceRange,
|
getNodePathFromSourceRange,
|
||||||
getNodeFromPath,
|
getNodeFromPath,
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { create } from 'react-modal-promise'
|
import { create } from 'react-modal-promise'
|
||||||
import { toolTips, useStore } from '../../useStore'
|
import { toolTips, useStore } from '../../useStore'
|
||||||
import {
|
import { BinaryPart, Value, VariableDeclarator } from '../../lang/wasm'
|
||||||
BinaryPart,
|
|
||||||
Value,
|
|
||||||
VariableDeclarator,
|
|
||||||
} from '../../lang/abstractSyntaxTreeTypes'
|
|
||||||
import {
|
import {
|
||||||
getNodePathFromSourceRange,
|
getNodePathFromSourceRange,
|
||||||
getNodeFromPath,
|
getNodeFromPath,
|
||||||
@ -21,8 +17,6 @@ import { GetInfoModal } from '../SetHorVertDistanceModal'
|
|||||||
import { createLiteral, createVariableDeclaration } from '../../lang/modifyAst'
|
import { createLiteral, createVariableDeclaration } from '../../lang/modifyAst'
|
||||||
import { removeDoubleNegatives } from '../AvailableVarsHelpers'
|
import { removeDoubleNegatives } from '../AvailableVarsHelpers'
|
||||||
import { updateCursors } from '../../lang/util'
|
import { updateCursors } from '../../lang/util'
|
||||||
import { ActionIcon } from 'components/ActionIcon'
|
|
||||||
import { sketchButtonClassnames } from 'Toolbar'
|
|
||||||
|
|
||||||
const getModalInfo = create(GetInfoModal as any)
|
const getModalInfo = create(GetInfoModal as any)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { create } from 'react-modal-promise'
|
import { create } from 'react-modal-promise'
|
||||||
import { toolTips, useStore } from '../../useStore'
|
import { toolTips, useStore } from '../../useStore'
|
||||||
import { Value } from '../../lang/abstractSyntaxTreeTypes'
|
import { Value } from '../../lang/wasm'
|
||||||
import {
|
import {
|
||||||
getNodePathFromSourceRange,
|
getNodePathFromSourceRange,
|
||||||
getNodeFromPath,
|
getNodeFromPath,
|
||||||
@ -147,7 +147,7 @@ export const SetAngleLength = ({
|
|||||||
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
|
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('e', e)
|
console.log('erorr', e)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
disabled={!enableAngLen}
|
disabled={!enableAngLen}
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
import { fireEvent, render, screen } from '@testing-library/react'
|
import { fireEvent, render, screen } from '@testing-library/react'
|
||||||
import UserSidebarMenu from './UserSidebarMenu'
|
import UserSidebarMenu from './UserSidebarMenu'
|
||||||
import { BrowserRouter } from 'react-router-dom'
|
import {
|
||||||
|
Route,
|
||||||
|
RouterProvider,
|
||||||
|
createMemoryRouter,
|
||||||
|
createRoutesFromElements,
|
||||||
|
} from 'react-router-dom'
|
||||||
import { Models } from '@kittycad/lib'
|
import { Models } from '@kittycad/lib'
|
||||||
import { GlobalStateProvider } from './GlobalStateProvider'
|
import { GlobalStateProvider } from './GlobalStateProvider'
|
||||||
import CommandBarProvider from './CommandBar'
|
import CommandBarProvider from './CommandBar'
|
||||||
@ -93,11 +98,24 @@ describe('UserSidebarMenu tests', () => {
|
|||||||
|
|
||||||
function TestWrap({ children }: { children: React.ReactNode }) {
|
function TestWrap({ children }: { children: React.ReactNode }) {
|
||||||
// wrap in router and xState context
|
// wrap in router and xState context
|
||||||
return (
|
// We have to use a memory router in the testing environment,
|
||||||
<BrowserRouter>
|
// and we have to use the createMemoryRouter function instead of <MemoryRouter /> as of react-router v6.4:
|
||||||
|
// https://reactrouter.com/en/6.16.0/routers/picking-a-router#using-v64-data-apis
|
||||||
|
const router = createMemoryRouter(
|
||||||
|
createRoutesFromElements(
|
||||||
|
<Route
|
||||||
|
path="/file/:id"
|
||||||
|
element={
|
||||||
<CommandBarProvider>
|
<CommandBarProvider>
|
||||||
<GlobalStateProvider>{children}</GlobalStateProvider>
|
<GlobalStateProvider>{children}</GlobalStateProvider>
|
||||||
</CommandBarProvider>
|
</CommandBarProvider>
|
||||||
</BrowserRouter>
|
}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
{
|
||||||
|
initialEntries: ['/file/new'],
|
||||||
|
initialIndex: 0,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
return <RouterProvider router={router} />
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,24 @@
|
|||||||
import { Popover, Transition } from '@headlessui/react'
|
import { Popover, Transition } from '@headlessui/react'
|
||||||
import { ActionButton } from './ActionButton'
|
import { ActionButton } from './ActionButton'
|
||||||
import { faBars, faGear, faSignOutAlt } from '@fortawesome/free-solid-svg-icons'
|
import {
|
||||||
|
faBars,
|
||||||
|
faBug,
|
||||||
|
faGear,
|
||||||
|
faSignOutAlt,
|
||||||
|
} from '@fortawesome/free-solid-svg-icons'
|
||||||
import { faGithub } from '@fortawesome/free-brands-svg-icons'
|
import { faGithub } from '@fortawesome/free-brands-svg-icons'
|
||||||
import { useLocation, useNavigate } from 'react-router-dom'
|
import { useLocation, useNavigate } from 'react-router-dom'
|
||||||
import { Fragment, useState } from 'react'
|
import { Fragment, useState } from 'react'
|
||||||
import { paths } from '../Router'
|
import { paths } from '../Router'
|
||||||
import makeUrlPathRelative from '../lib/makeUrlPathRelative'
|
|
||||||
import { Models } from '@kittycad/lib'
|
import { Models } from '@kittycad/lib'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
||||||
|
import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath'
|
||||||
|
|
||||||
type User = Models['User_type']
|
type User = Models['User_type']
|
||||||
|
|
||||||
const UserSidebarMenu = ({ user }: { user?: User }) => {
|
const UserSidebarMenu = ({ user }: { user?: User }) => {
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
|
const filePath = useAbsoluteFilePath()
|
||||||
const displayedName = getDisplayName(user)
|
const displayedName = getDisplayName(user)
|
||||||
const [imageLoadFailed, setImageLoadFailed] = useState(false)
|
const [imageLoadFailed, setImageLoadFailed] = useState(false)
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
@ -127,23 +133,30 @@ const UserSidebarMenu = ({ user }: { user?: User }) => {
|
|||||||
// since /settings is a nested route the sidebar doesn't close
|
// since /settings is a nested route the sidebar doesn't close
|
||||||
// automatically when navigating to it
|
// automatically when navigating to it
|
||||||
close()
|
close()
|
||||||
navigate(
|
const targetPath = location.pathname.includes(paths.FILE)
|
||||||
(location.pathname.endsWith('/')
|
? filePath + paths.SETTINGS
|
||||||
? location.pathname.slice(0, -1)
|
: paths.HOME + paths.SETTINGS
|
||||||
: location.pathname) + paths.SETTINGS
|
navigate(targetPath)
|
||||||
)
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Settings
|
Settings
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
<ActionButton
|
<ActionButton
|
||||||
Element="link"
|
Element="externalLink"
|
||||||
to="https://github.com/KittyCAD/modeling-app/discussions"
|
to="https://github.com/KittyCAD/modeling-app/discussions"
|
||||||
icon={{ icon: faGithub }}
|
icon={{ icon: faGithub }}
|
||||||
className="border-transparent dark:border-transparent dark:hover:border-liquid-60"
|
className="border-transparent dark:border-transparent dark:hover:border-liquid-60"
|
||||||
>
|
>
|
||||||
Request a feature
|
Request a feature
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
|
<ActionButton
|
||||||
|
Element="externalLink"
|
||||||
|
to="https://github.com/KittyCAD/modeling-app/issues/new"
|
||||||
|
icon={{ icon: faBug }}
|
||||||
|
className="border-transparent dark:border-transparent dark:hover:border-liquid-60"
|
||||||
|
>
|
||||||
|
Report a bug
|
||||||
|
</ActionButton>
|
||||||
<ActionButton
|
<ActionButton
|
||||||
Element="button"
|
Element="button"
|
||||||
onClick={() => send('Log out')}
|
onClick={() => send('Log out')}
|
||||||
|
@ -109,7 +109,6 @@ export default class Client extends jsrpc.JSONRPCServerAndClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
messageString += message
|
messageString += message
|
||||||
// console.log(messageString)
|
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import {
|
|||||||
CompletionItemKind,
|
CompletionItemKind,
|
||||||
CompletionTriggerKind,
|
CompletionTriggerKind,
|
||||||
} from 'vscode-languageserver-protocol'
|
} from 'vscode-languageserver-protocol'
|
||||||
|
import debounce from 'debounce-promise'
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
Completion,
|
Completion,
|
||||||
@ -53,14 +54,11 @@ export class LanguageServerPlugin implements PluginValue {
|
|||||||
private languageId: string
|
private languageId: string
|
||||||
private documentVersion: number
|
private documentVersion: number
|
||||||
|
|
||||||
private changesTimeout: number
|
|
||||||
|
|
||||||
constructor(private view: EditorView, private allowHTMLContent: boolean) {
|
constructor(private view: EditorView, private allowHTMLContent: boolean) {
|
||||||
this.client = this.view.state.facet(client)
|
this.client = this.view.state.facet(client)
|
||||||
this.documentUri = this.view.state.facet(documentUri)
|
this.documentUri = this.view.state.facet(documentUri)
|
||||||
this.languageId = this.view.state.facet(languageId)
|
this.languageId = this.view.state.facet(languageId)
|
||||||
this.documentVersion = 0
|
this.documentVersion = 0
|
||||||
this.changesTimeout = 0
|
|
||||||
|
|
||||||
this.client.attachPlugin(this)
|
this.client.attachPlugin(this)
|
||||||
|
|
||||||
@ -71,12 +69,10 @@ export class LanguageServerPlugin implements PluginValue {
|
|||||||
|
|
||||||
update({ docChanged }: ViewUpdate) {
|
update({ docChanged }: ViewUpdate) {
|
||||||
if (!docChanged) return
|
if (!docChanged) return
|
||||||
if (this.changesTimeout) clearTimeout(this.changesTimeout)
|
|
||||||
this.changesTimeout = window.setTimeout(() => {
|
|
||||||
this.sendChange({
|
this.sendChange({
|
||||||
documentText: this.view.state.doc.toString(),
|
documentText: this.view.state.doc.toString(),
|
||||||
})
|
})
|
||||||
}, changesDelay)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
@ -99,14 +95,32 @@ export class LanguageServerPlugin implements PluginValue {
|
|||||||
|
|
||||||
async sendChange({ documentText }: { documentText: string }) {
|
async sendChange({ documentText }: { documentText: string }) {
|
||||||
if (!this.client.ready) return
|
if (!this.client.ready) return
|
||||||
|
|
||||||
|
if (documentText.length > 5000) {
|
||||||
|
// Clear out the text it thinks we have, large documents will throw a stack error.
|
||||||
|
// This is obviously not a good fix but it works for now til we figure
|
||||||
|
// out the stack limits in wasm and also rewrite the parser.
|
||||||
|
// Since this is only for hover and completions it will be fine,
|
||||||
|
// completions will still work for stdlib but hover will not.
|
||||||
|
// That seems like a fine trade-off for a working editor for the time
|
||||||
|
// being.
|
||||||
|
documentText = ''
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.client.textDocumentDidChange({
|
debounce(
|
||||||
|
() => {
|
||||||
|
return this.client.textDocumentDidChange({
|
||||||
textDocument: {
|
textDocument: {
|
||||||
uri: this.documentUri,
|
uri: this.documentUri,
|
||||||
version: this.documentVersion++,
|
version: this.documentVersion++,
|
||||||
},
|
},
|
||||||
contentChanges: [{ text: documentText }],
|
contentChanges: [{ text: documentText }],
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
changesDelay,
|
||||||
|
{ leading: true }
|
||||||
|
)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
|
12
src/hooks/useAbsoluteFilePath.ts
Normal file
12
src/hooks/useAbsoluteFilePath.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { BROWSER_FILE_NAME, IndexLoaderData, paths } from 'Router'
|
||||||
|
import { useRouteLoaderData } from 'react-router-dom'
|
||||||
|
|
||||||
|
export function useAbsoluteFilePath() {
|
||||||
|
const routeData = useRouteLoaderData(paths.FILE) as IndexLoaderData
|
||||||
|
|
||||||
|
return (
|
||||||
|
paths.FILE +
|
||||||
|
'/' +
|
||||||
|
encodeURIComponent(routeData?.project?.path || BROWSER_FILE_NAME)
|
||||||
|
)
|
||||||
|
}
|
@ -2,35 +2,37 @@
|
|||||||
// Once we have xState this should be removed
|
// Once we have xState this should be removed
|
||||||
|
|
||||||
import { useStore, Selections } from 'useStore'
|
import { useStore, Selections } from 'useStore'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect } from 'react'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import { ArtifactMap, EngineCommandManager } from 'lang/std/engineConnection'
|
import { ArtifactMap, EngineCommandManager } from 'lang/std/engineConnection'
|
||||||
import { Models } from '@kittycad/lib/dist/types/src'
|
import { Models } from '@kittycad/lib/dist/types/src'
|
||||||
import { isReducedMotion } from 'lang/util'
|
import { isReducedMotion } from 'lang/util'
|
||||||
import { isOverlap } from 'lib/utils'
|
import { isOverlap } from 'lib/utils'
|
||||||
|
import { engineCommandManager } from '../lang/std/engineConnection'
|
||||||
interface DefaultPlanes {
|
import { DefaultPlanes } from '../wasm-lib/kcl/bindings/DefaultPlanes'
|
||||||
xy: string
|
import { getNodeFromPath } from '../lang/queryAst'
|
||||||
// TODO re-enable
|
import { CallExpression, PipeExpression } from '../lang/wasm'
|
||||||
// yz: string
|
|
||||||
// xz: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useAppMode() {
|
export function useAppMode() {
|
||||||
const {
|
const {
|
||||||
guiMode,
|
guiMode,
|
||||||
setGuiMode,
|
setGuiMode,
|
||||||
selectionRanges,
|
selectionRanges,
|
||||||
engineCommandManager,
|
|
||||||
selectionRangeTypeMap,
|
selectionRangeTypeMap,
|
||||||
|
defaultPlanes,
|
||||||
|
setDefaultPlanes,
|
||||||
|
setCurrentPlane,
|
||||||
|
ast,
|
||||||
} = useStore((s) => ({
|
} = useStore((s) => ({
|
||||||
guiMode: s.guiMode,
|
guiMode: s.guiMode,
|
||||||
setGuiMode: s.setGuiMode,
|
setGuiMode: s.setGuiMode,
|
||||||
selectionRanges: s.selectionRanges,
|
selectionRanges: s.selectionRanges,
|
||||||
engineCommandManager: s.engineCommandManager,
|
|
||||||
selectionRangeTypeMap: s.selectionRangeTypeMap,
|
selectionRangeTypeMap: s.selectionRangeTypeMap,
|
||||||
|
defaultPlanes: s.defaultPlanes,
|
||||||
|
setDefaultPlanes: s.setDefaultPlanes,
|
||||||
|
setCurrentPlane: s.setCurrentPlane,
|
||||||
|
ast: s.ast,
|
||||||
}))
|
}))
|
||||||
const [defaultPlanes, setDefaultPlanes] = useState<DefaultPlanes | null>(null)
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
guiMode.mode === 'sketch' &&
|
guiMode.mode === 'sketch' &&
|
||||||
@ -40,8 +42,10 @@ export function useAppMode() {
|
|||||||
const createAndShowPlanes = async () => {
|
const createAndShowPlanes = async () => {
|
||||||
let localDefaultPlanes: DefaultPlanes
|
let localDefaultPlanes: DefaultPlanes
|
||||||
if (!defaultPlanes) {
|
if (!defaultPlanes) {
|
||||||
localDefaultPlanes = await initDefaultPlanes(engineCommandManager)
|
const newDefaultPlanes = await initDefaultPlanes(engineCommandManager)
|
||||||
setDefaultPlanes(localDefaultPlanes)
|
if (!newDefaultPlanes) return
|
||||||
|
setDefaultPlanes(newDefaultPlanes)
|
||||||
|
localDefaultPlanes = newDefaultPlanes
|
||||||
} else {
|
} else {
|
||||||
localDefaultPlanes = defaultPlanes
|
localDefaultPlanes = defaultPlanes
|
||||||
}
|
}
|
||||||
@ -57,20 +61,52 @@ export function useAppMode() {
|
|||||||
const enableSketchMode = async () => {
|
const enableSketchMode = async () => {
|
||||||
let localDefaultPlanes: DefaultPlanes
|
let localDefaultPlanes: DefaultPlanes
|
||||||
if (!defaultPlanes) {
|
if (!defaultPlanes) {
|
||||||
localDefaultPlanes = await initDefaultPlanes(engineCommandManager)
|
const newDefaultPlanes = await initDefaultPlanes(engineCommandManager)
|
||||||
setDefaultPlanes(localDefaultPlanes)
|
if (!newDefaultPlanes) return
|
||||||
|
setDefaultPlanes(newDefaultPlanes)
|
||||||
|
localDefaultPlanes = newDefaultPlanes
|
||||||
} else {
|
} else {
|
||||||
localDefaultPlanes = defaultPlanes
|
localDefaultPlanes = defaultPlanes
|
||||||
}
|
}
|
||||||
setDefaultPlanesHidden(engineCommandManager, localDefaultPlanes, true)
|
setDefaultPlanesHidden(engineCommandManager, localDefaultPlanes, true)
|
||||||
// TODO figure out the plane to use based on the sketch
|
|
||||||
// maybe it's easier to make a new plane than rely on the defaults
|
const pipeExpression = getNodeFromPath<PipeExpression>(
|
||||||
await engineCommandManager?.sendSceneCommand({
|
ast,
|
||||||
|
guiMode.pathToNode,
|
||||||
|
'PipeExpression'
|
||||||
|
).node
|
||||||
|
if (pipeExpression.type !== 'PipeExpression') return /// bad bad bad
|
||||||
|
const sketchCallExpression = pipeExpression.body.find(
|
||||||
|
(e) =>
|
||||||
|
e.type === 'CallExpression' && e.callee.name === 'startSketchOn'
|
||||||
|
) as CallExpression
|
||||||
|
if (!sketchCallExpression) return // also bad bad bad
|
||||||
|
const firstArg = sketchCallExpression.arguments[0]
|
||||||
|
let planeId = ''
|
||||||
|
if (firstArg.type === 'Literal' && firstArg.value) {
|
||||||
|
const planeStrCleaned = firstArg.value
|
||||||
|
.toString()
|
||||||
|
.toLowerCase()
|
||||||
|
.replace('-', '')
|
||||||
|
if (
|
||||||
|
planeStrCleaned === 'xy' ||
|
||||||
|
planeStrCleaned === 'xz' ||
|
||||||
|
planeStrCleaned === 'yz'
|
||||||
|
) {
|
||||||
|
planeId = localDefaultPlanes[planeStrCleaned]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!planeId) return // they are on some non default plane, which we don't support yet
|
||||||
|
|
||||||
|
setCurrentPlane(planeId)
|
||||||
|
|
||||||
|
await engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
cmd: {
|
cmd: {
|
||||||
type: 'sketch_mode_enable',
|
type: 'sketch_mode_enable',
|
||||||
plane_id: localDefaultPlanes.xy,
|
plane_id: planeId,
|
||||||
ortho: true,
|
ortho: true,
|
||||||
animated: !isReducedMotion(),
|
animated: !isReducedMotion(),
|
||||||
},
|
},
|
||||||
@ -135,7 +171,7 @@ export function useAppMode() {
|
|||||||
])
|
])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const unSub = engineCommandManager?.subscribeTo({
|
const unSub = engineCommandManager.subscribeTo({
|
||||||
event: 'select_with_point',
|
event: 'select_with_point',
|
||||||
callback: async ({ data }) => {
|
callback: async ({ data }) => {
|
||||||
if (!data.entity_id) return
|
if (!data.entity_id) return
|
||||||
@ -144,8 +180,8 @@ export function useAppMode() {
|
|||||||
// user clicked something else in the scene
|
// user clicked something else in the scene
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const sketchModeResponse = await engineCommandManager?.sendSceneCommand(
|
setCurrentPlane(data.entity_id)
|
||||||
{
|
const sketchModeResponse = await engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
cmd: {
|
cmd: {
|
||||||
@ -154,8 +190,7 @@ export function useAppMode() {
|
|||||||
ortho: true,
|
ortho: true,
|
||||||
animated: !isReducedMotion(),
|
animated: !isReducedMotion(),
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
)
|
|
||||||
setDefaultPlanesHidden(engineCommandManager, defaultPlanes, true)
|
setDefaultPlanesHidden(engineCommandManager, defaultPlanes, true)
|
||||||
const sketchUuid = uuidv4()
|
const sketchUuid = uuidv4()
|
||||||
const proms: any[] = []
|
const proms: any[] = []
|
||||||
@ -178,8 +213,7 @@ export function useAppMode() {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
const res = await Promise.all(proms)
|
await Promise.all(proms)
|
||||||
console.log('res', res)
|
|
||||||
setGuiMode({
|
setGuiMode({
|
||||||
mode: 'sketch',
|
mode: 'sketch',
|
||||||
sketchMode: 'sketchEdit',
|
sketchMode: 'sketchEdit',
|
||||||
@ -202,14 +236,16 @@ async function createPlane(
|
|||||||
x_axis,
|
x_axis,
|
||||||
y_axis,
|
y_axis,
|
||||||
color,
|
color,
|
||||||
|
hidden,
|
||||||
}: {
|
}: {
|
||||||
x_axis: Models['Point3d_type']
|
x_axis: Models['Point3d_type']
|
||||||
y_axis: Models['Point3d_type']
|
y_axis: Models['Point3d_type']
|
||||||
color: Models['Color_type']
|
color: Models['Color_type']
|
||||||
|
hidden: boolean
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
const planeId = uuidv4()
|
const planeId = uuidv4()
|
||||||
await engineCommandManager?.sendSceneCommand({
|
await engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd: {
|
cmd: {
|
||||||
type: 'make_plane',
|
type: 'make_plane',
|
||||||
@ -218,10 +254,11 @@ async function createPlane(
|
|||||||
x_axis,
|
x_axis,
|
||||||
y_axis,
|
y_axis,
|
||||||
clobber: false,
|
clobber: false,
|
||||||
|
hide: hidden,
|
||||||
},
|
},
|
||||||
cmd_id: planeId,
|
cmd_id: planeId,
|
||||||
})
|
})
|
||||||
await engineCommandManager?.sendSceneCommand({
|
await engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd: {
|
cmd: {
|
||||||
type: 'plane_set_color',
|
type: 'plane_set_color',
|
||||||
@ -233,13 +270,22 @@ async function createPlane(
|
|||||||
return planeId
|
return planeId
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDefaultPlanesHidden(
|
export function setDefaultPlanesHidden(
|
||||||
engineCommandManager: EngineCommandManager | undefined,
|
engineCommandManager: EngineCommandManager,
|
||||||
defaultPlanes: DefaultPlanes,
|
defaultPlanes: DefaultPlanes,
|
||||||
hidden: boolean
|
hidden: boolean
|
||||||
) {
|
) {
|
||||||
Object.values(defaultPlanes).forEach((planeId) => {
|
Object.values(defaultPlanes).forEach((planeId) => {
|
||||||
engineCommandManager?.sendSceneCommand({
|
hidePlane(engineCommandManager, planeId, hidden)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function hidePlane(
|
||||||
|
engineCommandManager: EngineCommandManager,
|
||||||
|
planeId: string,
|
||||||
|
hidden: boolean
|
||||||
|
) {
|
||||||
|
engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd_id: uuidv4(),
|
cmd_id: uuidv4(),
|
||||||
cmd: {
|
cmd: {
|
||||||
@ -248,37 +294,49 @@ function setDefaultPlanesHidden(
|
|||||||
hidden: hidden,
|
hidden: hidden,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function initDefaultPlanes(
|
export async function initDefaultPlanes(
|
||||||
engineCommandManager: EngineCommandManager
|
engineCommandManager: EngineCommandManager,
|
||||||
): Promise<DefaultPlanes> {
|
hidePlanes?: boolean
|
||||||
|
): Promise<DefaultPlanes | null> {
|
||||||
|
if (!engineCommandManager.engineConnection?.isReady()) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
const xy = await createPlane(engineCommandManager, {
|
const xy = await createPlane(engineCommandManager, {
|
||||||
x_axis: { x: 1, y: 0, z: 0 },
|
x_axis: { x: 1, y: 0, z: 0 },
|
||||||
y_axis: { x: 0, y: 1, z: 0 },
|
y_axis: { x: 0, y: 1, z: 0 },
|
||||||
color: { r: 0.7, g: 0.28, b: 0.28, a: 0.4 },
|
color: { r: 0.7, g: 0.28, b: 0.28, a: 0.4 },
|
||||||
|
hidden: hidePlanes ? true : false,
|
||||||
})
|
})
|
||||||
// TODO re-enable
|
if (hidePlanes) {
|
||||||
// const yz = createPlane(engineCommandManager, {
|
hidePlane(engineCommandManager, xy, true)
|
||||||
// x_axis: { x: 0, y: 1, z: 0 },
|
}
|
||||||
// y_axis: { x: 0, y: 0, z: 1 },
|
const yz = await createPlane(engineCommandManager, {
|
||||||
// color: { r: 0.28, g: 0.7, b: 0.28, a: 0.4 },
|
x_axis: { x: 0, y: 1, z: 0 },
|
||||||
// })
|
y_axis: { x: 0, y: 0, z: 1 },
|
||||||
// const xz = createPlane(engineCommandManager, {
|
color: { r: 0.28, g: 0.7, b: 0.28, a: 0.4 },
|
||||||
// x_axis: { x: 1, y: 0, z: 0 },
|
hidden: hidePlanes ? true : false,
|
||||||
// y_axis: { x: 0, y: 0, z: 1 },
|
})
|
||||||
// color: { r: 0.28, g: 0.28, b: 0.7, a: 0.4 },
|
if (hidePlanes) {
|
||||||
// })
|
hidePlane(engineCommandManager, yz, true)
|
||||||
return { xy }
|
}
|
||||||
|
const xz = await createPlane(engineCommandManager, {
|
||||||
|
x_axis: { x: 1, y: 0, z: 0 },
|
||||||
|
y_axis: { x: 0, y: 0, z: 1 },
|
||||||
|
color: { r: 0.28, g: 0.28, b: 0.7, a: 0.4 },
|
||||||
|
hidden: hidePlanes ? true : false,
|
||||||
|
})
|
||||||
|
return { xy, yz, xz }
|
||||||
}
|
}
|
||||||
|
|
||||||
function isCursorInSketchCommandRange(
|
function isCursorInSketchCommandRange(
|
||||||
artifactMap: ArtifactMap,
|
artifactMap: ArtifactMap,
|
||||||
selectionRanges: Selections
|
selectionRanges: Selections
|
||||||
): string | false {
|
): string | false {
|
||||||
const overlapingEntries = Object.entries(artifactMap || {}).filter(
|
const overlapingEntries: [string, ArtifactMap[string]][] = Object.entries(
|
||||||
([id, artifact]) =>
|
artifactMap
|
||||||
|
).filter(([id, artifact]: [string, ArtifactMap[string]]) =>
|
||||||
selectionRanges.codeBasedSelections.some(
|
selectionRanges.codeBasedSelections.some(
|
||||||
(selection) =>
|
(selection) =>
|
||||||
Array.isArray(selection?.range) &&
|
Array.isArray(selection?.range) &&
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
import { useStore } from 'useStore'
|
import { useStore } from 'useStore'
|
||||||
|
import { engineCommandManager } from '../lang/std/engineConnection'
|
||||||
|
|
||||||
export function useEngineConnectionSubscriptions() {
|
export function useEngineConnectionSubscriptions() {
|
||||||
const {
|
const { setCursor2, setHighlightRange, highlightRange } = useStore((s) => ({
|
||||||
engineCommandManager,
|
|
||||||
setCursor2,
|
|
||||||
setHighlightRange,
|
|
||||||
highlightRange,
|
|
||||||
} = useStore((s) => ({
|
|
||||||
engineCommandManager: s.engineCommandManager,
|
|
||||||
setCursor2: s.setCursor2,
|
setCursor2: s.setCursor2,
|
||||||
setHighlightRange: s.setHighlightRange,
|
setHighlightRange: s.setHighlightRange,
|
||||||
highlightRange: s.highlightRange,
|
highlightRange: s.highlightRange,
|
||||||
|
@ -1,53 +1,92 @@
|
|||||||
import { useLayoutEffect } from 'react'
|
import { useLayoutEffect, useEffect, useRef } from 'react'
|
||||||
import { _executor } from '../lang/executor'
|
import { _executor } from '../lang/wasm'
|
||||||
import { useStore } from '../useStore'
|
import { useStore } from '../useStore'
|
||||||
import { EngineCommandManager } from '../lang/std/engineConnection'
|
import { engineCommandManager } from '../lang/std/engineConnection'
|
||||||
|
import { deferExecution } from 'lib/utils'
|
||||||
|
|
||||||
export function useSetupEngineManager(
|
export function useSetupEngineManager(
|
||||||
streamRef: React.RefObject<HTMLDivElement>,
|
streamRef: React.RefObject<HTMLDivElement>,
|
||||||
token?: string
|
token?: string
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
setEngineCommandManager,
|
|
||||||
setMediaStream,
|
setMediaStream,
|
||||||
setIsStreamReady,
|
setIsStreamReady,
|
||||||
setStreamDimensions,
|
setStreamDimensions,
|
||||||
|
streamDimensions,
|
||||||
executeCode,
|
executeCode,
|
||||||
} = useStore((s) => ({
|
} = useStore((s) => ({
|
||||||
setEngineCommandManager: s.setEngineCommandManager,
|
|
||||||
setMediaStream: s.setMediaStream,
|
setMediaStream: s.setMediaStream,
|
||||||
setIsStreamReady: s.setIsStreamReady,
|
setIsStreamReady: s.setIsStreamReady,
|
||||||
setStreamDimensions: s.setStreamDimensions,
|
setStreamDimensions: s.setStreamDimensions,
|
||||||
|
streamDimensions: s.streamDimensions,
|
||||||
executeCode: s.executeCode,
|
executeCode: s.executeCode,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const streamWidth = streamRef?.current?.offsetWidth
|
const streamWidth = streamRef?.current?.offsetWidth
|
||||||
const streamHeight = streamRef?.current?.offsetHeight
|
const streamHeight = streamRef?.current?.offsetHeight
|
||||||
|
|
||||||
const width = streamWidth ? streamWidth : 0
|
const hasSetNonZeroDimensions = useRef<boolean>(false)
|
||||||
const quadWidth = Math.round(width / 4) * 4
|
|
||||||
const height = streamHeight ? streamHeight : 0
|
useEffect(() => {
|
||||||
const quadHeight = Math.round(height / 4) * 4
|
executeCode()
|
||||||
|
}, [])
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
setStreamDimensions({
|
// Load the engine command manager once with the initial width and height,
|
||||||
streamWidth: quadWidth,
|
// then we do not want to reload it.
|
||||||
streamHeight: quadHeight,
|
const { width: quadWidth, height: quadHeight } = getDimensions(
|
||||||
})
|
streamWidth,
|
||||||
if (!width || !height) return
|
streamHeight
|
||||||
const eng = new EngineCommandManager({
|
)
|
||||||
|
if (!hasSetNonZeroDimensions.current && quadHeight && quadWidth) {
|
||||||
|
engineCommandManager.start({
|
||||||
setMediaStream,
|
setMediaStream,
|
||||||
setIsStreamReady,
|
setIsStreamReady,
|
||||||
width: quadWidth,
|
width: quadWidth,
|
||||||
height: quadHeight,
|
height: quadHeight,
|
||||||
|
executeCode,
|
||||||
token,
|
token,
|
||||||
})
|
})
|
||||||
setEngineCommandManager(eng)
|
setStreamDimensions({
|
||||||
eng.waitForReady.then(() => {
|
streamWidth: quadWidth,
|
||||||
executeCode()
|
streamHeight: quadHeight,
|
||||||
})
|
})
|
||||||
return () => {
|
hasSetNonZeroDimensions.current = true
|
||||||
eng?.tearDown()
|
|
||||||
}
|
}
|
||||||
}, [quadWidth, quadHeight])
|
}, [streamRef?.current?.offsetWidth, streamRef?.current?.offsetHeight])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleResize = deferExecution(() => {
|
||||||
|
const { width, height } = getDimensions(
|
||||||
|
streamRef?.current?.offsetWidth,
|
||||||
|
streamRef?.current?.offsetHeight
|
||||||
|
)
|
||||||
|
if (
|
||||||
|
streamDimensions.streamWidth !== width ||
|
||||||
|
streamDimensions.streamHeight !== height
|
||||||
|
) {
|
||||||
|
engineCommandManager.handleResize({
|
||||||
|
streamWidth: width,
|
||||||
|
streamHeight: height,
|
||||||
|
})
|
||||||
|
setStreamDimensions({
|
||||||
|
streamWidth: width,
|
||||||
|
streamHeight: height,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, 500)
|
||||||
|
|
||||||
|
window.addEventListener('resize', handleResize)
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('resize', handleResize)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDimensions(streamWidth?: number, streamHeight?: number) {
|
||||||
|
const width = streamWidth ? streamWidth : 0
|
||||||
|
const quadWidth = Math.round(width / 4) * 4
|
||||||
|
const height = streamHeight ? streamHeight : 0
|
||||||
|
const quadHeight = Math.round(height / 4) * 4
|
||||||
|
return { width: quadWidth, height: quadHeight }
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ export function useConvertToVariable() {
|
|||||||
|
|
||||||
updateAst(_modifiedAst, true)
|
updateAst(_modifiedAst, true)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('e', e)
|
console.log('error', e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
import { parser_wasm } from './abstractSyntaxTree'
|
|
||||||
import { KCLError } from './errors'
|
import { KCLError } from './errors'
|
||||||
import { initPromise } from './rust'
|
import { initPromise, parse } from './wasm'
|
||||||
|
|
||||||
beforeAll(() => initPromise)
|
beforeAll(() => initPromise)
|
||||||
|
|
||||||
describe('testing AST', () => {
|
describe('testing AST', () => {
|
||||||
test('5 + 6', () => {
|
test('5 + 6', () => {
|
||||||
const result = parser_wasm('5 +6')
|
const result = parse('5 +6')
|
||||||
delete (result as any).nonCodeMeta
|
delete (result as any).nonCodeMeta
|
||||||
expect(result.body).toEqual([
|
expect(result.body).toEqual([
|
||||||
{
|
{
|
||||||
@ -37,7 +36,7 @@ describe('testing AST', () => {
|
|||||||
])
|
])
|
||||||
})
|
})
|
||||||
test('const myVar = 5', () => {
|
test('const myVar = 5', () => {
|
||||||
const { body } = parser_wasm('const myVar = 5')
|
const { body } = parse('const myVar = 5')
|
||||||
expect(body).toEqual([
|
expect(body).toEqual([
|
||||||
{
|
{
|
||||||
type: 'VariableDeclaration',
|
type: 'VariableDeclaration',
|
||||||
@ -71,7 +70,7 @@ describe('testing AST', () => {
|
|||||||
const code = `const myVar = 5
|
const code = `const myVar = 5
|
||||||
const newVar = myVar + 1
|
const newVar = myVar + 1
|
||||||
`
|
`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
expect(body).toEqual([
|
expect(body).toEqual([
|
||||||
{
|
{
|
||||||
type: 'VariableDeclaration',
|
type: 'VariableDeclaration',
|
||||||
@ -143,7 +142,7 @@ const newVar = myVar + 1
|
|||||||
|
|
||||||
describe('testing function declaration', () => {
|
describe('testing function declaration', () => {
|
||||||
test('fn funcN = () => {}', () => {
|
test('fn funcN = () => {}', () => {
|
||||||
const { body } = parser_wasm('fn funcN = () => {}')
|
const { body } = parse('fn funcN = () => {}')
|
||||||
delete (body[0] as any).declarations[0].init.body.nonCodeMeta
|
delete (body[0] as any).declarations[0].init.body.nonCodeMeta
|
||||||
expect(body).toEqual([
|
expect(body).toEqual([
|
||||||
{
|
{
|
||||||
@ -179,7 +178,7 @@ describe('testing function declaration', () => {
|
|||||||
])
|
])
|
||||||
})
|
})
|
||||||
test('fn funcN = (a, b) => {return a + b}', () => {
|
test('fn funcN = (a, b) => {return a + b}', () => {
|
||||||
const { body } = parser_wasm(
|
const { body } = parse(
|
||||||
['fn funcN = (a, b) => {', ' return a + b', '}'].join('\n')
|
['fn funcN = (a, b) => {', ' return a + b', '}'].join('\n')
|
||||||
)
|
)
|
||||||
delete (body[0] as any).declarations[0].init.body.nonCodeMeta
|
delete (body[0] as any).declarations[0].init.body.nonCodeMeta
|
||||||
@ -256,7 +255,7 @@ describe('testing function declaration', () => {
|
|||||||
test('call expression assignment', () => {
|
test('call expression assignment', () => {
|
||||||
const code = `fn funcN = (a, b) => { return a + b }
|
const code = `fn funcN = (a, b) => { return a + b }
|
||||||
const myVar = funcN(1, 2)`
|
const myVar = funcN(1, 2)`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
delete (body[0] as any).declarations[0].init.body.nonCodeMeta
|
delete (body[0] as any).declarations[0].init.body.nonCodeMeta
|
||||||
expect(body).toEqual([
|
expect(body).toEqual([
|
||||||
{
|
{
|
||||||
@ -388,7 +387,7 @@ describe('testing pipe operator special', () => {
|
|||||||
|> lineTo([1, 1], %)
|
|> lineTo([1, 1], %)
|
||||||
|> rx(45, %)
|
|> rx(45, %)
|
||||||
`
|
`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
delete (body[0] as any).declarations[0].init.nonCodeMeta
|
delete (body[0] as any).declarations[0].init.nonCodeMeta
|
||||||
expect(body).toEqual([
|
expect(body).toEqual([
|
||||||
{
|
{
|
||||||
@ -404,7 +403,7 @@ describe('testing pipe operator special', () => {
|
|||||||
id: { type: 'Identifier', start: 6, end: 14, name: 'mySketch' },
|
id: { type: 'Identifier', start: 6, end: 14, name: 'mySketch' },
|
||||||
init: {
|
init: {
|
||||||
type: 'PipeExpression',
|
type: 'PipeExpression',
|
||||||
start: 15,
|
start: 17,
|
||||||
end: 145,
|
end: 145,
|
||||||
body: [
|
body: [
|
||||||
{
|
{
|
||||||
@ -624,7 +623,7 @@ describe('testing pipe operator special', () => {
|
|||||||
})
|
})
|
||||||
test('pipe operator with binary expression', () => {
|
test('pipe operator with binary expression', () => {
|
||||||
let code = `const myVar = 5 + 6 |> myFunc(45, %)`
|
let code = `const myVar = 5 + 6 |> myFunc(45, %)`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
delete (body as any)[0].declarations[0].init.nonCodeMeta
|
delete (body as any)[0].declarations[0].init.nonCodeMeta
|
||||||
expect(body).toEqual([
|
expect(body).toEqual([
|
||||||
{
|
{
|
||||||
@ -645,7 +644,7 @@ describe('testing pipe operator special', () => {
|
|||||||
},
|
},
|
||||||
init: {
|
init: {
|
||||||
type: 'PipeExpression',
|
type: 'PipeExpression',
|
||||||
start: 12,
|
start: 14,
|
||||||
end: 36,
|
end: 36,
|
||||||
body: [
|
body: [
|
||||||
{
|
{
|
||||||
@ -706,7 +705,7 @@ describe('testing pipe operator special', () => {
|
|||||||
})
|
})
|
||||||
test('array expression', () => {
|
test('array expression', () => {
|
||||||
let code = `const yo = [1, '2', three, 4 + 5]`
|
let code = `const yo = [1, '2', three, 4 + 5]`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
expect(body).toEqual([
|
expect(body).toEqual([
|
||||||
{
|
{
|
||||||
type: 'VariableDeclaration',
|
type: 'VariableDeclaration',
|
||||||
@ -781,7 +780,7 @@ describe('testing pipe operator special', () => {
|
|||||||
'const three = 3',
|
'const three = 3',
|
||||||
"const yo = {aStr: 'str', anum: 2, identifier: three, binExp: 4 + 5}",
|
"const yo = {aStr: 'str', anum: 2, identifier: three, binExp: 4 + 5}",
|
||||||
].join('\n')
|
].join('\n')
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
expect(body).toEqual([
|
expect(body).toEqual([
|
||||||
{
|
{
|
||||||
type: 'VariableDeclaration',
|
type: 'VariableDeclaration',
|
||||||
@ -925,7 +924,7 @@ describe('testing pipe operator special', () => {
|
|||||||
const code = `const yo = {key: {
|
const code = `const yo = {key: {
|
||||||
key2: 'value'
|
key2: 'value'
|
||||||
}}`
|
}}`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
expect(body).toEqual([
|
expect(body).toEqual([
|
||||||
{
|
{
|
||||||
type: 'VariableDeclaration',
|
type: 'VariableDeclaration',
|
||||||
@ -993,7 +992,7 @@ describe('testing pipe operator special', () => {
|
|||||||
})
|
})
|
||||||
test('object expression with array ast', () => {
|
test('object expression with array ast', () => {
|
||||||
const code = `const yo = {key: [1, '2']}`
|
const code = `const yo = {key: [1, '2']}`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
expect(body).toEqual([
|
expect(body).toEqual([
|
||||||
{
|
{
|
||||||
type: 'VariableDeclaration',
|
type: 'VariableDeclaration',
|
||||||
@ -1057,7 +1056,7 @@ describe('testing pipe operator special', () => {
|
|||||||
})
|
})
|
||||||
test('object memberExpression simple', () => {
|
test('object memberExpression simple', () => {
|
||||||
const code = `const prop = yo.one.two`
|
const code = `const prop = yo.one.two`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
expect(body).toEqual([
|
expect(body).toEqual([
|
||||||
{
|
{
|
||||||
type: 'VariableDeclaration',
|
type: 'VariableDeclaration',
|
||||||
@ -1112,7 +1111,7 @@ describe('testing pipe operator special', () => {
|
|||||||
})
|
})
|
||||||
test('object memberExpression with square braces', () => {
|
test('object memberExpression with square braces', () => {
|
||||||
const code = `const prop = yo.one["two"]`
|
const code = `const prop = yo.one["two"]`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
expect(body).toEqual([
|
expect(body).toEqual([
|
||||||
{
|
{
|
||||||
type: 'VariableDeclaration',
|
type: 'VariableDeclaration',
|
||||||
@ -1168,7 +1167,7 @@ describe('testing pipe operator special', () => {
|
|||||||
})
|
})
|
||||||
test('object memberExpression with two square braces literal and identifier', () => {
|
test('object memberExpression with two square braces literal and identifier', () => {
|
||||||
const code = `const prop = yo["one"][two]`
|
const code = `const prop = yo["one"][two]`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
expect(body).toEqual([
|
expect(body).toEqual([
|
||||||
{
|
{
|
||||||
type: 'VariableDeclaration',
|
type: 'VariableDeclaration',
|
||||||
@ -1227,7 +1226,7 @@ describe('testing pipe operator special', () => {
|
|||||||
describe('nests binary expressions correctly', () => {
|
describe('nests binary expressions correctly', () => {
|
||||||
it('works with the simple case', () => {
|
it('works with the simple case', () => {
|
||||||
const code = `const yo = 1 + 2`
|
const code = `const yo = 1 + 2`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
expect(body[0]).toEqual({
|
expect(body[0]).toEqual({
|
||||||
type: 'VariableDeclaration',
|
type: 'VariableDeclaration',
|
||||||
start: 0,
|
start: 0,
|
||||||
@ -1271,7 +1270,7 @@ describe('nests binary expressions correctly', () => {
|
|||||||
it('should nest according to precedence with multiply first', () => {
|
it('should nest according to precedence with multiply first', () => {
|
||||||
// should be binExp { binExp { lit-1 * lit-2 } + lit}
|
// should be binExp { binExp { lit-1 * lit-2 } + lit}
|
||||||
const code = `const yo = 1 * 2 + 3`
|
const code = `const yo = 1 * 2 + 3`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
expect(body[0]).toEqual({
|
expect(body[0]).toEqual({
|
||||||
type: 'VariableDeclaration',
|
type: 'VariableDeclaration',
|
||||||
start: 0,
|
start: 0,
|
||||||
@ -1328,7 +1327,7 @@ describe('nests binary expressions correctly', () => {
|
|||||||
it('should nest according to precedence with sum first', () => {
|
it('should nest according to precedence with sum first', () => {
|
||||||
// should be binExp { lit-1 + binExp { lit-2 * lit-3 } }
|
// should be binExp { lit-1 + binExp { lit-2 * lit-3 } }
|
||||||
const code = `const yo = 1 + 2 * 3`
|
const code = `const yo = 1 + 2 * 3`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
expect(body[0]).toEqual({
|
expect(body[0]).toEqual({
|
||||||
type: 'VariableDeclaration',
|
type: 'VariableDeclaration',
|
||||||
start: 0,
|
start: 0,
|
||||||
@ -1384,7 +1383,7 @@ describe('nests binary expressions correctly', () => {
|
|||||||
})
|
})
|
||||||
it('should nest properly with two opperators of equal precedence', () => {
|
it('should nest properly with two opperators of equal precedence', () => {
|
||||||
const code = `const yo = 1 + 2 - 3`
|
const code = `const yo = 1 + 2 - 3`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
expect((body[0] as any).declarations[0].init).toEqual({
|
expect((body[0] as any).declarations[0].init).toEqual({
|
||||||
type: 'BinaryExpression',
|
type: 'BinaryExpression',
|
||||||
start: 11,
|
start: 11,
|
||||||
@ -1421,7 +1420,7 @@ describe('nests binary expressions correctly', () => {
|
|||||||
})
|
})
|
||||||
it('should nest properly with two opperators of equal (but higher) precedence', () => {
|
it('should nest properly with two opperators of equal (but higher) precedence', () => {
|
||||||
const code = `const yo = 1 * 2 / 3`
|
const code = `const yo = 1 * 2 / 3`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
expect((body[0] as any).declarations[0].init).toEqual({
|
expect((body[0] as any).declarations[0].init).toEqual({
|
||||||
type: 'BinaryExpression',
|
type: 'BinaryExpression',
|
||||||
start: 11,
|
start: 11,
|
||||||
@ -1458,7 +1457,7 @@ describe('nests binary expressions correctly', () => {
|
|||||||
})
|
})
|
||||||
it('should nest properly with longer example', () => {
|
it('should nest properly with longer example', () => {
|
||||||
const code = `const yo = 1 + 2 * (3 - 4) / 5 + 6`
|
const code = `const yo = 1 + 2 * (3 - 4) / 5 + 6`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
const init = (body[0] as any).declarations[0].init
|
const init = (body[0] as any).declarations[0].init
|
||||||
expect(init).toEqual({
|
expect(init).toEqual({
|
||||||
type: 'BinaryExpression',
|
type: 'BinaryExpression',
|
||||||
@ -1520,14 +1519,12 @@ const key = 'c'`
|
|||||||
value: 'this is a comment',
|
value: 'this is a comment',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
const { nonCodeMeta } = parser_wasm(code)
|
const { nonCodeMeta } = parse(code)
|
||||||
expect(nonCodeMeta.nonCodeNodes[0]).toEqual(nonCodeMetaInstance)
|
expect(nonCodeMeta.nonCodeNodes[0]).toEqual(nonCodeMetaInstance)
|
||||||
|
|
||||||
// extra whitespace won't change it's position (0) or value (NB the start end would have changed though)
|
// extra whitespace won't change it's position (0) or value (NB the start end would have changed though)
|
||||||
const codeWithExtraStartWhitespace = '\n\n\n' + code
|
const codeWithExtraStartWhitespace = '\n\n\n' + code
|
||||||
const { nonCodeMeta: nonCodeMeta2 } = parser_wasm(
|
const { nonCodeMeta: nonCodeMeta2 } = parse(codeWithExtraStartWhitespace)
|
||||||
codeWithExtraStartWhitespace
|
|
||||||
)
|
|
||||||
expect(nonCodeMeta2.nonCodeNodes[0].value).toStrictEqual(
|
expect(nonCodeMeta2.nonCodeNodes[0].value).toStrictEqual(
|
||||||
nonCodeMetaInstance.value
|
nonCodeMetaInstance.value
|
||||||
)
|
)
|
||||||
@ -1545,7 +1542,7 @@ const key = 'c'`
|
|||||||
|> close(%)
|
|> close(%)
|
||||||
`
|
`
|
||||||
|
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
const indexOfSecondLineToExpression = 2
|
const indexOfSecondLineToExpression = 2
|
||||||
const sketchNonCodeMeta = (body as any)[0].declarations[0].init.nonCodeMeta
|
const sketchNonCodeMeta = (body as any)[0].declarations[0].init.nonCodeMeta
|
||||||
.nonCodeNodes
|
.nonCodeNodes
|
||||||
@ -1569,7 +1566,7 @@ const key = 'c'`
|
|||||||
' |> rx(90, %)',
|
' |> rx(90, %)',
|
||||||
].join('\n')
|
].join('\n')
|
||||||
|
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
const sketchNonCodeMeta = (body[0] as any).declarations[0].init.nonCodeMeta
|
const sketchNonCodeMeta = (body[0] as any).declarations[0].init.nonCodeMeta
|
||||||
.nonCodeNodes
|
.nonCodeNodes
|
||||||
expect(sketchNonCodeMeta[3]).toEqual({
|
expect(sketchNonCodeMeta[3]).toEqual({
|
||||||
@ -1587,7 +1584,7 @@ const key = 'c'`
|
|||||||
describe('test UnaryExpression', () => {
|
describe('test UnaryExpression', () => {
|
||||||
it('should parse a unary expression in simple var dec situation', () => {
|
it('should parse a unary expression in simple var dec situation', () => {
|
||||||
const code = `const myVar = -min(4, 100)`
|
const code = `const myVar = -min(4, 100)`
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
const myVarInit = (body?.[0] as any).declarations[0]?.init
|
const myVarInit = (body?.[0] as any).declarations[0]?.init
|
||||||
expect(myVarInit).toEqual({
|
expect(myVarInit).toEqual({
|
||||||
type: 'UnaryExpression',
|
type: 'UnaryExpression',
|
||||||
@ -1613,7 +1610,7 @@ describe('test UnaryExpression', () => {
|
|||||||
describe('testing nested call expressions', () => {
|
describe('testing nested call expressions', () => {
|
||||||
it('callExp in a binExp in a callExp', () => {
|
it('callExp in a binExp in a callExp', () => {
|
||||||
const code = 'const myVar = min(100, 1 + legLen(5, 3))'
|
const code = 'const myVar = min(100, 1 + legLen(5, 3))'
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
const myVarInit = (body?.[0] as any).declarations[0]?.init
|
const myVarInit = (body?.[0] as any).declarations[0]?.init
|
||||||
expect(myVarInit).toEqual({
|
expect(myVarInit).toEqual({
|
||||||
type: 'CallExpression',
|
type: 'CallExpression',
|
||||||
@ -1651,7 +1648,7 @@ describe('testing nested call expressions', () => {
|
|||||||
describe('should recognise callExpresions in binaryExpressions', () => {
|
describe('should recognise callExpresions in binaryExpressions', () => {
|
||||||
const code = "xLineTo(segEndX('seg02', %) + 1, %)"
|
const code = "xLineTo(segEndX('seg02', %) + 1, %)"
|
||||||
it('should recognise the callExp', () => {
|
it('should recognise the callExp', () => {
|
||||||
const { body } = parser_wasm(code)
|
const { body } = parse(code)
|
||||||
const callExpArgs = (body?.[0] as any).expression?.arguments
|
const callExpArgs = (body?.[0] as any).expression?.arguments
|
||||||
expect(callExpArgs).toEqual([
|
expect(callExpArgs).toEqual([
|
||||||
{
|
{
|
||||||
@ -1690,8 +1687,7 @@ describe('parsing errors', () => {
|
|||||||
|
|
||||||
let _theError
|
let _theError
|
||||||
try {
|
try {
|
||||||
const result = expect(parser_wasm(code))
|
const result = expect(parse(code))
|
||||||
console.log('result', result)
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_theError = e
|
_theError = e
|
||||||
}
|
}
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
import { Program } from './abstractSyntaxTreeTypes'
|
|
||||||
import { parse_js } from '../wasm-lib/pkg/wasm_lib'
|
|
||||||
import { initPromise } from './rust'
|
|
||||||
import { Token } from './tokeniser'
|
|
||||||
import { KCLError } from './errors'
|
|
||||||
import { KclError as RustKclError } from '../wasm-lib/kcl/bindings/KclError'
|
|
||||||
|
|
||||||
export const rangeTypeFix = (ranges: number[][]): [number, number][] =>
|
|
||||||
ranges.map(([start, end]) => [start, end])
|
|
||||||
|
|
||||||
export const parser_wasm = (code: string): Program => {
|
|
||||||
try {
|
|
||||||
const program: Program = parse_js(code)
|
|
||||||
return program
|
|
||||||
} catch (e: any) {
|
|
||||||
const parsed: RustKclError = JSON.parse(e.toString())
|
|
||||||
const kclError = new KCLError(
|
|
||||||
parsed.kind,
|
|
||||||
parsed.msg,
|
|
||||||
rangeTypeFix(parsed.sourceRanges)
|
|
||||||
)
|
|
||||||
|
|
||||||
console.log(kclError)
|
|
||||||
throw kclError
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function asyncParser(code: string): Promise<Program> {
|
|
||||||
await initPromise
|
|
||||||
try {
|
|
||||||
const program: Program = parse_js(code)
|
|
||||||
return program
|
|
||||||
} catch (e: any) {
|
|
||||||
const parsed: RustKclError = JSON.parse(e.toString())
|
|
||||||
const kclError = new KCLError(
|
|
||||||
parsed.kind,
|
|
||||||
parsed.msg,
|
|
||||||
rangeTypeFix(parsed.sourceRanges)
|
|
||||||
)
|
|
||||||
|
|
||||||
console.log(kclError)
|
|
||||||
throw kclError
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function rangeOfToken(token: Token | undefined): [number, number][] {
|
|
||||||
return token === undefined ? [] : [[token.start, token.end]]
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
export type { Program } from '../wasm-lib/kcl/bindings/Program'
|
|
||||||
export type { Value } from '../wasm-lib/kcl/bindings/Value'
|
|
||||||
export type { ObjectExpression } from '../wasm-lib/kcl/bindings/ObjectExpression'
|
|
||||||
export type { MemberExpression } from '../wasm-lib/kcl/bindings/MemberExpression'
|
|
||||||
export type { PipeExpression } from '../wasm-lib/kcl/bindings/PipeExpression'
|
|
||||||
export type { VariableDeclaration } from '../wasm-lib/kcl/bindings/VariableDeclaration'
|
|
||||||
export type { PipeSubstitution } from '../wasm-lib/kcl/bindings/PipeSubstitution'
|
|
||||||
export type { Identifier } from '../wasm-lib/kcl/bindings/Identifier'
|
|
||||||
export type { UnaryExpression } from '../wasm-lib/kcl/bindings/UnaryExpression'
|
|
||||||
export type { BinaryExpression } from '../wasm-lib/kcl/bindings/BinaryExpression'
|
|
||||||
export type { ReturnStatement } from '../wasm-lib/kcl/bindings/ReturnStatement'
|
|
||||||
export type { ExpressionStatement } from '../wasm-lib/kcl/bindings/ExpressionStatement'
|
|
||||||
export type { CallExpression } from '../wasm-lib/kcl/bindings/CallExpression'
|
|
||||||
export type { VariableDeclarator } from '../wasm-lib/kcl/bindings/VariableDeclarator'
|
|
||||||
export type { BinaryPart } from '../wasm-lib/kcl/bindings/BinaryPart'
|
|
||||||
export type { Literal } from '../wasm-lib/kcl/bindings/Literal'
|
|
||||||
export type { ArrayExpression } from '../wasm-lib/kcl/bindings/ArrayExpression'
|
|
||||||
|
|
||||||
export type SyntaxType =
|
|
||||||
| 'Program'
|
|
||||||
| 'ExpressionStatement'
|
|
||||||
| 'BinaryExpression'
|
|
||||||
| 'CallExpression'
|
|
||||||
| 'Identifier'
|
|
||||||
| 'ReturnStatement'
|
|
||||||
| 'VariableDeclaration'
|
|
||||||
| 'VariableDeclarator'
|
|
||||||
| 'MemberExpression'
|
|
||||||
| 'ArrayExpression'
|
|
||||||
| 'ObjectExpression'
|
|
||||||
| 'ObjectProperty'
|
|
||||||
| 'FunctionExpression'
|
|
||||||
| 'PipeExpression'
|
|
||||||
| 'PipeSubstitution'
|
|
||||||
| 'Literal'
|
|
||||||
| 'NonCodeNode'
|
|
||||||
| 'UnaryExpression'
|
|
@ -1,5 +1,4 @@
|
|||||||
import { parser_wasm } from './abstractSyntaxTree'
|
import { parse, initPromise } from './wasm'
|
||||||
import { initPromise } from './rust'
|
|
||||||
import { enginelessExecutor } from '../lib/testHelpers'
|
import { enginelessExecutor } from '../lib/testHelpers'
|
||||||
|
|
||||||
beforeAll(() => initPromise)
|
beforeAll(() => initPromise)
|
||||||
@ -8,12 +7,13 @@ describe('testing artifacts', () => {
|
|||||||
// Enable rotations #152
|
// Enable rotations #152
|
||||||
test('sketch artifacts', async () => {
|
test('sketch artifacts', async () => {
|
||||||
const code = `
|
const code = `
|
||||||
const mySketch001 = startSketchAt([0, 0])
|
const mySketch001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> lineTo([-1.59, -1.54], %)
|
|> lineTo([-1.59, -1.54], %)
|
||||||
|> lineTo([0.46, -5.82], %)
|
|> lineTo([0.46, -5.82], %)
|
||||||
// |> rx(45, %)
|
// |> rx(45, %)
|
||||||
show(mySketch001)`
|
show(mySketch001)`
|
||||||
const programMemory = await enginelessExecutor(parser_wasm(code))
|
const programMemory = await enginelessExecutor(parse(code))
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const shown = programMemory?.return?.map(
|
const shown = programMemory?.return?.map(
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@ -28,7 +28,7 @@ show(mySketch001)`
|
|||||||
name: '',
|
name: '',
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [21, 42],
|
sourceRange: [46, 71],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
value: [
|
value: [
|
||||||
@ -38,7 +38,7 @@ show(mySketch001)`
|
|||||||
to: [-1.59, -1.54],
|
to: [-1.59, -1.54],
|
||||||
from: [0, 0],
|
from: [0, 0],
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [48, 73],
|
sourceRange: [77, 102],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -48,7 +48,7 @@ show(mySketch001)`
|
|||||||
from: [-1.59, -1.54],
|
from: [-1.59, -1.54],
|
||||||
name: '',
|
name: '',
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [79, 103],
|
sourceRange: [108, 132],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -56,20 +56,22 @@ show(mySketch001)`
|
|||||||
position: [0, 0, 0],
|
position: [0, 0, 0],
|
||||||
rotation: [0, 0, 0, 1],
|
rotation: [0, 0, 0, 1],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
__meta: [{ sourceRange: [21, 42] }],
|
planeId: expect.any(String),
|
||||||
|
__meta: [{ sourceRange: [46, 71] }],
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
test('extrude artifacts', async () => {
|
test('extrude artifacts', async () => {
|
||||||
// Enable rotations #152
|
// Enable rotations #152
|
||||||
const code = `
|
const code = `
|
||||||
const mySketch001 = startSketchAt([0, 0])
|
const mySketch001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> lineTo([-1.59, -1.54], %)
|
|> lineTo([-1.59, -1.54], %)
|
||||||
|> lineTo([0.46, -5.82], %)
|
|> lineTo([0.46, -5.82], %)
|
||||||
// |> rx(45, %)
|
// |> rx(45, %)
|
||||||
|> extrude(2, %)
|
|> extrude(2, %)
|
||||||
show(mySketch001)`
|
show(mySketch001)`
|
||||||
const programMemory = await enginelessExecutor(parser_wasm(code))
|
const programMemory = await enginelessExecutor(parse(code))
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const shown = programMemory?.return?.map(
|
const shown = programMemory?.return?.map(
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@ -83,7 +85,7 @@ show(mySketch001)`
|
|||||||
height: 2,
|
height: 2,
|
||||||
position: [0, 0, 0],
|
position: [0, 0, 0],
|
||||||
rotation: [0, 0, 0, 1],
|
rotation: [0, 0, 0, 1],
|
||||||
__meta: [{ sourceRange: [21, 42] }],
|
__meta: [{ sourceRange: [46, 71] }],
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
@ -91,7 +93,8 @@ show(mySketch001)`
|
|||||||
// Enable rotations #152
|
// Enable rotations #152
|
||||||
// TODO #153 in order for getExtrudeWallTransform to work we need to query the engine for the location of a face.
|
// TODO #153 in order for getExtrudeWallTransform to work we need to query the engine for the location of a face.
|
||||||
const code = `
|
const code = `
|
||||||
const sk1 = startSketchAt([0, 0])
|
const sk1 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> lineTo([-2.5, 0], %)
|
|> lineTo([-2.5, 0], %)
|
||||||
|> lineTo({ to: [0, 10], tag: "p" }, %)
|
|> lineTo({ to: [0, 10], tag: "p" }, %)
|
||||||
|> lineTo([2.5, 0], %)
|
|> lineTo([2.5, 0], %)
|
||||||
@ -100,7 +103,8 @@ const sk1 = startSketchAt([0, 0])
|
|||||||
// |> ry(5, %)
|
// |> ry(5, %)
|
||||||
const theExtrude = extrude(2, sk1)
|
const theExtrude = extrude(2, sk1)
|
||||||
// const theTransf = getExtrudeWallTransform('p', theExtrude)
|
// const theTransf = getExtrudeWallTransform('p', theExtrude)
|
||||||
const sk2 = startSketchAt([0, 0])
|
const sk2 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> lineTo([-2.5, 0], %)
|
|> lineTo([-2.5, 0], %)
|
||||||
|> lineTo({ to: [0, 3], tag: "p" }, %)
|
|> lineTo({ to: [0, 3], tag: "p" }, %)
|
||||||
|> lineTo([2.5, 0], %)
|
|> lineTo([2.5, 0], %)
|
||||||
@ -109,7 +113,7 @@ const sk2 = startSketchAt([0, 0])
|
|||||||
|
|
||||||
|
|
||||||
show(theExtrude, sk2)`
|
show(theExtrude, sk2)`
|
||||||
const programMemory = await enginelessExecutor(parser_wasm(code))
|
const programMemory = await enginelessExecutor(parse(code))
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const geos = programMemory?.return?.map(
|
const geos = programMemory?.return?.map(
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@ -123,7 +127,7 @@ show(theExtrude, sk2)`
|
|||||||
height: 2,
|
height: 2,
|
||||||
position: [0, 0, 0],
|
position: [0, 0, 0],
|
||||||
rotation: [0, 0, 0, 1],
|
rotation: [0, 0, 0, 1],
|
||||||
__meta: [{ sourceRange: [13, 34] }],
|
__meta: [{ sourceRange: [38, 63] }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'ExtrudeGroup',
|
type: 'ExtrudeGroup',
|
||||||
@ -132,7 +136,7 @@ show(theExtrude, sk2)`
|
|||||||
height: 2,
|
height: 2,
|
||||||
position: [0, 0, 0],
|
position: [0, 0, 0],
|
||||||
rotation: [0, 0, 0, 1],
|
rotation: [0, 0, 0, 1],
|
||||||
__meta: [{ sourceRange: [302, 323] }],
|
__meta: [{ sourceRange: [356, 381] }],
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
import fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
|
|
||||||
import { parser_wasm } from './abstractSyntaxTree'
|
import { parse, ProgramMemory, SketchGroup, initPromise } from './wasm'
|
||||||
import { ProgramMemory, SketchGroup } from './executor'
|
|
||||||
import { initPromise } from './rust'
|
|
||||||
import { enginelessExecutor } from '../lib/testHelpers'
|
import { enginelessExecutor } from '../lib/testHelpers'
|
||||||
import { vi } from 'vitest'
|
|
||||||
import { KCLError } from './errors'
|
import { KCLError } from './errors'
|
||||||
|
|
||||||
beforeAll(() => initPromise)
|
beforeAll(() => initPromise)
|
||||||
@ -44,7 +41,8 @@ const newVar = myVar + 1`
|
|||||||
expect(root.magicNum.value).toBe(69)
|
expect(root.magicNum.value).toBe(69)
|
||||||
})
|
})
|
||||||
it('sketch declaration', async () => {
|
it('sketch declaration', async () => {
|
||||||
let code = `const mySketch = startSketchAt([0,0])
|
let code = `const mySketch = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0,0], %)
|
||||||
|> lineTo({to: [0,2], tag: "myPath"}, %)
|
|> lineTo({to: [0,2], tag: "myPath"}, %)
|
||||||
|> lineTo([2,3], %)
|
|> lineTo([2,3], %)
|
||||||
|> lineTo({ to: [5,-1], tag: "rightPath" }, %)
|
|> lineTo({ to: [5,-1], tag: "rightPath" }, %)
|
||||||
@ -60,7 +58,7 @@ show(mySketch)
|
|||||||
to: [0, 2],
|
to: [0, 2],
|
||||||
from: [0, 0],
|
from: [0, 0],
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [43, 80],
|
sourceRange: [72, 109],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
name: 'myPath',
|
name: 'myPath',
|
||||||
@ -71,7 +69,7 @@ show(mySketch)
|
|||||||
from: [0, 2],
|
from: [0, 2],
|
||||||
name: '',
|
name: '',
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [86, 102],
|
sourceRange: [115, 131],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -80,7 +78,7 @@ show(mySketch)
|
|||||||
to: [5, -1],
|
to: [5, -1],
|
||||||
from: [2, 3],
|
from: [2, 3],
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [108, 151],
|
sourceRange: [137, 180],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
name: 'rightPath',
|
name: 'rightPath',
|
||||||
@ -90,8 +88,8 @@ show(mySketch)
|
|||||||
expect(_return).toEqual([
|
expect(_return).toEqual([
|
||||||
{
|
{
|
||||||
type: 'Identifier',
|
type: 'Identifier',
|
||||||
start: 174,
|
start: 203,
|
||||||
end: 182,
|
end: 211,
|
||||||
name: 'mySketch',
|
name: 'mySketch',
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
@ -135,7 +133,8 @@ show(mySketch)
|
|||||||
it('execute pipe sketch into call expression', async () => {
|
it('execute pipe sketch into call expression', async () => {
|
||||||
// Enable rotations #152
|
// Enable rotations #152
|
||||||
const code = [
|
const code = [
|
||||||
'const mySk1 = startSketchAt([0,0])',
|
"const mySk1 = startSketchOn('XY')",
|
||||||
|
' |> startProfileAt([0,0], %)',
|
||||||
' |> lineTo([1,1], %)',
|
' |> lineTo([1,1], %)',
|
||||||
' |> lineTo({to: [0, 1], tag: "myPath"}, %)',
|
' |> lineTo({to: [0, 1], tag: "myPath"}, %)',
|
||||||
' |> lineTo([1,1], %)',
|
' |> lineTo([1,1], %)',
|
||||||
@ -150,7 +149,7 @@ show(mySketch)
|
|||||||
name: '',
|
name: '',
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [14, 34],
|
sourceRange: [39, 63],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
value: [
|
value: [
|
||||||
@ -160,7 +159,7 @@ show(mySketch)
|
|||||||
from: [0, 0],
|
from: [0, 0],
|
||||||
name: '',
|
name: '',
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [40, 56],
|
sourceRange: [69, 85],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -169,7 +168,7 @@ show(mySketch)
|
|||||||
to: [0, 1],
|
to: [0, 1],
|
||||||
from: [1, 1],
|
from: [1, 1],
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [62, 100],
|
sourceRange: [91, 129],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
name: 'myPath',
|
name: 'myPath',
|
||||||
@ -180,7 +179,7 @@ show(mySketch)
|
|||||||
from: [0, 1],
|
from: [0, 1],
|
||||||
name: '',
|
name: '',
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [106, 122],
|
sourceRange: [135, 151],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -188,7 +187,8 @@ show(mySketch)
|
|||||||
position: [0, 0, 0],
|
position: [0, 0, 0],
|
||||||
rotation: [0, 0, 0, 1],
|
rotation: [0, 0, 0, 1],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
__meta: [{ sourceRange: [14, 34] }],
|
planeId: expect.any(String),
|
||||||
|
__meta: [{ sourceRange: [39, 63] }],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
it('execute array expression', async () => {
|
it('execute array expression', async () => {
|
||||||
@ -332,7 +332,8 @@ describe('testing math operators', () => {
|
|||||||
})
|
})
|
||||||
it('with unaryExpression in ArrayExpression in CallExpression, checking nothing funny happens when used in a sketch', async () => {
|
it('with unaryExpression in ArrayExpression in CallExpression, checking nothing funny happens when used in a sketch', async () => {
|
||||||
const code = [
|
const code = [
|
||||||
'const part001 = startSketchAt([0, 0])',
|
"const part001 = startSketchOn('XY')",
|
||||||
|
' |> startProfileAt([0, 0], %)',
|
||||||
'|> line([-2.21, -legLen(5, min(3, 999))], %)',
|
'|> line([-2.21, -legLen(5, min(3, 999))], %)',
|
||||||
].join('\n')
|
].join('\n')
|
||||||
const { root } = await exe(code)
|
const { root } = await exe(code)
|
||||||
@ -344,7 +345,8 @@ describe('testing math operators', () => {
|
|||||||
it('test that % substitution feeds down CallExp->ArrExp->UnaryExp->CallExp', async () => {
|
it('test that % substitution feeds down CallExp->ArrExp->UnaryExp->CallExp', async () => {
|
||||||
const code = [
|
const code = [
|
||||||
`const myVar = 3`,
|
`const myVar = 3`,
|
||||||
`const part001 = startSketchAt([0, 0])`,
|
`const part001 = startSketchOn('XY')`,
|
||||||
|
` |> startProfileAt([0, 0], %)`,
|
||||||
` |> line({ to: [3, 4], tag: 'seg01' }, %)`,
|
` |> line({ to: [3, 4], tag: 'seg01' }, %)`,
|
||||||
` |> line([`,
|
` |> line([`,
|
||||||
` min(segLen('seg01', %), myVar),`,
|
` min(segLen('seg01', %), myVar),`,
|
||||||
@ -380,7 +382,8 @@ describe('testing math operators', () => {
|
|||||||
describe('Testing Errors', () => {
|
describe('Testing Errors', () => {
|
||||||
it('should throw an error when a variable is not defined', async () => {
|
it('should throw an error when a variable is not defined', async () => {
|
||||||
const code = `const myVar = 5
|
const code = `const myVar = 5
|
||||||
const theExtrude = startSketchAt([0, 0])
|
const theExtrude = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> line([-2.4, 5], %)
|
|> line([-2.4, 5], %)
|
||||||
|> line([-0.76], myVarZ, %)
|
|> line([-0.76], myVarZ, %)
|
||||||
|> line([5,5], %)
|
|> line([5,5], %)
|
||||||
@ -391,7 +394,7 @@ show(theExtrude)`
|
|||||||
new KCLError(
|
new KCLError(
|
||||||
'undefined_value',
|
'undefined_value',
|
||||||
'memory item key `myVarZ` is not defined',
|
'memory item key `myVarZ` is not defined',
|
||||||
[[100, 106]]
|
[[129, 135]]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -403,7 +406,7 @@ async function exe(
|
|||||||
code: string,
|
code: string,
|
||||||
programMemory: ProgramMemory = { root: {}, return: null }
|
programMemory: ProgramMemory = { root: {}, return: null }
|
||||||
) {
|
) {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
|
|
||||||
const result = await enginelessExecutor(ast, programMemory)
|
const result = await enginelessExecutor(ast, programMemory)
|
||||||
return result
|
return result
|
||||||
|
@ -1,81 +0,0 @@
|
|||||||
import { Program } from './abstractSyntaxTreeTypes'
|
|
||||||
import {
|
|
||||||
EngineCommandManager,
|
|
||||||
ArtifactMap,
|
|
||||||
SourceRangeMap,
|
|
||||||
} from './std/engineConnection'
|
|
||||||
import { ProgramReturn } from '../wasm-lib/kcl/bindings/ProgramReturn'
|
|
||||||
import { MemoryItem } from '../wasm-lib/kcl/bindings/MemoryItem'
|
|
||||||
import { execute_wasm } from '../wasm-lib/pkg/wasm_lib'
|
|
||||||
import { KCLError } from './errors'
|
|
||||||
import { KclError as RustKclError } from '../wasm-lib/kcl/bindings/KclError'
|
|
||||||
import { rangeTypeFix } from './abstractSyntaxTree'
|
|
||||||
|
|
||||||
export type { SourceRange } from '../wasm-lib/kcl/bindings/SourceRange'
|
|
||||||
export type { Position } from '../wasm-lib/kcl/bindings/Position'
|
|
||||||
export type { Rotation } from '../wasm-lib/kcl/bindings/Rotation'
|
|
||||||
export type { Path } from '../wasm-lib/kcl/bindings/Path'
|
|
||||||
export type { SketchGroup } from '../wasm-lib/kcl/bindings/SketchGroup'
|
|
||||||
export type { MemoryItem } from '../wasm-lib/kcl/bindings/MemoryItem'
|
|
||||||
export type { ExtrudeSurface } from '../wasm-lib/kcl/bindings/ExtrudeSurface'
|
|
||||||
|
|
||||||
export type PathToNode = [string | number, string][]
|
|
||||||
|
|
||||||
interface Memory {
|
|
||||||
[key: string]: MemoryItem
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ProgramMemory {
|
|
||||||
root: Memory
|
|
||||||
return: ProgramReturn | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export const executor = async (
|
|
||||||
node: Program,
|
|
||||||
programMemory: ProgramMemory = { root: {}, return: null },
|
|
||||||
engineCommandManager: EngineCommandManager,
|
|
||||||
// work around while the gemotry is still be stored on the frontend
|
|
||||||
// will be removed when the stream UI is added.
|
|
||||||
tempMapCallback: (a: {
|
|
||||||
artifactMap: ArtifactMap
|
|
||||||
sourceRangeMap: SourceRangeMap
|
|
||||||
}) => void = () => {}
|
|
||||||
): Promise<ProgramMemory> => {
|
|
||||||
engineCommandManager.startNewSession()
|
|
||||||
const _programMemory = await _executor(
|
|
||||||
node,
|
|
||||||
programMemory,
|
|
||||||
engineCommandManager
|
|
||||||
)
|
|
||||||
const { artifactMap, sourceRangeMap } =
|
|
||||||
await engineCommandManager.waitForAllCommands(node, _programMemory)
|
|
||||||
tempMapCallback({ artifactMap, sourceRangeMap })
|
|
||||||
|
|
||||||
engineCommandManager.endSession()
|
|
||||||
return _programMemory
|
|
||||||
}
|
|
||||||
|
|
||||||
export const _executor = async (
|
|
||||||
node: Program,
|
|
||||||
programMemory: ProgramMemory = { root: {}, return: null },
|
|
||||||
engineCommandManager: EngineCommandManager
|
|
||||||
): Promise<ProgramMemory> => {
|
|
||||||
try {
|
|
||||||
const memory: ProgramMemory = await execute_wasm(
|
|
||||||
JSON.stringify(node),
|
|
||||||
JSON.stringify(programMemory),
|
|
||||||
engineCommandManager
|
|
||||||
)
|
|
||||||
return memory
|
|
||||||
} catch (e: any) {
|
|
||||||
const parsed: RustKclError = JSON.parse(e.toString())
|
|
||||||
const kclError = new KCLError(
|
|
||||||
parsed.kind,
|
|
||||||
parsed.msg,
|
|
||||||
rangeTypeFix(parsed.sourceRanges)
|
|
||||||
)
|
|
||||||
|
|
||||||
console.log(kclError)
|
|
||||||
throw kclError
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
import { getNodePathFromSourceRange, getNodeFromPath } from './queryAst'
|
import { getNodePathFromSourceRange, getNodeFromPath } from './queryAst'
|
||||||
import { parser_wasm } from './abstractSyntaxTree'
|
import { Identifier, parse, initPromise } from './wasm'
|
||||||
import { initPromise } from './rust'
|
|
||||||
|
|
||||||
beforeAll(() => initPromise)
|
beforeAll(() => initPromise)
|
||||||
|
|
||||||
@ -20,11 +19,88 @@ const sk3 = startSketchAt([0, 0])
|
|||||||
lineToSubstringIndex + subStr.length,
|
lineToSubstringIndex + subStr.length,
|
||||||
]
|
]
|
||||||
|
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const nodePath = getNodePathFromSourceRange(ast, sourceRange)
|
const nodePath = getNodePathFromSourceRange(ast, sourceRange)
|
||||||
const { node } = getNodeFromPath<any>(ast, nodePath)
|
const { node } = getNodeFromPath<any>(ast, nodePath)
|
||||||
|
|
||||||
expect([node.start, node.end]).toEqual(sourceRange)
|
expect([node.start, node.end]).toEqual(sourceRange)
|
||||||
expect(node.type).toBe('CallExpression')
|
expect(node.type).toBe('CallExpression')
|
||||||
})
|
})
|
||||||
|
it('gets path right for function definition params', () => {
|
||||||
|
const code = `fn cube = (pos, scale) => {
|
||||||
|
const sg = startSketchAt(pos)
|
||||||
|
|> line([0, scale], %)
|
||||||
|
|> line([scale, 0], %)
|
||||||
|
|> line([0, -scale], %)
|
||||||
|
|
||||||
|
return sg
|
||||||
|
}
|
||||||
|
|
||||||
|
const b1 = cube([0,0], 10)`
|
||||||
|
const subStr = 'pos, scale'
|
||||||
|
const subStrIndex = code.indexOf(subStr)
|
||||||
|
const sourceRange: [number, number] = [
|
||||||
|
subStrIndex,
|
||||||
|
subStrIndex + 'pos'.length,
|
||||||
|
]
|
||||||
|
|
||||||
|
const ast = parse(code)
|
||||||
|
const nodePath = getNodePathFromSourceRange(ast, sourceRange)
|
||||||
|
const node = getNodeFromPath<Identifier>(ast, nodePath).node
|
||||||
|
|
||||||
|
expect(nodePath).toEqual([
|
||||||
|
['body', ''],
|
||||||
|
[0, 'index'],
|
||||||
|
['declarations', 'VariableDeclaration'],
|
||||||
|
[0, 'index'],
|
||||||
|
['init', ''],
|
||||||
|
['params', 'FunctionExpression'],
|
||||||
|
[0, 'index'],
|
||||||
|
])
|
||||||
|
expect(node.type).toBe('Identifier')
|
||||||
|
expect(node.name).toBe('pos')
|
||||||
|
})
|
||||||
|
it('gets path right for deep within function definition body', () => {
|
||||||
|
const code = `fn cube = (pos, scale) => {
|
||||||
|
const sg = startSketchAt(pos)
|
||||||
|
|> line([0, scale], %)
|
||||||
|
|> line([scale, 0], %)
|
||||||
|
|> line([0, -scale], %)
|
||||||
|
|
||||||
|
return sg
|
||||||
|
}
|
||||||
|
|
||||||
|
const b1 = cube([0,0], 10)`
|
||||||
|
const subStr = 'scale, 0'
|
||||||
|
const subStrIndex = code.indexOf(subStr)
|
||||||
|
const sourceRange: [number, number] = [
|
||||||
|
subStrIndex,
|
||||||
|
subStrIndex + 'scale'.length,
|
||||||
|
]
|
||||||
|
|
||||||
|
const ast = parse(code)
|
||||||
|
const nodePath = getNodePathFromSourceRange(ast, sourceRange)
|
||||||
|
const node = getNodeFromPath<Identifier>(ast, nodePath).node
|
||||||
|
expect(nodePath).toEqual([
|
||||||
|
['body', ''],
|
||||||
|
[0, 'index'],
|
||||||
|
['declarations', 'VariableDeclaration'],
|
||||||
|
[0, 'index'],
|
||||||
|
['init', ''],
|
||||||
|
['body', 'FunctionExpression'],
|
||||||
|
['body', 'FunctionExpression'],
|
||||||
|
[0, 'index'],
|
||||||
|
['declarations', 'VariableDeclaration'],
|
||||||
|
[0, 'index'],
|
||||||
|
['init', ''],
|
||||||
|
['body', 'PipeExpression'],
|
||||||
|
[2, 'index'],
|
||||||
|
['arguments', 'CallExpression'],
|
||||||
|
[0, 'index'],
|
||||||
|
['elements', 'ArrayExpression'],
|
||||||
|
[0, 'index'],
|
||||||
|
])
|
||||||
|
expect(node.type).toBe('Identifier')
|
||||||
|
expect(node.name).toBe('scale')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { parser_wasm } from './abstractSyntaxTree'
|
import { parse, recast, initPromise } from './wasm'
|
||||||
import {
|
import {
|
||||||
createLiteral,
|
createLiteral,
|
||||||
createIdentifier,
|
createIdentifier,
|
||||||
@ -13,8 +13,6 @@ import {
|
|||||||
giveSketchFnCallTag,
|
giveSketchFnCallTag,
|
||||||
moveValueIntoNewVariable,
|
moveValueIntoNewVariable,
|
||||||
} from './modifyAst'
|
} from './modifyAst'
|
||||||
import { recast } from './recast'
|
|
||||||
import { initPromise } from './rust'
|
|
||||||
import { enginelessExecutor } from '../lib/testHelpers'
|
import { enginelessExecutor } from '../lib/testHelpers'
|
||||||
|
|
||||||
beforeAll(() => initPromise)
|
beforeAll(() => initPromise)
|
||||||
@ -111,8 +109,8 @@ describe('Testing addSketchTo', () => {
|
|||||||
'yz'
|
'yz'
|
||||||
)
|
)
|
||||||
const str = recast(result.modifiedAst)
|
const str = recast(result.modifiedAst)
|
||||||
expect(str).toBe(`const part001 = startSketchAt('default')
|
expect(str).toBe(`const part001 = startSketchOn('YZ')
|
||||||
|> ry(90, %)
|
|> startProfileAt('default', %)
|
||||||
|> line('default', %)
|
|> line('default', %)
|
||||||
show(part001)
|
show(part001)
|
||||||
`)
|
`)
|
||||||
@ -126,7 +124,7 @@ function giveSketchFnCallTagTestHelper(
|
|||||||
// giveSketchFnCallTag inputs and outputs an ast, which is very verbose for testing
|
// giveSketchFnCallTag inputs and outputs an ast, which is very verbose for testing
|
||||||
// this wrapper changes the input and output to code
|
// this wrapper changes the input and output to code
|
||||||
// making it more of an integration test, but easier to read the test intention is the goal
|
// making it more of an integration test, but easier to read the test intention is the goal
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const start = code.indexOf(searchStr)
|
const start = code.indexOf(searchStr)
|
||||||
const range: [number, number] = [start, start + searchStr.length]
|
const range: [number, number] = [start, start + searchStr.length]
|
||||||
const { modifiedAst, tag, isTagExisting } = giveSketchFnCallTag(ast, range)
|
const { modifiedAst, tag, isTagExisting } = giveSketchFnCallTag(ast, range)
|
||||||
@ -135,7 +133,8 @@ function giveSketchFnCallTagTestHelper(
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('Testing giveSketchFnCallTag', () => {
|
describe('Testing giveSketchFnCallTag', () => {
|
||||||
const code = `const part001 = startSketchAt([0, 0])
|
const code = `const part001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> line([-2.57, -0.13], %)
|
|> line([-2.57, -0.13], %)
|
||||||
|> line([0, 0.83], %)
|
|> line([0, 0.83], %)
|
||||||
|> line([0.82, 0.34], %)
|
|> line([0.82, 0.34], %)
|
||||||
@ -187,7 +186,8 @@ fn ghi = (x) => {
|
|||||||
const abc = 3
|
const abc = 3
|
||||||
const identifierGuy = 5
|
const identifierGuy = 5
|
||||||
const yo = 5 + 6
|
const yo = 5 + 6
|
||||||
const part001 = startSketchAt([-1.2, 4.83])
|
const part001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([-1.2, 4.83], %)
|
||||||
|> line([2.8, 0], %)
|
|> line([2.8, 0], %)
|
||||||
|> angledLine([100 + 100, 3.09], %)
|
|> angledLine([100 + 100, 3.09], %)
|
||||||
|> angledLine([abc, 3.09], %)
|
|> angledLine([abc, 3.09], %)
|
||||||
@ -197,7 +197,7 @@ const part001 = startSketchAt([-1.2, 4.83])
|
|||||||
const yo2 = hmm([identifierGuy + 5])
|
const yo2 = hmm([identifierGuy + 5])
|
||||||
show(part001)`
|
show(part001)`
|
||||||
it('should move a binary expression into a new variable', async () => {
|
it('should move a binary expression into a new variable', async () => {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
const startIndex = code.indexOf('100 + 100') + 1
|
const startIndex = code.indexOf('100 + 100') + 1
|
||||||
const { modifiedAst } = moveValueIntoNewVariable(
|
const { modifiedAst } = moveValueIntoNewVariable(
|
||||||
@ -211,7 +211,7 @@ show(part001)`
|
|||||||
expect(newCode).toContain(`angledLine([newVar, 3.09], %)`)
|
expect(newCode).toContain(`angledLine([newVar, 3.09], %)`)
|
||||||
})
|
})
|
||||||
it('should move a value into a new variable', async () => {
|
it('should move a value into a new variable', async () => {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
const startIndex = code.indexOf('2.8') + 1
|
const startIndex = code.indexOf('2.8') + 1
|
||||||
const { modifiedAst } = moveValueIntoNewVariable(
|
const { modifiedAst } = moveValueIntoNewVariable(
|
||||||
@ -225,7 +225,7 @@ show(part001)`
|
|||||||
expect(newCode).toContain(`line([newVar, 0], %)`)
|
expect(newCode).toContain(`line([newVar, 0], %)`)
|
||||||
})
|
})
|
||||||
it('should move a callExpression into a new variable', async () => {
|
it('should move a callExpression into a new variable', async () => {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
const startIndex = code.indexOf('def(')
|
const startIndex = code.indexOf('def(')
|
||||||
const { modifiedAst } = moveValueIntoNewVariable(
|
const { modifiedAst } = moveValueIntoNewVariable(
|
||||||
@ -239,7 +239,7 @@ show(part001)`
|
|||||||
expect(newCode).toContain(`angledLine([newVar, 3.09], %)`)
|
expect(newCode).toContain(`angledLine([newVar, 3.09], %)`)
|
||||||
})
|
})
|
||||||
it('should move a binary expression with call expression into a new variable', async () => {
|
it('should move a binary expression with call expression into a new variable', async () => {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
const startIndex = code.indexOf('jkl(') + 1
|
const startIndex = code.indexOf('jkl(') + 1
|
||||||
const { modifiedAst } = moveValueIntoNewVariable(
|
const { modifiedAst } = moveValueIntoNewVariable(
|
||||||
@ -253,7 +253,7 @@ show(part001)`
|
|||||||
expect(newCode).toContain(`angledLine([newVar, 3.09], %)`)
|
expect(newCode).toContain(`angledLine([newVar, 3.09], %)`)
|
||||||
})
|
})
|
||||||
it('should move a identifier into a new variable', async () => {
|
it('should move a identifier into a new variable', async () => {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
const startIndex = code.indexOf('identifierGuy +') + 1
|
const startIndex = code.indexOf('identifierGuy +') + 1
|
||||||
const { modifiedAst } = moveValueIntoNewVariable(
|
const { modifiedAst } = moveValueIntoNewVariable(
|
||||||
|
@ -14,14 +14,15 @@ import {
|
|||||||
ObjectExpression,
|
ObjectExpression,
|
||||||
UnaryExpression,
|
UnaryExpression,
|
||||||
BinaryExpression,
|
BinaryExpression,
|
||||||
} from './abstractSyntaxTreeTypes'
|
PathToNode,
|
||||||
|
ProgramMemory,
|
||||||
|
} from './wasm'
|
||||||
import {
|
import {
|
||||||
findAllPreviousVariables,
|
findAllPreviousVariables,
|
||||||
getNodeFromPath,
|
getNodeFromPath,
|
||||||
getNodePathFromSourceRange,
|
getNodePathFromSourceRange,
|
||||||
isNodeSafeToReplace,
|
isNodeSafeToReplace,
|
||||||
} from './queryAst'
|
} from './queryAst'
|
||||||
import { PathToNode, ProgramMemory } from './executor'
|
|
||||||
import {
|
import {
|
||||||
addTagForSketchOnFace,
|
addTagForSketchOnFace,
|
||||||
getFirstArg,
|
getFirstArg,
|
||||||
@ -31,21 +32,26 @@ import { isLiteralArrayOrStatic } from './std/sketchcombos'
|
|||||||
|
|
||||||
export function addStartSketch(
|
export function addStartSketch(
|
||||||
node: Program,
|
node: Program,
|
||||||
|
axis: 'xy' | 'xz' | 'yz' | '-xy' | '-xz' | '-yz',
|
||||||
start: [number, number],
|
start: [number, number],
|
||||||
end: [number, number]
|
end: [number, number]
|
||||||
): { modifiedAst: Program; id: string; pathToNode: PathToNode } {
|
): { modifiedAst: Program; id: string; pathToNode: PathToNode } {
|
||||||
const _node = { ...node }
|
const _node = { ...node }
|
||||||
const _name = findUniqueName(node, 'part')
|
const _name = findUniqueName(node, 'part')
|
||||||
|
|
||||||
const startSketchAt = createCallExpression('startSketchAt', [
|
const startSketchOn = createCallExpressionStdLib('startSketchOn', [
|
||||||
|
createLiteral(axis.toUpperCase()),
|
||||||
|
])
|
||||||
|
const startProfileAt = createCallExpressionStdLib('startProfileAt', [
|
||||||
createArrayExpression([createLiteral(start[0]), createLiteral(start[1])]),
|
createArrayExpression([createLiteral(start[0]), createLiteral(start[1])]),
|
||||||
|
createPipeSubstitution(),
|
||||||
])
|
])
|
||||||
const initialLineTo = createCallExpression('line', [
|
const initialLineTo = createCallExpression('line', [
|
||||||
createArrayExpression([createLiteral(end[0]), createLiteral(end[1])]),
|
createArrayExpression([createLiteral(end[0]), createLiteral(end[1])]),
|
||||||
createPipeSubstitution(),
|
createPipeSubstitution(),
|
||||||
])
|
])
|
||||||
|
|
||||||
const pipeBody = [startSketchAt, initialLineTo]
|
const pipeBody = [startSketchOn, startProfileAt, initialLineTo]
|
||||||
|
|
||||||
const variableDeclaration = createVariableDeclaration(
|
const variableDeclaration = createVariableDeclaration(
|
||||||
_name,
|
_name,
|
||||||
@ -78,11 +84,11 @@ export function addSketchTo(
|
|||||||
const _node = { ...node }
|
const _node = { ...node }
|
||||||
const _name = name || findUniqueName(node, 'part')
|
const _name = name || findUniqueName(node, 'part')
|
||||||
|
|
||||||
const startSketchAt = createCallExpressionStdLib('startSketchAt', [
|
const startSketchOn = createCallExpressionStdLib('startSketchOn', [
|
||||||
createLiteral('default'),
|
createLiteral(axis.toUpperCase()),
|
||||||
])
|
])
|
||||||
const rotate = createCallExpression(axis === 'xz' ? 'rx' : 'ry', [
|
const startProfileAt = createCallExpressionStdLib('startProfileAt', [
|
||||||
createLiteral(90),
|
createLiteral('default'),
|
||||||
createPipeSubstitution(),
|
createPipeSubstitution(),
|
||||||
])
|
])
|
||||||
const initialLineTo = createCallExpressionStdLib('line', [
|
const initialLineTo = createCallExpressionStdLib('line', [
|
||||||
@ -90,10 +96,7 @@ export function addSketchTo(
|
|||||||
createPipeSubstitution(),
|
createPipeSubstitution(),
|
||||||
])
|
])
|
||||||
|
|
||||||
const pipeBody =
|
const pipeBody = [startSketchOn, startProfileAt, initialLineTo]
|
||||||
axis !== 'xy'
|
|
||||||
? [startSketchAt, rotate, initialLineTo]
|
|
||||||
: [startSketchAt, initialLineTo]
|
|
||||||
|
|
||||||
const variableDeclaration = createVariableDeclaration(
|
const variableDeclaration = createVariableDeclaration(
|
||||||
_name,
|
_name,
|
||||||
@ -321,7 +324,7 @@ export function extrudeSketch(
|
|||||||
[0, 'index'],
|
[0, 'index'],
|
||||||
]
|
]
|
||||||
return {
|
return {
|
||||||
modifiedAst: addToShow(_node, name),
|
modifiedAst: node,
|
||||||
pathToNode: [...pathToNode.slice(0, -1), [showCallIndex, 'index']],
|
pathToNode: [...pathToNode.slice(0, -1), [showCallIndex, 'index']],
|
||||||
pathToExtrudeArg,
|
pathToExtrudeArg,
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
import { parser_wasm } from './abstractSyntaxTree'
|
import { parse, recast, initPromise } from './wasm'
|
||||||
import {
|
import {
|
||||||
findAllPreviousVariables,
|
findAllPreviousVariables,
|
||||||
isNodeSafeToReplace,
|
isNodeSafeToReplace,
|
||||||
isTypeInValue,
|
isTypeInValue,
|
||||||
getNodePathFromSourceRange,
|
getNodePathFromSourceRange,
|
||||||
} from './queryAst'
|
} from './queryAst'
|
||||||
import { initPromise } from './rust'
|
|
||||||
import { enginelessExecutor } from '../lib/testHelpers'
|
import { enginelessExecutor } from '../lib/testHelpers'
|
||||||
import {
|
import {
|
||||||
createArrayExpression,
|
createArrayExpression,
|
||||||
@ -13,7 +12,6 @@ import {
|
|||||||
createLiteral,
|
createLiteral,
|
||||||
createPipeSubstitution,
|
createPipeSubstitution,
|
||||||
} from './modifyAst'
|
} from './modifyAst'
|
||||||
import { recast } from './recast'
|
|
||||||
|
|
||||||
beforeAll(() => initPromise)
|
beforeAll(() => initPromise)
|
||||||
|
|
||||||
@ -28,7 +26,8 @@ const halfArmAngle = armAngle / 2
|
|||||||
const arrExpShouldNotBeIncluded = [1, 2, 3]
|
const arrExpShouldNotBeIncluded = [1, 2, 3]
|
||||||
const objExpShouldNotBeIncluded = { a: 1, b: 2, c: 3 }
|
const objExpShouldNotBeIncluded = { a: 1, b: 2, c: 3 }
|
||||||
|
|
||||||
const part001 = startSketchAt([0, 0])
|
const part001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> yLineTo(1, %)
|
|> yLineTo(1, %)
|
||||||
|> xLine(3.84, %) // selection-range-7ish-before-this
|
|> xLine(3.84, %) // selection-range-7ish-before-this
|
||||||
|
|
||||||
@ -36,7 +35,7 @@ const variableBelowShouldNotBeIncluded = 3
|
|||||||
|
|
||||||
show(part001)`
|
show(part001)`
|
||||||
const rangeStart = code.indexOf('// selection-range-7ish-before-this') - 7
|
const rangeStart = code.indexOf('// selection-range-7ish-before-this') - 7
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
|
|
||||||
const { variables, bodyPath, insertIndex } = findAllPreviousVariables(
|
const { variables, bodyPath, insertIndex } = findAllPreviousVariables(
|
||||||
@ -59,7 +58,8 @@ show(part001)`
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('testing argIsNotIdentifier', () => {
|
describe('testing argIsNotIdentifier', () => {
|
||||||
const code = `const part001 = startSketchAt([-1.2, 4.83])
|
const code = `const part001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([-1.2, 4.83], %)
|
||||||
|> line([2.8, 0], %)
|
|> line([2.8, 0], %)
|
||||||
|> angledLine([100 + 100, 3.09], %)
|
|> angledLine([100 + 100, 3.09], %)
|
||||||
|> angledLine([abc, 3.09], %)
|
|> angledLine([abc, 3.09], %)
|
||||||
@ -70,7 +70,7 @@ const yo = 5 + 6
|
|||||||
const yo2 = hmm([identifierGuy + 5])
|
const yo2 = hmm([identifierGuy + 5])
|
||||||
show(part001)`
|
show(part001)`
|
||||||
it('find a safe binaryExpression', () => {
|
it('find a safe binaryExpression', () => {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const rangeStart = code.indexOf('100 + 100') + 2
|
const rangeStart = code.indexOf('100 + 100') + 2
|
||||||
const result = isNodeSafeToReplace(ast, [rangeStart, rangeStart])
|
const result = isNodeSafeToReplace(ast, [rangeStart, rangeStart])
|
||||||
expect(result.isSafe).toBe(true)
|
expect(result.isSafe).toBe(true)
|
||||||
@ -84,7 +84,7 @@ show(part001)`
|
|||||||
expect(outCode).toContain(`angledLine([replaceName, 3.09], %)`)
|
expect(outCode).toContain(`angledLine([replaceName, 3.09], %)`)
|
||||||
})
|
})
|
||||||
it('find a safe Identifier', () => {
|
it('find a safe Identifier', () => {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const rangeStart = code.indexOf('abc')
|
const rangeStart = code.indexOf('abc')
|
||||||
const result = isNodeSafeToReplace(ast, [rangeStart, rangeStart])
|
const result = isNodeSafeToReplace(ast, [rangeStart, rangeStart])
|
||||||
expect(result.isSafe).toBe(true)
|
expect(result.isSafe).toBe(true)
|
||||||
@ -92,7 +92,7 @@ show(part001)`
|
|||||||
expect(code.slice(result.value.start, result.value.end)).toBe('abc')
|
expect(code.slice(result.value.start, result.value.end)).toBe('abc')
|
||||||
})
|
})
|
||||||
it('find a safe CallExpression', () => {
|
it('find a safe CallExpression', () => {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const rangeStart = code.indexOf('def')
|
const rangeStart = code.indexOf('def')
|
||||||
const result = isNodeSafeToReplace(ast, [rangeStart, rangeStart])
|
const result = isNodeSafeToReplace(ast, [rangeStart, rangeStart])
|
||||||
expect(result.isSafe).toBe(true)
|
expect(result.isSafe).toBe(true)
|
||||||
@ -106,7 +106,7 @@ show(part001)`
|
|||||||
expect(outCode).toContain(`angledLine([replaceName, 3.09], %)`)
|
expect(outCode).toContain(`angledLine([replaceName, 3.09], %)`)
|
||||||
})
|
})
|
||||||
it('find an UNsafe CallExpression, as it has a PipeSubstitution', () => {
|
it('find an UNsafe CallExpression, as it has a PipeSubstitution', () => {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const rangeStart = code.indexOf('ghi')
|
const rangeStart = code.indexOf('ghi')
|
||||||
const range: [number, number] = [rangeStart, rangeStart]
|
const range: [number, number] = [rangeStart, rangeStart]
|
||||||
const result = isNodeSafeToReplace(ast, range)
|
const result = isNodeSafeToReplace(ast, range)
|
||||||
@ -115,7 +115,7 @@ show(part001)`
|
|||||||
expect(code.slice(result.value.start, result.value.end)).toBe('ghi(%)')
|
expect(code.slice(result.value.start, result.value.end)).toBe('ghi(%)')
|
||||||
})
|
})
|
||||||
it('find an UNsafe Identifier, as it is a callee', () => {
|
it('find an UNsafe Identifier, as it is a callee', () => {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const rangeStart = code.indexOf('ine([2.8,')
|
const rangeStart = code.indexOf('ine([2.8,')
|
||||||
const result = isNodeSafeToReplace(ast, [rangeStart, rangeStart])
|
const result = isNodeSafeToReplace(ast, [rangeStart, rangeStart])
|
||||||
expect(result.isSafe).toBe(false)
|
expect(result.isSafe).toBe(false)
|
||||||
@ -125,7 +125,7 @@ show(part001)`
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
it("find a safe BinaryExpression that's assigned to a variable", () => {
|
it("find a safe BinaryExpression that's assigned to a variable", () => {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const rangeStart = code.indexOf('5 + 6') + 1
|
const rangeStart = code.indexOf('5 + 6') + 1
|
||||||
const result = isNodeSafeToReplace(ast, [rangeStart, rangeStart])
|
const result = isNodeSafeToReplace(ast, [rangeStart, rangeStart])
|
||||||
expect(result.isSafe).toBe(true)
|
expect(result.isSafe).toBe(true)
|
||||||
@ -139,7 +139,7 @@ show(part001)`
|
|||||||
expect(outCode).toContain(`const yo = replaceName`)
|
expect(outCode).toContain(`const yo = replaceName`)
|
||||||
})
|
})
|
||||||
it('find a safe BinaryExpression that has a CallExpression within', () => {
|
it('find a safe BinaryExpression that has a CallExpression within', () => {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const rangeStart = code.indexOf('jkl') + 1
|
const rangeStart = code.indexOf('jkl') + 1
|
||||||
const result = isNodeSafeToReplace(ast, [rangeStart, rangeStart])
|
const result = isNodeSafeToReplace(ast, [rangeStart, rangeStart])
|
||||||
expect(result.isSafe).toBe(true)
|
expect(result.isSafe).toBe(true)
|
||||||
@ -155,7 +155,7 @@ show(part001)`
|
|||||||
expect(outCode).toContain(`angledLine([replaceName, 3.09], %)`)
|
expect(outCode).toContain(`angledLine([replaceName, 3.09], %)`)
|
||||||
})
|
})
|
||||||
it('find a safe BinaryExpression within a CallExpression', () => {
|
it('find a safe BinaryExpression within a CallExpression', () => {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const rangeStart = code.indexOf('identifierGuy') + 1
|
const rangeStart = code.indexOf('identifierGuy') + 1
|
||||||
const result = isNodeSafeToReplace(ast, [rangeStart, rangeStart])
|
const result = isNodeSafeToReplace(ast, [rangeStart, rangeStart])
|
||||||
expect(result.isSafe).toBe(true)
|
expect(result.isSafe).toBe(true)
|
||||||
@ -196,14 +196,15 @@ show(part001)`
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('testing getNodePathFromSourceRange', () => {
|
describe('testing getNodePathFromSourceRange', () => {
|
||||||
const code = `const part001 = startSketchAt([0.39, -0.05])
|
const code = `const part001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0.39, -0.05], %)
|
||||||
|> line([0.94, 2.61], %)
|
|> line([0.94, 2.61], %)
|
||||||
|> line([-0.21, -1.4], %)
|
|> line([-0.21, -1.4], %)
|
||||||
show(part001)`
|
show(part001)`
|
||||||
it('finds the second line when cursor is put at the end', () => {
|
it('finds the second line when cursor is put at the end', () => {
|
||||||
const searchLn = `line([0.94, 2.61], %)`
|
const searchLn = `line([0.94, 2.61], %)`
|
||||||
const sourceIndex = code.indexOf(searchLn) + searchLn.length
|
const sourceIndex = code.indexOf(searchLn) + searchLn.length
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const result = getNodePathFromSourceRange(ast, [sourceIndex, sourceIndex])
|
const result = getNodePathFromSourceRange(ast, [sourceIndex, sourceIndex])
|
||||||
expect(result).toEqual([
|
expect(result).toEqual([
|
||||||
['body', ''],
|
['body', ''],
|
||||||
@ -212,13 +213,13 @@ show(part001)`
|
|||||||
[0, 'index'],
|
[0, 'index'],
|
||||||
['init', ''],
|
['init', ''],
|
||||||
['body', 'PipeExpression'],
|
['body', 'PipeExpression'],
|
||||||
[1, 'index'],
|
[2, 'index'],
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
it('finds the last line when cursor is put at the end', () => {
|
it('finds the last line when cursor is put at the end', () => {
|
||||||
const searchLn = `line([-0.21, -1.4], %)`
|
const searchLn = `line([-0.21, -1.4], %)`
|
||||||
const sourceIndex = code.indexOf(searchLn) + searchLn.length
|
const sourceIndex = code.indexOf(searchLn) + searchLn.length
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const result = getNodePathFromSourceRange(ast, [sourceIndex, sourceIndex])
|
const result = getNodePathFromSourceRange(ast, [sourceIndex, sourceIndex])
|
||||||
const expected = [
|
const expected = [
|
||||||
['body', ''],
|
['body', ''],
|
||||||
@ -227,7 +228,7 @@ show(part001)`
|
|||||||
[0, 'index'],
|
[0, 'index'],
|
||||||
['init', ''],
|
['init', ''],
|
||||||
['body', 'PipeExpression'],
|
['body', 'PipeExpression'],
|
||||||
[2, 'index'],
|
[3, 'index'],
|
||||||
]
|
]
|
||||||
expect(result).toEqual(expected)
|
expect(result).toEqual(expected)
|
||||||
// expect similar result for start of line
|
// expect similar result for start of line
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { PathToNode, ProgramMemory, SketchGroup, SourceRange } from './executor'
|
|
||||||
import { Selection, ToolTip } from '../useStore'
|
import { Selection, ToolTip } from '../useStore'
|
||||||
import {
|
import {
|
||||||
BinaryExpression,
|
BinaryExpression,
|
||||||
@ -10,7 +9,11 @@ import {
|
|||||||
VariableDeclaration,
|
VariableDeclaration,
|
||||||
ReturnStatement,
|
ReturnStatement,
|
||||||
ArrayExpression,
|
ArrayExpression,
|
||||||
} from './abstractSyntaxTreeTypes'
|
PathToNode,
|
||||||
|
ProgramMemory,
|
||||||
|
SketchGroup,
|
||||||
|
SourceRange,
|
||||||
|
} from './wasm'
|
||||||
import { createIdentifier, splitPathAtLastIndex } from './modifyAst'
|
import { createIdentifier, splitPathAtLastIndex } from './modifyAst'
|
||||||
import { getSketchSegmentFromSourceRange } from './std/sketchConstraints'
|
import { getSketchSegmentFromSourceRange } from './std/sketchConstraints'
|
||||||
import { getAngle } from '../lib/utils'
|
import { getAngle } from '../lib/utils'
|
||||||
@ -239,7 +242,29 @@ function moreNodePathFromSourceRange(
|
|||||||
}
|
}
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
console.error('not implemented')
|
if (_node.type === 'FunctionExpression' && isInRange) {
|
||||||
|
for (let i = 0; i < _node.params.length; i++) {
|
||||||
|
const param = _node.params[i]
|
||||||
|
if (param.start <= start && param.end >= end) {
|
||||||
|
path.push(['params', 'FunctionExpression'])
|
||||||
|
path.push([i, 'index'])
|
||||||
|
return moreNodePathFromSourceRange(param, sourceRange, path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_node.body.start <= start && _node.body.end >= end) {
|
||||||
|
path.push(['body', 'FunctionExpression'])
|
||||||
|
const fnBody = _node.body.body
|
||||||
|
for (let i = 0; i < fnBody.length; i++) {
|
||||||
|
const statement = fnBody[i]
|
||||||
|
if (statement.start <= start && statement.end >= end) {
|
||||||
|
path.push(['body', 'FunctionExpression'])
|
||||||
|
path.push([i, 'index'])
|
||||||
|
return moreNodePathFromSourceRange(statement, sourceRange, path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.error('not implemented: ' + node.type)
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import { recast } from './recast'
|
import { parse, Program, recast, initPromise } from './wasm'
|
||||||
import { parser_wasm } from './abstractSyntaxTree'
|
|
||||||
import { Program } from './abstractSyntaxTreeTypes'
|
|
||||||
import fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
import { initPromise } from './rust'
|
|
||||||
|
|
||||||
beforeAll(() => initPromise)
|
beforeAll(() => initPromise)
|
||||||
|
|
||||||
@ -366,6 +363,6 @@ describe('it recasts binary expression using brackets where needed', () => {
|
|||||||
// helpers
|
// helpers
|
||||||
|
|
||||||
function code2ast(code: string): { ast: Program } {
|
function code2ast(code: string): { ast: Program } {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
return { ast }
|
return { ast }
|
||||||
}
|
}
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
import { Program } from './abstractSyntaxTreeTypes'
|
|
||||||
import { recast_wasm } from '../wasm-lib/pkg/wasm_lib'
|
|
||||||
|
|
||||||
export const recast = (ast: Program): string => {
|
|
||||||
try {
|
|
||||||
const s: string = recast_wasm(JSON.stringify(ast))
|
|
||||||
return s
|
|
||||||
} catch (e) {
|
|
||||||
// TODO: do something real with the error.
|
|
||||||
console.log('recast', e)
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
import init from '../wasm-lib/pkg/wasm_lib'
|
|
||||||
|
|
||||||
const initialise = async () => {
|
|
||||||
const baseUrl =
|
|
||||||
typeof window === 'undefined'
|
|
||||||
? 'http://127.0.0.1:3000'
|
|
||||||
: window.location.origin.includes('tauri://localhost')
|
|
||||||
? 'tauri://localhost'
|
|
||||||
: window.location.origin.includes('localhost')
|
|
||||||
? 'http://localhost:3000'
|
|
||||||
: window.location.origin && window.location.origin !== 'null'
|
|
||||||
? window.location.origin
|
|
||||||
: 'http://localhost:3000'
|
|
||||||
const fullUrl = baseUrl + '/wasm_lib_bg.wasm'
|
|
||||||
const input = await fetch(fullUrl)
|
|
||||||
const buffer = await input.arrayBuffer()
|
|
||||||
return init(buffer)
|
|
||||||
}
|
|
||||||
|
|
||||||
export const initPromise = initialise()
|
|
@ -1,4 +1,9 @@
|
|||||||
import { ProgramMemory, SourceRange } from 'lang/executor'
|
import {
|
||||||
|
ProgramMemory,
|
||||||
|
SourceRange,
|
||||||
|
Program,
|
||||||
|
VariableDeclarator,
|
||||||
|
} from 'lang/wasm'
|
||||||
import { Selections } from 'useStore'
|
import { Selections } from 'useStore'
|
||||||
import { VITE_KC_API_WS_MODELING_URL, VITE_KC_CONNECTION_TIMEOUT_MS } from 'env'
|
import { VITE_KC_API_WS_MODELING_URL, VITE_KC_CONNECTION_TIMEOUT_MS } from 'env'
|
||||||
import { Models } from '@kittycad/lib'
|
import { Models } from '@kittycad/lib'
|
||||||
@ -6,7 +11,6 @@ import { exportSave } from 'lib/exportSave'
|
|||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import * as Sentry from '@sentry/react'
|
import * as Sentry from '@sentry/react'
|
||||||
import { getNodeFromPath, getNodePathFromSourceRange } from 'lang/queryAst'
|
import { getNodeFromPath, getNodePathFromSourceRange } from 'lang/queryAst'
|
||||||
import { Program, VariableDeclarator } from 'lang/abstractSyntaxTreeTypes'
|
|
||||||
|
|
||||||
let lastMessage = ''
|
let lastMessage = ''
|
||||||
|
|
||||||
@ -23,6 +27,10 @@ interface ResultCommand extends CommandInfo {
|
|||||||
data: any
|
data: any
|
||||||
raw: WebSocketResponse
|
raw: WebSocketResponse
|
||||||
}
|
}
|
||||||
|
interface FailedCommand extends CommandInfo {
|
||||||
|
type: 'failed'
|
||||||
|
errors: Models['FailureWebSocketResponse_type']['errors']
|
||||||
|
}
|
||||||
interface PendingCommand extends CommandInfo {
|
interface PendingCommand extends CommandInfo {
|
||||||
type: 'pending'
|
type: 'pending'
|
||||||
promise: Promise<any>
|
promise: Promise<any>
|
||||||
@ -30,7 +38,7 @@ interface PendingCommand extends CommandInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ArtifactMap {
|
export interface ArtifactMap {
|
||||||
[key: string]: ResultCommand | PendingCommand
|
[key: string]: ResultCommand | PendingCommand | FailedCommand
|
||||||
}
|
}
|
||||||
export interface SourceRangeMap {
|
export interface SourceRangeMap {
|
||||||
[key: string]: SourceRange
|
[key: string]: SourceRange
|
||||||
@ -41,6 +49,11 @@ interface NewTrackArgs {
|
|||||||
mediaStream: MediaStream
|
mediaStream: MediaStream
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This looks funny, I know. This is needed because node and the browser
|
||||||
|
// disagree as to the type. In a browser it's a number, but in node it's a
|
||||||
|
// "Timeout".
|
||||||
|
type Timeout = ReturnType<typeof setTimeout>
|
||||||
|
|
||||||
type ClientMetrics = Models['ClientMetrics_type']
|
type ClientMetrics = Models['ClientMetrics_type']
|
||||||
|
|
||||||
// EngineConnection encapsulates the connection(s) to the Engine
|
// EngineConnection encapsulates the connection(s) to the Engine
|
||||||
@ -52,6 +65,9 @@ export class EngineConnection {
|
|||||||
unreliableDataChannel?: RTCDataChannel
|
unreliableDataChannel?: RTCDataChannel
|
||||||
|
|
||||||
private ready: boolean
|
private ready: boolean
|
||||||
|
private connecting: boolean
|
||||||
|
private dead: boolean
|
||||||
|
private failedConnTimeout: Timeout | null
|
||||||
|
|
||||||
readonly url: string
|
readonly url: string
|
||||||
private readonly token?: string
|
private readonly token?: string
|
||||||
@ -87,6 +103,9 @@ export class EngineConnection {
|
|||||||
this.url = url
|
this.url = url
|
||||||
this.token = token
|
this.token = token
|
||||||
this.ready = false
|
this.ready = false
|
||||||
|
this.connecting = false
|
||||||
|
this.dead = false
|
||||||
|
this.failedConnTimeout = null
|
||||||
this.onWebsocketOpen = onWebsocketOpen
|
this.onWebsocketOpen = onWebsocketOpen
|
||||||
this.onDataChannelOpen = onDataChannelOpen
|
this.onDataChannelOpen = onDataChannelOpen
|
||||||
this.onEngineConnectionOpen = onEngineConnectionOpen
|
this.onEngineConnectionOpen = onEngineConnectionOpen
|
||||||
@ -97,7 +116,10 @@ export class EngineConnection {
|
|||||||
// TODO(paultag): This ought to be tweakable.
|
// TODO(paultag): This ought to be tweakable.
|
||||||
const pingIntervalMs = 10000
|
const pingIntervalMs = 10000
|
||||||
|
|
||||||
setInterval(() => {
|
let pingInterval = setInterval(() => {
|
||||||
|
if (this.dead) {
|
||||||
|
clearInterval(pingInterval)
|
||||||
|
}
|
||||||
if (this.isReady()) {
|
if (this.isReady()) {
|
||||||
// When we're online, every 10 seconds, we'll attempt to put a 'ping'
|
// When we're online, every 10 seconds, we'll attempt to put a 'ping'
|
||||||
// command through the WebSocket connection. This will help both ends
|
// command through the WebSocket connection. This will help both ends
|
||||||
@ -106,6 +128,24 @@ export class EngineConnection {
|
|||||||
this.send({ type: 'ping' })
|
this.send({ type: 'ping' })
|
||||||
}
|
}
|
||||||
}, pingIntervalMs)
|
}, pingIntervalMs)
|
||||||
|
|
||||||
|
const connectionTimeoutMs = VITE_KC_CONNECTION_TIMEOUT_MS
|
||||||
|
let connectInterval = setInterval(() => {
|
||||||
|
if (this.dead) {
|
||||||
|
clearInterval(connectInterval)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.isReady()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
console.log('connecting via retry')
|
||||||
|
this.connect()
|
||||||
|
}, connectionTimeoutMs)
|
||||||
|
}
|
||||||
|
// isConnecting will return true when connect has been called, but the full
|
||||||
|
// WebRTC is not online.
|
||||||
|
isConnecting() {
|
||||||
|
return this.connecting
|
||||||
}
|
}
|
||||||
// isReady will return true only when the WebRTC *and* WebSocket connection
|
// isReady will return true only when the WebRTC *and* WebSocket connection
|
||||||
// are connected. During setup, the WebSocket connection comes online first,
|
// are connected. During setup, the WebSocket connection comes online first,
|
||||||
@ -114,6 +154,10 @@ export class EngineConnection {
|
|||||||
isReady() {
|
isReady() {
|
||||||
return this.ready
|
return this.ready
|
||||||
}
|
}
|
||||||
|
tearDown() {
|
||||||
|
this.dead = true
|
||||||
|
this.close()
|
||||||
|
}
|
||||||
// shouldTrace will return true when Sentry should be used to instrument
|
// shouldTrace will return true when Sentry should be used to instrument
|
||||||
// the Engine.
|
// the Engine.
|
||||||
shouldTrace() {
|
shouldTrace() {
|
||||||
@ -125,8 +169,10 @@ export class EngineConnection {
|
|||||||
// This will attempt the full handshake, and retry if the connection
|
// This will attempt the full handshake, and retry if the connection
|
||||||
// did not establish.
|
// did not establish.
|
||||||
connect() {
|
connect() {
|
||||||
// TODO(paultag): make this safe to call multiple times, and figure out
|
console.log('connect was called')
|
||||||
// when a connection is in progress (state: connecting or something).
|
if (this.isConnecting() || this.isReady()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Information on the connect transaction
|
// Information on the connect transaction
|
||||||
|
|
||||||
@ -314,6 +360,11 @@ export class EngineConnection {
|
|||||||
if (this.shouldTrace()) {
|
if (this.shouldTrace()) {
|
||||||
iceSpan.resolve?.()
|
iceSpan.resolve?.()
|
||||||
}
|
}
|
||||||
|
} else if (this.pc?.iceConnectionState === 'failed') {
|
||||||
|
// failed is a terminal state; let's explicitly kill the
|
||||||
|
// connection to the server at this point.
|
||||||
|
console.log('failed to negotiate ice connection; restarting')
|
||||||
|
this.close()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -358,20 +409,6 @@ export class EngineConnection {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(paultag): This ought to be both controllable, as well as something
|
|
||||||
// like exponential backoff to have some grace on the backend, as well as
|
|
||||||
// fix responsiveness for clients that had a weird network hiccup.
|
|
||||||
const connectionTimeoutMs = VITE_KC_CONNECTION_TIMEOUT_MS
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
if (this.isReady()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.log('engine connection timeout on connection, retrying')
|
|
||||||
this.close()
|
|
||||||
this.connect()
|
|
||||||
}, connectionTimeoutMs)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
this.pc.addEventListener('track', (event) => {
|
this.pc.addEventListener('track', (event) => {
|
||||||
@ -459,8 +496,11 @@ export class EngineConnection {
|
|||||||
|
|
||||||
this.onDataChannelOpen(this)
|
this.onDataChannelOpen(this)
|
||||||
|
|
||||||
this.onEngineConnectionOpen(this)
|
|
||||||
this.ready = true
|
this.ready = true
|
||||||
|
this.connecting = false
|
||||||
|
// Do this after we set the connection is ready to avoid errors when
|
||||||
|
// we try to send messages before the connection is ready.
|
||||||
|
this.onEngineConnectionOpen(this)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.unreliableDataChannel.addEventListener('close', (event) => {
|
this.unreliableDataChannel.addEventListener('close', (event) => {
|
||||||
@ -474,6 +514,22 @@ export class EngineConnection {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const connectionTimeoutMs = VITE_KC_CONNECTION_TIMEOUT_MS
|
||||||
|
|
||||||
|
if (this.failedConnTimeout) {
|
||||||
|
console.log('clearing timeout before set')
|
||||||
|
clearTimeout(this.failedConnTimeout)
|
||||||
|
this.failedConnTimeout = null
|
||||||
|
}
|
||||||
|
console.log('timeout set')
|
||||||
|
this.failedConnTimeout = setTimeout(() => {
|
||||||
|
if (this.isReady()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
console.log('engine connection timeout on connection, closing')
|
||||||
|
this.close()
|
||||||
|
}, connectionTimeoutMs)
|
||||||
|
|
||||||
this.onConnectionStarted(this)
|
this.onConnectionStarted(this)
|
||||||
}
|
}
|
||||||
unreliableSend(message: object | string) {
|
unreliableSend(message: object | string) {
|
||||||
@ -498,9 +554,15 @@ export class EngineConnection {
|
|||||||
this.pc = undefined
|
this.pc = undefined
|
||||||
this.unreliableDataChannel = undefined
|
this.unreliableDataChannel = undefined
|
||||||
this.webrtcStatsCollector = undefined
|
this.webrtcStatsCollector = undefined
|
||||||
|
if (this.failedConnTimeout) {
|
||||||
|
console.log('closed timeout in close')
|
||||||
|
clearTimeout(this.failedConnTimeout)
|
||||||
|
this.failedConnTimeout = null
|
||||||
|
}
|
||||||
|
|
||||||
this.onClose(this)
|
this.onClose(this)
|
||||||
this.ready = false
|
this.ready = false
|
||||||
|
this.connecting = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,6 +593,9 @@ export class EngineCommandManager {
|
|||||||
outSequence = 1
|
outSequence = 1
|
||||||
inSequence = 1
|
inSequence = 1
|
||||||
engineConnection?: EngineConnection
|
engineConnection?: EngineConnection
|
||||||
|
// Folks should realize that wait for ready does not get called _everytime_
|
||||||
|
// the connection resets and restarts, it only gets called the first time.
|
||||||
|
// Be careful what you put here.
|
||||||
waitForReady: Promise<void> = new Promise(() => {})
|
waitForReady: Promise<void> = new Promise(() => {})
|
||||||
private resolveReady = () => {}
|
private resolveReady = () => {}
|
||||||
|
|
||||||
@ -544,19 +609,36 @@ export class EngineCommandManager {
|
|||||||
[localUnsubscribeId: string]: (a: any) => void
|
[localUnsubscribeId: string]: (a: any) => void
|
||||||
}
|
}
|
||||||
} = {} as any
|
} = {} as any
|
||||||
constructor({
|
|
||||||
|
constructor() {
|
||||||
|
this.engineConnection = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
start({
|
||||||
setMediaStream,
|
setMediaStream,
|
||||||
setIsStreamReady,
|
setIsStreamReady,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
|
executeCode,
|
||||||
token,
|
token,
|
||||||
}: {
|
}: {
|
||||||
setMediaStream: (stream: MediaStream) => void
|
setMediaStream: (stream: MediaStream) => void
|
||||||
setIsStreamReady: (isStreamReady: boolean) => void
|
setIsStreamReady: (isStreamReady: boolean) => void
|
||||||
width: number
|
width: number
|
||||||
height: number
|
height: number
|
||||||
|
executeCode: (code?: string, force?: boolean) => void
|
||||||
token?: string
|
token?: string
|
||||||
}) {
|
}) {
|
||||||
|
if (width === 0 || height === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we already have an engine connection, just need to resize the stream.
|
||||||
|
if (this.engineConnection) {
|
||||||
|
this.handleResize({ streamWidth: width, streamHeight: height })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.waitForReady = new Promise((resolve) => {
|
this.waitForReady = new Promise((resolve) => {
|
||||||
this.resolveReady = resolve
|
this.resolveReady = resolve
|
||||||
})
|
})
|
||||||
@ -567,6 +649,32 @@ export class EngineCommandManager {
|
|||||||
onEngineConnectionOpen: () => {
|
onEngineConnectionOpen: () => {
|
||||||
this.resolveReady()
|
this.resolveReady()
|
||||||
setIsStreamReady(true)
|
setIsStreamReady(true)
|
||||||
|
|
||||||
|
// Make the axis gizmo.
|
||||||
|
// We do this after the connection opened to avoid a race condition.
|
||||||
|
// Connected opened is the last thing that happens when the stream
|
||||||
|
// is ready.
|
||||||
|
// We also do this here because we want to ensure we create the gizmo
|
||||||
|
// and execute the code everytime the stream is restarted.
|
||||||
|
const gizmoId = uuidv4()
|
||||||
|
this.sendSceneCommand({
|
||||||
|
type: 'modeling_cmd_req',
|
||||||
|
cmd_id: gizmoId,
|
||||||
|
cmd: {
|
||||||
|
type: 'make_axes_gizmo',
|
||||||
|
clobber: false,
|
||||||
|
// If true, axes gizmo will be placed in the corner of the screen.
|
||||||
|
// If false, it will be placed at the origin of the scene.
|
||||||
|
gizmo_mode: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
// We execute the code here to make sure if the stream was to
|
||||||
|
// restart in a session, we want to make sure to execute the code.
|
||||||
|
// We force it to re-execute the code because we want to make sure
|
||||||
|
// the code is executed everytime the stream is restarted.
|
||||||
|
// We pass undefined for the code so it reads from the current state.
|
||||||
|
executeCode(undefined, true)
|
||||||
},
|
},
|
||||||
onClose: () => {
|
onClose: () => {
|
||||||
setIsStreamReady(false)
|
setIsStreamReady(false)
|
||||||
@ -617,6 +725,12 @@ export class EngineCommandManager {
|
|||||||
message.request_id
|
message.request_id
|
||||||
) {
|
) {
|
||||||
this.handleModelingCommand(message.resp, message.request_id)
|
this.handleModelingCommand(message.resp, message.request_id)
|
||||||
|
} else if (
|
||||||
|
!message.success &&
|
||||||
|
message.request_id &&
|
||||||
|
this.artifactMap[message.request_id]
|
||||||
|
) {
|
||||||
|
this.handleFailedModelingCommand(message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -636,6 +750,30 @@ export class EngineCommandManager {
|
|||||||
|
|
||||||
this.engineConnection?.connect()
|
this.engineConnection?.connect()
|
||||||
}
|
}
|
||||||
|
handleResize({
|
||||||
|
streamWidth,
|
||||||
|
streamHeight,
|
||||||
|
}: {
|
||||||
|
streamWidth: number
|
||||||
|
streamHeight: number
|
||||||
|
}) {
|
||||||
|
console.log('handleResize', streamWidth, streamHeight)
|
||||||
|
if (!this.engineConnection?.isReady()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const resizeCmd: EngineCommand = {
|
||||||
|
type: 'modeling_cmd_req',
|
||||||
|
cmd_id: uuidv4(),
|
||||||
|
cmd: {
|
||||||
|
type: 'reconfigure_stream',
|
||||||
|
width: streamWidth,
|
||||||
|
height: streamHeight,
|
||||||
|
fps: 60,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
this.engineConnection?.send(resizeCmd)
|
||||||
|
}
|
||||||
handleModelingCommand(message: WebSocketResponse, id: string) {
|
handleModelingCommand(message: WebSocketResponse, id: string) {
|
||||||
if (message.type !== 'modeling') {
|
if (message.type !== 'modeling') {
|
||||||
return
|
return
|
||||||
@ -673,8 +811,40 @@ export class EngineCommandManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
handleFailedModelingCommand({
|
||||||
|
request_id,
|
||||||
|
errors,
|
||||||
|
}: Models['FailureWebSocketResponse_type']) {
|
||||||
|
const id = request_id
|
||||||
|
if (!id) return
|
||||||
|
const command = this.artifactMap[id]
|
||||||
|
if (command && command.type === 'pending') {
|
||||||
|
const resolve = command.resolve
|
||||||
|
this.artifactMap[id] = {
|
||||||
|
type: 'failed',
|
||||||
|
range: command.range,
|
||||||
|
commandType: command.commandType,
|
||||||
|
parentId: command.parentId ? command.parentId : undefined,
|
||||||
|
errors,
|
||||||
|
}
|
||||||
|
resolve({
|
||||||
|
id,
|
||||||
|
commandType: command.commandType,
|
||||||
|
range: command.range,
|
||||||
|
errors,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.artifactMap[id] = {
|
||||||
|
type: 'failed',
|
||||||
|
range: command.range,
|
||||||
|
commandType: command.commandType,
|
||||||
|
parentId: command.parentId ? command.parentId : undefined,
|
||||||
|
errors,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
tearDown() {
|
tearDown() {
|
||||||
this.engineConnection?.close()
|
this.engineConnection?.tearDown()
|
||||||
}
|
}
|
||||||
startNewSession() {
|
startNewSession() {
|
||||||
this.artifactMap = {}
|
this.artifactMap = {}
|
||||||
@ -769,6 +939,14 @@ export class EngineCommandManager {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
sendSceneCommand(command: EngineCommand): Promise<any> {
|
sendSceneCommand(command: EngineCommand): Promise<any> {
|
||||||
|
if (this.engineConnection === undefined) {
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.engineConnection?.isReady()) {
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
command.type === 'modeling_cmd_req' &&
|
command.type === 'modeling_cmd_req' &&
|
||||||
command.cmd.type !== lastMessage
|
command.cmd.type !== lastMessage
|
||||||
@ -776,10 +954,6 @@ export class EngineCommandManager {
|
|||||||
console.log('sending command', command.cmd.type)
|
console.log('sending command', command.cmd.type)
|
||||||
lastMessage = command.cmd.type
|
lastMessage = command.cmd.type
|
||||||
}
|
}
|
||||||
if (!this.engineConnection?.isReady()) {
|
|
||||||
console.log('socket not ready')
|
|
||||||
return Promise.resolve()
|
|
||||||
}
|
|
||||||
if (command.type !== 'modeling_cmd_req') return Promise.resolve()
|
if (command.type !== 'modeling_cmd_req') return Promise.resolve()
|
||||||
const cmd = command.cmd
|
const cmd = command.cmd
|
||||||
if (
|
if (
|
||||||
@ -821,10 +995,12 @@ export class EngineCommandManager {
|
|||||||
range: SourceRange
|
range: SourceRange
|
||||||
command: EngineCommand | string
|
command: EngineCommand | string
|
||||||
}): Promise<any> {
|
}): Promise<any> {
|
||||||
|
if (this.engineConnection === undefined) {
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
this.sourceRangeMap[id] = range
|
this.sourceRangeMap[id] = range
|
||||||
|
|
||||||
if (!this.engineConnection?.isReady()) {
|
if (!this.engineConnection?.isReady()) {
|
||||||
console.log('socket not ready')
|
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
this.engineConnection?.send(command)
|
this.engineConnection?.send(command)
|
||||||
@ -867,6 +1043,9 @@ export class EngineCommandManager {
|
|||||||
rangeStr: string,
|
rangeStr: string,
|
||||||
commandStr: string
|
commandStr: string
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
|
if (this.engineConnection === undefined) {
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
if (id === undefined) {
|
if (id === undefined) {
|
||||||
throw new Error('id is undefined')
|
throw new Error('id is undefined')
|
||||||
}
|
}
|
||||||
@ -890,6 +1069,8 @@ export class EngineCommandManager {
|
|||||||
}
|
}
|
||||||
if (command.type === 'result') {
|
if (command.type === 'result') {
|
||||||
return command.data
|
return command.data
|
||||||
|
} else if (command.type === 'failed') {
|
||||||
|
return Promise.resolve(command.errors)
|
||||||
}
|
}
|
||||||
return command.promise
|
return command.promise
|
||||||
}
|
}
|
||||||
@ -915,6 +1096,9 @@ export class EngineCommandManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private async fixIdMappings(ast: Program, programMemory: ProgramMemory) {
|
private async fixIdMappings(ast: Program, programMemory: ProgramMemory) {
|
||||||
|
if (this.engineConnection === undefined) {
|
||||||
|
return
|
||||||
|
}
|
||||||
/* This is a temporary solution since the cmd_ids that are sent through when
|
/* This is a temporary solution since the cmd_ids that are sent through when
|
||||||
sending 'extend_path' ids are not used as the segment ids.
|
sending 'extend_path' ids are not used as the segment ids.
|
||||||
|
|
||||||
@ -994,3 +1178,5 @@ export class EngineCommandManager {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const engineCommandManager = new EngineCommandManager()
|
||||||
|
@ -6,13 +6,9 @@ import {
|
|||||||
getXComponent,
|
getXComponent,
|
||||||
addCloseToPipe,
|
addCloseToPipe,
|
||||||
} from './sketch'
|
} from './sketch'
|
||||||
import { parser_wasm } from '../abstractSyntaxTree'
|
import { parse, recast, initPromise } from '../wasm'
|
||||||
import { getNodePathFromSourceRange } from '../queryAst'
|
import { getNodePathFromSourceRange } from '../queryAst'
|
||||||
import { recast } from '../recast'
|
|
||||||
import { enginelessExecutor } from '../../lib/testHelpers'
|
import { enginelessExecutor } from '../../lib/testHelpers'
|
||||||
import { initPromise } from '../rust'
|
|
||||||
|
|
||||||
beforeAll(() => initPromise)
|
|
||||||
|
|
||||||
const eachQuad: [number, [number, number]][] = [
|
const eachQuad: [number, [number, number]][] = [
|
||||||
[-315, [1, 1]],
|
[-315, [1, 1]],
|
||||||
@ -29,6 +25,8 @@ const eachQuad: [number, [number, number]][] = [
|
|||||||
[675, [1, -1]],
|
[675, [1, -1]],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
beforeAll(() => initPromise)
|
||||||
|
|
||||||
describe('testing getYComponent', () => {
|
describe('testing getYComponent', () => {
|
||||||
it('should return the vertical component of a vector correctly when given angles in each quadrant (and with angles < 0, or > 360)', () => {
|
it('should return the vertical component of a vector correctly when given angles in each quadrant (and with angles < 0, or > 360)', () => {
|
||||||
const expected: [number, number][] = []
|
const expected: [number, number][] = []
|
||||||
@ -98,7 +96,8 @@ describe('testing changeSketchArguments', () => {
|
|||||||
const lineAfterChange = 'lineTo([2, 3], %)'
|
const lineAfterChange = 'lineTo([2, 3], %)'
|
||||||
test('changeSketchArguments', async () => {
|
test('changeSketchArguments', async () => {
|
||||||
// Enable rotations #152
|
// Enable rotations #152
|
||||||
const genCode = (line: string) => `const mySketch001 = startSketchAt([0, 0])
|
const genCode = (line: string) => `const mySketch001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> ${line}
|
|> ${line}
|
||||||
|> lineTo([0.46, -5.82], %)
|
|> lineTo([0.46, -5.82], %)
|
||||||
// |> rx(45, %)
|
// |> rx(45, %)
|
||||||
@ -106,7 +105,7 @@ show(mySketch001)
|
|||||||
`
|
`
|
||||||
const code = genCode(lineToChange)
|
const code = genCode(lineToChange)
|
||||||
const expectedCode = genCode(lineAfterChange)
|
const expectedCode = genCode(lineAfterChange)
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
const sourceStart = code.indexOf(lineToChange)
|
const sourceStart = code.indexOf(lineToChange)
|
||||||
const { modifiedAst } = changeSketchArguments(
|
const { modifiedAst } = changeSketchArguments(
|
||||||
@ -139,15 +138,16 @@ describe('testing addNewSketchLn', () => {
|
|||||||
test('addNewSketchLn', async () => {
|
test('addNewSketchLn', async () => {
|
||||||
// Enable rotations #152
|
// Enable rotations #152
|
||||||
const code = `
|
const code = `
|
||||||
const mySketch001 = startSketchAt([0, 0])
|
const mySketch001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
// |> rx(45, %)
|
// |> rx(45, %)
|
||||||
|> lineTo([-1.59, -1.54], %)
|
|> lineTo([-1.59, -1.54], %)
|
||||||
|> lineTo([0.46, -5.82], %)
|
|> lineTo([0.46, -5.82], %)
|
||||||
show(mySketch001)`
|
show(mySketch001)`
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
const sourceStart = code.indexOf(lineToChange)
|
const sourceStart = code.indexOf(lineToChange)
|
||||||
expect(sourceStart).toBe(66)
|
expect(sourceStart).toBe(95)
|
||||||
let { modifiedAst } = addNewSketchLn({
|
let { modifiedAst } = addNewSketchLn({
|
||||||
node: ast,
|
node: ast,
|
||||||
programMemory,
|
programMemory,
|
||||||
@ -162,7 +162,8 @@ show(mySketch001)`
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
// Enable rotations #152
|
// Enable rotations #152
|
||||||
let expectedCode = `const mySketch001 = startSketchAt([0, 0])
|
let expectedCode = `const mySketch001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
// |> rx(45, %)
|
// |> rx(45, %)
|
||||||
|> lineTo([-1.59, -1.54], %)
|
|> lineTo([-1.59, -1.54], %)
|
||||||
|> lineTo([0.46, -5.82], %)
|
|> lineTo([0.46, -5.82], %)
|
||||||
@ -183,7 +184,8 @@ show(mySketch001)
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
expectedCode = `const mySketch001 = startSketchAt([0, 0])
|
expectedCode = `const mySketch001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
// |> rx(45, %)
|
// |> rx(45, %)
|
||||||
|> lineTo([-1.59, -1.54], %)
|
|> lineTo([-1.59, -1.54], %)
|
||||||
|> lineTo([0.46, -5.82], %)
|
|> lineTo([0.46, -5.82], %)
|
||||||
@ -198,14 +200,15 @@ describe('testing addTagForSketchOnFace', () => {
|
|||||||
it('needs to be in it', async () => {
|
it('needs to be in it', async () => {
|
||||||
const originalLine = 'lineTo([-1.59, -1.54], %)'
|
const originalLine = 'lineTo([-1.59, -1.54], %)'
|
||||||
// Enable rotations #152
|
// Enable rotations #152
|
||||||
const genCode = (line: string) => `const mySketch001 = startSketchAt([0, 0])
|
const genCode = (line: string) => `const mySketch001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
// |> rx(45, %)
|
// |> rx(45, %)
|
||||||
|> ${line}
|
|> ${line}
|
||||||
|> lineTo([0.46, -5.82], %)
|
|> lineTo([0.46, -5.82], %)
|
||||||
show(mySketch001)
|
show(mySketch001)
|
||||||
`
|
`
|
||||||
const code = genCode(originalLine)
|
const code = genCode(originalLine)
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
const sourceStart = code.indexOf(originalLine)
|
const sourceStart = code.indexOf(originalLine)
|
||||||
const sourceRange: [number, number] = [
|
const sourceRange: [number, number] = [
|
||||||
|
@ -4,9 +4,6 @@ import {
|
|||||||
SketchGroup,
|
SketchGroup,
|
||||||
SourceRange,
|
SourceRange,
|
||||||
PathToNode,
|
PathToNode,
|
||||||
MemoryItem,
|
|
||||||
} from '../executor'
|
|
||||||
import {
|
|
||||||
Program,
|
Program,
|
||||||
PipeExpression,
|
PipeExpression,
|
||||||
CallExpression,
|
CallExpression,
|
||||||
@ -14,7 +11,7 @@ import {
|
|||||||
Value,
|
Value,
|
||||||
Literal,
|
Literal,
|
||||||
VariableDeclaration,
|
VariableDeclaration,
|
||||||
} from '../abstractSyntaxTreeTypes'
|
} from '../wasm'
|
||||||
import {
|
import {
|
||||||
getNodeFromPath,
|
getNodeFromPath,
|
||||||
getNodeFromPathCurry,
|
getNodeFromPathCurry,
|
||||||
@ -38,7 +35,6 @@ import {
|
|||||||
findUniqueName,
|
findUniqueName,
|
||||||
} from '../modifyAst'
|
} from '../modifyAst'
|
||||||
import { roundOff, getLength, getAngle } from '../../lib/utils'
|
import { roundOff, getLength, getAngle } from '../../lib/utils'
|
||||||
import { getSketchSegmentFromSourceRange } from './sketchConstraints'
|
|
||||||
import { perpendicularDistance } from 'sketch-helpers'
|
import { perpendicularDistance } from 'sketch-helpers'
|
||||||
|
|
||||||
export type Coords2d = [number, number]
|
export type Coords2d = [number, number]
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
import { parser_wasm } from '../abstractSyntaxTree'
|
import { parse, SketchGroup, recast, initPromise } from '../wasm'
|
||||||
import { SketchGroup } from '../executor'
|
|
||||||
import {
|
import {
|
||||||
ConstraintType,
|
ConstraintType,
|
||||||
getTransformInfos,
|
getTransformInfos,
|
||||||
transformAstSketchLines,
|
transformAstSketchLines,
|
||||||
} from './sketchcombos'
|
} from './sketchcombos'
|
||||||
import { recast } from '../recast'
|
|
||||||
import { initPromise } from '../rust'
|
|
||||||
import { getSketchSegmentFromSourceRange } from './sketchConstraints'
|
import { getSketchSegmentFromSourceRange } from './sketchConstraints'
|
||||||
import { Selection } from '../../useStore'
|
import { Selection } from '../../useStore'
|
||||||
import { enginelessExecutor } from '../../lib/testHelpers'
|
import { enginelessExecutor } from '../../lib/testHelpers'
|
||||||
@ -31,7 +28,7 @@ async function testingSwapSketchFnCall({
|
|||||||
type: 'default',
|
type: 'default',
|
||||||
range: [startIndex, startIndex + callToSwap.length],
|
range: [startIndex, startIndex + callToSwap.length],
|
||||||
}
|
}
|
||||||
const ast = parser_wasm(inputCode)
|
const ast = parse(inputCode)
|
||||||
const programMemory = await enginelessExecutor(ast)
|
const programMemory = await enginelessExecutor(ast)
|
||||||
const selections = {
|
const selections = {
|
||||||
codeBasedSelections: [range],
|
codeBasedSelections: [range],
|
||||||
@ -55,7 +52,8 @@ async function testingSwapSketchFnCall({
|
|||||||
|
|
||||||
describe('testing swaping out sketch calls with xLine/xLineTo', () => {
|
describe('testing swaping out sketch calls with xLine/xLineTo', () => {
|
||||||
const bigExampleArr = [
|
const bigExampleArr = [
|
||||||
`const part001 = startSketchAt([0, 0])`,
|
`const part001 = startSketchOn('XY')`,
|
||||||
|
` |> startProfileAt([0, 0], %)`,
|
||||||
` |> lineTo({ to: [1, 1], tag: 'abc1' }, %)`,
|
` |> lineTo({ to: [1, 1], tag: 'abc1' }, %)`,
|
||||||
` |> line({ to: [-2.04, -0.7], tag: 'abc2' }, %)`,
|
` |> line({ to: [-2.04, -0.7], tag: 'abc2' }, %)`,
|
||||||
` |> angledLine({`,
|
` |> angledLine({`,
|
||||||
@ -280,7 +278,8 @@ describe('testing swaping out sketch calls with xLine/xLineTo while keeping vari
|
|||||||
`const angledLineOfYLengthY = 0.89`,
|
`const angledLineOfYLengthY = 0.89`,
|
||||||
`const angledLineToXx = -1.86`,
|
`const angledLineToXx = -1.86`,
|
||||||
`const angledLineToYy = -0.76`,
|
`const angledLineToYy = -0.76`,
|
||||||
`const part001 = startSketchAt([0, 0])`,
|
`const part001 = startSketchOn('XY')`,
|
||||||
|
` |> startProfileAt([0, 0], %)`,
|
||||||
// ` |> rx(90, %)`,
|
// ` |> rx(90, %)`,
|
||||||
` |> lineTo([1, 1], %)`,
|
` |> lineTo([1, 1], %)`,
|
||||||
` |> line([lineX, 2.13], %)`,
|
` |> line([lineX, 2.13], %)`,
|
||||||
@ -374,14 +373,15 @@ describe('testing swaping out sketch calls with xLine/xLineTo while keeping vari
|
|||||||
|
|
||||||
describe('testing getSketchSegmentIndexFromSourceRange', () => {
|
describe('testing getSketchSegmentIndexFromSourceRange', () => {
|
||||||
const code = `
|
const code = `
|
||||||
const part001 = startSketchAt([0, 0.04]) // segment-in-start
|
const part001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0.04], %) // segment-in-start
|
||||||
|> line([0, 0.4], %)
|
|> line([0, 0.4], %)
|
||||||
|> xLine(3.48, %)
|
|> xLine(3.48, %)
|
||||||
|> line([2.14, 1.35], %) // normal-segment
|
|> line([2.14, 1.35], %) // normal-segment
|
||||||
|> xLine(3.54, %)
|
|> xLine(3.54, %)
|
||||||
show(part001)`
|
show(part001)`
|
||||||
it('normal case works', async () => {
|
it('normal case works', async () => {
|
||||||
const programMemory = await enginelessExecutor(parser_wasm(code))
|
const programMemory = await enginelessExecutor(parse(code))
|
||||||
const index = code.indexOf('// normal-segment') - 7
|
const index = code.indexOf('// normal-segment') - 7
|
||||||
const { __geoMeta, ...segment } = getSketchSegmentFromSourceRange(
|
const { __geoMeta, ...segment } = getSketchSegmentFromSourceRange(
|
||||||
programMemory.root['part001'] as SketchGroup,
|
programMemory.root['part001'] as SketchGroup,
|
||||||
@ -395,7 +395,7 @@ show(part001)`
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
it('verify it works when the segment is in the `start` property', async () => {
|
it('verify it works when the segment is in the `start` property', async () => {
|
||||||
const programMemory = await enginelessExecutor(parser_wasm(code))
|
const programMemory = await enginelessExecutor(parse(code))
|
||||||
const index = code.indexOf('// segment-in-start') - 7
|
const index = code.indexOf('// segment-in-start') - 7
|
||||||
const { __geoMeta, ...segment } = getSketchSegmentFromSourceRange(
|
const { __geoMeta, ...segment } = getSketchSegmentFromSourceRange(
|
||||||
programMemory.root['part001'] as SketchGroup,
|
programMemory.root['part001'] as SketchGroup,
|
||||||
|
@ -3,8 +3,10 @@ import {
|
|||||||
Program,
|
Program,
|
||||||
VariableDeclarator,
|
VariableDeclarator,
|
||||||
CallExpression,
|
CallExpression,
|
||||||
} from '../abstractSyntaxTreeTypes'
|
SketchGroup,
|
||||||
import { SketchGroup, SourceRange, Path } from '../executor'
|
SourceRange,
|
||||||
|
Path,
|
||||||
|
} from '../wasm'
|
||||||
|
|
||||||
export function getSketchSegmentFromSourceRange(
|
export function getSketchSegmentFromSourceRange(
|
||||||
sketchGroup: SketchGroup,
|
sketchGroup: SketchGroup,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { parser_wasm } from '../abstractSyntaxTree'
|
import { parse, Value, recast, initPromise } from '../wasm'
|
||||||
import { Value } from '../abstractSyntaxTreeTypes'
|
|
||||||
import {
|
import {
|
||||||
getConstraintType,
|
getConstraintType,
|
||||||
getTransformInfos,
|
getTransformInfos,
|
||||||
@ -8,10 +7,8 @@ import {
|
|||||||
ConstraintType,
|
ConstraintType,
|
||||||
getConstraintLevelFromSourceRange,
|
getConstraintLevelFromSourceRange,
|
||||||
} from './sketchcombos'
|
} from './sketchcombos'
|
||||||
import { initPromise } from '../rust'
|
|
||||||
import { Selections, ToolTip } from '../../useStore'
|
import { Selections, ToolTip } from '../../useStore'
|
||||||
import { enginelessExecutor } from '../../lib/testHelpers'
|
import { enginelessExecutor } from '../../lib/testHelpers'
|
||||||
import { recast } from '../../lang/recast'
|
|
||||||
|
|
||||||
beforeAll(() => initPromise)
|
beforeAll(() => initPromise)
|
||||||
|
|
||||||
@ -63,7 +60,7 @@ describe('testing getConstraintType', () => {
|
|||||||
function getConstraintTypeFromSourceHelper(
|
function getConstraintTypeFromSourceHelper(
|
||||||
code: string
|
code: string
|
||||||
): ReturnType<typeof getConstraintType> {
|
): ReturnType<typeof getConstraintType> {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const args = (ast.body[0] as any).expression.arguments[0].elements as [
|
const args = (ast.body[0] as any).expression.arguments[0].elements as [
|
||||||
Value,
|
Value,
|
||||||
Value
|
Value
|
||||||
@ -74,7 +71,7 @@ function getConstraintTypeFromSourceHelper(
|
|||||||
function getConstraintTypeFromSourceHelper2(
|
function getConstraintTypeFromSourceHelper2(
|
||||||
code: string
|
code: string
|
||||||
): ReturnType<typeof getConstraintType> {
|
): ReturnType<typeof getConstraintType> {
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const arg = (ast.body[0] as any).expression.arguments[0] as Value
|
const arg = (ast.body[0] as any).expression.arguments[0] as Value
|
||||||
const fnName = (ast.body[0] as any).expression.callee.name as ToolTip
|
const fnName = (ast.body[0] as any).expression.callee.name as ToolTip
|
||||||
return getConstraintType(arg, fnName)
|
return getConstraintType(arg, fnName)
|
||||||
@ -95,7 +92,8 @@ const myVar2 = 5
|
|||||||
const myVar3 = 6
|
const myVar3 = 6
|
||||||
const myAng = 40
|
const myAng = 40
|
||||||
const myAng2 = 134
|
const myAng2 = 134
|
||||||
const part001 = startSketchAt([0, 0])
|
const part001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> line([1, 3.82], %) // ln-should-get-tag
|
|> line([1, 3.82], %) // ln-should-get-tag
|
||||||
|> lineTo([myVar, 1], %) // ln-lineTo-xAbsolute should use angleToMatchLengthX helper
|
|> lineTo([myVar, 1], %) // ln-lineTo-xAbsolute should use angleToMatchLengthX helper
|
||||||
|> lineTo([1, myVar], %) // ln-lineTo-yAbsolute should use angleToMatchLengthY helper
|
|> lineTo([1, myVar], %) // ln-lineTo-yAbsolute should use angleToMatchLengthY helper
|
||||||
@ -131,7 +129,8 @@ const myVar2 = 5
|
|||||||
const myVar3 = 6
|
const myVar3 = 6
|
||||||
const myAng = 40
|
const myAng = 40
|
||||||
const myAng2 = 134
|
const myAng2 = 134
|
||||||
const part001 = startSketchAt([0, 0])
|
const part001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> line({ to: [1, 3.82], tag: 'seg01' }, %) // ln-should-get-tag
|
|> line({ to: [1, 3.82], tag: 'seg01' }, %) // ln-should-get-tag
|
||||||
|> angledLineToX([
|
|> angledLineToX([
|
||||||
-angleToMatchLengthX('seg01', myVar, %),
|
-angleToMatchLengthX('seg01', myVar, %),
|
||||||
@ -199,7 +198,7 @@ const part001 = startSketchAt([0, 0])
|
|||||||
show(part001)
|
show(part001)
|
||||||
`
|
`
|
||||||
it('should transform the ast', async () => {
|
it('should transform the ast', async () => {
|
||||||
const ast = parser_wasm(inputScript)
|
const ast = parse(inputScript)
|
||||||
const selectionRanges: Selections['codeBasedSelections'] = inputScript
|
const selectionRanges: Selections['codeBasedSelections'] = inputScript
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter((ln) => ln.includes('//'))
|
.filter((ln) => ln.includes('//'))
|
||||||
@ -234,7 +233,8 @@ describe('testing transformAstForSketchLines for vertical and horizontal constra
|
|||||||
const inputScript = `const myVar = 2
|
const inputScript = `const myVar = 2
|
||||||
const myVar2 = 12
|
const myVar2 = 12
|
||||||
const myVar3 = -10
|
const myVar3 = -10
|
||||||
const part001 = startSketchAt([0, 0])
|
const part001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> lineTo([1, 1], %)
|
|> lineTo([1, 1], %)
|
||||||
|> line([-6.28, 1.4], %) // select for horizontal constraint 1
|
|> line([-6.28, 1.4], %) // select for horizontal constraint 1
|
||||||
|> line([-1.07, myVar], %) // select for vertical constraint 1
|
|> line([-1.07, myVar], %) // select for vertical constraint 1
|
||||||
@ -262,7 +262,8 @@ show(part001)
|
|||||||
const expectModifiedScript = `const myVar = 2
|
const expectModifiedScript = `const myVar = 2
|
||||||
const myVar2 = 12
|
const myVar2 = 12
|
||||||
const myVar3 = -10
|
const myVar3 = -10
|
||||||
const part001 = startSketchAt([0, 0])
|
const part001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> lineTo([1, 1], %)
|
|> lineTo([1, 1], %)
|
||||||
|> xLine(-6.28, %) // select for horizontal constraint 1
|
|> xLine(-6.28, %) // select for horizontal constraint 1
|
||||||
|> line([-1.07, myVar], %) // select for vertical constraint 1
|
|> line([-1.07, myVar], %) // select for vertical constraint 1
|
||||||
@ -286,7 +287,7 @@ const part001 = startSketchAt([0, 0])
|
|||||||
|> angledLineToY([301, myVar], %) // select for vertical constraint 10
|
|> angledLineToY([301, myVar], %) // select for vertical constraint 10
|
||||||
show(part001)
|
show(part001)
|
||||||
`
|
`
|
||||||
const ast = parser_wasm(inputScript)
|
const ast = parse(inputScript)
|
||||||
const selectionRanges: Selections['codeBasedSelections'] = inputScript
|
const selectionRanges: Selections['codeBasedSelections'] = inputScript
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter((ln) => ln.includes('// select for horizontal constraint'))
|
.filter((ln) => ln.includes('// select for horizontal constraint'))
|
||||||
@ -320,7 +321,8 @@ show(part001)
|
|||||||
const expectModifiedScript = `const myVar = 2
|
const expectModifiedScript = `const myVar = 2
|
||||||
const myVar2 = 12
|
const myVar2 = 12
|
||||||
const myVar3 = -10
|
const myVar3 = -10
|
||||||
const part001 = startSketchAt([0, 0])
|
const part001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> lineTo([1, 1], %)
|
|> lineTo([1, 1], %)
|
||||||
|> line([-6.28, 1.4], %) // select for horizontal constraint 1
|
|> line([-6.28, 1.4], %) // select for horizontal constraint 1
|
||||||
|> yLine(myVar, %) // select for vertical constraint 1
|
|> yLine(myVar, %) // select for vertical constraint 1
|
||||||
@ -344,7 +346,7 @@ const part001 = startSketchAt([0, 0])
|
|||||||
|> yLineTo(myVar, %) // select for vertical constraint 10
|
|> yLineTo(myVar, %) // select for vertical constraint 10
|
||||||
show(part001)
|
show(part001)
|
||||||
`
|
`
|
||||||
const ast = parser_wasm(inputScript)
|
const ast = parse(inputScript)
|
||||||
const selectionRanges: Selections['codeBasedSelections'] = inputScript
|
const selectionRanges: Selections['codeBasedSelections'] = inputScript
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter((ln) => ln.includes('// select for vertical constraint'))
|
.filter((ln) => ln.includes('// select for vertical constraint'))
|
||||||
@ -379,7 +381,8 @@ show(part001)
|
|||||||
describe('testing transformAstForSketchLines for vertical and horizontal distance constraints', () => {
|
describe('testing transformAstForSketchLines for vertical and horizontal distance constraints', () => {
|
||||||
describe('testing setHorzDistance for line', () => {
|
describe('testing setHorzDistance for line', () => {
|
||||||
const inputScript = `const myVar = 1
|
const inputScript = `const myVar = 1
|
||||||
const part001 = startSketchAt([0, 0])
|
const part001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> line([0.31, 1.67], %) // base selection
|
|> line([0.31, 1.67], %) // base selection
|
||||||
|> line([0.45, 1.46], %)
|
|> line([0.45, 1.46], %)
|
||||||
|> line([0.45, 1.46], %) // free
|
|> line([0.45, 1.46], %) // free
|
||||||
@ -435,7 +438,7 @@ async function helperThing(
|
|||||||
linesOfInterest: string[],
|
linesOfInterest: string[],
|
||||||
constraint: ConstraintType
|
constraint: ConstraintType
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const ast = parser_wasm(inputScript)
|
const ast = parse(inputScript)
|
||||||
const selectionRanges: Selections['codeBasedSelections'] = inputScript
|
const selectionRanges: Selections['codeBasedSelections'] = inputScript
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter((ln) =>
|
.filter((ln) =>
|
||||||
@ -480,7 +483,8 @@ const baseThickHalf = baseThick / 2
|
|||||||
const halfHeight = totalHeight / 2
|
const halfHeight = totalHeight / 2
|
||||||
const halfArmAngle = armAngle / 2
|
const halfArmAngle = armAngle / 2
|
||||||
|
|
||||||
const part001 = startSketchAt([-0.01, -0.05])
|
const part001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([-0.01, -0.05], %)
|
||||||
|> line([0.01, 0.94 + 0], %) // partial
|
|> line([0.01, 0.94 + 0], %) // partial
|
||||||
|> xLine(3.03, %) // partial
|
|> xLine(3.03, %) // partial
|
||||||
|> angledLine({
|
|> angledLine({
|
||||||
@ -498,7 +502,7 @@ const part001 = startSketchAt([-0.01, -0.05])
|
|||||||
|> xLine(-3.43 + 0, %) // full
|
|> xLine(-3.43 + 0, %) // full
|
||||||
|> angledLineOfXLength([243 + 0, 1.2 + 0], %) // full
|
|> angledLineOfXLength([243 + 0, 1.2 + 0], %) // full
|
||||||
show(part001)`
|
show(part001)`
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const constraintLevels: ReturnType<
|
const constraintLevels: ReturnType<
|
||||||
typeof getConstraintLevelFromSourceRange
|
typeof getConstraintLevelFromSourceRange
|
||||||
>[] = ['full', 'partial', 'free']
|
>[] = ['full', 'partial', 'free']
|
||||||
|
@ -6,7 +6,9 @@ import {
|
|||||||
Value,
|
Value,
|
||||||
BinaryPart,
|
BinaryPart,
|
||||||
VariableDeclarator,
|
VariableDeclarator,
|
||||||
} from '../abstractSyntaxTreeTypes'
|
PathToNode,
|
||||||
|
ProgramMemory,
|
||||||
|
} from '../wasm'
|
||||||
import {
|
import {
|
||||||
getNodeFromPath,
|
getNodeFromPath,
|
||||||
getNodeFromPathCurry,
|
getNodeFromPathCurry,
|
||||||
@ -25,10 +27,8 @@ import {
|
|||||||
giveSketchFnCallTag,
|
giveSketchFnCallTag,
|
||||||
} from '../modifyAst'
|
} from '../modifyAst'
|
||||||
import { createFirstArg, getFirstArg, replaceSketchLine } from './sketch'
|
import { createFirstArg, getFirstArg, replaceSketchLine } from './sketch'
|
||||||
import { PathToNode, ProgramMemory } from '../executor'
|
|
||||||
import { getSketchSegmentFromSourceRange } from './sketchConstraints'
|
import { getSketchSegmentFromSourceRange } from './sketchConstraints'
|
||||||
import { getAngle, roundOff, normaliseAngle } from '../../lib/utils'
|
import { getAngle, roundOff, normaliseAngle } from '../../lib/utils'
|
||||||
import { MemoryItem } from 'wasm-lib/kcl/bindings/MemoryItem'
|
|
||||||
|
|
||||||
type LineInputsType =
|
type LineInputsType =
|
||||||
| 'xAbsolute'
|
| 'xAbsolute'
|
||||||
@ -1279,7 +1279,7 @@ export function getTransformInfos(
|
|||||||
}) as TransformInfo[]
|
}) as TransformInfo[]
|
||||||
return theTransforms
|
return theTransforms
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log('error', error)
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { parser_wasm } from '../abstractSyntaxTree'
|
import { parse, initPromise } from '../wasm'
|
||||||
import { enginelessExecutor } from '../../lib/testHelpers'
|
import { enginelessExecutor } from '../../lib/testHelpers'
|
||||||
import { initPromise } from '../rust'
|
|
||||||
|
|
||||||
beforeAll(() => initPromise)
|
beforeAll(() => initPromise)
|
||||||
|
|
||||||
describe('testing angledLineThatIntersects', () => {
|
describe('testing angledLineThatIntersects', () => {
|
||||||
it('angledLineThatIntersects should intersect with another line', async () => {
|
it('angledLineThatIntersects should intersect with another line', async () => {
|
||||||
const code = (offset: string) => `const part001 = startSketchAt([0, 0])
|
const code = (offset: string) => `const part001 = startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|> lineTo({to:[2, 2], tag: "yo"}, %)
|
|> lineTo({to:[2, 2], tag: "yo"}, %)
|
||||||
|> lineTo([3, 1], %)
|
|> lineTo([3, 1], %)
|
||||||
|> angledLineThatIntersects({
|
|> angledLineThatIntersects({
|
||||||
@ -17,9 +17,9 @@ describe('testing angledLineThatIntersects', () => {
|
|||||||
}, %)
|
}, %)
|
||||||
const intersect = segEndX('yo2', part001)
|
const intersect = segEndX('yo2', part001)
|
||||||
show(part001)`
|
show(part001)`
|
||||||
const { root } = await enginelessExecutor(parser_wasm(code('-1')))
|
const { root } = await enginelessExecutor(parse(code('-1')))
|
||||||
expect(root.intersect.value).toBe(1 + Math.sqrt(2))
|
expect(root.intersect.value).toBe(1 + Math.sqrt(2))
|
||||||
const { root: noOffset } = await enginelessExecutor(parser_wasm(code('0')))
|
const { root: noOffset } = await enginelessExecutor(parse(code('0')))
|
||||||
expect(noOffset.intersect.value).toBeCloseTo(1)
|
expect(noOffset.intersect.value).toBeCloseTo(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
import { ProgramMemory, Path, SourceRange } from '../executor'
|
import {
|
||||||
import { Program, Value } from '../abstractSyntaxTreeTypes'
|
ProgramMemory,
|
||||||
|
Path,
|
||||||
|
SourceRange,
|
||||||
|
Program,
|
||||||
|
Value,
|
||||||
|
PathToNode,
|
||||||
|
} from '../wasm'
|
||||||
import { ToolTip } from '../../useStore'
|
import { ToolTip } from '../../useStore'
|
||||||
import { PathToNode } from '../executor'
|
|
||||||
import { EngineCommandManager } from './engineConnection'
|
import { EngineCommandManager } from './engineConnection'
|
||||||
|
|
||||||
export interface InternalFirstArg {
|
export interface InternalFirstArg {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { lexer, asyncLexer } from './tokeniser'
|
import { lexer, initPromise } from './wasm'
|
||||||
import { initPromise } from './rust'
|
|
||||||
|
|
||||||
beforeAll(() => initPromise)
|
beforeAll(() => initPromise)
|
||||||
|
|
||||||
@ -10,9 +9,9 @@ describe('testing lexer', () => {
|
|||||||
const code3 = `const yo = 45 /* this is a comment
|
const code3 = `const yo = 45 /* this is a comment
|
||||||
const ya = 6 */
|
const ya = 6 */
|
||||||
const yi=45`
|
const yi=45`
|
||||||
expect(await asyncLexer(code)).toEqual(lexer(code))
|
expect(lexer(code)).toEqual(lexer(code))
|
||||||
expect(await asyncLexer(code2)).toEqual(lexer(code2))
|
expect(lexer(code2)).toEqual(lexer(code2))
|
||||||
expect(await asyncLexer(code3)).toEqual(lexer(code3))
|
expect(lexer(code3)).toEqual(lexer(code3))
|
||||||
})
|
})
|
||||||
it('test lexer', () => {
|
it('test lexer', () => {
|
||||||
expect(stringSummaryLexer('1 + 2')).toEqual([
|
expect(stringSummaryLexer('1 + 2')).toEqual([
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
import { lexer_js } from '../wasm-lib/pkg/wasm_lib'
|
|
||||||
import { initPromise } from './rust'
|
|
||||||
import { Token } from '../wasm-lib/kcl/bindings/Token'
|
|
||||||
|
|
||||||
export type { Token } from '../wasm-lib/kcl/bindings/Token'
|
|
||||||
|
|
||||||
export async function asyncLexer(str: string): Promise<Token[]> {
|
|
||||||
await initPromise
|
|
||||||
try {
|
|
||||||
const tokens: Token[] = lexer_js(str)
|
|
||||||
return tokens
|
|
||||||
} catch (e) {
|
|
||||||
// TODO: do something real with the error.
|
|
||||||
console.log('lexer', e)
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function lexer(str: string): Token[] {
|
|
||||||
try {
|
|
||||||
const tokens: Token[] = lexer_js(str)
|
|
||||||
return tokens
|
|
||||||
} catch (e) {
|
|
||||||
// TODO: do something real with the error.
|
|
||||||
console.log('lexer', e)
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
import { Selections, StoreState } from '../useStore'
|
import { Selections, StoreState } from '../useStore'
|
||||||
import { Program } from './abstractSyntaxTreeTypes'
|
import { Program, PathToNode } from './wasm'
|
||||||
import { PathToNode } from './executor'
|
|
||||||
import { getNodeFromPath } from './queryAst'
|
import { getNodeFromPath } from './queryAst'
|
||||||
|
|
||||||
export function updateCursors(
|
export function updateCursors(
|
||||||
|
222
src/lang/wasm.ts
Normal file
222
src/lang/wasm.ts
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
import init, {
|
||||||
|
parse_wasm,
|
||||||
|
recast_wasm,
|
||||||
|
execute_wasm,
|
||||||
|
lexer_wasm,
|
||||||
|
modify_ast_for_sketch_wasm,
|
||||||
|
} from '../wasm-lib/pkg/wasm_lib'
|
||||||
|
import { KCLError } from './errors'
|
||||||
|
import { KclError as RustKclError } from '../wasm-lib/kcl/bindings/KclError'
|
||||||
|
import {
|
||||||
|
EngineCommandManager,
|
||||||
|
ArtifactMap,
|
||||||
|
SourceRangeMap,
|
||||||
|
} from './std/engineConnection'
|
||||||
|
import { ProgramReturn } from '../wasm-lib/kcl/bindings/ProgramReturn'
|
||||||
|
import { MemoryItem } from '../wasm-lib/kcl/bindings/MemoryItem'
|
||||||
|
import type { Program } from '../wasm-lib/kcl/bindings/Program'
|
||||||
|
import type { Token } from '../wasm-lib/kcl/bindings/Token'
|
||||||
|
import { DefaultPlanes } from '../wasm-lib/kcl/bindings/DefaultPlanes'
|
||||||
|
|
||||||
|
export type { Program } from '../wasm-lib/kcl/bindings/Program'
|
||||||
|
export type { Value } from '../wasm-lib/kcl/bindings/Value'
|
||||||
|
export type { ObjectExpression } from '../wasm-lib/kcl/bindings/ObjectExpression'
|
||||||
|
export type { MemberExpression } from '../wasm-lib/kcl/bindings/MemberExpression'
|
||||||
|
export type { PipeExpression } from '../wasm-lib/kcl/bindings/PipeExpression'
|
||||||
|
export type { VariableDeclaration } from '../wasm-lib/kcl/bindings/VariableDeclaration'
|
||||||
|
export type { PipeSubstitution } from '../wasm-lib/kcl/bindings/PipeSubstitution'
|
||||||
|
export type { Identifier } from '../wasm-lib/kcl/bindings/Identifier'
|
||||||
|
export type { UnaryExpression } from '../wasm-lib/kcl/bindings/UnaryExpression'
|
||||||
|
export type { BinaryExpression } from '../wasm-lib/kcl/bindings/BinaryExpression'
|
||||||
|
export type { ReturnStatement } from '../wasm-lib/kcl/bindings/ReturnStatement'
|
||||||
|
export type { ExpressionStatement } from '../wasm-lib/kcl/bindings/ExpressionStatement'
|
||||||
|
export type { CallExpression } from '../wasm-lib/kcl/bindings/CallExpression'
|
||||||
|
export type { VariableDeclarator } from '../wasm-lib/kcl/bindings/VariableDeclarator'
|
||||||
|
export type { BinaryPart } from '../wasm-lib/kcl/bindings/BinaryPart'
|
||||||
|
export type { Literal } from '../wasm-lib/kcl/bindings/Literal'
|
||||||
|
export type { ArrayExpression } from '../wasm-lib/kcl/bindings/ArrayExpression'
|
||||||
|
|
||||||
|
export type SyntaxType =
|
||||||
|
| 'Program'
|
||||||
|
| 'ExpressionStatement'
|
||||||
|
| 'BinaryExpression'
|
||||||
|
| 'CallExpression'
|
||||||
|
| 'Identifier'
|
||||||
|
| 'ReturnStatement'
|
||||||
|
| 'VariableDeclaration'
|
||||||
|
| 'VariableDeclarator'
|
||||||
|
| 'MemberExpression'
|
||||||
|
| 'ArrayExpression'
|
||||||
|
| 'ObjectExpression'
|
||||||
|
| 'ObjectProperty'
|
||||||
|
| 'FunctionExpression'
|
||||||
|
| 'PipeExpression'
|
||||||
|
| 'PipeSubstitution'
|
||||||
|
| 'Literal'
|
||||||
|
| 'NonCodeNode'
|
||||||
|
| 'UnaryExpression'
|
||||||
|
|
||||||
|
export type { SourceRange } from '../wasm-lib/kcl/bindings/SourceRange'
|
||||||
|
export type { Position } from '../wasm-lib/kcl/bindings/Position'
|
||||||
|
export type { Rotation } from '../wasm-lib/kcl/bindings/Rotation'
|
||||||
|
export type { Path } from '../wasm-lib/kcl/bindings/Path'
|
||||||
|
export type { SketchGroup } from '../wasm-lib/kcl/bindings/SketchGroup'
|
||||||
|
export type { MemoryItem } from '../wasm-lib/kcl/bindings/MemoryItem'
|
||||||
|
export type { ExtrudeSurface } from '../wasm-lib/kcl/bindings/ExtrudeSurface'
|
||||||
|
|
||||||
|
// Initialise the wasm module.
|
||||||
|
const initialise = async () => {
|
||||||
|
const baseUrl =
|
||||||
|
typeof window === 'undefined'
|
||||||
|
? 'http://127.0.0.1:3000'
|
||||||
|
: window.location.origin.includes('tauri://localhost')
|
||||||
|
? 'tauri://localhost'
|
||||||
|
: window.location.origin.includes('localhost')
|
||||||
|
? 'http://localhost:3000'
|
||||||
|
: window.location.origin && window.location.origin !== 'null'
|
||||||
|
? window.location.origin
|
||||||
|
: 'http://localhost:3000'
|
||||||
|
const fullUrl = baseUrl + '/wasm_lib_bg.wasm'
|
||||||
|
const input = await fetch(fullUrl)
|
||||||
|
const buffer = await input.arrayBuffer()
|
||||||
|
return init(buffer)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const initPromise = initialise()
|
||||||
|
|
||||||
|
export const rangeTypeFix = (ranges: number[][]): [number, number][] =>
|
||||||
|
ranges.map(([start, end]) => [start, end])
|
||||||
|
|
||||||
|
export const parse = (code: string): Program => {
|
||||||
|
try {
|
||||||
|
const program: Program = parse_wasm(code)
|
||||||
|
return program
|
||||||
|
} catch (e: any) {
|
||||||
|
const parsed: RustKclError = JSON.parse(e.toString())
|
||||||
|
const kclError = new KCLError(
|
||||||
|
parsed.kind,
|
||||||
|
parsed.msg,
|
||||||
|
rangeTypeFix(parsed.sourceRanges)
|
||||||
|
)
|
||||||
|
|
||||||
|
console.log(kclError)
|
||||||
|
throw kclError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PathToNode = [string | number, string][]
|
||||||
|
|
||||||
|
interface Memory {
|
||||||
|
[key: string]: MemoryItem
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProgramMemory {
|
||||||
|
root: Memory
|
||||||
|
return: ProgramReturn | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export const executor = async (
|
||||||
|
node: Program,
|
||||||
|
programMemory: ProgramMemory = { root: {}, return: null },
|
||||||
|
engineCommandManager: EngineCommandManager,
|
||||||
|
planes: DefaultPlanes,
|
||||||
|
// work around while the gemotry is still be stored on the frontend
|
||||||
|
// will be removed when the stream UI is added.
|
||||||
|
tempMapCallback: (a: {
|
||||||
|
artifactMap: ArtifactMap
|
||||||
|
sourceRangeMap: SourceRangeMap
|
||||||
|
}) => void = () => {}
|
||||||
|
): Promise<ProgramMemory> => {
|
||||||
|
engineCommandManager.startNewSession()
|
||||||
|
const _programMemory = await _executor(
|
||||||
|
node,
|
||||||
|
programMemory,
|
||||||
|
engineCommandManager,
|
||||||
|
planes
|
||||||
|
)
|
||||||
|
const { artifactMap, sourceRangeMap } =
|
||||||
|
await engineCommandManager.waitForAllCommands(node, _programMemory)
|
||||||
|
tempMapCallback({ artifactMap, sourceRangeMap })
|
||||||
|
|
||||||
|
engineCommandManager.endSession()
|
||||||
|
return _programMemory
|
||||||
|
}
|
||||||
|
|
||||||
|
export const _executor = async (
|
||||||
|
node: Program,
|
||||||
|
programMemory: ProgramMemory = { root: {}, return: null },
|
||||||
|
engineCommandManager: EngineCommandManager,
|
||||||
|
planes: DefaultPlanes
|
||||||
|
): Promise<ProgramMemory> => {
|
||||||
|
try {
|
||||||
|
const memory: ProgramMemory = await execute_wasm(
|
||||||
|
JSON.stringify(node),
|
||||||
|
JSON.stringify(programMemory),
|
||||||
|
engineCommandManager,
|
||||||
|
JSON.stringify(planes)
|
||||||
|
)
|
||||||
|
return memory
|
||||||
|
} catch (e: any) {
|
||||||
|
const parsed: RustKclError = JSON.parse(e.toString())
|
||||||
|
const kclError = new KCLError(
|
||||||
|
parsed.kind,
|
||||||
|
parsed.msg,
|
||||||
|
rangeTypeFix(parsed.sourceRanges)
|
||||||
|
)
|
||||||
|
|
||||||
|
console.log(kclError)
|
||||||
|
throw kclError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const recast = (ast: Program): string => {
|
||||||
|
try {
|
||||||
|
const s: string = recast_wasm(JSON.stringify(ast))
|
||||||
|
return s
|
||||||
|
} catch (e) {
|
||||||
|
// TODO: do something real with the error.
|
||||||
|
console.log('recast error', e)
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function lexer(str: string): Token[] {
|
||||||
|
try {
|
||||||
|
const tokens: Token[] = lexer_wasm(str)
|
||||||
|
return tokens
|
||||||
|
} catch (e) {
|
||||||
|
// TODO: do something real with the error.
|
||||||
|
console.log('lexer error', e)
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const modifyAstForSketch = async (
|
||||||
|
engineCommandManager: EngineCommandManager,
|
||||||
|
ast: Program,
|
||||||
|
variableName: string,
|
||||||
|
currentPlane: string,
|
||||||
|
engineId: string
|
||||||
|
): Promise<Program> => {
|
||||||
|
try {
|
||||||
|
const updatedAst: Program = await modify_ast_for_sketch_wasm(
|
||||||
|
engineCommandManager,
|
||||||
|
JSON.stringify(ast),
|
||||||
|
variableName,
|
||||||
|
JSON.stringify(currentPlane),
|
||||||
|
engineId
|
||||||
|
)
|
||||||
|
|
||||||
|
return updatedAst
|
||||||
|
} catch (e: any) {
|
||||||
|
const parsed: RustKclError = JSON.parse(e.toString())
|
||||||
|
const kclError = new KCLError(
|
||||||
|
parsed.kind,
|
||||||
|
parsed.msg,
|
||||||
|
rangeTypeFix(parsed.sourceRanges)
|
||||||
|
)
|
||||||
|
|
||||||
|
console.log(kclError)
|
||||||
|
throw kclError
|
||||||
|
}
|
||||||
|
}
|
@ -1,19 +1,28 @@
|
|||||||
export const bracket = `// Material: 6061-T6 Aluminum
|
export const bracket = `const sigmaAllow = 15000 // psi
|
||||||
const sigmaAllow = 35000 // psi
|
const width = 11 // inch
|
||||||
const width = 9 // inch
|
|
||||||
const p = 150 // Force on shelf - lbs
|
const p = 150 // Force on shelf - lbs
|
||||||
const distance = 6 // inches
|
const distance = 12 // inches
|
||||||
const FOS = 2
|
const FOS = 2
|
||||||
|
const thickness = sqrt(distance * p * FOS * 6 / ( sigmaAllow * width ))
|
||||||
|
const filletR = thickness * 2
|
||||||
|
const shelfMountL = 9
|
||||||
|
const wallMountL = 8
|
||||||
|
|
||||||
const leg1 = 5 // inches
|
const bracket = startSketchOn('XY')
|
||||||
const leg2 = 8 // inches
|
|> startProfileAt([0, 0], %)
|
||||||
const thickness = sqrt(distance * p * FOS * 6 / sigmaAllow / width) // inches
|
|> line([0, wallMountL], %)
|
||||||
const bracket = startSketchAt([0, 0])
|
|> tangentalArc({
|
||||||
|> line([0, leg1], %)
|
radius: filletR,
|
||||||
|> line([leg2, 0], %)
|
offset: 90
|
||||||
|
}, %)
|
||||||
|
|> line([-shelfMountL, 0], %)
|
||||||
|> line([0, -thickness], %)
|
|> line([0, -thickness], %)
|
||||||
|> line([-leg2 + thickness, 0], %)
|
|> line([shelfMountL, 0], %)
|
||||||
|> line([0, -leg1 + thickness], %)
|
|> tangentalArc({
|
||||||
|
radius: filletR - thickness,
|
||||||
|
offset: -90
|
||||||
|
}, %)
|
||||||
|
|> line([0, -wallMountL], %)
|
||||||
|> close(%)
|
|> close(%)
|
||||||
|> extrude(width, %)
|
|> extrude(width, %)
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ export async function exportSave(data: ArrayBuffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the file.
|
// Write the file.
|
||||||
await writeBinaryFile(filePath, uintArray)
|
await writeBinaryFile(filePath, file.contents)
|
||||||
} else {
|
} else {
|
||||||
// Download the file to the user's computer.
|
// Download the file to the user's computer.
|
||||||
// Now we need to download the files to the user's downloads folder.
|
// Now we need to download the files to the user's downloads folder.
|
||||||
@ -39,6 +39,6 @@ export async function exportSave(data: ArrayBuffer) {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// TODO: do something real with the error.
|
// TODO: do something real with the error.
|
||||||
console.log('export', e)
|
console.log('export error', e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ export async function initializeProjectDirectory(directory: string) {
|
|||||||
try {
|
try {
|
||||||
docDirectory = await documentDir()
|
docDirectory = await documentDir()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log('error', e)
|
||||||
docDirectory = await homeDir() // seems to work better on Linux
|
docDirectory = await homeDir() // seems to work better on Linux
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import { Program } from '../lang/abstractSyntaxTreeTypes'
|
import { Program, ProgramMemory, _executor, SourceRange } from '../lang/wasm'
|
||||||
import { ProgramMemory, _executor } from '../lang/executor'
|
|
||||||
import {
|
import {
|
||||||
EngineCommandManager,
|
EngineCommandManager,
|
||||||
EngineCommand,
|
EngineCommand,
|
||||||
} from '../lang/std/engineConnection'
|
} from '../lang/std/engineConnection'
|
||||||
import { SourceRange } from 'lang/executor'
|
import { Models } from '@kittycad/lib'
|
||||||
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
|
|
||||||
|
type WebSocketResponse = Models['OkWebSocketResponseData_type']
|
||||||
|
|
||||||
class MockEngineCommandManager {
|
class MockEngineCommandManager {
|
||||||
constructor(mockParams: {
|
constructor(mockParams: {
|
||||||
@ -23,7 +25,13 @@ class MockEngineCommandManager {
|
|||||||
range: SourceRange
|
range: SourceRange
|
||||||
command: EngineCommand
|
command: EngineCommand
|
||||||
}): Promise<any> {
|
}): Promise<any> {
|
||||||
return Promise.resolve()
|
const response: WebSocketResponse = {
|
||||||
|
type: 'modeling',
|
||||||
|
data: {
|
||||||
|
modeling_response: { type: 'empty' },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return Promise.resolve(JSON.stringify(response))
|
||||||
}
|
}
|
||||||
sendModelingCommandFromWasm(
|
sendModelingCommandFromWasm(
|
||||||
id: string,
|
id: string,
|
||||||
@ -57,7 +65,11 @@ export async function enginelessExecutor(
|
|||||||
}) as any as EngineCommandManager
|
}) as any as EngineCommandManager
|
||||||
await mockEngineCommandManager.waitForReady
|
await mockEngineCommandManager.waitForReady
|
||||||
mockEngineCommandManager.startNewSession()
|
mockEngineCommandManager.startNewSession()
|
||||||
const programMemory = await _executor(ast, pm, mockEngineCommandManager)
|
const programMemory = await _executor(ast, pm, mockEngineCommandManager, {
|
||||||
|
xy: uuidv4(),
|
||||||
|
yz: uuidv4(),
|
||||||
|
xz: uuidv4(),
|
||||||
|
})
|
||||||
await mockEngineCommandManager.waitForAllCommands()
|
await mockEngineCommandManager.waitForAllCommands()
|
||||||
return programMemory
|
return programMemory
|
||||||
}
|
}
|
||||||
@ -66,15 +78,21 @@ export async function executor(
|
|||||||
ast: Program,
|
ast: Program,
|
||||||
pm: ProgramMemory = { root: {}, return: null }
|
pm: ProgramMemory = { root: {}, return: null }
|
||||||
): Promise<ProgramMemory> {
|
): Promise<ProgramMemory> {
|
||||||
const engineCommandManager = new EngineCommandManager({
|
const engineCommandManager = new EngineCommandManager()
|
||||||
|
engineCommandManager.start({
|
||||||
setIsStreamReady: () => {},
|
setIsStreamReady: () => {},
|
||||||
setMediaStream: () => {},
|
setMediaStream: () => {},
|
||||||
width: 100,
|
width: 0,
|
||||||
height: 100,
|
height: 0,
|
||||||
|
executeCode: () => {},
|
||||||
})
|
})
|
||||||
await engineCommandManager.waitForReady
|
await engineCommandManager.waitForReady
|
||||||
engineCommandManager.startNewSession()
|
engineCommandManager.startNewSession()
|
||||||
const programMemory = await _executor(ast, pm, engineCommandManager)
|
const programMemory = await _executor(ast, pm, engineCommandManager, {
|
||||||
|
xy: uuidv4(),
|
||||||
|
yz: uuidv4(),
|
||||||
|
xz: uuidv4(),
|
||||||
|
})
|
||||||
await engineCommandManager.waitForAllCommands(ast, programMemory)
|
await engineCommandManager.waitForAllCommands(ast, programMemory)
|
||||||
return programMemory
|
return programMemory
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { isOverlap, roundOff } from './utils'
|
import { isOverlap, roundOff } from './utils'
|
||||||
import { SourceRange } from '../lang/executor'
|
import { SourceRange } from '../lang/wasm'
|
||||||
|
|
||||||
describe('testing isOverlapping', () => {
|
describe('testing isOverlapping', () => {
|
||||||
testBothOrders([0, 3], [3, 10])
|
testBothOrders([0, 3], [3, 10])
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { SourceRange } from '../lang/executor'
|
import { SourceRange } from '../lang/wasm'
|
||||||
|
|
||||||
export function isOverlap(a: SourceRange, b: SourceRange) {
|
export function isOverlap(a: SourceRange, b: SourceRange) {
|
||||||
const [startingRange, secondRange] = a[0] < b[0] ? [a, b] : [b, a]
|
const [startingRange, secondRange] = a[0] < b[0] ? [a, b] : [b, a]
|
||||||
|
@ -2,6 +2,7 @@ import { assign, createMachine } from 'xstate'
|
|||||||
import { CommandBarMeta } from '../lib/commands'
|
import { CommandBarMeta } from '../lib/commands'
|
||||||
import { Themes, getSystemTheme, setThemeClass } from '../lib/theme'
|
import { Themes, getSystemTheme, setThemeClass } from '../lib/theme'
|
||||||
import { CameraSystem, cameraSystems } from 'lib/cameraControls'
|
import { CameraSystem, cameraSystems } from 'lib/cameraControls'
|
||||||
|
import { Models } from '@kittycad/lib'
|
||||||
|
|
||||||
export const DEFAULT_PROJECT_NAME = 'project-$nnn'
|
export const DEFAULT_PROJECT_NAME = 'project-$nnn'
|
||||||
|
|
||||||
@ -11,11 +12,11 @@ export enum UnitSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const baseUnits = {
|
export const baseUnits = {
|
||||||
imperial: ['in', 'ft'],
|
imperial: ['in', 'ft', 'yd'],
|
||||||
metric: ['mm', 'cm', 'm'],
|
metric: ['mm', 'cm', 'm'],
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export type BaseUnit = 'in' | 'ft' | 'mm' | 'cm' | 'm'
|
export type BaseUnit = Models['UnitLength_type']
|
||||||
|
|
||||||
export const baseUnitsUnion = Object.values(baseUnits).flatMap((v) => v)
|
export const baseUnitsUnion = Object.values(baseUnits).flatMap((v) => v)
|
||||||
|
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
import { faArrowRight, faXmark } from '@fortawesome/free-solid-svg-icons'
|
import { faArrowRight, faXmark } from '@fortawesome/free-solid-svg-icons'
|
||||||
import { ActionButton } from '../../components/ActionButton'
|
import { ActionButton } from '../../components/ActionButton'
|
||||||
import { onboardingPaths, useDismiss, useNextClick } from '.'
|
import {
|
||||||
|
ONBOARDING_PROJECT_NAME,
|
||||||
|
onboardingPaths,
|
||||||
|
useDismiss,
|
||||||
|
useNextClick,
|
||||||
|
} from '.'
|
||||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
||||||
import { Themes, getSystemTheme } from 'lib/theme'
|
import { Themes, getSystemTheme } from 'lib/theme'
|
||||||
import { bracket } from 'lib/exampleKcl'
|
import { bracket } from 'lib/exampleKcl'
|
||||||
@ -25,14 +30,20 @@ function OnboardingWithNewFile() {
|
|||||||
}))
|
}))
|
||||||
const {
|
const {
|
||||||
settings: {
|
settings: {
|
||||||
context: { defaultDirectory, defaultProjectName },
|
context: { defaultDirectory },
|
||||||
},
|
},
|
||||||
} = useGlobalStateContext()
|
} = useGlobalStateContext()
|
||||||
|
|
||||||
async function createAndOpenNewProject() {
|
async function createAndOpenNewProject() {
|
||||||
const projects = await getProjectsInDir(defaultDirectory)
|
const projects = await getProjectsInDir(defaultDirectory)
|
||||||
const nextIndex = await getNextProjectIndex(defaultProjectName, projects)
|
const nextIndex = await getNextProjectIndex(
|
||||||
const name = interpolateProjectNameWithIndex(defaultProjectName, nextIndex)
|
ONBOARDING_PROJECT_NAME,
|
||||||
|
projects
|
||||||
|
)
|
||||||
|
const name = interpolateProjectNameWithIndex(
|
||||||
|
ONBOARDING_PROJECT_NAME,
|
||||||
|
nextIndex
|
||||||
|
)
|
||||||
const newFile = await createNewProject(defaultDirectory + '/' + name)
|
const newFile = await createNewProject(defaultDirectory + '/' + name)
|
||||||
navigate(`${paths.FILE}/${encodeURIComponent(newFile.path)}`)
|
navigate(`${paths.FILE}/${encodeURIComponent(newFile.path)}`)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { useHotkeys } from 'react-hotkeys-hook'
|
import { useHotkeys } from 'react-hotkeys-hook'
|
||||||
import { Outlet, useRouteLoaderData, useNavigate } from 'react-router-dom'
|
import { Outlet, useNavigate } from 'react-router-dom'
|
||||||
import Introduction from './Introduction'
|
import Introduction from './Introduction'
|
||||||
import Camera from './Camera'
|
import Camera from './Camera'
|
||||||
import Sketching from './Sketching'
|
import Sketching from './Sketching'
|
||||||
@ -15,7 +15,10 @@ import UserMenu from './UserMenu'
|
|||||||
import ProjectMenu from './ProjectMenu'
|
import ProjectMenu from './ProjectMenu'
|
||||||
import Export from './Export'
|
import Export from './Export'
|
||||||
import FutureWork from './FutureWork'
|
import FutureWork from './FutureWork'
|
||||||
import { IndexLoaderData, paths } from 'Router'
|
import { paths } from 'Router'
|
||||||
|
import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath'
|
||||||
|
|
||||||
|
export const ONBOARDING_PROJECT_NAME = 'Tutorial Project $nn'
|
||||||
|
|
||||||
export const onboardingPaths = {
|
export const onboardingPaths = {
|
||||||
INDEX: '/',
|
INDEX: '/',
|
||||||
@ -86,29 +89,23 @@ export const onboardingRoutes = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
export function useNextClick(newStatus: string) {
|
export function useNextClick(newStatus: string) {
|
||||||
|
const filePath = useAbsoluteFilePath()
|
||||||
const {
|
const {
|
||||||
settings: { send },
|
settings: { send },
|
||||||
} = useGlobalStateContext()
|
} = useGlobalStateContext()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const { project } = useRouteLoaderData(paths.FILE) as IndexLoaderData
|
|
||||||
|
|
||||||
return useCallback(() => {
|
return useCallback(() => {
|
||||||
send({
|
send({
|
||||||
type: 'Set Onboarding Status',
|
type: 'Set Onboarding Status',
|
||||||
data: { onboardingStatus: newStatus },
|
data: { onboardingStatus: newStatus },
|
||||||
})
|
})
|
||||||
navigate(
|
navigate(filePath + paths.ONBOARDING.INDEX.slice(0, -1) + newStatus)
|
||||||
paths.FILE +
|
}, [filePath, newStatus, send, navigate])
|
||||||
'/' +
|
|
||||||
encodeURIComponent(project?.path || 'new') +
|
|
||||||
paths.ONBOARDING.INDEX.slice(0, -1) +
|
|
||||||
newStatus
|
|
||||||
)
|
|
||||||
}, [project, newStatus, send, navigate])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useDismiss() {
|
export function useDismiss() {
|
||||||
const routeData = useRouteLoaderData(paths.FILE) as IndexLoaderData
|
const filePath = useAbsoluteFilePath()
|
||||||
const {
|
const {
|
||||||
settings: { send },
|
settings: { send },
|
||||||
} = useGlobalStateContext()
|
} = useGlobalStateContext()
|
||||||
@ -119,10 +116,8 @@ export function useDismiss() {
|
|||||||
type: 'Set Onboarding Status',
|
type: 'Set Onboarding Status',
|
||||||
data: { onboardingStatus: 'dismissed' },
|
data: { onboardingStatus: 'dismissed' },
|
||||||
})
|
})
|
||||||
navigate(
|
navigate(filePath)
|
||||||
paths.FILE + '/' + encodeURIComponent(routeData?.project?.path || 'new')
|
}, [send, navigate, filePath])
|
||||||
)
|
|
||||||
}, [send, navigate, routeData])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Onboarding = () => {
|
const Onboarding = () => {
|
||||||
|
@ -24,11 +24,19 @@ import {
|
|||||||
} from 'lib/cameraControls'
|
} from 'lib/cameraControls'
|
||||||
import { UnitSystem } from 'machines/settingsMachine'
|
import { UnitSystem } from 'machines/settingsMachine'
|
||||||
import { useDotDotSlash } from 'hooks/useDotDotSlash'
|
import { useDotDotSlash } from 'hooks/useDotDotSlash'
|
||||||
|
import {
|
||||||
|
createNewProject,
|
||||||
|
getNextProjectIndex,
|
||||||
|
getProjectsInDir,
|
||||||
|
interpolateProjectNameWithIndex,
|
||||||
|
} from 'lib/tauriFS'
|
||||||
|
import { ONBOARDING_PROJECT_NAME } from './Onboarding'
|
||||||
|
|
||||||
export const Settings = () => {
|
export const Settings = () => {
|
||||||
const loaderData = useRouteLoaderData(paths.FILE) as IndexLoaderData
|
const loaderData = useRouteLoaderData(paths.FILE) as IndexLoaderData
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
|
const isFileSettings = location.pathname.includes(paths.FILE)
|
||||||
const dotDotSlash = useDotDotSlash()
|
const dotDotSlash = useDotDotSlash()
|
||||||
useHotkeys('esc', () => navigate(dotDotSlash()))
|
useHotkeys('esc', () => navigate(dotDotSlash()))
|
||||||
const {
|
const {
|
||||||
@ -63,6 +71,33 @@ export const Settings = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function restartOnboarding() {
|
||||||
|
send({
|
||||||
|
type: 'Set Onboarding Status',
|
||||||
|
data: { onboardingStatus: '' },
|
||||||
|
})
|
||||||
|
|
||||||
|
if (isFileSettings) {
|
||||||
|
navigate(dotDotSlash(1) + paths.ONBOARDING.INDEX)
|
||||||
|
} else {
|
||||||
|
createAndOpenNewProject()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createAndOpenNewProject() {
|
||||||
|
const projects = await getProjectsInDir(defaultDirectory)
|
||||||
|
const nextIndex = await getNextProjectIndex(
|
||||||
|
ONBOARDING_PROJECT_NAME,
|
||||||
|
projects
|
||||||
|
)
|
||||||
|
const name = interpolateProjectNameWithIndex(
|
||||||
|
ONBOARDING_PROJECT_NAME,
|
||||||
|
nextIndex
|
||||||
|
)
|
||||||
|
const newFile = await createNewProject(defaultDirectory + '/' + name)
|
||||||
|
navigate(`${paths.FILE}/${encodeURIComponent(newFile.path)}`)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fixed inset-0 z-40 overflow-auto body-bg">
|
<div className="fixed inset-0 z-40 overflow-auto body-bg">
|
||||||
<AppHeader showToolbar={false} project={loaderData?.project}>
|
<AppHeader showToolbar={false} project={loaderData?.project}>
|
||||||
@ -257,26 +292,18 @@ export const Settings = () => {
|
|||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</SettingsSection>
|
</SettingsSection>
|
||||||
{location.pathname.includes(paths.FILE) && (
|
|
||||||
<SettingsSection
|
<SettingsSection
|
||||||
title="Onboarding"
|
title="Onboarding"
|
||||||
description="Replay the onboarding process"
|
description="Replay the onboarding process"
|
||||||
>
|
>
|
||||||
<ActionButton
|
<ActionButton
|
||||||
Element="button"
|
Element="button"
|
||||||
onClick={() => {
|
onClick={restartOnboarding}
|
||||||
send({
|
|
||||||
type: 'Set Onboarding Status',
|
|
||||||
data: { onboardingStatus: '' },
|
|
||||||
})
|
|
||||||
navigate(dotDotSlash(1) + paths.ONBOARDING.INDEX)
|
|
||||||
}}
|
|
||||||
icon={{ icon: faArrowRotateBack }}
|
icon={{ icon: faArrowRotateBack }}
|
||||||
>
|
>
|
||||||
Replay Onboarding
|
Replay Onboarding
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
</SettingsSection>
|
</SettingsSection>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -1,24 +1,27 @@
|
|||||||
import { create } from 'zustand'
|
import { create } from 'zustand'
|
||||||
import { persist } from 'zustand/middleware'
|
import { persist } from 'zustand/middleware'
|
||||||
import { addLineHighlight, EditorView } from './editor/highlightextension'
|
import { addLineHighlight, EditorView } from './editor/highlightextension'
|
||||||
import { parser_wasm } from './lang/abstractSyntaxTree'
|
|
||||||
import { Program } from './lang/abstractSyntaxTreeTypes'
|
|
||||||
import { getNodeFromPath } from './lang/queryAst'
|
|
||||||
import { enginelessExecutor } from './lib/testHelpers'
|
|
||||||
import {
|
import {
|
||||||
|
parse,
|
||||||
|
Program,
|
||||||
|
_executor,
|
||||||
|
recast,
|
||||||
ProgramMemory,
|
ProgramMemory,
|
||||||
Position,
|
Position,
|
||||||
PathToNode,
|
PathToNode,
|
||||||
Rotation,
|
Rotation,
|
||||||
SourceRange,
|
SourceRange,
|
||||||
} from './lang/executor'
|
} from './lang/wasm'
|
||||||
import { recast } from './lang/recast'
|
import { getNodeFromPath } from './lang/queryAst'
|
||||||
|
import { enginelessExecutor } from './lib/testHelpers'
|
||||||
import { EditorSelection } from '@codemirror/state'
|
import { EditorSelection } from '@codemirror/state'
|
||||||
import { EngineCommandManager } from './lang/std/engineConnection'
|
import { EngineCommandManager } from './lang/std/engineConnection'
|
||||||
import { KCLError } from './lang/errors'
|
import { KCLError } from './lang/errors'
|
||||||
import { deferExecution } from 'lib/utils'
|
import { deferExecution } from 'lib/utils'
|
||||||
import { _executor } from './lang/executor'
|
|
||||||
import { bracket } from 'lib/exampleKcl'
|
import { bracket } from 'lib/exampleKcl'
|
||||||
|
import { engineCommandManager } from './lang/std/engineConnection'
|
||||||
|
import { DefaultPlanes } from './wasm-lib/kcl/bindings/DefaultPlanes'
|
||||||
|
import { initDefaultPlanes } from './hooks/useAppMode'
|
||||||
|
|
||||||
export type Selection = {
|
export type Selection = {
|
||||||
type: 'default' | 'line-end' | 'line-mid'
|
type: 'default' | 'line-end' | 'line-mid'
|
||||||
@ -156,14 +159,12 @@ export interface StoreState {
|
|||||||
code: string
|
code: string
|
||||||
setCode: (code: string) => void
|
setCode: (code: string) => void
|
||||||
deferredSetCode: (code: string) => void
|
deferredSetCode: (code: string) => void
|
||||||
executeCode: (code?: string) => void
|
executeCode: (code?: string, force?: boolean) => void
|
||||||
formatCode: () => void
|
formatCode: () => void
|
||||||
programMemory: ProgramMemory
|
programMemory: ProgramMemory
|
||||||
setProgramMemory: (programMemory: ProgramMemory) => void
|
setProgramMemory: (programMemory: ProgramMemory) => void
|
||||||
isShiftDown: boolean
|
isShiftDown: boolean
|
||||||
setIsShiftDown: (isShiftDown: boolean) => void
|
setIsShiftDown: (isShiftDown: boolean) => void
|
||||||
engineCommandManager?: EngineCommandManager
|
|
||||||
setEngineCommandManager: (engineCommandManager: EngineCommandManager) => void
|
|
||||||
mediaStream?: MediaStream
|
mediaStream?: MediaStream
|
||||||
setMediaStream: (mediaStream: MediaStream) => void
|
setMediaStream: (mediaStream: MediaStream) => void
|
||||||
isStreamReady: boolean
|
isStreamReady: boolean
|
||||||
@ -183,6 +184,10 @@ export interface StoreState {
|
|||||||
}) => void
|
}) => void
|
||||||
isExecuting: boolean
|
isExecuting: boolean
|
||||||
setIsExecuting: (isExecuting: boolean) => void
|
setIsExecuting: (isExecuting: boolean) => void
|
||||||
|
defaultPlanes: DefaultPlanes | null
|
||||||
|
setDefaultPlanes: (defaultPlanes: DefaultPlanes) => void
|
||||||
|
currentPlane: string | null
|
||||||
|
setCurrentPlane: (currentPlane: string) => void
|
||||||
|
|
||||||
showHomeMenu: boolean
|
showHomeMenu: boolean
|
||||||
setHomeShowMenu: (showMenu: boolean) => void
|
setHomeShowMenu: (showMenu: boolean) => void
|
||||||
@ -222,11 +227,22 @@ export const useStore = create<StoreState>()(
|
|||||||
editorView.dispatch({ effects: addLineHighlight.of(selection) })
|
editorView.dispatch({ effects: addLineHighlight.of(selection) })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
executeCode: async (code) => {
|
executeCode: async (code, force) => {
|
||||||
|
if (!get().defaultPlanes) {
|
||||||
|
let defaultPlanes = await initDefaultPlanes(
|
||||||
|
engineCommandManager,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
if (!defaultPlanes) return
|
||||||
|
get().setDefaultPlanes(defaultPlanes)
|
||||||
|
}
|
||||||
|
|
||||||
const result = await executeCode({
|
const result = await executeCode({
|
||||||
code: code || get().code,
|
code: code || get().code,
|
||||||
lastAst: get().ast,
|
lastAst: get().ast,
|
||||||
engineCommandManager: get().engineCommandManager,
|
engineCommandManager: engineCommandManager,
|
||||||
|
defaultPlanes: get().defaultPlanes!,
|
||||||
|
force,
|
||||||
})
|
})
|
||||||
if (!result.isChange) {
|
if (!result.isChange) {
|
||||||
return
|
return
|
||||||
@ -332,13 +348,20 @@ export const useStore = create<StoreState>()(
|
|||||||
executeAst: async (ast) => {
|
executeAst: async (ast) => {
|
||||||
const _ast = ast || get().ast
|
const _ast = ast || get().ast
|
||||||
if (!get().isStreamReady) return
|
if (!get().isStreamReady) return
|
||||||
const engineCommandManager = get().engineCommandManager!
|
if (!get().defaultPlanes) {
|
||||||
if (!engineCommandManager) return
|
let defaultPlanes = await initDefaultPlanes(
|
||||||
|
engineCommandManager,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
if (!defaultPlanes) return
|
||||||
|
get().setDefaultPlanes(defaultPlanes)
|
||||||
|
}
|
||||||
|
|
||||||
set({ isExecuting: true })
|
set({ isExecuting: true })
|
||||||
const { logs, errors, programMemory } = await executeAst({
|
const { logs, errors, programMemory } = await executeAst({
|
||||||
ast: _ast,
|
ast: _ast,
|
||||||
engineCommandManager,
|
engineCommandManager,
|
||||||
|
defaultPlanes: get().defaultPlanes!,
|
||||||
})
|
})
|
||||||
set({
|
set({
|
||||||
programMemory,
|
programMemory,
|
||||||
@ -350,13 +373,21 @@ export const useStore = create<StoreState>()(
|
|||||||
executeAstMock: async (ast) => {
|
executeAstMock: async (ast) => {
|
||||||
const _ast = ast || get().ast
|
const _ast = ast || get().ast
|
||||||
if (!get().isStreamReady) return
|
if (!get().isStreamReady) return
|
||||||
const engineCommandManager = get().engineCommandManager!
|
|
||||||
if (!engineCommandManager) return
|
if (!get().defaultPlanes) {
|
||||||
|
let defaultPlanes = await initDefaultPlanes(
|
||||||
|
engineCommandManager,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
if (!defaultPlanes) return
|
||||||
|
get().setDefaultPlanes(defaultPlanes)
|
||||||
|
}
|
||||||
|
|
||||||
const { logs, errors, programMemory } = await executeAst({
|
const { logs, errors, programMemory } = await executeAst({
|
||||||
ast: _ast,
|
ast: _ast,
|
||||||
engineCommandManager,
|
engineCommandManager,
|
||||||
useFakeExecutor: true,
|
useFakeExecutor: true,
|
||||||
|
defaultPlanes: get().defaultPlanes!,
|
||||||
})
|
})
|
||||||
set({
|
set({
|
||||||
programMemory,
|
programMemory,
|
||||||
@ -371,7 +402,7 @@ export const useStore = create<StoreState>()(
|
|||||||
{ focusPath, callBack = () => {} } = {}
|
{ focusPath, callBack = () => {} } = {}
|
||||||
) => {
|
) => {
|
||||||
const newCode = recast(ast)
|
const newCode = recast(ast)
|
||||||
const astWithUpdatedSource = parser_wasm(newCode)
|
const astWithUpdatedSource = parse(newCode)
|
||||||
callBack(astWithUpdatedSource)
|
callBack(astWithUpdatedSource)
|
||||||
|
|
||||||
set({
|
set({
|
||||||
@ -427,7 +458,7 @@ export const useStore = create<StoreState>()(
|
|||||||
},
|
},
|
||||||
formatCode: async () => {
|
formatCode: async () => {
|
||||||
const code = get().code
|
const code = get().code
|
||||||
const ast = parser_wasm(code)
|
const ast = parse(code)
|
||||||
const newCode = recast(ast)
|
const newCode = recast(ast)
|
||||||
set({ code: newCode, ast })
|
set({ code: newCode, ast })
|
||||||
},
|
},
|
||||||
@ -435,8 +466,6 @@ export const useStore = create<StoreState>()(
|
|||||||
setProgramMemory: (programMemory) => set({ programMemory }),
|
setProgramMemory: (programMemory) => set({ programMemory }),
|
||||||
isShiftDown: false,
|
isShiftDown: false,
|
||||||
setIsShiftDown: (isShiftDown) => set({ isShiftDown }),
|
setIsShiftDown: (isShiftDown) => set({ isShiftDown }),
|
||||||
setEngineCommandManager: (engineCommandManager) =>
|
|
||||||
set({ engineCommandManager }),
|
|
||||||
setMediaStream: (mediaStream) => set({ mediaStream }),
|
setMediaStream: (mediaStream) => set({ mediaStream }),
|
||||||
isStreamReady: false,
|
isStreamReady: false,
|
||||||
setIsStreamReady: (isStreamReady) => set({ isStreamReady }),
|
setIsStreamReady: (isStreamReady) => set({ isStreamReady }),
|
||||||
@ -454,9 +483,15 @@ export const useStore = create<StoreState>()(
|
|||||||
fileId: '',
|
fileId: '',
|
||||||
setFileId: (fileId) => set({ fileId }),
|
setFileId: (fileId) => set({ fileId }),
|
||||||
streamDimensions: { streamWidth: 1280, streamHeight: 720 },
|
streamDimensions: { streamWidth: 1280, streamHeight: 720 },
|
||||||
setStreamDimensions: (streamDimensions) => set({ streamDimensions }),
|
setStreamDimensions: (streamDimensions) => {
|
||||||
|
set({ streamDimensions })
|
||||||
|
},
|
||||||
isExecuting: false,
|
isExecuting: false,
|
||||||
setIsExecuting: (isExecuting) => set({ isExecuting }),
|
setIsExecuting: (isExecuting) => set({ isExecuting }),
|
||||||
|
defaultPlanes: null,
|
||||||
|
setDefaultPlanes: (defaultPlanes) => set({ defaultPlanes }),
|
||||||
|
currentPlane: null,
|
||||||
|
setCurrentPlane: (currentPlane) => set({ currentPlane }),
|
||||||
|
|
||||||
// tauri specific app settings
|
// tauri specific app settings
|
||||||
defaultDir: {
|
defaultDir: {
|
||||||
@ -516,10 +551,14 @@ async function executeCode({
|
|||||||
engineCommandManager,
|
engineCommandManager,
|
||||||
code,
|
code,
|
||||||
lastAst,
|
lastAst,
|
||||||
|
defaultPlanes,
|
||||||
|
force,
|
||||||
}: {
|
}: {
|
||||||
code: string
|
code: string
|
||||||
lastAst: Program
|
lastAst: Program
|
||||||
engineCommandManager?: EngineCommandManager
|
engineCommandManager: EngineCommandManager
|
||||||
|
defaultPlanes: DefaultPlanes
|
||||||
|
force?: boolean
|
||||||
}): Promise<
|
}): Promise<
|
||||||
| {
|
| {
|
||||||
logs: string[]
|
logs: string[]
|
||||||
@ -532,14 +571,14 @@ async function executeCode({
|
|||||||
> {
|
> {
|
||||||
let ast: Program
|
let ast: Program
|
||||||
try {
|
try {
|
||||||
ast = parser_wasm(code)
|
ast = parse(code)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
let errors: KCLError[] = []
|
let errors: KCLError[] = []
|
||||||
let logs: string[] = [JSON.stringify(e)]
|
let logs: string[] = [JSON.stringify(e)]
|
||||||
if (e instanceof KCLError) {
|
if (e instanceof KCLError) {
|
||||||
errors = [e]
|
errors = [e]
|
||||||
logs = []
|
logs = []
|
||||||
if (e.msg === 'file is empty') engineCommandManager?.endSession()
|
if (e.msg === 'file is empty') engineCommandManager.endSession()
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
isChange: true,
|
isChange: true,
|
||||||
@ -562,12 +601,13 @@ async function executeCode({
|
|||||||
}
|
}
|
||||||
// Check if the ast we have is equal to the ast in the storage.
|
// Check if the ast we have is equal to the ast in the storage.
|
||||||
// If it is, we don't need to update the ast.
|
// If it is, we don't need to update the ast.
|
||||||
if (!engineCommandManager || JSON.stringify(ast) === JSON.stringify(lastAst))
|
if (JSON.stringify(ast) === JSON.stringify(lastAst) && !force)
|
||||||
return { isChange: false }
|
return { isChange: false }
|
||||||
|
|
||||||
const { logs, errors, programMemory } = await executeAst({
|
const { logs, errors, programMemory } = await executeAst({
|
||||||
ast,
|
ast,
|
||||||
engineCommandManager,
|
engineCommandManager,
|
||||||
|
defaultPlanes,
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
ast,
|
ast,
|
||||||
@ -581,10 +621,12 @@ async function executeCode({
|
|||||||
async function executeAst({
|
async function executeAst({
|
||||||
ast,
|
ast,
|
||||||
engineCommandManager,
|
engineCommandManager,
|
||||||
|
defaultPlanes,
|
||||||
useFakeExecutor = false,
|
useFakeExecutor = false,
|
||||||
}: {
|
}: {
|
||||||
ast: Program
|
ast: Program
|
||||||
engineCommandManager: EngineCommandManager
|
engineCommandManager: EngineCommandManager
|
||||||
|
defaultPlanes: DefaultPlanes
|
||||||
useFakeExecutor?: boolean
|
useFakeExecutor?: boolean
|
||||||
}): Promise<{
|
}): Promise<{
|
||||||
logs: string[]
|
logs: string[]
|
||||||
@ -607,7 +649,8 @@ async function executeAst({
|
|||||||
root: defaultProgramMemory,
|
root: defaultProgramMemory,
|
||||||
return: null,
|
return: null,
|
||||||
},
|
},
|
||||||
engineCommandManager
|
engineCommandManager,
|
||||||
|
defaultPlanes
|
||||||
))
|
))
|
||||||
|
|
||||||
await engineCommandManager.waitForAllCommands(ast, programMemory)
|
await engineCommandManager.waitForAllCommands(ast, programMemory)
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
serial-integration = { max-threads = 4 }
|
serial-integration = { max-threads = 4 }
|
||||||
|
|
||||||
[profile.default]
|
[profile.default]
|
||||||
slow-timeout = { period = "10s", terminate-after = 1 }
|
slow-timeout = { period = "60s", terminate-after = 1 }
|
||||||
|
|
||||||
[profile.ci]
|
[profile.ci]
|
||||||
slow-timeout = { period = "60s", terminate-after = 10 }
|
slow-timeout = { period = "120s", terminate-after = 10 }
|
||||||
|
|
||||||
[[profile.default.overrides]]
|
[[profile.default.overrides]]
|
||||||
filter = "test(serial_test_)"
|
filter = "test(serial_test_)"
|
||||||
|
282
src/wasm-lib/Cargo.lock
generated
282
src/wasm-lib/Cargo.lock
generated
@ -64,10 +64,16 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstream"
|
name = "anes"
|
||||||
version = "0.5.0"
|
version = "0.1.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c"
|
checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstream"
|
||||||
|
version = "0.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f6cd65a4b849ace0b7f6daeebcc1a1d111282227ca745458c61dbf670e52a597"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"anstyle-parse",
|
"anstyle-parse",
|
||||||
@ -103,9 +109,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstyle-wincon"
|
name = "anstyle-wincon"
|
||||||
version = "2.1.0"
|
version = "3.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd"
|
checksum = "0238ca56c96dfa37bdf7c373c8886dd591322500aceeeccdb2216fe06dc2f796"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
@ -142,6 +148,17 @@ dependencies = [
|
|||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-recursion"
|
||||||
|
version = "1.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.37",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-trait"
|
name = "async-trait"
|
||||||
version = "0.1.73"
|
version = "0.1.73"
|
||||||
@ -211,13 +228,16 @@ checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bigdecimal"
|
name = "bigdecimal"
|
||||||
version = "0.3.1"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa"
|
checksum = "454bca3db10617b88b566f205ed190aedb0e0e6dd4cad61d3988a72e8c5594cb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"libm",
|
||||||
"num-bigint",
|
"num-bigint",
|
||||||
"num-integer",
|
"num-integer",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -337,6 +357,12 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cast"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.83"
|
version = "1.0.83"
|
||||||
@ -374,6 +400,33 @@ dependencies = [
|
|||||||
"windows-targets 0.48.5",
|
"windows-targets 0.48.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ciborium"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926"
|
||||||
|
dependencies = [
|
||||||
|
"ciborium-io",
|
||||||
|
"ciborium-ll",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ciborium-io"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ciborium-ll"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b"
|
||||||
|
dependencies = [
|
||||||
|
"ciborium-io",
|
||||||
|
"half 1.8.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clang-sys"
|
name = "clang-sys"
|
||||||
version = "1.6.1"
|
version = "1.6.1"
|
||||||
@ -387,9 +440,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.4.4"
|
version = "4.4.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b1d7b8d5ec32af0fadc644bf1fd509a688c2103b185644bb1e29d164e0703136"
|
checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap_builder",
|
"clap_builder",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
@ -397,9 +450,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_builder"
|
name = "clap_builder"
|
||||||
version = "4.4.4"
|
version = "4.4.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5179bb514e4d7c2051749d8fcefa2ed6d06a9f4e6d69faf3805f5d80b8cf8d56"
|
checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstream",
|
"anstream",
|
||||||
"anstyle",
|
"anstyle",
|
||||||
@ -507,6 +560,42 @@ dependencies = [
|
|||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "criterion"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f"
|
||||||
|
dependencies = [
|
||||||
|
"anes",
|
||||||
|
"cast",
|
||||||
|
"ciborium",
|
||||||
|
"clap",
|
||||||
|
"criterion-plot",
|
||||||
|
"is-terminal",
|
||||||
|
"itertools 0.10.5",
|
||||||
|
"num-traits",
|
||||||
|
"once_cell",
|
||||||
|
"oorandom",
|
||||||
|
"plotters",
|
||||||
|
"rayon",
|
||||||
|
"regex",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
"serde_json",
|
||||||
|
"tinytemplate",
|
||||||
|
"walkdir",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "criterion-plot"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1"
|
||||||
|
dependencies = [
|
||||||
|
"cast",
|
||||||
|
"itertools 0.10.5",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-channel"
|
name = "crossbeam-channel"
|
||||||
version = "0.5.8"
|
version = "0.5.8"
|
||||||
@ -606,6 +695,20 @@ dependencies = [
|
|||||||
"syn 2.0.37",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "derive-docs"
|
||||||
|
version = "0.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c357dec14992ba88803535217ed83d6f6cd80efcb8fa8e3f8a30a9b84fadc1c7"
|
||||||
|
dependencies = [
|
||||||
|
"convert_case",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"serde",
|
||||||
|
"serde_tokenstream",
|
||||||
|
"syn 2.0.37",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "diff"
|
name = "diff"
|
||||||
version = "0.1.13"
|
version = "0.1.13"
|
||||||
@ -699,9 +802,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "expectorate"
|
name = "expectorate"
|
||||||
version = "1.0.7"
|
version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "710ab6a2d57038a835d66f78d5af3fa5d27c1ec4682f823b9203c48826cb0591"
|
checksum = "de6f19b25bdfa2747ae775f37cd109c31f1272d4e4c83095be0727840aa1d75f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"console",
|
"console",
|
||||||
"newline-converter",
|
"newline-converter",
|
||||||
@ -716,7 +819,7 @@ checksum = "832a761f35ab3e6664babfbdc6cef35a4860e816ec3916dcfd0882954e98a8a8"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bit_field",
|
"bit_field",
|
||||||
"flume",
|
"flume",
|
||||||
"half",
|
"half 2.2.1",
|
||||||
"lebe",
|
"lebe",
|
||||||
"miniz_oxide",
|
"miniz_oxide",
|
||||||
"rayon-core",
|
"rayon-core",
|
||||||
@ -983,6 +1086,12 @@ dependencies = [
|
|||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "half"
|
||||||
|
version = "1.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "half"
|
name = "half"
|
||||||
version = "2.2.1"
|
version = "2.2.1"
|
||||||
@ -1281,14 +1390,16 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kcl-lib"
|
name = "kcl-lib"
|
||||||
version = "0.1.30"
|
version = "0.1.33"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"async-recursion",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"bson",
|
"bson",
|
||||||
"clap",
|
"clap",
|
||||||
|
"criterion",
|
||||||
"dashmap",
|
"dashmap",
|
||||||
"derive-docs",
|
"derive-docs 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"expectorate",
|
"expectorate",
|
||||||
"futures",
|
"futures",
|
||||||
"itertools 0.11.0",
|
"itertools 0.11.0",
|
||||||
@ -1297,7 +1408,6 @@ dependencies = [
|
|||||||
"lazy_static",
|
"lazy_static",
|
||||||
"parse-display",
|
"parse-display",
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"regex",
|
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"schemars",
|
"schemars",
|
||||||
"serde",
|
"serde",
|
||||||
@ -1311,17 +1421,19 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
|
"winnow",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kittycad"
|
name = "kittycad"
|
||||||
version = "0.2.25"
|
version = "0.2.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d9cf962b1e81a0b4eb923a727e761b40672cbacc7f5f0b75e13579d346352bc7"
|
checksum = "539b323537b877fc8dd130362b8f1af9af8051c19208bb8bfd816ab7c330f2bb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.21.4",
|
"base64 0.21.4",
|
||||||
|
"bigdecimal",
|
||||||
"bytes",
|
"bytes",
|
||||||
"chrono",
|
"chrono",
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
@ -1383,6 +1495,12 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libm"
|
||||||
|
version = "0.2.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linked-hash-map"
|
name = "linked-hash-map"
|
||||||
version = "0.5.6"
|
version = "0.5.6"
|
||||||
@ -1606,10 +1724,16 @@ version = "0.1.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "44d11de466f4a3006fe8a5e7ec84e93b79c70cb992ae0aa0eb631ad2df8abfe2"
|
checksum = "44d11de466f4a3006fe8a5e7ec84e93b79c70cb992ae0aa0eb631ad2df8abfe2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "oorandom"
|
||||||
|
version = "11.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openapitor"
|
name = "openapitor"
|
||||||
version = "0.0.9"
|
version = "0.0.9"
|
||||||
source = "git+https://github.com/KittyCAD/kittycad.rs?branch=main#0d121f6881da91b4a30bee18bbfe50e4a2096073"
|
source = "git+https://github.com/KittyCAD/kittycad.rs?branch=main#fa0345c514fcc9ae6cd74ae35c8e5c2800fec34f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"Inflector",
|
"Inflector",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
@ -1783,14 +1907,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "phonenumber"
|
name = "phonenumber"
|
||||||
version = "0.3.2+8.13.9"
|
version = "0.3.3+8.13.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "34749f64ea9d76f10cdc8a859588b57775f59177c7dd91f744d620bd62982d6f"
|
checksum = "635f3e6288e4f01c049d89332a031bd74f25d64b6fb94703ca966e819488cd06"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"either",
|
"either",
|
||||||
"fnv",
|
"fnv",
|
||||||
"itertools 0.10.5",
|
"itertools 0.11.0",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"nom",
|
"nom",
|
||||||
"quick-xml",
|
"quick-xml",
|
||||||
@ -1798,6 +1922,7 @@ dependencies = [
|
|||||||
"regex-cache",
|
"regex-cache",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
|
"strum",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1839,6 +1964,34 @@ version = "0.3.27"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
|
checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
"plotters-backend",
|
||||||
|
"plotters-svg",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters-backend"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters-svg"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab"
|
||||||
|
dependencies = [
|
||||||
|
"plotters-backend",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "png"
|
name = "png"
|
||||||
version = "0.17.10"
|
version = "0.17.10"
|
||||||
@ -2064,9 +2217,9 @@ checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reqwest"
|
name = "reqwest"
|
||||||
version = "0.11.20"
|
version = "0.11.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1"
|
checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.21.4",
|
"base64 0.21.4",
|
||||||
"bytes",
|
"bytes",
|
||||||
@ -2091,6 +2244,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
|
"system-configuration",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls",
|
"tokio-rustls",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
@ -2696,6 +2850,28 @@ dependencies = [
|
|||||||
"syn 2.0.37",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strum"
|
||||||
|
version = "0.24.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f"
|
||||||
|
dependencies = [
|
||||||
|
"strum_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strum_macros"
|
||||||
|
version = "0.24.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59"
|
||||||
|
dependencies = [
|
||||||
|
"heck",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"rustversion",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.109"
|
version = "1.0.109"
|
||||||
@ -2718,6 +2894,27 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "system-configuration"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 1.3.2",
|
||||||
|
"core-foundation",
|
||||||
|
"system-configuration-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "system-configuration-sys"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9"
|
||||||
|
dependencies = [
|
||||||
|
"core-foundation-sys",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "take_mut"
|
name = "take_mut"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
@ -2784,18 +2981,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.48"
|
version = "1.0.49"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7"
|
checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "1.0.48"
|
version = "1.0.49"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35"
|
checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -2853,6 +3050,16 @@ dependencies = [
|
|||||||
"time-core",
|
"time-core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tinytemplate"
|
||||||
|
version = "1.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tinyvec"
|
name = "tinyvec"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
@ -2910,9 +3117,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-tungstenite"
|
name = "tokio-tungstenite"
|
||||||
version = "0.20.0"
|
version = "0.20.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2b2dbec703c26b00d74844519606ef15d09a7d6857860f84ad223dec002ddea2"
|
checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"log",
|
"log",
|
||||||
@ -3132,9 +3339,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tungstenite"
|
name = "tungstenite"
|
||||||
version = "0.20.0"
|
version = "0.20.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e862a1c4128df0112ab625f55cd5c934bcb4312ba80b39ae4b4835a3fd58e649"
|
checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"bytes",
|
"bytes",
|
||||||
@ -3621,6 +3828,15 @@ version = "0.48.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winnow"
|
||||||
|
version = "0.5.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winreg"
|
name = "winreg"
|
||||||
version = "0.50.0"
|
version = "0.50.0"
|
||||||
|
@ -11,7 +11,7 @@ crate-type = ["cdylib"]
|
|||||||
bson = { version = "2.7.0", features = ["uuid-1", "chrono"] }
|
bson = { version = "2.7.0", features = ["uuid-1", "chrono"] }
|
||||||
gloo-utils = "0.2.0"
|
gloo-utils = "0.2.0"
|
||||||
kcl-lib = { path = "kcl" }
|
kcl-lib = { path = "kcl" }
|
||||||
kittycad = { version = "0.2.25", default-features = false, features = ["js"] }
|
kittycad = { version = "0.2.31", default-features = false, features = ["js"] }
|
||||||
serde_json = "1.0.107"
|
serde_json = "1.0.107"
|
||||||
uuid = { version = "1.4.1", features = ["v4", "js", "serde"] }
|
uuid = { version = "1.4.1", features = ["v4", "js", "serde"] }
|
||||||
wasm-bindgen = "0.2.87"
|
wasm-bindgen = "0.2.87"
|
||||||
@ -20,9 +20,9 @@ wasm-bindgen-futures = "0.4.37"
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
image = "0.24.7"
|
image = "0.24.7"
|
||||||
kittycad = "0.2.25"
|
kittycad = "0.2.31"
|
||||||
pretty_assertions = "1.4.0"
|
pretty_assertions = "1.4.0"
|
||||||
reqwest = { version = "0.11.20", default-features = false }
|
reqwest = { version = "0.11.22", default-features = false }
|
||||||
tokio = { version = "1.32.0", features = ["rt-multi-thread", "macros", "time"] }
|
tokio = { version = "1.32.0", features = ["rt-multi-thread", "macros", "time"] }
|
||||||
twenty-twenty = "0.6.1"
|
twenty-twenty = "0.6.1"
|
||||||
uuid = { version = "1.4.1", features = ["v4", "js", "serde"] }
|
uuid = { version = "1.4.1", features = ["v4", "js", "serde"] }
|
||||||
|
@ -19,6 +19,6 @@ serde_tokenstream = "0.2"
|
|||||||
syn = { version = "2.0.37", features = ["full"] }
|
syn = { version = "2.0.37", features = ["full"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
expectorate = "1.0.7"
|
expectorate = "1.1.0"
|
||||||
openapitor = { git = "https://github.com/KittyCAD/kittycad.rs", branch = "main" }
|
openapitor = { git = "https://github.com/KittyCAD/kittycad.rs", branch = "main" }
|
||||||
pretty_assertions = "1.4.0"
|
pretty_assertions = "1.4.0"
|
||||||
|
@ -79,13 +79,6 @@ fn do_stdlib_inner(
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ast.sig.asyncness.is_some() {
|
|
||||||
errors.push(Error::new_spanned(
|
|
||||||
&ast.sig.fn_token,
|
|
||||||
"stdlib functions must not be async",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ast.sig.unsafety.is_some() {
|
if ast.sig.unsafety.is_some() {
|
||||||
errors.push(Error::new_spanned(
|
errors.push(Error::new_spanned(
|
||||||
&ast.sig.unsafety,
|
&ast.sig.unsafety,
|
||||||
@ -118,6 +111,7 @@ fn do_stdlib_inner(
|
|||||||
let fn_name = &ast.sig.ident;
|
let fn_name = &ast.sig.ident;
|
||||||
let fn_name_str = fn_name.to_string().replace("inner_", "");
|
let fn_name_str = fn_name.to_string().replace("inner_", "");
|
||||||
let fn_name_ident = format_ident!("{}", fn_name_str);
|
let fn_name_ident = format_ident!("{}", fn_name_str);
|
||||||
|
let boxed_fn_name_ident = format_ident!("boxed_{}", fn_name_str);
|
||||||
let _visibility = &ast.vis;
|
let _visibility = &ast.vis;
|
||||||
|
|
||||||
let (summary_text, description_text) = extract_doc_from_attrs(&ast.attrs);
|
let (summary_text, description_text) = extract_doc_from_attrs(&ast.attrs);
|
||||||
@ -204,7 +198,10 @@ fn do_stdlib_inner(
|
|||||||
syn::FnArg::Typed(pat) => pat.ty.as_ref().into_token_stream(),
|
syn::FnArg::Typed(pat) => pat.ty.as_ref().into_token_stream(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let ty_string = ty.to_string().replace('&', "").replace("mut", "").replace(' ', "");
|
let mut ty_string = ty.to_string().replace('&', "").replace("mut", "").replace(' ', "");
|
||||||
|
if ty_string.starts_with("Args") {
|
||||||
|
ty_string = "Args".to_string();
|
||||||
|
}
|
||||||
let ty_string = ty_string.trim().to_string();
|
let ty_string = ty_string.trim().to_string();
|
||||||
let ty_ident = if ty_string.starts_with("Vec<") {
|
let ty_ident = if ty_string.starts_with("Vec<") {
|
||||||
let ty_string = ty_string.trim_start_matches("Vec<").trim_end_matches('>');
|
let ty_string = ty_string.trim_start_matches("Vec<").trim_end_matches('>');
|
||||||
@ -305,6 +302,14 @@ fn do_stdlib_inner(
|
|||||||
#description_doc_comment
|
#description_doc_comment
|
||||||
#const_struct
|
#const_struct
|
||||||
|
|
||||||
|
fn #boxed_fn_name_ident(
|
||||||
|
args: crate::std::Args,
|
||||||
|
) -> std::pin::Pin<
|
||||||
|
Box<dyn std::future::Future<Output = anyhow::Result<crate::executor::MemoryItem, crate::errors::KclError>>>,
|
||||||
|
> {
|
||||||
|
Box::pin(#fn_name_ident(args))
|
||||||
|
}
|
||||||
|
|
||||||
impl #docs_crate::StdLibFn for #name_ident
|
impl #docs_crate::StdLibFn for #name_ident
|
||||||
{
|
{
|
||||||
fn name(&self) -> String {
|
fn name(&self) -> String {
|
||||||
@ -348,7 +353,7 @@ fn do_stdlib_inner(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn std_lib_fn(&self) -> crate::std::StdFn {
|
fn std_lib_fn(&self) -> crate::std::StdFn {
|
||||||
#fn_name_ident
|
#boxed_fn_name_ident
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone_box(&self) -> Box<dyn #docs_crate::StdLibFn> {
|
fn clone_box(&self) -> Box<dyn #docs_crate::StdLibFn> {
|
||||||
|
@ -7,6 +7,18 @@ pub(crate) struct Show {}
|
|||||||
#[allow(non_upper_case_globals, missing_docs)]
|
#[allow(non_upper_case_globals, missing_docs)]
|
||||||
#[doc = "Std lib function: show"]
|
#[doc = "Std lib function: show"]
|
||||||
pub(crate) const Show: Show = Show {};
|
pub(crate) const Show: Show = Show {};
|
||||||
|
fn boxed_show(
|
||||||
|
args: crate::std::Args,
|
||||||
|
) -> std::pin::Pin<
|
||||||
|
Box<
|
||||||
|
dyn std::future::Future<
|
||||||
|
Output = anyhow::Result<crate::executor::MemoryItem, crate::errors::KclError>,
|
||||||
|
>,
|
||||||
|
>,
|
||||||
|
> {
|
||||||
|
Box::pin(show(args))
|
||||||
|
}
|
||||||
|
|
||||||
impl crate::docs::StdLibFn for Show {
|
impl crate::docs::StdLibFn for Show {
|
||||||
fn name(&self) -> String {
|
fn name(&self) -> String {
|
||||||
"show".to_string()
|
"show".to_string()
|
||||||
@ -57,7 +69,7 @@ impl crate::docs::StdLibFn for Show {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn std_lib_fn(&self) -> crate::std::StdFn {
|
fn std_lib_fn(&self) -> crate::std::StdFn {
|
||||||
show
|
boxed_show
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone_box(&self) -> Box<dyn crate::docs::StdLibFn> {
|
fn clone_box(&self) -> Box<dyn crate::docs::StdLibFn> {
|
||||||
|
@ -7,6 +7,18 @@ pub(crate) struct LineTo {}
|
|||||||
#[allow(non_upper_case_globals, missing_docs)]
|
#[allow(non_upper_case_globals, missing_docs)]
|
||||||
#[doc = "Std lib function: lineTo"]
|
#[doc = "Std lib function: lineTo"]
|
||||||
pub(crate) const LineTo: LineTo = LineTo {};
|
pub(crate) const LineTo: LineTo = LineTo {};
|
||||||
|
fn boxed_line_to(
|
||||||
|
args: crate::std::Args,
|
||||||
|
) -> std::pin::Pin<
|
||||||
|
Box<
|
||||||
|
dyn std::future::Future<
|
||||||
|
Output = anyhow::Result<crate::executor::MemoryItem, crate::errors::KclError>,
|
||||||
|
>,
|
||||||
|
>,
|
||||||
|
> {
|
||||||
|
Box::pin(line_to(args))
|
||||||
|
}
|
||||||
|
|
||||||
impl crate::docs::StdLibFn for LineTo {
|
impl crate::docs::StdLibFn for LineTo {
|
||||||
fn name(&self) -> String {
|
fn name(&self) -> String {
|
||||||
"lineTo".to_string()
|
"lineTo".to_string()
|
||||||
@ -65,7 +77,7 @@ impl crate::docs::StdLibFn for LineTo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn std_lib_fn(&self) -> crate::std::StdFn {
|
fn std_lib_fn(&self) -> crate::std::StdFn {
|
||||||
line_to
|
boxed_line_to
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone_box(&self) -> Box<dyn crate::docs::StdLibFn> {
|
fn clone_box(&self) -> Box<dyn crate::docs::StdLibFn> {
|
||||||
|
@ -7,6 +7,18 @@ pub(crate) struct Min {}
|
|||||||
#[allow(non_upper_case_globals, missing_docs)]
|
#[allow(non_upper_case_globals, missing_docs)]
|
||||||
#[doc = "Std lib function: min"]
|
#[doc = "Std lib function: min"]
|
||||||
pub(crate) const Min: Min = Min {};
|
pub(crate) const Min: Min = Min {};
|
||||||
|
fn boxed_min(
|
||||||
|
args: crate::std::Args,
|
||||||
|
) -> std::pin::Pin<
|
||||||
|
Box<
|
||||||
|
dyn std::future::Future<
|
||||||
|
Output = anyhow::Result<crate::executor::MemoryItem, crate::errors::KclError>,
|
||||||
|
>,
|
||||||
|
>,
|
||||||
|
> {
|
||||||
|
Box::pin(min(args))
|
||||||
|
}
|
||||||
|
|
||||||
impl crate::docs::StdLibFn for Min {
|
impl crate::docs::StdLibFn for Min {
|
||||||
fn name(&self) -> String {
|
fn name(&self) -> String {
|
||||||
"min".to_string()
|
"min".to_string()
|
||||||
@ -57,7 +69,7 @@ impl crate::docs::StdLibFn for Min {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn std_lib_fn(&self) -> crate::std::StdFn {
|
fn std_lib_fn(&self) -> crate::std::StdFn {
|
||||||
min
|
boxed_min
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone_box(&self) -> Box<dyn crate::docs::StdLibFn> {
|
fn clone_box(&self) -> Box<dyn crate::docs::StdLibFn> {
|
||||||
|
@ -7,6 +7,18 @@ pub(crate) struct Show {}
|
|||||||
#[allow(non_upper_case_globals, missing_docs)]
|
#[allow(non_upper_case_globals, missing_docs)]
|
||||||
#[doc = "Std lib function: show"]
|
#[doc = "Std lib function: show"]
|
||||||
pub(crate) const Show: Show = Show {};
|
pub(crate) const Show: Show = Show {};
|
||||||
|
fn boxed_show(
|
||||||
|
args: crate::std::Args,
|
||||||
|
) -> std::pin::Pin<
|
||||||
|
Box<
|
||||||
|
dyn std::future::Future<
|
||||||
|
Output = anyhow::Result<crate::executor::MemoryItem, crate::errors::KclError>,
|
||||||
|
>,
|
||||||
|
>,
|
||||||
|
> {
|
||||||
|
Box::pin(show(args))
|
||||||
|
}
|
||||||
|
|
||||||
impl crate::docs::StdLibFn for Show {
|
impl crate::docs::StdLibFn for Show {
|
||||||
fn name(&self) -> String {
|
fn name(&self) -> String {
|
||||||
"show".to_string()
|
"show".to_string()
|
||||||
@ -52,7 +64,7 @@ impl crate::docs::StdLibFn for Show {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn std_lib_fn(&self) -> crate::std::StdFn {
|
fn std_lib_fn(&self) -> crate::std::StdFn {
|
||||||
show
|
boxed_show
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone_box(&self) -> Box<dyn crate::docs::StdLibFn> {
|
fn clone_box(&self) -> Box<dyn crate::docs::StdLibFn> {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "kcl-lib"
|
name = "kcl-lib"
|
||||||
description = "KittyCAD Language"
|
description = "KittyCAD Language"
|
||||||
version = "0.1.30"
|
version = "0.1.33"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
@ -9,21 +9,22 @@ license = "MIT"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = { version = "1.0.75", features = ["backtrace"] }
|
anyhow = { version = "1.0.75", features = ["backtrace"] }
|
||||||
|
async-recursion = "1.0.5"
|
||||||
async-trait = "0.1.73"
|
async-trait = "0.1.73"
|
||||||
clap = { version = "4.4.3", features = ["cargo", "derive", "env", "unicode"], optional = true }
|
clap = { version = "4.4.6", features = ["cargo", "derive", "env", "unicode"], optional = true }
|
||||||
dashmap = "5.5.3"
|
dashmap = "5.5.3"
|
||||||
#derive-docs = { version = "0.1.4" }
|
derive-docs = { version = "0.1.4" }
|
||||||
derive-docs = { path = "../derive-docs" }
|
#derive-docs = { path = "../derive-docs" }
|
||||||
kittycad = { version = "0.2.25", default-features = false, features = ["js"] }
|
kittycad = { version = "0.2.31", default-features = false, features = ["js"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
parse-display = "0.8.2"
|
parse-display = "0.8.2"
|
||||||
regex = "1.7.1"
|
|
||||||
schemars = { version = "0.8", features = ["impl_json_schema", "url", "uuid1"] }
|
schemars = { version = "0.8", features = ["impl_json_schema", "url", "uuid1"] }
|
||||||
serde = { version = "1.0.188", features = ["derive"] }
|
serde = { version = "1.0.188", features = ["derive"] }
|
||||||
serde_json = "1.0.107"
|
serde_json = "1.0.107"
|
||||||
thiserror = "1.0.48"
|
thiserror = "1.0.49"
|
||||||
ts-rs = { version = "7", package = "ts-rs-json-value", features = ["serde-json-impl", "schemars-impl", "uuid-impl"] }
|
ts-rs = { version = "7", package = "ts-rs-json-value", features = ["serde-json-impl", "schemars-impl", "uuid-impl"] }
|
||||||
uuid = { version = "1.4.1", features = ["v4", "js", "serde"] }
|
uuid = { version = "1.4.1", features = ["v4", "js", "serde"] }
|
||||||
|
winnow = "0.5.15"
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
js-sys = { version = "0.3.64" }
|
js-sys = { version = "0.3.64" }
|
||||||
@ -35,7 +36,7 @@ web-sys = { version = "0.3.64", features = ["console"] }
|
|||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
bson = { version = "2.7.0", features = ["uuid-1", "chrono"] }
|
bson = { version = "2.7.0", features = ["uuid-1", "chrono"] }
|
||||||
futures = { version = "0.3.28" }
|
futures = { version = "0.3.28" }
|
||||||
reqwest = { version = "0.11.20", default-features = false }
|
reqwest = { version = "0.11.22", default-features = false }
|
||||||
tokio = { version = "1.32.0", features = ["full"] }
|
tokio = { version = "1.32.0", features = ["full"] }
|
||||||
tokio-tungstenite = { version = "0.20.0", features = ["rustls-tls-native-roots"] }
|
tokio-tungstenite = { version = "0.20.0", features = ["rustls-tls-native-roots"] }
|
||||||
tower-lsp = { version = "0.20.0", features = ["proposed"] }
|
tower-lsp = { version = "0.20.0", features = ["proposed"] }
|
||||||
@ -50,7 +51,12 @@ panic = "abort"
|
|||||||
debug = true
|
debug = true
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
expectorate = "1.0.7"
|
criterion = "0.5.1"
|
||||||
|
expectorate = "1.1.0"
|
||||||
itertools = "0.11.0"
|
itertools = "0.11.0"
|
||||||
pretty_assertions = "1.4.0"
|
pretty_assertions = "1.4.0"
|
||||||
tokio = { version = "1.32.0", features = ["rt-multi-thread", "macros", "time"] }
|
tokio = { version = "1.32.0", features = ["rt-multi-thread", "macros", "time"] }
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "compiler_benchmark"
|
||||||
|
harness = false
|
||||||
|
41
src/wasm-lib/kcl/benches/compiler_benchmark.rs
Normal file
41
src/wasm-lib/kcl/benches/compiler_benchmark.rs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
|
||||||
|
pub fn bench_lex(c: &mut Criterion) {
|
||||||
|
c.bench_function("lex_cube", |b| b.iter(|| lex(CUBE_PROGRAM)));
|
||||||
|
c.bench_function("lex_big_kitt", |b| b.iter(|| lex(KITT_PROGRAM)));
|
||||||
|
c.bench_function("lex_pipes_on_pipes", |b| b.iter(|| lex(PIPES_PROGRAM)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn bench_lex_parse(c: &mut Criterion) {
|
||||||
|
c.bench_function("parse_lex_cube", |b| b.iter(|| lex_and_parse(CUBE_PROGRAM)));
|
||||||
|
c.bench_function("parse_lex_big_kitt", |b| b.iter(|| lex_and_parse(KITT_PROGRAM)));
|
||||||
|
c.bench_function("parse_lex_pipes_on_pipes", |b| b.iter(|| lex_and_parse(PIPES_PROGRAM)));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn lex(program: &str) {
|
||||||
|
black_box(kcl_lib::token::lexer(program));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn lex_and_parse(program: &str) {
|
||||||
|
let tokens = kcl_lib::token::lexer(program);
|
||||||
|
let parser = kcl_lib::parser::Parser::new(tokens);
|
||||||
|
black_box(parser.ast().unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, bench_lex, bench_lex_parse);
|
||||||
|
criterion_main!(benches);
|
||||||
|
|
||||||
|
const KITT_PROGRAM: &str = include_str!("../../tests/executor/inputs/kittycad_svg.kcl");
|
||||||
|
const PIPES_PROGRAM: &str = include_str!("../../tests/executor/inputs/pipes_on_pipes.kcl");
|
||||||
|
const CUBE_PROGRAM: &str = r#"fn cube = (pos, scale) => {
|
||||||
|
const sg = startSketchAt(pos)
|
||||||
|
|> line([0, scale], %)
|
||||||
|
|> line([scale, 0], %)
|
||||||
|
|> line([0, -scale], %)
|
||||||
|
|
||||||
|
return sg
|
||||||
|
}
|
||||||
|
|
||||||
|
const b1 = cube([0,0], 10)
|
||||||
|
const pt1 = b1[0]
|
||||||
|
show(b1)"#;
|
1
src/wasm-lib/kcl/clippy.toml
Normal file
1
src/wasm-lib/kcl/clippy.toml
Normal file
@ -0,0 +1 @@
|
|||||||
|
enum-variant-size-threshold = 48
|
293
src/wasm-lib/kcl/fuzz/Cargo.lock
generated
293
src/wasm-lib/kcl/fuzz/Cargo.lock
generated
@ -44,54 +44,6 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "anstream"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c"
|
|
||||||
dependencies = [
|
|
||||||
"anstyle",
|
|
||||||
"anstyle-parse",
|
|
||||||
"anstyle-query",
|
|
||||||
"anstyle-wincon",
|
|
||||||
"colorchoice",
|
|
||||||
"utf8parse",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "anstyle"
|
|
||||||
version = "1.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "anstyle-parse"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333"
|
|
||||||
dependencies = [
|
|
||||||
"utf8parse",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "anstyle-query"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
|
|
||||||
dependencies = [
|
|
||||||
"windows-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "anstyle-wincon"
|
|
||||||
version = "2.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd"
|
|
||||||
dependencies = [
|
|
||||||
"anstyle",
|
|
||||||
"windows-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.75"
|
version = "1.0.75"
|
||||||
@ -123,6 +75,17 @@ dependencies = [
|
|||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-recursion"
|
||||||
|
version = "1.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.37",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-trait"
|
name = "async-trait"
|
||||||
version = "0.1.73"
|
version = "0.1.73"
|
||||||
@ -131,7 +94,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -179,6 +142,20 @@ version = "0.21.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53"
|
checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bigdecimal"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "454bca3db10617b88b566f205ed190aedb0e0e6dd4cad61d3988a72e8c5594cb"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"libm",
|
||||||
|
"num-bigint",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bincode"
|
name = "bincode"
|
||||||
version = "1.3.3"
|
version = "1.3.3"
|
||||||
@ -284,54 +261,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clap"
|
|
||||||
version = "4.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6"
|
|
||||||
dependencies = [
|
|
||||||
"clap_builder",
|
|
||||||
"clap_derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clap_builder"
|
|
||||||
version = "4.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08"
|
|
||||||
dependencies = [
|
|
||||||
"anstream",
|
|
||||||
"anstyle",
|
|
||||||
"clap_lex",
|
|
||||||
"strsim",
|
|
||||||
"unicase",
|
|
||||||
"unicode-width",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clap_derive"
|
|
||||||
version = "4.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873"
|
|
||||||
dependencies = [
|
|
||||||
"heck",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.31",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clap_lex"
|
|
||||||
version = "0.5.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "colorchoice"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "convert_case"
|
name = "convert_case"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
@ -403,16 +332,14 @@ checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "derive-docs"
|
name = "derive-docs"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5fe5c5ea065cfabc5a7c5e8ed616e369fbf108c4be01e0e5609bc9846a732664"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"convert_case",
|
"convert_case",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_tokenstream",
|
"serde_tokenstream",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -529,7 +456,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -769,11 +696,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kcl-lib"
|
name = "kcl-lib"
|
||||||
version = "0.1.24"
|
version = "0.1.31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"async-recursion",
|
||||||
|
"async-trait",
|
||||||
"bson",
|
"bson",
|
||||||
"clap",
|
|
||||||
"dashmap",
|
"dashmap",
|
||||||
"derive-docs",
|
"derive-docs",
|
||||||
"futures",
|
"futures",
|
||||||
@ -781,7 +709,6 @@ dependencies = [
|
|||||||
"kittycad",
|
"kittycad",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"parse-display",
|
"parse-display",
|
||||||
"regex",
|
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"schemars",
|
"schemars",
|
||||||
"serde",
|
"serde",
|
||||||
@ -794,6 +721,8 @@ dependencies = [
|
|||||||
"uuid",
|
"uuid",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
|
"web-sys",
|
||||||
|
"winnow",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -806,12 +735,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kittycad"
|
name = "kittycad"
|
||||||
version = "0.2.24"
|
version = "0.2.26"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fd2f78e95054c83ab77059fe0237b128e2b241b4b8e9466e452d701c2599f3d3"
|
checksum = "e2623ee601ce203476229df3f9d3a14664cb43e3f7455e9ac8ed91aacaa6163d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64 0.21.3",
|
"base64 0.21.3",
|
||||||
|
"bigdecimal",
|
||||||
"bytes",
|
"bytes",
|
||||||
"chrono",
|
"chrono",
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
@ -850,6 +780,12 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libm"
|
||||||
|
version = "0.2.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linked-hash-map"
|
name = "linked-hash-map"
|
||||||
version = "0.5.6"
|
version = "0.5.6"
|
||||||
@ -942,6 +878,27 @@ dependencies = [
|
|||||||
"minimal-lexical",
|
"minimal-lexical",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-bigint"
|
||||||
|
version = "0.4.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-integer"
|
||||||
|
version = "0.1.45"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.16"
|
version = "0.2.16"
|
||||||
@ -1034,7 +991,7 @@ dependencies = [
|
|||||||
"regex",
|
"regex",
|
||||||
"regex-syntax 0.7.5",
|
"regex-syntax 0.7.5",
|
||||||
"structmeta",
|
"structmeta",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1045,9 +1002,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "phonenumber"
|
name = "phonenumber"
|
||||||
version = "0.3.2+8.13.9"
|
version = "0.3.3+8.13.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "34749f64ea9d76f10cdc8a859588b57775f59177c7dd91f744d620bd62982d6f"
|
checksum = "635f3e6288e4f01c049d89332a031bd74f25d64b6fb94703ca966e819488cd06"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"either",
|
"either",
|
||||||
@ -1060,6 +1017,7 @@ dependencies = [
|
|||||||
"regex-cache",
|
"regex-cache",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
|
"strum",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1080,7 +1038,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1127,9 +1085,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.66"
|
version = "1.0.67"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
|
checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
@ -1342,6 +1300,12 @@ dependencies = [
|
|||||||
"untrusted",
|
"untrusted",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.15"
|
version = "1.0.15"
|
||||||
@ -1359,10 +1323,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "schemars"
|
name = "schemars"
|
||||||
version = "0.8.13"
|
version = "0.8.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "763f8cd0d4c71ed8389c90cb8100cba87e763bd01a8e614d4f0af97bcd50a161"
|
checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"bigdecimal",
|
||||||
"bytes",
|
"bytes",
|
||||||
"chrono",
|
"chrono",
|
||||||
"dyn-clone",
|
"dyn-clone",
|
||||||
@ -1375,9 +1340,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "schemars_derive"
|
name = "schemars_derive"
|
||||||
version = "0.8.13"
|
version = "0.8.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ec0f696e21e10fa546b7ffb1c9672c6de8fbc7a81acf59524386d8639bf12737"
|
checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -1450,7 +1415,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1466,9 +1431,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.105"
|
version = "1.0.107"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360"
|
checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap 2.0.0",
|
"indexmap 2.0.0",
|
||||||
"itoa",
|
"itoa",
|
||||||
@ -1484,7 +1449,7 @@ checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1496,7 +1461,7 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"serde",
|
"serde",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1572,12 +1537,6 @@ version = "0.5.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "strsim"
|
|
||||||
version = "0.10.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "structmeta"
|
name = "structmeta"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@ -1587,7 +1546,7 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"structmeta-derive",
|
"structmeta-derive",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1598,7 +1557,29 @@ checksum = "a60bcaff7397072dca0017d1db428e30d5002e00b6847703e2e42005c95fbe00"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strum"
|
||||||
|
version = "0.24.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f"
|
||||||
|
dependencies = [
|
||||||
|
"strum_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strum_macros"
|
||||||
|
version = "0.24.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59"
|
||||||
|
dependencies = [
|
||||||
|
"heck",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"rustversion",
|
||||||
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1614,9 +1595,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.31"
|
version = "2.0.37"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398"
|
checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -1655,7 +1636,7 @@ checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1728,7 +1709,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1822,7 +1803,7 @@ checksum = "84fd902d4e0b9a4b27f2f440108dc034e1758628a9b702f8ec61ad66355422fa"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1851,7 +1832,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1891,15 +1872,15 @@ dependencies = [
|
|||||||
"Inflector",
|
"Inflector",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
"termcolor",
|
"termcolor",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tungstenite"
|
name = "tungstenite"
|
||||||
version = "0.20.0"
|
version = "0.20.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e862a1c4128df0112ab625f55cd5c934bcb4312ba80b39ae4b4835a3fd58e649"
|
checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"bytes",
|
"bytes",
|
||||||
@ -1921,15 +1902,6 @@ version = "1.16.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
|
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicase"
|
|
||||||
version = "2.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89"
|
|
||||||
dependencies = [
|
|
||||||
"version_check",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-bidi"
|
name = "unicode-bidi"
|
||||||
version = "0.3.13"
|
version = "0.3.13"
|
||||||
@ -1957,12 +1929,6 @@ version = "1.10.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
|
checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-width"
|
|
||||||
version = "0.1.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "untrusted"
|
name = "untrusted"
|
||||||
version = "0.7.1"
|
version = "0.7.1"
|
||||||
@ -1987,12 +1953,6 @@ version = "0.7.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "utf8parse"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
version = "1.4.1"
|
version = "1.4.1"
|
||||||
@ -2046,7 +2006,7 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -2080,7 +2040,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.31",
|
"syn 2.0.37",
|
||||||
"wasm-bindgen-backend",
|
"wasm-bindgen-backend",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
@ -2198,6 +2158,15 @@ version = "0.48.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winnow"
|
||||||
|
version = "0.5.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winreg"
|
name = "winreg"
|
||||||
version = "0.50.0"
|
version = "0.50.0"
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user