tiny-essentials 1.16.2 → 1.17.0

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 (133) hide show
  1. package/dist/legacy/crypto/decrypt.cjs +1 -0
  2. package/dist/legacy/crypto/decrypt.d.mts +1 -0
  3. package/dist/legacy/crypto/decrypt.mjs +1 -0
  4. package/dist/legacy/crypto/encrypt.cjs +1 -0
  5. package/dist/legacy/crypto/encrypt.d.mts +1 -0
  6. package/dist/legacy/crypto/encrypt.mjs +1 -0
  7. package/dist/legacy/get/decimalColor.cjs +1 -0
  8. package/dist/legacy/get/decimalColor.d.mts +1 -0
  9. package/dist/legacy/get/decimalColor.mjs +1 -0
  10. package/dist/legacy/get/pagination.cjs +1 -0
  11. package/dist/legacy/get/pagination.d.mts +1 -0
  12. package/dist/legacy/get/pagination.mjs +1 -0
  13. package/dist/legacy/get/queryUrlByName.cjs +1 -0
  14. package/dist/legacy/get/queryUrlByName.d.mts +1 -0
  15. package/dist/legacy/get/queryUrlByName.mjs +1 -0
  16. package/dist/legacy/get/queryUrlJSON.cjs +1 -0
  17. package/dist/legacy/get/queryUrlJSON.d.mts +1 -0
  18. package/dist/legacy/get/queryUrlJSON.mjs +1 -0
  19. package/dist/legacy/get/super_string_filter.cjs +1 -0
  20. package/dist/legacy/get/super_string_filter.d.mts +1 -0
  21. package/dist/legacy/get/super_string_filter.mjs +1 -0
  22. package/dist/legacy/get/versionCheck.cjs +1 -0
  23. package/dist/legacy/get/versionCheck.d.mts +1 -0
  24. package/dist/legacy/get/versionCheck.mjs +1 -0
  25. package/dist/legacy/http/HTTP-1.0.cjs +2 -0
  26. package/dist/legacy/http/HTTP-1.0.mjs +2 -0
  27. package/dist/legacy/http/auth.cjs +1 -0
  28. package/dist/legacy/http/auth.d.mts +1 -0
  29. package/dist/legacy/http/auth.mjs +1 -0
  30. package/dist/legacy/http/check_domain.cjs +11 -0
  31. package/dist/legacy/http/check_domain.d.mts +3 -0
  32. package/dist/legacy/http/check_domain.mjs +11 -0
  33. package/dist/legacy/http/csrfTokenAnalyze.cjs +1 -0
  34. package/dist/legacy/http/csrfTokenAnalyze.d.mts +1 -0
  35. package/dist/legacy/http/csrfTokenAnalyze.mjs +1 -0
  36. package/dist/legacy/http/domainValidator.cjs +1 -0
  37. package/dist/legacy/http/domainValidator.d.mts +1 -0
  38. package/dist/legacy/http/domainValidator.mjs +1 -0
  39. package/dist/legacy/http/errorsCallback.cjs +1 -0
  40. package/dist/legacy/http/errorsCallback.d.mts +1 -0
  41. package/dist/legacy/http/errorsCallback.mjs +1 -0
  42. package/dist/legacy/http/fetch/json.cjs +1 -0
  43. package/dist/legacy/http/fetch/json.d.mts +1 -0
  44. package/dist/legacy/http/fetch/json.mjs +1 -0
  45. package/dist/legacy/http/fetch/text.cjs +1 -0
  46. package/dist/legacy/http/fetch/text.d.mts +1 -0
  47. package/dist/legacy/http/fetch/text.mjs +1 -0
  48. package/dist/legacy/http/fileCache.cjs +1 -0
  49. package/dist/legacy/http/fileCache.d.mts +1 -0
  50. package/dist/legacy/http/fileCache.mjs +1 -0
  51. package/dist/legacy/http/getDomainURL.cjs +1 -0
  52. package/dist/legacy/http/getDomainURL.d.mts +1 -0
  53. package/dist/legacy/http/getDomainURL.mjs +1 -0
  54. package/dist/legacy/http/userIP.cjs +1 -0
  55. package/dist/legacy/http/userIP.d.mts +1 -0
  56. package/dist/legacy/http/userIP.mjs +1 -0
  57. package/dist/legacy/libs/capitalize.cjs +1 -0
  58. package/dist/legacy/libs/capitalize.d.mts +1 -0
  59. package/dist/legacy/libs/capitalize.mjs +1 -0
  60. package/dist/legacy/libs/convertBytes.cjs +2 -0
  61. package/dist/legacy/libs/convertBytes.mjs +2 -0
  62. package/dist/legacy/libs/custom_module_loader.cjs +2 -0
  63. package/dist/legacy/libs/custom_module_loader.mjs +2 -0
  64. package/dist/legacy/libs/dice.cjs +2 -0
  65. package/dist/legacy/libs/dice.mjs +2 -0
  66. package/dist/legacy/libs/markdown.cjs +1 -0
  67. package/dist/legacy/libs/markdown.mjs +1 -0
  68. package/dist/legacy/libs/percentage.cjs +1 -0
  69. package/dist/legacy/libs/percentage.mjs +1 -0
  70. package/dist/legacy/libs/regex/getLetter.cjs +2 -0
  71. package/dist/legacy/libs/regex/getLetter.d.mts +2 -0
  72. package/dist/legacy/libs/regex/getLetter.mjs +2 -0
  73. package/dist/legacy/libs/rule3.cjs +1 -0
  74. package/dist/legacy/libs/rule3.mjs +1 -0
  75. package/dist/legacy/momentjs/getAge.cjs +1 -0
  76. package/dist/legacy/momentjs/getAge.d.mts +1 -0
  77. package/dist/legacy/momentjs/getAge.mjs +1 -0
  78. package/dist/legacy/momentjs/timeDuration.cjs +1 -0
  79. package/dist/legacy/momentjs/timeDuration.d.mts +1 -0
  80. package/dist/legacy/momentjs/timeDuration.mjs +1 -0
  81. package/dist/legacy/socket.io/antiFlood/install.cjs +1 -0
  82. package/dist/legacy/socket.io/antiFlood/install.d.mts +1 -0
  83. package/dist/legacy/socket.io/antiFlood/install.mjs +1 -0
  84. package/dist/legacy/socket.io/antiFlood/verify.cjs +1 -0
  85. package/dist/legacy/socket.io/antiFlood/verify.d.mts +1 -0
  86. package/dist/legacy/socket.io/antiFlood/verify.mjs +1 -0
  87. package/dist/legacy/socket.io/cookie-session.cjs +1 -0
  88. package/dist/legacy/socket.io/cookie-session.d.mts +1 -0
  89. package/dist/legacy/socket.io/cookie-session.mjs +1 -0
  90. package/dist/legacy/socket.io/discord.cjs +1 -0
  91. package/dist/legacy/socket.io/discord.d.mts +1 -0
  92. package/dist/legacy/socket.io/discord.mjs +1 -0
  93. package/dist/v1/TinyBasicsEs.js +559 -71
  94. package/dist/v1/TinyBasicsEs.min.js +1 -1
  95. package/dist/v1/TinyDragger.js +486 -47
  96. package/dist/v1/TinyDragger.min.js +1 -1
  97. package/dist/v1/TinyEssentials.js +2496 -72
  98. package/dist/v1/TinyEssentials.min.js +1 -1
  99. package/dist/v1/TinyHtml.js +486 -47
  100. package/dist/v1/TinyHtml.min.js +1 -1
  101. package/dist/v1/TinySmartScroller.js +6230 -0
  102. package/dist/v1/TinySmartScroller.min.js +1 -0
  103. package/dist/v1/TinyUploadClicker.js +1538 -72
  104. package/dist/v1/TinyUploadClicker.min.js +1 -1
  105. package/dist/v1/UltraRandomMsgGen.js +995 -0
  106. package/dist/v1/UltraRandomMsgGen.min.js +1 -0
  107. package/dist/v1/basics/html.cjs +74 -24
  108. package/dist/v1/basics/html.d.mts +38 -15
  109. package/dist/v1/basics/html.mjs +63 -20
  110. package/dist/v1/build/TinySmartScroller.cjs +7 -0
  111. package/dist/v1/build/TinySmartScroller.d.mts +3 -0
  112. package/dist/v1/build/TinySmartScroller.mjs +2 -0
  113. package/dist/v1/build/UltraRandomMsgGen.cjs +7 -0
  114. package/dist/v1/build/UltraRandomMsgGen.d.mts +3 -0
  115. package/dist/v1/build/UltraRandomMsgGen.mjs +2 -0
  116. package/dist/v1/index.cjs +4 -0
  117. package/dist/v1/index.d.mts +3 -1
  118. package/dist/v1/index.mjs +3 -1
  119. package/dist/v1/libs/TinyHtml.cjs +486 -47
  120. package/dist/v1/libs/TinyHtml.d.mts +352 -139
  121. package/dist/v1/libs/TinyHtml.mjs +431 -47
  122. package/dist/v1/libs/TinySmartScroller.cjs +976 -0
  123. package/dist/v1/libs/TinySmartScroller.d.mts +458 -0
  124. package/dist/v1/libs/TinySmartScroller.mjs +856 -0
  125. package/dist/v1/libs/UltraRandomMsgGen.cjs +956 -0
  126. package/dist/v1/libs/UltraRandomMsgGen.d.mts +390 -0
  127. package/dist/v1/libs/UltraRandomMsgGen.mjs +825 -0
  128. package/docs/v1/README.md +2 -0
  129. package/docs/v1/basics/html.md +17 -2
  130. package/docs/v1/libs/TinyHtml.md +197 -8
  131. package/docs/v1/libs/TinySmartScroller.md +523 -0
  132. package/docs/v1/libs/UltraRandomMsgGen.md +289 -0
  133. package/package.json +1 -1
