@react-native-ohos/react-native-reanimated 3.18.2-rc.2 → 3.18.2

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 (92) hide show
  1. package/LICENSE +21 -21
  2. package/README.OpenSource +10 -10
  3. package/README.md +10 -10
  4. package/harmony/reanimated/BuildProfile.ets +1 -1
  5. package/harmony/reanimated/build-profile.json5 +11 -11
  6. package/harmony/reanimated/oh-package.json5 +11 -11
  7. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +86 -86
  8. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +47 -47
  9. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.cpp +68 -68
  10. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.h +68 -68
  11. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +101 -101
  12. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +51 -51
  13. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitShadowNode.h +49 -49
  14. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +96 -96
  15. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +33 -33
  16. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +95 -95
  17. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +29 -29
  18. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationType.h +9 -9
  19. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +232 -232
  20. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +90 -90
  21. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp +870 -870
  22. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h +147 -147
  23. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.cpp +91 -91
  24. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +176 -176
  25. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +971 -971
  26. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +254 -252
  27. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +231 -231
  28. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +109 -109
  29. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +56 -56
  30. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h +20 -20
  31. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +70 -70
  32. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +35 -35
  33. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/CollectionUtils.h +14 -14
  34. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.cpp +5 -5
  35. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.h +19 -19
  36. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +98 -98
  37. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedSystraceSection.h +135 -135
  38. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +47 -47
  39. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +59 -59
  40. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp +27 -27
  41. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h +25 -25
  42. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +94 -94
  43. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.h +49 -49
  44. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +8 -8
  45. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +39 -39
  46. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.cpp +326 -326
  47. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.h +345 -345
  48. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.cpp +52 -52
  49. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.h +35 -35
  50. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/Defs.h +10 -10
  51. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.cpp +342 -342
  52. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.h +47 -47
  53. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.cpp +16 -16
  54. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.h +20 -20
  55. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.cpp +20 -20
  56. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.h +29 -29
  57. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/PlatformLogger.h +16 -16
  58. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.cpp +26 -26
  59. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.h +199 -199
  60. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.cpp +95 -95
  61. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.h +19 -19
  62. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/SingleInstanceChecker.h +72 -72
  63. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ThreadSafeQueue.h +49 -49
  64. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.cpp +20 -20
  65. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.h +22 -22
  66. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +29 -29
  67. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.h +41 -41
  68. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +16 -16
  69. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +19 -19
  70. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.cpp +112 -112
  71. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.h +127 -127
  72. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.cpp +53 -53
  73. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.h +22 -22
  74. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +191 -191
  75. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +173 -173
  76. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +90 -90
  77. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +36 -36
  78. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +189 -189
  79. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +22 -22
  80. package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +3 -0
  81. package/harmony/reanimated/src/main/cpp/WorkletsModule.cpp +60 -60
  82. package/harmony/reanimated/src/main/cpp/patches/AnimatedSensor/AnimatedSensorModule.cpp +89 -89
  83. package/harmony/reanimated/src/main/cpp/patches/NativeModules/ReanimatedModuleProxy.cpp +4 -0
  84. package/harmony/reanimated/src/main/module.json5 +12 -12
  85. package/harmony/reanimated/src/main/resources/base/element/color.json +7 -7
  86. package/harmony/reanimated/src/main/resources/base/element/string.json +15 -15
  87. package/harmony/reanimated/src/main/resources/base/profile/main_pages.json +5 -5
  88. package/harmony/reanimated/src/main/resources/en_US/element/string.json +15 -15
  89. package/harmony/reanimated/src/main/resources/zh_CN/element/string.json +15 -15
  90. package/harmony/reanimated/ts.ts +6 -6
  91. package/harmony/reanimated.har +0 -0
  92. package/package.json +50 -50
