• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Node-API Data Types and APIs
2
3## Data Types
4
5### napi_status
6
7Enum indicating the execution status of a Node-API call.
8
9Each time a Node-API function is called, a value of **napi_status** is returned indicating the execution result.
10
11```c
12typedef enum {
13    napi_ok,
14    napi_invalid_arg,
15    napi_object_expected,
16    napi_string_expected,
17    napi_name_expected,
18    napi_function_expected,
19    napi_number_expected,
20    napi_boolean_expected,
21    napi_array_expected,
22    napi_generic_failure,
23    napi_pending_exception,
24    napi_cancelled,
25    napi_escape_called_twice,
26    napi_handle_scope_mismatch,
27    napi_callback_scope_mismatch,
28    napi_queue_full,
29    napi_closing,
30    napi_bigint_expected,
31    napi_date_expected,
32    napi_arraybuffer_expected,
33    napi_detachable_arraybuffer_expected,
34    napi_would_deadlock, /* unused */
35    napi_no_external_buffers_allowed,
36    napi_cannot_run_js
37} napi_status;
38```
39
40### napi_extended_error_info
41
42Struct that holds detailed error information when a Node-API call fails.
43
44```c
45typedef struct {
46    const char *error_message;
47    void *engine_reserved;
48    uint32_t engine_error_code;
49    napi_status error_code;
50} napi_extended_error_info;
51```
52
53### napi_value
54
55A C struct pointer acting as a reference to a JS object. A **napi_value** holds a JS object. **handle_scope** is used to manage the lifetime of **napi_value** handles. The JS object held by a **napi_value** in the scope will not be released. If the **napi_value** is out of the scope, it becomes invalid and will no longer hold the JS object.
56
57### napi_env
58
59- Context used by the underlying Node-API implementation. It is passed to the native functions when they are invoked, and must be passed back when Node-API calls are made.
60
61- **napi_env** becomes invalid when the JS thread bound with **napi_env** exits.
62
63- Avoid caching **napi_env** or passing **napi_env** between instances of the same addon running on different worker threads.
64
65### napi_threadsafe_function
66
67Pointer that represents a JS function that can be called asynchronously from multiple threads. It can be used to pass the asynchronous (async for short) operation result to the JS environment, such as reading data from another thread or performing compute-intensive operations. In addition, it can be used to call functions in C++ code from a JS environment for execution in another thread. By using **napi_threadsafe_function**, you can implement efficient interaction between JS and C++ code while maintaining thread safety.
68
69### napi_threadsafe_function_release_mode
70
71Enum that indicates when to release the thread-safe function.
72
73```c
74typedef enum {
75  napi_tsfn_release,
76  napi_tsfn_abort
77} napi_threadsafe_function_release_mode;
78```
79
80Its value is passed to **napi_release_threadsafe_function**.
81
82```cpp
83napi_release_threadsafe_function(napi_threadsafe_function func,
84                                 napi_threadsafe_function_release_mode mode);
85```
86
87- If the value is **napi_tsfn_release**, the current thread will not call this thread-safe function.
88
89- If the value is **napi_tsfn_abort**, only the current thread can call this thread-safe function.
90  In this case, using **napi_call_threadsafe_function** to call this function will return **napi_closing**, and this function will not be placed in the queue.
91
92### napi_threadsafe_function_call_mode
93
94Enum that indicates whether the call should be blocked when the queue associated with the thread-safe function is full.
95
96The data struct is as follows:
97
98```c
99typedef enum {
100  napi_tsfn_nonblocking,
101  napi_tsfn_blocking
102} napi_threadsafe_function_call_mode;
103```
104
105- **napi_tsfn_nonblocking**: Leave **napi_call_threadsafe_function** unblocked. If the queue is full, **napi_queue_full** is returned to prevent data from being added to the queue.
106
107- **napi_tsfn_blocking**: Block **napi_call_threadsafe_function** until there is available space in the queue.
108
109### Memory Management Types
110
111Node-API provides the following memory management types:
112
113**napi_handle_scope**
114
115Data used to manage the lifecycle of JS objects. It allows JS objects to remain active within a certain range for use in JS code. When **napi_handle_scope** is created, all JS objects created in this range remain active until the scope ends. This prevents released objects from being used in JS code, which improves code reliability and performance.
116
117**napi_escapable_handle_scope**
118
119- It is created by **napi_open_escapable_handle_scope** and closed by **napi_close_escapable_handle_scope**.
120
121- It is a special type of handle range used to return values created within the scope of **escapable_handle_scope** to a parent scope.
122
123- You can use **napi_escape_handle** to promote **escape_handle_scope** to a JS object so that it is valid for the lifetime of the outer scope.
124
125**napi_ref**
126
127Reference to **napi_value**, which allows you to manage the lifecycle of JS values.
128
129**napi_type_tag**
130
131Struct containing two unsigned 64-bit integers to identify the type of a Node-API value.
132
133```c
134typedef struct {
135  uint64_t lower;
136  uint64_t upper;
137} napi_type_tag;
138```
139
140- It is a 128-bit value stored as two unsigned 64-bit integers. It is used to tag JS objects to ensure that they are of a certain type.
141
142- This is a stronger check than **napi_instanceof** because **napi_instanceof** may report a false positive if the object's prototype is manipulated.
143
144- The combination of **type_tag** and **napi_wrap** is useful because it ensures that the pointer retrieved from a wrapped object can be safely converted to the native type corresponding to the type tag that had been previously applied to the JS object.
145
146**napi_async_cleanup_hook_handle**
147
148Value used to add a callback for an async operation. It is mainly used to perform a cleanup operation when an async operation is complete or canceled, for example, releasing a resource or canceling an operation. Using **napi_async_cleanup_hook_handle** ensures that related resources are correctly released and cleaned up when an async operation is complete or canceled, thereby avoiding problems such as memory leakage.
149
150### Callback Types
151
152Node-API provides the following callback types:
153
154**napi_callback_info**
155
156Data type passed to **napi_get_cb_info** to obtain JS input parameters.
157
158**napi_callback**
159
160User-defined native function, which is exposed to JS via Node-API. Generally, no handle or callback scope is created inside this callback.
161
162The basic usage is as follows:
163
164```c
165typedef napi_value (*napi_callback)(napi_env, napi_callback_info);
166```
167
168**napi_finalize**
169
170Function pointer passed to **napi_create_threadsafe_function** and **napi_set_instance_data**. **napi_finalize** is called when an object is reclaimed.
171
172**napi_async_execute_callback**
173
174Function pointer used in **napi_create_async_work**.
175
176- An async native function is called from a worker pool thread and can be executed in parallel with the main event loop thread.
177
178- Avoid making Node-API calls that execute JS code or interact with JS objects when implementing this callback.
179
180- Node-API calls should be executed in **napi_async_complete_callback**.
181
182**napi_async_complete_callback**
183
184Function pointer used when an async operation is complete. When an async operation is required, you can use **napi_create_async_work** to create an async work and specify **napi_async_complete_callback**. When the async work is complete, the callback will be automatically invoked for subsequent processing. Parameters of the callback include the status of the async operation and a return value, based on which corresponding processing can be performed.
185
186**napi_threadsafe_function_call_js**
187
188Function pointer used in the main thread to interact with the JS code in an independent thread to implement more complex scenarios. It is used in **napi_create_threadsafe_function(napi_env env, ..., napi_threadsafe_function_call_js call_js_cb, ...)**.
189
190**napi_cleanup_hook**
191
192Function pointer used with **napi_add_env_cleanup_hook**. It will be called when the environment is destroyed.
193
194**napi_async_cleanup_hook**
195
196Function pointer used with **napi_add_async_cleanup_hook**. It will be called when the environment is destroyed.
197
198### QoS
199
200Enum indicating the thread scheduling priority.
201
202```c
203typedef enum {
204  napi_qos_background = 0,
205  napi_qos_utility = 1,
206  napi_qos_default = 2,
207  napi_qos_user_initiated = 3,
208} napi_qos_t;
209```
210
211| QoS| Use Scenario|
212| -------- | -------- |
213| napi_qos_background | Low priority for works invisible to users, such as data synchronization and backup.|
214| napi_qos_utility | Medium priority for works that do not require immediate response, such as downloading or importing data.|
215| napi_qos_default | Default priority.|
216| napi_qos_user_initiated | High priority for user-triggered works with visible progress, for example, opening a file.|
217
218### Event Loop Modes
219
220Node-API provides two modes for running the underlying event loop. The two modes are defined as follows:
221
222```c
223typedef enum {
224    napi_event_mode_default = 0,
225    napi_event_mode_nowait = 1,
226} napi_event_mode;
227```
228
229| Event Loop Mode| Description|
230| -------- | -------- |
231| napi_event_mode_default |  Run the underlying event loop while blocking the current thread, and exit the event loop only when there is no task in the loop.|
232| napi_event_mode_nowait | Run the underlying event loop without blocking the current thread. Process a task and exit the event loop after the task is complete. If there is no task in the event loop, exit the event loop immediately.|
233
234### Thread-safe Task Priority
235
236Node-API defines the priorities of thread-safe tasks, as listed below. The tasks in the underlying task queue are executed in sequence based on their priorities.
237
238```c
239typedef enum {
240    napi_priority_immediate = 0,
241    napi_priority_high = 1,
242    napi_priority_low = 2,
243    napi_priority_idle = 3,
244} napi_task_priority;
245```
246
247| Task Priority| Description|
248| -------- | -------- |
249| napi_priority_immediate | Highest priority.|
250| napi_priority_high | Priority lower than **napi_priority_immediate**.|
251| napi_priority_low | Priority lower than **napi_priority_high**.|
252| napi_priority_idle | Lowest priority.|
253
254## APIs
255
256Node-API is extended based on the native modules provided by Node.js. The following lists the APIs supported currently.
257
258### Async Thread-Safe APIs
259
260| API| Description|
261| -------- | -------- |
262| napi_create_threadsafe_function | Creates a thread-safe function.|
263| napi_get_threadsafe_function_context | Obtains the context of a thread-safe function.|
264| napi_call_threadsafe_function | Calls a thread-safe function.|
265| napi_acquire_threadsafe_function | Acquires a thread-safe function.|
266| napi_release_threadsafe_function | Releases a thread-safe function.|
267| napi_ref_threadsafe_function | Indicates that the event loop running on the main thread should not exit until the thread-safe function is destroyed.|
268| napi_unref_threadsafe_function | Indicates that the event loop running on the main thread may exit before the thread-safe function is destroyed.|
269
270### Buffer
271
272| API| Description|
273| -------- | -------- |
274| napi_create_buffer | Creates a JS **Buffer** of the specified size.|
275| napi_create_buffer_copy | Creates a JS **Buffer** of the specified size and initializes it with the given data.|
276| napi_create_external_buffer | Creates a JS **Buffer** of the specified size and initializes it with the given data.|
277| napi_get_buffer_info | Obtains the underlying data of a JS **Buffer** and its length.|
278| napi_is_buffer | Checks whether the given JS value is a **Buffer** object.|
279| napi_create_external_arraybuffer | Creates a JS **ArrayBuffer** with external data.|
280
281### String
282
283| API| Description|
284| -------- | -------- |
285| napi_create_string_utf16 | Creates a JS string from a UTF16-encoded C string.|
286| napi_get_value_string_utf16 | Obtains the UTF16-encoded string corresponding to the given JS value.|
287| napi_create_string_latin1 | Creates a JS string from an ISO-8859-1-encoded C string.|
288| napi_create_string_utf8 | Creates a JS string from a UTF8-encoded C string.|
289| napi_get_value_string_latin1 | Obtains the ISO-8859-1-encoded string corresponding to the given JS value.|
290| napi_get_value_string_utf8 | Obtains the UTF8-encoded string corresponding to the given JS value.|
291
292### Date
293
294| API| Description|
295| -------- | -------- |
296| napi_create_date | Creates a JS **Date** object from C double data.|
297| napi_get_date_value | Obtains the C double equivalent of the given JS **Date** object.|
298| napi_is_date | Checks whether the given JS value is a JS **Date** object.|
299
300### ArrayBuffer
301
302| API| Description|
303| -------- | -------- |
304| napi_get_arraybuffer_info | Obtains the underlying data buffer of an **ArrayBuffer** and its length.|
305| napi_is_arraybuffer | Checks whether the given JS value is an **ArrayBuffer** object.|
306| napi_detach_arraybuffer | Detaches the underlying data of the given **ArrayBuffer**.|
307| napi_is_detached_arraybuffer | Checks whether the given **ArrayBuffer** has been detached.|
308| napi_create_arraybuffer | Creates a JS **ArrayBuffer** object of the specified size.|
309
310### Module
311
312| API| Description|
313| -------- | -------- |
314| napi_module_register | Registers a native module.|
315
316### Lifecycle Management
317
318| API| Description|
319| -------- | -------- |
320| napi_open_handle_scope | Opens a scope. You can use **napi_close_handle_scope** to close it.|
321| napi_close_handle_scope | Closes the scope passed in. After a scope is closed, all references declared in it are closed.|
322| napi_open_escapable_handle_scope | Opens an escapable handle scope, from which the declared values can be returned to the parent scope. You can use **napi_close_escapable_handle_scope** to close it.|
323| napi_close_escapable_handle_scope | Closes the escapable handle scope passed in.|
324| napi_escape_handle | Promotes the handle to the JS object so that it is valid for the lifetime of the parent scope.|
325| napi_create_reference | Creates a reference for an object to extend its lifespan. The caller needs to manage the reference lifespan.|
326| napi_delete_reference | Deletes the reference passed in.|
327| napi_reference_ref | Increments the reference count passed in and returns the new count.|
328| napi_reference_unref | Decrements the reference count passed in and returns the new count.|
329| napi_get_reference_value | Obtains the JS object associated with the reference.|
330| napi_add_finalizer | Adds a **napi_finalize** callback, which will be called when the JS object is garbage-collected.|
331
332### Promise
333
334| API| Description|
335| -------- | -------- |
336| napi_create_promise | Creates a deferred object and a JS promise.|
337| napi_resolve_deferred | Resolves a promise by way of the deferred object associated.|
338| napi_reject_deferred | Rejects a promise by way of the deferred object associated.|
339| napi_is_promise | Checks whether the given **napi_value** is a promise object.|
340
341### Array
342
343| API| Description|
344| -------- | -------- |
345| napi_create_array | Creates a JS **Array**.|
346| napi_create_array_with_length | Creates a JS **Array** of the specified length.|
347| napi_get_array_length | Obtains the length of an array.|
348| napi_is_array | Checks whether the given JS value is an **Array** object.|
349| napi_set_element | Sets an element at the specified index of the given **Object**.|
350| napi_get_element | Obtains the element at the specified index of the given **Object**.|
351| napi_has_element | Checks whether the given **Object** has an element at the specified index.|
352| napi_delete_element | Deletes the element at the specified index of the given **Object**.|
353| napi_create_typedarray | Creates a JS **TypedArray** from an existing **ArrayBuffer**.|
354| napi_is_typedarray | Checks whether a JS value is a **TypeArray** object.|
355| napi_get_typedarray_info | Obtains the properties of a **TypedArray**.|
356| napi_create_dataview | Creates a JS **DataView** from an existing **ArrayBuffer**.|
357| napi_is_dataview | Checks whether a JS value is a **DataView** object.|
358| napi_get_dataview_info | Obtains the properties of a **DataView**.|
359
360### Primitives
361
362| API| Description|
363| -------- | -------- |
364| napi_get_boolean | Obtains a JS Boolean object based on the given C Boolean value.|
365| napi_get_global | Obtains the **global** object.|
366| napi_get_null | Obtains the **null** object.|
367| napi_get_undefined | Obtains the **undefined** object.|
368| napi_coerce_to_bool | Forcibly converts a JS value into a JS Boolean value.|
369| napi_coerce_to_number | Forcibly converts a JS value into a JS number.|
370| napi_coerce_to_object | Forcibly converts a JS value into a JS object.|
371| napi_coerce_to_string | Forcibly converts a JS value into a JS string.|
372
373### Class
374
375| API| Description|
376| -------- | -------- |
377| napi_new_instance | Creates an instance based on the given constructor.|
378| napi_get_new_target | Obtains the **new.target** of the constructor call.|
379| napi_define_class | Defines a JS class corresponding to the C++ class.|
380| napi_wrap | Wraps a native object into an ArkTS object. This API allows the methods and properties of a native object to be called from ArkTS.|
381| napi_unwrap | Unwraps the native object from an ArkTS object.|
382| napi_remove_wrap | Removes the wrapping after the native object is unwrapped from an ArkTS object.|
383
384### Object
385
386| API| Description|
387| -------- | -------- |
388| napi_get_prototype | Obtains the prototype of a JS object.|
389| napi_create_object | Creates a default JS object.|
390| napi_object_freeze | Freezes an object.|
391| napi_object_seal | Seals an object.|
392| napi_typeof | Obtains the JS type of a JS value.|
393| napi_instanceof | Checks whether the given object is an instance of the specified constructor.|
394| napi_type_tag_object | Associates the value of the tag pointer with a JS object.|
395| napi_check_object_type_tag | Checks whether a tag pointer is associated with a JS object.|
396| napi_create_symbol | Creates a JS **Symbol** object.|
397| napi_create_external | Creates a JS external object, which can be used to pass custom data structs or objects in C/C++ to JS so that it can be accessible from JS.|
398| napi_get_value_external | Obtains the JS data from the external object created by **napi_create_external**. This API can be used to pass data between JS and C/C++.|
399
400### Basic Data Types
401
402| API| Description|
403| -------- | -------- |
404| napi_create_int32 | Creates a JS number from a C int32 value.|
405| napi_create_uint32 | Creates a JS number from a C uint32 value.|
406| napi_create_int64 | Creates a JS number from a C int64 value.|
407| napi_create_double | Creates a JS number from a C double value.|
408| napi_get_value_int32 | Obtains the C int32 equivalent of a JS number.|
409| napi_get_value_uint32 | Obtains the C uint32 equivalent of a JS number.|
410| napi_get_value_int64 | Obtains the C int64 equivalent of a JS number.|
411| napi_get_value_double | Obtains the C double equivalent of a JS number.|
412|napi_get_value_bool|Obtains the C bool equivalent of a JS Boolean value.|
413
414### BigInt
415
416| API| Description|
417| -------- | -------- |
418| napi_create_bigint_int64 | Creates a JS BigInt from C int64 data.|
419| napi_create_bigint_uint64 | Creates a JS BigInt from C uint64 data.|
420| napi_create_bigint_words | Creates a single JS BigInt from a C uint64 array.|
421| napi_get_value_bigint_int64 | Obtains the C int64 equivalent of a JS BigInt.|
422| napi_get_value_bigint_uint64 | Obtains the C uint64 equivalent of a JS BigInt.|
423| napi_get_value_bigint_words | Obtains information from a JS BigInt, including the sign bit, 64-bit little-endian array, and number of elements in the array.|
424
425### Exceptions and Errors
426
427| API| Description|
428| -------- | -------- |
429| napi_throw | Throws a JS value.|
430| napi_throw_error | Throws an ArkTS **Error** object with text information.|
431| napi_throw_type_error | Throws a JS type error with text information.|
432| napi_throw_range_error | Throws a JS range error with text information.|
433| napi_is_error | Checks whether **napi_value** indicates an error object.|
434| napi_create_error | Creates a JS **Error** with text information.|
435| napi_create_type_error | Creates a JS **TypeError** with text information.|
436| napi_create_range_error | Creates a JS **RangeError** with text information.|
437| napi_get_and_clear_last_exception | Obtains and clears the latest exception.|
438| napi_is_exception_pending | Checks whether an exception occurs.|
439| napi_fatal_error | Raises a fatal error to terminate the process immediately.|
440| napi_get_last_error_info | Obtains the **napi_extended_error_info** struct, which contains the latest error information.|
441| napi_fatal_exception | Throws a fatal exception, terminates the process, and generates a crash log.|
442
443### Property
444
445| API| Description|
446| -------- | -------- |
447| napi_get_property_names | Obtains the names of the enumerable properties of an object in an array of strings.|
448| napi_set_property | Sets a property for an object.|
449| napi_get_property | Obtains the requested property of an object.|
450| napi_has_property | Checks whether an object has the specified property.|
451| napi_delete_property | Deletes a property from an object.|
452| napi_has_own_property | Checks whether an object has the own property specified by **key**.|
453| napi_set_named_property | Sets a property with the specified name for an object.|
454| napi_get_named_property | Obtains the property with the specified name in an object.|
455| napi_has_named_property | Checks whether an object has the property with the specified name.|
456| napi_define_properties | Defines multiple properties for an object.|
457| napi_get_all_property_names | Obtains an array containing the names of all the available properties of this object.|
458
459### Async Works
460
461| API| Description|
462| -------- | -------- |
463| napi_create_async_work | Creates a work object that executes logic asynchronously.|
464| napi_delete_async_work | Releases an async work object.|
465| napi_queue_async_work | Adds an async work object to the queue so that it can be scheduled for execution.|
466| napi_cancel_async_work | Cancels a queued async work if it has not been started.|
467
468### Custom Async Operations
469
470| API| Description|
471| -------- | -------- |
472| napi_async_init | Creates an async context. The capabilities related to **async_hook** are not supported.|
473| napi_make_callback | Allows a JS function to be called in the async context. The capabilities related to **async_hook** are not supported.|
474| napi_async_destroy | Destroys the previously created async context. The capabilities related to **async_hook** are not supported.|
475| napi_open_callback_scope | Opens a callback scope. The capabilities related to **async_hook** are not supported.|
476| napi_close_callback_scope | Closes the callback scope. The capabilities related to **async_hook** are not supported.|
477
478### UV
479
480| API| Description|
481| -------- | -------- |
482| napi_get_uv_event_loop | Obtains the current libuv loop instance.|
483
484### Function Invocation
485
486| API| Description|
487| -------- | -------- |
488| napi_call_function | Calls a JS function from a C/C++ addon.|
489| napi_get_cb_info | Obtains detailed information about the call, such as the parameters and **this** pointer, from the given callback info.|
490
491### Extended Capabilities
492
493[Node-API Extended Symbols](../reference/native-lib/napi.md#node-api-extended-symbols)
494
495| API| Description|
496| -------- | -------- |
497| napi_queue_async_work_with_qos | Adds an async work object to the queue and schedules it based on the QoS passed in.|
498| napi_run_script_path | Runs an .abc file.|
499| napi_load_module | Loads an .abc file as a module. This API returns the namespace of the module.|
500| napi_load_module_with_info | Loads an .abc file as a module. This API returns the namespace of the module, which can be used in the newly created ArkTS runtime environment.|
501| napi_create_object_with_properties | Creates a JS object using the given **napi_property_descriptor**. The key of the descriptor must be a string and cannot be converted into a number.|
502| napi_create_object_with_named_properties | Creates a JS object using the given **napi_value**s and keys. The key must be a string and cannot be converted into a number.|
503| napi_coerce_to_native_binding_object | Forcibly binds a JS object and a native object.|
504| napi_create_ark_runtime|Creates an ArkTS runtime environment.|
505| napi_destroy_ark_runtime|Destroys an ArkTS runtime environment.|
506| napi_run_event_loop | Runs the underlying event loop.|
507| napi_stop_event_loop | Stops the underlying event loop.|
508| napi_serialize | Converts an ArkTS object into native data.|
509| napi_deserialize | Converts native data into an ArkTS object.|
510| napi_delete_serialization_data | Deletes serialized data.|
511| napi_call_threadsafe_function_with_priority|Calls a task with the specified priority and enqueuing mode into the ArkTS main thread.|
512| napi_is_sendable|Checks whether the given JS value is sendable.|
513| napi_define_sendable_class|Creates a **sendable** class.|
514| napi_create_sendable_object_with_properties | Creates a sendable object with the given **napi_property_descriptor**.|
515| napi_create_sendable_array | Creates a sendable array.|
516| napi_create_sendable_array_with_length | Creates a sendable array of the specified length.|
517| napi_create_sendable_arraybuffer | Creates a sendable ArrayBuffer.|
518| napi_create_sendable_typedarray | Creates a sendable TypedArray.|
519| napi_wrap_sendable | Wraps a native instance into an ArkTS object.|
520| napi_wrap_sendable_with_size | Wraps a native instance into an ArkTS object with the specified size.|
521| napi_unwrap_sendable | Unwraps the native instance from an ArkTS object.|
522| napi_remove_wrap_sendable | Removes the native instance from an ArkTS object.|
523
524#### napi_queue_async_work_with_qos
525
526```c
527napi_status napi_queue_async_work_with_qos(napi_env env,
528                                           napi_async_work work,
529                                           napi_qos_t qos);
530```
531
532This API has the same usage as **napi_queue_async_work**. The difference is you can specify the QoS for the work to run.
533
534#### napi_run_script_path
535
536```c
537napi_status napi_run_script_path(napi_env env,
538                                 const char* abcPath,
539                                 napi_value* result);
540```
541
542#### napi_load_module
543
544```c
545napi_status napi_load_module(napi_env env,
546                             const char* path,
547                             napi_value* result);
548```
549
550#### napi_create_object_with_properties
551
552```c
553napi_status napi_create_object_with_properties(napi_env env,
554                                               napi_value* result,
555                                               size_t property_count,
556                                               const napi_property_descriptor* properties);
557```
558
559#### napi_create_object_with_named_properties
560
561```c
562napi_status napi_create_object_with_named_properties(napi_env env,
563                                                     napi_value* result,
564                                                     size_t property_count,
565                                                     const char** keys,
566                                                     const napi_value* values);
567```
568
569#### napi_coerce_to_native_binding_object
570
571```c
572napi_status napi_coerce_to_native_binding_object(napi_env env,
573                                                 napi_value js_object,
574                                                 napi_native_binding_detach_callback detach_cb,
575                                                 napi_native_binding_attach_callback attach_cb,
576                                                 void* native_object,
577                                                 void* hint);
578```
579
580#### napi_run_event_loop
581
582```c
583napi_status napi_run_event_loop(napi_env env, napi_event_mode mode);
584```
585
586#### napi_stop_event_loop
587
588```c
589napi_status napi_stop_event_loop(napi_env env);
590```
591
592#### napi_serialize
593
594```c
595napi_status napi_serialize(napi_env env,
596                           napi_value object,
597                           napi_value transfer_list,
598                           napi_value clone_list,
599                           void** result);
600```
601
602#### napi_deserialize
603
604```c
605napi_status napi_deserialize(napi_env env, void* buffer, napi_value* object);
606```
607
608#### napi_delete_serialization_data
609
610```c
611napi_status napi_delete_serialization_data(napi_env env, void* buffer);
612```
613
614#### napi_call_threadsafe_function_with_priority
615
616```c
617napi_status napi_call_threadsafe_function_with_priority(napi_threadsafe_function func,
618                                                        void *data,
619                                                        napi_task_priority priority,
620                                                        bool isTail);
621```
622
623#### napi_is_sendable
624
625```c
626napi_status napi_is_sendable(napi_env env, napi_value value, bool* result);
627```
628
629#### napi_define_sendable_class
630
631```c
632napi_status napi_define_sendable_class(napi_env env,
633                                       const char* utf8name,
634                                       size_t length,
635                                       napi_callback constructor,
636                                       void* data,
637                                       size_t property_count,
638                                       const napi_property_descriptor* properties,
639                                       napi_value parent,
640                                       napi_value* result);
641
642```
643
644#### napi_create_sendable_object_with_properties
645
646```c
647napi_status napi_create_sendable_object_with_properties(napi_env env,
648                                                        size_t property_count,
649                                                        const napi_property_descriptor* properties,
650                                                        napi_value* result);
651```
652
653#### napi_create_sendable_array
654
655```c
656napi_status napi_create_sendable_array(napi_env env, napi_value* result);
657```
658
659#### napi_create_sendable_array_with_length
660
661```c
662napi_status napi_create_sendable_array_with_length(napi_env env, size_t length, napi_value* result);
663```
664
665#### napi_create_sendable_arraybuffer
666
667```c
668napi_status napi_create_sendable_arraybuffer(napi_env env, size_t byte_length, void** data, napi_value* result);
669```
670
671#### napi_create_sendable_typedarray
672
673```c
674napi_status napi_create_sendable_typedarray(napi_env env,
675                                            napi_typedarray_type type,
676                                            size_t length,
677                                            napi_value arraybuffer,
678                                            size_t byte_offset,
679                                            napi_value* result);
680```
681
682#### napi_wrap_sendable
683
684```c
685napi_status napi_wrap_sendable(napi_env env,
686                               napi_value js_object,
687                               void* native_object,
688                               napi_finalize finalize_cb,
689                               void* finalize_hint);
690```
691
692#### napi_wrap_sendable_with_size
693
694```c
695napi_status napi_wrap_sendable_with_size(napi_env env,
696                                         napi_value js_object,
697                                         void* native_object,
698                                         napi_finalize finalize_cb,
699                                         void* finalize_hint,
700                                         size_t native_binding_size);
701```
702
703#### napi_unwrap_sendable
704
705```c
706napi_status napi_unwrap_sendable(napi_env env, napi_value js_object, void** result);
707```
708
709#### napi_remove_wrap_sendable
710
711```c
712napi_status napi_remove_wrap_sendable(napi_env env, napi_value js_object, void** result);
713```
714
715### Environment Lifecycle
716
717| API| Description|
718| -------- | -------- |
719| napi_set_instance_data | Associates data with the currently running environment.|
720| napi_get_instance_data | Retrieves the data that was previously associated with the currently running environment.|
721
722### Object Lifetime Management
723
724| API| Description|
725| -------- | -------- |
726| napi_add_env_cleanup_hook | Adds a cleanup hook function for releasing resources when the environment exits.|
727| napi_remove_env_cleanup_hook | Removes a cleanup hook function.|
728| napi_add_async_cleanup_hook | Adds an async cleanup hook function for releasing resources when the environment exits.|
729| napi_remove_async_cleanup_hook | Removes an async cleanup hook function.|
730
731### ArkTS Runtime Environment
732
733| API| Description|
734| -------- | -------- |
735| napi_create_ark_runtime | Creates an ArkTS runtime environment.|
736| napi_destroy_ark_runtime | Destroys an ArkTS runtime environment.|
737
738### Other Utilities
739
740| API| Description|
741| -------- | -------- |
742| napi_get_version | Obtains the latest Node-API version supported by the node runtime.|
743| node_api_get_module_file_name | Obtains the absolute path of the module to be loaded.|
744| napi_strict_equals | Compares whether two values are strictly equal, that is, whether they are of the same type and have the same value.|
745