@applicaster/zapp-react-dom-app 13.0.0-rc.38 → 13.0.0-rc.39

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.
@@ -31,7 +31,10 @@ import {
31
31
  import { PlayerContentContext } from "@applicaster/zapp-react-dom-ui-components/Contexts";
32
32
 
33
33
  import { withNavigator } from "@applicaster/zapp-react-native-ui-components/Decorators/Navigator";
34
- import { getXray } from "@applicaster/zapp-react-native-utils/logger";
34
+ import {
35
+ getXray,
36
+ createLogger,
37
+ } from "@applicaster/zapp-react-native-utils/logger";
35
38
 
36
39
  import {
37
40
  confirmationDialogStore,
@@ -51,6 +54,11 @@ import { KeyInputHandler } from "@applicaster/zapp-react-native-utils/appUtils/k
51
54
  const { withXray } = getXray();
52
55
  const globalAny: any = global;
53
56
 
57
+ const { log_debug, log_warning } = createLogger({
58
+ category: "InteractionManager",
59
+ subsystem: "zapp-react-dom-app",
60
+ });
61
+
54
62
  const shouldUseOnScreenKeyboard = () =>
55
63
  isVizioPlatform() || window.applicaster.useOnScreenKeyboard;
56
64
 
@@ -283,8 +291,7 @@ class InteractionManagerClass extends React.Component<Props, State> {
283
291
  this.handleWebOsBack();
284
292
  }
285
293
  } catch (e) {
286
- // eslint-disable-next-line no-console
287
- console.warn("Failed to execute platformBack", e);
294
+ log_warning("Failed to execute platformBack", e);
288
295
  }
289
296
  }
290
297
 
@@ -378,23 +385,103 @@ class InteractionManagerClass extends React.Component<Props, State> {
378
385
  }
379
386
  }
380
387
 
