Skip to content

Commit fa0e069

Browse files
authored
chore: update deno core and Cargo.lock (#3)
1 parent 37f1cc0 commit fa0e069

File tree

8 files changed

+67
-83
lines changed

8 files changed

+67
-83
lines changed

.github/workflows/publish.yaml

-18
This file was deleted.

ReadMe.md README.md

+32-30
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- DO NOT EDIT -- ReadMe is generated from lib.rs -->
1+
<!-- DO NOT EDIT -- README is generated from lib.rs -->
22

33
# js-sandbox-ios
44

@@ -24,7 +24,7 @@ This library is in early development, with a basic but powerful API. The API may
2424
The _Hello World_ example -- print something using JavaScript -- is one line, as it should be:
2525
```rust
2626
fn main() {
27-
js_sandbox_ios::eval_json("console.log('Hello Rust from JS')").expect("JS runs");
27+
js_sandbox_ios::eval_json("console.log('Hello Rust from JS')").expect("JS runs");
2828
}
2929
```
3030

@@ -64,13 +64,13 @@ fn main() -> Result<(), AnyError> {
6464
return "A person named " + person.name + " of age " + person.age;
6565
}"#;
6666

67-
let mut script = Script::from_string(src)?;
67+
let mut script = Script::from_string(src)?;
6868

69-
let person = Person { name: "Roger".to_string(), age: 42 };
70-
let result: String = script.call("toString", (person,))?;
69+
let person = Person { name: "Roger".to_string(), age: 42 };
70+
let result: String = script.call("toString", (person,))?;
7171

72-
assert_eq!(result, "A person named Roger of age 42");
73-
Ok(())
72+
assert_eq!(result, "A person named Roger of age 42");
73+
Ok(())
7474
}
7575
```
7676

@@ -85,14 +85,14 @@ If you want to statically embed UTF-8 encoded files in the Rust binary, you can
8585
use js_sandbox_ios::Script;
8686

8787
fn main() {
88-
// (1) at runtime:
89-
let mut script = Script::from_file("script.js").expect("load + init succeeds");
88+
// (1) at runtime:
89+
let mut script = Script::from_file("script.js").expect("load + init succeeds");
9090

91-
// (2) at compile time:
92-
let code: &'static str = include_str!("script.js");
93-
let mut script = Script::from_string(code).expect("init succeeds");
91+
// (2) at compile time:
92+
let code: &'static str = include_str!("script.js");
93+
let mut script = Script::from_string(code).expect("init succeeds");
9494

95-
// use script as usual
95+
// use script as usual
9696
}
9797
```
9898

@@ -105,19 +105,19 @@ This example appends a string in two calls, and then gets the result in a third
105105
use js_sandbox_ios::{Script, AnyError};
106106

107107
fn main() -> Result<(), AnyError> {
108-
let src = r#"
108+
let src = r#"
109109
var total = '';
110110
function append(str) { total += str; }
111111
function get() { return total; }"#;
112112

113-
let mut script = Script::from_string(src)?;
113+
let mut script = Script::from_string(src)?;
114114

115-
let _: () = script.call("append", ("hello",))?;
116-
let _: () = script.call("append", (" world",))?;
117-
let result: String = script.call("get", ())?;
115+
let _: () = script.call("append", ("hello",))?;
116+
let _: () = script.call("append", (" world",))?;
117+
let result: String = script.call("get", ())?;
118118

119-
assert_eq!(result, "hello world");
120-
Ok(())
119+
assert_eq!(result, "hello world");
120+
Ok(())
121121
}
122122
```
123123

@@ -130,21 +130,23 @@ a timeout, after which JavaScript execution is aborted.
130130
use js_sandbox_ios::{Script, JsError};
131131

132132
fn main() -> Result<(), JsError> {
133-
use std::time::Duration;
134-
let js_code = "function run_forever() { for(;;) {} }";
135-
let mut script = Script::from_string(js_code)?
136-
.with_timeout(Duration::from_millis(1000));
133+
use std::time::Duration;
134+
let js_code = "function run_forever() { for(;;) {} }";
135+
let mut script = Script::from_string(js_code)?
136+
.with_timeout(Duration::from_millis(1000));
137137

138-
let result: Result<String, JsError> = script.call("run_forever", ());
138+
let result: Result<String, JsError> = script.call("run_forever", ());
139139

140-
assert_eq!(
141-
result.unwrap_err().to_string(),
142-
"Uncaught Error: execution terminated".to_string()
143-
);
140+
assert_eq!(
141+
result.unwrap_err().to_string(),
142+
"Uncaught Error: execution terminated".to_string()
143+
);
144144

145-
Ok(())
145+
Ok(())
146146
}
147147
```
148148

