@rive-app/react-native 0.2.2 → 0.2.4

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 (44) hide show
  1. package/android/build.gradle +4 -1
  2. package/android/src/main/AndroidManifest.xml +2 -12
  3. package/android/src/main/java/com/margelo/nitro/rive/HybridRiveRuntime.kt +26 -0
  4. package/android/src/main/java/com/rive/RiveInitializer.kt +64 -0
  5. package/android/src/main/java/com/rive/RivePackage.kt +17 -10
  6. package/android/src/main/java/com/rive/RiveReactNativeView.kt +70 -52
  7. package/ios/HybridRiveRuntime.swift +11 -0
  8. package/ios/RiveReactNativeView.swift +17 -19
  9. package/lib/module/core/RiveRuntime.js +22 -0
  10. package/lib/module/core/RiveRuntime.js.map +1 -0
  11. package/lib/module/hooks/useRiveProperty.js +3 -3
  12. package/lib/module/hooks/useRiveProperty.js.map +1 -1
  13. package/lib/module/index.js +1 -0
  14. package/lib/module/index.js.map +1 -1
  15. package/lib/module/specs/RiveRuntime.nitro.js +4 -0
  16. package/lib/module/specs/RiveRuntime.nitro.js.map +1 -0
  17. package/lib/typescript/src/core/RiveRuntime.d.ts +8 -0
  18. package/lib/typescript/src/core/RiveRuntime.d.ts.map +1 -0
  19. package/lib/typescript/src/hooks/useRiveProperty.d.ts.map +1 -1
  20. package/lib/typescript/src/index.d.ts +1 -0
  21. package/lib/typescript/src/index.d.ts.map +1 -1
  22. package/lib/typescript/src/specs/RiveRuntime.nitro.d.ts +10 -0
  23. package/lib/typescript/src/specs/RiveRuntime.nitro.d.ts.map +1 -0
  24. package/nitrogen/generated/android/c++/JHybridRiveRuntimeSpec.cpp +82 -0
  25. package/nitrogen/generated/android/c++/JHybridRiveRuntimeSpec.hpp +67 -0
  26. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rive/HybridRiveRuntimeSpec.kt +64 -0
  27. package/nitrogen/generated/android/rive+autolinking.cmake +2 -0
  28. package/nitrogen/generated/android/riveOnLoad.cpp +10 -0
  29. package/nitrogen/generated/ios/RNRive-Swift-Cxx-Bridge.cpp +25 -8
  30. package/nitrogen/generated/ios/RNRive-Swift-Cxx-Bridge.hpp +60 -43
  31. package/nitrogen/generated/ios/RNRive-Swift-Cxx-Umbrella.hpp +5 -0
  32. package/nitrogen/generated/ios/RNRiveAutolinking.mm +8 -0
  33. package/nitrogen/generated/ios/RNRiveAutolinking.swift +12 -0
  34. package/nitrogen/generated/ios/c++/HybridRiveRuntimeSpecSwift.cpp +11 -0
  35. package/nitrogen/generated/ios/c++/HybridRiveRuntimeSpecSwift.hpp +90 -0
  36. package/nitrogen/generated/ios/swift/HybridRiveRuntimeSpec.swift +57 -0
  37. package/nitrogen/generated/ios/swift/HybridRiveRuntimeSpec_cxx.swift +164 -0
  38. package/nitrogen/generated/shared/c++/HybridRiveRuntimeSpec.cpp +23 -0
  39. package/nitrogen/generated/shared/c++/HybridRiveRuntimeSpec.hpp +65 -0
  40. package/package.json +1 -1
  41. package/src/core/RiveRuntime.ts +23 -0
  42. package/src/hooks/useRiveProperty.ts +3 -7
  43. package/src/index.tsx +1 -0
  44. package/src/specs/RiveRuntime.nitro.ts +8 -0
