UNPKG

yugioh-card

Version:

<h1 align="center">🎉 游戏王卡片 - Yugioh Card 🎉</h1>

48 lines (47 loc) 1.69 kB
import { isPlainObject as e } from "lodash-unified"; //#region packages/src/utils/index.js var t = [], n = null, r = typeof window < "u" && window.document !== void 0, i = typeof process < "u" && process.versions != null && process.versions.node != null, a = () => { if (!i) throw Error("fs is not available in browser builds"); if (n ||= process.getBuiltinModule?.("node:fs") ?? process.getBuiltinModule?.("fs"), !n) throw Error("fs is not available in the current Node.js runtime"); return n; }, o = (e) => new Promise((n, r) => { if (t.includes(e)) { n(); return; } t.push(e), fetch(`${e}/font-list.json`).then((e) => { if (e.ok) return e.json(); throw Error(); }).then(async (t) => { let r = []; t.forEach((t) => { let n = new FontFace(t, `url(${e}/${t}.woff2) format('woff2')`, { display: "swap" }); document.fonts.add(n), r.push(n); }); let i = r.map((e) => e.load()); await Promise.allSettled(i), n(); }).catch(() => { r("读取字体失败"); }); }), s = (e, n) => { if (t.includes(e)) return; t.push(e); let r = JSON.parse(a().readFileSync(`${e}/font-list.json`, "utf-8")); n && r.forEach((t) => { n.FontLibrary.use(t, [`${e}/${t}.woff2`]); }); }, c = (e) => e.replace(/\d/g, (e) => String.fromCharCode(e.charCodeAt(0) + 65248)), l = (t, n = {}) => ([ "fontFamily", "fontSize", "fontStyle", "fontWeight", "lineHeight", "letterSpacing", "wordSpacing" ].forEach((e) => { !Object.hasOwn(t, e) && Object.hasOwn(n, e) && (t[e] = n[e]); }), Object.keys(t).forEach((n) => { e(t[n]) && l(t[n], t); }), t); //#endregion export { l as inheritProp, r as isBrowser, i as isNode, o as loadFontBrowser, s as loadFontNode, c as numberToFull };