tiny-essentials 1.28.1 → 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 (211) hide show
  1. package/changelog/1/28/2.md +43 -0
  2. package/dist/_/numbers.d.mts +91 -16
  3. package/dist/v1/TinyBasicsEs.min.js +1 -1
  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/basics/array.d.mts +14 -14
  8. package/dist/v1/basics/clock.cjs +15 -15
  9. package/dist/v1/basics/clock.d.mts +21 -21
  10. package/dist/v1/basics/clock.mjs +15 -15
  11. package/dist/v1/basics/collision.d.mts +245 -104
  12. package/dist/v1/basics/deprecated/html.d.mts +33 -33
  13. package/dist/v1/basics/extendObjType/Buffer.d.mts +1 -1
  14. package/dist/v1/basics/fullScreen.d.mts +47 -7
  15. package/dist/v1/basics/html.d.mts +52 -61
  16. package/dist/v1/basics/index.d.mts +11 -67
  17. package/dist/v1/basics/mediaContent.cjs +65 -23
  18. package/dist/v1/basics/mediaContent.d.mts +144 -73
  19. package/dist/v1/basics/mediaContent.mjs +65 -23
  20. package/dist/v1/basics/objChecker.d.mts +2 -2
  21. package/dist/v1/basics/objFilter.cjs +31 -7
  22. package/dist/v1/basics/objFilter.d.mts +10 -13
  23. package/dist/v1/basics/objFilter.mjs +31 -7
  24. package/dist/v1/basics/simpleMath.d.mts +21 -21
  25. package/dist/v1/basics/text.d.mts +34 -46
  26. package/dist/v1/build/ColorSafeStringify.d.mts +1 -1
  27. package/dist/v1/build/TinyAdvancedRaffle.d.mts +1 -1
  28. package/dist/v1/build/TinyAfterScrollWatcher.d.mts +1 -1
  29. package/dist/v1/build/TinyAnalogClock.d.mts +1 -1
  30. package/dist/v1/build/TinyArrayComparator.d.mts +1 -1
  31. package/dist/v1/build/TinyArrayPaginator.d.mts +1 -1
  32. package/dist/v1/build/TinyClassManager.d.mts +1 -1
  33. package/dist/v1/build/TinyClipboard.d.mts +1 -1
  34. package/dist/v1/build/TinyColorConverter.d.mts +1 -1
  35. package/dist/v1/build/TinyColorValidator.d.mts +1 -1
  36. package/dist/v1/build/TinyCookieConsent.d.mts +1 -1
  37. package/dist/v1/build/TinyDayNightCycle.d.mts +1 -1
  38. package/dist/v1/build/TinyDomReadyManager.d.mts +1 -1
  39. package/dist/v1/build/TinyDragDropDetector.d.mts +1 -1
  40. package/dist/v1/build/TinyDragger.d.mts +1 -1
  41. package/dist/v1/build/TinyElementObserver.d.mts +1 -1
  42. package/dist/v1/build/TinyGamepad.d.mts +1 -1
  43. package/dist/v1/build/TinyHtml.d.mts +1 -1
  44. package/dist/v1/build/TinyI18.d.mts +1 -1
  45. package/dist/v1/build/TinyIframeEvents.d.mts +1 -1
  46. package/dist/v1/build/TinyInventory.d.mts +1 -1
  47. package/dist/v1/build/TinyInventoryTrader.d.mts +1 -1
  48. package/dist/v1/build/TinyLevelUp.d.mts +1 -1
  49. package/dist/v1/build/TinyLoadingScreen.d.mts +1 -1
  50. package/dist/v1/build/TinyLocalStorage.d.mts +1 -1
  51. package/dist/v1/build/TinyMediaPlayer.d.mts +1 -1
  52. package/dist/v1/build/TinyNeedBar.d.mts +1 -1
  53. package/dist/v1/build/TinyNewWinEvents.d.mts +1 -1
  54. package/dist/v1/build/TinyNotifications.d.mts +1 -1
  55. package/dist/v1/build/TinyNotifyCenter.d.mts +1 -1
  56. package/dist/v1/build/TinyPromiseQueue.d.mts +1 -1
  57. package/dist/v1/build/TinyRadioFm.d.mts +1 -1
  58. package/dist/v1/build/TinyRateLimiter.d.mts +1 -1
  59. package/dist/v1/build/TinySimpleDice.d.mts +1 -1
  60. package/dist/v1/build/TinySmartScroller.d.mts +1 -1
  61. package/dist/v1/build/TinyTextDiffer.d.mts +1 -1
  62. package/dist/v1/build/TinyTextRangeEditor.d.mts +1 -1
  63. package/dist/v1/build/TinyTextarea.d.mts +1 -1
  64. package/dist/v1/build/TinyTimeout.d.mts +1 -1
  65. package/dist/v1/build/TinyToastNotify.d.mts +1 -1
  66. package/dist/v1/build/TinyUploadClicker.d.mts +1 -1
  67. package/dist/v1/build/UltraRandomMsgGen.d.mts +1 -1
  68. package/dist/v1/fileManager/asyncFuncs.d.mts +13 -13
  69. package/dist/v1/fileManager/index.d.mts +3 -29
  70. package/dist/v1/fileManager/normalFuncs.d.mts +22 -22
  71. package/dist/v1/index.d.mts +53 -139
  72. package/dist/v1/libs/ColorSafeStringify.d.mts +3 -12
  73. package/dist/v1/libs/TinyAdvancedRaffle.d.mts +60 -103
  74. package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +11 -18
  75. package/dist/v1/libs/TinyAnalogClock.d.mts +8 -11
  76. package/dist/v1/libs/TinyArrayComparator.d.mts +14 -20
  77. package/dist/v1/libs/TinyArrayPaginator.d.mts +22 -26
  78. package/dist/v1/libs/TinyClassManager/TinyPluginInliner.d.mts +8 -8
  79. package/dist/v1/libs/TinyClassManager.cjs +5 -7
  80. package/dist/v1/libs/TinyClassManager.d.mts +16 -16
  81. package/dist/v1/libs/TinyClassManager.mjs +5 -6
  82. package/dist/v1/libs/TinyClipboard.d.mts +8 -3
  83. package/dist/v1/libs/TinyColorConverter.d.mts +8 -31
  84. package/dist/v1/libs/TinyColorValidator.d.mts +145 -184
  85. package/dist/v1/libs/TinyCookieConsent.d.mts +17 -17
  86. package/dist/v1/libs/TinyDayNightCycle.d.mts +85 -110
  87. package/dist/v1/libs/TinyDomReadyManager.d.mts +8 -16
  88. package/dist/v1/libs/TinyDragDropDetector.d.mts +30 -30
  89. package/dist/v1/libs/TinyDragger.d.mts +82 -81
  90. package/dist/v1/libs/TinyElementObserver.d.mts +25 -28
  91. package/dist/v1/libs/TinyGamepad.cjs +0 -1
  92. package/dist/v1/libs/TinyGamepad.d.mts +50 -122
  93. package/dist/v1/libs/TinyGamepad.mjs +0 -1
  94. package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.cjs +2 -25
  95. package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.d.mts +19 -25
  96. package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.mjs +3 -27
  97. package/dist/v1/libs/TinyHtml/TinyHtmlButton.cjs +2 -1
  98. package/dist/v1/libs/TinyHtml/TinyHtmlButton.d.mts +55 -55
  99. package/dist/v1/libs/TinyHtml/TinyHtmlButton.mjs +2 -1
  100. package/dist/v1/libs/TinyHtml/TinyHtmlCanvas.d.mts +6 -6
  101. package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.cjs +8 -4
  102. package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.d.mts +19 -21
  103. package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.mjs +7 -4
  104. package/dist/v1/libs/TinyHtml/TinyHtmlEmbed.d.mts +8 -8
  105. package/dist/v1/libs/TinyHtml/TinyHtmlForm.d.mts +18 -18
  106. package/dist/v1/libs/TinyHtml/TinyHtmlIcon.d.mts +5 -6
  107. package/dist/v1/libs/TinyHtml/TinyHtmlIframe.d.mts +19 -19
  108. package/dist/v1/libs/TinyHtml/TinyHtmlImage.cjs +0 -28
  109. package/dist/v1/libs/TinyHtml/TinyHtmlImage.d.mts +22 -28
  110. package/dist/v1/libs/TinyHtml/TinyHtmlImage.mjs +1 -27
  111. package/dist/v1/libs/TinyHtml/TinyHtmlInput.d.mts +11 -11
  112. package/dist/v1/libs/TinyHtml/TinyHtmlLink.d.mts +23 -23
  113. package/dist/v1/libs/TinyHtml/TinyHtmlMedia.d.mts +26 -26
  114. package/dist/v1/libs/TinyHtml/TinyHtmlScript.cjs +4 -30
  115. package/dist/v1/libs/TinyHtml/TinyHtmlScript.d.mts +20 -26
  116. package/dist/v1/libs/TinyHtml/TinyHtmlScript.mjs +5 -32
  117. package/dist/v1/libs/TinyHtml/TinyHtmlSelect.d.mts +19 -19
  118. package/dist/v1/libs/TinyHtml/TinyHtmlStyle.d.mts +8 -8
  119. package/dist/v1/libs/TinyHtml/TinyHtmlTemplate.d.mts +26 -28
  120. package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.cjs +14 -15
  121. package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.d.mts +32 -32
  122. package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.mjs +15 -15
  123. package/dist/v1/libs/TinyHtml/index.d.mts +102 -45
  124. package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.cjs +11 -9
  125. package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.d.mts +21 -21
  126. package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.mjs +11 -9
  127. package/dist/v1/libs/TinyHtml/input/TinyHtmlFileInput.d.mts +11 -11
  128. package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.cjs +4 -4
  129. package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.d.mts +17 -13
  130. package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.mjs +4 -4
  131. package/dist/v1/libs/TinyHtml/input/TinyHtmlImageInput.d.mts +21 -21
  132. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.cjs +5 -4
  133. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.d.mts +14 -14
  134. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.mjs +5 -4
  135. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.cjs +4 -3
  136. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.d.mts +10 -10
  137. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.mjs +4 -3
  138. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.cjs +4 -3
  139. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.d.mts +19 -19
  140. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.mjs +4 -3
  141. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.cjs +5 -4
  142. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.d.mts +11 -11
  143. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.mjs +5 -4
  144. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.cjs +4 -3
  145. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.d.mts +15 -11
  146. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.mjs +4 -3
  147. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.cjs +49 -21
  148. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.d.mts +34 -20
  149. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.mjs +45 -20
  150. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.cjs +1 -1
  151. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.d.mts +14 -14
  152. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.mjs +1 -1
  153. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.cjs +1 -1
  154. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.d.mts +14 -14
  155. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.mjs +1 -1
  156. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.cjs +48 -25
  157. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.d.mts +27 -21
  158. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.mjs +40 -27
  159. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.cjs +1 -1
  160. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.d.mts +14 -14
  161. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.mjs +1 -1
  162. package/dist/v1/libs/TinyHtml/input/number/TinyHtmlNumberInput.d.mts +14 -14
  163. package/dist/v1/libs/TinyHtml/input/number/TinyHtmlRangeInput.d.mts +14 -14
  164. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlEmailInput.d.mts +25 -21
  165. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlPasswordInput.d.mts +18 -18
  166. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlSearchInput.d.mts +33 -29
  167. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlTelInput.d.mts +22 -22
  168. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlTextInput.d.mts +18 -18
  169. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlUrlInput.d.mts +31 -27
  170. package/dist/v1/libs/TinyHtml/media/TinyHtmlAudio.d.mts +35 -11
  171. package/dist/v1/libs/TinyHtml/media/TinyHtmlObject.d.mts +10 -10
  172. package/dist/v1/libs/TinyHtml/media/TinyHtmlSource.d.mts +12 -12
  173. package/dist/v1/libs/TinyHtml/media/TinyHtmlVideo.d.mts +35 -27
  174. package/dist/v1/libs/TinyHtml.cjs +3 -4
  175. package/dist/v1/libs/TinyHtml.d.mts +1503 -1731
  176. package/dist/v1/libs/TinyHtml.mjs +3 -4
  177. package/dist/v1/libs/TinyI18.d.mts +23 -61
  178. package/dist/v1/libs/TinyIframeEvents.cjs +1 -1
  179. package/dist/v1/libs/TinyIframeEvents.d.mts +29 -38
  180. package/dist/v1/libs/TinyIframeEvents.mjs +1 -1
  181. package/dist/v1/libs/TinyInventory.d.mts +78 -141
  182. package/dist/v1/libs/TinyInventoryTrader.d.mts +19 -22
  183. package/dist/v1/libs/TinyLevelUp.d.mts +10 -13
  184. package/dist/v1/libs/TinyLoadingScreen.d.mts +21 -31
  185. package/dist/v1/libs/TinyLocalStorage.d.mts +11 -36
  186. package/dist/v1/libs/TinyMamdaniInferenceSystem.d.mts +37 -23
  187. package/dist/v1/libs/TinyMediaPlayer.cjs +5 -3
  188. package/dist/v1/libs/TinyMediaPlayer.d.mts +102 -109
  189. package/dist/v1/libs/TinyMediaPlayer.mjs +5 -3
  190. package/dist/v1/libs/TinyNeedBar.d.mts +25 -37
  191. package/dist/v1/libs/TinyNewWinEvents.d.mts +29 -32
  192. package/dist/v1/libs/TinyNotifications.d.mts +6 -6
  193. package/dist/v1/libs/TinyNotifyCenter.d.mts +15 -21
  194. package/dist/v1/libs/TinyPromiseQueue.d.mts +11 -11
  195. package/dist/v1/libs/TinyRadioFm.cjs +32 -12
  196. package/dist/v1/libs/TinyRadioFm.d.mts +44 -80
  197. package/dist/v1/libs/TinyRadioFm.mjs +29 -12
  198. package/dist/v1/libs/TinyRateLimiter.d.mts +26 -39
  199. package/dist/v1/libs/TinySimpleDice.d.mts +17 -36
  200. package/dist/v1/libs/TinySmartScroller.d.mts +50 -60
  201. package/dist/v1/libs/TinyTextDiffer.d.mts +11 -14
  202. package/dist/v1/libs/TinyTextRangeEditor.d.mts +8 -8
  203. package/dist/v1/libs/TinyTextarea.d.mts +31 -31
  204. package/dist/v1/libs/TinyTimeout.d.mts +14 -14
  205. package/dist/v1/libs/TinyToastNotify.cjs +1 -1
  206. package/dist/v1/libs/TinyToastNotify.d.mts +15 -23
  207. package/dist/v1/libs/TinyToastNotify.mjs +1 -1
  208. package/dist/v1/libs/TinyUploadClicker.d.mts +38 -14
  209. package/dist/v1/libs/UltraRandomMsgGen.d.mts +44 -84
  210. package/dist/v1/libs/utils.d.mts +5 -1
  211. package/package.json +2 -2
