@amazon-devices/lottie-react-native 2.0.1758683737

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 (60) hide show
  1. package/LICENSE +7 -0
  2. package/SystemBundles/90296ccfe5ff2db2f9fe68a18eca092f8b7c17d1125cfafc612d18788fe9bce6.bundle +10322 -0
  3. package/SystemBundles/90296ccfe5ff2db2f9fe68a18eca092f8b7c17d1125cfafc612d18788fe9bce6.map +1 -0
  4. package/SystemModules/amzn__lottie-react-native-2.modules.txt +13 -0
  5. package/SystemModules/amzn__lottie-react-native-2.private.modules.txt +92 -0
  6. package/SystemModules/keplerscript-system-bundle-config.json +7 -0
  7. package/THIRD_PARTY_NOTICES.txt +640 -0
  8. package/android/build.gradle +120 -0
  9. package/android/gradle.properties +27 -0
  10. package/android/src/main/AndroidManifest.xml +6 -0
  11. package/android/src/main/java/com/airbnb/android/react/lottie/LottieAnimationViewManagerImpl.kt +260 -0
  12. package/android/src/main/java/com/airbnb/android/react/lottie/LottieAnimationViewPropertyManager.kt +156 -0
  13. package/android/src/main/java/com/airbnb/android/react/lottie/LottiePackage.kt +18 -0
  14. package/android/src/newarch/com/airbnb/android/react/lottie/LottieAnimationViewManager.kt +219 -0
  15. package/android/src/oldarch/com/airbnb/android/react/lottie/LottieAnimationViewManager.kt +187 -0
  16. package/ios/Fabric/LottieAnimationViewComponentView.h +28 -0
  17. package/ios/Fabric/LottieAnimationViewComponentView.mm +140 -0
  18. package/ios/Fabric/LottieContainerView.h +33 -0
  19. package/ios/Fabric/RNLottieFabricConversions.h +29 -0
  20. package/ios/LottieReactNative/AnimationViewManagerModule.swift +88 -0
  21. package/ios/LottieReactNative/Bridging.h +4 -0
  22. package/ios/LottieReactNative/ContainerView.swift +281 -0
  23. package/ios/LottieReactNative/LRNAnimationViewManagerObjC.m +25 -0
  24. package/ios/LottieReactNative/PlatformColor.swift +31 -0
  25. package/ios/LottieReactNative/RCTConvert+Lottie.h +7 -0
  26. package/ios/LottieReactNative/RCTConvert+Lottie.m +24 -0
  27. package/ios/LottieReactNative.xcodeproj/project.pbxproj +449 -0
  28. package/ios/LottieReactNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  29. package/ios/LottieReactNative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  30. package/kepler-compatibility.json +8 -0
  31. package/kepler-transformed-package-info.json +3 -0
  32. package/lib/commonjs/LottieView.js +207 -0
  33. package/lib/commonjs/LottieView.js.map +1 -0
  34. package/lib/commonjs/LottieView.types.js +6 -0
  35. package/lib/commonjs/LottieView.types.js.map +1 -0
  36. package/lib/commonjs/index.js +9 -0
  37. package/lib/commonjs/index.js.map +1 -0
  38. package/lib/commonjs/specs/LottieAnimationViewNativeComponent.js +97 -0
  39. package/lib/commonjs/specs/LottieAnimationViewNativeComponent.js.map +1 -0
  40. package/lib/module/LottieView.js +201 -0
  41. package/lib/module/LottieView.js.map +1 -0
  42. package/lib/module/LottieView.types.js +2 -0
  43. package/lib/module/LottieView.types.js.map +1 -0
  44. package/lib/module/index.js +3 -0
  45. package/lib/module/index.js.map +1 -0
  46. package/lib/module/specs/LottieAnimationViewNativeComponent.js +91 -0
  47. package/lib/module/specs/LottieAnimationViewNativeComponent.js.map +1 -0
  48. package/lib/typescript/LottieView.d.ts +27 -0
  49. package/lib/typescript/LottieView.types.d.ts +206 -0
  50. package/lib/typescript/index.d.ts +2 -0
  51. package/lib/typescript/specs/LottieAnimationViewNativeComponent.d.ts +61 -0
  52. package/lottie-react-native.podspec +44 -0
  53. package/package.json +1 -0
  54. package/react-native.config.js +32 -0
  55. package/src/LottieView.tsx +257 -0
  56. package/src/LottieView.types.ts +275 -0
  57. package/src/__tests__/__snapshots__/validate-public-api.test.js.snap +248 -0
  58. package/src/__tests__/validate-public-api.test.js +33 -0
  59. package/src/index.tsx +2 -0
  60. package/src/specs/LottieAnimationViewNativeComponent.ts +170 -0
