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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) 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 -1596
  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/src/components/{Embed → PlayerEmbed}/controllers/fetcher.d.ts +5 -4
  8. package/dist/es/src/components/{Embed/controllers/tracking.d.ts → PlayerEmbed/controllers/tracking/index.d.ts} +14 -11
  9. package/dist/es/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
  10. package/dist/es/src/components/{Embed → PlayerEmbed}/index.d.ts +23 -18
  11. package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +3 -0
  12. package/dist/es/src/index.d.ts +1 -1
  13. package/dist/iife/embeds.iife.js +342 -315
  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} +26 -14
  17. package/src/components/{Embed → PlayerEmbed}/controllers/event-forwarder.ts +4 -4
  18. package/src/components/{Embed → PlayerEmbed}/controllers/fetcher.ts +33 -14
  19. package/src/components/{Embed/controllers/tracking.ts → PlayerEmbed/controllers/tracking/index.ts} +47 -115
  20. package/src/components/PlayerEmbed/controllers/tracking/utils.ts +95 -0
  21. package/src/components/{Embed → PlayerEmbed}/index.ts +63 -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
@@ -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 };
@@ -1,22 +1,24 @@
1
- import type { Embed } from '..';
1
+ import type { PlayerEmbed } from '../..';
2
2
  import type { ReactiveController, ReactiveControllerHost } from 'lit';
3
- type EmbedHost = ReactiveControllerHost & Embed;
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
+ };
4
11
  declare class TrackingController implements ReactiveController {
5
- host: EmbedHost;
6
- private _tabId;
7
- private _clientId;
8
- private _visitorId;
12
+ host: PlayerEmbedHost;
13
+ private _batchedEvents;
9
14
  private _hasPlayed;
10
15
  private _hasLoaded;
11
16
  private _answersViewed;
12
17
  private _streamStartTime;
13
18
  private _streamLatestTime;
14
19
  private _currentlyPlayingVideo;
15
- constructor(host: EmbedHost);
16
- private _findVouchId;
17
- private _createVisitor;
18
- private _getUids;
19
- private _getReportingMetadata;
20
+ constructor(host: PlayerEmbedHost);
21
+ private _createTrackingEvent;
20
22
  private _sendTrackingEvent;
21
23
  private _streamEnded;
22
24
  private _handleVouchLoaded;
@@ -31,3 +33,4 @@ declare class TrackingController implements ReactiveController {
31
33
  hostDisconnected(): void;
32
34
  }
33
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 };
@@ -2,34 +2,38 @@ import { LitElement } from 'lit';
2
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
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
- disableTracking: EmbedProps['disableTracking'];
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;
@@ -51,17 +55,18 @@ declare class Embed extends LitElement {
51
55
  play(): void;
52
56
  pause(): void;
53
57
  setScene(index: number): void;
58
+ private _renderStyles;
54
59
  render(): import("lit").TemplateResult<1>;
55
60
  }
56
61
  declare global {
57
62
  interface HTMLElementTagNameMap {
58
- 'vouch-embed': Embed;
63
+ 'vouch-embed-player': PlayerEmbed;
59
64
  }
60
65
  namespace JSX {
61
66
  interface IntrinsicElements {
62
- 'vouch-embed': Embed;
67
+ 'vouch-embed-player': PlayerEmbed;
63
68
  }
64
69
  }
65
70
  }
66
- export { Embed };
67
- 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 };
@@ -1 +1 @@
1
- export { Embed } from './components/Embed';
1
+ export { PlayerEmbed } from './components/PlayerEmbed';