@applicaster/zapp-react-native-utils 12.0.0-alpha.4400210593 → 12.0.0-alpha.4408649484
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/AnalyticsEvents/index.ts +13 -0
- package/analyticsUtils/AnalyticsEvents/searchEvents.ts +21 -0
- package/analyticsUtils/AnalyticsEvents/sendShareEvent.ts +21 -0
- package/analyticsUtils/analyticsPlugins.ts +25 -0
- package/analyticsUtils/events.ts +12 -0
- package/analyticsUtils/index.tsx +12 -0
- package/appUtils/accessibilityManager/const.ts +50 -0
- package/appUtils/accessibilityManager/hooks.ts +31 -0
- package/appUtils/accessibilityManager/index.ts +150 -0
- package/appUtils/accessibilityManager/logger.ts +5 -0
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +2 -3
- package/appUtils/focusManager/__tests__/focusManager.test.js +4 -24
- package/appUtils/focusManager/__tests__/index.test.ts +2 -3
- package/appUtils/focusManager/index.ts +76 -57
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +75 -44
- package/appUtils/focusManager/utils/index.ts +100 -0
- package/appUtils/focusManagerAux/index.ts +76 -0
- package/appUtils/focusManagerAux/utils/index.ts +100 -0
- package/appUtils/index.js +2 -0
- package/appUtils/keyCodes/keys.web.js +8 -0
- package/appUtils/keyCodes/keysByPlatform.js +11 -1
- package/appUtils/platform/const.ts +25 -0
- package/appUtils/platform/index.ts +3 -0
- package/appUtils/platform/platformUtils.ts +185 -0
- package/appUtils/playerManager/conts.ts +1 -0
- package/appUtils/playerManager/index.ts +11 -5
- package/appUtils/playerManager/nativePlayerManager.ts +12 -0
- package/appUtils/playerManager/player.ts +10 -3
- package/appUtils/playerManager/playerNative.ts +10 -14
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +7 -1
- package/arrayUtils/__tests__/isFilledArray.test.ts +63 -0
- package/arrayUtils/index.ts +5 -0
- package/booleanUtils/index.ts +4 -4
- package/cellUtils/__tests__/cellUtils.test.ts +9 -20
- package/cellUtils/index.ts +6 -12
- package/dateUtils/index.ts +11 -0
- package/headersUtils/index.ts +1 -0
- package/inflatedUrlUtils/index.ts +4 -4
- package/keyboardState/index.ts +0 -0
- package/localizationUtils/__tests__/localizationUtils.test.ts +72 -53
- package/localizationUtils/index.ts +13 -22
- package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +2 -1
- package/numberUtils/__tests__/isLikeNumber.test.ts +18 -0
- package/numberUtils/index.ts +9 -18
- package/package.json +2 -2
- package/playerUtils/configurationGenerator.ts +3 -1
- package/pluginUtils/index.ts +9 -0
- package/reactHooks/autoscrolling/__tests__/{useTrackedView.test.ts → useTrackedView.test.tsx} +16 -1
- package/reactHooks/cell-click/__tests__/index.test.js +10 -1
- package/reactHooks/cell-click/index.ts +12 -12
- package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +30 -70
- package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +6 -2
- package/reactHooks/feed/__tests__/useInflatedUrl.test.ts +18 -3
- package/reactHooks/feed/useBuildPipesUrl.ts +7 -10
- package/reactHooks/feed/useFeedRefresh.tsx +9 -7
- package/reactHooks/feed/useInflatedUrl.ts +44 -15
- package/reactHooks/layout/__tests__/{index.test.js → index.test.tsx} +43 -29
- package/reactHooks/layout/getDeviceInfo/index.ts +4 -2
- package/reactHooks/layout/types/index.ts +1 -0
- package/reactHooks/layout/useDimensions/useDimensions.ts +5 -2
- package/reactHooks/navigation/__mocks__/index.ts +13 -0
- package/reactHooks/navigation/__mocks__/useNavigation.ts +3 -0
- package/reactHooks/navigation/__tests__/index.test.tsx +11 -8
- package/reactHooks/navigation/index.ts +60 -67
- package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +21 -23
- package/reactHooks/screen/index.ts +2 -0
- package/reactHooks/screen/useScreenBackgroundColor.ts +23 -0
- package/reactHooks/screen/useScreenContext.ts +3 -3
- package/reactUtils/index.ts +105 -0
- package/screenState/index.ts +0 -8
- package/stringUtils/index.ts +5 -0
- package/testUtils/getByTestId.ts +14 -0
- package/testUtils/index.tsx +24 -22
- package/types.ts +4 -0
- package/appUtils/focusManager/FocusableEvents.ts +0 -8
- package/appUtils/focusManager/treeDataStructure/Utils/__tests__/Utils_android.test.js +0 -1094
- package/appUtils/focusManager/treeDataStructure/Utils/index.android.js +0 -261
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platforms found in userAgent string, please note that simulators
|
|
3
|
+
* might not have the same agents that the devices have
|
|
4
|
+
*/
|
|
5
|
+
export const PLATFORMS = {
|
|
6
|
+
webos: "Web0S",
|
|
7
|
+
tizen: "Tizen",
|
|
8
|
+
samsung: "SMART-TV",
|
|
9
|
+
mac: "Mac",
|
|
10
|
+
win: "Win",
|
|
11
|
+
linux: "Linux",
|
|
12
|
+
iphone: "iPhone",
|
|
13
|
+
android: "Android",
|
|
14
|
+
mobile: "Mobile",
|
|
15
|
+
vizio: "VIZIO",
|
|
16
|
+
smartcast: "SmartCast",
|
|
17
|
+
conjure: "Conjure",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Keys used to store the platform / device state in the session storage
|
|
22
|
+
*/
|
|
23
|
+
export const PLATFORM_KEYS = {
|
|
24
|
+
deviceClosedCaptioningEnabled: "device_closed_captioning_enabled",
|
|
25
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { BehaviorSubject } from "rxjs";
|
|
2
|
+
|
|
3
|
+
import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
|
|
4
|
+
|
|
5
|
+
import { PLATFORM_KEYS, PLATFORMS } from "./const";
|
|
6
|
+
import { createLogger, utilsLogger } from "../../logger";
|
|
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
|
+
|
|
22
|
+
const { log_debug } = createLogger({
|
|
23
|
+
category: "General",
|
|
24
|
+
subsystem: "PlatformUtils",
|
|
25
|
+
parent: utilsLogger,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const getUserAgent = () =>
|
|
29
|
+
window?.navigator?.userAgent || global?.navigator?.userAgent;
|
|
30
|
+
|
|
31
|
+
/** VIZIO UTILS */
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Checks if we are on the Vizio platform by using the userAgent string
|
|
35
|
+
*
|
|
36
|
+
* Use this method when you need to identify the platform on runtime
|
|
37
|
+
* before the VIZIO Companion Library has loaded
|
|
38
|
+
*/
|
|
39
|
+
export const isVizioPlatform = () => {
|
|
40
|
+
const userAgent = getUserAgent();
|
|
41
|
+
|
|
42
|
+
const isVizioAgent =
|
|
43
|
+
userAgent.includes(PLATFORMS.vizio) ||
|
|
44
|
+
userAgent.includes(PLATFORMS.smartcast) ||
|
|
45
|
+
userAgent.includes(PLATFORMS.conjure);
|
|
46
|
+
|
|
47
|
+
return isVizioAgent;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Checks if we are on the Vizio platform by checking for the global VIZIO object
|
|
52
|
+
* and the VIZIO Companion Library. This method does not use the userAgent string,
|
|
53
|
+
* because it mainly checks whether we have access to apis, which may not be available yet
|
|
54
|
+
*/
|
|
55
|
+
export const hasVizioAPIs = () => {
|
|
56
|
+
const hasAPIs =
|
|
57
|
+
typeof window.VIZIO !== "undefined" &&
|
|
58
|
+
window?.applicaster?.vizioLibraryDidLoad;
|
|
59
|
+
|
|
60
|
+
return hasAPIs;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Manages device based closed captioning state
|
|
65
|
+
* Returns an observable that emits the current state and updates whenever it changes
|
|
66
|
+
*/
|
|
67
|
+
export class ClosedCaptioningManager {
|
|
68
|
+
private ccState$ = new BehaviorSubject<boolean>(false);
|
|
69
|
+
private static ccManagerInstance: ClosedCaptioningManager;
|
|
70
|
+
|
|
71
|
+
private constructor() {
|
|
72
|
+
this.initialize();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static getInstance(): ClosedCaptioningManager {
|
|
76
|
+
if (!ClosedCaptioningManager.ccManagerInstance) {
|
|
77
|
+
ClosedCaptioningManager.ccManagerInstance = new ClosedCaptioningManager();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return ClosedCaptioningManager.ccManagerInstance;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async initialize() {
|
|
84
|
+
const existingState = await sessionStorage.getItem(
|
|
85
|
+
PLATFORM_KEYS.deviceClosedCaptioningEnabled
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
log_debug("Initializing closed captioning manager", { existingState });
|
|
89
|
+
|
|
90
|
+
if (existingState !== null) {
|
|
91
|
+
this.ccState$.next(existingState === "true" || existingState === true);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (hasVizioAPIs()) {
|
|
95
|
+
window.VIZIO!.setClosedCaptionHandler((isCCEnabled) => {
|
|
96
|
+
log_debug("CC state changed", { isCCEnabled });
|
|
97
|
+
|
|
98
|
+
sessionStorage.setItem(
|
|
99
|
+
PLATFORM_KEYS.deviceClosedCaptioningEnabled,
|
|
100
|
+
isCCEnabled
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
this.ccState$.next(isCCEnabled);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
getCurrentState(): boolean {
|
|
109
|
+
return this.ccState$.getValue();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
getStateAsObservable() {
|
|
113
|
+
return this.ccState$.asObservable();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Subscribe to closed captioning state changes
|
|
119
|
+
* @returns Observable<boolean>
|
|
120
|
+
* @example
|
|
121
|
+
* const subscription = getClosedCaptionState().subscribe(
|
|
122
|
+
* isEnabled => setClosedCaptionState(isEnabled)
|
|
123
|
+
* );
|
|
124
|
+
* subscription.unsubscribe(), []);
|
|
125
|
+
*/
|
|
126
|
+
export const getClosedCaptionState = () => {
|
|
127
|
+
const ccManager = ClosedCaptioningManager.getInstance();
|
|
128
|
+
|
|
129
|
+
return ccManager.getStateAsObservable();
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Manages device based closed captioning state
|
|
134
|
+
* Returns an observable that emits the current state and updates whenever it changes
|
|
135
|
+
*/
|
|
136
|
+
export class TTSManager {
|
|
137
|
+
private ttsState$ = new BehaviorSubject<boolean>(false);
|
|
138
|
+
private static ttsManagerInstance: TTSManager;
|
|
139
|
+
|
|
140
|
+
private constructor() {
|
|
141
|
+
this.initialize();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
static getInstance(): TTSManager {
|
|
145
|
+
if (!TTSManager.ttsManagerInstance) {
|
|
146
|
+
TTSManager.ttsManagerInstance = new TTSManager();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return TTSManager.ttsManagerInstance;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async initialize() {
|
|
153
|
+
if (!isVizioPlatform()) return;
|
|
154
|
+
|
|
155
|
+
document.addEventListener(
|
|
156
|
+
"VIZIO_TTS_ENABLED",
|
|
157
|
+
() => {
|
|
158
|
+
this.ttsState$.next(true);
|
|
159
|
+
},
|
|
160
|
+
false
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
document.addEventListener(
|
|
164
|
+
"VIZIO_TTS_DISABLED",
|
|
165
|
+
() => {
|
|
166
|
+
this.ttsState$.next(false);
|
|
167
|
+
},
|
|
168
|
+
false
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
getCurrentState(): boolean {
|
|
173
|
+
return this.ttsState$.getValue();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
getStateAsObservable() {
|
|
177
|
+
return this.ttsState$.asObservable();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
readText(text: string) {
|
|
181
|
+
if (!window.VIZIO?.Chromevox) return;
|
|
182
|
+
|
|
183
|
+
window.VIZIO.Chromevox.play(text);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from "@applicaster/quick-brick-core/App/NetworkStatusProvider/utils";
|
|
12
12
|
import { setUserLanguagePreference } from "./userLanguagePreference";
|
|
13
13
|
import { PlayerRole } from "./conts";
|
|
14
|
+
import { RNPlayerManager } from "./nativePlayerManager";
|
|
14
15
|
|
|
15
16
|
const { log_error, log_debug, log_warning } = createLogger({
|
|
16
17
|
category: "General",
|
|
@@ -164,6 +165,10 @@ export class PlayerManager {
|
|
|
164
165
|
this.addPlayer(id, playerController);
|
|
165
166
|
|
|
166
167
|
if (playerController.playerRole === PlayerRole.Primary) {
|
|
168
|
+
if (playerController.playerPluginId !== "QuickBrickPlayerPlugin") {
|
|
169
|
+
RNPlayerManager?.["QuickBrickPlayerPlugin"]?.stopBackgroundPlayback?.();
|
|
170
|
+
}
|
|
171
|
+
|
|
167
172
|
playerController.addListener({
|
|
168
173
|
id: this.getPlayerListenerId(id),
|
|
169
174
|
listener: {
|
|
@@ -361,9 +366,9 @@ export class PlayerManager {
|
|
|
361
366
|
// TODO: Remove
|
|
362
367
|
if (this.castingReceiver) {
|
|
363
368
|
this.castingReceiver.rewind(deltaTime);
|
|
369
|
+
} else {
|
|
370
|
+
this.getActivePlayer()?.rewind(deltaTime);
|
|
364
371
|
}
|
|
365
|
-
|
|
366
|
-
this.getActivePlayer()?.rewind(deltaTime);
|
|
367
372
|
}
|
|
368
373
|
|
|
369
374
|
public forward(deltaTime = null) {
|
|
@@ -371,9 +376,9 @@ export class PlayerManager {
|
|
|
371
376
|
|
|
372
377
|
if (this.castingReceiver) {
|
|
373
378
|
this.castingReceiver.forward(deltaTime);
|
|
379
|
+
} else {
|
|
380
|
+
this.getActivePlayer()?.forward(deltaTime);
|
|
374
381
|
}
|
|
375
|
-
|
|
376
|
-
this.getActivePlayer()?.forward(deltaTime);
|
|
377
382
|
}
|
|
378
383
|
|
|
379
384
|
public seeking(time) {
|
|
@@ -436,7 +441,7 @@ export class PlayerManager {
|
|
|
436
441
|
}
|
|
437
442
|
|
|
438
443
|
// Call method on player just in case
|
|
439
|
-
return this.getActivePlayer()?.
|
|
444
|
+
return this.getActivePlayer()?.selectTrack(track);
|
|
440
445
|
}
|
|
441
446
|
|
|
442
447
|
public isRegistered() {
|
|
@@ -461,6 +466,7 @@ export class PlayerManager {
|
|
|
461
466
|
if (this.castingReceiver) {
|
|
462
467
|
this.castingReceiver.closeNativePlayer();
|
|
463
468
|
} else {
|
|
469
|
+
this.getActivePlayer().closeNativePlayer();
|
|
464
470
|
this.invokeHandler("close");
|
|
465
471
|
}
|
|
466
472
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NativeModules } from "react-native";
|
|
2
|
+
import { isApplePlatform } from "../../reactUtils";
|
|
3
|
+
|
|
4
|
+
export const RNPlayerManager = {
|
|
5
|
+
QuickBrickPlayerPlugin: isApplePlatform()
|
|
6
|
+
? NativeModules.PlayerModule
|
|
7
|
+
: NativeModules.QuickBrickDefaultPlayerModule,
|
|
8
|
+
KalturaPlayerPlugin: isApplePlatform()
|
|
9
|
+
? NativeModules.KalturaPlayerModule
|
|
10
|
+
: NativeModules.QBKalturaPlayerModule,
|
|
11
|
+
"quick-brick-player-brightcove": NativeModules.BrightcovePlayerModule,
|
|
12
|
+
};
|
|
@@ -359,6 +359,13 @@ export class Player {
|
|
|
359
359
|
});
|
|
360
360
|
};
|
|
361
361
|
|
|
362
|
+
onVideoError = (error: Error) => {
|
|
363
|
+
this.invokeListenersUpdate({
|
|
364
|
+
callbackName: SharedPlayerCallBacksKeys.OnVideoError,
|
|
365
|
+
event: error,
|
|
366
|
+
});
|
|
367
|
+
};
|
|
368
|
+
|
|
362
369
|
onError = (error: Error) => {
|
|
363
370
|
this.invokeListenersUpdate({
|
|
364
371
|
callbackName: SharedPlayerCallBacksKeys.OnError,
|
|
@@ -650,6 +657,7 @@ export class Player {
|
|
|
650
657
|
onPlayerSeekComplete: this.onSeekComplete,
|
|
651
658
|
onVideoEnd: this.onVideoEnd,
|
|
652
659
|
onError: this.onError,
|
|
660
|
+
onVideoError: this.onVideoError,
|
|
653
661
|
onLoad: this.onLoad,
|
|
654
662
|
onPlayerPause: this.onPlayerPause,
|
|
655
663
|
onPlayerResume: this.onPlayerResume,
|
|
@@ -684,9 +692,6 @@ export class Player {
|
|
|
684
692
|
play = () => {};
|
|
685
693
|
pause = () => {};
|
|
686
694
|
disableBufferAnimation = (): boolean => true;
|
|
687
|
-
setLanguage = (
|
|
688
|
-
_selected?: QuickBrickPlayer.TextTrack | QuickBrickPlayer.AudioTrack
|
|
689
|
-
) => {};
|
|
690
695
|
|
|
691
696
|
setPlaybackRate = (_rate) => {};
|
|
692
697
|
startSleepTimer = (_timestamp) => {};
|
|
@@ -727,4 +732,6 @@ export class Player {
|
|
|
727
732
|
}
|
|
728
733
|
|
|
729
734
|
public supportsNativeControls = (): boolean => false;
|
|
735
|
+
public supportNativeCast = (): boolean => false;
|
|
736
|
+
public destroy = () => {};
|
|
730
737
|
}
|
|
@@ -2,19 +2,10 @@ import * as R from "ramda";
|
|
|
2
2
|
import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
3
3
|
import { createLogger, utilsLogger } from "../../logger";
|
|
4
4
|
import { Player } from "./player";
|
|
5
|
-
import { findNodeHandle
|
|
6
|
-
import { isApplePlatform } from "../../reactUtils";
|
|
5
|
+
import { findNodeHandle } from "react-native";
|
|
7
6
|
import { PlayerRole } from "./conts";
|
|
8
7
|
import { toBooleanWithDefaultFalse } from "../../booleanUtils";
|
|
9
|
-
|
|
10
|
-
const RNPlayerManager = {
|
|
11
|
-
QuickBrickPlayerPlugin: isApplePlatform()
|
|
12
|
-
? NativeModules.PlayerModule
|
|
13
|
-
: NativeModules.QuickBrickDefaultPlayerModule,
|
|
14
|
-
KalturaPlayerPlugin: isApplePlatform()
|
|
15
|
-
? NativeModules.KalturaPlayerModule
|
|
16
|
-
: NativeModules.QBKalturaPlayerModule,
|
|
17
|
-
};
|
|
8
|
+
import { RNPlayerManager } from "./nativePlayerManager";
|
|
18
9
|
|
|
19
10
|
const logger = createLogger({
|
|
20
11
|
category: "PlayerNativeController",
|
|
@@ -111,7 +102,7 @@ export class PlayerNative extends Player {
|
|
|
111
102
|
return;
|
|
112
103
|
}
|
|
113
104
|
|
|
114
|
-
const newPosition = R.clamp(0,
|
|
105
|
+
const newPosition = R.clamp(0, this.playerState.seekableDuration, position);
|
|
115
106
|
|
|
116
107
|
if (
|
|
117
108
|
!this.invokeNativeFunction(
|
|
@@ -197,10 +188,10 @@ export class PlayerNative extends Player {
|
|
|
197
188
|
|
|
198
189
|
disableBufferAnimation = (): boolean => false;
|
|
199
190
|
|
|
200
|
-
|
|
191
|
+
selectTrack = (
|
|
201
192
|
selected: QuickBrickPlayer.TextTrack | QuickBrickPlayer.AudioTrack
|
|
202
193
|
) => {
|
|
203
|
-
this.currentPlayerComponent()?.["
|
|
194
|
+
this.currentPlayerComponent()?.["selectTrack"]?.(selected);
|
|
204
195
|
};
|
|
205
196
|
|
|
206
197
|
setPlaybackRate = (rate: number) => {
|
|
@@ -295,4 +286,9 @@ export class PlayerNative extends Player {
|
|
|
295
286
|
|
|
296
287
|
supportsNativeControls = (): boolean =>
|
|
297
288
|
toBooleanWithDefaultFalse(this.getConfig()?.["supports_native_controls"]);
|
|
289
|
+
|
|
290
|
+
supportNativeCast = (): boolean =>
|
|
291
|
+
toBooleanWithDefaultFalse(
|
|
292
|
+
this.playerPluginId === "quick-brick-player-brightcove"
|
|
293
|
+
);
|
|
298
294
|
}
|
|
@@ -4,6 +4,7 @@ import { useEffect } from "react";
|
|
|
4
4
|
import { playerManager } from "./index";
|
|
5
5
|
import { useValidatePlayerConfig } from "../../playerUtils/useValidatePlayerConfig";
|
|
6
6
|
import { PlayerRole } from "./conts";
|
|
7
|
+
import { isAppleTV } from "@applicaster/zapp-react-native-ui-components/Helpers/Platform";
|
|
7
8
|
|
|
8
9
|
// TODO: Rename to ControllerType
|
|
9
10
|
export const usePlayerControllerSetup = ({
|
|
@@ -34,10 +35,14 @@ export const usePlayerControllerSetup = ({
|
|
|
34
35
|
useValidatePlayerConfig(config);
|
|
35
36
|
|
|
36
37
|
useEffect(() => {
|
|
38
|
+
const newConfig = isAppleTV()
|
|
39
|
+
? { supports_native_controls: true, ...config }
|
|
40
|
+
: config;
|
|
41
|
+
|
|
37
42
|
const newPlayerController = new ControllerType({
|
|
38
43
|
player: ref,
|
|
39
44
|
listener: props as any,
|
|
40
|
-
config,
|
|
45
|
+
config: newConfig,
|
|
41
46
|
playerId,
|
|
42
47
|
entry,
|
|
43
48
|
playerPluginId: pluginId,
|
|
@@ -67,6 +72,7 @@ export const usePlayerControllerSetup = ({
|
|
|
67
72
|
|
|
68
73
|
return () => {
|
|
69
74
|
playerManager.unregisterPlayer(playerId);
|
|
75
|
+
playerController.destroy?.();
|
|
70
76
|
};
|
|
71
77
|
}, [playerId, playerController]);
|
|
72
78
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { isFilledArray } from "..";
|
|
2
|
+
|
|
3
|
+
describe("isFilledArray", () => {
|
|
4
|
+
it("non-empty array is not empty", () => {
|
|
5
|
+
const value = [1, 2, 3];
|
|
6
|
+
|
|
7
|
+
expect(isFilledArray(value)).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("empty array is empty", () => {
|
|
11
|
+
const value = [];
|
|
12
|
+
|
|
13
|
+
expect(isFilledArray(value)).toBe(false);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("number is not array", () => {
|
|
17
|
+
const value = 123;
|
|
18
|
+
|
|
19
|
+
expect(isFilledArray(value)).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("string is not array", () => {
|
|
23
|
+
const value = "vfnjdk";
|
|
24
|
+
|
|
25
|
+
expect(isFilledArray(value)).toBe(false);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("empty string is not array", () => {
|
|
29
|
+
const value = "";
|
|
30
|
+
|
|
31
|
+
expect(isFilledArray(value)).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("NaN is not array", () => {
|
|
35
|
+
const value = "";
|
|
36
|
+
|
|
37
|
+
expect(isFilledArray(value)).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("object is not array", () => {
|
|
41
|
+
const value = { test: 1 };
|
|
42
|
+
|
|
43
|
+
expect(isFilledArray(value)).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("empty object is not array", () => {
|
|
47
|
+
const value = {};
|
|
48
|
+
|
|
49
|
+
expect(isFilledArray(value)).toBe(false);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("undefined is not array", () => {
|
|
53
|
+
const value = undefined;
|
|
54
|
+
|
|
55
|
+
expect(isFilledArray(value)).toBe(false);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("null is not array", () => {
|
|
59
|
+
const value = null;
|
|
60
|
+
|
|
61
|
+
expect(isFilledArray(value)).toBe(false);
|
|
62
|
+
});
|
|
63
|
+
});
|
package/arrayUtils/index.ts
CHANGED
|
@@ -95,3 +95,8 @@ export const makeListOfIndexes = (size: number): number[] =>
|
|
|
95
95
|
export const makeListOf = (value: unknown, size: number): number[] => {
|
|
96
96
|
return Array(size).fill(value);
|
|
97
97
|
};
|
|
98
|
+
|
|
99
|
+
/** Checks if a value is a non-empty array */
|
|
100
|
+
export function isFilledArray(value: unknown): boolean {
|
|
101
|
+
return R.is(Array, value) && R.length(value) > 0;
|
|
102
|
+
}
|
package/booleanUtils/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { is, toLower } from "ramda";
|
|
2
2
|
|
|
3
3
|
export const toBoolean = (value: any): boolean | undefined => {
|
|
4
|
-
if (
|
|
4
|
+
if (is(Boolean, value)) {
|
|
5
5
|
return value;
|
|
6
6
|
}
|
|
7
7
|
|
|
@@ -17,12 +17,12 @@ export const toBooleanWithDefaultTrue = toBooleanWithDefault(true);
|
|
|
17
17
|
|
|
18
18
|
export const toBooleanWithDefaultFalse = toBooleanWithDefault(false);
|
|
19
19
|
|
|
20
|
-
export const isTrue = (value:
|
|
20
|
+
export const isTrue = (value: unknown): boolean => {
|
|
21
21
|
if (value === true) {
|
|
22
22
|
return true;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
if (
|
|
25
|
+
if (is(String, value) && toLower(value) === "true") {
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -24,7 +24,6 @@ import {
|
|
|
24
24
|
EMPTY,
|
|
25
25
|
FALLBACK,
|
|
26
26
|
TRANSFORM,
|
|
27
|
-
defaultColor,
|
|
28
27
|
} from "./fixtures";
|
|
29
28
|
|
|
30
29
|
describe("getKeyForLabel", () => {
|
|
@@ -395,9 +394,7 @@ describe("getColorFromData", () => {
|
|
|
395
394
|
it("should return value directly if valid color", () => {
|
|
396
395
|
const result = getColorFromData({
|
|
397
396
|
data: entry,
|
|
398
|
-
|
|
399
|
-
getValue: getValue(componentStyle),
|
|
400
|
-
defaultColor,
|
|
397
|
+
valueFromLayout: "#123456",
|
|
401
398
|
});
|
|
402
399
|
|
|
403
400
|
expect(result).toBe("#123456");
|
|
@@ -406,9 +403,7 @@ describe("getColorFromData", () => {
|
|
|
406
403
|
it("should return valid rgba color name", () => {
|
|
407
404
|
const result = getColorFromData({
|
|
408
405
|
data: entry,
|
|
409
|
-
|
|
410
|
-
getValue: getValue(componentStyle),
|
|
411
|
-
defaultColor,
|
|
406
|
+
valueFromLayout: "rgba(255, 255, 255, 0)",
|
|
412
407
|
});
|
|
413
408
|
|
|
414
409
|
expect(result).toBe("rgba(255, 255, 255, 0)");
|
|
@@ -417,33 +412,27 @@ describe("getColorFromData", () => {
|
|
|
417
412
|
it("should return path value if path value is set and is valid color", () => {
|
|
418
413
|
const result = getColorFromData({
|
|
419
414
|
data: entry,
|
|
420
|
-
|
|
421
|
-
getValue: getValue(componentStyle),
|
|
422
|
-
defaultColor,
|
|
415
|
+
valueFromLayout: "background_color",
|
|
423
416
|
});
|
|
424
417
|
|
|
425
418
|
expect(result).toBe("#123456");
|
|
426
419
|
});
|
|
427
420
|
|
|
428
|
-
it("should return
|
|
421
|
+
it("should return path value if path value is set, nested and is valid color", () => {
|
|
429
422
|
const result = getColorFromData({
|
|
430
423
|
data: entry,
|
|
431
|
-
|
|
432
|
-
getValue: getValue(componentStyle),
|
|
433
|
-
defaultColor,
|
|
424
|
+
valueFromLayout: "extensions.background_color",
|
|
434
425
|
});
|
|
435
426
|
|
|
436
|
-
expect(result).toBe(
|
|
427
|
+
expect(result).toBe("#123456");
|
|
437
428
|
});
|
|
438
429
|
|
|
439
|
-
it("should return
|
|
430
|
+
it("should return valueFromLayout if path does not exist", () => {
|
|
440
431
|
const result = getColorFromData({
|
|
441
432
|
data: entry,
|
|
442
|
-
|
|
443
|
-
getValue: getValue(componentStyle),
|
|
444
|
-
defaultColor,
|
|
433
|
+
valueFromLayout: "invalid_color",
|
|
445
434
|
});
|
|
446
435
|
|
|
447
|
-
expect(result).toBe(
|
|
436
|
+
expect(result).toBe("invalid_color");
|
|
448
437
|
});
|
|
449
438
|
});
|
package/cellUtils/index.ts
CHANGED
|
@@ -447,30 +447,24 @@ export const toResizeMode = (
|
|
|
447
447
|
|
|
448
448
|
type GetColorFromData = {
|
|
449
449
|
data: Record<string, any>;
|
|
450
|
-
|
|
451
|
-
getValue: Function;
|
|
452
|
-
defaultColor: string;
|
|
450
|
+
valueFromLayout: string;
|
|
453
451
|
};
|
|
454
452
|
|
|
455
453
|
export const getColorFromData = ({
|
|
456
454
|
data,
|
|
457
|
-
|
|
458
|
-
getValue,
|
|
459
|
-
defaultColor,
|
|
455
|
+
valueFromLayout,
|
|
460
456
|
}: GetColorFromData): string => {
|
|
461
|
-
const value = getValue(key);
|
|
462
|
-
|
|
463
457
|
// Temporary hack to fix color validation when alpha is floating point number
|
|
464
458
|
// https://github.com/dreamyguy/validate-color/issues/44
|
|
465
|
-
if (validateColor(
|
|
466
|
-
return
|
|
459
|
+
if (validateColor(valueFromLayout.replace(".00", ""))) {
|
|
460
|
+
return valueFromLayout;
|
|
467
461
|
}
|
|
468
462
|
|
|
469
|
-
const pathValue = R.path(
|
|
463
|
+
const pathValue = R.path(valueFromLayout.split("."), data);
|
|
470
464
|
|
|
471
465
|
if (pathValue && validateColor(pathValue)) {
|
|
472
466
|
return pathValue;
|
|
473
467
|
}
|
|
474
468
|
|
|
475
|
-
return
|
|
469
|
+
return valueFromLayout;
|
|
476
470
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import utc from "dayjs/plugin/utc";
|
|
3
|
+
import timezone from "dayjs/plugin/timezone";
|
|
4
|
+
import isoWeek from "dayjs/plugin/isoWeek";
|
|
5
|
+
|
|
6
|
+
// Extend dayjs with plugins
|
|
7
|
+
dayjs.extend(utc);
|
|
8
|
+
dayjs.extend(timezone);
|
|
9
|
+
dayjs.extend(isoWeek);
|
|
10
|
+
|
|
11
|
+
export { dayjs };
|
package/headersUtils/index.ts
CHANGED
|
@@ -28,5 +28,6 @@ export const getAppDataHeaders = (screenId: string) => {
|
|
|
28
28
|
"x-applicaster-signed-device-info-token": appData.signedDeviceInfoToken,
|
|
29
29
|
"x-applicaster-device-make": appData.deviceMake,
|
|
30
30
|
"x-applicaster-device-model": appData.deviceModel,
|
|
31
|
+
"x-applicaster-uuid": appData?.uuid,
|
|
31
32
|
};
|
|
32
33
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { last, head, isNil, includes,
|
|
1
|
+
import { last, head, isNil, includes, pathOr } from "ramda";
|
|
2
2
|
|
|
3
3
|
const stripBrackets = (path) => {
|
|
4
4
|
const withoutPrepened = last(path.split("{{"));
|
|
@@ -13,15 +13,15 @@ const hasValue = (context) => (path) => {
|
|
|
13
13
|
return !isNil(value);
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export const
|
|
16
|
+
export const getMissingValues = (context, string): string[] => {
|
|
17
17
|
if (!includes("{{", string)) {
|
|
18
|
-
return
|
|
18
|
+
return [];
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const SEARCH_REGEX = new RegExp(/{{.*?}}/g);
|
|
22
22
|
const paths = string.toString().match(SEARCH_REGEX);
|
|
23
23
|
|
|
24
|
-
return
|
|
24
|
+
return paths.filter((path) => !hasValue(context)(path));
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export const isNonInflatedUrl = (url: string): boolean =>
|
|
File without changes
|