@react-native-oh-tpl/react-native-gesture-handler 2.12.6-2 → 2.12.9

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 (192) hide show
  1. package/harmony/gesture_handler/BuildProfile.ets +5 -0
  2. package/harmony/gesture_handler/build-profile.json5 +13 -2
  3. package/harmony/gesture_handler/hvigorfile.ts +1 -1
  4. package/harmony/gesture_handler/index.ets +1 -1
  5. package/harmony/gesture_handler/oh-package-lock.json5 +17 -0
  6. package/harmony/gesture_handler/oh-package.json5 +10 -11
  7. package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.cpp +75 -6
  8. package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.h +14 -8
  9. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonComponentDescriptor.h +4 -28
  10. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonComponentInstance.h +27 -0
  11. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonJSIBinder.h +32 -0
  12. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.cpp +17 -12
  13. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.h +5 -2
  14. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerPackage.h +72 -0
  15. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentDescriptor.h +4 -28
  16. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentInstance.h +78 -0
  17. package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewJSIBinder.h +25 -0
  18. package/harmony/gesture_handler/src/main/ets/EventDispatcher.ts +16 -1
  19. package/harmony/gesture_handler/src/main/ets/GestureHandler.ts +2 -2
  20. package/harmony/gesture_handler/src/main/ets/{GestureHandlerArkUIAdapter.ets → GestureHandlerArkUIAdapter.ts} +2 -1
  21. package/harmony/gesture_handler/src/main/ets/GestureHandlerPackage.ts +2 -2
  22. package/harmony/gesture_handler/src/main/ets/OutgoingEvent.ts +5 -5
  23. package/harmony/gesture_handler/src/main/ets/RNGHLogger.ts +20 -1
  24. package/harmony/gesture_handler/src/main/ets/{RNGHRootTouchHandler.ets → RNGHRootTouchHandlerArkTS.ts} +5 -3
  25. package/harmony/gesture_handler/src/main/ets/RNGHRootTouchHandlerCAPI.ts +87 -0
  26. package/harmony/gesture_handler/src/main/ets/RNGestureHandlerButton.ets +4 -3
  27. package/harmony/gesture_handler/src/main/ets/RNGestureHandlerModule.ts +65 -7
  28. package/harmony/gesture_handler/src/main/ets/RNGestureHandlerRootView.ets +7 -11
  29. package/harmony/gesture_handler/src/main/ets/RNOHScrollLocker.ts +17 -5
  30. package/harmony/gesture_handler/src/main/ets/View.ts +1 -1
  31. package/harmony/gesture_handler/src/main/ets/ViewRegistry.ts +1 -1
  32. package/harmony/gesture_handler/src/main/ets/namespace/RNGestureHandlerButton.ts +140 -0
  33. package/harmony/gesture_handler/src/main/ets/namespace/RNGestureHandlerModule.ts +25 -0
  34. package/harmony/gesture_handler/src/main/ets/namespace/RNGestureHandlerRootView.ts +101 -0
  35. package/harmony/gesture_handler/src/main/ets/namespace/ts.ts +3 -0
  36. package/harmony/gesture_handler/src/main/ets/types.ts +25 -0
  37. package/harmony/gesture_handler/src/main/module.json5 +6 -6
  38. package/harmony/gesture_handler/ts.ts +2 -1
  39. package/harmony/gesture_handler.har +0 -0
  40. package/lib/commonjs/RNGestureHandlerModule.js +6 -3
  41. package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
  42. package/lib/commonjs/components/GestureHandlerRootView.js +5 -13
  43. package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
  44. package/lib/commonjs/handlers/createHandler.js +31 -28
  45. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  46. package/lib/commonjs/index.js +42 -19
  47. package/lib/commonjs/index.js.map +1 -1
  48. package/lib/commonjs/specs/NativeRNGestureHandlerModule.js +10 -0
  49. package/lib/commonjs/specs/NativeRNGestureHandlerModule.js.map +1 -0
  50. package/lib/commonjs/specs/RNGestureHandlerButtonNativeComponent.js +11 -0
  51. package/lib/commonjs/specs/RNGestureHandlerButtonNativeComponent.js.map +1 -0
  52. package/lib/commonjs/specs/RNGestureHandlerRootViewNativeComponent.js +11 -0
  53. package/lib/commonjs/specs/RNGestureHandlerRootViewNativeComponent.js.map +1 -0
  54. package/lib/module/RNGestureHandlerModule.js +3 -2
  55. package/lib/module/RNGestureHandlerModule.js.map +1 -1
  56. package/lib/module/components/GestureHandlerRootView.js +3 -11
  57. package/lib/module/components/GestureHandlerRootView.js.map +1 -1
  58. package/lib/module/handlers/createHandler.js +20 -19
  59. package/lib/module/handlers/createHandler.js.map +1 -1
  60. package/lib/module/index.js +6 -14
  61. package/lib/module/index.js.map +1 -1
  62. package/lib/module/specs/NativeRNGestureHandlerModule.js +3 -0
  63. package/lib/module/specs/NativeRNGestureHandlerModule.js.map +1 -0
  64. package/lib/module/specs/RNGestureHandlerButtonNativeComponent.js +3 -0
  65. package/lib/module/specs/RNGestureHandlerButtonNativeComponent.js.map +1 -0
  66. package/lib/module/specs/RNGestureHandlerRootViewNativeComponent.js +3 -0
  67. package/lib/module/specs/RNGestureHandlerRootViewNativeComponent.js.map +1 -0
  68. package/lib/typescript/RNGestureHandlerModule.d.ts +2 -6
  69. package/lib/typescript/RNGestureHandlerModule.d.ts.map +1 -1
  70. package/lib/typescript/components/GestureHandlerRootView.d.ts +6 -6
  71. package/lib/typescript/components/GestureHandlerRootView.d.ts.map +1 -1
  72. package/lib/typescript/handlers/createHandler.d.ts +11 -11
  73. package/lib/typescript/handlers/createHandler.d.ts.map +1 -1
  74. package/lib/typescript/index.d.ts +9 -8
  75. package/lib/typescript/index.d.ts.map +1 -1
  76. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +15 -0
  77. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts.map +1 -0
  78. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +15 -0
  79. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts.map +1 -0
  80. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +7 -0
  81. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts.map +1 -0
  82. package/package.json +9 -13
  83. package/src/RNGestureHandlerModule.ts +3 -4
  84. package/src/components/GestureHandlerRootView.tsx +4 -15
  85. package/src/handlers/createHandler.tsx +4 -5
  86. package/src/index.ts +13 -13
  87. package/src/specs/NativeRNGestureHandlerModule.ts +26 -0
  88. package/src/specs/RNGestureHandlerButtonNativeComponent.ts +18 -0
  89. package/src/specs/RNGestureHandlerRootViewNativeComponent.ts +6 -0
  90. package/README.md +0 -1
  91. package/harmony/gesture_handler/LICENSE +0 -21
  92. package/harmony/gesture_handler/OAT.xml +0 -44
  93. package/harmony/gesture_handler/README.OpenSource +0 -11
  94. package/harmony/gesture_handler/README.md +0 -1
  95. package/lib/commonjs/components/GestureButtons.js +0 -186
  96. package/lib/commonjs/components/GestureButtons.js.map +0 -1
  97. package/lib/commonjs/components/GestureHandlerButton.js +0 -9
  98. package/lib/commonjs/components/GestureHandlerButton.js.map +0 -1
  99. package/lib/commonjs/components/RNGestureHandlerButton.js +0 -23
  100. package/lib/commonjs/components/RNGestureHandlerButton.js.map +0 -1
  101. package/lib/commonjs/components/touchables/GenericTouchable.js +0 -247
  102. package/lib/commonjs/components/touchables/GenericTouchable.js.map +0 -1
  103. package/lib/commonjs/components/touchables/TouchableOpacity.js +0 -58
  104. package/lib/commonjs/components/touchables/TouchableOpacity.js.map +0 -1
  105. package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js +0 -18
  106. package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js.map +0 -1
  107. package/lib/commonjs/components/touchables/index.js +0 -21
  108. package/lib/commonjs/components/touchables/index.js.map +0 -1
  109. package/lib/commonjs/handlers/NativeViewGestureHandler.js +0 -19
  110. package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +0 -1
  111. package/lib/commonjs/handlers/PanGestureHandler.js +0 -103
  112. package/lib/commonjs/handlers/PanGestureHandler.js.map +0 -1
  113. package/lib/commonjs/handlers/TapGestureHandler.js +0 -22
  114. package/lib/commonjs/handlers/TapGestureHandler.js.map +0 -1
  115. package/lib/commonjs/handlers/createNativeWrapper.js +0 -64
  116. package/lib/commonjs/handlers/createNativeWrapper.js.map +0 -1
  117. package/lib/commonjs/handlers/gestureHandlerCommon.js +0 -22
  118. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +0 -1
  119. package/lib/commonjs/handlers/gestures/GestureDetector.js +0 -554
  120. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +0 -1
  121. package/lib/commonjs/init.js +0 -24
  122. package/lib/commonjs/init.js.map +0 -1
  123. package/lib/module/components/GestureButtons.js +0 -168
  124. package/lib/module/components/GestureButtons.js.map +0 -1
  125. package/lib/module/components/GestureHandlerButton.js +0 -3
  126. package/lib/module/components/GestureHandlerButton.js.map +0 -1
  127. package/lib/module/components/RNGestureHandlerButton.js +0 -17
  128. package/lib/module/components/RNGestureHandlerButton.js.map +0 -1
  129. package/lib/module/components/touchables/GenericTouchable.js +0 -238
  130. package/lib/module/components/touchables/GenericTouchable.js.map +0 -1
  131. package/lib/module/components/touchables/TouchableOpacity.js +0 -49
  132. package/lib/module/components/touchables/TouchableOpacity.js.map +0 -1
  133. package/lib/module/components/touchables/TouchableWithoutFeedback.js +0 -9
  134. package/lib/module/components/touchables/TouchableWithoutFeedback.js.map +0 -1
  135. package/lib/module/components/touchables/index.js +0 -8
  136. package/lib/module/components/touchables/index.js.map +0 -1
  137. package/lib/module/handlers/NativeViewGestureHandler.js +0 -12
  138. package/lib/module/handlers/NativeViewGestureHandler.js.map +0 -1
  139. package/lib/module/handlers/PanGestureHandler.js +0 -92
  140. package/lib/module/handlers/PanGestureHandler.js.map +0 -1
  141. package/lib/module/handlers/TapGestureHandler.js +0 -14
  142. package/lib/module/handlers/TapGestureHandler.js.map +0 -1
  143. package/lib/module/handlers/createNativeWrapper.js +0 -57
  144. package/lib/module/handlers/createNativeWrapper.js.map +0 -1
  145. package/lib/module/handlers/gestureHandlerCommon.js +0 -15
  146. package/lib/module/handlers/gestureHandlerCommon.js.map +0 -1
  147. package/lib/module/handlers/gestures/GestureDetector.js +0 -543
  148. package/lib/module/handlers/gestures/GestureDetector.js.map +0 -1
  149. package/lib/module/init.js +0 -17
  150. package/lib/module/init.js.map +0 -1
  151. package/lib/typescript/components/GestureButtons.d.ts +0 -122
  152. package/lib/typescript/components/GestureButtons.d.ts.map +0 -1
  153. package/lib/typescript/components/GestureHandlerButton.d.ts +0 -5
  154. package/lib/typescript/components/GestureHandlerButton.d.ts.map +0 -1
  155. package/lib/typescript/components/RNGestureHandlerButton.d.ts +0 -2
  156. package/lib/typescript/components/RNGestureHandlerButton.d.ts.map +0 -1
  157. package/lib/typescript/components/touchables/GenericTouchable.d.ts +0 -68
  158. package/lib/typescript/components/touchables/GenericTouchable.d.ts.map +0 -1
  159. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +0 -26
  160. package/lib/typescript/components/touchables/TouchableOpacity.d.ts.map +0 -1
  161. package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +0 -8
  162. package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts.map +0 -1
  163. package/lib/typescript/components/touchables/index.d.ts +0 -4
  164. package/lib/typescript/components/touchables/index.d.ts.map +0 -1
  165. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +0 -29
  166. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts.map +0 -1
  167. package/lib/typescript/handlers/PanGestureHandler.d.ts +0 -140
  168. package/lib/typescript/handlers/PanGestureHandler.d.ts.map +0 -1
  169. package/lib/typescript/handlers/TapGestureHandler.d.ts +0 -58
  170. package/lib/typescript/handlers/TapGestureHandler.d.ts.map +0 -1
  171. package/lib/typescript/handlers/createNativeWrapper.d.ts +0 -4
  172. package/lib/typescript/handlers/createNativeWrapper.d.ts.map +0 -1
  173. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +0 -2
  174. package/lib/typescript/handlers/gestureHandlerCommon.d.ts.map +0 -1
  175. package/lib/typescript/handlers/gestures/GestureDetector.d.ts +0 -24
  176. package/lib/typescript/handlers/gestures/GestureDetector.d.ts.map +0 -1
  177. package/lib/typescript/init.d.ts +0 -3
  178. package/lib/typescript/init.d.ts.map +0 -1
  179. package/src/components/GestureButtons.tsx +0 -334
  180. package/src/components/GestureHandlerButton.tsx +0 -5
  181. package/src/components/RNGestureHandlerButton.tsx +0 -23
  182. package/src/components/touchables/GenericTouchable.tsx +0 -301
  183. package/src/components/touchables/TouchableOpacity.tsx +0 -76
  184. package/src/components/touchables/TouchableWithoutFeedback.tsx +0 -14
  185. package/src/components/touchables/index.ts +0 -7
  186. package/src/handlers/NativeViewGestureHandler.ts +0 -55
  187. package/src/handlers/PanGestureHandler.ts +0 -327
  188. package/src/handlers/TapGestureHandler.ts +0 -95
  189. package/src/handlers/createNativeWrapper.tsx +0 -81
  190. package/src/handlers/gestureHandlerCommon.ts +0 -15
  191. package/src/handlers/gestures/GestureDetector.tsx +0 -823
  192. package/src/init.ts +0 -18
