@playpilot/tpi 8.40.0 → 8.41.0-beta.1

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.
@@ -139,5 +139,4 @@ export type ConfigResponse = {
139
139
  explore_navigation_insert_position?: InsertPosition
140
140
  explore_insert_cta_in_tpi?: boolean
141
141
  explore_custom_style?: string
142
- explore_use_router?: boolean
143
142
  }
@@ -6,18 +6,23 @@
6
6
  import { onDestroy } from 'svelte'
7
7
  import Tooltip from '../Tooltip.svelte'
8
8
  import Disclaimer from './Disclaimer.svelte'
9
+ import { getSplitTestVariantName } from '$lib/splitTest'
10
+ import { SplitTest } from '$lib/enums/SplitTest'
9
11
 
10
12
  interface Props {
11
13
  campaign: Campaign
12
14
  compact?: boolean
15
+ slim?: boolean
13
16
  }
14
17
 
15
- const { campaign, compact = false }: Props = $props()
18
+ const { campaign, compact = false, slim = false }: Props = $props()
16
19
 
17
20
  const { disclaimer, content, cta, campaign_type } = $derived(campaign)
18
21
  const { header, subheader, header_logo: logo, image, video } = $derived(content)
19
22
  const { header: buttonLabel, url: href, subheader: info } = $derived(cta)
20
23
 
24
+ const tall = slim && getSplitTestVariantName(SplitTest.DisplayAdFormat) === 'Tall'
25
+
21
26
  let contentHeight = $state(0)
22
27
  let videoElement: HTMLVideoElement | null = $state(null)
23
28
 
@@ -34,8 +39,8 @@
34
39
  })
35
40
  </script>
36
41
 
