@herowcode/utils 1.3.5 → 1.4.8

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 (456) hide show
  1. package/dist/api/index.cjs +12 -0
  2. package/dist/api/index.cjs.map +1 -0
  3. package/dist/api/{client.d.ts → index.d.mts} +19 -8
  4. package/dist/api/index.d.ts +36 -3
  5. package/dist/api/index.js +3 -0
  6. package/dist/api/index.js.map +1 -0
  7. package/dist/array/index.cjs +16 -0
  8. package/dist/array/index.cjs.map +1 -0
  9. package/dist/array/index.d.mts +5 -0
  10. package/dist/array/index.d.ts +5 -3
  11. package/dist/array/index.js +3 -0
  12. package/dist/array/index.js.map +1 -0
  13. package/dist/chunk-2MANLCNG.cjs +23 -0
  14. package/dist/chunk-2MANLCNG.cjs.map +1 -0
  15. package/dist/chunk-2RTW37WD.js +20 -0
  16. package/dist/chunk-2RTW37WD.js.map +1 -0
  17. package/dist/chunk-2Y6M7IOG.js +250 -0
  18. package/dist/chunk-2Y6M7IOG.js.map +1 -0
  19. package/dist/chunk-3JUB2OJL.js +3 -0
  20. package/dist/chunk-3JUB2OJL.js.map +1 -0
  21. package/dist/chunk-53JMVGIG.js +187 -0
  22. package/dist/chunk-53JMVGIG.js.map +1 -0
  23. package/dist/chunk-56NHIM5J.js +151 -0
  24. package/dist/chunk-56NHIM5J.js.map +1 -0
  25. package/dist/chunk-5OLQJUNS.js +66 -0
  26. package/dist/chunk-5OLQJUNS.js.map +1 -0
  27. package/dist/chunk-5YOEKMTJ.cjs +321 -0
  28. package/dist/chunk-5YOEKMTJ.cjs.map +1 -0
  29. package/dist/chunk-6TWPZ6LL.cjs +4 -0
  30. package/dist/chunk-6TWPZ6LL.cjs.map +1 -0
  31. package/dist/chunk-AQZBHMTO.js +96 -0
  32. package/dist/chunk-AQZBHMTO.js.map +1 -0
  33. package/dist/chunk-ATWN4SRX.js +29 -0
  34. package/dist/chunk-ATWN4SRX.js.map +1 -0
  35. package/dist/chunk-GRSF4RY2.cjs +20 -0
  36. package/dist/chunk-GRSF4RY2.cjs.map +1 -0
  37. package/dist/chunk-GX5E5B4L.cjs +70 -0
  38. package/dist/chunk-GX5E5B4L.cjs.map +1 -0
  39. package/dist/chunk-HK727IAV.cjs +201 -0
  40. package/dist/chunk-HK727IAV.cjs.map +1 -0
  41. package/dist/chunk-LJ6KOZD4.cjs +154 -0
  42. package/dist/chunk-LJ6KOZD4.cjs.map +1 -0
  43. package/dist/chunk-N2DRAZ3A.cjs +29 -0
  44. package/dist/chunk-N2DRAZ3A.cjs.map +1 -0
  45. package/dist/chunk-O7SH3E3T.js +18 -0
  46. package/dist/chunk-O7SH3E3T.js.map +1 -0
  47. package/dist/chunk-P5YNRND6.cjs +4 -0
  48. package/dist/chunk-P5YNRND6.cjs.map +1 -0
  49. package/dist/chunk-QAE6Q2SA.js +317 -0
  50. package/dist/chunk-QAE6Q2SA.js.map +1 -0
  51. package/dist/chunk-QRXVUXGJ.js +378 -0
  52. package/dist/chunk-QRXVUXGJ.js.map +1 -0
  53. package/dist/chunk-SLYUARZG.cjs +99 -0
  54. package/dist/chunk-SLYUARZG.cjs.map +1 -0
  55. package/dist/chunk-SWRIT7EE.js +3 -0
  56. package/dist/chunk-SWRIT7EE.js.map +1 -0
  57. package/dist/chunk-UXEUYHBD.cjs +401 -0
  58. package/dist/chunk-UXEUYHBD.cjs.map +1 -0
  59. package/dist/chunk-V6OKXUBQ.js +22 -0
  60. package/dist/chunk-V6OKXUBQ.js.map +1 -0
  61. package/dist/chunk-VAZJXZU5.cjs +31 -0
  62. package/dist/chunk-VAZJXZU5.cjs.map +1 -0
  63. package/dist/chunk-WGSFRFRO.cjs +252 -0
  64. package/dist/chunk-WGSFRFRO.cjs.map +1 -0
  65. package/dist/date/index.cjs +56 -0
  66. package/dist/date/index.cjs.map +1 -0
  67. package/dist/date/index.d.mts +63 -0
  68. package/dist/date/index.d.ts +63 -8
  69. package/dist/date/index.js +3 -0
  70. package/dist/date/index.js.map +1 -0
  71. package/dist/extract-youtube-video-id-HSYMYXIZ.js +3 -0
  72. package/dist/extract-youtube-video-id-HSYMYXIZ.js.map +1 -0
  73. package/dist/extract-youtube-video-id-XVGNPUDX.cjs +12 -0
  74. package/dist/extract-youtube-video-id-XVGNPUDX.cjs.map +1 -0
  75. package/dist/files/index.browser.cjs +21 -0
  76. package/dist/files/index.browser.cjs.map +1 -0
  77. package/dist/files/index.browser.d.mts +14 -0
  78. package/dist/files/index.browser.d.ts +14 -0
  79. package/dist/files/index.browser.js +4 -0
  80. package/dist/files/index.browser.js.map +1 -0
  81. package/dist/files/index.cjs +31 -0
  82. package/dist/files/index.cjs.map +1 -0
  83. package/dist/files/index.d.mts +3 -0
  84. package/dist/files/index.d.ts +3 -6
  85. package/dist/files/index.js +6 -0
  86. package/dist/files/index.js.map +1 -0
  87. package/dist/files/index.node.cjs +21 -0
  88. package/dist/files/index.node.cjs.map +1 -0
  89. package/dist/files/index.node.d.mts +7 -0
  90. package/dist/files/index.node.d.ts +7 -0
  91. package/dist/files/index.node.js +4 -0
  92. package/dist/files/index.node.js.map +1 -0
  93. package/dist/format-bytes-BGjeDnvM.d.mts +3 -0
  94. package/dist/format-bytes-BGjeDnvM.d.ts +3 -0
  95. package/dist/function/index.cjs +20 -0
  96. package/dist/function/index.cjs.map +1 -0
  97. package/dist/function/index.d.mts +22 -0
  98. package/dist/function/index.d.ts +22 -4
  99. package/dist/function/index.js +3 -0
  100. package/dist/function/index.js.map +1 -0
  101. package/dist/index.cjs +188 -0
  102. package/dist/index.cjs.map +1 -0
  103. package/dist/index.d.mts +12 -0
  104. package/dist/index.d.ts +12 -8
  105. package/dist/index.js +15 -0
  106. package/dist/index.js.map +1 -0
  107. package/dist/string/index.cjs +60 -0
  108. package/dist/string/index.cjs.map +1 -0
  109. package/dist/string/index.d.mts +28 -0
  110. package/dist/string/index.d.ts +28 -14
  111. package/dist/string/index.js +3 -0
  112. package/dist/string/index.js.map +1 -0
  113. package/dist/{cjs/function/try-catch.d.ts → try-catch-B7WzqcPU.d.mts} +4 -4
  114. package/dist/{function/try-catch.d.ts → try-catch-B7WzqcPU.d.ts} +4 -4
  115. package/dist/youtube/index.browser.cjs +35 -0
  116. package/dist/youtube/index.browser.cjs.map +1 -0
  117. package/dist/youtube/index.browser.d.mts +2 -0
  118. package/dist/youtube/index.browser.d.ts +2 -0
  119. package/dist/youtube/index.browser.js +6 -0
  120. package/dist/youtube/index.browser.js.map +1 -0
  121. package/dist/youtube/index.cjs +36 -0
  122. package/dist/youtube/index.cjs.map +1 -0
  123. package/dist/youtube/index.d.mts +12 -0
  124. package/dist/youtube/index.d.ts +12 -7
  125. package/dist/youtube/index.js +7 -0
  126. package/dist/youtube/index.js.map +1 -0
  127. package/dist/youtube/index.node.cjs +26 -0
  128. package/dist/youtube/index.node.cjs.map +1 -0
  129. package/dist/youtube/index.node.d.mts +49 -0
  130. package/dist/youtube/index.node.d.ts +49 -0
  131. package/dist/youtube/index.node.js +5 -0
  132. package/dist/youtube/index.node.js.map +1 -0
  133. package/package.json +134 -47
  134. package/dist/api/client.d.ts.map +0 -1
  135. package/dist/api/index.d.ts.map +0 -1
  136. package/dist/api/wrapper.d.ts +0 -27
  137. package/dist/api/wrapper.d.ts.map +0 -1
  138. package/dist/array/index.d.ts.map +0 -1
  139. package/dist/array/shuffle.d.ts +0 -2
  140. package/dist/array/shuffle.d.ts.map +0 -1
  141. package/dist/array/unique.d.ts +0 -2
  142. package/dist/array/unique.d.ts.map +0 -1
  143. package/dist/cjs/api/client.d.ts +0 -25
  144. package/dist/cjs/api/client.d.ts.map +0 -1
  145. package/dist/cjs/api/client.js +0 -148
  146. package/dist/cjs/api/client.js.map +0 -1
  147. package/dist/cjs/api/index.d.ts +0 -3
  148. package/dist/cjs/api/index.d.ts.map +0 -1
  149. package/dist/cjs/api/index.js +0 -6
  150. package/dist/cjs/api/index.js.map +0 -1
  151. package/dist/cjs/api/wrapper.d.ts +0 -27
  152. package/dist/cjs/api/wrapper.d.ts.map +0 -1
  153. package/dist/cjs/api/wrapper.js +0 -152
  154. package/dist/cjs/api/wrapper.js.map +0 -1
  155. package/dist/cjs/array/index.d.ts +0 -3
  156. package/dist/cjs/array/index.d.ts.map +0 -1
  157. package/dist/cjs/array/index.js +0 -19
  158. package/dist/cjs/array/index.js.map +0 -1
  159. package/dist/cjs/array/shuffle.d.ts +0 -2
  160. package/dist/cjs/array/shuffle.d.ts.map +0 -1
  161. package/dist/cjs/array/shuffle.js +0 -16
  162. package/dist/cjs/array/shuffle.js.map +0 -1
  163. package/dist/cjs/array/unique.d.ts +0 -2
  164. package/dist/cjs/array/unique.d.ts.map +0 -1
  165. package/dist/cjs/array/unique.js +0 -7
  166. package/dist/cjs/array/unique.js.map +0 -1
  167. package/dist/cjs/array.js +0 -1
  168. package/dist/cjs/date/dayjs.d.ts +0 -20
  169. package/dist/cjs/date/dayjs.d.ts.map +0 -1
  170. package/dist/cjs/date/dayjs.js +0 -123
  171. package/dist/cjs/date/dayjs.js.map +0 -1
  172. package/dist/cjs/date/fix-timezone-offset.d.ts +0 -3
  173. package/dist/cjs/date/fix-timezone-offset.d.ts.map +0 -1
  174. package/dist/cjs/date/fix-timezone-offset.js +0 -9
  175. package/dist/cjs/date/fix-timezone-offset.js.map +0 -1
  176. package/dist/cjs/date/format-date.d.ts +0 -23
  177. package/dist/cjs/date/format-date.d.ts.map +0 -1
  178. package/dist/cjs/date/format-date.js +0 -71
  179. package/dist/cjs/date/format-date.js.map +0 -1
  180. package/dist/cjs/date/get-current-date-in-utc.d.ts +0 -3
  181. package/dist/cjs/date/get-current-date-in-utc.d.ts.map +0 -1
  182. package/dist/cjs/date/get-current-date-in-utc.js +0 -8
  183. package/dist/cjs/date/get-current-date-in-utc.js.map +0 -1
  184. package/dist/cjs/date/get-date-in-utc.d.ts +0 -3
  185. package/dist/cjs/date/get-date-in-utc.d.ts.map +0 -1
  186. package/dist/cjs/date/get-date-in-utc.js +0 -8
  187. package/dist/cjs/date/get-date-in-utc.js.map +0 -1
  188. package/dist/cjs/date/get-relative-time.d.ts +0 -3
  189. package/dist/cjs/date/get-relative-time.d.ts.map +0 -1
  190. package/dist/cjs/date/get-relative-time.js +0 -8
  191. package/dist/cjs/date/get-relative-time.js.map +0 -1
  192. package/dist/cjs/date/index.d.ts +0 -8
  193. package/dist/cjs/date/index.d.ts.map +0 -1
  194. package/dist/cjs/date/index.js +0 -24
  195. package/dist/cjs/date/index.js.map +0 -1
  196. package/dist/cjs/date/parse-time-spent.d.ts +0 -15
  197. package/dist/cjs/date/parse-time-spent.d.ts.map +0 -1
  198. package/dist/cjs/date/parse-time-spent.js +0 -207
  199. package/dist/cjs/date/parse-time-spent.js.map +0 -1
  200. package/dist/cjs/date.js +0 -1
  201. package/dist/cjs/files/compress-image.d.ts +0 -10
  202. package/dist/cjs/files/compress-image.d.ts.map +0 -1
  203. package/dist/cjs/files/compress-image.js +0 -61
  204. package/dist/cjs/files/compress-image.js.map +0 -1
  205. package/dist/cjs/files/download-url.d.ts +0 -2
  206. package/dist/cjs/files/download-url.d.ts.map +0 -1
  207. package/dist/cjs/files/download-url.js +0 -29
  208. package/dist/cjs/files/download-url.js.map +0 -1
  209. package/dist/cjs/files/file-delete.d.ts +0 -2
  210. package/dist/cjs/files/file-delete.d.ts.map +0 -1
  211. package/dist/cjs/files/file-delete.js +0 -20
  212. package/dist/cjs/files/file-delete.js.map +0 -1
  213. package/dist/cjs/files/file-exists.d.ts +0 -2
  214. package/dist/cjs/files/file-exists.d.ts.map +0 -1
  215. package/dist/cjs/files/file-exists.js +0 -18
  216. package/dist/cjs/files/file-exists.js.map +0 -1
  217. package/dist/cjs/files/format-bytes.d.ts +0 -2
  218. package/dist/cjs/files/format-bytes.d.ts.map +0 -1
  219. package/dist/cjs/files/format-bytes.js +0 -17
  220. package/dist/cjs/files/format-bytes.js.map +0 -1
  221. package/dist/cjs/files/index.d.ts +0 -6
  222. package/dist/cjs/files/index.d.ts.map +0 -1
  223. package/dist/cjs/files/index.js +0 -22
  224. package/dist/cjs/files/index.js.map +0 -1
  225. package/dist/cjs/files.js +0 -1
  226. package/dist/cjs/function/debounce.d.ts +0 -11
  227. package/dist/cjs/function/debounce.d.ts.map +0 -1
  228. package/dist/cjs/function/debounce.js +0 -26
  229. package/dist/cjs/function/debounce.js.map +0 -1
  230. package/dist/cjs/function/index.d.ts +0 -4
  231. package/dist/cjs/function/index.d.ts.map +0 -1
  232. package/dist/cjs/function/index.js +0 -20
  233. package/dist/cjs/function/index.js.map +0 -1
  234. package/dist/cjs/function/throttle.d.ts +0 -10
  235. package/dist/cjs/function/throttle.d.ts.map +0 -1
  236. package/dist/cjs/function/throttle.js +0 -36
  237. package/dist/cjs/function/throttle.js.map +0 -1
  238. package/dist/cjs/function/try-catch.d.ts.map +0 -1
  239. package/dist/cjs/function/try-catch.js +0 -39
  240. package/dist/cjs/function/try-catch.js.map +0 -1
  241. package/dist/cjs/function.js +0 -1
  242. package/dist/cjs/index.d.ts +0 -8
  243. package/dist/cjs/index.d.ts.map +0 -1
  244. package/dist/cjs/index.js +0 -24
  245. package/dist/cjs/index.js.map +0 -1
  246. package/dist/cjs/string/camel-case.d.ts +0 -2
  247. package/dist/cjs/string/camel-case.d.ts.map +0 -1
  248. package/dist/cjs/string/camel-case.js +0 -25
  249. package/dist/cjs/string/camel-case.js.map +0 -1
  250. package/dist/cjs/string/capitalize.d.ts +0 -2
  251. package/dist/cjs/string/capitalize.d.ts.map +0 -1
  252. package/dist/cjs/string/capitalize.js +0 -13
  253. package/dist/cjs/string/capitalize.js.map +0 -1
  254. package/dist/cjs/string/format-hms-to-seconds.d.ts +0 -2
  255. package/dist/cjs/string/format-hms-to-seconds.d.ts.map +0 -1
  256. package/dist/cjs/string/format-hms-to-seconds.js +0 -30
  257. package/dist/cjs/string/format-hms-to-seconds.js.map +0 -1
  258. package/dist/cjs/string/format-seconds-to-fragment.d.ts +0 -3
  259. package/dist/cjs/string/format-seconds-to-fragment.d.ts.map +0 -1
  260. package/dist/cjs/string/format-seconds-to-fragment.js +0 -20
  261. package/dist/cjs/string/format-seconds-to-fragment.js.map +0 -1
  262. package/dist/cjs/string/format-seconds-to-hms.d.ts +0 -2
  263. package/dist/cjs/string/format-seconds-to-hms.d.ts.map +0 -1
  264. package/dist/cjs/string/format-seconds-to-hms.js +0 -17
  265. package/dist/cjs/string/format-seconds-to-hms.js.map +0 -1
  266. package/dist/cjs/string/format-string-to-time.d.ts +0 -2
  267. package/dist/cjs/string/format-string-to-time.d.ts.map +0 -1
  268. package/dist/cjs/string/format-string-to-time.js +0 -15
  269. package/dist/cjs/string/format-string-to-time.js.map +0 -1
  270. package/dist/cjs/string/index.d.ts +0 -14
  271. package/dist/cjs/string/index.d.ts.map +0 -1
  272. package/dist/cjs/string/index.js +0 -30
  273. package/dist/cjs/string/index.js.map +0 -1
  274. package/dist/cjs/string/kebab-case.d.ts +0 -2
  275. package/dist/cjs/string/kebab-case.d.ts.map +0 -1
  276. package/dist/cjs/string/kebab-case.js +0 -15
  277. package/dist/cjs/string/kebab-case.js.map +0 -1
  278. package/dist/cjs/string/markdown-to-text.d.ts +0 -2
  279. package/dist/cjs/string/markdown-to-text.d.ts.map +0 -1
  280. package/dist/cjs/string/markdown-to-text.js +0 -70
  281. package/dist/cjs/string/markdown-to-text.js.map +0 -1
  282. package/dist/cjs/string/remove-html-tags.d.ts +0 -2
  283. package/dist/cjs/string/remove-html-tags.d.ts.map +0 -1
  284. package/dist/cjs/string/remove-html-tags.js +0 -18
  285. package/dist/cjs/string/remove-html-tags.js.map +0 -1
  286. package/dist/cjs/string/slugify.d.ts +0 -2
  287. package/dist/cjs/string/slugify.d.ts.map +0 -1
  288. package/dist/cjs/string/slugify.js +0 -13
  289. package/dist/cjs/string/slugify.js.map +0 -1
  290. package/dist/cjs/string/snake-case.d.ts +0 -2
  291. package/dist/cjs/string/snake-case.d.ts.map +0 -1
  292. package/dist/cjs/string/snake-case.js +0 -15
  293. package/dist/cjs/string/snake-case.js.map +0 -1
  294. package/dist/cjs/string/to-sentence-case.d.ts +0 -2
  295. package/dist/cjs/string/to-sentence-case.d.ts.map +0 -1
  296. package/dist/cjs/string/to-sentence-case.js +0 -13
  297. package/dist/cjs/string/to-sentence-case.js.map +0 -1
  298. package/dist/cjs/string/truncate.d.ts +0 -2
  299. package/dist/cjs/string/truncate.d.ts.map +0 -1
  300. package/dist/cjs/string/truncate.js +0 -19
  301. package/dist/cjs/string/truncate.js.map +0 -1
  302. package/dist/cjs/string.js +0 -1
  303. package/dist/cjs/youtube/extract-youtube-video-id.d.ts +0 -2
  304. package/dist/cjs/youtube/extract-youtube-video-id.d.ts.map +0 -1
  305. package/dist/cjs/youtube/extract-youtube-video-id.js +0 -30
  306. package/dist/cjs/youtube/extract-youtube-video-id.js.map +0 -1
  307. package/dist/cjs/youtube/generate-youtube-url.d.ts +0 -20
  308. package/dist/cjs/youtube/generate-youtube-url.d.ts.map +0 -1
  309. package/dist/cjs/youtube/generate-youtube-url.js +0 -86
  310. package/dist/cjs/youtube/generate-youtube-url.js.map +0 -1
  311. package/dist/cjs/youtube/get-video-duration.d.ts +0 -7
  312. package/dist/cjs/youtube/get-video-duration.d.ts.map +0 -1
  313. package/dist/cjs/youtube/get-video-duration.js +0 -150
  314. package/dist/cjs/youtube/get-video-duration.js.map +0 -1
  315. package/dist/cjs/youtube/get-youtube-thumbnail.d.ts +0 -2
  316. package/dist/cjs/youtube/get-youtube-thumbnail.d.ts.map +0 -1
  317. package/dist/cjs/youtube/get-youtube-thumbnail.js +0 -68
  318. package/dist/cjs/youtube/get-youtube-thumbnail.js.map +0 -1
  319. package/dist/cjs/youtube/get-youtube-video-info.d.ts +0 -26
  320. package/dist/cjs/youtube/get-youtube-video-info.d.ts.map +0 -1
  321. package/dist/cjs/youtube/get-youtube-video-info.js +0 -244
  322. package/dist/cjs/youtube/get-youtube-video-info.js.map +0 -1
  323. package/dist/cjs/youtube/index.d.ts +0 -7
  324. package/dist/cjs/youtube/index.d.ts.map +0 -1
  325. package/dist/cjs/youtube/index.js +0 -23
  326. package/dist/cjs/youtube/index.js.map +0 -1
  327. package/dist/cjs/youtube/validate-youtube-link.d.ts +0 -2
  328. package/dist/cjs/youtube/validate-youtube-link.d.ts.map +0 -1
  329. package/dist/cjs/youtube/validate-youtube-link.js +0 -77
  330. package/dist/cjs/youtube/validate-youtube-link.js.map +0 -1
  331. package/dist/cjs/youtube.js +0 -1
  332. package/dist/date/dayjs.d.ts +0 -20
  333. package/dist/date/dayjs.d.ts.map +0 -1
  334. package/dist/date/fix-timezone-offset.d.ts +0 -3
  335. package/dist/date/fix-timezone-offset.d.ts.map +0 -1
  336. package/dist/date/format-date.d.ts +0 -23
  337. package/dist/date/format-date.d.ts.map +0 -1
  338. package/dist/date/get-current-date-in-utc.d.ts +0 -3
  339. package/dist/date/get-current-date-in-utc.d.ts.map +0 -1
  340. package/dist/date/get-date-in-utc.d.ts +0 -3
  341. package/dist/date/get-date-in-utc.d.ts.map +0 -1
  342. package/dist/date/get-relative-time.d.ts +0 -3
  343. package/dist/date/get-relative-time.d.ts.map +0 -1
  344. package/dist/date/index.d.ts.map +0 -1
  345. package/dist/date/parse-time-spent.d.ts +0 -15
  346. package/dist/date/parse-time-spent.d.ts.map +0 -1
  347. package/dist/esm/api/client.js +0 -143
  348. package/dist/esm/api/index.js +0 -1
  349. package/dist/esm/api/wrapper.js +0 -148
  350. package/dist/esm/array/index.js +0 -2
  351. package/dist/esm/array/shuffle.js +0 -12
  352. package/dist/esm/array/unique.js +0 -3
  353. package/dist/esm/array.js +0 -1
  354. package/dist/esm/date/dayjs.js +0 -111
  355. package/dist/esm/date/fix-timezone-offset.js +0 -5
  356. package/dist/esm/date/format-date.js +0 -67
  357. package/dist/esm/date/get-current-date-in-utc.js +0 -4
  358. package/dist/esm/date/get-date-in-utc.js +0 -4
  359. package/dist/esm/date/get-relative-time.js +0 -4
  360. package/dist/esm/date/index.js +0 -7
  361. package/dist/esm/date/parse-time-spent.js +0 -203
  362. package/dist/esm/date.js +0 -1
  363. package/dist/esm/files/compress-image.js +0 -57
  364. package/dist/esm/files/download-url.js +0 -24
  365. package/dist/esm/files/file-delete.js +0 -12
  366. package/dist/esm/files/file-exists.js +0 -10
  367. package/dist/esm/files/format-bytes.js +0 -13
  368. package/dist/esm/files/index.js +0 -5
  369. package/dist/esm/files.js +0 -1
  370. package/dist/esm/function/debounce.js +0 -22
  371. package/dist/esm/function/index.js +0 -3
  372. package/dist/esm/function/throttle.js +0 -32
  373. package/dist/esm/function/try-catch.js +0 -35
  374. package/dist/esm/function.js +0 -1
  375. package/dist/esm/index.js +0 -7
  376. package/dist/esm/string/camel-case.js +0 -21
  377. package/dist/esm/string/capitalize.js +0 -9
  378. package/dist/esm/string/format-hms-to-seconds.js +0 -25
  379. package/dist/esm/string/format-seconds-to-fragment.js +0 -15
  380. package/dist/esm/string/format-seconds-to-hms.js +0 -13
  381. package/dist/esm/string/format-string-to-time.js +0 -10
  382. package/dist/esm/string/index.js +0 -13
  383. package/dist/esm/string/kebab-case.js +0 -11
  384. package/dist/esm/string/markdown-to-text.js +0 -66
  385. package/dist/esm/string/remove-html-tags.js +0 -14
  386. package/dist/esm/string/slugify.js +0 -9
  387. package/dist/esm/string/snake-case.js +0 -11
  388. package/dist/esm/string/to-sentence-case.js +0 -9
  389. package/dist/esm/string/truncate.js +0 -15
  390. package/dist/esm/string.js +0 -1
  391. package/dist/esm/youtube/extract-youtube-video-id.js +0 -26
  392. package/dist/esm/youtube/generate-youtube-url.js +0 -81
  393. package/dist/esm/youtube/get-video-duration.js +0 -146
  394. package/dist/esm/youtube/get-youtube-thumbnail.js +0 -31
  395. package/dist/esm/youtube/get-youtube-video-info.js +0 -207
  396. package/dist/esm/youtube/index.js +0 -6
  397. package/dist/esm/youtube/validate-youtube-link.js +0 -40
  398. package/dist/esm/youtube.js +0 -1
  399. package/dist/files/compress-image.d.ts +0 -10
  400. package/dist/files/compress-image.d.ts.map +0 -1
  401. package/dist/files/download-url.d.ts +0 -2
  402. package/dist/files/download-url.d.ts.map +0 -1
  403. package/dist/files/file-delete.d.ts +0 -2
  404. package/dist/files/file-delete.d.ts.map +0 -1
  405. package/dist/files/file-exists.d.ts +0 -2
  406. package/dist/files/file-exists.d.ts.map +0 -1
  407. package/dist/files/format-bytes.d.ts +0 -2
  408. package/dist/files/format-bytes.d.ts.map +0 -1
  409. package/dist/files/index.d.ts.map +0 -1
  410. package/dist/function/debounce.d.ts +0 -11
  411. package/dist/function/debounce.d.ts.map +0 -1
  412. package/dist/function/index.d.ts.map +0 -1
  413. package/dist/function/throttle.d.ts +0 -10
  414. package/dist/function/throttle.d.ts.map +0 -1
  415. package/dist/function/try-catch.d.ts.map +0 -1
  416. package/dist/index.d.ts.map +0 -1
  417. package/dist/string/camel-case.d.ts +0 -2
  418. package/dist/string/camel-case.d.ts.map +0 -1
  419. package/dist/string/capitalize.d.ts +0 -2
  420. package/dist/string/capitalize.d.ts.map +0 -1
  421. package/dist/string/format-hms-to-seconds.d.ts +0 -2
  422. package/dist/string/format-hms-to-seconds.d.ts.map +0 -1
  423. package/dist/string/format-seconds-to-fragment.d.ts +0 -3
  424. package/dist/string/format-seconds-to-fragment.d.ts.map +0 -1
  425. package/dist/string/format-seconds-to-hms.d.ts +0 -2
  426. package/dist/string/format-seconds-to-hms.d.ts.map +0 -1
  427. package/dist/string/format-string-to-time.d.ts +0 -2
  428. package/dist/string/format-string-to-time.d.ts.map +0 -1
  429. package/dist/string/index.d.ts.map +0 -1
  430. package/dist/string/kebab-case.d.ts +0 -2
  431. package/dist/string/kebab-case.d.ts.map +0 -1
  432. package/dist/string/markdown-to-text.d.ts +0 -2
  433. package/dist/string/markdown-to-text.d.ts.map +0 -1
  434. package/dist/string/remove-html-tags.d.ts +0 -2
  435. package/dist/string/remove-html-tags.d.ts.map +0 -1
  436. package/dist/string/slugify.d.ts +0 -2
  437. package/dist/string/slugify.d.ts.map +0 -1
  438. package/dist/string/snake-case.d.ts +0 -2
  439. package/dist/string/snake-case.d.ts.map +0 -1
  440. package/dist/string/to-sentence-case.d.ts +0 -2
  441. package/dist/string/to-sentence-case.d.ts.map +0 -1
  442. package/dist/string/truncate.d.ts +0 -2
  443. package/dist/string/truncate.d.ts.map +0 -1
  444. package/dist/youtube/extract-youtube-video-id.d.ts +0 -2
  445. package/dist/youtube/extract-youtube-video-id.d.ts.map +0 -1
  446. package/dist/youtube/generate-youtube-url.d.ts +0 -20
  447. package/dist/youtube/generate-youtube-url.d.ts.map +0 -1
  448. package/dist/youtube/get-video-duration.d.ts +0 -7
  449. package/dist/youtube/get-video-duration.d.ts.map +0 -1
  450. package/dist/youtube/get-youtube-thumbnail.d.ts +0 -2
  451. package/dist/youtube/get-youtube-thumbnail.d.ts.map +0 -1
  452. package/dist/youtube/get-youtube-video-info.d.ts +0 -26
  453. package/dist/youtube/get-youtube-video-info.d.ts.map +0 -1
  454. package/dist/youtube/index.d.ts.map +0 -1
  455. package/dist/youtube/validate-youtube-link.d.ts +0 -2
  456. package/dist/youtube/validate-youtube-link.d.ts.map +0 -1
