react-native-reanimated 3.0.0-rc.8 → 3.0.0-rc.9

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 (72) hide show
  1. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +17 -12
  2. package/Common/cpp/NativeModules/NativeReanimatedModule.h +2 -2
  3. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +2 -2
  4. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +30 -0
  5. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +1 -1
  6. package/Common/cpp/SharedItems/Shareables.cpp +3 -1
  7. package/Common/cpp/SharedItems/Shareables.h +37 -22
  8. package/Common/cpp/Tools/RuntimeDecorator.cpp +26 -25
  9. package/Common/cpp/Tools/RuntimeDecorator.h +2 -1
  10. package/ios/LayoutReanimation/REAAnimationsManager.h +3 -1
  11. package/ios/LayoutReanimation/REAAnimationsManager.m +49 -16
  12. package/ios/LayoutReanimation/REAUIManager.mm +22 -62
  13. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +2 -2
  14. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  15. package/lib/commonjs/reanimated2/component/FlatList.js +19 -3
  16. package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
  17. package/lib/commonjs/reanimated2/core.js +6 -74
  18. package/lib/commonjs/reanimated2/core.js.map +1 -1
  19. package/lib/commonjs/reanimated2/errors.js +66 -0
  20. package/lib/commonjs/reanimated2/errors.js.map +1 -0
  21. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  22. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +0 -10
  23. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  24. package/lib/commonjs/reanimated2/initializers.js +157 -0
  25. package/lib/commonjs/reanimated2/initializers.js.map +1 -0
  26. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +1 -6
  27. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  28. package/lib/commonjs/reanimated2/js-reanimated/global.js +4 -7
  29. package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
  30. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +0 -4
  31. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  32. package/lib/commonjs/reanimated2/mock.js +26 -0
  33. package/lib/commonjs/reanimated2/mock.js.map +1 -1
  34. package/lib/commonjs/reanimated2/shareables.js +6 -0
  35. package/lib/commonjs/reanimated2/shareables.js.map +1 -1
  36. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +2 -2
  37. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  38. package/lib/module/reanimated2/component/FlatList.js +18 -4
  39. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  40. package/lib/module/reanimated2/core.js +3 -74
  41. package/lib/module/reanimated2/core.js.map +1 -1
  42. package/lib/module/reanimated2/errors.js +58 -0
  43. package/lib/module/reanimated2/errors.js.map +1 -0
  44. package/lib/module/reanimated2/globals.d.js.map +1 -1
  45. package/lib/module/reanimated2/hook/useAnimatedStyle.js +2 -12
  46. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  47. package/lib/module/reanimated2/initializers.js +143 -0
  48. package/lib/module/reanimated2/initializers.js.map +1 -0
  49. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +1 -6
  50. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  51. package/lib/module/reanimated2/js-reanimated/global.js +4 -7
  52. package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
  53. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +0 -2
  54. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  55. package/lib/module/reanimated2/mock.js +26 -0
  56. package/lib/module/reanimated2/mock.js.map +1 -1
  57. package/lib/module/reanimated2/shareables.js +6 -1
  58. package/lib/module/reanimated2/shareables.js.map +1 -1
  59. package/package.json +3 -2
  60. package/plugin.js +81 -15
  61. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +11 -2
  62. package/src/reanimated2/component/FlatList.tsx +30 -5
  63. package/src/reanimated2/core.ts +3 -66
  64. package/src/reanimated2/errors.ts +57 -0
  65. package/src/reanimated2/globals.d.ts +22 -3
  66. package/src/reanimated2/hook/useAnimatedStyle.ts +1 -11
  67. package/src/reanimated2/initializers.ts +143 -0
  68. package/src/reanimated2/js-reanimated/JSReanimated.ts +8 -4
  69. package/src/reanimated2/js-reanimated/global.ts +4 -7
  70. package/src/reanimated2/layoutReanimation/animationsManager.ts +0 -3
  71. package/src/reanimated2/mock.ts +105 -0
  72. package/src/reanimated2/shareables.ts +7 -0
@@ -58,8 +58,11 @@ NativeReanimatedModule::NativeReanimatedModule(
58
58
  platformDepMethodsHolder.configurePropsFunction)
59
59
  #endif
