@vouchfor/embeds 0.0.0-experiment.f97b5b2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. package/dist/es/browser-11f53075.js +433 -0
  2. package/dist/es/browser-11f53075.js.map +1 -0
  3. package/dist/es/embeds.js +7 -1512
  4. package/dist/es/embeds.js.map +1 -1
  5. package/dist/es/index-f9437731.js +9984 -0
  6. package/dist/es/index-f9437731.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 -20
  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 +12 -6
  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/{Embed → PlayerEmbed}/controllers/fetcher.ts +36 -17
  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 -24
  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/tracking.ts +0 -271
  28. /package/dist/es/{utils → src/utils}/env.d.ts +0 -0
  29. /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,35 +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
- enableTracking?: boolean;
8
+ disableTracking?: boolean;
9
9
  trackingSource?: string;
10
10
  vouchId?: string;
11
11
  templateId?: string;
12
+ questions?: number[];
12
13
  };
13
- declare class Embed extends LitElement {
14
+ declare class PlayerEmbed extends LitElement {
15
+ static styles: import("lit").CSSResult[];
14
16
  private _mediaPlayerRef;
15
- data: EmbedProps['data'];
16
- vouchId: EmbedProps['vouchId'];
17
- templateId: EmbedProps['templateId'];
18
- env: EmbedProps['env'];
19
- apiKey: EmbedProps['apiKey'];
20
- enableTracking: EmbedProps['enableTracking'];
21
- trackingSource: EmbedProps['trackingSource'];
22
- controls: EmbedProps['controls'];
23
- preload: EmbedProps['preload'];
24
- autoplay: EmbedProps['autoplay'];
25
- 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'];
26
29
  private eventController;
27
30
  private _fetcherController;
28
31
  private _trackingController;
29
- vouch: EmbedProps['data'];
32
+ vouch: PlayerEmbedProps['data'];
30
33
  template: TemplateInstance | undefined;
31
34
  get fetching(): boolean;
32
35
  get waiting(): boolean | undefined;
36
+ get initialised(): Promise<boolean> | undefined;
33
37
  get seeking(): boolean | undefined;
34
38
  get paused(): boolean | undefined;
35
39
  get captions(): boolean | undefined;
@@ -45,22 +49,24 @@ declare class Embed extends LitElement {
45
49
  get muted(): boolean;
46
50
  get scene(): Scene | null;
47
51
  get scenes(): Scene[];
52
+ get sceneConfig(): Scenes | null;
48
53
  get videoState(): import("@vouchfor/media-player/dist/src/components/MediaPlayer/controllers/scenes").VideoStateMap | undefined;
49
54
  get mediaPlayer(): MediaPlayer | undefined;
50
55
  play(): void;
51
56
  pause(): void;
52
57
  setScene(index: number): void;
58
+ private _renderStyles;
53
59
  render(): import("lit").TemplateResult<1>;
54
60
  }
55
61
  declare global {
56
62
  interface HTMLElementTagNameMap {
57
- 'vouch-embed': Embed;
63
+ 'vouch-embed-player': PlayerEmbed;
58
64
  }
59
65
  namespace JSX {
60
66
  interface IntrinsicElements {
61
- 'vouch-embed': Embed;
67
+ 'vouch-embed-player': PlayerEmbed;
62
68
  }
63
69
  }
64
70
  }
65
- export { Embed };
66
- 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';