react-native-reanimated 2.3.0-beta.1 → 2.3.0

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 (174) hide show
  1. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +12 -3
  2. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +13 -0
  3. package/Common/cpp/Registries/EventHandlerRegistry.cpp +2 -2
  4. package/Common/cpp/Registries/MapperRegistry.cpp +5 -5
  5. package/Common/cpp/SharedItems/FrozenObject.cpp +1 -3
  6. package/Common/cpp/SharedItems/ShareableValue.cpp +8 -10
  7. package/Common/cpp/Tools/FeaturesConfig.cpp +5 -0
  8. package/Common/cpp/Tools/JSIStoreValueUser.cpp +8 -8
  9. package/Common/cpp/Tools/Mapper.cpp +1 -1
  10. package/Common/cpp/Tools/RuntimeDecorator.cpp +40 -4
  11. package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -1
  12. package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +5 -0
  13. package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +6 -1
  14. package/Common/cpp/headers/Registries/EventHandlerRegistry.h +1 -0
  15. package/Common/cpp/headers/Registries/MapperRegistry.h +1 -0
  16. package/Common/cpp/headers/SharedItems/FrozenObject.h +4 -0
  17. package/Common/cpp/headers/SharedItems/HostFunctionHandler.h +2 -0
  18. package/Common/cpp/headers/SharedItems/MutableValue.h +2 -0
  19. package/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h +3 -1
  20. package/Common/cpp/headers/SharedItems/RemoteObject.h +4 -1
  21. package/Common/cpp/headers/SharedItems/ShareableValue.h +2 -0
  22. package/Common/cpp/headers/SharedItems/SharedParent.h +9 -9
  23. package/Common/cpp/headers/SharedItems/ValueWrapper.h +32 -28
  24. package/Common/cpp/headers/SpecTools/ErrorHandler.h +1 -0
  25. package/Common/cpp/headers/Tools/FeaturesConfig.h +19 -0
  26. package/Common/cpp/headers/Tools/JSIStoreValueUser.h +2 -5
  27. package/Common/cpp/headers/Tools/Mapper.h +2 -0
  28. package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +5 -0
  29. package/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h +1 -5
  30. package/Common/cpp/headers/Tools/RuntimeDecorator.h +10 -7
  31. package/Common/cpp/headers/Tools/Scheduler.h +2 -0
  32. package/Common/cpp/headers/Tools/WorkletEventHandler.h +2 -1
  33. package/Common/cpp/hidden_headers/Logger.h +2 -2
  34. package/Common/cpp/hidden_headers/LoggerInterface.h +1 -1
  35. package/RNReanimated.podspec +24 -6
  36. package/android/build.gradle +33 -13
  37. package/android/expo/linking.gradle +34 -0
  38. package/android/expo/src/main/java/com/swmansion/reanimated/EXReanimatedAdapter.java +12 -0
  39. package/android/expo/src/main/java/expo/modules/adapters/reanimated/EXReanimatedPackage.java +26 -0
  40. package/android/react-native-reanimated-63-hermes.aar +0 -0
  41. package/android/react-native-reanimated-63-jsc.aar +0 -0
  42. package/android/react-native-reanimated-64-hermes.aar +0 -0
  43. package/android/react-native-reanimated-64-jsc.aar +0 -0
  44. package/android/react-native-reanimated-65-hermes.aar +0 -0
  45. package/android/react-native-reanimated-65-jsc.aar +0 -0
  46. package/android/react-native-reanimated-66-hermes.aar +0 -0
  47. package/android/react-native-reanimated-66-jsc.aar +0 -0
  48. package/android/react-native-reanimated-67-hermes.aar +0 -0
  49. package/android/react-native-reanimated-67-jsc.aar +0 -0
  50. package/expo-module.config.json +3 -0
  51. package/ios/LayoutReanimation/REAAnimationsManager.m +65 -19
  52. package/ios/LayoutReanimation/REAUIManager.mm +114 -70
  53. package/ios/REAEventDispatcher.m +1 -1
  54. package/ios/REAModule.h +0 -2
  55. package/ios/REAModule.m +0 -3
  56. package/ios/REANodesManager.m +1 -0
  57. package/ios/RNGestureHandlerStateManager.h +5 -0
  58. package/ios/native/NativeMethods.h +5 -0
  59. package/ios/native/NativeMethods.mm +14 -6
  60. package/ios/native/NativeProxy.h +1 -0
  61. package/ios/native/NativeProxy.mm +84 -63
  62. package/ios/native/REAIOSErrorHandler.mm +19 -15
  63. package/ios/native/REAIOSLogger.mm +10 -6
  64. package/ios/native/REAIOSScheduler.mm +17 -10
  65. package/ios/native/REAInitializer.mm +42 -31
  66. package/ios/native/UIResponder+Reanimated.mm +2 -2
  67. package/lib/Animated.js +11 -5
  68. package/lib/ConfigHelper.js +121 -138
  69. package/lib/ReanimatedEventEmitter.js +0 -1
  70. package/lib/ReanimatedModule.js +0 -1
  71. package/lib/ReanimatedModule.macos.js +0 -1
  72. package/lib/ReanimatedModule.native.js +5 -6
  73. package/lib/ReanimatedModule.windows.js +0 -1
  74. package/lib/ReanimatedModuleCompat.js +64 -35
  75. package/lib/createAnimatedComponent.js +469 -499
  76. package/lib/index.js +11 -5
  77. package/lib/reanimated1/core/Core.test.js +1 -1
  78. package/lib/reanimated2/NativeMethods.js +7 -0
  79. package/lib/reanimated2/NativeReanimated/NativeReanimated.js +3 -0
  80. package/lib/reanimated2/PropAdapters.js +0 -1
  81. package/lib/reanimated2/UpdateProps.js +1 -1
  82. package/lib/reanimated2/ViewDescriptorsSet.js +4 -2
  83. package/lib/reanimated2/animation/spring.js +2 -0
  84. package/lib/reanimated2/animation/styleAnimation.js +5 -1
  85. package/lib/reanimated2/animation/util.js +23 -0
  86. package/lib/reanimated2/component/FlatList.js +30 -0
  87. package/lib/reanimated2/component/WrappedComponents.js +9 -0
  88. package/lib/reanimated2/component/index.js +4 -0
  89. package/lib/reanimated2/core.js +30 -3
  90. package/lib/reanimated2/globals.d.ts +8 -0
  91. package/lib/reanimated2/index.js +1 -0
  92. package/lib/reanimated2/js-reanimated/JSReanimated.js +4 -0
  93. package/lib/reanimated2/js-reanimated/Mapper.js +4 -3
  94. package/lib/reanimated2/js-reanimated/MapperRegistry.js +3 -6
  95. package/lib/reanimated2/js-reanimated/MutableValue.js +0 -2
  96. package/lib/reanimated2/js-reanimated/index.js +10 -8
  97. package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +14 -5
  98. package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +14 -14
  99. package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +8 -8
  100. package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +4 -2
  101. package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +16 -16
  102. package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +16 -16
  103. package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +4 -4
  104. package/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +20 -8
  105. package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +3 -3
  106. package/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +8 -8
  107. package/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +10 -10
  108. package/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +8 -8
  109. package/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +8 -8
  110. package/lib/reanimated2/mock.js +3 -1
  111. package/lib/reanimated2/utils.js +9 -0
  112. package/lib/setAndForwardRef.js +14 -48
  113. package/mock.js +1 -1
  114. package/package.json +27 -23
  115. package/plugin.js +111 -110
  116. package/react-native-reanimated.d.ts +63 -25
  117. package/src/Animated.js +11 -5
  118. package/src/{ConfigHelper.js → ConfigHelper.ts} +15 -7
  119. package/src/{ReanimatedEventEmitter.js → ReanimatedEventEmitter.ts} +0 -0
  120. package/src/{ReanimatedModule.js → ReanimatedModule.macos.ts} +0 -0
  121. package/src/{ReanimatedModule.native.js → ReanimatedModule.native.ts} +0 -0
  122. package/src/{ReanimatedModule.macos.js → ReanimatedModule.ts} +0 -0
  123. package/src/{ReanimatedModule.windows.js → ReanimatedModule.windows.ts} +0 -0
  124. package/src/ReanimatedModuleCompat.ts +51 -0
  125. package/src/{createAnimatedComponent.js → createAnimatedComponent.tsx} +278 -124
  126. package/src/reanimated1/core/Core.test.js +1 -1
  127. package/src/reanimated2/NativeMethods.ts +13 -1
  128. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +5 -11
  129. package/src/reanimated2/PropAdapters.ts +0 -1
  130. package/src/reanimated2/UpdateProps.ts +1 -1
  131. package/src/reanimated2/ViewDescriptorsSet.ts +6 -2
  132. package/src/reanimated2/animation/commonTypes.ts +4 -4
  133. package/src/reanimated2/animation/decay.ts +2 -2
  134. package/src/reanimated2/animation/delay.ts +3 -3
  135. package/src/reanimated2/animation/index.ts +7 -7
  136. package/src/reanimated2/animation/repeat.ts +4 -4
  137. package/src/reanimated2/animation/sequence.ts +2 -2
  138. package/src/reanimated2/animation/spring.ts +6 -5
  139. package/src/reanimated2/animation/styleAnimation.ts +24 -12
  140. package/src/reanimated2/animation/timing.ts +5 -5
  141. package/src/reanimated2/animation/util.ts +45 -6
  142. package/src/reanimated2/component/FlatList.tsx +44 -0
  143. package/src/reanimated2/component/WrappedComponents.ts +11 -0
  144. package/src/reanimated2/component/index.ts +9 -0
  145. package/src/reanimated2/core.ts +58 -14
  146. package/src/reanimated2/globals.d.ts +8 -0
  147. package/src/reanimated2/hook/useAnimatedStyle.ts +2 -2
  148. package/src/reanimated2/index.ts +1 -0
  149. package/src/reanimated2/js-reanimated/JSReanimated.ts +15 -26
  150. package/src/reanimated2/js-reanimated/Mapper.ts +22 -9
  151. package/src/reanimated2/js-reanimated/MapperRegistry.ts +22 -19
  152. package/src/reanimated2/js-reanimated/MutableValue.ts +11 -11
  153. package/src/reanimated2/js-reanimated/index.ts +31 -14
  154. package/src/reanimated2/layoutReanimation/{LayoutAnimationRepository.tsx → LayoutAnimationRepository.ts} +18 -5
  155. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +39 -20
  156. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +5 -1
  157. package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +21 -15
  158. package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +29 -24
  159. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +10 -2
  160. package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +61 -34
  161. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +49 -34
  162. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +17 -12
  163. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +20 -8
  164. package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +9 -9
  165. package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +8 -8
  166. package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +20 -14
  167. package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +14 -8
  168. package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +24 -12
  169. package/src/reanimated2/mock.ts +3 -1
  170. package/src/reanimated2/utils.ts +21 -0
  171. package/src/{setAndForwardRef.js → setAndForwardRef.ts} +12 -2
  172. package/android/react-native-reanimated-62-hermes.aar +0 -0
  173. package/android/react-native-reanimated-62-jsc.aar +0 -0
  174. package/src/ReanimatedModuleCompat.js +0 -37
