1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-09-16 08:41:37 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

update RNOH SDK dependence from local to remote (#473)

* fix harmony more than 2M issue

* fix mtpush-react-native conflics

* update harmony remote dependency flow

* udpate

* udpate

* udpate

* udpate

* udpate

* update

* uddate

* udpapte
This commit is contained in:
波仔糕
2025-02-14 17:55:09 +08:00
committed by GitHub
parent b04247b486
commit 2a96684de7
25 changed files with 145 additions and 121 deletions

View File

@@ -1,25 +1,11 @@
## 运行harmony_use_pushy项目步骤
### 1.将项目克隆到本地后在项目根目录创建libs文件夹
### 2.然后将[`rnoh`](https://github.com/bozaigao/rnoh)克隆到libs文件夹中。
说明rnoh项目基于react-native 0.72.5版本适配如果使用最新的RN版本可能会报错项目适配RN新版本请关注[`gitee仓库`](https://gitee.com/openharmony-sig/ohos_react_native/tree/0.72.5-ohos-5.0-release/tester/harmony/react_native_openharmony/src/main)
### 3.进入rnoh项目执行下面命令对rnoh项目依赖的C++库进行初始化;
```
git submodule update --init --recursive
```
### 4. 确保在react-native-update根目录已经执行过yarn submodule命令。
说明这个命令会在harmony/src/main/cpp目录生成HDiffPatch和lzma的C++模块依赖。
### 5. 在项目根目录执行下面命令安装第三方依赖。
### 1. 在项目根目录执行下面命令安装第三方依赖
```
yarn install
```
### 6. 在项目根目录执行下面命令生成bundle包文件。
### 2. 在项目根目录执行下面命令生成bundle包文件。
```
yarn build
```
@@ -27,8 +13,8 @@ yarn build
**注意⚠️**在使用pushy bundle --platform harmony命令进行打包的默认bundle包名是Hbundle.harmony.js不要随意修改包名因为diff是匹配该包名进行生成的。
### 7. 使用DevEco Studio IDE打开harmony目录然后执行sync运行项目
### 3. 使用DevEco Studio IDE打开harmony目录然后执行sync运行项目
![image](./sync.png)
### 8 运行效果图
### 4 运行效果图
![image](./demo.png)

View File

@@ -37,10 +37,6 @@
}
]
},
{
name: 'rnoh',
srcPath: '../libs/rnoh',
},
{
name: 'pushy',
srcPath: '../node_modules/react-native-update/harmony',

View File

@@ -41,4 +41,4 @@ export function generatePushyBuildTime(str?: string) {
export default {
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[generatePushyBuildTime()] /* Custom plugin to extend the functionality of Hvigor. */
}
}

View File

@@ -5,24 +5,25 @@
"lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {
"pushy@../../node_modules/react-native-update/harmony": "pushy@../../node_modules/react-native-update/harmony",
"rnoh@../../libs/rnoh": "rnoh@../../libs/rnoh"
"@rnoh/react-native-openharmony@0.72.38": "@rnoh/react-native-openharmony@0.72.38",
"pushy@../../node_modules/react-native-update/harmony": "pushy@../../node_modules/react-native-update/harmony"
},
"packages": {
"@rnoh/react-native-openharmony@0.72.38": {
"name": "@rnoh/react-native-openharmony",
"version": "0.72.38",
"integrity": "sha512-br5SIrbB0OarSLirenleE7eTOX1lNccMJ7nb/G7qWTyJ7kW4DalmTXVKYpoT2qaOLls1uEE7McD1OjbZZM9jug==",
"resolved": "https://ohpm.openharmony.cn/ohpm/@rnoh/react-native-openharmony/-/react-native-openharmony-0.72.38.har",
"registryType": "ohpm"
},
"pushy@../../node_modules/react-native-update/harmony": {
"name": "pushy",
"version": "3.1.0-0.0.7",
"resolved": "../../node_modules/react-native-update/harmony",
"registryType": "local",
"dependencies": {
"rnoh": "file:../../../libs/rnoh"
"@rnoh/react-native-openharmony": "^0.72.38"
}
},
"rnoh@../../libs/rnoh": {
"name": "rnoh",
"version": "0.72.12",
"resolved": "../../libs/rnoh",
"registryType": "local"
}
}
}

View File

@@ -6,7 +6,7 @@
"author": "",
"license": "",
"dependencies": {
"rnoh": "file:../../libs/rnoh",
"@rnoh/react-native-openharmony": "0.72.38",
"pushy": "file:../../node_modules/react-native-update/harmony"
}
}

View File

@@ -2,12 +2,23 @@ cmake_minimum_required(VERSION 3.16)
project(rnapp)
set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../libs/rnoh/src/main/cpp")
set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@rnoh/react-native-openharmony/src/main/cpp")
set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
add_subdirectory("${OH_MODULES}/pushy/src/main/cpp" ./pushy)
set(LOG_VERBOSITY_LEVEL 1)
set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
add_compile_definitions(WITH_HITRACE_SYSTRACE)
add_subdirectory("${OH_MODULES}/pushy/src/main/cpp" ./pushy)
add_subdirectory("${RNOH_CPP_DIR}" ./rn)
file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp") # this line is needed by codegen v1
add_library(rnoh_app SHARED
${GENERATED_CPP_FILES}
"./PackageProvider.cpp"
"${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
)

