Compare commits

...

17 Commits

Author SHA1 Message Date
befac6ad87 Move diff-circular-deps to dedicated script (#6123)
* Move diff-circular-deps to dedicated script

* Update package.json

Co-authored-by: Jace Browning <jacebrowning@gmail.com>

* Fix ci

---------

Co-authored-by: Jace Browning <jacebrowning@gmail.com>
2025-04-02 17:23:23 -04:00
60bc38559b fix sketch mode scale issue (#6107)
* fix sketch mode scale issue

* fmt

* Fix snapshot tests in kurt-5621-scale-issue (#6111)

* Change test function to share units with settings (#6114)

* Change test function to share units with settings

* Consolidate to the same module

---------

Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
2025-04-02 16:31:18 -04:00
2a56155587 add circular deps to PRs (#6116)
* add to ci

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-04-02 12:43:11 -07:00
87c3673a71 Fix length unit in import transform test (#6108)
Fix length unit of import_transform file

Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
2025-04-02 19:32:17 +00:00
21889162ff Map out dependencies between Windows scripts (#6112)
* Map dependencies between Windows scripts

* Skip unix-specific command on Windows

* Handle missing directory

* Explicitly run with PowerShell

This makes the scripts with work CMD out-of-the-box.
2025-04-02 19:07:18 +00:00
f1cccc22cd roll pitch yaw optional, can provide only 1 (#6115)
* roll pitch yaw optional, can provide only 1

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-04-02 18:52:28 +00:00
10c1f3a849 Prevent double-click to constrain length on unsupported lines (#5938)
* WIP: Prevent length constraint creation on endAbsolute lines
Fixes #5937

* Typo

Thanks @franknoirot

Co-authored-by: Frank Noirot <frank@zoo.dev>

* length constraint stuff from @lrev-Dev

* Clean up

* Lint

* Add regression test for double click after sketch constraint

---------

Co-authored-by: Frank Noirot <frank@zoo.dev>
Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
2025-04-02 14:52:36 +00:00
d168ef94e9 Sort imports (#6101)
* add package.json

Signed-off-by: Jess Frazelle <github@jessfraz.com>

initial run;

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

more fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

clientsidescne

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

paths

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

fix styles

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

combine

Signed-off-by: Jess Frazelle <github@jessfraz.com>

eslint rule

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

my ocd

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

constants file

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

no more import sceneInfra

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

try fix circular import

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-04-02 06:54:26 +00:00
29f8b05f56 Fix to not track operations when loading modules (#6083) 2025-04-02 00:34:25 -04:00
af482c30bd save as bw compatible (#6088)
* save as bw compatible

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* js side only for bw compatibility changes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* failure for doing wrong thing

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* remove from ts side

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-04-02 03:39:55 +00:00
4e36e398ee Display the next version using native git commands (#6091) 2025-04-02 03:06:38 +00:00
b5f81b9384 Use new Point3d for named views (#6102)
* Use new Point3d for named views

* Wait a bit for the file menu to be created

---------

Co-authored-by: Jace Browning <jacebrowning@gmail.com>
Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
2025-04-02 02:00:46 +00:00
879b471aed Revert "sort imports" (#6100)
Revert "sort imports (#6094)"

This reverts commit 2fc8cb5376.
2025-04-01 15:31:19 -07:00
964d81dc0e transform w optional args (#6095)
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-04-01 14:23:36 -07:00
443f7cd5fd try to make wheels smaller (#6098)
* try to make wheels smaller

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* target

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-04-01 14:22:33 -07:00
2fc8cb5376 sort imports (#6094)
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-04-01 14:20:42 -07:00
ee20a09e7e Update main.kcl (#6087)
* Update main.kcl

Finally making this bracket smarter
correcting fillet issues
single body w/ SSI extruded cuts
it even works as a sendcutsend upload now

* Update kcl-samples simulation test output

* Update main.kcl

descriptive variable names

* Update kcl-samples simulation test output

* Update main.kcl

spelling corrections

* Update kcl-samples simulation test output

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Josh Gomez <114548659+jgomez720@users.noreply.github.com>
2025-04-01 11:28:09 -07:00
469 changed files with 21665 additions and 12497 deletions

103
.eslintrc
View File

@ -1,103 +0,0 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": [
"react-perf",
"css-modules",
"jest",
"jsx-a11y",
"react",
"react-hooks",
"suggest-no-throw",
"testing-library",
"@typescript-eslint"
],
"extends": [
"plugin:css-modules/recommended",
"plugin:jsx-a11y/recommended",
"plugin:react-hooks/recommended"
],
"rules": {
"no-array-constructor": "off", // This is wrong; use the @typescript-eslint one instead.
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-array-delete": "error",
"@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/no-duplicate-type-constituents": "error",
"@typescript-eslint/no-empty-object-type": "error",
"@typescript-eslint/no-extra-non-null-assertion": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-for-in-array": "error",
"no-implied-eval": "off", // This is wrong; use the @typescript-eslint one instead.
"@typescript-eslint/no-implied-eval": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
"@typescript-eslint/no-redundant-type-constituents": "error",
"@typescript-eslint/no-this-alias": "warn",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-unnecessary-type-constraint": "error",
"no-unused-vars": "off", // This is wrong; use the @typescript-eslint one instead.
"@typescript-eslint/no-unused-vars": ["error", {
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_",
"ignoreRestSiblings": true,
"vars": "all",
"args": "none"
}],
"@typescript-eslint/no-unsafe-unary-minus": "error",
"@typescript-eslint/no-wrapper-object-types": "error",
"no-throw-literal": "off", // Use @typescript-eslint/only-throw-error instead.
"@typescript-eslint/only-throw-error": "error",
"@typescript-eslint/prefer-as-const": "warn",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/no-autofocus": "off",
"jsx-a11y/no-noninteractive-element-interactions": "off",
"no-restricted-globals": [
"error",
{
"name": "isNaN",
"message": "Use Number.isNaN() instead."
}
],
"no-restricted-syntax": [
"error",
{
"selector": "CallExpression[callee.object.name='Array'][callee.property.name='isArray']",
"message": "Use isArray() in lib/utils.ts instead of Array.isArray()."
}
],
"semi": [
"error",
"never"
],
"react-hooks/exhaustive-deps": "off",
"suggest-no-throw/suggest-no-throw": "error"
},
"overrides": [
{
"files": ["e2e/**/*.ts"], // Update the pattern based on your file structure
"extends": [
"plugin:testing-library/react"
],
"rules": {
"suggest-no-throw/suggest-no-throw": "off",
"testing-library/prefer-screen-queries": "off",
"jest/valid-expect": "off"
}
},
{
"files": ["src/**/*.test.ts"],
"extends": [
"plugin:testing-library/react"
],
"rules": {
"suggest-no-throw/suggest-no-throw": "off"
}
}
]
}

127
.eslintrc.json Normal file
View File

@ -0,0 +1,127 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": [
"react-perf",
"css-modules",
"jest",
"jsx-a11y",
"react",
"react-hooks",
"suggest-no-throw",
"testing-library",
"@typescript-eslint"
],
"extends": [
"plugin:css-modules/recommended",
"plugin:jsx-a11y/recommended",
"plugin:react-hooks/recommended"
],
"rules": {
"no-array-constructor": "off", // This is wrong; use the @typescript-eslint one instead.
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-array-delete": "error",
"@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/no-duplicate-type-constituents": "error",
"@typescript-eslint/no-empty-object-type": "error",
"@typescript-eslint/no-extra-non-null-assertion": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-for-in-array": "error",
"no-implied-eval": "off", // This is wrong; use the @typescript-eslint one instead.
"@typescript-eslint/no-implied-eval": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
"@typescript-eslint/no-redundant-type-constituents": "error",
"@typescript-eslint/no-this-alias": "warn",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-unnecessary-type-constraint": "error",
"no-unused-vars": "off", // This is wrong; use the @typescript-eslint one instead.
"@typescript-eslint/no-unused-vars": [
"error",
{
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_",
"ignoreRestSiblings": true,
"vars": "all",
"args": "none"
}
],
"@typescript-eslint/no-unsafe-unary-minus": "error",
"@typescript-eslint/no-wrapper-object-types": "error",
"no-throw-literal": "off", // Use @typescript-eslint/only-throw-error instead.
"@typescript-eslint/only-throw-error": "error",
"@typescript-eslint/prefer-as-const": "warn",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/no-autofocus": "off",
"jsx-a11y/no-noninteractive-element-interactions": "off",
"no-restricted-globals": [
"error",
{
"name": "isNaN",
"message": "Use Number.isNaN() instead."
}
],
"no-restricted-syntax": [
"error",
{
"selector": "CallExpression[callee.object.name='Array'][callee.property.name='isArray']",
"message": "Use isArray() in lib/utils.ts instead of Array.isArray()."
},
{
"selector": "CallExpression[callee.object.name='TOML'][callee.property.name='stringify']",
"message": "Do not use TOML.stringify directly. Use the wrappers in test-utils instead like settingsToToml."
},
{
"selector": "CallExpression[callee.object.name='TOML'][callee.property.name='parse']",
"message": "Do not use TOML.parse directly. Use the wrappers in test-utils instead like tomlToSettings."
}
],
"no-restricted-imports": [
"error",
{
"patterns": [
// Restrict all relative imports except for .css files.
{
"group": ["./*", "../*", "!./*.css", "!../*.css"],
"message": "Use absolute imports instead."
}
]
}
],
"semi": ["error", "never"],
"react-hooks/exhaustive-deps": "off",
"suggest-no-throw/suggest-no-throw": "error"
},
"overrides": [
{
"files": ["e2e/**/*.ts"], // Update the pattern based on your file structure
"extends": ["plugin:testing-library/react"],
"rules": {
"suggest-no-throw/suggest-no-throw": "off",
"testing-library/prefer-screen-queries": "off",
"jest/valid-expect": "off"
}
},
{
"files": ["src/**/*.test.ts"],
"extends": ["plugin:testing-library/react"],
"rules": {
"suggest-no-throw/suggest-no-throw": "off"
}
},
{
"files": ["packages/**/*.ts", "rust/**/*.ts"],
"extends": [],
"rules": {
"no-restricted-imports": "off"
}
}
]
}

View File

@ -136,6 +136,36 @@ jobs:
- run: yarn lint - run: yarn lint
yarn-circular-dependencies:
runs-on: ubuntu-latest
needs: yarn-build-wasm
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn install
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Copy prepared wasm
run: |
ls -R prepared-wasm
cp prepared-wasm/kcl_wasm_lib_bg.wasm public
mkdir rust/kcl-wasm-lib/pkg
cp prepared-wasm/kcl_wasm_lib* rust/kcl-wasm-lib/pkg
- name: Copy prepared ts-rs bindings
run: |
ls -R prepared-ts-rs-bindings
mkdir rust/kcl-lib/bindings
cp -r prepared-ts-rs-bindings/* rust/kcl-lib/bindings/
- run: yarn circular-deps:diff
python-codespell: python-codespell:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:

View File

@ -4,18 +4,38 @@ all: install build check
############################################################################### ###############################################################################
# INSTALL # INSTALL
WASM_PACK ?= ~/.cargo/bin/wasm-pack ifeq ($(OS),Windows_NT)
CARGO ?= ~/.cargo/bin/cargo.exe
WASM_PACK ?= ~/.cargo/bin/wasm-pack.exe
else
CARGO ?= ~/.cargo/bin/cargo
WASM_PACK ?= ~/.cargo/bin/wasm-pack
endif
.PHONY: install .PHONY: install
install: node_modules/.yarn-integrity $(WASM_PACK) ## Install dependencies install: node_modules/.yarn-integrity $(CARGO) $(WASM_PACK) ## Install dependencies
node_modules/.yarn-integrity: package.json yarn.lock node_modules/.yarn-integrity: package.json yarn.lock
yarn install yarn install
ifeq ($(OS),Windows_NT)
@ type nul > $@
else
@ touch $@ @ touch $@
endif
$(CARGO):
ifeq ($(OS),Windows_NT)
yarn install:rust:windows
else
yarn install:rust
endif
$(WASM_PACK): $(WASM_PACK):
yarn install:rust ifeq ($(OS),Windows_NT)
yarn install:wasm-pack:cargo
else
yarn install:wasm-pack:sh yarn install:wasm-pack:sh
endif
############################################################################### ###############################################################################
# BUILD # BUILD
@ -31,13 +51,17 @@ VITE_SOURCES := $(wildcard vite.*) $(wildcard vite/**/*.tsx)
build: build-web build-desktop build: build-web build-desktop
.PHONY: build-web .PHONY: build-web
build-web: public/kcl_wasm_lib_bg.wasm build/index.html build-web: install public/kcl_wasm_lib_bg.wasm build/index.html
.PHONY: build-desktop .PHONY: build-desktop
build-desktop: public/kcl_wasm_lib_bg.wasm .vite/build/main.js build-desktop: install public/kcl_wasm_lib_bg.wasm .vite/build/main.js
public/kcl_wasm_lib_bg.wasm: $(CARGO_SOURCES)$(RUST_SOURCES) public/kcl_wasm_lib_bg.wasm: $(CARGO_SOURCES) $(RUST_SOURCES)
ifeq ($(OS),Windows_NT)
yarn build:wasm:dev:windows
else
yarn build:wasm:dev yarn build:wasm:dev
endif
build/index.html: $(REACT_SOURCES) $(TYPESCRIPT_SOURCES) $(VITE_SOURCES) build/index.html: $(REACT_SOURCES) $(TYPESCRIPT_SOURCES) $(VITE_SOURCES)
yarn build:local yarn build:local
@ -63,8 +87,10 @@ lint: install ## Lint the code
############################################################################### ###############################################################################
# RUN # RUN
TARGET ?= web
.PHONY: run .PHONY: run
run: run-web run: run-$(TARGET)
.PHONY: run-web .PHONY: run-web
run-web: install build-web ## Start the web app run-web: install build-web ## Start the web app
@ -90,7 +116,7 @@ test-unit: install ## Run the unit tests
yarn test:unit yarn test:unit
.PHONY: test-e2e .PHONY: test-e2e
test-e2e: test-e2e-desktop test-e2e: test-e2e-$(TARGET)
.PHONY: test-e2e-web .PHONY: test-e2e-web
test-e2e-web: install build-web ## Run the web e2e tests test-e2e-web: install build-web ## Run the web e2e tests
@ -106,15 +132,23 @@ test-e2e-desktop: install build-desktop ## Run the desktop e2e tests
.PHONY: clean .PHONY: clean
clean: ## Delete all artifacts clean: ## Delete all artifacts
ifeq ($(OS),Windows_NT)
git clean --force -d -X
else
rm -rf .vite/ build/ rm -rf .vite/ build/
rm -rf trace.zip playwright-report/ test-results/ rm -rf trace.zip playwright-report/ test-results/
rm -rf public/kcl_wasm_lib_bg.wasm rm -rf public/kcl_wasm_lib_bg.wasm
rm -rf rust/*/bindings/ rust/*/pkg/ rust/target/ rm -rf rust/*/bindings/ rust/*/pkg/ rust/target/
rm -rf node_modules/ rust/*/node_modules/ rm -rf node_modules/ rust/*/node_modules/
endif
.PHONY: help .PHONY: help
help: install help: install
ifeq ($(OS),Windows_NT)
@ powershell -Command "Get-Content $(MAKEFILE_LIST) | Select-String -Pattern '^[^\s]+:.*##\s.*$$' | ForEach-Object { $$line = $$_.Line -split ':.*?##\s+'; Write-Host -NoNewline $$line[0].PadRight(30) -ForegroundColor Cyan; Write-Host $$line[1] }"
else
@ grep -E '^[^[:space:]]+:.*## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' @ grep -E '^[^[:space:]]+:.*## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
endif
.DEFAULT_GOAL := help .DEFAULT_GOAL := help

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -256392,7 +256392,7 @@
}, },
"required": false, "required": false,
"includeInSnippet": true, "includeInSnippet": true,
"description": "The roll angle in degrees. Must be used with `pitch` and `yaw`. Must be between -360 and 360.", "description": "The roll angle in degrees. Must be between -360 and 360. Default is 0 if not given.",
"labelRequired": true "labelRequired": true
}, },
{ {
@ -257990,7 +257990,7 @@
}, },
"required": false, "required": false,
"includeInSnippet": true, "includeInSnippet": true,
"description": "The pitch angle in degrees. Must be used with `roll` and `yaw`. Must be between -360 and 360.", "description": "The pitch angle in degrees. Must be between -360 and 360. Default is 0 if not given.",
"labelRequired": true "labelRequired": true
}, },
{ {
@ -259588,7 +259588,7 @@
}, },
"required": false, "required": false,
"includeInSnippet": true, "includeInSnippet": true,
"description": "The yaw angle in degrees. Must be used with `roll` and `pitch`. Must be between -360 and 360.", "description": "The yaw angle in degrees. Must be between -360 and 360. Default is 0 if not given.",
"labelRequired": true "labelRequired": true
}, },
{ {
@ -266057,6 +266057,7 @@
"deprecated": false, "deprecated": false,
"examples": [ "examples": [
"// Rotate a pipe with roll, pitch, and yaw.\n\n// Create a path for the sweep.\nsweepPath = startSketchOn(XZ)\n |> startProfileAt([0.05, 0.05], %)\n |> line(end = [0, 7])\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line(end = [-3, 0])\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line(end = [0, 7])\n\n// Create a hole for the pipe.\npipeHole = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 1.5)\n\nsweepSketch = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 2)\n |> hole(pipeHole, %)\n |> sweep(path = sweepPath)\n |> rotate(roll = 10, pitch = 10, yaw = 90)", "// Rotate a pipe with roll, pitch, and yaw.\n\n// Create a path for the sweep.\nsweepPath = startSketchOn(XZ)\n |> startProfileAt([0.05, 0.05], %)\n |> line(end = [0, 7])\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line(end = [-3, 0])\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line(end = [0, 7])\n\n// Create a hole for the pipe.\npipeHole = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 1.5)\n\nsweepSketch = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 2)\n |> hole(pipeHole, %)\n |> sweep(path = sweepPath)\n |> rotate(roll = 10, pitch = 10, yaw = 90)",
"// Rotate a pipe with just roll.\n\n// Create a path for the sweep.\nsweepPath = startSketchOn(XZ)\n |> startProfileAt([0.05, 0.05], %)\n |> line(end = [0, 7])\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line(end = [-3, 0])\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line(end = [0, 7])\n\n// Create a hole for the pipe.\npipeHole = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 1.5)\n\nsweepSketch = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 2)\n |> hole(pipeHole, %)\n |> sweep(path = sweepPath)\n |> rotate(roll = 10)",
"// Rotate a pipe about an axis with an angle.\n\n// Create a path for the sweep.\nsweepPath = startSketchOn(XZ)\n |> startProfileAt([0.05, 0.05], %)\n |> line(end = [0, 7])\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line(end = [-3, 0])\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line(end = [0, 7])\n\n// Create a hole for the pipe.\npipeHole = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 1.5)\n\nsweepSketch = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 2)\n |> hole(pipeHole, %)\n |> sweep(path = sweepPath)\n |> rotate(axis = [0, 0, 1.0], angle = 90)", "// Rotate a pipe about an axis with an angle.\n\n// Create a path for the sweep.\nsweepPath = startSketchOn(XZ)\n |> startProfileAt([0.05, 0.05], %)\n |> line(end = [0, 7])\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line(end = [-3, 0])\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line(end = [0, 7])\n\n// Create a hole for the pipe.\npipeHole = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 1.5)\n\nsweepSketch = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 2)\n |> hole(pipeHole, %)\n |> sweep(path = sweepPath)\n |> rotate(axis = [0, 0, 1.0], angle = 90)",
"// Rotate an imported model.\n\n\nimport \"tests/inputs/cube.sldprt\" as cube\n\ncube\n |> rotate(axis = [0, 0, 1.0], angle = 90)", "// Rotate an imported model.\n\n\nimport \"tests/inputs/cube.sldprt\" as cube\n\ncube\n |> rotate(axis = [0, 0, 1.0], angle = 90)",
"// Sweep two sketches along the same path.\n\n\nsketch001 = startSketchOn(XY)\nrectangleSketch = startProfileAt([-200, 23.86], sketch001)\n |> angledLine([0, 73.47], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 50.61\n ], %)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n ], %)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)\n\nsketch002 = startSketchOn(YZ)\nsweepPath = startProfileAt([0, 0], sketch002)\n |> yLine(length = 231.81)\n |> tangentialArc({ radius = 80, offset = -90 }, %)\n |> xLine(length = 384.93)\n\nparts = sweep([rectangleSketch, circleSketch], path = sweepPath)\n\n// Rotate the sweeps.\nrotate(parts, axis = [0, 0, 1.0], angle = 90)", "// Sweep two sketches along the same path.\n\n\nsketch001 = startSketchOn(XY)\nrectangleSketch = startProfileAt([-200, 23.86], sketch001)\n |> angledLine([0, 73.47], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 50.61\n ], %)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n ], %)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)\n\nsketch002 = startSketchOn(YZ)\nsweepPath = startProfileAt([0, 0], sketch002)\n |> yLine(length = 231.81)\n |> tangentialArc({ radius = 80, offset = -90 }, %)\n |> xLine(length = 384.93)\n\nparts = sweep([rectangleSketch, circleSketch], path = sweepPath)\n\n// Rotate the sweeps.\nrotate(parts, axis = [0, 0, 1.0], angle = 90)",
@ -267784,9 +267785,10 @@
"type": "number", "type": "number",
"schema": { "schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double", "title": "Nullable_double",
"type": "number", "type": "number",
"format": "double", "format": "double",
"nullable": true,
"definitions": { "definitions": {
"Solid": { "Solid": {
"type": "object", "type": "object",
@ -269371,9 +269373,9 @@
} }
} }
}, },
"required": true, "required": false,
"includeInSnippet": true, "includeInSnippet": true,
"description": "The scale factor for the x axis.", "description": "The scale factor for the x axis. Default is 1 if not provided.",
"labelRequired": true "labelRequired": true
}, },
{ {
@ -269381,9 +269383,10 @@
"type": "number", "type": "number",
"schema": { "schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double", "title": "Nullable_double",
"type": "number", "type": "number",
"format": "double", "format": "double",
"nullable": true,
"definitions": { "definitions": {
"Solid": { "Solid": {
"type": "object", "type": "object",
@ -270968,9 +270971,9 @@
} }
} }
}, },
"required": true, "required": false,
"includeInSnippet": true, "includeInSnippet": true,
"description": "The scale factor for the y axis.", "description": "The scale factor for the y axis. Default is 1 if not provided.",
"labelRequired": true "labelRequired": true
}, },
{ {
@ -270978,9 +270981,10 @@
"type": "number", "type": "number",
"schema": { "schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double", "title": "Nullable_double",
"type": "number", "type": "number",
"format": "double", "format": "double",
"nullable": true,
"definitions": { "definitions": {
"Solid": { "Solid": {
"type": "object", "type": "object",
@ -272565,9 +272569,9 @@
} }
} }
}, },
"required": true, "required": false,
"includeInSnippet": true, "includeInSnippet": true,
"description": "The scale factor for the z axis.", "description": "The scale factor for the z axis. Default is 1 if not provided.",
"labelRequired": true "labelRequired": true
}, },
{ {
@ -275836,9 +275840,9 @@
"unpublished": false, "unpublished": false,
"deprecated": false, "deprecated": false,
"examples": [ "examples": [
"// Scale a pipe.\n\n// Create a path for the sweep.\nsweepPath = startSketchOn(XZ)\n |> startProfileAt([0.05, 0.05], %)\n |> line(end = [0, 7])\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line(end = [-3, 0])\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line(end = [0, 7])\n\n// Create a hole for the pipe.\npipeHole = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 1.5)\n\nsweepSketch = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 2)\n |> hole(pipeHole, %)\n |> sweep(path = sweepPath)\n |> scale(x = 1.0, y = 1.0, z = 2.5)", "// Scale a pipe.\n\n// Create a path for the sweep.\nsweepPath = startSketchOn(XZ)\n |> startProfileAt([0.05, 0.05], %)\n |> line(end = [0, 7])\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line(end = [-3, 0])\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line(end = [0, 7])\n\n// Create a hole for the pipe.\npipeHole = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 1.5)\n\nsweepSketch = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 2)\n |> hole(pipeHole, %)\n |> sweep(path = sweepPath)\n |> scale(z = 2.5)",
"// Scale an imported model.\n\n\nimport \"tests/inputs/cube.sldprt\" as cube\n\ncube\n |> scale(x = 1.0, y = 1.0, z = 2.5)", "// Scale an imported model.\n\n\nimport \"tests/inputs/cube.sldprt\" as cube\n\ncube\n |> scale(z = 2.5)",
"// Sweep two sketches along the same path.\n\n\nsketch001 = startSketchOn(XY)\nrectangleSketch = startProfileAt([-200, 23.86], sketch001)\n |> angledLine([0, 73.47], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 50.61\n ], %)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n ], %)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)\n\nsketch002 = startSketchOn(YZ)\nsweepPath = startProfileAt([0, 0], sketch002)\n |> yLine(length = 231.81)\n |> tangentialArc({ radius = 80, offset = -90 }, %)\n |> xLine(length = 384.93)\n\nparts = sweep([rectangleSketch, circleSketch], path = sweepPath)\n\n// Scale the sweep.\nscale(\n parts,\n x = 1.0,\n y = 1.0,\n z = 0.5,\n)" "// Sweep two sketches along the same path.\n\n\nsketch001 = startSketchOn(XY)\nrectangleSketch = startProfileAt([-200, 23.86], sketch001)\n |> angledLine([0, 73.47], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 50.61\n ], %)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n ], %)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)\n\nsketch002 = startSketchOn(YZ)\nsweepPath = startProfileAt([0, 0], sketch002)\n |> yLine(length = 231.81)\n |> tangentialArc({ radius = 80, offset = -90 }, %)\n |> xLine(length = 384.93)\n\nparts = sweep([rectangleSketch, circleSketch], path = sweepPath)\n\n// Scale the sweep.\nscale(parts, z = 0.5)"
] ]
}, },
{ {
@ -326051,9 +326055,10 @@
"type": "number", "type": "number",
"schema": { "schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double", "title": "Nullable_double",
"type": "number", "type": "number",
"format": "double", "format": "double",
"nullable": true,
"definitions": { "definitions": {
"Solid": { "Solid": {
"type": "object", "type": "object",
@ -327638,9 +327643,9 @@
} }
} }
}, },
"required": true, "required": false,
"includeInSnippet": true, "includeInSnippet": true,
"description": "The amount to move the solid or sketch along the x axis.", "description": "The amount to move the solid or sketch along the x axis. Defaults to 0 if not provided.",
"labelRequired": true "labelRequired": true
}, },
{ {
@ -327648,9 +327653,10 @@
"type": "number", "type": "number",
"schema": { "schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double", "title": "Nullable_double",
"type": "number", "type": "number",
"format": "double", "format": "double",
"nullable": true,
"definitions": { "definitions": {
"Solid": { "Solid": {
"type": "object", "type": "object",
@ -329235,9 +329241,9 @@
} }
} }
}, },
"required": true, "required": false,
"includeInSnippet": true, "includeInSnippet": true,
"description": "The amount to move the solid or sketch along the y axis.", "description": "The amount to move the solid or sketch along the y axis. Defaults to 0 if not provided.",
"labelRequired": true "labelRequired": true
}, },
{ {
@ -329245,9 +329251,10 @@
"type": "number", "type": "number",
"schema": { "schema": {
"$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema",
"title": "double", "title": "Nullable_double",
"type": "number", "type": "number",
"format": "double", "format": "double",
"nullable": true,
"definitions": { "definitions": {
"Solid": { "Solid": {
"type": "object", "type": "object",
@ -330832,9 +330839,9 @@
} }
} }
}, },
"required": true, "required": false,
"includeInSnippet": true, "includeInSnippet": true,
"description": "The amount to move the solid or sketch along the z axis.", "description": "The amount to move the solid or sketch along the z axis. Defaults to 0 if not provided.",
"labelRequired": true "labelRequired": true
}, },
{ {
@ -334106,8 +334113,8 @@
"// Move a pipe.\n\n// Create a path for the sweep.\nsweepPath = startSketchOn(XZ)\n |> startProfileAt([0.05, 0.05], %)\n |> line(end = [0, 7])\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line(end = [-3, 0])\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line(end = [0, 7])\n\n// Create a hole for the pipe.\npipeHole = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 1.5)\n\nsweepSketch = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 2)\n |> hole(pipeHole, %)\n |> sweep(path = sweepPath)\n |> translate(x = 1.0, y = 1.0, z = 2.5)", "// Move a pipe.\n\n// Create a path for the sweep.\nsweepPath = startSketchOn(XZ)\n |> startProfileAt([0.05, 0.05], %)\n |> line(end = [0, 7])\n |> tangentialArc({ offset = 90, radius = 5 }, %)\n |> line(end = [-3, 0])\n |> tangentialArc({ offset = -90, radius = 5 }, %)\n |> line(end = [0, 7])\n\n// Create a hole for the pipe.\npipeHole = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 1.5)\n\nsweepSketch = startSketchOn(XY)\n |> circle(center = [0, 0], radius = 2)\n |> hole(pipeHole, %)\n |> sweep(path = sweepPath)\n |> translate(x = 1.0, y = 1.0, z = 2.5)",
"// Move an imported model.\n\n\nimport \"tests/inputs/cube.sldprt\" as cube\n\ncube\n |> translate(x = 1.0, y = 1.0, z = 2.5)", "// Move an imported model.\n\n\nimport \"tests/inputs/cube.sldprt\" as cube\n\ncube\n |> translate(x = 1.0, y = 1.0, z = 2.5)",
"// Sweep two sketches along the same path.\n\n\nsketch001 = startSketchOn(XY)\nrectangleSketch = startProfileAt([-200, 23.86], sketch001)\n |> angledLine([0, 73.47], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 50.61\n ], %)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n ], %)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)\n\nsketch002 = startSketchOn(YZ)\nsweepPath = startProfileAt([0, 0], sketch002)\n |> yLine(length = 231.81)\n |> tangentialArc({ radius = 80, offset = -90 }, %)\n |> xLine(length = 384.93)\n\nparts = sweep([rectangleSketch, circleSketch], path = sweepPath)\n\n// Move the sweeps.\ntranslate(\n parts,\n x = 1.0,\n y = 1.0,\n z = 2.5,\n)", "// Sweep two sketches along the same path.\n\n\nsketch001 = startSketchOn(XY)\nrectangleSketch = startProfileAt([-200, 23.86], sketch001)\n |> angledLine([0, 73.47], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 50.61\n ], %)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n ], %)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n\ncircleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)\n\nsketch002 = startSketchOn(YZ)\nsweepPath = startProfileAt([0, 0], sketch002)\n |> yLine(length = 231.81)\n |> tangentialArc({ radius = 80, offset = -90 }, %)\n |> xLine(length = 384.93)\n\nparts = sweep([rectangleSketch, circleSketch], path = sweepPath)\n\n// Move the sweeps.\ntranslate(\n parts,\n x = 1.0,\n y = 1.0,\n z = 2.5,\n)",
"// Move a sketch.\n\n\nfn square(length) {\n l = length / 2\n p0 = [-l, -l]\n p1 = [-l, l]\n p2 = [l, l]\n p3 = [l, -l]\n\n return startSketchOn(XY)\n |> startProfileAt(p0, %)\n |> line(endAbsolute = p1)\n |> line(endAbsolute = p2)\n |> line(endAbsolute = p3)\n |> close()\n}\n\nsquare(10)\n |> translate(x = 5, y = 5, z = 0)\n |> extrude(length = 10)", "// Move a sketch.\n\n\nfn square(length) {\n l = length / 2\n p0 = [-l, -l]\n p1 = [-l, l]\n p2 = [l, l]\n p3 = [l, -l]\n\n return startSketchOn(XY)\n |> startProfileAt(p0, %)\n |> line(endAbsolute = p1)\n |> line(endAbsolute = p2)\n |> line(endAbsolute = p3)\n |> close()\n}\n\nsquare(10)\n |> translate(x = 5, y = 5)\n |> extrude(length = 10)",
"// Translate and rotate a sketch to create a loft.\nsketch001 = startSketchOn(XY)\n\nfn square() {\n return startProfileAt([-10, 10], sketch001)\n |> xLine(length = 20)\n |> yLine(length = -20)\n |> xLine(length = -20)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n}\n\nprofile001 = square()\n\nprofile002 = square()\n |> translate(x = 0, y = 0, z = 20)\n |> rotate(axis = [0, 0, 1.0], angle = 45)\n\nloft([profile001, profile002])" "// Translate and rotate a sketch to create a loft.\nsketch001 = startSketchOn(XY)\n\nfn square() {\n return startProfileAt([-10, 10], sketch001)\n |> xLine(length = 20)\n |> yLine(length = -20)\n |> xLine(length = -20)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\n}\n\nprofile001 = square()\n\nprofile002 = square()\n |> translate(z = 20)\n |> rotate(axis = [0, 0, 1.0], angle = 45)\n\nloft([profile001, profile002])"
] ]
}, },
{ {

View File

@ -13,9 +13,9 @@ Translate is really useful for sketches if you want to move a sketch and then ro
```js ```js
translate( translate(
objects: SolidOrSketchOrImportedGeometry, objects: SolidOrSketchOrImportedGeometry,
x: number, x?: number,
y: number, y?: number,
z: number, z?: number,
global?: bool, global?: bool,
): SolidOrSketchOrImportedGeometry ): SolidOrSketchOrImportedGeometry
``` ```
@ -26,9 +26,9 @@ translate(
| Name | Type | Description | Required | | Name | Type | Description | Required |
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `objects` | [`SolidOrSketchOrImportedGeometry`](/docs/kcl/types/SolidOrSketchOrImportedGeometry) | The solid, sketch, or set of solids or sketches to move. | Yes | | `objects` | [`SolidOrSketchOrImportedGeometry`](/docs/kcl/types/SolidOrSketchOrImportedGeometry) | The solid, sketch, or set of solids or sketches to move. | Yes |
| `x` | [`number`](/docs/kcl/types/number) | The amount to move the solid or sketch along the x axis. | Yes | | `x` | [`number`](/docs/kcl/types/number) | The amount to move the solid or sketch along the x axis. Defaults to 0 if not provided. | No |
| `y` | [`number`](/docs/kcl/types/number) | The amount to move the solid or sketch along the y axis. | Yes | | `y` | [`number`](/docs/kcl/types/number) | The amount to move the solid or sketch along the y axis. Defaults to 0 if not provided. | No |
| `z` | [`number`](/docs/kcl/types/number) | The amount to move the solid or sketch along the z axis. | Yes | | `z` | [`number`](/docs/kcl/types/number) | The amount to move the solid or sketch along the z axis. Defaults to 0 if not provided. | No |
| `global` | [`bool`](/docs/kcl/types/bool) | If true, the transform is applied in global space. The origin of the model will move. By default, the transform is applied in local sketch axis, therefore the origin will not move. | No | | `global` | [`bool`](/docs/kcl/types/bool) | If true, the transform is applied in global space. The origin of the model will move. By default, the transform is applied in local sketch axis, therefore the origin will not move. | No |
### Returns ### Returns
@ -134,7 +134,7 @@ fn square(length) {
} }
square(10) square(10)
|> translate(x = 5, y = 5, z = 0) |> translate(x = 5, y = 5)
|> extrude(length = 10) |> extrude(length = 10)
``` ```
@ -156,7 +156,7 @@ fn square() {
profile001 = square() profile001 = square()
profile002 = square() profile002 = square()
|> translate(x = 0, y = 0, z = 20) |> translate(z = 20)
|> rotate(axis = [0, 0, 1.0], angle = 45) |> rotate(axis = [0, 0, 1.0], angle = 45)
loft([profile001, profile002]) loft([profile001, profile002])

View File

@ -1,4 +1,4 @@
import { test, expect } from './zoo-test' import { expect, test } from '@e2e/playwright/zoo-test'
test.describe('Electron app header tests', () => { test.describe('Electron app header tests', () => {
test( test(

View File

@ -1,13 +1,14 @@
import { Page } from '@playwright/test' import type { Page } from '@playwright/test'
import { test, expect } from './zoo-test'
import type { HomePageFixture } from '@e2e/playwright/fixtures/homePageFixture'
import { import {
getUtils, PERSIST_MODELING_CONTEXT,
TEST_COLORS, TEST_COLORS,
commonPoints, commonPoints,
PERSIST_MODELING_CONTEXT, getUtils,
orRunWhenFullSuiteEnabled, orRunWhenFullSuiteEnabled,
} from './test-utils' } from '@e2e/playwright/test-utils'
import { HomePageFixture } from './fixtures/homePageFixture' import { expect, test } from '@e2e/playwright/zoo-test'
test.setTimeout(120000) test.setTimeout(120000)

View File

@ -1,7 +1,8 @@
import { test, expect } from './zoo-test'
import fs from 'node:fs/promises' import fs from 'node:fs/promises'
import path from 'node:path' import path from 'node:path'
import { expect, test } from '@e2e/playwright/zoo-test'
test.describe('Point and click for boolean workflows', () => { test.describe('Point and click for boolean workflows', () => {
// Boolean operations to test // Boolean operations to test
const booleanOperations = [ const booleanOperations = [

View File

@ -1,10 +1,11 @@
import { Page } from '@playwright/test' import type { Page } from '@playwright/test'
import { test, expect } from './zoo-test' import type { EngineCommand } from '@src/lang/std/artifactGraph'
import { HomePageFixture } from './fixtures/homePageFixture' import { uuidv4 } from '@src/lib/utils'
import { getUtils } from './test-utils'
import { EngineCommand } from 'lang/std/artifactGraph' import type { HomePageFixture } from '@e2e/playwright/fixtures/homePageFixture'
import { uuidv4 } from 'lib/utils' import type { SceneFixture } from '@e2e/playwright/fixtures/sceneFixture'
import { SceneFixture } from './fixtures/sceneFixture' import { getUtils } from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
test.describe( test.describe(
'Can create sketches on all planes and their back sides', 'Can create sketches on all planes and their back sides',

View File

@ -1,13 +1,14 @@
import { test, expect } from './zoo-test' import { bracket } from '@src/lib/exampleKcl'
import {
orRunWhenFullSuiteEnabled,
getUtils,
executorInputPath,
} from './test-utils'
import { join } from 'path'
import { bracket } from 'lib/exampleKcl'
import { TEST_CODE_LONG_WITH_ERROR_OUT_OF_VIEW } from './storageStates'
import fsp from 'fs/promises' import fsp from 'fs/promises'
import { join } from 'path'
import { TEST_CODE_LONG_WITH_ERROR_OUT_OF_VIEW } from '@e2e/playwright/storageStates'
import {
executorInputPath,
getUtils,
orRunWhenFullSuiteEnabled,
} from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
test.describe('Code pane and errors', { tag: ['@skipWin'] }, () => { test.describe('Code pane and errors', { tag: ['@skipWin'] }, () => {
test('Typing KCL errors induces a badge on the code pane button', async ({ test('Typing KCL errors induces a badge on the code pane button', async ({

View File

@ -1,12 +1,13 @@
import { test, expect } from './zoo-test' import { KCL_DEFAULT_LENGTH } from '@src/lib/constants'
import * as fsp from 'fs/promises' import * as fsp from 'fs/promises'
import path, { join } from 'path'
import { import {
executorInputPath, executorInputPath,
getUtils, getUtils,
orRunWhenFullSuiteEnabled, orRunWhenFullSuiteEnabled,
} from './test-utils' } from '@e2e/playwright/test-utils'
import { KCL_DEFAULT_LENGTH } from 'lib/constants' import { expect, test } from '@e2e/playwright/zoo-test'
import path, { join } from 'path'
test.describe('Command bar tests', { tag: ['@skipWin'] }, () => { test.describe('Command bar tests', { tag: ['@skipWin'] }, () => {
test('Extrude from command bar selects extrude line after', async ({ test('Extrude from command bar selects extrude line after', async ({

View File

@ -1,5 +1,5 @@
import { test, expect } from './zoo-test' import { getUtils } from '@e2e/playwright/test-utils'
import { getUtils } from './test-utils' import { expect, test } from '@e2e/playwright/zoo-test'
test.describe('Copilot ghost text', () => { test.describe('Copilot ghost text', () => {
// eslint-disable-next-line jest/valid-title // eslint-disable-next-line jest/valid-title

View File

@ -1,6 +1,5 @@
import { test, expect } from './zoo-test' import { getUtils } from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
import { getUtils } from './test-utils'
function countNewlines(input: string): number { function countNewlines(input: string): number {
let count = 0 let count = 0

View File

@ -1,11 +1,12 @@
import { test, expect } from './zoo-test' import fsp from 'fs/promises'
import path from 'path' import path from 'path'
import { import {
getUtils,
executorInputPath, executorInputPath,
getPlaywrightDownloadDir, getPlaywrightDownloadDir,
} from './test-utils' getUtils,
import fsp from 'fs/promises' } from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
test( test(
'export works on the first try', 'export works on the first try',

View File

@ -1,14 +1,14 @@
import { test, expect } from './zoo-test' import { uuidv4 } from '@src/lib/utils'
import fsp from 'fs/promises' import fsp from 'fs/promises'
import { uuidv4 } from 'lib/utils' import { join } from 'path'
import { import {
TEST_COLORS,
executorInputPath, executorInputPath,
getUtils, getUtils,
orRunWhenFullSuiteEnabled, orRunWhenFullSuiteEnabled,
TEST_COLORS, } from '@e2e/playwright/test-utils'
} from './test-utils' import { expect, test } from '@e2e/playwright/zoo-test'
import { join } from 'path'
test.describe('Editor tests', { tag: ['@skipWin'] }, () => { test.describe('Editor tests', { tag: ['@skipWin'] }, () => {
test('can comment out code with ctrl+/', async ({ page, homePage }) => { test('can comment out code with ctrl+/', async ({ page, homePage }) => {
@ -985,12 +985,13 @@ sketch001 = startSketchOn(XZ)
test( test(
'Can undo a sketch modification with ctrl+z', 'Can undo a sketch modification with ctrl+z',
{ tag: ['@skipWin'] }, { tag: ['@skipWin'] },
async ({ page, homePage }) => { async ({ page, homePage, editor }) => {
const u = await getUtils(page) const u = await getUtils(page)
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
`sketch001 = startSketchOn(XZ) `@settings(defaultLengthUnit=in)
sketch001 = startSketchOn(XZ)
|> startProfileAt([4.61, -10.01], %) |> startProfileAt([4.61, -10.01], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArcTo([24.95, -0.38], %) |> tangentialArcTo([24.95, -0.38], %)
@ -1080,41 +1081,45 @@ sketch001 = startSketchOn(XZ)
await expect(page.locator('.cm-content')).not.toHaveText(prevContent) await expect(page.locator('.cm-content')).not.toHaveText(prevContent)
// expect the code to have changed // expect the code to have changed
await expect(page.locator('.cm-content')) await editor.expectEditor.toContain(
.toHaveText(`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([2.71, -2.71], %) |> startProfileAt([2.71, -2.71], %)
|> line(end = [15.4, -2.78]) |> line(end = [15.4, -2.78])
|> tangentialArcTo([27.6, -3.05], %) |> tangentialArcTo([27.6, -3.05], %)
|> close() |> close()
|> extrude(length = 5) |> extrude(length = 5)`,
`) { shouldNormalise: true }
)
// Hit undo // Hit undo
await page.keyboard.down('Control') await page.keyboard.down('Control')
await page.keyboard.press('KeyZ') await page.keyboard.press('KeyZ')
await page.keyboard.up('Control') await page.keyboard.up('Control')
await expect(page.locator('.cm-content')) await editor.expectEditor.toContain(
.toHaveText(`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([2.71, -2.71], %) |> startProfileAt([2.71, -2.71], %)
|> line(end = [15.4, -2.78]) |> line(end = [15.4, -2.78])
|> tangentialArcTo([24.95, -0.38], %) |> tangentialArcTo([24.95, -0.38], %)
|> close() |> close()
|> extrude(length = 5)`) |> extrude(length = 5)`,
{ shouldNormalise: true }
)
// Hit undo again. // Hit undo again.
await page.keyboard.down('Control') await page.keyboard.down('Control')
await page.keyboard.press('KeyZ') await page.keyboard.press('KeyZ')
await page.keyboard.up('Control') await page.keyboard.up('Control')
await expect(page.locator('.cm-content')) await editor.expectEditor.toContain(
.toHaveText(`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([2.71, -2.71], %) |> startProfileAt([2.71, -2.71], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArcTo([24.95, -0.38], %) |> tangentialArcTo([24.95, -0.38], %)
|> close() |> close()
|> extrude(length = 5) |> extrude(length = 5)`,
`) { shouldNormalise: true }
)
// Hit undo again. // Hit undo again.
await page.keyboard.down('Control') await page.keyboard.down('Control')
@ -1122,13 +1127,15 @@ sketch001 = startSketchOn(XZ)
await page.keyboard.up('Control') await page.keyboard.up('Control')
await page.waitForTimeout(100) await page.waitForTimeout(100)
await expect(page.locator('.cm-content')) await editor.expectEditor.toContain(
.toHaveText(`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([4.61, -10.01], %) |> startProfileAt([4.61, -10.01], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArcTo([24.95, -0.38], %) |> tangentialArcTo([24.95, -0.38], %)
|> close() |> close()
|> extrude(length = 5)`) |> extrude(length = 5)`,
{ shouldNormalise: true }
)
} }
) )

View File

@ -1,7 +1,8 @@
import { test, expect } from './zoo-test'
import * as fsp from 'fs/promises' import * as fsp from 'fs/promises'
import { join } from 'path' import { join } from 'path'
import { expect, test } from '@e2e/playwright/zoo-test'
const FEATURE_TREE_EXAMPLE_CODE = `export fn timesFive(x) { const FEATURE_TREE_EXAMPLE_CODE = `export fn timesFive(x) {
return 5 * x return 5 * x
} }

View File

@ -1,15 +1,16 @@
import { test, expect } from './zoo-test' import { FILE_EXT } from '@src/lib/constants'
import * as fsp from 'fs/promises'
import * as fs from 'fs' import * as fs from 'fs'
import * as fsp from 'fs/promises'
import { join } from 'path'
import { import {
createProject, createProject,
executorInputPath, executorInputPath,
getUtils, getUtils,
orRunWhenFullSuiteEnabled, orRunWhenFullSuiteEnabled,
runningOnWindows, runningOnWindows,
} from './test-utils' } from '@e2e/playwright/test-utils'
import { join } from 'path' import { expect, test } from '@e2e/playwright/zoo-test'
import { FILE_EXT } from 'lib/constants'
test.describe('integrations tests', () => { test.describe('integrations tests', () => {
test( test(

View File

@ -1,5 +1,5 @@
import type { Page, Locator, Route, Request } from '@playwright/test' import type { Locator, Page, Request, Route, TestInfo } from '@playwright/test'
import { expect, TestInfo } from '@playwright/test' import { expect } from '@playwright/test'
import * as fs from 'fs' import * as fs from 'fs'
import * as path from 'path' import * as path from 'path'

View File

@ -1,11 +1,12 @@
import type { Page, Locator } from '@playwright/test' import type { Locator, Page } from '@playwright/test'
import { expect } from '@playwright/test' import { expect } from '@playwright/test'
import { import {
closePane,
checkIfPaneIsOpen, checkIfPaneIsOpen,
closePane,
openPane, openPane,
sansWhitespace, sansWhitespace,
} from '../test-utils' } from '@e2e/playwright/test-utils'
interface EditorState { interface EditorState {
activeLines: Array<string> activeLines: Array<string>

View File

@ -1,28 +1,28 @@
/* eslint-disable react-hooks/rules-of-hooks */ /* eslint-disable react-hooks/rules-of-hooks */
import type { import type {
BrowserContext, BrowserContext,
ElectronApplication, ElectronApplication,
TestInfo,
Page, Page,
TestInfo,
} from '@playwright/test' } from '@playwright/test'
import { _electron as electron } from '@playwright/test' import { _electron as electron } from '@playwright/test'
import * as TOML from '@iarna/toml' import { SETTINGS_FILE_NAME } from '@src/lib/constants'
import { TEST_SETTINGS } from '../storageStates' import type { DeepPartial } from '@src/lib/types'
import { SETTINGS_FILE_NAME } from 'lib/constants'
import { getUtils, setup } from '../test-utils'
import fsp from 'fs/promises' import fsp from 'fs/promises'
import fs from 'node:fs' import fs from 'node:fs'
import path from 'path' import path from 'path'
import { CmdBarFixture } from './cmdBarFixture'
import { EditorFixture } from './editorFixture' import type { Settings } from '@rust/kcl-lib/bindings/Settings'
import { ToolbarFixture } from './toolbarFixture'
import { SceneFixture } from './sceneFixture' import { CmdBarFixture } from '@e2e/playwright/fixtures/cmdBarFixture'
import { HomePageFixture } from './homePageFixture' import { EditorFixture } from '@e2e/playwright/fixtures/editorFixture'
import { DeepPartial } from 'lib/types' import { HomePageFixture } from '@e2e/playwright/fixtures/homePageFixture'
import { Settings } from '@rust/kcl-lib/bindings/Settings' import { SceneFixture } from '@e2e/playwright/fixtures/sceneFixture'
import { ToolbarFixture } from '@e2e/playwright/fixtures/toolbarFixture'
import { TEST_SETTINGS } from '@e2e/playwright/storageStates'
import { getUtils, settingsToToml, setup } from '@e2e/playwright/test-utils'
export class AuthenticatedApp { export class AuthenticatedApp {
public readonly page: Page public readonly page: Page
@ -287,26 +287,30 @@ export class ElectronZoo {
let settingsOverridesToml = '' let settingsOverridesToml = ''
if (appSettings) { if (appSettings) {
settingsOverridesToml = TOML.stringify({ settingsOverridesToml = settingsToToml({
// @ts-expect-error
settings: { settings: {
...TEST_SETTINGS, ...TEST_SETTINGS,
...appSettings, ...appSettings,
app: { app: {
...TEST_SETTINGS.app, ...TEST_SETTINGS.app,
project_directory: this.projectDirName,
...appSettings.app, ...appSettings.app,
}, },
project: {
...TEST_SETTINGS.project,
directory: this.projectDirName,
},
}, },
}) })
} else { } else {
settingsOverridesToml = TOML.stringify({ settingsOverridesToml = settingsToToml({
// @ts-expect-error
settings: { settings: {
...TEST_SETTINGS, ...TEST_SETTINGS,
app: { app: {
...TEST_SETTINGS.app, ...TEST_SETTINGS.app,
project_directory: this.projectDirName, },
project: {
...TEST_SETTINGS.project,
directory: this.projectDirName,
}, },
}, },
}) })

View File

@ -1,4 +1,4 @@
import type { Page, Locator } from '@playwright/test' import type { Locator, Page } from '@playwright/test'
import { expect } from '@playwright/test' import { expect } from '@playwright/test'
interface ProjectCardState { interface ProjectCardState {

View File

@ -1,15 +1,17 @@
import type { Page, Locator } from '@playwright/test' import type { Locator, Page } from '@playwright/test'
import { expect } from '../zoo-test' import { isArray, uuidv4 } from '@src/lib/utils'
import { isArray, uuidv4 } from 'lib/utils'
import { CmdBarFixture } from './cmdBarFixture' import type { CmdBarFixture } from '@e2e/playwright/fixtures/cmdBarFixture'
import { import {
closeDebugPanel, closeDebugPanel,
doAndWaitForImageDiff, doAndWaitForImageDiff,
getPixelRGBs, getPixelRGBs,
getUtils,
openAndClearDebugPanel, openAndClearDebugPanel,
sendCustomCmd, sendCustomCmd,
getUtils, } from '@e2e/playwright/test-utils'
} from '../test-utils' import { expect } from '@e2e/playwright/zoo-test'
type MouseParams = { type MouseParams = {
pixelDiff?: number pixelDiff?: number

View File

@ -1,14 +1,18 @@
import { type Page, type Locator, test } from '@playwright/test' import { type Locator, type Page, test } from '@playwright/test'
import { expect } from '../zoo-test' import type { SidebarType } from '@src/components/ModelingSidebar/ModelingPanes'
import { SIDEBAR_BUTTON_SUFFIX } from '@src/lib/constants'
import type { ToolbarModeName } from '@src/lib/toolbar'
import { import {
checkIfPaneIsOpen, checkIfPaneIsOpen,
closePane, closePane,
doAndWaitForImageDiff, doAndWaitForImageDiff,
openPane, openPane,
} from '../test-utils' } from '@e2e/playwright/test-utils'
import { SidebarType } from 'components/ModelingSidebar/ModelingPanes' import { expect } from '@e2e/playwright/zoo-test'
import { SIDEBAR_BUTTON_SUFFIX } from 'lib/constants' import { type baseUnitLabels } from '@src/lib/settings/settingsTypes'
import { ToolbarModeName } from 'lib/toolbar'
type LengthUnitLabel = (typeof baseUnitLabels)[keyof typeof baseUnitLabels]
export class ToolbarFixture { export class ToolbarFixture {
public page: Page public page: Page
@ -235,6 +239,12 @@ export class ToolbarFixture {
async checkIfFeatureTreePaneIsOpen() { async checkIfFeatureTreePaneIsOpen() {
return this.checkIfPaneIsOpen(this.featureTreeId) return this.checkIfPaneIsOpen(this.featureTreeId)
} }
async selectUnit(unit: LengthUnitLabel) {
await this.page.getByTestId('units-menu').click()
const optionLocator = this.page.getByRole('button', { name: unit })
await expect(optionLocator).toBeVisible()
await optionLocator.click()
}
/** /**
* Get a specific operation button from the Feature Tree pane. * Get a specific operation button from the Feature Tree pane.

View File

@ -1,7 +1,8 @@
import { test, expect } from './zoo-test'
import { executorInputPath } from './test-utils'
import { join } from 'path'
import fsp from 'fs/promises' import fsp from 'fs/promises'
import { join } from 'path'
import { executorInputPath } from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
test( test(
'When machine-api server not found butt is disabled and shows the reason', 'When machine-api server not found butt is disabled and shows the reason',

View File

@ -1,13 +1,15 @@
import { test, expect } from './zoo-test' import { PROJECT_SETTINGS_FILE_NAME } from '@src/lib/constants'
import { PROJECT_SETTINGS_FILE_NAME } from 'lib/constants'
import * as fsp from 'fs/promises' import * as fsp from 'fs/promises'
import { join } from 'path' import { join } from 'path'
import type { NamedView } from '@rust/kcl-lib/bindings/NamedView'
import { import {
createProject, createProject,
tomlToPerProjectSettings,
perProjectsettingsToToml, perProjectsettingsToToml,
} from './test-utils' tomlToPerProjectSettings,
import { NamedView } from '@rust/kcl-lib/bindings/NamedView' } from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
// Helper function to determine if the file path on disk exists // Helper function to determine if the file path on disk exists
// Specifically this is used to check if project.toml exists on disk // Specifically this is used to check if project.toml exists on disk

View File

@ -1,4 +1,4 @@
import { test, expect } from './zoo-test' import { expect, test } from '@e2e/playwright/zoo-test'
/** /**
* Not all menu actions are tested. Some are default electron menu actions. * Not all menu actions are tested. Some are default electron menu actions.
@ -10,6 +10,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
test('File.Create project', async ({ tronApp, cmdBar, page }) => { test('File.Create project', async ({ tronApp, cmdBar, page }) => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) fail() if (!app || !app.applicationMenu) fail()
const newProject = const newProject =
@ -29,6 +30,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
test('File.Open project', async ({ tronApp, cmdBar, page }) => { test('File.Open project', async ({ tronApp, cmdBar, page }) => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) fail() if (!app || !app.applicationMenu) fail()
const openProject = const openProject =
@ -52,6 +54,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
}) => { }) => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) fail() if (!app || !app.applicationMenu) fail()
const userSettings = app.applicationMenu.getMenuItemById( const userSettings = app.applicationMenu.getMenuItemById(
@ -75,6 +78,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
}) => { }) => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) fail() if (!app || !app.applicationMenu) fail()
const keybindings = app.applicationMenu.getMenuItemById( const keybindings = app.applicationMenu.getMenuItemById(
@ -96,6 +100,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
}) => { }) => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
@ -112,6 +117,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
test('File.Preferences.Theme', async ({ tronApp, cmdBar, page }) => { test('File.Preferences.Theme', async ({ tronApp, cmdBar, page }) => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
@ -136,6 +142,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
}) => { }) => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
@ -152,6 +159,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
test('File.Preferences.Sign out', async ({ tronApp, cmdBar, page }) => { test('File.Preferences.Sign out', async ({ tronApp, cmdBar, page }) => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById('File.Sign out') const menu = app.applicationMenu.getMenuItemById('File.Sign out')
@ -170,6 +178,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
test('Edit.Rename project', async ({ tronApp, cmdBar, page }) => { test('Edit.Rename project', async ({ tronApp, cmdBar, page }) => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
@ -188,6 +197,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
test('Edit.Delete project', async ({ tronApp, cmdBar, page }) => { test('Edit.Delete project', async ({ tronApp, cmdBar, page }) => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
@ -210,6 +220,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
}) => { }) => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
@ -228,6 +239,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
test('View.Command Palette...', async ({ tronApp, cmdBar, page }) => { test('View.Command Palette...', async ({ tronApp, cmdBar, page }) => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
@ -245,6 +257,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
test('Help.Show all commands', async ({ tronApp, cmdBar, page }) => { test('Help.Show all commands', async ({ tronApp, cmdBar, page }) => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
@ -260,6 +273,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
test('Help.KCL code samples', async ({ tronApp, cmdBar, page }) => { test('Help.KCL code samples', async ({ tronApp, cmdBar, page }) => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
@ -275,6 +289,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
}) => { }) => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
@ -293,6 +308,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
test('Help.Reset onboarding', async ({ tronApp, cmdBar, page }) => { test('Help.Reset onboarding', async ({ tronApp, cmdBar, page }) => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(

View File

@ -2,8 +2,7 @@
// application, check it can make it to the project pane, and nothing more. // application, check it can make it to the project pane, and nothing more.
// It also tests our test wrappers are working. // It also tests our test wrappers are working.
// Additionally this serves as a nice minimal example. // Additionally this serves as a nice minimal example.
import { expect, test } from '@e2e/playwright/zoo-test'
import { test, expect } from './zoo-test'
test.describe('Open the application', () => { test.describe('Open the application', () => {
test('see the project view', async ({ page, context }) => { test('see the project view', async ({ page, context }) => {

View File

@ -1,22 +1,23 @@
import { test, expect } from './zoo-test' import { bracket } from '@src/lib/exampleKcl'
import { join } from 'path' import { onboardingPaths } from '@src/routes/Onboarding/paths'
import fsp from 'fs/promises' import fsp from 'fs/promises'
import { import { join } from 'path'
getUtils,
executorInputPath, import { expectPixelColor } from '@e2e/playwright/fixtures/sceneFixture'
createProject,
settingsToToml,
orRunWhenFullSuiteEnabled,
} from './test-utils'
import { bracket } from 'lib/exampleKcl'
import { onboardingPaths } from 'routes/Onboarding/paths'
import { import {
TEST_SETTINGS_KEY, TEST_SETTINGS_KEY,
TEST_SETTINGS_ONBOARDING_START,
TEST_SETTINGS_ONBOARDING_EXPORT, TEST_SETTINGS_ONBOARDING_EXPORT,
TEST_SETTINGS_ONBOARDING_START,
TEST_SETTINGS_ONBOARDING_USER_MENU, TEST_SETTINGS_ONBOARDING_USER_MENU,
} from './storageStates' } from '@e2e/playwright/storageStates'
import { expectPixelColor } from './fixtures/sceneFixture' import {
createProject,
executorInputPath,
getUtils,
orRunWhenFullSuiteEnabled,
settingsToToml,
} from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
// Because our default test settings have the onboardingStatus set to 'dismissed', // Because our default test settings have the onboardingStatus set to 'dismissed',
// we must set it to empty for the tests where we want to see the onboarding immediately. // we must set it to empty for the tests where we want to see the onboarding immediately.

View File

@ -1,4 +1,4 @@
import { test, expect } from '@playwright/test' import { expect, test } from '@playwright/test'
/** @deprecated, import from ./fixtureSetup.ts instead */ /** @deprecated, import from ./fixtureSetup.ts instead */
export const _test = test export const _test = test

View File

@ -1,12 +1,12 @@
import { Page } from '@playwright/test' import type { Locator, Page } from '@playwright/test'
import { test, expect } from './zoo-test'
import { EditorFixture } from './fixtures/editorFixture'
import { SceneFixture } from './fixtures/sceneFixture'
import { ToolbarFixture } from './fixtures/toolbarFixture'
import fs from 'node:fs/promises' import fs from 'node:fs/promises'
import path from 'node:path' import path from 'node:path'
import { getUtils, orRunWhenFullSuiteEnabled } from './test-utils'
import { Locator } from '@playwright/test' import type { EditorFixture } from '@e2e/playwright/fixtures/editorFixture'
import type { SceneFixture } from '@e2e/playwright/fixtures/sceneFixture'
import type { ToolbarFixture } from '@e2e/playwright/fixtures/toolbarFixture'
import { getUtils, orRunWhenFullSuiteEnabled } from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
// test file is for testing point an click code gen functionality that's not sketch mode related // test file is for testing point an click code gen functionality that's not sketch mode related

View File

@ -1,19 +1,20 @@
import { test, expect } from './zoo-test' import { DEFAULT_PROJECT_KCL_FILE } from '@src/lib/constants'
import fs from 'fs'
import fsp from 'fs/promises'
import path from 'path'
import type { Paths } from '@e2e/playwright/test-utils'
import { import {
createProject,
doExport, doExport,
executorInputPath, executorInputPath,
getPlaywrightDownloadDir,
getUtils, getUtils,
isOutOfViewInScrollContainer, isOutOfViewInScrollContainer,
Paths,
createProject,
getPlaywrightDownloadDir,
orRunWhenFullSuiteEnabled, orRunWhenFullSuiteEnabled,
runningOnWindows, runningOnWindows,
} from './test-utils' } from '@e2e/playwright/test-utils'
import fsp from 'fs/promises' import { expect, test } from '@e2e/playwright/zoo-test'
import fs from 'fs'
import path from 'path'
import { DEFAULT_PROJECT_KCL_FILE } from 'lib/constants'
test( test(
'projects reload if a new one is created, deleted, or renamed externally', 'projects reload if a new one is created, deleted, or renamed externally',

View File

@ -1,4 +1,5 @@
import { test, expect } from './zoo-test' import { expect, test } from '@e2e/playwright/zoo-test'
/* eslint-disable jest/no-conditional-expect */ /* eslint-disable jest/no-conditional-expect */
/** /**

View File

@ -1,5 +1,5 @@
import { test, expect } from './zoo-test' import { orRunWhenFullSuiteEnabled } from '@e2e/playwright/test-utils'
import { orRunWhenFullSuiteEnabled } from './test-utils' import { expect, test } from '@e2e/playwright/zoo-test'
/* eslint-disable jest/no-conditional-expect */ /* eslint-disable jest/no-conditional-expect */

View File

@ -1,17 +1,18 @@
import { Page } from '@playwright/test' import type { Page } from '@playwright/test'
import { test, expect } from './zoo-test' import { bracket } from '@src/lib/exampleKcl'
import path from 'path' import { reportRejection } from '@src/lib/trap'
import * as fsp from 'fs/promises' import * as fsp from 'fs/promises'
import path from 'path'
import { TEST_CODE_TRIGGER_ENGINE_EXPORT_ERROR } from '@e2e/playwright/storageStates'
import type { TestColor } from '@e2e/playwright/test-utils'
import { import {
getUtils,
TEST_COLORS, TEST_COLORS,
TestColor,
executorInputPath, executorInputPath,
getUtils,
orRunWhenFullSuiteEnabled, orRunWhenFullSuiteEnabled,
} from './test-utils' } from '@e2e/playwright/test-utils'
import { TEST_CODE_TRIGGER_ENGINE_EXPORT_ERROR } from './storageStates' import { expect, test } from '@e2e/playwright/zoo-test'
import { bracket } from 'lib/exampleKcl'
import { reportRejection } from 'lib/trap'
test.describe('Regression tests', { tag: ['@skipWin'] }, () => { test.describe('Regression tests', { tag: ['@skipWin'] }, () => {
// bugs we found that don't fit neatly into other categories // bugs we found that don't fit neatly into other categories
@ -797,6 +798,74 @@ plane002 = offsetPlane(XZ, offset = -2 * x)`
await page.getByTestId('custom-cmd-send-button').click() await page.getByTestId('custom-cmd-send-button').click()
} }
) )
test('scale other than default works with sketch mode', async ({
page,
homePage,
toolbar,
editor,
scene,
}) => {
await test.step('Load the washer code', async () => {
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`@settings(defaultLengthUnit = in)
innerDiameter = 0.203
outerDiameter = 0.438
thicknessMax = 0.038
thicknessMin = 0.024
washerSketch = startSketchOn(XY)
|> circle(center = [0, 0], radius = outerDiameter / 2)
washer = extrude(washerSketch, length = thicknessMax)`
)
})
await page.setBodyDimensions({ width: 1200, height: 500 })
await homePage.goToModelingScene()
})
const [circleCenterClick] = scene.makeMouseHelpers(650, 300)
const [circleRadiusClick] = scene.makeMouseHelpers(800, 320)
const [washerFaceClick] = scene.makeMouseHelpers(657, 286)
await page.waitForTimeout(100)
await test.step('Start sketching on the washer face', async () => {
await toolbar.startSketchPlaneSelection()
await washerFaceClick()
await page.waitForTimeout(600) // engine animation
await toolbar.expectToolbarMode.toBe('sketching')
})
await test.step('Draw a circle and verify code', async () => {
// select circle tool
await expect
.poll(async () => {
await toolbar.circleBtn.click()
return toolbar.circleBtn.getAttribute('aria-pressed')
})
.toBe('true')
await page.waitForTimeout(100)
await circleCenterClick()
// this number will be different if the scale is not set correctly for inches
await editor.expectEditor.toContain(
'circle(sketch001, center = [0.06, -0.06]'
)
await circleRadiusClick()
await editor.expectEditor.toContain(
'circle(sketch001, center = [0.06, -0.06], radius = 0.18'
)
})
await test.step('Exit sketch mode', async () => {
await toolbar.exitSketch()
await toolbar.expectToolbarMode.toBe('modeling')
await toolbar.selectUnit('Yards')
await editor.expectEditor.toContain('@settings(defaultLengthUnit = yd)')
})
})
}) })
async function clickExportButton(page: Page) { async function clickExportButton(page: Page) {

View File

@ -1,20 +1,20 @@
import { Page } from '@playwright/test' import type { Page } from '@playwright/test'
import { test, expect } from './zoo-test' import { roundOff, uuidv4 } from '@src/lib/utils'
import fs from 'node:fs/promises' import fs from 'node:fs/promises'
import path from 'node:path' import path from 'node:path'
import { HomePageFixture } from './fixtures/homePageFixture'
import type { CmdBarFixture } from '@e2e/playwright/fixtures/cmdBarFixture'
import type { HomePageFixture } from '@e2e/playwright/fixtures/homePageFixture'
import type { SceneFixture } from '@e2e/playwright/fixtures/sceneFixture'
import type { ToolbarFixture } from '@e2e/playwright/fixtures/toolbarFixture'
import { import {
getMovementUtils,
getUtils,
PERSIST_MODELING_CONTEXT, PERSIST_MODELING_CONTEXT,
TEST_COLORS, TEST_COLORS,
getMovementUtils,
getUtils,
orRunWhenFullSuiteEnabled, orRunWhenFullSuiteEnabled,
} from './test-utils' } from '@e2e/playwright/test-utils'
import { uuidv4, roundOff } from 'lib/utils' import { expect, test } from '@e2e/playwright/zoo-test'
import { SceneFixture } from './fixtures/sceneFixture'
import { ToolbarFixture } from './fixtures/toolbarFixture'
import { CmdBarFixture } from './fixtures/cmdBarFixture'
test.describe('Sketch tests', { tag: ['@skipWin'] }, () => { test.describe('Sketch tests', { tag: ['@skipWin'] }, () => {
test('multi-sketch file shows multiple Edit Sketch buttons', async ({ test('multi-sketch file shows multiple Edit Sketch buttons', async ({
@ -479,7 +479,8 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
`sketch001 = startSketchOn(XZ) `@settings(defaultLengthUnit=in)
sketch001 = startSketchOn(XZ)
|> circle(center = [4.61, -5.01], radius = 8)` |> circle(center = [4.61, -5.01], radius = 8)`
) )
}) })
@ -564,12 +565,14 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
test('Can edit a sketch that has been extruded in the same pipe', async ({ test('Can edit a sketch that has been extruded in the same pipe', async ({
page, page,
homePage, homePage,
editor,
}) => { }) => {
const u = await getUtils(page) const u = await getUtils(page)
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
`sketch001 = startSketchOn(XZ) `@settings(defaultLengthUnit=in)
sketch001 = startSketchOn(XZ)
|> startProfileAt([4.61, -10.01], %) |> startProfileAt([4.61, -10.01], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArcTo([24.95, -0.38], %) |> tangentialArcTo([24.95, -0.38], %)
@ -654,26 +657,29 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
await expect(page.locator('.cm-content')).not.toHaveText(prevContent) await expect(page.locator('.cm-content')).not.toHaveText(prevContent)
// expect the code to have changed // expect the code to have changed
await expect(page.locator('.cm-content')) await editor.expectEditor.toContain(
.toHaveText(`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([7.12, -12.68], %) |> startProfileAt([7.12, -12.68], %)
|> line(end = [12.68, -1.09]) |> line(end = [12.68, -1.09])
|> tangentialArcTo([24.89, 0.68], %) |> tangentialArcTo([24.89, 0.68], %)
|> close() |> close()
|> extrude(length = 5) |> extrude(length = 5)`,
`) { shouldNormalise: true }
)
}) })
test('Can edit a sketch that has been revolved in the same pipe', async ({ test('Can edit a sketch that has been revolved in the same pipe', async ({
page, page,
homePage, homePage,
scene, scene,
editor,
}) => { }) => {
const u = await getUtils(page) const u = await getUtils(page)
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
`sketch001 = startSketchOn(XZ) `@settings(defaultLengthUnit=in)
sketch001 = startSketchOn(XZ)
|> startProfileAt([4.61, -14.01], %) |> startProfileAt([4.61, -14.01], %)
|> line(end = [12.73, -0.09]) |> line(end = [12.73, -0.09])
|> tangentialArcTo([24.95, -5.38], %) |> tangentialArcTo([24.95, -5.38], %)
@ -758,14 +764,16 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
await expect(page.locator('.cm-content')).not.toHaveText(prevContent) await expect(page.locator('.cm-content')).not.toHaveText(prevContent)
// expect the code to have changed // expect the code to have changed
await expect(page.locator('.cm-content')) await editor.expectEditor.toContain(
.toHaveText(`sketch001 = startSketchOn(XZ) `sketch001 = startSketchOn(XZ)
|> startProfileAt([6.44, -12.07], %) |> startProfileAt([6.44, -12.07], %)
|> line(end = [14.72, 1.97]) |> line(end = [14.72, 1.97])
|> tangentialArcTo([24.95, -5.38], %) |> tangentialArcTo([24.95, -5.38], %)
|> line(end = [1.97, 2.06]) |> line(end = [1.97, 2.06])
|> close() |> close()
|> revolve(axis = "X")`) |> revolve(axis = "X")`,
{ shouldNormalise: true }
)
}) })
test('Can add multiple sketches', async ({ page, homePage }) => { test('Can add multiple sketches', async ({ page, homePage }) => {
const u = await getUtils(page) const u = await getUtils(page)

View File

@ -1,21 +1,22 @@
import { test, expect } from './zoo-test' import type { Models } from '@kittycad/lib'
import { secrets } from './secrets' import { KCL_DEFAULT_LENGTH } from '@src/lib/constants'
import {
Paths,
doExport,
getUtils,
settingsToToml,
orRunWhenFullSuiteEnabled,
} from './test-utils'
import { Models } from '@kittycad/lib'
import fsp from 'fs/promises'
import { spawn } from 'child_process' import { spawn } from 'child_process'
import { KCL_DEFAULT_LENGTH } from 'lib/constants' import fsp from 'fs/promises'
import JSZip from 'jszip' import JSZip from 'jszip'
import path from 'path' import path from 'path'
import { TEST_SETTINGS, TEST_SETTINGS_KEY } from './storageStates'
import { SceneFixture } from './fixtures/sceneFixture' import type { CmdBarFixture } from '@e2e/playwright/fixtures/cmdBarFixture'
import { CmdBarFixture } from './fixtures/cmdBarFixture' import type { SceneFixture } from '@e2e/playwright/fixtures/sceneFixture'
import { secrets } from '@e2e/playwright/secrets'
import { TEST_SETTINGS, TEST_SETTINGS_KEY } from '@e2e/playwright/storageStates'
import type { Paths } from '@e2e/playwright/test-utils'
import {
doExport,
getUtils,
orRunWhenFullSuiteEnabled,
settingsToToml,
} from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
test.beforeEach(async ({ page, context }) => { test.beforeEach(async ({ page, context }) => {
// Make the user avatar image always 404 // Make the user avatar image always 404
@ -345,8 +346,10 @@ const extrudeDefaultPlane = async (
app: { app: {
onboarding_status: 'dismissed', onboarding_status: 'dismissed',
show_debug_panel: true, show_debug_panel: true,
appearance: {
theme: 'dark', theme: 'dark',
}, },
},
project: { project: {
default_project_name: 'project-$nnn', default_project_name: 'project-$nnn',
}, },
@ -452,7 +455,7 @@ test(
await page.waitForTimeout(700) // TODO detect animation ending, or disable animation await page.waitForTimeout(700) // TODO detect animation ending, or disable animation
await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10) await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10)
code += `profile001 = startProfileAt([7.19, -9.7], sketch001)` code += `profile001 = startProfileAt([182.59, -246.32], sketch001)`
await expect(page.locator('.cm-content')).toHaveText(code) await expect(page.locator('.cm-content')).toHaveText(code)
await page.waitForTimeout(100) await page.waitForTimeout(100)
@ -470,7 +473,7 @@ test(
await page.waitForTimeout(500) await page.waitForTimeout(500)
code += ` code += `
|> xLine(length = 7.25)` |> xLine(length = 184.3)`
await expect(page.locator('.cm-content')).toHaveText(code) await expect(page.locator('.cm-content')).toHaveText(code)
await page await page
@ -628,7 +631,7 @@ test(
mask: [page.getByTestId('model-state-indicator')], mask: [page.getByTestId('model-state-indicator')],
}) })
await expect(page.locator('.cm-content')).toHaveText( await expect(page.locator('.cm-content')).toHaveText(
`sketch001 = startSketchOn(XZ)profile001 = circle(sketch001, center = [14.44, -2.44], radius = 1)` `sketch001 = startSketchOn(XZ)profile001 = circle(sketch001, center = [366.89, -62.01], radius = 1)`
) )
} }
) )
@ -665,7 +668,7 @@ test.describe(
const startXPx = 600 const startXPx = 600
await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10) await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10)
code += `profile001 = startProfileAt([7.19, -9.7], sketch001)` code += `profile001 = startProfileAt([182.59, -246.32], sketch001)`
await expect(u.codeLocator).toHaveText(code) await expect(u.codeLocator).toHaveText(code)
await page.waitForTimeout(100) await page.waitForTimeout(100)
@ -673,7 +676,7 @@ test.describe(
await page.waitForTimeout(100) await page.waitForTimeout(100)
code += ` code += `
|> xLine(length = 7.25)` |> xLine(length = 184.3)`
await expect(u.codeLocator).toHaveText(code) await expect(u.codeLocator).toHaveText(code)
await page await page
@ -688,7 +691,7 @@ test.describe(
await page.mouse.click(startXPx + PUR * 30, 500 - PUR * 20) await page.mouse.click(startXPx + PUR * 30, 500 - PUR * 20)
code += ` code += `
|> tangentialArcTo([21.7, -2.44], %)` |> tangentialArcTo([551.2, -62.01], %)`
await expect(u.codeLocator).toHaveText(code) await expect(u.codeLocator).toHaveText(code)
// click tangential arc tool again to unequip it // click tangential arc tool again to unequip it

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -29,5 +29,5 @@
} }
} }
], ],
"kcl_version": "0.2.54" "kcl_version": "0.2.57"
} }

View File

@ -1,17 +1,19 @@
import { Settings } from '@rust/kcl-lib/bindings/Settings' import type { SaveSettingsPayload } from '@src/lib/settings/settingsTypes'
import { SaveSettingsPayload } from 'lib/settings/settingsTypes' import { Themes } from '@src/lib/theme'
import { Themes } from 'lib/theme' import type { DeepPartial } from '@src/lib/types'
import { DeepPartial } from 'lib/types' import { onboardingPaths } from '@src/routes/Onboarding/paths'
import { onboardingPaths } from 'routes/Onboarding/paths'
import type { Settings } from '@rust/kcl-lib/bindings/Settings'
export const IS_PLAYWRIGHT_KEY = 'playwright' export const IS_PLAYWRIGHT_KEY = 'playwright'
export const TEST_SETTINGS_KEY = '/settings.toml' export const TEST_SETTINGS_KEY = '/settings.toml'
export const TEST_SETTINGS: DeepPartial<Settings> = { export const TEST_SETTINGS: DeepPartial<Settings> = {
app: { app: {
appearance: {
theme: Themes.Dark, theme: Themes.Dark,
},
onboarding_status: 'dismissed', onboarding_status: 'dismissed',
project_directory: '',
show_debug_panel: true, show_debug_panel: true,
}, },
modeling: { modeling: {
@ -22,6 +24,7 @@ export const TEST_SETTINGS: DeepPartial<Settings> = {
}, },
project: { project: {
default_project_name: 'project-$nnn', default_project_name: 'project-$nnn',
directory: '',
}, },
text_editor: { text_editor: {
text_wrapping: true, text_wrapping: true,
@ -54,7 +57,7 @@ export const TEST_SETTINGS_ONBOARDING_START: DeepPartial<Settings> = {
export const TEST_SETTINGS_DEFAULT_THEME: DeepPartial<Settings> = { export const TEST_SETTINGS_DEFAULT_THEME: DeepPartial<Settings> = {
...TEST_SETTINGS, ...TEST_SETTINGS,
app: { ...TEST_SETTINGS.app, theme: Themes.System }, app: { ...TEST_SETTINGS.app, appearance: { theme: Themes.System } },
} }
export const TEST_SETTINGS_CORRUPTED = { export const TEST_SETTINGS_CORRUPTED = {

View File

@ -1,7 +1,12 @@
import { test, expect } from './zoo-test' import type { EngineCommand } from '@src/lang/std/artifactGraph'
import { commonPoints, getUtils, orRunWhenFullSuiteEnabled } from './test-utils' import { uuidv4 } from '@src/lib/utils'
import { EngineCommand } from 'lang/std/artifactGraph'
import { uuidv4 } from 'lib/utils' import {
commonPoints,
getUtils,
orRunWhenFullSuiteEnabled,
} from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
test.describe('Test network and connection issues', () => { test.describe('Test network and connection issues', () => {
test( test(

View File

@ -1,9 +1,9 @@
import { import {
orRunWhenFullSuiteEnabled,
runningOnLinux, runningOnLinux,
runningOnMac, runningOnMac,
runningOnWindows, runningOnWindows,
orRunWhenFullSuiteEnabled, } from '@e2e/playwright/test-utils'
} from './test-utils'
describe('platform detection utilities', () => { describe('platform detection utilities', () => {
const originalPlatform = process.platform const originalPlatform = process.platform

View File

@ -1,32 +1,29 @@
import { import * as TOML from '@iarna/toml'
expect, import type { Models } from '@kittycad/lib'
BrowserContext, import type { BrowserContext, Locator, Page, TestInfo } from '@playwright/test'
TestInfo, import { expect } from '@playwright/test'
Locator, import type { EngineCommand } from '@src/lang/std/artifactGraph'
Page, import type { Configuration } from '@src/lang/wasm'
} from '@playwright/test' import { COOKIE_NAME } from '@src/lib/constants'
import { test } from './zoo-test' import { reportRejection } from '@src/lib/trap'
import { EngineCommand } from 'lang/std/artifactGraph' import type { DeepPartial } from '@src/lib/types'
import { isArray } from '@src/lib/utils'
import fsp from 'fs/promises' import fsp from 'fs/promises'
import path from 'path' import path from 'path'
import pixelMatch from 'pixelmatch' import pixelMatch from 'pixelmatch'
import type { Protocol } from 'playwright-core/types/protocol'
import { PNG } from 'pngjs' import { PNG } from 'pngjs'
import { Protocol } from 'playwright-core/types/protocol'
import type { Models } from '@kittycad/lib' import type { ProjectConfiguration } from '@rust/kcl-lib/bindings/ProjectConfiguration'
import { COOKIE_NAME } from 'lib/constants'
import { secrets } from './secrets' import { isErrorWhitelisted } from '@e2e/playwright/lib/console-error-whitelist'
import { secrets } from '@e2e/playwright/secrets'
import { import {
TEST_SETTINGS_KEY,
TEST_SETTINGS,
IS_PLAYWRIGHT_KEY, IS_PLAYWRIGHT_KEY,
} from './storageStates' TEST_SETTINGS,
import * as TOML from '@iarna/toml' TEST_SETTINGS_KEY,
import { isErrorWhitelisted } from './lib/console-error-whitelist' } from '@e2e/playwright/storageStates'
import { isArray } from 'lib/utils' import { test } from '@e2e/playwright/zoo-test'
import { reportRejection } from 'lib/trap'
import { DeepPartial } from 'lib/types'
import { Configuration } from 'lang/wasm'
import { ProjectConfiguration } from '@rust/kcl-lib/bindings/ProjectConfiguration'
const toNormalizedCode = (text: string) => { const toNormalizedCode = (text: string) => {
return text.replace(/\s+/g, '') return text.replace(/\s+/g, '')
@ -903,15 +900,21 @@ export async function setup(
settings: { settings: {
...TEST_SETTINGS, ...TEST_SETTINGS,
app: { app: {
...TEST_SETTINGS.project, appearance: {
project_directory: TEST_SETTINGS.app?.project_directory, ...TEST_SETTINGS.app?.appearance,
onboarding_status: 'dismissed',
theme: 'dark', theme: 'dark',
}, },
...TEST_SETTINGS.project,
onboarding_status: 'dismissed',
},
project: {
...TEST_SETTINGS.project,
directory: TEST_SETTINGS.project?.directory,
},
}, },
}), }),
IS_PLAYWRIGHT_KEY, IS_PLAYWRIGHT_KEY,
PLAYWRIGHT_TEST_DIR: TEST_SETTINGS.app?.project_directory || '', PLAYWRIGHT_TEST_DIR: TEST_SETTINGS.project?.directory || '',
PERSIST_MODELING_CONTEXT, PERSIST_MODELING_CONTEXT,
} }
) )
@ -1112,21 +1115,25 @@ export async function pollEditorLinesSelectedLength(page: Page, lines: number) {
} }
export function settingsToToml(settings: DeepPartial<Configuration>) { export function settingsToToml(settings: DeepPartial<Configuration>) {
// eslint-disable-next-line no-restricted-syntax
return TOML.stringify(settings as any) return TOML.stringify(settings as any)
} }
export function tomlToSettings(toml: string): DeepPartial<Configuration> { export function tomlToSettings(toml: string): DeepPartial<Configuration> {
// eslint-disable-next-line no-restricted-syntax
return TOML.parse(toml) return TOML.parse(toml)
} }
export function tomlToPerProjectSettings( export function tomlToPerProjectSettings(
toml: string toml: string
): DeepPartial<ProjectConfiguration> { ): DeepPartial<ProjectConfiguration> {
// eslint-disable-next-line no-restricted-syntax
return TOML.parse(toml) return TOML.parse(toml)
} }
export function perProjectsettingsToToml( export function perProjectsettingsToToml(
settings: DeepPartial<ProjectConfiguration> settings: DeepPartial<ProjectConfiguration>
) { ) {
// eslint-disable-next-line no-restricted-syntax
return TOML.stringify(settings as any) return TOML.stringify(settings as any)
} }

View File

@ -1,7 +1,8 @@
import { test, expect } from './zoo-test' import type { EngineCommand } from '@src/lang/std/artifactGraph'
import { EngineCommand } from 'lang/std/artifactGraph' import { uuidv4 } from '@src/lib/utils'
import { uuidv4 } from 'lib/utils'
import { getUtils, orRunWhenFullSuiteEnabled } from './test-utils' import { getUtils, orRunWhenFullSuiteEnabled } from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
test.describe('Testing Camera Movement', { tag: ['@skipWin'] }, () => { test.describe('Testing Camera Movement', { tag: ['@skipWin'] }, () => {
test('Can move camera reliably', async ({ page, context, homePage }) => { test('Can move camera reliably', async ({ page, context, homePage }) => {

View File

@ -1,14 +1,15 @@
import { test, expect } from './zoo-test' import { XOR } from '@src/lib/utils'
import * as fsp from 'fs/promises' import * as fsp from 'fs/promises'
import {
getUtils,
TEST_COLORS,
pollEditorLinesSelectedLength,
orRunWhenFullSuiteEnabled,
} from './test-utils'
import { XOR } from 'lib/utils'
import path from 'node:path' import path from 'node:path'
import {
TEST_COLORS,
getUtils,
orRunWhenFullSuiteEnabled,
pollEditorLinesSelectedLength,
} from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
test.describe('Testing constraints', { tag: ['@skipWin'] }, () => { test.describe('Testing constraints', { tag: ['@skipWin'] }, () => {
test('Can constrain line length', async ({ page, homePage }) => { test('Can constrain line length', async ({ page, homePage }) => {
await page.addInitScript(async () => { await page.addInitScript(async () => {
@ -1097,7 +1098,7 @@ test.describe('Electron constraint tests', () => {
test( test(
'Able to double click label to set constraint', 'Able to double click label to set constraint',
{ tag: '@electron' }, { tag: '@electron' },
async ({ page, context, homePage, scene, editor, toolbar }) => { async ({ page, context, homePage, scene, editor, toolbar, cmdBar }) => {
await context.folderSetupFn(async (dir) => { await context.folderSetupFn(async (dir) => {
const bracketDir = path.join(dir, 'test-sample') const bracketDir = path.join(dir, 'test-sample')
await fsp.mkdir(bracketDir, { recursive: true }) await fsp.mkdir(bracketDir, { recursive: true })
@ -1131,6 +1132,14 @@ test.describe('Electron constraint tests', () => {
await scene.waitForExecutionDone() await scene.waitForExecutionDone()
}) })
async function clickOnFirstSegmentLabel() {
const child = page
.locator('.segment-length-label-text')
.first()
.locator('xpath=..')
await child.dblclick()
}
await test.step('Double click to constrain', async () => { await test.step('Double click to constrain', async () => {
// Enter sketch edit mode via feature tree // Enter sketch edit mode via feature tree
await toolbar.openPane('feature-tree') await toolbar.openPane('feature-tree')
@ -1138,21 +1147,19 @@ test.describe('Electron constraint tests', () => {
await op.dblclick() await op.dblclick()
await toolbar.closePane('feature-tree') await toolbar.closePane('feature-tree')
const child = page await clickOnFirstSegmentLabel()
.locator('.segment-length-label-text') await cmdBar.progressCmdBar()
.first() await editor.expectEditor.toContain('length001 = 15.3')
.locator('xpath=..') await editor.expectEditor.toContain('|> angledLine([9, length001], %)')
await child.dblclick()
const cmdBarSubmitButton = page.getByRole('button', {
name: 'arrow right Continue',
}) })
await cmdBarSubmitButton.click()
await expect(page.locator('.cm-content')).toContainText( await test.step('Double click again and expect failure', async () => {
'length001 = 15.3' await clickOnFirstSegmentLabel()
)
await expect(page.locator('.cm-content')).toContainText( await expect(
'|> angledLine([9, length001], %)' page.getByText('Unable to constrain the length of this segment')
) ).toBeVisible()
await page.getByRole('button', { name: 'Exit Sketch' }).click() await page.getByRole('button', { name: 'Exit Sketch' }).click()
}) })
} }

View File

@ -1,7 +1,8 @@
import { test, expect } from './zoo-test' import { uuidv4 } from '@src/lib/utils'
import { getUtils } from './test-utils'
import { uuidv4 } from 'lib/utils' import { TEST_CODE_GIZMO } from '@e2e/playwright/storageStates'
import { TEST_CODE_GIZMO } from './storageStates' import { getUtils } from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
test.describe('Testing Gizmo', { tag: ['@skipWin'] }, () => { test.describe('Testing Gizmo', { tag: ['@skipWin'] }, () => {
const cases = [ const cases = [

View File

@ -1,5 +1,5 @@
import { test, expect } from './zoo-test' import { getUtils, orRunWhenFullSuiteEnabled } from '@e2e/playwright/test-utils'
import { getUtils, orRunWhenFullSuiteEnabled } from './test-utils' import { expect, test } from '@e2e/playwright/zoo-test'
test.describe('Test toggling perspective', () => { test.describe('Test toggling perspective', () => {
test('via command palette and toggle', async ({ page, homePage }) => { test('via command palette and toggle', async ({ page, homePage }) => {

View File

@ -1,9 +1,10 @@
import { test, expect } from './zoo-test' import { FILE_EXT } from '@src/lib/constants'
import { getUtils } from './test-utils' import { bracket } from '@src/lib/exampleKcl'
import { bracket } from 'lib/exampleKcl'
import * as fsp from 'fs/promises' import * as fsp from 'fs/promises'
import { join } from 'path' import { join } from 'path'
import { FILE_EXT } from 'lib/constants'
import { getUtils } from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
test.describe('Testing in-app sample loading', () => { test.describe('Testing in-app sample loading', () => {
/** /**

View File

@ -1,15 +1,15 @@
import { Page } from '@playwright/test' import type { Page } from '@playwright/test'
import { test, expect } from './zoo-test' import type { LineInputsType } from '@src/lang/std/sketchcombos'
import { uuidv4 } from '@src/lib/utils'
import type { EditorFixture } from '@e2e/playwright/fixtures/editorFixture'
import { import {
deg, deg,
getUtils, getUtils,
wiggleMove,
orRunWhenFullSuiteEnabled, orRunWhenFullSuiteEnabled,
} from './test-utils' wiggleMove,
import { LineInputsType } from 'lang/std/sketchcombos' } from '@e2e/playwright/test-utils'
import { uuidv4 } from 'lib/utils' import { expect, test } from '@e2e/playwright/zoo-test'
import { EditorFixture } from './fixtures/editorFixture'
test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => { test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => {
test('Hover over a segment should show its overlay, hovering over the input overlays should show its popover, clicking the input overlay should constrain/unconstrain it:\nfor the following segments', () => { test('Hover over a segment should show its overlay, hovering over the input overlays should show its popover, clicking the input overlay should constrain/unconstrain it:\nfor the following segments', () => {

View File

@ -1,9 +1,13 @@
import { test, expect } from './zoo-test' import type { Coords2d } from '@src/lang/std/sketch'
import { KCL_DEFAULT_LENGTH } from '@src/lib/constants'
import { uuidv4 } from '@src/lib/utils'
import { commonPoints, getUtils, orRunWhenFullSuiteEnabled } from './test-utils' import {
import { Coords2d } from 'lang/std/sketch' commonPoints,
import { KCL_DEFAULT_LENGTH } from 'lib/constants' getUtils,
import { uuidv4 } from 'lib/utils' orRunWhenFullSuiteEnabled,
} from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
test.describe('Testing selections', { tag: ['@skipWin'] }, () => { test.describe('Testing selections', { tag: ['@skipWin'] }, () => {
test.setTimeout(90_000) test.setTimeout(90_000)

View File

@ -1,24 +1,29 @@
import { test, expect } from './zoo-test' import {
PROJECT_SETTINGS_FILE_NAME,
SETTINGS_FILE_NAME,
} from '@src/lib/constants'
import type { SettingsLevel } from '@src/lib/settings/settingsTypes'
import type { DeepPartial } from '@src/lib/types'
import * as fsp from 'fs/promises' import * as fsp from 'fs/promises'
import { join } from 'path' import { join } from 'path'
import type { Settings } from '@rust/kcl-lib/bindings/Settings'
import { import {
getUtils,
executorInputPath,
createProject,
tomlToSettings,
TEST_COLORS,
orRunWhenFullSuiteEnabled,
} from './test-utils'
import { SettingsLevel } from 'lib/settings/settingsTypes'
import { SETTINGS_FILE_NAME, PROJECT_SETTINGS_FILE_NAME } from 'lib/constants'
import {
TEST_SETTINGS_KEY,
TEST_SETTINGS_CORRUPTED,
TEST_SETTINGS, TEST_SETTINGS,
TEST_SETTINGS_CORRUPTED,
TEST_SETTINGS_DEFAULT_THEME, TEST_SETTINGS_DEFAULT_THEME,
} from './storageStates' TEST_SETTINGS_KEY,
import { DeepPartial } from 'lib/types' } from '@e2e/playwright/storageStates'
import { Settings } from '@rust/kcl-lib/bindings/Settings' import {
TEST_COLORS,
createProject,
executorInputPath,
getUtils,
orRunWhenFullSuiteEnabled,
tomlToSettings,
} from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
test.describe('Testing settings', () => { test.describe('Testing settings', () => {
test('Stored settings are validated and fall back to defaults', async ({ test('Stored settings are validated and fall back to defaults', async ({
@ -45,12 +50,12 @@ test.describe('Testing settings', () => {
) )
) )
expect(storedSettings.settings?.app?.theme).toBe('dark') expect(storedSettings.settings?.app?.appearance?.theme).toBe('dark')
// Check that the invalid settings were changed to good defaults // Check that the invalid settings were changed to good defaults
expect(storedSettings.settings?.modeling?.base_unit).toBe('in') expect(storedSettings.settings?.modeling?.base_unit).toBe('in')
expect(storedSettings.settings?.modeling?.mouse_controls).toBe('zoo') expect(storedSettings.settings?.modeling?.mouse_controls).toBe('zoo')
expect(storedSettings.settings?.app?.project_directory).toBe('') expect(storedSettings.settings?.project?.directory).toBe('')
expect(storedSettings.settings?.project?.default_project_name).toBe( expect(storedSettings.settings?.project?.default_project_name).toBe(
'project-$nnn' 'project-$nnn'
) )
@ -381,7 +386,9 @@ test.describe('Testing settings', () => {
} }
await tronApp.cleanProjectDir({ await tronApp.cleanProjectDir({
app: { app: {
theme_color: '259', appearance: {
color: 259,
},
}, },
}) })
@ -413,9 +420,12 @@ test.describe('Testing settings', () => {
await tronApp.cleanProjectDir({ await tronApp.cleanProjectDir({
app: { app: {
appearance: {
// Doesn't matter what you set it to. It will // Doesn't matter what you set it to. It will
// default to 264.5 // default to 264.5
theme_color: '0',
color: 0,
},
}, },
}) })

View File

@ -1,12 +1,13 @@
import { Page } from '@playwright/test' import type { Page } from '@playwright/test'
import { test, expect } from './zoo-test'
import {
getUtils,
createProject,
orRunWhenFullSuiteEnabled,
} from './test-utils'
import { join } from 'path'
import fs from 'fs' import fs from 'fs'
import { join } from 'path'
import {
createProject,
getUtils,
orRunWhenFullSuiteEnabled,
} from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
test.describe('Text-to-CAD tests', { tag: ['@skipWin'] }, () => { test.describe('Text-to-CAD tests', { tag: ['@skipWin'] }, () => {
test('basic lego happy case', async ({ page, homePage }) => { test('basic lego happy case', async ({ page, homePage }) => {

View File

@ -1,11 +1,10 @@
import { test, expect } from './zoo-test'
import { import {
doExport, doExport,
getUtils, getUtils,
makeTemplate, makeTemplate,
orRunWhenFullSuiteEnabled, orRunWhenFullSuiteEnabled,
} from './test-utils' } from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
test('Units menu', async ({ page, homePage }) => { test('Units menu', async ({ page, homePage }) => {
test.fixme(orRunWhenFullSuiteEnabled()) test.fixme(orRunWhenFullSuiteEnabled())

View File

@ -1,12 +1,11 @@
/* eslint-disable react-hooks/rules-of-hooks */ /* eslint-disable react-hooks/rules-of-hooks */
import { test as playwrightTestFn } from '@playwright/test' import { test as playwrightTestFn } from '@playwright/test'
import type { Fixtures } from '@e2e/playwright/fixtures/fixtureSetup'
import { import {
fixturesBasedOnProcessEnvPlatform,
Fixtures,
ElectronZoo, ElectronZoo,
} from './fixtures/fixtureSetup' fixturesBasedOnProcessEnvPlatform,
} from '@e2e/playwright/fixtures/fixtureSetup'
export { expect } from '@playwright/test' export { expect } from '@playwright/test'

View File

@ -1,6 +1,6 @@
import type { ForgeConfig } from '@electron-forge/shared-types'
import { VitePlugin } from '@electron-forge/plugin-vite'
import { FusesPlugin } from '@electron-forge/plugin-fuses' import { FusesPlugin } from '@electron-forge/plugin-fuses'
import { VitePlugin } from '@electron-forge/plugin-vite'
import type { ForgeConfig } from '@electron-forge/shared-types'
import { FuseV1Options, FuseVersion } from '@electron/fuses' import { FuseV1Options, FuseVersion } from '@electron/fuses'
import path from 'path' import path from 'path'

2
forge.env.d.ts vendored
View File

@ -26,7 +26,7 @@ declare global {
declare module 'vite' { declare module 'vite' {
interface ConfigEnv< interface ConfigEnv<
K extends keyof VitePluginConfig = keyof VitePluginConfig K extends keyof VitePluginConfig = keyof VitePluginConfig,
> { > {
root: string root: string
forgeConfig: VitePluginConfig forgeConfig: VitePluginConfig

13
interface.d.ts vendored
View File

@ -1,13 +1,10 @@
import fs from 'node:fs/promises'
import fsSync from 'node:fs'
import path from 'path'
import { dialog, shell } from 'electron'
import { MachinesListing } from 'components/MachineManagerProvider' import { MachinesListing } from 'components/MachineManagerProvider'
import type { Channel } from 'src/menu/channels' import 'electron'
import { Menu, WebContents } from 'electron' import { dialog, shell } from 'electron'
import { ZooLabel, ZooMenuEvents } from 'menu/roles'
import type { MenuActionIPC } from 'menu/rules'
import type { WebContentSendPayload } from 'menu/channels' import type { WebContentSendPayload } from 'menu/channels'
import { ZooLabel } from 'menu/roles'
import fs from 'node:fs/promises'
import path from 'path'
// Extend the interface with additional custom properties // Extend the interface with additional custom properties
declare module 'electron' { declare module 'electron' {

1
known-circular.txt Normal file
View File

@ -0,0 +1 @@
$ dpdm --no-warning --no-tree -T --skip-dynamic-imports=circular src/index.tsx• Circular Dependencies 01) src/lang/std/sketch.ts -> src/lang/modifyAst.ts -> src/lang/modifyAst/addEdgeTreatment.ts 02) src/lang/std/sketch.ts -> src/lang/modifyAst.ts 03) src/lang/std/sketch.ts -> src/lang/modifyAst.ts -> src/lang/std/sketchcombos.ts 04) src/clientSideScene/CameraControls.ts -> src/clientSideScene/sceneInfra.ts 05) src/lib/singletons.ts -> src/editor/manager.ts -> src/lib/selections.ts 06) src/lib/singletons.ts -> src/editor/manager.ts 07) src/lib/singletons.ts -> src/lang/KclSingleton.ts 08) src/lib/singletons.ts -> src/lang/codeManager.ts 09) src/lib/singletons.ts -> src/clientSideScene/sceneEntities.ts -> src/clientSideScene/segments.ts -> src/components/Toolbar/angleLengthInfo.ts 10) src/lib/singletons.ts -> src/clientSideScene/sceneEntities.ts -> src/clientSideScene/segments.ts -> src/machines/commandBarMachine.ts -> src/lib/commandBarConfigs/authCommandConfig.ts -> src/machines/appMachine.ts -> src/machines/settingsMachine.ts -> src/lib/commandBarConfigs/settingsCommandConfig.ts -> src/lib/createMachineCommand.ts -> src/routes/Settings.tsx -> src/components/Settings/AllSettingsFields.tsx -> src/components/LspProvider.tsx -> src/editor/plugins/lsp/copilot/index.ts 11) src/lib/singletons.ts -> src/clientSideScene/sceneEntities.ts -> src/clientSideScene/segments.ts -> src/machines/commandBarMachine.ts -> src/lib/commandBarConfigs/authCommandConfig.ts -> src/machines/appMachine.ts -> src/machines/settingsMachine.ts -> src/lib/commandBarConfigs/settingsCommandConfig.ts -> src/lib/createMachineCommand.ts -> src/routes/Settings.tsx -> src/components/Settings/AllSettingsFields.tsx -> src/components/LspProvider.tsx -> src/editor/plugins/lsp/kcl/language.ts -> src/editor/plugins/lsp/kcl/index.ts 12) src/lib/singletons.ts -> src/clientSideScene/sceneEntities.ts -> src/clientSideScene/segments.ts -> src/machines/commandBarMachine.ts -> src/lib/commandBarConfigs/authCommandConfig.ts -> src/machines/appMachine.ts -> src/machines/settingsMachine.ts -> src/lib/commandBarConfigs/settingsCommandConfig.ts -> src/lib/createMachineCommand.ts -> src/routes/Settings.tsx -> src/components/Settings/AllSettingsFields.tsx -> src/components/LspProvider.tsx 13) src/machines/appMachine.ts -> src/machines/settingsMachine.ts -> src/lib/commandBarConfigs/settingsCommandConfig.ts -> src/lib/createMachineCommand.ts -> src/routes/Settings.tsx -> src/components/Settings/AllSettingsFields.tsx -> src/components/LspProvider.tsx 14) src/machines/appMachine.ts -> src/machines/settingsMachine.ts -> src/lib/commandBarConfigs/settingsCommandConfig.ts -> src/lib/createMachineCommand.ts -> src/routes/Settings.tsx -> src/components/Settings/AllSettingsFields.tsx -> src/components/Settings/SettingsFieldInput.tsx 15) src/machines/appMachine.ts -> src/machines/settingsMachine.ts -> src/lib/commandBarConfigs/settingsCommandConfig.ts -> src/lib/createMachineCommand.ts -> src/routes/Settings.tsx -> src/components/Settings/AllSettingsFields.tsx 16) src/routes/Settings.tsx -> src/components/Settings/AllSettingsFields.tsx 17) src/machines/appMachine.ts -> src/machines/settingsMachine.ts -> src/lib/commandBarConfigs/settingsCommandConfig.ts -> src/lib/createMachineCommand.ts -> src/routes/Settings.tsx -> src/components/Settings/SettingsSearchBar.tsx 18) src/machines/appMachine.ts -> src/machines/settingsMachine.ts -> src/lib/commandBarConfigs/settingsCommandConfig.ts -> src/lib/createMachineCommand.ts -> src/routes/Settings.tsx -> src/components/Settings/SettingsSectionsList.tsx 19) src/lib/singletons.ts -> src/clientSideScene/sceneEntities.ts -> src/clientSideScene/segments.ts -> src/machines/commandBarMachine.ts -> src/lib/commandBarConfigs/authCommandConfig.ts -> src/machines/appMachine.ts -> src/machines/settingsMachine.ts 20) src/machines/commandBarMachine.ts -> src/lib/commandBarConfigs/authCommandConfig.ts -> src/machines/appMachine.ts -> src/machines/settingsMachine.ts 21) src/hooks/useModelingContext.ts -> src/components/ModelingMachineProvider.tsx -> src/components/Toolbar/Intersect.tsx -> src/components/SetHorVertDistanceModal.tsx -> src/lib/useCalculateKclExpression.ts 22) src/components/ToastTextToCad.tsx -> src/lib/textToCad.ts 23) src/hooks/useModelingContext.ts -> src/components/ModelingMachineProvider.tsx -> src/machines/modelingMachine.ts -> src/clientSideScene/ClientSideSceneComp.tsx 24) src/routes/Onboarding/index.tsx -> src/routes/Onboarding/Camera.tsx -> src/routes/Onboarding/utils.tsx

View File

@ -26,7 +26,7 @@
"@fortawesome/react-fontawesome": "^0.2.0", "@fortawesome/react-fontawesome": "^0.2.0",
"@headlessui/react": "^1.7.19", "@headlessui/react": "^1.7.19",
"@headlessui/tailwindcss": "^0.2.2", "@headlessui/tailwindcss": "^0.2.2",
"@kittycad/lib": "2.0.23", "@kittycad/lib": "2.0.25",
"@lezer/highlight": "^1.2.1", "@lezer/highlight": "^1.2.1",
"@lezer/lr": "^1.4.1", "@lezer/lr": "^1.4.1",
"@react-hook/resize-observer": "^2.0.1", "@react-hook/resize-observer": "^2.0.1",
@ -88,24 +88,26 @@
"simpleserver:ci": "yarn pretest && http-server ./public --cors -p 3000 &", "simpleserver:ci": "yarn pretest && http-server ./public --cors -p 3000 &",
"simpleserver:bg": "yarn pretest && http-server ./public --cors -p 3000 &", "simpleserver:bg": "yarn pretest && http-server ./public --cors -p 3000 &",
"simpleserver:stop": "kill-port 3000", "simpleserver:stop": "kill-port 3000",
"fmt": "prettier --write ./src *.ts *.json *.js ./e2e ./packages ./rust/kcl-language-server ./rust/kcl-lib/bindings ./rust/kcl-wasm-lib/pkg", "fmt": "prettier --write .eslintrc.json ./src *.ts *.json *.js ./e2e ./packages ./rust/kcl-language-server ./rust/kcl-lib/bindings ./rust/kcl-wasm-lib/pkg",
"fmt:generated": "prettier --write *.ts *.json *.js ./rust/kcl-lib/bindings ./rust/kcl-wasm-lib/pkg", "fmt:generated": "prettier --write .eslintrc.json *.ts *.json *.js ./rust/kcl-lib/bindings ./rust/kcl-wasm-lib/pkg",
"fmt-check": "prettier --check ./src *.ts *.json *.js ./e2e ./packages ./rust/kcl-language-server", "fmt-check": "prettier --check .eslintrc.json ./src *.ts *.json *.js ./e2e ./packages ./rust/kcl-language-server",
"fetch:wasm": "./scripts/get-latest-wasm-bundle.sh", "fetch:wasm": "./scripts/get-latest-wasm-bundle.sh",
"fetch:wasm:windows": "./scripts/get-latest-wasm-bundle.ps1", "fetch:wasm:windows": "powershell -ExecutionPolicy Bypass -File ./scripts/get-latest-wasm-bundle.ps1",
"fetch:samples": "rm -rf public/kcl-samples* && curl -L -o public/kcl-samples.zip https://github.com/KittyCAD/kcl-samples/archive/refs/heads/achalmers/kw-args-xylineto.zip && unzip -o public/kcl-samples.zip -d public && mv public/kcl-samples-* public/kcl-samples", "fetch:samples": "rm -rf public/kcl-samples* && curl -L -o public/kcl-samples.zip https://github.com/KittyCAD/kcl-samples/archive/refs/heads/achalmers/kw-args-xylineto.zip && unzip -o public/kcl-samples.zip -d public && mv public/kcl-samples-* public/kcl-samples",
"build:wasm": "./scripts/build-wasm.sh", "build:wasm": "./scripts/build-wasm.sh",
"build:wasm:windows": "./scripts/build-wasm.ps1", "build:wasm:windows": "powershell -ExecutionPolicy Bypass -File ./scripts/build-wasm.ps1",
"build:wasm-dev": "yarn build:wasm:dev", "build:wasm-dev": "yarn build:wasm:dev",
"build:wasm:dev": "./scripts/build-wasm-dev.sh", "build:wasm:dev": "./scripts/build-wasm-dev.sh",
"build:wasm:dev:windows": "./scripts/build-wasm-dev.ps1", "build:wasm:dev:windows": "powershell -ExecutionPolicy Bypass -File ./scripts/build-wasm-dev.ps1",
"remove-importmeta": "sed -i 's/import.meta.url/window.location.origin/g' \"./rust/kcl-wasm-lib/pkg/kcl_wasm_lib.js\"; sed -i '' 's/import.meta.url/window.location.origin/g' \"./rust/kcl-wasm-lib/pkg/kcl_wasm_lib.js\" || echo \"sed for both mac and linux\"", "remove-importmeta": "sed -i 's/import.meta.url/window.location.origin/g' \"./rust/kcl-wasm-lib/pkg/kcl_wasm_lib.js\"; sed -i '' 's/import.meta.url/window.location.origin/g' \"./rust/kcl-wasm-lib/pkg/kcl_wasm_lib.js\" || echo \"sed for both mac and linux\"",
"lint-fix": "eslint --fix --ext .ts --ext .tsx src e2e packages/codemirror-lsp-client/src rust/kcl-language-server/client/src", "lint-fix": "eslint --fix --ext .ts --ext .tsx src e2e packages/codemirror-lsp-client/src rust/kcl-language-server/client/src",
"lint": "eslint --max-warnings 0 --ext .ts --ext .tsx src e2e packages/codemirror-lsp-client/src rust/kcl-language-server/client/src", "lint": "eslint --max-warnings 0 --ext .ts --ext .tsx src e2e packages/codemirror-lsp-client/src rust/kcl-language-server/client/src",
"circular-deps": "dpdm --no-warning --no-tree -T --skip-dynamic-imports=circular src/index.tsx",
"circular-deps:diff": "./scripts/diff-circular-deps.sh",
"files:set-version": "echo \"$(jq --arg v \"$VERSION\" '.version=$v' package.json --indent 2)\" > package.json", "files:set-version": "echo \"$(jq --arg v \"$VERSION\" '.version=$v' package.json --indent 2)\" > package.json",
"files:set-notes": "./scripts/set-files-notes.sh", "files:set-notes": "./scripts/set-files-notes.sh",
"files:flip-to-nightly": "./scripts/flip-files-to-nightly.sh", "files:flip-to-nightly": "./scripts/flip-files-to-nightly.sh",
"files:flip-to-nightly:windows": "./scripts/flip-files-to-nightly.ps1", "files:flip-to-nightly:windows": "powershell -ExecutionPolicy Bypass -File ./scripts/flip-files-to-nightly.ps1",
"files:invalidate-bucket": "./scripts/invalidate-files-bucket.sh", "files:invalidate-bucket": "./scripts/invalidate-files-bucket.sh",
"files:invalidate-bucket:nightly": "./scripts/invalidate-files-bucket.sh --nightly", "files:invalidate-bucket:nightly": "./scripts/invalidate-files-bucket.sh --nightly",
"postinstall": "yarn --cwd ./rust/kcl-language-server --modules-folder node_modules install && ./node_modules/.bin/electron-rebuild", "postinstall": "yarn --cwd ./rust/kcl-language-server --modules-folder node_modules install && ./node_modules/.bin/electron-rebuild",
@ -139,7 +141,20 @@
"trailingComma": "es5", "trailingComma": "es5",
"tabWidth": 2, "tabWidth": 2,
"semi": false, "semi": false,
"singleQuote": true "singleQuote": true,
"importOrder": [
"<THIRD_PARTY_MODULES>",
"^@rust/(.*)$",
"^@e2e/(.*)$",
"^@src/(.*)$",
"^[./]"
],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"plugins": [
"@trivago/prettier-plugin-sort-imports",
"prettier-plugin-organize-imports"
]
}, },
"browserslist": { "browserslist": {
"production": [ "production": [
@ -167,6 +182,7 @@
"@playwright/test": "^1.51.1", "@playwright/test": "^1.51.1",
"@testing-library/jest-dom": "^5.14.1", "@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^15.0.2", "@testing-library/react": "^15.0.2",
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
"@types/diff": "^7.0.2", "@types/diff": "^7.0.2",
"@types/electron": "^1.6.10", "@types/electron": "^1.6.10",
"@types/isomorphic-fetch": "^0.0.39", "@types/isomorphic-fetch": "^0.0.39",
@ -187,6 +203,7 @@
"@vitest/web-worker": "^1.5.0", "@vitest/web-worker": "^1.5.0",
"@xstate/cli": "^0.5.17", "@xstate/cli": "^0.5.17",
"autoprefixer": "^10.4.21", "autoprefixer": "^10.4.21",
"dpdm": "^3.14.0",
"electron": "^34.1.1", "electron": "^34.1.1",
"electron-builder": "^26.0.12", "electron-builder": "^26.0.12",
"eslint": "^8.0.1", "eslint": "^8.0.1",
@ -208,7 +225,8 @@
"pngjs": "^7.0.0", "pngjs": "^7.0.0",
"postcss": "^8.4.43", "postcss": "^8.4.43",
"postinstall-postinstall": "^2.1.0", "postinstall-postinstall": "^2.1.0",
"prettier": "^2.8.8", "prettier": "^3.5.3",
"prettier-plugin-organize-imports": "^4.1.0",
"setimmediate": "^1.0.5", "setimmediate": "^1.0.5",
"tailwindcss": "^3.4.17", "tailwindcss": "^3.4.17",
"ts-node": "^10.0.0", "ts-node": "^10.0.0",

View File

@ -1,6 +1,6 @@
import dts from 'rollup-plugin-dts'
import { lezer } from '@lezer/generator/rollup' import { lezer } from '@lezer/generator/rollup'
import typescript from '@rollup/plugin-typescript' import typescript from '@rollup/plugin-typescript'
import dts from 'rollup-plugin-dts'
export default [ export default [
{ {

View File

@ -1,14 +1,14 @@
// Base CodeMirror language support for kcl. // Base CodeMirror language support for kcl.
import { import {
LRLanguage, LRLanguage,
LanguageSupport, LanguageSupport,
indentNodeProp,
continuedIndent, continuedIndent,
delimitedIndent, delimitedIndent,
foldNodeProp,
foldInside, foldInside,
foldNodeProp,
indentNodeProp,
} from '@codemirror/language' } from '@codemirror/language'
// @ts-ignore: No types available // @ts-ignore: No types available
import { parser } from './kcl.grammar' import { parser } from './kcl.grammar'

View File

@ -1,9 +1,9 @@
import { KclLanguage } from '../src/index'
import { fileTests } from '@lezer/generator/dist/test' import { fileTests } from '@lezer/generator/dist/test'
import * as fs from 'fs' import * as fs from 'fs'
import * as path from 'path' import * as path from 'path'
import { KclLanguage } from '../src/index'
let caseDir = path.dirname(__filename) let caseDir = path.dirname(__filename)
for (let file of fs.readdirSync(caseDir)) { for (let file of fs.readdirSync(caseDir)) {

View File

@ -1,9 +1,8 @@
// Overrides the test options from the modeling-app config. // Overrides the test options from the modeling-app config.
import viteTsconfigPaths from 'vite-tsconfig-paths'
import { defineConfig, configDefaults } from 'vitest/config'
// @ts-ignore: No types available // @ts-ignore: No types available
import { lezer } from '@lezer/generator/rollup' import { lezer } from '@lezer/generator/rollup'
import viteTsconfigPaths from 'vite-tsconfig-paths'
import { defineConfig } from 'vitest/config'
const config = defineConfig({ const config = defineConfig({
test: { test: {

View File

@ -1,4 +1,4 @@
import { encoder, decoder } from '../codec' import { decoder, encoder } from './encode-decode'
export default class Bytes { export default class Bytes {
static encode(input: string): Uint8Array { static encode(input: string): Uint8Array {
@ -10,7 +10,7 @@ export default class Bytes {
} }
static append< static append<
T extends { length: number; set(arr: T, offset: number): void } T extends { length: number; set(arr: T, offset: number): void },
>(constructor: { new (length: number): T }, ...arrays: T[]) { >(constructor: { new (length: number): T }, ...arrays: T[]) {
let totalLength = 0 let totalLength = 0
for (const arr of arrays) { for (const arr of arrays) {

View File

@ -1,10 +1,10 @@
import * as vsrpc from 'vscode-jsonrpc' import * as vsrpc from 'vscode-jsonrpc'
import { Codec } from '.'
import Bytes from './bytes' import Bytes from './bytes'
import PromiseMap from './map'
import Queue from './queue' import Queue from './queue'
import Tracer from './tracer' import Tracer from './tracer'
import PromiseMap from './map' import { Codec } from './utils'
export default class StreamDemuxer extends Queue<Uint8Array> { export default class StreamDemuxer extends Queue<Uint8Array> {
readonly responses: PromiseMap<number | string, vsrpc.ResponseMessage> = readonly responses: PromiseMap<number | string, vsrpc.ResponseMessage> =

View File

@ -0,0 +1,2 @@
export const encoder = new TextEncoder()
export const decoder = new TextDecoder()

View File

@ -1,8 +1,7 @@
import * as jsrpc from 'json-rpc-2.0' import type * as vsrpc from 'vscode-jsonrpc'
import * as vsrpc from 'vscode-jsonrpc'
import Bytes from './bytes'
import StreamDemuxer from './demuxer' import StreamDemuxer from './demuxer'
import { decoder } from './encode-decode'
import Headers from './headers' import Headers from './headers'
import Queue from './queue' import Queue from './queue'
import Tracer from './tracer' import Tracer from './tracer'
@ -12,25 +11,6 @@ export enum LspWorkerEventType {
Call = 'call', Call = 'call',
} }
export const encoder = new TextEncoder()
export const decoder = new TextDecoder()
export class Codec {
static encode(
json: jsrpc.JSONRPCRequest | jsrpc.JSONRPCResponse
): Uint8Array {
const message = JSON.stringify(json)
const delimited = Headers.add(message)
return Bytes.encode(delimited)
}
static decode<T>(data: Uint8Array): T {
const delimited = Bytes.decode(data)
const message = Headers.remove(delimited)
return JSON.parse(message) as T
}
}
// FIXME: tracing efficiency // FIXME: tracing efficiency
export class IntoServer export class IntoServer
extends Queue<Uint8Array> extends Queue<Uint8Array>

View File

@ -1,4 +1,4 @@
import { Message } from 'vscode-languageserver-protocol' import type { Message } from 'vscode-languageserver-protocol'
export default class Tracer { export default class Tracer {
static client(message: string): void { static client(message: string): void {

View File

@ -0,0 +1,20 @@
import type * as jsrpc from 'json-rpc-2.0'
import Bytes from './bytes'
import Headers from './headers'
export class Codec {
static encode(
json: jsrpc.JSONRPCRequest | jsrpc.JSONRPCResponse
): Uint8Array {
const message = JSON.stringify(json)
const delimited = Headers.add(message)
return Bytes.encode(delimited)
}
static decode<T>(data: Uint8Array): T {
const delimited = Bytes.decode(data)
const message = Headers.remove(delimited)
return JSON.parse(message) as T
}
}

View File

@ -1,8 +1,8 @@
import type * as LSP from 'vscode-languageserver-protocol' import type * as LSP from 'vscode-languageserver-protocol'
import { FromServer, IntoServer } from './codec' import type { LanguageServerPlugin } from '../plugin/lsp'
import type { FromServer, IntoServer } from './codec'
import Client from './jsonrpc' import Client from './jsonrpc'
import { LanguageServerPlugin } from '../plugin/lsp'
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/ // https://microsoft.github.io/language-server-protocol/specifications/specification-current/
@ -12,15 +12,15 @@ interface LSPRequestMap {
'textDocument/hover': [LSP.HoverParams, LSP.Hover] 'textDocument/hover': [LSP.HoverParams, LSP.Hover]
'textDocument/completion': [ 'textDocument/completion': [
LSP.CompletionParams, LSP.CompletionParams,
LSP.CompletionItem[] | LSP.CompletionList | null LSP.CompletionItem[] | LSP.CompletionList | null,
] ]
'textDocument/semanticTokens/full': [ 'textDocument/semanticTokens/full': [
LSP.SemanticTokensParams, LSP.SemanticTokensParams,
LSP.SemanticTokens LSP.SemanticTokens,
] ]
'textDocument/formatting': [ 'textDocument/formatting': [
LSP.DocumentFormattingParams, LSP.DocumentFormattingParams,
LSP.TextEdit[] | null LSP.TextEdit[] | null,
] ]
'textDocument/foldingRange': [LSP.FoldingRangeParams, LSP.FoldingRange[]] 'textDocument/foldingRange': [LSP.FoldingRangeParams, LSP.FoldingRange[]]
} }

View File

@ -1,11 +1,12 @@
import * as jsrpc from 'json-rpc-2.0' import * as jsrpc from 'json-rpc-2.0'
import * as LSP from 'vscode-languageserver-protocol' import * as LSP from 'vscode-languageserver-protocol'
import type { FromServer, IntoServer } from './codec'
import { Codec } from './codec/utils'
import { import {
registerServerCapability, registerServerCapability,
unregisterServerCapability, unregisterServerCapability,
} from './server-capability-registration' } from './server-capability-registration'
import { Codec, FromServer, IntoServer } from './codec'
const client_capabilities: LSP.ClientCapabilities = { const client_capabilities: LSP.ClientCapabilities = {
textDocument: { textDocument: {

View File

@ -1,4 +1,4 @@
import { import type {
Registration, Registration,
ServerCapabilities, ServerCapabilities,
Unregistration, Unregistration,

View File

@ -1,36 +1,34 @@
import { foldService } from '@codemirror/language' import { foldService } from '@codemirror/language'
import { Extension, EditorState } from '@codemirror/state' import type { EditorState, Extension } from '@codemirror/state'
import { ViewPlugin } from '@codemirror/view' import { ViewPlugin } from '@codemirror/view'
import type { LanguageServerOptions } from './plugin/lsp'
import { import {
docPathFacet,
LanguageServerPlugin, LanguageServerPlugin,
LanguageServerPluginSpec, LanguageServerPluginSpec,
docPathFacet,
languageId, languageId,
workspaceFolders, workspaceFolders,
LanguageServerOptions,
} from './plugin/lsp' } from './plugin/lsp'
export type { LanguageServerClientOptions } from './client'
export { LanguageServerClient } from './client' export { LanguageServerClient } from './client'
export type { LanguageServerClientOptions } from './client'
export { FromServer, IntoServer, LspWorkerEventType } from './client/codec'
export { Codec } from './client/codec/utils'
export { export {
Codec, lspDiagnosticsEvent,
FromServer, lspFormatCodeEvent,
IntoServer, lspSemanticTokensEvent,
LspWorkerEventType, } from './plugin/annotation'
} from './client/codec'
export type { LanguageServerOptions } from './plugin/lsp'
export { export {
LanguageServerPlugin, LanguageServerPlugin,
LanguageServerPluginSpec, LanguageServerPluginSpec,
docPathFacet, docPathFacet,
languageId, languageId,
workspaceFolders, workspaceFolders,
lspSemanticTokensEvent,
lspDiagnosticsEvent,
lspFormatCodeEvent,
} from './plugin/lsp' } from './plugin/lsp'
export { posToOffset, offsetToPos } from './plugin/util' export type { LanguageServerOptions } from './plugin/lsp'
export { offsetToPos, posToOffset } from './plugin/util'
export function lspPlugin(options: LanguageServerOptions): Extension { export function lspPlugin(options: LanguageServerOptions): Extension {
let plugin: LanguageServerPlugin | null = null let plugin: LanguageServerPlugin | null = null

View File

@ -0,0 +1,12 @@
import { Annotation } from '@codemirror/state'
export enum LspAnnotation {
SemanticTokens = 'semantic-tokens',
FormatCode = 'format-code',
Diagnostics = 'diagnostics',
}
const lspEvent = Annotation.define<LspAnnotation>()
export const lspSemanticTokensEvent = lspEvent.of(LspAnnotation.SemanticTokens)
export const lspFormatCodeEvent = lspEvent.of(LspAnnotation.FormatCode)
export const lspDiagnosticsEvent = lspEvent.of(LspAnnotation.Diagnostics)

View File

@ -9,17 +9,18 @@ import {
prevSnippetField, prevSnippetField,
startCompletion, startCompletion,
} from '@codemirror/autocomplete' } from '@codemirror/autocomplete'
import { Prec, Extension } from '@codemirror/state' import { syntaxTree } from '@codemirror/language'
import { EditorView, keymap, KeyBinding, ViewPlugin } from '@codemirror/view' import type { Extension } from '@codemirror/state'
import { Prec } from '@codemirror/state'
import type { EditorView, KeyBinding, ViewPlugin } from '@codemirror/view'
import { keymap } from '@codemirror/view'
import { import {
CompletionItemKind, CompletionItemKind,
CompletionTriggerKind, CompletionTriggerKind,
} from 'vscode-languageserver-protocol' } from 'vscode-languageserver-protocol'
import { LanguageServerPlugin } from './lsp' import type { LanguageServerPlugin } from './lsp'
import { offsetToPos } from './util' import { offsetToPos } from './util'
import { syntaxTree } from '@codemirror/language'
export const CompletionItemKindMap = Object.fromEntries( export const CompletionItemKindMap = Object.fromEntries(
Object.entries(CompletionItemKind).map(([key, value]) => [value, key]) Object.entries(CompletionItemKind).map(([key, value]) => [value, key])

View File

@ -1,7 +1,9 @@
import { Extension, Prec } from '@codemirror/state' import type { Extension } from '@codemirror/state'
import { EditorView, keymap, KeyBinding, ViewPlugin } from '@codemirror/view' import { Prec } from '@codemirror/state'
import type { EditorView, KeyBinding, ViewPlugin } from '@codemirror/view'
import { keymap } from '@codemirror/view'
import { LanguageServerPlugin } from './lsp' import type { LanguageServerPlugin } from './lsp'
export default function lspFormatExt( export default function lspFormatExt(
plugin: ViewPlugin<LanguageServerPlugin> plugin: ViewPlugin<LanguageServerPlugin>

View File

@ -1,12 +1,8 @@
import { Extension } from '@codemirror/state' import type { Extension } from '@codemirror/state'
import { import type { ViewPlugin } from '@codemirror/view'
hoverTooltip, import { EditorView, hoverTooltip, tooltips } from '@codemirror/view'
tooltips,
ViewPlugin,
EditorView,
} from '@codemirror/view'
import { LanguageServerPlugin } from './lsp' import type { LanguageServerPlugin } from './lsp'
import { offsetToPos } from './util' import { offsetToPos } from './util'
export default function lspHoverExt( export default function lspHoverExt(

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