@vouchfor/embeds 0.0.0-experiment.cf82dbe → 0.0.0-experiment.cfa2fea

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. package/dist/es/browser-99a8cab9.js +733 -0
  2. package/dist/es/{browser-ff061c90.js.map → browser-99a8cab9.js.map} +1 -1
  3. package/dist/es/embeds.js +6 -1
  4. package/dist/es/embeds.js.map +1 -1
  5. package/dist/es/index-038b2aee.js +4599 -0
  6. package/dist/es/index-038b2aee.js.map +1 -0
  7. package/dist/es/src/components/DialogEmbed/DialogOverlay.d.ts +19 -0
  8. package/dist/es/src/components/DialogEmbed/DialogPortal.d.ts +35 -0
  9. package/dist/es/src/components/DialogEmbed/index.d.ts +36 -0
  10. package/dist/es/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
  11. package/dist/es/src/components/PlayerEmbed/index.d.ts +3 -1
  12. package/dist/es/src/index.d.ts +1 -0
  13. package/dist/{es/browser-ff061c90.js → iife/dialog-embed/browser-3b534a6e.js} +2 -2
  14. package/dist/iife/dialog-embed/browser-3b534a6e.js.map +1 -0
  15. package/dist/iife/dialog-embed/embed.iife.js +1722 -0
  16. package/dist/iife/dialog-embed/embed.iife.js.map +1 -0
  17. package/dist/iife/dialog-embed/embed.js +5 -0
  18. package/dist/iife/dialog-embed/embed.js.map +1 -0
  19. package/dist/iife/dialog-embed/index-85dfb3fa.js +27151 -0
  20. package/dist/iife/dialog-embed/index-85dfb3fa.js.map +1 -0
  21. package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogOverlay.d.ts +19 -0
  22. package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogPortal.d.ts +35 -0
  23. package/dist/iife/dialog-embed/src/components/DialogEmbed/index.d.ts +36 -0
  24. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
  25. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +14 -0
  26. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
  27. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
  28. package/dist/iife/dialog-embed/src/components/PlayerEmbed/index.d.ts +73 -0
  29. package/dist/iife/dialog-embed/src/components/PlayerEmbed/tests/data.d.ts +3 -0
  30. package/dist/iife/dialog-embed/src/index.d.ts +2 -0
  31. package/dist/iife/dialog-embed/src/utils/env.d.ts +12 -0
  32. package/dist/iife/dialog-embed/src/utils/events.d.ts +2 -0
  33. package/dist/iife/embeds.iife.js +444 -294
  34. package/dist/iife/embeds.iife.js.map +1 -1
  35. package/dist/iife/player-embed/browser-e32f9956.js +433 -0
  36. package/dist/iife/player-embed/browser-e32f9956.js.map +1 -0
  37. package/dist/iife/player-embed/embed.iife.js +1584 -0
  38. package/dist/iife/player-embed/embed.iife.js.map +1 -0
  39. package/dist/iife/player-embed/embed.js +5 -0
  40. package/dist/iife/player-embed/embed.js.map +1 -0
  41. package/dist/iife/player-embed/index-3ce3e134.js +26706 -0
  42. package/dist/iife/player-embed/index-3ce3e134.js.map +1 -0
  43. package/dist/iife/player-embed/src/components/DialogEmbed/DialogOverlay.d.ts +19 -0
  44. package/dist/iife/player-embed/src/components/DialogEmbed/DialogPortal.d.ts +35 -0
  45. package/dist/iife/player-embed/src/components/DialogEmbed/index.d.ts +36 -0
  46. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
  47. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +14 -0
  48. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
  49. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
  50. package/dist/iife/player-embed/src/components/PlayerEmbed/index.d.ts +73 -0
  51. package/dist/iife/player-embed/src/components/PlayerEmbed/tests/data.d.ts +3 -0
  52. package/dist/iife/player-embed/src/index.d.ts +2 -0
  53. package/dist/iife/player-embed/src/utils/env.d.ts +12 -0
  54. package/dist/iife/player-embed/src/utils/events.d.ts +2 -0
  55. package/package.json +9 -4
  56. package/src/components/DialogEmbed/Dialog.stories.ts +91 -0
  57. package/src/components/DialogEmbed/DialogOverlay.ts +131 -0
  58. package/src/components/DialogEmbed/DialogPortal.ts +126 -0
  59. package/src/components/DialogEmbed/index.ts +97 -0
  60. package/src/components/PlayerEmbed/controllers/event-forwarder.ts +2 -1
  61. package/src/components/PlayerEmbed/index.ts +10 -3
  62. package/src/index.ts +1 -0
  63. package/dist/es/index-b238c0dc.js +0 -9980
  64. package/dist/es/index-b238c0dc.js.map +0 -1
