react-native-macos 0.0.0-d74468479 → 0.0.0-d9a5f84e0

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 (178) hide show
  1. package/Libraries/Animated/AnimatedEvent.js +10 -5
  2. package/Libraries/Animated/AnimatedImplementation.js +39 -7
  3. package/Libraries/Animated/AnimatedMock.js +6 -3
  4. package/Libraries/Animated/AnimatedPlatformConfig.js +13 -0
  5. package/Libraries/Animated/Easing.js +36 -36
  6. package/Libraries/Animated/animations/Animation.js +5 -3
  7. package/Libraries/Animated/animations/DecayAnimation.js +5 -0
  8. package/Libraries/Animated/animations/SpringAnimation.js +15 -0
  9. package/Libraries/Animated/animations/TimingAnimation.js +14 -1
  10. package/Libraries/Animated/nodes/AnimatedAddition.js +5 -4
  11. package/Libraries/Animated/nodes/AnimatedColor.js +266 -0
  12. package/Libraries/Animated/nodes/AnimatedDiffClamp.js +4 -3
  13. package/Libraries/Animated/nodes/AnimatedDivision.js +5 -4
  14. package/Libraries/Animated/nodes/AnimatedInterpolation.js +5 -3
  15. package/Libraries/Animated/nodes/AnimatedModulo.js +4 -3
  16. package/Libraries/Animated/nodes/AnimatedMultiplication.js +5 -4
  17. package/Libraries/Animated/nodes/AnimatedNode.js +17 -5
  18. package/Libraries/Animated/nodes/AnimatedProps.js +11 -3
  19. package/Libraries/Animated/nodes/AnimatedStyle.js +6 -4
  20. package/Libraries/Animated/nodes/AnimatedSubtraction.js +5 -4
  21. package/Libraries/Animated/nodes/AnimatedTracking.js +7 -5
  22. package/Libraries/Animated/nodes/AnimatedTransform.js +5 -3
  23. package/Libraries/Animated/nodes/AnimatedValue.js +2 -0
  24. package/Libraries/Animated/nodes/AnimatedWithChildren.js +5 -4
  25. package/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js +2 -2
  26. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +3 -3
  27. package/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js +2 -0
  28. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +12 -0
  29. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +130 -68
  30. package/Libraries/Components/Slider/SliderNativeComponent.js +2 -2
  31. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +115 -2
  32. package/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +8 -1
  33. package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +4 -1
  34. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +31 -8
  35. package/Libraries/Components/Touchable/TouchableOpacity.js +0 -1
  36. package/Libraries/Components/View/ViewPropTypes.js +7 -0
  37. package/Libraries/Core/ReactNativeVersion.js +1 -1
  38. package/Libraries/Core/ReactNativeVersionCheck.js +1 -0
  39. package/Libraries/Core/Timers/JSTimers.js +17 -28
  40. package/Libraries/Image/Image.android.js +16 -7
  41. package/Libraries/Image/ImageViewNativeComponent.js +94 -57
  42. package/Libraries/Image/RCTImageView.mm +22 -14
  43. package/Libraries/Image/TextInlineImageNativeComponent.js +10 -68
  44. package/Libraries/Lists/VirtualizedList.js +8 -6
  45. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +0 -1
  46. package/Libraries/Modal/Modal.js +0 -1
  47. package/Libraries/NativeComponent/StaticViewConfigValidator.js +39 -0
  48. package/Libraries/Network/XMLHttpRequest.js +0 -1
  49. package/Libraries/Performance/QuickPerformanceLogger.js +17 -0
  50. package/Libraries/ReactNative/UIManager.js +5 -10
  51. package/Libraries/ReactNative/UIManagerInjection.js +3 -3
  52. package/Libraries/ReactNative/getNativeComponentAttributes.js +4 -0
  53. package/Libraries/Renderer/REVISION +1 -1
  54. package/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +278 -356
  55. package/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +87 -78
  56. package/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +340 -393
  57. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +278 -356
  58. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +87 -78
  59. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +340 -393
  60. package/Libraries/Text/RCTTextAttributes.m +18 -1
  61. package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +2 -0
  62. package/Libraries/WebSocket/RCTSRWebSocket.m +4 -0
  63. package/React/Base/RCTConvert.m +18 -1
  64. package/React/Base/RCTVersion.m +1 -1
  65. package/React/CoreModules/RCTAlertController.m +6 -0
  66. package/React/CoreModules/RCTDevSettings.mm +33 -12
  67. package/React/CoreModules/RCTExceptionsManager.mm +1 -1
  68. package/React/Fabric/RCTSurfacePresenter.mm +0 -2
  69. package/React/Views/RCTFont.mm +11 -9
  70. package/React/Views/RCTModalHostView.h +5 -0
  71. package/React/Views/RCTModalHostViewManager.m +3 -0
  72. package/React/Views/RCTSliderManager.m +1 -0
  73. package/ReactAndroid/build.gradle +14 -5
  74. package/ReactAndroid/gradle.properties +3 -3
  75. package/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +12 -4
  76. package/ReactAndroid/src/main/java/com/facebook/react/animated/AdditionAnimatedNode.java +1 -1
  77. package/ReactAndroid/src/main/java/com/facebook/react/animated/DiffClampAnimatedNode.java +1 -1
  78. package/ReactAndroid/src/main/java/com/facebook/react/animated/EventAnimationDriver.java +39 -3
  79. package/ReactAndroid/src/main/java/com/facebook/react/animated/ModulusAnimatedNode.java +2 -2
  80. package/ReactAndroid/src/main/java/com/facebook/react/animated/MultiplicationAnimatedNode.java +1 -1
  81. package/ReactAndroid/src/main/java/com/facebook/react/animated/SubtractionAnimatedNode.java +3 -3
  82. package/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModuleRegistry.java +0 -4
  83. package/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModuleRegistry.java +0 -3
  84. package/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java +0 -6
  85. package/ReactAndroid/src/main/java/com/facebook/react/bridge/WritableNativeArray.java +6 -6
  86. package/ReactAndroid/src/main/java/com/facebook/react/bridge/WritableNativeMap.java +6 -6
  87. package/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/ReadableMapBuffer.java +119 -78
  88. package/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/react/common/mapbuffer/ReadableMapBuffer.cpp +7 -35
  89. package/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/react/common/mapbuffer/ReadableMapBuffer.h +5 -18
  90. package/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +0 -14
  91. package/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java +1 -1
  92. package/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +0 -2
  93. package/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/FabricMountingManager.cpp +2 -1
  94. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
  95. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java +15 -0
  96. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerAdapter.java +4 -0
  97. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/PointerEvents.java +18 -0
  98. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java +12 -0
  99. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java +2 -2
  100. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +0 -3
  101. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/BaseViewManagerDelegate.java +4 -0
  102. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/BaseViewManagerInterface.java +3 -0
  103. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/ViewProps.java +1 -0
  104. package/ReactAndroid/src/main/java/com/facebook/react/views/drawer/ReactDrawerLayoutManager.java +3 -0
  105. package/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostManager.java +8 -0
  106. package/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ReactProgressBarViewManager.java +2 -0
  107. package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java +22 -5
  108. package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java +6 -0
  109. package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java +22 -5
  110. package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewHelper.java +23 -14
  111. package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java +6 -0
  112. package/ReactAndroid/src/main/java/com/facebook/react/views/slider/ReactSliderManager.java +24 -0
  113. package/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java +8 -8
  114. package/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java +1 -1
  115. package/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageShadowNode.java +1 -1
  116. package/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageViewManager.java +2 -2
  117. package/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java +1 -8
  118. package/ReactAndroid/src/main/jni/react/jni/JSLoader.cpp +40 -16
  119. package/ReactAndroid/src/main/jni/react/jni/WritableNativeArray.cpp +3 -3
  120. package/ReactAndroid/src/main/jni/react/jni/WritableNativeArray.h +3 -3
  121. package/ReactAndroid/src/main/jni/react/jni/WritableNativeMap.cpp +2 -2
  122. package/ReactAndroid/src/main/jni/react/jni/WritableNativeMap.h +3 -3
  123. package/ReactAndroid/src/main/res/views/uimanager/values/ids.xml +3 -0
  124. package/ReactAndroid/src/main/third-party/java/okhttp/BUCK +4 -4
  125. package/ReactCommon/cxxreact/JSBigString.cpp +0 -65
  126. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  127. package/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm +8 -3
  128. package/ReactCommon/react/renderer/attributedstring/conversions.h +38 -38
  129. package/ReactCommon/react/renderer/components/text/conversions.h +4 -4
  130. package/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp +5 -5
  131. package/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp +10 -1
  132. package/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp +64 -85
  133. package/ReactCommon/react/renderer/mapbuffer/MapBuffer.h +101 -27
  134. package/ReactCommon/react/renderer/mapbuffer/MapBufferBuilder.cpp +86 -165
  135. package/ReactCommon/react/renderer/mapbuffer/MapBufferBuilder.h +22 -57
  136. package/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp +36 -26
  137. package/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp +9 -19
  138. package/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h +30 -12
  139. package/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp +1 -1
  140. package/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp +4 -11
  141. package/ReactCommon/react/renderer/runtimescheduler/tests/StubQueue.h +1 -0
  142. package/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +4 -0
  143. package/jest/mockModal.js +2 -2
  144. package/package.json +11 -48
  145. package/react.gradle +0 -4
  146. package/scripts/find-node.sh +7 -0
  147. package/scripts/react_native_pods.rb +6 -5
  148. package/scripts/react_native_pods_utils/script_phases.rb +2 -2
  149. package/scripts/react_native_pods_utils/script_phases.sh +1 -1
  150. package/template/Gemfile.lock +3 -3
  151. package/template/_flowconfig +1 -1
  152. package/template/_gitignore +2 -1
  153. package/template/android/build.gradle +1 -1
  154. package/template/android/gradle.properties +1 -1
  155. package/template/android/settings.gradle +1 -5
  156. package/template/ios/Podfile +1 -0
  157. package/template/package.json +3 -3
  158. package/Libraries/Components/TextInput/AndroidTextInputViewConfig.js +0 -113
  159. package/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js +0 -76
  160. package/Libraries/DeprecatedPropTypes/DeprecatedEdgeInsetsPropType.js +0 -28
  161. package/Libraries/DeprecatedPropTypes/DeprecatedImagePropType.android.js +0 -131
  162. package/Libraries/DeprecatedPropTypes/DeprecatedImagePropType.ios.js +0 -82
  163. package/Libraries/DeprecatedPropTypes/DeprecatedImageSourcePropType.js +0 -40
  164. package/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js +0 -76
  165. package/Libraries/DeprecatedPropTypes/DeprecatedLayoutPropTypes.js +0 -233
  166. package/Libraries/DeprecatedPropTypes/DeprecatedPointPropType.js +0 -24
  167. package/Libraries/DeprecatedPropTypes/DeprecatedShadowPropTypesIOS.js +0 -30
  168. package/Libraries/DeprecatedPropTypes/DeprecatedStyleSheetPropType.js +0 -32
  169. package/Libraries/DeprecatedPropTypes/DeprecatedTextInputPropTypes.js +0 -693
  170. package/Libraries/DeprecatedPropTypes/DeprecatedTextPropTypes.js +0 -158
  171. package/Libraries/DeprecatedPropTypes/DeprecatedTextStylePropTypes.js +0 -168
  172. package/Libraries/DeprecatedPropTypes/DeprecatedTransformPropTypes.js +0 -99
  173. package/Libraries/DeprecatedPropTypes/DeprecatedViewAccessibility.js +0 -46
  174. package/Libraries/DeprecatedPropTypes/DeprecatedViewPropTypes.js +0 -408
  175. package/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js +0 -68
  176. package/Libraries/DeprecatedPropTypes/deprecatedCreateStrictShapeTypeChecker.js +0 -86
  177. package/ReactCommon/react/renderer/mapbuffer/primitives.h +0 -91
  178. package/flow-typed/npm/prop-types_v15.x.x.js +0 -42