@@ -0,0 +1,67 @@
1
+ ///
2
+ /// HybridRiveRuntimeSpec.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 <NitroModules/JHybridObject.hpp>
11
+ #include <fbjni/fbjni.h>
12
+ #include "HybridRiveRuntimeSpec.hpp"
13
+
14
+
15
+
16
+
17
+ namespace margelo::nitro::rive {
18
+
19
+ using namespace facebook;
20
+
21
+ class JHybridRiveRuntimeSpec: public jni::HybridClass<JHybridRiveRuntimeSpec, JHybridObject>,
22
+ public virtual HybridRiveRuntimeSpec {
23
+ public:
24
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/rive/HybridRiveRuntimeSpec;";
25
+ static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
26
+ static void registerNatives();
27
+
28
+ protected:
29
+ // C++ constructor (called from Java via `initHybrid()`)
30
+ explicit JHybridRiveRuntimeSpec(jni::alias_ref<jhybridobject> jThis) :
31
+ HybridObject(HybridRiveRuntimeSpec::TAG),
32
+ HybridBase(jThis),
33
+ _javaPart(jni::make_global(jThis)) {}
34
+
35
+ public:
36
+ ~JHybridRiveRuntimeSpec() override {
37
+ // Hermes GC can destroy JS objects on a non-JNI Thread.
38
+ jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
39
+ }
40
+
41
+ public:
42
+ size_t getExternalMemorySize() noexcept override;
43
+ bool equals(const std::shared_ptr<HybridObject>& other) override;
44
+ void dispose() noexcept override;
45
+ std::string toString() override;
46
+
47
+ public:
48
+ inline const jni::global_ref<JHybridRiveRuntimeSpec::javaobject>& getJavaPart() const noexcept {
49
+ return _javaPart;
50
+ }
51
+
52
+ public:
53
+ // Properties
54
+ bool getIsInitialized() override;
55
+ std::optional<std::string> getInitError() override;
56
+
57
+ public:
58
+ // Methods
59
+ std::shared_ptr<Promise<void>> initialize() override;
60
+
61
+ private:
62
+ friend HybridBase;
63
+ using HybridBase::HybridBase;
64
+ jni::global_ref<JHybridRiveRuntimeSpec::javaobject> _javaPart;
65
+ };
66
+
67
+ } // namespace margelo::nitro::rive
@@ -0,0 +1,64 @@
1
+ ///
2
+ /// HybridRiveRuntimeSpec.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.rive
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import com.margelo.nitro.core.Promise
14
+ import com.margelo.nitro.core.HybridObject
15
+
16
+ /**
17
+ * A Kotlin class representing the RiveRuntime HybridObject.
18
+ * Implement this abstract class to create Kotlin-based instances of RiveRuntime.
19
+ */
20
+ @DoNotStrip
21
+ @Keep
22
+ @Suppress(
23
+ "KotlinJniMissingFunction", "unused",
24
+ "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
25
+ "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
26
+ )
27
+ abstract class HybridRiveRuntimeSpec: HybridObject() {
28
+ @DoNotStrip
29
+ private var mHybridData: HybridData = initHybrid()
30
+
31
+ init {
32
+ super.updateNative(mHybridData)
33
+ }
34
+
35
+ override fun updateNative(hybridData: HybridData) {
36
+ mHybridData = hybridData
37
+ super.updateNative(hybridData)
38
+ }
39
+
40
+ // Default implementation of `HybridObject.toString()`
41
+ override fun toString(): String {
42
+ return "[HybridObject RiveRuntime]"
43
+ }
44
+
45
+ // Properties
46
+ @get:DoNotStrip
47
+ @get:Keep
48
+ abstract val isInitialized: Boolean
49
+
50
+ @get:DoNotStrip
51
+ @get:Keep
52
+ abstract val initError: String?
53
+
54
+ // Methods
55
+ @DoNotStrip
56
+ @Keep
57
+ abstract fun initialize(): Promise<Unit>
58
+
59
+ private external fun initHybrid(): HybridData
60
+
61
+ companion object {
62
+ protected const val TAG = "HybridRiveRuntimeSpec"
63
+ }
64
+ }
@@ -39,6 +39,7 @@ target_sources(
39
39
  ../nitrogen/generated/shared/c++/HybridRiveFileFactorySpec.cpp
40
40
  ../nitrogen/generated/shared/c++/HybridRiveImageSpec.cpp
41
41
  ../nitrogen/generated/shared/c++/HybridRiveImageFactorySpec.cpp
42
+ ../nitrogen/generated/shared/c++/HybridRiveRuntimeSpec.cpp
42
43
  ../nitrogen/generated/shared/c++/HybridRiveViewSpec.cpp
43
44
  ../nitrogen/generated/shared/c++/views/HybridRiveViewComponent.cpp
44
45
  ../nitrogen/generated/shared/c++/HybridViewModelSpec.cpp
@@ -60,6 +61,7 @@ target_sources(
60
61
  ../nitrogen/generated/android/c++/JHybridRiveFileFactorySpec.cpp
61
62
  ../nitrogen/generated/android/c++/JHybridRiveImageSpec.cpp
62
63
  ../nitrogen/generated/android/c++/JHybridRiveImageFactorySpec.cpp
64
+ ../nitrogen/generated/android/c++/JHybridRiveRuntimeSpec.cpp
63
65
  ../nitrogen/generated/android/c++/JHybridRiveViewSpec.cpp
64
66
  ../nitrogen/generated/android/c++/JVariant_HybridViewModelInstanceSpec_DataBindMode_DataBindByName.cpp
65
67
  ../nitrogen/generated/android/c++/JEventPropertiesOutput.cpp
@@ -21,6 +21,7 @@
21
21
  #include "JHybridRiveFileFactorySpec.hpp"
22
22
  #include "JHybridRiveImageSpec.hpp"
23
23
  #include "JHybridRiveImageFactorySpec.hpp"
24
+ #include "JHybridRiveRuntimeSpec.hpp"
24
25
  #include "JHybridRiveViewSpec.hpp"
25
26
  #include "JFunc_void_RiveError.hpp"
26
27
  #include "JFunc_void_UnifiedRiveEvent.hpp"
@@ -58,6 +59,7 @@ int initialize(JavaVM* vm) {
58
59
  margelo::nitro::rive::JHybridRiveFileFactorySpec::registerNatives();
59
60
  margelo::nitro::rive::JHybridRiveImageSpec::registerNatives();
60
61
  margelo::nitro::rive::JHybridRiveImageFactorySpec::registerNatives();
62
+ margelo::nitro::rive::JHybridRiveRuntimeSpec::registerNatives();
61
63
  margelo::nitro::rive::JHybridRiveViewSpec::registerNatives();
62
64
  margelo::nitro::rive::JFunc_void_RiveError_cxx::registerNatives();
63
65
  margelo::nitro::rive::JFunc_void_UnifiedRiveEvent_cxx::registerNatives();
@@ -120,6 +122,14 @@ int initialize(JavaVM* vm) {
120
122
  return instance->cthis()->shared();
121
123
  }
122
124
  );
125
+ HybridObjectRegistry::registerHybridObjectConstructor(
126
+ "RiveRuntime",
127
+ []() -> std::shared_ptr<HybridObject> {
128
+ static DefaultConstructableObject<JHybridRiveRuntimeSpec::javaobject> object("com/margelo/nitro/rive/HybridRiveRuntime");
129
+ auto instance = object.create();
130
+ return instance->cthis()->shared();
131
+ }
132
+ );
123
133
  });
