react-native-macos 0.0.0-78b696cee → 0.0.0-7c6fa2fb1

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 (197) hide show
  1. package/Libraries/Animated/AnimatedEvent.js +23 -4
  2. package/Libraries/Animated/NativeAnimatedHelper.js +1 -1
  3. package/Libraries/Components/DatePicker/DatePickerIOS.ios.js +3 -6
  4. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +4 -7
  5. package/Libraries/Components/ScrollView/ScrollView.js +8 -5
  6. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +268 -252
  7. package/Libraries/Core/ExceptionsManager.js +3 -1
  8. package/Libraries/Core/ReactNativeVersion.js +1 -1
  9. package/Libraries/Core/setUpBatchedBridge.js +1 -1
  10. package/Libraries/Core/setUpGlobals.js +2 -0
  11. package/Libraries/Core/setUpTimers.js +2 -2
  12. package/Libraries/Image/Image.ios.js +6 -0
  13. package/Libraries/LogBox/UI/LogBoxImages/alert-triangle.png +0 -0
  14. package/Libraries/LogBox/UI/LogBoxImages/chevron-left.png +0 -0
  15. package/Libraries/LogBox/UI/LogBoxImages/chevron-right.png +0 -0
  16. package/Libraries/LogBox/UI/LogBoxImages/close.png +0 -0
  17. package/Libraries/LogBox/UI/LogBoxImages/loader.png +0 -0
  18. package/Libraries/NativeAnimation/Nodes/RCTPropsAnimatedNode.m +0 -3
  19. package/Libraries/NativeAnimation/RCTNativeAnimatedModule.mm +6 -3
  20. package/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.h +1 -2
  21. package/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm +2 -1
  22. package/Libraries/NewAppScreen/components/logo.png +0 -0
  23. package/Libraries/Pressability/Pressability.js +1 -0
  24. package/Libraries/Pressability/PressabilityPerformanceEventEmitter.js +1 -0
  25. package/Libraries/Renderer/REVISION +1 -1
  26. package/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +238 -47
  27. package/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +84 -18
  28. package/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +84 -18
  29. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +238 -47
  30. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +84 -18
  31. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +84 -18
  32. package/Libraries/StyleSheet/normalizeColor.js +2 -2
  33. package/Libraries/Text/TextProps.js +1 -7
  34. package/Libraries/TurboModule/TurboModuleRegistry.js +1 -1
  35. package/Libraries/Utilities/HMRClient.js +1 -1
  36. package/Libraries/WebSocket/RCTSRWebSocket.m +23 -0
  37. package/React/Base/RCTBridge+Private.h +8 -0
  38. package/React/Base/RCTBridge.h +4 -0
  39. package/React/Base/RCTBridge.m +17 -0
  40. package/React/Base/RCTBridgeModule.h +1 -1
  41. package/React/Base/RCTBundleURLProvider.h +1 -1
  42. package/React/Base/RCTBundleURLProvider.mm +2 -2
  43. package/React/Base/RCTDefines.h +12 -3
  44. package/React/Base/RCTEventDispatcherProtocol.h +2 -0
  45. package/React/Base/RCTRootView.h +15 -0
  46. package/React/Base/RCTRootView.m +15 -0
  47. package/React/Base/RCTVersion.m +1 -1
  48. package/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h +11 -0
  49. package/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm +35 -1
  50. package/React/CoreModules/RCTDevMenu.mm +4 -4
  51. package/React/CoreModules/RCTDevSettings.mm +6 -6
  52. package/React/CoreModules/RCTDevSplitBundleLoader.mm +1 -1
  53. package/React/CoreModules/RCTDeviceInfo.mm +4 -4
  54. package/React/CoreModules/RCTEventDispatcher.mm +5 -0
  55. package/React/CoreModules/RCTPerfMonitor.mm +9 -4
  56. package/React/CxxBridge/RCTCxxBridge.mm +18 -1
  57. package/React/FBReactNativeSpec/FBReactNativeSpec.podspec +11 -3
  58. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +9 -0
  59. package/React/Fabric/Mounting/RCTMountingManager.mm +15 -1
  60. package/React/Fabric/RCTScheduler.mm +10 -3
  61. package/React/Modules/RCTUIManager.m +19 -10
  62. package/React/Views/RCTFont.mm +58 -47
  63. package/React/Views/RCTViewManager.m +3 -2
  64. package/ReactAndroid/build.gradle +12 -6
  65. package/ReactAndroid/gradle.properties +1 -1
  66. package/ReactAndroid/src/androidTest/java/com/facebook/react/tests/BUCK +0 -1
  67. package/ReactAndroid/src/androidTest/js/TestBundle.js +0 -7
  68. package/ReactAndroid/src/main/java/com/facebook/react/BUCK +0 -1
  69. package/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +24 -6
  70. package/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java +4 -0
  71. package/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java +4 -0
  72. package/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactCxxErrorHandler.java +39 -0
  73. package/ReactAndroid/src/main/java/com/facebook/react/bridge/RuntimeScheduler.java +21 -0
  74. package/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +6 -0
  75. package/ReactAndroid/src/main/java/com/facebook/react/fabric/Binding.java +5 -0
  76. package/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java +1 -0
  77. package/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk +2 -1
  78. package/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +14 -0
  79. package/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h +2 -0
  80. package/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java +9 -1
  81. package/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java +19 -0
  82. package/ReactAndroid/src/main/java/com/facebook/react/modules/core/{JavaScriptTimerManager.java → JavaScriptTimerExecutor.java} +1 -1
  83. package/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.java +7 -7
  84. package/ReactAndroid/src/main/java/com/facebook/react/modules/core/TimingModule.java +2 -2
  85. package/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.java +7 -1
  86. package/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java +23 -19
  87. package/ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java +1 -4
  88. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
  89. package/ReactAndroid/src/main/java/com/facebook/react/shell/BUCK +0 -1
  90. package/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.java +0 -5
  91. package/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java +0 -4
  92. package/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java +16 -0
  93. package/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java +8 -0
  94. package/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java +20 -1
  95. package/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java +25 -6
  96. package/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java +25 -5
  97. package/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditTextInputConnectionWrapper.java +3 -0
  98. package/ReactAndroid/src/main/jni/react/jni/Android.mk +3 -2
  99. package/ReactAndroid/src/main/jni/react/jni/BUCK +2 -0
  100. package/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp +29 -0
  101. package/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.h +4 -0
  102. package/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.cpp +18 -0
  103. package/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.h +25 -0
  104. package/ReactAndroid/src/main/jni/react/jni/JRuntimeScheduler.cpp +22 -0
  105. package/ReactAndroid/src/main/jni/react/jni/JRuntimeScheduler.h +30 -0
  106. package/ReactAndroid/src/main/third-party/android/androidx/BUCK +6 -6
  107. package/ReactCommon/React-Fabric.podspec +9 -0
  108. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  109. package/ReactCommon/hermes/inspector/tools/msggen/package.json +7 -4
  110. package/ReactCommon/hermes/inspector/tools/msggen/yarn.lock +13 -10
  111. package/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm +14 -31
  112. package/ReactCommon/react/renderer/animations/BUCK +1 -0
  113. package/ReactCommon/react/renderer/animations/LayoutAnimationCallbackWrapper.h +34 -0
  114. package/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp +5 -26
  115. package/ReactCommon/react/renderer/animations/LayoutAnimationDriver.h +3 -13
  116. package/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +1399 -1622
  117. package/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h +76 -244
  118. package/ReactCommon/react/renderer/animations/conversions.h +212 -0
  119. package/ReactCommon/react/renderer/animations/primitives.h +104 -0
  120. package/ReactCommon/react/renderer/animations/utils.cpp +71 -0
  121. package/ReactCommon/react/renderer/animations/utils.h +80 -0
  122. package/ReactCommon/react/renderer/attributedstring/AttributedString.h +0 -1
  123. package/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp +7 -3
  124. package/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h +12 -2
  125. package/ReactCommon/react/renderer/attributedstring/TextAttributes.h +1 -1
  126. package/ReactCommon/react/renderer/attributedstring/conversions.h +58 -3
  127. package/ReactCommon/react/renderer/attributedstring/primitives.h +18 -1
  128. package/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h +1 -17
  129. package/ReactCommon/react/renderer/components/view/Android.mk +1 -1
  130. package/ReactCommon/react/renderer/components/view/ViewComponentDescriptor.h +0 -23
  131. package/ReactCommon/react/renderer/components/view/ViewPropsInterpolation.h +2 -3
  132. package/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp +1 -0
  133. package/ReactCommon/react/renderer/components/view/ViewShadowNode.h +1 -1
  134. package/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h +4 -0
  135. package/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h +14 -6
  136. package/ReactCommon/react/renderer/core/ConcreteShadowNode.h +1 -0
  137. package/ReactCommon/react/renderer/core/Props.h +1 -0
  138. package/ReactCommon/react/renderer/core/PropsParserContext.h +3 -2
  139. package/ReactCommon/react/renderer/core/RawPropsKey.cpp +10 -2
  140. package/ReactCommon/react/renderer/core/ReactPrimitives.h +0 -2
  141. package/ReactCommon/react/renderer/core/ShadowNodeFamily.h +1 -0
  142. package/ReactCommon/react/renderer/graphics/Android.mk +1 -1
  143. package/ReactCommon/react/renderer/graphics/Transform.cpp +1 -1
  144. package/ReactCommon/react/renderer/graphics/Transform.h +1 -1
  145. package/ReactCommon/react/renderer/mounting/Android.mk +2 -1
  146. package/ReactCommon/react/renderer/mounting/MountingOverrideDelegate.h +1 -1
  147. package/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp +12 -0
  148. package/ReactCommon/react/renderer/mounting/ShadowViewMutation.h +10 -1
  149. package/ReactCommon/react/renderer/runtimescheduler/BUCK +0 -1
  150. package/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp +4 -2
  151. package/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h +4 -2
  152. package/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp +4 -3
  153. package/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.h +4 -2
  154. package/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerClock.h +4 -2
  155. package/ReactCommon/react/renderer/runtimescheduler/SchedulerPriority.h +4 -3
  156. package/ReactCommon/react/renderer/runtimescheduler/Task.cpp +4 -2
  157. package/ReactCommon/react/renderer/runtimescheduler/Task.h +4 -2
  158. package/ReactCommon/react/renderer/runtimescheduler/primitives.h +4 -2
  159. package/ReactCommon/react/renderer/scheduler/SurfaceHandler.h +4 -4
  160. package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.h +2 -0
  161. package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm +19 -0
  162. package/ReactCommon/react/renderer/timeline/BUCK +6 -6
  163. package/ReactCommon/react/renderer/uimanager/UIManagerAnimationDelegate.h +1 -1
  164. package/ReactCommon/react/test_utils/BUCK +3 -0
  165. package/ReactCommon/react/test_utils/MockSurfaceHandler.h +25 -0
  166. package/ReactCommon/react/utils/ContextContainer.h +0 -27
  167. package/flow/global.js +45 -0
  168. package/index.js +15 -10
  169. package/package.json +4 -4
  170. package/react.gradle +1 -1
  171. package/scripts/generate-specs-cli.js +18 -0
  172. package/scripts/ios-configure-glog.sh +4 -0
  173. package/scripts/react_native_pods.rb +156 -37
  174. package/template/_flowconfig +1 -1
  175. package/template/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  176. package/template/ios/HelloWorld.xcodeproj/project.pbxproj +0 -2
  177. package/template/package.json +1 -1
  178. package/Libraries/Components/DatePickerAndroid/DatePickerAndroid.android.js +0 -87
  179. package/Libraries/Components/DatePickerAndroid/DatePickerAndroid.ios.js +0 -30
  180. package/Libraries/Components/DatePickerAndroid/DatePickerAndroidTypes.js +0 -30
  181. package/ReactAndroid/src/androidTest/java/com/facebook/react/tests/DatePickerDialogTestCase.java +0 -172
  182. package/ReactAndroid/src/androidTest/js/DatePickerDialogTestModule.js +0 -45
  183. package/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/BUCK +0 -27
  184. package/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogFragment.java +0 -137
  185. package/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogModule.java +0 -153
  186. package/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerMode.java +0 -15
  187. package/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DismissableDatePickerDialog.java +0 -117
  188. package/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/BUCK +0 -20
  189. package/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/RuntimeSchedulerManager.java +0 -39
  190. package/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/Android.mk +0 -34
  191. package/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/BUCK +0 -35
  192. package/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/OnLoad.cpp +0 -15
  193. package/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/RuntimeSchedulerManager.cpp +0 -46
  194. package/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/RuntimeSchedulerManager.h +0 -40
  195. package/scripts/generate-specs.sh +0 -99
  196. package/template/_editorconfig +0 -3
  197. package/template/_gitattributes +0 -3
