@react-native-oh-tpl/react-native-gesture-handler 2.14.13 → 2.14.15

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 (49) hide show
  1. package/harmony/gesture_handler/BuildProfile.ets +1 -1
  2. package/harmony/gesture_handler/build-profile.json5 +0 -7
  3. package/harmony/gesture_handler/index.ets +1 -2
  4. package/harmony/gesture_handler/oh-package-lock.json5 +1 -1
  5. package/harmony/gesture_handler/oh-package.json5 +2 -2
  6. package/harmony/gesture_handler/src/main/cpp/CMakeLists.txt +1 -1
  7. package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.h +9 -18
  8. package/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.cpp +157 -0
  9. package/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.h +21 -0
  10. package/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerButtonComponentInstance.h +16 -16
  11. package/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerRootViewComponentInstance.h +202 -199
  12. package/harmony/gesture_handler/src/main/ets/RNOHPackage.ets +17 -0
  13. package/harmony/gesture_handler/src/main/ets/core/GestureHandler.ts +84 -35
  14. package/harmony/gesture_handler/src/main/ets/core/GestureHandlerOrchestrator.ts +20 -11
  15. package/harmony/gesture_handler/src/main/ets/core/GestureHandlerRegistry.ts +2 -2
  16. package/harmony/gesture_handler/src/main/ets/core/InteractionManager.ts +4 -4
  17. package/harmony/gesture_handler/src/main/ets/core/Multiset.ts +26 -0
  18. package/harmony/gesture_handler/src/main/ets/core/RNGHLogger.ts +7 -3
  19. package/harmony/gesture_handler/src/main/ets/core/ViewRegistry.ts +1 -2
  20. package/harmony/gesture_handler/src/main/ets/core/index.ts +2 -2
  21. package/harmony/gesture_handler/src/main/ets/gesture-handlers/FlingGestureHandler.ts +12 -4
  22. package/harmony/gesture_handler/src/main/ets/gesture-handlers/GestureHandlerFactory.ts +8 -5
  23. package/harmony/gesture_handler/src/main/ets/gesture-handlers/LongPressGestureHandler.ts +14 -2
  24. package/harmony/gesture_handler/src/main/ets/gesture-handlers/ManualGestureHandler.ts +9 -1
  25. package/harmony/gesture_handler/src/main/ets/gesture-handlers/NativeViewGestureHandler.ts +13 -4
  26. package/harmony/gesture_handler/src/main/ets/gesture-handlers/PanGestureHandler.ts +45 -12
  27. package/harmony/gesture_handler/src/main/ets/gesture-handlers/PinchGestureHandler.ts +145 -130
  28. package/harmony/gesture_handler/src/main/ets/gesture-handlers/RotationGestureHandler.ts +9 -1
  29. package/harmony/gesture_handler/src/main/ets/gesture-handlers/TapGestureHandler.ts +15 -5
  30. package/harmony/gesture_handler/src/main/ets/rnoh/GestureHandlerPackage.ts +6 -3
  31. package/harmony/gesture_handler/src/main/ets/rnoh/Logger.ts +74 -16
  32. package/harmony/gesture_handler/src/main/ets/rnoh/OutgoingEventDispatchers.ts +35 -12
  33. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootViewController.ts +196 -0
  34. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHView.ts +85 -0
  35. package/harmony/gesture_handler/src/main/ets/rnoh/{GestureHandlerArkUIAdapter.ts → RNGHViewController.ts} +45 -30
  36. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHViewRegistry.ts +19 -0
  37. package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerModule.ts +127 -93
  38. package/harmony/gesture_handler/src/main/ets/rnoh/RNOHGestureResponder.ts +0 -9
  39. package/harmony/gesture_handler/src/main/ets/rnoh/RNOHScrollLocker.ts +1 -8
  40. package/harmony/gesture_handler.har +0 -0
  41. package/package.json +7 -3
  42. package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.cpp +0 -149
  43. package/harmony/gesture_handler/src/main/ets/core/ViewFinder.ts +0 -11
  44. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootTouchHandlerArkTS.ts +0 -98
  45. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootTouchHandlerCAPI.ts +0 -110
  46. package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerButton.ets +0 -38
  47. package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerRootView.ets +0 -53
  48. package/harmony/gesture_handler/src/main/ets/rnoh/View.ts +0 -134
  49. package/harmony/gesture_handler/src/main/ets/rnoh/ViewRegistry.ts +0 -97
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Use these variables when you tailor your ArkTS code. They must be of the const type.
3
3
  */
