@playpilot/tpi 7.2.0 → 7.3.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/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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playpilot/tpi",
3
- "version": "7.2.0",
3
+ "version": "7.3.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -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 } = window.PlayPilotLinkInjections.config
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
+ }
@@ -100,4 +100,5 @@ export type ConfigResponse = {
100
100
  explore_navigation_path?: string
101
101
  explore_navigation_insert_position?: InsertPosition
102
102
  explore_insert_cta_in_tpi?: boolean
103
+ explore_custom_style?: string
103
104
  }
@@ -40,6 +40,7 @@
40
40
  .paragraph {
41
41
  display: block;
42
42
  margin: margin(1) 0 0;
43
+ font-family: theme(description-font-family, font-family);
43
44
  }
44
45
 
45
46
  .show-more {
@@ -100,6 +100,7 @@
100
100
  position: relative;
101
101
  background: theme(playlink-background, lighter);
102
102
  box-shadow: theme(playlink-shadow, shadow);
103
+ border: theme(playlink-border, 0);
103
104
  border-radius: theme(playlink-border-radius, border-radius);
104
105
  color: theme(playlink-text-color, text-color) !important;
105
106
  font-weight: theme(playlink-font-weight, inherit);
@@ -41,8 +41,9 @@
41
41
  margin: margin(1) 0 margin(0.5);
42
42
  font-size: theme(rail-title-font-size, 18px);
43
43
  line-height: normal;
44
- font-weight: inherit;
44
+ font-weight: theme(rail-title-font-weight, inherit);
45
45
  color: theme(rail-title-text-color, text-color);
46
+ font-family: theme(rail-title-font-family, font-family);
46
47
  }
47
48
 
48
49
  .rail {
@@ -16,6 +16,7 @@
16
16
  explore_navigation_selector: 'nav a:last-child',
17
17
  explore_navigation_label: 'Streaming guide',
18
18
  explore_navigation_path: '/explore',
19
+ explore_custom_style: 'main { border: 2px solid white }',
19
20
  },
20
21
  }
21
22
  }
@@ -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,15 @@ describe('explore.js', () => {
64
93
 
65
94
  expect(unmount).toHaveBeenCalled()
66
95
  })
96
+
97
+ it('Should remove custom style tag', () => {
98
+ document.body.innerHTML = `<div data-playpilot-explore></div><script id="${exploreCustomStyleId}"></script>`
99
+
100
+ insertExplore()
101
+ destroyExplore()
102
+
103
+ expect(document.querySelector('#' + exploreCustomStyleId)).not.toBeTruthy()
104
+ })
67
105
  })
68
106
 
69
107
  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&color=#fa548a')
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', () => {
@@ -14,6 +14,7 @@ export default defineConfig(() => ({
14
14
  entryFileNames: 'link-injections.js',
15
15
  },
16
16
  },
17
+ chunkSizeWarningLimit: 10,
17
18
  },
18
19
 
19
20
  resolve: {
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
  },