@applicaster/zapp-react-native-utils 12.0.0-alpha.4043183114 → 12.0.0-alpha.4155487673
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/analyticsUtils/AnalyticPlayerListener.ts +141 -0
- package/analyticsUtils/PlayerAnalyticsManager.ts +90 -0
- package/analyticsUtils/{analyticsTracker.ts → playerAnalyticsTracker.ts} +19 -10
- package/appUtils/HooksManager/{Hook.ts → Hook.js} +11 -17
- package/appUtils/HooksManager/{constants.ts → constants.js} +1 -1
- package/appUtils/HooksManager/{index.ts → index.js} +109 -98
- package/appUtils/RiverFocusManager/index.js +12 -17
- package/appUtils/accessibilityManager/hooks.ts +16 -7
- package/appUtils/accessibilityManager/index.ts +42 -26
- package/appUtils/focusManager/treeDataStructure/Tree/index.js +3 -2
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +3 -1
- package/appUtils/{index.ts → index.js} +1 -1
- package/appUtils/keyCodes/{index.ts → index.js} +0 -2
- package/appUtils/keyCodes/{keys/keyEventMapper.ts → keys.android.js} +19 -0
- package/appUtils/keyCodes/keys.ios.js +46 -0
- package/appUtils/platform/platformUtils.ts +14 -0
- package/appUtils/playerManager/index.ts +9 -27
- package/appUtils/playerManager/playerNative.ts +1 -1
- package/cellUtils/index.ts +38 -5
- package/domUtils/{cookieManager.ts → cookieManager.js} +2 -1
- package/functionUtils/index.ts +11 -15
- package/index.d.ts +15 -0
- package/modalState/index.ts +5 -1
- package/navigationUtils/index.ts +5 -14
- package/numberUtils/__tests__/toNumber.test.ts +2 -2
- package/package.json +2 -2
- package/playerUtils/imaScriptDom.ts +59 -0
- package/reactHooks/debugging/__tests__/index.test.js +81 -11
- package/reactHooks/navigation/index.ts +4 -7
- package/reactHooks/resolvers/useCellResolver.ts +5 -1
- package/reactUtils/index.ts +15 -2
- package/appUtils/HooksManager/types.ts +0 -93
- package/appUtils/keyCodes/keys/index.ts +0 -3
- package/appUtils/keyCodes/keys/keys.android.ts +0 -18
- package/appUtils/keyCodes/keys/keys.ios.ts +0 -25
- package/appUtils/keyCodes/keys/keys.ts +0 -15
- /package/appUtils/HooksManager/{logger.ts → logger.js} +0 -0
- /package/appUtils/{directionHelper.ts → directionHelper.js} +0 -0
- /package/appUtils/keyCodes/{androidTVKeys.ts → androidTVKeys.js} +0 -0
- /package/appUtils/keyCodes/{keys/keys.web.ts → keys.web.js} +0 -0
- /package/appUtils/keyCodes/{keys/keysByPlatform.ts → keysByPlatform.js} +0 -0
- /package/appUtils/{localizationsHelper.ts → localizationsHelper.js} +0 -0
- /package/domUtils/{logger.ts → logger.js} +0 -0
|
@@ -26,7 +26,7 @@ export const riverFocusManager = (function () {
|
|
|
26
26
|
/**
|
|
27
27
|
* Retrieve screen focus data by id
|
|
28
28
|
*
|
|
29
|
-
* @param {
|
|
29
|
+
* @param {String} screenFocusableGroupId Id that was used to save screen data.
|
|
30
30
|
*
|
|
31
31
|
*/
|
|
32
32
|
function screenFocusableData({ screenFocusableGroupId }) {
|
|
@@ -36,9 +36,8 @@ export const riverFocusManager = (function () {
|
|
|
36
36
|
/**
|
|
37
37
|
* Clear screen data for specific screen
|
|
38
38
|
*
|
|
39
|
-
* @param {
|
|
40
|
-
*
|
|
41
|
-
* isInsideContainer If this screen a screen picker child
|
|
39
|
+
* @param {String} screenId Unique Id of the screen from layout.json
|
|
40
|
+
* @param {boolean} isInsideContainer If this screen a screen picker child
|
|
42
41
|
*
|
|
43
42
|
*/
|
|
44
43
|
function clearScreenData({ screenId, isInsideContainer }) {
|
|
@@ -61,13 +60,9 @@ export const riverFocusManager = (function () {
|
|
|
61
60
|
/**
|
|
62
61
|
* Focus on selected items
|
|
63
62
|
*
|
|
64
|
-
* @param {
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* previousAction: QuickBrickNavigationActionType,
|
|
68
|
-
* isDeepLink: boolean }} object contains data for focus
|
|
69
|
-
* - `screenFocusedOnItem` focusable item to focus
|
|
70
|
-
* - `previousActionhistory` navigator history object
|
|
63
|
+
* @param {String} screenFocusableGroupId Top group id that was saved as screenn
|
|
64
|
+
* @param {String} screenFocusedOnItem focusable item to focus
|
|
65
|
+
* @param {object} history navigator history object
|
|
71
66
|
*
|
|
72
67
|
*/
|
|
73
68
|
function focusOnSelectedItem({
|
|
@@ -120,15 +115,15 @@ export const riverFocusManager = (function () {
|
|
|
120
115
|
|
|
121
116
|
/**
|
|
122
117
|
* Create unique key that will be used for save focused group data inside specific screen
|
|
123
|
-
*
|
|
124
|
-
* screenId Unique Id of the screen from layout.json
|
|
125
|
-
* isInsideContainer If this screen a screen picker child
|
|
118
|
+
*
|
|
119
|
+
* @param {String} screenId Unique Id of the screen from layout.json
|
|
120
|
+
* @param {boolean} isInsideContainer If this screen a screen picker child
|
|
126
121
|
*
|
|
127
122
|
*/
|
|
128
123
|
function screenFocusableGroupId({ screenId, isInsideContainer }) {
|
|
129
|
-
return
|
|
130
|
-
|
|
131
|
-
|
|
124
|
+
return R.isNil(isInsideContainer)
|
|
125
|
+
? `RiverFocusableGroup-${screenId}`
|
|
126
|
+
: `RiverFocusableGroup-${screenId}-isInsideContainer`;
|
|
132
127
|
}
|
|
133
128
|
|
|
134
129
|
return {
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
import { useEffect, useMemo } from "react";
|
|
2
|
-
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
3
2
|
import { AccessibilityManager } from "./index";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
/**
|
|
5
|
+
* This hook is used to instantiate the accessibility manager and update localizations used by the class.
|
|
6
|
+
* If the plugin config is not provided or it does not contain any localizations, the accessibility manager will not be updated.
|
|
7
|
+
* We use the plugin configuration because it offers a flattened structure where we can easily access the accessibility labels and hints
|
|
8
|
+
* i.e. pluginConfiguration = {
|
|
9
|
+
* accessibility_close_label: "Close",
|
|
10
|
+
* accessibility_close_hint: "Press here to close",
|
|
11
|
+
* }
|
|
12
|
+
*/
|
|
13
|
+
export const useAccessibilityManager = (
|
|
14
|
+
pluginConfiguration: Record<string, any> = {}
|
|
15
|
+
) => {
|
|
9
16
|
const accessibilityManager = useMemo(() => {
|
|
10
17
|
return AccessibilityManager.getInstance();
|
|
11
18
|
}, []);
|
|
12
19
|
|
|
13
20
|
useEffect(() => {
|
|
14
|
-
|
|
15
|
-
|
|
21
|
+
if (pluginConfiguration) {
|
|
22
|
+
accessibilityManager.updateLocalizations(pluginConfiguration);
|
|
23
|
+
}
|
|
24
|
+
}, [pluginConfiguration, accessibilityManager]);
|
|
16
25
|
|
|
17
26
|
useEffect(() => {
|
|
18
27
|
const subscription = accessibilityManager.getStateAsObservable().subscribe({
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
import { BehaviorSubject } from "rxjs";
|
|
2
2
|
import { accessibilityManagerLogger as logger } from "./logger";
|
|
3
3
|
import { TTSManager } from "../platform/platformUtils";
|
|
4
|
-
import { getLocalizations } from "../../localizationUtils";
|
|
5
4
|
import { BUTTON_ACCESSIBILITY_KEYS } from "./const";
|
|
6
|
-
|
|
7
|
-
export interface AccessibilityState {
|
|
8
|
-
screenReaderEnabled: boolean;
|
|
9
|
-
reduceMotionEnabled: boolean;
|
|
10
|
-
boldTextEnabled: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface AccessibilityProps {
|
|
14
|
-
accessibilityLabel?: string;
|
|
15
|
-
accessibilityHint?: string;
|
|
16
|
-
"aria-label"?: string;
|
|
17
|
-
"aria-description"?: string;
|
|
18
|
-
}
|
|
5
|
+
import { AccessibilityRole } from "react-native";
|
|
19
6
|
|
|
20
7
|
export class AccessibilityManager {
|
|
21
8
|
private static _instance: AccessibilityManager | null = null;
|
|
@@ -32,13 +19,9 @@ export class AccessibilityManager {
|
|
|
32
19
|
} | null>(null);
|
|
33
20
|
|
|
34
21
|
private ttsManager = TTSManager.getInstance();
|
|
35
|
-
private localizations: { [key: string]: string };
|
|
22
|
+
private localizations: { [key: string]: string } = {};
|
|
36
23
|
|
|
37
|
-
private constructor(
|
|
38
|
-
if (localizations) {
|
|
39
|
-
this.localizations = getLocalizations({ localizations });
|
|
40
|
-
}
|
|
41
|
-
}
|
|
24
|
+
private constructor() {}
|
|
42
25
|
|
|
43
26
|
public static getInstance(): AccessibilityManager {
|
|
44
27
|
if (!AccessibilityManager._instance) {
|
|
@@ -48,8 +31,17 @@ export class AccessibilityManager {
|
|
|
48
31
|
return AccessibilityManager._instance;
|
|
49
32
|
}
|
|
50
33
|
|
|
34
|
+
/**
|
|
35
|
+
* The method now accepts any object with localizations using a flattened structure
|
|
36
|
+
*
|
|
37
|
+
* i.e. { accessibility_close_label: "Close", accessibility_close_hint: "Press here to close" }
|
|
38
|
+
*
|
|
39
|
+
* No longer accepts:
|
|
40
|
+
*
|
|
41
|
+
* i.e. localizations: [{ en: { accessibility_close_label: "Close", accessibility_close_hint: "Press here to close" } }]
|
|
42
|
+
*/
|
|
51
43
|
public updateLocalizations(localizations: { [key: string]: string }) {
|
|
52
|
-
this.localizations =
|
|
44
|
+
this.localizations = localizations;
|
|
53
45
|
}
|
|
54
46
|
|
|
55
47
|
public getState(): AccessibilityState {
|
|
@@ -71,7 +63,7 @@ export class AccessibilityManager {
|
|
|
71
63
|
text: string;
|
|
72
64
|
keyOfLocalizedText?: string;
|
|
73
65
|
}) {
|
|
74
|
-
|
|
66
|
+
let textToRead = text;
|
|
75
67
|
|
|
76
68
|
if (keyOfLocalizedText) {
|
|
77
69
|
if (!this.localizations) {
|
|
@@ -90,16 +82,25 @@ export class AccessibilityManager {
|
|
|
90
82
|
return;
|
|
91
83
|
}
|
|
92
84
|
|
|
93
|
-
|
|
85
|
+
textToRead = localizedMessage;
|
|
94
86
|
}
|
|
95
87
|
|
|
96
88
|
if (this.ttsManager) {
|
|
97
|
-
|
|
89
|
+
logger.debug({
|
|
90
|
+
message: `Reading text: ${textToRead}`,
|
|
91
|
+
data: {
|
|
92
|
+
textToRead,
|
|
93
|
+
text,
|
|
94
|
+
keyOfLocalizedText,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
this.ttsManager.readText(textToRead);
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
this.announcements$.next({
|
|
101
|
-
message:
|
|
102
|
-
localizedMessage: keyOfLocalizedText ?
|
|
102
|
+
message: textToRead,
|
|
103
|
+
localizedMessage: keyOfLocalizedText ? textToRead : undefined,
|
|
103
104
|
timestamp: Date.now(),
|
|
104
105
|
});
|
|
105
106
|
}
|
|
@@ -113,6 +114,8 @@ export class AccessibilityManager {
|
|
|
113
114
|
accessibilityHint: `Press button to perform action on ${buttonName}`,
|
|
114
115
|
"aria-label": buttonName,
|
|
115
116
|
"aria-description": `Press button to perform action on ${buttonName}`,
|
|
117
|
+
accessibilityRole: "button" as AccessibilityRole,
|
|
118
|
+
"aria-role": "button",
|
|
116
119
|
};
|
|
117
120
|
}
|
|
118
121
|
|
|
@@ -130,6 +133,19 @@ export class AccessibilityManager {
|
|
|
130
133
|
accessibilityHint: hint,
|
|
131
134
|
"aria-label": label,
|
|
132
135
|
"aria-description": hint,
|
|
136
|
+
accessibilityRole: "button" as AccessibilityRole,
|
|
137
|
+
"aria-role": "button",
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public getInputAccessibilityProps(inputName: string): AccessibilityProps {
|
|
142
|
+
return {
|
|
143
|
+
accessibilityLabel: inputName,
|
|
144
|
+
accessibilityHint: `Enter text into ${inputName}`,
|
|
145
|
+
"aria-label": inputName,
|
|
146
|
+
"aria-description": `Enter text into ${inputName}`,
|
|
147
|
+
accessibilityRole: "textbox" as AccessibilityRole,
|
|
148
|
+
"aria-role": "textbox",
|
|
133
149
|
};
|
|
134
150
|
}
|
|
135
151
|
|
|
@@ -59,7 +59,7 @@ export class Tree {
|
|
|
59
59
|
/**
|
|
60
60
|
* Update node with provided data from newNode
|
|
61
61
|
* @private
|
|
62
|
-
* @param {Object}
|
|
62
|
+
* @param {Object} node to update
|
|
63
63
|
* @param {Object} newNode node to take data from
|
|
64
64
|
*/
|
|
65
65
|
updateNode(currentNode, newNode) {
|
|
@@ -175,6 +175,7 @@ export class Tree {
|
|
|
175
175
|
* @private
|
|
176
176
|
* @param {Object} node to check
|
|
177
177
|
* @returns True if node has defined groupID
|
|
178
|
+
* @returns False if node has NOT defined groupID
|
|
178
179
|
*/
|
|
179
180
|
hasGroupID(node) {
|
|
180
181
|
return node.component && node.component.props.groupId;
|
|
@@ -190,7 +191,7 @@ export class Tree {
|
|
|
190
191
|
const findChildNode = this.findInTree(node.component.props.groupId);
|
|
191
192
|
|
|
192
193
|
if (findChildNode) {
|
|
193
|
-
this.root.children.pop();
|
|
194
|
+
this.root.children.pop(findChildNode);
|
|
194
195
|
node.children.push(findChildNode);
|
|
195
196
|
}
|
|
196
197
|
}
|
|
@@ -191,6 +191,7 @@ const toDistance = ({ target, direction, comparisonRect }) => {
|
|
|
191
191
|
* Get target in shortest distance in specified direction
|
|
192
192
|
* @private
|
|
193
193
|
* @param {Object} direction of the navigation, which led to this focus change
|
|
194
|
+
* @param {Object} excludedNode node which should be excluded from target group
|
|
194
195
|
* @param {Array} targetNodes array of input target nodes
|
|
195
196
|
* @param {Object} comparisonRect rectangle to compare sides in direction.
|
|
196
197
|
* @returns {Object} target in direction.
|
|
@@ -299,7 +300,8 @@ export function findFocusableNode(direction, currentFocusNode) {
|
|
|
299
300
|
* @public
|
|
300
301
|
* @param {Object} direction of the navigation, which led to this focus change
|
|
301
302
|
* @param {Object} component - object to check props.prioritiseFocusOn
|
|
302
|
-
* @returns {Boolean} TRUE if object has priority in direction.
|
|
303
|
+
* @returns {Boolean} TRUE if object has priority in direction.
|
|
304
|
+
* @returns {Boolean} FALSE if object has NO priority in direction.
|
|
303
305
|
*/
|
|
304
306
|
export function hasPriorityInDirection(direction, component) {
|
|
305
307
|
const { prioritiseFocusOn = 0 } = component.props;
|
|
@@ -9,7 +9,7 @@ export { KEYS, ARROW_KEYS } from "./keyCodes/keys";
|
|
|
9
9
|
|
|
10
10
|
export { playerManager } from "./playerManager";
|
|
11
11
|
|
|
12
|
-
export {
|
|
12
|
+
export { accessibilityManager } from "./accessibilityManager";
|
|
13
13
|
|
|
14
14
|
export function deprecationMessage(fn, replacement) {
|
|
15
15
|
if (__DEV__ && process.env.NODE_ENV !== "test") {
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
export const KEYS = {
|
|
2
|
+
Enter: { code: "Enter", keyCode: 13 },
|
|
3
|
+
EnterKeyboard: { code: "EnterKeyboard", keyCode: 66 },
|
|
4
|
+
Back: { code: "Back", keyCode: 8 },
|
|
5
|
+
Space: { code: "Space", keyCode: 32 },
|
|
6
|
+
m: { code: "m", keyCode: 77 },
|
|
7
|
+
ArrowLeft: { code: "ArrowLeft", keyCode: 37 },
|
|
8
|
+
ArrowUp: { code: "ArrowUp", keyCode: 38 },
|
|
9
|
+
ArrowRight: { code: "ArrowRight", keyCode: 39 },
|
|
10
|
+
ArrowDown: { code: "ArrowDown", keyCode: 40 },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const ARROW_KEYS = [
|
|
14
|
+
KEYS.ArrowUp,
|
|
15
|
+
KEYS.ArrowLeft,
|
|
16
|
+
KEYS.ArrowDown,
|
|
17
|
+
KEYS.ArrowRight,
|
|
18
|
+
];
|
|
19
|
+
|
|
1
20
|
export function keyEventMapper(keyCode) {
|
|
2
21
|
switch (keyCode) {
|
|
3
22
|
case 19: // ArrowUp
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* global tizen */
|
|
2
|
+
const isTizen = typeof tizen !== "undefined";
|
|
3
|
+
|
|
4
|
+
export const KEYS = {
|
|
5
|
+
Enter: { code: "Enter", keyCode: 13 },
|
|
6
|
+
Space: { code: "Space", keyCode: 32 },
|
|
7
|
+
m: { code: "m", keyCode: 77 },
|
|
8
|
+
ArrowLeft: { code: "ArrowLeft", keyCode: 37 },
|
|
9
|
+
ArrowUp: { code: "ArrowUp", keyCode: 38 },
|
|
10
|
+
ArrowRight: { code: "ArrowRight", keyCode: 39 },
|
|
11
|
+
ArrowDown: { code: "ArrowDown", keyCode: 40 },
|
|
12
|
+
Back: isTizen
|
|
13
|
+
? { code: "Back", keyCode: 10009 }
|
|
14
|
+
: { code: "Backspace", keyCode: 8 },
|
|
15
|
+
Play: isTizen
|
|
16
|
+
? { code: "MediaPlay", keyCode: 10252 }
|
|
17
|
+
: { code: "PlayPause", keyCode: 179 },
|
|
18
|
+
Pause: isTizen
|
|
19
|
+
? { code: "MediaPause", keyCode: 19 }
|
|
20
|
+
: { code: "Pause", keyCode: 179 },
|
|
21
|
+
Forward: isTizen
|
|
22
|
+
? { code: "MediaFastForward", keyCode: 417 }
|
|
23
|
+
: { code: "Forward", keyCode: 176 },
|
|
24
|
+
Rewind: isTizen
|
|
25
|
+
? { code: "MediaRewind", keyCode: 412 }
|
|
26
|
+
: { code: "Rewind", keyCode: 177 },
|
|
27
|
+
VolumeUp: isTizen
|
|
28
|
+
? { code: "VolumeUp", keyCode: 447 }
|
|
29
|
+
: { code: "VolumeUp", keyCode: 175 },
|
|
30
|
+
VolumeDown: isTizen
|
|
31
|
+
? { code: "VolumeDown", keyCode: 448 }
|
|
32
|
+
: { code: "VolumeDown", keyCode: 174 },
|
|
33
|
+
ToggleMute: isTizen
|
|
34
|
+
? { code: "VolumeMute", keyCode: 449 }
|
|
35
|
+
: { code: "VolumeMute", keyCode: 173 },
|
|
36
|
+
Stop: isTizen
|
|
37
|
+
? { code: "MediaStop", keyCode: 413 }
|
|
38
|
+
: { code: "Q", keyCode: 81 },
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const ARROW_KEYS = [
|
|
42
|
+
KEYS.ArrowUp,
|
|
43
|
+
KEYS.ArrowLeft,
|
|
44
|
+
KEYS.ArrowDown,
|
|
45
|
+
KEYS.ArrowRight,
|
|
46
|
+
];
|
|
@@ -5,6 +5,20 @@ import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorag
|
|
|
5
5
|
import { PLATFORM_KEYS, PLATFORMS } from "./const";
|
|
6
6
|
import { createLogger, utilsLogger } from "../../logger";
|
|
7
7
|
|
|
8
|
+
declare global {
|
|
9
|
+
interface Window {
|
|
10
|
+
VIZIO?: {
|
|
11
|
+
exitApplication: () => void;
|
|
12
|
+
Chromevox: {
|
|
13
|
+
play: (text: string) => void;
|
|
14
|
+
};
|
|
15
|
+
setClosedCaptionHandler: (
|
|
16
|
+
callback: (isCCEnabled: boolean) => void
|
|
17
|
+
) => void;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
8
22
|
const { log_debug } = createLogger({
|
|
9
23
|
category: "General",
|
|
10
24
|
subsystem: "PlatformUtils",
|
|
@@ -3,7 +3,6 @@ import * as R from "ramda";
|
|
|
3
3
|
import { subscriber } from "../../functionUtils";
|
|
4
4
|
import { utilsLogger, createLogger } from "../../logger";
|
|
5
5
|
import { Player } from "./player";
|
|
6
|
-
import { AnalyticsTracker } from "../../analyticsUtils/analyticsTracker";
|
|
7
6
|
import {
|
|
8
7
|
hasTizenAPIs,
|
|
9
8
|
subscribeToDeviceNetworkChanges,
|
|
@@ -37,7 +36,10 @@ export interface PlayerLifecycleListener {
|
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
type PlayersMap = {
|
|
40
|
-
[id: string]: {
|
|
39
|
+
[id: string]: {
|
|
40
|
+
player: Player;
|
|
41
|
+
isInViewport: boolean;
|
|
42
|
+
};
|
|
41
43
|
};
|
|
42
44
|
|
|
43
45
|
export class PlayerManager {
|
|
@@ -46,7 +48,6 @@ export class PlayerManager {
|
|
|
46
48
|
private playersMap: PlayersMap = {};
|
|
47
49
|
private manager = subscriber();
|
|
48
50
|
private castingReceiver: Player;
|
|
49
|
-
private analyticsTracker: AnalyticsTracker;
|
|
50
51
|
private lifecycleListeners: PlayerLifecycleListener[] = [];
|
|
51
52
|
|
|
52
53
|
public static getInstance() {
|
|
@@ -57,7 +58,7 @@ export class PlayerManager {
|
|
|
57
58
|
return PlayerManager.instance;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
public getActivePlayerId = ():
|
|
61
|
+
public getActivePlayerId = (): string | null => {
|
|
61
62
|
return this.activePlayerId;
|
|
62
63
|
};
|
|
63
64
|
|
|
@@ -102,7 +103,10 @@ export class PlayerManager {
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
private addPlayer = (id: string, player: Player) => {
|
|
105
|
-
this.playersMap[id] = {
|
|
106
|
+
this.playersMap[id] = {
|
|
107
|
+
player: player,
|
|
108
|
+
isInViewport: false,
|
|
109
|
+
};
|
|
106
110
|
};
|
|
107
111
|
|
|
108
112
|
public isPlayerRegistered = (id: string) => !!this.playersMap[id];
|
|
@@ -251,28 +255,6 @@ export class PlayerManager {
|
|
|
251
255
|
this.castingReceiver = null;
|
|
252
256
|
}
|
|
253
257
|
|
|
254
|
-
/**
|
|
255
|
-
* Handles analytic events, generates a new analytics tracker and transmits events
|
|
256
|
-
* Passes entry data, and playerState to the tracker for additional context
|
|
257
|
-
* The end result is an event formatted and passed to AnalyticsBridge.postEvent
|
|
258
|
-
* When we get the synthetic event we need to pull the data in the e object
|
|
259
|
-
* e contains the return value from native
|
|
260
|
-
*/
|
|
261
|
-
public handleAnalyticEvent(event, data = {}, entry: ZappEntry) {
|
|
262
|
-
const playerState = this.getActivePlayer()?.getState();
|
|
263
|
-
|
|
264
|
-
if (!this.analyticsTracker?.handleAnalyticEvent) {
|
|
265
|
-
this.analyticsTracker = new AnalyticsTracker(entry);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
this.analyticsTracker?.handleAnalyticEvent?.(
|
|
269
|
-
event,
|
|
270
|
-
data,
|
|
271
|
-
entry,
|
|
272
|
-
playerState
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
258
|
/**
|
|
277
259
|
* Method retrieves the instantiated player instance controller
|
|
278
260
|
* Instance controller exposes methods like getContentDuration, getContentPosision
|
|
@@ -61,7 +61,7 @@ export class PlayerNative extends Player {
|
|
|
61
61
|
currentPlayerComponent = (): ReactComponent<PlayerProps> =>
|
|
62
62
|
this.playerComponent?.current;
|
|
63
63
|
|
|
64
|
-
getState = () => this.
|
|
64
|
+
getState = () => this.playerState;
|
|
65
65
|
|
|
66
66
|
// TODO: Try to add module interface
|
|
67
67
|
invokeNativeFunction = (funcName: string, ...params: any[]): boolean => {
|
package/cellUtils/index.ts
CHANGED
|
@@ -31,13 +31,12 @@ export const getKeyForLabel = (dataKey, customKey) => {
|
|
|
31
31
|
* This method will return true if the argument passed to it is either empty or nil
|
|
32
32
|
* The method prevents zero from being evaluated as falsey in an || condition
|
|
33
33
|
* i.e. - NaN, null, {}, "", [], should all return true
|
|
34
|
-
* @param {*} argument - argument passed to it could be any type
|
|
35
34
|
* @returns {Boolean} returns true if empty or nil
|
|
35
|
+
* @param value
|
|
36
36
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
);
|
|
37
|
+
|
|
38
|
+
export const isEmptyOrNil = (value: any): boolean =>
|
|
39
|
+
Number.isNaN(value) || value == null || R.isEmpty(value);
|
|
41
40
|
|
|
42
41
|
/**
|
|
43
42
|
* This method is used to find the appropriate label for any given text field.
|
|
@@ -320,6 +319,7 @@ export const ifElseFocusedSelected = (
|
|
|
320
319
|
* @param {Object} stylesObj styles object with keys from zapp { button_icon_width: "10" }
|
|
321
320
|
* @returns {*} value, returns any type that can be used as styles
|
|
322
321
|
*/
|
|
322
|
+
|
|
323
323
|
export const getValue = (stylesObj) => (key) => {
|
|
324
324
|
return R.propOr(null, key, stylesObj);
|
|
325
325
|
};
|
|
@@ -468,3 +468,36 @@ export const getColorFromData = ({
|
|
|
468
468
|
|
|
469
469
|
return valueFromLayout;
|
|
470
470
|
};
|
|
471
|
+
|
|
472
|
+
export const getImageStyles = ({
|
|
473
|
+
image,
|
|
474
|
+
value,
|
|
475
|
+
}: {
|
|
476
|
+
image: any;
|
|
477
|
+
value: any;
|
|
478
|
+
}) => {
|
|
479
|
+
return {
|
|
480
|
+
width: image.imageContentWidth,
|
|
481
|
+
height: image.imageContentHeight,
|
|
482
|
+
aspectRatio: image.aspectRatio,
|
|
483
|
+
borderRadius: toNumberWithDefaultZero(value("image_corner_radius")),
|
|
484
|
+
};
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
export const getImageContainerPaddingStyles = ({ value }: { value: any }) => {
|
|
488
|
+
return {
|
|
489
|
+
paddingTop: value("image_padding_top"),
|
|
490
|
+
paddingBottom: value("image_padding_bottom"),
|
|
491
|
+
paddingLeft: value("image_padding_left"),
|
|
492
|
+
paddingRight: value("image_padding_right"),
|
|
493
|
+
};
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
export const getImageContainerMarginStyles = ({ value }: { value: any }) => {
|
|
497
|
+
return {
|
|
498
|
+
marginTop: value("image_margin_top"),
|
|
499
|
+
marginBottom: value("image_margin_bottom"),
|
|
500
|
+
marginLeft: value("image_margin_left"),
|
|
501
|
+
marginRight: value("image_margin_right"),
|
|
502
|
+
};
|
|
503
|
+
};
|
|
@@ -2,6 +2,7 @@ import { domUtilsLogger } from "./logger";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Gets an object of cookies and sets them on the DOM.
|
|
5
|
+
* @param {Object} cookies selected data key for label.
|
|
5
6
|
*/
|
|
6
7
|
export function setCookies(cookies): void {
|
|
7
8
|
const cookieKeys = Object.keys(cookies);
|
|
@@ -24,7 +25,7 @@ export function setCookies(cookies): void {
|
|
|
24
25
|
/**
|
|
25
26
|
* Gets cookies set on DOM
|
|
26
27
|
*/
|
|
27
|
-
export function getCookies():
|
|
28
|
+
export function getCookies(): Object {
|
|
28
29
|
try {
|
|
29
30
|
if (document) {
|
|
30
31
|
return document.cookie;
|
package/functionUtils/index.ts
CHANGED
|
@@ -73,12 +73,12 @@ type SubscriberFn<T> = (
|
|
|
73
73
|
|
|
74
74
|
export type EventHandlerFn<T> = (event: string, ...args: unknown[]) => T;
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
on
|
|
78
|
-
invokeHandler: EventHandlerFn<SubscriberObj
|
|
79
|
-
removeHandler: EventHandlerFn<SubscriberObj
|
|
80
|
-
handlers: Record<string, SubscriberFn<SubscriberObj
|
|
81
|
-
}
|
|
76
|
+
type SubscriberObj = Partial<{
|
|
77
|
+
on?: SubscriberFn<SubscriberObj>;
|
|
78
|
+
invokeHandler: EventHandlerFn<SubscriberObj>;
|
|
79
|
+
removeHandler: EventHandlerFn<SubscriberObj>;
|
|
80
|
+
handlers: Record<string, SubscriberFn<SubscriberObj>[] | []>;
|
|
81
|
+
}>;
|
|
82
82
|
|
|
83
83
|
export const clearObject = (object: { [key: string]: unknown }) =>
|
|
84
84
|
Object.keys(object).forEach((key) => delete object[key]);
|
|
@@ -88,11 +88,7 @@ export const clearObject = (object: { [key: string]: unknown }) =>
|
|
|
88
88
|
* @param {Object} obj to add the subscription feature on
|
|
89
89
|
* @returns {Object} subscriber object
|
|
90
90
|
*/
|
|
91
|
-
export function subscriber
|
|
92
|
-
_obj: T = {} as T
|
|
93
|
-
): SubscriberObj {
|
|
94
|
-
const obj: T = _obj;
|
|
95
|
-
|
|
91
|
+
export function subscriber(obj: SubscriberObj = {}): SubscriberObj {
|
|
96
92
|
if (!obj.handlers) {
|
|
97
93
|
obj.handlers = {};
|
|
98
94
|
}
|
|
@@ -138,7 +134,7 @@ export function subscriber<T extends Partial<SubscriberObj> = {}>(
|
|
|
138
134
|
| SubscriberFn<SubscriberObj>[]
|
|
139
135
|
| [];
|
|
140
136
|
|
|
141
|
-
return obj
|
|
137
|
+
return obj;
|
|
142
138
|
};
|
|
143
139
|
|
|
144
140
|
/**
|
|
@@ -154,16 +150,16 @@ export function subscriber<T extends Partial<SubscriberObj> = {}>(
|
|
|
154
150
|
|
|
155
151
|
R.compose(R.forEach(callHandlerWithDispose), R.propOr([], event))(handlers);
|
|
156
152
|
|
|
157
|
-
return obj
|
|
153
|
+
return obj;
|
|
158
154
|
};
|
|
159
155
|
|
|
160
156
|
obj.removeHandler = function (event, handler) {
|
|
161
157
|
handlers[event] = R.reject(R.equals(handler), handlers[event]);
|
|
162
158
|
|
|
163
|
-
return obj
|
|
159
|
+
return obj;
|
|
164
160
|
};
|
|
165
161
|
|
|
166
|
-
return obj
|
|
162
|
+
return obj;
|
|
167
163
|
}
|
|
168
164
|
|
|
169
165
|
/**
|
package/index.d.ts
CHANGED
|
@@ -143,3 +143,18 @@ declare type BuilderData = {
|
|
|
143
143
|
river?: ZappRiver;
|
|
144
144
|
method?: string;
|
|
145
145
|
};
|
|
146
|
+
|
|
147
|
+
declare type AccessibilityState = {
|
|
148
|
+
screenReaderEnabled: boolean;
|
|
149
|
+
reduceMotionEnabled: boolean;
|
|
150
|
+
boldTextEnabled: boolean;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
declare type AccessibilityProps = {
|
|
154
|
+
accessibilityLabel?: string;
|
|
155
|
+
accessibilityHint?: string;
|
|
156
|
+
"aria-label"?: string;
|
|
157
|
+
"aria-description"?: string;
|
|
158
|
+
accessibilityRole?: string;
|
|
159
|
+
"aria-role"?: string;
|
|
160
|
+
};
|
package/modalState/index.ts
CHANGED
|
@@ -31,7 +31,11 @@ export const useModalStore = create<ModalStore>((set) => ({
|
|
|
31
31
|
set((state) => ({
|
|
32
32
|
modalState: { ...state.modalState, ...newState },
|
|
33
33
|
})),
|
|
34
|
-
openModal: ({
|
|
34
|
+
openModal: ({
|
|
35
|
+
item,
|
|
36
|
+
options = {},
|
|
37
|
+
props = { screenData: {} },
|
|
38
|
+
}: OpenModalArg) =>
|
|
35
39
|
set({
|
|
36
40
|
modalState: {
|
|
37
41
|
visible: true,
|