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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. package/harmony/gesture_handler/BuildProfile.ets +1 -1
  2. package/harmony/gesture_handler/index.ets +1 -2
  3. package/harmony/gesture_handler/oh-package-lock.json5 +1 -1
  4. package/harmony/gesture_handler/oh-package.json5 +1 -1
  5. package/harmony/gesture_handler/src/main/cpp/CMakeLists.txt +1 -1
  6. package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.h +9 -18
  7. package/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.cpp +123 -0
  8. package/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.h +15 -0
  9. package/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerButtonComponentInstance.h +17 -17
  10. package/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerRootViewComponentInstance.h +203 -200
  11. package/harmony/gesture_handler/src/main/ets/RNOHPackage.ets +17 -0
  12. package/harmony/gesture_handler/src/main/ets/core/GestureHandler.ts +84 -35
  13. package/harmony/gesture_handler/src/main/ets/core/GestureHandlerOrchestrator.ts +20 -11
  14. package/harmony/gesture_handler/src/main/ets/core/GestureHandlerRegistry.ts +2 -2
  15. package/harmony/gesture_handler/src/main/ets/core/InteractionManager.ts +4 -4
  16. package/harmony/gesture_handler/src/main/ets/core/Multiset.ts +26 -0
  17. package/harmony/gesture_handler/src/main/ets/core/RNGHLogger.ts +7 -3
  18. package/harmony/gesture_handler/src/main/ets/core/ViewRegistry.ts +1 -2
  19. package/harmony/gesture_handler/src/main/ets/core/index.ts +2 -2
  20. package/harmony/gesture_handler/src/main/ets/gesture-handlers/FlingGestureHandler.ts +12 -4
  21. package/harmony/gesture_handler/src/main/ets/gesture-handlers/GestureHandlerFactory.ts +8 -5
  22. package/harmony/gesture_handler/src/main/ets/gesture-handlers/LongPressGestureHandler.ts +14 -2
  23. package/harmony/gesture_handler/src/main/ets/gesture-handlers/ManualGestureHandler.ts +9 -1
  24. package/harmony/gesture_handler/src/main/ets/gesture-handlers/NativeViewGestureHandler.ts +13 -4
  25. package/harmony/gesture_handler/src/main/ets/gesture-handlers/PanGestureHandler.ts +31 -12
  26. package/harmony/gesture_handler/src/main/ets/gesture-handlers/PinchGestureHandler.ts +145 -130
  27. package/harmony/gesture_handler/src/main/ets/gesture-handlers/RotationGestureHandler.ts +9 -1
  28. package/harmony/gesture_handler/src/main/ets/gesture-handlers/TapGestureHandler.ts +15 -5
  29. package/harmony/gesture_handler/src/main/ets/rnoh/GestureHandlerPackage.ts +7 -4
  30. package/harmony/gesture_handler/src/main/ets/rnoh/Logger.ts +74 -16
  31. package/harmony/gesture_handler/src/main/ets/rnoh/OutgoingEventDispatchers.ts +35 -12
  32. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootViewController.ts +182 -0
  33. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHView.ts +62 -0
  34. package/harmony/gesture_handler/src/main/ets/rnoh/{GestureHandlerArkUIAdapter.ts → RNGHViewController.ts} +44 -22
  35. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHViewRegistry.ts +19 -0
  36. package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerModule.ts +130 -96
  37. package/harmony/gesture_handler/src/main/ets/rnoh/RNOHGestureResponder.ts +0 -9
  38. package/harmony/gesture_handler/src/main/ets/rnoh/RNOHScrollLocker.ts +1 -8
  39. package/harmony/gesture_handler.har +0 -0
  40. package/package.json +7 -3
  41. package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.cpp +0 -149
  42. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonComponentDescriptor.h +0 -36
  43. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonJSIBinder.h +0 -32
  44. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.cpp +0 -22
  45. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.h +0 -15
  46. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentDescriptor.h +0 -36
  47. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewJSIBinder.h +0 -25
  48. package/harmony/gesture_handler/src/main/ets/core/ViewFinder.ts +0 -11
  49. package/harmony/gesture_handler/src/main/ets/namespace/RNGestureHandlerModule.ts +0 -24
  50. package/harmony/gesture_handler/src/main/ets/namespace/components/RNGestureHandlerButton.ts +0 -139
  51. package/harmony/gesture_handler/src/main/ets/namespace/components/RNGestureHandlerRootView.ts +0 -101
  52. package/harmony/gesture_handler/src/main/ets/namespace/components/ts.ts +0 -2
  53. package/harmony/gesture_handler/src/main/ets/namespace/ts.ts +0 -2
  54. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootTouchHandlerArkTS.ts +0 -98
  55. package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootTouchHandlerCAPI.ts +0 -110
  56. package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerButton.ets +0 -38
  57. package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerRootView.ets +0 -53
  58. package/harmony/gesture_handler/src/main/ets/rnoh/View.ts +0 -134
  59. package/harmony/gesture_handler/src/main/ets/rnoh/ViewRegistry.ts +0 -97