@@ -1,7 +1,9 @@
1
1
  #pragma once
2
2
 
3
3
  #include <jsi/jsi.h>
4
+ #include <memory>
4
5
  #include <string>
6
+ #include <vector>
5
7
  #include "HostFunctionHandler.h"
6
8
  #include "JSIStoreValueUser.h"
7
9
  #include "SharedParent.h"
@@ -13,8 +15,8 @@ class HostFunctionWrapper;
13
15
 
14
16
  class ValueWrapper {
15
17
  public:
16
- ValueWrapper(){};
17
- ValueWrapper(ValueType _type) : type(_type){};
18
+ ValueWrapper() {}
19
+ explicit ValueWrapper(ValueType _type) : type(_type) {}
18
20
  ValueType getType() const {
19
21
  return type;
20
22
  }
@@ -47,105 +49,107 @@ class ValueWrapper {
47
49
 
48
50
  class BooleanValueWrapper : public ValueWrapper {
49
51
  public:
50
- BooleanValueWrapper(const bool _value)
51
- : ValueWrapper(ValueType::BoolType), value(_value){};
52
+ explicit BooleanValueWrapper(const bool _value)
53
+ : ValueWrapper(ValueType::BoolType), value(_value) {}
52
54
  bool value;
53
55
  };
54
56
 
55
57
  class NumberValueWrapper : public ValueWrapper {
56
58
  public:
57
- NumberValueWrapper(const double _value)
58
- : ValueWrapper(ValueType::NumberType), value(_value){};
59
+ explicit NumberValueWrapper(const double _value)
60
+ : ValueWrapper(ValueType::NumberType), value(_value) {}
59
61
  double value;
60
62
  };
61
63
 
62
64
  class StringValueWrapper : public ValueWrapper {
63
65
  public:
64
- StringValueWrapper(const std::string &_value)
65
- : ValueWrapper(ValueType::StringType), value(_value){};
66
+ explicit StringValueWrapper(const std::string &_value)
67
+ : ValueWrapper(ValueType::StringType), value(_value) {}
66
68
  std::string value;
67
69
  };
68
70
 
69
71
  class HostFunctionWrapper : public ValueWrapper {
70
72
  public:
71
- HostFunctionWrapper(const std::shared_ptr<HostFunctionHandler> &_value)
72
- : ValueWrapper(ValueType::HostFunctionType), value(_value){};
73
+ explicit HostFunctionWrapper(
74
+ const std::shared_ptr<HostFunctionHandler> &_value)
75
+ : ValueWrapper(ValueType::HostFunctionType), value(_value) {}
73
76
  std::shared_ptr<HostFunctionHandler> value;
74
77
  };
75
78
 
76
79
  class FrozenObjectWrapper : public ValueWrapper {
77
80
  public:
78
- FrozenObjectWrapper(const std::shared_ptr<FrozenObject> &_value)
79
- : ValueWrapper(ValueType::FrozenObjectType), value(_value){};
81
+ explicit FrozenObjectWrapper(const std::shared_ptr<FrozenObject> &_value)
82
+ : ValueWrapper(ValueType::FrozenObjectType), value(_value) {}
80
83
  std::shared_ptr<FrozenObject> value;
81
84
  };
82
85
 
83
86
  class RemoteObjectWrapper : public ValueWrapper {
84
87
  public:
85
- RemoteObjectWrapper(const std::shared_ptr<RemoteObject> &_value)
86
- : ValueWrapper(ValueType::RemoteObjectType), value(_value){};
88
+ explicit RemoteObjectWrapper(const std::shared_ptr<RemoteObject> &_value)
89
+ : ValueWrapper(ValueType::RemoteObjectType), value(_value) {}
87
90
  std::shared_ptr<RemoteObject> value;
88
91
  };
89
92
 
90
93
  class FrozenArrayWrapper : public ValueWrapper {
91
94
  public:
92
- FrozenArrayWrapper() : ValueWrapper(ValueType::FrozenArrayType){};
93
- FrozenArrayWrapper(const std::vector<std::shared_ptr<ShareableValue>> &_value)
94
- : ValueWrapper(ValueType::FrozenArrayType), value(_value){};
95
+ FrozenArrayWrapper() : ValueWrapper(ValueType::FrozenArrayType) {}
96
+ explicit FrozenArrayWrapper(
97
+ const std::vector<std::shared_ptr<ShareableValue>> &_value)
98
+ : ValueWrapper(ValueType::FrozenArrayType), value(_value) {}
95
99
  std::vector<std::shared_ptr<ShareableValue>> value;
96
100
  };
97
101
 
98
102
  class MutableValueWrapper : public ValueWrapper {
99
103
  public:
100
- MutableValueWrapper(const std::shared_ptr<MutableValue> &_value)
101
- : ValueWrapper(ValueType::MutableValueType), value(_value){};
104
+ explicit MutableValueWrapper(const std::shared_ptr<MutableValue> &_value)
105
+ : ValueWrapper(ValueType::MutableValueType), value(_value) {}
102
106
  std::shared_ptr<MutableValue> value;
103
107
  };
104
108
 
105
109
  inline bool ValueWrapper::asBoolean(
106
110
  const std::unique_ptr<ValueWrapper> &valueContainer) {
107
111
  return static_cast<BooleanValueWrapper *>(valueContainer.get())->value;
108
- };
112
+ }
109
113
 
110
114
  inline double ValueWrapper::asNumber(
111
115
  const std::unique_ptr<ValueWrapper> &valueContainer) {
112
116
  return static_cast<NumberValueWrapper *>(valueContainer.get())->value;
113
- };
117
+ }
114
118
 
