@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
@@ -107,11 +107,15 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
107
107
  this.orchestrator = deps.orchestrator
108
108
  this.tracker = deps.tracker
109
109
  this.interactionManager = deps.interactionManager
110
- this.logger = deps.logger
110
+ this.logger = deps.logger.cloneAndJoinPrefix("GestureHandler")
111
111
  this.scrollLocker = deps.scrollLocker
112
112
  this.rnGestureResponder = deps.rnGestureResponder
113
113
  }
114
114
 
115
+ public abstract getName(): string;
116
+
117
+ public abstract isGestureContinuous(): boolean;
118
+
115
119
  public setEventDispatcher(eventDispatcher: OutgoingEventDispatcher) {
116
120
  // TurboModule provides info about kind of event dispatcher when attaching GH to a view, not when GH is created.
117
121
  // This method must be called before any other
@@ -119,7 +123,7 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
119
123
  }
120
124
 
121
125
  public onPointerDown(e: IncomingEvent) {
122
- this.logger.info("onPointerDown")
126
+ const stopTracing = this.logger.cloneAndJoinPrefix("onPointerDown").startTracing()
123
127
  this.orchestrator.registerHandlerIfNotPresent(this);
124
128
  this.pointerType = e.pointerType;
125
129
  if (this.pointerType === PointerType.TOUCH) {
@@ -128,6 +132,7 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
128
132
  if (this.config.needsPointerData) {
129
133
  this.sendTouchEvent(e);
130
134
  }
135
+ stopTracing()
131
136
  }
132
137
 
133
138
  protected sendTouchEvent(e: IncomingEvent) {
@@ -137,7 +142,7 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
137
142
 
138
143
 
139
144
  const touchEvent: GestureTouchEvent | undefined =
140
- this.transformToTouchEvent(e);
145
+ this.transformToTouchEvent(e);
141
146
 
142
147
  if (touchEvent) {
143
148
  this.eventDispatcher.onGestureHandlerEvent(touchEvent)
@@ -238,35 +243,47 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
238
243
  }
239
244
 
240
245
  public onPointerUp(e: IncomingEvent): void {
241
- this.logger.info("onPointerUp")
242
- if (this.config.needsPointerData) this.sendTouchEvent(e)
246
+ const stopTracing = this.logger.cloneAndJoinPrefix("onPointerUp").startTracing()
247
+ if (this.config.needsPointerData) {
248
+ this.sendTouchEvent(e)
249
+ }
250
+ stopTracing()
243
251
  }
244
252
 
245
253
  public onAdditionalPointerAdd(e: IncomingEvent): void {
246
- this.logger.info("onAdditionalPointerAdd")
247
- if (this.config.needsPointerData) this.sendTouchEvent(e)
254
+ const stopTracing = this.logger.cloneAndJoinPrefix("onAdditionalPointerAdd").startTracing()
255
+ if (this.config.needsPointerData) {
256
+ this.sendTouchEvent(e)
257
+ }
258
+ stopTracing()
248
259
  }
249
260
 
250
261
  public onAdditionalPointerRemove(e: IncomingEvent): void {
251
- this.logger.info("onAdditionalPointerRemove")
252
- if (this.config.needsPointerData) this.sendTouchEvent(e)
262
+ const stopTracing = this.logger.cloneAndJoinPrefix("onAdditionalPointerRemove").startTracing()
263
+ if (this.config.needsPointerData) {
264
+ this.sendTouchEvent(e)
265
+ }
266
+ stopTracing()
253
267
  }
254
268
 
255
269
  public onPointerMove(e: IncomingEvent): void {
256
- this.logger.info("onPointerMove")
270
+ const stopTracing = this.logger.cloneAndJoinPrefix("onPointerMove").startTracing()
257
271
  this.tryToSendMoveEvent(false);
258
272
  if (this.config.needsPointerData) {
259
273
  this.sendTouchEvent(e);
260
274
  }
275
+ stopTracing()
261
276
  }
262
277
 
263
278
  private tryToSendMoveEvent(out: boolean): void {
264
- this.logger.info(`tryToSendMoveEvent ${JSON.stringify({
279
+ const logger = this.logger.cloneAndJoinPrefix(`tryToSendMoveEvent`)
280
+ const stopTracing = logger.startTracing()
281
+ logger.debug({
265
282
  out,
266
283
  enabled: this.config.enabled,
267
284
  isActivated: this.isActivated,
268
285
  shouldCancelWhenOutside: this.shouldCancelWhenOutside
269
- })}`)
286
+ })
270
287
  if (
271
288
  this.config.enabled &&
272
289
  this.isActivated &&
@@ -274,17 +291,19 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
274
291
  ) {
275
292
  this.sendEvent({ newState: this.currentState, oldState: this.currentState });
276
293
  }
294
+ stopTracing()
277
295
  }