package/docs/v1/README.md CHANGED
@@ -35,6 +35,8 @@ This folder contains the core scripts we have worked on so far. Each file is a m
35
35
  - 🕒 **[TinyDomReadyManager](./libs/TinyDomReadyManager.md)** — A readiness manager for DOM and async conditions, supporting prioritized callbacks, custom filters, and event-based or promise-based bootstrapping.
36
36
  - 📣 **[TinyNotifications](./libs/TinyNotifications.md)** — A browser notification utility with sound support, permission management, truncation logic, default icons, and enforced validation to ensure safe and predictable usage.
37
37
  - 🧱 **[TinyHtml](./libs/TinyHtml.md)** — A minimalist DOM utility class that offers jQuery-like methods in pure JavaScript for querying, styling, traversing, event handling, collision detection, and visibility logic — all in a lightweight and chainable interface.
38
+ - 🌀 **[TinySmartScroller](./libs/TinySmartScroller.md)** — A smart scroll monitor that detects user scroll behavior, visibility changes, element sizes, and automatically handles scroll preservation, bottom detection, debounce, and more.
39
+ - 🍮 **[UltraRandomMsgGen](./libs/UltraRandomMsgGen.md)** — A whimsical random message generator using grammar templates, word sets, emojis, and chaotic modes to craft playful text outputs.
38
40
 
