tiny-essentials 1.28.4 → 1.28.6

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 (66) hide show
  1. package/README.md +18 -1
  2. package/changelog/1/28/5.md +31 -0
  3. package/changelog/1/28/6.md +11 -0
  4. package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
  5. package/dist/v1/TinyBasicsEs.min.js +1 -1
  6. package/dist/v1/TinyEssentials.min.js +1 -1
  7. package/dist/v1/TinyIframeEvents.min.js +1 -1
  8. package/dist/v1/TinyLocalStorage.min.js +1 -1
  9. package/dist/v1/TinyMediaPlayer.min.js +1 -1
  10. package/dist/v1/TinyNewWinEvents.min.js +1 -1
  11. package/dist/v1/TinyRadioFm.min.js +1 -1
  12. package/dist/v1/TinySmartScroller.min.js +1 -1
  13. package/dist/v1/TinyTimeout.min.js +1 -1
  14. package/dist/v1/TinyUploadClicker.min.js +1 -1
  15. package/dist/v1/basics/index.cjs +4 -0
  16. package/dist/v1/basics/index.d.mts +3 -2
  17. package/dist/v1/basics/index.mjs +3 -2
  18. package/dist/v1/basics/mediaContent.cjs +1 -0
  19. package/dist/v1/basics/mediaContent.d.mts +4 -0
  20. package/dist/v1/basics/mediaContent.mjs +1 -0
  21. package/dist/v1/basics/objChecker.cjs +16 -0
  22. package/dist/v1/basics/objChecker.d.mts +12 -0
  23. package/dist/v1/basics/objChecker.mjs +14 -0
  24. package/dist/v1/basics/objFilter.cjs +0 -2
  25. package/dist/v1/basics/objFilter.d.mts +0 -2
  26. package/dist/v1/basics/objFilter.mjs +1 -2
  27. package/dist/v1/basics/promiseUtils.cjs +101 -0
  28. package/dist/v1/basics/promiseUtils.d.mts +31 -0
  29. package/dist/v1/basics/promiseUtils.mjs +89 -0
  30. package/dist/v1/css/TinyLoadingScreen.min.css +1 -1
  31. package/dist/v1/index.cjs +4 -0
  32. package/dist/v1/index.d.mts +3 -2
  33. package/dist/v1/index.mjs +3 -2
  34. package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.cjs +318 -0
  35. package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.d.mts +143 -0
  36. package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.mjs +283 -0
  37. package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.cjs +315 -0
  38. package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.d.mts +143 -0
  39. package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.mjs +280 -0
  40. package/dist/v1/libs/TinyMediaPlayer/SoundCloud.cjs +792 -0
  41. package/dist/v1/libs/TinyMediaPlayer/SoundCloud.d.mts +300 -0
  42. package/dist/v1/libs/TinyMediaPlayer/SoundCloud.mjs +697 -0
  43. package/dist/v1/libs/TinyMediaPlayer/Youtube.cjs +783 -0
  44. package/dist/v1/libs/TinyMediaPlayer/Youtube.d.mts +355 -0
  45. package/dist/v1/libs/TinyMediaPlayer/Youtube.mjs +694 -0
  46. package/dist/v1/libs/TinyMediaPlayer/docs/SoundCloudWidget.cjs +381 -0
  47. package/dist/v1/libs/TinyMediaPlayer/docs/SoundCloudWidget.d.mts +704 -0
  48. package/dist/v1/libs/TinyMediaPlayer/docs/SoundCloudWidget.mjs +343 -0
  49. package/dist/v1/libs/TinyMediaPlayer/docs/YouTubePlayer.cjs +546 -0
  50. package/dist/v1/libs/TinyMediaPlayer/docs/YouTubePlayer.d.mts +657 -0
  51. package/dist/v1/libs/TinyMediaPlayer/docs/YouTubePlayer.mjs +480 -0
  52. package/dist/v1/libs/TinyMediaPlayer/index.cjs +216 -0
  53. package/dist/v1/libs/TinyMediaPlayer/index.d.mts +162 -0
  54. package/dist/v1/libs/TinyMediaPlayer/index.mjs +190 -0
  55. package/dist/v1/libs/TinyMediaPlayer.cjs +627 -103
  56. package/dist/v1/libs/TinyMediaPlayer.d.mts +163 -65
  57. package/dist/v1/libs/TinyMediaPlayer.mjs +573 -93
  58. package/dist/v1/libs/TinyTimeout.cjs +4 -14
  59. package/dist/v1/libs/TinyTimeout.d.mts +1 -0
  60. package/dist/v1/libs/TinyTimeout.mjs +4 -13
  61. package/docs/v1/basics/mediaContent.md +1 -1
  62. package/docs/v1/basics/objChecker.md +13 -0
  63. package/docs/v1/basics/promiseUtils.md +32 -0
  64. package/docs/v1/libs/TinyMediaPlayer.md +268 -39
  65. package/docs/v1/libs/TinyTimeout.md +1 -14
  66. package/package.json +71 -10
