diff --git a/src/value.rs b/src/value.rs index 533d6ee..748a9ec 100644 --- a/src/value.rs +++ b/src/value.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use rquickjs::{context::EvalOptions, CatchResultExt, Coerced, FromJs}; +use rquickjs::{context::EvalOptions, CatchResultExt}; use serde::{Deserialize, Serialize}; #[derive(Clone, Serialize, Deserialize)] @@ -106,12 +106,7 @@ impl JSBytesValue { match type_field_value.as_ref() { "eval" => { if let Some(JSBytesValue::String(js)) = value.get("value") { - let mut options = EvalOptions::default(); - options.global = true; - return ctx.eval_with_options::(js.to_owned(), options) - .catch(&ctx) - .map(|v| Coerced::>::from_js(ctx, v).map(|v| v.to_string().map_err(|e| e.to_string())).map_err(|e| e.to_string())?) - .map_err(|e| format!("eval error: {}", e.to_string()))? + return Ok(js.to_owned()) } else { return Err("eval typed values needs to be a string".to_string()) } diff --git a/typst-package/ctxjs.wasm b/typst-package/ctxjs.wasm index 92d7245..c13aa95 100755 Binary files a/typst-package/ctxjs.wasm and b/typst-package/ctxjs.wasm differ diff --git a/typst-package/main.typ b/typst-package/main.typ new file mode 100644 index 0000000..baa5005 --- /dev/null +++ b/typst-package/main.typ @@ -0,0 +1,6 @@ +#import "lib.typ" as ctxjs + +#{ + _ = ctxjs.create-context("test") + let test = ctxjs.eval-format("test", "((callback) => {{ return callback(); }})({test})", ("test":ctxjs.eval-later("test", "() => {return 5;}"),)) +} \ No newline at end of file