124
134
  }
125
135
 
@@ -13,6 +13,7 @@
13
13
  #include "HybridRiveFileSpecSwift.hpp"
14
14
  #include "HybridRiveImageFactorySpecSwift.hpp"
15
15
  #include "HybridRiveImageSpecSwift.hpp"
16
+ #include "HybridRiveRuntimeSpecSwift.hpp"
16
17
  #include "HybridRiveSpecSwift.hpp"
17
18
  #include "HybridRiveViewSpecSwift.hpp"
18
19
  #include "HybridViewModelArtboardPropertySpecSwift.hpp"
@@ -168,6 +169,30 @@ namespace margelo::nitro::rive::bridge::swift {
168
169
  return swiftPart.toUnsafe();
169
170
  }
170
171
 
172
+ // pragma MARK: std::function<void()>
173
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
174
+ auto swiftClosure = RNRive::Func_void::fromUnsafe(swiftClosureWrapper);
175
+ return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
176
+ swiftClosure.call();
177
+ };
178
+ }
179
+
180
+ // pragma MARK: std::shared_ptr<HybridRiveRuntimeSpec>
181
+ std::shared_ptr<HybridRiveRuntimeSpec> create_std__shared_ptr_HybridRiveRuntimeSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
182
+ RNRive::HybridRiveRuntimeSpec_cxx swiftPart = RNRive::HybridRiveRuntimeSpec_cxx::fromUnsafe(swiftUnsafePointer);
183
+ return std::make_shared<margelo::nitro::rive::HybridRiveRuntimeSpecSwift>(swiftPart);
184
+ }
185
+ void* NON_NULL get_std__shared_ptr_HybridRiveRuntimeSpec_(std__shared_ptr_HybridRiveRuntimeSpec_ cppType) {
186
+ std::shared_ptr<margelo::nitro::rive::HybridRiveRuntimeSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::rive::HybridRiveRuntimeSpecSwift>(cppType);
187
+ #ifdef NITRO_DEBUG
188
+ if (swiftWrapper == nullptr) [[unlikely]] {
189
+ throw std::runtime_error("Class \"HybridRiveRuntimeSpec\" is not implemented in Swift!");
190
+ }
191
+ #endif
192
+ RNRive::HybridRiveRuntimeSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
193
+ return swiftPart.toUnsafe();
194
+ }
195
+
171
196
  // pragma MARK: std::shared_ptr<HybridViewModelInstanceSpec>
