@vouchfor/embeds 0.0.0-experiment.eb79200 → 0.0.0-experiment.ed7c00c

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 +1025 -1084
  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 +3006 -445
  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} +41 -30
  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 -8
  39. package/dist/es/components/Embed/controllers/tracking.d.ts +0 -28
  40. package/dist/es/components/Embed/index.d.ts +0 -65
  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 -43
  44. package/src/components/Embed/controllers/tracking.ts +0 -268
  45. package/src/components/Embed/index.ts +0 -204
  46. /package/dist/es/{utils → src/utils}/events.d.ts +0 -0
@@ -1,204 +0,0 @@
1
- import { html, LitElement } from 'lit';
2
- import { customElement, state, 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 } 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
- vouchHashId?: string;
24
- enableTracking?: boolean;
25
- trackingSource?: string;
26
- };
27
-
28
- @customElement('vouch-embed')
29
- class Embed extends LitElement {
30
- private _mediaPlayerRef: Ref<MediaPlayer> = createRef();
31
-
32
- @property({ type: Object, attribute: 'data' }) propData: EmbedProps['data'];
33
- @property({ type: String }) vouchHashId: EmbedProps['vouchHashId'];
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
- @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
- @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
-
51
- private eventController = new EventForwardController(this, [
52
- 'durationchange',
53
- 'ended',
54
- 'error',
55
- 'loadeddata',
56
- 'pause',
57
- 'stalled',
58
- 'play',
59
- 'playing',
60
- 'ratechange',
61
- 'scenechange',
62
- 'seeking',
63
- 'seeked',
64
- 'timeupdate',
65
- 'volumechange',
66
- 'waiting',
67
-
68
- 'video:loadeddata',
69
- 'video:seeked',
70
- 'video:play',
71
- 'video:playing',
72
- 'video:pause',
73
- 'video:stalled',
74
- 'video:timeupdate',
75
- 'video:ended',
76
- 'video:error'
77
- ]);
78
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
79
- // @ts-ignore
80
- private trackingController = new TrackingController(this);
81
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
82
- // @ts-ignore
83
- private fetcherController = new FetcherController(this);
84
-
85
- get waiting() {
86
- return this._mediaPlayerRef.value?.waiting;
87
- }
88
-
89
- get seeking() {
90
- return this._mediaPlayerRef.value?.seeking;
91
- }
92
-
93
- get paused() {
94
- return this._mediaPlayerRef.value?.paused;
95
- }
96
-
97
- get captions() {
98
- return this._mediaPlayerRef.value?.captions;
99
- }
100
-
101
- get fullscreen() {
102
- return this._mediaPlayerRef.value?.fullscreen;
103
- }
104
-
105
- get duration() {
106
- return this._mediaPlayerRef.value?.duration;
107
- }
108
-
109
- set currentTime(value: number) {
110
- if (this._mediaPlayerRef.value) {
111
- this._mediaPlayerRef.value.currentTime = value;
112
- }
113
- }
114
- get currentTime() {
115
- return this._mediaPlayerRef.value?.currentTime ?? 0;
116
- }
117
-
118
- set playbackRate(value: number) {
119
- if (this._mediaPlayerRef.value) {
120
- this._mediaPlayerRef.value.playbackRate = value;
121
- }
122
- }
123
- get playbackRate() {
124
- return this._mediaPlayerRef.value?.playbackRate ?? 1;
125
- }
126
-
127
- set volume(value: number) {
128
- if (this._mediaPlayerRef.value) {
129
- this._mediaPlayerRef.value.volume = value;
130
- }
131
- }
132
- get volume() {
133
- return this._mediaPlayerRef.value?.volume ?? 1;
134
- }
135
-
136
- set muted(value: boolean) {
137
- if (this._mediaPlayerRef.value) {
138
- this._mediaPlayerRef.value.muted = value;
139
- }
140
- }
141
- get muted() {
142
- return this._mediaPlayerRef.value?.muted ?? false;
143
- }
144
-
145
- get scene(): Scene | null {
146
- return this._mediaPlayerRef.value?.scene ?? null;
147
- }
148
-
149
- get scenes(): Scene[] {
150
- return this._mediaPlayerRef.value?.scenes ?? [];
151
- }
152
-
153
- get videoState() {
154
- return this._mediaPlayerRef.value?.videoState;
155
- }
156
-
157
- get mediaPlayer() {
158
- return this._mediaPlayerRef.value;
159
- }
160
-
161
- play() {
162
- this._mediaPlayerRef.value?.play();
163
- }
164
-
165
- pause() {
166
- this._mediaPlayerRef.value?.pause();
167
- }
168
-
169
- setScene(index: number) {
170
- this._mediaPlayerRef.value?.setScene(index);
171
- }
172
-
173
- render() {
174
- return html`
175
- <vmp-media-player
176
- ${ref(this._mediaPlayerRef)}
177
- ${this.eventController.register()}
178
- ?autoplay=${this.autoplay}
179
- ?loading=${this.fetching}
180
- .data=${this.data}
181
- .instance=${this.instance}
182
- resolution=${ifDefined(this.resolution)}
183
- aspectRatio=${ifDefined(this.aspectRatio)}
184
- preload=${ifDefined(this.preload)}
185
- .controls=${this.controls}
186
- ></vmp-media-player>
187
- `;
188
- }
189
- }
190
-
191
- declare global {
192
- interface HTMLElementTagNameMap {
193
- 'vouch-embed': Embed;
194
- }
195
-
196
- namespace JSX {
197
- interface IntrinsicElements {
198
- 'vouch-embed': Embed;
199
- }
200
- }
201
- }
202
-
203
- export { Embed };
204
- export type { EmbedProps };
File without changes