@agile-team/mach-report 2.23.0 → 2.23.1
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/README.md +3 -2
- package/dist/ExcelBindingWizard-BrTmdo7f.cjs +1 -0
- package/dist/ExcelBindingWizard-CcDMLO8Q.js +1486 -0
- package/dist/ParamEditor-BGjovFUe.js +737 -0
- package/dist/ParamEditor-CeNp4_zQ.cjs +1 -0
- package/dist/ReportBatchPanel-CHxBtG9R.cjs +1 -0
- package/dist/ReportBatchPanel-CJB67WNd.js +351 -0
- package/dist/ReportLabelStudio-Tplc1TLJ.js +784 -0
- package/dist/ReportLabelStudio-g8PkqJWn.cjs +1 -0
- package/dist/ReportParamPanel-C7fZTllk.cjs +1 -0
- package/dist/{ReportParamPanel-Dgmqro1Y.js → ReportParamPanel-GI43aGa0.js} +61 -56
- package/dist/{ReportPreview-FFIryrIr.cjs → ReportPreview-BoGBGyRr.cjs} +2 -2
- package/dist/{ReportPreview-DeWzG8jQ.js → ReportPreview-QLONCyci.js} +8 -8
- package/dist/ReportTemplateLibrary-BFQIX0sg.cjs +1 -0
- package/dist/ReportTemplateLibrary-KqX4E2sN.js +312 -0
- package/dist/RuleEditor-BZUP9yvL.cjs +1 -0
- package/dist/RuleEditor-OPX1awrH.js +2342 -0
- package/dist/TemplateOutlinePanel-CVYKVLv_.cjs +1 -0
- package/dist/TemplateOutlinePanel-DQS-eOs6.js +97 -0
- package/dist/TemplateReusePanel-CY6O93Zk.cjs +1 -0
- package/dist/TemplateReusePanel-DKXiFTyB.js +389 -0
- package/dist/TemplateReviewPanel-DbeNC8Ms.cjs +1 -0
- package/dist/TemplateReviewPanel-Dijwm9YE.js +593 -0
- package/dist/artifact-integrity.json +68 -68
- package/dist/{auto-CTIJ6PnR.js → auto-BB99S802.js} +4 -4
- package/dist/{auto-4pK9HePf.cjs → auto-BrPWo7Xm.cjs} +1 -1
- package/dist/designer-BZoVWTgl.js +7172 -0
- package/dist/designer-zS2uKJmY.cjs +2 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +7 -0
- package/dist/designer.d.ts +7 -0
- package/dist/designer.js +2 -2
- package/dist/{encoding-BefcaHdp.cjs → encoding-7lquyj0w.cjs} +1 -1
- package/dist/{encoding-CL6rXEkR.js → encoding-CEd-dq9A.js} +2 -2
- package/dist/{font-loader-BT5baV-o.js → font-loader-CNWXomuV.js} +1 -1
- package/dist/{font-loader-Ga51c2VC.cjs → font-loader-D8pI87fL.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +7 -7
- package/dist/{json-snapshot-OqkPyUk5.js → json-snapshot-BRnzKudk.js} +1 -1
- package/dist/{json-snapshot-1tvQNzQE.cjs → json-snapshot-DNiIbpOr.cjs} +1 -1
- package/dist/{pdf-aobetCsy.js → pdf-CJToa81Z.js} +2 -2
- package/dist/{pdf-HiEeXe9H.cjs → pdf-DpMkW72B.cjs} +1 -1
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.js +2 -2
- package/dist/{plugin-BFANt-i8.cjs → plugin-BWTp-X7b.cjs} +1 -1
- package/dist/{plugin-DeYYAL6F.js → plugin-_BkUVc2z.js} +1 -1
- package/dist/{prefill-Dk4C6S5R.js → prefill-CWGdnqQd.js} +1 -1
- package/dist/{prefill-DsUD5OoK.cjs → prefill-PaAy6wLk.cjs} +1 -1
- package/dist/{prepared-DCIxhKFo.js → prepared-CJy_qk7d.js} +1 -1
- package/dist/{prepared-Dv-XM3i1.cjs → prepared-D0yCSxSO.cjs} +1 -1
- package/dist/{protocol-DxeUKGYG.js → protocol-BG16rz6D.js} +2 -2
- package/dist/{protocol-B9YgfQ_d.cjs → protocol-wzhl1Fim.cjs} +1 -1
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/{runtime-DKlGd_D4.cjs → runtime-DYMOS_gz.cjs} +1 -1
- package/dist/{runtime-75Y5Oq5B.js → runtime-PiCax9zQ.js} +2 -2
- package/dist/sbom.cdx.json +1 -1
- package/dist/server-node.cjs +4 -4
- package/dist/server-node.js +737 -736
- package/dist/server.cjs +1 -1
- package/dist/server.js +5 -5
- package/dist/style.css +1 -1
- package/dist/{template-catalog--cjxzgH7.js → template-catalog-CRuZL3pi.js} +1 -1
- package/dist/{template-catalog-CoT7jm_6.cjs → template-catalog-DtrtT1FY.cjs} +1 -1
- package/dist/textwrap-D4ZksyMK.js +111 -0
- package/dist/textwrap-DEHqAjKZ.cjs +4 -0
- package/dist/vue/async.d.cts +7 -0
- package/dist/vue/async.d.ts +7 -0
- package/dist/vue/index.d.cts +7 -0
- package/dist/vue/index.d.ts +7 -0
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +6 -6
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +4 -4
- package/package.json +1 -1
- package/dist/ExcelBindingWizard-D4FLind-.js +0 -1485
- package/dist/ExcelBindingWizard-D4RS5Bpg.cjs +0 -1
- package/dist/ParamEditor-C-6C9rd2.cjs +0 -1
- package/dist/ParamEditor-CASZt-Ma.js +0 -732
- package/dist/ReportBatchPanel-Bq7t8a5r.js +0 -350
- package/dist/ReportBatchPanel-YVj5IO5y.cjs +0 -1
- package/dist/ReportLabelStudio-Cqhita1b.cjs +0 -1
- package/dist/ReportLabelStudio-Dj7GXhuv.js +0 -783
- package/dist/ReportParamPanel-DZbFVmDL.cjs +0 -1
- package/dist/ReportTemplateLibrary-BaWodmpm.cjs +0 -1
- package/dist/ReportTemplateLibrary-DdAAAD2I.js +0 -311
- package/dist/RuleEditor-D2UwQGF6.js +0 -2341
- package/dist/RuleEditor-DcT9xI1v.cjs +0 -1
- package/dist/TemplateOutlinePanel-CUHFFiNM.cjs +0 -1
- package/dist/TemplateOutlinePanel-DrT7XN0m.js +0 -96
- package/dist/TemplateReusePanel-4eejkNqi.js +0 -388
- package/dist/TemplateReusePanel-DZMyiX5I.cjs +0 -1
- package/dist/TemplateReviewPanel-BIhNLeNw.js +0 -592
- package/dist/TemplateReviewPanel-DnYImiXu.cjs +0 -1
- package/dist/designer-DhrE7jzw.js +0 -7169
- package/dist/designer-IAZu6kBX.cjs +0 -2
- package/dist/textwrap-BIjtEWmq.js +0 -110
- package/dist/textwrap-Cy7o1hIR.cjs +0 -4
package/dist/server-node.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as nt, o as Jn, w as Xi } from "./progress-BXzlVbIp.js";
|
|
2
2
|
import { parentPort as Zt, workerData as Zi, Worker as Qi } from "node:worker_threads";
|
|
3
|
-
import { randomUUID as At, createHash as
|
|
3
|
+
import { randomUUID as At, createHash as Mr } from "node:crypto";
|
|
4
4
|
import { promises as A } from "node:fs";
|
|
5
5
|
import L from "node:path";
|
|
6
|
-
const kt = 1.35,
|
|
6
|
+
const kt = 1.35, vr = 10.5, Vn = '"Microsoft YaHei", sans-serif', es = "1.0.0-mach", Ke = es, Hn = /[\u3000-\u9fff\uff00-\uffef]/, ts = /[ \n\u3000-\u9fff\uff00-\uffef]/, pe = new Uint8Array(128);
|
|
7
7
|
{
|
|
8
8
|
for (const e of "iljtf.,:;'`|!()[]") pe[e.charCodeAt(0)] = 1;
|
|
9
9
|
for (const e of "mwMW@") pe[e.charCodeAt(0)] = 2;
|
|
@@ -11,21 +11,22 @@ const kt = 1.35, Mr = 10.5, Vn = '"Microsoft YaHei", sans-serif', es = "1.0.0-ma
|
|
|
11
11
|
for (let e = 65; e <= 90; e++) pe[e] = 4;
|
|
12
12
|
pe[32] = 5;
|
|
13
13
|
}
|
|
14
|
-
const
|
|
15
|
-
function
|
|
14
|
+
const rs = [0.54, 0.26, 0.95, 0.59, 0.67, 0.3];
|
|
15
|
+
function ns(e) {
|
|
16
16
|
const t = e.charCodeAt(0);
|
|
17
|
-
return t < 128 ?
|
|
17
|
+
return t < 128 ? rs[pe[t]] : Hn.test(e) ? 1 : /[A-Z]/.test(e) ? 0.67 : 0.54;
|
|
18
18
|
}
|
|
19
19
|
const $r = {
|
|
20
20
|
measureMm(e, t) {
|
|
21
21
|
const { fontSizePt: r, bold: n = !1, letterSpacingPt: o = 0 } = t, i = 25.4 / 72;
|
|
22
|
-
let s = 0;
|
|
23
|
-
for (const
|
|
24
|
-
s +=
|
|
25
|
-
return n && (s *= 1.04), (s * r + o * Math.max(0,
|
|
22
|
+
let s = 0, a = 0;
|
|
23
|
+
for (const c of e)
|
|
24
|
+
s += ns(c), a++;
|
|
25
|
+
return n && (s *= 1.04), (s * r + o * Math.max(0, a - 1)) * i;
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
function
|
|
28
|
+
function os(e, t, r) {
|
|
29
|
+
if (!ts.test(e)) return [{ text: e, widthMm: r.measureMm(e, t), cjk: !1 }];
|
|
29
30
|
const n = [];
|
|
30
31
|
let o = "";
|
|
31
32
|
const i = () => {
|
|
@@ -59,7 +60,7 @@ function We(e, t, r, n = $r) {
|
|
|
59
60
|
const a = (r.letterSpacingPt ?? 0) * 25.4 / 72, c = () => {
|
|
60
61
|
o.push(i), i = "", s = 0;
|
|
61
62
|
};
|
|
62
|
-
for (const f of
|
|
63
|
+
for (const f of os(e, r, n)) {
|
|
63
64
|
if (f.br) {
|
|
64
65
|
c();
|
|
65
66
|
continue;
|
|
@@ -86,8 +87,8 @@ function We(e, t, r, n = $r) {
|
|
|
86
87
|
}
|
|
87
88
|
return c(), o;
|
|
88
89
|
}
|
|
89
|
-
const
|
|
90
|
-
function
|
|
90
|
+
const is = 4096, tn = 128 * 1024;
|
|
91
|
+
function ss(e) {
|
|
91
92
|
const t = /* @__PURE__ */ new Map();
|
|
92
93
|
let r = 0;
|
|
93
94
|
return { measureMm(n, o) {
|
|
@@ -96,7 +97,7 @@ function is(e) {
|
|
|
96
97
|
return t.delete(i), t.set(i, s), s;
|
|
97
98
|
const a = e.measureMm(n, o);
|
|
98
99
|
if (Number.isFinite(a) && i.length <= tn) {
|
|
99
|
-
for (; t.size >=
|
|
100
|
+
for (; t.size >= is || r + i.length > tn; ) {
|
|
100
101
|
const c = t.keys().next().value;
|
|
101
102
|
r -= c.length, t.delete(c);
|
|
102
103
|
}
|
|
@@ -207,13 +208,13 @@ function on(e) {
|
|
|
207
208
|
function sn(e) {
|
|
208
209
|
return e == null || e === "";
|
|
209
210
|
}
|
|
210
|
-
function
|
|
211
|
+
function as(e) {
|
|
211
212
|
const t = e.values?.[0] ?? (e.right && "value" in e.right ? e.right.value : e.value);
|
|
212
213
|
return e.valueType ?? e.numeric ?? (typeof t == "number" ? "decimal" : typeof t == "boolean" ? "boolean" : "text");
|
|
213
214
|
}
|
|
214
215
|
function Ye(e, t, r) {
|
|
215
216
|
if (sn(e) || sn(t)) return;
|
|
216
|
-
const n =
|
|
217
|
+
const n = as(r);
|
|
217
218
|
try {
|
|
218
219
|
if (n === "decimal") return it(V(e), V(t));
|
|
219
220
|
if (n === "number")
|
|
@@ -225,7 +226,7 @@ function Ye(e, t, r) {
|
|
|
225
226
|
return;
|
|
226
227
|
}
|
|
227
228
|
}
|
|
228
|
-
function
|
|
229
|
+
function cs(e) {
|
|
229
230
|
if (nn(e.field), ![">", ">=", "<", "<=", "==", "!=", "between", "contains", "isNull", "isNotNull"].includes(e.op)) throw new Error("未知条件运算符");
|
|
230
231
|
if (e.numeric !== void 0 && !["number", "decimal"].includes(e.numeric)) throw new Error("未知条件数值模式");
|
|
231
232
|
if (e.valueType !== void 0 && !["number", "decimal", "text", "date", "boolean"].includes(e.valueType)) throw new Error("未知条件值类型");
|
|
@@ -259,8 +260,8 @@ function zt(e, t) {
|
|
|
259
260
|
return !1;
|
|
260
261
|
}
|
|
261
262
|
}
|
|
262
|
-
function
|
|
263
|
-
|
|
263
|
+
function fs(e) {
|
|
264
|
+
cs(e), e = { ...e, right: e.right ? { ...e.right } : void 0, values: e.values ? [e.values[0], e.values[1]] : void 0 };
|
|
264
265
|
const t = (r, n) => Object.prototype.hasOwnProperty.call(r, n) ? r[n] : void 0;
|
|
265
266
|
return (r) => {
|
|
266
267
|
const n = t(r, e.field);
|
|
@@ -284,9 +285,9 @@ function q(e, t = { nodes: 0 }, r = 0) {
|
|
|
284
285
|
const i = o.map((s) => q(s, t, r + 1));
|
|
285
286
|
return "all" in e ? (s) => i.every((a) => a(s)) : (s) => i.some((a) => a(s));
|
|
286
287
|
}
|
|
287
|
-
return
|
|
288
|
+
return fs(e);
|
|
288
289
|
}
|
|
289
|
-
function
|
|
290
|
+
function us(e) {
|
|
290
291
|
q(e);
|
|
291
292
|
const t = /* @__PURE__ */ new Set();
|
|
292
293
|
function r(n) {
|
|
@@ -305,7 +306,7 @@ function Xn(e) {
|
|
|
305
306
|
return t === void 0 ? e.thousands ? "#,##0.###############" : void 0 : `${e.thousands ? "#,##0" : "0"}${t ? `.${"0".repeat(t)}` : ""}`;
|
|
306
307
|
}
|
|
307
308
|
}
|
|
308
|
-
function
|
|
309
|
+
function ls(e) {
|
|
309
310
|
const t = /^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/.exec(e.trim());
|
|
310
311
|
if (t) {
|
|
311
312
|
const n = new Date(Number(t[1]), Number(t[2]) - 1, Number(t[3]));
|
|
@@ -320,11 +321,11 @@ function tr(e, t) {
|
|
|
320
321
|
maximumFractionDigits: t
|
|
321
322
|
});
|
|
322
323
|
}
|
|
323
|
-
function
|
|
324
|
+
function ds(e, t) {
|
|
324
325
|
const r = (n) => String(n).padStart(2, "0");
|
|
325
326
|
return t.replace(/YYYY/g, String(e.getFullYear())).replace(/MM/g, r(e.getMonth() + 1)).replace(/DD/g, r(e.getDate())).replace(/hh/g, r(e.getHours())).replace(/mm/g, r(e.getMinutes())).replace(/ss/g, r(e.getSeconds()));
|
|
326
327
|
}
|
|
327
|
-
function
|
|
328
|
+
function ms(e, t, r) {
|
|
328
329
|
return r != null ? t ? tr(e, r) : e.toFixed(r) : t ? tr(e) : String(e);
|
|
329
330
|
}
|
|
330
331
|
function an(e) {
|
|
@@ -342,7 +343,7 @@ function Er(e, t) {
|
|
|
342
343
|
return e;
|
|
343
344
|
}
|
|
344
345
|
const r = an(e);
|
|
345
|
-
return r == null ? String(e) :
|
|
346
|
+
return r == null ? String(e) : ms(r, t.thousands === !0, t.digits);
|
|
346
347
|
}
|
|
347
348
|
case "percent": {
|
|
348
349
|
if (typeof e == "string")
|
|
@@ -355,14 +356,14 @@ function Er(e, t) {
|
|
|
355
356
|
return r == null ? String(e) : `${tr(r * 100, t.digits ?? 2)}%`;
|
|
356
357
|
}
|
|
357
358
|
case "date": {
|
|
358
|
-
const r = t.pattern ?? "YYYY-MM-DD", n = e instanceof Date ? e :
|
|
359
|
-
return n ?
|
|
359
|
+
const r = t.pattern ?? "YYYY-MM-DD", n = e instanceof Date ? e : ls(String(e));
|
|
360
|
+
return n ? ds(n, r) : String(e);
|
|
360
361
|
}
|
|
361
362
|
default:
|
|
362
363
|
return String(e);
|
|
363
364
|
}
|
|
364
365
|
}
|
|
365
|
-
const
|
|
366
|
+
const hs = [
|
|
366
367
|
{ name: "add", minArgs: 2, maxArgs: 256, input: "numeric", output: "numeric", example: "add(quantity, adjustment)" },
|
|
367
368
|
{ name: "subtract", minArgs: 2, maxArgs: 2, input: "numeric", output: "numeric", example: "subtract(input, output)" },
|
|
368
369
|
{ name: "multiply", minArgs: 2, maxArgs: 256, input: "numeric", output: "numeric", example: "multiply(quantity, price)" },
|
|
@@ -378,13 +379,13 @@ const ms = [
|
|
|
378
379
|
{ name: "dateYear", minArgs: 1, maxArgs: 1, input: "YYYY-MM-DD", output: "number", example: "dateYear(reportDate)" },
|
|
379
380
|
{ name: "dateMonth", minArgs: 1, maxArgs: 1, input: "YYYY-MM-DD", output: "number", example: "dateMonth(reportDate)" },
|
|
380
381
|
{ name: "dateDay", minArgs: 1, maxArgs: 1, input: "YYYY-MM-DD", output: "number", example: "dateDay(reportDate)" }
|
|
381
|
-
],
|
|
382
|
-
function
|
|
382
|
+
], gs = Object.freeze(hs.map((e) => Object.freeze(e)));
|
|
383
|
+
function ps(e, t, r, n, o) {
|
|
383
384
|
if (t.some((a) => a == null)) {
|
|
384
385
|
if (o === "error") throw new Error("函数参数包含空值");
|
|
385
386
|
return null;
|
|
386
387
|
}
|
|
387
|
-
if (e === "round" || e === "abs") return
|
|
388
|
+
if (e === "round" || e === "abs") return ys(e, t, r, n);
|
|
388
389
|
if (e.startsWith("date")) {
|
|
389
390
|
const a = er(t[0]);
|
|
390
391
|
return Number(a.slice(e === "dateYear" ? 0 : e === "dateMonth" ? 5 : 8, e === "dateYear" ? 4 : e === "dateMonth" ? 7 : 10));
|
|
@@ -395,7 +396,7 @@ function gs(e, t, r, n, o) {
|
|
|
395
396
|
if (s.length > 1e6) throw new Error("计算文本超出长度预算");
|
|
396
397
|
return s;
|
|
397
398
|
}
|
|
398
|
-
function
|
|
399
|
+
function ys(e, t, r, n) {
|
|
399
400
|
const o = t[0];
|
|
400
401
|
if (r !== "decimal" && (typeof o != "number" || !Number.isFinite(o))) throw new Error("普通数值函数需要有限数字");
|
|
401
402
|
const i = V(o);
|
|
@@ -409,7 +410,7 @@ function ps(e, t, r, n) {
|
|
|
409
410
|
if (r !== "decimal" && !Number.isFinite(c)) throw new Error("计算结果不是有限数字");
|
|
410
411
|
return r === "decimal" ? a : c;
|
|
411
412
|
}
|
|
412
|
-
const
|
|
413
|
+
const ws = [
|
|
413
414
|
"sum",
|
|
414
415
|
"count",
|
|
415
416
|
"avg",
|
|
@@ -427,7 +428,7 @@ function cn(e) {
|
|
|
427
428
|
function at(e, t) {
|
|
428
429
|
return t && Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0;
|
|
429
430
|
}
|
|
430
|
-
function
|
|
431
|
+
function bs(e) {
|
|
431
432
|
let t = 0, r = 0, n = 0, o = 0, i = 1 / 0, s = -1 / 0;
|
|
432
433
|
const a = (c) => {
|
|
433
434
|
const f = c - n, u = r + f;
|
|
@@ -458,7 +459,7 @@ function ws(e) {
|
|
|
458
459
|
}
|
|
459
460
|
};
|
|
460
461
|
}
|
|
461
|
-
function
|
|
462
|
+
function xs(e) {
|
|
462
463
|
let t = 0, r = V("0"), n = V("0"), o, i;
|
|
463
464
|
return {
|
|
464
465
|
add(s) {
|
|
@@ -487,21 +488,21 @@ function bs(e) {
|
|
|
487
488
|
function se(e) {
|
|
488
489
|
if (e.digits !== void 0 && ze(e.digits), e.numeric !== void 0 && e.numeric !== "number" && e.numeric !== "decimal")
|
|
489
490
|
throw new Error("未知聚合数值模式");
|
|
490
|
-
if (!
|
|
491
|
+
if (!ws.includes(e.op)) throw new Error("未知聚合操作");
|
|
491
492
|
if (e.op !== "count" && !e.field)
|
|
492
493
|
throw new Error("聚合需要度量字段");
|
|
493
494
|
if (e.op === "weightedAvg" && !e.weightField)
|
|
494
495
|
throw new Error("加权平均需要权重字段");
|
|
495
|
-
return e.numeric === "decimal" ?
|
|
496
|
+
return e.numeric === "decimal" ? xs(e) : bs(e);
|
|
496
497
|
}
|
|
497
498
|
function je(e, t) {
|
|
498
499
|
const r = se(t);
|
|
499
500
|
for (const n of e) r.add(n);
|
|
500
501
|
return r.value();
|
|
501
502
|
}
|
|
502
|
-
const
|
|
503
|
+
const Ms = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
503
504
|
function K(e) {
|
|
504
|
-
if (typeof e != "string" || !e.trim() ||
|
|
505
|
+
if (typeof e != "string" || !e.trim() || Ms.has(e))
|
|
505
506
|
throw new Error("计算字段应为安全的非空字段名");
|
|
506
507
|
}
|
|
507
508
|
function Ar(e) {
|
|
@@ -512,7 +513,7 @@ function vs(e) {
|
|
|
512
513
|
throw new Error("算术参数必须是有限数字;空值和小数文本不会隐式转换");
|
|
513
514
|
return e;
|
|
514
515
|
}
|
|
515
|
-
function
|
|
516
|
+
function $s(e, t) {
|
|
516
517
|
const r = vs(t);
|
|
517
518
|
let n;
|
|
518
519
|
if (e === "add") n = r.reduce((o, i) => o + i, 0);
|
|
@@ -525,7 +526,7 @@ function Ms(e, t) {
|
|
|
525
526
|
if (!Number.isFinite(n)) throw new Error("计算结果不是有限数字");
|
|
526
527
|
return n;
|
|
527
528
|
}
|
|
528
|
-
function
|
|
529
|
+
function Ss(e, t, r) {
|
|
529
530
|
const n = t.map(V);
|
|
530
531
|
let o;
|
|
531
532
|
return e === "add" ? o = n.reduce(st) : e === "multiply" ? o = n.reduce(Sr) : e === "subtract" ? o = st(n[0], {
|
|
@@ -533,10 +534,10 @@ function $s(e, t, r) {
|
|
|
533
534
|
coefficient: -n[1].coefficient
|
|
534
535
|
}) : o = Qt(n[0], n[1], r), Pt(o, r);
|
|
535
536
|
}
|
|
536
|
-
function
|
|
537
|
-
return r.nulls !== "error" && t.some((n) => n == null) || e === "divide" && r.divisionByZero === "null" && (r.numeric === "decimal" ? V(t[1]).coefficient === 0n : t[1] === 0) ? null : r.numeric === "decimal" ?
|
|
537
|
+
function Es(e, t, r) {
|
|
538
|
+
return r.nulls !== "error" && t.some((n) => n == null) || e === "divide" && r.divisionByZero === "null" && (r.numeric === "decimal" ? V(t[1]).coefficient === 0n : t[1] === 0) ? null : r.numeric === "decimal" ? Ss(e, t, r.digits) : $s(e, t);
|
|
538
539
|
}
|
|
539
|
-
function
|
|
540
|
+
function As(e, t) {
|
|
540
541
|
e.field !== void 0 && K(e.field), e.weightField !== void 0 && K(e.weightField);
|
|
541
542
|
const r = {
|
|
542
543
|
op: e.aggregate,
|
|
@@ -563,7 +564,7 @@ function Es(e, t) {
|
|
|
563
564
|
return i.value;
|
|
564
565
|
};
|
|
565
566
|
}
|
|
566
|
-
function
|
|
567
|
+
function ks(e, t) {
|
|
567
568
|
for (const r of e) {
|
|
568
569
|
const n = r(t);
|
|
569
570
|
if (n != null) return n;
|
|
@@ -575,7 +576,7 @@ function kr(e, t = {}, r = { nodes: 0 }, n = 0) {
|
|
|
575
576
|
throw new Error("计算表达式超出深度或节点预算");
|
|
576
577
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
577
578
|
throw new Error("计算表达式应为声明式对象");
|
|
578
|
-
if ("aggregate" in e) return
|
|
579
|
+
if ("aggregate" in e) return As(e, t);
|
|
579
580
|
if ("field" in e) {
|
|
580
581
|
K(e.field);
|
|
581
582
|
const o = e.field;
|
|
@@ -586,10 +587,10 @@ function kr(e, t = {}, r = { nodes: 0 }, n = 0) {
|
|
|
586
587
|
throw new Error("常量应为有限 JSON 标量");
|
|
587
588
|
return () => e.value;
|
|
588
589
|
}
|
|
589
|
-
return
|
|
590
|
+
return Ns(e, t, r, n);
|
|
590
591
|
}
|
|
591
|
-
function
|
|
592
|
-
const o =
|
|
592
|
+
function Ns(e, t, r, n) {
|
|
593
|
+
const o = gs.find((a) => a.name === e.op);
|
|
593
594
|
if (!o || !Array.isArray(e.args)) throw new Error("未知计算操作");
|
|
594
595
|
if (e.args.length > 256 || Object.keys(e.args).length !== e.args.length) throw new Error("计算参数超出预算或包含空位");
|
|
595
596
|
if (e.args.length < o.minArgs || e.args.length > o.maxArgs) throw new Error("运算参数数量不正确");
|
|
@@ -598,20 +599,20 @@ function ks(e, t, r, n) {
|
|
|
598
599
|
const s = e.args.map(
|
|
599
600
|
(a) => kr(a, t, r, n + 1)
|
|
600
601
|
);
|
|
601
|
-
return i ? (a) => s[i(a.row) ? 0 : 1](a) : ["add", "subtract", "multiply", "divide", "coalesce"].includes(e.op) ? e.op === "coalesce" ? (a) =>
|
|
602
|
+
return i ? (a) => s[i(a.row) ? 0 : 1](a) : ["add", "subtract", "multiply", "divide", "coalesce"].includes(e.op) ? e.op === "coalesce" ? (a) => ks(s, a) : (a) => Es(
|
|
602
603
|
e.op,
|
|
603
604
|
s.map((c) => c(a)),
|
|
604
605
|
t
|
|
605
|
-
) : (a) =>
|
|
606
|
+
) : (a) => ps(e.op, s.map((c) => c(a)), t.numeric, t.digits, t.nulls);
|
|
606
607
|
}
|
|
607
|
-
function
|
|
608
|
+
function Ps(e) {
|
|
608
609
|
kr(e);
|
|
609
610
|
const t = /* @__PURE__ */ new Set(), r = (n) => {
|
|
610
|
-
"field" in n && n.field && t.add(n.field), "aggregate" in n && n.weightField && t.add(n.weightField), "args" in n && (n.args.forEach(r), n.condition &&
|
|
611
|
+
"field" in n && n.field && t.add(n.field), "aggregate" in n && n.weightField && t.add(n.weightField), "args" in n && (n.args.forEach(r), n.condition && us(n.condition).forEach((o) => t.add(o)));
|
|
611
612
|
};
|
|
612
613
|
return r(e), [...t];
|
|
613
614
|
}
|
|
614
|
-
const
|
|
615
|
+
const Fs = 16, rr = 1024 * 1024, fn = 5e5, ct = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ Symbol("uncacheable-computation-definition");
|
|
615
616
|
function qe(e, t, r = 0) {
|
|
616
617
|
if (++t.nodes > 1e4 || r > 32) throw de;
|
|
617
618
|
if (e == null) return [String(e)];
|
|
@@ -634,7 +635,7 @@ function un(e, t) {
|
|
|
634
635
|
if (!r || r.get || r.set) throw de;
|
|
635
636
|
return r.value;
|
|
636
637
|
}
|
|
637
|
-
function
|
|
638
|
+
function Os(e) {
|
|
638
639
|
try {
|
|
639
640
|
return JSON.stringify(qe(e, { nodes: 0, units: 0 }));
|
|
640
641
|
} catch (t) {
|
|
@@ -642,10 +643,10 @@ function Fs(e) {
|
|
|
642
643
|
return;
|
|
643
644
|
}
|
|
644
645
|
}
|
|
645
|
-
function
|
|
646
|
+
function Rs(e) {
|
|
646
647
|
ct.set(e, { programs: /* @__PURE__ */ new Map(), units: 0, slots: 0 });
|
|
647
648
|
}
|
|
648
|
-
function
|
|
649
|
+
function Is(e, t) {
|
|
649
650
|
const r = ct.get(e);
|
|
650
651
|
if (!r) return;
|
|
651
652
|
const n = { programs: /* @__PURE__ */ new Map(), units: r.units, slots: r.slots };
|
|
@@ -658,27 +659,27 @@ function Rs(e, t) {
|
|
|
658
659
|
}
|
|
659
660
|
ct.set(t, n);
|
|
660
661
|
}
|
|
661
|
-
function
|
|
662
|
+
function Cs(e, t, r) {
|
|
662
663
|
const n = ct.get(e);
|
|
663
664
|
if (!n || t.some((f) => typeof f.expression == "string")) return;
|
|
664
|
-
const o =
|
|
665
|
+
const o = Os(t);
|
|
665
666
|
if (o === void 0 || o.length > rr) return;
|
|
666
667
|
const i = n.programs.get(o);
|
|
667
668
|
if (i) return i;
|
|
668
669
|
const s = r(), a = e.length * s.reduce((f, u) => f + u.dependencies.length + 1, 0), c = { fields: s, rows: /* @__PURE__ */ new WeakMap(), slots: a, cacheRows: a <= fn };
|
|
669
670
|
if (!c.cacheRows) return c;
|
|
670
|
-
for (; n.programs.size >=
|
|
671
|
+
for (; n.programs.size >= Fs || n.units + o.length > rr || n.slots + a > fn; ) {
|
|
671
672
|
const f = n.programs.keys().next().value;
|
|
672
673
|
n.slots -= n.programs.get(f).slots, n.units -= f.length, n.programs.delete(f);
|
|
673
674
|
}
|
|
674
675
|
return n.programs.set(o, c), n.units += o.length, n.slots += a, c;
|
|
675
676
|
}
|
|
676
|
-
function
|
|
677
|
+
function Ts(e, t, r, n) {
|
|
677
678
|
if ((r.definition.scope ?? "row") !== "row") return;
|
|
678
679
|
const o = e.program?.rows.get(t)?.get(r.definition.field);
|
|
679
680
|
return o?.dependencies.every((i, s) => Object.is(n[r.dependencies[s]], i)) ? o : void 0;
|
|
680
681
|
}
|
|
681
|
-
function
|
|
682
|
+
function js(e, t, r, n, o) {
|
|
682
683
|
const i = e.program;
|
|
683
684
|
if (!i?.cacheRows || (r.definition.scope ?? "row") !== "row") return;
|
|
684
685
|
let s = e.writes.get(t);
|
|
@@ -688,7 +689,7 @@ function Ts(e, t, r, n, o) {
|
|
|
688
689
|
...o ? { issue: { field: o.field, message: o.message } } : {}
|
|
689
690
|
});
|
|
690
691
|
}
|
|
691
|
-
function
|
|
692
|
+
function Ds(e) {
|
|
692
693
|
if (K(e.field), e.scope !== void 0 && !["row", "group", "dataset"].includes(e.scope))
|
|
693
694
|
throw new Error("未知计算范围");
|
|
694
695
|
if (e.numeric !== void 0 && e.numeric !== "number" && e.numeric !== "decimal")
|
|
@@ -699,9 +700,9 @@ function js(e) {
|
|
|
699
700
|
throw new Error("未知除零规则");
|
|
700
701
|
if (e.scope === "group" && (!Array.isArray(e.groupBy) || !e.groupBy.length))
|
|
701
702
|
throw new Error("分组计算需要 groupBy 字段");
|
|
702
|
-
|
|
703
|
+
Ls(e);
|
|
703
704
|
}
|
|
704
|
-
function
|
|
705
|
+
function Ls(e) {
|
|
705
706
|
if (e.groupBy !== void 0) {
|
|
706
707
|
if (!Array.isArray(e.groupBy) || e.groupBy.length > 16)
|
|
707
708
|
throw new Error("计算分组最多 16 级");
|
|
@@ -716,7 +717,7 @@ function Ds(e) {
|
|
|
716
717
|
function Nr(e) {
|
|
717
718
|
return [
|
|
718
719
|
.../* @__PURE__ */ new Set([
|
|
719
|
-
...typeof e.expression == "string" ? e.dependsOn ?? [] :
|
|
720
|
+
...typeof e.expression == "string" ? e.dependsOn ?? [] : Ps(e.expression),
|
|
720
721
|
...e.groupBy ?? []
|
|
721
722
|
])
|
|
722
723
|
];
|
|
@@ -726,7 +727,7 @@ function Zn(e) {
|
|
|
726
727
|
throw new Error("计算字段应为数组且最多2048项");
|
|
727
728
|
const t = /* @__PURE__ */ new Map();
|
|
728
729
|
for (const s of e) {
|
|
729
|
-
if (
|
|
730
|
+
if (Ds(s), t.has(s.field)) throw new Error(`计算字段重复:${s.field}`);
|
|
730
731
|
t.set(s.field, s);
|
|
731
732
|
}
|
|
732
733
|
const r = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), o = [];
|
|
@@ -746,7 +747,7 @@ function Zn(e) {
|
|
|
746
747
|
}
|
|
747
748
|
return e.forEach(i), o;
|
|
748
749
|
}
|
|
749
|
-
function
|
|
750
|
+
function Bs(e) {
|
|
750
751
|
try {
|
|
751
752
|
const t = Zn(e);
|
|
752
753
|
return {
|
|
@@ -787,7 +788,7 @@ function ln(e) {
|
|
|
787
788
|
};
|
|
788
789
|
});
|
|
789
790
|
}
|
|
790
|
-
function
|
|
791
|
+
function _s(e, t) {
|
|
791
792
|
return JSON.stringify(
|
|
792
793
|
t.map((r) => {
|
|
793
794
|
const n = Object.prototype.hasOwnProperty.call(e, r) ? e[r] : null;
|
|
@@ -797,7 +798,7 @@ function Bs(e, t) {
|
|
|
797
798
|
})
|
|
798
799
|
);
|
|
799
800
|
}
|
|
800
|
-
function
|
|
801
|
+
function Ks(e, t) {
|
|
801
802
|
if (t.scope === "dataset") return () => e;
|
|
802
803
|
if (t.scope !== "group") {
|
|
803
804
|
const o = /* @__PURE__ */ new WeakMap();
|
|
@@ -808,14 +809,14 @@ function _s(e, t) {
|
|
|
808
809
|
}
|
|
809
810
|
const r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new WeakMap();
|
|
810
811
|
for (const o of e) {
|
|
811
|
-
const i =
|
|
812
|
+
const i = _s(o, t.groupBy);
|
|
812
813
|
n.set(o, i);
|
|
813
814
|
const s = r.get(i);
|
|
814
815
|
s ? s.push(o) : r.set(i, [o]);
|
|
815
816
|
}
|
|
816
817
|
return (o) => r.get(n.get(o));
|
|
817
818
|
}
|
|
818
|
-
function
|
|
819
|
+
function Ws(e, t) {
|
|
819
820
|
const r = t.maxRows ?? 1e5, n = t.maxCells ?? 2e6;
|
|
820
821
|
if (!Array.isArray(e) || !Number.isSafeInteger(r) || r < 1 || e.length > r)
|
|
821
822
|
throw new Error("计算数据行数超出预算或输入不是数组");
|
|
@@ -830,7 +831,7 @@ function dn(e) {
|
|
|
830
831
|
throw t.name = "AbortError", t;
|
|
831
832
|
}
|
|
832
833
|
}
|
|
833
|
-
function
|
|
834
|
+
function zs(e, t, r, n, o, i) {
|
|
834
835
|
try {
|
|
835
836
|
const s = e.read({ row: t, rowIndex: r, rows: n });
|
|
836
837
|
if (s !== void 0 && !Ar(s))
|
|
@@ -846,26 +847,26 @@ function Ws(e, t, r, n, o, i) {
|
|
|
846
847
|
t[e.definition.field] = null, i.push({ rowIndex: r, field: e.definition.field, message: a });
|
|
847
848
|
}
|
|
848
849
|
}
|
|
849
|
-
function
|
|
850
|
-
const c =
|
|
850
|
+
function Js(e, t, r, n, o, i, s, a) {
|
|
851
|
+
const c = Ts(e, t, r, n);
|
|
851
852
|
if (c && (!c.issue || s.onError === "null")) {
|
|
852
853
|
n[r.definition.field] = c.value, c.issue && a.push({ ...c.issue, rowIndex: o });
|
|
853
854
|
return;
|
|
854
855
|
}
|
|
855
856
|
const f = a.length;
|
|
856
|
-
|
|
857
|
+
zs(r, n, o, i, s, a), js(e, t, r, n, a.length > f ? a[a.length - 1] : void 0);
|
|
857
858
|
}
|
|
858
859
|
function Ft(e, t) {
|
|
859
|
-
|
|
860
|
-
const r =
|
|
860
|
+
Ws(e, t), dn(t.signal);
|
|
861
|
+
const r = Cs(e, t.fields, () => ln(t)), n = { program: r, writes: /* @__PURE__ */ new WeakMap() }, o = r?.fields ?? ln(t), i = [], s = e.map((a, c) => {
|
|
861
862
|
if (!a || typeof a != "object" || Array.isArray(a))
|
|
862
863
|
throw new Error(`第 ${c + 1} 行应为对象`);
|
|
863
864
|
return { ...a };
|
|
864
865
|
});
|
|
865
866
|
for (const a of o) {
|
|
866
|
-
const c =
|
|
867
|
+
const c = Ks(s, a.definition);
|
|
867
868
|
s.forEach((f, u) => {
|
|
868
|
-
dn(t.signal),
|
|
869
|
+
dn(t.signal), Js(n, e[u], a, f, u, c(f), t, i);
|
|
869
870
|
});
|
|
870
871
|
}
|
|
871
872
|
return { rows: s, issues: i };
|
|
@@ -881,23 +882,23 @@ function Ae(e, t, r) {
|
|
|
881
882
|
}
|
|
882
883
|
return n;
|
|
883
884
|
}
|
|
884
|
-
const
|
|
885
|
-
function
|
|
885
|
+
const Me = ["#2563eb", "#0d9488", "#d97706", "#7c3aed", "#dc2626", "#0284c7"];
|
|
886
|
+
function Vs(e) {
|
|
886
887
|
if (!["bar", "line", "stackedBar", "percentBar"].includes(e.type)) throw new Error("未知图表类型");
|
|
887
888
|
if (!Array.isArray(e.categories) || !Array.isArray(e.series) || !e.categories.length || e.categories.length > 200 || !e.series.length || e.series.length > 12) throw new Error("图表支持 1–200 个分类、1–12 个系列;大数据应先聚合");
|
|
888
889
|
const t = Ae(e.categories, 200, "图表分类"), r = Ae(e.series, 12, "图表系列").map((n) => ({ ...n, values: Ae(n?.values, 200, "图表数值") }));
|
|
889
890
|
for (const n of t) if (typeof n != "string") throw new Error("图表分类应为字符串");
|
|
890
|
-
|
|
891
|
-
for (const n of r)
|
|
891
|
+
Hs(e);
|
|
892
|
+
for (const n of r) Us(n, t.length);
|
|
892
893
|
return { ...e, categories: t, series: r };
|
|
893
894
|
}
|
|
894
|
-
function
|
|
895
|
+
function Hs(e) {
|
|
895
896
|
for (const t of ["leftMm", "topMm", "widthMm", "heightMm"])
|
|
896
897
|
if (!Number.isFinite(e[t]) || e[t] < 0) throw new Error(`${t} 应为有限非负数`);
|
|
897
898
|
if (e.widthMm < 45 || e.heightMm < 35) throw new Error("图表至少需要 45×35mm");
|
|
898
899
|
if (!Number.isFinite(e.leftMm + e.widthMm) || !Number.isFinite(e.topMm + e.heightMm)) throw new Error("图表几何范围溢出");
|
|
899
900
|
}
|
|
900
|
-
function
|
|
901
|
+
function Us(e, t) {
|
|
901
902
|
if (!e || typeof e.name != "string" || !Array.isArray(e.values) || e.values.length !== t) throw new Error("图表系列应提供名称及逐分类的有限数字或 null");
|
|
902
903
|
for (const r of e.values) if (r !== null && !Number.isFinite(r)) throw new Error("图表系列应提供名称及逐分类的有限数字或 null");
|
|
903
904
|
if (e.color !== void 0 && !/^#[\da-f]{6}$/i.test(e.color)) throw new Error("图表颜色应为 #RRGGBB");
|
|
@@ -911,9 +912,9 @@ function ye(e, t, r, n, o = "center") {
|
|
|
911
912
|
function ft(e) {
|
|
912
913
|
return Number(e.toPrecision(5)).toString();
|
|
913
914
|
}
|
|
914
|
-
function
|
|
915
|
+
function Gs(e) {
|
|
915
916
|
let t = 0, r = 0;
|
|
916
|
-
const n = Qn(e) ?
|
|
917
|
+
const n = Qn(e) ? Ys(e) : void 0;
|
|
917
918
|
if (n)
|
|
918
919
|
t = n.min, r = n.max;
|
|
919
920
|
else for (const d of e.series) for (const l of d.values) l !== null && (t = Math.min(t, l), r = Math.max(r, l));
|
|
@@ -924,7 +925,7 @@ function Us(e) {
|
|
|
924
925
|
function Qn(e) {
|
|
925
926
|
return e.type === "stackedBar" || e.type === "percentBar";
|
|
926
927
|
}
|
|
927
|
-
function
|
|
928
|
+
function Ys(e) {
|
|
928
929
|
let t = 0, r = e.type === "percentBar" ? 100 : 0;
|
|
929
930
|
for (let n = 0; n < e.categories.length; n++) {
|
|
930
931
|
let o = 0, i = 0;
|
|
@@ -937,7 +938,7 @@ function Gs(e) {
|
|
|
937
938
|
}
|
|
938
939
|
return { min: t, max: r };
|
|
939
940
|
}
|
|
940
|
-
function
|
|
941
|
+
function qs(e) {
|
|
941
942
|
if (e.type !== "percentBar") return e;
|
|
942
943
|
const t = e.categories.map((r, n) => {
|
|
943
944
|
let o = 0;
|
|
@@ -954,7 +955,7 @@ function Ys(e) {
|
|
|
954
955
|
return i && s ? n / i / s * 100 : 0;
|
|
955
956
|
}) })) };
|
|
956
957
|
}
|
|
957
|
-
function
|
|
958
|
+
function Xs(e, t) {
|
|
958
959
|
const r = [], n = t.width / e.categories.length;
|
|
959
960
|
return e.categories.forEach((o, i) => {
|
|
960
961
|
let s = 0, a = 0;
|
|
@@ -963,12 +964,12 @@ function qs(e, t) {
|
|
|
963
964
|
if (u == null) return;
|
|
964
965
|
const d = u < 0 ? a : s, l = d + u;
|
|
965
966
|
u < 0 ? a = l : s = l;
|
|
966
|
-
const m = Math.min(t.y(d), t.y(l)), h = Math.abs(t.y(l) - t.y(d)), g = c.color ??
|
|
967
|
+
const m = Math.min(t.y(d), t.y(l)), h = Math.abs(t.y(l) - t.y(d)), g = c.color ?? Me[f % Me.length], y = t.left + n * (i + 0.15), w = n * 0.7;
|
|
967
968
|
r.push({ kind: "rect", leftMm: y, topMm: m, widthMm: w, heightMm: h, style: { backgroundColor: g, borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } }), e.showValues && h >= 5 && r.push({ ...ye(e.type === "percentBar" ? `${ft(u)}%` : ft(u), y, m + h / 2 - 2.5, w), style: { fontSize: 7, color: "#ffffff", align: "center" } });
|
|
968
969
|
});
|
|
969
970
|
}), r;
|
|
970
971
|
}
|
|
971
|
-
function
|
|
972
|
+
function Zs(e, t) {
|
|
972
973
|
const r = [];
|
|
973
974
|
e.title && r.push({ ...ye(e.title, e.leftMm, e.topMm, e.widthMm), style: { fontSize: 10, bold: !0, align: "left" } });
|
|
974
975
|
for (let i = 0; i <= 4; i++) {
|
|
@@ -982,11 +983,11 @@ function Xs(e, t) {
|
|
|
982
983
|
});
|
|
983
984
|
const o = t.width / e.series.length;
|
|
984
985
|
return e.series.forEach((i, s) => {
|
|
985
|
-
r.push({ ...ye(i.name, t.left + s * o, e.topMm + e.heightMm - 5, o), style: { fontSize: 8, color: i.color ??
|
|
986
|
+
r.push({ ...ye(i.name, t.left + s * o, e.topMm + e.heightMm - 5, o), style: { fontSize: 8, color: i.color ?? Me[s % Me.length], align: "center" } });
|
|
986
987
|
}), r;
|
|
987
988
|
}
|
|
988
|
-
function
|
|
989
|
-
const o = [], i = r.color ??
|
|
989
|
+
function Qs(e, t, r, n) {
|
|
990
|
+
const o = [], i = r.color ?? Me[n % Me.length], s = t.width / e.categories.length, a = s * 0.75 / e.series.length;
|
|
990
991
|
let c;
|
|
991
992
|
return r.values.forEach((f, u) => {
|
|
992
993
|
if (f === null) {
|
|
@@ -997,7 +998,7 @@ function Zs(e, t, r, n) {
|
|
|
997
998
|
e.type === "bar" ? o.push({ kind: "rect", leftMm: t.left + u * s + s * 0.125 + n * a, topMm: Math.min(l, t.y(0)), widthMm: a, heightMm: Math.abs(t.y(0) - l), style: { backgroundColor: i, borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } }) : (c && o.push(nr(c.x, c.y, d, l, i, 1.2)), o.push({ kind: "ellipse", leftMm: d - 0.7, topMm: l - 0.7, widthMm: 1.4, heightMm: 1.4, style: { backgroundColor: i, borderColor: i } }), c = { x: d, y: l }), e.showValues && o.push({ ...ye(ft(f), d - s / 2, Math.max(t.top, l - 5), s), style: { fontSize: 7, color: i, align: "center" } });
|
|
998
999
|
}), o;
|
|
999
1000
|
}
|
|
1000
|
-
function
|
|
1001
|
+
function ea(e, t) {
|
|
1001
1002
|
let r = 0, n = !1;
|
|
1002
1003
|
for (const o of t.values) {
|
|
1003
1004
|
if (o === null) {
|
|
@@ -1008,14 +1009,14 @@ function Qs(e, t) {
|
|
|
1008
1009
|
}
|
|
1009
1010
|
return r;
|
|
1010
1011
|
}
|
|
1011
|
-
function
|
|
1012
|
+
function ta(e) {
|
|
1012
1013
|
const t = e.categories.length, r = Math.max(1, Math.ceil(t / Math.max(1, Math.floor((e.widthMm - 17) / 14)))), n = 11 + +!!e.title + Math.ceil(t / r) + e.series.length;
|
|
1013
|
-
return e.series.reduce((o, i) => o +
|
|
1014
|
+
return e.series.reduce((o, i) => o + ea(e, i), n);
|
|
1014
1015
|
}
|
|
1015
|
-
function
|
|
1016
|
-
e =
|
|
1017
|
-
const t =
|
|
1018
|
-
return [...
|
|
1016
|
+
function ra(e) {
|
|
1017
|
+
e = qs(Vs(e));
|
|
1018
|
+
const t = Gs(e);
|
|
1019
|
+
return [...Zs(e, t), ...Qn(e) ? Xs(e, t) : e.series.flatMap((r, n) => Qs(e, t, r, n))];
|
|
1019
1020
|
}
|
|
1020
1021
|
function ut(e, t, r) {
|
|
1021
1022
|
if (e === void 0) return t;
|
|
@@ -1029,29 +1030,29 @@ function eo(e) {
|
|
|
1029
1030
|
if (e.title !== void 0 && (typeof e.title != "string" || e.title.length > 512)) throw new TypeError("图表标题过长");
|
|
1030
1031
|
if (e.showValues !== void 0 && typeof e.showValues != "boolean") throw new TypeError("图表数值标签应为布尔值");
|
|
1031
1032
|
if (!Array.isArray(e.measures) || !e.measures.length || e.measures.length > 12) throw new RangeError("图表支持 1–12 个度量");
|
|
1032
|
-
for (const t of Ae(e.measures, 12, "图表度量"))
|
|
1033
|
+
for (const t of Ae(e.measures, 12, "图表度量")) na(t);
|
|
1033
1034
|
ut(e.maxRows, 1e5, 1e5), ut(e.maxCategories, 200, 200);
|
|
1034
1035
|
}
|
|
1035
|
-
function
|
|
1036
|
+
function na(e) {
|
|
1036
1037
|
if (!e || typeof e != "object" || Array.isArray(e)) throw new TypeError("图表度量应为对象");
|
|
1037
1038
|
if (e.field !== void 0 && K(e.field), e.weightField !== void 0 && K(e.weightField), e.label !== void 0 && (typeof e.label != "string" || e.label.length > 256)) throw new TypeError("图表系列名称过长");
|
|
1038
1039
|
if (e.color !== void 0 && !/^#[\da-f]{6}$/i.test(e.color)) throw new TypeError("图表颜色应为 #RRGGBB");
|
|
1039
1040
|
se(e);
|
|
1040
1041
|
}
|
|
1041
|
-
function
|
|
1042
|
+
function oa(e) {
|
|
1042
1043
|
if (e == null) return { key: "null", label: "—" };
|
|
1043
1044
|
if (typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e))) throw new TypeError("图表分类应为文本、布尔或有限数字");
|
|
1044
1045
|
const t = String(e);
|
|
1045
1046
|
if (t.length > 512) throw new RangeError("图表分类名称过长");
|
|
1046
1047
|
return { key: JSON.stringify([typeof e, e]), label: t };
|
|
1047
1048
|
}
|
|
1048
|
-
function
|
|
1049
|
+
function ia(e) {
|
|
1049
1050
|
if (e === null) return null;
|
|
1050
1051
|
const t = Number(e);
|
|
1051
1052
|
if (!Number.isFinite(t)) throw new RangeError("聚合结果超出图表有限数值范围");
|
|
1052
1053
|
return t;
|
|
1053
1054
|
}
|
|
1054
|
-
function
|
|
1055
|
+
function sa(e, t, r) {
|
|
1055
1056
|
if (r?.aborted) {
|
|
1056
1057
|
const a = new Error("图表数据处理已取消");
|
|
1057
1058
|
throw a.name = "AbortError", a;
|
|
@@ -1067,7 +1068,7 @@ function ia(e, t, r) {
|
|
|
1067
1068
|
}
|
|
1068
1069
|
const c = e[a];
|
|
1069
1070
|
if (!c || typeof c != "object" || Array.isArray(c)) throw new TypeError("图表数据行应为对象");
|
|
1070
|
-
const f =
|
|
1071
|
+
const f = oa(Object.prototype.hasOwnProperty.call(c, t.categoryField) ? c[t.categoryField] : null);
|
|
1071
1072
|
let u = o.get(f.key);
|
|
1072
1073
|
if (!u) {
|
|
1073
1074
|
if (o.size >= i) throw new RangeError("图表分类超出预算,请明确筛选或聚合数据");
|
|
@@ -1078,11 +1079,11 @@ function ia(e, t, r) {
|
|
|
1078
1079
|
const s = [...o.values()];
|
|
1079
1080
|
return t.sort && s.sort((a, c) => (t.sort === "desc" ? -1 : 1) * (a.label < c.label ? -1 : a.label > c.label ? 1 : 0)), { categories: s.map((a) => a.label), series: n.map((a, c) => ({
|
|
1080
1081
|
name: a.label ?? `${a.field ?? "记录"} · ${a.op}`,
|
|
1081
|
-
values: s.map((f) =>
|
|
1082
|
+
values: s.map((f) => ia(f.accumulators[c].value())),
|
|
1082
1083
|
...a.color ? { color: a.color } : {}
|
|
1083
1084
|
})) };
|
|
1084
1085
|
}
|
|
1085
|
-
class
|
|
1086
|
+
class ve extends Error {
|
|
1086
1087
|
constructor(t, r) {
|
|
1087
1088
|
super(`报表页数超出上限 ${t}(至少 ${r} 页)`), this.limit = t, this.actual = r, this.code = "page-limit", this.name = "PaginatePageLimitError";
|
|
1088
1089
|
}
|
|
@@ -1101,22 +1102,22 @@ const Pr = 5e4;
|
|
|
1101
1102
|
function Ot(e = Pr) {
|
|
1102
1103
|
if (!Number.isSafeInteger(e) || e < 1 || e > 1e6) throw new RangeError("maxChartComponents 应为 1..1000000 的安全整数");
|
|
1103
1104
|
}
|
|
1104
|
-
function
|
|
1105
|
+
function aa(e, t, r) {
|
|
1105
1106
|
const n = e.chartBinding;
|
|
1106
1107
|
if (e.kind !== "chart" || e.grid || e.imageData || e.binding || e.pageAnchor) throw new TypeError("绑定图表不能同时设置图片、网格、记录绑定或页眉页脚");
|
|
1107
1108
|
const o = Object.prototype.hasOwnProperty.call(t, n.dataset) ? t[n.dataset] : void 0;
|
|
1108
1109
|
if (!Array.isArray(o)) throw new TypeError(`图表数据集 ${n.dataset} 未提供`);
|
|
1109
|
-
return { ...
|
|
1110
|
+
return { ...sa(o, n, r), type: n.type, leftMm: e.leftMm, topMm: e.topMm, widthMm: e.widthMm, heightMm: e.heightMm, title: n.title, showValues: n.showValues };
|
|
1110
1111
|
}
|
|
1111
|
-
function
|
|
1112
|
+
function ca(e, t, r = Pr) {
|
|
1112
1113
|
Ot(r);
|
|
1113
1114
|
let n = 0;
|
|
1114
1115
|
return Object.assign((i) => {
|
|
1115
1116
|
if (!i.chartBinding) return [i];
|
|
1116
|
-
const s =
|
|
1117
|
+
const s = aa(i, e, t), a = n + (s.categories.length ? ta(s) : 1);
|
|
1117
1118
|
if (!Number.isSafeInteger(a)) throw new RangeError("图表图元估算应为有限安全整数");
|
|
1118
1119
|
if (a > r) throw new Le(r, a);
|
|
1119
|
-
const c = s.categories.length ?
|
|
1120
|
+
const c = s.categories.length ? ra(s) : [{ kind: "text", leftMm: i.leftMm, topMm: i.topMm, widthMm: i.widthMm, heightMm: i.heightMm, text: "—", style: { align: "center", verticalAlign: "middle", color: "#94a3b8", fontSize: 10 } }];
|
|
1120
1121
|
return n += c.length, c;
|
|
1121
1122
|
}, { used: () => n });
|
|
1122
1123
|
}
|
|
@@ -1131,7 +1132,7 @@ function to(e, t) {
|
|
|
1131
1132
|
throw new Error("矩阵维度必须是有限 JSON 标量");
|
|
1132
1133
|
});
|
|
1133
1134
|
}
|
|
1134
|
-
function
|
|
1135
|
+
function fa(e, t, r) {
|
|
1135
1136
|
if (!e || typeof e != "object" || Array.isArray(e)) throw new Error("矩阵层级应为对象");
|
|
1136
1137
|
for (const n of [e.emptyLabel, e.subtotalLabel, e.totalLabel]) if (n !== void 0 && typeof n != "string") throw new Error("矩阵层级标签应为字符串");
|
|
1137
1138
|
mn(e.row, t.length), mn(e.column, r.length);
|
|
@@ -1156,7 +1157,7 @@ function gn(e, t) {
|
|
|
1156
1157
|
a || (a = { values: i, children: /* @__PURE__ */ new Map() }, n.children.set(s, a), o === r.length ? (e.leaves++, e.expanded++) : e.options.subtotals?.includes(o) && e.expanded++), n = a;
|
|
1157
1158
|
}
|
|
1158
1159
|
}
|
|
1159
|
-
function
|
|
1160
|
+
function ua(e, t) {
|
|
1160
1161
|
if (e === t) return 0;
|
|
1161
1162
|
if (e === null) return -1;
|
|
1162
1163
|
if (t === null) return 1;
|
|
@@ -1164,9 +1165,9 @@ function fa(e, t) {
|
|
|
1164
1165
|
const r = `${typeof e}:${e}`, n = `${typeof t}:${t}`;
|
|
1165
1166
|
return r < n ? -1 : 1;
|
|
1166
1167
|
}
|
|
1167
|
-
function
|
|
1168
|
+
function la(e, t) {
|
|
1168
1169
|
const r = [...e.children.values()];
|
|
1169
|
-
return t && t !== "source" && r.sort((n, o) =>
|
|
1170
|
+
return t && t !== "source" && r.sort((n, o) => ua(n.values[n.values.length - 1], o.values[o.values.length - 1]) * (t === "desc" ? -1 : 1)), r;
|
|
1170
1171
|
}
|
|
1171
1172
|
function Jt(e, t, r) {
|
|
1172
1173
|
return {
|
|
@@ -1181,7 +1182,7 @@ function Jt(e, t, r) {
|
|
|
1181
1182
|
function pn(e, t) {
|
|
1182
1183
|
const r = [];
|
|
1183
1184
|
function n(o) {
|
|
1184
|
-
for (const i of
|
|
1185
|
+
for (const i of la(o, e.options.sort?.[o.values.length]))
|
|
1185
1186
|
i.children.size ? (n(i), e.options.subtotals?.includes(i.values.length) && r.push(Jt(e, i.values, "subtotal"))) : r.push(Jt(e, i.values, "member"));
|
|
1186
1187
|
}
|
|
1187
1188
|
return n(e.root), t && e.leaves && r.push(Jt(e, [], "total")), r;
|
|
@@ -1190,16 +1191,16 @@ function yn(e, t, r) {
|
|
|
1190
1191
|
const n = to(t, e.fields), o = [ke(e.fields, n), ...(e.options.subtotals ?? []).map((i) => ke(e.fields, n.slice(0, i)))];
|
|
1191
1192
|
return r && o.push(ke(e.fields, [])), o;
|
|
1192
1193
|
}
|
|
1193
|
-
function
|
|
1194
|
+
function da(e, t, r) {
|
|
1194
1195
|
if (!(e.kind !== "member" && t > e.depth))
|
|
1195
1196
|
return e.kind === "total" ? { key: "total", text: r.totalLabel ?? "合计", rowSpan: 0 } : e.kind === "subtotal" && t === e.depth ? { key: e.key, text: r.subtotalLabel ?? "小计", rowSpan: 0 } : { key: JSON.stringify(e.values.slice(0, t + 1).map((n) => [typeof n, n])), text: e.labels[t], rowSpan: 1 };
|
|
1196
1197
|
}
|
|
1197
|
-
function
|
|
1198
|
+
function ma(e, t) {
|
|
1198
1199
|
const r = e.columnFields.length + 1, n = e.rowFields.length, o = Array.from({ length: r }, () => Array(n + t.length).fill(null));
|
|
1199
1200
|
for (let i = 0; i < e.columnFields.length; i++) {
|
|
1200
1201
|
let s;
|
|
1201
1202
|
t.forEach((a, c) => {
|
|
1202
|
-
const f =
|
|
1203
|
+
const f = da(a, i, e.hierarchy);
|
|
1203
1204
|
if (!f) {
|
|
1204
1205
|
s = void 0;
|
|
1205
1206
|
return;
|
|
@@ -1239,10 +1240,10 @@ function ro(e, t) {
|
|
|
1239
1240
|
}
|
|
1240
1241
|
return { row: r, column: n, shape: i };
|
|
1241
1242
|
}
|
|
1242
|
-
function
|
|
1243
|
+
function ha(e, t) {
|
|
1243
1244
|
return ro(e, t).shape;
|
|
1244
1245
|
}
|
|
1245
|
-
function
|
|
1246
|
+
function ga(e, t, r) {
|
|
1246
1247
|
const n = /* @__PURE__ */ new Map();
|
|
1247
1248
|
for (const o of e) {
|
|
1248
1249
|
const i = yn(r.row, o, !!t.totals), s = yn(r.column, o, !!t.totals);
|
|
@@ -1257,7 +1258,7 @@ function ha(e, t, r) {
|
|
|
1257
1258
|
}
|
|
1258
1259
|
return n;
|
|
1259
1260
|
}
|
|
1260
|
-
function
|
|
1261
|
+
function pa(e, t) {
|
|
1261
1262
|
return e.flatMap((r, n) => t.measures.map((o, i) => ({
|
|
1262
1263
|
...r,
|
|
1263
1264
|
field: r.kind === "total" ? `total_${i}` : `c${n}_${i}`,
|
|
@@ -1267,24 +1268,24 @@ function ga(e, t) {
|
|
|
1267
1268
|
operation: o.op
|
|
1268
1269
|
})));
|
|
1269
1270
|
}
|
|
1270
|
-
function
|
|
1271
|
+
function ya(e, t) {
|
|
1271
1272
|
return e.kind === "total" ? t.hierarchy.totalLabel ?? "合计" : [...e.labels, ...e.kind === "subtotal" ? [t.hierarchy.subtotalLabel ?? "小计"] : []].join(" / ");
|
|
1272
1273
|
}
|
|
1273
|
-
function
|
|
1274
|
+
function wa(e, t) {
|
|
1274
1275
|
return [
|
|
1275
1276
|
...t.rowFields.map((r, n) => ({ field: `r${n}`, header: t.hierarchy.row?.labels?.[n] ?? r, semanticRole: "dimension" })),
|
|
1276
1277
|
...e.map((r) => {
|
|
1277
1278
|
const n = t.measures[r.measure];
|
|
1278
1279
|
return {
|
|
1279
1280
|
field: r.field,
|
|
1280
|
-
header: `${
|
|
1281
|
+
header: `${ya(r, t)} · ${n.label ?? `${n.field} (${n.op})`}`,
|
|
1281
1282
|
semanticRole: "measure",
|
|
1282
1283
|
...n.digits === void 0 ? {} : { format: { kind: "number", digits: n.digits } }
|
|
1283
1284
|
};
|
|
1284
1285
|
})
|
|
1285
1286
|
];
|
|
1286
1287
|
}
|
|
1287
|
-
function
|
|
1288
|
+
function ba(e, t, r, n) {
|
|
1288
1289
|
return e.map((o) => {
|
|
1289
1290
|
const i = {};
|
|
1290
1291
|
r.rowFields.forEach((s, a) => {
|
|
@@ -1294,9 +1295,9 @@ function wa(e, t, r, n) {
|
|
|
1294
1295
|
return i;
|
|
1295
1296
|
});
|
|
1296
1297
|
}
|
|
1297
|
-
function
|
|
1298
|
-
const r = ro(e, t), n = pn(r.row, !!t.totals), o =
|
|
1299
|
-
return { columns:
|
|
1298
|
+
function xa(e, t) {
|
|
1299
|
+
const r = ro(e, t), n = pn(r.row, !!t.totals), o = pa(pn(r.column, !!t.totals), t), i = ga(e, t, r);
|
|
1300
|
+
return { columns: wa(o, t), rows: ba(n, o, t, i), headerGrid: ma(t, o), metadata: {
|
|
1300
1301
|
rowFields: [...t.rowFields],
|
|
1301
1302
|
rowLabels: [...t.hierarchy.row?.labels ?? t.rowFields],
|
|
1302
1303
|
columnFields: [...t.columnFields],
|
|
@@ -1305,7 +1306,7 @@ function ba(e, t) {
|
|
|
1305
1306
|
columns: o
|
|
1306
1307
|
} };
|
|
1307
1308
|
}
|
|
1308
|
-
function
|
|
1309
|
+
function Ma(e, t) {
|
|
1309
1310
|
const r = () => t.measures.map((c) => se(c)), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = t.totals ? r() : void 0, a = (c, f) => c?.forEach((u) => u.add(f));
|
|
1310
1311
|
for (const c of e) {
|
|
1311
1312
|
const f = t.row(c), u = t.column(c);
|
|
@@ -1366,10 +1367,10 @@ function Fr(e) {
|
|
|
1366
1367
|
return r.field;
|
|
1367
1368
|
}).some((r) => typeof r != "string" || !r.trim()))
|
|
1368
1369
|
throw new Error("矩阵度量字段应非空");
|
|
1369
|
-
e.hierarchy !== void 0 &&
|
|
1370
|
+
e.hierarchy !== void 0 && fa(e.hierarchy, e.rowFields, e.columnFields);
|
|
1370
1371
|
}
|
|
1371
1372
|
function no(e, t) {
|
|
1372
|
-
if (Fr(t), t.hierarchy) return
|
|
1373
|
+
if (Fr(t), t.hierarchy) return ha(e, t);
|
|
1373
1374
|
if (!Array.isArray(e) || e.length > (t.maxInputRows ?? 1e5))
|
|
1374
1375
|
throw new Error("矩阵输入超出预算");
|
|
1375
1376
|
const r = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
@@ -1384,11 +1385,11 @@ function no(e, t) {
|
|
|
1384
1385
|
const o = r.size + +(!!t.totals && e.length > 0), i = (n.size + +!!t.totals) * t.measures.length + 1;
|
|
1385
1386
|
return { rowCount: o, columnCount: i, cells: o * i };
|
|
1386
1387
|
}
|
|
1387
|
-
function
|
|
1388
|
+
function $a(e, t) {
|
|
1388
1389
|
if (t?.hierarchy)
|
|
1389
|
-
return Fr(t),
|
|
1390
|
+
return Fr(t), xa(e, t);
|
|
1390
1391
|
no(e, t);
|
|
1391
|
-
const r =
|
|
1392
|
+
const r = Ma(e, {
|
|
1392
1393
|
row: (s) => lt(s, t.rowFields),
|
|
1393
1394
|
column: (s) => lt(s, t.columnFields),
|
|
1394
1395
|
measures: t.measures.map((s) => ({ ...s, field: s.valueField ?? s.field })),
|
|
@@ -1415,24 +1416,24 @@ function Ma(e, t) {
|
|
|
1415
1416
|
}
|
|
1416
1417
|
}), t.totals && e.length && n.push(i), { rows: n, columns: o };
|
|
1417
1418
|
}
|
|
1418
|
-
const
|
|
1419
|
-
function
|
|
1419
|
+
const Sa = 96;
|
|
1420
|
+
function Ea(e, t = Sa) {
|
|
1420
1421
|
return e * t / 72;
|
|
1421
1422
|
}
|
|
1422
|
-
function Rt(e, t = 96, r =
|
|
1423
|
+
function Rt(e, t = 96, r = vr) {
|
|
1423
1424
|
if (e?.fontSizePx != null)
|
|
1424
1425
|
return { fontSizePt: e.fontSizePx * 72 / t, fontSizePx: e.fontSizePx };
|
|
1425
1426
|
const n = e?.fontSize ?? r;
|
|
1426
|
-
return { fontSizePt: n, fontSizePx:
|
|
1427
|
+
return { fontSizePt: n, fontSizePx: Ea(n, t) };
|
|
1427
1428
|
}
|
|
1428
|
-
function
|
|
1429
|
+
function Aa(e) {
|
|
1429
1430
|
return e?.lineHeight ?? kt;
|
|
1430
1431
|
}
|
|
1431
1432
|
function ee(e, t) {
|
|
1432
1433
|
const r = { ...e, ...t };
|
|
1433
1434
|
return t?.fontSize != null && t.fontSizePx == null && delete r.fontSizePx, t?.fontSizePx != null && t.fontSize == null && delete r.fontSize, r;
|
|
1434
1435
|
}
|
|
1435
|
-
function
|
|
1436
|
+
function ka(e, t) {
|
|
1436
1437
|
const r = e.length;
|
|
1437
1438
|
if (r === 0) return [];
|
|
1438
1439
|
const n = e.reduce((a, c) => a + c, 0), o = n > 0 && t > 0 ? t / n : 1, i = [];
|
|
@@ -1444,7 +1445,7 @@ function Aa(e, t) {
|
|
|
1444
1445
|
return i;
|
|
1445
1446
|
}
|
|
1446
1447
|
function bn(e, t, r) {
|
|
1447
|
-
return e?.length ?
|
|
1448
|
+
return e?.length ? ka(e, t) : Array.from({ length: r }, (n, o) => ({
|
|
1448
1449
|
pos: t * o / r,
|
|
1449
1450
|
size: t / r
|
|
1450
1451
|
}));
|
|
@@ -1457,14 +1458,14 @@ function oo(e, t, r) {
|
|
|
1457
1458
|
for (const $ of p) {
|
|
1458
1459
|
for (; x < i && u.has(d(b, x)); ) x++;
|
|
1459
1460
|
if (x >= i) break;
|
|
1460
|
-
const j = Math.max(1, Math.min($?.colSpan ?? 1, i - x)), D = Math.max(1, $?.rowSpan ?? 1),
|
|
1461
|
-
for (let N = b; N <
|
|
1462
|
-
for (let R = x; R <
|
|
1461
|
+
const j = Math.max(1, Math.min($?.colSpan ?? 1, i - x)), D = Math.max(1, $?.rowSpan ?? 1), M = Math.min(o, b + D), v = Math.min(i, x + j);
|
|
1462
|
+
for (let N = b; N < M; N++)
|
|
1463
|
+
for (let R = x; R < v; R++)
|
|
1463
1464
|
u.add(d(N, R));
|
|
1464
|
-
for (let N = x + 1; N <
|
|
1465
|
-
for (let R = b; R <
|
|
1466
|
-
for (let N = b + 1; N <
|
|
1467
|
-
for (let R = x; R <
|
|
1465
|
+
for (let N = x + 1; N < v; N++)
|
|
1466
|
+
for (let R = b; R < M; R++) m.add(g(N, R));
|
|
1467
|
+
for (let N = b + 1; N < M; N++)
|
|
1468
|
+
for (let R = x; R < v; R++) h.add(y(N, R));
|
|
1468
1469
|
const S = a(x), I = f(b);
|
|
1469
1470
|
l.push({
|
|
1470
1471
|
ri: b,
|
|
@@ -1472,9 +1473,9 @@ function oo(e, t, r) {
|
|
|
1472
1473
|
cell: $ ?? {},
|
|
1473
1474
|
xMm: S,
|
|
1474
1475
|
yMm: I,
|
|
1475
|
-
widthMm: a(
|
|
1476
|
-
heightMm: f(
|
|
1477
|
-
}), x =
|
|
1476
|
+
widthMm: a(v) - S,
|
|
1477
|
+
heightMm: f(M) - I
|
|
1478
|
+
}), x = v;
|
|
1478
1479
|
}
|
|
1479
1480
|
});
|
|
1480
1481
|
const w = [];
|
|
@@ -1494,10 +1495,10 @@ function oo(e, t, r) {
|
|
|
1494
1495
|
}
|
|
1495
1496
|
return { columns: s, rows: c, cells: l, edges: w };
|
|
1496
1497
|
}
|
|
1497
|
-
function
|
|
1498
|
+
function Na(e, t, r, n = e.paddingMm ?? 1) {
|
|
1498
1499
|
return t.field !== e.tree.labelField ? 0 : Math.min(r.depth * (e.tree.indentMm ?? 3), Math.max(0, t.widthMm - n * 2 - 4));
|
|
1499
1500
|
}
|
|
1500
|
-
function
|
|
1501
|
+
function Pa(e, t, r, n) {
|
|
1501
1502
|
const o = n.tree;
|
|
1502
1503
|
(o.input === "nested" || [o.idField, o.parentField].includes(t.field)) && (e.editable = !1), r.hasChildren && o.parentValues === "leaf-aggregate" && o.aggregates?.some((i) => i.field === t.field) && (e.derived = !0, e.editable = !1);
|
|
1503
1504
|
}
|
|
@@ -1516,13 +1517,13 @@ function Or(e) {
|
|
|
1516
1517
|
}
|
|
1517
1518
|
}
|
|
1518
1519
|
function so(e, t) {
|
|
1519
|
-
let r = ee({ fontSize: e.fontSizePt ??
|
|
1520
|
+
let r = ee({ fontSize: e.fontSizePt ?? vr, bold: e.headerBold ?? !0, align: "center", verticalAlign: "middle", backgroundColor: e.headerBackgroundColor }, t.style);
|
|
1520
1521
|
return e.headerAlign !== void 0 && (r.align = e.headerAlign), r = ee(r, e.headerStyle), t.headerAlign !== void 0 && (r.align = t.headerAlign), ee(r, t.headerStyle);
|
|
1521
1522
|
}
|
|
1522
|
-
function
|
|
1523
|
+
function Fa(e, t) {
|
|
1523
1524
|
return { member: "body", subtotal: "subtotal", total: "grand-total" }[e?.rows.get(t)?.kind ?? "member"];
|
|
1524
1525
|
}
|
|
1525
|
-
function
|
|
1526
|
+
function Oa(e) {
|
|
1526
1527
|
const t = e.matrix;
|
|
1527
1528
|
if (!t.hierarchy) return t;
|
|
1528
1529
|
const r = new Map(e.columns.map((o) => [o.field, o.header])), n = { sum: "求和", count: "计数", avg: "平均", min: "最小", max: "最大", weightedAvg: "加权平均" };
|
|
@@ -1535,10 +1536,10 @@ function Fa(e) {
|
|
|
1535
1536
|
return o.label === void 0 && i ? { ...o, label: `${i}(${n[o.op]})` } : o;
|
|
1536
1537
|
}) };
|
|
1537
1538
|
}
|
|
1538
|
-
function
|
|
1539
|
+
function Ra(e, t) {
|
|
1539
1540
|
if (!e.matrix) return { list: e, rows: t };
|
|
1540
1541
|
if (e.detail || e.groupBy || e.groups?.length || e.grandTotal) throw new Error("矩阵不能同时配置普通分组、总计或主从明细");
|
|
1541
|
-
const r =
|
|
1542
|
+
const r = $a(t, Oa(e)), n = r.columns.map((a) => ({ ...a, widthMm: a.semanticRole === "dimension" ? e.matrix.rowWidthMm ?? 40 : e.matrix.columnWidthMm ?? 28, editable: !1, align: a.semanticRole === "dimension" ? "center" : "right" })), o = { ...e, columns: n, headerGrid: r.headerGrid, rowKey: void 0, revisionField: void 0, sourceTokenField: void 0 };
|
|
1542
1543
|
e.layout === "wide" && (o.widthMm = n.reduce((a, c) => a + c.widthMm, 0));
|
|
1543
1544
|
const i = r.metadata, s = i ? { rows: new WeakMap(r.rows.map((a, c) => [a, i.rows[c]])), header: {
|
|
1544
1545
|
columns: i.columns,
|
|
@@ -1549,7 +1550,7 @@ function Oa(e, t) {
|
|
|
1549
1550
|
} } : void 0;
|
|
1550
1551
|
return { list: o, rows: r.rows, ...s ? { matrix: s } : {} };
|
|
1551
1552
|
}
|
|
1552
|
-
function
|
|
1553
|
+
function Ia(e, t) {
|
|
1553
1554
|
if (!e.matrix?.hierarchy || !e.headerGrid) return e.headerGrid;
|
|
1554
1555
|
const r = e.paddingMm ?? 1, n = e.headerGrid.cells.map(() => e.rowHeightMm ?? 0), o = e.columns.map((c) => c.widthMm), i = oo({ ...e.headerGrid, colWidthsMm: o }, o.reduce((c, f) => c + f, 0), n.length), s = /* @__PURE__ */ new WeakMap();
|
|
1555
1556
|
for (const { cell: c, ci: f, ri: u, widthMm: d } of i.cells) {
|
|
@@ -1598,7 +1599,7 @@ function $e(e) {
|
|
|
1598
1599
|
const t = new Error("树报表处理已取消");
|
|
1599
1600
|
throw t.name = "AbortError", t;
|
|
1600
1601
|
}
|
|
1601
|
-
function
|
|
1602
|
+
function Ca(e) {
|
|
1602
1603
|
const t = e.aggregates ?? [];
|
|
1603
1604
|
if (!Array.isArray(t) || t.length > 32) throw new Error("树聚合最多 32 项");
|
|
1604
1605
|
if (e.parentValues !== "leaf-aggregate" && t.length) throw new Error("树聚合需显式选择 leaf-aggregate 父级取值策略");
|
|
@@ -1611,7 +1612,7 @@ function Ia(e) {
|
|
|
1611
1612
|
r.add(n.field), se({ ...n, field: n.valueField ?? n.field });
|
|
1612
1613
|
}
|
|
1613
1614
|
}
|
|
1614
|
-
function
|
|
1615
|
+
function Ta(e) {
|
|
1615
1616
|
if (!we(e.idField) || !we(e.labelField)) throw new Error("树需要安全的业务键和标签字段");
|
|
1616
1617
|
if (e.input === "flat" && (!we(e.parentField) || e.parentField === e.idField)) throw new Error("扁平树需要独立的父键字段");
|
|
1617
1618
|
if (e.childrenField !== void 0 && !we(e.childrenField)) throw new Error("子节点字段应安全且非空");
|
|
@@ -1619,10 +1620,10 @@ function Ca(e) {
|
|
|
1619
1620
|
}
|
|
1620
1621
|
function mo(e) {
|
|
1621
1622
|
if (!e || typeof e != "object" || !["flat", "nested"].includes(e.input)) throw new Error("树输入应为 flat 或 nested");
|
|
1622
|
-
if (
|
|
1623
|
+
if (Ta(e), e.orphan !== void 0 && !["error", "root"].includes(e.orphan)) throw new Error("树孤儿策略应为 error 或 root");
|
|
1623
1624
|
if (e.parentValues !== void 0 && !["source", "leaf-aggregate"].includes(e.parentValues)) throw new Error("未知树父级取值策略");
|
|
1624
1625
|
if (e.indentMm !== void 0 && (!Number.isFinite(e.indentMm) || e.indentMm < 0 || e.indentMm > 20)) throw new Error("树每级缩进应为 0–20 mm");
|
|
1625
|
-
Rr(e),
|
|
1626
|
+
Rr(e), Ca(e);
|
|
1626
1627
|
}
|
|
1627
1628
|
function ho(e, t, r, n) {
|
|
1628
1629
|
if (!e || typeof e != "object" || Array.isArray(e)) throw new Error("树节点应为对象");
|
|
@@ -1632,7 +1633,7 @@ function ho(e, t, r, n) {
|
|
|
1632
1633
|
const s = { original: e, row: e, key: o, depth: 0, children: [] };
|
|
1633
1634
|
return r.set(i, s), s;
|
|
1634
1635
|
}
|
|
1635
|
-
function
|
|
1636
|
+
function ja(e, t, r, n, o) {
|
|
1636
1637
|
for (const s of e)
|
|
1637
1638
|
$e(o), ho(s, t, r, n);
|
|
1638
1639
|
const i = [];
|
|
@@ -1654,7 +1655,7 @@ function Ta(e, t, r, n, o) {
|
|
|
1654
1655
|
}
|
|
1655
1656
|
return i;
|
|
1656
1657
|
}
|
|
1657
|
-
function
|
|
1658
|
+
function Da(e, t, r, n, o) {
|
|
1658
1659
|
const i = [], s = [{ rows: e, next: 0 }];
|
|
1659
1660
|
for (; s.length; ) {
|
|
1660
1661
|
$e(o);
|
|
@@ -1674,7 +1675,7 @@ function ja(e, t, r, n, o) {
|
|
|
1674
1675
|
}
|
|
1675
1676
|
return i;
|
|
1676
1677
|
}
|
|
1677
|
-
function
|
|
1678
|
+
function La(e, t, r, n) {
|
|
1678
1679
|
const o = [], i = [{ nodes: e, next: 0 }];
|
|
1679
1680
|
for (; i.length; ) {
|
|
1680
1681
|
$e(n);
|
|
@@ -1690,7 +1691,7 @@ function Da(e, t, r, n) {
|
|
|
1690
1691
|
if (o.length !== t) throw new Error("树父子关系存在循环");
|
|
1691
1692
|
return o;
|
|
1692
1693
|
}
|
|
1693
|
-
function
|
|
1694
|
+
function Ba(e, t, r, n) {
|
|
1694
1695
|
if (t.parentValues !== "leaf-aggregate") return;
|
|
1695
1696
|
const o = t.aggregates, i = /* @__PURE__ */ new Map();
|
|
1696
1697
|
for (const a of e) a.children.length && i.set(a, o.map((c) => se({ ...c, field: c.valueField ?? c.field })));
|
|
@@ -1708,8 +1709,8 @@ function La(e, t, r, n) {
|
|
|
1708
1709
|
}
|
|
1709
1710
|
function go(e, t, r) {
|
|
1710
1711
|
if (mo(t), $e(r), !Array.isArray(e)) throw new Error("树数据应为节点数组");
|
|
1711
|
-
const n = Rr(t), o = /* @__PURE__ */ new Map(), i = t.input === "flat" ?
|
|
1712
|
-
return
|
|
1712
|
+
const n = Rr(t), o = /* @__PURE__ */ new Map(), i = t.input === "flat" ? ja(e, t, o, n, r) : Da(e, t, o, n, r);
|
|
1713
|
+
return La(i, o.size, n, r);
|
|
1713
1714
|
}
|
|
1714
1715
|
function po(e, t, r) {
|
|
1715
1716
|
return go(e, t, r).map((n) => n.original);
|
|
@@ -1722,9 +1723,9 @@ function yo(e, t, r = {}) {
|
|
|
1722
1723
|
i.row = o[s];
|
|
1723
1724
|
});
|
|
1724
1725
|
}
|
|
1725
|
-
return
|
|
1726
|
+
return Ba(n, t, Rr(t), r.signal), { rows: n.map((o) => o.row), entries: n.map((o) => ({ row: o.row, original: o.original, key: o.key, depth: o.depth, hasChildren: !!o.children.length })), leaves: n.filter((o) => !o.children.length).map((o) => o.row) };
|
|
1726
1727
|
}
|
|
1727
|
-
function
|
|
1728
|
+
function _a(e, t, r) {
|
|
1728
1729
|
const n = /* @__PURE__ */ new Set(), o = e.cells.map((i, s) => {
|
|
1729
1730
|
const a = [];
|
|
1730
1731
|
let c = 0;
|
|
@@ -1743,7 +1744,7 @@ function Ba(e, t, r) {
|
|
|
1743
1744
|
});
|
|
1744
1745
|
return { ...e, cells: o, colWidthsMm: r };
|
|
1745
1746
|
}
|
|
1746
|
-
function
|
|
1747
|
+
function Ka(e) {
|
|
1747
1748
|
if (!e.columns.some((n) => n.hidden)) return e;
|
|
1748
1749
|
const t = /* @__PURE__ */ new Set(), r = e.columns.filter((n, o) => n.hidden ? !1 : (t.add(o), !0));
|
|
1749
1750
|
if (!r.length) throw new Error("列表至少需要一列可见列");
|
|
@@ -1751,7 +1752,7 @@ function _a(e) {
|
|
|
1751
1752
|
...e,
|
|
1752
1753
|
columns: r,
|
|
1753
1754
|
...e.headerGrid ? {
|
|
1754
|
-
headerGrid:
|
|
1755
|
+
headerGrid: _a(
|
|
1755
1756
|
e.headerGrid,
|
|
1756
1757
|
t,
|
|
1757
1758
|
r.map((n) => n.widthMm)
|
|
@@ -1762,10 +1763,10 @@ function _a(e) {
|
|
|
1762
1763
|
function Cr(e) {
|
|
1763
1764
|
return e.kind === "list" ? e.id : e.nid;
|
|
1764
1765
|
}
|
|
1765
|
-
function
|
|
1766
|
+
function Wa(e) {
|
|
1766
1767
|
return e.kind === "list" ? !1 : e.pageAnchor !== void 0 || e.kind === "text" && typeof e.text == "string" && /\{(?:page|totalPages)\}/.test(e.text);
|
|
1767
1768
|
}
|
|
1768
|
-
function
|
|
1769
|
+
function za(e, t) {
|
|
1769
1770
|
const r = e.filter((o) => t.componentIds.includes(Cr(o) ?? ""));
|
|
1770
1771
|
if (r.filter((o) => o.kind === "list" && o.cardinality !== "record").length && r.length !== 1) throw new Error("纵向重复区域必须独占流式分段,不能与静态或单记录区域并排");
|
|
1771
1772
|
for (const o of r) {
|
|
@@ -1773,7 +1774,7 @@ function Wa(e, t) {
|
|
|
1773
1774
|
if (o.topMm < t.topMm - 1e-3 || i > t.topMm + t.heightMm + 1e-3) throw new Error("流式分段应完整包含其组件的原始纵向范围");
|
|
1774
1775
|
}
|
|
1775
1776
|
}
|
|
1776
|
-
function
|
|
1777
|
+
function Ja(e, t) {
|
|
1777
1778
|
if (!t) return e.map((n) => ({ components: [n] }));
|
|
1778
1779
|
const r = new Map(e.map((n) => [Cr(n), n]));
|
|
1779
1780
|
return t.bands.map((n) => ({ band: n, components: n.componentIds.map((o) => {
|
|
@@ -1786,14 +1787,14 @@ function wo(e, t) {
|
|
|
1786
1787
|
if (!t || !Array.isArray(t.bands) || !t.bands.length || t.bands.length > 1e4) throw new Error("流式排版应包含 1–10000 个区域");
|
|
1787
1788
|
const r = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
1788
1789
|
for (const o of e) {
|
|
1789
|
-
if (
|
|
1790
|
+
if (Wa(o)) continue;
|
|
1790
1791
|
const i = Cr(o);
|
|
1791
1792
|
if (!i || r.has(i)) throw new Error("流式排版组件应具有唯一标识");
|
|
1792
1793
|
r.add(i);
|
|
1793
1794
|
}
|
|
1794
|
-
if (
|
|
1795
|
+
if (Va(e, t, r, n), n.size !== r.size) throw new Error("流式排版必须显式包含每个非锚点组件");
|
|
1795
1796
|
}
|
|
1796
|
-
function
|
|
1797
|
+
function Va(e, t, r, n) {
|
|
1797
1798
|
let o = -1 / 0;
|
|
1798
1799
|
for (const i of t.bands) {
|
|
1799
1800
|
if (!Number.isFinite(i.topMm) || !Number.isFinite(i.heightMm) || i.topMm < 0 || i.heightMm <= 0 || i.topMm < o - 1e-3) throw new Error("流式区域应按原始位置排序,尺寸有效且不重叠");
|
|
@@ -1802,14 +1803,14 @@ function Ja(e, t, r, n) {
|
|
|
1802
1803
|
if (!r.has(s) || n.has(s)) throw new Error(`流式区域组件缺失、重复或包含页锚点:${s}`);
|
|
1803
1804
|
n.add(s);
|
|
1804
1805
|
}
|
|
1805
|
-
|
|
1806
|
+
za(e, i), o = i.topMm + i.heightMm;
|
|
1806
1807
|
}
|
|
1807
1808
|
}
|
|
1808
|
-
function*
|
|
1809
|
+
function* Ha(e) {
|
|
1809
1810
|
const { page: t } = e;
|
|
1810
1811
|
wo(t.components, t.flow);
|
|
1811
1812
|
let r = 0, n = 0;
|
|
1812
|
-
for (const o of
|
|
1813
|
+
for (const o of Ja(t.components, t.flow)) {
|
|
1813
1814
|
e.active();
|
|
1814
1815
|
const i = o.band, s = o.components.some((u) => u.kind === "list" && u.cardinality !== "record"), a = s ? 0 : o.components.reduce((u, d) => Math.max(u, d.topMm - i.topMm + (d.kind === "list" ? e.height(d) : d.heightMm)), i.heightMm);
|
|
1815
1816
|
let c = Math.max(e.top(), n + i.topMm - r);
|
|
@@ -1825,23 +1826,23 @@ function* Va(e) {
|
|
|
1825
1826
|
n = f, r = i.topMm + i.heightMm;
|
|
1826
1827
|
}
|
|
1827
1828
|
}
|
|
1828
|
-
function
|
|
1829
|
+
function Ua(e) {
|
|
1829
1830
|
return !!(e.computed?.length || e.groups?.length || e.groupBy || e.grandTotal || e.rowVisibleWhen || e.matrix || e.tree || e.detail || e.columns.some((t) => t.rules?.length || t.visibleWhen || t.visual));
|
|
1830
1831
|
}
|
|
1831
1832
|
function Tr(e) {
|
|
1832
|
-
return e.pages.some((t) => t.components.some((r) => r.kind === "list" ?
|
|
1833
|
+
return e.pages.some((t) => t.components.some((r) => r.kind === "list" ? Ua(r) : !!r.chartBinding));
|
|
1833
1834
|
}
|
|
1834
|
-
const
|
|
1835
|
+
const Ga = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
1835
1836
|
function ne(e) {
|
|
1836
1837
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
1837
1838
|
}
|
|
1838
1839
|
function Xe(e) {
|
|
1839
|
-
return typeof e == "string" && !!e.trim() && !
|
|
1840
|
+
return typeof e == "string" && !!e.trim() && !Ga.has(e);
|
|
1840
1841
|
}
|
|
1841
1842
|
function dt(e, t, r, n) {
|
|
1842
1843
|
for (const o of Object.keys(e)) t.includes(o) || n.push({ path: `${r}.${o}`, message: "存在未知配置字段" });
|
|
1843
1844
|
}
|
|
1844
|
-
function
|
|
1845
|
+
function Ya(e, t, r) {
|
|
1845
1846
|
if (e !== void 0) {
|
|
1846
1847
|
if (!ne(e) || !["number", "percent", "date"].includes(String(e.kind))) {
|
|
1847
1848
|
r.push({ path: t, message: "绑定格式应为 number、percent 或 date" });
|
|
@@ -1850,7 +1851,7 @@ function Ga(e, t, r) {
|
|
|
1850
1851
|
dt(e, e.kind === "date" ? ["kind", "pattern"] : e.kind === "number" ? ["kind", "digits", "thousands"] : ["kind", "digits"], t, r), e.digits !== void 0 && (!Number.isInteger(e.digits) || Number(e.digits) < 0 || Number(e.digits) > 100) && r.push({ path: `${t}.digits`, message: "精度应为 0..100 整数" }), e.thousands !== void 0 && typeof e.thousands != "boolean" && r.push({ path: `${t}.thousands`, message: "千分位开关应为布尔值" }), e.pattern !== void 0 && typeof e.pattern != "string" && r.push({ path: `${t}.pattern`, message: "日期格式应为字符串" });
|
|
1851
1852
|
}
|
|
1852
1853
|
}
|
|
1853
|
-
function
|
|
1854
|
+
function qa(e, t, r) {
|
|
1854
1855
|
const n = e.binding;
|
|
1855
1856
|
if (n === void 0) return;
|
|
1856
1857
|
const o = `${t}.binding`;
|
|
@@ -1860,9 +1861,9 @@ function Ya(e, t, r) {
|
|
|
1860
1861
|
}
|
|
1861
1862
|
(!["text", "image", "barcode", "qrcode"].includes(String(e.kind)) || e.grid !== void 0) && r.push({ path: o, message: "绑定仅支持独立文本、图片、条码与二维码组件" }), dt(n, ["field", "format", "prefix", "suffix", "emptyText"], o, r), Xe(n.field) || r.push({ path: `${o}.field`, message: "绑定字段应为安全的非空字段名(按字面读取自有字段)" });
|
|
1862
1863
|
for (const i of ["prefix", "suffix", "emptyText"]) n[i] !== void 0 && typeof n[i] != "string" && r.push({ path: `${o}.${i}`, message: "应为字符串" });
|
|
1863
|
-
|
|
1864
|
+
Ya(n.format, `${o}.format`, r), e.kind === "image" && ["format", "prefix", "suffix"].some((i) => n[i] !== void 0) && r.push({ path: o, message: "图片绑定直接读取 PNG/JPEG data URL,不支持文本格式或前后缀" });
|
|
1864
1865
|
}
|
|
1865
|
-
function
|
|
1866
|
+
function Xa(e, t) {
|
|
1866
1867
|
if (!ne(e)) {
|
|
1867
1868
|
t.push({ path: "$.repeat", message: "逐记录配置应为对象" });
|
|
1868
1869
|
return;
|
|
@@ -1873,7 +1874,7 @@ function qa(e, t) {
|
|
|
1873
1874
|
}
|
|
1874
1875
|
function bo(e, t, r, n) {
|
|
1875
1876
|
if (!ne(e)) return;
|
|
1876
|
-
|
|
1877
|
+
qa(e, t, n), e.binding !== void 0 && !r && n.push({ path: `${t}.binding`, message: "字段绑定需要模板 repeat 数据集;普通报表请使用列表字段" }), r && e.kind === "list" && n.push({ path: t, message: "逐记录标签使用固定组件;动态列表请使用普通报表模板" }), e.chartBinding !== void 0 && (r || t.includes(".children.")) && n.push({ path: `${t}.chartBinding`, message: "数据图表应放在普通报表的页面或流式分区,不放在逐记录标签或嵌套单元格内" });
|
|
1877
1878
|
const o = e.grid;
|
|
1878
1879
|
ne(o) && Array.isArray(o.cells) && o.cells.forEach((i, s) => {
|
|
1879
1880
|
Array.isArray(i) && i.forEach((a, c) => {
|
|
@@ -1883,7 +1884,7 @@ function bo(e, t, r, n) {
|
|
|
1883
1884
|
}
|
|
1884
1885
|
function xo(e, t) {
|
|
1885
1886
|
const r = e.repeat !== void 0;
|
|
1886
|
-
r &&
|
|
1887
|
+
r && Xa(e.repeat, t), Array.isArray(e.pages) && e.pages.forEach((n, o) => {
|
|
1887
1888
|
if (!ne(n)) return;
|
|
1888
1889
|
const i = `$.pages.${o}`;
|
|
1889
1890
|
r && (n.layout === "wide" || n.flow !== void 0) && t.push({ path: i, message: "逐记录标签仅支持固定尺寸页面,不支持宽表或流式分区" }), Array.isArray(n.components) && n.components.forEach((s, a) => {
|
|
@@ -1894,8 +1895,8 @@ function xo(e, t) {
|
|
|
1894
1895
|
});
|
|
1895
1896
|
});
|
|
1896
1897
|
}
|
|
1897
|
-
const
|
|
1898
|
-
function
|
|
1898
|
+
const Za = 512, xn = 256 * 1024;
|
|
1899
|
+
function Qa() {
|
|
1899
1900
|
const e = /* @__PURE__ */ new Map();
|
|
1900
1901
|
let t = 0, r;
|
|
1901
1902
|
return (n, o, i, s) => {
|
|
@@ -1905,7 +1906,7 @@ function Za() {
|
|
|
1905
1906
|
return e.delete(a), e.set(a, c), c.lines.slice();
|
|
1906
1907
|
const f = We(n, o, i, s), u = a.length + f.reduce((d, l) => d + l.length, 0);
|
|
1907
1908
|
if (u <= xn) {
|
|
1908
|
-
for (; e.size >=
|
|
1909
|
+
for (; e.size >= Za || t + u > xn; ) {
|
|
1909
1910
|
const d = e.keys().next().value;
|
|
1910
1911
|
t -= e.get(d).units, e.delete(d);
|
|
1911
1912
|
}
|
|
@@ -1914,7 +1915,7 @@ function Za() {
|
|
|
1914
1915
|
return f;
|
|
1915
1916
|
};
|
|
1916
1917
|
}
|
|
1917
|
-
function
|
|
1918
|
+
function ec(e) {
|
|
1918
1919
|
return typeof e == "string" && /^data:image\/(png|jpe?g);base64,[A-Za-z0-9+/\r\n]+=*$/.test(e);
|
|
1919
1920
|
}
|
|
1920
1921
|
class H extends Error {
|
|
@@ -1929,78 +1930,78 @@ function jr(e, t, r = {}) {
|
|
|
1929
1930
|
if (a == null || typeof a == "string" || typeof a == "boolean" || typeof a == "number" && Number.isFinite(a)) return a;
|
|
1930
1931
|
throw new H(i, "绑定值应为字符串、有限数字、布尔值或空值", n, t);
|
|
1931
1932
|
}
|
|
1932
|
-
function
|
|
1933
|
+
function tc(e, t, r = {}) {
|
|
1933
1934
|
const n = jr(t, e.field, r);
|
|
1934
1935
|
return n == null || n === "" ? e.emptyText ?? "" : `${e.prefix ?? ""}${Er(n, e.format)}${e.suffix ?? ""}`;
|
|
1935
1936
|
}
|
|
1936
|
-
const
|
|
1937
|
+
const rc = 1e4, Mn = 25e4;
|
|
1937
1938
|
function Dr(e) {
|
|
1938
1939
|
if (e?.aborted) throw e.reason ?? new DOMException("标签生成已取消", "AbortError");
|
|
1939
1940
|
}
|
|
1940
|
-
function
|
|
1941
|
+
function Mo(e, t, r) {
|
|
1941
1942
|
const n = typeof e.copies == "object" ? jr(t, e.copies.field, r) : e.copies ?? 1;
|
|
1942
1943
|
if (typeof n != "number" || !Number.isSafeInteger(n) || n < 1 || n > 1e3) throw new H(`$.datasets.${r.dataset}[${r.rowIndex}]`, "每条记录复制数必须是 1..1000 的数值型整数", r.rowIndex, typeof e.copies == "object" ? e.copies.field : void 0);
|
|
1943
1944
|
return n;
|
|
1944
1945
|
}
|
|
1945
|
-
function
|
|
1946
|
+
function vo(e, t, r) {
|
|
1946
1947
|
if (e.rowKey === void 0) return;
|
|
1947
1948
|
const n = jr(t, e.rowKey, r);
|
|
1948
1949
|
if (typeof n == "string" && n.trim() || typeof n == "number" && Number.isFinite(n)) return n;
|
|
1949
1950
|
throw new H(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`, "业务主键必须是非空字符串或有限数字", r.rowIndex, e.rowKey);
|
|
1950
1951
|
}
|
|
1951
|
-
function
|
|
1952
|
+
function nc(e) {
|
|
1952
1953
|
const t = (r) => 1 + (r.grid?.cells.reduce((n, o) => n + 1 + o.length + o.reduce((i, s) => i + (s?.children?.reduce((a, c) => a + t(c), 0) ?? 0), 0), 0) ?? 0);
|
|
1953
1954
|
return e.pages.reduce((r, n) => r + n.components.reduce((o, i) => o + t(i), 0), 0);
|
|
1954
1955
|
}
|
|
1955
|
-
function
|
|
1956
|
+
function oc(e, t, r) {
|
|
1956
1957
|
const n = e.repeat, o = Object.prototype.hasOwnProperty.call(t, n.dataset) ? t[n.dataset] : void 0;
|
|
1957
1958
|
if (!Array.isArray(o)) throw new H(`$.datasets.${n.dataset}`, "逐记录标签数据集缺失,应提供对象数组(允许空数组)");
|
|
1958
|
-
const i = /* @__PURE__ */ new Set(), s = r.maxPages ??
|
|
1959
|
+
const i = /* @__PURE__ */ new Set(), s = r.maxPages ?? rc, a = nc(e);
|
|
1959
1960
|
let c = 0, f = 0;
|
|
1960
1961
|
for (const [u, d] of o.entries()) {
|
|
1961
1962
|
if (Dr(r.signal), !d || typeof d != "object" || Array.isArray(d)) throw new H(`$.datasets.${n.dataset}[${u}]`, "标签记录应为对象", u);
|
|
1962
|
-
const l = { rowIndex: u, dataset: n.dataset }, m =
|
|
1963
|
+
const l = { rowIndex: u, dataset: n.dataset }, m = vo(n, d, l);
|
|
1963
1964
|
if (m !== void 0) {
|
|
1964
1965
|
const g = JSON.stringify([typeof m, m]);
|
|
1965
1966
|
if (i.has(g)) throw new H(`$.datasets.${n.dataset}[${u}].${n.rowKey}`, "业务主键重复;请先确认记录来源,避免重复打印标签", u, n.rowKey);
|
|
1966
1967
|
i.add(g);
|
|
1967
1968
|
}
|
|
1968
|
-
const h =
|
|
1969
|
-
if (c += h * e.pages.length, f += h * a, c > s) throw new
|
|
1970
|
-
if (f >
|
|
1969
|
+
const h = Mo(n, d, l);
|
|
1970
|
+
if (c += h * e.pages.length, f += h * a, c > s) throw new ve(s, c);
|
|
1971
|
+
if (f > Mn) throw new H("$.repeat", `标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${Mn},请分批生成`, u);
|
|
1971
1972
|
}
|
|
1972
1973
|
return o;
|
|
1973
1974
|
}
|
|
1974
|
-
function
|
|
1975
|
+
function ic(e, t, r) {
|
|
1975
1976
|
if (!e.binding) return e;
|
|
1976
|
-
const { binding: n, ...o } = e, i =
|
|
1977
|
+
const { binding: n, ...o } = e, i = tc(n, t.row, t);
|
|
1977
1978
|
if (e.kind === "image") {
|
|
1978
1979
|
if (!i) return;
|
|
1979
|
-
if (!
|
|
1980
|
+
if (!ec(i)) throw new H(`${r}.binding`, "图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换", t.rowIndex, n.field);
|
|
1980
1981
|
return { ...o, imageData: i };
|
|
1981
1982
|
}
|
|
1982
1983
|
return e.kind === "barcode" || e.kind === "qrcode" ? (delete o.imageData, { ...o, code: { ...o.code, value: i }, fallbackText: i }) : (delete o.lines, delete o.richParagraphs, { ...o, text: i });
|
|
1983
1984
|
}
|
|
1984
|
-
function
|
|
1985
|
+
function sc(e, t, r) {
|
|
1985
1986
|
if (e.kind !== "text" || e.grid || e.richParagraphs?.length) return e;
|
|
1986
1987
|
const n = e.style ?? {}, o = Rt(n).fontSizePt, i = e.text ?? e.lines?.join(`
|
|
1987
1988
|
`) ?? "";
|
|
1988
1989
|
if (i.length > 16384) throw new H(r, "标签文本超过 16384 字符预算,请缩小字段内容", t.rowIndex);
|
|
1989
|
-
const s = t.wrapText(i, e.widthMm, { fontSizePt: o, bold: n.bold, italic: n.italic, fontFamily: n.fontFamily, letterSpacingPt: n.letterSpacing }, t.options.measurer ?? $r), a = s.length * o *
|
|
1990
|
+
const s = t.wrapText(i, e.widthMm, { fontSizePt: o, bold: n.bold, italic: n.italic, fontFamily: n.fontFamily, letterSpacingPt: n.letterSpacing }, t.options.measurer ?? $r), a = s.length * o * Aa(n) * 25.4 / 72;
|
|
1990
1991
|
if (a > e.heightMm + 0.05) throw new H(r, `标签文字需要约 ${a.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`, t.rowIndex, e.binding?.field);
|
|
1991
1992
|
return { ...e, lines: s };
|
|
1992
1993
|
}
|
|
1993
1994
|
function $o(e, t, r) {
|
|
1994
1995
|
Dr(t.options.signal);
|
|
1995
|
-
const n =
|
|
1996
|
+
const n = ic(e, t, r);
|
|
1996
1997
|
if (!n) return;
|
|
1997
1998
|
let o = n.grid;
|
|
1998
1999
|
return o && (o = { ...o, cells: o.cells.map((i, s) => i.map((a, c) => a?.children?.length ? { ...a, children: a.children.flatMap((f, u) => {
|
|
1999
2000
|
const d = $o(f, t, `${r}.grid.cells.${s}.${c}.children.${u}`);
|
|
2000
2001
|
return d ? [d] : [];
|
|
2001
|
-
}) } : a)) }),
|
|
2002
|
+
}) } : a)) }), sc(o === n.grid ? n : { ...n, grid: o }, t, r);
|
|
2002
2003
|
}
|
|
2003
|
-
function
|
|
2004
|
+
function ac(e, t, r, n, o, i) {
|
|
2004
2005
|
return {
|
|
2005
2006
|
...e,
|
|
2006
2007
|
components: e.components.flatMap((s, a) => {
|
|
@@ -2010,25 +2011,25 @@ function sc(e, t, r, n, o, i) {
|
|
|
2010
2011
|
meta: { ...e.meta, record: { dataset: r.dataset, rowIndex: r.rowIndex, ...i === void 0 ? {} : { rowKey: i }, copyIndex: n, copyCount: o, templatePageIndex: t } }
|
|
2011
2012
|
};
|
|
2012
2013
|
}
|
|
2013
|
-
function*
|
|
2014
|
+
function* cc(e, t, r) {
|
|
2014
2015
|
const n = [];
|
|
2015
2016
|
if (xo(e, n), n.length) throw new H(n[0].path, n[0].message);
|
|
2016
2017
|
if (!e.repeat) {
|
|
2017
2018
|
for (const [a, c] of e.pages.entries()) yield { page: c, pageIndex: a };
|
|
2018
2019
|
return;
|
|
2019
2020
|
}
|
|
2020
|
-
const o = e.repeat, i =
|
|
2021
|
+
const o = e.repeat, i = oc(e, t, r), s = Qa();
|
|
2021
2022
|
for (const [a, c] of i.entries()) {
|
|
2022
|
-
const f = { row: c, rowIndex: a, dataset: o.dataset, options: r, wrapText: s }, u =
|
|
2023
|
+
const f = { row: c, rowIndex: a, dataset: o.dataset, options: r, wrapText: s }, u = Mo(o, c, f), d = vo(o, c, f);
|
|
2023
2024
|
for (let l = 0; l < u; l++) for (const [m, h] of e.pages.entries())
|
|
2024
|
-
Dr(r.signal), yield { page:
|
|
2025
|
+
Dr(r.signal), yield { page: ac(h, m, f, l, u, d), pageIndex: m };
|
|
2025
2026
|
}
|
|
2026
2027
|
}
|
|
2027
|
-
const
|
|
2028
|
+
const fc = /^#[0-9a-f]{6}$/i;
|
|
2028
2029
|
function So(e) {
|
|
2029
2030
|
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
2030
2031
|
const t = e;
|
|
2031
|
-
return t.kind !== "colorScale" && t.kind !== "dataBar" || t.field !== void 0 && (typeof t.field != "string" || !t.field.trim()) || t.numeric !== void 0 && !["number", "decimal"].includes(t.numeric) || [t.min, t.max].some((r) => r !== void 0 && (typeof r != "number" || !Number.isFinite(r))) || t.min !== void 0 && t.max !== void 0 && t.min > t.max ? !1 : Object.entries(t).every(([r, n]) => !["color", "negativeColor", "lowColor", "highColor"].includes(r) || typeof n == "string" &&
|
|
2032
|
+
return t.kind !== "colorScale" && t.kind !== "dataBar" || t.field !== void 0 && (typeof t.field != "string" || !t.field.trim()) || t.numeric !== void 0 && !["number", "decimal"].includes(t.numeric) || [t.min, t.max].some((r) => r !== void 0 && (typeof r != "number" || !Number.isFinite(r))) || t.min !== void 0 && t.max !== void 0 && t.min > t.max ? !1 : Object.entries(t).every(([r, n]) => !["color", "negativeColor", "lowColor", "highColor"].includes(r) || typeof n == "string" && fc.test(n));
|
|
2032
2033
|
}
|
|
2033
2034
|
function Eo(e, t) {
|
|
2034
2035
|
if (typeof e == "number") return Number.isFinite(e) ? e : void 0;
|
|
@@ -2036,7 +2037,7 @@ function Eo(e, t) {
|
|
|
2036
2037
|
const r = Number(e);
|
|
2037
2038
|
return Number.isFinite(r) ? r : void 0;
|
|
2038
2039
|
}
|
|
2039
|
-
function
|
|
2040
|
+
function uc(e, t, r) {
|
|
2040
2041
|
let n = "#";
|
|
2041
2042
|
for (const o of [1, 3, 5]) {
|
|
2042
2043
|
const i = parseInt(e.slice(o, o + 2), 16), s = parseInt(t.slice(o, o + 2), 16);
|
|
@@ -2051,7 +2052,7 @@ function Ht(e, t, r) {
|
|
|
2051
2052
|
const n = r - t;
|
|
2052
2053
|
return Number.isFinite(n) ? (e - t) / n : (e / 2 - t / 2) / (r / 2 - t / 2);
|
|
2053
2054
|
}
|
|
2054
|
-
function
|
|
2055
|
+
function lc(e, t, r, n) {
|
|
2055
2056
|
const o = /* @__PURE__ */ new WeakMap();
|
|
2056
2057
|
return { apply(i, s) {
|
|
2057
2058
|
const a = Eo(s[t], e.numeric);
|
|
@@ -2061,34 +2062,34 @@ function uc(e, t, r, n) {
|
|
|
2061
2062
|
i.dataBar = { start: Math.min(h, g), end: Math.max(h, g), color: a < 0 ? e.negativeColor ?? "#f3bcc3" : e.color ?? "#bad8fa" };
|
|
2062
2063
|
return;
|
|
2063
2064
|
}
|
|
2064
|
-
const c =
|
|
2065
|
+
const c = uc(e.lowColor ?? "#f0f7ff", e.highColor ?? "#8bbcf1", Ht(a, r, n)), f = i.style ?? {}, u = o.get(f) ?? /* @__PURE__ */ new Map();
|
|
2065
2066
|
o.set(f, u);
|
|
2066
2067
|
let d = u.get(c);
|
|
2067
2068
|
d || (d = { ...f, backgroundColor: c }, u.set(c, d)), i.style = d;
|
|
2068
2069
|
} };
|
|
2069
2070
|
}
|
|
2070
|
-
function
|
|
2071
|
+
function dc(e, t, r) {
|
|
2071
2072
|
return e.map((n) => {
|
|
2072
|
-
|
|
2073
|
+
vn(r);
|
|
2073
2074
|
const o = n.visual;
|
|
2074
2075
|
if (!o) return;
|
|
2075
2076
|
if (!So(o)) throw new TypeError("Invalid column visual rule");
|
|
2076
2077
|
const i = o.field ?? n.field;
|
|
2077
2078
|
let s = 1 / 0, a = -1 / 0, c = 0;
|
|
2078
2079
|
if (o.min === void 0 || o.max === void 0) for (const d of t) {
|
|
2079
|
-
(c++ & 1023) === 0 &&
|
|
2080
|
+
(c++ & 1023) === 0 && vn(r);
|
|
2080
2081
|
const l = Eo(d[i], o.numeric);
|
|
2081
2082
|
l !== void 0 && (s = Math.min(s, l), a = Math.max(a, l));
|
|
2082
2083
|
}
|
|
2083
2084
|
let f = o.min ?? s, u = o.max ?? a;
|
|
2084
2085
|
if (!(!Number.isFinite(f) || !Number.isFinite(u)))
|
|
2085
|
-
return f > u && (o.min !== void 0 ? u = f : f = u),
|
|
2086
|
+
return f > u && (o.min !== void 0 ? u = f : f = u), lc(o, i, f, u);
|
|
2086
2087
|
});
|
|
2087
2088
|
}
|
|
2088
|
-
function
|
|
2089
|
+
function vn(e) {
|
|
2089
2090
|
if (e?.aborted) throw e.reason ?? new DOMException("Aborted", "AbortError");
|
|
2090
2091
|
}
|
|
2091
|
-
function
|
|
2092
|
+
function mc(e) {
|
|
2092
2093
|
return {
|
|
2093
2094
|
widthMm: e.widthMm,
|
|
2094
2095
|
heightMm: e.heightMm,
|
|
@@ -2123,11 +2124,11 @@ function Ao(e, t) {
|
|
|
2123
2124
|
}
|
|
2124
2125
|
return r;
|
|
2125
2126
|
}
|
|
2126
|
-
function
|
|
2127
|
+
function hc(e) {
|
|
2127
2128
|
if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return e;
|
|
2128
2129
|
}
|
|
2129
2130
|
function Lr(e, t, r = [], n) {
|
|
2130
|
-
const o = e.fontSizePt ??
|
|
2131
|
+
const o = e.fontSizePt ?? vr, i = e.paddingMm ?? 1, s = e.columns.map((w) => w.align ?? w.style?.align ?? e.align ?? "left"), a = e.columns.map((w, p) => ({
|
|
2131
2132
|
...ee({
|
|
2132
2133
|
fontSize: o,
|
|
2133
2134
|
verticalAlign: "middle"
|
|
@@ -2156,7 +2157,7 @@ function Lr(e, t, r = [], n) {
|
|
|
2156
2157
|
const m = d.map((w, p) => ({
|
|
2157
2158
|
text: w,
|
|
2158
2159
|
style: u[p]
|
|
2159
|
-
})), h = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, g = e.columns.map((w) => w.widthMm), y =
|
|
2160
|
+
})), h = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, g = e.columns.map((w) => w.widthMm), y = gc(Ia(e, t), g, {
|
|
2160
2161
|
cells: [m],
|
|
2161
2162
|
colWidthsMm: g,
|
|
2162
2163
|
rowHeightsMm: [l],
|
|
@@ -2165,7 +2166,7 @@ function Lr(e, t, r = [], n) {
|
|
|
2165
2166
|
return {
|
|
2166
2167
|
fontSizePt: o,
|
|
2167
2168
|
paddingMm: i,
|
|
2168
|
-
visuals:
|
|
2169
|
+
visuals: dc(e.columns, r, n),
|
|
2169
2170
|
visibility: e.columns.map((w) => w.visibleWhen ? q(w.visibleWhen) : void 0),
|
|
2170
2171
|
ruleReaders: e.columns.map((w) => w.rules?.map((p) => q(p.when))),
|
|
2171
2172
|
cellStyles: a,
|
|
@@ -2181,14 +2182,14 @@ function Lr(e, t, r = [], n) {
|
|
|
2181
2182
|
columns: e.columns
|
|
2182
2183
|
};
|
|
2183
2184
|
}
|
|
2184
|
-
function
|
|
2185
|
+
function gc(e, t, r) {
|
|
2185
2186
|
if (!e) return r;
|
|
2186
2187
|
if (!e.cells.length) throw new Error("自定义列表表头至少需要一行");
|
|
2187
2188
|
const n = e.rowHeightsMm ?? e.cells.map(() => r.rowHeightsMm[0]);
|
|
2188
2189
|
if (n.length !== e.cells.length || n.some((o) => !Number.isFinite(o) || o <= 0)) throw new Error("自定义列表表头行高无效");
|
|
2189
2190
|
return { ...e, colWidthsMm: t, rowHeightsMm: n };
|
|
2190
2191
|
}
|
|
2191
|
-
function
|
|
2192
|
+
function pc(e, t, r) {
|
|
2192
2193
|
const n = t.format?.kind === "number" || t.format?.kind === "percent";
|
|
2193
2194
|
t.valueType !== void 0 ? e.valueType = t.valueType : n && (e.valueType = "number"), t.editable !== void 0 && (e.editable = t.editable), (typeof e.value == "number" || e.value == null) && r !== void 0 && (e.numberFormat = r);
|
|
2194
2195
|
}
|
|
@@ -2206,12 +2207,12 @@ function _e(e, t, r) {
|
|
|
2206
2207
|
break;
|
|
2207
2208
|
}
|
|
2208
2209
|
}
|
|
2209
|
-
const m = c.format ? Er(u, c.format) : Or(u), h =
|
|
2210
|
-
l =
|
|
2210
|
+
const m = c.format ? Er(u, c.format) : Or(u), h = yc(e, c, o);
|
|
2211
|
+
l = wc(e, c, l, o);
|
|
2211
2212
|
const g = Ao(e, l), y = We(m, Math.max(1, c.widthMm - e.paddingMm * 2 - h), g.measureOptions, r);
|
|
2212
2213
|
i = Math.max(i, y.length * g.lineMm + e.paddingMm * 2);
|
|
2213
|
-
const w =
|
|
2214
|
-
u != null && e.visuals[a]?.apply(p, t), w !== void 0 && (p.value = w),
|
|
2214
|
+
const w = hc(u), p = { text: m, style: l };
|
|
2215
|
+
u != null && e.visuals[a]?.apply(p, t), w !== void 0 && (p.value = w), pc(p, c, e.numberFormats[a]), bc(p, c, e, o, h), e.derivedFields.has(c.field) && (p.derived = !0, p.editable = !1), f || (p.editable = !1), s[a] = p;
|
|
2215
2216
|
}
|
|
2216
2217
|
return {
|
|
2217
2218
|
grid: { cells: [s], colWidthsMm: e.colWidthsMm, rowHeightsMm: [i], paddingMm: e.paddingMm },
|
|
@@ -2219,14 +2220,14 @@ function _e(e, t, r) {
|
|
|
2219
2220
|
...e.matrix ? { meta: { matrix: { row: e.matrix.rows.get(t) } } } : {}
|
|
2220
2221
|
};
|
|
2221
2222
|
}
|
|
2222
|
-
function
|
|
2223
|
-
return !r || t.field !== e.tree.list.tree.labelField ? 0 :
|
|
2223
|
+
function yc(e, t, r) {
|
|
2224
|
+
return !r || t.field !== e.tree.list.tree.labelField ? 0 : Na(e.tree.list, t, r, e.paddingMm);
|
|
2224
2225
|
}
|
|
2225
|
-
function
|
|
2226
|
+
function wc(e, t, r, n) {
|
|
2226
2227
|
return !n || t.field !== e.tree.list.tree.labelField || r.align === "left" ? r : { ...r, align: "left" };
|
|
2227
2228
|
}
|
|
2228
|
-
function
|
|
2229
|
-
n && (o && (e.indentMm = o),
|
|
2229
|
+
function bc(e, t, r, n, o = 0) {
|
|
2230
|
+
n && (o && (e.indentMm = o), Pa(e, t, n, r.tree.list));
|
|
2230
2231
|
}
|
|
2231
2232
|
function ko(e) {
|
|
2232
2233
|
if (e != null && typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e))) throw new Error("分组字段应为有限 JSON 标量");
|
|
@@ -2264,13 +2265,13 @@ function Ne(e, t, r, n, o, i) {
|
|
|
2264
2265
|
const m = e.columns[l], h = n.get(m.field), g = e.autoStyles[l]?.[io(h?.value, m.format)] ?? e.cellStyles[l];
|
|
2265
2266
|
s.push({ ...h, text: h?.text ?? "", style: ee(g, o) });
|
|
2266
2267
|
}
|
|
2267
|
-
const f = { text: r, colSpan: e.columns.length, style: { bold: !0, ...c } }, u = a ? [s] : [[f], s], d = u.map((l) =>
|
|
2268
|
+
const f = { text: r, colSpan: e.columns.length, style: { bold: !0, ...c } }, u = a ? [s] : [[f], s], d = u.map((l) => xc(e, l, t));
|
|
2268
2269
|
return {
|
|
2269
2270
|
grid: { cells: u, colWidthsMm: e.colWidthsMm, rowHeightsMm: d, paddingMm: e.paddingMm },
|
|
2270
2271
|
heightMm: d.reduce((l, m) => l + m, 0)
|
|
2271
2272
|
};
|
|
2272
2273
|
}
|
|
2273
|
-
function
|
|
2274
|
+
function xc(e, t, r) {
|
|
2274
2275
|
let n = e.rowHeightFloorMm, o = 0;
|
|
2275
2276
|
for (const i of t) {
|
|
2276
2277
|
let s = 0;
|
|
@@ -2281,10 +2282,10 @@ function bc(e, t, r) {
|
|
|
2281
2282
|
}
|
|
2282
2283
|
return n;
|
|
2283
2284
|
}
|
|
2284
|
-
function
|
|
2285
|
+
function Mc(e, t, r) {
|
|
2285
2286
|
const { templatePage: n, current: o, warnings: i, nextId: s, pushCurrent: a } = r, c = () => mt(n, o), f = Math.max(o.marginTopMm, Be(n)), u = n.layout === "wide" ? Be(n) : f, d = {
|
|
2286
2287
|
id: r.tableId,
|
|
2287
|
-
columnKeys: e.columns.map((
|
|
2288
|
+
columnKeys: e.columns.map((M) => M.field),
|
|
2288
2289
|
...e.layout === void 0 ? {} : { layout: e.layout },
|
|
2289
2290
|
...e.title === void 0 ? {} : { title: e.title }
|
|
2290
2291
|
}, l = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = {
|
|
@@ -2298,50 +2299,50 @@ function xc(e, t, r) {
|
|
|
2298
2299
|
table: { ...d, role: "header", rowIndex: -1 },
|
|
2299
2300
|
style: t.borderStyle,
|
|
2300
2301
|
...e.meta || t.matrix ? { meta: { ...e.meta, ...t.matrix ? { matrix: t.matrix.header } : {} } } : {}
|
|
2301
|
-
}, g = (
|
|
2302
|
+
}, g = (M) => o.components.push({ ...h, topMm: M });
|
|
2302
2303
|
if (r.flow && e.header !== !1 && t.headerHeightMm > c() - f + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的表头高度超出单页可用范围`);
|
|
2303
2304
|
let y = Math.max(r.startTop ?? e.topMm, f);
|
|
2304
2305
|
e.header !== !1 && (g(y), y += t.headerHeightMm + r.mmPerRow);
|
|
2305
2306
|
function w() {
|
|
2306
|
-
const
|
|
2307
|
-
return (e.header !== !1 && e.headerEveryPage !== !1 ?
|
|
2307
|
+
const M = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, u);
|
|
2308
|
+
return (e.header !== !1 && e.headerEveryPage !== !1 ? M + t.headerHeightMm : u) + [...m.values()].reduce((S, I) => S + I.heightMm, 0);
|
|
2308
2309
|
}
|
|
2309
2310
|
function p() {
|
|
2310
|
-
const
|
|
2311
|
-
return Math.min(n.heightMm -
|
|
2311
|
+
const M = n.layout === "wide" ? 0 : o.marginBottomMm;
|
|
2312
|
+
return Math.min(n.heightMm - M, mt(n, o)) - w();
|
|
2312
2313
|
}
|
|
2313
|
-
function b(
|
|
2314
|
-
if (y +
|
|
2314
|
+
function b(M) {
|
|
2315
|
+
if (y + M <= c()) return;
|
|
2315
2316
|
a(), o.components = [], o.heightMm = n.heightMm, n.layout === "wide" && (o.marginTopMm = 0, o.marginBottomMm = 0);
|
|
2316
|
-
const
|
|
2317
|
-
e.header !== !1 && e.headerEveryPage !== !1 ? (g(
|
|
2317
|
+
const v = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, u);
|
|
2318
|
+
e.header !== !1 && e.headerEveryPage !== !1 ? (g(v), y = v + t.headerHeightMm) : y = u;
|
|
2318
2319
|
for (const S of m.values()) $(S, "listgr", "group-header");
|
|
2319
2320
|
}
|
|
2320
|
-
function x(
|
|
2321
|
+
function x(M, v, S, I) {
|
|
2321
2322
|
const N = p();
|
|
2322
|
-
if (r.flow &&
|
|
2323
|
-
|
|
2323
|
+
if (r.flow && M.heightMm > N + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的单行高度超出单页可用范围`);
|
|
2324
|
+
M.heightMm > N && i.push(`列表 ${e.id ?? e.dataset} 行高 ${M.heightMm.toFixed(2)}mm 超出单页可用高度 ${N.toFixed(2)}mm,预览与打印可能截断内容`), b(M.heightMm), $(M, v, S, I);
|
|
2324
2325
|
}
|
|
2325
|
-
function $(
|
|
2326
|
-
const N =
|
|
2327
|
-
S !== "header" && l.set(N, R +
|
|
2326
|
+
function $(M, v, S, I) {
|
|
2327
|
+
const N = M.table?.id ?? d.id, R = S === "header" ? -1 : l.get(N) ?? 0;
|
|
2328
|
+
S !== "header" && l.set(N, R + M.grid.cells.length), o.components.push({
|
|
2328
2329
|
kind: "rect",
|
|
2329
2330
|
leftMm: e.leftMm,
|
|
2330
2331
|
topMm: y,
|
|
2331
2332
|
widthMm: e.widthMm,
|
|
2332
|
-
heightMm:
|
|
2333
|
-
grid:
|
|
2334
|
-
nid: s(
|
|
2335
|
-
table: { ...d, ...
|
|
2333
|
+
heightMm: M.heightMm,
|
|
2334
|
+
grid: M.grid,
|
|
2335
|
+
nid: s(v),
|
|
2336
|
+
table: { ...d, ...M.table, role: S, rowIndex: R, ...I ? { source: I } : {} },
|
|
2336
2337
|
style: t.borderStyle,
|
|
2337
|
-
...e.meta ||
|
|
2338
|
-
}), y +=
|
|
2338
|
+
...e.meta || M.meta ? { meta: { ...e.meta, ...M.meta } } : {}
|
|
2339
|
+
}), y += M.heightMm;
|
|
2339
2340
|
}
|
|
2340
|
-
function j(
|
|
2341
|
-
|
|
2341
|
+
function j(M) {
|
|
2342
|
+
M <= p() && b(M);
|
|
2342
2343
|
}
|
|
2343
|
-
return { keepTogether: j, placeGridRow: x, setGroupHeader: (
|
|
2344
|
-
|
|
2344
|
+
return { keepTogether: j, placeGridRow: x, setGroupHeader: (M, v) => {
|
|
2345
|
+
v ? m.set(M, v) : m.delete(M);
|
|
2345
2346
|
}, bottom: () => y };
|
|
2346
2347
|
}
|
|
2347
2348
|
function vc(e, t) {
|
|
@@ -2365,7 +2366,7 @@ function It(e, t) {
|
|
|
2365
2366
|
}
|
|
2366
2367
|
return r;
|
|
2367
2368
|
}
|
|
2368
|
-
function
|
|
2369
|
+
function $c(e, t, r, n, o) {
|
|
2369
2370
|
if (!e.grandTotal) return;
|
|
2370
2371
|
const i = typeof e.grandTotal == "object" ? e.grandTotal : void 0, s = Ct(e)[0], a = i?.fields ?? s?.subtotal ?? [], c = i?.aggregates ?? s?.aggregates ?? [];
|
|
2371
2372
|
if (a.length === 0 && c.length === 0) {
|
|
@@ -2387,10 +2388,10 @@ function Ct(e) {
|
|
|
2387
2388
|
return t;
|
|
2388
2389
|
}
|
|
2389
2390
|
function Br(e) {
|
|
2390
|
-
const t =
|
|
2391
|
+
const t = Ka(e), r = t.columns.reduce((o, i) => o + i.widthMm, 0), n = r > t.widthMm ? t.widthMm / r : 1;
|
|
2391
2392
|
return n === 1 ? t : { ...t, columns: t.columns.map((o) => ({ ...o, widthMm: o.widthMm * n })) };
|
|
2392
2393
|
}
|
|
2393
|
-
function
|
|
2394
|
+
function Sc(e, t, r) {
|
|
2394
2395
|
const n = e.detail;
|
|
2395
2396
|
if (!n) return;
|
|
2396
2397
|
const o = /* @__PURE__ */ new Set();
|
|
@@ -2421,7 +2422,7 @@ function or(e) {
|
|
|
2421
2422
|
if (!Oo(e)) throw new Error("主从关联键必须是非空字符串或有限数字");
|
|
2422
2423
|
return ko(e);
|
|
2423
2424
|
}
|
|
2424
|
-
function*
|
|
2425
|
+
function* Ec(e, t, r, n, o) {
|
|
2425
2426
|
if (!r) return;
|
|
2426
2427
|
const i = r.rows.get(or(t[e.detail.parentKey])) ?? [];
|
|
2427
2428
|
if (!i.length) return;
|
|
@@ -2436,14 +2437,14 @@ function Ro(e) {
|
|
|
2436
2437
|
if (!e.columns.some((t) => t.field === e.tree.labelField && !t.hidden)) throw new Error("树形布局需要可见的标签列");
|
|
2437
2438
|
Ir(e.tree, e.computed);
|
|
2438
2439
|
}
|
|
2439
|
-
function
|
|
2440
|
+
function Ac(e, t, r) {
|
|
2440
2441
|
Ro(e);
|
|
2441
2442
|
const n = yo(t, e.tree, { signal: r.signal, computed: e.computed?.length ? { fields: e.computed, formula: r.formula } : void 0 }), o = { ...e, rowKey: e.tree.idField }, i = It(o, n.entries.map((c) => c.original)), s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new WeakMap();
|
|
2442
2443
|
for (const c of n.entries)
|
|
2443
2444
|
s.set(c.row, i.get(c.original)), a.set(c.row, c);
|
|
2444
2445
|
return { list: o, rows: n.rows, sources: s, treeRows: a, totalRows: n.leaves };
|
|
2445
2446
|
}
|
|
2446
|
-
function
|
|
2447
|
+
function kc(e, t) {
|
|
2447
2448
|
if (e.cardinality === "record") {
|
|
2448
2449
|
if (t.length > 1) throw new Error(`单记录区域 ${e.id ?? e.dataset} 仅允许 0 或 1 行数据`);
|
|
2449
2450
|
if (e.tree || e.matrix || e.detail || e.groups?.length || e.groupBy || e.grandTotal || e.rowVisibleWhen) throw new Error("单记录区域不能配置树、矩阵、主从、分组、总计或行过滤");
|
|
@@ -2453,38 +2454,38 @@ function Ac(e, t) {
|
|
|
2453
2454
|
function Io(e, t, r) {
|
|
2454
2455
|
const n = r.prepared.get(e);
|
|
2455
2456
|
if (n) return n;
|
|
2456
|
-
const o =
|
|
2457
|
+
const o = kc(e, t);
|
|
2457
2458
|
if (o)
|
|
2458
2459
|
return r.prepared.set(e, o), o;
|
|
2459
2460
|
if (e.tree) {
|
|
2460
|
-
const c =
|
|
2461
|
+
const c = Ac(e, t, r);
|
|
2461
2462
|
return r.prepared.set(e, c), c;
|
|
2462
2463
|
}
|
|
2463
2464
|
let i = e.computed?.length ? Ft(t, { fields: e.computed, signal: r.signal, formula: r.formula }).rows : t;
|
|
2464
2465
|
const s = i === t ? void 0 : new Map(i.map((c, f) => [c, t[f]]));
|
|
2465
2466
|
e.rowVisibleWhen && (i = i.filter(q(e.rowVisibleWhen)));
|
|
2466
|
-
const a =
|
|
2467
|
+
const a = Ra(e, i);
|
|
2467
2468
|
if (!e.matrix) {
|
|
2468
2469
|
const c = It(e, s ? i.map((f) => s.get(f)) : i);
|
|
2469
2470
|
a.sources = s ? new Map(i.map((f) => [f, c.get(s.get(f))])) : c;
|
|
2470
2471
|
}
|
|
2471
2472
|
return r.prepared.set(e, a), a;
|
|
2472
2473
|
}
|
|
2473
|
-
function
|
|
2474
|
+
function Nc(e, t, r, n) {
|
|
2474
2475
|
if (!n.flow) return;
|
|
2475
2476
|
const { current: o, templatePage: i } = n, s = Math.max(o.marginTopMm, Be(i)), a = Math.max(n.startTop ?? e.topMm, s), c = (e.header === !1 ? 0 : t.headerHeightMm) + (r[0] ? _e(t, r[0], n.measurer).heightMm : 0);
|
|
2476
2477
|
a + c <= mt(i, o) + 1e-3 || a <= s + 1e-3 || (n.pushCurrent(), o.components = [], o.heightMm = i.heightMm, i.layout === "wide" && (o.marginTopMm = 0, o.marginBottomMm = 0), n.startTop = Math.max(o.marginTopMm, Be(i)));
|
|
2477
2478
|
}
|
|
2478
|
-
function*
|
|
2479
|
+
function* Pc(e, t, r) {
|
|
2479
2480
|
const n = Io(e, t, r), o = n.rows;
|
|
2480
2481
|
e = n.list, e.layout === "wide" && (r.current.widthMm = Math.max(r.current.widthMm, e.leftMm + e.widthMm + r.current.marginRightMm));
|
|
2481
2482
|
const i = n.sources ?? It(e, o), s = Br(e), a = Ct(s), c = { ...Lr(s, r.measurer, o, r.signal), rowHeightFloorMm: s.rowHeightMm ?? 0, matrix: n.matrix, ...n.treeRows ? { tree: { list: s, rows: n.treeRows } } : {} };
|
|
2482
|
-
|
|
2483
|
-
const f =
|
|
2483
|
+
Nc(s, c, o, r);
|
|
2484
|
+
const f = Mc(s, c, r), u = Sc(s, o, r);
|
|
2484
2485
|
let d;
|
|
2485
2486
|
for (const l of No(o, a)) {
|
|
2486
2487
|
if (ae(r.signal), l.kind === "row")
|
|
2487
|
-
f.placeGridRow(d ?? _e(c, l.row, r.measurer), "listr",
|
|
2488
|
+
f.placeGridRow(d ?? _e(c, l.row, r.measurer), "listr", Fa(n.matrix, l.row), i.get(l.row)), d = void 0, yield* r.takePages(), yield* Ec(s, l.row, u, r, f);
|
|
2488
2489
|
else if (l.kind === "groupHeader") {
|
|
2489
2490
|
const m = Ne(c, r.measurer, l.label, /* @__PURE__ */ new Map(), l.group.headerStyle ?? {}, s.columns.length);
|
|
2490
2491
|
d ??= _e(c, l.firstRow, r.measurer);
|
|
@@ -2496,7 +2497,7 @@ function* Nc(e, t, r) {
|
|
|
2496
2497
|
} else f.setGroupHeader(l.depth);
|
|
2497
2498
|
yield* r.takePages();
|
|
2498
2499
|
}
|
|
2499
|
-
|
|
2500
|
+
$c(s, n.totalRows ?? o, c, r, f), r.finished?.(f.bottom()), yield* r.takePages();
|
|
2500
2501
|
}
|
|
2501
2502
|
function _r(e) {
|
|
2502
2503
|
return e.kind !== "list" && (e.pageAnchor !== void 0 || e.kind === "text" && typeof e.text == "string" && (e.text.includes("{page}") || e.text.includes("{totalPages}")));
|
|
@@ -2510,7 +2511,7 @@ function Kr(e, t) {
|
|
|
2510
2511
|
...e.grid ? { grid: { ...e.grid, cells: e.grid.cells.map((r) => r.map((n) => n ? { ...n, ...n.text === void 0 ? {} : { text: t(n.text) }, ...n.children ? { children: n.children.map((o) => Kr(o, t)) } : {} } : null)) } } : {}
|
|
2511
2512
|
};
|
|
2512
2513
|
}
|
|
2513
|
-
function
|
|
2514
|
+
function Fc(e, t, r, n, o, i) {
|
|
2514
2515
|
const s = {
|
|
2515
2516
|
pageWidthMm: t.widthMm,
|
|
2516
2517
|
pageHeightMm: t.heightMm,
|
|
@@ -2542,17 +2543,17 @@ function To(e) {
|
|
|
2542
2543
|
for (const t of ["maxPages", "maxCells", "knownTotalPages"]) if (e[t] !== void 0 && (!Number.isSafeInteger(e[t]) || e[t] < 1)) throw new RangeError(`${t} 应为正安全整数`);
|
|
2543
2544
|
Ot(e.maxChartComponents);
|
|
2544
2545
|
}
|
|
2545
|
-
function
|
|
2546
|
+
function Oc(e, t) {
|
|
2546
2547
|
const r = Io(e, t.datasets[e.dataset] ?? [], t), n = Br(r.list), o = { ...Lr(n, t.measurer, r.rows, t.signal), rowHeightFloorMm: n.rowHeightMm ?? 0 };
|
|
2547
2548
|
return (n.header === !1 ? 0 : o.headerHeightMm) + r.rows.reduce((i, s) => i + _e(o, s, t.measurer).heightMm, 0);
|
|
2548
2549
|
}
|
|
2549
|
-
function*
|
|
2550
|
+
function* Rc(e) {
|
|
2550
2551
|
const { templatePage: t, current: r } = e, n = new Map(t.components.map((i, s) => [i, s])), o = (i, s, a) => {
|
|
2551
2552
|
const c = e.datasets[i.dataset];
|
|
2552
|
-
return Array.isArray(c) || e.warnings.push(`数据集 ${i.dataset} 未提供数据,列表 ${i.id ?? ""} 输出为空`),
|
|
2553
|
+
return Array.isArray(c) || e.warnings.push(`数据集 ${i.dataset} 未提供数据,列表 ${i.id ?? ""} 输出为空`), Pc(i, Array.isArray(c) ? c : [], { ...e, tableId: `${e.tableId}:${n.get(i)}`, startTop: s, finished: a, flow: !!t.flow });
|
|
2553
2554
|
};
|
|
2554
2555
|
if (t.flow) {
|
|
2555
|
-
yield*
|
|
2556
|
+
yield* Ha({
|
|
2556
2557
|
page: t,
|
|
2557
2558
|
active: () => ae(e.signal),
|
|
2558
2559
|
top: () => Math.max(r.marginTopMm, Be(t)),
|
|
@@ -2564,7 +2565,7 @@ function* Oc(e) {
|
|
|
2564
2565
|
e.pushCurrent(), r.components = [], r.heightMm = t.heightMm, t.layout === "wide" && (r.marginTopMm = 0, r.marginBottomMm = 0);
|
|
2565
2566
|
},
|
|
2566
2567
|
takePages: e.takePages,
|
|
2567
|
-
height: (i) =>
|
|
2568
|
+
height: (i) => Oc(i, e),
|
|
2568
2569
|
list: o
|
|
2569
2570
|
});
|
|
2570
2571
|
return;
|
|
@@ -2574,21 +2575,21 @@ function* Oc(e) {
|
|
|
2574
2575
|
}
|
|
2575
2576
|
function* jo(e, t, r, n, o, i = /* @__PURE__ */ new WeakMap(), s) {
|
|
2576
2577
|
let a = 0, c = 0, f = 0;
|
|
2577
|
-
const u =
|
|
2578
|
-
for (const { pageIndex: m, page: h } of
|
|
2578
|
+
const u = ss(r.measurer ?? $r), d = ca(t, r.signal, r.maxChartComponents), l = (m) => `${m}_${(++a).toString(36)}`;
|
|
2579
|
+
for (const { pageIndex: m, page: h } of cc(e, t, r)) {
|
|
2579
2580
|
ae(r.signal);
|
|
2580
|
-
const g =
|
|
2581
|
+
const g = mc(h), y = h.components.filter(_r);
|
|
2581
2582
|
let w = [];
|
|
2582
2583
|
const p = (x = !1) => {
|
|
2583
|
-
if (ae(r.signal), r.maxPages !== void 0 && c >= r.maxPages) throw new
|
|
2584
|
+
if (ae(r.signal), r.maxPages !== void 0 && c >= r.maxPages) throw new ve(r.maxPages, c + 1);
|
|
2584
2585
|
if (r.maxCells !== void 0 && (f += [...g.components, ...y].reduce(($, j) => $ + Co(j), 0), f > r.maxCells))
|
|
2585
2586
|
throw new De(r.maxCells, f);
|
|
2586
|
-
w.push(
|
|
2587
|
+
w.push(Fc(h, g, y, ++c, x, o));
|
|
2587
2588
|
}, b = () => {
|
|
2588
2589
|
const x = w;
|
|
2589
2590
|
return w = [], x;
|
|
2590
2591
|
};
|
|
2591
|
-
yield*
|
|
2592
|
+
yield* Rc({
|
|
2592
2593
|
templatePage: h,
|
|
2593
2594
|
current: g,
|
|
2594
2595
|
warnings: n,
|
|
@@ -2607,7 +2608,7 @@ function* jo(e, t, r, n, o, i = /* @__PURE__ */ new WeakMap(), s) {
|
|
|
2607
2608
|
}
|
|
2608
2609
|
s && (s.chartComponents = d.used());
|
|
2609
2610
|
}
|
|
2610
|
-
function
|
|
2611
|
+
function Ic(e, t, r = {}) {
|
|
2611
2612
|
const n = typeof r == "number" ? { mmPerRow: r } : r;
|
|
2612
2613
|
To(n);
|
|
2613
2614
|
const o = [], i = { chartComponents: 0 }, s = [...jo(e, t, n, o, n.knownTotalPages, void 0, i)];
|
|
@@ -2625,26 +2626,26 @@ function Lo(e, t, r, n, o) {
|
|
|
2625
2626
|
for (const i of r) i.components = i.components.map((s) => _r(s) ? Kr(s, (a) => a.replace(/\{totalPages\}/g, String(r.length))) : s);
|
|
2626
2627
|
return n.forEach((i) => t.onWarning?.(i)), { plan: { schemaVersion: Ke, ...Tr(e) ? { requiresRecalculation: !0 } : {}, pages: r }, warnings: n, ...o };
|
|
2627
2628
|
}
|
|
2628
|
-
function
|
|
2629
|
+
function Cc(e) {
|
|
2629
2630
|
const t = e.columns.find((i) => !i.hidden)?.field;
|
|
2630
2631
|
if (!t) return { groups: 0, total: 0 };
|
|
2631
2632
|
const r = Ct(e), n = (i = [], s = []) => i.includes(t) || s.some((a) => a.field === t), o = typeof e.grandTotal == "object" ? e.grandTotal : void 0;
|
|
2632
2633
|
return { groups: r.filter((i) => n(i.subtotal, i.aggregates)).length, total: Number(n(o?.fields ?? r[0]?.subtotal, o?.aggregates ?? r[0]?.aggregates)) };
|
|
2633
2634
|
}
|
|
2634
|
-
function
|
|
2635
|
+
function Tc(e, t, r) {
|
|
2635
2636
|
Ro(e);
|
|
2636
2637
|
const n = po(t[e.dataset] ?? [], e.tree, r), o = e.columns.filter((s) => !s.hidden).length, i = e.header === !1 ? 0 : e.headerGrid ? Wr(e.headerGrid) : o;
|
|
2637
2638
|
return n.length * o + i + +!!e.grandTotal * 2 * o;
|
|
2638
2639
|
}
|
|
2639
|
-
function
|
|
2640
|
-
if (e.tree) return
|
|
2640
|
+
function jc(e, t, r = {}) {
|
|
2641
|
+
if (e.tree) return Tc(e, t, r.signal);
|
|
2641
2642
|
if (e.matrix) {
|
|
2642
2643
|
let c = t[e.dataset] ?? [];
|
|
2643
2644
|
e.computed?.length && (c = Ft(c, { fields: e.computed, ...r }).rows), e.rowVisibleWhen && (c = c.filter(q(e.rowVisibleWhen)));
|
|
2644
2645
|
const f = no(c, e.matrix);
|
|
2645
2646
|
return f.cells + (e.header === !1 ? 0 : f.columnCount * (e.matrix.hierarchy ? e.matrix.columnFields.length + 1 : 1));
|
|
2646
2647
|
}
|
|
2647
|
-
const n = t[e.dataset]?.length ?? 0, o = e.columns.filter((c) => !c.hidden).length, i = Ct(e).length, s =
|
|
2648
|
+
const n = t[e.dataset]?.length ?? 0, o = e.columns.filter((c) => !c.hidden).length, i = Ct(e).length, s = Cc(e);
|
|
2648
2649
|
let a = (n * (1 + 2 * i + s.groups) + +!!e.grandTotal * (1 + s.total)) * o;
|
|
2649
2650
|
if (a += e.header === !1 ? 0 : e.headerGrid ? Wr(e.headerGrid) : o, e.cardinality === "record" && n === 0 && (a += o), e.detail) {
|
|
2650
2651
|
const c = t[e.detail.dataset]?.length ?? 0, f = e.detail.columns.filter((u) => !u.hidden).length;
|
|
@@ -2653,7 +2654,7 @@ function Tc(e, t, r = {}) {
|
|
|
2653
2654
|
if (!Number.isSafeInteger(a)) throw new RangeError("报表单元格估算超出安全整数预算");
|
|
2654
2655
|
return a;
|
|
2655
2656
|
}
|
|
2656
|
-
function
|
|
2657
|
+
function Dc(e) {
|
|
2657
2658
|
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
2658
2659
|
const { start: t, end: r, color: n } = e;
|
|
2659
2660
|
return typeof t == "number" && typeof r == "number" && Number.isFinite(t) && Number.isFinite(r) && t >= 0 && r <= 1 && t <= r && typeof n == "string" && /^#[0-9a-f]{6}$/i.test(n);
|
|
@@ -2699,17 +2700,17 @@ function _o(e) {
|
|
|
2699
2700
|
if (o) return o;
|
|
2700
2701
|
}
|
|
2701
2702
|
}
|
|
2702
|
-
function
|
|
2703
|
+
function Lc(e) {
|
|
2703
2704
|
const t = _o(e.pages);
|
|
2704
2705
|
if (t) throw new TypeError(`${t.path}: ${t.message}`);
|
|
2705
2706
|
}
|
|
2706
|
-
function
|
|
2707
|
+
function Bc(e, t, r) {
|
|
2707
2708
|
e !== void 0 && (typeof e != "string" || !e.trim() || e.length > 4096) && r.push({ path: t, message: "来源范围应为不超过 4096 字符的非空字符串" });
|
|
2708
2709
|
}
|
|
2709
2710
|
function Ko(e, t, r) {
|
|
2710
2711
|
e.editable !== void 0 && typeof e.editable != "boolean" && r.push({ path: `${t}.editable`, message: "编辑控制应为布尔值" }), e.valueType !== void 0 && !["text", "number", "boolean"].includes(e.valueType) && r.push({ path: `${t}.valueType`, message: "编辑类型应为 text、number 或 boolean" });
|
|
2711
2712
|
}
|
|
2712
|
-
function
|
|
2713
|
+
function _c(e, t, r) {
|
|
2713
2714
|
Ko(e, t, r), e.indentMm !== void 0 && (typeof e.indentMm != "number" || !Number.isFinite(e.indentMm) || e.indentMm < 0) && r.push({ path: `${t}.indentMm`, message: "单元格缩进应为有限非负数" }), e.derived !== void 0 && typeof e.derived != "boolean" && r.push({ path: `${t}.derived`, message: "派生结果标记应为布尔值" }), Wo(e.source, `${t}.source`, r, !0), e.formula !== void 0 && typeof e.formula != "string" && r.push({ path: `${t}.formula`, message: "单元格公式应为字符串" });
|
|
2714
2715
|
}
|
|
2715
2716
|
function Wo(e, t, r, n = !1) {
|
|
@@ -2719,7 +2720,7 @@ function Wo(e, t, r, n = !1) {
|
|
|
2719
2720
|
return;
|
|
2720
2721
|
}
|
|
2721
2722
|
const o = e;
|
|
2722
|
-
|
|
2723
|
+
Bc(o.sourceScope, `${t}.sourceScope`, r);
|
|
2723
2724
|
for (const i of ["datasetId", ...n ? ["field"] : []])
|
|
2724
2725
|
(typeof o[i] != "string" || !o[i].trim()) && r.push({ path: `${t}.${i}`, message: "业务标识应为非空字符串" });
|
|
2725
2726
|
for (const i of ["rowKey", "revision"]) {
|
|
@@ -2728,22 +2729,22 @@ function Wo(e, t, r, n = !1) {
|
|
|
2728
2729
|
}
|
|
2729
2730
|
o.sourceToken !== void 0 && typeof o.sourceToken != "string" && r.push({ path: `${t}.sourceToken`, message: "来源令牌应为字符串" });
|
|
2730
2731
|
}
|
|
2731
|
-
function
|
|
2732
|
+
function Kc(e) {
|
|
2732
2733
|
const t = [];
|
|
2733
2734
|
return e.value !== void 0 && typeof e.value != "string" && t.push({ path: "value", message: "Symbol value must be a string." }), e.symbology !== void 0 && !["code128", "code39", "ean13", "ean8"].includes(e.symbology) && t.push({ path: "symbology", message: "Unsupported barcode symbology." }), e.errorCorrection !== void 0 && !["L", "M", "Q", "H"].includes(e.errorCorrection) && t.push({ path: "errorCorrection", message: "Unsupported QR error correction." }), e.showText !== void 0 && typeof e.showText != "boolean" && t.push({ path: "showText", message: "showText must be a boolean." }), t;
|
|
2734
2735
|
}
|
|
2735
|
-
function
|
|
2736
|
+
function Wc(e, t) {
|
|
2736
2737
|
const r = [];
|
|
2737
2738
|
return t !== "barcode" && t !== "qrcode" && r.push({ path: "", message: "code is only supported by barcode and qrcode components." }), t === "qrcode" && e.symbology !== void 0 && r.push({ path: "symbology", message: "QR components do not use a linear symbology." }), t === "qrcode" && e.showText === !0 && r.push({ path: "showText", message: "Use a separate text component below a QR code." }), t === "barcode" && e.errorCorrection !== void 0 && r.push({ path: "errorCorrection", message: "Linear barcodes do not use QR error correction." }), r;
|
|
2738
2739
|
}
|
|
2739
|
-
function
|
|
2740
|
+
function zc(e, t) {
|
|
2740
2741
|
if (typeof e != "object" || e === null || Array.isArray(e)) return [{ path: "", message: "code must be an object." }];
|
|
2741
|
-
const r = e, n = [...
|
|
2742
|
+
const r = e, n = [...Kc(r), ...Wc(r, t)];
|
|
2742
2743
|
for (const s of Object.keys(r)) ["value", "symbology", "errorCorrection", "quietZoneModules", "showText"].includes(s) || n.push({ path: s, message: "Unknown symbol option." });
|
|
2743
2744
|
const o = r.symbology === "ean13" || r.symbology === "ean8", i = t === "qrcode" ? 4 : o ? 11 : 10;
|
|
2744
2745
|
return r.quietZoneModules !== void 0 && (!Number.isSafeInteger(r.quietZoneModules) || Number(r.quietZoneModules) < i || Number(r.quietZoneModules) > 64) && n.push({ path: "quietZoneModules", message: `Quiet zone must contain ${i}–64 whole modules.` }), n;
|
|
2745
2746
|
}
|
|
2746
|
-
const
|
|
2747
|
+
const Jc = /* @__PURE__ */ new Set([
|
|
2747
2748
|
"text",
|
|
2748
2749
|
"image",
|
|
2749
2750
|
"barcode",
|
|
@@ -2759,11 +2760,11 @@ function J(e) {
|
|
|
2759
2760
|
function ht(e) {
|
|
2760
2761
|
return e === null ? "null" : typeof e == "string" ? JSON.stringify(e.slice(0, 120)) : ["number", "boolean", "undefined"].includes(typeof e) ? String(e) : `[${typeof e}]`;
|
|
2761
2762
|
}
|
|
2762
|
-
function
|
|
2763
|
+
function Vc(e, t, r, n) {
|
|
2763
2764
|
const o = e[t];
|
|
2764
2765
|
(typeof o != "number" || !Number.isFinite(o)) && n.push({ path: `${r}.${t}`, message: `应为有限数字,实际 ${ht(o)}` });
|
|
2765
2766
|
}
|
|
2766
|
-
function
|
|
2767
|
+
function Hc(e, t, r) {
|
|
2767
2768
|
if (e !== void 0) {
|
|
2768
2769
|
const n = `${t}.table`;
|
|
2769
2770
|
if (!J(e)) r.push({ path: n, message: "逻辑表来源应为对象" });
|
|
@@ -2776,7 +2777,7 @@ function Vc(e, t, r) {
|
|
|
2776
2777
|
}
|
|
2777
2778
|
}
|
|
2778
2779
|
}
|
|
2779
|
-
function
|
|
2780
|
+
function Uc(e, t, r, n) {
|
|
2780
2781
|
if (e !== void 0)
|
|
2781
2782
|
if (!J(e) || !Array.isArray(e.cells))
|
|
2782
2783
|
r.push({ path: `${t}.grid.cells`, message: "grid.cells 应为二维数组" });
|
|
@@ -2794,7 +2795,7 @@ function Hc(e, t, r, n) {
|
|
|
2794
2795
|
r.push({ path: f, message: "网格单元格应为对象或 null" });
|
|
2795
2796
|
return;
|
|
2796
2797
|
}
|
|
2797
|
-
|
|
2798
|
+
_c(a, f, r), a.dataBar !== void 0 && !Dc(a.dataBar) && r.push({ path: `${f}.dataBar`, message: "数据条应包含 0–1 有序比例与 #RRGGBB 颜色" }), zo(a.richParagraphs, f, r), Array.isArray(a.children) && a.children.forEach((u, d) => {
|
|
2798
2799
|
Jr(u, `${t}.grid.cells.${s}.${c}.children.${d}`, r, n);
|
|
2799
2800
|
});
|
|
2800
2801
|
});
|
|
@@ -2810,7 +2811,7 @@ function ir(e, t, r, n, o = 0) {
|
|
|
2810
2811
|
s !== void 0 && (typeof s != "number" || !Number.isFinite(s) || s < o) && n.push({ path: `${r}.${i}`, message: "富文本数值应为范围内有限数字" });
|
|
2811
2812
|
}
|
|
2812
2813
|
}
|
|
2813
|
-
function
|
|
2814
|
+
function Gc(e, t, r) {
|
|
2814
2815
|
if (e !== void 0) {
|
|
2815
2816
|
if (!J(e)) {
|
|
2816
2817
|
r.push({ path: t, message: "富文本样式应为对象" });
|
|
@@ -2823,7 +2824,7 @@ function Uc(e, t, r) {
|
|
|
2823
2824
|
ir(e, ["fontSize", "fontSizePx", "lineWidthPt", "lineHeight", "opacity"], t, r), ir(e, ["letterSpacing", "rotateDeg"], t, r, -1 / 0), typeof e.opacity == "number" && e.opacity > 1 && r.push({ path: `${t}.opacity`, message: "透明度不能大于1" }), gt(e.align, ["left", "center", "right", "justify"], `${t}.align`, r), gt(e.verticalAlign, ["top", "middle", "bottom"], `${t}.verticalAlign`, r);
|
|
2824
2825
|
}
|
|
2825
2826
|
}
|
|
2826
|
-
function
|
|
2827
|
+
function Yc(e, t, r) {
|
|
2827
2828
|
if (!J(e)) {
|
|
2828
2829
|
r.push({ path: t, message: "富文本片段应为对象" });
|
|
2829
2830
|
return;
|
|
@@ -2831,7 +2832,7 @@ function Gc(e, t, r) {
|
|
|
2831
2832
|
gt(e.kind, ["text", "field"], `${t}.kind`, r);
|
|
2832
2833
|
for (const n of ["text", "field"])
|
|
2833
2834
|
e[n] !== void 0 && typeof e[n] != "string" && r.push({ path: `${t}.${n}`, message: "富文本内容应为字符串" });
|
|
2834
|
-
|
|
2835
|
+
Gc(e.style, `${t}.style`, r);
|
|
2835
2836
|
}
|
|
2836
2837
|
function zo(e, t, r) {
|
|
2837
2838
|
if (e !== void 0) {
|
|
@@ -2845,7 +2846,7 @@ function zo(e, t, r) {
|
|
|
2845
2846
|
r.push({ path: i, message: "段落缺少 segments 数组" });
|
|
2846
2847
|
return;
|
|
2847
2848
|
}
|
|
2848
|
-
gt(n.align, ["left", "center", "right", "justify"], `${i}.align`, r), ir(n, ["lineHeight", "spaceBeforeMm", "spaceAfterMm", "indentMm"], i, r), n.segments.forEach((s, a) =>
|
|
2849
|
+
gt(n.align, ["left", "center", "right", "justify"], `${i}.align`, r), ir(n, ["lineHeight", "spaceBeforeMm", "spaceAfterMm", "indentMm"], i, r), n.segments.forEach((s, a) => Yc(s, `${i}.segments.${a}`, r));
|
|
2849
2850
|
});
|
|
2850
2851
|
}
|
|
2851
2852
|
}
|
|
@@ -2863,18 +2864,18 @@ function Jr(e, t, r, n = []) {
|
|
|
2863
2864
|
return;
|
|
2864
2865
|
}
|
|
2865
2866
|
const o = e.kind;
|
|
2866
|
-
typeof o != "string" ? r.push({ path: `${t}.kind`, message: "组件缺少 kind 字符串" }) :
|
|
2867
|
+
typeof o != "string" ? r.push({ path: `${t}.kind`, message: "组件缺少 kind 字符串" }) : Jc.has(o) || n.push({
|
|
2867
2868
|
path: `${t}.kind`,
|
|
2868
2869
|
message: `未知组件类型 ${ht(o)},将以兜底方式渲染`
|
|
2869
2870
|
});
|
|
2870
2871
|
for (const i of ["leftMm", "topMm", "widthMm", "heightMm"])
|
|
2871
|
-
|
|
2872
|
+
Vc(e, i, t, r);
|
|
2872
2873
|
typeof e.leftMm == "number" && e.leftMm < -100 && r.push({ path: `${t}.leftMm`, message: "几何数值异常(leftMm<-100)" });
|
|
2873
2874
|
for (const i of ["widthMm", "heightMm"])
|
|
2874
2875
|
typeof e[i] == "number" && e[i] < 0 && r.push({ path: `${t}.${i}`, message: "组件尺寸不能为负数" });
|
|
2875
|
-
|
|
2876
|
+
Hc(e.table, t, r), Xc(e.code, o, t, r), qc(e, t, r), e.pageAnchor !== void 0 && !["header", "footer"].includes(e.pageAnchor) && r.push({ path: `${t}.pageAnchor`, message: "页面锚点应为 header 或 footer" }), e.lineDirection !== void 0 && !["down", "up"].includes(e.lineDirection) && r.push({ path: `${t}.lineDirection`, message: "线段方向应为 down 或 up" }), Uc(e.grid, t, r, n), zo(e.richParagraphs, t, r);
|
|
2876
2877
|
}
|
|
2877
|
-
function
|
|
2878
|
+
function qc(e, t, r) {
|
|
2878
2879
|
if (e.chartBinding !== void 0)
|
|
2879
2880
|
try {
|
|
2880
2881
|
if (eo(e.chartBinding), e.kind !== "chart" || ["binding", "imageData", "grid", "pageAnchor"].some((n) => e[n] !== void 0)) throw new Error("绑定图表不能设置图片、网格、记录绑定或页眉页脚");
|
|
@@ -2883,9 +2884,9 @@ function Yc(e, t, r) {
|
|
|
2883
2884
|
r.push({ path: `${t}.chartBinding`, message: n instanceof Error ? n.message : String(n) });
|
|
2884
2885
|
}
|
|
2885
2886
|
}
|
|
2886
|
-
function
|
|
2887
|
+
function Xc(e, t, r, n) {
|
|
2887
2888
|
if (e !== void 0)
|
|
2888
|
-
for (const o of
|
|
2889
|
+
for (const o of zc(e, t)) n.push({ path: `${r}.code${o.path ? `.${o.path}` : ""}`, message: o.message });
|
|
2889
2890
|
}
|
|
2890
2891
|
function Vo(e, t, r) {
|
|
2891
2892
|
if (!J(e)) return;
|
|
@@ -2897,7 +2898,7 @@ function Vo(e, t, r) {
|
|
|
2897
2898
|
});
|
|
2898
2899
|
});
|
|
2899
2900
|
}
|
|
2900
|
-
function
|
|
2901
|
+
function Zc(e, t, r, n = []) {
|
|
2901
2902
|
if (!J(e)) {
|
|
2902
2903
|
r.push({ path: t, message: "页应为对象" });
|
|
2903
2904
|
return;
|
|
@@ -2928,7 +2929,7 @@ function Je(e) {
|
|
|
2928
2929
|
else {
|
|
2929
2930
|
const o = _o(n);
|
|
2930
2931
|
if (o) return { ok: !1, errors: [...t, o], warnings: r };
|
|
2931
|
-
n.forEach((s, a) =>
|
|
2932
|
+
n.forEach((s, a) => Zc(s, `$.pages.${a}`, t, r)), n.length > 2e3 && r.push({
|
|
2932
2933
|
path: "$.pages",
|
|
2933
2934
|
message: `页数异常大(${n.length} 页),渲染与打印耗时可能显著增加`
|
|
2934
2935
|
});
|
|
@@ -2975,13 +2976,13 @@ function Uo(e, t, r) {
|
|
|
2975
2976
|
}
|
|
2976
2977
|
return o;
|
|
2977
2978
|
}
|
|
2978
|
-
function
|
|
2979
|
+
function Qc(e) {
|
|
2979
2980
|
return Uo(e, Vr, !0);
|
|
2980
2981
|
}
|
|
2981
|
-
function
|
|
2982
|
+
function ef(e) {
|
|
2982
2983
|
return Uo(e, Ho, !1);
|
|
2983
2984
|
}
|
|
2984
|
-
function
|
|
2985
|
+
function tf(e) {
|
|
2985
2986
|
if (typeof e == "string") {
|
|
2986
2987
|
if (e.length > 2048) return;
|
|
2987
2988
|
try {
|
|
@@ -2999,9 +3000,9 @@ function U(e) {
|
|
|
2999
3000
|
return ["multiSelect", "cascader", "numberRange"].includes(e.type ?? "");
|
|
3000
3001
|
}
|
|
3001
3002
|
function Tt(e, t) {
|
|
3002
|
-
return e.type === "numberRange" ?
|
|
3003
|
+
return e.type === "numberRange" ? tf(t) : e.type === "cascader" ? ef(t) : Qc(t);
|
|
3003
3004
|
}
|
|
3004
|
-
function
|
|
3005
|
+
function rf(e, t, r = !1) {
|
|
3005
3006
|
const n = pt(e, 1e3);
|
|
3006
3007
|
if (!n) return !1;
|
|
3007
3008
|
const o = [{ items: n, depth: 1 }], i = /* @__PURE__ */ new Set();
|
|
@@ -3011,7 +3012,7 @@ function tf(e, t, r = !1) {
|
|
|
3011
3012
|
if (f > Ho) return !1;
|
|
3012
3013
|
const u = /* @__PURE__ */ new Set();
|
|
3013
3014
|
for (const d of c) {
|
|
3014
|
-
const l =
|
|
3015
|
+
const l = nf(d, r);
|
|
3015
3016
|
if (++s > 1e3 || !l || i.has(d) || u.has(l.value)) return !1;
|
|
3016
3017
|
if (i.add(d), u.add(l.value), l.children !== void 0) {
|
|
3017
3018
|
const m = pt(l.children, 1e3);
|
|
@@ -3025,7 +3026,7 @@ function tf(e, t, r = !1) {
|
|
|
3025
3026
|
function Go(e) {
|
|
3026
3027
|
return e.map((t) => ({ value: t.value, label: t.label, ...t.children ? { children: Go(t.children) } : {} }));
|
|
3027
3028
|
}
|
|
3028
|
-
function
|
|
3029
|
+
function nf(e, t) {
|
|
3029
3030
|
if (!e || typeof e != "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(e))) return;
|
|
3030
3031
|
const r = Object.getOwnPropertyDescriptors(e);
|
|
3031
3032
|
if (Object.values(r).some((i) => !Object.prototype.hasOwnProperty.call(i, "value"))) return;
|
|
@@ -3033,7 +3034,7 @@ function rf(e, t) {
|
|
|
3033
3034
|
if (!(typeof n != "string" || !t && !n.trim() || n.length > 1024 || typeof o != "string" || o.length > 1024))
|
|
3034
3035
|
return { value: n, label: o, ...r.children ? { children: r.children.value } : {} };
|
|
3035
3036
|
}
|
|
3036
|
-
function
|
|
3037
|
+
function of(e, t) {
|
|
3037
3038
|
let r = e;
|
|
3038
3039
|
for (const [n, o] of t.entries()) {
|
|
3039
3040
|
const i = r.find((s) => s.value === o);
|
|
@@ -3042,23 +3043,23 @@ function nf(e, t) {
|
|
|
3042
3043
|
}
|
|
3043
3044
|
return !1;
|
|
3044
3045
|
}
|
|
3045
|
-
function
|
|
3046
|
+
function sf(e, t) {
|
|
3046
3047
|
const r = Tt(e, t);
|
|
3047
3048
|
if (!r) return [["type", e.type === "numberRange" ? "请填写完整数字范围,最小值不能大于最大值" : e.type === "cascader" ? "请选择完整的末级路径" : "请选择有效选项,不能重复或超出数量限制"]];
|
|
3048
|
-
if (e.type === "numberRange") return
|
|
3049
|
+
if (e.type === "numberRange") return af(e, r);
|
|
3049
3050
|
const n = r, o = [];
|
|
3050
|
-
return e.type === "cascader" && e.options && !
|
|
3051
|
+
return e.type === "cascader" && e.options && !of(e.options, n) && o.push(["option", "应为允许选项中的完整叶节点路径"]), e.type === "multiSelect" && (e.options && n.some((i) => !e.options.some((s) => s.value === i)) && o.push(["option", "不在允许的选项中"]), e.minItems !== void 0 && n.length < e.minItems && o.push(["minItems", `至少选择 ${e.minItems} 项`]), e.maxItems !== void 0 && n.length > e.maxItems && o.push(["maxItems", `最多选择 ${e.maxItems} 项`])), o;
|
|
3051
3052
|
}
|
|
3052
|
-
function
|
|
3053
|
+
function af(e, t) {
|
|
3053
3054
|
const r = [];
|
|
3054
3055
|
return typeof e.min == "number" && t[0] < e.min && r.push(["minimum", `不能小于 ${e.min}`]), typeof e.max == "number" && t[1] > e.max && r.push(["maximum", `不能大于 ${e.max}`]), r;
|
|
3055
3056
|
}
|
|
3056
|
-
function
|
|
3057
|
+
function cf(e) {
|
|
3057
3058
|
const t = [];
|
|
3058
3059
|
for (const r of ["minItems", "maxItems"]) e[r] !== void 0 && (e.type !== "multiSelect" || !Number.isSafeInteger(e[r]) || e[r] < 0 || e[r] > Vr) && t.push(`${r} 应为多选参数的 0–100 整数边界`);
|
|
3059
3060
|
return e.minItems !== void 0 && e.maxItems !== void 0 && e.minItems > e.maxItems && t.push("最少项目数不能大于最多项目数"), t;
|
|
3060
3061
|
}
|
|
3061
|
-
function
|
|
3062
|
+
function ff(e) {
|
|
3062
3063
|
if (e.type === "numberRange") {
|
|
3063
3064
|
const r = { type: "number", ...typeof e.min == "number" ? { minimum: e.min } : {}, ...typeof e.max == "number" ? { maximum: e.max } : {} };
|
|
3064
3065
|
return { type: "array", minItems: 2, maxItems: 2, prefixItems: [r, { ...r }], items: !1, "x-report-number-range": { ordered: !0 }, "x-report-wire-encoding": "json" };
|
|
@@ -3066,11 +3067,11 @@ function cf(e) {
|
|
|
3066
3067
|
const t = { "x-report-wire-encoding": "json", "x-report-wire-max-code-units": sr, type: "array", minItems: Math.max(e.required ? 1 : 0, e.minItems ?? 0), maxItems: e.type === "cascader" ? 16 : e.maxItems ?? Vr, items: { type: "string", minLength: 1, maxLength: 1024, pattern: "\\S", "x-report-max-code-units": 1024 } };
|
|
3067
3068
|
return e.type === "multiSelect" ? (t.uniqueItems = !0, e.options && (t.items = { ...t.items, enum: e.options.map((r) => r.value) })) : t["x-report-cascader"] = { leafOnly: !0, ...e.options ? { options: Go(e.options) } : {} }, t;
|
|
3068
3069
|
}
|
|
3069
|
-
function
|
|
3070
|
+
function uf(e) {
|
|
3070
3071
|
const t = [];
|
|
3071
3072
|
return e.optionsSource !== void 0 && ((!["select", "multiSelect", "cascader"].includes(e.type ?? "") || typeof e.optionsSource != "string" || !/^[\w][\w.:-]{0,127}$/.test(e.optionsSource)) && t.push("远程选项来源应为选择参数的有效来源键(最多 128 字符)"), e.options !== void 0 && t.push("远程选项来源与静态选项不能同时配置")), e.dependsOn !== void 0 && (!e.optionsSource || !Array.isArray(e.dependsOn) || e.dependsOn.length > 32 || e.dependsOn.some((r) => typeof r != "string" || !r) || new Set(e.dependsOn).size !== e.dependsOn.length) && t.push("联动依赖应为远程选项的最多 32 个唯一参数名"), t;
|
|
3072
3073
|
}
|
|
3073
|
-
function
|
|
3074
|
+
function lf(e) {
|
|
3074
3075
|
const t = new Map(e.map((o, i) => [o.field, { def: o, index: i, degree: 0, children: [] }])), r = [];
|
|
3075
3076
|
for (const o of t.values()) for (const i of o.def.dependsOn ?? []) {
|
|
3076
3077
|
const s = t.get(i);
|
|
@@ -3107,7 +3108,7 @@ function qo(e) {
|
|
|
3107
3108
|
function Xo(e, t) {
|
|
3108
3109
|
return typeof t != "string" ? !1 : e === "month" ? Yo(t) : e === "year" ? Hr(t) : (e === "date" || e === "dateRange") && yt(t);
|
|
3109
3110
|
}
|
|
3110
|
-
function
|
|
3111
|
+
function df(e, t) {
|
|
3111
3112
|
if (e === "date" && !yt(t)) return "应为有效的 YYYY-MM-DD 日期";
|
|
3112
3113
|
if (e === "month" && !Yo(t)) return "应为有效的 YYYY-MM 月份";
|
|
3113
3114
|
if (e === "year" && !Hr(t)) return "应为 0001 至 9999 的四位年份";
|
|
@@ -3122,20 +3123,20 @@ function Zo(e) {
|
|
|
3122
3123
|
return /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e) && Number.isFinite(Number(e));
|
|
3123
3124
|
}
|
|
3124
3125
|
function Qo(e, t) {
|
|
3125
|
-
if (U(e)) return
|
|
3126
|
+
if (U(e)) return sf(e, t);
|
|
3126
3127
|
if (e.type === "number" && !Zo(t)) return [["type", "应为有限数字"]];
|
|
3127
|
-
const r =
|
|
3128
|
+
const r = df(e.type, t);
|
|
3128
3129
|
if (r) return [["type", r]];
|
|
3129
3130
|
const n = [];
|
|
3130
3131
|
e.type === "select" && e.options && !e.options.some((i) => i.value === t) && n.push(["option", "不在允许的选项中"]);
|
|
3131
3132
|
const o = Array.from(t).length;
|
|
3132
|
-
return e.minLength !== void 0 && o < e.minLength && n.push(["minLength", `至少 ${e.minLength} 个字符`]), e.maxLength !== void 0 && o > e.maxLength && n.push(["maxLength", `最多 ${e.maxLength} 个字符`]), n.push(...
|
|
3133
|
+
return e.minLength !== void 0 && o < e.minLength && n.push(["minLength", `至少 ${e.minLength} 个字符`]), e.maxLength !== void 0 && o > e.maxLength && n.push(["maxLength", `最多 ${e.maxLength} 个字符`]), n.push(...mf(e, t)), n;
|
|
3133
3134
|
}
|
|
3134
|
-
function
|
|
3135
|
+
function mf(e, t) {
|
|
3135
3136
|
const r = e.type === "dateRange" ? qo(t) : void 0, n = r?.start ?? (e.type === "number" ? Number(t) : t), o = r?.end ?? n, i = [];
|
|
3136
3137
|
return e.min !== void 0 && n < e.min && i.push(["minimum", `不能小于 ${e.min}`]), e.max !== void 0 && o > e.max && i.push(["maximum", `不能大于 ${e.max}`]), i;
|
|
3137
3138
|
}
|
|
3138
|
-
function
|
|
3139
|
+
function hf(e) {
|
|
3139
3140
|
const t = [];
|
|
3140
3141
|
for (const o of ["min", "max"]) {
|
|
3141
3142
|
const i = e[o];
|
|
@@ -3143,9 +3144,9 @@ function mf(e) {
|
|
|
3143
3144
|
Xo(e.type, i) || ["number", "numberRange"].includes(e.type ?? "") && typeof i == "number" && Number.isFinite(i) || t.push(`${o} 应为数字的有限边界或日期/月/年的规范字符串边界`);
|
|
3144
3145
|
}
|
|
3145
3146
|
const r = typeof e.min == "number" && typeof e.max == "number" && e.min > e.max, n = typeof e.min == "string" && typeof e.max == "string" && e.min > e.max;
|
|
3146
|
-
return (r || n) && t.push("最小边界不能大于最大边界"), [...t, ...
|
|
3147
|
+
return (r || n) && t.push("最小边界不能大于最大边界"), [...t, ...gf(e), ...cf(e)];
|
|
3147
3148
|
}
|
|
3148
|
-
function
|
|
3149
|
+
function gf(e) {
|
|
3149
3150
|
const t = [];
|
|
3150
3151
|
U(e) && (e.minLength !== void 0 || e.maxLength !== void 0) && t.push("复合参数使用项目数或数值边界,而不是文本长度约束"), e.type === "number" && (e.minLength !== void 0 || e.maxLength !== void 0) && t.push("number 参数使用 min/max 而不是文本长度约束");
|
|
3151
3152
|
for (const r of ["minLength", "maxLength"]) {
|
|
@@ -3158,20 +3159,20 @@ function Dt(e) {
|
|
|
3158
3159
|
if (!Array.isArray(e)) return [{ code: "definition", field: "", path: "$.paramDefs", message: "参数定义应为数组" }];
|
|
3159
3160
|
const t = /* @__PURE__ */ new Set(), r = e.flatMap((n, o) => {
|
|
3160
3161
|
const i = n && typeof n.field == "string" ? n.field : "";
|
|
3161
|
-
return
|
|
3162
|
+
return yf(n, t).map((a) => ({ code: "definition", field: i, path: `$.paramDefs.${o}`, message: a }));
|
|
3162
3163
|
});
|
|
3163
|
-
return r.length ? r :
|
|
3164
|
+
return r.length ? r : lf(e).map(({ index: n, message: o }) => ({ code: "definition", field: e[n].field, path: `$.paramDefs.${n}`, message: o }));
|
|
3164
3165
|
}
|
|
3165
|
-
function
|
|
3166
|
+
function pf(e) {
|
|
3166
3167
|
const t = [];
|
|
3167
|
-
return e.type !== void 0 && !["text", "number", "date", "month", "year", "dateRange", "select", "multiSelect", "cascader", "numberRange"].includes(e.type) && t.push("未知参数类型"), e.label !== void 0 && typeof e.label != "string" && t.push("参数标签应为字符串"), e.placeholder !== void 0 && typeof e.placeholder != "string" && t.push("提示文字应为字符串"), e.required !== void 0 && typeof e.required != "boolean" && t.push("required 应为布尔值"), e.defaultValue !== void 0 && typeof e.defaultValue != "string" && t.push("默认值应为字符串"), e.options !== void 0 && !
|
|
3168
|
+
return e.type !== void 0 && !["text", "number", "date", "month", "year", "dateRange", "select", "multiSelect", "cascader", "numberRange"].includes(e.type) && t.push("未知参数类型"), e.label !== void 0 && typeof e.label != "string" && t.push("参数标签应为字符串"), e.placeholder !== void 0 && typeof e.placeholder != "string" && t.push("提示文字应为字符串"), e.required !== void 0 && typeof e.required != "boolean" && t.push("required 应为布尔值"), e.defaultValue !== void 0 && typeof e.defaultValue != "string" && t.push("默认值应为字符串"), e.options !== void 0 && !rf(e.options, e.type === "cascader", !U(e)) && t.push("选项应为包含字符串 label/value 的数组"), [...t, ...uf(e)];
|
|
3168
3169
|
}
|
|
3169
|
-
function
|
|
3170
|
+
function yf(e, t) {
|
|
3170
3171
|
if (!e || typeof e != "object" || Array.isArray(e)) return ["参数定义项应为对象"];
|
|
3171
|
-
const r =
|
|
3172
|
-
return typeof e.field != "string" || !e.field.trim() || t.has(e.field) ? r.push("参数名应为非空且不重复的字符串") : t.add(e.field), r.length || (r.push(...
|
|
3172
|
+
const r = pf(e);
|
|
3173
|
+
return typeof e.field != "string" || !e.field.trim() || t.has(e.field) ? r.push("参数名应为非空且不重复的字符串") : t.add(e.field), r.length || (r.push(...hf(e)), r.length) || e.defaultValue !== void 0 && (e.required && (!e.defaultValue.trim() || U(e) && Tt(e, e.defaultValue)?.length === 0) ? r.push("必填参数的默认值不能为空") : e.defaultValue.trim() && r.push(...Qo(e, e.defaultValue).map(([, n]) => `默认值${n}`))), r;
|
|
3173
3174
|
}
|
|
3174
|
-
function
|
|
3175
|
+
function wf(e, t, r) {
|
|
3175
3176
|
for (const [n, o] of Object.entries(e))
|
|
3176
3177
|
(typeof o == "string" || typeof o == "number" && Number.isFinite(o)) && (Object.defineProperty(t, n, { value: String(o), writable: !0, enumerable: !0, configurable: !0 }), Object.defineProperty(r, n, { value: o, writable: !0, enumerable: !0, configurable: !0 }));
|
|
3177
3178
|
}
|
|
@@ -3181,14 +3182,14 @@ function wt(e) {
|
|
|
3181
3182
|
function ar(e, t = {}) {
|
|
3182
3183
|
const r = /* @__PURE__ */ Object.create(null), n = /* @__PURE__ */ Object.create(null), o = Dt(e);
|
|
3183
3184
|
if ((!t || typeof t != "object" || Array.isArray(t)) && o.push({ code: "type", field: "", path: "$.params", message: "参数应为对象" }), o.length) return { ok: !1, values: r, typedValues: n, issues: o };
|
|
3184
|
-
|
|
3185
|
+
wf(t, r, n);
|
|
3185
3186
|
for (const i of e) {
|
|
3186
3187
|
const s = Object.prototype.hasOwnProperty.call(t, i.field) && t[i.field] !== void 0 ? t[i.field] : i.defaultValue;
|
|
3187
|
-
|
|
3188
|
+
bf(i, s, { values: r, typedValues: n, issues: o });
|
|
3188
3189
|
}
|
|
3189
|
-
return o.push(...
|
|
3190
|
+
return o.push(...xf(e, r)), { ok: o.length === 0, values: r, typedValues: n, issues: o };
|
|
3190
3191
|
}
|
|
3191
|
-
function
|
|
3192
|
+
function bf(e, t, r) {
|
|
3192
3193
|
const { values: n, typedValues: o, issues: i } = r, s = (u, d) => i.push({ code: u, path: `$.params.${e.field}`, field: e.field, message: d }), a = U(e) && !wt(t) ? Tt(e, t) : void 0;
|
|
3193
3194
|
if (wt(t) || a?.length === 0) {
|
|
3194
3195
|
e.required && s("required", "此参数为必填项"), (typeof t == "string" || a) && (n[e.field] = a ? "" : String(t)), delete o[e.field];
|
|
@@ -3203,7 +3204,7 @@ function wf(e, t, r) {
|
|
|
3203
3204
|
const f = Qo(e, c);
|
|
3204
3205
|
f.forEach(([u, d]) => s(u, d)), f.length && U(e) ? delete o[e.field] : o[e.field] = a ?? (e.type === "number" && Zo(c) ? Number(c) : c);
|
|
3205
3206
|
}
|
|
3206
|
-
function
|
|
3207
|
+
function xf(e, t) {
|
|
3207
3208
|
return e.flatMap((r) => !wt(t[r.field]) && r.dependsOn?.some((n) => wt(t[n])) ? [{ code: "dependency", path: `$.params.${r.field}`, field: r.field, message: "请先填写联动依赖的上级参数" }] : []);
|
|
3208
3209
|
}
|
|
3209
3210
|
function $n(e, t = {}) {
|
|
@@ -3211,22 +3212,22 @@ function $n(e, t = {}) {
|
|
|
3211
3212
|
if (!r.ok) throw new jt(r.issues);
|
|
3212
3213
|
return r.values;
|
|
3213
3214
|
}
|
|
3214
|
-
function
|
|
3215
|
+
function Mf(e) {
|
|
3215
3216
|
const t = {}, r = "(?![\\s\\S])";
|
|
3216
3217
|
return e.type === "date" && (t.format = "date"), e.type === "month" && (t.pattern = `^(?!0000)[0-9]{4}-(0[1-9]|1[0-2])${r}`), e.type === "year" && (t.pattern = `^(?!0000)[0-9]{4}${r}`), e.type === "dateRange" && (t.pattern = `^[0-9]{4}-[0-9]{2}-[0-9]{2}/[0-9]{4}-[0-9]{2}-[0-9]{2}${r}`), e.type === "dateRange" && (t["x-report-date-range"] = { separator: "/", ordered: !0, calendarDates: !0 }), t;
|
|
3217
3218
|
}
|
|
3218
3219
|
function vf(e) {
|
|
3219
|
-
const t = { type: e.type === "number" ? "number" : "string", title: e.label ?? e.field, ...
|
|
3220
|
-
return U(e) && Object.assign(t,
|
|
3220
|
+
const t = { type: e.type === "number" ? "number" : "string", title: e.label ?? e.field, ...Mf(e) };
|
|
3221
|
+
return U(e) && Object.assign(t, ff(e)), e.required && !U(e) && e.type !== "number" && !t.pattern && (t.pattern = "\\S"), e.type === "select" && e.options && (t.enum = e.options.map((r) => r.value)), Object.assign(t, Sf(e)), Object.assign(t, $f(e)), t;
|
|
3221
3222
|
}
|
|
3222
|
-
function
|
|
3223
|
+
function $f(e) {
|
|
3223
3224
|
const t = {};
|
|
3224
3225
|
return e.defaultValue !== void 0 && (!(e.type === "number" || U(e)) || e.defaultValue.trim()) && (t.default = U(e) ? Tt(e, e.defaultValue) : e.type === "number" ? Number(e.defaultValue) : e.defaultValue), e.minLength !== void 0 && (t.minLength = e.minLength), e.maxLength !== void 0 && (t.maxLength = e.maxLength), !U(e) && typeof e.min == "number" && (t.minimum = e.min), !U(e) && typeof e.max == "number" && (t.maximum = e.max), typeof e.min == "string" && (t["x-report-minimum"] = e.min), typeof e.max == "string" && (t["x-report-maximum"] = e.max), t;
|
|
3225
3226
|
}
|
|
3226
|
-
function
|
|
3227
|
+
function Sf(e) {
|
|
3227
3228
|
return { ...e.optionsSource ? { "x-report-options-source": e.optionsSource } : {}, ...e.dependsOn?.length ? { "x-report-depends-on": [...e.dependsOn] } : {} };
|
|
3228
3229
|
}
|
|
3229
|
-
function
|
|
3230
|
+
function Ef(e) {
|
|
3230
3231
|
const t = Dt(e);
|
|
3231
3232
|
if (t.length) throw new jt(t);
|
|
3232
3233
|
return {
|
|
@@ -3245,7 +3246,7 @@ function bt(e, t) {
|
|
|
3245
3246
|
return i.filter((a) => r.has(a.field) ? !1 : (r.add(a.field), !0));
|
|
3246
3247
|
});
|
|
3247
3248
|
}
|
|
3248
|
-
function
|
|
3249
|
+
function Af(e) {
|
|
3249
3250
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
3250
3251
|
}
|
|
3251
3252
|
function cr(e, t, r) {
|
|
@@ -3265,7 +3266,7 @@ function ei(e, t, r) {
|
|
|
3265
3266
|
const n = /* @__PURE__ */ new Set();
|
|
3266
3267
|
e.forEach((o, i) => {
|
|
3267
3268
|
const s = `${t}.${i}`;
|
|
3268
|
-
if (!
|
|
3269
|
+
if (!Af(o)) {
|
|
3269
3270
|
r.push({ path: s, message: "聚合应为对象" });
|
|
3270
3271
|
return;
|
|
3271
3272
|
}
|
|
@@ -3293,12 +3294,12 @@ function ei(e, t, r) {
|
|
|
3293
3294
|
}
|
|
3294
3295
|
});
|
|
3295
3296
|
}
|
|
3296
|
-
function
|
|
3297
|
+
function kf(e, t, r) {
|
|
3297
3298
|
if (e === void 0) return;
|
|
3298
|
-
const n =
|
|
3299
|
+
const n = Bs(e);
|
|
3299
3300
|
for (const o of n.errors) r.push({ path: t, message: o });
|
|
3300
3301
|
}
|
|
3301
|
-
function
|
|
3302
|
+
function Nf(e, t, r) {
|
|
3302
3303
|
if (e !== void 0)
|
|
3303
3304
|
try {
|
|
3304
3305
|
Fr(e);
|
|
@@ -3309,7 +3310,7 @@ function kf(e, t, r) {
|
|
|
3309
3310
|
});
|
|
3310
3311
|
}
|
|
3311
3312
|
}
|
|
3312
|
-
function
|
|
3313
|
+
function Pf(e, t, r) {
|
|
3313
3314
|
if (e.tree === void 0) return;
|
|
3314
3315
|
const n = `${t}.tree`;
|
|
3315
3316
|
try {
|
|
@@ -3323,14 +3324,14 @@ function Nf(e, t, r) {
|
|
|
3323
3324
|
r.push({ path: n, message: o instanceof Error ? o.message : String(o) });
|
|
3324
3325
|
}
|
|
3325
3326
|
}
|
|
3326
|
-
const
|
|
3327
|
+
const Ff = 1e7, Of = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]), Rf = /* @__PURE__ */ new Set(["text", "number", "boolean", "date", "decimal"]);
|
|
3327
3328
|
function Qe(e) {
|
|
3328
3329
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
3329
3330
|
}
|
|
3330
3331
|
function fr(e) {
|
|
3331
|
-
return typeof e == "string" && !!e.trim() && e.length <= 4096 && !
|
|
3332
|
+
return typeof e == "string" && !!e.trim() && e.length <= 4096 && !Of.has(e);
|
|
3332
3333
|
}
|
|
3333
|
-
function
|
|
3334
|
+
function If(e, t, r) {
|
|
3334
3335
|
if (!Array.isArray(e) || !e.length || e.length > 2048) {
|
|
3335
3336
|
r.push({ path: t, message: "绑定契约应包含 1–2048 个字段" });
|
|
3336
3337
|
return;
|
|
@@ -3345,10 +3346,10 @@ function Rf(e, t, r) {
|
|
|
3345
3346
|
n.add(o.field);
|
|
3346
3347
|
for (const a of ["label", "semanticKey", "unit"])
|
|
3347
3348
|
o[a] !== void 0 && (typeof o[a] != "string" || String(o[a]).length > 4096) && r.push({ path: `${s}.${a}`, message: "应为不超过 4096 位的字符串" });
|
|
3348
|
-
o.type !== void 0 && !
|
|
3349
|
+
o.type !== void 0 && !Rf.has(String(o.type)) && r.push({ path: `${s}.type`, message: "未知绑定字段类型" });
|
|
3349
3350
|
});
|
|
3350
3351
|
}
|
|
3351
|
-
function
|
|
3352
|
+
function Cf(e, t, r) {
|
|
3352
3353
|
if (e === void 0) return;
|
|
3353
3354
|
if (!Qe(e) || !Qe(e.datasets)) {
|
|
3354
3355
|
r.push({ path: t, message: "模板数据契约应声明 datasets" });
|
|
@@ -3359,19 +3360,19 @@ function If(e, t, r) {
|
|
|
3359
3360
|
(!n.length || n.length > 256) && r.push({ path: `${t}.datasets`, message: "应声明 1–256 个数据集" });
|
|
3360
3361
|
for (const [o, i] of n) {
|
|
3361
3362
|
const s = `${t}.datasets.${o}`;
|
|
3362
|
-
!fr(o) || !Qe(i) ? r.push({ path: s, message: "数据集应使用安全名称和字段契约" }) :
|
|
3363
|
+
!fr(o) || !Qe(i) ? r.push({ path: s, message: "数据集应使用安全名称和字段契约" }) : If(i.fields, `${s}.fields`, r);
|
|
3363
3364
|
}
|
|
3364
3365
|
}
|
|
3365
|
-
class
|
|
3366
|
+
class Tf extends Error {
|
|
3366
3367
|
constructor(t) {
|
|
3367
3368
|
super(`模板校验失败:${t.slice(0, 3).map((r) => `${r.path}: ${r.message}`).join("; ")}`), this.errors = t, this.name = "ReportTemplateError";
|
|
3368
3369
|
}
|
|
3369
3370
|
}
|
|
3370
|
-
const
|
|
3371
|
+
const jf = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]), Df = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]), et = 2e5, Lf = 64;
|
|
3371
3372
|
function C(e) {
|
|
3372
3373
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
3373
3374
|
}
|
|
3374
|
-
function
|
|
3375
|
+
function Bf(e, t, r) {
|
|
3375
3376
|
const n = Object.getPrototypeOf(e), o = Array.isArray(e);
|
|
3376
3377
|
if (o ? n !== Array.prototype : n !== Object.prototype && n !== null)
|
|
3377
3378
|
return r.push({ path: t, message: "模板对象必须使用普通 JSON 对象原型" }), !1;
|
|
@@ -3382,13 +3383,13 @@ function Lf(e, t, r) {
|
|
|
3382
3383
|
}
|
|
3383
3384
|
return Object.getOwnPropertySymbols(e).length > 0 ? (r.push({ path: t, message: "模板不能包含 Symbol 键" }), !1) : !0;
|
|
3384
3385
|
}
|
|
3385
|
-
function
|
|
3386
|
-
return
|
|
3386
|
+
function _f(e, t, r, n) {
|
|
3387
|
+
return jf.has(e) ? (n.push({ path: r, message: "模板不能包含可能污染原型的键" }), !1) : t.get || t.set || !t.enumerable ? (n.push({ path: r, message: "模板不能包含访问器或不可枚举字段" }), !1) : !0;
|
|
3387
3388
|
}
|
|
3388
|
-
function
|
|
3389
|
+
function Kf(e) {
|
|
3389
3390
|
return e === null || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e);
|
|
3390
3391
|
}
|
|
3391
|
-
function
|
|
3392
|
+
function Wf(e, t) {
|
|
3392
3393
|
const r = /* @__PURE__ */ new Set();
|
|
3393
3394
|
let n = 0, o = 0, i = !1;
|
|
3394
3395
|
const s = (a, c, f) => {
|
|
@@ -3397,15 +3398,15 @@ function Kf(e, t) {
|
|
|
3397
3398
|
n === et + 1 && t.push({ path: c, message: "模板超过 JSON 节点安全上限" });
|
|
3398
3399
|
return;
|
|
3399
3400
|
}
|
|
3400
|
-
if (f >
|
|
3401
|
+
if (f > Lf) {
|
|
3401
3402
|
t.push({ path: c, message: "模板嵌套层级过深" });
|
|
3402
3403
|
return;
|
|
3403
3404
|
}
|
|
3404
3405
|
if (typeof a == "string") {
|
|
3405
|
-
o += a.length, o >
|
|
3406
|
+
o += a.length, o > Ff && (i = !0, t.push({ path: c, message: "模板文本超过 1000 万字符的安全上限" }));
|
|
3406
3407
|
return;
|
|
3407
3408
|
}
|
|
3408
|
-
if (!
|
|
3409
|
+
if (!Kf(a)) {
|
|
3409
3410
|
if (!a || typeof a != "object") {
|
|
3410
3411
|
t.push({ path: c, message: "模板只允许 JSON 值,不允许函数、undefined 或非有限数字" });
|
|
3411
3412
|
return;
|
|
@@ -3414,12 +3415,12 @@ function Kf(e, t) {
|
|
|
3414
3415
|
t.push({ path: c, message: "模板不能包含循环引用" });
|
|
3415
3416
|
return;
|
|
3416
3417
|
}
|
|
3417
|
-
if (
|
|
3418
|
+
if (Bf(a, c, t)) {
|
|
3418
3419
|
r.add(a);
|
|
3419
3420
|
for (const [u, d] of Object.entries(Object.getOwnPropertyDescriptors(a))) {
|
|
3420
3421
|
if (Array.isArray(a) && u === "length") continue;
|
|
3421
3422
|
const l = `${c}.${u}`;
|
|
3422
|
-
if (
|
|
3423
|
+
if (_f(u, d, l, t) && s(d.value, l, f + 1), n > et || i) break;
|
|
3423
3424
|
}
|
|
3424
3425
|
r.delete(a);
|
|
3425
3426
|
}
|
|
@@ -3440,7 +3441,7 @@ function ce(e, t, r, n) {
|
|
|
3440
3441
|
e[t] !== void 0 && typeof e[t] != "boolean" && n.push({ path: `${r}.${t}`, message: "应为布尔值" });
|
|
3441
3442
|
}
|
|
3442
3443
|
function Se(e, t, r, n = !1) {
|
|
3443
|
-
e !== void 0 && !
|
|
3444
|
+
e !== void 0 && !Df.has(e) && !(n && e === "auto") && r.push({ path: t, message: `未知对齐方式${n ? "(支持 auto)" : ""}` });
|
|
3444
3445
|
}
|
|
3445
3446
|
function oe(e, t, r) {
|
|
3446
3447
|
if (e !== void 0) {
|
|
@@ -3456,7 +3457,7 @@ function oe(e, t, r) {
|
|
|
3456
3457
|
for (const n of ["fontFamily", "color", "backgroundColor", "lineColor", "borderColor"]) _(e, n, t, r);
|
|
3457
3458
|
}
|
|
3458
3459
|
}
|
|
3459
|
-
function
|
|
3460
|
+
function zf(e, t, r) {
|
|
3460
3461
|
if (e === void 0) return;
|
|
3461
3462
|
if (!Array.isArray(e)) {
|
|
3462
3463
|
r.push({ path: t, message: "参数定义应为数组" });
|
|
@@ -3476,7 +3477,7 @@ function Wf(e, t, r) {
|
|
|
3476
3477
|
const f = i[c];
|
|
3477
3478
|
f !== void 0 && (typeof f != "number" || !Number.isSafeInteger(f) || f < 0) && r.push({ path: `${a}.${c}`, message: "长度边界应为非负整数" });
|
|
3478
3479
|
}
|
|
3479
|
-
|
|
3480
|
+
Jf(i, a, r), i.options !== void 0 && (Array.isArray(i.options) ? i.options.forEach((c, f) => {
|
|
3480
3481
|
const u = `${a}.options.${f}`;
|
|
3481
3482
|
if (!C(c)) r.push({ path: u, message: "选项应为对象" });
|
|
3482
3483
|
else
|
|
@@ -3484,7 +3485,7 @@ function Wf(e, t, r) {
|
|
|
3484
3485
|
}) : r.push({ path: `${a}.options`, message: "选项应为数组" }));
|
|
3485
3486
|
}), r.length === o && r.push(...Dt(e).map((i) => ({ path: i.path.replace("$.paramDefs", t), message: i.message })));
|
|
3486
3487
|
}
|
|
3487
|
-
function
|
|
3488
|
+
function Jf(e, t, r) {
|
|
3488
3489
|
for (const i of ["min", "max"]) {
|
|
3489
3490
|
const s = e[i];
|
|
3490
3491
|
if (s === void 0) continue;
|
|
@@ -3533,7 +3534,7 @@ function ri(e, t, r) {
|
|
|
3533
3534
|
ce(e, "keepWithNext", t, r), ce(e, "repeatHeader", t, r), ei(e.aggregates, `${t}.aggregates`, r), e.subtotal !== void 0 && (!Array.isArray(e.subtotal) || e.subtotal.some((n) => typeof n != "string")) && r.push({ path: `${t}.subtotal`, message: "小计字段应为字符串数组" });
|
|
3534
3535
|
}
|
|
3535
3536
|
}
|
|
3536
|
-
function
|
|
3537
|
+
function Vf(e, t, r) {
|
|
3537
3538
|
if (!(e === void 0 || typeof e == "boolean")) {
|
|
3538
3539
|
if (!C(e)) {
|
|
3539
3540
|
r.push({ path: t, message: "合计应为布尔值或对象" });
|
|
@@ -3542,7 +3543,7 @@ function Jf(e, t, r) {
|
|
|
3542
3543
|
_(e, "label", t, r), ei(e.aggregates, `${t}.aggregates`, r), oe(e.style, `${t}.style`, r), e.fields !== void 0 && (!Array.isArray(e.fields) || e.fields.some((n) => typeof n != "string")) && r.push({ path: `${t}.fields`, message: "合计字段应为字符串数组" });
|
|
3543
3544
|
}
|
|
3544
3545
|
}
|
|
3545
|
-
function
|
|
3546
|
+
function Hf(e, t, r, n) {
|
|
3546
3547
|
const o = { kind: "rect", leftMm: 0, topMm: 0, widthMm: 1, heightMm: 1, grid: e };
|
|
3547
3548
|
if (Jo(o, r, n, []), Ur(o, r, n), !C(e) || !Array.isArray(e.cells)) return;
|
|
3548
3549
|
const i = e.cells, s = Array.isArray(t) ? t.length : 0;
|
|
@@ -3550,9 +3551,9 @@ function Vf(e, t, r, n) {
|
|
|
3550
3551
|
n.push({ path: r, message: "表头逻辑网格超过 20 万格安全上限" });
|
|
3551
3552
|
return;
|
|
3552
3553
|
}
|
|
3553
|
-
e.cells.length || n.push({ path: `${r}.cells`, message: "表头至少需要一行" }), Array.isArray(e.colWidthsMm) && e.colWidthsMm.length !== s && n.push({ path: `${r}.colWidthsMm`, message: "表头列宽数量应与列表列数一致" }), Array.isArray(e.rowHeightsMm) && e.rowHeightsMm.length !== e.cells.length && n.push({ path: `${r}.rowHeightsMm`, message: "表头行高数量应与行数一致" }),
|
|
3554
|
+
e.cells.length || n.push({ path: `${r}.cells`, message: "表头至少需要一行" }), Array.isArray(e.colWidthsMm) && e.colWidthsMm.length !== s && n.push({ path: `${r}.colWidthsMm`, message: "表头列宽数量应与列表列数一致" }), Array.isArray(e.rowHeightsMm) && e.rowHeightsMm.length !== e.cells.length && n.push({ path: `${r}.rowHeightsMm`, message: "表头行高数量应与行数一致" }), Uf(i, s, r, n);
|
|
3554
3555
|
}
|
|
3555
|
-
function
|
|
3556
|
+
function Uf(e, t, r, n) {
|
|
3556
3557
|
const o = /* @__PURE__ */ new Set();
|
|
3557
3558
|
e.forEach((i, s) => {
|
|
3558
3559
|
if (!Array.isArray(i)) return;
|
|
@@ -3568,8 +3569,8 @@ function Hf(e, t, r, n) {
|
|
|
3568
3569
|
});
|
|
3569
3570
|
});
|
|
3570
3571
|
}
|
|
3571
|
-
function
|
|
3572
|
-
if (
|
|
3572
|
+
function Gf(e, t, r) {
|
|
3573
|
+
if (Pf(e, t, r), kf(e.computed, `${t}.computed`, r), Nf(e.matrix, `${t}.matrix`, r), e.matrix && (e.detail || e.groupBy || Array.isArray(e.groups) && e.groups.length || e.grandTotal) && r.push({ path: `${t}.matrix`, message: "矩阵请使用自身 totals 汇总,不能同时配置普通分组、总计或主从明细" }), cr(e.rowVisibleWhen, `${t}.rowVisibleWhen`, r), e.groups !== void 0 && (!Array.isArray(e.groups) || e.groups.length > 16 ? r.push({ path: `${t}.groups`, message: "分组应为数组,最多 16 级" }) : e.groups.forEach((i, s) => ri(i, `${t}.groups.${s}`, r))), e.detail === void 0) return;
|
|
3573
3574
|
const n = e.detail, o = `${t}.detail`;
|
|
3574
3575
|
if (!C(n)) {
|
|
3575
3576
|
r.push({ path: o, message: "主从关联应为对象" });
|
|
@@ -3579,15 +3580,15 @@ function Uf(e, t, r) {
|
|
|
3579
3580
|
for (const i of ["rowKey", "revisionField", "sourceTokenField"]) _(n, i, o, r, n[i] !== void 0);
|
|
3580
3581
|
_(n, "label", o, r), ce(n, "header", o, r), W(n, "rowHeightMm", o, r, Number.MIN_VALUE), ti(n.columns, `${o}.columns`, r), n.unmatched !== void 0 && n.unmatched !== "error" && n.unmatched !== "ignore" && r.push({ path: `${o}.unmatched`, message: "未关联明细策略应为 error 或 ignore" });
|
|
3581
3582
|
}
|
|
3582
|
-
function
|
|
3583
|
+
function Yf(e, t, r) {
|
|
3583
3584
|
for (const n of ["leftMm", "topMm"]) W(e, n, t, r, -1 / 0, !0);
|
|
3584
3585
|
W(e, "widthMm", t, r, Number.MIN_VALUE, !0), _(e, "dataset", t, r, !0), _(e, "title", t, r);
|
|
3585
3586
|
for (const n of ["rowKey", "revisionField", "sourceTokenField"]) _(e, n, t, r, e[n] !== void 0);
|
|
3586
|
-
e.headerGrid !== void 0 &&
|
|
3587
|
+
e.headerGrid !== void 0 && Hf(e.headerGrid, e.columns, `${t}.headerGrid`, r), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && r.push({ path: `${t}.layout`, message: "布局应为 page 或 wide" }), ti(e.columns, `${t}.columns`, r);
|
|
3587
3588
|
for (const n of ["fontSizePt", "rowHeightMm"]) W(e, n, t, r, Number.MIN_VALUE);
|
|
3588
3589
|
W(e, "paddingMm", t, r);
|
|
3589
3590
|
for (const n of ["header", "headerBold", "headerEveryPage", "border"]) ce(e, n, t, r);
|
|
3590
|
-
e.cardinality !== void 0 && e.cardinality !== "record" && r.push({ path: `${t}.cardinality`, message: "单记录区域类型应为 record" }), _(e, "headerBackgroundColor", t, r), Se(e.align, `${t}.align`, r, !0), Se(e.headerAlign, `${t}.headerAlign`, r), oe(e.headerStyle, `${t}.headerStyle`, r),
|
|
3591
|
+
e.cardinality !== void 0 && e.cardinality !== "record" && r.push({ path: `${t}.cardinality`, message: "单记录区域类型应为 record" }), _(e, "headerBackgroundColor", t, r), Se(e.align, `${t}.align`, r, !0), Se(e.headerAlign, `${t}.headerAlign`, r), oe(e.headerStyle, `${t}.headerStyle`, r), Gf(e, t, r), ri(e.groupBy, `${t}.groupBy`, r), Vf(e.grandTotal, `${t}.grandTotal`, r);
|
|
3591
3592
|
}
|
|
3592
3593
|
function Sn(e, t, r) {
|
|
3593
3594
|
Array.isArray(e.richParagraphs) && e.richParagraphs.forEach((n, o) => {
|
|
@@ -3637,7 +3638,7 @@ function Ur(e, t, r) {
|
|
|
3637
3638
|
});
|
|
3638
3639
|
});
|
|
3639
3640
|
}
|
|
3640
|
-
function
|
|
3641
|
+
function qf(e, t, r) {
|
|
3641
3642
|
if (!(e.flow === void 0 || !Array.isArray(e.components)))
|
|
3642
3643
|
try {
|
|
3643
3644
|
wo(e.components, e.flow);
|
|
@@ -3645,9 +3646,9 @@ function Yf(e, t, r) {
|
|
|
3645
3646
|
r.push({ path: `${t}.flow`, message: n instanceof Error ? n.message : String(n) });
|
|
3646
3647
|
}
|
|
3647
3648
|
}
|
|
3648
|
-
function
|
|
3649
|
+
function Xf(e) {
|
|
3649
3650
|
const t = [], r = [];
|
|
3650
|
-
return
|
|
3651
|
+
return Wf(e, t), t.length ? { ok: !1, errors: t, warnings: r } : (C(e) ? (e.schemaVersion !== void 0 && e.schemaVersion !== Ke && t.push({ path: "$.schemaVersion", message: "不支持的模板 schemaVersion" }), zf(e.params, "$.params", t), Cf(e.dataContract, "$.dataContract", t), xo(e, t), !Array.isArray(e.pages) || e.pages.length === 0 ? t.push({ path: "$.pages", message: "模板至少需要一页" }) : e.pages.forEach((n, o) => {
|
|
3651
3652
|
const i = `$.pages.${o}`;
|
|
3652
3653
|
if (!C(n)) {
|
|
3653
3654
|
t.push({ path: i, message: "页应为对象" });
|
|
@@ -3657,11 +3658,11 @@ function qf(e) {
|
|
|
3657
3658
|
for (const s of ["marginTopMm", "marginBottomMm", "marginLeftMm", "marginRightMm"]) W(n, s, i, t);
|
|
3658
3659
|
typeof n.widthMm == "number" && Number(n.marginLeftMm ?? 0) + Number(n.marginRightMm ?? 0) >= n.widthMm && t.push({ path: i, message: "横向页边距占满页面" }), typeof n.heightMm == "number" && Number(n.marginTopMm ?? 0) + Number(n.marginBottomMm ?? 0) >= n.heightMm && t.push({ path: i, message: "纵向页边距占满页面" }), Array.isArray(n.components) ? n.components.forEach((s, a) => {
|
|
3659
3660
|
const c = `${i}.components.${a}`;
|
|
3660
|
-
C(s) && s.kind === "list" ?
|
|
3661
|
-
}) : t.push({ path: `${i}.components`, message: "组件应为数组" }),
|
|
3661
|
+
C(s) && s.kind === "list" ? Yf(s, c, t) : (Jo(s, c, t, r), C(s) && Ur(s, c, t));
|
|
3662
|
+
}) : t.push({ path: `${i}.components`, message: "组件应为数组" }), qf(n, i, t);
|
|
3662
3663
|
})) : t.push({ path: "$", message: "模板应为对象" }), { ok: t.length === 0, errors: t, warnings: r });
|
|
3663
3664
|
}
|
|
3664
|
-
class
|
|
3665
|
+
class Zf extends Error {
|
|
3665
3666
|
constructor(t) {
|
|
3666
3667
|
super(t.map((r) => r.message).join(";")), this.issues = t, this.name = "ReportValidationError";
|
|
3667
3668
|
}
|
|
@@ -3670,7 +3671,7 @@ function En(e, t, r) {
|
|
|
3670
3671
|
if (!Number.isSafeInteger(e) || e < 1 || e > r) throw new Error(`校验 ${t} 超出预算`);
|
|
3671
3672
|
return e;
|
|
3672
3673
|
}
|
|
3673
|
-
function
|
|
3674
|
+
function Qf(e) {
|
|
3674
3675
|
if (e.aggregates && e.scope !== "dataset") throw new Error("仅数据集规则允许汇总");
|
|
3675
3676
|
if (e.aggregates && (!Array.isArray(e.aggregates) || e.aggregates.length > 64)) throw new Error("校验汇总最多 64 项");
|
|
3676
3677
|
const t = /* @__PURE__ */ new Set();
|
|
@@ -3688,7 +3689,7 @@ function ni(e) {
|
|
|
3688
3689
|
if (t.add(r.id), r.field !== void 0 && K(r.field), r.dataset !== void 0 && K(r.dataset), typeof r.message != "string" || !r.message.trim() || r.message.length > 2048) throw new Error("校验规则需要有界提示文案");
|
|
3689
3690
|
if (r.severity !== void 0 && !["error", "warning"].includes(r.severity)) throw new Error("未知校验严重程度");
|
|
3690
3691
|
if (r.scope !== void 0 && !["row", "dataset"].includes(r.scope)) throw new Error("未知校验范围");
|
|
3691
|
-
|
|
3692
|
+
Qf(r);
|
|
3692
3693
|
const n = { nodes: 0 }, o = q(r.assert, n), i = r.when ? q(r.when, n) : void 0;
|
|
3693
3694
|
return { rule: r, assert: o, when: i, checks: n.nodes };
|
|
3694
3695
|
});
|
|
@@ -3699,12 +3700,12 @@ function An(e) {
|
|
|
3699
3700
|
throw t.name = "AbortError", t;
|
|
3700
3701
|
}
|
|
3701
3702
|
}
|
|
3702
|
-
function
|
|
3703
|
+
function eu(e, t, r, n) {
|
|
3703
3704
|
const o = n && Object.prototype.hasOwnProperty.call(t, n) ? t[n] : void 0;
|
|
3704
3705
|
if (o !== void 0 && typeof o != "string" && !(typeof o == "number" && Number.isFinite(o))) throw new Error("校验定位需要稳定的文本或数值业务键");
|
|
3705
3706
|
return { ruleId: e.id, rowIndex: r, ...o === void 0 ? {} : { rowKey: o }, field: e.field, severity: e.severity ?? "error", message: e.message };
|
|
3706
3707
|
}
|
|
3707
|
-
function
|
|
3708
|
+
function tu(e, t) {
|
|
3708
3709
|
const r = t.computed?.length ? { fields: t.computed, formula: t.formula, signal: t.signal } : void 0;
|
|
3709
3710
|
if (t.tree) {
|
|
3710
3711
|
const o = yo(e, t.tree, { signal: t.signal, computed: r });
|
|
@@ -3714,7 +3715,7 @@ function eu(e, t) {
|
|
|
3714
3715
|
const n = r ? Ft(e, r).rows : e;
|
|
3715
3716
|
return { rows: n, summaryRows: n, rowKey: t.rowKey };
|
|
3716
3717
|
}
|
|
3717
|
-
function
|
|
3718
|
+
function ru(e, t) {
|
|
3718
3719
|
const r = /* @__PURE__ */ new Set();
|
|
3719
3720
|
e.forEach((n) => {
|
|
3720
3721
|
if (!n || typeof n != "object" || Array.isArray(n)) throw new Error("校验数据行应为对象");
|
|
@@ -3725,13 +3726,13 @@ function tu(e, t) {
|
|
|
3725
3726
|
r.add(o);
|
|
3726
3727
|
});
|
|
3727
3728
|
}
|
|
3728
|
-
function
|
|
3729
|
+
function nu(e, t, r) {
|
|
3729
3730
|
if (!Array.isArray(e) || e.length > 1e5) throw new Error("校验数据最多 100000 行");
|
|
3730
3731
|
An(t.signal);
|
|
3731
3732
|
const n = En(t.maxChecks ?? 2e6, "maxChecks", 1e7), o = En(t.maxIssues ?? 1e3, "maxIssues", 1e4);
|
|
3732
3733
|
t.rowKey !== void 0 && K(t.rowKey);
|
|
3733
|
-
const i =
|
|
3734
|
-
|
|
3734
|
+
const i = tu(e, t), { rows: s, summaryRows: a, rowKey: c } = i;
|
|
3735
|
+
ru(s, c);
|
|
3735
3736
|
const f = ni(t.rules), u = f.reduce((l, m) => l + (m.rule.scope === "dataset" ? m.checks + a.length * (m.rule.aggregates?.length ?? 0) : s.length * m.checks), 0);
|
|
3736
3737
|
if (r.checks += u, r.checks > n) throw new Error("整批校验超出 maxChecks 预算");
|
|
3737
3738
|
const d = [];
|
|
@@ -3740,22 +3741,22 @@ function ru(e, t, r) {
|
|
|
3740
3741
|
if (An(t.signal), !h || typeof h != "object" || Array.isArray(h)) throw new Error("校验数据行应为对象");
|
|
3741
3742
|
if (!(l.when && !l.when(h) || l.assert(h))) {
|
|
3742
3743
|
if (d.length >= o) throw new Error("校验问题超出 maxIssues 预算,请缩小范围");
|
|
3743
|
-
d.push(
|
|
3744
|
+
d.push(eu(l.rule, h, l.rule.scope === "dataset" ? void 0 : g, l.rule.scope === "dataset" ? void 0 : c));
|
|
3744
3745
|
}
|
|
3745
3746
|
});
|
|
3746
3747
|
return d;
|
|
3747
3748
|
}
|
|
3748
|
-
function
|
|
3749
|
+
function ou(e, t = "allow") {
|
|
3749
3750
|
if (!["allow", "block"].includes(t)) throw new Error("未知校验警告策略");
|
|
3750
3751
|
if (!Array.isArray(e) || e.length > 1e4 || e.some((r) => !r || !["error", "warning"].includes(r.severity) || typeof r.ruleId != "string" || !r.ruleId.trim() || typeof r.message != "string" || !r.message.trim())) throw new Error("校验问题结构无效");
|
|
3751
|
-
if (e.some((r) => r.severity === "error" || t === "block")) throw new
|
|
3752
|
+
if (e.some((r) => r.severity === "error" || t === "block")) throw new Zf(e);
|
|
3752
3753
|
}
|
|
3753
3754
|
function kn(e, t, r) {
|
|
3754
3755
|
const n = e.get(t);
|
|
3755
3756
|
if (n && JSON.stringify(n) !== JSON.stringify(r)) throw new Error("同一数据集的校验计算/业务键存在歧义,请统一绑定");
|
|
3756
3757
|
e.set(t, r);
|
|
3757
3758
|
}
|
|
3758
|
-
function
|
|
3759
|
+
function iu(e, t, r, n = []) {
|
|
3759
3760
|
ni(t.rules);
|
|
3760
3761
|
const o = [], i = { checks: 0 };
|
|
3761
3762
|
for (const [a, c] of e.entries()) {
|
|
@@ -3764,7 +3765,7 @@ function ou(e, t, r, n = []) {
|
|
|
3764
3765
|
d.kind === "list" && (kn(f, d.dataset, { rowKey: d.tree?.idField ?? d.rowKey, computed: d.computed, tree: d.tree }), d.detail && kn(f, d.detail.dataset, { rowKey: d.detail.rowKey }));
|
|
3765
3766
|
for (const [u, d] of f) {
|
|
3766
3767
|
const l = t.rules.filter((m) => !m.dataset || m.dataset === u);
|
|
3767
|
-
if (l.length && (o.push(...
|
|
3768
|
+
if (l.length && (o.push(...nu(c.datasets[u] ?? [], { ...t, rules: l, ...d, formula: n[a], signal: r }, i).map((m) => ({ ...m, dataset: u, sourceScope: c.sourceScope }))), o.length > (t.maxIssues ?? 1e3)))
|
|
3768
3769
|
throw new Error("整批候选校验问题超出 maxIssues 预算");
|
|
3769
3770
|
}
|
|
3770
3771
|
}
|
|
@@ -3772,23 +3773,23 @@ function ou(e, t, r, n = []) {
|
|
|
3772
3773
|
if (t.rules.some((a) => a.dataset && !s.has(a.dataset))) throw new Error("校验目标数据集不存在");
|
|
3773
3774
|
return o;
|
|
3774
3775
|
}
|
|
3775
|
-
function
|
|
3776
|
+
function su(e) {
|
|
3776
3777
|
return !e || typeof e != "object" ? !1 : [e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex].every((t) => Number.isInteger(t) && t >= 0);
|
|
3777
3778
|
}
|
|
3778
|
-
function
|
|
3779
|
+
function au(e) {
|
|
3779
3780
|
return e.value !== void 0 ? e.value : e.rawText ?? e.text ?? null;
|
|
3780
3781
|
}
|
|
3781
|
-
function
|
|
3782
|
+
function cu(e, t) {
|
|
3782
3783
|
return e.valueType ? e.valueType : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t === null && e.numberFormat && /[0#?]/.test(e.numberFormat) ? "number" : "text";
|
|
3783
3784
|
}
|
|
3784
|
-
function
|
|
3785
|
+
function fu(e, t) {
|
|
3785
3786
|
if (e.derived) return "derived";
|
|
3786
3787
|
if (e.editable === !1) return "cell";
|
|
3787
3788
|
if (e.formula !== void 0) return "formula";
|
|
3788
3789
|
if (e.children?.length || e.richParagraphs?.length) return "complex";
|
|
3789
3790
|
if (t.table && t.table.role !== "body" && e.editable !== !0) return "structure";
|
|
3790
3791
|
}
|
|
3791
|
-
function
|
|
3792
|
+
function uu(e, t) {
|
|
3792
3793
|
const r = e.table;
|
|
3793
3794
|
if (r)
|
|
3794
3795
|
return {
|
|
@@ -3798,23 +3799,23 @@ function fu(e, t) {
|
|
|
3798
3799
|
columnKey: r.columnKeys[t.columnIndex]
|
|
3799
3800
|
};
|
|
3800
3801
|
}
|
|
3801
|
-
function
|
|
3802
|
+
function lu(e, t, r) {
|
|
3802
3803
|
if (e.derived) return;
|
|
3803
3804
|
if (e.source) return { ...e.source };
|
|
3804
3805
|
const n = t.table?.source, o = t.table?.columnKeys[r.columnIndex];
|
|
3805
3806
|
if (!(!n || n.rowKey === void 0 || o === void 0))
|
|
3806
3807
|
return { ...n, rowKey: n.rowKey, field: o };
|
|
3807
3808
|
}
|
|
3808
|
-
function
|
|
3809
|
-
const n =
|
|
3809
|
+
function du(e, t, r) {
|
|
3810
|
+
const n = au(r), o = fu(r, e);
|
|
3810
3811
|
return {
|
|
3811
3812
|
address: { ...t },
|
|
3812
3813
|
cell: r,
|
|
3813
3814
|
component: e,
|
|
3814
3815
|
value: n,
|
|
3815
|
-
valueType:
|
|
3816
|
-
table:
|
|
3817
|
-
source:
|
|
3816
|
+
valueType: cu(r, n),
|
|
3817
|
+
table: uu(e, t),
|
|
3818
|
+
source: lu(r, e, t),
|
|
3818
3819
|
editable: o === void 0,
|
|
3819
3820
|
readOnlyReason: o
|
|
3820
3821
|
};
|
|
@@ -3822,7 +3823,7 @@ function lu(e, t, r) {
|
|
|
3822
3823
|
function oi(e) {
|
|
3823
3824
|
const t = /* @__PURE__ */ new Map();
|
|
3824
3825
|
return (r) => {
|
|
3825
|
-
if (!
|
|
3826
|
+
if (!su(r)) return null;
|
|
3826
3827
|
const n = e.pages[r.pageIndex]?.components[r.componentIndex];
|
|
3827
3828
|
if (!n?.grid) return null;
|
|
3828
3829
|
let o = t.get(n);
|
|
@@ -3838,28 +3839,28 @@ function oi(e) {
|
|
|
3838
3839
|
t.set(n, o);
|
|
3839
3840
|
}
|
|
3840
3841
|
const i = o.get(`${r.rowIndex}:${r.columnIndex}`);
|
|
3841
|
-
return i ?
|
|
3842
|
+
return i ? du(n, r, i) : null;
|
|
3842
3843
|
};
|
|
3843
3844
|
}
|
|
3844
|
-
function
|
|
3845
|
+
function mu(e) {
|
|
3845
3846
|
const t = [""];
|
|
3846
3847
|
let r = !1, n = !1;
|
|
3847
3848
|
for (const o of e)
|
|
3848
3849
|
o === ";" && !r && !n ? t.push("") : t[t.length - 1] += o, o === '"' && !n && (r = !r), n = o === "\\" && !n;
|
|
3849
3850
|
return t;
|
|
3850
3851
|
}
|
|
3851
|
-
function
|
|
3852
|
-
const r =
|
|
3852
|
+
function hu(e, t) {
|
|
3853
|
+
const r = mu(t), n = e === 0 && r.length > 2 ? 2 : e < 0 && r.length > 1 ? 1 : 0;
|
|
3853
3854
|
return { pattern: r[n], magnitude: Math.abs(e), negative: e < 0 && n === 0 };
|
|
3854
3855
|
}
|
|
3855
|
-
function
|
|
3856
|
+
function gu(e) {
|
|
3856
3857
|
const t = [];
|
|
3857
3858
|
return { text: e.replace(/"([^"]*)"|\\(.)/g, (n, o, i) => (t.push(o ?? i ?? ""), String.fromCharCode(57344 + t.length - 1))).replace(/\[(Black|Blue|Cyan|Green|Magenta|Red|White|Yellow|Color\d+)\]/gi, ""), literals: t };
|
|
3858
3859
|
}
|
|
3859
3860
|
function Pe(e, t) {
|
|
3860
3861
|
return /[0#?@_*%[\]"\\.,/]/.test(e) ? null : e.replace(/[\uE000-\uF8FF]/g, (r) => t.literals[r.charCodeAt(0) - 57344] ?? "");
|
|
3861
3862
|
}
|
|
3862
|
-
function
|
|
3863
|
+
function pu(e, t) {
|
|
3863
3864
|
const r = /^(.*?)(0)(?:\.([0#]+))?E([+-])(0+)(.*?)$/i.exec(t.text);
|
|
3864
3865
|
if (!r) return null;
|
|
3865
3866
|
const n = Pe(r[1], t), o = Pe(r[6], t), i = r[3] ?? "";
|
|
@@ -3867,7 +3868,7 @@ function gu(e, t) {
|
|
|
3867
3868
|
const [s, a] = e.magnitude.toExponential(i.length).split("e"), c = i.replace(/#/g, "").length, [f, u = ""] = s.split("."), d = u.replace(/0+$/, "").padEnd(c, "0"), l = Number(a), m = l < 0 ? "-" : r[4] === "+" ? "+" : "", h = String(Math.abs(l)).padStart(r[5].length, "0");
|
|
3868
3869
|
return `${e.negative ? "-" : ""}${n}${f}${d ? `.${d}` : ""}E${m}${h}${o}`;
|
|
3869
3870
|
}
|
|
3870
|
-
function
|
|
3871
|
+
function yu(e, t) {
|
|
3871
3872
|
const r = /^(.*?)([#,]*0[0#]*)(?:\.([0#]+))?(%)?(.*?)$/.exec(t.text);
|
|
3872
3873
|
if (!r) return Pe(t.text, t);
|
|
3873
3874
|
const n = Pe(r[1], t), o = Pe(r[5], t), i = r[2], s = r[3] ?? "";
|
|
@@ -3882,14 +3883,14 @@ function pu(e, t) {
|
|
|
3882
3883
|
});
|
|
3883
3884
|
return `${e.negative ? "-" : ""}${n}${c}${r[4] ?? ""}${o}`;
|
|
3884
3885
|
}
|
|
3885
|
-
function
|
|
3886
|
+
function wu(e, t, r) {
|
|
3886
3887
|
if (!t || /^(General|@)$/i.test(t)) return String(e);
|
|
3887
|
-
const n =
|
|
3888
|
+
const n = hu(e, t);
|
|
3888
3889
|
if (n.pattern === "") return "";
|
|
3889
|
-
const o =
|
|
3890
|
+
const o = gu(n.pattern), i = pu(n, o) ?? yu(n, o);
|
|
3890
3891
|
return i !== null ? i : String(e);
|
|
3891
3892
|
}
|
|
3892
|
-
function
|
|
3893
|
+
function bu(e) {
|
|
3893
3894
|
return e !== void 0 && e.replace(/"[^"]*"|\\./g, "").includes("%");
|
|
3894
3895
|
}
|
|
3895
3896
|
class P extends Error {
|
|
@@ -3897,16 +3898,16 @@ class P extends Error {
|
|
|
3897
3898
|
super(`Invalid report cell edit: ${t}`), this.code = t, this.name = "ReportCellEditError";
|
|
3898
3899
|
}
|
|
3899
3900
|
}
|
|
3900
|
-
function
|
|
3901
|
+
function xu(e, t) {
|
|
3901
3902
|
let r = e.trim();
|
|
3902
3903
|
const n = t && r.endsWith("%");
|
|
3903
3904
|
if (n && (r = r.slice(0, -1).trim()), /^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?(?:[eE][+-]?\d+)?$/.test(r) && (r = r.replace(/,/g, "")), !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(r)) throw new P("number");
|
|
3904
3905
|
return Number(r) / (n ? 100 : 1);
|
|
3905
3906
|
}
|
|
3906
|
-
function
|
|
3907
|
+
function Mu(e, t) {
|
|
3907
3908
|
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
3908
3909
|
if (typeof e != "string" && typeof e != "number") throw new P("number");
|
|
3909
|
-
const r = typeof e == "number" ? e :
|
|
3910
|
+
const r = typeof e == "number" ? e : xu(e, bu(t.cell.numberFormat));
|
|
3910
3911
|
if (!Number.isFinite(r) || Number.isInteger(r) && !Number.isSafeInteger(r)) throw new P("number");
|
|
3911
3912
|
return r;
|
|
3912
3913
|
}
|
|
@@ -3918,19 +3919,19 @@ function vu(e) {
|
|
|
3918
3919
|
if (["false", "no", "否", "0"].includes(t)) return !1;
|
|
3919
3920
|
throw new P("boolean");
|
|
3920
3921
|
}
|
|
3921
|
-
function Mu(e, t) {
|
|
3922
|
-
return e.valueType === "number" ? xu(t, e) : e.valueType === "boolean" ? vu(t) : t === null ? null : String(t);
|
|
3923
|
-
}
|
|
3924
3922
|
function $u(e, t) {
|
|
3923
|
+
return e.valueType === "number" ? Mu(t, e) : e.valueType === "boolean" ? vu(t) : t === null ? null : String(t);
|
|
3924
|
+
}
|
|
3925
|
+
function Su(e, t) {
|
|
3925
3926
|
const r = t.cell.text, o = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((i) => i.includes(r ?? ""));
|
|
3926
3927
|
return o ? o[e ? 0 : 1] : String(e);
|
|
3927
3928
|
}
|
|
3928
3929
|
function ii(e, t) {
|
|
3929
|
-
return t === null ? "" : typeof t == "boolean" ?
|
|
3930
|
+
return t === null ? "" : typeof t == "boolean" ? Su(t, e) : typeof t == "number" ? wu(t, e.cell.numberFormat) : String(t);
|
|
3930
3931
|
}
|
|
3931
3932
|
function si(e, t) {
|
|
3932
3933
|
if (!e.editable) throw new P("readonly");
|
|
3933
|
-
const r =
|
|
3934
|
+
const r = $u(e, t);
|
|
3934
3935
|
return {
|
|
3935
3936
|
address: { ...e.address },
|
|
3936
3937
|
table: e.table,
|
|
@@ -3941,7 +3942,7 @@ function si(e, t) {
|
|
|
3941
3942
|
text: ii(e, r)
|
|
3942
3943
|
};
|
|
3943
3944
|
}
|
|
3944
|
-
function
|
|
3945
|
+
function Eu(e, t) {
|
|
3945
3946
|
const r = t.source;
|
|
3946
3947
|
if (!r) return !1;
|
|
3947
3948
|
const n = e.source;
|
|
@@ -3991,11 +3992,11 @@ function fi(e, t) {
|
|
|
3991
3992
|
}
|
|
3992
3993
|
for (const o of n) {
|
|
3993
3994
|
const [i, s] = JSON.parse(o);
|
|
3994
|
-
|
|
3995
|
+
Is(e[i].datasets[s], r[i].datasets[s]);
|
|
3995
3996
|
}
|
|
3996
3997
|
return r;
|
|
3997
3998
|
}
|
|
3998
|
-
function
|
|
3999
|
+
function Au(e, t, r) {
|
|
3999
4000
|
const n = [], o = /* @__PURE__ */ new Set();
|
|
4000
4001
|
return e.forEach((i, s) => {
|
|
4001
4002
|
for (const a of ai(i))
|
|
@@ -4009,7 +4010,7 @@ function Eu(e, t, r) {
|
|
|
4009
4010
|
});
|
|
4010
4011
|
}), n;
|
|
4011
4012
|
}
|
|
4012
|
-
function
|
|
4013
|
+
function ku(e, t, r) {
|
|
4013
4014
|
if (!r || r.revision === void 0 && r.sourceToken === void 0) return e;
|
|
4014
4015
|
const n = new Set(t.edits.flatMap((o) => o.source ? [Ee(o.source)] : []));
|
|
4015
4016
|
return ui(e, new Map([...n].map((o) => [o, r])));
|
|
@@ -4048,7 +4049,7 @@ function xt(e) {
|
|
|
4048
4049
|
const n = e.address;
|
|
4049
4050
|
return JSON.stringify([n.pageIndex, n.componentIndex, n.rowIndex, n.columnIndex]);
|
|
4050
4051
|
}
|
|
4051
|
-
function
|
|
4052
|
+
function Nu(e) {
|
|
4052
4053
|
const t = /* @__PURE__ */ new Map(), r = oi(e);
|
|
4053
4054
|
return e.pages.forEach((n, o) => n.components.forEach((i, s) => {
|
|
4054
4055
|
if (!(!i.grid || i.table?.role !== "body"))
|
|
@@ -4061,7 +4062,7 @@ function ku(e) {
|
|
|
4061
4062
|
function li(e, t) {
|
|
4062
4063
|
if (++e.nodes > 1e6 || t > 128) throw new P("limit");
|
|
4063
4064
|
}
|
|
4064
|
-
function
|
|
4065
|
+
function Mt(e, t) {
|
|
4065
4066
|
const r = Object.getOwnPropertyDescriptor(e, t);
|
|
4066
4067
|
if (!r || r.get || r.set) throw new P("conflict");
|
|
4067
4068
|
return r.value;
|
|
@@ -4082,7 +4083,7 @@ function di(e, t, r, n, o) {
|
|
|
4082
4083
|
if (e === null || typeof e != "object") return;
|
|
4083
4084
|
if (Gr(e), r.has(e)) throw new P("conflict");
|
|
4084
4085
|
r.add(e);
|
|
4085
|
-
const i = Object.keys(e), s = i.map((a) =>
|
|
4086
|
+
const i = Object.keys(e), s = i.map((a) => Mt(e, a));
|
|
4086
4087
|
t.push({
|
|
4087
4088
|
object: e,
|
|
4088
4089
|
prototype: Object.getPrototypeOf(e),
|
|
@@ -4094,23 +4095,23 @@ function di(e, t, r, n, o) {
|
|
|
4094
4095
|
for (const a of s) di(a, t, r, n, o + 1);
|
|
4095
4096
|
r.delete(e);
|
|
4096
4097
|
}
|
|
4097
|
-
function
|
|
4098
|
+
function Pu(e) {
|
|
4098
4099
|
const { object: t, keys: r, values: n } = e;
|
|
4099
4100
|
if (Gr(t), Object.getPrototypeOf(t) !== e.prototype || Object.getOwnPropertyDescriptor(t, "toJSON") || e.date !== void 0 && !Object.is(Date.prototype.getTime.call(t), e.date) || e.length !== void 0 && t.length !== e.length) return !1;
|
|
4100
4101
|
const o = Object.keys(t);
|
|
4101
|
-
return o.length === r.length && r.every((i, s) => o[s] === i && Object.is(
|
|
4102
|
+
return o.length === r.length && r.every((i, s) => o[s] === i && Object.is(Mt(t, i), n[s]));
|
|
4102
4103
|
}
|
|
4103
|
-
function
|
|
4104
|
+
function Fu(e) {
|
|
4104
4105
|
const t = [];
|
|
4105
4106
|
return di(e, t, /* @__PURE__ */ new Set(), { nodes: 0 }, 0), () => {
|
|
4106
4107
|
try {
|
|
4107
|
-
return t.every(
|
|
4108
|
+
return t.every(Pu);
|
|
4108
4109
|
} catch {
|
|
4109
4110
|
return !1;
|
|
4110
4111
|
}
|
|
4111
4112
|
};
|
|
4112
4113
|
}
|
|
4113
|
-
function
|
|
4114
|
+
function vt(e, t, r, n = !1) {
|
|
4114
4115
|
if (li(t, r), n) {
|
|
4115
4116
|
if (typeof e == "function" || typeof e == "symbol") throw new P("conflict");
|
|
4116
4117
|
e !== null && typeof e == "object" && Gr(e);
|
|
@@ -4119,20 +4120,20 @@ function Mt(e, t, r, n = !1) {
|
|
|
4119
4120
|
if (e instanceof Date) return new Date(Date.prototype.getTime.call(e));
|
|
4120
4121
|
if (Array.isArray(e)) {
|
|
4121
4122
|
const o = [];
|
|
4122
|
-
for (let i = 0; i < e.length; i++) o[i] = Mt(
|
|
4123
|
+
for (let i = 0; i < e.length; i++) o[i] = vt(Mt(e, String(i)), t, r + 1, n);
|
|
4123
4124
|
return o;
|
|
4124
4125
|
}
|
|
4125
|
-
return Object.fromEntries(Object.keys(e).map((o) => [o, Mt(
|
|
4126
|
-
}
|
|
4127
|
-
function Fu(e) {
|
|
4128
|
-
return Mt(e, { nodes: 0 }, 0, !0);
|
|
4126
|
+
return Object.fromEntries(Object.keys(e).map((o) => [o, vt(Mt(e, o), t, r + 1, n)]));
|
|
4129
4127
|
}
|
|
4130
4128
|
function Ou(e) {
|
|
4131
|
-
|
|
4132
|
-
|
|
4129
|
+
return vt(e, { nodes: 0 }, 0, !0);
|
|
4130
|
+
}
|
|
4131
|
+
function Ru(e) {
|
|
4132
|
+
const t = vt(e, { nodes: 0 }, 0);
|
|
4133
|
+
for (const r of t) for (const n of Object.values(r.datasets)) Rs(n);
|
|
4133
4134
|
return t;
|
|
4134
4135
|
}
|
|
4135
|
-
async function
|
|
4136
|
+
async function Iu(e, t, r = {}) {
|
|
4136
4137
|
return Do(e, t, { ...r, knownTotalPages: void 0 });
|
|
4137
4138
|
}
|
|
4138
4139
|
const Pn = /* @__PURE__ */ new WeakMap();
|
|
@@ -4145,19 +4146,19 @@ function He(e) {
|
|
|
4145
4146
|
function mi(e, t) {
|
|
4146
4147
|
return e[t] === void 0 ? "" : e[t];
|
|
4147
4148
|
}
|
|
4148
|
-
function
|
|
4149
|
+
function Cu(e, t) {
|
|
4149
4150
|
if (t.edits.length > 1e4) throw new P("limit");
|
|
4150
4151
|
const r = oi(e), n = /* @__PURE__ */ new Set(), o = [], i = t.edits.map((s) => {
|
|
4151
4152
|
const a = r(s.address);
|
|
4152
4153
|
if (!a?.source) throw new P("missing");
|
|
4153
4154
|
const c = xt(s);
|
|
4154
4155
|
if (n.has(c)) throw new P("duplicate");
|
|
4155
|
-
if (n.add(c),
|
|
4156
|
+
if (n.add(c), Eu(a, s) || !Object.is(a.value, s.previousValue) || (a.cell.text ?? "") !== s.previousText) throw new P("conflict");
|
|
4156
4157
|
return o.push(a), si(a, s.value);
|
|
4157
4158
|
});
|
|
4158
4159
|
return { batch: { requestId: t.requestId, edits: i }, contexts: o };
|
|
4159
4160
|
}
|
|
4160
|
-
function
|
|
4161
|
+
function Tu(e, t) {
|
|
4161
4162
|
const r = ci(e);
|
|
4162
4163
|
return t.flatMap((n) => {
|
|
4163
4164
|
if (!n.source) throw new P("missing");
|
|
@@ -4172,12 +4173,12 @@ function Ut(e, t, r) {
|
|
|
4172
4173
|
const n = { ...e, value: t, source: { ...e.source, ...r?.revision === void 0 ? {} : { revision: r.revision }, ...r?.sourceToken === void 0 ? {} : { sourceToken: r.sourceToken } } };
|
|
4173
4174
|
return n.cell = { ...e.cell, value: n.value, text: ii(n, n.value) }, n;
|
|
4174
4175
|
}
|
|
4175
|
-
function
|
|
4176
|
+
function ju(e, t, r) {
|
|
4176
4177
|
if (!r || r.revision === void 0 && r.sourceToken === void 0) return [...e];
|
|
4177
4178
|
const n = new Set(t.edits.flatMap((o) => o.source ? [Ee(o.source)] : []));
|
|
4178
|
-
return fi(e,
|
|
4179
|
+
return fi(e, Au(e, n, r));
|
|
4179
4180
|
}
|
|
4180
|
-
function
|
|
4181
|
+
function Du(e, t, r) {
|
|
4181
4182
|
const n = new Set(t.edits.map((o) => Ee(o.source)));
|
|
4182
4183
|
for (const o of n) e.set(o, {
|
|
4183
4184
|
...e.get(o),
|
|
@@ -4186,38 +4187,38 @@ function ju(e, t, r) {
|
|
|
4186
4187
|
});
|
|
4187
4188
|
return n;
|
|
4188
4189
|
}
|
|
4189
|
-
function
|
|
4190
|
+
function Lu(e, t) {
|
|
4190
4191
|
let r = t.parts;
|
|
4191
4192
|
const n = t.rebuild, o = [...t.validationFormulas ?? []];
|
|
4192
|
-
let i =
|
|
4193
|
+
let i = Fu(r), s = e, a;
|
|
4193
4194
|
const c = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
4194
4195
|
function u(m) {
|
|
4195
4196
|
if (m !== s) throw new P("conflict");
|
|
4196
4197
|
if (a) return a;
|
|
4197
4198
|
if (!i?.()) throw new P("conflict");
|
|
4198
|
-
return
|
|
4199
|
+
return Ru(r);
|
|
4199
4200
|
}
|
|
4200
4201
|
async function d(m, h, g, y = {}) {
|
|
4201
|
-
He(y.signal), h = { requestId: h.requestId, edits: h.edits.map((
|
|
4202
|
-
const w = u(m), p = fi(w,
|
|
4202
|
+
He(y.signal), h = { requestId: h.requestId, edits: h.edits.map((v) => ({ ...v, address: { ...v.address }, source: v.source ? { ...v.source } : void 0, table: v.table ? { ...v.table } : void 0 })) }, g = g.map((v) => ({ ...v, address: { ...v.address }, source: v.source ? { ...v.source } : void 0, table: v.table ? { ...v.table } : void 0, cell: { ...v.cell } })), await new Promise((v) => setTimeout(v, 0)), He(y.signal);
|
|
4203
|
+
const w = u(m), p = fi(w, Tu(w, h.edits)), b = ui(await n(p, y.signal), f);
|
|
4203
4204
|
He(y.signal);
|
|
4204
4205
|
let x = !1, $ = [], j = "allow", D = !1;
|
|
4205
|
-
function v
|
|
4206
|
-
return D = !0, $ = Object.freeze(
|
|
4206
|
+
function M(v) {
|
|
4207
|
+
return D = !0, $ = Object.freeze(iu(p, v, y.signal, o).map((S) => Object.freeze({ ...S }))), D = !1, j = v.warningPolicy ?? "allow", $;
|
|
4207
4208
|
}
|
|
4208
|
-
return y.validation &&
|
|
4209
|
+
return y.validation && M(y.validation), { plan: b, get validationIssues() {
|
|
4209
4210
|
return $;
|
|
4210
|
-
}, validate:
|
|
4211
|
+
}, validate: M, commit(v) {
|
|
4211
4212
|
if (He(y.signal), x || s !== m) throw new P("conflict");
|
|
4212
|
-
if (
|
|
4213
|
+
if (v?.conflicts?.length) throw new P("conflict");
|
|
4213
4214
|
if (D) throw new Error("候选规则校验未完成,不能提交");
|
|
4214
|
-
|
|
4215
|
-
const S =
|
|
4216
|
-
if (
|
|
4217
|
-
const N =
|
|
4218
|
-
for (const [R, ge] of c) N.has(Ee(ge.source)) && c.set(R, Ut(ge, ge.value,
|
|
4215
|
+
ou($, j);
|
|
4216
|
+
const S = ju(p, h, v), I = ku(b, h, v);
|
|
4217
|
+
if (v) {
|
|
4218
|
+
const N = Du(f, h, v);
|
|
4219
|
+
for (const [R, ge] of c) N.has(Ee(ge.source)) && c.set(R, Ut(ge, ge.value, v));
|
|
4219
4220
|
}
|
|
4220
|
-
return g.forEach((N, R) => c.set(xt(N), Ut(N, h.edits[R].value,
|
|
4221
|
+
return g.forEach((N, R) => c.set(xt(N), Ut(N, h.edits[R].value, v))), x = !0, a = S, r = void 0, i = void 0, s = I, Pn.set(s, l), s;
|
|
4221
4222
|
} };
|
|
4222
4223
|
}
|
|
4223
4224
|
const l = {
|
|
@@ -4225,12 +4226,12 @@ function Du(e, t) {
|
|
|
4225
4226
|
return s;
|
|
4226
4227
|
},
|
|
4227
4228
|
async prepare(m, h, g) {
|
|
4228
|
-
const y =
|
|
4229
|
+
const y = Cu(m, h);
|
|
4229
4230
|
return d(m, y.batch, y.contexts, g);
|
|
4230
4231
|
},
|
|
4231
4232
|
async prepareHistory(m, h, g, y, w) {
|
|
4232
4233
|
if (!y.trim() || h.length > 1e4) throw new P("limit");
|
|
4233
|
-
const p = u(m), b = ci(p), x =
|
|
4234
|
+
const p = u(m), b = ci(p), x = Nu(m), $ = /* @__PURE__ */ new Set(), D = h.map((S) => {
|
|
4234
4235
|
if (!S.source) throw new P("missing");
|
|
4235
4236
|
const I = xt(S);
|
|
4236
4237
|
if ($.has(I)) throw new P("duplicate");
|
|
@@ -4239,15 +4240,15 @@ function Du(e, t) {
|
|
|
4239
4240
|
if (!N?.source) throw new P("missing");
|
|
4240
4241
|
const R = b(N.source)[0];
|
|
4241
4242
|
return Ut(N, mi(R.row, N.source.field));
|
|
4242
|
-
}).map((S, I) => ({ context: S, edit: si(S, h[I][g]) })).filter(({ edit: S }) => !Object.is(S.previousValue, S.value)),
|
|
4243
|
-
return { batch:
|
|
4243
|
+
}).map((S, I) => ({ context: S, edit: si(S, h[I][g]) })).filter(({ edit: S }) => !Object.is(S.previousValue, S.value)), M = { requestId: y, edits: D.map(({ edit: S }) => S) }, v = D.map(({ context: S }) => S);
|
|
4244
|
+
return { batch: M, contexts: v, prepared: await d(m, M, v, w) };
|
|
4244
4245
|
}
|
|
4245
4246
|
};
|
|
4246
4247
|
return Pn.set(e, l), l;
|
|
4247
4248
|
}
|
|
4248
|
-
let
|
|
4249
|
+
let Bu = 0;
|
|
4249
4250
|
function tt() {
|
|
4250
|
-
return `report-${Date.now()}-${++
|
|
4251
|
+
return `report-${Date.now()}-${++Bu}`;
|
|
4251
4252
|
}
|
|
4252
4253
|
function xe(e, t, r) {
|
|
4253
4254
|
if (!r?.aborted)
|
|
@@ -4293,11 +4294,11 @@ function Y(e) {
|
|
|
4293
4294
|
function ur(e) {
|
|
4294
4295
|
return typeof e == "string" && e.trim().length > 0 && e.length <= 4096;
|
|
4295
4296
|
}
|
|
4296
|
-
function
|
|
4297
|
+
function _u(e) {
|
|
4297
4298
|
for (const t of ["description", "missingMeaning"]) e[t] !== void 0 && !ur(e[t]) && Y(`${t} 应为 1–4096 位非空字符串`);
|
|
4298
|
-
e.aggregation !== void 0 && !["sum", "avg", "min", "max", "count", "none"].includes(e.aggregation) && Y("未知字段聚合语义"), e.aggregation && !["count", "none"].includes(e.aggregation) && !["number", "decimal"].includes(e.type) && Y("数值聚合仅适用于 number/decimal"), e.format !== void 0 &&
|
|
4299
|
+
e.aggregation !== void 0 && !["sum", "avg", "min", "max", "count", "none"].includes(e.aggregation) && Y("未知字段聚合语义"), e.aggregation && !["count", "none"].includes(e.aggregation) && !["number", "decimal"].includes(e.type) && Y("数值聚合仅适用于 number/decimal"), e.format !== void 0 && Ku(e), e.calculation !== void 0 && (!e.calculation || !ur(e.calculation.description) || !Array.isArray(e.calculation.dependsOn) || !e.calculation.dependsOn.length || e.calculation.dependsOn.length > 256 || e.calculation.dependsOn.some((t) => typeof t != "string" || !t.trim()) || new Set(e.calculation.dependsOn).size !== e.calculation.dependsOn.length) && Y("计算说明需包含说明及 1–256 个唯一依赖字段");
|
|
4299
4300
|
}
|
|
4300
|
-
function
|
|
4301
|
+
function Ku(e) {
|
|
4301
4302
|
const t = e.format;
|
|
4302
4303
|
if ((!t || !["number", "percent", "date"].includes(t.kind)) && Y("未知字段显示格式"), t.kind === "date") {
|
|
4303
4304
|
(e.type !== "date" || t.pattern !== void 0 && (!ur(t.pattern) || t.pattern.length > 128)) && Y("日期格式仅适用于日期,pattern 最多 128 位");
|
|
@@ -4305,7 +4306,7 @@ function _u(e) {
|
|
|
4305
4306
|
}
|
|
4306
4307
|
["number", "decimal"].includes(e.type) || Y("数值显示格式仅适用于 number/decimal"), t.digits !== void 0 && (!Number.isSafeInteger(t.digits) || t.digits < 0 || t.digits > 100) && Y("显示小数位应为 0–100 的整数"), t.kind === "number" && t.thousands !== void 0 && typeof t.thousands != "boolean" && Y("thousands 应为布尔值");
|
|
4307
4308
|
}
|
|
4308
|
-
function
|
|
4309
|
+
function Wu(e) {
|
|
4309
4310
|
const t = new Map(e.map((n) => [n.field, n])), r = /* @__PURE__ */ new Set();
|
|
4310
4311
|
for (const n of e) {
|
|
4311
4312
|
const o = [{ field: n.field, exit: !1 }], i = /* @__PURE__ */ new Set();
|
|
@@ -4322,7 +4323,7 @@ function Ku(e) {
|
|
|
4322
4323
|
}
|
|
4323
4324
|
}
|
|
4324
4325
|
}
|
|
4325
|
-
const
|
|
4326
|
+
const zu = ["text", "number", "boolean", "date", "decimal"], Ju = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
4326
4327
|
function z(e) {
|
|
4327
4328
|
throw new Error(`数据契约无效:${e}`);
|
|
4328
4329
|
}
|
|
@@ -4330,45 +4331,45 @@ function hi(e) {
|
|
|
4330
4331
|
(!e || !Array.isArray(e.fields) || !e.fields.length || e.fields.length > 2048) && z("fields 应包含 1–2048 个字段");
|
|
4331
4332
|
const t = /* @__PURE__ */ new Set();
|
|
4332
4333
|
for (const r of e.fields)
|
|
4333
|
-
(!r || typeof r.field != "string" || !r.field.trim() ||
|
|
4334
|
-
|
|
4334
|
+
(!r || typeof r.field != "string" || !r.field.trim() || Ju.has(r.field) || t.has(r.field)) && z("字段名应安全、非空且唯一"), t.add(r.field), zu.includes(r.type) || z(`未知字段类型 ${r.type}`), Gu(r), Uu(r), _u(r), Vu(r);
|
|
4335
|
+
Hu(e, t), Wu(e.fields);
|
|
4335
4336
|
}
|
|
4336
|
-
function
|
|
4337
|
+
function Vu(e) {
|
|
4337
4338
|
e.enum !== void 0 && (!Array.isArray(e.enum) || !e.enum.length || e.enum.some((t) => !gi(t, e.type))) && z("enum 应为匹配字段类型的非空标量数组");
|
|
4338
4339
|
}
|
|
4339
|
-
function
|
|
4340
|
+
function Hu(e, t) {
|
|
4340
4341
|
e.rowKey !== void 0 && ((typeof e.rowKey != "string" || !e.rowKey.trim() || !t.has(e.rowKey)) && z("rowKey 应为引用已声明字段的非空字符串"), e.fields.find((r) => r.field === e.rowKey)?.type === "boolean" && z("布尔字段不能作为业务主键"));
|
|
4341
4342
|
}
|
|
4342
|
-
function
|
|
4343
|
+
function Uu(e) {
|
|
4343
4344
|
for (const t of ["label", "unit"]) e[t] !== void 0 && typeof e[t] != "string" && z(`${t} 应为字符串`);
|
|
4344
4345
|
for (const t of ["required", "nullable"]) e[t] !== void 0 && typeof e[t] != "boolean" && z(`${t} 应为布尔值`);
|
|
4345
4346
|
e.semanticRole !== void 0 && !["identifier", "dimension", "measure", "date", "text"].includes(e.semanticRole) && z("未知字段语义");
|
|
4346
4347
|
}
|
|
4347
|
-
function
|
|
4348
|
+
function Gu(e) {
|
|
4348
4349
|
for (const t of ["min", "max", "minLength", "maxLength"]) {
|
|
4349
4350
|
const r = e[t];
|
|
4350
4351
|
r !== void 0 && (!Number.isFinite(r) || t.includes("Length") && (!Number.isInteger(r) || r < 0)) && z(`${t} 无效`);
|
|
4351
4352
|
}
|
|
4352
4353
|
e.min !== void 0 && e.max !== void 0 && e.min > e.max && z("min 不能超过 max"), e.minLength !== void 0 && e.maxLength !== void 0 && e.minLength > e.maxLength && z("minLength 不能超过 maxLength"), e.type !== "number" && (e.min !== void 0 || e.max !== void 0) && z("min/max 仅适用于 number,精确小数文本需业务校验"), ["number", "boolean"].includes(e.type) && (e.minLength !== void 0 || e.maxLength !== void 0) && z("长度约束仅适用于文本类型");
|
|
4353
4354
|
}
|
|
4354
|
-
function
|
|
4355
|
+
function Yu(e) {
|
|
4355
4356
|
const t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
|
|
4356
4357
|
if (!t) return !1;
|
|
4357
4358
|
const r = Number(t[1]), n = Number(t[2]), o = Number(t[3]), i = r % 4 === 0 && (r % 100 !== 0 || r % 400 === 0);
|
|
4358
4359
|
return r > 0 && n >= 1 && n <= 12 && o >= 1 && o <= [31, i ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][n - 1];
|
|
4359
4360
|
}
|
|
4360
4361
|
function gi(e, t) {
|
|
4361
|
-
return t === "number" ? typeof e == "number" && Number.isFinite(e) : t === "boolean" ? typeof e == "boolean" : typeof e != "string" ? !1 : t === "date" ?
|
|
4362
|
+
return t === "number" ? typeof e == "number" && Number.isFinite(e) : t === "boolean" ? typeof e == "boolean" : typeof e != "string" ? !1 : t === "date" ? Yu(e) : t === "decimal" ? e.length <= 1e4 && /^-?(?:0|[1-9]\d*)(?:\.\d+)?$/.test(e) : !0;
|
|
4362
4363
|
}
|
|
4363
|
-
function
|
|
4364
|
+
function qu(e, t) {
|
|
4364
4365
|
if (e == null)
|
|
4365
4366
|
return t.required || e === null && t.nullable === !1 ? { code: "required", message: "缺少必需字段值" } : void 0;
|
|
4366
4367
|
if (!gi(e, t.type)) return { code: "type", message: `值应为 ${t.type},不会自动转换原始值` };
|
|
4367
4368
|
if (t.enum && !t.enum.includes(e)) return { code: "enum", message: "值不在允许的枚举中" };
|
|
4368
4369
|
if (typeof e == "number" && (t.min !== void 0 && e < t.min || t.max !== void 0 && e > t.max)) return { code: "range", message: "数值超出范围" };
|
|
4369
|
-
if (typeof e == "string" && !
|
|
4370
|
+
if (typeof e == "string" && !Xu(e, t)) return { code: "range", message: "文本长度超出范围" };
|
|
4370
4371
|
}
|
|
4371
|
-
function
|
|
4372
|
+
function Xu(e, t) {
|
|
4372
4373
|
if (t.minLength === void 0 && t.maxLength === void 0) return !0;
|
|
4373
4374
|
let r = 0;
|
|
4374
4375
|
for (const n of e) r++;
|
|
@@ -4379,14 +4380,14 @@ function Gt(e, t) {
|
|
|
4379
4380
|
if (!Number.isInteger(r) || r < 1) throw new Error("数据校验预算应为正整数");
|
|
4380
4381
|
return r;
|
|
4381
4382
|
}
|
|
4382
|
-
function
|
|
4383
|
+
function Zu(e, t, r) {
|
|
4383
4384
|
const n = Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0;
|
|
4384
4385
|
if ((typeof n != "string" || !n.trim()) && !(typeof n == "number" && Number.isFinite(n))) return "业务主键应为非空字符串或有限数字";
|
|
4385
4386
|
const o = JSON.stringify([typeof n, n]);
|
|
4386
4387
|
if (r.has(o)) return "业务主键重复";
|
|
4387
4388
|
r.add(o);
|
|
4388
4389
|
}
|
|
4389
|
-
function
|
|
4390
|
+
function Qu(e, t, r = {}) {
|
|
4390
4391
|
hi(t);
|
|
4391
4392
|
const n = r.path ?? "$.rows", o = [], i = Gt(r.maxIssues, 100);
|
|
4392
4393
|
if (!Array.isArray(e)) return { ok: !1, issues: [{ code: "row", path: n, message: "数据集应为对象数组" }] };
|
|
@@ -4398,25 +4399,25 @@ function Zu(e, t, r = {}) {
|
|
|
4398
4399
|
o.push({ code: "row", path: `${n}[${a}]`, rowIndex: a, message: "行应为对象" });
|
|
4399
4400
|
continue;
|
|
4400
4401
|
}
|
|
4401
|
-
|
|
4402
|
+
el(c, t, a, n, s, o, i);
|
|
4402
4403
|
}
|
|
4403
4404
|
return { ok: o.length === 0, issues: o };
|
|
4404
4405
|
}
|
|
4405
|
-
function
|
|
4406
|
+
function el(e, t, r, n, o, i, s) {
|
|
4406
4407
|
for (const a of t.fields) {
|
|
4407
4408
|
if (i.length >= s) return;
|
|
4408
|
-
const c =
|
|
4409
|
+
const c = qu(Object.prototype.hasOwnProperty.call(e, a.field) ? e[a.field] : void 0, a);
|
|
4409
4410
|
c && i.push({ ...c, rowIndex: r, field: a.field, path: `${n}[${r}].${a.field}` });
|
|
4410
4411
|
}
|
|
4411
4412
|
if (t.rowKey && i.length < s) {
|
|
4412
|
-
const a =
|
|
4413
|
+
const a = Zu(e, t.rowKey, o);
|
|
4413
4414
|
a && i.push({ code: "row-key", path: `${n}[${r}].${t.rowKey}`, message: a, rowIndex: r, field: t.rowKey });
|
|
4414
4415
|
}
|
|
4415
4416
|
}
|
|
4416
|
-
function
|
|
4417
|
-
return hi(e), { $schema: "https://json-schema.org/draft/2020-12/schema", type: "array", items: { type: "object", properties: Object.fromEntries(e.fields.map((r) => [r.field,
|
|
4417
|
+
function tl(e) {
|
|
4418
|
+
return hi(e), { $schema: "https://json-schema.org/draft/2020-12/schema", type: "array", items: { type: "object", properties: Object.fromEntries(e.fields.map((r) => [r.field, rl(r, r.field === e.rowKey)])), required: e.fields.filter((r) => r.required || r.field === e.rowKey).map((r) => r.field), additionalProperties: !0 }, ...e.rowKey ? { "x-report-rowKey": e.rowKey } : {} };
|
|
4418
4419
|
}
|
|
4419
|
-
function
|
|
4420
|
+
function rl(e, t) {
|
|
4420
4421
|
const r = !t && e.nullable !== !1 && !e.required;
|
|
4421
4422
|
return {
|
|
4422
4423
|
type: r ? [Fn(e.type), "null"] : Fn(e.type),
|
|
@@ -4427,7 +4428,7 @@ function tl(e, t) {
|
|
|
4427
4428
|
...e.enum ? { enum: r ? [...e.enum, null] : [...e.enum] } : {},
|
|
4428
4429
|
...e.min === void 0 ? {} : { minimum: e.min },
|
|
4429
4430
|
...e.max === void 0 ? {} : { maximum: e.max },
|
|
4430
|
-
...
|
|
4431
|
+
...nl(e, t),
|
|
4431
4432
|
...t && e.type === "text" ? { pattern: "\\S" } : {},
|
|
4432
4433
|
...e.unit ? { "x-report-unit": e.unit } : {},
|
|
4433
4434
|
...e.semanticRole ? { "x-report-semanticRole": e.semanticRole } : {},
|
|
@@ -4437,23 +4438,23 @@ function tl(e, t) {
|
|
|
4437
4438
|
...e.calculation ? { "x-report-calculation": { description: e.calculation.description, dependsOn: [...e.calculation.dependsOn] } } : {}
|
|
4438
4439
|
};
|
|
4439
4440
|
}
|
|
4440
|
-
function
|
|
4441
|
+
function nl(e, t) {
|
|
4441
4442
|
const r = {};
|
|
4442
4443
|
return (e.minLength !== void 0 || t && e.type !== "number") && (r.minLength = Math.max(e.minLength ?? 0, t ? 1 : 0)), e.type === "decimal" ? r.maxLength = Math.min(e.maxLength ?? 1e4, 1e4) : e.maxLength !== void 0 && (r.maxLength = e.maxLength), r;
|
|
4443
4444
|
}
|
|
4444
4445
|
function Fn(e) {
|
|
4445
4446
|
return e === "text" || e === "date" || e === "decimal" ? "string" : e;
|
|
4446
4447
|
}
|
|
4447
|
-
function
|
|
4448
|
+
function ol(e) {
|
|
4448
4449
|
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
4449
4450
|
const t = e, r = (n) => typeof n == "string" && n.trim().length > 0 && n.length <= 256;
|
|
4450
4451
|
return !r(t.datasetId) || !r(t.field) || t.tableId !== void 0 && !r(t.tableId) || t.reportScope !== void 0 && (typeof t.reportScope != "string" || !t.reportScope.trim() || t.reportScope.length > 4096) ? !1 : t.rowKey === void 0 ? !0 : typeof t.rowKey == "string" ? t.rowKey.trim().length > 0 && t.rowKey.length <= 1024 : typeof t.rowKey == "number" && Number.isFinite(t.rowKey);
|
|
4451
4452
|
}
|
|
4452
|
-
function
|
|
4453
|
+
function il(e) {
|
|
4453
4454
|
return e === "missing-source" || e === "not-applicable" || e === "not-calculable";
|
|
4454
4455
|
}
|
|
4455
4456
|
function Yr(e) {
|
|
4456
|
-
return e.target !== void 0 && !
|
|
4457
|
+
return e.target !== void 0 && !ol(e.target) ? !1 : e.valueState === void 0 || il(e.valueState) && e.target !== void 0;
|
|
4457
4458
|
}
|
|
4458
4459
|
function pi(e, t, r = {}) {
|
|
4459
4460
|
const n = /* @__PURE__ */ new Map();
|
|
@@ -4471,11 +4472,11 @@ function pi(e, t, r = {}) {
|
|
|
4471
4472
|
}
|
|
4472
4473
|
return o;
|
|
4473
4474
|
}
|
|
4474
|
-
function
|
|
4475
|
+
function sl(e, t, r = {}) {
|
|
4475
4476
|
return Object.values(pi(e, t, r)).reduce((n, o) => n + o.length, 0);
|
|
4476
4477
|
}
|
|
4477
|
-
function
|
|
4478
|
-
const n =
|
|
4478
|
+
function al(e, t, r) {
|
|
4479
|
+
const n = tl(r), o = e?.pages.flatMap((a) => a.components).find((a) => a.kind === "list" && a.dataset === t && a.tree?.input === "nested");
|
|
4479
4480
|
if (!o || o.kind !== "list" || !o.tree) return n;
|
|
4480
4481
|
const i = n.items, s = o.tree.childrenField ?? "children";
|
|
4481
4482
|
return { ...n, items: { $ref: "#/$defs/treeNode" }, $defs: { treeNode: { ...i, properties: { ...i.properties, [s]: { anyOf: [{ type: "null" }, { type: "array", items: { $ref: "#/$defs/treeNode" } }] } } } } };
|
|
@@ -4507,12 +4508,12 @@ function wi(e, t, r) {
|
|
|
4507
4508
|
function lr(e) {
|
|
4508
4509
|
return Ot(e.maxChartComponents), { maxPages: e.maxPages, maxCells: e.maxCells, maxChartComponents: e.maxChartComponents ?? Pr, usedPages: 0, usedCells: 0, usedChartComponents: 0 };
|
|
4509
4510
|
}
|
|
4510
|
-
function
|
|
4511
|
+
function cl(e, t) {
|
|
4511
4512
|
if (!e.repeat) return !1;
|
|
4512
4513
|
const r = Object.prototype.hasOwnProperty.call(t, e.repeat.dataset) ? t[e.repeat.dataset] : void 0;
|
|
4513
4514
|
return Array.isArray(r) && r.length === 0;
|
|
4514
4515
|
}
|
|
4515
|
-
function
|
|
4516
|
+
function fl(e) {
|
|
4516
4517
|
const t = (r) => r.grid?.cells.reduce((n, o) => n + o.reduce((i, s) => i + (s ? 1 + (s.children?.reduce((a, c) => a + t(c), 0) ?? 0) : 0), 0), 0) ?? 0;
|
|
4517
4518
|
return e.pages.reduce((r, n) => r + n.components.reduce((o, i) => o + t(i), 0), 0);
|
|
4518
4519
|
}
|
|
@@ -4525,7 +4526,7 @@ function Yt(e, t) {
|
|
|
4525
4526
|
function bi(e, t, r, n, o) {
|
|
4526
4527
|
Ot(e?.maxChartComponents);
|
|
4527
4528
|
const i = dr(t.maxPages, t.usedPages), s = t.maxChartComponents - t.usedChartComponents;
|
|
4528
|
-
if (i !== void 0 && i < 1 && r.pages.length && !
|
|
4529
|
+
if (i !== void 0 && i < 1 && r.pages.length && !cl(r, n)) throw new ve(0, 1);
|
|
4529
4530
|
if (s < 1 && r.pages.some((a) => a.components.some((c) => c.kind !== "list" && c.chartBinding))) throw new Le(s, 1);
|
|
4530
4531
|
return {
|
|
4531
4532
|
...e,
|
|
@@ -4536,12 +4537,12 @@ function bi(e, t, r, n, o) {
|
|
|
4536
4537
|
};
|
|
4537
4538
|
}
|
|
4538
4539
|
function xi(e, t) {
|
|
4539
|
-
const r =
|
|
4540
|
+
const r = fl(t.plan), n = dr(e.maxCells, e.usedCells);
|
|
4540
4541
|
if (n !== void 0 && r > n) throw new De(n, r);
|
|
4541
4542
|
e.usedPages += t.plan.pages.length, e.usedCells += r, e.usedChartComponents += t.chartComponents;
|
|
4542
4543
|
}
|
|
4543
|
-
function
|
|
4544
|
-
return e instanceof
|
|
4544
|
+
function Mi(e, t) {
|
|
4545
|
+
return e instanceof ve && t.maxPages !== void 0 && (e.limit === t.maxPages - t.usedPages || e.limit === 0) ? new ve(t.maxPages, t.usedPages + e.actual) : e instanceof De && t.maxCells !== void 0 ? new De(t.maxCells, t.usedCells + e.actual) : e instanceof Le && e.limit === t.maxChartComponents - t.usedChartComponents ? new Le(t.maxChartComponents, t.usedChartComponents + e.estimated) : e;
|
|
4545
4546
|
}
|
|
4546
4547
|
class E extends Error {
|
|
4547
4548
|
constructor(t, r, n) {
|
|
@@ -4570,41 +4571,41 @@ function mr(e, t) {
|
|
|
4570
4571
|
);
|
|
4571
4572
|
}) : Promise.resolve(e);
|
|
4572
4573
|
}
|
|
4573
|
-
function
|
|
4574
|
+
function ul(e, t) {
|
|
4574
4575
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
4575
4576
|
throw new E("validate", `报表 ${t} 的数据集应为对象`);
|
|
4576
4577
|
for (const [r, n] of Object.entries(e))
|
|
4577
4578
|
if (!Array.isArray(n) || n.some((o) => !o || typeof o != "object" || Array.isArray(o)))
|
|
4578
4579
|
throw new E("validate", `报表 ${t} 的数据集 ${r} 应为对象数组`);
|
|
4579
4580
|
}
|
|
4580
|
-
async function
|
|
4581
|
+
async function ll(e, t, r) {
|
|
4581
4582
|
const { reportId: n, signal: o } = t;
|
|
4582
4583
|
try {
|
|
4583
4584
|
const i = await mr(e(t), o);
|
|
4584
4585
|
G(o);
|
|
4585
|
-
const s =
|
|
4586
|
+
const s = Xf(i);
|
|
4586
4587
|
if (!s.ok)
|
|
4587
4588
|
throw new E("validate", `报表 ${n} 模板校验失败:${s.errors.slice(0, 3).map((a) => `${a.path}: ${a.message}`).join("; ")}`);
|
|
4588
4589
|
return r.push(...s.warnings.map((a) => `${n}: ${a.path}: ${a.message}`)), i;
|
|
4589
4590
|
} catch (i) {
|
|
4590
|
-
throw o?.aborted ? Lt(o) : i instanceof E ? i : i instanceof
|
|
4591
|
+
throw o?.aborted ? Lt(o) : i instanceof E ? i : i instanceof Tf ? new E("validate", `报表 ${n} 模板校验失败:${i.message}`, i) : new E("fetch", `报表 ${n} 模板加载失败:${i instanceof Error ? i.message : String(i)}`, i);
|
|
4591
4592
|
}
|
|
4592
4593
|
}
|
|
4593
|
-
async function
|
|
4594
|
+
async function dl(e, t, r, n) {
|
|
4594
4595
|
const o = t.signal;
|
|
4595
4596
|
let i;
|
|
4596
4597
|
try {
|
|
4597
4598
|
if (e.load) i = await mr(e.load(t), o);
|
|
4598
4599
|
else if (e.provider) {
|
|
4599
4600
|
const s = await mr(e.provider.query(t), o);
|
|
4600
|
-
G(o),
|
|
4601
|
+
G(o), ml(s, r), i = s.datasets, n?.(r, s);
|
|
4601
4602
|
} else i = e.datasets ?? {};
|
|
4602
4603
|
} catch (s) {
|
|
4603
4604
|
throw o?.aborted ? Lt(o) : s instanceof E ? s : new E("fetch", `报表 ${r} 取数失败:${s instanceof Error ? s.message : String(s)}`, s);
|
|
4604
4605
|
}
|
|
4605
4606
|
return G(o), i;
|
|
4606
4607
|
}
|
|
4607
|
-
function
|
|
4608
|
+
function ml(e, t) {
|
|
4608
4609
|
if (!e || typeof e != "object" || Array.isArray(e)) throw new E("validate", `报表 ${t} Provider 应返回 datasets 结果对象`);
|
|
4609
4610
|
for (const r of ["revision", "sourceToken"])
|
|
4610
4611
|
if (e[r] !== void 0 && typeof e[r] != "string") throw new E("validate", `报表 ${t} Provider ${r} 应为字符串`);
|
|
@@ -4613,7 +4614,7 @@ function dl(e, t) {
|
|
|
4613
4614
|
if (e.diagnostics?.some((r) => !Yr(r)))
|
|
4614
4615
|
throw new E("validate", `报表 ${t} Provider 数据说明缺少有效的字段身份或值状态`);
|
|
4615
4616
|
}
|
|
4616
|
-
function
|
|
4617
|
+
function hl(e, t, r, n, o) {
|
|
4617
4618
|
try {
|
|
4618
4619
|
t = pi(n, t, { maxRows: e.dataValidation?.maxRows, signal: o });
|
|
4619
4620
|
} catch (i) {
|
|
@@ -4622,29 +4623,29 @@ function ml(e, t, r, n, o) {
|
|
|
4622
4623
|
for (const [i, s] of Object.entries(e.dataSchema ?? {})) {
|
|
4623
4624
|
let a;
|
|
4624
4625
|
try {
|
|
4625
|
-
a =
|
|
4626
|
+
a = Qu(Object.prototype.hasOwnProperty.call(t, i) ? t[i] : void 0, s, { ...e.dataValidation, path: `$.datasets.${i}` });
|
|
4626
4627
|
} catch (c) {
|
|
4627
4628
|
throw new E("config", `报表 ${r} 数据集 ${i} 字段契约配置无效`, c);
|
|
4628
4629
|
}
|
|
4629
4630
|
if (!a.ok) throw new E("validate", `报表 ${r} 数据集 ${i} 不符合字段契约:${a.issues[0]?.message}`, { issues: a.issues });
|
|
4630
4631
|
}
|
|
4631
4632
|
}
|
|
4632
|
-
async function
|
|
4633
|
+
async function gl(e, t, r, n, o) {
|
|
4633
4634
|
try {
|
|
4634
4635
|
let i;
|
|
4635
4636
|
try {
|
|
4636
|
-
i =
|
|
4637
|
+
i = Ou(e);
|
|
4637
4638
|
} catch {
|
|
4638
4639
|
}
|
|
4639
|
-
const s = i ?? e, a = bi(t.pagination, n, s.template, s.datasets, o), c = i ? await Do(s.template, s.datasets, a) :
|
|
4640
|
+
const s = i ?? e, a = bi(t.pagination, n, s.template, s.datasets, o), c = i ? await Do(s.template, s.datasets, a) : Ic(s.template, s.datasets, a);
|
|
4640
4641
|
return xi(n, c), { result: c, part: s };
|
|
4641
4642
|
} catch (i) {
|
|
4642
4643
|
G(o);
|
|
4643
|
-
const s =
|
|
4644
|
+
const s = Mi(i, n);
|
|
4644
4645
|
throw new E("validate", `报表 ${r} 排版失败:${s instanceof Error ? s.message : String(s)}`, s);
|
|
4645
4646
|
}
|
|
4646
4647
|
}
|
|
4647
|
-
function
|
|
4648
|
+
function vi(e, t, r, n, o) {
|
|
4648
4649
|
const i = /* @__PURE__ */ new Map(), s = (a) => {
|
|
4649
4650
|
let c = i.get(a);
|
|
4650
4651
|
return c === void 0 && (c = JSON.stringify([r, n, a]), i.set(a, c)), c;
|
|
@@ -4655,22 +4656,22 @@ function Mi(e, t, r, n, o) {
|
|
|
4655
4656
|
components: wi(a.components, o ?? yi(r, n), s)
|
|
4656
4657
|
});
|
|
4657
4658
|
}
|
|
4658
|
-
async function
|
|
4659
|
+
async function pl(e, t, r, n, o) {
|
|
4659
4660
|
const i = [], s = lr(n);
|
|
4660
4661
|
for (const [f, u] of e.entries()) {
|
|
4661
4662
|
G(o);
|
|
4662
4663
|
try {
|
|
4663
|
-
const d = await
|
|
4664
|
-
xi(s, d),
|
|
4664
|
+
const d = await Iu(u.template, u.datasets, bi(t[f]?.pagination, s, u.template, u.datasets, o));
|
|
4665
|
+
xi(s, d), vi(i, d.plan, f, r[f], u.sourceScope);
|
|
4665
4666
|
} catch (d) {
|
|
4666
|
-
throw
|
|
4667
|
+
throw Mi(d, s);
|
|
4667
4668
|
}
|
|
4668
4669
|
}
|
|
4669
4670
|
const a = { schemaVersion: Ke, ...e.some((f) => Tr(f.template)) ? { requiresRecalculation: !0 } : {}, pages: i }, c = Je(a);
|
|
4670
4671
|
if (!c.ok) throw new E("validate", `重算渲染计划校验失败:${c.errors[0]?.message}`);
|
|
4671
4672
|
return a;
|
|
4672
4673
|
}
|
|
4673
|
-
function
|
|
4674
|
+
function yl(e, t = {}) {
|
|
4674
4675
|
if (t.maxPages !== void 0 && (!Number.isSafeInteger(t.maxPages) || t.maxPages < 1)) throw new E("config", "maxPages 应为正安全整数");
|
|
4675
4676
|
if (t.maxCells !== void 0 && (!Number.isSafeInteger(t.maxCells) || t.maxCells < 1)) throw new E("config", "maxCells 应为正安全整数");
|
|
4676
4677
|
try {
|
|
@@ -4688,37 +4689,37 @@ function pl(e, t = {}) {
|
|
|
4688
4689
|
G(s);
|
|
4689
4690
|
const u = me({ ...f, signal: s }), d = [...o], l = { ...i };
|
|
4690
4691
|
if (d.length === 0) throw new E("config", "缺少报表 ID");
|
|
4691
|
-
const m = d.map(r), h = u.runSync("validate", () => m.map((
|
|
4692
|
-
|
|
4692
|
+
const m = d.map(r), h = u.runSync("validate", () => m.map((M) => $n(
|
|
4693
|
+
M.params ?? (typeof M.template == "function" ? [] : M.template.params) ?? [],
|
|
4693
4694
|
l
|
|
4694
4695
|
))), g = [], y = [], w = lr(t), p = [];
|
|
4695
|
-
for (const [
|
|
4696
|
+
for (const [M, v] of m.entries()) {
|
|
4696
4697
|
G(s);
|
|
4697
|
-
const S = d[
|
|
4698
|
-
I.params = u.runSync("validate", () => $n(
|
|
4699
|
-
const R = await u.run("query", () =>
|
|
4698
|
+
const S = d[M], I = { reportId: S, params: h[M], signal: s }, N = typeof v.template == "function" ? await u.run("query", () => ll(v.template, I, p), S) : v.template;
|
|
4699
|
+
I.params = u.runSync("validate", () => $n(v.params ?? N.params ?? [], I.params), S);
|
|
4700
|
+
const R = await u.run("query", () => dl(v, I, S, (Kt, qi) => c?.(Kt, qi, M)), S);
|
|
4700
4701
|
u.runSync("validate", () => {
|
|
4701
|
-
|
|
4702
|
+
ul(R, S), t.onDatasets?.(S, R, N), hl(v, R, S, N, s);
|
|
4702
4703
|
}, S), G(s);
|
|
4703
|
-
const ge = yi(
|
|
4704
|
-
y.push(Yi),
|
|
4704
|
+
const ge = yi(M, S, v.sourceScope), { result: en, part: Yi } = await u.run("layout", () => gl({ template: N, datasets: R, sourceScope: ge }, v, S, w, s), S);
|
|
4705
|
+
y.push(Yi), vi(g, en.plan, M, S, ge), p.push(...en.warnings.map((Kt) => `${S}: ${Kt}`));
|
|
4705
4706
|
}
|
|
4706
4707
|
G(s);
|
|
4707
|
-
const b = { schemaVersion: Ke, ...y.some((
|
|
4708
|
-
const
|
|
4709
|
-
if (!
|
|
4710
|
-
return
|
|
4708
|
+
const b = { schemaVersion: Ke, ...y.some((M) => Tr(M.template)) ? { requiresRecalculation: !0 } : {}, pages: g }, x = u.runSync("validate", () => {
|
|
4709
|
+
const M = Je(b);
|
|
4710
|
+
if (!M.ok) throw new E("validate", `渲染计划校验失败:${M.errors.slice(0, 3).map((v) => `${v.path}: ${v.message}`).join("; ")}`);
|
|
4711
|
+
return M;
|
|
4711
4712
|
});
|
|
4712
|
-
p.push(...x.warnings.map((
|
|
4713
|
-
const $ = m.map((
|
|
4713
|
+
p.push(...x.warnings.map((M) => `${M.path}: ${M.message}`));
|
|
4714
|
+
const $ = m.map((M) => ({ ...M, pagination: { ...M.pagination } })), j = { maxPages: t.maxPages, maxCells: t.maxCells, maxChartComponents: t.maxChartComponents };
|
|
4714
4715
|
try {
|
|
4715
|
-
|
|
4716
|
+
Lu(b, { parts: y, validationFormulas: $.map((M) => M.pagination?.formula), rebuild: (M, v) => pl(M, $, d, j, v) });
|
|
4716
4717
|
} catch {
|
|
4717
4718
|
p.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算");
|
|
4718
4719
|
}
|
|
4719
|
-
const D = a ?? t.onWarning ?? ((
|
|
4720
|
-
for (const
|
|
4721
|
-
G(s), D(
|
|
4720
|
+
const D = a ?? t.onWarning ?? ((M) => console.warn("[mach-report]", M));
|
|
4721
|
+
for (const M of p)
|
|
4722
|
+
G(s), D(M);
|
|
4722
4723
|
return G(s), b;
|
|
4723
4724
|
}, {
|
|
4724
4725
|
getParamDefs: (o) => bt(e, o)
|
|
@@ -4774,7 +4775,7 @@ async function Fe(e, t, r) {
|
|
|
4774
4775
|
function Si(e, t) {
|
|
4775
4776
|
nt(t.signal), Jn(() => t.onDiagnostic?.(e)), nt(t.signal);
|
|
4776
4777
|
}
|
|
4777
|
-
class
|
|
4778
|
+
class wl extends Error {
|
|
4778
4779
|
constructor(t) {
|
|
4779
4780
|
super(`Output contains ${t.length} known fidelity issue(s): ${t[0]?.code}`), this.diagnostics = t, this.code = "output-fidelity", this.name = "OutputFidelityError";
|
|
4780
4781
|
}
|
|
@@ -4791,7 +4792,7 @@ function te(e) {
|
|
|
4791
4792
|
function Oe(e) {
|
|
4792
4793
|
throw new Bt("image-budget-exceeded", e);
|
|
4793
4794
|
}
|
|
4794
|
-
function
|
|
4795
|
+
function bl(e) {
|
|
4795
4796
|
const t = { ...qt };
|
|
4796
4797
|
for (const r of Object.keys(qt)) {
|
|
4797
4798
|
const n = e[r] ?? qt[r];
|
|
@@ -4800,12 +4801,12 @@ function wl(e) {
|
|
|
4800
4801
|
}
|
|
4801
4802
|
return t;
|
|
4802
4803
|
}
|
|
4803
|
-
function
|
|
4804
|
+
function xl(e) {
|
|
4804
4805
|
if (e.length < 33 || ![137, 80, 78, 71, 13, 10, 26, 10].every((r, n) => e[n] === r)) return te("图片内容与 PNG/JPEG 类型不一致。");
|
|
4805
4806
|
const t = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
4806
4807
|
return t.getUint32(8) !== 13 || String.fromCharCode(...e.subarray(12, 16)) !== "IHDR" ? te("PNG must begin with an IHDR header.") : [t.getUint32(16), t.getUint32(20)];
|
|
4807
4808
|
}
|
|
4808
|
-
const
|
|
4809
|
+
const Ml = /* @__PURE__ */ new Set([192, 193, 194, 195, 197, 198, 199, 201, 202, 203, 205, 206, 207]);
|
|
4809
4810
|
function vl(e) {
|
|
4810
4811
|
if (e[0] !== 255 || e[1] !== 216) return te("图片内容与 PNG/JPEG 类型不一致。");
|
|
4811
4812
|
let t = 2;
|
|
@@ -4817,13 +4818,13 @@ function vl(e) {
|
|
|
4817
4818
|
if (r === 1 || r >= 208 && r <= 215) continue;
|
|
4818
4819
|
const n = e[t] * 256 + e[t + 1];
|
|
4819
4820
|
if (n < 2 || t + n > e.length) return te("JPEG segment exceeds its data boundary.");
|
|
4820
|
-
if (
|
|
4821
|
+
if (Ml.has(r))
|
|
4821
4822
|
return n < 8 ? te("JPEG frame header is incomplete.") : [e[t + 5] * 256 + e[t + 6], e[t + 3] * 256 + e[t + 4]];
|
|
4822
4823
|
t += n;
|
|
4823
4824
|
}
|
|
4824
4825
|
return te("JPEG has no supported dimension header.");
|
|
4825
4826
|
}
|
|
4826
|
-
function
|
|
4827
|
+
function $l(e, t) {
|
|
4827
4828
|
if (e.length > Math.ceil(t.maxImageBytes / 3) * 4 + 64) return Oe("单张图片超过字节预算。");
|
|
4828
4829
|
const r = /^data:image\/(png|jpe?g);base64,([A-Za-z0-9+/]+={0,2})$/i.exec(e);
|
|
4829
4830
|
if (!r || r[2].length % 4) return te("Image must contain valid PNG/JPEG base64 data.");
|
|
@@ -4831,17 +4832,17 @@ function Ml(e, t) {
|
|
|
4831
4832
|
if (o > t.maxImageBytes) return Oe("单张图片超过字节预算。");
|
|
4832
4833
|
const i = r[1].toLowerCase() === "png" ? "png" : "jpeg", s = atob(n), a = new Uint8Array(o);
|
|
4833
4834
|
for (let u = 0; u < o; u++) a[u] = s.charCodeAt(u);
|
|
4834
|
-
const [c, f] = i === "png" ?
|
|
4835
|
+
const [c, f] = i === "png" ? xl(a) : vl(a);
|
|
4835
4836
|
return !c || !f ? te("Image dimensions must be positive.") : c > t.maxImageDimension || f > t.maxImageDimension || c * f > t.maxImagePixels ? Oe("Image exceeds its decoded dimension or pixel budget.") : { dataUrl: `data:image/${i};base64,${n}`, bytes: a, extension: i, width: c, height: f };
|
|
4836
4837
|
}
|
|
4837
|
-
function
|
|
4838
|
-
const t =
|
|
4838
|
+
function Sl(e = {}) {
|
|
4839
|
+
const t = bl(e), r = /* @__PURE__ */ new Map();
|
|
4839
4840
|
let n = 0, o = 0;
|
|
4840
4841
|
return (i) => {
|
|
4841
4842
|
const s = i.replace(/^data:image\/(png|jpe?g);base64,/i, (f, u) => `data:image/${u.toLowerCase() === "png" ? "png" : "jpeg"};base64,`), a = r.get(s);
|
|
4842
4843
|
if (a) return a;
|
|
4843
4844
|
if (r.size >= t.maxImages) return Oe("唯一图片数量超过预算。");
|
|
4844
|
-
const c =
|
|
4845
|
+
const c = $l(i, t);
|
|
4845
4846
|
return n + c.bytes.length > t.maxTotalImageBytes || o + c.width * c.height > t.maxTotalImagePixels ? Oe("图片总字节或总像素超过预算。") : (n += c.bytes.length, o += c.width * c.height, r.set(s, c), c);
|
|
4846
4847
|
};
|
|
4847
4848
|
}
|
|
@@ -4853,13 +4854,13 @@ class Zr extends Error {
|
|
|
4853
4854
|
function $t(e) {
|
|
4854
4855
|
if (e.aborted) throw e.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
4855
4856
|
}
|
|
4856
|
-
function
|
|
4857
|
+
function El(e) {
|
|
4857
4858
|
const t = { maxAssets: 1e3, maxImageBytes: 33554432, maxTotalImageBytes: 134217728, maxDurationMs: 3e4, ...e.assetBudget };
|
|
4858
4859
|
for (const [r, n] of Object.entries(t))
|
|
4859
4860
|
if (!Number.isSafeInteger(n) || n <= 0 || n > 2147483647) throw new RangeError(`${r} must be a positive safe integer at most 2147483647.`);
|
|
4860
4861
|
return t;
|
|
4861
4862
|
}
|
|
4862
|
-
function
|
|
4863
|
+
function Al(e) {
|
|
4863
4864
|
const t = /^data:image\/[a-z0-9.+-]+(;base64)?,(.*)$/is.exec(e);
|
|
4864
4865
|
if (!t) throw new TypeError("Asset renderers must return an image data URL.");
|
|
4865
4866
|
return t[1] ? Math.ceil(t[2].length * 3 / 4) : new TextEncoder().encode(decodeURIComponent(t[2])).byteLength;
|
|
@@ -4868,14 +4869,14 @@ function Ue(e, t, r, n, o) {
|
|
|
4868
4869
|
const i = { code: r, message: n, severity: "warning", format: e.options.format ?? "dom", pageIndex: t.pageIndex, componentIndex: t.componentIndex, componentPath: t.componentPath, kind: t.component.kind, nid: t.component.nid };
|
|
4869
4870
|
if (e.diagnostics.push(i), Si(i, { ...e.options, signal: e.signal }), e.options.assetFailure !== "placeholder") throw new Zr(i, o);
|
|
4870
4871
|
}
|
|
4871
|
-
async function
|
|
4872
|
+
async function kl(e, t, r) {
|
|
4872
4873
|
const n = e.options.assetRegistry?.rendererFor(t) ?? e.options.assetRenderers?.[t.kind];
|
|
4873
4874
|
if (t.imageData || !n) return t.imageData;
|
|
4874
4875
|
if (++e.rendered > e.budget.maxAssets) return Ue(e, r, "asset-budget-exceeded", "Output exceeded the asset count budget.");
|
|
4875
4876
|
let o;
|
|
4876
4877
|
try {
|
|
4877
4878
|
if (e.active = r, o = await Xi(n({ ...r, signal: e.signal }), e.signal), $t(e.signal), o.length > e.budget.maxImageBytes * 4 + 1024) return Ue(e, r, "asset-budget-exceeded", "Output exceeded the image payload byte budget.");
|
|
4878
|
-
const i =
|
|
4879
|
+
const i = Al(o);
|
|
4879
4880
|
if (i > e.budget.maxImageBytes || e.bytes + i > e.budget.maxTotalImageBytes) return Ue(e, r, "asset-budget-exceeded", "Output exceeded the encoded image byte budget.");
|
|
4880
4881
|
/^data:image\/(png|jpe?g);base64,/i.test(o) && e.inspectImage(o), e.bytes += i;
|
|
4881
4882
|
} catch (i) {
|
|
@@ -4884,7 +4885,7 @@ async function Al(e, t, r) {
|
|
|
4884
4885
|
}
|
|
4885
4886
|
return o;
|
|
4886
4887
|
}
|
|
4887
|
-
function
|
|
4888
|
+
function Nl(e, t) {
|
|
4888
4889
|
const r = e.active;
|
|
4889
4890
|
if (!r) {
|
|
4890
4891
|
t.abort(new Error("Asset rendering exceeded maxDurationMs."));
|
|
@@ -4900,7 +4901,7 @@ function kl(e, t) {
|
|
|
4900
4901
|
}
|
|
4901
4902
|
t.abort(new Zr(n));
|
|
4902
4903
|
}
|
|
4903
|
-
async function
|
|
4904
|
+
async function Pl(e, t, r, n, o) {
|
|
4904
4905
|
if (!t?.children?.length) return t;
|
|
4905
4906
|
const i = [];
|
|
4906
4907
|
for (const [s, a] of t.children.entries())
|
|
@@ -4910,7 +4911,7 @@ async function Nl(e, t, r, n, o) {
|
|
|
4910
4911
|
async function Ei(e, t, r, n) {
|
|
4911
4912
|
if ($t(e.signal), n.has(t)) throw new TypeError("Cyclic grid children cannot be rendered.");
|
|
4912
4913
|
let o = e.cache.get(t);
|
|
4913
|
-
o || (o =
|
|
4914
|
+
o || (o = kl(e, t, r), e.cache.set(t, o));
|
|
4914
4915
|
const i = await o;
|
|
4915
4916
|
$t(e.signal);
|
|
4916
4917
|
let s = t.grid;
|
|
@@ -4922,14 +4923,14 @@ async function Ei(e, t, r, n) {
|
|
|
4922
4923
|
continue;
|
|
4923
4924
|
}
|
|
4924
4925
|
const d = [];
|
|
4925
|
-
for (const [l, m] of u.entries()) d.push(m?.children?.length ? await
|
|
4926
|
+
for (const [l, m] of u.entries()) d.push(m?.children?.length ? await Pl(e, m, r, [...r.componentPath, f, l], a) : m);
|
|
4926
4927
|
c.push(d.some((l, m) => l !== u[m]) ? d : u);
|
|
4927
4928
|
}
|
|
4928
4929
|
c.some((f, u) => f !== s.cells[u]) && (s = { ...s, cells: c });
|
|
4929
4930
|
}
|
|
4930
4931
|
return i !== t.imageData || s !== t.grid ? { ...t, imageData: i, grid: s } : t;
|
|
4931
4932
|
}
|
|
4932
|
-
function
|
|
4933
|
+
function Fl(e, t, r) {
|
|
4933
4934
|
const n = /* @__PURE__ */ new Set(), o = (i) => {
|
|
4934
4935
|
if (nt(r), !n.has(i)) {
|
|
4935
4936
|
if (n.add(i), i.imageData && /^data:image\/(png|jpe?g);base64,/i.test(i.imageData))
|
|
@@ -4943,17 +4944,17 @@ function Pl(e, t, r) {
|
|
|
4943
4944
|
};
|
|
4944
4945
|
for (const i of e.pages) for (const s of i.components) o(s);
|
|
4945
4946
|
}
|
|
4946
|
-
function
|
|
4947
|
-
if (e.options.fidelity === "strict" && e.diagnostics.length) throw new
|
|
4947
|
+
function Ol(e) {
|
|
4948
|
+
if (e.options.fidelity === "strict" && e.diagnostics.length) throw new wl(e.diagnostics);
|
|
4948
4949
|
}
|
|
4949
4950
|
async function On(e, t = {}) {
|
|
4950
|
-
nt(t.signal),
|
|
4951
|
-
const r =
|
|
4952
|
-
if (
|
|
4951
|
+
nt(t.signal), Lc(e);
|
|
4952
|
+
const r = El(t), n = Sl(t);
|
|
4953
|
+
if (Fl(e, n, t.signal), t.signal?.aborted) throw t.signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
4953
4954
|
const o = new AbortController(), i = () => o.abort(t.signal?.reason);
|
|
4954
4955
|
if (t.signal?.addEventListener("abort", i, { once: !0 }), !t.assetRegistry && (!t.assetRenderers || !Object.keys(t.assetRenderers).length))
|
|
4955
4956
|
return t.signal?.removeEventListener("abort", i), { plan: e, diagnostics: [] };
|
|
4956
|
-
const s = { options: t, signal: o.signal, diagnostics: [], rendered: 0, bytes: 0, budget: r, cache: /* @__PURE__ */ new WeakMap(), inspectImage: n }, a = setTimeout(() =>
|
|
4957
|
+
const s = { options: t, signal: o.signal, diagnostics: [], rendered: 0, bytes: 0, budget: r, cache: /* @__PURE__ */ new WeakMap(), inspectImage: n }, a = setTimeout(() => Nl(s, o), r.maxDurationMs);
|
|
4957
4958
|
try {
|
|
4958
4959
|
const c = [];
|
|
4959
4960
|
for (const [f, u] of e.pages.entries()) {
|
|
@@ -4965,25 +4966,25 @@ async function On(e, t = {}) {
|
|
|
4965
4966
|
for (const [l, m] of u.components.entries()) d.push(await Ei(s, m, { component: m, pageIndex: f, componentIndex: l, componentPath: [] }, /* @__PURE__ */ new Set()));
|
|
4966
4967
|
c.push(d.some((l, m) => l !== u.components[m]) ? { ...u, components: d } : u);
|
|
4967
4968
|
}
|
|
4968
|
-
return $t(s.signal),
|
|
4969
|
+
return $t(s.signal), Ol(s), { plan: c.some((f, u) => f !== e.pages[u]) ? { ...e, pages: c } : e, diagnostics: s.diagnostics };
|
|
4969
4970
|
} finally {
|
|
4970
4971
|
clearTimeout(a), t.signal?.removeEventListener("abort", i);
|
|
4971
4972
|
}
|
|
4972
4973
|
}
|
|
4973
|
-
const
|
|
4974
|
-
function
|
|
4974
|
+
const Rl = /* @__PURE__ */ new Set([8, 9, 10, 12, 13]);
|
|
4975
|
+
function Il(e, t) {
|
|
4975
4976
|
const r = Array.isArray(e), n = Object.getPrototypeOf(e);
|
|
4976
4977
|
if (n !== (r ? Array.prototype : Object.prototype) && !(n === null && !r) || Object.getOwnPropertySymbols(e).length) throw t("input", "快照应为普通 JSON 对象");
|
|
4977
4978
|
const o = Object.getOwnPropertyNames(e).filter((i) => !(r && i === "length"));
|
|
4978
4979
|
if (r && (o.length !== e.length || o.some((i, s) => i !== String(s)))) throw t("input", "快照数组应为连续数组");
|
|
4979
4980
|
return { array: r, keys: o };
|
|
4980
4981
|
}
|
|
4981
|
-
function
|
|
4982
|
+
function Cl(e) {
|
|
4982
4983
|
if (/^[\u0020-\u007e]*$/.test(e) && !/["\\]/.test(e)) return e.length + 2;
|
|
4983
4984
|
let t = 2;
|
|
4984
4985
|
for (let r = 0; r < e.length; r++) {
|
|
4985
4986
|
const n = e.charCodeAt(r);
|
|
4986
|
-
if (n < 32) t +=
|
|
4987
|
+
if (n < 32) t += Rl.has(n) ? 2 : 6;
|
|
4987
4988
|
else if (n === 34 || n === 92) t += 2;
|
|
4988
4989
|
else if (n < 128) t++;
|
|
4989
4990
|
else if (n < 2048) t += 2;
|
|
@@ -5003,7 +5004,7 @@ function Ai(e, t) {
|
|
|
5003
5004
|
if (l.length + 2 > t.maxBytes - o) throw t.error("budget", "快照超过字节预算");
|
|
5004
5005
|
const m = s.get(l);
|
|
5005
5006
|
if (m !== void 0) return m;
|
|
5006
|
-
const h =
|
|
5007
|
+
const h = Cl(l);
|
|
5007
5008
|
return l.length <= 256 && s.size < 4096 && s.set(l, h), h;
|
|
5008
5009
|
}
|
|
5009
5010
|
function c(l) {
|
|
@@ -5019,7 +5020,7 @@ function Ai(e, t) {
|
|
|
5019
5020
|
return u(l, m);
|
|
5020
5021
|
}
|
|
5021
5022
|
function u(l, m) {
|
|
5022
|
-
const { array: h, keys: g } =
|
|
5023
|
+
const { array: h, keys: g } = Il(l, t.error);
|
|
5023
5024
|
i.add(l), c(2);
|
|
5024
5025
|
const y = h ? [] : {};
|
|
5025
5026
|
let w = 0;
|
|
@@ -5037,7 +5038,7 @@ function Ai(e, t) {
|
|
|
5037
5038
|
const d = f(e, 0);
|
|
5038
5039
|
return t.check?.(), d;
|
|
5039
5040
|
}
|
|
5040
|
-
const
|
|
5041
|
+
const Tl = new Uint32Array([
|
|
5041
5042
|
1116352408,
|
|
5042
5043
|
1899447441,
|
|
5043
5044
|
3049323471,
|
|
@@ -5114,7 +5115,7 @@ function ki(e, t, r) {
|
|
|
5114
5115
|
function Ni(e, t) {
|
|
5115
5116
|
let r = e[0], n = e[1], o = e[2], i = e[3], s = e[4], a = e[5], c = e[6], f = e[7];
|
|
5116
5117
|
for (let u = 0; u < 64; u++) {
|
|
5117
|
-
const d = Q(s, 6) ^ Q(s, 11) ^ Q(s, 25), l = s & a ^ ~s & c, m = f + d + l +
|
|
5118
|
+
const d = Q(s, 6) ^ Q(s, 11) ^ Q(s, 25), l = s & a ^ ~s & c, m = f + d + l + Tl[u] + t[u] >>> 0, h = Q(r, 2) ^ Q(r, 13) ^ Q(r, 22), g = r & n ^ r & o ^ n & o, y = h + g >>> 0;
|
|
5118
5119
|
f = c, c = a, a = s, s = i + m >>> 0, i = o, o = n, n = r, r = m + y >>> 0;
|
|
5119
5120
|
}
|
|
5120
5121
|
e[0] = e[0] + r, e[1] = e[1] + n, e[2] = e[2] + o, e[3] = e[3] + i, e[4] = e[4] + s, e[5] = e[5] + a, e[6] = e[6] + c, e[7] = e[7] + f;
|
|
@@ -5132,7 +5133,7 @@ function Rn(e) {
|
|
|
5132
5133
|
ki(t, o, n), Ni(r, n);
|
|
5133
5134
|
return Oi(r);
|
|
5134
5135
|
}
|
|
5135
|
-
async function
|
|
5136
|
+
async function jl(e) {
|
|
5136
5137
|
const t = Pi(e), r = Fi(), n = new Uint32Array(64);
|
|
5137
5138
|
for (let o = 0; o < t.length; o += 64)
|
|
5138
5139
|
o > 0 && o % 262144 === 0 && await new Promise((i) => setTimeout(i, 0)), ki(t, o, n), Ni(r, n);
|
|
@@ -5142,13 +5143,13 @@ function Ri(e) {
|
|
|
5142
5143
|
if (typeof e != "string" || !e.trim() || e.length > 31 || /[\\/*?:[\]]/.test(e) || /^'|'$/.test(e)) throw new TypeError("工作表名称无效");
|
|
5143
5144
|
return e;
|
|
5144
5145
|
}
|
|
5145
|
-
function
|
|
5146
|
+
function Dl(e) {
|
|
5146
5147
|
if (e !== void 0) {
|
|
5147
5148
|
if (!Array.isArray(e) || e.length > 1e4) throw new RangeError("工作表名称列表最多 10000 项");
|
|
5148
5149
|
return Array.from(e, Ri);
|
|
5149
5150
|
}
|
|
5150
5151
|
}
|
|
5151
|
-
function
|
|
5152
|
+
function Ll(e) {
|
|
5152
5153
|
if (!Array.isArray(e) || e.length > 16384) throw new TypeError("附加工作表行应为最多 16384 列的标量数组");
|
|
5153
5154
|
return Array.from(e, (t) => {
|
|
5154
5155
|
if (t === null || typeof t == "boolean" || typeof t == "number" && Number.isFinite(t) || typeof t == "string" && t.length <= 32767 && t.split(`
|
|
@@ -5156,7 +5157,7 @@ function Dl(e) {
|
|
|
5156
5157
|
throw new TypeError("附加工作表仅接受 Excel 范围内的文本、有限数值、布尔或空值");
|
|
5157
5158
|
});
|
|
5158
5159
|
}
|
|
5159
|
-
function
|
|
5160
|
+
function Bl(e) {
|
|
5160
5161
|
if (e === void 0) return;
|
|
5161
5162
|
if (!Array.isArray(e) || e.length > 100) throw new RangeError("附加工作表最多 100 张");
|
|
5162
5163
|
let t = 0, r = 0, n = 0;
|
|
@@ -5168,7 +5169,7 @@ function Ll(e) {
|
|
|
5168
5169
|
if (o.add(a), !Array.isArray(i.rows) || i.rows.length > 1e5) throw new RangeError("附加工作表最多 100000 行");
|
|
5169
5170
|
if (n += i.rows.length, n > 1e5) throw new RangeError("附加工作表总行数超过 100000");
|
|
5170
5171
|
const c = Array.from(i.rows, (u) => {
|
|
5171
|
-
const d =
|
|
5172
|
+
const d = Ll(u);
|
|
5172
5173
|
if (t += d.length, t > 1e5) throw new RangeError("附加工作表总单元格超过 100000");
|
|
5173
5174
|
for (const l of d) typeof l == "string" && (r += l.length);
|
|
5174
5175
|
if (r > 4e6) throw new RangeError("附加工作表文本超过 4000000 字符");
|
|
@@ -5179,7 +5180,7 @@ function Ll(e) {
|
|
|
5179
5180
|
});
|
|
5180
5181
|
}
|
|
5181
5182
|
function hr(e) {
|
|
5182
|
-
return e && { ...e, sheetNames:
|
|
5183
|
+
return e && { ...e, sheetNames: Dl(e.sheetNames), additionalSheets: Bl(e.additionalSheets) };
|
|
5183
5184
|
}
|
|
5184
5185
|
function Qr(e, t) {
|
|
5185
5186
|
if (e.format !== "xlsx") return;
|
|
@@ -5212,7 +5213,7 @@ function Ii(e) {
|
|
|
5212
5213
|
return Rn(new TextEncoder().encode(JSON.stringify(r)));
|
|
5213
5214
|
}
|
|
5214
5215
|
const gr = /* @__PURE__ */ new WeakMap();
|
|
5215
|
-
function
|
|
5216
|
+
function _l(e, t, r) {
|
|
5216
5217
|
const n = Ci(e, t, r);
|
|
5217
5218
|
let o = !0;
|
|
5218
5219
|
return { prepared: n, forward() {
|
|
@@ -5245,7 +5246,7 @@ function ji(e) {
|
|
|
5245
5246
|
if (!e.revisions || typeof e.revisions != "object" || Array.isArray(e.revisions) || Object.values(e.revisions).some((t) => !t || typeof t != "object" || t.revision !== void 0 && typeof t.revision != "string" || t.sourceToken !== void 0 && typeof t.sourceToken != "string")) throw new E("validate", "准备结果修订无效");
|
|
5246
5247
|
if (e.layout && (!["heuristic", "provided", "font-bytes"].includes(e.layout.textMetrics) || e.layout.fontFingerprint !== void 0 && !/^[a-f0-9]{64}$/.test(e.layout.fontFingerprint))) throw new E("validate", "准备结果字体度量标识无效");
|
|
5247
5248
|
}
|
|
5248
|
-
function
|
|
5249
|
+
function Kl(e) {
|
|
5249
5250
|
if (e.layoutPolicy !== void 0 && !["verify", "preserve"].includes(e.layoutPolicy)) throw new E("validate", "无效的 layoutPolicy");
|
|
5250
5251
|
if (e.format !== "pdf") return;
|
|
5251
5252
|
if (e.layoutPolicy === "preserve" && !e.prepared.layout?.fontFingerprint) {
|
|
@@ -5297,17 +5298,17 @@ function Di(e, t) {
|
|
|
5297
5298
|
function _t(e) {
|
|
5298
5299
|
return e.grid?.cells.reduce((t, r) => t + r.reduce((n, o) => n + (o ? 1 + (o.children?.reduce((i, s) => i + _t(s), 0) ?? 0) : 0), 0), 0) ?? 0;
|
|
5299
5300
|
}
|
|
5300
|
-
function
|
|
5301
|
-
return e.pages.reduce((n, o) => n + o.components.reduce((i, s) => s.kind !== "list" ? i + _t(s) : i +
|
|
5301
|
+
function Wl(e, t, r) {
|
|
5302
|
+
return e.pages.reduce((n, o) => n + o.components.reduce((i, s) => s.kind !== "list" ? i + _t(s) : i + jc(s, t, r), 0), 0);
|
|
5302
5303
|
}
|
|
5303
|
-
function
|
|
5304
|
+
function zl(e, t = Object.keys(e)) {
|
|
5304
5305
|
return Di(e, t).map((r, n) => {
|
|
5305
5306
|
const o = t[n], i = bt(e, [o]);
|
|
5306
5307
|
return {
|
|
5307
5308
|
id: o,
|
|
5308
5309
|
params: JSON.parse(JSON.stringify(i)),
|
|
5309
|
-
paramsSchema:
|
|
5310
|
-
datasetsSchema: Object.fromEntries(Object.entries(r.dataSchema ?? {}).map(([s, a]) => [s,
|
|
5310
|
+
paramsSchema: Ef(i),
|
|
5311
|
+
datasetsSchema: Object.fromEntries(Object.entries(r.dataSchema ?? {}).map(([s, a]) => [s, al(typeof r.template == "function" ? void 0 : r.template, s, a)])),
|
|
5311
5312
|
capabilities: {
|
|
5312
5313
|
save: !!r.provider?.save,
|
|
5313
5314
|
export: !!r.provider?.export,
|
|
@@ -5345,22 +5346,22 @@ function Bi(e) {
|
|
|
5345
5346
|
maxRows: Math.min(t.maxRows ?? 1e5, $.dataValidation?.maxRows ?? 1 / 0),
|
|
5346
5347
|
maxCells: Math.min(t.maxCells ?? 2e6, $.dataValidation?.maxCells ?? 1 / 0)
|
|
5347
5348
|
}
|
|
5348
|
-
}])), h = await
|
|
5349
|
+
}])), h = await yl(l, { maxPages: t.maxPages, maxCells: t.maxCells, maxChartComponents: t.maxChartComponents, onDatasets: (x, $, j) => {
|
|
5349
5350
|
try {
|
|
5350
|
-
a +=
|
|
5351
|
+
a += sl(j, $, { maxRows: t.maxRows, signal: o.signal });
|
|
5351
5352
|
} catch (D) {
|
|
5352
5353
|
throw D instanceof ao ? new B("budget", D.message, "$.budget.maxRows") : D;
|
|
5353
5354
|
}
|
|
5354
|
-
T(t, "maxRows", a), c +=
|
|
5355
|
+
T(t, "maxRows", a), c += Wl(j, $, l[x]?.pagination), T(t, "maxCells", c);
|
|
5355
5356
|
} })({ ...o, params: o.params ?? {}, onWarning: (x) => f.push({ code: "layout", message: x, severity: "warning" }), onQueryResult: (x, $, j = 0) => {
|
|
5356
5357
|
const D = qr(j, x);
|
|
5357
|
-
Object.defineProperty(u, x, { value: { revision: $.revision, sourceToken: $.sourceToken }, enumerable: !0, writable: !0 }), d.push({ reportId: x, reportIndex: j, reportScope: D, ...$.revision === void 0 ? {} : { revision: $.revision }, ...$.sourceToken === void 0 ? {} : { sourceToken: $.sourceToken } }), f.push(...($.diagnostics ?? []).map((
|
|
5358
|
-
...
|
|
5358
|
+
Object.defineProperty(u, x, { value: { revision: $.revision, sourceToken: $.sourceToken }, enumerable: !0, writable: !0 }), d.push({ reportId: x, reportIndex: j, reportScope: D, ...$.revision === void 0 ? {} : { revision: $.revision }, ...$.sourceToken === void 0 ? {} : { sourceToken: $.sourceToken } }), f.push(...($.diagnostics ?? []).map((M) => ({ ...M, ...M.target ? { target: {
|
|
5359
|
+
...M.target,
|
|
5359
5360
|
reportScope: D,
|
|
5360
|
-
...
|
|
5361
|
+
...M.target.tableId ? { tableId: JSON.stringify([j, x, M.target.tableId]) } : {}
|
|
5361
5362
|
} } : {} })));
|
|
5362
5363
|
} }).catch((x) => {
|
|
5363
|
-
throw x instanceof E && x.cause instanceof
|
|
5364
|
+
throw x instanceof E && x.cause instanceof ve ? new B("budget", x.cause.message, "$.budget.maxPages") : x instanceof E && x.cause instanceof De ? new B("budget", x.cause.message, "$.budget.maxCells") : x instanceof E && x.cause instanceof Le ? new B("budget", x.cause.message, "$.budget.maxChartComponents") : x;
|
|
5364
5365
|
});
|
|
5365
5366
|
O(o.signal);
|
|
5366
5367
|
const g = e.assets ? await me(o).run("assets", () => On(h, { ...e.assets, signal: o.signal })) : { plan: h, diagnostics: [] }, y = g.plan;
|
|
@@ -5378,7 +5379,7 @@ function Bi(e) {
|
|
|
5378
5379
|
return O(o.signal), In({ ...o, prepared: f }, t, i);
|
|
5379
5380
|
};
|
|
5380
5381
|
return {
|
|
5381
|
-
describe: (o) =>
|
|
5382
|
+
describe: (o) => zl(e.reports, o),
|
|
5382
5383
|
validate: (o) => Li(e.reports, o),
|
|
5383
5384
|
prepare: (o) => Fe(o.signal, t.maxDurationMs, async (i) => {
|
|
5384
5385
|
const { signal: s, onEvent: a, ...c } = Cn(o), f = { ...c, ...c.pdf ? { pdf: Re(c.pdf) } : {}, taskId: c.taskId ?? tt() }, u = a ? (g) => xe(a, g, i) : void 0, d = { ...f, signal: i, onEvent: u };
|
|
@@ -5402,7 +5403,7 @@ function Bi(e) {
|
|
|
5402
5403
|
return T(t, "maxRows", h.stats.rows), T(t, "maxPages", h.stats.pages), T(t, "maxCells", h.stats.cells), T(t, "maxOutputBytes", h.bytes.byteLength), { ...h, stats: { ...h.stats, outputBytes: h.bytes.byteLength } };
|
|
5403
5404
|
}
|
|
5404
5405
|
const m = { ...d, signal: i, onEvent: l };
|
|
5405
|
-
if (me(m).runSync("validate", () =>
|
|
5406
|
+
if (me(m).runSync("validate", () => Kl(m)), e.assets) {
|
|
5406
5407
|
const h = await me(m).run("assets", () => On(u.plan, { ...e.assets, signal: i }));
|
|
5407
5408
|
u.plan = h.plan, u.diagnostics.push(...St(h.diagnostics));
|
|
5408
5409
|
}
|
|
@@ -5416,7 +5417,7 @@ function Bi(e) {
|
|
|
5416
5417
|
})
|
|
5417
5418
|
};
|
|
5418
5419
|
}
|
|
5419
|
-
const
|
|
5420
|
+
const Jl = { cells: 2e4, pages: 20, bytes: 2e6 };
|
|
5420
5421
|
function Ie(e) {
|
|
5421
5422
|
return e.cells >= e.limits.cells || e.pages >= e.limits.pages || e.bytes >= e.limits.bytes || e.capped;
|
|
5422
5423
|
}
|
|
@@ -5461,7 +5462,7 @@ function _i(e, t, r) {
|
|
|
5461
5462
|
}
|
|
5462
5463
|
}
|
|
5463
5464
|
}
|
|
5464
|
-
function
|
|
5465
|
+
function Vl(e, t) {
|
|
5465
5466
|
if (e.format === "xlsx")
|
|
5466
5467
|
for (const r of e.xlsx?.additionalSheets ?? []) {
|
|
5467
5468
|
if (!re(t)) return;
|
|
@@ -5475,13 +5476,13 @@ function Jl(e, t) {
|
|
|
5475
5476
|
}
|
|
5476
5477
|
}
|
|
5477
5478
|
}
|
|
5478
|
-
function
|
|
5479
|
-
const t = { ...
|
|
5479
|
+
function Hl(e) {
|
|
5480
|
+
const t = { ...Jl, ...e.thresholds };
|
|
5480
5481
|
for (const r of Object.values(t)) if (!Number.isSafeInteger(r) || r <= 0) throw new RangeError("导出隔离阈值应为正安全整数");
|
|
5481
5482
|
return t;
|
|
5482
5483
|
}
|
|
5483
|
-
function
|
|
5484
|
-
const r =
|
|
5484
|
+
function Ul(e, t) {
|
|
5485
|
+
const r = Hl(t), n = e.pdf?.customFontFaces ? Object.values(e.pdf.customFontFaces) : [e.pdf?.customFontBytes], o = { pages: e.prepared.plan.pages.length, cells: 0, bytes: n.reduce((a, c) => a + (c?.byteLength ?? 0), 0), visits: 0, capped: !1, limits: r };
|
|
5485
5486
|
for (const a of e.prepared.plan.pages) {
|
|
5486
5487
|
if (Ie(o)) break;
|
|
5487
5488
|
for (const c of a.components) {
|
|
@@ -5489,7 +5490,7 @@ function Hl(e, t) {
|
|
|
5489
5490
|
_i(c, o, 0);
|
|
5490
5491
|
}
|
|
5491
5492
|
}
|
|
5492
|
-
|
|
5493
|
+
Vl(e, o);
|
|
5493
5494
|
let i = Ie(o) ? "worker" : "local", s = o.capped ? "scan-limit" : i === "worker" ? "threshold" : "small-task";
|
|
5494
5495
|
return t.mode === "local" && (i = "local", s = "explicit-local"), t.mode === "worker" && (i = "worker", s = "explicit-worker"), Object.values(e.xlsx ?? {}).some((a) => typeof a == "function") && (i = "local", s = "nonserializable-options"), { mode: i, reason: s, estimate: { pages: o.pages, cells: o.cells, bytes: o.bytes }, hardCancellation: i === "worker" };
|
|
5495
5496
|
}
|
|
@@ -5502,20 +5503,20 @@ class Dn extends Error {
|
|
|
5502
5503
|
function ue(e) {
|
|
5503
5504
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
5504
5505
|
}
|
|
5505
|
-
function
|
|
5506
|
+
function Gl(e) {
|
|
5506
5507
|
return ue(e) ? ["rows", "pages", "cells"].every((t) => typeof e[t] == "number" && Number.isSafeInteger(e[t]) && e[t] >= 0) && typeof e.durationMs == "number" && Number.isFinite(e.durationMs) && e.durationMs >= 0 : !1;
|
|
5507
5508
|
}
|
|
5508
|
-
function
|
|
5509
|
+
function Yl(e) {
|
|
5509
5510
|
return Array.isArray(e) && e.every((t) => ue(t) && typeof t.code == "string" && typeof t.message == "string" && ["info", "warning", "error"].includes(t.severity) && Yr(t));
|
|
5510
5511
|
}
|
|
5511
|
-
function
|
|
5512
|
+
function ql(e) {
|
|
5512
5513
|
return ue(e) && Object.values(e).every((t) => ue(t) && (t.revision === void 0 || typeof t.revision == "string") && (t.sourceToken === void 0 || typeof t.sourceToken == "string"));
|
|
5513
5514
|
}
|
|
5514
|
-
function
|
|
5515
|
+
function Xl(e) {
|
|
5515
5516
|
return e === void 0 ? !0 : ue(e) && ["heuristic", "provided", "font-bytes"].includes(e.textMetrics) && (e.fontFingerprint === void 0 || typeof e.fontFingerprint == "string" && /^[a-f0-9]{64}$/.test(e.fontFingerprint));
|
|
5516
5517
|
}
|
|
5517
|
-
function
|
|
5518
|
-
if (!ue(e) || !
|
|
5518
|
+
function Zl(e, t) {
|
|
5519
|
+
if (!ue(e) || !Gl(e.stats) || !Yl(e.diagnostics) || !ql(e.revisions) || !Xl(e.layout) || !Ti(e.sources)) return !1;
|
|
5519
5520
|
if (t === "prepare") return Je(e.plan).ok;
|
|
5520
5521
|
const r = e.format === "pdf" ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
5521
5522
|
return e.bytes instanceof Uint8Array && (e.format === "pdf" || e.format === "xlsx") && e.contentType === r;
|
|
@@ -5529,7 +5530,7 @@ function Ki(e) {
|
|
|
5529
5530
|
}
|
|
5530
5531
|
return t;
|
|
5531
5532
|
}
|
|
5532
|
-
function
|
|
5533
|
+
function Ql(e) {
|
|
5533
5534
|
const t = Ki(e);
|
|
5534
5535
|
if (!ue(e)) return t;
|
|
5535
5536
|
for (const r of ["format", "severity", "kind", "nid"]) typeof e[r] == "string" && (t[r] = e[r]);
|
|
@@ -5545,7 +5546,7 @@ function Wi(e) {
|
|
|
5545
5546
|
...typeof t.code == "string" ? { code: t.code } : {},
|
|
5546
5547
|
...typeof t.path == "string" ? { path: t.path } : {},
|
|
5547
5548
|
...Array.isArray(t.issues) ? { issues: t.issues.map(Ki) } : {},
|
|
5548
|
-
...Array.isArray(t.diagnostics) ? { diagnostics: t.diagnostics.map(
|
|
5549
|
+
...Array.isArray(t.diagnostics) ? { diagnostics: t.diagnostics.map(Ql) } : {}
|
|
5549
5550
|
};
|
|
5550
5551
|
}
|
|
5551
5552
|
function zi(e) {
|
|
@@ -5565,7 +5566,7 @@ function Vi(e) {
|
|
|
5565
5566
|
const t = e.result;
|
|
5566
5567
|
return !t || !("bytes" in t) || !(t.bytes.buffer instanceof ArrayBuffer) ? [] : [t.bytes.buffer];
|
|
5567
5568
|
}
|
|
5568
|
-
function
|
|
5569
|
+
function ed(e, t) {
|
|
5569
5570
|
if (!ue(e) || typeof e.taskId != "string" || !e.taskId || t.taskId !== void 0 && e.taskId !== t.taskId || e.correlationId !== t.correlationId || e.reportId !== void 0 && (typeof e.reportId != "string" || !("reportIds" in t && t.reportIds.includes(e.reportId))) || !["query", "validate", "layout", "assets", "encode"].includes(e.stage) || !["started", "completed", "failed"].includes(e.status)) return !1;
|
|
5570
5571
|
for (const r of ["completed", "total"]) if (e[r] !== void 0 && (typeof e[r] != "number" || !Number.isFinite(e[r]) || e[r] < 0)) return !1;
|
|
5571
5572
|
return e.completed === void 0 || e.total === void 0 || e.completed <= e.total;
|
|
@@ -5575,17 +5576,17 @@ class yr extends Error {
|
|
|
5575
5576
|
super("报表 Worker 无法启动"), this.cause = t, this.name = "ReportWorkerStartError";
|
|
5576
5577
|
}
|
|
5577
5578
|
}
|
|
5578
|
-
let
|
|
5579
|
+
let td = 0;
|
|
5579
5580
|
function Ln(e) {
|
|
5580
5581
|
const t = new Error("报表 Worker 任务已取消");
|
|
5581
5582
|
return t.name = "AbortError", Object.defineProperty(t, "cause", { value: e }), t;
|
|
5582
5583
|
}
|
|
5583
|
-
function
|
|
5584
|
+
function rd(e, t) {
|
|
5584
5585
|
if (!e || typeof e != "object") return;
|
|
5585
5586
|
const r = e;
|
|
5586
5587
|
return r.protocol === fe && r.id === t ? r : void 0;
|
|
5587
5588
|
}
|
|
5588
|
-
function
|
|
5589
|
+
function nd(e, t = {}) {
|
|
5589
5590
|
const r = t.timeoutMs ?? 12e4;
|
|
5590
5591
|
if (!Number.isFinite(r) || r <= 0 || r > 2147483647) throw new RangeError("Worker timeoutMs 应为正有限数字,且不能超过 2147483647");
|
|
5591
5592
|
const n = (o, i, s, a) => s?.aborted ? Promise.reject(Ln(s.reason)) : new Promise((c, f) => {
|
|
@@ -5596,7 +5597,7 @@ function rd(e, t = {}) {
|
|
|
5596
5597
|
f(new yr(p));
|
|
5597
5598
|
return;
|
|
5598
5599
|
}
|
|
5599
|
-
const d = `mach-report-${Date.now()}-${++
|
|
5600
|
+
const d = `mach-report-${Date.now()}-${++td}`;
|
|
5600
5601
|
let l = !1, m = () => {
|
|
5601
5602
|
}, h;
|
|
5602
5603
|
const g = (p, b) => {
|
|
@@ -5613,14 +5614,14 @@ function rd(e, t = {}) {
|
|
|
5613
5614
|
($) => f(p ?? $)
|
|
5614
5615
|
);
|
|
5615
5616
|
}, y = () => g(Ln(s?.reason)), w = (p) => {
|
|
5616
|
-
const b =
|
|
5617
|
+
const b = rd(p, d);
|
|
5617
5618
|
if (!(!b || l)) {
|
|
5618
5619
|
if ("type" in b && b.type === "event") {
|
|
5619
5620
|
const x = "event" in b ? b.event : void 0;
|
|
5620
|
-
|
|
5621
|
+
ed(x, i) ? xe(a, x, s) : g(new Error("报表 Worker 返回无效阶段事件"));
|
|
5621
5622
|
return;
|
|
5622
5623
|
}
|
|
5623
|
-
b.error && typeof b.error.name == "string" && typeof b.error.message == "string" ? g(new Dn(b.error)) :
|
|
5624
|
+
b.error && typeof b.error.name == "string" && typeof b.error.message == "string" ? g(new Dn(b.error)) : Zl(b.result, o) && (o === "prepare" || "format" in b.result && "format" in i && b.result.format === i.format) ? g(void 0, b.result) : g(new Error("报表 Worker 返回无效响应"));
|
|
5624
5625
|
}
|
|
5625
5626
|
};
|
|
5626
5627
|
try {
|
|
@@ -5630,7 +5631,7 @@ function rd(e, t = {}) {
|
|
|
5630
5631
|
}
|
|
5631
5632
|
if (s?.addEventListener("abort", y, { once: !0 }), h = setTimeout(() => g(new Dn({ name: "ReportRuntimeError", code: "timeout", message: `报表 Worker 执行超过 ${r}ms` })), r), s?.aborted) y();
|
|
5632
5633
|
else {
|
|
5633
|
-
const { onEvent: p, signal: b, ...x } = i, $ =
|
|
5634
|
+
const { onEvent: p, signal: b, ...x } = i, $ = od(x);
|
|
5634
5635
|
u.postMessage({ protocol: fe, id: d, operation: o, input: x, ...t.budget ? { budget: t.budget } : {} }, $);
|
|
5635
5636
|
}
|
|
5636
5637
|
} catch (p) {
|
|
@@ -5639,10 +5640,10 @@ function rd(e, t = {}) {
|
|
|
5639
5640
|
});
|
|
5640
5641
|
return { exportPrepared: (o, i, s) => n("exportPrepared", o, i, s), prepare: (o, i, s) => n("prepare", o, i, s), export: (o, i, s) => n("export", o, i, s) };
|
|
5641
5642
|
}
|
|
5642
|
-
function
|
|
5643
|
+
function od(e) {
|
|
5643
5644
|
return e.pdf ? (e.pdf = Re(e.pdf), (e.pdf?.customFontFaces ? Object.values(e.pdf.customFontFaces) : [e.pdf?.customFontBytes]).filter((r) => r instanceof Uint8Array).map((r) => r.buffer)) : [];
|
|
5644
5645
|
}
|
|
5645
|
-
function
|
|
5646
|
+
function id(e) {
|
|
5646
5647
|
if (e.mode !== void 0 && !["auto", "local", "worker"].includes(e.mode)) throw new TypeError("无效的导出执行模式");
|
|
5647
5648
|
if (e.fallback !== void 0 && !["local", "error"].includes(e.fallback)) throw new TypeError("无效的导出回退策略");
|
|
5648
5649
|
$i({ ...e.budget, maxDurationMs: e.timeoutMs ?? e.budget?.maxDurationMs ?? 12e4 });
|
|
@@ -5656,12 +5657,12 @@ function _n(e, t) {
|
|
|
5656
5657
|
function Kn(e, t, r) {
|
|
5657
5658
|
T(r, "maxRows", e.stats.rows), T(r, "maxPages", e.stats.pages), T(r, "maxCells", e.stats.cells), T(r, "maxOutputBytes", e.bytes.byteLength), Qr({ ...t, prepared: { ...t.prepared, stats: e.stats } }, r);
|
|
5658
5659
|
}
|
|
5659
|
-
function
|
|
5660
|
-
const r = { ...Xr, ...t.budget }, n =
|
|
5660
|
+
function sd(e, t) {
|
|
5661
|
+
const r = { ...Xr, ...t.budget }, n = _l(e.prepared, r.maxPreparedBytes, e.signal), o = { ...e, prepared: n.prepared, pdf: Re(e.pdf), xlsx: hr(e.xlsx) };
|
|
5661
5662
|
return { request: o, forward: () => ({ ...o, prepared: n.forward() }) };
|
|
5662
5663
|
}
|
|
5663
|
-
function
|
|
5664
|
-
|
|
5664
|
+
function ad(e, t) {
|
|
5665
|
+
id(e);
|
|
5665
5666
|
const r = { ...e, thresholds: { ...e.thresholds }, budget: { ...Xr, ...e.budget } }, n = r.timeoutMs ?? r.budget.maxDurationMs ?? 12e4, o = Bi({ reports: {}, budget: { ...r.budget, maxDurationMs: n } }), i = /* @__PURE__ */ new Set();
|
|
5666
5667
|
let s = !1;
|
|
5667
5668
|
const a = r.mode !== "worker" && r.fallback !== "error";
|
|
@@ -5671,13 +5672,13 @@ function sd(e, t) {
|
|
|
5671
5672
|
if (w <= 0) throw new B("timeout", `报表执行超过 ${n}ms`);
|
|
5672
5673
|
return w;
|
|
5673
5674
|
};
|
|
5674
|
-
let m =
|
|
5675
|
+
let m = Ul(f, r);
|
|
5675
5676
|
if (m.reason === "nonserializable-options" && r.mode === "worker") throw new TypeError("Worker 模式不接受函数选项;请使用本地模式或可序列化配置");
|
|
5676
5677
|
if (m.mode === "worker" && !t) {
|
|
5677
5678
|
if (!a) throw new yr(new Error("未配置 workerFactory"));
|
|
5678
5679
|
m = _n(m, "worker-unavailable");
|
|
5679
5680
|
}
|
|
5680
|
-
const h =
|
|
5681
|
+
const h = sd(f, r), g = h.request;
|
|
5681
5682
|
if (Bn(r, m), O(f.signal), m.mode === "worker")
|
|
5682
5683
|
try {
|
|
5683
5684
|
const w = t(l());
|
|
@@ -5715,7 +5716,7 @@ function sd(e, t) {
|
|
|
5715
5716
|
}
|
|
5716
5717
|
};
|
|
5717
5718
|
}
|
|
5718
|
-
async function
|
|
5719
|
+
async function cd(e, t) {
|
|
5719
5720
|
try {
|
|
5720
5721
|
if (e.operation !== "exportPrepared") throw new TypeError("内置编码 Worker 仅接受 exportPrepared");
|
|
5721
5722
|
return await Ji(Bi({ reports: {}, budget: e.budget }), e, t);
|
|
@@ -5731,7 +5732,7 @@ class k extends Error {
|
|
|
5731
5732
|
function Et(e, t) {
|
|
5732
5733
|
if (typeof e != "string" || !e.trim() || e.length > 256 || typeof t != "string" || t !== t.trim() || !/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(t)) throw new k("input", "任务范围应非空,ID应为1–128位安全标识");
|
|
5733
5734
|
}
|
|
5734
|
-
function
|
|
5735
|
+
function fd(e) {
|
|
5735
5736
|
const t = Array.isArray(e), r = Object.getPrototypeOf(e), n = Object.keys(e);
|
|
5736
5737
|
if (r !== (t ? Array.prototype : Object.prototype) && !(r === null && !t)) throw new k("input", "任务对象应为普通 JSON 对象");
|
|
5737
5738
|
if (Object.getOwnPropertySymbols(e).length) throw new k("input", "任务不能包含Symbol");
|
|
@@ -5739,7 +5740,7 @@ function cd(e) {
|
|
|
5739
5740
|
if (t && (n.length !== e.length || n.some((i) => i !== String(Number(i)) || !Number.isSafeInteger(Number(i)) || Number(i) < 0 || Number(i) >= e.length))) throw new k("input", "任务数组不能稀疏或包含额外属性");
|
|
5740
5741
|
return n.sort();
|
|
5741
5742
|
}
|
|
5742
|
-
function
|
|
5743
|
+
function ud(e, t) {
|
|
5743
5744
|
const r = Object.getOwnPropertyDescriptor(e, t);
|
|
5744
5745
|
if (["__proto__", "prototype", "constructor"].includes(t) || r.get || r.set) throw new k("input", "任务不能包含危险键或访问器");
|
|
5745
5746
|
return r.value;
|
|
@@ -5757,12 +5758,12 @@ function ie(e, t = {}) {
|
|
|
5757
5758
|
}
|
|
5758
5759
|
if (f === null || typeof f == "boolean" || typeof f == "number" && Number.isFinite(f)) return f;
|
|
5759
5760
|
if (!f || typeof f != "object" || s.has(f)) throw new k("input", "任务只允许无循环的有限 JSON 值");
|
|
5760
|
-
const d = Array.isArray(f), l =
|
|
5761
|
+
const d = Array.isArray(f), l = fd(f);
|
|
5761
5762
|
s.add(f);
|
|
5762
5763
|
const m = /* @__PURE__ */ Object.create(null);
|
|
5763
5764
|
for (const h of l) {
|
|
5764
5765
|
if (i += h.length, i > n) throw new k("input", "任务文本超过预算");
|
|
5765
|
-
m[h] = a(
|
|
5766
|
+
m[h] = a(ud(f, h), u + 1);
|
|
5766
5767
|
}
|
|
5767
5768
|
return s.delete(f), d ? Array.from({ length: f.length }, (h, g) => m[String(g)]) : m;
|
|
5768
5769
|
}
|
|
@@ -5780,13 +5781,13 @@ function Hi(e, t, r, n) {
|
|
|
5780
5781
|
if (!e.request || typeof e.request.kind != "string" || !e.request.kind.trim() || e.request.kind.length > 128) throw new k("input", "任务类型无效");
|
|
5781
5782
|
ie(e.request.payload, { maxNodes: 19e3, maxCharacters: 75e4 }), ie(e);
|
|
5782
5783
|
}
|
|
5783
|
-
function
|
|
5784
|
+
function ld(e, t) {
|
|
5784
5785
|
if (e && (e.createdAt !== t.createdAt || ie(e.request) !== ie(t.request))) throw new k("input", "任务创建时间与请求不可变更,请使用新任务ID");
|
|
5785
5786
|
}
|
|
5786
|
-
function
|
|
5787
|
+
function dd(e, t) {
|
|
5787
5788
|
return e.status === "queued" || e.status === "running" && (e.lease?.expiresAt ?? 0) <= t;
|
|
5788
5789
|
}
|
|
5789
|
-
function
|
|
5790
|
+
function md(e = {}) {
|
|
5790
5791
|
const t = {
|
|
5791
5792
|
maxRecords: e.maxRecords ?? 1e4,
|
|
5792
5793
|
maxBytes: e.maxBytes ?? 67108864,
|
|
@@ -5811,23 +5812,23 @@ function Ui(e, t) {
|
|
|
5811
5812
|
function Gi(e) {
|
|
5812
5813
|
return e.status !== "queued" && e.status !== "running";
|
|
5813
5814
|
}
|
|
5814
|
-
function
|
|
5815
|
+
function hd(e) {
|
|
5815
5816
|
const t = { ...e, tombstoneRetentionMs: e.tombstoneRetentionMs ?? 6048e5, limit: e.limit ?? 100 };
|
|
5816
5817
|
if (![t.now, t.terminalBefore].every((r) => Number.isSafeInteger(r) && r >= 0) || t.terminalBefore > t.now) throw new k("input", "终态清理时间应为不超过当前时间的非负整数");
|
|
5817
5818
|
if (![t.tombstoneRetentionMs, t.limit].every((r) => Number.isSafeInteger(r) && r > 0) || !Number.isSafeInteger(t.now + t.tombstoneRetentionMs)) throw new k("input", "幂等保留期与清理批量应为正整数");
|
|
5818
5819
|
return t;
|
|
5819
5820
|
}
|
|
5820
|
-
async function
|
|
5821
|
+
async function gd(e) {
|
|
5821
5822
|
const t = new TextEncoder().encode(ie(e)), r = globalThis.crypto?.subtle;
|
|
5822
|
-
if (!r) return
|
|
5823
|
+
if (!r) return jl(t);
|
|
5823
5824
|
const n = await r.digest("SHA-256", t);
|
|
5824
5825
|
return Array.from(new Uint8Array(n), (o) => o.toString(16).padStart(2, "0")).join("");
|
|
5825
5826
|
}
|
|
5826
|
-
async function
|
|
5827
|
+
async function pd(e, t) {
|
|
5827
5828
|
if (!Gi(e)) throw new k("input", "只能归档终态任务");
|
|
5828
|
-
return { scope: e.scope, id: e.id, revision: e.revision, status: e.status, createdAt: e.createdAt, updatedAt: e.updatedAt, attempt: e.attempt, requestHash: await
|
|
5829
|
+
return { scope: e.scope, id: e.id, revision: e.revision, status: e.status, createdAt: e.createdAt, updatedAt: e.updatedAt, attempt: e.attempt, requestHash: await gd(e.request), expiresAt: t };
|
|
5829
5830
|
}
|
|
5830
|
-
function
|
|
5831
|
+
function yd(e) {
|
|
5831
5832
|
if (!e || !["completed", "failed", "cancelled"].includes(e.status) || !/^[a-f0-9]{64}$/.test(e.requestHash)) throw new k("input", "任务幂等摘要无效");
|
|
5832
5833
|
if (![e.revision, e.createdAt, e.updatedAt, e.attempt, e.expiresAt].every((t) => Number.isSafeInteger(t) && t >= 0) || e.revision < 1) throw new k("input", "任务幂等摘要时间或修订无效");
|
|
5833
5834
|
}
|
|
@@ -5835,7 +5836,7 @@ function Ve(e) {
|
|
|
5835
5836
|
return e?.code;
|
|
5836
5837
|
}
|
|
5837
5838
|
function Te(e, t) {
|
|
5838
|
-
return
|
|
5839
|
+
return Mr("sha256").update(JSON.stringify([e, t])).digest("hex") + ".json";
|
|
5839
5840
|
}
|
|
5840
5841
|
async function wr(e) {
|
|
5841
5842
|
try {
|
|
@@ -5845,7 +5846,7 @@ async function wr(e) {
|
|
|
5845
5846
|
throw t;
|
|
5846
5847
|
}
|
|
5847
5848
|
}
|
|
5848
|
-
async function
|
|
5849
|
+
async function wd(e, t) {
|
|
5849
5850
|
const r = await wr(e);
|
|
5850
5851
|
if (r === void 0) return;
|
|
5851
5852
|
let n;
|
|
@@ -5866,7 +5867,7 @@ async function yd(e, t) {
|
|
|
5866
5867
|
}
|
|
5867
5868
|
throw new k("conflict", "任务目录的写入进程仍在运行");
|
|
5868
5869
|
}
|
|
5869
|
-
async function
|
|
5870
|
+
async function bd(e, t) {
|
|
5870
5871
|
if (!t) throw new k("conflict", "任务目录已有写入进程;多实例请使用数据库CAS适配器");
|
|
5871
5872
|
const r = e + ".recovery";
|
|
5872
5873
|
let n;
|
|
@@ -5876,19 +5877,19 @@ async function wd(e, t) {
|
|
|
5876
5877
|
throw Ve(o) === "EEXIST" ? new k("conflict", "任务目录恢复正在进行,请稍后重试") : o;
|
|
5877
5878
|
}
|
|
5878
5879
|
try {
|
|
5879
|
-
return await n.writeFile(JSON.stringify({ pid: process.pid })), await
|
|
5880
|
+
return await n.writeFile(JSON.stringify({ pid: process.pid })), await wd(e, !0), await A.open(e, "wx", 384);
|
|
5880
5881
|
} finally {
|
|
5881
5882
|
await n.close(), await A.unlink(r);
|
|
5882
5883
|
}
|
|
5883
5884
|
}
|
|
5884
|
-
async function
|
|
5885
|
+
async function xd(e, t) {
|
|
5885
5886
|
const r = L.join(e, ".writer-lock"), n = At();
|
|
5886
5887
|
let o;
|
|
5887
5888
|
try {
|
|
5888
5889
|
o = await A.open(r, "wx", 384);
|
|
5889
5890
|
} catch (i) {
|
|
5890
5891
|
if (Ve(i) !== "EEXIST") throw i;
|
|
5891
|
-
o = await
|
|
5892
|
+
o = await bd(r, t);
|
|
5892
5893
|
}
|
|
5893
5894
|
try {
|
|
5894
5895
|
await o.writeFile(JSON.stringify({ pid: process.pid, token: n })), await o.sync();
|
|
@@ -5898,10 +5899,10 @@ async function bd(e, t) {
|
|
|
5898
5899
|
}
|
|
5899
5900
|
return { file: r, token: n, handle: o };
|
|
5900
5901
|
}
|
|
5901
|
-
function
|
|
5902
|
+
function Md(e, t, r, n) {
|
|
5902
5903
|
if ("tombstone" in r) {
|
|
5903
5904
|
const o = r.tombstone;
|
|
5904
|
-
if (
|
|
5905
|
+
if (yd(o), Et(o.scope, o.id), Te(o.scope, o.id) !== t) throw new k("input", "持久任务摘要身份不匹配");
|
|
5905
5906
|
const i = Ce(o);
|
|
5906
5907
|
e.tombstoneBytes += i, e.tombstones.set(t, { value: o, bytes: i });
|
|
5907
5908
|
} else {
|
|
@@ -5920,11 +5921,11 @@ async function vd(e, t) {
|
|
|
5920
5921
|
for (const i of n) {
|
|
5921
5922
|
const s = L.join(e, i);
|
|
5922
5923
|
if ((await A.stat(s)).size > 4e6) throw new k("capacity", "持久任务文件超过单文件预算");
|
|
5923
|
-
|
|
5924
|
+
Md(o, i, JSON.parse(await A.readFile(s, "utf8")), t);
|
|
5924
5925
|
}
|
|
5925
5926
|
return o;
|
|
5926
5927
|
}
|
|
5927
|
-
async function
|
|
5928
|
+
async function $d(e, t, r) {
|
|
5928
5929
|
const n = L.join(e, `.pending-${At()}`);
|
|
5929
5930
|
try {
|
|
5930
5931
|
const o = await A.open(n, "wx", 384);
|
|
@@ -5946,10 +5947,10 @@ async function Md(e, t, r) {
|
|
|
5946
5947
|
});
|
|
5947
5948
|
}
|
|
5948
5949
|
}
|
|
5949
|
-
async function
|
|
5950
|
-
const t = L.resolve(e.directory), r =
|
|
5950
|
+
async function Id(e) {
|
|
5951
|
+
const t = L.resolve(e.directory), r = md(e);
|
|
5951
5952
|
await A.mkdir(t, { recursive: !0, mode: 448 });
|
|
5952
|
-
const n = await
|
|
5953
|
+
const n = await xd(t, e.recoverDeadOwner ?? !1);
|
|
5953
5954
|
let o;
|
|
5954
5955
|
try {
|
|
5955
5956
|
o = await vd(t, r);
|
|
@@ -5970,7 +5971,7 @@ async function Rd(e) {
|
|
|
5970
5971
|
}), m;
|
|
5971
5972
|
}, f = async (l, m, h) => {
|
|
5972
5973
|
try {
|
|
5973
|
-
await
|
|
5974
|
+
await $d(t, l, m);
|
|
5974
5975
|
} catch (g) {
|
|
5975
5976
|
throw await wr(L.join(t, l)) === m && h(), g;
|
|
5976
5977
|
}
|
|
@@ -5987,13 +5988,13 @@ async function Rd(e) {
|
|
|
5987
5988
|
const h = o.tombstones.get(Te(l, m));
|
|
5988
5989
|
return h ? Xt(h.value) : void 0;
|
|
5989
5990
|
},
|
|
5990
|
-
candidates: async (l, m) => (a(), await s, Array.from(o.records.values(), (h) => h.record).filter((h) =>
|
|
5991
|
+
candidates: async (l, m) => (a(), await s, Array.from(o.records.values(), (h) => h.record).filter((h) => dd(h, l)).sort((h, g) => h.createdAt - g.createdAt).slice(0, m).map(Xt)),
|
|
5991
5992
|
compareAndSwap: async (l, m, h, g) => {
|
|
5992
5993
|
const y = JSON.parse(ie(g));
|
|
5993
5994
|
return Hi(y, l, m, h), c(async () => {
|
|
5994
5995
|
const w = Te(l, m), p = o.records.get(w);
|
|
5995
5996
|
if ((p?.record.revision ?? null) !== h || o.tombstones.has(w)) return !1;
|
|
5996
|
-
|
|
5997
|
+
ld(p?.record, y);
|
|
5997
5998
|
const b = Ui(y, r), x = o.bytes - (p?.bytes ?? 0) + b;
|
|
5998
5999
|
if (x > r.maxBytes || !p && o.records.size >= r.maxRecords) throw new k("capacity", "持久任务容量已满,请清理终态任务或扩大显式预算");
|
|
5999
6000
|
return await f(w, ie(y), () => {
|
|
@@ -6002,14 +6003,14 @@ async function Rd(e) {
|
|
|
6002
6003
|
});
|
|
6003
6004
|
},
|
|
6004
6005
|
prune: async (l) => {
|
|
6005
|
-
const m =
|
|
6006
|
+
const m = hd(l);
|
|
6006
6007
|
return c(async () => {
|
|
6007
6008
|
const h = { archived: 0, expired: 0 };
|
|
6008
6009
|
for (const [g, y] of o.tombstones)
|
|
6009
6010
|
y.value.expiresAt > m.now || h.expired >= m.limit || (await A.unlink(L.join(t, g)), o.tombstones.delete(g), o.tombstoneBytes -= y.bytes, h.expired++);
|
|
6010
6011
|
for (const [g, y] of o.records) {
|
|
6011
6012
|
if (!Gi(y.record) || y.record.updatedAt > m.terminalBefore || h.archived + h.expired >= m.limit) continue;
|
|
6012
|
-
const w = await
|
|
6013
|
+
const w = await pd(y.record, m.now + m.tombstoneRetentionMs), p = Ce(w);
|
|
6013
6014
|
if (o.tombstones.size >= r.maxTombstones || o.tombstoneBytes + p > r.maxTombstoneBytes) break;
|
|
6014
6015
|
await f(g, ie({ tombstone: w }), () => {
|
|
6015
6016
|
o.tombstones.set(g, { value: w, bytes: p }), o.tombstoneBytes += p, o.records.delete(g), o.bytes -= y.bytes;
|
|
@@ -6039,7 +6040,7 @@ class F extends Error {
|
|
|
6039
6040
|
super(r), this.code = t, this.name = "ReportDocumentError";
|
|
6040
6041
|
}
|
|
6041
6042
|
}
|
|
6042
|
-
function
|
|
6043
|
+
function Sd(e = {}) {
|
|
6043
6044
|
const t = { maxDocuments: e.maxDocuments ?? 32, maxBytes: e.maxBytes ?? 64e6, maxPages: e.maxPages ?? 1e4, maxPageBytes: e.maxPageBytes ?? 4e6, maxManifestBytes: e.maxManifestBytes ?? 1e6 };
|
|
6044
6045
|
if (Object.values(t).some((r) => !Number.isSafeInteger(r) || r < 1)) throw new F("input", "文档预算应为正安全整数");
|
|
6045
6046
|
return t;
|
|
@@ -6066,7 +6067,7 @@ function Ge(e, t) {
|
|
|
6066
6067
|
}
|
|
6067
6068
|
throw new F("capacity", "文档容量统计无效");
|
|
6068
6069
|
}
|
|
6069
|
-
function
|
|
6070
|
+
function Ed(e, t, r = []) {
|
|
6070
6071
|
const n = /* @__PURE__ */ new Map();
|
|
6071
6072
|
let o = 0, i = Promise.resolve();
|
|
6072
6073
|
for (const u of r) {
|
|
@@ -6157,7 +6158,7 @@ function Sd(e, t, r = []) {
|
|
|
6157
6158
|
})
|
|
6158
6159
|
};
|
|
6159
6160
|
}
|
|
6160
|
-
const br = (e) => e?.code, rt = (e, t) =>
|
|
6161
|
+
const br = (e) => e?.code, rt = (e, t) => Mr("sha256").update(le(e, t)).digest("hex");
|
|
6161
6162
|
async function xr(e, t) {
|
|
6162
6163
|
const r = await A.lstat(e);
|
|
6163
6164
|
if (!r.isFile() || r.size > t) throw new F("capacity", "文档文件类型或大小无效");
|
|
@@ -6173,7 +6174,7 @@ async function zn(e, t) {
|
|
|
6173
6174
|
});
|
|
6174
6175
|
}
|
|
6175
6176
|
}
|
|
6176
|
-
async function
|
|
6177
|
+
async function Ad(e, t) {
|
|
6177
6178
|
const r = (await A.readdir(e)).filter((o) => /^[a-f0-9]{64}$/.test(o));
|
|
6178
6179
|
if (r.length > t.maxDocuments) throw new F("capacity", "文档数量超过目录预算");
|
|
6179
6180
|
const n = [];
|
|
@@ -6197,8 +6198,8 @@ async function Ed(e, t) {
|
|
|
6197
6198
|
}
|
|
6198
6199
|
return n;
|
|
6199
6200
|
}
|
|
6200
|
-
async function
|
|
6201
|
-
const t =
|
|
6201
|
+
async function Cd(e) {
|
|
6202
|
+
const t = Sd(e), r = L.resolve(e.directory);
|
|
6202
6203
|
await A.mkdir(r, { recursive: !0, mode: 448 });
|
|
6203
6204
|
const n = L.join(r, ".document-writer-lock"), o = At();
|
|
6204
6205
|
let i;
|
|
@@ -6231,8 +6232,8 @@ async function Id(e) {
|
|
|
6231
6232
|
};
|
|
6232
6233
|
let d;
|
|
6233
6234
|
try {
|
|
6234
|
-
const l = await
|
|
6235
|
-
d =
|
|
6235
|
+
const l = await Ad(r, t);
|
|
6236
|
+
d = Ed({
|
|
6236
6237
|
write: async (m, h) => {
|
|
6237
6238
|
await a();
|
|
6238
6239
|
const g = L.join(r, rt(m.scope, m.id));
|
|
@@ -6264,10 +6265,10 @@ async function Id(e) {
|
|
|
6264
6265
|
}
|
|
6265
6266
|
};
|
|
6266
6267
|
}
|
|
6267
|
-
function
|
|
6268
|
+
function kd(e) {
|
|
6268
6269
|
const t = e.filename ?? e.workerUrl;
|
|
6269
6270
|
if (!t || e.filename && e.workerUrl) throw new TypeError("请且仅请指定 filename 或 workerUrl");
|
|
6270
|
-
return
|
|
6271
|
+
return nd(() => {
|
|
6271
6272
|
const r = new Qi(t, e.workerOptions);
|
|
6272
6273
|
return {
|
|
6273
6274
|
postMessage: (n, o) => r.postMessage(n, o),
|
|
@@ -6281,7 +6282,7 @@ function Ad(e) {
|
|
|
6281
6282
|
};
|
|
6282
6283
|
}, e);
|
|
6283
6284
|
}
|
|
6284
|
-
function
|
|
6285
|
+
function Td(e) {
|
|
6285
6286
|
const t = Zt;
|
|
6286
6287
|
if (!t) throw new Error("serveNodeReportWorker 只能在 worker_threads 中调用");
|
|
6287
6288
|
const r = (n) => {
|
|
@@ -6289,12 +6290,12 @@ function Cd(e) {
|
|
|
6289
6290
|
};
|
|
6290
6291
|
return t.on("message", r), () => t.off("message", r);
|
|
6291
6292
|
}
|
|
6292
|
-
function
|
|
6293
|
-
return
|
|
6293
|
+
function jd(e) {
|
|
6294
|
+
return Mr("sha256").update(e).digest("hex");
|
|
6294
6295
|
}
|
|
6295
|
-
function
|
|
6296
|
+
function Dd(e = {}) {
|
|
6296
6297
|
const t = { timeoutMs: e.timeoutMs ?? e.budget?.maxDurationMs, budget: { ...e.budget } };
|
|
6297
|
-
return
|
|
6298
|
+
return ad(e, (r) => kd({
|
|
6298
6299
|
filename: typeof __filename == "string" ? __filename : new URL(import.meta.url),
|
|
6299
6300
|
workerOptions: { workerData: { machReportEncoding: "prepared-v1" } },
|
|
6300
6301
|
...t,
|
|
@@ -6304,15 +6305,15 @@ function jd(e = {}) {
|
|
|
6304
6305
|
if (Zt && Zi?.machReportEncoding === "prepared-v1") {
|
|
6305
6306
|
const e = Zt;
|
|
6306
6307
|
e.on("message", (t) => {
|
|
6307
|
-
zi(t) &&
|
|
6308
|
+
zi(t) && cd(t, (r) => e.postMessage({ protocol: fe, id: t.id, type: "event", event: r })).then((r) => e.postMessage(r, Vi(r)));
|
|
6308
6309
|
});
|
|
6309
6310
|
}
|
|
6310
6311
|
export {
|
|
6311
6312
|
Dn as ReportWorkerError,
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6313
|
+
Dd as createNodeAutoReportExporter,
|
|
6314
|
+
kd as createNodeReportExecutor,
|
|
6315
|
+
Cd as openFileReportDocumentStore,
|
|
6316
|
+
Id as openFileReportJobStore,
|
|
6317
|
+
jd as reportArtifactSha256,
|
|
6318
|
+
Td as serveNodeReportWorker
|
|
6318
6319
|
};
|