react-native-reanimated 2.14.1 → 2.14.3

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 (36) hide show
  1. package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
  3. package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
  4. package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  5. package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
  6. package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
  7. package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
  8. package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
  9. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  10. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  11. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  12. package/android/.gradle/file-system.probe +0 -0
  13. package/android/CMakeLists.txt +41 -32
  14. package/android/build.gradle +1 -1
  15. package/android/react-native-reanimated-67-hermes.aar +0 -0
  16. package/android/react-native-reanimated-67-jsc.aar +0 -0
  17. package/android/react-native-reanimated-68-hermes.aar +0 -0
  18. package/android/react-native-reanimated-68-jsc.aar +0 -0
  19. package/android/react-native-reanimated-69-hermes.aar +0 -0
  20. package/android/react-native-reanimated-69-jsc.aar +0 -0
  21. package/android/react-native-reanimated-70-hermes.aar +0 -0
  22. package/android/react-native-reanimated-70-jsc.aar +0 -0
  23. package/android/react-native-reanimated-71-hermes.aar +0 -0
  24. package/android/react-native-reanimated-71-jsc.aar +0 -0
  25. package/ios/native/NativeProxy.mm +5 -1
  26. package/lib/createAnimatedComponent.js +2 -2
  27. package/lib/reanimated2/animation/styleAnimation.js +4 -1
  28. package/lib/reanimated2/hook/useAnimatedStyle.js +3 -3
  29. package/lib/reanimated2/hook/utils.js +7 -15
  30. package/lib/reanimated2/platform-specific/checkVersion.js +4 -0
  31. package/package.json +1 -1
  32. package/src/createAnimatedComponent.tsx +2 -2
  33. package/src/reanimated2/animation/styleAnimation.ts +8 -1
  34. package/src/reanimated2/hook/useAnimatedStyle.ts +3 -3
  35. package/src/reanimated2/hook/utils.ts +6 -16
  36. package/src/reanimated2/platform-specific/checkVersion.ts +6 -0
@@ -1,2 +1,2 @@
1
- #Thu Jan 12 09:56:32 UTC 2023
1
+ #Thu Jan 19 15:25:25 UTC 2023
2
2
  gradle.version=7.5.1
Binary file
@@ -160,48 +160,54 @@ else()
160
160
  set (JSI_LIB "")
161
161
  else()
162
162
  find_library(
163
- JSI_LIB
164
- jsi
165
- PATHS ${LIBRN_DIR}
166
- NO_CMAKE_FIND_ROOT_PATH
163
+ JSI_LIB
164
+ jsi
165
+ PATHS ${LIBRN_DIR}
166
+ NO_DEFAULT_PATH
167
+ NO_CMAKE_FIND_ROOT_PATH
167
168
  )
168
169
  endif()
169
170
 
170
171
  find_library(
171
- GLOG_LIB
172
- glog
173
- PATHS ${LIBRN_DIR}
174
- NO_CMAKE_FIND_ROOT_PATH
172
+ GLOG_LIB
173
+ glog
174
+ PATHS ${LIBRN_DIR}
175
+ NO_DEFAULT_PATH
176
+ NO_CMAKE_FIND_ROOT_PATH
175
177
  )
176
178
 
177
179
  find_library(
178
- FBJNI_LIB
179
- fbjni
180
- PATHS ${LIBRN_DIR}
181
- NO_CMAKE_FIND_ROOT_PATH
180
+ FBJNI_LIB
181
+ fbjni
182
+ PATHS ${LIBRN_DIR}
183
+ NO_DEFAULT_PATH
184
+ NO_CMAKE_FIND_ROOT_PATH
182
185
  )
183
186
 
184
187
  if(${REACT_NATIVE_MINOR_VERSION} LESS 69)
185
188
  find_library(
186
- FOLLY_LIB
187
- folly_json
188
- PATHS ${LIBRN_DIR}
189
- NO_CMAKE_FIND_ROOT_PATH
189
+ FOLLY_LIB
190
+ folly_json
191
+ PATHS ${LIBRN_DIR}
192
+ NO_DEFAULT_PATH
193
+ NO_CMAKE_FIND_ROOT_PATH
190
194
  )
191
195
  else()
192
196
  find_library(
193
- FOLLY_LIB
194
- folly_runtime
195
- PATHS ${LIBRN_DIR}
196
- NO_CMAKE_FIND_ROOT_PATH
197
+ FOLLY_LIB
198
+ folly_runtime
199
+ PATHS ${LIBRN_DIR}
200
+ NO_DEFAULT_PATH
201
+ NO_CMAKE_FIND_ROOT_PATH
197
202
  )
198
203
  endif()
199
204
 