278
296
 
279
297
  public onPointerEnter(e: IncomingEvent): void {
280
- this.logger.info("onPointerEnter")
298
+ const stopTracing = this.logger.cloneAndJoinPrefix("onPointerEnter").startTracing()
281
299
  if (this.config.needsPointerData) {
282
300
  this.sendTouchEvent(e)
283
301
  }
302
+ stopTracing()
284
303
  }
285
304
 
286
305
  public onPointerOut(e: IncomingEvent): void {
287
- this.logger.info("onPointerOut")
306
+ const stopTracing = this.logger.cloneAndJoinPrefix("onPointerOut").startTracing()
288
307
  if (this.shouldCancelWhenOutside) {
289
308
  switch (this.currentState) {
290
309
  case State.ACTIVE:
@@ -294,33 +313,38 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
294
313
  this.fail();
295
314
  break;
296
315
  }
316
+ stopTracing()
297
317
  return;
298
318
  }
299
319
  if (this.config.needsPointerData) {
300
320
  this.sendTouchEvent(e);
301
321
  }
322
+ stopTracing()
302
323
  }
303
324
 
304
325
  public onPointerCancel(e: IncomingEvent): void {
305
- this.logger.info("onPointerCancel")
326
+ const stopTracing = this.logger.cloneAndJoinPrefix("onPointerCancel").startTracing()
306
327
  if (this.config.needsPointerData) {
307
328
  this.sendTouchEvent(e);
308
329
  }
309
330
  this.cancel();
310
331
  this.reset();
332
+ stopTracing()
311
333
  }
312
334
 
313
335
  public onPointerOutOfBounds(e: IncomingEvent): void {
314
- this.logger.info("onPointerOutOfBounds")
336
+ const stopTracing = this.logger.cloneAndJoinPrefix("onPointerOutOfBounds").startTracing()
315
337
  this.tryToSendMoveEvent(true);
316
338
  if (this.config.needsPointerData) {
317
339
  this.sendTouchEvent(e);
318
340
  }
341
+ stopTracing()
319
342
  }
320
343
 
321
344
  public onViewAttached(view: View) {
322
- this.logger.info("onViewAttached")
345
+ const stopTracing = this.logger.cloneAndJoinPrefix("onViewAttached").startTracing()
323
346
  this.view = view
347
+ stopTracing()
324
348
  }
325
349
 
326
350
  public getTag(): number {
@@ -336,11 +360,15 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
336
360
  }
337
361
 
338
362
  public begin(): void {
339
- this.logger.info("begin")
340
- if (!this.isWithinHitSlop()) return;
363
+ const stopTracing = this.logger.cloneAndJoinPrefix("begin").startTracing()
364
+ if (!this.isWithinHitSlop()) {
365
+ stopTracing()
366
+ return;
367
+ }
341
368
  if (this.currentState === State.UNDETERMINED) {
342
369
  this.moveToState(State.BEGAN);
343
370
  }
371
+ stopTracing()
344
372
  }
345
373
 
346
374
  private isWithinHitSlop(): boolean {
@@ -413,15 +441,20 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
413
441
  }
414
442
 
