1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_NAPI_ACE_PLUGIN_DATA_H 17 #define OHOS_NAPI_ACE_PLUGIN_DATA_H 18 19 #include <map> 20 #include <string> 21 #include <vector> 22 23 #include "ability.h" 24 #include "napi/native_api.h" 25 #include "napi/native_common.h" 26 #include "napi/native_node_api.h" 27 #include "pac_map.h" 28 #include "want.h" 29 30 namespace OHOS::Ace::Napi { 31 struct ACECallbackInfo { 32 napi_env env = nullptr; 33 napi_ref callback = nullptr; 34 }; 35 36 enum class TACENativeValueType { 37 NVT_NONE = 0, 38 NVT_UNDEFINED, 39 NVT_INT32, 40 NVT_BOOL, 41 NVT_STRING, 42 NVT_DOUBLE, 43 }; 44 45 struct ACEThreadReturnData { 46 TACENativeValueType data_type = TACENativeValueType::NVT_NONE; 47 int32_t int32_value = 0; 48 bool bool_value = false; 49 std::string str_value = {}; 50 double double_value = 0.0; 51 AppExecFwk::PacMap paramList = {}; 52 }; 53 54 struct AceFromJSParam { 55 AAFwk::Want want = {}; 56 AppExecFwk::PacMap paramList = {}; 57 }; 58 59 struct ACERequestCallbackData { 60 std::string sourceName; 61 std::string abilityName; 62 std::string data; 63 std::string extraData; 64 std::string name; 65 }; 66 67 struct ACEAsyncJSCallbackInfo { 68 ACECallbackInfo cbInfo = {}; 69 Ability* ability = nullptr; 70 napi_async_work asyncWork = nullptr; 71 napi_deferred deferred = nullptr; 72 ACEThreadReturnData native_data = {}; 73 AceFromJSParam jsParamList = {}; 74 napi_value result = nullptr; 75 int error_code = 0; 76 AAFwk::Want wantStage = {}; 77 napi_value onRequestData = nullptr; 78 bool onRequestCallbackOK = false; 79 ACERequestCallbackData requestCallbackData; 80 }; 81 82 struct ACEAsyncParamEx { 83 std::string resource = {}; 84 size_t argc = 0; 85 napi_async_execute_callback execute = nullptr; 86 napi_async_complete_callback complete = nullptr; 87 }; 88 89 struct ACEComplexArrayData { 90 std::vector<int> intList = {}; 91 std::vector<int64_t> longList = {}; 92 std::vector<bool> boolList = {}; 93 std::vector<double> doubleList = {}; 94 std::vector<std::string> stringList = {}; 95 }; 96 } // namespace OHOS::Ace::Napi 97 #endif // OHOS_NAPI_ACE_PLUGIN_DATA_H 98