@rhq/rover 0.0.0-stage → 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.
@@ -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
+ }