@spzxg/cli-ui 0.6.0 → 0.6.2

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.
@@ -0,0 +1,26 @@
1
+ import { a } from "./cli-ui-embed-6IJ_jRVh.js";
2
+ import { r as p } from "./cli-ui-jszip.min-BZsUwI-s.js";
3
+ function f(t, n) {
4
+ for (var o = 0; o < n.length; o++) {
5
+ const e = n[o];
6
+ if (typeof e != "string" && !Array.isArray(e)) {
7
+ for (const r in e)
8
+ if (r !== "default" && !(r in t)) {
9
+ const i = Object.getOwnPropertyDescriptor(e, r);
10
+ i && Object.defineProperty(t, r, i.get ? i : {
11
+ enumerable: !0,
12
+ get: () => e[r]
13
+ });
14
+ }
15
+ }
16
+ }
17
+ return Object.freeze(Object.defineProperty(t, Symbol.toStringTag, { value: "Module" }));
18
+ }
19
+ var s = p();
20
+ const c = /* @__PURE__ */ a(s), l = /* @__PURE__ */ f({
21
+ __proto__: null,
22
+ default: c
23
+ }, [s]);
24
+ export {
25
+ l as j
26
+ };
@@ -0,0 +1,93 @@
1
+ const I = "http://schemas.openxmlformats.org/spreadsheetml/2006/main", X = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", j = /* @__PURE__ */ new Set([14, 15, 16, 17, 18, 19, 20, 21, 22, 27, 30, 36, 45, 46, 47, 50, 57]), b = (e) => new DOMParser().parseFromString(e, "application/xml"), g = (e, t) => Array.from(e.getElementsByTagNameNS(I, t));
2
+ function _(e) {
3
+ let t = 0;
4
+ for (const n of e) {
5
+ const o = n.toUpperCase().charCodeAt(0);
6
+ if (o < 65 || o > 90) break;
7
+ t = t * 26 + (o - 64);
8
+ }
9
+ return t - 1;
10
+ }
11
+ function B(e) {
12
+ const t = e.replace(/"[^"]*"/g, "").replace(/\[[^\]]*\]/g, "").replace(/\\./g, "");
13
+ return /[ymdhs]/i.test(t) && !/^[#0.,%E+\-\s]*$/i.test(t);
14
+ }
15
+ function L(e) {
16
+ const t = Math.round((e - 25569) * 864e5), n = new Date(t);
17
+ if (Number.isNaN(n.getTime())) return String(e);
18
+ const o = (w) => String(w).padStart(2, "0"), m = `${n.getUTCFullYear()}-${o(n.getUTCMonth() + 1)}-${o(n.getUTCDate())}`;
19
+ if (!(n.getUTCHours() * 3600 + n.getUTCMinutes() * 60 + n.getUTCSeconds())) return m;
20
+ const d = `${o(n.getUTCHours())}:${o(n.getUTCMinutes())}${n.getUTCSeconds() ? `:${o(n.getUTCSeconds())}` : ""}`;
21
+ return e < 1 ? d : `${m} ${d}`;
22
+ }
23
+ function v(e) {
24
+ return g(e, "t").filter((t) => {
25
+ var n;
26
+ return ((n = t.parentElement) == null ? void 0 : n.localName) !== "rPh";
27
+ }).map((t) => t.textContent ?? "").join("");
28
+ }
29
+ async function R(e) {
30
+ var E;
31
+ const t = await import("./cli-ui-jszip.min-m01fexHW.js").then((s) => s.j), o = await (t.default ?? t).loadAsync(e), m = async (s) => {
32
+ const a = o.file(s);
33
+ return a ? a.async("string") : null;
34
+ }, S = await m("xl/workbook.xml");
35
+ if (!S) throw new Error("不是 Excel 工作簿");
36
+ const d = /* @__PURE__ */ new Map(), w = await m("xl/_rels/workbook.xml.rels");
37
+ if (w)
38
+ for (const s of Array.from(b(w).getElementsByTagName("Relationship"))) {
39
+ const a = s.getAttribute("Target") ?? "";
40
+ d.set(s.getAttribute("Id") ?? "", a.startsWith("/") ? a.slice(1) : `xl/${a}`);
41
+ }
42
+ const T = [], $ = await m("xl/sharedStrings.xml");
43
+ if ($) for (const s of g(b($), "si")) T.push(v(s));
44
+ const y = /* @__PURE__ */ new Set(), C = /* @__PURE__ */ new Set(), U = await m("xl/styles.xml");
45
+ if (U) {
46
+ const s = b(U), a = new Map(g(s, "numFmt").map((l) => [Number(l.getAttribute("numFmtId")), l.getAttribute("formatCode") ?? ""])), N = g(s, "cellXfs")[0];
47
+ N && Array.from(N.children).filter((l) => l.localName === "xf").forEach((l, h) => {
48
+ const i = Number(l.getAttribute("numFmtId") ?? 0), r = a.get(i);
49
+ j.has(i) || r !== void 0 && B(r) ? y.add(h) : (i === 9 || i === 10 || r !== void 0 && r.replace(/"[^"]*"/g, "").includes("%")) && C.add(h);
50
+ });
51
+ }
52
+ const x = [];
53
+ for (const s of g(b(S), "sheet")) {
54
+ const a = s.getAttribute("name") ?? `Sheet${x.length + 1}`, N = d.get(s.getAttributeNS(X, "id") ?? s.getAttribute("r:id") ?? "") ?? `xl/worksheets/sheet${x.length + 1}.xml`, l = await m(N);
55
+ if (!l) continue;
56
+ const h = [];
57
+ for (const r of g(b(l), "row")) {
58
+ const D = Number(r.getAttribute("r")) || h.length + 1, F = [];
59
+ let M = 0;
60
+ for (const u of Array.from(r.children).filter((A) => A.localName === "c")) {
61
+ const A = u.getAttribute("r"), k = A ? _(A) : M;
62
+ M = k + 1;
63
+ const p = u.getAttribute("t"), c = ((E = g(u, "v")[0]) == null ? void 0 : E.textContent) ?? "";
64
+ let f;
65
+ p === "s" ? f = T[Number(c)] ?? "" : p === "inlineStr" ? f = v(u) : p === "b" ? f = c === "1" ? "TRUE" : c === "0" ? "FALSE" : c : p === "str" || p === "e" || !c ? f = c : y.has(Number(u.getAttribute("s") ?? -1)) && Number.isFinite(Number(c)) ? f = L(Number(c)) : C.has(Number(u.getAttribute("s") ?? -1)) && Number.isFinite(Number(c)) ? f = `${Number((Number(c) * 100).toPrecision(12))}%` : f = c, F[k] = f;
66
+ }
67
+ h[D - 1] = Array.from(F, (u) => u ?? "");
68
+ }
69
+ const i = Array.from(h, (r) => r ?? []);
70
+ for (; i.length && i[i.length - 1].every((r) => !r); ) i.pop();
71
+ for (const r of i) for (; r.length && !r[r.length - 1]; ) r.pop();
72
+ x.push({ name: a, hidden: (s.getAttribute("state") ?? "visible") !== "visible", rows: i });
73
+ }
74
+ return x;
75
+ }
76
+ const P = (e) => /[",\n\r]/.test(e) ? `"${e.replace(/"/g, '""')}"` : e;
77
+ function H(e) {
78
+ return e.map((t) => {
79
+ const n = `## 工作表:${t.name}${t.hidden ? "(隐藏)" : ""}(${t.rows.length} 行)`;
80
+ return t.rows.length ? `${n}
81
+ ${t.rows.map((o) => o.map(P).join(",")).join(`
82
+ `)}` : `${n}
83
+ (空)`;
84
+ }).join(`
85
+
86
+ `);
87
+ }
88
+ export {
89
+ _ as columnIndex,
90
+ L as excelDate,
91
+ R as readXlsx,
92
+ H as sheetsToText
93
+ };