@react-native-oh-tpl/react-native-gesture-handler 2.14.14 → 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 (26) 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/oh-package.json5 +2 -2
  4. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonComponentDescriptor.h +36 -0
  5. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonJSIBinder.h +32 -0
  6. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.cpp +22 -0
  7. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.h +15 -0
  8. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentDescriptor.h +36 -0
  9. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewJSIBinder.h +25 -0
  10. package/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.cpp +34 -0
  11. package/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.h +6 -0
  12. package/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerButtonComponentInstance.h +1 -1
  13. package/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerRootViewComponentInstance.h +1 -1
  14. package/harmony/gesture_handler/src/main/ets/gesture-handlers/PanGestureHandler.ts +14 -0
  15. package/harmony/gesture_handler/src/main/ets/namespace/RNGestureHandlerModule.ts +24 -0
  16. package/harmony/gesture_handler/src/main/ets/namespace/components/RNGestureHandlerButton.ts +139 -0
  17. package/harmony/gesture_handler/src/main/ets/namespace/components/RNGestureHandlerRootView.ts +101 -0
  18. package/harmony/gesture_handler/src/main/ets/namespace/components/ts.ts +2 -0
  19. package/harmony/gesture_handler/src/main/ets/namespace/ts.ts +2 -0
  20. package/harmony/gesture_handler/src/main/ets/rnoh/GestureHandlerPackage.ts +1 -1
  21. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootViewController.ts +17 -3
  22. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHView.ts +26 -3
  23. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHViewController.ts +1 -8
  24. package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerModule.ts +4 -4
  25. package/harmony/gesture_handler.har +0 -0
  26. package/package.json +1 -1
@@ -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.14';
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",
@@ -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.14',
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
  }
