Compare commits

...

5 Commits

Author SHA1 Message Date
7711bf768c Iterate over binary ops (instead of recursing) 2025-04-08 17:15:33 -05:00
83f74faaf7 fix nix (#6213)
Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: Adam Sunderland <adam@kittycad.io>
2025-04-08 19:06:47 +00:00
0bb5797377 Fix unclickable state while opening share link in browser (#6201)
* Fix unclickable state, don't show warning if query present

* Leave a note about need for a web test

* Fix browser share links by waiting for network connection

* Don't worry about engineConnection on home route
2025-04-08 13:10:49 -04:00
c3097aa334 fix missing extension (#6205)
* fix missing extension

* fix e2e

* better name
2025-04-08 15:41:48 +00:00
2cd0fcc9a7 #6157 Dispatch wheel event to camControls when hovering segment label (#6158)
dispatch wheel event to camControls when hovering segment label
2025-04-08 11:12:12 -04:00
14 changed files with 2260 additions and 339 deletions

View File

@ -38,7 +38,7 @@ test.describe('Point and click for boolean workflows', () => {
path.resolve( path.resolve(
__dirname, __dirname,
'../../', '../../',
'./rust/kcl-lib/e2e/executor/inputs/boolean-setup-with' './rust/kcl-lib/e2e/executor/inputs/boolean-setup-with-sketch-on-faces.kcl'
), ),
'utf-8' 'utf-8'
) )

View File

@ -612,3 +612,12 @@ profile001 = startProfileAt([-12.34, 12.34], sketch002)
const sketch002 = extrude(sketch002, length = ${[5, 5]} + 7)` const sketch002 = extrude(sketch002, length = ${[5, 5]} + 7)`
await expect(page.locator('.cm-content')).toHaveText(result2.regExp) await expect(page.locator('.cm-content')).toHaveText(result2.regExp)
}) })
test.fixme(
`Opening a share link in the web isn't blocked by the web warning banner`,
async () => {
// This test is not able to be run right now since we don't have a web-only setup for Playwright.
// @franknoirot can implement it when that testing infra is set up. It should be a test to cover the fix from
// modeling-app issue #6172.
}
)

View File

@ -19,9 +19,14 @@
(self: super: { (self: super: {
rustToolchain = super. rust-bin.stable.latest.default.override { rustToolchain = super. rust-bin.stable.latest.default.override {
targets = [ "wasm32-unknown-unknown" ]; targets = [ "wasm32-unknown-unknown" ];
extensions = [ "rustfmt" "llvm-tools-preview" ]; extensions = [ "rustfmt" "llvm-tools-preview" "rust-src" ];
}; };
}) })
(self: super: {
cargo-llvm-cov = super.cargo-llvm-cov.overrideAttrs(oa: {
doCheck = false; doInstallCheck = false;
});
})
]; ];
# Systems supported # Systems supported
@ -34,7 +39,7 @@
# Helper to provide system-specific attributes # Helper to provide system-specific attributes
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f { forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
pkgs = import nixpkgs { inherit overlays system; }; pkgs = import nixpkgs { inherit overlays system; config.allowBroken = true; };
}); });
in in
@ -62,7 +67,7 @@
electron electron
playwright-driver.browsers playwright-driver.browsers
]) ++ pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs; [ ]) ++ pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs; [
libiconv libiconv
darwin.apple_sdk.frameworks.Security darwin.apple_sdk.frameworks.Security
]); ]);

View File

