Skip to content
Open
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
335 changes: 306 additions & 29 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
v8 = "0.74.3"
v8 = "145.0.0"

[dev-dependencies]
tokio = { version = "1", features = ["rt", "time", "macros"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl Runtime {
pub fn new(options: RuntimeOptions) -> Self {
// Load ICU data to enable i18n, similar to Deno:
// https://github.com/denoland/deno/blob/a55b194638bcaace38917703b7d9233fb1989d44/core/runtime.rs#L223
v8::icu::set_common_data_72(&ICU_DATA.0).expect("Failed to load ICU data");
v8::icu::set_common_data_77(&ICU_DATA.0).expect("Failed to load ICU data");

let mut flags = FLAGS.join(" ");

Expand Down
2 changes: 1 addition & 1 deletion crates/runtime_crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
v8 = "0.74.3"
v8 = "145.0.0"
anyhow = "1.0.72"
rand = "0.8.5"
uuid = { version = "1.4.1", features = ["v4", "fast-rng"] }
Expand Down
14 changes: 7 additions & 7 deletions crates/runtime_crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub enum KeyGenAlgorithm {
}

pub fn extract_algorithm_object(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
value: v8::Local<v8::Value>,
) -> Result<Algorithm> {
if let Some(algorithm) = value.to_object(scope) {
Expand Down Expand Up @@ -143,7 +143,7 @@ pub fn extract_algorithm_object(
}

pub fn extract_algorithm_object_or_string(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
value: v8::Local<v8::Value>,
) -> Result<String> {
if value.is_string() {
Expand All @@ -162,7 +162,7 @@ pub fn extract_algorithm_object_or_string(
}

pub fn extract_cryptokey_key_value(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
value: v8::Local<v8::Value>,
) -> Result<Vec<u8>> {
if let Some(key) = value.to_object(scope) {
Expand Down Expand Up @@ -196,7 +196,7 @@ pub fn get_named_curve(curve: &str) -> Result<CryptoNamedCurve> {
}

pub fn extract_sha_hash(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
algorithm: v8::Local<v8::Object>,
) -> Result<Sha> {
let hash_key = v8_string(scope, "hash");
Expand All @@ -209,7 +209,7 @@ pub fn extract_sha_hash(
}

pub fn extract_sign_verify_algorithm(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
value: v8::Local<v8::Value>,
) -> Result<Algorithm> {
if value.is_string() {
Expand Down Expand Up @@ -260,7 +260,7 @@ pub fn extract_sign_verify_algorithm(
}

pub fn extract_derive_algorithm(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
value: v8::Local<v8::Value>,
) -> Result<DeriveAlgorithm> {
if let Some(algorithm) = value.to_object(scope) {
Expand Down Expand Up @@ -348,7 +348,7 @@ pub fn extract_derive_algorithm(
}

pub fn extract_generate_key_algorithm(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
value: v8::Local<v8::Value>,
) -> Result<KeyGenAlgorithm> {
if let Some(algorithm) = value.to_object(scope) {
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime_http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
v8 = "0.74.3"
v8 = "145.0.0"
hyper = { version = "1.0", features = ["http1", "http2"] }
http-body-util = "0.1"
bytes = "1.5"
Expand Down
4 changes: 2 additions & 2 deletions crates/runtime_http/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use lagoss_runtime_v8_utils::{

pub fn request_to_v8<'a>(
request: (Parts, Bytes),
scope: &mut v8::HandleScope<'a>,
scope: &mut v8::PinScope<'a, '_>,
) -> v8::Local<'a, v8::Object> {
let body_empty = request.1.is_empty();
let len = if body_empty { 3 } else { 4 };
Expand Down Expand Up @@ -49,7 +49,7 @@ pub fn request_to_v8<'a>(
}

pub fn request_from_v8<'a>(
scope: &mut v8::HandleScope<'a>,
scope: &mut v8::PinScope<'a, '_>,
request: v8::Local<'a, v8::Value>,
) -> Result<Request<String>> {
let request = match request.to_object(scope) {
Expand Down
4 changes: 2 additions & 2 deletions crates/runtime_http/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use lagoss_runtime_v8_utils::{

pub fn response_to_v8<'a>(
response: (u16, HeaderMap, Bytes),
scope: &mut v8::HandleScope<'a>,
scope: &mut v8::PinScope<'a, '_>,
) -> v8::Local<'a, v8::Object> {
let len = 3;
let mut names = Vec::with_capacity(len);
Expand All @@ -29,7 +29,7 @@ pub fn response_to_v8<'a>(
}

pub fn response_from_v8<'a>(
scope: &mut v8::HandleScope<'a>,
scope: &mut v8::PinScope<'a, '_>,
response: v8::Local<'a, v8::Value>,
) -> Result<(Builder, Full<Bytes>, bool)> {
let response = match response.to_object(scope) {
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime_isolate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
v8 = "0.74.3"
v8 = "145.0.0"
tokio = { version = "1", features = ["rt-multi-thread"] }
futures = "0.3.28"
hyper = { version = "1.0" }
Expand Down
4 changes: 2 additions & 2 deletions crates/runtime_isolate/src/bindings/compression/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use lagoss_runtime_v8_utils::v8_string;
use uuid::Uuid;

fn compression_create(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
) -> Result<String> {
let format_string = args.get(0).to_rust_string_lossy(scope);
Expand Down Expand Up @@ -50,7 +50,7 @@ fn compression_create(
}

pub fn compression_create_binding(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
Expand Down
4 changes: 2 additions & 2 deletions crates/runtime_isolate/src/bindings/compression/finish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::Result;
use lagoss_runtime_v8_utils::{v8_exception, v8_uint8array};

fn compression_finish(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
) -> Result<Vec<u8>> {
let id = args.get(0).to_rust_string_lossy(scope);
Expand Down Expand Up @@ -32,7 +32,7 @@ fn compression_finish(
}

pub fn compression_finish_binding(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
Expand Down
4 changes: 2 additions & 2 deletions crates/runtime_isolate/src/bindings/compression/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use anyhow::Result;
use lagoss_runtime_v8_utils::{extract_v8_uint8array, v8_exception, v8_uint8array};

fn compression_write(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
) -> Result<Vec<u8>> {
let id = args.get(0).to_rust_string_lossy(scope);
Expand Down Expand Up @@ -54,7 +54,7 @@ fn compression_write(
}

pub fn compression_write_binding(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime_isolate/src/bindings/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use log::error;
use crate::Isolate;

pub fn console_binding(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
mut _retval: v8::ReturnValue,
) {
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime_isolate/src/bindings/crypto/decrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::bindings::{BindingResult, PromiseResult};
type Arg = (Algorithm, Vec<u8>, Vec<u8>);

pub fn decrypt_init(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
) -> Result<Arg> {
let algorithm = extract_algorithm_object(scope, args.get(0))?;
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime_isolate/src/bindings/crypto/derive_bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::bindings::{BindingResult, PromiseResult};
type Arg = (DeriveAlgorithm, Vec<u8>, u32);

pub fn derive_bits_init(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
) -> Result<Arg> {
let algorithm = extract_derive_algorithm(scope, args.get(0))?;
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime_isolate/src/bindings/crypto/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::bindings::{BindingResult, PromiseResult};
type Arg = (String, Vec<u8>);

pub fn digest_init(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
) -> Result<Arg> {
let name = extract_algorithm_object_or_string(scope, args.get(0))?;
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime_isolate/src/bindings/crypto/encrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::bindings::{BindingResult, PromiseResult};
type Arg = (Algorithm, Vec<u8>, Vec<u8>);

pub fn encrypt_init(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
) -> Result<Arg> {
let algorithm = extract_algorithm_object(scope, args.get(0))?;
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime_isolate/src/bindings/crypto/generate_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::bindings::{BindingResult, PromiseResult};
type Arg = KeyGenAlgorithm;

pub fn generate_key_init(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
) -> Result<Arg> {
extract_generate_key_algorithm(scope, args.get(0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use lagoss_runtime_crypto::methods::get_key;
use lagoss_runtime_v8_utils::v8_uint8array;

pub fn get_key_value_binding(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
_args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
Expand Down
4 changes: 2 additions & 2 deletions crates/runtime_isolate/src/bindings/crypto/random_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use lagoss_runtime_crypto::methods::random_values;
use lagoss_runtime_v8_utils::{v8_exception, v8_integer};

pub fn random_values_binding(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
mut _retval: v8::ReturnValue,
) {
Expand All @@ -14,7 +14,7 @@ pub fn random_values_binding(
return;
}

let chunk = unsafe { v8::Local::<v8::TypedArray>::cast(value) };
let chunk: v8::Local<v8::TypedArray> = value.cast();
let mut buf = vec![0; chunk.byte_length()];
chunk.copy_contents(&mut buf);

Expand Down
2 changes: 1 addition & 1 deletion crates/runtime_isolate/src/bindings/crypto/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::bindings::{BindingResult, PromiseResult};

type Arg = (Algorithm, Vec<u8>, Vec<u8>);

pub fn sign_init(scope: &mut v8::HandleScope, args: v8::FunctionCallbackArguments) -> Result<Arg> {
pub fn sign_init(scope: &mut v8::PinScope<'_, '_>, args: v8::FunctionCallbackArguments) -> Result<Arg> {
let algorithm = extract_sign_verify_algorithm(scope, args.get(0))?;
let key_value = extract_cryptokey_key_value(scope, args.get(1))?;
let data = extract_v8_uint8array(args.get(2))?;
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime_isolate/src/bindings/crypto/uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use lagoss_runtime_crypto::methods::uuid;
use lagoss_runtime_v8_utils::v8_string;

pub fn uuid_binding(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
_args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
) {
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime_isolate/src/bindings/crypto/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::bindings::{BindingResult, PromiseResult};
type Arg = (Algorithm, Vec<u8>, Vec<u8>, Vec<u8>);

pub fn verify_init(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
) -> Result<Arg> {
let algorithm = extract_sign_verify_algorithm(scope, args.get(0))?;
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime_isolate/src/bindings/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static CLIENT: OnceLock<Client> = OnceLock::new();

type Arg = Request<String>;

pub fn fetch_init(scope: &mut v8::HandleScope, args: v8::FunctionCallbackArguments) -> Result<Arg> {
pub fn fetch_init(scope: &mut v8::PinScope<'_, '_>, args: v8::FunctionCallbackArguments) -> Result<Arg> {
let id = scope
.get_continuation_preserved_embedder_data()
.to_uint32(scope)
Expand Down
14 changes: 10 additions & 4 deletions crates/runtime_isolate/src/bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub enum PromiseResult {
}

impl PromiseResult {
pub fn into_value<'a>(self, scope: &mut v8::HandleScope<'a>) -> v8::Local<'a, v8::Value> {
pub fn into_value<'a>(self, scope: &mut v8::PinScope<'a, '_>) -> v8::Local<'a, v8::Value> {
match self {
PromiseResult::Response(response) => response_to_v8(response, scope).into(),
PromiseResult::ArrayBuffer(bytes) => v8_uint8array(scope, bytes).into(),
Expand Down Expand Up @@ -70,7 +70,7 @@ macro_rules! binding {

macro_rules! async_binding {
($scope: ident, $lagoss_object: ident, $name: literal, $init: expr, $binding: expr) => {
let binding = |scope: &mut v8::HandleScope,
let binding = |scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue| {
let promise = v8::PromiseResolver::new(scope).unwrap();
Expand Down Expand Up @@ -108,7 +108,7 @@ macro_rules! async_binding {
}

pub fn bind<'a>(
scope: &mut v8::HandleScope<'a, ()>,
scope: &mut v8::PinScope<'a, '_, ()>,
bind_strategy: BindStrategy,
) -> v8::Local<'a, v8::Context> {
let global = v8::ObjectTemplate::new(scope);
Expand Down Expand Up @@ -192,5 +192,11 @@ pub fn bind<'a>(
global.set(v8_string(scope, "LagossAsync").into(), lagoss_object.into());
}

v8::Context::new_from_template(scope, global)
v8::Context::new(
scope,
v8::ContextOptions {
global_template: Some(global),
..Default::default()
},
)
}
2 changes: 1 addition & 1 deletion crates/runtime_isolate/src/bindings/pull_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use lagoss_runtime_v8_utils::{extract_v8_uint8array, v8_exception};
use crate::Isolate;

pub fn pull_stream_binding(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
mut _retval: v8::ReturnValue,
) {
Expand Down
4 changes: 2 additions & 2 deletions crates/runtime_isolate/src/bindings/queue_microtask.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use lagoss_runtime_v8_utils::v8_exception;

pub fn queue_microtask_binding(
scope: &mut v8::HandleScope,
scope: &mut v8::PinScope<'_, '_>,
args: v8::FunctionCallbackArguments,
mut _retval: v8::ReturnValue,
) {
Expand All @@ -12,6 +12,6 @@ pub fn queue_microtask_binding(
scope.throw_exception(exception);
}

let function = unsafe { v8::Local::<v8::Function>::cast(value) };
let function: v8::Local<v8::Function> = value.cast();
scope.enqueue_microtask(function);
}
2 changes: 1 addition & 1 deletion crates/runtime_isolate/src/bindings/sleep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use super::BindingResult;

type Arg = u64;

pub fn sleep_init(scope: &mut v8::HandleScope, args: v8::FunctionCallbackArguments) -> Result<Arg> {
pub fn sleep_init(scope: &mut v8::PinScope<'_, '_>, args: v8::FunctionCallbackArguments) -> Result<Arg> {
match args.get(0).to_int32(scope) {
Some(delay) => Ok(delay.value() as u64),
None => Err(anyhow!("Invalid delay")),
Expand Down
Loading
Loading