Skip to content

Commit babd400

Browse files
committed
add harmony support
1 parent cb28df7 commit babd400

23 files changed

+1133
-7
lines changed
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/node_modules
2+
/oh_modules
3+
/.preview
4+
/build
5+
/.cxx
6+
/.test
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"apiType": "stageMode",
3+
"targets": [
4+
{
5+
"name": "default"
6+
}
7+
]
8+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
2+
export { harTasks } from '@ohos/hvigor-ohos-plugin';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./ts"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Define project specific obfuscation rules here.
2+
# You can include the obfuscation configuration files in the current module's build-profile.json5.
3+
#
4+
# For more details, see
5+
# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
6+
7+
# Obfuscation options:
8+
# -disable-obfuscation: disable all obfuscations
9+
# -enable-property-obfuscation: obfuscate the property names
10+
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
11+
# -compact: remove unnecessary blank spaces and all line feeds
12+
# -remove-log: remove all console.* statements
13+
# -print-namecache: print the name cache that contains the mapping from the old names to new names
14+
# -apply-namecache: reuse the given cache file
15+
16+
# Keep options:
17+
# -keep-property-name: specifies property names that you want to keep
18+
# -keep-global-name: specifies names that you want to keep in the global scope
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"license": "",
3+
"devDependencies": {
4+
"rnoh": "file:../rnoh"
5+
},
6+
"author": "",
7+
"name": "rnoh-async-storage",
8+
"description": "",
9+
"main": "",
10+
"version": "2.5.1",
11+
"dependencies": {}
12+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* MIT License
3+
*
4+
* Copyright (C) 2023 Huawei Device Co., Ltd.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
#include "RNOH/Package.h"
26+
#include "RNAsyncStorageTurboModule.h"
27+
28+
using namespace rnoh;
29+
using namespace facebook;
30+
class NativeRNAsyncStorageFactoryDelegate : public TurboModuleFactoryDelegate {
31+
public:
32+
SharedTurboModule createTurboModule(Context ctx,const std::string &name) const override {
33+
if (name == "RNCAsyncStorage") {
34+
return std::make_shared<RNAsyncStorageTurboModule>(ctx, name);
35+
}
36+
return nullptr;
37+
};
38+
};
39+
40+
namespace rnoh {
41+
class AsyncStoragePackage : public Package {
42+
public:
43+
AsyncStoragePackage(Package::Context ctx) : Package(ctx) {}
44+
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
45+
return std::make_unique<NativeRNAsyncStorageFactoryDelegate>();
46+
}
47+
};
48+
} // namespace rnoh
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# the minimum version of CMake.
2+
cmake_minimum_required(VERSION 3.13)
3+
set(CMAKE_VERBOSE_MAKEFILE on)
4+
5+
file(GLOB rnoh_async_storage_SRC CONFIGURE_DEPENDS *.cpp)
6+
add_library(rnoh_async_storage SHARED ${rnoh_async_storage_SRC})
7+
target_include_directories(rnoh_async_storage PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
8+
target_link_libraries(rnoh_async_storage PUBLIC rnoh)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* MIT License
3+
*
4+
* Copyright (C) 2023 Huawei Device Co., Ltd.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
#include "RNAsyncStorageTurboModule.h"
26+
#include "RNOH/ArkTSTurboModule.h"
27+
28+
using namespace rnoh;
29+
using namespace facebook;
30+
31+
static jsi::Value __hostFunction_RNAsyncStorageTurboModule_multiGet(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
32+
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "multiGet", args, count);
33+
}
34+
35+
static jsi::Value __hostFunction_RNAsyncStorageTurboModule_multiSet(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
36+
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "multiSet", args, count);
37+
}
38+
39+
static jsi::Value __hostFunction_RNAsyncStorageTurboModule_multiRemove(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
40+
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "multiRemove", args, count);
41+
}
42+
43+
static jsi::Value __hostFunction_RNAsyncStorageTurboModule_multiMerge(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
44+
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "multiMerge", args, count);
45+
}
46+
47+
static jsi::Value __hostFunction_RNAsyncStorageTurboModule_getAllKeys(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
48+
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "getAllKeys", args, count);
49+
}
50+
51+
static jsi::Value __hostFunction_RNAsyncStorageTurboModule_clear(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
52+
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "clear", args, count);
53+
}
54+
55+
RNAsyncStorageTurboModule::RNAsyncStorageTurboModule(const ArkTSTurboModule::Context ctx, const std::string name)
56+
: ArkTSTurboModule(ctx, name) {
57+
methodMap_["multiGet"] = MethodMetadata{2, __hostFunction_RNAsyncStorageTurboModule_multiGet};
58+
methodMap_["multiSet"] = MethodMetadata{2, __hostFunction_RNAsyncStorageTurboModule_multiSet};
59+
methodMap_["multiRemove"] = MethodMetadata{2, __hostFunction_RNAsyncStorageTurboModule_multiRemove};
60+
methodMap_["multiMerge"] = MethodMetadata{2, __hostFunction_RNAsyncStorageTurboModule_multiMerge};
61+
methodMap_["getAllKeys"] = MethodMetadata{2, __hostFunction_RNAsyncStorageTurboModule_getAllKeys};
62+
methodMap_["clear"] = MethodMetadata{1, __hostFunction_RNAsyncStorageTurboModule_clear};
63+
}

0 commit comments

Comments
 (0)