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_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_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
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
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_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
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
napi_coerce_to_object
napi_coerce_to_string
napi_create_ark_runtimeapi-12
Create the ark runtime.
napi_create_array
napi_create_array_with_length
napi_create_arraybuffer
napi_create_async_work
napi_create_bigint_int64
Creates a ArkTS BigInt from C int64 data.
napi_create_bigint_uint64
Creates a 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
napi_create_date
Creates an ArkTS ‘Date’ object from C double data
napi_create_double
napi_create_error
Creates a ArkTS Error with text information.
napi_create_external
napi_create_external_arraybuffer
napi_create_external_buffer
Creates an ArkTS ArrayBuffer object of the specified size and initializes it with the given data.
napi_create_function
napi_create_int32
napi_create_int64
napi_create_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 a 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
napi_create_string_utf8
napi_create_string_utf16
napi_create_symbol
napi_create_threadsafe_function
Creates a thread-safe function.
napi_create_type_error
Creates a ArkTS TypeError with text information.
napi_create_typedarray
napi_create_uint32
napi_define_class
Defines an ArkTS class, including constructor function and properties.
napi_define_properties
napi_define_sendable_classapi-12
Defines a sendable class.
napi_delete_async_work
napi_delete_element
napi_delete_property
napi_delete_reference
Deletes the reference passed in.
napi_delete_serialization_dataapi-12
Delete serialization data.
napi_deserializeapi-12
Restore serialization data to a ArkTS object.
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
napi_get_arraybuffer_info
napi_get_boolean
napi_get_buffer_info
Obtains the underlying data of ‘ArrayBuffer’ and its length.
napi_get_cb_info
napi_get_dataview_info
napi_get_date_value
Obtains the C equivalent of the given ArkTS ‘Date’ object.
napi_get_element
napi_get_global
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
napi_get_new_target
napi_get_node_version
napi_get_null
napi_get_property
napi_get_property_names
napi_get_prototype
napi_get_reference_value
Obtains the ArkTS Object associated with the reference.
napi_get_threadsafe_function_context
Obtains the context of a thread-safe function.
napi_get_typedarray_info
napi_get_undefined
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
napi_get_value_double
napi_get_value_external
napi_get_value_int32
napi_get_value_int64
napi_get_value_string_latin1
napi_get_value_string_utf8
napi_get_value_string_utf16
napi_get_value_uint32
napi_get_version
napi_has_element
napi_has_named_property
napi_has_own_property
Check if the given ArkTS Object has the named own property or not.
napi_has_property
napi_instanceof
napi_is_array
napi_is_arraybuffer
napi_is_buffer
Checks whether the given ArkTS value is a ‘ArrayBuffer’ object.
napi_is_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
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 a 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
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_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
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
napi_remove_wrap_sendableapi-12
Retrieves a native instance that was previously wrapped in a 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 a ArkTS object.
napi_set_element
napi_set_instance_dataapi-11
Associates data with the currently running environment.
napi_set_named_property
napi_set_property
napi_stop_event_loopapi-12
Stop the event loop in current thread.
napi_strict_equals
napi_throw
Throws a ArkTS error.
napi_throw_error
Throws a ArkTS Error with text information.
napi_throw_range_error
Throws a ArkTS RangeError with text information.
napi_throw_type_error
Throws a ArkTS TypeError with text information.
napi_type_tag_object
napi_typeof
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
napi_unwrap_sendableapi-12
Retrieves a native instance that was previously wrapped in a ArkTS object.
napi_wrap
napi_wrap_enhanceapi-18
Wraps a native instance in a ArkTS object.
napi_wrap_sendableapi-12
Wraps a native instance in a ArkTS object.
napi_wrap_sendable_with_sizeapi-12
Wraps a native instance in a 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_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_threadsafe_function
napi_threadsafe_function_call_js
napi_value