4
- export const HAR_VERSION = '2.14.1-2.14.13';
4
+ export const HAR_VERSION = '2.14.1-2.14.15';
5
5
  export const BUILD_MODE_NAME = 'release';
6
6
  export const DEBUG = false;
7
7
  export const TARGET_NAME = 'default';
@@ -1,12 +1,5 @@
1
1
  {
2
2
  "apiType": 'stageMode',
3
- // "buildOption": {
4
- // "externalNativeOptions": {
5
- // "path": "./src/main/cpp/CMakeLists.txt",
6
- // "arguments": "",
7
- // "cppFlags": "",
8
- // },
9
- // },
10
3
  "targets": [
11
4
  {
12
5
  "name": "default",
@@ -1,3 +1,2 @@
1
1
  export * from "./ts"
2
- export * from "./src/main/ets/rnoh/RNGestureHandlerRootView"
3
- export * from "./src/main/ets/rnoh/RNGestureHandlerButton"
2
+ export { default } from "./src/main/ets/RNOHPackage"
@@ -10,7 +10,7 @@
10
10
  "packages": {
11
11
  "@rnoh/react-native-openharmony@../react_native_openharmony.har": {
12
12
  "name": "@rnoh/react-native-openharmony",
13
- "version": "0.72.28",
13
+ "version": "0.72.35",
14
14
  "resolved": "../react_native_openharmony.har",
15
15
  "registryType": "local"
16
16
  }
@@ -5,8 +5,8 @@
5
5
  name: '@react-native-oh-tpl/react-native-gesture-handler',
6
6
  description: '',
7
7
  type: 'module',
8
- version: '2.14.1-2.14.13',
8
+ version: '2.14.1-2.14.15',
9
9
  dependencies: {
10
- "@rnoh/react-native-openharmony": "file:./react_native_openharmony"
10
+ "@rnoh/react-native-openharmony": "file:../react_native_openharmony"
11
11
  },
12
12
  }
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13)
2
2
  set(CMAKE_VERBOSE_MAKEFILE on)
3
3
 
4
4
  file(GLOB rnoh_gesture_handler_SRC CONFIGURE_DEPENDS *.cpp)
5
+
5
6
  add_library(rnoh_gesture_handler SHARED ${rnoh_gesture_handler_SRC})
6
7
  target_include_directories(rnoh_gesture_handler PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
7
8
  target_link_libraries(rnoh_gesture_handler PUBLIC rnoh)
8
-
@@ -1,21 +1,12 @@
1
1
  #pragma once
2
- #include "RNOH/Package.h"
2
+ #include "RnohReactNativeHarmonyGestureHandlerPackage.h"
3
3
 
4
4
  namespace rnoh {
5
- class GestureHandlerPackage : public Package {
6
- public:
7
- GestureHandlerPackage(Package::Context ctx) : Package(ctx) {}
8
-
9
- std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override;
10
-
11
- std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override;
12
-
13
- ComponentJSIBinderByString createComponentJSIBinderByName() override;
14
-
15
- EventEmitRequestHandlers createEventEmitRequestHandlers();
16
-
17
- ComponentInstanceFactoryDelegate::Shared createComponentInstanceFactoryDelegate();
18
-
19
- std::vector<ArkTSMessageHandler::Shared> createArkTSMessageHandlers() override;
20
- };
21
- } // namespace rnoh
5
+ /**
6
+ * @deprecated: Use RnohReactNativeHarmonyGestureHandlerPackage instead (2024-10-10)
7
+ */
8
+ class GestureHandlerPackage : public RnohReactNativeHarmonyGestureHandlerPackage {
9
+ using Super = RnohReactNativeHarmonyGestureHandlerPackage;
10
+ using Super::Super;
11
+ };
12
+ } // namespace rnoh
@@ -0,0 +1,157 @@
1
+ #pragma once
2
+ #include "RnohReactNativeHarmonyGestureHandlerPackage.h"
3
+ #include "RNOH/RNInstanceCAPI.h"
4
+ #include "componentInstances/RNGestureHandlerButtonComponentInstance.h"
5
+ #include "componentInstances/RNGestureHandlerRootViewComponentInstance.h"
6
+ #include "RNOH/ArkTSTurboModule.h"
7
+ #include "RNGestureHandlerModule.h"
8
+ #include "RNGestureHandlerButtonComponentDescriptor.h"
9
+ #include "RNGestureHandlerRootViewComponentDescriptor.h"
10
+ #include "RNGestureHandlerButtonJSIBinder.h"
11
+ #include "RNGestureHandlerRootViewJSIBinder.h"
12
+ #include <glog/logging.h>
13
+ #include <react/renderer/debug/SystraceSection.h>
14
+
15
+ using namespace rnoh;
16
+ using namespace facebook;
17
+
18
+ class GestureHandlerTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
19
+ public:
20
+ SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
21
+ if (name == "RNGestureHandlerModule") {
22
+ return std::make_shared<RNGestureHandlerModule>(ctx, name);
23
+ }
24
+ return nullptr;
25
+ };
26
+ };
27
+
28
+
29
+ class RNGHEventEmitRequestHandler : public EventEmitRequestHandler {
30
+ void handleEvent(EventEmitRequestHandler::Context const &ctx) override {
31
+ facebook::react::SystraceSection s("RNGH::RNGHEventEmitRequestHandler::handleEvent");
32
+ auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::ViewEventEmitter>(ctx.tag);
33
+ if (eventEmitter == nullptr) {
34
+ return;
35
+ }
36
+ if (ctx.eventName == "onGestureHandlerEvent") {
37
+ eventEmitter->dispatchUniqueEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
38
+ } else if (ctx.eventName == "onGestureHandlerStateChange") {
39
+ eventEmitter->dispatchEvent("onGestureHandlerStateChange", ArkJS(ctx.env).getDynamic(ctx.payload));
40
+ }
41
+ }
42
+ };
43
+
44
+ class RNOHCorePackageComponentInstanceFactoryDelegate : public ComponentInstanceFactoryDelegate {
45
+ public:
46
+ using ComponentInstanceFactoryDelegate::ComponentInstanceFactoryDelegate;
47
+
48
+ ComponentInstance::Shared create(ComponentInstance::Context ctx) override {
49
+ if (ctx.componentName == "RNGestureHandlerButton") {
50
+ return std::make_shared<RNGestureHandlerButtonComponentInstance>(ctx);
51
+ } else if (ctx.componentName == "RNGestureHandlerRootView") {
52
+ return std::make_shared<RNGestureHandlerRootViewComponentInstance>(ctx);
53
+ }
54
+ return nullptr;
55
+ }
56
+ };
57
+
58
+ std::unique_ptr<TurboModuleFactoryDelegate> RnohReactNativeHarmonyGestureHandlerPackage::createTurboModuleFactoryDelegate() {
59
+ return std::make_unique<GestureHandlerTurboModuleFactoryDelegate>();
60
+ }
61
+
62
+ std::vector<react::ComponentDescriptorProvider> RnohReactNativeHarmonyGestureHandlerPackage::createComponentDescriptorProviders() {
63
+ return {
64
+ react::concreteComponentDescriptorProvider<react::RNGestureHandlerRootViewComponentDescriptor>(),
65
+ react::concreteComponentDescriptorProvider<react::RNGestureHandlerButtonComponentDescriptor>(),
66
+ };
67
+ }
68
+
69
+ ComponentJSIBinderByString RnohReactNativeHarmonyGestureHandlerPackage::createComponentJSIBinderByName() {
70
+ return {
71
+ {"RNGestureHandlerButton", std::make_shared<RNGestureHandlerButtonJSIBinder>()},
72
+ {"RNGestureHandlerRootView", std::make_shared<RNGestureHandlerRootViewJSIBinder>()},
73
+ };
74
+ };
75
+
76
+ EventEmitRequestHandlers RnohReactNativeHarmonyGestureHandlerPackage::createEventEmitRequestHandlers() {
77
+ return {
78
+ std::make_shared<RNGHEventEmitRequestHandler>(),
79
+ };
80
+ }
81
+
82
+ ComponentInstanceFactoryDelegate::Shared
83
+ RnohReactNativeHarmonyGestureHandlerPackage::createComponentInstanceFactoryDelegate() {
84
+ return std::make_shared<RNOHCorePackageComponentInstanceFactoryDelegate>();
85
+ }
86
+
87
+ class ScrollLockerArkTSMessageHandler : public ArkTSMessageHandler {
88
+ public:
89
+ void handleArkTSMessage(const Context &ctx) override {
90
+ facebook::react::SystraceSection s("RNGH::ScrollLockerArkTSMessageHandler::handleArkTSMessage");
91
+ if (ctx.messageName == "RNGH::SET_NATIVE_RESPONDERS_BLOCK") {
92
+ auto targetComponentInstanceTag = ctx.messagePayload["targetTag"].asDouble();
93
+ auto shouldBlock = ctx.messagePayload["shouldBlock"].asBool();
94
+ auto rnInstance = ctx.rnInstance.lock();
95
+ if (rnInstance != nullptr) {
96
+ auto rnInstanceCAPI = std::dynamic_pointer_cast<RNInstanceCAPI>(rnInstance);
97
+ if (rnInstanceCAPI != nullptr) {
98
+
99
+ std::vector<ComponentInstance::Shared> ancestors;
100
+ auto tmpComponentInstance = rnInstanceCAPI->findComponentInstanceByTag(targetComponentInstanceTag);
101
+ while (tmpComponentInstance != nullptr) {
102
+ ancestors.push_back(tmpComponentInstance);
103
+ tmpComponentInstance = tmpComponentInstance->getParent().lock();
104
+ }
105
+ if (ancestors.size() == 0) {
106
+ return;
107
+ }
108
+ /**
109
+ * Ensure consistent behavior with Android by not blocking
110
+ * scrolls above the GestureHandlerRootView handling the
111
+ * touch. If there are multiple nested
112
+ * GestureHandlerRootViews, the one nearest to the actual
113
+ * root will handle the touch.
114
+ */
115
+ auto isChangingResponderStatusAllowed = false;
116
+ for (size_t i = ancestors.size() - 1; i > 0; i--) {
117
+ auto ancestor = ancestors[i];
118
+ if (!isChangingResponderStatusAllowed) {
119
+ auto rootView =
120
+ std::dynamic_pointer_cast<RNGestureHandlerRootViewComponentInstance>(ancestor);
121
+ if (rootView != nullptr) {
122
+ isChangingResponderStatusAllowed = true;
123
+ }
124
+ } else {
125
+ ancestor->setNativeResponderBlocked(shouldBlock, "RNGH");
126
+ }
127
+ }
128
+ }
129
+ }
130
+ } else if (ctx.messageName == "RNGH::ROOT_VIEW_IS_HANDLING_TOUCHES") {
131
+ auto descendantViewTag = ctx.messagePayload["descendantViewTag"].asDouble();
132
+ auto isHandlingTouches = ctx.messagePayload["isHandlingTouches"].asBool();
133
+ auto rnInstance = ctx.rnInstance.lock();
134
+ if (rnInstance != nullptr) {
135
+ auto rnInstanceCAPI = std::dynamic_pointer_cast<RNInstanceCAPI>(rnInstance);
136
+ if (rnInstanceCAPI != nullptr) {
137
+ auto tmpComponentInstance = rnInstanceCAPI->findComponentInstanceByTag(descendantViewTag);
138
+ while (tmpComponentInstance != nullptr) {
139
+ tmpComponentInstance = tmpComponentInstance->getParent().lock();
140
+ if (tmpComponentInstance) {
141
+ auto rnghRootViewComponentInstance =
142
+ std::dynamic_pointer_cast<RNGestureHandlerRootViewComponentInstance>(
143
+ tmpComponentInstance);
144
+ if (rnghRootViewComponentInstance) {
145
+ rnghRootViewComponentInstance->setIsHandlingTouches(isHandlingTouches);
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+ }
152
+ };
153
+ };
154
+
155
+ std::vector<ArkTSMessageHandler::Shared> RnohReactNativeHarmonyGestureHandlerPackage::createArkTSMessageHandlers() {
156
+ return {std::make_shared<ScrollLockerArkTSMessageHandler>()};
157
+ }
@@ -0,0 +1,21 @@
1
+ #pragma once
2
+ #include "RNOH/Package.h"
3
+
4
+ namespace rnoh {
5
+ class RnohReactNativeHarmonyGestureHandlerPackage : public Package {
6
+ public:
7
+ RnohReactNativeHarmonyGestureHandlerPackage(Package::Context ctx) : Package(ctx) {}
8
+
9
+ std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override;
10
+
11
+ std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override;
12
+
13
+ ComponentJSIBinderByString createComponentJSIBinderByName() override;
14
+
15
+ EventEmitRequestHandlers createEventEmitRequestHandlers();
16
+
17
+ ComponentInstanceFactoryDelegate::Shared createComponentInstanceFactoryDelegate();
18
+
19
+ std::vector<ArkTSMessageHandler::Shared> createArkTSMessageHandlers() override;
20
+ };
21
+ } // namespace rnoh
@@ -4,24 +4,24 @@
4
4
  #import "../RNGestureHandlerButtonComponentDescriptor.h"
5
5
 
6
6
  namespace rnoh {
7
- class RNGestureHandlerButtonComponentInstance
8
- : public CppComponentInstance<facebook::react::RNGestureHandlerButtonShadowNode> {
9
- private:
10
- StackNode m_stackNode;
7
+ class RNGestureHandlerButtonComponentInstance
8
+ : public CppComponentInstance<facebook::react::RNGestureHandlerButtonShadowNode> {
9
+ private:
10
+ StackNode m_stackNode;
11
11
 
12
- public:
13
- RNGestureHandlerButtonComponentInstance(Context context) : CppComponentInstance(std::move(context)) {};
12
+ public:
13
+ RNGestureHandlerButtonComponentInstance(Context context) : CppComponentInstance(std::move(context)){};
14
14
 
15
- StackNode &getLocalRootArkUINode() override { return m_stackNode; };
15
+ StackNode &getLocalRootArkUINode() override { return m_stackNode; };
16
16
 
17
- void onChildInserted(ComponentInstance::Shared const &childComponentInstance, std::size_t index) override {
18
- CppComponentInstance::onChildInserted(childComponentInstance, index);
19
- m_stackNode.insertChild(childComponentInstance->getLocalRootArkUINode(), index);
20
- };
17
+ void onChildInserted(ComponentInstance::Shared const &childComponentInstance, std::size_t index) override {
18
+ CppComponentInstance::onChildInserted(childComponentInstance, index);
19
+ m_stackNode.insertChild(childComponentInstance->getLocalRootArkUINode(), index);
20
+ };
21
21
 
22
- void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override {
23
- CppComponentInstance::onChildRemoved(childComponentInstance);
24
- m_stackNode.removeChild(childComponentInstance->getLocalRootArkUINode());
25
- };
22
+ void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override {
23
+ CppComponentInstance::onChildRemoved(childComponentInstance);
24
+ m_stackNode.removeChild(childComponentInstance->getLocalRootArkUINode());
26
25
  };
27
- } // namespace rnoh
26
+ };
27
+ } // namespace rnoh