@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
@@ -40,9 +40,13 @@ android {
40
40
 
41
41
  compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
42
42
 
43
+ def skipSetup = project.hasProperty('Rive_RiveRuntimeAndroidSkipSetup') ?
44
+ project.property('Rive_RiveRuntimeAndroidSkipSetup').toBoolean() : false
45
+
43
46
  defaultConfig {
44
47
  minSdkVersion getExtOrIntegerDefault("minSdkVersion")
45
48
  targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
49
+ buildConfigField "boolean", "RIVE_SKIP_SETUP", "$skipSetup"
46
50
 
47
51
  externalNativeBuild {
48
52
  cmake {
@@ -149,7 +153,6 @@ dependencies {
149
153
  implementation "com.facebook.react:react-android"
150
154
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
151
155
  implementation "app.rive:rive-android:${riveAndroidVersion}"
152
- implementation "androidx.startup:startup-runtime:1.2.0"
153
156
  implementation project(":react-native-nitro-modules")
154
157
  }
155
158
 
@@ -1,13 +1,3 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- xmlns:tools="http://schemas.android.com/tools">
3
- <application>
4
- <provider
5
- android:name="androidx.startup.InitializationProvider"
6
- android:authorities="${applicationId}.androidx-startup"
7
- android:exported="false"
8
- tools:node="merge">
9
- <meta-data android:name="app.rive.runtime.kotlin.RiveInitializer"
10
- android:value="androidx.startup" />
11
- </provider>
12
- </application>
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <application />
13
3
  </manifest>
@@ -0,0 +1,26 @@
1
+ package com.margelo.nitro.rive
2
+
3
+ import androidx.annotation.Keep
4
+ import com.facebook.proguard.annotations.DoNotStrip
5
+ import com.margelo.nitro.core.Promise
6
+ import com.rive.RiveInitializer
7
+ import kotlinx.coroutines.Dispatchers
8
+ import kotlinx.coroutines.withContext
9
+
10
+ @Keep
11
+ @DoNotStrip
12
+ class HybridRiveRuntime : HybridRiveRuntimeSpec() {
13
+ override fun initialize(): Promise<Unit> {
14
+ return Promise.async {
15
+ withContext(Dispatchers.Main) {
16
+ RiveInitializer.manualInitialize()
17
+ }
18
+ }
19
+ }
20
+
21
+ override val isInitialized: Boolean
22
+ get() = RiveInitializer.isInitialized
23
+
24
+ override val initError: String?
25
+ get() = RiveInitializer.error
26
+ }
@@ -10,6 +10,7 @@ import com.rive.ViewConfiguration
10
10
  import app.rive.runtime.kotlin.core.Fit as RiveFit
11
11
  import app.rive.runtime.kotlin.core.Alignment as RiveAlignment
12
12
  import app.rive.runtime.kotlin.core.errors.*
13
+ import android.util.Log
13
14
  import kotlinx.coroutines.Dispatchers
14
15
  import kotlinx.coroutines.withContext
15
16
 
@@ -268,6 +269,7 @@ class HybridRiveView(val context: ThemedReactContext) : HybridRiveViewSpec() {
268
269
  val (errorType, errorDescription) = detectErrorType(e)
269
270
  val noteString = note?.let { " $it" } ?: ""
270
271
  val errorMessage = "[RIVE] $tag$noteString $errorDescription"
272
+ Log.e(TAG, errorMessage, e)
271
273
  val riveError = RiveError(
272
274
  type = errorType,
273
275
  message = errorMessage
@@ -0,0 +1,64 @@
1
+ package com.rive
2
+
3
+ import android.content.Context
4
+ import android.util.Log
5
+ import app.rive.runtime.kotlin.core.Rive
6
+
7
+ object RiveInitializer {
8
+ private const val TAG = "RiveInitializer"
9
+
10
+ @Volatile
11
+ var isInitialized = false
12
+ private set
13
+
14
+ @Volatile
15
+ var error: String? = null
16
+ private set
17
+
18
+ private var context: Context? = null
19
+
20
+ fun storeContext(ctx: Context) {
21
+ context = ctx.applicationContext
22
+ }
23
+
24
+ @Synchronized
25
+ fun autoInitialize(ctx: Context): Boolean {
26
+ storeContext(ctx)
27
+ if (isInitialized) return true
28
+ return try {
29
+ Rive.init(ctx)
30
+ isInitialized = true
31
+ error = null
32
+ true
33
+ } catch (e: Throwable) {
34
+ error = formatError(e)
35
+ Log.e(TAG, "Auto-init failed: $error", e)
36
+ false
37
+ }
38
+ }
39
+
40
+ @Synchronized
41
+ fun manualInitialize() {
42
+ val ctx = context
43
+ if (ctx == null) {
44
+ error = "Context not available. Ensure RivePackage is registered."
45
+ Log.e(TAG, "Manual init failed: $error")
46
+ return
47
+ }
48
+ if (isInitialized) return
49
+ try {
50
+ Rive.init(ctx)
51
+ isInitialized = true
52
+ error = null
53
+ } catch (e: Throwable) {
54
+ error = formatError(e)
55
+ Log.e(TAG, "Manual init failed: $error", e)
56
+ }
57
+ }
58
+
59
+ private fun formatError(e: Throwable): String {
60
+ val name = e::class.simpleName ?: "Unknown"
61
+ val msg = e.message ?: e.toString()
62
+ return "$name: $msg"
63
+ }
64
+ }
@@ -9,21 +9,28 @@ import com.margelo.nitro.rive.riveOnLoad
9
9
 
10
10
  class RivePackage : BaseReactPackage() {
11
11
  override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<in Nothing, in Nothing>> {
12
+ if (BuildConfig.RIVE_SKIP_SETUP) {
13
+ RiveInitializer.storeContext(reactContext)
14
+ } else {
15
+ RiveInitializer.autoInitialize(reactContext)
16
+ }
17
+
12
18
  val viewManagers: MutableList<ViewManager<*, *>> = ArrayList()
13
19
  viewManagers.add(RiveViewManager())
14
20
  return viewManagers
15
21
  }
16
- override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
17
- return null
18
- }
19
22
 
20
- override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
21
- return ReactModuleInfoProvider { HashMap() }
22
- }
23
+ override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
24
+ return null
25
+ }
26
+
27
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
28
+ return ReactModuleInfoProvider { HashMap() }
29
+ }
23
30
 
24
- companion object {
25
- init {
26
- riveOnLoad.initializeNative()
27
- }
31
+ companion object {
32
+ init {
33
+ riveOnLoad.initializeNative()
28
34
  }
35
+ }
29
36
  }
@@ -77,7 +77,6 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {
77
77
  private var eventListeners: MutableList<RiveFileController.RiveEventListener> = mutableListOf()
78
78
  private val viewReadyDeferred = CompletableDeferred<Boolean>()
79
79
  private var _activeStateMachineName: String? = null
80
- private var _pendingBindData: BindData? = null
81
80
  private var willDispose = false
82
81
 
83
82
  init {
@@ -104,11 +103,17 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {
104
103
 
105
104
  fun configure(config: ViewConfiguration, dataBindingChanged: Boolean, reload: Boolean = false, initialUpdate: Boolean = false) {
106
105
  if (reload) {
106
+ val hasDataBinding = when (config.bindData) {
107
+ is BindData.None -> false
108
+ is BindData.Auto -> config.riveFile.viewModelCount > 0
109
+ is BindData.Instance, is BindData.ByName -> true
110
+ }
107
111
  riveAnimationView?.setRiveFile(
108
112
  config.riveFile,
109
113
  artboardName = config.artboardName,
110
114
  stateMachineName = config.stateMachineName,
111
115
  autoplay = config.autoPlay,
116
+ autoBind = hasDataBinding,
112
117
  alignment = config.alignment,
113
118
  fit = config.fit
114
119
  )
@@ -121,7 +126,7 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {
121
126
  }
122
127
 
123
128
  if (dataBindingChanged || initialUpdate || reload) {
124
- applyDataBinding(config.bindData, config.autoPlay)
129
+ applyDataBinding(config.bindData)
125
130
  }
126
131
 
127
132
  viewReadyDeferred.complete(true)
@@ -143,20 +148,8 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {
143
148
  }
144
149
  }
145
150
 
146
- fun applyDataBinding(bindData: BindData, autoPlay: Boolean) {
147
- val stateMachines = riveAnimationView?.controller?.stateMachines
148
- if (stateMachines.isNullOrEmpty()) {
149
- _pendingBindData = bindData
150
- return
151
- }
152
-
151
+ fun applyDataBinding(bindData: BindData) {
153
152
  bindToStateMachine(bindData)
154
-
155
- if (autoPlay) {
156
- stateMachines.first().name.let { smName ->
157
- riveAnimationView?.play(smName, isStateMachine = true)
158
- }
159
- }
160
153
  }
161
154
 
162
155
  fun play() {
@@ -164,14 +157,6 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {
164
157
  _activeStateMachineName = getSafeStateMachineName()
165
158
  }
166
159
  riveAnimationView?.play()
167
- applyPendingBindData()
168
- }
169
-
170
- private fun applyPendingBindData() {
171
- _pendingBindData?.let { bindData ->
172
- _pendingBindData = null
173
- bindToStateMachine(bindData)
174
- }
175
160
  }
176
161
 
177
162
  fun pause() = riveAnimationView?.pause()
@@ -0,0 +1,11 @@
1
+ import NitroModules
2
+
3
+ final class HybridRiveRuntime: HybridRiveRuntimeSpec {
4
+ var isInitialized: Bool { true }
5
+
6
+ var initError: String? { nil }
7
+
8
+ func initialize() throws -> Promise<Void> {
9
+ return .resolved()
10
+ }
11
+ }
@@ -166,6 +166,7 @@ class RiveReactNativeView: UIView, RiveStateMachineDelegate {
166
166
  try handleInput(name: name, path: path, type: .number) { (input: RiveRuntime.RiveSMINumber) in
167
167
  input.setValue(value)
168
168
  }
169
+ playIfNeeded()
169
170
  }
170
171
 
171
172
  func getNumberInputValue(name: String, path: String?) throws -> Float {
@@ -178,6 +179,7 @@ class RiveReactNativeView: UIView, RiveStateMachineDelegate {
178
179
  try handleInput(name: name, path: path, type: .boolean) { (input: RiveRuntime.RiveSMIBool) in
179
180
  input.setValue(value)
180
181
  }
182
+ playIfNeeded()
181
183
  }
182
184
 
183
185
  func getBooleanInputValue(name: String, path: String?) throws -> Bool {
@@ -190,6 +192,7 @@ class RiveReactNativeView: UIView, RiveStateMachineDelegate {
190
192
  try handleInput(name: name, path: path, type: .trigger) { (input: RiveRuntime.RiveSMITrigger) in
191
193
  input.fire()
192
194
  }
195
+ playIfNeeded()
193
196
  }
194
197
 
195
198
  func setTextRunValue(name: String, value: String, path: String?) throws {
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ import { NitroModules } from 'react-native-nitro-modules';
4
+ const RiveRuntimeInternal = NitroModules.createHybridObject('RiveRuntime');
5
+ export let RiveRuntime;
6
+ (function (_RiveRuntime) {
7
+ async function initialize() {
8
+ await RiveRuntimeInternal.initialize();
9
+ if (!RiveRuntimeInternal.isInitialized) {
10
+ throw new Error(`Rive initialization failed: ${RiveRuntimeInternal.initError ?? 'Unknown error'}`);
11
+ }
12
+ }
13
+ _RiveRuntime.initialize = initialize;
14
+ function getStatus() {
15
+ return {
16
+ isInitialized: RiveRuntimeInternal.isInitialized,
17
+ error: RiveRuntimeInternal.initError ?? undefined
18
+ };
19
+ }
20
+ _RiveRuntime.getStatus = getStatus;
21
+ })(RiveRuntime || (RiveRuntime = {}));
22
+ //# sourceMappingURL=RiveRuntime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NitroModules","RiveRuntimeInternal","createHybridObject","RiveRuntime","_RiveRuntime","initialize","isInitialized","Error","initError","getStatus","error","undefined"],"sourceRoot":"../../../src","sources":["core/RiveRuntime.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAGzD,MAAMC,mBAAmB,GACvBD,YAAY,CAACE,kBAAkB,CAAkB,aAAa,CAAC;AAAC,WAEjDC,WAAW;AAAA,WAAAC,YAAA;EACnB,eAAeC,UAAUA,CAAA,EAAkB;IAChD,MAAMJ,mBAAmB,CAACI,UAAU,CAAC,CAAC;IACtC,IAAI,CAACJ,mBAAmB,CAACK,aAAa,EAAE;MACtC,MAAM,IAAIC,KAAK,CACb,+BAA+BN,mBAAmB,CAACO,SAAS,IAAI,eAAe,EACjF,CAAC;IACH;EACF;EAACJ,YAAA,CAAAC,UAAA,GAAAA,UAAA;EAEM,SAASI,SAASA,CAAA,EAA+C;IACtE,OAAO;MACLH,aAAa,EAAEL,mBAAmB,CAACK,aAAa;MAChDI,KAAK,EAAET,mBAAmB,CAACO,SAAS,IAAIG;IAC1C,CAAC;EACH;EAACP,YAAA,CAAAK,SAAA,GAAAA,SAAA;AAAA,GAfcN,WAAW,KAAXA,WAAW","ignoreList":[]}
@@ -60,15 +60,15 @@ export function useRiveProperty(viewModelInstance, path, options) {
60
60
  };
61
61
  }, [options, property]);
62
62
 
63
- // Set the value of the property
63
+ // Set the value of the property (no-op if property isn't available yet)
64
64
  const setPropertyValue = useCallback(valueOrUpdater => {
65
65
  if (!property) {
66
- setError(new Error(`Cannot set value for property "${path}" because it was not found. Your view model instance may be undefined, or the path may be incorrect.`));
66
+ return;
67
67
  } else {
68
68
  const newValue_0 = typeof valueOrUpdater === 'function' ? valueOrUpdater(property.value) : valueOrUpdater;
69
69
  property.value = newValue_0;
70
70
  }
71
- }, [property, path]);
71
+ }, [property]);
72
72
  return [value, setPropertyValue, error, property];
73
73
  }
74
74
 
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","useEffect","useState","useMemo","useRiveProperty","viewModelInstance","path","options","property","getProperty","value","setValue","error","setError","Error","removeListener","onPropertyEventOverride","addListener","newValue","dispose","setPropertyValue","valueOrUpdater"],"sourceRoot":"../../../src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O,cAAc,GAAGR,OAAO,CAACS,uBAAuB,GAClDR,QAAQ,CAACS,WAAW,CAACV,OAAO,CAACS,uBAAuB,CAAC,GACrDR,QAAQ,CAACS,WAAW,CAAEC,QAAQ,IAAK;MACjCP,QAAQ,CAACO,QAAQ,CAAC;IACpB,CAAC,CAAC;IAEN,OAAO,MAAM;MACXH,cAAc,CAAC,CAAC;MAChBP,QAAQ,CAACW,OAAO,CAAC,CAAC;IACpB,CAAC;EACH,CAAC,EAAE,CAACZ,OAAO,EAAEC,QAAQ,CAAC,CAAC;;EAEvB;EACA,MAAMY,gBAAgB,GAAGpB,WAAW,CACjCqB,cAAqD,IAAK;IACzD,IAAI,CAACb,QAAQ,EAAE;MACbK,QAAQ,CACN,IAAIC,KAAK,CACP,kCAAkCR,IAAI,sGACxC,CACF,CAAC;IACH,CAAC,MAAM;MACL,MAAMY,UAAQ,GACZ,OAAOG,cAAc,KAAK,UAAU,GAC/BA,cAAc,CACbb,QAAQ,CAACE,KACX,CAAC,GACDW,cAAc;MACpBb,QAAQ,CAACE,KAAK,GAAGQ,UAAQ;IAC3B;EACF,CAAC,EACD,CAACV,QAAQ,EAAEF,IAAI,CACjB,CAAC;EAED,OAAO,CAACI,KAAK,EAAEU,gBAAgB,EAAER,KAAK,EAAEJ,QAAQ,CAAiB;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"names":["useCallback","useEffect","useState","useMemo","useRiveProperty","viewModelInstance","path","options","property","getProperty","value","setValue","error","setError","Error","removeListener","onPropertyEventOverride","addListener","newValue","dispose","setPropertyValue","valueOrUpdater"],"sourceRoot":"../../../src","sources":["hooks/useRiveProperty.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,OAAO,QAAQ,OAAO;AAOjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,iBAAu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XH,cAAc,CAAC,CAAC;MAChBP,QAAQ,CAACW,OAAO,CAAC,CAAC;IACpB,CAAC;EACH,CAAC,EAAE,CAACZ,OAAO,EAAEC,QAAQ,CAAC,CAAC;;EAEvB;EACA,MAAMY,gBAAgB,GAAGpB,WAAW,CACjCqB,cAAqD,IAAK;IACzD,IAAI,CAACb,QAAQ,EAAE;MACb;IACF,CAAC,MAAM;MACL,MAAMU,UAAQ,GACZ,OAAOG,cAAc,KAAK,UAAU,GAC/BA,cAAc,CACbb,QAAQ,CAACE,KACX,CAAC,GACDW,cAAc;MACpBb,QAAQ,CAACE,KAAK,GAAGQ,UAAQ;IAC3B;EACF,CAAC,EACD,CAACV,QAAQ,CACX,CAAC;EAED,OAAO,CAACE,KAAK,EAAEU,gBAAgB,EAAER,KAAK,EAAEJ,QAAQ,CAAiB;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -26,5 +26,6 @@ export { useRiveTrigger } from "./hooks/useRiveTrigger.js";
26
26
  export { useRiveList } from "./hooks/useRiveList.js";
27
27
  export { useViewModelInstance } from "./hooks/useViewModelInstance.js";
28
28
  export { useRiveFile } from "./hooks/useRiveFile.js";
29
+ export { RiveRuntime } from "./core/RiveRuntime.js";
29
30
  export { DataBindMode };
30
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["DataBindMode","DataBindByName","constructor","name","byName","NitroRiveView","RiveView","Fit","Alignment","RiveFileFactory","RiveImages","RiveColor","RiveEventType","RiveErrorType","ArtboardByIndex","ArtboardByName","useRive","useRiveNumber","useRiveString","useRiveBoolean","useRiveEnum","useRiveColor","useRiveTrigger","useRiveList","useViewModelInstance","useRiveFile"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AACA,SAIEA,YAAY,QAEP,2BAAwB;AAE/B,OAAO,MAAMC,cAAc,CAAoC;EAE7DC,WAAWA,CAACC,IAAY,EAAE;IACxB,IAAI,CAACC,MAAM,GAAGD,IAAI;EACpB;AACF;AAEA,SAASE,aAAa,QAAQ,kCAA+B;AAE7D,SAASC,QAAQ,QAA4B,oBAAiB;AAkB9D,SAASC,GAAG,QAAQ,eAAY;AAChC,SAASC,SAAS,QAAQ,qBAAkB;AAC5C,SAASC,eAAe,QAAQ,oBAAiB;AACjD,SAASC,UAAU,QAAQ,sBAAmB;AAE9C,SAASC,SAAS,QAAQ,qBAAkB;AAC5C,SAAyBC,aAAa,QAAQ,kBAAe;AAC7D,SAAyBC,aAAa,QAAQ,kBAAe;AAC7D,SAASC,eAAe,EAAEC,cAAc,QAAQ,uBAAoB;AACpE,SAASC,OAAO,QAAQ,oBAAiB;AACzC,SAASC,aAAa,QAAQ,0BAAuB;AACrD,SAASC,aAAa,QAAQ,0BAAuB;AACrD,SAASC,cAAc,QAAQ,2BAAwB;AACvD,SAASC,WAAW,QAAQ,wBAAqB;AACjD,SAASC,YAAY,QAAQ,yBAAsB;AACnD,SAASC,cAAc,QAAQ,2BAAwB;AACvD,SAASC,WAAW,QAAQ,wBAAqB;AACjD,SAASC,oBAAoB,QAAQ,iCAA8B;AACnE,SAASC,WAAW,QAAQ,wBAAqB;AAGjD,SAASzB,YAAY","ignoreList":[]}
1
+ {"version":3,"names":["DataBindMode","DataBindByName","constructor","name","byName","NitroRiveView","RiveView","Fit","Alignment","RiveFileFactory","RiveImages","RiveColor","RiveEventType","RiveErrorType","ArtboardByIndex","ArtboardByName","useRive","useRiveNumber","useRiveString","useRiveBoolean","useRiveEnum","useRiveColor","useRiveTrigger","useRiveList","useViewModelInstance","useRiveFile","RiveRuntime"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AACA,SAIEA,YAAY,QAEP,2BAAwB;AAE/B,OAAO,MAAMC,cAAc,CAAoC;EAE7DC,WAAWA,CAACC,IAAY,EAAE;IACxB,IAAI,CAACC,MAAM,GAAGD,IAAI;EACpB;AACF;AAEA,SAASE,aAAa,QAAQ,kCAA+B;AAE7D,SAASC,QAAQ,QAA4B,oBAAiB;AAkB9D,SAASC,GAAG,QAAQ,eAAY;AAChC,SAASC,SAAS,QAAQ,qBAAkB;AAC5C,SAASC,eAAe,QAAQ,oBAAiB;AACjD,SAASC,UAAU,QAAQ,sBAAmB;AAE9C,SAASC,SAAS,QAAQ,qBAAkB;AAC5C,SAAyBC,aAAa,QAAQ,kBAAe;AAC7D,SAAyBC,aAAa,QAAQ,kBAAe;AAC7D,SAASC,eAAe,EAAEC,cAAc,QAAQ,uBAAoB;AACpE,SAASC,OAAO,QAAQ,oBAAiB;AACzC,SAASC,aAAa,QAAQ,0BAAuB;AACrD,SAASC,aAAa,QAAQ,0BAAuB;AACrD,SAASC,cAAc,QAAQ,2BAAwB;AACvD,SAASC,WAAW,QAAQ,wBAAqB;AACjD,SAASC,YAAY,QAAQ,yBAAsB;AACnD,SAASC,cAAc,QAAQ,2BAAwB;AACvD,SAASC,WAAW,QAAQ,wBAAqB;AACjD,SAASC,oBAAoB,QAAQ,iCAA8B;AACnE,SAASC,WAAW,QAAQ,wBAAqB;AAGjD,SAASC,WAAW,QAAQ,uBAAoB;AAChD,SAAS1B,YAAY","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=RiveRuntime.nitro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["specs/RiveRuntime.nitro.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ export declare namespace RiveRuntime {
2
+ function initialize(): Promise<void>;
3
+ function getStatus(): {
4
+ isInitialized: boolean;
5
+ error?: string;
6
+ };
7
+ }
8
+ //# sourceMappingURL=RiveRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RiveRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/RiveRuntime.ts"],"names":[],"mappings":"AAMA,yBAAiB,WAAW,CAAC;IAC3B,SAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAOhD;IAED,SAAgB,SAAS,IAAI;QAAE,aAAa,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAKtE;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useRiveProperty.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useRiveProperty.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,iBAAiB,EAAE,CAAC,EAC5D,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,EACvD,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IACP,4DAA4D;IAC5D,WAAW,EAAE,CAAC,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC,GAAG,SAAS,CAAC;IACpE,+EAA+E;IAC/E,uBAAuB,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;CACpD,GACA;IACD,CAAC,GAAG,SAAS;IACb,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC,GAAG,SAAS,KAAK,CAAC,CAAC,KAAK,IAAI;IACtD,KAAK,GAAG,IAAI;IACZ,CAAC,GAAG,SAAS;CACd,CA4EA"}
1
+ {"version":3,"file":"useRiveProperty.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useRiveProperty.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,iBAAiB,EAAE,CAAC,EAC5D,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,EACvD,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IACP,4DAA4D;IAC5D,WAAW,EAAE,CAAC,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC,GAAG,SAAS,CAAC;IACpE,+EAA+E;IAC/E,uBAAuB,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;CACpD,GACA;IACD,CAAC,GAAG,SAAS;IACb,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC,GAAG,SAAS,KAAK,CAAC,CAAC,KAAK,IAAI;IACtD,KAAK,GAAG,IAAI;IACZ,CAAC,GAAG,SAAS;CACd,CAwEA"}
@@ -32,5 +32,6 @@ export { useViewModelInstance } from './hooks/useViewModelInstance';
32
32
  export { useRiveFile } from './hooks/useRiveFile';
33
33
  export { type RiveFileInput } from './hooks/useRiveFile';
34
34
  export { type SetValueAction } from './types';
35
+ export { RiveRuntime } from './core/RiveRuntime';
35
36
  export { DataBindMode };
36
37
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,aAAa,IAAI,mBAAmB,EACzC,YAAY,EACZ,KAAK,cAAc,IAAI,uBAAuB,EAC/C,MAAM,wBAAwB,CAAC;AAEhC,qBAAa,cAAe,YAAW,uBAAuB;IAC5D,MAAM,EAAE,MAAM,CAAC;gBACH,IAAI,EAAE,MAAM;CAGzB;AAED,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC/D,YAAY,EAAE,eAAe,EAAE,CAAC;AAChC,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,mBAAmB,EAA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: 'swift';
4
+ android: 'kotlin';
5
+ }> {
6
+ initialize(): Promise<void>;
7
+ readonly isInitialized: boolean;
8
+ readonly initError: string | undefined;
9
+ }
10
+ //# sourceMappingURL=RiveRuntime.nitro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RiveRuntime.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/RiveRuntime.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,WACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IACzD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC"}
@@ -0,0 +1,82 @@
1
+ ///
2
+ /// JHybridRiveRuntimeSpec.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 "JHybridRiveRuntimeSpec.hpp"
9
+
10
+
11
+
12
+ #include <string>
13
+ #include <optional>
14
+ #include <NitroModules/Promise.hpp>
15
+ #include <NitroModules/JPromise.hpp>
16
+ #include <NitroModules/JUnit.hpp>
17
+
18
+ namespace margelo::nitro::rive {
19
+
20
+ jni::local_ref<JHybridRiveRuntimeSpec::jhybriddata> JHybridRiveRuntimeSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
21
+ return makeCxxInstance(jThis);
22
+ }
23
+
24
+ void JHybridRiveRuntimeSpec::registerNatives() {
25
+ registerHybrid({
26
+ makeNativeMethod("initHybrid", JHybridRiveRuntimeSpec::initHybrid),
27
+ });
28
+ }
29
+
30
+ size_t JHybridRiveRuntimeSpec::getExternalMemorySize() noexcept {
31
+ static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
32
+ return method(_javaPart);
33
+ }
34
+
35
+ bool JHybridRiveRuntimeSpec::equals(const std::shared_ptr<HybridObject>& other) {
36
+ if (auto otherCast = std::dynamic_pointer_cast<JHybridRiveRuntimeSpec>(other)) {
37
+ return _javaPart == otherCast->_javaPart;
38
+ }
39
+ return false;
40
+ }
41
+
42
+ void JHybridRiveRuntimeSpec::dispose() noexcept {
43
+ static const auto method = javaClassStatic()->getMethod<void()>("dispose");
44
+ method(_javaPart);
45
+ }
46
+
47
+ std::string JHybridRiveRuntimeSpec::toString() {
48
+ static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
49
+ auto javaString = method(_javaPart);
50
+ return javaString->toStdString();
51
+ }
52
+
53
+ // Properties
54
+ bool JHybridRiveRuntimeSpec::getIsInitialized() {
55
+ static const auto method = javaClassStatic()->getMethod<jboolean()>("isInitialized");
56
+ auto __result = method(_javaPart);
57
+ return static_cast<bool>(__result);
58
+ }
59
+ std::optional<std::string> JHybridRiveRuntimeSpec::getInitError() {
60
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getInitError");
61
+ auto __result = method(_javaPart);
62
+ return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
63
+ }
64
+
65
+ // Methods
66
+ std::shared_ptr<Promise<void>> JHybridRiveRuntimeSpec::initialize() {
67
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("initialize");
68
+ auto __result = method(_javaPart);
69
+ return [&]() {
70
+ auto __promise = Promise<void>::create();
71
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
72
+ __promise->resolve();
73
+ });
74
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
75
+ jni::JniException __jniError(__throwable);
76
+ __promise->reject(std::make_exception_ptr(__jniError));
77
+ });
78
+ return __promise;
79
+ }();
80
+ }
81
+
82
+ } // namespace margelo::nitro::rive
@@ -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
+ }