@@ -9,11 +9,11 @@
9
9
 
10
10
  #include <ReactCommon/RuntimeExecutor.h>
11
11
  #include <better/optional.h>
12
- #include <react/renderer/core/EventTarget.h>
12
+ #include <better/set.h>
13
+ #include <react/renderer/animations/LayoutAnimationCallbackWrapper.h>
14
+ #include <react/renderer/animations/primitives.h>
13
15
  #include <react/renderer/core/RawValue.h>
14
16
  #include <react/renderer/debug/flags.h>
15
- #include <react/renderer/mounting/Differentiator.h>
16
- #include <react/renderer/mounting/MountingCoordinator.h>
17
17
  #include <react/renderer/mounting/MountingOverrideDelegate.h>
18
18
  #include <react/renderer/mounting/MountingTransaction.h>
19
19
  #include <react/renderer/mounting/ShadowViewMutation.h>
@@ -36,146 +36,14 @@ void PrintMutationInstructionRelative(
36
36
  #define PrintMutationInstructionRelative(a, b, c)
37
37
  #endif
38
38
 
39
- // This corresponds exactly with JS.
40
- enum class AnimationType {
41
- None = 0,
42
- Spring = 1,
43
- Linear = 2,
44
- EaseInEaseOut = 4,
45
- EaseIn = 8,
46
- EaseOut = 16,
47
- Keyboard = 32
48
- };
49
- enum class AnimationProperty {
50
- NotApplicable = 0,
51
- Opacity = 1,
52
- ScaleX = 2,
53
- ScaleY = 4,
54
- ScaleXY = 8
55
- };
56
- enum class AnimationConfigurationType { Create = 1, Update = 2, Delete = 4 };
57
-
58
- // This corresponds exactly with JS.
59
- struct AnimationConfig {
60
- AnimationType animationType = AnimationType::None;
61
- AnimationProperty animationProperty = AnimationProperty::NotApplicable;
62
- double duration =
63
- 0; // these are perhaps better represented as uint64_t, but they
64
- // come from JS as doubles
65
- double delay = 0;
66
- double springDamping = 0;
67
- double initialVelocity = 0;
68
- };
69
-
70
- // This corresponds exactly with JS.
71
- struct LayoutAnimationConfig {
72
- double duration; // ms
73
- AnimationConfig createConfig;
74
- AnimationConfig updateConfig;
75
- AnimationConfig deleteConfig;
76
- };
77
-
78
- struct AnimationKeyFrame {
79
- // The mutation(s) that should be executed once the animation completes.
80
- // This maybe empty.
81
- // For CREATE/INSERT this will contain CREATE, INSERT in that order.
82
- // For REMOVE/DELETE, same.
83
- std::vector<ShadowViewMutation> finalMutationsForKeyFrame;
84
-
85
- // The type of animation this is (for configuration purposes)
86
- AnimationConfigurationType type;
87
-
88
- // Tag representing the node being animated.
89
- Tag tag;
90
-
91
- ShadowView parentView;
92
-
93
- // ShadowView representing the start and end points of this animation.
94
- ShadowView viewStart;
95
- ShadowView viewEnd;
96
-
97
- // ShadowView representing the previous frame of the animation.
98
- ShadowView viewPrev;
99
-
100
- // If an animation interrupts an existing one, the starting state may actually
101
- // be halfway through the intended transition.
102
- double initialProgress;
103
-
104
- bool invalidated{false};
105
-
106
- // In the case where some mutation conflicts with this keyframe,
107
- // should we generate final synthetic UPDATE mutations for this keyframe?
108
- bool generateFinalSyntheticMutations{true};
109
- };
110
-
111
- class LayoutAnimationCallbackWrapper {
112
- public:
113
- LayoutAnimationCallbackWrapper(jsi::Function &&callback)
114
- : callback_(std::make_shared<jsi::Function>(std::move(callback))) {}
115
- LayoutAnimationCallbackWrapper() : callback_(nullptr) {}
116
-
117
- // Copy and assignment-copy constructors should copy callback_, and not
118
- // std::move it. Copying is desirable, otherwise the shared_ptr and
119
- // jsi::Function will be deallocated too early.
120
-
121
- bool readyForCleanup() const {
122
- return callback_ == nullptr || *callComplete_;
123
- }
124
-
125
- void call(const RuntimeExecutor &runtimeExecutor) const {
126
- if (readyForCleanup()) {
127
- return;
128
- }
129
-
130
- std::weak_ptr<jsi::Function> callable = callback_;
131
- std::shared_ptr<std::atomic_bool> callComplete = callComplete_;
132
-
133
- runtimeExecutor(
134
- [=, callComplete = std::move(callComplete)](jsi::Runtime &runtime) {
135
- auto fn = callable.lock();
136
-
137
- if (!fn || *callComplete) {
138
- return;
139
- }
140
-
141
- fn->call(runtime);
142
- *callComplete = true;
143
- });
144
- }
145
-
146
- private:
147
- std::shared_ptr<std::atomic_bool> callComplete_ =
148
- std::make_shared<std::atomic_bool>(false);
149
- std::shared_ptr<jsi::Function> callback_;
150
- };
151
-
152
- struct LayoutAnimation {
153
- SurfaceId surfaceId;
154
- uint64_t startTime;
155
- bool completed = false;
156
- LayoutAnimationConfig layoutAnimationConfig;
157
- LayoutAnimationCallbackWrapper successCallback;
158
- LayoutAnimationCallbackWrapper failureCallback;
159
- std::vector<AnimationKeyFrame> keyFrames;
160
- };
161
-
162
39
  class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate,
163
40
  public MountingOverrideDelegate {
164
41
  public:
165
42
  LayoutAnimationKeyFrameManager(
166
43
  RuntimeExecutor runtimeExecutor,
167
- LayoutAnimationStatusDelegate *delegate)
168
- : runtimeExecutor_(runtimeExecutor),
169
- layoutAnimationStatusDelegate_(delegate),
170
- now_([]() {
171
- return std::chrono::duration_cast<std::chrono::milliseconds>(
172
- std::chrono::high_resolution_clock::now()
173
- .time_since_epoch())
174
- .count();
175
- }) {}
176
- ~LayoutAnimationKeyFrameManager() {}
177
-
178
- #pragma mark UIManagerAnimationDelegate methods
44
+ LayoutAnimationStatusDelegate *delegate);
45
+
46
+ #pragma mark - UIManagerAnimationDelegate methods
179
47
 
180
48
  void uiManagerDidConfigureNextLayoutAnimation(
181
49
  jsi::Runtime &runtime,
@@ -191,7 +59,7 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate,
191
59
 
192
60
  void stopSurface(SurfaceId surfaceId) override;
193
61
 
194
- #pragma mark MountingOverrideDelegate methods
62
+ #pragma mark - MountingOverrideDelegate methods
195
63
 
196
64
  bool shouldOverridePullTransaction() const override;
197
65
 
@@ -205,7 +73,6 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate,
205
73
  ShadowViewMutationList mutations) const override;
206
74
 
207
75
  // Exposed for testing.
208
- public:
209
76
  void uiManagerDidConfigureNextLayoutAnimation(
210
77
  LayoutAnimation layoutAnimation) const;
211
78
 
@@ -214,50 +81,47 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate,
214
81
  // delegate is protected by a mutex; ALL method calls into this delegate are
215
82
  // also protected by the mutex! The only way to set this without a mutex is
216
83
  // via a constructor.
217
- public:
218
84
  void setLayoutAnimationStatusDelegate(
219
85
  LayoutAnimationStatusDelegate *delegate) const;
220
86
 
221
- private:
222
- RuntimeExecutor runtimeExecutor_;
223
- mutable std::mutex layoutAnimationStatusDelegateMutex_;
224
- mutable LayoutAnimationStatusDelegate *layoutAnimationStatusDelegate_{};
87
+ void setClockNow(std::function<uint64_t()> now);
225
88
 
226
- // Function that returns current time in milliseconds
227
- std::function<uint64_t()> now_;
89
+ void enableSkipInvalidatedKeyFrames();
228
90
 
229
- void adjustImmediateMutationIndicesForDelayedMutations(
230
- SurfaceId surfaceId,
231
- ShadowViewMutation &mutation,
232
- bool skipLastAnimation = false,
233
- bool lastAnimationOnly = false) const;
91
+ void enableCrashOnMissingComponentDescriptor();
234
92
 
235
- void adjustDelayedMutationIndicesForMutation(
236
- SurfaceId surfaceId,
237
- ShadowViewMutation const &mutation,
238
- bool skipLastAnimation = false) const;
93
+ void enableSimulateImagePropsMemoryAccess();
239
94
 
240
- void getAndEraseConflictingAnimations(
241
- SurfaceId surfaceId,
242
- ShadowViewMutationList const &mutations,
243
- std::vector<AnimationKeyFrame> &conflictingAnimations) const;
95
+ protected:
96
+ SharedComponentDescriptorRegistry componentDescriptorRegistry_;
97
+ mutable better::optional<LayoutAnimation> currentAnimation_{};
98
+ mutable std::mutex currentAnimationMutex_;
244
99
 
245
- mutable std::mutex surfaceIdsToStopMutex_;
246
- mutable std::vector<SurfaceId> surfaceIdsToStop_{};
100
+ /**
101
+ * All mutations of inflightAnimations_ are thread-safe as long as
102
+ * we keep the contract of: only mutate it within the context of
103
+ * `pullTransaction`. If that contract is held, this is implicitly protected
104
+ * by the MountingCoordinator's mutex.
105
+ */
106
+ mutable std::vector<LayoutAnimation> inflightAnimations_{};
247
107
 
248
- protected:
249
108
  bool hasComponentDescriptorForShadowView(ShadowView const &shadowView) const;
250
109
  ComponentDescriptor const &getComponentDescriptorForShadowView(
251
110
  ShadowView const &shadowView) const;
252
- std::pair<double, double> calculateAnimationProgress(
253
- uint64_t now,
254
- LayoutAnimation const &animation,
255
- AnimationConfig const &mutationConfig) const;
256
111
 
112
+ /**
113
+ * Given a `progress` between 0 and 1, a mutation and LayoutAnimation config,
114
+ * return a ShadowView with mutated props and/or LayoutMetrics.
115
+ *
116
+ * @param progress
117
+ * @param layoutAnimation
118
+ * @param animatedMutation
119
+ * @return
120
+ */
257
121
  ShadowView createInterpolatedShadowView(
258
122
  double progress,
259
- ShadowView startingView,
260
- ShadowView finalView) const;
123
+ ShadowView const &startingView,
124
+ ShadowView const &finalView) const;
261
125
 