39
41
  ### 3. **`fileManager/`**
40
42
  * 📁 **[Main](./fileManager/main.md)** — A Node.js file/directory utility module with support for JSON, backups, renaming, size analysis, and more.
@@ -140,9 +140,9 @@ const data = { name: 'Yasmin', type: 'dev' };
140
140
  saveJsonFile('yasmin.json', data);
141
141
  ```
142
142
 
143
- ### 🌐 `fetchJson(url, options?): Promise<any>`
143
+ ### 🌐 `fetchTemplate(...)`
144
144
 
145
- Loads and parses a JSON from a remote URL using the Fetch API, with support for custom HTTP methods, retries, timeouts, headers, and even external abort controllers.
145
+ Loads data from a remote URL using Fetch API, with support for custom HTTP methods, retries, timeouts, headers, and even external abort controllers.
146
146
 
147
147
  #### 📥 Parameters
148
148
 
@@ -156,6 +156,21 @@ Loads and parses a JSON from a remote URL using the Fetch API, with support for
156
156
  * `headers` *(object)*: Additional headers to include in the request.
157
157
  * `body` *(object)*: Request body. If the value is a plain object, it will be automatically stringified as JSON.
158
158
 
159
+ #### `fetchJson(url, options?): Promise<any[] | Record<string | number | symbol, unknown>>`
160
+
161
+ Loads and parses a JSON.
162
+
163
+ * `url` *(string)*: The full URL to fetch JSON from (must start with `http://`, `https://`, `/`, `./`, or `../`).
164
+ * `options` *(object)* *(optional)*:
165
+
166
+ #### `fetchBlob(url, options?): Promise<any[] | Record<string | number | symbol, unknown>>`
167
+
168
+ Loads a remote file as a Blob.
169
+
170
+ * `url` *(string)*: The full URL to fetch JSON from (must start with `http://`, `https://`, `/`, `./`, or `../`).
171
+ * `allowedMimeTypes` Optional list of accepted MIME types (e.g., ['image/jpeg']).
172
+ * `options` *(object)* *(optional)*:
173
+
159
174
  ##### `signal` (`AbortSignal` | `null`) — *optional*
