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"] }
|
||||
indxdb = { version = "0.3.0", optional = true }
|
||||
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"
|
||||
lexicmp = "0.1.0"
|
||||
lru = "0.10.1"
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use crate::ctx::canceller::Canceller;
|
||||
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::err::Error;
|
||||
use crate::idx::planner::QueryPlanner;
|
||||
|
@ -14,6 +16,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
|||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use trice::Instant;
|
||||
#[cfg(feature = "http")]
|
||||
use url::Url;
|
||||
|
||||
impl<'a> From<Value> for Cow<'a, Value> {
|
||||
|
@ -209,6 +212,7 @@ impl<'a> Context<'a> {
|
|||
}
|
||||
|
||||
/// Get the capabilities for this context
|
||||
#[allow(dead_code)]
|
||||
pub fn get_capabilities(&self) -> Arc<Capabilities> {
|
||||
self.capabilities.clone()
|
||||
}
|
||||
|
@ -235,6 +239,7 @@ impl<'a> Context<'a> {
|
|||
}
|
||||
|
||||
/// Check if a network target is allowed
|
||||
#[cfg(feature = "http")]
|
||||
pub fn check_allowed_net(&self, target: &Url) -> Result<(), Error> {
|
||||
match target.host() {
|
||||
Some(host)
|
||||
|
|
|
@ -227,7 +227,7 @@ impl<'js> Response<'js> {
|
|||
// Static methods
|
||||
// ------------------------------
|
||||
|
||||
#[qjs(r#static, rename = "json")]
|
||||
#[qjs(static, rename = "json")]
|
||||
pub fn static_json(
|
||||
ctx: Ctx<'js>,
|
||||
data: Value<'js>,
|
||||
|
@ -254,7 +254,7 @@ impl<'js> Response<'js> {
|
|||
}
|
||||
|
||||
// Returns a new response representing a network error
|
||||
#[qjs(r#static)]
|
||||
#[qjs(static)]
|
||||
pub fn error(ctx: Ctx<'js>) -> Result<Self> {
|
||||
let headers = Class::instance(ctx, Headers::new_empty())?;
|
||||
Ok(Response {
|
||||
|
@ -271,7 +271,7 @@ impl<'js> Response<'js> {
|
|||
}
|
||||
|
||||
// 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> {
|
||||
let url = url
|
||||
.parse::<Url>()
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
//! 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)]
|
||||
mod test;
|
||||
|
@ -29,24 +33,44 @@ macro_rules! impl_stub_class {
|
|||
mod $module{
|
||||
use super::*;
|
||||
|
||||
#[js::class]
|
||||
#[derive(Trace)]
|
||||
pub struct $name;
|
||||
|
||||
#[js::methods]
|
||||
impl $name {
|
||||
#[qjs(constructor)]
|
||||
pub fn new(ctx: Ctx<'_>) -> Result<Self> {
|
||||
Err(Exception::throw_internal(
|
||||
&ctx,
|
||||
concat!(
|
||||
"The '",
|
||||
stringify!($name),
|
||||
"' class is not available in this build of SurrealDB. In order to use '",
|
||||
stringify!($name),
|
||||
"', enable the 'http' feature."
|
||||
),
|
||||
))
|
||||
impl<'js> Trace<'js> for $name{
|
||||
fn trace<'a>(&self, _tracer: Tracer<'a, 'js>){}
|
||||
}
|
||||
|
||||
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(
|
||||
&ctx,
|
||||
concat!(
|
||||
"The '",
|
||||
stringify!($name),
|
||||
"' class is not available in this build of SurrealDB. In order to use '",
|
||||
stringify!($name),
|
||||
"', enable the 'http' feature."
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
Constructor::new_class::<$name,_,_>(ctx.clone(), new).map(Some)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue