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