Compare commits
48 Commits
franknoiro
...
v0.26.5
Author | SHA1 | Date | |
---|---|---|---|
0b24216dc5 | |||
2d3841bf61 | |||
51a71a180e | |||
1ec25dfe96 | |||
8de29dd461 | |||
b11040c23c | |||
2bc4f076cb | |||
9e1cf90c81 | |||
062fae1e54 | |||
d7660e221c | |||
938e27adac | |||
17b9af2416 | |||
64f0f5b773 | |||
f452f9bf00 | |||
97705234c6 | |||
30dfc167d3 | |||
d8105627c0 | |||
6b7fac3642 | |||
35805916aa | |||
4a4400e979 | |||
efd1f288b9 | |||
0337ab9cff | |||
f0dda692f6 | |||
2ce0c59d08 | |||
393b43d485 | |||
4fbcde8773 | |||
12d444fa69 | |||
683b4488af | |||
e1c1e07046 | |||
984420c155 | |||
7bad60dfa3 | |||
aaca88220c | |||
360384e8c8 | |||
ab2ad1313f | |||
897205acc2 | |||
862ca1124e | |||
d9981d9d7b | |||
8df0581831 | |||
54e6358df1 | |||
daf20a978d | |||
8e64798dda | |||
a1ceb4fa47 | |||
2db8d13051 | |||
aceb8052e2 | |||
62fae1e93b | |||
2abfbb9788 | |||
ad1cd56891 | |||
26951364cf |
@ -4,9 +4,9 @@ set -euo pipefail
|
|||||||
if [[ ! -f "test-results/.last-run.json" ]]; then
|
if [[ ! -f "test-results/.last-run.json" ]]; then
|
||||||
# if no last run artifact, than run plawright normally
|
# if no last run artifact, than run plawright normally
|
||||||
echo "run playwright normally"
|
echo "run playwright normally"
|
||||||
if [[ "$3" == "ubuntu-latest" ]]; then
|
if [[ "$3" == ubuntu-latest* ]]; then
|
||||||
yarn test:playwright:browser:chrome:ubuntu -- --shard=$1/$2 || true
|
yarn test:playwright:browser:chrome:ubuntu -- --shard=$1/$2 || true
|
||||||
elif [[ "$3" == "windows-latest" ]]; then
|
elif [[ "$3" == windows-latest* ]]; then
|
||||||
yarn test:playwright:browser:chrome:windows -- --shard=$1/$2 || true
|
yarn test:playwright:browser:chrome:windows -- --shard=$1/$2 || true
|
||||||
else
|
else
|
||||||
echo "Do not run playwright. Unable to detect os runtime."
|
echo "Do not run playwright. Unable to detect os runtime."
|
||||||
@ -26,9 +26,9 @@ while [[ $retry -le $max_retrys ]]; do
|
|||||||
if [[ $failed_tests -gt 0 ]]; then
|
if [[ $failed_tests -gt 0 ]]; then
|
||||||
echo "retried=true" >>$GITHUB_OUTPUT
|
echo "retried=true" >>$GITHUB_OUTPUT
|
||||||
echo "run playwright with last failed tests and retry $retry"
|
echo "run playwright with last failed tests and retry $retry"
|
||||||
if [[ "$3" == "ubuntu-latest" ]]; then
|
if [[ "$3" == ubuntu-latest* ]]; then
|
||||||
yarn test:playwright:browser:chrome:ubuntu -- --last-failed || true
|
yarn test:playwright:browser:chrome:ubuntu -- --last-failed || true
|
||||||
elif [[ "$3" == "windows-latest" ]]; then
|
elif [[ "$3" == windows-latest* ]]; then
|
||||||
yarn test:playwright:browser:chrome:windows -- --last-failed || true
|
yarn test:playwright:browser:chrome:windows -- --last-failed || true
|
||||||
else
|
else
|
||||||
echo "Do not run playwright. Unable to detect os runtime."
|
echo "Do not run playwright. Unable to detect os runtime."
|
||||||
|
12
.github/ci-cd-scripts/playwright-electron.sh
vendored
@ -4,11 +4,11 @@ set -euo pipefail
|
|||||||
if [[ ! -f "test-results/.last-run.json" ]]; then
|
if [[ ! -f "test-results/.last-run.json" ]]; then
|
||||||
# if no last run artifact, than run plawright normally
|
# if no last run artifact, than run plawright normally
|
||||||
echo "run playwright normally"
|
echo "run playwright normally"
|
||||||
if [[ "$1" == "ubuntu-latest" ]]; then
|
if [[ "$1" == ubuntu-latest* ]]; then
|
||||||
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test:playwright:electron:ubuntu || true
|
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test:playwright:electron:ubuntu || true
|
||||||
elif [[ "$1" == "windows-latest" ]]; then
|
elif [[ "$1" == windows-latest* ]]; then
|
||||||
yarn test:playwright:electron:windows || true
|
yarn test:playwright:electron:windows || true
|
||||||
elif [[ "$1" == "macos-14" ]]; then
|
elif [[ "$1" == macos-14* ]]; then
|
||||||
yarn test:playwright:electron:macos || true
|
yarn test:playwright:electron:macos || true
|
||||||
else
|
else
|
||||||
echo "Do not run playwright. Unable to detect os runtime."
|
echo "Do not run playwright. Unable to detect os runtime."
|
||||||
@ -28,11 +28,11 @@ while [[ $retry -le $max_retrys ]]; do
|
|||||||
if [[ $failed_tests -gt 0 ]]; then
|
if [[ $failed_tests -gt 0 ]]; then
|
||||||
echo "retried=true" >>$GITHUB_OUTPUT
|
echo "retried=true" >>$GITHUB_OUTPUT
|
||||||
echo "run playwright with last failed tests and retry $retry"
|
echo "run playwright with last failed tests and retry $retry"
|
||||||
if [[ "$1" == "ubuntu-latest" ]]; then
|
if [[ "$1" == ubuntu-latest* ]]; then
|
||||||
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test:playwright:electron:ubuntu -- --last-failed || true
|
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test:playwright:electron:ubuntu -- --last-failed || true
|
||||||
elif [[ "$1" == "windows-latest" ]]; then
|
elif [[ "$1" == windows-latest* ]]; then
|
||||||
yarn test:playwright:electron:windows -- --last-failed || true
|
yarn test:playwright:electron:windows -- --last-failed || true
|
||||||
elif [[ "$1" == "macos-14" ]]; then
|
elif [[ "$1" == macos-14* ]]; then
|
||||||
yarn test:playwright:electron:macos -- --last-failed || true
|
yarn test:playwright:electron:macos -- --last-failed || true
|
||||||
else
|
else
|
||||||
echo "Do not run playwright. Unable to detect os runtime."
|
echo "Do not run playwright. Unable to detect os runtime."
|
||||||
|
6
.github/dependabot.yml
vendored
@ -8,21 +8,21 @@ updates:
|
|||||||
- package-ecosystem: 'npm' # See documentation for possible values
|
- package-ecosystem: 'npm' # See documentation for possible values
|
||||||
directory: '/' # Location of package manifests
|
directory: '/' # Location of package manifests
|
||||||
schedule:
|
schedule:
|
||||||
interval: 'daily'
|
interval: 'weekly'
|
||||||
reviewers:
|
reviewers:
|
||||||
- franknoirot
|
- franknoirot
|
||||||
- irev-dev
|
- irev-dev
|
||||||
- package-ecosystem: 'github-actions' # See documentation for possible values
|
- package-ecosystem: 'github-actions' # See documentation for possible values
|
||||||
directory: '/' # Location of package manifests
|
directory: '/' # Location of package manifests
|
||||||
schedule:
|
schedule:
|
||||||
interval: 'daily'
|
interval: 'weekly'
|
||||||
reviewers:
|
reviewers:
|
||||||
- adamchalmers
|
- adamchalmers
|
||||||
- jessfraz
|
- jessfraz
|
||||||
- package-ecosystem: 'cargo' # See documentation for possible values
|
- package-ecosystem: 'cargo' # See documentation for possible values
|
||||||
directory: '/src/wasm-lib/' # Location of package manifests
|
directory: '/src/wasm-lib/' # Location of package manifests
|
||||||
schedule:
|
schedule:
|
||||||
interval: 'daily'
|
interval: 'weekly'
|
||||||
reviewers:
|
reviewers:
|
||||||
- adamchalmers
|
- adamchalmers
|
||||||
- jessfraz
|
- jessfraz
|
||||||
|
13
.github/workflows/build-test-publish-apps.yml
vendored
@ -85,7 +85,7 @@ jobs:
|
|||||||
- name: Prepare electron-builder.yml file for updater test
|
- name: Prepare electron-builder.yml file for updater test
|
||||||
if: ${{ env.CUT_RELEASE_PR == 'true' }}
|
if: ${{ env.CUT_RELEASE_PR == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
yq -i '.publish[0].url = "https://dl.zoo.dev/releases/modeling-app/updater-test-release-notes"' electron-builder.yml
|
yq -i '.publish[0].url = "https://dl.zoo.dev/releases/modeling-app/updater-test"' electron-builder.yml
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
if: ${{ env.CUT_RELEASE_PR == 'true' }}
|
if: ${{ env.CUT_RELEASE_PR == 'true' }}
|
||||||
@ -181,6 +181,7 @@ jobs:
|
|||||||
- name: Build the app (release)
|
- name: Build the app (release)
|
||||||
if: ${{ env.BUILD_RELEASE == 'true' }}
|
if: ${{ env.BUILD_RELEASE == 'true' }}
|
||||||
env:
|
env:
|
||||||
|
PUBLISH_FOR_PULL_REQUEST: true
|
||||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
APPLE_ID: ${{ secrets.APPLE_ID }}
|
||||||
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||||
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||||
@ -360,17 +361,17 @@ jobs:
|
|||||||
run: "ls -R out"
|
run: "ls -R out"
|
||||||
|
|
||||||
- name: Authenticate to Google Cloud
|
- name: Authenticate to Google Cloud
|
||||||
uses: 'google-github-actions/auth@v2.1.6'
|
uses: 'google-github-actions/auth@v2.1.7'
|
||||||
with:
|
with:
|
||||||
credentials_json: '${{ secrets.GOOGLE_CLOUD_DL_SA }}'
|
credentials_json: '${{ secrets.GOOGLE_CLOUD_DL_SA }}'
|
||||||
|
|
||||||
- name: Set up Google Cloud SDK
|
- name: Set up Google Cloud SDK
|
||||||
uses: google-github-actions/setup-gcloud@v2.1.0
|
uses: google-github-actions/setup-gcloud@v2.1.2
|
||||||
with:
|
with:
|
||||||
project_id: ${{ env.GOOGLE_CLOUD_PROJECT_ID }}
|
project_id: ${{ env.GOOGLE_CLOUD_PROJECT_ID }}
|
||||||
|
|
||||||
- name: Upload release files to public bucket
|
- name: Upload release files to public bucket
|
||||||
uses: google-github-actions/upload-cloud-storage@v2.2.0
|
uses: google-github-actions/upload-cloud-storage@v2.2.1
|
||||||
with:
|
with:
|
||||||
path: out
|
path: out
|
||||||
glob: 'Zoo*'
|
glob: 'Zoo*'
|
||||||
@ -378,7 +379,7 @@ jobs:
|
|||||||
destination: ${{ env.BUCKET_DIR }}
|
destination: ${{ env.BUCKET_DIR }}
|
||||||
|
|
||||||
- name: Upload update endpoint to public bucket
|
- name: Upload update endpoint to public bucket
|
||||||
uses: google-github-actions/upload-cloud-storage@v2.2.0
|
uses: google-github-actions/upload-cloud-storage@v2.2.1
|
||||||
with:
|
with:
|
||||||
path: out
|
path: out
|
||||||
glob: 'latest*'
|
glob: 'latest*'
|
||||||
@ -386,7 +387,7 @@ jobs:
|
|||||||
destination: ${{ env.BUCKET_DIR }}
|
destination: ${{ env.BUCKET_DIR }}
|
||||||
|
|
||||||
- name: Upload download endpoint to public bucket
|
- name: Upload download endpoint to public bucket
|
||||||
uses: google-github-actions/upload-cloud-storage@v2.2.0
|
uses: google-github-actions/upload-cloud-storage@v2.2.1
|
||||||
with:
|
with:
|
||||||
path: last_download.json
|
path: last_download.json
|
||||||
destination: ${{ env.BUCKET_DIR }}
|
destination: ${{ env.BUCKET_DIR }}
|
||||||
|
4
.github/workflows/cargo-test.yml
vendored
@ -5,6 +5,8 @@ on:
|
|||||||
paths:
|
paths:
|
||||||
- 'src/wasm-lib/**.rs'
|
- 'src/wasm-lib/**.rs'
|
||||||
- 'src/wasm-lib/**.hbs'
|
- 'src/wasm-lib/**.hbs'
|
||||||
|
- 'src/wasm-lib/**.gen'
|
||||||
|
- 'src/wasm-lib/**.snap'
|
||||||
- '**/Cargo.toml'
|
- '**/Cargo.toml'
|
||||||
- '**/Cargo.lock'
|
- '**/Cargo.lock'
|
||||||
- '**/rust-toolchain.toml'
|
- '**/rust-toolchain.toml'
|
||||||
@ -15,6 +17,8 @@ on:
|
|||||||
paths:
|
paths:
|
||||||
- 'src/wasm-lib/**.rs'
|
- 'src/wasm-lib/**.rs'
|
||||||
- 'src/wasm-lib/**.hbs'
|
- 'src/wasm-lib/**.hbs'
|
||||||
|
- 'src/wasm-lib/**.gen'
|
||||||
|
- 'src/wasm-lib/**.snap'
|
||||||
- '**/Cargo.toml'
|
- '**/Cargo.toml'
|
||||||
- '**/Cargo.lock'
|
- '**/Cargo.lock'
|
||||||
- '**/rust-toolchain.toml'
|
- '**/rust-toolchain.toml'
|
||||||
|
6
.github/workflows/e2e-tests.yml
vendored
@ -39,7 +39,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest]
|
os: [ubuntu-latest-8-cores, windows-latest-8-cores]
|
||||||
shardIndex: [1, 2, 3, 4]
|
shardIndex: [1, 2, 3, 4]
|
||||||
shardTotal: [4]
|
shardTotal: [4]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@ -227,7 +227,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-14]
|
os: [ubuntu-latest-8-cores, windows-latest-8-cores, macos-14-large]
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
needs: check-rust-changes
|
needs: check-rust-changes
|
||||||
@ -287,7 +287,7 @@ jobs:
|
|||||||
brew install gnu-sed
|
brew install gnu-sed
|
||||||
echo "/opt/homebrew/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH
|
echo "/opt/homebrew/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH
|
||||||
- name: Install vector
|
- name: Install vector
|
||||||
if: ${{ !startsWith(matrix.os, 'windows') }}
|
if: ${{ startsWith(matrix.os, 'ubuntu') }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
curl --proto '=https' --tlsv1.2 -sSfL https://sh.vector.dev > /tmp/vector.sh
|
curl --proto '=https' --tlsv1.2 -sSfL https://sh.vector.dev > /tmp/vector.sh
|
||||||
|
25
.github/workflows/static-analysis.yml
vendored
@ -81,6 +81,31 @@ jobs:
|
|||||||
- name: Run codespell
|
- name: Run codespell
|
||||||
run: codespell --config .codespellrc # Edit this file to tweak the typo list and other configuration.
|
run: codespell --config .codespellrc # Edit this file to tweak the typo list and other configuration.
|
||||||
|
|
||||||
|
yarn-unit-test-kcl-samples:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version-file: '.nvmrc'
|
||||||
|
cache: 'yarn'
|
||||||
|
|
||||||
|
- run: yarn install
|
||||||
|
- run: yarn build:wasm
|
||||||
|
|
||||||
|
- run: yarn simpleserver:bg
|
||||||
|
if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }}
|
||||||
|
|
||||||
|
- name: Install Chromium Browser
|
||||||
|
if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }}
|
||||||
|
run: yarn playwright install chromium --with-deps
|
||||||
|
|
||||||
|
- name: run unit tests for kcl samples
|
||||||
|
if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }}
|
||||||
|
run: yarn test:unit:kcl-samples
|
||||||
|
env:
|
||||||
|
VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
|
||||||
|
|
||||||
yarn-unit-test:
|
yarn-unit-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
2
Makefile
@ -19,7 +19,7 @@ $(XSTATE_TYPEGENS): $(TS_SRC)
|
|||||||
yarn xstate typegen 'src/**/*.ts?(x)'
|
yarn xstate typegen 'src/**/*.ts?(x)'
|
||||||
|
|
||||||
public/wasm_lib_bg.wasm: $(WASM_LIB_FILES)
|
public/wasm_lib_bg.wasm: $(WASM_LIB_FILES)
|
||||||
yarn build:wasm-dev
|
yarn build:wasm
|
||||||
|
|
||||||
node_modules: package.json yarn.lock
|
node_modules: package.json yarn.lock
|
||||||
yarn install
|
yarn install
|
||||||
|
@ -110,7 +110,7 @@ Which commands from setup are one off vs need to be run every time?
|
|||||||
The following will need to be run when checking out a new commit and guarantees the build is not stale:
|
The following will need to be run when checking out a new commit and guarantees the build is not stale:
|
||||||
```bash
|
```bash
|
||||||
yarn install
|
yarn install
|
||||||
yarn build:wasm-dev # or yarn build:wasm for slower but more production-like build
|
yarn build:wasm
|
||||||
yarn start # or yarn build:local && yarn serve for slower but more production-like build
|
yarn start # or yarn build:local && yarn serve for slower but more production-like build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -84,9 +84,13 @@ layout: manual
|
|||||||
* [`rem`](kcl/rem)
|
* [`rem`](kcl/rem)
|
||||||
* [`revolve`](kcl/revolve)
|
* [`revolve`](kcl/revolve)
|
||||||
* [`segAng`](kcl/segAng)
|
* [`segAng`](kcl/segAng)
|
||||||
|
* [`segEnd`](kcl/segEnd)
|
||||||
* [`segEndX`](kcl/segEndX)
|
* [`segEndX`](kcl/segEndX)
|
||||||
* [`segEndY`](kcl/segEndY)
|
* [`segEndY`](kcl/segEndY)
|
||||||
* [`segLen`](kcl/segLen)
|
* [`segLen`](kcl/segLen)
|
||||||
|
* [`segStart`](kcl/segStart)
|
||||||
|
* [`segStartX`](kcl/segStartX)
|
||||||
|
* [`segStartY`](kcl/segStartY)
|
||||||
* [`shell`](kcl/shell)
|
* [`shell`](kcl/shell)
|
||||||
* [`sin`](kcl/sin)
|
* [`sin`](kcl/sin)
|
||||||
* [`sqrt`](kcl/sqrt)
|
* [`sqrt`](kcl/sqrt)
|
||||||
|
53
docs/kcl/segEnd.md
Normal file
56
docs/kcl/segStart.md
Normal file
43
docs/kcl/segStartX.md
Normal file
44
docs/kcl/segStartY.md
Normal file
4166
docs/kcl/std.json
@ -632,16 +632,18 @@ test.describe('Editor tests', () => {
|
|||||||
|
|
||||||
await u.waitForAuthSkipAppStart()
|
await u.waitForAuthSkipAppStart()
|
||||||
|
|
||||||
// this test might be brittle as we add and remove functions
|
|
||||||
// but should also be easy to update.
|
|
||||||
// tests clicking on an option, selection the first option
|
// tests clicking on an option, selection the first option
|
||||||
// and arrowing down to an option
|
// and arrowing down to an option
|
||||||
|
|
||||||
await u.codeLocator.click()
|
await u.codeLocator.click()
|
||||||
await page.keyboard.type('sketch001 = start')
|
await page.keyboard.type('sketch001 = start')
|
||||||
|
|
||||||
// expect there to be six auto complete options
|
// expect there to be some auto complete options
|
||||||
await expect(page.locator('.cm-completionLabel')).toHaveCount(8)
|
// exact number depends on the KCL stdlib, so let's just check it's > 0 for now.
|
||||||
|
await expect(async () => {
|
||||||
|
const children = await page.locator('.cm-completionLabel').count()
|
||||||
|
expect(children).toBeGreaterThan(0)
|
||||||
|
}).toPass()
|
||||||
// this makes sure we can accept a completion with click
|
// this makes sure we can accept a completion with click
|
||||||
await page.getByText('startSketchOn').click()
|
await page.getByText('startSketchOn').click()
|
||||||
await page.keyboard.type("'XZ'")
|
await page.keyboard.type("'XZ'")
|
||||||
@ -692,6 +694,9 @@ test.describe('Editor tests', () => {
|
|||||||
.toHaveText(`sketch001 = startSketchOn('XZ')
|
.toHaveText(`sketch001 = startSketchOn('XZ')
|
||||||
|> startProfileAt([3.14, 12], %)
|
|> startProfileAt([3.14, 12], %)
|
||||||
|> xLine(5, %) // lin`)
|
|> xLine(5, %) // lin`)
|
||||||
|
|
||||||
|
// expect there to be no KCL errors
|
||||||
|
await expect(page.locator('.cm-lint-marker-error')).toHaveCount(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('with tab to accept the completion', async ({ page }) => {
|
test('with tab to accept the completion', async ({ page }) => {
|
||||||
@ -985,7 +990,7 @@ test.describe('Editor tests', () => {
|
|||||||
|> extrude(5, %)`)
|
|> extrude(5, %)`)
|
||||||
})
|
})
|
||||||
|
|
||||||
test(
|
test.fixme(
|
||||||
`Can use the import stdlib function on a local OBJ file`,
|
`Can use the import stdlib function on a local OBJ file`,
|
||||||
{ tag: '@electron' },
|
{ tag: '@electron' },
|
||||||
async ({ browserName }, testInfo) => {
|
async ({ browserName }, testInfo) => {
|
||||||
|
@ -26,10 +26,6 @@ test.describe('integrations tests', () => {
|
|||||||
'Creating a new file or switching file while in sketchMode should exit sketchMode',
|
'Creating a new file or switching file while in sketchMode should exit sketchMode',
|
||||||
{ tag: '@electron' },
|
{ tag: '@electron' },
|
||||||
async ({ tronApp, homePage, scene, editor, toolbar }) => {
|
async ({ tronApp, homePage, scene, editor, toolbar }) => {
|
||||||
test.skip(
|
|
||||||
process.platform === 'win32',
|
|
||||||
'windows times out will waiting for the execution indicator?'
|
|
||||||
)
|
|
||||||
await tronApp.initialise({
|
await tronApp.initialise({
|
||||||
fixtures: { homePage, scene, editor, toolbar },
|
fixtures: { homePage, scene, editor, toolbar },
|
||||||
folderSetupFn: async (dir) => {
|
folderSetupFn: async (dir) => {
|
||||||
@ -55,7 +51,6 @@ test.describe('integrations tests', () => {
|
|||||||
sortBy: 'last-modified-desc',
|
sortBy: 'last-modified-desc',
|
||||||
})
|
})
|
||||||
await homePage.openProject('test-sample')
|
await homePage.openProject('test-sample')
|
||||||
// windows times out here, hence the skip above
|
|
||||||
await scene.waitForExecutionDone()
|
await scene.waitForExecutionDone()
|
||||||
})
|
})
|
||||||
await test.step('enter sketch mode', async () => {
|
await test.step('enter sketch mode', async () => {
|
||||||
@ -71,10 +66,13 @@ test.describe('integrations tests', () => {
|
|||||||
await toolbar.editSketch()
|
await toolbar.editSketch()
|
||||||
await expect(toolbar.exitSketchBtn).toBeVisible()
|
await expect(toolbar.exitSketchBtn).toBeVisible()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const fileName = 'Untitled.kcl'
|
||||||
await test.step('check sketch mode is exited when creating new file', async () => {
|
await test.step('check sketch mode is exited when creating new file', async () => {
|
||||||
await toolbar.fileTreeBtn.click()
|
await toolbar.fileTreeBtn.click()
|
||||||
await toolbar.expectFileTreeState(['main.kcl'])
|
await toolbar.expectFileTreeState(['main.kcl'])
|
||||||
await toolbar.createFile({ wait: true })
|
|
||||||
|
await toolbar.createFile({ fileName, waitForToastToDisappear: true })
|
||||||
|
|
||||||
// check we're out of sketch mode
|
// check we're out of sketch mode
|
||||||
await expect(toolbar.exitSketchBtn).not.toBeVisible()
|
await expect(toolbar.exitSketchBtn).not.toBeVisible()
|
||||||
@ -93,10 +91,10 @@ test.describe('integrations tests', () => {
|
|||||||
})
|
})
|
||||||
await toolbar.editSketch()
|
await toolbar.editSketch()
|
||||||
await expect(toolbar.exitSketchBtn).toBeVisible()
|
await expect(toolbar.exitSketchBtn).toBeVisible()
|
||||||
await toolbar.expectFileTreeState(['main.kcl', 'Untitled.kcl'])
|
await toolbar.expectFileTreeState(['main.kcl', fileName])
|
||||||
})
|
})
|
||||||
await test.step('check sketch mode is exited when opening a different file', async () => {
|
await test.step('check sketch mode is exited when opening a different file', async () => {
|
||||||
await toolbar.openFile('untitled.kcl', { wait: false })
|
await toolbar.openFile(fileName, { wait: false })
|
||||||
|
|
||||||
// check we're out of sketch mode
|
// check we're out of sketch mode
|
||||||
await expect(toolbar.exitSketchBtn).not.toBeVisible()
|
await expect(toolbar.exitSketchBtn).not.toBeVisible()
|
||||||
@ -109,7 +107,7 @@ test.describe('when using the file tree to', () => {
|
|||||||
const fromFile = 'main.kcl'
|
const fromFile = 'main.kcl'
|
||||||
const toFile = 'hello.kcl'
|
const toFile = 'hello.kcl'
|
||||||
|
|
||||||
test(
|
test.fixme(
|
||||||
`rename ${fromFile} to ${toFile}, and doesn't crash on reload and settings load`,
|
`rename ${fromFile} to ${toFile}, and doesn't crash on reload and settings load`,
|
||||||
{ tag: '@electron' },
|
{ tag: '@electron' },
|
||||||
async ({ browser: _, tronApp }, testInfo) => {
|
async ({ browser: _, tronApp }, testInfo) => {
|
||||||
@ -157,7 +155,7 @@ test.describe('when using the file tree to', () => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
test(
|
test.fixme(
|
||||||
`create many new untitled files they increment their names`,
|
`create many new untitled files they increment their names`,
|
||||||
{ tag: '@electron' },
|
{ tag: '@electron' },
|
||||||
async ({ browser: _, tronApp }, testInfo) => {
|
async ({ browser: _, tronApp }, testInfo) => {
|
||||||
@ -298,7 +296,7 @@ test.describe('when using the file tree to', () => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
test(
|
test.fixme(
|
||||||
'loading small file, then large, then back to small',
|
'loading small file, then large, then back to small',
|
||||||
{
|
{
|
||||||
tag: '@electron',
|
tag: '@electron',
|
||||||
|
@ -195,7 +195,7 @@ export class SceneFixture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
waitForExecutionDone = async () => {
|
waitForExecutionDone = async () => {
|
||||||
await expect(this.exeIndicator).toBeVisible()
|
await expect(this.exeIndicator).toBeVisible({ timeout: 30000 })
|
||||||
}
|
}
|
||||||
|
|
||||||
expectPixelColor = async (
|
expectPixelColor = async (
|
||||||
|
@ -16,6 +16,7 @@ export class ToolbarFixture {
|
|||||||
fileCreateToast!: Locator
|
fileCreateToast!: Locator
|
||||||
filePane!: Locator
|
filePane!: Locator
|
||||||
exeIndicator!: Locator
|
exeIndicator!: Locator
|
||||||
|
treeInputField!: Locator
|
||||||
|
|
||||||
constructor(page: Page) {
|
constructor(page: Page) {
|
||||||
this.page = page
|
this.page = page
|
||||||
@ -31,6 +32,7 @@ export class ToolbarFixture {
|
|||||||
this.editSketchBtn = page.getByText('Edit Sketch')
|
this.editSketchBtn = page.getByText('Edit Sketch')
|
||||||
this.fileTreeBtn = page.locator('[id="files-button-holder"]')
|
this.fileTreeBtn = page.locator('[id="files-button-holder"]')
|
||||||
this.createFileBtn = page.getByTestId('create-file-button')
|
this.createFileBtn = page.getByTestId('create-file-button')
|
||||||
|
this.treeInputField = page.getByTestId('tree-input-field')
|
||||||
|
|
||||||
this.filePane = page.locator('#files-pane')
|
this.filePane = page.locator('#files-pane')
|
||||||
this.fileCreateToast = page.getByText('Successfully created')
|
this.fileCreateToast = page.getByText('Successfully created')
|
||||||
@ -59,10 +61,15 @@ export class ToolbarFixture {
|
|||||||
expectFileTreeState = async (expected: string[]) => {
|
expectFileTreeState = async (expected: string[]) => {
|
||||||
await expect.poll(this._serialiseFileTree).toEqual(expected)
|
await expect.poll(this._serialiseFileTree).toEqual(expected)
|
||||||
}
|
}
|
||||||
createFile = async ({ wait }: { wait: boolean } = { wait: false }) => {
|
createFile = async (args: {
|
||||||
|
fileName: string
|
||||||
|
waitForToastToDisappear: boolean
|
||||||
|
}) => {
|
||||||
await this.createFileBtn.click()
|
await this.createFileBtn.click()
|
||||||
|
await this.treeInputField.fill(args.fileName)
|
||||||
|
await this.treeInputField.press('Enter')
|
||||||
await expect(this.fileCreateToast).toBeVisible()
|
await expect(this.fileCreateToast).toBeVisible()
|
||||||
if (wait) {
|
if (args.waitForToastToDisappear) {
|
||||||
await this.fileCreateToast.waitFor({ state: 'detached' })
|
await this.fileCreateToast.waitFor({ state: 'detached' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ export const isErrorWhitelisted = (exception: Error) => {
|
|||||||
{
|
{
|
||||||
name: '"{"kind"',
|
name: '"{"kind"',
|
||||||
message:
|
message:
|
||||||
'"engine","sourceRanges":[[0,0]],"msg":"Failed to get string from response from engine: `JsValue(undefined)`"}"',
|
'"engine","sourceRanges":[[0,0,0]],"msg":"Failed to get string from response from engine: `JsValue(undefined)`"}"',
|
||||||
stack: '',
|
stack: '',
|
||||||
foundInSpec: 'e2e/playwright/testing-settings.spec.ts',
|
foundInSpec: 'e2e/playwright/testing-settings.spec.ts',
|
||||||
project: 'Google Chrome',
|
project: 'Google Chrome',
|
||||||
@ -156,8 +156,8 @@ export const isErrorWhitelisted = (exception: Error) => {
|
|||||||
{
|
{
|
||||||
name: 'Unhandled Promise Rejection',
|
name: 'Unhandled Promise Rejection',
|
||||||
message:
|
message:
|
||||||
'{"kind":"engine","sourceRanges":[[0,0]],"msg":"Failed to get string from response from engine: `JsValue(undefined)`"}',
|
'{"kind":"engine","sourceRanges":[[0,0,0]],"msg":"Failed to get string from response from engine: `JsValue(undefined)`"}',
|
||||||
stack: `Unhandled Promise Rejection: {"kind":"engine","sourceRanges":[[0,0]],"msg":"Failed to get string from response from engine: \`JsValue(undefined)\`"}
|
stack: `Unhandled Promise Rejection: {"kind":"engine","sourceRanges":[[0,0,0]],"msg":"Failed to get string from response from engine: \`JsValue(undefined)\`"}
|
||||||
at unknown (http://localhost:3000/src/lang/std/engineConnection.ts:1245:26)`,
|
at unknown (http://localhost:3000/src/lang/std/engineConnection.ts:1245:26)`,
|
||||||
foundInSpec:
|
foundInSpec:
|
||||||
'e2e/playwright/onboarding-tests.spec.ts Click through each onboarding step',
|
'e2e/playwright/onboarding-tests.spec.ts Click through each onboarding step',
|
||||||
@ -253,7 +253,7 @@ export const isErrorWhitelisted = (exception: Error) => {
|
|||||||
{
|
{
|
||||||
name: '{"kind"',
|
name: '{"kind"',
|
||||||
stack: ``,
|
stack: ``,
|
||||||
message: `engine","sourceRanges":[[0,0]],"msg":"Failed to wait for promise from engine: JsValue(\\"Force interrupt, executionIsStale, new AST requested\\")"}`,
|
message: `engine","sourceRanges":[[0,0,0]],"msg":"Failed to wait for promise from engine: JsValue(\\"Force interrupt, executionIsStale, new AST requested\\")"}`,
|
||||||
project: 'Google Chrome',
|
project: 'Google Chrome',
|
||||||
foundInSpec: 'e2e/playwright/testing-settings.spec.ts',
|
foundInSpec: 'e2e/playwright/testing-settings.spec.ts',
|
||||||
},
|
},
|
||||||
|
@ -854,7 +854,7 @@ test(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
test(
|
test.fixme(
|
||||||
'Deleting projects, can delete individual project, can still create projects after deleting all',
|
'Deleting projects, can delete individual project, can still create projects after deleting all',
|
||||||
{ tag: '@electron' },
|
{ tag: '@electron' },
|
||||||
async ({ browserName }, testInfo) => {
|
async ({ browserName }, testInfo) => {
|
||||||
@ -1490,7 +1490,6 @@ test(
|
|||||||
'function_sketch.kcl',
|
'function_sketch.kcl',
|
||||||
'function_sketch_with_position.kcl',
|
'function_sketch_with_position.kcl',
|
||||||
'global-tags.kcl',
|
'global-tags.kcl',
|
||||||
'helix_ccw.kcl',
|
|
||||||
'helix_defaults.kcl',
|
'helix_defaults.kcl',
|
||||||
'helix_defaults_negative_extrude.kcl',
|
'helix_defaults_negative_extrude.kcl',
|
||||||
'helix_with_length.kcl',
|
'helix_with_length.kcl',
|
||||||
@ -1670,7 +1669,8 @@ test(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
test(
|
// Flaky
|
||||||
|
test.fixme(
|
||||||
'Original project name persist after onboarding',
|
'Original project name persist after onboarding',
|
||||||
{ tag: '@electron' },
|
{ tag: '@electron' },
|
||||||
async ({ browserName }, testInfo) => {
|
async ({ browserName }, testInfo) => {
|
||||||
|
@ -1031,7 +1031,7 @@ test.describe('Grid visibility', { tag: '@snapshot' }, () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test('theme persists', async ({ page, context }) => {
|
test.fixme('theme persists', async ({ page, context }) => {
|
||||||
const u = await getUtils(page)
|
const u = await getUtils(page)
|
||||||
await context.addInitScript(async () => {
|
await context.addInitScript(async () => {
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 37 KiB |
@ -258,7 +258,7 @@ test.describe('Testing settings', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test(
|
test.fixme(
|
||||||
`Project settings override user settings on desktop`,
|
`Project settings override user settings on desktop`,
|
||||||
{ tag: ['@electron', '@skipWin'] },
|
{ tag: ['@electron', '@skipWin'] },
|
||||||
async ({ browser: _ }, testInfo) => {
|
async ({ browser: _ }, testInfo) => {
|
||||||
@ -415,7 +415,7 @@ test.describe('Testing settings', () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// It was much easier to test the logo color than the background stream color.
|
// It was much easier to test the logo color than the background stream color.
|
||||||
test(
|
test.fixme(
|
||||||
'user settings reload on external change, on project and modeling view',
|
'user settings reload on external change, on project and modeling view',
|
||||||
{ tag: '@electron' },
|
{ tag: '@electron' },
|
||||||
async ({ browserName }, testInfo) => {
|
async ({ browserName }, testInfo) => {
|
||||||
|
@ -256,13 +256,17 @@ test('First escape in tool pops you out of tool, second exits sketch mode', asyn
|
|||||||
).not.toBeVisible()
|
).not.toBeVisible()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Basic default modeling and sketch hotkeys work', async ({ page }) => {
|
test.fixme(
|
||||||
|
'Basic default modeling and sketch hotkeys work',
|
||||||
|
async ({ page }) => {
|
||||||
const u = await getUtils(page)
|
const u = await getUtils(page)
|
||||||
|
|
||||||
// This test can run long if it takes a little too long to load
|
// This test can run long if it takes a little too long to load
|
||||||
// the engine.
|
// the engine.
|
||||||
test.setTimeout(90000)
|
test.setTimeout(90000)
|
||||||
// This test has a weird bug on ubuntu
|
// This test has a weird bug on ubuntu
|
||||||
|
// Funny, it's flaking on Windows too :). I think there is just something
|
||||||
|
// actually wrong.
|
||||||
test.skip(
|
test.skip(
|
||||||
process.platform === 'linux',
|
process.platform === 'linux',
|
||||||
'weird playwright bug on ubuntu https://github.com/KittyCAD/modeling-app/issues/2444'
|
'weird playwright bug on ubuntu https://github.com/KittyCAD/modeling-app/issues/2444'
|
||||||
@ -430,7 +434,8 @@ test('Basic default modeling and sketch hotkeys work', async ({ page }) => {
|
|||||||
await page.keyboard.press('Escape')
|
await page.keyboard.press('Escape')
|
||||||
await page.waitForTimeout(100)
|
await page.waitForTimeout(100)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
test('Delete key does not navigate back', async ({ page }) => {
|
test('Delete key does not navigate back', async ({ page }) => {
|
||||||
await page.setViewportSize({ width: 1200, height: 500 })
|
await page.setViewportSize({ width: 1200, height: 500 })
|
||||||
|
1
interface.d.ts
vendored
@ -78,6 +78,7 @@ export interface IElectronAPI {
|
|||||||
) => Electron.IpcRenderer
|
) => Electron.IpcRenderer
|
||||||
onUpdateError: (callback: (value: { error: Error }) => void) => Electron
|
onUpdateError: (callback: (value: { error: Error }) => void) => Electron
|
||||||
appRestart: () => void
|
appRestart: () => void
|
||||||
|
getArgvParsed: () => any
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
25
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "zoo-modeling-app",
|
"name": "zoo-modeling-app",
|
||||||
"version": "0.26.2",
|
"version": "0.26.5",
|
||||||
"private": true,
|
"private": true,
|
||||||
"productName": "Zoo Modeling App",
|
"productName": "Zoo Modeling App",
|
||||||
"author": {
|
"author": {
|
||||||
@ -14,7 +14,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codemirror/autocomplete": "^6.17.0",
|
"@codemirror/autocomplete": "^6.17.0",
|
||||||
"@codemirror/commands": "^6.6.0",
|
"@codemirror/commands": "^6.6.0",
|
||||||
"@codemirror/language": "^6.10.2",
|
"@codemirror/language": "^6.10.3",
|
||||||
"@codemirror/lint": "^6.8.1",
|
"@codemirror/lint": "^6.8.1",
|
||||||
"@codemirror/search": "^6.5.6",
|
"@codemirror/search": "^6.5.6",
|
||||||
"@codemirror/state": "^6.4.1",
|
"@codemirror/state": "^6.4.1",
|
||||||
@ -40,7 +40,7 @@
|
|||||||
"codemirror": "^6.0.1",
|
"codemirror": "^6.0.1",
|
||||||
"decamelize": "^6.0.0",
|
"decamelize": "^6.0.0",
|
||||||
"electron-squirrel-startup": "^1.0.1",
|
"electron-squirrel-startup": "^1.0.1",
|
||||||
"electron-updater": "^6.3.0",
|
"electron-updater": "^6.3.9",
|
||||||
"fuse.js": "^7.0.0",
|
"fuse.js": "^7.0.0",
|
||||||
"html2canvas-pro": "^1.5.8",
|
"html2canvas-pro": "^1.5.8",
|
||||||
"isomorphic-fetch": "^3.0.0",
|
"isomorphic-fetch": "^3.0.0",
|
||||||
@ -60,12 +60,13 @@
|
|||||||
"sketch-helpers": "^0.0.4",
|
"sketch-helpers": "^0.0.4",
|
||||||
"three": "^0.166.1",
|
"three": "^0.166.1",
|
||||||
"ua-parser-js": "^1.0.37",
|
"ua-parser-js": "^1.0.37",
|
||||||
"uuid": "^9.0.1",
|
"uuid": "^11.0.2",
|
||||||
"vscode-jsonrpc": "^8.2.1",
|
"vscode-jsonrpc": "^8.2.1",
|
||||||
"vscode-languageserver-protocol": "^3.17.5",
|
"vscode-languageserver-protocol": "^3.17.5",
|
||||||
"vscode-uri": "^3.0.8",
|
"vscode-uri": "^3.0.8",
|
||||||
"web-vitals": "^3.5.2",
|
"web-vitals": "^3.5.2",
|
||||||
"xstate": "^5.17.4"
|
"xstate": "^5.17.4",
|
||||||
|
"yargs": "^17.7.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
@ -105,7 +106,8 @@
|
|||||||
"tronb:package": "electron-builder --config electron-builder.yml",
|
"tronb:package": "electron-builder --config electron-builder.yml",
|
||||||
"test-setup": "yarn install && yarn build:wasm",
|
"test-setup": "yarn install && yarn build:wasm",
|
||||||
"test": "vitest --mode development",
|
"test": "vitest --mode development",
|
||||||
"test:unit": "vitest run --mode development",
|
"test:unit": "vitest run --mode development --exclude **/kclSamples.test.ts",
|
||||||
|
"test:unit:kcl-samples": "vitest run --mode development ./src/lang/kclSamples.test.ts",
|
||||||
"test:playwright:browser:chrome": "playwright test --project='Google Chrome' --config=playwright.ci.config.ts --grep-invert='@snapshot|@electron'",
|
"test:playwright:browser:chrome": "playwright test --project='Google Chrome' --config=playwright.ci.config.ts --grep-invert='@snapshot|@electron'",
|
||||||
"test:playwright:browser:chrome:windows": "playwright test --project=\"Google Chrome\" --config=playwright.ci.config.ts --grep-invert=\"@snapshot|@electron|@skipWin\"",
|
"test:playwright:browser:chrome:windows": "playwright test --project=\"Google Chrome\" --config=playwright.ci.config.ts --grep-invert=\"@snapshot|@electron|@skipWin\"",
|
||||||
"test:playwright:browser:chrome:ubuntu": "playwright test --project='Google Chrome' --config=playwright.ci.config.ts --grep-invert='@snapshot|@electron|@skipLinux'",
|
"test:playwright:browser:chrome:ubuntu": "playwright test --project='Google Chrome' --config=playwright.ci.config.ts --grep-invert='@snapshot|@electron|@skipLinux'",
|
||||||
@ -117,7 +119,8 @@
|
|||||||
"test:playwright:electron:windows:local": "yarn tron:package && NODE_ENV=development playwright test --config=playwright.electron.config.ts --grep=@electron --grep-invert=@skipWin",
|
"test:playwright:electron:windows:local": "yarn tron:package && NODE_ENV=development playwright test --config=playwright.electron.config.ts --grep=@electron --grep-invert=@skipWin",
|
||||||
"test:playwright:electron:macos:local": "yarn tron:package && NODE_ENV=development playwright test --config=playwright.electron.config.ts --grep=@electron --grep-invert=@skipMacos",
|
"test:playwright:electron:macos:local": "yarn tron:package && NODE_ENV=development playwright test --config=playwright.electron.config.ts --grep=@electron --grep-invert=@skipMacos",
|
||||||
"test:playwright:electron:ubuntu:local": "yarn tron:package && NODE_ENV=development playwright test --config=playwright.electron.config.ts --grep=@electron --grep-invert=@skipLinux",
|
"test:playwright:electron:ubuntu:local": "yarn tron:package && NODE_ENV=development playwright test --config=playwright.electron.config.ts --grep=@electron --grep-invert=@skipLinux",
|
||||||
"test:unit:local": "yarn simpleserver:bg && yarn test:unit; kill-port 3000"
|
"test:unit:local": "yarn simpleserver:bg && yarn test:unit; kill-port 3000",
|
||||||
|
"test:unit:kcl-samples:local": "yarn simpleserver:bg && yarn test:unit:kcl-samples; kill-port 3000"
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"trailingComma": "es5",
|
"trailingComma": "es5",
|
||||||
@ -144,8 +147,8 @@
|
|||||||
"@electron-forge/maker-deb": "^7.4.0",
|
"@electron-forge/maker-deb": "^7.4.0",
|
||||||
"@electron-forge/maker-rpm": "^7.4.0",
|
"@electron-forge/maker-rpm": "^7.4.0",
|
||||||
"@electron-forge/maker-squirrel": "^7.4.0",
|
"@electron-forge/maker-squirrel": "^7.4.0",
|
||||||
"@electron-forge/maker-wix": "^7.4.0",
|
"@electron-forge/maker-wix": "^7.5.0",
|
||||||
"@electron-forge/maker-zip": "^7.4.0",
|
"@electron-forge/maker-zip": "^7.5.0",
|
||||||
"@electron-forge/plugin-auto-unpack-natives": "^7.4.0",
|
"@electron-forge/plugin-auto-unpack-natives": "^7.4.0",
|
||||||
"@electron-forge/plugin-fuses": "^7.4.0",
|
"@electron-forge/plugin-fuses": "^7.4.0",
|
||||||
"@electron-forge/plugin-vite": "^7.4.0",
|
"@electron-forge/plugin-vite": "^7.4.0",
|
||||||
@ -171,7 +174,7 @@
|
|||||||
"@types/ua-parser-js": "^0.7.39",
|
"@types/ua-parser-js": "^0.7.39",
|
||||||
"@types/uuid": "^9.0.8",
|
"@types/uuid": "^9.0.8",
|
||||||
"@types/wicg-file-system-access": "^2023.10.5",
|
"@types/wicg-file-system-access": "^2023.10.5",
|
||||||
"@types/ws": "^8.5.10",
|
"@types/ws": "^8.5.13",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
||||||
"@typescript-eslint/parser": "^5.0.0",
|
"@typescript-eslint/parser": "^5.0.0",
|
||||||
"@vitejs/plugin-react": "^4.3.0",
|
"@vitejs/plugin-react": "^4.3.0",
|
||||||
@ -187,7 +190,7 @@
|
|||||||
"eslint-plugin-css-modules": "^2.12.0",
|
"eslint-plugin-css-modules": "^2.12.0",
|
||||||
"eslint-plugin-import": "^2.30.0",
|
"eslint-plugin-import": "^2.30.0",
|
||||||
"eslint-plugin-suggest-no-throw": "^1.0.0",
|
"eslint-plugin-suggest-no-throw": "^1.0.0",
|
||||||
"happy-dom": "^14.3.10",
|
"happy-dom": "^15.10.2",
|
||||||
"http-server": "^14.1.1",
|
"http-server": "^14.1.1",
|
||||||
"husky": "^9.1.5",
|
"husky": "^9.1.5",
|
||||||
"kill-port": "^2.0.1",
|
"kill-port": "^2.0.1",
|
||||||
|
@ -22,6 +22,10 @@ import Gizmo from 'components/Gizmo'
|
|||||||
import { CoreDumpManager } from 'lib/coredump'
|
import { CoreDumpManager } from 'lib/coredump'
|
||||||
import { UnitsMenu } from 'components/UnitsMenu'
|
import { UnitsMenu } from 'components/UnitsMenu'
|
||||||
import { CameraProjectionToggle } from 'components/CameraProjectionToggle'
|
import { CameraProjectionToggle } from 'components/CameraProjectionToggle'
|
||||||
|
import { maybeWriteToDisk } from 'lib/telemetry'
|
||||||
|
maybeWriteToDisk()
|
||||||
|
.then(() => {})
|
||||||
|
.catch(() => {})
|
||||||
|
|
||||||
export function App() {
|
export function App() {
|
||||||
const { project, file } = useLoaderData() as IndexLoaderData
|
const { project, file } = useLoaderData() as IndexLoaderData
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
} from 'react-router-dom'
|
} from 'react-router-dom'
|
||||||
import { ErrorPage } from './components/ErrorPage'
|
import { ErrorPage } from './components/ErrorPage'
|
||||||
import { Settings } from './routes/Settings'
|
import { Settings } from './routes/Settings'
|
||||||
|
import { Telemetry } from './routes/Telemetry'
|
||||||
import Onboarding, { onboardingRoutes } from './routes/Onboarding'
|
import Onboarding, { onboardingRoutes } from './routes/Onboarding'
|
||||||
import SignIn from './routes/SignIn'
|
import SignIn from './routes/SignIn'
|
||||||
import { Auth } from './Auth'
|
import { Auth } from './Auth'
|
||||||
@ -28,6 +29,7 @@ import {
|
|||||||
homeLoader,
|
homeLoader,
|
||||||
onboardingRedirectLoader,
|
onboardingRedirectLoader,
|
||||||
settingsLoader,
|
settingsLoader,
|
||||||
|
telemetryLoader,
|
||||||
} from 'lib/routeLoaders'
|
} from 'lib/routeLoaders'
|
||||||
import { CommandBarProvider } from 'components/CommandBar/CommandBarProvider'
|
import { CommandBarProvider } from 'components/CommandBar/CommandBarProvider'
|
||||||
import SettingsAuthProvider from 'components/SettingsAuthProvider'
|
import SettingsAuthProvider from 'components/SettingsAuthProvider'
|
||||||
@ -43,6 +45,7 @@ import { coreDump } from 'lang/wasm'
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { AppStateProvider } from 'AppState'
|
import { AppStateProvider } from 'AppState'
|
||||||
import { reportRejection } from 'lib/trap'
|
import { reportRejection } from 'lib/trap'
|
||||||
|
import { RouteProvider } from 'components/RouteProvider'
|
||||||
import { ProjectsContextProvider } from 'components/ProjectsContextProvider'
|
import { ProjectsContextProvider } from 'components/ProjectsContextProvider'
|
||||||
|
|
||||||
const createRouter = isDesktop() ? createHashRouter : createBrowserRouter
|
const createRouter = isDesktop() ? createHashRouter : createBrowserRouter
|
||||||
@ -56,6 +59,7 @@ const router = createRouter([
|
|||||||
* inefficient re-renders, use the react profiler to see. */
|
* inefficient re-renders, use the react profiler to see. */
|
||||||
element: (
|
element: (
|
||||||
<CommandBarProvider>
|
<CommandBarProvider>
|
||||||
|
<RouteProvider>
|
||||||
<SettingsAuthProvider>
|
<SettingsAuthProvider>
|
||||||
<LspProvider>
|
<LspProvider>
|
||||||
<ProjectsContextProvider>
|
<ProjectsContextProvider>
|
||||||
@ -69,6 +73,7 @@ const router = createRouter([
|
|||||||
</ProjectsContextProvider>
|
</ProjectsContextProvider>
|
||||||
</LspProvider>
|
</LspProvider>
|
||||||
</SettingsAuthProvider>
|
</SettingsAuthProvider>
|
||||||
|
</RouteProvider>
|
||||||
</CommandBarProvider>
|
</CommandBarProvider>
|
||||||
),
|
),
|
||||||
errorElement: <ErrorPage />,
|
errorElement: <ErrorPage />,
|
||||||
@ -124,6 +129,16 @@ const router = createRouter([
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: PATHS.FILE + 'TELEMETRY',
|
||||||
|
loader: telemetryLoader,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: makeUrlPathRelative(PATHS.TELEMETRY),
|
||||||
|
element: <Telemetry />,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -149,6 +164,11 @@ const router = createRouter([
|
|||||||
loader: settingsLoader,
|
loader: settingsLoader,
|
||||||
element: <Settings />,
|
element: <Settings />,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: makeUrlPathRelative(PATHS.TELEMETRY),
|
||||||
|
loader: telemetryLoader,
|
||||||
|
element: <Telemetry />,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
12
src/commandLineArgs.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import yargs from 'yargs'
|
||||||
|
import { hideBin } from 'yargs/helpers'
|
||||||
|
|
||||||
|
const argv = yargs(hideBin(process.argv))
|
||||||
|
.option('telemetry', {
|
||||||
|
alias: 't',
|
||||||
|
type: 'boolean',
|
||||||
|
description: 'Writes startup telemetry to file on disk.',
|
||||||
|
})
|
||||||
|
.parse()
|
||||||
|
|
||||||
|
export default argv
|
@ -1161,6 +1161,29 @@ const CustomIconMap = {
|
|||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
|
stopwatch: (
|
||||||
|
<svg
|
||||||
|
width="20"
|
||||||
|
height="20"
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fill-rule="evenodd"
|
||||||
|
clip-rule="evenodd"
|
||||||
|
d="M7.95705 5.99046C7.05643 6.44935 6.33654 7.19809 5.91336 8.11602C5.49019 9.03396 5.38838 10.0676 5.62434 11.0505C5.8603 12.0334 6.42029 12.9081 7.21408 13.5339C8.00787 14.1597 8.98922 14.5 10 14.5C11.0108 14.5 11.9921 14.1597 12.7859 13.5339C13.5797 12.9082 14.1397 12.0334 14.3757 11.0505C14.6116 10.0676 14.5098 9.03396 14.0866 8.11603C13.6635 7.19809 12.9436 6.44935 12.043 5.99046L12.497 5.09946C13.5977 5.66032 14.4776 6.57544 14.9948 7.69737C15.512 8.81929 15.6364 10.0827 15.348 11.2839C15.0596 12.4852 14.3752 13.5544 13.405 14.3192C12.4348 15.0841 11.2354 15.5 10 15.5C8.7646 15.5 7.56517 15.0841 6.59499 14.3192C5.6248 13.5544 4.94037 12.4852 4.65197 11.2839C4.36357 10.0827 4.488 8.81929 5.00522 7.69736C5.52243 6.57544 6.40231 5.66032 7.50306 5.09946L7.95705 5.99046Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path d="M10 5.5V4M10 4H8M10 4H12" stroke="currentColor" />
|
||||||
|
<path
|
||||||
|
fill-rule="evenodd"
|
||||||
|
clip-rule="evenodd"
|
||||||
|
d="M12.8536 7.85356L10.3536 10.3536C10.1583 10.5488 9.84171 10.5488 9.64645 10.3536C9.45118 10.1583 9.45118 9.84172 9.64645 9.64645L12.1464 7.14645L12.8536 7.85356Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
),
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export type CustomIconName = keyof typeof CustomIconMap
|
export type CustomIconName = keyof typeof CustomIconMap
|
||||||
|
@ -29,6 +29,7 @@ import {
|
|||||||
KclSamplesManifestItem,
|
KclSamplesManifestItem,
|
||||||
} from 'lib/getKclSamplesManifest'
|
} from 'lib/getKclSamplesManifest'
|
||||||
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||||
|
import { markOnce } from 'lib/performance'
|
||||||
|
|
||||||
type MachineContext<T extends AnyStateMachine> = {
|
type MachineContext<T extends AnyStateMachine> = {
|
||||||
state: StateFrom<T>
|
state: StateFrom<T>
|
||||||
@ -54,6 +55,7 @@ export const FileMachineProvider = ({
|
|||||||
)
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
markOnce('code/didLoadFile')
|
||||||
async function fetchKclSamples() {
|
async function fetchKclSamples() {
|
||||||
setKclSamples(await getKclSamplesManifest())
|
setKclSamples(await getKclSamplesManifest())
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,10 @@ import { Dispatch, useCallback, useRef, useState } from 'react'
|
|||||||
import { useNavigate, useRouteLoaderData } from 'react-router-dom'
|
import { useNavigate, useRouteLoaderData } from 'react-router-dom'
|
||||||
import { Disclosure } from '@headlessui/react'
|
import { Disclosure } from '@headlessui/react'
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||||
import { faChevronRight } from '@fortawesome/free-solid-svg-icons'
|
import { faChevronRight, faPencil } from '@fortawesome/free-solid-svg-icons'
|
||||||
import { useFileContext } from 'hooks/useFileContext'
|
import { useFileContext } from 'hooks/useFileContext'
|
||||||
import styles from './FileTree.module.css'
|
import styles from './FileTree.module.css'
|
||||||
import { sortProject } from 'lib/desktopFS'
|
import { sortFilesAndDirectories } from 'lib/desktopFS'
|
||||||
import { FILE_EXT } from 'lib/constants'
|
import { FILE_EXT } from 'lib/constants'
|
||||||
import { CustomIcon } from './CustomIcon'
|
import { CustomIcon } from './CustomIcon'
|
||||||
import { codeManager, kclManager } from 'lib/singletons'
|
import { codeManager, kclManager } from 'lib/singletons'
|
||||||
@ -27,6 +27,36 @@ function getIndentationCSS(level: number) {
|
|||||||
return `calc(1rem * ${level + 1})`
|
return `calc(1rem * ${level + 1})`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function TreeEntryInput(props: {
|
||||||
|
level: number
|
||||||
|
onSubmit: (value: string) => void
|
||||||
|
}) {
|
||||||
|
const [value, setValue] = useState('')
|
||||||
|
const onKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||||
|
if (e.key !== 'Enter') return
|
||||||
|
props.onSubmit(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<label>
|
||||||
|
<span className="sr-only">Entry input</span>
|
||||||
|
<input
|
||||||
|
data-testid="tree-input-field"
|
||||||
|
type="text"
|
||||||
|
autoFocus
|
||||||
|
autoCapitalize="off"
|
||||||
|
autoCorrect="off"
|
||||||
|
className="w-full py-1 bg-transparent text-chalkboard-100 placeholder:text-chalkboard-70 dark:text-chalkboard-10 dark:placeholder:text-chalkboard-50 focus:outline-none focus:ring-0"
|
||||||
|
onBlur={() => props.onSubmit(value)}
|
||||||
|
onChange={(e) => setValue(e.target.value)}
|
||||||
|
onKeyPress={onKeyPress}
|
||||||
|
style={{ paddingInlineStart: getIndentationCSS(props.level) }}
|
||||||
|
value={value}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function RenameForm({
|
function RenameForm({
|
||||||
fileOrDir,
|
fileOrDir,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
@ -113,23 +143,44 @@ function DeleteFileTreeItemDialog({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const FileTreeItem = ({
|
const FileTreeItem = ({
|
||||||
|
parentDir,
|
||||||
project,
|
project,
|
||||||
currentFile,
|
currentFile,
|
||||||
|
lastDirectoryClicked,
|
||||||
fileOrDir,
|
fileOrDir,
|
||||||
onNavigateToFile,
|
onNavigateToFile,
|
||||||
|
onClickDirectory,
|
||||||
|
onCreateFile,
|
||||||
|
onCreateFolder,
|
||||||
|
newTreeEntry,
|
||||||
level = 0,
|
level = 0,
|
||||||
|
treeSelection,
|
||||||
|
setTreeSelection,
|
||||||
}: {
|
}: {
|
||||||
|
parentDir: FileEntry | undefined
|
||||||
project?: IndexLoaderData['project']
|
project?: IndexLoaderData['project']
|
||||||
currentFile?: IndexLoaderData['file']
|
currentFile?: IndexLoaderData['file']
|
||||||
|
lastDirectoryClicked?: FileEntry
|
||||||
fileOrDir: FileEntry
|
fileOrDir: FileEntry
|
||||||
onNavigateToFile?: () => void
|
onNavigateToFile?: () => void
|
||||||
|
onClickDirectory: (
|
||||||
|
open: boolean,
|
||||||
|
path: FileEntry,
|
||||||
|
parentDir: FileEntry | undefined
|
||||||
|
) => void
|
||||||
|
onCreateFile: (name: string) => void
|
||||||
|
onCreateFolder: (name: string) => void
|
||||||
|
newTreeEntry: TreeEntry
|
||||||
level?: number
|
level?: number
|
||||||
|
treeSelection: FileEntry | undefined
|
||||||
|
setTreeSelection: Dispatch<React.SetStateAction<FileEntry | undefined>>
|
||||||
}) => {
|
}) => {
|
||||||
const { send: fileSend, context: fileContext } = useFileContext()
|
const { send: fileSend, context: fileContext } = useFileContext()
|
||||||
const { onFileOpen, onFileClose } = useLspContext()
|
const { onFileOpen, onFileClose } = useLspContext()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const [isConfirmingDelete, setIsConfirmingDelete] = useState(false)
|
const [isConfirmingDelete, setIsConfirmingDelete] = useState(false)
|
||||||
const isCurrentFile = fileOrDir.path === currentFile?.path
|
const isCurrentFile = fileOrDir.path === currentFile?.path
|
||||||
|
const isFileOrDirHighlighted = treeSelection?.path === fileOrDir?.path
|
||||||
const itemRef = useRef(null)
|
const itemRef = useRef(null)
|
||||||
|
|
||||||
// Since every file or directory gets its own FileTreeItem, we can do this.
|
// Since every file or directory gets its own FileTreeItem, we can do this.
|
||||||
@ -156,6 +207,10 @@ const FileTreeItem = ({
|
|||||||
[fileOrDir.path]
|
[fileOrDir.path]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const showNewTreeEntry =
|
||||||
|
newTreeEntry !== undefined &&
|
||||||
|
fileOrDir.path === fileContext.selectedDirectory.path
|
||||||
|
|
||||||
const isRenaming = fileContext.itemsBeingRenamed.includes(fileOrDir.path)
|
const isRenaming = fileContext.itemsBeingRenamed.includes(fileOrDir.path)
|
||||||
const removeCurrentItemFromRenaming = useCallback(
|
const removeCurrentItemFromRenaming = useCallback(
|
||||||
() =>
|
() =>
|
||||||
@ -179,13 +234,6 @@ const FileTreeItem = ({
|
|||||||
})
|
})
|
||||||
}, [fileContext.itemsBeingRenamed, fileOrDir.path, fileSend])
|
}, [fileContext.itemsBeingRenamed, fileOrDir.path, fileSend])
|
||||||
|
|
||||||
const clickDirectory = () => {
|
|
||||||
fileSend({
|
|
||||||
type: 'Set selected directory',
|
|
||||||
directory: fileOrDir,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleKeyUp(e: React.KeyboardEvent<HTMLButtonElement>) {
|
function handleKeyUp(e: React.KeyboardEvent<HTMLButtonElement>) {
|
||||||
if (e.metaKey && e.key === 'Backspace') {
|
if (e.metaKey && e.key === 'Backspace') {
|
||||||
// Open confirmation dialog
|
// Open confirmation dialog
|
||||||
@ -199,6 +247,8 @@ const FileTreeItem = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
|
setTreeSelection(fileOrDir)
|
||||||
|
|
||||||
if (fileOrDir.children !== null) return // Don't open directories
|
if (fileOrDir.children !== null) return // Don't open directories
|
||||||
|
|
||||||
if (fileOrDir.name?.endsWith(FILE_EXT) === false && project?.path) {
|
if (fileOrDir.name?.endsWith(FILE_EXT) === false && project?.path) {
|
||||||
@ -222,16 +272,19 @@ const FileTreeItem = ({
|
|||||||
// Open kcl files
|
// Open kcl files
|
||||||
navigate(`${PATHS.FILE}/${encodeURIComponent(fileOrDir.path)}`)
|
navigate(`${PATHS.FILE}/${encodeURIComponent(fileOrDir.path)}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
onNavigateToFile?.()
|
onNavigateToFile?.()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The below handles both the "root" of all directories and all subs. It's
|
||||||
|
// why some code is duplicated.
|
||||||
return (
|
return (
|
||||||
<div className="contents" data-testid="file-tree-item" ref={itemRef}>
|
<div className="contents" data-testid="file-tree-item" ref={itemRef}>
|
||||||
{fileOrDir.children === null ? (
|
{fileOrDir.children === null ? (
|
||||||
<li
|
<li
|
||||||
className={
|
className={
|
||||||
'group m-0 p-0 border-solid border-0 hover:bg-primary/5 focus-within:bg-primary/5 dark:hover:bg-primary/20 dark:focus-within:bg-primary/20 ' +
|
'group m-0 p-0 border-solid border-0 hover:bg-primary/5 focus-within:bg-primary/5 dark:hover:bg-primary/20 dark:focus-within:bg-primary/20 ' +
|
||||||
(isCurrentFile
|
(isFileOrDirHighlighted || isCurrentFile
|
||||||
? '!bg-primary/10 !text-primary dark:!bg-primary/20 dark:!text-inherit'
|
? '!bg-primary/10 !text-primary dark:!bg-primary/20 dark:!text-inherit'
|
||||||
: '')
|
: '')
|
||||||
}
|
}
|
||||||
@ -268,14 +321,13 @@ const FileTreeItem = ({
|
|||||||
<Disclosure.Button
|
<Disclosure.Button
|
||||||
className={
|
className={
|
||||||
' group border-none text-sm rounded-none p-0 m-0 flex items-center justify-start w-full py-0.5 hover:text-primary hover:bg-primary/5 dark:hover:text-inherit dark:hover:bg-primary/10' +
|
' group border-none text-sm rounded-none p-0 m-0 flex items-center justify-start w-full py-0.5 hover:text-primary hover:bg-primary/5 dark:hover:text-inherit dark:hover:bg-primary/10' +
|
||||||
(fileContext.selectedDirectory.path.includes(fileOrDir.path)
|
(isFileOrDirHighlighted ? ' ui-open:bg-primary/10' : '')
|
||||||
? ' ui-open:bg-primary/10'
|
|
||||||
: '')
|
|
||||||
}
|
}
|
||||||
style={{ paddingInlineStart: getIndentationCSS(level) }}
|
style={{ paddingInlineStart: getIndentationCSS(level) }}
|
||||||
onClick={(e) => e.currentTarget.focus()}
|
onClick={(e) => {
|
||||||
onClickCapture={clickDirectory}
|
e.stopPropagation()
|
||||||
onFocusCapture={clickDirectory}
|
onClickDirectory(open, fileOrDir, parentDir)
|
||||||
|
}}
|
||||||
onKeyDown={(e) => e.key === 'Enter' && e.preventDefault()}
|
onKeyDown={(e) => e.key === 'Enter' && e.preventDefault()}
|
||||||
onKeyUp={handleKeyUp}
|
onKeyUp={handleKeyUp}
|
||||||
>
|
>
|
||||||
@ -317,35 +369,69 @@ const FileTreeItem = ({
|
|||||||
>
|
>
|
||||||
<ul
|
<ul
|
||||||
className="m-0 p-0"
|
className="m-0 p-0"
|
||||||
onClickCapture={(e) => {
|
onClick={(e) => {
|
||||||
fileSend({
|
e.stopPropagation()
|
||||||
type: 'Set selected directory',
|
onClickDirectory(open, fileOrDir, parentDir)
|
||||||
directory: fileOrDir,
|
|
||||||
})
|
|
||||||
}}
|
}}
|
||||||
onFocusCapture={(e) =>
|
|
||||||
fileSend({
|
|
||||||
type: 'Set selected directory',
|
|
||||||
directory: fileOrDir,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{fileOrDir.children?.map((child) => (
|
{showNewTreeEntry && (
|
||||||
|
<div
|
||||||
|
className="flex items-center"
|
||||||
|
style={{
|
||||||
|
paddingInlineStart: getIndentationCSS(level + 1),
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon
|
||||||
|
icon={faPencil}
|
||||||
|
className="inline-block mr-2 m-0 p-0 w-2 h-2"
|
||||||
|
/>
|
||||||
|
<TreeEntryInput
|
||||||
|
level={-1}
|
||||||
|
onSubmit={(value: string) =>
|
||||||
|
newTreeEntry === 'file'
|
||||||
|
? onCreateFile(value)
|
||||||
|
: onCreateFolder(value)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{sortFilesAndDirectories(fileOrDir.children || []).map(
|
||||||
|
(child) => (
|
||||||
<FileTreeItem
|
<FileTreeItem
|
||||||
|
parentDir={fileOrDir}
|
||||||
fileOrDir={child}
|
fileOrDir={child}
|
||||||
project={project}
|
project={project}
|
||||||
currentFile={currentFile}
|
currentFile={currentFile}
|
||||||
|
onCreateFile={onCreateFile}
|
||||||
|
onCreateFolder={onCreateFolder}
|
||||||
|
newTreeEntry={newTreeEntry}
|
||||||
|
lastDirectoryClicked={lastDirectoryClicked}
|
||||||
|
onClickDirectory={onClickDirectory}
|
||||||
onNavigateToFile={onNavigateToFile}
|
onNavigateToFile={onNavigateToFile}
|
||||||
level={level + 1}
|
level={level + 1}
|
||||||
key={level + '-' + child.path}
|
key={level + '-' + child.path}
|
||||||
|
treeSelection={treeSelection}
|
||||||
|
setTreeSelection={setTreeSelection}
|
||||||
/>
|
/>
|
||||||
))}
|
)
|
||||||
|
)}
|
||||||
|
{!showNewTreeEntry && fileOrDir.children?.length === 0 && (
|
||||||
|
<div
|
||||||
|
className="flex items-center text-chalkboard-50"
|
||||||
|
style={{
|
||||||
|
paddingInlineStart: getIndentationCSS(level + 1),
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div>No files</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
</Disclosure.Panel>
|
</Disclosure.Panel>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Disclosure>
|
</Disclosure>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isConfirmingDelete && (
|
{isConfirmingDelete && (
|
||||||
<DeleteFileTreeItemDialog
|
<DeleteFileTreeItemDialog
|
||||||
fileOrDir={fileOrDir}
|
fileOrDir={fileOrDir}
|
||||||
@ -409,27 +495,15 @@ interface FileTreeProps {
|
|||||||
) => void
|
) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FileTreeMenu = () => {
|
export const FileTreeMenu = ({
|
||||||
const { send } = useFileContext()
|
onCreateFile,
|
||||||
const { send: modelingSend } = useModelingContext()
|
onCreateFolder,
|
||||||
|
}: {
|
||||||
function createFile() {
|
onCreateFile: () => void
|
||||||
send({
|
onCreateFolder: () => void
|
||||||
type: 'Create file',
|
}) => {
|
||||||
data: { name: '', makeDir: false, shouldSetToRename: true },
|
useHotkeyWrapper(['mod + n'], onCreateFile)
|
||||||
})
|
useHotkeyWrapper(['mod + shift + n'], onCreateFolder)
|
||||||
modelingSend({ type: 'Cancel' })
|
|
||||||
}
|
|
||||||
|
|
||||||
function createFolder() {
|
|
||||||
send({
|
|
||||||
type: 'Create file',
|
|
||||||
data: { name: '', makeDir: true, shouldSetToRename: true },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
useHotkeyWrapper(['mod + n'], createFile)
|
|
||||||
useHotkeyWrapper(['mod + shift + n'], createFolder)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -442,7 +516,7 @@ export const FileTreeMenu = () => {
|
|||||||
bgClassName: 'bg-transparent',
|
bgClassName: 'bg-transparent',
|
||||||
}}
|
}}
|
||||||
className="!p-0 !bg-transparent hover:text-primary border-transparent hover:border-primary !outline-none"
|
className="!p-0 !bg-transparent hover:text-primary border-transparent hover:border-primary !outline-none"
|
||||||
onClick={createFile}
|
onClick={onCreateFile}
|
||||||
>
|
>
|
||||||
<Tooltip position="bottom-right" delay={750}>
|
<Tooltip position="bottom-right" delay={750}>
|
||||||
Create file
|
Create file
|
||||||
@ -458,7 +532,7 @@ export const FileTreeMenu = () => {
|
|||||||
bgClassName: 'bg-transparent',
|
bgClassName: 'bg-transparent',
|
||||||
}}
|
}}
|
||||||
className="!p-0 !bg-transparent hover:text-primary border-transparent hover:border-primary !outline-none"
|
className="!p-0 !bg-transparent hover:text-primary border-transparent hover:border-primary !outline-none"
|
||||||
onClick={createFolder}
|
onClick={onCreateFolder}
|
||||||
>
|
>
|
||||||
<Tooltip position="bottom-right" delay={750}>
|
<Tooltip position="bottom-right" delay={750}>
|
||||||
Create folder
|
Create folder
|
||||||
@ -468,30 +542,110 @@ export const FileTreeMenu = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TreeEntry = 'file' | 'folder' | undefined
|
||||||
|
|
||||||
|
export const useFileTreeOperations = () => {
|
||||||
|
const { send } = useFileContext()
|
||||||
|
const { send: modelingSend } = useModelingContext()
|
||||||
|
|
||||||
|
// As long as this is undefined, a new "file tree entry prompt" is not shown.
|
||||||
|
const [newTreeEntry, setNewTreeEntry] = useState<TreeEntry>(undefined)
|
||||||
|
|
||||||
|
function createFile(args: { dryRun: boolean; name?: string }) {
|
||||||
|
if (args.dryRun) {
|
||||||
|
setNewTreeEntry('file')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear so that the entry prompt goes away.
|
||||||
|
setNewTreeEntry(undefined)
|
||||||
|
|
||||||
|
if (!args.name) return
|
||||||
|
|
||||||
|
send({
|
||||||
|
type: 'Create file',
|
||||||
|
data: { name: args.name, makeDir: false, shouldSetToRename: false },
|
||||||
|
})
|
||||||
|
modelingSend({ type: 'Cancel' })
|
||||||
|
}
|
||||||
|
|
||||||
|
function createFolder(args: { dryRun: boolean; name?: string }) {
|
||||||
|
if (args.dryRun) {
|
||||||
|
setNewTreeEntry('folder')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
setNewTreeEntry(undefined)
|
||||||
|
|
||||||
|
if (!args.name) return
|
||||||
|
|
||||||
|
send({
|
||||||
|
type: 'Create file',
|
||||||
|
data: { name: args.name, makeDir: true, shouldSetToRename: false },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
createFile,
|
||||||
|
createFolder,
|
||||||
|
newTreeEntry,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const FileTree = ({
|
export const FileTree = ({
|
||||||
className = '',
|
className = '',
|
||||||
onNavigateToFile: closePanel,
|
onNavigateToFile: closePanel,
|
||||||
}: FileTreeProps) => {
|
}: FileTreeProps) => {
|
||||||
|
const { createFile, createFolder, newTreeEntry } = useFileTreeOperations()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
<div className="flex items-center gap-1 px-4 py-1 bg-chalkboard-20/40 dark:bg-chalkboard-80/50 border-b border-b-chalkboard-30 dark:border-b-chalkboard-80">
|
<div className="flex items-center gap-1 px-4 py-1 bg-chalkboard-20/40 dark:bg-chalkboard-80/50 border-b border-b-chalkboard-30 dark:border-b-chalkboard-80">
|
||||||
<h2 className="flex-1 m-0 p-0 text-sm mono">Files</h2>
|
<h2 className="flex-1 m-0 p-0 text-sm mono">Files</h2>
|
||||||
<FileTreeMenu />
|
<FileTreeMenu
|
||||||
|
onCreateFile={() => createFile({ dryRun: true })}
|
||||||
|
onCreateFolder={() => createFolder({ dryRun: true })}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<FileTreeInner onNavigateToFile={closePanel} />
|
<FileTreeInner
|
||||||
|
onNavigateToFile={closePanel}
|
||||||
|
newTreeEntry={newTreeEntry}
|
||||||
|
onCreateFile={(name: string) => createFile({ dryRun: false, name })}
|
||||||
|
onCreateFolder={(name: string) => createFolder({ dryRun: false, name })}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FileTreeInner = ({
|
export const FileTreeInner = ({
|
||||||
onNavigateToFile,
|
onNavigateToFile,
|
||||||
|
onCreateFile,
|
||||||
|
onCreateFolder,
|
||||||
|
newTreeEntry,
|
||||||
}: {
|
}: {
|
||||||
|
onCreateFile: (name: string) => void
|
||||||
|
onCreateFolder: (name: string) => void
|
||||||
|
newTreeEntry: TreeEntry
|
||||||
onNavigateToFile?: () => void
|
onNavigateToFile?: () => void
|
||||||
}) => {
|
}) => {
|
||||||
const loaderData = useRouteLoaderData(PATHS.FILE) as IndexLoaderData
|
const loaderData = useRouteLoaderData(PATHS.FILE) as IndexLoaderData
|
||||||
const { send: fileSend, context: fileContext } = useFileContext()
|
const { send: fileSend, context: fileContext } = useFileContext()
|
||||||
const { send: modelingSend } = useModelingContext()
|
const { send: modelingSend } = useModelingContext()
|
||||||
|
|
||||||
|
const [lastDirectoryClicked, setLastDirectoryClicked] = useState<
|
||||||
|
FileEntry | undefined
|
||||||
|
>(undefined)
|
||||||
|
|
||||||
|
const [treeSelection, setTreeSelection] = useState<FileEntry | undefined>(
|
||||||
|
loaderData.file
|
||||||
|
)
|
||||||
|
|
||||||
|
const onNavigateToFile_ = () => {
|
||||||
|
// Reset modeling state when navigating to a new file
|
||||||
|
onNavigateToFile?.()
|
||||||
|
modelingSend({ type: 'Cancel' })
|
||||||
|
}
|
||||||
|
|
||||||
// Refresh the file tree when there are changes.
|
// Refresh the file tree when there are changes.
|
||||||
useFileSystemWatcher(
|
useFileSystemWatcher(
|
||||||
async (eventType, path) => {
|
async (eventType, path) => {
|
||||||
@ -508,34 +662,82 @@ export const FileTreeInner = ({
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
const clickDirectory = () => {
|
const onTreeEntryInputSubmit = (value: string) => {
|
||||||
|
if (newTreeEntry === 'file') {
|
||||||
|
onCreateFile(value)
|
||||||
|
onNavigateToFile_()
|
||||||
|
} else {
|
||||||
|
onCreateFolder(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const onClickDirectory = (
|
||||||
|
open_: boolean,
|
||||||
|
fileOrDir: FileEntry,
|
||||||
|
parentDir: FileEntry | undefined
|
||||||
|
) => {
|
||||||
|
// open true is closed... it's broken. Save me. I've inverted it here for
|
||||||
|
// sanity.
|
||||||
|
const open = !open_
|
||||||
|
|
||||||
|
const target = open ? fileOrDir : parentDir
|
||||||
|
|
||||||
|
// We're at the root, can't select anything further
|
||||||
|
if (!target) return
|
||||||
|
|
||||||
|
setTreeSelection(target)
|
||||||
|
setLastDirectoryClicked(target)
|
||||||
fileSend({
|
fileSend({
|
||||||
type: 'Set selected directory',
|
type: 'Set selected directory',
|
||||||
directory: fileContext.project,
|
directory: target,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const showNewTreeEntry =
|
||||||
|
newTreeEntry !== undefined &&
|
||||||
|
fileContext.selectedDirectory.path === loaderData.project?.path
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div className="relative">
|
||||||
<div
|
<div
|
||||||
className="overflow-auto pb-12 absolute inset-0"
|
className="overflow-auto pb-12 absolute inset-0"
|
||||||
data-testid="file-pane-scroll-container"
|
data-testid="file-pane-scroll-container"
|
||||||
>
|
>
|
||||||
<ul className="m-0 p-0 text-sm" onClickCapture={clickDirectory}>
|
<ul className="m-0 p-0 text-sm">
|
||||||
{sortProject(fileContext.project?.children || []).map((fileOrDir) => (
|
{showNewTreeEntry && (
|
||||||
|
<div
|
||||||
|
className="flex items-center"
|
||||||
|
style={{ paddingInlineStart: getIndentationCSS(0) }}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon
|
||||||
|
icon={faPencil}
|
||||||
|
className="inline-block mr-2 m-0 p-0 w-2 h-2"
|
||||||
|
/>
|
||||||
|
<TreeEntryInput level={-1} onSubmit={onTreeEntryInputSubmit} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{sortFilesAndDirectories(fileContext.project?.children || []).map(
|
||||||
|
(fileOrDir) => (
|
||||||
<FileTreeItem
|
<FileTreeItem
|
||||||
|
parentDir={fileContext.project}
|
||||||
project={fileContext.project}
|
project={fileContext.project}
|
||||||
currentFile={loaderData?.file}
|
currentFile={loaderData?.file}
|
||||||
|
lastDirectoryClicked={lastDirectoryClicked}
|
||||||
fileOrDir={fileOrDir}
|
fileOrDir={fileOrDir}
|
||||||
onNavigateToFile={() => {
|
onCreateFile={onCreateFile}
|
||||||
// Reset modeling state when navigating to a new file
|
onCreateFolder={onCreateFolder}
|
||||||
modelingSend({ type: 'Cancel' })
|
newTreeEntry={newTreeEntry}
|
||||||
onNavigateToFile?.()
|
onClickDirectory={onClickDirectory}
|
||||||
}}
|
onNavigateToFile={onNavigateToFile_}
|
||||||
key={fileOrDir.path}
|
key={fileOrDir.path}
|
||||||
|
treeSelection={treeSelection}
|
||||||
|
setTreeSelection={setTreeSelection}
|
||||||
/>
|
/>
|
||||||
))}
|
)
|
||||||
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,23 @@ export function LowerRightControls({
|
|||||||
Report a bug
|
Report a bug
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</a>
|
</a>
|
||||||
|
<Link
|
||||||
|
to={
|
||||||
|
location.pathname.includes(PATHS.FILE)
|
||||||
|
? filePath + PATHS.TELEMETRY + '?tab=project'
|
||||||
|
: PATHS.HOME + PATHS.TELEMETRY
|
||||||
|
}
|
||||||
|
data-testid="telemetry-link"
|
||||||
|
>
|
||||||
|
<CustomIcon
|
||||||
|
name="stopwatch"
|
||||||
|
className={`w-5 h-5 ${linkOverrideClassName}`}
|
||||||
|
/>
|
||||||
|
<span className="sr-only">Telemetry</span>
|
||||||
|
<Tooltip position="top" contentClassName="text-xs">
|
||||||
|
Telemetry
|
||||||
|
</Tooltip>
|
||||||
|
</Link>
|
||||||
<Link
|
<Link
|
||||||
to={
|
to={
|
||||||
location.pathname.includes(PATHS.FILE)
|
location.pathname.includes(PATHS.FILE)
|
||||||
|
@ -158,8 +158,12 @@ export const ModelingMachineProvider = ({
|
|||||||
'enable copilot': () => {
|
'enable copilot': () => {
|
||||||
editorManager.setCopilotEnabled(true)
|
editorManager.setCopilotEnabled(true)
|
||||||
},
|
},
|
||||||
'sketch exit execute': ({ context: { store } }) => {
|
// tsc reports this typing as perfectly fine, but eslint is complaining.
|
||||||
;(async () => {
|
// It's actually nonsensical, so I'm quieting.
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||||
|
'sketch exit execute': async ({
|
||||||
|
context: { store },
|
||||||
|
}): Promise<void> => {
|
||||||
// When cancelling the sketch mode we should disable sketch mode within the engine.
|
// When cancelling the sketch mode we should disable sketch mode within the engine.
|
||||||
await engineCommandManager.sendSceneCommand({
|
await engineCommandManager.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
@ -177,7 +181,7 @@ export const ModelingMachineProvider = ({
|
|||||||
|
|
||||||
store.videoElement?.pause()
|
store.videoElement?.pause()
|
||||||
|
|
||||||
kclManager
|
return kclManager
|
||||||
.executeCode()
|
.executeCode()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (engineCommandManager.engineConnection?.idleMode) return
|
if (engineCommandManager.engineConnection?.idleMode) return
|
||||||
@ -187,7 +191,6 @@ export const ModelingMachineProvider = ({
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(reportRejection)
|
.catch(reportRejection)
|
||||||
})().catch(reportRejection)
|
|
||||||
},
|
},
|
||||||
'Set mouse state': assign(({ context, event }) => {
|
'Set mouse state': assign(({ context, event }) => {
|
||||||
if (event.type !== 'Set mouse state') return {}
|
if (event.type !== 'Set mouse state') return {}
|
||||||
|
@ -48,7 +48,7 @@ export const ModelingPaneHeader = ({
|
|||||||
bgClassName: 'bg-transparent dark:bg-transparent',
|
bgClassName: 'bg-transparent dark:bg-transparent',
|
||||||
}}
|
}}
|
||||||
className="!p-0 !bg-transparent hover:text-primary border-transparent dark:!border-transparent hover:!border-primary dark:hover:!border-chalkboard-70 !outline-none"
|
className="!p-0 !bg-transparent hover:text-primary border-transparent dark:!border-transparent hover:!border-primary dark:hover:!border-chalkboard-70 !outline-none"
|
||||||
onClick={onClose}
|
onClick={() => onClose()}
|
||||||
>
|
>
|
||||||
<Tooltip position="bottom-right" delay={750}>
|
<Tooltip position="bottom-right" delay={750}>
|
||||||
Close
|
Close
|
||||||
@ -59,14 +59,12 @@ export const ModelingPaneHeader = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const ModelingPane = ({
|
export const ModelingPane = ({
|
||||||
title,
|
|
||||||
icon,
|
|
||||||
id,
|
id,
|
||||||
children,
|
children,
|
||||||
className,
|
className,
|
||||||
Menu,
|
|
||||||
detailsTestId,
|
detailsTestId,
|
||||||
onClose,
|
onClose,
|
||||||
|
title,
|
||||||
...props
|
...props
|
||||||
}: ModelingPaneProps) => {
|
}: ModelingPaneProps) => {
|
||||||
const { settings } = useSettingsAuthContext()
|
const { settings } = useSettingsAuthContext()
|
||||||
@ -78,6 +76,7 @@ export const ModelingPane = ({
|
|||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
{...props}
|
{...props}
|
||||||
|
title={title && typeof title === 'string' ? title : ''}
|
||||||
data-testid={detailsTestId}
|
data-testid={detailsTestId}
|
||||||
id={id}
|
id={id}
|
||||||
className={
|
className={
|
||||||
@ -88,14 +87,7 @@ export const ModelingPane = ({
|
|||||||
(className || '')
|
(className || '')
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<ModelingPaneHeader
|
{children}
|
||||||
id={id}
|
|
||||||
icon={icon}
|
|
||||||
title={title}
|
|
||||||
Menu={Menu}
|
|
||||||
onClose={onClose}
|
|
||||||
/>
|
|
||||||
<div className="relative w-full">{children}</div>
|
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import { CamDebugSettings } from 'clientSideScene/ClientSideSceneComp'
|
|||||||
|
|
||||||
export const DebugPane = () => {
|
export const DebugPane = () => {
|
||||||
return (
|
return (
|
||||||
|
<div className="relative">
|
||||||
<section
|
<section
|
||||||
data-testid="debug-panel"
|
data-testid="debug-panel"
|
||||||
className="absolute inset-0 p-2 box-border overflow-auto"
|
className="absolute inset-0 p-2 box-border overflow-auto"
|
||||||
@ -16,5 +17,6 @@ export const DebugPane = () => {
|
|||||||
<DebugFeatureTree />
|
<DebugFeatureTree />
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { Themes, getSystemTheme } from 'lib/theme'
|
|||||||
import { useMemo, useRef } from 'react'
|
import { useMemo, useRef } from 'react'
|
||||||
import { highlightSelectionMatches, searchKeymap } from '@codemirror/search'
|
import { highlightSelectionMatches, searchKeymap } from '@codemirror/search'
|
||||||
import { lineHighlightField } from 'editor/highlightextension'
|
import { lineHighlightField } from 'editor/highlightextension'
|
||||||
import { roundOff } from 'lib/utils'
|
import { onMouseDragMakeANewNumber, onMouseDragRegex } from 'lib/utils'
|
||||||
import {
|
import {
|
||||||
lineNumbers,
|
lineNumbers,
|
||||||
rectangularSelection,
|
rectangularSelection,
|
||||||
@ -129,7 +129,9 @@ export const KclEditorPane = () => {
|
|||||||
closeBrackets(),
|
closeBrackets(),
|
||||||
highlightActiveLine(),
|
highlightActiveLine(),
|
||||||
highlightSelectionMatches(),
|
highlightSelectionMatches(),
|
||||||
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
|
syntaxHighlighting(defaultHighlightStyle, {
|
||||||
|
fallback: true,
|
||||||
|
}),
|
||||||
rectangularSelection(),
|
rectangularSelection(),
|
||||||
dropCursor(),
|
dropCursor(),
|
||||||
interact({
|
interact({
|
||||||
@ -137,29 +139,12 @@ export const KclEditorPane = () => {
|
|||||||
// a rule for a number dragger
|
// a rule for a number dragger
|
||||||
{
|
{
|
||||||
// the regexp matching the value
|
// the regexp matching the value
|
||||||
regexp: /-?\b\d+\.?\d*\b/g,
|
regexp: onMouseDragRegex,
|
||||||
// set cursor to "ew-resize" on hover
|
// set cursor to "ew-resize" on hover
|
||||||
cursor: 'ew-resize',
|
cursor: 'ew-resize',
|
||||||
// change number value based on mouse X movement on drag
|
// change number value based on mouse X movement on drag
|
||||||
onDrag: (text, setText, e) => {
|
onDrag: (text, setText, e) => {
|
||||||
const multiplier =
|
onMouseDragMakeANewNumber(text, setText, e)
|
||||||
e.shiftKey && e.metaKey
|
|
||||||
? 0.01
|
|
||||||
: e.metaKey
|
|
||||||
? 0.1
|
|
||||||
: e.shiftKey
|
|
||||||
? 10
|
|
||||||
: 1
|
|
||||||
|
|
||||||
const delta = e.movementX * multiplier
|
|
||||||
|
|
||||||
const newVal = roundOff(
|
|
||||||
Number(text) + delta,
|
|
||||||
multiplier === 0.01 ? 2 : multiplier === 0.1 ? 1 : 0
|
|
||||||
)
|
|
||||||
|
|
||||||
if (isNaN(newVal)) return
|
|
||||||
setText(newVal.toString())
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -174,9 +159,12 @@ export const KclEditorPane = () => {
|
|||||||
const initialCode = useRef(codeManager.code)
|
const initialCode = useRef(codeManager.code)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div className="relative">
|
||||||
<div
|
<div
|
||||||
id="code-mirror-override"
|
id="code-mirror-override"
|
||||||
className={'absolute inset-0 ' + (cursorBlinking.current ? 'blink' : '')}
|
className={
|
||||||
|
'absolute inset-0 ' + (cursorBlinking.current ? 'blink' : '')
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<CodeEditor
|
<CodeEditor
|
||||||
initialDocValue={initialCode.current}
|
initialDocValue={initialCode.current}
|
||||||
@ -196,5 +184,6 @@ export const KclEditorPane = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -43,14 +43,14 @@ describe('processMemory', () => {
|
|||||||
tag: null,
|
tag: null,
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
faceId: expect.any(String),
|
faceId: expect.any(String),
|
||||||
sourceRange: [170, 194],
|
sourceRange: [170, 194, 0],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'extrudePlane',
|
type: 'extrudePlane',
|
||||||
tag: null,
|
tag: null,
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
faceId: expect.any(String),
|
faceId: expect.any(String),
|
||||||
sourceRange: [202, 230],
|
sourceRange: [202, 230, 0],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
theSketch: [
|
theSketch: [
|
||||||
|
@ -2,11 +2,17 @@ import { IconDefinition, faBugSlash } from '@fortawesome/free-solid-svg-icons'
|
|||||||
import { KclEditorMenu } from 'components/ModelingSidebar/ModelingPanes/KclEditorMenu'
|
import { KclEditorMenu } from 'components/ModelingSidebar/ModelingPanes/KclEditorMenu'
|
||||||
import { CustomIconName } from 'components/CustomIcon'
|
import { CustomIconName } from 'components/CustomIcon'
|
||||||
import { KclEditorPane } from 'components/ModelingSidebar/ModelingPanes/KclEditorPane'
|
import { KclEditorPane } from 'components/ModelingSidebar/ModelingPanes/KclEditorPane'
|
||||||
|
import { ModelingPaneHeader } from 'components/ModelingSidebar/ModelingPane'
|
||||||
import { MouseEventHandler, ReactNode } from 'react'
|
import { MouseEventHandler, ReactNode } from 'react'
|
||||||
import { MemoryPane, MemoryPaneMenu } from './MemoryPane'
|
import { MemoryPane, MemoryPaneMenu } from './MemoryPane'
|
||||||
import { LogsPane } from './LoggingPanes'
|
import { LogsPane } from './LoggingPanes'
|
||||||
import { DebugPane } from './DebugPane'
|
import { DebugPane } from './DebugPane'
|
||||||
import { FileTreeInner, FileTreeMenu, FileTreeRoot } from 'components/FileTree'
|
import {
|
||||||
|
FileTreeInner,
|
||||||
|
FileTreeMenu,
|
||||||
|
FileTreeRoot,
|
||||||
|
useFileTreeOperations,
|
||||||
|
} from 'components/FileTree'
|
||||||
import { useKclContext } from 'lang/KclProvider'
|
import { useKclContext } from 'lang/KclProvider'
|
||||||
import { editorManager } from 'lib/singletons'
|
import { editorManager } from 'lib/singletons'
|
||||||
import { ContextFrom } from 'xstate'
|
import { ContextFrom } from 'xstate'
|
||||||
@ -38,20 +44,19 @@ interface PaneCallbackProps {
|
|||||||
|
|
||||||
export type SidebarPane = {
|
export type SidebarPane = {
|
||||||
id: SidebarType
|
id: SidebarType
|
||||||
title: ReactNode
|
sidebarName: string
|
||||||
sidebarName?: string
|
|
||||||
icon: CustomIconName | IconDefinition
|
icon: CustomIconName | IconDefinition
|
||||||
keybinding: string
|
keybinding: string
|
||||||
Content: ReactNode | React.FC
|
Content: React.FC<{ id: SidebarType; onClose: () => void }>
|
||||||
Menu?: ReactNode | React.FC
|
|
||||||
hide?: boolean | ((props: PaneCallbackProps) => boolean)
|
hide?: boolean | ((props: PaneCallbackProps) => boolean)
|
||||||
showBadge?: BadgeInfo
|
showBadge?: BadgeInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SidebarAction = {
|
export type SidebarAction = {
|
||||||
id: string
|
id: string
|
||||||
title: ReactNode
|
sidebarName: string
|
||||||
icon: CustomIconName
|
icon: CustomIconName
|
||||||
|
title: ReactNode
|
||||||
iconClassName?: string // Just until we get rid of FontAwesome icons
|
iconClassName?: string // Just until we get rid of FontAwesome icons
|
||||||
keybinding: string
|
keybinding: string
|
||||||
action: () => void
|
action: () => void
|
||||||
@ -59,14 +64,30 @@ export type SidebarAction = {
|
|||||||
disable?: () => string | undefined
|
disable?: () => string | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For now a lot of icons are the same but the reality is they could totally
|
||||||
|
// be different, like an icon based on some data for the pane, or the icon
|
||||||
|
// changes to be a spinning loader on loading.
|
||||||
|
|
||||||
export const sidebarPanes: SidebarPane[] = [
|
export const sidebarPanes: SidebarPane[] = [
|
||||||
{
|
{
|
||||||
id: 'code',
|
id: 'code',
|
||||||
title: 'KCL Code',
|
|
||||||
icon: 'code',
|
icon: 'code',
|
||||||
Content: KclEditorPane,
|
sidebarName: 'KCL Code',
|
||||||
|
Content: (props: { id: SidebarType; onClose: () => void }) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ModelingPaneHeader
|
||||||
|
id={props.id}
|
||||||
|
icon="code"
|
||||||
|
title="KCL Code"
|
||||||
|
Menu={<KclEditorMenu />}
|
||||||
|
onClose={props.onClose}
|
||||||
|
/>
|
||||||
|
<KclEditorPane />
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
},
|
||||||
keybinding: 'Shift + C',
|
keybinding: 'Shift + C',
|
||||||
Menu: KclEditorMenu,
|
|
||||||
showBadge: {
|
showBadge: {
|
||||||
value: ({ kclContext }) => {
|
value: ({ kclContext }) => {
|
||||||
return kclContext.errors.length
|
return kclContext.errors.length
|
||||||
@ -79,34 +100,96 @@ export const sidebarPanes: SidebarPane[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'files',
|
id: 'files',
|
||||||
title: <FileTreeRoot />,
|
|
||||||
sidebarName: 'Project Files',
|
|
||||||
icon: 'folder',
|
icon: 'folder',
|
||||||
Content: FileTreeInner,
|
sidebarName: 'Project Files',
|
||||||
|
Content: (props: { id: SidebarType; onClose: () => void }) => {
|
||||||
|
const { createFile, createFolder, newTreeEntry } = useFileTreeOperations()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ModelingPaneHeader
|
||||||
|
id={props.id}
|
||||||
|
icon="folder"
|
||||||
|
title={<FileTreeRoot />}
|
||||||
|
Menu={
|
||||||
|
<FileTreeMenu
|
||||||
|
onCreateFile={() => createFile({ dryRun: true })}
|
||||||
|
onCreateFolder={() => createFolder({ dryRun: true })}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
onClose={props.onClose}
|
||||||
|
/>
|
||||||
|
<FileTreeInner
|
||||||
|
onCreateFile={(name: string) => createFile({ dryRun: false, name })}
|
||||||
|
onCreateFolder={(name: string) =>
|
||||||
|
createFolder({ dryRun: false, name })
|
||||||
|
}
|
||||||
|
newTreeEntry={newTreeEntry}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
},
|
||||||
keybinding: 'Shift + F',
|
keybinding: 'Shift + F',
|
||||||
Menu: FileTreeMenu,
|
|
||||||
hide: ({ platform }) => platform === 'web',
|
hide: ({ platform }) => platform === 'web',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'variables',
|
id: 'variables',
|
||||||
title: 'Variables',
|
|
||||||
icon: 'make-variable',
|
icon: 'make-variable',
|
||||||
Content: MemoryPane,
|
sidebarName: 'Variables',
|
||||||
Menu: MemoryPaneMenu,
|
Content: (props: { id: SidebarType; onClose: () => void }) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ModelingPaneHeader
|
||||||
|
id={props.id}
|
||||||
|
icon="make-variable"
|
||||||
|
title="Variables"
|
||||||
|
Menu={<MemoryPaneMenu />}
|
||||||
|
onClose={props.onClose}
|
||||||
|
/>
|
||||||
|
<MemoryPane />
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
},
|
||||||
keybinding: 'Shift + V',
|
keybinding: 'Shift + V',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'logs',
|
id: 'logs',
|
||||||
title: 'Logs',
|
|
||||||
icon: 'logs',
|
icon: 'logs',
|
||||||
Content: LogsPane,
|
sidebarName: 'Logs',
|
||||||
|
Content: (props: { id: SidebarType; onClose: () => void }) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ModelingPaneHeader
|
||||||
|
id={props.id}
|
||||||
|
icon="logs"
|
||||||
|
title="Logs"
|
||||||
|
Menu={null}
|
||||||
|
onClose={props.onClose}
|
||||||
|
/>
|
||||||
|
<LogsPane />
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
},
|
||||||
keybinding: 'Shift + L',
|
keybinding: 'Shift + L',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'debug',
|
id: 'debug',
|
||||||
title: 'Debug',
|
|
||||||
icon: faBugSlash,
|
icon: faBugSlash,
|
||||||
Content: DebugPane,
|
sidebarName: 'Debug',
|
||||||
|
Content: (props: { id: SidebarType; onClose: () => void }) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ModelingPaneHeader
|
||||||
|
id={props.id}
|
||||||
|
icon={faBugSlash}
|
||||||
|
title="Debug"
|
||||||
|
Menu={null}
|
||||||
|
onClose={props.onClose}
|
||||||
|
/>
|
||||||
|
<DebugPane />
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
},
|
||||||
keybinding: 'Shift + D',
|
keybinding: 'Shift + D',
|
||||||
hide: ({ settings }) => !settings.modeling.showDebugPanel.current,
|
hide: ({ settings }) => !settings.modeling.showDebugPanel.current,
|
||||||
},
|
},
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
.grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: auto 1fr;
|
|
||||||
grid-template-rows: 1fr 1fr;
|
|
||||||
row-gap: 0.25rem;
|
|
||||||
align-items: stretch;
|
|
||||||
position: relative;
|
|
||||||
padding-block: 1px;
|
|
||||||
max-width: 100%;
|
|
||||||
flex: 1 1 0;
|
|
||||||
}
|
|
||||||
|
@ -5,14 +5,12 @@ import {
|
|||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
useMemo,
|
useMemo,
|
||||||
ReactNode,
|
|
||||||
useContext,
|
useContext,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
import { useHotkeys } from 'react-hotkeys-hook'
|
import { useHotkeys } from 'react-hotkeys-hook'
|
||||||
import { SidebarAction, SidebarType, sidebarPanes } from './ModelingPanes'
|
import { SidebarAction, SidebarType, sidebarPanes } from './ModelingPanes'
|
||||||
import Tooltip from 'components/Tooltip'
|
import Tooltip from 'components/Tooltip'
|
||||||
import { ActionIcon } from 'components/ActionIcon'
|
import { ActionIcon } from 'components/ActionIcon'
|
||||||
import styles from './ModelingSidebar.module.css'
|
|
||||||
import { ModelingPane } from './ModelingPane'
|
import { ModelingPane } from './ModelingPane'
|
||||||
import { isDesktop } from 'lib/isDesktop'
|
import { isDesktop } from 'lib/isDesktop'
|
||||||
import { useModelingContext } from 'hooks/useModelingContext'
|
import { useModelingContext } from 'hooks/useModelingContext'
|
||||||
@ -62,6 +60,7 @@ export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) {
|
|||||||
{
|
{
|
||||||
id: 'export',
|
id: 'export',
|
||||||
title: 'Export part',
|
title: 'Export part',
|
||||||
|
sidebarName: 'Export part',
|
||||||
icon: 'floppyDiskArrow',
|
icon: 'floppyDiskArrow',
|
||||||
keybinding: 'Ctrl + Shift + E',
|
keybinding: 'Ctrl + Shift + E',
|
||||||
action: () =>
|
action: () =>
|
||||||
@ -73,6 +72,7 @@ export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) {
|
|||||||
{
|
{
|
||||||
id: 'make',
|
id: 'make',
|
||||||
title: 'Make part',
|
title: 'Make part',
|
||||||
|
sidebarName: 'Make part',
|
||||||
icon: 'printer3d',
|
icon: 'printer3d',
|
||||||
keybinding: 'Ctrl + Shift + M',
|
keybinding: 'Ctrl + Shift + M',
|
||||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||||
@ -182,7 +182,7 @@ export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) {
|
|||||||
bottomRight: 'hidden',
|
bottomRight: 'hidden',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div id="app-sidebar" className={styles.grid + ' flex-1'}>
|
<div id="app-sidebar" className="flex flex-row h-full">
|
||||||
<ul
|
<ul
|
||||||
className={
|
className={
|
||||||
(context.store?.openPanes.length === 0 ? 'rounded-r ' : '') +
|
(context.store?.openPanes.length === 0 ? 'rounded-r ' : '') +
|
||||||
@ -220,7 +220,7 @@ export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) {
|
|||||||
key={action.id}
|
key={action.id}
|
||||||
paneConfig={{
|
paneConfig={{
|
||||||
id: action.id,
|
id: action.id,
|
||||||
title: action.title,
|
sidebarName: action.sidebarName,
|
||||||
icon: action.icon,
|
icon: action.icon,
|
||||||
keybinding: action.keybinding,
|
keybinding: action.keybinding,
|
||||||
iconClassName: action.iconClassName,
|
iconClassName: action.iconClassName,
|
||||||
@ -237,10 +237,8 @@ export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) {
|
|||||||
<ul
|
<ul
|
||||||
id="pane-section"
|
id="pane-section"
|
||||||
className={
|
className={
|
||||||
'ml-[-1px] col-start-2 col-span-1 flex flex-col gap-2 ' +
|
'ml-[-1px] col-start-2 col-span-1 flex flex-col items-stretch gap-2 ' +
|
||||||
(context.store?.openPanes.length >= 1
|
(context.store?.openPanes.length >= 1 ? `w-full` : `hidden`)
|
||||||
? `row-start-1 row-end-3`
|
|
||||||
: `hidden`)
|
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{filteredPanes
|
{filteredPanes
|
||||||
@ -249,13 +247,15 @@ export function ModelingSidebar({ paneOpacity }: ModelingSidebarProps) {
|
|||||||
<ModelingPane
|
<ModelingPane
|
||||||
key={pane.id}
|
key={pane.id}
|
||||||
icon={pane.icon}
|
icon={pane.icon}
|
||||||
|
title={pane.sidebarName}
|
||||||
|
onClose={() => {}}
|
||||||
id={`${pane.id}-pane`}
|
id={`${pane.id}-pane`}
|
||||||
title={pane.title}
|
|
||||||
Menu={pane.Menu}
|
|
||||||
onClose={() => togglePane(pane.id)}
|
|
||||||
>
|
>
|
||||||
{pane.Content instanceof Function ? (
|
{pane.Content instanceof Function ? (
|
||||||
<pane.Content />
|
<pane.Content
|
||||||
|
id={pane.id}
|
||||||
|
onClose={() => togglePane(pane.id)}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
pane.Content
|
pane.Content
|
||||||
)}
|
)}
|
||||||
@ -271,8 +271,7 @@ interface ModelingPaneButtonProps
|
|||||||
extends React.HTMLAttributes<HTMLButtonElement> {
|
extends React.HTMLAttributes<HTMLButtonElement> {
|
||||||
paneConfig: {
|
paneConfig: {
|
||||||
id: string
|
id: string
|
||||||
title: ReactNode
|
sidebarName: string
|
||||||
sidebarName?: string
|
|
||||||
icon: CustomIconName | IconDefinition
|
icon: CustomIconName | IconDefinition
|
||||||
keybinding: string
|
keybinding: string
|
||||||
iconClassName?: string
|
iconClassName?: string
|
||||||
@ -301,10 +300,7 @@ function ModelingPaneButton({
|
|||||||
<button
|
<button
|
||||||
className="group pointer-events-auto flex items-center justify-center border-transparent dark:border-transparent disabled:!border-transparent p-0 m-0 rounded-sm !outline-0 focus-visible:border-primary"
|
className="group pointer-events-auto flex items-center justify-center border-transparent dark:border-transparent disabled:!border-transparent p-0 m-0 rounded-sm !outline-0 focus-visible:border-primary"
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
name={
|
name={paneConfig.sidebarName}
|
||||||
paneConfig.sidebarName ??
|
|
||||||
(typeof paneConfig.title === 'string' ? paneConfig.title : '')
|
|
||||||
}
|
|
||||||
data-testid={paneConfig.id + '-pane-button'}
|
data-testid={paneConfig.id + '-pane-button'}
|
||||||
disabled={disabledText !== undefined}
|
disabled={disabledText !== undefined}
|
||||||
aria-disabled={disabledText !== undefined}
|
aria-disabled={disabledText !== undefined}
|
||||||
@ -320,7 +316,7 @@ function ModelingPaneButton({
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<span className="sr-only">
|
<span className="sr-only">
|
||||||
{paneConfig.sidebarName ?? paneConfig.title}
|
{paneConfig.sidebarName}
|
||||||
{paneIsOpen !== undefined ? ` pane` : ''}
|
{paneIsOpen !== undefined ? ` pane` : ''}
|
||||||
</span>
|
</span>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
@ -329,7 +325,7 @@ function ModelingPaneButton({
|
|||||||
hoverOnly
|
hoverOnly
|
||||||
>
|
>
|
||||||
<span className="flex-1">
|
<span className="flex-1">
|
||||||
{paneConfig.sidebarName ?? paneConfig.title}
|
{paneConfig.sidebarName}
|
||||||
{disabledText !== undefined ? ` (${disabledText})` : ''}
|
{disabledText !== undefined ? ` (${disabledText})` : ''}
|
||||||
{paneIsOpen !== undefined ? ` pane` : ''}
|
{paneIsOpen !== undefined ? ` pane` : ''}
|
||||||
</span>
|
</span>
|
||||||
|
33
src/components/RouteProvider.tsx
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import { useEffect, useState, createContext, ReactNode } from 'react'
|
||||||
|
import { useNavigation, useLocation } from 'react-router-dom'
|
||||||
|
import { PATHS } from 'lib/paths'
|
||||||
|
import { markOnce } from 'lib/performance'
|
||||||
|
|
||||||
|
export const RouteProviderContext = createContext({})
|
||||||
|
|
||||||
|
export function RouteProvider({ children }: { children: ReactNode }) {
|
||||||
|
const [first, setFirstState] = useState(true)
|
||||||
|
const navigation = useNavigation()
|
||||||
|
const location = useLocation()
|
||||||
|
useEffect(() => {
|
||||||
|
// On initialization, the react-router-dom does not send a 'loading' state event.
|
||||||
|
// it sends an idle event first.
|
||||||
|
const pathname = first ? location.pathname : navigation.location?.pathname
|
||||||
|
const isHome = pathname === PATHS.HOME
|
||||||
|
const isFile =
|
||||||
|
pathname?.includes(PATHS.FILE) &&
|
||||||
|
pathname?.substring(pathname?.length - 4) === '.kcl'
|
||||||
|
if (isHome) {
|
||||||
|
markOnce('code/willLoadHome')
|
||||||
|
} else if (isFile) {
|
||||||
|
markOnce('code/willLoadFile')
|
||||||
|
}
|
||||||
|
setFirstState(false)
|
||||||
|
}, [navigation])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<RouteProviderContext.Provider value={{}}>
|
||||||
|
{children}
|
||||||
|
</RouteProviderContext.Provider>
|
||||||
|
)
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
import { trap } from 'lib/trap'
|
import { trap } from 'lib/trap'
|
||||||
import { useMachine } from '@xstate/react'
|
import { useMachine } from '@xstate/react'
|
||||||
import { useNavigate, useRouteLoaderData, useLocation } from 'react-router-dom'
|
import { useNavigate, useRouteLoaderData, useLocation } from 'react-router-dom'
|
||||||
import { PATHS } from 'lib/paths'
|
import { PATHS, BROWSER_PATH } from 'lib/paths'
|
||||||
import { authMachine, TOKEN_PERSIST_KEY } from '../machines/authMachine'
|
import { authMachine, TOKEN_PERSIST_KEY } from '../machines/authMachine'
|
||||||
import withBaseUrl from '../lib/withBaseURL'
|
import withBaseUrl from '../lib/withBaseURL'
|
||||||
import React, { createContext, useEffect, useState } from 'react'
|
import React, { createContext, useEffect, useState } from 'react'
|
||||||
@ -41,6 +41,7 @@ import { reportRejection } from 'lib/trap'
|
|||||||
import { getAppSettingsFilePath } from 'lib/desktop'
|
import { getAppSettingsFilePath } from 'lib/desktop'
|
||||||
import { isDesktop } from 'lib/isDesktop'
|
import { isDesktop } from 'lib/isDesktop'
|
||||||
import { useFileSystemWatcher } from 'hooks/useFileSystemWatcher'
|
import { useFileSystemWatcher } from 'hooks/useFileSystemWatcher'
|
||||||
|
import { createRouteCommands } from 'lib/commandBarConfigs/routeCommandConfig'
|
||||||
|
|
||||||
type MachineContext<T extends AnyStateMachine> = {
|
type MachineContext<T extends AnyStateMachine> = {
|
||||||
state: StateFrom<T>
|
state: StateFrom<T>
|
||||||
@ -284,6 +285,44 @@ export const SettingsAuthProviderBase = ({
|
|||||||
settingsWithCommandConfigs,
|
settingsWithCommandConfigs,
|
||||||
])
|
])
|
||||||
|
|
||||||
|
// Due to the route provider, i've moved this to the SettingsAuthProvider instead of CommandBarProvider
|
||||||
|
// This will register the commands to route to Telemetry, Home, and Settings.
|
||||||
|
useEffect(() => {
|
||||||
|
const filePath =
|
||||||
|
PATHS.FILE +
|
||||||
|
'/' +
|
||||||
|
encodeURIComponent(loadedProject?.file?.path || BROWSER_PATH)
|
||||||
|
const { RouteTelemetryCommand, RouteHomeCommand, RouteSettingsCommand } =
|
||||||
|
createRouteCommands(navigate, location, filePath)
|
||||||
|
commandBarSend({
|
||||||
|
type: 'Remove commands',
|
||||||
|
data: {
|
||||||
|
commands: [
|
||||||
|
RouteTelemetryCommand,
|
||||||
|
RouteHomeCommand,
|
||||||
|
RouteSettingsCommand,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if (location.pathname === PATHS.HOME) {
|
||||||
|
commandBarSend({
|
||||||
|
type: 'Add commands',
|
||||||
|
data: { commands: [RouteTelemetryCommand, RouteSettingsCommand] },
|
||||||
|
})
|
||||||
|
} else if (location.pathname.includes(PATHS.FILE)) {
|
||||||
|
commandBarSend({
|
||||||
|
type: 'Add commands',
|
||||||
|
data: {
|
||||||
|
commands: [
|
||||||
|
RouteTelemetryCommand,
|
||||||
|
RouteSettingsCommand,
|
||||||
|
RouteHomeCommand,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, [location])
|
||||||
|
|
||||||
// Listen for changes to the system theme and update the app theme accordingly
|
// Listen for changes to the system theme and update the app theme accordingly
|
||||||
// This is only done if the theme setting is set to 'system'.
|
// This is only done if the theme setting is set to 'system'.
|
||||||
// It can't be done in XState (in an invoked callback, for example)
|
// It can't be done in XState (in an invoked callback, for example)
|
||||||
|
72
src/components/TelemetryExplorer.tsx
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
import { getMarks } from 'lib/performance'
|
||||||
|
|
||||||
|
import {
|
||||||
|
printDeltaTotal,
|
||||||
|
printInvocationCount,
|
||||||
|
printMarkDownTable,
|
||||||
|
printRawMarks,
|
||||||
|
} from 'lib/telemetry'
|
||||||
|
|
||||||
|
export function TelemetryExplorer() {
|
||||||
|
const marks = getMarks()
|
||||||
|
const markdownTable = printMarkDownTable(marks)
|
||||||
|
const rawMarks = printRawMarks(marks)
|
||||||
|
const deltaTotalTable = printDeltaTotal(marks)
|
||||||
|
const invocationCount = printInvocationCount(marks)
|
||||||
|
// TODO data-telemetry-type
|
||||||
|
// TODO data-telemetry-name
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1 className="pb-4">Marks</h1>
|
||||||
|
<div className="max-w-xl max-h-64 overflow-auto select-all">
|
||||||
|
{marks.map((mark, index) => {
|
||||||
|
return (
|
||||||
|
<pre className="text-xs" key={index}>
|
||||||
|
<code key={index}>{JSON.stringify(mark, null, 2)}</code>
|
||||||
|
</pre>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
<h1 className="pb-4">Startup Performance</h1>
|
||||||
|
<div className="max-w-xl max-h-64 overflow-auto select-all">
|
||||||
|
{markdownTable.map((line, index) => {
|
||||||
|
return (
|
||||||
|
<pre className="text-xs" key={index}>
|
||||||
|
<code key={index}>{line}</code>
|
||||||
|
</pre>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
<h1 className="pb-4">Delta and Totals</h1>
|
||||||
|
<div className="max-w-xl max-h-64 overflow-auto select-all">
|
||||||
|
{deltaTotalTable.map((line, index) => {
|
||||||
|
return (
|
||||||
|
<pre className="text-xs" key={index}>
|
||||||
|
<code key={index}>{line}</code>
|
||||||
|
</pre>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
<h1 className="pb-4">Raw Marks</h1>
|
||||||
|
<div className="max-w-xl max-h-64 overflow-auto select-all">
|
||||||
|
{rawMarks.map((line, index) => {
|
||||||
|
return (
|
||||||
|
<pre className="text-xs" key={index}>
|
||||||
|
<code key={index}>{line}</code>
|
||||||
|
</pre>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
<h1 className="pb-4">Invocation Count</h1>
|
||||||
|
<div className="max-w-xl max-h-64 overflow-auto select-all">
|
||||||
|
{invocationCount.map((line, index) => {
|
||||||
|
return (
|
||||||
|
<pre className="text-xs" key={index}>
|
||||||
|
<code key={index}>{line}</code>
|
||||||
|
</pre>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
import { EditorView, ViewUpdate } from '@codemirror/view'
|
import { EditorView, ViewUpdate } from '@codemirror/view'
|
||||||
|
import { syntaxTree } from '@codemirror/language'
|
||||||
import { EditorSelection, Annotation, Transaction } from '@codemirror/state'
|
import { EditorSelection, Annotation, Transaction } from '@codemirror/state'
|
||||||
import { engineCommandManager } from 'lib/singletons'
|
import { engineCommandManager } from 'lib/singletons'
|
||||||
import { modelingMachine, ModelingMachineEvent } from 'machines/modelingMachine'
|
import { modelingMachine, ModelingMachineEvent } from 'machines/modelingMachine'
|
||||||
@ -12,6 +13,7 @@ import {
|
|||||||
setDiagnosticsEffect,
|
setDiagnosticsEffect,
|
||||||
} from '@codemirror/lint'
|
} from '@codemirror/lint'
|
||||||
import { StateFrom } from 'xstate'
|
import { StateFrom } from 'xstate'
|
||||||
|
import { markOnce } from 'lib/performance'
|
||||||
|
|
||||||
const updateOutsideEditorAnnotation = Annotation.define<boolean>()
|
const updateOutsideEditorAnnotation = Annotation.define<boolean>()
|
||||||
export const updateOutsideEditorEvent = updateOutsideEditorAnnotation.of(true)
|
export const updateOutsideEditorEvent = updateOutsideEditorAnnotation.of(true)
|
||||||
@ -59,6 +61,49 @@ export default class EditorManager {
|
|||||||
|
|
||||||
setEditorView(editorView: EditorView) {
|
setEditorView(editorView: EditorView) {
|
||||||
this._editorView = editorView
|
this._editorView = editorView
|
||||||
|
this.overrideTreeHighlighterUpdateForPerformanceTracking()
|
||||||
|
}
|
||||||
|
|
||||||
|
overrideTreeHighlighterUpdateForPerformanceTracking() {
|
||||||
|
// @ts-ignore
|
||||||
|
this._editorView?.plugins.forEach((e) => {
|
||||||
|
let sawATreeDiff = false
|
||||||
|
|
||||||
|
// we cannot use <>.constructor.name since it will get destroyed
|
||||||
|
// when packaging the application.
|
||||||
|
const isTreeHighlightPlugin =
|
||||||
|
e?.value &&
|
||||||
|
e.value?.hasOwnProperty('tree') &&
|
||||||
|
e.value?.hasOwnProperty('decoratedTo') &&
|
||||||
|
e.value?.hasOwnProperty('decorations')
|
||||||
|
|
||||||
|
if (isTreeHighlightPlugin) {
|
||||||
|
let originalUpdate = e.value.update
|
||||||
|
// @ts-ignore
|
||||||
|
function performanceTrackingUpdate(args) {
|
||||||
|
/**
|
||||||
|
* TreeHighlighter.update will be called multiple times on start up.
|
||||||
|
* We do not want to track the highlight performance of an empty update.
|
||||||
|
* mark the syntax highlight one time when the new tree comes in with the
|
||||||
|
* initial code
|
||||||
|
*/
|
||||||
|
const treeIsDifferent =
|
||||||
|
// @ts-ignore
|
||||||
|
!sawATreeDiff && this.tree !== syntaxTree(args.state)
|
||||||
|
if (treeIsDifferent && !sawATreeDiff) {
|
||||||
|
markOnce('code/willSyntaxHighlight')
|
||||||
|
}
|
||||||
|
// Call the original function
|
||||||
|
// @ts-ignore
|
||||||
|
originalUpdate.apply(this, [args])
|
||||||
|
if (treeIsDifferent && !sawATreeDiff) {
|
||||||
|
markOnce('code/didSyntaxHighlight')
|
||||||
|
sawATreeDiff = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
e.value.update = performanceTrackingUpdate
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
get editorView(): EditorView | null {
|
get editorView(): EditorView | null {
|
||||||
|
@ -8,8 +8,10 @@ import ModalContainer from 'react-modal-promise'
|
|||||||
import { isDesktop } from 'lib/isDesktop'
|
import { isDesktop } from 'lib/isDesktop'
|
||||||
import { AppStreamProvider } from 'AppState'
|
import { AppStreamProvider } from 'AppState'
|
||||||
import { ToastUpdate } from 'components/ToastUpdate'
|
import { ToastUpdate } from 'components/ToastUpdate'
|
||||||
|
import { markOnce } from 'lib/performance'
|
||||||
import { AUTO_UPDATER_TOAST_ID } from 'lib/constants'
|
import { AUTO_UPDATER_TOAST_ID } from 'lib/constants'
|
||||||
|
|
||||||
|
markOnce('code/willAuth')
|
||||||
// uncomment for xstate inspector
|
// uncomment for xstate inspector
|
||||||
// import { DEV } from 'env'
|
// import { DEV } from 'env'
|
||||||
// import { inspect } from '@xstate/inspect'
|
// import { inspect } from '@xstate/inspect'
|
||||||
|
@ -21,6 +21,7 @@ import {
|
|||||||
import { getNodeFromPath } from './queryAst'
|
import { getNodeFromPath } from './queryAst'
|
||||||
import { codeManager, editorManager, sceneInfra } from 'lib/singletons'
|
import { codeManager, editorManager, sceneInfra } from 'lib/singletons'
|
||||||
import { Diagnostic } from '@codemirror/lint'
|
import { Diagnostic } from '@codemirror/lint'
|
||||||
|
import { markOnce } from 'lib/performance'
|
||||||
import { Node } from 'wasm-lib/kcl/bindings/Node'
|
import { Node } from 'wasm-lib/kcl/bindings/Node'
|
||||||
|
|
||||||
interface ExecuteArgs {
|
interface ExecuteArgs {
|
||||||
@ -38,6 +39,7 @@ export class KclManager {
|
|||||||
body: [],
|
body: [],
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
nonCodeMeta: {
|
nonCodeMeta: {
|
||||||
nonCodeNodes: {},
|
nonCodeNodes: {},
|
||||||
startNodes: [],
|
startNodes: [],
|
||||||
@ -204,6 +206,7 @@ export class KclManager {
|
|||||||
body: [],
|
body: [],
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
nonCodeMeta: {
|
nonCodeMeta: {
|
||||||
nonCodeNodes: {},
|
nonCodeNodes: {},
|
||||||
startNodes: [],
|
startNodes: [],
|
||||||
@ -255,6 +258,7 @@ export class KclManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ast = args.ast || this.ast
|
const ast = args.ast || this.ast
|
||||||
|
markOnce('code/startExecuteAst')
|
||||||
|
|
||||||
const currentExecutionId = args.executionId || Date.now()
|
const currentExecutionId = args.executionId || Date.now()
|
||||||
this._cancelTokens.set(currentExecutionId, false)
|
this._cancelTokens.set(currentExecutionId, false)
|
||||||
@ -329,6 +333,7 @@ export class KclManager {
|
|||||||
})
|
})
|
||||||
|
|
||||||
this._cancelTokens.delete(currentExecutionId)
|
this._cancelTokens.delete(currentExecutionId)
|
||||||
|
markOnce('code/endExecuteAst')
|
||||||
}
|
}
|
||||||
// NOTE: this always updates the code state and editor.
|
// NOTE: this always updates the code state and editor.
|
||||||
// DO NOT CALL THIS from codemirror ever.
|
// DO NOT CALL THIS from codemirror ever.
|
||||||
|
@ -1903,6 +1903,6 @@ describe('parsing errors', () => {
|
|||||||
const error = result as KCLError
|
const error = result as KCLError
|
||||||
expect(error.kind).toBe('syntax')
|
expect(error.kind).toBe('syntax')
|
||||||
expect(error.msg).toBe('Unexpected token: (')
|
expect(error.msg).toBe('Unexpected token: (')
|
||||||
expect(error.sourceRanges).toEqual([[27, 28]])
|
expect(error.sourceRanges).toEqual([[27, 28, 0]])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -19,7 +19,7 @@ const mySketch001 = startSketchOn('XY')
|
|||||||
const sketch001 = execState.memory.get('mySketch001')
|
const sketch001 = execState.memory.get('mySketch001')
|
||||||
expect(sketch001).toEqual({
|
expect(sketch001).toEqual({
|
||||||
type: 'UserVal',
|
type: 'UserVal',
|
||||||
__meta: [{ sourceRange: [46, 71] }],
|
__meta: [{ sourceRange: [46, 71, 0] }],
|
||||||
value: {
|
value: {
|
||||||
type: 'Sketch',
|
type: 'Sketch',
|
||||||
on: expect.any(Object),
|
on: expect.any(Object),
|
||||||
@ -29,7 +29,7 @@ const mySketch001 = startSketchOn('XY')
|
|||||||
tag: null,
|
tag: null,
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [46, 71],
|
sourceRange: [46, 71, 0],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
paths: [
|
paths: [
|
||||||
@ -39,7 +39,7 @@ const mySketch001 = startSketchOn('XY')
|
|||||||
to: [-1.59, -1.54],
|
to: [-1.59, -1.54],
|
||||||
from: [0, 0],
|
from: [0, 0],
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [77, 102],
|
sourceRange: [77, 102, 0],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -49,13 +49,13 @@ const mySketch001 = startSketchOn('XY')
|
|||||||
from: [-1.59, -1.54],
|
from: [-1.59, -1.54],
|
||||||
tag: null,
|
tag: null,
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [108, 132],
|
sourceRange: [108, 132, 0],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
__meta: [{ sourceRange: [46, 71] }],
|
__meta: [{ sourceRange: [46, 71, 0] }],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -80,14 +80,14 @@ const mySketch001 = startSketchOn('XY')
|
|||||||
faceId: expect.any(String),
|
faceId: expect.any(String),
|
||||||
tag: null,
|
tag: null,
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [77, 102],
|
sourceRange: [77, 102, 0],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'extrudePlane',
|
type: 'extrudePlane',
|
||||||
faceId: expect.any(String),
|
faceId: expect.any(String),
|
||||||
tag: null,
|
tag: null,
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [108, 132],
|
sourceRange: [108, 132, 0],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
sketch: {
|
sketch: {
|
||||||
@ -104,7 +104,7 @@ const mySketch001 = startSketchOn('XY')
|
|||||||
tag: null,
|
tag: null,
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [77, 102],
|
sourceRange: [77, 102, 0],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -114,7 +114,7 @@ const mySketch001 = startSketchOn('XY')
|
|||||||
tag: null,
|
tag: null,
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [108, 132],
|
sourceRange: [108, 132, 0],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -122,7 +122,7 @@ const mySketch001 = startSketchOn('XY')
|
|||||||
height: 2,
|
height: 2,
|
||||||
startCapId: expect.any(String),
|
startCapId: expect.any(String),
|
||||||
endCapId: expect.any(String),
|
endCapId: expect.any(String),
|
||||||
__meta: [{ sourceRange: [46, 71] }],
|
__meta: [{ sourceRange: [46, 71, 0] }],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
test('sketch extrude and sketch on one of the faces', async () => {
|
test('sketch extrude and sketch on one of the faces', async () => {
|
||||||
@ -162,7 +162,7 @@ const sk2 = startSketchOn('XY')
|
|||||||
faceId: expect.any(String),
|
faceId: expect.any(String),
|
||||||
tag: null,
|
tag: null,
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [69, 89],
|
sourceRange: [69, 89, 0],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'extrudePlane',
|
type: 'extrudePlane',
|
||||||
@ -174,14 +174,14 @@ const sk2 = startSketchOn('XY')
|
|||||||
value: 'p',
|
value: 'p',
|
||||||
},
|
},
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [95, 117],
|
sourceRange: [95, 117, 0],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'extrudePlane',
|
type: 'extrudePlane',
|
||||||
faceId: expect.any(String),
|
faceId: expect.any(String),
|
||||||
tag: null,
|
tag: null,
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [123, 142],
|
sourceRange: [123, 142, 0],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
sketch: {
|
sketch: {
|
||||||
@ -194,7 +194,7 @@ const sk2 = startSketchOn('XY')
|
|||||||
p: {
|
p: {
|
||||||
__meta: [
|
__meta: [
|
||||||
{
|
{
|
||||||
sourceRange: [114, 116],
|
sourceRange: [114, 116, 0],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
type: 'TagIdentifier',
|
type: 'TagIdentifier',
|
||||||
@ -210,7 +210,7 @@ const sk2 = startSketchOn('XY')
|
|||||||
tag: null,
|
tag: null,
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [69, 89],
|
sourceRange: [69, 89, 0],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -225,7 +225,7 @@ const sk2 = startSketchOn('XY')
|
|||||||
},
|
},
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [95, 117],
|
sourceRange: [95, 117, 0],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -235,7 +235,7 @@ const sk2 = startSketchOn('XY')
|
|||||||
tag: null,
|
tag: null,
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [123, 142],
|
sourceRange: [123, 142, 0],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -243,7 +243,7 @@ const sk2 = startSketchOn('XY')
|
|||||||
height: 2,
|
height: 2,
|
||||||
startCapId: expect.any(String),
|
startCapId: expect.any(String),
|
||||||
endCapId: expect.any(String),
|
endCapId: expect.any(String),
|
||||||
__meta: [{ sourceRange: [38, 63] }],
|
__meta: [{ sourceRange: [38, 63, 0] }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'Solid',
|
type: 'Solid',
|
||||||
@ -254,7 +254,7 @@ const sk2 = startSketchOn('XY')
|
|||||||
faceId: expect.any(String),
|
faceId: expect.any(String),
|
||||||
tag: null,
|
tag: null,
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [373, 393],
|
sourceRange: [373, 393, 0],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'extrudePlane',
|
type: 'extrudePlane',
|
||||||
@ -266,14 +266,14 @@ const sk2 = startSketchOn('XY')
|
|||||||
value: 'o',
|
value: 'o',
|
||||||
},
|
},
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [399, 420],
|
sourceRange: [399, 420, 0],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'extrudePlane',
|
type: 'extrudePlane',
|
||||||
faceId: expect.any(String),
|
faceId: expect.any(String),
|
||||||
tag: null,
|
tag: null,
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [426, 445],
|
sourceRange: [426, 445, 0],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
sketch: {
|
sketch: {
|
||||||
@ -286,7 +286,7 @@ const sk2 = startSketchOn('XY')
|
|||||||
o: {
|
o: {
|
||||||
__meta: [
|
__meta: [
|
||||||
{
|
{
|
||||||
sourceRange: [417, 419],
|
sourceRange: [417, 419, 0],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
type: 'TagIdentifier',
|
type: 'TagIdentifier',
|
||||||
@ -302,7 +302,7 @@ const sk2 = startSketchOn('XY')
|
|||||||
tag: null,
|
tag: null,
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [373, 393],
|
sourceRange: [373, 393, 0],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -317,7 +317,7 @@ const sk2 = startSketchOn('XY')
|
|||||||
},
|
},
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [399, 420],
|
sourceRange: [399, 420, 0],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -327,7 +327,7 @@ const sk2 = startSketchOn('XY')
|
|||||||
tag: null,
|
tag: null,
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [426, 445],
|
sourceRange: [426, 445, 0],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -335,7 +335,7 @@ const sk2 = startSketchOn('XY')
|
|||||||
height: 2,
|
height: 2,
|
||||||
startCapId: expect.any(String),
|
startCapId: expect.any(String),
|
||||||
endCapId: expect.any(String),
|
endCapId: expect.any(String),
|
||||||
__meta: [{ sourceRange: [342, 367] }],
|
__meta: [{ sourceRange: [342, 367, 0] }],
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
@ -9,8 +9,8 @@ describe('test kclErrToDiagnostic', () => {
|
|||||||
kind: 'semantic',
|
kind: 'semantic',
|
||||||
msg: 'Semantic error',
|
msg: 'Semantic error',
|
||||||
sourceRanges: [
|
sourceRanges: [
|
||||||
[0, 1],
|
[0, 1, 0],
|
||||||
[2, 3],
|
[2, 3, 0],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -19,8 +19,8 @@ describe('test kclErrToDiagnostic', () => {
|
|||||||
kind: 'type',
|
kind: 'type',
|
||||||
msg: 'Type error',
|
msg: 'Type error',
|
||||||
sourceRanges: [
|
sourceRanges: [
|
||||||
[4, 5],
|
[4, 5, 0],
|
||||||
[6, 7],
|
[6, 7, 0],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -4,15 +4,17 @@ import { posToOffset } from '@kittycad/codemirror-lsp-client'
|
|||||||
import { Diagnostic as LspDiagnostic } from 'vscode-languageserver-protocol'
|
import { Diagnostic as LspDiagnostic } from 'vscode-languageserver-protocol'
|
||||||
import { Text } from '@codemirror/state'
|
import { Text } from '@codemirror/state'
|
||||||
|
|
||||||
|
const TOP_LEVEL_MODULE_ID = 0
|
||||||
|
|
||||||
type ExtractKind<T> = T extends { kind: infer K } ? K : never
|
type ExtractKind<T> = T extends { kind: infer K } ? K : never
|
||||||
export class KCLError extends Error {
|
export class KCLError extends Error {
|
||||||
kind: ExtractKind<RustKclError> | 'name'
|
kind: ExtractKind<RustKclError> | 'name'
|
||||||
sourceRanges: [number, number][]
|
sourceRanges: [number, number, number][]
|
||||||
msg: string
|
msg: string
|
||||||
constructor(
|
constructor(
|
||||||
kind: ExtractKind<RustKclError> | 'name',
|
kind: ExtractKind<RustKclError> | 'name',
|
||||||
msg: string,
|
msg: string,
|
||||||
sourceRanges: [number, number][]
|
sourceRanges: [number, number, number][]
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
this.kind = kind
|
this.kind = kind
|
||||||
@ -23,63 +25,63 @@ export class KCLError extends Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class KCLLexicalError extends KCLError {
|
export class KCLLexicalError extends KCLError {
|
||||||
constructor(msg: string, sourceRanges: [number, number][]) {
|
constructor(msg: string, sourceRanges: [number, number, number][]) {
|
||||||
super('lexical', msg, sourceRanges)
|
super('lexical', msg, sourceRanges)
|
||||||
Object.setPrototypeOf(this, KCLSyntaxError.prototype)
|
Object.setPrototypeOf(this, KCLSyntaxError.prototype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class KCLInternalError extends KCLError {
|
export class KCLInternalError extends KCLError {
|
||||||
constructor(msg: string, sourceRanges: [number, number][]) {
|
constructor(msg: string, sourceRanges: [number, number, number][]) {
|
||||||
super('internal', msg, sourceRanges)
|
super('internal', msg, sourceRanges)
|
||||||
Object.setPrototypeOf(this, KCLSyntaxError.prototype)
|
Object.setPrototypeOf(this, KCLSyntaxError.prototype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class KCLSyntaxError extends KCLError {
|
export class KCLSyntaxError extends KCLError {
|
||||||
constructor(msg: string, sourceRanges: [number, number][]) {
|
constructor(msg: string, sourceRanges: [number, number, number][]) {
|
||||||
super('syntax', msg, sourceRanges)
|
super('syntax', msg, sourceRanges)
|
||||||
Object.setPrototypeOf(this, KCLSyntaxError.prototype)
|
Object.setPrototypeOf(this, KCLSyntaxError.prototype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class KCLSemanticError extends KCLError {
|
export class KCLSemanticError extends KCLError {
|
||||||
constructor(msg: string, sourceRanges: [number, number][]) {
|
constructor(msg: string, sourceRanges: [number, number, number][]) {
|
||||||
super('semantic', msg, sourceRanges)
|
super('semantic', msg, sourceRanges)
|
||||||
Object.setPrototypeOf(this, KCLSemanticError.prototype)
|
Object.setPrototypeOf(this, KCLSemanticError.prototype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class KCLTypeError extends KCLError {
|
export class KCLTypeError extends KCLError {
|
||||||
constructor(msg: string, sourceRanges: [number, number][]) {
|
constructor(msg: string, sourceRanges: [number, number, number][]) {
|
||||||
super('type', msg, sourceRanges)
|
super('type', msg, sourceRanges)
|
||||||
Object.setPrototypeOf(this, KCLTypeError.prototype)
|
Object.setPrototypeOf(this, KCLTypeError.prototype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class KCLUnimplementedError extends KCLError {
|
export class KCLUnimplementedError extends KCLError {
|
||||||
constructor(msg: string, sourceRanges: [number, number][]) {
|
constructor(msg: string, sourceRanges: [number, number, number][]) {
|
||||||
super('unimplemented', msg, sourceRanges)
|
super('unimplemented', msg, sourceRanges)
|
||||||
Object.setPrototypeOf(this, KCLUnimplementedError.prototype)
|
Object.setPrototypeOf(this, KCLUnimplementedError.prototype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class KCLUnexpectedError extends KCLError {
|
export class KCLUnexpectedError extends KCLError {
|
||||||
constructor(msg: string, sourceRanges: [number, number][]) {
|
constructor(msg: string, sourceRanges: [number, number, number][]) {
|
||||||
super('unexpected', msg, sourceRanges)
|
super('unexpected', msg, sourceRanges)
|
||||||
Object.setPrototypeOf(this, KCLUnexpectedError.prototype)
|
Object.setPrototypeOf(this, KCLUnexpectedError.prototype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class KCLValueAlreadyDefined extends KCLError {
|
export class KCLValueAlreadyDefined extends KCLError {
|
||||||
constructor(key: string, sourceRanges: [number, number][]) {
|
constructor(key: string, sourceRanges: [number, number, number][]) {
|
||||||
super('name', `Key ${key} was already defined elsewhere`, sourceRanges)
|
super('name', `Key ${key} was already defined elsewhere`, sourceRanges)
|
||||||
Object.setPrototypeOf(this, KCLValueAlreadyDefined.prototype)
|
Object.setPrototypeOf(this, KCLValueAlreadyDefined.prototype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class KCLUndefinedValueError extends KCLError {
|
export class KCLUndefinedValueError extends KCLError {
|
||||||
constructor(key: string, sourceRanges: [number, number][]) {
|
constructor(key: string, sourceRanges: [number, number, number][]) {
|
||||||
super('name', `Key ${key} has not been defined`, sourceRanges)
|
super('name', `Key ${key} has not been defined`, sourceRanges)
|
||||||
Object.setPrototypeOf(this, KCLUndefinedValueError.prototype)
|
Object.setPrototypeOf(this, KCLUndefinedValueError.prototype)
|
||||||
}
|
}
|
||||||
@ -97,13 +99,22 @@ export function lspDiagnosticsToKclErrors(
|
|||||||
.flatMap(
|
.flatMap(
|
||||||
({ range, message }) =>
|
({ range, message }) =>
|
||||||
new KCLError('unexpected', message, [
|
new KCLError('unexpected', message, [
|
||||||
[posToOffset(doc, range.start)!, posToOffset(doc, range.end)!],
|
[
|
||||||
|
posToOffset(doc, range.start)!,
|
||||||
|
posToOffset(doc, range.end)!,
|
||||||
|
TOP_LEVEL_MODULE_ID,
|
||||||
|
],
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
.filter(({ sourceRanges }) => {
|
.filter(({ sourceRanges }) => {
|
||||||
const [from, to] = sourceRanges[0]
|
const [from, to, moduleId] = sourceRanges[0]
|
||||||
return (
|
return (
|
||||||
from !== null && to !== null && from !== undefined && to !== undefined
|
from !== null &&
|
||||||
|
to !== null &&
|
||||||
|
from !== undefined &&
|
||||||
|
to !== undefined &&
|
||||||
|
// Filter out errors that are not from the top-level module.
|
||||||
|
moduleId === TOP_LEVEL_MODULE_ID
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
@ -127,8 +138,16 @@ export function kclErrorsToDiagnostics(
|
|||||||
errors: KCLError[]
|
errors: KCLError[]
|
||||||
): CodeMirrorDiagnostic[] {
|
): CodeMirrorDiagnostic[] {
|
||||||
return errors?.flatMap((err) => {
|
return errors?.flatMap((err) => {
|
||||||
return err.sourceRanges.map(([from, to]) => {
|
const sourceRanges: CodeMirrorDiagnostic[] = err.sourceRanges
|
||||||
|
// Filter out errors that are not from the top-level module.
|
||||||
|
.filter(([_start, _end, moduleId]) => moduleId === TOP_LEVEL_MODULE_ID)
|
||||||
|
.map(([from, to]) => {
|
||||||
return { from, to, message: err.msg, severity: 'error' }
|
return { from, to, message: err.msg, severity: 'error' }
|
||||||
})
|
})
|
||||||
|
// Make sure we didn't filter out all the source ranges.
|
||||||
|
if (sourceRanges.length === 0) {
|
||||||
|
sourceRanges.push({ from: 0, to: 0, message: err.msg, severity: 'error' })
|
||||||
|
}
|
||||||
|
return sourceRanges
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ const newVar = myVar + 1`
|
|||||||
to: [0, 2],
|
to: [0, 2],
|
||||||
from: [0, 0],
|
from: [0, 0],
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [72, 97],
|
sourceRange: [72, 97, 0],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
tag: {
|
tag: {
|
||||||
@ -81,7 +81,7 @@ const newVar = myVar + 1`
|
|||||||
from: [0, 2],
|
from: [0, 2],
|
||||||
tag: null,
|
tag: null,
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [103, 119],
|
sourceRange: [103, 119, 0],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -90,7 +90,7 @@ const newVar = myVar + 1`
|
|||||||
to: [5, -1],
|
to: [5, -1],
|
||||||
from: [2, 3],
|
from: [2, 3],
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [125, 154],
|
sourceRange: [125, 154, 0],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
tag: {
|
tag: {
|
||||||
@ -160,14 +160,14 @@ const newVar = myVar + 1`
|
|||||||
tag: null,
|
tag: null,
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
sourceRange: [39, 63],
|
sourceRange: [39, 63, 0],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
tags: {
|
tags: {
|
||||||
myPath: {
|
myPath: {
|
||||||
__meta: [
|
__meta: [
|
||||||
{
|
{
|
||||||
sourceRange: [109, 116],
|
sourceRange: [109, 116, 0],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
type: 'TagIdentifier',
|
type: 'TagIdentifier',
|
||||||
@ -182,7 +182,7 @@ const newVar = myVar + 1`
|
|||||||
from: [0, 0],
|
from: [0, 0],
|
||||||
tag: null,
|
tag: null,
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [69, 85],
|
sourceRange: [69, 85, 0],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -191,7 +191,7 @@ const newVar = myVar + 1`
|
|||||||
to: [0, 1],
|
to: [0, 1],
|
||||||
from: [1, 1],
|
from: [1, 1],
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [91, 117],
|
sourceRange: [91, 117, 0],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
tag: {
|
tag: {
|
||||||
@ -207,15 +207,15 @@ const newVar = myVar + 1`
|
|||||||
from: [0, 1],
|
from: [0, 1],
|
||||||
tag: null,
|
tag: null,
|
||||||
__geoMeta: {
|
__geoMeta: {
|
||||||
sourceRange: [123, 139],
|
sourceRange: [123, 139, 0],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
__meta: [{ sourceRange: [39, 63] }],
|
__meta: [{ sourceRange: [39, 63, 0] }],
|
||||||
},
|
},
|
||||||
__meta: [{ sourceRange: [39, 63] }],
|
__meta: [{ sourceRange: [39, 63, 0] }],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
it('execute array expression', async () => {
|
it('execute array expression', async () => {
|
||||||
@ -229,7 +229,7 @@ const newVar = myVar + 1`
|
|||||||
value: 3,
|
value: 3,
|
||||||
__meta: [
|
__meta: [
|
||||||
{
|
{
|
||||||
sourceRange: [14, 15],
|
sourceRange: [14, 15, 0],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@ -238,7 +238,7 @@ const newVar = myVar + 1`
|
|||||||
value: [1, '2', 3, 9],
|
value: [1, '2', 3, 9],
|
||||||
__meta: [
|
__meta: [
|
||||||
{
|
{
|
||||||
sourceRange: [27, 49],
|
sourceRange: [27, 49, 0],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@ -257,7 +257,7 @@ const newVar = myVar + 1`
|
|||||||
value: { aStr: 'str', anum: 2, identifier: 3, binExp: 9 },
|
value: { aStr: 'str', anum: 2, identifier: 3, binExp: 9 },
|
||||||
__meta: [
|
__meta: [
|
||||||
{
|
{
|
||||||
sourceRange: [27, 83],
|
sourceRange: [27, 83, 0],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@ -272,7 +272,7 @@ const newVar = myVar + 1`
|
|||||||
value: '123',
|
value: '123',
|
||||||
__meta: [
|
__meta: [
|
||||||
{
|
{
|
||||||
sourceRange: [41, 50],
|
sourceRange: [41, 50, 0],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@ -426,7 +426,7 @@ const theExtrude = startSketchOn('XY')
|
|||||||
new KCLError(
|
new KCLError(
|
||||||
'undefined_value',
|
'undefined_value',
|
||||||
'memory item key `myVarZ` is not defined',
|
'memory item key `myVarZ` is not defined',
|
||||||
[[129, 135]]
|
[[129, 135, 0]]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
87
src/lang/kclSamples.test.ts
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
import { parse, initPromise, programMemoryInit } from './wasm'
|
||||||
|
import { enginelessExecutor } from '../lib/testHelpers'
|
||||||
|
import { assert } from 'vitest'
|
||||||
|
// These unit tests makes web requests to a public github repository.
|
||||||
|
|
||||||
|
interface KclSampleFile {
|
||||||
|
file: string
|
||||||
|
title: string
|
||||||
|
filename: string
|
||||||
|
description: string
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
await initPromise
|
||||||
|
})
|
||||||
|
|
||||||
|
// Only used to actually fetch an older version of KCL code that will break in the parser.
|
||||||
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
|
async function getBrokenSampleCodeForLocalTesting() {
|
||||||
|
const result = await fetch(
|
||||||
|
'https://raw.githubusercontent.com/KittyCAD/kcl-samples/5ccd04a1773ebdbfd02684057917ce5dbe0eaab3/80-20-rail.kcl'
|
||||||
|
)
|
||||||
|
const text = await result.text()
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getKclSampleCodeFromGithub(file: string): Promise<string> {
|
||||||
|
const result = await fetch(
|
||||||
|
`https://raw.githubusercontent.com/KittyCAD/kcl-samples/refs/heads/main/${file}/${file}.kcl`
|
||||||
|
)
|
||||||
|
const text = await result.text()
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getFileNamesFromManifestJSON(): Promise<KclSampleFile[]> {
|
||||||
|
const result = await fetch(
|
||||||
|
'https://raw.githubusercontent.com/KittyCAD/kcl-samples/refs/heads/main/manifest.json'
|
||||||
|
)
|
||||||
|
const json = await result.json()
|
||||||
|
json.forEach((file: KclSampleFile) => {
|
||||||
|
const filenameWithoutExtension = file.file.split('.')[0]
|
||||||
|
file.filename = filenameWithoutExtension
|
||||||
|
})
|
||||||
|
return json
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value to use across all tests!
|
||||||
|
let files: KclSampleFile[] = []
|
||||||
|
|
||||||
|
describe('Test KCL Samples from public Github repository', () => {
|
||||||
|
describe('When parsing source code', () => {
|
||||||
|
// THIS RUNS ACROSS OTHER TESTS!
|
||||||
|
it('should fetch files', async () => {
|
||||||
|
files = await getFileNamesFromManifestJSON()
|
||||||
|
})
|
||||||
|
// Run through all of the files in the manifest json. This will allow us to be automatically updated
|
||||||
|
// with the latest changes in github. We won't be hard coding the filenames
|
||||||
|
it(
|
||||||
|
'should run through all the files',
|
||||||
|
async () => {
|
||||||
|
for (let i = 0; i < files.length; i++) {
|
||||||
|
const file: KclSampleFile = files[i]
|
||||||
|
const code = await getKclSampleCodeFromGithub(file.filename)
|
||||||
|
const parsed = parse(code)
|
||||||
|
assert(!(parsed instanceof Error))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
files.length * 1000
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('when performing enginelessExecutor', () => {
|
||||||
|
it(
|
||||||
|
'should run through all the files',
|
||||||
|
async () => {
|
||||||
|
for (let i = 0; i < files.length; i++) {
|
||||||
|
const file: KclSampleFile = files[i]
|
||||||
|
const code = await getKclSampleCodeFromGithub(file.filename)
|
||||||
|
const parsed = parse(code)
|
||||||
|
assert(!(parsed instanceof Error))
|
||||||
|
await enginelessExecutor(parsed, programMemoryInit())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
files.length * 1000
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
@ -101,15 +101,15 @@ describe('Testing findUniqueName', () => {
|
|||||||
it('should find a unique name', () => {
|
it('should find a unique name', () => {
|
||||||
const result = findUniqueName(
|
const result = findUniqueName(
|
||||||
JSON.stringify([
|
JSON.stringify([
|
||||||
{ type: 'Identifier', name: 'yo01', start: 0, end: 0 },
|
{ type: 'Identifier', name: 'yo01', start: 0, end: 0, moduleId: 0 },
|
||||||
{ type: 'Identifier', name: 'yo02', start: 0, end: 0 },
|
{ type: 'Identifier', name: 'yo02', start: 0, end: 0, moduleId: 0 },
|
||||||
{ type: 'Identifier', name: 'yo03', start: 0, end: 0 },
|
{ type: 'Identifier', name: 'yo03', start: 0, end: 0, moduleId: 0 },
|
||||||
{ type: 'Identifier', name: 'yo04', start: 0, end: 0 },
|
{ type: 'Identifier', name: 'yo04', start: 0, end: 0, moduleId: 0 },
|
||||||
{ type: 'Identifier', name: 'yo05', start: 0, end: 0 },
|
{ type: 'Identifier', name: 'yo05', start: 0, end: 0, moduleId: 0 },
|
||||||
{ type: 'Identifier', name: 'yo06', start: 0, end: 0 },
|
{ type: 'Identifier', name: 'yo06', start: 0, end: 0, moduleId: 0 },
|
||||||
{ type: 'Identifier', name: 'yo07', start: 0, end: 0 },
|
{ type: 'Identifier', name: 'yo07', start: 0, end: 0, moduleId: 0 },
|
||||||
{ type: 'Identifier', name: 'yo08', start: 0, end: 0 },
|
{ type: 'Identifier', name: 'yo08', start: 0, end: 0, moduleId: 0 },
|
||||||
{ type: 'Identifier', name: 'yo09', start: 0, end: 0 },
|
{ type: 'Identifier', name: 'yo09', start: 0, end: 0, moduleId: 0 },
|
||||||
] satisfies Node<Identifier>[]),
|
] satisfies Node<Identifier>[]),
|
||||||
'yo',
|
'yo',
|
||||||
2
|
2
|
||||||
@ -124,6 +124,7 @@ describe('Testing addSketchTo', () => {
|
|||||||
body: [],
|
body: [],
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
nonCodeMeta: { nonCodeNodes: {}, startNodes: [] },
|
nonCodeMeta: { nonCodeNodes: {}, startNodes: [] },
|
||||||
},
|
},
|
||||||
'yz'
|
'yz'
|
||||||
|
@ -242,6 +242,7 @@ export function mutateObjExpProp(
|
|||||||
value: updateWith,
|
value: updateWith,
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -577,6 +578,7 @@ export function createLiteral(value: string | number): Node<Literal> {
|
|||||||
type: 'Literal',
|
type: 'Literal',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
value,
|
value,
|
||||||
raw: `${value}`,
|
raw: `${value}`,
|
||||||
}
|
}
|
||||||
@ -587,6 +589,7 @@ export function createTagDeclarator(value: string): Node<TagDeclarator> {
|
|||||||
type: 'TagDeclarator',
|
type: 'TagDeclarator',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
|
|
||||||
value,
|
value,
|
||||||
}
|
}
|
||||||
@ -597,6 +600,7 @@ export function createIdentifier(name: string): Node<Identifier> {
|
|||||||
type: 'Identifier',
|
type: 'Identifier',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
|
|
||||||
name,
|
name,
|
||||||
}
|
}
|
||||||
@ -607,6 +611,7 @@ export function createPipeSubstitution(): Node<PipeSubstitution> {
|
|||||||
type: 'PipeSubstitution',
|
type: 'PipeSubstitution',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,10 +623,12 @@ export function createCallExpressionStdLib(
|
|||||||
type: 'CallExpression',
|
type: 'CallExpression',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
callee: {
|
callee: {
|
||||||
type: 'Identifier',
|
type: 'Identifier',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
|
|
||||||
name,
|
name,
|
||||||
},
|
},
|
||||||
@ -638,10 +645,12 @@ export function createCallExpression(
|
|||||||
type: 'CallExpression',
|
type: 'CallExpression',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
callee: {
|
callee: {
|
||||||
type: 'Identifier',
|
type: 'Identifier',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
|
|
||||||
name,
|
name,
|
||||||
},
|
},
|
||||||
@ -657,6 +666,7 @@ export function createArrayExpression(
|
|||||||
type: 'ArrayExpression',
|
type: 'ArrayExpression',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
|
|
||||||
nonCodeMeta: nonCodeMetaEmpty(),
|
nonCodeMeta: nonCodeMetaEmpty(),
|
||||||
elements,
|
elements,
|
||||||
@ -670,6 +680,7 @@ export function createPipeExpression(
|
|||||||
type: 'PipeExpression',
|
type: 'PipeExpression',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
|
|
||||||
body,
|
body,
|
||||||
nonCodeMeta: nonCodeMetaEmpty(),
|
nonCodeMeta: nonCodeMetaEmpty(),
|
||||||
@ -686,12 +697,14 @@ export function createVariableDeclaration(
|
|||||||
type: 'VariableDeclaration',
|
type: 'VariableDeclaration',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
|
|
||||||
declarations: [
|
declarations: [
|
||||||
{
|
{
|
||||||
type: 'VariableDeclarator',
|
type: 'VariableDeclarator',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
|
|
||||||
id: createIdentifier(varName),
|
id: createIdentifier(varName),
|
||||||
init,
|
init,
|
||||||
@ -709,12 +722,14 @@ export function createObjectExpression(properties: {
|
|||||||
type: 'ObjectExpression',
|
type: 'ObjectExpression',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
|
|
||||||
nonCodeMeta: nonCodeMetaEmpty(),
|
nonCodeMeta: nonCodeMetaEmpty(),
|
||||||
properties: Object.entries(properties).map(([key, value]) => ({
|
properties: Object.entries(properties).map(([key, value]) => ({
|
||||||
type: 'ObjectProperty',
|
type: 'ObjectProperty',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
key: createIdentifier(key),
|
key: createIdentifier(key),
|
||||||
|
|
||||||
value,
|
value,
|
||||||
@ -730,6 +745,7 @@ export function createUnaryExpression(
|
|||||||
type: 'UnaryExpression',
|
type: 'UnaryExpression',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
|
|
||||||
operator,
|
operator,
|
||||||
argument,
|
argument,
|
||||||
@ -745,6 +761,7 @@ export function createBinaryExpression([left, operator, right]: [
|
|||||||
type: 'BinaryExpression',
|
type: 'BinaryExpression',
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
|
|
||||||
operator,
|
operator,
|
||||||
left,
|
left,
|
||||||
|
@ -13,6 +13,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
37,
|
37,
|
||||||
64,
|
64,
|
||||||
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"pathIds": [
|
"pathIds": [
|
||||||
@ -31,6 +32,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
37,
|
37,
|
||||||
64,
|
64,
|
||||||
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"planeId": "UUID",
|
"planeId": "UUID",
|
||||||
@ -56,6 +58,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
70,
|
70,
|
||||||
86,
|
86,
|
||||||
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [
|
"edgeIds": [
|
||||||
@ -77,6 +80,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
92,
|
92,
|
||||||
119,
|
119,
|
||||||
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeCutId": "UUID",
|
"edgeCutId": "UUID",
|
||||||
@ -99,6 +103,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
125,
|
125,
|
||||||
150,
|
150,
|
||||||
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [
|
"edgeIds": [
|
||||||
@ -120,6 +125,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
156,
|
156,
|
||||||
203,
|
203,
|
||||||
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [
|
"edgeIds": [
|
||||||
@ -141,6 +147,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
209,
|
209,
|
||||||
217,
|
217,
|
||||||
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [],
|
"edgeIds": [],
|
||||||
@ -162,6 +169,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
231,
|
231,
|
||||||
254,
|
254,
|
||||||
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [
|
"edgeIds": [
|
||||||
@ -289,6 +297,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
260,
|
260,
|
||||||
299,
|
299,
|
||||||
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"consumedEdgeId": "UUID",
|
"consumedEdgeId": "UUID",
|
||||||
@ -307,6 +316,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
350,
|
350,
|
||||||
377,
|
377,
|
||||||
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"planeId": "UUID",
|
"planeId": "UUID",
|
||||||
@ -331,6 +341,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
383,
|
383,
|
||||||
398,
|
398,
|
||||||
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [
|
"edgeIds": [
|
||||||
@ -352,6 +363,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
404,
|
404,
|
||||||
420,
|
420,
|
||||||
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [
|
"edgeIds": [
|
||||||
@ -373,6 +385,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
426,
|
426,
|
||||||
473,
|
473,
|
||||||
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [
|
"edgeIds": [
|
||||||
@ -394,6 +407,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
479,
|
479,
|
||||||
487,
|
487,
|
||||||
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [],
|
"edgeIds": [],
|
||||||
@ -415,6 +429,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
501,
|
501,
|
||||||
522,
|
522,
|
||||||
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [
|
"edgeIds": [
|
||||||
|
@ -49,6 +49,26 @@ sketch002 = startSketchOn(extrude001, seg02)
|
|||||||
extrude002 = extrude(5, sketch002)
|
extrude002 = extrude(5, sketch002)
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const exampleCodeNo3D = `sketch003 = startSketchOn('YZ')
|
||||||
|
|> startProfileAt([5.82, 0], %)
|
||||||
|
|> angledLine([180, 11.54], %, $rectangleSegmentA001)
|
||||||
|
|> angledLine([
|
||||||
|
segAng(rectangleSegmentA001) - 90,
|
||||||
|
8.21
|
||||||
|
], %, $rectangleSegmentB001)
|
||||||
|
|> angledLine([
|
||||||
|
segAng(rectangleSegmentA001),
|
||||||
|
-segLen(rectangleSegmentA001)
|
||||||
|
], %, $rectangleSegmentC001)
|
||||||
|
|> lineTo([profileStartX(%), profileStartY(%)], %)
|
||||||
|
|> close(%)
|
||||||
|
sketch004 = startSketchOn('-XZ')
|
||||||
|
|> startProfileAt([0, 14.36], %)
|
||||||
|
|> line([15.49, 0.05], %)
|
||||||
|
|> tangentialArcTo([0, 0], %)
|
||||||
|
|> tangentialArcTo([-6.8, 8.17], %)
|
||||||
|
`
|
||||||
|
|
||||||
const sketchOnFaceOnFaceEtc = `sketch001 = startSketchOn('XZ')
|
const sketchOnFaceOnFaceEtc = `sketch001 = startSketchOn('XZ')
|
||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
|> line([4, 8], %)
|
|> line([4, 8], %)
|
||||||
@ -83,6 +103,7 @@ extrude004 = extrude(3, sketch004)
|
|||||||
const codeToWriteCacheFor = {
|
const codeToWriteCacheFor = {
|
||||||
exampleCode1,
|
exampleCode1,
|
||||||
sketchOnFaceOnFaceEtc,
|
sketchOnFaceOnFaceEtc,
|
||||||
|
exampleCodeNo3D,
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
type CodeKey = keyof typeof codeToWriteCacheFor
|
type CodeKey = keyof typeof codeToWriteCacheFor
|
||||||
@ -236,6 +257,69 @@ describe('testing createArtifactGraph', () => {
|
|||||||
await GraphTheGraph(theMap, 2000, 2000, 'exampleCode1.png')
|
await GraphTheGraph(theMap, 2000, 2000, 'exampleCode1.png')
|
||||||
}, 20000)
|
}, 20000)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe(`code with sketches but no extrusions or other 3D elements`, () => {
|
||||||
|
let ast: Program
|
||||||
|
let theMap: ReturnType<typeof createArtifactGraph>
|
||||||
|
it(`setup`, () => {
|
||||||
|
// putting this logic in here because describe blocks runs before beforeAll has finished
|
||||||
|
const {
|
||||||
|
orderedCommands,
|
||||||
|
responseMap,
|
||||||
|
ast: _ast,
|
||||||
|
} = getCommands('exampleCodeNo3D')
|
||||||
|
ast = _ast
|
||||||
|
theMap = createArtifactGraph({ orderedCommands, responseMap, ast })
|
||||||
|
})
|
||||||
|
|
||||||
|
it('there should be two planes, one for each sketch path', () => {
|
||||||
|
const planes = [...filterArtifacts({ types: ['plane'] }, theMap)].map(
|
||||||
|
(plane) => expandPlane(plane[1], theMap)
|
||||||
|
)
|
||||||
|
expect(planes).toHaveLength(2)
|
||||||
|
planes.forEach((path) => {
|
||||||
|
expect(path.type).toBe('plane')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('there should be two paths, one on each plane', () => {
|
||||||
|
const paths = [...filterArtifacts({ types: ['path'] }, theMap)].map(
|
||||||
|
(path) => expandPath(path[1], theMap)
|
||||||
|
)
|
||||||
|
expect(paths).toHaveLength(2)
|
||||||
|
paths.forEach((path) => {
|
||||||
|
if (err(path)) throw path
|
||||||
|
expect(path.type).toBe('path')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it(`there should be 1 solid2D, just for the first closed path`, () => {
|
||||||
|
const solid2Ds = [...filterArtifacts({ types: ['solid2D'] }, theMap)]
|
||||||
|
expect(solid2Ds).toHaveLength(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('there should be no extrusions', () => {
|
||||||
|
const extrusions = [...filterArtifacts({ types: ['sweep'] }, theMap)].map(
|
||||||
|
(extrusion) => expandSweep(extrusion[1], theMap)
|
||||||
|
)
|
||||||
|
expect(extrusions).toHaveLength(0)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('there should be 8 segments, 4 + 1 (close) from the first sketch and 3 from the second', () => {
|
||||||
|
const segments = [...filterArtifacts({ types: ['segment'] }, theMap)].map(
|
||||||
|
(segment) => expandSegment(segment[1], theMap)
|
||||||
|
)
|
||||||
|
expect(segments).toHaveLength(8)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('screenshot graph', async () => {
|
||||||
|
// Ostensibly this takes a screen shot of the graph of the artifactGraph
|
||||||
|
// but it's it also tests that all of the id links are correct because if one
|
||||||
|
// of the edges refers to a non-existent node, the graph will throw.
|
||||||
|
// further more we can check that each edge is bi-directional, if it's not
|
||||||
|
// by checking the arrow heads going both ways, on the graph.
|
||||||
|
await GraphTheGraph(theMap, 2000, 2000, 'exampleCodeNo3D.png')
|
||||||
|
}, 20000)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('capture graph of sketchOnFaceOnFace...', () => {
|
describe('capture graph of sketchOnFaceOnFace...', () => {
|
||||||
@ -457,7 +541,10 @@ async function GraphTheGraph(
|
|||||||
`./src/lang/std/artifactMapGraphs/${imageName}`
|
`./src/lang/std/artifactMapGraphs/${imageName}`
|
||||||
)
|
)
|
||||||
// chop the top 30 pixels off the image
|
// chop the top 30 pixels off the image
|
||||||
const originalImg = PNG.sync.read(fs.readFileSync(originalImgPath))
|
const originalImgExists = fs.existsSync(originalImgPath)
|
||||||
|
const originalImg = originalImgExists
|
||||||
|
? PNG.sync.read(fs.readFileSync(originalImgPath))
|
||||||
|
: null
|
||||||
// const img1Data = new Uint8Array(img1.data)
|
// const img1Data = new Uint8Array(img1.data)
|
||||||
// const img1DataChopped = img1Data.slice(30 * img1.width * 4)
|
// const img1DataChopped = img1Data.slice(30 * img1.width * 4)
|
||||||
// img1.data = Buffer.from(img1DataChopped)
|
// img1.data = Buffer.from(img1DataChopped)
|
||||||
@ -468,10 +555,10 @@ async function GraphTheGraph(
|
|||||||
const newImageDataChopped = newImageData.slice(30 * newImage.width * 4)
|
const newImageDataChopped = newImageData.slice(30 * newImage.width * 4)
|
||||||
newImage.data = Buffer.from(newImageDataChopped)
|
newImage.data = Buffer.from(newImageDataChopped)
|
||||||
|
|
||||||
const { width, height } = originalImg
|
const { width, height } = originalImg ?? newImage
|
||||||
const diff = new PNG({ width, height })
|
const diff = new PNG({ width, height })
|
||||||
|
|
||||||
const imageSizeDifferent = originalImg.data.length !== newImage.data.length
|
const imageSizeDifferent = originalImg?.data.length !== newImage.data.length
|
||||||
let numDiffPixels = 0
|
let numDiffPixels = 0
|
||||||
if (!imageSizeDifferent) {
|
if (!imageSizeDifferent) {
|
||||||
numDiffPixels = pixelmatch(
|
numDiffPixels = pixelmatch(
|
||||||
@ -523,7 +610,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
sweepId: '',
|
sweepId: '',
|
||||||
codeRef: {
|
codeRef: {
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
range: [37, 64],
|
range: [37, 64, 0],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
@ -535,7 +622,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceIds: [],
|
surfaceIds: [],
|
||||||
edgeIds: [],
|
edgeIds: [],
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [231, 254],
|
range: [231, 254, 0],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -545,7 +632,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
planeId: expect.any(String),
|
planeId: expect.any(String),
|
||||||
sweepId: expect.any(String),
|
sweepId: expect.any(String),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [37, 64],
|
range: [37, 64, 0],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
solid2dId: expect.any(String),
|
solid2dId: expect.any(String),
|
||||||
@ -558,7 +645,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceId: '',
|
surfaceId: '',
|
||||||
edgeIds: [],
|
edgeIds: [],
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [70, 86],
|
range: [70, 86, 0],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -568,7 +655,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
planeId: expect.any(String),
|
planeId: expect.any(String),
|
||||||
sweepId: expect.any(String),
|
sweepId: expect.any(String),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [37, 64],
|
range: [37, 64, 0],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
solid2dId: expect.any(String),
|
solid2dId: expect.any(String),
|
||||||
@ -582,7 +669,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
edgeIds: [],
|
edgeIds: [],
|
||||||
surfaceId: '',
|
surfaceId: '',
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [260, 299],
|
range: [260, 299, 0],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -592,7 +679,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceId: expect.any(String),
|
surfaceId: expect.any(String),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [92, 119],
|
range: [92, 119, 0],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
edgeCutId: expect.any(String),
|
edgeCutId: expect.any(String),
|
||||||
@ -612,7 +699,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceId: expect.any(String),
|
surfaceId: expect.any(String),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [156, 203],
|
range: [156, 203, 0],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -623,7 +710,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceIds: expect.any(Array),
|
surfaceIds: expect.any(Array),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [231, 254],
|
range: [231, 254, 0],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -640,7 +727,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceId: expect.any(String),
|
surfaceId: expect.any(String),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [125, 150],
|
range: [125, 150, 0],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -651,7 +738,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceIds: expect.any(Array),
|
surfaceIds: expect.any(Array),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [231, 254],
|
range: [231, 254, 0],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -668,7 +755,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceId: expect.any(String),
|
surfaceId: expect.any(String),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [92, 119],
|
range: [92, 119, 0],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
edgeCutId: expect.any(String),
|
edgeCutId: expect.any(String),
|
||||||
@ -680,7 +767,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceIds: expect.any(Array),
|
surfaceIds: expect.any(Array),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [231, 254],
|
range: [231, 254, 0],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -697,7 +784,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceId: expect.any(String),
|
surfaceId: expect.any(String),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [70, 86],
|
range: [70, 86, 0],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -708,7 +795,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceIds: expect.any(Array),
|
surfaceIds: expect.any(Array),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [231, 254],
|
range: [231, 254, 0],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -726,7 +813,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceIds: expect.any(Array),
|
surfaceIds: expect.any(Array),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [231, 254],
|
range: [231, 254, 0],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -744,7 +831,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceIds: expect.any(Array),
|
surfaceIds: expect.any(Array),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [231, 254],
|
range: [231, 254, 0],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -36,9 +36,12 @@ interface solid2D {
|
|||||||
}
|
}
|
||||||
export interface PathArtifactRich {
|
export interface PathArtifactRich {
|
||||||
type: 'path'
|
type: 'path'
|
||||||
|
/** A path must always lie on a plane */
|
||||||
plane: PlaneArtifact | WallArtifact
|
plane: PlaneArtifact | WallArtifact
|
||||||
|
/** A path must always contain 0 or more segments */
|
||||||
segments: Array<SegmentArtifact>
|
segments: Array<SegmentArtifact>
|
||||||
sweep: SweepArtifact
|
/** A path may not result in a sweep artifact */
|
||||||
|
sweep?: SweepArtifact
|
||||||
codeRef: CommonCommandProperties
|
codeRef: CommonCommandProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,13 +590,15 @@ export function expandPath(
|
|||||||
{ keys: path.segIds, types: ['segment'] },
|
{ keys: path.segIds, types: ['segment'] },
|
||||||
artifactGraph
|
artifactGraph
|
||||||
)
|
)
|
||||||
const sweep = getArtifactOfTypes(
|
const sweep = path.sweepId
|
||||||
|
? getArtifactOfTypes(
|
||||||
{
|
{
|
||||||
key: path.sweepId,
|
key: path.sweepId,
|
||||||
types: ['sweep'],
|
types: ['sweep'],
|
||||||
},
|
},
|
||||||
artifactGraph
|
artifactGraph
|
||||||
)
|
)
|
||||||
|
: undefined
|
||||||
const plane = getArtifactOfTypes(
|
const plane = getArtifactOfTypes(
|
||||||
{ key: path.planeId, types: ['plane', 'wall'] },
|
{ key: path.planeId, types: ['plane', 'wall'] },
|
||||||
artifactGraph
|
artifactGraph
|
||||||
@ -628,7 +633,7 @@ export function expandSweep(
|
|||||||
if (err(path)) return path
|
if (err(path)) return path
|
||||||
return {
|
return {
|
||||||
type: 'sweep',
|
type: 'sweep',
|
||||||
subType: 'extrusion',
|
subType: sweep.subType,
|
||||||
surfaces: Array.from(surfs.values()),
|
surfaces: Array.from(surfs.values()),
|
||||||
edges: Array.from(edges.values()),
|
edges: Array.from(edges.values()),
|
||||||
path,
|
path,
|
||||||
|
BIN
src/lang/std/artifactMapGraphs/exampleCodeNo3D.png
Normal file
After Width: | Height: | Size: 92 KiB |
@ -28,6 +28,7 @@ import {
|
|||||||
} from 'lib/constants'
|
} from 'lib/constants'
|
||||||
import { KclManager } from 'lang/KclSingleton'
|
import { KclManager } from 'lang/KclSingleton'
|
||||||
import { reportRejection } from 'lib/trap'
|
import { reportRejection } from 'lib/trap'
|
||||||
|
import { markOnce } from 'lib/performance'
|
||||||
import { MachineManager } from 'components/MachineManagerProvider'
|
import { MachineManager } from 'components/MachineManagerProvider'
|
||||||
|
|
||||||
// TODO(paultag): This ought to be tweakable.
|
// TODO(paultag): This ought to be tweakable.
|
||||||
@ -330,6 +331,7 @@ class EngineConnection extends EventTarget {
|
|||||||
token?: string
|
token?: string
|
||||||
callbackOnEngineLiteConnect?: () => void
|
callbackOnEngineLiteConnect?: () => void
|
||||||
}) {
|
}) {
|
||||||
|
markOnce('code/startInitialEngineConnect')
|
||||||
super()
|
super()
|
||||||
|
|
||||||
this.engineCommandManager = engineCommandManager
|
this.engineCommandManager = engineCommandManager
|
||||||
@ -785,6 +787,7 @@ class EngineConnection extends EventTarget {
|
|||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new CustomEvent(EngineConnectionEvents.Opened, { detail: this })
|
new CustomEvent(EngineConnectionEvents.Opened, { detail: this })
|
||||||
)
|
)
|
||||||
|
markOnce('code/endInitialEngineConnect')
|
||||||
}
|
}
|
||||||
this.unreliableDataChannel?.addEventListener(
|
this.unreliableDataChannel?.addEventListener(
|
||||||
'open',
|
'open',
|
||||||
|
@ -1823,11 +1823,13 @@ export const updateStartProfileAtArgs: SketchLineHelper['updateArgs'] = ({
|
|||||||
modifiedAst: {
|
modifiedAst: {
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
body: [],
|
body: [],
|
||||||
|
|
||||||
nonCodeMeta: {
|
nonCodeMeta: {
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
|
moduleId: 0,
|
||||||
startNodes: [],
|
startNodes: [],
|
||||||
nonCodeNodes: [],
|
nonCodeNodes: [],
|
||||||
},
|
},
|
||||||
|
@ -120,8 +120,8 @@ const initialise = async () => {
|
|||||||
|
|
||||||
export const initPromise = initialise()
|
export const initPromise = initialise()
|
||||||
|
|
||||||
export const rangeTypeFix = (ranges: number[][]): [number, number][] =>
|
export const rangeTypeFix = (ranges: number[][]): [number, number, number][] =>
|
||||||
ranges.map(([start, end]) => [start, end])
|
ranges.map(([start, end, moduleId]) => [start, end, moduleId])
|
||||||
|
|
||||||
export const parse = (code: string | Error): Node<Program> | Error => {
|
export const parse = (code: string | Error): Node<Program> | Error => {
|
||||||
if (err(code)) return code
|
if (err(code)) return code
|
||||||
|