@applicaster/zapp-react-native-utils 13.0.0-alpha.5335086935 → 13.0.0-alpha.5375459737
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 +137 -6
- package/actionsExecutor/consts.ts +4 -0
- package/appUtils/HooksManager/Hook.ts +4 -0
- package/appUtils/HooksManager/index.ts +3 -1
- package/appUtils/contextKeysManager/contextResolver.ts +1 -12
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +1 -0
- package/appUtils/focusManager/index.ts +14 -10
- package/appUtils/keyCodes/index.ts +11 -7
- package/appUtils/localizationsHelper.ts +23 -0
- package/appUtils/orientationHelper.ts +11 -13
- package/appUtils/playerManager/player.ts +24 -12
- package/appUtils/playerManager/playerNative.ts +18 -3
- package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +7 -1
- package/arrayUtils/index.ts +1 -1
- package/componentsUtils/index.ts +18 -3
- package/dateUtils/index.ts +19 -0
- package/focusManager/FocusManager.ts +3 -1
- package/focusManager/index.ts +3 -21
- package/functionUtils/index.ts +46 -8
- package/index.d.ts +0 -12
- package/localizationUtils/index.ts +5 -10
- package/manifestUtils/defaultManifestConfigurations/player.js +14 -0
- package/manifestUtils/fonts/index.js +5 -6
- package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +1 -1
- package/modalState/__tests__/index.test.ts +51 -0
- package/modalState/index.ts +32 -2
- package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +1 -0
- package/navigationUtils/index.ts +3 -1
- package/numberUtils/__tests__/toPositiveNumberWithDefault.test.ts +23 -3
- package/numberUtils/index.ts +11 -5
- package/package.json +2 -6
- package/playerUtils/configurationGenerator.ts +14 -0
- package/reactHooks/advertising/index.ts +5 -5
- package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +5 -7
- package/reactHooks/autoscrolling/useTrackedView.ts +12 -1
- package/reactHooks/feed/useFeedLoader.tsx +17 -8
- package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +39 -0
- package/reactHooks/navigation/__tests__/index.test.tsx +6 -17
- package/reactHooks/navigation/index.ts +6 -4
- package/reactHooks/navigation/useRoute.ts +4 -6
- package/services/js2native.ts +673 -0
- package/time/BackgroundTimer.ts +55 -0
- package/time/Timer.ts +6 -6
- package/utils/README.md +30 -0
- package/utils/chunk.ts +5 -0
- package/utils/index.ts +5 -0
- package/utils/times.ts +5 -0
- package/zappFrameworkUtils/localStorageHelper.ts +6 -0
- package/zappFrameworkUtils/loginPluginUtils.ts +6 -2
- package/zappFrameworkUtils/types.ts +11 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="@applicaster/applicaster-types" />
|
|
2
2
|
import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
|
|
3
|
-
import React, { createContext, useMemo } from "react";
|
|
3
|
+
import React, { createContext, useEffect, useMemo } from "react";
|
|
4
|
+
import { NativeModules } from "react-native";
|
|
4
5
|
import {
|
|
5
6
|
actionExecutor as _actionExecutor,
|
|
6
7
|
ActionResult,
|
|
@@ -19,8 +20,20 @@ import {
|
|
|
19
20
|
EntryResolver,
|
|
20
21
|
resolveObjectValues,
|
|
21
22
|
} from "../appUtils/contextKeysManager/contextResolver";
|
|
23
|
+
import { useNavigation } from "../reactHooks";
|
|
24
|
+
import { get } from "lodash";
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
import {
|
|
27
|
+
useContentTypes,
|
|
28
|
+
usePickFromState,
|
|
29
|
+
} from "@applicaster/zapp-react-native-redux/hooks";
|
|
30
|
+
import {
|
|
31
|
+
ACTION_EXECUTOR_EVENT_SOURCE,
|
|
32
|
+
TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT,
|
|
33
|
+
} from "./consts";
|
|
34
|
+
const { ReactNativeEventBusBridge } = NativeModules;
|
|
35
|
+
|
|
36
|
+
export const { log_error, log_info, log_debug } = createLogger({
|
|
24
37
|
subsystem: "ActionExecutorContext",
|
|
25
38
|
category: "General",
|
|
26
39
|
});
|
|
@@ -51,6 +64,42 @@ type Props = {
|
|
|
51
64
|
children: React.ReactNode;
|
|
52
65
|
};
|
|
53
66
|
|
|
67
|
+
function findParentComponent(
|
|
68
|
+
childId: string,
|
|
69
|
+
parent: ZappRiver | ZappUIComponent
|
|
70
|
+
): ZappRiver | ZappUIComponent | null {
|
|
71
|
+
for (const child of parent.ui_components) {
|
|
72
|
+
if (child.id === childId) return parent;
|
|
73
|
+
|
|
74
|
+
if (child.ui_components) {
|
|
75
|
+
const found = findParentComponent(childId, child);
|
|
76
|
+
if (found) return found;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// send all data just in case (like for message string formatting)
|
|
84
|
+
// Type is not exported for now
|
|
85
|
+
type MaxTagsReachedEvent = {
|
|
86
|
+
// todo: current stable Android SDK crashes when we pass array from RN back to RN
|
|
87
|
+
selectedItems?: string[];
|
|
88
|
+
maxItems: number;
|
|
89
|
+
tag: string;
|
|
90
|
+
keyNamespace: string;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
async function onMaxTagsReached(data: MaxTagsReachedEvent) {
|
|
94
|
+
const event = {
|
|
95
|
+
type: TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT,
|
|
96
|
+
source: ACTION_EXECUTOR_EVENT_SOURCE,
|
|
97
|
+
data,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
await ReactNativeEventBusBridge?.postEvent(event);
|
|
101
|
+
}
|
|
102
|
+
|
|
54
103
|
const prepareDefaultActions = (actionExecutor) => {
|
|
55
104
|
actionExecutor.registerAction("localStorageSet", async (action) => {
|
|
56
105
|
const namespaces = action.options.content;
|
|
@@ -65,11 +114,13 @@ const prepareDefaultActions = (actionExecutor) => {
|
|
|
65
114
|
async (_action, context) => {
|
|
66
115
|
const dispatch = appStore.getDispatch();
|
|
67
116
|
|
|
68
|
-
|
|
117
|
+
const dataSource =
|
|
118
|
+
context?.component?.data?.source ||
|
|
119
|
+
findParentComponent(context?.component.id, context?.screenData)?.data
|
|
120
|
+
?.source;
|
|
69
121
|
|
|
70
|
-
|
|
122
|
+
log_info(`handleAction: refreshComponent for dataSource:${dataSource}`);
|
|
71
123
|
|
|
72
|
-
// TODO: Later we can pass component ids to do refresh instead of current one
|
|
73
124
|
// TODO: In theory we should wait callback to complete, before completing the action, but now it's not needed
|
|
74
125
|
// TODO: handle focused item removal
|
|
75
126
|
dispatch(
|
|
@@ -169,8 +220,29 @@ const prepareDefaultActions = (actionExecutor) => {
|
|
|
169
220
|
action: ActionType,
|
|
170
221
|
context?: Record<string, any>
|
|
171
222
|
): Promise<ActionResult> => {
|
|
223
|
+
if (!context) {
|
|
224
|
+
log_error(
|
|
225
|
+
"handleAction: localStorageToggleFlag action missing context"
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
return ActionResult.Error;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const entry = context?.entry as ZappEntry;
|
|
232
|
+
|
|
233
|
+
if (!entry) {
|
|
234
|
+
log_error(
|
|
235
|
+
"handleAction: localStorageToggleFlag action missing entry. Entry is required to get the tag."
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
return ActionResult.Error;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const tag = action.options?.selector
|
|
242
|
+
? get(entry, action.options.selector)
|
|
243
|
+
: (entry.extensions?.tag ?? entry.id);
|
|
244
|
+
|
|
172
245
|
const keyNamespace = action.options?.key;
|
|
173
|
-
const tag = context?.entry?.extensions?.tag;
|
|
174
246
|
|
|
175
247
|
if (keyNamespace && tag) {
|
|
176
248
|
const multiSelectProvider =
|
|
@@ -188,6 +260,23 @@ const prepareDefaultActions = (actionExecutor) => {
|
|
|
188
260
|
if (selectedItems.includes(tag)) {
|
|
189
261
|
await multiSelectProvider.removeItem(tag);
|
|
190
262
|
} else {
|
|
263
|
+
const maxItems = action.options?.max_items;
|
|
264
|
+
|
|
265
|
+
if (maxItems && selectedItems.length >= maxItems) {
|
|
266
|
+
log_info(
|
|
267
|
+
`handleAction: localStorageToggleFlag event reached max items limit: ${maxItems}, cannot add tag: ${tag}`
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
await onMaxTagsReached({
|
|
271
|
+
selectedItems,
|
|
272
|
+
maxItems,
|
|
273
|
+
tag,
|
|
274
|
+
keyNamespace,
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
return ActionResult.Cancel;
|
|
278
|
+
}
|
|
279
|
+
|
|
191
280
|
await multiSelectProvider.addItem(tag);
|
|
192
281
|
}
|
|
193
282
|
} else {
|
|
@@ -211,6 +300,10 @@ export function withActionExecutor(Component) {
|
|
|
211
300
|
prepareDefaultActions(_actionExecutor);
|
|
212
301
|
|
|
213
302
|
return function ActionExecutorComponent(props: Props) {
|
|
303
|
+
const navigator = useNavigation();
|
|
304
|
+
const { rivers } = usePickFromState(["rivers"]);
|
|
305
|
+
const contentTypes = useContentTypes();
|
|
306
|
+
|
|
214
307
|
const handlers = useMemo(() => {
|
|
215
308
|
return {
|
|
216
309
|
unregisterAction: _actionExecutor.unregisterAction,
|
|
@@ -221,6 +314,44 @@ export function withActionExecutor(Component) {
|
|
|
221
314
|
};
|
|
222
315
|
}, []);
|
|
223
316
|
|
|
317
|
+
useEffect(() => {
|
|
318
|
+
return _actionExecutor.registerAction(
|
|
319
|
+
"navigateToScreen",
|
|
320
|
+
async (action: ActionType, context?: Record<string, any>) => {
|
|
321
|
+
const screenType = action.options?.typeMapping;
|
|
322
|
+
|
|
323
|
+
if (!screenType) {
|
|
324
|
+
log_error("navigateToScreen: typeMapping option is missing");
|
|
325
|
+
|
|
326
|
+
return ActionResult.Error;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const screenId = contentTypes?.[screenType]?.screen_id || null;
|
|
330
|
+
|
|
331
|
+
if (!screenId) {
|
|
332
|
+
log_error(
|
|
333
|
+
`navigateToScreen: can not resolve screen type mapping: ${screenType}`
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
return ActionResult.Error;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const river = rivers[screenId];
|
|
340
|
+
|
|
341
|
+
if (!river) {
|
|
342
|
+
log_error("navigateToScreen: can not resolve river");
|
|
343
|
+
|
|
344
|
+
return ActionResult.Error;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
context?.callback?.({ success: false, error: null, abort: true });
|
|
348
|
+
navigator.replace(river);
|
|
349
|
+
|
|
350
|
+
return ActionResult.Success;
|
|
351
|
+
}
|
|
352
|
+
);
|
|
353
|
+
}, [navigator, rivers, contentTypes]);
|
|
354
|
+
|
|
224
355
|
return (
|
|
225
356
|
<ActionExecutorContext.Provider value={handlers}>
|
|
226
357
|
<Component {...props} />
|
|
@@ -65,6 +65,10 @@ export class Hook implements HookInterface {
|
|
|
65
65
|
event: (typeof HOOKS_EVENTS)[keyof typeof HOOKS_EVENTS],
|
|
66
66
|
...args
|
|
67
67
|
) {
|
|
68
|
+
if (this.state === hookState(HOOKS_EVENTS.CANCEL)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
68
72
|
this.state = hookState(event);
|
|
69
73
|
this.manager.subscriber.invokeHandler(event, ...args);
|
|
70
74
|
}
|
|
@@ -84,7 +84,7 @@ export function HooksManager({
|
|
|
84
84
|
plugins,
|
|
85
85
|
startUpHooksData = {},
|
|
86
86
|
}: HookManagerArgs): HookManager {
|
|
87
|
-
hooksManagerLogger.addContext({ targetScreen });
|
|
87
|
+
hooksManagerLogger.addContext({ targetScreenId: targetScreen.id });
|
|
88
88
|
|
|
89
89
|
function logHookEvent(func, message, data) {
|
|
90
90
|
func({
|
|
@@ -269,6 +269,7 @@ export function HooksManager({
|
|
|
269
269
|
payload = initialPayload,
|
|
270
270
|
callback: callbackArg,
|
|
271
271
|
cancelled,
|
|
272
|
+
abort,
|
|
272
273
|
}) {
|
|
273
274
|
let callback = callbackArg;
|
|
274
275
|
|
|
@@ -308,6 +309,7 @@ export function HooksManager({
|
|
|
308
309
|
hookPlugin.setStateAndNotify(HOOKS_EVENTS.CANCEL, {
|
|
309
310
|
hookPlugin,
|
|
310
311
|
payload,
|
|
312
|
+
abort,
|
|
311
313
|
});
|
|
312
314
|
|
|
313
315
|
const isHookInHomescreen = payload?.home;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import { createLogger } from "../../logger";
|
|
2
1
|
import { ContextKeysManager } from "./index";
|
|
3
2
|
import * as R from "ramda";
|
|
4
3
|
|
|
5
|
-
const { log_error } = createLogger({
|
|
6
|
-
subsystem: "contextResolver",
|
|
7
|
-
category: "General",
|
|
8
|
-
});
|
|
9
|
-
|
|
10
4
|
interface IResolver {
|
|
11
5
|
resolve: (string) => Promise<string | number | object>;
|
|
12
6
|
}
|
|
@@ -64,12 +58,7 @@ export const resolveObjectValues = async (
|
|
|
64
58
|
return [key, resolvedValue];
|
|
65
59
|
}
|
|
66
60
|
|
|
67
|
-
|
|
68
|
-
key,
|
|
69
|
-
value,
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
return [key, null];
|
|
61
|
+
return [key, value];
|
|
73
62
|
})
|
|
74
63
|
);
|
|
75
64
|
|
|
@@ -334,16 +334,7 @@ export const focusManager = (function () {
|
|
|
334
334
|
return { success: false };
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
-
function treeLoaded(
|
|
338
|
-
logger.log({
|
|
339
|
-
message: "treeLoaded",
|
|
340
|
-
data: {
|
|
341
|
-
val,
|
|
342
|
-
node,
|
|
343
|
-
currentFocusNode,
|
|
344
|
-
},
|
|
345
|
-
});
|
|
346
|
-
}
|
|
337
|
+
function treeLoaded(_val, _node) {}
|
|
347
338
|
|
|
348
339
|
function pressIn() {
|
|
349
340
|
const currentFocusable = getCurrentFocus();
|
|
@@ -543,6 +534,18 @@ export const focusManager = (function () {
|
|
|
543
534
|
|
|
544
535
|
const { on, invokeHandler, removeHandler } = eventHandler;
|
|
545
536
|
|
|
537
|
+
function findPreferredFocusChild(id) {
|
|
538
|
+
const node = getCurrentFocusNode(id);
|
|
539
|
+
|
|
540
|
+
const preferredFocus = findPriorityItem([node]);
|
|
541
|
+
|
|
542
|
+
if (isNilOrEmpty(preferredFocus)) {
|
|
543
|
+
return undefined;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
return preferredFocus[0];
|
|
547
|
+
}
|
|
548
|
+
|
|
546
549
|
/**
|
|
547
550
|
* this is the list of the functions available externally
|
|
548
551
|
* when importing the focus manager
|
|
@@ -572,5 +575,6 @@ export const focusManager = (function () {
|
|
|
572
575
|
isGroupItemFocused,
|
|
573
576
|
recoverFocus,
|
|
574
577
|
isCurrentFocusOnTheTopScreen,
|
|
578
|
+
findPreferredFocusChild,
|
|
575
579
|
};
|
|
576
580
|
})();
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as R from "ramda";
|
|
2
|
-
|
|
3
1
|
// more keys can be added here. Simply make sure
|
|
4
2
|
// the key matches the code value
|
|
5
3
|
|
|
@@ -34,12 +32,18 @@ export function keyCode(key) {
|
|
|
34
32
|
keyCode(keyEvent).matchesAny("Enter", "Backspace", KEYS.ArrowLeft, ...)
|
|
35
33
|
*/
|
|
36
34
|
|
|
37
|
-
const matches =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
const matches = (compareKey) => {
|
|
36
|
+
// If compareKey is a string, look it up in KEYS object
|
|
37
|
+
const keyToCompare =
|
|
38
|
+
typeof compareKey === "string" ? KEYS[compareKey] : compareKey;
|
|
39
|
+
|
|
40
|
+
// Compare either code or keyCode properties
|
|
41
|
+
return (
|
|
42
|
+
keyToCompare?.code === key.code || keyToCompare?.keyCode === key.keyCode
|
|
43
|
+
);
|
|
44
|
+
};
|
|
41
45
|
|
|
42
|
-
const matchesAny = (...args) =>
|
|
46
|
+
const matchesAny = (...args) => args.some(matches);
|
|
43
47
|
|
|
44
48
|
const direction = () =>
|
|
45
49
|
matchesAny(...ARROW_KEYS) ? directionHelper(key) : null;
|
|
@@ -65,6 +65,29 @@ export function getUILanguage() {
|
|
|
65
65
|
return getLanguageCode();
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
export const toDayJSLocaleMap = (code) => {
|
|
69
|
+
const map = {
|
|
70
|
+
hy: "hy-am",
|
|
71
|
+
fj: null,
|
|
72
|
+
la: null,
|
|
73
|
+
no: null,
|
|
74
|
+
pa: "pa-in",
|
|
75
|
+
qu: null,
|
|
76
|
+
"es-LA": "es",
|
|
77
|
+
sm: null,
|
|
78
|
+
to: null,
|
|
79
|
+
xh: null,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
if (map[code] === null) {
|
|
83
|
+
return "en";
|
|
84
|
+
} else if (map[code]) {
|
|
85
|
+
return map[code];
|
|
86
|
+
} else {
|
|
87
|
+
return code;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
68
91
|
/**
|
|
69
92
|
* returns the localization for the app based on the locale. If the locale is null
|
|
70
93
|
* or undefined, or if the given locale doesn't exist in the localizations,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/// <reference types="@types/react-native" />
|
|
2
1
|
import * as ReactNative from "react-native";
|
|
3
|
-
import { isTV, platformSelect } from "../reactUtils";
|
|
4
2
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
5
|
-
|
|
3
|
+
|
|
4
|
+
import { isTV, platformSelect } from "../reactUtils";
|
|
5
|
+
import { useIsTablet } from "../reactHooks";
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
QUICK_BRICK_EVENTS,
|
|
@@ -121,8 +121,15 @@ export const removeOrientationChangeListener = (listener: any): void => {
|
|
|
121
121
|
*/
|
|
122
122
|
export const isOrientationCompatible = ({
|
|
123
123
|
orientation,
|
|
124
|
-
layoutData: { width, height },
|
|
124
|
+
layoutData: { width, height, isTablet, isTabletPortrait },
|
|
125
125
|
}) => {
|
|
126
|
+
// We count portrait as compatible, because if default in zapp for mobile layout
|
|
127
|
+
// We count landscape as compatible, because if isTabletPortrait is false,
|
|
128
|
+
// it defaults for device
|
|
129
|
+
if (isTablet && !isTabletPortrait) {
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
|
|
126
133
|
const isLandscape = width > height;
|
|
127
134
|
|
|
128
135
|
if (
|
|
@@ -146,15 +153,6 @@ export const isOrientationCompatible = ({
|
|
|
146
153
|
return true;
|
|
147
154
|
};
|
|
148
155
|
|
|
149
|
-
export const useIsOrientationCompatible = (orientation) => {
|
|
150
|
-
const { height, width } = ReactNative.useWindowDimensions();
|
|
151
|
-
|
|
152
|
-
return isOrientationCompatible({
|
|
153
|
-
orientation,
|
|
154
|
-
layoutData: { width, height },
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
|
|
158
156
|
/**
|
|
159
157
|
* Determine final screen orientation based on device type,
|
|
160
158
|
* settings and orientation value provided by screen data settings
|
|
@@ -97,7 +97,7 @@ export class Player {
|
|
|
97
97
|
this.onVideoLoad = this.onVideoLoad.bind(this);
|
|
98
98
|
this.isFullScreenSupported = this.isFullScreenSupported.bind(this);
|
|
99
99
|
this.onPlayerSeekComplete = this.onPlayerSeekComplete.bind(this);
|
|
100
|
-
|
|
100
|
+
this.onAdBreakEnd = this.onAdBreakEnd.bind(this);
|
|
101
101
|
this.entryObservable = null;
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -201,17 +201,25 @@ export class Player {
|
|
|
201
201
|
adPosition: currentTime,
|
|
202
202
|
};
|
|
203
203
|
} else {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
204
|
+
this.updateContentDuration({ seekableDuration, duration, currentTime });
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
207
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
protected updateContentDuration = ({
|
|
209
|
+
seekableDuration = null,
|
|
210
|
+
duration = null,
|
|
211
|
+
currentTime = null,
|
|
212
|
+
}) => {
|
|
213
|
+
if (!isEmptyOrNil(seekableDuration) && seekableDuration >= 0) {
|
|
214
|
+
this.playerState.seekableDuration = seekableDuration;
|
|
215
|
+
}
|
|
211
216
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
217
|
+
if (!isEmptyOrNil(duration) && duration >= 0) {
|
|
218
|
+
this.playerState.contentDuration = duration;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (!isEmptyOrNil(currentTime) && currentTime >= 0) {
|
|
222
|
+
this.playerState.contentPosition = currentTime;
|
|
215
223
|
}
|
|
216
224
|
};
|
|
217
225
|
|
|
@@ -559,7 +567,7 @@ export class Player {
|
|
|
559
567
|
});
|
|
560
568
|
};
|
|
561
569
|
|
|
562
|
-
onAdBreakEnd
|
|
570
|
+
onAdBreakEnd(event) {
|
|
563
571
|
this.playerState.adState = null;
|
|
564
572
|
this.playerState.isInAdBreak = false;
|
|
565
573
|
|
|
@@ -567,7 +575,7 @@ export class Player {
|
|
|
567
575
|
callbackName: SharedPlayerCallBacksKeys.OnAdBreakEnd,
|
|
568
576
|
event,
|
|
569
577
|
});
|
|
570
|
-
}
|
|
578
|
+
}
|
|
571
579
|
|
|
572
580
|
onAdEnd = (event) => {
|
|
573
581
|
this.playerState.adState = null;
|
|
@@ -736,6 +744,10 @@ export class Player {
|
|
|
736
744
|
return null;
|
|
737
745
|
};
|
|
738
746
|
|
|
747
|
+
public hasResumePosition() {
|
|
748
|
+
return false;
|
|
749
|
+
}
|
|
750
|
+
|
|
739
751
|
public getConfig = () => this.config;
|
|
740
752
|
|
|
741
753
|
// TODO: replace with enum of supported orientations
|
|
@@ -54,6 +54,10 @@ export class PlayerNative extends Player {
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
public hasResumePosition() {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
57
61
|
getContentPosition = () => {
|
|
58
62
|
return this.playerState.contentPosition;
|
|
59
63
|
};
|
|
@@ -221,11 +225,13 @@ export class PlayerNative extends Player {
|
|
|
221
225
|
};
|
|
222
226
|
|
|
223
227
|
onVideoLoad = (event) => {
|
|
224
|
-
|
|
225
|
-
this.seekTo(this.startPosition);
|
|
226
|
-
this.startPosition = null;
|
|
228
|
+
this.updateContentDuration(event);
|
|
227
229
|
|
|
230
|
+
if (this.startPosition && !this.playerState.isInAdBreak) {
|
|
228
231
|
super.onVideoLoad({ ...event, ignoreContinueWatching: true });
|
|
232
|
+
|
|
233
|
+
this.seekTo(this.startPosition);
|
|
234
|
+
this.startPosition = null;
|
|
229
235
|
} else {
|
|
230
236
|
super.onVideoLoad(event);
|
|
231
237
|
}
|
|
@@ -249,6 +255,15 @@ export class PlayerNative extends Player {
|
|
|
249
255
|
}
|
|
250
256
|
};
|
|
251
257
|
|
|
258
|
+
onAdBreakEnd = (event) => {
|
|
259
|
+
super.onAdBreakEnd(event);
|
|
260
|
+
|
|
261
|
+
if (this.startPosition) {
|
|
262
|
+
this.seekTo(this.startPosition);
|
|
263
|
+
this.startPosition = null;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
252
267
|
// This function is called when native player used directly without wrapped component,
|
|
253
268
|
// Since event from native comes with wrapped in NativeEvent property
|
|
254
269
|
getNativeViewListener = (): QuickBrickPlayer.SharedPlayerCallBacks => {
|
|
@@ -3,12 +3,18 @@ import { OverlaysObserver } from "./OverlayObserver/OverlaysObserver";
|
|
|
3
3
|
import { useFeedLoader } from "../../reactHooks";
|
|
4
4
|
import { usePlayer } from "./usePlayer";
|
|
5
5
|
|
|
6
|
+
const getLiveUrl = (url: string) => {
|
|
7
|
+
// Use the replace method with a regular expression to replace all instances of subClass with livePage
|
|
8
|
+
return url.replace(new RegExp("subClass", "g"), "livePage");
|
|
9
|
+
};
|
|
10
|
+
|
|
6
11
|
export const useTitleSummaryOverlay = (
|
|
7
|
-
feedUrl,
|
|
8
12
|
entry,
|
|
9
13
|
isLive = false,
|
|
10
14
|
interval: number
|
|
11
15
|
) => {
|
|
16
|
+
// TODO: Have generic place for live url from configuration. Currently its hardcoded for client.
|
|
17
|
+
const feedUrl = getLiveUrl(entry?.extensions?.live?.channel_src ?? "");
|
|
12
18
|
const player = usePlayer();
|
|
13
19
|
const [title, setTitle] = useState<string | number>(entry?.title || "");
|
|
14
20
|
const [summary, setSummary] = useState<string | number>(entry?.summary || "");
|
package/arrayUtils/index.ts
CHANGED
|
@@ -93,7 +93,7 @@ export const isIndexInRange = (index: number, length: number): boolean => {
|
|
|
93
93
|
export const makeListOfIndexes = (size: number): number[] =>
|
|
94
94
|
Array.from({ length: size }, (_, index) => index);
|
|
95
95
|
|
|
96
|
-
export const makeListOf =
|
|
96
|
+
export const makeListOf = (value: unknown, size: number): number[] => {
|
|
97
97
|
return Array(size).fill(value);
|
|
98
98
|
};
|
|
99
99
|
|
package/componentsUtils/index.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const GROUP = "group-qb";
|
|
2
|
+
const GROUP_INFO = "group-info-qb";
|
|
3
|
+
const EMPTY_GROUP_COMPONENT = "empty_group_component";
|
|
4
|
+
|
|
5
|
+
const GALLERY = "gallery-qb";
|
|
6
|
+
|
|
7
|
+
const SCREEN_PICKER = "screen-picker-qb-tv";
|
|
8
|
+
|
|
9
|
+
export const isGallery = (item): boolean => item?.component_type === GALLERY;
|
|
3
10
|
|
|
4
11
|
export const isScreenPicker = (item): boolean =>
|
|
5
|
-
item?.component_type ===
|
|
12
|
+
item?.component_type === SCREEN_PICKER;
|
|
6
13
|
|
|
7
14
|
export const isFirstComponentScreenPicker = (
|
|
8
15
|
components: ZappUIComponent[]
|
|
@@ -15,3 +22,11 @@ export const isFirstComponentGallery = (
|
|
|
15
22
|
): boolean => {
|
|
16
23
|
return isGallery(components?.[0]);
|
|
17
24
|
};
|
|
25
|
+
|
|
26
|
+
export const isGroup = (item): boolean => item?.component_type === GROUP;
|
|
27
|
+
|
|
28
|
+
export const isEmptyGroup = (item): boolean =>
|
|
29
|
+
item?.component_type === EMPTY_GROUP_COMPONENT;
|
|
30
|
+
|
|
31
|
+
export const isGroupInfo = (item): boolean =>
|
|
32
|
+
item?.component_type === GROUP_INFO;
|
package/dateUtils/index.ts
CHANGED
|
@@ -2,10 +2,29 @@ import dayjs from "dayjs";
|
|
|
2
2
|
import utc from "dayjs/plugin/utc";
|
|
3
3
|
import timezone from "dayjs/plugin/timezone";
|
|
4
4
|
import isoWeek from "dayjs/plugin/isoWeek";
|
|
5
|
+
import duration from "dayjs/plugin/duration";
|
|
6
|
+
import relativeTime from "dayjs/plugin/relativeTime";
|
|
5
7
|
|
|
6
8
|
// Extend dayjs with plugins
|
|
7
9
|
dayjs.extend(utc);
|
|
8
10
|
dayjs.extend(timezone);
|
|
9
11
|
dayjs.extend(isoWeek);
|
|
12
|
+
dayjs.extend(duration);
|
|
13
|
+
|
|
14
|
+
dayjs.extend(relativeTime, {
|
|
15
|
+
thresholds: [
|
|
16
|
+
{ l: "s", r: 1 },
|
|
17
|
+
{ l: "m", r: 1 },
|
|
18
|
+
{ l: "mm", r: 59, d: "minute" },
|
|
19
|
+
{ l: "h", r: 1 },
|
|
20
|
+
{ l: "hh", r: 23, d: "hour" },
|
|
21
|
+
{ l: "d", r: 1 },
|
|
22
|
+
{ l: "dd", r: 29, d: "day" },
|
|
23
|
+
{ l: "M", r: 1 },
|
|
24
|
+
{ l: "MM", r: 11, d: "month" },
|
|
25
|
+
{ l: "y", r: 1 },
|
|
26
|
+
{ l: "yy", d: "year" },
|
|
27
|
+
],
|
|
28
|
+
});
|
|
10
29
|
|
|
11
30
|
export { dayjs };
|
|
@@ -227,7 +227,9 @@ class FocusManager {
|
|
|
227
227
|
|
|
228
228
|
const nextNextFocus = FocusManager.getNextFocusable(direction, nextFocus);
|
|
229
229
|
|
|
230
|
-
|
|
230
|
+
if (nextNextFocus) {
|
|
231
|
+
FocusManager.instance.setFocus(nextNextFocus, options);
|
|
232
|
+
}
|
|
231
233
|
} else {
|
|
232
234
|
FocusManager.instance.setFocusLocal(nextFocus);
|
|
233
235
|
|