@@ -0,0 +1,97 @@
1
+ import { css, html, LitElement } from 'lit';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+ import { ifDefined } from 'lit/directives/if-defined.js';
4
+ import { v4 as uuidv4 } from 'uuid';
5
+
6
+ import type { PlayerEmbedProps } from '../PlayerEmbed';
7
+
8
+ import '../PlayerEmbed';
9
+ import './DialogPortal';
10
+
11
+ type DialogEmbedProps = Omit<PlayerEmbedProps, 'data'> & {
12
+ disableAutoplay?: boolean;
13
+ };
14
+
15
+ @customElement('vouch-embed-dialog')
16
+ class DialogEmbed extends LitElement {
17
+ static styles = [
18
+ css`
19
+ :host {
20
+ --vu-button-padding: 10px 20px;
21
+ --vu-button-background: #287179;
22
+ --vu-button-background-hover: #4faab2;
23
+
24
+ display: flex;
25
+ width: fit-content;
26
+ height: fit-content;
27
+ }
28
+ `
29
+ ];
30
+
31
+ @property({ type: String }) vouchId: DialogEmbedProps['vouchId'];
32
+ @property({ type: String }) templateId: DialogEmbedProps['templateId'];
33
+ @property({ type: Array }) questions: DialogEmbedProps['questions'];
34
+
35
+ @property({ type: String }) env: DialogEmbedProps['env'] = 'prod';
36
+ @property({ type: String }) apiKey: DialogEmbedProps['apiKey'] = '';
37
+ @property({ type: Boolean }) disableTracking: DialogEmbedProps['disableTracking'] = false;
38
+ @property({ type: String }) trackingSource: DialogEmbedProps['trackingSource'] = 'embedded_player';
39
+
40
+ @property({ type: Array }) controls: DialogEmbedProps['controls'];
41
+ @property({ type: String }) preload: DialogEmbedProps['preload'] = 'none';
42
+ @property({ type: Boolean }) disableAutoplay: DialogEmbedProps['disableAutoplay'] = false;
43
+ @property({ type: Number }) aspectRatio: DialogEmbedProps['aspectRatio'] = 0;
44
+
45
+ private _id = uuidv4();
46
+
47
+ private _handleRootClick = () => {
48
+ this.dispatchEvent(new CustomEvent('dialogembed:click', { detail: this._id, bubbles: true, composed: true }));
49
+ };
50
+
51
+ connectedCallback(): void {
52
+ super.connectedCallback();
53
+ this.addEventListener('click', this._handleRootClick);
54
+ }
55
+
56
+ disconnectedCallback(): void {
57
+ super.disconnectedCallback();
58
+ this.removeEventListener('click', this._handleRootClick);
59
+ }
60
+
61
+ render() {
62
+ return html`
63
+ <slot>
64
+ <vmp-button size="large">Play</vmp-button>
65
+ </slot>
66
+ <vouch-embed-dialog-portal
67
+ id=${this._id}
68
+ ?autoplay=${false}
69
+ vouchId=${ifDefined(this.vouchId)}
70
+ templateId=${ifDefined(this.templateId)}
71
+ .questions=${this.questions}
72
+ .controls=${this.controls}
73
+ env=${ifDefined(this.env)}
74
+ apiKey=${ifDefined(this.apiKey)}
75
+ ?disableTracking=${this.disableTracking}
76
+ trackingSource=${ifDefined(this.trackingSource)}
77
+ preload=${ifDefined(this.preload)}
78
+ aspectRatio=${this.aspectRatio}
79
+ ></vouch-embed-dialog-portal>
80
+ `;
81
+ }
82
+ }
83
+
84
+ declare global {
85
+ interface HTMLElementTagNameMap {
86
+ 'vouch-embed-dialog': DialogEmbed;
87
+ }
88
+
89
+ namespace JSX {
90
+ interface IntrinsicElements {
91
+ 'vouch-embed-dialog': DialogEmbed;
92
+ }
93
+ }
94
+ }
95
+
96
+ export { DialogEmbed };
97
+ export type { DialogEmbedProps };
@@ -2,6 +2,7 @@ import { createRef, ref } from 'lit/directives/ref.js';
2
2
 