172
197
  std::shared_ptr<HybridViewModelInstanceSpec> create_std__shared_ptr_HybridViewModelInstanceSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
173
198
  RNRive::HybridViewModelInstanceSpec_cxx swiftPart = RNRive::HybridViewModelInstanceSpec_cxx::fromUnsafe(swiftUnsafePointer);
@@ -200,14 +225,6 @@ namespace margelo::nitro::rive::bridge::swift {
200
225
  };
201
226
  }
202
227
 
203
- // pragma MARK: std::function<void()>
204
- Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
205
- auto swiftClosure = RNRive::Func_void::fromUnsafe(swiftClosureWrapper);
206
- return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
207
- swiftClosure.call();
208
- };
209
- }
210
-
211
228
  // pragma MARK: std::function<void(const UnifiedRiveEvent& /* event */)>
212
229
  Func_void_UnifiedRiveEvent create_Func_void_UnifiedRiveEvent(void* NON_NULL swiftClosureWrapper) noexcept {
213
230
  auto swiftClosure = RNRive::Func_void_UnifiedRiveEvent::fromUnsafe(swiftClosureWrapper);
@@ -30,6 +30,8 @@ namespace margelo::nitro::rive { class HybridRiveFileSpec; }
30
30
  namespace margelo::nitro::rive { class HybridRiveImageFactorySpec; }
31
31
  // Forward declaration of `HybridRiveImageSpec` to properly resolve imports.
32
32
  namespace margelo::nitro::rive { class HybridRiveImageSpec; }
33
+ // Forward declaration of `HybridRiveRuntimeSpec` to properly resolve imports.
34
+ namespace margelo::nitro::rive { class HybridRiveRuntimeSpec; }
33
35
  // Forward declaration of `HybridRiveSpec` to properly resolve imports.
34
36
  namespace margelo::nitro::rive { class HybridRiveSpec; }
35
37
  // Forward declaration of `HybridRiveViewSpec` to properly resolve imports.
@@ -82,6 +84,8 @@ namespace RNRive { class HybridRiveFileSpec_cxx; }
82
84
  namespace RNRive { class HybridRiveImageFactorySpec_cxx; }
83
85
  // Forward declaration of `HybridRiveImageSpec_cxx` to properly resolve imports.
84
86
  namespace RNRive { class HybridRiveImageSpec_cxx; }
87
+ // Forward declaration of `HybridRiveRuntimeSpec_cxx` to properly resolve imports.
88
+ namespace RNRive { class HybridRiveRuntimeSpec_cxx; }
85
89
  // Forward declaration of `HybridRiveSpec_cxx` to properly resolve imports.
86
90
  namespace RNRive { class HybridRiveSpec_cxx; }
87
91
  // Forward declaration of `HybridRiveViewSpec_cxx` to properly resolve imports.
@@ -123,6 +127,7 @@ namespace RNRive { class HybridViewModelTriggerPropertySpec_cxx; }
123
127
  #include "HybridRiveFileSpec.hpp"
124
128
  #include "HybridRiveImageFactorySpec.hpp"
125
129
  #include "HybridRiveImageSpec.hpp"
130
+ #include "HybridRiveRuntimeSpec.hpp"
126
131
  #include "HybridRiveSpec.hpp"
127
132
  #include "HybridRiveViewSpec.hpp"
128
133
  #include "HybridViewModelArtboardPropertySpec.hpp"
@@ -530,6 +535,61 @@ namespace margelo::nitro::rive::bridge::swift {
530
535
  return Result<std::shared_ptr<Promise<std::shared_ptr<HybridRiveImageSpec>>>>::withError(error);
531
536
  }
532
537
 
538
+ // pragma MARK: std::shared_ptr<Promise<void>>
539
+ /**
540
+ * Specialized version of `std::shared_ptr<Promise<void>>`.
541
+ */
542
+ using std__shared_ptr_Promise_void__ = std::shared_ptr<Promise<void>>;
543
+ inline std::shared_ptr<Promise<void>> create_std__shared_ptr_Promise_void__() noexcept {
544
+ return Promise<void>::create();
545
+ }
546
+ inline PromiseHolder<void> wrap_std__shared_ptr_Promise_void__(std::shared_ptr<Promise<void>> promise) noexcept {
547
+ return PromiseHolder<void>(std::move(promise));
548
+ }
549
+
550
+ // pragma MARK: std::function<void()>
551
+ /**
552
+ * Specialized version of `std::function<void()>`.
553
+ */
554
+ using Func_void = std::function<void()>;
555
+ /**
556
+ * Wrapper class for a `std::function<void()>`, this can be used from Swift.
557
+ */
558
+ class Func_void_Wrapper final {
559
+ public:
560
+ explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
561
+ inline void call() const noexcept {
562
+ _function->operator()();
563
+ }
564
+ private:
565
+ std::unique_ptr<std::function<void()>> _function;
566
+ } SWIFT_NONCOPYABLE;
567
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
568
+ inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
569
+ return Func_void_Wrapper(std::move(value));
570
+ }
571
+
572
+ // pragma MARK: std::shared_ptr<HybridRiveRuntimeSpec>
573
+ /**
574
+ * Specialized version of `std::shared_ptr<HybridRiveRuntimeSpec>`.
575
+ */
576
+ using std__shared_ptr_HybridRiveRuntimeSpec_ = std::shared_ptr<HybridRiveRuntimeSpec>;
577
+ std::shared_ptr<HybridRiveRuntimeSpec> create_std__shared_ptr_HybridRiveRuntimeSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
578
+ void* NON_NULL get_std__shared_ptr_HybridRiveRuntimeSpec_(std__shared_ptr_HybridRiveRuntimeSpec_ cppType);
579
+
580
+ // pragma MARK: std::weak_ptr<HybridRiveRuntimeSpec>
581
+ using std__weak_ptr_HybridRiveRuntimeSpec_ = std::weak_ptr<HybridRiveRuntimeSpec>;
582
+ inline std__weak_ptr_HybridRiveRuntimeSpec_ weakify_std__shared_ptr_HybridRiveRuntimeSpec_(const std::shared_ptr<HybridRiveRuntimeSpec>& strong) noexcept { return strong; }
583
+
584
+ // pragma MARK: Result<std::shared_ptr<Promise<void>>>
585
+ using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
586
+ inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) noexcept {
587
+ return Result<std::shared_ptr<Promise<void>>>::withValue(value);
588
+ }
589
+ inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::exception_ptr& error) noexcept {
590
+ return Result<std::shared_ptr<Promise<void>>>::withError(error);
591
+ }
592
+
533
593
  // pragma MARK: std::optional<bool>
