@react-native-ohos/react-native-reanimated 3.18.1-rc.1
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.
- package/harmony/reanimated/BuildProfile.ets +17 -0
- package/harmony/reanimated/build-profile.json5 +12 -0
- package/harmony/reanimated/hvigorfile.ts +5 -0
- package/harmony/reanimated/index.ets +5 -0
- package/harmony/reanimated/oh-package.json5 +12 -0
- package/harmony/reanimated/src/main/cpp/CMakeLists.txt +72 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +86 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +47 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.cpp +68 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.h +68 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +101 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +51 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitShadowNode.h +49 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +87 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +33 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +95 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +29 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationType.h +9 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +232 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +90 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp +870 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h +147 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.cpp +91 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +176 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +971 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +252 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +231 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +109 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +56 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h +20 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +70 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +35 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/CollectionUtils.h +14 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.cpp +5 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.h +19 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +98 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedSystraceSection.h +135 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +47 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +59 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp +27 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h +25 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +94 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.h +49 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +8 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +39 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.cpp +326 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.h +345 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.cpp +52 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.h +35 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/Defs.h +10 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.cpp +342 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.h +47 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.cpp +16 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.h +20 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.cpp +20 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.h +29 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/PlatformLogger.h +16 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.cpp +26 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.h +199 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.cpp +95 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.h +19 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/SingleInstanceChecker.h +72 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ThreadSafeQueue.h +49 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.cpp +20 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.h +22 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +29 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.h +41 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +16 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +19 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.cpp +112 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.h +127 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.cpp +53 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.h +22 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +191 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +155 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +90 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +36 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +182 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +22 -0
- package/harmony/reanimated/src/main/cpp/ReanimatedLogger.cpp +33 -0
- package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +222 -0
- package/harmony/reanimated/src/main/cpp/ReanimatedModule.h +24 -0
- package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.cpp +56 -0
- package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.h +31 -0
- package/harmony/reanimated/src/main/cpp/ReanimatedPackage.cpp +47 -0
- package/harmony/reanimated/src/main/cpp/ReanimatedPackage.h +16 -0
- package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.cpp +23 -0
- package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.h +20 -0
- package/harmony/reanimated/src/main/cpp/TransformParser.h +94 -0
- package/harmony/reanimated/src/main/cpp/WorkletsModule.cpp +58 -0
- package/harmony/reanimated/src/main/cpp/WorkletsModule.h +22 -0
- package/harmony/reanimated/src/main/cpp/patches/AnimatedSensor/AnimatedSensorModule.cpp +89 -0
- package/harmony/reanimated/src/main/cpp/patches/Fabric/ShadowTreeCloner.cpp +95 -0
- package/harmony/reanimated/src/main/cpp/patches/NativeModules/ReanimatedModuleProxy.cpp +961 -0
- package/harmony/reanimated/src/main/ets/AnimationManager.ts +61 -0
- package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +41 -0
- package/harmony/reanimated/src/main/ets/ReanimatedPackage.ts +29 -0
- package/harmony/reanimated/src/main/ets/WorkletsModule.ts +15 -0
- package/harmony/reanimated/src/main/module.json5 +13 -0
- package/harmony/reanimated/src/main/resources/base/element/color.json +8 -0
- package/harmony/reanimated/src/main/resources/base/element/string.json +16 -0
- package/harmony/reanimated/src/main/resources/base/media/icon.png +0 -0
- package/harmony/reanimated/src/main/resources/base/media/startIcon.png +0 -0
- package/harmony/reanimated/src/main/resources/base/profile/main_pages.json +5 -0
- package/harmony/reanimated/src/main/resources/en_US/element/string.json +16 -0
- package/harmony/reanimated/src/main/resources/zh_CN/element/string.json +16 -0
- package/harmony/reanimated/ts.ts +6 -0
- package/harmony/reanimated.har +0 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +7 -0
- package/package.json +50 -0
- package/src/index.ts +10 -0
package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <reanimated/AnimatedSensor/AnimatedSensorModule.h>
|
|
4
|
+
#include <reanimated/LayoutAnimations/LayoutAnimationsManager.h>
|
|
5
|
+
#include <reanimated/NativeModules/ReanimatedModuleProxySpec.h>
|
|
6
|
+
#include <reanimated/Tools/PlatformDepMethodsHolder.h>
|
|
7
|
+
|
|
8
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
9
|
+
#include <reanimated/Fabric/PropsRegistry.h>
|
|
10
|
+
#include <reanimated/Fabric/ReanimatedCommitHook.h>
|
|
11
|
+
#include <reanimated/Fabric/ReanimatedMountHook.h>
|
|
12
|
+
#include <reanimated/LayoutAnimations/LayoutAnimationsProxy.h>
|
|
13
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
14
|
+
|
|
15
|
+
#include <worklets/NativeModules/WorkletsModuleProxy.h>
|
|
16
|
+
#include <worklets/Registries/EventHandlerRegistry.h>
|
|
17
|
+
#include <worklets/Tools/JSScheduler.h>
|
|
18
|
+
#include <worklets/Tools/SingleInstanceChecker.h>
|
|
19
|
+
#include <worklets/Tools/UIScheduler.h>
|
|
20
|
+
|
|
21
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
22
|
+
#include <react/renderer/uimanager/UIManager.h>
|
|
23
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
24
|
+
|
|
25
|
+
#include <memory>
|
|
26
|
+
#include <string>
|
|
27
|
+
#include <unordered_set>
|
|
28
|
+
#include <utility>
|
|
29
|
+
#include <vector>
|
|
30
|
+
|
|
31
|
+
namespace reanimated {
|
|
32
|
+
|
|
33
|
+
using namespace facebook;
|
|
34
|
+
|
|
35
|
+
class ReanimatedModuleProxy
|
|
36
|
+
: public ReanimatedModuleProxySpec,
|
|
37
|
+
public std::enable_shared_from_this<ReanimatedModuleProxy> {
|
|
38
|
+
public:
|
|
39
|
+
ReanimatedModuleProxy(
|
|
40
|
+
const std::shared_ptr<WorkletsModuleProxy> &workletsModuleProxy,
|
|
41
|
+
jsi::Runtime &rnRuntime,
|
|
42
|
+
const std::shared_ptr<CallInvoker> &jsCallInvoker,
|
|
43
|
+
const PlatformDepMethodsHolder &platformDepMethodsHolder,
|
|
44
|
+
const bool isBridgeless,
|
|
45
|
+
const bool isReducedMotion);
|
|
46
|
+
|
|
47
|
+
// We need this init method to initialize callbacks with
|
|
48
|
+
// weak_from_this() which is available only after the object
|
|
49
|
+
// is fully constructed.
|
|
50
|
+
void init(const PlatformDepMethodsHolder &platformDepMethodsHolder);
|
|
51
|
+
|
|
52
|
+
void scheduleOnUI(jsi::Runtime &rt, const jsi::Value &worklet) override;
|
|
53
|
+
jsi::Value executeOnUIRuntimeSync(jsi::Runtime &rt, const jsi::Value &worklet)
|
|
54
|
+
override;
|
|
55
|
+
|
|
56
|
+
jsi::Value createWorkletRuntime(
|
|
57
|
+
jsi::Runtime &rt,
|
|
58
|
+
const jsi::Value &name,
|
|
59
|
+
const jsi::Value &initializer) override;
|
|
60
|
+
jsi::Value scheduleOnRuntime(
|
|
61
|
+
jsi::Runtime &rt,
|
|
62
|
+
const jsi::Value &workletRuntimeValue,
|
|
63
|
+
const jsi::Value &shareableWorkletValue) override;
|
|
64
|
+
|
|
65
|
+
~ReanimatedModuleProxy();
|
|
66
|
+
|
|
67
|
+
jsi::Value registerEventHandler(
|
|
68
|
+
jsi::Runtime &rt,
|
|
69
|
+
const jsi::Value &worklet,
|
|
70
|
+
const jsi::Value &eventName,
|
|
71
|
+
const jsi::Value &emitterReactTag) override;
|
|
72
|
+
void unregisterEventHandler(
|
|
73
|
+
jsi::Runtime &rt,
|
|
74
|
+
const jsi::Value ®istrationId) override;
|
|
75
|
+
|
|
76
|
+
jsi::Value getViewProp(
|
|
77
|
+
jsi::Runtime &rt,
|
|
78
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
79
|
+
const jsi::Value &shadowNodeWrapper,
|
|
80
|
+
#else
|
|
81
|
+
const jsi::Value &viewTag,
|
|
82
|
+
#endif
|
|
83
|
+
const jsi::Value &propName,
|
|
84
|
+
const jsi::Value &callback) override;
|
|
85
|
+
|
|
86
|
+
jsi::Value enableLayoutAnimations(jsi::Runtime &rt, const jsi::Value &config)
|
|
87
|
+
override;
|
|
88
|
+
jsi::Value configureProps(
|
|
89
|
+
jsi::Runtime &rt,
|
|
90
|
+
const jsi::Value &uiProps,
|
|
91
|
+
const jsi::Value &nativeProps) override;
|
|
92
|
+
jsi::Value configureLayoutAnimationBatch(
|
|
93
|
+
jsi::Runtime &rt,
|
|
94
|
+
const jsi::Value &layoutAnimationsBatch) override;
|
|
95
|
+
void setShouldAnimateExiting(
|
|
96
|
+
jsi::Runtime &rt,
|
|
97
|
+
const jsi::Value &viewTag,
|
|
98
|
+
const jsi::Value &shouldAnimate) override;
|
|
99
|
+
|
|
100
|
+
void onRender(double timestampMs);
|
|
101
|
+
|
|
102
|
+
bool isAnyHandlerWaitingForEvent(
|
|
103
|
+
const std::string &eventName,
|
|
104
|
+
const int emitterReactTag);
|
|
105
|
+
|
|
106
|
+
void maybeRequestRender();
|
|
107
|
+
|
|
108
|
+
bool handleEvent(
|
|
109
|
+
const std::string &eventName,
|
|
110
|
+
const int emitterReactTag,
|
|
111
|
+
const jsi::Value &payload,
|
|
112
|
+
double currentTime);
|
|
113
|
+
|
|
114
|
+
inline std::shared_ptr<JSLogger> getJSLogger() const {
|
|
115
|
+
return jsLogger_;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
119
|
+
bool handleRawEvent(const RawEvent &rawEvent, double currentTime);
|
|
120
|
+
|
|
121
|
+
void updateProps(jsi::Runtime &rt, const jsi::Value &operations);
|
|
122
|
+
|
|
123
|
+
void removeFromPropsRegistry(jsi::Runtime &rt, const jsi::Value &viewTags);
|
|
124
|
+
|
|
125
|
+
void performOperations();
|
|
126
|
+
|
|
127
|
+
void markNodeAsRemovable(
|
|
128
|
+
jsi::Runtime &rt,
|
|
129
|
+
const jsi::Value &shadowNodeWrapper) override;
|
|
130
|
+
void unmarkNodeAsRemovable(jsi::Runtime &rt, const jsi::Value &viewTag)
|
|
131
|
+
override;
|
|
132
|
+
|
|
133
|
+
void dispatchCommand(
|
|
134
|
+
jsi::Runtime &rt,
|
|
135
|
+
const jsi::Value &shadowNodeValue,
|
|
136
|
+
const jsi::Value &commandNameValue,
|
|
137
|
+
const jsi::Value &argsValue);
|
|
138
|
+
|
|
139
|
+
jsi::String obtainProp(
|
|
140
|
+
jsi::Runtime &rt,
|
|
141
|
+
const jsi::Value &shadowNodeWrapper,
|
|
142
|
+
const jsi::Value &propName);
|
|
143
|
+
|
|
144
|
+
jsi::Value measure(jsi::Runtime &rt, const jsi::Value &shadowNodeValue);
|
|
145
|
+
|
|
146
|
+
void initializeFabric(const std::shared_ptr<UIManager> &uiManager);
|
|
147
|
+
|
|
148
|
+
void initializeLayoutAnimationsProxy();
|
|
149
|
+
|
|
150
|
+
std::string obtainPropFromShadowNode(
|
|
151
|
+
jsi::Runtime &rt,
|
|
152
|
+
const std::string &propName,
|
|
153
|
+
const ShadowNode::Shared &shadowNode);
|
|
154
|
+
|
|
155
|
+
#ifdef IS_REANIMATED_EXAMPLE_APP
|
|
156
|
+
std::function<std::string()> createRegistriesLeakCheck();
|
|
157
|
+
#endif // IS_REANIMATED_EXAMPLE_APP
|
|
158
|
+
#endif
|
|
159
|
+
|
|
160
|
+
jsi::Value registerSensor(
|
|
161
|
+
jsi::Runtime &rt,
|
|
162
|
+
const jsi::Value &sensorType,
|
|
163
|
+
const jsi::Value &interval,
|
|
164
|
+
const jsi::Value &iosReferenceFrame,
|
|
165
|
+
const jsi::Value &sensorDataContainer) override;
|
|
166
|
+
void unregisterSensor(jsi::Runtime &rt, const jsi::Value &sensorId) override;
|
|
167
|
+
|
|
168
|
+
void cleanupSensors();
|
|
169
|
+
|
|
170
|
+
jsi::Value subscribeForKeyboardEvents(
|
|
171
|
+
jsi::Runtime &rt,
|
|
172
|
+
const jsi::Value &keyboardEventContainer,
|
|
173
|
+
const jsi::Value &isStatusBarTranslucent,
|
|
174
|
+
const jsi::Value &isNavigationBarTranslucent) override;
|
|
175
|
+
void unsubscribeFromKeyboardEvents(
|
|
176
|
+
jsi::Runtime &rt,
|
|
177
|
+
const jsi::Value &listenerId) override;
|
|
178
|
+
|
|
179
|
+
inline LayoutAnimationsManager &layoutAnimationsManager() {
|
|
180
|
+
return *layoutAnimationsManager_;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
[[nodiscard]] inline jsi::Runtime &getUIRuntime() const {
|
|
184
|
+
return uiWorkletRuntime_->getJSIRuntime();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
[[nodiscard]] inline bool isBridgeless() const {
|
|
188
|
+
return isBridgeless_;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
[[nodiscard]] inline bool isReducedMotion() const {
|
|
192
|
+
return isReducedMotion_;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
[[nodiscard]] inline std::shared_ptr<WorkletsModuleProxy>
|
|
196
|
+
getWorkletsModuleProxy() const {
|
|
197
|
+
return workletsModuleProxy_;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
private:
|
|
201
|
+
void requestAnimationFrame(jsi::Runtime &rt, const jsi::Value &callback);
|
|
202
|
+
|
|
203
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
204
|
+
jsi::Value filterNonAnimatableProps(
|
|
205
|
+
jsi::Runtime &rt,
|
|
206
|
+
const jsi::Value &props);
|
|
207
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
208
|
+
|
|
209
|
+
const bool isBridgeless_;
|
|
210
|
+
const bool isReducedMotion_;
|
|
211
|
+
std::shared_ptr<WorkletsModuleProxy> workletsModuleProxy_;
|
|
212
|
+
const std::string valueUnpackerCode_;
|
|
213
|
+
std::shared_ptr<WorkletRuntime> uiWorkletRuntime_;
|
|
214
|
+
|
|
215
|
+
std::unique_ptr<EventHandlerRegistry> eventHandlerRegistry_;
|
|
216
|
+
const RequestRenderFunction requestRender_;
|
|
217
|
+
std::vector<std::shared_ptr<jsi::Value>> frameCallbacks_;
|
|
218
|
+
volatile bool renderRequested_{false};
|
|
219
|
+
std::function<void(const double)> onRenderCallback_;
|
|
220
|
+
AnimatedSensorModule animatedSensorModule_;
|
|
221
|
+
const std::shared_ptr<JSLogger> jsLogger_;
|
|
222
|
+
std::shared_ptr<LayoutAnimationsManager> layoutAnimationsManager_;
|
|
223
|
+
|
|
224
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
225
|
+
std::unordered_set<std::string>
|
|
226
|
+
animatablePropNames_; // filled by configureProps
|
|
227
|
+
std::shared_ptr<UIManager> uiManager_;
|
|
228
|
+
std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy_;
|
|
229
|
+
|
|
230
|
+
std::vector<std::pair<ShadowNode::Shared, std::unique_ptr<jsi::Value>>>
|
|
231
|
+
operationsInBatch_; // TODO: refactor std::pair to custom struct
|
|
232
|
+
|
|
233
|
+
std::shared_ptr<PropsRegistry> propsRegistry_;
|
|
234
|
+
std::shared_ptr<ReanimatedCommitHook> commitHook_;
|
|
235
|
+
std::shared_ptr<ReanimatedMountHook> mountHook_;
|
|
236
|
+
|
|
237
|
+
std::vector<Tag> tagsToRemove_; // from `propsRegistry_`
|
|
238
|
+
#else
|
|
239
|
+
const ObtainPropFunction obtainPropFunction_;
|
|
240
|
+
const ConfigurePropsFunction configurePropsPlatformFunction_;
|
|
241
|
+
const UpdatePropsFunction updatePropsFunction_;
|
|
242
|
+
#endif
|
|
243
|
+
|
|
244
|
+
const KeyboardEventSubscribeFunction subscribeForKeyboardEventsFunction_;
|
|
245
|
+
const KeyboardEventUnsubscribeFunction unsubscribeFromKeyboardEventsFunction_;
|
|
246
|
+
|
|
247
|
+
#ifndef NDEBUG
|
|
248
|
+
worklets::SingleInstanceChecker<ReanimatedModuleProxy> singleInstanceChecker_;
|
|
249
|
+
#endif // NDEBUG
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
} // namespace reanimated
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
#include <reanimated/NativeModules/ReanimatedModuleProxySpec.h>
|
|
2
|
+
|
|
3
|
+
#include <utility>
|
|
4
|
+
|
|
5
|
+
#define REANIMATED_SPEC_PREFIX(FN_NAME) \
|
|
6
|
+
__hostFunction_ReanimatedModuleProxySpec_##FN_NAME
|
|
7
|
+
|
|
8
|
+
namespace reanimated {
|
|
9
|
+
|
|
10
|
+
// scheduler
|
|
11
|
+
|
|
12
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(scheduleOnUI)(
|
|
13
|
+
jsi::Runtime &rt,
|
|
14
|
+
TurboModule &turboModule,
|
|
15
|
+
const jsi::Value *args,
|
|
16
|
+
size_t) {
|
|
17
|
+
static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
18
|
+
->scheduleOnUI(rt, std::move(args[0]));
|
|
19
|
+
return jsi::Value::undefined();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(executeOnUIRuntimeSync)(
|
|
23
|
+
jsi::Runtime &rt,
|
|
24
|
+
TurboModule &turboModule,
|
|
25
|
+
const jsi::Value *args,
|
|
26
|
+
size_t) {
|
|
27
|
+
return static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
28
|
+
->executeOnUIRuntimeSync(rt, std::move(args[0]));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(createWorkletRuntime)(
|
|
32
|
+
jsi::Runtime &rt,
|
|
33
|
+
TurboModule &turboModule,
|
|
34
|
+
const jsi::Value *args,
|
|
35
|
+
size_t) {
|
|
36
|
+
return static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
37
|
+
->createWorkletRuntime(rt, std::move(args[0]), std::move(args[1]));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(scheduleOnRuntime)(
|
|
41
|
+
jsi::Runtime &rt,
|
|
42
|
+
TurboModule &turboModule,
|
|
43
|
+
const jsi::Value *args,
|
|
44
|
+
size_t) {
|
|
45
|
+
return static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
46
|
+
->scheduleOnRuntime(rt, std::move(args[0]), std::move(args[1]));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(registerEventHandler)(
|
|
50
|
+
jsi::Runtime &rt,
|
|
51
|
+
TurboModule &turboModule,
|
|
52
|
+
const jsi::Value *args,
|
|
53
|
+
size_t) {
|
|
54
|
+
return static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
55
|
+
->registerEventHandler(
|
|
56
|
+
rt, std::move(args[0]), std::move(args[1]), std::move(args[2]));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(unregisterEventHandler)(
|
|
60
|
+
jsi::Runtime &rt,
|
|
61
|
+
TurboModule &turboModule,
|
|
62
|
+
const jsi::Value *args,
|
|
63
|
+
size_t) {
|
|
64
|
+
static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
65
|
+
->unregisterEventHandler(rt, std::move(args[0]));
|
|
66
|
+
return jsi::Value::undefined();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(getViewProp)(
|
|
70
|
+
jsi::Runtime &rt,
|
|
71
|
+
TurboModule &turboModule,
|
|
72
|
+
const jsi::Value *args,
|
|
73
|
+
size_t) {
|
|
74
|
+
static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
75
|
+
->getViewProp(
|
|
76
|
+
rt, std::move(args[0]), std::move(args[1]), std::move(args[2]));
|
|
77
|
+
return jsi::Value::undefined();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(enableLayoutAnimations)(
|
|
81
|
+
jsi::Runtime &rt,
|
|
82
|
+
TurboModule &turboModule,
|
|
83
|
+
const jsi::Value *args,
|
|
84
|
+
size_t) {
|
|
85
|
+
static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
86
|
+
->enableLayoutAnimations(rt, std::move(args[0]));
|
|
87
|
+
return jsi::Value::undefined();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(registerSensor)(
|
|
91
|
+
jsi::Runtime &rt,
|
|
92
|
+
TurboModule &turboModule,
|
|
93
|
+
const jsi::Value *args,
|
|
94
|
+
size_t) {
|
|
95
|
+
return static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
96
|
+
->registerSensor(
|
|
97
|
+
rt,
|
|
98
|
+
std::move(args[0]),
|
|
99
|
+
std::move(args[1]),
|
|
100
|
+
std::move(args[2]),
|
|
101
|
+
std::move(args[3]));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(unregisterSensor)(
|
|
105
|
+
jsi::Runtime &rt,
|
|
106
|
+
TurboModule &turboModule,
|
|
107
|
+
const jsi::Value *args,
|
|
108
|
+
size_t) {
|
|
109
|
+
static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
110
|
+
->unregisterSensor(rt, std::move(args[0]));
|
|
111
|
+
return jsi::Value::undefined();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(configureProps)(
|
|
115
|
+
jsi::Runtime &rt,
|
|
116
|
+
TurboModule &turboModule,
|
|
117
|
+
const jsi::Value *args,
|
|
118
|
+
size_t) {
|
|
119
|
+
static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
120
|
+
->configureProps(rt, std::move(args[0]), std::move(args[1]));
|
|
121
|
+
return jsi::Value::undefined();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(subscribeForKeyboardEvents)(
|
|
125
|
+
jsi::Runtime &rt,
|
|
126
|
+
TurboModule &turboModule,
|
|
127
|
+
const jsi::Value *args,
|
|
128
|
+
size_t) {
|
|
129
|
+
return static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
130
|
+
->subscribeForKeyboardEvents(
|
|
131
|
+
rt, std::move(args[0]), std::move(args[1]), std::move(args[2]));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(unsubscribeFromKeyboardEvents)(
|
|
135
|
+
jsi::Runtime &rt,
|
|
136
|
+
TurboModule &turboModule,
|
|
137
|
+
const jsi::Value *args,
|
|
138
|
+
size_t) {
|
|
139
|
+
static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
140
|
+
->unsubscribeFromKeyboardEvents(rt, std::move(args[0]));
|
|
141
|
+
return jsi::Value::undefined();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(configureLayoutAnimationBatch)(
|
|
145
|
+
jsi::Runtime &rt,
|
|
146
|
+
TurboModule &turboModule,
|
|
147
|
+
const jsi::Value *args,
|
|
148
|
+
size_t) {
|
|
149
|
+
return static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
150
|
+
->configureLayoutAnimationBatch(rt, std::move(args[0]));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(setShouldAnimateExiting)(
|
|
154
|
+
jsi::Runtime &rt,
|
|
155
|
+
TurboModule &turboModule,
|
|
156
|
+
const jsi::Value *args,
|
|
157
|
+
size_t) {
|
|
158
|
+
static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
159
|
+
->setShouldAnimateExiting(rt, std::move(args[0]), std::move(args[1]));
|
|
160
|
+
return jsi::Value::undefined();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
164
|
+
|
|
165
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(markNodeAsRemovable)(
|
|
166
|
+
jsi::Runtime &rt,
|
|
167
|
+
TurboModule &turboModule,
|
|
168
|
+
const jsi::Value *args,
|
|
169
|
+
size_t) {
|
|
170
|
+
static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
171
|
+
->markNodeAsRemovable(rt, std::move(args[0]));
|
|
172
|
+
return jsi::Value::undefined();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(unmarkNodeAsRemovable)(
|
|
176
|
+
jsi::Runtime &rt,
|
|
177
|
+
TurboModule &turboModule,
|
|
178
|
+
const jsi::Value *args,
|
|
179
|
+
size_t) {
|
|
180
|
+
static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
181
|
+
->unmarkNodeAsRemovable(rt, std::move(args[0]));
|
|
182
|
+
return jsi::Value::undefined();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
186
|
+
|
|
187
|
+
ReanimatedModuleProxySpec::ReanimatedModuleProxySpec(
|
|
188
|
+
const std::shared_ptr<CallInvoker> &jsInvoker)
|
|
189
|
+
: TurboModule("NativeReanimated", jsInvoker) {
|
|
190
|
+
methodMap_["scheduleOnUI"] =
|
|
191
|
+
MethodMetadata{1, REANIMATED_SPEC_PREFIX(scheduleOnUI)};
|
|
192
|
+
methodMap_["executeOnUIRuntimeSync"] =
|
|
193
|
+
MethodMetadata{1, REANIMATED_SPEC_PREFIX(executeOnUIRuntimeSync)};
|
|
194
|
+
methodMap_["createWorkletRuntime"] =
|
|
195
|
+
MethodMetadata{2, REANIMATED_SPEC_PREFIX(createWorkletRuntime)};
|
|
196
|
+
methodMap_["scheduleOnRuntime"] =
|
|
197
|
+
MethodMetadata{2, REANIMATED_SPEC_PREFIX(scheduleOnRuntime)};
|
|
198
|
+
|
|
199
|
+
methodMap_["registerEventHandler"] =
|
|
200
|
+
MethodMetadata{3, REANIMATED_SPEC_PREFIX(registerEventHandler)};
|
|
201
|
+
methodMap_["unregisterEventHandler"] =
|
|
202
|
+
MethodMetadata{1, REANIMATED_SPEC_PREFIX(unregisterEventHandler)};
|
|
203
|
+
|
|
204
|
+
methodMap_["getViewProp"] =
|
|
205
|
+
MethodMetadata{3, REANIMATED_SPEC_PREFIX(getViewProp)};
|
|
206
|
+
methodMap_["enableLayoutAnimations"] =
|
|
207
|
+
MethodMetadata{2, REANIMATED_SPEC_PREFIX(enableLayoutAnimations)};
|
|
208
|
+
methodMap_["registerSensor"] =
|
|
209
|
+
MethodMetadata{4, REANIMATED_SPEC_PREFIX(registerSensor)};
|
|
210
|
+
methodMap_["unregisterSensor"] =
|
|
211
|
+
MethodMetadata{1, REANIMATED_SPEC_PREFIX(unregisterSensor)};
|
|
212
|
+
methodMap_["configureProps"] =
|
|
213
|
+
MethodMetadata{2, REANIMATED_SPEC_PREFIX(configureProps)};
|
|
214
|
+
methodMap_["subscribeForKeyboardEvents"] =
|
|
215
|
+
MethodMetadata{2, REANIMATED_SPEC_PREFIX(subscribeForKeyboardEvents)};
|
|
216
|
+
methodMap_["unsubscribeFromKeyboardEvents"] =
|
|
217
|
+
MethodMetadata{1, REANIMATED_SPEC_PREFIX(unsubscribeFromKeyboardEvents)};
|
|
218
|
+
|
|
219
|
+
methodMap_["configureLayoutAnimationBatch"] =
|
|
220
|
+
MethodMetadata{1, REANIMATED_SPEC_PREFIX(configureLayoutAnimationBatch)};
|
|
221
|
+
methodMap_["setShouldAnimateExitingForTag"] =
|
|
222
|
+
MethodMetadata{2, REANIMATED_SPEC_PREFIX(setShouldAnimateExiting)};
|
|
223
|
+
|
|
224
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
225
|
+
methodMap_["markNodeAsRemovable"] =
|
|
226
|
+
MethodMetadata{1, REANIMATED_SPEC_PREFIX(markNodeAsRemovable)};
|
|
227
|
+
methodMap_["unmarkNodeAsRemovable"] =
|
|
228
|
+
MethodMetadata{1, REANIMATED_SPEC_PREFIX(unmarkNodeAsRemovable)};
|
|
229
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
230
|
+
}
|
|
231
|
+
} // namespace reanimated
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <ReactCommon/CallInvoker.h>
|
|
4
|
+
#include <ReactCommon/TurboModule.h>
|
|
5
|
+
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <string>
|
|
8
|
+
#include <vector>
|
|
9
|
+
|
|
10
|
+
using namespace facebook;
|
|
11
|
+
using namespace react;
|
|
12
|
+
|
|
13
|
+
namespace reanimated {
|
|
14
|
+
|
|
15
|
+
class JSI_EXPORT ReanimatedModuleProxySpec : public TurboModule {
|
|
16
|
+
protected:
|
|
17
|
+
explicit ReanimatedModuleProxySpec(
|
|
18
|
+
const std::shared_ptr<CallInvoker> &jsInvoker);
|
|
19
|
+
|
|
20
|
+
public:
|
|
21
|
+
// Scheduling
|
|
22
|
+
virtual void scheduleOnUI(jsi::Runtime &rt, const jsi::Value &worklet) = 0;
|
|
23
|
+
virtual jsi::Value executeOnUIRuntimeSync(
|
|
24
|
+
jsi::Runtime &rt,
|
|
25
|
+
const jsi::Value &worklet) = 0;
|
|
26
|
+
|
|
27
|
+
// Worklet runtime
|
|
28
|
+
virtual jsi::Value createWorkletRuntime(
|
|
29
|
+
jsi::Runtime &rt,
|
|
30
|
+
const jsi::Value &name,
|
|
31
|
+
const jsi::Value &initializer) = 0;
|
|
32
|
+
virtual jsi::Value scheduleOnRuntime(
|
|
33
|
+
jsi::Runtime &rt,
|
|
34
|
+
const jsi::Value &workletRuntimeValue,
|
|
35
|
+
const jsi::Value &shareableWorkletValue) = 0;
|
|
36
|
+
|
|
37
|
+
// events
|
|
38
|
+
virtual jsi::Value registerEventHandler(
|
|
39
|
+
jsi::Runtime &rt,
|
|
40
|
+
const jsi::Value &worklet,
|
|
41
|
+
const jsi::Value &eventName,
|
|
42
|
+
const jsi::Value &emitterReactTag) = 0;
|
|
43
|
+
virtual void unregisterEventHandler(
|
|
44
|
+
jsi::Runtime &rt,
|
|
45
|
+
const jsi::Value ®istrationId) = 0;
|
|
46
|
+
|
|
47
|
+
// views
|
|
48
|
+
virtual jsi::Value getViewProp(
|
|
49
|
+
jsi::Runtime &rt,
|
|
50
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
51
|
+
const jsi::Value &shadowNodeWrapper,
|
|
52
|
+
#else
|
|
53
|
+
const jsi::Value &viewTag,
|
|
54
|
+
#endif
|
|
55
|
+
const jsi::Value &propName,
|
|
56
|
+
const jsi::Value &callback) = 0;
|
|
57
|
+
|
|
58
|
+
// sensors
|
|
59
|
+
virtual jsi::Value registerSensor(
|
|
60
|
+
jsi::Runtime &rt,
|
|
61
|
+
const jsi::Value &sensorType,
|
|
62
|
+
const jsi::Value &interval,
|
|
63
|
+
const jsi::Value &iosReferenceFrame,
|
|
64
|
+
const jsi::Value &sensorDataContainer) = 0;
|
|
65
|
+
virtual void unregisterSensor(
|
|
66
|
+
jsi::Runtime &rt,
|
|
67
|
+
const jsi::Value &sensorId) = 0;
|
|
68
|
+
|
|
69
|
+
// keyboard
|
|
70
|
+
virtual jsi::Value subscribeForKeyboardEvents(
|
|
71
|
+
jsi::Runtime &rt,
|
|
72
|
+
const jsi::Value &keyboardEventContainer,
|
|
73
|
+
const jsi::Value &isStatusBarTranslucent,
|
|
74
|
+
const jsi::Value &isNavigationBarTranslucent) = 0;
|
|
75
|
+
virtual void unsubscribeFromKeyboardEvents(
|
|
76
|
+
jsi::Runtime &rt,
|
|
77
|
+
const jsi::Value &listenerId) = 0;
|
|
78
|
+
|
|
79
|
+
// other
|
|
80
|
+
virtual jsi::Value enableLayoutAnimations(
|
|
81
|
+
jsi::Runtime &rt,
|
|
82
|
+
const jsi::Value &config) = 0;
|
|
83
|
+
virtual jsi::Value configureProps(
|
|
84
|
+
jsi::Runtime &rt,
|
|
85
|
+
const jsi::Value &uiProps,
|
|
86
|
+
const jsi::Value &nativeProps) = 0;
|
|
87
|
+
|
|
88
|
+
// layout animations
|
|
89
|
+
virtual jsi::Value configureLayoutAnimationBatch(
|
|
90
|
+
jsi::Runtime &rt,
|
|
91
|
+
const jsi::Value &layoutAnimationsBatch) = 0;
|
|
92
|
+
|
|
93
|
+
virtual void setShouldAnimateExiting(
|
|
94
|
+
jsi::Runtime &rt,
|
|
95
|
+
const jsi::Value &viewTag,
|
|
96
|
+
const jsi::Value &shouldAnimate) = 0;
|
|
97
|
+
|
|
98
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
99
|
+
// Cleanup
|
|
100
|
+
virtual void markNodeAsRemovable(
|
|
101
|
+
jsi::Runtime &rt,
|
|
102
|
+
const jsi::Value &shadowNodeWrapper) = 0;
|
|
103
|
+
virtual void unmarkNodeAsRemovable(
|
|
104
|
+
jsi::Runtime &rt,
|
|
105
|
+
const jsi::Value &viewTag) = 0;
|
|
106
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
} // namespace reanimated
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#include <reanimated/RuntimeDecorators/RNRuntimeDecorator.h>
|
|
2
|
+
#include <worklets/Tools/ReanimatedJSIUtils.h>
|
|
3
|
+
#include <worklets/Tools/ReanimatedVersion.h>
|
|
4
|
+
|
|
5
|
+
namespace reanimated {
|
|
6
|
+
|
|
7
|
+
void RNRuntimeDecorator::decorate(
|
|
8
|
+
jsi::Runtime &rnRuntime,
|
|
9
|
+
const std::shared_ptr<ReanimatedModuleProxy> &reanimatedModuleProxy) {
|
|
10
|
+
jsi::Runtime &uiRuntime = reanimatedModuleProxy->getUIRuntime();
|
|
11
|
+
auto workletRuntimeValue =
|
|
12
|
+
rnRuntime.global()
|
|
13
|
+
.getPropertyAsObject(rnRuntime, "ArrayBuffer")
|
|
14
|
+
.asFunction(rnRuntime)
|
|
15
|
+
.callAsConstructor(rnRuntime, {static_cast<double>(sizeof(void *))});
|
|
16
|
+
uintptr_t *workletRuntimeData = reinterpret_cast<uintptr_t *>(
|
|
17
|
+
workletRuntimeValue.getObject(rnRuntime).getArrayBuffer(rnRuntime).data(
|
|
18
|
+
rnRuntime));
|
|
19
|
+
workletRuntimeData[0] = reinterpret_cast<uintptr_t>(&uiRuntime);
|
|
20
|
+
rnRuntime.global().setProperty(
|
|
21
|
+
rnRuntime, "_WORKLET_RUNTIME", workletRuntimeValue);
|
|
22
|
+
|
|
23
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
24
|
+
constexpr auto isFabric = true;
|
|
25
|
+
#else
|
|
26
|
+
constexpr auto isFabric = false;
|
|
27
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
28
|
+
rnRuntime.global().setProperty(rnRuntime, "_IS_FABRIC", isFabric);
|
|
29
|
+
|
|
30
|
+
rnRuntime.global().setProperty(
|
|
31
|
+
rnRuntime, "_IS_BRIDGELESS", reanimatedModuleProxy->isBridgeless());
|
|
32
|
+
|
|
33
|
+
#ifndef NDEBUG
|
|
34
|
+
checkJSVersion(rnRuntime, reanimatedModuleProxy->getJSLogger());
|
|
35
|
+
#endif // NDEBUG
|
|
36
|
+
|
|
37
|
+
#if defined(IS_REANIMATED_EXAMPLE_APP) && defined(RCT_NEW_ARCH_ENABLED)
|
|
38
|
+
jsi_utils::installJsiFunction(
|
|
39
|
+
rnRuntime,
|
|
40
|
+
"_registriesLeakCheck",
|
|
41
|
+
reanimatedModuleProxy->createRegistriesLeakCheck());
|
|
42
|
+
#endif // defined(IS_REANIMATED_EXAMPLE_APP) && defined(RCT_NEW_ARCH_ENABLED)
|
|
43
|
+
injectReanimatedCppVersion(rnRuntime);
|
|
44
|
+
|
|
45
|
+
rnRuntime.global().setProperty(
|
|
46
|
+
rnRuntime,
|
|
47
|
+
"_REANIMATED_IS_REDUCED_MOTION",
|
|
48
|
+
reanimatedModuleProxy->isReducedMotion());
|
|
49
|
+
|
|
50
|
+
rnRuntime.global().setProperty(
|
|
51
|
+
rnRuntime,
|
|
52
|
+
"__reanimatedModuleProxy",
|
|
53
|
+
jsi::Object::createFromHostObject(rnRuntime, reanimatedModuleProxy));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
} // namespace reanimated
|
package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <reanimated/NativeModules/ReanimatedModuleProxy.h>
|
|
4
|
+
|
|
5
|
+
#include <jsi/jsi.h>
|
|
6
|
+
|
|
7
|
+
#include <memory>
|
|
8
|
+
|
|
9
|
+
using namespace facebook;
|
|
10
|
+
|
|
11
|
+
namespace reanimated {
|
|
12
|
+
|
|
13
|
+
class RNRuntimeDecorator {
|
|
14
|
+
public:
|
|
15
|
+
static void decorate(
|
|
16
|
+
jsi::Runtime &rnRuntime,
|
|
17
|
+
const std::shared_ptr<ReanimatedModuleProxy> &reanimatedModuleProxy);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
} // namespace reanimated
|