@react-native-ohos/react-native-reanimated 3.18.1-rc.6 → 3.18.2-rc.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.
- package/LICENSE +21 -21
- package/README.OpenSource +10 -10
- package/README.md +10 -10
- package/harmony/reanimated/BuildProfile.ets +16 -16
- package/harmony/reanimated/build-profile.json5 +11 -11
- package/harmony/reanimated/oh-package.json5 +11 -11
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +86 -86
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +47 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.cpp +68 -68
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.h +68 -68
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +101 -101
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +51 -51
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitShadowNode.h +49 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +96 -87
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +33 -33
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +95 -95
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +29 -29
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationType.h +9 -9
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +232 -232
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +90 -90
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp +870 -870
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h +147 -147
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.cpp +91 -91
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +176 -176
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +971 -971
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +252 -252
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +231 -231
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +109 -109
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +56 -56
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +70 -70
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +35 -35
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/CollectionUtils.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.cpp +5 -5
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.h +19 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +98 -98
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedSystraceSection.h +135 -135
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +47 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +59 -59
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp +27 -27
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h +25 -25
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +94 -94
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.h +49 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +8 -8
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +39 -39
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.cpp +326 -326
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.h +345 -345
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.cpp +52 -52
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.h +35 -35
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/Defs.h +10 -10
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.cpp +342 -342
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.h +47 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.cpp +16 -16
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.h +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.cpp +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.h +29 -29
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/PlatformLogger.h +16 -16
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.cpp +26 -26
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.h +199 -199
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.cpp +95 -95
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.h +19 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/SingleInstanceChecker.h +72 -72
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ThreadSafeQueue.h +49 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.cpp +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.h +22 -22
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +29 -29
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.h +41 -41
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +16 -16
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +19 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.cpp +112 -112
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.h +127 -127
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.cpp +53 -53
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.h +22 -22
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +191 -191
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +173 -155
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +90 -90
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +36 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +189 -182
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +22 -22
- package/harmony/reanimated/src/main/cpp/WorkletsModule.cpp +60 -60
- package/harmony/reanimated/src/main/cpp/patches/AnimatedSensor/AnimatedSensorModule.cpp +89 -89
- package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +7 -0
- package/harmony/reanimated/src/main/module.json5 +12 -12
- package/harmony/reanimated/src/main/resources/base/element/color.json +7 -7
- package/harmony/reanimated/src/main/resources/base/element/string.json +15 -15
- package/harmony/reanimated/src/main/resources/base/profile/main_pages.json +5 -5
- package/harmony/reanimated/src/main/resources/en_US/element/string.json +15 -15
- package/harmony/reanimated/src/main/resources/zh_CN/element/string.json +15 -15
- package/harmony/reanimated/ts.ts +6 -6
- package/harmony/reanimated.har +0 -0
- package/package.json +50 -50
package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <cxxreact/MessageQueueThread.h>
|
|
4
|
-
#include <worklets/NativeModules/WorkletsModuleProxySpec.h>
|
|
5
|
-
#include <worklets/Tools/JSScheduler.h>
|
|
6
|
-
#include <worklets/Tools/SingleInstanceChecker.h>
|
|
7
|
-
#include <worklets/Tools/UIScheduler.h>
|
|
8
|
-
#include <worklets/WorkletRuntime/WorkletRuntime.h>
|
|
9
|
-
#include <memory>
|
|
10
|
-
#include <string>
|
|
11
|
-
|
|
12
|
-
namespace worklets {
|
|
13
|
-
|
|
14
|
-
class WorkletsModuleProxy
|
|
15
|
-
: public WorkletsModuleProxySpec,
|
|
16
|
-
public std::enable_shared_from_this<WorkletsModuleProxy> {
|
|
17
|
-
public:
|
|
18
|
-
explicit WorkletsModuleProxy(
|
|
19
|
-
const std::string &valueUnpackerCode,
|
|
20
|
-
const std::shared_ptr<MessageQueueThread> &jsQueue,
|
|
21
|
-
const std::shared_ptr<CallInvoker> &jsCallInvoker,
|
|
22
|
-
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
23
|
-
const std::shared_ptr<UIScheduler> &uiScheduler);
|
|
24
|
-
|
|
25
|
-
~WorkletsModuleProxy();
|
|
26
|
-
|
|
27
|
-
jsi::Value makeShareableClone(
|
|
28
|
-
jsi::Runtime &rt,
|
|
29
|
-
const jsi::Value &value,
|
|
30
|
-
const jsi::Value &shouldRetainRemote,
|
|
31
|
-
const jsi::Value &nativeStateSource) override;
|
|
32
|
-
|
|
33
|
-
[[nodiscard]] inline std::string getValueUnpackerCode() const {
|
|
34
|
-
return valueUnpackerCode_;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
[[nodiscard]] inline std::shared_ptr<MessageQueueThread> getJSQueue() const {
|
|
38
|
-
return jsQueue_;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
[[nodiscard]] inline std::shared_ptr<JSScheduler> getJSScheduler() const {
|
|
42
|
-
return jsScheduler_;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
[[nodiscard]] inline std::shared_ptr<UIScheduler> getUIScheduler() const {
|
|
46
|
-
return uiScheduler_;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private:
|
|
50
|
-
const std::string valueUnpackerCode_;
|
|
51
|
-
const std::shared_ptr<MessageQueueThread> jsQueue_;
|
|
52
|
-
const std::shared_ptr<JSScheduler> jsScheduler_;
|
|
53
|
-
const std::shared_ptr<UIScheduler> uiScheduler_;
|
|
54
|
-
#ifndef NDEBUG
|
|
55
|
-
SingleInstanceChecker<WorkletsModuleProxy> singleInstanceChecker_;
|
|
56
|
-
#endif // NDEBUG
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
} // namespace worklets
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <cxxreact/MessageQueueThread.h>
|
|
4
|
+
#include <worklets/NativeModules/WorkletsModuleProxySpec.h>
|
|
5
|
+
#include <worklets/Tools/JSScheduler.h>
|
|
6
|
+
#include <worklets/Tools/SingleInstanceChecker.h>
|
|
7
|
+
#include <worklets/Tools/UIScheduler.h>
|
|
8
|
+
#include <worklets/WorkletRuntime/WorkletRuntime.h>
|
|
9
|
+
#include <memory>
|
|
10
|
+
#include <string>
|
|
11
|
+
|
|
12
|
+
namespace worklets {
|
|
13
|
+
|
|
14
|
+
class WorkletsModuleProxy
|
|
15
|
+
: public WorkletsModuleProxySpec,
|
|
16
|
+
public std::enable_shared_from_this<WorkletsModuleProxy> {
|
|
17
|
+
public:
|
|
18
|
+
explicit WorkletsModuleProxy(
|
|
19
|
+
const std::string &valueUnpackerCode,
|
|
20
|
+
const std::shared_ptr<MessageQueueThread> &jsQueue,
|
|
21
|
+
const std::shared_ptr<CallInvoker> &jsCallInvoker,
|
|
22
|
+
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
23
|
+
const std::shared_ptr<UIScheduler> &uiScheduler);
|
|
24
|
+
|
|
25
|
+
~WorkletsModuleProxy();
|
|
26
|
+
|
|
27
|
+
jsi::Value makeShareableClone(
|
|
28
|
+
jsi::Runtime &rt,
|
|
29
|
+
const jsi::Value &value,
|
|
30
|
+
const jsi::Value &shouldRetainRemote,
|
|
31
|
+
const jsi::Value &nativeStateSource) override;
|
|
32
|
+
|
|
33
|
+
[[nodiscard]] inline std::string getValueUnpackerCode() const {
|
|
34
|
+
return valueUnpackerCode_;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
[[nodiscard]] inline std::shared_ptr<MessageQueueThread> getJSQueue() const {
|
|
38
|
+
return jsQueue_;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[[nodiscard]] inline std::shared_ptr<JSScheduler> getJSScheduler() const {
|
|
42
|
+
return jsScheduler_;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[[nodiscard]] inline std::shared_ptr<UIScheduler> getUIScheduler() const {
|
|
46
|
+
return uiScheduler_;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private:
|
|
50
|
+
const std::string valueUnpackerCode_;
|
|
51
|
+
const std::shared_ptr<MessageQueueThread> jsQueue_;
|
|
52
|
+
const std::shared_ptr<JSScheduler> jsScheduler_;
|
|
53
|
+
const std::shared_ptr<UIScheduler> uiScheduler_;
|
|
54
|
+
#ifndef NDEBUG
|
|
55
|
+
SingleInstanceChecker<WorkletsModuleProxy> singleInstanceChecker_;
|
|
56
|
+
#endif // NDEBUG
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
} // namespace worklets
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
#include <worklets/NativeModules/WorkletsModuleProxySpec.h>
|
|
2
|
-
|
|
3
|
-
#include <utility>
|
|
4
|
-
|
|
5
|
-
#define WORKLETS_SPEC_PREFIX(FN_NAME) \
|
|
6
|
-
__hostFunction_WorkletsModuleProxySpec_##FN_NAME
|
|
7
|
-
|
|
8
|
-
namespace worklets {
|
|
9
|
-
|
|
10
|
-
static jsi::Value WORKLETS_SPEC_PREFIX(makeShareableClone)(
|
|
11
|
-
jsi::Runtime &rt,
|
|
12
|
-
TurboModule &turboModule,
|
|
13
|
-
const jsi::Value *args,
|
|
14
|
-
size_t) {
|
|
15
|
-
return static_cast<WorkletsModuleProxySpec *>(&turboModule)
|
|
16
|
-
->makeShareableClone(
|
|
17
|
-
rt, std::move(args[0]), std::move(args[1]), std::move(args[2]));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
WorkletsModuleProxySpec::WorkletsModuleProxySpec(
|
|
21
|
-
const std::shared_ptr<CallInvoker> jsInvoker)
|
|
22
|
-
: TurboModule("NativeWorklets", jsInvoker) {
|
|
23
|
-
methodMap_["makeShareableClone"] =
|
|
24
|
-
MethodMetadata{2, WORKLETS_SPEC_PREFIX(makeShareableClone)};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
} // namespace worklets
|
|
1
|
+
#include <worklets/NativeModules/WorkletsModuleProxySpec.h>
|
|
2
|
+
|
|
3
|
+
#include <utility>
|
|
4
|
+
|
|
5
|
+
#define WORKLETS_SPEC_PREFIX(FN_NAME) \
|
|
6
|
+
__hostFunction_WorkletsModuleProxySpec_##FN_NAME
|
|
7
|
+
|
|
8
|
+
namespace worklets {
|
|
9
|
+
|
|
10
|
+
static jsi::Value WORKLETS_SPEC_PREFIX(makeShareableClone)(
|
|
11
|
+
jsi::Runtime &rt,
|
|
12
|
+
TurboModule &turboModule,
|
|
13
|
+
const jsi::Value *args,
|
|
14
|
+
size_t) {
|
|
15
|
+
return static_cast<WorkletsModuleProxySpec *>(&turboModule)
|
|
16
|
+
->makeShareableClone(
|
|
17
|
+
rt, std::move(args[0]), std::move(args[1]), std::move(args[2]));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
WorkletsModuleProxySpec::WorkletsModuleProxySpec(
|
|
21
|
+
const std::shared_ptr<CallInvoker> jsInvoker)
|
|
22
|
+
: TurboModule("NativeWorklets", jsInvoker) {
|
|
23
|
+
methodMap_["makeShareableClone"] =
|
|
24
|
+
MethodMetadata{2, WORKLETS_SPEC_PREFIX(makeShareableClone)};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
} // namespace worklets
|
package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <ReactCommon/CallInvoker.h>
|
|
4
|
-
#include <ReactCommon/TurboModule.h>
|
|
5
|
-
#include <memory>
|
|
6
|
-
|
|
7
|
-
using namespace facebook;
|
|
8
|
-
using namespace react;
|
|
9
|
-
|
|
10
|
-
namespace worklets {
|
|
11
|
-
|
|
12
|
-
class JSI_EXPORT WorkletsModuleProxySpec : public TurboModule {
|
|
13
|
-
protected:
|
|
14
|
-
explicit WorkletsModuleProxySpec(
|
|
15
|
-
const std::shared_ptr<CallInvoker> jsInvoker);
|
|
16
|
-
|
|
17
|
-
public:
|
|
18
|
-
virtual jsi::Value makeShareableClone(
|
|
19
|
-
jsi::Runtime &rt,
|
|
20
|
-
const jsi::Value &value,
|
|
21
|
-
const jsi::Value &shouldRetainRemote,
|
|
22
|
-
const jsi::Value &nativeStateSource) = 0;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
} // namespace worklets
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <ReactCommon/CallInvoker.h>
|
|
4
|
+
#include <ReactCommon/TurboModule.h>
|
|
5
|
+
#include <memory>
|
|
6
|
+
|
|
7
|
+
using namespace facebook;
|
|
8
|
+
using namespace react;
|
|
9
|
+
|
|
10
|
+
namespace worklets {
|
|
11
|
+
|
|
12
|
+
class JSI_EXPORT WorkletsModuleProxySpec : public TurboModule {
|
|
13
|
+
protected:
|
|
14
|
+
explicit WorkletsModuleProxySpec(
|
|
15
|
+
const std::shared_ptr<CallInvoker> jsInvoker);
|
|
16
|
+
|
|
17
|
+
public:
|
|
18
|
+
virtual jsi::Value makeShareableClone(
|
|
19
|
+
jsi::Runtime &rt,
|
|
20
|
+
const jsi::Value &value,
|
|
21
|
+
const jsi::Value &shouldRetainRemote,
|
|
22
|
+
const jsi::Value &nativeStateSource) = 0;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
} // namespace worklets
|
package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
#include <worklets/Registries/EventHandlerRegistry.h>
|
|
2
|
-
#include <worklets/Tools/WorkletEventHandler.h>
|
|
3
|
-
|
|
4
|
-
#include <utility>
|
|
5
|
-
#include <vector>
|
|
6
|
-
|
|
7
|
-
namespace worklets {
|
|
8
|
-
|
|
9
|
-
void EventHandlerRegistry::registerEventHandler(
|
|
10
|
-
const std::shared_ptr<WorkletEventHandler> &eventHandler) {
|
|
11
|
-
const std::lock_guard<std::mutex> lock(instanceMutex);
|
|
12
|
-
const auto &eventName = eventHandler->getEventName();
|
|
13
|
-
auto handlerId = eventHandler->getHandlerId();
|
|
14
|
-
|
|
15
|
-
if (eventHandler->shouldIgnoreEmitterReactTag()) {
|
|
16
|
-
eventMappingsWithoutTag[eventName][handlerId] = eventHandler;
|
|
17
|
-
} else {
|
|
18
|
-
const auto emitterReactTag = eventHandler->getEmitterReactTag();
|
|
19
|
-
const auto eventHash = std::make_pair(emitterReactTag, eventName);
|
|
20
|
-
eventMappingsWithTag[eventHash][handlerId] = eventHandler;
|
|
21
|
-
}
|
|
22
|
-
eventHandlers[handlerId] = eventHandler;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
void EventHandlerRegistry::unregisterEventHandler(const uint64_t id) {
|
|
26
|
-
const std::lock_guard<std::mutex> lock(instanceMutex);
|
|
27
|
-
auto handlerIt = eventHandlers.find(id);
|
|
28
|
-
if (handlerIt != eventHandlers.end()) {
|
|
29
|
-
const auto &eventHandler = handlerIt->second;
|
|
30
|
-
const auto &eventName = eventHandler->getEventName();
|
|
31
|
-
|
|
32
|
-
if (eventHandler->shouldIgnoreEmitterReactTag()) {
|
|
33
|
-
const auto eventMappingIt = eventMappingsWithoutTag.find(eventName);
|
|
34
|
-
auto &handlersMap = eventMappingIt->second;
|
|
35
|
-
handlersMap.erase(id);
|
|
36
|
-
if (handlersMap.empty()) {
|
|
37
|
-
eventMappingsWithoutTag.erase(eventMappingIt);
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
const auto emitterReactTag = eventHandler->getEmitterReactTag();
|
|
41
|
-
const auto eventHash = std::make_pair(emitterReactTag, eventName);
|
|
42
|
-
const auto eventMappingIt = eventMappingsWithTag.find(eventHash);
|
|
43
|
-
auto &handlersMap = eventMappingIt->second;
|
|
44
|
-
handlersMap.erase(id);
|
|
45
|
-
if (handlersMap.empty()) {
|
|
46
|
-
eventMappingsWithTag.erase(eventMappingIt);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
eventHandlers.erase(handlerIt);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
void EventHandlerRegistry::processEvent(
|
|
54
|
-
const std::shared_ptr<WorkletRuntime> &uiWorkletRuntime,
|
|
55
|
-
const double eventTimestamp,
|
|
56
|
-
const std::string &eventName,
|
|
57
|
-
const int emitterReactTag,
|
|
58
|
-
const jsi::Value &eventPayload) {
|
|
59
|
-
std::vector<std::shared_ptr<WorkletEventHandler>> handlersForEvent;
|
|
60
|
-
{
|
|
61
|
-
const std::lock_guard<std::mutex> lock(instanceMutex);
|
|
62
|
-
auto handlersIt = eventMappingsWithoutTag.find(eventName);
|
|
63
|
-
if (handlersIt != eventMappingsWithoutTag.end()) {
|
|
64
|
-
for (auto handler : handlersIt->second) {
|
|
65
|
-
handlersForEvent.push_back(handler.second);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
const auto eventHash = std::make_pair(emitterReactTag, eventName);
|
|
69
|
-
auto handlersWithTagIt = eventMappingsWithTag.find(eventHash);
|
|
70
|
-
if (handlersWithTagIt != eventMappingsWithTag.end()) {
|
|
71
|
-
for (auto handler : handlersWithTagIt->second) {
|
|
72
|
-
handlersForEvent.push_back(handler.second);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
jsi::Runtime &rt = uiWorkletRuntime->getJSIRuntime();
|
|
78
|
-
eventPayload.asObject(rt).setProperty(
|
|
79
|
-
rt, "eventName", jsi::String::createFromUtf8(rt, eventName));
|
|
80
|
-
for (auto handler : handlersForEvent) {
|
|
81
|
-
handler->process(uiWorkletRuntime, eventTimestamp, eventPayload);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
bool EventHandlerRegistry::isAnyHandlerWaitingForEvent(
|
|
86
|
-
const std::string &eventName,
|
|
87
|
-
const int emitterReactTag) {
|
|
88
|
-
const std::lock_guard<std::mutex> lock(instanceMutex);
|
|
89
|
-
const auto eventHash = std::make_pair(emitterReactTag, eventName);
|
|
90
|
-
auto it = eventMappingsWithTag.find(eventHash);
|
|
91
|
-
return it != eventMappingsWithTag.end() && !it->second.empty();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
} // namespace worklets
|
|
1
|
+
#include <worklets/Registries/EventHandlerRegistry.h>
|
|
2
|
+
#include <worklets/Tools/WorkletEventHandler.h>
|
|
3
|
+
|
|
4
|
+
#include <utility>
|
|
5
|
+
#include <vector>
|
|
6
|
+
|
|
7
|
+
namespace worklets {
|
|
8
|
+
|
|
9
|
+
void EventHandlerRegistry::registerEventHandler(
|
|
10
|
+
const std::shared_ptr<WorkletEventHandler> &eventHandler) {
|
|
11
|
+
const std::lock_guard<std::mutex> lock(instanceMutex);
|
|
12
|
+
const auto &eventName = eventHandler->getEventName();
|
|
13
|
+
auto handlerId = eventHandler->getHandlerId();
|
|
14
|
+
|
|
15
|
+
if (eventHandler->shouldIgnoreEmitterReactTag()) {
|
|
16
|
+
eventMappingsWithoutTag[eventName][handlerId] = eventHandler;
|
|
17
|
+
} else {
|
|
18
|
+
const auto emitterReactTag = eventHandler->getEmitterReactTag();
|
|
19
|
+
const auto eventHash = std::make_pair(emitterReactTag, eventName);
|
|
20
|
+
eventMappingsWithTag[eventHash][handlerId] = eventHandler;
|
|
21
|
+
}
|
|
22
|
+
eventHandlers[handlerId] = eventHandler;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
void EventHandlerRegistry::unregisterEventHandler(const uint64_t id) {
|
|
26
|
+
const std::lock_guard<std::mutex> lock(instanceMutex);
|
|
27
|
+
auto handlerIt = eventHandlers.find(id);
|
|
28
|
+
if (handlerIt != eventHandlers.end()) {
|
|
29
|
+
const auto &eventHandler = handlerIt->second;
|
|
30
|
+
const auto &eventName = eventHandler->getEventName();
|
|
31
|
+
|
|
32
|
+
if (eventHandler->shouldIgnoreEmitterReactTag()) {
|
|
33
|
+
const auto eventMappingIt = eventMappingsWithoutTag.find(eventName);
|
|
34
|
+
auto &handlersMap = eventMappingIt->second;
|
|
35
|
+
handlersMap.erase(id);
|
|
36
|
+
if (handlersMap.empty()) {
|
|
37
|
+
eventMappingsWithoutTag.erase(eventMappingIt);
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
const auto emitterReactTag = eventHandler->getEmitterReactTag();
|
|
41
|
+
const auto eventHash = std::make_pair(emitterReactTag, eventName);
|
|
42
|
+
const auto eventMappingIt = eventMappingsWithTag.find(eventHash);
|
|
43
|
+
auto &handlersMap = eventMappingIt->second;
|
|
44
|
+
handlersMap.erase(id);
|
|
45
|
+
if (handlersMap.empty()) {
|
|
46
|
+
eventMappingsWithTag.erase(eventMappingIt);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
eventHandlers.erase(handlerIt);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void EventHandlerRegistry::processEvent(
|
|
54
|
+
const std::shared_ptr<WorkletRuntime> &uiWorkletRuntime,
|
|
55
|
+
const double eventTimestamp,
|
|
56
|
+
const std::string &eventName,
|
|
57
|
+
const int emitterReactTag,
|
|
58
|
+
const jsi::Value &eventPayload) {
|
|
59
|
+
std::vector<std::shared_ptr<WorkletEventHandler>> handlersForEvent;
|
|
60
|
+
{
|
|
61
|
+
const std::lock_guard<std::mutex> lock(instanceMutex);
|
|
62
|
+
auto handlersIt = eventMappingsWithoutTag.find(eventName);
|
|
63
|
+
if (handlersIt != eventMappingsWithoutTag.end()) {
|
|
64
|
+
for (auto handler : handlersIt->second) {
|
|
65
|
+
handlersForEvent.push_back(handler.second);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const auto eventHash = std::make_pair(emitterReactTag, eventName);
|
|
69
|
+
auto handlersWithTagIt = eventMappingsWithTag.find(eventHash);
|
|
70
|
+
if (handlersWithTagIt != eventMappingsWithTag.end()) {
|
|
71
|
+
for (auto handler : handlersWithTagIt->second) {
|
|
72
|
+
handlersForEvent.push_back(handler.second);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
jsi::Runtime &rt = uiWorkletRuntime->getJSIRuntime();
|
|
78
|
+
eventPayload.asObject(rt).setProperty(
|
|
79
|
+
rt, "eventName", jsi::String::createFromUtf8(rt, eventName));
|
|
80
|
+
for (auto handler : handlersForEvent) {
|
|
81
|
+
handler->process(uiWorkletRuntime, eventTimestamp, eventPayload);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
bool EventHandlerRegistry::isAnyHandlerWaitingForEvent(
|
|
86
|
+
const std::string &eventName,
|
|
87
|
+
const int emitterReactTag) {
|
|
88
|
+
const std::lock_guard<std::mutex> lock(instanceMutex);
|
|
89
|
+
const auto eventHash = std::make_pair(emitterReactTag, eventName);
|
|
90
|
+
auto it = eventMappingsWithTag.find(eventHash);
|
|
91
|
+
return it != eventMappingsWithTag.end() && !it->second.empty();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
} // namespace worklets
|
package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.h
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <worklets/WorkletRuntime/WorkletRuntime.h>
|
|
4
|
-
|
|
5
|
-
#include <jsi/jsi.h>
|
|
6
|
-
|
|
7
|
-
#include <map>
|
|
8
|
-
#include <memory>
|
|
9
|
-
#include <mutex>
|
|
10
|
-
#include <string>
|
|
11
|
-
#include <unordered_map>
|
|
12
|
-
#include <utility>
|
|
13
|
-
|
|
14
|
-
using namespace facebook;
|
|
15
|
-
|
|
16
|
-
namespace worklets {
|
|
17
|
-
|
|
18
|
-
class WorkletEventHandler;
|
|
19
|
-
|
|
20
|
-
class EventHandlerRegistry {
|
|
21
|
-
std::map<
|
|
22
|
-
std::pair<int, std::string>,
|
|
23
|
-
std::unordered_map<uint64_t, std::shared_ptr<WorkletEventHandler>>>
|
|
24
|
-
eventMappingsWithTag;
|
|
25
|
-
std::map<
|
|
26
|
-
std::string,
|
|
27
|
-
std::unordered_map<uint64_t, std::shared_ptr<WorkletEventHandler>>>
|
|
28
|
-
eventMappingsWithoutTag;
|
|
29
|
-
std::map<uint64_t, std::shared_ptr<WorkletEventHandler>> eventHandlers;
|
|
30
|
-
std::mutex instanceMutex;
|
|
31
|
-
|
|
32
|
-
public:
|
|
33
|
-
void registerEventHandler(
|
|
34
|
-
const std::shared_ptr<WorkletEventHandler> &eventHandler);
|
|
35
|
-
void unregisterEventHandler(const uint64_t id);
|
|
36
|
-
|
|
37
|
-
void processEvent(
|
|
38
|
-
const std::shared_ptr<WorkletRuntime> &uiWorkletRuntime,
|
|
39
|
-
const double eventTimestamp,
|
|
40
|
-
const std::string &eventName,
|
|
41
|
-
const int emitterReactTag,
|
|
42
|
-
const jsi::Value &eventPayload);
|
|
43
|
-
|
|
44
|
-
bool isAnyHandlerWaitingForEvent(
|
|
45
|
-
const std::string &eventName,
|
|
46
|
-
const int emitterReactTag);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
} // namespace worklets
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <worklets/WorkletRuntime/WorkletRuntime.h>
|
|
4
|
+
|
|
5
|
+
#include <jsi/jsi.h>
|
|
6
|
+
|
|
7
|
+
#include <map>
|
|
8
|
+
#include <memory>
|
|
9
|
+
#include <mutex>
|
|
10
|
+
#include <string>
|
|
11
|
+
#include <unordered_map>
|
|
12
|
+
#include <utility>
|
|
13
|
+
|
|
14
|
+
using namespace facebook;
|
|
15
|
+
|
|
16
|
+
namespace worklets {
|
|
17
|
+
|
|
18
|
+
class WorkletEventHandler;
|
|
19
|
+
|
|
20
|
+
class EventHandlerRegistry {
|
|
21
|
+
std::map<
|
|
22
|
+
std::pair<int, std::string>,
|
|
23
|
+
std::unordered_map<uint64_t, std::shared_ptr<WorkletEventHandler>>>
|
|
24
|
+
eventMappingsWithTag;
|
|
25
|
+
std::map<
|
|
26
|
+
std::string,
|
|
27
|
+
std::unordered_map<uint64_t, std::shared_ptr<WorkletEventHandler>>>
|
|
28
|
+
eventMappingsWithoutTag;
|
|
29
|
+
std::map<uint64_t, std::shared_ptr<WorkletEventHandler>> eventHandlers;
|
|
30
|
+
std::mutex instanceMutex;
|
|
31
|
+
|
|
32
|
+
public:
|
|
33
|
+
void registerEventHandler(
|
|
34
|
+
const std::shared_ptr<WorkletEventHandler> &eventHandler);
|
|
35
|
+
void unregisterEventHandler(const uint64_t id);
|
|
36
|
+
|
|
37
|
+
void processEvent(
|
|
38
|
+
const std::shared_ptr<WorkletRuntime> &uiWorkletRuntime,
|
|
39
|
+
const double eventTimestamp,
|
|
40
|
+
const std::string &eventName,
|
|
41
|
+
const int emitterReactTag,
|
|
42
|
+
const jsi::Value &eventPayload);
|
|
43
|
+
|
|
44
|
+
bool isAnyHandlerWaitingForEvent(
|
|
45
|
+
const std::string &eventName,
|
|
46
|
+
const int emitterReactTag);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
} // namespace worklets
|
package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#include <worklets/Registries/WorkletRuntimeRegistry.h>
|
|
2
|
-
|
|
3
|
-
namespace worklets {
|
|
4
|
-
|
|
5
|
-
std::set<jsi::Runtime *> WorkletRuntimeRegistry::registry_{};
|
|
6
|
-
std::mutex WorkletRuntimeRegistry::mutex_{};
|
|
7
|
-
|
|
8
|
-
} // namespace worklets
|
|
1
|
+
#include <worklets/Registries/WorkletRuntimeRegistry.h>
|
|
2
|
+
|
|
3
|
+
namespace worklets {
|
|
4
|
+
|
|
5
|
+
std::set<jsi::Runtime *> WorkletRuntimeRegistry::registry_{};
|
|
6
|
+
std::mutex WorkletRuntimeRegistry::mutex_{};
|
|
7
|
+
|
|
8
|
+
} // namespace worklets
|
package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <jsi/jsi.h>
|
|
4
|
-
|
|
5
|
-
#include <mutex>
|
|
6
|
-
#include <set>
|
|
7
|
-
|
|
8
|
-
using namespace facebook;
|
|
9
|
-
|
|
10
|
-
namespace worklets {
|
|
11
|
-
|
|
12
|
-
class WorkletRuntimeRegistry {
|
|
13
|
-
private:
|
|
14
|
-
static std::set<jsi::Runtime *> registry_;
|
|
15
|
-
static std::mutex mutex_; // Protects `registry_`.
|
|
16
|
-
|
|
17
|
-
WorkletRuntimeRegistry() {} // private ctor
|
|
18
|
-
|
|
19
|
-
static void registerRuntime(jsi::Runtime &runtime) {
|
|
20
|
-
std::lock_guard<std::mutex> lock(mutex_);
|
|
21
|
-
registry_.insert(&runtime);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static void unregisterRuntime(jsi::Runtime &runtime) {
|
|
25
|
-
std::lock_guard<std::mutex> lock(mutex_);
|
|
26
|
-
registry_.erase(&runtime);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
friend class WorkletRuntimeCollector;
|
|
30
|
-
|
|
31
|
-
public:
|
|
32
|
-
static bool isRuntimeAlive(jsi::Runtime *runtime) {
|
|
33
|
-
assert(runtime != nullptr);
|
|
34
|
-
std::lock_guard<std::mutex> lock(mutex_);
|
|
35
|
-
return registry_.find(runtime) != registry_.end();
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
} // namespace worklets
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
|
|
5
|
+
#include <mutex>
|
|
6
|
+
#include <set>
|
|
7
|
+
|
|
8
|
+
using namespace facebook;
|
|
9
|
+
|
|
10
|
+
namespace worklets {
|
|
11
|
+
|
|
12
|
+
class WorkletRuntimeRegistry {
|
|
13
|
+
private:
|
|
14
|
+
static std::set<jsi::Runtime *> registry_;
|
|
15
|
+
static std::mutex mutex_; // Protects `registry_`.
|
|
16
|
+
|
|
17
|
+
WorkletRuntimeRegistry() {} // private ctor
|
|
18
|
+
|
|
19
|
+
static void registerRuntime(jsi::Runtime &runtime) {
|
|
20
|
+
std::lock_guard<std::mutex> lock(mutex_);
|
|
21
|
+
registry_.insert(&runtime);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static void unregisterRuntime(jsi::Runtime &runtime) {
|
|
25
|
+
std::lock_guard<std::mutex> lock(mutex_);
|
|
26
|
+
registry_.erase(&runtime);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
friend class WorkletRuntimeCollector;
|
|
30
|
+
|
|
31
|
+
public:
|
|
32
|
+
static bool isRuntimeAlive(jsi::Runtime *runtime) {
|
|
33
|
+
assert(runtime != nullptr);
|
|
34
|
+
std::lock_guard<std::mutex> lock(mutex_);
|
|
35
|
+
return registry_.find(runtime) != registry_.end();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
} // namespace worklets
|