@@ -0,0 +1,36 @@
1
+
2
+ #pragma once
3
+
4
+ // This file was generated.
5
+
6
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
7
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
8
+ #include <react/renderer/components/view/ViewShadowNode.h>
9
+
10
+ namespace facebook {
11
+ namespace react {
12
+
13
+ extern const char RNGestureHandlerButtonComponentName[] = "RNGestureHandlerButton";
14
+
15
+ class RNGestureHandlerButtonProps : public ViewProps {
16
+ public:
17
+ RNGestureHandlerButtonProps() = default;
18
+
19
+ RNGestureHandlerButtonProps(const PropsParserContext &context, const RNGestureHandlerButtonProps &sourceProps, const RawProps &rawProps)
20
+ : ViewProps(context, sourceProps, rawProps) {}
21
+ };
22
+
23
+ using RNGestureHandlerButtonShadowNode = ConcreteViewShadowNode<
24
+ RNGestureHandlerButtonComponentName,
25
+ RNGestureHandlerButtonProps,
26
+ ViewEventEmitter>;
27
+
28
+ class RNGestureHandlerButtonComponentDescriptor final
29
+ : public ConcreteComponentDescriptor<RNGestureHandlerButtonShadowNode> {
30
+ public:
31
+ RNGestureHandlerButtonComponentDescriptor(ComponentDescriptorParameters const &parameters)
32
+ : ConcreteComponentDescriptor(parameters) {}
33
+ };
34
+
35
+ } // namespace react
36
+ } // namespace facebook
@@ -0,0 +1,32 @@
1
+ #pragma once
2
+
3
+ // This file was generated.
4
+
5
+ #include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
6
+
7
+ namespace rnoh {
8
+ class RNGestureHandlerButtonJSIBinder : public ViewComponentJSIBinder {
9
+ protected:
10
+ facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
11
+ auto object = ViewComponentJSIBinder::createNativeProps(rt);
12
+ object.setProperty(rt, "exclusive", true);
13
+ object.setProperty(rt, "foreground", true);
14
+ object.setProperty(rt, "borderless", true);
15
+ object.setProperty(rt, "enabled", true);
16
+ object.setProperty(rt, "rippleColor", true);
17
+ object.setProperty(rt, "rippleRadius", true);
18
+ object.setProperty(rt, "touchSoundDisabled", true);
19
+ return object;
20
+ }
21
+
22
+ facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override {
23
+ facebook::jsi::Object events(rt);
24
+ return events;
25
+ }
26
+
27
+ facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override {
28
+ facebook::jsi::Object events(rt);
29
+ return events;
30
+ }
31
+ };
32
+ } // namespace rnoh
@@ -0,0 +1,22 @@
1
+
2
+ #include "RNGestureHandlerModule.h"
3
+
4
+ // This file was generated.
5
+
6
+ namespace rnoh {
7
+ using namespace facebook;
8
+
9
+ RNGestureHandlerModule::RNGestureHandlerModule(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) {
10
+ methodMap_ = {
11
+ ARK_METHOD_METADATA(handleSetJSResponder, 2),
12
+ ARK_METHOD_METADATA(handleClearJSResponder, 0),
13
+ ARK_METHOD_METADATA(createGestureHandler, 3),
14
+ ARK_METHOD_METADATA(attachGestureHandler, 3),
15
+ ARK_METHOD_METADATA(updateGestureHandler, 2),
16
+ ARK_METHOD_METADATA(dropGestureHandler, 1),
17
+ ARK_METHOD_METADATA(install, 0),
18
+ ARK_METHOD_METADATA(flushOperations, 0),
19
+ };
20
+ }
21
+
22
+ } // namespace rnoh
@@ -0,0 +1,15 @@
1
+
2
+ #pragma once
3
+
4
+ // This file was generated.
5
+
6
+ #include "RNOH/ArkTSTurboModule.h"
7
+
8
+ namespace rnoh {
9
+
10
+ class JSI_EXPORT RNGestureHandlerModule : public ArkTSTurboModule {
11
+ public:
12
+ RNGestureHandlerModule(const ArkTSTurboModule::Context ctx, const std::string name);
13
+ };
14
+
15
+ } // namespace rnoh
@@ -0,0 +1,36 @@
1
+
2
+ #pragma once
3
+
4
+ // This file was generated.
5
+
6
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
7
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
8
+ #include <react/renderer/components/view/ViewShadowNode.h>
9
+
10
+ namespace facebook {
11
+ namespace react {
12
+
13
+ extern const char RNGestureHandlerRootViewComponentName[] = "RNGestureHandlerRootView";
14
+
15
+ class RNGestureHandlerRootViewProps : public ViewProps {
16
+ public:
17
+ RNGestureHandlerRootViewProps() = default;
18
+
19
+ RNGestureHandlerRootViewProps(const PropsParserContext &context, const RNGestureHandlerRootViewProps &sourceProps, const RawProps &rawProps)
20
+ : ViewProps(context, sourceProps, rawProps) {}
21
+ };
22
+
23
+ using RNGestureHandlerRootViewShadowNode = ConcreteViewShadowNode<
24
+ RNGestureHandlerRootViewComponentName,
25
+ RNGestureHandlerRootViewProps,
26
+ ViewEventEmitter>;
27
+
28
+ class RNGestureHandlerRootViewComponentDescriptor final
29
+ : public ConcreteComponentDescriptor<RNGestureHandlerRootViewShadowNode> {
30
+ public:
31
+ RNGestureHandlerRootViewComponentDescriptor(ComponentDescriptorParameters const &parameters)
32
+ : ConcreteComponentDescriptor(parameters) {}
33
+ };
34
+
35
+ } // namespace react
36
+ } // namespace facebook
@@ -0,0 +1,25 @@
1
+ #pragma once
2
+
3
+ // This file was generated.
4
+
5
+ #include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
6
+
7
+ namespace rnoh {
8
+ class RNGestureHandlerRootViewJSIBinder : public ViewComponentJSIBinder {
9
+ protected:
10
+ facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
11
+ auto object = ViewComponentJSIBinder::createNativeProps(rt);
12
+ return object;
13
+ }
14
+
15
+ facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override {
16
+ facebook::jsi::Object events(rt);
17
+ return events;
18
+ }
19
+
20
+ facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override {
21
+ facebook::jsi::Object events(rt);
22
+ return events;
23
+ }
24
+ };
25
+ } // namespace rnoh
@@ -3,12 +3,29 @@
3
3
  #include "RNOH/RNInstanceCAPI.h"
4
4
  #include "componentInstances/RNGestureHandlerButtonComponentInstance.h"
5
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"
6
12
  #include <glog/logging.h>
