@applicaster/zapp-react-native-utils 16.0.0-alpha.2663208063 → 16.0.0-alpha.2710214351
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/actionUtils/index.ts +3 -1
- package/actionsExecutor/ActionExecutor.ts +10 -1
- package/actionsExecutor/ActionExecutorContext.tsx +29 -1
- package/actionsExecutor/__tests__/ActionExecutor.test.ts +71 -0
- package/actionsExecutor/__tests__/StorageActions.test.ts +98 -0
- package/actionsExecutor/__tests__/feedDecorator.test.ts +91 -0
- package/actionsExecutor/__tests__/screenToggleFlag.test.ts +90 -0
- package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +3 -0
- package/actionsExecutor/actions/__tests__/goBack.test.ts +62 -0
- package/actionsExecutor/actions/__tests__/goHome.test.ts +19 -0
- package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +267 -0
- package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +24 -0
- package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +273 -1
- package/actionsExecutor/actions/__tests__/presentScreen.test.ts +127 -0
- package/actionsExecutor/actions/__tests__/showAlert.test.ts +49 -0
- package/actionsExecutor/actions/__tests__/showToast.test.ts +2 -2
- package/actionsExecutor/actions/dismissBottomSheet.ts +2 -1
- package/actionsExecutor/actions/goBack.ts +60 -0
- package/actionsExecutor/actions/goHome.ts +31 -0
- package/actionsExecutor/actions/index.ts +8 -0
- package/actionsExecutor/actions/navigateToScreen.ts +43 -45
- package/actionsExecutor/actions/openBottomSheet.ts +36 -16
- package/actionsExecutor/actions/presentScreen.ts +78 -0
- package/actionsExecutor/actions/screenToggleFlag.ts +1 -3
- package/actionsExecutor/actions/showAlert.ts +51 -0
- package/actionsExecutor/actions/showToast.ts +2 -2
- package/actionsExecutor/consts.ts +4 -0
- package/actionsExecutor/feedDecorator.ts +12 -6
- package/appUtils/contextKeysManager/__tests__/getKey/failure.test.ts +1 -22
- package/appUtils/contextKeysManager/__tests__/getKey/success/fullSearch.test.ts +1 -25
- package/appUtils/contextKeysManager/__tests__/getKey/success/searchInSecure.test.ts +1 -7
- package/appUtils/contextKeysManager/__tests__/removeKey/failure.test.ts +0 -25
- package/appUtils/contextKeysManager/__tests__/removeKey/success.test.ts +0 -6
- package/appUtils/contextKeysManager/__tests__/setKey/failure/failedToSaveInStorage.test.ts +0 -40
- package/appUtils/contextKeysManager/__tests__/setKey/{success/saveItemAndReference.test.ts → success.test.ts} +2 -42
- package/appUtils/contextKeysManager/index.ts +28 -129
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +4 -11
- package/appUtils/playerManager/OverlayObserver/__tests__/getUpcomingQueue.test.ts +67 -0
- package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +9 -2
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.android.tv.ts +4 -1
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ios.tv.ts +4 -1
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ts +21 -2
- package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.web.ts +4 -1
- package/appUtils/playerManager/OverlayObserver/utils.ts +9 -7
- package/appUtils/playerManager/__tests__/playerDiagnostics.test.ts +62 -0
- package/appUtils/playerManager/__tests__/playerNative.test.ts +114 -0
- package/appUtils/playerManager/__tests__/playerNativeCommand.test.ts +62 -0
- package/appUtils/playerManager/__tests__/playerToolbox.test.ts +281 -0
- package/appUtils/playerManager/__tests__/usePlayerControllerSetup.test.tsx +62 -0
- package/appUtils/playerManager/const.ts +13 -0
- package/appUtils/playerManager/index.ts +7 -0
- package/appUtils/playerManager/player.ts +25 -0
- package/appUtils/playerManager/playerNative.ts +27 -3
- package/appUtils/playerManager/playerNativeCommand.ts +3 -6
- package/appUtils/playerManager/playerToolbox.ts +196 -0
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +6 -0
- package/arrayUtils/__tests__/reorderByIds.test.ts +13 -0
- package/arrayUtils/index.ts +26 -43
- package/cellUtils/__tests__/getButtonsEnabled.test.ts +28 -0
- package/cellUtils/__tests__/getCellNavigationEnabled.test.ts +36 -0
- package/cellUtils/__tests__/getIsCellNavigationEnabled.test.ts +35 -0
- package/cellUtils/__tests__/isCellNavigationEnabled.test.ts +21 -0
- package/cellUtils/index.ts +70 -3
- package/configurationUtils/__tests__/manifestKeyParser.test.ts +21 -0
- package/configurationUtils/__tests__/modalBlocksParser.test.ts +297 -1
- package/configurationUtils/manifestKeyParser.ts +12 -1
- package/configurationUtils/modalBlocksParser.ts +78 -4
- package/entryActions/__tests__/buildEntryActions.test.ts +235 -0
- package/entryActions/aliasPresentation.ts +108 -0
- package/entryActions/buildEntryActions.ts +167 -0
- package/entryActions/index.ts +15 -0
- package/entryActions/types.ts +39 -0
- package/focusManager/FocusManager.ts +26 -0
- package/focusManager/__tests__/FocusManager.test.ts +9 -0
- package/localizationUtils/index.ts +12 -6
- package/logger/__tests__/xrayToolbox.test.ts +69 -0
- package/logger/xrayToolbox.ts +67 -0
- package/manifestUtils/_internals/index.js +8 -3
- package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +30 -1
- package/manifestUtils/keys.js +7 -2
- package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +21 -0
- package/manifestUtils/mobileAction/groups/__tests__/buildMobileActionButtonGroups.test.js +1 -1
- package/manifestUtils/mobileAction/groups/defaults.js +2 -1
- package/modalState/ModalOrchestrator.ts +23 -9
- package/modalState/RemoteEditableCollection.ts +9 -1
- package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +39 -0
- package/modalState/__tests__/RemoteEditableCollection.test.ts +90 -1
- package/modalState/__tests__/index.test.ts +30 -1
- package/modalState/__tests__/useModalStoreState.test.ts +142 -0
- package/modalState/index.ts +8 -1
- package/modalState/store.ts +9 -2
- package/modalState/types.ts +42 -2
- package/modalState/useBottomSheetContent.ts +24 -17
- package/navigationUtils/xrayNavigator.ts +12 -0
- package/package.json +3 -2
- package/playerUtils/__tests__/resolvePlayerActions.test.ts +138 -0
- package/playerUtils/index.ts +17 -1
- package/playerUtils/resolvePlayerActions.ts +71 -0
- package/pluginUtils/__tests__/pluginUtils.test.js +32 -0
- package/pluginUtils/index.ts +29 -0
- package/quickBrickAssets/__tests__/index.test.ts +18 -0
- package/quickBrickAssets/index.ts +35 -0
- package/reactHooks/__tests__/getPluginConfiguration.test.ts +82 -0
- package/reactHooks/actions/index.ts +74 -3
- package/reactHooks/cell-click/__tests__/index.test.js +64 -0
- package/reactHooks/cell-click/index.ts +21 -14
- package/reactHooks/connection/index.tsx +8 -5
- package/reactHooks/feed/__tests__/feedInvalidation.test.tsx +338 -0
- package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +8 -2
- package/reactHooks/feed/__tests__/useMarkPipesDataStale.test.tsx +243 -0
- package/reactHooks/feed/useFeedLoader.tsx +28 -1
- package/reactHooks/feed/useLoadPipesDataDispatch.ts +12 -11
- package/reactHooks/feed/useMarkPipesDataStale.ts +68 -23
- package/reactHooks/navigation/__tests__/index.test.tsx +176 -1
- package/reactHooks/navigation/__tests__/usePresentScreen.test.ts +154 -0
- package/reactHooks/navigation/index.ts +2 -0
- package/reactHooks/navigation/usePresentScreen.ts +157 -0
- package/reactHooks/navigation/useRoute.ts +22 -5
- package/reactHooks/usePluginConfiguration.ts +84 -46
- package/riverComponetsMeasurementProvider/index.tsx +3 -1
- package/uiActionsRegistrator/__tests__/resolveActionIdentifiers.test.ts +93 -0
- package/uiActionsRegistrator/__tests__/subscribe.test.ts +133 -0
- package/uiActionsRegistrator/__tests__/usableActionItems.test.ts +52 -0
- package/uiActionsRegistrator/index.ts +25 -203
- package/uiActionsRegistrator/registry.ts +351 -0
- package/uiActionsRegistrator/resolveActionIdentifiers.ts +100 -0
- package/uiActionsRegistrator/usableActionItems.ts +66 -0
- package/appUtils/contextKeysManager/__tests__/getKey/success/byReference.test.ts +0 -56
- package/appUtils/contextKeysManager/__tests__/getKeyByReference/failure.test.ts +0 -265
- package/appUtils/contextKeysManager/__tests__/getKeyByReference/success.test.ts +0 -303
- package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/failure.test.ts +0 -82
- package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/success.test.ts +0 -41
- package/appUtils/contextKeysManager/__tests__/setKey/success/saveItemButNotReference.test.ts +0 -208
- package/appUtils/contextKeysManager/__tests__/setReferenceForKey/failure.test.ts +0 -93
- package/appUtils/contextKeysManager/__tests__/setReferenceForKey/success.test.ts +0 -45
- package/playerUtils/__tests__/getPlayerActionButtons.test.ts +0 -54
- package/playerUtils/getPlayerActionButtons.ts +0 -17
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNil } from "@applicaster/zapp-react-native-utils/utils";
|
|
2
2
|
|
|
3
|
-
import { StorageLevel
|
|
3
|
+
import { StorageLevel } from "./consts";
|
|
4
4
|
import {
|
|
5
5
|
getNamespaceAndKey,
|
|
6
6
|
keyIsValid,
|
|
@@ -59,18 +59,14 @@ type Setup = {
|
|
|
59
59
|
sessionStorage?: Storage;
|
|
60
60
|
localStorage?: Storage;
|
|
61
61
|
secureStorage?: Storage;
|
|
62
|
-
referenceStorage?: Storage;
|
|
63
62
|
};
|
|
64
63
|
|
|
65
|
-
export const REFERENCE_NAMESPACE = "applicaster.v2.references";
|
|
66
|
-
|
|
67
64
|
export class ContextKeysManager {
|
|
68
65
|
private static _instance: ContextKeysManager;
|
|
69
66
|
private _logger: Logger;
|
|
70
67
|
private _sessionStorage: Storage;
|
|
71
68
|
private _localStorage: Storage;
|
|
72
69
|
private _secureStorage: Storage;
|
|
73
|
-
private _referenceStorage: Storage;
|
|
74
70
|
|
|
75
71
|
public static get instance() {
|
|
76
72
|
if (!this._instance) {
|
|
@@ -79,7 +75,6 @@ export class ContextKeysManager {
|
|
|
79
75
|
sessionStorage: SessionStorage,
|
|
80
76
|
localStorage: LocalStorage,
|
|
81
77
|
secureStorage: SecureStorage,
|
|
82
|
-
referenceStorage: SessionStorage,
|
|
83
78
|
});
|
|
84
79
|
|
|
85
80
|
this._instance = instance;
|
|
@@ -94,13 +89,11 @@ export class ContextKeysManager {
|
|
|
94
89
|
sessionStorage = SessionStorage,
|
|
95
90
|
localStorage = LocalStorage,
|
|
96
91
|
secureStorage = SecureStorage,
|
|
97
|
-
|
|
98
|
-
}: Setup) {
|
|
92
|
+
}: Setup = {}) {
|
|
99
93
|
this._logger = logger;
|
|
100
94
|
this._sessionStorage = sessionStorage;
|
|
101
95
|
this._localStorage = localStorage;
|
|
102
96
|
this._secureStorage = secureStorage;
|
|
103
|
-
this._referenceStorage = referenceStorage;
|
|
104
97
|
}
|
|
105
98
|
|
|
106
99
|
private parseKey(key: KeyName): ParsedKeyAndNamespace {
|
|
@@ -119,41 +112,6 @@ export class ContextKeysManager {
|
|
|
119
112
|
return { isValid: true, ...parsedKey };
|
|
120
113
|
}
|
|
121
114
|
|
|
122
|
-
// GET
|
|
123
|
-
public async getKeyByReference(
|
|
124
|
-
key: string,
|
|
125
|
-
namespace: string
|
|
126
|
-
): Promise<ValueOrNothing> {
|
|
127
|
-
// 1) look for storage
|
|
128
|
-
// 2) if storage found - look value in it
|
|
129
|
-
// 3) if storage not found return NOTHING
|
|
130
|
-
|
|
131
|
-
return this._referenceStorage
|
|
132
|
-
.getItem(buildNamespaceKey(key, namespace), REFERENCE_NAMESPACE)
|
|
133
|
-
.then((storage: StorageType | unknown) => {
|
|
134
|
-
switch (storage) {
|
|
135
|
-
case StorageType.session:
|
|
136
|
-
return this._sessionStorage.getItem(key, namespace);
|
|
137
|
-
case StorageType.local:
|
|
138
|
-
return this._localStorage.getItem(key, namespace);
|
|
139
|
-
case StorageType.secure:
|
|
140
|
-
return this._secureStorage.getItem(key, namespace);
|
|
141
|
-
default:
|
|
142
|
-
// unknown storage
|
|
143
|
-
return NOTHING;
|
|
144
|
-
}
|
|
145
|
-
})
|
|
146
|
-
.catch((error) => {
|
|
147
|
-
// something went wrong
|
|
148
|
-
this._logger.warn({
|
|
149
|
-
message: error.message,
|
|
150
|
-
data: { key, namespace },
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
return NOTHING;
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
|
|
157
115
|
public async getKeys(
|
|
158
116
|
keys: Array<KeyName>,
|
|
159
117
|
contextObj?: { key: string; required?: boolean }[]
|
|
@@ -228,19 +186,7 @@ export class ContextKeysManager {
|
|
|
228
186
|
return NOTHING;
|
|
229
187
|
}
|
|
230
188
|
|
|
231
|
-
//
|
|
232
|
-
// if not found, look in session > local > secure
|
|
233
|
-
|
|
234
|
-
const resultByReference = await this.getKeyByReference(
|
|
235
|
-
parsedKey,
|
|
236
|
-
parsedNamespace
|
|
237
|
-
);
|
|
238
|
-
|
|
239
|
-
if (!isNil(resultByReference)) {
|
|
240
|
-
return resultByReference;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// try to full-search
|
|
189
|
+
// look in session > local > secure
|
|
244
190
|
try {
|
|
245
191
|
const resultFromSessionStorage = await this._sessionStorage.getItem(
|
|
246
192
|
parsedKey,
|
|
@@ -284,41 +230,6 @@ export class ContextKeysManager {
|
|
|
284
230
|
// GET
|
|
285
231
|
|
|
286
232
|
// SET
|
|
287
|
-
public async setReferenceForKey(
|
|
288
|
-
key: string,
|
|
289
|
-
namespace: string,
|
|
290
|
-
storageLevel: StorageLevel
|
|
291
|
-
): Promise<boolean> {
|
|
292
|
-
return this._referenceStorage
|
|
293
|
-
.setItem(
|
|
294
|
-
buildNamespaceKey(key, namespace),
|
|
295
|
-
storageLevel,
|
|
296
|
-
REFERENCE_NAMESPACE
|
|
297
|
-
)
|
|
298
|
-
.then((result) => {
|
|
299
|
-
if (savingResultIsSuccess(result)) {
|
|
300
|
-
return true;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
this._logger.warn({
|
|
304
|
-
message:
|
|
305
|
-
"While saving reference - reference storage return non expected value: true",
|
|
306
|
-
data: { key, namespace, storageLevel },
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
return false;
|
|
310
|
-
})
|
|
311
|
-
.catch((error) => {
|
|
312
|
-
// something went wrong
|
|
313
|
-
this._logger.warn({
|
|
314
|
-
message: error.message,
|
|
315
|
-
data: { key, namespace, storageLevel },
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
return false;
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
|
|
322
233
|
// for all keys where saving were succeed return true
|
|
323
234
|
// for others return false
|
|
324
235
|
public async setKeys(
|
|
@@ -352,29 +263,36 @@ export class ContextKeysManager {
|
|
|
352
263
|
}
|
|
353
264
|
|
|
354
265
|
try {
|
|
266
|
+
let setItemResult: boolean;
|
|
267
|
+
|
|
355
268
|
switch (storageLevel) {
|
|
356
269
|
case StorageLevel.persisted:
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
270
|
+
setItemResult = await this._localStorage.setItem(
|
|
271
|
+
parsedKey,
|
|
272
|
+
value,
|
|
273
|
+
parsedNamespace
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
break;
|
|
363
277
|
case StorageLevel.secure:
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
278
|
+
setItemResult = await this._secureStorage.setItem(
|
|
279
|
+
parsedKey,
|
|
280
|
+
value,
|
|
281
|
+
parsedNamespace
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
break;
|
|
370
285
|
default:
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
286
|
+
setItemResult = await this._sessionStorage.setItem(
|
|
287
|
+
parsedKey,
|
|
288
|
+
value,
|
|
289
|
+
parsedNamespace
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
break;
|
|
377
293
|
}
|
|
294
|
+
|
|
295
|
+
return savingResultIsSuccess(setItemResult);
|
|
378
296
|
} catch (error) {
|
|
379
297
|
// something went wrong
|
|
380
298
|
this._logger.warn({
|
|
@@ -388,24 +306,6 @@ export class ContextKeysManager {
|
|
|
388
306
|
// SET
|
|
389
307
|
|
|
390
308
|
// REMOVE
|
|
391
|
-
public async removeReferenceForKey(
|
|
392
|
-
key: string,
|
|
393
|
-
namespace: string
|
|
394
|
-
): Promise<boolean> {
|
|
395
|
-
return this._referenceStorage
|
|
396
|
-
.removeItem(buildNamespaceKey(key, namespace), REFERENCE_NAMESPACE)
|
|
397
|
-
.then(() => true)
|
|
398
|
-
.catch((error) => {
|
|
399
|
-
// something went wrong
|
|
400
|
-
this._logger.warn({
|
|
401
|
-
message: error.message,
|
|
402
|
-
data: { key, namespace },
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
return false;
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
|
|
409
309
|
public async removeKey(key: KeyName): Promise<boolean> {
|
|
410
310
|
const {
|
|
411
311
|
isValid: isValidKey,
|
|
@@ -422,7 +322,6 @@ export class ContextKeysManager {
|
|
|
422
322
|
this._sessionStorage.removeItem(parsedKey, parsedNamespace),
|
|
423
323
|
this._localStorage.removeItem(parsedKey, parsedNamespace),
|
|
424
324
|
this._secureStorage.removeItem(parsedKey, parsedNamespace),
|
|
425
|
-
this.removeReferenceForKey(parsedKey, parsedNamespace),
|
|
426
325
|
])
|
|
427
326
|
.then(() => true)
|
|
428
327
|
.catch((error) => {
|
|
@@ -2,8 +2,7 @@ import { BehaviorSubject, Observable } from "rxjs";
|
|
|
2
2
|
import { distinctUntilChanged } from "rxjs/operators";
|
|
3
3
|
import { Player } from "../player";
|
|
4
4
|
import { createLogger, utilsLogger } from "../../../logger";
|
|
5
|
-
import {
|
|
6
|
-
import { findPluginByIdentifier } from "../../../pluginUtils";
|
|
5
|
+
import { getPluginByIdentifier } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
7
6
|
import {
|
|
8
7
|
loadFeedEntry,
|
|
9
8
|
loadFeedAndPrefetchThumbnailImage,
|
|
@@ -237,11 +236,8 @@ export class OverlaysObserver {
|
|
|
237
236
|
|
|
238
237
|
preparePlayNext = async () => {
|
|
239
238
|
try {
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
const playNextPlugin: any = findPluginByIdentifier(
|
|
243
|
-
"QuickBrickPlayNextOverlay",
|
|
244
|
-
plugins
|
|
239
|
+
const playNextPlugin: any = getPluginByIdentifier(
|
|
240
|
+
"QuickBrickPlayNextOverlay"
|
|
245
241
|
);
|
|
246
242
|
|
|
247
243
|
if (!playNextPlugin) {
|
|
@@ -252,10 +248,7 @@ export class OverlaysObserver {
|
|
|
252
248
|
return;
|
|
253
249
|
}
|
|
254
250
|
|
|
255
|
-
const playNextFeedUrl: string = await retrieveFeedUrl(
|
|
256
|
-
this.entry,
|
|
257
|
-
plugins
|
|
258
|
-
);
|
|
251
|
+
const playNextFeedUrl: string = await retrieveFeedUrl(this.entry);
|
|
259
252
|
|
|
260
253
|
if (!playNextFeedUrl || typeof playNextFeedUrl !== "string") {
|
|
261
254
|
log_debug(
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { getUpcomingQueue } from "../getUpcomingQueue";
|
|
2
|
+
|
|
3
|
+
describe("getUpcomingQueue", () => {
|
|
4
|
+
it("returns null when plugin is not provided or has no module", async () => {
|
|
5
|
+
expect(await getUpcomingQueue(undefined)).toBeNull();
|
|
6
|
+
expect(await getUpcomingQueue({} as any)).toBeNull();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("returns null when QueueManager is not present on module", async () => {
|
|
10
|
+
const plugin = {
|
|
11
|
+
identifier: "queue-action",
|
|
12
|
+
module: {},
|
|
13
|
+
} as any;
|
|
14
|
+
|
|
15
|
+
expect(await getUpcomingQueue(plugin)).toBeNull();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("calls setupQuickBrickQueue when QueueManager is not initialized", async () => {
|
|
19
|
+
const setupQuickBrickQueue = jest.fn();
|
|
20
|
+
const mockUpcoming = [{ id: "item_1" }];
|
|
21
|
+
|
|
22
|
+
const QueueManager = {
|
|
23
|
+
isInitialized: jest
|
|
24
|
+
.fn()
|
|
25
|
+
.mockReturnValueOnce(false)
|
|
26
|
+
.mockReturnValueOnce(true),
|
|
27
|
+
instance: {
|
|
28
|
+
getUpcomingQueue: jest.fn().mockResolvedValue(mockUpcoming),
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const plugin = {
|
|
33
|
+
identifier: "queue-action",
|
|
34
|
+
module: {
|
|
35
|
+
QueueManager,
|
|
36
|
+
setupQuickBrickQueue,
|
|
37
|
+
},
|
|
38
|
+
} as any;
|
|
39
|
+
|
|
40
|
+
const result = await getUpcomingQueue(plugin);
|
|
41
|
+
|
|
42
|
+
expect(setupQuickBrickQueue).toHaveBeenCalled();
|
|
43
|
+
expect(result).toEqual(mockUpcoming);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("returns upcoming items when QueueManager is already initialized", async () => {
|
|
47
|
+
const mockUpcoming = [{ id: "item_1" }, { id: "item_2" }];
|
|
48
|
+
|
|
49
|
+
const QueueManager = {
|
|
50
|
+
isInitialized: jest.fn().mockReturnValue(true),
|
|
51
|
+
instance: {
|
|
52
|
+
getUpcomingQueue: jest.fn().mockResolvedValue(mockUpcoming),
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const plugin = {
|
|
57
|
+
identifier: "queue-action",
|
|
58
|
+
module: {
|
|
59
|
+
QueueManager,
|
|
60
|
+
},
|
|
61
|
+
} as any;
|
|
62
|
+
|
|
63
|
+
const result = await getUpcomingQueue(plugin);
|
|
64
|
+
|
|
65
|
+
expect(result).toEqual(mockUpcoming);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { retrieveFeedUrl, retrievePlayPreviousFeedUrl } from "../utils";
|
|
2
2
|
|
|
3
|
+
// mock for import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
4
|
+
jest.mock("@applicaster/zapp-react-native-redux/AppStore", () => ({
|
|
5
|
+
appStore: {
|
|
6
|
+
get: jest.fn(() => []),
|
|
7
|
+
},
|
|
8
|
+
}));
|
|
9
|
+
|
|
3
10
|
const entryWith = (extensions: Record<string, unknown>): ZappEntry =>
|
|
4
11
|
({ id: "1", type: { value: "video" }, extensions }) as ZappEntry;
|
|
5
12
|
|
|
@@ -7,14 +14,14 @@ describe("playlist feed url accessors", () => {
|
|
|
7
14
|
it("returns the next feed url when present", async () => {
|
|
8
15
|
const entry = entryWith({ play_next_feed_url: "https://feeds/next.json" });
|
|
9
16
|
|
|
10
|
-
await expect(retrieveFeedUrl(entry
|
|
17
|
+
await expect(retrieveFeedUrl(entry)).resolves.toBe(
|
|
11
18
|
"https://feeds/next.json"
|
|
12
19
|
);
|
|
13
20
|
});
|
|
14
21
|
|
|
15
22
|
it("resolves to null for a missing entry", async () => {
|
|
16
23
|
await expect(
|
|
17
|
-
retrieveFeedUrl(undefined as unknown as ZappEntry
|
|
24
|
+
retrieveFeedUrl(undefined as unknown as ZappEntry)
|
|
18
25
|
).resolves.toBeNull();
|
|
19
26
|
});
|
|
20
27
|
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/** `queue-action` is not supported on this platform. See getUpcomingQueue.ts */
|
|
2
|
+
export const getUpcomingQueue = async (
|
|
3
|
+
_plugin?: QuickBrickPlugin | ZappPlugin
|
|
4
|
+
): Promise<unknown[] | null> => null;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/** `queue-action` is not supported on this platform. See getUpcomingQueue.ts */
|
|
2
|
+
export const getUpcomingQueue = async (
|
|
3
|
+
_plugin?: QuickBrickPlugin | ZappPlugin
|
|
4
|
+
): Promise<unknown[] | null> => null;
|
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
export const getUpcomingQueue = async (
|
|
2
|
-
|
|
1
|
+
export const getUpcomingQueue = async (
|
|
2
|
+
plugin?: QuickBrickPlugin | ZappPlugin
|
|
3
|
+
): Promise<unknown[] | null> => {
|
|
4
|
+
const module = (plugin as any)?.module;
|
|
5
|
+
const QueueManager = module?.QueueManager;
|
|
6
|
+
const setupQuickBrickQueue = module?.setupQuickBrickQueue;
|
|
7
|
+
|
|
8
|
+
if (!QueueManager) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (
|
|
13
|
+
!QueueManager.isInitialized?.() &&
|
|
14
|
+
typeof setupQuickBrickQueue === "function"
|
|
15
|
+
) {
|
|
16
|
+
setupQuickBrickQueue();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!QueueManager.isInitialized?.()) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
3
22
|
|
|
4
23
|
return QueueManager.instance.getUpcomingQueue();
|
|
5
24
|
};
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/** `queue-action` is not supported on this platform. See getUpcomingQueue.ts */
|
|
2
|
+
export const getUpcomingQueue = async (
|
|
3
|
+
_plugin?: QuickBrickPlugin | ZappPlugin
|
|
4
|
+
): Promise<unknown[] | null> => null;
|
|
@@ -59,18 +59,20 @@ export const parseTimeToSeconds = (timeStr: string): number => {
|
|
|
59
59
|
* on playerManager, decoupling Queue playback logic entirely from OverlaysObserver (which should
|
|
60
60
|
* strictly focus on recommendation visuals and chapter markers).
|
|
61
61
|
*/
|
|
62
|
-
export const retrieveFeedUrl = async (
|
|
63
|
-
entry: ZappEntry,
|
|
64
|
-
plugins?: ZappPlugin[]
|
|
65
|
-
): Promise<string> => {
|
|
62
|
+
export const retrieveFeedUrl = async (entry: ZappEntry): Promise<string> => {
|
|
66
63
|
if (!entry) return null;
|
|
67
64
|
|
|
68
|
-
const availablePlugins =
|
|
69
|
-
|
|
65
|
+
const availablePlugins = appStore.get("plugins");
|
|
66
|
+
|
|
67
|
+
const queuePlugin = findPluginByIdentifier(
|
|
68
|
+
"queue-action",
|
|
69
|
+
availablePlugins,
|
|
70
|
+
true
|
|
71
|
+
);
|
|
70
72
|
|
|
71
73
|
if (queuePlugin) {
|
|
72
74
|
try {
|
|
73
|
-
const upcomingQueue = await getUpcomingQueue();
|
|
75
|
+
const upcomingQueue = await getUpcomingQueue(queuePlugin);
|
|
74
76
|
|
|
75
77
|
if (upcomingQueue && upcomingQueue.length > 0) {
|
|
76
78
|
const queueItemId = entry?.extensions?.queueItemId || entry?.id;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Player } from "../player";
|
|
2
|
+
|
|
3
|
+
const entry = (id: string) => ({ id, title: id }) as unknown as ZappEntry;
|
|
4
|
+
|
|
5
|
+
const makePlayer = () => {
|
|
6
|
+
const player = new Player({ playerId: "test-player" });
|
|
7
|
+
player.entry = entry("first");
|
|
8
|
+
|
|
9
|
+
return player;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
describe("Player per-entry diagnostics", () => {
|
|
13
|
+
it("keeps the latest of onError and onVideoError, and clears it when a new entry loads", () => {
|
|
14
|
+
const player = makePlayer();
|
|
15
|
+
const second = { message: "second" };
|
|
16
|
+
|
|
17
|
+
player.onError({ message: "first" } as any);
|
|
18
|
+
player.onVideoError(second as any);
|
|
19
|
+
|
|
20
|
+
expect(player.lastError).toBe(second);
|
|
21
|
+
|
|
22
|
+
player.entry = entry("second");
|
|
23
|
+
|
|
24
|
+
expect(player.lastError).toBeNull();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("reads the next entry without creating the overlay observer", () => {
|
|
28
|
+
const player = makePlayer();
|
|
29
|
+
|
|
30
|
+
expect(player.getPlayNextEntry()).toBeNull();
|
|
31
|
+
|
|
32
|
+
jest
|
|
33
|
+
.spyOn(player.getOverlayObservable(), "getPlayNextEntry")
|
|
34
|
+
.mockReturnValue(entry("next"));
|
|
35
|
+
|
|
36
|
+
expect(player.getPlayNextEntry()).toEqual(entry("next"));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("keeps the content clock while a client-side ad plays", () => {
|
|
40
|
+
const player = makePlayer();
|
|
41
|
+
|
|
42
|
+
player.onVideoProgress({
|
|
43
|
+
currentTime: 300,
|
|
44
|
+
duration: 1800,
|
|
45
|
+
seekableDuration: 1800,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
player.onAdBegin({});
|
|
49
|
+
|
|
50
|
+
player.onVideoProgress({
|
|
51
|
+
currentTime: 5,
|
|
52
|
+
duration: 15,
|
|
53
|
+
seekableDuration: 15,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
expect(player.getPosition()).toBe(5);
|
|
57
|
+
expect(player.getDuration()).toBe(15);
|
|
58
|
+
expect(player.getContentPosition()).toBe(300);
|
|
59
|
+
expect(player.getContentDuration()).toBe(1800);
|
|
60
|
+
expect(player.getSeekableDuration()).toBe(1800);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { PlayerNative } from "../playerNative";
|
|
2
|
+
|
|
3
|
+
const playerWithEntry = (entry: any) =>
|
|
4
|
+
new PlayerNative({
|
|
5
|
+
entry,
|
|
6
|
+
player: null as any,
|
|
7
|
+
playerId: "test-player",
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
describe("PlayerNative.isAudioItem", () => {
|
|
11
|
+
it.each(["audio", "audio-player", "audio-detail", "audio-show", "audio-hub"])(
|
|
12
|
+
"treats the %s content type as audio",
|
|
13
|
+
(type) => {
|
|
14
|
+
expect(playerWithEntry({ type: { value: type } }).isAudioItem()).toBe(
|
|
15
|
+
true
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
it.each(["video", "video-detail", "comic-detail", "article-show"])(
|
|
21
|
+
"does not treat the %s content type as audio",
|
|
22
|
+
(type) => {
|
|
23
|
+
expect(playerWithEntry({ type: { value: type } }).isAudioItem()).toBe(
|
|
24
|
+
false
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
it("falls back to the media type when the content type says nothing", () => {
|
|
30
|
+
const entry = { content: { type: "audio/mpeg" }, type: { value: "link" } };
|
|
31
|
+
|
|
32
|
+
expect(playerWithEntry(entry).isAudioItem()).toBe(true);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("returns false when there is no entry", () => {
|
|
36
|
+
expect(playerWithEntry(null).isAudioItem()).toBe(false);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe("PlayerNative.command", () => {
|
|
41
|
+
it("invokes native function with playerId on iOS platform", () => {
|
|
42
|
+
const player = new PlayerNative({
|
|
43
|
+
entry: null,
|
|
44
|
+
player: { current: {} } as any,
|
|
45
|
+
playerId: "test-player",
|
|
46
|
+
playerPluginId: "QuickBrickPlayerPlugin",
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const commandSpy = jest.fn();
|
|
50
|
+
|
|
51
|
+
jest.spyOn(player, "getPlayerModule").mockReturnValue({
|
|
52
|
+
command: commandSpy,
|
|
53
|
+
} as any);
|
|
54
|
+
|
|
55
|
+
player.command("setPlayerControls", { transport: ["play"] });
|
|
56
|
+
|
|
57
|
+
expect(commandSpy).toHaveBeenCalledWith(
|
|
58
|
+
"setPlayerControls",
|
|
59
|
+
"test-player",
|
|
60
|
+
{
|
|
61
|
+
transport: ["play"],
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("invokes native function with view tag on Android when method exists", () => {
|
|
67
|
+
const reactUtils = require("../../../reactUtils");
|
|
68
|
+
jest.spyOn(reactUtils, "isApplePlatform").mockReturnValue(false);
|
|
69
|
+
|
|
70
|
+
const player = new PlayerNative({
|
|
71
|
+
entry: null,
|
|
72
|
+
player: { current: {} } as any,
|
|
73
|
+
playerId: "test-player",
|
|
74
|
+
playerPluginId: "QuickBrickPlayerPlugin",
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const commandSpy = jest.fn();
|
|
78
|
+
|
|
79
|
+
jest.spyOn(player, "getPlayerModule").mockReturnValue({
|
|
80
|
+
command: commandSpy,
|
|
81
|
+
} as any);
|
|
82
|
+
|
|
83
|
+
jest.spyOn(player, "getComponentNode").mockReturnValue(12345 as any);
|
|
84
|
+
|
|
85
|
+
player.command("setPlayerControls", { transport: ["play"] });
|
|
86
|
+
|
|
87
|
+
expect(commandSpy).toHaveBeenCalledWith(12345, "setPlayerControls", {
|
|
88
|
+
transport: ["play"],
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
(reactUtils.isApplePlatform as jest.Mock).mockRestore();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("handles when native module does not have command method on Android", () => {
|
|
95
|
+
const reactUtils = require("../../../reactUtils");
|
|
96
|
+
jest.spyOn(reactUtils, "isApplePlatform").mockReturnValue(false);
|
|
97
|
+
|
|
98
|
+
const player = new PlayerNative({
|
|
99
|
+
entry: null,
|
|
100
|
+
player: { current: {} } as any,
|
|
101
|
+
playerId: "test-player",
|
|
102
|
+
playerPluginId: "KalturaPlayerPlugin",
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
jest.spyOn(player, "getPlayerModule").mockReturnValue({} as any);
|
|
106
|
+
jest.spyOn(player, "getComponentNode").mockReturnValue(12345 as any);
|
|
107
|
+
|
|
108
|
+
expect(() => {
|
|
109
|
+
player.command("setPlayerControls", { transport: ["play"] });
|
|
110
|
+
}).not.toThrow();
|
|
111
|
+
|
|
112
|
+
(reactUtils.isApplePlatform as jest.Mock).mockRestore();
|
|
113
|
+
});
|
|
114
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { NativeModules } from "react-native";
|
|
2
|
+
import {
|
|
3
|
+
PlayerNativeCommandTypes,
|
|
4
|
+
PlayerNativeSendCommand,
|
|
5
|
+
} from "../playerNativeCommand";
|
|
6
|
+
|
|
7
|
+
describe("PlayerNativeSendCommand", () => {
|
|
8
|
+
const reactUtils = require("../../../reactUtils");
|
|
9
|
+
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
jest.restoreAllMocks();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("calls NativeModules.PlayerModule.command on Apple platform with playerId", () => {
|
|
15
|
+
jest.spyOn(reactUtils, "isApplePlatform").mockReturnValue(true);
|
|
16
|
+
|
|
17
|
+
NativeModules.PlayerModule = {
|
|
18
|
+
command: jest.fn(),
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
PlayerNativeSendCommand(
|
|
22
|
+
PlayerNativeCommandTypes.setPlayerControls,
|
|
23
|
+
"player-123",
|
|
24
|
+
{ transport: ["play"] }
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
expect(NativeModules.PlayerModule.command).toHaveBeenCalledWith(
|
|
28
|
+
"setPlayerControls",
|
|
29
|
+
"player-123",
|
|
30
|
+
{ transport: ["play"] }
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("does not call NativeModules.PlayerModule.command on non-Apple platform", () => {
|
|
35
|
+
jest.spyOn(reactUtils, "isApplePlatform").mockReturnValue(false);
|
|
36
|
+
|
|
37
|
+
NativeModules.PlayerModule = {
|
|
38
|
+
command: jest.fn(),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
PlayerNativeSendCommand(
|
|
42
|
+
PlayerNativeCommandTypes.setPlayerControls,
|
|
43
|
+
"player-123",
|
|
44
|
+
{ transport: ["play"] }
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
expect(NativeModules.PlayerModule.command).not.toHaveBeenCalled();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("does nothing when playerId or command is missing", () => {
|
|
51
|
+
jest.spyOn(reactUtils, "isApplePlatform").mockReturnValue(true);
|
|
52
|
+
|
|
53
|
+
NativeModules.PlayerModule = {
|
|
54
|
+
command: jest.fn(),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
PlayerNativeSendCommand("", "player-123");
|
|
58
|
+
PlayerNativeSendCommand("setPlayerControls", "");
|
|
59
|
+
|
|
60
|
+
expect(NativeModules.PlayerModule.command).not.toHaveBeenCalled();
|
|
61
|
+
});
|
|
62
|
+
});
|