react-native-yolo 0.0.1 → 0.0.2

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 (35) hide show
  1. package/android/src/main/java/com/yolo/HybridYolo.kt +22 -7
  2. package/android/src/main/java/com/yolo/YoloPackage.kt +11 -2
  3. package/ios/Bridge.h +1 -1
  4. package/ios/HybridYolo.swift +11 -4
  5. package/lib/commonjs/index.js +3 -1
  6. package/lib/commonjs/index.js.map +1 -1
  7. package/lib/module/index.js +3 -2
  8. package/lib/module/index.js.map +1 -1
  9. package/lib/typescript/src/index.d.ts +4 -2
  10. package/lib/typescript/src/index.d.ts.map +1 -1
  11. package/lib/typescript/src/specs/yolo.nitro.d.ts +8 -6
  12. package/lib/typescript/src/specs/yolo.nitro.d.ts.map +1 -1
  13. package/nitrogen/generated/android/Yolo+autolinking.cmake +2 -0
  14. package/nitrogen/generated/android/YoloOnLoad.cpp +2 -0
  15. package/nitrogen/generated/android/c++/JHybridYoloSpec.cpp +10 -11
  16. package/nitrogen/generated/android/c++/JHybridYoloSpec.hpp +3 -3
  17. package/nitrogen/generated/android/c++/views/JHybridYoloStateUpdater.cpp +56 -0
  18. package/nitrogen/generated/android/c++/views/JHybridYoloStateUpdater.hpp +49 -0
  19. package/nitrogen/generated/android/kotlin/com/margelo/nitro/yolo/HybridYoloSpec.kt +7 -8
  20. package/nitrogen/generated/android/kotlin/com/margelo/nitro/yolo/views/HybridYoloManager.kt +80 -0
  21. package/nitrogen/generated/android/kotlin/com/margelo/nitro/yolo/views/HybridYoloStateUpdater.kt +23 -0
  22. package/nitrogen/generated/ios/Yolo-Swift-Cxx-Bridge.hpp +0 -11
  23. package/nitrogen/generated/ios/Yolo-Swift-Cxx-Umbrella.hpp +0 -2
  24. package/nitrogen/generated/ios/c++/HybridYoloSpecSwift.hpp +7 -17
  25. package/nitrogen/generated/ios/c++/views/HybridYoloComponent.mm +122 -0
  26. package/nitrogen/generated/ios/swift/HybridYoloSpec.swift +3 -4
  27. package/nitrogen/generated/ios/swift/HybridYoloSpec_cxx.swift +27 -21
  28. package/nitrogen/generated/shared/c++/HybridYoloSpec.cpp +2 -2
  29. package/nitrogen/generated/shared/c++/HybridYoloSpec.hpp +3 -3
  30. package/nitrogen/generated/shared/c++/views/HybridYoloComponent.cpp +83 -0
  31. package/nitrogen/generated/shared/c++/views/HybridYoloComponent.hpp +110 -0
  32. package/nitrogen/generated/shared/json/YoloConfig.json +10 -0
  33. package/package.json +2 -2
  34. package/src/index.ts +13 -4
  35. package/src/specs/yolo.nitro.ts +12 -5
@@ -1,12 +1,27 @@
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
8
  import com.margelo.nitro.yolo.HybridYoloSpec
4
9
 
5
- class HybridYolo: HybridYoloSpec() {
6
- override fun sum(num1: Double, num2: Double): Double {
7
- return num1 + num2
8
- }
9
- override fun subtract(num1: Double, num2: Double): Double {
10
- return num1 - num2
11
- }
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
+ )
26
+ }
12
27
  }
@@ -4,17 +4,26 @@ 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.margelo.nitro.yolo.YoloOnLoad;
7
+ import com.facebook.react.uimanager.ViewManager;
8
+ import com.margelo.nitro.yolo.*;
9
+ import com.margelo.nitro.yolo.views.*;
8
10
 
9
11
 
10
12
  public class YoloPackage : BaseReactPackage() {
11
13
  override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? = null
12
14
 
13
15
  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
+ }
14
22
 
15
23
  companion object {
16
24
  init {
17
- YoloOnLoad.initializeNative();
25
+ YoloOnLoad.initializeNative()
18
26
  }
19
27
  }
20
28
  }
29
+
package/ios/Bridge.h CHANGED
@@ -2,7 +2,7 @@
2
2
  // Bridge.h
3
3
  // yolo
4
4
  //
5
- // Created by Khaoula-Ghalimi on 17/06/2026
5
+ // Created by Khaoula-Ghalimi on 20/06/2026
6
6
  //
7
7
 
8
8
  #pragma once
@@ -2,13 +2,20 @@
2
2
  // HybridYolo.swift
3
3
  // Pods
4
4
  //