@@ -1,68 +1,68 @@
1
- #pragma once
2
- #ifdef RCT_NEW_ARCH_ENABLED
3
-
4
- #include <react/renderer/components/root/RootShadowNode.h>
5
- #include <react/renderer/core/ShadowNode.h>
6
-
7
- #include <unordered_map>
8
- #include <utility>
9
-
10
- using namespace facebook;
11
- using namespace react;
12
-
13
- namespace reanimated {
14
-
15
- class PropsRegistry {
16
- public:
17
- std::lock_guard<std::mutex> createLock() const;
18
- // returns a lock you need to hold when calling any of the methods below
19
-
20
- void update(const ShadowNode::Shared &shadowNode, folly::dynamic &&props);
21
-
22
- void for_each(std::function<void(
23
- const ShadowNodeFamily &family,
24
- const folly::dynamic &props)> callback) const;
25
-
26
- void remove(const Tag tag);
27
-
28
- void pauseReanimatedCommits() {
29
- isPaused_ = true;
30
- }
31
-
32
- bool shouldReanimatedSkipCommit() {
33
- return isPaused_;
34
- }
35
-
36
- void unpauseReanimatedCommits() {
37
- isPaused_ = false;
38
- }
39
-
40
- void pleaseCommitAfterPause() {
41
- shouldCommitAfterPause_ = true;
42
- }
43
-
44
- bool shouldCommitAfterPause() {
45
- return shouldCommitAfterPause_.exchange(false);
46
- }
47
-
48
- bool isEmpty() {
49
- return map_.empty();
50
- }
51
-
52
- void markNodeAsRemovable(const ShadowNode::Shared &shadowNode);
53
- void unmarkNodeAsRemovable(Tag viewTag);
54
- void handleNodeRemovals(const RootShadowNode &rootShadowNode);
55
-
56
- private:
57
- std::unordered_map<Tag, std::pair<ShadowNode::Shared, folly::dynamic>> map_;
58
- std::unordered_map<Tag, ShadowNode::Shared> removableShadowNodes_;
59
-
60
- mutable std::mutex mutex_; // Protects `map_`.
61
-
62
- std::atomic<bool> isPaused_;
63
- std::atomic<bool> shouldCommitAfterPause_;
64
- };
65
-
66
- } // namespace reanimated
67
-
68
- #endif // RCT_NEW_ARCH_ENABLED
1
+ #pragma once
2
+ #ifdef RCT_NEW_ARCH_ENABLED
3
+
4
+ #include <react/renderer/components/root/RootShadowNode.h>
5
+ #include <react/renderer/core/ShadowNode.h>
6
+
7
+ #include <unordered_map>
8
+ #include <utility>
9
+
10
+ using namespace facebook;
11
+ using namespace react;
12
+
13
+ namespace reanimated {
14
+
15
+ class PropsRegistry {
16
+ public:
17
+ std::lock_guard<std::mutex> createLock() const;
18
+ // returns a lock you need to hold when calling any of the methods below
19
+
20
+ void update(const ShadowNode::Shared &shadowNode, folly::dynamic &&props);
21
+
22
+ void for_each(std::function<void(
23
+ const ShadowNodeFamily &family,
24
+ const folly::dynamic &props)> callback) const;
25
+
26
+ void remove(const Tag tag);
27
+
28
+ void pauseReanimatedCommits() {
29
+ isPaused_ = true;
30
+ }
31
+
32
+ bool shouldReanimatedSkipCommit() {
33
+ return isPaused_;
34
+ }
35
+
36
+ void unpauseReanimatedCommits() {
37
+ isPaused_ = false;
38
+ }
39
+
40
+ void pleaseCommitAfterPause() {
41
+ shouldCommitAfterPause_ = true;
42
+ }
43
+
44
+ bool shouldCommitAfterPause() {
45
+ return shouldCommitAfterPause_.exchange(false);
46
+ }
47
+
48
+ bool isEmpty() {
49
+ return map_.empty();
50
+ }
51
+
52
+ void markNodeAsRemovable(const ShadowNode::Shared &shadowNode);
53
+ void unmarkNodeAsRemovable(Tag viewTag);
54
+ void handleNodeRemovals(const RootShadowNode &rootShadowNode);
55
+
56
+ private:
57
+ std::unordered_map<Tag, std::pair<ShadowNode::Shared, folly::dynamic>> map_;
58
+ std::unordered_map<Tag, ShadowNode::Shared> removableShadowNodes_;
59
+
60
+ mutable std::mutex mutex_; // Protects `map_`.
61
+
62
+ std::atomic<bool> isPaused_;
63
+ std::atomic<bool> shouldCommitAfterPause_;
64
+ };
65
+
66
+ } // namespace reanimated
67
+
68
+ #endif // RCT_NEW_ARCH_ENABLED
@@ -1,101 +1,101 @@
1
- #ifdef RCT_NEW_ARCH_ENABLED
2
-
3
- #include <reanimated/Fabric/ReanimatedCommitHook.h>
4
- #include <reanimated/Fabric/ReanimatedCommitShadowNode.h>
5
- #include <reanimated/Fabric/ShadowTreeCloner.h>
6
-
7
- #include <react/renderer/core/ComponentDescriptor.h>
8
-
9
- #include <unordered_map>
10
- #include <vector>
11
-
12
- using namespace facebook::react;
13
-
14
- namespace reanimated {
15
-
16
- ReanimatedCommitHook::ReanimatedCommitHook(
17
- const std::shared_ptr<PropsRegistry> &propsRegistry,
18
- const std::shared_ptr<UIManager> &uiManager,
19
- const std::shared_ptr<LayoutAnimationsProxy> &layoutAnimationsProxy)
20
- : propsRegistry_(propsRegistry),
21
- uiManager_(uiManager),
22
- layoutAnimationsProxy_(layoutAnimationsProxy) {
23
- uiManager_->registerCommitHook(*this);
24
- }
25
-
26
- ReanimatedCommitHook::~ReanimatedCommitHook() noexcept {
27
- uiManager_->unregisterCommitHook(*this);
28
- }
29
-
30
- void ReanimatedCommitHook::maybeInitializeLayoutAnimations(
31
- SurfaceId surfaceId) {
32
- auto lock = std::unique_lock<std::mutex>(mutex_);
33
- if (surfaceId > currentMaxSurfaceId_) {
34
- // when a new surfaceId is observed we call setMountingOverrideDelegate
35
- // for all yet unseen surfaces
36
- uiManager_->getShadowTreeRegistry().enumerate(
37
- [strongThis = shared_from_this()](
38
- const ShadowTree &shadowTree, bool &stop) {
39
- // Executed synchronously.
40
- if (shadowTree.getSurfaceId() <= strongThis->currentMaxSurfaceId_) {
41
- // the set function actually adds our delegate to a list, so we
42
- // shouldn't invoke it twice for the same surface
43
- return;
44
- }
45
- shadowTree.getMountingCoordinator()->setMountingOverrideDelegate(
46
- strongThis->layoutAnimationsProxy_);
47
- });
48
- currentMaxSurfaceId_ = surfaceId;
49
- }
50
- }
51
-
52
- RootShadowNode::Unshared ReanimatedCommitHook::shadowTreeWillCommit(
53
- ShadowTree const &,
54
- RootShadowNode::Shared const &,
55
- RootShadowNode::Unshared const &newRootShadowNode) noexcept {
56
- maybeInitializeLayoutAnimations(newRootShadowNode->getSurfaceId());
57
-
58
- auto reaShadowNode =
59
- std::reinterpret_pointer_cast<ReanimatedCommitShadowNode>(
60
- newRootShadowNode);
61
-
62
- if (reaShadowNode->hasReanimatedCommitTrait()) {
63
- // ShadowTree commited by Reanimated, no need to apply updates from
64
- // PropsRegistry
65
- reaShadowNode->unsetReanimatedCommitTrait();
66
- reaShadowNode->setReanimatedMountTrait();
67
- return newRootShadowNode;
68
- }
69
-
70
- // ShadowTree not commited by Reanimated, apply updates from PropsRegistry
71
- reaShadowNode->unsetReanimatedMountTrait();
72
- RootShadowNode::Unshared rootNode = newRootShadowNode;
73
- PropsMap propsMap;
74
-
75
- {
76
- auto lock = propsRegistry_->createLock();
77
-
78
- propsRegistry_->for_each(
79
- [&](const ShadowNodeFamily &family, const folly::dynamic &props) {
80
- propsMap[&family].emplace_back(props);
81
- });
82
-
83
- rootNode = cloneShadowTreeWithNewProps(*rootNode, propsMap);
84
-
85
- // If the commit comes from React Native then pause commits from
86
- // Reanimated since the ShadowTree to be committed by Reanimated may not
87
- // include the new changes from React Native yet and all changes of animated
88
- // props will be applied in ReanimatedCommitHook by iterating over
89
- // PropsRegistry.
90
- // This is very important, since if we didn't pause Reanimated commits,
91
- // it could lead to RN commits being delayed until the animation is finished
92
- // (very bad).
93
- propsRegistry_->pauseReanimatedCommits();
94
- }
95
-
96
- return rootNode;
97
- }
98
-
99
- } // namespace reanimated
100
-
101
- #endif // RCT_NEW_ARCH_ENABLED
1
+ #ifdef RCT_NEW_ARCH_ENABLED
2
+
3
+ #include <reanimated/Fabric/ReanimatedCommitHook.h>
4
+ #include <reanimated/Fabric/ReanimatedCommitShadowNode.h>
5
+ #include <reanimated/Fabric/ShadowTreeCloner.h>
6
+
7
+ #include <react/renderer/core/ComponentDescriptor.h>
8
+
9
+ #include <unordered_map>
10
+ #include <vector>
11
+
12
+ using namespace facebook::react;
13
+
14
+ namespace reanimated {
15
+
16
+ ReanimatedCommitHook::ReanimatedCommitHook(
17
+ const std::shared_ptr<PropsRegistry> &propsRegistry,
18
+ const std::shared_ptr<UIManager> &uiManager,
19
+ const std::shared_ptr<LayoutAnimationsProxy> &layoutAnimationsProxy)
20
+ : propsRegistry_(propsRegistry),
21
+ uiManager_(uiManager),
22
+ layoutAnimationsProxy_(layoutAnimationsProxy) {
23
+ uiManager_->registerCommitHook(*this);
24
+ }
25
+
26
+ ReanimatedCommitHook::~ReanimatedCommitHook() noexcept {
27
+ uiManager_->unregisterCommitHook(*this);
28
+ }
29
+
30
+ void ReanimatedCommitHook::maybeInitializeLayoutAnimations(
31
+ SurfaceId surfaceId) {
32
+ auto lock = std::unique_lock<std::mutex>(mutex_);
33
+ if (surfaceId > currentMaxSurfaceId_) {
34
+ // when a new surfaceId is observed we call setMountingOverrideDelegate
35
+ // for all yet unseen surfaces
36
+ uiManager_->getShadowTreeRegistry().enumerate(
37
+ [strongThis = shared_from_this()](
38
+ const ShadowTree &shadowTree, bool &stop) {
39
+ // Executed synchronously.
40
+ if (shadowTree.getSurfaceId() <= strongThis->currentMaxSurfaceId_) {
41
+ // the set function actually adds our delegate to a list, so we
42
+ // shouldn't invoke it twice for the same surface
43
+ return;
44
+ }
45
+ shadowTree.getMountingCoordinator()->setMountingOverrideDelegate(
46
+ strongThis->layoutAnimationsProxy_);
47
+ });
48
+ currentMaxSurfaceId_ = surfaceId;
49
+ }
50
+ }
51
+
52
+ RootShadowNode::Unshared ReanimatedCommitHook::shadowTreeWillCommit(
53
+ ShadowTree const &,
54
+ RootShadowNode::Shared const &,
55
+ RootShadowNode::Unshared const &newRootShadowNode) noexcept {
56
+ maybeInitializeLayoutAnimations(newRootShadowNode->getSurfaceId());
57
+
58
+ auto reaShadowNode =
59
+ std::reinterpret_pointer_cast<ReanimatedCommitShadowNode>(
60
+ newRootShadowNode);
61
+
62
+ if (reaShadowNode->hasReanimatedCommitTrait()) {
63
+ // ShadowTree commited by Reanimated, no need to apply updates from
64
+ // PropsRegistry
65
+ reaShadowNode->unsetReanimatedCommitTrait();
66
+ reaShadowNode->setReanimatedMountTrait();
67
+ return newRootShadowNode;
68
+ }
69
+
70
+ // ShadowTree not commited by Reanimated, apply updates from PropsRegistry
71
+ reaShadowNode->unsetReanimatedMountTrait();
72
+ RootShadowNode::Unshared rootNode = newRootShadowNode;
73
+ PropsMap propsMap;
74
+
75
+ {
76
+ auto lock = propsRegistry_->createLock();
77
+
78
+ propsRegistry_->for_each(
79
+ [&](const ShadowNodeFamily &family, const folly::dynamic &props) {
80
+ propsMap[&family].emplace_back(props);
81
+ });
82
+
83
+ rootNode = cloneShadowTreeWithNewProps(*rootNode, propsMap);
84
+
85
+ // If the commit comes from React Native then pause commits from
86
+ // Reanimated since the ShadowTree to be committed by Reanimated may not
87
+ // include the new changes from React Native yet and all changes of animated
88
+ // props will be applied in ReanimatedCommitHook by iterating over
89
+ // PropsRegistry.
90
+ // This is very important, since if we didn't pause Reanimated commits,
91
+ // it could lead to RN commits being delayed until the animation is finished
92
+ // (very bad).
93
+ propsRegistry_->pauseReanimatedCommits();
94
+ }
95
+
96
+ return rootNode;
97
+ }
98
+
99
+ } // namespace reanimated
100
+
101
+ #endif // RCT_NEW_ARCH_ENABLED
@@ -1,51 +1,51 @@
1
- #pragma once
2
- #ifdef RCT_NEW_ARCH_ENABLED
3
-
4
- #include <reanimated/Fabric/PropsRegistry.h>
5
- #include <reanimated/LayoutAnimations/LayoutAnimationsProxy.h>
6
-
7
- #include <react/renderer/uimanager/UIManagerCommitHook.h>
8
-
9
- #include <memory>
10
-
11
- using namespace facebook::react;
12
-
13
- namespace reanimated {
14
-
15
- class ReanimatedCommitHook
16
- : public UIManagerCommitHook,
17
- public std::enable_shared_from_this<ReanimatedCommitHook> {
18
- public:
19
- ReanimatedCommitHook(
20
- const std::shared_ptr<PropsRegistry> &propsRegistry,
21
- const std::shared_ptr<UIManager> &uiManager,
22
- const std::shared_ptr<LayoutAnimationsProxy> &layoutAnimationsProxy);
23
-
24
- ~ReanimatedCommitHook() noexcept override;
25
-
26
- void commitHookWasRegistered(UIManager const &) noexcept override {}
27
-
28
- void commitHookWasUnregistered(UIManager const &) noexcept override {}
29
-
30
- void maybeInitializeLayoutAnimations(SurfaceId surfaceId);
31
-
32
- RootShadowNode::Unshared shadowTreeWillCommit(
33
- ShadowTree const &shadowTree,
34
- RootShadowNode::Shared const &oldRootShadowNode,
35
- RootShadowNode::Unshared const &newRootShadowNode) noexcept override;
36
-
37
- private:
38
- std::shared_ptr<PropsRegistry> propsRegistry_;
39
-
40
- std::shared_ptr<UIManager> uiManager_;
41
-
42
- std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy_;
43
-
44
- SurfaceId currentMaxSurfaceId_ = -1;
45
-
46
- std::mutex mutex_; // Protects `currentMaxSurfaceId_`.
47
- };
48
-
49
- } // namespace reanimated
50
-
51
- #endif // RCT_NEW_ARCH_ENABLED
1
+ #pragma once
2
+ #ifdef RCT_NEW_ARCH_ENABLED
3
+
4
+ #include <reanimated/Fabric/PropsRegistry.h>
5
+ #include <reanimated/LayoutAnimations/LayoutAnimationsProxy.h>
6
+
7
+ #include <react/renderer/uimanager/UIManagerCommitHook.h>
8
+
9
+ #include <memory>
10
+
11
+ using namespace facebook::react;
12
+
13
+ namespace reanimated {
14
+
15
+ class ReanimatedCommitHook
16
+ : public UIManagerCommitHook,
17
+ public std::enable_shared_from_this<ReanimatedCommitHook> {
18
+ public:
19
+ ReanimatedCommitHook(
20
+ const std::shared_ptr<PropsRegistry> &propsRegistry,
21
+ const std::shared_ptr<UIManager> &uiManager,
22
+ const std::shared_ptr<LayoutAnimationsProxy> &layoutAnimationsProxy);
23
+
24
+ ~ReanimatedCommitHook() noexcept override;
25
+
26
+ void commitHookWasRegistered(UIManager const &) noexcept override {}
27
+
28
+ void commitHookWasUnregistered(UIManager const &) noexcept override {}
29
+
30
+ void maybeInitializeLayoutAnimations(SurfaceId surfaceId);
31
+
32
+ RootShadowNode::Unshared shadowTreeWillCommit(
33
+ ShadowTree const &shadowTree,
34
+ RootShadowNode::Shared const &oldRootShadowNode,
35
+ RootShadowNode::Unshared const &newRootShadowNode) noexcept override;
36
+
37
+ private:
38
+ std::shared_ptr<PropsRegistry> propsRegistry_;
39
+
40
+ std::shared_ptr<UIManager> uiManager_;
41
+
42
+ std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy_;
43
+
44
+ SurfaceId currentMaxSurfaceId_ = -1;
45
+
46
+ std::mutex mutex_; // Protects `currentMaxSurfaceId_`.
47
+ };
48
+
49
+ } // namespace reanimated
50
+
51
+ #endif // RCT_NEW_ARCH_ENABLED
@@ -1,49 +1,49 @@
1
- #pragma once
2
- #ifdef RCT_NEW_ARCH_ENABLED
3
-
4
- #include <react/renderer/core/ShadowNode.h>
5
-
6
- using namespace facebook::react;
7
-
8
- namespace reanimated {
9
-
10
- // We use this trait to mark that a commit was created by Reanimated.
11
- // Traits are copied when nodes are cloned, so this information
12
- // won't be lost unless someone explicitly overrides it.
13
- // We need this information to skip unnecessary updates in
14
- // the commit hook.
15
- // Currently RN traits go up to 10, so hopefully
16
- // the arbitrarily chosen numbers 27 and 28 will be safe :)
17
-
18
- // We have to use 2 traits, because we want to distinguish reanimated
19
- // commits both in the commit hook and mount hook. If we only had one trait
20
- // and didn't remove it in the commit hook, then any node that would clone
21
- // this node would also have our commit trait, rendering this trait useless.
22
- constexpr ShadowNodeTraits::Trait ReanimatedCommitTrait{1 << 27};
23
- constexpr ShadowNodeTraits::Trait ReanimatedMountTrait{1 << 28};
24
-
25
- class ReanimatedCommitShadowNode : public ShadowNode {
26
- public:
27
- inline void setReanimatedCommitTrait() {
28
- traits_.set(ReanimatedCommitTrait);
29
- }
30
- inline void unsetReanimatedCommitTrait() {
31
- traits_.unset(ReanimatedCommitTrait);
32
- }
33
- inline bool hasReanimatedCommitTrait() {
34
- return traits_.check(ReanimatedCommitTrait);
35
- }
36
- inline void setReanimatedMountTrait() {
37
- traits_.set(ReanimatedMountTrait);
38
- }
39
- inline void unsetReanimatedMountTrait() {
40
- traits_.unset(ReanimatedMountTrait);
41
- }
42
- inline bool hasReanimatedMountTrait() {
43
- return traits_.check(ReanimatedMountTrait);
44
- }
45
- };
46
-
47
- } // namespace reanimated
48
-
49
- #endif // RCT_NEW_ARCH_ENABLED
1
+ #pragma once
2
+ #ifdef RCT_NEW_ARCH_ENABLED
3
+
4
+ #include <react/renderer/core/ShadowNode.h>
5
+
6
+ using namespace facebook::react;
7
+
8
+ namespace reanimated {
9
+
10
+ // We use this trait to mark that a commit was created by Reanimated.
11
+ // Traits are copied when nodes are cloned, so this information
12
+ // won't be lost unless someone explicitly overrides it.
13
+ // We need this information to skip unnecessary updates in
14
+ // the commit hook.
15
+ // Currently RN traits go up to 10, so hopefully
16
+ // the arbitrarily chosen numbers 27 and 28 will be safe :)
17
+
18
+ // We have to use 2 traits, because we want to distinguish reanimated
19
+ // commits both in the commit hook and mount hook. If we only had one trait
20
+ // and didn't remove it in the commit hook, then any node that would clone
21
+ // this node would also have our commit trait, rendering this trait useless.
22
+ constexpr ShadowNodeTraits::Trait ReanimatedCommitTrait{1 << 27};
23
+ constexpr ShadowNodeTraits::Trait ReanimatedMountTrait{1 << 28};
24
+
25
+ class ReanimatedCommitShadowNode : public ShadowNode {
26
+ public:
27
+ inline void setReanimatedCommitTrait() {
28
+ traits_.set(ReanimatedCommitTrait);
29
+ }
30
+ inline void unsetReanimatedCommitTrait() {
31
+ traits_.unset(ReanimatedCommitTrait);
32
+ }
33
+ inline bool hasReanimatedCommitTrait() {
34
+ return traits_.check(ReanimatedCommitTrait);
35
+ }
36
+ inline void setReanimatedMountTrait() {
37
+ traits_.set(ReanimatedMountTrait);
38
+ }
39
+ inline void unsetReanimatedMountTrait() {
40
+ traits_.unset(ReanimatedMountTrait);
41
+ }
42
+ inline bool hasReanimatedMountTrait() {
43
+ return traits_.check(ReanimatedMountTrait);
44
+ }
45
+ };
46
+
47
+ } // namespace reanimated
48
+
49
+ #endif // RCT_NEW_ARCH_ENABLED