Fix build by upgrading rquickjs (#2509)
This commit is contained in:
parent
cbf933b319
commit
e477dc9133
5 changed files with 301 additions and 232 deletions
460
Cargo.lock
generated
460
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -77,7 +77,7 @@ geo = { version = "0.25.1", features = ["use-serde"] }
|
||||||
indexmap = { version = "1.9.3", features = ["serde"] }
|
indexmap = { version = "1.9.3", features = ["serde"] }
|
||||||
indxdb = { version = "0.3.0", optional = true }
|
indxdb = { version = "0.3.0", optional = true }
|
||||||
ipnet = "2.8.0"
|
ipnet = "2.8.0"
|
||||||
js = { version = "0.4.0-beta.3", package = "rquickjs", features = ["array-buffer", "bindgen", "classes", "futures", "loader", "macro", "parallel", "properties","rust-alloc"], optional = true }
|
js = { version = "=0.4.0-beta.4", package = "rquickjs", features = ["array-buffer", "bindgen", "classes", "futures", "loader", "macro", "parallel", "properties","rust-alloc"], optional = true }
|
||||||
jsonwebtoken = "8.3.0"
|
jsonwebtoken = "8.3.0"
|
||||||
lexicmp = "0.1.0"
|
lexicmp = "0.1.0"
|
||||||
lru = "0.10.1"
|
lru = "0.10.1"
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
use crate::ctx::canceller::Canceller;
|
use crate::ctx::canceller::Canceller;
|
||||||
use crate::ctx::reason::Reason;
|
use crate::ctx::reason::Reason;
|
||||||
use crate::dbs::capabilities::{FuncTarget, NetTarget};
|
use crate::dbs::capabilities::FuncTarget;
|
||||||
|
#[cfg(feature = "http")]
|
||||||
|
use crate::dbs::capabilities::NetTarget;
|
||||||
use crate::dbs::{Capabilities, Notification};
|
use crate::dbs::{Capabilities, Notification};
|
||||||
use crate::err::Error;
|
use crate::err::Error;
|
||||||
use crate::idx::planner::QueryPlanner;
|
use crate::idx::planner::QueryPlanner;
|
||||||
|
@ -14,6 +16,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use trice::Instant;
|
use trice::Instant;
|
||||||
|
#[cfg(feature = "http")]
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
impl<'a> From<Value> for Cow<'a, Value> {
|
impl<'a> From<Value> for Cow<'a, Value> {
|
||||||
|
@ -209,6 +212,7 @@ impl<'a> Context<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the capabilities for this context
|
/// Get the capabilities for this context
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn get_capabilities(&self) -> Arc<Capabilities> {
|
pub fn get_capabilities(&self) -> Arc<Capabilities> {
|
||||||
self.capabilities.clone()
|
self.capabilities.clone()
|
||||||
}
|
}
|
||||||
|
@ -235,6 +239,7 @@ impl<'a> Context<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a network target is allowed
|
/// Check if a network target is allowed
|
||||||
|
#[cfg(feature = "http")]
|
||||||
pub fn check_allowed_net(&self, target: &Url) -> Result<(), Error> {
|
pub fn check_allowed_net(&self, target: &Url) -> Result<(), Error> {
|
||||||
match target.host() {
|
match target.host() {
|
||||||
Some(host)
|
Some(host)
|
||||||
|
|
|
@ -227,7 +227,7 @@ impl<'js> Response<'js> {
|
||||||
// Static methods
|
// Static methods
|
||||||
// ------------------------------
|
// ------------------------------
|
||||||
|
|
||||||
#[qjs(r#static, rename = "json")]
|
#[qjs(static, rename = "json")]
|
||||||
pub fn static_json(
|
pub fn static_json(
|
||||||
ctx: Ctx<'js>,
|
ctx: Ctx<'js>,
|
||||||
data: Value<'js>,
|
data: Value<'js>,
|
||||||
|
@ -254,7 +254,7 @@ impl<'js> Response<'js> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a new response representing a network error
|
// Returns a new response representing a network error
|
||||||
#[qjs(r#static)]
|
#[qjs(static)]
|
||||||
pub fn error(ctx: Ctx<'js>) -> Result<Self> {
|
pub fn error(ctx: Ctx<'js>) -> Result<Self> {
|
||||||
let headers = Class::instance(ctx, Headers::new_empty())?;
|
let headers = Class::instance(ctx, Headers::new_empty())?;
|
||||||
Ok(Response {
|
Ok(Response {
|
||||||
|
@ -271,7 +271,7 @@ impl<'js> Response<'js> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a new response with a different URL
|
// Creates a new response with a different URL
|
||||||
#[qjs(r#static)]
|
#[qjs(static)]
|
||||||
pub fn redirect(ctx: Ctx<'_>, url: String, status: Opt<u32>) -> Result<Response> {
|
pub fn redirect(ctx: Ctx<'_>, url: String, status: Opt<u32>) -> Result<Response> {
|
||||||
let url = url
|
let url = url
|
||||||
.parse::<Url>()
|
.parse::<Url>()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
//! stub implementations for the fetch API when `http` is not enabled.
|
//! stub implementations for the fetch API when `http` is not enabled.
|
||||||
|
|
||||||
use js::{class::Trace, Class, Ctx, Exception, Function, Result};
|
use js::{
|
||||||
|
class::{ClassId, JsClass, Trace, Tracer},
|
||||||
|
function::Constructor,
|
||||||
|
Class, Ctx, Exception, Function, Object, Result,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test;
|
mod test;
|
||||||
|
@ -29,14 +33,31 @@ macro_rules! impl_stub_class {
|
||||||
mod $module{
|
mod $module{
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[js::class]
|
|
||||||
#[derive(Trace)]
|
|
||||||
pub struct $name;
|
pub struct $name;
|
||||||
|
|
||||||
#[js::methods]
|
impl<'js> Trace<'js> for $name{
|
||||||
impl $name {
|
fn trace<'a>(&self, _tracer: Tracer<'a, 'js>){}
|
||||||
#[qjs(constructor)]
|
}
|
||||||
pub fn new(ctx: Ctx<'_>) -> Result<Self> {
|
|
||||||
|
impl<'js> JsClass<'js> for $name {
|
||||||
|
const NAME: &'static str = stringify!($name);
|
||||||
|
|
||||||
|
type Mutable = js::class::Readable;
|
||||||
|
|
||||||
|
/// A unique id for the class.
|
||||||
|
fn class_id() -> &'static ClassId{
|
||||||
|
static ID: ClassId = ClassId::new();
|
||||||
|
&ID
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the class prototype,
|
||||||
|
fn prototype(ctx: &Ctx<'js>) -> Result<Option<Object<'js>>>{
|
||||||
|
Object::new(ctx.clone()).map(Some)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a predefined constructor for this specific class type if there is one.
|
||||||
|
fn constructor(ctx: &Ctx<'js>) -> Result<Option<Constructor<'js>>>{
|
||||||
|
fn new(ctx: Ctx<'_>) -> Result<()> {
|
||||||
Err(Exception::throw_internal(
|
Err(Exception::throw_internal(
|
||||||
&ctx,
|
&ctx,
|
||||||
concat!(
|
concat!(
|
||||||
|
@ -48,6 +69,9 @@ macro_rules! impl_stub_class {
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Constructor::new_class::<$name,_,_>(ctx.clone(), new).map(Some)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)*
|
)*
|
||||||
|
|
Loading…
Reference in a new issue