115
119
  inline const std::string &ValueWrapper::asString(
116
120
  const std::unique_ptr<ValueWrapper> &valueContainer) {
117
121
  return static_cast<StringValueWrapper *>(valueContainer.get())->value;
118
- };
122
+ }
119
123
 
120
124
  inline const std::shared_ptr<HostFunctionHandler> &ValueWrapper::asHostFunction(
121
125
  const std::unique_ptr<ValueWrapper> &valueContainer) {
122
126
  return static_cast<HostFunctionWrapper *>(valueContainer.get())->value;
123
- };
127
+ }
124
128
 
125
129
  inline const std::shared_ptr<FrozenObject> &ValueWrapper::asFrozenObject(
126
130
  const std::unique_ptr<ValueWrapper> &valueContainer) {
127
131
  return static_cast<FrozenObjectWrapper *>(valueContainer.get())->value;
128
- };
132
+ }
129
133
 
130
134
  inline const std::shared_ptr<RemoteObject> &ValueWrapper::asRemoteObject(
131
135
  const std::unique_ptr<ValueWrapper> &valueContainer) {
132
136
  return static_cast<RemoteObjectWrapper *>(valueContainer.get())->value;
133
- };
137
+ }
134
138
 
135
139
  inline std::vector<std::shared_ptr<ShareableValue>>
