@rhq/rover 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -42,6 +42,18 @@ Traditional email clients treat every message the same: they show sender, subjec
42
42
 
43
43
  ## Installation
44
44
 
45
+ ### React Native & Expo
46
+ ```bash
47
+ # In an Expo project
48
+ npx expo install @rhq/rover
49
+
50
+ # In a React Native project
51
+ npm install @rhq/rover
52
+ # on iOS, install CocoaPods:
53
+ npx pod-install
54
+ ```
55
+
56
+ ### Web & Node.js
45
57
  ```bash
46
58
  npm install @rhq/rover
47
59
  # or with pnpm
@@ -52,6 +64,16 @@ yarn add @rhq/rover
52
64
 
53
65
  ---
54
66
 
67
+ ## ⚡ React Native & Hermes Architecture
68
+
69
+ Rover includes dedicated first-class React Native support:
70
+ - **Zero Node Built-in Dependencies**: No `fs`, `path`, or `url` imports in the React Native execution path.
71
+ - **Hermes Native Performance**: Functions execute via compiled C++ JSI host objects and UniFFI native bindings, completely bypassing legacy React Native JSON bridge overhead.
72
+ - **Off-Thread Background Processing**: Execute heavy batch email syncs off the UI thread via `processAsync` and `processBatchAsync` without dropping a single frame (120fps smooth animations).
73
+ - **Zero Breaking API Changes**: Existing code runs without changes. The same exports, function signatures, and return objects work seamlessly on Web, Node, iOS, and Android.
74
+
75
+ ---
76
+
55
77
  ## Integrating Into an Email Client Application
56
78
 
57
79
  ### 1. Ingesting Real-World Raw Emails (IMAP, Gmail API, JMAP)
package/Rover.podspec ADDED
@@ -0,0 +1,32 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "Rover"
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.homepage = "https://blogs.relaymail.online/blog/rover"
10
+ s.license = package['license']
11
+ s.authors = package['author']
12
+ s.platforms = { :ios => "13.4" }
13
+ s.source = { :git => "https://github.com/RelayHQX/rover.git", :tag => "v#{s.version}" }
14
+
15
+ s.source_files = "ios/**/*.{h,m,mm,swift}", "cpp/**/*.{h,cpp}"
16
+ s.public_header_files = "ios/**/*.h", "cpp/**/*.h"
17
+
18
+ s.pod_target_xcconfig = {
19
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
20
+ "SWIFT_INCLUDE_PATHS" => "$(PODS_TARGET_SRCROOT)/ios",
21
+ "OTHER_SWIFT_FLAGS" => "-import-objc-header $(PODS_TARGET_SRCROOT)/ios/Rover-Bridging-Header.h"
22
+ }
23
+
24
+ s.dependency "React-Core"
25
+ s.dependency "React-callinvoker"
26
+
27
+ if defined?(install_modules_dependencies)
28
+ install_modules_dependencies(s)
29
+ else
30
+ s.dependency "ExpoModulesCore" rescue nil
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ cmake_minimum_required(VERSION 3.18.1)
2
+ project(roverjsi)
3
+
4
+ set(CMAKE_CXX_STANDARD 17)
5
+
6
+ include_directories(
7
+ ${CMAKE_CURRENT_SOURCE_DIR}/../cpp
8
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp
9
+ )
10
+
11
+ # Location of prebuilt librelay_rover.so compiled by cargo
12
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/librelay_rover.so")
13
+ add_library(relay_rover SHARED IMPORTED)
14
+ set_target_properties(relay_rover PROPERTIES
15
+ IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/librelay_rover.so"
16
+ )
17
+ endif()
18
+
19
+ add_library(roverjsi SHARED
20
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/rover-jni.cpp
21
+ ${CMAKE_CURRENT_SOURCE_DIR}/../cpp/RoverJsi.cpp
22
+ )
23
+
24
+ find_library(LOG_LIB log)
25
+ find_library(ANDROID_LIB android)
26
+
27
+ target_link_libraries(roverjsi
28
+ PRIVATE
29
+ relay_rover
30
+ ${LOG_LIB}
31
+ ${ANDROID_LIB}
32
+ )
@@ -0,0 +1,77 @@
1
+ apply plugin: 'com.android.library'
2
+ apply plugin: 'kotlin-android'
3
+
4
+ group = 'com.relayhq.rover'
5
+ version = '0.1.0'
6
+
7
+ buildscript {
8
+ repositories {
9
+ google()
10
+ mavenCentral()
11
+ }
12
+ dependencies {
13
+ classpath 'com.android.tools.build:gradle:8.2.1'
14
+ classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22'
15
+ }
16
+ }
17
+
18
+ android {
19
+ compileSdkVersion 34
20
+ namespace "com.relayhq.rover"
21
+
22
+ defaultConfig {
23
+ minSdkVersion 21
24
+ targetSdkVersion 34
25
+ versionCode 1
26
+ versionName "0.1.0"
27
+
28
+ ndk {
29
+ abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86_64', 'x86'
30
+ }
31
+
32
+ externalNativeBuild {
33
+ cmake {
34
+ cppFlags "-std=c++17 -O3"
35
+ arguments "-DANDROID_STL=c++_shared"
36
+ }
37
+ }
38
+ }
39
+
40
+ externalNativeBuild {
41
+ cmake {
42
+ path "CMakeLists.txt"
43
+ }
44
+ }
45
+
46
+ sourceSets {
47
+ main {
48
+ jniLibs.srcDirs = ['src/main/jniLibs']
49
+ }
50
+ }
51
+
52
+ lintOptions {
53
+ abortOnError false
54
+ }
55
+ }
56
+
57
+ repositories {
58
+ google()
59
+ mavenCentral()
60
+ }
61
+
62
+ dependencies {
63
+ // Kotlin & Coroutines
64
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:1.9.22"
65
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3"
66
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3"
67
+
68
+ // JNA for UniFFI bindings
69
+ implementation "net.java.dev.jna:jna:5.14.0@aar"
70
+
71
+ // Optional Expo Modules Core dependency
72
+ compileOnly "host.exp:expo:+"
73
+ compileOnly project(':expo-modules-core')
74
+
75
+ // Optional React Native dependency
76
+ compileOnly "com.facebook.react:react-android:+"
77
+ }
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.relayhq.rover">
3
+ </manifest>
@@ -0,0 +1,15 @@
1
+ #include <jni.h>
2
+ #include <jsi/jsi.h>
3
+ #include "RoverJsi.h"
4
+
5
+ extern "C" JNIEXPORT void JNICALL
6
+ Java_com_relayhq_rover_RoverJsiModule_nativeInstall(
7
+ JNIEnv* env,
8
+ jobject /* this */,
9
+ jlong jsiRuntimePointer
10
+ ) {
11
+ if (jsiRuntimePointer != 0) {
12
+ auto* runtime = reinterpret_cast<facebook::jsi::Runtime*>(jsiRuntimePointer);
13
+ relay_rover::RoverHostObject::install(*runtime);
14
+ }
15
+ }
@@ -0,0 +1,16 @@
1
+ package com.relayhq.rover
2
+
3
+ /**
4
+ * JNI wrapper to install the RoverHostObject directly into the Hermes / React Native JSI runtime.
5
+ */
6
+ object RoverJsiModule {
7
+ init {
8
+ try {
9
+ System.loadLibrary("roverjsi")
10
+ } catch (_: UnsatisfiedLinkError) {
11
+ // Handled when embedded directly
12
+ }
13
+ }
14
+
15
+ external fun nativeInstall(jsiRuntimePointer: Long)
16
+ }
@@ -0,0 +1,56 @@
1
+ package com.relayhq.rover
2
+
3
+ import expo.modules.kotlin.modules.Module
4
+ import expo.modules.kotlin.modules.ModuleDefinition
5
+ import kotlinx.coroutines.Dispatchers
6
+ import kotlinx.coroutines.withContext
7
+
8
+ /**
9
+ * Expo Module implementation for Relay Rover on Android.
10
+ * Integrates Rust core through UniFFI bindings and exposes high-performance JSI methods.
11
+ */
12
+ class RoverModule : Module() {
13
+ override fun definition() = ModuleDefinition {
14
+ Name("RelayRover")
15
+
16
+ Function("classify") { subject: String, body: String ->
17
+ RoverNativeBridge.classify(subject, body)
18
+ }
19
+
20
+ Function("generatePreview") { subject: String, body: String ->
21
+ RoverNativeBridge.generatePreview(subject, body)
22
+ }
23
+
24
+ Function("processEmail") { subject: String, body: String ->
25
+ RoverNativeBridge.processEmail(subject, body)
26
+ }
27
+
28
+ Function("processEmailJson") { emailJson: String ->
29
+ RoverNativeBridge.processEmailJson(emailJson)
30
+ }
31
+
32
+ Function("processBatchJson") { batchJson: String ->
33
+ RoverNativeBridge.processBatchJson(batchJson)
34
+ }
35
+
36
+ Function("htmlToText") { html: String ->
37
+ RoverNativeBridge.htmlToText(html)
38
+ }
39
+
40
+ Function("cleanEmailBody") { bodyOrHtml: String ->
41
+ RoverNativeBridge.cleanEmailBody(bodyOrHtml)
42
+ }
43
+
44
+ AsyncFunction("processEmailAsync") { emailJson: String ->
45
+ withContext(Dispatchers.Default) {
46
+ RoverNativeBridge.processEmailJson(emailJson)
47
+ }
48
+ }
49
+
50
+ AsyncFunction("processBatchAsync") { batchJson: String ->
51
+ withContext(Dispatchers.Default) {
52
+ RoverNativeBridge.processBatchJson(batchJson)
53
+ }
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,45 @@
1
+ package com.relayhq.rover
2
+
3
+ import uniffi.relay_rover.*
4
+
5
+ /**
6
+ * High-performance Kotlin bridge connecting UniFFI-generated Rust bindings
7
+ * to Expo and React Native runtime.
8
+ */
9
+ object RoverNativeBridge {
10
+ init {
11
+ try {
12
+ System.loadLibrary("relay_rover")
13
+ } catch (_: UnsatisfiedLinkError) {
14
+ // In Android/JNA environments, UniFFI or system dynamic loader locates the library
15
+ }
16
+ }
17
+
18
+ fun classify(subject: String, body: String): String {
19
+ return uniffi.relay_rover.classify(subject, body)
20
+ }
21
+
22
+ fun generatePreview(subject: String, body: String): String {
23
+ return uniffi.relay_rover.generatePreview(subject, body)
24
+ }
25
+
26
+ fun processEmail(subject: String, body: String): String {
27
+ return uniffi.relay_rover.processEmail(subject, body)
28
+ }
29
+
30
+ fun processEmailJson(emailJson: String): String {
31
+ return uniffi.relay_rover.processEmailJson(emailJson)
32
+ }
33
+
34
+ fun processBatchJson(batchJson: String): String {
35
+ return uniffi.relay_rover.processBatchJson(batchJson)
36
+ }
37
+
38
+ fun htmlToText(html: String): String {
39
+ return uniffi.relay_rover.htmlToText(html)
40
+ }
41
+
42
+ fun cleanEmailBody(bodyOrHtml: String): String {
43
+ return uniffi.relay_rover.cleanEmailBody(bodyOrHtml)
44
+ }
45
+ }
@@ -0,0 +1,73 @@
1
+ package com.relayhq.rover
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
5
+ import com.facebook.react.bridge.ReactMethod
6
+ import com.facebook.react.bridge.Promise
7
+
8
+ /**
9
+ * React Native Android Bridge module for vanilla (non-Expo) React Native applications.
10
+ */
11
+ class RoverNativeModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
12
+ override fun getName(): String = "RelayRover"
13
+
14
+ @ReactMethod(isBlockingSynchronousMethod = true)
15
+ fun classify(subject: String, body: String): String = RoverNativeBridge.classify(subject, body)
16
+
17
+ @ReactMethod(isBlockingSynchronousMethod = true)
18
+ fun generatePreview(subject: String, body: String): String = RoverNativeBridge.generatePreview(subject, body)
19
+
20
+ @ReactMethod(isBlockingSynchronousMethod = true)
21
+ fun processEmail(subject: String, body: String): String = RoverNativeBridge.processEmail(subject, body)
22
+
23
+ @ReactMethod(isBlockingSynchronousMethod = true)
24
+ fun processEmailJson(emailJson: String): String = RoverNativeBridge.processEmailJson(emailJson)
25
+
26
+ @ReactMethod(isBlockingSynchronousMethod = true)
27
+ fun processBatchJson(batchJson: String): String = RoverNativeBridge.processBatchJson(batchJson)
28
+
29
+ @ReactMethod(isBlockingSynchronousMethod = true)
30
+ fun htmlToText(html: String): String = RoverNativeBridge.htmlToText(html)
31
+
32
+ @ReactMethod(isBlockingSynchronousMethod = true)
33
+ fun cleanEmailBody(bodyOrHtml: String): String = RoverNativeBridge.cleanEmailBody(bodyOrHtml)
34
+
35
+ @ReactMethod
36
+ fun processEmailAsync(emailJson: String, promise: Promise) {
37
+ Thread {
38
+ try {
39
+ val res = RoverNativeBridge.processEmailJson(emailJson)
40
+ promise.resolve(res)
41
+ } catch (e: Throwable) {
42
+ promise.reject("ROVER_ERROR", e.message, e)
43
+ }
44
+ }.start()
45
+ }
46
+
47
+ @ReactMethod
48
+ fun processBatchAsync(batchJson: String, promise: Promise) {
49
+ Thread {
50
+ try {
51
+ val res = RoverNativeBridge.processBatchJson(batchJson)
52
+ promise.resolve(res)
53
+ } catch (e: Throwable) {
54
+ promise.reject("ROVER_ERROR", e.message, e)
55
+ }
56
+ }.start()
57
+ }
58
+
59
+ @ReactMethod(isBlockingSynchronousMethod = true)
60
+ fun installJsi(): Boolean {
61
+ return try {
62
+ val jsContext = reactApplicationContext.javaScriptContextHolder?.get() ?: 0L
63
+ if (jsContext != 0L) {
64
+ RoverJsiModule.nativeInstall(jsContext)
65
+ true
66
+ } else {
67
+ false
68
+ }
69
+ } catch (_: Throwable) {
70
+ false
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,16 @@
1
+ package com.relayhq.rover
2
+
3
+ import com.facebook.react.ReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.uimanager.ViewManager
7
+
8
+ class RoverPackage : ReactPackage {
9
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
10
+ return listOf(RoverNativeModule(reactContext))
11
+ }
12
+
13
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
14
+ return emptyList()
15
+ }
16
+ }