@@ -21,10 +21,13 @@ import {
21
21
RiveGeneralEvent ,
22
22
RiveOpenUrlEvent ,
23
23
RiveRendererInterface ,
24
+ FilesHandledMapping ,
25
+ RiveAssetPropType ,
24
26
} from './types' ;
25
27
import { convertErrorFromNativeToRN , XOR } from './helpers' ;
26
28
27
29
import { Alignment , Fit } from './types' ;
30
+ import { parsePossibleSources } from './utils' ;
28
31
29
32
const { RiveReactNativeRendererModule } = NativeModules ;
30
33
@@ -79,6 +82,7 @@ type RiveProps = {
79
82
layoutScaleFactor ?: number ;
80
83
alignment : Alignment ;
81
84
artboardName ?: string ;
85
+ assetsHandled ?: FilesHandledMapping ;
82
86
animationName ?: string ;
83
87
stateMachineName ?: string ;
84
88
ref : any ;
@@ -104,6 +108,10 @@ type Props = {
104
108
testID ?: string ;
105
109
alignment ?: Alignment ;
106
110
artboardName ?: string ;
111
+ /**
112
+ * @experimental This is an experimental feature and may change without a major version update (breaking change).
113
+ */
114
+ assetsHandled ?: FilesHandledMapping ;
107
115
animationName ?: string ;
108
116
stateMachineName ?: string ;
109
117
autoplay ?: boolean ;
@@ -131,6 +139,7 @@ const RiveContainer = React.forwardRef<RiveRef, Props>(
131
139
fit = Fit . Contain ,
132
140
layoutScaleFactor,
133
141
artboardName,
142
+ assetsHandled : assetsHandled ,
134
143
animationName,
135
144
stateMachineName,
136
145
testID,
@@ -416,6 +425,28 @@ const RiveContainer = React.forwardRef<RiveRef, Props>(
416
425
]
417
426
) ;
418
427
428
+ function transformFilesHandledMapping (
429
+ mapping ?: FilesHandledMapping
430
+ ) : FilesHandledMapping | undefined {
431
+ const transformedMapping : FilesHandledMapping = { } ;
432
+ if ( mapping === undefined ) {
433
+ return undefined ;
434
+ }
435
+
436
+ Object . keys ( mapping ) . forEach ( ( key ) => {
437
+ const option = mapping [ key ] ;
438
+ transformedMapping [ key ] = {
439
+ ...option ,
440
+ source : parsePossibleSources ( option . source as RiveAssetPropType ) ,
441
+ } ;
442
+ } ) ;
443
+
444
+ return transformedMapping ;
445
+ }
446
+
447
+ const convertedAssetHandledSources =
448
+ transformFilesHandledMapping ( assetsHandled ) ;
449
+
419
450
return (
420
451
< View style = { [ styles . container , style ] } ref = { ref as any } testID = { testID } >
421
452
< View style = { styles . children } > { children } </ View >
@@ -445,6 +476,7 @@ const RiveContainer = React.forwardRef<RiveRef, Props>(
445
476
onError = { onErrorHandler }
446
477
alignment = { alignment }
447
478
artboardName = { artboardName }
479
+ assetsHandled = { convertedAssetHandledSources }
448
480
animationName = { animationName }
449
481
stateMachineName = { stateMachineName }
450
482
/>
0 commit comments