Compare commits

..

9 Commits

1241 changed files with 228917 additions and 383278 deletions

View File

@ -1,4 +1,5 @@
NODE_ENV=production NODE_ENV=production
DEV=false
VITE_KC_API_WS_MODELING_URL=wss://api.zoo.dev/ws/modeling/commands VITE_KC_API_WS_MODELING_URL=wss://api.zoo.dev/ws/modeling/commands
VITE_KC_API_BASE_URL=https://api.zoo.dev VITE_KC_API_BASE_URL=https://api.zoo.dev
VITE_KC_SITE_BASE_URL=https://zoo.dev VITE_KC_SITE_BASE_URL=https://zoo.dev

View File

@ -1,4 +1,3 @@
src/wasm-lib/* src/wasm-lib/*
*.typegen.ts *.typegen.ts
packages/codemirror-lsp-client/dist/* packages/codemirror-lsp-client/dist/*
e2e/playwright/snapshots/prompt-to-edit/*

13
.gitattributes vendored
View File

@ -1,13 +0,0 @@
# Set default behavior to automatically normalize line endings.
* text=auto
# Force batch scripts to always use CRLF line endings so that if a repo is accessed
# in Windows via a file share from Linux, the scripts will work.
*.{cmd,[cC][mM][dD]} text working-tree-encoding=UTF-16LE eol=CRLF
*.{bat,[bB][aA][tT]} text working-tree-encoding=UTF-16LE eol=CRLF
*.{ics,[iI][cC][sS]} text working-tree-encoding=UTF-16LE eol=CRLF
*.{ps1,[iP][sS][1]} text working-tree-encoding=UTF-16LE eol=CRLF
# Force bash scripts to always use LF line endings so that if a repo is accessed
# in Unix via a file share from Windows, the scripts will work.
*.sh text eol=lfol=lf

View File

@ -21,7 +21,7 @@ if [[ ! -f "test-results/.last-run.json" ]]; then
fi fi
retry=1 retry=1
max_retrys=1 max_retrys=5
# retry failed tests, doing our own retries because using inbuilt playwright retries causes connection issues # retry failed tests, doing our own retries because using inbuilt playwright retries causes connection issues
while [[ $retry -le $max_retrys ]]; do while [[ $retry -le $max_retrys ]]; do

View File

@ -22,9 +22,6 @@ jobs:
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
with: with:
workspaces: './src/wasm-lib' workspaces: './src/wasm-lib'
- uses: taiki-e/install-action@2dbeb927f58939d3aa13bf06ba0c0a34b76b9bfb
with:
tool: wasm-pack
- name: build wasm - name: build wasm
run: yarn build:wasm run: yarn build:wasm

View File

@ -7,11 +7,14 @@ on:
- main - main
tags: tags:
- 'v[0-9]+.[0-9]+.[0-9]+' - 'v[0-9]+.[0-9]+.[0-9]+'
- 'nightly-v[0-9]+.[0-9]+.[0-9]+' schedule:
- cron: '0 4 * * *'
# Daily at 04:00 AM UTC
# Will checkout the last commit from the default branch (main as of 2023-10-04)
env: env:
IS_RELEASE: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} IS_RELEASE: ${{ github.ref_type == 'tag' }}
IS_NIGHTLY: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'nightly-v') }} IS_NIGHTLY: ${{ github.event_name == 'schedule' }}
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@ -41,19 +44,12 @@ jobs:
workspaces: './src/wasm-lib' workspaces: './src/wasm-lib'
# TODO: see if we can fetch from main instead if no diff at src/wasm-lib # TODO: see if we can fetch from main instead if no diff at src/wasm-lib
- uses: taiki-e/install-action@2dbeb927f58939d3aa13bf06ba0c0a34b76b9bfb
with:
tool: wasm-pack
- name: Run build:wasm - name: Run build:wasm
run: "yarn build:wasm" run: "yarn build:wasm"
- name: Set nightly version, product name, release notes, and icons - name: Set nightly version, product name, release notes, and icons
if: ${{ env.IS_NIGHTLY == 'true' }} if: ${{ env.IS_NIGHTLY == 'true' }}
run: | run: yarn files:flip-to-nightly
export VERSION=${GITHUB_REF_NAME#nightly-v}
yarn files:set-version
yarn files:flip-to-nightly
- name: Set release version - name: Set release version
if: ${{ env.IS_RELEASE == 'true' }} if: ${{ env.IS_RELEASE == 'true' }}
@ -132,7 +128,7 @@ jobs:
- name: yarn install - name: yarn install
# Windows is picky sometimes and fails on fetch. Step takes about ~30s # Windows is picky sometimes and fails on fetch. Step takes about ~30s
uses: nick-fields/retry@v3.0.1 uses: nick-fields/retry@v3.0.0
with: with:
timeout_minutes: 2 timeout_minutes: 2
max_attempts: 3 max_attempts: 3
@ -183,7 +179,7 @@ jobs:
WINDOWS_CERTIFICATE_THUMBPRINT: ${{ secrets.WINDOWS_CERTIFICATE_THUMBPRINT }} WINDOWS_CERTIFICATE_THUMBPRINT: ${{ secrets.WINDOWS_CERTIFICATE_THUMBPRINT }}
DEBUG: "electron-notarize*" DEBUG: "electron-notarize*"
# TODO: Fix electron-notarize flakes. The logs above should help gather more data on failures # TODO: Fix electron-notarize flakes. The logs above should help gather more data on failures
uses: nick-fields/retry@v3.0.1 uses: nick-fields/retry@v3.0.0
with: with:
timeout_minutes: 10 timeout_minutes: 10
max_attempts: 3 max_attempts: 3
@ -244,7 +240,7 @@ jobs:
WINDOWS_CERTIFICATE_THUMBPRINT: ${{ secrets.WINDOWS_CERTIFICATE_THUMBPRINT }} WINDOWS_CERTIFICATE_THUMBPRINT: ${{ secrets.WINDOWS_CERTIFICATE_THUMBPRINT }}
DEBUG: "electron-notarize*" DEBUG: "electron-notarize*"
# TODO: Fix electron-notarize flakes. The logs above should help gather more data on failures # TODO: Fix electron-notarize flakes. The logs above should help gather more data on failures
uses: nick-fields/retry@v3.0.1 uses: nick-fields/retry@v3.0.0
with: with:
timeout_minutes: 10 timeout_minutes: 10
max_attempts: 3 max_attempts: 3
@ -273,7 +269,7 @@ jobs:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
permissions: permissions:
contents: write contents: write
if: ${{ github.ref_type == 'tag' }} if: ${{ github.ref_type == 'tag' || github.event_name == 'schedule' }}
env: env:
VERSION_NO_V: ${{ needs.prepare-files.outputs.version }} VERSION_NO_V: ${{ needs.prepare-files.outputs.version }}
VERSION: ${{ format('v{0}', needs.prepare-files.outputs.version) }} VERSION: ${{ format('v{0}', needs.prepare-files.outputs.version) }}
@ -330,8 +326,8 @@ jobs:
env: env:
NOTES: ${{ needs.prepare-files.outputs.notes }} NOTES: ${{ needs.prepare-files.outputs.notes }}
PUB_DATE: ${{ github.event.repository.updated_at }} PUB_DATE: ${{ github.event.repository.updated_at }}
WEBSITE_DIR: ${{ env.IS_NIGHTLY == 'true' && 'dl.zoo.dev/releases/modeling-app/nightly' || 'dl.zoo.dev/releases/modeling-app' }} WEBSITE_DIR: ${{ github.event_name == 'schedule' && 'dl.zoo.dev/releases/modeling-app/nightly' || 'dl.zoo.dev/releases/modeling-app' }}
URL_CODED_NAME: ${{ env.IS_NIGHTLY == 'true' && 'Zoo%20Modeling%20App%20%28Nightly%29' || 'Zoo%20Modeling%20App' }} URL_CODED_NAME: ${{ github.event_name == 'schedule' && 'Zoo%20Modeling%20App%20%28Nightly%29' || 'Zoo%20Modeling%20App' }}
run: | run: |
RELEASE_DIR=https://${WEBSITE_DIR} RELEASE_DIR=https://${WEBSITE_DIR}
jq --null-input \ jq --null-input \
@ -386,7 +382,7 @@ jobs:
# see https://github.com/actions/checkout/issues/1471 # see https://github.com/actions/checkout/issues/1471
git fetch --prune --unshallow --tags git fetch --prune --unshallow --tags
export TAG="nightly-${VERSION}" export TAG="nightly-${VERSION}"
export PREVIOUS_TAG=$(git tag --list --sort=-committerdate "nightly-v[0-9]*" | head -n2 | tail -n1) export PREVIOUS_TAG=$(git describe --tags --match="nightly-v[0-9]*" --abbrev=0)
export NOTES=$(./scripts/get-nightly-changelog.sh) export NOTES=$(./scripts/get-nightly-changelog.sh)
yarn files:set-notes yarn files:set-notes
@ -414,3 +410,14 @@ jobs:
- name: Invalidate bucket cache on latest*.yml and last_download.json files - name: Invalidate bucket cache on latest*.yml and last_download.json files
if: ${{ env.IS_NIGHTLY == 'true' }} if: ${{ env.IS_NIGHTLY == 'true' }}
run: yarn files:invalidate-bucket:nightly run: yarn files:invalidate-bucket:nightly
- name: Tag nightly commit
if: ${{ env.IS_NIGHTLY == 'true' }}
uses: actions/github-script@v7
with:
script: |
const { VERSION } = process.env
const { owner, repo } = context.repo
const { sha } = context
const ref = `refs/tags/nightly-${VERSION}`
github.rest.git.createRef({ owner, repo, sha, ref })

View File

@ -46,7 +46,7 @@ jobs:
shell: bash shell: bash
run: |- run: |-
cd "${{ matrix.dir }}" cd "${{ matrix.dir }}"
cargo llvm-cov nextest --workspace --lcov --output-path lcov.info --test-threads=1 --retries=2 --no-fail-fast -P ci 2>&1 | tee /tmp/github-actions.log cargo llvm-cov nextest --workspace --lcov --output-path lcov.info --test-threads=1 --no-fail-fast -P ci 2>&1 | tee /tmp/github-actions.log
env: env:
KITTYCAD_API_TOKEN: ${{secrets.KITTYCAD_API_TOKEN}} KITTYCAD_API_TOKEN: ${{secrets.KITTYCAD_API_TOKEN}}
RUST_MIN_STACK: 10485760000 RUST_MIN_STACK: 10485760000

View File

@ -26,21 +26,11 @@ jobs:
const issue_number = context.payload.pull_request.number; const issue_number = context.payload.pull_request.number;
const owner = context.repo.owner; const owner = context.repo.owner;
const repo = context.repo.repo; const repo = context.repo.repo;
const { data: comments } = await github.rest.issues.listComments({ // Post a comment on the PR
await github.rest.issues.createComment({
owner, owner,
repo, repo,
issue_number issue_number,
}); body: message,
});
const commentExists = comments.some(comment => comment.body === message);
if (!commentExists) {
// Post a comment on the PR
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: message,
});
}

View File

@ -1,10 +1,9 @@
name: E2E Tests name: E2E Flow Tests
on: on:
push: push:
branches: [ main ] branches: [ main ]
pull_request: pull_request:
schedule: branches: [ main ]
- cron: 0 * * * * # hourly
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@ -17,7 +16,24 @@ permissions:
jobs: jobs:
electron:
check-rust-changes:
runs-on: ubuntu-latest
outputs:
rust-changed: ${{ steps.filter.outputs.rust }}
steps:
- uses: actions/checkout@v4
- id: filter
name: Check for Rust changes
uses: dorny/paths-filter@v3
with:
filters: |
rust:
- 'src/wasm-lib/**'
flow-tests:
timeout-minutes: 60 timeout-minutes: 60
name: playwright:electron:${{ matrix.os }} ${{ matrix.shardIndex }} ${{ matrix.shardTotal }} name: playwright:electron:${{ matrix.os }} ${{ matrix.shardIndex }} ${{ matrix.shardTotal }}
strategy: strategy:
@ -27,45 +43,36 @@ jobs:
os: [namespace-profile-ubuntu-8-cores, namespace-profile-macos-8-cores, windows-16-cores] os: [namespace-profile-ubuntu-8-cores, namespace-profile-macos-8-cores, windows-16-cores]
shardIndex: [1, 2, 3, 4] shardIndex: [1, 2, 3, 4]
shardTotal: [4] shardTotal: [4]
# TODO: add ref here for main and latest release tag
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
needs: check-rust-changes
steps: steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.MODELING_APP_GH_APP_ID }}
private-key: ${{ secrets.MODELING_APP_GH_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- id: filter
name: Check for Rust changes
uses: dorny/paths-filter@v3
with:
filters: |
rust:
- 'src/wasm-lib/**'
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
cache: 'yarn' cache: 'yarn'
- uses: KittyCAD/action-install-cli@main - uses: KittyCAD/action-install-cli@main
- name: Install dependencies - name: Install dependencies
shell: bash shell: bash
run: yarn run: yarn
- name: Cache Playwright Browsers - name: Cache Playwright Browsers
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: | path: |
~/.cache/ms-playwright/ ~/.cache/ms-playwright/
key: ${{ runner.os }}-playwright-${{ hashFiles('yarn.lock') }} key: ${{ runner.os }}-playwright-${{ hashFiles('yarn.lock') }}
- name: Install Playwright Browsers - name: Install Playwright Browsers
shell: bash shell: bash
run: yarn playwright install --with-deps run: yarn playwright install --with-deps
- name: Download Wasm Cache - name: Download Wasm Cache
id: download-wasm id: download-wasm
if: github.event_name != 'schedule' && steps.filter.outputs.rust == 'false' if: needs.check-rust-changes.outputs.rust-changed == 'false'
uses: dawidd6/action-download-artifact@v7 uses: dawidd6/action-download-artifact@v7
continue-on-error: true continue-on-error: true
with: with:
@ -74,32 +81,35 @@ jobs:
workflow: build-and-store-wasm.yml workflow: build-and-store-wasm.yml
branch: main branch: main
path: src/wasm-lib/pkg path: src/wasm-lib/pkg
- name: copy wasm blob - name: copy wasm blob
if: github.event_name != 'schedule' && steps.filter.outputs.rust == 'false' if: needs.check-rust-changes.outputs.rust-changed == 'false'
shell: bash shell: bash
run: cp src/wasm-lib/pkg/wasm_lib_bg.wasm public run: cp src/wasm-lib/pkg/wasm_lib_bg.wasm public
continue-on-error: true continue-on-error: true
- name: Setup Rust - name: Setup Rust
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@2dbeb927f58939d3aa13bf06ba0c0a34b76b9bfb
with:
tool: wasm-pack
- name: Cache Wasm (because rust diff) - name: Cache Wasm (because rust diff)
if: github.event_name == 'schedule' || steps.filter.outputs.rust == 'true' if: needs.check-rust-changes.outputs.rust-changed == 'true'
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
with: with:
workspaces: './src/wasm-lib' workspaces: './src/wasm-lib'
- name: OR Cache Wasm (because wasm cache failed) - name: OR Cache Wasm (because wasm cache failed)
if: steps.download-wasm.outcome == 'failure' if: steps.download-wasm.outcome == 'failure'
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
with: with:
workspaces: './src/wasm-lib' workspaces: './src/wasm-lib'
- name: install good sed - name: install good sed
if: ${{ startsWith(matrix.os, 'macos') }} if: ${{ startsWith(matrix.os, 'macos') }}
shell: bash shell: bash
run: | run: |
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
shell: bash shell: bash
# TODO: figure out what to do with this, it's failing # TODO: figure out what to do with this, it's failing
@ -117,89 +127,39 @@ jobs:
sed -i "s#GH_ACTIONS_AXIOM_TOKEN#${{secrets.GH_ACTIONS_AXIOM_TOKEN}}#g" /tmp/vector.toml sed -i "s#GH_ACTIONS_AXIOM_TOKEN#${{secrets.GH_ACTIONS_AXIOM_TOKEN}}#g" /tmp/vector.toml
cat /tmp/vector.toml cat /tmp/vector.toml
${HOME}/.vector/bin/vector --config /tmp/vector.toml & ${HOME}/.vector/bin/vector --config /tmp/vector.toml &
- name: Build Wasm (because rust diff) - name: Build Wasm (because rust diff)
if: github.event_name == 'schedule' || steps.filter.outputs.rust == 'true' if: needs.check-rust-changes.outputs.rust-changed == 'true'
shell: bash shell: bash
run: yarn build:wasm run: yarn build:wasm
- name: OR Build Wasm (because wasm cache failed) - name: OR Build Wasm (because wasm cache failed)
if: steps.download-wasm.outcome == 'failure' if: steps.download-wasm.outcome == 'failure'
shell: bash shell: bash
run: yarn build:wasm run: yarn build:wasm
- name: build web - name: build web
shell: bash shell: bash
run: yarn tronb:vite:dev run: yarn tronb:vite:dev
- name: Run ubuntu/chrome snapshots
if: ${{ matrix.os == 'namespace-profile-ubuntu-8-cores' && matrix.shardIndex == 1 }}
shell: bash
# TODO: break this in its own job, for now it's not slowing down the overall execution as ubuntu is the quickest,
# but we could do better. This forces a large 1/1 shard of all 20 snapshot tests that runs in about 3 minutes.
run: |
PLATFORM=web yarn playwright test --config=playwright.config.ts --retries="3" --update-snapshots --grep=@snapshot --trace=on --shard=1/1
env:
CI: true
NODE_ENV: development
VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
VITE_KC_SKIP_AUTH: true
token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
snapshottoken: ${{ secrets.KITTYCAD_API_TOKEN }}
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() && (success() || failure()) }}
with:
name: playwright-report-snapshots-${{ matrix.os }}-snapshot-${{ matrix.shardIndex }}-${{ github.sha }}
path: playwright-report/
include-hidden-files: true
retention-days: 30
overwrite: true
- name: Clean up test-results - name: Clean up test-results
if: ${{ !cancelled() && (success() || failure()) }} if: ${{ !cancelled() && (success() || failure()) }}
continue-on-error: true continue-on-error: true
run: rm -r test-results run: rm -r test-results
- name: check for changes
if: ${{ matrix.os == 'namespace-profile-ubuntu-8-cores' && matrix.shardIndex == 1 && github.ref != 'refs/heads/main' }}
shell: bash
id: git-check
run: |
git add e2e/playwright/snapshot-tests.spec.ts-snapshots e2e/playwright/snapshots
if git status | grep -q "Changes to be committed"
then echo "modified=true" >> $GITHUB_OUTPUT
else echo "modified=false" >> $GITHUB_OUTPUT
fi
- name: Commit changes, if any
if: steps.git-check.outputs.modified == 'true'
shell: bash
run: |
git add e2e/playwright/snapshot-tests.spec.ts-snapshots e2e/playwright/snapshots
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git fetch origin
echo ${{ github.head_ref }}
git checkout ${{ github.head_ref }}
git commit -m "A snapshot a day keeps the bugs away! 📷🐛 (OS: ${{matrix.os}})" || true
git push
git push origin ${{ github.head_ref }}
# only upload artifacts if there's actually changes
- uses: actions/upload-artifact@v4
if: steps.git-check.outputs.modified == 'true'
with:
name: playwright-report-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }}
path: playwright-report/
include-hidden-files: true
retention-days: 30
- uses: actions/download-artifact@v4 - uses: actions/download-artifact@v4
if: ${{ !cancelled() && (success() || failure()) }} if: ${{ !cancelled() && (success() || failure()) }}
continue-on-error: true continue-on-error: true
with: with:
name: test-results-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }} name: test-results-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }}
path: test-results/ path: test-results/
- name: Run playwright/electron flow (with retries) - name: Run playwright/electron flow (with retries)
id: retry id: retry
if: ${{ !cancelled() && (success() || failure()) }} if: ${{ !cancelled() && (success() || failure()) }}
uses: nick-fields/retry@v3.0.1 shell: bash
with: run: |
command: .github/ci-cd-scripts/playwright-electron.sh ${{matrix.shardIndex}} ${{matrix.shardTotal}} ${{matrix.os}} .github/ci-cd-scripts/playwright-electron.sh ${{matrix.shardIndex}} ${{matrix.shardTotal}} ${{matrix.os}}
timeout_minutes: 30
max_attempts: 25
env: env:
CI: true CI: true
FAIL_ON_CONSOLE_ERRORS: true FAIL_ON_CONSOLE_ERRORS: true
@ -207,6 +167,7 @@ jobs:
VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }} VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
VITE_KC_SKIP_AUTH: true VITE_KC_SKIP_AUTH: true
token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }} token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
if: always() if: always()
with: with:
@ -215,6 +176,7 @@ jobs:
include-hidden-files: true include-hidden-files: true
retention-days: 30 retention-days: 30
overwrite: true overwrite: true
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
if: always() if: always()
with: with:
@ -223,4 +185,3 @@ jobs:
include-hidden-files: true include-hidden-files: true
retention-days: 30 retention-days: 30
overwrite: true overwrite: true

145
.github/workflows/e2e-snapshot-tests.yml vendored Normal file
View File

@ -0,0 +1,145 @@
name: E2E Snapshot Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
actions: read
jobs:
check-rust-changes:
runs-on: ubuntu-latest
outputs:
rust-changed: ${{ steps.filter.outputs.rust }}
steps:
- uses: actions/checkout@v4
- id: filter
name: Check for Rust changes
uses: dorny/paths-filter@v3
with:
filters: |
rust:
- 'src/wasm-lib/**'
snapshot-tests:
runs-on: ubuntu-22.04
needs: check-rust-changes
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install dependencies
run: yarn
- name: Cache Playwright Browsers
uses: actions/cache@v4
with:
path: |
~/.cache/ms-playwright/
key: ${{ runner.os }}-playwright-${{ hashFiles('yarn.lock') }}
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Download Wasm Cache
id: download-wasm
if: needs.check-rust-changes.outputs.rust-changed == 'false'
uses: dawidd6/action-download-artifact@v7
continue-on-error: true
with:
github_token: ${{secrets.GITHUB_TOKEN}}
name: wasm-bundle
workflow: build-and-store-wasm.yml
branch: main
path: src/wasm-lib/pkg
- name: copy wasm blob
if: needs.check-rust-changes.outputs.rust-changed == 'false'
run: cp src/wasm-lib/pkg/wasm_lib_bg.wasm public
continue-on-error: true
- name: Setup Rust
if: needs.check-rust-changes.outputs.rust-changed == 'true'
uses: dtolnay/rust-toolchain@stable
- name: Cache Wasm (because rust diff)
if: needs.check-rust-changes.outputs.rust-changed == 'true'
uses: Swatinem/rust-cache@v2
with:
workspaces: './src/wasm-lib'
- name: OR Cache Wasm (because wasm cache failed)
if: steps.download-wasm.outcome == 'failure'
uses: Swatinem/rust-cache@v2
with:
workspaces: './src/wasm-lib'
- name: Build Wasm (because rust diff)
if: needs.check-rust-changes.outputs.rust-changed == 'true'
run: yarn build:wasm
- name: OR Build Wasm (because wasm cache failed)
if: steps.download-wasm.outcome == 'failure'
run: yarn build:wasm
- name: build web
run: yarn tronb:vite:dev
- name: Run chrome snapshots
run: |
PLATFORM=web yarn playwright test --config=playwright.config.ts --retries="3" --update-snapshots --grep=@snapshot
env:
CI: true
NODE_ENV: development
VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
VITE_KC_SKIP_AUTH: true
token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
snapshottoken: ${{ secrets.KITTYCAD_API_TOKEN }}
- name: check for changes
id: git-check
run: |
{
echo 'changes<<EOF'
git diff --name-only e2e/playwright/snapshot-tests.spec.ts-snapshots
echo EOF
} >> "$GITHUB_OUTPUT"
# only upload artifacts if there's actually changes
- name: Upload changes, if any
if: steps.git-check.outputs.changes != ''
uses: actions/upload-artifact@v4
with:
name: playwright-snapshots-${{ runner.os }}-${{ github.sha }}
path: ${{ steps.git-check.outputs.changes }}
- name: Upload report, if any
uses: actions/upload-artifact@v4
if: steps.git-check.outputs.changes != ''
with:
name: playwright-report-${{ runner.os }}-${{ github.sha }}
path: playwright-report/
include-hidden-files: true
retention-days: 30
- name: Fail the run if we have snapshot updates
if: steps.git-check.outputs.changes != ''
run: exit 1
# TODO: check if we could comment on the PR as well

View File

@ -37,9 +37,6 @@ jobs:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
cache: 'yarn' cache: 'yarn'
- run: yarn install - run: yarn install
- uses: taiki-e/install-action@2dbeb927f58939d3aa13bf06ba0c0a34b76b9bfb
with:
tool: wasm-pack
- run: yarn build:wasm - run: yarn build:wasm
yarn-tsc: yarn-tsc:
@ -56,9 +53,6 @@ jobs:
with: with:
workspaces: './src/wasm-lib' workspaces: './src/wasm-lib'
- uses: taiki-e/install-action@2dbeb927f58939d3aa13bf06ba0c0a34b76b9bfb
with:
tool: wasm-pack
- run: yarn build:wasm - run: yarn build:wasm
- run: yarn tsc - run: yarn tsc
@ -98,9 +92,6 @@ jobs:
cache: 'yarn' cache: 'yarn'
- run: yarn install - run: yarn install
- uses: taiki-e/install-action@2dbeb927f58939d3aa13bf06ba0c0a34b76b9bfb
with:
tool: wasm-pack
- run: yarn build:wasm - run: yarn build:wasm
- run: yarn simpleserver:bg - run: yarn simpleserver:bg
@ -127,9 +118,6 @@ jobs:
cache: 'yarn' cache: 'yarn'
- run: yarn install - run: yarn install
- uses: taiki-e/install-action@2dbeb927f58939d3aa13bf06ba0c0a34b76b9bfb
with:
tool: wasm-pack
- run: yarn build:wasm - run: yarn build:wasm
- run: yarn simpleserver:bg - run: yarn simpleserver:bg

View File

@ -1,39 +0,0 @@
name: tag-nightly
permissions:
contents: write
on:
schedule:
- cron: '0 4 * * *'
# Daily at 04:00 AM UTC
# Will checkout the last commit from the default branch (main as of 2023-10-04)
jobs:
tag-nightly:
runs-on: ubuntu-22.04
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.MODELING_APP_GH_APP_ID }}
private-key: ${{ secrets.MODELING_APP_GH_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- run: yarn install
- name: Push tag
run: |
VERSION_NO_V=$(date +'%-y.%-m.%-d')
TAG="nightly-v$VERSION_NO_V"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git tag $TAG
git push origin tag $TAG

4
.gitignore vendored
View File

@ -41,12 +41,9 @@ e2e/playwright/playwright-secrets.env
e2e/playwright/temp1.png e2e/playwright/temp1.png
e2e/playwright/temp2.png e2e/playwright/temp2.png
e2e/playwright/temp3.png e2e/playwright/temp3.png
# this will be overridden for specific directories
e2e/playwright/**/*.png
# exports from snapshot-tests.spec.ts "exports of each format should work" # exports from snapshot-tests.spec.ts "exports of each format should work"
e2e/playwright/export-snapshots/* e2e/playwright/export-snapshots/*
!e2e/playwright/export-snapshots/*.png !e2e/playwright/export-snapshots/*.png
!e2e/playwright/snapshot-tests.spec.ts-snapshots/*.png
/kcl-samples /kcl-samples
/test-results/ /test-results/
@ -71,4 +68,3 @@ venv
# electron # electron
out/ out/
*.snap.new

View File

@ -10,7 +10,6 @@ target
src/wasm-lib/pkg src/wasm-lib/pkg
src/wasm-lib/kcl/bindings src/wasm-lib/kcl/bindings
e2e/playwright/export-snapshots e2e/playwright/export-snapshots
e2e/playwright/snapshots/prompt-to-edit
# XState generated files # XState generated files

View File

@ -48,49 +48,22 @@ We recommend downloading the latest application binary from [our Releases page](
## Running a development build ## Running a development build
Install a node version manager such as [fnm](https://github.com/Schniz/fnm?tab=readme-ov-#installation). First, [install Rust via `rustup`](https://www.rust-lang.org/tools/install). This project uses a lot of Rust compiled to [WASM](https://webassembly.org/) within it. We always use the latest stable version of Rust, so you may need to run `rustup update stable`. Then, run:
On Windows, it's also recommended to [upgrade your PowerShell version](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.5#winget), we're using 7.
Then in the repo run the following to install and use the node version specified in `.nvmrc`. You might need to specify your processor architecture with `--arch arm64` or `--arch x64` if it's not autodetected.
```
fnm install --corepack-enabled
fnm use
```
Install the NPM dependencies with:
``` ```
yarn install yarn install
``` ```
This project uses a lot of Rust compiled to [WASM](https://webassembly.org/) within it. We have package scripts to run rustup, see `package.json` for reference: followed by:
```
# macOS/Linux
yarn install:rust
yarn install:wasm-pack:sh
# Windows
yarn install:rust:windows
yarn install:wasm-pack:cargo
``` ```
Then to build the WASM layer, run:
```
# macOS/Linux
yarn build:wasm yarn build:wasm
# Windows
yarn build:wasm:windows
``` ```
Or if you have the `gh` cli installed and want to download the latest main wasm bundle. Note that on Windows, you need to associate .ps1 files with PowerShell, which can be done via the right click menu, selecting `C:\Program Files\PowerShell\7\pwsh.exe`, and you can install tools like `gh` via `yarn install:tools:windows`. or if you have the gh cli installed
``` ```
# macOS/Linux ./get-latest-wasm-bundle.sh # this will download the latest main wasm bundle
yarn fetch:wasm
# Windows
yarn fetch:wasm:windows
``` ```
That will build the WASM binary and put in the `public` dir (though gitignored). That will build the WASM binary and put in the `public` dir (though gitignored).
@ -101,7 +74,7 @@ Finally, to run the web app only, run:
yarn start yarn start
``` ```
If you're not a Zoo employee you won't be able to access the dev environment, you should copy everything from `.env.production` to `.env.development` to make it point to production instead, then when you navigate to `localhost:3000` the easiest way to sign in is to paste `localStorage.setItem('TOKEN_PERSIST_KEY', "your-token-from-https://zoo.dev/account/api-tokens")` replacing the with a real token from https://zoo.dev/account/api-tokens of course, then navigate to localhost:3000 again. Note that navigating to `localhost:3000/signin` removes your token so you will need to set the token again. If you're not an KittyCAD employee you won't be able to access the dev environment, you should copy everything from `.env.production` to `.env.development` to make it point to production instead, then when you navigate to `localhost:3000` the easiest way to sign in is to paste `localStorage.setItem('TOKEN_PERSIST_KEY', "your-token-from-https://zoo.dev/account/api-tokens")` replacing the with a real token from https://zoo.dev/account/api-tokens of course, then navigate to localhost:3000 again. Note that navigating to `localhost:3000/signin` removes your token so you will need to set the token again.
### Development environment variables ### Development environment variables
@ -128,7 +101,7 @@ This will start the application and hot-reload on changes.
Devtools can be opened with the usual Cmd-Opt-I (Mac) or Ctrl-Shift-I (Linux and Windows). Devtools can be opened with the usual Cmd-Opt-I (Mac) or Ctrl-Shift-I (Linux and Windows).
To package the app for your platform with electron-builder, run `yarn tronb:package:dev` (or `yarn tronb:package:prod` to point to the .env.production variables) To build with electron-builder, run `yarn tronb:package:dev` (or `yarn tronb:package:prod` to point to the .env.production variables)
## Checking out commits / Bisecting ## Checking out commits / Bisecting

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -9,10 +9,7 @@ Check a value at runtime, and raise an error if the argument provided
is false. is false.
```js ```js
assert( assert(data: bool, message: string) -> ()
data: bool,
message: string,
) -> ()
``` ```
@ -25,7 +22,7 @@ assert(
### Returns ### Returns
`()` `()`
### Examples ### Examples

View File

@ -9,12 +9,7 @@ Check that a numerical value equals another at runtime,
otherwise raise an error. otherwise raise an error.
```js ```js
assertEqual( assertEqual(left: number, right: number, epsilon: number, message: string) -> ()
left: number,
right: number,
epsilon: number,
message: string,
) -> ()
``` ```
@ -29,7 +24,7 @@ assertEqual(
### Returns ### Returns
`()` `()`
### Examples ### Examples

View File

@ -9,11 +9,7 @@ Check that a numerical value is greater than another at runtime,
otherwise raise an error. otherwise raise an error.
```js ```js
assertGreaterThan( assertGreaterThan(left: number, right: number, message: string) -> ()
left: number,
right: number,
message: string,
) -> ()
``` ```
@ -27,7 +23,7 @@ assertGreaterThan(
### Returns ### Returns
`()` `()`
### Examples ### Examples

View File

@ -9,11 +9,7 @@ Check that a numerical value is greater than or equal to another at runtime,
otherwise raise an error. otherwise raise an error.
```js ```js
assertGreaterThanOrEq( assertGreaterThanOrEq(left: number, right: number, message: string) -> ()
left: number,
right: number,
message: string,
) -> ()
``` ```
@ -27,7 +23,7 @@ assertGreaterThanOrEq(
### Returns ### Returns
`()` `()`
### Examples ### Examples

View File

@ -9,11 +9,7 @@ Check that a numerical value is less than to another at runtime,
otherwise raise an error. otherwise raise an error.
```js ```js
assertLessThan( assertLessThan(left: number, right: number, message: string) -> ()
left: number,
right: number,
message: string,
) -> ()
``` ```
@ -27,7 +23,7 @@ assertLessThan(
### Returns ### Returns
`()` `()`
### Examples ### Examples

View File

@ -9,11 +9,7 @@ Check that a numerical value is less than or equal to another at runtime,
otherwise raise an error. otherwise raise an error.
```js ```js
assertLessThanOrEq( assertLessThanOrEq(left: number, right: number, message: string) -> ()
left: number,
right: number,
message: string,
) -> ()
``` ```
@ -27,7 +23,7 @@ assertLessThanOrEq(
### Returns ### Returns
`()` `()`
### Examples ### Examples

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -26,7 +26,7 @@ cm() -> number
### Returns ### Returns
`number` `number`
### Examples ### Examples

View File

@ -1,15 +0,0 @@
---
title: "std::HALF_TURN"
excerpt: ""
layout: manual
---
```js
std::HALF_TURN: number(deg) = 180deg
```

View File

@ -1,15 +0,0 @@
---
title: "std::QUARTER_TURN"
excerpt: ""
layout: manual
---
```js
std::QUARTER_TURN: number(deg) = 90deg
```

View File

@ -1,15 +0,0 @@
---
title: "std::THREE_QUARTER_TURN"
excerpt: ""
layout: manual
---
```js
std::THREE_QUARTER_TURN: number(deg) = 270deg
```

View File

@ -1,15 +0,0 @@
---
title: "std::XY"
excerpt: ""
layout: manual
---
```js
std::XY
```

View File

@ -1,15 +0,0 @@
---
title: "std::XZ"
excerpt: ""
layout: manual
---
```js
std::XZ
```

View File

@ -1,15 +0,0 @@
---
title: "std::YZ"
excerpt: ""
layout: manual
---
```js
std::YZ
```

View File

@ -1,15 +0,0 @@
---
title: "std::ZERO"
excerpt: ""
layout: manual
---
```js
std::ZERO: number = 0
```

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

48
docs/kcl/cos.md Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -26,7 +26,7 @@ ft() -> number
### Returns ### Returns
`number` `number`
### Examples ### Examples

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -26,7 +26,7 @@ inch() -> number
### Returns ### Returns
`number` `number`
### Examples ### Examples

View File

@ -6,131 +6,113 @@ layout: manual
## Table of Contents ## Table of Contents
### Language * [Types](kcl/types)
* [Modules](kcl/modules)
* [`Types`](kcl/types) * [Known Issues](kcl/KNOWN-ISSUES)
* [`Modules`](kcl/modules) * [`abs`](kcl/abs)
* [`Settings`](kcl/settings) * [`acos`](kcl/acos)
* [`Known Issues`](kcl/known-issues) * [`angleToMatchLengthX`](kcl/angleToMatchLengthX)
* [`angleToMatchLengthY`](kcl/angleToMatchLengthY)
### Standard library * [`angledLine`](kcl/angledLine)
* [`angledLineOfXLength`](kcl/angledLineOfXLength)
* **`std`** * [`angledLineOfYLength`](kcl/angledLineOfYLength)
* [`HALF_TURN`](kcl/const_std-HALF_TURN) * [`angledLineThatIntersects`](kcl/angledLineThatIntersects)
* [`QUARTER_TURN`](kcl/const_std-QUARTER_TURN) * [`angledLineToX`](kcl/angledLineToX)
* [`THREE_QUARTER_TURN`](kcl/const_std-THREE_QUARTER_TURN) * [`angledLineToY`](kcl/angledLineToY)
* [`XY`](kcl/const_std-XY) * [`appearance`](kcl/appearance)
* [`XZ`](kcl/const_std-XZ) * [`arc`](kcl/arc)
* [`YZ`](kcl/const_std-YZ) * [`arcTo`](kcl/arcTo)
* [`ZERO`](kcl/const_std-ZERO) * [`asin`](kcl/asin)
* [`abs`](kcl/abs) * [`assert`](kcl/assert)
* [`acos`](kcl/acos) * [`assertEqual`](kcl/assertEqual)
* [`angleToMatchLengthX`](kcl/angleToMatchLengthX) * [`assertGreaterThan`](kcl/assertGreaterThan)
* [`angleToMatchLengthY`](kcl/angleToMatchLengthY) * [`assertGreaterThanOrEq`](kcl/assertGreaterThanOrEq)
* [`angledLine`](kcl/angledLine) * [`assertLessThan`](kcl/assertLessThan)
* [`angledLineOfXLength`](kcl/angledLineOfXLength) * [`assertLessThanOrEq`](kcl/assertLessThanOrEq)
* [`angledLineOfYLength`](kcl/angledLineOfYLength) * [`atan`](kcl/atan)
* [`angledLineThatIntersects`](kcl/angledLineThatIntersects) * [`atan2`](kcl/atan2)
* [`angledLineToX`](kcl/angledLineToX) * [`bezierCurve`](kcl/bezierCurve)
* [`angledLineToY`](kcl/angledLineToY) * [`ceil`](kcl/ceil)
* [`appearance`](kcl/appearance) * [`chamfer`](kcl/chamfer)
* [`arc`](kcl/arc) * [`circle`](kcl/circle)
* [`arcTo`](kcl/arcTo) * [`circleThreePoint`](kcl/circleThreePoint)
* [`asin`](kcl/asin) * [`close`](kcl/close)
* [`assert`](kcl/assert) * [`cm`](kcl/cm)
* [`assertEqual`](kcl/assertEqual) * [`cos`](kcl/cos)
* [`assertGreaterThan`](kcl/assertGreaterThan) * [`e`](kcl/e)
* [`assertGreaterThanOrEq`](kcl/assertGreaterThanOrEq) * [`extrude`](kcl/extrude)
* [`assertLessThan`](kcl/assertLessThan) * [`fillet`](kcl/fillet)
* [`assertLessThanOrEq`](kcl/assertLessThanOrEq) * [`floor`](kcl/floor)
* [`atan`](kcl/atan) * [`ft`](kcl/ft)
* [`atan2`](kcl/atan2) * [`getNextAdjacentEdge`](kcl/getNextAdjacentEdge)
* [`bezierCurve`](kcl/bezierCurve) * [`getOppositeEdge`](kcl/getOppositeEdge)
* [`ceil`](kcl/ceil) * [`getPreviousAdjacentEdge`](kcl/getPreviousAdjacentEdge)
* [`chamfer`](kcl/chamfer) * [`helix`](kcl/helix)
* [`circle`](kcl/circle) * [`helixRevolutions`](kcl/helixRevolutions)
* [`circleThreePoint`](kcl/circleThreePoint) * [`hole`](kcl/hole)
* [`close`](kcl/close) * [`hollow`](kcl/hollow)
* [`cm`](kcl/cm) * [`inch`](kcl/inch)
* [`extrude`](kcl/extrude) * [`lastSegX`](kcl/lastSegX)
* [`fillet`](kcl/fillet) * [`lastSegY`](kcl/lastSegY)
* [`floor`](kcl/floor) * [`legAngX`](kcl/legAngX)
* [`ft`](kcl/ft) * [`legAngY`](kcl/legAngY)
* [`getNextAdjacentEdge`](kcl/getNextAdjacentEdge) * [`legLen`](kcl/legLen)
* [`getOppositeEdge`](kcl/getOppositeEdge) * [`line`](kcl/line)
* [`getPreviousAdjacentEdge`](kcl/getPreviousAdjacentEdge) * [`ln`](kcl/ln)
* [`helix`](kcl/helix) * [`loft`](kcl/loft)
* [`helixRevolutions`](kcl/helixRevolutions) * [`log`](kcl/log)
* [`hole`](kcl/hole) * [`log10`](kcl/log10)
* [`hollow`](kcl/hollow) * [`log2`](kcl/log2)
* [`inch`](kcl/inch) * [`m`](kcl/m)
* [`lastSegX`](kcl/lastSegX) * [`map`](kcl/map)
* [`lastSegY`](kcl/lastSegY) * [`max`](kcl/max)
* [`legAngX`](kcl/legAngX) * [`min`](kcl/min)
* [`legAngY`](kcl/legAngY) * [`mirror2d`](kcl/mirror2d)
* [`legLen`](kcl/legLen) * [`mm`](kcl/mm)
* [`line`](kcl/line) * [`offsetPlane`](kcl/offsetPlane)
* [`ln`](kcl/ln) * [`patternCircular2d`](kcl/patternCircular2d)
* [`loft`](kcl/loft) * [`patternCircular3d`](kcl/patternCircular3d)
* [`log`](kcl/log) * [`patternLinear2d`](kcl/patternLinear2d)
* [`log10`](kcl/log10) * [`patternLinear3d`](kcl/patternLinear3d)
* [`log2`](kcl/log2) * [`patternTransform`](kcl/patternTransform)
* [`m`](kcl/m) * [`patternTransform2d`](kcl/patternTransform2d)
* [`map`](kcl/map) * [`pi`](kcl/pi)
* [`max`](kcl/max) * [`polar`](kcl/polar)
* [`min`](kcl/min) * [`polygon`](kcl/polygon)
* [`mirror2d`](kcl/mirror2d) * [`pop`](kcl/pop)
* [`mm`](kcl/mm) * [`pow`](kcl/pow)
* [`offsetPlane`](kcl/offsetPlane) * [`profileStart`](kcl/profileStart)
* [`patternCircular2d`](kcl/patternCircular2d) * [`profileStartX`](kcl/profileStartX)
* [`patternCircular3d`](kcl/patternCircular3d) * [`profileStartY`](kcl/profileStartY)
* [`patternLinear2d`](kcl/patternLinear2d) * [`push`](kcl/push)
* [`patternLinear3d`](kcl/patternLinear3d) * [`reduce`](kcl/reduce)
* [`patternTransform`](kcl/patternTransform) * [`rem`](kcl/rem)
* [`patternTransform2d`](kcl/patternTransform2d) * [`revolve`](kcl/revolve)
* [`polar`](kcl/polar) * [`round`](kcl/round)
* [`polygon`](kcl/polygon) * [`segAng`](kcl/segAng)
* [`pop`](kcl/pop) * [`segEnd`](kcl/segEnd)
* [`pow`](kcl/pow) * [`segEndX`](kcl/segEndX)
* [`profileStart`](kcl/profileStart) * [`segEndY`](kcl/segEndY)
* [`profileStartX`](kcl/profileStartX) * [`segLen`](kcl/segLen)
* [`profileStartY`](kcl/profileStartY) * [`segStart`](kcl/segStart)
* [`push`](kcl/push) * [`segStartX`](kcl/segStartX)
* [`reduce`](kcl/reduce) * [`segStartY`](kcl/segStartY)
* [`rem`](kcl/rem) * [`shell`](kcl/shell)
* [`revolve`](kcl/revolve) * [`sin`](kcl/sin)
* [`rotate`](kcl/rotate) * [`sqrt`](kcl/sqrt)
* [`round`](kcl/round) * [`startProfileAt`](kcl/startProfileAt)
* [`scale`](kcl/scale) * [`startSketchOn`](kcl/startSketchOn)
* [`segAng`](kcl/segAng) * [`sweep`](kcl/sweep)
* [`segEnd`](kcl/segEnd) * [`tan`](kcl/tan)
* [`segEndX`](kcl/segEndX) * [`tangentToEnd`](kcl/tangentToEnd)
* [`segEndY`](kcl/segEndY) * [`tangentialArc`](kcl/tangentialArc)
* [`segLen`](kcl/segLen) * [`tangentialArcTo`](kcl/tangentialArcTo)
* [`segStart`](kcl/segStart) * [`tangentialArcToRelative`](kcl/tangentialArcToRelative)
* [`segStartX`](kcl/segStartX) * [`tau`](kcl/tau)
* [`segStartY`](kcl/segStartY) * [`toDegrees`](kcl/toDegrees)
* [`shell`](kcl/shell) * [`toRadians`](kcl/toRadians)
* [`sqrt`](kcl/sqrt) * [`xLine`](kcl/xLine)
* [`startProfileAt`](kcl/startProfileAt) * [`xLineTo`](kcl/xLineTo)
* [`startSketchOn`](kcl/startSketchOn) * [`yLine`](kcl/yLine)
* [`sweep`](kcl/sweep) * [`yLineTo`](kcl/yLineTo)
* [`tangentToEnd`](kcl/tangentToEnd) * [`yd`](kcl/yd)
* [`tangentialArc`](kcl/tangentialArc)
* [`tangentialArcTo`](kcl/tangentialArcTo)
* [`tangentialArcToRelative`](kcl/tangentialArcToRelative)
* [`toDegrees`](kcl/toDegrees)
* [`toRadians`](kcl/toRadians)
* [`translate`](kcl/translate)
* [`xLine`](kcl/xLine)
* [`xLineTo`](kcl/xLineTo)
* [`yLine`](kcl/yLine)
* [`yLineTo`](kcl/yLineTo)
* [`yd`](kcl/yd)
* **`std::math`**
* [`E`](kcl/const_std-math-E)
* [`PI`](kcl/const_std-math-PI)
* [`TAU`](kcl/const_std-math-TAU)
* [`cos`](kcl/std-math-cos)
* [`sin`](kcl/std-math-sin)
* [`tan`](kcl/std-math-tan)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -9,10 +9,7 @@ Compute the angle of the given leg for x.
```js ```js
legAngX( legAngX(hypotenuse: number, leg: number) -> number
hypotenuse: number,
leg: number,
) -> number
``` ```
### Tags ### Tags
@ -29,7 +26,7 @@ legAngX(
### Returns ### Returns
`number` `number`
### Examples ### Examples

View File

@ -9,10 +9,7 @@ Compute the angle of the given leg for y.
```js ```js
legAngY( legAngY(hypotenuse: number, leg: number) -> number
hypotenuse: number,
leg: number,
) -> number
``` ```
### Tags ### Tags
@ -29,7 +26,7 @@ legAngY(
### Returns ### Returns
`number` `number`
### Examples ### Examples

View File

@ -9,10 +9,7 @@ Compute the length of the given leg.
```js ```js
legLen( legLen(hypotenuse: number, leg: number) -> number
hypotenuse: number,
leg: number,
) -> number
``` ```
### Tags ### Tags
@ -29,7 +26,7 @@ legLen(
### Returns ### Returns
`number` `number`
### Examples ### Examples

File diff suppressed because one or more lines are too long

44
docs/kcl/lineTo.md Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -26,7 +26,7 @@ m() -> number
### Returns ### Returns
`number` `number`
### Examples ### Examples

View File

@ -9,10 +9,7 @@ Apply a function to every element of a list.
Given a list like `[a, b, c]`, and a function like `f`, returns `[f(a), f(b), f(c)]` Given a list like `[a, b, c]`, and a function like `f`, returns `[f(a), f(b), f(c)]`
```js ```js
map( map(array: [KclValue], map_fn: FunctionParam) -> [KclValue]
array: [KclValue],
mapFn: FunctionSource,
) -> [KclValue]
``` ```
@ -21,11 +18,11 @@ map(
| Name | Type | Description | Required | | Name | Type | Description | Required |
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `array` | [`[KclValue]`](/docs/kcl/types/KclValue) | | Yes | | `array` | [`[KclValue]`](/docs/kcl/types/KclValue) | | Yes |
| `mapFn` | `FunctionSource` | | Yes | | `map_fn` | `FunctionParam` | | Yes |
### Returns ### Returns
[`[KclValue]`](/docs/kcl/types/KclValue) [`[KclValue]`](/docs/kcl/types/KclValue)
### Examples ### Examples

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -26,7 +26,7 @@ mm() -> number
### Returns ### Returns
`number` `number`
### Examples ### Examples

View File

@ -20,7 +20,7 @@ export fn increment(x) {
Other files in the project can now import functions that have been exported. Other files in the project can now import functions that have been exported.
This makes them available to use in another file. This makes them available to use in another file.
```norun ```
// main.kcl // main.kcl
import increment from "util.kcl" import increment from "util.kcl"
@ -48,64 +48,12 @@ export fn decrement(x) {
When importing, you can import multiple functions at once. When importing, you can import multiple functions at once.
```norun ```
import increment, decrement from "util.kcl" import increment, decrement from "util.kcl"
``` ```
Imported symbols can be renamed for convenience or to avoid name collisions. Imported symbols can be renamed for convenience or to avoid name collisions.
```norun ```
import increment as inc, decrement as dec from "util.kcl" import increment as inc, decrement as dec from "util.kcl"
``` ```
## Importing files from other CAD systems
`import` can also be used to import files from other CAD systems. The format of the statement is the
same as for KCL files. You can only import the whole file, not items from it. E.g.,
```norun
import "tests/inputs/cube.obj"
// Use `cube` just like a KCL object.
```
```norun
import "tests/inputs/cube-2.sldprt" as cube
// Use `cube` just like a KCL object.
```
You can make the file format explicit using a format attribute (useful if using a different
extension), e.g.,
```norun
@(format = obj)
import "tests/inputs/cube"
```
For formats lacking unit data (such as STL, OBJ, or PLY files), the default
unit of measurement is millimeters. Alternatively you may specify the unit
by using an attirbute. Likewise, you can also specify a coordinate system. E.g.,
```norun
@(unitLength = ft, coords = opengl)
import "tests/inputs/cube.obj"
```
When importing a GLTF file, the bin file will be imported as well.
Import paths are relative to the current project directory. Imports currently only work when
using the native Modeling App, not in the browser.
### Supported values
File formats: `fbx`, `gltf`/`glb`, `obj`+, `ply`+, `sldprt`, `step`/`stp`, `stl`+. (Those marked with a
'+' support customising the length unit and coordinate system).
Length units: `mm` (the default), `cm`, `m`, `inch`, `ft`, `yd`.
Coordinate systems:
- `zoo` (the default), forward: -Y, up: +Z, handedness: right
- `opengl`, forward: +Z, up: +Y, handedness: right
- `vulkan`, forward: +Z, up: -Y, handedness: left

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More