tiny-essentials 1.28.3 → 1.28.5
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/changelog/1/28/4.md +4 -0
- package/changelog/1/28/5.md +31 -0
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyMediaPlayer.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 +21 -30
- package/dist/v1/basics/objFilter.d.mts +0 -2
- package/dist/v1/basics/objFilter.mjs +21 -30
- 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/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 +268 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.d.mts +118 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.mjs +237 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.cjs +265 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.d.mts +118 -0
- package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.mjs +234 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.cjs +671 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.d.mts +259 -0
- package/dist/v1/libs/TinyMediaPlayer/Youtube.mjs +597 -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 +165 -0
- package/dist/v1/libs/TinyMediaPlayer/index.d.mts +102 -0
- package/dist/v1/libs/TinyMediaPlayer/index.mjs +144 -0
- package/dist/v1/libs/TinyMediaPlayer.cjs +589 -103
- package/dist/v1/libs/TinyMediaPlayer.d.mts +150 -65
- package/dist/v1/libs/TinyMediaPlayer.mjs +535 -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 +239 -32
- package/docs/v1/libs/TinyTimeout.md +1 -14
- package/package.json +21 -1
|
@@ -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,7 @@ 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;
|
|
10
12
|
export type LoopModeType = 'NONE' | 'TRACK' | 'PLAYLIST';
|
|
11
13
|
export type TinyMediaPlayerOptions = {
|
|
12
14
|
/**
|
|
@@ -17,6 +19,28 @@ export type TinyMediaPlayerOptions = {
|
|
|
17
19
|
* - The specific key name used for localStorage cache.
|
|
18
20
|
*/
|
|
19
21
|
volumeStorageKey?: string;
|
|
22
|
+
/**
|
|
23
|
+
* - If true, clicking 'previous' repeats the current track on the first click.
|
|
24
|
+
*/
|
|
25
|
+
repeatCurrentOnPrev?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* - If true, volume fades smoothly during play/pause transitions.
|
|
28
|
+
*/
|
|
29
|
+
smoothPlayPauseVolume?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* - If true, volume fades smoothly to zero when stopping.
|
|
32
|
+
*/
|
|
33
|
+
smoothStopVolume?: boolean;
|
|
34
|
+
};
|
|
35
|
+
export type SearchResult = {
|
|
36
|
+
/**
|
|
37
|
+
* - The matched media content.
|
|
38
|
+
*/
|
|
39
|
+
track: MediaContent;
|
|
40
|
+
/**
|
|
41
|
+
* - The current index of the track in the playlist.
|
|
42
|
+
*/
|
|
43
|
+
index: number;
|
|
20
44
|
};
|
|
21
45
|
/**
|
|
22
46
|
* @typedef {import('../basics/mediaContent.mjs').PictureDataType} PictureDataType
|
|
@@ -27,74 +51,21 @@ export type TinyMediaPlayerOptions = {
|
|
|
27
51
|
* @typedef {import('../basics/mediaContent.mjs').LoadingMediaProgress} LoadingMediaProgress
|
|
28
52
|
* @typedef {import('../basics/mediaContent.mjs').MediaLoadingErrorData} MediaLoadingErrorData
|
|
29
53
|
* @typedef {import('../basics/mediaContent.mjs').UnknownArtistGetter} UnknownArtistGetter
|
|
54
|
+
* @typedef {import('./TinyMediaPlayer/index.mjs').ContentTimeData} ContentTimeData
|
|
30
55
|
*/
|
|
31
56
|
/**
|
|
32
57
|
* The loop configuration modes.
|
|
33
58
|
* @typedef {'NONE' | 'TRACK' | 'PLAYLIST'} LoopModeType
|
|
34
59
|
*/
|
|
35
60
|
/**
|
|
36
|
-
* Configuration options for initializing the
|
|
61
|
+
* Configuration options for initializing the TinyMediaPlayer.
|
|
37
62
|
* @typedef {Object} TinyMediaPlayerOptions
|
|
38
63
|
* @property {boolean} [persistVolume=false] - Whether to automatically save the volume in localStorage.
|
|
39
|
-
* @property {string} [volumeStorageKey='
|
|
64
|
+
* @property {string} [volumeStorageKey='tiny_media_player_volume'] - The specific key name used for localStorage cache.
|
|
65
|
+
* @property {boolean} [repeatCurrentOnPrev=false] - If true, clicking 'previous' repeats the current track on the first click.
|
|
66
|
+
* @property {boolean} [smoothPlayPauseVolume=false] - If true, volume fades smoothly during play/pause transitions.
|
|
67
|
+
* @property {boolean} [smoothStopVolume=false] - If true, volume fades smoothly to zero when stopping.
|
|
40
68
|
*/
|
|
41
|
-
/**
|
|
42
|
-
* Interface definition for a Media Provider Adapter.
|
|
43
|
-
* All specific API wrappers must extend and implement this class.
|
|
44
|
-
* @abstract
|
|
45
|
-
*/
|
|
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
69
|
/**
|
|
99
70
|
* Represents a search match containing the media object and its exact playlist index.
|
|
100
71
|
* @typedef {Object} SearchResult
|
|
@@ -143,8 +114,48 @@ declare class TinyMediaPlayer extends EventEmitter {
|
|
|
143
114
|
onError?: (error: MediaLoadingErrorData) => void;
|
|
144
115
|
}): Promise<MediaContent>;
|
|
145
116
|
get destroyed(): boolean;
|
|
117
|
+
/** @returns {number} The duration (ms) of the volume fade speed. */
|
|
118
|
+
get fadeVolumeSpeed(): number;
|
|
119
|
+
/**
|
|
120
|
+
* @param {number} value - The new duration in milliseconds.
|
|
121
|
+
* @throws {TypeError} If the value is not a number.
|
|
122
|
+
* @throws {RangeError} If the value is negative.
|
|
123
|
+
*/
|
|
124
|
+
set fadeVolumeSpeed(value: number);
|
|
125
|
+
/** @returns {number} The duration (ms) before the prev click state resets. */
|
|
126
|
+
get prevClickTimeoutDuration(): number;
|
|
127
|
+
/**
|
|
128
|
+
* @param {number} value - The new duration in milliseconds.
|
|
129
|
+
* @throws {TypeError} If the value is not a number.
|
|
130
|
+
* @throws {RangeError} If the value is negative.
|
|
131
|
+
*/
|
|
132
|
+
set prevClickTimeoutDuration(value: number);
|
|
133
|
+
/** @returns {boolean} True if clicking 'previous' repeats the current track on the first click. */
|
|
134
|
+
get repeatCurrentOnPrev(): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* @param {boolean} value - The repeat mode state.
|
|
137
|
+
* @throws {TypeError} If the value is not a boolean.
|
|
138
|
+
*/
|
|
139
|
+
set repeatCurrentOnPrev(value: boolean);
|
|
140
|
+
/** @returns {boolean} True if volume fades smoothly during play/pause transitions. */
|
|
141
|
+
get smoothPlayPauseVolume(): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* @param {boolean} value - The smooth play/pause volume mode.
|
|
144
|
+
* @throws {TypeError} If the value is not a boolean.
|
|
145
|
+
*/
|
|
146
|
+
set smoothPlayPauseVolume(value: boolean);
|
|
147
|
+
/** @returns {boolean} True if volume fades smoothly to zero when stopping. */
|
|
148
|
+
get smoothStopVolume(): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* @param {boolean} value - The smooth stop volume mode.
|
|
151
|
+
* @throws {TypeError} If the value is not a boolean.
|
|
152
|
+
*/
|
|
153
|
+
set smoothStopVolume(value: boolean);
|
|
146
154
|
/**
|
|
147
155
|
* @param {TinyMediaPlayerOptions} [options={}] - Configuration parameters for the player.
|
|
156
|
+
* @throws {TypeError} If options is not a valid object.
|
|
157
|
+
* @throws {TypeError} If option values do not match their expected types.
|
|
158
|
+
* @throws {RangeError} If numeric options are out of valid ranges.
|
|
148
159
|
*/
|
|
149
160
|
constructor(options?: TinyMediaPlayerOptions);
|
|
150
161
|
/**
|
|
@@ -207,13 +218,67 @@ declare class TinyMediaPlayer extends EventEmitter {
|
|
|
207
218
|
* @throws {TypeError} If the value is not a string or is empty.
|
|
208
219
|
*/
|
|
209
220
|
set volumeStorageKey(value: string);
|
|
221
|
+
get adapters(): BaseMediaAdapter[];
|
|
222
|
+
get adaptersSize(): number;
|
|
223
|
+
static get defaultAdapterEventNames(): string[];
|
|
224
|
+
/** @param {string[]} value */
|
|
225
|
+
static set defaultAdapterEventNames(value: string[]);
|
|
210
226
|
/**
|
|
211
227
|
* Registers a new media API adapter.
|
|
212
|
-
* @param {string} id - Unique identifier for the platform (e.g., 'youtube', 'spotify').
|
|
213
228
|
* @param {BaseMediaAdapter} adapter - An instance extending BaseMediaAdapter.
|
|
214
|
-
* @throws {TypeError} If
|
|
229
|
+
* @throws {TypeError} If the adapter is invalid.
|
|
230
|
+
*/
|
|
231
|
+
registerAdapter(adapter: BaseMediaAdapter): void;
|
|
232
|
+
/**
|
|
233
|
+
* Removes a media API adapter.
|
|
234
|
+
* @param {BaseMediaAdapter} adapter - An instance extending BaseMediaAdapter.
|
|
235
|
+
* @throws {TypeError} If adapter is invalid.
|
|
236
|
+
*/
|
|
237
|
+
removeAdapter(adapter: BaseMediaAdapter): boolean;
|
|
238
|
+
/**
|
|
239
|
+
* Destroys and removes a media API adapter.
|
|
240
|
+
* @param {BaseMediaAdapter} adapter - An instance extending BaseMediaAdapter.
|
|
241
|
+
* @throws {TypeError} If adapter is invalid.
|
|
242
|
+
*/
|
|
243
|
+
destroyAdapter(adapter: BaseMediaAdapter): boolean;
|
|
244
|
+
/**
|
|
245
|
+
* If exists a media API adapter.
|
|
246
|
+
* @param {BaseMediaAdapter} adapter - An instance extending BaseMediaAdapter.
|
|
247
|
+
* @throws {TypeError} If adapter is invalid.
|
|
215
248
|
*/
|
|
216
|
-
|
|
249
|
+
hasAdapter(adapter: BaseMediaAdapter): boolean;
|
|
250
|
+
/**
|
|
251
|
+
* Destroys and removes all registered media adapters.
|
|
252
|
+
*/
|
|
253
|
+
destroyAllAdapters(): void;
|
|
254
|
+
/**
|
|
255
|
+
* Clears all registered media adapters.
|
|
256
|
+
*/
|
|
257
|
+
clearAdapters(): void;
|
|
258
|
+
/**
|
|
259
|
+
* Helper to find the correct API wrapper for the content.
|
|
260
|
+
* @param {MediaContent} content - The content to check.
|
|
261
|
+
* @returns {BaseMediaAdapter | null} The compatible adapter, or null if empty.
|
|
262
|
+
* @throws {TypeError} If the content is invalid.
|
|
263
|
+
*/
|
|
264
|
+
getMediaAdapter(content: MediaContent): BaseMediaAdapter | null;
|
|
265
|
+
/**
|
|
266
|
+
* Adds a new event to be listened to on the adapters.
|
|
267
|
+
* @param {string} eventName - The name of the event to add.
|
|
268
|
+
* @throws {TypeError} If the event name is not a string.
|
|
269
|
+
*/
|
|
270
|
+
addAdapterEvent(eventName: string): void;
|
|
271
|
+
/**
|
|
272
|
+
* Removes an event from the list of listened events.
|
|
273
|
+
* @param {string} eventName - The name of the event to remove.
|
|
274
|
+
* @throws {TypeError} If the event name is not a string.
|
|
275
|
+
*/
|
|
276
|
+
removeAdapterEvent(eventName: string): void;
|
|
277
|
+
/**
|
|
278
|
+
* Resets the event list to the factory default state: ['timeupdate', 'ended'].
|
|
279
|
+
* @throws {TypeError} If the event name is not a string.
|
|
280
|
+
*/
|
|
281
|
+
resetAdapterEvents(): void;
|
|
217
282
|
/**
|
|
218
283
|
* Adds a new item to the end of the playlist.
|
|
219
284
|
* @param {MediaContent} content - The structured media content object.
|
|
@@ -224,7 +289,7 @@ declare class TinyMediaPlayer extends EventEmitter {
|
|
|
224
289
|
/**
|
|
225
290
|
* Checks if a track exists at the specified index.
|
|
226
291
|
* @param {number} index - The target index.
|
|
227
|
-
* @returns {boolean} True if the track exists
|
|
292
|
+
* @returns {boolean} True if the track exists at the specified index.
|
|
228
293
|
* @throws {TypeError} If the index is not a number.
|
|
229
294
|
*/
|
|
230
295
|
existsTrack(index: number): boolean;
|
|
@@ -233,7 +298,7 @@ declare class TinyMediaPlayer extends EventEmitter {
|
|
|
233
298
|
* @param {number} index - The target index.
|
|
234
299
|
* @returns {MediaContent} The media content object.
|
|
235
300
|
* @throws {TypeError} If the index is not a number.
|
|
236
|
-
* @throws {RangeError} If the index is out of bounds.
|
|
301
|
+
* @throws {RangeError} If the index is out of the playlist bounds.
|
|
237
302
|
*/
|
|
238
303
|
getTrack(index: number): MediaContent;
|
|
239
304
|
/**
|
|
@@ -283,9 +348,9 @@ declare class TinyMediaPlayer extends EventEmitter {
|
|
|
283
348
|
/**
|
|
284
349
|
* Jumps to a specific absolute time in the timeline.
|
|
285
350
|
* @param {number} timeMs - The target time in milliseconds.
|
|
351
|
+
* @returns {Promise<void>}
|
|
286
352
|
* @throws {TypeError} If timeMs is not a number.
|
|
287
353
|
* @throws {RangeError} If timeMs is negative.
|
|
288
|
-
* @returns {Promise<void>}
|
|
289
354
|
*/
|
|
290
355
|
seek(timeMs: number): Promise<void>;
|
|
291
356
|
/**
|
|
@@ -295,6 +360,26 @@ declare class TinyMediaPlayer extends EventEmitter {
|
|
|
295
360
|
* @returns {Promise<void>}
|
|
296
361
|
*/
|
|
297
362
|
step(stepMs: number): Promise<void>;
|
|
363
|
+
/**
|
|
364
|
+
* Gets the current playback time.
|
|
365
|
+
* @returns {number} The current time in milliseconds.
|
|
366
|
+
*/
|
|
367
|
+
getCurrentTime(): number;
|
|
368
|
+
/**
|
|
369
|
+
* Gets the total duration of the current track.
|
|
370
|
+
* @returns {number} The total duration in milliseconds.
|
|
371
|
+
*/
|
|
372
|
+
getTotalDuration(): number;
|
|
373
|
+
/**
|
|
374
|
+
* Gets the remaining time until the current track ends.
|
|
375
|
+
* @returns {number} The remaining time in milliseconds.
|
|
376
|
+
*/
|
|
377
|
+
getRemainingTime(): number;
|
|
378
|
+
/**
|
|
379
|
+
* Gets the percentage of the current track that has been played.
|
|
380
|
+
* @returns {number} A value between 0 and 100.
|
|
381
|
+
*/
|
|
382
|
+
getPlaybackPercentage(): number;
|
|
298
383
|
/**
|
|
299
384
|
* Safely destroys the TinyMediaPlayer instance.
|
|
300
385
|
* This method stops active playback, clears the internal playlist,
|