@@ -0,0 +1,480 @@
1
+ /**
2
+ * https://developers.google.com/youtube/iframe_api_reference
3
+ * @fileoverview JSDoc type definitions for the YouTube IFrame Player API.
4
+ * This file provides full IntelliSense/autocomplete for the global `window.YT` object.
5
+ * @module youtube-api-docs
6
+ */
7
+ /**
8
+ * Represents the current state of the player.
9
+ * @typedef {-1|0|1|2|3|5} YTPlayerState
10
+ * @property {-1} UNSTARTED - The video has not been started.
11
+ * @property {0} ENDED - The video has ended.
12
+ * @property {1} PLAYING - The video is playing.
13
+ * @property {2} PAUSED - The video is paused.
14
+ * @property {3} BUFFERING - The video is buffering.
15
+ * @property {5} CUED - The video is cued and ready to play.
16
+ */
17
+ /**
18
+ * Represents the player error codes.
19
+ * @typedef {2|5|100|101|150} YTPlayerErrors
20
+ * @property {2} INVALIDPARAM - The request contains an invalid parameter value (e.g., invalid video ID).
21
+ * @property {5} INVALIDPLAYER - The content cannot be played in an HTML5 player or an HTML5 error occurred.
22
+ * @property {100} NOTFOUND - The requested video was not found (removed or private).
23
+ * @property {101} NOTALLOWED - The owner does not allow playback in embedded players.
24
+ * @property {150} NOTALLOWED_REDUNDANT - Same as 101.
25
+ */
26
+ /**
27
+ * The playback quality string.
28
+ * @typedef {'small'|'medium'|'large'|'hd720'|'hd1080'|'highres'} YTQuality
29
+ */
30
+ /**
31
+ * Properties for 360° video playback, defining the viewing angle.
32
+ * @typedef {Object} YTSphericalProperties
33
+ * @property {number} yaw - Horizontal angle of view [0, 360].
34
+ * @property {number} pitch - Vertical angle of view [-90, 90].
35
+ * @property {number} roll - Rotational angle [-180, 180].
36
+ * @property {number} fov - Field of view [30, 120].
37
+ */
38
+ /**
39
+ * Base structure for all YouTube Player Events.
40
+ * @typedef {Object} YouTubePlayerEventBase
41
+ * @property {YouTubePlayer} target - The player object that emitted the event.
42
+ */
43
+ /**
44
+ * Called when the player is ready to accept commands.
45
+ * @typedef {(event: YouTubePlayerEventBase) => void} OnReadyEvent
46
+ */
47
+ /**
48
+ * Called when the video playback state changes (e.g., playing, paused).
49
+ * @typedef {(event: YouTubePlayerEventBase & { data: YTPlayerState }) => void} OnStateChangeEvent
50
+ */
51
+ /**
52
+ * Called when an error occurs during video processing or playback.
53
+ * @typedef {(event: YouTubePlayerEventBase & { data: YTPlayerErrors }) => void} OnErrorEvent
54
+ */
55
+ /**
56
+ * Called specifically when the playback quality setting is updated.
57
+ * @typedef {(event: YouTubePlayerEventBase & { data: YTQuality }) => void} OnPlaybackQualityChangeEvent
58
+ */
59
+ /**
60
+ * Called when the video's speed (playback rate) changes or is set.
61
+ * @typedef {(event: YouTubePlayerEventBase & { data: number }) => void} OnPlaybackRateChangeEvent
62
+ */
63
+ /**
64
+ * Called when a change occurs within the API module itself.
65
+ * @typedef {(event: YouTubePlayerEventBase & { data: any }) => void} OnApiChangeEvent
66
+ */
67
+ /**
68
+ * Called when automatic playback is specifically blocked by the browser or platform rules.
69
+ * @typedef {(event: YouTubePlayerEventBase) => void} OnAutoplayBlockedEvent
70
+ */
71
+ /**
72
+ * Container object for configuring event listeners on the player instance.
73
+ * @typedef {Object} YTPlayerOptionsEvents
74
+ * @property {OnReadyEvent} [onReady] - Called when the player is ready.
75
+ * @property {OnStateChangeEvent} [onStateChange] - Called when the state changes.
76
+ * @property {OnErrorEvent} [onError] - Called when an error occurs.
77
+ * @property {OnPlaybackQualityChangeEvent} [onPlaybackQualityChange] - Called when quality changes.
78
+ * @property {OnPlaybackRateChangeEvent} [onPlaybackRateChange] - Called when playback rate changes.
79
+ * @property {OnApiChangeEvent} [onApiChange] - Called when the API module changes.
80
+ * @property {OnAutoplayBlockedEvent} [onAutoplayBlocked] - Called when autoplay is blocked.
81
+ */
82
+ /**
83
+ * Configuration options for initializing the YouTube Player instance.
84
+ * @typedef {Object} YTPlayerOptions
85
+ * @property {number|string} [width=640] - Desired width of the player frame in pixels.
86
+ * @property {number|string} [height=390] - Desired height of the player frame in pixels.
87
+ * @property {string} [videoId] - The unique identifier for the YouTube video to load.
88
+ * @property {Object<string, any>} [playerVars] - Additional configuration parameters passed to the player.
89
+ * @property {YTPlayerOptionsEvents} [events] - An object containing event listeners to handle specific player events.
90
+ */
91
+ /**
92
+ * List of valid names for all YouTube Player Event listeners.
93
+ * @typedef {'onReady'|'onStateChange'|'onError'|'onPlaybackQualityChange'|'onPlaybackRateChange'|'onApiChange'|'onAutoplayBlocked'} EventNames
94
+ */
95
+ /**
96
+ * Options specifically used when queuing or loading a playlist.
97
+ * @typedef {Object} YTPlaylistOptions
98
+ * @property {'playlist'|'user_uploads'} [listType='playlist'] - Specifies whether to use a standard playlist or user uploads feed.
99
+ * @property {string|string[]} list - The ID of the target playlist or an array containing multiple video IDs.
100
+ * @property {number} [index=0] - The zero-based index of the first video that should be played from the list.
101
+ * @property {number} [startSeconds] - The specific time in seconds where the playback of the first video should begin.
102
+ */
103
+ /**
104
+ * Options used to cue or load a video based on its full media URL.
105
+ * @typedef {Object} VideoByUrlOptions
106
+ * @property {string} mediaContentUrl - The complete URL pointing to the desired YouTube video resource.
107
+ * @property {number} [startSeconds] - Optional time in seconds to begin playback from within the video.
108
+ * @property {number} [endSeconds] - Optional time in seconds when playback should stop within the video.
109
+ */
110
+ /**
111
+ * Options used to cue or load a video based on its unique ID.
112
+ * @typedef {Object} VideoByIdOptions
113
+ * @property {string} videoId - The unique identifier of the target YouTube video.
114
+ * @property {number} [startSeconds] - Optional time in seconds to begin playback from within the video.
115
+ * @property {number} [endSeconds] - Optional time in seconds when playback should stop within the video.
116
+ */
117
+ /**
118
+ * Detailed data object representing the current status and metadata of a loaded YouTube video.
119
+ * @typedef {Object} VideoData
120
+ * @property {boolean|null} allowLiveDvr - Whether DVR capabilities are permitted for live content.
121
+ * @property {string|null} author - The name or ID of the video creator.
122
+ * @property {boolean|null} backgroundable - Indicates if the video can be played in the background while minimized.
123
+ * @property {string|null} cpn - Content Protection Network identifier.
124
+ * @property {number|null} errorCode - A specific error code if playback failed.
125
+ * @property {string|null} eventId - An ID related to a specific content event.
126
+ * @property {boolean|null} hasProgressBarBoundaries - Flag indicating if the progress bar has defined start/end boundaries.
127
+ * @property {boolean|null} isListed - Indicates if the video belongs to a list or series.
128
+ * @property {boolean|null} isLive - True if the content is currently streaming live.
129
+ * @property {boolean|null} isManifestless - Flag indicating if manifest files are not being used for streaming.
130
+ * @property {boolean|null} isMultiChannelAudio - Indicates support for multiple audio channels.
131
+ * @property {boolean|null} isPlayable - Overall flag indicating the video can be played by the player.
132
+ * @property {boolean|null} isPremiere - True if the content is a scheduled premiere.
133
+ * @property {boolean|null} isSeekable - Whether random access seeking within the video is allowed.
134
+ * @property {boolean|null} isWindowedLive - Indicates if it is a windowed live event.
135
+ * @property {string|null} itct - Indicator of Interactivity Content Tracking tag.
136
+ * @property {number|null} paidContentOverlayDurationMs - Duration in milliseconds for paid content overlays.
137
+ * @property {string|null} playerResponseCpn - Content Protection Network response identifier from the player itself.
138
+ * @property {number|null} progressBarEndPositionUtcTimeMillis - UTC time in milliseconds for the end of the video's progress bar.
139
+ * @property {number|null} progressBarStartPositionUtcTimeMillis - UTC time in milliseconds for the start of the video's progress bar.
140
+ * @property {string|null} title - The descriptive title of the video.
141
+ * @property {string|null} video_id - The unique ID string of the video content.
142
+ */
143
+ /**
144
+ * The main YouTube Player class instance. Manages all player interactions and state.
145
+ */
146
+ class YouTubePlayer {
147
+ /**
148
+ * Constructor for the YouTube Player. Initializes the player element.
149
+ * @param {string|HTMLElement} element - The DOM element or its ID where the player iframe will be inserted.
150
+ * @param {YTPlayerOptions} [options] - Optional configuration settings for the player initialization.
151
+ */
152
+ constructor(element, options) { }
153
+ /**
154
+ * Stores and retrieves the title of the currently loaded video.
155
+ * @type {string|null|undefined}
156
+ */
157
+ videoTitle = '';
158
+ /**
159
+ * Retrieves a comprehensive snapshot of the current video metadata and status (e.g., ID, author, playability).
160
+ * @returns {Partial<VideoData>} A partial object containing various details about the loaded content.
161
+ */
162
+ getVideoData() {
163
+ return {
164
+ allowLiveDvr: false,
165
+ author: '',
166
+ backgroundable: true,
167
+ cpn: '',
168
+ errorCode: null,
169
+ eventId: '',
170
+ hasProgressBarBoundaries: false,
171
+ isListed: true,
172
+ isLive: false,
173
+ isManifestless: false,
174
+ isMultiChannelAudio: false,
175
+ isPlayable: true,
176
+ isPremiere: false,
177
+ isSeekable: null,
178
+ isWindowedLive: false,
179
+ itct: '',
180
+ paidContentOverlayDurationMs: 0,
181
+ playerResponseCpn: '',
182
+ progressBarEndPositionUtcTimeMillis: null,
183
+ progressBarStartPositionUtcTimeMillis: null,
184
+ title: '',
185
+ video_id: '',
186
+ };
187
+ }
188
+ /**
189
+ * Plays the loaded/selected video.
190
+ *
191
+ * The final player state after this function executes will be playing (1).
192
+ * @returns {void}
193
+ */
194
+ playVideo() { }
195
+ /**
196
+ * Pauses the playing video.
197
+ *
198
+ * The final player state after this function executes will be paused (2)
199
+ * unless the player is in the ended (0) state when the function is called,
200
+ * in which case the player state will not change.
201
+ * @returns {void}
202
+ */
203
+ pauseVideo() { }
204
+ /**
205
+ * Stops and cancels the current video playback.
206
+ *
207
+ * Important: Unlike the pauseVideo function, which leaves the player in the
208
+ * paused (2) state, the stopVideo function could put the player into any
209
+ * not-playing state, including ended (0), paused (2), video cued (5) or
210
+ * unstarted (-1).
211
+ * @returns {void}
212
+ */
213
+ stopVideo() { }
214
+ /**
215
+ * Seeks to a specific time in the video.
216
+ * @param {number} seconds - The time to seek to.
217
+ * @param {boolean} [allowSeekAhead] - Whether to make a new request to the server if the time is outside the buffer.
218
+ * @returns {void}
219
+ */
220
+ seekTo(seconds, allowSeekAhead) { }
221
+ /**
222
+ * Retrieves the current spherical properties for 360° video playback.
223
+ * @returns {YTSphericalProperties}
224
+ */
225
+ getSphericalProperties() {
226
+ return { yaw: 0, pitch: 0, roll: 0, fov: 0 };
227
+ }
228
+ /**
229
+ * Sets the orientation for 360° video playback.
230
+ * @param {YTSphericalProperties & { enableOrientationSensor?: boolean }} properties - The new orientation properties.
231
+ * @returns {void}
232
+ */
233
+ setSphericalProperties(properties) { }
234
+ /**
235
+ * Loads and plays the next video in the playlist.
236
+ * @returns {void}
237
+ */
238
+ nextVideo() { }
239
+ /**
240
+ * Loads and plays the previous video in the playlist.
241
+ * @returns {void}
242
+ */
243
+ previousVideo() { }
244
+ /**
245
+ * Loads and plays the video at the specified index in the playlist.
246
+ * @param {number} index - The zero-based index of the video.
247
+ * @returns {void}
248
+ */
249
+ playVideoAt(index) { }
250
+ /**
251
+ * Mutes the player.
252
+ * @returns {void}
253
+ */
254
+ mute() { }
255
+ /**
256
+ * Unmutes the player.
257
+ * @returns {void}
258
+ */
259
+ unMute() { }
260
+ /**
261
+ * Checks if the player is muted.
262
+ * @returns {boolean}
263
+ */
264
+ isMuted() {
265
+ return false;
266
+ }
267
+ /**
268
+ * Sets the player volume.
269
+ * @param {number} volume - Volume level between 0 and 100.
270
+ * @returns {void}
271
+ */
272
+ setVolume(volume) { }
273
+ /**
274
+ * Gets the current player volume between 0 and 100.
275
+ * @returns {number}
276
+ */
277
+ getVolume() {
278
+ return 0;
279
+ }
280
+ /**
281
+ * Sets the size of the <iframe>.
282
+ * @param {number|string} width - Width in pixels.
283
+ * @param {number|string} height - Height in pixels.
284
+ * @returns {this}
285
+ */
286
+ setSize(width, height) {
287
+ return this;
288
+ }
289
+ /**
290
+ * Gets the current playback rate.
291
+ * @returns {number}
292
+ */
293
+ getPlaybackRate() {
294
+ return 1;
295
+ }
296
+ /**
297
+ * Sets the suggested playback rate.
298
+ * @param {number} suggestedRate - The playback rate (e.g., 0.5, 1, 1.5, 2).
299
+ * @returns {void}
300
+ */
301
+ setPlaybackRate(suggestedRate) { }
302
+ /**
303
+ * Gets the available playback rates for the current video.
304
+ * @returns {number[]}
305
+ */
306
+ getAvailablePlaybackRates() {
307
+ return [1];
308
+ }
309
+ /**
310
+ * Sets whether the playlist should loop.
311
+ * @param {boolean} loopPlaylists - If true, the playlist repeats after the last video.
312
+ * @returns {void}
313
+ */
314
+ setLoop(loopPlaylists) { }
315
+ /**
316
+ * Sets whether the playlist should be shuffled.
317
+ * @param {boolean} shufflePlaylist - If true, the playlist order is randomized.
318
+ * @returns {void}
319
+ */
320
+ setShuffle(shufflePlaylist) { }
321
+ /**
322
+ * Returns a number between 0 and 1 that specifies the percentage of the video
323
+ * that the player shows as buffered.
324
+ * @returns {number}
325
+ */
326
+ getVideoLoadedFraction() {
327
+ return 0;
328
+ }
329
+ /**
330
+ * Returns the current player state.
331
+ * @returns {YTPlayerState}
332
+ */
333
+ getPlayerState() {
334
+ return 0;
335
+ }
336
+ /**
337
+ * Returns the current time in seconds.
338
+ * @returns {number}
339
+ */
340
+ getCurrentTime() {
341
+ return 0;
342
+ }
343
+ /**
344
+ * Returns the URL of the current video.
345
+ * @returns {string}
346
+ */
347
+ getVideoUrl() {
348
+ return '';
349
+ }
350
+ /**
351
+ * Returns the embed code of the current video.
352
+ * @returns {string}
353
+ */
354
+ getVideoEmbedCode() {
355
+ return '';
356
+ }
357
+ /**
358
+ * Returns the duration of the video in seconds.
359
+ * @returns {number}
360
+ */
361
+ getDuration() {
362
+ return 0;
363
+ }
364
+ /**
365
+ * Returns the array of video IDs in the current playlist.
366
+ * @returns {string[]}
367
+ */
368
+ getPlaylist() {
369
+ return [];
370
+ }
371
+ /**
372
+ * Returns the index of the current video in the playlist.
373
+ * @returns {number}
374
+ */
375
+ getPlaylistIndex() {
376
+ return 0;
377
+ }
378
+ /**
379
+ * Queues a video by its ID.
380
+ * @param {string|VideoByIdOptions} videoId - The ID of the video.
381
+ * @param {number} [startSeconds] - The time to start at.
382
+ * @param {YTQuality} [quality] - The video quality
383
+ * @returns {void}
384
+ */
385
+ cueVideoById(videoId, startSeconds, quality) { }
386
+ /**
387
+ * Loads a video by its ID.
388
+ * @param {string|VideoByIdOptions} videoId - The ID of the video.
389
+ * @param {number} [startSeconds] - The time to start at.
390
+ * @param {YTQuality} [quality] - The video quality
391
+ * @returns {void}
392
+ */
393
+ loadVideoById(videoId, startSeconds, quality) { }
394
+ /**
395
+ * Queues a video by its URL.
396
+ * @param {string|VideoByUrlOptions} mediaContentUrl - The full URL of the YouTube video.
397
+ * @param {number} [startSeconds] - The time to start at.
398
+ * @param {YTQuality} [quality] - The video quality
399
+ * @returns {void}
400
+ */
401
+ cueVideoByUrl(mediaContentUrl, startSeconds, quality) { }
402
+ /**
403
+ * Loads a video by its URL.
404
+ * @param {string|VideoByUrlOptions} mediaContentUrl - The full URL of the YouTube video.
405
+ * @param {number} [startSeconds] - The time to start at.
406
+ * @param {YTQuality} [quality] - The video quality.
407
+ * @returns {void}
408
+ */
409
+ loadVideoByUrl(mediaContentUrl, startSeconds, quality) { }
410
+ /**
411
+ * Queues a playlist.
412
+ * @param {string|string[]|YTPlaylistOptions} playlist - The playlist ID, array of IDs, or options object.
413
+ * @param {number} [index=0] - The index of the first video.
414
+ * @param {number} [startSeconds] - The time to start at.
415
+ * @returns {void}
416
+ */
417
+ cuePlaylist(playlist, index, startSeconds) { }
418
+ /**
419
+ * Loads a playlist.
420
+ * @param {string|string[]|YTPlaylistOptions} playlist - The playlist ID, array of IDs, or options object.
421
+ * @param {number} [index=0] - The index of the first video.
422
+ * @param {number} [startSeconds] - The time to start at.
423
+ * @returns {void}
424
+ */
425
+ loadPlaylist(playlist, index, startSeconds) { }
426
+ /**
427
+ * Adds an event listener.
428
+ * @param {EventNames} event - The event name.
429
+ * @param {string} listener - The listener is a string that specifies the function
430
+ * that will execute when the specified event fires.
431
+ * @returns {void}
432
+ */
433
+ addEventListener(event, listener) { }
434
+ /**
435
+ * Removes an event listener.
436
+ * @param {EventNames} event - The event name.
437
+ * @param {string} listener - The listener is a string that identifies the function
438
+ * that will no longer execute when the specified event fires.
439
+ * @returns {void}
440
+ */
441
+ removeEventListener(event, listener) { }
442
+ /**
443
+ * Returns the DOM node of the <iframe>.
444
+ * @returns {HTMLElement}
445
+ */
446
+ getIframe() {
447
+ return document.createElement('iframe');
448
+ }
449
+ /**
450
+ * Returns the options available for the current module.
451
+ * @param {string} [module] - The name of the module.
452
+ * @returns {Object<string, any>}
453
+ */
454
+ getOptions(module) {
455
+ return {};
456
+ }
457
+ /**
458
+ * Retrieves an option for a specific module.
459
+ * @param {any} module - The name of the module.
460
+ * @param {any} option - The name of the option.
461
+ * @returns {any}
462
+ */
463
+ getOption(module, option) {
464
+ return undefined;
465
+ }
466
+ /**
467
+ * Sets an option for a specific module.
468
+ * @param {any} module - The name of the module.
469
+ * @param {any} option - The name of the option.
470
+ * @param {any} value - The value to set.
471
+ * @returns {void}
472
+ */
473
+ setOption(module, option, value) { }
474
+ /**
475
+ * Destroys the player and removes the <iframe>.
476
+ * @returns {void}
477
+ */
478
+ destroy() { }
479
+ }
480
+ export default YouTubePlayer;
@@ -0,0 +1,216 @@
1
+ 'use strict';
2
+
3
+ var events = require('events');
4
+ var utils = require('../utils.cjs');
5
+
6
+ /**
7
+ * @typedef {import('../../basics/mediaContent.mjs').PictureDataType} PictureDataType
8
+ * @typedef {import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>} MediaContent
9
+ */
10
+
11
+ /**
12
+ * @typedef {Object} ContentTimeData
13
+ * @property {number} total - The total duration of the media in milliseconds.
14
+ * @property {number} current - The current playback position in milliseconds.
15
+ * @property {number} remaining - The remaining time until the media ends in milliseconds.
16
+ * @property {number} playbackPercentage - The percentage of the media that has been played (0 to 100).
17
+ */
18
+
19
+ /**
20
+ * Represents the data structure for a piece of content.
21
+ * @typedef {Object} ContentData
22
+ * @property {string} id - The unique identifier for the content.
23
+ * @property {string} createdAt - The timestamp indicating when the content was created.
24
+ * @property {string} title - The title of the content.
25
+ * @property {number} duration - The duration of the content.
26
+ * @property {string} artistId - The unique identifier for the artist.
27
+ * @property {string} [artistName] - The name of the artist (optional).
28
+ * @property {string} [description] - A brief description of the content (optional).
29
+ * @property {string} [avatar] - The URL for the artist's avatar image (optional).
30
+ * @property {string} [url] - The URL to access the content (optional).
31
+ */
32
+
33
+ const checkDestroy = utils.createCheckDestroyed('BaseMediaAdapter');
34
+
35
+ /**
36
+ * Interface definition for a Media Provider Adapter.
37
+ * All specific API wrappers must extend and implement this class.
38
+ * @abstract
39
+ */
40
+ class BaseMediaAdapter extends events.EventEmitter {
41
+ constructor() {
42
+ if (new.target === BaseMediaAdapter) {
43
+ throw new Error('BaseMediaAdapter is an abstract class and cannot be instantiated directly.');
44
+ }
45
+ super();
46
+ }
47
+
48
+ /** @type {boolean} */
49
+ #destroyed = false;
50
+
51
+ get destroyed() {
52
+ return this.#destroyed;
53
+ }
54
+
55
+ /**
56
+ * Determines if this adapter can play the provided content.
57
+ * @param {MediaContent} content - The media content to evaluate.
58
+ * @returns {boolean} True if the adapter can handle the content, false otherwise.
59
+ */
60
+ static canHandle(content) {
61
+ throw new Error('Method "canHandle" must be implemented by the subclass.');
62
+ }
63
+
64
+ /**
65
+ * Synchronously checks whether the media adapter is fully initialized and ready.
66
+ * @returns {boolean} True if the adapter is ready, false otherwise.
67
+ */
68
+ isReady() {
69
+ checkDestroy(this.#destroyed);
70
+ throw new Error('Method "isReady" must be implemented by the subclass.');
71
+ }
72
+
73
+ /**
74
+ * Asynchronously waits until the content media adapter is fully initialized and ready.
75
+ * @returns {Promise<void>} A promise that resolves once the adapter is ready.
76
+ */
77
+ async waitIsReady() {
78
+ checkDestroy(this.#destroyed);
79
+ throw new Error('Method "waitIsReady" must be implemented by the subclass.');
80
+ }
81
+
82
+ /**
83
+ * Determines if this adapter can play the provided content.
84
+ * @param {MediaContent} content - The media content to evaluate.
85
+ * @returns {boolean} True if the adapter can handle the content, false otherwise.
86
+ */
87
+ canHandle(content) {
88
+ checkDestroy(this.#destroyed);
89
+ return BaseMediaAdapter.canHandle(content);
90
+ }
91
+
92
+ /**
93
+ * Starts or resumes playback of the provided content.
94
+ * @param {MediaContent} content - The media content to play.
95
+ * @returns {Promise<void>}
96
+ */
97
+ async play(content) {
98
+ checkDestroy(this.#destroyed);
99
+ throw new Error('Method "play" must be implemented by the subclass.');
100
+ }
101
+
102
+ /**
103
+ * Pauses the current playback.
104
+ * @returns {Promise<void>}
105
+ */
106
+ async pause() {
107
+ checkDestroy(this.#destroyed);
108
+ throw new Error('Method "pause" must be implemented by the subclass.');
109
+ }
110
+
111
+ /**
112
+ * Stops the playback completely and resets the internal platform state.
113
+ * @returns {Promise<void>}
114
+ */
115
+ async stop() {
116
+ checkDestroy(this.#destroyed);
117
+ throw new Error('Method "stop" must be implemented by the subclass.');
118
+ }
119
+
120
+ /**
121
+ * Seeks to a specific time in the media timeline.
122
+ * @param {number} timeMs - The target time in milliseconds.
123
+ * @returns {Promise<void>}
124
+ */
125
+ async seek(timeMs) {
126
+ checkDestroy(this.#destroyed);
127
+ throw new Error('Method "seek" must be implemented by the subclass.');
128
+ }
129
+
130
+ /**
131
+ * Retrieves the current playback time from the underlying API.
132
+ * @returns {number} The current time in milliseconds.
133
+ */
134
+ getCurrentTime() {
135
+ checkDestroy(this.#destroyed);
136
+ throw new Error('Method "getCurrentTime" must be implemented by the subclass.');
137
+ }
138
+
139
+ /**
140
+ * Gets the total duration of the content.
141
+ * @returns {number} The total duration in milliseconds.
142
+ */
143
+ getTotalDuration() {
144
+ checkDestroy(this.#destroyed);
145
+ throw new Error('Method "getTotalDuration" must be implemented by the subclass.');
146
+ }
147
+
148
+ /**
149
+ * Gets the remaining time until the content ends.
150
+ * @returns {number} The remaining time in milliseconds.
151
+ */
152
+ getRemainingTime() {
153
+ checkDestroy(this.#destroyed);
154
+ throw new Error('Method "getRemainingTime" must be implemented by the subclass.');
155
+ }
156
+
157
+ /**
158
+ * Gets the percentage of the content that has been played.
159
+ * @returns {number} The percentage from 0 to 100.
160
+ */
161
+ getPlaybackPercentage() {
162
+ checkDestroy(this.#destroyed);
163
+ throw new Error('Method "getPlaybackPercentage" must be implemented by the subclass.');
164
+ }
165
+
166
+ /**
167
+ * Retrieves a consolidated object containing all time-related metrics for the current media content.
168
+ * @returns {ContentTimeData} An object containing total, current, remaining time, and playback percentage.
169
+ */
170
+ getTimeData() {
171
+ checkDestroy(this.#destroyed);
172
+ throw new Error('Method "getTimeData" must be implemented by the subclass.');
173
+ }
174
+
175
+ /**
176
+ * Sets the playback volume for the underlying API.
177
+ * @param {number} volume - The volume level from 0.0 to 1.0.
178
+ * @returns {void}
179
+ */
180
+ setVolume(volume) {
181
+ checkDestroy(this.#destroyed);
182
+ throw new Error('Method "setVolume" must be implemented by the subclass.');
183
+ }
184
+
185
+ /**
186
+ * Gets the playback volume for the underlying API.
187
+ * @returns {number} - The volume level from 0.0 to 1.0.
188
+ */
189
+ getVolume() {
190
+ checkDestroy(this.#destroyed);
191
+ throw new Error('Method "getVolume" must be implemented by the subclass.');
192
+ }
193
+
194
+ /**
195
+ * Retrieves the metadata of the currently loaded content, returning a structured
196
+ * object containing details such as the content ID, title, author, and duration.
197
+ * @returns {Promise<ContentData>}
198
+ */
199
+ async getContentData() {
200
+ checkDestroy(this.#destroyed);
201
+ throw new Error('Method "getContentData" must be implemented by the subclass.');
202
+ }
203
+
204
+ /**
205
+ * Cleans up the instance.
206
+ * @returns {void}
207
+ */
208
+ destroy() {
209
+ if (this.#destroyed) return;
210
+ this.removeAllListeners();
211
+ this.#destroyed = true;
212
+ this.emit('destroyed');
213
+ }
214
+ }
215
+
216
+ exports.BaseMediaAdapter = BaseMediaAdapter;