@ -918,165 +918,193 @@ impl Node<MemberExpression> {
impl Node<BinaryExpression> { impl Node<BinaryExpression> {
#[async_recursion] #[async_recursion]
pub async fn get_result(&self, exec_state: &mut ExecState, ctx: &ExecutorContext) -> Result<KclValue, KclError> { pub async fn get_result(&self, exec_state: &mut ExecState, ctx: &ExecutorContext) -> Result<KclValue, KclError> {
let left_value = self.left.get_result(exec_state, ctx).await?; let mut partial = self.right.get_result(exec_state, ctx).await?;
let right_value = self.right.get_result(exec_state, ctx).await?; let mut next = &self.left;
let mut meta = left_value.metadata(); let source_range = self.into();
meta.extend(right_value.metadata()); // Don't recurse through a big chain of binary operations, iterate instead.
while let BinaryPart::BinaryExpression(next_binary_expr) = next {
// First check if we are doing string concatenation. let metadata = partial.metadata();
if self.operator == BinaryOperator::Add { partial = do_binary_op(
if let (KclValue::String { value: left, meta: _ }, KclValue::String { value: right, meta: _ }) = partial,
(&left_value, &right_value) next_binary_expr.right.get_result(exec_state, ctx).await?,
{ next_binary_expr.operator,
return Ok(KclValue::String { metadata,
value: format!("{}{}", left, right), source_range,
meta, exec_state,
}); ctx,
} )
.await?;
next = &next_binary_expr.left;
} }
// Then check if we have solids. let next_value = next.get_result(exec_state, ctx).await?;
if self.operator == BinaryOperator::Add || self.operator == BinaryOperator::Or { let mut meta = partial.metadata();
if let (KclValue::Solid { value: left }, KclValue::Solid { value: right }) = (&left_value, &right_value) { meta.extend(next_value.metadata());
let args = crate::std::Args::new(Default::default(), self.into(), ctx.clone(), None);
let result =
crate::std::csg::inner_union(vec![*left.clone(), *right.clone()], exec_state, args).await?;
return Ok(result.into());
}
} else if self.operator == BinaryOperator::Sub {
// Check if we have solids.
if let (KclValue::Solid { value: left }, KclValue::Solid { value: right }) = (&left_value, &right_value) {
let args = crate::std::Args::new(Default::default(), self.into(), ctx.clone(), None);
let result =
crate::std::csg::inner_subtract(vec![*left.clone()], vec![*right.clone()], exec_state, args)
.await?;
return Ok(result.into());
}
} else if self.operator == BinaryOperator::And {
// Check if we have solids.
if let (KclValue::Solid { value: left }, KclValue::Solid { value: right }) = (&left_value, &right_value) {
let args = crate::std::Args::new(Default::default(), self.into(), ctx.clone(), None);
let result =
crate::std::csg::inner_intersect(vec![*left.clone(), *right.clone()], exec_state, args).await?;
return Ok(result.into());
}
}
// Check if we are doing logical operations on booleans.
if self.operator == BinaryOperator::Or || self.operator == BinaryOperator::And {
let KclValue::Bool {
value: left_value,
meta: _,
} = left_value
else {
return Err(KclError::Semantic(KclErrorDetails {
message: format!(
"Cannot apply logical operator to non-boolean value: {}",
left_value.human_friendly_type()
),
source_ranges: vec![self.left.clone().into()],
}));
};
let KclValue::Bool {
value: right_value,
meta: _,
} = right_value
else {
return Err(KclError::Semantic(KclErrorDetails {
message: format!(
"Cannot apply logical operator to non-boolean value: {}",
right_value.human_friendly_type()
),
source_ranges: vec![self.right.clone().into()],
}));
};
let raw_value = match self.operator {
BinaryOperator::Or => left_value || right_value,
BinaryOperator::And => left_value && right_value,
_ => unreachable!(),
};
return Ok(KclValue::Bool { value: raw_value, meta });
}
let left = number_as_f64(&left_value, self.left.clone().into())?;
let right = number_as_f64(&right_value, self.right.clone().into())?;
let value = match self.operator {
BinaryOperator::Add => {
let (l, r, ty) = NumericType::combine_eq(left, right);
self.warn_on_unknown(&ty, "Adding", exec_state);
KclValue::Number { value: l + r, meta, ty }
}
BinaryOperator::Sub => {
let (l, r, ty) = NumericType::combine_eq(left, right);
self.warn_on_unknown(&ty, "Subtracting", exec_state);
KclValue::Number { value: l - r, meta, ty }
}
BinaryOperator::Mul => {
let (l, r, ty) = NumericType::combine_mul(left, right);
self.warn_on_unknown(&ty, "Multiplying", exec_state);
KclValue::Number { value: l * r, meta, ty }
}
BinaryOperator::Div => {
let (l, r, ty) = NumericType::combine_div(left, right);
self.warn_on_unknown(&ty, "Dividing", exec_state);
KclValue::Number { value: l / r, meta, ty }
}
BinaryOperator::Mod => {
let (l, r, ty) = NumericType::combine_div(left, right);
self.warn_on_unknown(&ty, "Modulo of", exec_state);
KclValue::Number { value: l % r, meta, ty }
}
BinaryOperator::Pow => KclValue::Number {
value: left.n.powf(right.n),
meta,
ty: NumericType::Unknown,
},
BinaryOperator::Neq => {
let (l, r, ty) = NumericType::combine_eq(left, right);
self.warn_on_unknown(&ty, "Comparing", exec_state);
KclValue::Bool { value: l != r, meta }
}
BinaryOperator::Gt => {
let (l, r, ty) = NumericType::combine_eq(left, right);
self.warn_on_unknown(&ty, "Comparing", exec_state);
KclValue::Bool { value: l > r, meta }
}
BinaryOperator::Gte => {
let (l, r, ty) = NumericType::combine_eq(left, right);
self.warn_on_unknown(&ty, "Comparing", exec_state);
KclValue::Bool { value: l >= r, meta }
}
BinaryOperator::Lt => {
let (l, r, ty) = NumericType::combine_eq(left, right);
self.warn_on_unknown(&ty, "Comparing", exec_state);
KclValue::Bool { value: l < r, meta }
}
BinaryOperator::Lte => {
let (l, r, ty) = NumericType::combine_eq(left, right);
self.warn_on_unknown(&ty, "Comparing", exec_state);
KclValue::Bool { value: l <= r, meta }
}
BinaryOperator::Eq => {
let (l, r, ty) = NumericType::combine_eq(left, right);
self.warn_on_unknown(&ty, "Comparing", exec_state);
KclValue::Bool { value: l == r, meta }
}
BinaryOperator::And | BinaryOperator::Or => unreachable!(),
};
let value = do_binary_op(partial, next_value, self.operator, meta, self.into(), exec_state, ctx).await?;
Ok(value) Ok(value)
} }
}
fn warn_on_unknown(&self, ty: &NumericType, verb: &str, exec_state: &mut ExecState) { fn warn_on_unknown(source_range: SourceRange, ty: &NumericType, verb: &str, exec_state: &mut ExecState) {
if *CHECK_NUMERIC_TYPES && ty == &NumericType::Unknown { if *CHECK_NUMERIC_TYPES && ty == &NumericType::Unknown {
// TODO suggest how to fix this // TODO suggest how to fix this
exec_state.warn(CompilationError::err( exec_state.warn(CompilationError::err(
self.as_source_range(), source_range,
format!("{} numbers which have unknown or incompatible units.", verb), format!("{} numbers which have unknown or incompatible units.", verb),
)); ));
}
}
async fn do_binary_op(
left_value: KclValue,
right_value: KclValue,
operator: BinaryOperator,
meta: Vec<Metadata>,
source_range: SourceRange,
exec_state: &mut ExecState,
ctx: &ExecutorContext,
) -> Result<KclValue, KclError> {
// First check if we are doing string concatenation.
if operator == BinaryOperator::Add {
if let (KclValue::String { value: left, meta: _ }, KclValue::String { value: right, meta: _ }) =
(&left_value, &right_value)
{
return Ok(KclValue::String {
value: format!("{}{}", left, right),
meta,
});
} }
} }
// Then check if we have solids.
if operator == BinaryOperator::Add || operator == BinaryOperator::Or {
if let (KclValue::Solid { value: left }, KclValue::Solid { value: right }) = (&left_value, &right_value) {
let args = crate::std::Args::new(Default::default(), source_range, ctx.clone(), None);
let result = crate::std::csg::inner_union(vec![*left.clone(), *right.clone()], exec_state, args).await?;
return Ok(result.into());
}
} else if operator == BinaryOperator::Sub {
// Check if we have solids.
if let (KclValue::Solid { value: left }, KclValue::Solid { value: right }) = (&left_value, &right_value) {
let args = crate::std::Args::new(Default::default(), source_range, ctx.clone(), None);
let result =
crate::std::csg::inner_subtract(vec![*left.clone()], vec![*right.clone()], exec_state, args).await?;
return Ok(result.into());
}
} else if operator == BinaryOperator::And {
// Check if we have solids.
if let (KclValue::Solid { value: left }, KclValue::Solid { value: right }) = (&left_value, &right_value) {
let args = crate::std::Args::new(Default::default(), source_range, ctx.clone(), None);
let result =
crate::std::csg::inner_intersect(vec![*left.clone(), *right.clone()], exec_state, args).await?;
return Ok(result.into());
}
}
// Check if we are doing logical operations on booleans.
if operator == BinaryOperator::Or || operator == BinaryOperator::And {
let KclValue::Bool {
value: left_value,
meta: _,
} = left_value
else {
return Err(KclError::Semantic(KclErrorDetails {
message: format!(
"Cannot apply logical operator to non-boolean value: {}",
left_value.human_friendly_type()
),
source_ranges: left_value.into(),
}));
};
let KclValue::Bool {
value: right_value,
meta: _,
} = right_value
else {
return Err(KclError::Semantic(KclErrorDetails {
message: format!(
"Cannot apply logical operator to non-boolean value: {}",
right_value.human_friendly_type()
),
source_ranges: right_value.into(),
}));
};
let raw_value = match operator {
BinaryOperator::Or => left_value || right_value,
BinaryOperator::And => left_value && right_value,
_ => unreachable!(),
};
return Ok(KclValue::Bool { value: raw_value, meta });
}
let left = number_as_f64(&left_value, (&left_value).into())?;
let right = number_as_f64(&right_value, (&left_value).into())?;
let value = match operator {
BinaryOperator::Add => {
let (l, r, ty) = NumericType::combine_eq(left, right);
warn_on_unknown(source_range, &ty, "Adding", exec_state);
KclValue::Number { value: l + r, meta, ty }
}
BinaryOperator::Sub => {
let (l, r, ty) = NumericType::combine_eq(left, right);
warn_on_unknown(source_range, &ty, "Subtracting", exec_state);
KclValue::Number { value: l - r, meta, ty }
}
BinaryOperator::Mul => {
let (l, r, ty) = NumericType::combine_mul(left, right);
warn_on_unknown(source_range, &ty, "Multiplying", exec_state);
KclValue::Number { value: l * r, meta, ty }
}
BinaryOperator::Div => {
let (l, r, ty) = NumericType::combine_div(left, right);
warn_on_unknown(source_range, &ty, "Dividing", exec_state);
KclValue::Number { value: l / r, meta, ty }
}
BinaryOperator::Mod => {
let (l, r, ty) = NumericType::combine_div(left, right);
warn_on_unknown(source_range, &ty, "Modulo of", exec_state);
KclValue::Number { value: l % r, meta, ty }
}
BinaryOperator::Pow => KclValue::Number {
value: left.n.powf(right.n),
meta,
ty: NumericType::Unknown,
},
BinaryOperator::Neq => {
let (l, r, ty) = NumericType::combine_eq(left, right);
warn_on_unknown(source_range, &ty, "Comparing", exec_state);
KclValue::Bool { value: l != r, meta }
}
BinaryOperator::Gt => {
let (l, r, ty) = NumericType::combine_eq(left, right);
warn_on_unknown(source_range, &ty, "Comparing", exec_state);
KclValue::Bool { value: l > r, meta }
}
BinaryOperator::Gte => {
let (l, r, ty) = NumericType::combine_eq(left, right);
warn_on_unknown(source_range, &ty, "Comparing", exec_state);
KclValue::Bool { value: l >= r, meta }
}
BinaryOperator::Lt => {
let (l, r, ty) = NumericType::combine_eq(left, right);
warn_on_unknown(source_range, &ty, "Comparing", exec_state);
KclValue::Bool { value: l < r, meta }
}
BinaryOperator::Lte => {
let (l, r, ty) = NumericType::combine_eq(left, right);
warn_on_unknown(source_range, &ty, "Comparing", exec_state);
KclValue::Bool { value: l <= r, meta }
}
BinaryOperator::Eq => {
let (l, r, ty) = NumericType::combine_eq(left, right);
warn_on_unknown(source_range, &ty, "Comparing", exec_state);
KclValue::Bool { value: l == r, meta }
}
BinaryOperator::And | BinaryOperator::Or => unreachable!(),
};
Ok(value)
} }
impl Node<UnaryExpression> { impl Node<UnaryExpression> {

View File

@ -2832,7 +2832,7 @@ impl BinaryExpression {
} }
} }
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema, FromStr, Display)] #[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, ts_rs::TS, JsonSchema, FromStr, Display)]
#[ts(export)] #[ts(export)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
#[display(style = "snake_case")] #[display(style = "snake_case")]

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,6 @@ fn f(i) {
return i * 2 return i * 2
} }
x = f(0) + f(1) + f(2) + f(3) + f(4) + f(5) + f(6) + f(7) + f(8) + f(9) + f(10) + f(11) + f(12) + f(13) + f(14) + f(15) + f(16) + f(17) + f(18) + f(19) + f(20) + f(21) + f(22) + f(23) + f(24) + f(25) + f(26) + f(27) + f(28) + f(29) + f(30) + f(31) + f(32) + f(33) + f(34) + f(35) + f(36) + f(37) + f(38) + f(39) + f(40) + f(41) + f(42) + f(43) + f(44) + f(45) + f(46) + f(47) + f(48) + f(49) + f(50) + f(51) + f(52) + f(53) + f(54) + f(55) + f(56) + f(57) + f(58) + f(59) + f(60) + f(61) + f(62) + f(63) + f(64) + f(65) + f(66) + f(67) + f(68) + f(69) + f(70) x = f(0) + f(1) + f(2) + f(3) + f(4) + f(5) + f(6) + f(7) + f(8) + f(9) + f(10) + f(11) + f(12) + f(13) + f(14) + f(15) + f(16) + f(17) + f(18) + f(19) + f(20) + f(21) + f(22) + f(23) + f(24) + f(25) + f(26) + f(27) + f(28) + f(29) + f(30) + f(31) + f(32) + f(33) + f(34) + f(35) + f(36) + f(37) + f(38) + f(39) + f(40) + f(41) + f(42) + f(43) + f(44) + f(45) + f(46) + f(47) + f(48) + f(49) + f(50) + f(51) + f(52) + f(53) + f(54) + f(55) + f(56) + f(57) + f(58) + f(59) + f(60) + f(61) + f(62) + f(63) + f(64) + f(65) + f(66) + f(67) + f(68) + f(69) + f(70) + f(71) + f(72) + f(73) + f(74) + f(75) + f(76) + f(77) + f(78) + f(79) + f(80) + f(81) + f(82) + f(83) + f(84) + f(85) + f(86) + f(87) + f(88) + f(89) + f(90) + f(91) + f(92) + f(93) + f(94) + f(95) + f(96) + f(97) + f(98) + f(99) + f(100)
assertEqual(x, 4970, 0.1, "Big sum") assertEqual(x, 10100, 0.1, "Big sum")

View File

@ -1278,6 +1278,546 @@ description: Operations executed add_lots.kcl
}, },
"sourceRange": [] "sourceRange": []
}, },
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{
"type": "GroupEnd"
},
{
"type": "GroupBegin",
"group": {
"type": "FunctionCall",
"name": "f",
"functionSourceRange": [
4,
26,
0
],
"unlabeledArg": null,
"labeledArgs": {}
},
"sourceRange": []
},
{ {
"type": "GroupEnd" "type": "GroupEnd"
} }

View File

@ -8,7 +8,7 @@ description: Variables in memory after executing add_lots.kcl
}, },
"x": { "x": {
"type": "Number", "type": "Number",
"value": 4970.0, "value": 10100.0,
"ty": { "ty": {
"type": "Default", "type": "Default",
"len": { "len": {

View File

@ -6,6 +6,6 @@ fn f(i) {
return i * 2 return i * 2
} }
x = f(0) + f(1) + f(2) + f(3) + f(4) + f(5) + f(6) + f(7) + f(8) + f(9) + f(10) + f(11) + f(12) + f(13) + f(14) + f(15) + f(16) + f(17) + f(18) + f(19) + f(20) + f(21) + f(22) + f(23) + f(24) + f(25) + f(26) + f(27) + f(28) + f(29) + f(30) + f(31) + f(32) + f(33) + f(34) + f(35) + f(36) + f(37) + f(38) + f(39) + f(40) + f(41) + f(42) + f(43) + f(44) + f(45) + f(46) + f(47) + f(48) + f(49) + f(50) + f(51) + f(52) + f(53) + f(54) + f(55) + f(56) + f(57) + f(58) + f(59) + f(60) + f(61) + f(62) + f(63) + f(64) + f(65) + f(66) + f(67) + f(68) + f(69) + f(70) x = f(0) + f(1) + f(2) + f(3) + f(4) + f(5) + f(6) + f(7) + f(8) + f(9) + f(10) + f(11) + f(12) + f(13) + f(14) + f(15) + f(16) + f(17) + f(18) + f(19) + f(20) + f(21) + f(22) + f(23) + f(24) + f(25) + f(26) + f(27) + f(28) + f(29) + f(30) + f(31) + f(32) + f(33) + f(34) + f(35) + f(36) + f(37) + f(38) + f(39) + f(40) + f(41) + f(42) + f(43) + f(44) + f(45) + f(46) + f(47) + f(48) + f(49) + f(50) + f(51) + f(52) + f(53) + f(54) + f(55) + f(56) + f(57) + f(58) + f(59) + f(60) + f(61) + f(62) + f(63) + f(64) + f(65) + f(66) + f(67) + f(68) + f(69) + f(70) + f(71) + f(72) + f(73) + f(74) + f(75) + f(76) + f(77) + f(78) + f(79) + f(80) + f(81) + f(82) + f(83) + f(84) + f(85) + f(86) + f(87) + f(88) + f(89) + f(90) + f(91) + f(92) + f(93) + f(94) + f(95) + f(96) + f(97) + f(98) + f(99) + f(100)
assertEqual(x, 4970, 0.1, "Big sum") assertEqual(x, 10100, 0.1, "Big sum")

View File

@ -1705,6 +1705,10 @@ function createLengthIndicator({
lengthIndicatorText.innerText = roundOff(length).toString() lengthIndicatorText.innerText = roundOff(length).toString()
const lengthIndicatorWrapper = document.createElement('div') const lengthIndicatorWrapper = document.createElement('div')
lengthIndicatorWrapper.addEventListener('wheel', (e) => {
// dispatch to cameraControls, without this mouse wheel wouldn't work when hovering this segment label
sceneInfra.camControls.onMouseWheel(e)
})
// Double click workflow // Double click workflow
lengthIndicatorWrapper.ondblclick = () => { lengthIndicatorWrapper.ondblclick = () => {
const selection = lengthIndicatorGroup.parent?.userData.selection const selection = lengthIndicatorGroup.parent?.userData.selection

View File

@ -2,12 +2,16 @@ import { Dialog } from '@headlessui/react'
import { useState } from 'react' import { useState } from 'react'
import { ActionButton } from '@src/components/ActionButton' import { ActionButton } from '@src/components/ActionButton'
import { CREATE_FILE_URL_PARAM } from '@src/lib/constants'
import { useSettings } from '@src/machines/appMachine' import { useSettings } from '@src/machines/appMachine'
import { useSearchParams } from 'react-router-dom'
const DownloadAppBanner = () => { const DownloadAppBanner = () => {
const [searchParams] = useSearchParams()
const settings = useSettings() const settings = useSettings()
const [isBannerDismissed, setIsBannerDismissed] = useState( const [isBannerDismissed, setIsBannerDismissed] = useState(
settings.app.dismissWebBanner.current searchParams.has(CREATE_FILE_URL_PARAM) ||
settings.app.dismissWebBanner.current
) )
return ( return (
@ -43,7 +47,7 @@ const DownloadAppBanner = () => {
<ActionButton <ActionButton
Element="externalLink" Element="externalLink"
to="https://zoo.dev/modeling-app/download" to="https://zoo.dev/modeling-app/download"
className="group text-warn-10 dark:!text-warn-10 pr-1 border-warn-70 hover:border-warn-80 dark:!border-warn-70 dark:hover:!border-warn-80 bg-warn-70 group-hover:bg-warn-80 dark:bg-warn-70 dark:group-hover:bg-warn-80" className="group !text-warn-10 pr-1 border-warn-70 hover:border-warn-80 dark:!border-warn-70 dark:hover:!border-warn-80 bg-warn-70 group-hover:bg-warn-80 dark:bg-warn-70 dark:group-hover:bg-warn-80"
iconEnd={{ iconEnd={{
icon: 'arrowRight', icon: 'arrowRight',
iconClassName: 'text-warn-10 dark:text-warn-10', iconClassName: 'text-warn-10 dark:text-warn-10',

View File

@ -1,11 +1,14 @@
import { useEffect } from 'react' import { useEffect } from 'react'
import { useSearchParams } from 'react-router-dom' import { useLocation, useSearchParams } from 'react-router-dom'
import { useNetworkContext } from '@src/hooks/useNetworkContext'
import { EngineConnectionStateType } from '@src/lang/std/engineConnection'
import { base64ToString } from '@src/lib/base64' import { base64ToString } from '@src/lib/base64'
import type { ProjectsCommandSchema } from '@src/lib/commandBarConfigs/projectsCommandConfig' import type { ProjectsCommandSchema } from '@src/lib/commandBarConfigs/projectsCommandConfig'
import { CREATE_FILE_URL_PARAM, DEFAULT_FILE_NAME } from '@src/lib/constants' import { CREATE_FILE_URL_PARAM, DEFAULT_FILE_NAME } from '@src/lib/constants'
import { isDesktop } from '@src/lib/isDesktop' import { isDesktop } from '@src/lib/isDesktop'
import type { FileLinkParams } from '@src/lib/links' import type { FileLinkParams } from '@src/lib/links'
import { PATHS } from '@src/lib/paths'
import { useSettings } from '@src/machines/appMachine' import { useSettings } from '@src/machines/appMachine'
// For initializing the command arguments, we actually want `method` to be undefined // For initializing the command arguments, we actually want `method` to be undefined
@ -26,13 +29,21 @@ export type CreateFileSchemaMethodOptional = Omit<
export function useCreateFileLinkQuery( export function useCreateFileLinkQuery(
callback: (args: CreateFileSchemaMethodOptional) => void callback: (args: CreateFileSchemaMethodOptional) => void
) { ) {
const { immediateState } = useNetworkContext()
const { pathname } = useLocation()
const [searchParams] = useSearchParams() const [searchParams] = useSearchParams()
const settings = useSettings() const settings = useSettings()
useEffect(() => { useEffect(() => {
const isHome = pathname === PATHS.HOME
const createFileParam = searchParams.has(CREATE_FILE_URL_PARAM) const createFileParam = searchParams.has(CREATE_FILE_URL_PARAM)
if (createFileParam) { if (
createFileParam &&
(immediateState.type ===
EngineConnectionStateType.ConnectionEstablished ||
isHome)
) {
const params: FileLinkParams = { const params: FileLinkParams = {
code: base64ToString( code: base64ToString(
decodeURIComponent(searchParams.get('code') ?? '') decodeURIComponent(searchParams.get('code') ?? '')
@ -54,5 +65,5 @@ export function useCreateFileLinkQuery(
callback(argDefaultValues) callback(argDefaultValues)
} }
}, [searchParams]) }, [searchParams, immediateState])
} }