tiny-essentials 1.28.7 → 1.28.9

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 (55) hide show
  1. package/changelog/1/28/9.md +17 -0
  2. package/dist/v1/TinyBasicsEs.min.js +1 -1
  3. package/dist/v1/TinyDebugger.min.js +1 -0
  4. package/dist/v1/TinyEssentials.min.js +1 -1
  5. package/dist/v1/TinyMediaPlayer.min.js +1 -1
  6. package/dist/v1/TinyRadioFm.min.js +1 -1
  7. package/dist/v1/TinyUploadClicker.min.js +1 -1
  8. package/dist/v1/basics/browserDetector.cjs +228 -0
  9. package/dist/v1/basics/browserDetector.d.mts +66 -0
  10. package/dist/v1/basics/browserDetector.mjs +207 -0
  11. package/dist/v1/basics/index.cjs +6 -0
  12. package/dist/v1/basics/index.d.mts +2 -1
  13. package/dist/v1/basics/index.mjs +2 -1
  14. package/dist/v1/build/TinyDebugger.cjs +7 -0
  15. package/dist/v1/build/TinyDebugger.d.mts +3 -0
  16. package/dist/v1/build/TinyDebugger.mjs +2 -0
  17. package/dist/v1/index.cjs +8 -0
  18. package/dist/v1/index.d.mts +3 -1
  19. package/dist/v1/index.mjs +4 -2
  20. package/dist/v1/libs/TinyDebugger.cjs +380 -0
  21. package/dist/v1/libs/TinyDebugger.d.mts +132 -0
  22. package/dist/v1/libs/TinyDebugger.mjs +351 -0
  23. package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.cjs +39 -3
  24. package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.d.mts +10 -0
  25. package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.mjs +35 -3
  26. package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.cjs +39 -3
  27. package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.d.mts +10 -0
  28. package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.mjs +35 -3
  29. package/dist/v1/libs/TinyMediaPlayer/Mock.cjs +333 -0
  30. package/dist/v1/libs/TinyMediaPlayer/Mock.d.mts +154 -0
  31. package/dist/v1/libs/TinyMediaPlayer/Mock.mjs +296 -0
  32. package/dist/v1/libs/TinyMediaPlayer/SoundCloud.cjs +30 -0
  33. package/dist/v1/libs/TinyMediaPlayer/SoundCloud.d.mts +10 -0
  34. package/dist/v1/libs/TinyMediaPlayer/SoundCloud.mjs +26 -0
  35. package/dist/v1/libs/TinyMediaPlayer/Youtube.cjs +39 -3
  36. package/dist/v1/libs/TinyMediaPlayer/Youtube.d.mts +10 -0
  37. package/dist/v1/libs/TinyMediaPlayer/Youtube.mjs +32 -3
  38. package/dist/v1/libs/TinyMediaPlayer/index.cjs +18 -0
  39. package/dist/v1/libs/TinyMediaPlayer/index.d.mts +10 -0
  40. package/dist/v1/libs/TinyMediaPlayer/index.mjs +16 -0
  41. package/dist/v1/libs/TinyMediaPlayer.cjs +156 -31
  42. package/dist/v1/libs/TinyMediaPlayer.d.mts +43 -7
  43. package/dist/v1/libs/TinyMediaPlayer.mjs +148 -31
  44. package/dist/v1/libs/TinyPromiseQueue.cjs +6 -4
  45. package/dist/v1/libs/TinyPromiseQueue.d.mts +8 -6
  46. package/dist/v1/libs/TinyPromiseQueue.mjs +6 -4
  47. package/dist/v1/libs/TinyRadioFm.cjs +271 -138
  48. package/dist/v1/libs/TinyRadioFm.d.mts +67 -3
  49. package/dist/v1/libs/TinyRadioFm.mjs +239 -123
  50. package/docs/v1/README.md +2 -0
  51. package/docs/v1/basics/browserDetector.md +135 -0
  52. package/docs/v1/libs/TinyDebugger.md +119 -0
  53. package/docs/v1/libs/TinyMediaPlayer.md +26 -22
  54. package/docs/v1/libs/TinyRadioFm.md +25 -3
  55. package/package.json +13 -1
