@24i/bigscreen-sdk 1.0.17-alpha.2323 → 1.0.17-alpha.2326

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/bigscreen-sdk",
3
- "version": "1.0.17-alpha.2323",
3
+ "version": "1.0.17-alpha.2326",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "homepage": "https://github.com/24i/smartapps-bigscreen-sdk#readme",
39
39
  "dependencies": {
40
- "@24i/appstage-shared-analytics": "1.0.15-alpha.53",
40
+ "@24i/appstage-shared-analytics": "1.0.16-alpha.58",
41
41
  "@24i/appstage-shared-events-manager": "1.0.7",
42
42
  "@24i/appstage-shared-perf-utils": "1.0.5",
43
43
  "@24i/player-base": "6.10.0",
@@ -62,7 +62,7 @@
62
62
  "@types/jest": "^29.2.3",
63
63
  "@types/minimist": "^1.2.2",
64
64
  "@types/node": "^18.7.18",
65
- "@types/react": "^18.0.28",
65
+ "@types/react": "^18.0.33",
66
66
  "babel-jest": "^29.4.3",
67
67
  "chalk": "^5.2.0",
68
68
  "coveralls": "^3.1.1",
@@ -279,6 +279,7 @@
279
279
  "./utils/timers": "./packages/utils/src/timers/index.ts",
280
280
  "./utils/wait": "./packages/utils/src/wait.ts",
281
281
  "./utils/xhr": "./packages/utils/src/xhr/index.ts",
282
+ "./utils/keyPress": "./packages/utils/src/keyPress/index.ts",
282
283
  "./utils": "./packages/utils/src/index.ts",
283
284
  "./volume-control/interface": "./packages/volume-control/src/IVolumeControlUI.ts",
284
285
  "./volume-control": "./packages/volume-control/src/index.ts",
@@ -106,6 +106,7 @@ export const gtagPayloadParams: Record<string, string> = {
106
106
  seriesTitle: `${stringParameter}.video_series_title`,
107
107
  url: `${stringParameter}.video_url`,
108
108
  assetId: `${stringParameter}.video_asset_id`,
109
+ externalId: `${stringParameter}.video_external_id`,
109
110
  channelNumber: `${numericParameter}.channel_number`,
110
111
  channelTitle: `${stringParameter}.channel_title`,
111
112
  };
@@ -7,31 +7,12 @@ export const Interactable = forwardRef<Props>(
7
7
  ref: Reference<HTMLDivElement> | null) => {
8
8
  const domRef = ref || createRef<HTMLDivElement>();
9
9
 
10
- let keyIsReleased = true;
11
-
12
- const releaseKey = () => {
13
- keyIsReleased = true;
14
- window.removeEventListener('keyup', releaseKey);
15
- };
16
-
17
- const onClickProxy = (e: MouseEvent) => {
10
+ const onPressProxy = (e: MouseEvent | KeyboardEvent) => {
18
11
  if (typeof onPress === 'function' && isClickOrEnter(e)) {
19
12
  onPress(e);
20
13
  }
21
14
  };
22
15
 
23
- const onKeyDownProxy = (e: KeyboardEvent) => {
24
- if (typeof onPress === 'function' && isClickOrEnter(e) && keyIsReleased) {
25
- if (blockRepeatedKeyDown) {
26
- keyIsReleased = false;
27
- window.addEventListener('keyup', releaseKey);
28
- onPress(e);
29
- } else {
30
- onPress(e);
31
- }
32
- }
33
- };
34
-
35
16
  const onMouseEnter = () => {
36
17
  domRef.current!.focus({ preventScroll: true });
37
18
  };
@@ -41,8 +22,8 @@ export const Interactable = forwardRef<Props>(
41
22
  {...otherProps}
42
23
  ref={domRef}
43
24
  onMouseEnter={onMouseEnter}
44
- onClick={onClickProxy}
45
- onKeyDown={onKeyDownProxy}
25
+ onClick={onPressProxy}
26
+ onKeyDown={onPressProxy}
46
27
  tabIndex={0}
47
28
  >
48
29
  {children}
@@ -1406,7 +1406,7 @@ declare namespace React {
1406
1406
  onCompositionUpdateCapture?: CompositionEventHandler<T> | undefined;
1407
1407
 
1408
1408
  // Focus Events
1409
- onFocus?: (event: any) => void;
1409
+ onFocus?: (event: globalThis.FocusEvent) => void;
1410
1410
  onFocusCapture?: (event: globalThis.FocusEvent) => void;
1411
1411
  onBlur?: (event: globalThis.FocusEvent) => void;
1412
1412
  onBlurCapture?: (event: globalThis.FocusEvent) => void;
@@ -35,6 +35,8 @@ import { generateUuid } from '@24i/bigscreen-sdk/utils/generateUuid';
35
35
  - **[timers](#timers)** - functions to simplify work with setTimeout and setInterval.
36
36
  - **[counter](#counter)** - exports `createCounter` that allows you to add value to counter till callback is triggered at some point.
37
37
  - **[xhr](#xhr)** - provides wrap over `XMLHttpRequest`, with the possibility to repeat the failing request.
38
+ - **[simulateKeyPress](#simulateKeyPress)** - simulate key press in the `keydown` handler.
39
+ - **[keyPressSimulator](#keyPressSimulator)** - simulate key press globally for the specific keys.
38
40
 
39
41
  ### addClass
40
42
  Adds a class to the element in the reference.
@@ -347,3 +349,11 @@ const retryConfig = {
347
349
  const options = { ...xhrSendOptions, retryConfig };
348
350
  const response = await xhrSendRetry(url, options);
349
351
  ```
352
+
353
+ ### keyPressSimulator and simulateKeyPress
354
+ Modifies `keydown` event behavior to be similar to `keypress` and causes triggering `keydown` event only once
355
+ before the key is released. This is because `keypress` event is deprecated and it is not implemented
356
+ with the same behavior on all platforms.
357
+
358
+ - Use globally for the specific keys with `keyPressSimulator` util.
359
+ - Use locally in the `keydown` handler with `simulateKeyPress` util.
@@ -34,3 +34,8 @@ export {
34
34
  } from './timeConstants';
35
35
  export { xhrSend, xhrSendRetry, defaultRetryConfig, mockXhr } from './xhr';
36
36
  export type { XhrOptions, XhrResponse, RetryConfig, RSOptions, ShouldRetryParam } from './xhr';
37
+ export {
38
+ registerKeyPressSimulator,
39
+ unregisterKeyPressSimulator,
40
+ simulateKeyPress,
41
+ } from './keyPress';
@@ -0,0 +1,2 @@
1
+ export { registerKeyPressSimulator, unregisterKeyPressSimulator } from './keyPressSimulator';
2
+ export { simulateKeyPress } from './simulateKeyPress';
@@ -0,0 +1,44 @@
1
+ import { Key } from '@24i/bigscreen-sdk/driver-base/keymap';
2
+ import { stopEvent } from '@24i/bigscreen-sdk/utils';
3
+
4
+ let keysPressed: Record<number, boolean>;
5
+
6
+ const onKeyDown = (e: KeyboardEvent) => {
7
+ const { keyCode } = e;
8
+ if (keysPressed[keyCode] === true) {
9
+ stopEvent(e);
10
+ } else if (typeof keysPressed[keyCode] !== 'undefined') {
11
+ keysPressed[keyCode] = true;
12
+ }
13
+ };
14
+
15
+ const onKeyUp = (e: KeyboardEvent) => {
16
+ const { keyCode } = e;
17
+ if (keysPressed[keyCode] === true) keysPressed[keyCode] = false;
18
+ };
19
+
20
+ /**
21
+ * Modifies `keydown` event behavior to similar to `keypress` and causes
22
+ * triggering `keydown` event only once before the key is released. This is
23
+ * because `keypress` event is deprecated and it is not implemented with the same
24
+ * behavior on all platforms. This functionality is applied across the board for
25
+ * all provided keys globally. To use in one specific handler only
26
+ * use `simulateKeyPress` util.
27
+ * @param keys array with keys to behave as keypress
28
+ */
29
+ export const registerKeyPressSimulator = (keys: Key[]) => {
30
+ keysPressed = {};
31
+ keys.forEach((key) => {
32
+ keysPressed[key.keyCode] = false;
33
+ });
34
+ window.document.addEventListener('keydown', onKeyDown, true);
35
+ window.document.addEventListener('keyup', onKeyUp, true);
36
+ };
37
+
38
+ /**
39
+ * Unregister key press simulator events, turn off the functionality.
40
+ */
41
+ export const unregisterKeyPressSimulator = () => {
42
+ window.document.removeEventListener('keydown', onKeyDown, true);
43
+ window.document.removeEventListener('keyup', onKeyUp, true);
44
+ };
@@ -0,0 +1,25 @@
1
+ const NO_KEY = -1;
2
+
3
+ /**
4
+ * Returns a new `keydown` handler wrapped with the simulated key press functionality.
5
+ * Modifies `keydown` event behavior to similar to `keypress` and causes triggering keydown
6
+ * event only once before the key is released. This is because `keypress` event is deprecated
7
+ * and it is not implemented with the same behavior on all platforms. Apply this globally for
8
+ * the specific keys by using `keyPressSimulator` util.
9
+ * @param onKeyDown original handler for keydown event
10
+ * @returns decorated handler with key press functionality
11
+ */
12
+ export const simulateKeyPress = (onKeyDown: (e: KeyboardEvent) => void) => {
13
+ let keyPressed = NO_KEY;
14
+ const onKeyUp = (e: KeyboardEvent) => {
15
+ if (e.keyCode !== keyPressed) return;
16
+ window.document.removeEventListener('keyup', onKeyUp);
17
+ keyPressed = NO_KEY;
18
+ };
19
+ return (e: KeyboardEvent) => {
20
+ if (keyPressed !== NO_KEY) return;
21
+ keyPressed = e.keyCode;
22
+ window.document.addEventListener('keyup', onKeyUp);
23
+ onKeyDown(e);
24
+ };
25
+ };