@@ -9,7 +9,7 @@
9
9
  * @throws {Error} - If an unexpected error occurs while handling the result.
10
10
  * @throws {DOMException} - If the FileReader encounters an error while reading the file.
11
11
  */
12
- export function readFileBlob(file: File | Blob, method: "readAsArrayBuffer" | "readAsDataURL" | "readAsText" | "readAsBinaryString"): Promise<any>;
12
+ export declare function readFileBlob(file: File | Blob, method: 'readAsArrayBuffer' | 'readAsDataURL' | 'readAsText' | 'readAsBinaryString'): Promise<any>;
13
13
  /**
14
14
  * Reads a file as a Base64 string using FileReader, and optionally formats it as a full data URL.
15
15
  *
@@ -24,7 +24,7 @@ export function readFileBlob(file: File | Blob, method: "readAsArrayBuffer" | "r
24
24
  * @throws {Error} - If the result does not match the expected data URL format or Base64 structure.
25
25
  * @throws {DOMException} - If the FileReader fails to read the file.
26
26
  */
27
- export function readBase64Blob(file: File | Blob, isDataUrl?: boolean | string): Promise<string>;
27
+ export declare function readBase64Blob(file: File | Blob, isDataUrl?: boolean | string): Promise<string>;
28
28
  /**
29
29
  * Reads a file and strictly validates its content as proper JSON using FileReader.
30
30
  *
@@ -38,7 +38,7 @@ export function readBase64Blob(file: File | Blob, isDataUrl?: boolean | string):
38
38
  * @throws {Error} - If the result is empty or structurally invalid as JSON.
39
39
  * @throws {DOMException} - If the FileReader fails to read the file.
40
40
  */