136
140
  &ValueWrapper::asFrozenArray(
137
141
  const std::unique_ptr<ValueWrapper> &valueContainer) {
138
142
  return static_cast<FrozenArrayWrapper *>(valueContainer.get())->value;
139
- };
143
+ }
140
144
 
141
145
  inline const std::shared_ptr<MutableValue> &ValueWrapper::asMutableValue(
142
146
  const std::unique_ptr<ValueWrapper> &valueContainer) {
143
147
  return static_cast<MutableValueWrapper *>(valueContainer.get())->value;
144
- };
148
+ }
145
149
 
146
150
  inline const HostFunctionWrapper *ValueWrapper::asHostFunctionWrapper(
147
151
  const std::unique_ptr<ValueWrapper> &valueContainer) {
148
152
  return static_cast<HostFunctionWrapper *>(valueContainer.get());
149
- };
153
+ }
150
154
 
151
155
  } // namespace reanimated
@@ -1,5 +1,6 @@
1
1
  #pragma once
2
2
 
3
+ #include <memory>
3
4
  #include <string>
4
5
  #include "Scheduler.h"
5
6
 
@@ -0,0 +1,19 @@
1
+ #pragma once
2
+ #include <string>
3
+
4
+ namespace reanimated {
5
+
6
+ class FeaturesConfig {
7
+ public:
8
+ static inline bool isLayoutAnimationEnabled() {
9
+ return _isLayoutAnimationEnabled;
10
+ }
11
+ static inline void setLayoutAnimationEnabled(bool isLayoutAnimationEnabled) {
12
+ _isLayoutAnimationEnabled = isLayoutAnimationEnabled;
13
+ }
14
+
15
+ private:
16
+ static bool _isLayoutAnimationEnabled;
17
+ };
18
+
19
+ } // namespace reanimated
@@ -1,5 +1,4 @@
1
- #ifndef JSIStoreValueUser_h
2
- #define JSIStoreValueUser_h
1
+ #pragma once
3
2
 
