@playpilot/tpi 8.27.1 → 8.28.0
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/.prettierrc +3 -2
- package/dist/editorial.mount.js +8 -8
- package/dist/link-injections.js +2 -2
- package/dist/mount.js +7 -7
- package/eslint.config.js +0 -1
- package/package.json +1 -1
- package/src/lib/api/externalPages.ts +1 -1
- package/src/lib/explore.ts +2 -1
- package/src/lib/types/config.d.ts +122 -120
- package/src/lib/types/position.d.ts +2 -0
- package/src/lib/types/script.d.ts +4 -2
- package/src/routes/components/Debugger.svelte +1 -1
- package/src/routes/components/Explore/Routes/ExploreModal.svelte +70 -19
- package/src/routes/components/Modals/Modal.svelte +2 -1
- package/src/routes/components/Participant.svelte +160 -160
- package/src/routes/explore/+page.svelte +1 -2
- package/src/tests/lib/api/externalPages.test.js +1 -1
- package/src/tests/lib/explore.test.js +4 -2
- package/src/tests/lib/injection.test.js +1 -1
- package/src/tests/lib/retargeting.test.js +2 -0
- package/src/tests/routes/components/Playlinks/Playlink.test.js +2 -0
- package/src/tests/setup.js +108 -108
package/eslint.config.js
CHANGED
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@ export async function fetchLinkInjections(
|
|
|
23
23
|
|
|
24
24
|
if (!apiToken) throw new Error('No token was provided')
|
|
25
25
|
|
|
26
|
-
const apiUrl = `/external-pages/?api-token=${apiToken}&include_title_details=true${isEditorialMode ? '&editorial_mode_enabled=true' : ''}&language=${language}`
|
|
26
|
+
const apiUrl = `/external-pages/?api-token=${apiToken}&include_title_details=true&include_participant_details=true${isEditorialMode ? '&editorial_mode_enabled=true' : ''}&language=${language}`
|
|
27
27
|
let response: LinkInjectionResponse
|
|
28
28
|
|
|
29
29
|
if (method === 'POST') {
|
package/src/lib/explore.ts
CHANGED
|
@@ -44,7 +44,8 @@ export function insertExploreIntoNavigation(): boolean {
|
|
|
44
44
|
if (!config) return false
|
|
45
45
|
|
|
46
46
|
const { explore_navigation_selector: selector, explore_navigation_label: label, explore_navigation_path: path, explore_navigation_insert_position: insertPosition } = config
|
|
47
|
-
|
|
47
|
+
|
|
48
|
+
if (!selector || !path) return false
|
|
48
49
|
|
|
49
50
|
// Make sure to remove an element we created if it already exists. Should not be possible under normal circumstances.
|
|
50
51
|
document.querySelector('[data-playpilot-explore-navigation-element]')?.remove()
|
|
@@ -1,120 +1,122 @@
|
|
|
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
|
-
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* Change the
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
*
|
|
109
|
-
* `
|
|
110
|
-
* `
|
|
111
|
-
* `
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
1
|
+
import type { InsertPosition } from './position'
|
|
2
|
+
|
|
3
|
+
export type ConfigResponse = {
|
|
4
|
+
/**
|
|
5
|
+
* Used to exclude URL matching a regex pattern. If a url matches, nothing is executed beyond fetching the config.
|
|
6
|
+
* The url should never be indexed.
|
|
7
|
+
*/
|
|
8
|
+
exclude_urls_pattern?: string
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Used to inject custom styling for the links, modal, and popover. All styling is done via CSS variables. The passed
|
|
12
|
+
* string should not contain a selector.
|
|
13
|
+
* For example:
|
|
14
|
+
* `--some-variable: some-value;`
|
|
15
|
+
*
|
|
16
|
+
* rather than:
|
|
17
|
+
* `body { --some-variable: some-value; }`
|
|
18
|
+
*/
|
|
19
|
+
custom_style?: string
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The primary selector for the entire article from which text will be selected. Should contain as little content as
|
|
23
|
+
* possible. Should match all pages. May contain multiple selectors like `.article, .listicle`.
|
|
24
|
+
*/
|
|
25
|
+
html_selector?: string
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Some pages contain elements that can't easily be excluded via the `html_selector`. These elements can instead be
|
|
29
|
+
* excluded via this property. May contain multiple selectors like `.footer, .ad`.
|
|
30
|
+
*/
|
|
31
|
+
exclude_elements_selector?: string
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Disable all injections from showing on pages without editorial mode enabled
|
|
35
|
+
*/
|
|
36
|
+
disable_public_injections?: boolean
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Region to fall back on if other methods of getting the region fail. This should be equal to the region most relevant
|
|
40
|
+
* to the partner. Should be lowercase.
|
|
41
|
+
*/
|
|
42
|
+
fallback_region?: string
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Disclaimer text that is shown above playlinks in title cards used to replace the default text
|
|
46
|
+
*/
|
|
47
|
+
playlinks_disclaimer_text?: string
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Some partners may want to display titles without affiliate links, which currently comes down to no playlinks.
|
|
51
|
+
* This can also be set via the config on the script itself.
|
|
52
|
+
*/
|
|
53
|
+
no_affiliate?: boolean
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Whether or not we can insert retargeting pixels. Not all third parties allow this and it is disabled by default
|
|
57
|
+
*/
|
|
58
|
+
allow_retargeting_pixels?: boolean
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* By default affiliate links (playlinks) will render as links even without consent, as a disclaimer is given. Set to true to require explicit consent, rendering as static text without consent.
|
|
62
|
+
*/
|
|
63
|
+
require_affiliate_consent?: boolean
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Scroll reveal posters that show on mobile are enabled by default. Use this option to disable them.
|
|
67
|
+
*/
|
|
68
|
+
disable_scroll_reveal_posters?: boolean
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Playlinks are merged by default, when this option is enabled playlinks will instead be shown categorized.
|
|
72
|
+
*/
|
|
73
|
+
categorize_playlinks?: boolean
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* By default no user identifiable data is tracked. This can be changed using this option. User ids are stored in localStorage and sent along with any tracking request.
|
|
77
|
+
*/
|
|
78
|
+
allow_user_id_tracking?: boolean
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The sid for the current domain, used for tracking
|
|
82
|
+
*/
|
|
83
|
+
domain_sid?: string
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The sid for the organization the domain belongs to, used for tracking. Can be empty.
|
|
87
|
+
*/
|
|
88
|
+
organization_sid?: string
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The following options are all relevant for in text disclaimers, which renders as a disclaimer text within the article,
|
|
92
|
+
* rather than only inside of title cards.
|
|
93
|
+
* Change the text content using `in_text_disclaimer_text`.
|
|
94
|
+
* Change where the element is inserted using `in_text_disclaimer_selector`, by default it will insert before the first text element.
|
|
95
|
+
* Change the insert position using `in_text_disclaimer_insert_position`, by default it will insert before the given selector.
|
|
96
|
+
*/
|
|
97
|
+
in_text_disclaimer_enabled?: boolean
|
|
98
|
+
in_text_disclaimer_text?: string
|
|
99
|
+
in_text_disclaimer_selector?: string
|
|
100
|
+
in_text_disclaimer_insert_position?: InsertPosition
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Open TPI links in explore rather than in modals in the article
|
|
104
|
+
*/
|
|
105
|
+
open_tpi_links_in_explore?: boolean
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* These options are all relevant for the Explore component, which can be inserted as a widget on any page or as a modal.
|
|
109
|
+
* `explore_navigation_selector` is used to select the navigation element that should be copied and inserted _after_.
|
|
110
|
+
* `explore_navigation_label` will end up being the label of the navigation item, defaults to `Streaming Guide`.
|
|
111
|
+
* `explore_navigation_path` is the path that the navigation item will lead to, this will be set up by the third party.
|
|
112
|
+
* `explore_navigation_insert_position` is used to determine if the navigation item should be inserted before or after the given selector.
|
|
113
|
+
* `explore_insert_cta_in_tpi` is used to insert a call to action in modals which opens the explore page as a modal.
|
|
114
|
+
*/
|
|
115
|
+
explore_navigation_selector?: string
|
|
116
|
+
explore_navigation_label?: string
|
|
117
|
+
explore_navigation_path?: string
|
|
118
|
+
explore_navigation_insert_position?: InsertPosition
|
|
119
|
+
explore_insert_cta_in_tpi?: boolean
|
|
120
|
+
explore_custom_style?: string
|
|
121
|
+
explore_use_router?: boolean
|
|
122
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Campaign } from './campaign'
|
|
2
|
+
import type { ConfigResponse } from './config'
|
|
2
3
|
import type { ConsentOptions } from './consent'
|
|
3
4
|
import type { LinkInjection, LinkInjectionResponse } from './injection'
|
|
5
|
+
import type { InsertPosition } from './position'
|
|
4
6
|
import type { TitleData } from './title'
|
|
5
7
|
|
|
6
8
|
export type ScriptConfig = {
|
|
@@ -17,7 +19,7 @@ export type ScriptConfig = {
|
|
|
17
19
|
// Selector for the after article playlinks. Will be placed _after_ the given selector.
|
|
18
20
|
after_article_selector?: string
|
|
19
21
|
// Selector to change the insert position of the after article playlinks. Should only be used if no viable selector can be given with `after_article_selector`.
|
|
20
|
-
after_article_insert_position?: InsertPosition
|
|
22
|
+
after_article_insert_position?: InsertPosition
|
|
21
23
|
// The language of the page will be inferred from the html `lang` attribute. Can be set manually using this option in the config object.
|
|
22
24
|
language?: string | null
|
|
23
25
|
// Set to the last success external-pages fetch.
|
|
@@ -25,7 +27,7 @@ export type ScriptConfig = {
|
|
|
25
27
|
// Lists all tracked events through the `track()` function.
|
|
26
28
|
tracked_events?: { event: string, payload: Record<string, any> }[]
|
|
27
29
|
// Queued tracking events that were fired before consent was given. These might be fired later if the user consents.
|
|
28
|
-
queued_tracking_events?: { event: string, title: TitleData | null, payload: Record<
|
|
30
|
+
queued_tracking_events?: { event: string, title: TitleData | null, payload: Record<string, any> }[]
|
|
29
31
|
// Lists all split test identifiers as created by each running split test. Identifiers are only created when a split test is fired.
|
|
30
32
|
split_test_identifiers?: Record<string, number>
|
|
31
33
|
// All link injections as returned from external-pages, with AI and manual injections merged.
|
|
@@ -181,7 +181,7 @@
|
|
|
181
181
|
{#if !useExploreRouter()}
|
|
182
182
|
<button onclick={(() => {
|
|
183
183
|
destroyExplore()
|
|
184
|
-
window.PlayPilotLinkInjections.config
|
|
184
|
+
window.PlayPilotLinkInjections.config!.explore_use_router = !useExploreRouter()
|
|
185
185
|
insertExplore()
|
|
186
186
|
})}>Toggle new explore</button>
|
|
187
187
|
{/if}
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
import { fetchSimilarTitles, fetchTitleBySid } from '$lib/api/titles'
|
|
3
3
|
import { mobileBreakpoint } from '$lib/constants'
|
|
4
4
|
import { SplitTest } from '$lib/enums/SplitTest'
|
|
5
|
+
import { t } from '$lib/localization'
|
|
5
6
|
import { openModal } from '$lib/modal'
|
|
6
7
|
import { getSplitTestVariantName, trackSplitTestView } from '$lib/splitTest'
|
|
7
8
|
import type { TitleData } from '$lib/types/title'
|
|
9
|
+
import Modal from '../../Modals/Modal.svelte'
|
|
8
10
|
|
|
9
11
|
interface Props {
|
|
10
12
|
navigate?: (key: string, pushState?: boolean) => void
|
|
@@ -12,8 +14,6 @@
|
|
|
12
14
|
|
|
13
15
|
const { navigate = () => null }: Props = $props()
|
|
14
16
|
|
|
15
|
-
openModalViaRoute()
|
|
16
|
-
|
|
17
17
|
async function openModalViaRoute(): Promise<void> {
|
|
18
18
|
const currentUrl = new URL(document.location.toString())
|
|
19
19
|
const sid = currentUrl.searchParams.get('sid')
|
|
@@ -26,22 +26,73 @@
|
|
|
26
26
|
|
|
27
27
|
if (isMobile) trackSplitTestView(SplitTest.Reels)
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
})
|
|
43
|
-
} catch {
|
|
44
|
-
navigate('home')
|
|
45
|
-
}
|
|
29
|
+
const [title, railTitles] = (await Promise.allSettled([
|
|
30
|
+
fetchTitleBySid(sid),
|
|
31
|
+
fetchSimilarTitles({ sid } as unknown as TitleData)])
|
|
32
|
+
).map(promise => (promise.status === 'fulfilled' ? promise.value : null))
|
|
33
|
+
|
|
34
|
+
openModal({
|
|
35
|
+
type,
|
|
36
|
+
data: [(title as TitleData), ...(railTitles as TitleData[])],
|
|
37
|
+
props: {
|
|
38
|
+
onclose: () => navigate('home'),
|
|
39
|
+
pushState: false,
|
|
40
|
+
},
|
|
41
|
+
})
|
|
46
42
|
}
|
|
47
43
|
</script>
|
|
44
|
+
|
|
45
|
+
{#await openModalViaRoute()}
|
|
46
|
+
<Modal blur pushState={false}>
|
|
47
|
+
{#snippet dialog()}
|
|
48
|
+
<div class="loading">
|
|
49
|
+
<div class="bar"></div>
|
|
50
|
+
<div class="bar"></div>
|
|
51
|
+
<div class="bar"></div>
|
|
52
|
+
</div>
|
|
53
|
+
{/snippet}
|
|
54
|
+
</Modal>
|
|
55
|
+
{:catch}
|
|
56
|
+
<Modal blur onclose={() => navigate('home')} pushState={false}>
|
|
57
|
+
<div class="error">
|
|
58
|
+
{t('An Error Occurred')}
|
|
59
|
+
</div>
|
|
60
|
+
</Modal>
|
|
61
|
+
{/await}
|
|
62
|
+
|
|
63
|
+
<style lang="scss">
|
|
64
|
+
.loading {
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
height: 100%;
|
|
69
|
+
gap: margin(0.5);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@keyframes animate-bar {
|
|
73
|
+
to {
|
|
74
|
+
height: margin(3);
|
|
75
|
+
opacity: 0.5;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.bar {
|
|
80
|
+
height: margin(4);
|
|
81
|
+
width: margin(1);
|
|
82
|
+
border-radius: margin(0.25);
|
|
83
|
+
background: white;
|
|
84
|
+
animation: animate-bar 750ms infinite;
|
|
85
|
+
|
|
86
|
+
@for $i from 0 through 2 {
|
|
87
|
+
&:nth-child(#{$i}) {
|
|
88
|
+
animation-delay: $i * 250ms;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.error {
|
|
94
|
+
padding: margin(2);
|
|
95
|
+
font-size: 1.25em;
|
|
96
|
+
color: theme(text-color);
|
|
97
|
+
}
|
|
98
|
+
</style>
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
|
|
60
60
|
onMount(() => {
|
|
61
61
|
const scrollElement = getScrollRoot()
|
|
62
|
+
|
|
62
63
|
scrollElement.classList.add('playpilot-modal-open')
|
|
63
64
|
|
|
64
65
|
hasPreviousModal = !!getPreviousModal()
|
|
@@ -70,7 +71,7 @@
|
|
|
70
71
|
requestAnimationFrame(setInitialScrollPosition)
|
|
71
72
|
|
|
72
73
|
return () => {
|
|
73
|
-
scrollElement.classList.remove('playpilot-modal-open')
|
|
74
|
+
if (!document.querySelector('.modal')) scrollElement.classList.remove('playpilot-modal-open')
|
|
74
75
|
|
|
75
76
|
// Remove the modal entry from above from the browser history. This is done only once for the entire stack.
|
|
76
77
|
// We check for getPreviousModal not because we really care about the previous modal, but to check if all
|