From 293a36f98d3614368d24f7804d2fc4191a54c0e3 Mon Sep 17 00:00:00 2001 From: snek Date: Wed, 19 Jun 2024 11:33:46 -0700 Subject: fix: more node-api fixes (#24220) - add fallback impls of external string apis which always copy. after upstream changes to rusty_v8 we can support non-copying api as well. - `napi_get_buffer_data` needs to work on all TypedArray instances. - Fixes: https://github.com/denoland/deno/issues/24209 - `target_defaults.default_configuration` is used by some modules to find the corresponding node file from node-gyp - `node_api_get_module_filename` expects the filename to be a `file:` url. --- ext/napi/lib.rs | 6 +++++- ext/node/polyfills/process.ts | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/napi/lib.rs b/ext/napi/lib.rs index 402785ce8..829839838 100644 --- a/ext/napi/lib.rs +++ b/ext/napi/lib.rs @@ -9,6 +9,7 @@ use core::ptr::NonNull; use deno_core::error::type_error; use deno_core::error::AnyError; use deno_core::op2; +use deno_core::url::Url; use deno_core::ExternalOpsTracker; use deno_core::OpState; use deno_core::V8CrossThreadTaskSpawner; @@ -528,7 +529,10 @@ where let type_tag = v8::Private::new(scope, Some(type_tag_name)); let type_tag = v8::Global::new(scope, type_tag); - let env_shared = EnvShared::new(napi_wrap, type_tag, path.clone()); + let url_filename = + Url::from_file_path(&path).map_err(|_| type_error("Invalid path"))?; + let env_shared = + EnvShared::new(napi_wrap, type_tag, format!("{url_filename}\0")); let ctx = scope.get_current_context(); let mut env = Env::new( diff --git a/ext/node/polyfills/process.ts b/ext/node/polyfills/process.ts index bec62122b..02837f827 100644 --- a/ext/node/polyfills/process.ts +++ b/ext/node/polyfills/process.ts @@ -403,7 +403,9 @@ Process.prototype.chdir = chdir; /** https://nodejs.org/api/process.html#processconfig */ Process.prototype.config = { - target_defaults: {}, + target_defaults: { + default_configuration: "Release", + }, variables: {}, }; -- cgit v1.2.3