@rive-app/react-native 0.2.3 → 0.2.5

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 (45) 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/margelo/nitro/rive/HybridRiveView.kt +2 -0
  5. package/android/src/main/java/com/rive/RiveInitializer.kt +64 -0
  6. package/android/src/main/java/com/rive/RivePackage.kt +17 -10
  7. package/android/src/main/java/com/rive/RiveReactNativeView.kt +8 -23
  8. package/ios/HybridRiveRuntime.swift +11 -0
  9. package/ios/RiveReactNativeView.swift +3 -0
  10. package/lib/module/core/RiveRuntime.js +22 -0
  11. package/lib/module/core/RiveRuntime.js.map +1 -0
  12. package/lib/module/hooks/useRiveProperty.js +3 -3
  13. package/lib/module/hooks/useRiveProperty.js.map +1 -1
  14. package/lib/module/index.js +1 -0
  15. package/lib/module/index.js.map +1 -1
  16. package/lib/module/specs/RiveRuntime.nitro.js +4 -0
  17. package/lib/module/specs/RiveRuntime.nitro.js.map +1 -0
  18. package/lib/typescript/src/core/RiveRuntime.d.ts +8 -0
  19. package/lib/typescript/src/core/RiveRuntime.d.ts.map +1 -0
  20. package/lib/typescript/src/hooks/useRiveProperty.d.ts.map +1 -1
  21. package/lib/typescript/src/index.d.ts +1 -0
  22. package/lib/typescript/src/index.d.ts.map +1 -1
  23. package/lib/typescript/src/specs/RiveRuntime.nitro.d.ts +10 -0
  24. package/lib/typescript/src/specs/RiveRuntime.nitro.d.ts.map +1 -0
  25. package/nitrogen/generated/android/c++/JHybridRiveRuntimeSpec.cpp +82 -0
  26. package/nitrogen/generated/android/c++/JHybridRiveRuntimeSpec.hpp +67 -0
  27. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rive/HybridRiveRuntimeSpec.kt +64 -0
  28. package/nitrogen/generated/android/rive+autolinking.cmake +2 -0
  29. package/nitrogen/generated/android/riveOnLoad.cpp +10 -0
  30. package/nitrogen/generated/ios/RNRive-Swift-Cxx-Bridge.cpp +25 -8
  31. package/nitrogen/generated/ios/RNRive-Swift-Cxx-Bridge.hpp +60 -43
  32. package/nitrogen/generated/ios/RNRive-Swift-Cxx-Umbrella.hpp +5 -0
  33. package/nitrogen/generated/ios/RNRiveAutolinking.mm +8 -0
  34. package/nitrogen/generated/ios/RNRiveAutolinking.swift +12 -0
  35. package/nitrogen/generated/ios/c++/HybridRiveRuntimeSpecSwift.cpp +11 -0
  36. package/nitrogen/generated/ios/c++/HybridRiveRuntimeSpecSwift.hpp +90 -0
  37. package/nitrogen/generated/ios/swift/HybridRiveRuntimeSpec.swift +57 -0
  38. package/nitrogen/generated/ios/swift/HybridRiveRuntimeSpec_cxx.swift +164 -0
  39. package/nitrogen/generated/shared/c++/HybridRiveRuntimeSpec.cpp +23 -0
  40. package/nitrogen/generated/shared/c++/HybridRiveRuntimeSpec.hpp +65 -0
  41. package/package.json +3 -3
  42. package/src/core/RiveRuntime.ts +23 -0
  43. package/src/hooks/useRiveProperty.ts +3 -7
  44. package/src/index.tsx +1 -0
  45. package/src/specs/RiveRuntime.nitro.ts +8 -0
