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.
- package/README.md +18 -1
- package/changelog/1/28/5.md +31 -0
- package/changelog/1/28/6.md +11 -0
- package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyIframeEvents.min.js +1 -1
- package/dist/v1/TinyLocalStorage.min.js +1 -1
- package/dist/v1/TinyMediaPlayer.min.js +1 -1
- package/dist/v1/TinyNewWinEvents.min.js +1 -1
- package/dist/v1/TinyRadioFm.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyTimeout.min.js +1 -1
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/basics/index.cjs +4 -0
- package/dist/v1/basics/index.d.mts +3 -2
- package/dist/v1/basics/index.mjs +3 -2
- package/dist/v1/basics/mediaContent.cjs +1 -0
- package/dist/v1/basics/mediaContent.d.mts +4 -0
- package/dist/v1/basics/mediaContent.mjs +1 -0
- package/dist/v1/basics/objChecker.cjs +16 -0
- package/dist/v1/basics/objChecker.d.mts +12 -0
- package/dist/v1/basics/objChecker.mjs +14 -0
- package/dist/v1/basics/objFilter.cjs +0 -2
- package/dist/v1/basics/objFilter.d.mts +0 -2
- package/dist/v1/basics/objFilter.mjs +1 -2
- package/dist/v1/basics/promiseUtils.cjs +101 -0
- package/dist/v1/basics/promiseUtils.d.mts +31 -0
- package/dist/v1/basics/promiseUtils.mjs +89 -0
- package/dist/v1/css/TinyLoadingScreen.min.css +1 -1
- package/dist/v1/index.cjs +4 -0
- package/dist/v1/index.d.mts +3 -2
- package/dist/v1/index.mjs +3 -2
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.cjs +318 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.d.mts +143 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.mjs +283 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.cjs +315 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.d.mts +143 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.mjs +280 -0
- package/dist/v1/libs/TinyMediaPlayer/SoundCloud.cjs +792 -0
- package/dist/v1/libs/TinyMediaPlayer/SoundCloud.d.mts +300 -0
- package/dist/v1/libs/TinyMediaPlayer/SoundCloud.mjs +697 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.cjs +783 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.d.mts +355 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.mjs +694 -0
- package/dist/v1/libs/TinyMediaPlayer/docs/SoundCloudWidget.cjs +381 -0
- package/dist/v1/libs/TinyMediaPlayer/docs/SoundCloudWidget.d.mts +704 -0
- package/dist/v1/libs/TinyMediaPlayer/docs/SoundCloudWidget.mjs +343 -0
- package/dist/v1/libs/TinyMediaPlayer/docs/YouTubePlayer.cjs +546 -0
- package/dist/v1/libs/TinyMediaPlayer/docs/YouTubePlayer.d.mts +657 -0
- package/dist/v1/libs/TinyMediaPlayer/docs/YouTubePlayer.mjs +480 -0
- package/dist/v1/libs/TinyMediaPlayer/index.cjs +216 -0
- package/dist/v1/libs/TinyMediaPlayer/index.d.mts +162 -0
- package/dist/v1/libs/TinyMediaPlayer/index.mjs +190 -0
- package/dist/v1/libs/TinyMediaPlayer.cjs +627 -103
- package/dist/v1/libs/TinyMediaPlayer.d.mts +163 -65
- package/dist/v1/libs/TinyMediaPlayer.mjs +573 -93
- package/dist/v1/libs/TinyTimeout.cjs +4 -14
- package/dist/v1/libs/TinyTimeout.d.mts +1 -0
- package/dist/v1/libs/TinyTimeout.mjs +4 -13
- package/docs/v1/basics/mediaContent.md +1 -1
- package/docs/v1/basics/objChecker.md +13 -0
- package/docs/v1/basics/promiseUtils.md +32 -0
- package/docs/v1/libs/TinyMediaPlayer.md +268 -39
- package/docs/v1/libs/TinyTimeout.md +1 -14
- package/package.json +71 -10
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
+
import { BaseMediaAdapter } from './TinyMediaPlayer/index.mjs';
|
|
2
3
|
export type PictureDataType = import('../basics/mediaContent.mjs').PictureDataType;
|
|
3
4
|
export type MediaContent = import('../basics/mediaContent.mjs').MediaContent<PictureDataType>;
|
|
4
5
|
export type MediaContentBase = import('../basics/mediaContent.mjs').MediaContentBase;
|
|
@@ -7,6 +8,8 @@ export type ParseMediaContentMetadata = import('../basics/mediaContent.mjs').Par
|
|
|
7
8
|
export type LoadingMediaProgress = import('../basics/mediaContent.mjs').LoadingMediaProgress;
|
|
8
9
|
export type MediaLoadingErrorData = import('../basics/mediaContent.mjs').MediaLoadingErrorData;
|
|
9
10
|
export type UnknownArtistGetter = import('../basics/mediaContent.mjs').UnknownArtistGetter;
|
|
11
|
+
export type ContentTimeData = import('./TinyMediaPlayer/index.mjs').ContentTimeData;
|
|
12
|
+
export type ContentData = import('./TinyMediaPlayer/index.mjs').ContentData;
|
|
10
13
|
export type LoopModeType = 'NONE' | 'TRACK' | 'PLAYLIST';
|
|
11
14
|
export type TinyMediaPlayerOptions = {
|
|
12
15
|
/**
|
|
@@ -17,6 +20,28 @@ export type TinyMediaPlayerOptions = {
|
|
|
17
20
|
* - The specific key name used for localStorage cache.
|
|
18
21
|
*/
|
|
19
22
|
volumeStorageKey?: string;
|
|
23
|
+
/**
|
|
24
|
+
* - If true, clicking 'previous' repeats the current track on the first click.
|
|
25
|
+
*/
|
|
26
|
+
repeatCurrentOnPrev?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* - If true, volume fades smoothly during play/pause transitions.
|
|
29
|
+
*/
|
|
30
|
+
smoothPlayPauseVolume?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* - If true, volume fades smoothly to zero when stopping.
|
|
33
|
+
*/
|
|
34
|
+
smoothStopVolume?: boolean;
|
|
35
|
+
};
|
|
36
|
+
export type SearchResult = {
|
|
37
|
+
/**
|
|
38
|
+
* - The matched media content.
|
|
39
|
+
*/
|
|
40
|
+
track: MediaContent;
|
|
41
|
+
/**
|
|
42
|
+
* - The current index of the track in the playlist.
|
|
43
|
+
*/
|
|
44
|
+
index: number;
|
|
20
45
|
};
|
|
21
46
|
/**
|
|
22
47
|
* @typedef {import('../basics/mediaContent.mjs').PictureDataType} PictureDataType
|
|
@@ -27,74 +52,22 @@ export type TinyMediaPlayerOptions = {
|
|
|
27
52
|
* @typedef {import('../basics/mediaContent.mjs').LoadingMediaProgress} LoadingMediaProgress
|
|
28
53
|
* @typedef {import('../basics/mediaContent.mjs').MediaLoadingErrorData} MediaLoadingErrorData
|
|
29
54
|
* @typedef {import('../basics/mediaContent.mjs').UnknownArtistGetter} UnknownArtistGetter
|
|
55
|
+
* @typedef {import('./TinyMediaPlayer/index.mjs').ContentTimeData} ContentTimeData
|
|
56
|
+
* @typedef {import('./TinyMediaPlayer/index.mjs').ContentData} ContentData
|
|
30
57
|
*/
|
|
31
58
|
/**
|
|
32
59
|
* The loop configuration modes.
|
|
33
60
|
* @typedef {'NONE' | 'TRACK' | 'PLAYLIST'} LoopModeType
|
|
34
61
|
*/
|
|
35
62
|
/**
|
|
36
|
-
* Configuration options for initializing the
|
|
63
|
+
* Configuration options for initializing the TinyMediaPlayer.
|
|
37
64
|
* @typedef {Object} TinyMediaPlayerOptions
|
|
38
65
|
* @property {boolean} [persistVolume=false] - Whether to automatically save the volume in localStorage.
|
|
39
|
-
* @property {string} [volumeStorageKey='
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
* All specific API wrappers must extend and implement this class.
|
|
44
|
-
* @abstract
|
|
66
|
+
* @property {string} [volumeStorageKey='tiny_media_player_volume'] - The specific key name used for localStorage cache.
|
|
67
|
+
* @property {boolean} [repeatCurrentOnPrev=false] - If true, clicking 'previous' repeats the current track on the first click.
|
|
68
|
+
* @property {boolean} [smoothPlayPauseVolume=false] - If true, volume fades smoothly during play/pause transitions.
|
|
69
|
+
* @property {boolean} [smoothStopVolume=false] - If true, volume fades smoothly to zero when stopping.
|
|
45
70
|
*/
|
|
46
|
-
declare class BaseMediaAdapter {
|
|
47
|
-
constructor();
|
|
48
|
-
/**
|
|
49
|
-
* Determines if this adapter can play the provided content.
|
|
50
|
-
* @param {MediaContent} content - The media content to evaluate.
|
|
51
|
-
* @returns {boolean} True if the adapter can handle the content, false otherwise.
|
|
52
|
-
*/
|
|
53
|
-
canHandle(content: MediaContent): boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Starts or resumes playback of the provided content.
|
|
56
|
-
* @param {MediaContent} content - The media content to play.
|
|
57
|
-
* @returns {Promise<void>}
|
|
58
|
-
*/
|
|
59
|
-
play(content: MediaContent): Promise<void>;
|
|
60
|
-
/**
|
|
61
|
-
* Pauses the current playback.
|
|
62
|
-
* @returns {Promise<void>}
|
|
63
|
-
*/
|
|
64
|
-
pause(): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Stops the playback completely and resets the internal platform state.
|
|
67
|
-
* @returns {Promise<void>}
|
|
68
|
-
*/
|
|
69
|
-
stop(): Promise<void>;
|
|
70
|
-
/**
|
|
71
|
-
* Seeks to a specific time in the media timeline.
|
|
72
|
-
* @param {number} timeMs - The target time in milliseconds.
|
|
73
|
-
* @returns {Promise<void>}
|
|
74
|
-
*/
|
|
75
|
-
seek(timeMs: number): Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* Retrieves the current playback time from the underlying API.
|
|
78
|
-
* @returns {number} The current time in milliseconds.
|
|
79
|
-
*/
|
|
80
|
-
getCurrentTime(): number;
|
|
81
|
-
/**
|
|
82
|
-
* Sets the playback volume for the underlying API.
|
|
83
|
-
* @param {number} volume - The volume level from 0.0 to 1.0.
|
|
84
|
-
* @returns {void}
|
|
85
|
-
*/
|
|
86
|
-
setVolume(volume: number): void;
|
|
87
|
-
}
|
|
88
|
-
export type SearchResult = {
|
|
89
|
-
/**
|
|
90
|
-
* - The matched media content.
|
|
91
|
-
*/
|
|
92
|
-
track: MediaContent;
|
|
93
|
-
/**
|
|
94
|
-
* - The current index of the track in the playlist.
|
|
95
|
-
*/
|
|
96
|
-
index: number;
|
|
97
|
-
};
|
|
98
71
|
/**
|
|
99
72
|
* Represents a search match containing the media object and its exact playlist index.
|
|
100
73
|
* @typedef {Object} SearchResult
|
|
@@ -143,8 +116,48 @@ declare class TinyMediaPlayer extends EventEmitter {
|
|
|
143
116
|
onError?: (error: MediaLoadingErrorData) => void;
|
|
144
117
|
}): Promise<MediaContent>;
|
|
145
118
|
get destroyed(): boolean;
|
|
119
|
+
/** @returns {number} The duration (ms) of the volume fade speed. */
|
|
120
|
+
get fadeVolumeSpeed(): number;
|
|
121
|
+
/**
|
|
122
|
+
* @param {number} value - The new duration in milliseconds.
|
|
123
|
+
* @throws {TypeError} If the value is not a number.
|
|
124
|
+
* @throws {RangeError} If the value is negative.
|
|
125
|
+
*/
|
|
126
|
+
set fadeVolumeSpeed(value: number);
|
|
127
|
+
/** @returns {number} The duration (ms) before the prev click state resets. */
|
|
128
|
+
get prevClickTimeoutDuration(): number;
|
|
129
|
+
/**
|
|
130
|
+
* @param {number} value - The new duration in milliseconds.
|
|
131
|
+
* @throws {TypeError} If the value is not a number.
|
|
132
|
+
* @throws {RangeError} If the value is negative.
|
|
133
|
+
*/
|
|
134
|
+
set prevClickTimeoutDuration(value: number);
|
|
135
|
+
/** @returns {boolean} True if clicking 'previous' repeats the current track on the first click. */
|
|
136
|
+
get repeatCurrentOnPrev(): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* @param {boolean} value - The repeat mode state.
|
|
139
|
+
* @throws {TypeError} If the value is not a boolean.
|
|
140
|
+
*/
|
|
141
|
+
set repeatCurrentOnPrev(value: boolean);
|
|
142
|
+
/** @returns {boolean} True if volume fades smoothly during play/pause transitions. */
|
|
143
|
+
get smoothPlayPauseVolume(): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* @param {boolean} value - The smooth play/pause volume mode.
|
|
146
|
+
* @throws {TypeError} If the value is not a boolean.
|
|
147
|
+
*/
|
|
148
|
+
set smoothPlayPauseVolume(value: boolean);
|
|
149
|
+
/** @returns {boolean} True if volume fades smoothly to zero when stopping. */
|
|
150
|
+
get smoothStopVolume(): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* @param {boolean} value - The smooth stop volume mode.
|
|
153
|
+
* @throws {TypeError} If the value is not a boolean.
|
|
154
|
+
*/
|
|
155
|
+
set smoothStopVolume(value: boolean);
|
|
146
156
|
/**
|
|
147
157
|
* @param {TinyMediaPlayerOptions} [options={}] - Configuration parameters for the player.
|
|
158
|
+
* @throws {TypeError} If options is not a valid object.
|
|
159
|
+
* @throws {TypeError} If option values do not match their expected types.
|
|
160
|
+
* @throws {RangeError} If numeric options are out of valid ranges.
|
|
148
161
|
*/
|
|
149
162
|
constructor(options?: TinyMediaPlayerOptions);
|
|
150
163
|
/**
|
|
@@ -207,13 +220,67 @@ declare class TinyMediaPlayer extends EventEmitter {
|
|
|
207
220
|
* @throws {TypeError} If the value is not a string or is empty.
|
|
208
221
|
*/
|
|
209
222
|
set volumeStorageKey(value: string);
|
|
223
|
+
get adapters(): BaseMediaAdapter[];
|
|
224
|
+
get adaptersSize(): number;
|
|
225
|
+
static get defaultAdapterEventNames(): string[];
|
|
226
|
+
/** @param {string[]} value */
|
|
227
|
+
static set defaultAdapterEventNames(value: string[]);
|
|
210
228
|
/**
|
|
211
229
|
* Registers a new media API adapter.
|
|
212
|
-
* @param {string} id - Unique identifier for the platform (e.g., 'youtube', 'spotify').
|
|
213
230
|
* @param {BaseMediaAdapter} adapter - An instance extending BaseMediaAdapter.
|
|
214
|
-
* @throws {TypeError} If
|
|
231
|
+
* @throws {TypeError} If the adapter is invalid.
|
|
232
|
+
*/
|
|
233
|
+
registerAdapter(adapter: BaseMediaAdapter): void;
|
|
234
|
+
/**
|
|
235
|
+
* Removes a media API adapter.
|
|
236
|
+
* @param {BaseMediaAdapter} adapter - An instance extending BaseMediaAdapter.
|
|
237
|
+
* @throws {TypeError} If adapter is invalid.
|
|
238
|
+
*/
|
|
239
|
+
removeAdapter(adapter: BaseMediaAdapter): boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Destroys and removes a media API adapter.
|
|
242
|
+
* @param {BaseMediaAdapter} adapter - An instance extending BaseMediaAdapter.
|
|
243
|
+
* @throws {TypeError} If adapter is invalid.
|
|
215
244
|
*/
|
|
216
|
-
|
|
245
|
+
destroyAdapter(adapter: BaseMediaAdapter): boolean;
|
|
246
|
+
/**
|
|
247
|
+
* If exists a media API adapter.
|
|
248
|
+
* @param {BaseMediaAdapter} adapter - An instance extending BaseMediaAdapter.
|
|
249
|
+
* @throws {TypeError} If adapter is invalid.
|
|
250
|
+
*/
|
|
251
|
+
hasAdapter(adapter: BaseMediaAdapter): boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Destroys and removes all registered media adapters.
|
|
254
|
+
*/
|
|
255
|
+
destroyAllAdapters(): void;
|
|
256
|
+
/**
|
|
257
|
+
* Clears all registered media adapters.
|
|
258
|
+
*/
|
|
259
|
+
clearAdapters(): void;
|
|
260
|
+
/**
|
|
261
|
+
* Helper to find the correct API wrapper for the content.
|
|
262
|
+
* @param {MediaContent} content - The content to check.
|
|
263
|
+
* @returns {BaseMediaAdapter | null} The compatible adapter, or null if empty.
|
|
264
|
+
* @throws {TypeError} If the content is invalid.
|
|
265
|
+
*/
|
|
266
|
+
getMediaAdapter(content: MediaContent): BaseMediaAdapter | null;
|
|
267
|
+
/**
|
|
268
|
+
* Adds a new event to be listened to on the adapters.
|
|
269
|
+
* @param {string} eventName - The name of the event to add.
|
|
270
|
+
* @throws {TypeError} If the event name is not a string.
|
|
271
|
+
*/
|
|
272
|
+
addAdapterEvent(eventName: string): void;
|
|
273
|
+
/**
|
|
274
|
+
* Removes an event from the list of listened events.
|
|
275
|
+
* @param {string} eventName - The name of the event to remove.
|
|
276
|
+
* @throws {TypeError} If the event name is not a string.
|
|
277
|
+
*/
|
|
278
|
+
removeAdapterEvent(eventName: string): void;
|
|
279
|
+
/**
|
|
280
|
+
* Resets the event list to the factory default state: ['timeupdate', 'ended'].
|
|
281
|
+
* @throws {TypeError} If the event name is not a string.
|
|
282
|
+
*/
|
|
283
|
+
resetAdapterEvents(): void;
|
|
217
284
|
/**
|
|
218
285
|
* Adds a new item to the end of the playlist.
|
|
219
286
|
* @param {MediaContent} content - The structured media content object.
|
|
@@ -224,7 +291,7 @@ declare class TinyMediaPlayer extends EventEmitter {
|
|
|
224
291
|
/**
|
|
225
292
|
* Checks if a track exists at the specified index.
|
|
226
293
|
* @param {number} index - The target index.
|
|
227
|
-
* @returns {boolean} True if the track exists
|
|
294
|
+
* @returns {boolean} True if the track exists at the specified index.
|
|
228
295
|
* @throws {TypeError} If the index is not a number.
|
|
229
296
|
*/
|
|
230
297
|
existsTrack(index: number): boolean;
|
|
@@ -233,7 +300,7 @@ declare class TinyMediaPlayer extends EventEmitter {
|
|
|
233
300
|
* @param {number} index - The target index.
|
|
234
301
|
* @returns {MediaContent} The media content object.
|
|
235
302
|
* @throws {TypeError} If the index is not a number.
|
|
236
|
-
* @throws {RangeError} If the index is out of bounds.
|
|
303
|
+
* @throws {RangeError} If the index is out of the playlist bounds.
|
|
237
304
|
*/
|
|
238
305
|
getTrack(index: number): MediaContent;
|
|
239
306
|
/**
|
|
@@ -283,9 +350,9 @@ declare class TinyMediaPlayer extends EventEmitter {
|
|
|
283
350
|
/**
|
|
284
351
|
* Jumps to a specific absolute time in the timeline.
|
|
285
352
|
* @param {number} timeMs - The target time in milliseconds.
|
|
353
|
+
* @returns {Promise<void>}
|
|
286
354
|
* @throws {TypeError} If timeMs is not a number.
|
|
287
355
|
* @throws {RangeError} If timeMs is negative.
|
|
288
|
-
* @returns {Promise<void>}
|
|
289
356
|
*/
|
|
290
357
|
seek(timeMs: number): Promise<void>;
|
|
291
358
|
/**
|
|
@@ -295,6 +362,37 @@ declare class TinyMediaPlayer extends EventEmitter {
|
|
|
295
362
|
* @returns {Promise<void>}
|
|
296
363
|
*/
|
|
297
364
|
step(stepMs: number): Promise<void>;
|
|
365
|
+
/**
|
|
366
|
+
* Gets the current playback time.
|
|
367
|
+
* @returns {number} The current time in milliseconds.
|
|
368
|
+
*/
|
|
369
|
+
getCurrentTime(): number;
|
|
370
|
+
/**
|
|
371
|
+
* Gets the total duration of the current track.
|
|
372
|
+
* @returns {number} The total duration in milliseconds.
|
|
373
|
+
*/
|
|
374
|
+
getTotalDuration(): number;
|
|
375
|
+
/**
|
|
376
|
+
* Gets the remaining time until the current track ends.
|
|
377
|
+
* @returns {number} The remaining time in milliseconds.
|
|
378
|
+
*/
|
|
379
|
+
getRemainingTime(): number;
|
|
380
|
+
/**
|
|
381
|
+
* Gets the percentage of the current track that has been played.
|
|
382
|
+
* @returns {number} A value between 0 and 100.
|
|
383
|
+
*/
|
|
384
|
+
getPlaybackPercentage(): number;
|
|
385
|
+
/**
|
|
386
|
+
* Retrieves the metadata of the currently loaded content, returning a structured
|
|
387
|
+
* object containing details such as the content ID, title, author, and duration.
|
|
388
|
+
* @returns {Promise<ContentData>}
|
|
389
|
+
*/
|
|
390
|
+
getContentData(): Promise<ContentData>;
|
|
391
|
+
/**
|
|
392
|
+
* Asynchronously waits until the content media adapter is fully initialized and ready.
|
|
393
|
+
* @returns {Promise<void>} A promise that resolves once the adapter is ready.
|
|
394
|
+
*/
|
|
395
|
+
waitIsReady(): Promise<void>;
|
|
298
396
|
/**
|
|
299
397
|
* Safely destroys the TinyMediaPlayer instance.
|
|
300
398
|
* This method stops active playback, clears the internal playlist,
|