diff --git a/Cargo.lock b/Cargo.lock index 266ad8f740a5f..27a59c7e86fd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -749,12 +749,22 @@ dependencies = [ "data-url", "deno_ast", "deno_bench_util", + "deno_broadcast_channel", + "deno_console", "deno_core", + "deno_crypto", "deno_doc", + "deno_fetch", "deno_graph", "deno_lint", + "deno_net", "deno_runtime", "deno_task_shell", + "deno_url", + "deno_web", + "deno_webgpu", + "deno_websocket", + "deno_webstorage", "dissimilar", "dprint-plugin-json", "dprint-plugin-markdown", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index e79431e862df6..5920ffacb2bc8 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -25,10 +25,20 @@ harness = false path = "./bench/lsp_bench_standalone.rs" [build-dependencies] +deno_broadcast_channel = { version = "0.35.0", path = "../ext/broadcast_channel" } +deno_console = { version = "0.41.0", path = "../ext/console" } deno_core = { version = "0.123.0", path = "../core" } +deno_crypto = { version = "0.55.0", path = "../ext/crypto" } +deno_fetch = { version = "0.64.0", path = "../ext/fetch" } +deno_net = { version = "0.33.0", path = "../ext/net" } +deno_url = { version = "0.41.0", path = "../ext/url" } +deno_web = { version = "0.72.0", path = "../ext/web" } +deno_webgpu = { version = "0.42.0", path = "../ext/webgpu" } +deno_websocket = { version = "0.46.0", path = "../ext/websocket" } +deno_webstorage = { version = "0.36.0", path = "../ext/webstorage" } regex = "=1.5.5" serde = { version = "=1.0.133", features = ["derive"] } -zstd = { version = '=0.9.2', default-features = false } +zstd = '=0.9.2' [target.'cfg(windows)'.build-dependencies] winapi = "=0.3.9" @@ -88,7 +98,7 @@ tokio-util = "=0.6.9" typed-arena = "2.0.1" uuid = { version = "=0.8.2", features = ["v4", "serde"] } walkdir = "=2.3.2" -zstd = { version = '=0.9.2', default-features = false } +zstd = '=0.9.2' [target.'cfg(windows)'.dependencies] fwdansi = "=1.1.0" diff --git a/cli/build.rs b/cli/build.rs index 7b56dbcbd0522..01c0a13582353 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -81,33 +81,22 @@ fn create_compiler_snapshot( ) { // libs that are being provided by op crates. let mut op_crate_libs = HashMap::new(); - op_crate_libs.insert("deno.console", "../ext/console/lib.deno_console.d.ts"); - op_crate_libs.insert("deno.url", "../ext/url/lib.deno_url.d.ts"); - op_crate_libs.insert("deno.web", "../ext/web/lib.deno_web.d.ts"); - op_crate_libs.insert("deno.fetch", "../ext/fetch/lib.deno_fetch.d.ts"); - op_crate_libs.insert("deno.webgpu", "./dts/lib.deno_webgpu.d.ts"); - op_crate_libs - .insert("deno.websocket", "../ext/websocket/lib.deno_websocket.d.ts"); - op_crate_libs.insert( - "deno.webstorage", - "../ext/webstorage/lib.deno_webstorage.d.ts", - ); - op_crate_libs.insert("deno.crypto", "../ext/crypto/lib.deno_crypto.d.ts"); + op_crate_libs.insert("deno.console", deno_console::get_declaration()); + op_crate_libs.insert("deno.url", deno_url::get_declaration()); + op_crate_libs.insert("deno.web", deno_web::get_declaration()); + op_crate_libs.insert("deno.fetch", deno_fetch::get_declaration()); + op_crate_libs.insert("deno.webgpu", deno_webgpu_get_declaration()); + op_crate_libs.insert("deno.websocket", deno_websocket::get_declaration()); + op_crate_libs.insert("deno.webstorage", deno_webstorage::get_declaration()); + op_crate_libs.insert("deno.crypto", deno_crypto::get_declaration()); op_crate_libs.insert( "deno.broadcast_channel", - "../ext/broadcast_channel/lib.deno_broadcast_channel.d.ts", + deno_broadcast_channel::get_declaration(), ); - op_crate_libs.insert("deno.net", "../ext/net/lib.deno_net.d.ts"); + op_crate_libs.insert("deno.net", deno_net::get_declaration()); + // ensure we invalidate the build properly. - for (name, path) in op_crate_libs.iter() { - let path = std::fs::canonicalize(path) - .map_err(|e| format!("{}: {}", path, e)) - .unwrap(); - println!( - "cargo:rustc-env={}_LIB_PATH={}", - name.replace('.', "_").to_uppercase(), - path.display() - ); + for (_, path) in op_crate_libs.iter() { println!("cargo:rerun-if-changed={}", path.display()); } @@ -248,12 +237,6 @@ fn create_compiler_snapshot( // this corresponds to `ts.ScriptKind.TypeScript` "scriptKind": 3 })) - } else { - Err(custom_error( - "InvalidSpecifier", - format!("An invalid specifier was requested: {}", args.specifier), - )) - } } else { Err(custom_error( "InvalidSpecifier", @@ -339,13 +322,55 @@ fn main() { println!("cargo:rustc-env=DENO_CANARY={}", c); } println!("cargo:rerun-if-env-changed=DENO_CANARY"); + println!("cargo:rustc-env=GIT_COMMIT_HASH={}", git_commit_hash()); println!("cargo:rerun-if-env-changed=GIT_COMMIT_HASH"); println!("cargo:rustc-env=TS_VERSION={}", ts_version()); println!("cargo:rerun-if-env-changed=TS_VERSION"); - println!("cargo:rustc-env=TARGET={}", target); + println!( + "cargo:rustc-env=DENO_CONSOLE_LIB_PATH={}", + deno_console::get_declaration().display() + ); + println!( + "cargo:rustc-env=DENO_URL_LIB_PATH={}", + deno_url::get_declaration().display() + ); + println!( + "cargo:rustc-env=DENO_WEB_LIB_PATH={}", + deno_web::get_declaration().display() + ); + println!( + "cargo:rustc-env=DENO_FETCH_LIB_PATH={}", + deno_fetch::get_declaration().display() + ); + println!( + "cargo:rustc-env=DENO_WEBGPU_LIB_PATH={}", + deno_webgpu_get_declaration().display() + ); + println!( + "cargo:rustc-env=DENO_WEBSOCKET_LIB_PATH={}", + deno_websocket::get_declaration().display() + ); + println!( + "cargo:rustc-env=DENO_WEBSTORAGE_LIB_PATH={}", + deno_webstorage::get_declaration().display() + ); + println!( + "cargo:rustc-env=DENO_CRYPTO_LIB_PATH={}", + deno_crypto::get_declaration().display() + ); + println!( + "cargo:rustc-env=DENO_BROADCAST_CHANNEL_LIB_PATH={}", + deno_broadcast_channel::get_declaration().display() + ); + println!( + "cargo:rustc-env=DENO_NET_LIB_PATH={}", + deno_net::get_declaration().display() + ); + + println!("cargo:rustc-env=TARGET={}", env::var("TARGET").unwrap()); println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").unwrap()); let c = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()); @@ -369,6 +394,11 @@ fn main() { } } +fn deno_webgpu_get_declaration() -> PathBuf { + let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); + manifest_dir.join("dts").join("lib.deno_webgpu.d.ts") +} + fn get_js_files(d: &str) -> Vec { let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); let mut js_files = std::fs::read_dir(d) diff --git a/ext/broadcast_channel/lib.rs b/ext/broadcast_channel/lib.rs index e228871b9d1b1..57287ffbce3ef 100644 --- a/ext/broadcast_channel/lib.rs +++ b/ext/broadcast_channel/lib.rs @@ -15,6 +15,7 @@ use deno_core::Resource; use deno_core::ResourceId; use deno_core::ZeroCopyBuf; use std::cell::RefCell; +use std::path::PathBuf; use std::rc::Rc; #[async_trait] @@ -126,3 +127,8 @@ pub fn init( }) .build() } + +pub fn get_declaration() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("lib.deno_broadcast_channel.d.ts") +} diff --git a/ext/console/lib.rs b/ext/console/lib.rs index 03b3a79c04a26..6c5bba9fa9166 100644 --- a/ext/console/lib.rs +++ b/ext/console/lib.rs @@ -2,6 +2,7 @@ use deno_core::include_js_files; use deno_core::Extension; +use std::path::PathBuf; pub fn init() -> Extension { Extension::builder() @@ -12,3 +13,7 @@ pub fn init() -> Extension { )) .build() } + +pub fn get_declaration() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_console.d.ts") +} diff --git a/ext/crypto/lib.rs b/ext/crypto/lib.rs index a2dc8e6260ab7..3515013f8e8ba 100644 --- a/ext/crypto/lib.rs +++ b/ext/crypto/lib.rs @@ -51,6 +51,7 @@ use sha2::Sha256; use sha2::Sha384; use sha2::Sha512; use std::convert::TryFrom; +use std::path::PathBuf; pub use rand; // Re-export rand @@ -881,3 +882,7 @@ pub fn op_crypto_unwrap_key( _ => Err(type_error("Unsupported algorithm")), } } + +pub fn get_declaration() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_crypto.d.ts") +} diff --git a/ext/fetch/lib.rs b/ext/fetch/lib.rs index 59d5f9a6bc1ba..b744a9bbd6022 100644 --- a/ext/fetch/lib.rs +++ b/ext/fetch/lib.rs @@ -45,6 +45,7 @@ use std::borrow::Cow; use std::cell::RefCell; use std::convert::From; use std::path::Path; +use std::path::PathBuf; use std::pin::Pin; use std::rc::Rc; use tokio::io::AsyncReadExt; @@ -170,6 +171,10 @@ pub trait FetchPermissions { fn check_read(&mut self, _p: &Path) -> Result<(), AnyError>; } +pub fn get_declaration() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_fetch.d.ts") +} + #[derive(Deserialize)] #[serde(rename_all = "camelCase")] pub struct FetchArgs { diff --git a/ext/net/lib.rs b/ext/net/lib.rs index 84358210ec72a..c95348020b9e5 100644 --- a/ext/net/lib.rs +++ b/ext/net/lib.rs @@ -14,6 +14,7 @@ use deno_core::OpState; use deno_tls::rustls::RootCertStore; use std::cell::RefCell; use std::path::Path; +use std::path::PathBuf; use std::rc::Rc; pub trait NetPermissions { @@ -60,6 +61,10 @@ pub fn check_unstable2(state: &Rc>, api_name: &str) { state.borrow::().check_unstable(api_name) } +pub fn get_declaration() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_net.d.ts") +} + #[derive(Clone)] pub struct DefaultTlsOptions { pub root_cert_store: Option, diff --git a/ext/url/lib.rs b/ext/url/lib.rs index 0fa389fb0a129..46e363bc3d038 100644 --- a/ext/url/lib.rs +++ b/ext/url/lib.rs @@ -14,6 +14,7 @@ use deno_core::url::Url; use deno_core::Extension; use deno_core::ZeroCopyBuf; use std::panic::catch_unwind; +use std::path::PathBuf; use crate::urlpattern::op_urlpattern_parse; use crate::urlpattern::op_urlpattern_process_match_input; @@ -186,3 +187,7 @@ pub fn op_url_stringify_search_params( .finish(); Ok(search) } + +pub fn get_declaration() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_url.d.ts") +} diff --git a/ext/web/lib.rs b/ext/web/lib.rs index d199b7bfe360c..21fa285ba3089 100644 --- a/ext/web/lib.rs +++ b/ext/web/lib.rs @@ -27,6 +27,7 @@ use serde::Serialize; use std::borrow::Cow; use std::cell::RefCell; use std::fmt; +use std::path::PathBuf; use std::usize; use crate::blob::op_blob_create_object_url; @@ -352,6 +353,10 @@ fn op_encoding_encode_into( }) } +pub fn get_declaration() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_web.d.ts") +} + #[derive(Debug)] pub struct DomExceptionQuotaExceededError { pub msg: String, diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs index 0b94702748b1a..95afd79bd20db 100644 --- a/ext/websocket/lib.rs +++ b/ext/websocket/lib.rs @@ -33,6 +33,7 @@ use std::borrow::Cow; use std::cell::RefCell; use std::convert::TryFrom; use std::fmt; +use std::path::PathBuf; use std::rc::Rc; use std::sync::Arc; use tokio::net::TcpStream; @@ -505,6 +506,10 @@ pub fn init( .build() } +pub fn get_declaration() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_websocket.d.ts") +} + #[derive(Debug)] pub struct DomExceptionNetworkError { pub msg: String, diff --git a/ext/webstorage/lib.rs b/ext/webstorage/lib.rs index 8569fece66816..7cda0176a5b3a 100644 --- a/ext/webstorage/lib.rs +++ b/ext/webstorage/lib.rs @@ -43,6 +43,10 @@ pub fn init(origin_storage_dir: Option) -> Extension { .build() } +pub fn get_declaration() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_webstorage.d.ts") +} + struct LocalStorage(Connection); struct SessionStorage(Connection);