@vouchfor/embeds 0.0.0-experiment.f4df018 → 0.0.0-experiment.f7614ec

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. package/dist/es/browser-0a211a9c.js +433 -0
  2. package/dist/es/browser-0a211a9c.js.map +1 -0
  3. package/dist/es/embeds.js +7 -1499
  4. package/dist/es/embeds.js.map +1 -1
  5. package/dist/es/index-b6636843.js +9984 -0
  6. package/dist/es/index-b6636843.js.map +1 -0
  7. package/dist/es/{components/Embed → src/components/PlayerEmbed}/controllers/fetcher.d.ts +5 -4
  8. package/dist/es/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
  9. package/dist/es/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
  10. package/dist/es/{components/Embed → src/components/PlayerEmbed}/index.d.ts +26 -18
  11. package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +3 -0
  12. package/dist/es/src/index.d.ts +1 -0
  13. package/dist/iife/embeds.iife.js +455 -313
  14. package/dist/iife/embeds.iife.js.map +1 -1
  15. package/package.json +7 -4
  16. package/src/components/{Embed/Embed.stories.ts → PlayerEmbed/PlayerEmbed.stories.ts} +27 -14
  17. package/src/components/{Embed → PlayerEmbed}/controllers/event-forwarder.ts +4 -4
  18. package/src/components/PlayerEmbed/controllers/fetcher.ts +152 -0
  19. package/src/components/PlayerEmbed/controllers/tracking/index.ts +224 -0
  20. package/src/components/PlayerEmbed/controllers/tracking/utils.ts +95 -0
  21. package/src/components/{Embed → PlayerEmbed}/index.ts +70 -22
  22. package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +80 -0
  23. package/src/components/PlayerEmbed/tests/data.ts +183 -0
  24. package/src/index.ts +1 -1
  25. package/dist/es/components/Embed/controllers/tracking.d.ts +0 -28
  26. package/dist/es/index.d.ts +0 -1
  27. package/src/components/Embed/controllers/fetcher.ts +0 -113
  28. package/src/components/Embed/controllers/tracking.ts +0 -261
  29. /package/dist/es/{utils → src/utils}/env.d.ts +0 -0
  30. /package/dist/es/{utils → src/utils}/events.d.ts +0 -0
@@ -1,13 +1,14 @@
1
- import type { Embed } from '..';
1
+ import type { PlayerEmbed } from '..';
2
2
  import type { ReactiveControllerHost } from 'lit';
3
- type EmbedHost = ReactiveControllerHost & Embed;
3
+ type PlayerEmbedHost = ReactiveControllerHost & PlayerEmbed;
4
4
  declare class FetcherController {
5
- host: EmbedHost;
5
+ host: PlayerEmbedHost;
6
6
  private _fetching;
7
+ private _vouch;
7
8
  set fetching(value: boolean);
8
9
  get fetching(): boolean;
9
10
  private getVouch;
10
11
  private getTemplate;
11
- constructor(host: EmbedHost);
12
+ constructor(host: PlayerEmbedHost);
12
13
  }
13
14
  export { FetcherController };
@@ -0,0 +1,36 @@
1
+ import type { PlayerEmbed } from '../..';
2
+ import type { ReactiveController, ReactiveControllerHost } from 'lit';
3
+ type PlayerEmbedHost = ReactiveControllerHost & PlayerEmbed;
4
+ type TrackingEvent = 'VOUCH_LOADED' | 'VOUCH_RESPONSE_VIEWED' | 'VIDEO_PLAYED' | 'VIDEO_STREAMED';
5
+ type TrackingPayload = {
6
+ vouchId?: string;
7
+ answerId?: string;
8
+ streamStart?: number;
9
+ streamEnd?: number;
10
+ };
11
+ declare class TrackingController implements ReactiveController {
12
+ host: PlayerEmbedHost;
13
+ private _batchedEvents;
14
+ private _hasPlayed;
15
+ private _hasLoaded;
16
+ private _answersViewed;
17
+ private _streamStartTime;
18
+ private _streamLatestTime;
19
+ private _currentlyPlayingVideo;
20
+ constructor(host: PlayerEmbedHost);
21
+ private _createTrackingEvent;
22
+ private _sendTrackingEvent;
23
+ private _streamEnded;
24
+ private _handleVouchLoaded;
25
+ private _handlePlay;
26
+ private _handleVideoPlay;
27
+ private _handleVideoTimeUpdate;
28
+ private _handleVideoPause;
29
+ private _pageUnloading;
30
+ private _handleVisibilityChange;
31
+ private _handlePageHide;
32
+ hostConnected(): void;
33
+ hostDisconnected(): void;
34
+ }
35
+ export { TrackingController };
36
+ export type { TrackingEvent, TrackingPayload };
@@ -0,0 +1,17 @@
1
+ import type { TrackingPayload } from '.';
2
+ import type { Vouch } from '@vouchfor/media-player';
3
+ import type { Environment } from '../../../../utils/env';
4
+ declare function getUids(env: Environment): {
5
+ client: null;
6
+ tab: null;
7
+ request: string;
8
+ visitor?: undefined;
9
+ } | {
10
+ client: string;
11
+ tab: string;
12
+ request: string;
13
+ visitor: string;
14
+ };
15
+ declare function findVouchId(payload?: TrackingPayload, vouch?: Vouch): string | null | undefined;
16
+ declare function getReportingMetadata(source?: string): any;
17
+ export { getUids, findVouchId, getReportingMetadata };
@@ -1,33 +1,39 @@
1
1
  import { LitElement } from 'lit';
