@vouchfor/embeds 0.0.0-experiment.401abc6 → 0.0.0-experiment.40b39e3
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 +17 -121
- package/dist/es/embeds.js.map +1 -1
- package/dist/es/src/components/DialogEmbed/DialogOverlay.d.ts +4 -4
- package/dist/es/src/components/DialogEmbed/DialogPortal.d.ts +3 -3
- package/dist/es/src/components/DialogEmbed/index.d.ts +4 -5
- package/dist/es/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +4 -3
- package/dist/es/src/components/PlayerEmbed/controllers/fetcher.d.ts +3 -2
- package/dist/es/src/components/PlayerEmbed/controllers/tracking/index.d.ts +4 -2
- package/dist/es/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +4 -3
- package/dist/es/src/components/PlayerEmbed/index.d.ts +11 -10
- package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +2 -1
- package/dist/iife/dialog-embed/embed.iife.js +276 -240
- package/dist/iife/dialog-embed/embed.iife.js.map +1 -1
- package/dist/iife/embeds.iife.js +273 -237
- package/dist/iife/embeds.iife.js.map +1 -1
- package/dist/iife/player-embed/embed.iife.js +241 -205
- package/dist/iife/player-embed/embed.iife.js.map +1 -1
- package/package.json +29 -28
- package/src/components/PlayerEmbed/PlayerEmbed.stories.ts +3 -1
- package/src/components/PlayerEmbed/controllers/tracking/index.ts +8 -8
- package/src/components/PlayerEmbed/index.ts +5 -2
- package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +5 -5
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.40b39e3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Aaron Williams",
|
|
6
6
|
"main": "dist/es/embeds.js",
|
|
@@ -31,10 +31,11 @@
|
|
|
31
31
|
"prepublishOnly": "yarn build",
|
|
32
32
|
"size": "size-limit",
|
|
33
33
|
"storybook": "yarn prebuild && storybook dev -p 6007",
|
|
34
|
-
"prebuild": "yarn
|
|
34
|
+
"prebuild": "yarn generate:manifest",
|
|
35
35
|
"test": "rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner",
|
|
36
36
|
"test:ci": "yarn test --config web-test-runner.ci.config.js",
|
|
37
|
-
"test:watch": "yarn test --watch"
|
|
37
|
+
"test:watch": "yarn test --watch",
|
|
38
|
+
"typecheck": "tsc --noEmit"
|
|
38
39
|
},
|
|
39
40
|
"lint-staged": {
|
|
40
41
|
"**/*.{ts,tsx,js}": "eslint --fix --quiet",
|
|
@@ -42,47 +43,47 @@
|
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
45
|
"@a11y/focus-trap": "^1.0.5",
|
|
45
|
-
"@lit/task": "^1.0.
|
|
46
|
-
"@vouchfor/canvas-video": "0.0.0-experiment.
|
|
47
|
-
"@vouchfor/media-player": "0.0.0-experiment.
|
|
46
|
+
"@lit/task": "^1.0.2",
|
|
47
|
+
"@vouchfor/canvas-video": "0.0.0-experiment.40b39e3",
|
|
48
|
+
"@vouchfor/media-player": "0.0.0-experiment.40b39e3",
|
|
48
49
|
"uuid": "^9.0.1"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
52
|
"lit": "^3.1.2"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"@esm-bundle/chai": "^4.3.4
|
|
55
|
+
"@esm-bundle/chai": "^4.3.4",
|
|
55
56
|
"@open-wc/testing": "^4.0.0",
|
|
56
|
-
"@storybook/addon-essentials": "^8.
|
|
57
|
-
"@storybook/addon-links": "^8.
|
|
58
|
-
"@storybook/blocks": "^8.
|
|
59
|
-
"@storybook/web-components": "^8.
|
|
60
|
-
"@storybook/web-components-vite": "^8.
|
|
57
|
+
"@storybook/addon-essentials": "^8.6.12",
|
|
58
|
+
"@storybook/addon-links": "^8.6.12",
|
|
59
|
+
"@storybook/blocks": "^8.6.12",
|
|
60
|
+
"@storybook/web-components": "^8.6.12",
|
|
61
|
+
"@storybook/web-components-vite": "^8.6.12",
|
|
61
62
|
"@svgr/core": "^8.1.0",
|
|
62
63
|
"@types/flat": "^5.0.5",
|
|
63
|
-
"@types/mocha": "^10.0.
|
|
64
|
-
"@vouchfor/eslint-config": "^1.0.
|
|
64
|
+
"@types/mocha": "^10.0.10",
|
|
65
|
+
"@vouchfor/eslint-config": "^1.0.5",
|
|
65
66
|
"@vouchfor/prettier-config": "^1.0.1",
|
|
66
|
-
"@vouchfor/video-utils": "0.0.0-experiment.
|
|
67
|
-
"@web/dev-server-esbuild": "^1.0.
|
|
68
|
-
"@web/test-runner": "^0.
|
|
69
|
-
"@web/test-runner-browserstack": "^0.
|
|
67
|
+
"@vouchfor/video-utils": "0.0.0-experiment.40b39e3",
|
|
68
|
+
"@web/dev-server-esbuild": "^1.0.4",
|
|
69
|
+
"@web/test-runner": "^0.20.1",
|
|
70
|
+
"@web/test-runner-browserstack": "^0.8.0",
|
|
70
71
|
"@web/test-runner-mocha": "^0.9.0",
|
|
71
72
|
"@web/test-runner-playwright": "^0.11.0",
|
|
72
|
-
"glob": "^10.
|
|
73
|
-
"lint-staged": "^15.
|
|
74
|
-
"lit": "^3.
|
|
73
|
+
"glob": "^10.4.5",
|
|
74
|
+
"lint-staged": "^15.5.1",
|
|
75
|
+
"lit": "^3.3.0",
|
|
75
76
|
"lodash": "^4.17.21",
|
|
76
|
-
"react": "^18.
|
|
77
|
-
"react-dom": "^18.
|
|
77
|
+
"react": "^18.3.1",
|
|
78
|
+
"react-dom": "^18.3.1",
|
|
78
79
|
"rollup-plugin-tla": "^0.0.2",
|
|
79
80
|
"sinon": "^17.0.1",
|
|
80
|
-
"storybook": "^8.
|
|
81
|
+
"storybook": "^8.6.12",
|
|
81
82
|
"svgson": "^5.3.1",
|
|
82
|
-
"typescript": "^5.
|
|
83
|
-
"vite": "^5.
|
|
84
|
-
"vite-plugin-commonjs": "^0.10.
|
|
85
|
-
"vite-plugin-dts": "^3.
|
|
83
|
+
"typescript": "^5.8.3",
|
|
84
|
+
"vite": "^5.4.18",
|
|
85
|
+
"vite-plugin-commonjs": "^0.10.4",
|
|
86
|
+
"vite-plugin-dts": "^3.9.1",
|
|
86
87
|
"web-component-analyzer": "^2.0.0"
|
|
87
88
|
}
|
|
88
89
|
}
|
|
@@ -19,7 +19,8 @@ const _PlayerEmbed = ({
|
|
|
19
19
|
env,
|
|
20
20
|
apiKey,
|
|
21
21
|
controls,
|
|
22
|
-
aspectRatio
|
|
22
|
+
aspectRatio,
|
|
23
|
+
senderId
|
|
23
24
|
}: PlayerEmbedArgs) => {
|
|
24
25
|
return html`
|
|
25
26
|
<div style="height: 100vh">
|
|
@@ -33,6 +34,7 @@ const _PlayerEmbed = ({
|
|
|
33
34
|
?autoplay=${autoplay}
|
|
34
35
|
preload=${ifDefined(preload)}
|
|
35
36
|
aspectRatio=${ifDefined(aspectRatio)}
|
|
37
|
+
senderId=${ifDefined(senderId)}
|
|
36
38
|
@error=${console.log}
|
|
37
39
|
></vouch-embed-player>
|
|
38
40
|
</div>
|
|
@@ -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';
|
|
@@ -15,6 +15,7 @@ type TrackingPayload = {
|
|
|
15
15
|
answerId?: string;
|
|
16
16
|
streamStart?: number;
|
|
17
17
|
streamEnd?: number;
|
|
18
|
+
senderId?: string;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
type BatchEvent = {
|
|
@@ -41,7 +42,7 @@ class TrackingController implements ReactiveController {
|
|
|
41
42
|
private _answersViewed: BooleanMap = {};
|
|
42
43
|
private _streamStartTime: TimeMap = {};
|
|
43
44
|
private _streamLatestTime: TimeMap = {};
|
|
44
|
-
private _currentlyPlayingVideo:
|
|
45
|
+
private _currentlyPlayingVideo: MediaEventDetail | null = null;
|
|
45
46
|
|
|
46
47
|
constructor(host: PlayerEmbedHost) {
|
|
47
48
|
this.host = host;
|
|
@@ -59,6 +60,7 @@ class TrackingController implements ReactiveController {
|
|
|
59
60
|
event,
|
|
60
61
|
payload: {
|
|
61
62
|
...payload,
|
|
63
|
+
senderId: this.host.senderId,
|
|
62
64
|
vouchId,
|
|
63
65
|
time: new Date().toISOString()
|
|
64
66
|
}
|
|
@@ -127,14 +129,12 @@ class TrackingController implements ReactiveController {
|
|
|
127
129
|
private _handlePlay = () => {
|
|
128
130
|
// Only send the video played event once per session
|
|
129
131
|
if (!this._hasPlayed) {
|
|
130
|
-
this._createTrackingEvent('VIDEO_PLAYED', {
|
|
131
|
-
streamStart: this.host.currentTime
|
|
132
|
-
});
|
|
132
|
+
this._createTrackingEvent('VIDEO_PLAYED', { streamStart: this.host.currentTime });
|
|
133
133
|
this._hasPlayed = true;
|
|
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,7 +144,7 @@ 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
150
|
!this.host.paused
|
|
@@ -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,
|
|
@@ -25,6 +25,7 @@ type PlayerEmbedProps = Pick<MediaPlayerProps, 'aspectRatio' | 'language' | 'pre
|
|
|
25
25
|
templateId?: string;
|
|
26
26
|
// Index of the questions to include starting from 1
|
|
27
27
|
questions?: number[];
|
|
28
|
+
senderId?: string;
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
@customElement('vouch-embed-player')
|
|
@@ -52,6 +53,7 @@ class PlayerEmbed extends LitElement {
|
|
|
52
53
|
@property({ type: Boolean }) autoplay: PlayerEmbedProps['autoplay'] = false;
|
|
53
54
|
@property({ type: Number }) aspectRatio: PlayerEmbedProps['aspectRatio'] = 0;
|
|
54
55
|
@property({ type: String }) language?: MediaPlayerProps['language'];
|
|
56
|
+
@property({ type: String }) senderId?: PlayerEmbedProps['senderId'];
|
|
55
57
|
|
|
56
58
|
private eventController = new EventForwardController(this, [
|
|
57
59
|
'durationchange',
|
|
@@ -78,6 +80,7 @@ class PlayerEmbed extends LitElement {
|
|
|
78
80
|
'video:play',
|
|
79
81
|
'video:playing',
|
|
80
82
|
'video:pause',
|
|
83
|
+
'video:waiting',
|
|
81
84
|
'video:stalled',
|
|
82
85
|
'video:timeupdate',
|
|
83
86
|
'video:ended',
|
|
@@ -173,8 +176,8 @@ class PlayerEmbed extends LitElement {
|
|
|
173
176
|
// return this._mediaPlayerRef.value?.sceneConfig ?? null;
|
|
174
177
|
// }
|
|
175
178
|
|
|
176
|
-
get
|
|
177
|
-
return this._mediaPlayerRef.value?.
|
|
179
|
+
get mediaState() {
|
|
180
|
+
return this._mediaPlayerRef.value?.mediaState;
|
|
178
181
|
}
|
|
179
182
|
|
|
180
183
|
get mediaPlayer() {
|
|
@@ -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
|
|
|
@@ -45,14 +45,14 @@ describe.skip('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();
|