From 8fbee44203c946c8498344619503a106230db60d Mon Sep 17 00:00:00 2001 From: Adam Chalmers Date: Mon, 25 Nov 2024 14:36:48 -0600 Subject: [PATCH 1/2] Bump kcl libraries --- Cargo.lock | 19 ++++++++++--------- src/cmd_file.rs | 8 ++++---- src/cmd_kcl.rs | 25 +++++++++++-------------- src/cmd_ml/cmd_text_to_cad.rs | 8 ++++---- src/context.rs | 29 +++++++++++++---------------- src/kcl_error_fmt.rs | 10 +++++----- 6 files changed, 47 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 70ebf8d0..c1822f9c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -862,9 +862,9 @@ dependencies = [ [[package]] name = "derive-docs" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8d1f48a43a738ddb38cc99f66e2c207d952a18ed02b453299f562c1cb3ee4e" +checksum = "f26afe8c7a6902add6133e3b2d747c9be9cd9efcf8811b76e5bd6bab7a0ba4c0" dependencies = [ "Inflector", "convert_case", @@ -1956,9 +1956,9 @@ dependencies = [ [[package]] name = "kcl-lib" -version = "0.2.24" +version = "0.2.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e54dc67c463a325b5899d40be1cca07a505581c330b6413a59297f89bd88140" +checksum = "f2d1dfc33302d0b95433befd718bbeba79267a19fff09844193fa83e22c642d5" dependencies = [ "anyhow", "approx 0.5.1", @@ -1971,6 +1971,7 @@ dependencies = [ "dashmap 6.1.0", "databake", "derive-docs", + "fnv", "form_urlencoded", "futures", "git_rev", @@ -2010,9 +2011,9 @@ dependencies = [ [[package]] name = "kcl-test-server" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36e829e2a3dfe1e1018ba42c024c8ee154d4128ce89c3a78e86b4a5349f0b600" +checksum = "b15aa6558d34af2bbc2bab3ab148a48bbfd565b773b730289cf251c70a860a93" dependencies = [ "anyhow", "hyper 0.14.30", @@ -2066,9 +2067,9 @@ dependencies = [ [[package]] name = "kittycad-modeling-cmds" -version = "0.2.74" +version = "0.2.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a77a98d3b7f946d2379b7f4507789cd874e89b50b3cd8492a5cc4bcb29dc3f" +checksum = "3b77259b37acafa360d98af27431ac394bc8899eeed7037513832ddbee856811" dependencies = [ "anyhow", "chrono", @@ -2076,7 +2077,7 @@ dependencies = [ "enum-iterator", "enum-iterator-derive", "euler", - "http 0.2.12", + "http 1.1.0", "kittycad", "kittycad-modeling-cmds-macros", "kittycad-unit-conversion-derive", diff --git a/src/cmd_file.rs b/src/cmd_file.rs index 72098c92..6fba042f 100644 --- a/src/cmd_file.rs +++ b/src/cmd_file.rs @@ -6,7 +6,7 @@ use std::{ use anyhow::Result; use base64::prelude::*; use clap::Parser; -use kcl_lib::engine::EngineManager; +use kcl_lib::EngineManager; use kittycad_modeling_cmds as kcmc; use crate::cmd_kcl::write_deterministic_export; @@ -283,7 +283,7 @@ impl crate::cmd::Command for CmdFileSnapshot { let resp = engine .send_modeling_cmd( uuid::Uuid::new_v4(), - kcl_lib::executor::SourceRange::default(), + kcl_lib::SourceRange::default(), kcmc::ModelingCmd::ImportFiles(kcmc::ImportFiles { files: files.into_iter().map(|f| f.into()).collect(), format: src_format.into(), @@ -304,7 +304,7 @@ impl crate::cmd::Command for CmdFileSnapshot { engine .send_modeling_cmd( uuid::Uuid::new_v4(), - kcl_lib::executor::SourceRange::default(), + kcl_lib::SourceRange::default(), kittycad_modeling_cmds::ModelingCmd::DefaultCameraFocusOn( kittycad_modeling_cmds::DefaultCameraFocusOn { uuid: object_id }, ), @@ -316,7 +316,7 @@ impl crate::cmd::Command for CmdFileSnapshot { let resp = engine .send_modeling_cmd( uuid::Uuid::new_v4(), - kcl_lib::executor::SourceRange::default(), + kcl_lib::SourceRange::default(), kittycad_modeling_cmds::ModelingCmd::TakeSnapshot(kittycad_modeling_cmds::TakeSnapshot { format: output_format, }), diff --git a/src/cmd_kcl.rs b/src/cmd_kcl.rs index 4f99de9b..34773676 100644 --- a/src/cmd_kcl.rs +++ b/src/cmd_kcl.rs @@ -210,17 +210,14 @@ impl crate::cmd::Command for CmdKclFormat { let input = std::str::from_utf8(&input)?; // Parse the file. - let program = kcl_lib::parser::top_level_parse(input)?; + let program = kcl_lib::Program::parse(input)?; // Recast the program to a string. - let formatted = program.recast( - &kcl_lib::ast::types::FormatOptions { - tab_size: self.tab_size, - use_tabs: self.use_tabs, - insert_final_newline: self.insert_final_newline, - }, - 0, - ); + let formatted = program.recast_with_options(&kcl_lib::FormatOptions { + tab_size: self.tab_size, + use_tabs: self.use_tabs, + insert_final_newline: self.insert_final_newline, + }); if self.write { if self.input.to_str().unwrap_or("-") == "-" { @@ -1039,7 +1036,7 @@ impl crate::cmd::Command for CmdKclLint { let input = std::str::from_utf8(&input)?; // Parse the file. - let program = kcl_lib::parser::top_level_parse(input)?; + let program = kcl_lib::Program::parse(input)?; for discovered_finding in program.lint_all()? { let finding_range = discovered_finding.pos.to_lsp_range(input); @@ -1119,9 +1116,9 @@ fn print_trace_link(io: &mut IoStreams, session_data: &Option, -) -> Result { +) -> Result { // Create the default settings from the src unit if given. - let default_settings = kcl_lib::executor::ExecutorSettings { + let default_settings = kcl_lib::ExecutorSettings { // We default to millimeters if not otherwise noted. units: src_unit.clone().unwrap_or(kittycad::types::UnitLength::Mm).into(), ..Default::default() @@ -1152,8 +1149,8 @@ pub fn get_modeling_settings_from_project_toml( let project_toml = find_project_toml(&dir)?; if let Some(project_toml) = project_toml { let project_toml = std::fs::read_to_string(&project_toml)?; - let project_toml: kcl_lib::settings::types::project::ProjectConfiguration = toml::from_str(&project_toml)?; - let settings: kcl_lib::executor::ExecutorSettings = project_toml.settings.modeling.into(); + let project_toml: kcl_lib::ProjectConfiguration = toml::from_str(&project_toml)?; + let settings: kcl_lib::ExecutorSettings = project_toml.settings.modeling.into(); // Make sure if they gave a command line flag, it tells them they don't match. if let Some(src_unit) = src_unit { let units: kittycad::types::UnitLength = settings.units.into(); diff --git a/src/cmd_ml/cmd_text_to_cad.rs b/src/cmd_ml/cmd_text_to_cad.rs index 9c1c09c4..ca3ea4d7 100644 --- a/src/cmd_ml/cmd_text_to_cad.rs +++ b/src/cmd_ml/cmd_text_to_cad.rs @@ -1,6 +1,6 @@ use anyhow::Result; use clap::Parser; -use kcl_lib::engine::EngineManager; +use kcl_lib::EngineManager; use kcmc::each_cmd as mcmd; use kcmc::format::InputFormat; use kcmc::ok_response::OkModelingCmdResponse; @@ -291,7 +291,7 @@ async fn get_image_bytes( let resp = engine .send_modeling_cmd( uuid::Uuid::new_v4(), - kcl_lib::executor::SourceRange::default(), + kcl_lib::SourceRange::default(), ModelingCmd::from(mcmd::ImportFiles { files: vec![ImportFile { path: "model.gltf".to_string(), @@ -315,7 +315,7 @@ async fn get_image_bytes( engine .send_modeling_cmd( uuid::Uuid::new_v4(), - kcl_lib::executor::SourceRange::default(), + kcl_lib::SourceRange::default(), ModelingCmd::from(mcmd::DefaultCameraFocusOn { uuid: object_id }), ) .await?; @@ -325,7 +325,7 @@ async fn get_image_bytes( let resp = engine .send_modeling_cmd( uuid::Uuid::new_v4(), - kcl_lib::executor::SourceRange::default(), + kcl_lib::SourceRange::default(), ModelingCmd::from(mcmd::TakeSnapshot { format: output_format }), ) .await?; diff --git a/src/context.rs b/src/context.rs index 801006e8..6c6ebea9 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1,7 +1,8 @@ use std::str::FromStr; use anyhow::{anyhow, Result}; -use kcl_lib::engine::EngineManager; +use kcl_lib::native_engine::EngineConnection; +use kcl_lib::EngineManager; use kcmc::each_cmd as mcmd; use kcmc::websocket::OkWebSocketResponseData; use kittycad::types::{ApiCallStatus, AsyncApiCallOutput, TextToCad, TextToCadCreateBody}; @@ -110,7 +111,7 @@ impl Context<'_> { let engine = self.engine(hostname, replay).await?; let resp = engine - .send_modeling_cmd(uuid::Uuid::new_v4(), kcl_lib::executor::SourceRange::default(), cmd) + .send_modeling_cmd(uuid::Uuid::new_v4(), kcl_lib::SourceRange::default(), cmd) .await?; Ok(resp) } @@ -124,14 +125,10 @@ impl Context<'_> { Ok(ws) } - pub async fn engine( - &self, - hostname: &str, - replay: Option, - ) -> Result { + pub async fn engine(&self, hostname: &str, replay: Option) -> Result { let ws = self.engine_ws(hostname, replay).await?; - let engine = kcl_lib::engine::conn::EngineConnection::new(ws).await?; + let engine = EngineConnection::new(ws).await?; Ok(engine) } @@ -141,16 +138,16 @@ impl Context<'_> { hostname: &str, code: &str, cmd: kittycad_modeling_cmds::ModelingCmd, - settings: kcl_lib::executor::ExecutorSettings, + settings: kcl_lib::ExecutorSettings, ) -> Result<(OkWebSocketResponseData, Option)> { let client = self.api_client(hostname)?; - let program = kcl_lib::parser::top_level_parse(code) - .map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?; + let program = + kcl_lib::Program::parse(code).map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?; - let ctx = kcl_lib::executor::ExecutorContext::new(&client, settings).await?; - let (_, session_data) = ctx - .run_with_session_data(&program, None, Default::default(), None) + let ctx = kcl_lib::ExecutorContext::new(&client, settings).await?; + let session_data = ctx + .run_with_session_data(&program, &mut Default::default()) .await .map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?; @@ -158,7 +155,7 @@ impl Context<'_> { ctx.engine .send_modeling_cmd( uuid::Uuid::new_v4(), - kcl_lib::executor::SourceRange::default(), + kcl_lib::SourceRange::default(), ModelingCmd::from(mcmd::ZoomToFit { animated: false, object_ids: Default::default(), @@ -169,7 +166,7 @@ impl Context<'_> { let resp = ctx .engine - .send_modeling_cmd(uuid::Uuid::new_v4(), kcl_lib::executor::SourceRange::default(), cmd) + .send_modeling_cmd(uuid::Uuid::new_v4(), kcl_lib::SourceRange::default(), cmd) .await .map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?; Ok((resp, session_data)) diff --git a/src/kcl_error_fmt.rs b/src/kcl_error_fmt.rs index 3f972f55..c28d5b28 100644 --- a/src/kcl_error_fmt.rs +++ b/src/kcl_error_fmt.rs @@ -4,7 +4,7 @@ use std::fmt; use colored::Colorize; -use kcl_lib::executor::SourceRange; +use kcl_lib::SourceRange; /// Separator used between the line numbering and the lines. const SEPARATOR: &str = " | "; @@ -27,8 +27,8 @@ pub struct KclError { /// The error types that we can pretty format. #[derive(Debug)] pub enum ErrorTypes { - /// Contains [`kcl_lib::errors::KclError`]. - Kcl(kcl_lib::errors::KclError), + /// Contains [`kcl_lib::KclError`]. + Kcl(kcl_lib::KclError), } impl std::error::Error for KclError {} @@ -39,8 +39,8 @@ impl fmt::Display for KclError { } } -impl From for ErrorTypes { - fn from(err: kcl_lib::errors::KclError) -> Self { +impl From for ErrorTypes { + fn from(err: kcl_lib::KclError) -> Self { Self::Kcl(err) } } From a57b751df256eb2ed5c7b12c0dd257de479eafc7 Mon Sep 17 00:00:00 2001 From: Adam Chalmers Date: Mon, 25 Nov 2024 16:05:46 -0600 Subject: [PATCH 2/2] Release 0.2.89 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c1822f9c..4b374bb4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5447,7 +5447,7 @@ dependencies = [ [[package]] name = "zoo" -version = "0.2.88" +version = "0.2.89" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 9ed1caba..5606a519 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zoo" -version = "0.2.88" +version = "0.2.89" edition = "2021" build = "build.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html