Migrate project from NAN to Node-API for improved compatibility
Hello there, This pr is the contribution to issue #1036,
Here's a summary of the changes made to migrate the project from nan to Node-API: src/addon.cpp Replaced #include <nan.h> with #include <node_api.h>. Updated the IsRunningInElectronRenderer function to use Node-API functions instead of nan functions. Modified the InitModule function to use Node-API for module initialization.
src/shadow_node.hpp Replaced #include <nan.h> with #include <node_api.h>. Changed the class inheritance from Nan::ObjectWrap to Napi::ObjectWrap<ShadowNode>. Updated method signatures to use Napi::CallbackInfo instead of Nan::FunctionCallbackInfov8::Value. Replaced Nan::Persistentv8::Function with Napi::FunctionReference.
src/rcl_handle.cpp Replaced #include <nan.h> with #include <node_api.h>. Changed the class inheritance from Nan::ObjectWrap to Napi::ObjectWrap<RclHandle>. Updated method signatures to use Napi::CallbackInfo instead of Nan::FunctionCallbackInfov8::Value. Replaced Nan functions with their Node-API equivalents in the Init, New, SyncProperties, PropertiesGetter, Release, Dismiss, and NewInstance methods.
src/rcl_bindings.cpp Replaced #include <nan.h> with #include <node_api.h>. Updated the Init and CreateNode methods to use Node-API functions instead of Nan functions. src/rcl_action_bindings.cpp Updated the ActionCreateServer method to use Node-API instead of nan.
If any feedback feel free to mention.
Just wondering if we could leverage AI agent to convert most of the code from NAPI to Node-API :smile:
Just wondering if we could leverage AI agent to convert most of the code from NAPI to Node-API 😄
Glad for your reply, I believe using AI in efficient way will help in the problem solving faster.
Can you just check it now,
I just modified the following things,
- Header File: Included node_api.h in both files.
- Initialization Function: Updated the initialization function to use Node-API conventions.
- Module Registration: Used NAPI_MODULE macro for module registration.
i welcome you with some feedback to it.