262
126
  void callCallback(const LayoutAnimationCallbackWrapper &callback) const;
263
127
 
@@ -276,86 +140,54 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate,
276
140
  bool interrupted,
277
141
  std::string logPrefix) const;
278
142
 
279
- SharedComponentDescriptorRegistry componentDescriptorRegistry_;
280
- mutable better::optional<LayoutAnimation> currentAnimation_{};
281
- mutable std::mutex currentAnimationMutex_;
143
+ private:
144
+ RuntimeExecutor runtimeExecutor_;
145
+ mutable std::mutex layoutAnimationStatusDelegateMutex_;
146
+ mutable LayoutAnimationStatusDelegate *layoutAnimationStatusDelegate_{};
147
+ mutable std::mutex surfaceIdsToStopMutex_;
148
+ mutable better::set<SurfaceId> surfaceIdsToStop_{};
149
+ bool skipInvalidatedKeyFrames_{false};
282
150
 
283
- /**
284
- * All mutations of inflightAnimations_ are thread-safe as long as
285
- * we keep the contract of: only mutate it within the context of
286
- * `pullTransaction`. If that contract is held, this is implicitly protected
287
- * by the MountingCoordinator's mutex.
151
+ /*
152
+ * Feature flag that forces a crash if component descriptor for shadow view
153
+ * doesn't exist. This is an unexpected state and we crash to collect extra
154
+ * logs.
288
155
  */
