Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules
*.tgz
.vscode
/**/.vscode
bundle.harmony.js
Expand Down
14,014 changes: 12,074 additions & 1,940 deletions react-native-harmony-screens/package-lock.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions react-native-harmony-screens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@
"peerDependencies": {
"react": "*",
"react-native": "*",
"react-native-harmony": "npm:@rnoh/react-native-harmony@>=0.72.41",
"react-native-harmony": "npm:@react-native-oh/react-native-harmony@^0.72.48",
"react-native-screens": "3.34.0"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@rnoh/react-native-harmony": "^0.75.2",
"react-native-harmony": "npm:@rnoh/react-native-harmony@0.75.2",
"react-native-harmony": "npm:@react-native-oh/react-native-harmony@^0.72.48",
"@babel/core": "^7.20.0",
"@babel/eslint-parser": "7.22.15",
"@react-native-community/cli": "^11.3.6",
Expand Down
4 changes: 2 additions & 2 deletions tester/.npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@rnoh:registry=https://gl.swmansion.com/api/v4/projects/458/packages/npm/
//gl.swmansion.com/api/v4/projects/458/packages/npm/:_authToken="${RNOH_NPM_TOKEN}"
# @rnoh:registry=https://gl.swmansion.com/api/v4/projects/458/packages/npm/
# //gl.swmansion.com/api/v4/projects/458/packages/npm/:_authToken="${RNOH_NPM_TOKEN}"
4 changes: 3 additions & 1 deletion tester/apps/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function App() {

// import {Button, Text, View} from 'react-native';
// import {NavigationContainer} from '@react-navigation/native';
// import {createNativeStackNavigator} from '@react-navigation/native-stack';
// import {createNativeStackNavigator} from '@react-navigation/stack';

// const Stack = createNativeStackNavigator();

Expand Down Expand Up @@ -47,7 +47,9 @@ export default function App() {
// );
// }


// export default function App() {
// // return <DetailsScreen />
// return (
// <NavigationContainer>
// <Stack.Navigator initialRouteName="Home">
Expand Down
32 changes: 16 additions & 16 deletions tester/harmony/entry/hvigorfile.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { hapTasks } from '@ohos/hvigor-ohos-plugin';
import { createRNOHHvigorPlugin } from '@rnoh/hvigor-plugin';

export default {
system: hapTasks,
plugins: [
createRNOHHvigorPlugin({
codegen: {
rnohModulePath: './oh_modules/@rnoh/react-native-openharmony',
},
autolinking: {
excludeNpmPackages: [],
},
}),
],
};
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
export { hapTasks } from '@ohos/hvigor-ohos-plugin';
32 changes: 30 additions & 2 deletions tester/harmony/entry/oh-package-lock.json5

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion tester/harmony/entry/oh-package.json5
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"description": "example description",
"version": "1.0.0",
"dependencies": {
"@rnoh/react-native-openharmony-screens": "file:../screens"
"@react-native-oh-tpl/react-native-openharmony-screens": "file:../screens",
"@react-native-oh-tpl/react-native-gesture-handler": "file:../../node_modules/@react-native-oh-tpl/react-native-gesture-handler/harmony/gesture_handler.har",
"@react-native-oh-tpl/react-native-safe-area-context": "file:../../node_modules/@react-native-oh-tpl/react-native-safe-area-context/harmony/safe_area.har"

}
}
13 changes: 10 additions & 3 deletions tester/harmony/entry/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ set(LOG_VERBOSITY_LEVEL 1)
set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
set(WITH_HITRACE_SYSTRACE ON)
set(WITH_HITRACE_REACT_MARKER ON)
set(OH_MODULES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../oh_modules") # required by 'autolink_libraries'
#set(OH_MODULES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../oh_modules") # required by 'autolink_libraries'
set(OH_MODULES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")

add_subdirectory("${RNOH_CPP_DIR}" ./rn)

include("${CMAKE_CURRENT_SOURCE_DIR}/autolinking.cmake")
#include("${CMAKE_CURRENT_SOURCE_DIR}/autolinking.cmake")

# RNOH_BEGIN: manual_package_linking_1
#add_subdirectory("${OH_MODULES_DIR}/@rnoh/react-native-openharmony-screens/src/main/cpp" ./rnoh_screens) # <=
add_subdirectory("${OH_MODULES_DIR}/@react-native-oh-tpl/react-native-openharmony-screens/src/main/cpp" ./rnoh_screens)
add_subdirectory("${OH_MODULES_DIR}/@react-native-oh-tpl/react-native-gesture-handler/src/main/cpp" ./gesture-handler)
add_subdirectory("${OH_MODULES_DIR}/@react-native-oh-tpl/react-native-safe-area-context/src/main/cpp" ./safe-area)
# RNOH_END: manual_package_linking_1

file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp") # this line is needed by codegen v1
Expand All @@ -26,8 +30,11 @@ add_library(rnoh_app SHARED
)
target_link_libraries(rnoh_app PUBLIC rnoh)

autolink_libraries(rnoh_app)
#autolink_libraries(rnoh_app)

# RNOH_BEGIN: manual_package_linking_2
#target_link_libraries(rnoh_app PUBLIC rnoh_screens)
target_link_libraries(rnoh_app PUBLIC rnoh_screens)
target_link_libraries(rnoh_app PUBLIC rnoh_gesture_handler)
target_link_libraries(rnoh_app PUBLIC rnoh_safe_area)
# RNOH_END: manual_package_linking_2
26 changes: 20 additions & 6 deletions tester/harmony/entry/src/main/cpp/PackageProvider.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
#include "RNOH/PackageProvider.h"
#include "generated/RNOHGeneratedPackage.h"
// #include "ScreensPackage.h"
#include "RNOHPackagesFactory.h"
#include "ScreensPackage.h"
#include "GestureHandlerPackage.h"
#include "SafeAreaViewPackage.h"
// #include "RNOHPackagesFactory.h"

// using namespace rnoh;
//
// std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) {
// auto packages = createRNOHPackages(ctx); // <= autolinking
// packages.push_back(std::make_shared<RNOHGeneratedPackage>(ctx));
// packages.push_back(std::make_shared<ScreensPackage>(ctx));
// return packages;
// }
using namespace rnoh;

std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) {
auto packages = createRNOHPackages(ctx); // <= autolinking
packages.push_back(std::make_shared<RNOHGeneratedPackage>(ctx));
// packages.push_back(std::make_shared<ScreensPackage>(ctx));
return packages;
return {
std::make_shared<RNOHGeneratedPackage>(ctx), // generated by codegen v1
std::make_shared<GestureHandlerPackage>(ctx),
std::make_shared<SafeAreaViewPackage>(ctx),
// std::make_shared<CheckboxPackage>(ctx),
// std::make_shared<GestureHandlerPackage>(ctx),
// std::make_shared<SafeAreaViewPackage>(ctx),
};
}
8 changes: 4 additions & 4 deletions tester/harmony/entry/src/main/cpp/RNOHPackagesFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
// clang-format off
#pragma once
#include "RNOH/Package.h"
#include "RnohReactNativeHarmonyGestureHandlerPackage.h"
#include "RnohReactNativeHarmonySafeAreaContextPackage.h"
// #include "RnohReactNativeHarmonyGestureHandlerPackage.h"
// #include "RnohReactNativeHarmonySafeAreaContextPackage.h"
#include "RnohReactNativeHarmonyScreensPackage.h"

std::vector<rnoh::Package::Shared> createRNOHPackages(const rnoh::Package::Context &ctx) {
return {
std::make_shared<rnoh::RnohReactNativeHarmonyGestureHandlerPackage>(ctx),
std::make_shared<rnoh::RnohReactNativeHarmonySafeAreaContextPackage>(ctx),
// std::make_shared<rnoh::RnohReactNativeHarmonyGestureHandlerPackage>(ctx),
// std::make_shared<rnoh::RnohReactNativeHarmonySafeAreaContextPackage>(ctx),
std::make_shared<rnoh::RnohReactNativeHarmonyScreensPackage>(ctx),
};
}
10 changes: 7 additions & 3 deletions tester/harmony/entry/src/main/ets/PackageProvider.ets
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import type { RNPackageContext, RNOHPackage } from '@rnoh/react-native-openharmony';
import type { RNPackageContext, RNPackage } from '@rnoh/react-native-openharmony';
import { createRNOHPackages as createRNOHPackagesAutolinking } from "./RNOHPackagesFactory"
import RNOHScreensPackage from "@rnoh/react-native-openharmony-screens"
import RNOHScreensPackage from "@react-native-oh-tpl/react-native-openharmony-screens"
import { GestureHandlerPackage } from '@react-native-oh-tpl/react-native-gesture-handler/ts';
import {SafeAreaViewPackage} from '@react-native-oh-tpl/react-native-safe-area-context/ts';

export function getRNOHPackages(ctx: RNPackageContext): RNOHPackage[] {
export function getRNOHPackages(ctx: RNPackageContext): RNPackage[] {
return [
...createRNOHPackagesAutolinking(ctx),
new RNOHScreensPackage(ctx), // comment this line out when testing SamplePackage autolinking
new GestureHandlerPackage(ctx),
new SafeAreaViewPackage(ctx),
]
}
16 changes: 8 additions & 8 deletions tester/harmony/entry/src/main/ets/RNOHPackagesFactory.ets
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* This file was generated by RNOH autolinking.
* DO NOT modify it manually, your changes WILL be overwritten.
*/
import type { RNPackageContext, RNOHPackage } from '@rnoh/react-native-openharmony';
import RnohReactNativeHarmonyGestureHandlerPackage from '@rnoh/react-native-openharmony-gesture-handler';
import RnohReactNativeHarmonySafeAreaContextPackage from '@rnoh/react-native-openharmony-safe-area-context';
import RnohReactNativeHarmonyScreensPackage from '@rnoh/react-native-openharmony-screens';
import type { RNPackageContext, RNPackage } from '@rnoh/react-native-openharmony';
// import RnohReactNativeHarmonyGestureHandlerPackage from '@rnoh/react-native-openharmony-gesture-handler';
// import {SafeAreaViewPackage} from '@rnoh/react-native-openharmony-safe-area-context';
// import RnohReactNativeHarmonyScreensPackage from '@react-native-oh-tpl/react-native-openharmony-screens';

export function createRNOHPackages(ctx: RNPackageContext): RNOHPackage[] {
export function createRNOHPackages(ctx: RNPackageContext): RNPackage[] {
return [
new RnohReactNativeHarmonyGestureHandlerPackage(ctx),
new RnohReactNativeHarmonySafeAreaContextPackage(ctx),
new RnohReactNativeHarmonyScreensPackage(ctx),
// new RnohReactNativeHarmonyGestureHandlerPackage(ctx),
// new SafeAreaViewPackage(ctx),
// new RnohReactNativeHarmonyScreensPackage(ctx),
];
}
43 changes: 41 additions & 2 deletions tester/harmony/entry/src/main/ets/pages/Index.ets
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import {
AnyJSBundleProvider,
FileJSBundleProvider,
ComponentBuilderContext,
ResourceJSBundleProvider,
RNApp,
RNOHErrorDialog,
MetroJSBundleProvider,
Expand All @@ -7,8 +11,20 @@ import {
RNOHLogger
} from "@rnoh/react-native-openharmony";
import { getRNOHPackages } from '../PackageProvider'
import {componentBuilder} from '@react-native-oh-tpl/react-native-openharmony-screens'


@Builder
export function buildCustomRNComponent(ctx: ComponentBuilderContext) {
// There seems to be a problem with the placement of ArkTS components in mixed mode. Nested Stack temporarily avoided.
Stack() {
componentBuilder(ctx)
}
.position({ x: 0, y: 0 })

}
const wrappedCustomRNComponentBuilder = wrapBuilder(buildCustomRNComponent)

@Entry
@Component
struct Index {
Expand All @@ -33,19 +49,42 @@ struct Index {

build() {
Column() {
Text("1233333333122 1212323")
if (this.rnohCoreContext && this.shouldShow) {
if (this.rnohCoreContext?.isDebugModeEnabled) {
RNOHErrorDialog({ ctx: this.rnohCoreContext })
}
Text("222 1214442323")
RNApp({
rnInstanceConfig: {
name: "app_name",
createRNPackages: getRNOHPackages,
name: "app_name",
enableNDKTextMeasuring: true,
enableBackgroundExecutor: false,
enableCAPIArchitecture: true,
arkTsComponentNames: ["RNSScreen", "RNSFullWindowOverlay", "RNSModalScreen", "RNSScreenContainer", "RNSScreenNavigationContainer", "RNSScreenStack", "RNSScreenStackHeaderSubview", "RNSSearchBar", "RNSScreenStackHeaderConfig"],
},
initialProps: { "foo": "bar" } as Record<string, string>,
appKey: "app_name",
wrappedCustomRNComponentBuilder: wrappedCustomRNComponentBuilder,
onSetUp: (rnInstance) => {
rnInstance.enableFeatureFlag("ENABLE_RN_INSTANCE_CLEAN_UP")
},
// jsBundleProvider: new TraceJSBundleProviderDecorator(
// new MetroJSBundleProvider(),
// this.rnohCoreContext.logger),

jsBundleProvider: new TraceJSBundleProviderDecorator(
new MetroJSBundleProvider(),
new AnyJSBundleProvider([
new MetroJSBundleProvider(),
// NOTE: to load the bundle from file, place it in
// `/data/app/el2/100/base/com.rnoh.tester/files/bundle.harmony.js`
// on your device. The path mismatch is due to app sandboxing on HarmonyOS
new FileJSBundleProvider('/data/storage/el2/base/files/bundle.harmony.js'),
// new FileJSBundleProvider(context.filesDir + '/' + this.bundlePath),
new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'hermes_bundle.hbc'),
new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'bundle.harmony.js')
]),
this.rnohCoreContext.logger),
})
}
Expand Down
17 changes: 16 additions & 1 deletion tester/harmony/hvigor/hvigor-config.json5
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
{
"modelVersion": "5.0.0",
"dependencies": {
"@rnoh/hvigor-plugin": "../../node_modules/react-native-harmony/harmony/rnoh-hvigor-plugin-0.75.0.tgz", // <PROJECT_ROOT>/node_modules/<RNOH>/harmony/rnoh-hvigor-plugin-X.X.X.tgz
},
"execution": {
// "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */
// "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
// "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
// "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
// "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
},
"logging": {
// "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
},
"debugging": {
"stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
},
"nodeOptions": {
// "maxOldSpaceSize": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */
}
}
Loading