react-native-yolo 0.0.2 → 0.0.3

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.
Files changed (39) hide show
  1. package/README.md +28 -6
  2. package/android/build.gradle +5 -0
  3. package/android/src/main/java/com/yolo/HybridYolo.kt +36 -21
  4. package/android/src/main/java/com/yolo/YoloPackage.kt +2 -11
  5. package/android/src/main/java/com/yolo/loader/YoloModelLoader.kt +130 -0
  6. package/android/src/main/java/com/yolo/utils/ContextProvider.kt +14 -0
  7. package/ios/Bridge.h +1 -1
  8. package/ios/HybridYolo.swift +4 -11
  9. package/lib/commonjs/index.js +1 -3
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/module/index.js +2 -3
  12. package/lib/module/index.js.map +1 -1
  13. package/lib/typescript/src/index.d.ts +2 -4
  14. package/lib/typescript/src/index.d.ts.map +1 -1
  15. package/lib/typescript/src/specs/yolo.nitro.d.ts +6 -8
  16. package/lib/typescript/src/specs/yolo.nitro.d.ts.map +1 -1
  17. package/nitrogen/generated/android/Yolo+autolinking.cmake +0 -2
  18. package/nitrogen/generated/android/YoloOnLoad.cpp +0 -2
  19. package/nitrogen/generated/android/c++/JHybridYoloSpec.cpp +11 -11
  20. package/nitrogen/generated/android/c++/JHybridYoloSpec.hpp +3 -3
  21. package/nitrogen/generated/android/kotlin/com/margelo/nitro/yolo/HybridYoloSpec.kt +8 -7
  22. package/nitrogen/generated/ios/Yolo-Swift-Cxx-Bridge.hpp +20 -0
  23. package/nitrogen/generated/ios/Yolo-Swift-Cxx-Umbrella.hpp +3 -0
  24. package/nitrogen/generated/ios/c++/HybridYoloSpecSwift.hpp +16 -8
  25. package/nitrogen/generated/ios/swift/HybridYoloSpec.swift +4 -3
  26. package/nitrogen/generated/ios/swift/HybridYoloSpec_cxx.swift +20 -27
  27. package/nitrogen/generated/shared/c++/HybridYoloSpec.cpp +2 -2
  28. package/nitrogen/generated/shared/c++/HybridYoloSpec.hpp +4 -4
  29. package/package.json +1 -1
  30. package/src/index.ts +10 -12
  31. package/src/specs/yolo.nitro.ts +5 -11
  32. package/nitrogen/generated/android/c++/views/JHybridYoloStateUpdater.cpp +0 -56
  33. package/nitrogen/generated/android/c++/views/JHybridYoloStateUpdater.hpp +0 -49
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/yolo/views/HybridYoloManager.kt +0 -80
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/yolo/views/HybridYoloStateUpdater.kt +0 -23
  36. package/nitrogen/generated/ios/c++/views/HybridYoloComponent.mm +0 -122
  37. package/nitrogen/generated/shared/c++/views/HybridYoloComponent.cpp +0 -83
  38. package/nitrogen/generated/shared/c++/views/HybridYoloComponent.hpp +0 -110
  39. package/nitrogen/generated/shared/json/YoloConfig.json +0 -10
package/README.md CHANGED
@@ -1,18 +1,29 @@
1
1
  # react-native-yolo
2
2
 
3
- react-native-yolo is a react native package built with Nitro
3
+ 🚧 **Work in Progress**
4
+
5
+ `react-native-yolo` is currently under active development and is **not yet ready for production use**. APIs, features, and installation steps may change between releases.
6
+
7
+ The goal of this project is to provide YOLO-based object detection capabilities for React Native applications using Nitro Modules.
4
8
 
