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. --- cli/napi/node_api.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'cli/napi/node_api.rs') diff --git a/cli/napi/node_api.rs b/cli/napi/node_api.rs index 268715fa8..81cb800a7 100644 --- a/cli/napi/node_api.rs +++ b/cli/napi/node_api.rs @@ -426,22 +426,14 @@ fn napi_get_buffer_info( let env = check_env!(env); check_arg!(env, value); + // NB: Any TypedArray instance seems to be accepted by this function + // in Node.js. let Some(ta) = value.and_then(|v| v8::Local::::try_from(v).ok()) else { return napi_set_last_error(env, napi_invalid_arg); }; - let buffer_constructor = - v8::Local::new(&mut env.scope(), &env.buffer_constructor); - - if !ta - .instance_of(&mut env.scope(), buffer_constructor.into()) - .unwrap_or(false) - { - return napi_set_last_error(env, napi_invalid_arg); - } - if !data.is_null() { unsafe { *data = ta.data(); -- cgit v1.2.3