5
- // Created by Khaoula-Ghalimi on 17/06/2026.
5
+ // Created by Khaoula-Ghalimi on 20/06/2026.
6
6
  //
7
7
 
8
8
  import Foundation
9
+ import UIKit
9
10
 
10
- class HybridYolo: HybridYoloSpec {
11
- func sum(num1: Double, num2: Double) throws -> Double {
12
- return num1 + num2
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
13
19
  }
20
+ }
14
21
  }
@@ -5,5 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Yolo = void 0;
7
7
  var _reactNativeNitroModules = require("react-native-nitro-modules");
8
- const Yolo = exports.Yolo = _reactNativeNitroModules.NitroModules.createHybridObject('Yolo');
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);
9
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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
+ {"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,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
- import { NitroModules } from 'react-native-nitro-modules';
4
- export const Yolo = NitroModules.createHybridObject('Yolo');
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);
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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
+ {"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,3 +1,5 @@
1
- import type { Yolo as YoloSpec } from './specs/yolo.nitro';
2
- export declare const Yolo: YoloSpec;
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>;
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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
+ {"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,9 +1,11 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- export interface Yolo extends HybridObject<{
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, {
3
8
  ios: 'swift';
4
9
  android: 'kotlin';
5
- }> {
6
- sum(num1: number, num2: number): number;
7
- subtract(num1: number, num2: number): number;
8
- }
10
+ }>;
9
11
  //# 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,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,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAC7C"}
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"}
@@ -34,8 +34,10 @@ 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
37
38
  # Android-specific Nitrogen C++ sources
38
39
  ../nitrogen/generated/android/c++/JHybridYoloSpec.cpp
40
+ ../nitrogen/generated/android/c++/views/JHybridYoloStateUpdater.cpp
39
41
  )
40
42
 
41
43
  # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
@@ -16,6 +16,7 @@
16
16
  #include <NitroModules/HybridObjectRegistry.hpp>
17
17
 
18
18
  #include "JHybridYoloSpec.hpp"
19
+ #include "views/JHybridYoloStateUpdater.hpp"
19
20
  #include <NitroModules/DefaultConstructableObject.hpp>
20
21
 
21
22
  namespace margelo::nitro::yolo {
@@ -41,6 +42,7 @@ void registerAllNatives() {
41
42
 
42
43
  // Register native JNI methods
43
44
  margelo::nitro::yolo::JHybridYoloSpec::CxxPart::registerNatives();
45
+ margelo::nitro::yolo::views::JHybridYoloStateUpdater::registerNatives();
44
46
 
45
47
  // Register Nitro Hybrid Objects
46
48
  HybridObjectRegistry::registerHybridObjectConstructor(
@@ -41,18 +41,17 @@ namespace margelo::nitro::yolo {
41
41
  }
42
42
 
43
43
  // Properties
44
-
45
-
46
- // Methods
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;
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);
51
48
  }
52
- double JHybridYoloSpec::subtract(double num1, double num2) {
53
- static const auto method = _javaPart->javaClassStatic()->getMethod<double(double /* num1 */, double /* num2 */)>("subtract");
54
- auto __result = method(_javaPart, num1, num2);
55
- return __result;
49
+ void JHybridYoloSpec::setIsRed(bool isRed) {
50
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jboolean /* isRed */)>("setRed");
51
+ method(_javaPart, isRed);
56
52
  }
57
53
 
54
+ // Methods
55
+
56
+
58
57
  } // namespace margelo::nitro::yolo
