@vouchfor/embeds 0.0.0-experiment.f80a91a → 0.0.0-experiment.f958e09
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/es/embeds.js +1138 -9
- package/dist/es/embeds.js.map +1 -1
- package/dist/es/src/components/DialogEmbed/DialogOverlay.d.ts +2 -1
- package/dist/es/src/components/DialogEmbed/DialogPortal.d.ts +2 -1
- package/dist/es/src/components/DialogEmbed/index.d.ts +4 -1
- package/dist/es/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +1 -1
- package/dist/es/src/components/PlayerEmbed/index.d.ts +74 -0
- package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +1 -1
- package/dist/iife/dialog-embed/embed.iife.js +382 -353
- package/dist/iife/dialog-embed/embed.iife.js.map +1 -1
- package/dist/iife/embeds.iife.js +393 -364
- package/dist/iife/embeds.iife.js.map +1 -1
- package/dist/iife/player-embed/embed.iife.js +367 -340
- package/dist/iife/player-embed/embed.iife.js.map +1 -1
- package/package.json +34 -30
- package/src/components/DialogEmbed/Dialog.stories.ts +12 -0
- package/src/components/DialogEmbed/DialogOverlay.ts +2 -1
- package/src/components/DialogEmbed/DialogPortal.ts +22 -10
- package/src/components/DialogEmbed/index.ts +5 -1
- package/src/components/PlayerEmbed/controllers/tracking/utils.ts +1 -1
- package/src/components/PlayerEmbed/index.ts +106 -5
- package/src/components/PlayerEmbed/tests/data.ts +1 -1
- package/dist/es/browser-07a8b7dc.js +0 -433
- package/dist/es/browser-07a8b7dc.js.map +0 -1
- package/dist/es/index-0c298932.js +0 -10473
- package/dist/es/index-0c298932.js.map +0 -1
- package/dist/iife/dialog-embed/browser-450a324f.js +0 -433
- package/dist/iife/dialog-embed/browser-450a324f.js.map +0 -1
- package/dist/iife/dialog-embed/embed.js +0 -5
- package/dist/iife/dialog-embed/embed.js.map +0 -1
- package/dist/iife/dialog-embed/index-62750303.js +0 -32932
- package/dist/iife/dialog-embed/index-62750303.js.map +0 -1
- package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogOverlay.d.ts +0 -19
- package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogPortal.d.ts +0 -35
- package/dist/iife/dialog-embed/src/components/DialogEmbed/index.d.ts +0 -35
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +0 -15
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +0 -14
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +0 -36
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +0 -17
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/tests/data.d.ts +0 -3
- package/dist/iife/dialog-embed/src/index.d.ts +0 -2
- package/dist/iife/dialog-embed/src/utils/env.d.ts +0 -12
- package/dist/iife/dialog-embed/src/utils/events.d.ts +0 -2
- package/dist/iife/player-embed/browser-c51cdddb.js +0 -433
- package/dist/iife/player-embed/browser-c51cdddb.js.map +0 -1
- package/dist/iife/player-embed/embed.js +0 -5
- package/dist/iife/player-embed/embed.js.map +0 -1
- package/dist/iife/player-embed/index-0d71c577.js +0 -32489
- package/dist/iife/player-embed/index-0d71c577.js.map +0 -1
- package/dist/iife/player-embed/src/components/DialogEmbed/DialogOverlay.d.ts +0 -19
- package/dist/iife/player-embed/src/components/DialogEmbed/DialogPortal.d.ts +0 -35
- package/dist/iife/player-embed/src/components/DialogEmbed/index.d.ts +0 -35
- package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +0 -15
- package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +0 -14
- package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +0 -36
- package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +0 -17
- package/dist/iife/player-embed/src/components/PlayerEmbed/tests/data.d.ts +0 -3
- package/dist/iife/player-embed/src/index.d.ts +0 -2
- package/dist/iife/player-embed/src/utils/env.d.ts +0 -12
- package/dist/iife/player-embed/src/utils/events.d.ts +0 -2
- package/src/mixins/media-player-proxy.ts +0 -116
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vouchfor/embeds",
|
3
|
-
"version": "0.0.0-experiment.
|
3
|
+
"version": "0.0.0-experiment.f958e09",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": "Aaron Williams",
|
6
6
|
"main": "dist/es/embeds.js",
|
@@ -15,6 +15,9 @@
|
|
15
15
|
"tag": "experiment",
|
16
16
|
"access": "public"
|
17
17
|
},
|
18
|
+
"engines": {
|
19
|
+
"node": ">=18.18.0"
|
20
|
+
},
|
18
21
|
"scripts": {
|
19
22
|
"build": "rm -rf dist && tsc && yarn build:self",
|
20
23
|
"build:deps": "yarn --cwd ../media-player build",
|
@@ -39,45 +42,46 @@
|
|
39
42
|
"dependencies": {
|
40
43
|
"@a11y/focus-trap": "^1.0.5",
|
41
44
|
"@lit/task": "^1.0.0",
|
42
|
-
"@vouchfor/
|
45
|
+
"@vouchfor/canvas-video": "0.0.0-experiment.f958e09",
|
46
|
+
"@vouchfor/media-player": "0.0.0-experiment.f958e09",
|
43
47
|
"uuid": "^9.0.1"
|
44
48
|
},
|
45
49
|
"peerDependencies": {
|
46
|
-
"lit": "^3.1.
|
50
|
+
"lit": "^3.1.2"
|
47
51
|
},
|
48
52
|
"devDependencies": {
|
49
53
|
"@esm-bundle/chai": "^4.3.4-fix.0",
|
50
|
-
"@open-wc/testing": "^
|
51
|
-
"@storybook/addon-essentials": "^
|
52
|
-
"@storybook/addon-links": "^
|
53
|
-
"@storybook/blocks": "^
|
54
|
-
"@storybook/web-components": "^
|
55
|
-
"@storybook/web-components-vite": "^
|
56
|
-
"@
|
57
|
-
"@
|
58
|
-
"@
|
59
|
-
"@
|
60
|
-
"@
|
61
|
-
"@
|
62
|
-
"@web/
|
63
|
-
"@web/test-runner
|
64
|
-
"
|
65
|
-
"
|
66
|
-
"
|
54
|
+
"@open-wc/testing": "^4.0.0",
|
55
|
+
"@storybook/addon-essentials": "^8.0.4",
|
56
|
+
"@storybook/addon-links": "^8.0.4",
|
57
|
+
"@storybook/blocks": "^8.0.4",
|
58
|
+
"@storybook/web-components": "^8.0.4",
|
59
|
+
"@storybook/web-components-vite": "^8.0.4",
|
60
|
+
"@svgr/core": "^8.1.0",
|
61
|
+
"@types/flat": "^5.0.5",
|
62
|
+
"@types/mocha": "^10.0.6",
|
63
|
+
"@vouchfor/eslint-config": "^1.0.1",
|
64
|
+
"@vouchfor/prettier-config": "^1.0.1",
|
65
|
+
"@vouchfor/video-utils": "0.0.0-experiment.f958e09",
|
66
|
+
"@web/dev-server-esbuild": "^1.0.2",
|
67
|
+
"@web/test-runner": "^0.18.1",
|
68
|
+
"@web/test-runner-browserstack": "^0.7.1",
|
69
|
+
"@web/test-runner-mocha": "^0.9.0",
|
70
|
+
"@web/test-runner-playwright": "^0.11.0",
|
67
71
|
"glob": "^10.3.10",
|
68
|
-
"lint-staged": "^
|
69
|
-
"lit": "^3.1.
|
72
|
+
"lint-staged": "^15.2.2",
|
73
|
+
"lit": "^3.1.2",
|
70
74
|
"lodash": "^4.17.21",
|
71
|
-
"prettier": "^3.0.3",
|
72
75
|
"react": "^18.2.0",
|
73
76
|
"react-dom": "^18.2.0",
|
74
|
-
"rollup-plugin-
|
77
|
+
"rollup-plugin-tla": "^0.0.2",
|
75
78
|
"sinon": "^17.0.1",
|
76
|
-
"storybook": "^
|
77
|
-
"
|
78
|
-
"
|
79
|
-
"vite
|
80
|
-
"vite-plugin-
|
81
|
-
"
|
79
|
+
"storybook": "^8.0.4",
|
80
|
+
"svgson": "^5.3.1",
|
81
|
+
"typescript": "^5.4.3",
|
82
|
+
"vite": "^5.2.2",
|
83
|
+
"vite-plugin-commonjs": "^0.10.1",
|
84
|
+
"vite-plugin-dts": "^3.7.3",
|
85
|
+
"web-component-analyzer": "^2.0.0"
|
82
86
|
}
|
83
87
|
}
|
@@ -35,6 +35,18 @@ const _DialogEmbed = ({
|
|
35
35
|
aspectRatio=${ifDefined(aspectRatio)}
|
36
36
|
@error=${console.log}
|
37
37
|
></vouch-embed-dialog>
|
38
|
+
<vouch-embed-dialog
|
39
|
+
env=${ifDefined(env)}
|
40
|
+
apiKey=${ifDefined(apiKey)}
|
41
|
+
vouchId=${ifDefined(vouchId)}
|
42
|
+
templateId=${ifDefined(templateId)}
|
43
|
+
.questions=${questions}
|
44
|
+
.controls=${controls}
|
45
|
+
?autoplay=${autoplay}
|
46
|
+
preload=${ifDefined(preload)}
|
47
|
+
aspectRatio=${ifDefined(aspectRatio)}
|
48
|
+
@error=${console.log}
|
49
|
+
></vouch-embed-dialog>
|
38
50
|
</div>
|
39
51
|
`;
|
40
52
|
};
|
@@ -21,10 +21,11 @@ class DialogOverlay extends LitElement {
|
|
21
21
|
}
|
22
22
|
|
23
23
|
.container {
|
24
|
-
position:
|
24
|
+
position: fixed;
|
25
25
|
display: flex;
|
26
26
|
inset: 0;
|
27
27
|
opacity: 1;
|
28
|
+
z-index: 2147483647;
|
28
29
|
align-items: center;
|
29
30
|
justify-content: center;
|
30
31
|
transition: opacity 100ms ease-in;
|
@@ -29,19 +29,25 @@ class DialogPortal extends LitElement {
|
|
29
29
|
|
30
30
|
@state() open = false;
|
31
31
|
|
32
|
-
private _handleToggle = () => {
|
33
|
-
this
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
private _handleToggle = ({ detail }: CustomEvent<string>) => {
|
33
|
+
// Because we have to attach this listener to the document since this element is portalled outside of the button,
|
34
|
+
// we also have to make sure that this player is actually the one we want to open and play by passing in an ID
|
35
|
+
// from the button wrapper parent and checking against that same ID we pass as the event detail
|
36
|
+
if (this.id === detail) {
|
37
|
+
this.open = !this.open;
|
38
|
+
|
39
|
+
if (this.open) {
|
40
|
+
if (!this.disableAutoplay && this._mediaPlayerRef?.value) {
|
41
|
+
this._mediaPlayerRef.value.muted = false;
|
42
|
+
this._mediaPlayerRef.value.play();
|
43
|
+
}
|
44
|
+
} else {
|
45
|
+
this._mediaPlayerRef?.value?.pause();
|
39
46
|
}
|
40
|
-
} else {
|
41
|
-
this._mediaPlayerRef?.value?.pause();
|
42
47
|
}
|
43
48
|
};
|
44
49
|
|
50
|
+
// We could do the same thing on close and check for the correct ID but it doesn't really matter
|
45
51
|
private _handleClose = () => {
|
46
52
|
this.open = false;
|
47
53
|
this._mediaPlayerRef?.value?.pause();
|
@@ -70,7 +76,13 @@ class DialogPortal extends LitElement {
|
|
70
76
|
}
|
71
77
|
|
72
78
|
protected createRenderRoot(): HTMLElement | DocumentFragment {
|
73
|
-
|
79
|
+
// We must create a new node here because portalling into the same node (document.body) causes the second
|
80
|
+
// element to overwrite the first for some reason (not behaviour really stated in the docs)
|
81
|
+
// I am fairly certain this function is only run once as the default behaviour creates the open shadow root
|
82
|
+
// and returns that shadow root in this function: https://lit.dev/docs/components/shadow-dom/#implementing-createrenderroot
|
83
|
+
const newNode = document.createElement('div');
|
84
|
+
document.body.appendChild(newNode);
|
85
|
+
return newNode;
|
74
86
|
}
|
75
87
|
|
76
88
|
render() {
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { css, html, LitElement } from 'lit';
|
2
2
|
import { customElement, property } from 'lit/decorators.js';
|
3
3
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
4
|
+
import { v4 as uuidv4 } from 'uuid';
|
4
5
|
|
5
6
|
import type { PlayerEmbedProps } from '../PlayerEmbed';
|
6
7
|
|
@@ -41,8 +42,10 @@ class DialogEmbed extends LitElement {
|
|
41
42
|
@property({ type: Boolean }) disableAutoplay: DialogEmbedProps['disableAutoplay'] = false;
|
42
43
|
@property({ type: Number }) aspectRatio: DialogEmbedProps['aspectRatio'] = 0;
|
43
44
|
|
45
|
+
private _id = uuidv4();
|
46
|
+
|
44
47
|
private _handleRootClick = () => {
|
45
|
-
this.dispatchEvent(new CustomEvent('dialogembed:click', { bubbles: true, composed: true }));
|
48
|
+
this.dispatchEvent(new CustomEvent('dialogembed:click', { detail: this._id, bubbles: true, composed: true }));
|
46
49
|
};
|
47
50
|
|
48
51
|
connectedCallback(): void {
|
@@ -61,6 +64,7 @@ class DialogEmbed extends LitElement {
|
|
61
64
|
<vmp-button size="large">Play</vmp-button>
|
62
65
|
</slot>
|
63
66
|
<vouch-embed-dialog-portal
|
67
|
+
id=${this._id}
|
64
68
|
?autoplay=${false}
|
65
69
|
vouchId=${ifDefined(this.vouchId)}
|
66
70
|
templateId=${ifDefined(this.templateId)}
|
@@ -2,7 +2,7 @@ import { TEMPLATE_VERSION } from '@vouchfor/canvas-video';
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
3
3
|
|
4
4
|
import type { TrackingPayload } from '.';
|
5
|
-
import type { Vouch } from '@vouchfor/
|
5
|
+
import type { Vouch } from '@vouchfor/video-utils';
|
6
6
|
import type { Environment } from '~/utils/env';
|
7
7
|
|
8
8
|
import packageJson from '~/../package.json';
|
@@ -1,16 +1,15 @@
|
|
1
1
|
import { css, html, LitElement } from 'lit';
|
2
2
|
import { customElement, property, state } from 'lit/decorators.js';
|
3
3
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
4
|
-
import { ref } from 'lit/directives/ref.js';
|
4
|
+
import { createRef, ref } from 'lit/directives/ref.js';
|
5
5
|
|
6
|
-
import type { TemplateInstance } from '@vouchfor/canvas-video';
|
7
|
-
import type { MediaPlayerProps } from '@vouchfor/media-player';
|
6
|
+
import type { Scene, Scenes, TemplateInstance } from '@vouchfor/canvas-video';
|
7
|
+
import type { MediaPlayer, MediaPlayerProps } from '@vouchfor/media-player';
|
8
8
|
import type { Environment } from '~/utils/env';
|
9
9
|
|
10
10
|
import { EventForwardController } from './controllers/event-forwarder';
|
11
11
|
import { FetcherController } from './controllers/fetcher';
|
12
12
|
import { TrackingController } from './controllers/tracking';
|
13
|
-
import { MediaPlayerProxy } from '~/mixins/media-player-proxy';
|
14
13
|
|
15
14
|
import '@vouchfor/media-player';
|
16
15
|
|
@@ -26,7 +25,7 @@ type PlayerEmbedProps = Pick<MediaPlayerProps, 'data' | 'aspectRatio' | 'preload
|
|
26
25
|
};
|
27
26
|
|
28
27
|
@customElement('vouch-embed-player')
|
29
|
-
class PlayerEmbed extends
|
28
|
+
class PlayerEmbed extends LitElement {
|
30
29
|
static styles = [
|
31
30
|
css`
|
32
31
|
:host {
|
@@ -90,6 +89,108 @@ class PlayerEmbed extends MediaPlayerProxy(LitElement) {
|
|
90
89
|
return this._fetcherController.fetching;
|
91
90
|
}
|
92
91
|
|
92
|
+
private _mediaPlayerRef = createRef<MediaPlayer>();
|
93
|
+
|
94
|
+
get waiting() {
|
95
|
+
return this._mediaPlayerRef.value?.waiting;
|
96
|
+
}
|
97
|
+
|
98
|
+
get initialised() {
|
99
|
+
return this._mediaPlayerRef.value?.initialised;
|
100
|
+
}
|
101
|
+
|
102
|
+
get seeking() {
|
103
|
+
return this._mediaPlayerRef.value?.seeking;
|
104
|
+
}
|
105
|
+
|
106
|
+
get paused() {
|
107
|
+
return this._mediaPlayerRef.value?.paused;
|
108
|
+
}
|
109
|
+
|
110
|
+
get captions() {
|
111
|
+
return this._mediaPlayerRef.value?.captions;
|
112
|
+
}
|
113
|
+
|
114
|
+
get fullscreen() {
|
115
|
+
return this._mediaPlayerRef.value?.fullscreen;
|
116
|
+
}
|
117
|
+
|
118
|
+
get duration() {
|
119
|
+
return this._mediaPlayerRef.value?.duration;
|
120
|
+
}
|
121
|
+
|
122
|
+
set currentTime(value: number) {
|
123
|
+
if (this._mediaPlayerRef.value) {
|
124
|
+
this._mediaPlayerRef.value.currentTime = value;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
get currentTime() {
|
128
|
+
return this._mediaPlayerRef.value?.currentTime ?? 0;
|
129
|
+
}
|
130
|
+
|
131
|
+
set playbackRate(value: number) {
|
132
|
+
if (this._mediaPlayerRef.value) {
|
133
|
+
this._mediaPlayerRef.value.playbackRate = value;
|
134
|
+
}
|
135
|
+
}
|
136
|
+
get playbackRate() {
|
137
|
+
return this._mediaPlayerRef.value?.playbackRate ?? 1;
|
138
|
+
}
|
139
|
+
|
140
|
+
set volume(value: number) {
|
141
|
+
if (this._mediaPlayerRef.value) {
|
142
|
+
this._mediaPlayerRef.value.volume = value;
|
143
|
+
}
|
144
|
+
}
|
145
|
+
get volume() {
|
146
|
+
return this._mediaPlayerRef.value?.volume ?? 1;
|
147
|
+
}
|
148
|
+
|
149
|
+
set muted(value: boolean) {
|
150
|
+
if (this._mediaPlayerRef.value) {
|
151
|
+
this._mediaPlayerRef.value.muted = value;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
get muted() {
|
155
|
+
return this._mediaPlayerRef.value?.muted ?? false;
|
156
|
+
}
|
157
|
+
|
158
|
+
get scene(): Scene | null {
|
159
|
+
return this._mediaPlayerRef.value?.scene ?? null;
|
160
|
+
}
|
161
|
+
|
162
|
+
get scenes(): Scene[] {
|
163
|
+
return this._mediaPlayerRef.value?.scenes ?? [];
|
164
|
+
}
|
165
|
+
|
166
|
+
get sceneConfig(): Scenes | null {
|
167
|
+
return this._mediaPlayerRef.value?.sceneConfig ?? null;
|
168
|
+
}
|
169
|
+
|
170
|
+
get videoState() {
|
171
|
+
return this._mediaPlayerRef.value?.videoState;
|
172
|
+
}
|
173
|
+
|
174
|
+
get mediaPlayer() {
|
175
|
+
return this._mediaPlayerRef.value;
|
176
|
+
}
|
177
|
+
|
178
|
+
play() {
|
179
|
+
this._mediaPlayerRef.value?.play();
|
180
|
+
}
|
181
|
+
|
182
|
+
pause() {
|
183
|
+
this._mediaPlayerRef.value?.pause();
|
184
|
+
}
|
185
|
+
|
186
|
+
reset(time = 0, play = false) {
|
187
|
+
this._mediaPlayerRef.value?.reset(time, play);
|
188
|
+
}
|
189
|
+
|
190
|
+
setScene(index: number) {
|
191
|
+
this._mediaPlayerRef.value?.setScene(index);
|
192
|
+
}
|
193
|
+
|
93
194
|
private _renderStyles() {
|
94
195
|
if (!this.aspectRatio) {
|
95
196
|
return html`
|