160
175
 
161
176
  Custom abort signal. If set:
@@ -1,10 +1,21 @@
1
1
  # 📚 TinyHtml Class
2
2
 
3
- `TinyHtml` is a lightweight utility class that provides DOM element manipulation and querying utilities, inspired by jQuery — but with modern native browser APIs.
3
+ `TinyHtml` is a lightweight utility class that provides DOM element manipulation and querying utilities, inspired by jQuery — but built with modern native browser APIs.
4
4
 
5
- It supports both static and instance-level operations, making it easy to work with elements' dimensions, collisions, and more in a readable, performant way.
5
+ It supports both static and instance-level operations, making it easy to work with elements dimensions, collisions, and more in a readable and performant way.
6
+
7
+ Most instance methods that do not return a specific value are designed to return the `TinyHtml` instance itself, enabling **method chaining**.
8
+ This allows you to write fluent and expressive code like:
9
+
10
+ ```js
11
+ TinyHtml.createElement('div')
12
+ .addClass('box')
13
+ .setAttr('role', 'dialog')
14
+ .appendTo(document.body);
15
+ ```
16
+
17
+ This design keeps your code concise while maintaining clarity and control over the DOM structure.
6
18
 
7
- ---
8
19
 
9
20
  ## 🧩 Type Definitions – Core Building Blocks
10
21
 
@@ -69,8 +80,28 @@ ElementAndWindow | TinyHtml
69
80
 
70
81
  ---
71
82
 
83
+ #### `TinyElementAndWinAndDoc`
84
+
85
+ Accepts both raw DOM elements, `document`, and the `window` object.
86
+
87
+ ```ts
88
+ ElementAndWinAndDoc | TinyHtml
89
+ ```
90
+
91
+ ---
92
+
72
93
  ### 🔀 Union Types
73
94
 
95
+ #### `ElementAndWinAndDoc`
96
+
97
+ Used for scrollable or measurable targets.
98
+
99
+ ```ts
100
+ Element | Window | Document
101
+ ```
102
+
103
+ ---
104
+
74
105
  #### `ElementAndWindow`
75
106
 
76
107
  Used for scrollable or measurable targets.
@@ -97,7 +128,7 @@ Flexible type for querying or filtering elements:
97
128
  Values accepted by the TinyHtml constructor:
98
129
 
99
130
  ```ts
100
- Window | Element | Document
131
+ Window | Element | Document | Text
101
132
  ```
102
133
 
103
134
  ---
@@ -271,13 +302,63 @@ HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | HTMLOptionElement
271
302
 
272
303
  These methods wrap native DOM query methods and return results as `TinyHtml` instances for consistency.
273
304
 
