summaryrefslogtreecommitdiff
path: root/node_modules/@jet-app/app-store/tmp/src/common/grouping/hero/hero-common.js
blob: 4a67b72cb549a0532accaaeaeb5a0833ca3a82cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
//  hero-carousel-overlay-common.ts
//  AppStoreKit
//
//  Created by Jonathan Ellenbogen on 12/11/20.
//  Copyright (c) 2016 Apple Inc. All rights reserved.
//
import * as models from "../../../api/models";
import * as serverData from "../../../foundation/json-parsing/server-data";
import { artworkDictionaryFromData, videoDictionaryFromData } from "../../arcade/breakouts-common";
import * as content from "../../content/content";
export function heroArtworkFromData(objectGraph, data, presentedInTopShelf = false) {
    const artworkDictionary = artworkDictionaryFromData(objectGraph, data);
    const isPhone = objectGraph.client.isPhone;
    const isTV = objectGraph.client.isTV;
    let heroArtworkKey = isPhone ? "breakoutTall" : "breakoutFullScreen";
    if (presentedInTopShelf) {
        heroArtworkKey = "topShelf";
    }
    const heroArtworkData = serverData.asDictionary(artworkDictionary, heroArtworkKey);
    let heroArtwork = null;
    let backgroundColor = null;
    if (serverData.isDefinedNonNullNonEmpty(heroArtworkData)) {
        heroArtwork = content.artworkFromApiArtwork(objectGraph, heroArtworkData, {
            withJoeColorPlaceholder: true,
            useCase: 6 /* content.ArtworkUseCase.ArcadeLargeBreakout */,
        });
        if (serverData.isDefinedNonNullNonEmpty(heroArtwork)) {
            if (isPhone) {
                heroArtwork.crop = "oa";
            }
            else if (presentedInTopShelf) {
                heroArtwork.crop = "ta";
            }
            else if (isTV) {
                heroArtwork.crop = "od";
            }
            else {
                heroArtwork.crop = "ob";
            }
            backgroundColor = heroArtwork.backgroundColor;
        }
    }
    return {
        artwork: heroArtwork,
        artworkData: heroArtworkData,
        backgroundColor: backgroundColor,
    };
}
export function heroVideoFromData(objectGraph, data, isUpsell = false, wants9x16 = false) {
    const videoDictionary = videoDictionaryFromData(objectGraph, data);
    const use9x16 = objectGraph.client.isPhone || wants9x16;
    const heroVideoKey = use9x16 ? "sizzleVideo9x16" : "sizzleVideo16x9";
    const heroVideoFallbackKey = use9x16 ? "breakoutVideo9x16" : "breakoutVideo16x9";
    const heroVideoData = serverData.asDictionary(videoDictionary, heroVideoKey) ||
        serverData.asDictionary(videoDictionary, heroVideoFallbackKey);
    let heroVideo = null;
    let backgroundColor = null;
    let artworkData = null;
    if (serverData.isDefinedNonNullNonEmpty(heroVideoData)) {
        artworkData = serverData.asDictionary(heroVideoData, "previewFrame");
        const artwork = content.artworkFromApiArtwork(objectGraph, artworkData, {
            withJoeColorPlaceholder: true,
            useCase: 6 /* content.ArtworkUseCase.ArcadeLargeBreakout */,
        });
        if (serverData.isDefinedNonNullNonEmpty(artwork)) {
            artwork.crop = "sr";
            backgroundColor = artwork.backgroundColor;
        }
        // Get the video URL
        const videoUrl = serverData.asString(heroVideoData, "video");
        if (serverData.isDefinedNonNullNonEmpty(artwork) && (videoUrl === null || videoUrl === void 0 ? void 0 : videoUrl.length) > 0) {
            heroVideo = new models.Video(videoUrl, artwork, {
                canPlayFullScreen: false,
                allowsAutoPlay: true,
                looping: true,
                playbackControls: {
                    prominentPlay: isUpsell,
                },
                autoPlayPlaybackControls: {},
            });
        }
    }
    return {
        video: heroVideo,
        artworkData: artworkData,
        backgroundColor: backgroundColor,
    };
}
//# sourceMappingURL=hero-common.js.map