41
- export function readJsonBlob(file: File | Blob): Promise<Record<string | number | symbol, any> | any[]>;
41
+ export declare function readJsonBlob(file: File | Blob): Promise<Record<string | number | symbol, any> | any[]>;
42
42
  /**
43
43
  * Saves a JSON object as a downloadable file.
44
44
  * @param {string} filename
@@ -46,7 +46,8 @@ export function readJsonBlob(file: File | Blob): Promise<Record<string | number
46
46
  * @param {number} [spaces=2]
47
47
  * @throws {TypeError} - If arguments do not match expected types.
48
48
  */
49
- export function saveJsonFile(filename: string, data: any, spaces?: number): void;
49
+ export declare function saveJsonFile(filename: string, data: any, spaces?: number): void;
50
+ export type FetchOnProgressResult = (loaded: number, total: number) => void;
50
51
  /**
51
52
  * Callback function used to report the progress of a data download.
52
53
  *
@@ -67,7 +68,7 @@ export function saveJsonFile(filename: string, data: any, spaces?: number): void
67
68
  * @param {(res: Response) => ResponseInit} [returnResponse] - The callback function to return the ResponseInit to ReadableStream.
68
69
  * @returns {Response} A new Response object with the tracked stream.
69
70
  */
70
- export function trackFetchProgress(response: Response, onProgress: FetchOnProgressResult, returnResponse?: (res: Response) => ResponseInit): Response;
71
+ export declare function trackFetchProgress(response: Response, onProgress: FetchOnProgressResult, returnResponse?: (res: Response) => ResponseInit): Response;
71
72
  /**
72
73
  * Loads and parses a JSON from a remote URL using Fetch API.
73
74
  *
@@ -77,7 +78,7 @@ export function trackFetchProgress(response: Response, onProgress: FetchOnProgre
77
78
  * @returns {Promise<any[] | Record<string | number | symbol, unknown>>} Parsed JSON object.
78
79
  * @throws {Error} Throws if fetch fails, times out, or returns invalid JSON.
79
80
  */
80
- export function fetchJson(url: string | URL | Request, options?: RequestInit | null, onProgress?: FetchOnProgressResult): Promise<any[] | Record<string | number | symbol, unknown>>;
81
+ export declare function fetchJson(url: string | URL | Request, options?: RequestInit | null, onProgress?: FetchOnProgressResult): Promise<any[] | Record<string | number | symbol, unknown>>;
81
82
  /**
82
83
  * Loads a remote file as a Blob using Fetch API.
83
84
  *
@@ -88,7 +89,7 @@ export function fetchJson(url: string | URL | Request, options?: RequestInit | n
88
89
  * @returns {Promise<Blob>} - The fetched file as a Blob.
89
90
  * @throws {Error} Throws if fetch fails, response is not ok, or MIME type is not allowed.
90
91
  */
91
- export function fetchBlob(url: string | URL | Request, allowedMimeTypes?: string[], options?: RequestInit | null, onProgress?: FetchOnProgressResult): Promise<Blob>;
92
+ export declare function fetchBlob(url: string | URL | Request, allowedMimeTypes?: string[], options?: RequestInit | null, onProgress?: FetchOnProgressResult): Promise<Blob>;
92
93
  /**
93
94
  * Loads a remote file as a text using Fetch API.
94
95
  * @param {string | URL | Request} url - The full URL to fetch the file from.
@@ -98,7 +99,39 @@ export function fetchBlob(url: string | URL | Request, allowedMimeTypes?: string
98
99
  * @returns {Promise<string>} - The fetched file as a text.
99
100
  * @throws {Error} Throws if fetch fails, response is not ok, or MIME type is not allowed.
100
101
  */
101
- export function fetchText(url: string | URL | Request, allowedMimeTypes?: string[], options?: RequestInit | null, onProgress?: FetchOnProgressResult): Promise<string>;
102
+ export declare function fetchText(url: string | URL | Request, allowedMimeTypes?: string[], options?: RequestInit | null, onProgress?: FetchOnProgressResult): Promise<string>;
103
+ export type ImageLoadResult = {
104
+ /**
105
+ * The image element instance used for loading.
106
+ */
107
+ element: HTMLImageElement;
108
+ /**
109
+ * The browser event triggered by the final lifecycle state.
110
+ */
111
+ event: Event;
112
+ /**
113
+ * The specific outcome string of the loading process.
114
+ */
115
+ status: ImageLoadStatus;
116
+ /**
117
+ * Indicates if the image was successfully loaded without errors.
118
+ */
119
+ isSuccess: boolean;
120
+ /**
121
+ * The total duration in milliseconds from start to finish.
122
+ */
123
+ loadTimeMs: number;
124
+ /**
125
+ * An object containing the rendered and intrinsic sizes of the image.
126
+ */
127
+ dimensions: {
128
+ width: number;
129
+ height: number;
130
+ naturalWidth: number;
131
+ naturalHeight: number;
132
+ };
133
+ };
134
+ export type ImageLoadStatus = 'loaded' | 'aborted';
102
135
  /**
103
136
  * Represents the final state and metadata of an attempted image load.
104
137
  * @typedef {Object} ImageLoadResult
@@ -127,10 +160,10 @@ export function fetchText(url: string | URL | Request, allowedMimeTypes?: string
127
160
  * @param {(event: Event, startTime: number) => void} [options.onLoading]
128
161
  * @returns {Promise<ImageLoadResult>}
129
162
  */
