Questions tagged [node-addon-api]

node-addon-api is the C++ wrapper for N-API, the ABI stable library to build addons for Node.js.

126 questions
2
votes
0 answers

node-addon-api pass object of another class as callback function argument

How do I pass an object of another class as a parameter of a callback function in node-addon-api? Code Snippet: #include #include "Third_Party_Library.h" using namespace Napi; class WorkerInit : public AsyncWorker { public: …
Ganesh Rathinavel
  • 1,243
  • 4
  • 17
  • 38
1
vote
0 answers

Do NodeJS addons use the Heap?

After reading this post about the heap, I'm left wondering: do the operations performed in a Node addon context consume that same heap memory?
glimmbo
  • 143
  • 10
1
vote
0 answers

I can't connect to web socket server in electron app

I am working on electron project which includes node addon module. In native module, I am using ixWebSocket library to communicate with third party api. After initializing websocket properties, I call start() function to run background thread. Code…
1
vote
0 answers

Node-gyp build fails. Unable to figure out what is causing the issue

Iam trying to install the jsonski package, but Iam encountering issues with node-gyp while doing so. I am able to run the node-gyp configure command without issues as seen below, ubuntu@Ubuntu-22:~/JSON/JSONSki$ node-gyp configure gyp info it worked…
1
vote
1 answer

How do I call a JS callbacks from C++ with node-addon-api?

I need a way to invoke JS callbacks from a C library that uses contexts. Here's an example: const ctx1 = mylib_init(); mylib_set_event_callback(ctx1, () => { console.log("EVENT"); }); Napi::FunctionReference cb; bool done = false; // Used to…
Alex Shaw
  • 163
  • 1
  • 7
1
vote
0 answers

An Electron RTSP player: How to play the video stream?

What seemed to be an easy job turned out otherwise. I wanted to write an Electron app to manage DVR streams as I wasn't satisfied with some apps I used. I choose Electron because I recently started JS and took the opportunity to practice it and also…
Siavoshkc
  • 346
  • 2
  • 16
1
vote
0 answers

Node addon "Check failed: IsEmpty()"

I have a Node addon related to a failure, when I destroy an object. I have no idea which object is causing that. Here is some features I am using. I have a project where I create a few objects using Napi::ObjectWrap, some asynchronous functions that…
Bob
  • 13,867
  • 1
  • 5
  • 27
1
vote
1 answer

How do you avoid full compilation with gyp?

I'm getting started with the `node-addon-api' and while my code does compile and run, I do get the following warning: Generating code Previous IPDB not found, fall back to full compilation. All 303 functions were compiled because no usable…
Markstar
  • 639
  • 9
  • 24
1
vote
0 answers

How to instantiate and return a wrapped C++ object from AsyncWorker

I'm following the Node Addon API documentation to resolve a promise on the C++ side. On resolve I'd like to return a C++ object back to JS. My code is similar to what is here. The main difference is that I'd like to return an instance of the object…
Ali
  • 1,001
  • 2
  • 14
  • 32
1
vote
1 answer

Node addon crashes in Electron but works fine in vanilla Node

I am building a Node addon on macOS to communicate with Apple's Photos framework, it will query photos from the Photos library and export them to a folder. The addon works well in vanilla Node (v16.14.0), but it crashes in Electron. I am using…
Hao Xi
  • 351
  • 4
  • 12
1
vote
1 answer

Electron Node addon with AsyncWorker hang on `dispatch_group_wait` on macOS

I am creating a Node addon to export a video file from macOS Photos library, as it takes a few seconds, I wrapped the code into an AsyncWorker. The C++ / Objective-C code: class Napi_PhotosExport_AsyncWorker : public Napi::AsyncWorker { void…
Hao Xi
  • 351
  • 4
  • 12
1
vote
1 answer

How to iterate JavaScript array using Node-API

I'm building a Node.js addon using Node-API. Basically, my algorithm takes a js array as the input and then process it inside the addon and return it. To do any logic for the array I need to loop through it. But I don't know-how. Because I didn't…
0xdw
  • 3,755
  • 2
  • 25
  • 40
1
vote
1 answer

Can nw addon be built with _HAS_ITERATOR_DEBUGGING=1 for debug mode? (Windows)

Original questin: Is there any way to get what macros nw-gyp add to the build project by default? I'm developing a nw addon and I've tried to link a custom static lib to .node DLL. However I found nw-gyp will add _HAS_ITERATOR_DEBUGGING=0 by default…
Jian Wang
  • 41
  • 4
1
vote
2 answers

NodeJS module compilation

I have a node add on module using node-addon-api interface. { "targets": [ { "target_name": "mod", "sources": [ "./src/index.cpp", ... ], "include_dirs": [ ..., "
Bob
  • 13,867
  • 1
  • 5
  • 27
1
vote
1 answer

Node addon don't work in electron, but worked in nodejs

I wrote a nodejs addon, compiled with node-gyp. It won't work on electron, but nodejs worked. The nodejs and electron node has the same version. The addon do these things: Load ffmpeg static library and open a rtsp or local file. Convert the frame…
Yohanan
  • 13
  • 2
1 2
3
8 9