5
9
  [![Version](https://img.shields.io/npm/v/react-native-yolo.svg)](https://www.npmjs.com/package/react-native-yolo)
6
10
  [![Downloads](https://img.shields.io/npm/dm/react-native-yolo.svg)](https://www.npmjs.com/package/react-native-yolo)
7
11
  [![License](https://img.shields.io/npm/l/react-native-yolo.svg)](https://github.com/patrickkabwe/react-native-yolo/LICENSE)
8
12
 
13
+ ## Current Status
14
+
15
+ * 🚧 Under active development
16
+ * ⚠️ Breaking changes may occur between releases
17
+ * ⚠️ Documentation is incomplete
18
+ * ⚠️ Features are still being implemented and tested
19
+
9
20
  ## Requirements
10
21
 
11
- - React Native v0.76.0 or higher
12
- - Node 18.0.0 or higher
22
+ * React Native v0.76.0 or higher
23
+ * Node 18.0.0 or higher
13
24
 
14
- > [!IMPORTANT]
15
- > To Support `Nitro Views` you need to install React Native version v0.78.0 or higher.
25
+ > [!IMPORTANT]
26
+ > To support `Nitro Views`, you need React Native v0.78.0 or higher.
16
27
 
17
28
  ## Installation
18
29
 
@@ -20,10 +31,21 @@ react-native-yolo is a react native package built with Nitro
20
31
  npm install react-native-yolo react-native-nitro-modules
21
32
  ```
22
33
 
34
+ ## Roadmap
35
+
36
+ Planned features include:
37
+
38
+ * YOLO model loading
39
+ * Real-time object detection
40
+ * Camera integration
41
+ * Android support
42
+ * iOS support
43
+ * Performance optimizations
44
+
23
45
  ## Credits
24
46
 
25
47
  Bootstrapped with [create-nitro-module](https://github.com/patrickkabwe/create-nitro-module).
26
48
 
27
49
  ## Contributing
28
50
 
29
- Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
51
+ Contributions, bug reports, and feature requests are welcome. Since the project is still under development, feedback is especially appreciated.
@@ -137,6 +137,11 @@ dependencies {
137
137
 
138
138
  // Add a dependency on NitroModules
139
139
  implementation project(":react-native-nitro-modules")
140
+
141
+ // Add TensorFlow Lite dependencies
142
+ implementation "com.google.ai.edge.litert:litert:1.4.2"
143
+ implementation "com.google.ai.edge.litert:litert-support-api:1.4.2"
144
+ implementation "com.google.ai.edge.litert:litert-gpu:1.4.2"
140
145
  }
141
146
 
142
147
  if (isNewArchitectureEnabled()) {
@@ -1,27 +1,42 @@
1
1
  package com.yolo
2
2
 
3
- import android.graphics.Color
4
- import android.view.View
5
- import androidx.annotation.Keep
6
- import com.facebook.proguard.annotations.DoNotStrip
7
- import com.facebook.react.uimanager.ThemedReactContext
3
+ import android.net.Uri
4
+ import android.util.Log
5
+ import com.margelo.nitro.NitroModules
8
6
  import com.margelo.nitro.yolo.HybridYoloSpec
7
+ import java.io.File
8
+ import java.io.RandomAccessFile
9
+ import java.net.URL
10
+ import java.nio.MappedByteBuffer
11
+ import java.nio.channels.FileChannel
12
+ import org.tensorflow.lite.Interpreter
13
+ import org.tensorflow.lite.support.common.FileUtil
14
+ import yolo.com.loader.YoloModelLoader
9
15
 
10
- @Keep
11
- @DoNotStrip
12
- class HybridYolo(val context: ThemedReactContext): HybridYoloSpec() {
13
- // View
14
- override val view: View = View(context)
15
-
16
- // Props
17
- private var _isRed = false
18
- override var isRed: Boolean
19
- get() = _isRed
20
- set(value) {
21
- _isRed = value
22
- view.setBackgroundColor(
23
- if (value) Color.RED
24
- else Color.BLACK
25
- )
16
+ class HybridYolo : HybridYoloSpec() {
17
+ private var interpreter: Interpreter? = null
18
+ private val modelLoader = YoloModelLoader()
19
+
20
+ override fun sum(num1: Double, num2: Double): Double {
21
+ return num1 + num2
22
+ }
23
+
24
+ override fun loadModel(modelPath: String) {
25
+ val context =
26
+ NitroModules.applicationContext ?: throw IllegalStateException("Context is null")
27
+
28
+ Log.d("YOLO_TAG", "Trying to load: $modelPath")
29
+
30
+ try {
31
+ val modelBuffer = modelLoader.load(modelPath)
32
+
33
+ interpreter?.close()
34
+ interpreter = Interpreter(modelBuffer)
35
+
36
+ Log.d("YOLO_TAG", "✅ Model loaded successfully!")
37
+ } catch (e: Exception) {
38
+ Log.e("YOLO_TAG", "❌ Failed to load model: ${e.message}", e)
26
39
  }
40
+ }
41
+
27
42
  }
@@ -4,26 +4,17 @@ import com.facebook.react.bridge.NativeModule;
4
4
  import com.facebook.react.bridge.ReactApplicationContext;
5
5
  import com.facebook.react.module.model.ReactModuleInfoProvider;
6
6
  import com.facebook.react.BaseReactPackage;
7
- import com.facebook.react.uimanager.ViewManager;
8
- import com.margelo.nitro.yolo.*;
9
- import com.margelo.nitro.yolo.views.*;
7
+ import com.margelo.nitro.yolo.YoloOnLoad;
10
8
 
11
9
 
12
10
  public class YoloPackage : BaseReactPackage() {
13
11
  override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? = null
14
12
 
15
13
  override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider { emptyMap() }
16
-
17
- override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
18
- val viewManagers = ArrayList<ViewManager<*, *>>()
19
- viewManagers.add(HybridYoloManager())
20
- return viewManagers
21
- }
22
14
 
23
15
  companion object {
24
16
  init {
25
- YoloOnLoad.initializeNative()
17
+ YoloOnLoad.initializeNative();
26
18
  }
27
19
  }
28
20
  }
29
-
@@ -0,0 +1,130 @@
1
+ package yolo.com.loader
2
+
3
+ import android.net.Uri
4
+ import android.util.Log
5
+ import com.yolo.utils.ContextProvider
6
+ import java.io.File
7
+ import java.io.RandomAccessFile
8
+ import java.net.URL
9
+ import java.nio.MappedByteBuffer
10
+ import java.nio.channels.FileChannel
11
+ import org.tensorflow.lite.support.common.FileUtil
12
+
13
+
14
+
15
+ /**
16
+ * A utility class for loading YOLO models from various sources, including URLs, file URIs, absolute paths, and APK assets.
17
+ * This class provides methods to load a model into a MappedByteBuffer, which can be used with TensorFlow Lite's Interpreter for inference.
18
+ * It also includes methods to copy raw resources to the cache directory and map files for efficient reading
19
+ */
20
+ class YoloModelLoader {
21
+ companion object {
22
+ private const val TAG = "YOLO_TAG_LOADER"
23
+ }
24
+
25
+ /**
26
+ * Loads a YOLO model from the specified path. The path can be a URL, a file URI, an absolute
27
+ * path, or an asset name.
28
+ * @param modelPath The path to the YOLO model.
29
+ * @return A MappedByteBuffer containing the model data.
30
+ * @throws IllegalArgumentException if the model cannot be loaded from the specified path.
31
+ */
32
+ fun load(modelPath: String): MappedByteBuffer {
33
+ val context = ContextProvider.context
34
+
35
+ return when {
36
+ modelPath.startsWith("http://") || modelPath.startsWith("https://") -> {
37
+ Log.d(TAG, "Loading model from URL")
38
+ val cachedFile = downloadToCache(modelPath)
39
+ mapFile(cachedFile)
40
+ }
41
+ modelPath.startsWith("file://") -> {
42
+ Log.d(TAG, "Loading model from file URI")
43
+ val file = File(Uri.parse(modelPath).path!!)
44
+ mapFile(file)
45
+ }
46
+ modelPath.startsWith("/") -> {
47
+ Log.d(TAG, "Loading model from absolute path")
48
+ mapFile(File(modelPath))
49
+ }
50
+ modelPath.startsWith("assets_") -> {
51
+ Log.d(TAG, "Loading model from RN raw resource")
52
+ val file = copyRawResourceToCache(modelPath)
53
+ mapFile(file)
54
+ }
55
+ else -> {
56
+ Log.d(TAG, "Loading model from APK assets")
57
+ FileUtil.loadMappedFile(context, modelPath)
58
+ }
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Copies a raw resource to the cache directory and returns the corresponding File object.
64
+ * @param resourceName The name of the raw resource (without the file extension).
65
+ * @return The File object pointing to the copied resource in the cache directory.
66
+ * @throws IllegalArgumentException if the raw resource is not found.
67
+ */
68
+ private fun copyRawResourceToCache(resourceName: String): File {
69
+ val context = ContextProvider.context
70
+
71
+ val resId = context.resources.getIdentifier(resourceName, "raw", context.packageName)
72
+
73
+ if (resId == 0) {
74
+ throw IllegalArgumentException("Raw resource not found: $resourceName")
75
+ }
76
+
77
+ val file = File(context.cacheDir, "$resourceName.tflite")
78
+
79
+ context.resources.openRawResource(resId).use { input ->
80
+ file.outputStream().use { output -> input.copyTo(output) }
81
+ }
82
+
83
+ Log.d(TAG, "Copied raw resource to: ${file.absolutePath}")
84
+ Log.d(TAG, "Copied raw resource size: ${file.length()} bytes")
85
+
86
+ return file
87
+ }
88
+
89
+ /**
90
+ * Maps a file to a MappedByteBuffer for efficient reading.
91
+ * @param file The file to be mapped.
92
+ * @return A MappedByteBuffer containing the file data.
93
+ * @throws IllegalArgumentException if the file does not exist or is empty.
94
+ */
95
+ private fun mapFile(file: File): MappedByteBuffer {
96
+ if (!file.exists()) {
97
+ throw IllegalArgumentException("Model file does not exist: ${file.absolutePath}")
98
+ }
99
+
100
+ if (file.length() <= 0) {
101
+ throw IllegalArgumentException("Model file is empty: ${file.absolutePath}")
102
+ }
103
+
104
+ val randomAccessFile = RandomAccessFile(file, "r")
105
+ val fileChannel = randomAccessFile.channel
106
+
107
+ return fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fileChannel.size())
108
+ }
109
+
110
+ /**
111
+ * Downloads a file from a URL to the cache directory and returns the corresponding File object.
112
+ * @param urlString The URL of the file to download.
113
+ * @return The File object pointing to the downloaded file in the cache directory.
114
+ * @throws IllegalArgumentException if the file cannot be downloaded.
115
+ */
116
+ private fun downloadToCache(urlString: String): File {
117
+ val context = ContextProvider.context
118
+
119
+ val file = File(context.cacheDir, "yolo_model.tflite")
120
+
121
+ URL(urlString).openStream().use { input ->
122
+ file.outputStream().use { output -> input.copyTo(output) }
123
+ }
124
+
125
+ Log.d(TAG, "Downloaded model to: ${file.absolutePath}")
126
+ Log.d(TAG, "Downloaded model size: ${file.length()} bytes")
127
+
128
+ return file
129
+ }
130
+ }
@@ -0,0 +1,14 @@
1
+ package com.yolo.utils
2
+
3
+ import android.content.Context
4
+ import com.margelo.nitro.NitroModules
5
+
6
+ /**
7
+ * Provides a way to access the application context from anywhere in the app.
8
+ * This is useful for classes that do not have a direct reference to a Context object.
9
+ */
10
+ object ContextProvider {
11
+ val context: Context
12
+ get() = NitroModules.applicationContext
13
+ ?: throw IllegalStateException("Context is null")
14
+ }
package/ios/Bridge.h CHANGED
@@ -2,7 +2,7 @@
2
2
  // Bridge.h
3
3
  // yolo
4
4
  //
5
- // Created by Khaoula-Ghalimi on 20/06/2026
5
+ // Created by Khaoula-Ghalimi on 22/06/2026
6
6
  //
7
7
 
8
8
  #pragma once
@@ -2,20 +2,13 @@
2
2
  // HybridYolo.swift
3
3
  // Pods
4
4
  //
5
- // Created by Khaoula-Ghalimi on 20/06/2026.
5
+ // Created by Khaoula-Ghalimi on 22/06/2026.
6
6
  //
7
7
 
8
8
  import Foundation
9
- import UIKit
10
9
 
11
- class HybridYolo : HybridYoloSpec {
12
- // UIView
13
- var view: UIView = UIView()
14
-
15
- // Props
16
- var isRed: Bool = false {
17
- didSet {
18
- view.backgroundColor = isRed ? .red : .black
10
+ class HybridYolo: HybridYoloSpec {
11
+ func sum(num1: Double, num2: Double) throws -> Double {
12
+ return num1 + num2
19
13
  }
20
- }
21
14
  }
@@ -5,7 +5,5 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Yolo = void 0;
7
7
  var _reactNativeNitroModules = require("react-native-nitro-modules");
8
- var _YoloConfig = _interopRequireDefault(require("../nitrogen/generated/shared/json/YoloConfig.json"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- const Yolo = exports.Yolo = (0, _reactNativeNitroModules.getHostComponent)('Yolo', () => _YoloConfig.default);
8
+ const Yolo = exports.Yolo = _reactNativeNitroModules.NitroModules.createHybridObject('Yolo');
11
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNativeNitroModules","require","_YoloConfig","_interopRequireDefault","e","__esModule","default","Yolo","exports","getHostComponent","YoloConfig"],"sourceRoot":"..\\..\\src","sources":["index.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA0E,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAOnE,MAAMG,IAAI,GAAAC,OAAA,CAAAD,IAAA,GAAG,IAAAE,yCAAgB,EAClC,MAAM,EACN,MAAMC,mBACR,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNativeNitroModules","require","Yolo","exports","NitroModules","createHybridObject"],"sourceRoot":"..\\..\\src","sources":["index.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAGO,MAAMC,IAAI,GAAAC,OAAA,CAAAD,IAAA,GACfE,qCAAY,CAACC,kBAAkB,CAAW,MAAM,CAAC","ignoreList":[]}
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- import { getHostComponent } from 'react-native-nitro-modules';
4
- import YoloConfig from '../nitrogen/generated/shared/json/YoloConfig.json';
5
- export const Yolo = getHostComponent('Yolo', () => YoloConfig);
3
+ import { NitroModules } from 'react-native-nitro-modules';
4
+ export const Yolo = NitroModules.createHybridObject('Yolo');
6
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getHostComponent","YoloConfig","Yolo"],"sourceRoot":"..\\..\\src","sources":["index.ts"],"mappings":";;AAAA,SAASA,gBAAgB,QAAwB,4BAA4B;AAC7E,OAAOC,UAAU,MAAM,mDAAmD;AAO1E,OAAO,MAAMC,IAAI,GAAGF,gBAAgB,CAClC,MAAM,EACN,MAAMC,UACR,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["NitroModules","Yolo","createHybridObject"],"sourceRoot":"..\\..\\src","sources":["index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAGzD,OAAO,MAAMC,IAAI,GACfD,YAAY,CAACE,kBAAkB,CAAW,MAAM,CAAC","ignoreList":[]}
@@ -1,5 +1,3 @@
1
- import { type HybridRef } from 'react-native-nitro-modules';
2
- import type { YoloProps, YoloMethods } from './specs/yolo.nitro';
3
- export declare const Yolo: import("react-native-nitro-modules").ReactNativeView<YoloProps, YoloMethods>;
4
- export type YoloRef = HybridRef<YoloProps, YoloMethods>;
1
+ import type { Yolo as YoloSpec } from './specs/yolo.nitro';
2
+ export declare const Yolo: YoloSpec;
5
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAE7E,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACZ,MAAM,oBAAoB,CAAA;AAG3B,eAAO,MAAM,IAAI,8EAGhB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG,SAAS,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE1D,eAAO,MAAM,IAAI,UACkC,CAAA"}
@@ -1,11 +1,9 @@
1
- import type { HybridView, HybridViewProps, HybridViewMethods } from 'react-native-nitro-modules';
2
- export interface YoloProps extends HybridViewProps {
3
- isRed: boolean;
4
- }
5
- export interface YoloMethods extends HybridViewMethods {
6
- }
7
- export type Yolo = HybridView<YoloProps, YoloMethods, {
1
+ import type { HybridObject } from 'react-native-nitro-modules';
2
+ export interface Yolo extends HybridObject<{
8
3
  ios: 'swift';
9
4
  android: 'kotlin';
10
- }>;
5
+ }> {
6
+ sum(num1: number, num2: number): number;
7
+ loadModel(modelPath: string): void;
8
+ }
11
9
  //# sourceMappingURL=yolo.nitro.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"yolo.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/yolo.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,iBAAiB,EAClB,MAAM,4BAA4B,CAAA;AAEnC,MAAM,WAAW,SAAU,SAAQ,eAAe;IAC/C,KAAK,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,WAAY,SAAQ,iBAAiB;CAAG;AAEzD,MAAM,MAAM,IAAI,GAAG,UAAU,CAAC,SAAS,EAAE,WAAW,EAAE;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAA"}
1
+ {"version":3,"file":"yolo.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/yolo.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D,MAAM,WAAW,IAAK,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IAC7E,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACvC,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACnC"}
@@ -34,10 +34,8 @@ target_sources(
34
34
  ../nitrogen/generated/android/YoloOnLoad.cpp
35
35
  # Shared Nitrogen C++ sources
36
36
  ../nitrogen/generated/shared/c++/HybridYoloSpec.cpp
37
- ../nitrogen/generated/shared/c++/views/HybridYoloComponent.cpp
38
37
  # Android-specific Nitrogen C++ sources
39
38
  ../nitrogen/generated/android/c++/JHybridYoloSpec.cpp
40
- ../nitrogen/generated/android/c++/views/JHybridYoloStateUpdater.cpp
41
39
  )
42
40
 
43
41
  # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
@@ -16,7 +16,6 @@
16
16
  #include <NitroModules/HybridObjectRegistry.hpp>
17
17
 
18
18
  #include "JHybridYoloSpec.hpp"
19
- #include "views/JHybridYoloStateUpdater.hpp"
20
19
  #include <NitroModules/DefaultConstructableObject.hpp>
21
20
 
22
21
  namespace margelo::nitro::yolo {
@@ -42,7 +41,6 @@ void registerAllNatives() {
42
41
 
43
42
  // Register native JNI methods
44
43
  margelo::nitro::yolo::JHybridYoloSpec::CxxPart::registerNatives();
45
- margelo::nitro::yolo::views::JHybridYoloStateUpdater::registerNatives();
46
44
 
47
45
  // Register Nitro Hybrid Objects
48
46
  HybridObjectRegistry::registerHybridObjectConstructor(
@@ -9,7 +9,7 @@
9
9
 
10
10
 
11
11
 
12
-
12
+ #include <string>
13
13
 
14
14
  namespace margelo::nitro::yolo {
15
15
 
@@ -41,17 +41,17 @@ namespace margelo::nitro::yolo {
41
41
  }
42
42
 
43
43
  // Properties
44
- bool JHybridYoloSpec::getIsRed() {
45
- static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("isRed");
46
- auto __result = method(_javaPart);
47
- return static_cast<bool>(__result);
48
- }
49
- void JHybridYoloSpec::setIsRed(bool isRed) {
50
- static const auto method = _javaPart->javaClassStatic()->getMethod<void(jboolean /* isRed */)>("setRed");
51
- method(_javaPart, isRed);
52
- }
44
+
53
45
 
54
46
  // Methods
55
-
47
+ double JHybridYoloSpec::sum(double num1, double num2) {
48
+ static const auto method = _javaPart->javaClassStatic()->getMethod<double(double /* num1 */, double /* num2 */)>("sum");
49
+ auto __result = method(_javaPart, num1, num2);
50
+ return __result;
51
+ }
52
+ void JHybridYoloSpec::loadModel(const std::string& modelPath) {
53
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* modelPath */)>("loadModel");
54
+ method(_javaPart, jni::make_jstring(modelPath));
55
+ }
56
56
 
57
57
  } // namespace margelo::nitro::yolo
@@ -50,12 +50,12 @@ namespace margelo::nitro::yolo {
50
50
 
51
51
  public:
52
52
  // Properties
53
- bool getIsRed() override;
54
- void setIsRed(bool isRed) override;
53
+
55
54
 
56
55
  public:
57
56
  // Methods
58
-
57
+ double sum(double num1, double num2) override;
58
+ void loadModel(const std::string& modelPath) override;
59
59
 
60
60
  private:
61
61
  jni::global_ref<JHybridYoloSpec::JavaPart> _javaPart;
@@ -11,7 +11,6 @@ import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
13
  import com.margelo.nitro.core.HybridObject
14
- import com.margelo.nitro.views.HybridView
15
14
 
16
15
  /**
17
16
  * A Kotlin class representing the Yolo HybridObject.
@@ -24,16 +23,18 @@ import com.margelo.nitro.views.HybridView
24
23
  "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
25
24
  "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
26
25
  )
27
- abstract class HybridYoloSpec: HybridView() {
26
+ abstract class HybridYoloSpec: HybridObject() {
28
27
  // Properties
29
- @get:DoNotStrip
30
- @get:Keep
31
- @set:DoNotStrip
32
- @set:Keep
33
- abstract var isRed: Boolean
28
+
34
29
 
35
30
  // Methods
31
+ @DoNotStrip
32
+ @Keep
33
+ abstract fun sum(num1: Double, num2: Double): Double
36
34
 
35
+ @DoNotStrip
36
+ @Keep
37
+ abstract fun loadModel(modelPath: String): Unit
37
38
 
38
39
  // Default implementation of `HybridObject.toString()`
39
40
  override fun toString(): String {
@@ -17,6 +17,8 @@ namespace Yolo { class HybridYoloSpec_cxx; }
17
17
 
18
18
  // Include C++ defined types
19
19
  #include "HybridYoloSpec.hpp"
20
+ #include <NitroModules/Result.hpp>
21
+ #include <exception>
20
22
  #include <memory>
21
23
 
22
24
  /**
@@ -36,5 +38,23 @@ namespace margelo::nitro::yolo::bridge::swift {
36
38
  // pragma MARK: std::weak_ptr<HybridYoloSpec>
37
39
  using std__weak_ptr_HybridYoloSpec_ = std::weak_ptr<HybridYoloSpec>;
38
40
  inline std__weak_ptr_HybridYoloSpec_ weakify_std__shared_ptr_HybridYoloSpec_(const std::shared_ptr<HybridYoloSpec>& strong) noexcept { return strong; }
41
+
42
+ // pragma MARK: Result<double>
43
+ using Result_double_ = Result<double>;
44
+ inline Result_double_ create_Result_double_(double value) noexcept {
45
+ return Result<double>::withValue(std::move(value));
46
+ }
47
+ inline Result_double_ create_Result_double_(const std::exception_ptr& error) noexcept {
48
+ return Result<double>::withError(error);
49
+ }
50
+
51
+ // pragma MARK: Result<void>
52
+ using Result_void_ = Result<void>;
53
+ inline Result_void_ create_Result_void_() noexcept {
54
+ return Result<void>::withValue();
55
+ }
56
+ inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
57
+ return Result<void>::withError(error);
58
+ }
39
59
 
40
60
  } // namespace margelo::nitro::yolo::bridge::swift
@@ -13,7 +13,10 @@ namespace margelo::nitro::yolo { class HybridYoloSpec; }
13
13
 
14
14
  // Include C++ defined types
15
15
  #include "HybridYoloSpec.hpp"
16
+ #include <NitroModules/Result.hpp>
17
+ #include <exception>
16
18
  #include <memory>
19
+ #include <string>
17
20
 
18
21
  // C++ helpers for Swift
19
22
  #include "Yolo-Swift-Cxx-Bridge.hpp"
@@ -14,7 +14,7 @@ namespace Yolo { class HybridYoloSpec_cxx; }
14
14
 
15
15
 
16
16
 
17
-
17
+ #include <string>
18
18
 
19
19
  #include "Yolo-Swift-Cxx-Umbrella.hpp"
20
20
 
@@ -62,16 +62,24 @@ namespace margelo::nitro::yolo {
62
62
 
63
63
  public:
64
64
  // Properties
65
- inline bool getIsRed() noexcept override {
66
- return _swiftPart.isRed();
67
- }
68
- inline void setIsRed(bool isRed) noexcept override {
69
- _swiftPart.setIsRed(std::forward<decltype(isRed)>(isRed));
70
- }
65
+
71
66
 
72
67
  public:
73
68
  // Methods
74
-
69
+ inline double sum(double num1, double num2) override {
70
+ auto __result = _swiftPart.sum(std::forward<decltype(num1)>(num1), std::forward<decltype(num2)>(num2));
71
+ if (__result.hasError()) [[unlikely]] {
72
+ std::rethrow_exception(__result.error());
73
+ }
74
+ auto __value = std::move(__result.value());
75
+ return __value;
76
+ }
77
+ inline void loadModel(const std::string& modelPath) override {
78
+ auto __result = _swiftPart.loadModel(modelPath);
79
+ if (__result.hasError()) [[unlikely]] {
80
+ std::rethrow_exception(__result.error());
81
+ }
82
+ }
75
83
 
76
84
  private:
77
85
  Yolo::HybridYoloSpec_cxx _swiftPart;
@@ -8,12 +8,13 @@
8
8
  import NitroModules
9
9
 
10
10
  /// See ``HybridYoloSpec``
11
- public protocol HybridYoloSpec_protocol: HybridObject, HybridView {
11
+ public protocol HybridYoloSpec_protocol: HybridObject {
12
12
  // Properties
13
- var isRed: Bool { get set }
13
+
14
14
 
15
15
  // Methods
16
-
16
+ func sum(num1: Double, num2: Double) throws -> Double
17
+ func loadModel(modelPath: String) throws -> Void
17
18
  }
18
19
 
19
20
  public extension HybridYoloSpec_protocol {