4
3
  #include <jsi/jsi.h>
5
4
  #include <stdio.h>
@@ -27,7 +26,7 @@ class StoreUser {
27
26
  std::shared_ptr<StaticStoreUser> storeUserData;
28
27
 
29
28
  public:
30
- StoreUser(std::shared_ptr<Scheduler> s, RuntimeManager &runtimeManager);
29
+ StoreUser(std::shared_ptr<Scheduler> s, const RuntimeManager &runtimeManager);
31
30
 
32
31
  std::weak_ptr<jsi::Value> getWeakRef(jsi::Runtime &rt);
33
32
  void removeRefs();
@@ -36,5 +35,3 @@ class StoreUser {
36
35
  };
37
36
 
38
37
  } // namespace reanimated
39
-
40
- #endif /* JSIStoreValueUser_h */
@@ -2,6 +2,8 @@
2
2
 
3
3
  #include <jsi/jsi.h>
4
4
  #include <stdio.h>
5
+ #include <memory>
6
+ #include <vector>
5
7
  #include "NativeReanimatedModule.h"
6
8
  #include "ShareableValue.h"
7
9
 
@@ -2,6 +2,9 @@
2
2
 
3
3
  #include <jsi/jsi.h>
4
4
  #include <stdio.h>
5
+ #include <string>
6
+ #include <utility>
7
+ #include <vector>
5
8
 
6
9
  using namespace facebook;
7
10
 
@@ -18,6 +21,7 @@ using ScrollToFunction = std::function<void(int, double, double, bool)>;
18
21
  using MeasuringFunction =
19
22
  std::function<std::vector<std::pair<std::string, double>>(int)>;
20
23
  using TimeProviderFunction = std::function<double(void)>;
24
+ using SetGestureStateFunction = std::function<void(int, int)>;
21
25
 
22
26
  struct PlatformDepMethodsHolder {
23
27
  RequestRender requestRender;
@@ -25,6 +29,7 @@ struct PlatformDepMethodsHolder {
25
29
  ScrollToFunction scrollToFunction;
26
30
  MeasuringFunction measuringFunction;
27
31
  TimeProviderFunction getCurrentTime;
32
+ SetGestureStateFunction setGestureStateFunction;
28
33
  };
29
34
 
30
35
  } // namespace reanimated
@@ -1,6 +1,4 @@
1
-
2
- #ifndef REANIMATEDEXAMPLE_REANIMATEDHIDDEN_H
3
- #define REANIMATEDEXAMPLE_REANIMATEDHIDDEN_H
1
+ #pragma once
4
2
 
5
3
  #if defined(ONANDROID)
6
4
  #include "Logger.h"
@@ -11,5 +9,3 @@
11
9
  #include "Common/cpp/hidden_headers/LoggerInterface.h"
12
10
  #include "Common/cpp/hidden_headers/SpeedChecker.h"
