mirror of
https://github.com/Drop-OSS/droplet.git
synced 2025-11-09 20:12:18 +10:00
fix: temporary remove luajit for compliation reasons
This commit is contained in:
53
Cargo.lock
generated
53
Cargo.lock
generated
@ -288,16 +288,6 @@ dependencies = [
|
|||||||
"static_assertions",
|
"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]]
|
[[package]]
|
||||||
name = "bumpalo"
|
name = "bumpalo"
|
||||||
version = "3.19.0"
|
version = "3.19.0"
|
||||||
@ -489,7 +479,6 @@ dependencies = [
|
|||||||
"flate2",
|
"flate2",
|
||||||
"hex",
|
"hex",
|
||||||
"md5",
|
"md5",
|
||||||
"mlua",
|
|
||||||
"napi",
|
"napi",
|
||||||
"napi-build",
|
"napi-build",
|
||||||
"napi-derive",
|
"napi-derive",
|
||||||
@ -900,32 +889,6 @@ dependencies = [
|
|||||||
"windows-sys 0.59.0",
|
"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]]
|
[[package]]
|
||||||
name = "napi"
|
name = "napi"
|
||||||
version = "3.0.0-beta.11"
|
version = "3.0.0-beta.11"
|
||||||
@ -1104,16 +1067,6 @@ dependencies = [
|
|||||||
"portable-atomic",
|
"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]]
|
[[package]]
|
||||||
name = "parking_lot_core"
|
name = "parking_lot_core"
|
||||||
version = "0.9.11"
|
version = "0.9.11"
|
||||||
@ -1191,12 +1144,6 @@ version = "0.2.16"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
|
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pkg-config"
|
|
||||||
version = "0.3.32"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pollster"
|
name = "pollster"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
|
|||||||
@ -23,7 +23,7 @@ rawzip = "0.3.0"
|
|||||||
dyn-clone = "1.0.20"
|
dyn-clone = "1.0.20"
|
||||||
flate2 = "1.1.2"
|
flate2 = "1.1.2"
|
||||||
rhai = "1.22.2"
|
rhai = "1.22.2"
|
||||||
mlua = { version = "0.11.2", features = ["luajit"] }
|
# mlua = { version = "0.11.2", features = ["luajit"] }
|
||||||
boa_engine = "0.20.0"
|
boa_engine = "0.20.0"
|
||||||
serde_json = "1.0.143"
|
serde_json = "1.0.143"
|
||||||
anyhow = "1.0.99"
|
anyhow = "1.0.99"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@drop-oss/droplet",
|
"name": "@drop-oss/droplet",
|
||||||
"version": "3.0.0",
|
"version": "3.0.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
"napi": {
|
"napi": {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use boa_engine::{Context, JsValue, Source};
|
use boa_engine::{Context, JsValue, Source};
|
||||||
use mlua::{FromLuaMulti, Function, Lua};
|
// use mlua::{FromLuaMulti, Function, Lua};
|
||||||
use napi::Result;
|
use napi::Result;
|
||||||
use rhai::AST;
|
use rhai::AST;
|
||||||
|
|
||||||
@ -14,14 +14,14 @@ pub struct Script(ScriptInner);
|
|||||||
|
|
||||||
pub enum ScriptInner {
|
pub enum ScriptInner {
|
||||||
Rhai { script: AST },
|
Rhai { script: AST },
|
||||||
Lua { script: Function },
|
// Lua { script: Function },
|
||||||
Javascript { script: boa_engine::Script },
|
Javascript { script: boa_engine::Script },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[napi]
|
#[napi]
|
||||||
pub struct ScriptEngine {
|
pub struct ScriptEngine {
|
||||||
rhai_engine: rhai::Engine,
|
rhai_engine: rhai::Engine,
|
||||||
lua_engine: Lua,
|
// lua_engine: Lua,
|
||||||
js_engine: Context,
|
js_engine: Context,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,13 +31,13 @@ impl ScriptEngine {
|
|||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
ScriptEngine {
|
ScriptEngine {
|
||||||
rhai_engine: rhai::Engine::new(),
|
rhai_engine: rhai::Engine::new(),
|
||||||
lua_engine: Lua::new(),
|
// lua_engine: Lua::new(),
|
||||||
js_engine: Context::default(),
|
js_engine: Context::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[napi]
|
#[napi]
|
||||||
pub fn build_rahi_script(&self, content: String) -> Result<Script> {
|
pub fn build_rhai_script(&self, content: String) -> Result<Script> {
|
||||||
let script = self
|
let script = self
|
||||||
.rhai_engine
|
.rhai_engine
|
||||||
.compile(content.clone())
|
.compile(content.clone())
|
||||||
@ -45,6 +45,7 @@ impl ScriptEngine {
|
|||||||
Ok(Script(ScriptInner::Rhai { script }))
|
Ok(Script(ScriptInner::Rhai { script }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
#[napi]
|
#[napi]
|
||||||
pub fn build_lua_script(&self, content: String) -> Result<Script> {
|
pub fn build_lua_script(&self, content: String) -> Result<Script> {
|
||||||
let func = self
|
let func = self
|
||||||
@ -54,6 +55,7 @@ impl ScriptEngine {
|
|||||||
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
|
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
|
||||||
Ok(Script(ScriptInner::Lua { script: func }))
|
Ok(Script(ScriptInner::Lua { script: func }))
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
#[napi]
|
#[napi]
|
||||||
pub fn build_js_script(&mut self, content: String) -> Result<Script> {
|
pub fn build_js_script(&mut self, content: String) -> Result<Script> {
|
||||||
@ -76,6 +78,7 @@ impl ScriptEngine {
|
|||||||
Ok(v)
|
Ok(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
fn execute_lua_script<T>(&self, function: &Function) -> Result<T>
|
fn execute_lua_script<T>(&self, function: &Function) -> Result<T>
|
||||||
where
|
where
|
||||||
T: FromLuaMulti,
|
T: FromLuaMulti,
|
||||||
@ -85,6 +88,7 @@ impl ScriptEngine {
|
|||||||
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
|
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
|
||||||
Ok(v)
|
Ok(v)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
fn execute_js_script(&mut self, func: &boa_engine::Script) -> Result<JsValue> {
|
fn execute_js_script(&mut self, func: &boa_engine::Script) -> Result<JsValue> {
|
||||||
let v = func
|
let v = func
|
||||||
@ -100,9 +104,9 @@ impl ScriptEngine {
|
|||||||
ScriptInner::Rhai { script } => {
|
ScriptInner::Rhai { script } => {
|
||||||
self.execute_rhai_script::<()>(script)?;
|
self.execute_rhai_script::<()>(script)?;
|
||||||
}
|
}
|
||||||
ScriptInner::Lua { script } => {
|
/*ScriptInner::Lua { script } => {
|
||||||
self.execute_lua_script::<()>(script)?;
|
self.execute_lua_script::<()>(script)?;
|
||||||
}
|
}*/
|
||||||
ScriptInner::Javascript { script } => {
|
ScriptInner::Javascript { script } => {
|
||||||
self.execute_js_script(script)?;
|
self.execute_js_script(script)?;
|
||||||
}
|
}
|
||||||
@ -114,14 +118,15 @@ impl ScriptEngine {
|
|||||||
pub fn fetch_strings(&mut self, script: &mut Script) -> Result<Vec<String>> {
|
pub fn fetch_strings(&mut self, script: &mut Script) -> Result<Vec<String>> {
|
||||||
Ok(match &script.0 {
|
Ok(match &script.0 {
|
||||||
ScriptInner::Rhai { script } => self.execute_rhai_script(script)?,
|
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 } => {
|
ScriptInner::Javascript { script } => {
|
||||||
let v = self.execute_js_script(script)?;
|
let v = self.execute_js_script(script)?;
|
||||||
|
|
||||||
serde_json::from_value(
|
serde_json::from_value(
|
||||||
v.to_json(&mut self.js_engine)
|
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()))?
|
)
|
||||||
|
.map_err(|e| napi::Error::from_reason(e.to_string()))?
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user