305
+ ### `TinyHtml.createElement(tagName, ops)`
306
+
307
+ Creates a new DOM element with the given tag name and optional creation options.
308
+
309
+ * **Parameters**:
310
+
311
+ * `tagName` *(string)* — The tag name of the element to create (e.g., `'div'`, `'span'`).
312
+ * `ops` *(ElementCreationOptions)* — *(optional)* Options for advanced element creation.
313
+ * **Returns**: `TinyHtml` — A `TinyHtml` instance wrapping the newly created element.
314
+ * **Throws**:
315
+
316
+ * `TypeError` — If `tagName` is not a string.
317
+ * `TypeError` — If `ops` is defined but not an object.
318
+
319
+ ---
320
+
321
+ ### `TinyHtml.createTextNode(value)`
322
+
323
+ Creates a new `TinyHtml` instance that wraps a DOM `TextNode`.
324
+
325
+ This method is useful when you want to insert raw text content into the DOM without it being interpreted as HTML. The returned instance behaves like any other `TinyHtml` element and can be appended or manipulated as needed.
326
+
327
+ * **Parameters**:
328
+
329
+ * `value` *(string)* — The plain text content to be wrapped in a `TextNode`.
330
+
331
+ * **Returns**: `TinyHtml` — A `TinyHtml` instance wrapping the newly created DOM `TextNode`.
332
+
333
+ * **Throws**:
334
+
335
+ * `TypeError` — If the provided `value` is not a string.
336
+
337
+ ---
338
+
339
+ ### `TinyHtml.createElementFromHTML(htmlString)`
340
+
341
+ Creates an `HTMLElement` or `TextNode` from an HTML string.
342
+ Supports both elements and plain text.
343
+
344
+ * **Parameters**:
345
+
346
+ * `htmlString` *(string)* — The HTML string to convert.
347
+
348
+ * **Returns**: `TinyHtml` — A `TinyHtml` instance wrapping the resulting `HTMLElement` or `TextNode`.
349
+
350
+ * **Throws**:
351
+
352
+ * `Error` — If the parsed content does not produce a valid `Element` when expecting an HTML structure.
353
+
354
+ ---
355
+
274
356
  ### `TinyHtml.query(selector)`
275
357
  Finds the first element by CSS selector.
276
358
 
277
359
  - **Parameters**:
278
360
  - `selector` *(string)* — CSS selector
279
- - **Returns**: `TinyHtml`
280
- - **Throws**: If no element is found.
361
+ - **Returns**: `TinyHtml` or `null`
281
362
 
282
363
  ---
283
364
 
@@ -291,7 +372,9 @@ Finds all elements by CSS selector.
291
372
  ### `TinyHtml.getById(selector)`
292
373
  Selects an element by ID.
293
374
 
294
- - **Throws**: If no element is found.
375
+ - **Parameters**:
376
+ - `selector` *(string)* — Id selector
377
+ - **Returns**: `TinyHtml` or `null`
295
378
 
296
379
  ---
297
380
 
@@ -363,6 +446,8 @@ Each method below ensures type and returns raw DOM objects:
363
446
  | `_preEventTargetElem(...)` | `EventTarget` | `EventTarget` |
364
447
  | `_preElemsAndWindow(...)` | `Element\|Window` | `ElementAndWindow[]` |
365
448
  | `_preElemAndWindow(...)` | `Element\|Window` | `ElementAndWindow` |
449
+ | `_preElemsAndWinAndDoc(...)` | `Element\|Window\|Document` | `ElementAndWindow[]` |
450
+ | `_preElemAndWinAndDoc(...)` | `Element\|Window\|Document` | `ElementAndWindow` |
366
451
 
367
452
  ---
368
453
 
@@ -949,10 +1034,12 @@ element.empty();
949
1034
 
950
1035
  ---
951
1036
 
952
- ### 🔍 `.html()` / `TinyHtml.html(el)`
1037
+ ### 🔍 `.html(ops?)` / `TinyHtml.html(el, ops?)`
953
1038
 
954
1039
  Gets the `innerHTML` string of the element.
955
1040
 
