Skip to content

Commit

Permalink
Bump kcl libraries, release 0.2.89 (#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchalmers authored Nov 25, 2024
1 parent 99ad579 commit 55bd709
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 54 deletions.
21 changes: 11 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/cmd_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand All @@ -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 },
),
Expand All @@ -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,
}),
Expand Down
25 changes: 11 additions & 14 deletions src/cmd_kcl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("-") == "-" {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1119,9 +1116,9 @@ fn print_trace_link(io: &mut IoStreams, session_data: &Option<kittycad::types::M
pub fn get_modeling_settings_from_project_toml(
input: &std::path::Path,
src_unit: Option<kittycad::types::UnitLength>,
) -> Result<kcl_lib::executor::ExecutorSettings> {
) -> Result<kcl_lib::ExecutorSettings> {
// 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()
Expand Down Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/cmd_ml/cmd_text_to_cad.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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(),
Expand All @@ -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?;
Expand All @@ -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?;
Expand Down
29 changes: 13 additions & 16 deletions src/context.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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)
}
Expand All @@ -124,14 +125,10 @@ impl Context<'_> {
Ok(ws)
}

pub async fn engine(
&self,
hostname: &str,
replay: Option<String>,
) -> Result<kcl_lib::engine::conn::EngineConnection> {
pub async fn engine(&self, hostname: &str, replay: Option<String>) -> Result<EngineConnection> {
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)
}
Expand All @@ -141,24 +138,24 @@ impl Context<'_> {
hostname: &str,
code: &str,
cmd: kittycad_modeling_cmds::ModelingCmd,
settings: kcl_lib::executor::ExecutorSettings,
settings: kcl_lib::ExecutorSettings,
) -> Result<(OkWebSocketResponseData, Option<ModelingSessionData>)> {
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))?;

// Zoom on the object.
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(),
Expand All @@ -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))
Expand Down
10 changes: 5 additions & 5 deletions src/kcl_error_fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = " | ";
Expand All @@ -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 {}
Expand All @@ -39,8 +39,8 @@ impl fmt::Display for KclError {
}
}

impl From<kcl_lib::errors::KclError> for ErrorTypes {
fn from(err: kcl_lib::errors::KclError) -> Self {
impl From<kcl_lib::KclError> for ErrorTypes {
fn from(err: kcl_lib::KclError) -> Self {
Self::Kcl(err)
}
}
Expand Down

0 comments on commit 55bd709

Please sign in to comment.