@playpilot/tpi 7.2.0 → 7.3.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 +7 -7
- package/dist/link-injections.js +1 -1
- package/dist/mount.js +5 -5
- package/events.md +5 -0
- package/package.json +1 -1
- package/src/lib/explore.ts +19 -1
- package/src/lib/types/config.d.ts +1 -0
- package/src/routes/explore/+page.svelte +1 -0
- package/src/tests/lib/explore.test.js +38 -1
- package/src/tests/routes/components/YouTubeEmbedOverlay.test.js +1 -1
- package/vite._main.config.js +1 -0
- package/vite.config.js +8 -0
package/events.md
CHANGED
|
@@ -9,6 +9,11 @@ All events share a common payload:
|
|
|
9
9
|
- `organization_sid`: The sid for the related organization
|
|
10
10
|
- `domain_sid`: The sid for the related domain
|
|
11
11
|
- `device`: Basic device info containing the screen type, size, touch, and orientation
|
|
12
|
+
- `type`: "desktop" or "mobile"
|
|
13
|
+
- `width`: Screen width in pixels
|
|
14
|
+
- `height`: Screen height in pixels
|
|
15
|
+
- `touch`: Whether the device uses touch controls or not
|
|
16
|
+
- `orientation`: "landscape-primary", "landscape-secondary", "portrait-primary", "portrait-secondary", or "undefined"
|
|
12
17
|
|
|
13
18
|
Events related to titles share an additional set of data (referred to below as `Title`):
|
|
14
19
|
|
package/package.json
CHANGED
package/src/lib/explore.ts
CHANGED
|
@@ -3,6 +3,7 @@ import Explore from '../routes/components/Explore/Explore.svelte'
|
|
|
3
3
|
|
|
4
4
|
export const exploreParentSelector = '[data-playpilot-explore]'
|
|
5
5
|
export const explorePreConsentSelector = '[data-playpilot-pre-consent-explore]'
|
|
6
|
+
export const exploreCustomStyleId = 'playpilot-explore-custom-style'
|
|
6
7
|
|
|
7
8
|
let exploreInsertedComponent: object | null = null
|
|
8
9
|
|
|
@@ -19,6 +20,8 @@ export function insertExplore(): void {
|
|
|
19
20
|
|
|
20
21
|
target.innerHTML = ''
|
|
21
22
|
exploreInsertedComponent = mount(Explore, { target })
|
|
23
|
+
|
|
24
|
+
insertExploreCustomStyle()
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
export function destroyExplore(): void {
|
|
@@ -26,6 +29,8 @@ export function destroyExplore(): void {
|
|
|
26
29
|
|
|
27
30
|
unmount(exploreInsertedComponent)
|
|
28
31
|
exploreInsertedComponent = null
|
|
32
|
+
|
|
33
|
+
document.querySelector('#' + exploreCustomStyleId)?.remove()
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
/**
|
|
@@ -37,7 +42,7 @@ export function insertExploreIntoNavigation(): boolean {
|
|
|
37
42
|
const config = window.PlayPilotLinkInjections.config
|
|
38
43
|
if (!config) return false
|
|
39
44
|
|
|
40
|
-
const { explore_navigation_selector: selector, explore_navigation_label: label, explore_navigation_path: path, explore_navigation_insert_position: insertPosition } =
|
|
45
|
+
const { explore_navigation_selector: selector, explore_navigation_label: label, explore_navigation_path: path, explore_navigation_insert_position: insertPosition } = config
|
|
41
46
|
if (!selector) return false
|
|
42
47
|
|
|
43
48
|
// Make sure to remove an element we created if it already exists. Should not be possible under normal circumstances.
|
|
@@ -59,3 +64,16 @@ export function insertExploreIntoNavigation(): boolean {
|
|
|
59
64
|
|
|
60
65
|
return true
|
|
61
66
|
}
|
|
67
|
+
|
|
68
|
+
function insertExploreCustomStyle(): void {
|
|
69
|
+
const customStyleString = window.PlayPilotLinkInjections.config?.explore_custom_style
|
|
70
|
+
|
|
71
|
+
if (!customStyleString) return
|
|
72
|
+
|
|
73
|
+
const styleElement = document.createElement('style')
|
|
74
|
+
|
|
75
|
+
styleElement.textContent = customStyleString
|
|
76
|
+
styleElement.id = exploreCustomStyleId
|
|
77
|
+
|
|
78
|
+
document.body.appendChild(styleElement)
|
|
79
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
|
-
import { destroyExplore, explorePreConsentSelector, insertExplore, insertExploreIntoNavigation } from '$lib/explore'
|
|
2
|
+
import { destroyExplore, exploreCustomStyleId, explorePreConsentSelector, insertExplore, insertExploreIntoNavigation } from '$lib/explore'
|
|
3
3
|
import { mount, unmount } from 'svelte'
|
|
4
|
+
import { waitFor } from '@testing-library/svelte'
|
|
4
5
|
vi.mock('svelte', () => ({
|
|
5
6
|
mount: vi.fn(() => true),
|
|
6
7
|
unmount: vi.fn(),
|
|
@@ -49,6 +50,34 @@ describe('explore.js', () => {
|
|
|
49
50
|
|
|
50
51
|
expect(document.querySelector(explorePreConsentSelector)).not.toBeTruthy()
|
|
51
52
|
})
|
|
53
|
+
|
|
54
|
+
it('Should insert custom style tag if config object is given', async () => {
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
window.PlayPilotLinkInjections = {
|
|
57
|
+
config: {
|
|
58
|
+
explore_custom_style: 'main { color: red; }',
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
insertExplore()
|
|
63
|
+
|
|
64
|
+
await waitFor(() => {
|
|
65
|
+
expect(document.querySelector('#' + exploreCustomStyleId)).toBeTruthy()
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('Should not insert custom style tag if config value is not given', async () => {
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
window.PlayPilotLinkInjections = {
|
|
72
|
+
config: {
|
|
73
|
+
explore_custom_style: '',
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
insertExplore()
|
|
78
|
+
|
|
79
|
+
expect(document.querySelector('#' + exploreCustomStyleId)).not.toBeTruthy()
|
|
80
|
+
})
|
|
52
81
|
})
|
|
53
82
|
|
|
54
83
|
describe('destroyExplore', () => {
|
|
@@ -64,6 +93,14 @@ describe('explore.js', () => {
|
|
|
64
93
|
|
|
65
94
|
expect(unmount).toHaveBeenCalled()
|
|
66
95
|
})
|
|
96
|
+
|
|
97
|
+
it('Should remove custom style tag', () => {
|
|
98
|
+
document.body.innerHTML = `<script id="${exploreCustomStyleId}"></script>`
|
|
99
|
+
|
|
100
|
+
destroyExplore()
|
|
101
|
+
|
|
102
|
+
expect(document.querySelector('#' + exploreCustomStyleId)).not.toBeTruthy()
|
|
103
|
+
})
|
|
67
104
|
})
|
|
68
105
|
|
|
69
106
|
describe('insertExploreIntoNavigation', () => {
|
|
@@ -8,7 +8,7 @@ describe('YouTubeEmbedOverlay.svelte', () => {
|
|
|
8
8
|
const { container } = render(YouTubeEmbedOverlay, { embeddable_url: 'youtube.com/watch?v=abc', onclose: () => null })
|
|
9
9
|
|
|
10
10
|
// @ts-ignore
|
|
11
|
-
expect(container.querySelector('iframe').src).toBe('https://video.playpilot.net/?video_id=abc&autoplay=true&playsinline=true&controls=play,mute,fullscreen,progress,current-time
|
|
11
|
+
expect(container.querySelector('iframe').src).toBe('https://video.playpilot.net/?video_id=abc&color=fa548a&autoplay=true&playsinline=true&controls=play,mute,fullscreen,progress,current-time')
|
|
12
12
|
})
|
|
13
13
|
|
|
14
14
|
it('Should render error message if embeddable_url is invalid', () => {
|
package/vite._main.config.js
CHANGED
package/vite.config.js
CHANGED
|
@@ -17,6 +17,14 @@ export default defineConfig(() => ({
|
|
|
17
17
|
|
|
18
18
|
test: {
|
|
19
19
|
environment: 'happy-dom',
|
|
20
|
+
environmentOptions: {
|
|
21
|
+
happyDOM: {
|
|
22
|
+
settings: {
|
|
23
|
+
enableJavaScriptEvaluation: true,
|
|
24
|
+
disableJavaScriptFileLoading: true,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
20
28
|
include: ['src/**/*.{test,spec}.{js,ts}'],
|
|
21
29
|
setupFiles: ['src/tests/setup.js'],
|
|
22
30
|
},
|