@applicaster/zapp-react-native-utils 12.0.3-alpha.5953460913 → 13.0.0-alpha.1436249127
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/actionsExecutor/ActionExecutorContext.tsx +15 -1
- package/appUtils/HooksManager/{Hook.js → Hook.ts} +35 -23
- package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +4 -2
- package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +693 -0
- package/appUtils/HooksManager/__tests__/hook.test.js +196 -184
- package/appUtils/HooksManager/__tests__/hooksManager.test.js +96 -99
- package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
- package/appUtils/HooksManager/{index.js → index.ts} +121 -112
- package/appUtils/HooksManager/types.ts +116 -0
- package/appUtils/RiverFocusManager/index.js +17 -12
- package/appUtils/focusManager/treeDataStructure/Tree/index.js +2 -3
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
- package/appUtils/{index.js → index.ts} +1 -1
- package/appUtils/keyCodes/__tests__/keyCodes.test.js +3 -3
- package/appUtils/keyCodes/{index.js → index.ts} +2 -0
- package/appUtils/keyCodes/keys/index.ts +3 -0
- package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
- package/appUtils/keyCodes/keys/keys.android.ts +18 -0
- package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
- package/appUtils/keyCodes/keys/keys.ts +15 -0
- package/appUtils/keyCodes/keysByPlatform.ts +8 -0
- package/appUtils/platform/platformUtils.ts +0 -14
- package/appUtils/playerManager/index.ts +6 -2
- package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
- package/functionUtils/index.ts +15 -11
- package/modalState/index.ts +1 -5
- package/navigationUtils/index.ts +14 -5
- package/package.json +2 -2
- package/reactHooks/navigation/index.ts +7 -4
- package/reactUtils/index.ts +0 -14
- package/appUtils/keyCodes/keys.ios.js +0 -46
- /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
- /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
- /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
- /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
- /package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +0 -0
- /package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +0 -0
- /package/domUtils/{logger.js → logger.ts} +0 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { SubscriberObj } from "../../functionUtils";
|
|
2
|
+
import { HOOKS_EVENTS } from "./constants";
|
|
3
|
+
|
|
4
|
+
export interface HookConfiguration {}
|
|
5
|
+
|
|
6
|
+
/* existing Hook Plugn props: sample */
|
|
7
|
+
interface _HookModulePlugin {
|
|
8
|
+
Component:
|
|
9
|
+
| React.FC<HookPluginProps>
|
|
10
|
+
| React.Component<HookPluginProps, any>
|
|
11
|
+
| React.ReactNode;
|
|
12
|
+
ModalContainer?: React.FC<ModalProps> | React.Component<ModalProps, any>;
|
|
13
|
+
skipHook?: (payload: ZappRiver | ZappEntry) => boolean;
|
|
14
|
+
presentFullScreen: boolean;
|
|
15
|
+
showNavBar?: boolean;
|
|
16
|
+
isFlowBlocker: (() => boolean) | boolean; // narrow this
|
|
17
|
+
hasPlayerHook?: boolean;
|
|
18
|
+
name: string;
|
|
19
|
+
runInBackground?: (
|
|
20
|
+
item: HookPluginProps["payload"],
|
|
21
|
+
callback: hookCallback,
|
|
22
|
+
hookPlugin: HookScreenData,
|
|
23
|
+
presentUI: (payload?: HookPluginProps["payload"]) => void
|
|
24
|
+
) => any;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//* Derived from usage */
|
|
28
|
+
export interface HookModule {
|
|
29
|
+
ModalContainer?: React.ComponentType<any>;
|
|
30
|
+
Component: React.ComponentType<any>;
|
|
31
|
+
presentFullScreen: boolean;
|
|
32
|
+
run?: (
|
|
33
|
+
arg0: unknown,
|
|
34
|
+
callback: () => void,
|
|
35
|
+
configuration: HookConfiguration
|
|
36
|
+
) => void; // not sure about optional parameter
|
|
37
|
+
hasPlayerHook?: boolean;
|
|
38
|
+
configuration?: HookConfiguration;
|
|
39
|
+
isFlowBlocker: () => boolean;
|
|
40
|
+
skipHook?: (payload?: ZappRiver | ZappEntry) => boolean;
|
|
41
|
+
runInBackground?: (
|
|
42
|
+
arg0: unknown,
|
|
43
|
+
callback: () => void,
|
|
44
|
+
hookPlugin: Hook,
|
|
45
|
+
presentUI: (payload?: HookPluginProps["payload"]) => void
|
|
46
|
+
) => void;
|
|
47
|
+
name: string;
|
|
48
|
+
showNavBar?: boolean; // unsure
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type HookManagerArgs = {
|
|
52
|
+
rivers: Record<string, ZappRiver>;
|
|
53
|
+
plugins: ZappPlugin[];
|
|
54
|
+
targetScreen: ZappRiver;
|
|
55
|
+
startUpHooksData?: {
|
|
56
|
+
startUpHooks?: unknown[] | "in_process";
|
|
57
|
+
setStartUpHooks?: (arg0: string) => void;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export interface HookManager {
|
|
62
|
+
subscriber: SubscriberObj;
|
|
63
|
+
presentScreenHook: (
|
|
64
|
+
hook: Hook,
|
|
65
|
+
payload: unknown,
|
|
66
|
+
callback: (...any) => void
|
|
67
|
+
) => void;
|
|
68
|
+
executeHook: (
|
|
69
|
+
hook: Hook,
|
|
70
|
+
payload: unknown,
|
|
71
|
+
callback: (...any) => void
|
|
72
|
+
) => void;
|
|
73
|
+
handleHooks: (payload: unknown) => void;
|
|
74
|
+
runInBackground: (
|
|
75
|
+
hook: Hook,
|
|
76
|
+
payload: unknown,
|
|
77
|
+
callback: (...any) => void,
|
|
78
|
+
presentUI: (payload?: HookPluginProps["payload"]) => void
|
|
79
|
+
) => void;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export type HookIniObj = {
|
|
83
|
+
hook: HookModule & {
|
|
84
|
+
module: HookModule;
|
|
85
|
+
general: unknown;
|
|
86
|
+
screen_id?: string;
|
|
87
|
+
identifier?: string;
|
|
88
|
+
weight?: number | string;
|
|
89
|
+
};
|
|
90
|
+
hooks: Hook<any>[];
|
|
91
|
+
manager: HookManager;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export interface Hook<T extends HookModule = HookModule> {
|
|
95
|
+
manager: HookManager;
|
|
96
|
+
lastHook: boolean;
|
|
97
|
+
state: number;
|
|
98
|
+
module: T;
|
|
99
|
+
screen_id: string;
|
|
100
|
+
identifier: string;
|
|
101
|
+
configuration: T["configuration"];
|
|
102
|
+
setStateAndNotify(
|
|
103
|
+
event: typeof HOOKS_EVENTS[keyof typeof HOOKS_EVENTS],
|
|
104
|
+
opts: {
|
|
105
|
+
error?: typeof Error;
|
|
106
|
+
route?: string;
|
|
107
|
+
hookPlugin: Hook<T>;
|
|
108
|
+
payload: unknown;
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
general?: {
|
|
112
|
+
transition_type: typeof HOOKS_EVENTS[keyof typeof HOOKS_EVENTS];
|
|
113
|
+
allow_screen_plugin_presentation: boolean;
|
|
114
|
+
is_flow_blocker: boolean;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -26,7 +26,7 @@ export const riverFocusManager = (function () {
|
|
|
26
26
|
/**
|
|
27
27
|
* Retrieve screen focus data by id
|
|
28
28
|
*
|
|
29
|
-
* @param {
|
|
29
|
+
* @param {{screenFocusableGroupId: string}} screenFocusableGroupId Unique Id of the screen from layout.json
|
|
30
30
|
*
|
|
31
31
|
*/
|
|
32
32
|
function screenFocusableData({ screenFocusableGroupId }) {
|
|
@@ -36,8 +36,9 @@ export const riverFocusManager = (function () {
|
|
|
36
36
|
/**
|
|
37
37
|
* Clear screen data for specific screen
|
|
38
38
|
*
|
|
39
|
-
* @param {
|
|
40
|
-
*
|
|
39
|
+
* @param {{ screenId: string, isInsideContainer: boolean }}
|
|
40
|
+
* screenId Unique Id of the screen from layout.json
|
|
41
|
+
* isInsideContainer If this screen a screen picker child
|
|
41
42
|
*
|
|
42
43
|
*/
|
|
43
44
|
function clearScreenData({ screenId, isInsideContainer }) {
|
|
@@ -60,9 +61,13 @@ export const riverFocusManager = (function () {
|
|
|
60
61
|
/**
|
|
61
62
|
* Focus on selected items
|
|
62
63
|
*
|
|
63
|
-
* @param {
|
|
64
|
-
*
|
|
65
|
-
*
|
|
64
|
+
* @param {{
|
|
65
|
+
* screenFocusableGroupId: string,
|
|
66
|
+
* screenFocusedOnItem: () => void,
|
|
67
|
+
* previousAction: QuickBrickNavigationActionType,
|
|
68
|
+
* isDeepLink: boolean }} object contains data for focus
|
|
69
|
+
* - `screenFocusedOnItem` focusable item to focus
|
|
70
|
+
* - `previousActionhistory` navigator history object
|
|
66
71
|
*
|
|
67
72
|
*/
|
|
68
73
|
function focusOnSelectedItem({
|
|
@@ -115,15 +120,15 @@ export const riverFocusManager = (function () {
|
|
|
115
120
|
|
|
116
121
|
/**
|
|
117
122
|
* Create unique key that will be used for save focused group data inside specific screen
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
123
|
+
* @param {{ screenId: string, isInsideContainer: boolean }}
|
|
124
|
+
* screenId Unique Id of the screen from layout.json
|
|
125
|
+
* isInsideContainer If this screen a screen picker child
|
|
121
126
|
*
|
|
122
127
|
*/
|
|
123
128
|
function screenFocusableGroupId({ screenId, isInsideContainer }) {
|
|
124
|
-
return
|
|
125
|
-
?
|
|
126
|
-
|
|
129
|
+
return `RiverFocusableGroup-${screenId}${
|
|
130
|
+
R.isNil(isInsideContainer) ? "" : "-isInsideContainer"
|
|
131
|
+
}`;
|
|
127
132
|
}
|
|
128
133
|
|
|
129
134
|
return {
|
|
@@ -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} currentNode to update
|
|
63
63
|
* @param {Object} newNode node to take data from
|
|
64
64
|
*/
|
|
65
65
|
updateNode(currentNode, newNode) {
|
|
@@ -175,7 +175,6 @@ 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
|
|
179
178
|
*/
|
|
180
179
|
hasGroupID(node) {
|
|
181
180
|
return node.component && node.component.props.groupId;
|
|
@@ -191,7 +190,7 @@ export class Tree {
|
|
|
191
190
|
const findChildNode = this.findInTree(node.component.props.groupId);
|
|
192
191
|
|
|
193
192
|
if (findChildNode) {
|
|
194
|
-
this.root.children.pop(
|
|
193
|
+
this.root.children.pop();
|
|
195
194
|
node.children.push(findChildNode);
|
|
196
195
|
}
|
|
197
196
|
}
|
|
@@ -191,7 +191,6 @@ 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
|
|
195
194
|
* @param {Array} targetNodes array of input target nodes
|
|
196
195
|
* @param {Object} comparisonRect rectangle to compare sides in direction.
|
|
197
196
|
* @returns {Object} target in direction.
|
|
@@ -300,8 +299,7 @@ export function findFocusableNode(direction, currentFocusNode) {
|
|
|
300
299
|
* @public
|
|
301
300
|
* @param {Object} direction of the navigation, which led to this focus change
|
|
302
301
|
* @param {Object} component - object to check props.prioritiseFocusOn
|
|
303
|
-
* @returns {Boolean} TRUE if object has priority in direction.
|
|
304
|
-
* @returns {Boolean} FALSE if object has NO priority in direction.
|
|
302
|
+
* @returns {Boolean} TRUE if object has priority in direction. FALSE if object has NO priority in direction.
|
|
305
303
|
*/
|
|
306
304
|
export function hasPriorityInDirection(direction, component) {
|
|
307
305
|
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") {
|
|
@@ -13,7 +13,7 @@ const globalTizen = {
|
|
|
13
13
|
describe("keyCodes", () => {
|
|
14
14
|
describe("keyCode", () => {
|
|
15
15
|
const { keyCode } = require("..");
|
|
16
|
-
const { KEYS } = require("../keys.web");
|
|
16
|
+
const { KEYS } = require("../keys/keys.web");
|
|
17
17
|
|
|
18
18
|
it("returns an object for a given key event", () => {
|
|
19
19
|
expect(keyCode(KEYS.Enter)).toMatchSnapshot();
|
|
@@ -63,7 +63,7 @@ describe("keyCodes", () => {
|
|
|
63
63
|
it("uses the proper keyCode for the environment", () => {
|
|
64
64
|
Platform.OS = "samsung_tv";
|
|
65
65
|
const { keyCode } = require("../");
|
|
66
|
-
const { KEYS } = require("../keys.web");
|
|
66
|
+
const { KEYS } = require("../keys/keys.web");
|
|
67
67
|
|
|
68
68
|
expect(globalTizen.tvinputdevice.registerKeyBatch).toHaveBeenCalledWith([
|
|
69
69
|
"MediaPlay",
|
|
@@ -97,7 +97,7 @@ describe("keyCodes", () => {
|
|
|
97
97
|
it("uses the proper keyCode for the environment", () => {
|
|
98
98
|
Platform.OS = "lg_tv";
|
|
99
99
|
const { keyCode } = require("..");
|
|
100
|
-
const { KEYS } = require("../keys.web");
|
|
100
|
+
const { KEYS } = require("../keys/keys.web");
|
|
101
101
|
// Back is reserved on LG
|
|
102
102
|
expect(keyCode({ keyCode: 417 }).matches(KEYS.Forward)).toBeTruthy();
|
|
103
103
|
});
|
|
@@ -1,22 +1,3 @@
|
|
|
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
|
-
|
|
20
1
|
export function keyEventMapper(keyCode) {
|
|
21
2
|
switch (keyCode) {
|
|
22
3
|
case 19: // ArrowUp
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const KEYS = {
|
|
2
|
+
Enter: { code: "Enter", keyCode: 13 },
|
|
3
|
+
Space: { code: "Space", keyCode: 32 },
|
|
4
|
+
m: { code: "m", keyCode: 77 },
|
|
5
|
+
ArrowLeft: { code: "ArrowLeft", keyCode: 37 },
|
|
6
|
+
ArrowUp: { code: "ArrowUp", keyCode: 38 },
|
|
7
|
+
ArrowRight: { code: "ArrowRight", keyCode: 39 },
|
|
8
|
+
ArrowDown: { code: "ArrowDown", keyCode: 40 },
|
|
9
|
+
Back: { code: "Backspace", keyCode: 8 },
|
|
10
|
+
Play: { code: "PlayPause", keyCode: 179 },
|
|
11
|
+
Pause: { code: "Pause", keyCode: 179 },
|
|
12
|
+
Forward: { code: "Forward", keyCode: 176 },
|
|
13
|
+
Rewind: { code: "Rewind", keyCode: 177 },
|
|
14
|
+
VolumeUp: { code: "VolumeUp", keyCode: 175 },
|
|
15
|
+
VolumeDown: { code: "VolumeDown", keyCode: 174 },
|
|
16
|
+
ToggleMute: { code: "VolumeMute", keyCode: 173 },
|
|
17
|
+
Stop: { code: "Q", keyCode: 81 },
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const ARROW_KEYS = [
|
|
21
|
+
KEYS.ArrowUp,
|
|
22
|
+
KEYS.ArrowLeft,
|
|
23
|
+
KEYS.ArrowDown,
|
|
24
|
+
KEYS.ArrowRight,
|
|
25
|
+
];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// dummy file to make sure the folder structure is created
|
|
2
|
+
export const KEYS: Record<string, { code: string; keyCode: number }> = {
|
|
3
|
+
ArrowLeft: { code: "ArrowLeft", keyCode: -1 },
|
|
4
|
+
ArrowUp: { code: "ArrowUp", keyCode: -1 },
|
|
5
|
+
ArrowRight: { code: "ArrowRight", keyCode: -1 },
|
|
6
|
+
ArrowDown: { code: "ArrowDown", keyCode: -1 },
|
|
7
|
+
Back: { code: "Back", keyCode: -1 },
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const ARROW_KEYS = [
|
|
11
|
+
KEYS.ArrowUp,
|
|
12
|
+
KEYS.ArrowLeft,
|
|
13
|
+
KEYS.ArrowDown,
|
|
14
|
+
KEYS.ArrowRight,
|
|
15
|
+
];
|
|
@@ -9,20 +9,6 @@ import {
|
|
|
9
9
|
import { PLATFORM_KEYS, PLATFORMS } from "./const";
|
|
10
10
|
import { createLogger, utilsLogger } from "../../logger";
|
|
11
11
|
|
|
12
|
-
declare global {
|
|
13
|
-
interface Window {
|
|
14
|
-
VIZIO?: {
|
|
15
|
-
exitApplication: () => void;
|
|
16
|
-
Chromevox: {
|
|
17
|
-
play: (text: string) => void;
|
|
18
|
-
};
|
|
19
|
-
setClosedCaptionHandler: (
|
|
20
|
-
callback: (isCCEnabled: boolean) => void
|
|
21
|
-
) => void;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
12
|
const { log_debug } = createLogger({
|
|
27
13
|
category: "General",
|
|
28
14
|
subsystem: "PlatformUtils",
|
|
@@ -169,8 +169,12 @@ export class PlayerManager {
|
|
|
169
169
|
this.addPlayer(id, playerController);
|
|
170
170
|
|
|
171
171
|
if (playerController.playerRole === PlayerRole.Primary) {
|
|
172
|
-
if (
|
|
173
|
-
RNPlayerManager
|
|
172
|
+
if (RNPlayerManager) {
|
|
173
|
+
Object.keys(RNPlayerManager).forEach((pluginId) => {
|
|
174
|
+
if (pluginId !== playerController.playerPluginId) {
|
|
175
|
+
RNPlayerManager[pluginId]?.stopBackgroundPlayback?.();
|
|
176
|
+
}
|
|
177
|
+
});
|
|
174
178
|
}
|
|
175
179
|
|
|
176
180
|
playerController.addListener({
|
|
@@ -2,7 +2,6 @@ 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.
|
|
6
5
|
*/
|
|
7
6
|
export function setCookies(cookies): void {
|
|
8
7
|
const cookieKeys = Object.keys(cookies);
|
|
@@ -25,7 +24,7 @@ export function setCookies(cookies): void {
|
|
|
25
24
|
/**
|
|
26
25
|
* Gets cookies set on DOM
|
|
27
26
|
*/
|
|
28
|
-
export function getCookies():
|
|
27
|
+
export function getCookies(): typeof document.cookie {
|
|
29
28
|
try {
|
|
30
29
|
if (document) {
|
|
31
30
|
return document.cookie;
|
package/functionUtils/index.ts
CHANGED
|
@@ -111,12 +111,12 @@ type SubscriberFn<T> = (
|
|
|
111
111
|
|
|
112
112
|
export type EventHandlerFn<T> = (event: string, ...args: unknown[]) => T;
|
|
113
113
|
|
|
114
|
-
type SubscriberObj =
|
|
115
|
-
on
|
|
116
|
-
invokeHandler: EventHandlerFn<SubscriberObj
|
|
117
|
-
removeHandler: EventHandlerFn<SubscriberObj
|
|
118
|
-
handlers: Record<string, SubscriberFn<SubscriberObj
|
|
119
|
-
}
|
|
114
|
+
export type SubscriberObj<T extends {} = {}> = {
|
|
115
|
+
on: SubscriberFn<SubscriberObj<T>>;
|
|
116
|
+
invokeHandler: EventHandlerFn<SubscriberObj<T>>;
|
|
117
|
+
removeHandler: EventHandlerFn<SubscriberObj<T>>;
|
|
118
|
+
handlers: Record<string, SubscriberFn<SubscriberObj<T>>[] | []>;
|
|
119
|
+
} & T;
|
|
120
120
|
|
|
121
121
|
export const clearObject = (object: { [key: string]: unknown }) =>
|
|
122
122
|
Object.keys(object).forEach((key) => delete object[key]);
|
|
@@ -126,7 +126,11 @@ export const clearObject = (object: { [key: string]: unknown }) =>
|
|
|
126
126
|
* @param {Object} obj to add the subscription feature on
|
|
127
127
|
* @returns {Object} subscriber object
|
|
128
128
|
*/
|
|
129
|
-
export function subscriber
|
|
129
|
+
export function subscriber<T extends Partial<SubscriberObj> = {}>(
|
|
130
|
+
_obj: T = {} as T
|
|
131
|
+
): SubscriberObj {
|
|
132
|
+
const obj: T = _obj;
|
|
133
|
+
|
|
130
134
|
if (!obj.handlers) {
|
|
131
135
|
obj.handlers = {};
|
|
132
136
|
}
|
|
@@ -172,7 +176,7 @@ export function subscriber(obj: SubscriberObj = {}): SubscriberObj {
|
|
|
172
176
|
| SubscriberFn<SubscriberObj>[]
|
|
173
177
|
| [];
|
|
174
178
|
|
|
175
|
-
return obj;
|
|
179
|
+
return obj as SubscriberObj;
|
|
176
180
|
};
|
|
177
181
|
|
|
178
182
|
/**
|
|
@@ -188,16 +192,16 @@ export function subscriber(obj: SubscriberObj = {}): SubscriberObj {
|
|
|
188
192
|
|
|
189
193
|
R.compose(R.forEach(callHandlerWithDispose), R.propOr([], event))(handlers);
|
|
190
194
|
|
|
191
|
-
return obj;
|
|
195
|
+
return obj as SubscriberObj;
|
|
192
196
|
};
|
|
193
197
|
|
|
194
198
|
obj.removeHandler = function (event, handler) {
|
|
195
199
|
handlers[event] = R.reject(R.equals(handler), handlers[event]);
|
|
196
200
|
|
|
197
|
-
return obj;
|
|
201
|
+
return obj as SubscriberObj;
|
|
198
202
|
};
|
|
199
203
|
|
|
200
|
-
return obj;
|
|
204
|
+
return obj as SubscriberObj;
|
|
201
205
|
}
|
|
202
206
|
|
|
203
207
|
/**
|
package/modalState/index.ts
CHANGED
|
@@ -31,11 +31,7 @@ export const useModalStore = create<ModalStore>((set) => ({
|
|
|
31
31
|
set((state) => ({
|
|
32
32
|
modalState: { ...state.modalState, ...newState },
|
|
33
33
|
})),
|
|
34
|
-
openModal: ({
|
|
35
|
-
item,
|
|
36
|
-
options = {},
|
|
37
|
-
props = { screenData: {} },
|
|
38
|
-
}: OpenModalArg) =>
|
|
34
|
+
openModal: ({ item, options = {}, props }: OpenModalArg) =>
|
|
39
35
|
set({
|
|
40
36
|
modalState: {
|
|
41
37
|
visible: true,
|
package/navigationUtils/index.ts
CHANGED
|
@@ -324,7 +324,13 @@ export function getPathAttributes({
|
|
|
324
324
|
* @param {object} rivers
|
|
325
325
|
* @returns {object}
|
|
326
326
|
*/
|
|
327
|
-
export function getRiverFromRoute({
|
|
327
|
+
export function getRiverFromRoute({
|
|
328
|
+
route,
|
|
329
|
+
rivers,
|
|
330
|
+
}: {
|
|
331
|
+
route: string;
|
|
332
|
+
rivers: Record<string, ZappRiver>;
|
|
333
|
+
}) {
|
|
328
334
|
if (!route) {
|
|
329
335
|
return null;
|
|
330
336
|
}
|
|
@@ -437,7 +443,7 @@ export const runZappHooksForEntry = async (
|
|
|
437
443
|
|
|
438
444
|
let success;
|
|
439
445
|
let payload;
|
|
440
|
-
const rivers = appStore.get("rivers");
|
|
446
|
+
const rivers: Record<string, ZappRiver> = appStore.get("rivers");
|
|
441
447
|
const plugins = appStore.get("plugins");
|
|
442
448
|
const appData = appStore.get("appData");
|
|
443
449
|
|
|
@@ -492,13 +498,16 @@ export const runZappHooksForEntry = async (
|
|
|
492
498
|
payload = _payload;
|
|
493
499
|
};
|
|
494
500
|
|
|
495
|
-
HooksManager(hooksOptions)
|
|
501
|
+
const hooksManager = HooksManager(hooksOptions);
|
|
502
|
+
|
|
503
|
+
hooksManager.subscriber
|
|
496
504
|
.on(HOOKS_EVENTS.PRESENT_SCREEN_HOOK, handleHookPresent)
|
|
497
505
|
.on(HOOKS_EVENTS.START_BACKGROUND_HOOK, handleBackgroundHook)
|
|
498
506
|
.on(HOOKS_EVENTS.ERROR, onFinished(false))
|
|
499
507
|
.on(HOOKS_EVENTS.CANCEL, onFinished(false))
|
|
500
|
-
.on(HOOKS_EVENTS.COMPLETE, onFinished(true))
|
|
501
|
-
|
|
508
|
+
.on(HOOKS_EVENTS.COMPLETE, onFinished(true));
|
|
509
|
+
|
|
510
|
+
hooksManager.handleHooks(entry);
|
|
502
511
|
|
|
503
512
|
// eslint-disable-next-line no-unmodified-loop-condition
|
|
504
513
|
while (success === undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0-alpha.1436249127",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "
|
|
31
|
+
"@applicaster/applicaster-types": "13.0.0-alpha.1436249127",
|
|
32
32
|
"buffer": "^5.2.1",
|
|
33
33
|
"camelize": "^1.0.0",
|
|
34
34
|
"create-react-context": "^0.2.3",
|
|
@@ -320,16 +320,19 @@ export const useZappHooksForEntry = (
|
|
|
320
320
|
callbacks?.handleHookComplete?.(props);
|
|
321
321
|
};
|
|
322
322
|
|
|
323
|
-
const hookManager = HooksManager(hooksOptions)
|
|
323
|
+
const hookManager = HooksManager(hooksOptions);
|
|
324
|
+
|
|
325
|
+
hookManager.subscriber
|
|
324
326
|
.on(HOOKS_EVENTS.PRESENT_SCREEN_HOOK, handleHookPresent)
|
|
325
327
|
.on(HOOKS_EVENTS.ERROR, handleHookError)
|
|
326
328
|
.on(HOOKS_EVENTS.CANCEL, handleHookCancel)
|
|
327
329
|
.on(HOOKS_EVENTS.START_BACKGROUND_HOOK, handleBackgroundHook)
|
|
328
|
-
.on(HOOKS_EVENTS.COMPLETE, handleHookComplete)
|
|
329
|
-
|
|
330
|
+
.on(HOOKS_EVENTS.COMPLETE, handleHookComplete);
|
|
331
|
+
|
|
332
|
+
hookManager.handleHooks(entry);
|
|
330
333
|
|
|
331
334
|
return () => {
|
|
332
|
-
hookManager
|
|
335
|
+
hookManager.subscriber
|
|
333
336
|
.removeHandler(HOOKS_EVENTS.PRESENT_SCREEN_HOOK, handleHookPresent)
|
|
334
337
|
.removeHandler(HOOKS_EVENTS.ERROR, handleHookError)
|
|
335
338
|
.removeHandler(HOOKS_EVENTS.CANCEL, handleHookCancel)
|
package/reactUtils/index.ts
CHANGED
|
@@ -109,20 +109,6 @@ export const isTvOSPlatform = () => getPlatform() === "tvos";
|
|
|
109
109
|
|
|
110
110
|
export const isAndroidTVPlatform = () => getPlatform() === "android_tv";
|
|
111
111
|
|
|
112
|
-
declare global {
|
|
113
|
-
interface Window {
|
|
114
|
-
VIZIO?: {
|
|
115
|
-
Chromevox: {
|
|
116
|
-
play: (text: string) => void;
|
|
117
|
-
};
|
|
118
|
-
exitApplication: () => void;
|
|
119
|
-
setClosedCaptionHandler: (
|
|
120
|
-
callback: (isCCEnabled: boolean) => void
|
|
121
|
-
) => void;
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
112
|
/**
|
|
127
113
|
* Platforms found in userAgent string, please note that simulators
|
|
128
114
|
* might not have the same agents that the devices have
|
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
];
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|