60
60
  {
61
- auto requestAnimationFrame = [=](FrameCallback callback) {
62
- frameCallbacks.push_back(callback);
61
+ auto requestAnimationFrame = [=](jsi::Runtime &rt, const jsi::Value &fn) {
62
+ auto jsFunction = std::make_shared<jsi::Value>(rt, fn);
63
+ frameCallbacks.push_back([=](double timestamp) {
64
+ runtimeHelper->runOnUIGuarded(*jsFunction, jsi::Value(timestamp));
65
+ });
63
66
  maybeRequestRender();
64
67
  };
65
68
 
@@ -174,24 +177,28 @@ NativeReanimatedModule::NativeReanimatedModule(
174
177
 
175
178
  void NativeReanimatedModule::installCoreFunctions(
176
179
  jsi::Runtime &rt,
177
- const jsi::Value &valueUnpacker,
178
- const jsi::Value &layoutAnimationStartFunction) {
180
+ const jsi::Value &callGuard,
181
+ const jsi::Value &valueUnpacker) {
179
182
  if (!runtimeHelper) {
180
183
  // initialize runtimeHelper here if not already present. We expect only one
181
184
  // instace of the helper to exists.
182
185
  runtimeHelper =
183
186
  std::make_shared<JSRuntimeHelper>(&rt, this->runtime.get(), scheduler);
184
187
  }
188
+ runtimeHelper->callGuard =
189
+ std::make_unique<CoreFunction>(runtimeHelper.get(), callGuard);
185
190
  runtimeHelper->valueUnpacker =
186
- std::make_shared<CoreFunction>(runtimeHelper.get(), valueUnpacker);
191
+ std::make_unique<CoreFunction>(runtimeHelper.get(), valueUnpacker);
187
192
  }
188
193
 
189
194
  NativeReanimatedModule::~NativeReanimatedModule() {
190
195
  if (runtimeHelper) {
196
+ runtimeHelper->callGuard = nullptr;
191
197
  runtimeHelper->valueUnpacker = nullptr;
192
- // event handler registry stores some JSI values from UI runtime, so it has
193
- // to go away before we tear down the runtime
198
+ // event handler registry and frame callbacks store some JSI values from UI
199
+ // runtime, so they have to go away before we tear down the runtime
194
200
  eventHandlerRegistry.reset();
201
+ frameCallbacks.clear();
195
202
  runtime.reset();
196
203
  // make sure uiRuntimeDestroyed is set after the runtime is deallocated
197
204
  runtimeHelper->uiRuntimeDestroyed = true;
@@ -205,13 +212,11 @@ void NativeReanimatedModule::scheduleOnUI(
205
212
  assert(
206
213
  shareableWorklet->valueType() == Shareable::WorkletType &&
207
214
  "only worklets can be scheduled to run on UI");
208
- auto uiRuntime = runtimeHelper->uiRuntime();
209
- frameCallbacks.push_back([=](double timestamp) {
210
- jsi::Runtime &rt = *uiRuntime;
215
+ scheduler->scheduleOnUI([=] {
216
+ jsi::Runtime &rt = *runtimeHelper->uiRuntime();
211
217
  auto workletValue = shareableWorklet->getJSValue(rt);
212
- workletValue.asObject(rt).asFunction(rt).call(rt);
218
+ runtimeHelper->runOnUIGuarded(workletValue);
213
219
  });
214
- maybeRequestRender();
215
220
  }
216
221
 
217
222
  jsi::Value NativeReanimatedModule::makeSynchronizedDataHolder(
@@ -49,8 +49,8 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec,
49
49
 
50
50
  void installCoreFunctions(
51
51
  jsi::Runtime &rt,
52
- const jsi::Value &workletMaker,
53
- const jsi::Value &layoutAnimationStartFunction) override;
52
+ const jsi::Value &callGuard,
53
+ const jsi::Value &valueUnpacker) override;
54
54
 
55
55
  jsi::Value makeShareableClone(jsi::Runtime &rt, const jsi::Value &value)
56
56
  override;
@@ -24,8 +24,8 @@ class JSI_EXPORT NativeReanimatedModuleSpec : public TurboModule {
24
24
  public:
25
25
  virtual void installCoreFunctions(
26
26
  jsi::Runtime &rt,
27
- const jsi::Value &valueUnpacker,
28
- const jsi::Value &layoutAnimationStartFunction) = 0;
27
+ const jsi::Value &callGuard,
28
+ const jsi::Value &valueUnpacker) = 0;
29
29
 
30
30
  // SharedValue
31
31
  virtual jsi::Value makeShareableClone(
@@ -9,6 +9,7 @@
9
9
  #include <jsi/jsi.h>
10
10
 
11
11
  #include <memory>
12
+ #include <string>
12
13
  #include <utility>
13
14
 
14
15
  #if __has_include(<reacthermes/HermesExecutorFactory.h>)
@@ -79,6 +80,35 @@ ReanimatedHermesRuntime::ReanimatedHermesRuntime(
79
80
  // that the thread was indeed `quit` before
80
81
  jsQueue->quitSynchronous();
81
82
  #endif
83
+
84
+ #ifdef DEBUG
85
+ facebook::hermes::HermesRuntime *wrappedRuntime = runtime_.get();
86
+ jsi::Value evalWithSourceMap = jsi::Function::createFromHostFunction(
87
+ *runtime_,
88
+ jsi::PropNameID::forAscii(*runtime_, "evalWithSourceMap"),
89
+ 3,
90
+ [wrappedRuntime](
91
+ jsi::Runtime &rt,
92
+ const jsi::Value &thisValue,
93
+ const jsi::Value *args,
94
+ size_t count) -> jsi::Value {
95
+ auto code = std::make_shared<const jsi::StringBuffer>(
96
+ args[0].asString(rt).utf8(rt));
97
+ std::string sourceURL;
98
+ if (count > 1 && args[1].isString()) {
99
+ sourceURL = args[1].asString(rt).utf8(rt);
100
+ }
101
+ std::shared_ptr<const jsi::Buffer> sourceMap;
102
+ if (count > 2 && args[2].isString()) {
103
+ sourceMap = std::make_shared<const jsi::StringBuffer>(
104
+ args[2].asString(rt).utf8(rt));
105
+ }
106
+ return wrappedRuntime->evaluateJavaScriptWithSourceMap(
107
+ code, sourceMap, sourceURL);
108
+ });
109
+ runtime_->global().setProperty(
110
+ *runtime_, "evalWithSourceMap", evalWithSourceMap);
111
+ #endif // DEBUG
82
112
  }
83
113
 
84
114
  ReanimatedHermesRuntime::~ReanimatedHermesRuntime() {
@@ -116,7 +116,7 @@ class ReanimatedHermesRuntime
116
116
  ~ReanimatedHermesRuntime();
117
117
 
118
118
  private:
119
- std::shared_ptr<facebook::hermes::HermesRuntime> runtime_;
119
+ std::unique_ptr<facebook::hermes::HermesRuntime> runtime_;
120
120
  ReanimatedReentrancyCheck reentrancyCheck_;
121
121
  };
122
122
 
@@ -13,7 +13,9 @@ CoreFunction::CoreFunction(
13
13
  rnFunction_ = std::make_unique<jsi::Function>(workletObject.asFunction(rt));
14
14
  functionBody_ =
15
15
  workletObject.getProperty(rt, "asString").asString(rt).utf8(rt);
16
- location_ = workletObject.getProperty(rt, "__location").asString(rt).utf8(rt);
16
+ location_ = "worklet_" +
17
+ std::to_string(static_cast<unsigned long long>(
18
+ workletObject.getProperty(rt, "__workletHash").getNumber()));
17
19
  }
18
20
 
19
21
  std::unique_ptr<jsi::Function> &CoreFunction::getFunction(jsi::Runtime &rt) {
@@ -14,13 +14,35 @@
14
14
  #include "RuntimeManager.h"
15
15
  #include "Scheduler.h"
16
16
 
17
- #define HAS_JS_WEAK_OBJECTS JS_RUNTIME_HERMES
17
+ #define HAS_JS_WEAK_OBJECTS (JS_RUNTIME_HERMES || JS_RUNTIME_V8)
18
18
 
19
19
  using namespace facebook;
20
20
 
21
21
  namespace reanimated {
22
22
 
23
- class CoreFunction;
23
+ class JSRuntimeHelper;
24
+
25
+ // Core functions are not allowed to capture outside variables, otherwise they'd
26
+ // try to access _closure variable which is something we want to avoid for
27
+ // simplicity reasons.
28
+ class CoreFunction {
29
+ private:
30
+ std::unique_ptr<jsi::Function> rnFunction_;
31
+ std::unique_ptr<jsi::Function> uiFunction_;
32
+ std::string functionBody_;
33
+ std::string location_;
34
+ JSRuntimeHelper
35
+ *runtimeHelper_; // runtime helper holds core function references, so we
36
+ // use normal pointer here to avoid ref cycles.
37
+ std::unique_ptr<jsi::Function> &getFunction(jsi::Runtime &rt);
38
+
39
+ public:
40
+ CoreFunction(JSRuntimeHelper *runtimeHelper, const jsi::Value &workletObject);
41
+ template <typename... Args>
42
+ jsi::Value call(jsi::Runtime &rt, Args &&...args) {
43
+ return getFunction(rt)->call(rt, args...);
44
+ }
45
+ };
24
46
 
25
47
  class JSRuntimeHelper {
26
48
  private:
@@ -36,7 +58,8 @@ class JSRuntimeHelper {
36
58
  : rnRuntime_(rnRuntime), uiRuntime_(uiRuntime), scheduler_(scheduler) {}
37
59
 
38
60
  volatile bool uiRuntimeDestroyed;
39
- std::shared_ptr<CoreFunction> valueUnpacker;
61
+ std::unique_ptr<CoreFunction> callGuard;
62
+ std::unique_ptr<CoreFunction> valueUnpacker;
40
63
 
41
64
  inline jsi::Runtime *uiRuntime() const {
42
65
  return uiRuntime_;
@@ -61,27 +84,19 @@ class JSRuntimeHelper {
61
84
  void scheduleOnJS(std::function<void()> job) {
62
85
  scheduler_->scheduleOnJS(job);
63
86
  }
64
- };
65
-
66
- // Core functions are not allowed to capture outside variables, otherwise they'd
67
- // try to access _closure variable which is something we want to avoid for
68
- // simplicity reasons.
69
- class CoreFunction {
70
- private:
71
- std::unique_ptr<jsi::Function> rnFunction_;
72
- std::unique_ptr<jsi::Function> uiFunction_;
73
- std::string functionBody_;
74
- std::string location_;
75
- JSRuntimeHelper
76
- *runtimeHelper_; // runtime helper holds core function references, so we
77
- // use normal pointer here to avoid ref cycles.
78
- std::unique_ptr<jsi::Function> &getFunction(jsi::Runtime &rt);
79
87
 
80
- public:
81
- CoreFunction(JSRuntimeHelper *runtimeHelper, const jsi::Value &workletObject);
82
88
  template <typename... Args>
83
- jsi::Value call(jsi::Runtime &rt, Args &&...args) {
84
- return getFunction(rt)->call(rt, args...);
89
+ inline void runOnUIGuarded(const jsi::Value &function, Args &&...args) {
90
+ // We only use callGuard in debug mode, otherwise we call the provided
91
+ // function directly. CallGuard provides a way of capturing exceptions in
92
+ // JavaScript and propagating them to the main React Native thread such that
93
+ // they can be presented using RN's LogBox.
94
+ jsi::Runtime &rt = *uiRuntime_;
95
+ #ifdef DEBUG
96
+ callGuard->call(rt, function, args...);
97
+ #else
98
+ function.asObject(rt).asFunction(rt).call(rt, args...);
99
+ #endif
85
100
  }
86
101
  };
87
102
 
@@ -30,11 +30,32 @@ void RuntimeDecorator::decorateRuntime(
30
30
  rt.global().setProperty(
31
31
  rt, "_LABEL", jsi::String::createFromAscii(rt, label));
32
32
 
33
- jsi::Object dummyGlobal(rt);
34
- dummyGlobal.setProperty(rt, "gc", rt.global().getProperty(rt, "gc"));
35
- rt.global().setProperty(rt, "global", dummyGlobal);
33
+ rt.global().setProperty(rt, "global", rt.global());
36
34
 
37
- rt.global().setProperty(rt, "jsThis", jsi::Value::undefined());
35
+ #ifdef DEBUG
36
+ auto evalWithSourceUrl = [](jsi::Runtime &rt,
37
+ const jsi::Value &thisValue,
38
+ const jsi::Value *args,
39
+ size_t count) -> jsi::Value {
40
+ auto code = std::make_shared<const jsi::StringBuffer>(
41
+ args[0].asString(rt).utf8(rt));
42
+ std::string url;
43
+ if (count > 1 && args[1].isString()) {
44
+ url = args[1].asString(rt).utf8(rt);
45
+ }
46
+
47
+ return rt.evaluateJavaScript(code, url);
48
+ };
49
+
50
+ rt.global().setProperty(
51
+ rt,
52
+ "evalWithSourceUrl",
53
+ jsi::Function::createFromHostFunction(
54
+ rt,
55
+ jsi::PropNameID::forAscii(rt, "evalWithSourceUrl"),
56
+ 1,
57
+ evalWithSourceUrl));
58
+ #endif // DEBUG
38
59
 
39
60
  auto callback = [](jsi::Runtime &rt,
40
61
  const jsi::Value &thisValue,
@@ -56,22 +77,6 @@ void RuntimeDecorator::decorateRuntime(
56
77
  rt, jsi::PropNameID::forAscii(rt, "_log"), 1, callback);
57
78
  rt.global().setProperty(rt, "_log", log);
58
79
 
59
- auto setGlobalConsole = [](jsi::Runtime &rt,
60
- const jsi::Value &thisValue,
61
- const jsi::Value *args,
62
- size_t count) -> jsi::Value {
63
- rt.global().setProperty(rt, "console", args[0]);
64
- return jsi::Value::undefined();
65
- };
66
- rt.global().setProperty(
67
- rt,
68
- "_setGlobalConsole",
69
- jsi::Function::createFromHostFunction(
70
- rt,
71
- jsi::PropNameID::forAscii(rt, "_setGlobalConsole"),
72
- 1,
73
- setGlobalConsole));
74
-
75
80
  auto chronoNow = [](jsi::Runtime &rt,
76
81
  const jsi::Value &thisValue,
77
82
  const jsi::Value *args,
@@ -226,11 +231,7 @@ void RuntimeDecorator::decorateUIRuntime(
226
231
  const jsi::Value &thisValue,
227
232
  const jsi::Value *args,
228
233
  const size_t count) -> jsi::Value {
229
- auto fun =
230
- std::make_shared<jsi::Function>(args[0].asObject(rt).asFunction(rt));
231
- requestFrame([&rt, fun](double timestampMs) {
232
- fun->call(rt, jsi::Value(timestampMs));
233
- });
234
+ requestFrame(rt, std::move(args[0]));
234
235
  return jsi::Value::undefined();
235
236
  };
236
237
  jsi::Value requestAnimationFrame = jsi::Function::createFromHostFunction(
@@ -11,7 +11,8 @@ using namespace facebook;
11
11
 
12
12
  namespace reanimated {
13
13
 
14
- using RequestFrameFunction = std::function<void(std::function<void(double)>)>;
14
+ using RequestFrameFunction =
15
+ std::function<void(jsi::Runtime &, const jsi::Value &)>;
15
16
  using ScheduleOnJSFunction =
16
17
  std::function<void(jsi::Runtime &, const jsi::Value &, const jsi::Value &)>;
17
18
  using MakeShareableCloneFunction =
@@ -33,7 +33,9 @@ typedef void (^REAAnimationRemovingBlock)(NSNumber *_Nonnull tag);
33
33
  - (REASnapshot *)prepareSnapshotBeforeMountForView:(UIView *)view;
34
34
  - (BOOL)wantsHandleRemovalOfView:(UIView *)view;
35
35
  - (void)removeAnimationsFromSubtree:(UIView *)view;
36
- - (void)removeChildren:(NSArray<UIView *> *)children fromContainer:(UIView *)container;
36
+ - (void)reattachAnimatedChildren:(NSArray<id<RCTComponent>> *)children
37
+ toContainer:(id<RCTComponent>)container
38
+ atIndices:(NSArray<NSNumber *> *)indices;
37
39
  - (void)onViewCreate:(UIView *)view after:(REASnapshot *)after;
38
40
  - (void)onViewUpdate:(UIView *)view before:(REASnapshot *)before after:(REASnapshot *)after;
39
41
 
@@ -245,11 +245,17 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
245
245
  }
246
246
 
247
247
  - (void)registerExitingAncestors:(UIView *)child
248
+ {
249
+ [self registerExitingAncestors:child exitingSubviewsCount:1];
250
+ }
251
+
252
+ - (void)registerExitingAncestors:(UIView *)child exitingSubviewsCount:(int)exitingSubviewsCount
248
253
  {
249
254
  UIView *parent = child.superview;
250
255
  while (parent != nil && ![parent isKindOfClass:[RCTRootView class]]) {
251
256
  if (parent.reactTag != nil) {
252
- _exitingSubviewsCountMap[parent.reactTag] = @([_exitingSubviewsCountMap[parent.reactTag] intValue] + 1);
257
+ _exitingSubviewsCountMap[parent.reactTag] =
258
+ @([_exitingSubviewsCountMap[parent.reactTag] intValue] + exitingSubviewsCount);
253
259
  }
254
260
  parent = parent.superview;
255
261
  }
@@ -279,20 +285,22 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
279
285
  }
280
286
  }
281
287
 
282
- - (BOOL)removeRecursive:(UIView *)view fromContainer:(UIView *)container withoutAnimation:(BOOL)removeImmediately;
288
+ - (BOOL)startAnimationsRecursive:(UIView *)view
289
+ shouldRemoveSubviewsWithoutAnimations:(BOOL)shouldRemoveSubviewsWithoutAnimations;
283
290
  {
284
291
  if (!view.reactTag) {
285
292
  return NO;
286
293
  }
287
294
  BOOL hasExitAnimation = _hasAnimationForTag(view.reactTag, @"exiting") || [_exitingViews objectForKey:view.reactTag];
288
295
  BOOL hasAnimatedChildren = NO;
289
- removeImmediately = removeImmediately && !hasExitAnimation;
296
+ shouldRemoveSubviewsWithoutAnimations = shouldRemoveSubviewsWithoutAnimations && !hasExitAnimation;
290
297
  NSMutableArray *toBeRemoved = [[NSMutableArray alloc] init];
291
298
 
292
299
  for (UIView *subview in [view.reactSubviews copy]) {
293
- if ([self removeRecursive:subview fromContainer:view withoutAnimation:removeImmediately]) {
300
+ if ([self startAnimationsRecursive:subview
301
+ shouldRemoveSubviewsWithoutAnimations:shouldRemoveSubviewsWithoutAnimations]) {
294
302
  hasAnimatedChildren = YES;
295
- } else if (removeImmediately) {
303
+ } else if (shouldRemoveSubviewsWithoutAnimations) {
296
304
  [toBeRemoved addObject:subview];
297
305
  }
298
306
  }
@@ -307,14 +315,8 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
307
315
  if (hasExitAnimation) {
308
316
  before = [[REASnapshot alloc] init:view];
309
317
  }
310
- // start exit animation
311
- UIView *originalSuperview = view.superview;
312
- NSUInteger originalIndex = [originalSuperview.subviews indexOfObjectIdenticalTo:view];
313
- [container removeReactSubview:view];
314
- // we don't want user interaction on exiting views
315
- view.userInteractionEnabled = NO;
316
- [originalSuperview insertSubview:view atIndex:originalIndex];
317
318
 
319
+ // start exit animation
318
320
  if (hasExitAnimation && ![_exitingViews objectForKey:view.reactTag]) {
319
321
  NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:before.values frameConfig:ExitingFrame];
320
322
  [_exitingViews setObject:view forKey:view.reactTag];
@@ -335,14 +337,45 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
335
337
  // start new animations for it, and might as well remove
336
338
  // the layout animation config now
337
339
  _clearAnimationConfigForTag(view.reactTag);
340
+
341
+ // we don't want user interaction on exiting views
342
+ view.userInteractionEnabled = NO;
343
+
338
344
  return YES;
339
345
  }
340
346
 
341
- - (void)removeChildren:(NSArray<UIView *> *)children fromContainer:(UIView *)container
347
+ - (void)reattachAnimatedChildren:(NSArray<id<RCTComponent>> *)children
348
+ toContainer:(id<RCTComponent>)container
349
+ atIndices:(NSArray<NSNumber *> *)indices
342
350
  {
343
- for (UIView *removedChild in children) {
344
- if (![self removeRecursive:removedChild fromContainer:container withoutAnimation:true]) {
345
- [removedChild removeFromSuperview];
351
+ if (![container isKindOfClass:[UIView class]]) {
352
+ return;
353
+ }
354
+
355
+ // since we reattach only some of the views,
356
+ // we count the views we DIDN'T reattach
357
+ // and shift later views' indices by that number
358
+ // to make sure they appear at correct relative posisitons
359
+ // in the `subviews` array
360
+ int skippedViewsCount = 0;
361
+
362
+ for (int i = 0; i < children.count; i++) {
363
+ id<RCTComponent> child = children[i];
364
+ if (![child isKindOfClass:[UIView class]]) {
365
+ skippedViewsCount++;
366
+ continue;
367
+ }
368
+ UIView *childView = (UIView *)child;
369
+ NSNumber *originalIndex = indices[i];
370
+ if ([self startAnimationsRecursive:childView shouldRemoveSubviewsWithoutAnimations:YES]) {
371
+ [(UIView *)container insertSubview:childView atIndex:[originalIndex intValue] - skippedViewsCount];
372
+ int exitingSubviewsCount = [_exitingSubviewsCountMap[childView.reactTag] intValue];
373
+ if ([_exitingViews objectForKey:childView.reactTag] != nil) {
374
+ exitingSubviewsCount++;
375
+ }
376
+ [self registerExitingAncestors:childView exitingSubviewsCount:exitingSubviewsCount];
377
+ } else {
378
+ skippedViewsCount++;
346
379
  }
347
380
  }
348
381
  }
@@ -24,12 +24,6 @@
24
24
  removeAtIndices:(NSArray<NSNumber *> *)removeAtIndices
25
25
  registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)registry;
26
26
 
27
- - (void)_removeChildren:(NSArray<UIView *> *)children fromContainer:(UIView *)container;
28
-
29
- - (void)_removeChildren:(NSArray<UIView *> *)children
30
- fromContainer:(UIView *)container
31
- withAnimation:(RCTLayoutAnimationGroup *)animation;
32
-
33
27
  - (RCTViewManagerUIBlock)uiBlockWithLayoutUpdateForRootView:(RCTRootShadowView *)rootShadowView;
34
28
 
35
29
  - (NSArray<id<RCTComponent>> *)_childrenToRemoveFromContainer:(id<RCTComponent>)container
@@ -37,7 +31,6 @@
37
31
  @end
38
32
 
39
33
  @implementation REAUIManager {
40
- RCTLayoutAnimationGroup *_reactLayoutAnimationGroup;
41
34
  NSMutableDictionary<NSNumber *, NSMutableSet<id<RCTComponent>> *> *_toBeRemovedRegister;
42
35
  NSMutableDictionary<NSNumber *, NSNumber *> *_parentMapper;
43
36
  REAAnimationsManager *_animationsManager;
@@ -51,13 +44,6 @@
51
44
 
52
45
  - (void)setBridge:(RCTBridge *)bridge
53
46
  {
54
- // setting a layout animation group with a deleting animation in order to
55
- // allows us to call a different method in RCTUIManager for cleaning up exiting views
56
- RCTLayoutAnimation *deletingAnimation = [[RCTLayoutAnimation alloc] initWithDuration:0 config:@{}];
57
- _reactLayoutAnimationGroup = [[RCTLayoutAnimationGroup alloc] initWithCreatingLayoutAnimation:nil
58
- updatingLayoutAnimation:nil
59
- deletingLayoutAnimation:deletingAnimation
60
- callback:nil];
61
47
  if (!_blockSetter) {
62
48
  _blockSetter = true;
63
49
 
@@ -79,21 +65,6 @@
79
65
  }
80
66
  }
81
67
 
82
- - (void)_removeChildren:(NSArray<UIView *> *)children
83
- fromContainer:(UIView *)container
84
- withAnimation:(RCTLayoutAnimationGroup *)animation
85
- {
86
- if (animation == _reactLayoutAnimationGroup) {
87
- // if a removed view in this batch has an `exiting` animation,
88
- // let REAAnimationsManager handle the removal
89
- [_animationsManager removeChildren:children fromContainer:container];
90
- } else {
91
- // otherwise, if there's a layout animation group set,
92
- // delegate to the React Native implementation for layout animations
93
- [super _removeChildren:children fromContainer:container withAnimation:animation];
94
- }
95
- }
96
-
97
68
  - (void)_manageChildren:(NSNumber *)containerTag
98
69
  moveFromIndices:(NSArray<NSNumber *> *)moveFromIndices
99
70
  moveToIndices:(NSArray<NSNumber *> *)moveToIndices
@@ -102,41 +73,14 @@
102
73
  removeAtIndices:(NSArray<NSNumber *> *)removeAtIndices
103
74
  registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)registry
104
75
  {
105
- if (!reanimated::FeaturesConfig::isLayoutAnimationEnabled()) {
106
- [super _manageChildren:containerTag
107
- moveFromIndices:moveFromIndices
108
- moveToIndices:moveToIndices
109
- addChildReactTags:addChildReactTags
110
- addAtIndices:addAtIndices
111
- removeAtIndices:removeAtIndices
112
- registry:registry];
113
- return;
76
+ bool isLayoutAnimationEnabled = reanimated::FeaturesConfig::isLayoutAnimationEnabled();
77
+ id<RCTComponent> container;
78
+ NSArray<id<RCTComponent>> *permanentlyRemovedChildren;
79
+ if (isLayoutAnimationEnabled) {
80
+ container = registry[containerTag];
81
+ permanentlyRemovedChildren = [self _childrenToRemoveFromContainer:container atIndices:removeAtIndices];
114
82
  }
115
83
 
116
- // Reanimated changes /start
117
- BOOL isUIViewRegistry = ((id)registry == (id)[self valueForKey:@"_viewRegistry"]);
118
- if (isUIViewRegistry) {
119
- BOOL wasProxyRemovalSet = [self valueForKey:@"_layoutAnimationGroup"] == _reactLayoutAnimationGroup;
120
- BOOL wantProxyRemoval = NO;
121
- if (!wasProxyRemovalSet) {
122
- id<RCTComponent> container = registry[containerTag];
123
- NSArray<id<RCTComponent>> *permanentlyRemovedChildren = [self _childrenToRemoveFromContainer:container
124
- atIndices:removeAtIndices];
125
- for (UIView *removedChild in permanentlyRemovedChildren) {
126
- if ([_animationsManager wantsHandleRemovalOfView:removedChild]) {
127
- wantProxyRemoval = YES;
128
- break;
129
- }
130
- [_animationsManager removeAnimationsFromSubtree:removedChild];
131
- }
132
- if (wantProxyRemoval) {
133
- // set layout animation group
134
- [super setNextLayoutAnimationGroup:_reactLayoutAnimationGroup];
135
- }
136
- }
137
- }
138
- // Reanimated changes /end
139
-
140
84
  [super _manageChildren:containerTag
141
85
  moveFromIndices:moveFromIndices
142
86
  moveToIndices:moveToIndices
@@ -144,6 +88,22 @@
144
88
  addAtIndices:addAtIndices
145
89
  removeAtIndices:removeAtIndices
146
90
  registry:registry];
91
+
92
+ if (isLayoutAnimationEnabled) {
93
+ // we sort the (index, view) pairs to make sure we insert views back in order
94
+ NSMutableArray<NSArray<id> *> *removedViewsWithIndices = [NSMutableArray new];
95
+ for (int i = 0; i < removeAtIndices.count; i++) {
96
+ removedViewsWithIndices[i] = @[ removeAtIndices[i], permanentlyRemovedChildren[i] ];
97
+ }
98
+ [removedViewsWithIndices
99
+ sortUsingComparator:^NSComparisonResult(NSArray<id> *_Nonnull obj1, NSArray<id> *_Nonnull obj2) {
100
+ return [(NSNumber *)obj1[0] compare:(NSNumber *)obj2[0]];
101
+ }];
102
+
103
+ [_animationsManager reattachAnimatedChildren:permanentlyRemovedChildren
104
+ toContainer:container
105
+ atIndices:removeAtIndices];
106
+ }
147
107
  }
148
108
 
149
109
  - (void)callAnimationForTree:(UIView *)view parentTag:(NSNumber *)parentTag
@@ -59,8 +59,8 @@ class NativeReanimated {
59
59
  throw new Error('stub implementation, used on the web only');
60
60
  }
61
61
 
62
- installCoreFunctions(valueUnpacker) {
63
- return this.InnerNativeModule.installCoreFunctions(valueUnpacker);
62
+ installCoreFunctions(callGuard, valueUnpacker) {
63
+ return this.InnerNativeModule.installCoreFunctions(callGuard, valueUnpacker);
64
64
  }
65
65
 
66
66
  makeShareableClone(value) {
@@ -1 +1 @@
1
- {"version":3,"names":["NativeReanimated","constructor","native","global","__reanimatedModuleProxy","undefined","ReanimatedModule","NativeModules","installTurboModule","InnerNativeModule","checkVersion","cppVersion","_REANIMATED_VERSION_CPP","ok","jsVersion","match","jsMajor","jsMinor","split","cppMajor","cppMinor","console","error","getTimestamp","Error","installCoreFunctions","valueUnpacker","makeShareableClone","value","makeSynchronizedDataHolder","valueRef","getDataSynchronously","ref","updateDataSynchronously","scheduleOnUI","shareable","registerSensor","sensorType","interval","handler","unregisterSensor","sensorId","registerEventHandler","eventHash","eventHandler","unregisterEventHandler","id","getViewProp","viewTag","propName","callback","configureLayoutAnimation","type","config","enableLayoutAnimations","flag","configureProps","uiProps","nativeProps","subscribeForKeyboardEvents","unsubscribeFromKeyboardEvents","listenerId"],"sources":["NativeReanimated.ts"],"sourcesContent":["import { NativeModules } from 'react-native';\nimport { ShareableRef, ShareableSyncDataHolderRef } from '../commonTypes';\nimport { LayoutAnimationFunction } from '../layoutReanimation';\nimport { version as jsVersion } from '../../../package.json';\n\nexport class NativeReanimated {\n native: boolean;\n private InnerNativeModule: any;\n\n constructor(native = true) {\n if (global.__reanimatedModuleProxy === undefined && native) {\n const { ReanimatedModule } = NativeModules;\n ReanimatedModule?.installTurboModule();\n }\n this.InnerNativeModule = global.__reanimatedModuleProxy;\n this.native = native;\n if (native) {\n this.checkVersion();\n }\n }\n\n checkVersion(): void {\n const cppVersion = global._REANIMATED_VERSION_CPP;\n const ok = (() => {\n if (\n jsVersion.match(/^\\d+\\.\\d+\\.\\d+$/) &&\n cppVersion.match(/^\\d+\\.\\d+\\.\\d+$/)\n ) {\n // x.y.z, compare only major and minor, skip patch\n const [jsMajor, jsMinor] = jsVersion.split('.');\n const [cppMajor, cppMinor] = cppVersion.split('.');\n return jsMajor === cppMajor && jsMinor === cppMinor;\n } else {\n // alpha, beta or rc, compare everything\n return jsVersion === cppVersion;\n }\n })();\n if (!ok) {\n console.error(\n `[Reanimated] Mismatch between JavaScript part and native part of Reanimated (${jsVersion} vs. ${cppVersion}). Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must downgrade to ${cppVersion} which is bundled into Expo SDK.`\n );\n // TODO: detect Expo managed workflow\n }\n }\n\n getTimestamp(): number {\n throw new Error('stub implementation, used on the web only');\n }\n\n installCoreFunctions(valueUnpacker: <T>(value: T) => T): void {\n return this.InnerNativeModule.installCoreFunctions(valueUnpacker);\n }\n\n makeShareableClone<T>(value: T): ShareableRef<T> {\n return this.InnerNativeModule.makeShareableClone(value);\n }\n\n makeSynchronizedDataHolder<T>(\n valueRef: ShareableRef<T>\n ): ShareableSyncDataHolderRef<T> {\n return this.InnerNativeModule.makeSynchronizedDataHolder(valueRef);\n }\n\n getDataSynchronously<T>(ref: ShareableSyncDataHolderRef<T>): T {\n return this.InnerNativeModule.getDataSynchronously(ref);\n }\n\n updateDataSynchronously<T>(\n ref: ShareableSyncDataHolderRef<T>,\n value: T\n ): void {\n this.InnerNativeModule.updateDataSynchronously(ref, value);\n }\n\n scheduleOnUI<T>(shareable: ShareableRef<T>) {\n return this.InnerNativeModule.scheduleOnUI(shareable);\n }\n\n registerSensor<T>(\n sensorType: number,\n interval: number,\n handler: ShareableRef<T>\n ) {\n return this.InnerNativeModule.registerSensor(sensorType, interval, handler);\n }\n\n unregisterSensor(sensorId: number) {\n return this.InnerNativeModule.unregisterSensor(sensorId);\n }\n\n registerEventHandler<T>(\n eventHash: string,\n eventHandler: ShareableRef<T>\n ): string {\n return this.InnerNativeModule.registerEventHandler(eventHash, eventHandler);\n }\n\n unregisterEventHandler(id: string): void {\n return this.InnerNativeModule.unregisterEventHandler(id);\n }\n\n getViewProp<T>(\n viewTag: string,\n propName: string,\n callback?: (result: T) => void\n ): Promise<T> {\n return this.InnerNativeModule.getViewProp(viewTag, propName, callback);\n }\n\n configureLayoutAnimation(\n viewTag: number,\n type: string,\n config: ShareableRef<Keyframe | LayoutAnimationFunction>\n ) {\n this.InnerNativeModule.configureLayoutAnimation(viewTag, type, config);\n }\n\n enableLayoutAnimations(flag: boolean): void {\n this.InnerNativeModule.enableLayoutAnimations(flag);\n }\n\n configureProps(uiProps: string[], nativeProps: string[]): void {\n this.InnerNativeModule.configureProps(uiProps, nativeProps);\n }\n\n subscribeForKeyboardEvents(handler: ShareableRef<number>): number {\n return this.InnerNativeModule.subscribeForKeyboardEvents(handler);\n }\n\n unsubscribeFromKeyboardEvents(listenerId: number): void {\n this.InnerNativeModule.unsubscribeFromKeyboardEvents(listenerId);\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAGA;;;;AAEO,MAAMA,gBAAN,CAAuB;EAI5BC,WAAW,GAAgB;IAAA,IAAfC,MAAe,uEAAN,IAAM;;IAAA;;IAAA;;IACzB,IAAIC,MAAM,CAACC,uBAAP,KAAmCC,SAAnC,IAAgDH,MAApD,EAA4D;MAC1D,MAAM;QAAEI;MAAF,IAAuBC,0BAA7B;MACAD,gBAAgB,SAAhB,IAAAA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K9C,iBAAL,CAAuB6C,sBAAvB,CAA8CC,IAA9C;EACD;;EAEDC,cAAc,CAACC,OAAD,EAAoBC,WAApB,EAAiD;IAC7D,KAAKjD,iBAAL,CAAuB+C,cAAvB,CAAsCC,OAAtC,EAA+CC,WAA/C;EACD;;EAEDC,0BAA0B,CAACpB,OAAD,EAAwC;IAChE,OAAO,KAAK9B,iBAAL,CAAuBkD,0BAAvB,CAAkDpB,OAAlD,CAAP;EACD;;EAEDqB,6BAA6B,CAACC,UAAD,EAA2B;IACtD,KAAKpD,iBAAL,CAAuBmD,6BAAvB,CAAqDC,UAArD;EACD;;AA9H2B"}
1
+ {"version":3,"names":["NativeReanimated","constructor","native","global","__reanimatedModuleProxy","undefined","ReanimatedModule","NativeModules","installTurboModule","InnerNativeModule","checkVersion","cppVersion","_REANIMATED_VERSION_CPP","ok","jsVersion","match","jsMajor","jsMinor","split","cppMajor","cppMinor","console","error","getTimestamp","Error","installCoreFunctions","callGuard","valueUnpacker","makeShareableClone","value","makeSynchronizedDataHolder","valueRef","getDataSynchronously","ref","updateDataSynchronously","scheduleOnUI","shareable","registerSensor","sensorType","interval","handler","unregisterSensor","sensorId","registerEventHandler","eventHash","eventHandler","unregisterEventHandler","id","getViewProp","viewTag","propName","callback","configureLayoutAnimation","type","config","enableLayoutAnimations","flag","configureProps","uiProps","nativeProps","subscribeForKeyboardEvents","unsubscribeFromKeyboardEvents","listenerId"],"sources":["NativeReanimated.ts"],"sourcesContent":["import { NativeModules } from 'react-native';\nimport { ShareableRef, ShareableSyncDataHolderRef } from '../commonTypes';\nimport { LayoutAnimationFunction } from '../layoutReanimation';\nimport { version as jsVersion } from '../../../package.json';\n\nexport class NativeReanimated {\n native: boolean;\n private InnerNativeModule: any;\n\n constructor(native = true) {\n if (global.__reanimatedModuleProxy === undefined && native) {\n const { ReanimatedModule } = NativeModules;\n ReanimatedModule?.installTurboModule();\n }\n this.InnerNativeModule = global.__reanimatedModuleProxy;\n this.native = native;\n if (native) {\n this.checkVersion();\n }\n }\n\n checkVersion(): void {\n const cppVersion = global._REANIMATED_VERSION_CPP;\n const ok = (() => {\n if (\n jsVersion.match(/^\\d+\\.\\d+\\.\\d+$/) &&\n cppVersion.match(/^\\d+\\.\\d+\\.\\d+$/)\n ) {\n // x.y.z, compare only major and minor, skip patch\n const [jsMajor, jsMinor] = jsVersion.split('.');\n const [cppMajor, cppMinor] = cppVersion.split('.');\n return jsMajor === cppMajor && jsMinor === cppMinor;\n } else {\n // alpha, beta or rc, compare everything\n return jsVersion === cppVersion;\n }\n })();\n if (!ok) {\n console.error(\n `[Reanimated] Mismatch between JavaScript part and native part of Reanimated (${jsVersion} vs. ${cppVersion}). Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must downgrade to ${cppVersion} which is bundled into Expo SDK.`\n );\n // TODO: detect Expo managed workflow\n }\n }\n\n getTimestamp(): number {\n throw new Error('stub implementation, used on the web only');\n }\n\n installCoreFunctions(\n callGuard: <T extends Array<any>, U>(\n fn: (...args: T) => U,\n ...args: T\n ) => void,\n valueUnpacker: <T>(value: T) => T\n ): void {\n return this.InnerNativeModule.installCoreFunctions(\n callGuard,\n valueUnpacker\n );\n }\n\n makeShareableClone<T>(value: T): ShareableRef<T> {\n return this.InnerNativeModule.makeShareableClone(value);\n }\n\n makeSynchronizedDataHolder<T>(\n valueRef: ShareableRef<T>\n ): ShareableSyncDataHolderRef<T> {\n return this.InnerNativeModule.makeSynchronizedDataHolder(valueRef);\n }\n\n getDataSynchronously<T>(ref: ShareableSyncDataHolderRef<T>): T {\n return this.InnerNativeModule.getDataSynchronously(ref);\n }\n\n updateDataSynchronously<T>(\n ref: ShareableSyncDataHolderRef<T>,\n value: T\n ): void {\n this.InnerNativeModule.updateDataSynchronously(ref, value);\n }\n\n scheduleOnUI<T>(shareable: ShareableRef<T>) {\n return this.InnerNativeModule.scheduleOnUI(shareable);\n }\n\n registerSensor<T>(\n sensorType: number,\n interval: number,\n handler: ShareableRef<T>\n ) {\n return this.InnerNativeModule.registerSensor(sensorType, interval, handler);\n }\n\n unregisterSensor(sensorId: number) {\n return this.InnerNativeModule.unregisterSensor(sensorId);\n }\n\n registerEventHandler<T>(\n eventHash: string,\n eventHandler: ShareableRef<T>\n ): string {\n return this.InnerNativeModule.registerEventHandler(eventHash, eventHandler);\n }\n\n unregisterEventHandler(id: string): void {\n return this.InnerNativeModule.unregisterEventHandler(id);\n }\n\n getViewProp<T>(\n viewTag: string,\n propName: string,\n callback?: (result: T) => void\n ): Promise<T> {\n return this.InnerNativeModule.getViewProp(viewTag, propName, callback);\n }\n\n configureLayoutAnimation(\n viewTag: number,\n type: string,\n config: ShareableRef<Keyframe | LayoutAnimationFunction>\n ) {\n this.InnerNativeModule.configureLayoutAnimation(viewTag, type, config);\n }\n\n enableLayoutAnimations(flag: boolean): void {\n this.InnerNativeModule.enableLayoutAnimations(flag);\n }\n\n configureProps(uiProps: string[], nativeProps: string[]): void {\n this.InnerNativeModule.configureProps(uiProps, nativeProps);\n }\n\n subscribeForKeyboardEvents(handler: ShareableRef<number>): number {\n return this.InnerNativeModule.subscribeForKeyboardEvents(handler);\n }\n\n unsubscribeFromKeyboardEvents(listenerId: number): void {\n this.InnerNativeModule.unsubscribeFromKeyboardEvents(listenerId);\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAGA;;;;AAEO,MAAMA,gBAAN,CAAuB;EAI5BC,WAAW,GAAgB;IAAA,IAAfC,MAAe,uEAAN,IAAM;;IAAA;;IAAA;;IACzB,IAAIC,MAAM,CAACC,uBAAP,KAAmCC,SAAnC,IAAgDH,MAApD,EAA4D;MAC1D,MAAM;QAAEI;MAAF,IAAuBC,0BAA7B;MACAD,gBAAgB,SAAhB,IAAAA,gBAAgB,WAAhB,YAAAA,gBAAgB,CAAEE,kBAAlB;IACD;;IACD,KAAKC,iBAAL,GAAyBN,MAAM,CAACC,uBAAhC;IACA,KAAKF,MAAL,GAAcA,MAAd;;IACA,IAAIA,MAAJ,EAAY;MACV,KAAKQ,YA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