@@ -0,0 +1,65 @@
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
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+
17
+
18
+ #include <string>
19
+ #include <optional>
20
+ #include <NitroModules/Promise.hpp>
21
+
22
+ namespace margelo::nitro::rive {
23
+
24
+ using namespace margelo::nitro;
25
+
26
+ /**
27
+ * An abstract base class for `RiveRuntime`
28
+ * Inherit this class to create instances of `HybridRiveRuntimeSpec` in C++.
29
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
30
+ * @example
31
+ * ```cpp
32
+ * class HybridRiveRuntime: public HybridRiveRuntimeSpec {
33
+ * public:
34
+ * HybridRiveRuntime(...): HybridObject(TAG) { ... }
35
+ * // ...
36
+ * };
37
+ * ```
38
+ */
39
+ class HybridRiveRuntimeSpec: public virtual HybridObject {
40
+ public:
41
+ // Constructor
42
+ explicit HybridRiveRuntimeSpec(): HybridObject(TAG) { }
43
+
44
+ // Destructor
45
+ ~HybridRiveRuntimeSpec() override = default;
46
+
47
+ public:
48
+ // Properties
49
+ virtual bool getIsInitialized() = 0;
50
+ virtual std::optional<std::string> getInitError() = 0;
51
+
52
+ public:
53
+ // Methods
54
+ virtual std::shared_ptr<Promise<void>> initialize() = 0;
55
+
56
+ protected:
57
+ // Hybrid Setup
58
+ void loadHybridMethods() override;
59
+
60
+ protected:
61
+ // Tag for logging
62
+ static constexpr auto TAG = "RiveRuntime";
63
+ };
64
+
65
+ } // namespace margelo::nitro::rive
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rive-app/react-native",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Rive React Native",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -64,8 +64,8 @@
64
64
  },
65
65
  "homepage": "https://github.com/rive-app/rive-nitro-react-native#readme",
66
66
  "runtimeVersions": {
67
- "ios": "6.13.0",
68
- "android": "11.1.0"
67
+ "ios": "6.15.2",
68
+ "android": "11.2.0"
69
69
  },
70
70
  "publishConfig": {
71
71
  "registry": "https://registry.npmjs.org/"
@@ -0,0 +1,23 @@
1
+ import { NitroModules } from 'react-native-nitro-modules';
2
+ import type { RiveRuntime as RiveRuntimeSpec } from '../specs/RiveRuntime.nitro';
3
+
4
+ const RiveRuntimeInternal =
5
+ NitroModules.createHybridObject<RiveRuntimeSpec>('RiveRuntime');
6
+
7
+ export namespace RiveRuntime {
8
+ export async function initialize(): Promise<void> {
9
+ await RiveRuntimeInternal.initialize();
10
+ if (!RiveRuntimeInternal.isInitialized) {
11
+ throw new Error(
12
+ `Rive initialization failed: ${RiveRuntimeInternal.initError ?? 'Unknown error'}`
13
+ );
14
+ }
15
+ }
16
+
17
+ export function getStatus(): { isInitialized: boolean; error?: string } {
18
+ return {
19
+ isInitialized: RiveRuntimeInternal.isInitialized,
20
+ error: RiveRuntimeInternal.initError ?? undefined,
21
+ };
22
+ }
23
+ }
@@ -86,15 +86,11 @@ export function useRiveProperty<P extends ViewModelProperty, T>(
86
86
  };
87
87
  }, [options, property]);
88
88
 
89
- // Set the value of the property
89
+ // Set the value of the property (no-op if property isn't available yet)
90
90
  const setPropertyValue = useCallback(
91
91
  (valueOrUpdater: T | ((prevValue: T | undefined) => T)) => {
92
92
  if (!property) {
93
- setError(
94
- new Error(
95
- `Cannot set value for property "${path}" because it was not found. Your view model instance may be undefined, or the path may be incorrect.`
96
- )
97
- );
93
+ return;
98
94
  } else {
99
95
  const newValue =
100
96
  typeof valueOrUpdater === 'function'
@@ -105,7 +101,7 @@ export function useRiveProperty<P extends ViewModelProperty, T>(
105
101
  property.value = newValue;
106
102
  }
107
103
  },
108
- [property, path]
104
+ [property]
109
105
  );
110
106
 
111
107
  return [value, setPropertyValue, error, property as unknown as P];
package/src/index.tsx CHANGED
@@ -55,4 +55,5 @@ export { useViewModelInstance } from './hooks/useViewModelInstance';
55
55
  export { useRiveFile } from './hooks/useRiveFile';
56
56
  export { type RiveFileInput } from './hooks/useRiveFile';
57
57
  export { type SetValueAction } from './types';
58
+ export { RiveRuntime } from './core/RiveRuntime';
58
59
  export { DataBindMode };
@@ -0,0 +1,8 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules';
2
+
3
+ export interface RiveRuntime
4
+ extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
5
+ initialize(): Promise<void>;
6
+ readonly isInitialized: boolean;
7
+ readonly initError: string | undefined;
8
+ }