@applicaster/zapp-react-native-utils 14.0.0-alpha.5810348423 → 14.0.0-alpha.6000342231
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 +5 -2
- package/appUtils/RiverFocusManager/{index.ts → index.js} +18 -25
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +1 -3
- package/appUtils/focusManager/index.ios.ts +13 -67
- package/appUtils/focusManagerAux/utils/index.ts +18 -0
- package/appUtils/focusManagerAux/utils/utils.ios.ts +35 -0
- package/appUtils/platform/platformUtils.ts +2 -2
- package/appUtils/playerManager/conts.ts +21 -0
- package/arrayUtils/__tests__/allTruthy.test.ts +24 -0
- package/arrayUtils/__tests__/anyThruthy.test.ts +24 -0
- package/arrayUtils/index.ts +5 -0
- package/navigationUtils/index.ts +19 -16
- package/package.json +2 -2
- package/reactHooks/feed/useFeedLoader.tsx +0 -9
- package/reactHooks/feed/useInflatedUrl.ts +23 -29
- package/reactHooks/layout/index.ts +1 -1
- package/utils/index.ts +1 -0
- package/appUtils/focusManagerAux/utils/index.ios.ts +0 -107
|
@@ -35,8 +35,11 @@ export class AnalyticPlayerListener
|
|
|
35
35
|
this.handleAnalyticEvent(PLAYBACK_EVENT.complete);
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
onError = (err:
|
|
39
|
-
this.handleAnalyticEvent(
|
|
38
|
+
onError = (err: QuickBrickPlayer.PlayerErrorI) => {
|
|
39
|
+
this.handleAnalyticEvent(
|
|
40
|
+
PLAYBACK_EVENT.error,
|
|
41
|
+
err.toObject?.() || { message: err.message }
|
|
42
|
+
);
|
|
40
43
|
};
|
|
41
44
|
|
|
42
45
|
onPlayerPause = (event) => {
|
|
@@ -1,31 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { isNotNil } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
1
|
+
import * as R from "ramda";
|
|
2
|
+
|
|
3
|
+
import { focusManager } from "../focusManager";
|
|
5
4
|
|
|
6
5
|
let riverFocusData = {};
|
|
7
6
|
let initialyPresentedScreenFocused = false;
|
|
8
7
|
|
|
9
8
|
export const riverFocusManager = (function () {
|
|
10
|
-
/**
|
|
11
|
-
* Create unique key that will be used for save focused group data inside specific screen
|
|
12
|
-
* @param {{ screenId: string, isInsideContainer: boolean }}
|
|
13
|
-
* screenId Unique Id of the screen from layout.json
|
|
14
|
-
* isInsideContainer If this screen a screen picker child
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
function screenFocusableGroupId({
|
|
18
|
-
screenId,
|
|
19
|
-
isInsideContainer,
|
|
20
|
-
}: {
|
|
21
|
-
screenId: string;
|
|
22
|
-
isInsideContainer: Option<boolean>;
|
|
23
|
-
}) {
|
|
24
|
-
return `${QUICK_BRICK_CONTENT}-${screenId}${
|
|
25
|
-
isNil(isInsideContainer) ? "" : "-isInsideContainer"
|
|
26
|
-
}`;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
9
|
function setScreenFocusableData({
|
|
30
10
|
screenFocusableGroupId,
|
|
31
11
|
groupId,
|
|
@@ -98,8 +78,8 @@ export const riverFocusManager = (function () {
|
|
|
98
78
|
}) {
|
|
99
79
|
// Check if screen should be focused
|
|
100
80
|
const shouldFocus =
|
|
101
|
-
(initialyPresentedScreenFocused === false && isEmpty(riverFocusData)) ||
|
|
102
|
-
|
|
81
|
+
(initialyPresentedScreenFocused === false && R.isEmpty(riverFocusData)) ||
|
|
82
|
+
R.compose(R.not, R.isNil)(riverFocusData[screenFocusableGroupId]) ||
|
|
103
83
|
isDeepLink;
|
|
104
84
|
|
|
105
85
|
// TODO: Uncommit it to start fixing bug where selection wrong item
|
|
@@ -138,6 +118,19 @@ export const riverFocusManager = (function () {
|
|
|
138
118
|
}
|
|
139
119
|
}
|
|
140
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Create unique key that will be used for save focused group data inside specific screen
|
|
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
|
|
126
|
+
*
|
|
127
|
+
*/
|
|
128
|
+
function screenFocusableGroupId({ screenId, isInsideContainer }) {
|
|
129
|
+
return `RiverFocusableGroup-${screenId}${
|
|
130
|
+
R.isNil(isInsideContainer) ? "" : "-isInsideContainer"
|
|
131
|
+
}`;
|
|
132
|
+
}
|
|
133
|
+
|
|
141
134
|
return {
|
|
142
135
|
setScreenFocusableData,
|
|
143
136
|
clearAllScreensData,
|
|
@@ -69,11 +69,9 @@ exports[`focusManagerIOS should be defined 1`] = `
|
|
|
69
69
|
"getGroupRootById": [Function],
|
|
70
70
|
"getPreferredFocusChild": [Function],
|
|
71
71
|
"invokeHandler": [Function],
|
|
72
|
+
"isChildOf": [Function],
|
|
72
73
|
"isFocusOn": [Function],
|
|
73
|
-
"isFocusOnContent": [Function],
|
|
74
|
-
"isFocusOnMenu": [Function],
|
|
75
74
|
"isGroupItemFocused": [Function],
|
|
76
|
-
"isTabsScreenContentFocused": [Function],
|
|
77
75
|
"moveFocus": [Function],
|
|
78
76
|
"on": [Function],
|
|
79
77
|
"press": [Function],
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { NativeModules } from "react-native";
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
|
|
4
|
+
import {
|
|
5
|
+
isCurrentFocusOn,
|
|
6
|
+
isChildOf as isChildOfUtils,
|
|
7
|
+
} from "../focusManagerAux/utils";
|
|
4
8
|
import { Tree } from "./treeDataStructure/Tree";
|
|
5
9
|
import { findFocusableNode } from "./treeDataStructure/Utils";
|
|
6
10
|
import { subscriber } from "../../functionUtils";
|
|
7
11
|
import { findChild } from "./utils";
|
|
8
12
|
|
|
9
13
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
isCurrentFocusOnTabsScreenContent,
|
|
14
|
-
} from "../focusManagerAux/utils/index.ios";
|
|
14
|
+
emitRegistered,
|
|
15
|
+
emitUnregistered,
|
|
16
|
+
} from "../focusManagerAux/utils/utils.ios";
|
|
15
17
|
|
|
16
18
|
const { FocusableManagerModule } = NativeModules;
|
|
17
19
|
|
|
@@ -186,18 +188,13 @@ export const focusManager = (function () {
|
|
|
186
188
|
function register({ id, component }) {
|
|
187
189
|
const { isGroup = false } = component;
|
|
188
190
|
|
|
189
|
-
|
|
190
|
-
// id,
|
|
191
|
-
// isGroup,
|
|
192
|
-
// component,
|
|
193
|
-
// name: component.constructor?.name,
|
|
194
|
-
// });
|
|
191
|
+
emitRegistered(id);
|
|
195
192
|
|
|
196
193
|
return isGroup ? registerGroup(id, component) : registerItem(id, component);
|
|
197
194
|
}
|
|
198
195
|
|
|
199
196
|
function unregister(id, { group = false } = {}) {
|
|
200
|
-
|
|
197
|
+
emitUnregistered(id);
|
|
201
198
|
|
|
202
199
|
group ? unregisterGroup(id) : unregisterItem(id);
|
|
203
200
|
}
|
|
@@ -276,9 +273,7 @@ export const focusManager = (function () {
|
|
|
276
273
|
function setFocus(
|
|
277
274
|
id: string,
|
|
278
275
|
direction?: FocusManager.IOS.Direction,
|
|
279
|
-
options?: Partial<{
|
|
280
|
-
groupFocusedChanged: boolean;
|
|
281
|
-
}>,
|
|
276
|
+
options?: Partial<{ groupFocusedChanged: boolean }>,
|
|
282
277
|
callback?: any
|
|
283
278
|
) {
|
|
284
279
|
blur(direction);
|
|
@@ -417,55 +412,8 @@ export const focusManager = (function () {
|
|
|
417
412
|
return id && isCurrentFocusOn(id, currentFocusNode);
|
|
418
413
|
}
|
|
419
414
|
|
|
420
|
-
function
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
const result = isCurrentFocusOnMenu(
|
|
424
|
-
focusableTree,
|
|
425
|
-
currentFocusable?.props?.id
|
|
426
|
-
);
|
|
427
|
-
|
|
428
|
-
console.log("debug_2", "FM - isFocusOnMenu", {
|
|
429
|
-
result,
|
|
430
|
-
focusableTree,
|
|
431
|
-
currentFocusable,
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
return result;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
function isFocusOnContent(): boolean {
|
|
438
|
-
const currentFocusable = getCurrentFocus();
|
|
439
|
-
|
|
440
|
-
const result = isCurrentFocusOnContent(
|
|
441
|
-
focusableTree,
|
|
442
|
-
currentFocusable?.props?.id
|
|
443
|
-
);
|
|
444
|
-
|
|
445
|
-
console.log("debug_2", "FM - isFocusOnContent", {
|
|
446
|
-
result,
|
|
447
|
-
focusableTree,
|
|
448
|
-
currentFocusable,
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
return result;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
function isTabsScreenContentFocused(): boolean {
|
|
455
|
-
const currentFocusable = getCurrentFocus();
|
|
456
|
-
|
|
457
|
-
const result = isCurrentFocusOnTabsScreenContent(
|
|
458
|
-
focusableTree,
|
|
459
|
-
currentFocusable?.props?.id
|
|
460
|
-
);
|
|
461
|
-
|
|
462
|
-
console.log("debug_2", "FM - isTabsScreenContentFocused", {
|
|
463
|
-
result,
|
|
464
|
-
focusableTree,
|
|
465
|
-
currentFocusable,
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
return result;
|
|
415
|
+
function isChildOf(childId, parentId): boolean {
|
|
416
|
+
return isChildOfUtils(focusableTree, childId, parentId);
|
|
469
417
|
}
|
|
470
418
|
|
|
471
419
|
return {
|
|
@@ -490,8 +438,6 @@ export const focusManager = (function () {
|
|
|
490
438
|
isGroupItemFocused,
|
|
491
439
|
getPreferredFocusChild,
|
|
492
440
|
isFocusOn,
|
|
493
|
-
|
|
494
|
-
isFocusOnContent,
|
|
495
|
-
isTabsScreenContentFocused,
|
|
441
|
+
isChildOf,
|
|
496
442
|
};
|
|
497
443
|
})();
|
|
@@ -190,3 +190,21 @@ export const isCurrentFocusOn = (id, node) => {
|
|
|
190
190
|
|
|
191
191
|
return isCurrentFocusOn(id, node.parent);
|
|
192
192
|
};
|
|
193
|
+
|
|
194
|
+
export const isChildOf = (focusableTree, childId, parentId) => {
|
|
195
|
+
if (isNil(childId) || isNil(parentId)) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const childNode = focusableTree.findInTree(childId);
|
|
200
|
+
|
|
201
|
+
if (isNil(childNode)) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (childNode.parent?.id === parentId) {
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return isChildOf(focusableTree, childNode.parent?.id, parentId);
|
|
210
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ReplaySubject } from "rxjs";
|
|
2
|
+
import { filter } from "rxjs/operators";
|
|
3
|
+
import { BUTTON_PREFIX } from "@applicaster/zapp-react-native-ui-components/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const";
|
|
4
|
+
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager/index.ios";
|
|
5
|
+
|
|
6
|
+
type FocusableID = string;
|
|
7
|
+
type RegistrationEvent = {
|
|
8
|
+
id: FocusableID;
|
|
9
|
+
registered: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const isFocusableButton = (id: Option<FocusableID>): boolean =>
|
|
13
|
+
id && id.includes?.(BUTTON_PREFIX);
|
|
14
|
+
|
|
15
|
+
const registeredSubject$ = new ReplaySubject<RegistrationEvent>(1);
|
|
16
|
+
|
|
17
|
+
export const focusableButtonsRegistration$ = (focusableGroupId: string) =>
|
|
18
|
+
registeredSubject$.pipe(
|
|
19
|
+
filter(
|
|
20
|
+
(value) =>
|
|
21
|
+
value.registered && focusManager.isChildOf(value.id, focusableGroupId)
|
|
22
|
+
)
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export const emitRegistered = (id: Option<FocusableID>): void => {
|
|
26
|
+
if (isFocusableButton(id)) {
|
|
27
|
+
registeredSubject$.next({ id, registered: true });
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const emitUnregistered = (id: Option<FocusableID>): void => {
|
|
32
|
+
if (isFocusableButton(id)) {
|
|
33
|
+
registeredSubject$.next({ id, registered: false });
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -229,14 +229,14 @@ export class TTSManager {
|
|
|
229
229
|
try {
|
|
230
230
|
window.webOS.service.request("luna://com.webos.service.tts", {
|
|
231
231
|
method: "speak",
|
|
232
|
-
onFailure(error: any) {
|
|
232
|
+
onFailure: (error: any) => {
|
|
233
233
|
log_debug("There was a failure setting up webOS TTS service", {
|
|
234
234
|
error,
|
|
235
235
|
});
|
|
236
236
|
|
|
237
237
|
this.ttsState$.next(false);
|
|
238
238
|
},
|
|
239
|
-
onSuccess(response: any) {
|
|
239
|
+
onSuccess: (response: any) => {
|
|
240
240
|
log_debug("webOS TTS service is configured successfully", {
|
|
241
241
|
response,
|
|
242
242
|
});
|
|
@@ -2,6 +2,27 @@ export const userPreferencesNamespace = "user_preferences";
|
|
|
2
2
|
|
|
3
3
|
export const skipActionType = "show_skip";
|
|
4
4
|
|
|
5
|
+
export class PlayerError
|
|
6
|
+
extends Error
|
|
7
|
+
implements QuickBrickPlayer.PlayerErrorI
|
|
8
|
+
{
|
|
9
|
+
description: string;
|
|
10
|
+
|
|
11
|
+
constructor(message: string, description: string) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.description = description;
|
|
14
|
+
|
|
15
|
+
Object.setPrototypeOf(this, PlayerError.prototype);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
toObject() {
|
|
19
|
+
return {
|
|
20
|
+
error: this.message,
|
|
21
|
+
message: this.description,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
5
26
|
export enum SharedPlayerCallBacksKeys {
|
|
6
27
|
OnPlayerResume = "onPlayerResume",
|
|
7
28
|
OnPlayerPause = "onPlayerPause",
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { allTruthy } from "..";
|
|
2
|
+
|
|
3
|
+
describe("allTruthy", () => {
|
|
4
|
+
it("should return true when all values are true", () => {
|
|
5
|
+
expect(allTruthy([true, true, true])).toBe(true);
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it("should return false when at least one value is false", () => {
|
|
9
|
+
expect(allTruthy([true, false, true])).toBe(false);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should return false when all values are false", () => {
|
|
13
|
+
expect(allTruthy([false, false, false])).toBe(false);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should return false for an empty array", () => {
|
|
17
|
+
expect(allTruthy([])).toBe(false);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("should handle single-element arrays correctly", () => {
|
|
21
|
+
expect(allTruthy([true])).toBe(true);
|
|
22
|
+
expect(allTruthy([false])).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { anyTruthy } from "..";
|
|
2
|
+
|
|
3
|
+
describe("anyTruthy", () => {
|
|
4
|
+
it("should return true when at least one value is true", () => {
|
|
5
|
+
expect(anyTruthy([false, true, false])).toBe(true);
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it("should return false when all values are false", () => {
|
|
9
|
+
expect(anyTruthy([false, false, false])).toBe(false);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should return true when all values are true", () => {
|
|
13
|
+
expect(anyTruthy([true, true, true])).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should return false for an empty array", () => {
|
|
17
|
+
expect(anyTruthy([])).toBe(false);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("should handle single-element arrays correctly", () => {
|
|
21
|
+
expect(anyTruthy([true])).toBe(true);
|
|
22
|
+
expect(anyTruthy([false])).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
});
|
package/arrayUtils/index.ts
CHANGED
package/navigationUtils/index.ts
CHANGED
|
@@ -575,24 +575,27 @@ export function routeIsPlayerScreen(currentRoute) {
|
|
|
575
575
|
return currentRoute?.includes("/playable");
|
|
576
576
|
}
|
|
577
577
|
|
|
578
|
-
export const getNavBarProps =
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
578
|
+
export const getNavBarProps = (
|
|
579
|
+
currentRiver: ZappRiver,
|
|
580
|
+
pathname: string,
|
|
581
|
+
title: string
|
|
582
|
+
) => {
|
|
583
|
+
const props = getNavigationPropsV2({
|
|
584
|
+
currentRiver,
|
|
585
|
+
title,
|
|
586
|
+
category: "nav_bar",
|
|
587
|
+
});
|
|
585
588
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
589
|
+
if (props) {
|
|
590
|
+
return {
|
|
591
|
+
...props,
|
|
592
|
+
id: pathname,
|
|
593
|
+
pathname: pathname,
|
|
594
|
+
};
|
|
595
|
+
}
|
|
593
596
|
|
|
594
|
-
|
|
595
|
-
|
|
597
|
+
return null;
|
|
598
|
+
};
|
|
596
599
|
|
|
597
600
|
export const findMenuPlugin = (
|
|
598
601
|
navigations: ZappNavigation[],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "14.0.0-alpha.
|
|
3
|
+
"version": "14.0.0-alpha.6000342231",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "14.0.0-alpha.
|
|
30
|
+
"@applicaster/applicaster-types": "14.0.0-alpha.6000342231",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -37,15 +37,6 @@ export const useFeedLoader = ({
|
|
|
37
37
|
mapping,
|
|
38
38
|
pipesOptions = {},
|
|
39
39
|
}: Props): FeedLoaderResponse => {
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (!feedUrl) {
|
|
42
|
-
logger.warning({
|
|
43
|
-
message: "Required parameter feedUrl is missing",
|
|
44
|
-
data: { feedUrl },
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}, []);
|
|
48
|
-
|
|
49
40
|
const isInitialRender = useIsInitialRender();
|
|
50
41
|
|
|
51
42
|
const callableFeedUrl = useInflatedUrl({ feedUrl, mapping });
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
} from "@applicaster/zapp-pipes-v2-client";
|
|
19
19
|
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
20
20
|
import { ENDPOINT_TAGS } from "../../types";
|
|
21
|
+
import { isNilOrEmpty } from "../../reactUtils/helpers";
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* will match any occurrence in a string of one or more word characters
|
|
@@ -75,15 +76,19 @@ export const getInflatedDataSourceUrl: GetInflatedDataSourceUrl = ({
|
|
|
75
76
|
* https://foo.com/shows/A1234
|
|
76
77
|
*/
|
|
77
78
|
|
|
78
|
-
if (!
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
if (!isNilOrEmpty(mapping)) {
|
|
80
|
+
if (!source) {
|
|
81
|
+
if (__DEV__) {
|
|
82
|
+
// eslint-disable-next-line no-console
|
|
83
|
+
throw new Error(
|
|
84
|
+
"getInflatedDataSourceUrl: source is empty while mapping is provided"
|
|
85
|
+
);
|
|
86
|
+
}
|
|
85
87
|
|
|
86
|
-
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
return source || null;
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
// Hack because in tv we expect to get key names instead of values from the fake entry
|
|
@@ -193,28 +198,17 @@ export function useInflatedUrl({
|
|
|
193
198
|
|
|
194
199
|
const url = useMemo(
|
|
195
200
|
() =>
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
: feedUrl,
|
|
207
|
-
[feedUrl, mapping]
|
|
201
|
+
getInflatedDataSourceUrl({
|
|
202
|
+
source: feedUrl,
|
|
203
|
+
contexts: {
|
|
204
|
+
entry: entryContext,
|
|
205
|
+
screen: screenContext,
|
|
206
|
+
search: getSearchContext(searchContext, mapping),
|
|
207
|
+
},
|
|
208
|
+
mapping,
|
|
209
|
+
}),
|
|
210
|
+
[entryContext, feedUrl, mapping, screenContext, searchContext]
|
|
208
211
|
);
|
|
209
212
|
|
|
210
|
-
if (!feedUrl) {
|
|
211
|
-
logger.warning({
|
|
212
|
-
message: "Required parameter feedUrl is missing",
|
|
213
|
-
data: { feedUrl },
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
return null;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
213
|
return url;
|
|
220
214
|
}
|
package/utils/index.ts
CHANGED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isNil,
|
|
3
|
-
startsWith,
|
|
4
|
-
endsWith,
|
|
5
|
-
} from "@applicaster/zapp-react-native-utils/utils";
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
QUICK_BRICK_CONTENT,
|
|
9
|
-
QUICK_BRICK_NAVBAR,
|
|
10
|
-
} from "@applicaster/quick-brick-core/const";
|
|
11
|
-
|
|
12
|
-
import { SCREEN_PICKER_CONTAINER } from "@applicaster/zapp-react-native-utils/screenPickerUtils";
|
|
13
|
-
|
|
14
|
-
const isNavBar = (node) => startsWith(QUICK_BRICK_NAVBAR, node?.id);
|
|
15
|
-
const isContent = (node) => startsWith(QUICK_BRICK_CONTENT, node?.id);
|
|
16
|
-
const isRoot = (node) => node?.id === "root";
|
|
17
|
-
|
|
18
|
-
// FIXME
|
|
19
|
-
const isScrenPicker = (node) =>
|
|
20
|
-
startsWith(SCREEN_PICKER_CONTAINER, node?.id) &&
|
|
21
|
-
endsWith("-screen-container", node?.id);
|
|
22
|
-
|
|
23
|
-
export const isCurrentFocusOnTabsScreenContent = (focusableTree, id) => {
|
|
24
|
-
const node = focusableTree.findInTree(id);
|
|
25
|
-
|
|
26
|
-
if (isNil(node)) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (isRoot(node)) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (isNavBar(node)) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (isContent(node)) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (isScrenPicker(node)) {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return isCurrentFocusOnTabsScreenContent(focusableTree, node.parent?.id);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const isCurrentFocusOnMenu = (focusableTree, id): boolean => {
|
|
50
|
-
const node = focusableTree.findInTree(id);
|
|
51
|
-
|
|
52
|
-
if (isNil(node)) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (isRoot(node)) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (isNavBar(node)) {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (isContent(node)) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return isCurrentFocusOnMenu(focusableTree, node.parent.id);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const isCurrentFocusOnContent = (focusableTree, id) => {
|
|
72
|
-
const node = focusableTree.findInTree(id);
|
|
73
|
-
|
|
74
|
-
if (isNil(node)) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (isRoot(node)) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (isNavBar(node)) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (isContent(node)) {
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return isCurrentFocusOnContent(focusableTree, node.parent?.id);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export const isCurrentFocusOn = (id, node) => {
|
|
94
|
-
if (!node) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (isRoot(node)) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (node?.id === id) {
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return isCurrentFocusOn(id, node.parent);
|
|
107
|
-
};
|