13
11
  #endif
14
-
15
- #endif // REANIMATEDEXAMPLE_REANIMATEDHIDDEN_H
@@ -2,6 +2,8 @@
2
2
 
3
3
  #include <jsi/jsi.h>
4
4
  #include <stdio.h>
5
+ #include <memory>
6
+ #include <string>
5
7
  #include <unordered_map>
6
8
  #include "LayoutAnimationsProxy.h"
7
9
  #include "PlatformDepMethodsHolder.h"
@@ -34,6 +36,7 @@ class RuntimeDecorator {
34
36
  const ScrollToFunction scrollTo,
35
37
  const MeasuringFunction measure,
36
38
  const TimeProviderFunction getCurrentTime,
39
+ const SetGestureStateFunction setGestureState,
37
40
  std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy);
38
41
 
39
42
  /**
@@ -56,27 +59,27 @@ class RuntimeDecorator {
56
59
  static void registerRuntime(jsi::Runtime *runtime, RuntimeType runtimeType);
57
60
 
58
61
  private:
59
- static std::unordered_map<RuntimePointer, RuntimeType> runtimeRegistry;
62
+ static std::unordered_map<RuntimePointer, RuntimeType> &runtimeRegistry();
60
63
  };
61
64
 
62
65
  inline bool RuntimeDecorator::isUIRuntime(jsi::Runtime &rt) {
63
- auto iterator = runtimeRegistry.find(&rt);
64
- if (iterator == runtimeRegistry.end())
66
+ auto iterator = runtimeRegistry().find(&rt);
67
+ if (iterator == runtimeRegistry().end())
65
68
  return false;
66
69
  return iterator->second == RuntimeType::UI;
67
70
  }
68
71
 
69
72
  inline bool RuntimeDecorator::isWorkletRuntime(jsi::Runtime &rt) {
70
- auto iterator = runtimeRegistry.find(&rt);
71
- if (iterator == runtimeRegistry.end())
73
+ auto iterator = runtimeRegistry().find(&rt);
74
+ if (iterator == runtimeRegistry().end())
72
75
  return false;
73
76
  auto type = iterator->second;
74
77
  return type == RuntimeType::UI || type == RuntimeType::Worklet;
75
78
  }
76
79
 
77
80
  inline bool RuntimeDecorator::isReactRuntime(jsi::Runtime &rt) {
78
- auto iterator = runtimeRegistry.find(&rt);
79
- if (iterator == runtimeRegistry.end())
81
+ auto iterator = runtimeRegistry().find(&rt);
82
+ if (iterator == runtimeRegistry().end())
80
83
  return true;
81
84
  return false;
82
85
  }
@@ -3,9 +3,11 @@
3
3
  #include <ReactCommon/CallInvoker.h>
4
4
  #include <condition_variable>
5
5
  #include <functional>
6
+ #include <memory>
6
7
  #include <mutex>
7
8
  #include <queue>
8
9
  #include <thread>
10
+ #include <utility>
9
11
 
10
12
  namespace reanimated {
11
13
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  #include <jsi/jsi.h>
4
4
  #include <string>
5
+ #include <utility>
5
6
 
6
7
  using namespace facebook;
7
8
 
@@ -23,7 +24,7 @@ class WorkletEventHandler {
23
24
  std::string eventName,
24
25
  jsi::Function &&handler)
25
26
  : id(id), eventName(eventName), handler(std::move(handler)) {}
26
- void process(jsi::Runtime &rt, jsi::Value &eventValue);
27
+ void process(jsi::Runtime &rt, const jsi::Value &eventValue);
27
28
  };
28
29
 
29
30
  } // namespace reanimated
@@ -13,10 +13,10 @@ class Logger {
13
13
  throw std::runtime_error("no logger specified");
14
14
  }
15
15
  instance->log(value);
16
- };
16
+ }
17
17
 
18
18
  private:
19
19
  static std::unique_ptr<LoggerInterface> instance;
20
20
  };
21
21
 
22
- } // namespace reanimated
22
+ } // namespace reanimated
@@ -11,4 +11,4 @@ class LoggerInterface {
11
11
  virtual ~LoggerInterface() {}
12
12
  };
13
13
 
14
- } // namespace reanimated
14
+ } // namespace reanimated
@@ -5,9 +5,28 @@ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
5
5
  reactVersion = '0.0.0'
6
6
 
7
7
  begin
8
- reactVersion = JSON.parse(File.read(File.join(__dir__, "..", "react-native", "package.json")))["version"]
8
+ # standard app
9
+ # /appName/node_modules/react-native-reanimated/RNReanimated.podspec
10
+ # /appName/node_modules/react-native/package.json
11
+ reactVersion = JSON.parse(File.read(File.join(__dir__, "..", "..", "node_modules", "react-native", "package.json")))["version"]
9
12
  rescue
10
- reactVersion = '0.64.0'
13
+ begin
14
+ # monorepo
15
+ # /monorepo/packages/appName/node_modules/react-native-reanimated/RNReanimated.podspec
16
+ # /monorepo/node_modules/react-native/package.json
17
+ reactVersion = JSON.parse(File.read(File.join(__dir__, "..", "..", "..", "..", "node_modules", "react-native", "package.json")))["version"]
18
+ rescue
19
+ begin
20
+ # Example app in reanimated repo
21
+ # /react-native-reanimated/RNReanimated.podspec
22
+ # /react-native-reanimated/node_modules/react-native/package.json
23
+ reactVersion = JSON.parse(File.read(File.join(__dir__, "node_modules", "react-native", "package.json")))["version"]
24
+ rescue
25
+ # should never happen
26
+ reactVersion = '0.66.0'
27
+ puts "[RNReanimated] Unable to recognized your `react-native` version! Default `react-native` version: " + reactVersion
28
+ end
29
+ end
11
30
  end
12
31
 
13
32
  rnVersion = reactVersion.split('.')[1]
@@ -20,7 +39,7 @@ end
20
39
 
21
40
  folly_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DRNVERSION=' + rnVersion
22
41
  folly_compiler_flags = folly_flags + ' ' + '-Wno-comma -Wno-shorten-64-to-32'
23
- folly_version = '2020.01.13.00'
42
+ folly_version = '2021.04.26.00'
24
43
  boost_compiler_flags = '-Wno-documentation'
25
44
 
26
45
  Pod::Spec.new do |s|
@@ -49,12 +68,12 @@ Pod::Spec.new do |s|
49
68
 
50
69
  s.pod_target_xcconfig = {
51
70
  "USE_HEADERMAP" => "YES",
52
- "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\" "
71
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\" "
53
72
  }
54
73
  s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
55
74
  s.xcconfig = {
56
75
  "CLANG_CXX_LANGUAGE_STANDARD" => "c++14",
57
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\"",
76
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\"",
58
77
  "OTHER_CFLAGS" => "$(inherited)" + " " + folly_flags }
59
78
 
60
79
  s.requires_arc = true
@@ -74,7 +93,6 @@ Pod::Spec.new do |s|
74
93
  s.dependency 'React-RCTBlob'
75
94
  s.dependency 'React-RCTSettings'
76
95
  s.dependency 'React-RCTText'
77
- s.dependency 'React-RCTVibration'
78
96
  s.dependency 'React-RCTImage'
79
97
  s.dependency 'React-Core/RCTWebSocket'
80
98
  s.dependency 'React-cxxreact'
@@ -31,20 +31,14 @@ abstract class replaceSoTask extends DefaultTask {
31
31
  def getCurrentFlavor() {
32
32
  Gradle gradle = getGradle()
33
33
  String taskRequestName = gradle.getStartParameter().getTaskRequests().toString()
34
- Pattern pattern
35
-
36
- if(taskRequestName.contains("assemble")) {
37
- pattern = Pattern.compile("assemble(\\w+)(Release|Debug)")
38
- }
39
- else {
40
- pattern = Pattern.compile("generate(\\w+)(Release|Debug)")
41
- }
34
+ Pattern pattern = Pattern.compile("(assemble|bundle|install|generate)(\\w*)(Release|Debug)")
42
35
  Matcher matcher = pattern.matcher(taskRequestName)
43
36
 
44
37
  if(matcher.find()) {
45
- return matcher.group(1).toLowerCase()
38
+ return matcher.group(2)
46
39
  }
47
- return ""
40
+
41
+ return "NOT-FOUND"
48
42
  }
49
43
 
50
44
  def replaceSoTaskDebug
@@ -64,8 +58,9 @@ rootProject.getSubprojects().forEach({project ->
64
58
 
65
59
  if(project.getProperties().get("android") && Integer.parseInt(minor) < 65) {
66
60
  def projectProperties = project.getProperties()
67
- if(!projectProperties.get("reanimated")
68
- || (projectProperties.get("reanimated") && projectProperties.get("reanimated").get("enablePackagingOptions"))
61
+ final NOTFOUND = "NOT-FOUND"
62
+ if(!NOTFOUND.equals(getCurrentFlavor()) && (!projectProperties.get("reanimated")
63
+ || (projectProperties.get("reanimated") && projectProperties.get("reanimated").get("enablePackagingOptions")))
69
64
  ) {
70
65
  def flavorString = getCurrentFlavor()
71
66
  replaceSoTask.appName = project.getProperties().path
@@ -88,4 +83,29 @@ rootProject.getSubprojects().forEach({project ->
88
83
  }
89
84
  })
90
85
 
91
- artifacts.add("default", file("react-native-reanimated-${minor}-${engine}.aar"))
86
+ def minorCopy = Integer.parseInt(minor)
87
+ def aar = file("react-native-reanimated-${minorCopy}-${engine}.aar")
88
+
89
+ while (!aar.exists()) {
90
+ minorCopy -= 1
91
+ aar = file("react-native-reanimated-${minorCopy}-${engine}.aar")
92
+ if (minorCopy < 63) {
93
+ throw new GradleException('No aar for react-native-reanimated found.')
94
+ }
95
+ if (aar.exists()) {
96
+ println "\n\n\n"
97
+ println "****************************************************************************************"
98
+ println "\n\n\n"
99
+ println "WARNING reanimated - no version-specific reanimated AAR for react-native version " . minor . " found."
100
+ println "Falling back to AAR for react-native version " . minorCopy
101
+ println "The react-native JSI interface is not ABI-safe yet, this may result in crashes."
102
+ println "Please post a pull request to implement support for react-native version " . minor . " to the reanimated repo."
103
+ println "Thanks!"
104
+ println "\n\n\n"
105
+ println "****************************************************************************************"
106
+ }
107
+ }
108
+
109
+ artifacts.add("default", aar)
110
+
111
+ apply from: './expo/linking.gradle'
@@ -0,0 +1,34 @@
1
+ def isExpoLinked = false
2
+ rootProject.getSubprojects().forEach({ project ->
3
+ if (project.plugins.hasPlugin("com.android.application")) {
4
+ if (project.configurations.implementation.getDependencies().find { dep -> dep.name == "expo" }) {
5
+ isExpoLinked = true
6
+ }
7
+ }
8
+ })
9
+
10
+ def safeExtGet(prop, fallback) {
11
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
12
+ }
13
+
14
+ if (isExpoLinked) {
15
+ apply plugin: 'com.android.library'
16
+
17
+ android {
18
+ compileSdkVersion safeExtGet('compileSdkVersion', 30)
19
+
20
+ sourceSets {
21
+ main.manifest.srcFile 'src/AndroidManifest.xml'
22
+ main.java.srcDirs = [ 'expo/src/main/java' ]
23
+ }
24
+ }
25
+
26
+ dependencies {
27
+ implementation 'com.facebook.react:react-native:+'
28
+ implementation project(':expo-modules-core')
29
+
30
+ project.configurations.default.artifacts.each { artifact ->
31
+ api files(artifact.file)
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,12 @@
1
+ package com.swmansion.reanimated;
2
+
3
+ import com.facebook.react.bridge.JavaScriptContextHolder;
4
+ import com.facebook.react.bridge.ReactApplicationContext;
5
+
6
+ public class EXReanimatedAdapter {
7
+ public static void registerJSIModules(ReactApplicationContext reactApplicationContext, JavaScriptContextHolder jsContext) {
8
+ NodesManager nodesManager =
9
+ reactApplicationContext.getNativeModule(ReanimatedModule.class).getNodesManager();
10
+ nodesManager.initWithContext(reactApplicationContext);
11
+ }
12
+ }
@@ -0,0 +1,26 @@
1
+ package expo.modules.adapters.reanimated;
2
+
3
+ import android.content.Context;
4
+
5
+ import com.facebook.react.bridge.JavaScriptContextHolder;
6
+ import com.facebook.react.bridge.ReactApplicationContext;
7
+ import com.swmansion.reanimated.EXReanimatedAdapter;
8
+
9
+ import java.util.Collections;
10
+ import java.util.List;
11
+
12
+ import expo.modules.core.interfaces.Package;
13
+ import expo.modules.core.interfaces.ReactNativeHostHandler;
14
+
15
+ public class EXReanimatedPackage implements Package {
16
+ @Override
17
+ public List<? extends ReactNativeHostHandler> createReactNativeHostHandlers(Context context) {
18
+ final ReactNativeHostHandler handler = new ReactNativeHostHandler() {
19
+ @Override
20
+ public void onRegisterJSIModules(ReactApplicationContext reactApplicationContext, JavaScriptContextHolder jsContext, boolean useDeveloperSupport) {
21
+ EXReanimatedAdapter.registerJSIModules(reactApplicationContext, jsContext);
22
+ }
23
+ };
24
+ return Collections.singletonList(handler);
25
+ }
26
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "platforms": ["android"]
3
+ }