@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/eslint.config.js CHANGED
@@ -69,7 +69,6 @@ export default [
69
69
  },
70
70
  {
71
71
  files: ['**/*.ts'],
72
- ignores: ['**/*.d.ts'],
73
72
  languageOptions: {
74
73
  parser: tsParser,
75
74
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playpilot/tpi",
3
- "version": "8.27.1",
3
+ "version": "8.28.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -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') {
@@ -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
- if (!selector) return false
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
- export type ConfigResponse = {
2
- /**
3
- * Used to exclude URL matching a regex pattern. If a url matches, nothing is executed beyond fetching the config.
4
- * The url should never be indexed.
5
- */
6
- exclude_urls_pattern?: string
7
-
8
- /**
9
- * Used to inject custom styling for the links, modal, and popover. All styling is done via CSS variables. The passed
10
- * string should not contain a selector.
11
- * For example:
12
- * `--some-variable: some-value;`
13
- *
14
- * rather than:
15
- * `body { --some-variable: some-value; }`
16
- */
17
- custom_style?: string
18
-
19
- /**
20
- * The primary selector for the entire article from which text will be selected. Should contain as little content as
21
- * possible. Should match all pages. May contain multiple selectors like `.article, .listicle`.
22
- */
23
- html_selector?: string
24
-
25
- /**
26
- * Some pages contain elements that can't easily be excluded via the `html_selector`. These elements can instead be
27
- * excluded via this property. May contain multiple selectors like `.footer, .ad`.
28
- */
29
- exclude_elements_selector?: string
30
-
31
- /**
32
- * Disable all injections from showing on pages without editorial mode enabled
33
- */
34
- disable_public_injections?: boolean
35
-
36
- /**
37
- * Region to fall back on if other methods of getting the region fail. This should be equal to the region most relevant
38
- * to the partner. Should be lowercase.
39
- */
40
- fallback_region?: string
41
-
42
- /**
43
- * Disclaimer text that is shown above playlinks in title cards used to replace the default text
44
- */
45
- playlinks_disclaimer_text?: string
46
-
47
- /**
48
- * Some partners may want to display titles without affiliate links, which currently comes down to no playlinks.
49
- * This can also be set via the config on the script itself.
50
- */
51
- no_affiliate?: boolean
52
-
53
- /**
54
- * Whether or not we can insert retargeting pixels. Not all third parties allow this and it is disabled by default
55
- */
56
- allow_retargeting_pixels?: boolean
57
-
58
- /**
59
- * 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.
60
- */
61
- require_affiliate_consent?: boolean
62
-
63
- /**
64
- * Scroll reveal posters that show on mobile are enabled by default. Use this option to disable them.
65
- */
66
- disable_scroll_reveal_posters?: boolean
67
-
68
- /**
69
- * Playlinks are merged by default, when this option is enabled playlinks will instead be shown categorized.
70
- */
71
- categorize_playlinks?: boolean
72
-
73
- /**
74
- * 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.
75
- */
76
- allow_user_id_tracking?: boolean
77
-
78
- /**
79
- * The sid for the current domain, used for tracking
80
- */
81
- domain_sid?: string
82
-
83
- /**
84
- * The sid for the organization the domain belongs to, used for tracking. Can be empty.
85
- */
86
- organization_sid?: string
87
-
88
- /**
89
- * The following options are all relevant for in text disclaimers, which renders as a disclaimer text within the article,
90
- * rather than only inside of title cards.
91
- * Change the text content using `in_text_disclaimer_text`.
92
- * Change where the element is inserted using `in_text_disclaimer_selector`, by default it will insert before the first text element.
93
- * Change the insert position using `in_text_disclaimer_insert_position`, by default it will insert before the given selector.
94
- */
95
- in_text_disclaimer_enabled?: boolean
96
- in_text_disclaimer_text?: string
97
- in_text_disclaimer_selector?: string
98
- in_text_disclaimer_insert_position?: InsertPosition
99
-
100
- /**
101
- * Open TPI links in explore rather than in modals in the article
102
- */
103
- open_tpi_links_in_explore?: boolean
104
-
105
- /**
106
- * These options are all relevant for the Explore component, which can be inserted as a widget on any page or as a modal.
107
- * `explore_navigation_selector` is used to select the navigation element that should be copied and inserted _after_.
108
- * `explore_navigation_label` will end up being the label of the navigation item, defaults to `Streaming Guide`.
109
- * `explore_navigation_path` is the path that the navigation item will lead to, this will be set up by the third party.
110
- * `explore_navigation_insert_position` is used to determine if the navigation item should be inserted before or after the given selector.
111
- * `explore_insert_cta_in_tpi` is used to insert a call to action in modals which opens the explore page as a modal.
112
- */
113
- explore_navigation_selector?: string
114
- explore_navigation_label?: string
115
- explore_navigation_path?: string
116
- explore_navigation_insert_position?: InsertPosition
117
- explore_insert_cta_in_tpi?: boolean
118
- explore_custom_style?: string
119
- explore_use_router?: boolean
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
+ }
@@ -4,3 +4,5 @@ export type Position = {
4
4
  }
5
5
 
6
6
  export type Alignment = 'bottom' | 'center'
7
+
8
+ export type InsertPosition = 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend' | ''
@@ -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<strong, any> }[]
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.explore_use_router = !useExploreRouter()
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
- try {
30
- const [title, railTitles] = (await Promise.allSettled([
31
- fetchTitleBySid(sid),
32
- fetchSimilarTitles({ sid } as unknown as TitleData)])
33
- ).map(promise => (promise.status === 'fulfilled' ? promise.value : null))
34
-
35
- openModal({
36
- type,
37
- data: [(title as TitleData), ...(railTitles as TitleData[])],
38
- props: {
39
- onclose: () => navigate('home'),
40
- pushState: false,
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