@@ -50,12 +50,12 @@ namespace margelo::nitro::yolo {
50
50
 
51
51
  public:
52
52
  // Properties
53
-
53
+ bool getIsRed() override;
54
+ void setIsRed(bool isRed) override;
54
55
 
55
56
  public:
56
57
  // Methods
57
- double sum(double num1, double num2) override;
58
- double subtract(double num1, double num2) override;
58
+
59
59
 
60
60
  private:
61
61
  jni::global_ref<JHybridYoloSpec::JavaPart> _javaPart;
@@ -0,0 +1,56 @@
1
+ ///
2
+ /// JHybridYoloStateUpdater.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "JHybridYoloStateUpdater.hpp"
9
+ #include "views/HybridYoloComponent.hpp"
10
+ #include <NitroModules/NitroDefines.hpp>
11
+ #include <react/fabric/StateWrapperImpl.h>
12
+
13
+ namespace margelo::nitro::yolo::views {
14
+
15
+ using namespace facebook;
16
+ using ConcreteStateData = react::ConcreteState<HybridYoloState>;
17
+
18
+ void JHybridYoloStateUpdater::updateViewProps(jni::alias_ref<jni::JClass> /* class */,
19
+ jni::alias_ref<JHybridYoloSpec::JavaPart> javaView,
20
+ jni::alias_ref<JStateWrapper::javaobject> stateWrapperInterface) {
21
+ std::shared_ptr<JHybridYoloSpec> hybridView = javaView->getJHybridYoloSpec();
22
+
23
+ // Get concrete StateWrapperImpl from passed StateWrapper interface object
24
+ jobject rawStateWrapper = stateWrapperInterface.get();
25
+ if (!stateWrapperInterface->isInstanceOf(react::StateWrapperImpl::javaClassStatic())) [[unlikely]] {
26
+ throw std::runtime_error("StateWrapper is not a StateWrapperImpl");
27
+ }
28
+ auto stateWrapper = jni::alias_ref<react::StateWrapperImpl::javaobject>{
29
+ static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)};
30
+ std::shared_ptr<const react::State> state = stateWrapper->cthis()->getState();
31
+ auto concreteState = std::static_pointer_cast<const ConcreteStateData>(state);
32
+ const HybridYoloState& data = concreteState->getData();
33
+ const std::shared_ptr<HybridYoloProps>& props = data.getProps();
34
+ if (props == nullptr) [[unlikely]] {
35
+ // Props aren't set yet!
36
+ throw std::runtime_error("HybridYoloState's data doesn't contain any props!");
37
+ }
38
+
39
+ // Update all props if they are dirty
40
+ if (props->isRed.isDirty) {
41
+ hybridView->setIsRed(props->isRed.value);
42
+ props->isRed.isDirty = false;
43
+ }
44
+
45
+ // Update hybridRef if it changed
46
+ if (props->hybridRef.isDirty) {
47
+ // hybridRef changed - call it with new this
48
+ const auto& maybeFunc = props->hybridRef.value;
49
+ if (maybeFunc.has_value()) {
50
+ maybeFunc.value()(hybridView);
51
+ }
52
+ props->hybridRef.isDirty = false;
53
+ }
54
+ }
55
+
56
+ } // namespace margelo::nitro::yolo::views
@@ -0,0 +1,49 @@
1
+ ///
2
+ /// JHybridYoloStateUpdater.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #ifndef RN_SERIALIZABLE_STATE
11
+ #error Yolo was compiled without the 'RN_SERIALIZABLE_STATE' flag. This flag is required for Nitro Views - set it in your CMakeLists!
12
+ #endif
13
+
14
+ #include <fbjni/fbjni.h>
15
+ #include <react/fabric/CoreComponentsRegistry.h>
16
+ #include <react/fabric/StateWrapperImpl.h>
17
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
18
+ #include <NitroModules/NitroDefines.hpp>
19
+ #include <NitroModules/JStateWrapper.hpp>
20
+ #include "JHybridYoloSpec.hpp"
21
+ #include "views/HybridYoloComponent.hpp"
22
+
23
+ namespace margelo::nitro::yolo::views {
24
+
25
+ using namespace facebook;
26
+
27
+ class JHybridYoloStateUpdater final: public jni::JavaClass<JHybridYoloStateUpdater> {
28
+ public:
29
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/yolo/views/HybridYoloStateUpdater;";
30
+
31
+ public:
32
+ static void updateViewProps(jni::alias_ref<jni::JClass> /* class */,
33
+ jni::alias_ref<JHybridYoloSpec::JavaPart> view,
34
+ jni::alias_ref<JStateWrapper::javaobject> stateWrapperInterface);
35
+
36
+ public:
37
+ static void registerNatives() {
38
+ // Register JNI calls
39
+ javaClassStatic()->registerNatives({
40
+ makeNativeMethod("updateViewProps", JHybridYoloStateUpdater::updateViewProps),
41
+ });
42
+ // Register React Native view component descriptor
43
+ auto provider = react::concreteComponentDescriptorProvider<HybridYoloComponentDescriptor>();
44
+ auto providerRegistry = react::CoreComponentsRegistry::sharedProviderRegistry();
45
+ providerRegistry->add(provider);
46
+ }
47
+ };
48
+
49
+ } // namespace margelo::nitro::yolo::views
@@ -11,6 +11,7 @@ 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
14
15
 