415
443
  public activate(): void {
416
- this.logger.info("activate")
417
- if (!this.config.manualActivation || this.currentState === State.UNDETERMINED || this.currentState === State.BEGAN) {
444
+ const stopTracing = this.logger.cloneAndJoinPrefix("activate").startTracing()
445
+ if (!this.config.manualActivation || this.currentState === State.UNDETERMINED ||
446
+ this.currentState === State.BEGAN) {
418
447
  this.moveToState(State.ACTIVE)
419
448
  }
449
+ stopTracing()
420
450
  }
421
451
 
422
452
  protected moveToState(state: State) {
423
- this.logger.info(`moveToState ${getStateName(state)}`)
424
- if (state === this.currentState) return;
453
+ const stopTracing = this.logger.cloneAndJoinPrefix(`moveToState ${getStateName(state)}`).startTracing()
454
+ if (state === this.currentState) {
455
+ stopTracing()
456
+ return;
457
+ }
425
458
  const oldState = this.currentState
426
459
  this.currentState = state;
427
460
  if (this.tracker.getTrackedPointersCount() > 0 && this.config.needsPointerData && this.isFinished()) {
@@ -433,6 +466,7 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
433
466
  if (!this.isEnabled() && this.isFinished()) {
434
467
  this.currentState = State.UNDETERMINED;
435
468
  }
469
+ stopTracing()
436
470
  }
437
471
 
438
472
  private isFinished() {
@@ -522,7 +556,7 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
522
556
  }
523
557
 
524
558
  public cancel(): void {
525
- this.logger.info(`cancel`)
559
+ const stopTracing = this.logger.cloneAndJoinPrefix(`cancel`).startTracing()
526
560
  if (
527
561
  this.currentState === State.ACTIVE ||
528
562
  this.currentState === State.UNDETERMINED ||
@@ -531,6 +565,7 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
531
565
  this.onCancel();
532
566
  this.moveToState(State.CANCELLED);
533
567
  }
568
+ stopTracing()
534
569
  }
535
570
 
536
571
  protected onCancel(): void {
@@ -546,11 +581,14 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
546
581
  return this.currentState
547
582
  }
548
583
 
549
- public sendEvent({newState, oldState}: {
584
+ public sendEvent({ newState, oldState }: {
550
585
  oldState: State,
551
586
  newState: State
552
587
  }): void {
553
- const logger = this.logger.cloneWithPrefix(`sendEvent(newState=${getStateName(newState)}, oldState=${getStateName(oldState)})`)
588
+ const logger =
589
+ this.logger.cloneAndJoinPrefix(`sendEvent`)
590
+ const stopTracing = logger.startTracing()
591
+ logger.debug({ tag: this.getTag(), newState, oldState })
554
592
  const stateChangeEvent = this.createStateChangeEvent(newState, oldState);
555
593
  if (this.lastSentState !== newState) {
556
594
  this.lastSentState = newState;
@@ -562,6 +600,7 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
562
600
  logger.debug("calling onGestureHandlerEvent")
563
601
  this.eventDispatcher.onGestureHandlerEvent(stateChangeEvent);
564
602
  }
603
+ stopTracing()
565
604
  }
566
605
 
567
606
  private createStateChangeEvent(newState: State, oldState: State): GestureStateChangeEvent {
@@ -594,19 +633,21 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
594
633
  }
595
634
 
596
635
  shouldWaitForHandlerFailure(handler: GestureHandler): boolean {
597
- if (handler === this)
636
+ if (handler === this) {
598
637
  return false;
638
+ }
599
639
  return this.interactionManager.shouldWaitForHandlerFailure(this, handler);
600
640
  }
601
641
 
602
642
  shouldRequireToWaitForFailure(handler: GestureHandler): boolean {
603
- if (handler === this)
643
+ if (handler === this) {
604
644
  return false;
645
+ }
605
646
  return this.interactionManager.shouldRequireHandlerToWaitForFailure(this, handler);
606
647
  }
607
648
 
608
649
  shouldWaitFor(otherHandler: GestureHandler): boolean {
609
- const logger = this.logger.cloneWithPrefix(`shouldWaitFor(${otherHandler.getTag()})`)
650
+ const logger = this.logger.cloneAndJoinPrefix(`shouldWaitFor(${otherHandler.getTag()})`)
610
651
  const result = (
611
652
  this !== otherHandler &&
612
653
  (this.shouldWaitForHandlerFailure(otherHandler) ||
@@ -617,7 +658,7 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
617
658
  }
618
659
 
619
660
  reset(): void {
620
- this.logger.info("reset")
661
+ const stopTracing = this.logger.cloneAndJoinPrefix("reset").startTracing()
621
662
  this.tracker.resetTracker();
622
663
  this.onReset();
623
664
  this.resetProgress();
@@ -625,6 +666,7 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
625
666
  // manager.resetManager()
626
667
  // );
627
668
  this.currentState = State.UNDETERMINED;
669
+ stopTracing()
628
670
  }
629
671
 
630
672
  isAwaiting(): boolean {
@@ -644,7 +686,7 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
644
686
  }
645
687
 
646
688
  fail(): void {
647
- this.logger.info('fail')
689
+ const stopTracing = this.logger.cloneAndJoinPrefix('fail').startTracing()
648
690
  if (
649
691
  this.currentState === State.ACTIVE ||
650
692
  this.currentState === State.BEGAN
@@ -652,11 +694,13 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
652
694
  this.moveToState(State.FAILED);
653
695
  }
654
696
  this.resetProgress();
697
+ stopTracing()
655
698
  }
656
699
 
657
700
  shouldBeCancelledByOther(otherHandler: GestureHandler): boolean {
658
- if (otherHandler === this)
701
+ if (otherHandler === this) {
659
702
  return false;
703
+ }
660
704
  return this.interactionManager.shouldHandlerBeCancelledBy(this, otherHandler);
661
705
  }
662
706
 
@@ -665,11 +709,15 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
665
709
  }
666
710
 
667
711
  shouldRecognizeSimultaneously(otherHandler: GestureHandler): boolean {
668
- this.logger.cloneWithPrefix(`shouldRecognizeSimultaneously(${otherHandler.getTag()})`).debug("")
712
+ const stopTracing =
713
+ this.logger.cloneAndJoinPrefix(`shouldRecognizeSimultaneously(${otherHandler.getTag()})`).startTracing()
669
714
  if (otherHandler === this) {
715
+ stopTracing
670
716
  return true;
671
717
  }
672
- return this.interactionManager.shouldRecognizeSimultaneously(this, otherHandler);
718
+ const result = this.interactionManager.shouldRecognizeSimultaneously(this, otherHandler);
719
+ stopTracing()
720
+ return result;
673
721
  }
674
722
 
675
723
  public getPointerType(): PointerType {
@@ -681,10 +729,11 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
681
729
  }
682
730
 
683
731
  public end() {
684
- this.logger.info("end")
732
+ const stopTracing = this.logger.cloneAndJoinPrefix("end").startTracing()
685
733
  if (this.currentState === State.BEGAN || this.currentState === State.ACTIVE) {
686
734
  this.moveToState(State.END);
687
735
  }
688
736
  this.resetProgress();
737
+ stopTracing()
689
738
  }
690
739
  }
@@ -9,11 +9,15 @@ export class GestureHandlerOrchestrator {
9
9
  private handlersToCancel: GestureHandler[] = []
10
10
  private activationIndex: number = 0
11
11
 
12
- constructor(private logger: RNGHLogger) {
12
+ private logger: RNGHLogger
13
+
14
+ constructor(logger: RNGHLogger) {
15
+ this.logger = logger.cloneAndJoinPrefix("GestureHandlerOrchestrator")
13
16
  }
14
17
 
15
18
  public onHandlerStateChange(handler: GestureHandler, newState: State, oldState: State, sendIfDisabled?: boolean) {
16
- const logger = this.logger.cloneWithPrefix(`onHandlerStateChange(handler=${handler.getTag()}, newState=${getStateName(newState)}, oldState=${getStateName(oldState)})`)
19
+ const logger =
20
+ this.logger.cloneAndJoinPrefix(`onHandlerStateChange(handler=${handler.getTag()}, newState=${getStateName(newState)}, oldState=${getStateName(oldState)})`)
17
21
  logger.debug("start")
18
22
 
19
23
  if (!handler.isEnabled() && !sendIfDisabled) {
@@ -73,7 +77,7 @@ export class GestureHandlerOrchestrator {
73
77
  }
74
78
 
75
79
  private tryActivate(handler: GestureHandler): void {
76
- const logger = this.logger.cloneWithPrefix(`tryActivate(${handler.getTag()})`)
80
+ const logger = this.logger.cloneAndJoinPrefix(`tryActivate(${handler.getTag()})`)
77
81
  logger.debug({
78
82
  gestureHandlers: this.gestureHandlers.map(gh => gh.getTag()),
79
83
  awaitingHandlers: Array.from(this.awaitingHandlers).map(gh => gh.getTag()),
@@ -123,7 +127,7 @@ export class GestureHandlerOrchestrator {
123
127
  }
124
128
 
125
129
  private hasOtherHandlerToWaitFor(handler: GestureHandler): boolean {
126
- const logger = this.logger.cloneWithPrefix(`hasOtherHandlerToWaitFor(handler=${handler.getTag()})`)
130
+ const logger = this.logger.cloneAndJoinPrefix(`hasOtherHandlerToWaitFor(handler=${handler.getTag()})`)
127
131
  for (const otherHandler of this.gestureHandlers) {
128
132
  if (otherHandler === handler) {
129
133
  return false
@@ -138,7 +142,7 @@ export class GestureHandlerOrchestrator {
138
142
  }
139
143
 
140
144
  private addAwaitingHandler(handler: GestureHandler) {
141
- const logger = this.logger.cloneWithPrefix(`addAwaitingHandler(handlerTag=${handler.getTag()})`)
145
+ const logger = this.logger.cloneAndJoinPrefix(`addAwaitingHandler(handlerTag=${handler.getTag()})`)
142
146
  logger.debug({ awaitingHandlers: this.awaitingHandlers })
143
147
  if (!this.awaitingHandlers.has(handler)) {
144
148
  this.awaitingHandlers.add(handler)
@@ -156,11 +160,12 @@ export class GestureHandlerOrchestrator {
156
160
  return true
157
161
  }
158
162
 
159
- private shouldHandlerBeCancelledByOtherHandler({handler, otherHandler}: {
163
+ private shouldHandlerBeCancelledByOtherHandler({ handler, otherHandler }: {
160
164
  handler: GestureHandler,
161
165
  otherHandler: GestureHandler
162
166
  }): boolean {
163
- const logger = this.logger.cloneWithPrefix(`shouldHandlerBeCancelledByOtherHandler(${handler.getTag()}, ${otherHandler.getTag()})`)
167
+ const logger =
168
+ this.logger.cloneAndJoinPrefix(`shouldHandlerBeCancelledByOtherHandler(${handler.getTag()}, ${otherHandler.getTag()})`)
164
169
  if (this.canRunSimultaneously(handler, otherHandler)) {
165
170
  logger.debug("false")
166
171
  return false;
@@ -176,7 +181,7 @@ export class GestureHandlerOrchestrator {
176
181
  }
177
182
 
178
183
  private canRunSimultaneously(handlerA: GestureHandler, handlerB: GestureHandler) {
179
- const logger = this.logger.cloneWithPrefix("canRunSimultaneously")
184
+ const logger = this.logger.cloneAndJoinPrefix("canRunSimultaneously")
180
185
  const result = handlerA === handlerB
181
186
  || handlerA.shouldRecognizeSimultaneously(handlerB)
182
187
  || handlerB.shouldRecognizeSimultaneously(handlerA)
@@ -275,7 +280,7 @@ export class GestureHandlerOrchestrator {
275
280
  }
276
281
 
277
282
  private cleanupAwaitingHandlers(handler: GestureHandler): void {
278
- const logger = this.logger.cloneWithPrefix(`cleanupAwaitingHandlers(handler=${handler.getTag()})`)
283
+ const logger = this.logger.cloneAndJoinPrefix(`cleanupAwaitingHandlers(handler=${handler.getTag()})`)
279
284
  logger.debug({ awaitingHandlers: this.awaitingHandlers })
280
285
  for (const awaitingHandler of this.awaitingHandlers) {
281
286
  if (
@@ -297,7 +302,9 @@ export class GestureHandlerOrchestrator {
297
302
 
298
303
  public registerHandlerIfNotPresent(handler: GestureHandler) {
299
304
  this.logger.info(`registerHandlerIfNotPresent(${handler.getTag()})`)
300
- if (this.gestureHandlers.includes(handler)) return;
305
+ if (this.gestureHandlers.includes(handler)) {
306
+ return;
307
+ }
301
308
  this.gestureHandlers.push(handler);
302
309
  handler.setActive(false);
303
310
  handler.setAwaiting(false);
@@ -315,7 +322,9 @@ export class GestureHandlerOrchestrator {
315
322
  public cancelMouseAndPenGestures(currentHandler: GestureHandler): void {
316
323
  this.logger.info("cancelMouseAndPenGestures")
317
324
  this.gestureHandlers.forEach((handler: GestureHandler) => {
318
- if (handler.getPointerType() !== PointerType.MOUSE && handler.getPointerType() !== PointerType.PEN) return;
325
+ if (handler.getPointerType() !== PointerType.MOUSE && handler.getPointerType() !== PointerType.PEN) {
326
+ return;
327
+ }
319
328
 
320
329
  if (handler !== currentHandler) {
321
330
  handler.cancel();
@@ -10,7 +10,7 @@ export class GestureHandlerRegistry {
10
10
  private logger: RNGHLogger
11
11
 
12
12
  constructor(viewRegistry: ViewRegistry | undefined, logger: RNGHLogger) {
13
- this.logger = logger.cloneWithPrefix("GestureHandlerRegistry")
13
+ this.logger = logger.cloneAndJoinPrefix("GestureHandlerRegistry")
14
14
  this.viewRegistry = viewRegistry
15
15
  }
16
16
 
@@ -19,7 +19,7 @@ export class GestureHandlerRegistry {
19
19
  }
20
20
 
21
21
  public bindGestureHandlerWithView(gestureHandlerTag: number, view: View) {
22
- this.logger.cloneWithPrefix("bindGestureHandlerWithView").debug({gestureHandlerTag, viewTag: view.getTag()})
22
+ this.logger.cloneAndJoinPrefix("bindGestureHandlerWithView").debug({gestureHandlerTag, viewTag: view.getTag()})
23
23
  const viewTag = view.getTag()
24
24
  if (!this.gestureHandlersByViewTag.has(viewTag))
25
25
  this.gestureHandlersByViewTag.set(viewTag, new Set())
@@ -9,7 +9,7 @@ export class InteractionManager {
9
9
  private logger: RNGHLogger
10
10
 
11
11
  constructor(logger: RNGHLogger) {
12
- this.logger = logger.cloneWithPrefix("InteractionManager")
12
+ this.logger = logger.cloneAndJoinPrefix("InteractionManager")
13
13
  }
14
14
 
15
15
  public configureInteractions(handler: GestureHandler, config: Config) {
@@ -60,7 +60,7 @@ export class InteractionManager {
60
60
  handler: GestureHandler,
61
61
  otherHandler: GestureHandler
62
62
  ): boolean {
63
- const logger = this.logger.cloneWithPrefix(`shouldWaitForHandlerFailure(${handler.getTag()}, ${otherHandler.getTag()})`)
63
+ const logger = this.logger.cloneAndJoinPrefix(`shouldWaitForHandlerFailure(${handler.getTag()}, ${otherHandler.getTag()})`)
64
64
  const waitFor = this.waitForRelations.get(
65
65
  handler.getTag()
66
66
  );
@@ -85,7 +85,7 @@ export class InteractionManager {
85
85
  handler: GestureHandler,
86
86
  otherHandler: GestureHandler
87
87
  ): boolean {
88
- const logger = this.logger.cloneWithPrefix(`shouldRecognizeSimultaneously(${handler.getTag()}, ${otherHandler.getTag()})`)
88
+ const logger = this.logger.cloneAndJoinPrefix(`shouldRecognizeSimultaneously(${handler.getTag()}, ${otherHandler.getTag()})`)
89
89
  const simultaneousHandlers: number[] | undefined =
90
90
  this.simultaneousRelations.get(handler.getTag());
91
91
  if (!simultaneousHandlers) {
@@ -122,7 +122,7 @@ export class InteractionManager {
122
122
  handler: GestureHandler,
123
123
  otherHandler: GestureHandler
124
124
  ): boolean {
125
- const logger = this.logger.cloneWithPrefix(`shouldHandlerBeCancelledBy(handler=${handler.getTag()}, otherHandler=${otherHandler.getTag()})`)
125
+ const logger = this.logger.cloneAndJoinPrefix(`shouldHandlerBeCancelledBy(handler=${handler.getTag()}, otherHandler=${otherHandler.getTag()})`)
126
126
  // We check constructor name instead of using `instanceof` in order do avoid circular dependencies
127
127
  // const isNativeHandler =
128
128
  // otherHandler.constructor.name === 'NativeViewGestureHandler';
@@ -0,0 +1,26 @@
1
+ export class Multiset<T> {
2
+ private multiplicityByElement: Map<T, number> = new Map();
3
+ private elements: T[] = [];
4
+
5
+ add(element: T) {
6
+ const count = this.multiplicityByElement.get(element) || 0;
7
+ if (count === 0) {
8
+ this.elements.push(element);
9
+ }
10
+ this.multiplicityByElement.set(element, count + 1);
11
+ }
12
+
13
+ remove(element: T) {
14
+ const count = this.multiplicityByElement.get(element) || 0;
15
+ if (count > 1) {
16
+ this.multiplicityByElement.set(element, count - 1);
17
+ } else {
18
+ this.multiplicityByElement.delete(element);
19
+ this.elements = this.elements.filter(v => v !== element);
20
+ }
21
+ }
22
+
23
+ getElements() {
24
+ return this.elements;
25
+ }
26
+ }
@@ -1,12 +1,16 @@
1
1
  export type RNGHLoggerMessage = string | Object
2
2
 
3
3
  export interface RNGHLogger {
4
- info(msg: string): void;
5
-
6
- cloneWithPrefix(prefix: string): RNGHLogger;
4
+ cloneAndJoinPrefix(prefix: string): RNGHLogger;
7
5
 
8
6
  debug(msg: RNGHLoggerMessage);
9
7
 
8
+ info(msg: string): void;
9
+
10
+ warn(warn: string);
11
+
10
12
  error(msg: string);
13
+
14
+ startTracing(): () => void
11
15
  }
12
16
 
@@ -1,7 +1,6 @@
1
1
  import { Tag, View } from "./View"
2
- import { ViewFinder } from "./ViewFinder"
3
2
 
4
- export interface ViewRegistry extends ViewFinder {
3
+ export interface ViewRegistry {
5
4
  getViewByTag(viewTag: Tag): View | undefined
6
5
  save(view: View): void
7
6
  deleteByTag(viewTag: Tag): void
@@ -11,5 +11,5 @@ export * from "./PointerTracker"
11
11
  export * from "./RNGHError"
12
12
  export * from "./State"
13
13
  export * from "./GestureHandlerRegistry"
14
- export * from "./ViewFinder"
15
- export * from "./ViewRegistry"
14
+ export * from "./ViewRegistry"
15
+ export * from './Multiset'
@@ -28,7 +28,15 @@ const DIAGONAL_DEVIATION_COSINE = coneToDeviation(90 - DEFAULT_ALIGNMENT_CONE);
28
28
 
29
29
  export class FlingGestureHandler extends GestureHandler {
30
30
  constructor(deps: GestureHandlerDependencies) {
31
- super({ ...deps, logger: deps.logger.cloneWithPrefix("FlingGestureHandler") })
31
+ super({ ...deps, logger: deps.logger.cloneAndJoinPrefix("FlingGestureHandler") })
32
+ }
33
+
34
+ override getName(): string {
35
+ return "FlingGestureHandler"
36
+ }
37
+
38
+ override isGestureContinuous(): boolean {
39
+ return true
32
40
  }
33
41
 
34
42
  getDefaultConfig() {
@@ -65,7 +73,7 @@ export class FlingGestureHandler extends GestureHandler {
65
73
  }
66
74
 
67
75
  private tryEndFling(): boolean {
68
- const logger = this.logger.cloneWithPrefix("tryEndFling")
76
+ const logger = this.logger.cloneAndJoinPrefix("tryEndFling")
69
77
  const velocityVector = this.tracker.getVelocity(this.keyPointer);
70
78
 
71
79
  const getAlignment = (
@@ -154,7 +162,7 @@ export class FlingGestureHandler extends GestureHandler {
154
162
  }
155
163
 
156
164
  private pointerMoveAction(event: IncomingEvent): void {
157
- this.logger.cloneWithPrefix("pointerMoveAction").info(JSON.stringify(event))
165
+ this.logger.cloneAndJoinPrefix("pointerMoveAction").info(JSON.stringify(event))
158
166
  this.tracker.track(event);
159
167
 
160
168
  if (this.currentState !== State.BEGAN) {
@@ -187,7 +195,7 @@ export class FlingGestureHandler extends GestureHandler {
187
195
  }
188
196
 
189
197
  private onUp(event: IncomingEvent): void {
190
- const logger = this.logger.cloneWithPrefix("onUp")
198
+ const logger = this.logger.cloneAndJoinPrefix("onUp")
191
199
  logger.info("start")
192
200
  if (this.currentState === State.BEGAN) {
193
201
  this.endFling();
@@ -22,19 +22,21 @@ export class GestureHandlerFactory {
22
22
  private orchestrator: GestureHandlerOrchestrator
23
23
  private logger: RNGHLogger
24
24
 
25
- constructor(private cleanLogger: RNGHLogger, private scrollLocker: ScrollLocker, private interactionManager: InteractionManager, private rnGestureResponder: RNGestureResponder) {
26
- this.logger = cleanLogger.cloneWithPrefix("Factory")
27
- this.orchestrator = new GestureHandlerOrchestrator(cleanLogger.cloneWithPrefix("Orchestrator"))
25
+ constructor(private cleanLogger: RNGHLogger, private scrollLocker: ScrollLocker,
26
+ private interactionManager: InteractionManager, private rnGestureResponder: RNGestureResponder) {
27
+ this.logger = cleanLogger.cloneAndJoinPrefix("GestureHandlerFactory")
28
+ this.orchestrator = new GestureHandlerOrchestrator(cleanLogger)
28
29
  }
29
30
 
30
31
  create(handlerName: string, handlerTag: number): GestureHandler {
31
- this.logger.info(`create ${handlerName} with handlerTag: ${handlerTag}`)
32
+ this.logger.cloneAndJoinPrefix(`create`).debug(`(handlerName=${handlerName}, handlerTag=${handlerTag})`);
33
+
32
34
  const deps: GestureHandlerDependencies = {
33
35
  tracker: new PointerTracker(),
34
36
  orchestrator: this.orchestrator,
35
37
  handlerTag,
36
38
  interactionManager: this.interactionManager,
37
- logger: this.cleanLogger.cloneWithPrefix("GestureHandler"),
39
+ logger: this.cleanLogger,
38
40
  scrollLocker: this.scrollLocker,
39
41
  rnGestureResponder: this.rnGestureResponder,
40
42
  }
@@ -60,5 +62,6 @@ export class GestureHandlerFactory {
60
62
  this.logger.info(msg)
61
63
  throw new RNGHError(msg)
62
64
  }
65
+
63
66
  }
64
67
  }