diff --git a/frameworks/jskitsimpl/distributeddata/src/entry_point.cpp b/frameworks/jskitsimpl/distributeddata/src/entry_point.cpp index 04651a56a88a5b8c2db1321f1d92e93b92f24b63..ce56ad52e7159b9310b8716829fd82bf7b87b90c 100644 --- a/frameworks/jskitsimpl/distributeddata/src/entry_point.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/entry_point.cpp @@ -20,6 +20,10 @@ #include "log_print.h" using namespace OHOS::DistributedData; using namespace OHOS::DistributedKv; + +extern const char _binary_distributed_data_js_start[]; +extern const char _binary_distributed_data_js_end[]; + static napi_value Init(napi_env env, napi_value exports) { napi_property_descriptor desc = DECLARE_NAPI_METHOD("createKVManager", KVManager::CreateKVManager); @@ -28,6 +32,19 @@ static napi_value Init(napi_env env, napi_value exports) return exports; } +// function name: NAPI_{ModuleName}_GetJSCode +extern "C" __attribute__((visibility("default"))) void NAPI_data_distributedData_GetJSCode(const char** buf, + int* bufLen) +{ + if (buf != nullptr) { + *buf = _binary_distributed_data_js_start; + } + + if (bufLen != nullptr) { + *bufLen = _binary_distributed_data_js_end - _binary_distributed_data_js_start; + } +} + static __attribute__((constructor)) void RegisterModule() { static napi_module module = { diff --git a/interfaces/jskits/distributeddata/BUILD.gn b/interfaces/jskits/distributeddata/BUILD.gn index 24362422d007009328291da51b8db2d2c6e3ff9c..109fcc69fc3bed23331012d336b380c5b1c2eb27 100644 --- a/interfaces/jskits/distributeddata/BUILD.gn +++ b/interfaces/jskits/distributeddata/BUILD.gn @@ -14,6 +14,13 @@ import("//build/ohos.gni") import("//build/ohos/ace/ace.gni") +base_output_path = get_label_info(":distributed_data_js", "target_out_dir") +distributed_data_js_obj_path = base_output_path + "/distributed_data.o" +gen_js_obj("distributed_data_js") { + input = "distributed_data.js" + output = distributed_data_js_obj_path +} + group("build_module") { deps = [ ":distributeddata" ] } @@ -45,6 +52,7 @@ ohos_shared_library("distributeddata") { ] deps = [ + ":distributed_data_js", "//foundation/ace/napi:ace_napi", "//foundation/distributeddatamgr/distributeddatamgr/interfaces/innerkits/distributeddata:distributeddata_inner", "//third_party/libuv:uv_static", diff --git a/interfaces/jskits/distributeddata/distributed_data.js b/interfaces/jskits/distributeddata/distributed_data.js new file mode 100644 index 0000000000000000000000000000000000000000..b7868e0ff8f2b6f27de4c50a073711b69c81977b --- /dev/null +++ b/interfaces/jskits/distributeddata/distributed_data.js @@ -0,0 +1,47 @@ +const distributedDataSo = requireInternal('data.distributedData'); + +export default { + createKVManager: distributedDataSo.createKVManager, + UserType: { + SAME_USER_ID: 0, + }, + Constants: { + MAX_KEY_LENGTH: 1024, + MAX_VALUE_LENGTH: 4194303, + MAX_KEY_LENGTH_DEVICE: 896, + MAX_STORE_ID_LENGTH: 128, + MAX_QUERY_LENGTH: 512000, + MAX_BATCH_SIZE: 128, + }, + ValueType: { + STRING: 0, + INTEGER: 1, + FLOAT: 2, + BYTE_ARRAY: 3, + BOOLEAN: 4, + DOUBLE: 5, + }, + SyncMode: { + PULL_ONLY: 0, + PUSH_ONLY: 1, + PUSH_PULL: 2, + }, + SubscribeType: { + SUBSCRIBE_TYPE_LOCAL: 0, + SUBSCRIBE_TYPE_REMOTE: 1, + SUBSCRIBE_TYPE_ALL: 2, + }, + KVStoreType: { + DEVICE_COLLABORATION: 0, + SINGLE_VERSION: 1, + MULTI_VERSION: 2, + }, + SecurityLevel: { + NO_LEVEL: 0, + S0: 1, + S1: 2, + S2: 3, + S3: 5, + S4: 6, + }, +} \ No newline at end of file