Merged
chore: migrate repository from GitHub br_rnoh0.82 to GitCode master branch #19
liangtaoAdd on Sep 24
chore: migrate repository from GitHub br_rnoh0.82 to GitCode master branch #19
Merged
Total: 85 files changed+1897-50
| @@ -0,0 +1,7 @@ | |||
| 1 | +# v6.3.1-beta.1 | ||
| 2 | +* feat: support autolink | ||
| 3 | + | ||
| 4 | +# v6.1.2-rc.1 | ||
| 5 | +## 更新内容 | ||
| 6 | +* 修改组织名为@react-native-ohos | ||
| 7 | +* 内置Codegen生成代码 | ||
| @@ -49,8 +49,6 @@ | |||
| 49 | <filteritem type="filepath" name="index.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/> | 49 | <filteritem type="filepath" name="index.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/> |
| 50 | <filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/> | 50 | <filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/> |
| 51 | <filteritem type="filepath" name="hvigor/hvigor-config.json5" desc="工程模板,不修改版权头,以防有修改版权风险"/> | 51 | <filteritem type="filepath" name="hvigor/hvigor-config.json5" desc="工程模板,不修改版权头,以防有修改版权风险"/> |
| 52 | - <filteritem type="filename" name="buildEnv.sh" desc="配置文件,不添加许可证头"/> | ||
| 53 | - <filteritem type="filename" name="buildEnv.sh" desc="配置文件,不修改版权头,以防有修改版权风险"/> | ||
| 54 | </filefilter> | 52 | </filefilter> |
| 55 | <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies"> | 53 | <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies"> |
| 56 | <filteritem type="filepath" name="harmony/mail/hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改"/> | 54 | <filteritem type="filepath" name="harmony/mail/hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改"/> |
| @@ -83,8 +81,6 @@ | |||
| 83 | <filteritem type="filepath" name="index.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/> | 81 | <filteritem type="filepath" name="index.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/> |
| 84 | <filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/> | 82 | <filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/> |
| 85 | <filteritem type="filepath" name="hvigor/hvigor-config.json5" desc="工程模板,不修改版权头,以防有修改版权风险"/> | 83 | <filteritem type="filepath" name="hvigor/hvigor-config.json5" desc="工程模板,不修改版权头,以防有修改版权风险"/> |
| 86 | - <filteritem type="filename" name="buildEnv.sh" desc="配置文件,不添加许可证头"/> | ||
| 87 | - <filteritem type="filename" name="buildEnv.sh" desc="配置文件,不修改版权头,以防有修改版权风险"/> | ||
| 88 | </filefilter> | 84 | </filefilter> |
| 89 | 85 | ||
| 90 | <filefilter name="binaryFileTypePolicyFilter" desc="Filters for copyright header policies"> | 86 | <filefilter name="binaryFileTypePolicyFilter" desc="Filters for copyright header policies"> |
| @@ -4,9 +4,9 @@ This project is based on [react-native-mail](https://github.com/chirag04/react-n | |||
| 4 | 4 | ||
| 5 | ## Documentation | 5 | ## Documentation |
| 6 | 6 | ||
| 7 | -- [中文](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-mail.md) | 7 | +- [中文](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/zh-cn/react-native-mail.md) |
| 8 | 8 | ||
| 9 | -- [English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/en/react-native-mail.md) | 9 | +- [English](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/en/react-native-mail.md) |
| 10 | 10 | ||
| 11 | ## License | 11 | ## License |
| 12 | 12 | ||
| @@ -1,5 +0,0 @@ | |||
| 1 | -#!/bin/bash | ||
| 2 | -ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) | ||
| 3 | -BUILD_PKG_DIR=src | ||
| 4 | -BUILD_SAMPLE_DIR=src | ||
| 5 | -BUILD_THIRD_PARTY_DIR=$ROOT_DIR/react-native-mail/harmony/mail/ | ||
| @@ -0,0 +1,19 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +{ | ||
| 8 | + "extends": "@react-native", | ||
| 9 | + "rules": { | ||
| 10 | + "react-native/no-inline-styles": "off", | ||
| 11 | + "react/no-unstable-nested-components": "off", | ||
| 12 | + "react/react-in-jsx-scope": "off", | ||
| 13 | + "@typescript-eslint/no-unused-vars": "warn", | ||
| 14 | + "react-hooks/exhaustive-deps": "off", | ||
| 15 | + "radix": "off", | ||
| 16 | + "prettier/prettier": "warn", | ||
| 17 | + "max-lines": "off" | ||
| 18 | + } | ||
| 19 | +} | ||
| @@ -0,0 +1,71 @@ | |||
| 1 | +.husky | ||
| 2 | +bundle.harmony.js | ||
| 3 | +package-lock.json | ||
| 4 | +*.hbc | ||
| 5 | +lintCppResult.txt | ||
| 6 | + | ||
| 7 | +# --- | ||
| 8 | + | ||
| 9 | +# OSX | ||
| 10 | +# | ||
| 11 | +.DS_Store | ||
| 12 | + | ||
| 13 | +# Xcode | ||
| 14 | +# | ||
| 15 | +build/ | ||
| 16 | +*.pbxuser | ||
| 17 | +!default.pbxuser | ||
| 18 | +*.mode1v3 | ||
| 19 | +!default.mode1v3 | ||
| 20 | +*.mode2v3 | ||
| 21 | +!default.mode2v3 | ||
| 22 | +*.perspectivev3 | ||
| 23 | +!default.perspectivev3 | ||
| 24 | +xcuserdata | ||
| 25 | +*.xccheckout | ||
| 26 | +*.moved-aside | ||
| 27 | +DerivedData | ||
| 28 | +*.hmap | ||
| 29 | +*.ipa | ||
| 30 | +*.xcuserstate | ||
| 31 | + | ||
| 32 | +# Android/IntelliJ | ||
| 33 | +# | ||
| 34 | +build/ | ||
| 35 | +.idea | ||
| 36 | +.gradle | ||
| 37 | +local.properties | ||
| 38 | +*.iml | ||
| 39 | +*.hprof | ||
| 40 | +.cxx/ | ||
| 41 | +*.keystore | ||
| 42 | +!debug.keystore | ||
| 43 | +BuildProfile.ets | ||
| 44 | + | ||
| 45 | +# node.js | ||
| 46 | +# | ||
| 47 | +node_modules/ | ||
| 48 | +npm-debug.log | ||
| 49 | +yarn-error.log | ||
| 50 | + | ||
| 51 | +# fastlane | ||
| 52 | +# | ||
| 53 | +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the | ||
| 54 | +# screenshots whenever they are needed. | ||
| 55 | +# For more information about the recommended setup visit: | ||
| 56 | +# https://docs.fastlane.tools/best-practices/source-control/ | ||
| 57 | + | ||
| 58 | +**/fastlane/report.xml | ||
| 59 | +**/fastlane/Preview.html | ||
| 60 | +**/fastlane/screenshots | ||
| 61 | +**/fastlane/test_output | ||
| 62 | + | ||
| 63 | +# Bundle artifact | ||
| 64 | +*.jsbundle | ||
| 65 | + | ||
| 66 | +# Ruby / CocoaPods | ||
| 67 | +/vendor/bundle/ | ||
| 68 | + | ||
| 69 | +# Temporary files created by Metro to check the health of the file watcher | ||
| 70 | +.metro-health-check* | ||
| 71 | +*.htrace | ||
| @@ -0,0 +1,6 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | +18 | ||
| @@ -0,0 +1,7 @@ | |||
| 1 | +module.exports = { | ||
| 2 | + arrowParens: 'avoid', | ||
| 3 | + bracketSameLine: true, | ||
| 4 | + bracketSpacing: true, | ||
| 5 | + singleQuote: true, | ||
| 6 | + trailingComma: 'all', | ||
| 7 | +}; | ||
| @@ -0,0 +1,6 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | +{} | ||
| @@ -0,0 +1,6 @@ | |||
| 1 | +module.exports = { | ||
| 2 | + presets: ['module:@react-native/babel-preset'], | ||
| 3 | + plugins: [ | ||
| 4 | + 'react-native-reanimated/plugin', | ||
| 5 | + ], | ||
| 6 | +}; | ||
| @@ -0,0 +1,9 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +import React from 'react'; | ||
| 8 | + | ||
| 9 | +export const AppParamsContext = React.createContext(undefined); | ||
| @@ -0,0 +1,24 @@ | |||
| 1 | +# it may cause some issues when building the project when switching branches | ||
| 2 | +package-lock.json | ||
| 3 | +# we add this because we want to keep the signing configs out of git | ||
| 4 | +/build-profile.json5 | ||
| 5 | + | ||
| 6 | +rnoh_modules | ||
| 7 | + | ||
| 8 | +**/oh-package-lock.json5 | ||
| 9 | +# --- | ||
| 10 | + | ||
| 11 | +/node_modules | ||
| 12 | +/local.properties | ||
| 13 | +/.idea | ||
| 14 | +**/build | ||
| 15 | +/.hvigor | ||
| 16 | +.cxx | ||
| 17 | +/.clangd | ||
| 18 | +/.clang-format | ||
| 19 | +/.clang-tidy | ||
| 20 | +/oh_modules | ||
| 21 | +hvigorw | ||
| 22 | +hvigorw.bat | ||
| 23 | +hvigor/hvigor-wrapper.js | ||
| 24 | + | ||
| @@ -0,0 +1,10 @@ | |||
| 1 | +{ | ||
| 2 | + "app": { | ||
| 3 | + "bundleName": "com.harmony.mail.demo", | ||
| 4 | + "vendor": "example", | ||
| 5 | + "versionCode": 1000000, | ||
| 6 | + "versionName": "1.0.0", | ||
| 7 | + "icon": "$media:app_icon", | ||
| 8 | + "label": "$string:app_name" | ||
| 9 | + } | ||
| 10 | +} | ||
| @@ -0,0 +1,8 @@ | |||
| 1 | +{ | ||
| 2 | + "string": [ | ||
| 3 | + { | ||
| 4 | + "name": "app_name", | ||
| 5 | + "value": "mailTester" | ||
| 6 | + } | ||
| 7 | + ] | ||
| 8 | +} | ||
| @@ -0,0 +1,39 @@ | |||
| 1 | +{ | ||
| 2 | + "app": { | ||
| 3 | + "products": [ | ||
| 4 | + { | ||
| 5 | + "name": 'default', | ||
| 6 | + "signingConfig": 'default', | ||
| 7 | + "compatibleSdkVersion": '5.0.0(12)', | ||
| 8 | + "runtimeOS": 'HarmonyOS' | ||
| 9 | + }, | ||
| 10 | + ], | ||
| 11 | + "buildModeSet": [ | ||
| 12 | + { | ||
| 13 | + "name": 'debug', | ||
| 14 | + }, | ||
| 15 | + { | ||
| 16 | + "name": 'release', | ||
| 17 | + }, | ||
| 18 | + ], | ||
| 19 | + "signingConfigs": [] | ||
| 20 | + }, | ||
| 21 | + "modules": [ | ||
| 22 | + { | ||
| 23 | + "name": 'entry', | ||
| 24 | + "srcPath": './entry', | ||
| 25 | + "targets": [ | ||
| 26 | + { | ||
| 27 | + "name": 'default', | ||
| 28 | + "applyToProducts": [ | ||
| 29 | + 'default' | ||
| 30 | + ], | ||
| 31 | + }, | ||
| 32 | + ], | ||
| 33 | + }, | ||
| 34 | + { | ||
| 35 | + "name": 'mail', | ||
| 36 | + "srcPath": '../../harmony/mail' | ||
| 37 | + } | ||
| 38 | + ], | ||
| 39 | +} | ||
| @@ -0,0 +1,32 @@ | |||
| 1 | +{ | ||
| 2 | + "files": ["**/*.ts", "**/*.ets"], | ||
| 3 | + "ignore": [ | ||
| 4 | + "**/ohosTest/**/*", | ||
| 5 | + "**/node_modules/**/*", | ||
| 6 | + "**/hvigorfile.ts", | ||
| 7 | + "**/node_modules/**/*", | ||
| 8 | + "**/oh_modules/**/*", | ||
| 9 | + "**/build/**/*", | ||
| 10 | + "**/.preview/**/*" | ||
| 11 | + ], | ||
| 12 | + "plugins": ["@typescript-eslint"], | ||
| 13 | + "ruleSet": [], | ||
| 14 | + "rules": { | ||
| 15 | + "@typescript-eslint/await-thenable": "warn", | ||
| 16 | + "@typescript-eslint/consistent-type-imports": "warn", | ||
| 17 | + "@typescript-eslint/explicit-function-return-type": "warn", | ||
| 18 | + "@typescript-eslint/explicit-module-boundary-types": "warn", | ||
| 19 | + "@typescript-eslint/no-dynamic-delete": "warn", | ||
| 20 | + "@typescript-eslint/no-explicit-any": "warn", | ||
| 21 | + "@typescript-eslint/no-for-in-array": "warn", | ||
| 22 | + "@typescript-eslint/no-this-alias": "warn", | ||
| 23 | + "@typescript-eslint/no-unnecessary-type-constraint": "warn", | ||
| 24 | + "@typescript-eslint/no-unsafe-argument": "warn", | ||
| 25 | + "@typescript-eslint/no-unsafe-assignment": "warn", | ||
| 26 | + "@typescript-eslint/no-unsafe-call": "warn", | ||
| 27 | + "@typescript-eslint/no-unsafe-member-access": "warn", | ||
| 28 | + "@typescript-eslint/no-unsafe-return": "warn", | ||
| 29 | + "@typescript-eslint/prefer-literal-enum-member": "warn" | ||
| 30 | + }, | ||
| 31 | + "overrides": [] | ||
| 32 | +} | ||
| @@ -0,0 +1,7 @@ | |||
| 1 | +/node_modules | ||
| 2 | +/.preview | ||
| 3 | +/build | ||
| 4 | +/.cxx | ||
| 5 | +package-lock.json | ||
| 6 | +/oh_modules | ||
| 7 | +/assets | ||
| @@ -0,0 +1,22 @@ | |||
| 1 | +{ | ||
| 2 | + "apiType": 'stageMode', | ||
| 3 | + "buildOption": { | ||
| 4 | + "externalNativeOptions": { | ||
| 5 | + "path": "./src/main/cpp/CMakeLists.txt", | ||
| 6 | + "arguments": "", | ||
| 7 | + "cppFlags": "-s", | ||
| 8 | + "abiFilters": [ | ||
| 9 | + "arm64-v8a", | ||
| 10 | + "x86_64" | ||
| 11 | + ] | ||
| 12 | + }, | ||
| 13 | + }, | ||
| 14 | + "targets": [ | ||
| 15 | + { | ||
| 16 | + "name": "default", | ||
| 17 | + }, | ||
| 18 | + { | ||
| 19 | + "name": "ohosTest", | ||
| 20 | + } | ||
| 21 | + ] | ||
| 22 | +} | ||
| @@ -0,0 +1,8 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. | ||
| 8 | +export { hapTasks } from '@ohos/hvigor-ohos-plugin'; | ||
| @@ -0,0 +1,11 @@ | |||
| 1 | +{ | ||
| 2 | + "license": "ISC", | ||
| 3 | + "devDependencies": {}, | ||
| 4 | + "name": "entry", | ||
| 5 | + "description": "example description", | ||
| 6 | + "version": "1.0.0", | ||
| 7 | + "dependencies": { | ||
| 8 | + "@rnoh/react-native-openharmony": "file:../../node_modules/react-native-harmony/harmony/react_native_openharmony.har", | ||
| 9 | + "@react-native-ohos/react-native-mail": "file:../../node_modules/@react-native-ohos/react-native-mail/harmony/mail.har" | ||
| 10 | + } | ||
| 11 | +} | ||
| @@ -0,0 +1,2 @@ | |||
| 1 | +jsbundle.h | ||
| 2 | +generated/ | ||
| @@ -0,0 +1,41 @@ | |||
| 1 | +project(rnapp) | ||
| 2 | +cmake_minimum_required(VERSION 3.4.1) | ||
| 3 | +set(CMAKE_SKIP_BUILD_RPATH TRUE) | ||
| 4 | +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") | ||
| 5 | +set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules") | ||
| 6 | +set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") | ||
| 7 | +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@rnoh/react-native-openharmony/src/main/cpp") | ||
| 8 | +set(RNOH_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated") | ||
| 9 | +set(LOG_VERBOSITY_LEVEL 1) | ||
| 10 | +set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments") | ||
| 11 | +set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie") | ||
| 12 | +set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") | ||
| 13 | + | ||
| 14 | +set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use | ||
| 15 | +add_compile_definitions(WITH_HITRACE_SYSTRACE) | ||
| 16 | + | ||
| 17 | +# (VM) Define a variable and assign it to the current module's cpp directory | ||
| 18 | +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) | ||
| 19 | + | ||
| 20 | +# Add the Header File directory, including cpp, cpp/include, and tell cmake to find the Header Files introduced by the code here | ||
| 21 | +include_directories(${NATIVERENDER_ROOT_PATH} | ||
| 22 | + ${NATIVERENDER_ROOT_PATH}/include) | ||
| 23 | + | ||
| 24 | +add_subdirectory("${RNOH_CPP_DIR}" ./rnoh) | ||
| 25 | + | ||
| 26 | +# RNOH_BEGIN: manual_package_linking_1 | ||
| 27 | +add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-mail/src/main/cpp" ./mail) | ||
| 28 | +# RNOH_END: manual_package_linking_1 | ||
| 29 | + | ||
| 30 | +file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp") # this line is needed by codegen v1 | ||
| 31 | + | ||
| 32 | +add_library(rnoh_app SHARED | ||
| 33 | + ${GENERATED_CPP_FILES} | ||
| 34 | + "./PackageProvider.cpp" | ||
| 35 | + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" | ||
| 36 | +) | ||
| 37 | +target_link_libraries(rnoh_app PUBLIC rnoh) | ||
| 38 | + | ||
| 39 | +# RNOH_BEGIN: manual_package_linking_2 | ||
| 40 | +target_link_libraries(rnoh_app PUBLIC rnoh_mail) | ||
| 41 | +# RNOH_END: manual_package_linking_2 | ||
| @@ -0,0 +1,19 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +#include "RNOH/PackageProvider.h" | ||
| 8 | +#include "generated/RNOHGeneratedPackage.h" | ||
| 9 | +#include "MailPackage.h" | ||
| 10 | + | ||
| 11 | +using namespace rnoh; | ||
| 12 | + | ||
| 13 | +std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) | ||
| 14 | +{ | ||
| 15 | + return { | ||
| 16 | + std::make_shared<RNOHGeneratedPackage>(ctx), // generated by codegen v1 | ||
| 17 | + std::make_shared<MailPackage>(ctx), | ||
| 18 | + }; | ||
| 19 | +} | ||
| @@ -0,0 +1,14 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +import type {RNPackageContext, RNPackage} from '@rnoh/react-native-openharmony/ts'; | ||
| 8 | +import {RNMailPackage} from '@react-native-ohos/react-native-mail/ts'; | ||
| 9 | + | ||
| 10 | +export function createRNPackages(ctx: RNPackageContext): RNPackage[] { | ||
| 11 | + return [ | ||
| 12 | + new RNMailPackage(ctx), | ||
| 13 | + ]; | ||
| 14 | +} | ||
Binary files do not support preview
Binary files do not support preview
| @@ -0,0 +1,27 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +import {RNAbility} from '@rnoh/react-native-openharmony'; | ||
| 8 | +import { AbilityConstant, Want } from '@kit.AbilityKit'; | ||
| 9 | + | ||
| 10 | +export default class EntryAbility extends RNAbility { | ||
| 11 | + | ||
| 12 | + onCreate(want: Want) { | ||
| 13 | + super.onCreate(want) | ||
| 14 | + this.handleWeChatCallIfNeed(want) | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + getPagePath() { | ||
| 18 | + return 'pages/Index'; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + onNewWant(want: Want, _launchParam: AbilityConstant.LaunchParam): void { | ||
| 22 | + this.handleWeChatCallIfNeed(want) | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + private handleWeChatCallIfNeed(want: Want) { | ||
| 26 | + } | ||
| 27 | +} | ||
| @@ -0,0 +1,114 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +import { | ||
| 8 | + AnyJSBundleProvider, | ||
| 9 | + ComponentBuilderContext, | ||
| 10 | + FileJSBundleProvider, | ||
| 11 | + MetroJSBundleProvider, | ||
| 12 | + ResourceJSBundleProvider, | ||
| 13 | + RNApp, | ||
| 14 | + RNOHErrorDialog, | ||
| 15 | + RNOHLogger, | ||
| 16 | + TraceJSBundleProviderDecorator, | ||
| 17 | + RNOHCoreContext | ||
| 18 | +} from '@rnoh/react-native-openharmony'; | ||
| 19 | +import font from '@ohos.font'; | ||
| 20 | +import { createRNPackages } from '../RNPackagesFactory'; | ||
| 21 | + | ||
| 22 | +const arkTsComponentNames: string[] = [ | ||
| 23 | +]; | ||
| 24 | + | ||
| 25 | +@Builder | ||
| 26 | +export function buildCustomRNComponent(ctx: ComponentBuilderContext) { | ||
| 27 | + // There seems to be a problem with the placement of ArkTS components in mixed mode. Nested Stack temporarily avoided. | ||
| 28 | + Stack() { | ||
| 29 | + } | ||
| 30 | + .position({ x: 0, y: 0 }) | ||
| 31 | + | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +const wrappedCustomRNComponentBuilder = wrapBuilder(buildCustomRNComponent) | ||
| 35 | + | ||
| 36 | +/** | ||
| 37 | + * If you want to use custom fonts, you need to register them here. | ||
| 38 | + * We should support react-native-asset to handle registering fonts automatically. | ||
| 39 | + */ | ||
| 40 | +const fonts: font.FontOptions[] = [ | ||
| 41 | + { | ||
| 42 | + familyName: 'Pacifico-Regular', | ||
| 43 | + familySrc: '/assets/fonts/Pacifico-Regular.ttf' | ||
| 44 | + }, | ||
| 45 | + { | ||
| 46 | + familyName: 'StintUltraCondensed-Regular', | ||
| 47 | + familySrc: '/assets/fonts/StintUltraCondensed-Regular.ttf' | ||
| 48 | + } | ||
| 49 | +] | ||
| 50 | + | ||
| 51 | +@Entry | ||
| 52 | +@Component | ||
| 53 | +struct Index { | ||
| 54 | + @StorageLink('RNOHCoreContext') private rnohCoreContext: RNOHCoreContext | undefined = undefined | ||
| 55 | + @State shouldShow: boolean = false | ||
| 56 | + private logger!: RNOHLogger | ||
| 57 | + bundlePath: string = 'bunlde.harmony.js' | ||
| 58 | + @State hasBundle: boolean = false | ||
| 59 | + | ||
| 60 | + aboutToAppear() { | ||
| 61 | + this.logger = this.rnohCoreContext!.logger.clone('Index') | ||
| 62 | + const stopTracing = this.logger.clone('aboutToAppear').startTracing() | ||
| 63 | + for (const customFont of fonts) { | ||
| 64 | + font.registerFont(customFont) | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + this.shouldShow = true | ||
| 68 | + stopTracing() | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + onBackPress(): boolean | undefined { | ||
| 72 | + // NOTE: this is required since `Ability`'s `onBackPressed` function always | ||
| 73 | + // terminates or puts the app in the background, but we want Ark to ignore it completely | ||
| 74 | + // when handled by app. | ||
| 75 | + this.rnohCoreContext!.dispatchBackPress() | ||
| 76 | + return true | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + build() { | ||
| 80 | + Column() { | ||
| 81 | + if (this.rnohCoreContext && this.shouldShow) { | ||
| 82 | + if (this.rnohCoreContext?.isDebugModeEnabled) { | ||
| 83 | + RNOHErrorDialog({ ctx: this.rnohCoreContext }) | ||
| 84 | + } | ||
| 85 | + RNApp({ | ||
| 86 | + rnInstanceConfig: { | ||
| 87 | + createRNPackages, | ||
| 88 | + enableNDKTextMeasuring: true, | ||
| 89 | + enableBackgroundExecutor: false, | ||
| 90 | + enableCAPIArchitecture: true, | ||
| 91 | + arkTsComponentNames: arkTsComponentNames, | ||
| 92 | + }, | ||
| 93 | + initialProps: { 'foo': 'bar' } as Record<string, string>, | ||
| 94 | + appKey: 'react-native-mail-example', | ||
| 95 | + wrappedCustomRNComponentBuilder: wrappedCustomRNComponentBuilder, | ||
| 96 | + onSetUp: (rnInstance) => { | ||
| 97 | + rnInstance.enableFeatureFlag('ENABLE_RN_INSTANCE_CLEAN_UP') | ||
| 98 | + }, | ||
| 99 | + jsBundleProvider: new TraceJSBundleProviderDecorator( | ||
| 100 | + new AnyJSBundleProvider([ | ||
| 101 | + new MetroJSBundleProvider(), | ||
| 102 | + new FileJSBundleProvider('/data/storage/el2/base/files/bundle.harmony.js'), | ||
| 103 | + new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'hermes_bundle.hbc'), | ||
| 104 | + new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'bundle.harmony.js') | ||
| 105 | + ]), | ||
| 106 | + this.rnohCoreContext.logger), | ||
| 107 | + }) | ||
| 108 | + } | ||
| 109 | + Text('1233333333122 1212323') | ||
| 110 | + } | ||
| 111 | + .height('100%') | ||
| 112 | + .width('100%') | ||
| 113 | + } | ||
| 114 | +} | ||
| @@ -0,0 +1,133 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +import { RNInstance, JSBundleProvider, RNAbility, RNSurface } from '@rnoh/react-native-openharmony' | ||
| 8 | +import { CustomComponentBuilder } from '@rnoh/react-native-openharmony/src/main/ets/RNOHCorePackage' | ||
| 9 | +import { SurfaceConfig2 } from '@rnoh/react-native-openharmony/src/main/ets/RNSurface' | ||
| 10 | + | ||
| 11 | +@Component | ||
| 12 | +export struct SurfaceDeadlockTest { | ||
| 13 | + public jsBundleProvider: JSBundleProvider | undefined = undefined | ||
| 14 | + public appKeys: string[] = [] | ||
| 15 | + public numberOfIterations: number = 1 | ||
| 16 | + @BuilderParam public buildCustomComponent!: CustomComponentBuilder | ||
| 17 | + // ------------------------------------------------------------------------------------------------------------------- | ||
| 18 | + @StorageLink('RNAbility') private rnAbility: RNAbility = {} as RNAbility | ||
| 19 | + private rnInstance!: RNInstance | ||
| 20 | + @State private shouldShow: boolean = false | ||
| 21 | + private shouldDestroyRNInstance: boolean = false | ||
| 22 | + private cleanUpCallbacks: (() => void)[] = [] | ||
| 23 | + | ||
| 24 | + aboutToAppear() { | ||
| 25 | + this.getOrCreateRNInstance().then(rnInstance => { | ||
| 26 | + this.rnInstance = rnInstance | ||
| 27 | + const jsBundleExecutionStatus = this.rnInstance.getBundleExecutionStatus(this.jsBundleProvider?.getURL()) | ||
| 28 | + if (this.jsBundleProvider && jsBundleExecutionStatus === undefined) { | ||
| 29 | + this.rnInstance.runJSBundle(this.jsBundleProvider).then(() => { | ||
| 30 | + this.shouldShow = true | ||
| 31 | + }) | ||
| 32 | + return; | ||
| 33 | + } | ||
| 34 | + }).catch((reason: string | Error) => { | ||
| 35 | + if (typeof reason === 'string') { | ||
| 36 | + this.rnAbility.getLogger().error(reason) | ||
| 37 | + } else if (reason instanceof Error) { | ||
| 38 | + this.rnAbility.getLogger().error(reason.message) | ||
| 39 | + } else { | ||
| 40 | + this.rnAbility.getLogger().error('Fatal exception') | ||
| 41 | + } | ||
| 42 | + }) | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + aboutToDisappear() { | ||
| 46 | + if (this.shouldDestroyRNInstance) { | ||
| 47 | + this.rnAbility.destroyAndUnregisterRNInstance(this.rnInstance) | ||
| 48 | + } | ||
| 49 | + this.cleanUpCallbacks.forEach(cleanUp => cleanUp()) | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + private getOrCreateRNInstance(): Promise<RNInstance> { | ||
| 53 | + return this.rnAbility.createAndRegisterRNInstance({ createRNPackages: () => [] }) | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + build() { | ||
| 57 | + Stack() { | ||
| 58 | + if (this.shouldShow) { | ||
| 59 | + ForEach(this.appKeys, (appKey: string, idx) => { | ||
| 60 | + Stack() { | ||
| 61 | + Blinker({ | ||
| 62 | + minDelayInMs: 1000, | ||
| 63 | + maxDelayInMs: 2000, | ||
| 64 | + blinksCount: this.numberOfIterations, | ||
| 65 | + randomnessPrecisionInMs: 500 | ||
| 66 | + }) { | ||
| 67 | + RNSurface({ | ||
| 68 | + ctx: this.rnAbility.createRNOHContext({ rnInstance: this.rnInstance }), | ||
| 69 | + surfaceConfig: { | ||
| 70 | + initialProps: {}, | ||
| 71 | + appKey: appKey, | ||
| 72 | + } as SurfaceConfig2, | ||
| 73 | + buildCustomComponent: this.buildCustomComponent, | ||
| 74 | + }) | ||
| 75 | + } | ||
| 76 | + }.height(`${100 / this.appKeys.length}%`) | ||
| 77 | + .position({ x: 0, y: `${(idx / this.appKeys.length) * 100}%` }) | ||
| 78 | + }) | ||
| 79 | + } | ||
| 80 | + }.width('100%') | ||
| 81 | + .height('100%') | ||
| 82 | + } | ||
| 83 | +} | ||
| 84 | + | ||
| 85 | +@Component | ||
| 86 | +struct Blinker { | ||
| 87 | + public minDelayInMs: number = 0 | ||
| 88 | + public maxDelayInMs: number = 1000 | ||
| 89 | + public blinksCount: number = 0 | ||
| 90 | + public randomnessPrecisionInMs: number = 250 | ||
| 91 | + @BuilderParam public renderChildren: () => void | ||
| 92 | + private currentBlinksCount = 0 | ||
| 93 | + @State private isVisible: boolean = false | ||
| 94 | + private timeout: number = 0 | ||
| 95 | + | ||
| 96 | + aboutToAppear() { | ||
| 97 | + this.blink(this.minDelayInMs) | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + aboutToDisappear() { | ||
| 101 | + clearTimeout(this.timeout) | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + private blink(ms: number) { | ||
| 105 | + this.isVisible = !this.isVisible | ||
| 106 | + this.currentBlinksCount += 1 | ||
| 107 | + if (this.currentBlinksCount >= this.blinksCount) { | ||
| 108 | + if (this.timeout) { | ||
| 109 | + clearTimeout(this.timeout) | ||
| 110 | + } | ||
| 111 | + this.isVisible = true | ||
| 112 | + return | ||
| 113 | + } | ||
| 114 | + this.timeout = setTimeout(() => { | ||
| 115 | + this.blink(this.getNextDelay()) | ||
| 116 | + }, ms) | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + private getNextDelay(): number { | ||
| 120 | + const randomFactor = Math.floor( | ||
| 121 | + Math.random() * (Number.MAX_VALUE / this.randomnessPrecisionInMs) | ||
| 122 | + ) * this.randomnessPrecisionInMs; | ||
| 123 | + return (randomFactor % this.maxDelayInMs) + this.minDelayInMs | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + build() { | ||
| 127 | + Stack() { | ||
| 128 | + if (this.isVisible) { | ||
| 129 | + this.renderChildren() | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | + } | ||
| 133 | +} | ||
| @@ -0,0 +1,43 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +@Component | ||
| 8 | +export struct TouchDisplayer { | ||
| 9 | + @State currentTouches: TouchObject[] = [] | ||
| 10 | + @State touchIndicatorOpacity: number = 0 | ||
| 11 | + @BuilderParam buildChildren: () => void | ||
| 12 | + build() { | ||
| 13 | + Stack() { | ||
| 14 | + this.buildChildren() | ||
| 15 | + ForEach(this.currentTouches, (activeTouch: TouchObject) => { | ||
| 16 | + Stack() { | ||
| 17 | + } | ||
| 18 | + .width(64) | ||
| 19 | + .height(64) | ||
| 20 | + .backgroundColor('blue') | ||
| 21 | + .borderWidth(2) | ||
| 22 | + .borderColor('white') | ||
| 23 | + .opacity(this.touchIndicatorOpacity) | ||
| 24 | + .position({ x: activeTouch.x - 32, y: activeTouch.y - 32 }) | ||
| 25 | + .borderRadius(1000) | ||
| 26 | + .hitTestBehavior(HitTestMode.Transparent) | ||
| 27 | + }) | ||
| 28 | + } | ||
| 29 | + .width('100%') | ||
| 30 | + .height('100%') | ||
| 31 | + .hitTestBehavior(HitTestMode.Transparent) | ||
| 32 | + .onTouch(e => { | ||
| 33 | + this.currentTouches = e.touches | ||
| 34 | + this.touchIndicatorOpacity = 0.5 | ||
| 35 | + animateTo({ | ||
| 36 | + duration: 500, | ||
| 37 | + curve: Curve.Linear, | ||
| 38 | + }, () => { | ||
| 39 | + this.touchIndicatorOpacity = 0 | ||
| 40 | + }) | ||
| 41 | + }) | ||
| 42 | + } | ||
| 43 | +} | ||
| @@ -0,0 +1,52 @@ | |||
| 1 | +{ | ||
| 2 | + "module": { | ||
| 3 | + "name": "entry", | ||
| 4 | + "type": "entry", | ||
| 5 | + "description": "$string:module_desc", | ||
| 6 | + "mainElement": "EntryAbility", | ||
| 7 | + "deviceTypes": [ | ||
| 8 | + "default" | ||
| 9 | + ], | ||
| 10 | + "querySchemes": [ | ||
| 11 | + "weixin", | ||
| 12 | + ], | ||
| 13 | + "deliveryWithInstall": true, | ||
| 14 | + "installationFree": false, | ||
| 15 | + "pages": "$profile:main_pages", | ||
| 16 | + // below property is supported from 5.0.0 - it is needed by bundleManager.canOpenLink to check if the app can open some url | ||
| 17 | + // "querySchemes": ["maps", "http", "https", "customDomain"], | ||
| 18 | + "requestPermissions": [ | ||
| 19 | + { | ||
| 20 | + "name": "ohos.permission.INTERNET" | ||
| 21 | + }, | ||
| 22 | + ], | ||
| 23 | + "metadata": [ | ||
| 24 | + { | ||
| 25 | + "name": "OPTLazyForEach", | ||
| 26 | + "value": "true", | ||
| 27 | + } | ||
| 28 | + ], | ||
| 29 | + "abilities": [ | ||
| 30 | + { | ||
| 31 | + "name": "EntryAbility", | ||
| 32 | + "srcEntry": "./ets/entryability/EntryAbility.ets", | ||
| 33 | + "description": "$string:EntryAbility_desc", | ||
| 34 | + "icon": "$media:icon", | ||
| 35 | + "label": "$string:EntryAbility_label", | ||
| 36 | + "startWindowIcon": "$media:icon", | ||
| 37 | + "startWindowBackground": "$color:start_window_background", | ||
| 38 | + "visible": true, | ||
| 39 | + "skills": [ | ||
| 40 | + { | ||
| 41 | + "entities": [ | ||
| 42 | + "entity.system.home" | ||
| 43 | + ], | ||
| 44 | + "actions": [ | ||
| 45 | + "action.system.home" | ||
| 46 | + ] | ||
| 47 | + } | ||
| 48 | + ] | ||
| 49 | + } | ||
| 50 | + ] | ||
| 51 | + } | ||
| 52 | +} | ||
| @@ -0,0 +1 @@ | |||
| 1 | +rawfile/assets | ||
| @@ -0,0 +1,8 @@ | |||
| 1 | +{ | ||
| 2 | + "color": [ | ||
| 3 | + { | ||
| 4 | + "name": "start_window_background", | ||
| 5 | + "value": "#FFFFFF" | ||
| 6 | + } | ||
| 7 | + ] | ||
| 8 | +} | ||
| @@ -0,0 +1,16 @@ | |||
| 1 | +{ | ||
| 2 | + "string": [ | ||
| 3 | + { | ||
| 4 | + "name": "module_desc", | ||
| 5 | + "value": "module description" | ||
| 6 | + }, | ||
| 7 | + { | ||
| 8 | + "name": "EntryAbility_desc", | ||
| 9 | + "value": "description" | ||
| 10 | + }, | ||
| 11 | + { | ||
| 12 | + "name": "EntryAbility_label", | ||
| 13 | + "value": "React Native Tester" | ||
| 14 | + } | ||
| 15 | + ] | ||
| 16 | +} | ||
| @@ -0,0 +1,5 @@ | |||
| 1 | +{ | ||
| 2 | + "src": [ | ||
| 3 | + "pages/Index" | ||
| 4 | + ] | ||
| 5 | +} | ||
| @@ -0,0 +1 @@ | |||
| 1 | +text test | ||
| @@ -0,0 +1,18 @@ | |||
| 1 | +/* | ||
【AI-Review】【一般】【基础代码问题】【代码逻辑错误】PowerShell 脚本使用了无效的 C 风格注释语法 ● 问题:example/harmony/format.ps1 第 1-5 行使用了 C 风格注释 /* Copyright (c) 2025 ... /,但 PowerShell 不支持 / / 注释语法(PowerShell 使用 # 单行注释和 <# #> 多行注释)。实际运行测试表明,PowerShell 将 /、、/ 解析为命令调用,逐行触发 CommandNotFoundException 错误(共 4 次)。 ● 影响:一般。每次执行该格式化脚本时都会输出 4 条 CommandNotFoundException 错误到 stderr,虽然脚本因 PowerShell 的错误继续特性仍能执行后续逻辑,但错误输出会干扰 CI/CD 日志判断,也会误导开发者以为脚本存在问题。 ● 建议:将第 1-5 行的 C 风格注释改为 PowerShell 单行注释,即用 # 替换 /* 和 */ 并删除每行开头的 *。 ![]() ![]() | |||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +$directoryPath = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
| 8 | +$filePaths = Get-ChildItem $directoryPath -Recurse -Include *.h, *.cpp | | ||
| 9 | +Where-Object { | ||
| 10 | + $_.DirectoryName -notmatch 'third-party' -and | ||
| 11 | + $_.DirectoryName -notmatch 'patches' -and | ||
| 12 | + $_.DirectoryName -notmatch 'node_modules' -and | ||
| 13 | + $_.DirectoryName -notmatch '.cxx' -and | ||
| 14 | + $_.DirectoryName -notmatch 'build' | ||
| 15 | +} | ||
| 16 | +foreach ($filePath in $filePaths) { | ||
| 17 | + & "clang-format.exe" -style=file -i $filePath.FullName | ||
| 18 | +} | ||
| @@ -0,0 +1 @@ | |||
| 1 | +*.tgz | ||
| @@ -0,0 +1,21 @@ | |||
| 1 | +{ | ||
| 2 | + "modelVersion": "5.0.0", | ||
| 3 | + "dependencies": { | ||
| 4 | + }, | ||
| 5 | + "execution": { | ||
| 6 | + // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */ | ||
| 7 | + "daemon": false, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ | ||
| 8 | + "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ | ||
| 9 | + "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ | ||
| 10 | + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ | ||
| 11 | + }, | ||
| 12 | + "logging": { | ||
| 13 | + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ | ||
| 14 | + }, | ||
| 15 | + "debugging": { | ||
| 16 | + "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ | ||
| 17 | + }, | ||
| 18 | + "nodeOptions": { | ||
| 19 | + // "maxOldSpaceSize": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */ | ||
| 20 | + } | ||
| 21 | +} | ||
| @@ -0,0 +1,8 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. | ||
| 8 | +export { appTasks } from '@ohos/hvigor-ohos-plugin'; | ||
| @@ -0,0 +1,12 @@ | |||
| 1 | +{ | ||
| 2 | + "modelVersion": "5.0.0", | ||
| 3 | + "license": "ISC", | ||
| 4 | + "name": "rnoh", | ||
| 5 | + "description": "example description", | ||
| 6 | + "repository": {}, | ||
| 7 | + "version": "1.0.0", | ||
| 8 | + "overrides": { | ||
| 9 | + "@rnoh/react-native-openharmony": "file:../node_modules/@react-native-oh/react-native-harmony/react_native_openharmony.har" | ||
| 10 | + }, | ||
| 11 | + "dynamicDependencies": {} | ||
| 12 | +} | ||
| @@ -0,0 +1,11 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +import {AppRegistry, View, Text} from 'react-native'; | ||
| 8 | +import {name as appName} from './app.json'; | ||
| 9 | +import App from './src/index'; | ||
| 10 | + | ||
| 11 | +AppRegistry.registerComponent(appName, () => App); | ||
| @@ -0,0 +1,11 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
| 8 | +module.exports = { | ||
| 9 | + preset: 'ts-jest', | ||
| 10 | + testEnvironment: 'node', | ||
| 11 | +}; | ||
| @@ -0,0 +1,32 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +const { mergeConfig, getDefaultConfig } = require('@react-native/metro-config'); | ||
| 8 | +const { | ||
| 9 | + createHarmonyMetroConfig, | ||
| 10 | +} = require('@react-native-oh/react-native-harmony/metro.config'); | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * @type {import("metro-config").ConfigT} | ||
| 14 | + */ | ||
| 15 | +const config = { | ||
| 16 | + transformer: { | ||
| 17 | + getTransformOptions: async () => ({ | ||
| 18 | + transform: { | ||
| 19 | + experimentalImportSupport: false, | ||
| 20 | + inlineRequires: true, | ||
| 21 | + }, | ||
| 22 | + }), | ||
| 23 | + }, | ||
| 24 | +}; | ||
| 25 | + | ||
| 26 | +module.exports = mergeConfig( | ||
| 27 | + getDefaultConfig(__dirname), | ||
| 28 | + createHarmonyMetroConfig({ | ||
| 29 | + reactNativeHarmonyPackageName: '@react-native-oh/react-native-harmony', | ||
| 30 | + }), | ||
| 31 | + config, | ||
| 32 | +); | ||
| @@ -0,0 +1,61 @@ | |||
| 1 | +{ | ||
| 2 | + "name": "react-native-harmony-tester", | ||
| 3 | + "version": "1.0.0", | ||
| 4 | + "private": true, | ||
| 5 | + "scripts": { | ||
| 6 | + "i": "cd ../ && npm i && npm run pack && cd ./example && npm i", | ||
| 7 | + "reStart": "npm run install:pkg && npm run codegen && hdc rport tcp:8081 tcp:8081 && react-native start", | ||
| 8 | + "start": "hdc rport tcp:8081 tcp:8081 && react-native start", | ||
| 9 | + "codegen": "react-native codegen-harmony --rnoh-module-path ./harmony/entry/oh_modules/@rnoh/react-native-openharmony", | ||
| 10 | + "pack:pkg": "cd ../ && npm pack && cd ./example", | ||
| 11 | + "install:pkg": "npm uninstall @react-native-ohos/react-native-mail && npm run pack:pkg && npm i @react-native-ohos/react-native-mail@file:../react-native-ohos-react-native-mail-6.3.1-beta.1.tgz", | ||
| 12 | + "dev": "npm run codegen && react-native bundle-harmony --dev --minify=false", | ||
| 13 | + "prod": "npm run codegen && react-native bundle-harmony --dev=false --minify=true", | ||
| 14 | + "postinstall": "node ./scripts/create-build-profile", | ||
| 15 | + "fast:pkg": "cd ../ && npm i --force && npm pack && cd ./example && npm i --force && npm run dev" | ||
| 16 | + }, | ||
| 17 | + "dependencies": { | ||
| 18 | + "@gorhom/portal": "^1.0.14", | ||
| 19 | + "@react-native-ohos/react-native-mail": "file:../react-native-ohos-react-native-mail-6.3.1-beta.1.tgz", | ||
| 20 | + "react": "19.1.1", | ||
| 21 | + "react-native": "0.82.1", | ||
| 22 | + "@rnoh/testerino": "npm:@react-native-oh-tpl/testerino@0.0.9", | ||
| 23 | + "@react-native-oh/react-native-harmony": "npm:@react-native-oh/react-native-harmony@0.82.30", | ||
| 24 | + "react-native-reanimated": "^3.6.0" | ||
| 25 | + }, | ||
| 26 | + "devDependencies": { | ||
| 27 | + "@babel/core": "^7.25.2", | ||
| 28 | + "@babel/preset-env": "^7.25.3", | ||
| 29 | + "@babel/runtime": "^7.25.0", | ||
| 30 | + "@react-native-community/cli": "20.0.0", | ||
| 31 | + "@react-native-community/cli-platform-android": "15.0.1", | ||
| 32 | + "@react-native-community/cli-platform-ios": "20.0.0", | ||
| 33 | + "@react-native-community/eslint-config": "^3.2.0", | ||
| 34 | + "@react-native/babel-preset": "0.82.1", | ||
| 35 | + "@react-native/eslint-config": "0.82.1", | ||
| 36 | + "@react-native/metro-config": "0.82.1", | ||
| 37 | + "@react-native/typescript-config": "0.82.1", | ||
| 38 | + "@react-native-oh/react-native-harmony-cli": "npm:@react-native-oh/react-native-harmony-cli@0.82.30", | ||
| 39 | + "@tsconfig/react-native": "^3.0.0", | ||
| 40 | + "@types/d3-scale-chromatic": "^3.0.0", | ||
| 41 | + "@types/jest": "^29.5.13", | ||
| 42 | + "@types/react": "^19.1.0", | ||
| 43 | + "@types/react-test-renderer": "^19.1.0", | ||
| 44 | + "babel-jest": "^29.6.3", | ||
| 45 | + "eslint": "^8.19.0", | ||
| 46 | + "jest": "^29.7.0", | ||
| 47 | + "metro-react-native-babel-preset": "0.76.8", | ||
| 48 | + "prettier": "3.0.0", | ||
| 49 | + "react-test-renderer": "19.1.1", | ||
| 50 | + "typescript": "5.5.4" | ||
| 51 | + }, | ||
| 52 | + "overrides": { | ||
| 53 | + "@react-native-community/cli": "20.0.0" | ||
| 54 | + }, | ||
| 55 | + "resolutions": { | ||
| 56 | + "@react-native-community/cli": "20.0.0" | ||
| 57 | + }, | ||
| 58 | + "engines": { | ||
| 59 | + "node": ">=18" | ||
| 60 | + } | ||
| 61 | +} | ||
| @@ -0,0 +1,10 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +module.exports = { | ||
| 8 | + project: {}, | ||
| 9 | + assets: ['./assets/fonts/'], | ||
| 10 | +}; | ||
| @@ -0,0 +1,45 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | + * Use of this source code is governed by a MIT license that can be | ||
| 4 | + * found in the LICENSE file. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +const fs = require('fs'); | ||
| 8 | +const JSON5 = require('json5'); | ||
| 9 | +const path = require('path'); | ||
| 10 | + | ||
| 11 | +const templatePath = path.join( | ||
| 12 | + __dirname, | ||
| 13 | + '..', | ||
| 14 | + 'harmony', | ||
| 15 | + 'build-profile.template.json5', | ||
| 16 | +); | ||
| 17 | +const existingProfilePath = path.join( | ||
| 18 | + __dirname, | ||
| 19 | + '..', | ||
| 20 | + 'harmony', | ||
| 21 | + 'build-profile.json5', | ||
| 22 | +); | ||
| 23 | + | ||
| 24 | +if (fs.existsSync(existingProfilePath)) { | ||
| 25 | + let existingProfile = JSON5.parse( | ||
| 26 | + fs.readFileSync(existingProfilePath, 'utf-8'), | ||
| 27 | + ); | ||
| 28 | + let template = JSON5.parse(fs.readFileSync(templatePath, 'utf-8')); | ||
| 29 | + let signingConfigs = | ||
| 30 | + existingProfile.app && existingProfile.app.signingConfigs; | ||
| 31 | + | ||
| 32 | + existingProfile = {...template}; | ||
| 33 | + | ||
| 34 | + if (signingConfigs) { | ||
| 35 | + existingProfile.app.signingConfigs = signingConfigs; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + fs.writeFileSync( | ||
| 39 | + existingProfilePath, | ||
| 40 | + JSON5.stringify(existingProfile, null, 2), | ||
| 41 | + ); | ||
| 42 | +} else { | ||
| 43 | + // File doesn't exist, create a copy from the template | ||
| 44 | + fs.copyFileSync(templatePath, existingProfilePath); | ||
| 45 | +} | ||
| @@ -0,0 +1,62 @@ | |||
| 1 | +import React from 'react'; | ||
| 2 | +import { | ||
| 3 | + SafeAreaView, | ||
| 4 | + StatusBar, | ||
| 5 | + Text, | ||
| 6 | + View, | ||
| 7 | +} from 'react-native'; | ||
| 8 | +import {NavigationContainer, Page} from './Navigation'; | ||
| 9 | +import {PortalProvider} from '@gorhom/portal'; | ||
| 10 | +import testSuiteByName from './index'; | ||
| 11 | + | ||
| 12 | +const comList = Object.keys(testSuiteByName).map(testSuiteName => { | ||
| 13 | + return { | ||
| 14 | + name: testSuiteName, | ||
| 15 | + com: testSuiteByName[testSuiteName as keyof typeof testSuiteByName] | ||
| 16 | + } | ||
| 17 | +}) | ||
| 18 | +// @ts-ignore | ||
| 19 | +comList.sort((a, b) => { | ||
| 20 | + return a.name.localeCompare(b.name) | ||
| 21 | +}) | ||
| 22 | +function App() { | ||
| 23 | + return ( | ||
| 24 | + <View style={{backgroundColor: 'black'}}> | ||
| 25 | + <StatusBar barStyle="light-content" /> | ||
| 26 | + <SafeAreaView> | ||
| 27 | + <NavigationContainer> | ||
| 28 | + <PortalProvider> | ||
| 29 | + {comList.map(com => { | ||
| 30 | + const TestSuite = com.com | ||
| 31 | + return ( | ||
| 32 | + <Page | ||
| 33 | + key={com.name} | ||
| 34 | + name={`${com.name}`}> | ||
| 35 | + <TestSuite key={com.name} /> | ||
| 36 | + </Page> | ||
| 37 | + ); | ||
| 38 | + })} | ||
| 39 | + | ||
| 40 | + </PortalProvider> | ||
| 41 | + </NavigationContainer> | ||
| 42 | + </SafeAreaView> | ||
| 43 | + </View> | ||
| 44 | + ); | ||
| 45 | +} | ||
| 46 | +export default App; | ||
| 47 | + | ||
| 48 | +export const displayName = 'Mail'; | ||
| 49 | +export const framework = 'React'; | ||
| 50 | +export const category = 'UI'; | ||
| 51 | +export const title = 'Mail'; | ||
| 52 | +export const documentationURL = 'https://reactnative.dev/docs/button'; | ||
| 53 | +export const description = 'React Native Mail'; | ||
| 54 | + | ||
| 55 | +export const examples = [ | ||
| 56 | + { | ||
| 57 | + title: 'React Native Mail', | ||
| 58 | + render: function (): any { | ||
| 59 | + return <App />; | ||
| 60 | + }, | ||
| 61 | + }, | ||
| 62 | +]; | ||
| @@ -0,0 +1,72 @@ | |||
| 1 | +import React, { Component } from 'react'; | ||
| 2 | +import { View, Alert, Button, Text } from 'react-native'; | ||
| 3 | +import Mailer from 'react-native-mail'; | ||
| 4 | + | ||
| 5 | +export default function () { | ||
| 6 | + | ||
| 7 | + const handleEmail = () => { | ||
| 8 | + Mailer.mail({ | ||
| 9 | + subject: 'need help', | ||
| 10 | + recipients: ['support@example.com'], | ||
| 11 | + ccRecipients: ['supportCC@example.com'], | ||
| 12 | + bccRecipients: ['supportBCC@example.com'], | ||
| 13 | + body: '<b>A Bold Body</b>', | ||
| 14 | + customChooserTitle: 'This is my new title', // Android only (defaults to "Send Mail") | ||
| 15 | + isHTML: true, | ||
| 16 | + attachments: [{ | ||
| 17 | + // Specify either `path` or `uri` to indicate where to find the file data. | ||
| 18 | + path: '', // /data/storage/el2/base/haps/entry/files/11.png | ||
| 19 | + uri: '', // file://<packageName>/data/storage/el2/base/haps/entry/files/11.png | ||
| 20 | + // Specify either `type` or `mimeType` to indicate the type of data. | ||
| 21 | + type: '', // Mime Type: jpg, png, doc, ppt, html, pdf, csv | ||
| 22 | + mimeType: '', // - use only if you want to use custom type | ||
| 23 | + name: '', // Optional: Custom filename for attachment | ||
| 24 | + }] | ||
| 25 | + }, (error, event) => { | ||
| 26 | + Alert.alert( | ||
| 27 | + error, | ||
| 28 | + event, | ||
| 29 | + [ | ||
| 30 | + { text: 'Ok', onPress: () => console.log('OK: Email Error Response') }, | ||
| 31 | + { text: 'Cancel', onPress: () => console.log('CANCEL: Email Error Response') } | ||
| 32 | + ], | ||
| 33 | + { cancelable: true } | ||
| 34 | + ) | ||
| 35 | + }); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + return ( | ||
| 39 | + <View style={{ backgroundColor: 'white', flex: 1, gap: 10 }}> | ||
| 40 | + <View style={{ flexDirection: 'row', rowGap: 10 }}> | ||
| 41 | + <Text>subject:</Text> | ||
| 42 | + <Text>need help</Text> | ||
| 43 | + </View> | ||
| 44 | + <View style={{ flexDirection: 'row', rowGap: 10 }}> | ||
| 45 | + <Text>recipients:</Text> | ||
| 46 | + <Text>support@example.com</Text> | ||
| 47 | + </View> | ||
| 48 | + <View style={{ flexDirection: 'row', rowGap: 10 }}> | ||
| 49 | + <Text>ccRecipients:</Text> | ||
| 50 | + <Text>supportCC@example.com</Text> | ||
| 51 | + </View> | ||
| 52 | + <View style={{ flexDirection: 'row', rowGap: 10 }}> | ||
| 53 | + <Text>bccRecipients:</Text> | ||
| 54 | + <Text>supportBCC@example.com</Text> | ||
| 55 | + </View> | ||
| 56 | + <View style={{ flexDirection: 'row', rowGap: 10 }}> | ||
| 57 | + <Text>body:</Text> | ||
| 58 | + <Text>{`<b>A Bold Body</b>`}</Text> | ||
| 59 | + </View> | ||
| 60 | + <View style={{ flexDirection: 'row', rowGap: 10 }}> | ||
| 61 | + <Text>isHTML:</Text> | ||
| 62 | + <Text>true</Text> | ||
| 63 | + </View> | ||
| 64 | + <Button | ||
| 65 | + onPress={handleEmail} | ||
| 66 | + title="Email Me" | ||
| 67 | + color="#841584" | ||
| 68 | + accessabilityLabel="Purple Email Me Button" | ||
| 69 | + /> | ||
| 70 | + </View> | ||
| 71 | + ); | ||
| 72 | +} | ||
| @@ -0,0 +1,7 @@ | |||
| 1 | +// import EmailDemo from './demo'; | ||
| 2 | +import EmailTesterr from './tester'; | ||
| 3 | + | ||
| 4 | +export default{ | ||
| 5 | + // EmailDemo, | ||
| 6 | + EmailTesterr, | ||
| 7 | +} | ||
| @@ -0,0 +1,206 @@ | |||
| 1 | +import { View, Alert, Button, ScrollView, TextInput, Text, TouchableHighlight, Linking } from 'react-native'; | ||
| 2 | +import Mailer from 'react-native-mail'; | ||
| 3 | +import { Tester, TestCase, TestSuite } from '@rnoh/testerino'; | ||
| 4 | +import { useState } from 'react'; | ||
| 5 | + | ||
| 6 | +// { | ||
| 7 | +// subject: 'need help', | ||
| 8 | +// recipients: ['support@example.com'], | ||
| 9 | +// ccRecipients: ['supportCC@example.com'], | ||
| 10 | +// bccRecipients: ['supportBCC@example.com'], | ||
| 11 | +// body: '<b>A Bold Body</b>', | ||
| 12 | +// customChooserTitle: 'This is my new title', // Android only (defaults to "Send Mail") | ||
| 13 | +// isHTML: true, | ||
| 14 | +// attachments: [{ | ||
| 15 | +// // Specify either `path` or `uri` to indicate where to find the file data. | ||
| 16 | +// // The API used to create or locate the file will usually indicate which it returns. | ||
| 17 | +// // An absolute path will look like: /cacheDir/photos/some image.jpg | ||
| 18 | +// // A URI starts with a protocol and looks like: content://appname/cacheDir/photos/some%20image.jpg | ||
| 19 | +// path: '/data/storage/el2/base/haps/entry/files/test.txt', // The absolute path of the file from which to read data. | ||
| 20 | +// // uri: 'file://media/Photo/4/IMG_1718588093_001/screenshot_20240617_093313.jpg', // The uri of the file from which to read the data. | ||
| 21 | +// // Specify either `type` or `mimeType` to indicate the type of data. | ||
| 22 | +// type: 'text', // Mime Type: jpg, png, doc, ppt, html, pdf, csv | ||
| 23 | +// mimeType: '', // - use only if you want to use custom type | ||
| 24 | +// name: 'test.txt', // Optional: Custom filename for attachment | ||
| 25 | +// }] | ||
| 26 | +// } | ||
| 27 | +let attachments = { | ||
| 28 | + path: '', | ||
| 29 | + uri: '', | ||
| 30 | + type: '', | ||
| 31 | + mimeType: '', | ||
| 32 | + name: '', | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +export default function RnMailTest() { | ||
| 36 | + const [mailOptions, setMailOptions] = useState({ | ||
| 37 | + subject: '', | ||
| 38 | + recipients: [], | ||
| 39 | + ccRecipients: [], | ||
| 40 | + bccRecipients: [], | ||
| 41 | + body: '', | ||
| 42 | + customChooserTitle: '', | ||
| 43 | + isHTML: false, | ||
| 44 | + attachments: [ | ||
| 45 | + { | ||
| 46 | + path: '', // /data/storage/el2/base/haps/entry/files/11.png | ||
| 47 | + uri: '', // file://com.rnoh.tester/data/storage/el2/base/haps/entry/files/11.png | ||
| 48 | + type: '', | ||
| 49 | + mimeType: '', | ||
| 50 | + name: '', | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + ] | ||
| 54 | + }); | ||
| 55 | + const [error, setError] = useState(''); | ||
| 56 | + const [event, setEvent] = useState(''); | ||
| 57 | + | ||
| 58 | + const rnMailoptions = [ | ||
| 59 | + { | ||
| 60 | + key: 'subject:主题', | ||
| 61 | + placeholder: '请输入主题', | ||
| 62 | + value: 'subject', | ||
| 63 | + }, | ||
| 64 | + { | ||
| 65 | + key: 'recipients:收件人,多个用英文逗号分隔', | ||
| 66 | + placeholder: 'eg:support@example.com,support1@example.com', | ||
| 67 | + value: 'recipients', | ||
| 68 | + }, | ||
| 69 | + | ||
| 70 | + { | ||
| 71 | + key: 'ccRecipients:抄送收件人,多个用英文逗号分隔', | ||
| 72 | + placeholder: 'eg:support@example.com,support1@example.com', | ||
| 73 | + value: 'ccRecipients', | ||
| 74 | + }, | ||
| 75 | + { | ||
| 76 | + key: 'bccRecipients:密件抄送收件人,多个用英文逗号分隔', | ||
| 77 | + placeholder: 'eg:support@example.com,support1@example.com', | ||
| 78 | + value: 'bccRecipients', | ||
| 79 | + }, | ||
| 80 | + { | ||
| 81 | + key: 'body:内容', | ||
| 82 | + placeholder: '请输入内容', | ||
| 83 | + value: 'body', | ||
| 84 | + }, | ||
| 85 | + { | ||
| 86 | + key: 'customChooserTitle:自定义标题', | ||
| 87 | + placeholder: '请输入自定义标题', | ||
| 88 | + value: 'customChooserTitle', | ||
| 89 | + }, | ||
| 90 | + { | ||
| 91 | + key: 'isHTML:是否是html', | ||
| 92 | + placeholder: '请输入true或fasle', | ||
| 93 | + value: 'isHTML', | ||
| 94 | + }, | ||
| 95 | + ] | ||
| 96 | + const rnMailoptionsAttchments = [ | ||
| 97 | + { | ||
| 98 | + key: 'path:文件沙箱路径与uri二选一', | ||
| 99 | + placeholder: 'eg: /data/storage/el2/base/haps/entry/files/文件名', | ||
| 100 | + value: 'path', | ||
| 101 | + }, | ||
| 102 | + { | ||
| 103 | + key: 'uri:带前缀的文件沙箱路径与path二选一', | ||
| 104 | + placeholder: 'eg: file://文件沙箱路径', | ||
| 105 | + value: 'uri', | ||
| 106 | + }, | ||
| 107 | + { | ||
| 108 | + key: 'type:文件类型与mimeType二选一', | ||
| 109 | + placeholder: 'eg: jpg, png, doc, ppt, html, pdf, csv', | ||
| 110 | + value: 'type', | ||
| 111 | + }, | ||
| 112 | + { | ||
| 113 | + key: 'mimeType:自定义付件类型与type二选一', | ||
| 114 | + placeholder: '请输入自定义付件类型', | ||
| 115 | + value: 'mimeType', | ||
| 116 | + }, | ||
| 117 | + { | ||
| 118 | + key: 'name:附件文件名', | ||
| 119 | + placeholder: '请输入附件文件名', | ||
| 120 | + value: 'name', | ||
| 121 | + } | ||
| 122 | + ] | ||
| 123 | + | ||
| 124 | + | ||
| 125 | + const handleEmail = () => { | ||
| 126 | + Mailer.mail(mailOptions, (error, event) => { | ||
| 127 | + setError(error); | ||
| 128 | + setEvent(event); | ||
| 129 | + Alert.alert( | ||
| 130 | + error, | ||
| 131 | + event, | ||
| 132 | + [ | ||
| 133 | + { | ||
| 134 | + text: 'Ok', onPress: () => { | ||
| 135 | + setError(''); | ||
| 136 | + setEvent(''); | ||
| 137 | + console.log('OK: Email Error Response') | ||
| 138 | + } | ||
| 139 | + }, | ||
| 140 | + { | ||
| 141 | + text: 'Cancel', onPress: () => { | ||
| 142 | + setError(''); | ||
| 143 | + setEvent(''); | ||
| 144 | + console.log('CANCEL: Email Error Response') | ||
| 145 | + } | ||
| 146 | + } | ||
| 147 | + ], | ||
| 148 | + { cancelable: true } | ||
| 149 | + ) | ||
| 150 | + }); | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + return ( | ||
| 154 | + <Tester style={{ flex: 1 }}> | ||
| 155 | + <TestSuite name='mail'> | ||
| 156 | + <TestCase itShould='打开邮箱'> | ||
| 157 | + <View style={{ margin: 10 }}> | ||
| 158 | + <Text>参数:{JSON.stringify(mailOptions)}</Text> | ||
| 159 | + <Button title="打开邮箱" onPress={() => { | ||
| 160 | + handleEmail() | ||
| 161 | + }}></Button> | ||
| 162 | + </View> | ||
| 163 | + </TestCase> | ||
| 164 | + <ScrollView> | ||
| 165 | + { | ||
| 166 | + rnMailoptions.map(item => { | ||
| 167 | + return (<TestCase itShould={item.key} key={item.key}> | ||
| 168 | + <TextInput style={{ height: 30, fontSize: 12, }} placeholder={item.placeholder} | ||
| 169 | + onChange={({ nativeEvent: { eventCount, target, text } }) => { | ||
| 170 | + let value = text; | ||
| 171 | + if (item.value === 'recipients' | ||
| 172 | + || item.value === 'ccRecipients' | ||
| 173 | + || item.value === 'bccRecipients') { | ||
| 174 | + value = text.split(/[,,]/); | ||
| 175 | + } | ||
| 176 | + setMailOptions({ ...mailOptions, [item.value]: value }) | ||
| 177 | + }} ></TextInput> | ||
| 178 | + </TestCase>) | ||
| 179 | + }) | ||
| 180 | + } | ||
| 181 | + <TestSuite name='attachments:附件'> | ||
| 182 | + {rnMailoptionsAttchments.map(item => { | ||
| 183 | + return (<TestCase itShould={'attachments:' + item.key} key={'attachments:' + item.key}> | ||
| 184 | + <TextInput style={{ height: 30, fontSize: 12, }} | ||
| 185 | + placeholder={item.placeholder} | ||
| 186 | + onChange={({ nativeEvent: { eventCount, target, text } }) => { | ||
| 187 | + attachments = { | ||
| 188 | + ...attachments, | ||
| 189 | + [item.value]: text | ||
| 190 | + } | ||
| 191 | + setMailOptions({ ...mailOptions, 'attachments': [attachments] }) | ||
| 192 | + }} ></TextInput> | ||
| 193 | + </TestCase>) | ||
| 194 | + })} | ||
| 195 | + </TestSuite> | ||
| 196 | + <TestCase itShould='callback方法'> | ||
| 197 | + <View style={{ height: 350, margin: 10 }}> | ||
| 198 | + <Text style={{ marginBottom: 20 }}>callback结果error:{error}</Text> | ||
| 199 | + <Text>callback结果event:{event}</Text> | ||
| 200 | + </View> | ||
| 201 | + </TestCase> | ||
| 202 | + </ScrollView> | ||
| 203 | + </TestSuite> | ||
| 204 | + </Tester> | ||
| 205 | + ) | ||
| 206 | +} | ||
| @@ -0,0 +1,10 @@ | |||
| 1 | +{ | ||
| 2 | + "extends": "@react-native/typescript-config/tsconfig.json", | ||
| 3 | + "compilerOptions": { | ||
| 4 | + "jsx": "react-native", | ||
| 5 | + "paths": { | ||
| 6 | + "react-native": ["./node_modules/@react-native-oh/react-native-harmony"] | ||
| 7 | + } | ||
| 8 | + }, | ||
| 9 | + "exclude": ["harmony"] | ||
| 10 | +} | ||
| @@ -1,7 +1,7 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Use these variables when you tailor your ArkTS code. They must be of the const type. | 2 | * Use these variables when you tailor your ArkTS code. They must be of the const type. |
| 3 | */ | 3 | */ |
| 4 | -export const HAR_VERSION = '6.1.1-0.0.1'; | 4 | +export const HAR_VERSION = '6.3.1-beta.1'; |
| 5 | export const BUILD_MODE_NAME = 'debug'; | 5 | export const BUILD_MODE_NAME = 'debug'; |
| 6 | export const DEBUG = true; | 6 | export const DEBUG = true; |
| 7 | export const TARGET_NAME = 'default'; | 7 | export const TARGET_NAME = 'default'; |
| @@ -3,5 +3,6 @@ | |||
| 3 | * Use of this source code is governed by a MIT license that can be | 3 | * Use of this source code is governed by a MIT license that can be |
| 4 | * found in the LICENSE file. | 4 | * found in the LICENSE file. |
| 5 | */ | 5 | */ |
| 6 | - | 6 | +import { RNMailPackage } from './src/main/ets/RNMailPackge'; |
| 7 | +export default RNMailPackage; | ||
| 7 | export * from './ts'; | 8 | export * from './ts'; |
| @@ -1,18 +0,0 @@ | |||
| 1 | -{ | ||
| 2 | - "meta": { | ||
| 3 | - "stableOrder": true | ||
| 4 | - }, | ||
| 5 | - "lockfileVersion": 3, | ||
| 6 | - "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", | ||
| 7 | - "specifiers": { | ||
| 8 | - "@rnoh/react-native-openharmony@../react_native_openharmony": "@rnoh/react-native-openharmony@../react_native_openharmony" | ||
| 9 | - }, | ||
| 10 | - "packages": { | ||
| 11 | - "@rnoh/react-native-openharmony@../react_native_openharmony": { | ||
| 12 | - "name": "@rnoh/react-native-openharmony", | ||
| 13 | - "version": "0.72.27", | ||
| 14 | - "resolved": "../react_native_openharmony", | ||
| 15 | - "registryType": "local" | ||
| 16 | - } | ||
| 17 | - } | ||
| 18 | -} | ||
| @@ -1,10 +1,10 @@ | |||
| 1 | { | 1 | { |
| 2 | - "name": "@react-native-oh-tpl/react-native-mail", | 2 | + "name": "@react-native-ohos/react-native-mail", |
| 3 | - "version": "6.1.1-0.0.1", | 3 | + "version": "6.3.1-beta.1", |
| 4 | "description": "", | 4 | "description": "", |
| 5 | "main": "index.ets", | 5 | "main": "index.ets", |
| 6 | "author": "", | 6 | "author": "", |
| 7 | - "license": "Apache-2.0", | 7 | + "license": "MIT", |
| 8 | "dependencies": { | 8 | "dependencies": { |
| 9 | "@rnoh/react-native-openharmony": "file:../react_native_openharmony" | 9 | "@rnoh/react-native-openharmony": "file:../react_native_openharmony" |
| 10 | }, | 10 | }, |
| @@ -0,0 +1,9 @@ | |||
| 1 | +cmake_minimum_required(VERSION 3.13) | ||
| 2 | +set(CMAKE_VERBOSE_MAKEFILE on) | ||
| 3 | + | ||
| 4 | +set(rnoh_mail_generated_dir "${CMAKE_CURRENT_SOURCE_DIR}/generated") | ||
| 5 | +file(GLOB_RECURSE rnoh_mail_generated_SRC "${rnoh_mail_generated_dir}/**/*.cpp") | ||
| 6 | +file(GLOB rnoh_mail_SRC CONFIGURE_DEPENDS *.cpp) | ||
| 7 | +add_library(rnoh_mail SHARED ${rnoh_mail_SRC} ${rnoh_mail_generated_SRC}) | ||
| 8 | +target_include_directories(rnoh_mail PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${rnoh_mail_generated_dir} ${CMAKE_CURRENT_SOURCE_DIR}/generated/RNOH/generated) | ||
| 9 | +target_link_libraries(rnoh_mail PUBLIC rnoh) | ||
| @@ -0,0 +1,19 @@ | |||
| 1 | +// Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved | ||
| 2 | +// Use of this source code is governed by a MIT license that can be | ||
| 3 | +// found in the LICENSE file. | ||
| 4 | + | ||
| 5 | +#ifndef MAILPACKAGE_H | ||
| 6 | +#define MAILPACKAGE_H | ||
| 7 | + | ||
| 8 | + | ||
| 9 | +#include "generated/RNOH/generated/BaseReactNativeMailPackage.h" | ||
| 10 | +#pragma once | ||
| 11 | + | ||
| 12 | + | ||
| 13 | +namespace rnoh { | ||
| 14 | +class MailPackage : public BaseReactNativeMailPackage { | ||
| 15 | + using Super = BaseReactNativeMailPackage; | ||
| 16 | + using Super::Super; | ||
| 17 | +}; | ||
| 18 | +} // namespace rnoh | ||
| 19 | +#endif //MAILPACKAGE_H | ||
| @@ -0,0 +1,72 @@ | |||
| 1 | +/** | ||
| 2 | + * This code was generated by "react-native codegen-lib-harmony" | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +#pragma once | ||
| 6 | + | ||
| 7 | +#include "RNOH/Package.h" | ||
| 8 | +#include "RNOH/ArkTSTurboModule.h" | ||
| 9 | +#include "RNOH/generated/turbo_modules/RNMail.h" | ||
| 10 | + | ||
| 11 | +namespace rnoh { | ||
| 12 | + | ||
| 13 | +class BaseReactNativeMailPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate { | ||
| 14 | + public: | ||
| 15 | + SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override { | ||
| 16 | + if (name == "RNMail") { | ||
| 17 | + return std::make_shared<RNMail>(ctx, name); | ||
| 18 | + } | ||
| 19 | + return nullptr; | ||
| 20 | + }; | ||
| 21 | +}; | ||
| 22 | + | ||
| 23 | +class BaseReactNativeMailPackageEventEmitRequestHandler : public EventEmitRequestHandler { | ||
| 24 | + public: | ||
| 25 | + void handleEvent(Context const &ctx) override { | ||
| 26 | + auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag); | ||
| 27 | + auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag); | ||
| 28 | + | ||
| 29 | + if (eventEmitter == nullptr) { | ||
| 30 | + return; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + std::vector<std::string> supportedComponentNames = { | ||
| 34 | + }; | ||
| 35 | + | ||
| 36 | + std::vector<std::string> supportedEventNames = { | ||
| 37 | + }; | ||
| 38 | + | ||
| 39 | + if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() && | ||
| 40 | + std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) { | ||
| 41 | + eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload)); | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | +}; | ||
| 45 | + | ||
| 46 | + | ||
| 47 | +class BaseReactNativeMailPackage : public Package { | ||
| 48 | + public: | ||
| 49 | + BaseReactNativeMailPackage(Package::Context ctx) : Package(ctx){}; | ||
| 50 | + | ||
| 51 | + std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override { | ||
| 52 | + return std::make_unique<BaseReactNativeMailPackageTurboModuleFactoryDelegate>(); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override { | ||
| 56 | + return { | ||
| 57 | + }; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + ComponentJSIBinderByString createComponentJSIBinderByName() override { | ||
| 61 | + return { | ||
| 62 | + }; | ||
| 63 | + }; | ||
| 64 | + | ||
| 65 | + EventEmitRequestHandlers createEventEmitRequestHandlers() override { | ||
| 66 | + return { | ||
| 67 | + std::make_shared<BaseReactNativeMailPackageEventEmitRequestHandler>(), | ||
| 68 | + }; | ||
| 69 | + } | ||
| 70 | +}; | ||
| 71 | + | ||
| 72 | +} // namespace rnoh | ||
| @@ -0,0 +1,16 @@ | |||
| 1 | +/** | ||
| 2 | + * This code was generated by "react-native codegen-lib-harmony" | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +#include "RNMail.h" | ||
| 6 | + | ||
| 7 | +namespace rnoh { | ||
| 8 | +using namespace facebook; | ||
| 9 | + | ||
| 10 | +RNMail::RNMail(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) { | ||
| 11 | + methodMap_ = { | ||
| 12 | + ARK_METHOD_METADATA(mail, 2), | ||
| 13 | + }; | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +} // namespace rnoh | ||
| @@ -0,0 +1,16 @@ | |||
| 1 | +/** | ||
| 2 | + * This code was generated by "react-native codegen-lib-harmony" | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +#pragma once | ||
| 6 | + | ||
| 7 | +#include "RNOH/ArkTSTurboModule.h" | ||
| 8 | + | ||
| 9 | +namespace rnoh { | ||
| 10 | + | ||
| 11 | +class JSI_EXPORT RNMail : public ArkTSTurboModule { | ||
| 12 | + public: | ||
| 13 | + RNMail(const ArkTSTurboModule::Context ctx, const std::string name); | ||
| 14 | +}; | ||
| 15 | + | ||
| 16 | +} // namespace rnoh | ||
| @@ -0,0 +1,24 @@ | |||
| 1 | + | ||
| 2 | +/** | ||
| 3 | + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). | ||
| 4 | + * | ||
| 5 | + * Do not edit this file as changes may cause incorrect behavior and will be lost | ||
| 6 | + * once the code is regenerated. | ||
| 7 | + * | ||
| 8 | + * @generated by codegen project: GenerateComponentDescriptorH.js | ||
| 9 | + */ | ||
| 10 | + | ||
| 11 | +#pragma once | ||
| 12 | + | ||
| 13 | +#include "ShadowNodes.h" | ||
| 14 | +#include <react/renderer/core/ConcreteComponentDescriptor.h> | ||
| 15 | +#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h> | ||
| 16 | + | ||
| 17 | +namespace facebook::react { | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | +void react_native_mail_registerComponentDescriptorsFromCodegen( | ||
| 22 | + std::shared_ptr<const ComponentDescriptorProviderRegistry> registry); | ||
| 23 | + | ||
| 24 | +} // namespace facebook::react | ||
Aharmony/mail/src/main/cpp/generated/react/renderer/components/react_native_mail/EventEmitters.cpp+16-0
| @@ -0,0 +1,16 @@ | |||
| 1 | + | ||
| 2 | +/** | ||
| 3 | + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). | ||
| 4 | + * | ||
| 5 | + * Do not edit this file as changes may cause incorrect behavior and will be lost | ||
| 6 | + * once the code is regenerated. | ||
| 7 | + * | ||
| 8 | + * @generated by codegen project: GenerateEventEmitterCpp.js | ||
| 9 | + */ | ||
| 10 | + | ||
| 11 | +#include "EventEmitters.h" | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +namespace facebook::react { | ||
| 15 | + | ||
| 16 | +} // namespace facebook::react | ||
Aharmony/mail/src/main/cpp/generated/react/renderer/components/react_native_mail/EventEmitters.h+17-0
| @@ -0,0 +1,17 @@ | |||
| 1 | + | ||
| 2 | +/** | ||
| 3 | + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). | ||
| 4 | + * | ||
| 5 | + * Do not edit this file as changes may cause incorrect behavior and will be lost | ||
| 6 | + * once the code is regenerated. | ||
| 7 | + * | ||
| 8 | + * @generated by codegen project: GenerateEventEmitterH.js | ||
| 9 | + */ | ||
| 10 | +#pragma once | ||
| 11 | + | ||
| 12 | +#include <react/renderer/components/view/ViewEventEmitter.h> | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +namespace facebook::react { | ||
| 16 | + | ||
| 17 | +} // namespace facebook::react | ||
Aharmony/mail/src/main/cpp/generated/react/renderer/components/react_native_mail/Props.cpp+19-0File content is under review, please try again later
Aharmony/mail/src/main/cpp/generated/react/renderer/components/react_native_mail/Props.h+18-0File content is under review, please try again later
Aharmony/mail/src/main/cpp/generated/react/renderer/components/react_native_mail/ShadowNodes.cpp+17-0
| @@ -0,0 +1,17 @@ | |||
| 1 | + | ||
| 2 | +/** | ||
| 3 | + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). | ||
| 4 | + * | ||
| 5 | + * Do not edit this file as changes may cause incorrect behavior and will be lost | ||
| 6 | + * once the code is regenerated. | ||
| 7 | + * | ||
| 8 | + * @generated by codegen project: GenerateShadowNodeCpp.js | ||
| 9 | + */ | ||
| 10 | + | ||
| 11 | +#include "ShadowNodes.h" | ||
| 12 | + | ||
| 13 | +namespace facebook::react { | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + | ||
| 17 | +} // namespace facebook::react | ||
| @@ -0,0 +1,23 @@ | |||
| 1 | + | ||
| 2 | +/** | ||
| 3 | + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). | ||
| 4 | + * | ||
| 5 | + * Do not edit this file as changes may cause incorrect behavior and will be lost | ||
| 6 | + * once the code is regenerated. | ||
| 7 | + * | ||
| 8 | + * @generated by codegen project: GenerateShadowNodeH.js | ||
| 9 | + */ | ||
| 10 | + | ||
| 11 | +#pragma once | ||
| 12 | + | ||
| 13 | +#include "EventEmitters.h" | ||
| 14 | +#include "Props.h" | ||
| 15 | +#include "States.h" | ||
| 16 | +#include <react/renderer/components/view/ConcreteViewShadowNode.h> | ||
| 17 | +#include <jsi/jsi.h> | ||
| 18 | + | ||
| 19 | +namespace facebook::react { | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +} // namespace facebook::react | ||
| @@ -0,0 +1,16 @@ | |||
| 1 | + | ||
| 2 | +/** | ||
| 3 | + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). | ||
| 4 | + * | ||
| 5 | + * Do not edit this file as changes may cause incorrect behavior and will be lost | ||
| 6 | + * once the code is regenerated. | ||
| 7 | + * | ||
| 8 | + * @generated by codegen project: GenerateStateCpp.js | ||
| 9 | + */ | ||
| 10 | +#include "States.h" | ||
| 11 | + | ||
| 12 | +namespace facebook::react { | ||
| 13 | + | ||
| 14 | + | ||
| 15 | + | ||
| 16 | +} // namespace facebook::react | ||
| @@ -0,0 +1,19 @@ | |||
| 1 | +/** | ||
| 2 | + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). | ||
| 3 | + * | ||
| 4 | + * Do not edit this file as changes may cause incorrect behavior and will be lost | ||
| 5 | + * once the code is regenerated. | ||
| 6 | + * | ||
| 7 | + * @generated by codegen project: GenerateStateH.js | ||
| 8 | + */ | ||
| 9 | +#pragma once | ||
| 10 | + | ||
| 11 | +#ifdef ANDROID | ||
| 12 | +#include <folly/dynamic.h> | ||
| 13 | +#endif | ||
| 14 | + | ||
| 15 | +namespace facebook::react { | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | +} // namespace facebook::react | ||
| @@ -22,10 +22,11 @@ | |||
| 22 | * SOFTWARE. | 22 | * SOFTWARE. |
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | -import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts'; | 25 | +import { TurboModulesFactory } from '@rnoh/react-native-openharmony/ts'; |
| 26 | import type { TurboModule, TurboModuleContext, } from '@rnoh/react-native-openharmony/ts'; | 26 | import type { TurboModule, TurboModuleContext, } from '@rnoh/react-native-openharmony/ts'; |
| 27 | -import { TM } from "@rnoh/react-native-openharmony/generated/ts" | 27 | +import { TM } from "./generated/ts" |
| 28 | import { RNMailTurboModule } from './RNMailTurboModule'; | 28 | import { RNMailTurboModule } from './RNMailTurboModule'; |
| 29 | +import { RNOHPackage } from '@rnoh/react-native-openharmony'; | ||
| 29 | 30 | ||
| 30 | class RNMailTurboModulesFactory extends TurboModulesFactory { | 31 | class RNMailTurboModulesFactory extends TurboModulesFactory { |
| 31 | createTurboModule(name: string): TurboModule | null { | 32 | createTurboModule(name: string): TurboModule | null { |
| @@ -40,7 +41,7 @@ class RNMailTurboModulesFactory extends TurboModulesFactory { | |||
| 40 | } | 41 | } |
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | -export class RNMailPackage extends RNPackage { | 44 | +export class RNMailPackage extends RNOHPackage { |
| 44 | createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory { | 45 | createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory { |
| 45 | return new RNMailTurboModulesFactory(ctx); | 46 | return new RNMailTurboModulesFactory(ctx); |
| 46 | } | 47 | } |
| @@ -25,7 +25,7 @@ import { Want } from '@kit.AbilityKit'; | |||
| 25 | import { BusinessError } from '@kit.BasicServicesKit'; | 25 | import { BusinessError } from '@kit.BasicServicesKit'; |
| 26 | import fileUri from '@ohos.file.fileuri'; | 26 | import fileUri from '@ohos.file.fileuri'; |
| 27 | import { TurboModule } from '@rnoh/react-native-openharmony/ts'; | 27 | import { TurboModule } from '@rnoh/react-native-openharmony/ts'; |
| 28 | -import { TM } from "@rnoh/react-native-openharmony/generated/ts"; | 28 | +import { TM } from "./generated/ts"; |
| 29 | import Logger from './Logger'; | 29 | import Logger from './Logger'; |
| 30 | import { mainOptions } from './types'; | 30 | import { mainOptions } from './types'; |
| 31 | import { supportedMimeTypes } from './constant'; | 31 | import { supportedMimeTypes } from './constant'; |
| @@ -0,0 +1,5 @@ | |||
| 1 | + | ||
| 2 | +/** | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +export {} | ||
| @@ -0,0 +1,5 @@ | |||
| 1 | +/** | ||
| 2 | + * This code was generated by "react-native codegen-lib-harmony" | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +export * from "./ts" | ||
| @@ -0,0 +1,6 @@ | |||
| 1 | +/** | ||
| 2 | + * This code was generated by "react-native codegen-lib-harmony" | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +export * as RNC from "./components/ts" | ||
| 6 | +export * as TM from "./turboModules/ts" | ||
| @@ -0,0 +1,16 @@ | |||
| 1 | +/** | ||
| 2 | + * This code was generated by "react-native codegen-lib-harmony" | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +import { Tag } from "@rnoh/react-native-openharmony/ts" | ||
| 6 | + | ||
| 7 | +export namespace RNMail { | ||
| 8 | + export const NAME = 'RNMail' as const | ||
| 9 | + | ||
| 10 | + export type options = {subject?: string, recipients?: string[], ccRecipients?: string[], bccRecipients?: string[], body?: string, customChooserTitle?: string, isHTML?: boolean, attachments?: {path?: string, uri?: string, type?: string, mimeType?: string, name?: string}[]} | ||
| 11 | + | ||
| 12 | + export interface Spec { | ||
| 13 | + mail(option: options, callback: (error: string, event: string) => void): void; | ||
| 14 | + | ||
| 15 | + } | ||
| 16 | +} | ||
| @@ -0,0 +1,5 @@ | |||
| 1 | +/** | ||
| 2 | + * This code was generated by "react-native codegen-lib-harmony" | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +export * from "./RNMail" | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | import { NativeModules, Platform } from 'react-native'; | 1 | import { NativeModules, Platform } from 'react-native'; |
| 2 | -import NativeRNMailHarmony from './src/NativeRNMail.harmonys'; | 2 | +import NativeRNMailHarmony from './src/NativeRNMail.harmonys' |
| 3 | 3 | ||
| 4 | -export default Platform.OS === 'harmony' ? NativeRNMailHarmony : NativeModules.RNMail; | 4 | +export default Platform.OS == 'harmony' ? NativeRNMailHarmony : NativeModules.RNMail; |
| 5 | 5 | ||
| @@ -1,16 +1,20 @@ | |||
| 1 | { | 1 | { |
| 2 | "name": "@react-native-ohos/react-native-mail", | 2 | "name": "@react-native-ohos/react-native-mail", |
| 3 | - "version": "6.1.1-0.0.1", | 3 | + "version": "6.3.1-beta.1", |
| 4 | "description": "A wrapper on top of MFMailComposeViewController from iOS and Mail Intent on android and e-mail on harmony", | 4 | "description": "A wrapper on top of MFMailComposeViewController from iOS and Mail Intent on android and e-mail on harmony", |
| 5 | + "homepage": "https://gitcode.com/CPF-RN/rntpc_react-native-mail#readme", | ||
| 5 | "author": { | 6 | "author": { |
| 6 | "name": "Chirag Jain", | 7 | "name": "Chirag Jain", |
| 7 | "email": "jain_chirag04@yahoo.com", | 8 | "email": "jain_chirag04@yahoo.com", |
| 8 | "url": "http://chiragjain.tumblr.com" | 9 | "url": "http://chiragjain.tumblr.com" |
| 9 | }, | 10 | }, |
| 10 | "license": "MIT", | 11 | "license": "MIT", |
| 12 | + "scripts": { | ||
| 13 | + "codegen-lib": "react-native codegen-lib-harmony --no-safety-check --npm-package-name react-native-mail --cpp-output-path ./harmony/mail/src/main/cpp/generated --ets-output-path ./harmony/mail/src/main/ets/generated --turbo-modules-spec-paths ./src/NativeRNMail.harmonys.ts" | ||
| 14 | + }, | ||
| 11 | "repository": { | 15 | "repository": { |
| 12 | "type": "git", | 16 | "type": "git", |
| 13 | - "url": "https://gitcode.com/OpenHarmony-RN/rntpc_react-native-mail.git" | 17 | + "url": "https://gitcode.com/CPF-RN/rntpc_react-native-mail.git" |
| 14 | }, | 18 | }, |
| 15 | "publishConfig": { | 19 | "publishConfig": { |
| 16 | "registry": "https://registry.npmjs.org/", | 20 | "registry": "https://registry.npmjs.org/", |
| @@ -20,16 +24,21 @@ | |||
| 20 | "harmony", | 24 | "harmony", |
| 21 | "src", | 25 | "src", |
| 22 | "index.js", | 26 | "index.js", |
| 27 | + "!build", | ||
| 28 | + "README.md", | ||
| 29 | + "CHANGELOG.md", | ||
| 23 | "index.d.ts" | 30 | "index.d.ts" |
| 24 | ], | 31 | ], |
| 32 | + | ||
| 25 | "harmony": { | 33 | "harmony": { |
| 26 | - "alias": "react-native-mail", | 34 | + "alias": "react-native-mail", |
| 27 | - "codegenConfig": { | 35 | + "autolinking": { |
| 28 | - "specPaths": [ | 36 | + "etsPackageClassName":"RNMailPackage", |
| 29 | - "./src" | 37 | + "cppPackageClassName":"MailPackage", |
| 30 | - ] | 38 | + "cmakeLibraryTargetName": "rnoh_mail", |
| 31 | - } | 39 | + "ohPackageName": "@react-native-ohos/react-native-mail" |
| 32 | - }, | 40 | + } |
| 41 | + }, | ||
| 33 | "keywords": [ | 42 | "keywords": [ |
| 34 | "react", | 43 | "react", |
| 35 | "react-native", | 44 | "react-native", |
| @@ -41,5 +50,8 @@ | |||
| 41 | ], | 50 | ], |
| 42 | "dependencies": { | 51 | "dependencies": { |
| 43 | "react-native-mail": "6.1.1" | 52 | "react-native-mail": "6.1.1" |
| 53 | + }, | ||
| 54 | + "devDependencies": { | ||
| 55 | + "react-native-harmony-cli": "npm:@react-native-oh/react-native-harmony-cli@^0.0.27" | ||
| 44 | } | 56 | } |
| 45 | -} | 57 | +} |


【AI-Review】【严重】【业务功能】【功能实现错误】appKey 与 JS 侧 AppRegistry 注册名不一致导致 RN 应用无法渲染
● 问题:example/harmony/entry/src/main/ets/pages/Index.ets 第 94 行 appKey: 'react-native-mail-example' 与 JS 侧注册的应用名不一致。example/app.json 第 2 行 "name": "app_name" 定义了应用名,example/index.js 第 8-11 行 import {name as appName} from './app.json'; AppRegistry.registerComponent(appName, () => App); 使用该名称注册 RN 根组件。RNOH 的 RNApp 组件通过 appKey 在 JS bundle 中查找已注册的组件,两者必须完全匹配。
● 影响:严重。启动示例 App 时,原生侧以 appKey: 'react-native-mail-example' 查找 JS 组件,但 JS bundle 中只注册了 'app_name',导致 RN 应用无法渲染。用户只能看到 Index.ets 第 109 行的占位 Text('1233333333122 1212323'),无法验证 react-native-mail 的鸿蒙化迁移效果,示例工程失去回归价值。
● 建议:将第 94 行 appKey 改为 'app_name',与 example/app.json 中的 name 字段保持一致;或将 example/app.json 的 name 改为 'react-native-mail-example' 并同步修改 example/index.js 中的 appName 引用。