Compare commits

..

4 Commits

Author SHA1 Message Date
3972431cb4 Cut release v0.13.0 (#1177) 2023-12-05 10:54:47 -05:00
884545fcde Bump tailwindcss from 3.3.5 to 3.3.6 (#1175)
Bumps [tailwindcss](https://github.com/tailwindlabs/tailwindcss) from 3.3.5 to 3.3.6.
- [Release notes](https://github.com/tailwindlabs/tailwindcss/releases)
- [Changelog](https://github.com/tailwindlabs/tailwindcss/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tailwindlabs/tailwindcss/compare/v3.3.5...v3.3.6)

---
updated-dependencies:
- dependency-name: tailwindcss
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-05 05:05:29 -05:00
6deb242eb5 update e2e tests after grid update (#1171)
* update default plane size after grid update

* use similar scale

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)

* fix test numbers

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-05 14:59:50 +11:00
77fa9af71e expand lsp test (#1167) 2023-12-05 06:34:23 +11:00
11 changed files with 88 additions and 68 deletions

View File

@ -4,8 +4,6 @@ import { EngineCommand } from '../../src/lang/std/engineConnection'
import { v4 as uuidv4 } from 'uuid'
import { getUtils } from './test-utils'
import waitOn from 'wait-on'
import { Models } from '@kittycad/lib'
import fsp from 'fs/promises'
/*
debug helper: unfortunately we do rely on exact coord mouse clicks in a few places
@ -86,26 +84,26 @@ test('Basic sketch', async ({ page }) => {
await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 10)
const startAt = '[10.97, -14.79]'
const tenish = '11.07'
const startAt = '[18.26, -24.63]'
const num = '18.43'
await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %)
|> line([${tenish}, 0], %)`)
|> line([${num}, 0], %)`)
await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20)
await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %)
|> line([${tenish}, 0], %)
|> line([0, ${tenish}], %)`)
|> line([${num}, 0], %)
|> line([0, ${num}], %)`)
await page.mouse.click(startXPx, 500 - PUR * 20)
await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %)
|> line([${tenish}, 0], %)
|> line([0, ${tenish}], %)
|> line([-22.04, 0], %)`)
|> line([${num}, 0], %)
|> line([0, ${num}], %)
|> line([-36.69, 0], %)`)
// deselect line tool
await u.doAndWaitForCmd(
@ -133,8 +131,8 @@ test('Basic sketch', async ({ page }) => {
await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %)
|> line({ to: [${tenish}, 0], tag: 'seg01' }, %)
|> line([0, ${tenish}], %)
|> line({ to: [${num}, 0], tag: 'seg01' }, %)
|> line([0, ${num}], %)
|> angledLine([180, segLen('seg01', %)], %)`)
})
@ -183,6 +181,26 @@ test('if you write invalid kcl you get inlined errors', async ({ page }) => {
// wait for .cm-lint-marker-error not to be visible
await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible()
// let's check we get an error when defining the same variable twice
await page.getByText('const bottomAng = 25').click()
await page.keyboard.press('Enter')
await page.keyboard.type("// Let's define the same thing twice")
await page.keyboard.press('Enter')
await page.keyboard.type('const topAng = 42')
await expect(page.locator('.cm-lint-marker-error')).toBeVisible()
await expect(page.locator('.cm-lintRange.cm-lintRange-error')).toBeVisible()
await page.locator('.cm-lintRange.cm-lintRange-error').hover()
await expect(page.locator('.cm-diagnosticText')).toBeVisible()
await expect(page.getByText('Cannot redefine topAng')).toBeVisible()
const secondTopAng = await page.getByText('topAng').first()
await secondTopAng?.dblclick()
await page.keyboard.type('otherAng')
await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible()
})
test('executes on load', async ({ page, context }) => {
@ -488,27 +506,27 @@ test('Selections work on fresh and edited sketch', async ({ page }) => {
await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 10)
const startAt = '[10.97, -14.79]'
const tenish = '11.07'
const twentyish = '22.04'
const startAt = '[18.26, -24.63]'
const num = '18.43'
const num2 = '36.69'
await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %)
|> line([${tenish}, 0], %)`)
|> line([${num}, 0], %)`)
await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20)
await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %)
|> line([${tenish}, 0], %)
|> line([0, ${tenish}], %)`)
|> line([${num}, 0], %)
|> line([0, ${num}], %)`)
await page.mouse.click(startXPx, 500 - PUR * 20)
await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %)
|> line([${tenish}, 0], %)
|> line([0, ${tenish}], %)
|> line([-${twentyish}, 0], %)`)
|> line([${num}, 0], %)
|> line([0, ${num}], %)
|> line([-${num2}, 0], %)`)
// deselect line tool
await u.doAndWaitForCmd(
@ -561,7 +579,7 @@ test('Selections work on fresh and edited sketch', async ({ page }) => {
// check the same selection again by putting cursor in code first then selecting axis
await u.doAndWaitForCmd(
() => page.getByText(` |> line([-${twentyish}, 0], %)`).click(),
() => page.getByText(` |> line([-${num2}, 0], %)`).click(),
'select_clear',
false
)
@ -576,7 +594,7 @@ test('Selections work on fresh and edited sketch', async ({ page }) => {
// select segment in editor than another segment in scene and check there are two cursors
await u.doAndWaitForCmd(
() => page.getByText(` |> line([-${twentyish}, 0], %)`).click(),
() => page.getByText(` |> line([-${num2}, 0], %)`).click(),
'select_clear',
false
)

View File

@ -45,7 +45,7 @@ test('change camera, show planes', async ({ page, context }) => {
type: 'default_camera_look_at',
center: { x: 0, y: 0, z: 0 },
up: { x: 0, y: 0, z: 1 },
vantage: { x: 0, y: 50, z: 50 },
vantage: { x: 0, y: 85, z: 85 },
},
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View File

@ -1,6 +1,6 @@
{
"name": "untitled-app",
"version": "0.12.0",
"version": "0.13.0",
"private": true,
"dependencies": {
"@codemirror/autocomplete": "^6.10.2",
@ -134,7 +134,7 @@
"postcss": "^8.4.31",
"prettier": "^2.8.0",
"setimmediate": "^1.0.5",
"tailwindcss": "^3.3.5",
"tailwindcss": "^3.3.6",
"vite": "^4.5.0",
"vite-plugin-eslint": "^1.8.1",
"vite-tsconfig-paths": "^4.2.1",

View File

@ -8,7 +8,7 @@
},
"package": {
"productName": "kittycad-modeling",
"version": "0.12.0"
"version": "0.13.0"
},
"tauri": {
"allowlist": {

View File

@ -1216,7 +1216,7 @@ export class EngineCommandManager {
type: 'modeling_cmd_req',
cmd: {
type: 'make_plane',
size: 60,
size: 100,
origin: { x: 0, y: 0, z: 0 },
x_axis,
y_axis,

View File

@ -1,24 +1,36 @@
use crate::{ExecutionError, NumericValue, Value};
use crate::{ExecutionError, Value};
/// Types that can be written to or read from KCEP program memory,
/// but require multiple values to store.
/// They get laid out into multiple consecutive memory addresses.
pub trait Composite<const SIZE: usize>: Sized {
pub trait Composite: Sized {
/// How many memory addresses are required to store this value?
const SIZE: usize;
/// Store the value in memory.
fn into_parts(self) -> [Value; SIZE];
fn into_parts(self) -> Vec<Value>;
/// Read the value from memory.
fn from_parts(values: [Value; SIZE]) -> Result<Self, ExecutionError>;
fn from_parts(values: Vec<Value>) -> Result<Self, ExecutionError>;
}
impl Composite<3> for kittycad::types::Point3D {
fn into_parts(self) -> [Value; 3] {
[self.x, self.y, self.z]
.map(NumericValue::Float)
.map(Value::NumericValue)
impl Composite for kittycad::types::Point3D {
fn into_parts(self) -> Vec<Value> {
let points = [self.x, self.y, self.z];
points
.into_iter()
.map(|x| Value::NumericValue(crate::NumericValue::Float(x)))
.collect()
}
fn from_parts(values: [Value; 3]) -> Result<Self, ExecutionError> {
let [x, y, z] = values;
const SIZE: usize = 3;
fn from_parts(values: Vec<Value>) -> Result<Self, ExecutionError> {
let n = values.len();
let Ok([x, y, z]): Result<[Value; 3], _> = values.try_into() else {
return Err(ExecutionError::MemoryWrongSize {
actual: n,
expected: Self::SIZE,
});
};
let x = x.try_into()?;
let y = y.try_into()?;
let z = z.try_into()?;

View File

@ -6,10 +6,9 @@
//! You can think of it as a domain-specific language for making KittyCAD API calls and using
//! the results to make other API calls.
use std::{collections::HashMap, fmt};
use composite::Composite;
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, fmt};
mod composite;
#[cfg(test)]
@ -49,7 +48,7 @@ impl Memory {
/// Store a composite value (i.e. a value which takes up multiple addresses in memory).
/// Store its parts in consecutive memory addresses starting at `start`.
pub fn set_composite<T: Composite<{ N }>, const N: usize>(&mut self, composite_value: T, start: Address) {
pub fn set_composite<T: Composite>(&mut self, composite_value: T, start: Address) {
let parts = composite_value.into_parts().into_iter();
for (value, addr) in parts.zip(start.0..) {
self.0.insert(addr, value);
@ -58,14 +57,17 @@ impl Memory {
/// Get a composite value (i.e. a value which takes up multiple addresses in memory).
/// Its parts are stored in consecutive memory addresses starting at `start`.
pub fn get_composite<T: Composite<{ N }>, const N: usize>(&self, start: Address) -> Result<T, ExecutionError> {
let addrs: [Address; N] = core::array::from_fn(|i| Address(i + start.0));
let values: [Value; N] = arr_res_to_res_array(addrs.map(|addr| {
self.get(&addr)
.map(|x| x.to_owned())
.ok_or(ExecutionError::MemoryEmpty { addr })
}))?;
pub fn get_composite<T: Composite>(&self, start: Address) -> Result<T, ExecutionError> {
let addrs = start.0..start.0 + T::SIZE;
let values: Vec<Value> = addrs
.into_iter()
.map(|a| {
let addr = Address(a);
self.get(&addr)
.map(|x| x.to_owned())
.ok_or(ExecutionError::MemoryEmpty { addr })
})
.collect::<Result<_, _>>()?;
T::from_parts(values)
}
}
@ -271,18 +273,6 @@ pub enum ExecutionError {
CannotApplyOperation { op: Operation, operands: Vec<Value> },
#[error("Tried to read a '{expected}' from KCEP program memory, found an '{actual}' instead")]
MemoryWrongType { expected: &'static str, actual: String },
}
/// Take an array of result and return a result of array.
/// If all members of the array are Ok(T), returns Ok with an array of the T values.
/// If any member of the array was Err(E), return Err with the first E value.
fn arr_res_to_res_array<T, E, const N: usize>(arr: [Result<T, E>; N]) -> Result<[T; N], E> {
let mut out = core::array::from_fn(|_| None);
for (i, res) in arr.into_iter().enumerate() {
out[i] = match res {
Ok(x) => Some(x),
Err(e) => return Err(e),
};
}
Ok(out.map(|opt| opt.unwrap()))
#[error("Wrong size of memory trying to read value from KCEP program memory: got {actual} but wanted {expected}")]
MemoryWrongSize { expected: usize, actual: usize },
}

View File

@ -7698,10 +7698,10 @@ swr@^2.2.2:
client-only "^0.0.1"
use-sync-external-store "^1.2.0"
tailwindcss@^3.3.5:
version "3.3.5"
resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.3.5.tgz#22a59e2fbe0ecb6660809d9cc5f3976b077be3b8"
integrity sha512-5SEZU4J7pxZgSkv7FP1zY8i2TIAOooNZ1e/OGtxIEv6GltpoiXUqWvLy89+a10qYTB1N5Ifkuw9lqQkN9sscvA==
tailwindcss@^3.3.6:
version "3.3.6"
resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.3.6.tgz#4dd7986bf4902ad385d90d45fd4b2fa5fab26d5f"
integrity sha512-AKjF7qbbLvLaPieoKeTjG1+FyNZT6KaJMJPFeQyLfIp7l82ggH1fbHJSsYIvnbTFQOlkh+gBYpyby5GT1LIdLw==
dependencies:
"@alloc/quick-lru" "^5.2.0"
arg "^5.0.2"