tiny-essentials 1.28.8 → 1.28.10

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.
@@ -1042,16 +1042,6 @@ class TinyHtml {
1042
1042
  return true;
1043
1043
  }
1044
1044
 
1045
- /**
1046
- * @deprecated Use the getter {@link elements} instead.
1047
- * Returns the current targets held by this instance.
1048
- *
1049
- * @returns {ConstructorElValues[]} - The instance's targets element.
1050
- */
1051
- getAll() {
1052
- return [...this.#el];
1053
- }
1054
-
1055
1045
  ////////////////////////////////////////////////
1056
1046
 
1057
1047
  // TITLE: Element Getter (Private) (Pt1)
@@ -463,13 +463,6 @@ declare class TinyHtml<TinyHtmlT extends TinyHtmlConstructor> {
463
463
  * @returns {boolean} - True if the element exists; otherwise, false.
464
464
  */
465
465
  exists(index: number): boolean;
466
- /**
467
- * @deprecated Use the getter {@link elements} instead.
468
- * Returns the current targets held by this instance.
469
- *
470
- * @returns {ConstructorElValues[]} - The instance's targets element.
471
- */
472
- getAll(): ConstructorElValues[];
473
466
  /**
474
467
  * Returns the current Element held by this instance.
475
468
  *
@@ -909,15 +909,6 @@ class TinyHtml {
909
909
  return false;
910
910
  return true;
911
911
  }
912
- /**
913
- * @deprecated Use the getter {@link elements} instead.
914
- * Returns the current targets held by this instance.
915
- *
916
- * @returns {ConstructorElValues[]} - The instance's targets element.
917
- */
918
- getAll() {
919
- return [...this.#el];
920
- }
921
912
  ////////////////////////////////////////////////
922
913
  // TITLE: Element Getter (Private) (Pt1)
923
914
  /**
@@ -52,6 +52,19 @@ class BaseMediaAdapter extends events.EventEmitter {
52
52
  return this.#destroyed;
53
53
  }
54
54
 
55
+ /**
56
+ * Returns the thumbnail URL for the currently loaded track.
57
+ * @param {string} trackId - The SoundCloud track ID.
58
+ * @returns {string} The thumbnail URL.
59
+ * @throws {TypeError} If the trackId is not a valid string.
60
+ */
61
+ static getThumbnailUrl(trackId) {
62
+ if (typeof trackId !== 'string' || trackId.trim() === '') {
63
+ throw new TypeError('The "trackId" must be a non-empty string.');
64
+ }
65
+ return ``;
66
+ }
67
+
55
68
  /**
56
69
  * Determines if this adapter can play the provided content.
57
70
  * @param {MediaContent} content - The media content to evaluate.
@@ -66,6 +66,13 @@ declare class BaseMediaAdapter extends EventEmitter {
66
66
  #private;
67
67
  constructor();
68
68
  get destroyed(): boolean;
69
+ /**
70
+ * Returns the thumbnail URL for the currently loaded track.
71
+ * @param {string} trackId - The SoundCloud track ID.
72
+ * @returns {string} The thumbnail URL.
73
+ * @throws {TypeError} If the trackId is not a valid string.
74
+ */
75
+ static getThumbnailUrl(trackId: string): string;
69
76
  /**
70
77
  * Determines if this adapter can play the provided content.
71
78
  * @param {MediaContent} content - The media content to evaluate.
@@ -42,6 +42,18 @@ class BaseMediaAdapter extends EventEmitter {
42
42
  get destroyed() {
43
43
  return this.#destroyed;
44
44
  }
45
+ /**
46
+ * Returns the thumbnail URL for the currently loaded track.
47
+ * @param {string} trackId - The SoundCloud track ID.
48
+ * @returns {string} The thumbnail URL.
49
+ * @throws {TypeError} If the trackId is not a valid string.
50
+ */
51
+ static getThumbnailUrl(trackId) {
52
+ if (typeof trackId !== 'string' || trackId.trim() === '') {
53
+ throw new TypeError('The "trackId" must be a non-empty string.');
54
+ }
55
+ return ``;
56
+ }
45
57
  /**
46
58
  * Determines if this adapter can play the provided content.
47
59
  * @param {MediaContent} content - The media content to evaluate.
package/docs/v1/README.md CHANGED
@@ -21,6 +21,7 @@ Here, you can navigate through different sections of the project. Below are the
21
21
  - 📺 **[FullScreen](./basics/fullScreen.md)** — A complete fullscreen API manager with detection, event handling, and cross-browser compatibility.
22
22
  - 🧱 **[Collision](./basics/collision.md)** — Full-featured rectangle collision detection system with directional analysis, depth calculation, and center offset metrics.
23
23
  - 🎵 **[MediaContent](./basics/mediaContent.md)** — A comprehensive media processing module for downloading audio, extracting rich ID3 metadata, and managing image blobs for album art.
24
+ - 📦 **[BrowserDetector](./basics/browserDetector.md)** — A multi-layered JavaScript utility for identifying the user's web browser and rendering engine.
24
25
 
25
26
  ### 2. **`libs/`**
26
27
  - 🗂️ **[TinyPromiseQueue](./libs/TinyPromiseQueue.md)** — A class that allows sequential execution of asynchronous tasks, supporting task delays, cancellation, and queue management.
@@ -64,6 +65,7 @@ Here, you can navigate through different sections of the project. Below are the
64
65
  * 🧠 **[TinyMamdaniInferenceSystem](./libs/TinyMamdaniInferenceSystem.md)** — A implementation of a Mamdani Inference System, allowing you to model logic using trapezoidal membership functions.
65
66
  * 📻 **[TinyRadioFm](./libs/TinyRadioFm.md)** — It is designed to handle complex playback sequences, including music and voice playlists, scheduled timeline mutations, and custom content injections, all while maintaining absolute reproducibility through a mathematical seed.
66
67
  * ⏯️ **[TinyMediaPlayer](./libs/TinyMediaPlayer.md)** — A universal media player architecture utilizing an adapter pattern to orchestrate multiple platform APIs, featuring robust playlist management, playback controls, and weighted random selection.
68
+ * 🛠️ **[TinyDebugger](./libs/TinyDebugger.md)** — A lightweight, event-driven debugging utility designed to wrap standard `console` methods. It provides enhanced features such as custom prefixes, color support, and the ability to emit events whenever a log occurs, making it perfect for complex applications where you might want to redirect logs to an external service or a UI component.
67
69
 
68
70
  ### 2.1. **`libs/TinyClassManager`**
69
71
 
@@ -0,0 +1,135 @@
1
+ # 🌐 Browser Detection Toolkit
2
+
3
+ A multi-layered JavaScript utility for identifying the user's web browser and rendering engine.
4
+
5
+ ## 📋 Table of Contents
6
+ 1. [Data Types](#📋-data-types)
7
+ 2. [Core Functions](#🛠️-core-functions)
8
+ - [isBrowserAgent](#1-isbrowseragent)
9
+ - [getBrowserCssPrefix](#2-getbrowsercssprefix)
10
+ - [getDuckTyping](#3-getducktyping)
11
+ 3. [Advanced Detection](#🎯-advanced-detection)
12
+ - [getBrowserPings](#4-getbrowserpings)
13
+ - [browserIs](#5-browseris)
14
+
15
+ ---
16
+
17
+ ## 📋 Data Types
18
+
19
+ To ensure type safety and clarity, the toolkit utilizes the following definitions:
20
+
21
+ ### `BrowserDetected`
22
+ A union type representing the supported browser names:
23
+ `'chrome' | 'firefox' | 'ie' | 'edge' | 'safari' | 'opera' | 'yandex' | 'other'`
24
+
25
+ ### `DuckTypingResult`
26
+ An object returned by feature detection, containing boolean flags:
27
+ | Property | Description |
28
+ | :--- | :--- |
29
+ | `isOpera` | `true` if Opera is detected |
30
+ | `isFirefox` | `true` if Firefox is detected |
31
+ | `isSafari` | `true` if Safari is detected |
32
+ | `isIE` | `true` if Internet Explorer is detected |
33
+ | `isEdge` | `true` if Microsoft Edge is detected |
34
+ | `isChrome` | `true` if Google Chrome is detected |
35
+ | `isBlink` | `true` if the Blink rendering engine is detected |
36
+
37
+ ---
38
+
39
+ ## 🛠️ Core Functions
40
+
41
+ ### 1. `isBrowserAgent()`
42
+ Parses the `navigator.userAgent` string to provide a quick identification of the browser.
43
+
44
+ * **Returns:** `BrowserDetected`
45
+ * **Best use case:** Quick, lightweight checks where absolute precision is not critical.
46
+
47
+ ```javascript
48
+ import { isBrowserAgent } from 'tiny-essentials/basics/browserDetector';
49
+
50
+ const browser = isBrowserAgent();
51
+ console.log(`You are using: ${browser}`);
52
+ // Output example: "chrome"
53
+ ```
54
+
55
+ ### 2. `getBrowserCssPrefix()`
56
+ Inspects the computed styles of the document to determine the CSS rendering engine.
57
+
58
+ * **Returns:** `'gecko' | 'webkit' | 'trident' | 'other'`
59
+ * **Best use case:** When you need to apply CSS vendor prefixes or handle engine-specific rendering quirks.
60
+
61
+ ```javascript
62
+ import { getBrowserCssPrefix } from 'tiny-essentials/basics/browserDetector';
63
+
64
+ const engine = getBrowserCssPrefix();
65
+ if (engine === 'webkit') {
66
+ console.log("Applying WebKit specific styles... 🎨");
67
+ }
68
+ ```
69
+
70
+ ### 3. `getDuckTyping()`
71
+ Performs deep feature detection by checking for the existence of specific global objects and APIs.
72
+
73
+ * **Returns:** `DuckTypingResult`
74
+ * **Best use case:** When you need to know exactly which features are available in the current environment.
75
+
76
+ ```javascript
77
+ import { getDuckTyping } from './browserDetector.js';
78
+
79
+ const features = getDuckTyping();
80
+
81
+ if (features.isChrome) {
82
+ console.log("Chrome-specific API available! ✅");
83
+ }
84
+
85
+ if (features.isBlink) {
86
+ console.log("Blink engine detected. ⚡");
87
+ }
88
+ ```
89
+
90
+ ---
91
+
92
+ ## 🎯 Advanced Detection
93
+
94
+ These functions aggregate the results from the core functions to provide the highest possible accuracy.
95
+
96
+ ### 4. `getBrowserPings(disable = [])`
97
+ Aggregates detection results from all three methods (User Agent, CSS Prefix, and Duck Typing) to provide a "ping count" for each browser.
98
+
99
+ * **Parameters:**
100
+ * `disable` (Array): An optional array of `BrowserDetected` names to exclude from the results.
101
+ * **Returns:** `Object<BrowserDetected, number>` (An object where keys are browsers and values are the number of times they were detected).
102
+ * **Throws:** `TypeError` if `disable` is not an array or contains invalid browser names.
103
+
104
+ ```javascript
105
+ import { getBrowserPings } from 'tiny-essentials/basics/browserDetector';
106
+
107
+ // Get detection counts for all browsers
108
+ const counts = getBrowserPings();
109
+ console.log(counts);
110
+
111
+ // Get counts while ignoring Internet Explorer
112
+ const filteredCounts = getBrowserPings(['ie']);
113
+ console.log(filteredCounts);
114
+ ```
115
+
116
+ ### 5. `browserIs(disable = [])`
117
+ The most reliable method. It runs all detection strategies and returns the browser that received the highest number of "pings."
118
+
119
+ * **Parameters:**
120
+ * `disable` (Array): An optional array of `BrowserDetected` names to exclude.
121
+ * **Returns:** `BrowserDetected` (The most likely browser name).
122
+ * **Throws:** `TypeError` if `disable` is not an array or contains invalid browser names.
123
+
124
+ ```javascript
125
+ import { browserIs } from 'tiny-essentials/basics/browserDetector';
126
+
127
+ // Get the most accurate browser identification
128
+ const currentBrowser = browserIs();
129
+
130
+ if (currentBrowser === 'firefox') {
131
+ console.log("Welcome, Firefox user! 🦊");
132
+ } else {
133
+ console.log(`Detected: ${currentBrowser}`);
134
+ }
135
+ ```
@@ -0,0 +1,119 @@
1
+ # 🛠️ TinyDebugger Documentation
2
+
3
+ `TinyDebugger` is a lightweight, event-driven debugging utility designed to wrap standard `console` methods. It provides enhanced features such as custom prefixes, color support, and the ability to emit events whenever a log occurs, making it perfect for complex applications where you might want to redirect logs to an external service or a UI component.
4
+
5
+ ## 🚀 Quick Start
6
+
7
+ To use `TinyDebugger`, import it into your project and initialize it with a configuration object.
8
+
9
+ ```javascript
10
+ import TinyDebugger from 'tiny-essentials/libs/TinyDebugger';
11
+
12
+ const debuggerInstance = new TinyDebugger({
13
+ logger: console, // You can use standard console or a custom object
14
+ id: 'APP_CORE',
15
+ debugMode: true,
16
+ canEmitLogs: true,
17
+ useLogColors: true
18
+ });
19
+
20
+ debuggerInstance.log('info', 'Hello, Yasmin! The debugger is ready. 🌟');
21
+ ```
22
+
23
+ ---
24
+
25
+ ## ⚙️ Configuration
26
+
27
+ When creating a new instance via the `constructor`, you can pass a configuration object with the following properties:
28
+
29
+ | Property | Type | Required | Default | Description |
30
+ | :--- | :--- | :--- | :--- | :--- |
31
+ | `logger` | `Object` | **Yes** | N/A | An object implementing the `Console` interface. |
32
+ | `id` | `string` | **Yes** | N/A | A unique identifier for this debugger instance. |
33
+ | `debugMode` | `boolean` | **Yes** | N/A | If `false`, all logging methods will return immediately. |
34
+ | `canEmitLogs` | `boolean` | No | `false` | If `true`, the instance will emit events for every log action. |
35
+ | `useLogColors` | `boolean` | No | `false` | Enables ANSI color codes. *Note: Automatically disabled in Firefox.* |
36
+
37
+ ---
38
+
39
+ ## ✨ Key Features
40
+
41
+ ### 🎨 Custom Colors
42
+ You can inject colors into your log messages using the `_colorName_` syntax.
43
+ * **Syntax:** `_color_`
44
+ * **Example:** `debugger.log('info', 'This is _red_ critical error!');`
45
+
46
+ ### 🏷️ Custom Prefixes
47
+ You can use placeholders to insert specific prefix text into your logs.
48
+ * **Syntax:** `:id:`
49
+ * **Example:** `debugger.log('info', ':info: System initialized.');`
50
+
51
+ ### 📡 Event Emission
52
+ If `canEmitLogs` is set to `true`, `TinyDebugger` acts as an `EventEmitter`, allowing you to listen to specific debugging events. This is incredibly useful for building custom developer consoles in web applications.
53
+
54
+ ---
55
+
56
+ ## 📖 API Reference
57
+
58
+ ### `log(logType, message, ...args)`
59
+ The primary method for logging.
60
+ * **logType:** `'log' | 'info' | 'warn' | 'error' | 'debug' | 'dirxml' | 'group' | 'groupCollapsed' | 'trace'`
61
+ * **message:** `string` (The text to display)
62
+ * **args:** `...any` (Additional data to inspect)
63
+
64
+ ### `logLabel(logType, label)`
65
+ Logs a specific console type associated with a label.
66
+ * **logType:** `'count' | 'countReset' | 'time' | 'timeEnd' | 'profile' | 'profileEnd' | 'timeStamp'`
67
+ * **label:** `string`
68
+
69
+ ### `logTimeLabel(label, ...args)`
70
+ Starts a timer with a specific label.
71
+ * **label:** `string`
72
+
73
+ ### `logAssert(condition, ...args)`
74
+ Logs a message only if the provided condition evaluates to `false`.
75
+ * **condition:** `boolean`
76
+
77
+ ### `logDir(item, options)`
78
+ Displays an element as a JavaScript object (similar to `console.dir`).
79
+ * **item:** `any`
80
+ * **options:** `InspectOptions`
81
+
82
+ ### `logTable(tabularData, properties)`
83
+ Displays data in a clean, readable table.
84
+ * **tabularData:** `any`
85
+ * **properties:** `string[]` (Optional array of column properties)
86
+
87
+ ### `logClear()`
88
+ Clears the console.
89
+ ### `logGroupEnd()`
90
+ Ends the current console group.
91
+
92
+ ---
93
+
94
+ ## 🛠️ Advanced Customization
95
+
96
+ You can dynamically modify the behavior of your debugger instance using these internal methods:
97
+
98
+ | Method | Description |
99
+ | :--- | :--- |
100
+ | `_addLogColor(id, code)` | Adds a new color shortcut (e.g., `_mycolor_`). |
101
+ | `_removeLogColor(id)` | Removes a color shortcut. |
102
+ | `_addLogPrefix(id, text)` | Adds a new prefix shortcut (e.g., `:status:`). |
103
+ | `_removeLogPrefix(id)` | Removes a prefix shortcut. |
104
+
105
+ ### Example: Adding a Custom Color
106
+ ```javascript
107
+ debuggerInstance._addLogColor('gold', '\x1b[33m');
108
+ debuggerInstance.log('info', 'This message is _gold_!');
109
+ ```
110
+
111
+ ---
112
+
113
+ ## ⚠️ Error Handling
114
+
115
+ It will throw `TypeError` if:
116
+ 1. The `logger` provided is not a valid object.
117
+ 2. The `id` is not a string.
118
+ 3. Configuration booleans are provided as other types.
119
+ 4. An invalid `logType` is passed to the logging methods.
@@ -14,6 +14,7 @@ To support different media platforms, `TinyMediaPlayer` relies on **Adapters**.
14
14
  #### Methods
15
15
  | Method | Description | Parameters | Returns |
16
16
  | :--- | :--- | :--- | :--- |
17
+ | `static getThumbnailUrl` | Returns the thumbnail URL for the provided track ID. Throws `TypeError` if `trackId` is invalid. | `trackId: string` | `string` |
17
18
  | `static canHandle` | Determines if the adapter can play the provided content. | `content: MediaContent` | `boolean` |
18
19
  | `canHandle` | Determines if the adapter can play the provided content. | `content: MediaContent` | `boolean` |
19
20
  | `isReady` | Synchronously checks if the adapter is ready. | None | `boolean` |
@@ -231,7 +232,7 @@ When initializing `new TinyMediaPlayer(options)`, you can pass the following `Ti
231
232
  * **`registerAdapter(adapter)`**: Registers a new provider.
232
233
  * `adapter`: An instance of a class extending `BaseMediaAdapter`.
233
234
  * **`removeAdapter(adapter)`**: Removes a specific registered adapter.
234
- * **`destroyAdapter(adapter)`**: Destroys and removes a specific registered adapter.
235
+ * **`destroyAdapter(adapter)`**: Destroys and removes a specific registered media adapter.
235
236
  * **`hasAdapter(adapter)`**: Checks if a specific adapter is registered.
236
237
  * **`clearAdapters()`**: Clears the list of adapters (does not call `destroy` on them).
237
238
  * **`destroyAllAdapters()`**: Destroys and removes all registered media adapters.
@@ -252,30 +253,30 @@ When initializing `new TinyMediaPlayer(options)`, you can pass the following `Ti
252
253
  * **`existsTrack(index)`**: Returns `true` if the track exists at the given index.
253
254
  * **`getTrack(index)`**: Retrieves the track at the specified index.
254
255
  * **`removeTrack(index)`**: **(Async)** Removes a track and adjusts the current index/playback accordingly.
255
- * **`searchTrack(query)`**: Searches the playlist.
256
+ * **`searchTrack(query)`**: Searches the playlist (string or function).
256
257
  * `query`: A `string` (searches title, artist, or album) or a `function` (custom logic).
257
- * **Returns**: `SearchResult[]` (array of objects containing the track and their corresponding indices).
258
+ * `Returns`: `SearchResult[]` (array of objects containing the track and their corresponding indices).
258
259
  * **`clearPlaylist()`**: **(Async)** Stops playback and empties the entire playlist.
259
260
 
260
261
  #### ⏯️ Playback Controls
261
262
  * **`play()`**: **(Async)** Starts playback of the current track.
262
263
  * **`pause()`**: **(Async)** Pauses the current track.
263
- * **`mute()`**: **(Async)** Mutes the playback.
264
- * **`unMute()`**: **(Async)** Unmutes the playback.
265
264
  * **`stop()`**: **(Async)** Stops the current track completely.
266
265
  * **`next()`**: **(Async)** Advances to the next track (respects `loopMode` and `isRandom`).
267
266
  * **`prev()`**: **(Async)** Returns to the previous track (respects `loopMode` and `isRandom`).
268
267
  * **`skipTo(index)`**: **(Async)** Jumps to a specific index in the playlist.
269
268
  * **`seek(timeMs)`**: **(Async)** Jumps to a specific millisecond in the current track.
270
269
  * **`step(stepMs)`**: **(Async)** Moves the timeline forward (+) or backward (-) by `stepMs`.
270
+ * **`mute()`**: **(Async)** Mutes the current playback.
271
+ * **`unMute()`**: **(Async)** Unmutes the current playback.
271
272
 
272
273
  #### ⏳ Time Utilities
273
274
  * **`getCurrentTime()`**: Gets the current playback time in milliseconds.
274
275
  * **`getTotalDuration()`**: Gets the total duration of the current track in milliseconds.
275
276
  * **`getRemainingTime()`**: Gets the remaining time until the current track ends in milliseconds.
276
277
  * **`getPlaybackPercentage()`**: Gets the percentage of the current track that has been played (0-100).
277
- * **`isPaused` (Getter)**: Checks if the adapter is paused.
278
- * **`isEnded` (Getter)**: Checks if the adapter has ended.
278
+ * **`isPaused`**: **(Getter)** Checks if the adapter is paused.
279
+ * **`isEnded`**: **(Getter)** Checks if the adapter has ended.
279
280
  * **`getContentData()`**: **(Async)** Retrieves structured metadata for the current content.
280
281
  * **`waitIsReady()`**: **(Async)** Waits until the active adapter is fully initialized.
281
282
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-essentials",
3
- "version": "1.28.8",
3
+ "version": "1.28.10",
4
4
  "description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
5
5
  "bin": {
6
6
  "tiny-essentials-fork": "./TinyFork.mjs"
@@ -112,6 +112,10 @@
112
112
  "require": "./dist/v1/basics/promiseUtils.cjs",
113
113
  "import": "./dist/v1/basics/promiseUtils.mjs"
114
114
  },
115
+ "./basics/browserDetector": {
116
+ "require": "./dist/v1/basics/browserDetector.cjs",
117
+ "import": "./dist/v1/basics/browserDetector.mjs"
118
+ },
115
119
  "./fileManager": {
116
120
  "require": "./dist/v1/fileManager/index.cjs",
117
121
  "import": "./dist/v1/fileManager/index.mjs"
File without changes