Module napi

Module napi 

Source
Available on crate feature napi only.

Structs§

napi_async_cleanup_hook_handle__
napi_async_context__
napi_async_work__
napi_callback_info__
napi_callback_scope__
napi_critical_scope__
napi_deferred__
napi_escapable_handle_scope__
napi_event_modeapi-12
Indicates the running mode of the native event loop in an asynchronous native thread.
napi_extended_error_info
napi_handle_scope__
napi_key_collection_mode
napi_key_conversion
napi_key_filter
napi_module
napi_node_version
napi_property_attributes
napi_property_descriptor
napi_qos_t
napi_ref__
napi_status
napi_strong_ref__
napi_task_priorityapi-12
Indicates the priority of a task dispatched from native thread to ArkTS thread.
napi_threadsafe_function__
napi_threadsafe_function_call_mode
napi_threadsafe_function_release_mode
napi_type_tag
napi_typedarray_type
napi_valuetype
uv_loop_s

Constants§

NAPI_AUTO_LENGTH
NAPI_MODULE_VERSION
NAPI_VERSION
NAPI_VERSION_EXPERIMENTAL

Functions§

napi_acquire_threadsafe_function
Acquires a thread-safe function.
napi_add_async_cleanup_hookapi-11
Registers an asynchronous clean-up hook for releasing resources when the environment exits.
napi_add_env_cleanup_hookapi-11
Registers a clean-up hook for releasing resources when the environment exits.
napi_add_finalizerapi-11
Adds a ‘napi_finalize’ callback, which will be called when the ArkTS object is garbage-collected.
napi_adjust_external_memory
napi_async_destroyapi-11
Destroys the previously created asynchronous context. The capabilities related to ‘async_hook’ are not supported currently.
napi_async_initapi-11
Creates an asynchronous context. The capabilities related to ‘async_hook’ are not supported currently.
napi_call_function
Invoke an ArkTS function. This is the primary mechanism to call back into JavaScript.
napi_call_threadsafe_function
Calls a thread-safe function.
napi_call_threadsafe_function_with_priorityapi-12
Dispatch a task with specified priority from a native thread to an ArkTS thread, the task will execute the given thread safe function.
napi_cancel_async_work
Cancels queued work if it has not yet been started. If it has already started executing, it cannot be cancelled. If successful, the complete callback will be invoked with a status value of napi_cancelled. The work should not be deleted before the complete callback invocation, even if it has been successfully cancelled.
napi_check_object_type_tag
napi_close_callback_scopeapi-11
Closes the callback scope. The capabilities related to ‘async_hook’ are not supported currently.
napi_close_critical_scopeapi-21
To close a critical scope.
napi_close_escapable_handle_scope
Closes the escapable handle scope passed in.
napi_close_handle_scope
Closes the scope passed in. After the scope is closed, all references declared in it are closed.
napi_coerce_to_bool
Coerce the given ArkTS value to an ArkTS boolean value.
napi_coerce_to_native_binding_objectapi-11
This API sets native properties to a object and converts this ArkTS object to native binding object.
napi_coerce_to_number
Coerce the given ArkTS value to an ArkTS number value.
napi_coerce_to_object
Coerce the given ArkTS value to an ArkTS object value.
napi_coerce_to_string
Coerce the given ArkTS value to an ArkTS string value.
napi_create_ark_contextapi-20
To create a new virtual machine context.
napi_create_ark_runtimeapi-12
Create the ark runtime.
napi_create_array
Creates an ArkTS array.
napi_create_array_with_length
Creates an ArkTS array of the specified length.
napi_create_arraybuffer
Creates an ArkTS ArrayBuffer of the specified size.
napi_create_async_work
Allocate a work object that is used to execute logic asynchronously.
napi_create_bigint_int64
Creates an ArkTS BigInt from C int64 data.
napi_create_bigint_uint64
Creates an ArkTS BigInt from C int64 data.
napi_create_bigint_words
Creates a single ArkTS BigInt from a C uint64 array.
napi_create_buffer
Creates an ArkTS ArrayBuffer object of the specified size.
napi_create_buffer_copy
Creates an ArkTS ArrayBuffer object of the specified size and initializes it with the given data.
napi_create_dataview
Creates an ArkTS DataView from an existing ArrayBuffer.
napi_create_date
Creates an ArkTS ‘Date’ object from C double data
napi_create_double
Creates an ArkTS number from C double data.
napi_create_error
Creates an ArkTS Error with text information.
napi_create_external
Allocates a JS value with external data.
napi_create_external_arraybuffer
The underlying data that ArrayBuffer point to.
napi_create_external_buffer
Creates an ArkTS ArrayBuffer object of the specified size and initializes it with the given data.
napi_create_function
Create an ArkTS function. This is the primary mechanism to call back into native code from ArkTS.
napi_create_int32
Creates an ArkTS number from C int32_t data.
napi_create_int64
Creates an ArkTS number from C int64_t data.
napi_create_object
Creates a default ArkTS object.
napi_create_object_with_named_propertiesapi-11
Create ArkTS Object with initial properties given by keys and values, note that property key must be String, and must can not convert to element_index, also all keys must not duplicate.
napi_create_object_with_propertiesapi-11
Create ArkTS Object with initial properties given by descriptors, note that property key must be String, and must can not convert to element_index, also all keys must not duplicate.
napi_create_promise
Creates a deferred object and an ArkTS promise.
napi_create_range_error
Creates an ArkTS RangeError with text information.
napi_create_reference
Creates a reference for an object to extend its lifespan. The caller needs to manage the reference lifespan.
napi_create_sendable_arrayapi-12
Create a sendable array.
napi_create_sendable_array_with_lengthapi-12
Create a sendable array with length.
napi_create_sendable_arraybufferapi-12
Create a sendable arraybuffer.
napi_create_sendable_object_with_propertiesapi-12
Defines a sendable object.
napi_create_sendable_typedarrayapi-12
Create a sendable typedarray.
napi_create_string_latin1
Creates an ArkTS string from an ISO-8859-1-encoded C string.
napi_create_string_utf8
Creates an ArkTS string from a UTF8-encoded C string.
napi_create_string_utf16
napi_create_strong_referenceapi-21
Creates a strong reference for an ArkTS object to extend its lifespan. The caller needs to manage the reference lifespan.
napi_create_symbol
Creates an ArkTS symbol.
napi_create_threadsafe_function
Creates a thread-safe function.
napi_create_type_error
Creates an ArkTS TypeError with text information.
napi_create_typedarray
Creates an ArkTS TypeArray from an existing ArrayBuffer.
napi_create_uint32
Creates an ArkTS number from C uint32_t data.
napi_define_class
Defines an ArkTS class, including constructor function and properties.
napi_define_properties
Efficient define multiple properties on the given ArkTS Object by napi_property_descriptor.
napi_define_sendable_classapi-12
Defines a sendable class.
napi_delete_async_work
Free a previously allocated work object.
napi_delete_element
Delete the special index from the given ArkTS Array.
napi_delete_property
Delete the named property of the given ArkTS Object.
napi_delete_reference
Deletes the reference passed in.
napi_delete_serialization_dataapi-12
Delete serialization data.
napi_delete_strong_referenceapi-21
Deletes the strong reference passed in.
napi_deserializeapi-12
Restore serialization data to an ArkTS object.
napi_destroy_ark_contextapi-20
To destroy a virtual machine context which will not be used again.
napi_destroy_ark_runtimeapi-12
Destroy the ark runtime.
napi_detach_arraybuffer
Detaches the underlying data from an ‘ArrayBuffer’ object. After the data is detached, you can operate the data in C/C++.
napi_escape_handle
Promotes the handle to the input ArkTS object so that it is valid for the lifespan of its outer scope.
napi_fatal_error
Raises a fatal error to terminate the process immediately.
napi_fatal_exceptionapi-12
Throws UncaughtException to ArkTS.
napi_get_all_property_names
Obtains the names of all properties of an ArkTS object.
napi_get_and_clear_last_exception
Obtains and clears the latest exception.
napi_get_array_length
Obtains the array length.
napi_get_arraybuffer_info
Obtains the underlying data buffer of ArrayBuffer and its length.
napi_get_boolean
Obtains the ArkTS singleton value corresponding to given C primitive boolean value.
napi_get_buffer_info
Obtains the underlying data of ‘ArrayBuffer’ and its length.
napi_get_buffer_string_utf16_in_critical_scopeapi-21
To obtain a ArkTS string buffer cache within the critical scope.
napi_get_cb_info
Obtains callback details about the call like arguments, this from given callback info.
napi_get_dataview_info
Obtains properties of a DataView.
napi_get_date_value
Obtains the C equivalent of the given ArkTS ‘Date’ object.
napi_get_element
Get the requests element of the given ArkTS Array.
napi_get_global
Obtains the ArkTS global object.
napi_get_instance_dataapi-11
Retrieves the data that was previously associated with the currently running environment.
napi_get_last_error_info
Obtains the napi_extended_error_info struct, which contains the latest error information.
napi_get_named_property
Get the requests property of the given ArkTS Object.
napi_get_new_target
Obtains callback details about the call like arguments, this from given callback info.
napi_get_node_version
napi_get_null
Obtains the ArkTS null value.
napi_get_property
Get the requests property of the given ArkTS Object.
napi_get_property_names
Obtains the names of the enumerable properties of object as an Array of Strings. The keys that are symbols will not be included.
napi_get_prototype
Obtains the prototype of an ArkTS object.
napi_get_reference_value
Obtains the ArkTS Object associated with the reference.
napi_get_strong_reference_valueapi-21
Obtains the ArkTS Object associated with the strong reference.
napi_get_threadsafe_function_context
Obtains the context of a thread-safe function.
napi_get_typedarray_info
Obtains properties of a TypedArray.
napi_get_undefined
Obtains the ArkTS undefined value.
napi_get_uv_event_loop
Obtains the current libuv loop instance.
napi_get_value_bigint_int64
Obtains a signed 64-bit integer from an ArkTS BigInt object.
napi_get_value_bigint_uint64
Obtains an unsigned 64-bit integer from an ArkTS BigInt object.
napi_get_value_bigint_words
Obtains the underlying 64-bit unsigned (uint64) byte data from an ArkTS BigInt object.
napi_get_value_bool
Obtains the C Boolean equivalent of an ArkTS Boolean value.
napi_get_value_double
Obtains the double value corresponding to the given ArkTS value.
napi_get_value_external
Obtains the external data pointer previously passed through napi_create_external().
napi_get_value_int32
Obtains the int32_t value corresponding to the given ArkTS value.
napi_get_value_int64
Obtains the int64_t value corresponding to the given ArkTS value.
napi_get_value_string_latin1
Obtains the ISO-8859-1-encoded string corresponding to the given ArkTS value.
napi_get_value_string_utf8
Obtains the UTF8-encoded string corresponding to the given ArkTS value.
napi_get_value_string_utf16
napi_get_value_uint32
Obtains the uint32_t value corresponding to the given ArkTS value.
napi_get_version
napi_has_element
Check if the given ArkTS Array has an element at the requested index.
napi_has_named_property
Check if the given ArkTS Object has the named property or not.
napi_has_own_property
Check if the given ArkTS Object has the named own property or not.
napi_has_property
Check if the given ArkTS Object has the named property or not.
napi_instanceof
Invoke instanceof operation on the object.
napi_is_array
Checks if the ArkTS value is an ArkTS Array.
napi_is_arraybuffer
Checks if the ArkTS value is an ArkTS ArrayBuffer.
napi_is_buffer
Checks whether the given ArkTS value is a ‘ArrayBuffer’ object.
napi_is_dataview
Checks if the ArkTS value is an ArkTS DataView.
napi_is_date
Checks whether the given ArkTS value is a ‘Date’ object. You can use this API to check the type of the parameter passed from ArkTS.
napi_is_detached_arraybuffer
Checks whether the given ‘ArrayBuffer’ has been detached.
napi_is_error
Checks whether a ‘napi_value’ is an error object.
napi_is_exception_pending
Checks whether an exception occurs.
napi_is_promise
Checks whether the given ‘napi_value’ is a promise object.
napi_is_sendableapi-12
Queries a napi_value to check if it is sendable.
napi_is_typedarray
Checks if the ArkTS value is an ArkTS TypedArray.
napi_load_moduleapi-11
Loads an .abc file as a module. This API returns the namespace of the module.
napi_load_module_with_infoapi-12
The module is loaded through the NAPI. By default, the default object is exported from the module.
napi_make_callbackapi-11
Allows an ArkTS function to be called in the asynchronous context. The capabilities related to ‘async_hook’ are not supported currently.
napi_module_register
Registers a native module.
napi_new_instance
Instantiate a new ArkTS value using a given napi_value that represents the constructor for the object.
napi_object_freeze
Freezes an ArkTS object. Once an object is frozen, its properties are immutable.
napi_object_seal
Seals an ArkTS object. Once an object is sealed, its properties cannot be added or deleted, but property values can be modified.
napi_open_callback_scopeapi-11
Opens a callback scope. The capabilities related to ‘async_hook’ are not supported currently.
napi_open_critical_scopeapi-21
To open a critical scope.
napi_open_escapable_handle_scope
Opens an escapable handle scope from which the declared values can be returned to the outer scope.
napi_open_handle_scope
Opens a scope.
napi_queue_async_work
Requests that the previously allocated work be scheduled for execution. Once it returns successfully, this API must not be called again with the same napi_async_work item or the result will be undefined.
napi_queue_async_work_with_qos
napi_ref_threadsafe_function
Indicates that the event loop running on the main thread should not exit until the thread-safe function is destroyed.
napi_reference_ref
Increments the reference count for the reference passed in and returns the count.
napi_reference_unref
Decrements the reference count for the reference passed in and returns the count.
napi_reject_deferred
Rejects a promise by way of the deferred object associated.
napi_release_threadsafe_function
Releases a thread-safe function.
napi_remove_async_cleanup_hookapi-11
Unregisters the asynchronous clean-up hook.
napi_remove_env_cleanup_hookapi-11
Unregisters the clean-up hook.
napi_remove_wrap
Retrieves a native instance that was previously wrapped in the ArkTS object js_object using napi_wrap and removes the wrapping.
napi_remove_wrap_sendableapi-12
Retrieves a native instance that was previously wrapped in an ArkTS object and removes the wrapping.
napi_resolve_deferred
Resolves a promise by way of the deferred object associated.
napi_run_event_loopapi-12
Run the event loop by the given env and running mode in current thread.
napi_run_script
napi_run_script_path
napi_serializeapi-12
Serialize an ArkTS object.
napi_set_element
Set a element on the given ArkTS Array.
napi_set_instance_dataapi-11
Associates data with the currently running environment.
napi_set_named_property
Set a property on the given ArkTS Object.
napi_set_property
Set a property on the given ArkTS Object.
napi_stop_event_loopapi-12
Stop the event loop in current thread.
napi_strict_equals
Checks if the two ArkTS values are equal.
napi_switch_ark_contextapi-20
To switch a virtual machine context which is expected to be used later.
napi_throw
Throws an ArkTS error.
napi_throw_error
Throws an ArkTS Error with text information.
napi_throw_range_error
Throws an ArkTS RangeError with text information.
napi_throw_type_error
Throws an ArkTS TypeError with text information.
napi_type_tag_object
napi_typeof
Similar to typeof operation, support external value, detects null as a separate type.
napi_unref_threadsafe_function
Indicates that the event loop running on the main thread may exit before the thread-safe function is destroyed.
napi_unwrap
Retrieves a native instance that was previously wrapped in an ArkTS object using napi_wrap.
napi_unwrap_sendableapi-12
Retrieves a native instance that was previously wrapped in an ArkTS object.
napi_wrap
Wraps a native instance in a ArkTS object. The native instance can be retrieved later using napi_unwrap.
napi_wrap_enhanceapi-18
Wraps a native instance in an ArkTS object.
napi_wrap_sendableapi-12
Wraps a native instance in an ArkTS object.
napi_wrap_sendable_with_sizeapi-12
Wraps a native instance in an ArkTS object.
node_api_get_module_file_nameapi-11
Obtains the absolute path of the location, from which the addon is loaded.

Type Aliases§

char16_t
napi_addon_register_func
napi_async_cleanup_hook
napi_async_cleanup_hook_handle
napi_async_complete_callback
napi_async_context
napi_async_execute_callback
napi_async_work
napi_callback
napi_callback_info
napi_callback_scope
napi_critical_scopeapi-21
Native critical scope provides a scope within that an ArkTS string buffer cache can be obtained.
napi_deferred
napi_env
napi_escapable_handle_scope
napi_finalize
napi_handle_scope
napi_native_binding_attach_callbackapi-11
Native attach callback of napi_coerce_to_native_binding_object that can be used to bind the ArkTS object and the native object.
napi_native_binding_detach_callbackapi-11
Native detach callback of napi_coerce_to_native_binding_object that can be used to detach the ArkTS object and the native object.
napi_ref
napi_strong_refapi-21
Native strong reference of an ArkTS object.
napi_threadsafe_function
napi_threadsafe_function_call_js
napi_value