change name for initial publish to cargo (#340)
* change name for initial publish to cargo Signed-off-by: Jess Frazelle <github@jessfraz.com> * add license Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
30
src/wasm-lib/Cargo.lock
generated
30
src/wasm-lib/Cargo.lock
generated
@ -413,6 +413,20 @@ dependencies = [
|
|||||||
"syn 2.0.29",
|
"syn 2.0.29",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "derive-docs"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "075291fd1d6d70a886078f7b1c132a160559ceb9a0fe143177872d40ea587906"
|
||||||
|
dependencies = [
|
||||||
|
"convert_case",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"serde",
|
||||||
|
"serde_tokenstream",
|
||||||
|
"syn 2.0.29",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "diff"
|
name = "diff"
|
||||||
version = "0.1.13"
|
version = "0.1.13"
|
||||||
@ -932,12 +946,12 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kcl"
|
name = "kcl-lib"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bson",
|
"bson",
|
||||||
"derive-docs",
|
"derive-docs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"expectorate",
|
"expectorate",
|
||||||
"futures",
|
"futures",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
@ -953,7 +967,7 @@ dependencies = [
|
|||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-tungstenite",
|
"tokio-tungstenite",
|
||||||
"ts-rs",
|
"ts-rs-json-value",
|
||||||
"uuid",
|
"uuid",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
@ -2346,9 +2360,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
|
checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ts-rs"
|
name = "ts-rs-json-value"
|
||||||
version = "7.0.0"
|
version = "7.0.0"
|
||||||
source = "git+https://github.com/kittycad/ts-rs.git?branch=serde_json#94e2a19c41194e47009fafc7b5a2c28ae544a6e8"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b66d07e64e1e39d693819307757ad16878ff2be1f26d6fc2137c4e23bc0c0545"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
@ -2359,7 +2374,8 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ts-rs-macros"
|
name = "ts-rs-macros"
|
||||||
version = "7.0.0"
|
version = "7.0.0"
|
||||||
source = "git+https://github.com/kittycad/ts-rs.git?branch=serde_json#94e2a19c41194e47009fafc7b5a2c28ae544a6e8"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a6f41cc0aeb7a4a55730188e147d3795a7349b501f8334697fd37629b896cdc2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"Inflector",
|
"Inflector",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@ -2592,7 +2608,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bson",
|
"bson",
|
||||||
"gloo-utils",
|
"gloo-utils",
|
||||||
"kcl",
|
"kcl-lib",
|
||||||
"kittycad",
|
"kittycad",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
|
@ -10,7 +10,7 @@ crate-type = ["cdylib"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
bson = { version = "2.6.1", features = ["uuid-1", "chrono"] }
|
bson = { version = "2.6.1", features = ["uuid-1", "chrono"] }
|
||||||
gloo-utils = "0.2.0"
|
gloo-utils = "0.2.0"
|
||||||
kcl = { path = "kcl" }
|
kcl-lib = { path = "kcl" }
|
||||||
kittycad = { version = "0.2.15", default-features = false, features = ["js"] }
|
kittycad = { version = "0.2.15", default-features = false, features = ["js"] }
|
||||||
serde_json = "1.0.93"
|
serde_json = "1.0.93"
|
||||||
wasm-bindgen = "0.2.87"
|
wasm-bindgen = "0.2.87"
|
||||||
|
@ -3,6 +3,7 @@ name = "derive-docs"
|
|||||||
description = "A tool for generating documentation from Rust derive macros"
|
description = "A tool for generating documentation from Rust derive macros"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
license = "MIT"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "kcl"
|
name = "kcl-lib"
|
||||||
description = "KittyCAD Language"
|
description = "KittyCAD Language"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
license = "MIT"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.75"
|
anyhow = "1.0.75"
|
||||||
derive-docs = { path = "../derive-docs" }
|
derive-docs = { version = "0.1.0" }
|
||||||
kittycad = { version = "0.2.15", default-features = false, features = ["js"] }
|
kittycad = { version = "0.2.15", default-features = false, features = ["js"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
parse-display = "0.8.2"
|
parse-display = "0.8.2"
|
||||||
@ -17,7 +18,7 @@ schemars = { version = "0.8", features = ["url", "uuid1"] }
|
|||||||
serde = {version = "1.0.152", features = ["derive"] }
|
serde = {version = "1.0.152", features = ["derive"] }
|
||||||
serde_json = "1.0.93"
|
serde_json = "1.0.93"
|
||||||
thiserror = "1.0.47"
|
thiserror = "1.0.47"
|
||||||
ts-rs = { git = "https://github.com/kittycad/ts-rs.git", branch = "serde_json", features = ["serde-json-impl", "uuid-impl"] }
|
ts-rs = { version = "7", package = "ts-rs-json-value", features = ["serde-json-impl", "uuid-impl"] }
|
||||||
uuid = { version = "1.4.1", features = ["v4", "js", "serde"] }
|
uuid = { version = "1.4.1", features = ["v4", "js", "serde"] }
|
||||||
wasm-bindgen = "0.2.87"
|
wasm-bindgen = "0.2.87"
|
||||||
wasm-bindgen-futures = "0.4.37"
|
wasm-bindgen-futures = "0.4.37"
|
||||||
|
@ -44,7 +44,7 @@ pub fn normalize_rad(angle: f64) -> f64 {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// assert_eq!(kcl::std::utils::delta_angle(std::f64::consts::PI/8.0, std::f64::consts::PI/4.0), std::f64::consts::PI/8.0);
|
/// assert_eq!(kcl_lib::std::utils::delta_angle(std::f64::consts::PI/8.0, std::f64::consts::PI/4.0), std::f64::consts::PI/8.0);
|
||||||
/// ```
|
/// ```
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn delta_angle(from_angle: f64, to_angle: f64) -> f64 {
|
pub fn delta_angle(from_angle: f64, to_angle: f64) -> f64 {
|
||||||
@ -69,8 +69,8 @@ pub fn delta_angle(from_angle: f64, to_angle: f64) -> f64 {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// assert_eq!(kcl::std::utils::distance_between_points(&[0.0, 0.0], &[0.0, 5.0]), 5.0);
|
/// assert_eq!(kcl_lib::std::utils::distance_between_points(&[0.0, 0.0], &[0.0, 5.0]), 5.0);
|
||||||
/// assert_eq!(kcl::std::utils::distance_between_points(&[0.0, 0.0], &[3.0, 4.0]), 5.0);
|
/// assert_eq!(kcl_lib::std::utils::distance_between_points(&[0.0, 0.0], &[3.0, 4.0]), 5.0);
|
||||||
/// ```
|
/// ```
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn distance_between_points(point_a: &[f64; 2], point_b: &[f64; 2]) -> f64 {
|
pub fn distance_between_points(point_a: &[f64; 2], point_b: &[f64; 2]) -> f64 {
|
||||||
|
@ -9,22 +9,22 @@ use wasm_bindgen::prelude::*;
|
|||||||
pub async fn execute_wasm(
|
pub async fn execute_wasm(
|
||||||
program_str: &str,
|
program_str: &str,
|
||||||
memory_str: &str,
|
memory_str: &str,
|
||||||
manager: kcl::engine::conn_wasm::EngineCommandManager,
|
manager: kcl_lib::engine::conn_wasm::EngineCommandManager,
|
||||||
) -> Result<JsValue, String> {
|
) -> Result<JsValue, String> {
|
||||||
// deserialize the ast from a stringified json
|
// deserialize the ast from a stringified json
|
||||||
let program: kcl::abstract_syntax_tree_types::Program =
|
let program: kcl_lib::abstract_syntax_tree_types::Program =
|
||||||
serde_json::from_str(program_str).map_err(|e| e.to_string())?;
|
serde_json::from_str(program_str).map_err(|e| e.to_string())?;
|
||||||
let mut mem: kcl::executor::ProgramMemory =
|
let mut mem: kcl_lib::executor::ProgramMemory =
|
||||||
serde_json::from_str(memory_str).map_err(|e| e.to_string())?;
|
serde_json::from_str(memory_str).map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
let mut engine = kcl::engine::EngineConnection::new(manager)
|
let mut engine = kcl_lib::engine::EngineConnection::new(manager)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| format!("{:?}", e))?;
|
.map_err(|e| format!("{:?}", e))?;
|
||||||
|
|
||||||
let memory = kcl::executor::execute(
|
let memory = kcl_lib::executor::execute(
|
||||||
program,
|
program,
|
||||||
&mut mem,
|
&mut mem,
|
||||||
kcl::executor::BodyType::Root,
|
kcl_lib::executor::BodyType::Root,
|
||||||
&mut engine,
|
&mut engine,
|
||||||
)
|
)
|
||||||
.map_err(String::from)?;
|
.map_err(String::from)?;
|
||||||
@ -58,14 +58,14 @@ pub fn deserialize_files(data: &[u8]) -> Result<JsValue, JsError> {
|
|||||||
// test for this function and by extension lexer are done in javascript land src/lang/tokeniser.test.ts
|
// test for this function and by extension lexer are done in javascript land src/lang/tokeniser.test.ts
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn lexer_js(js: &str) -> Result<JsValue, JsError> {
|
pub fn lexer_js(js: &str) -> Result<JsValue, JsError> {
|
||||||
let tokens = kcl::tokeniser::lexer(js);
|
let tokens = kcl_lib::tokeniser::lexer(js);
|
||||||
Ok(JsValue::from_serde(&tokens)?)
|
Ok(JsValue::from_serde(&tokens)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn parse_js(js: &str) -> Result<JsValue, String> {
|
pub fn parse_js(js: &str) -> Result<JsValue, String> {
|
||||||
let tokens = kcl::tokeniser::lexer(js);
|
let tokens = kcl_lib::tokeniser::lexer(js);
|
||||||
let program = kcl::parser::abstract_syntax_tree(&tokens).map_err(String::from)?;
|
let program = kcl_lib::parser::abstract_syntax_tree(&tokens).map_err(String::from)?;
|
||||||
// The serde-wasm-bindgen does not work here because of weird HashMap issues so we use the
|
// The serde-wasm-bindgen does not work here because of weird HashMap issues so we use the
|
||||||
// gloo-serialize crate instead.
|
// gloo-serialize crate instead.
|
||||||
JsValue::from_serde(&program).map_err(|e| e.to_string())
|
JsValue::from_serde(&program).map_err(|e| e.to_string())
|
||||||
@ -76,9 +76,9 @@ pub fn parse_js(js: &str) -> Result<JsValue, String> {
|
|||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn recast_wasm(json_str: &str) -> Result<JsValue, JsError> {
|
pub fn recast_wasm(json_str: &str) -> Result<JsValue, JsError> {
|
||||||
// deserialize the ast from a stringified json
|
// deserialize the ast from a stringified json
|
||||||
let program: kcl::abstract_syntax_tree_types::Program =
|
let program: kcl_lib::abstract_syntax_tree_types::Program =
|
||||||
serde_json::from_str(json_str).map_err(JsError::from)?;
|
serde_json::from_str(json_str).map_err(JsError::from)?;
|
||||||
|
|
||||||
let result = kcl::recast::recast(&program, "", false);
|
let result = kcl_lib::recast::recast(&program, "", false);
|
||||||
Ok(JsValue::from_serde(&result)?)
|
Ok(JsValue::from_serde(&result)?)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user