@vouchfor/embeds 0.0.0-experiment.f9b576b → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/es/browser-11f53075.js +433 -0
- package/dist/es/browser-11f53075.js.map +1 -0
- package/dist/es/embeds.js +8 -13
- package/dist/es/embeds.js.map +1 -1
- package/dist/es/index-f9437731.js +9984 -0
- package/dist/es/index-f9437731.js.map +1 -0
- package/dist/es/src/components/PlayerEmbed/controllers/fetcher.d.ts +14 -0
- package/dist/es/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
- package/dist/es/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
- package/dist/es/src/components/PlayerEmbed/index.d.ts +72 -0
- package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +3 -0
- package/dist/es/src/index.d.ts +1 -0
- package/dist/es/src/utils/env.d.ts +12 -0
- package/dist/es/src/utils/events.d.ts +2 -0
- package/dist/iife/embeds.iife.js +482 -261
- package/dist/iife/embeds.iife.js.map +1 -1
- package/package.json +22 -11
- package/src/components/PlayerEmbed/PlayerEmbed.stories.ts +79 -0
- package/src/components/PlayerEmbed/controllers/event-forwarder.ts +47 -0
- package/src/components/PlayerEmbed/controllers/fetcher.ts +152 -0
- package/src/components/PlayerEmbed/controllers/tracking/index.ts +224 -0
- package/src/components/PlayerEmbed/controllers/tracking/utils.ts +95 -0
- package/src/components/PlayerEmbed/index.ts +247 -0
- package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +80 -0
- package/src/components/PlayerEmbed/tests/data.ts +183 -0
- package/src/index.ts +1 -1
- package/src/utils/env.ts +64 -0
- package/src/utils/events.ts +13 -0
- package/dist/es/components/InlineEmbed.d.ts +0 -12
- package/dist/es/components/index.d.ts +0 -2
- package/dist/es/index.d.ts +0 -1
- package/src/components/InlineEmbed.stories.ts +0 -119
- package/src/components/InlineEmbed.ts +0 -18
- package/src/components/index.ts +0 -2
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { PlayerEmbed } from '..';
|
2
|
+
import type { ReactiveControllerHost } from 'lit';
|
3
|
+
type PlayerEmbedHost = ReactiveControllerHost & PlayerEmbed;
|
4
|
+
declare class FetcherController {
|
5
|
+
host: PlayerEmbedHost;
|
6
|
+
private _fetching;
|
7
|
+
private _vouch;
|
8
|
+
set fetching(value: boolean);
|
9
|
+
get fetching(): boolean;
|
10
|
+
private getVouch;
|
11
|
+
private getTemplate;
|
12
|
+
constructor(host: PlayerEmbedHost);
|
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 };
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import { LitElement } from 'lit';
|
2
|
+
import type { Scene, Scenes, TemplateInstance } from '@vouchfor/canvas-video';
|
3
|
+
import type { MediaPlayer, MediaPlayerProps } from '@vouchfor/media-player';
|
4
|
+
import type { Environment } from '../../utils/env';
|
5
|
+
type PlayerEmbedProps = Pick<MediaPlayerProps, 'data' | 'aspectRatio' | 'preload' | 'autoplay' | 'controls'> & {
|
6
|
+
env: Environment;
|
7
|
+
apiKey: string;
|
8
|
+
disableTracking?: boolean;
|
9
|
+
trackingSource?: string;
|
10
|
+
vouchId?: string;
|
11
|
+
templateId?: string;
|
12
|
+
questions?: number[];
|
13
|
+
};
|
14
|
+
declare class PlayerEmbed extends LitElement {
|
15
|
+
static styles: import("lit").CSSResult[];
|
16
|
+
private _mediaPlayerRef;
|
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'];
|
29
|
+
private eventController;
|
30
|
+
private _fetcherController;
|
31
|
+
private _trackingController;
|
32
|
+
vouch: PlayerEmbedProps['data'];
|
33
|
+
template: TemplateInstance | undefined;
|
34
|
+
get fetching(): boolean;
|
35
|
+
get waiting(): boolean | undefined;
|
36
|
+
get initialised(): Promise<boolean> | undefined;
|
37
|
+
get seeking(): boolean | undefined;
|
38
|
+
get paused(): boolean | undefined;
|
39
|
+
get captions(): boolean | undefined;
|
40
|
+
get fullscreen(): boolean | undefined;
|
41
|
+
get duration(): number | undefined;
|
42
|
+
set currentTime(value: number);
|
43
|
+
get currentTime(): number;
|
44
|
+
set playbackRate(value: number);
|
45
|
+
get playbackRate(): number;
|
46
|
+
set volume(value: number);
|
47
|
+
get volume(): number;
|
48
|
+
set muted(value: boolean);
|
49
|
+
get muted(): boolean;
|
50
|
+
get scene(): Scene | null;
|
51
|
+
get scenes(): Scene[];
|
52
|
+
get sceneConfig(): Scenes | null;
|
53
|
+
get videoState(): import("@vouchfor/media-player/dist/src/components/MediaPlayer/controllers/scenes").VideoStateMap | undefined;
|
54
|
+
get mediaPlayer(): MediaPlayer | undefined;
|
55
|
+
play(): void;
|
56
|
+
pause(): void;
|
57
|
+
setScene(index: number): void;
|
58
|
+
private _renderStyles;
|
59
|
+
render(): import("lit").TemplateResult<1>;
|
60
|
+
}
|
61
|
+
declare global {
|
62
|
+
interface HTMLElementTagNameMap {
|
63
|
+
'vouch-embed-player': PlayerEmbed;
|
64
|
+
}
|
65
|
+
namespace JSX {
|
66
|
+
interface IntrinsicElements {
|
67
|
+
'vouch-embed-player': PlayerEmbed;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
export { PlayerEmbed };
|
72
|
+
export type { PlayerEmbedProps };
|
@@ -0,0 +1 @@
|
|
1
|
+
export { PlayerEmbed } from './components/PlayerEmbed';
|
@@ -0,0 +1,12 @@
|
|
1
|
+
type Environment = 'local' | 'dev' | 'staging' | 'prod';
|
2
|
+
type GetEnvUrlsReturn = {
|
3
|
+
videoUrl: string;
|
4
|
+
publicApiUrl: string;
|
5
|
+
embedApiUrl: string;
|
6
|
+
};
|
7
|
+
declare const devEmbedApiUrl = "https://embed-dev.vouchfor.com/v2";
|
8
|
+
declare const stagingEmbedApiUrl = "https://embed-staging.vouchfor.com/v2";
|
9
|
+
declare const prodEmbedApiUrl = "https://embed.vouchfor.com/v2";
|
10
|
+
declare function getEnvUrls(env: Environment): GetEnvUrlsReturn;
|
11
|
+
export { devEmbedApiUrl, stagingEmbedApiUrl, prodEmbedApiUrl, getEnvUrls };
|
12
|
+
export type { Environment };
|