534
594
  /**
535
595
  * Specialized version of `std::optional<bool>`.
@@ -708,40 +768,6 @@ namespace margelo::nitro::rive::bridge::swift {
708
768
  return *optional;
709
769
  }
710
770
 
711
- // pragma MARK: std::shared_ptr<Promise<void>>
712
- /**
713
- * Specialized version of `std::shared_ptr<Promise<void>>`.
714
- */
715
- using std__shared_ptr_Promise_void__ = std::shared_ptr<Promise<void>>;
716
- inline std::shared_ptr<Promise<void>> create_std__shared_ptr_Promise_void__() noexcept {
717
- return Promise<void>::create();
718
- }
719
- inline PromiseHolder<void> wrap_std__shared_ptr_Promise_void__(std::shared_ptr<Promise<void>> promise) noexcept {
720
- return PromiseHolder<void>(std::move(promise));
721
- }
722
-
723
- // pragma MARK: std::function<void()>
724
- /**
725
- * Specialized version of `std::function<void()>`.
726
- */
727
- using Func_void = std::function<void()>;
728
- /**
729
- * Wrapper class for a `std::function<void()>`, this can be used from Swift.
730
- */
731
- class Func_void_Wrapper final {
732
- public:
733
- explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
734
- inline void call() const noexcept {
735
- _function->operator()();
736
- }
737
- private:
738
- std::unique_ptr<std::function<void()>> _function;
739
- } SWIFT_NONCOPYABLE;
740
- Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
741
- inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
742
- return Func_void_Wrapper(std::move(value));
743
- }
744
-
745
771
  // pragma MARK: std::variant<bool, std::string, double>