289
- mutable std::vector<LayoutAnimation> inflightAnimations_{};
156
+ bool crashOnMissingComponentDescriptor_{false};
290
157
 
291
- private:
292
- // A vector of callable function wrappers that are in the process of being
293
- // called
294
- mutable std::mutex callbackWrappersPendingMutex_;
295
- mutable std::vector<std::unique_ptr<LayoutAnimationCallbackWrapper>>
296
- callbackWrappersPending_{};
158
+ /*
159
+ * Feature flag that enables simulation of memory access. This is a temporary
160
+ * flag to diagnose where crashes are coming from in LayoutAnimations on iOS.
161
+ */
162
+ bool simulateImagePropsMemoryAccess_{false};
297
163
 
298
- public:
299
- void setClockNow(std::function<uint64_t()> now);
300
- };
164
+ // Function that returns current time in milliseconds
165
+ std::function<uint64_t()> now_;
166
+
167
+ void adjustImmediateMutationIndicesForDelayedMutations(
168
+ SurfaceId surfaceId,
169
+ ShadowViewMutation &mutation,
170
+ bool skipLastAnimation = false,
171
+ bool lastAnimationOnly = false) const;
301
172
 
302
- static inline bool shouldFirstComeBeforeSecondRemovesOnly(
303
- ShadowViewMutation const &lhs,
304
- ShadowViewMutation const &rhs) noexcept {
305
- // Make sure that removes on the same level are sorted - highest indices must
306
- // come first.
307
- return (lhs.type == ShadowViewMutation::Type::Remove &&
308
- lhs.type == rhs.type) &&
309
- (lhs.parentShadowView.tag == rhs.parentShadowView.tag) &&
310
- (lhs.index > rhs.index);
311
- }
312
-
313
- static inline bool shouldFirstComeBeforeSecondMutation(
314
- ShadowViewMutation const &lhs,
315
- ShadowViewMutation const &rhs) noexcept {
316
- if (lhs.type != rhs.type) {
317
- // Deletes always come last
318
- if (lhs.type == ShadowViewMutation::Type::Delete) {
319
- return false;
320
- }
321
- if (rhs.type == ShadowViewMutation::Type::Delete) {
322
- return true;
323
- }
324
-
325
- // Remove comes before insert
326
- if (lhs.type == ShadowViewMutation::Type::Remove &&
327
- rhs.type == ShadowViewMutation::Type::Insert) {
328
- return true;
329
- }
330
- if (rhs.type == ShadowViewMutation::Type::Remove &&
331
- lhs.type == ShadowViewMutation::Type::Insert) {
332
- return false;
333
- }
334
-
335
- // Create comes before insert
336
- if (lhs.type == ShadowViewMutation::Type::Create &&
337
- rhs.type == ShadowViewMutation::Type::Insert) {
338
- return true;
339
- }
340
- if (rhs.type == ShadowViewMutation::Type::Create &&
341
- lhs.type == ShadowViewMutation::Type::Insert) {
342
- return false;
343
- }
344
- } else {
345
- // Make sure that removes on the same level are sorted - highest indices
346
- // must come first.
347
- if (lhs.type == ShadowViewMutation::Type::Remove &&
348
- lhs.parentShadowView.tag == rhs.parentShadowView.tag) {
349
- if (lhs.index > rhs.index) {
350
- return true;
351
- } else {
352
- return false;
353
- }
354
- }
355
- }
356
-
357
- return false;
358
- }
173
+ void adjustDelayedMutationIndicesForMutation(
174
+ SurfaceId surfaceId,
175
+ ShadowViewMutation const &mutation,
176
+ bool skipLastAnimation = false) const;
177
+
178
+ void getAndEraseConflictingAnimations(
179
+ SurfaceId surfaceId,
180
+ ShadowViewMutationList const &mutations,
181
+ std::vector<AnimationKeyFrame> &conflictingAnimations) const;
182
+
183
+ /*
184
+ * Removes animations from `inflightAnimations_` for stopped surfaces.
185
+ */
186
+ void deleteAnimationsForStoppedSurfaces() const;
187
+
188
+ void simulateImagePropsMemoryAccess(
189
+ ShadowViewMutationList const &mutations) const;
190
+ };
359
191
 