130
- export function loadImage(options: {
163
+ export declare function loadImage(options: {
131
164
  url: string;
132
- crossOrigin?: string | undefined;
133
- onLoading?: ((event: Event, startTime: number) => void) | undefined;
165
+ crossOrigin?: string;
166
+ onLoading?: (event: Event, startTime: number) => void;
134
167
  }): Promise<ImageLoadResult>;
135
168
  /**
136
169
  * Installs a script that toggles CSS classes on a given element
@@ -146,61 +179,19 @@ export function loadImage(options: {
146
179
  * @returns {() => void} Function that removes all installed event listeners.
147
180
  * @throws {TypeError} If any provided setting is invalid.
148
181
  */
149
- export function installWindowHiddenScript(settings?: {
150
- element?: Element | undefined;
151
- hiddenClass?: string | undefined;
152
- visibleClass?: string | undefined;
153
- onVisible?: ((data: {
182
+ export declare function installWindowHiddenScript(settings?: {
183
+ element?: Element;
184
+ hiddenClass?: string;
185
+ visibleClass?: string;
186
+ onVisible?: (data: {
154
187
  type: string;
155
188
  oldType: string;
156
189
  oldClass: string;
157
- }) => void) | undefined;
158
- onHidden?: ((data: {
190
+ }) => void;
191
+ onHidden?: (data: {
159
192
  type: string;
160
193
  oldType: string;
161
194
  oldClass: string;
162
- }) => void) | undefined;
195
+ }) => void;
163
196
  }): () => void;
164
- /**
165
- * Callback function used to report the progress of a data download.
166
- */
167
- export type FetchOnProgressResult = (loaded: number, total: number) => void;
168
- /**
169
- * Represents the final state and metadata of an attempted image load.
170
- */
171
- export type ImageLoadResult = {
172
- /**
173
- * The image element instance used for loading.
174
- */
175
- element: HTMLImageElement;
176
- /**
177
- * The browser event triggered by the final lifecycle state.
178
- */
179
- event: Event;
180
- /**
181
- * The specific outcome string of the loading process.
182
- */
183
- status: ImageLoadStatus;
184
- /**
185
- * Indicates if the image was successfully loaded without errors.
186
- */
187
- isSuccess: boolean;
188
- /**
189
- * The total duration in milliseconds from start to finish.
190
- */
191
- loadTimeMs: number;
192
- /**
193
- * An object containing the rendered and intrinsic sizes of the image.
194
- */
195
- dimensions: {
196
- width: number;
197
- height: number;
198
- naturalWidth: number;
199
- naturalHeight: number;
200
- };
201
- };
202
- /**
203
- * Describes the possible resolution states for the image loading attempt.
204
- */
205
- export type ImageLoadStatus = "loaded" | "aborted";
206
197
  //# sourceMappingURL=html.d.mts.map
@@ -1,68 +1,12 @@
1
- import { multiplyArrayBlocks } from './array.mjs';
2
- import { valMediaContentMetadata } from './mediaContent.mjs';
3
- import { valMediaContentMetadataPartial } from './mediaContent.mjs';
4
- import { parseMediaMetadata } from './mediaContent.mjs';
5
- import { extractMediaId3Tags } from './mediaContent.mjs';
6
- import { diffStrings } from './text.mjs';
7
- import { diffObjList } from './text.mjs';
8
- import { diffArrayList } from './array.mjs';
9
- import { breakdownDuration } from './clock.mjs';
10
- import { calculateMarketcap } from './simpleMath.mjs';
11
- import { compareMarketcap } from './simpleMath.mjs';
12
- import { getPercentage } from './simpleMath.mjs';
13
- import { areElsCollTop } from './collision.mjs';
14
- import { areElsCollBottom } from './collision.mjs';
15
- import { areElsCollLeft } from './collision.mjs';
16
- import { areElsCollRight } from './collision.mjs';
17
- import { areElsCollPerfTop } from './collision.mjs';
18
- import { areElsCollPerfBottom } from './collision.mjs';
19
- import { areElsCollPerfLeft } from './collision.mjs';
20
- import { areElsCollPerfRight } from './collision.mjs';
21
- import { areElsColliding } from './collision.mjs';
22
- import { areElsPerfColliding } from './collision.mjs';
23
- import { getElsColliding } from './collision.mjs';
24
- import { getElsPerfColliding } from './collision.mjs';
25
- import { getElsCollOverlap } from './collision.mjs';
26
- import { getElsCollOverlapPos } from './collision.mjs';
27
- import { getRectCenter } from './collision.mjs';
28
- import { getElsRelativeCenterOffset } from './collision.mjs';
29
- import { getElsCollDirDepth } from './collision.mjs';
30
- import { getElsCollDetails } from './collision.mjs';
31
- import { safeTextTrim } from './text.mjs';
32
- import { installWindowHiddenScript } from './html.mjs';
33
- import { genFibonacciSeq } from './simpleMath.mjs';
34
- import { fetchJson } from './html.mjs';
35
- import { fetchText } from './html.mjs';
36
- import { readJsonBlob } from './html.mjs';
37
- import { readFileBlob } from './html.mjs';
38
- import { readBase64Blob } from './html.mjs';
39
- import { saveJsonFile } from './html.mjs';
40
- import { documentIsFullScreen } from './fullScreen.mjs';
41
- import { isScreenFilled } from './fullScreen.mjs';
42
- import { requestFullScreen } from './fullScreen.mjs';
43
- import { exitFullScreen } from './fullScreen.mjs';
44
- import { isFullScreenMode } from './fullScreen.mjs';
45
- import { onFullScreenChange } from './fullScreen.mjs';
46
- import { offFullScreenChange } from './fullScreen.mjs';
47
- import { isJsonObject } from './objChecker.mjs';
48
- import { arraySortPositions } from './array.mjs';
49
- import { formatBytes } from './simpleMath.mjs';
50
- import { addAiMarkerShortcut } from './text.mjs';
51
- import { extendObjType } from './objFilter.mjs';
52
- import { reorderObjTypeOrder } from './objFilter.mjs';
53
- import { cloneObjTypeOrder } from './objFilter.mjs';
54
- import { countObj } from './objChecker.mjs';
55
- import { objType } from './objFilter.mjs';
56
- import { ruleOfThree } from './simpleMath.mjs';
57
- import { getSimplePerc } from './simpleMath.mjs';
58
- import { asyncReplace } from './text.mjs';
59
- import { getAge } from './simpleMath.mjs';
60
- import { formatCustomTimer } from './clock.mjs';
61
- import { formatDayTimer } from './clock.mjs';
62
- import { formatTimer } from './clock.mjs';
63
- import { getTimeDuration } from './clock.mjs';
64
- import { shuffleArray } from './array.mjs';
65
- import { toTitleCase } from './text.mjs';
66
- import { toTitleCaseLowerFirst } from './text.mjs';
67
- export { multiplyArrayBlocks, valMediaContentMetadata, valMediaContentMetadataPartial, parseMediaMetadata, extractMediaId3Tags, diffStrings, diffObjList, diffArrayList, breakdownDuration, calculateMarketcap, compareMarketcap, getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, fetchJson, fetchText, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst };
1
+ import { diffArrayList, shuffleArray, arraySortPositions, multiplyArrayBlocks } from './array.mjs';
2
+ import { breakdownDuration, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration } from './clock.mjs';
3
+ import { readJsonBlob, saveJsonFile, fetchJson, installWindowHiddenScript, readFileBlob, readBase64Blob, fetchText } from './html.mjs';
4
+ import { extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objType } from './objFilter.mjs';
5
+ import { countObj, isJsonObject } from './objChecker.mjs';
6
+ import { documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange } from './fullScreen.mjs';
7
+ import { calculateMarketcap, compareMarketcap, formatBytes, genFibonacciSeq, getAge, getPercentage, getSimplePerc, ruleOfThree } from './simpleMath.mjs';
8
+ import { addAiMarkerShortcut, diffStrings, diffObjList, safeTextTrim, toTitleCase, toTitleCaseLowerFirst, asyncReplace } from './text.mjs';
9
+ import { areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails } from './collision.mjs';
10
+ import { extractMediaId3Tags, parseMediaMetadata, valMediaContentMetadata, valMediaContentMetadataPartial } from './mediaContent.mjs';
11
+ export { multiplyArrayBlocks, valMediaContentMetadata, valMediaContentMetadataPartial, parseMediaMetadata, extractMediaId3Tags, diffStrings, diffObjList, diffArrayList, breakdownDuration, calculateMarketcap, compareMarketcap, getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, fetchJson, fetchText, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
68
12
  //# sourceMappingURL=index.d.mts.map
@@ -1,12 +1,18 @@
1
1
  'use strict';
2
2
 
3
3
  /**
4
+ * A type representing either a static string or a function that returns a string, used to resolve an unknown artist's name.
4
5
  * @typedef {string|(() => string)} UnknownArtistGetter
5
6
  */
6
7
 
8
+ /**
9
+ * Represents the data type for images, which can be raw binary (Uint8Array) or a string (such as a Blob URL or Data URL).
10
+ * @typedef {Uint8Array|string} PictureDataType
11
+ */
12
+
7
13
  /**
8
14
  * Represents an image attachment template.
9
- * @template {Uint8Array|string} PictureData
15
+ * @template {PictureDataType} PictureData
10
16
  * @typedef {Object} IPictureTemplate
11
17
  * @property {string} format - The MIME type of the image (e.g., 'image/jpeg').
12
18
  * @property {PictureData} data - The raw binary data of the image.
@@ -28,7 +34,7 @@
28
34
  /**
29
35
  * This metadata structure is modeled template.
30
36
  *
31
- * @template {IPictureTemplate<Uint8Array|string>} IPictureContent
37
+ * @template {IPictureTemplate<PictureDataType>} IPictureContent
32
38
  * @typedef {Object} ContentMetadataTemplate
33
39
  * @property {string|null} title - The title of the track.
34
40
  * @property {string|null} album - The name of the album.
@@ -49,7 +55,8 @@
49
55
  * This metadata structure is modeled after the standard output of the
50
56
  * `music-metadata@11.13.0` npm package.
51
57
  *
52
- * @typedef {ContentMetadataTemplate<IPicture>} MediaContentMetadata
58
+ * @template {PictureDataType} PictureData
59
+ * @typedef {ContentMetadataTemplate<IPictureTemplate<PictureData>>} MediaContentMetadata
53
60
  */
54
61
 
55
62
  /**
@@ -67,7 +74,8 @@
67
74
  * The final content object used within the media, combining
68
75
  * core playback properties with rich metadata.
69
76
  *
70
- * @typedef {MediaContentBase & MediaContentMetadata} MediaContent
77
+ * @template {PictureDataType} PictureData
78
+ * @typedef {MediaContentBase & MediaContentMetadata<PictureData>} MediaContent
71
79
  */
72
80
 
73
81
  //////////////////////////////////////////////////////////////////
@@ -76,11 +84,11 @@
76
84
  * A promise that resolves to an object containing the extracted metadata.
77
85
  * @callback ParseMediaContentMetadata
78
86
  * @param {Blob} data - The raw file blob.
79
- * @returns {Promise<{ common: Partial<ContentMetadataTemplate<IPictureTemplate<Uint8Array|string>>> }>} A promise resolving to the common metadata properties.
87
+ * @returns {Promise<{ common: Partial<ContentMetadataTemplate<IPictureTemplate<PictureDataType>>> }>} A promise resolving to the common metadata properties.
80
88
  */
81
89
 
82
90
  /**
83
- * @typedef {Object} LoadingMediaProgress
91
+ * @typedef {Object} LoadingMediaProgress Represents the current state of a media loading operation, including its status, execution stage, and the URL being processed.
84
92
  * @property {'loading'|'success'} status - The current status of the operation.
85
93
  * @property {LoadingProgressStage} stage - The current execution stage.
86
94
  * @property {ProgressEvent<EventTarget>} [event] - The current loading event.
@@ -88,14 +96,17 @@
88
96
  */
89
97
 
90
98
  /**
99
+ * Defines the specific execution stages of a successful loading process.
91
100
  * @typedef {'INITIALIZING'|'DOWNLOADING'|'METADATA_LOADED'|'EXTRACTING_ID3'|'COMPLETE'} LoadingProgressStage
92
101
  */
93
102
 
94
103
  /**
104
+ * Defines the specific stages where a loading error might occur.
95
105
  * @typedef {'INITIALIZING'|'DOWNLOADING'|'METADATA'|'ID3'|'UNKNOWN'} LoadingErrorStage
96
106
  */
97
107
 
98
108
  /**
109
+ * A data structure containing details about a media loading error.
99
110
  * @typedef {Object} MediaLoadingErrorData
100
111
  * @property {Error} error - The original error object.
101
112
  * @property {string} url - The URL that failed.
@@ -105,14 +116,19 @@
105
116
  //////////////////////////////////////////////////////////////////
106
117
 
107
118
  const checkString = (/** @type {string} */ val, /** @type {string} */ name) => {
119
+ if (typeof name !== 'string') throw new TypeError('Expected "name" to be a string.');
108
120
  if (typeof val !== 'string')
109
121
  throw new TypeError(`Expected "${name}" to be a string, but received ${typeof val}.`);
110
122
  };
123
+
111
124
  const checkFunction = (/** @type {Function} */ val, /** @type {string} */ name) => {
125
+ if (typeof name !== 'string') throw new TypeError('Expected "name" to be a string.');
112
126
  if (typeof val !== 'function')
113
127
  throw new TypeError(`Expected "${name}" to be a function, but received ${typeof val}.`);
114
128
  };
129
+
115
130
  const checkObject = (/** @type {Object<string, any> | null} */ val, /** @type {string} */ name) => {
131
+ if (typeof name !== 'string') throw new TypeError('Expected "name" to be a string.');
116
132
  if (typeof val !== 'object' || val === null || Array.isArray(val)) {
117
133
  throw new TypeError(
118
134
  `Expected "${name}" to be a plain object, but received ${val === null ? 'null' : Array.isArray(val) ? 'array' : typeof val}.`,
@@ -123,7 +139,10 @@ const checkObject = (/** @type {Object<string, any> | null} */ val, /** @type {s
123
139
  /** @type {Map<string, number>} */
124
140
  const _blobCounter = new Map();
125
141
 
126
- /** @returns {MediaContentBase} */
142
+ /**
143
+ * Returns a new object initialized with the default values for the core media content properties.
144
+ * @returns {MediaContentBase}
145
+ */
127
146
  const getMediaContentBase = () => ({
128
147
  id: '',
129
148
  title: '',
@@ -133,7 +152,10 @@ const getMediaContentBase = () => ({
133
152
  weight: 1,
134
153
  });
135
154
 
136
- /** @returns {MediaContentMetadata} */
155
+ /**
156
+ * Returns a new object initialized with the default values for the media content metadata properties.
157
+ * @returns {MediaContentMetadata<PictureDataType>}
158
+ */
137
159
  const getMediaContentMetadata = () => ({
138
160
  title: null,
139
161
  album: null,
@@ -194,7 +216,7 @@ const generateSimpleHash = async (str) => {
194
216
 
195
217
  /**
196
218
  * Helper to convert Uint8Array or Base64 string directly into a high performance Blob URL.
197
- * @param {Uint8Array|string} data
219
+ * @param {PictureDataType} data
198
220
  * @param {string} format
199
221
  * @returns {string} The generated Blob URL or original string if already valid.
200
222
  */
@@ -256,7 +278,8 @@ const blobUrlToBase64 = async (url) => {
256
278
 
257
279
  /**
258
280
  * Safely revokes Blob URLs to prevent memory leaks from createObjectURL.
259
- * @param {MediaContent} content
281
+ * @template {PictureDataType} PictureData
282
+ * @param {MediaContent<PictureData>} content
260
283
  */
261
284
  const revokeContentUrls = (content) => {
262
285
  checkObject(content, 'content');
@@ -294,6 +317,7 @@ const validateMediaContent = (common, isPartial) => {
294
317
  /** @type {string[] | IPictureTemplate<string|Uint8Array>[] | undefined} */ v,
295
318
  /** @type {(value: any, index: number, array: any[]) => any} */ valueValidator,
296
319
  ) => {
320
+ checkFunction(valueValidator, 'valueValidator');
297
321
  if (isUndefinedAllowed(v)) return true;
298
322
  if (Array.isArray(v) && v.every(valueValidator)) return true;
299
323
  return false;
@@ -339,10 +363,11 @@ const validateMediaContent = (common, isPartial) => {
339
363
 
340
364
  /**
341
365
  * Validate Nested Objects (Disk and Track)
366
+ * @param {string} name
342
367
  * @param {MediaNumber|null} [info]
343
- * @param {string} [name]
344
368
  */
345
- const validateTrackInfo = (info, name) => {
369
+ const validateTrackInfo = (name, info) => {
370
+ checkString(name, 'name');
346
371
  if (isUndefinedAllowed(info)) return; // Ignores if partial
347
372
 
348
373
  if (info === undefined || info === null) {
@@ -357,8 +382,8 @@ const validateMediaContent = (common, isPartial) => {
357
382
  throw new TypeError(`Invalid metadata: "${name}.of" must be a number or null.`);
358
383
  };
359
384
 
360
- validateTrackInfo(common.disk, 'disk');
361
- validateTrackInfo(common.track, 'track');
385
+ validateTrackInfo('disk', common.disk);
386
+ validateTrackInfo('track', common.track);
362
387
  };
363
388
 
364
389
  /**
@@ -366,21 +391,27 @@ const validateMediaContent = (common, isPartial) => {
366
391
  * This ensures that if a property is present, it matches the expected type.
367
392
  * @param {ContentMetadataTemplate<IPictureTemplate<string | Uint8Array<ArrayBufferLike>>>} common
368
393
  */
369
- const valMediaContentMetadata = (common) => validateMediaContent(common, false);
394
+ const valMediaContentMetadata = (common) => {
395
+ checkObject(common, 'common');
396
+ return validateMediaContent(common, false);
397
+ };
370
398
 
371
399
  /**
372
400
  * Helper to validate types within the media content metadata object.
373
401
  * Allows the absence of properties (useful for updates/patch).
374
402
  * @param {Partial<ContentMetadataTemplate<IPictureTemplate<string | Uint8Array<ArrayBufferLike>>>>} common
375
403
  */
376
- const valMediaContentMetadataPartial = (common) => validateMediaContent(common, true);
404
+ const valMediaContentMetadataPartial = (common) => {
405
+ checkObject(common, 'common');
406
+ return validateMediaContent(common, true);
407
+ };
377
408
 
378
409
  /**
379
410
  * Downloads an audio file from a URL and extracts its ID3/metadata tags.
380
411
  *
381
412
  * @param {string} url - The full URL of the audio file to be downloaded.
382
413
  * @param {ParseMediaContentMetadata} parseFile - The function used to parse the file data.
383
- * @returns {Promise<MediaContentMetadata>} A promise that resolves to an object containing the extracted metadata.
414
+ * @returns {Promise<MediaContentMetadata<string>>} A promise that resolves to an object containing the extracted metadata.
384
415
  * @throws {TypeError} If the provided `url` is not a string or `parseFile` is not a function.
385
416
  * @throws {Error} If the network request fails or the parsing process encounters an error.
386
417
  */
@@ -440,15 +471,16 @@ const extractMediaId3Tags = async (url, parseFile) => {
440
471
  * A Static Factory Method that prepares a MediaContent object by
441
472
  * extracting metadata from an audio source.
442
473
  *
474
+ * @template {PictureDataType} PictureData
443
475
  * @param {string | HTMLMediaElement} source - A URL string or an existing Audio object.
444
- * @param {Partial<MediaContentBase & MediaContentMetadata> & { id?: string; weight?: number }} [defaultMetadata={}] - Optional default metadata that overrides automatic extraction.
445
- * @param {Partial<MediaContentBase & MediaContentMetadata> & { id?: string; weight?: number }} [metadata={}] - Optional manual metadata that overrides automatic extraction.
476
+ * @param {Partial<MediaContentBase & MediaContentMetadata<PictureData>> & { id?: string; weight?: number }} [defaultMetadata={}] - Optional default metadata that overrides automatic extraction.
477
+ * @param {Partial<MediaContentBase & MediaContentMetadata<PictureData>> & { id?: string; weight?: number }} [metadata={}] - Optional manual metadata that overrides automatic extraction.
446
478
  * @param {ParseMediaContentMetadata} [parseFile] - Private helper to interface with parseFile.
447
479
  * @param {Object} [callbacks={}] - Callbacks for monitoring the loading process.
448
480
  * @param {(progress: LoadingMediaProgress) => void} [callbacks.onProgress] - Callback triggered on stage changes.
449
481
  * @param {(error: MediaLoadingErrorData) => void} [callbacks.onError] - Callback triggered when a non-fatal or fatal error occurs.
450
482
  * @param {UnknownArtistGetter} unknownArtist
451
- * @returns {Promise<MediaContent>} A promise that resolves to a valid MediaContent object.
483
+ * @returns {Promise<MediaContent<PictureData>>} A promise that resolves to a valid MediaContent object.
452
484
  * @throws {MediaLoadingError} If the preparation process fails at any stage.
453
485
  *
454
486
  * @example
@@ -482,7 +514,8 @@ const parseMediaMetadata = async (
482
514
  source,
483
515
  defaultMetadata = {},
484
516
  metadata = {},
485
- parseFile = (url) => {
517
+ parseFile = (data) => {
518
+ if (!(data instanceof Blob)) throw new TypeError('Expected "data" to be a Blob.');
486
519
  return new Promise((resolve, reject) => reject(new TypeError('parseFile library not found.')));
487
520
  },
488
521
  callbacks = {},
@@ -516,6 +549,11 @@ const parseMediaMetadata = async (
516
549
  * @param {ProgressEvent<EventTarget>} [event]
517
550
  */
518
551
  const notifyProgress = (stage, event) => {
552
+ checkString(stage, 'stage');
553
+ if (event !== undefined && !(event instanceof Event)) {
554
+ throw new TypeError('Expected "event" to be an Event or undefined.');
555
+ }
556
+
519
557
  if (callbacks.onProgress) {
520
558
  callbacks.onProgress({
521
559
  event,
@@ -527,6 +565,9 @@ const parseMediaMetadata = async (
527
565
  };
528
566
 
529
567
  const notifyError = (/** @type {Error} */ error, /** @type {LoadingErrorStage} */ stage) => {
568
+ if (!(error instanceof Error)) throw new TypeError('Expected "error" to be an Error.');
569
+ checkString(stage, 'stage'); // Adicionado
570
+
530
571
  if (callbacks.onError) {
531
572
  callbacks.onError({
532
573
  error,
@@ -603,7 +644,7 @@ const parseMediaMetadata = async (
603
644
  };
604
645
 
605
646
  // 4. Automatic Metadata Extraction (ID3 Tags)
606
- /** @type {Partial<MediaContentMetadata>} */
647
+ /** @type {Partial<MediaContentMetadata<string>>} */
607
648
  let extractedMetadata = {};
608
649
  notifyProgress('EXTRACTING_ID3');
609
650
  try {
@@ -621,6 +662,7 @@ const parseMediaMetadata = async (
621
662
  * @returns {string}
622
663
  */
623
664
  const getFallbackTitleFromUrl = (url) => {
665
+ checkString(url, 'url');
624
666
  try {
625
667
  // Remove query params or hashes, get the last segment, and strip extension
626
668
  const filename = url.split(/[?#]/)[0].split('/').pop();
@@ -654,7 +696,7 @@ const parseMediaMetadata = async (
654
696
  });
655
697
  }
656
698
 
657
- return /** @type {MediaContent} */ (finalContent);
699
+ return /** @type {MediaContent<PictureData>} */ (finalContent);
658
700
  } catch (err) {
659
701
  // If it's already a MediaLoadingError, re-throw it.
660
702
  // Otherwise, wrap it.