一、扩展能力
接口 |
功能说明 |
napi_queue_async_work_with_qos |
将异步工作对象加到队列,由底层根据传入的qos优先级去调度执行。 |
napi_run_script_path |
运行指定abc文件。 |
napi_load_module |
将abc文件作为模块加载,返回模块的命名空间。 |
napi_load_module_with_info |
将abc文件作为模块加载,返回模块的命名空间, 可在新创建的ArkTs基础运行时环境中使用。 |
napi_create_object_with_properties |
使用给定的napi_property_descriptor创建js Object。descriptor的键名必须为 string,且不可转为number。 |
napi_create_object_with_named_properties |
使用给定的napi_value和键名创建js Object。键名必须为 string,且不可转为number。 |
napi_coerce_to_native_binding_object |
强制将js Object和Native对象绑定。 |
napi_run_event_loop |
触发底层的事件循环。 |
napi_stop_event_loop |
停止底层的事件循环。 |
napi_serialize |
将ArkTS对象转换为native数据。 |
napi_deserialize |
将native数据转为ArkTS对象。 |
napi_delete_serialization_data |
删除序列化数据。 |
napi_call_threadsafe_function_with_priority |
将指定优先级和入队方式的任务投递到ArkTS线程。 |
napi_is_sendable |
判断给定JS value是否是Sendable的。 |
napi_define_sendable_class |
创建一个sendable类。 |
napi_create_sendable_object_with_properties |
使用给定的napi_property_descriptor创建一个sendable对象。 |
napi_create_sendable_array |
创建一个sendable数组。 |
napi_create_sendable_array_with_length |
创建一个指定长度的sendable数组。 |
napi_create_sendable_arraybuffer |
创建一个sendable ArrayBuffer。 |
napi_create_sendable_typedarray |
创建一个sendable TypedArray。 |
napi_wrap_sendable |
包裹一个native实例到ArkTS对象中。 |
napi_wrap_sendable_with_size |
包裹一个native实例到ArkTS对象中并指定大小。 |
napi_unwrap_sendable |
获取ArkTS对象包裹的native实例。 |
napi_remove_wrap_sendable |
移除并获取ArkTS对象包裹的native实例。 |
1、napi_queue_async_work_with_qos
napi_status napi_queue_async_work_with_qos(napi_env env,
napi_async_work work,
napi_qos_t qos);
2、napi_run_script_path
napi_status napi_run_script_path(napi_env env,
const char* abcPath,
napi_value* result);
3、napi_load_module
napi_status napi_load_module(napi_env env,
const char* path,
napi_value* result);
4、napi_create_object_with_properties
napi_status napi_create_object_with_properties(napi_env env,
napi_value* result,
size_t property_count,
const napi_property_descriptor* properties);
5、napi_create_object_with_named_properties
napi_status napi_create_object_with_named_properties(napi_env env,
napi_value* result,
size_t property_count,
const char** keys,
const napi_value* values);
6、napi_coerce_to_native_binding_object
napi_status napi_coerce_to_native_binding_object(napi_env env,
napi_value js_object,
napi_native_binding_detach_callback detach_cb,
napi_native_binding_attach_callback attach_cb,
void* native_object,
void* hint);
7、napi_run_event_loop
napi_status napi_run_event_loop(napi_env env, napi_event_mode mode);
8、napi_stop_event_loop
napi_status napi_stop_event_loop(napi_env env);
9、napi_serialize
napi_status napi_serialize(napi_env env,
napi_value object,
napi_value transfer_list,
napi_value clone_list,
void** result);
10、napi_deserialize
napi_status napi_deserialize(napi_env env, void* buffer, napi_value* object);
11、napi_delete_serialization_data
napi_status napi_delete_serialization_data(napi_env env, void* buffer);
12、napi_call_threadsafe_function_with_priority
napi_status napi_call_threadsafe_function_with_priority(napi_threadsafe_function func,
void *data,
napi_task_priority priority,
bool isTail);
13、napi_is_sendable
napi_status napi_is_sendable(napi_env env, napi_value value, bool* result);
14、napi_define_sendable_class
napi_status napi_define_sendable_class(napi_env env,
const char* utf8name,
size_t length,
napi_callback constructor,
void* data,
size_t property_count,
const napi_property_descriptor* properties,
napi_value parent,
napi_value* result);
15、napi_create_sendable_object_with_properties
napi_status napi_create_sendable_object_with_properties(napi_env env,
size_t property_count,
const napi_property_descriptor* properties,
napi_value* result);
16、napi_create_sendable_array
napi_status napi_create_sendable_array(napi_env env, napi_value* result);
17、napi_create_sendable_array_with_length
napi_status napi_create_sendable_array_with_length(napi_env env, size_t length, napi_value* result);
18、napi_create_sendable_arraybuffer
napi_status napi_create_sendable_arraybuffer(napi_env env, size_t byte_length, void** data, napi_value* result);
19、napi_create_sendable_typedarray
napi_status napi_create_sendable_typedarray(napi_env env,
napi_typedarray_type type,
size_t length,
napi_value arraybuffer,
size_t byte_offset,
napi_value* result);
20、napi_wrap_sendable
napi_status napi_wrap_sendable(napi_env env,
napi_value js_object,
void* native_object,
napi_finalize finalize_cb,
void* finalize_hint);
21、napi_wrap_sendable_with_size
napi_status napi_wrap_sendable_with_size(napi_env env,
napi_value js_object,
void* native_object,
napi_finalize finalize_cb,
void* finalize_hint,
size_t native_binding_size);
22、napi_unwrap_sendable
napi_status napi_unwrap_sendable(napi_env env, napi_value js_object, void** result);
23、napi_remove_wrap_sendable
napi_status napi_remove_wrap_sendable(napi_env env, napi_value js_object, void** result);
二、环境生命周期
接口 |
功能说明 |
napi_set_instance_data |
绑定与当前运行的环境相关联的数据项。 |
napi_get_instance_data |
检索与当前运行的环境相关联的数据项。 |
三、对象生命周期管理
接口 |
功能说明 |
napi_add_env_cleanup_hook |
注册环境清理钩子函数。 |
napi_remove_env_cleanup_hook |
取消环境清理钩子函数。 |
napi_add_async_cleanup_hook |
注册清理异步钩子函数。 |
napi_remove_async_cleanup_hook |
取消清理异步钩子函数。 |
四、ArkTs基础运行时环境
接口 |
功能说明 |
napi_create_ark_runtime |
创建基础运行时环境 |
napi_destroy_ark_runtime |
销毁基础运行时环境 |
五、其他实用工具
接口 |
功能说明 |
node_api_get_module_file_name |
用于获取加载项加载位置的绝对路径。 |