diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e8872af..9532f184 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [24.x, 23.x, 22.x, 21.x, 20.x, 19.x, 18.x, 17.x, 16.x] + node-version: [25.x, 24.x, 23.x, 22.x, 21.x, 20.x, 19.x, 18.x, 17.x, 16.x] os: [windows-latest] include: - node-version: lts/* @@ -35,6 +35,8 @@ jobs: os: ubuntu-24.04-arm # Linux on arm64 - node-version: lts/* os: windows-2025 + - node-version: lts/* + os: windows-11-arm # Windows on arm64 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 diff --git a/appveyor.yml b/appveyor.yml index 338a8d5b..b00b646c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,17 +14,6 @@ image: environment: NODE_GYP_FORCE_PYTHON: C:\Python39-x64\python.exe matrix: # Test against these versions of Io.js and Node.js. - - nodejs_version: "24" - - nodejs_version: "23" - - nodejs_version: "22" - - nodejs_version: "22" - NODE_GYP_FORCE_PYTHON: C:\Python312-x64\python.exe - - nodejs_version: "21" - - nodejs_version: "20" - - nodejs_version: "19" - - nodejs_version: "18" - - nodejs_version: "17" - - nodejs_version: "16" - nodejs_version: "14" APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - nodejs_version: "12" diff --git a/nan.h b/nan.h index f0bfc0c6..fd2b2b24 100644 --- a/nan.h +++ b/nan.h @@ -427,15 +427,12 @@ template class WeakCallbackInfo; namespace imp { static const size_t kMaxLength = 0x3fffffff; - // v8::String::REPLACE_INVALID_UTF8 was introduced - // in node.js v0.10.29 and v0.8.27. -#if NODE_MAJOR_VERSION > 0 || \ - NODE_MINOR_VERSION > 10 || \ - NODE_MINOR_VERSION == 10 && NODE_PATCH_VERSION >= 29 || \ - NODE_MINOR_VERSION == 8 && NODE_PATCH_VERSION >= 27 - static const unsigned kReplaceInvalidUtf8 = v8::String::REPLACE_INVALID_UTF8; +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 13 || \ + (V8_MAJOR_VERSION == 13 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 4)) + static const unsigned kReplaceInvalidUtf8 + = v8::String::WriteFlags::kReplaceInvalidUtf8; #else - static const unsigned kReplaceInvalidUtf8 = 0; + static const unsigned kReplaceInvalidUtf8 = v8::String::REPLACE_INVALID_UTF8; #endif } // end of namespace imp @@ -1167,11 +1164,18 @@ class Utf8String { str_ = static_cast(malloc(len)); assert(str_ != 0); } - const int flags = - v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8; #if NODE_MAJOR_VERSION >= 11 - length_ = string->WriteUtf8(v8::Isolate::GetCurrent(), str_, +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 13 || \ + (V8_MAJOR_VERSION == 13 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 4)) + length_ = string->WriteUtf8V2(v8::Isolate::GetCurrent(), str_, + static_cast(len), imp::kReplaceInvalidUtf8); +#else + const int flags = + v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8; + length_ = string->WriteUtf8(v8::Isolate::GetCurrent(), str_, static_cast(len), 0, flags); +#endif + #else // See https://github.com/nodejs/nan/issues/832. // Disable the warning as there is no way around it. @@ -1183,7 +1187,9 @@ class Utf8String { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif - length_ = string->WriteUtf8(str_, static_cast(len), 0, flags); + const int flags = + v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8; + length_ = string->WriteUtf8(str_, static_cast(len), 0, flags); #ifdef __GNUC__ #pragma GCC diagnostic pop #endif @@ -2626,7 +2632,9 @@ NAN_DEPRECATED inline void SetAccessor( , getter_ , setter_ , obj -#if !defined(V8_MAJOR_VERSION) || V8_MAJOR_VERSION < 12 +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION < 12 \ + || (V8_MAJOR_VERSION == 12 && defined(V8_MINOR_VERSION) \ + && V8_MINOR_VERSION == 0)) , settings #endif , attribute @@ -2680,7 +2688,9 @@ inline void SetAccessor( , getter_ , setter_ , obj -#if !defined(V8_MAJOR_VERSION) || V8_MAJOR_VERSION < 12 +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION < 12 \ + || (V8_MAJOR_VERSION == 12 && defined(V8_MINOR_VERSION) \ + && V8_MINOR_VERSION == 0)) , settings #endif , attribute diff --git a/nan_maybe_43_inl.h b/nan_maybe_43_inl.h index f37ce973..48b62e9d 100644 --- a/nan_maybe_43_inl.h +++ b/nan_maybe_43_inl.h @@ -207,7 +207,11 @@ inline Maybe SetPrototype( , v8::Local prototype) { v8::Isolate *isolate = v8::Isolate::GetCurrent(); v8::HandleScope scope(isolate); - return obj->SetPrototype(isolate->GetCurrentContext(), prototype); +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION >= 14) + return obj->SetPrototypeV2(isolate->GetCurrentContext(), prototype); +#else + return obj->SetPrototype(isolate->GetCurrentContext(), prototype); +#endif } inline MaybeLocal ObjectProtoToString(