Skip to content

Feat/cpp#528

Merged
sunnylqm merged 14 commits intomasterfrom
feat/cpp
Mar 24, 2026
Merged

Feat/cpp#528
sunnylqm merged 14 commits intomasterfrom
feat/cpp

Conversation

@sunnylqm
Copy link
Contributor

@sunnylqm sunnylqm commented Mar 24, 2026

Summary by CodeRabbit

  • New Features

    • Enhanced update patching and state management with improved file-based operations and rollback handling.
    • Restructured server endpoint configuration to support multiple primary endpoints.
  • Documentation

    • Updated regional service descriptions and removed region-specific claims from README.
  • Chores

    • Updated React Native to 0.84.1 and corresponding tooling versions.
    • Updated dependencies including testing and build tools.
    • Improved build configuration for Android and iOS platforms.
    • Added test suite for core patching functionality.

@sunnylqm sunnylqm merged commit 87c7c9c into master Mar 24, 2026
1 check was pending
@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e6ec7fb1-ee47-4c9d-93d5-ab746be0c5a7

📥 Commits

Reviewing files that changed from the base of the PR and between 37ad3e0 and 85eae3e.

⛔ Files ignored due to path filters (7)
  • Example/testHotUpdate/bun.lock is excluded by !**/*.lock
  • Example/testHotUpdate/ios/Podfile.lock is excluded by !**/*.lock
  • android/lib/arm64-v8a/librnupdate.so is excluded by !**/*.so
  • android/lib/armeabi-v7a/librnupdate.so is excluded by !**/*.so
  • android/lib/x86/librnupdate.so is excluded by !**/*.so
  • android/lib/x86_64/librnupdate.so is excluded by !**/*.so
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (47)
  • .gitignore
  • .npmignore
  • Example/testHotUpdate/android/app/build.gradle
  • Example/testHotUpdate/ios/AwesomeProject.xcodeproj/project.pbxproj
  • Example/testHotUpdate/package.json
  • Example/testHotUpdate/tsconfig.json
  • README-CN.md
  • README.md
  • android/build.gradle
  • android/jni/Android.mk
  • android/jni/Application.mk
  • android/src/main/java/cn/reactnative/modules/update/ArchivePatchPlanResult.java
  • android/src/main/java/cn/reactnative/modules/update/CopyGroupResult.java
  • android/src/main/java/cn/reactnative/modules/update/DownloadTask.java
  • android/src/main/java/cn/reactnative/modules/update/NativeUpdateCore.java
  • android/src/main/java/cn/reactnative/modules/update/StateCoreResult.java
  • android/src/main/java/cn/reactnative/modules/update/UpdateContext.java
  • android/src/newarch/cn/reactnative/modules/update/UpdateModule.java
  • android/src/oldarch/cn/reactnative/modules/update/UpdateModule.java
  • cpp/patch_core/archive_patch_core.cpp
  • cpp/patch_core/archive_patch_core.h
  • cpp/patch_core/patch_core.cpp
  • cpp/patch_core/patch_core.h
  • cpp/patch_core/patch_core_android.cpp
  • cpp/patch_core/state_core.cpp
  • cpp/patch_core/state_core.h
  • cpp/patch_core/tests/patch_core_test.cpp
  • cpp/patch_core/update_core_android.cpp
  • error.js
  • harmony/pushy/src/main/cpp/CMakeLists.txt
  • harmony/pushy/src/main/cpp/pushy.cpp
  • harmony/pushy/src/main/ets/DownloadTask.ts
  • harmony/pushy/src/main/ets/NativePatchCore.ts
  • harmony/pushy/src/main/ets/PushyTurboModule.ts
  • harmony/pushy/src/main/ets/UpdateContext.ts
  • ios/RCTPushy/RCTPushy.mm
  • package.json
  • react-native-update.podspec
  • scripts/build-harmony-har.js
  • scripts/prepublish.ts
  • scripts/prune-host-stl.sh
  • scripts/test-patch-core.sh
  • src/__tests__/client.test.ts
  • src/__tests__/setup.ts
  • src/client.ts
  • src/core.ts
  • src/type.ts

📝 Walkthrough

Walkthrough

The PR introduces a unified C++ patch and state management core library with native bindings for Android (JNI), iOS (Objective-C++), and HarmonyOS (N-API), replacing distributed Java/Objective-C implementation logic with centralized native implementations. Dependency versions are updated accordingly.

Changes

