@applicaster/zapp-react-dom-app 13.0.0-alpha.4863201005 → 13.0.0-alpha.4951885994

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
 
@@ -140,13 +148,16 @@ class InteractionManagerClass extends React.Component<Props, State> {
140
148
  this.onConfirmDialogOpen = this.onConfirmDialogOpen.bind(this);
141
149
  this.onConfirmDialogClose = this.onConfirmDialogClose.bind(this);
142
150
 
151
+ this.handlePhysicalKeyboardDismiss =
152
+ this.handlePhysicalKeyboardDismiss.bind(this);
153
+
143
154
  this.confirmDialog.setConfirmAction(this.performExit);
144
155
  this.confirmDialog.setCancelAction(this.onConfirmDialogClose);
145
156
  this.longPressDetector = new KeyboardLongPressManager();
146
157
  }
147
158
 
148
159
  componentDidMount() {
149
- window.addEventListener("keydown", this.onKeyDownListener);
160
+ window.addEventListener("keydown", this.onKeyDownListener, true);
150
161
  window.addEventListener("keyup", this.onKeyUp);
151
162
  window.addEventListener("mousemove", this.onMouseMoveListener);
152
163
 
@@ -181,6 +192,11 @@ class InteractionManagerClass extends React.Component<Props, State> {
181
192
  "onLongPressRelease",
182
193
  this.handleLongPressRelease.bind(this)
183
194
  );
195
+
196
+ document.addEventListener(
197
+ "keyboardDismissedByPhysicalKeypress",
198
+ this.handlePhysicalKeyboardDismiss
199
+ );
184
200
  }
185
201
 
186
202
  componentWillUnmount() {
@@ -209,6 +225,11 @@ class InteractionManagerClass extends React.Component<Props, State> {
209
225
  "onLongPressRelease",
210
226
  this.handleLongPressRelease
211
227
  );
228
+
229
+ document.removeEventListener(
230
+ "keyboardDismissedByPhysicalKeypress",
231
+ this.handlePhysicalKeyboardDismiss
232
+ );
212
233
  }
213
234
 
214
235
  performExit() {
@@ -270,8 +291,7 @@ class InteractionManagerClass extends React.Component<Props, State> {
270
291
  this.handleWebOsBack();
271
292
  }
272
293
  } catch (e) {
273
- // eslint-disable-next-line no-console
274
- console.warn("Failed to execute platformBack", e);
294
+ log_warning("Failed to execute platformBack", e);
275
295
  }
276
296
  }
277
297
 
@@ -365,23 +385,103 @@ class InteractionManagerClass extends React.Component<Props, State> {
365
385
  }
366
386
  }
367
387
 
368
- 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) {
369
396
  const { displayState, setDisplayState, navigator } = this.props;
397
+ const { isDialogVisible } = confirmationDialogStore.getState();
370
398
  const { isKeyboardVisible } = this.state;
371
399
 
372
- const { isDialogVisible } = confirmationDialogStore.getState();
400
+ log_debug("onBackPress", {
401
+ eventCode: event.code,
402
+ displayState,
403
+ isDialogVisible,
404
+ isKeyboardVisible,
405
+ });
373
406
 
374
407
  if (isKeyboardVisible && shouldUseOnScreenKeyboard()) {
375
- if (keyCode(event).matchesAny("Escape", "Back")) {
376
- this.handleKeyboardDismiss();
377
- }
378
-
408
+ this.handleKeyboardDismiss();
379
409
  event.preventDefault();
380
410
  event.stopPropagation();
381
411
 
382
412
  return;
383
413
  }
384
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
+
385
485
  if (this.keySupportsLongPress(event)) {
386
486
  this.longPressDetector.monitorKeyPress(event.code, event);
387
487
  }
@@ -447,62 +547,6 @@ class InteractionManagerClass extends React.Component<Props, State> {
447
547
  }
448
548
  }
449
549
 
