@vouchfor/embeds 0.0.0-experiment.eb79200 → 0.0.0-experiment.f112aaa
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/browser-f5bec026.js +433 -0
- package/dist/es/browser-f5bec026.js.map +1 -0
- package/dist/es/embeds.js +7 -1202
- package/dist/es/embeds.js.map +1 -1
- package/dist/es/index-6ce8276f.js +9947 -0
- package/dist/es/index-6ce8276f.js.map +1 -0
- package/dist/es/{components → src/components}/Embed/controllers/fetcher.d.ts +6 -0
- package/dist/es/{components → src/components}/Embed/controllers/tracking.d.ts +7 -2
- package/dist/es/{components → src/components}/Embed/index.d.ts +21 -16
- package/dist/es/src/utils/env.d.ts +12 -0
- package/dist/iife/embeds.iife.js +418 -341
- package/dist/iife/embeds.iife.js.map +1 -1
- package/package.json +6 -6
- package/src/components/Embed/Embed.stories.ts +15 -18
- package/src/components/Embed/controllers/fetcher.ts +124 -15
- package/src/components/Embed/controllers/tracking.ts +119 -93
- package/src/components/Embed/index.ts +40 -27
- package/src/utils/env.ts +18 -32
- package/dist/es/components/Embed/controllers/event-forwarder.d.ts +0 -14
- package/dist/es/utils/env.d.ts +0 -18
- /package/dist/es/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/es/{utils → src/utils}/events.d.ts +0 -0
@@ -1,9 +1,9 @@
|
|
1
|
-
import { html, LitElement } from 'lit';
|
2
|
-
import { customElement,
|
1
|
+
import { css, html, LitElement } from 'lit';
|
2
|
+
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 } 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';
|
@@ -14,39 +14,43 @@ import { TrackingController } from './controllers/tracking';
|
|
14
14
|
|
15
15
|
import '@vouchfor/media-player';
|
16
16
|
|
17
|
-
type EmbedProps = Pick<
|
18
|
-
MediaPlayerProps,
|
19
|
-
'data' | 'resolution' | 'aspectRatio' | 'preload' | 'autoplay' | 'controls'
|
20
|
-
> & {
|
17
|
+
type EmbedProps = Pick<MediaPlayerProps, 'data' | 'aspectRatio' | 'preload' | 'autoplay' | 'controls'> & {
|
21
18
|
env: Environment;
|
22
19
|
apiKey: string;
|
23
|
-
|
24
|
-
enableTracking?: boolean;
|
20
|
+
disableTracking?: boolean;
|
25
21
|
trackingSource?: string;
|
22
|
+
vouchId?: string;
|
23
|
+
templateId?: string;
|
24
|
+
// Index of the questions to include starting from 1
|
25
|
+
questions?: number[];
|
26
26
|
};
|
27
27
|
|
28
28
|
@customElement('vouch-embed')
|
29
29
|
class Embed extends LitElement {
|
30
|
+
static styles = [
|
31
|
+
css`
|
32
|
+
:host {
|
33
|
+
display: flex;
|
34
|
+
}
|
35
|
+
`
|
36
|
+
];
|
37
|
+
|
30
38
|
private _mediaPlayerRef: Ref<MediaPlayer> = createRef();
|
31
39
|
|
32
|
-
@property({ type: Object
|
33
|
-
@property({ type: String })
|
40
|
+
@property({ type: Object }) data: EmbedProps['data'];
|
41
|
+
@property({ type: String }) vouchId: EmbedProps['vouchId'];
|
42
|
+
@property({ type: String }) templateId: EmbedProps['templateId'];
|
43
|
+
@property({ type: Array }) questions: EmbedProps['questions'];
|
34
44
|
|
35
45
|
@property({ type: String }) env: EmbedProps['env'] = 'prod';
|
36
46
|
@property({ type: String }) apiKey: EmbedProps['apiKey'] = '';
|
47
|
+
@property({ type: Boolean }) disableTracking: EmbedProps['disableTracking'] = false;
|
48
|
+
@property({ type: String }) trackingSource: EmbedProps['trackingSource'] = 'embed';
|
37
49
|
|
50
|
+
@property({ type: Array }) controls: EmbedProps['controls'];
|
38
51
|
@property({ type: String }) preload: EmbedProps['preload'] = 'auto';
|
39
52
|
@property({ type: Boolean }) autoplay: EmbedProps['autoplay'] = false;
|
40
|
-
@property({ type: Boolean }) enableTracking: EmbedProps['enableTracking'] = false;
|
41
|
-
@property({ type: String }) trackingSource: EmbedProps['trackingSource'] = 'media_player';
|
42
|
-
|
43
|
-
@property({ type: Number }) resolution: EmbedProps['resolution'] = 1080;
|
44
53
|
@property({ type: Number }) aspectRatio: EmbedProps['aspectRatio'] = 0;
|
45
|
-
@property({ type: Array }) controls: EmbedProps['controls'];
|
46
|
-
|
47
|
-
@state() data: MediaPlayerProps['data'];
|
48
|
-
@state() instance: MediaPlayerProps['instance'];
|
49
|
-
@state() fetching = false;
|
50
54
|
|
51
55
|
private eventController = new EventForwardController(this, [
|
52
56
|
'durationchange',
|
@@ -66,6 +70,7 @@ class Embed extends LitElement {
|
|
66
70
|
'waiting',
|
67
71
|
|
68
72
|
'video:loadeddata',
|
73
|
+
'video:seeking',
|
69
74
|
'video:seeked',
|
70
75
|
'video:play',
|
71
76
|
'video:playing',
|
@@ -75,12 +80,17 @@ class Embed extends LitElement {
|
|
75
80
|
'video:ended',
|
76
81
|
'video:error'
|
77
82
|
]);
|
83
|
+
private _fetcherController = new FetcherController(this);
|
78
84
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
79
85
|
// @ts-ignore
|
80
|
-
private
|
81
|
-
|
82
|
-
|
83
|
-
|
86
|
+
private _trackingController = new TrackingController(this);
|
87
|
+
|
88
|
+
@state() vouch: EmbedProps['data'];
|
89
|
+
@state() template: TemplateInstance | undefined;
|
90
|
+
|
91
|
+
get fetching() {
|
92
|
+
return this._fetcherController.fetching;
|
93
|
+
}
|
84
94
|
|
85
95
|
get waiting() {
|
86
96
|
return this._mediaPlayerRef.value?.waiting;
|
@@ -150,6 +160,10 @@ class Embed extends LitElement {
|
|
150
160
|
return this._mediaPlayerRef.value?.scenes ?? [];
|
151
161
|
}
|
152
162
|
|
163
|
+
get sceneConfig(): Scenes | null {
|
164
|
+
return this._mediaPlayerRef.value?.sceneConfig ?? null;
|
165
|
+
}
|
166
|
+
|
153
167
|
get videoState() {
|
154
168
|
return this._mediaPlayerRef.value?.videoState;
|
155
169
|
}
|
@@ -177,9 +191,8 @@ class Embed extends LitElement {
|
|
177
191
|
${this.eventController.register()}
|
178
192
|
?autoplay=${this.autoplay}
|
179
193
|
?loading=${this.fetching}
|
180
|
-
.data=${this.
|
181
|
-
.
|
182
|
-
resolution=${ifDefined(this.resolution)}
|
194
|
+
.data=${this.vouch}
|
195
|
+
.template=${this.template}
|
183
196
|
aspectRatio=${ifDefined(this.aspectRatio)}
|
184
197
|
preload=${ifDefined(this.preload)}
|
185
198
|
.controls=${this.controls}
|
package/src/utils/env.ts
CHANGED
@@ -1,15 +1,11 @@
|
|
1
|
-
type Environment = 'dev' | 'staging' | 'prod';
|
1
|
+
type Environment = 'local' | 'dev' | 'staging' | 'prod';
|
2
2
|
|
3
3
|
type GetEnvUrlsReturn = {
|
4
|
-
marketingUrl: string;
|
5
4
|
videoUrl: string;
|
6
5
|
publicApiUrl: string;
|
7
6
|
embedApiUrl: string;
|
8
|
-
publicRecorderUrl: string;
|
9
7
|
};
|
10
8
|
|
11
|
-
const marketingUrl = 'https://vouchfor.com';
|
12
|
-
|
13
9
|
const devVideoUrl = 'https://d2rxhdlm2q91uk.cloudfront.net';
|
14
10
|
const stagingVideoUrl = 'https://d1ix11aj5kfygl.cloudfront.net';
|
15
11
|
const prodVideoUrl = 'https://d157jlwnudd93d.cloudfront.net';
|
@@ -18,61 +14,51 @@ const devPublicApiUrl = 'https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws
|
|
18
14
|
const stagingPublicApiUrl = 'https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging';
|
19
15
|
const prodPublicApiUrl = 'https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod';
|
20
16
|
|
21
|
-
const
|
22
|
-
const
|
23
|
-
const
|
24
|
-
|
25
|
-
const devPublicRecorderUrl = 'https://dev.vouchfor.com';
|
26
|
-
const stagingPublicRecorderUrl = 'https://staging.vouchfor.com';
|
27
|
-
const prodPublicRecorderUrl = 'https://app.vouchfor.com';
|
17
|
+
const localEmbedApiUrl = 'http://localhost:6060/v2';
|
18
|
+
const devEmbedApiUrl = 'https://embed-dev.vouchfor.com/v2';
|
19
|
+
const stagingEmbedApiUrl = 'https://embed-staging.vouchfor.com/v2';
|
20
|
+
const prodEmbedApiUrl = 'https://embed.vouchfor.com/v2';
|
28
21
|
|
29
22
|
// We are handling the case where env is an unknown string so the ts error is a lie
|
30
23
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
31
24
|
// @ts-ignore
|
32
25
|
function getEnvUrls(env: Environment): GetEnvUrlsReturn {
|
33
|
-
if (!['dev', 'staging', 'prod'].includes(env)) {
|
26
|
+
if (!['local', 'dev', 'staging', 'prod'].includes(env)) {
|
34
27
|
throw new Error(`Unknown environment: ${env}`);
|
35
28
|
}
|
36
29
|
|
30
|
+
if (env === 'local') {
|
31
|
+
return {
|
32
|
+
videoUrl: devVideoUrl,
|
33
|
+
publicApiUrl: devPublicApiUrl,
|
34
|
+
embedApiUrl: localEmbedApiUrl
|
35
|
+
};
|
36
|
+
}
|
37
|
+
|
37
38
|
if (env === 'dev') {
|
38
39
|
return {
|
39
|
-
marketingUrl,
|
40
40
|
videoUrl: devVideoUrl,
|
41
41
|
publicApiUrl: devPublicApiUrl,
|
42
|
-
embedApiUrl: devEmbedApiUrl
|
43
|
-
publicRecorderUrl: devPublicRecorderUrl
|
42
|
+
embedApiUrl: devEmbedApiUrl
|
44
43
|
};
|
45
44
|
}
|
46
45
|
|
47
46
|
if (env === 'staging') {
|
48
47
|
return {
|
49
|
-
marketingUrl,
|
50
48
|
videoUrl: stagingVideoUrl,
|
51
49
|
publicApiUrl: stagingPublicApiUrl,
|
52
|
-
embedApiUrl: stagingEmbedApiUrl
|
53
|
-
publicRecorderUrl: stagingPublicRecorderUrl
|
50
|
+
embedApiUrl: stagingEmbedApiUrl
|
54
51
|
};
|
55
52
|
}
|
56
53
|
|
57
54
|
if (env === 'prod') {
|
58
55
|
return {
|
59
|
-
marketingUrl,
|
60
56
|
videoUrl: prodVideoUrl,
|
61
57
|
publicApiUrl: prodPublicApiUrl,
|
62
|
-
embedApiUrl: prodEmbedApiUrl
|
63
|
-
publicRecorderUrl: prodPublicRecorderUrl
|
58
|
+
embedApiUrl: prodEmbedApiUrl
|
64
59
|
};
|
65
60
|
}
|
66
61
|
}
|
67
62
|
|
68
|
-
export {
|
69
|
-
marketingUrl,
|
70
|
-
devEmbedApiUrl,
|
71
|
-
stagingEmbedApiUrl,
|
72
|
-
prodEmbedApiUrl,
|
73
|
-
devPublicRecorderUrl,
|
74
|
-
stagingPublicRecorderUrl,
|
75
|
-
prodPublicRecorderUrl,
|
76
|
-
getEnvUrls
|
77
|
-
};
|
63
|
+
export { devEmbedApiUrl, stagingEmbedApiUrl, prodEmbedApiUrl, getEnvUrls };
|
78
64
|
export type { Environment };
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import type { Embed } from '..';
|
2
|
-
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
3
|
-
type EmbedHost = ReactiveControllerHost & Embed;
|
4
|
-
declare class EventForwardController implements ReactiveController {
|
5
|
-
host: EmbedHost;
|
6
|
-
private _events;
|
7
|
-
private _cleanup;
|
8
|
-
private _forwardElementRef;
|
9
|
-
constructor(host: EmbedHost, events: string[]);
|
10
|
-
register(): import("lit-html/directive.js").DirectiveResult<typeof import("lit-html/directives/ref.js").RefDirective>;
|
11
|
-
hostConnected(): void;
|
12
|
-
hostDisconnected(): void;
|
13
|
-
}
|
14
|
-
export { EventForwardController };
|
package/dist/es/utils/env.d.ts
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
type Environment = 'dev' | 'staging' | 'prod';
|
2
|
-
type GetEnvUrlsReturn = {
|
3
|
-
marketingUrl: string;
|
4
|
-
videoUrl: string;
|
5
|
-
publicApiUrl: string;
|
6
|
-
embedApiUrl: string;
|
7
|
-
publicRecorderUrl: string;
|
8
|
-
};
|
9
|
-
declare const marketingUrl = "https://vouchfor.com";
|
10
|
-
declare const devEmbedApiUrl = "http://localhost:6060/v1";
|
11
|
-
declare const stagingEmbedApiUrl = "https://embed-staging.vouchfor.com/v1";
|
12
|
-
declare const prodEmbedApiUrl = "https://embed.vouchfor.com/v1";
|
13
|
-
declare const devPublicRecorderUrl = "https://dev.vouchfor.com";
|
14
|
-
declare const stagingPublicRecorderUrl = "https://staging.vouchfor.com";
|
15
|
-
declare const prodPublicRecorderUrl = "https://app.vouchfor.com";
|
16
|
-
declare function getEnvUrls(env: Environment): GetEnvUrlsReturn;
|
17
|
-
export { marketingUrl, devEmbedApiUrl, stagingEmbedApiUrl, prodEmbedApiUrl, devPublicRecorderUrl, stagingPublicRecorderUrl, prodPublicRecorderUrl, getEnvUrls };
|
18
|
-
export type { Environment };
|
File without changes
|
File without changes
|