Skip to content

Update deno_core dependency to 0.200 to avoid compilation error in nightly rust #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js-sandbox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ readme = "../ReadMe.md"

[dependencies]
js-sandbox-macros = { path = "../js-sandbox-macros", version = "=0.2.0-rc.1" }
deno_core = "0.178"
deno_core = "0.200"
serde_json = "1"
serde = { version = "1", features = ["derive"] }
21 changes: 13 additions & 8 deletions js-sandbox/src/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::path::Path;
use std::rc::Rc;
use std::{thread, time::Duration};

use deno_core::{op, Extension, JsRuntime, OpState, ZeroCopyBuf};
use deno_core::{op, Extension, FastString, JsBuffer, JsRuntime, Op, OpState};
use serde::de::DeserializeOwned;

use crate::{AnyError, CallArgs, JsError, JsValue};
Expand Down Expand Up @@ -129,7 +129,8 @@ impl Script {

Deno.core.ops.op_return(__rust_result);
}})()"
);
)
.into();

if let Some(timeout) = self.timeout {
let handle = self.runtime.v8_isolate().thread_safe_handle();
Expand Down Expand Up @@ -163,10 +164,14 @@ impl Script {
Ok(extracted.json_value)
}

fn create_script(js_code: String) -> Result<Self, JsError> {
let ext = Extension::builder("script")
.ops(vec![(op_return::decl())])
.build();
fn create_script<S>(js_code: S) -> Result<Self, JsError>
where
S: Into<FastString>,
{
let ext = Extension {
ops: Cow::Owned(vec![op_return::DECL]),
..Default::default()
};

let mut runtime = JsRuntime::new(deno_core::RuntimeOptions {
module_loader: Some(Rc::new(deno_core::FsModuleLoader)),
Expand All @@ -175,7 +180,7 @@ impl Script {
});

// We cannot provide a dynamic filename because execute_script() requires a &'static str
runtime.execute_script(Self::DEFAULT_FILENAME, js_code)?;
runtime.execute_script(Self::DEFAULT_FILENAME, js_code.into())?;

Ok(Script {
runtime,
Expand All @@ -201,7 +206,7 @@ impl deno_core::Resource for ResultResource {
fn op_return(
state: &mut OpState,
args: JsValue,
_buf: Option<ZeroCopyBuf>,
_buf: Option<JsBuffer>,
) -> Result<JsValue, deno_core::error::AnyError> {
let entry = ResultResource { json_value: args };
let resource_table = &mut state.resource_table;
Expand Down