@playpilot/tpi 8.21.5 → 8.21.8-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/.vscode/settings.json +5 -0
- package/dist/editorial.mount.js +11 -11
- package/dist/link-injections.js +2 -2
- package/dist/mount.js +9 -9
- package/package.json +10 -8
- package/patches/svelte+5.55.7.patch +13 -0
- package/src/lib/api/youtubeAvailability.ts +2 -1
- package/src/lib/injectionElements.ts +0 -1
- package/src/mount.ts +1 -1
- package/src/routes/+page.svelte +1 -1
- package/src/routes/components/Editorial/EditorItem.svelte +1 -1
- package/src/routes/components/Explore/ExploreRouter.svelte +10 -4
- package/src/routes/components/SwipeHandle.svelte +1 -0
- package/src/tests/lib/api/auth.test.js +1 -1
- package/src/tests/lib/api/search.test.js +2 -2
- package/src/tests/lib/api/youtubeAvailability.test.js +9 -0
- package/src/tests/lib/injectionElements.test.js +1 -1
- package/src/tests/routes/components/Editorial/EditorItem.test.js +1 -1
- package/src/tests/routes/components/YouTubeEmbed.test.js +6 -0
- package/vite.config.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playpilot/tpi",
|
|
3
|
-
"version": "8.21.
|
|
3
|
+
"version": "8.21.8-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"lint": "prettier --check . && eslint .",
|
|
14
14
|
"test:unit": "vitest",
|
|
15
15
|
"test": "npm run test:unit -- --run",
|
|
16
|
-
"release": "node release.js"
|
|
16
|
+
"release": "node release.js",
|
|
17
|
+
"postinstall": "patch-package"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
20
|
"@playpilot/retargeting-tracking": "^1.4.1",
|
|
@@ -29,16 +30,17 @@
|
|
|
29
30
|
"eslint-config-prettier": "^9.1.0",
|
|
30
31
|
"eslint-plugin-svelte": "^3.15.0",
|
|
31
32
|
"globals": "^15.0.0",
|
|
32
|
-
"happy-dom": "^
|
|
33
|
+
"happy-dom": "^20.10.6",
|
|
34
|
+
"patch-package": "^8.0.1",
|
|
33
35
|
"prettier": "^3.8.3",
|
|
34
36
|
"prettier-plugin-svelte": "^3.2.6",
|
|
35
37
|
"sass": "^1.99.0",
|
|
36
|
-
"svelte": "5.
|
|
37
|
-
"svelte-check": "^4.
|
|
38
|
-
"svelte-preprocess": "^6.0.
|
|
38
|
+
"svelte": "5.55.7",
|
|
39
|
+
"svelte-check": "^4.6.0",
|
|
40
|
+
"svelte-preprocess": "^6.0.5",
|
|
39
41
|
"svelte-tiny-slider": "^2.7.2",
|
|
40
|
-
"typescript": "^
|
|
41
|
-
"typescript-eslint": "^8.
|
|
42
|
+
"typescript": "^6.0.3",
|
|
43
|
+
"typescript-eslint": "^8.62.0",
|
|
42
44
|
"vite": "^5.4.21",
|
|
43
45
|
"vite-plugin-css-injected-by-js": "^4.0.1",
|
|
44
46
|
"vitest": "^2.1.9"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
diff --git a/node_modules/svelte/src/compiler/warnings.js b/node_modules/svelte/src/compiler/warnings.js
|
|
2
|
+
index 089cb1e..5003a7f 100644
|
|
3
|
+
--- a/node_modules/svelte/src/compiler/warnings.js
|
|
4
|
+
+++ b/node_modules/svelte/src/compiler/warnings.js
|
|
5
|
+
@@ -667,7 +667,7 @@ export function reactive_declaration_module_script_dependency(node) {
|
|
6
|
+
* @param {string} type
|
|
7
|
+
*/
|
|
8
|
+
export function state_referenced_locally(node, name, type) {
|
|
9
|
+
- w(node, 'state_referenced_locally', `This reference only captures the initial value of \`${name}\`. Did you mean to reference it inside a ${type} instead?\nhttps://svelte.dev/e/state_referenced_locally`);
|
|
10
|
+
+ // w(node, 'state_referenced_locally', `This reference only captures the initial value of \`${name}\`. Did you mean to reference it inside a ${type} instead?\nhttps://svelte.dev/e/state_referenced_locally`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { PUBLIC_YOUTUBE_AVAILABILITY_URL } from '$env/static/public'
|
|
2
|
+
import { getRegionBasedOnIp } from './region'
|
|
2
3
|
|
|
3
4
|
export async function isYouTubeVideoAvailableInRegion(videoId: string): Promise<boolean> {
|
|
4
|
-
const region =
|
|
5
|
+
const region = (await getRegionBasedOnIp())?.toUpperCase()
|
|
5
6
|
|
|
6
7
|
if (!region) return true
|
|
7
8
|
|
|
@@ -17,7 +17,6 @@ export function getLinkInjectionElements(parentElement: HTMLElement, excludeElem
|
|
|
17
17
|
if (validElements.includes(element)) continue
|
|
18
18
|
if (excludeElementsSelector && element.matches(excludeElementsSelector)) continue
|
|
19
19
|
|
|
20
|
-
// Ignore links, buttons, and headers
|
|
21
20
|
if (/^(A|BUTTON|SCRIPT|NOSCRIPT|STYLE|IFRAME|FIGCAPTION|TIME|LABEL|BLOCKQUOTE|H1)$/.test(element.tagName)) continue
|
|
22
21
|
|
|
23
22
|
// Ignore elements that are visibly hidden as they are likely only for screen readers.
|
package/src/mount.ts
CHANGED
package/src/routes/+page.svelte
CHANGED
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
}} />
|
|
216
216
|
|
|
217
217
|
{#snippet failed()}
|
|
218
|
-
<Alert fixed>An error has
|
|
218
|
+
<Alert fixed>An error has occurred in the PlayPilot Linkinjections editor view. We've been notified and will investigate!</Alert>
|
|
219
219
|
{/snippet}
|
|
220
220
|
</svelte:boundary>
|
|
221
221
|
{/if}
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
function getMatchingElements(): Element[] {
|
|
82
|
-
const injectedElements = Array.from(document.querySelectorAll(`[data-playpilot-injection-key="${key}"]`))
|
|
82
|
+
const injectedElements = Array.from(document.querySelectorAll(`[data-playpilot-injection-key="${key.toString()}"]`))
|
|
83
83
|
if (injectedElements.length) return injectedElements
|
|
84
84
|
|
|
85
85
|
// No matching injection was found, so we try and get the element the sentence might be in.
|
|
@@ -74,7 +74,13 @@
|
|
|
74
74
|
|
|
75
75
|
<svelte:window on:popstate={onhashchange} />
|
|
76
76
|
|
|
77
|
-
<
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
<svelte:boundary onerror={(error) => console.error(error)}>
|
|
78
|
+
<ExploreLayout {navigate} bind:searchQuery bind:filter>
|
|
79
|
+
<CurrentRouteComponent {searchQuery} {filter} {navigate} />
|
|
80
|
+
<CurrentAppendComponent {navigate} />
|
|
81
|
+
</ExploreLayout>
|
|
82
|
+
|
|
83
|
+
{#snippet failed()}
|
|
84
|
+
<p>An error occurred.</p>
|
|
85
|
+
{/snippet}
|
|
86
|
+
</svelte:boundary>
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
|
|
78
78
|
<svelte:window ontouchmove={move} ontouchend={end} />
|
|
79
79
|
|
|
80
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
80
81
|
<div class="handle" class:dragging={isDragging} class:dragged={hasBeenDragged} bind:this={handleElement} ontouchstart={start}></div>
|
|
81
82
|
|
|
82
83
|
<style lang="scss">
|
|
@@ -64,7 +64,7 @@ describe('$lib/api/auth', () => {
|
|
|
64
64
|
it('Should throw error if api response was negative and throwError is true', async () => {
|
|
65
65
|
vi.mocked(api).mockRejectedValueOnce({ response: '', ok: false, status: 403 })
|
|
66
66
|
|
|
67
|
-
expect(async () => await authorize({ href: 'https://example.com/some-path?articleReplacementEditToken=some-token', throwError: true })).rejects.toThrowError()
|
|
67
|
+
await expect(async () => await authorize({ href: 'https://example.com/some-path?articleReplacementEditToken=some-token', throwError: true })).rejects.toThrowError()
|
|
68
68
|
})
|
|
69
69
|
})
|
|
70
70
|
|
|
@@ -30,14 +30,14 @@ describe('$lib/api/search', () => {
|
|
|
30
30
|
it('Should throw when response is invalid', async () => {
|
|
31
31
|
vi.mocked(api).mockRejectedValueOnce({ ok: false })
|
|
32
32
|
|
|
33
|
-
expect(async () => await searchTitles('')).rejects.toThrowError()
|
|
33
|
+
await expect(async () => await searchTitles('')).rejects.toThrowError()
|
|
34
34
|
})
|
|
35
35
|
|
|
36
36
|
it('Should throw when no api token is given', async () => {
|
|
37
37
|
// @ts-ignore
|
|
38
38
|
window.PlayPilotLinkInjections = null
|
|
39
39
|
|
|
40
|
-
expect(async () => await searchTitles('')).rejects.toThrowError('No token was provided')
|
|
40
|
+
await expect(async () => await searchTitles('')).rejects.toThrowError('No token was provided')
|
|
41
41
|
})
|
|
42
42
|
})
|
|
43
43
|
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
2
|
import { isYouTubeVideoAvailableInRegion } from '$lib/api/youtubeAvailability'
|
|
3
3
|
import { fakeFetch } from '../../helpers'
|
|
4
|
+
import { getRegionBasedOnIp } from '$lib/api/region'
|
|
4
5
|
|
|
5
6
|
vi.mock('$lib/tracking', () => ({
|
|
6
7
|
track: vi.fn(),
|
|
@@ -10,6 +11,10 @@ vi.mock('$env/static/public', () => ({
|
|
|
10
11
|
PUBLIC_YOUTUBE_AVAILABILITY_URL: 'https://some-path.com',
|
|
11
12
|
}))
|
|
12
13
|
|
|
14
|
+
vi.mock('$lib/api/region', () => ({
|
|
15
|
+
getRegionBasedOnIp: vi.fn(),
|
|
16
|
+
}))
|
|
17
|
+
|
|
13
18
|
describe('youtubeAvailability', () => {
|
|
14
19
|
beforeEach(() => {
|
|
15
20
|
vi.resetAllMocks()
|
|
@@ -17,6 +22,8 @@ describe('youtubeAvailability', () => {
|
|
|
17
22
|
|
|
18
23
|
// @ts-ignore
|
|
19
24
|
window.PlayPilotLinkInjections = { region: 'nl' }
|
|
25
|
+
|
|
26
|
+
vi.mocked(getRegionBasedOnIp).mockResolvedValue('nl')
|
|
20
27
|
})
|
|
21
28
|
|
|
22
29
|
describe('isYouTubeVideoAvailableInRegion', () => {
|
|
@@ -24,6 +31,8 @@ describe('youtubeAvailability', () => {
|
|
|
24
31
|
// @ts-ignore
|
|
25
32
|
window.PlayPilotLinkInjections = {}
|
|
26
33
|
|
|
34
|
+
vi.mocked(getRegionBasedOnIp).mockResolvedValueOnce('')
|
|
35
|
+
|
|
27
36
|
expect(await isYouTubeVideoAvailableInRegion('video-id')).toBe(true)
|
|
28
37
|
expect(global.fetch).not.toHaveBeenCalled()
|
|
29
38
|
})
|
|
@@ -30,7 +30,7 @@ describe('injectionElements.ts', () => {
|
|
|
30
30
|
})
|
|
31
31
|
|
|
32
32
|
it('Should ignore child elements that were already included in parent text', () => {
|
|
33
|
-
document.body.innerHTML = '<section><p>Some paragraph <
|
|
33
|
+
document.body.innerHTML = '<section><p>Some paragraph <span>Some div</span></p></section>'
|
|
34
34
|
const parent = /** @type {HTMLElement} */ (document.querySelector('section'))
|
|
35
35
|
|
|
36
36
|
expect(getLinkInjectionElements(parent)).toHaveLength(1)
|
|
@@ -109,7 +109,7 @@ describe('EditorItem.svelte', () => {
|
|
|
109
109
|
const onhighlight = vi.fn()
|
|
110
110
|
const { container } = render(EditorItem, { linkInjection, onhighlight })
|
|
111
111
|
|
|
112
|
-
await fireEvent.mouseOver(/** @type {HTMLElement} */ (document.querySelector(`[data-playpilot-injection-key
|
|
112
|
+
await fireEvent.mouseOver(/** @type {HTMLElement} */ (document.querySelector(`[data-playpilot-injection-key="${ linkInjection.key }"]`)))
|
|
113
113
|
expect(container.querySelector('.highlighted')).toBeTruthy()
|
|
114
114
|
expect(onhighlight).toHaveBeenCalled()
|
|
115
115
|
})
|
|
@@ -2,8 +2,14 @@ import { render } from '@testing-library/svelte'
|
|
|
2
2
|
import { describe, expect, it } from 'vitest'
|
|
3
3
|
|
|
4
4
|
import YouTubeEmbed from '../../../routes/components/YouTubeEmbed.svelte'
|
|
5
|
+
import { beforeEach } from 'node:test'
|
|
6
|
+
import { fakeFetch } from '../../helpers'
|
|
5
7
|
|
|
6
8
|
describe('YouTubeEmbed.svelte', () => {
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
fakeFetch()
|
|
11
|
+
})
|
|
12
|
+
|
|
7
13
|
it('Should render embed iframe with given video url and default options', () => {
|
|
8
14
|
const { container } = render(YouTubeEmbed, { embeddable_url: 'youtube.com/watch?v=abc' })
|
|
9
15
|
|