746
772
  /**
747
773
  * Wrapper struct for `std::variant<bool, std::string, double>`.
@@ -869,15 +895,6 @@ namespace margelo::nitro::rive::bridge::swift {
869
895
  return Result<std::optional<std::shared_ptr<HybridViewModelInstanceSpec>>>::withError(error);
870
896
  }
871
897
 
872
- // pragma MARK: Result<std::shared_ptr<Promise<void>>>
873
- using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
874
- inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) noexcept {
875
- return Result<std::shared_ptr<Promise<void>>>::withValue(value);
876
- }
877
- inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::exception_ptr& error) noexcept {
878
- return Result<std::shared_ptr<Promise<void>>>::withError(error);
879
- }
880
-
881
898
  // pragma MARK: Result<bool>
882
899
  using Result_bool_ = Result<bool>;
883
900
  inline Result_bool_ create_Result_bool_(bool value) noexcept {
@@ -30,6 +30,8 @@ namespace margelo::nitro::rive { class HybridRiveFileSpec; }
30
30
  namespace margelo::nitro::rive { class HybridRiveImageFactorySpec; }
31
31
  // Forward declaration of `HybridRiveImageSpec` to properly resolve imports.
32
32
  namespace margelo::nitro::rive { class HybridRiveImageSpec; }
33
+ // Forward declaration of `HybridRiveRuntimeSpec` to properly resolve imports.
34
+ namespace margelo::nitro::rive { class HybridRiveRuntimeSpec; }
33
35
  // Forward declaration of `HybridRiveSpec` to properly resolve imports.
34
36
  namespace margelo::nitro::rive { class HybridRiveSpec; }
35
37
  // Forward declaration of `HybridRiveViewSpec` to properly resolve imports.
@@ -83,6 +85,7 @@ namespace margelo::nitro::rive { struct UnifiedRiveEvent; }
83
85
  #include "HybridRiveFileSpec.hpp"
84
86
  #include "HybridRiveImageFactorySpec.hpp"
85
87
  #include "HybridRiveImageSpec.hpp"
88
+ #include "HybridRiveRuntimeSpec.hpp"
86
89
  #include "HybridRiveSpec.hpp"
87
90
  #include "HybridRiveViewSpec.hpp"
88
91
  #include "HybridViewModelArtboardPropertySpec.hpp"
@@ -135,6 +138,8 @@ namespace RNRive { class HybridRiveFileSpec_cxx; }
135
138
  namespace RNRive { class HybridRiveImageFactorySpec_cxx; }
136
139
  // Forward declaration of `HybridRiveImageSpec_cxx` to properly resolve imports.
137
140
  namespace RNRive { class HybridRiveImageSpec_cxx; }
141
+ // Forward declaration of `HybridRiveRuntimeSpec_cxx` to properly resolve imports.
142
+ namespace RNRive { class HybridRiveRuntimeSpec_cxx; }
138
143
  // Forward declaration of `HybridRiveSpec_cxx` to properly resolve imports.
139
144
  namespace RNRive { class HybridRiveSpec_cxx; }
140
145
  // Forward declaration of `HybridRiveViewSpec_cxx` to properly resolve imports.
@@ -15,6 +15,7 @@
15
15
  #include "HybridRiveFileSpecSwift.hpp"
16
16
  #include "HybridRiveViewSpecSwift.hpp"
17
17
  #include "HybridRiveImageFactorySpecSwift.hpp"
18
+ #include "HybridRiveRuntimeSpecSwift.hpp"
18
19
 
19
20
  @interface RNRiveAutolinking : NSObject
20
21
  @end
@@ -60,6 +61,13 @@
60
61
  return hybridObject;
61
62
  }
62
63
  );
64
+ HybridObjectRegistry::registerHybridObjectConstructor(
65
+ "RiveRuntime",
66
+ []() -> std::shared_ptr<HybridObject> {
67
+ std::shared_ptr<HybridRiveRuntimeSpec> hybridObject = RNRive::RNRiveAutolinking::createRiveRuntime();
68
+ return hybridObject;
69
+ }
70
+ );
63
71
  }
64
72
 
65
73
  @end
@@ -71,4 +71,16 @@ public final class RNRiveAutolinking {
71
71
  public static func isRiveImageFactoryRecyclable() -> Bool {
72
72
  return HybridRiveImageFactory.self is any RecyclableView.Type
73
73
  }
74
+
75
+ public static func createRiveRuntime() -> bridge.std__shared_ptr_HybridRiveRuntimeSpec_ {
76
+ let hybridObject = HybridRiveRuntime()
77
+ return { () -> bridge.std__shared_ptr_HybridRiveRuntimeSpec_ in
78
+ let __cxxWrapped = hybridObject.getCxxWrapper()
79
+ return __cxxWrapped.getCxxPart()
80
+ }()
81
+ }
82
+
83
+ public static func isRiveRuntimeRecyclable() -> Bool {
84
+ return HybridRiveRuntime.self is any RecyclableView.Type
85
+ }
74
86
  }
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridRiveRuntimeSpecSwift.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 "HybridRiveRuntimeSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::rive {
11
+ } // namespace margelo::nitro::rive
@@ -0,0 +1,90 @@
1
+ ///
2
+ /// HybridRiveRuntimeSpecSwift.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 "HybridRiveRuntimeSpec.hpp"
11
+
12
+ // Forward declaration of `HybridRiveRuntimeSpec_cxx` to properly resolve imports.
13
+ namespace RNRive { class HybridRiveRuntimeSpec_cxx; }
14
+
15
+
16
+
17
+ #include <string>
18
+ #include <optional>
19
+ #include <NitroModules/Promise.hpp>
20
+
21
+ #include "RNRive-Swift-Cxx-Umbrella.hpp"
22
+
23
+ namespace margelo::nitro::rive {
24
+
25
+ /**
26
+ * The C++ part of HybridRiveRuntimeSpec_cxx.swift.
27
+ *
28
+ * HybridRiveRuntimeSpecSwift (C++) accesses HybridRiveRuntimeSpec_cxx (Swift), and might
29
+ * contain some additional bridging code for C++ <> Swift interop.
30
+ *
31
+ * Since this obviously introduces an overhead, I hope at some point in
32
+ * the future, HybridRiveRuntimeSpec_cxx can directly inherit from the C++ class HybridRiveRuntimeSpec
33
+ * to simplify the whole structure and memory management.
34
+ */
35
+ class HybridRiveRuntimeSpecSwift: public virtual HybridRiveRuntimeSpec {
36
+ public:
37
+ // Constructor from a Swift instance
38
+ explicit HybridRiveRuntimeSpecSwift(const RNRive::HybridRiveRuntimeSpec_cxx& swiftPart):
39
+ HybridObject(HybridRiveRuntimeSpec::TAG),
40
+ _swiftPart(swiftPart) { }
41
+
42
+ public:
43
+ // Get the Swift part
44
+ inline RNRive::HybridRiveRuntimeSpec_cxx& getSwiftPart() noexcept {
45
+ return _swiftPart;
46
+ }
47
+
48
+ public:
49
+ inline size_t getExternalMemorySize() noexcept override {
50
+ return _swiftPart.getMemorySize();
51
+ }
52
+ bool equals(const std::shared_ptr<HybridObject>& other) override {
53
+ if (auto otherCast = std::dynamic_pointer_cast<HybridRiveRuntimeSpecSwift>(other)) {
54
+ return _swiftPart.equals(otherCast->_swiftPart);
55
+ }
56
+ return false;
57
+ }
58
+ void dispose() noexcept override {
59
+ _swiftPart.dispose();
60
+ }
61
+ std::string toString() override {
62
+ return _swiftPart.toString();
63
+ }
64
+
65
+ public:
66
+ // Properties
67
+ inline bool getIsInitialized() noexcept override {
68
+ return _swiftPart.isInitialized();
69
+ }
70
+ inline std::optional<std::string> getInitError() noexcept override {
71
+ auto __result = _swiftPart.getInitError();
72
+ return __result;
73
+ }
74
+
75
+ public:
76
+ // Methods
77
+ inline std::shared_ptr<Promise<void>> initialize() override {
78
+ auto __result = _swiftPart.initialize();
79
+ if (__result.hasError()) [[unlikely]] {
80
+ std::rethrow_exception(__result.error());
81
+ }
82
+ auto __value = std::move(__result.value());
83
+ return __value;
84
+ }
85
+
86
+ private:
87
+ RNRive::HybridRiveRuntimeSpec_cxx _swiftPart;
88
+ };
89
+
90
+ } // namespace margelo::nitro::rive
@@ -0,0 +1,57 @@
1
+ ///
2
+ /// HybridRiveRuntimeSpec.swift
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 Foundation
9
+ import NitroModules
10
+
11
+ /// See ``HybridRiveRuntimeSpec``
12
+ public protocol HybridRiveRuntimeSpec_protocol: HybridObject {
13
+ // Properties
14
+ var isInitialized: Bool { get }
15
+ var initError: String? { get }
16
+
17
+ // Methods
18
+ func initialize() throws -> Promise<Void>
19
+ }
20
+
21
+ public extension HybridRiveRuntimeSpec_protocol {
22
+ /// Default implementation of ``HybridObject.toString``
23
+ func toString() -> String {
24
+ return "[HybridObject RiveRuntime]"
25
+ }
26
+ }
27
+
28
+ /// See ``HybridRiveRuntimeSpec``
29
+ open class HybridRiveRuntimeSpec_base {
30
+ private weak var cxxWrapper: HybridRiveRuntimeSpec_cxx? = nil
31
+ public init() { }
32
+ public func getCxxWrapper() -> HybridRiveRuntimeSpec_cxx {
33
+ #if DEBUG
34
+ guard self is any HybridRiveRuntimeSpec else {
35
+ fatalError("`self` is not a `HybridRiveRuntimeSpec`! Did you accidentally inherit from `HybridRiveRuntimeSpec_base` instead of `HybridRiveRuntimeSpec`?")
36
+ }
37
+ #endif
38
+ if let cxxWrapper = self.cxxWrapper {
39
+ return cxxWrapper
40
+ } else {
41
+ let cxxWrapper = HybridRiveRuntimeSpec_cxx(self as! any HybridRiveRuntimeSpec)
42
+ self.cxxWrapper = cxxWrapper
43
+ return cxxWrapper
44
+ }
45
+ }
46
+ }
47
+
48
+ /**
49
+ * A Swift base-protocol representing the RiveRuntime HybridObject.
50
+ * Implement this protocol to create Swift-based instances of RiveRuntime.
51
+ * ```swift
52
+ * class HybridRiveRuntime : HybridRiveRuntimeSpec {
53
+ * // ...
54
+ * }
55
+ * ```
56
+ */
57
+ public typealias HybridRiveRuntimeSpec = HybridRiveRuntimeSpec_protocol & HybridRiveRuntimeSpec_base