@vouchfor/embeds 0.0.0-experiment.0dd23b5 → 0.0.0-experiment.0e35ffd

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