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,162 @@
1
+ import { EventEmitter } from 'events';
2
+ export type PictureDataType = import('../../basics/mediaContent.mjs').PictureDataType;
3
+ export type MediaContent = import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>;
4
+ export type ContentTimeData = {
5
+ /**
6
+ * - The total duration of the media in milliseconds.
7
+ */
8
+ total: number;
9
+ /**
10
+ * - The current playback position in milliseconds.
11
+ */
12
+ current: number;
13
+ /**
14
+ * - The remaining time until the media ends in milliseconds.
15
+ */
16
+ remaining: number;
17
+ /**
18
+ * - The percentage of the media that has been played (0 to 100).
19
+ */
20
+ playbackPercentage: number;
21
+ };
22
+ export type ContentData = {
23
+ /**
24
+ * - The unique identifier for the content.
25
+ */
26
+ id: string;
27
+ /**
28
+ * - The timestamp indicating when the content was created.
29
+ */
30
+ createdAt: string;
31
+ /**
32
+ * - The title of the content.
33
+ */
34
+ title: string;
35
+ /**
36
+ * - The duration of the content.
37
+ */
38
+ duration: number;
39
+ /**
40
+ * - The unique identifier for the artist.
41
+ */
42
+ artistId: string;
43
+ /**
44
+ * - The name of the artist (optional).
45
+ */
46
+ artistName?: string;
47
+ /**
48
+ * - A brief description of the content (optional).
49
+ */
50
+ description?: string;
51
+ /**
52
+ * - The URL for the artist's avatar image (optional).
53
+ */
54
+ avatar?: string;
55
+ /**
56
+ * - The URL to access the content (optional).
57
+ */
58
+ url?: string;
59
+ };
60
+ /**
61
+ * Interface definition for a Media Provider Adapter.
62
+ * All specific API wrappers must extend and implement this class.
63
+ * @abstract
64
+ */
65
+ declare class BaseMediaAdapter extends EventEmitter {
66
+ #private;
67
+ constructor();
68
+ get destroyed(): boolean;
69
+ /**
70
+ * Determines if this adapter can play the provided content.
71
+ * @param {MediaContent} content - The media content to evaluate.
72
+ * @returns {boolean} True if the adapter can handle the content, false otherwise.
73
+ */
74
+ static canHandle(content: MediaContent): boolean;
75
+ /**
76
+ * Synchronously checks whether the media adapter is fully initialized and ready.
77
+ * @returns {boolean} True if the adapter is ready, false otherwise.
78
+ */
79
+ isReady(): boolean;
80
+ /**
81
+ * Asynchronously waits until the content media adapter is fully initialized and ready.
82
+ * @returns {Promise<void>} A promise that resolves once the adapter is ready.
83
+ */
84
+ waitIsReady(): Promise<void>;
85
+ /**
86
+ * Determines if this adapter can play the provided content.
87
+ * @param {MediaContent} content - The media content to evaluate.
88
+ * @returns {boolean} True if the adapter can handle the content, false otherwise.
89
+ */
90
+ canHandle(content: MediaContent): boolean;
91
+ /**
92
+ * Starts or resumes playback of the provided content.
93
+ * @param {MediaContent} content - The media content to play.
94
+ * @returns {Promise<void>}
95
+ */
96
+ play(content: MediaContent): Promise<void>;
97
+ /**
98
+ * Pauses the current playback.
99
+ * @returns {Promise<void>}
100
+ */
101
+ pause(): Promise<void>;
102
+ /**
103
+ * Stops the playback completely and resets the internal platform state.
104
+ * @returns {Promise<void>}
105
+ */
106
+ stop(): Promise<void>;
107
+ /**
108
+ * Seeks to a specific time in the media timeline.
109
+ * @param {number} timeMs - The target time in milliseconds.
110
+ * @returns {Promise<void>}
111
+ */
112
+ seek(timeMs: number): Promise<void>;
113
+ /**
114
+ * Retrieves the current playback time from the underlying API.
115
+ * @returns {number} The current time in milliseconds.
116
+ */
117
+ getCurrentTime(): number;
118
+ /**
119
+ * Gets the total duration of the content.
120
+ * @returns {number} The total duration in milliseconds.
121
+ */
122
+ getTotalDuration(): number;
123
+ /**
124
+ * Gets the remaining time until the content ends.
125
+ * @returns {number} The remaining time in milliseconds.
126
+ */
127
+ getRemainingTime(): number;
128
+ /**
129
+ * Gets the percentage of the content that has been played.
130
+ * @returns {number} The percentage from 0 to 100.
131
+ */
132
+ getPlaybackPercentage(): number;
133
+ /**
134
+ * Retrieves a consolidated object containing all time-related metrics for the current media content.
135
+ * @returns {ContentTimeData} An object containing total, current, remaining time, and playback percentage.
136
+ */
137
+ getTimeData(): ContentTimeData;
138
+ /**
139
+ * Sets the playback volume for the underlying API.
140
+ * @param {number} volume - The volume level from 0.0 to 1.0.
141
+ * @returns {void}
142
+ */
143
+ setVolume(volume: number): void;
144
+ /**
145
+ * Gets the playback volume for the underlying API.
146
+ * @returns {number} - The volume level from 0.0 to 1.0.
147
+ */
148
+ getVolume(): number;
149
+ /**
150
+ * Retrieves the metadata of the currently loaded content, returning a structured
151
+ * object containing details such as the content ID, title, author, and duration.
152
+ * @returns {Promise<ContentData>}
153
+ */
154
+ getContentData(): Promise<ContentData>;
155
+ /**
156
+ * Cleans up the instance.
157
+ * @returns {void}
158
+ */
159
+ destroy(): void;
160
+ }
161
+ export { BaseMediaAdapter };
162
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1,190 @@
1
+ import { EventEmitter } from 'events';
2
+ import { createCheckDestroyed } from '../utils.mjs';
3
+ /**
4
+ * @typedef {import('../../basics/mediaContent.mjs').PictureDataType} PictureDataType
5
+ * @typedef {import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>} MediaContent
6
+ */
7
+ /**
8
+ * @typedef {Object} ContentTimeData
9
+ * @property {number} total - The total duration of the media in milliseconds.
10
+ * @property {number} current - The current playback position in milliseconds.
11
+ * @property {number} remaining - The remaining time until the media ends in milliseconds.
12
+ * @property {number} playbackPercentage - The percentage of the media that has been played (0 to 100).
13
+ */
14
+ /**
15
+ * Represents the data structure for a piece of content.
16
+ * @typedef {Object} ContentData
17
+ * @property {string} id - The unique identifier for the content.
18
+ * @property {string} createdAt - The timestamp indicating when the content was created.
19
+ * @property {string} title - The title of the content.
20
+ * @property {number} duration - The duration of the content.
21
+ * @property {string} artistId - The unique identifier for the artist.
22
+ * @property {string} [artistName] - The name of the artist (optional).
23
+ * @property {string} [description] - A brief description of the content (optional).
24
+ * @property {string} [avatar] - The URL for the artist's avatar image (optional).
25
+ * @property {string} [url] - The URL to access the content (optional).
26
+ */
27
+ const checkDestroy = createCheckDestroyed('BaseMediaAdapter');
28
+ /**
29
+ * Interface definition for a Media Provider Adapter.
30
+ * All specific API wrappers must extend and implement this class.
31
+ * @abstract
32
+ */
33
+ class BaseMediaAdapter extends EventEmitter {
34
+ constructor() {
35
+ if (new.target === BaseMediaAdapter) {
36
+ throw new Error('BaseMediaAdapter is an abstract class and cannot be instantiated directly.');
37
+ }
38
+ super();
39
+ }
40
+ /** @type {boolean} */
41
+ #destroyed = false;
42
+ get destroyed() {
43
+ return this.#destroyed;
44
+ }
45
+ /**
46
+ * Determines if this adapter can play the provided content.
47
+ * @param {MediaContent} content - The media content to evaluate.
48
+ * @returns {boolean} True if the adapter can handle the content, false otherwise.
49
+ */
50
+ static canHandle(content) {
51
+ throw new Error('Method "canHandle" must be implemented by the subclass.');
52
+ }
53
+ /**
54
+ * Synchronously checks whether the media adapter is fully initialized and ready.
55
+ * @returns {boolean} True if the adapter is ready, false otherwise.
56
+ */
57
+ isReady() {
58
+ checkDestroy(this.#destroyed);
59
+ throw new Error('Method "isReady" must be implemented by the subclass.');
60
+ }
61
+ /**
62
+ * Asynchronously waits until the content media adapter is fully initialized and ready.
63
+ * @returns {Promise<void>} A promise that resolves once the adapter is ready.
64
+ */
65
+ async waitIsReady() {
66
+ checkDestroy(this.#destroyed);
67
+ throw new Error('Method "waitIsReady" must be implemented by the subclass.');
68
+ }
69
+ /**
70
+ * Determines if this adapter can play the provided content.
71
+ * @param {MediaContent} content - The media content to evaluate.
72
+ * @returns {boolean} True if the adapter can handle the content, false otherwise.
73
+ */
74
+ canHandle(content) {
75
+ checkDestroy(this.#destroyed);
76
+ return BaseMediaAdapter.canHandle(content);
77
+ }
78
+ /**
79
+ * Starts or resumes playback of the provided content.
80
+ * @param {MediaContent} content - The media content to play.
81
+ * @returns {Promise<void>}
82
+ */
83
+ async play(content) {
84
+ checkDestroy(this.#destroyed);
85
+ throw new Error('Method "play" must be implemented by the subclass.');
86
+ }
87
+ /**
88
+ * Pauses the current playback.
89
+ * @returns {Promise<void>}
90
+ */
91
+ async pause() {
92
+ checkDestroy(this.#destroyed);
93
+ throw new Error('Method "pause" must be implemented by the subclass.');
94
+ }
95
+ /**
96
+ * Stops the playback completely and resets the internal platform state.
97
+ * @returns {Promise<void>}
98
+ */
99
+ async stop() {
100
+ checkDestroy(this.#destroyed);
101
+ throw new Error('Method "stop" must be implemented by the subclass.');
102
+ }
103
+ /**
104
+ * Seeks to a specific time in the media timeline.
105
+ * @param {number} timeMs - The target time in milliseconds.
106
+ * @returns {Promise<void>}
107
+ */
108
+ async seek(timeMs) {
109
+ checkDestroy(this.#destroyed);
110
+ throw new Error('Method "seek" must be implemented by the subclass.');
111
+ }
112
+ /**
113
+ * Retrieves the current playback time from the underlying API.
114
+ * @returns {number} The current time in milliseconds.
115
+ */
116
+ getCurrentTime() {
117
+ checkDestroy(this.#destroyed);
118
+ throw new Error('Method "getCurrentTime" must be implemented by the subclass.');
119
+ }
120
+ /**
121
+ * Gets the total duration of the content.
122
+ * @returns {number} The total duration in milliseconds.
123
+ */
124
+ getTotalDuration() {
125
+ checkDestroy(this.#destroyed);
126
+ throw new Error('Method "getTotalDuration" must be implemented by the subclass.');
127
+ }
128
+ /**
129
+ * Gets the remaining time until the content ends.
130
+ * @returns {number} The remaining time in milliseconds.
131
+ */
132
+ getRemainingTime() {
133
+ checkDestroy(this.#destroyed);
134
+ throw new Error('Method "getRemainingTime" must be implemented by the subclass.');
135
+ }
136
+ /**
137
+ * Gets the percentage of the content that has been played.
138
+ * @returns {number} The percentage from 0 to 100.
139
+ */
140
+ getPlaybackPercentage() {
141
+ checkDestroy(this.#destroyed);
142
+ throw new Error('Method "getPlaybackPercentage" must be implemented by the subclass.');
143
+ }
144
+ /**
145
+ * Retrieves a consolidated object containing all time-related metrics for the current media content.
146
+ * @returns {ContentTimeData} An object containing total, current, remaining time, and playback percentage.
147
+ */
148
+ getTimeData() {
149
+ checkDestroy(this.#destroyed);
150
+ throw new Error('Method "getTimeData" must be implemented by the subclass.');
151
+ }
152
+ /**
153
+ * Sets the playback volume for the underlying API.
154
+ * @param {number} volume - The volume level from 0.0 to 1.0.
155
+ * @returns {void}
156
+ */
157
+ setVolume(volume) {
158
+ checkDestroy(this.#destroyed);
159
+ throw new Error('Method "setVolume" must be implemented by the subclass.');
160
+ }
161
+ /**
162
+ * Gets the playback volume for the underlying API.
163
+ * @returns {number} - The volume level from 0.0 to 1.0.
164
+ */
165
+ getVolume() {
166
+ checkDestroy(this.#destroyed);
167
+ throw new Error('Method "getVolume" must be implemented by the subclass.');
168
+ }
169
+ /**
170
+ * Retrieves the metadata of the currently loaded content, returning a structured
171
+ * object containing details such as the content ID, title, author, and duration.
172
+ * @returns {Promise<ContentData>}
173
+ */
174
+ async getContentData() {
175
+ checkDestroy(this.#destroyed);
176
+ throw new Error('Method "getContentData" must be implemented by the subclass.');
177
+ }
178
+ /**
179
+ * Cleans up the instance.
180
+ * @returns {void}
181
+ */
182
+ destroy() {
183
+ if (this.#destroyed)
184
+ return;
185
+ this.removeAllListeners();
186
+ this.#destroyed = true;
187
+ this.emit('destroyed');
188
+ }
189
+ }
190
+ export { BaseMediaAdapter };