From 0bdc50c78f22c773266e7f571c1fbb39e54e5726 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Sat, 29 Mar 2025 19:26:20 -0700 Subject: [PATCH] bump kcl-lib and friends (#6063) * bump kcl-lib and friends Signed-off-by: Jess Frazelle * expose Signed-off-by: Jess Frazelle * relevant files Signed-off-by: Jess Frazelle * udpates Signed-off-by: Jess Frazelle * fixes Signed-off-by: Jess Frazelle * updates Signed-off-by: Jess Frazelle --------- Signed-off-by: Jess Frazelle --- rust/Cargo.lock | 24 ++++++------- rust/Cargo.toml | 2 +- rust/kcl-bumper/Cargo.toml | 2 +- rust/kcl-derive-docs/Cargo.toml | 2 +- rust/kcl-directory-test-macro/Cargo.toml | 2 +- rust/kcl-language-server-release/Cargo.toml | 2 +- rust/kcl-language-server/Cargo.toml | 2 +- rust/kcl-lib/Cargo.toml | 4 +-- rust/kcl-lib/src/coredump/mod.rs | 4 +-- rust/kcl-lib/src/lib.rs | 2 +- rust/kcl-lib/src/lsp/kcl/mod.rs | 2 +- rust/kcl-lib/src/simulation_tests.rs | 2 ++ rust/kcl-lib/src/unparser.rs | 37 +++++++++++++++++++-- rust/kcl-python-bindings/Cargo.toml | 2 +- rust/kcl-test-server/Cargo.toml | 2 +- rust/kcl-to-core/Cargo.toml | 2 +- rust/kcl-wasm-lib/Cargo.toml | 2 +- 17 files changed, 64 insertions(+), 31 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index ba2521209..d3c912e7b 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1780,7 +1780,7 @@ dependencies = [ [[package]] name = "kcl-bumper" -version = "0.1.55" +version = "0.1.56" dependencies = [ "anyhow", "clap", @@ -1791,7 +1791,7 @@ dependencies = [ [[package]] name = "kcl-derive-docs" -version = "0.1.55" +version = "0.1.56" dependencies = [ "Inflector", "anyhow", @@ -1810,7 +1810,7 @@ dependencies = [ [[package]] name = "kcl-directory-test-macro" -version = "0.1.55" +version = "0.1.56" dependencies = [ "proc-macro2", "quote", @@ -1819,7 +1819,7 @@ dependencies = [ [[package]] name = "kcl-language-server" -version = "0.2.55" +version = "0.2.56" dependencies = [ "anyhow", "clap", @@ -1840,7 +1840,7 @@ dependencies = [ [[package]] name = "kcl-language-server-release" -version = "0.1.55" +version = "0.1.56" dependencies = [ "anyhow", "clap", @@ -1860,7 +1860,7 @@ dependencies = [ [[package]] name = "kcl-lib" -version = "0.2.55" +version = "0.2.56" dependencies = [ "anyhow", "approx 0.5.1", @@ -1928,7 +1928,7 @@ dependencies = [ [[package]] name = "kcl-python-bindings" -version = "0.3.55" +version = "0.3.56" dependencies = [ "anyhow", "kcl-lib", @@ -1943,7 +1943,7 @@ dependencies = [ [[package]] name = "kcl-test-server" -version = "0.1.55" +version = "0.1.56" dependencies = [ "anyhow", "hyper 0.14.32", @@ -1956,7 +1956,7 @@ dependencies = [ [[package]] name = "kcl-to-core" -version = "0.1.55" +version = "0.1.56" dependencies = [ "anyhow", "async-trait", @@ -1970,7 +1970,7 @@ dependencies = [ [[package]] name = "kcl-wasm-lib" -version = "0.1.55" +version = "0.1.56" dependencies = [ "bson", "console_error_panic_hook", @@ -1996,9 +1996,9 @@ dependencies = [ [[package]] name = "kittycad" -version = "0.3.33" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f6f65645cc07a8f43c34584e4979bf4da16c047cce50c4715fa9381227574d5" +checksum = "0a345fd2a4cb16205f32bd1aa41715045830c59d78c59927fca6580e2a651ac9" dependencies = [ "anyhow", "async-trait", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 3de4d4ebb..a2909ba41 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -35,7 +35,7 @@ clap = { version = "4.5.31", features = ["derive"] } dashmap = { version = "6.1.0" } http = "1" indexmap = "2.7.0" -kittycad = { version = "0.3.33", default-features = false, features = ["js", "requests"] } +kittycad = { version = "0.3.36", default-features = false, features = ["js", "requests"] } kittycad-modeling-cmds = { version = "0.2.107", features = ["ts-rs", "websocket"] } lazy_static = "1.5.0" miette = "7.5.0" diff --git a/rust/kcl-bumper/Cargo.toml b/rust/kcl-bumper/Cargo.toml index 9476ce192..9aeae2585 100644 --- a/rust/kcl-bumper/Cargo.toml +++ b/rust/kcl-bumper/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-bumper" -version = "0.1.55" +version = "0.1.56" edition = "2021" repository = "https://github.com/KittyCAD/modeling-api" rust-version = "1.76" diff --git a/rust/kcl-derive-docs/Cargo.toml b/rust/kcl-derive-docs/Cargo.toml index 66e139449..eddd97ecf 100644 --- a/rust/kcl-derive-docs/Cargo.toml +++ b/rust/kcl-derive-docs/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-derive-docs" description = "A tool for generating documentation from Rust derive macros" -version = "0.1.55" +version = "0.1.56" edition = "2021" license = "MIT" repository = "https://github.com/KittyCAD/modeling-app" diff --git a/rust/kcl-directory-test-macro/Cargo.toml b/rust/kcl-directory-test-macro/Cargo.toml index 64a2aba41..df302b97f 100644 --- a/rust/kcl-directory-test-macro/Cargo.toml +++ b/rust/kcl-directory-test-macro/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-directory-test-macro" description = "A tool for generating tests from a directory of kcl files" -version = "0.1.55" +version = "0.1.56" edition = "2021" license = "MIT" repository = "https://github.com/KittyCAD/modeling-app" diff --git a/rust/kcl-language-server-release/Cargo.toml b/rust/kcl-language-server-release/Cargo.toml index e48fe3baa..e21f4d468 100644 --- a/rust/kcl-language-server-release/Cargo.toml +++ b/rust/kcl-language-server-release/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kcl-language-server-release" -version = "0.1.55" +version = "0.1.56" edition = "2021" authors = ["KittyCAD Inc "] publish = false diff --git a/rust/kcl-language-server/Cargo.toml b/rust/kcl-language-server/Cargo.toml index cd779f078..2a8320b7d 100644 --- a/rust/kcl-language-server/Cargo.toml +++ b/rust/kcl-language-server/Cargo.toml @@ -2,7 +2,7 @@ name = "kcl-language-server" description = "A language server for KCL." authors = ["KittyCAD Inc "] -version = "0.2.55" +version = "0.2.56" edition = "2021" license = "MIT" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/rust/kcl-lib/Cargo.toml b/rust/kcl-lib/Cargo.toml index 795c90cd8..31d1e326f 100644 --- a/rust/kcl-lib/Cargo.toml +++ b/rust/kcl-lib/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-lib" description = "KittyCAD Language implementation and tools" -version = "0.2.55" +version = "0.2.56" edition = "2021" license = "MIT" repository = "https://github.com/KittyCAD/modeling-app" @@ -104,7 +104,7 @@ tower-lsp = { workspace = true, features = ["proposed", "default"] } [features] default = ["engine"] -cli = ["dep:clap"] +cli = ["dep:clap", "kittycad/clap"] dhat-heap = ["dep:dhat"] # For the lsp server, when run with stdout for rpc we want to disable println. # This is used for editor extensions that use the lsp server. diff --git a/rust/kcl-lib/src/coredump/mod.rs b/rust/kcl-lib/src/coredump/mod.rs index 3057e3e40..df217a651 100644 --- a/rust/kcl-lib/src/coredump/mod.rs +++ b/rust/kcl-lib/src/coredump/mod.rs @@ -53,7 +53,7 @@ pub trait CoreDump: Clone { .meta() .create_debug_uploads(vec![kittycad::types::multipart::Attachment { name: "".to_string(), - filename: Some(format!(r#"modeling-app/coredump-{coredump_id}-screenshot.png"#)), + filepath: Some(format!(r#"modeling-app/coredump-{coredump_id}-screenshot.png"#).into()), content_type: Some("image/png".to_string()), data, }]) @@ -101,7 +101,7 @@ pub trait CoreDump: Clone { .meta() .create_debug_uploads(vec![kittycad::types::multipart::Attachment { name: "".to_string(), - filename: Some(format!(r#"modeling-app/coredump-{}.json"#, coredump_id)), + filepath: Some(format!(r#"modeling-app/coredump-{}.json"#, coredump_id).into()), content_type: Some("application/json".to_string()), data, }]) diff --git a/rust/kcl-lib/src/lib.rs b/rust/kcl-lib/src/lib.rs index 028ef606f..f8d2c31a8 100644 --- a/rust/kcl-lib/src/lib.rs +++ b/rust/kcl-lib/src/lib.rs @@ -97,7 +97,7 @@ pub use parsing::ast::{modify::modify_ast_for_sketch, types::FormatOptions}; pub use settings::types::{project::ProjectConfiguration, Configuration, UnitLength}; pub use source_range::SourceRange; #[cfg(not(target_arch = "wasm32"))] -pub use unparser::recast_dir; +pub use unparser::{recast_dir, walk_dir}; // Rather than make executor public and make lots of it pub(crate), just re-export into a new module. // Ideally we wouldn't export these things at all, they should only be used for testing. diff --git a/rust/kcl-lib/src/lsp/kcl/mod.rs b/rust/kcl-lib/src/lsp/kcl/mod.rs index b4bf045eb..c3d77f822 100644 --- a/rust/kcl-lib/src/lsp/kcl/mod.rs +++ b/rust/kcl-lib/src/lsp/kcl/mod.rs @@ -786,7 +786,7 @@ impl Backend { vec![kittycad::types::multipart::Attachment { // Clean the URI part. name: "attachment".to_string(), - filename: Some("attachment.zip".to_string()), + filepath: Some("attachment.zip".into()), content_type: Some("application/x-zip".to_string()), data: self.create_zip().await?, }], diff --git a/rust/kcl-lib/src/simulation_tests.rs b/rust/kcl-lib/src/simulation_tests.rs index b5af5869b..570e7bea5 100644 --- a/rust/kcl-lib/src/simulation_tests.rs +++ b/rust/kcl-lib/src/simulation_tests.rs @@ -114,6 +114,8 @@ async fn unparse_test(test: &Test) { let kcl_files = kcl_files.into_iter().filter(|f| f != &entry_point); let futures = kcl_files .into_iter() + .filter(|file| file.extension().is_some_and(|ext| ext == "kcl")) // We only care about kcl + // files here. .map(|file| { let snap_path = Path::new("..").join(&test.output_dir); tokio::spawn(async move { diff --git a/rust/kcl-lib/src/unparser.rs b/rust/kcl-lib/src/unparser.rs index d5771d108..8d178cab1 100644 --- a/rust/kcl-lib/src/unparser.rs +++ b/rust/kcl-lib/src/unparser.rs @@ -1,5 +1,8 @@ use std::fmt::Write; +#[cfg(feature = "cli")] +use clap::ValueEnum; + use crate::parsing::{ ast::types::{ Annotation, ArrayExpression, ArrayRangeExpression, BinaryExpression, BinaryOperator, BinaryPart, BodyItem, @@ -864,10 +867,33 @@ impl Parameter { } } -/// Collect all the kcl files in a directory, recursively. +lazy_static::lazy_static! { + + pub static ref IMPORT_FILE_EXTENSIONS: Vec = { + let mut import_file_extensions = vec!["stp".to_string(), "glb".to_string(), "fbxb".to_string()]; + #[cfg(feature = "cli")] + let named_extensions = kittycad::types::FileImportFormat::value_variants() + .iter() + .map(|x| format!("{}", x)) + .collect::>(); + #[cfg(not(feature = "cli"))] + let named_extensions = vec![]; // We don't really need this outside of the CLI. + // Add all the default import formats. + import_file_extensions.extend_from_slice(&named_extensions); + import_file_extensions + }; + + pub static ref RELEVANT_EXTENSIONS: Vec = { + let mut relevant_extensions = IMPORT_FILE_EXTENSIONS.clone(); + relevant_extensions.push("kcl".to_string()); + relevant_extensions + }; +} + +/// Collect all the kcl (and other relevant) files in a directory, recursively. #[cfg(not(target_arch = "wasm32"))] #[async_recursion::async_recursion] -pub(crate) async fn walk_dir(dir: &std::path::PathBuf) -> Result, anyhow::Error> { +pub async fn walk_dir(dir: &std::path::PathBuf) -> Result, anyhow::Error> { // Make sure we actually have a directory. if !dir.is_dir() { anyhow::bail!("`{}` is not a directory", dir.display()); @@ -881,7 +907,10 @@ pub(crate) async fn walk_dir(dir: &std::path::PathBuf) -> Result