149149
[Deno]: https://deno.land
150150
[serde_json]: https://docs.serde.rs/serde_json
151+
152+
License: Zlib

cfg/ReadMe.in cfg/README.in

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
<!-- DO NOT EDIT -- ReadMe is generated from lib.rs -->
1+
<!-- DO NOT EDIT -- README is generated from lib.rs -->
22

33
# {{crate}}
44

55
[<img alt="crates.io" src="https://img.shields.io/crates/v/js-sandbox?logo=rust&color=A6854D" />](https://crates.io/crates/js-sandbox)
66
[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-js--sandbox-4D8AA6?&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K" />](https://docs.rs/js-sandbox)
77

88
{{readme}}
9+
10+
License: {{license}}

js-sandbox-macros/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[package]
44
name = "js-sandbox-macros"
5-
version = "0.2.0-rc.1"
5+
version = "0.2.0"
66
description = "Procedural macros for js-sandbox"
77
repository = "https://github.com/Bromeon/js-sandbox"
88
documentation = "https://docs.rs/js-sandbox-macros/0.2.0-rc.1"
@@ -14,6 +14,6 @@ edition = "2021"
1414
proc-macro = true
1515

1616
[dependencies]
17-
syn = { version = "2.0.32", features = ["full"] }
18-
quote = "1.0.33"
19-
proc-macro2 = "1.0.66"
17+
syn = { version = "2.0.89", features = ["full"] }
18+
quote = "1.0.37"
19+
proc-macro2 = "1.0.92"

js-sandbox/Cargo.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
[package]
44
name = "js-sandbox-ios"
5-
version = "0.1.1"
5+
version = "0.2.0"
66
description = "Execute JavaScript code from Rust in a secure sandbox, and transport data to/from JS plug-ins."
77
repository = "https://github.com/Bromeon/js-sandbox"
88
documentation = "https://docs.rs/js-sandbox/0.2.0-rc.1"
99
authors = ["Jan Haller <[email protected]>"]
1010
license = "Zlib"
1111
edition = "2021"
12-
readme = "../ReadMe.md"
12+
readme = "../Readme.md"
1313

1414
[dependencies]
15-
js-sandbox-macros = { path = "../js-sandbox-macros", version = "=0.2.0-rc.1" }
16-
deno_core = "0.238.0"
17-
serde_json = "1.0.106"
18-
serde = { version = "1.0.188", features = ["derive"] }
15+
js-sandbox-macros = { path = "../js-sandbox-macros", version = "=0.2.0" }
16+
deno_core = "0.322.0"
17+
serde_json = "1.0.133"
18+
serde = { version = "1.0.215", features = ["derive"] }
1919
tracing = "0.1.40"

js-sandbox/src/lib.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Copyright (c) 2020-2023 js-sandbox contributors. Zlib license.
22

3-
// Note: the crate documentation is copied to ReadMe.md using cargo-readme (see CI)
3+
// Note: the crate documentation is copied to README.md using cargo-readme (see CI)
44
// Alternatives:
5-
// * once stable: #![feature(external_doc)] #![doc(include = "../ReadMe.md")]
6-
// * doc_comment crate + doctest!("../ReadMe.md"); -- works for running doc-tests, but not for doc on crate level
5+
// * once stable: #![feature(external_doc)] #![doc(include = "../README.md")]
6+
// * doc_comment crate + doctest!("../README.md"); -- works for running doc-tests, but not for doc on crate level
77

88
//! `js-sandbox` is a Rust library for executing JavaScript code from Rust in a secure sandbox. It is based on the [Deno] project and uses [serde_json]
99
//! for serialization.
@@ -37,13 +37,13 @@
3737
//! use js_sandbox_ios::{Script, AnyError};
3838
//!
3939
//! fn main() -> Result<(), AnyError> {
40-
//! let js_code = "function sub(a, b) { return a - b; }";
41-
//! let mut script = Script::from_string(js_code)?;
40+
//! let js_code = "function sub(a, b) { return a - b; }";
41+
//! let mut script = Script::from_string(js_code)?;
4242
//!
43-
//! let result: i32 = script.call("sub", (7, 5))?;
43+
//! let result: i32 = script.call("sub", (7, 5))?;
4444
//!
45-
//! assert_eq!(result, 2);
46-
//! Ok(())
45+
//! assert_eq!(result, 2);
46+
//! Ok(())
4747
//! }
4848
//! ```
4949
//!
@@ -55,23 +55,23 @@
5555
//!
5656
//! #[derive(Serialize)]
5757
//! struct Person {
58-
//! name: String,
59-
//! age: u8,
58+
//! name: String,
59+
//! age: u8,
6060
//! }
6161
//!
6262
//! fn main() -> Result<(), AnyError> {
63-
//! let src = r#"
63+
//! let src = r#"
6464
//! function toString(person) {
6565
//! return "A person named " + person.name + " of age " + person.age;
6666
//! }"#;
6767
//!
68-
//! let mut script = Script::from_string(src)?;
68+
//! let mut script = Script::from_string(src)?;
6969
//!
70-
//! let person = Person { name: "Roger".to_string(), age: 42 };
71-
//! let result: String = script.call("toString", (person,))?;
70+
//! let person = Person { name: "Roger".to_string(), age: 42 };
71+
//! let result: String = script.call("toString", (person,))?;
7272
//!
73-
//! assert_eq!(result, "A person named Roger of age 42");
74-
//! Ok(())
73+
//! assert_eq!(result, "A person named Roger of age 42");
74+
//! Ok(())
7575
//! }
7676
//! ```
7777
//!

js-sandbox/src/script.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{thread, time::Duration};
99

1010
use deno_core::anyhow::Context;
1111
use deno_core::v8::{Global, Value};
12-
use deno_core::{op2, serde_v8, v8, Extension, FastString, JsBuffer, JsRuntime, Op, OpState};
12+
use deno_core::{op2, serde_v8, v8, Extension, FastString, JsBuffer, JsRuntime, OpDecl, OpState};
1313
use serde::de::DeserializeOwned;
1414
use serde::{Deserialize, Serialize};
1515

@@ -82,8 +82,9 @@ impl Script {
8282
}
8383

8484
pub fn new() -> Self {
85+
const DECL: OpDecl = op_return();
8586
let ext = Extension {
86-
ops: Cow::Owned(vec![op_return::DECL]),
87+
ops: Cow::Owned(vec![DECL]),
8788
..Default::default()
8889
};
8990

@@ -133,7 +134,7 @@ impl Script {
133134
// We cannot provide a dynamic filename because execute_script() requires a &'static str
134135
let global = self
135136
.runtime
136-
.execute_script(Self::DEFAULT_FILENAME, js_code.into())?;
137+
.execute_script(Self::DEFAULT_FILENAME, js_code)?;
137138

138139
self.added_namespaces.insert(namespace.to_string(), global);
139140

@@ -296,7 +297,7 @@ impl Script {
296297
};
297298

298299
// 'undefined' will cause JSON serialization error, so it needs to be treated as null
299-
let js_code = format!(
300+
let js_code: String = format!(
300301
"(async () => {{
301302
let __rust_result = {fn_name}.constructor.name === 'AsyncFunction'
302303
? await {fn_name}({json_args})
@@ -307,8 +308,7 @@ impl Script {
307308
308309
Deno.core.ops.op_return(__rust_result);
309310
}})()"
310-
)
311-
.into();
311+
);
312312

313313
if let Some(timeout) = self.timeout {
314314
let handle = self.runtime.v8_isolate().thread_safe_handle();

publish.sh

-2
This file was deleted.

0 commit comments

Comments
 (0)