@playpilot/tpi 8.29.3 → 8.29.5
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/dist/editorial.mount.js +8 -8
- package/dist/link-injections.js +1 -1
- package/dist/mount.js +5 -5
- package/package.json +1 -1
- package/src/lib/api/ads.ts +1 -0
- package/src/lib/injection.ts +3 -2
- package/src/routes/components/Explore/Routes/ExploreModal.svelte +111 -106
- package/src/tests/lib/api/ads.test.js +8 -0
package/package.json
CHANGED
package/src/lib/api/ads.ts
CHANGED
package/src/lib/injection.ts
CHANGED
|
@@ -356,13 +356,14 @@ function addLinkInjectionEventListeners(injections: LinkInjection[]): void {
|
|
|
356
356
|
export function clearLinkInjections(): void {
|
|
357
357
|
const elements = document.querySelectorAll(keySelector)
|
|
358
358
|
|
|
359
|
-
if (!elements.length) return
|
|
360
|
-
|
|
361
359
|
elements.forEach((element) => clearLinkInjection(element.getAttribute(keyDataAttribute) || ''))
|
|
362
360
|
|
|
363
361
|
clearAfterArticlePlaylinks()
|
|
364
362
|
clearInTextDisclaimer()
|
|
365
363
|
clearInTextWidgets()
|
|
364
|
+
|
|
365
|
+
if (!elements.length) return
|
|
366
|
+
|
|
366
367
|
destroyAllModals(false)
|
|
367
368
|
destroyLinkPopover(false)
|
|
368
369
|
}
|
|
@@ -1,106 +1,111 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
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
|
-
data
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { fetchAds } from '$lib/api/ads'
|
|
3
|
+
import { fetchParticipantBySid } from '$lib/api/participants'
|
|
4
|
+
import { fetchSimilarTitles, fetchTitleBySid } from '$lib/api/titles'
|
|
5
|
+
import { mobileBreakpoint } from '$lib/constants'
|
|
6
|
+
import { SplitTest } from '$lib/enums/SplitTest'
|
|
7
|
+
import { t } from '$lib/localization'
|
|
8
|
+
import { openModal, type ModalType } from '$lib/modal'
|
|
9
|
+
import { getSplitTestVariantName, trackSplitTestView } from '$lib/splitTest'
|
|
10
|
+
import type { Campaign } from '$lib/types/campaign'
|
|
11
|
+
import type { TitleData } from '$lib/types/title'
|
|
12
|
+
import Modal from '../../Modals/Modal.svelte'
|
|
13
|
+
|
|
14
|
+
interface Props {
|
|
15
|
+
navigate?: (key: string, pushState?: boolean) => void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { navigate = () => null }: Props = $props()
|
|
19
|
+
|
|
20
|
+
async function openModalViaRoute(): Promise<void> {
|
|
21
|
+
const currentUrl = new URL(document.location.toString())
|
|
22
|
+
const sid = currentUrl.searchParams.get('sid')
|
|
23
|
+
|
|
24
|
+
if (!sid) return
|
|
25
|
+
|
|
26
|
+
let type: ModalType = sid.startsWith('pr') ? 'participant' : 'title' // Sids with with `pr` for participants, `ti` for titles
|
|
27
|
+
let data: any = null
|
|
28
|
+
|
|
29
|
+
if (type === 'title') {
|
|
30
|
+
const isMobile = window.innerWidth < mobileBreakpoint
|
|
31
|
+
const isInReelSplitTest = isMobile && getSplitTestVariantName(SplitTest.Reels) === 'Reel'
|
|
32
|
+
|
|
33
|
+
if (isMobile) trackSplitTestView(SplitTest.Reels)
|
|
34
|
+
|
|
35
|
+
type = isMobile && isInReelSplitTest ? 'titles-reel' : 'titles-rail'
|
|
36
|
+
|
|
37
|
+
const [ads, title, railTitles] = (await Promise.allSettled([fetchAds(), fetchTitleBySid(sid), fetchSimilarTitles({ sid } as unknown as TitleData)])).map((promise) =>
|
|
38
|
+
promise.status === 'fulfilled' ? promise.value : null,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
window.PlayPilotLinkInjections.ads = ads as Campaign[]
|
|
42
|
+
data = [title as TitleData, ...(railTitles as TitleData[])]
|
|
43
|
+
} else if (type === 'participant') {
|
|
44
|
+
data = await fetchParticipantBySid(sid)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
openModal({
|
|
48
|
+
type,
|
|
49
|
+
data,
|
|
50
|
+
props: {
|
|
51
|
+
onclose: () => navigate('home'),
|
|
52
|
+
pushState: false,
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
{#await openModalViaRoute()}
|
|
59
|
+
<Modal blur pushState={false}>
|
|
60
|
+
{#snippet dialog()}
|
|
61
|
+
<div class="loading">
|
|
62
|
+
<div class="bar"></div>
|
|
63
|
+
<div class="bar"></div>
|
|
64
|
+
<div class="bar"></div>
|
|
65
|
+
</div>
|
|
66
|
+
{/snippet}
|
|
67
|
+
</Modal>
|
|
68
|
+
{:catch}
|
|
69
|
+
<Modal blur onclose={() => navigate('home')} pushState={false}>
|
|
70
|
+
<div class="error">
|
|
71
|
+
{t('An Error Occurred')}
|
|
72
|
+
</div>
|
|
73
|
+
</Modal>
|
|
74
|
+
{/await}
|
|
75
|
+
|
|
76
|
+
<style lang="scss">
|
|
77
|
+
.loading {
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
height: 100%;
|
|
82
|
+
gap: margin(0.5);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@keyframes animate-bar {
|
|
86
|
+
to {
|
|
87
|
+
height: margin(3);
|
|
88
|
+
opacity: 0.5;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.bar {
|
|
93
|
+
height: margin(4);
|
|
94
|
+
width: margin(1);
|
|
95
|
+
border-radius: margin(0.25);
|
|
96
|
+
background: white;
|
|
97
|
+
animation: animate-bar 750ms infinite;
|
|
98
|
+
|
|
99
|
+
@for $i from 0 through 2 {
|
|
100
|
+
&:nth-child(#{$i}) {
|
|
101
|
+
animation-delay: $i * 250ms;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.error {
|
|
107
|
+
padding: margin(2);
|
|
108
|
+
font-size: 1.25em;
|
|
109
|
+
color: theme(text-color);
|
|
110
|
+
}
|
|
111
|
+
</style>
|
|
@@ -58,6 +58,14 @@ describe('$lib/api/ads', () => {
|
|
|
58
58
|
expect(api).not.toHaveBeenCalled()
|
|
59
59
|
})
|
|
60
60
|
|
|
61
|
+
it('Should not call api if no_affiliate is true', async () => {
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
window.PlayPilotLinkInjections = { no_affiliate: true }
|
|
64
|
+
|
|
65
|
+
await fetchAds()
|
|
66
|
+
expect(api).not.toHaveBeenCalled()
|
|
67
|
+
})
|
|
68
|
+
|
|
61
69
|
it('Should fire track event when ads failed to fetch', async () => {
|
|
62
70
|
vi.mocked(api).mockRejectedValueOnce({ ok: false, status: 505 })
|
|
63
71
|
|