15
16
  /**
16
17
  * A Kotlin class representing the Yolo HybridObject.
@@ -23,18 +24,16 @@ import com.margelo.nitro.core.HybridObject
23
24
  "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
24
25
  "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
25
26
  )
26
- abstract class HybridYoloSpec: HybridObject() {
27
+ abstract class HybridYoloSpec: HybridView() {
27
28
  // Properties
28
-
29
+ @get:DoNotStrip
30
+ @get:Keep
31
+ @set:DoNotStrip
32
+ @set:Keep
33
+ abstract var isRed: Boolean
29
34
 
30
35
  // Methods
31
- @DoNotStrip
32
- @Keep
33
- abstract fun sum(num1: Double, num2: Double): Double
34
36
 
35
- @DoNotStrip
36
- @Keep
37
- abstract fun subtract(num1: Double, num2: Double): Double
38
37
 
39
38
  // Default implementation of `HybridObject.toString()`
40
39
  override fun toString(): String {
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// HybridYoloManager.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.yolo.views
9
+
10
+ import android.view.View
11
+ import com.facebook.react.uimanager.ReactStylesDiffMap
12
+ import com.facebook.react.uimanager.SimpleViewManager
13
+ import com.facebook.react.uimanager.StateWrapper
14
+ import com.facebook.react.uimanager.ThemedReactContext
15
+ import com.margelo.nitro.R.id.associated_hybrid_view_tag
16
+ import com.margelo.nitro.views.RecyclableView
17
+ import com.yolo.*
18
+
19
+ /**
20
+ * Represents the React Native `ViewManager` for the "Yolo" Nitro HybridView.
21
+ */
22
+ public class HybridYoloManager: SimpleViewManager<View>() {
23
+ init {
24
+ if (RecyclableView::class.java.isAssignableFrom(HybridYolo::class.java)) {
25
+ // Enable view recycling
26
+ super.setupViewRecycling()
27
+ }
28
+ }
29
+
30
+ override fun getName(): String {
31
+ return "Yolo"
32
+ }
33
+
34
+ override fun createViewInstance(reactContext: ThemedReactContext): View {
35
+ val hybridView = HybridYolo(reactContext)
36
+ val view = hybridView.view
37
+ view.setTag(associated_hybrid_view_tag, hybridView)
38
+ return view
39
+ }
40
+
41
+ override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? {
42
+ val hybridView = getHybridView(view)
43
+ ?: throw Error("Couldn't find view $view in local views table!")
44
+
45
+ // 1. Update each prop individually
46
+ hybridView.beforeUpdate()
47
+ HybridYoloStateUpdater.updateViewProps(hybridView, stateWrapper)
48
+ hybridView.afterUpdate()
49
+
50
+ // 2. Continue in base View props
51
+ return super.updateState(view, props, stateWrapper)
52
+ }
53
+
54
+ override fun onDropViewInstance(view: View) {
55
+ val hybridView = getHybridView(view)
56
+ hybridView?.onDropView()
57
+ return super.onDropViewInstance(view)
58
+ }
59
+
60
+ protected override fun prepareToRecycleView(reactContext: ThemedReactContext, view: View): View? {
61
+ super.prepareToRecycleView(reactContext, view)
62
+ val hybridView = getHybridView(view)
63
+ ?: return null
64
+
65
+ @Suppress("USELESS_IS_CHECK")
66
+ if (hybridView is RecyclableView) {
67
+ // Recycle in it's implementation
68
+ hybridView.prepareForRecycle()
69
+
70
+ // Maybe update the view if it changed
71
+ return hybridView.view
72
+ } else {
73
+ return null
74
+ }
75
+ }
76
+
77
+ private fun getHybridView(view: View): HybridYolo? {
78
+ return view.getTag(associated_hybrid_view_tag) as? HybridYolo
79
+ }
80
+ }
@@ -0,0 +1,23 @@
1
+ ///
2
+ /// HybridYoloStateUpdater.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.yolo.views
9
+
10
+ import com.facebook.react.uimanager.StateWrapper
11
+ import com.margelo.nitro.yolo.*
12
+
13
+ internal class HybridYoloStateUpdater {
14
+ companion object {
15
+ /**
16
+ * Updates the props for [view] through C++.
17
+ * The [state] prop is expected to contain [view]'s props as wrapped Fabric state.
18
+ */
19
+ @Suppress("KotlinJniMissingFunction")
20
+ @JvmStatic
21
+ external fun updateViewProps(view: HybridYoloSpec, state: StateWrapper)
22
+ }
23
+ }
@@ -17,8 +17,6 @@ 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>
22
20
  #include <memory>
23
21
 