2
- import type { Scene, TemplateInstance } from '@vouchfor/canvas-video';
2
+ import type { Scene, Scenes, TemplateInstance } from '@vouchfor/canvas-video';
3
3
  import type { MediaPlayer, MediaPlayerProps } from '@vouchfor/media-player';
4
4
  import type { Environment } from '../../utils/env';
5
- type EmbedProps = Pick<MediaPlayerProps, 'data' | 'aspectRatio' | 'preload' | 'autoplay' | 'controls'> & {
5
+ type PlayerEmbedProps = Pick<MediaPlayerProps, 'data' | 'aspectRatio' | 'preload' | 'autoplay' | 'controls'> & {
6
6
  env: Environment;
7
7
  apiKey: string;
8
+ disableTracking?: boolean;
8
9
  trackingSource?: string;
9
10
  vouchId?: string;
10
11
  templateId?: string;
12
+ questions?: number[];
11
13
  };
12
- declare class Embed extends LitElement {
14
+ declare class PlayerEmbed extends LitElement {
15
+ static styles: import("lit").CSSResult[];
13
16
  private _mediaPlayerRef;
14
- data: EmbedProps['data'];
15
- vouchId: EmbedProps['vouchId'];
16
- templateId: EmbedProps['templateId'];
17
- env: EmbedProps['env'];
18
- apiKey: EmbedProps['apiKey'];
19
- trackingSource: EmbedProps['trackingSource'];
20
- controls: EmbedProps['controls'];
21
- preload: EmbedProps['preload'];
22
- autoplay: EmbedProps['autoplay'];
23
- aspectRatio: EmbedProps['aspectRatio'];
17
+ data: PlayerEmbedProps['data'];
18
+ vouchId: PlayerEmbedProps['vouchId'];
19
+ templateId: PlayerEmbedProps['templateId'];
20
+ questions: PlayerEmbedProps['questions'];
21
+ env: PlayerEmbedProps['env'];
22
+ apiKey: PlayerEmbedProps['apiKey'];
23
+ disableTracking: PlayerEmbedProps['disableTracking'];
24
+ trackingSource: PlayerEmbedProps['trackingSource'];
25
+ controls: PlayerEmbedProps['controls'];
26
+ preload: PlayerEmbedProps['preload'];
27
+ autoplay: PlayerEmbedProps['autoplay'];
28
+ aspectRatio: PlayerEmbedProps['aspectRatio'];
24
29
  private eventController;
25
30
  private _fetcherController;
26
31
  private _trackingController;
27
- vouch: EmbedProps['data'];
32
+ vouch: PlayerEmbedProps['data'];
28
33
  template: TemplateInstance | undefined;
29
34
  get fetching(): boolean;
30
35
  get waiting(): boolean | undefined;
36
+ get initialised(): Promise<boolean> | undefined;
31
37
  get seeking(): boolean | undefined;
32
38
  get paused(): boolean | undefined;
33
39
  get captions(): boolean | undefined;
@@ -43,22 +49,24 @@ declare class Embed extends LitElement {
43
49
  get muted(): boolean;
44
50
  get scene(): Scene | null;
45
51
  get scenes(): Scene[];
52
+ get sceneConfig(): Scenes | null;
46
53
  get videoState(): import("@vouchfor/media-player/dist/src/components/MediaPlayer/controllers/scenes").VideoStateMap | undefined;
47
54
  get mediaPlayer(): MediaPlayer | undefined;
48
55
  play(): void;
49
56
  pause(): void;
50
57
  setScene(index: number): void;
58
+ private _renderStyles;
51
59
  render(): import("lit").TemplateResult<1>;
52
60
  }
53
61
  declare global {
54
62
  interface HTMLElementTagNameMap {
55
- 'vouch-embed': Embed;
63
+ 'vouch-embed-player': PlayerEmbed;
56
64
  }
57
65
  namespace JSX {
58
66
  interface IntrinsicElements {
59
- 'vouch-embed': Embed;
67
+ 'vouch-embed-player': PlayerEmbed;
60
68
  }
61
69
  }
62
70
  }
63
- export { Embed };
64
- export type { EmbedProps };
71
+ export { PlayerEmbed };
72
+ export type { PlayerEmbedProps };
@@ -0,0 +1,3 @@
1
+ import type { Vouch } from '@vouchfor/media-player';
2
+ declare const data: Vouch;
3
+ export { data };
@@ -0,0 +1 @@
1
+ export { PlayerEmbed } from './components/PlayerEmbed';