fix: temporary remove luajit for compliation reasons

This commit is contained in:
DecDuck
2025-08-25 12:43:23 +10:00
parent 817c3cf503
commit e66a6581cb
4 changed files with 16 additions and 64 deletions

53
Cargo.lock generated
View File

@ -288,16 +288,6 @@ dependencies = [
"static_assertions",
]
[[package]]
name = "bstr"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "234113d19d0d7d613b40e86fb654acf958910802bcceab913a4f9e7cda03b1a4"
dependencies = [
"memchr",
"serde",
]
[[package]]
name = "bumpalo"
version = "3.19.0"
@ -489,7 +479,6 @@ dependencies = [
"flate2",
"hex",
"md5",
"mlua",
"napi",
"napi-build",
"napi-derive",
@ -900,32 +889,6 @@ dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "mlua"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab2fea92b2adabd51808311b101551d6e3f8602b65e9fae51f7ad5b3d500f4cd"
dependencies = [
"bstr",
"either",
"mlua-sys",
"num-traits",
"parking_lot",
"rustc-hash",
"rustversion",
]
[[package]]
name = "mlua-sys"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d4dc9cfc5a7698899802e97480617d9726f7da78c910db989d4d0fd4991d900"
dependencies = [
"cc",
"cfg-if",
"pkg-config",
]
[[package]]
name = "napi"
version = "3.0.0-beta.11"
@ -1104,16 +1067,6 @@ dependencies = [
"portable-atomic",
]
[[package]]
name = "parking_lot"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.11"
@ -1191,12 +1144,6 @@ version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
[[package]]
name = "pkg-config"
version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
[[package]]
name = "pollster"
version = "0.4.0"

View File

@ -23,7 +23,7 @@ rawzip = "0.3.0"
dyn-clone = "1.0.20"
flate2 = "1.1.2"
rhai = "1.22.2"
mlua = { version = "0.11.2", features = ["luajit"] }
# mlua = { version = "0.11.2", features = ["luajit"] }
boa_engine = "0.20.0"
serde_json = "1.0.143"
anyhow = "1.0.99"

View File

@ -1,6 +1,6 @@
{
"name": "@drop-oss/droplet",
"version": "3.0.0",
"version": "3.0.1",
"main": "index.js",
"types": "index.d.ts",
"napi": {

View File

@ -1,5 +1,5 @@
use boa_engine::{Context, JsValue, Source};
use mlua::{FromLuaMulti, Function, Lua};
// use mlua::{FromLuaMulti, Function, Lua};
use napi::Result;
use rhai::AST;
@ -14,14 +14,14 @@ pub struct Script(ScriptInner);
pub enum ScriptInner {
Rhai { script: AST },
Lua { script: Function },
// Lua { script: Function },
Javascript { script: boa_engine::Script },
}
#[napi]
pub struct ScriptEngine {
rhai_engine: rhai::Engine,
lua_engine: Lua,
// lua_engine: Lua,
js_engine: Context,
}
@ -31,13 +31,13 @@ impl ScriptEngine {
pub fn new() -> Self {
ScriptEngine {
rhai_engine: rhai::Engine::new(),
lua_engine: Lua::new(),
// lua_engine: Lua::new(),
js_engine: Context::default(),
}
}
#[napi]
pub fn build_rahi_script(&self, content: String) -> Result<Script> {
pub fn build_rhai_script(&self, content: String) -> Result<Script> {
let script = self
.rhai_engine
.compile(content.clone())
@ -45,6 +45,7 @@ impl ScriptEngine {
Ok(Script(ScriptInner::Rhai { script }))
}
/*
#[napi]
pub fn build_lua_script(&self, content: String) -> Result<Script> {
let func = self
@ -54,6 +55,7 @@ impl ScriptEngine {
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
Ok(Script(ScriptInner::Lua { script: func }))
}
*/
#[napi]
pub fn build_js_script(&mut self, content: String) -> Result<Script> {
@ -76,6 +78,7 @@ impl ScriptEngine {
Ok(v)
}
/*
fn execute_lua_script<T>(&self, function: &Function) -> Result<T>
where
T: FromLuaMulti,
@ -85,6 +88,7 @@ impl ScriptEngine {
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
Ok(v)
}
*/
fn execute_js_script(&mut self, func: &boa_engine::Script) -> Result<JsValue> {
let v = func
@ -100,9 +104,9 @@ impl ScriptEngine {
ScriptInner::Rhai { script } => {
self.execute_rhai_script::<()>(script)?;
}
ScriptInner::Lua { script } => {
/*ScriptInner::Lua { script } => {
self.execute_lua_script::<()>(script)?;
}
}*/
ScriptInner::Javascript { script } => {
self.execute_js_script(script)?;
}
@ -114,14 +118,15 @@ impl ScriptEngine {
pub fn fetch_strings(&mut self, script: &mut Script) -> Result<Vec<String>> {
Ok(match &script.0 {
ScriptInner::Rhai { script } => self.execute_rhai_script(script)?,
ScriptInner::Lua { script } => self.execute_lua_script(script)?,
//ScriptInner::Lua { script } => self.execute_lua_script(script)?,
ScriptInner::Javascript { script } => {
let v = self.execute_js_script(script)?;
serde_json::from_value(
v.to_json(&mut self.js_engine)
.map_err(|e| napi::Error::from_reason(e.to_string()))?,
).map_err(|e| napi::Error::from_reason(e.to_string()))?
)
.map_err(|e| napi::Error::from_reason(e.to_string()))?
}
})
}