7
13
  #include <react/renderer/debug/SystraceSection.h>
8
14
 
9
15
  using namespace rnoh;
10
16
  using namespace facebook;
11
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
+
12
29
  class RNGHEventEmitRequestHandler : public EventEmitRequestHandler {
13
30
  void handleEvent(EventEmitRequestHandler::Context const &ctx) override {
14
31
  facebook::react::SystraceSection s("RNGH::RNGHEventEmitRequestHandler::handleEvent");
@@ -38,6 +55,23 @@ public:
38
55
  }
39
56
  };
40
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
+ };
41
75
 
42
76
  EventEmitRequestHandlers RnohReactNativeHarmonyGestureHandlerPackage::createEventEmitRequestHandlers() {
43
77
  return {
@@ -5,7 +5,13 @@ namespace rnoh {
5
5
  class RnohReactNativeHarmonyGestureHandlerPackage : public Package {
6
6
  public:
7
7
  RnohReactNativeHarmonyGestureHandlerPackage(Package::Context ctx) : Package(ctx) {}
8
+
9
+ std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override;
10
+
11
+ std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override;
8
12
 
13
+ ComponentJSIBinderByString createComponentJSIBinderByName() override;
14
+
9
15
  EventEmitRequestHandlers createEventEmitRequestHandlers();
10
16
 
11
17
  ComponentInstanceFactoryDelegate::Shared createComponentInstanceFactoryDelegate();
@@ -1,7 +1,7 @@
1
1
  #pragma once
2
2
  #import "RNOH/CppComponentInstance.h"
3
3
  #import "RNOH/arkui/StackNode.h"
4
- #import "generated/RNGestureHandlerButtonComponentDescriptor.h"
4
+ #import "../RNGestureHandlerButtonComponentDescriptor.h"
5
5
 
6
6
  namespace rnoh {
7
7
  class RNGestureHandlerButtonComponentInstance
@@ -4,7 +4,7 @@
4
4
  #import "RNOH/arkui/ArkUINodeRegistry.h"
5
5
  #import "RNOH/arkui/NativeNodeApi.h"
6
6
  #import "RNOH/RNInstanceCAPI.h"
7
- #import "generated/RNGestureHandlerRootViewComponentDescriptor.h"
7
+ #import "../RNGestureHandlerRootViewComponentDescriptor.h"
8
8
  #import "RNGestureHandlerButtonComponentInstance.h"
9
9
 
10
10
  namespace rnoh {
@@ -284,7 +284,13 @@ export class PanGestureHandler extends GestureHandler<PanGestureHandlerConfig> {
284
284
  if (this.currentState === State.ACTIVE) {
285
285
  this.lastPos = this.tracker.getLastAvgPos();
286
286
  }
287
+
287
288
  this.tracker.removeFromTracker(event.pointerId);
289
+
290
+ if (this.tracker.getTrackedPointersCount() === 0) {
291
+ this.clearActivationTimeout();
292
+ }
293
+
288
294
  if (this.currentState === State.ACTIVE) {
289
295
  this.end();
290
296
  } else {
@@ -358,4 +364,12 @@ export class PanGestureHandler extends GestureHandler<PanGestureHandlerConfig> {
358
364
  this.unlockRNGestureResponder?.()
359
365
  }
360
366
  }
367
+
368
+ protected onCancel(): void {
369
+ this.clearActivationTimeout();
370
+ }
371
+
372
+ protected onReset(): void {
373
+ this.clearActivationTimeout();
374
+ }
361
375
  }
@@ -0,0 +1,24 @@
1
+ // This file was generated.
2
+
3
+ export namespace RNGestureHandlerModule {
4
+ export const NAME = 'RNGestureHandlerModule' as const
5
+
6
+ export interface Spec {
7
+ handleSetJSResponder(tag: number, blockNativeResponder: boolean): void;
8
+
9
+ handleClearJSResponder(): void;
10
+
11
+ createGestureHandler(handlerName: string, handlerTag: number, config: Object): void;
12
+
13
+ attachGestureHandler(handlerTag: number, newView: number, actionType: number): void;
14
+
15
+ updateGestureHandler(handlerTag: number, newConfig: Object): void;
16
+
17
+ dropGestureHandler(handlerTag: number): void;
18
+
19
+ install(): boolean;
20
+
21
+ flushOperations(): void;
22
+
23
+ }
24
+ }
@@ -0,0 +1,139 @@
1
+ // This file was generated.
2
+ import {
3
+ Descriptor as ComponentDescriptor,
4
+ ViewBaseProps,
5
+ ViewRawProps,
6
+ ViewDescriptorWrapperBase,
7
+ ColorValue,
8
+ Color,
9
+ RNInstance,
10
+ Tag,
11
+ RNComponentCommandReceiver,
12
+ ViewPropsSelector,
13
+ } from '@rnoh/react-native-openharmony/ts';
14
+
15
+
16
+ export namespace RNGestureHandlerButton {
17
+ export const NAME = "RNGestureHandlerButton" as const
18
+
19
+ export interface DirectRawProps {
20
+ exclusive?: boolean;
21
+ foreground?: boolean;
22
+ borderless?: boolean;
23
+ enabled?: boolean;
24
+ rippleColor?: ColorValue;
25
+ rippleRadius?: number;
26
+ touchSoundDisabled?: boolean;
27
+ }
28
+
29
+ export interface Props extends ViewBaseProps {}
30
+
31
+ export interface State {}
32
+
33
+ export interface RawProps extends ViewRawProps, DirectRawProps {}
34
+
35
+ export class PropsSelector extends ViewPropsSelector<Props, RawProps> {
36
+ get exclusive() {
37
+ return this.rawProps.exclusive ?? true;
38
+ }
39
+
40
+ get foreground() {
41
+ return this.rawProps.foreground ?? false;
42
+ }
43
+
44
+ get borderless() {
45
+ return this.rawProps.borderless ?? false;
46
+ }
47
+
48
+ get enabled() {
49
+ return this.rawProps.enabled ?? true;
50
+ }
51
+
52
+ get rippleRadius() {
53
+ return this.rawProps.rippleRadius ?? 0;
54
+ }
55
+
56
+ get touchSoundDisabled() {
57
+ return this.rawProps.touchSoundDisabled ?? false;
58
+ }
59
+
60
+
61
+ get rippleColor() {
62
+ if (this.rawProps.rippleColor) {
63
+ return Color.fromColorValue(this.rawProps.rippleColor)
64
+ } else {
65
+ return new Color({ r: 0, g: 0, b: 0, a: 255})
66
+ }
67
+ }
68
+
69
+ }
70
+
71
+ export type Descriptor = ComponentDescriptor<
72
+ typeof NAME,
73
+ Props,
74
+ State,
75
+ RawProps
76
+ >;
77
+
78
+ export class DescriptorWrapper extends ViewDescriptorWrapperBase<
79
+ typeof NAME,
80
+ Props,
81
+ State,
82
+ RawProps,
83
+ PropsSelector
84
+ > {
85
+ protected createPropsSelector() {
86
+ return new PropsSelector(this.descriptor.props, this.descriptor.rawProps)
87
+ }
88
+ }
89
+
90
+ export interface EventPayloadByName {
91
+ }
92
+
93
+ export class EventEmitter {
94
+ constructor(private rnInstance: RNInstance, private tag: Tag) {}
95
+
96
+ emit<TEventName extends keyof EventPayloadByName>(eventName: TEventName, payload: EventPayloadByName[TEventName]) {
97
+ this.rnInstance.emitComponentEvent(this.tag, eventName, payload)
98
+ }
99
+ }
100
+
101
+ export interface CommandArgvByName {
102
+ }
103
+
104
+ export class CommandReceiver {
105
+ private listenersByCommandName = new Map<string, Set<(...args: any[]) => void>>()
106
+ private cleanUp: (() => void) | undefined = undefined
107
+
108
+ constructor(private componentCommandReceiver: RNComponentCommandReceiver, private tag: Tag) {
109
+ }
110
+
111
+ subscribe<TCommandName extends keyof CommandArgvByName>(commandName: TCommandName, listener: (argv: CommandArgvByName[TCommandName]) => void) {
112
+ if (!this.listenersByCommandName.has(commandName)) {
113
+ this.listenersByCommandName.set(commandName, new Set())
114
+ }
115
+ this.listenersByCommandName.get(commandName)!.add(listener)
116
+ const hasRegisteredCommandReceiver = !!this.cleanUp
117
+ if (!hasRegisteredCommandReceiver) {
118
+ this.cleanUp = this.componentCommandReceiver.registerCommandCallback(this.tag, (commandName: string, argv: any[]) => {
119
+ if (this.listenersByCommandName.has(commandName)) {
120
+ const listeners = this.listenersByCommandName.get(commandName)!
121
+ listeners.forEach(listener => {
122
+ listener(argv)
123
+ })
124
+ }
125
+ })
126
+ }
127
+
128
+ return () => {
129
+ this.listenersByCommandName.get(commandName)?.delete(listener)
130
+ if (this.listenersByCommandName.get(commandName)?.size ?? 0 === 0) {
131
+ this.listenersByCommandName.delete(commandName)
132
+ }
133
+ if (this.listenersByCommandName.size === 0) {
134
+ this.cleanUp?.()
135
+ }
136
+ }
137
+ }
138
+ }
139
+ }
@@ -0,0 +1,101 @@
1
+ // This file was generated.
2
+ import {
3
+ Descriptor as ComponentDescriptor,
4
+ ViewBaseProps,
5
+ ViewRawProps,
6
+ ViewDescriptorWrapperBase,
7
+ ColorValue,
8
+ Color,
9
+ RNInstance,
10
+ Tag,
11
+ RNComponentCommandReceiver,
12
+ ViewPropsSelector,
13
+ } from '@rnoh/react-native-openharmony/ts';
14
+
15
+
16
+ export namespace RNGestureHandlerRootView {
17
+ export const NAME = "RNGestureHandlerRootView" as const
18
+
19
+ export interface DirectRawProps {
20
+ }
21
+
22
+ export interface Props extends ViewBaseProps {}
23
+
24
+ export interface State {}
25
+
26
+ export interface RawProps extends ViewRawProps, DirectRawProps {}
27
+
28
+ export class PropsSelector extends ViewPropsSelector<Props, RawProps> {
29
+
30
+ }
31
+
32
+ export type Descriptor = ComponentDescriptor<
33
+ typeof NAME,
34
+ Props,
35
+ State,
36
+ RawProps
37
+ >;
38
+
39
+ export class DescriptorWrapper extends ViewDescriptorWrapperBase<
40
+ typeof NAME,
41
+ Props,
42
+ State,
43
+ RawProps,
44
+ PropsSelector
45
+ > {
46
+ protected createPropsSelector() {
47
+ return new PropsSelector(this.descriptor.props, this.descriptor.rawProps)
48
+ }
49
+ }
50
+
51
+ export interface EventPayloadByName {
52
+ }
53
+
54
+ export class EventEmitter {
55
+ constructor(private rnInstance: RNInstance, private tag: Tag) {}
56
+
57
+ emit<TEventName extends keyof EventPayloadByName>(eventName: TEventName, payload: EventPayloadByName[TEventName]) {
58
+ this.rnInstance.emitComponentEvent(this.tag, eventName, payload)
59
+ }
60
+ }
61
+
62
+ export interface CommandArgvByName {
63
+ }
64
+
65
+ export class CommandReceiver {
66
+ private listenersByCommandName = new Map<string, Set<(...args: any[]) => void>>()
67
+ private cleanUp: (() => void) | undefined = undefined
68
+
69
+ constructor(private componentCommandReceiver: RNComponentCommandReceiver, private tag: Tag) {
70
+ }
71
+
72
+ subscribe<TCommandName extends keyof CommandArgvByName>(commandName: TCommandName, listener: (argv: CommandArgvByName[TCommandName]) => void) {
73
+ if (!this.listenersByCommandName.has(commandName)) {
74
+ this.listenersByCommandName.set(commandName, new Set())
75
+ }
76
+ this.listenersByCommandName.get(commandName)!.add(listener)
77
+ const hasRegisteredCommandReceiver = !!this.cleanUp
78
+ if (!hasRegisteredCommandReceiver) {
79
+ this.cleanUp = this.componentCommandReceiver.registerCommandCallback(this.tag, (commandName: string, argv: any[]) => {
80
+ if (this.listenersByCommandName.has(commandName)) {
81
+ const listeners = this.listenersByCommandName.get(commandName)!
82
+ listeners.forEach(listener => {
83
+ listener(argv)
84
+ })
85
+ }
86
+ })
87
+ }
88
+
89
+ return () => {
90
+ this.listenersByCommandName.get(commandName)?.delete(listener)
91
+ if (this.listenersByCommandName.get(commandName)?.size ?? 0 === 0) {
92
+ this.listenersByCommandName.delete(commandName)
93
+ }
94
+ if (this.listenersByCommandName.size === 0) {
95
+ this.cleanUp?.()
96
+ }
97
+ }
98
+ }
99
+ }
100
+
101
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./RNGestureHandlerButton"
2
+ export * from "./RNGestureHandlerRootView"
@@ -0,0 +1,2 @@
1
+ export * as RNC from "./components/ts"
2
+ export * as TM from "./RNGestureHandlerModule"
@@ -19,7 +19,7 @@ class GestureHandlerTurboModuleFactory extends TurboModulesFactory {
19
19
  * @deprecated: Use the package class exported from ../RNOHPackage.ets (2024-10-10)
20
20
  */
21
21
  export class GestureHandlerPackage extends RNPackage {
22
- createUITurboModuleFactory(ctx: TurboModuleContext): TurboModulesFactory {
22
+ createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
23
23
  return new GestureHandlerTurboModuleFactory(ctx);
24
24
  }
25
25
  }
@@ -1,6 +1,6 @@
1
1
  import { TouchEvent as TouchEventArkTS, TouchType, TouchObject } from './types';
2
2
  import { RNGHLogger, View, Multiset, GestureHandlerRegistry } from '../core';
3
- import { RawTouchableView } from "./RNGHView"
3
+ import { RawTouchableView, RNGHView } from "./RNGHView"
4
4
  import { RNGHViewController } from './RNGHViewController';
5
5
 
6
6
  type RawTouchPoint = {
@@ -59,8 +59,9 @@ export class RNGHRootViewController {
59
59
  if (e.type === TouchType.Down) {
60
60
  this.activeViewTags.clear();
61
61
  }
62
- const views = touchableViews
63
- for (const view of views) {
62
+ const views = touchableViews as RNGHView[]
63
+ for (let i = 0; i < views.length; i++) {
64
+ const view = views[i];
64
65
  for (const handler of this.gestureHandlerRegistry.getGestureHandlersByViewTag(
65
66
  view.getTag(),
66
67
  )) {
@@ -87,6 +88,19 @@ export class RNGHRootViewController {
87
88
  this.activeViewTags.add(view.getTag());
88
89
  }
89
90
  }
91
+
92
+ // If the pointer is inside the view but it overflows its parent, handlers attached to the parent
93
+ // might not have been called correctly (wrong bounding box). Extending the parent bounding box
94
+ // with the child bounding box ensures that the parent handlers are called correctly.
95
+ // This approach is slightly different from Android RNGH implementation (extracting parent gesture handlers),
96
+ // however, the outcome is the same.
97
+ for (let j = i; j > 1; j--) {
98
+ const currentView = views[j];
99
+ const parentView = views[j-1];
100
+ if (parentView.intersectsWith(currentView)) {
101
+ parentView.attachChildrenBoundingRects(currentView);
102
+ }
103
+ }
90
104
  }
91
105
 
92
106
  // send touch to gesture handlers, prioritize handling touch events for child components
@@ -20,6 +20,7 @@ export class RNGHView implements View {
20
20
  private tag: number
21
21
  private buttonRole: boolean
22
22
  private boundingBox: BoundingBox
23
+ private childrenBoundingBoxes: Set<BoundingBox> = new Set()
23
24
 
24
25
  constructor({ tag, buttonRole, ...boundingBox }: RawTouchableView) {
25
26
  this.tag = tag
@@ -35,23 +36,45 @@ export class RNGHView implements View {
35
36
  return { ...this.boundingBox }
36
37
  }
37
38
 
39
+ getChildrenBoundingRects(): BoundingBox[] {
40
+ return Array.from(this.childrenBoundingBoxes)
41
+ }
42
+
38
43
  isPositionInBounds({ x, y }: {
39
44
  x: number;
40
45
  y: number
41
46
  }): boolean {
42
- const rect = this.getBoundingRect();
43
- return (
47
+ const rects = [this.boundingBox, ...this.childrenBoundingBoxes]
48
+ return rects.some(rect => (
44
49
  x >= rect.x &&
45
50
  x <= rect.x + rect.width &&
46
51
  y >= rect.y &&
47
52
  y <= rect.y + rect.height
48
- );
53
+ ))
49
54
  }
50
55
 
51
56
  updateBoundingBox(boundingBox: BoundingBox) {
52
57
  this.boundingBox = boundingBox
53
58
  }
54
59
 
60
+ attachChildrenBoundingRects(view: RNGHView) {
61
+ this.childrenBoundingBoxes.add(view.getBoundingRect())
62
+ for (const childBoundingBox of view.getChildrenBoundingRects()) {
63
+ this.childrenBoundingBoxes.add(childBoundingBox)
64
+ }
65
+ }
66
+
67
+ intersectsWith(view: RNGHView): boolean {
68
+ const rect1 = this.getBoundingRect()
69
+ const rect2 = view.getBoundingRect()
70
+ return (
71
+ rect1.x < rect2.x + rect2.width &&
72
+ rect1.x + rect1.width > rect2.x &&
73
+ rect1.y < rect2.y + rect2.height &&
74
+ rect1.y + rect1.height > rect2.y
75
+ )
76
+ }
77
+
55
78
  setButtonRole(buttonRole: boolean) {
56
79
  this.buttonRole = buttonRole
57
80
  }
@@ -165,16 +165,9 @@ export class RNGHViewController {
165
165
  }
166
166
 
167
167
  private isInBounds(point: Point): boolean {
168
- const x = point.x;
169
- const y = point.y;
170
168
  const rect = this.view.getBoundingRect();
171
169
  this.logger.cloneAndJoinPrefix("isInBounds").debug({ rect })
172
- const result =
173
- x >= rect.x &&
174
- x <= rect.x + rect.width &&
175
- y >= rect.y &&
176
- y <= rect.y + rect.height;
177
- return result;
170
+ return this.view.isPositionInBounds(point);
178
171
  }
179
172
 
180
173
  private updateActivePointers(touchType: TouchType, pointerId: number): void {
@@ -1,5 +1,5 @@
1
- import { UITurboModule, UITurboModuleContext, Tag } from "@rnoh/react-native-openharmony/ts";
2
- import { TM } from "@rnoh/react-native-openharmony/generated/ts"
1
+ import { TurboModule, TurboModuleContext, Tag } from "@rnoh/react-native-openharmony/ts";
2
+ import { TM } from "../namespace/ts"
3
3
  import {
4
4
  GestureHandlerRegistry,
5
5
  State,
@@ -25,7 +25,7 @@ export enum ActionType {
25
25
  }
26
26
 
27
27
 
28
- export class RNGestureHandlerModule extends UITurboModule implements TM.RNGestureHandlerModule.Spec {
28
+ export class RNGestureHandlerModule extends TurboModule implements TM.RNGestureHandlerModule.Spec {
29
29
  static readonly NAME = "RNGestureHandlerModule"
30
30
 
31
31
  private gestureHandlerRegistry: GestureHandlerRegistry
@@ -36,7 +36,7 @@ export class RNGestureHandlerModule extends UITurboModule implements TM.RNGestur
36
36
  private rootViewControllerByRootTag = new Map<Tag, RNGHRootViewController>()
37
37
  private interactionManager: InteractionManager
38
38
 
39
- constructor(ctx: UITurboModuleContext, isDevModeEnabled: boolean = false) {
39
+ constructor(ctx: TurboModuleContext, isDevModeEnabled: boolean = false) {
40
40
  super(ctx)
41
41
  this.cleanLogger =
42
42
  isDevModeEnabled && ctx.isDebugModeEnabled ? new DevelopmentRNGHLogger(ctx.logger, "RNGH") :
Binary file
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "type": "git",
18
18
  "url": "https://github.com/react-native-oh-library/react-native-harmony-gesture-handler.git"
19
19
  },
20
- "version": "2.14.14",
20
+ "version": "2.14.15",
21
21
  "description": "",
22
22
  "react-native": "src/index.ts",
23
23
  "main": "lib/commonjs/index.js",