@@ -19,6 +19,8 @@ const invariant = require('invariant');
19
19
 
20
20
  const {shouldUseNativeDriver} = require('./NativeAnimatedHelper');
21
21
 
22
+ import type {PlatformConfig} from './AnimatedPlatformConfig';
23
+
22
24
  export type Mapping =
23
25
  | {[key: string]: Mapping, ...}
24
26
  | AnimatedValue
@@ -26,12 +28,14 @@ export type Mapping =
26
28
  export type EventConfig = {
27
29
  listener?: ?Function,
28
30
  useNativeDriver: boolean,
31
+ platformConfig?: PlatformConfig,
29
32
  };
30
33
 
31
34
  function attachNativeEvent(
32
35
  viewRef: any,
33
36
  eventName: string,
34
37
  argMapping: $ReadOnlyArray<?Mapping>,
38
+ platformConfig: ?PlatformConfig,
35
39
  ): {detach: () => void} {
36
40
  // Find animated values in `argMapping` and create an array representing their
37
41
  // key path inside the `nativeEvent` object. Ex.: ['contentOffset', 'x'].
@@ -39,7 +43,7 @@ function attachNativeEvent(
39
43
 
40
44
  const traverse = (value, path) => {
41
45
  if (value instanceof AnimatedValue) {
42
- value.__makeNative();
46
+ value.__makeNative(platformConfig);
43
47
 
44
48
  eventMappings.push({
45
49
  nativeEventPath: path,
@@ -145,9 +149,9 @@ function validateMapping(argMapping, args) {
145
149
  class AnimatedEvent {
146
150
  _argMapping: $ReadOnlyArray<?Mapping>;
147
151
  _listeners: Array<Function> = [];
148
- _callListeners: Function;
149
152
  _attachedEvent: ?{detach: () => void, ...};
150
153
  __isNative: boolean;
154
+ __platformConfig: ?PlatformConfig;
151
155
 
152
156
  constructor(argMapping: $ReadOnlyArray<?Mapping>, config: EventConfig) {
153
157
  this._argMapping = argMapping;
@@ -160,9 +164,9 @@ class AnimatedEvent {
160
164
  if (config.listener) {
161
165
  this.__addListener(config.listener);
162
166
  }
163
- this._callListeners = this._callListeners.bind(this);
164
167
  this._attachedEvent = null;
165
168
  this.__isNative = shouldUseNativeDriver(config);
169
+ this.__platformConfig = config.platformConfig;
166
170
  }
167
171
 
168
172
  __addListener(callback: Function): void {
@@ -183,6 +187,7 @@ class AnimatedEvent {
183
187
  viewRef,
184
188
  eventName,
185
189
  this._argMapping,
190
+ this.__platformConfig,
186
191
  );
187
192
  }
188
193
 
@@ -245,9 +250,9 @@ class AnimatedEvent {
245
250
  };
246
251
  }
247
252
 
248
- _callListeners(...args: any) {
253
+ _callListeners = (...args: any) => {
249
254
  this._listeners.forEach(listener => listener(...args));
250
- }
255
+ };
251
256
  }
252
257
 
253
258
  module.exports = {AnimatedEvent, attachNativeEvent};
@@ -38,6 +38,8 @@ import type {DecayAnimationConfig} from './animations/DecayAnimation';
38
38
  import type {SpringAnimationConfig} from './animations/SpringAnimation';
39
39
  import type {Mapping, EventConfig} from './AnimatedEvent';
40
40
 
41
+ import AnimatedColor from './nodes/AnimatedColor';
42
+
41
43
  export type CompositeAnimation = {
42
44
  start: (callback?: ?EndCallback) => void,
43
45
  stop: () => void,
@@ -102,7 +104,7 @@ const _combineCallbacks = function(
102
104
  };
103
105
 
104
106
  const maybeVectorAnim = function(
105
- value: AnimatedValue | AnimatedValueXY,
107
+ value: AnimatedValue | AnimatedValueXY | AnimatedColor,
106
108
  config: Object,
107
109
  anim: (value: AnimatedValue, config: Object) => CompositeAnimation,
108
110
  ): ?CompositeAnimation {
@@ -121,16 +123,42 @@ const maybeVectorAnim = function(
121
123
  // We use `stopTogether: false` here because otherwise tracking will break
122
124
  // because the second animation will get stopped before it can update.
123
125
  return parallel([aX, aY], {stopTogether: false});
126
+ } else if (value instanceof AnimatedColor) {
127
+ const configR = {...config};
128
+ const configG = {...config};
129
+ const configB = {...config};
130
+ const configA = {...config};
131
+ for (const key in config) {
132
+ const {r, g, b, a} = config[key];
133
+ if (
134
+ r !== undefined &&
135
+ g !== undefined &&
136
+ b !== undefined &&
137
+ a !== undefined
138
+ ) {
139
+ configR[key] = r;
140
+ configG[key] = g;
141
+ configB[key] = b;
142
+ configA[key] = a;
143
+ }
144
+ }
145
+ const aR = anim((value: AnimatedColor).r, configR);
146
+ const aG = anim((value: AnimatedColor).g, configG);
147
+ const aB = anim((value: AnimatedColor).b, configB);
148
+ const aA = anim((value: AnimatedColor).a, configA);
149
+ // We use `stopTogether: false` here because otherwise tracking will break
150
+ // because the second animation will get stopped before it can update.
151
+ return parallel([aR, aG, aB, aA], {stopTogether: false});
124
152
  }
125
153
  return null;
126
154
  };
127
155
 
128
156
  const spring = function(
129
- value: AnimatedValue | AnimatedValueXY,
157
+ value: AnimatedValue | AnimatedValueXY | AnimatedColor,
130
158
  config: SpringAnimationConfig,
131
159
  ): CompositeAnimation {
132
160
  const start = function(
133
- animatedValue: AnimatedValue | AnimatedValueXY,
161
+ animatedValue: AnimatedValue | AnimatedValueXY | AnimatedColor,
134
162
  configuration: SpringAnimationConfig,
135
163
  callback?: ?EndCallback,
136
164
  ): void {
@@ -179,11 +207,11 @@ const spring = function(
179
207
  };
180
208
 
181
209
  const timing = function(
182
- value: AnimatedValue | AnimatedValueXY,
210
+ value: AnimatedValue | AnimatedValueXY | AnimatedColor,
183
211
  config: TimingAnimationConfig,
184
212
  ): CompositeAnimation {
185
213
  const start = function(
186
- animatedValue: AnimatedValue | AnimatedValueXY,
214
+ animatedValue: AnimatedValue | AnimatedValueXY | AnimatedColor,
187
215
  configuration: TimingAnimationConfig,
188
216
  callback?: ?EndCallback,
189
217
  ): void {
@@ -233,11 +261,11 @@ const timing = function(
233
261
  };
234
262
 
235
263
  const decay = function(
236
- value: AnimatedValue | AnimatedValueXY,
264
+ value: AnimatedValue | AnimatedValueXY | AnimatedColor,
237
265
  config: DecayAnimationConfig,
238
266
  ): CompositeAnimation {
239
267
  const start = function(
240
- animatedValue: AnimatedValue | AnimatedValueXY,
268
+ animatedValue: AnimatedValue | AnimatedValueXY | AnimatedColor,
241
269
  configuration: DecayAnimationConfig,
242
270
  callback?: ?EndCallback,
243
271
  ): void {
@@ -547,6 +575,10 @@ module.exports = {
547
575
  * See https://reactnative.dev/docs/animatedvaluexy
548
576
  */
549
577
  ValueXY: AnimatedValueXY,
578
+ /**
579
+ * Value class for driving color animations.
580
+ */
581
+ Color: AnimatedColor,
550
582
  /**
551
583
  * Exported to use the Interpolation type in flow.
552
584
  *
@@ -24,6 +24,8 @@ import type {TimingAnimationConfig} from './animations/TimingAnimation';
24
24
  import type {DecayAnimationConfig} from './animations/DecayAnimation';
25
25
  import type {SpringAnimationConfig} from './animations/SpringAnimation';
26
26
 
27
+ import AnimatedColor from './nodes/AnimatedColor';
28
+
27
29
  /**
28
30
  * Animations are a source of flakiness in snapshot testing. This mock replaces
29
31
  * animation functions from AnimatedImplementation with empty animations for
@@ -89,7 +91,7 @@ const mockCompositeAnimation = (
89
91
  });
90
92
 
91
93
  const spring = function(
92
- value: AnimatedValue | AnimatedValueXY,
94
+ value: AnimatedValue | AnimatedValueXY | AnimatedColor,
93
95
  config: SpringAnimationConfig,
94
96
  ): CompositeAnimation {
95
97
  const anyValue: any = value;
@@ -109,7 +111,7 @@ const spring = function(
109
111
  };
110
112
 
111
113
  const timing = function(
112
- value: AnimatedValue | AnimatedValueXY,
114
+ value: AnimatedValue | AnimatedValueXY | AnimatedColor,
113
115
  config: TimingAnimationConfig,
114
116
  ): CompositeAnimation {
115
117
  const anyValue: any = value;
@@ -123,7 +125,7 @@ const timing = function(
123
125
  };
124
126
 
125
127
  const decay = function(
126
- value: AnimatedValue | AnimatedValueXY,
128
+ value: AnimatedValue | AnimatedValueXY | AnimatedColor,
127
129
  config: DecayAnimationConfig,
128
130
  ): CompositeAnimation {
129
131
  return emptyAnimation;
@@ -170,6 +172,7 @@ const loop = function(
170
172
  module.exports = {
171
173
  Value: AnimatedValue,
172
174
  ValueXY: AnimatedValueXY,
175
+ Color: AnimatedColor,
173
176
  Interpolation: AnimatedInterpolation,
174
177
  Node: AnimatedNode,
175
178
  decay,
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow
8
+ * @format
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ export type PlatformConfig = {};
@@ -57,20 +57,20 @@ let ease;
57
57
  * - [`inOut`](docs/easing.html#inout) makes any easing function symmetrical
58
58
  * - [`out`](docs/easing.html#out) runs an easing function backwards
59
59
  */
60
- class Easing {
60
+ const Easing = {
61
61
  /**
62
62
  * A stepping function, returns 1 for any positive value of `n`.
63
63
  */
64
- static step0(n: number): number {
64
+ step0(n: number): number {
65
65
  return n > 0 ? 1 : 0;
66
- }
66
+ },
67
67
 
68
68
  /**
69
69
  * A stepping function, returns 1 if `n` is greater than or equal to 1.
70
70
  */
71
- static step1(n: number): number {
71
+ step1(n: number): number {
72
72
  return n >= 1 ? 1 : 0;
73
- }
73
+ },
74
74
 
75
75
  /**
76
76
  * A linear function, `f(t) = t`. Position correlates to elapsed time one to
@@ -78,9 +78,9 @@ class Easing {
78
78
  *
79
79
  * http://cubic-bezier.com/#0,0,1,1
80
80
  */
81
- static linear(t: number): number {
81
+ linear(t: number): number {
82
82
  return t;
83
- }
83
+ },
84
84
 
85
85
  /**
86
86
  * A simple inertial interaction, similar to an object slowly accelerating to
@@ -88,12 +88,12 @@ class Easing {
88
88
  *
89
89
  * http://cubic-bezier.com/#.42,0,1,1
90
90
  */
91
- static ease(t: number): number {
91
+ ease(t: number): number {
92
92
  if (!ease) {
93
93
  ease = Easing.bezier(0.42, 0, 1, 1);
94
94
  }
95
95
  return ease(t);
96
- }
96
+ },
97
97
 
98
98
  /**
99
99
  * A quadratic function, `f(t) = t * t`. Position equals the square of elapsed
@@ -101,9 +101,9 @@ class Easing {
101
101
  *
102
102
  * http://easings.net/#easeInQuad
103
103
  */
104
- static quad(t: number): number {
104
+ quad(t: number): number {
105
105
  return t * t;
106
- }
106
+ },
107
107
 
108
108
  /**
109
109
  * A cubic function, `f(t) = t * t * t`. Position equals the cube of elapsed
@@ -111,9 +111,9 @@ class Easing {
111
111
  *
112
112
  * http://easings.net/#easeInCubic
113
113
  */
114
- static cubic(t: number): number {
114
+ cubic(t: number): number {
115
115
  return t * t * t;
116
- }
116
+ },
117
117
 
118
118
  /**
119
119
  * A power function. Position is equal to the Nth power of elapsed time.
@@ -121,36 +121,36 @@ class Easing {
121
121
  * n = 4: http://easings.net/#easeInQuart
122
122
  * n = 5: http://easings.net/#easeInQuint
123
123
  */
124
- static poly(n: number): (t: number) => number {
124
+ poly(n: number): (t: number) => number {
125
125
  return (t: number) => Math.pow(t, n);
126
- }
126
+ },
127
127
 
128
128
  /**
129
129
  * A sinusoidal function.
130
130
  *
131
131
  * http://easings.net/#easeInSine
132
132
  */
133
- static sin(t: number): number {
133
+ sin(t: number): number {
134
134
  return 1 - Math.cos((t * Math.PI) / 2);
135
- }
135
+ },
136
136
 
137
137
  /**
138
138
  * A circular function.
139
139
  *
140
140
  * http://easings.net/#easeInCirc
141
141
  */
142
- static circle(t: number): number {
142
+ circle(t: number): number {
143
143
  return 1 - Math.sqrt(1 - t * t);
144
- }
144
+ },
145
145
 
146
146
  /**
147
147
  * An exponential function.
148
148
  *
149
149
  * http://easings.net/#easeInExpo
150
150
  */
151
- static exp(t: number): number {
151
+ exp(t: number): number {
152
152
  return Math.pow(2, 10 * (t - 1));
153
- }
153
+ },
154
154
 
155
155
  /**
156
156
  * A simple elastic interaction, similar to a spring oscillating back and
@@ -162,10 +162,10 @@ class Easing {
162
162
  *
163
163
  * http://easings.net/#easeInElastic
164
164
  */
165
- static elastic(bounciness: number = 1): (t: number) => number {
165
+ elastic(bounciness: number = 1): (t: number) => number {
166
166
  const p = bounciness * Math.PI;
167
167
  return t => 1 - Math.pow(Math.cos((t * Math.PI) / 2), 3) * Math.cos(t * p);
168
- }
168
+ },
169
169
 
170
170
  /**
171
171
  * Use with `Animated.parallel()` to create a simple effect where the object
@@ -173,16 +173,16 @@ class Easing {
173
173
  *
174
174
  * https://easings.net/#easeInBack
175
175
  */
176
- static back(s: number = 1.70158): (t: number) => number {
176
+ back(s: number = 1.70158): (t: number) => number {
177
177
  return t => t * t * ((s + 1) * t - s);
178
- }
178
+ },
179
179
 
180
180
  /**
181
181
  * Provides a simple bouncing effect.
182
182
  *
183
183
  * http://easings.net/#easeInBounce
184
184
  */
185
- static bounce(t: number): number {
185
+ bounce(t: number): number {
186
186
  if (t < 1 / 2.75) {
187
187
  return 7.5625 * t * t;
188
188
  }
@@ -199,7 +199,7 @@ class Easing {
199
199
 
200
200
  const t2 = t - 2.625 / 2.75;
201
201
  return 7.5625 * t2 * t2 + 0.984375;
202
- }
202
+ },
203
203
 
204
204
  /**
205
205
  * Provides a cubic bezier curve, equivalent to CSS Transitions'
@@ -208,7 +208,7 @@ class Easing {
208
208
  * A useful tool to visualize cubic bezier curves can be found at
209
209
  * http://cubic-bezier.com/
210
210
  */
211
- static bezier(
211
+ bezier(
212
212
  x1: number,
213
213
  y1: number,
214
214
  x2: number,
@@ -216,35 +216,35 @@ class Easing {
216
216
  ): (t: number) => number {
217
217
  const _bezier = require('./bezier');
218
218
  return _bezier(x1, y1, x2, y2);
219
- }
219
+ },
220
220
 
221
221
  /**
222
222
  * Runs an easing function forwards.
223
223
  */
224
- static in(easing: (t: number) => number): (t: number) => number {
224
+ in(easing: (t: number) => number): (t: number) => number {
225
225
  return easing;
226
- }
226
+ },
227
227
 
228
228
  /**
229
229
  * Runs an easing function backwards.
230
230
  */
231
- static out(easing: (t: number) => number): (t: number) => number {
231
+ out(easing: (t: number) => number): (t: number) => number {
232
232
  return t => 1 - easing(1 - t);
233
- }
233
+ },
234
234
 
235
235
  /**
236
236
  * Makes any easing function symmetrical. The easing function will run
237
237
  * forwards for half of the duration, then backwards for the rest of the
238
238
  * duration.
239
239
  */
240
- static inOut(easing: (t: number) => number): (t: number) => number {
240
+ inOut(easing: (t: number) => number): (t: number) => number {
241
241
  return t => {
242
242
  if (t < 0.5) {
243
243
  return easing(t * 2) / 2;
244
244
  }
245
245
  return 1 - easing((1 - t) * 2) / 2;
246
246
  };
247
- }
248
- }
247
+ },
248
+ };
249
249
 
250
250
  module.exports = Easing;
@@ -11,7 +11,7 @@
11
11
  'use strict';
12
12
 
13
13
  const NativeAnimatedHelper = require('../NativeAnimatedHelper');
14
-
14
+ import type {PlatformConfig} from '../AnimatedPlatformConfig';
15
15
  import type AnimatedValue from '../nodes/AnimatedValue';
16
16
 
17
17
  export type EndResult = {finished: boolean, ...};
@@ -20,6 +20,7 @@ export type EndCallback = (result: EndResult) => void;
20
20
  export type AnimationConfig = {
21
21
  isInteraction?: boolean,
22
22
  useNativeDriver: boolean,
23
+ platformConfig?: PlatformConfig,
23
24
  onComplete?: ?EndCallback,
24
25
  iterations?: number,
25
26
  };
@@ -65,12 +66,13 @@ class Animation {
65
66
  startNativeAnimationWaitId,
66
67
  );
67
68
  try {
68
- animatedValue.__makeNative();
69
+ const config = this.__getNativeAnimationConfig();
70
+ animatedValue.__makeNative(config.platformConfig);
69
71
  this.__nativeId = NativeAnimatedHelper.generateNewAnimationId();
70
72
  NativeAnimatedHelper.API.startAnimatingNode(
71
73
  this.__nativeId,
72
74
  animatedValue.__getNativeTag(),
73
- this.__getNativeAnimationConfig(),
75
+ config,
74
76
  // $FlowFixMe[method-unbinding] added when improving typing for this parameters
75
77
  this.__debouncedOnEnd.bind(this),
76
78
  );
@@ -14,6 +14,7 @@ const Animation = require('./Animation');
14
14
 
15
15
  const {shouldUseNativeDriver} = require('../NativeAnimatedHelper');
16
16
 
17
+ import type {PlatformConfig} from '../AnimatedPlatformConfig';
17
18
  import type AnimatedValue from '../nodes/AnimatedValue';
18
19
  import type {AnimationConfig, EndCallback} from './Animation';
19
20
 
@@ -44,12 +45,14 @@ class DecayAnimation extends Animation {
44
45
  _onUpdate: (value: number) => void;
45
46
  _animationFrame: any;
46
47
  _useNativeDriver: boolean;
48
+ _platformConfig: ?PlatformConfig;
47
49
 
48
50
  constructor(config: DecayAnimationConfigSingle) {
49
51
  super();
50
52
  this._deceleration = config.deceleration ?? 0.998;
51
53
  this._velocity = config.velocity;
52
54
  this._useNativeDriver = shouldUseNativeDriver(config);
55
+ this._platformConfig = config.platformConfig;
53
56
  this.__isInteraction = config.isInteraction ?? !this._useNativeDriver;
54
57
  this.__iterations = config.iterations ?? 1;
55
58
  }
@@ -57,6 +60,7 @@ class DecayAnimation extends Animation {
57
60
  __getNativeAnimationConfig(): {|
58
61
  deceleration: number,
59
62
  iterations: number,
63
+ platformConfig: ?PlatformConfig,
60
64
  type: $TEMPORARY$string<'decay'>,
61
65
  velocity: number,
62
66
  |} {
@@ -65,6 +69,7 @@ class DecayAnimation extends Animation {
65
69
  deceleration: this._deceleration,
66
70
  velocity: this._velocity,
67
71
  iterations: this.__iterations,
72
+ platformConfig: this._platformConfig,
68
73
  };
69
74
  }
70
75
 
@@ -20,8 +20,11 @@ const invariant = require('invariant');
20
20
 
21
21
  const {shouldUseNativeDriver} = require('../NativeAnimatedHelper');
22
22
 
23
+ import type {PlatformConfig} from '../AnimatedPlatformConfig';
23
24
  import type {AnimationConfig, EndCallback} from './Animation';
24
25
 
26
+ import AnimatedColor from '../nodes/AnimatedColor';
27
+
25
28
  export type SpringAnimationConfig = {
26
29
  ...AnimationConfig,
27
30
  toValue:
@@ -33,6 +36,14 @@ export type SpringAnimationConfig = {
33
36
  ...
34
37
  }
35
38
  | AnimatedValueXY
39
+ | {
40
+ r: number,
41
+ g: number,
42
+ b: number,
43
+ a: number,
44
+ ...
45
+ }
46
+ | AnimatedColor
36
47
  | AnimatedInterpolation,
37
48
  overshootClamping?: boolean,
38
49
  restDisplacementThreshold?: number,
@@ -92,6 +103,7 @@ class SpringAnimation extends Animation {
92
103
  _onUpdate: (value: number) => void;
93
104
  _animationFrame: any;
94
105
  _useNativeDriver: boolean;
106
+ _platformConfig: ?PlatformConfig;
95
107
 
96
108
  constructor(config: SpringAnimationConfigSingle) {
97
109
  super();
@@ -104,6 +116,7 @@ class SpringAnimation extends Animation {
104
116
  this._toValue = config.toValue;
105
117
  this._delay = config.delay ?? 0;
106
118
  this._useNativeDriver = shouldUseNativeDriver(config);
119
+ this._platformConfig = config.platformConfig;
107
120
  this.__isInteraction = config.isInteraction ?? !this._useNativeDriver;
108
121
  this.__iterations = config.iterations ?? 1;
109
122
 
@@ -162,6 +175,7 @@ class SpringAnimation extends Animation {
162
175
  initialVelocity: number,
163
176
  iterations: number,
164
177
  mass: number,
178
+ platformConfig: ?PlatformConfig,
165
179
  overshootClamping: boolean,
166
180
  restDisplacementThreshold: number,
167
181
  restSpeedThreshold: number,
@@ -180,6 +194,7 @@ class SpringAnimation extends Animation {
180
194
  initialVelocity: this._initialVelocity ?? this._lastVelocity,
181
195
  toValue: this._toValue,
182
196
  iterations: this.__iterations,
197
+ platformConfig: this._platformConfig,
183
198
  };
184
199
  }
185
200
 
@@ -17,8 +17,11 @@ const Animation = require('./Animation');
17
17
 
18
18
  const {shouldUseNativeDriver} = require('../NativeAnimatedHelper');
19
19
 
20
+ import type {PlatformConfig} from '../AnimatedPlatformConfig';
20
21
  import type {AnimationConfig, EndCallback} from './Animation';
21
22
 
23
+ import AnimatedColor from '../nodes/AnimatedColor';
24
+
22
25
  export type TimingAnimationConfig = {
23
26
  ...AnimationConfig,
24
27
  toValue:
@@ -30,6 +33,14 @@ export type TimingAnimationConfig = {
30
33
  ...
31
34
  }
32
35
  | AnimatedValueXY
36
+ | {
37
+ r: number,
38
+ g: number,
39
+ b: number,
40
+ a: number,
41
+ ...
42
+ }
43
+ | AnimatedColor
33
44
  | AnimatedInterpolation,
34
45
  easing?: (value: number) => number,
35
46
  duration?: number,
@@ -48,7 +59,6 @@ let _easeInOut;
48
59
  function easeInOut() {
49
60
  if (!_easeInOut) {
50
61
  const Easing = require('../Easing');
51
- // $FlowFixMe[method-unbinding]
52
62
  _easeInOut = Easing.inOut(Easing.ease);
53
63
  }
54
64
  return _easeInOut;
@@ -65,6 +75,7 @@ class TimingAnimation extends Animation {
65
75
  _animationFrame: any;
66
76
  _timeout: any;
67
77
  _useNativeDriver: boolean;
78
+ _platformConfig: ?PlatformConfig;
68
79
 
69
80
  constructor(config: TimingAnimationConfigSingle) {
70
81
  super();
@@ -74,6 +85,7 @@ class TimingAnimation extends Animation {
74
85
  this._delay = config.delay ?? 0;
75
86
  this.__iterations = config.iterations ?? 1;
76
87
  this._useNativeDriver = shouldUseNativeDriver(config);
88
+ this._platformConfig = config.platformConfig;
77
89
  this.__isInteraction = config.isInteraction ?? !this._useNativeDriver;
78
90
  }
79
91
 
@@ -90,6 +102,7 @@ class TimingAnimation extends Animation {
90
102
  frames,
91
103
  toValue: this._toValue,
92
104
  iterations: this.__iterations,
105
+ platformConfig: this._platformConfig,
93
106
  };
94
107
  }
95
108
 
@@ -15,6 +15,7 @@ const AnimatedNode = require('./AnimatedNode');
15
15
  const AnimatedValue = require('./AnimatedValue');
16
16
  const AnimatedWithChildren = require('./AnimatedWithChildren');
17
17
 
18
+ import type {PlatformConfig} from '../AnimatedPlatformConfig';
18
19
  import type {InterpolationConfigType} from './AnimatedInterpolation';
19
20
 
20
21
  class AnimatedAddition extends AnimatedWithChildren {
@@ -27,10 +28,10 @@ class AnimatedAddition extends AnimatedWithChildren {
27
28
  this._b = typeof b === 'number' ? new AnimatedValue(b) : b;
28
29
  }
29
30
 
30
- __makeNative() {
31
- this._a.__makeNative();
32
- this._b.__makeNative();
33
- super.__makeNative();
31
+ __makeNative(platformConfig: ?PlatformConfig) {
32
+ this._a.__makeNative(platformConfig);
33
+ this._b.__makeNative(platformConfig);
34
+ super.__makeNative(platformConfig);
34
35
  }
35
36
 
36
37
  __getValue(): number {