37
- <a {href} target="_blank" class="display" class:compact rel="sponsored" {onclick} use:middlemouse={{ onclick }}>
38
- {#if info}
42
+ <a {href} target="_blank" class="display" class:compact class:slim class:tall rel="sponsored" {onclick} use:middlemouse={{ onclick }}>
43
+ {#if info && !slim}
39
44
  <div class="info">
40
45
  {#if compact}
41
46
  <Tooltip>
@@ -62,7 +67,7 @@
62
67
  <span class="name">{header}</span>
63
68
  {/if}
64
69
 
65
- {#if subheader}
70
+ {#if subheader && !slim}
66
71
  <div class="subheader">{subheader}</div>
67
72
  {/if}
68
73
  </div>
@@ -90,6 +95,8 @@
90
95
  </a>
91
96
 
92
97
  <style lang="scss">
98
+ $background-color: rgb(110, 110, 110);
99
+
93
100
  .display {
94
101
  display: block;
95
102
  position: relative;
@@ -102,6 +109,16 @@
102
109
  font-family: theme(detail-font-family, font-family);
103
110
  line-height: 1.2;
104
111
  font-style: normal !important;
112
+
113
+ &.slim {
114
+ aspect-ratio: unset;
115
+ height: margin(5.5);
116
+ background: $background-color;
117
+
118
+ &.tall {
119
+ height: margin(8);
120
+ }
121
+ }
105
122
  }
106
123
 
107
124
  .info {
@@ -131,7 +148,7 @@
131
148
  bottom: 0;
132
149
  left: 0;
133
150
  padding: margin(0.5);
134
- background: linear-gradient(to right, rgba(110, 110, 110, 1), rgba(85, 85, 85, 0.3));
151
+ background: linear-gradient(to right, $background-color, rgba(85, 85, 85, 0.3));
135
152
  font-size: margin(0.875);
136
153
  text-decoration: none;
137
154
 
@@ -142,10 +159,25 @@
142
159
  padding: margin(0.75);
143
160
  }
144
161
  }
162
+
163
+ .slim & {
164
+ background: transparent;
165
+ padding-left: margin(10.5);
166
+ height: 100%;
167
+ font-size: theme(font-size-small);
168
+ }
145
169
  }
146
170
 
147
171
  .logo {
148
172
  border-radius: theme(display-ad-border-radius, border-radius);
173
+
174
+ .slim & {
175
+ position: absolute;
176
+ width: margin(1.5);
177
+ height: margin(1.5);
178
+ bottom: margin(0.5);
179
+ left: margin(0.5);
180
+ }
149
181
  }
150
182
 
151
183
  .name {
@@ -176,11 +208,26 @@
176
208
  display: block;
177
209
  width: 100%;
178
210
  height: auto;
211
+
212
+ .slim & {
213
+ width: auto;
214
+ height: 100%;
215
+ aspect-ratio: 16 / 9;
216
+ background: black;
217
+ }
218
+
219
+ .tall & {
220
+ mask-image: linear-gradient(to right, white 50%, transparent);
221
+ }
179
222
  }
180
223
 
181
224
  .disclaimer {
182
225
  position: absolute;
183
226
  bottom: calc(var(--offset) + margin(0.25));
184
227
  right: margin(0.25);
228
+
229
+ .slim & {
230
+ bottom: margin(0.25);
231
+ }
185
232
  }
186
233
  </style>
@@ -3,7 +3,7 @@
3
3
  import { fetchLinkInjections } from '$lib/api/externalPages'
4
4
  import { Language } from '$lib/enums/Language'
5
5
  import { SplitTest } from '$lib/enums/SplitTest'
6
- import { destroyExplore, insertExplore, useExploreRouter } from '$lib/explore'
6
+ import { destroyExplore, insertExplore } from '$lib/explore'
7
7
  import { getPageTextAndElements } from '$lib/injectionElements'
8
8
  import { getLanguage } from '$lib/language'
9
9
  import { getFullUrlPath } from '$lib/url'
@@ -217,14 +217,6 @@
217
217
  <button onclick={replaceWithBetaScript}>Use beta script</button>
218
218
  {/if}
219
219
 
220
- {#if !useExploreRouter()}
221
- <button onclick={(() => {
222
- destroyExplore()
223
- window.PlayPilotLinkInjections.config!.explore_use_router = !useExploreRouter()
224
- insertExplore()
225
- })}>Toggle new explore</button>
226
- {/if}
227
-
228
220
  <hr />
229
221
 
230
222
  <div>
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { ExploreFilter } from '$lib/types/filter'
3
3
  import { heading } from '$lib/actions/heading'
4
- import { exploreParentSelector, useExploreRouter } from '$lib/explore'
4
+ import { exploreParentSelector } from '$lib/explore'
5
5
  import { t } from '$lib/localization'
6
6
  import { track } from '$lib/tracking'
7
7
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
@@ -57,28 +57,20 @@
57
57
  <!-- eslint-disable-next-line svelte/no-at-html-tags -->
58
58
  {@html t('Streaming Guide Disclaimer')}
59
59
  </p>
60
-
61
- {#if !useExploreRouter()}
62
- <p class="description">
63
- {t('Streaming Guide Description')}
64
- </p>
65
- {/if}
66
60
  </div>
67
61
  </div>
68
62
 
69
63
  <Search oninput={(query) => searchQuery = query} />
70
64
 
71
- {#if useExploreRouter()}
72
- <div class="filter">
73
- <Filter
74
- {filter}
75
- {searchQuery}
76
- limit={clientWidth < 500}
77
- showSorting={!searchQuery}
78
- onchange={() => navigate('results')}
79
- onempty={() => navigate('home')} />
80
- </div>
81
- {/if}
65
+ <div class="filter">
66
+ <Filter
67
+ {filter}
68
+ {searchQuery}
69
+ limit={clientWidth < 500}
70
+ showSorting={!searchQuery}
71
+ onchange={() => navigate('results')}
72
+ onempty={() => navigate('home')} />
73
+ </div>
82
74
 
83
75
  {#await isUserRegionSupported() then isSupported}
84
76
  {#if !isSupported}
@@ -161,14 +153,6 @@
161
153
  }
162
154
  }
163
155
 
164
- .description {
165
- max-width: theme(explore-header-max-width, 600px);
166
- margin: 0;
167
- color: theme(text-color-alt);
168
- font-size: theme(font-size-base);
169
- line-height: 1.35;
170
- }
171
-
172
156
  .filter {
173
157
  display: flex;
174
158
  flex-direction: column;
@@ -1,7 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { ExploreRoute } from '$lib/types/explore'
3
3
  import type { ExploreFilter } from '$lib/types/filter'
4
- import { useExploreRouter } from '$lib/explore'
5
4
  import { track } from '$lib/tracking'
6
5
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
7
6
  import ExploreHome from './Routes/ExploreHome.svelte'
@@ -11,29 +10,24 @@
11
10
  import ExploreModal from './Routes/ExploreModal.svelte'
12
11
 
13
12
  const routes: ExploreRoute[] = [
13
+ {
14
+ key: 'home',
15
+ component: ExploreHome,
16
+ },
14
17
  {
15
18
  key: 'results',
16
19
  component: ExploreResults,
17
20
  },
18
- ]
19
-
20
- if (useExploreRouter()) {
21
- routes.unshift({
22
- key: 'home',
23
- component: ExploreHome,
24
- })
25
-
26
- routes.push({
21
+ {
27
22
  key: 'title',
28
23
  component: ExploreTitle,
29
- })
30
-
31
- routes.push({
24
+ },
25
+ {
32
26
  key: 'modal',
33
27
  component: ExploreHome,
34
28
  appendComponent: ExploreModal,
35
- })
36
- }
29
+ }
30
+ ]
37
31
 
38
32
  const initialRouteKey = getCurrentRouteParam() || routes[0].key
39
33
 
@@ -32,7 +32,7 @@
32
32
  }
33
33
  </script>
34
34
 
35
- <svelte:window {onscroll} bind:innerWidth={windowWidth} />
35
+ <svelte:window bind:innerWidth={windowWidth} />
36
36
 
37
37
  <div data-testid="explore-home"></div>
38
38
 
@@ -9,6 +9,8 @@
9
9
  import IconArrow from '../Icons/IconArrow.svelte'
10
10
  import ModalCloseOverlay from './ModalCloseOverlay.svelte'
11
11
  import Display from '../Ads/Display.svelte'
12
+ import { SplitTest } from '$lib/enums/SplitTest'
13
+ import { getSplitTestVariantName, trackSplitTestView } from '$lib/splitTest'
12
14
 
13
15
  interface Props {
14
16
  items: Record<string, any>[]
@@ -27,6 +29,8 @@
27
29
  let element: HTMLElement | null = $state(null)
28
30
  let displayAd = $state(getFirstAdOfType('card'))
29
31
 
32
+ if (!!displayAd) trackSplitTestView(SplitTest.DisplayAdFormat)
33
+
30
34
  onMount(() => {
31
35
  setAvailableHeight()
32
36
 
@@ -60,9 +64,9 @@
60
64
  <svelte:window onresize={setAvailableHeight} onupdateads={() => displayAd = getFirstAdOfType('card')} />
61
65
 
62
66
  {#snippet prepend()}
63
- {#if displayAd}
67
+ {#if displayAd && getSplitTestVariantName(SplitTest.DisplayAdFormat) !== 'Inline'}
64
68
  <div class="ad">
65
- <Display campaign={displayAd} />
69
+ <Display campaign={displayAd} slim />
66
70
  </div>
67
71
  {/if}
68
72
  {/snippet}
@@ -1,5 +1,7 @@
1
1
  <script lang="ts">
2
+ import { SplitTest } from '$lib/enums/SplitTest'
2
3
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
4
+ import { getSplitTestVariantName } from '$lib/splitTest'
3
5
  import { track } from '$lib/tracking'
4
6
  import type { TitleData } from '$lib/types/title'
5
7
  import Title from '../Title.svelte'
@@ -16,6 +18,6 @@
16
18
 
17
19
  <RailModal items={titles} {initialIndex} {onclose} onchange={(index) => track(TrackingEvent.ExploreTitleRailSetIndex, titles[index], { index })} {...restProps}>
18
20
  {#snippet each(title, currentIndex)}
19
- <Title {title} useVideoBackground={title.sid === titles[currentIndex]?.sid} />
21
+ <Title {title} useVideoBackground={title.sid === titles[currentIndex]?.sid} useDisplayAdSplitTest={getSplitTestVariantName(SplitTest.DisplayAdFormat) === 'Inline'} />
20
22
  {/snippet}
21
23
  </RailModal>
@@ -7,11 +7,14 @@
7
7
  import type { TitleData } from '$lib/types/title'
8
8
  import { heading } from '$lib/actions/heading'
9
9
  import { campaignToPlaylink, getFirstAdOfType } from '$lib/api/ads'
10
- import { getContext } from 'svelte'
10
+ import { getContext, type Snippet } from 'svelte'
11
11
  import Playlink from './Playlink.svelte'
12
12
  import Button from '../Button.svelte'
13
13
  import PlaylinksDisclaimer from './PlaylinksDisclaimer.svelte'
14
14
  import { getConfigValue } from '$lib/api/config'
15
+ import { getSplitTestVariantName } from '$lib/splitTest'
16
+ import { SplitTest } from '$lib/enums/SplitTest'
17
+ import Display from '../Ads/Display.svelte'
15
18
 
16
19
  type Category = PlaylinkCategory | '' | 'Other'
17
20
  type CategorizedPlaylinks = Partial<Record<Category, PlaylinkData[]>>
@@ -21,9 +24,10 @@
21
24
  playlinks: PlaylinkData[]
22
25
  title: TitleData
23
26
  limit?: number
27
+ children?: Snippet
24
28
  }
25
29
 
26
- const { playlinks, title, limit = 3 }: Props = $props()
30
+ const { playlinks, title, limit = 3, children }: Props = $props()
27
31
 
28
32
  const isModal = getContext('scope') === 'modal'
29
33
  const type = getContext('type')
@@ -94,7 +98,11 @@
94
98
 
95
99
  <!-- A fake highlighted playlink as part of the display ad, to be shown after the first playlink -->
96
100
  {#if displayAd && (index === 0)}
97
- <Playlink playlink={campaignToPlaylink(displayAd)} onclick={() => track(TrackingEvent.DisplayedAdPlaylickClick, title, { campaign_name: displayAd.campaign_name })} hideCategory disclaimer={displayAd.disclaimer || ''} />
101
+ {#if children}
102
+ {@render children()}
103
+ {:else}
104
+ <Playlink playlink={campaignToPlaylink(displayAd)} onclick={() => track(TrackingEvent.DisplayedAdPlaylickClick, title, { campaign_name: displayAd.campaign_name })} hideCategory disclaimer={displayAd.disclaimer || ''} />
105
+ {/if}
98
106
  {/if}
99
107
  {/each}
100
108
  </div>
@@ -8,7 +8,6 @@
8
8
  import { exploreModalUrl } from '$lib/routes'
9
9
  import { generateRandomHash } from '$lib/hash'
10
10
  import { getFirstTitleWithAvailableTrailer } from '$lib/trailer'
11
- import { useExploreRouter } from '$lib/explore'
12
11
  import { getContext, onMount } from 'svelte'
13
12
  import type TinySlider from 'svelte-tiny-slider'
14
13
 
@@ -92,11 +91,7 @@
92
91
  return
93
92
  }
94
93
 
95
- if (useExploreRouter()) {
96
- openModal({ event, type: 'titles-rail', data: titles as TitleData[], returnToTitle, props: { initialIndex: index } })
97
- } else {
98
- openModal({ event, data: title, returnToTitle })
99
- }
94
+ openModal({ event, type: 'titles-rail', data: titles as TitleData[], returnToTitle, props: { initialIndex: index } })
100
95
  }
101
96
 
102
97
  async function expandFirstAvailableTrailer(): Promise<void> {
@@ -14,14 +14,18 @@
14
14
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
15
15
  import TitleBackground from './TitleBackground.svelte'
16
16
  import TitleInfo from './TitleInfo.svelte'
17
+ import Display from './Ads/Display.svelte'
18
+ import type { Campaign } from '$lib/types/campaign'
19
+ import { getFirstAdOfType } from '$lib/api/ads'
17
20
 
18
21
  interface Props {
19
22
  title: TitleData
20
23
  small?: boolean
21
24
  useVideoBackground?: boolean
25
+ useDisplayAdSplitTest?: boolean // NOTE: Temporary split test, remove me after the DisplayAdFormat split test is gone
22
26
  }
23
27
 
24
- const { title, small = false, useVideoBackground = true }: Props = $props()
28
+ const { title, small = false, useVideoBackground = true, useDisplayAdSplitTest = false }: Props = $props()
25
29
 
26
30
  const noAffiliate = !!window.PlayPilotLinkInjections?.no_affiliate
27
31
 
@@ -58,7 +62,11 @@
58
62
  {/if}
59
63
 
60
64
  {#if !noAffiliate}
61
- <Playlinks playlinks={title.providers} {title} />
65
+ <Playlinks playlinks={title.providers} {title}>
66
+ {#if useDisplayAdSplitTest && getFirstAdOfType('card')}
67
+ <Display campaign={getFirstAdOfType('card')!} />
68
+ {/if}
69
+ </Playlinks>
62
70
  {/if}
63
71
 
64
72
  <ParticipantsRail {title} />
@@ -39,10 +39,21 @@
39
39
 
40
40
  // Used to re-render some elements with a key
41
41
  let renderKey = Math.random()
42
+
43
+ function insertMockAd(): void {
44
+ // @ts-ignore
45
+ window.PlayPilotLinkInjections.consents = {
46
+ ads: true
47
+ }
48
+
49
+ window.PlayPilotLinkInjections.ads = [campaign]
50
+ }
42
51
  </script>
43
52
 
44
53
  <h1>Elements</h1>
45
54
 
55
+ <button onclick={insertMockAd}>Insert mock ad</button>
56
+
46
57
  <p>This page lays out various elements used in TPI. It does not currently include editor elements.</p>
47
58
 
48
59
  <h2>Youtube Embed</h2>
@@ -173,7 +184,15 @@
173
184
  <div class="group">
174
185
  <div>
175
186
  <h3>Ads/Display.svelte</h3>
176
- <div class="item"><Display {campaign} /></div>
187
+ <div class="item">
188
+ <Display {campaign} />
189
+
190
+ Compact (Used in popover)
191
+ <Display {campaign} compact />
192
+
193
+ Slim (Used in rail modals)
194
+ <Display {campaign} slim />
195
+ </div>
177
196
  </div>
178
197
 
179
198
  <div>
@@ -6,9 +6,8 @@
6
6
  */
7
7
 
8
8
  import { browser } from '$app/environment'
9
- import { destroyExplore, insertExplore, insertExploreIntoNavigation, useExploreRouter } from '$lib/explore'
9
+ import { insertExplore, insertExploreIntoNavigation } from '$lib/explore'
10
10
  import Debugger from '../components/Debugger.svelte'
11
-
12
11
  if (browser) {
13
12
  // @ts-ignore
14
13
  window.PlayPilotLinkInjections = {
@@ -18,7 +17,6 @@
18
17
  explore_navigation_label: 'Streaming guide (inserted)',
19
18
  explore_navigation_path: '/explore',
20
19
  explore_custom_style: 'main { border: 2px solid white }',
21
- explore_use_router: true,
22
20
  open_tpi_links_in_explore: true,
23
21
  },
24
22
  require_consent: false,
@@ -34,11 +32,7 @@
34
32
  <title>PlayPilot Link Injections - Explore</title>
35
33
  </svelte:head>
36
34
 
37
- <button onclick={(() => {
38
- destroyExplore()
39
- window.PlayPilotLinkInjections.config!.explore_use_router = !useExploreRouter()
40
- insertExplore()
41
- })}>Toggle new explore</button>
35
+
42
36
 
43
37
  <main>
44
38
  <!--
@@ -72,6 +72,14 @@ describe('$lib/api/ads', () => {
72
72
  await expect(async () => await fetchAds()).rejects.toThrowError()
73
73
  expect(track).toHaveBeenCalledWith(TrackingEvent.AdsFetchFailed, null, { status: 505 })
74
74
  })
75
+
76
+ it('Should include set region', async () => {
77
+ window.PlayPilotLinkInjections.region = 'uk'
78
+
79
+ await fetchAds()
80
+
81
+ expect(api).toHaveBeenCalledWith(expect.stringContaining('&region=uk'))
82
+ })
75
83
  })
76
84
 
77
85
  describe('getFirstAdOfType', () => {