24
22
  /**
@@ -38,14 +36,5 @@ namespace margelo::nitro::yolo::bridge::swift {
38
36
  // pragma MARK: std::weak_ptr<HybridYoloSpec>
39
37
  using std__weak_ptr_HybridYoloSpec_ = std::weak_ptr<HybridYoloSpec>;
40
38
  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
39
 
51
40
  } // namespace margelo::nitro::yolo::bridge::swift
@@ -13,8 +13,6 @@ 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>
18
16
  #include <memory>
19
17
 
20
18
  // C++ helpers for Swift
@@ -62,26 +62,16 @@ namespace margelo::nitro::yolo {
62
62
 
63
63
  public:
64
64
  // Properties
65
-
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
+ }
66
71
 
67
72
  public:
68
73
  // Methods
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 double subtract(double num1, double num2) override {
78
- auto __result = _swiftPart.subtract(std::forward<decltype(num1)>(num1), std::forward<decltype(num2)>(num2));
79
- if (__result.hasError()) [[unlikely]] {
80
- std::rethrow_exception(__result.error());
81
- }
82
- auto __value = std::move(__result.value());
83
- return __value;
84
- }
74
+
85
75
 
86
76
  private:
87
77
  Yolo::HybridYoloSpec_cxx _swiftPart;
@@ -0,0 +1,122 @@
1
+ ///
2
+ /// HybridYoloComponent.mm
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #import "HybridYoloComponent.hpp"
9
+ #import <memory>
10
+ #import <react/renderer/componentregistry/ComponentDescriptorProvider.h>
11
+ #import <React/RCTViewComponentView.h>
12
+ #import <React/RCTComponentViewFactory.h>
13
+ #import <React/UIView+ComponentViewProtocol.h>
14
+ #import <NitroModules/NitroDefines.hpp>
15
+ #import <UIKit/UIKit.h>
16
+
17
+ #import "HybridYoloSpecSwift.hpp"
18
+ #import "Yolo-Swift-Cxx-Umbrella.hpp"
19
+
20
+ #if __has_include(<cxxreact/ReactNativeVersion.h>)
21
+ #include <cxxreact/ReactNativeVersion.h>
22
+ #if REACT_NATIVE_VERSION_MINOR >= 82
23
+ #define ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
24
+ #endif
25
+ #endif
26
+
27
+ using namespace facebook;
28
+ using namespace margelo::nitro::yolo;
29
+ using namespace margelo::nitro::yolo::views;
30
+
31
+ /**
32
+ * Represents the React Native View holder for the Nitro "Yolo" HybridView.
33
+ */
34
+ @interface HybridYoloComponent: RCTViewComponentView
35
+ + (BOOL)shouldBeRecycled;
36
+ @end
37
+
38
+ @implementation HybridYoloComponent {
39
+ std::shared_ptr<HybridYoloSpecSwift> _hybridView;
40
+ }
41
+
42
+ + (void) load {
43
+ [super load];
44
+ [RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[HybridYoloComponent class]];
45
+ }
46
+
47
+ + (react::ComponentDescriptorProvider) componentDescriptorProvider {
48
+ return react::concreteComponentDescriptorProvider<HybridYoloComponentDescriptor>();
49
+ }
50
+
51
+ - (instancetype) init {
52
+ if (self = [super init]) {
53
+ std::shared_ptr<HybridYoloSpec> hybridView = Yolo::YoloAutolinking::createYolo();
54
+ _hybridView = std::dynamic_pointer_cast<HybridYoloSpecSwift>(hybridView);
55
+ [self updateView];
56
+ }
57
+ return self;
58
+ }
59
+
60
+ - (void) updateView {
61
+ // 1. Get Swift part
62
+ Yolo::HybridYoloSpec_cxx& swiftPart = _hybridView->getSwiftPart();
63
+
64
+ // 2. Get UIView*
65
+ void* viewUnsafe = swiftPart.getView();
66
+ UIView* view = (__bridge_transfer UIView*) viewUnsafe;
67
+
68
+ // 3. Update RCTViewComponentView's [contentView]
69
+ [self setContentView:view];
70
+ }
71
+
72
+ - (void) updateProps:(const std::shared_ptr<const react::Props>&)props
73
+ oldProps:(const std::shared_ptr<const react::Props>&)oldProps {
74
+ // 1. Downcast props
75
+ const auto& newViewPropsConst = *std::static_pointer_cast<HybridYoloProps const>(props);
76
+ auto& newViewProps = const_cast<HybridYoloProps&>(newViewPropsConst);
77
+ Yolo::HybridYoloSpec_cxx& swiftPart = _hybridView->getSwiftPart();
78
+
79
+ // 2. Update each prop individually
80
+ swiftPart.beforeUpdate();
81
+
82
+ // isRed: boolean
83
+ if (newViewProps.isRed.isDirty) {
84
+ swiftPart.setIsRed(newViewProps.isRed.value);
85
+ newViewProps.isRed.isDirty = false;
86
+ }
87
+
88
+ swiftPart.afterUpdate();
89
+
90
+ // 3. Update hybridRef if it changed
91
+ if (newViewProps.hybridRef.isDirty) {
92
+ // hybridRef changed - call it with new this
93
+ const auto& maybeFunc = newViewProps.hybridRef.value;
94
+ if (maybeFunc.has_value()) {
95
+ maybeFunc.value()(_hybridView);
96
+ }
97
+ newViewProps.hybridRef.isDirty = false;
98
+ }
99
+
100
+ // 4. Continue in base class
101
+ [super updateProps:props oldProps:oldProps];
102
+ }
103
+
104
+ + (BOOL)shouldBeRecycled {
105
+ return Yolo::YoloAutolinking::isYoloRecyclable();
106
+ }
107
+
108
+ - (void)prepareForRecycle {
109
+ [super prepareForRecycle];
110
+ Yolo::HybridYoloSpec_cxx& swiftPart = _hybridView->getSwiftPart();
111
+ swiftPart.maybePrepareForRecycle();
112
+ }
113
+
114
+ #ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
115
+ - (void)invalidate {
116
+ Yolo::HybridYoloSpec_cxx& swiftPart = _hybridView->getSwiftPart();
117
+ swiftPart.onDropView();
118
+ [super invalidate];
119
+ }
120
+ #endif
121
+
122
+ @end
@@ -8,13 +8,12 @@
8
8
  import NitroModules
