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 FOUNDATION_ACE_ADAPTER_PREVIEW_ACE_RUN_OPTIONS_H 17 #define FOUNDATION_ACE_ADAPTER_PREVIEW_ACE_RUN_OPTIONS_H 18 19 #include <functional> 20 #include <string> 21 #include <map> 22 23 #include "base/utils/device_config.h" 24 #include "base/utils/device_type.h" 25 #include "base/utils/macros.h" 26 27 namespace OHOS::Ace::Platform { 28 29 using SendRenderDataCallback = bool (*)(const void*, const size_t, const int32_t, const int32_t, const uint64_t); 30 using SendCurrentRouterCallback = bool (*)(const std::string currentRouterPath); 31 using FastPreviewErrorCallback = void (*)(const std::string& jsonStr); 32 33 constexpr uint32_t THEME_ID_LIGHT = 117440515; 34 constexpr uint32_t THEME_ID_DARK = 117440516; 35 36 enum class AceVersion { 37 ACE_1_0, 38 ACE_2_0, 39 }; 40 41 enum class ProjectModel { 42 FA, 43 STAGE, 44 }; 45 46 struct ACE_FORCE_EXPORT AceRunArgs { 47 // the adopted project model 48 ProjectModel projectModel = ProjectModel::FA; 49 // stores routing information 50 std::string pageProfile = ""; 51 // The absolute path end of "default". 52 std::string assetPath; 53 // The absolute path of system resources. 54 std::string systemResourcesPath; 55 // The absolute path of app resources. 56 std::string appResourcesPath; 57 58 // Indicate light or dark theme. 59 uint32_t themeId = THEME_ID_LIGHT; 60 61 OHOS::Ace::DeviceConfig deviceConfig = { 62 .orientation = DeviceOrientation::PORTRAIT, 63 .density = 1.0, 64 .deviceType = DeviceType::PHONE, 65 .colorMode = ColorMode::LIGHT, 66 }; 67 68 // Set page path to launch directly, or launch the main page in default. 69 std::string url; 70 71 std::string windowTitle; 72 73 bool isRound = false; 74 int32_t viewWidth = 0; 75 int32_t viewHeight = 0; 76 int32_t deviceWidth = 0; 77 int32_t deviceHeight = 0; 78 79 // Locale 80 std::string language = "zh"; 81 std::string region = "CN"; 82 std::string script = ""; 83 84 std::string configChanges; 85 86 AceVersion aceVersion = AceVersion::ACE_1_0; 87 88 bool formsEnabled = false; 89 90 SendRenderDataCallback onRender = nullptr; 91 SendCurrentRouterCallback onRouterChange = nullptr; 92 FastPreviewErrorCallback onError = nullptr; 93 94 // Container sdk path. 95 std::string containerSdkPath = ""; 96 bool isComponentMode = false; 97 98 // for strict mode 99 std::map<std::string, std::string> pkgContextInfoJsonStringMap; 100 std::map<std::string, std::string> packageNameList; 101 }; 102 103 } // namespace OHOS::Ace::Platform 104 105 #endif // FOUNDATION_ACE_ADAPTER_PREVIEW_ACE_RUN_OPTIONS_H 106