UNPKG

webfont-awesome-pro

Version:
305 lines (256 loc) 13.3 kB
import $hSjDC$chalk from "chalk"; import $hSjDC$readline from "readline"; import {Downloader as $hSjDC$Downloader} from "nodejs-file-downloader"; import $hSjDC$fs from "fs"; import $hSjDC$postcss from "postcss"; import $hSjDC$postcsssafeparser from "postcss-safe-parser"; function $parcel$interopDefault(a) { return a && a.__esModule ? a.default : a; } function $a777439b98e3ff1b$export$2e2bcd8739ae039(ms = 500, n = 5) { return new Promise((resolve)=>setTimeout(resolve, ms - n)); } function $eb80b25db258156d$export$db9f06b5d27d15d8(text) { return new Promise((resolve)=>{ const rl = (0, $hSjDC$readline).createInterface({ input: process.stdin, output: process.stdout }); rl.question(text, (anwer)=>{ resolve(anwer); rl.close(); }); }); } async function $1208536e777ab3f1$export$2e2bcd8739ae039() { console.log("--------"); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(1000); console.log(" "); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(100); console.log(`Set the ${(0, $hSjDC$chalk).cyan("Download Path")}!`); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(100); console.log("--------"); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(100); console.log("Download path can be " + (0, $hSjDC$chalk).cyan("`path/to/your/public/folder`") + " or " + (0, $hSjDC$chalk).cyan("`anything`") + "."); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(100); console.log("--------"); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(100); console.log("if the path does not exist, it will be created automatically."); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(500); console.log("--------"); const dir = await (0, $eb80b25db258156d$export$db9f06b5d27d15d8)(`Enter download path: ${(0, $hSjDC$chalk).bold.cyan("(fapro)")} `); const useDir = dir ? dir : "fapro"; console.log((0, $hSjDC$chalk).bold.cyan(`${useDir}`) + `${dir ? "" : " (default)"}`); console.log("--------"); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(750); console.log(" "); console.log((0, $hSjDC$chalk).bgYellow.black(" -- Preparing Downloader -- ")); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(2250); console.log(" "); return { useDir: useDir }; } async function $fb617e32957cfdd1$export$75ad550fa5fe1d36(dirpath) { let curpath = "."; const dirs = dirpath.split("/"); for (const dir of dirs){ curpath += `/${dir}`; if (!(0, $hSjDC$fs).existsSync(curpath)) { (0, $hSjDC$fs).mkdirSync(curpath); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(100); } } } let $79f93e09d37d22af$var$filesDownloaded = []; async function $79f93e09d37d22af$export$bb3b75778e3e272(fileurl, filedir, progress = null) { await (0, $fb617e32957cfdd1$export$75ad550fa5fe1d36)(`${filedir}`); const downloader = new (0, $hSjDC$Downloader)({ url: fileurl, directory: `./${filedir}`, cloneFiles: false }); try { await downloader.download(); const fileorigin = fileurl.split("/"); const filename = fileorigin[fileorigin.length - 1]; console.log(`\u{1F680} ${progress ? (0, $hSjDC$chalk).yellow(progress) + " " : ""}${filename}`); $79f93e09d37d22af$var$filesDownloaded.push(filename); } catch (_error) { throw new Error((0, $hSjDC$chalk).red("The version you wanted to download is not available. Please use other release version.")); } } function $79f93e09d37d22af$export$8de8b92fd301c83e() { const files = [ ...$79f93e09d37d22af$var$filesDownloaded ]; $79f93e09d37d22af$var$filesDownloaded = []; return files; } async function $ccfdb89c88d6a2d0$export$2e2bcd8739ae039(useVer, useDir, fontlist) { console.log("--------"); console.log(`\u{1F557} Downloading All Stylesheets`); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(2000); const dir = `${useDir}/css`; for(let i = 0; i < fontlist.length; i++){ const url = fontlist[i]; const progress = `[${i + 1}/${fontlist.length}]`; await (0, $79f93e09d37d22af$export$bb3b75778e3e272)(url, dir, progress); } console.log((0, $hSjDC$chalk).greenBright("\u2705 Stylesheets Downloaded")); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(2000); return (0, $79f93e09d37d22af$export$8de8b92fd301c83e)(); } let $1ffd869ab3f86381$var$fontUrls = []; async function $1ffd869ab3f86381$export$85c953af022fd6f3(filename, filedir) { const css = (0, $hSjDC$fs).readFileSync(`./${filedir}/${filename}`, "utf8"); (0, $hSjDC$postcss)().process(css, { parser: (0, $hSjDC$postcsssafeparser), from: undefined }).then((result)=>{ result.root.walkAtRules("font-face", (rule)=>{ rule.walkDecls("src", (decl)=>{ const matches = decl.value.match(/url\(([^)]+)\)/g); if (matches) matches.forEach((url)=>{ const cleanUrl = url.replace(/url\(["']?/, "").replace(/["']?\)/, ""); $1ffd869ab3f86381$var$fontUrls.push(cleanUrl); }); }); }); }); } function $1ffd869ab3f86381$export$cbcfe4007f417765() { const fixedFonts = [ ...$1ffd869ab3f86381$var$fontUrls ]; $1ffd869ab3f86381$var$fontUrls = []; return fixedFonts; } async function $9ff909d4a69662c1$export$ae70b50decb7cf58(sheets, useDir) { console.log("--------"); console.log("\uD83D\uDD57 Reading Available Webfonts"); const dir = `${useDir}/css`; for (const sheet of sheets)await (0, $1ffd869ab3f86381$export$85c953af022fd6f3)(sheet, dir); const fonts = (0, $1ffd869ab3f86381$export$cbcfe4007f417765)(); console.log("\u2705 Found " + (0, $hSjDC$chalk).green(fonts.length.toString()) + " Webfonts"); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(2000); return fonts; } async function $9ff909d4a69662c1$export$6c18a7d4cf131851(fonts, filedir, baseUrl) { const dir = `${filedir}/webfonts`; await (0, $fb617e32957cfdd1$export$75ad550fa5fe1d36)(dir); const fonturl = baseUrl; console.log("--------"); console.log("\uD83D\uDD57 Downloading All Webfonts"); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(2000); for(let i = 0; i < fonts.length; i++){ const font = fonts[i].replace("..", ""); const url = `${fonturl}${font}`; const progress = `[${i + 1}/${fonts.length}]`; await (0, $79f93e09d37d22af$export$bb3b75778e3e272)(url, dir, progress); } console.log((0, $hSjDC$chalk).greenBright("\u2705 Webfonts Downloaded")); } var $2fec5fa9afe64cbe$exports = {}; $2fec5fa9afe64cbe$exports = JSON.parse("{\"version\":\"7.0.0\",\"root\":\"https://site-assets.fontawesome.com/releases/v7.0.0\",\"css\":[\"fontawesome.css\",\"whiteboard-semibold.css\",\"thumbprint-light.css\",\"slab-press-regular.css\",\"slab-regular.css\",\"sharp-duotone-thin.css\",\"sharp-duotone-solid.css\",\"sharp-duotone-regular.css\",\"sharp-duotone-light.css\",\"sharp-thin.css\",\"sharp-solid.css\",\"sharp-regular.css\",\"sharp-light.css\",\"notdog-duo-solid.css\",\"notdog-solid.css\",\"jelly-fill-regular.css\",\"jelly-duo-regular.css\",\"jelly-regular.css\",\"etch-solid.css\",\"duotone-thin.css\",\"duotone.css\",\"duotone-regular.css\",\"duotone-light.css\",\"thin.css\",\"solid.css\",\"regular.css\",\"light.css\",\"brands.css\",\"chisel-regular.css\"]}"); async function $6057a7b12f1c52d2$var$getVersion() { const url = `https://raw.githubusercontent.com/devanka761/webfont-awesome-pro/refs/heads/master/src/json/fonts.json?ts=${Date.now().toString(36)}`; return await fetch(url, { method: "GET" }).then((res)=>res.json()).then((res)=>{ console.log(`\u{2705} Found: v${res.version}`); return res; }).catch(()=>{ console.log(`\u{26D4} Error getting the latest version!`); console.log(`\u{26D4} Forced Using v${(0, (/*@__PURE__*/$parcel$interopDefault($2fec5fa9afe64cbe$exports))).version}`); return 0, (/*@__PURE__*/$parcel$interopDefault($2fec5fa9afe64cbe$exports)); }); } async function $6057a7b12f1c52d2$export$2e2bcd8739ae039() { console.log("--------"); console.log("\uD83D\uDD57 Checking Latest Version"); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(1000); const curFonts = await $6057a7b12f1c52d2$var$getVersion(); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(100); console.log("--------"); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(1000); console.log(" "); console.log((0, $hSjDC$chalk).bgGreen.black(` -- Downloading Version ${curFonts.version} of Font Awesome ${curFonts.version.split(".")[0]} Pro -- `)); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(1000); console.log(" "); console.log("--------"); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(100); console.log("\uD83D\uDD57 Reading Available Stylesheets"); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(500); const fontlist = curFonts.css.map((file)=>`${curFonts.root}/css/${file}`); console.log("\u2705 Found " + (0, $hSjDC$chalk).green(fontlist.length.toString()) + " Sytlesheets"); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(2000); return { fontlist: fontlist, useVer: curFonts.version, baseUrl: curFonts.root }; } async function $763cbf9c5fe61a09$export$2e2bcd8739ae039() { console.log((0, $hSjDC$chalk).bgCyan.black(" -- Font Awesome Pro Downloader | Devanka761 -- ")); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(500); console.log(""); console.log("--------"); console.log(`Font Awesome Pro Downloader was made for ${(0, $hSjDC$chalk).yellow("educational purposes")} only!`); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(100); console.log("--------"); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(100); console.log(`This downloader provides ${(0, $hSjDC$chalk).bold.green("Paid version")} for the latest Official Package. It is intended for ${(0, $hSjDC$chalk).yellow("experimental")} and ${(0, $hSjDC$chalk).yellow("personal use")} only. It is ${(0, $hSjDC$chalk).red("not licensed")} for commercial use.`); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(100); console.log("--------"); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(100); console.log(`To unlock commercial use and get an official product license, please consider to go to the ${(0, $hSjDC$chalk).green("Font Awesome")} webiste: ${(0, $hSjDC$chalk).green("https://fontawesome.com/plans")}`); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(100); console.log("--------"); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(500); let agree = await (0, $eb80b25db258156d$export$db9f06b5d27d15d8)(`Continue to download? (${(0, $hSjDC$chalk).cyan("Y")}/n) `); agree = agree ? agree.toLowerCase() : "y"; const notAgrees = [ "no", "n", "nope" ]; const isOk = notAgrees.find((textNo)=>textNo === agree) ? false : true; console.log((0, $hSjDC$chalk).cyan(isOk ? "y" : "n")); if (!isOk) { console.log("--------"); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(1000); console.log((0, $hSjDC$chalk).red("\u26D4 Font Awesome Pro Downloader Canceled")); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(1000); console.log((0, $hSjDC$chalk).bgRed.black(" --- DONE --- ")); } return { isOk: isOk }; } async function $eb17f609fec572d7$var$startDownloader() { await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(100); console.clear(); const { isOk: isOk } = await (0, $763cbf9c5fe61a09$export$2e2bcd8739ae039)(); if (!isOk) return; const { useDir: useDir } = await (0, $1208536e777ab3f1$export$2e2bcd8739ae039)(); const { fontlist: fontlist, useVer: useVer, baseUrl: baseUrl } = await (0, $6057a7b12f1c52d2$export$2e2bcd8739ae039)(); const cssUrls = await (0, $ccfdb89c88d6a2d0$export$2e2bcd8739ae039)(useVer, useDir, fontlist); const fontUrls = await (0, $9ff909d4a69662c1$export$ae70b50decb7cf58)(cssUrls, useDir); await (0, $9ff909d4a69662c1$export$6c18a7d4cf131851)(fontUrls, useDir, baseUrl); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(2000); console.log("--------"); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(1000); console.log((0, $hSjDC$chalk).green(`\u{2705} Font Awesome ${useVer.split(".")[0]} Pro v${useVer} Downloaded Successfully!`)); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(1000); console.log((0, $hSjDC$chalk).bgGreen.black(" --- DONE --- ")); await (0, $a777439b98e3ff1b$export$2e2bcd8739ae039)(2000); } function $eb17f609fec572d7$export$c0a0c3a161860b55() { $eb17f609fec572d7$var$startDownloader(); } function $eb17f609fec572d7$export$89ae034f08762d55() { $eb17f609fec572d7$var$startDownloader(); } export {$eb17f609fec572d7$export$c0a0c3a161860b55 as getFontAwesomePro, $eb17f609fec572d7$export$89ae034f08762d55 as getFapro}; //# sourceMappingURL=module.mjs.map