@playpilot/tpi 8.41.0 → 8.42.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/dist/editorial.mount.js +8 -8
- package/dist/link-injections.js +1 -1
- package/dist/mount.js +8 -8
- package/package.json +1 -1
- package/src/lib/injection.ts +578 -545
- package/src/lib/types/config.d.ts +158 -147
- package/src/lib/types/injection.d.ts +65 -59
- package/src/tests/lib/injection.test.js +1618 -1548
|
@@ -1,147 +1,158 @@
|
|
|
1
|
-
import type {
|
|
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
|
-
* to the
|
|
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
|
-
* Change
|
|
100
|
-
* Change the
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
*
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
*
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
1
|
+
import type { LinkInjection } from './injection'
|
|
2
|
+
import type { InsertPosition } from './position'
|
|
3
|
+
|
|
4
|
+
export type ConfigResponse = {
|
|
5
|
+
/**
|
|
6
|
+
* Used to exclude URL matching a regex pattern. If a url matches, nothing is executed beyond fetching the config.
|
|
7
|
+
* The url should never be indexed.
|
|
8
|
+
*/
|
|
9
|
+
exclude_urls_pattern?: string
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Similar to `exclude_urls_pattern` but limited to participant injections. Other injections will continue to function.
|
|
13
|
+
*/
|
|
14
|
+
exclude_participants_urls_pattern?: string
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Used to inject custom styling for the links, modal, and popover. All styling is done via CSS variables. The passed
|
|
18
|
+
* string should not contain a selector.
|
|
19
|
+
* For example:
|
|
20
|
+
* `--some-variable: some-value;`
|
|
21
|
+
*
|
|
22
|
+
* rather than:
|
|
23
|
+
* `body { --some-variable: some-value; }`
|
|
24
|
+
*/
|
|
25
|
+
custom_style?: string
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The primary selector for the entire article from which text will be selected. Should contain as little content as
|
|
29
|
+
* possible. Should match all pages. May contain multiple selectors like `.article, .listicle`.
|
|
30
|
+
*/
|
|
31
|
+
html_selector?: string
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Some pages contain elements that can't easily be excluded via the `html_selector`. These elements can instead be
|
|
35
|
+
* excluded via this property. May contain multiple selectors like `.footer, .ad`.
|
|
36
|
+
*/
|
|
37
|
+
exclude_elements_selector?: string
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Disable all injections from showing on pages without editorial mode enabled
|
|
41
|
+
*/
|
|
42
|
+
disable_public_injections?: boolean
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Region to fall back on if other methods of getting the region fail. This should be equal to the region most relevant
|
|
46
|
+
* to the partner. Should be lowercase.
|
|
47
|
+
*/
|
|
48
|
+
fallback_region?: string
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Disclaimer text that is shown above playlinks in title cards used to replace the default text
|
|
52
|
+
*/
|
|
53
|
+
playlinks_disclaimer_text?: string
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Some partners may want to display titles without affiliate links, which currently comes down to no playlinks.
|
|
57
|
+
* This can also be set via the config on the script itself.
|
|
58
|
+
*/
|
|
59
|
+
no_affiliate?: boolean
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Whether or not we can insert retargeting pixels. Not all third parties allow this and it is disabled by default
|
|
63
|
+
*/
|
|
64
|
+
allow_retargeting_pixels?: boolean
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 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.
|
|
68
|
+
*/
|
|
69
|
+
require_affiliate_consent?: boolean
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Scroll reveal posters that show on mobile are enabled by default. Use this option to disable them.
|
|
73
|
+
*/
|
|
74
|
+
disable_scroll_reveal_posters?: boolean
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Playlinks are merged by default, when this option is enabled playlinks will instead be shown categorized.
|
|
78
|
+
*/
|
|
79
|
+
categorize_playlinks?: boolean
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 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.
|
|
83
|
+
*/
|
|
84
|
+
allow_user_id_tracking?: boolean
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The sid for the current domain, used for tracking
|
|
88
|
+
*/
|
|
89
|
+
domain_sid?: string
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The sid for the organization the domain belongs to, used for tracking. Can be empty.
|
|
93
|
+
*/
|
|
94
|
+
organization_sid?: string
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The following options are all relevant for in text disclaimers, which renders as a disclaimer text within the article,
|
|
98
|
+
* rather than only inside of title cards.
|
|
99
|
+
* Change the text content using `in_text_disclaimer_text`.
|
|
100
|
+
* Change where the element is inserted using `in_text_disclaimer_selector`, by default it will insert before the first text element.
|
|
101
|
+
* Change the insert position using `in_text_disclaimer_insert_position`, by default it will insert before the given selector.
|
|
102
|
+
*/
|
|
103
|
+
in_text_disclaimer_enabled?: boolean
|
|
104
|
+
in_text_disclaimer_text?: string
|
|
105
|
+
in_text_disclaimer_selector?: string
|
|
106
|
+
in_text_disclaimer_insert_position?: InsertPosition
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Open TPI links in explore rather than in modals in the article
|
|
110
|
+
*/
|
|
111
|
+
open_tpi_links_in_explore?: boolean
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Participants with a popularity score lower than this threshold will not be injected
|
|
115
|
+
*/
|
|
116
|
+
participant_injection_popularity_threshold?: number
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Whether or not to base the threshold on the article participants average popularity score.
|
|
120
|
+
* When enabled, this turns `participant_injection_popularity_threshold` into a percentage.
|
|
121
|
+
*/
|
|
122
|
+
participant_injection_popularity_threshold_use_article_average?: boolean
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Include a limit of how many times a single titles/participants may appear in one article.
|
|
126
|
+
*/
|
|
127
|
+
unique_injection_count_limit?: number
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* No more than this count of participant links will show on the entire article.
|
|
131
|
+
*/
|
|
132
|
+
total_participant_injection_count_limit?: number
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Exclude any injections that use one of the given anchors
|
|
136
|
+
*/
|
|
137
|
+
exclude_injections_by_anchors?: LinkInjection['anchor'][]
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Exclude any injections that use one of the given evidence
|
|
141
|
+
*/
|
|
142
|
+
exclude_injections_by_evidence?: LinkInjection['evidence'][]
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* These options are all relevant for the Explore component, which can be inserted as a widget on any page or as a modal.
|
|
146
|
+
* `explore_navigation_selector` is used to select the navigation element that should be copied and inserted _after_.
|
|
147
|
+
* `explore_navigation_label` will end up being the label of the navigation item, defaults to `Streaming Guide`.
|
|
148
|
+
* `explore_navigation_path` is the path that the navigation item will lead to, this will be set up by the third party.
|
|
149
|
+
* `explore_navigation_insert_position` is used to determine if the navigation item should be inserted before or after the given selector.
|
|
150
|
+
* `explore_insert_cta_in_tpi` is used to insert a call to action in modals which opens the explore page as a modal.
|
|
151
|
+
*/
|
|
152
|
+
explore_navigation_selector?: string
|
|
153
|
+
explore_navigation_label?: string
|
|
154
|
+
explore_navigation_path?: string
|
|
155
|
+
explore_navigation_insert_position?: InsertPosition
|
|
156
|
+
explore_insert_cta_in_tpi?: boolean
|
|
157
|
+
explore_custom_style?: string
|
|
158
|
+
}
|
|
@@ -1,59 +1,65 @@
|
|
|
1
|
-
import type { ParticipantData } from './participant'
|
|
2
|
-
import type { TitleData } from './title'
|
|
3
|
-
|
|
4
|
-
export type LinkInjectionDataType = 'title' | 'participant'
|
|
5
|
-
|
|
6
|
-
export type LinkInjection = {
|
|
7
|
-
sid: string
|
|
8
|
-
title: string
|
|
9
|
-
sentence: string
|
|
10
|
-
playpilot_url: string
|
|
11
|
-
key: string
|
|
12
|
-
title_details?: TitleData
|
|
13
|
-
participant_details?: ParticipantData
|
|
14
|
-
phrase_before?: string | null
|
|
15
|
-
phrase_after?: string | null
|
|
16
|
-
inactive?: boolean
|
|
17
|
-
failed?: boolean
|
|
18
|
-
failed_message?: string
|
|
19
|
-
in_text?: boolean
|
|
20
|
-
after_article?: boolean
|
|
21
|
-
after_article_style?: 'modal_button' | 'playlinks' | null
|
|
22
|
-
manual?: boolean
|
|
23
|
-
removed?: boolean
|
|
24
|
-
duplicate?: boolean
|
|
25
|
-
matchingElement?: null | Element
|
|
26
|
-
popularity?: number | null
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export type
|
|
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
|
-
}
|
|
1
|
+
import type { ParticipantData } from './participant'
|
|
2
|
+
import type { TitleData } from './title'
|
|
3
|
+
|
|
4
|
+
export type LinkInjectionDataType = 'title' | 'participant'
|
|
5
|
+
|
|
6
|
+
export type LinkInjection = {
|
|
7
|
+
sid: string
|
|
8
|
+
title: string
|
|
9
|
+
sentence: string
|
|
10
|
+
playpilot_url: string
|
|
11
|
+
key: string
|
|
12
|
+
title_details?: TitleData
|
|
13
|
+
participant_details?: ParticipantData
|
|
14
|
+
phrase_before?: string | null
|
|
15
|
+
phrase_after?: string | null
|
|
16
|
+
inactive?: boolean
|
|
17
|
+
failed?: boolean
|
|
18
|
+
failed_message?: string
|
|
19
|
+
in_text?: boolean
|
|
20
|
+
after_article?: boolean
|
|
21
|
+
after_article_style?: 'modal_button' | 'playlinks' | null
|
|
22
|
+
manual?: boolean
|
|
23
|
+
removed?: boolean
|
|
24
|
+
duplicate?: boolean
|
|
25
|
+
matchingElement?: null | Element
|
|
26
|
+
popularity?: number | null
|
|
27
|
+
anchor?: 'full' | 'attached' | 'bare' | null
|
|
28
|
+
evidence?: 'credited' | 'screen_work' | 'title_mention' | 'name_only' | null
|
|
29
|
+
type: LinkInjectionDataType
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type LinkInjectionRanges = Record<string, {
|
|
33
|
+
elementIndex: number
|
|
34
|
+
from: number
|
|
35
|
+
to: number
|
|
36
|
+
}>
|
|
37
|
+
|
|
38
|
+
export type LinkInjectionResponse = {
|
|
39
|
+
injections_ready: boolean
|
|
40
|
+
ai_enabled: boolean
|
|
41
|
+
injections_enabled: boolean
|
|
42
|
+
ai_running: boolean
|
|
43
|
+
ai_injections: LinkInjection[] | null
|
|
44
|
+
ai_progress_message: string
|
|
45
|
+
ai_progress_percentage: number
|
|
46
|
+
ai_last_run: string | null
|
|
47
|
+
manual_injections: LinkInjection[] | null
|
|
48
|
+
organization_sid?: string
|
|
49
|
+
domain_sid?: string
|
|
50
|
+
session_id?: string | null
|
|
51
|
+
session_last_ping?: string | null
|
|
52
|
+
content_modified_time?: string | null
|
|
53
|
+
pixels?: string[]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type LinkInjectionTypes = {
|
|
57
|
+
aiInjections: LinkInjection[]
|
|
58
|
+
manualInjections: LinkInjection[]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type ArticleMetaData = {
|
|
62
|
+
content_heading: string | null
|
|
63
|
+
content_modified_time: string | null
|
|
64
|
+
content_published_time: string | null
|
|
65
|
+
}
|