UNPKG

can-can-word-bug

Version:

can-can-word-bug 是一个 TS 编写的工具库

53 lines (52 loc) 1.64 kB
import { m, c as z } from "../createEl-TLDNe8hm.js"; import y from "./zip.js"; const S = /* @__PURE__ */ (() => { let i = null; return async (e = {}) => { var f; i && ((f = i.parentNode) == null || f.removeChild(i), i = null), e = m( { type: "file", mozdirectory: e.directory, webkitdirectory: e.directory, style: { position: "fixed", left: "0", top: "0", opacity: "0", pointerEvents: "none" } }, e ), i = z("input", e), document.body.appendChild(i), i.dispatchEvent(new MouseEvent("click")); const o = e.multiple || e.directory; return await new Promise((a, n) => { i.onchange = async (s) => { const c = s.target.files; if (!c) return n(new Error("No file selected")); !o && c.length < 1 && n(new Error("No file selected")); const t = Array.from(c); if (e.maxSize) { if (e.checkAllFileSize) { const r = t.reduce((d, u) => d + u.size, 0); if (r > e.maxSize) return n(new Error(`File exceeds limit size:${r} > ${e.maxSize}`)); } else for (const r of t) if (r.size > e.maxSize) return n(new Error(`File exceeds limit size: ${r.size} > ${e.maxSize}`)); } let { zipOpts: l } = e; if (l === !0 && (l = {}), l) { const r = await y(t, l); return a({ fileList: t, zipFile: r }); } if (o) return a(t); if (!o) return a(t[0]); }, i.onerror = n; }); }; })(); export { S as default };