381
- onKeyDown(event) {
388
+ /**
389
+ When pressing escape or the Native "Back" button:
390
+ if on the transport controls: we show the player
391
+ if on the player : we show the UI
392
+ if on the UI : we exit the app
393
+ note: backspace affects the keyboard input, so it behaves differently
394
+ */
395
+ onBackPress(event) {
382
396
  const { displayState, setDisplayState, navigator } = this.props;
397
+ const { isDialogVisible } = confirmationDialogStore.getState();
383
398
  const { isKeyboardVisible } = this.state;
384
399
 
385
- const { isDialogVisible } = confirmationDialogStore.getState();
400
+ log_debug("onBackPress", {
401
+ eventCode: event.code,
402
+ displayState,
403
+ isDialogVisible,
404
+ isKeyboardVisible,
405
+ });
386
406
 
387
407
  if (isKeyboardVisible && shouldUseOnScreenKeyboard()) {
388
- if (keyCode(event).matchesAny("Escape", "Back")) {
389
- this.handleKeyboardDismiss();
390
- }
391
-
408
+ this.handleKeyboardDismiss();
392
409
  event.preventDefault();
393
410
  event.stopPropagation();
394
411
 
395
412
  return;
396
413
  }
397
414
 
415
+ switch (displayState) {
416
+ case DISPLAY_STATES.DEFAULT:
417
+ case DISPLAY_STATES.PLAYER:
418
+ if (isDialogVisible) {
419
+ this.onConfirmDialogClose();
420
+ } else if (navigator.canGoBack()) {
421
+ navigator.goBack();
422
+ } else if (this.isHomeScreen()) {
423
+ this.platformBack();
424
+ } else if (navigator.currentRoute.includes("hook")) {
425
+ // If code reaches this block navigator cant go back, it is not home,
426
+ // and this is a login plugin that was pushed on top of the home
427
+ // Treat it like a home screen and run platformBack()
428
+ const entryData = navigator?.data?.entry;
429
+ const isHookInHomescreen = entryData?.payload?.home;
430
+
431
+ const isHookFlowBlocker =
432
+ typeof entryData?.hookPlugin?.module?.isFlowBlocker === "function"
433
+ ? entryData?.hookPlugin?.module?.isFlowBlocker()
434
+ : entryData?.hookPlugin?.module?.isFlowBlocker;
435
+
436
+ if (isHookInHomescreen && isHookFlowBlocker) {
437
+ this.platformBack();
438
+ } else {
439
+ navigator.goBack(false, true);
440
+ }
441
+ } else {
442
+ this.goToHome();
443
+ }
444
+
445
+ break;
446
+ case DISPLAY_STATES.HUD:
447
+ // IF transport controls are open, close them instead of closing player
448
+ setDisplayState(DISPLAY_STATES.PLAYER);
449
+ break;
450
+ default:
451
+ setDisplayState(DISPLAY_STATES.PLAYER);
452
+ break;
453
+ }
454
+ }
455
+
456
+ onBackspacePress(event) {
457
+ const isInputFocused =
458
+ document.activeElement instanceof HTMLInputElement ||
459
+ document.activeElement instanceof HTMLTextAreaElement;
460
+
461
+ // Don't handle backspace if input is focused
462
+ if (isInputFocused) {
463
+ return;
464
+ }
465
+
466
+ this.onBackPress(event);
467
+ }
468
+
469
+ onKeyDown(event) {
470
+ const { displayState, setDisplayState, navigator } = this.props;
471
+ const { isDialogVisible } = confirmationDialogStore.getState();
472
+
473
+ if (keyCode(event).matches("Backspace")) {
474
+ this.onBackspacePress(event);
475
+
476
+ return;
477
+ }
478
+
479
+ if (keyCode(event).matchesAny(KEYS.Back, KEYS.Escape, KEYS.EscapeDevice)) {
480
+ this.onBackPress(event);
481
+
482
+ return;
483
+ }
484
+
398
485
  if (this.keySupportsLongPress(event)) {
399
486
  this.longPressDetector.monitorKeyPress(event.code, event);
400
487
  }
@@ -460,55 +547,6 @@ class InteractionManagerClass extends React.Component<Props, State> {
460
547
  }
461
548
  }
462
549
 
463
- /**
464
- When pressing escape or the Native "Back" button:
465
- if on the transport controls: we show the player
466
- if on the player : we show the UI
467
- if on the UI : we exit the app
468
- note: backspace affects the keyboard input, so it not handled here
469
- */
470
- if (keyCode(event).matchesAny(KEYS.Back, KEYS.Escape, KEYS.EscapeDevice)) {
471
- switch (displayState) {
472
- case DISPLAY_STATES.DEFAULT:
473
- case DISPLAY_STATES.PLAYER:
474
- if (isDialogVisible) {
475
- this.onConfirmDialogClose();
476
- } else if (navigator.canGoBack()) {
477
- navigator.goBack();
478
- } else if (this.isHomeScreen()) {
479
- this.platformBack();
480
- } else if (navigator.currentRoute.includes("hook")) {
481
- // If code reaches this block navigator cant go back, it is not home,
482
- // and this is a login plugin that was pushed on top of the home
483
- // Treat it like a home screen and run platformBack()
484
- const entryData = navigator?.data?.entry;
485
- const isHookInHomescreen = entryData?.payload?.home;
486
-
487
- const isHookFlowBlocker =
488
- typeof entryData?.hookPlugin?.module?.isFlowBlocker === "function"
489
- ? entryData?.hookPlugin?.module?.isFlowBlocker()
490
- : entryData?.hookPlugin?.module?.isFlowBlocker;
491
-
492
- if (isHookInHomescreen && isHookFlowBlocker) {
493
- this.platformBack();
494
- } else {
495
- navigator.goBack(false, true);
496
- }
497
- } else {
498
- this.goToHome();
499
- }
500
-
501
- break;
502
- case DISPLAY_STATES.HUD:
503
- // IF transport controls are open, close them instead of closing player
504
- setDisplayState(DISPLAY_STATES.PLAYER);
505
- break;
506
- default:
507
- setDisplayState(DISPLAY_STATES.PLAYER);
508
- break;
509
- }
510
- }
511
-
512
550
  if (
513
551
  keyCode(event).matches(KEYS.Enter) ||
514
552
  (__DEV__ && keyCode(event).matches(KEYS.X))
@@ -533,10 +571,7 @@ class InteractionManagerClass extends React.Component<Props, State> {
533
571
  this.platformBack();
534
572
  }
535
573
 
536
- if (
537
- keyCode(event).matchesAny(...ARROW_KEYS) &&
538
- !this.state.isKeyboardVisible
539
- ) {
574
+ if (keyCode(event).matchesAny(...ARROW_KEYS)) {
540
575
  if (displayState === DISPLAY_STATES.PLAYER) {
541
576
  setDisplayState(DISPLAY_STATES.HUD);
542
577
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-dom-app",
3
- "version": "13.0.0-rc.38",
3
+ "version": "13.0.0-rc.39",
4
4
  "description": "Zapp App Component for Applicaster's Quick Brick React Native App",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "homepage": "https://github.com/applicaster/zapp-react-dom-app#readme",
24
24
  "dependencies": {
25
- "@applicaster/zapp-react-dom-ui-components": "13.0.0-rc.38",
26
- "@applicaster/zapp-react-native-bridge": "13.0.0-rc.38",
27
- "@applicaster/zapp-react-native-redux": "13.0.0-rc.38",
28
- "@applicaster/zapp-react-native-ui-components": "13.0.0-rc.38",
29
- "@applicaster/zapp-react-native-utils": "13.0.0-rc.38",
25
+ "@applicaster/zapp-react-dom-ui-components": "13.0.0-rc.39",
26
+ "@applicaster/zapp-react-native-bridge": "13.0.0-rc.39",
27
+ "@applicaster/zapp-react-native-redux": "13.0.0-rc.39",
28
+ "@applicaster/zapp-react-native-ui-components": "13.0.0-rc.39",
29
+ "@applicaster/zapp-react-native-utils": "13.0.0-rc.39",
30
30
  "abortcontroller-polyfill": "^1.7.5",
31
31
  "react-router-dom": "^5.1.2",
32
32
  "typeface-montserrat": "^0.0.54",