@@ -1,15 +1,21 @@
1
- import { TurboModule, TurboModuleContext, Tag } from "@rnoh/react-native-openharmony/ts";
2
- import { TM } from "../namespace/ts"
3
- import { GestureHandlerRegistry, State, OutgoingEventDispatcher, RNGHLogger, InteractionManager, ViewRegistry } from '../core';
1
+ import { UITurboModule, UITurboModuleContext, Tag } from "@rnoh/react-native-openharmony/ts";
2
+ import { TM } from "@rnoh/react-native-openharmony/generated/ts"
3
+ import {
4
+ GestureHandlerRegistry,
5
+ State,
6
+ OutgoingEventDispatcher,
7
+ RNGHLogger,
8
+ InteractionManager,
9
+ ViewRegistry
10
+ } from '../core';
4
11
  import { GestureHandlerFactory } from "../gesture-handlers"
5
- import { ViewRegistryArkTS, ViewRegistryCAPI } from './ViewRegistry';
6
- import { StandardRNGHLogger, FakeRNGHLogger } from './Logger';
12
+ import { RNGHViewRegistry } from './RNGHViewRegistry';
13
+ import { DevelopmentRNGHLogger, ProductionRNGHLogger } from './Logger';
7
14
  import { JSEventDispatcher, AnimatedEventDispatcher, ReanimatedEventDispatcher } from './OutgoingEventDispatchers'
8
- import { RNOHScrollLockerArkTS, RNOHScrollLockerCAPI } from "./RNOHScrollLocker"
9
- import { RNGHRootTouchHandlerCAPI, RawTouchEvent } from "./RNGHRootTouchHandlerCAPI"
10
- import { RNGHRootTouchHandlerArkTS } from './RNGHRootTouchHandlerArkTS';
11
- import { ViewCAPI } from "./View"
12
- import { FakeRNGestureResponder, RNOHGestureResponder } from "./RNOHGestureResponder"
15
+ import { RNOHScrollLockerCAPI } from "./RNOHScrollLocker"
16
+ import { RNGHRootViewController, RawTouchEvent } from "./RNGHRootViewController"
17
+ import { RNGHView } from "./RNGHView"
18
+ import { RNOHGestureResponder } from "./RNOHGestureResponder"
13
19
 
