--- remote/node_modules/nan/nan_implementation_12_inl.h.orig 2026-06-04 08:41:57 UTC +++ remote/node_modules/nan/nan_implementation_12_inl.h @@ -14,6 +14,22 @@ namespace imp { namespace imp { +// Recent V8 versions (currently Chromium/Electron's V8 snapshot; not yet in +// any released Node) gained an ExternalPointerTypeTag parameter on +// v8::External::New(). Detect that API via the V8_EXTERNAL_POINTER_TAG_COUNT +// macro (defined in alongside the new signature) rather than +// a V8_MAJOR_VERSION cutoff, since Node and Chromium ship divergent V8 +// snapshots under the same major version. Externals created via this helper +// are read back through imp::GetExternalPointer in nan_callbacks_12_inl.h, +// which uses the matching kExternalPointerTypeTagDefault tag. +inline v8::Local NewExternal(v8::Isolate* isolate, void* value) { +#ifdef V8_EXTERNAL_POINTER_TAG_COUNT + return v8::External::New(isolate, value, v8::kExternalPointerTypeTagDefault); +#else + return v8::External::New(isolate, value); +#endif +} + //=== Array ==================================================================== Factory::return_t @@ -76,7 +92,7 @@ Factory::New(void * value) { Factory::return_t Factory::New(void * value) { - return v8::External::New(v8::Isolate::GetCurrent(), value); + return imp::NewExternal(v8::Isolate::GetCurrent(), value); } //=== Function ================================================================= @@ -92,7 +108,7 @@ Factory::New( FunctionCallback callback obj->SetInternalField( imp::kFunctionIndex - , v8::External::New(isolate, reinterpret_cast(callback))); + , imp::NewExternal(isolate, reinterpret_cast(callback))); v8::Local val = v8::Local::New(isolate, data); @@ -128,7 +144,7 @@ Factory::New( FunctionCallback c obj->SetInternalField( imp::kFunctionIndex - , v8::External::New(isolate, reinterpret_cast(callback))); + , imp::NewExternal(isolate, reinterpret_cast(callback))); v8::Local val = v8::Local::New(isolate, data); if (!val.IsEmpty()) {