3
3
  import type { PlayerEmbed } from '..';
4
4
  import type { ReactiveController, ReactiveControllerHost } from 'lit';
5
+ import type { DirectiveResult } from 'lit/directive.js';
5
6
  import type { Ref } from 'lit/directives/ref.js';
6
7
 
7
8
  import { forwardEvent } from '~/utils/events';
@@ -21,7 +22,7 @@ class EventForwardController implements ReactiveController {
21
22
  host.addController(this);
22
23
  }
23
24
 
24
- register() {
25
+ register(): DirectiveResult {
25
26
  return ref(this._forwardElementRef);
26
27
  }
27
28
 
@@ -5,7 +5,6 @@ import { createRef, ref } from 'lit/directives/ref.js';
5
5
 
6
6
  import type { Scene, Scenes, TemplateInstance } from '@vouchfor/canvas-video';
7
7
  import type { MediaPlayer, MediaPlayerProps } from '@vouchfor/media-player';
8
- import type { Ref } from 'lit/directives/ref.js';
9
8
  import type { Environment } from '~/utils/env';
10
9
 
11
10
  import { EventForwardController } from './controllers/event-forwarder';
@@ -35,8 +34,6 @@ class PlayerEmbed extends LitElement {
35
34
  `
36
35
  ];
37
36
 
38
- private _mediaPlayerRef: Ref<MediaPlayer> = createRef();
39
-
40
37
  @property({ type: Object }) data: PlayerEmbedProps['data'];
41
38
  @property({ type: String }) vouchId: PlayerEmbedProps['vouchId'];
42
39
  @property({ type: String }) templateId: PlayerEmbedProps['templateId'];
@@ -92,10 +89,16 @@ class PlayerEmbed extends LitElement {
92
89
  return this._fetcherController.fetching;
93
90
  }
94
91
 
92
+ private _mediaPlayerRef = createRef<MediaPlayer>();
93
+
95
94
  get waiting() {
96
95
  return this._mediaPlayerRef.value?.waiting;
97
96
  }
98
97
 
98
+ get initialised() {
99
+ return this._mediaPlayerRef.value?.initialised;
100
+ }
101
+
99
102
  get seeking() {
100
103
  return this._mediaPlayerRef.value?.seeking;
101
104
  }
@@ -180,6 +183,10 @@ class PlayerEmbed extends LitElement {
180
183
  this._mediaPlayerRef.value?.pause();
181
184
  }
182
185
 
186
+ reset(time = 0, play = false) {
187
+ this._mediaPlayerRef.value?.reset(time, play);
188
+ }
189
+
183
190
  setScene(index: number) {
184
191
  this._mediaPlayerRef.value?.setScene(index);
185
192
  }
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { PlayerEmbed } from '~/components/PlayerEmbed';
2
+ export { DialogEmbed } from '~/components/DialogEmbed';