200
205
  find_library(
201
- REACTNATIVEJNI_LIB
202
- reactnativejni
203
- PATHS ${LIBRN_DIR}
204
- NO_CMAKE_FIND_ROOT_PATH
206
+ REACTNATIVEJNI_LIB
207
+ reactnativejni
208
+ PATHS ${LIBRN_DIR}
209
+ NO_DEFAULT_PATH
210
+ NO_CMAKE_FIND_ROOT_PATH
205
211
  )
206
212
 
207
213
  target_link_libraries(
@@ -246,10 +252,11 @@ if(${JS_RUNTIME} STREQUAL "hermes")
246
252
  set(HERMES_EXECUTOR_LIB ReactAndroid::hermes_executor)
247
253
  else()
248
254
  find_library(
249
- HERMES_EXECUTOR_LIB
250
- hermes-executor-debug
251
- PATHS ${LIBRN_DIR}
252
- NO_CMAKE_FIND_ROOT_PATH
255
+ HERMES_EXECUTOR_LIB
256
+ hermes-executor-debug
257
+ PATHS ${LIBRN_DIR}
258
+ NO_DEFAULT_PATH
259
+ NO_CMAKE_FIND_ROOT_PATH
253
260
  )
254
261
  endif()
255
262
  target_link_libraries(
@@ -269,6 +276,7 @@ elseif(${JS_RUNTIME} STREQUAL "v8")
269
276
  V8EXECUTOR_LIB
270
277
  v8executor
271
278
  PATHS ${V8_SO_DIR}
279
+ NO_DEFAULT_PATH
272
280
  NO_CMAKE_FIND_ROOT_PATH
273
281
  )
274
282
  target_link_libraries(
@@ -281,10 +289,11 @@ elseif(${JS_RUNTIME} STREQUAL "jsc")
281
289
  set(JSEXECUTOR_LIB ReactAndroid::jscexecutor)
282
290
  else()
283
291
  find_library(
284
- JSEXECUTOR_LIB
285
- jscexecutor
286
- PATHS ${LIBRN_DIR}
287
- NO_CMAKE_FIND_ROOT_PATH
292
+ JSEXECUTOR_LIB
293
+ jscexecutor
294
+ PATHS ${LIBRN_DIR}
295
+ NO_DEFAULT_PATH
296
+ NO_CMAKE_FIND_ROOT_PATH
288
297
  )
289
298
  endif()
290
299
  target_link_libraries(${PACKAGE_NAME} ${JSEXECUTOR_LIB})
@@ -481,7 +481,7 @@ android {
481
481
  debug {
482
482
  externalNativeBuild {
483
483
  cmake {
484
- if (JS_RUNTIME == "hermes") {
484
+ if (JS_RUNTIME == "hermes" && !REANIMATED_PACKAGE_BUILD) {
485
485
  arguments "-DHERMES_ENABLE_DEBUGGER=1"
486
486
  } else {
487
487
  arguments "-DHERMES_ENABLE_DEBUGGER=0"
@@ -23,7 +23,11 @@
23
23
  #elif __has_include(<hermes/hermes.h>)
24
24
  #import <hermes/hermes.h>
25
25
  #else
26
- #import <jsi/JSCRuntime.h>
26
+ #if REACT_NATIVE_MINOR_VERSION >= 71
27
+ #include <jsc/JSCRuntime.h>
28
+ #else
29
+ #include <jsi/JSCRuntime.h>
30
+ #endif // REACT_NATIVE_MINOR_VERSION
27
31
  #endif
28
32
 
29
33
  namespace reanimated {
@@ -192,8 +192,8 @@ export default function createAnimatedComponent(Component, options) {
192
192
  let viewTag = findNodeHandle((options === null || options === void 0 ? void 0 : options.setNativeProps) ? this : node);
193
193
  const componentName = Component.displayName || Component.name;
194
194
  if ((componentName === null || componentName === void 0 ? void 0 : componentName.endsWith('FlashList')) && this._component) {
195
- // @ts-ignore it's FlashList specific: https://github.com/Shopify/flash-list/blob/218f314e63806b4fe926741ef73f8b9cd6ebc7eb/src/FlashList.tsx#L824
196
- viewTag = findNodeHandle(this._component.recyclerlistview_unsafe);
195
+ // @ts-ignore it's FlashList specific: https://github.com/Shopify/flash-list/blob/218f314e63806b4fe926741ef73f8b9cd6ebc7eb/src/FlashList.tsx#L815
196
+ viewTag = findNodeHandle(this._component.getScrollableNode());
197
197
  }
198
198
  for (const key in this.props) {
199
199
  const prop = this.props[key];
@@ -24,7 +24,7 @@ export function setPath(obj, path, value) {
24
24
  for (let i = 0; i < keys.length - 1; i++) {
25
25
  // creates entry if there isn't one
26
26
  currObj = currObj;
27
- if (!currObj[keys[i]]) {
27
+ if (!(keys[i] in currObj)) {
28
28
  // if next key is a number create an array
29
29
  if (typeof keys[i + 1] === 'number') {
30
30
  currObj[keys[i]] = [];
@@ -117,6 +117,9 @@ export function withStyleAnimation(styleAnimations) {
117
117
  if (prevAnimation && !prevVal) {
118
118
  prevVal = prevAnimation.current;
119
119
  }
120
+ if (prevVal === undefined) {
121
+ console.warn(`Initial values for animation are missing for property ${currentEntry.path.join('.')}`);
122
+ }
120
123
  setPath(animation.current, currentEntry.path, prevVal);
121
124
  let currentAnimation;
122
125
  if (typeof currentEntry.value !== 'object' ||
@@ -155,7 +155,7 @@ function styleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsA
155
155
  requestFrame(frame);
156
156
  }
157
157
  }
158
- state.last = Object.assign({}, oldValues, newValues);
158
+ state.last = Object.assign(oldValues, newValues);
159
159
  const style = getStyleWithoutAnimations(state.last);
160
160
  if (style) {
161
161
  updateProps(viewDescriptors, style, maybeViewRef);
@@ -165,7 +165,7 @@ function styleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsA
165
165
  state.isAnimationCancelled = true;
166
166
  state.animations = [];
167
167
  const diff = styleDiff(oldValues, newValues);
168
- state.last = Object.assign({}, oldValues, newValues);
168
+ state.last = Object.assign(oldValues, diff);
169
169
  if (diff) {
170
170
  updateProps(viewDescriptors, newValues, maybeViewRef);
171
171
  }
@@ -240,7 +240,7 @@ function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animati
240
240
  }
241
241
  // calculate diff
242
242
  const diff = styleDiff(oldValues, newValues);
243
- state.last = Object.assign({}, oldValues, newValues);
243
+ state.last = Object.assign(oldValues, diff);
244
244
  if (Object.keys(diff).length !== 0) {
245
245
  updatePropsJestWrapper(viewDescriptors, diff, maybeViewRef, animatedStyle, adapters);
246
246
  }
@@ -108,25 +108,17 @@ export function canApplyOptimalisation(upadterFn) {
108
108
  }
109
109
  export function isAnimated(prop) {
110
110
  'worklet';
111
- const propsToCheck = [prop];
112
- while (propsToCheck.length > 0) {
113
- const currentProp = propsToCheck.pop();
114
- if (Array.isArray(currentProp)) {
115
- for (const item of currentProp) {
116
- propsToCheck.push(item);
117
- }
118
- }
119
- else if ((currentProp === null || currentProp === void 0 ? void 0 : currentProp.onFrame) !== undefined) {
111
+ if (Array.isArray(prop)) {
112
+ return prop.some(isAnimated);
113
+ }
114
+ else if (typeof prop === 'object') {
115
+ if (prop.onFrame !== undefined) {
120
116
  return true;
121
117
  }
122
- else if (typeof currentProp === 'object') {
123
- for (const item of Object.values(currentProp)) {
124
- propsToCheck.push(item);
125
- }
118
+ else {
119
+ return Object.values(prop).some(isAnimated);
126
120
  }
127
- // if none of the above, it's not the animated prop, check next one
128
121
  }
129
- // when none of the props were animated return false
130
122
  return false;
131
123
  }
132
124
  export function styleDiff(oldStyle, newStyle) {
@@ -4,6 +4,10 @@ import { version as jsVersion } from '../../../package.json';
4
4
  */
5
5
  export function checkVersion() {
6
6
  const cppVersion = global._REANIMATED_VERSION_CPP;
7
+ if (cppVersion === undefined) {
8
+ console.error(`[Reanimated] Couldn't determine the version of the native part of Reanimated. Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must use the exact version which is bundled into Expo SDK.`);
9
+ return;
10
+ }
7
11
  const ok = (() => {
8
12
  if (jsVersion.match(/^\d+\.\d+\.\d+$/) &&
9
13
  cppVersion.match(/^\d+\.\d+\.\d+$/)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-reanimated",
3
- "version": "2.14.1",
3
+ "version": "2.14.3",
4
4
  "description": "More powerful alternative to Animated library for React Native.",
5
5
  "scripts": {
6
6
  "test": "yarn run format:js && yarn run lint:js && yarn run test:unit",
@@ -245,8 +245,8 @@ export default function createAnimatedComponent(
245
245
  const componentName = Component.displayName || Component.name;
246
246
 
247
247
  if (componentName?.endsWith('FlashList') && this._component) {
248
- // @ts-ignore it's FlashList specific: https://github.com/Shopify/flash-list/blob/218f314e63806b4fe926741ef73f8b9cd6ebc7eb/src/FlashList.tsx#L824
249
- viewTag = findNodeHandle(this._component.recyclerlistview_unsafe);
248
+ // @ts-ignore it's FlashList specific: https://github.com/Shopify/flash-list/blob/218f314e63806b4fe926741ef73f8b9cd6ebc7eb/src/FlashList.tsx#L815
249
+ viewTag = findNodeHandle(this._component.getScrollableNode());
250
250
  }
251
251
 
252
252
  for (const key in this.props) {
@@ -46,7 +46,7 @@ export function setPath<T>(
46
46
  for (let i = 0; i < keys.length - 1; i++) {
47
47
  // creates entry if there isn't one
48
48
  currObj = currObj as { [key: string]: NestedObjectValues<T> };
49
- if (!currObj[keys[i]]) {
49
+ if (!(keys[i] in currObj)) {
50
50
  // if next key is a number create an array
51
51
  if (typeof keys[i + 1] === 'number') {
52
52
  currObj[keys[i]] = [];
@@ -178,6 +178,13 @@ export function withStyleAnimation(
178
178
  if (prevAnimation && !prevVal) {
179
179
  prevVal = prevAnimation.current;
180
180
  }
181
+ if (prevVal === undefined) {
182
+ console.warn(
183
+ `Initial values for animation are missing for property ${currentEntry.path.join(
184
+ '.'
185
+ )}`
186
+ );
187
+ }
181
188
  setPath(animation.current, currentEntry.path, prevVal);
182
189
  let currentAnimation: AnimationObject;
183
190
  if (
@@ -253,7 +253,7 @@ function styleUpdater(
253
253
  requestFrame(frame);
254
254
  }
255
255
  }
256
- state.last = Object.assign({}, oldValues, newValues);
256
+ state.last = Object.assign(oldValues, newValues);
257
257
  const style = getStyleWithoutAnimations(state.last);
258
258
  if (style) {
259
259
  updateProps(viewDescriptors, style, maybeViewRef);
@@ -263,7 +263,7 @@ function styleUpdater(
263
263
  state.animations = [];
264
264
 
265
265
  const diff = styleDiff(oldValues, newValues);
266
- state.last = Object.assign({}, oldValues, newValues);
266
+ state.last = Object.assign(oldValues, diff);
267
267
  if (diff) {
268
268
  updateProps(viewDescriptors, newValues, maybeViewRef);
269
269
  }
@@ -361,7 +361,7 @@ function jestStyleUpdater(
361
361
 
362
362
  // calculate diff
363
363
  const diff = styleDiff(oldValues, newValues);
364
- state.last = Object.assign({}, oldValues, newValues);
364
+ state.last = Object.assign(oldValues, diff);
365
365
 
366
366
  if (Object.keys(diff).length !== 0) {
367
367
  updatePropsJestWrapper(
@@ -179,25 +179,15 @@ export function canApplyOptimalisation(upadterFn: WorkletFunction): number {
179
179
 
180
180
  export function isAnimated(prop: NestedObjectValues<AnimationObject>): boolean {
181
181
  'worklet';
182
- const propsToCheck: NestedObjectValues<AnimationObject>[] = [prop];
183
- while (propsToCheck.length > 0) {
184
- const currentProp: NestedObjectValues<AnimationObject> =
185
- propsToCheck.pop() as NestedObjectValues<AnimationObject>;
186
- if (Array.isArray(currentProp)) {
187
- for (const item of currentProp) {
188
- propsToCheck.push(item);
189
- }
190
- } else if (currentProp?.onFrame !== undefined) {
182
+ if (Array.isArray(prop)) {
183
+ return prop.some(isAnimated);
184
+ } else if (typeof prop === 'object') {
185
+ if (prop.onFrame !== undefined) {
191
186
  return true;
192
- } else if (typeof currentProp === 'object') {
193
- for (const item of Object.values(currentProp)) {
194
- propsToCheck.push(item);
195
- }
187
+ } else {
188
+ return Object.values(prop).some(isAnimated);
196
189
  }
197
- // if none of the above, it's not the animated prop, check next one
198
190
  }
199
-
200
- // when none of the props were animated return false
201
191
  return false;
202
192
  }
203
193
 
@@ -5,6 +5,12 @@ import { version as jsVersion } from '../../../package.json';
5
5
  */
6
6
  export function checkVersion(): void {
7
7
  const cppVersion = global._REANIMATED_VERSION_CPP;
8
+ if (cppVersion === undefined) {
9
+ console.error(
10
+ `[Reanimated] Couldn't determine the version of the native part of Reanimated. Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must use the exact version which is bundled into Expo SDK.`
11
+ );
12
+ return;
13
+ }
8
14
  const ok = (() => {
9
15
  if (
10
16
  jsVersion.match(/^\d+\.\d+\.\d+$/) &&