@vouchfor/embeds 0.0.0-experiment.1b80037 → 0.0.0-experiment.1edf9a0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. package/dist/es/embeds.js +1016 -1106
  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/{components/Embed → src/components/PlayerEmbed}/controllers/event-forwarder.d.ts +6 -5
  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 +75 -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/iife/dialog-embed/embed.iife.js +4042 -0
  16. package/dist/iife/dialog-embed/embed.iife.js.map +1 -0
  17. package/dist/iife/embeds.iife.js +2998 -444
  18. package/dist/iife/embeds.iife.js.map +1 -1
  19. package/dist/iife/player-embed/embed.iife.js +3904 -0
  20. package/dist/iife/player-embed/embed.iife.js.map +1 -0
  21. package/package.json +46 -33
  22. package/src/components/DialogEmbed/Dialog.stories.ts +91 -0
  23. package/src/components/DialogEmbed/DialogOverlay.ts +131 -0
  24. package/src/components/DialogEmbed/DialogPortal.ts +126 -0
  25. package/src/components/DialogEmbed/index.ts +97 -0
  26. package/src/components/PlayerEmbed/MultiEmbed.stories.ts +135 -0
  27. package/src/components/{Embed/Embed.stories.ts → PlayerEmbed/PlayerEmbed.stories.ts} +38 -24
  28. package/src/components/{Embed → PlayerEmbed}/controllers/event-forwarder.ts +6 -5
  29. package/src/components/PlayerEmbed/controllers/fetcher.ts +152 -0
  30. package/src/components/PlayerEmbed/controllers/tracking/index.ts +224 -0
  31. package/src/components/PlayerEmbed/controllers/tracking/utils.ts +95 -0
  32. package/src/components/PlayerEmbed/index.ts +262 -0
  33. package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +87 -0
  34. package/src/components/PlayerEmbed/tests/data.ts +227 -0
  35. package/src/components/PlayerEmbed/tests/media-data.ts +22 -0
  36. package/src/index.ts +2 -1
  37. package/src/utils/env.ts +18 -32
  38. package/dist/es/components/Embed/controllers/fetcher.d.ts +0 -20
  39. package/dist/es/components/Embed/controllers/tracking.d.ts +0 -28
  40. package/dist/es/components/Embed/index.d.ts +0 -63
  41. package/dist/es/index.d.ts +0 -1
  42. package/dist/es/utils/env.d.ts +0 -18
  43. package/src/components/Embed/controllers/fetcher.ts +0 -115
  44. package/src/components/Embed/controllers/tracking.ts +0 -261
  45. package/src/components/Embed/index.ts +0 -208
  46. /package/dist/es/{utils → src/utils}/events.d.ts +0 -0
