Skip to content

Commit 9ee6f27

Browse files
authored
Feat/har (#526)
* har * cpp * fix ci * refactor: Implement UpdateContext as a singleton and centralize preference and launch state management. * cleanup
1 parent 07947a5 commit 9ee6f27

File tree

23 files changed

+968
-311
lines changed

23 files changed

+968
-311
lines changed

.github/workflows/publish.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,25 @@ permissions:
1010
jobs:
1111
build:
1212
runs-on: ubuntu-latest
13+
container: ghcr.io/sanchuanhehe/harmony-next-pipeline-docker/harmonyos-ci-image:latest
1314
timeout-minutes: 10
1415
steps:
15-
- uses: actions/checkout@v5
16+
- uses: actions/checkout@v6
17+
with:
18+
submodules: recursive
1619
- uses: oven-sh/setup-bun@v2
1720
# Setup .npmrc file to publish to npm
18-
- uses: actions/setup-node@v6
19-
with:
20-
node-version: 24
21-
registry-url: 'https://registry.npmjs.org'
21+
# - uses: actions/setup-node@v6
22+
# with:
23+
# node-version: 24
24+
# registry-url: 'https://registry.npmjs.org'
2225
- run: bun install --frozen-lockfile
26+
- name: Verify Harmony build tools
27+
run: |
28+
command -v hvigorw >/dev/null 2>&1 || (echo "Missing hvigorw in the Harmony container image." >&2; exit 1)
29+
command -v ohpm >/dev/null 2>&1 || (echo "Missing ohpm in the Harmony container image." >&2; exit 1)
30+
- name: Build Harmony HAR
31+
run: npm run build:harmony-har -- --build-mode release
32+
- name: Verify Harmony HAR artifact
33+
run: test -f harmony/pushy.har
2334
- run: npm publish --provenance --access public

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ Example/harmony_use_pushy/libs
5555

5656

5757
harmony/package
58+
harmony/pushy.har
5859
**/oh_modules
5960
harmony/pushy/.preview
61+
harmony/pushy/.cxx
6062
Example/harmony_use_pushy/harmony/entry/src/main/resources/rawfile/meta.json
6163
**/.hvigor
6264
Example/harmony_use_pushy/harmony/entry/src/main/cpp/generated

Example/harmony_use_pushy/bun.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/harmony_use_pushy/harmony/build-profile.json5

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,5 @@
3636
},
3737
],
3838
},
39-
{
40-
name: 'pushy',
41-
srcPath: '../node_modules/react-native-update/harmony/pushy',
42-
},
4339
],
4440
}

Example/harmony_use_pushy/harmony/entry/oh-package-lock.json5

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/harmony_use_pushy/harmony/entry/oh-package.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
license: '',
88
dependencies: {
99
'@rnoh/react-native-openharmony': '0.72.96',
10-
pushy: 'file:../../node_modules/react-native-update/harmony/pushy',
10+
pushy: 'file:../../../../harmony/pushy.har',
1111
},
1212
}

Example/harmony_use_pushy/harmony/entry/src/main/cpp/CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,25 @@ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
1212
set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
1313
add_compile_definitions(WITH_HITRACE_SYSTRACE)
1414

15-
add_subdirectory("${OH_MODULES}/pushy/src/main/cpp" ./pushy)
15+
set(PUSHY_CPP_DIR "${NODE_MODULES}/react-native-update/harmony/pushy/src/main/cpp")
16+
set(PUSHY_TURBO_MODULE_CPP "${PUSHY_CPP_DIR}/PushyTurboModule.cpp")
17+
if(NOT EXISTS "${PUSHY_TURBO_MODULE_CPP}")
18+
message(FATAL_ERROR "Cannot find Pushy glue source in node_modules: ${PUSHY_TURBO_MODULE_CPP}")
19+
endif()
1620
add_subdirectory("${RNOH_CPP_DIR}" ./rn)
1721

22+
# Build only the RNOH glue here. librnupdate.so is provided by pushy.har.
23+
add_library(rnoh_pushy SHARED "${PUSHY_TURBO_MODULE_CPP}")
24+
target_include_directories(rnoh_pushy PUBLIC "${PUSHY_CPP_DIR}")
25+
target_link_libraries(rnoh_pushy PUBLIC rnoh)
26+
1827
file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp") # this line is needed by codegen v1
1928

2029
add_library(rnoh_app SHARED
2130
${GENERATED_CPP_FILES}
2231
"./PackageProvider.cpp"
2332
"${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
2433
)
34+
target_include_directories(rnoh_app PRIVATE "${PUSHY_CPP_DIR}")
2535
target_link_libraries(rnoh_app PUBLIC rnoh)
26-
target_link_libraries(rnoh_app PUBLIC rnoh_pushy)
36+
target_link_libraries(rnoh_app PUBLIC rnoh_pushy)

Example/harmony_use_pushy/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
"test": "jest"
1313
},
1414
"dependencies": {
15-
"@react-native-oh/react-native-harmony": "^0.72.59",
15+
"@react-native-oh/react-native-harmony": "0.72.96",
1616
"react": "18.2.0",
1717
"react-native": "0.72.5",
18-
"react-native-update": "^10.37.1"
18+
"react-native-update": "^10.37.15"
1919
},
2020
"devDependencies": {
2121
"@babel/core": "^7.20.0",
@@ -32,7 +32,7 @@
3232
"metro-react-native-babel-preset": "0.76.8",
3333
"prettier": "^2.4.1",
3434
"react-test-renderer": "18.2.0",
35-
"typescript": "4.8.4"
35+
"typescript": "5.9.3"
3636
},
3737
"engines": {
3838
"node": ">=16"

harmony/har-wrapper/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.hvigor
2+
.idea
3+
build
4+
oh_modules
5+
oh-package-lock.json5
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"app": {
3+
"bundleName": "com.reactnativecn.pushy.har",
4+
"vendor": "reactnativecn",
5+
"versionCode": 1,
6+
"versionName": "1.0.0"
7+
}
8+
}

0 commit comments

Comments
 (0)