@smartimpact-it/modern-video-embed 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +1205 -0
  2. package/dist/components/VimeoEmbed.d.ts +143 -0
  3. package/dist/components/VimeoEmbed.d.ts.map +1 -0
  4. package/dist/components/VimeoEmbed.js +1176 -0
  5. package/dist/components/VimeoEmbed.js.map +1 -0
  6. package/dist/components/VimeoEmbed.min.js +1 -0
  7. package/dist/components/YouTubeEmbed.d.ts +225 -0
  8. package/dist/components/YouTubeEmbed.d.ts.map +1 -0
  9. package/dist/components/YouTubeEmbed.js +1354 -0
  10. package/dist/components/YouTubeEmbed.js.map +1 -0
  11. package/dist/components/YouTubeEmbed.min.js +1 -0
  12. package/dist/css/components.css +349 -0
  13. package/dist/css/components.css.map +1 -0
  14. package/dist/css/components.min.css +1 -0
  15. package/dist/css/main.css +12210 -0
  16. package/dist/css/main.css.map +1 -0
  17. package/dist/css/main.min.css +7 -0
  18. package/dist/index.d.ts +3 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +4 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/index.min.js +1 -0
  23. package/dist/types/index.d.ts +7 -0
  24. package/dist/types/index.d.ts.map +1 -0
  25. package/dist/types/index.js +5 -0
  26. package/dist/types/index.js.map +1 -0
  27. package/dist/vimeo-only.d.ts +7 -0
  28. package/dist/vimeo-only.d.ts.map +1 -0
  29. package/dist/vimeo-only.js +8 -0
  30. package/dist/vimeo-only.js.map +1 -0
  31. package/dist/vimeo-only.min.js +1 -0
  32. package/dist/youtube-only.d.ts +7 -0
  33. package/dist/youtube-only.d.ts.map +1 -0
  34. package/dist/youtube-only.js +8 -0
  35. package/dist/youtube-only.js.map +1 -0
  36. package/dist/youtube-only.min.js +1 -0
  37. package/package.json +75 -0
  38. package/src/components/VimeoEmbed.ts +1340 -0
  39. package/src/components/YouTubeEmbed.ts +1568 -0
  40. package/src/index.ts +3 -0
  41. package/src/styles/README.md +56 -0
  42. package/src/styles/components.scss +7 -0
  43. package/src/styles/main.scss +10 -0
  44. package/src/styles/vimeo-embed.scss +255 -0
  45. package/src/styles/youtube-embed.scss +261 -0
  46. package/src/types/common.d.ts +198 -0
  47. package/src/types/index.ts +7 -0
  48. package/src/types/vimeo-embed.d.ts +80 -0
  49. package/src/types/youtube-embed.d.ts +83 -0
  50. package/src/vimeo-only.ts +9 -0
  51. package/src/youtube-only.ts +9 -0