@@ -1,208 +0,0 @@
1
- import { html, LitElement } from 'lit';
2
- import { customElement, property } from 'lit/decorators.js';
3
- import { ifDefined } from 'lit/directives/if-defined.js';
4
- import { createRef, ref } from 'lit/directives/ref.js';
5
-
6
- import type { Scene, TemplateInstance } from '@vouchfor/canvas-video';
7
- import type { MediaPlayer, MediaPlayerProps } from '@vouchfor/media-player';
8
- import type { Ref } from 'lit/directives/ref.js';
9
- import type { Environment } from '~/utils/env';
10
-
11
- import { EventForwardController } from './controllers/event-forwarder';
12
- import { FetcherController } from './controllers/fetcher';
13
- import { TrackingController } from './controllers/tracking';
14
-
15
- import '@vouchfor/media-player';
16
-
17
- type EmbedProps = Pick<
18
- MediaPlayerProps,
19
- 'data' | 'resolution' | 'aspectRatio' | 'preload' | 'autoplay' | 'controls'
20
- > & {
21
- env: Environment;
22
- apiKey: string;
23
- vouchId?: string;
24
- templateId?: string;
25
- };
26
-
27
- @customElement('vouch-embed')
28
- class Embed extends LitElement {
29
- private _mediaPlayerRef: Ref<MediaPlayer> = createRef();
30
-
31
- @property({ type: Object, attribute: 'data' }) data: EmbedProps['data'];
32
- @property({ type: String }) vouchId: EmbedProps['vouchId'];
33
- @property({ type: String }) templateId: EmbedProps['templateId'];
34
-
35
- @property({ type: String }) env: EmbedProps['env'] = 'prod';
36
- @property({ type: String }) apiKey: EmbedProps['apiKey'] = '';
37
-
38
- @property({ type: String }) preload: EmbedProps['preload'] = 'auto';
39
- @property({ type: Boolean }) autoplay: EmbedProps['autoplay'] = false;
40
-
41
- @property({ type: Number }) resolution: EmbedProps['resolution'] = 1080;
42
- @property({ type: Number }) aspectRatio: EmbedProps['aspectRatio'] = 0;
43
- @property({ type: Array }) controls: EmbedProps['controls'];
44
-
45
- private eventController = new EventForwardController(this, [
46
- 'durationchange',
47
- 'ended',
48
- 'error',
49
- 'loadeddata',
50
- 'pause',
51
- 'stalled',
52
- 'play',
53
- 'playing',
54
- 'ratechange',
55
- 'scenechange',
56
- 'seeking',
57
- 'seeked',
58
- 'timeupdate',
59
- 'volumechange',
60
- 'waiting',
61
-
62
- 'video:loadeddata',
63
- 'video:seeked',
64
- 'video:play',
65
- 'video:playing',
66
- 'video:pause',
67
- 'video:stalled',
68
- 'video:timeupdate',
69
- 'video:ended',
70
- 'video:error'
71
- ]);
72
- private _fetcherController = new FetcherController(this);
73
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
74
- // @ts-ignore
75
- private _trackingController = new TrackingController(this);
76
-
77
- get vouch() {
78
- return this._fetcherController.vouch;
79
- }
80
-
81
- get template(): TemplateInstance | null {
82
- return this._fetcherController.template;
83
- }
84
-
85
- get fetching() {
86
- return this._fetcherController.fetching;
87
- }
88
-
89
- get waiting() {
90
- return this._mediaPlayerRef.value?.waiting;
91
- }
92
-
93
- get seeking() {
94
- return this._mediaPlayerRef.value?.seeking;
95
- }
96
-
97
- get paused() {
98
- return this._mediaPlayerRef.value?.paused;
99
- }
100
-
101
- get captions() {
102
- return this._mediaPlayerRef.value?.captions;
103
- }
104
-
105
- get fullscreen() {
106
- return this._mediaPlayerRef.value?.fullscreen;
107
- }
108
-
109
- get duration() {
110
- return this._mediaPlayerRef.value?.duration;
111
- }
112
-
113
- set currentTime(value: number) {
114
- if (this._mediaPlayerRef.value) {
115
- this._mediaPlayerRef.value.currentTime = value;
116
- }
117
- }
118
- get currentTime() {
119
- return this._mediaPlayerRef.value?.currentTime ?? 0;
120
- }
121
-
122
- set playbackRate(value: number) {
123
- if (this._mediaPlayerRef.value) {
124
- this._mediaPlayerRef.value.playbackRate = value;
125
- }
126
- }
127
- get playbackRate() {
128
- return this._mediaPlayerRef.value?.playbackRate ?? 1;
129
- }
130
-
131
- set volume(value: number) {
132
- if (this._mediaPlayerRef.value) {
133
- this._mediaPlayerRef.value.volume = value;
134
- }
135
- }
136
- get volume() {
137
- return this._mediaPlayerRef.value?.volume ?? 1;
138
- }
139
-
140
- set muted(value: boolean) {
141
- if (this._mediaPlayerRef.value) {
142
- this._mediaPlayerRef.value.muted = value;
143
- }
144
- }
145
- get muted() {
146
- return this._mediaPlayerRef.value?.muted ?? false;
147
- }
148
-
149
- get scene(): Scene | null {
150
- return this._mediaPlayerRef.value?.scene ?? null;
151
- }
152
-
153
- get scenes(): Scene[] {
154
- return this._mediaPlayerRef.value?.scenes ?? [];
155
- }
156
-
157
- get videoState() {
158
- return this._mediaPlayerRef.value?.videoState;
159
- }
160
-
161
- get mediaPlayer() {
162
- return this._mediaPlayerRef.value;
163
- }
164
-
165
- play() {
166
- this._mediaPlayerRef.value?.play();
167
- }
168
-
169
- pause() {
170
- this._mediaPlayerRef.value?.pause();
171
- }
172
-
173
- setScene(index: number) {
174
- this._mediaPlayerRef.value?.setScene(index);
175
- }
176
-
177
- render() {
178
- return html`
179
- <vmp-media-player
180
- ${ref(this._mediaPlayerRef)}
181
- ${this.eventController.register()}
182
- ?autoplay=${this.autoplay}
183
- ?loading=${this.fetching}
184
- .data=${this.vouch}
185
- .template=${this.template}
186
- resolution=${ifDefined(this.resolution)}
187
- aspectRatio=${ifDefined(this.aspectRatio)}
188
- preload=${ifDefined(this.preload)}
189
- .controls=${this.controls}
190
- ></vmp-media-player>
191
- `;
192
- }
193
- }
194
-
195
- declare global {
196
- interface HTMLElementTagNameMap {
197
- 'vouch-embed': Embed;
198
- }
199
-
200
- namespace JSX {
201
- interface IntrinsicElements {
202
- 'vouch-embed': Embed;
203
- }
204
- }
205
- }
206
-
207
- export { Embed };
208
- export type { EmbedProps };
File without changes