Skip to content

Commit 97848e7

Browse files
bozaigaoSteven
andauthored
support to harmony local debug mode (#493)
* support to Expo * update * update * update * support to harmony local debug * udpate * update --------- Co-authored-by: Steven <steven@Stevens-MacBook-Pro.local>
1 parent bf3a080 commit 97848e7

File tree

16 files changed

+9976
-12608
lines changed

16 files changed

+9976
-12608
lines changed

Example/harmony_use_pushy/README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
## 运行harmony_use_pushy项目步骤
22

3-
### 1. 先在react-native-update根目录执行下面命令同步C++模块
3+
### 1. 在项目根目录执行下面命令安装第三方依赖
44
```
5-
yarn submodule
5+
bun install
66
```
77

8-
### 2. 在项目根目录执行下面命令安装第三方依赖。
8+
### 2. 本地debug 模式
99
```
10-
yarn install
10+
bun run start
1111
```
12+
![image](./debug.png)
1213

13-
### 3. 在项目根目录执行下面命令生成bundle包文件。
14+
### 3. release 模式: 在项目根目录执行下面命令生成bundle包文件。
1415
```
15-
yarn build
16+
bun run build
1617
```
1718
说明:这个命令会在harmony/entry/src/main/resources/rawfile目录生成Hbundle.harmony.js和assets文件,同时会基于该内容在.pushy/output目录生成ppk包。
1819

Example/harmony_use_pushy/bun.lock

Lines changed: 2130 additions & 0 deletions
Large diffs are not rendered by default.
743 KB
Loading
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* This code was generated by "react-native codegen-harmony"
3+
*
4+
* Do not edit this file as changes may cause incorrect behavior and will be
5+
* lost once the code is regenerated.
6+
*
7+
* @generatorVersion: 1
8+
*/
9+
10+
#pragma once
11+
12+
#include "RNOH/Package.h"
13+
#include "RNOH/ArkTSTurboModule.h"
14+
15+
namespace rnoh {
16+
17+
class RNOHGeneratedPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
18+
public:
19+
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
20+
return nullptr;
21+
};
22+
};
23+
24+
class GeneratedEventEmitRequestHandler : public EventEmitRequestHandler {
25+
public:
26+
void handleEvent(Context const &ctx) override {
27+
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
28+
if (eventEmitter == nullptr) {
29+
return;
30+
}
31+
32+
std::vector<std::string> supportedEventNames = {
33+
};
34+
if (std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
35+
eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
36+
}
37+
}
38+
};
39+
40+
class RNOHGeneratedPackage : public Package {
41+
public:
42+
RNOHGeneratedPackage(Package::Context ctx) : Package(ctx){};
43+
44+
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
45+
return std::make_unique<RNOHGeneratedPackageTurboModuleFactoryDelegate>();
46+
}
47+
48+
std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
49+
return {
50+
};
51+
}
52+
53+
ComponentJSIBinderByString createComponentJSIBinderByName() override {
54+
return {
55+
};
56+
};
57+
58+
EventEmitRequestHandlers createEventEmitRequestHandlers() override {
59+
return {
60+
std::make_shared<GeneratedEventEmitRequestHandler>(),
61+
};
62+
}
63+
};
64+
65+
} // namespace rnoh

Example/harmony_use_pushy/harmony/entry/src/main/ets/pages/Index.ets

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { FileJSBundleProvider } from 'pushy/src/main/ets/FileJSBundleProvider';
2-
import { ComponentBuilderContext, RNOHCoreContext,RNAbility } from '@rnoh/react-native-openharmony';
2+
import { ComponentBuilderContext, RNOHCoreContext,RNAbility,
3+
MetroJSBundleProvider } from '@rnoh/react-native-openharmony';
34
import {
45
RNApp,
56
AnyJSBundleProvider,
@@ -61,8 +62,9 @@ struct Index {
6162
},
6263
jsBundleProvider: new TraceJSBundleProviderDecorator(
6364
new AnyJSBundleProvider([
64-
// MetroJSBundleProvider.fromServerIp('127.0.0.1'),
65-
// new ResourceJSBundleProvider(rnohCoreContext.uiAbilityContext.resourceManager, 'hermes_bundle.hbc'),
65+
// local debug mode
66+
new MetroJSBundleProvider(),
67+
// release mode
6668
new FileJSBundleProvider(this.rnohCoreContext.uiAbilityContext),
6769
new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'bundle.harmony.js')
6870
]),

Example/harmony_use_pushy/harmony/entry/src/main/resources/rawfile/bundle.harmony.js

Lines changed: 169 additions & 170 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"pushy_build_time": "2025-03-09T01:57:42.464Z",
2+
"pushy_build_time": "2025-04-12T11:12:43.423Z",
33
"versionName": "1.0.0"
44
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
/**
3+
*/
4+
5+
export {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* This code was generated by "react-native codegen-harmony"
3+
*
4+
* Do not edit this file as changes may cause incorrect behavior and will be
5+
* lost once the code is regenerated.
6+
*/
7+
8+
export * from "./ts"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* This code was generated by "react-native codegen-harmony"
3+
*
4+
* Do not edit this file as changes may cause incorrect behavior and will be
5+
* lost once the code is regenerated.
6+
*/
7+
8+
export * as RNC from "./components/ts"
9+
export * as TM from "./turboModules/ts"

0 commit comments

Comments
 (0)