@react-native-ohos/react-native-reanimated 3.18.2 → 3.18.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 (99) hide show
  1. package/LICENSE +21 -21
  2. package/README.OpenSource +10 -10
  3. package/README.md +406 -10
  4. package/harmony/reanimated/BuildProfile.ets +1 -1
  5. package/harmony/reanimated/build-profile.json5 +11 -11
  6. package/harmony/reanimated/oh-package-lock.json5 +29 -0
  7. package/harmony/reanimated/oh-package.json5 +11 -11
  8. package/harmony/reanimated/src/main/cpp/CMakeLists.txt +2 -0
  9. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +86 -86
  10. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +47 -47
  11. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.cpp +68 -68
  12. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.h +73 -68
  13. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +101 -101
  14. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +51 -51
  15. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitShadowNode.h +49 -49
  16. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +96 -96
  17. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +33 -33
  18. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +95 -95
  19. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +29 -29
  20. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationType.h +9 -9
  21. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +232 -232
  22. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +90 -90
  23. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp +870 -870
  24. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h +147 -147
  25. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.cpp +91 -91
  26. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +176 -176
  27. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +971 -971
  28. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +252 -254
  29. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +231 -231
  30. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +109 -109
  31. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +56 -56
  32. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h +20 -20
  33. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +70 -70
  34. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +35 -35
  35. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/CollectionUtils.h +14 -14
  36. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.cpp +5 -5
  37. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.h +19 -19
  38. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +98 -98
  39. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedSystraceSection.h +135 -135
  40. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +47 -47
  41. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +59 -59
  42. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp +27 -27
  43. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h +25 -25
  44. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +94 -94
  45. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.h +49 -49
  46. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +8 -8
  47. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +39 -39
  48. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.cpp +326 -326
  49. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.h +345 -345
  50. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.cpp +52 -52
  51. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.h +35 -35
  52. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/Defs.h +10 -10
  53. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.cpp +342 -342
  54. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.h +47 -47
  55. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.cpp +16 -16
  56. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.h +20 -20
  57. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.cpp +20 -20
  58. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.h +29 -29
  59. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/PlatformLogger.h +16 -16
  60. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.cpp +26 -26
  61. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.h +199 -199
  62. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.cpp +95 -95
  63. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.h +19 -19
  64. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/SingleInstanceChecker.h +72 -72
  65. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ThreadSafeQueue.h +49 -49
  66. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.cpp +20 -20
  67. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.h +22 -22
  68. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +29 -29
  69. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.h +41 -41
  70. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +16 -16
  71. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +19 -19
  72. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.cpp +112 -112
  73. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.h +127 -127
  74. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.cpp +53 -53
  75. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.h +22 -22
  76. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +191 -191
  77. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +173 -173
  78. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +90 -90
  79. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +36 -36
  80. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +189 -189
  81. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +22 -22
  82. package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +29 -19
  83. package/harmony/reanimated/src/main/cpp/ReanimatedSensor.cpp +248 -0
  84. package/harmony/reanimated/src/main/cpp/ReanimatedSensor.h +36 -0
  85. package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.cpp +36 -0
  86. package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.h +23 -0
  87. package/harmony/reanimated/src/main/cpp/WorkletsModule.cpp +60 -60
  88. package/harmony/reanimated/src/main/cpp/patches/AnimatedSensor/AnimatedSensorModule.cpp +89 -89
  89. package/harmony/reanimated/src/main/cpp/patches/NativeModules/ReanimatedModuleProxy.cpp +53 -4
  90. package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +115 -15
  91. package/harmony/reanimated/src/main/module.json5 +12 -12
  92. package/harmony/reanimated/src/main/resources/base/element/color.json +7 -7
  93. package/harmony/reanimated/src/main/resources/base/element/string.json +15 -15
  94. package/harmony/reanimated/src/main/resources/base/profile/main_pages.json +5 -5
  95. package/harmony/reanimated/src/main/resources/en_US/element/string.json +15 -15
  96. package/harmony/reanimated/src/main/resources/zh_CN/element/string.json +15 -15
  97. package/harmony/reanimated/ts.ts +6 -6
  98. package/harmony/reanimated.har +0 -0
  99. package/package.json +51 -50