9
9
 
10
10
  /// See ``HybridYoloSpec``
11
- public protocol HybridYoloSpec_protocol: HybridObject {
11
+ public protocol HybridYoloSpec_protocol: HybridObject, HybridView {
12
12
  // Properties
13
-
13
+ var isRed: Bool { get set }
14
14
 
15
15
  // Methods
16
- func sum(num1: Double, num2: Double) throws -> Double
17
- func subtract(num1: Double, num2: Double) throws -> Double
16
+
18
17
  }
19
18
 
20
19
  public extension HybridYoloSpec_protocol {
@@ -121,30 +121,36 @@ open class HybridYoloSpec_cxx {
121
121
  }
122
122
 
123
123
  // Properties
124
-
124
+ public final var isRed: Bool {
125
+ @inline(__always)
126
+ get {
127
+ return self.__implementation.isRed
128
+ }
129
+ @inline(__always)
130
+ set {
131
+ self.__implementation.isRed = newValue
132
+ }
133
+ }
125
134
 
126
135
  // Methods
127
- @inline(__always)
128
- public final func sum(num1: Double, num2: Double) -> bridge.Result_double_ {
129
- do {
130
- let __result = try self.__implementation.sum(num1: num1, num2: num2)
131
- let __resultCpp = __result
132
- return bridge.create_Result_double_(__resultCpp)
133
- } catch (let __error) {
134
- let __exceptionPtr = __error.toCpp()
135
- return bridge.create_Result_double_(__exceptionPtr)
136
- }
136
+ public final func getView() -> UnsafeMutableRawPointer {
137
+ return Unmanaged.passRetained(__implementation.view).toOpaque()
137
138
  }
138
139
 
139
- @inline(__always)
140
- public final func subtract(num1: Double, num2: Double) -> bridge.Result_double_ {
141
- do {
142
- let __result = try self.__implementation.subtract(num1: num1, num2: num2)
143
- let __resultCpp = __result
144
- return bridge.create_Result_double_(__resultCpp)
145
- } catch (let __error) {
146
- let __exceptionPtr = __error.toCpp()
147
- return bridge.create_Result_double_(__exceptionPtr)
148
- }
140
+ public final func beforeUpdate() {
141
+ __implementation.beforeUpdate()
142
+ }
143
+
144
+ public final func afterUpdate() {
145
+ __implementation.afterUpdate()
146
+ }
147
+
148
+ public final func maybePrepareForRecycle() {
149
+ guard let recyclable = __implementation as? any RecyclableView else { return }
150
+ recyclable.prepareForRecycle()
151
+ }
152
+
153
+ public final func onDropView() {
154
+ __implementation.onDropView()
149
155
  }
150
156
  }
@@ -14,8 +14,8 @@ namespace margelo::nitro::yolo {
14
14
  HybridObject::loadHybridMethods();
15
15
  // load custom methods/properties
16
16
  registerHybrids(this, [](Prototype& prototype) {
17
- prototype.registerHybridMethod("sum", &HybridYoloSpec::sum);
18
- prototype.registerHybridMethod("subtract", &HybridYoloSpec::subtract);
17
+ prototype.registerHybridGetter("isRed", &HybridYoloSpec::getIsRed);
18
+ prototype.registerHybridSetter("isRed", &HybridYoloSpec::setIsRed);
19
19
  });
20
20
  }
21
21
 
@@ -44,12 +44,12 @@ namespace margelo::nitro::yolo {
44
44
 
45
45
  public:
46
46
  // Properties
47
-
47
+ virtual bool getIsRed() = 0;
48
+ virtual void setIsRed(bool isRed) = 0;
48
49
 
49
50
  public:
50
51
  // Methods
51
- virtual double sum(double num1, double num2) = 0;
52
- virtual double subtract(double num1, double num2) = 0;
52
+
53
53
 
54
54
  protected:
55
55
  // Hybrid Setup
@@ -0,0 +1,83 @@
1
+ ///
2
+ /// HybridYoloComponent.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridYoloComponent.hpp"
9
+
10
+ #include <string>
11
+ #include <exception>
12
+ #include <utility>
13
+ #include <NitroModules/NitroDefines.hpp>
14
+ #include <NitroModules/JSIConverter.hpp>
15
+ #include <NitroModules/PropNameIDCache.hpp>
16
+ #include <react/renderer/core/RawValue.h>
17
+ #include <react/renderer/core/ShadowNode.h>
18
+ #include <react/renderer/core/ComponentDescriptor.h>
19
+ #include <react/renderer/components/view/ViewProps.h>
20
+
21
+ namespace margelo::nitro::yolo::views {
22
+
23
+ extern const char HybridYoloComponentName[] = "Yolo";
24
+
25
+ HybridYoloProps::HybridYoloProps(const react::PropsParserContext& context,
26
+ const HybridYoloProps& sourceProps,
27
+ const react::RawProps& rawProps):
28
+ react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
29
+ isRed([&]() -> CachedProp<bool> {
30
+ try {
31
+ const react::RawValue* rawValue = rawProps.at("isRed", nullptr, nullptr);
32
+ if (rawValue == nullptr) return sourceProps.isRed;
33
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
34
+ return CachedProp<bool>::fromRawValue(*runtime, value, sourceProps.isRed);
35
+ } catch (const std::exception& exc) {
36
+ throw std::runtime_error(std::string("Yolo.isRed: ") + exc.what());
37
+ }
38
+ }()),
39
+ hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridYoloSpec>& /* ref */)>>> {
40
+ try {
41
+ const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
42
+ if (rawValue == nullptr) return sourceProps.hybridRef;
43
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
44
+ return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridYoloSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
45
+ } catch (const std::exception& exc) {
46
+ throw std::runtime_error(std::string("Yolo.hybridRef: ") + exc.what());
47
+ }
48
+ }()) { }
49
+
50
+ bool HybridYoloProps::filterObjectKeys(const std::string& propName) {
51
+ switch (hashString(propName)) {
52
+ case hashString("isRed"): return true;
53
+ case hashString("hybridRef"): return true;
54
+ default: return false;
55
+ }
56
+ }
57
+
58
+ HybridYoloComponentDescriptor::HybridYoloComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
59
+ : ConcreteComponentDescriptor(parameters,
60
+ react::RawPropsParser(/* enableJsiParser */ true)) {}
61
+
62
+ std::shared_ptr<const react::Props> HybridYoloComponentDescriptor::cloneProps(const react::PropsParserContext& context,
63
+ const std::shared_ptr<const react::Props>& props,
64
+ react::RawProps rawProps) const {
65
+ // 1. Prepare raw props parser
66
+ rawProps.parse(rawPropsParser_);
67
+ // 2. Copy props with Nitro's cached copy constructor
68
+ return HybridYoloShadowNode::Props(context, /* & */ rawProps, props);
69
+ }
70
+
71
+ #ifdef ANDROID
72
+ void HybridYoloComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
73
+ // This is called immediately after `ShadowNode` is created, cloned or in progress.
74
+ // On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
75
+ auto& concreteShadowNode = static_cast<HybridYoloShadowNode&>(shadowNode);
76
+ const std::shared_ptr<const HybridYoloProps>& constProps = concreteShadowNode.getConcreteSharedProps();
77
+ const std::shared_ptr<HybridYoloProps>& props = std::const_pointer_cast<HybridYoloProps>(constProps);
78
+ HybridYoloState state{props};
79
+ concreteShadowNode.setStateData(std::move(state));
80
+ }
81
+ #endif
82
+
83
+ } // namespace margelo::nitro::yolo::views
@@ -0,0 +1,110 @@
1
+ ///
2
+ /// HybridYoloComponent.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <optional>
11
+ #include <NitroModules/NitroDefines.hpp>
12
+ #include <NitroModules/NitroHash.hpp>
13
+ #include <NitroModules/CachedProp.hpp>
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+ #include <react/renderer/core/PropsParserContext.h>
16
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
+ #include <react/renderer/components/view/ViewProps.h>
18
+
19
+ #include <memory>
20
+ #include "HybridYoloSpec.hpp"
21
+ #include <functional>
22
+ #include <optional>
23
+
24
+ namespace margelo::nitro::yolo::views {
25
+
26
+ using namespace facebook;
27
+
28
+ /**
29
+ * The name of the actual native View.
30
+ */
31
+ extern const char HybridYoloComponentName[];
32
+
33
+ /**
34
+ * Props for the "Yolo" View.
35
+ */
36
+ class HybridYoloProps final: public react::ViewProps {
37
+ public:
38
+ HybridYoloProps() = default;
39
+ HybridYoloProps(const react::PropsParserContext& context,
40
+ const HybridYoloProps& sourceProps,
41
+ const react::RawProps& rawProps);
42
+
43
+ public:
44
+ CachedProp<bool> isRed;
45
+ CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridYoloSpec>& /* ref */)>>> hybridRef;
46
+
47
+ private:
48
+ static bool filterObjectKeys(const std::string& propName);
49
+ };
50
+
51
+ /**
52
+ * State for the "Yolo" View.
53
+ */
54
+ class HybridYoloState final {
55
+ public:
56
+ HybridYoloState() = default;
57
+ explicit HybridYoloState(const std::shared_ptr<HybridYoloProps>& props):
58
+ _props(props) {}
59
+
60
+ public:
61
+ [[nodiscard]]
62
+ const std::shared_ptr<HybridYoloProps>& getProps() const {
63
+ return _props;
64
+ }
65
+
66
+ public:
67
+ #ifdef ANDROID
68
+ HybridYoloState(const HybridYoloState& /* previousState */, folly::dynamic /* data */) {}
69
+ folly::dynamic getDynamic() const {
70
+ throw std::runtime_error("HybridYoloState does not support folly!");
71
+ }
72
+ react::MapBuffer getMapBuffer() const {
73
+ throw std::runtime_error("HybridYoloState does not support MapBuffer!");
74
+ };
75
+ #endif
76
+
77
+ private:
78
+ std::shared_ptr<HybridYoloProps> _props;
79
+ };
80
+
81
+ /**
82
+ * The Shadow Node for the "Yolo" View.
83
+ */
84
+ using HybridYoloShadowNode = react::ConcreteViewShadowNode<HybridYoloComponentName /* "HybridYolo" */,
85
+ HybridYoloProps /* custom props */,
86
+ react::ViewEventEmitter /* default */,
87
+ HybridYoloState /* custom state */>;
88
+
89
+ /**
90
+ * The Component Descriptor for the "Yolo" View.
91
+ */
92
+ class HybridYoloComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridYoloShadowNode> {
93
+ public:
94
+ explicit HybridYoloComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
95
+
96
+ public:
97
+ /**
98
+ * A faster path for cloning props - reuses the caching logic from `HybridYoloProps`.
99
+ */
100
+ std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
101
+ const std::shared_ptr<const react::Props>& props,
102
+ react::RawProps rawProps) const override;
103
+ #ifdef ANDROID
104
+ void adopt(react::ShadowNode& shadowNode) const override;
105
+ #endif
106
+ };
107
+
108
+ /* The actual view for "Yolo" needs to be implemented in platform-specific code. */
109
+
110
+ } // namespace margelo::nitro::yolo::views
@@ -0,0 +1,10 @@
1
+ {
2
+ "uiViewClassName": "Yolo",
3
+ "supportsRawText": false,
4
+ "bubblingEventTypes": {},
5
+ "directEventTypes": {},
6
+ "validAttributes": {
7
+ "isRed": true,
8
+ "hybridRef": true
9
+ }
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-yolo",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "react-native-yolo is a react native package built with Nitro",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/module/index.js",
@@ -119,4 +119,4 @@
119
119
  ]
