@playpilot/tpi 8.35.0-beta.2 → 8.36.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.
- package/dist/editorial.mount.js +10 -11
- package/dist/link-injections.js +2 -2
- package/dist/mount.css +1 -0
- package/dist/mount.js +8 -9
- package/package.json +1 -1
- package/src/lib/api/providers.ts +3 -1
- package/src/main.ts +24 -3
- package/src/routes/components/Explore/Filter/Filter.svelte +1 -1
- package/src/routes/components/Explore/Routes/ExploreResults.svelte +1 -1
- package/src/routes/components/Icons/IconAttribution.svelte +1 -1
- package/src/routes/components/Icons/IconFilter.svelte +2 -4
- package/src/routes/components/Participants/Participant.svelte +3 -2
- package/src/routes/components/Participants/ParticipantImage.svelte +2 -1
- package/src/tests/lib/api/providers.test.js +9 -0
- package/src/tests/main.test.js +2 -1
- package/src/tests/routes/components/Explore/Filter/Filter.test.js +2 -1
- package/src/tests/routes/components/Participants/Participant.test.js +9 -9
- package/vite._mount.config.js +1 -3
package/package.json
CHANGED
package/src/lib/api/providers.ts
CHANGED
|
@@ -15,7 +15,9 @@ export async function fetchProviders(): Promise<PlaylinkData[]> {
|
|
|
15
15
|
include_count: false,
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
let response = await api<PlaylinkData[]>(`/providers/?api-token=${apiToken}&` + paramsToString(params))
|
|
19
|
+
|
|
20
|
+
response = response.filter((a, i, providers) => providers.findIndex(b => (b.slug === a.slug)) === i)
|
|
19
21
|
|
|
20
22
|
return response
|
|
21
23
|
}
|
package/src/main.ts
CHANGED
|
@@ -83,17 +83,38 @@ window.PlayPilotLinkInjections ||= {
|
|
|
83
83
|
},
|
|
84
84
|
|
|
85
85
|
mount(): void {
|
|
86
|
+
const scriptId = 'playpilot-mount'
|
|
87
|
+
const styleId = 'playpilot-mount-style'
|
|
88
|
+
|
|
89
|
+
const ondoubleload = (event: Event): void => {
|
|
90
|
+
if (!event.target) return
|
|
91
|
+
|
|
92
|
+
(event.target as HTMLElement).dataset.loaded = 'true'
|
|
93
|
+
|
|
94
|
+
if (document.getElementById(scriptId)?.dataset.loaded !== 'true' || document.getElementById(styleId)?.dataset.loaded !== 'true') return
|
|
95
|
+
|
|
96
|
+
window.PlayPilotMount?.mount()
|
|
97
|
+
}
|
|
98
|
+
|
|
86
99
|
const shouldLoadEditorial = isEditorialModeEnabled() || getAuthToken()
|
|
87
100
|
|
|
88
101
|
const script = document.createElement('script')
|
|
89
|
-
|
|
90
|
-
script.id = 'playpilot-mount'
|
|
102
|
+
script.id = scriptId
|
|
91
103
|
script.src = `${cdnBaseUrl}/dist/${shouldLoadEditorial ? 'editorial.' : ''}mount.js`
|
|
92
104
|
// script.src = './dist/mount.js' // Use me during development of this script
|
|
105
|
+
script.defer = true
|
|
106
|
+
script.onload = ondoubleload
|
|
93
107
|
|
|
94
|
-
|
|
108
|
+
const style = document.createElement('link')
|
|
109
|
+
style.id = styleId
|
|
110
|
+
style.rel = 'stylesheet'
|
|
111
|
+
style.type = 'text/css'
|
|
112
|
+
style.href = `${cdnBaseUrl}/dist/mount.css`
|
|
113
|
+
// style.href = './dist/mount.css' // Use me during development of this script
|
|
114
|
+
style.onload = ondoubleload
|
|
95
115
|
|
|
96
116
|
document.body.appendChild(script)
|
|
117
|
+
document.head.appendChild(style)
|
|
97
118
|
},
|
|
98
119
|
}
|
|
99
120
|
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
{#await promise then { next }}
|
|
171
171
|
{#if next}
|
|
172
172
|
<div class="show-more" class:grid>
|
|
173
|
-
<Button size="large" onclick={fetchMoreTitles}>{t('Show More')}</Button>
|
|
173
|
+
<Button size="large" onclick={fetchMoreTitles} label="Show more movies & shows">{t('Show More')}</Button>
|
|
174
174
|
</div>
|
|
175
175
|
{/if}
|
|
176
176
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
<svg height="
|
|
1
|
+
<svg width="21px" height="21px" viewBox="0 -960 960 960">
|
|
2
2
|
<path fill="currentColor" d="M430-200h100v-180h60v-184q0-27-28.5-41.5T480-620q-53 0-81.5 14.5T370-564v184h60v180Zm-105 88.5q-73-31.5-127.5-86t-86-127.5Q80-398 80-480.5t31.5-155q31.5-72.5 86-127t127.5-86Q398-880 480.5-880t155 31.5q72.5 31.5 127 86t86 127Q880-563 880-480.5T848.5-325q-31.5 73-86 127.5t-127 86Q563-80 480.5-80T325-111.5Zm381.5-142Q800-347 800-480t-93.5-226.5Q613-800 480-800t-226.5 93.5Q160-613 160-480t93.5 226.5Q347-160 480-160t226.5-93.5ZM523-657q17-17 17-43t-17-43q-17-17-43-17t-43 17q-17 17-17 43t17 43q17 17 43 17t43-17Zm-43 177Z"/>
|
|
3
3
|
</svg>
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
<svg
|
|
2
|
-
<path
|
|
3
|
-
<path d="M3.8929 2.45945C3.8103 2.80816 3.61245 3.11879 3.33136 3.34108C3.05027 3.56336 2.7024 3.68429 2.34404 3.68429C1.98568 3.68429 1.63781 3.56336 1.35672 3.34108C1.07563 3.11879 0.87778 2.80816 0.795181 2.45945H0.385466C0.291124 2.45489 0.202153 2.4142 0.136997 2.34582C0.0718422 2.27744 0.0354977 2.18661 0.0354977 2.09216C0.0354977 1.99771 0.0718422 1.90688 0.136997 1.8385C0.202153 1.77012 0.291124 1.72943 0.385466 1.72488H0.795181C0.87778 1.37617 1.07563 1.06553 1.35672 0.843245C1.63781 0.620959 1.98568 0.500031 2.34404 0.500031C2.7024 0.500031 3.05027 0.620959 3.33136 0.843245C3.61245 1.06553 3.8103 1.37617 3.8929 1.72488L10.1801 1.72488C10.2744 1.72943 10.3634 1.77012 10.4285 1.8385C10.4937 1.90688 10.53 1.99771 10.53 2.09216C10.53 2.18661 10.4937 2.27744 10.4285 2.34582C10.3634 2.4142 10.2744 2.45489 10.1801 2.45945L3.8929 2.45945ZM2.34404 1.23544C2.17451 1.23544 2.00879 1.28572 1.86784 1.3799C1.72688 1.47408 1.61702 1.60795 1.55214 1.76458C1.48727 1.9212 1.47029 2.09354 1.50337 2.25981C1.53644 2.42608 1.61807 2.57881 1.73795 2.69868C1.85782 2.81856 2.01055 2.90019 2.17682 2.93327C2.34309 2.96634 2.51543 2.94936 2.67206 2.88449C2.82868 2.81961 2.96255 2.70975 3.05673 2.56879C3.15092 2.42784 3.20119 2.26212 3.20119 2.09259C3.2013 1.97996 3.17921 1.8684 3.13619 1.76431C3.09316 1.66022 3.03004 1.56563 2.95044 1.48594C2.87083 1.40626 2.77631 1.34304 2.67226 1.29992C2.56821 1.25679 2.45668 1.23459 2.34404 1.23459V1.23544Z" fill="currentColor"/>
|
|
4
|
-
<path d="M6.0975 11.2752C6.01491 11.6239 5.81705 11.9345 5.53596 12.1568C5.25488 12.3791 4.907 12.5 4.54864 12.5C4.19028 12.5 3.84241 12.3791 3.56132 12.1568C3.28024 11.9345 3.08238 11.6239 2.99978 11.2752H0.385491C0.335766 11.2776 0.286069 11.2699 0.239415 11.2525C0.192761 11.2351 0.150121 11.2085 0.114079 11.1741C0.0780373 11.1398 0.0493441 11.0985 0.0297394 11.0527C0.0101337 11.0069 2.67029e-05 10.9577 2.67029e-05 10.9079C2.67029e-05 10.8581 0.0101337 10.8088 0.0297394 10.7631C0.0493441 10.7173 0.0780373 10.676 0.114079 10.6417C0.150121 10.6073 0.192761 10.5807 0.239415 10.5633C0.286069 10.5459 0.335766 10.5382 0.385491 10.5406H2.99978C3.08238 10.1919 3.28024 9.88126 3.56132 9.65898C3.84241 9.43669 4.19028 9.31577 4.54864 9.31577C4.907 9.31577 5.25488 9.43669 5.53596 9.65898C5.81705 9.88126 6.01491 10.1919 6.0975 10.5406H10.1801C10.2298 10.5382 10.2795 10.5459 10.3262 10.5633C10.3728 10.5807 10.4155 10.6073 10.4515 10.6417C10.4875 10.676 10.5162 10.7173 10.5358 10.7631C10.5554 10.8088 10.5656 10.8581 10.5656 10.9079C10.5656 10.9577 10.5554 11.0069 10.5358 11.0527C10.5162 11.0985 10.4875 11.1398 10.4515 11.1741C10.4155 11.2085 10.3728 11.2351 10.3262 11.2525C10.2795 11.2699 10.2298 11.2776 10.1801 11.2752H6.0975ZM4.54779 10.0503C4.37826 10.0503 4.21254 10.1006 4.07158 10.1948C3.93063 10.289 3.82077 10.4228 3.75589 10.5795C3.69101 10.7361 3.67404 10.9084 3.70711 11.0747C3.74018 11.241 3.82182 11.3937 3.94169 11.5136C4.06157 11.6334 4.2143 11.7151 4.38057 11.7481C4.54684 11.7812 4.71918 11.7642 4.8758 11.6994C5.03242 11.6345 5.16629 11.5246 5.26048 11.3837C5.35466 11.2427 5.40493 11.077 5.40493 10.9075C5.40493 10.6801 5.31463 10.4621 5.15388 10.3014C4.99313 10.1406 4.77512 10.0503 4.54779 10.0503Z" fill="currentColor"/>
|
|
1
|
+
<svg height="24px" viewBox="0 -960 960 960" width="24px">
|
|
2
|
+
<path fill="currentColor" transform="scale(1.2) translate(0, 75)" scale="1.2" d="M440-120v-240h80v80h320v80H520v80h-80Zm-320-80v-80h240v80H120Zm160-160v-80H120v-80h160v-80h80v240h-80Zm160-80v-80h400v80H440Zm160-160v-240h80v80h160v80H680v80h-80Zm-480-80v-80h400v80H120Z" />
|
|
5
3
|
</svg>
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
{ label: 'Year', value: Sorting.Chronological },
|
|
31
31
|
]
|
|
32
32
|
|
|
33
|
+
let clientWidth = $state(0)
|
|
33
34
|
let currentJob: 'all' | Job = $state('all')
|
|
34
35
|
let descriptionExpanded: boolean = $state(false)
|
|
35
36
|
|
|
@@ -66,7 +67,7 @@
|
|
|
66
67
|
</div>
|
|
67
68
|
</div>
|
|
68
69
|
|
|
69
|
-
<div class="content" class:small>
|
|
70
|
+
<div class="content" class:small bind:clientWidth>
|
|
70
71
|
{#if !small}
|
|
71
72
|
<div class="list-header">
|
|
72
73
|
<div class="heading subheading" use:heading={3} id="credits">{t('Credits')}</div>
|
|
@@ -80,7 +81,7 @@
|
|
|
80
81
|
{/each}
|
|
81
82
|
</div>
|
|
82
83
|
|
|
83
|
-
<Filter {filter} {sortings} hideActive />
|
|
84
|
+
<Filter {filter} {sortings} limit={clientWidth < 700} hideActive />
|
|
84
85
|
{/if}
|
|
85
86
|
|
|
86
87
|
<ExploreResults forceGrid hidePlaylinks filter={filterWithParticipant} {onTitleClick} />
|
|
@@ -3,6 +3,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
|
3
3
|
import { api } from '$lib/api/api'
|
|
4
4
|
import { fetchProviders } from '$lib/api/providers'
|
|
5
5
|
import { getApiToken } from '$lib/token'
|
|
6
|
+
import { title } from '$lib/fakeData'
|
|
6
7
|
|
|
7
8
|
vi.mock('$lib/token', () => ({
|
|
8
9
|
getApiToken: vi.fn(),
|
|
@@ -33,5 +34,13 @@ describe('$lib/api/ads', () => {
|
|
|
33
34
|
|
|
34
35
|
await expect(async () => await fetchProviders()).rejects.toThrow()
|
|
35
36
|
})
|
|
37
|
+
|
|
38
|
+
it('Should remove duplicates', async () => {
|
|
39
|
+
vi.mocked(api).mockResolvedValueOnce([title.providers[0], title.providers[0]])
|
|
40
|
+
|
|
41
|
+
const response = await fetchProviders()
|
|
42
|
+
|
|
43
|
+
expect(response).toEqual([title.providers[0]])
|
|
44
|
+
})
|
|
36
45
|
})
|
|
37
46
|
})
|
package/src/tests/main.test.js
CHANGED
|
@@ -113,10 +113,11 @@ describe('main.ts', () => {
|
|
|
113
113
|
})
|
|
114
114
|
|
|
115
115
|
describe('mount', () => {
|
|
116
|
-
it('Should insert script
|
|
116
|
+
it('Should insert both script and style tags', () => {
|
|
117
117
|
window.PlayPilotLinkInjections.mount()
|
|
118
118
|
|
|
119
119
|
expect(document.querySelector('script#playpilot-mount')).toBeTruthy()
|
|
120
|
+
expect(document.querySelector('link#playpilot-mount-style')).toBeTruthy()
|
|
120
121
|
})
|
|
121
122
|
|
|
122
123
|
it('Should insert script tag with editorial mode if editiorial mode is enabled', () => {
|
|
@@ -25,8 +25,9 @@ describe('Filter.svelte', () => {
|
|
|
25
25
|
it('Should not limit the number of filter items shown after pressing expand button', async () => {
|
|
26
26
|
const { getByText, getAllByTestId } = render(Filter, { filter: {} })
|
|
27
27
|
|
|
28
|
-
await fireEvent.click(getByText('
|
|
28
|
+
await fireEvent.click(getByText('Show more'))
|
|
29
29
|
|
|
30
|
+
expect(getByText('Show less')).toBeTruthy()
|
|
30
31
|
expect(getAllByTestId('filter-item')).toHaveLength(7)
|
|
31
32
|
})
|
|
32
33
|
|
|
@@ -40,27 +40,27 @@ describe('Participant.svelte', () => {
|
|
|
40
40
|
})
|
|
41
41
|
|
|
42
42
|
it('Should not show load more button while loading and when fewer than page size of titles are fetched', async () => {
|
|
43
|
-
vi.mocked(fetchTitles).mockResolvedValueOnce({ results: [title, title], next:
|
|
43
|
+
vi.mocked(fetchTitles).mockResolvedValueOnce({ results: [title, title], next: null, previous: 'previous' })
|
|
44
44
|
|
|
45
|
-
const {
|
|
45
|
+
const { queryByLabelText, getAllByTestId } = render(Participant, { participant: participants[0] })
|
|
46
46
|
|
|
47
|
-
expect(
|
|
47
|
+
expect(queryByLabelText('Show more movies & shows')).not.toBeTruthy()
|
|
48
48
|
|
|
49
49
|
await waitFor(() => {
|
|
50
50
|
expect(getAllByTestId('title')).toHaveLength(2)
|
|
51
51
|
})
|
|
52
52
|
|
|
53
|
-
expect(
|
|
53
|
+
expect(queryByLabelText('Show more movies & shows')).not.toBeTruthy()
|
|
54
54
|
})
|
|
55
55
|
|
|
56
56
|
it('Should show load more button after loading and if more than page size of titles are fetched', async () => {
|
|
57
57
|
const resolved = ({ results: Array(30).fill(title), next: 'next', previous: 'previous' })
|
|
58
58
|
vi.mocked(fetchTitles).mockResolvedValueOnce(resolved)
|
|
59
59
|
|
|
60
|
-
const {
|
|
60
|
+
const { getByLabelText } = render(Participant, { participant: participants[0] })
|
|
61
61
|
|
|
62
62
|
await waitFor(() => {
|
|
63
|
-
expect(
|
|
63
|
+
expect(getByLabelText('Show more movies & shows')).toBeTruthy()
|
|
64
64
|
})
|
|
65
65
|
})
|
|
66
66
|
|
|
@@ -68,11 +68,11 @@ describe('Participant.svelte', () => {
|
|
|
68
68
|
const resolved = ({ results: Array(30).fill(title), next: 'next', previous: 'previous' })
|
|
69
69
|
vi.mocked(fetchTitles).mockResolvedValueOnce(resolved)
|
|
70
70
|
|
|
71
|
-
const {
|
|
71
|
+
const { getByLabelText } = render(Participant, { participant: participants[0] })
|
|
72
72
|
|
|
73
|
-
await waitFor(() =>
|
|
73
|
+
await waitFor(() => getByLabelText('Show more movies & shows'))
|
|
74
74
|
|
|
75
|
-
await fireEvent.click(
|
|
75
|
+
await fireEvent.click(getByLabelText('Show more movies & shows'))
|
|
76
76
|
|
|
77
77
|
expect(fetchTitles).toHaveBeenCalledWith({ page: 2, page_size: expect.any(Number), participant_job: null, participant_sid: participants[0].sid })
|
|
78
78
|
})
|
package/vite._mount.config.js
CHANGED
|
@@ -2,7 +2,6 @@ import path from 'path'
|
|
|
2
2
|
import * as dotenv from 'dotenv'
|
|
3
3
|
import { defineConfig } from 'vitest/config'
|
|
4
4
|
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
|
5
|
-
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
|
|
6
5
|
import packageJson from './package.json'
|
|
7
6
|
|
|
8
7
|
dotenv.config({ path: '.env' })
|
|
@@ -13,7 +12,6 @@ export default defineConfig(({ mode }) => {
|
|
|
13
12
|
return {
|
|
14
13
|
plugins: [
|
|
15
14
|
svelte(),
|
|
16
|
-
cssInjectedByJsPlugin(),
|
|
17
15
|
injectEnvVariables,
|
|
18
16
|
],
|
|
19
17
|
|
|
@@ -22,9 +20,9 @@ export default defineConfig(({ mode }) => {
|
|
|
22
20
|
rollupOptions: {
|
|
23
21
|
input: './src/mount.ts',
|
|
24
22
|
output: {
|
|
25
|
-
format: 'iife',
|
|
26
23
|
name: 'PlayPilotMount',
|
|
27
24
|
entryFileNames: isEditiorial ? 'editorial.mount.js' : 'mount.js',
|
|
25
|
+
assetFileNames: (assetInfo) => assetInfo.name,
|
|
28
26
|
},
|
|
29
27
|
},
|
|
30
28
|
},
|