@vouchfor/embeds 0.0.0-experiment.79ff9cf → 0.0.0-experiment.7be60c6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. package/dist/es/embeds.js +1152 -13
  2. package/dist/es/embeds.js.map +1 -1
  3. package/dist/es/src/components/DialogEmbed/DialogOverlay.d.ts +20 -0
  4. package/dist/es/src/components/DialogEmbed/DialogPortal.d.ts +36 -0
  5. package/dist/es/src/components/DialogEmbed/index.d.ts +38 -0
  6. package/dist/es/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
  7. package/dist/es/src/components/PlayerEmbed/controllers/fetcher.d.ts +14 -0
  8. package/dist/es/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
  9. package/dist/es/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
  10. package/dist/es/src/components/PlayerEmbed/index.d.ts +77 -0
  11. package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +4 -0
  12. package/dist/es/src/components/PlayerEmbed/tests/media-data.d.ts +19 -0
  13. package/dist/es/src/index.d.ts +2 -0
  14. package/dist/es/src/utils/env.d.ts +12 -0
  15. package/dist/es/src/utils/events.d.ts +2 -0
  16. package/dist/iife/dialog-embed/embed.iife.js +1757 -0
  17. package/dist/iife/dialog-embed/embed.iife.js.map +1 -0
  18. package/dist/iife/embeds.iife.js +1757 -0
  19. package/dist/iife/embeds.iife.js.map +1 -0
  20. package/dist/iife/player-embed/embed.iife.js +1619 -0
  21. package/dist/iife/player-embed/embed.iife.js.map +1 -0
  22. package/package.json +52 -34
  23. package/src/components/DialogEmbed/Dialog.stories.ts +91 -0
  24. package/src/components/DialogEmbed/DialogOverlay.ts +131 -0
  25. package/src/components/DialogEmbed/DialogPortal.ts +126 -0
  26. package/src/components/DialogEmbed/index.ts +97 -0
  27. package/src/components/PlayerEmbed/MultiEmbed.stories.ts +135 -0
  28. package/src/components/PlayerEmbed/PlayerEmbed.stories.ts +93 -0
  29. package/src/components/PlayerEmbed/controllers/event-forwarder.ts +48 -0
  30. package/src/components/PlayerEmbed/controllers/fetcher.ts +152 -0
  31. package/src/components/PlayerEmbed/controllers/tracking/index.ts +224 -0
  32. package/src/components/PlayerEmbed/controllers/tracking/utils.ts +95 -0
  33. package/src/components/PlayerEmbed/index.ts +265 -0
  34. package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +87 -0
  35. package/src/components/PlayerEmbed/tests/data.ts +227 -0
  36. package/src/components/PlayerEmbed/tests/media-data.ts +22 -0
  37. package/src/index.ts +2 -1
  38. package/src/utils/env.ts +64 -0
  39. package/src/utils/events.ts +13 -0
  40. package/dist/es/components/InlineEmbed.d.ts +0 -12
  41. package/dist/es/components/index.d.ts +0 -2
  42. package/dist/es/index.d.ts +0 -1
  43. package/dist/umd/embeds.umd.cjs +0 -1351
  44. package/dist/umd/embeds.umd.cjs.map +0 -1
  45. package/src/components/InlineEmbed.stories.ts +0 -119
  46. package/src/components/InlineEmbed.ts +0 -18
  47. package/src/components/index.ts +0 -2
@@ -0,0 +1,64 @@
1
+ type Environment = 'local' | 'dev' | 'staging' | 'prod';
2
+
3
+ type GetEnvUrlsReturn = {
4
+ videoUrl: string;
5
+ publicApiUrl: string;
6
+ embedApiUrl: string;
7
+ };
8
+
9
+ const devVideoUrl = 'https://d2rxhdlm2q91uk.cloudfront.net';
10
+ const stagingVideoUrl = 'https://d1ix11aj5kfygl.cloudfront.net';
11
+ const prodVideoUrl = 'https://d157jlwnudd93d.cloudfront.net';
12
+
13
+ const devPublicApiUrl = 'https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev';
14
+ const stagingPublicApiUrl = 'https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging';
15
+ const prodPublicApiUrl = 'https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod';
16
+
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';
21
+
22
+ // We are handling the case where env is an unknown string so the ts error is a lie
23
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
24
+ // @ts-ignore
25
+ function getEnvUrls(env: Environment): GetEnvUrlsReturn {
26
+ if (!['local', 'dev', 'staging', 'prod'].includes(env)) {
27
+ throw new Error(`Unknown environment: ${env}`);
28
+ }
29
+
30
+ if (env === 'local') {
31
+ return {
32
+ videoUrl: devVideoUrl,
33
+ publicApiUrl: devPublicApiUrl,
34
+ embedApiUrl: localEmbedApiUrl
35
+ };
36
+ }
37
+
38
+ if (env === 'dev') {
39
+ return {
40
+ videoUrl: devVideoUrl,
41
+ publicApiUrl: devPublicApiUrl,
42
+ embedApiUrl: devEmbedApiUrl
43
+ };
44
+ }
45
+
46
+ if (env === 'staging') {
47
+ return {
48
+ videoUrl: stagingVideoUrl,
49
+ publicApiUrl: stagingPublicApiUrl,
50
+ embedApiUrl: stagingEmbedApiUrl
51
+ };
52
+ }
53
+
54
+ if (env === 'prod') {
55
+ return {
56
+ videoUrl: prodVideoUrl,
57
+ publicApiUrl: prodPublicApiUrl,
58
+ embedApiUrl: prodEmbedApiUrl
59
+ };
60
+ }
61
+ }
62
+
63
+ export { devEmbedApiUrl, stagingEmbedApiUrl, prodEmbedApiUrl, getEnvUrls };
64
+ 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 };
@@ -1,2 +0,0 @@
1
- export { InlineEmbed } from './InlineEmbed';
2
- export type { InlineEmbedProps } from './InlineEmbed';
@@ -1 +0,0 @@
1
- export { InlineEmbed } from './components/InlineEmbed';