@@ -0,0 +1,206 @@
1
+ import type { StyleProp, ViewStyle, LayoutChangeEvent, Animated, AccessibilityProps } from 'react-native';
2
+ /**
3
+ * Serialized animation as generated from After Effects
4
+ */
5
+ export interface AnimationObject {
6
+ v: string;
7
+ fr: number;
8
+ ip: number;
9
+ op: number;
10
+ w: number;
11
+ h: number;
12
+ nm?: string;
13
+ ddd?: number;
14
+ assets: any[];
15
+ layers: any[];
16
+ markers?: any[];
17
+ }
18
+ type ColorFilter = {
19
+ keypath: string;
20
+ color: string;
21
+ };
22
+ type TextFilterIOS = {
23
+ keypath: string;
24
+ text: string;
25
+ };
26
+ type TextFilterAndroid = {
27
+ find: string;
28
+ replace: string;
29
+ };
30
+ type TextFilterKepler = {
31
+ keypath: string;
32
+ text: string;
33
+ };
34
+ type AnimatedInterpolation = ReturnType<Animated.Value['interpolate']>;
35
+ /**
36
+ * Properties of the AnimatedLottieView component
37
+ */
38
+ export interface AnimatedLottieViewProps extends AccessibilityProps {
39
+ /**
40
+ * The source of animation. Can be referenced as a local asset by a string, or remotely
41
+ * with an object with a `uri` property, or it can be an actual JS object of an
42
+ * animation, obtained (for example) with something like
43
+ * `require('../path/to/animation.json')`
44
+ */
45
+ source: string | AnimationObject | {
46
+ uri: string;
47
+ };
48
+ /**
49
+ * A number between 0 and 1, or an `Animated` number between 0 and 1. This number
50
+ * represents the normalized progress of the animation. If you update this prop, the
51
+ * animation will correspondingly update to the frame at that progress value. This
52
+ * prop is not required if you are using the imperative API.
53
+ */
54
+ progress?: number | Animated.Value | AnimatedInterpolation;
55
+ /**
56
+ * The speed the animation will progress. This only affects the imperative API. The
57
+ * default value is 1.
58
+ */
59
+ speed?: number;
60
+ /**
61
+ * The duration of the animation in ms. Takes precedence over speed when set.
62
+ * This only works when source is an actual JS object of an animation.
63
+ */
64
+ duration?: number;
65
+ /**
66
+ * A boolean flag indicating whether or not the animation should loop.
67
+ */
68
+ loop?: boolean;
69
+ /**
70
+ * Style attributes for the view, as expected in a standard `View`:
71
+ * http://facebook.github.io/react-native/releases/0.39/docs/view.html#style
72
+ *
73
+ * **CAVEAT: border styling is not supported.**
74
+ */
75
+ style?: StyleProp<ViewStyle>;
76
+ /**
77
+ * Determines how to resize the animated view when the frame doesn't match the raw image
78
+ * dimensions.
79
+ *
80
+ * Refer to https://facebook.github.io/react-native/docs/image.html#resizemode
81
+ */
82
+ resizeMode?: 'cover' | 'contain' | 'center';
83
+ /**
84
+ * Determines how Lottie should render
85
+ * Refer to LottieAnimationView#setRenderMode(RenderMode) for more information.
86
+ */
87
+ renderMode?: 'AUTOMATIC' | 'HARDWARE' | 'SOFTWARE';
88
+ /**
89
+ * A boolean flag indicating whether or not the animation should start automatically when
90
+ * mounted. This only affects the imperative API.
91
+ */
92
+ autoPlay?: boolean;
93
+ /**
94
+ * A boolean flag indicating whether or not the animation should size itself automatically
95
+ * according to the width in the animation's JSON. This only works when source is an actual
96
+ * JS object of an animation.
97
+ */
98
+ autoSize?: boolean;
99
+ /**
100
+ * A callback function which will be called when animation is finished. Note that this
101
+ * callback will be called only when `loop` is set to false.
102
+ */
103
+ onAnimationFinish?: (isCancelled: boolean) => void;
104
+ /**
105
+ * A callback function which will be called when the view has been laid out.
106
+ */
107
+ onLayout?: (event: LayoutChangeEvent) => void;
108
+ /**
109
+ * An array of layers you want to override its color filter.
110
+ */
111
+ colorFilters?: Array<ColorFilter>;
112
+ /**
113
+ * A string to identify the component during testing.
114
+ */
115
+ testID?: string;
116
+ /**
117
+ * A boolean flag to enable merge patching.
118
+ * @platform android
119
+ */
120
+ enableMergePathsAndroidForKitKatAndAbove?: boolean;
121
+ /**
122
+ * A boolean flag indicating whether or not the animation should caching. Defaults to true.
123
+ * Refer to LottieAnimationView#setCacheComposition(boolean) for more information.
124
+ *
125
+ * @platform android
126
+ */
127
+ cacheComposition?: boolean;
128
+ /**
129
+ * An array of objects denoting text values to find and replace.
130
+ *
131
+ * @platform android
132
+ */
133
+ textFiltersAndroid?: Array<TextFilterAndroid>;
134
+ /**
135
+ * Relative folder inside of assets containing image files to be animated.
136
+ * Make sure that the images that bodymovin export are in that folder with their names unchanged (should be img_#).
137
+ * Refer to https://github.com/airbnb/lottie-android#image-support for more details.
138
+ *
139
+ * @platform android
140
+ */
141
+ imageAssetsFolder?: string;
142
+ /**
143
+ * Uses hardware acceleration to perform the animation. This should only
144
+ * be used for animations where your width and height are equal to the composition width
145
+ * and height, e.g. you are not scaling the animation.
146
+ *
147
+ * @platform android
148
+ */
149
+ hardwareAccelerationAndroid?: boolean;
150
+ /**
151
+ * An array of objects denoting text layers by KeyPath and a new string value.
152
+ *
153
+ * @platform ios
154
+ */
155
+ textFiltersIOS?: Array<TextFilterIOS>;
156
+ /**
157
+ * A boolean flag to enable use of platform-level looping on Windows. This improves loop smoothness,
158
+ * but onAnimationLoop will not fire and changing the loop prop will restart playback.
159
+ *
160
+ * @platform windows
161
+ */
162
+ useNativeLooping?: boolean;
163
+ /**
164
+ * A callback function which will be called when the animation loops.
165
+ *
166
+ * @platform windows
167
+ */
168
+ onAnimationLoop?: () => void;
169
+ /**
170
+ * A callback function which will be called when animation json load is finished.
171
+ *
172
+ * @platform kepler
173
+ */
174
+ onAnimationLoad?: () => void;
175
+ /**
176
+ * A callback function which will be called when animation json load is finished.
177
+ *
178
+ * @platform kepler
179
+ */
180
+ onAnimationJsonLoad?: () => void;
181
+ /**
182
+ * A callback function which will be called when animation play is started.
183
+ *
184
+ * @platform kepler
185
+ */
186
+ onAnimationPlay?: () => void;
187
+ /**
188
+ * A callback function which will be called when animation is paused.
189
+ *
190
+ * @platform kepler
191
+ */
192
+ onAnimationPause?: () => void;
193
+ /**
194
+ * A callback function which will be called when animation is resumed.
195
+ *
196
+ * @platform kepler
197
+ */
198
+ onAnimationResume?: () => void;
199
+ /**
200
+ * An array of objects denoting text values to find and replace.
201
+ *
202
+ * @platform kepler
203
+ */
204
+ textFiltersKepler?: Array<TextFilterKepler>;
205
+ }
206
+ export {};
@@ -0,0 +1,2 @@
1
+ import { AnimatedLottieView } from './LottieView';
2
+ export default AnimatedLottieView;
@@ -0,0 +1,61 @@
1
+ /// <reference types="react" />
2
+ import type { BubblingEventHandler, Int32, Double, Float } from 'react-native/Libraries/Types/CodegenTypes';
3
+ import type { HostComponent, ProcessedColorValue, ViewProps } from 'react-native';
4
+ export type OnAnimationFinishEvent = Readonly<{
5
+ isCancelled: boolean;
6
+ }>;
7
+ export type EmptyEvent = {};
8
+ type ColorFilterStruct = Readonly<{
9
+ keypath: string;
10
+ color: ProcessedColorValue;
11
+ }>;
12
+ type TextFilterIOSStruct = Readonly<{
13
+ keypath: string;
14
+ text: string;
15
+ }>;
16
+ type TextFilterAndroidStruct = Readonly<{
17
+ find: string;
18
+ replace: string;
19
+ }>;
20
+ type TextFilterKeplerStruct = Readonly<{
21
+ keypath: string;
22
+ text: string;
23
+ }>;
24
+ export interface NativeProps extends ViewProps {
25
+ autoPlay?: boolean;
26
+ resizeMode?: string;
27
+ renderMode?: string;
28
+ sourceName?: string;
29
+ sourceJson?: string;
30
+ sourceURL?: string;
31
+ imageAssetsFolder?: string;
32
+ progress?: Float;
33
+ speed?: Double;
34
+ loop?: boolean;
35
+ enableMergePathsAndroidForKitKatAndAbove?: boolean;
36
+ hardwareAccelerationAndroid?: boolean;
37
+ cacheComposition?: boolean;
38
+ colorFilters?: ReadonlyArray<ColorFilterStruct>;
39
+ dummy?: Readonly<{
40
+ dummy: boolean;
41
+ }>;
42
+ textFiltersAndroid?: ReadonlyArray<TextFilterAndroidStruct>;
43
+ textFiltersIOS?: ReadonlyArray<TextFilterIOSStruct>;
44
+ textFiltersKepler?: ReadonlyArray<TextFilterKeplerStruct>;
45
+ onAnimationFinish?: BubblingEventHandler<OnAnimationFinishEvent, 'onAnimationFinish'>;
46
+ onAnimationLoad?: BubblingEventHandler<EmptyEvent>;
47
+ onAnimationPlay?: BubblingEventHandler<EmptyEvent>;
48
+ onAnimationPause?: BubblingEventHandler<EmptyEvent>;
49
+ onAnimationResume?: BubblingEventHandler<EmptyEvent>;
50
+ onAnimationJsonLoad?: BubblingEventHandler<EmptyEvent>;
51
+ }
52
+ type LottieViewNativeComponentType = HostComponent<NativeProps>;
53
+ interface NativeCommands {
54
+ play: (viewRef: React.ElementRef<LottieViewNativeComponentType>, startFrame: Int32, endFrame: Int32) => void;
55
+ reset: (viewRef: React.ElementRef<LottieViewNativeComponentType>) => void;
56
+ pause: (viewRef: React.ElementRef<LottieViewNativeComponentType>) => void;
57
+ resume: (viewRef: React.ElementRef<LottieViewNativeComponentType>) => void;
58
+ }
59
+ export declare const Commands: NativeCommands;
60
+ declare const _default: HostComponent<NativeProps>;
61
+ export default _default;
@@ -0,0 +1,44 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
6
+
7
+ Pod::Spec.new do |s|
8
+ s.name = package["name"]
9
+ s.version = package['version']
10
+ s.summary = package["description"]
11
+ s.license = package["license"]
12
+
13
+ s.author = package["author"]
14
+ s.homepage = package["homepage"]
15
+
16
+ s.ios.deployment_target = '12.4'
17
+ s.osx.deployment_target = '10.10'
18
+ s.tvos.deployment_target = '12.4'
19
+
20
+ s.source = { :git => "https://github.com/lottie-react-native/lottie-react-native.git", :tag => "v#{s.version}" }
21
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
22
+
23
+ s.dependency 'lottie-ios', '~> 3.5.0'
24
+
25
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
26
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
27
+ s.pod_target_xcconfig = {
28
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
29
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
30
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
31
+ "DEFINES_MODULE" => "YES",
32
+ }
33
+
34
+ s.dependency "React-RCTFabric"
35
+ s.dependency "React-Codegen"
36
+ s.dependency "RCT-Folly"
37
+ s.dependency "RCTRequired"
38
+ s.dependency "RCTTypeSafety"
39
+ s.dependency "ReactCommon/turbomodule/core"
40
+ else
41
+ s.dependency 'React-Core'
42
+ s.exclude_files = "ios/Fabric"
43
+ end
44
+ end
package/package.json ADDED
@@ -0,0 +1 @@
1
+ {"name": "@amazon-devices/lottie-react-native", "version": "2.0.1758683737+6.0.0-rc.1", "description": "React Native bindings for Lottie", "main": "lib/commonjs/index.js", "module": "lib/module/index.js", "react-native": "src/index.tsx", "types": "lib/typescript/index.d.ts", "source": "src/index.tsx", "sideEffects": false, "files": ["SystemBundles", "SystemModules", "src", "lib", "android", "ios", "*.podspec", "kepler-compatibility.json", "react-native.config.js", "THIRD_PARTY_NOTICES.txt", "kepler-transformed-package-info.json"], "author": "Emilio Rodriguez <emiliorodriguez@gmail.com>", "homepage": "https://github.com/airbnb/lottie-react-native#readme", "license": "See license in LICENSE", "keywords": ["lottie", "animation", "react", "react-native", "keyframe"], "repository": "https://github.com/react-native-community/lottie-react-native", "bugs": {"url": "https://github.com/react-native-community/lottie-react-native/issues"}, "scripts": {"build": "bob build", "build:release": "npm-run-all build", "test": "jest", "update-api-snapshot": "jest src/__tests__/validate-public-api.test.js -u"}, "//-0": "amznmod_react - Add keplerImport and kepler 3p module aliasing", "keplerImport": true, "kepler": {"temporary-alias-for-package": {"name": "lottie-react-native", "version": "6.0.0-rc.1"}}, "//-1": "amznmod_react - change peerDependencies to restrict to 72.0 or greater", "peerDependencies": {"react": "*", "react-native": ">=0.46", "react-native-windows": ">=0.72.x"}, "peerDependenciesMeta": {"react-native-windows": {"optional": true}}, "//-2": "amznmod_react - change devDependencies versions to be Kepler compatible", "devDependencies": {"@amazon-devices/react-native-kepler": "^2.0.0+rn0.72.0", "@react-native-community/eslint-config": "^2.0.0", "@types/jest": "29.5.12", "@types/react": "^18.0.18", "@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/parser": "^4.33.0", "eslint": "^7.14.0", "eslint-config-prettier": "^6.11.0", "eslint-plugin-prettier": "3.1.2", "flow-api-translator": "^0.20.1", "jest": "^29.2.1", "metro-react-native-babel-preset": "^0.64.0", "npm-run-all": "^4.1.5", "prettier": "^2.2.1", "react": "18.2.0", "react-native": "0.72.0", "react-native-builder-bob": "^0.17.1", "react-native-windows": "0.72.0", "ts-jest": "29.1.2", "typescript": "^4.4.4"}, "react-native-builder-bob": {"source": "src", "output": "lib", "targets": ["commonjs", "module", "typescript"]}, "codegenConfig": {"android": {"javaPackageName": "com.airbnb.android.react.lottie"}, "name": "lottiereactnative", "type": "components", "jsSrcsDir": "./src/specs"}}
@@ -0,0 +1,32 @@
1
+ let supportsCodegenConfig = false;
2
+ try {
3
+ const rnCliAndroidVersion =
4
+ require('@react-native-community/cli-platform-android/package.json').version;
5
+ const [major] = rnCliAndroidVersion.split('.');
6
+ supportsCodegenConfig = major >= 9;
7
+ } catch (e) {
8
+ // ignore
9
+ }
10
+
11
+ module.exports = {
12
+ dependency: {
13
+ platforms: {
14
+ android: supportsCodegenConfig
15
+ ? {
16
+ libraryName: 'lottiereactnative',
17
+ componentDescriptors: ['LottieAnimationViewComponentDescriptor'],
18
+ }
19
+ : {},
20
+ macos: null,
21
+ windows: null,
22
+ // amznmod_react - add autolink information for Kepler platform
23
+ kepler: {
24
+ autolink: {
25
+ AmazonLottieLib: {
26
+ provider: 'system'
27
+ },
28
+ },
29
+ },
30
+ },
31
+ },
32
+ };
@@ -0,0 +1,257 @@
1
+ /*
2
+ * Portions of this file are copyright (c) 2023 Amazon.com, Inc. or its affiliates. All rights reserved.
3
+ *
4
+ * PORTIONS OF THIS FILE ARE AMAZON PROPRIETARY/CONFIDENTIAL. USE IS SUBJECT TO LICENSE TERMS.
5
+ *
6
+ * Amazon modifications are indicated by [amznmod_* comments].
7
+ */
8
+
9
+ /*
10
+ * Changelog:
11
+ * Set up lottie-react-native package to build for Kepler
12
+ */
13
+
14
+ import React from 'react';
15
+ import {
16
+ View,
17
+ StyleSheet,
18
+ NativeSyntheticEvent,
19
+ Animated,
20
+ processColor,
21
+ } from 'react-native';
22
+
23
+ import type { AnimatedLottieViewProps } from './LottieView.types';
24
+
25
+ import NativeLottieAnimationView, {
26
+ Commands,
27
+ } from './specs/LottieAnimationViewNativeComponent';
28
+
29
+ const AnimatedNativeLottieView = Animated.createAnimatedComponent(
30
+ NativeLottieAnimationView,
31
+ );
32
+
33
+ // amznmod_react - add textFiltersKepler prop for Kepler
34
+ const defaultProps: AnimatedLottieViewProps = {
35
+ source: undefined,
36
+ progress: 0,
37
+ speed: 1,
38
+ loop: true,
39
+ autoPlay: false,
40
+ autoSize: false,
41
+ enableMergePathsAndroidForKitKatAndAbove: false,
42
+ cacheComposition: true,
43
+ useNativeLooping: false,
44
+ resizeMode: 'contain',
45
+ colorFilters: [],
46
+ textFiltersAndroid: [],
47
+ textFiltersIOS: [],
48
+ textFiltersKepler: [],
49
+ };
50
+
51
+ /**
52
+ * View hosting the lottie animation.
53
+ */
54
+ export class AnimatedLottieView extends React.PureComponent<
55
+ AnimatedLottieViewProps,
56
+ {}
57
+ > {
58
+ static defaultProps = defaultProps;
59
+
60
+ _lottieAnimationViewRef:
61
+ | React.ElementRef<typeof NativeLottieAnimationView>
62
+ | undefined;
63
+
64
+ constructor(props: AnimatedLottieViewProps) {
65
+ super(props);
66
+ this.play = this.play.bind(this);
67
+ this.reset = this.reset.bind(this);
68
+ this.pause = this.pause.bind(this);
69
+ this.resume = this.resume.bind(this);
70
+ this.onAnimationFinish = this.onAnimationFinish.bind(this);
71
+ this._captureRef = this._captureRef.bind(this);
72
+ // amznmod_react - add onAnimation... callbacks
73
+ this.onAnimationLoad = this.onAnimationLoad.bind(this);
74
+ this.onAnimationPlay = this.onAnimationPlay.bind(this);
75
+ this.onAnimationPause = this.onAnimationPause.bind(this);
76
+ this.onAnimationResume = this.onAnimationResume.bind(this);
77
+ this.onAnimationJsonLoad = this.onAnimationJsonLoad.bind(this);
78
+ }
79
+
80
+ componentDidUpdate(prevProps: AnimatedLottieViewProps) {
81
+ if (
82
+ this.props.autoPlay === true &&
83
+ this.props.source !== prevProps.source &&
84
+ !!this.props.source
85
+ ) {
86
+ this.play();
87
+ }
88
+ }
89
+
90
+ play(startFrame?: number, endFrame?: number): void {
91
+ Commands.play(
92
+ this._lottieAnimationViewRef,
93
+ startFrame ?? -1,
94
+ endFrame ?? -1,
95
+ );
96
+ }
97
+
98
+ reset() {
99
+ Commands.reset(this._lottieAnimationViewRef);
100
+ }
101
+
102
+ pause() {
103
+ Commands.pause(this._lottieAnimationViewRef);
104
+ }
105
+
106
+ resume() {
107
+ Commands.resume(this._lottieAnimationViewRef);
108
+ }
109
+
110
+ onAnimationFinish = (evt: NativeSyntheticEvent<{ isCancelled: boolean }>) => {
111
+ if (this.props.onAnimationFinish) {
112
+ this.props.onAnimationFinish(evt.nativeEvent.isCancelled);
113
+ }
114
+ };
115
+
116
+ // amznmod_react - onAnimationLoad callback
117
+ onAnimationLoad = () => {
118
+ if (this.props.onAnimationLoad) {
119
+ this.props.onAnimationLoad();
120
+ }
121
+ };
122
+
123
+ // PROJ*-136246 - deprecate onAnimationJsonLoad in MR33
124
+ // amznmod_react - onAnimationLoad callback
125
+ onAnimationJsonLoad = () => {
126
+ console.warn("onAnimationJsonLoad will be deprecated in favor of onAnimationLoad in MR33. Migrate to use onAnimationLoad.")
127
+ if (this.props.onAnimationJsonLoad) {
128
+ this.props.onAnimationJsonLoad();
129
+ }
130
+ };
131
+
132
+ // amznmod_react - onAnimationPlay callback
133
+ onAnimationPlay = () => {
134
+ if (this.props.onAnimationPlay) {
135
+ this.props.onAnimationPlay();
136
+ }
137
+ };
138
+
139
+ // amznmod_react - onAnimationPause callback
140
+ onAnimationPause = () => {
141
+ if (this.props.onAnimationPause) {
142
+ this.props.onAnimationPause();
143
+ }
144
+ };
145
+
146
+ // amznmod_react - onAnimationResume callback
147
+ onAnimationResume = () => {
148
+ if (this.props.onAnimationResume) {
149
+ this.props.onAnimationResume();
150
+ }
151
+ };
152
+
153
+ _captureRef(ref: React.ElementRef<typeof NativeLottieAnimationView>) {
154
+ if (ref === null) {
155
+ return;
156
+ }
157
+
158
+ this._lottieAnimationViewRef = ref;
159
+ // amznmod_react - Fix for a crash on autoplay + progress with animation
160
+ if (this._lottieAnimationViewRef && this.props.autoPlay === true) {
161
+ this.play();
162
+ }
163
+ }
164
+
165
+ render(): React.ReactNode {
166
+ // amznmod_react - add textFiltersKepler prop
167
+ const {
168
+ style,
169
+ source,
170
+ autoSize,
171
+ autoPlay,
172
+ duration,
173
+ textFiltersAndroid,
174
+ textFiltersIOS,
175
+ textFiltersKepler,
176
+ ...rest
177
+ } = this.props;
178
+
179
+ const sourceName = typeof source === 'string' ? source : undefined;
180
+ const sourceJson =
181
+ typeof source === 'object' && !(source as any).uri
182
+ ? JSON.stringify(source)
183
+ : undefined;
184
+ const sourceURL =
185
+ typeof source === 'object' && (source as any).uri
186
+ ? (source as any).uri
187
+ : undefined;
188
+
189
+ const aspectRatioStyle = sourceJson
190
+ ? { aspectRatio: (source as any).w / (source as any).h }
191
+ : undefined;
192
+
193
+ const styleObject = StyleSheet.flatten(style);
194
+ let sizeStyle;
195
+ if (
196
+ !styleObject ||
197
+ (styleObject.width === undefined && styleObject.height === undefined)
198
+ ) {
199
+ sizeStyle =
200
+ autoSize && sourceJson
201
+ ? { width: (source as any).w }
202
+ : StyleSheet.absoluteFill;
203
+ }
204
+
205
+ const speed =
206
+ duration && sourceJson && (source as any).fr
207
+ ? Math.round(
208
+ (((source as any).op / (source as any).fr) * 1000) / duration,
209
+ )
210
+ : this.props.speed;
211
+
212
+ const colorFilters = this.props.colorFilters?.map((colorFilter) => ({
213
+ ...colorFilter,
214
+ color: processColor(colorFilter.color),
215
+ }));
216
+ // amznmod_react - Clip LottieView on ReactNative
217
+ const baseStyle= {
218
+ overflow: 'hidden',
219
+ };
220
+
221
+ return (
222
+ // amznmod_react - Clip LottieView on ReactNative
223
+ <View style={[aspectRatioStyle, sizeStyle, style, baseStyle]}>
224
+ <AnimatedNativeLottieView
225
+ ref={this._captureRef}
226
+ {...rest}
227
+ // amznmod_react - add autoPlay prop
228
+ autoPlay={autoPlay}
229
+ colorFilters={colorFilters}
230
+ textFiltersAndroid={textFiltersAndroid}
231
+ textFiltersIOS={textFiltersIOS}
232
+ // amznmod_react - add textFiltersKepler prop
233
+ // amznmod_react - Clip LottieView on ReactNative
234
+ textFiltersKepler={textFiltersKepler}
235
+ speed={speed}
236
+ style={[
237
+ aspectRatioStyle,
238
+ sizeStyle || { width: '100%', height: '100%' },
239
+ style,
240
+ baseStyle
241
+ ]}
242
+ sourceName={sourceName}
243
+ sourceJson={sourceJson}
244
+ sourceURL={sourceURL}
245
+ onAnimationFinish={this.onAnimationFinish}
246
+ //amznmod_react - add onAnimation... callbacks
247
+ onAnimationLoad={this.onAnimationLoad}
248
+ onAnimationPlay={this.onAnimationPlay}
249
+ onAnimationPause={this.onAnimationPause}
250
+ onAnimationResume={this.onAnimationResume}
251
+ // PROJ*-136246 - deprecate onAnimationJsonLoad in MR33
252
+ onAnimationJsonLoad={this.onAnimationJsonLoad}
253
+ />
254
+ </View>
255
+ );
256
+ }
257
+ }