1041
+ * `ops?`: GetHTMLOptions from native DOM.
1042
+
956
1043
  ```js
957
1044
  element.html(); // → "<p>Some HTML content</p>"
958
1045
  ```
@@ -1334,6 +1421,108 @@ TinyHtml.isScrolledIntoView(element);
1334
1421
 
1335
1422
  ---
1336
1423
 
1424
+ ### 🫣 `.isInContainer(container)`
1425
+
1426
+ Partially Visible in Container
1427
+
1428
+ ```js
1429
+ element.isInContainer(container);
1430
+ ```
1431
+
1432
+ Checks if **any part** of the element is visible **inside the scrollable container** — meaning:
1433
+
1434
+ * It **overlaps** the visible area of the container.
1435
+ * At least part of it is within the container’s viewport.
1436
+
1437
+ #### ✅ Use when:
1438
+
1439
+ * You want to detect if an element is **partially scrolled into view**.
1440
+ * Useful for triggering **lazy loading**, **animations**, or **UI changes** when something starts to appear.
1441
+
1442
+ #### 🔍 Logic:
1443
+
1444
+ * It compares the element's `getBoundingClientRect()` with the container’s.
1445
+ * Ensures there's **some overlap**, vertically or horizontally.
1446
+
1447
+ #### 🔁 Static version:
1448
+
1449
+ ```js
1450
+ TinyHtml.isInContainer(element, container);
1451
+ ```
1452
+
1453
+ ---
1454
+
1455
+ ### ✅ `.isFullyInContainer(container)`
1456
+
1457
+ Fully Visible in Container
1458
+
1459
+ ```js
1460
+ element.isFullyInContainer(container);
1461
+ ```
1462
+
1463
+ Checks if the element is **completely visible** inside the scrollable container — meaning:
1464
+
1465
+ * **Top and bottom** of the element are within the container.
1466
+ * **Left and right** are also inside the container’s boundaries.
1467
+
1468
+ #### ✅ Use when:
1469
+
1470
+ * You want to detect if an element is **entirely inside** its scrollable container.
1471
+ * Useful for triggering **lazy loading**, **animations**, or **UI changes** when something starts to appear.
1472
+
1473
+ #### 🔍 Logic:
1474
+
1475
+ * It compares the full bounding box of the element to the container's.
1476
+ * All four edges must be within bounds to return `true`.
1477
+
1478
+ #### 🔁 Static version:
1479
+
1480
+ ```js
1481
+ TinyHtml.isFullyInContainer(element, container);
1482
+ ```
1483
+
1484
+ ---
1485
+
1486
+ ### ✅ `.hasScroll()`
1487
+
1488
+ Detect Scrollability in Any Direction
1489
+
1490
+ ```js
1491
+ element.hasScroll();
1492
+ ```
1493
+
1494
+ Checks if the element has **scrollable content** in either vertical or horizontal direction.
1495
+
1496
+ Returns:
1497
+
1498
+ ```js
1499
+ { v: true|false, h: true|false }
1500
+ ```
1501
+
1502
+ Where:
1503
+
1504
+ * `v` = vertical scroll present
1505
+ * `h` = horizontal scroll present
1506
+
1507
+ #### ✅ Use when:
1508
+
1509
+ * You want to detect **whether an element needs scrollbars**.
1510
+ * Useful for adjusting layout, showing scroll indicators, or enabling custom scrolling behaviors.
1511
+
1512
+ #### 🔍 Logic:
1513
+
1514
+ * It compares the element's `scrollHeight` with `clientHeight` for vertical,
1515
+ * And `scrollWidth` with `clientWidth` for horizontal.
1516
+ * If content overflows in either direction, it returns `true` for that axis.
1517
+
1518
+ #### 🔁 Static version:
1519
+
1520
+ ```js
1521
+ TinyHtml.hasScroll(element);
1522
+ ```
1523
+
1524
+ ---
1525
+
1337
1526
  ## 🎨 CSS Property Aliases (`cssPropAliases`)
1338
1527
 
1339
1528
  TinyHtml provides automatic conversion between `camelCase` and `kebab-case` style properties to simplify working with inline styles in HTML elements.