@@ -1,9 +0,0 @@
1
- export function slugify(text) {
2
- return text
3
- .normalize("NFD")
4
- .replace(/[\u0300-\u036f]/g, "")
5
- .replace(/[^\w\s]/gi, "")
6
- .trim()
7
- .replace(/\s+/g, "-")
8
- .toLowerCase();
9
- }
@@ -1,11 +0,0 @@
1
- export function snakeCase(str) {
2
- if (typeof str !== "string") {
3
- throw new Error("Input must be a string");
4
- }
5
- return str
6
- .replace(/([a-z])([A-Z])/g, "$1_$2")
7
- .replace(/[\s-]+/g, "_")
8
- .replace(/[^a-zA-Z0-9_]/g, "")
9
- .toLowerCase()
10
- .replace(/^_+|_+$/g, "");
11
- }
@@ -1,9 +0,0 @@
1
- export function toSentenceCase(str) {
2
- return str
3
- .replace(/_/g, " ")
4
- .replace(/([A-Z])/g, " $1")
5
- .toLowerCase()
6
- .replace(/^\w/, (c) => c.toUpperCase())
7
- .replace(/\s+/g, " ")
8
- .trim();
9
- }
@@ -1,15 +0,0 @@
1
- export function truncate(str, length, suffix = "...") {
2
- if (typeof str !== "string") {
3
- throw new Error("Input must be a string");
4
- }
5
- if (typeof length !== "number" || length < 0) {
6
- throw new Error("Length must be a non-negative number");
7
- }
8
- if (str.length <= length) {
9
- return str;
10
- }
11
- if (length === 0) {
12
- return suffix;
13
- }
14
- return str.slice(0, Math.max(0, length - suffix.length)) + suffix;
15
- }
@@ -1 +0,0 @@
1
- export * from './string/index.js'
@@ -1,26 +0,0 @@
1
- export function extractYouTubeId(urlString) {
2
- if (!urlString)
3
- return null;
4
- try {
5
- const url = new URL(urlString);
6
- const hostname = url.hostname.toLowerCase();
7
- const pathname = url.pathname;
8
- if (hostname.includes("youtu.be")) {
9
- const id = pathname.replace(/^\/+/, "").split(/[?&#]/)[0];
10
- return id || null;
11
- }
12
- if (hostname.includes("youtube.com")) {
13
- if (url.searchParams.has("v")) {
14
- return url.searchParams.get("v");
15
- }
16
- const parts = pathname.split("/").filter(Boolean);
17
- const last = parts[parts.length - 1];
18
- if (last)
19
- return last.split(/[?&#]/)[0] || null;
20
- }
21
- }
22
- catch (_a) { }
23
- const regex = /(?:v=|\/embed\/|\/shorts\/|youtu\.be\/)([0-9A-Za-z_-]{6,})/i;
24
- const match = urlString.match(regex);
25
- return match ? match[1] : null;
26
- }
@@ -1,81 +0,0 @@
1
- import { formatHMSToSeconds, formatSecondsToFragment } from "../string.js";
2
- import { extractYouTubeId } from "./extract-youtube-video-id.js";
3
- export const generateYoutubeURL = (opts) => {
4
- const { videoURL, start, end, embed = false, short = false, useFragment = false, autoplay, controls, rel, loop, mute, modestbranding, origin, playlist, params = {}, } = opts;
5
- const videoId = extractYouTubeId(videoURL);
6
- if (!videoId)
7
- return null;
8
- const startSec = formatHMSToSeconds(start);
9
- const endSec = formatHMSToSeconds(end);
10
- // base url
11
- const base = embed
12
- ? `https://www.youtube.com/embed/${videoId}`
13
- : short
14
- ? `https://youtu.be/${videoId}`
15
- : "https://www.youtube.com/watch";
16
- const search = new URLSearchParams();
17
- // Add video ID for watch URLs
18
- if (!embed && !short) {
19
- search.set("v", videoId);
20
- }
21
- // Standard param names for watch/embed
22
- if (!useFragment) {
23
- if (startSec != null) {
24
- // youtu.be historically uses "t" as a query param, but "start" is widely supported.
25
- // Use "t" for short links, otherwise "start".
26
- search.set(short ? "t" : "start", String(startSec));
27
- }
28
- if (endSec != null) {
29
- search.set("end", String(endSec));
30
- }
31
- }
32
- // embed / player related params
33
- if (typeof autoplay !== "undefined")
34
- search.set("autoplay", autoplay ? "1" : "0");
35
- if (typeof controls !== "undefined")
36
- search.set("controls", String(controls));
37
- if (typeof rel !== "undefined")
38
- search.set("rel", String(rel));
39
- if (typeof modestbranding !== "undefined")
40
- search.set("modestbranding", String(modestbranding));
41
- if (typeof origin !== "undefined")
42
- search.set("origin", origin);
43
- if (typeof mute !== "undefined")
44
- search.set("mute", mute ? "1" : "0");
45
- // loop requires playlist param when embedding a single video
46
- if (loop) {
47
- search.set("loop", "1");
48
- if (playlist) {
49
- search.set("playlist", playlist);
50
- }
51
- else if (embed) {
52
- // for embed+loop, YouTube expects &playlist=VIDEO_ID
53
- search.set("playlist", videoId);
54
- }
55
- }
56
- else if (playlist) {
57
- search.set("playlist", playlist);
58
- }
59
- // merge custom params (allow overriding)
60
- Object.entries(params).forEach(([k, v]) => {
61
- if (v === false)
62
- search.set(k, "0");
63
- else if (v === true)
64
- search.set(k, "1");
65
- else
66
- search.set(k, String(v));
67
- });
68
- const qs = search.toString() ? `?${search.toString()}` : "";
69
- // fragment handling (e.g. #t=1m2s)
70
- let fragment = "";
71
- if (useFragment && startSec != null) {
72
- fragment = `#t=${formatSecondsToFragment(startSec)}`;
73
- }
74
- // For short links, people often prefer the short host and start as query or fragment.
75
- if (short) {
76
- // prefer fragment if requested, otherwise use search params (t)
77
- return `${base}${qs}${fragment}`;
78
- }
79
- // watch/embed links
80
- return `${base}${qs}${fragment}`;
81
- };
@@ -1,146 +0,0 @@
1
- /** biome-ignore-all lint/suspicious/noExplicitAny: Window is any */
2
- import { formatSecondsToHMS } from "../string.js";
3
- import { extractYouTubeId } from "./extract-youtube-video-id.js";
4
- import { validateYoutubeLink } from "./validate-youtube-link.js";
5
- let YtApiLoading = null;
6
- function loadYouTubeIFrameAPI() {
7
- var _a;
8
- if ((_a = window.YT) === null || _a === void 0 ? void 0 : _a.Player)
9
- return Promise.resolve();
10
- if (YtApiLoading)
11
- return YtApiLoading;
12
- YtApiLoading = new Promise((resolve) => {
13
- const existing = document.querySelector('script[src="https://www.youtube.com/iframe_api"]');
14
- if (existing) {
15
- // Poll until the API is ready
16
- const poll = setInterval(() => {
17
- var _a;
18
- if ((_a = window.YT) === null || _a === void 0 ? void 0 : _a.Player) {
19
- clearInterval(poll);
20
- resolve();
21
- }
22
- }, 50);
23
- return;
24
- }
25
- const tag = document.createElement("script");
26
- tag.src = "https://www.youtube.com/iframe_api";
27
- tag.async = true;
28
- document.body.appendChild(tag);
29
- window.onYouTubeIframeAPIReady = () => {
30
- resolve();
31
- };
32
- });
33
- return YtApiLoading;
34
- }
35
- /**
36
- * getYoutubeVideoDuration
37
- * Returns a function that accepts a YouTube URL (full or short) and returns a Promise
38
- * resolving to the video duration formatted as "HH:MM:SS" or null on failure.
39
- */
40
- export async function getYoutubeVideoDuration(videoUrl) {
41
- const videoId = extractYouTubeId(videoUrl);
42
- if (!videoId)
43
- return null;
44
- const videoIsValid = await validateYoutubeLink(videoUrl);
45
- if (!videoIsValid)
46
- return null;
47
- try {
48
- await loadYouTubeIFrameAPI();
49
- }
50
- catch (_a) {
51
- return null;
52
- }
53
- return await new Promise((resolve) => {
54
- const iframeId = `yt-duration-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
55
- const iframe = document.createElement("iframe");
56
- // create a minimal offscreen iframe for the player
57
- iframe.id = iframeId;
58
- iframe.style.position = "fixed";
59
- iframe.style.left = "-9999px";
60
- iframe.style.width = "1px";
61
- iframe.style.height = "1px";
62
- iframe.style.opacity = "0";
63
- iframe.style.pointerEvents = "none";
64
- // embed URL with enablejsapi so we can construct YT.Player
65
- const origin = window.location.origin;
66
- iframe.src = `https://www.youtube.com/embed/${encodeURIComponent(videoId)}?enablejsapi=1&origin=${encodeURIComponent(origin)}`;
67
- let resolved = false;
68
- let player = null;
69
- let cleanupTimeout = null;
70
- function cleanupAndResolve(result) {
71
- if (resolved)
72
- return;
73
- resolved = true;
74
- try {
75
- if (player && typeof player.destroy === "function")
76
- player.destroy();
77
- }
78
- catch (_a) {
79
- /* ignore */
80
- }
81
- try {
82
- if (iframe.parentNode)
83
- iframe.parentNode.removeChild(iframe);
84
- }
85
- catch (_b) {
86
- /* ignore */
87
- }
88
- if (cleanupTimeout)
89
- window.clearTimeout(cleanupTimeout);
90
- resolve(result);
91
- }
92
- // timeout fallback
93
- cleanupTimeout = window.setTimeout(() => {
94
- cleanupAndResolve(null);
95
- }, 10000); // 10s timeout
96
- document.body.appendChild(iframe);
97
- // Construct player
98
- try {
99
- player = new window.YT.Player(iframeId, {
100
- events: {
101
- onReady: (e) => {
102
- try {
103
- let duration = e.target.getDuration();
104
- if (!duration || duration === 0) {
105
- // Sometimes duration is 0 immediately; try a few short retries
106
- let attempts = 0;
107
- const tryInterval = setInterval(() => {
108
- attempts += 1;
109
- try {
110
- duration = e.target.getDuration();
111
- if (duration && duration > 0) {
112
- clearInterval(tryInterval);
113
- cleanupAndResolve(formatSecondsToHMS(duration));
114
- }
115
- else if (attempts >= 8) {
116
- clearInterval(tryInterval);
117
- cleanupAndResolve(null);
118
- }
119
- }
120
- catch (_a) {
121
- if (attempts >= 8) {
122
- clearInterval(tryInterval);
123
- cleanupAndResolve(null);
124
- }
125
- }
126
- }, 300);
127
- }
128
- else {
129
- cleanupAndResolve(formatSecondsToHMS(duration));
130
- }
131
- }
132
- catch (_a) {
133
- cleanupAndResolve(null);
134
- }
135
- },
136
- onError: () => {
137
- cleanupAndResolve(null);
138
- },
139
- },
140
- });
141
- }
142
- catch (_a) {
143
- cleanupAndResolve(null);
144
- }
145
- });
146
- }
@@ -1,31 +0,0 @@
1
- export async function getYoutubeThumbnail(videoUrl) {
2
- const { extractYouTubeId } = await import("./extract-youtube-video-id.js");
3
- const videoId = extractYouTubeId(videoUrl);
4
- if (!videoId)
5
- return null;
6
- // Try loading YouTube thumbnail images — avoids CORS problems because
7
- // creating an Image and listening for load/error is not blocked by CORS.
8
- const thumbs = [
9
- `https://img.youtube.com/vi/${videoId}/maxresdefault.jpg`,
10
- `https://img.youtube.com/vi/${videoId}/hqdefault.jpg`,
11
- `https://img.youtube.com/vi/${videoId}/mqdefault.jpg`,
12
- `https://img.youtube.com/vi/${videoId}/default.jpg`,
13
- ];
14
- const loadImage = (src) => new Promise((resolve) => {
15
- const img = new Image();
16
- img.onload = () => resolve(true);
17
- img.onerror = () => resolve(false);
18
- img.src = src;
19
- });
20
- for (const url of thumbs) {
21
- try {
22
- const ok = await loadImage(url);
23
- if (ok)
24
- return url;
25
- }
26
- catch (_a) {
27
- // ignore and try next thumbnail
28
- }
29
- }
30
- return null;
31
- }
@@ -1,207 +0,0 @@
1
- const videoInfoCache = new Map();
2
- export async function getYoutubeVideoInfo(videoUrl) {
3
- const { extractYouTubeId } = await import("./extract-youtube-video-id.js");
4
- const videoId = extractYouTubeId(videoUrl);
5
- if (!videoId)
6
- return null;
7
- const cached = videoInfoCache.get(videoId);
8
- if (cached)
9
- return cached;
10
- const fetchPromise = fetchYoutubeVideoInfo(videoId);
11
- videoInfoCache.set(videoId, fetchPromise);
12
- const info = await fetchPromise;
13
- if (!info) {
14
- videoInfoCache.delete(videoId);
15
- }
16
- return info;
17
- }
18
- async function fetchYoutubeVideoInfo(videoId) {
19
- const watchUrl = `https://www.youtube.com/watch?v=${encodeURIComponent(videoId)}`;
20
- const htmlInfo = await fetchFromWatchPage(videoId, watchUrl);
21
- if (htmlInfo)
22
- return htmlInfo;
23
- const oEmbedInfo = await fetchFromOEmbed(videoId, watchUrl);
24
- if (oEmbedInfo)
25
- return oEmbedInfo;
26
- const noEmbedInfo = await fetchFromNoEmbed(videoId, watchUrl);
27
- if (noEmbedInfo)
28
- return noEmbedInfo;
29
- return null;
30
- }
31
- async function fetchFromWatchPage(videoId, watchUrl) {
32
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
33
- try {
34
- const response = await fetch(watchUrl);
35
- if (!response.ok) {
36
- return null;
37
- }
38
- const html = await response.text();
39
- const rawJson = extractJsonBlock(html, "ytInitialPlayerResponse");
40
- if (!rawJson) {
41
- return null;
42
- }
43
- const data = JSON.parse(rawJson);
44
- const details = data.videoDetails;
45
- const microformat = (_a = data.microformat) === null || _a === void 0 ? void 0 : _a.playerMicroformatRenderer;
46
- if (!details && !microformat) {
47
- return null;
48
- }
49
- const thumbnails = getThumbnails(details, microformat);
50
- const bestThumbnail = selectBestThumbnail(thumbnails);
51
- return {
52
- id: (_b = details === null || details === void 0 ? void 0 : details.videoId) !== null && _b !== void 0 ? _b : videoId,
53
- url: watchUrl,
54
- title: (_d = (_c = details === null || details === void 0 ? void 0 : details.title) !== null && _c !== void 0 ? _c : extractText(microformat === null || microformat === void 0 ? void 0 : microformat.title)) !== null && _d !== void 0 ? _d : "",
55
- channelTitle: (_f = (_e = details === null || details === void 0 ? void 0 : details.author) !== null && _e !== void 0 ? _e : microformat === null || microformat === void 0 ? void 0 : microformat.ownerChannelName) !== null && _f !== void 0 ? _f : "",
56
- channelId: (_g = details === null || details === void 0 ? void 0 : details.channelId) !== null && _g !== void 0 ? _g : microformat === null || microformat === void 0 ? void 0 : microformat.externalChannelId,
57
- channelUrl: microformat === null || microformat === void 0 ? void 0 : microformat.ownerProfileUrl,
58
- description: (_h = extractText(microformat === null || microformat === void 0 ? void 0 : microformat.description)) !== null && _h !== void 0 ? _h : details === null || details === void 0 ? void 0 : details.shortDescription,
59
- shortDescription: details === null || details === void 0 ? void 0 : details.shortDescription,
60
- thumbnails,
61
- thumbnail: bestThumbnail === null || bestThumbnail === void 0 ? void 0 : bestThumbnail.url,
62
- publishedAt: (_j = microformat === null || microformat === void 0 ? void 0 : microformat.publishDate) !== null && _j !== void 0 ? _j : microformat === null || microformat === void 0 ? void 0 : microformat.uploadDate,
63
- uploadedAt: microformat === null || microformat === void 0 ? void 0 : microformat.uploadDate,
64
- keywords: details === null || details === void 0 ? void 0 : details.keywords,
65
- viewCount: parseNumber(details === null || details === void 0 ? void 0 : details.viewCount),
66
- lengthSeconds: parseNumber(details === null || details === void 0 ? void 0 : details.lengthSeconds),
67
- isLive: (_k = details === null || details === void 0 ? void 0 : details.isLiveContent) !== null && _k !== void 0 ? _k : (_l = microformat === null || microformat === void 0 ? void 0 : microformat.liveBroadcastDetails) === null || _l === void 0 ? void 0 : _l.isLiveNow,
68
- };
69
- }
70
- catch (_m) {
71
- return null;
72
- }
73
- }
74
- async function fetchFromOEmbed(videoId, watchUrl) {
75
- var _a;
76
- try {
77
- const oEmbedUrl = `https://www.youtube.com/oembed?url=${encodeURIComponent(watchUrl)}&format=json`;
78
- const response = await fetch(oEmbedUrl);
79
- if (!response.ok) {
80
- return null;
81
- }
82
- const data = (await response.json());
83
- if (!(data === null || data === void 0 ? void 0 : data.title) || !(data === null || data === void 0 ? void 0 : data.author_name)) {
84
- return null;
85
- }
86
- const thumbnails = createThumbnailList(data.thumbnail_url, data.thumbnail_width, data.thumbnail_height);
87
- return {
88
- id: videoId,
89
- url: watchUrl,
90
- title: data.title,
91
- channelTitle: data.author_name,
92
- channelUrl: data.author_url,
93
- thumbnails,
94
- thumbnail: (_a = thumbnails[0]) === null || _a === void 0 ? void 0 : _a.url,
95
- description: undefined,
96
- shortDescription: undefined,
97
- publishedAt: undefined,
98
- uploadedAt: undefined,
99
- keywords: undefined,
100
- viewCount: undefined,
101
- lengthSeconds: undefined,
102
- isLive: undefined,
103
- };
104
- }
105
- catch (_b) {
106
- return null;
107
- }
108
- }
109
- async function fetchFromNoEmbed(videoId, watchUrl) {
110
- var _a;
111
- try {
112
- const noEmbedUrl = `https://noembed.com/embed?url=${encodeURIComponent(watchUrl)}`;
113
- const response = await fetch(noEmbedUrl);
114
- if (!response.ok) {
115
- return null;
116
- }
117
- const data = (await response.json());
118
- if (!(data === null || data === void 0 ? void 0 : data.title) || !(data === null || data === void 0 ? void 0 : data.author_name)) {
119
- return null;
120
- }
121
- const thumbnails = createThumbnailList(data.thumbnail_url, data.thumbnail_width, data.thumbnail_height);
122
- return {
123
- id: videoId,
124
- url: watchUrl,
125
- title: data.title,
126
- channelTitle: data.author_name,
127
- channelUrl: data.author_url,
128
- description: data.description,
129
- shortDescription: data.description,
130
- thumbnails,
131
- thumbnail: (_a = thumbnails[0]) === null || _a === void 0 ? void 0 : _a.url,
132
- publishedAt: data.upload_date,
133
- uploadedAt: data.upload_date,
134
- keywords: undefined,
135
- viewCount: undefined,
136
- lengthSeconds: undefined,
137
- isLive: undefined,
138
- };
139
- }
140
- catch (_b) {
141
- return null;
142
- }
143
- }
144
- function extractJsonBlock(html, marker) {
145
- const markerIndex = html.indexOf(marker);
146
- if (markerIndex === -1)
147
- return null;
148
- const jsonStart = html.indexOf("{", markerIndex);
149
- if (jsonStart === -1)
150
- return null;
151
- let depth = 0;
152
- for (let i = jsonStart; i < html.length; i++) {
153
- const char = html[i];
154
- if (char === "{") {
155
- depth += 1;
156
- }
157
- else if (char === "}") {
158
- depth -= 1;
159
- }
160
- if (depth === 0) {
161
- return html.slice(jsonStart, i + 1);
162
- }
163
- }
164
- return null;
165
- }
166
- function getThumbnails(details, microformat) {
167
- var _a, _b, _c, _d;
168
- if ((_b = (_a = details === null || details === void 0 ? void 0 : details.thumbnail) === null || _a === void 0 ? void 0 : _a.thumbnails) === null || _b === void 0 ? void 0 : _b.length) {
169
- return details.thumbnail.thumbnails;
170
- }
171
- return (_d = (_c = microformat === null || microformat === void 0 ? void 0 : microformat.thumbnail) === null || _c === void 0 ? void 0 : _c.thumbnails) !== null && _d !== void 0 ? _d : [];
172
- }
173
- function selectBestThumbnail(thumbnails) {
174
- if (!thumbnails.length)
175
- return undefined;
176
- return thumbnails.reduce((best, current) => {
177
- if (!best)
178
- return current;
179
- if (!best.width)
180
- return current;
181
- if (!current.width)
182
- return best;
183
- return current.width > best.width ? current : best;
184
- });
185
- }
186
- function extractText(field) {
187
- var _a;
188
- if (!field)
189
- return undefined;
190
- if (field.simpleText)
191
- return field.simpleText;
192
- if ((_a = field.runs) === null || _a === void 0 ? void 0 : _a.length) {
193
- return field.runs.map((run) => { var _a; return (_a = run.text) !== null && _a !== void 0 ? _a : ""; }).join("");
194
- }
195
- return undefined;
196
- }
197
- function parseNumber(value) {
198
- if (value === undefined)
199
- return undefined;
200
- const parsed = Number(value);
201
- return Number.isNaN(parsed) ? undefined : parsed;
202
- }
203
- function createThumbnailList(url, width, height) {
204
- if (!url)
205
- return [];
206
- return [{ url, width, height }];
207
- }
@@ -1,6 +0,0 @@
1
- export * from "./extract-youtube-video-id.js";
2
- export * from "./generate-youtube-url.js";
3
- export * from "./get-video-duration.js";
4
- export * from "./get-youtube-thumbnail.js";
5
- export * from "./get-youtube-video-info.js";
6
- export * from "./validate-youtube-link.js";
@@ -1,40 +0,0 @@
1
- export async function validateYoutubeLink(videoUrl) {
2
- const { extractYouTubeId } = await import("./extract-youtube-video-id.js");
3
- const videoId = extractYouTubeId(videoUrl);
4
- if (!videoId)
5
- return false;
6
- // Try loading YouTube thumbnail images — avoids CORS problems because
7
- // creating an Image and listening for load/error is not blocked by CORS.
8
- const thumbs = [
9
- `https://img.youtube.com/vi/${videoId}/maxresdefault.jpg`,
10
- `https://img.youtube.com/vi/${videoId}/hqdefault.jpg`,
11
- `https://img.youtube.com/vi/${videoId}/mqdefault.jpg`,
12
- `https://img.youtube.com/vi/${videoId}/default.jpg`,
13
- ];
14
- const loadImage = (src) => new Promise((resolve) => {
15
- const img = new Image();
16
- img.onload = () => resolve(true);
17
- img.onerror = () => resolve(false);
18
- img.src = src;
19
- });
20
- for (const url of thumbs) {
21
- try {
22
- const ok = await loadImage(url);
23
- if (ok)
24
- return true;
25
- }
26
- catch (_a) {
27
- // ignore and try next thumbnail
28
- }
29
- }
30
- // Fallback: try oEmbed endpoint (may be subject to CORS in some environments)
31
- try {
32
- const watchUrl = `https://www.youtube.com/watch?v=${encodeURIComponent(videoId)}`;
33
- const oembedUrl = `https://www.youtube.com/oembed?url=${encodeURIComponent(watchUrl)}&format=json`;
34
- const res = await fetch(oembedUrl, { method: "GET" });
35
- return res.ok;
36
- }
37
- catch (_b) {
38
- return false;
39
- }
40
- }
@@ -1 +0,0 @@
1
- export * from './youtube/index.js'
@@ -1,10 +0,0 @@
1
- interface ICompressImageParams {
2
- file: File;
3
- maxWidth?: number;
4
- maxHeight?: number;
5
- quality?: number;
6
- allowedFileTypes?: string[];
7
- }
8
- export declare function compressImage({ file, maxWidth, maxHeight, quality, allowedFileTypes, }: ICompressImageParams): Promise<File>;
9
- export {};
10
- //# sourceMappingURL=compress-image.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compress-image.d.ts","sourceRoot":"","sources":["../../src/files/compress-image.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC5B;AAYD,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,QAAmC,EACnC,SAAoC,EACpC,OAAW,EACX,gBAAyE,GAC1E,EAAE,oBAAoB,iBAiEtB"}
@@ -1,2 +0,0 @@
1
- export declare const downloadUrl: (url: string) => Promise<boolean>;
2
- //# sourceMappingURL=download-url.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"download-url.d.ts","sourceRoot":"","sources":["../../src/files/download-url.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,OAAO,CAyB9D,CAAA"}
@@ -1,2 +0,0 @@
1
- export declare const fileDelete: (filePath: string) => Promise<void>;
2
- //# sourceMappingURL=file-delete.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-delete.d.ts","sourceRoot":"","sources":["../../src/files/file-delete.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,GAAU,UAAU,MAAM,kBAOhD,CAAA"}
@@ -1,2 +0,0 @@
1
- export declare const fileExists: (filePath: string) => Promise<boolean>;
2
- //# sourceMappingURL=file-exists.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-exists.d.ts","sourceRoot":"","sources":["../../src/files/file-exists.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,GAAU,UAAU,MAAM,qBAOhD,CAAA"}
@@ -1,2 +0,0 @@
1
- export declare function formatBytes(bytes: number): string;
2
- //# sourceMappingURL=format-bytes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format-bytes.d.ts","sourceRoot":"","sources":["../../src/files/format-bytes.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAejD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/files/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA"}
@@ -1,11 +0,0 @@
1
- type TAnyFunction = (...args: unknown[]) => unknown;
2
- /**
3
- * Creates a debounced function that delays invoking func until after delay milliseconds
4
- * have elapsed since the last time the debounced function was invoked
5
- * @param fn - The function to debounce
6
- * @param delay - The number of milliseconds to delay
7
- * @returns The debounced function
8
- */
9
- export declare function debounce<T extends TAnyFunction>(fn: T, delay: number): (...args: Parameters<T>) => void;
10
- export {};
11
- //# sourceMappingURL=debounce.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/function/debounce.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAA;AAEnD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,YAAY,EAC7C,EAAE,EAAE,CAAC,EACL,KAAK,EAAE,MAAM,GACZ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAiBlC"}