@vouchfor/embeds 0.0.0-experiment.d892f46 → 0.0.0-experiment.d8c5de1
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 +109 -101
- package/dist/es/embeds.js.map +1 -1
- package/dist/es/src/components/Embed/controllers/tracking.d.ts +2 -0
- package/dist/es/src/components/Embed/index.d.ts +2 -1
- package/dist/iife/embeds.iife.js +261 -157
- package/dist/iife/embeds.iife.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Embed/Embed.stories.ts +1 -0
- package/src/components/Embed/controllers/tracking.ts +25 -5
- package/src/components/Embed/index.ts +5 -1
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.d8c5de1",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": "Aaron Williams",
|
6
6
|
"main": "dist/es/embeds.js",
|
@@ -36,7 +36,7 @@
|
|
36
36
|
},
|
37
37
|
"dependencies": {
|
38
38
|
"@lit/task": "^1.0.0",
|
39
|
-
"@vouchfor/media-player": "0.0.0-experiment.
|
39
|
+
"@vouchfor/media-player": "0.0.0-experiment.d8c5de1",
|
40
40
|
"uuid": "^9.0.1"
|
41
41
|
},
|
42
42
|
"peerDependencies": {
|
@@ -142,7 +142,7 @@ class TrackingController implements ReactiveController {
|
|
142
142
|
const { client, tab, request, visitor } = this._getUids();
|
143
143
|
|
144
144
|
navigator.sendBeacon(
|
145
|
-
`${publicApiUrl}/api/events`,
|
145
|
+
`${publicApiUrl}/api/v2/events`,
|
146
146
|
JSON.stringify({
|
147
147
|
event,
|
148
148
|
payload: {
|
@@ -174,6 +174,8 @@ class TrackingController implements ReactiveController {
|
|
174
174
|
streamEnd: this._streamLatestTime[key]
|
175
175
|
});
|
176
176
|
}
|
177
|
+
|
178
|
+
// Make sure these events are only sent once by deleting the start and latest times
|
177
179
|
delete this._streamStartTime[key];
|
178
180
|
delete this._streamLatestTime[key];
|
179
181
|
}
|
@@ -240,16 +242,30 @@ class TrackingController implements ReactiveController {
|
|
240
242
|
delete this._streamLatestTime[key];
|
241
243
|
};
|
242
244
|
|
245
|
+
private _pageUnloading = () => {
|
246
|
+
this._streamEnded();
|
247
|
+
// This will try to send the same stream event again so we delete the start and latest
|
248
|
+
// time in stream ended so that there is no times to send and the pause event does nothing
|
249
|
+
this.host.pause();
|
250
|
+
};
|
251
|
+
|
243
252
|
private _handleVisibilityChange = () => {
|
244
253
|
if (document.visibilityState === 'hidden') {
|
245
|
-
this.
|
246
|
-
this._streamEnded();
|
254
|
+
this._pageUnloading();
|
247
255
|
}
|
248
256
|
};
|
249
257
|
|
258
|
+
private _handlePageHide = () => {
|
259
|
+
this._pageUnloading();
|
260
|
+
};
|
261
|
+
|
250
262
|
hostConnected() {
|
251
263
|
requestAnimationFrame(() => {
|
252
|
-
|
264
|
+
if ('onvisibilitychange' in document) {
|
265
|
+
document.addEventListener('visibilitychange', this._handleVisibilityChange);
|
266
|
+
} else {
|
267
|
+
window.addEventListener('pagehide', this._handlePageHide);
|
268
|
+
}
|
253
269
|
this.host.addEventListener('vouch:loaded', this._handleVouchLoaded);
|
254
270
|
this.host.mediaPlayer?.addEventListener('play', this._handlePlay);
|
255
271
|
this.host.mediaPlayer?.addEventListener('video:play', this._handleVideoPlay);
|
@@ -260,7 +276,11 @@ class TrackingController implements ReactiveController {
|
|
260
276
|
|
261
277
|
hostDisconnected() {
|
262
278
|
this._streamEnded();
|
263
|
-
|
279
|
+
if ('onvisibilitychange' in document) {
|
280
|
+
document.removeEventListener('visibilitychange', this._handleVisibilityChange);
|
281
|
+
} else {
|
282
|
+
window.removeEventListener('pagehide', this._handlePageHide);
|
283
|
+
}
|
264
284
|
this.host.removeEventListener('vouch:loaded', this._handleVouchLoaded);
|
265
285
|
this.host.mediaPlayer?.removeEventListener('play', this._handlePlay);
|
266
286
|
this.host.mediaPlayer?.removeEventListener('video:play', this._handleVideoPlay);
|
@@ -3,7 +3,7 @@ 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 { Scene, TemplateInstance } from '@vouchfor/canvas-video';
|
6
|
+
import type { Scene, Scenes, TemplateInstance } from '@vouchfor/canvas-video';
|
7
7
|
import type { MediaPlayer, MediaPlayerProps } from '@vouchfor/media-player';
|
8
8
|
import type { Ref } from 'lit/directives/ref.js';
|
9
9
|
import type { Environment } from '~/utils/env';
|
@@ -149,6 +149,10 @@ class Embed extends LitElement {
|
|
149
149
|
return this._mediaPlayerRef.value?.scenes ?? [];
|
150
150
|
}
|
151
151
|
|
152
|
+
get sceneConfig(): Scenes | null {
|
153
|
+
return this._mediaPlayerRef.value?.sceneConfig ?? null;
|
154
|
+
}
|
155
|
+
|
152
156
|
get videoState() {
|
153
157
|
return this._mediaPlayerRef.value?.videoState;
|
154
158
|
}
|