@vouchfor/embeds 0.0.0-experiment.e075b1c → 0.0.0-experiment.e08b50d
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/es/embeds.js +19 -27
- package/dist/es/embeds.js.map +1 -1
- package/dist/es/src/components/PlayerEmbed/index.d.ts +5 -7
- package/dist/iife/dialog-embed/embed.iife.js +2604 -321
- package/dist/iife/dialog-embed/embed.iife.js.map +1 -1
- package/dist/iife/embeds.iife.js +2604 -321
- package/dist/iife/embeds.iife.js.map +1 -1
- package/dist/iife/player-embed/embed.iife.js +2581 -298
- package/dist/iife/player-embed/embed.iife.js.map +1 -1
- package/package.json +4 -4
- package/src/components/PlayerEmbed/controllers/tracking/index.ts +7 -7
- package/src/components/PlayerEmbed/index.ts +18 -21
- package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +6 -6
- package/src/components/PlayerEmbed/tests/data.ts +6 -3
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.e08b50d",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": "Aaron Williams",
|
6
6
|
"main": "dist/es/embeds.js",
|
@@ -43,8 +43,8 @@
|
|
43
43
|
"dependencies": {
|
44
44
|
"@a11y/focus-trap": "^1.0.5",
|
45
45
|
"@lit/task": "^1.0.0",
|
46
|
-
"@vouchfor/canvas-video": "0.0.0-experiment.
|
47
|
-
"@vouchfor/media-player": "0.0.0-experiment.
|
46
|
+
"@vouchfor/canvas-video": "0.0.0-experiment.e08b50d",
|
47
|
+
"@vouchfor/media-player": "0.0.0-experiment.e08b50d",
|
48
48
|
"uuid": "^9.0.1"
|
49
49
|
},
|
50
50
|
"peerDependencies": {
|
@@ -63,7 +63,7 @@
|
|
63
63
|
"@types/mocha": "^10.0.6",
|
64
64
|
"@vouchfor/eslint-config": "^1.0.1",
|
65
65
|
"@vouchfor/prettier-config": "^1.0.1",
|
66
|
-
"@vouchfor/video-utils": "0.0.0-experiment.
|
66
|
+
"@vouchfor/video-utils": "0.0.0-experiment.e08b50d",
|
67
67
|
"@web/dev-server-esbuild": "^1.0.2",
|
68
68
|
"@web/test-runner": "^0.18.1",
|
69
69
|
"@web/test-runner-browserstack": "^0.7.1",
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { PlayerEmbed } from '../..';
|
2
|
-
import type {
|
2
|
+
import type { MediaEventDetail } from '@vouchfor/media-player';
|
3
3
|
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
4
4
|
|
5
5
|
import { findVouchId, getReportingMetadata, getUids } from './utils';
|
@@ -41,7 +41,7 @@ class TrackingController implements ReactiveController {
|
|
41
41
|
private _answersViewed: BooleanMap = {};
|
42
42
|
private _streamStartTime: TimeMap = {};
|
43
43
|
private _streamLatestTime: TimeMap = {};
|
44
|
-
private _currentlyPlayingVideo:
|
44
|
+
private _currentlyPlayingVideo: MediaEventDetail | null = null;
|
45
45
|
|
46
46
|
constructor(host: PlayerEmbedHost) {
|
47
47
|
this.host = host;
|
@@ -134,7 +134,7 @@ class TrackingController implements ReactiveController {
|
|
134
134
|
}
|
135
135
|
};
|
136
136
|
|
137
|
-
private _handleVideoPlay = ({ detail: { id, key } }: CustomEvent<
|
137
|
+
private _handleVideoPlay = ({ detail: { id, key } }: CustomEvent<MediaEventDetail>) => {
|
138
138
|
// Only increment play count once per session
|
139
139
|
if (!this._answersViewed[key]) {
|
140
140
|
this._createTrackingEvent('VOUCH_RESPONSE_VIEWED', {
|
@@ -144,12 +144,12 @@ class TrackingController implements ReactiveController {
|
|
144
144
|
}
|
145
145
|
};
|
146
146
|
|
147
|
-
private _handleVideoTimeUpdate = ({ detail: { id, key, node } }: CustomEvent<
|
147
|
+
private _handleVideoTimeUpdate = ({ detail: { id, key, node } }: CustomEvent<MediaEventDetail>) => {
|
148
148
|
if (
|
149
149
|
// We only want to count any time that the video is actually playing
|
150
|
-
!this.host.paused
|
150
|
+
!this.host.paused
|
151
151
|
// Only update the latest time if this event fires for the currently active video
|
152
|
-
id === this.host.scene?.video?.id
|
152
|
+
// id === this.host.scene?.video?.id
|
153
153
|
) {
|
154
154
|
this._currentlyPlayingVideo = { id, key, node };
|
155
155
|
this._streamLatestTime[key] = node.currentTime;
|
@@ -161,7 +161,7 @@ class TrackingController implements ReactiveController {
|
|
161
161
|
}
|
162
162
|
};
|
163
163
|
|
164
|
-
private _handleVideoPause = ({ detail: { id, key } }: CustomEvent<
|
164
|
+
private _handleVideoPause = ({ detail: { id, key } }: CustomEvent<MediaEventDetail>) => {
|
165
165
|
if (this._streamLatestTime[key] > this._streamStartTime[key] + MINIMUM_SEND_THRESHOLD) {
|
166
166
|
this._createTrackingEvent('VIDEO_STREAMED', {
|
167
167
|
answerId: id,
|
@@ -3,8 +3,9 @@ import { customElement, property, state } from 'lit/decorators.js';
|
|
3
3
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
4
4
|
import { createRef, ref } from 'lit/directives/ref.js';
|
5
5
|
|
6
|
-
import type {
|
6
|
+
import type { TemplateInstance } from '@vouchfor/canvas-video';
|
7
7
|
import type { MediaPlayer, MediaPlayerProps } from '@vouchfor/media-player';
|
8
|
+
import type { Vouch } from '@vouchfor/video-utils';
|
8
9
|
import type { PropertyValueMap } from 'lit';
|
9
10
|
import type { Environment } from '~/utils/env';
|
10
11
|
|
@@ -14,10 +15,8 @@ import { TrackingController } from './controllers/tracking';
|
|
14
15
|
|
15
16
|
import '@vouchfor/media-player';
|
16
17
|
|
17
|
-
type PlayerEmbedProps = Pick<
|
18
|
-
|
19
|
-
'data' | 'aspectRatio' | 'language' | 'preload' | 'autoplay' | 'controls'
|
20
|
-
> & {
|
18
|
+
type PlayerEmbedProps = Pick<MediaPlayerProps, 'aspectRatio' | 'language' | 'preload' | 'autoplay' | 'controls'> & {
|
19
|
+
data?: Vouch;
|
21
20
|
env: Environment;
|
22
21
|
apiKey: string;
|
23
22
|
disableTracking?: boolean;
|
@@ -162,20 +161,20 @@ class PlayerEmbed extends LitElement {
|
|
162
161
|
return this._mediaPlayerRef.value?.muted ?? false;
|
163
162
|
}
|
164
163
|
|
165
|
-
get scene(): Scene | null {
|
166
|
-
|
167
|
-
}
|
164
|
+
// get scene(): Scene | null {
|
165
|
+
// return this._mediaPlayerRef.value?.scene ?? null;
|
166
|
+
// }
|
168
167
|
|
169
|
-
get scenes(): Scene[] {
|
170
|
-
|
171
|
-
}
|
168
|
+
// get scenes(): Scene[] {
|
169
|
+
// return this._mediaPlayerRef.value?.scenes ?? [];
|
170
|
+
// }
|
172
171
|
|
173
|
-
get sceneConfig(): Scenes | null {
|
174
|
-
|
175
|
-
}
|
172
|
+
// get sceneConfig(): Scenes | null {
|
173
|
+
// return this._mediaPlayerRef.value?.sceneConfig ?? null;
|
174
|
+
// }
|
176
175
|
|
177
|
-
get
|
178
|
-
return this._mediaPlayerRef.value?.
|
176
|
+
get mediaState() {
|
177
|
+
return this._mediaPlayerRef.value?.mediaState;
|
179
178
|
}
|
180
179
|
|
181
180
|
get mediaPlayer() {
|
@@ -194,9 +193,9 @@ class PlayerEmbed extends LitElement {
|
|
194
193
|
this._mediaPlayerRef.value?.reset(time, play);
|
195
194
|
}
|
196
195
|
|
197
|
-
setScene(index: number) {
|
198
|
-
|
199
|
-
}
|
196
|
+
// setScene(index: number) {
|
197
|
+
// this._mediaPlayerRef.value?.setScene(index);
|
198
|
+
// }
|
200
199
|
|
201
200
|
private _renderStyles() {
|
202
201
|
if (!this.aspectRatio) {
|
@@ -238,8 +237,6 @@ class PlayerEmbed extends LitElement {
|
|
238
237
|
${this.eventController.register()}
|
239
238
|
?autoplay=${this.autoplay}
|
240
239
|
?loading=${this.fetching}
|
241
|
-
.data=${this.vouch}
|
242
|
-
.template=${this.template}
|
243
240
|
aspectRatio=${ifDefined(this.aspectRatio)}
|
244
241
|
preload=${ifDefined(this.preload)}
|
245
242
|
language=${ifDefined(this.language)}
|
@@ -4,7 +4,7 @@ import { html } from 'lit';
|
|
4
4
|
import sinon from 'sinon';
|
5
5
|
|
6
6
|
import type { PlayerEmbed } from '../index.js';
|
7
|
-
import type {
|
7
|
+
import type { MediaMap } from '@vouchfor/media-player';
|
8
8
|
|
9
9
|
import { data } from './data.js';
|
10
10
|
|
@@ -13,7 +13,7 @@ import { data } from './data.js';
|
|
13
13
|
// https://modern-web.dev/guides/test-runner/typescript/
|
14
14
|
import '../../../test/lib/embeds.js';
|
15
15
|
|
16
|
-
function getVideo(videos:
|
16
|
+
function getVideo(videos: MediaMap) {
|
17
17
|
return Object.values(videos)[0];
|
18
18
|
}
|
19
19
|
|
@@ -27,7 +27,7 @@ function playerLoaded(player: PlayerEmbed) {
|
|
27
27
|
);
|
28
28
|
}
|
29
29
|
|
30
|
-
describe('Embeds', () => {
|
30
|
+
describe.skip('Embeds', () => {
|
31
31
|
it('Sends correct tracking events', async () => {
|
32
32
|
const player = await fixture<PlayerEmbed>(
|
33
33
|
html`<vouch-embed-player env="dev" .data=${data} aspectratio=${1}></vouch-embed-player>`
|
@@ -45,14 +45,14 @@ describe('Embeds', () => {
|
|
45
45
|
await waitUntil(
|
46
46
|
() => {
|
47
47
|
// Video plays for 3 seconds
|
48
|
-
return (getVideo(player.mediaPlayer!.
|
48
|
+
return (getVideo(player.mediaPlayer!.media)?.node?.currentTime ?? 0) > 3;
|
49
49
|
},
|
50
50
|
'Video did not play for 3 seconds',
|
51
51
|
{ timeout: 20000 }
|
52
52
|
);
|
53
|
-
expect(getVideo(player.mediaPlayer!.
|
53
|
+
expect(getVideo(player.mediaPlayer!.media)?.node?.paused).eq(false);
|
54
54
|
player.pause();
|
55
|
-
expect(getVideo(player.mediaPlayer!.
|
55
|
+
expect(getVideo(player.mediaPlayer!.media)?.node?.paused).eq(true);
|
56
56
|
expect(sendTrackingSpy.callCount).to.be.eq(0);
|
57
57
|
// Destroy node because events are sent when node is removed from the document
|
58
58
|
player.remove();
|
@@ -65,7 +65,8 @@ const data: Vouch = {
|
|
65
65
|
language: 'en',
|
66
66
|
translation: {
|
67
67
|
language: 'ja'
|
68
|
-
}
|
68
|
+
},
|
69
|
+
items: []
|
69
70
|
}
|
70
71
|
}
|
71
72
|
},
|
@@ -114,7 +115,8 @@ const data: Vouch = {
|
|
114
115
|
language: 'en',
|
115
116
|
translation: {
|
116
117
|
language: 'fr'
|
117
|
-
}
|
118
|
+
},
|
119
|
+
items: []
|
118
120
|
}
|
119
121
|
}
|
120
122
|
},
|
@@ -158,7 +160,8 @@ const data: Vouch = {
|
|
158
160
|
language: 'en',
|
159
161
|
translation: {
|
160
162
|
language: 'de'
|
161
|
-
}
|
163
|
+
},
|
164
|
+
items: []
|
162
165
|
}
|
163
166
|
}
|
164
167
|
},
|