View File

@@ -1,4 +1,4 @@
import type {RNPackageContext, RNPackage} from 'rnoh/ts';
import type {RNPackageContext, RNPackage} from '@rnoh/react-native-openharmony/ts';
import {PushyPackage} from 'pushy/ts';
export function createRNPackages(ctx: RNPackageContext): RNPackage[] {

View File

@@ -1,4 +1,4 @@
import {RNAbility} from 'rnoh/ts';
import {RNAbility} from '@rnoh/react-native-openharmony';
export default class EntryAbility extends RNAbility {
getPagePath() {

View File

@@ -1,26 +1,32 @@
import { FileJSBundleProvider } from 'pushy/src/main/ets/FileJSBundleProvider';
import { ComponentBuilderContext, JSBundleProvider, RNOHLogger } from 'rnoh';
import { ComponentBuilderContext, RNOHCoreContext,RNAbility } from '@rnoh/react-native-openharmony';
import {
RNApp,
RNAbility,
AnyJSBundleProvider,
ResourceJSBundleProvider,
TraceJSBundleProviderDecorator,
} from 'rnoh'
} from '@rnoh/react-native-openharmony'
import { createRNPackages } from '../RNPackagesFactory'
import preferences from '@ohos.data.preferences';
const arkTsComponentNames: Array<string> = [];
@Builder
export function CustomComponentBuilder(ctx: ComponentBuilderContext) {
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() {
}
.position({ x: 0, y: 0 })
}
const wrappedCustomRNComponentBuilder = wrapBuilder(buildCustomRNComponent)
@Entry
@Component
struct Index {
@StorageLink('RNAbility') private rnAbility: RNAbility | undefined = undefined
@StorageLink('RNOHCoreContext') private rnohCoreContext: RNOHCoreContext | undefined = undefined
@State shouldShow: boolean = false
@State message: string = 'Hello World';
aboutToAppear(): void {
this.shouldShow = true
@@ -30,28 +36,37 @@ struct Index {
// NOTE: this is required since `Ability`'s `onBackPressed` function always
// terminates or puts the app in the background, but we want Ark to ignore it completely
// when handled by RN
return this.rnAbility?.onBackPress();
this.rnohCoreContext!.dispatchBackPress()
// this.preferences = preferences.getPreferencesSync(this.context, {name:'update'});
return true
}
build() {
Column() {
if (this.rnAbility && this.shouldShow) {
if (this.rnohCoreContext && this.shouldShow) {
RNApp({
rnInstanceConfig: { createRNPackages },
rnInstanceConfig: {
createRNPackages,
enableNDKTextMeasuring: true,
enableBackgroundExecutor: false,
enableCAPIArchitecture: true,
arkTsComponentNames: arkTsComponentNames,
},
initialProps: { "foo": "bar" } as Record<string, string>,
appKey: "harmony_use_pushy",
buildCustomComponent: CustomComponentBuilder,
wrappedCustomRNComponentBuilder: wrappedCustomRNComponentBuilder,
onSetUp: (rnInstance) => {
rnInstance.enableFeatureFlag("ENABLE_RN_INSTANCE_CLEAN_UP")
},
jsBundleProvider: new TraceJSBundleProviderDecorator(
new AnyJSBundleProvider([
// MetroJSBundleProvider.fromServerIp('127.0.0.1'),
// new ResourceJSBundleProvider(this.rnAbility.context.resourceManager, 'hermes_bundle.hbc'),
new FileJSBundleProvider(this.rnAbility.context),
new ResourceJSBundleProvider(this.rnAbility.context.resourceManager, 'bundle.harmony.js')
// new ResourceJSBundleProvider(rnohCoreContext.uiAbilityContext.resourceManager, 'hermes_bundle.hbc'),
new FileJSBundleProvider(this.rnohCoreContext.uiAbilityContext),
new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'bundle.harmony.js')
]),
this.rnAbility.getLogger()),
this.rnohCoreContext.logger),
})
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
{
"pushy_build_time": "2025-02-14T09:43:25.648Z",
"versionName": "1.0.0"
}

View File

@@ -0,0 +1,14 @@
{
"ios": {
"appId": 24794,
"appKey": "SqShg4Klnj2hG6LAFMW2PdcgSSuniz0T"
},
"android": {
"appId": 27509,
"appKey": "aQz3Uc2pA7gt_prDaQ4rbWRY"
},
"harmony": {
"appId": 29140,
"appKey": "JLklGflGIRbY-cMebjQwm1J1"
}
}

View File

@@ -13,5 +13,8 @@
"suppressImplicitAnyIndexErrors": true,
"strict": false
}
},
"overrides": {
"@rnoh/react-native-openharmony": "0.72.38"
}
}

View File

@@ -8,7 +8,7 @@
"appKey": "aQz3Uc2pA7gt_prDaQ4rbWRY"
},
"harmony": {
"appId": 29040,
"appKey": "gdzeAqAFE5Jew15c5Df8EKU9"
"appId": 29140,
"appKey": "JLklGflGIRbY-cMebjQwm1J1"
}
}

View File

@@ -6003,7 +6003,7 @@ react-is@^17.0.1:
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
"react-native-update@file:../..":
version "10.15.1"
version "10.19.6"
dependencies:
nanoid "^3.3.3"
react-native-url-polyfill "^2.0.0"