@@ -0,0 +1,198 @@
1
+ /**
2
+ * Common Types for Video Embed Components
3
+ */
4
+
5
+ /**
6
+ * Player state information
7
+ */
8
+ export interface PlayerState {
9
+ playing: boolean;
10
+ muted: boolean;
11
+ videoId: string;
12
+ ready: boolean;
13
+ initialized: boolean;
14
+ }
15
+
16
+ /**
17
+ * YouTube Player Parameters
18
+ * @see https://developers.google.com/youtube/player_parameters
19
+ */
20
+ export interface YouTubePlayerVars {
21
+ /** Whether to autoplay the video */
22
+ autoplay?: 0 | 1;
23
+ /** Whether to show video annotations */
24
+ iv_load_policy?: 1 | 3;
25
+ /** Start time in seconds */
26
+ start?: number;
27
+ /** End time in seconds */
28
+ end?: number;
29
+ /** Whether to show related videos */
30
+ rel?: 0 | 1;
31
+ /** Whether to show controls */
32
+ controls?: 0 | 1;
33
+ /** Whether to show YouTube logo */
34
+ modestbranding?: 0 | 1;
35
+ /** Whether to loop the video (requires playlist param) */
36
+ loop?: 0 | 1;
37
+ /** Playlist ID for looping */
38
+ playlist?: string;
39
+ /** Playback quality */
40
+ quality?:
41
+ | "small"
42
+ | "medium"
43
+ | "large"
44
+ | "hd720"
45
+ | "hd1080"
46
+ | "highres"
47
+ | "default";
48
+ /** Player color */
49
+ color?: "red" | "white";
50
+ /** Closed captions */
51
+ cc_load_policy?: 0 | 1;
52
+ /** Closed captions language */
53
+ cc_lang_pref?: string;
54
+ /** Disable keyboard controls */
55
+ disablekb?: 0 | 1;
56
+ /** Enable JavaScript API */
57
+ enablejsapi?: 0 | 1;
58
+ /** Fullscreen button */
59
+ fs?: 0 | 1;
60
+ /** Player language */
61
+ hl?: string;
62
+ /** Origin parameter for security */
63
+ origin?: string;
64
+ /** Widget referrer */
65
+ widget_referrer?: string;
66
+ /** Additional parameters */
67
+ [key: string]: string | number | undefined;
68
+ }
69
+
70
+ /**
71
+ * Vimeo Player Parameters
72
+ * @see https://developer.vimeo.com/player/sdk/embed
73
+ */
74
+ export interface VimeoPlayerVars {
75
+ /** Whether to loop the video */
76
+ loop?: boolean;
77
+ /** Custom player color (hex without #) */
78
+ color?: string;
79
+ /** Show video title */
80
+ title?: boolean;
81
+ /** Show video author */
82
+ byline?: boolean;
83
+ /** Show author portrait */
84
+ portrait?: boolean;
85
+ /** Do Not Track */
86
+ dnt?: boolean;
87
+ /** Playback quality */
88
+ quality?: "360p" | "540p" | "720p" | "1080p" | "2k" | "4k" | "auto";
89
+ /** Muted */
90
+ muted?: boolean;
91
+ /** Background mode */
92
+ background?: boolean;
93
+ /** Transparent background */
94
+ transparent?: boolean;
95
+ /** Speed controls */
96
+ speed?: boolean;
97
+ /** Keyboard shortcuts */
98
+ keyboard?: boolean;
99
+ /** Picture in Picture */
100
+ pip?: boolean;
101
+ /** Playsinline on mobile */
102
+ playsinline?: boolean;
103
+ /** Responsive embed */
104
+ responsive?: boolean;
105
+ /** Additional parameters */
106
+ [key: string]: string | number | boolean | undefined;
107
+ }
108
+
109
+ /**
110
+ * Custom event detail for video embed events
111
+ */
112
+ export interface VideoEventDetail {
113
+ /** Video ID */
114
+ videoId?: string;
115
+ /** Current time in seconds */
116
+ currentTime?: number;
117
+ /** Video duration in seconds */
118
+ duration?: number;
119
+ /** Error message */
120
+ message?: string;
121
+ /** Error code */
122
+ code?: number | string;
123
+ /** Additional data */
124
+ [key: string]: any;
125
+ }
126
+
127
+ /**
128
+ * Video embed custom events
129
+ */
130
+ export interface VideoEmbedEventMap {
131
+ ready: CustomEvent<VideoEventDetail>;
132
+ play: CustomEvent<VideoEventDetail>;
133
+ pause: CustomEvent<VideoEventDetail>;
134
+ ended: CustomEvent<VideoEventDetail>;
135
+ error: CustomEvent<VideoEventDetail>;
136
+ timeupdate: CustomEvent<VideoEventDetail>;
137
+ loadstart: CustomEvent<VideoEventDetail>;
138
+ bufferstart: CustomEvent<VideoEventDetail>;
139
+ bufferend: CustomEvent<VideoEventDetail>;
140
+ qualitychange: CustomEvent<QualityChangeDetail>;
141
+ }
142
+
143
+ /**
144
+ * Attribute change callback parameters
145
+ */
146
+ export interface AttributeChangeParams {
147
+ name: string;
148
+ oldValue: string | null;
149
+ newValue: string | null;
150
+ }
151
+
152
+ /**
153
+ * Video quality options
154
+ */
155
+ export type YouTubeQuality =
156
+ | "tiny" // 144p
157
+ | "small" // 240p
158
+ | "medium" // 360p
159
+ | "large" // 480p
160
+ | "hd720" // 720p
161
+ | "hd1080" // 1080p
162
+ | "hd1440" // 1440p
163
+ | "hd2160" // 2160p (4K)
164
+ | "highres" // Higher than 1080p
165
+ | "default" // Auto quality
166
+ | "auto"; // Auto quality
167
+
168
+ export type VimeoQuality =
169
+ | "240p"
170
+ | "360p"
171
+ | "540p"
172
+ | "720p"
173
+ | "1080p"
174
+ | "2k" // 1440p
175
+ | "4k" // 2160p
176
+ | "auto";
177
+
178
+ /**
179
+ * Quality change event detail
180
+ */
181
+ export interface QualityChangeDetail {
182
+ /** Previous quality level */
183
+ oldQuality: string;
184
+ /** New quality level */
185
+ newQuality: string;
186
+ /** Available quality levels */
187
+ availableQualities?: string[];
188
+ }
189
+
190
+ /**
191
+ * Fullscreen API types
192
+ */
193
+ export interface FullscreenAPI {
194
+ requestFullscreen(): Promise<void>;
195
+ exitFullscreen(): Promise<void>;
196
+ readonly fullscreenElement: Element | null;
197
+ readonly fullscreenEnabled: boolean;
198
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Central export point for all type definitions
3
+ */
4
+
5
+ export * from "./common";
6
+ export type { YouTubeEmbedElement } from "./youtube-embed";
7
+ export type { VimeoEmbedElement } from "./vimeo-embed";
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Vimeo Embed Component API Documentation
3
+ */
4
+
5
+ import type {
6
+ PlayerState,
7
+ VimeoPlayerVars,
8
+ VideoEventDetail,
9
+ VimeoQuality,
10
+ } from "./common";
11
+
12
+ export interface VimeoEmbedElement extends HTMLElement {
13
+ // Properties
14
+ url: string;
15
+ videoId: string;
16
+ autoplay: boolean;
17
+ controls: boolean;
18
+ lazy: boolean;
19
+ muted: boolean;
20
+ poster: string;
21
+ playing: boolean;
22
+ background: boolean;
23
+ playerVars: VimeoPlayerVars;
24
+
25
+ // Methods
26
+ play(): Promise<void>;
27
+ pause(): void;
28
+ stopVideo(): void;
29
+ mute(): void;
30
+ unmute(): void;
31
+ togglePlay(): void;
32
+ toggleMute(): void;
33
+ loadVideo(videoIdOrUrl: string): void;
34
+ getPlayerState(): PlayerState;
35
+ isPlaying(): boolean;
36
+ isMuted(): Promise<boolean>;
37
+ getCurrentTime(): Promise<number>;
38
+ }
39
+
40
+ // Custom Events
41
+ export interface VimeoEmbedEvents {
42
+ ready: CustomEvent<VideoEventDetail>;
43
+ play: CustomEvent<VideoEventDetail>;
44
+ pause: CustomEvent<VideoEventDetail>;
45
+ stop: CustomEvent<VideoEventDetail>;
46
+ ended: CustomEvent<VideoEventDetail>;
47
+ error: CustomEvent<VideoEventDetail>;
48
+ connected: CustomEvent<void>;
49
+ disconnected: CustomEvent<void>;
50
+ timeupdate: CustomEvent<VideoEventDetail>;
51
+ }
52
+
53
+ // Usage Examples:
54
+
55
+ // HTML Usage:
56
+ // <vimeo-embed
57
+ // url="https://vimeo.com/123456789"
58
+ // autoplay
59
+ // controls
60
+ // lazy
61
+ // muted
62
+ // poster="custom-thumbnail.jpg">
63
+ // </vimeo-embed>
64
+
65
+ // JavaScript Usage:
66
+ // const embed = document.querySelector('vimeo-embed');
67
+ // embed.url = 'https://vimeo.com/123456789';
68
+ // embed.autoplay = true;
69
+ // embed.play();
70
+
71
+ // Event Listening:
72
+ // embed.addEventListener('ready', () => console.log('Player ready'));
73
+ // embed.addEventListener('play', () => console.log('Video started'));
74
+ // embed.addEventListener('pause', () => console.log('Video paused'));
75
+
76
+ declare global {
77
+ interface HTMLElementTagNameMap {
78
+ "vimeo-embed": VimeoEmbedElement;
79
+ }
80
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * YouTube Embed Component API Documentation
3
+ */
4
+
5
+ import type {
6
+ PlayerState,
7
+ YouTubePlayerVars,
8
+ VideoEventDetail,
9
+ YouTubeQuality,
10
+ } from "./common";
11
+
12
+ export interface YouTubeEmbedElement extends HTMLElement {
13
+ // Properties
14
+ url: string;
15
+ videoId: string;
16
+ autoplay: boolean;
17
+ controls: boolean;
18
+ lazy: boolean;
19
+ muted: boolean;
20
+ poster: string;
21
+ playing: boolean;
22
+ background: boolean;
23
+ playerVars: YouTubePlayerVars;
24
+
25
+ // Methods
26
+ play(): Promise<void>;
27
+ pause(): void;
28
+ stopVideo(): void;
29
+ mute(): void;
30
+ unmute(): void;
31
+ togglePlay(): void;
32
+ toggleMute(): void;
33
+ loadVideo(videoIdOrUrl: string): void;
34
+ getPlayerState(): PlayerState;
35
+ getCurrentTime(): number;
36
+ isPlaying(): boolean;
37
+ isMuted(): boolean;
38
+ }
39
+
40
+ // Custom Events
41
+ export interface YouTubeEmbedEvents {
42
+ ready: CustomEvent<VideoEventDetail>;
43
+ play: CustomEvent<VideoEventDetail>;
44
+ pause: CustomEvent<VideoEventDetail>;
45
+ ended: CustomEvent<VideoEventDetail>;
46
+ error: CustomEvent<VideoEventDetail>;
47
+ timeupdate: CustomEvent<VideoEventDetail>;
48
+ stop: CustomEvent<VideoEventDetail>;
49
+ connected: CustomEvent<void>;
50
+ disconnected: CustomEvent<void>;
51
+ }
52
+
53
+ // Usage Examples:
54
+
55
+ // HTML Usage:
56
+ // <youtube-embed
57
+ // url="https://www.youtube.com/watch?v=dQw4w9WgXcQ"
58
+ // autoplay
59
+ // controls
60
+ // lazy
61
+ // muted
62
+ // poster="custom-thumbnail.jpg"
63
+ // player-vars='{"loop": 1, "quality": "hd720"}'>
64
+ // </youtube-embed>
65
+
66
+ // JavaScript Usage:
67
+ // const embed = document.querySelector('youtube-embed');
68
+ // embed.url = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
69
+ // embed.autoplay = true;
70
+ // embed.playerVars = { loop: 1, quality: 'hd720' };
71
+ // embed.play();
72
+
73
+ // Event Listening:
74
+ // embed.addEventListener('ready', (e) => console.log('Player ready', e.detail));
75
+ // embed.addEventListener('play', (e) => console.log('Video started', e.detail));
76
+ // embed.addEventListener('pause', (e) => console.log('Video paused', e.detail));
77
+ // embed.addEventListener('error', (e) => console.error('Error:', e.detail.message));
78
+
79
+ declare global {
80
+ interface HTMLElementTagNameMap {
81
+ "youtube-embed": YouTubeEmbedElement;
82
+ }
83
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Vimeo-only bundle entry point
3
+ * Use this for smaller bundle size when only Vimeo embeds are needed
4
+ */
5
+
6
+ export { VimeoEmbed } from "./components/VimeoEmbed";
7
+
8
+ // Auto-register the custom element
9
+ import "./components/VimeoEmbed";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * YouTube-only bundle entry point
3
+ * Use this for smaller bundle size when only YouTube embeds are needed
4
+ */
5
+
6
+ export { YouTubeEmbed } from "./components/YouTubeEmbed";
7
+
8
+ // Auto-register the custom element
9
+ import "./components/YouTubeEmbed";