@vouchfor/embeds 0.0.0-experiment.79ff9cf → 0.0.0-experiment.acfa1ff
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/es/components/Embed/controllers/event-forwarder.d.ts +14 -0
- package/dist/es/components/Embed/controllers/fetcher.d.ts +8 -0
- package/dist/es/components/Embed/controllers/tracking.d.ts +28 -0
- package/dist/es/components/Embed/index.d.ts +65 -0
- package/dist/es/embeds.js +1203 -13
- package/dist/es/embeds.js.map +1 -1
- package/dist/es/index.d.ts +1 -1
- package/dist/es/utils/env.d.ts +18 -0
- package/dist/es/utils/events.d.ts +2 -0
- package/dist/iife/embeds.iife.js +1481 -0
- package/dist/iife/embeds.iife.js.map +1 -0
- package/package.json +12 -7
- package/src/components/Embed/Embed.stories.ts +82 -0
- package/src/components/Embed/controllers/event-forwarder.ts +47 -0
- package/src/components/Embed/controllers/fetcher.ts +43 -0
- package/src/components/Embed/controllers/tracking.ts +268 -0
- package/src/components/Embed/index.ts +204 -0
- package/src/index.ts +1 -1
- package/src/utils/env.ts +78 -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/umd/embeds.umd.cjs +0 -1351
- package/dist/umd/embeds.umd.cjs.map +0 -1
- package/src/components/InlineEmbed.stories.ts +0 -119
- package/src/components/InlineEmbed.ts +0 -18
- package/src/components/index.ts +0 -2
package/src/utils/env.ts
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
type Environment = 'dev' | 'staging' | 'prod';
|
2
|
+
|
3
|
+
type GetEnvUrlsReturn = {
|
4
|
+
marketingUrl: string;
|
5
|
+
videoUrl: string;
|
6
|
+
publicApiUrl: string;
|
7
|
+
embedApiUrl: string;
|
8
|
+
publicRecorderUrl: string;
|
9
|
+
};
|
10
|
+
|
11
|
+
const marketingUrl = 'https://vouchfor.com';
|
12
|
+
|
13
|
+
const devVideoUrl = 'https://d2rxhdlm2q91uk.cloudfront.net';
|
14
|
+
const stagingVideoUrl = 'https://d1ix11aj5kfygl.cloudfront.net';
|
15
|
+
const prodVideoUrl = 'https://d157jlwnudd93d.cloudfront.net';
|
16
|
+
|
17
|
+
const devPublicApiUrl = 'https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev';
|
18
|
+
const stagingPublicApiUrl = 'https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging';
|
19
|
+
const prodPublicApiUrl = 'https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod';
|
20
|
+
|
21
|
+
const devEmbedApiUrl = 'http://localhost:6060/v1';
|
22
|
+
const stagingEmbedApiUrl = 'https://embed-staging.vouchfor.com/v1';
|
23
|
+
const prodEmbedApiUrl = 'https://embed.vouchfor.com/v1';
|
24
|
+
|
25
|
+
const devPublicRecorderUrl = 'https://dev.vouchfor.com';
|
26
|
+
const stagingPublicRecorderUrl = 'https://staging.vouchfor.com';
|
27
|
+
const prodPublicRecorderUrl = 'https://app.vouchfor.com';
|
28
|
+
|
29
|
+
// We are handling the case where env is an unknown string so the ts error is a lie
|
30
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
31
|
+
// @ts-ignore
|
32
|
+
function getEnvUrls(env: Environment): GetEnvUrlsReturn {
|
33
|
+
if (!['dev', 'staging', 'prod'].includes(env)) {
|
34
|
+
throw new Error(`Unknown environment: ${env}`);
|
35
|
+
}
|
36
|
+
|
37
|
+
if (env === 'dev') {
|
38
|
+
return {
|
39
|
+
marketingUrl,
|
40
|
+
videoUrl: devVideoUrl,
|
41
|
+
publicApiUrl: devPublicApiUrl,
|
42
|
+
embedApiUrl: devEmbedApiUrl,
|
43
|
+
publicRecorderUrl: devPublicRecorderUrl
|
44
|
+
};
|
45
|
+
}
|
46
|
+
|
47
|
+
if (env === 'staging') {
|
48
|
+
return {
|
49
|
+
marketingUrl,
|
50
|
+
videoUrl: stagingVideoUrl,
|
51
|
+
publicApiUrl: stagingPublicApiUrl,
|
52
|
+
embedApiUrl: stagingEmbedApiUrl,
|
53
|
+
publicRecorderUrl: stagingPublicRecorderUrl
|
54
|
+
};
|
55
|
+
}
|
56
|
+
|
57
|
+
if (env === 'prod') {
|
58
|
+
return {
|
59
|
+
marketingUrl,
|
60
|
+
videoUrl: prodVideoUrl,
|
61
|
+
publicApiUrl: prodPublicApiUrl,
|
62
|
+
embedApiUrl: prodEmbedApiUrl,
|
63
|
+
publicRecorderUrl: prodPublicRecorderUrl
|
64
|
+
};
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
export {
|
69
|
+
marketingUrl,
|
70
|
+
devEmbedApiUrl,
|
71
|
+
stagingEmbedApiUrl,
|
72
|
+
prodEmbedApiUrl,
|
73
|
+
devPublicRecorderUrl,
|
74
|
+
stagingPublicRecorderUrl,
|
75
|
+
prodPublicRecorderUrl,
|
76
|
+
getEnvUrls
|
77
|
+
};
|
78
|
+
export type { Environment };
|
@@ -0,0 +1,13 @@
|
|
1
|
+
function forwardEvent(type: string, fromElement: HTMLElement, toElement: HTMLElement) {
|
2
|
+
function forwarder(event: Event) {
|
3
|
+
toElement.dispatchEvent(new CustomEvent(event.type, event));
|
4
|
+
}
|
5
|
+
|
6
|
+
fromElement.addEventListener(type, forwarder);
|
7
|
+
|
8
|
+
return () => {
|
9
|
+
fromElement.removeEventListener(type, forwarder);
|
10
|
+
};
|
11
|
+
}
|
12
|
+
|
13
|
+
export { forwardEvent };
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { MediaPlayer } from '@vouchfor/media-player';
|
2
|
-
import type { MediaPlayerProps } from '@vouchfor/media-player';
|
3
|
-
type InlineEmbedProps = MediaPlayerProps;
|
4
|
-
declare class InlineEmbed extends MediaPlayer {
|
5
|
-
}
|
6
|
-
declare global {
|
7
|
-
interface HTMLElementTagNameMap {
|
8
|
-
'vembed-inline': InlineEmbed;
|
9
|
-
}
|
10
|
-
}
|
11
|
-
export { InlineEmbed };
|
12
|
-
export type { InlineEmbedProps };
|