360
192
  } // namespace react
361
193
  } // namespace facebook
@@ -0,0 +1,212 @@
1
+ /*
2
+ * Copyright (c) Facebook, Inc. and its 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
+
8
+ #include <better/optional.h>
9
+ #include <react/renderer/animations/primitives.h>
10
+
11
+ #include <glog/logging.h>
12
+
13
+ namespace facebook {
14
+ namespace react {
15
+
16
+ static inline better::optional<AnimationType> parseAnimationType(
17
+ std::string param) {
18
+ if (param == "spring") {
19
+ return AnimationType::Spring;
20
+ }
21
+ if (param == "linear") {
22
+ return AnimationType::Linear;
23
+ }
24
+ if (param == "easeInEaseOut") {
25
+ return AnimationType::EaseInEaseOut;
26
+ }
27
+ if (param == "easeIn") {
28
+ return AnimationType::EaseIn;
29
+ }
30
+ if (param == "easeOut") {
31
+ return AnimationType::EaseOut;
32
+ }
33
+ if (param == "keyboard") {
34
+ return AnimationType::Keyboard;
35
+ }
36
+
37
+ LOG(ERROR) << "Error parsing animation type: " << param;
38
+ return {};
39
+ }
40
+
41
+ static inline better::optional<AnimationProperty> parseAnimationProperty(
42
+ std::string param) {
43
+ if (param == "opacity") {
44
+ return AnimationProperty::Opacity;
45
+ }
46
+ if (param == "scaleX") {
47
+ return AnimationProperty::ScaleX;
48
+ }
49
+ if (param == "scaleY") {
50
+ return AnimationProperty::ScaleY;
51
+ }
52
+ if (param == "scaleXY") {
53
+ return AnimationProperty::ScaleXY;
54
+ }
55
+
56
+ LOG(ERROR) << "Error parsing animation property: " << param;
57
+ return {};
58
+ }
59
+
60
+ static inline better::optional<AnimationConfig> parseAnimationConfig(
61
+ folly::dynamic const &config,
62
+ double defaultDuration,
63
+ bool parsePropertyType) {
64
+ if (config.empty() || !config.isObject()) {
65
+ return AnimationConfig{
66
+ AnimationType::Linear,
67
+ AnimationProperty::NotApplicable,
68
+ defaultDuration,
69
+ 0,
70
+ 0,
71
+ 0};
72
+ }
73
+
74
+ auto const typeIt = config.find("type");
75
+ if (typeIt == config.items().end()) {
76
+ LOG(ERROR) << "Error parsing animation config: could not find field `type`";
77
+ return {};
78
+ }
79
+ auto const animationTypeParam = typeIt->second;
80
+ if (animationTypeParam.empty() || !animationTypeParam.isString()) {
81
+ LOG(ERROR)
82
+ << "Error parsing animation config: could not unwrap field `type`";
83
+ return {};
84
+ }
85
+ const auto animationType = parseAnimationType(animationTypeParam.asString());
86
+ if (!animationType) {
87
+ LOG(ERROR)
88
+ << "Error parsing animation config: could not parse field `type`";
89
+ return {};
90
+ }
91
+
92
+ AnimationProperty animationProperty = AnimationProperty::NotApplicable;
93
+ if (parsePropertyType) {
94
+ auto const propertyIt = config.find("property");
95
+ if (propertyIt == config.items().end()) {
96
+ LOG(ERROR)
97
+ << "Error parsing animation config: could not find field `property`";
98
+ return {};
99
+ }
100
+ auto const animationPropertyParam = propertyIt->second;
101
+ if (animationPropertyParam.empty() || !animationPropertyParam.isString()) {
102
+ LOG(ERROR)
103
+ << "Error parsing animation config: could not unwrap field `property`";
104
+ return {};
105
+ }
106
+ const auto animationPropertyParsed =
107
+ parseAnimationProperty(animationPropertyParam.asString());
108
+ if (!animationPropertyParsed) {
109
+ LOG(ERROR)
110
+ << "Error parsing animation config: could not parse field `property`";
111
+ return {};
112
+ }
113
+ animationProperty = *animationPropertyParsed;
114
+ }
115
+
116
+ double duration = defaultDuration;
117
+ double delay = 0;
118
+ double springDamping = 0.5;
119
+ double initialVelocity = 0;
120
+
121
+ auto const durationIt = config.find("duration");
122
+ if (durationIt != config.items().end()) {
123
+ if (durationIt->second.isDouble()) {
124
+ duration = durationIt->second.asDouble();
125
+ } else {
126
+ LOG(ERROR)
127
+ << "Error parsing animation config: field `duration` must be a number";
128
+ return {};
129
+ }
130
+ }
131
+
132
+ auto const delayIt = config.find("delay");
133
+ if (delayIt != config.items().end()) {
134
+ if (delayIt->second.isDouble()) {
135
+ delay = delayIt->second.asDouble();
136
+ } else {
137
+ LOG(ERROR)
138
+ << "Error parsing animation config: field `delay` must be a number";
139
+ return {};
140
+ }
141
+ }
142
+
143
+ auto const springDampingIt = config.find("springDamping");
144
+ if (springDampingIt != config.items().end() &&
145
+ springDampingIt->second.isDouble()) {
146
+ if (springDampingIt->second.isDouble()) {
147
+ springDamping = springDampingIt->second.asDouble();
148
+ } else {
149
+ LOG(ERROR)
150
+ << "Error parsing animation config: field `springDamping` must be a number";
151
+ return {};
152
+ }
153
+ }
154
+
155
+ auto const initialVelocityIt = config.find("initialVelocity");
156
+ if (initialVelocityIt != config.items().end()) {
157
+ if (initialVelocityIt->second.isDouble()) {
158
+ initialVelocity = initialVelocityIt->second.asDouble();
159
+ } else {
160
+ LOG(ERROR)
161
+ << "Error parsing animation config: field `initialVelocity` must be a number";
162
+ return {};
163
+ }
164
+ }
165
+
166
+ return better::optional<AnimationConfig>(AnimationConfig{
167
+ *animationType,
168
+ animationProperty,
169
+ duration,
170
+ delay,
171
+ springDamping,
172
+ initialVelocity});
173
+ }
174
+
175
+ // Parse animation config from JS
176
+ static inline better::optional<LayoutAnimationConfig>
177
+ parseLayoutAnimationConfig(folly::dynamic const &config) {
178
+ if (config.empty() || !config.isObject()) {
179
+ return {};
180
+ }
181
+
182
+ const auto durationIt = config.find("duration");
183
+ if (durationIt == config.items().end() || !durationIt->second.isDouble()) {
184
+ return {};
185
+ }
186
+ const double duration = durationIt->second.asDouble();
187
+
188
+ const auto createConfigIt = config.find("create");
189
+ const auto createConfig = createConfigIt == config.items().end()
190
+ ? better::optional<AnimationConfig>(AnimationConfig{})
191
+ : parseAnimationConfig(createConfigIt->second, duration, true);
192
+
193
+ const auto updateConfigIt = config.find("update");
194
+ const auto updateConfig = updateConfigIt == config.items().end()
195
+ ? better::optional<AnimationConfig>(AnimationConfig{})
196
+ : parseAnimationConfig(updateConfigIt->second, duration, false);
197
+
198
+ const auto deleteConfigIt = config.find("delete");
199
+ const auto deleteConfig = deleteConfigIt == config.items().end()
200
+ ? better::optional<AnimationConfig>(AnimationConfig{})
201
+ : parseAnimationConfig(deleteConfigIt->second, duration, true);
202
+
203
+ if (!createConfig || !updateConfig || !deleteConfig) {
204
+ return {};
205
+ }
206
+
207
+ return LayoutAnimationConfig{
208
+ duration, *createConfig, *updateConfig, *deleteConfig};
209
+ }
210
+
211
+ } // namespace react
212
+ } // namespace facebook