Cohort / File(s) Summary
Build Configuration
.gitignore, .npmignore, android/build.gradle, android/jni/Android.mk, android/jni/Application.mk, harmony/pushy/src/main/cpp/CMakeLists.txt, react-native-update.podspec, package.json, scripts/prune-host-stl.sh, scripts/build-harmony-har.js, scripts/prepublish.ts, scripts/test-patch-core.sh
Updated ignores, NDK platform targeting (android-16→android-21), C++17 compilation flags, linker options, CMake configuration to include patch-core sources, CocoaPods source files, native build orchestration, and cleanup scripts for C++ runtime library artifacts.
C++ Patch/State Core Libraries
cpp/patch_core/patch_core.h, cpp/patch_core/patch_core.cpp, cpp/patch_core/state_core.h, cpp/patch_core/state_core.cpp, cpp/patch_core/archive_patch_core.h, cpp/patch_core/archive_patch_core.cpp, cpp/patch_core/tests/patch_core_test.cpp
New core libraries providing filesystem-backed patching, state management (version sync, switching, rollback, first-load tracking), archive patch planning, and cleanup utilities with comprehensive test coverage.
Android JNI Bridges
cpp/patch_core/patch_core_android.cpp, cpp/patch_core/update_core_android.cpp, android/src/main/java/cn/reactnative/modules/update/DownloadTask.java, android/src/main/java/cn/reactnative/modules/update/UpdateContext.java, android/src/main/java/cn/reactnative/modules/update/NativeUpdateCore.java, android/src/main/java/cn/reactnative/modules/update/ArchivePatchPlanResult.java, android/src/main/java/cn/reactnative/modules/update/CopyGroupResult.java, android/src/main/java/cn/reactnative/modules/update/StateCoreResult.java, android/src/newarch/cn/reactnative/modules/update/UpdateModule.java, android/src/oldarch/cn/reactnative/modules/update/UpdateModule.java
JNI bindings exposing native patch/state operations; Java classes refactored to delegate patching and state management to C++; result classes introduced for native return values; first-load marker handling moved to atomic consumption pattern.
iOS Objective-C++ Integration
ios/RCTPushy/RCTPushy.mm
Replaced manual patching and state synchronization with C++ function calls; updated patch method signature to accept patch type; refactored launch decision and rollback logic to use native state resolver; simplified cleanup to delegate to native implementation.
HarmonyOS/Harmony OS Integration
harmony/pushy/src/main/cpp/pushy.cpp, harmony/pushy/src/main/ets/NativePatchCore.ts, harmony/pushy/src/main/ets/DownloadTask.ts, harmony/pushy/src/main/ets/PushyTurboModule.ts, harmony/pushy/src/main/ets/UpdateContext.ts
N-API bindings wrapping C++ core functions; TypeScript wrapper providing typed constants and result interfaces; DownloadTask and UpdateContext refactored to use native patching and state operations; removed direct preference manager dependency.
Type Definitions & Configuration
src/type.ts, src/client.ts
Changed UpdateServerConfig.main from single string to string array, removed backups property; refactored endpoint resolution to deduplicate and filter instead of merge; removed default endpoint parameter.
Core Implementation Updates
src/core.ts
Suppressed deep import lint warning; simplified error handling in JSON parse catch clause.
Tests
src/__tests__/client.test.ts, src/__tests__/setup.ts
Added Bun test suite for server configuration behavior; extended react-native mock with DeviceEventEmitter support.
Example & Documentation
Example/testHotUpdate/android/app/build.gradle, Example/testHotUpdate/ios/AwesomeProject.xcodeproj/project.pbxproj, Example/testHotUpdate/package.json, Example/testHotUpdate/tsconfig.json, README.md, README-CN.md
Version bumps (react-native 0.82.1→0.84.1, react 19.1.1→19.2.3, detox ^20.47.0→^20.50.1); iOS build settings updated (explicit C++ flags, module enablement); TypeScript config adds jest types; Node requirement raised to >=22; documentation restructured to remove China-region service distinction and HarmonyOS explicit mention.

Sequence Diagram(s)

sequenceDiagram
    participant JS as JavaScript/TypeScript
    participant JNI as JNI/N-API Bridge
    participant Core as C++ Patch Core
    participant FS as File System

    JS->>JNI: syncStateWithBinaryVersion(pkg, build)
    JNI->>Core: pushy::state::SyncBinaryVersion(state, pkg, build)
    Core->>Core: Validate version change
    Core-->>JNI: Return updated State + changed flag
    JNI-->>JS: Return StateCoreResult

    JS->>JNI: buildArchivePatchPlan(type, entries, copies, deletes)
    JNI->>Core: pushy::archive_patch::BuildArchivePatchPlan(manifest)
    Core->>Core: Validate entries & build plan
    Core-->>JNI: Return ArchivePatchPlan
    JNI-->>JS: Return plan config (merge_source, enable_merge)

    JS->>JNI: applyPatchFromFileSource(options)
    JNI->>Core: pushy::patch::ApplyPatchFromFileSource(options, bundlePatcher)
    Core->>FS: Validate & read origin bundle
    Core->>FS: Apply patch via hdiff
    Core->>FS: Write destination bundle
    Core->>FS: Copy files per manifest
    Core->>FS: Merge directories if enabled
    Core-->>JNI: Return Status
    JNI-->>JS: Void or Exception

    JS->>JNI: runStateCore(operation, state, args)
    JNI->>Core: pushy::state::SwitchVersion/MarkSuccess/Rollback/etc.
    Core->>Core: Compute new state
    Core-->>JNI: Return updated State
    JNI-->>JS: Return StateCoreResult with operation outcomes
Loading

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 Hops through the code with native delight,
C++ cores now shining bright,
State and patches sing in harmony,
iOS, Android, unifying spree,
Carrots of logic, well arranged,
The update system: beautifully changed! 🥕

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cpp

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant