tiny-essentials 1.28.0 → 1.28.2

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 (323) hide show
  1. package/changelog/1/28/1.md +23 -0
  2. package/changelog/1/28/2.md +43 -0
  3. package/dist/_/numbers.d.mts +91 -16
  4. package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
  5. package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
  6. package/dist/v1/TinyAnalogClock.min.js +1 -1
  7. package/dist/v1/TinyBasicsEs.min.js +1 -1
  8. package/dist/v1/TinyDayNightCycle.min.js +1 -1
  9. package/dist/v1/TinyDragDropDetector.min.js +1 -1
  10. package/dist/v1/TinyDragger.min.js +1 -1
  11. package/dist/v1/TinyElementObserver.min.js +1 -1
  12. package/dist/v1/TinyEssentials.min.js +1 -1
  13. package/dist/v1/TinyGamepad.min.js +1 -1
  14. package/dist/v1/TinyHtml.min.js +1 -1
  15. package/dist/v1/TinyI18.min.js +1 -1
  16. package/dist/v1/TinyIframeEvents.min.js +1 -1
  17. package/dist/v1/TinyLocalStorage.min.js +1 -1
  18. package/dist/v1/TinyMediaPlayer.min.js +1 -1
  19. package/dist/v1/TinyNewWinEvents.min.js +1 -1
  20. package/dist/v1/TinyNotifyCenter.min.js +1 -1
  21. package/dist/v1/TinyRadioFm.min.js +1 -1
  22. package/dist/v1/TinyRateLimiter.min.js +1 -1
  23. package/dist/v1/TinySmartScroller.min.js +1 -1
  24. package/dist/v1/TinyTextDiffer.min.js +1 -1
  25. package/dist/v1/TinyTextarea.min.js +1 -1
  26. package/dist/v1/TinyTimeout.min.js +1 -1
  27. package/dist/v1/TinyToastNotify.min.js +1 -1
  28. package/dist/v1/TinyUploadClicker.min.js +1 -1
  29. package/dist/v1/UltraRandomMsgGen.min.js +1 -1
  30. package/dist/v1/basics/array.cjs +57 -9
  31. package/dist/v1/basics/array.d.mts +28 -12
  32. package/dist/v1/basics/array.mjs +51 -9
  33. package/dist/v1/basics/clock.cjs +94 -42
  34. package/dist/v1/basics/clock.d.mts +22 -22
  35. package/dist/v1/basics/clock.mjs +91 -54
  36. package/dist/v1/basics/collision.d.mts +245 -104
  37. package/dist/v1/basics/deprecated/html.cjs +246 -0
  38. package/dist/v1/basics/deprecated/html.d.mts +63 -0
  39. package/dist/v1/basics/deprecated/html.mjs +190 -0
  40. package/dist/v1/basics/extendObjType/Buffer.d.mts +1 -1
  41. package/dist/v1/basics/fullScreen.d.mts +47 -7
  42. package/dist/v1/basics/html.cjs +149 -130
  43. package/dist/v1/basics/html.d.mts +69 -113
  44. package/dist/v1/basics/html.mjs +113 -105
  45. package/dist/v1/basics/index.cjs +2 -0
  46. package/dist/v1/basics/index.d.mts +11 -65
  47. package/dist/v1/basics/index.mjs +3 -3
  48. package/dist/v1/basics/mediaContent.cjs +116 -32
  49. package/dist/v1/basics/mediaContent.d.mts +143 -159
  50. package/dist/v1/basics/mediaContent.mjs +105 -33
  51. package/dist/v1/basics/objChecker.cjs +7 -5
  52. package/dist/v1/basics/objChecker.d.mts +5 -4
  53. package/dist/v1/basics/objChecker.mjs +6 -6
  54. package/dist/v1/basics/objFilter.cjs +71 -14
  55. package/dist/v1/basics/objFilter.d.mts +16 -19
  56. package/dist/v1/basics/objFilter.mjs +63 -14
  57. package/dist/v1/basics/simpleMath.cjs +81 -25
  58. package/dist/v1/basics/simpleMath.d.mts +22 -22
  59. package/dist/v1/basics/simpleMath.mjs +70 -27
  60. package/dist/v1/basics/text.cjs +76 -31
  61. package/dist/v1/basics/text.d.mts +64 -14
  62. package/dist/v1/basics/text.mjs +62 -31
  63. package/dist/v1/build/ColorSafeStringify.d.mts +1 -1
  64. package/dist/v1/build/TinyAdvancedRaffle.d.mts +1 -1
  65. package/dist/v1/build/TinyAfterScrollWatcher.d.mts +1 -1
  66. package/dist/v1/build/TinyAnalogClock.d.mts +1 -1
  67. package/dist/v1/build/TinyArrayComparator.d.mts +1 -1
  68. package/dist/v1/build/TinyArrayPaginator.d.mts +1 -1
  69. package/dist/v1/build/TinyClassManager.d.mts +1 -1
  70. package/dist/v1/build/TinyClipboard.d.mts +1 -1
  71. package/dist/v1/build/TinyColorConverter.d.mts +1 -1
  72. package/dist/v1/build/TinyColorValidator.d.mts +1 -1
  73. package/dist/v1/build/TinyCookieConsent.d.mts +1 -1
  74. package/dist/v1/build/TinyDayNightCycle.d.mts +1 -1
  75. package/dist/v1/build/TinyDomReadyManager.d.mts +1 -1
  76. package/dist/v1/build/TinyDragDropDetector.d.mts +1 -1
  77. package/dist/v1/build/TinyDragger.d.mts +1 -1
  78. package/dist/v1/build/TinyElementObserver.d.mts +1 -1
  79. package/dist/v1/build/TinyGamepad.d.mts +1 -1
  80. package/dist/v1/build/TinyHtml.d.mts +1 -1
  81. package/dist/v1/build/TinyI18.d.mts +1 -1
  82. package/dist/v1/build/TinyIframeEvents.d.mts +1 -1
  83. package/dist/v1/build/TinyInventory.d.mts +1 -1
  84. package/dist/v1/build/TinyInventoryTrader.d.mts +1 -1
  85. package/dist/v1/build/TinyLevelUp.d.mts +1 -1
  86. package/dist/v1/build/TinyLoadingScreen.d.mts +1 -1
  87. package/dist/v1/build/TinyLocalStorage.d.mts +1 -1
  88. package/dist/v1/build/TinyMediaPlayer.d.mts +1 -1
  89. package/dist/v1/build/TinyNeedBar.d.mts +1 -1
  90. package/dist/v1/build/TinyNewWinEvents.d.mts +1 -1
  91. package/dist/v1/build/TinyNotifications.d.mts +1 -1
  92. package/dist/v1/build/TinyNotifyCenter.d.mts +1 -1
  93. package/dist/v1/build/TinyPromiseQueue.d.mts +1 -1
  94. package/dist/v1/build/TinyRadioFm.d.mts +1 -1
  95. package/dist/v1/build/TinyRateLimiter.d.mts +1 -1
  96. package/dist/v1/build/TinySimpleDice.d.mts +1 -1
  97. package/dist/v1/build/TinySmartScroller.d.mts +1 -1
  98. package/dist/v1/build/TinyTextDiffer.d.mts +1 -1
  99. package/dist/v1/build/TinyTextRangeEditor.d.mts +1 -1
  100. package/dist/v1/build/TinyTextarea.d.mts +1 -1
  101. package/dist/v1/build/TinyTimeout.d.mts +1 -1
  102. package/dist/v1/build/TinyToastNotify.d.mts +1 -1
  103. package/dist/v1/build/TinyUploadClicker.d.mts +1 -1
  104. package/dist/v1/build/UltraRandomMsgGen.d.mts +1 -1
  105. package/dist/v1/fileManager/asyncFuncs.d.mts +13 -13
  106. package/dist/v1/fileManager/index.d.mts +3 -29
  107. package/dist/v1/fileManager/normalFuncs.d.mts +22 -22
  108. package/dist/v1/index.cjs +4 -0
  109. package/dist/v1/index.d.mts +54 -137
  110. package/dist/v1/index.mjs +4 -3
  111. package/dist/v1/libs/ColorSafeStringify.d.mts +3 -12
  112. package/dist/v1/libs/TinyAdvancedRaffle.cjs +64 -50
  113. package/dist/v1/libs/TinyAdvancedRaffle.d.mts +64 -116
  114. package/dist/v1/libs/TinyAdvancedRaffle.mjs +62 -49
  115. package/dist/v1/libs/TinyAfterScrollWatcher.cjs +17 -1
  116. package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +15 -19
  117. package/dist/v1/libs/TinyAfterScrollWatcher.mjs +15 -1
  118. package/dist/v1/libs/TinyAnalogClock.cjs +60 -0
  119. package/dist/v1/libs/TinyAnalogClock.d.mts +12 -9
  120. package/dist/v1/libs/TinyAnalogClock.mjs +57 -0
  121. package/dist/v1/libs/TinyArrayComparator.d.mts +14 -20
  122. package/dist/v1/libs/TinyArrayPaginator.d.mts +22 -26
  123. package/dist/v1/libs/TinyClassManager/TinyPluginInliner.d.mts +8 -8
  124. package/dist/v1/libs/TinyClassManager.cjs +5 -7
  125. package/dist/v1/libs/TinyClassManager.d.mts +16 -16
  126. package/dist/v1/libs/TinyClassManager.mjs +5 -6
  127. package/dist/v1/libs/TinyClipboard.cjs +2 -0
  128. package/dist/v1/libs/TinyClipboard.d.mts +12 -5
  129. package/dist/v1/libs/TinyClipboard.mjs +2 -0
  130. package/dist/v1/libs/TinyColorConverter.cjs +1 -0
  131. package/dist/v1/libs/TinyColorConverter.d.mts +10 -32
  132. package/dist/v1/libs/TinyColorConverter.mjs +1 -0
  133. package/dist/v1/libs/TinyColorValidator.d.mts +145 -184
  134. package/dist/v1/libs/TinyCookieConsent.d.mts +17 -17
  135. package/dist/v1/libs/TinyDayNightCycle.cjs +67 -42
  136. package/dist/v1/libs/TinyDayNightCycle.d.mts +87 -117
  137. package/dist/v1/libs/TinyDayNightCycle.mjs +65 -41
  138. package/dist/v1/libs/TinyDomReadyManager.d.mts +8 -16
  139. package/dist/v1/libs/TinyDragDropDetector.cjs +25 -0
  140. package/dist/v1/libs/TinyDragDropDetector.d.mts +32 -26
  141. package/dist/v1/libs/TinyDragDropDetector.mjs +22 -0
  142. package/dist/v1/libs/TinyDragger.cjs +46 -19
  143. package/dist/v1/libs/TinyDragger.d.mts +82 -81
  144. package/dist/v1/libs/TinyDragger.mjs +45 -18
  145. package/dist/v1/libs/TinyElementObserver.cjs +39 -0
  146. package/dist/v1/libs/TinyElementObserver.d.mts +28 -25
  147. package/dist/v1/libs/TinyElementObserver.mjs +36 -0
  148. package/dist/v1/libs/TinyGamepad.cjs +131 -2
  149. package/dist/v1/libs/TinyGamepad.d.mts +50 -122
  150. package/dist/v1/libs/TinyGamepad.mjs +129 -2
  151. package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.cjs +2 -25
  152. package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.d.mts +19 -25
  153. package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.mjs +3 -27
  154. package/dist/v1/libs/TinyHtml/TinyHtmlButton.cjs +2 -1
  155. package/dist/v1/libs/TinyHtml/TinyHtmlButton.d.mts +55 -55
  156. package/dist/v1/libs/TinyHtml/TinyHtmlButton.mjs +2 -1
  157. package/dist/v1/libs/TinyHtml/TinyHtmlCanvas.d.mts +6 -6
  158. package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.cjs +8 -4
  159. package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.d.mts +19 -21
  160. package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.mjs +7 -4
  161. package/dist/v1/libs/TinyHtml/TinyHtmlEmbed.d.mts +8 -8
  162. package/dist/v1/libs/TinyHtml/TinyHtmlForm.d.mts +18 -18
  163. package/dist/v1/libs/TinyHtml/TinyHtmlIcon.d.mts +5 -6
  164. package/dist/v1/libs/TinyHtml/TinyHtmlIframe.d.mts +19 -19
  165. package/dist/v1/libs/TinyHtml/TinyHtmlImage.cjs +0 -28
  166. package/dist/v1/libs/TinyHtml/TinyHtmlImage.d.mts +22 -28
  167. package/dist/v1/libs/TinyHtml/TinyHtmlImage.mjs +1 -27
  168. package/dist/v1/libs/TinyHtml/TinyHtmlInput.d.mts +11 -11
  169. package/dist/v1/libs/TinyHtml/TinyHtmlLink.d.mts +23 -23
  170. package/dist/v1/libs/TinyHtml/TinyHtmlMedia.d.mts +26 -26
  171. package/dist/v1/libs/TinyHtml/TinyHtmlScript.cjs +4 -30
  172. package/dist/v1/libs/TinyHtml/TinyHtmlScript.d.mts +20 -26
  173. package/dist/v1/libs/TinyHtml/TinyHtmlScript.mjs +5 -32
  174. package/dist/v1/libs/TinyHtml/TinyHtmlSelect.d.mts +19 -19
  175. package/dist/v1/libs/TinyHtml/TinyHtmlStyle.d.mts +8 -8
  176. package/dist/v1/libs/TinyHtml/TinyHtmlTemplate.d.mts +26 -28
  177. package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.cjs +14 -15
  178. package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.d.mts +32 -32
  179. package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.mjs +15 -15
  180. package/dist/v1/libs/TinyHtml/index.d.mts +102 -45
  181. package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.cjs +11 -9
  182. package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.d.mts +21 -21
  183. package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.mjs +11 -9
  184. package/dist/v1/libs/TinyHtml/input/TinyHtmlFileInput.d.mts +11 -11
  185. package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.cjs +4 -4
  186. package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.d.mts +17 -13
  187. package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.mjs +4 -4
  188. package/dist/v1/libs/TinyHtml/input/TinyHtmlImageInput.d.mts +21 -21
  189. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.cjs +5 -4
  190. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.d.mts +14 -14
  191. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.mjs +5 -4
  192. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.cjs +4 -3
  193. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.d.mts +10 -10
  194. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.mjs +4 -3
  195. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.cjs +4 -3
  196. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.d.mts +19 -19
  197. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.mjs +4 -3
  198. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.cjs +5 -4
  199. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.d.mts +11 -11
  200. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.mjs +5 -4
  201. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.cjs +4 -3
  202. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.d.mts +15 -11
  203. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.mjs +4 -3
  204. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.cjs +49 -21
  205. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.d.mts +34 -20
  206. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.mjs +45 -20
  207. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.cjs +1 -1
  208. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.d.mts +14 -14
  209. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.mjs +1 -1
  210. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.cjs +1 -1
  211. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.d.mts +14 -14
  212. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.mjs +1 -1
  213. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.cjs +48 -25
  214. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.d.mts +27 -21
  215. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.mjs +40 -27
  216. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.cjs +1 -1
  217. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.d.mts +14 -14
  218. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.mjs +1 -1
  219. package/dist/v1/libs/TinyHtml/input/number/TinyHtmlNumberInput.d.mts +14 -14
  220. package/dist/v1/libs/TinyHtml/input/number/TinyHtmlRangeInput.d.mts +14 -14
  221. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlEmailInput.d.mts +25 -21
  222. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlPasswordInput.d.mts +18 -18
  223. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlSearchInput.d.mts +33 -29
  224. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlTelInput.d.mts +22 -22
  225. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlTextInput.d.mts +18 -18
  226. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlUrlInput.d.mts +31 -27
  227. package/dist/v1/libs/TinyHtml/media/TinyHtmlAudio.d.mts +35 -11
  228. package/dist/v1/libs/TinyHtml/media/TinyHtmlObject.d.mts +10 -10
  229. package/dist/v1/libs/TinyHtml/media/TinyHtmlSource.d.mts +12 -12
  230. package/dist/v1/libs/TinyHtml/media/TinyHtmlVideo.d.mts +35 -27
  231. package/dist/v1/libs/TinyHtml.cjs +4 -5
  232. package/dist/v1/libs/TinyHtml.d.mts +1503 -1731
  233. package/dist/v1/libs/TinyHtml.mjs +5 -6
  234. package/dist/v1/libs/TinyI18.cjs +61 -0
  235. package/dist/v1/libs/TinyI18.d.mts +34 -58
  236. package/dist/v1/libs/TinyI18.mjs +55 -0
  237. package/dist/v1/libs/TinyIframeEvents.cjs +19 -2
  238. package/dist/v1/libs/TinyIframeEvents.d.mts +29 -38
  239. package/dist/v1/libs/TinyIframeEvents.mjs +19 -2
  240. package/dist/v1/libs/TinyInventory.d.mts +78 -141
  241. package/dist/v1/libs/TinyInventoryTrader.d.mts +19 -22
  242. package/dist/v1/libs/TinyLevelUp.d.mts +10 -13
  243. package/dist/v1/libs/TinyLoadingScreen.d.mts +21 -31
  244. package/dist/v1/libs/TinyLocalStorage.cjs +48 -0
  245. package/dist/v1/libs/TinyLocalStorage.d.mts +11 -30
  246. package/dist/v1/libs/TinyLocalStorage.mjs +45 -0
  247. package/dist/v1/libs/TinyMamdaniInferenceSystem.d.mts +37 -23
  248. package/dist/v1/libs/TinyMediaPlayer.cjs +77 -3
  249. package/dist/v1/libs/TinyMediaPlayer.d.mts +109 -106
  250. package/dist/v1/libs/TinyMediaPlayer.mjs +71 -3
  251. package/dist/v1/libs/TinyNeedBar.d.mts +25 -37
  252. package/dist/v1/libs/TinyNewWinEvents.cjs +29 -0
  253. package/dist/v1/libs/TinyNewWinEvents.d.mts +32 -29
  254. package/dist/v1/libs/TinyNewWinEvents.mjs +26 -0
  255. package/dist/v1/libs/TinyNotifications.d.mts +6 -6
  256. package/dist/v1/libs/TinyNotifyCenter.cjs +36 -0
  257. package/dist/v1/libs/TinyNotifyCenter.d.mts +15 -15
  258. package/dist/v1/libs/TinyNotifyCenter.mjs +32 -0
  259. package/dist/v1/libs/TinyPromiseQueue.d.mts +11 -11
  260. package/dist/v1/libs/TinyRadioFm.cjs +70 -12
  261. package/dist/v1/libs/TinyRadioFm.d.mts +45 -80
  262. package/dist/v1/libs/TinyRadioFm.mjs +64 -12
  263. package/dist/v1/libs/TinyRateLimiter.cjs +52 -0
  264. package/dist/v1/libs/TinyRateLimiter.d.mts +29 -36
  265. package/dist/v1/libs/TinyRateLimiter.mjs +48 -0
  266. package/dist/v1/libs/TinySimpleDice.d.mts +17 -36
  267. package/dist/v1/libs/TinySmartScroller.cjs +52 -3
  268. package/dist/v1/libs/TinySmartScroller.d.mts +62 -70
  269. package/dist/v1/libs/TinySmartScroller.mjs +51 -5
  270. package/dist/v1/libs/TinyTextDiffer.cjs +19 -18
  271. package/dist/v1/libs/TinyTextDiffer.d.mts +11 -13
  272. package/dist/v1/libs/TinyTextDiffer.mjs +16 -17
  273. package/dist/v1/libs/TinyTextRangeEditor.d.mts +8 -8
  274. package/dist/v1/libs/TinyTextarea.cjs +19 -0
  275. package/dist/v1/libs/TinyTextarea.d.mts +34 -28
  276. package/dist/v1/libs/TinyTextarea.mjs +17 -0
  277. package/dist/v1/libs/TinyTimeout.cjs +11 -1
  278. package/dist/v1/libs/TinyTimeout.d.mts +14 -14
  279. package/dist/v1/libs/TinyTimeout.mjs +9 -1
  280. package/dist/v1/libs/TinyToastNotify.cjs +36 -1
  281. package/dist/v1/libs/TinyToastNotify.d.mts +15 -17
  282. package/dist/v1/libs/TinyToastNotify.mjs +32 -1
  283. package/dist/v1/libs/TinyUploadClicker.cjs +19 -0
  284. package/dist/v1/libs/TinyUploadClicker.d.mts +38 -8
  285. package/dist/v1/libs/TinyUploadClicker.mjs +17 -0
  286. package/dist/v1/libs/UltraRandomMsgGen.cjs +148 -35
  287. package/dist/v1/libs/UltraRandomMsgGen.d.mts +52 -78
  288. package/dist/v1/libs/UltraRandomMsgGen.mjs +133 -34
  289. package/dist/v1/libs/utils.cjs +21 -0
  290. package/dist/v1/libs/utils.d.mts +6 -0
  291. package/dist/v1/libs/utils.mjs +16 -0
  292. package/docs/v1/README.md +1 -0
  293. package/docs/v1/basics/array.md +2 -2
  294. package/docs/v1/basics/deprecated/html.md +17 -0
  295. package/docs/v1/basics/fullScreen.md +1 -1
  296. package/docs/v1/basics/html.md +12 -26
  297. package/docs/v1/basics/mediaContent.md +1 -1
  298. package/docs/v1/basics/objChecker.md +1 -1
  299. package/docs/v1/basics/text.md +2 -2
  300. package/docs/v1/fileManager/main.md +1 -1
  301. package/docs/v1/libs/ColorSafeStringify.md +1 -1
  302. package/docs/v1/libs/TinyAfterScrollWatcher.md +1 -1
  303. package/docs/v1/libs/TinyAnalogClock.md +1 -1
  304. package/docs/v1/libs/TinyArrayComparator.md +1 -1
  305. package/docs/v1/libs/TinyArrayPaginator.md +1 -1
  306. package/docs/v1/libs/TinyClassManager/TinyPluginInliner.md +2 -2
  307. package/docs/v1/libs/TinyClassManager.md +1 -1
  308. package/docs/v1/libs/TinyClipboard.md +1 -1
  309. package/docs/v1/libs/TinyCookieConsent.md +1 -1
  310. package/docs/v1/libs/TinyDomReadyManager.md +1 -1
  311. package/docs/v1/libs/TinyDragDropDetector.md +1 -1
  312. package/docs/v1/libs/TinyDragger.md +1 -1
  313. package/docs/v1/libs/TinyElementObserver.md +1 -1
  314. package/docs/v1/libs/TinyHtml.md +1 -1
  315. package/docs/v1/libs/TinyIframeEvents.md +2 -2
  316. package/docs/v1/libs/TinyLevelUp.md +1 -1
  317. package/docs/v1/libs/TinyLoadingScreen.md +1 -1
  318. package/docs/v1/libs/TinyNewWinEvents.md +2 -2
  319. package/docs/v1/libs/TinyNotifications.md +1 -1
  320. package/docs/v1/libs/TinyPromiseQueue.md +2 -2
  321. package/docs/v1/libs/TinyTextDiffer.md +1 -1
  322. package/docs/v1/libs/TinyTextarea.md +1 -1
  323. package/package.json +11 -2
@@ -1,9 +1,14 @@
1
1
  /**
2
+ * A type representing either a static string or a function that returns a string, used to resolve an unknown artist's name.
2
3
  * @typedef {string|(() => string)} UnknownArtistGetter
3
4
  */
5
+ /**
6
+ * Represents the data type for images, which can be raw binary (Uint8Array) or a string (such as a Blob URL or Data URL).
7
+ * @typedef {Uint8Array|string} PictureDataType
8
+ */
4
9
  /**
5
10
  * Represents an image attachment template.
6
- * @template {Uint8Array|string} PictureData
11
+ * @template {PictureDataType} PictureData
7
12
  * @typedef {Object} IPictureTemplate
8
13
  * @property {string} format - The MIME type of the image (e.g., 'image/jpeg').
9
14
  * @property {PictureData} data - The raw binary data of the image.
@@ -22,7 +27,7 @@
22
27
  /**
23
28
  * This metadata structure is modeled template.
24
29
  *
25
- * @template {IPictureTemplate<Uint8Array|string>} IPictureContent
30
+ * @template {IPictureTemplate<PictureDataType>} IPictureContent
26
31
  * @typedef {Object} ContentMetadataTemplate
27
32
  * @property {string|null} title - The title of the track.
28
33
  * @property {string|null} album - The name of the album.
@@ -42,7 +47,8 @@
42
47
  * This metadata structure is modeled after the standard output of the
43
48
  * `music-metadata@11.13.0` npm package.
44
49
  *
45
- * @typedef {ContentMetadataTemplate<IPicture>} MediaContentMetadata
50
+ * @template {PictureDataType} PictureData
51
+ * @typedef {ContentMetadataTemplate<IPictureTemplate<PictureData>>} MediaContentMetadata
46
52
  */
47
53
  /**
48
54
  * The core properties required for any content item within the media system.
@@ -58,38 +64,64 @@
58
64
  * The final content object used within the media, combining
59
65
  * core playback properties with rich metadata.
60
66
  *
61
- * @typedef {MediaContentBase & MediaContentMetadata} MediaContent
67
+ * @template {PictureDataType} PictureData
68
+ * @typedef {MediaContentBase & MediaContentMetadata<PictureData>} MediaContent
62
69
  */
63
70
  //////////////////////////////////////////////////////////////////
64
71
  /**
65
72
  * A promise that resolves to an object containing the extracted metadata.
66
73
  * @callback ParseMediaContentMetadata
67
74
  * @param {Blob} data - The raw file blob.
68
- * @returns {Promise<{ common: Partial<ContentMetadataTemplate<IPictureTemplate<Uint8Array|string>>> }>} A promise resolving to the common metadata properties.
75
+ * @returns {Promise<{ common: Partial<ContentMetadataTemplate<IPictureTemplate<PictureDataType>>> }>} A promise resolving to the common metadata properties.
69
76
  */
70
77
  /**
71
- * @typedef {Object} LoadingMediaProgress
78
+ * @typedef {Object} LoadingMediaProgress Represents the current state of a media loading operation, including its status, execution stage, and the URL being processed.
72
79
  * @property {'loading'|'success'} status - The current status of the operation.
73
80
  * @property {LoadingProgressStage} stage - The current execution stage.
74
81
  * @property {ProgressEvent<EventTarget>} [event] - The current loading event.
75
82
  * @property {string} url - The URL being processed.
76
83
  */
77
84
  /**
85
+ * Defines the specific execution stages of a successful loading process.
78
86
  * @typedef {'INITIALIZING'|'DOWNLOADING'|'METADATA_LOADED'|'EXTRACTING_ID3'|'COMPLETE'} LoadingProgressStage
79
87
  */
80
88
  /**
89
+ * Defines the specific stages where a loading error might occur.
81
90
  * @typedef {'INITIALIZING'|'DOWNLOADING'|'METADATA'|'ID3'|'UNKNOWN'} LoadingErrorStage
82
91
  */
83
92
  /**
93
+ * A data structure containing details about a media loading error.
84
94
  * @typedef {Object} MediaLoadingErrorData
85
95
  * @property {Error} error - The original error object.
86
96
  * @property {string} url - The URL that failed.
87
97
  * @property {LoadingErrorStage} stage - The stage where it failed.
88
98
  */
89
99
  //////////////////////////////////////////////////////////////////
100
+ const checkString = (/** @type {string} */ val, /** @type {string} */ name) => {
101
+ if (typeof name !== 'string')
102
+ throw new TypeError('Expected "name" to be a string.');
103
+ if (typeof val !== 'string')
104
+ throw new TypeError(`Expected "${name}" to be a string, but received ${typeof val}.`);
105
+ };
106
+ const checkFunction = (/** @type {Function} */ val, /** @type {string} */ name) => {
107
+ if (typeof name !== 'string')
108
+ throw new TypeError('Expected "name" to be a string.');
109
+ if (typeof val !== 'function')
110
+ throw new TypeError(`Expected "${name}" to be a function, but received ${typeof val}.`);
111
+ };
112
+ const checkObject = (/** @type {Object<string, any> | null} */ val, /** @type {string} */ name) => {
113
+ if (typeof name !== 'string')
114
+ throw new TypeError('Expected "name" to be a string.');
115
+ if (typeof val !== 'object' || val === null || Array.isArray(val)) {
116
+ throw new TypeError(`Expected "${name}" to be a plain object, but received ${val === null ? 'null' : Array.isArray(val) ? 'array' : typeof val}.`);
117
+ }
118
+ };
90
119
  /** @type {Map<string, number>} */
91
120
  export const _blobCounter = new Map();
92
- /** @returns {MediaContentBase} */
121
+ /**
122
+ * Returns a new object initialized with the default values for the core media content properties.
123
+ * @returns {MediaContentBase}
124
+ */
93
125
  export const getMediaContentBase = () => ({
94
126
  id: '',
95
127
  title: '',
@@ -98,7 +130,10 @@ export const getMediaContentBase = () => ({
98
130
  duration: 0,
99
131
  weight: 1,
100
132
  });
101
- /** @returns {MediaContentMetadata} */
133
+ /**
134
+ * Returns a new object initialized with the default values for the media content metadata properties.
135
+ * @returns {MediaContentMetadata<PictureDataType>}
136
+ */
102
137
  export const getMediaContentMetadata = () => ({
103
138
  title: null,
104
139
  album: null,
@@ -125,6 +160,10 @@ export class MediaLoadingError extends Error {
125
160
  * @param {LoadingErrorStage} stage - The stage where the error occurred.
126
161
  */
127
162
  constructor(message, url, stage) {
163
+ checkString(message, 'message');
164
+ checkString(url, 'url');
165
+ if (typeof stage !== 'string')
166
+ throw new TypeError(`Expected "stage" to be a string, but received ${typeof stage}.`);
128
167
  super(message);
129
168
  this.name = 'MediaLoadingError';
130
169
  this.url = url;
@@ -138,6 +177,7 @@ export class MediaLoadingError extends Error {
138
177
  * @private
139
178
  */
140
179
  export const generateSimpleHash = async (str) => {
180
+ checkString(str, 'str');
141
181
  const msgUint8 = new TextEncoder().encode(str);
142
182
  const hashBuffer = await crypto.subtle.digest('SHA-1', msgUint8);
143
183
  const hashArray = Array.from(new Uint8Array(hashBuffer));
@@ -149,12 +189,15 @@ export const generateSimpleHash = async (str) => {
149
189
  };
150
190
  /**
151
191
  * Helper to convert Uint8Array or Base64 string directly into a high performance Blob URL.
152
- * @param {Uint8Array|string} data
192
+ * @param {PictureDataType} data
153
193
  * @param {string} format
154
194
  * @returns {string} The generated Blob URL or original string if already valid.
155
- * @private
156
195
  */
157
196
  export const convertToBlobUrl = (data, format = 'image/jpeg') => {
197
+ if (!(data instanceof Uint8Array) && typeof data !== 'string') {
198
+ throw new TypeError(`Expected "data" to be an instance of Uint8Array or a string, but received ${typeof data}.`);
199
+ }
200
+ checkString(format, 'format');
158
201
  const createBlobCounter = (/** @type {Blob} */ blob) => {
159
202
  const url = URL.createObjectURL(blob);
160
203
  const blobUrlUsage = _blobCounter.get(url);
@@ -182,10 +225,10 @@ export const convertToBlobUrl = (data, format = 'image/jpeg') => {
182
225
  * Asynchronous helper to convert a Blob URL back to Base64 (Date URL) at export time.
183
226
  * @param {string} url
184
227
  * @returns {Promise<string>}
185
- * @private
186
228
  */
187
229
  export const blobUrlToBase64 = async (url) => {
188
- if (typeof url !== 'string' || !url.startsWith('blob:'))
230
+ checkString(url, 'url');
231
+ if (!url.startsWith('blob:'))
189
232
  return url;
190
233
  try {
191
234
  const response = await fetch(url);
@@ -204,10 +247,11 @@ export const blobUrlToBase64 = async (url) => {
204
247
  };
205
248
  /**
206
249
  * Safely revokes Blob URLs to prevent memory leaks from createObjectURL.
207
- * @param {MediaContent} content
208
- * @private
250
+ * @template {PictureDataType} PictureData
251
+ * @param {MediaContent<PictureData>} content
209
252
  */
210
253
  export const revokeContentUrls = (content) => {
254
+ checkObject(content, 'content');
211
255
  if (content && Array.isArray(content.picture)) {
212
256
  content.picture.forEach((pic) => {
213
257
  if (typeof pic.data === 'string' && pic.data.startsWith('blob:')) {
@@ -228,13 +272,16 @@ export const revokeContentUrls = (content) => {
228
272
  * @param {boolean} isPartial - If true, properties can be undefined.
229
273
  */
230
274
  const validateMediaContent = (common, isPartial) => {
231
- // Helper to check if the property can be ignored in partial mode
275
+ checkObject(common, 'common');
276
+ if (typeof isPartial !== 'boolean')
277
+ throw new TypeError('Expected "isPartial" to be a boolean.');
232
278
  const isUndefinedAllowed = (/** @type {any} */ v) => isPartial && typeof v === 'undefined';
233
279
  const isString = (/** @type {string | null | undefined} */ v) => isUndefinedAllowed(v) || typeof v === 'string' || v === null;
234
280
  const isNumber = (/** @type {number | null | undefined}} */ v) => isUndefinedAllowed(v) || typeof v === 'number' || v === null;
235
281
  const isArray = (
236
282
  /** @type {string[] | IPictureTemplate<string|Uint8Array>[] | undefined} */ v,
237
283
  /** @type {(value: any, index: number, array: any[]) => any} */ valueValidator) => {
284
+ checkFunction(valueValidator, 'valueValidator');
238
285
  if (isUndefinedAllowed(v))
239
286
  return true;
240
287
  if (Array.isArray(v) && v.every(valueValidator))
@@ -263,7 +310,9 @@ const validateMediaContent = (common, isPartial) => {
263
310
  throw new TypeError('Invalid metadata: "composer" must be an array of string.');
264
311
  if (!isArray(common.artists, (value) => typeof value === 'string'))
265
312
  throw new TypeError('Invalid metadata: "artists" must be an array of string.');
266
- if (!isArray(common.picture, (value) => (typeof value.description === 'undefined' || typeof value.description === 'string') &&
313
+ if (!isArray(common.picture, (value) => value &&
314
+ typeof value === 'object' &&
315
+ (typeof value.description === 'undefined' || typeof value.description === 'string') &&
267
316
  (typeof value.name === 'undefined' || typeof value.name === 'string') &&
268
317
  (typeof value.type === 'undefined' || typeof value.type === 'string') &&
269
318
  typeof value.format === 'string' &&
@@ -271,10 +320,11 @@ const validateMediaContent = (common, isPartial) => {
271
320
  throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');
272
321
  /**
273
322
  * Validate Nested Objects (Disk and Track)
323
+ * @param {string} name
274
324
  * @param {MediaNumber|null} [info]
275
- * @param {string} [name]
276
325
  */
277
- const validateTrackInfo = (info, name) => {
326
+ const validateTrackInfo = (name, info) => {
327
+ checkString(name, 'name');
278
328
  if (isUndefinedAllowed(info))
279
329
  return; // Ignores if partial
280
330
  if (info === undefined || info === null) {
@@ -287,36 +337,40 @@ const validateMediaContent = (common, isPartial) => {
287
337
  if (typeof info.of !== 'number' && info.of !== null)
288
338
  throw new TypeError(`Invalid metadata: "${name}.of" must be a number or null.`);
289
339
  };
290
- validateTrackInfo(common.disk, 'disk');
291
- validateTrackInfo(common.track, 'track');
340
+ validateTrackInfo('disk', common.disk);
341
+ validateTrackInfo('track', common.track);
292
342
  };
293
343
  /**
294
344
  * Helper to validate types within the media content metadata object.
295
345
  * This ensures that if a property is present, it matches the expected type.
296
346
  * @param {ContentMetadataTemplate<IPictureTemplate<string | Uint8Array<ArrayBufferLike>>>} common
297
347
  */
298
- export const valMediaContentMetadata = (common) => validateMediaContent(common, false);
348
+ export const valMediaContentMetadata = (common) => {
349
+ checkObject(common, 'common');
350
+ return validateMediaContent(common, false);
351
+ };
299
352
  /**
300
353
  * Helper to validate types within the media content metadata object.
301
354
  * Allows the absence of properties (useful for updates/patch).
302
355
  * @param {Partial<ContentMetadataTemplate<IPictureTemplate<string | Uint8Array<ArrayBufferLike>>>>} common
303
356
  */
304
- export const valMediaContentMetadataPartial = (common) => validateMediaContent(common, true);
357
+ export const valMediaContentMetadataPartial = (common) => {
358
+ checkObject(common, 'common');
359
+ return validateMediaContent(common, true);
360
+ };
305
361
  /**
306
362
  * Downloads an audio file from a URL and extracts its ID3/metadata tags.
307
363
  *
308
364
  * @param {string} url - The full URL of the audio file to be downloaded.
309
365
  * @param {ParseMediaContentMetadata} parseFile - The function used to parse the file data.
310
- * @returns {Promise<MediaContentMetadata>} A promise that resolves to an object containing the extracted metadata.
366
+ * @returns {Promise<MediaContentMetadata<string>>} A promise that resolves to an object containing the extracted metadata.
311
367
  * @throws {TypeError} If the provided `url` is not a string or `parseFile` is not a function.
312
368
  * @throws {Error} If the network request fails or the parsing process encounters an error.
313
369
  */
314
370
  export const extractMediaId3Tags = async (url, parseFile) => {
315
371
  // Argument Validation
316
- if (typeof url !== 'string')
317
- throw new TypeError(`Expected url to be a string, but received ${typeof url}.`);
318
- if (typeof parseFile !== 'function')
319
- throw new TypeError(`Expected parseFile to be a function, but received ${typeof parseFile}.`);
372
+ checkString(url, 'url');
373
+ checkFunction(parseFile, 'parseFile');
320
374
  try {
321
375
  // 1. Download the file from the provided URL
322
376
  const response = await fetch(url);
@@ -361,15 +415,16 @@ export const extractMediaId3Tags = async (url, parseFile) => {
361
415
  * A Static Factory Method that prepares a MediaContent object by
362
416
  * extracting metadata from an audio source.
363
417
  *
418
+ * @template {PictureDataType} PictureData
364
419
  * @param {string | HTMLMediaElement} source - A URL string or an existing Audio object.
365
- * @param {Partial<MediaContentBase & MediaContentMetadata> & { id?: string; weight?: number }} [defaultMetadata={}] - Optional default metadata that overrides automatic extraction.
366
- * @param {Partial<MediaContentBase & MediaContentMetadata> & { id?: string; weight?: number }} [metadata={}] - Optional manual metadata that overrides automatic extraction.
420
+ * @param {Partial<MediaContentBase & MediaContentMetadata<PictureData>> & { id?: string; weight?: number }} [defaultMetadata={}] - Optional default metadata that overrides automatic extraction.
421
+ * @param {Partial<MediaContentBase & MediaContentMetadata<PictureData>> & { id?: string; weight?: number }} [metadata={}] - Optional manual metadata that overrides automatic extraction.
367
422
  * @param {ParseMediaContentMetadata} [parseFile] - Private helper to interface with parseFile.
368
423
  * @param {Object} [callbacks={}] - Callbacks for monitoring the loading process.
369
424
  * @param {(progress: LoadingMediaProgress) => void} [callbacks.onProgress] - Callback triggered on stage changes.
370
425
  * @param {(error: MediaLoadingErrorData) => void} [callbacks.onError] - Callback triggered when a non-fatal or fatal error occurs.
371
426
  * @param {UnknownArtistGetter} unknownArtist
372
- * @returns {Promise<MediaContent>} A promise that resolves to a valid MediaContent object.
427
+ * @returns {Promise<MediaContent<PictureData>>} A promise that resolves to a valid MediaContent object.
373
428
  * @throws {MediaLoadingError} If the preparation process fails at any stage.
374
429
  *
375
430
  * @example
@@ -399,16 +454,25 @@ export const extractMediaId3Tags = async (url, parseFile) => {
399
454
  * }
400
455
  * );
401
456
  */
402
- export const parseMediaMetadata = async (source, defaultMetadata = {}, metadata = {}, parseFile = (url) => {
457
+ export const parseMediaMetadata = async (source, defaultMetadata = {}, metadata = {}, parseFile = (data) => {
458
+ if (!(data instanceof Blob))
459
+ throw new TypeError('Expected "data" to be a Blob.');
403
460
  return new Promise((resolve, reject) => reject(new TypeError('parseFile library not found.')));
404
461
  }, callbacks = {}, unknownArtist = 'null') => {
405
462
  // Argument Validation
406
463
  if (typeof source !== 'string' && !(source instanceof HTMLMediaElement))
407
464
  throw new TypeError('Source must be a string or an HTMLMediaElement.');
465
+ checkObject(defaultMetadata, 'defaultMetadata');
466
+ checkObject(metadata, 'metadata');
467
+ checkFunction(parseFile, 'parseFile');
468
+ checkObject(callbacks, 'callbacks');
408
469
  if (callbacks.onProgress && typeof callbacks.onProgress !== 'function')
409
470
  throw new TypeError('callbacks.onProgress must be a function.');
410
471
  if (callbacks.onError && typeof callbacks.onError !== 'function')
411
472
  throw new TypeError('callbacks.onError must be a function.');
473
+ if (typeof unknownArtist !== 'string' && typeof unknownArtist !== 'function') {
474
+ throw new TypeError('unknownArtist must be a string or a function returning a string.');
475
+ }
412
476
  /** @type {HTMLMediaElement} */
413
477
  let audio;
414
478
  /** @type {string} */
@@ -418,6 +482,10 @@ export const parseMediaMetadata = async (source, defaultMetadata = {}, metadata
418
482
  * @param {ProgressEvent<EventTarget>} [event]
419
483
  */
420
484
  const notifyProgress = (stage, event) => {
485
+ checkString(stage, 'stage');
486
+ if (event !== undefined && !(event instanceof Event)) {
487
+ throw new TypeError('Expected "event" to be an Event or undefined.');
488
+ }
421
489
  if (callbacks.onProgress) {
422
490
  callbacks.onProgress({
423
491
  event,
@@ -428,6 +496,9 @@ export const parseMediaMetadata = async (source, defaultMetadata = {}, metadata
428
496
  }
429
497
  };
430
498
  const notifyError = (/** @type {Error} */ error, /** @type {LoadingErrorStage} */ stage) => {
499
+ if (!(error instanceof Error))
500
+ throw new TypeError('Expected "error" to be an Error.');
501
+ checkString(stage, 'stage'); // Adicionado
431
502
  if (callbacks.onError) {
432
503
  callbacks.onError({
433
504
  error,
@@ -492,7 +563,7 @@ export const parseMediaMetadata = async (source, defaultMetadata = {}, metadata
492
563
  weight: metadata.weight ?? 1,
493
564
  };
494
565
  // 4. Automatic Metadata Extraction (ID3 Tags)
495
- /** @type {Partial<MediaContentMetadata>} */
566
+ /** @type {Partial<MediaContentMetadata<string>>} */
496
567
  let extractedMetadata = {};
497
568
  notifyProgress('EXTRACTING_ID3');
498
569
  try {
@@ -510,6 +581,7 @@ export const parseMediaMetadata = async (source, defaultMetadata = {}, metadata
510
581
  * @returns {string}
511
582
  */
512
583
  const getFallbackTitleFromUrl = (url) => {
584
+ checkString(url, 'url');
513
585
  try {
514
586
  // Remove query params or hashes, get the last segment, and strip extension
515
587
  const filename = url.split(/[?#]/)[0].split('/').pop();
@@ -540,7 +612,7 @@ export const parseMediaMetadata = async (source, defaultMetadata = {}, metadata
540
612
  url: url,
541
613
  });
542
614
  }
543
- return /** @type {MediaContent} */ (finalContent);
615
+ return /** @type {MediaContent<PictureData>} */ (finalContent);
544
616
  }
545
617
  catch (err) {
546
618
  // If it's already a MediaLoadingError, re-throw it.
@@ -4,20 +4,22 @@
4
4
  * Counts the number of elements in an array or the number of properties in an object.
5
5
  *
6
6
  * @param {Array<*>|Record<string | number | symbol, any>} obj - The array or object to count.
7
- * @returns {number} - The count of items (array elements or object keys), or `0` if the input is neither an array nor an object.
7
+ * @returns {number} - The count of items (array elements or object keys).
8
+ * @throws {TypeError} If the input is neither an array nor a pure object.
8
9
  *
9
10
  * @example
10
11
  * countObj([1, 2, 3]); // 3
11
12
  * countObj({ a: 1, b: 2 }); // 2
12
- * countObj('not an object'); // 0
13
+ * countObj('not an object'); // Throws TypeError
13
14
  */
14
15
  function countObj(obj) {
16
+ if (!Array.isArray(obj) && !isJsonObject(obj))
17
+ throw new TypeError('Argument must be either an Array or a pure JSON Object.');
18
+
15
19
  // Is Array
16
20
  if (Array.isArray(obj)) return obj.length;
17
21
  // Object
18
- if (isJsonObject(obj)) return Object.keys(obj).length;
19
- // Nothing
20
- return 0;
22
+ return Object.keys(obj).length;
21
23
  }
22
24
 
23
25
  /**
@@ -2,14 +2,15 @@
2
2
  * Counts the number of elements in an array or the number of properties in an object.
3
3
  *
4
4
  * @param {Array<*>|Record<string | number | symbol, any>} obj - The array or object to count.
5
- * @returns {number} - The count of items (array elements or object keys), or `0` if the input is neither an array nor an object.
5
+ * @returns {number} - The count of items (array elements or object keys).
6
+ * @throws {TypeError} If the input is neither an array nor a pure object.
6
7
  *
7
8
  * @example
8
9
  * countObj([1, 2, 3]); // 3
9
10
  * countObj({ a: 1, b: 2 }); // 2
10
- * countObj('not an object'); // 0
11
+ * countObj('not an object'); // Throws TypeError
11
12
  */
12
- export function countObj(obj: Array<any> | Record<string | number | symbol, any>): number;
13
+ export declare function countObj(obj: Array<any> | Record<string | number | symbol, any>): number;
13
14
  /**
14
15
  * Determines whether a given value is a pure JSON object (plain object).
15
16
  *
@@ -25,5 +26,5 @@ export function countObj(obj: Array<any> | Record<string | number | symbol, any>
25
26
  * @param {unknown} value - The value to test.
26
27
  * @returns {value is Record<string | number | symbol, unknown>} Returns true if the value is a pure object.
27
28
  */
28
- export function isJsonObject(value: unknown): value is Record<string | number | symbol, unknown>;
29
+ export declare function isJsonObject(value: unknown): value is Record<string | number | symbol, unknown>;
29
30
  //# sourceMappingURL=objChecker.d.mts.map
@@ -2,22 +2,22 @@
2
2
  * Counts the number of elements in an array or the number of properties in an object.
3
3
  *
4
4
  * @param {Array<*>|Record<string | number | symbol, any>} obj - The array or object to count.
5
- * @returns {number} - The count of items (array elements or object keys), or `0` if the input is neither an array nor an object.
5
+ * @returns {number} - The count of items (array elements or object keys).
6
+ * @throws {TypeError} If the input is neither an array nor a pure object.
6
7
  *
7
8
  * @example
8
9
  * countObj([1, 2, 3]); // 3
9
10
  * countObj({ a: 1, b: 2 }); // 2
10
- * countObj('not an object'); // 0
11
+ * countObj('not an object'); // Throws TypeError
11
12
  */
12
13
  export function countObj(obj) {
14
+ if (!Array.isArray(obj) && !isJsonObject(obj))
15
+ throw new TypeError('Argument must be either an Array or a pure JSON Object.');
13
16
  // Is Array
14
17
  if (Array.isArray(obj))
15
18
  return obj.length;
16
19
  // Object
17
- if (isJsonObject(obj))
18
- return Object.keys(obj).length;
19
- // Nothing
20
- return 0;
20
+ return Object.keys(obj).length;
21
21
  }
22
22
  /**
23
23
  * Determines whether a given value is a pure JSON object (plain object).
@@ -33,26 +33,48 @@ const typeValidator = {
33
33
  * If no index is provided, the type is inserted just before 'object' (if it exists), or at the end.
34
34
  *
35
35
  * @param {ExtendObjType|ExtendObjTypeArray} newItems
36
- * - New type validators to be added.
36
+ * - New type validators to be added.
37
37
  * @param {number} [index] - Optional. Position at which to insert each new type. Ignored if the type already exists.
38
38
  * @returns {string[]} - A list of successfully added type names.
39
39
  *
40
40
  * @example
41
41
  * extendObjType({
42
- * htmlElement2: val => typeof HTMLElement !== 'undefined' && val instanceof HTMLElement
42
+ * htmlElement2: val => typeof HTMLElement !== 'undefined' && val instanceof HTMLElement
43
43
  * });
44
44
  *
45
45
  * @example
46
46
  * extendObjType([
47
- * ['alpha', val => typeof val === 'string'],
48
- * ['beta', val => Array.isArray(val)]
47
+ * ['alpha', val => typeof val === 'string'],
48
+ * ['beta', val => Array.isArray(val)]
49
49
  * ]);
50
50
  */
51
51
  function extendObjType(newItems, index) {
52
+ if (typeof newItems !== 'object' || newItems === null) {
53
+ throw new TypeError("Argument 'newItems' must be an object or an array.");
54
+ }
55
+
56
+ if (typeof index !== 'undefined' && typeof index !== 'number') {
57
+ throw new TypeError("Argument 'index' must be a number.");
58
+ }
59
+
52
60
  const added = [];
53
61
 
54
62
  const entries = Array.isArray(newItems) ? newItems : Object.entries(newItems);
55
- for (const [key, fn] of entries) {
63
+
64
+ for (const entry of entries) {
65
+ if (!Array.isArray(entry) || entry.length < 2) {
66
+ throw new TypeError("Each item in 'newItems' array must be a [key, function] pair.");
67
+ }
68
+
69
+ const [key, fn] = entry;
70
+
71
+ if (typeof key !== 'string') {
72
+ throw new TypeError('Validator key must be a string.');
73
+ }
74
+ if (typeof fn !== 'function') {
75
+ throw new TypeError(`Validator for key '${key}' must be a function.`);
76
+ }
77
+
56
78
  if (!typeValidator.items.hasOwnProperty(key)) {
57
79
  // @ts-ignore
58
80
  typeValidator.items[key] = fn;
@@ -86,10 +108,17 @@ function extendObjType(newItems, index) {
86
108
  *
87
109
  * @example
88
110
  * reorderObjTypeOrder([
89
- * 'string', 'number', 'array', 'object'
111
+ * 'string', 'number', 'array', 'object'
90
112
  * ]);
91
113
  */
92
114
  function reorderObjTypeOrder(newOrder) {
115
+ if (!Array.isArray(newOrder)) {
116
+ throw new TypeError("Argument 'newOrder' must be an array of strings.");
117
+ }
118
+ if (!newOrder.every((item) => typeof item === 'string')) {
119
+ throw new TypeError("All elements in 'newOrder' must be strings.");
120
+ }
121
+
93
122
  const currentOrder = [...typeValidator.order]; // shallow clone
94
123
 
95
124
  // All keys in newOrder must exist in currentOrder
@@ -147,7 +176,7 @@ const getType = (val) => {
147
176
  * @param {*} obj - The object to check or identify.
148
177
  * @param {string} [type] - Optional. If provided, checks whether the object matches this type (e.g., "object", "array", "string").
149
178
  * @returns {boolean|string|null} - Returns `true` if the type matches, `false` if not,
150
- * the type string if no type is provided, or `null` if the object is `undefined`.
179
+ * the type string if no type is provided, or `null` if the object is `undefined`.
151
180
  *
152
181
  * @example
153
182
  * objType([], 'array'); // true
@@ -157,6 +186,10 @@ const getType = (val) => {
157
186
  */
158
187
  function objType(obj, type) {
159
188
  if (typeof obj === 'undefined') return null;
189
+ if (typeof type !== 'undefined' && typeof type !== 'string') {
190
+ throw new TypeError("Argument 'type' must be a string.");
191
+ }
192
+
160
193
  const result = getType(obj);
161
194
  if (typeof type === 'string') return result === type.toLowerCase();
162
195
  return result;
@@ -239,7 +272,10 @@ extendObjType([
239
272
  ],
240
273
  [
241
274
  'array',
242
- /** @param {*} val @returns {val is any[]} */
275
+ /**
276
+ * @template {any} Value
277
+ * @param {*} val @returns {val is Value[]}
278
+ */
243
279
  (val) => Array.isArray(val),
244
280
  ],
245
281
  ]);
@@ -267,27 +303,44 @@ extendObjType([
267
303
  ],
268
304
  [
269
305
  'map',
270
- /** @param {*} val @returns {val is Map<unknown, unknown>} */
306
+ /**
307
+ * @template {any} Key
308
+ * @template {any} Value
309
+ * @param {*} val @returns {val is Map<Key, Value>}
310
+ */
271
311
  (val) => val instanceof Map,
272
312
  ],
273
313
  [
274
314
  'set',
275
- /** @param {*} val @returns {val is Set<unknown>} */
315
+ /**
316
+ * @template {any} Value
317
+ * @param {*} val @returns {val is Set<Value>}
318
+ */
276
319
  (val) => val instanceof Set,
277
320
  ],
278
321
  [
279
322
  'weakmap',
280
- /** @param {*} val @returns {val is WeakMap<unknown, unknown>} */
323
+ /**
324
+ * @template {WeakKey} Key
325
+ * @template {any} Value
326
+ * @param {*} val @returns {val is WeakMap<Key, Value>}
327
+ */
281
328
  (val) => val instanceof WeakMap,
282
329
  ],
283
330
  [
284
331
  'weakset',
285
- /** @param {*} val @returns {val is WeakSet<unknown>} */
332
+ /**
333
+ * @template {WeakKey} Value
334
+ * @param {*} val @returns {val is WeakSet<Value>}
335
+ */
286
336
  (val) => val instanceof WeakSet,
287
337
  ],
288
338
  [
289
339
  'promise',
290
- /** @param {*} val @returns {val is Promise<unknown>} */
340
+ /**
341
+ * @template {any} Value
342
+ * @param {*} val @returns {val is Promise<Value>}
343
+ */
291
344
  (val) => val instanceof Promise,
292
345
  ],
293
346
  ]);
@@ -305,7 +358,11 @@ if (isBrowser) {
305
358
  extendObjType([
306
359
  [
307
360
  'object',
308
- /** @param {*} val @returns {val is Record<string | number | symbol, unknown>} */
361
+ /**
362
+ * @template {string | number | symbol} Key
363
+ * @template {any} Value
364
+ * @param {*} val @returns {val is Record<Key, Value>}
365
+ */
309
366
  (val) => objChecker.isJsonObject(val),
310
367
  ],
311
368
  ]);