14
20
  export enum ActionType {
15
21
  REANIMATED_WORKLET = 1,
@@ -19,23 +25,27 @@ export enum ActionType {
19
25
  }
20
26
 
21
27
 
22
- export class RNGestureHandlerModule extends TurboModule implements TM.RNGestureHandlerModule.Spec {
23
- static NAME = "RNGestureHandlerModule"
28
+ export class RNGestureHandlerModule extends UITurboModule implements TM.RNGestureHandlerModule.Spec {
29
+ static readonly NAME = "RNGestureHandlerModule"
24
30
 
25
31
  private gestureHandlerRegistry: GestureHandlerRegistry
26
32
  private gestureHandlerFactory: GestureHandlerFactory | undefined = undefined
27
33
  private viewRegistry: ViewRegistry | undefined = undefined
28
34
  private logger: RNGHLogger
29
- private touchHandlerByRootTag = new Map<Tag, RNGHRootTouchHandlerCAPI>()
35
+ private cleanLogger: RNGHLogger
36
+ private rootViewControllerByRootTag = new Map<Tag, RNGHRootViewController>()
30
37
  private interactionManager: InteractionManager
31
38
 
32
- constructor(ctx: TurboModuleContext) {
39
+ constructor(ctx: UITurboModuleContext, isDevModeEnabled: boolean = false) {
33
40
  super(ctx)
34
- const debug = false
35
- this.logger = debug ? new StandardRNGHLogger(ctx.logger, "RNGH") : new FakeRNGHLogger()
36
- this.interactionManager = new InteractionManager(this.logger)
37
- this.gestureHandlerRegistry = new GestureHandlerRegistry(this.viewRegistry, this.logger)
38
-
41
+ this.cleanLogger =
42
+ isDevModeEnabled && ctx.isDebugModeEnabled ? new DevelopmentRNGHLogger(ctx.logger, "RNGH") :
43
+ new ProductionRNGHLogger(ctx.logger, "RNGH")
44
+ this.logger = this.cleanLogger.cloneAndJoinPrefix("RNGestureHandlerModule")
45
+ const logger = this.logger.cloneAndJoinPrefix("constructor")
46
+ const stopTracing = logger.startTracing()
47
+ this.interactionManager = new InteractionManager(this.cleanLogger)
48
+ this.gestureHandlerRegistry = new GestureHandlerRegistry(this.viewRegistry, this.cleanLogger)
39
49
  if (this.ctx.rnInstance.getArchitecture() === "C_API") {
40
50
  this.ctx.rnInstance.cppEventEmitter.subscribe("RNGH::TOUCH_EVENT", (e: any) => {
41
51
  this.onTouch(e)
@@ -44,60 +54,67 @@ export class RNGestureHandlerModule extends TurboModule implements TM.RNGestureH
44
54
  this.onGHRootCreated(rootTag)
45
55
  })
46
56
  this.ctx.rnInstance.cppEventEmitter.subscribe("RNGH::CANCEL_TOUCHES", (rootTag: any) => {
47
- const touchHandler = this.touchHandlerByRootTag.get(rootTag)
57
+ const touchHandler = this.rootViewControllerByRootTag.get(rootTag)
48
58
  touchHandler?.cancelTouches()
49
59
  })
50
60
  }
61
+ stopTracing()
51
62
  }
52
63
 
53
64
  /**
54
- * @architecture: C-API
55
65
  * Called from C++.
56
66
  */
57
67
  private onGHRootCreated(rootTag: Tag) {
58
- this.touchHandlerByRootTag.set(rootTag, new RNGHRootTouchHandlerCAPI(this.logger, new RNGHRootTouchHandlerArkTS(rootTag, this.viewRegistry, this.gestureHandlerRegistry, this.logger)));
68
+ const stopTracing = this.logger.cloneAndJoinPrefix("onGHRootCreated").startTracing()
69
+ this.rootViewControllerByRootTag.set(rootTag, new RNGHRootViewController(this.logger, this.gestureHandlerRegistry));
70
+ stopTracing()
59
71
  }
60
72
 
61
73
  /**
62
- * @architecture: C-API
63
74
  * Called from C++.
64
75
  */
65
76
  private onTouch(e: RawTouchEvent & { rootTag: Tag }) {
66
- const logger = this.logger.cloneWithPrefix("onTouch")
67
- if (!(this.viewRegistry instanceof ViewRegistryCAPI)) {
68
- logger.error("Expected ViewRegistryCAPI")
69
- return;
70
- }
71
- const touchHandler = this.touchHandlerByRootTag.get(e.rootTag)
72
- if (!touchHandler) {
73
- logger.error(`Couldn't find touch handler for gesture root tag: ${e.rootTag}`)
74
- return;
75
- }
76
- // update view registry
77
- e.touchableViews.forEach(touchableView => {
78
- const view = this.viewRegistry.getViewByTag(touchableView.tag)
79
- if (view) {
80
- if (!(view instanceof ViewCAPI)) {
81
- logger.error(`Expected ViewCAPI`)
82
- return
83
- }
84
- view.updateBoundingBox(touchableView)
85
- view.setButtonRole(touchableView.buttonRole)
86
- } else {
87
- this.viewRegistry.save(new ViewCAPI(touchableView))
77
+ const logger = this.logger.cloneAndJoinPrefix("onTouch")
78
+ const stopTracing = logger.startTracing();
79
+ (() => {
80
+ if (!(this.viewRegistry instanceof RNGHViewRegistry)) {
81
+ logger.error("Expected ViewRegistryCAPI")
82
+ return;
83
+ }
84
+ const rootViewController = this.rootViewControllerByRootTag.get(e.rootTag)
85
+ if (!rootViewController) {
86
+ logger.error(`Couldn't find a rootViewController for a gesture root tag: ${e.rootTag}`)
87
+ return;
88
88
  }
89
- })
90
- // relay touch
91
- touchHandler.handleTouch(e, e.touchableViews.map(({tag}) => this.viewRegistry.getViewByTag(tag)));
89
+ // update view registry
90
+ e.touchableViews.forEach(touchableView => {
91
+ const view = this.viewRegistry.getViewByTag(touchableView.tag)
92
+ if (view) {
93
+ if (!(view instanceof RNGHView)) {
94
+ logger.error(`Expected ViewCAPI`)
95
+ return
96
+ }
97
+ view.updateBoundingBox(touchableView)
98
+ view.setButtonRole(touchableView.buttonRole)
99
+ } else {
100
+ this.viewRegistry.save(new RNGHView(touchableView))
101
+ }
102
+ })
103
+ rootViewController.handleTouch(e, e.touchableViews.map(({ tag }) => this.viewRegistry.getViewByTag(tag)));
104
+ })()
105
+ stopTracing()
92
106
  }
93
107
 
94
108
  // -------------------------------------------------------------------------------------------------------------------
95
109
 
96
110
  public install() {
97
- this.viewRegistry = this.ctx.rnInstance.getArchitecture() === "ARK_TS" ? new ViewRegistryArkTS(this.ctx.descriptorRegistry) : new ViewRegistryCAPI()
98
- const scrollLocker = this.ctx.rnInstance.getArchitecture() === "ARK_TS" ? new RNOHScrollLockerArkTS(this.ctx.rnInstance) : new RNOHScrollLockerCAPI(this.ctx.rnInstance, this.logger);
99
- const rnGestureResponder = this.ctx.rnInstance.getArchitecture() === "ARK_TS" ? new FakeRNGestureResponder() : new RNOHGestureResponder(this.ctx.rnInstance)
100
- this.gestureHandlerFactory = new GestureHandlerFactory(this.logger, scrollLocker, this.interactionManager, rnGestureResponder)
111
+ const stopTracing = this.ctx.logger.clone("install").startTracing()
112
+ this.viewRegistry = new RNGHViewRegistry()
113
+ const scrollLocker = new RNOHScrollLockerCAPI(this.ctx.rnInstance, this.cleanLogger);
114
+ const rnGestureResponder = new RNOHGestureResponder(this.ctx.rnInstance)
115
+ this.gestureHandlerFactory =
116
+ new GestureHandlerFactory(this.cleanLogger, scrollLocker, this.interactionManager, rnGestureResponder)
117
+ stopTracing()
101
118
  return true
102
119
  }
103
120
 
@@ -106,16 +123,20 @@ export class RNGestureHandlerModule extends TurboModule implements TM.RNGestureH
106
123
  handlerTag: number,
107
124
  config: Readonly<Record<string, unknown>>
108
125
  ) {
109
- const logger = this.logger.cloneWithPrefix("createGestureHandler")
110
- if (!this.gestureHandlerFactory) {
111
- this.ctx.logger.error("Trying to create a gesture handler before creating gesture handler factory")
112
- return
113
- }
114
- logger.debug({ handlerName, handlerTag, config })
115
- const gestureHandler = this.gestureHandlerFactory.create(handlerName, handlerTag)
116
- this.gestureHandlerRegistry.addGestureHandler(gestureHandler)
117
- this.interactionManager.configureInteractions(gestureHandler, config);
118
- gestureHandler.updateGestureConfig(config)
126
+ const logger = this.logger.cloneAndJoinPrefix("createGestureHandler")
127
+ const stopTracing = logger.startTracing();
128
+ (() => {
129
+ if (!this.gestureHandlerFactory) {
130
+ logger.error("Trying to create a gesture handler before creating gesture handler factory")
131
+ return
132
+ }
133
+ logger.debug({ handlerName, handlerTag, config })
134
+ const gestureHandler = this.gestureHandlerFactory.create(handlerName, handlerTag)
135
+ this.gestureHandlerRegistry.addGestureHandler(gestureHandler)
136
+ this.interactionManager.configureInteractions(gestureHandler, config);
137
+ gestureHandler.updateGestureConfig(config)
138
+ })()
139
+ stopTracing()
119
140
  }
120
141
 
121
142
  public attachGestureHandler(
@@ -123,43 +144,55 @@ export class RNGestureHandlerModule extends TurboModule implements TM.RNGestureH
123
144
  viewTag: number,
124
145
  actionType: ActionType
125
146
  ) {
126
- const eventDispatcher = this.createEventDispatcher(actionType, viewTag)
127
- if (!eventDispatcher) {
128
- this.ctx.logger.error("RNGH: Couldn't create EventDispatcher")
129
- return
130
- }
131
- const viewRegistry = this.viewRegistry
132
- let view = this.viewRegistry.getViewByTag(viewTag)
133
- if (!view && viewRegistry instanceof ViewRegistryCAPI) {
134
- view = new ViewCAPI({
135
- tag: viewTag,
136
- x: 0,
137
- y: 0,
138
- width: 0,
139
- height: 0,
140
- buttonRole: false
147
+ const logger = this.logger.cloneAndJoinPrefix("attachGestureHandler")
148
+ const stopTracing = logger.startTracing();
149
+ (() => {
150
+ const eventDispatcher = this.createEventDispatcher(actionType, viewTag)
151
+ if (!eventDispatcher) {
152
+ logger.error("RNGH: Couldn't create EventDispatcher")
153
+ return
154
+ }
155
+ const viewRegistry = this.viewRegistry
156
+ let view = this.viewRegistry.getViewByTag(viewTag)
157
+ if (!view && viewRegistry instanceof RNGHViewRegistry) {
158
+ view = new RNGHView({
159
+ tag: viewTag,
160
+ x: 0,
161
+ y: 0,
162
+ width: 0,
163
+ height: 0,
164
+ buttonRole: false
165
+ })
166
+ viewRegistry.save(view)
167
+ }
168
+ if (!view) {
169
+ logger.error("Expected view")
170
+ return;
171
+ }
172
+ this.gestureHandlerRegistry.bindGestureHandlerWithView(handlerTag, view)
173
+ this.gestureHandlerRegistry.getGestureHandlersByViewTag(view.getTag()).forEach((handler) => {
174
+ if (handler.isGestureContinuous() && eventDispatcher instanceof JSEventDispatcher) {
175
+ logger.warn(`Using JSEventDispatcher for a continuous gesture (${handler.getName()}). Gesture-driven animations may not be smooth. Consider using Animated.event.`)
176
+ }
141
177
  })
142
- viewRegistry.save(view)
143
- }
144
- if (!view) {
145
- this.ctx.logger.error("Expected view")
146
- return;
147
- }
148
- this.gestureHandlerRegistry.bindGestureHandlerWithView(handlerTag, view)
149
- this.gestureHandlerRegistry
150
- .getGestureHandlerByHandlerTag(handlerTag)
151
- .setEventDispatcher(eventDispatcher)
178
+ this.gestureHandlerRegistry
179
+ .getGestureHandlerByHandlerTag(handlerTag)
180
+ .setEventDispatcher(eventDispatcher)
181
+ })()
182
+ stopTracing()
152
183
  }
153
184
 
154
185
  private createEventDispatcher(actionType: ActionType, viewTag: number): OutgoingEventDispatcher | null {
155
186
  switch (actionType) {
156
187
  case ActionType.REANIMATED_WORKLET:
157
- return new ReanimatedEventDispatcher(this.ctx.rnInstance, this.logger.cloneWithPrefix('ReanimatedEventDispatcher'), viewTag)
188
+ return new ReanimatedEventDispatcher(this.ctx.rnInstance,
189
+ this.cleanLogger, viewTag)
158
190
  case ActionType.NATIVE_ANIMATED_EVENT:
159
- return new AnimatedEventDispatcher(this.ctx.rnInstance, this.logger.cloneWithPrefix('AnimatedEventDispatcher'), viewTag)
191
+ return new AnimatedEventDispatcher(this.ctx.rnInstance,
192
+ this.cleanLogger, viewTag)
160
193
  case ActionType.JS_FUNCTION_OLD_API:
161
194
  case ActionType.JS_FUNCTION_NEW_API:
162
- return new JSEventDispatcher(this.ctx.rnInstance, this.logger.cloneWithPrefix('JSEventDispatcher'));
195
+ return new JSEventDispatcher(this.ctx.rnInstance, this.cleanLogger);
163
196
  }
164
197
  }
165
198
 
@@ -167,22 +200,26 @@ export class RNGestureHandlerModule extends TurboModule implements TM.RNGestureH
167
200
  handlerTag: number,
168
201
  newConfig: Readonly<Record<string, unknown>>
169
202
  ) {
203
+ const stopTracing = this.logger.cloneAndJoinPrefix("updateGestureHandler").startTracing()
170
204
  const gestureHandler = this.gestureHandlerRegistry.getGestureHandlerByHandlerTag(handlerTag)
171
205
  this.interactionManager.configureInteractions(gestureHandler, newConfig);
172
206
  gestureHandler.updateGestureConfig(newConfig)
207
+ stopTracing()
173
208
  }
174
209
 
175
210
  public dropGestureHandler(handlerTag: number) {
211
+ const stopTracing = this.logger.cloneAndJoinPrefix("dropGestureHandler").startTracing()
176
212
  this.interactionManager.dropRelationsForHandlerWithTag(handlerTag)
177
213
  this.gestureHandlerRegistry.removeGestureHandlerByHandlerTag(handlerTag)
214
+ stopTracing()
178
215
  }
179
216
 
180
217
  public handleSetJSResponder(tag: number, blockNativeResponder: boolean) {
181
- this.warn("handleSetJSResponder is not implemented")
218
+ this.logger.cloneAndJoinPrefix("handleSetJSResponder").warn("not implemented")
182
219
  }
183
220
 
184
221
  public handleClearJSResponder() {
185
- this.warn("handleClearJSResponder is not implemented")
222
+ this.logger.cloneAndJoinPrefix("handleClearJSResponder").warn("not implemented")
186
223
  }
187
224
 
188
225
  public flushOperations() {
@@ -190,9 +227,6 @@ export class RNGestureHandlerModule extends TurboModule implements TM.RNGestureH
190
227
  }
191
228
 
192
229
  // -------------------------------------------------------------------------------------------------------------------
193
- protected warn(message: string) {
194
- this.ctx.logger.warn("RNGH: " + message)
195
- }
196
230
 
197
231
  public getGestureHandlerRegistry() {
198
232
  return this.gestureHandlerRegistry
@@ -204,7 +238,7 @@ export class RNGestureHandlerModule extends TurboModule implements TM.RNGestureH
204
238
 
205
239
  public getViewRegistry() {
206
240
  if (!this.viewRegistry) {
207
- this.logger.info("Tried to get viewRegistry before it was initialized")
241
+ this.logger.error("Tried to get viewRegistry before it was initialized")
208
242
  throw new Error("Tried to get viewRegistry before it was initialized")
209
243
  }
210
244
  return this.viewRegistry
@@ -1,16 +1,7 @@
1
1
  import { RNInstance } from "@rnoh/react-native-openharmony/ts"
2
2
  import { RNGestureResponder } from "../core"
3
3
 
4
- export class FakeRNGestureResponder {
5
- lock() {
6
- // Cancelling RN events isn't supported in ArkTS architecture.
7
- return () => {}
8
- }
9
- }
10
4
 
11
- /**
12
- * Used in C-API architecture.
13
- */
14
5
  export class RNOHGestureResponder implements RNGestureResponder {
15
6
  constructor(private rnInstance: RNInstance) {
16
7
  }
@@ -1,20 +1,13 @@
1
1
  import { RNInstance } from '@rnoh/react-native-openharmony/ts';
2
2
  import { ScrollLocker, RNGHLogger } from '../core';
3
3
 
4
- export class RNOHScrollLockerArkTS implements ScrollLocker {
5
- constructor(private rnInstance: RNInstance) {
6
- }
7
4
 
8
- lockScrollContainingViewTag(viewTag: number) {
9
- return this.rnInstance.blockComponentsGestures(viewTag);
10
- }
11
- }
12
5
 
13
6
  export class RNOHScrollLockerCAPI implements ScrollLocker {
14
7
  private logger: RNGHLogger
15
8
 
16
9
  constructor(private rnInstance: RNInstance, logger: RNGHLogger) {
17
- this.logger = logger.cloneWithPrefix("RNOHScrollLockerCAPI")
10
+ this.logger = logger.cloneAndJoinPrefix("RNOHScrollLockerCAPI")
18
11
  }
19
12
 
20
13
  lockScrollContainingViewTag(viewTag: number) {
Binary file
package/package.json CHANGED
@@ -7,13 +7,17 @@
7
7
  "./src/specs"
8
8
  ]
9
9
  },
10
- "redirectInternalImports": true
10
+ "redirectInternalImports": true,
11
+ "autolinking": {
12
+ "cmakeLibraryTargetName": "rnoh_gesture_handler",
13
+ "ohPackageName": "@react-native-oh-tpl/react-native-gesture-handler"
14
+ }
11
15
  },
12
16
  "repository": {
13
17
  "type": "git",
14
18
  "url": "https://github.com/react-native-oh-library/react-native-harmony-gesture-handler.git"
15
19
  },
16
- "version": "2.14.13",
20
+ "version": "2.14.14",
17
21
  "description": "",
18
22
  "react-native": "src/index.ts",
19
23
  "main": "lib/commonjs/index.js",
@@ -71,4 +75,4 @@
71
75
  ]
72
76
  ]
73
77
  }
74
- }
78
+ }
@@ -1,149 +0,0 @@
1
- #pragma once
2
- #include "GestureHandlerPackage.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
-
14
- using namespace rnoh;
15
- using namespace facebook;
16
-
17
- class GestureHandlerTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
18
- public:
19
- SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
20
- if (name == "RNGestureHandlerModule") {
21
- return std::make_shared<RNGestureHandlerModule>(ctx, name);
22
- }
23
- return nullptr;
24
- };
25
- };
26
-
27
-
28
- class RNGHEventEmitRequestHandler : public EventEmitRequestHandler {
29
- void handleEvent(EventEmitRequestHandler::Context const &ctx) override {
30
- auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::ViewEventEmitter>(ctx.tag);
31
- if (eventEmitter == nullptr) {
32
- return;
33
- }
34
- if (ctx.eventName == "onGestureHandlerEvent") {
35
- eventEmitter->dispatchUniqueEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
36
- } else if (ctx.eventName == "onGestureHandlerStateChange") {
37
- eventEmitter->dispatchEvent("onGestureHandlerStateChange", ArkJS(ctx.env).getDynamic(ctx.payload));
38
- }
39
- }
40
- };
41
-
42
- class RNOHCorePackageComponentInstanceFactoryDelegate : public ComponentInstanceFactoryDelegate {
43
- public:
44
- using ComponentInstanceFactoryDelegate::ComponentInstanceFactoryDelegate;
45
-
46
- ComponentInstance::Shared create(ComponentInstance::Context ctx) override {
47
- if (ctx.componentName == "RNGestureHandlerButton") {
48
- return std::make_shared<RNGestureHandlerButtonComponentInstance>(ctx);
49
- } else if (ctx.componentName == "RNGestureHandlerRootView") {
50
- return std::make_shared<RNGestureHandlerRootViewComponentInstance>(ctx);
51
- }
52
- return nullptr;
53
- }
54
- };
55
-
56
- std::unique_ptr<TurboModuleFactoryDelegate> GestureHandlerPackage::createTurboModuleFactoryDelegate() {
57
- return std::make_unique<GestureHandlerTurboModuleFactoryDelegate>();
58
- }
59
-
60
- std::vector<react::ComponentDescriptorProvider> GestureHandlerPackage::createComponentDescriptorProviders() {
61
- return {
62
- react::concreteComponentDescriptorProvider<react::RNGestureHandlerRootViewComponentDescriptor>(),
63
- react::concreteComponentDescriptorProvider<react::RNGestureHandlerButtonComponentDescriptor>(),
64
- };
65
- }
66
-
67
- ComponentJSIBinderByString GestureHandlerPackage::createComponentJSIBinderByName() {
68
- return {
69
- {"RNGestureHandlerButton", std::make_shared<RNGestureHandlerButtonJSIBinder>()},
70
- {"RNGestureHandlerRootView", std::make_shared<RNGestureHandlerRootViewJSIBinder>()},
71
- };
72
- };
73
-
74
- EventEmitRequestHandlers GestureHandlerPackage::createEventEmitRequestHandlers() {
75
- return {
76
- std::make_shared<RNGHEventEmitRequestHandler>(),
77
- };
78
- }
79
-
80
- ComponentInstanceFactoryDelegate::Shared GestureHandlerPackage::createComponentInstanceFactoryDelegate() {
81
- return std::make_shared<RNOHCorePackageComponentInstanceFactoryDelegate>();
82
- }
83
-
84
- class ScrollLockerArkTSMessageHandler : public ArkTSMessageHandler {
85
- public:
86
- void handleArkTSMessage(const Context &ctx) override {
87
- if (ctx.messageName == "RNGH::SET_NATIVE_RESPONDERS_BLOCK") {
88
- auto targetComponentInstanceTag = ctx.messagePayload["targetTag"].asDouble();
89
- auto shouldBlock = ctx.messagePayload["shouldBlock"].asBool();
90
- auto rnInstance = ctx.rnInstance.lock();
91
- if (rnInstance != nullptr) {
92
- auto rnInstanceCAPI = std::dynamic_pointer_cast<RNInstanceCAPI>(rnInstance);
93
- if (rnInstanceCAPI != nullptr) {
94
-
95
- std::vector<ComponentInstance::Shared> ancestors;
96
- auto tmpComponentInstance = rnInstanceCAPI->findComponentInstanceByTag(targetComponentInstanceTag);
97
- while (tmpComponentInstance != nullptr) {
98
- ancestors.push_back(tmpComponentInstance);
99
- tmpComponentInstance = tmpComponentInstance->getParent().lock();
100
- }
101
- if (ancestors.size() == 0) {
102
- return;
103
- }
104
- /**
105
- * Ensure consistent behavior with Android by not blocking scrolls above the GestureHandlerRootView handling
106
- * the touch. If there are multiple nested GestureHandlerRootViews, the one nearest to the actual root will
107
- * handle the touch.
108
- */
109
- auto isChangingResponderStatusAllowed = false;
110
- for (size_t i = ancestors.size() - 1; i > 0; i--) {
111
- auto ancestor = ancestors[i];
112
- if (!isChangingResponderStatusAllowed) {
113
- auto rootView = std::dynamic_pointer_cast<RNGestureHandlerRootViewComponentInstance>(ancestor);
114
- if (rootView != nullptr) {
115
- isChangingResponderStatusAllowed = true;
116
- }
117
- } else {
118
- ancestor->setNativeResponderBlocked(shouldBlock, "RNGH");
119
- }
120
- }
121
- }
122
- }
123
- } else if (ctx.messageName == "RNGH::ROOT_VIEW_IS_HANDLING_TOUCHES") {
124
- auto descendantViewTag = ctx.messagePayload["descendantViewTag"].asDouble();
125
- auto isHandlingTouches = ctx.messagePayload["isHandlingTouches"].asBool();
126
- auto rnInstance = ctx.rnInstance.lock();
127
- if (rnInstance != nullptr) {
128
- auto rnInstanceCAPI = std::dynamic_pointer_cast<RNInstanceCAPI>(rnInstance);
129
- if (rnInstanceCAPI != nullptr) {
130
- auto tmpComponentInstance = rnInstanceCAPI->findComponentInstanceByTag(descendantViewTag);
131
- while (tmpComponentInstance != nullptr) {
132
- tmpComponentInstance = tmpComponentInstance->getParent().lock();
133
- if (tmpComponentInstance) {
134
- auto rnghRootViewComponentInstance =
135
- std::dynamic_pointer_cast<RNGestureHandlerRootViewComponentInstance>(tmpComponentInstance);
136
- if (rnghRootViewComponentInstance) {
137
- rnghRootViewComponentInstance->setIsHandlingTouches(isHandlingTouches);
138
- }
139
- }
140
- }
141
- }
142
- }
143
- }
144
- };
145
- };
146
-
147
- std::vector<ArkTSMessageHandler::Shared> GestureHandlerPackage::createArkTSMessageHandlers() {
148
- return {std::make_shared<ScrollLockerArkTSMessageHandler>()};
149
- }
@@ -1,36 +0,0 @@
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
@@ -1,32 +0,0 @@
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
@@ -1,22 +0,0 @@
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
@@ -1,15 +0,0 @@
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