@playpilot/tpi 5.19.2-beta.1 → 5.19.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playpilot/tpi",
3
- "version": "5.19.2-beta.1",
3
+ "version": "5.19.3",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
package/release.js CHANGED
@@ -7,6 +7,9 @@ if (!['major', 'minor', 'patch'].includes(versionType)) {
7
7
  }
8
8
 
9
9
  try {
10
+ console.log(`Bumping version: ${versionType}...`)
11
+ execSync(`npm version ${versionType}`, { stdio: 'inherit' })
12
+
10
13
  console.log('Building...')
11
14
  execSync('npm run build', { stdio: 'inherit' })
12
15
 
@@ -14,9 +17,6 @@ try {
14
17
  execSync('git add dist', { stdio: 'inherit' })
15
18
  execSync('git commit -m "chore: Update dist"', { stdio: 'inherit' })
16
19
 
17
- console.log(`Bumping version: ${versionType}...`)
18
- execSync(`npm version ${versionType}`, { stdio: 'inherit' })
19
-
20
20
  console.log('Pushing to git...')
21
21
  execSync('git push --follow-tags', { stdio: 'inherit' })
22
22
 
@@ -40,7 +40,7 @@ export function getLinkInjectionElements(parentElement: HTMLElement, excludeElem
40
40
  if (excludeElementsSelector && element.matches(excludeElementsSelector)) continue
41
41
 
42
42
  // Ignore links, buttons, and headers
43
- if (/^(A|BUTTON|SCRIPT|NOSCRIPT|STYLE|IFRAME|FIGCAPTION|TIME|H1)$/.test(element.tagName)) continue
43
+ if (/^(A|BUTTON|SCRIPT|NOSCRIPT|STYLE|IFRAME|FIGCAPTION|TIME|LABEL|BLOCKQUOTE|H1)$/.test(element.tagName)) continue
44
44
 
45
45
  // Ignore elements that are visibly hidden as they are likely only for screen readers.
46
46
  // These elements can be hidden via display: none or via a tiny width or perhaps even a clip path.
@@ -129,9 +129,7 @@ export function injectLinksInDocument(elements: HTMLElement[], injections: LinkI
129
129
  const fullText = cleanPhrase(elements.map(element => element.innerText).join(' '))
130
130
 
131
131
  const validInjections = filterInvalidInTextInjections(mergedInjections)
132
- const foundInjections = validInjections.filter(i => {
133
- return fullText.includes(cleanPhrase(i.sentence))
134
- })
132
+ const foundInjections = validInjections.filter(i => fullText.includes(cleanPhrase(i.sentence)))
135
133
 
136
134
  const failedMessages: Record<string, string> = {}
137
135
 
@@ -26,7 +26,7 @@
26
26
  { label: 'HTML selector', data: data.selector },
27
27
  ],
28
28
  [`Succesful injections (${succesfulInjections.length})`]: succesfulInjections.map(injection => ({ label: injection.title, data: injection.sentence })),
29
- [`Failed injections (${failedInjections.length})`]: failedInjections.map(injection => ({ label: injection.title, data: injection.failed_message })),
29
+ [`Failed injections (${failedInjections.length})`]: failedInjections.map(injection => ({ label: injection.title, data: `Reason: ${injection.failed_message} | Sentence: ${injection.sentence}` })),
30
30
  [`Fetched ads (${data.ads?.length || 0})`]: data.ads?.map(ad => ({ label: ad.campaign_name, data: ad })),
31
31
  [`Tracking events (${data.tracked_events?.length || 0})`]: data.tracked_events?.map(event => ({ label: event.event, data: event.payload })),
32
32
  }
@@ -1,12 +1,17 @@
1
1
  <script lang="ts">
2
2
  interface Props {
3
3
  direction?: 'left' | 'right'
4
+ title?: string
4
5
  }
5
6
 
6
- const { direction = 'right' }: Props = $props()
7
+ const { direction = 'right', title = '' }: Props = $props()
7
8
  </script>
8
9
 
9
10
  <svg class="{direction}" height="16px" viewBox="0 -960 960 960" width="16px">
11
+ {#if title}
12
+ <title>{title}</title>
13
+ {/if}
14
+
10
15
  <path d="m288-96-68-68 316-316-316-316 68-68 384 384L288-96Z" fill="currentColor" />
11
16
  </svg>
12
17
 
@@ -7,5 +7,6 @@
7
7
  </script>
8
8
 
9
9
  <svg width={size} height={size} viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
10
- <path d="M7 0.351929L9.163 4.72803L14 5.43408L10.5 8.8385L11.326 13.648L7 11.3761L2.674 13.648L3.5 8.8385L0 5.43408L4.837 4.72803L7 0.351929Z" fill="#F6C045"/>
10
+ <title>IMDb rating</title>
11
+ <path d="M7 0.351929L9.163 4.72803L14 5.43408L10.5 8.8385L11.326 13.648L7 11.3761L2.674 13.648L3.5 8.8385L0 5.43408L4.837 4.72803L7 0.351929Z" fill="#F6C045"/>
11
12
  </svg>
@@ -19,6 +19,7 @@
19
19
  closeButtonStyle?: 'shadow' | 'flat'
20
20
  initialScrollPosition?: number
21
21
  onscroll?: () => void
22
+ onclose?: () => void
22
23
  }
23
24
 
24
25
  const {
@@ -29,6 +30,7 @@
29
30
  closeButtonStyle = 'shadow',
30
31
  initialScrollPosition = 0,
31
32
  onscroll = () => null,
33
+ onclose = () => null,
32
34
  }: Props = $props()
33
35
 
34
36
  const inlineBubble = isInSplitTestVariant(SplitTest.TopScrollFormat, 1)
@@ -80,11 +82,16 @@
80
82
  if (isMobile) return fly(node, { duration: 250, ...options })
81
83
  return scale(node, { duration: 150, start: 0.85 })
82
84
  }
85
+
86
+ function close() {
87
+ onclose()
88
+ destroyAllModals()
89
+ }
83
90
  </script>
84
91
 
85
92
  <svelte:window
86
- onkeydown={({ key }) => { if (key === 'Escape') destroyAllModals() }}
87
- onhashchange={() => destroyAllModals()}
93
+ onkeydown={({ key }) => { if (key === 'Escape') close() }}
94
+ onhashchange={close}
88
95
  bind:innerWidth={windowWidth} />
89
96
 
90
97
  <div class="modal" style:--dialog-offset="{dialogOffset}px" transition:fade|global={{ duration: 150 }} bind:this={modalElement} class:has-bubble={!!bubble && inlineBubble} class:has-prepend={!!prepend}>
@@ -102,7 +109,7 @@
102
109
 
103
110
  {#if isMobile}
104
111
  <div class="swipe-handle" transition:scaleOrFly|global>
105
- <SwipeHandle target={dialogElement!} onpassed={() => destroyAllModals()} />
112
+ <SwipeHandle target={dialogElement!} onpassed={close} />
106
113
  </div>
107
114
  {/if}
108
115
 
@@ -116,7 +123,7 @@
116
123
  {/if}
117
124
 
118
125
  <div class="close {closeButtonStyle}">
119
- <RoundButton onclick={() => destroyAllModals()} aria-label="Close">
126
+ <RoundButton onclick={close} aria-label="Close">
120
127
  <IconClose />
121
128
  </RoundButton>
122
129
  </div>
@@ -126,7 +133,7 @@
126
133
 
127
134
  <!-- svelte-ignore a11y_click_events_have_key_events -->
128
135
  <!-- svelte-ignore a11y_no_static_element_interactions -->
129
- <div class="backdrop" onclick={() => destroyAllModals()}></div>
136
+ <div class="backdrop" onclick={close}></div>
130
137
  </div>
131
138
 
132
139
  <style lang="scss">
@@ -22,11 +22,15 @@
22
22
 
23
23
  {#snippet controls({ setIndex, currentIndex, reachedEnd })}
24
24
  {#if currentIndex > 0}
25
- <button class="arrow left" onclick={() => setIndex(currentIndex - 1)}><IconArrow direction="left" /></button>
25
+ <button class="arrow left" onclick={() => setIndex(currentIndex - 1)} aria-label="Previous" aria-live="polite">
26
+ <IconArrow direction="left" title="Previous" />
27
+ </button>
26
28
  {/if}
27
29
 
28
30
  {#if !reachedEnd}
29
- <button class="arrow right" onclick={() => setIndex(currentIndex + 1)}><IconArrow /></button>
31
+ <button class="arrow right" onclick={() => setIndex(currentIndex + 1)} aria-label="Next" aria-live="polite">
32
+ <IconArrow title="Next" />
33
+ </button>
30
34
  {/if}
31
35
  {/snippet}
32
36
  </TinySlider>
@@ -57,10 +57,7 @@
57
57
 
58
58
  <!-- Temporarily not available on production as there is not yet an API endpoint for either -->
59
59
  {#if process.env.NODE_ENV !== 'production'}
60
- {#if true}
61
- <ParticipantsRail />
62
- {/if}
63
-
60
+ <ParticipantsRail />
64
61
  <SimilarRail {title} />
65
62
  {/if}
66
63
  </div>
@@ -869,6 +869,8 @@ describe('linkInjection.js', () => {
869
869
  <noscript>I am noscript</noscript>
870
870
  <figcaption>I am a figcaption</figcaption>
871
871
  <time>I am time</time>
872
+ <label>I am a label</label>
873
+ <blockquote>I am a quote</blockquote>
872
874
 
873
875
  <div>
874
876
  <a>I am another link</a>
@@ -16,47 +16,53 @@ describe('Modal.svelte', () => {
16
16
  vi.resetAllMocks()
17
17
  })
18
18
 
19
+ const onclose = vi.fn()
19
20
  const children = createRawSnippet(() => ({ render: () => '<div></div>' }))
20
21
 
21
- it('Should fire given destroyAllModals function when backdrop is clicked', async () => {
22
- const { container } = render(Modal, { children })
22
+ it('Should fire given onclose and destroyAllModals functions when backdrop is clicked', async () => {
23
+ const { container } = render(Modal, { children, onclose })
23
24
 
24
25
  await fireEvent.click(/** @type {Node} */ (container.querySelector('.backdrop')))
25
26
 
27
+ expect(onclose).toHaveBeenCalled()
26
28
  expect(destroyAllModals).toHaveBeenCalled()
27
29
  })
28
30
 
29
- it('Should fire destroyAllModals function when close button is clicked', async () => {
30
- const { container } = render(Modal, { children })
31
+ it('Should fire given onclose and destroyAllModals functions when close button is clicked', async () => {
32
+ const { container } = render(Modal, { children, onclose })
31
33
 
32
34
  await fireEvent.click(/** @type {Node} */ (container.querySelector('button')))
33
35
 
36
+ expect(onclose).toHaveBeenCalled()
34
37
  expect(destroyAllModals).toHaveBeenCalled()
35
38
  })
36
39
 
37
- it('Should not fire given onclose function when dialog is clicked', async () => {
38
- const { container } = render(Modal, { children })
40
+ it('Should not fire given onclose or destroyAllModals functions when dialog is clicked', async () => {
41
+ const { container } = render(Modal, { children, onclose })
39
42
 
40
43
  await fireEvent.click(/** @type {Node} */ (container.querySelector('.dialog')))
41
44
 
45
+ expect(onclose).not.toHaveBeenCalled()
42
46
  expect(destroyAllModals).not.toHaveBeenCalled()
43
47
  })
44
48
 
45
- it('Should fire given destroyAllModals function when escape key is pressed', async () => {
46
- render(Modal, { children })
49
+ it('Should fire given onclose and destroyAllModals functions when escape key is pressed', async () => {
50
+ render(Modal, { children, onclose })
47
51
 
48
52
  fireEvent.keyDown(window, { key: 'Escape' })
49
53
 
54
+ expect(onclose).toHaveBeenCalled()
50
55
  expect(destroyAllModals).toHaveBeenCalled()
51
56
  })
52
57
 
53
- it('Should not fire given onclose function when key other than escape key is pressed', async () => {
54
- render(Modal, { children })
58
+ it('Should not fire given onclose or destroyAllModals function when key other than escape key is pressed', async () => {
59
+ render(Modal, { children, onclose })
55
60
 
56
61
  fireEvent.keyDown(window, { key: 'a' })
57
62
  fireEvent.keyDown(window, { key: 'Enter' })
58
63
  fireEvent.keyDown(window, { key: 'Space' })
59
64
 
65
+ expect(onclose).not.toHaveBeenCalled()
60
66
  expect(destroyAllModals).not.toHaveBeenCalled()
61
67
  })
62
68