120
120
  ]
121
121
  }
122
- }
122
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,14 @@
1
- import { NitroModules } from 'react-native-nitro-modules'
2
- import type { Yolo as YoloSpec } from './specs/yolo.nitro'
1
+ import { getHostComponent, type HybridRef } from 'react-native-nitro-modules'
2
+ import YoloConfig from '../nitrogen/generated/shared/json/YoloConfig.json'
3
+ import type {
4
+ YoloProps,
5
+ YoloMethods,
6
+ } from './specs/yolo.nitro'
3
7
 
4
- export const Yolo =
5
- NitroModules.createHybridObject<YoloSpec>('Yolo')
8
+
9
+ export const Yolo = getHostComponent<YoloProps, YoloMethods>(
10
+ 'Yolo',
11
+ () => YoloConfig
12
+ )
13
+
14
+ export type YoloRef = HybridRef<YoloProps, YoloMethods>
@@ -1,6 +1,13 @@
1
- import type { HybridObject } from 'react-native-nitro-modules'
1
+ import type {
2
+ HybridView,
3
+ HybridViewProps,
4
+ HybridViewMethods,
5
+ } from 'react-native-nitro-modules'
2
6
 
3
- export interface Yolo extends HybridObject<{ ios: 'swift', android: 'kotlin' }> {
4
- sum(num1: number, num2: number): number
5
- subtract(num1: number, num2: number): number
6
- }
7
+ export interface YoloProps extends HybridViewProps {
8
+ isRed: boolean
9
+ }
10
+
11
+ export interface YoloMethods extends HybridViewMethods {}
12
+
13
+ export type Yolo = HybridView<YoloProps, YoloMethods, { ios: 'swift', android: 'kotlin' }>