@@ -0,0 +1,333 @@
1
+ 'use strict';
2
+
3
+ var utils = require('../utils.cjs');
4
+ var index = require('./index.cjs');
5
+ var objChecker = require('../../basics/objChecker.cjs');
6
+
7
+ /**
8
+ * @typedef {import('../../basics/mediaContent.mjs').PictureDataType} PictureDataType
9
+ * @typedef {import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>} MediaContent
10
+ * @typedef {import('./index.mjs').ContentData} ContentData
11
+ * @typedef {import('./index.mjs').ContentTimeData} ContentTimeData
12
+ */
13
+
14
+ const checkDestroy = utils.createCheckDestroyed('MockMediaAdapter');
15
+ const createdAt = new Date().toISOString();
16
+
17
+ /**
18
+ * MOCK VERSION of BaseMediaAdapter
19
+ *
20
+ * This file simulates the behavior of the Media Adapter for testing purposes.
21
+ */
22
+ class MockMediaAdapter extends index.BaseMediaAdapter {
23
+ get id() {
24
+ return 'mock';
25
+ }
26
+
27
+ #isReady = true;
28
+ #currentVolume = 1.0;
29
+
30
+ /** @type {string|null} */
31
+ #currentContentId = null;
32
+ #destroyed = false;
33
+ #isPlaying = false;
34
+ #isPaused = false;
35
+ #isEnded = false;
36
+ #isMuted = false;
37
+ #currentTime = 0; // in milliseconds
38
+ #totalDuration = 60000; // 60 seconds in milliseconds
39
+
40
+ /**
41
+ * @returns {boolean}
42
+ */
43
+ get destroyed() {
44
+ return this.#destroyed;
45
+ }
46
+
47
+ /**
48
+ * @returns {boolean}
49
+ */
50
+ get isPlaying() {
51
+ checkDestroy(this.#destroyed);
52
+ return this.#isPlaying;
53
+ }
54
+
55
+ /**
56
+ * @returns {string|null}
57
+ */
58
+ get currentContentId() {
59
+ checkDestroy(this.#destroyed);
60
+ return this.#currentContentId;
61
+ }
62
+
63
+ /**
64
+ * @returns {number}
65
+ */
66
+ get volume() {
67
+ checkDestroy(this.#destroyed);
68
+ return this.#currentVolume;
69
+ }
70
+
71
+ /**
72
+ * @param {number} value - O volume de 0.0 a 1.0.
73
+ * @throws {RangeError} Se o valor estiver fora do intervalo.
74
+ */
75
+ set volume(value) {
76
+ checkDestroy(this.#destroyed);
77
+ if (typeof value !== 'number' || value < 0 || value > 1) {
78
+ throw new RangeError('Volume must be a number between 0.0 and 1.0.');
79
+ }
80
+ this.#currentVolume = value;
81
+ this.emit('volumeChange', value);
82
+ }
83
+
84
+ constructor() {
85
+ super();
86
+ }
87
+
88
+ /**
89
+ * Checks whether the media adapter is fully initialized and ready.
90
+ * @returns {boolean} True if the adapter is ready, false otherwise.
91
+ */
92
+ isReady() {
93
+ checkDestroy(this.#destroyed);
94
+ return this.#isReady;
95
+ }
96
+
97
+ /**
98
+ * Checks whether the media adapter is paused.
99
+ * @returns {boolean} True if the adapter is ready, false otherwise.
100
+ */
101
+ isPaused() {
102
+ checkDestroy(this.#destroyed);
103
+ return this.#isPaused;
104
+ }
105
+
106
+ /**
107
+ * Checks whether the media adapter is ended.
108
+ * @returns {boolean} True if the adapter is ready, false otherwise.
109
+ */
110
+ isEnded() {
111
+ checkDestroy(this.#destroyed);
112
+ return this.#isEnded;
113
+ }
114
+
115
+ /**
116
+ * Asynchronously waits until the content media adapter is fully initialized and ready.
117
+ * @returns {Promise<void>} A promise that resolves once the adapter is ready.
118
+ */
119
+ async waitIsReady() {
120
+ checkDestroy(this.#destroyed);
121
+ return Promise.resolve();
122
+ }
123
+
124
+ /**
125
+ * Retrieves a consolidated object containing all time-related metrics for the current media content.
126
+ * @returns {ContentTimeData} An object containing total, current, remaining time, and playback percentage.
127
+ */
128
+ getTimeData() {
129
+ checkDestroy(this.#destroyed);
130
+ const total = this.getTotalDuration();
131
+ const current = this.getCurrentTime();
132
+ const remaining = total > 0 ? total - current : 0;
133
+ const playbackPercentage = total > 0 ? (current / total) * 100 : 0;
134
+ return { total, current, remaining, playbackPercentage };
135
+ }
136
+
137
+ /**
138
+ * Determines if this adapter can play the provided content.
139
+ * @param {MediaContent} content - The media content to evaluate.
140
+ * @returns {boolean} True if the adapter can handle the content, false otherwise.
141
+ */
142
+ static canHandle(content) {
143
+ return content && typeof content.url === 'string';
144
+ }
145
+
146
+ /**
147
+ * Determines if this adapter can play the provided content.
148
+ * @param {MediaContent} content - The media content to evaluate.
149
+ * @returns {boolean} True if the adapter can handle the content, false otherwise.
150
+ */
151
+ canHandle(content) {
152
+ checkDestroy(this.#destroyed);
153
+ return MockMediaAdapter.canHandle(content);
154
+ }
155
+
156
+ /**
157
+ * Starts or resumes playback of the provided content.
158
+ * @param {MediaContent} content - The media content to play.
159
+ * @returns {Promise<void>}
160
+ */
161
+ async play(content) {
162
+ checkDestroy(this.#destroyed);
163
+ if (!objChecker.isValidObj(content)) {
164
+ throw new TypeError('Invalid media content provided to play().');
165
+ }
166
+ this.#currentContentId = typeof content.url === 'string' ? content.url : 'mock';
167
+ this.#isPaused = false;
168
+ this.#isEnded = false;
169
+ this.#isPlaying = true;
170
+
171
+ // Simulate a small delay for loading
172
+ await new Promise((resolve) => setTimeout(resolve, 10));
173
+
174
+ this.emit('play');
175
+ }
176
+
177
+ /**
178
+ * Pauses the current playback.
179
+ * @returns {Promise<void>}
180
+ */
181
+ async pause() {
182
+ checkDestroy(this.#destroyed);
183
+ this.#isPaused = true;
184
+ this.#isEnded = false;
185
+ this.#isPlaying = false;
186
+ this.emit('pause');
187
+ }
188
+
189
+ /**
190
+ * Stops the playback completely and resets the internal platform state.
191
+ * @returns {Promise<void>}
192
+ */
193
+ async stop() {
194
+ checkDestroy(this.#destroyed);
195
+ this.#isPaused = false;
196
+ this.#isEnded = true;
197
+ this.#isPlaying = false;
198
+ this.#currentTime = 0;
199
+ this.emit('ended');
200
+ }
201
+
202
+ /**
203
+ * Seeks to a specific time in the media timeline.
204
+ * @param {number} timeMs - The target time in milliseconds.
205
+ * @returns {Promise<void>}
206
+ */
207
+ async seek(timeMs) {
208
+ checkDestroy(this.#destroyed);
209
+ if (typeof timeMs !== 'number') {
210
+ throw new TypeError('Seek time must be a number.');
211
+ }
212
+ this.#currentTime = timeMs;
213
+ this.emit('seek', this.#currentTime);
214
+ }
215
+
216
+ /**
217
+ * Checks whether the player is currently muted.
218
+ * @returns {boolean|null} True if muted, false otherwise.
219
+ */
220
+ isMuted() {
221
+ checkDestroy(this.#destroyed);
222
+ return this.#isMuted;
223
+ }
224
+
225
+ /**
226
+ * Mutes the current playback.
227
+ * @returns {Promise<void>}
228
+ */
229
+ async mute() {
230
+ checkDestroy(this.#destroyed);
231
+ this.#isMuted = true;
232
+ }
233
+
234
+ /**
235
+ * Unmutes the current playback.
236
+ * @returns {Promise<void>}
237
+ */
238
+ async unMute() {
239
+ checkDestroy(this.#destroyed);
240
+ this.#isMuted = false;
241
+ }
242
+
243
+ /**
244
+ * Retrieves the current playback time from the underlying API.
245
+ * @returns {number} The current time in milliseconds.
246
+ */
247
+ getCurrentTime() {
248
+ checkDestroy(this.#destroyed);
249
+ return this.#currentTime;
250
+ }
251
+
252
+ /**
253
+ * Gets the total duration of the content.
254
+ * @returns {number} The total duration in milliseconds.
255
+ */
256
+ getTotalDuration() {
257
+ checkDestroy(this.#destroyed);
258
+ return this.#totalDuration;
259
+ }
260
+
261
+ /**
262
+ * Gets the remaining time until the content ends.
263
+ * @returns {number} The remaining time in milliseconds.
264
+ */
265
+ getRemainingTime() {
266
+ checkDestroy(this.#destroyed);
267
+ const total = this.getTotalDuration();
268
+ const current = this.getCurrentTime();
269
+ return total > 0 ? total - current : 0;
270
+ }
271
+
272
+ /**
273
+ * Gets the percentage of the content that has been played.
274
+ * @returns {number} The percentage from 0 to 100.
275
+ */
276
+ getPlaybackPercentage() {
277
+ checkDestroy(this.#destroyed);
278
+ const total = this.getTotalDuration();
279
+ const current = this.getCurrentTime();
280
+ return total > 0 ? (current / total) * 100 : 0;
281
+ }
282
+
283
+ /**
284
+ * Sets the playback volume for the underlying API.
285
+ * @param {number} volume - The volume level from 0.0 to 1.0.
286
+ * @returns {void}
287
+ */
288
+ setVolume(volume) {
289
+ checkDestroy(this.#destroyed);
290
+ this.volume = volume;
291
+ }
292
+
293
+ /**
294
+ * Gets the playback volume for the underlying API.
295
+ * @returns {number} - The volume level from 0.0 to 1.0.
296
+ */
297
+ getVolume() {
298
+ checkDestroy(this.#destroyed);
299
+ return this.volume;
300
+ }
301
+
302
+ /**
303
+ * Retrieves the metadata of the currently loaded content, returning a structured
304
+ * object containing details such as the content ID, title, author, and duration.
305
+ * @returns {Promise<ContentData>}
306
+ */
307
+ async getContentData() {
308
+ checkDestroy(this.#destroyed);
309
+ return {
310
+ id: this.#currentContentId ?? 'mock',
311
+ createdAt,
312
+ artistId: 'mock-artist',
313
+ artistName: 'Mock Artist',
314
+ description: 'Mock description',
315
+ title: 'Mock Title',
316
+ duration: this.#totalDuration,
317
+ avatar: '',
318
+ url: '',
319
+ };
320
+ }
321
+
322
+ /**
323
+ * Cleans up the instance.
324
+ * @returns {void}
325
+ */
326
+ destroy() {
327
+ if (this.#destroyed) return;
328
+ this.#destroyed = true;
329
+ super.destroy();
330
+ }
331
+ }
332
+
333
+ exports.MockMediaAdapter = MockMediaAdapter;
@@ -0,0 +1,154 @@
1
+ import { BaseMediaAdapter } from './index.mjs';
2
+ export type PictureDataType = import('../../basics/mediaContent.mjs').PictureDataType;
3
+ export type MediaContent = import('../../basics/mediaContent.mjs').MediaContent<PictureDataType>;
4
+ export type ContentData = import('./index.mjs').ContentData;
5
+ export type ContentTimeData = import('./index.mjs').ContentTimeData;
6
+ /**
7
+ * MOCK VERSION of BaseMediaAdapter
8
+ *
9
+ * This file simulates the behavior of the Media Adapter for testing purposes.
10
+ */
11
+ declare class MockMediaAdapter extends BaseMediaAdapter {
12
+ #private;
13
+ get id(): string;
14
+ /**
15
+ * @returns {boolean}
16
+ */
17
+ get destroyed(): boolean;
18
+ /**
19
+ * @returns {boolean}
20
+ */
21
+ get isPlaying(): boolean;
22
+ /**
23
+ * @returns {string|null}
24
+ */
25
+ get currentContentId(): string | null;
26
+ /**
27
+ * @returns {number}
28
+ */
29
+ get volume(): number;
30
+ /**
31
+ * @param {number} value - O volume de 0.0 a 1.0.
32
+ * @throws {RangeError} Se o valor estiver fora do intervalo.
33
+ */
34
+ set volume(value: number);
35
+ constructor();
36
+ /**
37
+ * Checks whether the media adapter is fully initialized and ready.
38
+ * @returns {boolean} True if the adapter is ready, false otherwise.
39
+ */
40
+ isReady(): boolean;
41
+ /**
42
+ * Checks whether the media adapter is paused.
43
+ * @returns {boolean} True if the adapter is ready, false otherwise.
44
+ */
45
+ isPaused(): boolean;
46
+ /**
47
+ * Checks whether the media adapter is ended.
48
+ * @returns {boolean} True if the adapter is ready, false otherwise.
49
+ */
50
+ isEnded(): boolean;
51
+ /**
52
+ * Asynchronously waits until the content media adapter is fully initialized and ready.
53
+ * @returns {Promise<void>} A promise that resolves once the adapter is ready.
54
+ */
55
+ waitIsReady(): Promise<void>;
56
+ /**
57
+ * Retrieves a consolidated object containing all time-related metrics for the current media content.
58
+ * @returns {ContentTimeData} An object containing total, current, remaining time, and playback percentage.
59
+ */
60
+ getTimeData(): ContentTimeData;
61
+ /**
62
+ * Determines if this adapter can play the provided content.
63
+ * @param {MediaContent} content - The media content to evaluate.
64
+ * @returns {boolean} True if the adapter can handle the content, false otherwise.
65
+ */
66
+ static canHandle(content: MediaContent): boolean;
67
+ /**
68
+ * Determines if this adapter can play the provided content.
69
+ * @param {MediaContent} content - The media content to evaluate.
70
+ * @returns {boolean} True if the adapter can handle the content, false otherwise.
71
+ */
72
+ canHandle(content: MediaContent): boolean;
73
+ /**
74
+ * Starts or resumes playback of the provided content.
75
+ * @param {MediaContent} content - The media content to play.
76
+ * @returns {Promise<void>}
77
+ */
78
+ play(content: MediaContent): Promise<void>;
79
+ /**
80
+ * Pauses the current playback.
81
+ * @returns {Promise<void>}
82
+ */
83
+ pause(): Promise<void>;
84
+ /**
85
+ * Stops the playback completely and resets the internal platform state.
86
+ * @returns {Promise<void>}
87
+ */
88
+ stop(): Promise<void>;
89
+ /**
90
+ * Seeks to a specific time in the media timeline.
91
+ * @param {number} timeMs - The target time in milliseconds.
92
+ * @returns {Promise<void>}
93
+ */
94
+ seek(timeMs: number): Promise<void>;
95
+ /**
96
+ * Checks whether the player is currently muted.
97
+ * @returns {boolean|null} True if muted, false otherwise.
98
+ */
99
+ isMuted(): boolean | null;
100
+ /**
101
+ * Mutes the current playback.
102
+ * @returns {Promise<void>}
103
+ */
104
+ mute(): Promise<void>;
105
+ /**
106
+ * Unmutes the current playback.
107
+ * @returns {Promise<void>}
108
+ */
109
+ unMute(): Promise<void>;
110
+ /**
111
+ * Retrieves the current playback time from the underlying API.
112
+ * @returns {number} The current time in milliseconds.
113
+ */
114
+ getCurrentTime(): number;
115
+ /**
116
+ * Gets the total duration of the content.
117
+ * @returns {number} The total duration in milliseconds.
118
+ */
119
+ getTotalDuration(): number;
120
+ /**
121
+ * Gets the remaining time until the content ends.
122
+ * @returns {number} The remaining time in milliseconds.
123
+ */
124
+ getRemainingTime(): number;
125
+ /**
126
+ * Gets the percentage of the content that has been played.
127
+ * @returns {number} The percentage from 0 to 100.
128
+ */
129
+ getPlaybackPercentage(): number;
130
+ /**
131
+ * Sets the playback volume for the underlying API.
132
+ * @param {number} volume - The volume level from 0.0 to 1.0.
133
+ * @returns {void}
134
+ */
135
+ setVolume(volume: number): void;
136
+ /**
137
+ * Gets the playback volume for the underlying API.
138
+ * @returns {number} - The volume level from 0.0 to 1.0.
139
+ */
140
+ getVolume(): number;
141
+ /**
142
+ * Retrieves the metadata of the currently loaded content, returning a structured
143
+ * object containing details such as the content ID, title, author, and duration.
144
+ * @returns {Promise<ContentData>}
145
+ */
146
+ getContentData(): Promise<ContentData>;
147
+ /**
148
+ * Cleans up the instance.
149
+ * @returns {void}
150
+ */
151
+ destroy(): void;
152
+ }
153
+ export { MockMediaAdapter };
154
+ //# sourceMappingURL=Mock.d.mts.map