@@ -324,7 +324,7 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
324
324
  return this.view
325
325
  }
326
326
 
327
- protected begin(): void {
327
+ public begin(): void {
328
328
  this.logger.info("begin")
329
329
  if (!this.isWithinHitSlop()) return;
330
330
  if (this.currentState === State.UNDETERMINED) {
@@ -401,7 +401,7 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
401
401
  return false;
402
402
  }
403
403
 
404
- protected activate(): void {
404
+ public activate(): void {
405
405
  this.logger.info("activate")
406
406
  if (this.currentState === State.UNDETERMINED || this.currentState === State.BEGAN) {
407
407
  this.moveToState(State.ACTIVE)
@@ -1,8 +1,9 @@
1
- import { Point } from "rnoh"
1
+ import { Point } from "@rnoh/react-native-openharmony/ts"
2
2
  import { GestureHandler } from "./GestureHandler"
3
3
  import { AdaptedEvent, EventType, PointerType, TouchEventType, Touch } from "./Event"
4
4
  import { View } from "./View"
5
5
  import { RNGHLogger } from "./RNGHLogger"
6
+ import { TouchEvent, TouchType, TouchObject } from "./types"
6
7
 
7
8
  export class GestureHandlerArkUIAdapter {
8
9
  private activePointerIds = new Set<number>()
@@ -1,5 +1,5 @@
1
- import {RNPackage, TurboModuleContext, TurboModulesFactory} from 'rnoh/ts';
2
- import type {TurboModule} from 'rnoh/ts';
1
+ import {RNPackage, TurboModuleContext, TurboModulesFactory} from '@rnoh/react-native-openharmony/ts';
2
+ import type {TurboModule} from '@rnoh/react-native-openharmony/ts';
3
3
  import {RNGestureHandlerModule} from './RNGestureHandlerModule';
4
4
 
5
5
  class GestureHandlerTurboModulesFactory extends TurboModulesFactory {
@@ -17,17 +17,17 @@ export type GestureUpdateEvent<GestureEventPayloadT = Record<string, unknown>> =
17
17
  export type GestureStateChangeEvent<GestureStateChangeEventPayloadT = Record<string, unknown>> = HandlerStateChangeEventPayload & GestureStateChangeEventPayloadT
18
18
 
19
19
  export type TouchData = {
20
- absoluteX: number;
21
- absoluteY: number;
20
+ id: number;
22
21
  x: number;
23
22
  y: number;
24
- id: number;
23
+ absoluteX: number;
24
+ absoluteY: number;
25
25
  };
26
26
 
27
27
  export type GestureTouchEvent = {
28
- state: State;
29
- numberOfTouches: number;
30
28
  handlerTag: number;
29
+ numberOfTouches: number;
30
+ state: State;
31
31
  eventType: TouchEventType;
32
32
  allTouches: TouchData[];
33
33
  changedTouches: TouchData[];
@@ -1,19 +1,31 @@
1
- import { RNOHContext } from "rnoh/ts"
1
+ import { RNOHContext } from "@rnoh/react-native-openharmony/ts"
2
2
 
3
3
  export interface RNGHLogger {
4
4
  info(msg: string): void
5
5
 
6
6
  cloneWithPrefix(prefix: string): RNGHLogger
7
+
8
+ debug(msg: string)
9
+
10
+ error(msg: string)
7
11
  }
8
12
 
9
13
  export class StandardRNGHLogger implements RNGHLogger {
10
14
  constructor(private rnohLogger: RNOHContext["logger"], private prefix: string) {
11
15
  }
12
16
 
17
+ error(msg: string) {
18
+ this.rnohLogger.error(`${this.prefix}::${msg}`)
19
+ }
20
+
13
21
  info(msg: string) {
14
22
  this.rnohLogger.info(`${this.prefix}::${msg}`)
15
23
  }
16
24
 
25
+ debug(msg: string) {
26
+ this.rnohLogger.debug(`${this.prefix}::${msg}`)
27
+ }
28
+
17
29
  cloneWithPrefix(prefix: string) {
18
30
  return new StandardRNGHLogger(this.rnohLogger, `${this.prefix}::${prefix}`)
19
31
  }
@@ -23,6 +35,13 @@ export class FakeRNGHLogger implements RNGHLogger {
23
35
  info(msg: string) {
24
36
  }
25
37
 
38
+ debug(msg: string) {
39
+
40
+ }
41
+
42
+ error(msg: string): void {
43
+ }
44
+
26
45
  cloneWithPrefix(prefix: string) {
27
46
  return new FakeRNGHLogger()
28
47
  }
@@ -1,11 +1,12 @@
1
- import { Tag } from "rnoh"
1
+ import { Tag } from "@rnoh/react-native-openharmony/ts"
2
2
  import { GestureHandlerRegistry } from "./GestureHandlerRegistry"
3
3
  import { GestureHandlerArkUIAdapter } from "./GestureHandlerArkUIAdapter"
4
4
  import { ViewRegistry } from "./ViewRegistry"
5
5
  import { RNGHLogger } from './RNGHLogger'
6
+ import { TouchEvent, TouchType } from "./types"
6
7
 
7
8
 
8
- export class RNGHRootTouchHandler {
9
+ export class RNGHRootTouchHandlerArkTS {
9
10
  private adapterByViewTag: Map<number, GestureHandlerArkUIAdapter> = new Map() // TODO: remove an adapter when a view or gesture handler is removed
10
11
  private activeViewTags: number[] = []
11
12
  private viewRegistry: ViewRegistry
@@ -20,7 +21,8 @@ export class RNGHRootTouchHandler {
20
21
  this.logger = logger
21
22
  }
22
23
 
23
- public handleTouch(e: TouchEvent) {
24
+ public handleTouch(touchEvent: any) {
25
+ const e = touchEvent as TouchEvent
24
26
  if (e.type === TouchType.Down) {
25
27
  this.activeViewTags = []
26
28
  }
@@ -0,0 +1,87 @@
1
+ import { RNGHRootTouchHandlerArkTS } from "./RNGHRootTouchHandlerArkTS"
2
+ import { TouchEvent as TouchEventArkTS, TouchType, TouchObject } from "./types"
3
+ import { RNGHLogger } from "./RNGHLogger"
4
+
5
+ type RawTouchPoint = {
6
+ contactAreaHeight: number
7
+ contactAreaWidth: number
8
+ id: number
9
+ nodeX: number
10
+ nodeY: number
11
+ pressedTime: number
12
+ pressure: number
13
+ rawX: number
14
+ rawY: number
15
+ screenX: number
16
+ screenY: number
17
+ tiltX: number
18
+ tiltY: number
19
+ toolHeight: number
20
+ toolType: number
21
+ toolWidth: number
22
+ toolX: number
23
+ toolY: number
24
+ windowX: number
25
+ windowY: number
26
+ }
27
+
28
+ export type RawTouchEvent = {
29
+ action: number,
30
+ actionTouch: RawTouchPoint,
31
+ touchPoints: RawTouchPoint[],
32
+ sourceType: number,
33
+ timestamp: number
34
+ }
35
+
36
+ class TouchEvent {
37
+ constructor(private raw: RawTouchEvent) {
38
+ }
39
+
40
+ asTouchEventArkTS(): TouchEventArkTS {
41
+ const touchType = this.touchTypeFromAction(this.raw.action)
42
+ return {
43
+ type: this.touchTypeFromAction(this.raw.action),
44
+ touches: this.raw.touchPoints.map(tp => this.touchObjectFromTouchPoint(tp, touchType)),
45
+ changedTouches: [this.touchObjectFromTouchPoint(this.raw.actionTouch, touchType)],
46
+ timestamp: this.raw.timestamp
47
+ }
48
+ }
49
+
50
+ private touchTypeFromAction(action: number): TouchType {
51
+ switch (action) {
52
+ case 1:
53
+ return TouchType.Down
54
+ case 2:
55
+ return TouchType.Move
56
+ case 3:
57
+ return TouchType.Up
58
+ default:
59
+ return TouchType.Cancel
60
+ }
61
+ }
62
+
63
+ private touchObjectFromTouchPoint(touchPoint: RawTouchPoint, touchType: TouchType): TouchObject {
64
+ return {
65
+ id: touchPoint.id,
66
+ windowX: touchPoint.windowX,
67
+ windowY: touchPoint.windowY,
68
+ x: touchPoint.windowX,
69
+ y: touchPoint.windowY,
70
+ type: touchType
71
+ }
72
+ }
73
+ }
74
+
75
+ export class RNGHRootTouchHandlerCAPI {
76
+ private logger: RNGHLogger
77
+
78
+ constructor(logger: RNGHLogger, private touchHandlerArkTS: RNGHRootTouchHandlerArkTS) {
79
+ this.logger = logger.cloneWithPrefix("RNGHRootTouchHandlerCAPI")
80
+ }
81
+
82
+ handleTouch(rawTouchEvent: RawTouchEvent) {
83
+ this.logger.cloneWithPrefix("handleTouch").debug(JSON.stringify(rawTouchEvent))
84
+ this.touchHandlerArkTS.handleTouch(new TouchEvent(rawTouchEvent).asTouchEventArkTS())
85
+ }
86
+ }
87
+
@@ -1,10 +1,11 @@
1
- import { Descriptor, RNOHContext, RNViewBase, ComponentBuilderContext, RNComponentFactory, Tag } from "rnoh"
1
+ import { RNOHContext, RNViewBase, ComponentBuilderContext, RNComponentFactory, Tag } from "@rnoh/react-native-openharmony"
2
+ import { RNGestureHandlerButton as RNC } from "./namespace/RNGestureHandlerButton"
2
3
 
3
- export type RNGestureHandlerButtonDescriptor = Descriptor<"RNGestureHandlerButton">
4
+ export type RNGestureHandlerButtonDescriptor = RNC.Descriptor
4
5
 
5
6
  @Component
6
7
  export struct RNGestureHandlerButton {
7
- static readonly DESCRIPTOR_TYPE = "RNGestureHandlerButton"
8
+ static readonly NAME = RNC.NAME
8
9
  public ctx!: RNOHContext
9
10
  public tag: number = -1
10
11
  @BuilderParam public buildCustomComponent: (componentBuilderContext: ComponentBuilderContext) => void
@@ -1,10 +1,19 @@
1
- import { TurboModule, TurboModuleContext } from 'rnoh/ts';
1
+ import { TurboModule, TurboModuleContext, Tag } from '@rnoh/react-native-openharmony/ts';
2
+ // import { TM } from "rnoh/generated/ts"
2
3
  import { GestureHandlerRegistry } from './GestureHandlerRegistry';
3
4
  import { GestureHandlerFactory } from "./GestureHandlerFactory"
4
5
  import { ViewRegistry } from './ViewRegistry';
5
6
  import { RNGHLogger, StandardRNGHLogger, FakeRNGHLogger } from './RNGHLogger';
6
- import { EventDispatcher, JSEventDispatcher, AnimatedEventDispatcher } from './EventDispatcher'
7
- import { RNOHScrollLocker } from "./RNOHScrollLocker"
7
+ import {
8
+ EventDispatcher,
9
+ JSEventDispatcher,
10
+ AnimatedEventDispatcher,
11
+ ReanimatedEventDispatcher
12
+ } from './EventDispatcher'
13
+ import { RNOHScrollLockerArkTS, RNOHScrollLockerCAPI } from "./RNOHScrollLocker"
14
+ import { State } from './State';
15
+ import { RNGHRootTouchHandlerCAPI, RawTouchEvent } from "./RNGHRootTouchHandlerCAPI"
16
+ import { RNGHRootTouchHandlerArkTS } from './RNGHRootTouchHandlerArkTS';
8
17
 
9
18
  export enum ActionType {
10
19
  REANIMATED_WORKLET = 1,
@@ -15,22 +24,48 @@ export enum ActionType {
15
24
 
16
25
 
17
26
  export class RNGestureHandlerModule extends TurboModule {
27
+ // implements TM.RNGestureHandlerModule.Spec {
18
28
  static NAME = "RNGestureHandlerModule"
19
29
 
20
30
  private gestureHandlerRegistry = new GestureHandlerRegistry()
21
31
  private gestureHandlerFactory: GestureHandlerFactory | undefined = undefined
22
32
  private viewRegistry: ViewRegistry | undefined = undefined
23
33
  private logger: RNGHLogger
34
+ private touchHandlerByRootTag = new Map<Tag, RNGHRootTouchHandlerCAPI>()
24
35
 
25
36
  constructor(ctx: TurboModuleContext) {
26
37
  super(ctx)
27
38
  const debug = false
28
39
  this.logger = debug ? new StandardRNGHLogger(ctx.logger, "RNGH") : new FakeRNGHLogger()
40
+ if (this.ctx.rnInstance.getArchitecture() === "C_API") {
41
+ this.ctx.rnInstance.cppEventEmitter.subscribe("RNGH::TOUCH_EVENT", (e: any) => {
42
+ this.onTouch(e)
43
+ })
44
+ this.ctx.rnInstance.cppEventEmitter.subscribe("RNGH::ROOT_CREATED", (rootTag: any) => {
45
+ this.onGHRootCreated(rootTag)
46
+ })
47
+ }
48
+ }
49
+
50
+ private onGHRootCreated(rootTag: Tag) {
51
+ this.touchHandlerByRootTag.set(rootTag, new RNGHRootTouchHandlerCAPI(this.logger, new RNGHRootTouchHandlerArkTS(rootTag, this.viewRegistry, this.gestureHandlerRegistry, this.logger)));
52
+ }
53
+
54
+ private onTouch(e: RawTouchEvent & { rootTag: Tag }) {
55
+ const touchHandler = this.touchHandlerByRootTag.get(e.rootTag)
56
+ if (touchHandler) {
57
+ touchHandler.handleTouch(e);
58
+ } else {
59
+ this.logger.info(`Couldn't find touch handler for root tag: ${e.rootTag}`)
60
+ }
61
+
29
62
  }
30
63
 
31
64
  public install() {
32
65
  this.viewRegistry = new ViewRegistry(this.ctx.descriptorRegistry, this.ctx.componentManagerRegistry)
33
- this.gestureHandlerFactory = new GestureHandlerFactory(this.logger, new RNOHScrollLocker(this.ctx.rnInstance))
66
+ const scrollLocker = this.ctx.rnInstance.getArchitecture() === "ARK_TS" ? new RNOHScrollLockerArkTS(this.ctx.rnInstance) : new RNOHScrollLockerCAPI(this.ctx.rnInstance);
67
+ this.gestureHandlerFactory = new GestureHandlerFactory(this.logger, scrollLocker)
68
+ return true
34
69
  }
35
70
 
36
71
  public createGestureHandler(
@@ -71,15 +106,13 @@ export class RNGestureHandlerModule extends TurboModule {
71
106
  private createEventDispatcher(actionType: ActionType, viewTag: number): EventDispatcher | null {
72
107
  switch (actionType) {
73
108
  case ActionType.REANIMATED_WORKLET:
74
- this.ctx.logger.error("RNGH: Reanimated Worklets are not supported")
75
- break;
109
+ return new ReanimatedEventDispatcher(this.ctx.rnInstance, this.logger.cloneWithPrefix('ReanimatedEventDispatcher'), viewTag)
76
110
  case ActionType.NATIVE_ANIMATED_EVENT:
77
111
  return new AnimatedEventDispatcher(this.ctx.rnInstance, this.logger.cloneWithPrefix('AnimatedEventDispatcher'), viewTag)
78
112
  case ActionType.JS_FUNCTION_OLD_API:
79
113
  case ActionType.JS_FUNCTION_NEW_API:
80
114
  return new JSEventDispatcher(this.ctx.rnInstance, this.logger.cloneWithPrefix('JSEventDispatcher'));
81
115
  }
82
- return null
83
116
  }
84
117
 
85
118
  public updateGestureHandler(
@@ -120,6 +153,31 @@ export class RNGestureHandlerModule extends TurboModule {
120
153
  }
121
154
 
122
155
  public getViewRegistry() {
156
+ if (!this.viewRegistry) {
157
+ this.logger.info("Tried to get viewRegistry before it was initialized")
158
+ throw new Error("Tried to get viewRegistry before it was initialized")
159
+ }
123
160
  return this.viewRegistry
124
161
  }
162
+
163
+ public setGestureHandlerState(handlerTag: number, newState: State) {
164
+ const handler = this.getGestureHandlerRegistry().getGestureHandlerByHandlerTag(handlerTag);
165
+ switch (newState) {
166
+ case State.ACTIVE:
167
+ handler.activate();
168
+ break;
169
+ case State.BEGAN:
170
+ handler.begin();
171
+ break;
172
+ case State.END:
173
+ handler.end();
174
+ break;
175
+ case State.FAILED:
176
+ handler.fail();
177
+ break;
178
+ case State.CANCELLED:
179
+ handler.cancel();
180
+ break;
181
+ }
182
+ }
125
183
  }
@@ -1,18 +1,14 @@
1
- import { Descriptor, RNOHContext, RNViewBase, ComponentBuilderContext, RNComponentFactory, Tag } from "rnoh"
2
- import { RNGHRootTouchHandler } from "./RNGHRootTouchHandler"
1
+ import { RNOHContext, RNViewBase, ComponentBuilderContext, RNComponentFactory, Tag } from "@rnoh/react-native-openharmony"
2
+ import { RNGestureHandlerRootView as RNC } from "./namespace/RNGestureHandlerRootView"
3
+ import { RNGHRootTouchHandlerArkTS as RNGHRootTouchHandler } from "./RNGHRootTouchHandlerArkTS"
3
4
  import { RNGestureHandlerModule } from "./RNGestureHandlerModule"
4
- import { Vector2D } from "./Vector2D"
5
- import { ViewRegistry } from './ViewRegistry'
6
5
 
7
- export type RNGestureHandlerRootViewDescriptor = Descriptor<"RNGestureHandlerRootView">
6
+
7
+ export type RNGestureHandlerRootViewDescriptor = RNC.Descriptor
8
8
 
9
9
  @Component
10
10
  export struct RNGestureHandlerRootView {
11
- /**
12
- * @deprecated: Use RNGestureHandlerRootView.NAME instead
13
- */
14
- static readonly DESCRIPTOR_TYPE = "RNGestureHandlerRootView"
15
- static readonly NAME = "RNGestureHandlerRootView"
11
+ static readonly NAME = RNC.NAME
16
12
  ctx!: RNOHContext
17
13
  tag: number = -1
18
14
  @BuilderParam buildCustomComponent: (componentBuilderContext: ComponentBuilderContext) => void
@@ -23,7 +19,7 @@ export struct RNGestureHandlerRootView {
23
19
  aboutToAppear() {
24
20
  const rnGestureHandlerModule = this.ctx.rnInstance.getTurboModule<RNGestureHandlerModule>(RNGestureHandlerModule.NAME)
25
21
  const rootTag = this.ctx.descriptorRegistry.getDescriptorLineage(this.tag)[0].tag
26
- this.touchHandler = new RNGHRootTouchHandler(rootTag, rnGestureHandlerModule.getViewRegistry() as ViewRegistry, rnGestureHandlerModule.getGestureHandlerRegistry(), rnGestureHandlerModule.getLogger())
22
+ this.touchHandler = new RNGHRootTouchHandler(rootTag, rnGestureHandlerModule.getViewRegistry(), rnGestureHandlerModule.getGestureHandlerRegistry(), rnGestureHandlerModule.getLogger())
27
23
  this.handleDescriptorChange(this.ctx.descriptorRegistry.getDescriptor<RNGestureHandlerRootViewDescriptor>(this.tag))
28
24
  this.unsubscribes.push(this.ctx.descriptorRegistry.subscribeToDescriptorChanges(this.tag, (d) => {
29
25
  this.handleDescriptorChange(d as RNGestureHandlerRootViewDescriptor)
@@ -1,11 +1,23 @@
1
- import { RNInstance } from "rnoh/ts"
1
+ import { RNInstance } from "@rnoh/react-native-openharmony/ts"
2
2
  import { ScrollLocker } from "./GestureHandler"
3
3
 
4
- export class RNOHScrollLocker implements ScrollLocker {
5
- public constructor(private rnInstance: RNInstance) {
4
+ export class RNOHScrollLockerArkTS implements ScrollLocker {
5
+ constructor(private rnInstance: RNInstance) {
6
6
  }
7
7
 
8
- public lockScrollContainingViewTag(viewTag: number) {
8
+ lockScrollContainingViewTag(viewTag: number) {
9
9
  return this.rnInstance.blockComponentsGestures(viewTag)
10
10
  }
11
- }
11
+ }
12
+
13
+ export class RNOHScrollLockerCAPI implements ScrollLocker {
14
+ constructor(private rnInstance: RNInstance) {
15
+ }
16
+
17
+ lockScrollContainingViewTag(viewTag: number) {
18
+ this.rnInstance.postMessageToCpp("RNGH::SET_NATIVE_RESPONDERS_BLOCK", { targetTag: viewTag, shouldBlock: true });
19
+ return () => {
20
+ this.rnInstance.postMessageToCpp("RNGH::SET_NATIVE_RESPONDERS_BLOCK", { targetTag: viewTag, shouldBlock: false });
21
+ }
22
+ }
23
+ }
@@ -1,4 +1,4 @@
1
- import { DescriptorRegistry, Descriptor, Tag } from "rnoh/ts"
1
+ import { DescriptorRegistry, Descriptor, Tag } from "@rnoh/react-native-openharmony/ts"
2
2
  import { Vector2D } from "./Vector2D"
3
3
 
4
4
  export type BoundingBox = {
@@ -1,4 +1,4 @@
1
- import { DescriptorRegistry, ComponentManagerRegistry, Tag } from "rnoh/ts"
1
+ import { DescriptorRegistry, ComponentManagerRegistry, Tag } from "@rnoh/react-native-openharmony/ts"
2
2
  import { View } from "./View"
3
3
 
4
4
  export class ViewRegistry {
@@ -0,0 +1,140 @@
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
+
140
+ }
@@ -0,0 +1,25 @@
1
+ // This file was generated.
2
+ import { Tag } from "../../ts"
3
+
4
+ export namespace RNGestureHandlerModule {
5
+ export const NAME = 'RNGestureHandlerModule' as const
6
+
7
+ export interface Spec {
8
+ handleSetJSResponder(tag: number, blockNativeResponder: boolean): void;
9
+
10
+ handleClearJSResponder(): void;
11
+
12
+ createGestureHandler(handlerName: string, handlerTag: number, config: Object): void;
13
+
14
+ attachGestureHandler(handlerTag: number, newView: number, actionType: number): void;
15
+
16
+ updateGestureHandler(handlerTag: number, newConfig: Object): void;
17
+
18
+ dropGestureHandler(handlerTag: number): void;
19
+
20
+ install(): boolean;
21
+
22
+ flushOperations(): void;
23
+
24
+ }
25
+ }