diff --git a/Cargo.lock b/Cargo.lock index af01744264..fc056d8232 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1196,9 +1196,9 @@ dependencies = [ [[package]] name = "deno_core" -version = "0.255.0" +version = "0.256.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66349d0fd8e9cad751435b59cf9e09e9fad9433301e9529ca4edf130ea3a06a0" +checksum = "cd5997286bcc46199bbae727f43ee65cf4bd073ac2d240a36a6ceae3bfab14ac" dependencies = [ "anyhow", "bit-set", @@ -1653,9 +1653,9 @@ dependencies = [ [[package]] name = "deno_ops" -version = "0.131.0" +version = "0.132.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3363343cd15758aa02792e93b53b1def9cf1e8b23dd82bdce0f223e6046e76" +checksum = "02163d08afdd6fcf21e37c399c7425987c7170203a853052a800e80c91c2e87b" dependencies = [ "proc-macro-rules", "proc-macro2", @@ -5357,9 +5357,9 @@ dependencies = [ [[package]] name = "serde_v8" -version = "0.164.0" +version = "0.165.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f96a94476f3d22fe9f70c2d992d020173ccd61ad6fa1b62ed8090abe835c4e9f" +checksum = "88862d513bcbc04a7f93b0f454dffd0b01a5c0d8e1964c7532ec55f52b9a6351" dependencies = [ "bytes", "derive_more", diff --git a/Cargo.toml b/Cargo.toml index 3de8949e82..2afb6c9a51 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ repository = "https://github.com/denoland/deno" [workspace.dependencies] deno_ast = { version = "0.32.0", features = ["transpiling"] } -deno_core = { version = "0.255.0" } +deno_core = { version = "0.256.0" } deno_bench_util = { version = "0.129.0", path = "./bench_util" } deno_lockfile = "0.18.0" diff --git a/cli/module_loader.rs b/cli/module_loader.rs index 21ceee1097..e6329a0ecf 100644 --- a/cli/module_loader.rs +++ b/cli/module_loader.rs @@ -653,16 +653,16 @@ impl ModuleLoader for CliModuleLoader { maybe_referrer: Option<&ModuleSpecifier>, is_dynamic: bool, requested_module_type: RequestedModuleType, - ) -> Pin> { + ) -> deno_core::ModuleLoadResponse { // NOTE: this block is async only because of `deno_core` interface // requirements; module was already loaded when constructing module graph // during call to `prepare_load` so we can load it synchronously. - Box::pin(deno_core::futures::future::ready(self.load_sync( + deno_core::ModuleLoadResponse::Sync(self.load_sync( specifier, maybe_referrer, is_dynamic, requested_module_type, - ))) + )) } fn prepare_load( diff --git a/cli/standalone/mod.rs b/cli/standalone/mod.rs index 88e45161c0..f3763004cc 100644 --- a/cli/standalone/mod.rs +++ b/cli/standalone/mod.rs @@ -53,7 +53,6 @@ use deno_runtime::permissions::PermissionsContainer; use deno_runtime::WorkerLogLevel; use deno_semver::npm::NpmPackageReqReference; use import_map::parse_from_json; -use std::pin::Pin; use std::rc::Rc; use std::sync::Arc; @@ -150,16 +149,16 @@ impl ModuleLoader for EmbeddedModuleLoader { maybe_referrer: Option<&ModuleSpecifier>, is_dynamic: bool, _requested_module_type: RequestedModuleType, - ) -> Pin> { + ) -> deno_core::ModuleLoadResponse { let is_data_uri = get_source_from_data_url(original_specifier).ok(); if let Some((source, _)) = is_data_uri { - return Box::pin(deno_core::futures::future::ready(Ok( + return deno_core::ModuleLoadResponse::Sync(Ok( deno_core::ModuleSource::new( deno_core::ModuleType::JavaScript, ModuleSourceCode::String(source.into()), original_specifier, ), - ))); + )); } let permissions = if is_dynamic { @@ -175,7 +174,7 @@ impl ModuleLoader for EmbeddedModuleLoader { ) { return match result { - Ok(code_source) => Box::pin(deno_core::futures::future::ready(Ok( + Ok(code_source) => deno_core::ModuleLoadResponse::Sync(Ok( deno_core::ModuleSource::new_with_redirect( match code_source.media_type { MediaType::Json => ModuleType::Json, @@ -185,45 +184,48 @@ impl ModuleLoader for EmbeddedModuleLoader { original_specifier, &code_source.found_url, ), - ))), - Err(err) => Box::pin(deno_core::futures::future::ready(Err(err))), + )), + Err(err) => deno_core::ModuleLoadResponse::Sync(Err(err)), }; } let Some(module) = self.shared.eszip.get_module(original_specifier.as_str()) else { - return Box::pin(deno_core::futures::future::ready(Err(type_error( - format!("Module not found: {}", original_specifier), + return deno_core::ModuleLoadResponse::Sync(Err(type_error(format!( + "Module not found: {}", + original_specifier )))); }; let original_specifier = original_specifier.clone(); let found_specifier = ModuleSpecifier::parse(&module.specifier).expect("invalid url in eszip"); - async move { - let code = module.source().await.ok_or_else(|| { - type_error(format!("Module not found: {}", original_specifier)) - })?; - let code = arc_u8_to_arc_str(code) - .map_err(|_| type_error("Module source is not utf-8"))?; - Ok(deno_core::ModuleSource::new_with_redirect( - match module.kind { - eszip::ModuleKind::JavaScript => ModuleType::JavaScript, - eszip::ModuleKind::Json => ModuleType::Json, - eszip::ModuleKind::Jsonc => { - return Err(type_error("jsonc modules not supported")) - } - eszip::ModuleKind::OpaqueData => { - unreachable!(); - } - }, - ModuleSourceCode::String(code.into()), - &original_specifier, - &found_specifier, - )) - } - .boxed_local() + deno_core::ModuleLoadResponse::Async( + async move { + let code = module.source().await.ok_or_else(|| { + type_error(format!("Module not found: {}", original_specifier)) + })?; + let code = arc_u8_to_arc_str(code) + .map_err(|_| type_error("Module source is not utf-8"))?; + Ok(deno_core::ModuleSource::new_with_redirect( + match module.kind { + eszip::ModuleKind::JavaScript => ModuleType::JavaScript, + eszip::ModuleKind::Json => ModuleType::Json, + eszip::ModuleKind::Jsonc => { + return Err(type_error("jsonc modules not supported")) + } + eszip::ModuleKind::OpaqueData => { + unreachable!(); + } + }, + ModuleSourceCode::String(code.into()), + &original_specifier, + &found_specifier, + )) + } + .boxed_local(), + ) } } diff --git a/ext/node/ops/crypto/x509.rs b/ext/node/ops/crypto/x509.rs index 2e0aec011a..eefe1c6d0e 100644 --- a/ext/node/ops/crypto/x509.rs +++ b/ext/node/ops/crypto/x509.rs @@ -1,6 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -use deno_core::error::bad_resource_id; use deno_core::error::AnyError; use deno_core::op2; use deno_core::v8; @@ -14,7 +13,7 @@ use x509_parser::prelude::*; use digest::Digest; -struct Certificate { +pub(crate) struct Certificate { _buf: Vec, pem: Option, cert: X509Certificate<'static>, @@ -73,20 +72,15 @@ pub fn op_node_x509_parse<'s>( } #[op2(fast)] -pub fn op_node_x509_ca(rid: v8::Local) -> Result { - let cert = deno_core::cppgc::unwrap_cppgc_object::(rid) - .ok_or_else(bad_resource_id)?; +pub fn op_node_x509_ca(#[cppgc] cert: &Certificate) -> Result { Ok(cert.is_ca()) } #[op2(fast)] pub fn op_node_x509_check_email( - rid: v8::Local, + #[cppgc] cert: &Certificate, #[string] email: &str, ) -> Result { - let cert = deno_core::cppgc::unwrap_cppgc_object::(rid) - .ok_or_else(bad_resource_id)?; - let subject = cert.subject(); if subject .iter_email() @@ -120,50 +114,40 @@ pub fn op_node_x509_check_email( #[op2] #[string] pub fn op_node_x509_fingerprint( - rid: v8::Local, + #[cppgc] cert: &Certificate, ) -> Result, AnyError> { - let cert = deno_core::cppgc::unwrap_cppgc_object::(rid) - .ok_or_else(bad_resource_id)?; Ok(cert.fingerprint::()) } #[op2] #[string] pub fn op_node_x509_fingerprint256( - rid: v8::Local, + #[cppgc] cert: &Certificate, ) -> Result, AnyError> { - let cert = deno_core::cppgc::unwrap_cppgc_object::(rid) - .ok_or_else(bad_resource_id)?; Ok(cert.fingerprint::()) } #[op2] #[string] pub fn op_node_x509_fingerprint512( - rid: v8::Local, + #[cppgc] cert: &Certificate, ) -> Result, AnyError> { - let cert = deno_core::cppgc::unwrap_cppgc_object::(rid) - .ok_or_else(bad_resource_id)?; Ok(cert.fingerprint::()) } #[op2] #[string] pub fn op_node_x509_get_issuer( - rid: v8::Local, + #[cppgc] cert: &Certificate, ) -> Result { - let cert = deno_core::cppgc::unwrap_cppgc_object::(rid) - .ok_or_else(bad_resource_id)?; Ok(x509name_to_string(cert.issuer(), oid_registry())?) } #[op2] #[string] pub fn op_node_x509_get_subject( - rid: v8::Local, + #[cppgc] cert: &Certificate, ) -> Result { - let cert = deno_core::cppgc::unwrap_cppgc_object::(rid) - .ok_or_else(bad_resource_id)?; Ok(x509name_to_string(cert.subject(), oid_registry())?) } @@ -230,30 +214,24 @@ fn x509name_to_string( #[op2] #[string] pub fn op_node_x509_get_valid_from( - rid: v8::Local, + #[cppgc] cert: &Certificate, ) -> Result { - let cert = deno_core::cppgc::unwrap_cppgc_object::(rid) - .ok_or_else(bad_resource_id)?; Ok(cert.validity().not_before.to_string()) } #[op2] #[string] pub fn op_node_x509_get_valid_to( - rid: v8::Local, + #[cppgc] cert: &Certificate, ) -> Result { - let cert = deno_core::cppgc::unwrap_cppgc_object::(rid) - .ok_or_else(bad_resource_id)?; Ok(cert.validity().not_after.to_string()) } #[op2] #[string] pub fn op_node_x509_get_serial_number( - rid: v8::Local, + #[cppgc] cert: &Certificate, ) -> Result { - let cert = deno_core::cppgc::unwrap_cppgc_object::(rid) - .ok_or_else(bad_resource_id)?; let mut s = cert.serial.to_str_radix(16); s.make_ascii_uppercase(); Ok(s) @@ -261,11 +239,8 @@ pub fn op_node_x509_get_serial_number( #[op2(fast)] pub fn op_node_x509_key_usage( - rid: v8::Local, + #[cppgc] cert: &Certificate, ) -> Result { - let cert = deno_core::cppgc::unwrap_cppgc_object::(rid) - .ok_or_else(bad_resource_id)?; - let key_usage = cert .extensions() .iter()