diff --git a/lib/src/fnc/script/globals/mod.rs b/lib/src/fnc/script/globals/mod.rs new file mode 100644 index 00000000..95383506 --- /dev/null +++ b/lib/src/fnc/script/globals/mod.rs @@ -0,0 +1 @@ +pub mod surrealdb; diff --git a/lib/src/fnc/script/globals/surrealdb.rs b/lib/src/fnc/script/globals/surrealdb.rs new file mode 100644 index 00000000..7143328d --- /dev/null +++ b/lib/src/fnc/script/globals/surrealdb.rs @@ -0,0 +1,6 @@ +#[js::bind(object, public)] +#[quickjs(rename = "surrealdb")] +#[allow(non_upper_case_globals)] +pub mod package { + pub const version: &str = crate::cnf::VERSION; +} diff --git a/lib/src/fnc/script/main.rs b/lib/src/fnc/script/main.rs index 141d76b2..96c6aa2e 100644 --- a/lib/src/fnc/script/main.rs +++ b/lib/src/fnc/script/main.rs @@ -1,5 +1,6 @@ use super::classes; use super::executor::Executor; +use super::globals; use super::modules::loader; use super::modules::resolver; use crate::ctx::Context; @@ -36,6 +37,8 @@ pub async fn run( let res: Result, js::Error> = ctx.with(|ctx| { // Get the context global object let global = ctx.globals(); + // Register the surrealdb module as a global object + global.init_def::().unwrap(); // Register the Duration type as a global class global.init_def::().unwrap(); // Register the Record type as a global class diff --git a/lib/src/fnc/script/mod.rs b/lib/src/fnc/script/mod.rs index d2ffacbc..c473a64d 100644 --- a/lib/src/fnc/script/mod.rs +++ b/lib/src/fnc/script/mod.rs @@ -6,6 +6,7 @@ mod classes; mod error; mod executor; mod from; +mod globals; mod into; mod main; mod modules;