@herowcode/utils 1.3.5 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.cjs +12 -0
- package/dist/api/index.cjs.map +1 -0
- package/dist/api/{client.d.ts → index.d.mts} +19 -8
- package/dist/api/index.d.ts +36 -3
- package/dist/api/index.js +3 -0
- package/dist/api/index.js.map +1 -0
- package/dist/array/index.cjs +16 -0
- package/dist/array/index.cjs.map +1 -0
- package/dist/array/index.d.mts +5 -0
- package/dist/array/index.d.ts +5 -3
- package/dist/array/index.js +3 -0
- package/dist/array/index.js.map +1 -0
- package/dist/chunk-2MANLCNG.cjs +23 -0
- package/dist/chunk-2MANLCNG.cjs.map +1 -0
- package/dist/chunk-2RTW37WD.js +20 -0
- package/dist/chunk-2RTW37WD.js.map +1 -0
- package/dist/chunk-2Y6M7IOG.js +250 -0
- package/dist/chunk-2Y6M7IOG.js.map +1 -0
- package/dist/chunk-3JUB2OJL.js +3 -0
- package/dist/chunk-3JUB2OJL.js.map +1 -0
- package/dist/chunk-53JMVGIG.js +187 -0
- package/dist/chunk-53JMVGIG.js.map +1 -0
- package/dist/chunk-56NHIM5J.js +151 -0
- package/dist/chunk-56NHIM5J.js.map +1 -0
- package/dist/chunk-5OLQJUNS.js +66 -0
- package/dist/chunk-5OLQJUNS.js.map +1 -0
- package/dist/chunk-5YOEKMTJ.cjs +321 -0
- package/dist/chunk-5YOEKMTJ.cjs.map +1 -0
- package/dist/chunk-6TWPZ6LL.cjs +4 -0
- package/dist/chunk-6TWPZ6LL.cjs.map +1 -0
- package/dist/chunk-AQZBHMTO.js +96 -0
- package/dist/chunk-AQZBHMTO.js.map +1 -0
- package/dist/chunk-ATWN4SRX.js +29 -0
- package/dist/chunk-ATWN4SRX.js.map +1 -0
- package/dist/chunk-GRSF4RY2.cjs +20 -0
- package/dist/chunk-GRSF4RY2.cjs.map +1 -0
- package/dist/chunk-GX5E5B4L.cjs +70 -0
- package/dist/chunk-GX5E5B4L.cjs.map +1 -0
- package/dist/chunk-HK727IAV.cjs +201 -0
- package/dist/chunk-HK727IAV.cjs.map +1 -0
- package/dist/chunk-LJ6KOZD4.cjs +154 -0
- package/dist/chunk-LJ6KOZD4.cjs.map +1 -0
- package/dist/chunk-N2DRAZ3A.cjs +29 -0
- package/dist/chunk-N2DRAZ3A.cjs.map +1 -0
- package/dist/chunk-O7SH3E3T.js +18 -0
- package/dist/chunk-O7SH3E3T.js.map +1 -0
- package/dist/chunk-P5YNRND6.cjs +4 -0
- package/dist/chunk-P5YNRND6.cjs.map +1 -0
- package/dist/chunk-QAE6Q2SA.js +317 -0
- package/dist/chunk-QAE6Q2SA.js.map +1 -0
- package/dist/chunk-QRXVUXGJ.js +378 -0
- package/dist/chunk-QRXVUXGJ.js.map +1 -0
- package/dist/chunk-SLYUARZG.cjs +99 -0
- package/dist/chunk-SLYUARZG.cjs.map +1 -0
- package/dist/chunk-SWRIT7EE.js +3 -0
- package/dist/chunk-SWRIT7EE.js.map +1 -0
- package/dist/chunk-UXEUYHBD.cjs +401 -0
- package/dist/chunk-UXEUYHBD.cjs.map +1 -0
- package/dist/chunk-V6OKXUBQ.js +22 -0
- package/dist/chunk-V6OKXUBQ.js.map +1 -0
- package/dist/chunk-VAZJXZU5.cjs +31 -0
- package/dist/chunk-VAZJXZU5.cjs.map +1 -0
- package/dist/chunk-WGSFRFRO.cjs +252 -0
- package/dist/chunk-WGSFRFRO.cjs.map +1 -0
- package/dist/date/index.cjs +56 -0
- package/dist/date/index.cjs.map +1 -0
- package/dist/date/index.d.mts +63 -0
- package/dist/date/index.d.ts +63 -8
- package/dist/date/index.js +3 -0
- package/dist/date/index.js.map +1 -0
- package/dist/extract-youtube-video-id-HSYMYXIZ.js +3 -0
- package/dist/extract-youtube-video-id-HSYMYXIZ.js.map +1 -0
- package/dist/extract-youtube-video-id-XVGNPUDX.cjs +12 -0
- package/dist/extract-youtube-video-id-XVGNPUDX.cjs.map +1 -0
- package/dist/files/index.browser.cjs +21 -0
- package/dist/files/index.browser.cjs.map +1 -0
- package/dist/files/index.browser.d.mts +14 -0
- package/dist/files/index.browser.d.ts +14 -0
- package/dist/files/index.browser.js +4 -0
- package/dist/files/index.browser.js.map +1 -0
- package/dist/files/index.cjs +31 -0
- package/dist/files/index.cjs.map +1 -0
- package/dist/files/index.d.mts +3 -0
- package/dist/files/index.d.ts +3 -6
- package/dist/files/index.js +6 -0
- package/dist/files/index.js.map +1 -0
- package/dist/files/index.node.cjs +21 -0
- package/dist/files/index.node.cjs.map +1 -0
- package/dist/files/index.node.d.mts +7 -0
- package/dist/files/index.node.d.ts +7 -0
- package/dist/files/index.node.js +4 -0
- package/dist/files/index.node.js.map +1 -0
- package/dist/format-bytes-BGjeDnvM.d.mts +3 -0
- package/dist/format-bytes-BGjeDnvM.d.ts +3 -0
- package/dist/function/index.cjs +20 -0
- package/dist/function/index.cjs.map +1 -0
- package/dist/function/index.d.mts +22 -0
- package/dist/function/index.d.ts +22 -4
- package/dist/function/index.js +3 -0
- package/dist/function/index.js.map +1 -0
- package/dist/index.cjs +188 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -8
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/nextjs/index.browser.cjs +110 -0
- package/dist/nextjs/index.browser.cjs.map +1 -0
- package/dist/nextjs/index.browser.d.mts +10 -0
- package/dist/nextjs/index.browser.d.ts +10 -0
- package/dist/nextjs/index.browser.js +103 -0
- package/dist/nextjs/index.browser.js.map +1 -0
- package/dist/string/index.cjs +60 -0
- package/dist/string/index.cjs.map +1 -0
- package/dist/string/index.d.mts +28 -0
- package/dist/string/index.d.ts +28 -14
- package/dist/string/index.js +3 -0
- package/dist/string/index.js.map +1 -0
- package/dist/{cjs/function/try-catch.d.ts → try-catch-B7WzqcPU.d.mts} +4 -4
- package/dist/{function/try-catch.d.ts → try-catch-B7WzqcPU.d.ts} +4 -4
- package/dist/youtube/index.browser.cjs +35 -0
- package/dist/youtube/index.browser.cjs.map +1 -0
- package/dist/youtube/index.browser.d.mts +2 -0
- package/dist/youtube/index.browser.d.ts +2 -0
- package/dist/youtube/index.browser.js +6 -0
- package/dist/youtube/index.browser.js.map +1 -0
- package/dist/youtube/index.cjs +36 -0
- package/dist/youtube/index.cjs.map +1 -0
- package/dist/youtube/index.d.mts +12 -0
- package/dist/youtube/index.d.ts +12 -7
- package/dist/youtube/index.js +7 -0
- package/dist/youtube/index.js.map +1 -0
- package/dist/youtube/index.node.cjs +26 -0
- package/dist/youtube/index.node.cjs.map +1 -0
- package/dist/youtube/index.node.d.mts +49 -0
- package/dist/youtube/index.node.d.ts +49 -0
- package/dist/youtube/index.node.js +5 -0
- package/dist/youtube/index.node.js.map +1 -0
- package/package.json +164 -49
- package/dist/api/client.d.ts.map +0 -1
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/wrapper.d.ts +0 -27
- package/dist/api/wrapper.d.ts.map +0 -1
- package/dist/array/index.d.ts.map +0 -1
- package/dist/array/shuffle.d.ts +0 -2
- package/dist/array/shuffle.d.ts.map +0 -1
- package/dist/array/unique.d.ts +0 -2
- package/dist/array/unique.d.ts.map +0 -1
- package/dist/cjs/api/client.d.ts +0 -25
- package/dist/cjs/api/client.d.ts.map +0 -1
- package/dist/cjs/api/client.js +0 -148
- package/dist/cjs/api/client.js.map +0 -1
- package/dist/cjs/api/index.d.ts +0 -3
- package/dist/cjs/api/index.d.ts.map +0 -1
- package/dist/cjs/api/index.js +0 -6
- package/dist/cjs/api/index.js.map +0 -1
- package/dist/cjs/api/wrapper.d.ts +0 -27
- package/dist/cjs/api/wrapper.d.ts.map +0 -1
- package/dist/cjs/api/wrapper.js +0 -152
- package/dist/cjs/api/wrapper.js.map +0 -1
- package/dist/cjs/array/index.d.ts +0 -3
- package/dist/cjs/array/index.d.ts.map +0 -1
- package/dist/cjs/array/index.js +0 -19
- package/dist/cjs/array/index.js.map +0 -1
- package/dist/cjs/array/shuffle.d.ts +0 -2
- package/dist/cjs/array/shuffle.d.ts.map +0 -1
- package/dist/cjs/array/shuffle.js +0 -16
- package/dist/cjs/array/shuffle.js.map +0 -1
- package/dist/cjs/array/unique.d.ts +0 -2
- package/dist/cjs/array/unique.d.ts.map +0 -1
- package/dist/cjs/array/unique.js +0 -7
- package/dist/cjs/array/unique.js.map +0 -1
- package/dist/cjs/array.js +0 -1
- package/dist/cjs/date/dayjs.d.ts +0 -20
- package/dist/cjs/date/dayjs.d.ts.map +0 -1
- package/dist/cjs/date/dayjs.js +0 -123
- package/dist/cjs/date/dayjs.js.map +0 -1
- package/dist/cjs/date/fix-timezone-offset.d.ts +0 -3
- package/dist/cjs/date/fix-timezone-offset.d.ts.map +0 -1
- package/dist/cjs/date/fix-timezone-offset.js +0 -9
- package/dist/cjs/date/fix-timezone-offset.js.map +0 -1
- package/dist/cjs/date/format-date.d.ts +0 -23
- package/dist/cjs/date/format-date.d.ts.map +0 -1
- package/dist/cjs/date/format-date.js +0 -71
- package/dist/cjs/date/format-date.js.map +0 -1
- package/dist/cjs/date/get-current-date-in-utc.d.ts +0 -3
- package/dist/cjs/date/get-current-date-in-utc.d.ts.map +0 -1
- package/dist/cjs/date/get-current-date-in-utc.js +0 -8
- package/dist/cjs/date/get-current-date-in-utc.js.map +0 -1
- package/dist/cjs/date/get-date-in-utc.d.ts +0 -3
- package/dist/cjs/date/get-date-in-utc.d.ts.map +0 -1
- package/dist/cjs/date/get-date-in-utc.js +0 -8
- package/dist/cjs/date/get-date-in-utc.js.map +0 -1
- package/dist/cjs/date/get-relative-time.d.ts +0 -3
- package/dist/cjs/date/get-relative-time.d.ts.map +0 -1
- package/dist/cjs/date/get-relative-time.js +0 -8
- package/dist/cjs/date/get-relative-time.js.map +0 -1
- package/dist/cjs/date/index.d.ts +0 -8
- package/dist/cjs/date/index.d.ts.map +0 -1
- package/dist/cjs/date/index.js +0 -24
- package/dist/cjs/date/index.js.map +0 -1
- package/dist/cjs/date/parse-time-spent.d.ts +0 -15
- package/dist/cjs/date/parse-time-spent.d.ts.map +0 -1
- package/dist/cjs/date/parse-time-spent.js +0 -207
- package/dist/cjs/date/parse-time-spent.js.map +0 -1
- package/dist/cjs/date.js +0 -1
- package/dist/cjs/files/compress-image.d.ts +0 -10
- package/dist/cjs/files/compress-image.d.ts.map +0 -1
- package/dist/cjs/files/compress-image.js +0 -61
- package/dist/cjs/files/compress-image.js.map +0 -1
- package/dist/cjs/files/download-url.d.ts +0 -2
- package/dist/cjs/files/download-url.d.ts.map +0 -1
- package/dist/cjs/files/download-url.js +0 -29
- package/dist/cjs/files/download-url.js.map +0 -1
- package/dist/cjs/files/file-delete.d.ts +0 -2
- package/dist/cjs/files/file-delete.d.ts.map +0 -1
- package/dist/cjs/files/file-delete.js +0 -20
- package/dist/cjs/files/file-delete.js.map +0 -1
- package/dist/cjs/files/file-exists.d.ts +0 -2
- package/dist/cjs/files/file-exists.d.ts.map +0 -1
- package/dist/cjs/files/file-exists.js +0 -18
- package/dist/cjs/files/file-exists.js.map +0 -1
- package/dist/cjs/files/format-bytes.d.ts +0 -2
- package/dist/cjs/files/format-bytes.d.ts.map +0 -1
- package/dist/cjs/files/format-bytes.js +0 -17
- package/dist/cjs/files/format-bytes.js.map +0 -1
- package/dist/cjs/files/index.d.ts +0 -6
- package/dist/cjs/files/index.d.ts.map +0 -1
- package/dist/cjs/files/index.js +0 -22
- package/dist/cjs/files/index.js.map +0 -1
- package/dist/cjs/files.js +0 -1
- package/dist/cjs/function/debounce.d.ts +0 -11
- package/dist/cjs/function/debounce.d.ts.map +0 -1
- package/dist/cjs/function/debounce.js +0 -26
- package/dist/cjs/function/debounce.js.map +0 -1
- package/dist/cjs/function/index.d.ts +0 -4
- package/dist/cjs/function/index.d.ts.map +0 -1
- package/dist/cjs/function/index.js +0 -20
- package/dist/cjs/function/index.js.map +0 -1
- package/dist/cjs/function/throttle.d.ts +0 -10
- package/dist/cjs/function/throttle.d.ts.map +0 -1
- package/dist/cjs/function/throttle.js +0 -36
- package/dist/cjs/function/throttle.js.map +0 -1
- package/dist/cjs/function/try-catch.d.ts.map +0 -1
- package/dist/cjs/function/try-catch.js +0 -39
- package/dist/cjs/function/try-catch.js.map +0 -1
- package/dist/cjs/function.js +0 -1
- package/dist/cjs/index.d.ts +0 -8
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -24
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/string/camel-case.d.ts +0 -2
- package/dist/cjs/string/camel-case.d.ts.map +0 -1
- package/dist/cjs/string/camel-case.js +0 -25
- package/dist/cjs/string/camel-case.js.map +0 -1
- package/dist/cjs/string/capitalize.d.ts +0 -2
- package/dist/cjs/string/capitalize.d.ts.map +0 -1
- package/dist/cjs/string/capitalize.js +0 -13
- package/dist/cjs/string/capitalize.js.map +0 -1
- package/dist/cjs/string/format-hms-to-seconds.d.ts +0 -2
- package/dist/cjs/string/format-hms-to-seconds.d.ts.map +0 -1
- package/dist/cjs/string/format-hms-to-seconds.js +0 -30
- package/dist/cjs/string/format-hms-to-seconds.js.map +0 -1
- package/dist/cjs/string/format-seconds-to-fragment.d.ts +0 -3
- package/dist/cjs/string/format-seconds-to-fragment.d.ts.map +0 -1
- package/dist/cjs/string/format-seconds-to-fragment.js +0 -20
- package/dist/cjs/string/format-seconds-to-fragment.js.map +0 -1
- package/dist/cjs/string/format-seconds-to-hms.d.ts +0 -2
- package/dist/cjs/string/format-seconds-to-hms.d.ts.map +0 -1
- package/dist/cjs/string/format-seconds-to-hms.js +0 -17
- package/dist/cjs/string/format-seconds-to-hms.js.map +0 -1
- package/dist/cjs/string/format-string-to-time.d.ts +0 -2
- package/dist/cjs/string/format-string-to-time.d.ts.map +0 -1
- package/dist/cjs/string/format-string-to-time.js +0 -15
- package/dist/cjs/string/format-string-to-time.js.map +0 -1
- package/dist/cjs/string/index.d.ts +0 -14
- package/dist/cjs/string/index.d.ts.map +0 -1
- package/dist/cjs/string/index.js +0 -30
- package/dist/cjs/string/index.js.map +0 -1
- package/dist/cjs/string/kebab-case.d.ts +0 -2
- package/dist/cjs/string/kebab-case.d.ts.map +0 -1
- package/dist/cjs/string/kebab-case.js +0 -15
- package/dist/cjs/string/kebab-case.js.map +0 -1
- package/dist/cjs/string/markdown-to-text.d.ts +0 -2
- package/dist/cjs/string/markdown-to-text.d.ts.map +0 -1
- package/dist/cjs/string/markdown-to-text.js +0 -70
- package/dist/cjs/string/markdown-to-text.js.map +0 -1
- package/dist/cjs/string/remove-html-tags.d.ts +0 -2
- package/dist/cjs/string/remove-html-tags.d.ts.map +0 -1
- package/dist/cjs/string/remove-html-tags.js +0 -18
- package/dist/cjs/string/remove-html-tags.js.map +0 -1
- package/dist/cjs/string/slugify.d.ts +0 -2
- package/dist/cjs/string/slugify.d.ts.map +0 -1
- package/dist/cjs/string/slugify.js +0 -13
- package/dist/cjs/string/slugify.js.map +0 -1
- package/dist/cjs/string/snake-case.d.ts +0 -2
- package/dist/cjs/string/snake-case.d.ts.map +0 -1
- package/dist/cjs/string/snake-case.js +0 -15
- package/dist/cjs/string/snake-case.js.map +0 -1
- package/dist/cjs/string/to-sentence-case.d.ts +0 -2
- package/dist/cjs/string/to-sentence-case.d.ts.map +0 -1
- package/dist/cjs/string/to-sentence-case.js +0 -13
- package/dist/cjs/string/to-sentence-case.js.map +0 -1
- package/dist/cjs/string/truncate.d.ts +0 -2
- package/dist/cjs/string/truncate.d.ts.map +0 -1
- package/dist/cjs/string/truncate.js +0 -19
- package/dist/cjs/string/truncate.js.map +0 -1
- package/dist/cjs/string.js +0 -1
- package/dist/cjs/youtube/extract-youtube-video-id.d.ts +0 -2
- package/dist/cjs/youtube/extract-youtube-video-id.d.ts.map +0 -1
- package/dist/cjs/youtube/extract-youtube-video-id.js +0 -30
- package/dist/cjs/youtube/extract-youtube-video-id.js.map +0 -1
- package/dist/cjs/youtube/generate-youtube-url.d.ts +0 -20
- package/dist/cjs/youtube/generate-youtube-url.d.ts.map +0 -1
- package/dist/cjs/youtube/generate-youtube-url.js +0 -86
- package/dist/cjs/youtube/generate-youtube-url.js.map +0 -1
- package/dist/cjs/youtube/get-video-duration.d.ts +0 -7
- package/dist/cjs/youtube/get-video-duration.d.ts.map +0 -1
- package/dist/cjs/youtube/get-video-duration.js +0 -150
- package/dist/cjs/youtube/get-video-duration.js.map +0 -1
- package/dist/cjs/youtube/get-youtube-thumbnail.d.ts +0 -2
- package/dist/cjs/youtube/get-youtube-thumbnail.d.ts.map +0 -1
- package/dist/cjs/youtube/get-youtube-thumbnail.js +0 -68
- package/dist/cjs/youtube/get-youtube-thumbnail.js.map +0 -1
- package/dist/cjs/youtube/get-youtube-video-info.d.ts +0 -26
- package/dist/cjs/youtube/get-youtube-video-info.d.ts.map +0 -1
- package/dist/cjs/youtube/get-youtube-video-info.js +0 -244
- package/dist/cjs/youtube/get-youtube-video-info.js.map +0 -1
- package/dist/cjs/youtube/index.d.ts +0 -7
- package/dist/cjs/youtube/index.d.ts.map +0 -1
- package/dist/cjs/youtube/index.js +0 -23
- package/dist/cjs/youtube/index.js.map +0 -1
- package/dist/cjs/youtube/validate-youtube-link.d.ts +0 -2
- package/dist/cjs/youtube/validate-youtube-link.d.ts.map +0 -1
- package/dist/cjs/youtube/validate-youtube-link.js +0 -77
- package/dist/cjs/youtube/validate-youtube-link.js.map +0 -1
- package/dist/cjs/youtube.js +0 -1
- package/dist/date/dayjs.d.ts +0 -20
- package/dist/date/dayjs.d.ts.map +0 -1
- package/dist/date/fix-timezone-offset.d.ts +0 -3
- package/dist/date/fix-timezone-offset.d.ts.map +0 -1
- package/dist/date/format-date.d.ts +0 -23
- package/dist/date/format-date.d.ts.map +0 -1
- package/dist/date/get-current-date-in-utc.d.ts +0 -3
- package/dist/date/get-current-date-in-utc.d.ts.map +0 -1
- package/dist/date/get-date-in-utc.d.ts +0 -3
- package/dist/date/get-date-in-utc.d.ts.map +0 -1
- package/dist/date/get-relative-time.d.ts +0 -3
- package/dist/date/get-relative-time.d.ts.map +0 -1
- package/dist/date/index.d.ts.map +0 -1
- package/dist/date/parse-time-spent.d.ts +0 -15
- package/dist/date/parse-time-spent.d.ts.map +0 -1
- package/dist/esm/api/client.js +0 -143
- package/dist/esm/api/index.js +0 -1
- package/dist/esm/api/wrapper.js +0 -148
- package/dist/esm/array/index.js +0 -2
- package/dist/esm/array/shuffle.js +0 -12
- package/dist/esm/array/unique.js +0 -3
- package/dist/esm/array.js +0 -1
- package/dist/esm/date/dayjs.js +0 -111
- package/dist/esm/date/fix-timezone-offset.js +0 -5
- package/dist/esm/date/format-date.js +0 -67
- package/dist/esm/date/get-current-date-in-utc.js +0 -4
- package/dist/esm/date/get-date-in-utc.js +0 -4
- package/dist/esm/date/get-relative-time.js +0 -4
- package/dist/esm/date/index.js +0 -7
- package/dist/esm/date/parse-time-spent.js +0 -203
- package/dist/esm/date.js +0 -1
- package/dist/esm/files/compress-image.js +0 -57
- package/dist/esm/files/download-url.js +0 -24
- package/dist/esm/files/file-delete.js +0 -12
- package/dist/esm/files/file-exists.js +0 -10
- package/dist/esm/files/format-bytes.js +0 -13
- package/dist/esm/files/index.js +0 -5
- package/dist/esm/files.js +0 -1
- package/dist/esm/function/debounce.js +0 -22
- package/dist/esm/function/index.js +0 -3
- package/dist/esm/function/throttle.js +0 -32
- package/dist/esm/function/try-catch.js +0 -35
- package/dist/esm/function.js +0 -1
- package/dist/esm/index.js +0 -7
- package/dist/esm/string/camel-case.js +0 -21
- package/dist/esm/string/capitalize.js +0 -9
- package/dist/esm/string/format-hms-to-seconds.js +0 -25
- package/dist/esm/string/format-seconds-to-fragment.js +0 -15
- package/dist/esm/string/format-seconds-to-hms.js +0 -13
- package/dist/esm/string/format-string-to-time.js +0 -10
- package/dist/esm/string/index.js +0 -13
- package/dist/esm/string/kebab-case.js +0 -11
- package/dist/esm/string/markdown-to-text.js +0 -66
- package/dist/esm/string/remove-html-tags.js +0 -14
- package/dist/esm/string/slugify.js +0 -9
- package/dist/esm/string/snake-case.js +0 -11
- package/dist/esm/string/to-sentence-case.js +0 -9
- package/dist/esm/string/truncate.js +0 -15
- package/dist/esm/string.js +0 -1
- package/dist/esm/youtube/extract-youtube-video-id.js +0 -26
- package/dist/esm/youtube/generate-youtube-url.js +0 -81
- package/dist/esm/youtube/get-video-duration.js +0 -146
- package/dist/esm/youtube/get-youtube-thumbnail.js +0 -31
- package/dist/esm/youtube/get-youtube-video-info.js +0 -207
- package/dist/esm/youtube/index.js +0 -6
- package/dist/esm/youtube/validate-youtube-link.js +0 -40
- package/dist/esm/youtube.js +0 -1
- package/dist/files/compress-image.d.ts +0 -10
- package/dist/files/compress-image.d.ts.map +0 -1
- package/dist/files/download-url.d.ts +0 -2
- package/dist/files/download-url.d.ts.map +0 -1
- package/dist/files/file-delete.d.ts +0 -2
- package/dist/files/file-delete.d.ts.map +0 -1
- package/dist/files/file-exists.d.ts +0 -2
- package/dist/files/file-exists.d.ts.map +0 -1
- package/dist/files/format-bytes.d.ts +0 -2
- package/dist/files/format-bytes.d.ts.map +0 -1
- package/dist/files/index.d.ts.map +0 -1
- package/dist/function/debounce.d.ts +0 -11
- package/dist/function/debounce.d.ts.map +0 -1
- package/dist/function/index.d.ts.map +0 -1
- package/dist/function/throttle.d.ts +0 -10
- package/dist/function/throttle.d.ts.map +0 -1
- package/dist/function/try-catch.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/string/camel-case.d.ts +0 -2
- package/dist/string/camel-case.d.ts.map +0 -1
- package/dist/string/capitalize.d.ts +0 -2
- package/dist/string/capitalize.d.ts.map +0 -1
- package/dist/string/format-hms-to-seconds.d.ts +0 -2
- package/dist/string/format-hms-to-seconds.d.ts.map +0 -1
- package/dist/string/format-seconds-to-fragment.d.ts +0 -3
- package/dist/string/format-seconds-to-fragment.d.ts.map +0 -1
- package/dist/string/format-seconds-to-hms.d.ts +0 -2
- package/dist/string/format-seconds-to-hms.d.ts.map +0 -1
- package/dist/string/format-string-to-time.d.ts +0 -2
- package/dist/string/format-string-to-time.d.ts.map +0 -1
- package/dist/string/index.d.ts.map +0 -1
- package/dist/string/kebab-case.d.ts +0 -2
- package/dist/string/kebab-case.d.ts.map +0 -1
- package/dist/string/markdown-to-text.d.ts +0 -2
- package/dist/string/markdown-to-text.d.ts.map +0 -1
- package/dist/string/remove-html-tags.d.ts +0 -2
- package/dist/string/remove-html-tags.d.ts.map +0 -1
- package/dist/string/slugify.d.ts +0 -2
- package/dist/string/slugify.d.ts.map +0 -1
- package/dist/string/snake-case.d.ts +0 -2
- package/dist/string/snake-case.d.ts.map +0 -1
- package/dist/string/to-sentence-case.d.ts +0 -2
- package/dist/string/to-sentence-case.d.ts.map +0 -1
- package/dist/string/truncate.d.ts +0 -2
- package/dist/string/truncate.d.ts.map +0 -1
- package/dist/youtube/extract-youtube-video-id.d.ts +0 -2
- package/dist/youtube/extract-youtube-video-id.d.ts.map +0 -1
- package/dist/youtube/generate-youtube-url.d.ts +0 -20
- package/dist/youtube/generate-youtube-url.d.ts.map +0 -1
- package/dist/youtube/get-video-duration.d.ts +0 -7
- package/dist/youtube/get-video-duration.d.ts.map +0 -1
- package/dist/youtube/get-youtube-thumbnail.d.ts +0 -2
- package/dist/youtube/get-youtube-thumbnail.d.ts.map +0 -1
- package/dist/youtube/get-youtube-video-info.d.ts +0 -26
- package/dist/youtube/get-youtube-video-info.d.ts.map +0 -1
- package/dist/youtube/index.d.ts.map +0 -1
- package/dist/youtube/validate-youtube-link.d.ts +0 -2
- package/dist/youtube/validate-youtube-link.d.ts.map +0 -1
|
@@ -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
|
-
}
|
package/dist/esm/youtube.js
DELETED
|
@@ -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 +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 +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 +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 +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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/function/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type TAnyFunction = (...args: unknown[]) => unknown;
|
|
2
|
-
/**
|
|
3
|
-
* Creates a throttled function that only invokes func at most once per every delay milliseconds
|
|
4
|
-
* @param fn - The function to throttle
|
|
5
|
-
* @param delay - The number of milliseconds to throttle invocations to
|
|
6
|
-
* @returns The throttled function
|
|
7
|
-
*/
|
|
8
|
-
export declare function throttle<T extends TAnyFunction>(fn: T, delay: number): (...args: Parameters<T>) => void;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=throttle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../src/function/throttle.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAA;AAEnD;;;;;GAKG;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,CA+BlC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"try-catch.d.ts","sourceRoot":"","sources":["../../src/function/try-catch.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAE,CAAA;AAC3C,KAAK,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,IAAI;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAA;AAElD,MAAM,MAAM,eAAe,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,IAAI,IAC9C,QAAQ,CAAC,CAAC,CAAC,GACX,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAElB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,IAAI,EACnD,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EACvC,WAAW,CAAC,EAAE,CAAC,GACd,OAAO,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAa3D"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"camel-case.d.ts","sourceRoot":"","sources":["../../src/string/camel-case.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA0B7C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capitalize.d.ts","sourceRoot":"","sources":["../../src/string/capitalize.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAU9C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format-hms-to-seconds.d.ts","sourceRoot":"","sources":["../../src/string/format-hms-to-seconds.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,GAAG,MAAM,KAAG,MAAM,GAAG,IAoBnE,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format-seconds-to-fragment.d.ts","sourceRoot":"","sources":["../../src/string/format-seconds-to-fragment.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,eAAO,MAAM,uBAAuB,GAAI,MAAM,MAAM,KAAG,MAUtD,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format-seconds-to-hms.d.ts","sourceRoot":"","sources":["../../src/string/format-seconds-to-hms.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAc/D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format-string-to-time.d.ts","sourceRoot":"","sources":["../../src/string/format-string-to-time.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,WAU7C,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,yBAAyB,CAAA;AACvC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kebab-case.d.ts","sourceRoot":"","sources":["../../src/string/kebab-case.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAW7C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-to-text.d.ts","sourceRoot":"","sources":["../../src/string/markdown-to-text.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAsFvD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove-html-tags.d.ts","sourceRoot":"","sources":["../../src/string/remove-html-tags.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAepD"}
|
package/dist/string/slugify.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"slugify.d.ts","sourceRoot":"","sources":["../../src/string/slugify.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ5C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"snake-case.d.ts","sourceRoot":"","sources":["../../src/string/snake-case.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAW7C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"to-sentence-case.d.ts","sourceRoot":"","sources":["../../src/string/to-sentence-case.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,UAQzC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"truncate.d.ts","sourceRoot":"","sources":["../../src/string/truncate.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAQ,GAAG,MAAM,CAkB5E"}
|