450
- /**
451
- When pressing backspace or the Native "Back" button:
452
- if on the transport controls: we show the player
453
- if on the player : we show the UI
454
- if on the UI : we exit the app
455
- */
456
-
457
- if (
458
- keyCode(event).matchesAny(
459
- KEYS.Back,
460
- KEYS.Escape,
461
- KEYS.EscapeDevice,
462
- KEYS.Backspace
463
- )
464
- ) {
465
- switch (displayState) {
466
- case DISPLAY_STATES.DEFAULT:
467
- case DISPLAY_STATES.PLAYER:
468
- if (isDialogVisible) {
469
- this.onConfirmDialogClose();
470
- } else if (navigator.canGoBack()) {
471
- navigator.goBack();
472
- } else if (this.isHomeScreen()) {
473
- this.platformBack();
474
- } else if (navigator.currentRoute.includes("hook")) {
475
- // If code reaches this block navigator cant go back, it is not home,
476
- // and this is a login plugin that was pushed on top of the home
477
- // Treat it like a home screen and run platformBack()
478
- const entryData = navigator?.data?.entry;
479
- const isHookInHomescreen = entryData?.payload?.home;
480
-
481
- const isHookFlowBlocker =
482
- typeof entryData?.hookPlugin?.module?.isFlowBlocker === "function"
483
- ? entryData?.hookPlugin?.module?.isFlowBlocker()
484
- : entryData?.hookPlugin?.module?.isFlowBlocker;
485
-
486
- if (isHookInHomescreen && isHookFlowBlocker) {
487
- this.platformBack();
488
- } else {
489
- navigator.goBack(false, true);
490
- }
491
- } else {
492
- this.goToHome();
493
- }
494
-
495
- break;
496
- case DISPLAY_STATES.HUD:
497
- // IF transport controls are open, close them instead of closing player
498
- setDisplayState(DISPLAY_STATES.PLAYER);
499
- break;
500
- default:
501
- setDisplayState(DISPLAY_STATES.PLAYER);
502
- break;
503
- }
504
- }
505
-
506
550
  if (
507
551
  keyCode(event).matches(KEYS.Enter) ||
508
552
  (__DEV__ && keyCode(event).matches(KEYS.X))
@@ -510,6 +554,7 @@ class InteractionManagerClass extends React.Component<Props, State> {
510
554
  if (displayState === DISPLAY_STATES.PLAYER) {
511
555
  setDisplayState(DISPLAY_STATES.HUD);
512
556
  } else {
557
+ focusManager.pressIn();
513
558
  focusManager.press();
514
559
  }
515
560
 
@@ -526,10 +571,7 @@ class InteractionManagerClass extends React.Component<Props, State> {
526
571
  this.platformBack();
527
572
  }
528
573
 
529
- if (
530
- keyCode(event).matchesAny(...ARROW_KEYS) &&
531
- !this.state.isKeyboardVisible
532
- ) {
574
+ if (keyCode(event).matchesAny(...ARROW_KEYS)) {
533
575
  if (displayState === DISPLAY_STATES.PLAYER) {
534
576
  setDisplayState(DISPLAY_STATES.HUD);
535
577
  }
@@ -652,7 +694,7 @@ class InteractionManagerClass extends React.Component<Props, State> {
652
694
  }
653
695
  }
654
696
 
655
- handleKeyboardDismiss = () => {
697
+ handleKeyboardDismiss() {
656
698
  this.isDismissing = true;
657
699
 
658
700
  this.setState(
@@ -663,9 +705,10 @@ class InteractionManagerClass extends React.Component<Props, State> {
663
705
  },
664
706
  () => {
665
707
  this.isDismissing = false;
708
+ focusManager.recoverFocus();
666
709
  }
667
710
  );
668
- };
711
+ }
669
712
 
670
713
  handleKeyboardInput = (value: string) => {
671
714
  const { activeInputRef } = this.state;
@@ -761,6 +804,35 @@ class InteractionManagerClass extends React.Component<Props, State> {
761
804
  ].includes(event.code);
762
805
  }
763
806
 
807
+ handlePhysicalKeyboardDismiss(event: CustomEvent) {
808
+ const { value, position, inputElement } = event.detail;
809
+
810
+ this.isDismissing = true;
811
+
812
+ this.setState(
813
+ {
814
+ isKeyboardVisible: false,
815
+ keyboardInput: "",
816
+ activeInputRef: null,
817
+ },
818
+ () => {
819
+ if (inputElement) {
820
+ inputElement.value = value;
821
+ inputElement.focus();
822
+ inputElement.setSelectionRange(position, position);
823
+
824
+ const keyboardEvent = new CustomEvent("keyboardUpdate", {
825
+ detail: { value },
826
+ });
827
+
828
+ document.dispatchEvent(keyboardEvent);
829
+ }
830
+
831
+ this.isDismissing = false;
832
+ }
833
+ );
834
+ }
835
+
764
836
  render() {
765
837
  return (
766
838
  (shouldUseOnScreenKeyboard() && this.state.isKeyboardVisible && (
@@ -3,11 +3,6 @@ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils"
3
3
  import { QuickBrickCommunicationModule } from "../../Polyfills/QuickBrickCommunicationModule";
4
4
  import { loadLocaleImpl, getLanguageCode } from "./utils";
5
5
 
6
- type Locale = {
7
- language: string;
8
- country: string;
9
- };
10
-
11
6
  async function getBrowserLocale() {
12
7
  return navigator.language;
13
8
  }
@@ -19,7 +14,7 @@ async function getSamsungLocale() {
19
14
  }
20
15
 
21
16
  try {
22
- tizen.systeminfo.getPropertyValue("LOCALE", (locale: Locale) => {
17
+ tizen.systeminfo.getPropertyValue("LOCALE", (locale) => {
23
18
  resolve(locale.language);
24
19
  });
25
20
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-dom-app",
3
- "version": "13.0.0-alpha.4863201005",
3
+ "version": "13.0.0-alpha.4951885994",
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-alpha.4863201005",
26
- "@applicaster/zapp-react-native-bridge": "13.0.0-alpha.4863201005",
27
- "@applicaster/zapp-react-native-redux": "13.0.0-alpha.4863201005",
28
- "@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.4863201005",
29
- "@applicaster/zapp-react-native-utils": "13.0.0-alpha.4863201005",
25
+ "@applicaster/zapp-react-dom-ui-components": "13.0.0-alpha.4951885994",
26
+ "@applicaster/zapp-react-native-bridge": "13.0.0-alpha.4951885994",
27
+ "@applicaster/zapp-react-native-redux": "13.0.0-alpha.4951885994",
28
+ "@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.4951885994",
29
+ "@applicaster/zapp-react-native-utils": "13.0.0-alpha.4951885994",
30
30
  "abortcontroller-polyfill": "^1.7.5",
31
31
  "react-router-dom": "^5.1.2",
32
32
  "typeface-montserrat": "^0.0.54",
@@ -37,15 +37,14 @@
37
37
  "peerDependencies": {
38
38
  "@applicaster/zapp-pipes-v2-client": "*",
39
39
  "@react-native-community/netinfo": "*",
40
- "@types/node": "*",
41
40
  "core-js": "3.29.1",
42
41
  "immer": "*",
43
- "react": "17.0.2",
44
- "react-dom": "17.0.2",
42
+ "react": "*",
43
+ "react-dom": "*",
45
44
  "react-native": "*",
46
45
  "react-native-safe-area-context": "*",
47
46
  "react-native-svg": "*",
48
- "react-native-web": "0.18.11",
47
+ "react-native-web": "*",
49
48
  "uglify-js": "*",
50
49
  "validate-color": "*",
51
50
  "zustand": "*"