pax_global_header00006660000000000000000000000064151140333070014507gustar00rootroot0000000000000052 comment=5d0ff9c5afde2bb8a4092328118ec90aa7294770 nan-2.24.0/000077500000000000000000000000001511403330700123505ustar00rootroot00000000000000nan-2.24.0/.dntrc000066400000000000000000000013441511403330700134650ustar00rootroot00000000000000## DNT config file ## see https://github.com/rvagg/dnt NODE_VERSIONS="\ master \ v0.11.13 \ v0.10.30 \ v0.10.29 \ v0.10.28 \ v0.10.26 \ v0.10.25 \ v0.10.24 \ v0.10.23 \ v0.10.22 \ v0.10.21 \ v0.10.20 \ v0.10.19 \ v0.8.28 \ v0.8.27 \ v0.8.26 \ v0.8.24 \ " OUTPUT_PREFIX="nan-" TEST_CMD=" \ cd /dnt/ && \ npm install && \ node_modules/.bin/node-gyp --nodedir /usr/src/node/ rebuild --directory test && \ node_modules/.bin/tap --gc test/js/*-test.js \ " nan-2.24.0/.github/000077500000000000000000000000001511403330700137105ustar00rootroot00000000000000nan-2.24.0/.github/workflows/000077500000000000000000000000001511403330700157455ustar00rootroot00000000000000nan-2.24.0/.github/workflows/ci.yml000066400000000000000000000031561511403330700170700ustar00rootroot00000000000000# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs # https://github.com/actions/setup-node # https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories name: ci on: push: # branches: [main] pull_request: # branches: [main] workflow_dispatch: permissions: contents: read jobs: pre-commit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: pre-commit/action@v3.0.1 ci: strategy: fail-fast: false matrix: 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/* os: macos-15-intel # macOS on Intel - node-version: lts/* os: macos-latest # macOS on arm64 - node-version: lts/* os: ubuntu-latest # Linux on x64 - node-version: lts/* 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 - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: npm install # TODO: On Windows Node.js v11 these will fail but `make test` will succeed - if: matrix.node-version != '11.x' run: | npm run-script rebuild-tests npm test - run: make test nan-2.24.0/.gitignore000066400000000000000000000000241511403330700143340ustar00rootroot00000000000000build/ node_modules/nan-2.24.0/.npmignore000066400000000000000000000001331511403330700143440ustar00rootroot00000000000000test/ examples/ .dntrc .npmignore appveyor.yml Makefile cpplint.py nan-*.tgz doc/.build.sh nan-2.24.0/.pre-commit-config.yaml000066400000000000000000000003211511403330700166250ustar00rootroot00000000000000repos: - repo: https://github.com/cpplint/cpplint rev: 2.0.0 hooks: - id: cpplint args: - --filter=-whitespace/indent_namespace,-whitespace/parens - --linelength=88 nan-2.24.0/CHANGELOG.md000066400000000000000000000551451511403330700141730ustar00rootroot00000000000000# NAN ChangeLog **Version 2.24.0: current Node 25.2.1, Node 0.12: 0.12.18, Node 0.10: 0.10.48, iojs: 3.3.1** ### 2.24.0 Dec 03 2025 - Feature: Adding new Nan::TryEncode() wrapper for node::TryEncode() (#1005) fd5ff3f5ab3f5bb6bb6dd2d247f3eccd79227854 ### 2.23.1 Nov 05 2025 - Feature: Adding WriteUtf8V2() and SetPrototypeV2() methods to support v8 14.3 (#1004) 9e1106ab7b7036d262df7f430eee3bff33757e9a ### 2.23.0 Jul 10 2025 - Feature: Support Node 23 (#979) 59ab6d03d5d68554290ee9f34003cd90aa92c185 ### 2.22.2 Feb 26 2025 - Bugfix: Fix version guard for `ScriptOrigin` constructors (#989) 053239d73702ac11fa0c3c438f85c1409f960f89 ### 2.22.1 Feb 21 2025 - Build: Fix compatibility with Python >= 3.12 (#987) b5d90f15730b620fb6cc4fed079674740424539a ### 2.22.0 Oct 11 2024 - Feature: replace SetAccessor -> SetNativeDataProperty (#977) 6bd62c9a0004339d5d1e18a945c84929d0f6b808 ### 2.21.0 Oct 10 2024 - Feature: Support for node version 20.17.0 (#976) a7df36eda8a7fe8581c00a18590f5e4faafca7ae ### 2.20.0 Jun 12 2024 - Feature: fix removal of v8::CopyablePersistent (#970) 5805ca5c4c2eef9a65316b68741e29f4825c511f ### 2.19.0 Mar 6 2024 - Feature: Fix builds for Electron 29 (#966) 1b630ddb3412cde35b64513662b440f9fd71e1ff ### 2.18.0 Sep 12 2023 - Feature: Cast v8::Object::GetInternalField() return value to v8::Value (#956) bdfee1788239f735b67fe6b46b1439da755e9b62 ### 2.17.0 Oct 10 2022 - Feature: overload deprecated AccessorSignatures (#943) 7f9ceb80fbc45c9ba1a10e6591ccbef9e8dee6b4 ### 2.16.0 May 25 2022 - Feature: Add support for Node 18 (#937) 16fa32231e2ccd89d2804b3f765319128b20c4ac ### 2.15.0 Aug 4 2021 - Feature: add ScriptOrigin (#918) d09debf9eeedcb7ca4073e84ffe5fbb455ecb709 ### 2.14.2 Oct 13 2020 - Bugfix: fix gcc 8 function cast warning (#899) 35f0fab205574b2cbda04e6347c8b2db755e124f ### 2.14.1 Apr 21 2020 - Bugfix: use GetBackingStore() instead of GetContents() (#888) 2c023bd447661a61071da318b0ff4003c3858d39 ### 2.14.0 May 16 2019 - Feature: Add missing methods to Nan::Maybe (#852) 4e962489fb84a184035b9fa74f245f650249aca6 ### 2.13.2 Mar 24 2019 - Bugfix: remove usage of deprecated `IsNearDeath` (#842) fbaf42252af279c3d867c6b193571f9711c39847 ### 2.13.1 Mar 14 2019 - Bugfix: check V8 version directly instead of inferring from NMV (#840) 12f9df9f393285de8fb4a8cd01478dc4fe3b089d ### 2.13.0 Mar 13 2019 - Feature: add support for node master (#831) 113c0282072e7ff4f9dfc98b432fd894b798c2c ### 2.12.1 Dec 18 2018 - Bugfix: Fix build breakage with Node.js 10.0.0-10.9.0. (#833) 625e90e8fef8d39ffa7247250a76a100b2487474 ### 2.12.0 Dec 16 2018 - Bugfix: Add scope.Escape() to Call() (#817) 2e5ed4fc3a8ac80a6ef1f2a55099ab3ac8800dc6 - Bugfix: Fix Node.js v10.12.0 deprecation warnings. 509859cc23b1770376b56550a027840a2ce0f73d - Feature: Allow SetWeak() for non-object persistent handles. (#824) e6ef6a48e7e671fe3e4b7dddaa8912a3f8262ecd ### 2.11.1 Sep 29 2018 - Fix: adapt to V8 7.0 24a22c3b25eeeec2016c6ec239bdd6169e985447 ### 2.11.0 Aug 25 2018 - Removal: remove `FunctionCallbackInfo::Callee` for nodejs `>= 10` 1a56c0a6efd4fac944cb46c30912a8e023bda7d4 - Bugfix: Fix `AsyncProgressWorkerBase::WorkProgress` sends invalid data b0c764d1dab11e9f8b37ffb81e2560a4498aad5e - Feature: Introduce `GetCurrentEventLoop` b4911b0bb1f6d47d860e10ec014d941c51efac5e - Feature: Add `NAN_MODULE_WORKER_ENABLED` macro as a replacement for `NAN_MODULE` b058fb047d18a58250e66ae831444441c1f2ac7a ### 2.10.0 Mar 16 2018 - Deprecation: Deprecate `MakeCallback` 5e92b19a59e194241d6a658bd6ff7bfbda372950 - Feature: add `Nan::Call` overload 4482e1242fe124d166fc1a5b2be3c1cc849fe452 - Feature: add more `Nan::Call` overloads 8584e63e6d04c7d2eb8c4a664e4ef57d70bf672b - Feature: Fix deprecation warnings for Node 10 1caf258243b0602ed56922bde74f1c91b0cbcb6a ### 2.9.2 Feb 22 2018 - Bugfix: Bandaid for async hooks 212bd2f849be14ef1b02fc85010b053daa24252b ### 2.9.1 Feb 22 2018 - Bugfix: Avoid deprecation warnings in deprecated `Nan::Callback::operator()` 372b14d91289df4604b0f81780709708c45a9aa4 - Bugfix: Avoid deprecation warnings in `Nan::JSON` 3bc294bce0b7d0a3ee4559926303e5ed4866fda2 ### 2.9.0 Feb 22 2018 - Deprecation: Deprecate legacy `Callback::Call` 6dd5fa690af61ca3523004b433304c581b3ea309 - Feature: introduce `AsyncResource` class 90c0a179c0d8cb5fd26f1a7d2b1d6231eb402d48o - Feature: Add context aware `Nan::Callback::Call` functions 7169e09fb088418b6e388222e88b4c13f07ebaee - Feature: Make `AsyncWorker` context aware 066ba21a6fb9e2b5230c9ed3a6fc51f1211736a4 - Feature: add `Callback` overload to `Nan::Call` 5328daf66e202658c1dc0d916c3aaba99b3cc606 - Bugfix: fix warning: suggest parentheses around `&&` within `||` b2bb63d68b8ae623a526b542764e1ac82319cb2c - Bugfix: Fix compilation on io.js 3 d06114dba0a522fb436f0c5f47b994210968cd7b ### 2.8.0 Nov 15 2017 - Deprecation: Deprecate `Nan::ForceSet` in favor of `Nan::DefineOwnProperty()` 95cbb976d6fbbba88ba0f86dd188223a8591b4e7 - Feature: Add `Nan::AsyncProgressQueueWorker` a976636ecc2ef617d1b061ce4a6edf39923691cb - Feature: Add `Nan::DefineOwnProperty()` 95cbb976d6fbbba88ba0f86dd188223a8591b4e7 - Bugfix: Fix compiling on io.js 1 & 2 82705a64503ce60c62e98df5bd02972bba090900 - Bugfix: Use DefineOwnProperty instead of ForceSet 95cbb976d6fbbba88ba0f86dd188223a8591b4e7 ### 2.7.0 Aug 30 2017 - Feature: Add `Nan::To()` overload. b93280670c9f6da42ed4cf6cbf085ffdd87bd65b - Bugfix: Fix ternary in `Nan::MaybeLocal::FromMaybe()`. 79a26f7d362e756a9524e672a82c3d603b542867 ### 2.6.2 Apr 12 2017 - Bugfix: Fix v8::JSON::Parse() deprecation warning. 87f6a3c65815fa062296a994cc863e2fa124867d ### 2.6.1 Apr 6 2017 - Bugfix: nan_json.h: fix build breakage in Node 6 ac8d47dc3c10bfbf3f15a6b951633120c0ee6d51 ### 2.6.0 Apr 6 2017 - Feature: nan: add support for JSON::Parse & Stringify b533226c629cce70e1932a873bb6f849044a56c5 ### 2.5.1 Jan 23 2017 - Bugfix: Fix disappearing handle for private value 6a80995694f162ef63dbc9948fbefd45d4485aa0 - Bugfix: Add missing scopes a93b8bae6bc7d32a170db6e89228b7f60ee57112 - Bugfix: Use string::data instead of string::front in NewOneByteString d5f920371e67e1f3b268295daee6e83af86b6e50 ### 2.5.0 Dec 21 2016 - Feature: Support Private accessors a86255cb357e8ad8ccbf1f6a4a901c921e39a178 - Bugfix: Abort in delete operators that shouldn't be called 0fe38215ff8581703967dfd26c12793feb960018 ### 2.4.0 Jul 10 2016 - Feature: Rewrite Callback to add Callback::Reset c4cf44d61f8275cd5f7b0c911d7a806d4004f649 - Feature: AsyncProgressWorker: add template types for .send 1242c9a11a7ed481c8f08ec06316385cacc513d0 - Bugfix: Add constness to old Persistent comparison operators bd43cb9982c7639605d60fd073efe8cae165d9b2 ### 2.3.5 May 31 2016 - Bugfix: Replace NAN_INLINE with 'inline' keyword. 71819d8725f822990f439479c9aba3b240804909 ### 2.3.4 May 31 2016 - Bugfix: Remove V8 deprecation warnings 0592fb0a47f3a1c7763087ebea8e1138829f24f9 - Bugfix: Fix new versions not to use WeakCallbackInfo::IsFirstPass 615c19d9e03d4be2049c10db0151edbc3b229246 - Bugfix: Make ObjectWrap::handle() const d19af99595587fe7a26bd850af6595c2a7145afc - Bugfix: Fix compilation errors related to 0592fb0a47f3a1c7763087ebea8e1138829f24f9 e9191c525b94f652718325e28610a1adcf90fed8 ### 2.3.3 May 4 2016 - Bugfix: Refactor SetMethod() to deal with v8::Templates (#566) b9083cf6d5de6ebe6bcb49c7502fbb7c0d9ddda8 ### 2.3.2 Apr 27 2016 - Bugfix: Fix compilation on outdated versions due to Handle removal f8b7c875d04d425a41dfd4f3f8345bc3a11e6c52 ### 2.3.1 Apr 27 2016 - Bugfix: Don't use deprecated v8::Template::Set() in SetMethod a90951e9ea70fa1b3836af4b925322919159100e ### 2.3.0 Apr 27 2016 - Feature: added Signal() for invoking async callbacks without sending data from AsyncProgressWorker d8adba45f20e077d00561b20199133620c990b38 - Bugfix: Don't use deprecated v8::Template::Set() 00dacf0a4b86027415867fa7f1059acc499dcece ### 2.2.1 Mar 29 2016 - Bugfix: Use NewFromUnsigned in ReturnValue::Set(uint32_t i) for pre_12 3a18f9bdce29826e0e4c217854bc476918241a58 - Performance: Remove unneeeded nullptr checks b715ef44887931c94f0d1605b3b1a4156eebece9 ### 2.2.0 Jan 9 2016 - Feature: Add Function::Call wrapper 4c157474dacf284d125c324177b45aa5dabc08c6 - Feature: Rename GC*logueCallback to GCCallback for > 4.0 3603435109f981606d300eb88004ca101283acec - Bugfix: Fix Global::Pass for old versions 367e82a60fbaa52716232cc89db1cc3f685d77d9 - Bugfix: Remove weird MaybeLocal wrapping of what already is a MaybeLocal 23b4590db10c2ba66aee2338aebe9751c4cb190b ### 2.1.0 Oct 8 2015 - Deprecation: Deprecate NanErrnoException in favor of ErrnoException 0af1ca4cf8b3f0f65ed31bc63a663ab3319da55c - Feature: added helper class for accessing contents of typedarrays 17b51294c801e534479d5463697a73462d0ca555 - Feature: [Maybe types] Add MakeMaybe(...) 48d7b53d9702b0c7a060e69ea10fea8fb48d814d - Feature: new: allow utf16 string with length 66ac6e65c8ab9394ef588adfc59131b3b9d8347b - Feature: Introduce SetCallHandler and SetCallAsFunctionHandler 7764a9a115d60ba10dc24d86feb0fbc9b4f75537 - Bugfix: Enable creating Locals from Globals under Node 0.10. 9bf9b8b190821af889790fdc18ace57257e4f9ff - Bugfix: Fix issue #462 where PropertyCallbackInfo data is not stored safely. 55f50adedd543098526c7b9f4fffd607d3f9861f ### 2.0.9 Sep 8 2015 - Bugfix: EscapableHandleScope in Nan::NewBuffer for Node 0.8 and 0.10 b1654d7 ### 2.0.8 Aug 28 2015 - Work around duplicate linking bug in clang 11902da ### 2.0.7 Aug 26 2015 - Build: Repackage ### 2.0.6 Aug 26 2015 - Bugfix: Properly handle null callback in FunctionTemplate factory 6e99cb1 - Bugfix: Remove unused static std::map instances 525bddc - Bugfix: Make better use of maybe versions of APIs bfba85b - Bugfix: Fix shadowing issues with handle in ObjectWrap 0a9072d ### 2.0.5 Aug 10 2015 - Bugfix: Reimplement weak callback in ObjectWrap 98d38c1 - Bugfix: Make sure callback classes are not assignable, copyable or movable 81f9b1d ### 2.0.4 Aug 6 2015 - Build: Repackage ### 2.0.3 Aug 6 2015 - Bugfix: Don't use clang++ / g++ syntax extension. 231450e ### 2.0.2 Aug 6 2015 - Build: Repackage ### 2.0.1 Aug 6 2015 - Bugfix: Add workaround for missing REPLACE_INVALID_UTF8 60d6687 - Bugfix: Reimplement ObjectWrap from scratch to prevent memory leaks 6484601 - Bugfix: Fix Persistent leak in FunctionCallbackInfo and PropertyCallbackInfo 641ef5f - Bugfix: Add missing overload for Nan::NewInstance that takes argc/argv 29450ed ### 2.0.0 Jul 31 2015 - Change: Renamed identifiers with leading underscores b5932b4 - Change: Replaced NanObjectWrapHandle with class NanObjectWrap 464f1e1 - Change: Replace NanScope and NanEscpableScope macros with classes 47751c4 - Change: Rename NanNewBufferHandle to NanNewBuffer 6745f99 - Change: Rename NanBufferUse to NanNewBuffer 3e8b0a5 - Change: Rename NanNewBuffer to NanCopyBuffer d6af78d - Change: Remove Nan prefix from all names 72d1f67 - Change: Update Buffer API for new upstream changes d5d3291 - Change: Rename Scope and EscapableScope to HandleScope and EscapableHandleScope 21a7a6a - Change: Get rid of Handles e6c0daf - Feature: Support io.js 3 with V8 4.4 - Feature: Introduce NanPersistent 7fed696 - Feature: Introduce NanGlobal 4408da1 - Feature: Added NanTryCatch 10f1ca4 - Feature: Update for V8 v4.3 4b6404a - Feature: Introduce NanNewOneByteString c543d32 - Feature: Introduce namespace Nan 67ed1b1 - Removal: Remove NanLocker and NanUnlocker dd6e401 - Removal: Remove string converters, except NanUtf8String, which now follows the node implementation b5d00a9 - Removal: Remove NanReturn* macros d90a25c - Removal: Remove HasInstance e8f84fe ### 1.9.0 Jul 31 2015 - Feature: Added `NanFatalException` 81d4a2c - Feature: Added more error types 4265f06 - Feature: Added dereference and function call operators to NanCallback c4b2ed0 - Feature: Added indexed GetFromPersistent and SaveToPersistent edd510c - Feature: Added more overloads of SaveToPersistent and GetFromPersistent 8b1cef6 - Feature: Added NanErrnoException dd87d9e - Correctness: Prevent assign, copy, and move for classes that do not support it 1f55c59, 4b808cb, c96d9b2, fba4a29, 3357130 - Deprecation: Deprecate `NanGetPointerSafe` and `NanSetPointerSafe` 81d4a2c - Deprecation: Deprecate `NanBooleanOptionValue` and `NanUInt32OptionValue` 0ad254b ### 1.8.4 Apr 26 2015 - Build: Repackage ### 1.8.3 Apr 26 2015 - Bugfix: Include missing header 1af8648 ### 1.8.2 Apr 23 2015 - Build: Repackage ### 1.8.1 Apr 23 2015 - Bugfix: NanObjectWrapHandle should take a pointer 155f1d3 ### 1.8.0 Apr 23 2015 - Feature: Allow primitives with NanReturnValue 2e4475e - Feature: Added comparison operators to NanCallback 55b075e - Feature: Backport thread local storage 15bb7fa - Removal: Remove support for signatures with arguments 8a2069d - Correcteness: Replaced NanObjectWrapHandle macro with function 0bc6d59 ### 1.7.0 Feb 28 2015 - Feature: Made NanCallback::Call accept optional target 8d54da7 - Feature: Support atom-shell 0.21 0b7f1bb ### 1.6.2 Feb 6 2015 - Bugfix: NanEncode: fix argument type for node::Encode on io.js 2be8639 ### 1.6.1 Jan 23 2015 - Build: version bump ### 1.5.3 Jan 23 2015 - Build: repackage ### 1.6.0 Jan 23 2015 - Deprecated `NanNewContextHandle` in favor of `NanNew` 49259af - Support utility functions moved in newer v8 versions (Node 0.11.15, io.js 1.0) a0aa179 - Added `NanEncode`, `NanDecodeBytes` and `NanDecodeWrite` 75e6fb9 ### 1.5.2 Jan 23 2015 - Bugfix: Fix non-inline definition build error with clang++ 21d96a1, 60fadd4 - Bugfix: Readded missing String constructors 18d828f - Bugfix: Add overload handling NanNew(..) 5ef813b - Bugfix: Fix uv_work_cb versioning 997e4ae - Bugfix: Add function factory and test 4eca89c - Bugfix: Add object template factory and test cdcb951 - Correctness: Lifted an io.js related typedef c9490be - Correctness: Make explicit downcasts of String lengths 00074e6 - Windows: Limit the scope of disabled warning C4530 83d7deb ### 1.5.1 Jan 15 2015 - Build: version bump ### 1.4.3 Jan 15 2015 - Build: version bump ### 1.4.2 Jan 15 2015 - Feature: Support io.js 0dbc5e8 ### 1.5.0 Jan 14 2015 - Feature: Support io.js b003843 - Correctness: Improved NanNew internals 9cd4f6a - Feature: Implement progress to NanAsyncWorker 8d6a160 ### 1.4.1 Nov 8 2014 - Bugfix: Handle DEBUG definition correctly - Bugfix: Accept int as Boolean ### 1.4.0 Nov 1 2014 - Feature: Added NAN_GC_CALLBACK 6a5c245 - Performance: Removed unnecessary local handle creation 18a7243, 41fe2f8 - Correctness: Added constness to references in NanHasInstance 02c61cd - Warnings: Fixed spurious warnings from -Wundef and -Wshadow, 541b122, 99d8cb6 - Windoze: Shut Visual Studio up when compiling 8d558c1 - License: Switch to plain MIT from custom hacked MIT license 11de983 - Build: Added test target to Makefile e232e46 - Performance: Removed superfluous scope in NanAsyncWorker f4b7821 - Sugar/Feature: Added NanReturnThis() and NanReturnHolder() shorthands 237a5ff, d697208 - Feature: Added suitable overload of NanNew for v8::Integer::NewFromUnsigned b27b450 ### 1.3.0 Aug 2 2014 - Added NanNew(std::string) - Added NanNew(std::string&) - Added NanAsciiString helper class - Added NanUtf8String helper class - Added NanUcs2String helper class - Deprecated NanRawString() - Deprecated NanCString() - Added NanGetIsolateData(v8::Isolate *isolate) - Added NanMakeCallback(v8::Handle target, v8::Handle func, int argc, v8::Handle* argv) - Added NanMakeCallback(v8::Handle target, v8::Handle symbol, int argc, v8::Handle* argv) - Added NanMakeCallback(v8::Handle target, const char* method, int argc, v8::Handle* argv) - Added NanSetTemplate(v8::Handle templ, v8::Handle name , v8::Handle value, v8::PropertyAttribute attributes) - Added NanSetPrototypeTemplate(v8::Local templ, v8::Handle name, v8::Handle value, v8::PropertyAttribute attributes) - Added NanSetInstanceTemplate(v8::Local templ, const char *name, v8::Handle value) - Added NanSetInstanceTemplate(v8::Local templ, v8::Handle name, v8::Handle value, v8::PropertyAttribute attributes) ### 1.2.0 Jun 5 2014 - Add NanSetPrototypeTemplate - Changed NAN_WEAK_CALLBACK internals, switched _NanWeakCallbackData to class, introduced _NanWeakCallbackDispatcher - Removed -Wno-unused-local-typedefs from test builds - Made test builds Windows compatible ('Sleep()') ### 1.1.2 May 28 2014 - Release to fix more stuff-ups in 1.1.1 ### 1.1.1 May 28 2014 - Release to fix version mismatch in nan.h and lack of changelog entry for 1.1.0 ### 1.1.0 May 25 2014 - Remove nan_isolate, use v8::Isolate::GetCurrent() internally instead - Additional explicit overloads for NanNew(): (char*,int), (uint8_t*[,int]), (uint16_t*[,int), double, int, unsigned int, bool, v8::String::ExternalStringResource*, v8::String::ExternalAsciiStringResource* - Deprecate NanSymbol() - Added SetErrorMessage() and ErrorMessage() to NanAsyncWorker ### 1.0.0 May 4 2014 - Heavy API changes for V8 3.25 / Node 0.11.13 - Use cpplint.py - Removed NanInitPersistent - Removed NanPersistentToLocal - Removed NanFromV8String - Removed NanMakeWeak - Removed NanNewLocal - Removed NAN_WEAK_CALLBACK_OBJECT - Removed NAN_WEAK_CALLBACK_DATA - Introduce NanNew, replaces NanNewLocal, NanPersistentToLocal, adds many overloaded typed versions - Introduce NanUndefined, NanNull, NanTrue and NanFalse - Introduce NanEscapableScope and NanEscapeScope - Introduce NanMakeWeakPersistent (requires a special callback to work on both old and new node) - Introduce NanMakeCallback for node::MakeCallback - Introduce NanSetTemplate - Introduce NanGetCurrentContext - Introduce NanCompileScript and NanRunScript - Introduce NanAdjustExternalMemory - Introduce NanAddGCEpilogueCallback, NanAddGCPrologueCallback, NanRemoveGCEpilogueCallback, NanRemoveGCPrologueCallback - Introduce NanGetHeapStatistics - Rename NanAsyncWorker#SavePersistent() to SaveToPersistent() ### 0.8.0 Jan 9 2014 - NanDispose -> NanDisposePersistent, deprecate NanDispose - Extract _NAN_*_RETURN_TYPE, pull up NAN_*() ### 0.7.1 Jan 9 2014 - Fixes to work against debug builds of Node - Safer NanPersistentToLocal (avoid reinterpret_cast) - Speed up common NanRawString case by only extracting flattened string when necessary ### 0.7.0 Dec 17 2013 - New no-arg form of NanCallback() constructor. - NanCallback#Call takes Handle rather than Local - Removed deprecated NanCallback#Run method, use NanCallback#Call instead - Split off _NAN_*_ARGS_TYPE from _NAN_*_ARGS - Restore (unofficial) Node 0.6 compatibility at NanCallback#Call() - Introduce NanRawString() for char* (or appropriate void*) from v8::String (replacement for NanFromV8String) - Introduce NanCString() for null-terminated char* from v8::String ### 0.6.0 Nov 21 2013 - Introduce NanNewLocal(v8::Handle value) for use in place of v8::Local::New(...) since v8 started requiring isolate in Node 0.11.9 ### 0.5.2 Nov 16 2013 - Convert SavePersistent and GetFromPersistent in NanAsyncWorker from protected and public ### 0.5.1 Nov 12 2013 - Use node::MakeCallback() instead of direct v8::Function::Call() ### 0.5.0 Nov 11 2013 - Added @TooTallNate as collaborator - New, much simpler, "include_dirs" for binding.gyp - Added full range of NAN_INDEX_* macros to match NAN_PROPERTY_* macros ### 0.4.4 Nov 2 2013 - Isolate argument from v8::Persistent::MakeWeak removed for 0.11.8+ ### 0.4.3 Nov 2 2013 - Include node_object_wrap.h, removed from node.h for Node 0.11.8. ### 0.4.2 Nov 2 2013 - Handle deprecation of v8::Persistent::Dispose(v8::Isolate* isolate)) for Node 0.11.8 release. ### 0.4.1 Sep 16 2013 - Added explicit `#include ` as it was removed from node.h for v0.11.8 ### 0.4.0 Sep 2 2013 - Added NAN_INLINE and NAN_DEPRECATED and made use of them - Added NanError, NanTypeError and NanRangeError - Cleaned up code ### 0.3.2 Aug 30 2013 - Fix missing scope declaration in GetFromPersistent() and SaveToPersistent in NanAsyncWorker ### 0.3.1 Aug 20 2013 - fix "not all control paths return a value" compile warning on some platforms ### 0.3.0 Aug 19 2013 - Made NAN work with NPM - Lots of fixes to NanFromV8String, pulling in features from new Node core - Changed node::encoding to Nan::Encoding in NanFromV8String to unify the API - Added optional error number argument for NanThrowError() - Added NanInitPersistent() - Added NanReturnNull() and NanReturnEmptyString() - Added NanLocker and NanUnlocker - Added missing scopes - Made sure to clear disposed Persistent handles - Changed NanAsyncWorker to allocate error messages on the heap - Changed NanThrowError(Local) to NanThrowError(Handle) - Fixed leak in NanAsyncWorker when errmsg is used ### 0.2.2 Aug 5 2013 - Fixed usage of undefined variable with node::BASE64 in NanFromV8String() ### 0.2.1 Aug 5 2013 - Fixed 0.8 breakage, node::BUFFER encoding type not available in 0.8 for NanFromV8String() ### 0.2.0 Aug 5 2013 - Added NAN_PROPERTY_GETTER, NAN_PROPERTY_SETTER, NAN_PROPERTY_ENUMERATOR, NAN_PROPERTY_DELETER, NAN_PROPERTY_QUERY - Extracted _NAN_METHOD_ARGS, _NAN_GETTER_ARGS, _NAN_SETTER_ARGS, _NAN_PROPERTY_GETTER_ARGS, _NAN_PROPERTY_SETTER_ARGS, _NAN_PROPERTY_ENUMERATOR_ARGS, _NAN_PROPERTY_DELETER_ARGS, _NAN_PROPERTY_QUERY_ARGS - Added NanGetInternalFieldPointer, NanSetInternalFieldPointer - Added NAN_WEAK_CALLBACK, NAN_WEAK_CALLBACK_OBJECT, NAN_WEAK_CALLBACK_DATA, NanMakeWeak - Renamed THROW_ERROR to _NAN_THROW_ERROR - Added NanNewBufferHandle(char*, size_t, node::smalloc::FreeCallback, void*) - Added NanBufferUse(char*, uint32_t) - Added NanNewContextHandle(v8::ExtensionConfiguration*, v8::Handle, v8::Handle) - Fixed broken NanCallback#GetFunction() - Added optional encoding and size arguments to NanFromV8String() - Added NanGetPointerSafe() and NanSetPointerSafe() - Added initial test suite (to be expanded) - Allow NanUInt32OptionValue to convert any Number object ### 0.1.0 Jul 21 2013 - Added `NAN_GETTER`, `NAN_SETTER` - Added `NanThrowError` with single Local argument - Added `NanNewBufferHandle` with single uint32_t argument - Added `NanHasInstance(Persistent&, Handle)` - Added `Local NanCallback#GetFunction()` - Added `NanCallback#Call(int, Local[])` - Deprecated `NanCallback#Run(int, Local[])` in favour of Call nan-2.24.0/CMakeLists.txt000066400000000000000000000102171511403330700151110ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.5) project(nan) set(CMAKE_CXX_STANDARD 11) set(CPPLINT "${CMAKE_CURRENT_SOURCE_DIR}/cpplint.py") set(MODULES symbols strings) set(SOURCES "") set(ADDONS "") foreach(MODULE ${MODULES}) list(APPEND SOURCES "test/cpp/${MODULE}.cpp") list(APPEND ADDONS "test/build/${CMAKE_BUILD_TYPE}/${MODULE}.node") endforeach() set(LINT_SOURCES examples/async_pi_estimate/addon.cc examples/async_pi_estimate/async.cc examples/async_pi_estimate/async.h examples/async_pi_estimate/pi_est.cc examples/async_pi_estimate/pi_est.h examples/async_pi_estimate/sync.cc examples/async_pi_estimate/sync.h nan.h nan_callbacks.h nan_callbacks_12_inl.h nan_callbacks_pre_12_inl.h nan_converters.h nan_converters_43_inl.h nan_converters_pre_43_inl.h nan_define_own_property_helper.h nan_implementation_12_inl.h nan_implementation_pre_12_inl.h nan_json.h nan_maybe_43_inl.h nan_maybe_pre_43_inl.h nan_new.h nan_object_wrap.h nan_persistent_12_inl.h nan_persistent_pre_12_inl.h nan_private.h nan_scriptorigin.h nan_string_bytes.h nan_weak.h test/cpp/accessors.cpp test/cpp/accessors2.cpp test/cpp/asyncresource.cpp test/cpp/asyncworker.cpp test/cpp/asyncprogressworker.cpp test/cpp/asyncprogressworkerstream.cpp test/cpp/asyncprogressworkersignal.cpp test/cpp/asyncprogressqueueworker.cpp test/cpp/asyncprogressqueueworkerstream.cpp test/cpp/asyncworkererror.cpp test/cpp/buffer.cpp test/cpp/bufferworkerpersistent.cpp test/cpp/error.cpp test/cpp/gc.cpp test/cpp/indexedinterceptors.cpp test/cpp/callbackcontext.cpp test/cpp/converters.cpp test/cpp/isolatedata.cpp test/cpp/json-parse.cpp test/cpp/json-stringify.cpp test/cpp/makecallback.cpp test/cpp/maybe.cpp test/cpp/morenews.cpp test/cpp/multifile1.cpp test/cpp/multifile2.cpp test/cpp/multifile2.h test/cpp/namedinterceptors.cpp test/cpp/nancallback.cpp test/cpp/nannew.cpp test/cpp/news.cpp test/cpp/objectwraphandle.cpp test/cpp/persistent.cpp test/cpp/private.cpp test/cpp/returnemptystring.cpp test/cpp/returnnull.cpp test/cpp/returnundefined.cpp test/cpp/returnvalue.cpp test/cpp/setcallhandler.cpp test/cpp/settemplate.cpp test/cpp/sleep.h test/cpp/strings.cpp test/cpp/symbols.cpp test/cpp/threadlocal.cpp test/cpp/trycatch.cpp test/cpp/typedarrays.cpp test/cpp/weak.cpp test/cpp/weak2.cpp test/cpp/wrappedobjectfactory.cpp node_modules/node-gyp/gyp/data/win/large-pdb-shim.cc) set(FILTER "-build/include_subdir,-whitespace/parens") find_package(Python COMPONENTS Interpreter Development REQUIRED) execute_process( COMMAND npm install OUTPUT_FILE node_modules WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) add_custom_target(lint COMMAND ${Python_EXECUTABLE} ${CPPLINT} --filter=${FILTER} ${LINT_SOURCES} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) add_custom_target(test DEPENDS ${ADDONS} COMMAND npm test ) add_custom_target(forcetest WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test COMMAND ../node_modules/.bin/node-gyp rebuild COMMAND npm test ) add_custom_target(docs DEPENDS README.md doc/.build.sh doc/asyncworker.md doc/buffers.md doc/callback.md doc/converters.md doc/errors.md doc/maybe_types.md doc/methods.md doc/new.md doc/node_misc.md doc/persistent.md doc/scopes.md doc/script.md doc/string_bytes.md doc/v8_internals.md doc/json.md doc/v8_misc.md WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND doc/.build.sh ) add_custom_command(OUTPUT ${ADDONS} DEPENDS ${SOURCES} nan.h nan_new.h nan_implementation_pre_12_inl.h nan_implementation_12_inl.h nan_callbacks.h nan_callbacks_12_inl.h nan_callbacks_pre_12_inl.h nan_converters.h nan_converters_43_inl.h nan_converters_pre_43_inl.h nan_define_own_property_helper.h nan_json.h nan_maybe_43_inl.h nan_maybe_pre_43_inl.h nan_persistent_12_inl.h nan_persistent_pre_12_inl.h nan_private.h nan_weak.h nan_scriptorigin.h nan_string_bytes.h test/binding.gyp WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test COMMAND ../node_modules/.bin/node-gyp rebuild )nan-2.24.0/LICENSE.md000066400000000000000000000021701511403330700137540ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2018 [NAN contributors]() Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. nan-2.24.0/Makefile000066400000000000000000000067541511403330700140240ustar00rootroot00000000000000TOPLEVEL ?= $(dir $(lastword $(MAKEFILE_LIST))) CPPLINT ?= $(TOPLEVEL)/cpplint.py PYTHON ?= python BUILDTYPE ?= Release MODULES = symbols strings SOURCES = $(MODULES:%=test/cpp/%.cpp) ADDONS = $(MODULES:%=test/build/$(BUILDTYPE)/%.node) LINT_SOURCES = \ examples/async_pi_estimate/addon.cc \ examples/async_pi_estimate/async.cc \ examples/async_pi_estimate/async.h \ examples/async_pi_estimate/pi_est.cc \ examples/async_pi_estimate/pi_est.h \ examples/async_pi_estimate/sync.cc \ examples/async_pi_estimate/sync.h \ nan.h \ nan_callbacks.h \ nan_callbacks_12_inl.h \ nan_callbacks_pre_12_inl.h \ nan_converters.h \ nan_converters_43_inl.h \ nan_converters_pre_43_inl.h \ nan_define_own_property_helper.h \ nan_implementation_12_inl.h \ nan_implementation_pre_12_inl.h \ nan_json.h \ nan_maybe_43_inl.h \ nan_maybe_pre_43_inl.h \ nan_new.h \ nan_object_wrap.h \ nan_persistent_12_inl.h \ nan_persistent_pre_12_inl.h \ nan_private.h \ nan_scriptorigin.h \ nan_string_bytes.h \ nan_weak.h \ test/cpp/accessors.cpp \ test/cpp/accessors2.cpp \ test/cpp/asyncresource.cpp \ test/cpp/asyncworker.cpp \ test/cpp/asyncprogressworker.cpp \ test/cpp/asyncprogressworkerstream.cpp \ test/cpp/asyncprogressworkersignal.cpp \ test/cpp/asyncprogressqueueworker.cpp \ test/cpp/asyncprogressqueueworkerstream.cpp \ test/cpp/asyncworkererror.cpp \ test/cpp/buffer.cpp \ test/cpp/bufferworkerpersistent.cpp \ test/cpp/error.cpp \ test/cpp/gc.cpp \ test/cpp/indexedinterceptors.cpp \ test/cpp/callbackcontext.cpp \ test/cpp/converters.cpp \ test/cpp/isolatedata.cpp \ test/cpp/json-parse.cpp \ test/cpp/json-stringify.cpp \ test/cpp/makecallback.cpp \ test/cpp/maybe.cpp \ test/cpp/morenews.cpp \ test/cpp/multifile1.cpp \ test/cpp/multifile2.cpp \ test/cpp/multifile2.h \ test/cpp/namedinterceptors.cpp \ test/cpp/nancallback.cpp \ test/cpp/nannew.cpp \ test/cpp/news.cpp \ test/cpp/objectwraphandle.cpp \ test/cpp/persistent.cpp \ test/cpp/private.cpp \ test/cpp/returnemptystring.cpp \ test/cpp/returnnull.cpp \ test/cpp/returnundefined.cpp \ test/cpp/returnvalue.cpp \ test/cpp/setcallhandler.cpp \ test/cpp/settemplate.cpp \ test/cpp/sleep.h \ test/cpp/strings.cpp \ test/cpp/symbols.cpp \ test/cpp/threadlocal.cpp \ test/cpp/trycatch.cpp \ test/cpp/typedarrays.cpp \ test/cpp/weak.cpp \ test/cpp/weak2.cpp \ test/cpp/wrappedobjectfactory.cpp \ node_modules/node-gyp/gyp/data/win/large-pdb-shim.cc FILTER = -build/include_subdir,-whitespace/parens .PHONY: lint lint: cd $(TOPLEVEL) && $(PYTHON) $(CPPLINT) --filter=$(FILTER) $(LINT_SOURCES) test: $(ADDONS) npm test forcetest: cd test && ../node_modules/.bin/node-gyp rebuild && cd .. npm test docs: README.md doc/.build.sh doc/asyncworker.md doc/buffers.md doc/callback.md \ doc/converters.md doc/errors.md doc/maybe_types.md doc/methods.md doc/new.md \ doc/node_misc.md doc/persistent.md doc/scopes.md doc/script.md doc/string_bytes.md \ doc/v8_internals.md doc/json.md doc/v8_misc.md doc/.build.sh $(ADDONS): nan.h nan_new.h nan_implementation_pre_12_inl.h nan_implementation_12_inl.h \ nan_callbacks.h nan_callbacks_12_inl.h nan_callbacks_pre_12_inl.h \ nan_converters.h nan_converters_43_inl.h nan_converters_pre_43_inl.h \ nan_define_own_property_helper.h \ nan_json.h nan_maybe_43_inl.h nan_maybe_pre_43_inl.h \ nan_persistent_12_inl.h nan_persistent_pre_12_inl.h nan_private.h \ nan_weak.h nan_scriptorigin.h nan_string_bytes.h \ test/binding.gyp $(SOURCES) cd test/ && ../node_modules/.bin/node-gyp rebuild nan-2.24.0/README.md000066400000000000000000000676401511403330700136440ustar00rootroot00000000000000Native Abstractions for Node.js =============================== **A header file filled with macro and utility goodness for making add-on development for Node.js easier across versions 8, 10, 12, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24 and 25.** ***Current version: 2.24.0*** *(See [CHANGELOG.md](https://github.com/nodejs/nan/blob/master/CHANGELOG.md) for complete ChangeLog)* [![NPM](https://nodei.co/npm/nan.png?downloads=true&downloadRank=true)](https://nodei.co/npm/nan/) [![NPM](https://nodei.co/npm-dl/nan.png?months=6&height=3)](https://nodei.co/npm/nan/) [![Build status](https://ci.appveyor.com/api/projects/status/kh73pbm9dsju7fgh)](https://ci.appveyor.com/project/RodVagg/nan) Thanks to the crazy changes in V8 (and some in Node core), keeping native addons compiling happily across versions, particularly 0.10 to 0.12 to 4.0, is a minor nightmare. The goal of this project is to store all logic necessary to develop native Node.js addons without having to inspect `NODE_MODULE_VERSION` and get yourself into a macro-tangle. This project also contains some helper utilities that make addon development a bit more pleasant. * **[News & Updates](#news)** * **[Usage](#usage)** * **[Example](#example)** * **[API](#api)** * **[Tests](#tests)** * **[Known issues](#issues)** * **[Governance & Contributing](#governance)** ## News & Updates ## Usage Simply add **NAN** as a dependency using a package manager like npm, yarn, or bun: ``` bash $ npm install nan ``` Pull in the path to **NAN** in your *binding.gyp* so that you can use `#include ` in your *.cpp* files: ``` python "include_dirs" : [ "` when compiling your addon. ## Example Just getting started with Nan? Take a look at the **[Node Add-on Examples](https://github.com/nodejs/node-addon-examples)**. Refer to a [quick-start **Nan** Boilerplate](https://github.com/fcanas/node-native-boilerplate) for a ready-to-go project that utilizes basic Nan functionality. For a simpler example, see the **[async pi estimation example](https://github.com/nodejs/nan/tree/master/examples/async_pi_estimate)** in the examples directory for full code and an explanation of what this Monte Carlo Pi estimation example does. Below are just some parts of the full example that illustrate the use of **NAN**. Yet another example is **[nan-example-eol](https://github.com/CodeCharmLtd/nan-example-eol)**. It shows newline detection implemented as a native addon. Also take a look at our comprehensive **[C++ test suite](https://github.com/nodejs/nan/tree/master/test/cpp)** which has a plethora of code snippets for your pasting pleasure. ## API Additional to the NAN documentation below, please consult: * [The V8 Getting Started * Guide](https://v8.dev/docs/embed) * [V8 API Documentation](https://v8docs.nodesource.com/) * [Node Add-on Documentation](https://nodejs.org/api/addons.html) ### JavaScript-accessible methods A _template_ is a blueprint for JavaScript functions and objects in a context. You can use a template to wrap C++ functions and data structures within JavaScript objects so that they can be manipulated from JavaScript. See the V8 Embedders Guide section on [Templates](https://github.com/v8/v8/wiki/Embedder%27s-Guide#templates) for further information. In order to expose functionality to JavaScript via a template, you must provide it to V8 in a form that it understands. Across the versions of V8 supported by NAN, JavaScript-accessible method signatures vary widely, NAN fully abstracts method declaration and provides you with an interface that is similar to the most recent V8 API but is backward-compatible with older versions that still use the now-deceased `v8::Argument` type. * **Method argument types** - Nan::FunctionCallbackInfo - Nan::PropertyCallbackInfo - Nan::ReturnValue * **Method declarations** - Method declaration - Getter declaration - Setter declaration - Property getter declaration - Property setter declaration - Property enumerator declaration - Property deleter declaration - Property query declaration - Index getter declaration - Index setter declaration - Index enumerator declaration - Index deleter declaration - Index query declaration * Method and template helpers - Nan::SetMethod() - Nan::SetPrototypeMethod() - Nan::SetAccessor() - Nan::SetNamedPropertyHandler() - Nan::SetIndexedPropertyHandler() - Nan::SetTemplate() - Nan::SetPrototypeTemplate() - Nan::SetInstanceTemplate() - Nan::SetCallHandler() - Nan::SetCallAsFunctionHandler() ### Scopes A _local handle_ is a pointer to an object. All V8 objects are accessed using handles, they are necessary because of the way the V8 garbage collector works. A handle scope can be thought of as a container for any number of handles. When you've finished with your handles, instead of deleting each one individually you can simply delete their scope. The creation of `HandleScope` objects is different across the supported versions of V8. Therefore, NAN provides its own implementations that can be used safely across these. - Nan::HandleScope - Nan::EscapableHandleScope Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://github.com/v8/v8/wiki/Embedder%27s%20Guide#handles-and-garbage-collection). ### Persistent references An object reference that is independent of any `HandleScope` is a _persistent_ reference. Where a `Local` handle only lives as long as the `HandleScope` in which it was allocated, a `Persistent` handle remains valid until it is explicitly disposed. Due to the evolution of the V8 API, it is necessary for NAN to provide a wrapper implementation of the `Persistent` classes to supply compatibility across the V8 versions supported. - Nan::PersistentBase & v8::PersistentBase - Nan::NonCopyablePersistentTraits & v8::NonCopyablePersistentTraits - Nan::CopyablePersistentTraits & v8::CopyablePersistentTraits - Nan::Persistent - Nan::Global - Nan::WeakCallbackInfo - Nan::WeakCallbackType Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://v8.dev/docs/embed#handles-and-garbage-collection). ### New NAN provides a `Nan::New()` helper for the creation of new JavaScript objects in a way that's compatible across the supported versions of V8. - Nan::New() - Nan::Undefined() - Nan::Null() - Nan::True() - Nan::False() - Nan::EmptyString() ### Converters NAN contains functions that convert `v8::Value`s to other `v8::Value` types and native types. Since type conversion is not guaranteed to succeed, they return `Nan::Maybe` types. These converters can be used in place of `value->ToX()` and `value->XValue()` (where `X` is one of the types, e.g. `Boolean`) in a way that provides a consistent interface across V8 versions. Newer versions of V8 use the new `v8::Maybe` and `v8::MaybeLocal` types for these conversions, older versions don't have this functionality so it is provided by NAN. - Nan::To() ### Maybe Types The `Nan::MaybeLocal` and `Nan::Maybe` types are monads that encapsulate `v8::Local` handles that _may be empty_. * **Maybe Types** - Nan::MaybeLocal - Nan::Maybe - Nan::Nothing - Nan::Just * **Maybe Helpers** - Nan::Call() - Nan::ToDetailString() - Nan::ToArrayIndex() - Nan::Equals() - Nan::NewInstance() - Nan::GetFunction() - Nan::Set() - Nan::DefineOwnProperty() - Nan::ForceSet() - Nan::Get() - Nan::GetPropertyAttributes() - Nan::Has() - Nan::Delete() - Nan::GetPropertyNames() - Nan::GetOwnPropertyNames() - Nan::SetPrototype() - Nan::ObjectProtoToString() - Nan::HasOwnProperty() - Nan::HasRealNamedProperty() - Nan::HasRealIndexedProperty() - Nan::HasRealNamedCallbackProperty() - Nan::GetRealNamedPropertyInPrototypeChain() - Nan::GetRealNamedProperty() - Nan::CallAsFunction() - Nan::CallAsConstructor() - Nan::GetSourceLine() - Nan::GetLineNumber() - Nan::GetStartColumn() - Nan::GetEndColumn() - Nan::CloneElementAt() - Nan::HasPrivate() - Nan::GetPrivate() - Nan::SetPrivate() - Nan::DeletePrivate() - Nan::MakeMaybe() ### Script NAN provides `v8::Script` helpers as the API has changed over the supported versions of V8. - Nan::CompileScript() - Nan::RunScript() - Nan::ScriptOrigin ### JSON The _JSON_ object provides the C++ versions of the methods offered by the `JSON` object in javascript. V8 exposes these methods via the `v8::JSON` object. - Nan::JSON.Parse - Nan::JSON.Stringify Refer to the V8 JSON object in the [V8 documentation](https://v8docs.nodesource.com/node-8.16/da/d6f/classv8_1_1_j_s_o_n.html) for more information about these methods and their arguments. ### Errors NAN includes helpers for creating, throwing and catching Errors as much of this functionality varies across the supported versions of V8 and must be abstracted. Note that an Error object is simply a specialized form of `v8::Value`. Also consult the V8 Embedders Guide section on [Exceptions](https://v8.dev/docs/embed#exceptions) for more information. - Nan::Error() - Nan::RangeError() - Nan::ReferenceError() - Nan::SyntaxError() - Nan::TypeError() - Nan::ThrowError() - Nan::ThrowRangeError() - Nan::ThrowReferenceError() - Nan::ThrowSyntaxError() - Nan::ThrowTypeError() - Nan::FatalException() - Nan::ErrnoException() - Nan::TryCatch ### Buffers NAN's `node::Buffer` helpers exist as the API has changed across supported Node versions. Use these methods to ensure compatibility. - Nan::NewBuffer() - Nan::CopyBuffer() - Nan::FreeCallback() ### Nan::Callback `Nan::Callback` makes it easier to use `v8::Function` handles as callbacks. A class that wraps a `v8::Function` handle, protecting it from garbage collection and making it particularly useful for storage and use across asynchronous execution. - Nan::Callback ### Asynchronous work helpers `Nan::AsyncWorker`, `Nan::AsyncProgressWorker` and `Nan::AsyncProgressQueueWorker` are helper classes that make working with asynchronous code easier. - Nan::AsyncWorker - Nan::AsyncProgressWorkerBase & Nan::AsyncProgressWorker - Nan::AsyncProgressQueueWorker - Nan::AsyncQueueWorker ### Strings & Bytes Miscellaneous string & byte encoding and decoding functionality provided for compatibility across supported versions of V8 and Node. Implemented by NAN to ensure that all encoding types are supported, even for older versions of Node where they are missing. - Nan::Encoding - Nan::Encode() - Nan::TryEncode() - Nan::DecodeBytes() - Nan::DecodeWrite() ### Object Wrappers The `ObjectWrap` class can be used to make wrapped C++ objects and a factory of wrapped objects. - Nan::ObjectWrap ### V8 internals The hooks to access V8 internals—including GC and statistics—are different across the supported versions of V8, therefore NAN provides its own hooks that call the appropriate V8 methods. - NAN_GC_CALLBACK() - Nan::AddGCEpilogueCallback() - Nan::RemoveGCEpilogueCallback() - Nan::AddGCPrologueCallback() - Nan::RemoveGCPrologueCallback() - Nan::GetHeapStatistics() - Nan::SetCounterFunction() - Nan::SetCreateHistogramFunction() - Nan::SetAddHistogramSampleFunction() - Nan::IdleNotification() - Nan::LowMemoryNotification() - Nan::ContextDisposedNotification() - Nan::GetInternalFieldPointer() - Nan::SetInternalFieldPointer() - Nan::AdjustExternalMemory() ### Miscellaneous V8 Helpers - Nan::Utf8String - Nan::GetCurrentContext() - Nan::SetIsolateData() - Nan::GetIsolateData() - Nan::TypedArrayContents ### Miscellaneous Node Helpers - Nan::AsyncResource - Nan::MakeCallback() - NAN_MODULE_INIT() - Nan::Export() ### Tests To run the NAN tests do: ``` sh npm install npm run-script rebuild-tests npm test ``` Or just: ``` sh npm install make test ``` ## Known issues ### Compiling against Node.js 0.12 on OSX With new enough compilers available on OSX, the versions of V8 headers corresponding to Node.js 0.12 do not compile anymore. The error looks something like: ``` ❯ CXX(target) Release/obj.target/accessors/cpp/accessors.o In file included from ../cpp/accessors.cpp:9: In file included from ../../nan.h:51: In file included from /Users/ofrobots/.node-gyp/0.12.18/include/node/node.h:61: /Users/ofrobots/.node-gyp/0.12.18/include/node/v8.h:5800:54: error: 'CreateHandle' is a protected member of 'v8::HandleScope' return Handle(reinterpret_cast(HandleScope::CreateHandle( ~~~~~~~~~~~~~^~~~~~~~~~~~ ``` This can be worked around by patching your local versions of v8.h corresponding to Node 0.12 to make `v8::Handle` a friend of `v8::HandleScope`. Since neither Node.js not V8 support this release line anymore this patch cannot be released by either project in an official release. For this reason, we do not test against Node.js 0.12 on OSX in this project's CI. If you need to support that configuration, you will need to either get an older compiler, or apply a source patch to the version of V8 headers as a workaround. ## Governance & Contributing NAN is governed by the [Node.js Addon API Working Group](https://github.com/nodejs/CTC/blob/master/WORKING_GROUPS.md#addon-api) ### Addon API Working Group (WG) The NAN project is jointly governed by a Working Group which is responsible for high-level guidance of the project. Members of the WG are also known as Collaborators, there is no distinction between the two, unlike other Node.js projects. The WG has final authority over this project including: * Technical direction * Project governance and process (including this policy) * Contribution policy * GitHub repository hosting * Maintaining the list of additional Collaborators For the current list of WG members, see the project [README.md](./README.md#collaborators). Individuals making significant and valuable contributions are made members of the WG and given commit-access to the project. These individuals are identified by the WG and their addition to the WG is discussed via GitHub and requires unanimous consensus amongst those WG members participating in the discussion with a quorum of 50% of WG members required for acceptance of the vote. _Note:_ If you make a significant contribution and are not considered for commit-access log an issue or contact a WG member directly. For the current list of WG members / Collaborators, see the project [README.md](./README.md#collaborators). ### Consensus Seeking Process The WG follows a [Consensus Seeking](https://en.wikipedia.org/wiki/Consensus-seeking_decision-making) decision making model. Modifications of the contents of the NAN repository are made on a collaborative basis. Anybody with a GitHub account may propose a modification via pull request and it will be considered by the WG. All pull requests must be reviewed and accepted by a WG member with sufficient expertise who is able to take full responsibility for the change. In the case of pull requests proposed by an existing WG member, an additional WG member is required for sign-off. Consensus should be sought if additional WG members participate and there is disagreement around a particular modification. If a change proposal cannot reach a consensus, a WG member can call for a vote amongst the members of the WG. Simple majority wins. ## Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: * (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or * (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or * (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. * (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. ### WG Members / Collaborators
Rod VaggGitHub/rvaggTwitter/@rvagg
Benjamin ByholmGitHub/kkoopa-
Trevor NorrisGitHub/trevnorrisTwitter/@trevnorris
Nathan RajlichGitHub/TooTallNateTwitter/@TooTallNate
Brett LawsonGitHub/brett19Twitter/@brett19x
Ben NoordhuisGitHub/bnoordhuisTwitter/@bnoordhuis
David SiegelGitHub/agnatTwitter/@agnat
Michael Ira KrufkyGitHub/mkrufkyTwitter/@mkrufky
## Licence & copyright Copyright (c) 2018 NAN WG Members / Collaborators (listed above). Native Abstractions for Node.js is licensed under an MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. nan-2.24.0/appveyor.yml000066400000000000000000000037521511403330700147470ustar00rootroot00000000000000# http://www.appveyor.com/docs/appveyor-yml # https://www.appveyor.com/docs/windows-images-software # https://nodejs.org/en/about/previous-releases # https://devguide.python.org/versions # Test supported Node.js versions before unsupported versions. # Run on the most current Visual Studio possible for each nodejs_version. # Run on the earliest supported Python version when possible (currently py39). # For all supported Node.js versions test also on the latest Python (currently py313). image: - Visual Studio 2022 environment: NODE_GYP_FORCE_PYTHON: C:\Python39-x64\python.exe matrix: # Test against these versions of Io.js and Node.js. - nodejs_version: "14" APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - nodejs_version: "12" APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - nodejs_version: "10" APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - nodejs_version: "8" APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 matrix: fast_finish: true # Install scripts. (runs after repo cloning) install: # Output useful info for debugging. - node --version - npm --version - py --list - py -VV # py is 64-bit AMD64 Python 3 on Visual Studio images - python -VV # python is 32-bit Intel Python 3 on Visual Studio images # Get the latest stable version of Node 0.STABLE.latest - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) x64 - node --version - set PATH=%APPDATA%\npm;%PATH% # Typical npm stuff. - npm install - npm run rebuild-tests # Post-install test scripts. test_script: # Output useful info for debugging. - node --version - npm --version - py --list - py -VV # py is 64-bit AMD64 Python 3 on Visual Studio images - python -VV # python is 32-bit Intel Python 3 on Visual Studio images # run tests - node node_modules\tap\bin\tap.js --gc test/js/*-test.js # Don't actually build. build: off # Set build version format here instead of in the admin panel. version: "{build}" nan-2.24.0/doc/000077500000000000000000000000001511403330700131155ustar00rootroot00000000000000nan-2.24.0/doc/.build.sh000077500000000000000000000016201511403330700146300ustar00rootroot00000000000000#!/usr/bin/env bash files=" \ methods.md \ scopes.md \ persistent.md \ new.md \ converters.md \ maybe_types.md \ script.md \ json.md \ errors.md \ buffers.md \ callback.md \ asyncworker.md \ string_bytes.md \ object_wrappers.md \ v8_internals.md \ v8_misc.md \ node_misc.md \ " __dirname=$(dirname "${BASH_SOURCE[0]}") head=$(perl -e 'while (<>) { if (!$en){print;} if ($_=~/ NanNew("foo").ToLocalChecked() */ if (arguments[groups[3][0]] === 'NanNew') { return [arguments[0], '.ToLocalChecked()'].join(''); } /* insert warning for removed functions as comment on new line above */ switch (arguments[groups[4][0]]) { case 'GetIndexedPropertiesExternalArrayData': case 'GetIndexedPropertiesExternalArrayDataLength': case 'GetIndexedPropertiesExternalArrayDataType': case 'GetIndexedPropertiesPixelData': case 'GetIndexedPropertiesPixelDataLength': case 'HasIndexedPropertiesInExternalArrayData': case 'HasIndexedPropertiesInPixelData': case 'SetIndexedPropertiesToExternalArrayData': case 'SetIndexedPropertiesToPixelData': return arguments[groups[4][0] - 1] ? arguments[0] : [warning1, arguments[0]].join(''); default: } /* remove unnecessary NanScope() */ switch (arguments[groups[5][0]]) { case 'NAN_GETTER': case 'NAN_METHOD': case 'NAN_SETTER': case 'NAN_INDEX_DELETER': case 'NAN_INDEX_ENUMERATOR': case 'NAN_INDEX_GETTER': case 'NAN_INDEX_QUERY': case 'NAN_INDEX_SETTER': case 'NAN_PROPERTY_DELETER': case 'NAN_PROPERTY_ENUMERATOR': case 'NAN_PROPERTY_GETTER': case 'NAN_PROPERTY_QUERY': case 'NAN_PROPERTY_SETTER': return arguments[groups[5][0] - 1]; default: } /* Value conversion */ switch (arguments[groups[6][0]]) { case 'Boolean': case 'Int32': case 'Integer': case 'Number': case 'Object': case 'String': case 'Uint32': return [arguments[groups[6][0] - 2], 'NanTo(', arguments[groups[6][0] - 1]].join(''); default: } /* other value conversion */ switch (arguments[groups[7][0]]) { case 'BooleanValue': return [arguments[groups[7][0] - 2], 'NanTo(', arguments[groups[7][0] - 1]].join(''); case 'Int32Value': return [arguments[groups[7][0] - 2], 'NanTo(', arguments[groups[7][0] - 1]].join(''); case 'IntegerValue': return [arguments[groups[7][0] - 2], 'NanTo(', arguments[groups[7][0] - 1]].join(''); case 'Uint32Value': return [arguments[groups[7][0] - 2], 'NanTo(', arguments[groups[7][0] - 1]].join(''); default: } /* NAN_WEAK_CALLBACK */ if (arguments[groups[8][0]] === 'NAN_WEAK_CALLBACK') { return ['template\nvoid ', arguments[groups[8][0] + 1], '(const NanWeakCallbackInfo &data)'].join(''); } /* use methods on NAN classes instead */ switch (arguments[groups[9][0]]) { case 'NanDisposePersistent': return [arguments[groups[9][0] + 1], '.Reset('].join(''); case 'NanObjectWrapHandle': return [arguments[groups[9][0] + 1], '->handle('].join(''); default: } /* use method on NanPersistent instead */ if (arguments[groups[10][0]] === 'NanMakeWeakPersistent') { return arguments[groups[10][0] + 1] + '.SetWeak('; } /* These return Maybes, the upper ones take no arguments */ switch (arguments[groups[11][0]]) { case 'GetEndColumn': case 'GetFunction': case 'GetLineNumber': case 'GetOwnPropertyNames': case 'GetPropertyNames': case 'GetSourceLine': case 'GetStartColumn': case 'NewInstance': case 'ObjectProtoToString': case 'ToArrayIndex': case 'ToDetailString': return [arguments[groups[11][0] - 2], 'Nan', arguments[groups[11][0]], '(', arguments[groups[11][0] - 1]].join(''); case 'CallAsConstructor': case 'CallAsFunction': case 'CloneElementAt': case 'Delete': case 'ForceSet': case 'Get': case 'GetPropertyAttributes': case 'GetRealNamedProperty': case 'GetRealNamedPropertyInPrototypeChain': case 'Has': case 'HasOwnProperty': case 'HasRealIndexedProperty': case 'HasRealNamedCallbackProperty': case 'HasRealNamedProperty': case 'Set': case 'SetAccessor': case 'SetIndexedPropertyHandler': case 'SetNamedPropertyHandler': case 'SetPrototype': return [arguments[groups[11][0] - 2], 'Nan', arguments[groups[11][0]], '(', arguments[groups[11][0] - 1], ', '].join(''); default: } /* Automatic ToLocalChecked(), take it or leave it */ switch (arguments[groups[12][0]]) { case 'Date': case 'String': case 'RegExp': return ['NanNew', arguments[groups[12][0] - 1], arguments[groups[12][0] + 1], '.ToLocalChecked()'].join(''); default: } /* NanEquals is now required for uniformity */ if (arguments[groups[13][0]] === 'Equals') { return [arguments[groups[13][0] - 1], 'NanEquals(', arguments[groups[13][0] - 1], ', ', arguments[groups[13][0] + 1]].join(''); } /* use method on replacement class instead */ if (arguments[groups[14][0]] === 'NanAssignPersistent') { return [arguments[groups[14][0] + 1], '.Reset('].join(''); } /* args --> info */ if (arguments[groups[15][0]] === 'args') { return [arguments[groups[15][0] - 1], 'info', arguments[groups[15][0] + 1]].join(''); } /* ObjectWrap --> NanObjectWrap */ if (arguments[groups[16][0]] === 'ObjectWrap') { return [arguments[groups[16][0] - 1], 'NanObjectWrap', arguments[groups[16][0] + 1]].join(''); } /* Persistent --> NanPersistent */ if (arguments[groups[17][0]] === 'Persistent') { return [arguments[groups[17][0] - 1], 'NanPersistent', arguments[groups[17][0] + 1]].join(''); } /* This should not happen. A switch is probably missing a case if it does. */ throw 'Unhandled match: ' + arguments[0]; } /* reads a file, runs replacement and writes it back */ function processFile(file) { fs.readFile(file, {encoding: 'utf8'}, function (err, data) { if (err) { throw err; } /* run replacement twice, might need more runs */ fs.writeFile(file, data.replace(master, replace).replace(master, replace), function (err) { if (err) { throw err; } }); }); } /* process file names from command line and process the identified files */ for (i = 2, length = process.argv.length; i < length; i++) { glob(process.argv[i], function (err, matches) { if (err) { throw err; } matches.forEach(processFile); }); } nan-2.24.0/tools/README.md000066400000000000000000000007101511403330700147650ustar00rootroot000000000000001to2 naively converts source code files from NAN 1 to NAN 2. There will be erroneous conversions, false positives and missed opportunities. The input files are rewritten in place. Make sure that you have backups. You will have to manually review the changes afterwards and do some touchups. ```sh $ tools/1to2.js Usage: 1to2 [options] Options: -h, --help output usage information -V, --version output the version number ``` nan-2.24.0/tools/package.json000066400000000000000000000006711511403330700160020ustar00rootroot00000000000000{ "name": "1to2", "version": "1.0.0", "description": "NAN 1 -> 2 Migration Script", "main": "1to2.js", "repository": { "type": "git", "url": "git://github.com/nodejs/nan.git" }, "contributors": [ "Benjamin Byholm (https://github.com/kkoopa/)", "Mathias Küsel (https://github.com/mathiask88/)" ], "dependencies": { "glob": "~5.0.10", "commander": "~2.8.1" }, "license": "MIT" }