mirror of
https://github.com/chirpstack/chirpstack.git
synced 2024-12-22 06:27:49 +00:00
Update rquickjs dependency.
This commit is contained in:
parent
ed9a9b0c88
commit
40cfa3ddf2
28
Cargo.lock
generated
28
Cargo.lock
generated
@ -668,17 +668,17 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bindgen"
|
name = "bindgen"
|
||||||
version = "0.66.1"
|
version = "0.69.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7"
|
checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.5.0",
|
"bitflags 2.5.0",
|
||||||
"cexpr",
|
"cexpr",
|
||||||
"clang-sys",
|
"clang-sys",
|
||||||
|
"itertools 0.12.1",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"lazycell",
|
"lazycell",
|
||||||
"log",
|
"log",
|
||||||
"peeking_take_while",
|
|
||||||
"prettyplease",
|
"prettyplease",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -3043,12 +3043,6 @@ dependencies = [
|
|||||||
"sha2",
|
"sha2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "peeking_take_while"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pem"
|
name = "pem"
|
||||||
version = "3.0.4"
|
version = "3.0.4"
|
||||||
@ -3764,9 +3758,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rquickjs"
|
name = "rquickjs"
|
||||||
version = "0.5.1"
|
version = "0.6.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ad7f63201fa6f2ff8173e4758ea552549d687d8f63003361a8b5c50f7c446ded"
|
checksum = "9cbd33e0b668aea0ab238b9164523aca929096f9f40834700d71d91dd4888882"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rquickjs-core",
|
"rquickjs-core",
|
||||||
"rquickjs-macro",
|
"rquickjs-macro",
|
||||||
@ -3774,9 +3768,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rquickjs-core"
|
name = "rquickjs-core"
|
||||||
version = "0.5.1"
|
version = "0.6.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cad00eeddc0f88af54ee202c8385fb214fe0423897c056a7df8369fb482e3695"
|
checksum = "2e9129d69b7b8f7ee8ad1da5b12c7f4a8a8acd45f2e6dd9cb2ee1bc5a1f2fa3d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"relative-path",
|
"relative-path",
|
||||||
@ -3785,9 +3779,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rquickjs-macro"
|
name = "rquickjs-macro"
|
||||||
version = "0.5.1"
|
version = "0.6.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f27b39e889cc951e3e5f6b74012f943e642fa0fac51a8552948751f19a9b62f8"
|
checksum = "c7d2ecaf7c9eda262e02a91e9541989a9dd18984d17d0d97f99f33b464318057"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"convert_case",
|
"convert_case",
|
||||||
"fnv",
|
"fnv",
|
||||||
@ -3803,9 +3797,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rquickjs-sys"
|
name = "rquickjs-sys"
|
||||||
version = "0.5.1"
|
version = "0.6.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "120dbbc3296de9b96de8890091635d46f3506cd38b4e8f21800c386c035d64fa"
|
checksum = "bf6f2288d8e7fbb5130f62cf720451641e99d55f6fde9db86aa2914ecb553fd2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"cc",
|
"cc",
|
||||||
|
@ -118,7 +118,7 @@ rumqttc = { version = "0.24", features = ["url"] }
|
|||||||
hex = "0.4"
|
hex = "0.4"
|
||||||
|
|
||||||
# Codecs
|
# Codecs
|
||||||
rquickjs = { version = "0.5", features = [
|
rquickjs = { version = "0.6", features = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"loader",
|
"loader",
|
||||||
"array-buffer",
|
"array-buffer",
|
||||||
|
@ -18,9 +18,10 @@ impl Plugin {
|
|||||||
let script = fs::read_to_string(file_path).context("Read ADR plugin")?;
|
let script = fs::read_to_string(file_path).context("Read ADR plugin")?;
|
||||||
|
|
||||||
let (id, name) = ctx.with::<_, Result<(String, String)>>(|ctx| {
|
let (id, name) = ctx.with::<_, Result<(String, String)>>(|ctx| {
|
||||||
let m = ctx
|
let m = rquickjs::Module::declare(ctx, "script", script.clone())
|
||||||
.compile("script", script.clone())
|
.context("Declare script")?;
|
||||||
.context("Compile script")?;
|
let (m, m_promise) = m.eval().context("Evaluate script")?;
|
||||||
|
m_promise.finish()?;
|
||||||
let id_func: rquickjs::Function = m.get("id").context("Get id function")?;
|
let id_func: rquickjs::Function = m.get("id").context("Get id function")?;
|
||||||
let name_func: rquickjs::Function = m.get("name").context("Get name function")?;
|
let name_func: rquickjs::Function = m.get("name").context("Get name function")?;
|
||||||
|
|
||||||
@ -51,10 +52,10 @@ impl Handler for Plugin {
|
|||||||
let ctx = rquickjs::Context::full(&rt)?;
|
let ctx = rquickjs::Context::full(&rt)?;
|
||||||
|
|
||||||
ctx.with::<_, Result<Response>>(|ctx| {
|
ctx.with::<_, Result<Response>>(|ctx| {
|
||||||
let m = ctx
|
let m = rquickjs::Module::declare(ctx.clone(), "script", self.script.clone())
|
||||||
.clone()
|
.context("Declare script")?;
|
||||||
.compile("script", self.script.clone())
|
let (m, m_promise) = m.eval().context("Evaluate script")?;
|
||||||
.context("Compile script")?;
|
m_promise.finish()?;
|
||||||
let func: rquickjs::Function = m.get("handle").context("Get handle function")?;
|
let func: rquickjs::Function = m.get("handle").context("Get handle function")?;
|
||||||
|
|
||||||
let device_variables = rquickjs::Object::new(ctx.clone())?;
|
let device_variables = rquickjs::Object::new(ctx.clone())?;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::{Context, Result};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use rquickjs::{CatchResultExt, IntoJs};
|
use rquickjs::{CatchResultExt, IntoJs};
|
||||||
|
|
||||||
@ -50,13 +50,17 @@ pub async fn decode(
|
|||||||
let out = ctx.with(|ctx| -> Result<pbjson_types::Struct> {
|
let out = ctx.with(|ctx| -> Result<pbjson_types::Struct> {
|
||||||
// We need to export the Buffer class, as eval / eval_with_options
|
// We need to export the Buffer class, as eval / eval_with_options
|
||||||
// does not allow using import statement.
|
// does not allow using import statement.
|
||||||
let buff: rquickjs::Module = ctx.clone().compile(
|
let buff = rquickjs::Module::declare(
|
||||||
|
ctx.clone(),
|
||||||
"b",
|
"b",
|
||||||
r#"
|
r#"
|
||||||
import { Buffer } from "buffer";
|
import { Buffer } from "buffer";
|
||||||
export { Buffer }
|
export { Buffer }
|
||||||
"#,
|
"#,
|
||||||
)?;
|
)
|
||||||
|
.context("Declare script")?;
|
||||||
|
let (buff, buff_promise) = buff.eval().context("Evalulate script")?;
|
||||||
|
buff_promise.finish()?;
|
||||||
let buff: rquickjs::Function = buff.get("Buffer")?;
|
let buff: rquickjs::Function = buff.get("Buffer")?;
|
||||||
|
|
||||||
let input = rquickjs::Object::new(ctx.clone())?;
|
let input = rquickjs::Object::new(ctx.clone())?;
|
||||||
@ -69,14 +73,11 @@ pub async fn decode(
|
|||||||
globals.set("chirpstack_input", input)?;
|
globals.set("chirpstack_input", input)?;
|
||||||
globals.set("Buffer", buff)?;
|
globals.set("Buffer", buff)?;
|
||||||
|
|
||||||
|
let mut eval_options = rquickjs::context::EvalOptions::default();
|
||||||
|
eval_options.strict = false;
|
||||||
|
|
||||||
let res: rquickjs::Object = ctx
|
let res: rquickjs::Object = ctx
|
||||||
.eval_with_options(
|
.eval_with_options(script, eval_options)
|
||||||
script,
|
|
||||||
rquickjs::context::EvalOptions {
|
|
||||||
strict: false,
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.catch(&ctx)
|
.catch(&ctx)
|
||||||
.map_err(|e| anyhow!("JS error: {}", e))?;
|
.map_err(|e| anyhow!("JS error: {}", e))?;
|
||||||
|
|
||||||
@ -137,13 +138,17 @@ pub async fn encode(
|
|||||||
ctx.with(|ctx| {
|
ctx.with(|ctx| {
|
||||||
// We need to export the Buffer class, as eval / eval_with_options
|
// We need to export the Buffer class, as eval / eval_with_options
|
||||||
// does not allow using import statement.
|
// does not allow using import statement.
|
||||||
let buff: rquickjs::Module = ctx.clone().compile(
|
let buff = rquickjs::Module::declare(
|
||||||
|
ctx.clone(),
|
||||||
"b",
|
"b",
|
||||||
r#"
|
r#"
|
||||||
import { Buffer } from "buffer";
|
import { Buffer } from "buffer";
|
||||||
export { Buffer }
|
export { Buffer }
|
||||||
"#,
|
"#,
|
||||||
)?;
|
)
|
||||||
|
.context("Declare script")?;
|
||||||
|
let (buff, buff_promise) = buff.eval().context("Evaluate script")?;
|
||||||
|
buff_promise.finish()?;
|
||||||
let buff: rquickjs::Function = buff.get("Buffer")?;
|
let buff: rquickjs::Function = buff.get("Buffer")?;
|
||||||
|
|
||||||
let input = rquickjs::Object::new(ctx.clone())?;
|
let input = rquickjs::Object::new(ctx.clone())?;
|
||||||
@ -155,14 +160,11 @@ pub async fn encode(
|
|||||||
globals.set("chirpstack_input", input)?;
|
globals.set("chirpstack_input", input)?;
|
||||||
globals.set("Buffer", buff)?;
|
globals.set("Buffer", buff)?;
|
||||||
|
|
||||||
|
let mut eval_options = rquickjs::context::EvalOptions::default();
|
||||||
|
eval_options.strict = false;
|
||||||
|
|
||||||
let res: rquickjs::Object = ctx
|
let res: rquickjs::Object = ctx
|
||||||
.eval_with_options(
|
.eval_with_options(script, eval_options)
|
||||||
script,
|
|
||||||
rquickjs::context::EvalOptions {
|
|
||||||
strict: false,
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.catch(&ctx)
|
.catch(&ctx)
|
||||||
.map_err(|e| anyhow!("JS error: {}", e))?;
|
.map_err(|e| anyhow!("JS error: {}", e))?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user