@@ -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
@@ -1,96 +1,96 @@
1
- #ifdef RCT_NEW_ARCH_ENABLED
2
-
3
- #include <glog/logging.h>
4
- #include <reanimated/Fabric/ReanimatedCommitShadowNode.h>
5
- #include <reanimated/Fabric/ReanimatedMountHook.h>
6
-
7
- namespace reanimated {
8
-
9
- ReanimatedMountHook::ReanimatedMountHook(
10
- const std::shared_ptr<PropsRegistry> &propsRegistry,
11
- const std::shared_ptr<UIManager> &uiManager)
12
- : propsRegistry_(propsRegistry), uiManager_(uiManager) {
13
- uiManager_->registerMountHook(*this);
14
- }
15
-
16
- ReanimatedMountHook::~ReanimatedMountHook() noexcept {
17
- uiManager_->unregisterMountHook(*this);
18
- }
19
-
20
- void ReanimatedMountHook::shadowTreeDidMount(
21
- const RootShadowNode::Shared &rootShadowNode,
22
- double) noexcept {
23
- auto reaShadowNode =
24
- std::reinterpret_pointer_cast<ReanimatedCommitShadowNode>(
25
- std::const_pointer_cast<RootShadowNode>(rootShadowNode));
26
-
27
- if (reaShadowNode->hasReanimatedMountTrait()) {
28
- // We mark reanimated commits with ReanimatedMountTrait. We don't want other
29
- // shadow nodes to use this trait, but since this rootShadowNode is Shared,
30
- // we don't have that guarantee. That's why we also unset this trait in the
31
- // commit hook. We remove it here mainly for the sake of cleanliness.
32
- reaShadowNode->unsetReanimatedMountTrait();
33
- return;
34
- }
35
-
36
- {
37
- auto lock = propsRegistry_->createLock();
38
- propsRegistry_->handleNodeRemovals(*rootShadowNode);
39
-
40
- // When commit from React Native has finished, we reset the skip commit flag
41
- // in order to allow Reanimated to commit its tree
42
- propsRegistry_->unpauseReanimatedCommits();
43
- if (!propsRegistry_->shouldCommitAfterPause()) {
44
- return;
45
- }
46
- }
47
-
48
- try {
49
- const auto &shadowTreeRegistry = uiManager_->getShadowTreeRegistry();
50
- shadowTreeRegistry.visit(
51
- rootShadowNode->getSurfaceId(), [=](ShadowTree const &shadowTree) {
52
- shadowTree.commit(
53
- [=](RootShadowNode const &oldRootShadowNode)
54
- -> RootShadowNode::Unshared {
55
- PropsMap propsMap;
56
-
57
- RootShadowNode::Unshared rootNode =
58
- std::static_pointer_cast<RootShadowNode>(
59
- oldRootShadowNode.ShadowNode::clone({}));
60
-
61
- if (rootNode) {
62
- auto lock = propsRegistry_->createLock();
63
-
64
- if (!propsRegistry_->isEmpty()) {
65
- propsRegistry_->for_each([&](const ShadowNodeFamily &family,
66
- const folly::dynamic &props) {
67
- propsMap[&family].emplace_back(props);
68
- });
69
-
70
- rootNode = cloneShadowTreeWithNewProps(oldRootShadowNode, propsMap);
71
- }
72
- }
73
-
74
- if (rootNode) {
75
- auto reaShadowNode =
76
- std::reinterpret_pointer_cast<ReanimatedCommitShadowNode>(
77
- rootNode);
78
- reaShadowNode->setReanimatedCommitTrait();
79
- }
80
-
81
- return rootNode;
82
- },
83
- {/* .enableStateReconciliation = */
84
- false,
85
- /* .mountSynchronously = */ true});
86
- });
87
- } catch (const std::exception &e) {
88
- LOG(ERROR) << "ReanimatedMountHook::shadowTreeDidMount error: " << e.what();
89
- } catch (...) {
90
- LOG(ERROR) << "ReanimatedMountHook::shadowTreeDidMount unknown error";
91
- }
92
- }
93
-
94
- } // namespace reanimated
95
-
96
- #endif // RCT_NEW_ARCH_ENABLED
1
+ #ifdef RCT_NEW_ARCH_ENABLED
2
+
3
+ #include <glog/logging.h>
4
+ #include <reanimated/Fabric/ReanimatedCommitShadowNode.h>
5
+ #include <reanimated/Fabric/ReanimatedMountHook.h>
6
+
7
+ namespace reanimated {
8
+
9
+ ReanimatedMountHook::ReanimatedMountHook(
10
+ const std::shared_ptr<PropsRegistry> &propsRegistry,
11
+ const std::shared_ptr<UIManager> &uiManager)
12
+ : propsRegistry_(propsRegistry), uiManager_(uiManager) {
13
+ uiManager_->registerMountHook(*this);
14
+ }
15
+
16
+ ReanimatedMountHook::~ReanimatedMountHook() noexcept {
17
+ uiManager_->unregisterMountHook(*this);
18
+ }
19
+
20
+ void ReanimatedMountHook::shadowTreeDidMount(
21
+ const RootShadowNode::Shared &rootShadowNode,
22
+ double) noexcept {
23
+ auto reaShadowNode =
24
+ std::reinterpret_pointer_cast<ReanimatedCommitShadowNode>(
25
+ std::const_pointer_cast<RootShadowNode>(rootShadowNode));
26
+
27
+ if (reaShadowNode->hasReanimatedMountTrait()) {
28
+ // We mark reanimated commits with ReanimatedMountTrait. We don't want other
29
+ // shadow nodes to use this trait, but since this rootShadowNode is Shared,
30
+ // we don't have that guarantee. That's why we also unset this trait in the
31
+ // commit hook. We remove it here mainly for the sake of cleanliness.
32
+ reaShadowNode->unsetReanimatedMountTrait();
33
+ return;
34
+ }
35
+
36
+ {
37
+ auto lock = propsRegistry_->createLock();
38
+ propsRegistry_->handleNodeRemovals(*rootShadowNode);
39
+
40
+ // When commit from React Native has finished, we reset the skip commit flag
41
+ // in order to allow Reanimated to commit its tree
42
+ propsRegistry_->unpauseReanimatedCommits();
43
+ if (!propsRegistry_->shouldCommitAfterPause()) {
44
+ return;
45
+ }
46
+ }
47
+
48
+ try {
49
+ const auto &shadowTreeRegistry = uiManager_->getShadowTreeRegistry();
50
+ shadowTreeRegistry.visit(
51
+ rootShadowNode->getSurfaceId(), [=](ShadowTree const &shadowTree) {
52
+ shadowTree.commit(
53
+ [=](RootShadowNode const &oldRootShadowNode)
54
+ -> RootShadowNode::Unshared {
55
+ PropsMap propsMap;
56
+
57
+ RootShadowNode::Unshared rootNode =
58
+ std::static_pointer_cast<RootShadowNode>(
59
+ oldRootShadowNode.ShadowNode::clone({}));
60
+
61
+ if (rootNode) {
62
+ auto lock = propsRegistry_->createLock();
63
+
64
+ if (!propsRegistry_->isEmpty()) {
65
+ propsRegistry_->for_each([&](const ShadowNodeFamily &family,
66
+ const folly::dynamic &props) {
67
+ propsMap[&family].emplace_back(props);
68
+ });
69
+
70
+ rootNode = cloneShadowTreeWithNewProps(oldRootShadowNode, propsMap);
71
+ }
72
+ }
73
+
74
+ if (rootNode) {
75
+ auto reaShadowNode =
76
+ std::reinterpret_pointer_cast<ReanimatedCommitShadowNode>(
77
+ rootNode);
78
+ reaShadowNode->setReanimatedCommitTrait();
79
+ }
80
+
81
+ return rootNode;
82
+ },
83
+ {/* .enableStateReconciliation = */
84
+ false,
85
+ /* .mountSynchronously = */ true});
86
+ });
87
+ } catch (const std::exception &e) {
88
+ LOG(ERROR) << "ReanimatedMountHook::shadowTreeDidMount error: " << e.what();
89
+ } catch (...) {
90
+ LOG(ERROR) << "ReanimatedMountHook::shadowTreeDidMount unknown error";
91
+ }
92
+ }
93
+
94
+ } // namespace reanimated
95
+
96
+ #endif // RCT_NEW_ARCH_ENABLED
@@ -1,33 +1,33 @@
1
- #pragma once
2
- #ifdef RCT_NEW_ARCH_ENABLED
3
-
4
- #include <reanimated/Fabric/PropsRegistry.h>
5
- #include <reanimated/Fabric/ShadowTreeCloner.h>
6
-
7
- #include <react/renderer/uimanager/UIManagerMountHook.h>
8
-
9
- #include <memory>
10
-
11
- namespace reanimated {
12
-
13
- using namespace facebook::react;
14
-
15
- class ReanimatedMountHook : public UIManagerMountHook {
16
- public:
17
- ReanimatedMountHook(
18
- const std::shared_ptr<PropsRegistry> &propsRegistry,
19
- const std::shared_ptr<UIManager> &uiManager);
20
- ~ReanimatedMountHook() noexcept override;
21
-
22
- void shadowTreeDidMount(
23
- RootShadowNode::Shared const &rootShadowNode,
24
- double mountTime) noexcept override;
25
-
26
- private:
27
- const std::shared_ptr<PropsRegistry> propsRegistry_;
28
- const std::shared_ptr<UIManager> uiManager_;
29
- };
30
-
31
- } // namespace reanimated
32
-
33
- #endif // RCT_NEW_ARCH_ENABLED
1
+ #pragma once
2
+ #ifdef RCT_NEW_ARCH_ENABLED
3
+
4
+ #include <reanimated/Fabric/PropsRegistry.h>
5
+ #include <reanimated/Fabric/ShadowTreeCloner.h>
6
+
7
+ #include <react/renderer/uimanager/UIManagerMountHook.h>
8
+
9
+ #include <memory>
10
+
11
+ namespace reanimated {
12
+
13
+ using namespace facebook::react;
14
+
15
+ class ReanimatedMountHook : public UIManagerMountHook {
16
+ public:
17
+ ReanimatedMountHook(
18
+ const std::shared_ptr<PropsRegistry> &propsRegistry,
19
+ const std::shared_ptr<UIManager> &uiManager);
20
+ ~ReanimatedMountHook() noexcept override;
21
+
22
+ void shadowTreeDidMount(
23
+ RootShadowNode::Shared const &rootShadowNode,
24
+ double mountTime) noexcept override;
25
+
26
+ private:
27
+ const std::shared_ptr<PropsRegistry> propsRegistry_;
28
+ const std::shared_ptr<UIManager> uiManager_;
29
+ };
30
+
31
+ } // namespace reanimated
32
+
33
+ #endif // RCT_NEW_ARCH_ENABLED