@vouchfor/embeds 0.0.0-experiment.799d4c6 → 0.0.0-experiment.7ccd27e
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/embeds.js +1020 -612
- package/dist/es/embeds.js.map +1 -1
- 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 +20 -16
- package/dist/es/src/utils/env.d.ts +12 -0
- package/dist/iife/embeds.iife.js +399 -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 +117 -93
- package/src/components/Embed/index.ts +31 -26
- 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
1
|
import { html, LitElement } from 'lit';
|
2
|
-
import { customElement,
|
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,35 @@ 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
30
|
private _mediaPlayerRef: Ref<MediaPlayer> = createRef();
|
31
31
|
|
32
|
-
@property({ type: Object
|
33
|
-
@property({ type: String })
|
32
|
+
@property({ type: Object }) data: EmbedProps['data'];
|
33
|
+
@property({ type: String }) vouchId: EmbedProps['vouchId'];
|
34
|
+
@property({ type: String }) templateId: EmbedProps['templateId'];
|
35
|
+
@property({ type: Array }) questions: EmbedProps['questions'];
|
34
36
|
|
35
37
|
@property({ type: String }) env: EmbedProps['env'] = 'prod';
|
36
38
|
@property({ type: String }) apiKey: EmbedProps['apiKey'] = '';
|
39
|
+
@property({ type: Boolean }) disableTracking: EmbedProps['disableTracking'] = false;
|
40
|
+
@property({ type: String }) trackingSource: EmbedProps['trackingSource'] = 'embed';
|
37
41
|
|
42
|
+
@property({ type: Array }) controls: EmbedProps['controls'];
|
38
43
|
@property({ type: String }) preload: EmbedProps['preload'] = 'auto';
|
39
44
|
@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
45
|
@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
46
|
|
51
47
|
private eventController = new EventForwardController(this, [
|
52
48
|
'durationchange',
|
@@ -66,6 +62,7 @@ class Embed extends LitElement {
|
|
66
62
|
'waiting',
|
67
63
|
|
68
64
|
'video:loadeddata',
|
65
|
+
'video:seeking',
|
69
66
|
'video:seeked',
|
70
67
|
'video:play',
|
71
68
|
'video:playing',
|
@@ -75,12 +72,17 @@ class Embed extends LitElement {
|
|
75
72
|
'video:ended',
|
76
73
|
'video:error'
|
77
74
|
]);
|
75
|
+
private _fetcherController = new FetcherController(this);
|
78
76
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
79
77
|
// @ts-ignore
|
80
|
-
private
|
81
|
-
|
82
|
-
|
83
|
-
|
78
|
+
private _trackingController = new TrackingController(this);
|
79
|
+
|
80
|
+
@state() vouch: EmbedProps['data'];
|
81
|
+
@state() template: TemplateInstance | undefined;
|
82
|
+
|
83
|
+
get fetching() {
|
84
|
+
return this._fetcherController.fetching;
|
85
|
+
}
|
84
86
|
|
85
87
|
get waiting() {
|
86
88
|
return this._mediaPlayerRef.value?.waiting;
|
@@ -150,6 +152,10 @@ class Embed extends LitElement {
|
|
150
152
|
return this._mediaPlayerRef.value?.scenes ?? [];
|
151
153
|
}
|
152
154
|
|
155
|
+
get sceneConfig(): Scenes | null {
|
156
|
+
return this._mediaPlayerRef.value?.sceneConfig ?? null;
|
157
|
+
}
|
158
|
+
|
153
159
|
get videoState() {
|
154
160
|
return this._mediaPlayerRef.value?.videoState;
|
155
161
|
}
|
@@ -177,9 +183,8 @@ class Embed extends LitElement {
|
|
177
183
|
${this.eventController.register()}
|
178
184
|
?autoplay=${this.autoplay}
|
179
185
|
?loading=${this.fetching}
|
180
|
-
.data=${this.
|
181
|
-
.
|
182
|
-
resolution=${ifDefined(this.resolution)}
|
186
|
+
.data=${this.vouch}
|
187
|
+
.template=${this.template}
|
183
188
|
aspectRatio=${ifDefined(this.aspectRatio)}
|
184
189
|
preload=${ifDefined(this.preload)}
|
185
190
|
.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
|