@agile-team/mach-report 2.17.0 → 2.18.0
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 +18 -9
- package/dist/{ExcelBindingWizard-Bq6FYME6.cjs → ExcelBindingWizard-Czn3C2yE.cjs} +1 -1
- package/dist/{ExcelBindingWizard-Co1svTsw.js → ExcelBindingWizard-DMGZj6I6.js} +3 -3
- package/dist/ParamEditor-KzDQvbHY.js +732 -0
- package/dist/ParamEditor-oDfD8LgE.cjs +1 -0
- package/dist/{ReportBatchPanel-uQh06usx.js → ReportBatchPanel-BJK7PvZ4.js} +39 -39
- package/dist/ReportBatchPanel-DnmNRssu.cjs +1 -0
- package/dist/ReportParamPanel-mQkeN70Q.js +1020 -0
- package/dist/ReportParamPanel-sOANVRz-.cjs +1 -0
- package/dist/ReportPreview-BxWWTUL5.js +5583 -0
- package/dist/ReportPreview-Yf99omi3.cjs +6 -0
- package/dist/{ReportTemplateLibrary-TIL_Oj2l.js → ReportTemplateLibrary-BFjB08Wu.js} +1 -1
- package/dist/{ReportTemplateLibrary-CnP7_1pH.cjs → ReportTemplateLibrary-BO42QnWd.cjs} +1 -1
- package/dist/RuleEditor-CqxT1a-W.js +2337 -0
- package/dist/RuleEditor-D7YWigD9.cjs +1 -0
- package/dist/{TemplateOutlinePanel-BlLxRrfu.cjs → TemplateOutlinePanel-B0XX350V.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-BouxsuqQ.js → TemplateOutlinePanel-zG0DrsIB.js} +2 -2
- package/dist/{TemplateReusePanel-yxsHSO40.cjs → TemplateReusePanel-BD0HSKp_.cjs} +1 -1
- package/dist/{TemplateReusePanel-BEACLPaN.js → TemplateReusePanel-Czwe5GbC.js} +2 -2
- package/dist/{TemplateReviewPanel-D9Cx0m2N.cjs → TemplateReviewPanel-CA5sdffM.cjs} +1 -1
- package/dist/{TemplateReviewPanel-B1OGRY2i.js → TemplateReviewPanel-NhmQI65C.js} +2 -2
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.d.cts +100 -41
- package/dist/analytics.d.ts +100 -41
- package/dist/analytics.js +76 -141
- package/dist/artifact-integrity.json +108 -102
- package/dist/assets-2eC3mOcV.js +232 -0
- package/dist/assets-B0Hxn4l6.cjs +1 -0
- package/dist/{auto-DDHflI9v.cjs → auto-B0EZFIK1.cjs} +1 -1
- package/dist/{auto-BIOmtVhk.js → auto-BlchZ1b8.js} +19 -19
- package/dist/{batch-WzDIXJAt.js → batch-DGCt44XM.js} +1 -1
- package/dist/{batch-z6Aw5GEY.cjs → batch-DYcokH4v.cjs} +1 -1
- package/dist/charts-Dlv8j2AG.js +141 -0
- package/dist/charts-aCtoswXq.cjs +1 -0
- package/dist/codes.cjs +9 -9
- package/dist/codes.d.cts +54 -0
- package/dist/codes.d.ts +54 -0
- package/dist/codes.js +12097 -13668
- package/dist/column-visual-BpgQVWwT.js +238 -0
- package/dist/column-visual-CtYxnBCP.cjs +1 -0
- package/dist/component-tree-6TV7W6Yj.cjs +1 -0
- package/dist/component-tree-CvW4lzpv.js +67 -0
- package/dist/computed-4TnxzgIh.cjs +1 -0
- package/dist/computed-C8NRZQss.js +739 -0
- package/dist/data-bar-Ce38juRZ.cjs +1 -0
- package/dist/data-bar-PtjXhMgN.js +9 -0
- package/dist/designer--TKECSEc.cjs +2 -0
- package/dist/designer-d6hJS41w.js +5683 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +710 -42
- package/dist/designer.d.ts +710 -42
- package/dist/designer.js +23 -20
- package/dist/{encoding-BFMFIc4r.cjs → encoding-B--eZpp1.cjs} +1 -1
- package/dist/{encoding-DP_Eaf0A.js → encoding-mctOLocI.js} +2 -2
- package/dist/{font-loader-7FWVlykp.cjs → font-loader-DBBJ5KE9.cjs} +1 -1
- package/dist/{font-loader-CQZowp0I.js → font-loader-DW8tIaNp.js} +1 -1
- package/dist/index-CPh6tqge.js +1575 -0
- package/dist/index-CUNw7dL9.cjs +1 -0
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +361 -15
- package/dist/index.d.ts +361 -15
- package/dist/index.js +876 -835
- package/dist/json-snapshot-By4ZVVUt.js +1967 -0
- package/dist/json-snapshot-jiXff4lc.cjs +2 -0
- package/dist/matrix-0hywp0-F.cjs +1 -0
- package/dist/matrix-Dy-tyY7E.js +381 -0
- package/dist/param-validation-C-8sRJLq.cjs +1 -0
- package/dist/param-validation-CnDEd2l-.js +333 -0
- package/dist/{pdf-l3ea86di.js → pdf-CKROKygt.js} +1851 -1849
- package/dist/{pdf-B8JouyYv.cjs → pdf-DqyxJ96U.cjs} +46 -46
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.d.cts +54 -0
- package/dist/pdf.d.ts +54 -0
- package/dist/pdf.js +2 -2
- package/dist/{plugin-BBp74CQZ.js → plugin-ByjF2kiV.js} +5 -5
- package/dist/{plugin-CtFX9PFG.cjs → plugin-DM1M2wlI.cjs} +1 -1
- package/dist/prefill-B8H9qwE4.js +371 -0
- package/dist/prefill-D7EswyTI.cjs +1 -0
- package/dist/{prepared-CARicKYh.js → prepared-BE-4jfX5.js} +2 -2
- package/dist/{prepared-Ch1x_Gog.cjs → prepared-CGVphji3.cjs} +1 -1
- package/dist/{protocol-B5A2uom4.cjs → protocol-ByRVzzQG.cjs} +1 -1
- package/dist/{protocol-BaiWjq5w.js → protocol-Cr81vFSQ.js} +3 -3
- package/dist/{record-bindings-D4TuMzHs.js → record-bindings-DEJtmo3p.js} +67 -107
- package/dist/record-bindings-ehjnCDHt.cjs +1 -0
- package/dist/{region-binding-workflow-BNasF5kz.js → region-binding-workflow-CBg0l_tj.js} +1 -1
- package/dist/{region-binding-workflow-O2Cni3mF.cjs → region-binding-workflow-D05tOYn3.cjs} +1 -1
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/{report-params-B1RzkhJj.js → report-params-D9tBuM9B.js} +1 -1
- package/dist/{report-params-WDGrA4oP.cjs → report-params-VTg8MoCp.cjs} +1 -1
- package/dist/runtime-CDA6d263.cjs +1 -0
- package/dist/runtime-CEMvybO7.js +170 -0
- package/dist/sbom.cdx.json +1 -1
- package/dist/server/node.d.cts +75 -7
- package/dist/server/node.d.ts +75 -7
- package/dist/server-node.cjs +4 -4
- package/dist/server-node.js +2692 -1990
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +243 -28
- package/dist/server.d.ts +243 -28
- package/dist/server.js +28 -28
- package/dist/sha256-BDQ1Qk7A.js +158 -0
- package/dist/sha256-DgZAKXqI.cjs +1 -0
- package/dist/style.css +1 -1
- package/dist/template-bindings-Cg5oBLFT.cjs +1 -0
- package/dist/template-bindings-TKnXM7ll.js +62 -0
- package/dist/{template-catalog-wT1fNeAP.js → template-catalog-CmbWOJqy.js} +16 -16
- package/dist/{template-catalog-Dua8h9ZA.cjs → template-catalog-Utu4GP09.cjs} +1 -1
- package/dist/{template-fragments-BajTajb4.cjs → template-fragments-C_zSHJAa.cjs} +1 -1
- package/dist/{template-fragments-DmX5XK4N.js → template-fragments-DWgo9tlZ.js} +2 -2
- package/dist/{template-outline-BwRV_eRo.cjs → template-outline-DWkzZXVC.cjs} +1 -1
- package/dist/{template-outline-cnWfT_LK.js → template-outline-DiADphlq.js} +1 -1
- package/dist/{template-registry-u11fPd8D.js → template-registry-BIhIHOab.js} +319 -314
- package/dist/template-registry-DzWswQI5.cjs +1 -0
- package/dist/vue/async.d.cts +528 -33
- package/dist/vue/async.d.ts +528 -33
- package/dist/vue/index.d.cts +616 -64
- package/dist/vue/index.d.ts +616 -64
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +94 -89
- package/dist/{workbook-session-DN5LSA5C.cjs → workbook-session-B94EwVa_.cjs} +1 -1
- package/dist/{workbook-session-B8pNW24X.js → workbook-session-BoScoOg-.js} +2 -2
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +75 -7
- package/dist/worker.d.ts +75 -7
- package/dist/worker.js +4 -4
- package/dist/xlsx.cjs +4 -4
- package/dist/xlsx.d.cts +120 -13
- package/dist/xlsx.d.ts +120 -13
- package/dist/xlsx.js +313 -279
- package/package.json +1 -1
- package/dist/ParamEditor-B5UZRgxv.cjs +0 -1
- package/dist/ParamEditor-DNNARyeB.js +0 -594
- package/dist/ReportBatchPanel-Ctvs2t_9.cjs +0 -1
- package/dist/ReportPreview-BdQawRh0.js +0 -4879
- package/dist/ReportPreview-CJC_-j2I.cjs +0 -6
- package/dist/RuleEditor-DkRjOLlr.js +0 -2141
- package/dist/RuleEditor-h5anGsDB.cjs +0 -1
- package/dist/assets-BIMVwjQe.js +0 -231
- package/dist/assets-Dfs2ElxI.cjs +0 -1
- package/dist/component-tree-Ca6YYfHq.js +0 -61
- package/dist/component-tree-DkGLEfZC.cjs +0 -1
- package/dist/computed-BW5a8QFk.js +0 -612
- package/dist/computed-C2GD3XcE.cjs +0 -1
- package/dist/config-Dg_o8e7m.cjs +0 -1
- package/dist/config-XQ4qrQ7Q.js +0 -844
- package/dist/designer-D9XAxqSc.js +0 -5178
- package/dist/designer-uCDo5XSK.cjs +0 -2
- package/dist/drill-ByN8COs_.cjs +0 -1
- package/dist/drill-CKW3Xtfa.js +0 -145
- package/dist/json-snapshot-D7PE1NsU.cjs +0 -2
- package/dist/json-snapshot-DYmEe3sO.js +0 -1779
- package/dist/matrix-JLAXlux-.js +0 -302
- package/dist/matrix-gTHpDTGm.cjs +0 -1
- package/dist/param-validation-C3HlcLLO.cjs +0 -1
- package/dist/param-validation-Do7Eg8Zv.js +0 -181
- package/dist/record-bindings-B86Sur_y.cjs +0 -1
- package/dist/runtime-DakRXui3.js +0 -170
- package/dist/runtime-dL5ygIfa.cjs +0 -1
- package/dist/sha256-BshdOkCC.cjs +0 -1
- package/dist/sha256-DTG-Gq8i.js +0 -157
- package/dist/template-bindings-C2SpvsMU.js +0 -58
- package/dist/template-bindings-CEtWyiLX.cjs +0 -1
- package/dist/template-registry-CpysHAxy.cjs +0 -1
- package/dist/tree-CLpxYbKa.cjs +0 -1
- package/dist/tree-DNJorJUf.js +0 -172
package/dist/runtime-DakRXui3.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { R as y, I as R, J as X, K as C, F as O, m as z, H as G, L as H, b as K, P as Q, n as Y } from "./json-snapshot-DYmEe3sO.js";
|
|
2
|
-
import { g as M } from "./report-params-B1RzkhJj.js";
|
|
3
|
-
import { d as $, r as Z, R as ee } from "./param-validation-Do7Eg8Zv.js";
|
|
4
|
-
import { t as P, b as x, D as te, v as se, c as T, R as D } from "./sha256-DTG-Gq8i.js";
|
|
5
|
-
import { b as ae } from "./template-registry-u11fPd8D.js";
|
|
6
|
-
import { T as re } from "./tree-DNJorJUf.js";
|
|
7
|
-
import { a as j } from "./assets-BIMVwjQe.js";
|
|
8
|
-
import { s as S, a as J, d as oe, e as ne, r as ce } from "./prepared-CARicKYh.js";
|
|
9
|
-
function I(e = []) {
|
|
10
|
-
return e.map(({ code: s, message: r, severity: c, pageIndex: t, componentIndex: a }) => ({ code: s, message: r, severity: c, path: a < 0 ? `$.pages.${t}` : `$.pages.${t}.components.${a}` }));
|
|
11
|
-
}
|
|
12
|
-
async function _(e, s, r = Date.now()) {
|
|
13
|
-
const c = e.prepared;
|
|
14
|
-
if (e.fidelity === "strict" && c.diagnostics.some((f) => f.code === "asset-render-failed" || f.code === "asset-budget-exceeded")) throw new y("validate", "严格输出拒绝已有资产渲染降级,请修复组件后重新准备报表。");
|
|
15
|
-
const t = e.format === "pdf" ? await import("@agile-team/mach-report/pdf") : void 0;
|
|
16
|
-
P(e.signal);
|
|
17
|
-
const a = e.pdf?.customFontFaces ?? (e.pdf?.customFontBytes ? { regular: e.pdf.customFontBytes } : void 0), l = t && a ? t.createFontBytesMeasurer(a) : void 0, m = R(e), i = await m.run("encode", async () => {
|
|
18
|
-
let f;
|
|
19
|
-
if (e.format === "pdf") {
|
|
20
|
-
P(e.signal);
|
|
21
|
-
const n = await t.renderPlanToPdf(c.plan, { ...e.pdf, ...l ? { measurer: l } : {}, fidelity: e.fidelity, signal: e.signal, onProgress: (g, d) => m.progress("encode", g, d) });
|
|
22
|
-
f = n.bytes, c.diagnostics.push(...I(n.diagnostics)), c.diagnostics.push(...n.fidelityWarnings.map((g) => ({ code: "pdf-fidelity", message: g, severity: "warning" })), ...n.pageErrors.map((g) => ({ code: "pdf-page", message: g, severity: "error" }))), n.unsupportedTextCount && c.diagnostics.push({ code: "pdf-font", message: `${n.unsupportedTextCount} 段文本包含当前字体不支持的字符`, severity: "warning" });
|
|
23
|
-
} else {
|
|
24
|
-
const { renderPlanToXlsx: n } = await import("@agile-team/mach-report/xlsx");
|
|
25
|
-
P(e.signal);
|
|
26
|
-
const g = await n(c.plan, { ...e.xlsx, fidelity: e.fidelity, signal: e.signal, onProgress: (d, v) => m.progress("encode", d, v) });
|
|
27
|
-
f = new Uint8Array(g.buffer), c.diagnostics.push(...I(g.diagnostics)), c.diagnostics.push(...g.warnings.map((d) => ({ code: "xlsx-fidelity", message: d, severity: "warning" })));
|
|
28
|
-
}
|
|
29
|
-
return P(e.signal), f;
|
|
30
|
-
});
|
|
31
|
-
x(s, "maxOutputBytes", i.byteLength);
|
|
32
|
-
const { plan: o, ...w } = c;
|
|
33
|
-
return { ...w, bytes: i, format: e.format, contentType: e.format === "pdf" ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", stats: { ...w.stats, durationMs: Date.now() - r, outputBytes: i.byteLength } };
|
|
34
|
-
}
|
|
35
|
-
function N(e) {
|
|
36
|
-
return { ...e, reportIds: [...e.reportIds], ...e.params ? { params: { ...e.params } } : {} };
|
|
37
|
-
}
|
|
38
|
-
function A(e, s) {
|
|
39
|
-
if (s.length === 0) throw new y("config", "缺少报表 ID");
|
|
40
|
-
return s.map((r) => {
|
|
41
|
-
if (!Object.prototype.hasOwnProperty.call(e, r)) throw new y("config", `未注册报表 ${r}`);
|
|
42
|
-
return e[r];
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function k(e) {
|
|
46
|
-
return e.grid?.cells.reduce((s, r) => s + r.reduce((c, t) => c + (t ? 1 + (t.children?.reduce((a, l) => a + k(l), 0) ?? 0) : 0), 0), 0) ?? 0;
|
|
47
|
-
}
|
|
48
|
-
function ie(e, s, r) {
|
|
49
|
-
return e.pages.reduce((c, t) => c + t.components.reduce((a, l) => l.kind !== "list" ? a + k(l) : a + Y(l, s, r), 0), 0);
|
|
50
|
-
}
|
|
51
|
-
function de(e, s = Object.keys(e)) {
|
|
52
|
-
return A(e, s).map((r, c) => {
|
|
53
|
-
const t = s[c], a = M(e, [t]);
|
|
54
|
-
return {
|
|
55
|
-
id: t,
|
|
56
|
-
params: JSON.parse(JSON.stringify(a)),
|
|
57
|
-
paramsSchema: Z(a),
|
|
58
|
-
datasetsSchema: Object.fromEntries(Object.entries(r.dataSchema ?? {}).map(([l, m]) => [l, X(typeof r.template == "function" ? void 0 : r.template, l, m)])),
|
|
59
|
-
capabilities: {
|
|
60
|
-
save: !!r.provider?.save,
|
|
61
|
-
export: !!r.provider?.export,
|
|
62
|
-
templates: !!r.provider?.templates
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
function U(e, s) {
|
|
68
|
-
A(e, s.reportIds);
|
|
69
|
-
const r = $(M(e, s.reportIds), s.params), c = s.reportIds.flatMap((a) => $(M(e, [a]), s.params).issues), t = new Map(c.map((a) => [JSON.stringify(a), a]));
|
|
70
|
-
return { ...r, ok: t.size === 0, issues: [...t.values()] };
|
|
71
|
-
}
|
|
72
|
-
function V(e, s) {
|
|
73
|
-
const r = ae(e.plan);
|
|
74
|
-
if (!r.ok) throw new y("validate", `执行器返回无效计划:${r.errors[0]?.path}`);
|
|
75
|
-
const c = e.plan.pages.length, t = e.plan.pages.reduce((a, l) => a + l.components.reduce((m, i) => m + k(i), 0), 0);
|
|
76
|
-
return x(s, "maxRows", e.stats.rows), x(s, "maxPages", c), x(s, "maxCells", t), { ...e, stats: { ...e.stats, pages: c, cells: t } };
|
|
77
|
-
}
|
|
78
|
-
function q(e, s) {
|
|
79
|
-
const r = U(e.reports, s);
|
|
80
|
-
if (!r.ok) throw new ee(r.issues);
|
|
81
|
-
}
|
|
82
|
-
function ye(e) {
|
|
83
|
-
const s = { ...te, ...e.budget };
|
|
84
|
-
se(s);
|
|
85
|
-
const r = async (t, a) => {
|
|
86
|
-
const l = Date.now();
|
|
87
|
-
let m = 0, i = 0;
|
|
88
|
-
const o = [], w = {}, f = [], n = Object.fromEntries(Object.entries(e.reports).map(([p, u]) => [p, {
|
|
89
|
-
...u,
|
|
90
|
-
pagination: { ...e.pagination, ...u.pagination, ...a ? { measurer: a } : {} },
|
|
91
|
-
dataValidation: {
|
|
92
|
-
...u.dataValidation,
|
|
93
|
-
maxRows: Math.min(s.maxRows ?? 1e5, u.dataValidation?.maxRows ?? 1 / 0),
|
|
94
|
-
maxCells: Math.min(s.maxCells ?? 2e6, u.dataValidation?.maxCells ?? 1 / 0)
|
|
95
|
-
}
|
|
96
|
-
}])), d = await z(n, { maxPages: s.maxPages, maxCells: s.maxCells, onDatasets: (p, u, h) => {
|
|
97
|
-
try {
|
|
98
|
-
m += G(h, u, { maxRows: s.maxRows, signal: t.signal });
|
|
99
|
-
} catch (b) {
|
|
100
|
-
throw b instanceof re ? new D("budget", b.message, "$.budget.maxRows") : b;
|
|
101
|
-
}
|
|
102
|
-
x(s, "maxRows", m), i += ie(h, u, n[p]?.pagination), x(s, "maxCells", i);
|
|
103
|
-
} })({ ...t, params: t.params ?? {}, onWarning: (p) => o.push({ code: "layout", message: p, severity: "warning" }), onQueryResult: (p, u, h = 0) => {
|
|
104
|
-
const b = H(h, p);
|
|
105
|
-
Object.defineProperty(w, p, { value: { revision: u.revision, sourceToken: u.sourceToken }, enumerable: !0, writable: !0 }), f.push({ reportId: p, reportIndex: h, reportScope: b, ...u.revision === void 0 ? {} : { revision: u.revision }, ...u.sourceToken === void 0 ? {} : { sourceToken: u.sourceToken } }), o.push(...(u.diagnostics ?? []).map((F) => ({ ...F, ...F.target ? { target: {
|
|
106
|
-
...F.target,
|
|
107
|
-
reportScope: b,
|
|
108
|
-
...F.target.tableId ? { tableId: JSON.stringify([h, p, F.target.tableId]) } : {}
|
|
109
|
-
} } : {} })));
|
|
110
|
-
} }).catch((p) => {
|
|
111
|
-
throw p instanceof y && p.cause instanceof K ? new D("budget", p.cause.message, "$.budget.maxPages") : p instanceof y && p.cause instanceof Q ? new D("budget", p.cause.message, "$.budget.maxCells") : p;
|
|
112
|
-
});
|
|
113
|
-
P(t.signal);
|
|
114
|
-
const v = e.assets ? await R(t).run("assets", () => j(d, { ...e.assets, signal: t.signal })) : { plan: d, diagnostics: [] }, E = v.plan;
|
|
115
|
-
o.push(...I(v.diagnostics));
|
|
116
|
-
const L = E.pages.reduce((p, u) => p + u.components.reduce((h, b) => h + k(b), 0), 0);
|
|
117
|
-
x(s, "maxPages", E.pages.length), x(s, "maxCells", L);
|
|
118
|
-
const B = ce(t.pdf), W = e.pagination?.measurer || Object.values(e.reports).some((p) => p.pagination?.measurer);
|
|
119
|
-
return { plan: E, diagnostics: o, revisions: w, sources: f, layout: { textMetrics: B ? "font-bytes" : W ? "provided" : "heuristic", ...B ? { fontFingerprint: B } : {} }, stats: { rows: m, pages: E.pages.length, cells: L, durationMs: Date.now() - l } };
|
|
120
|
-
}, c = async (t) => {
|
|
121
|
-
const a = Date.now();
|
|
122
|
-
if (t.format !== "pdf" && t.format !== "xlsx") throw new y("config", "不支持的报表导出格式");
|
|
123
|
-
const l = t.format === "pdf" ? await import("@agile-team/mach-report/pdf") : void 0;
|
|
124
|
-
P(t.signal);
|
|
125
|
-
const m = t.pdf?.customFontFaces ?? (t.pdf?.customFontBytes ? { regular: t.pdf.customFontBytes } : void 0), i = l && m ? l.createFontBytesMeasurer(m) : void 0, o = await r(t, i);
|
|
126
|
-
return P(t.signal), _({ ...t, prepared: o }, s, a);
|
|
127
|
-
};
|
|
128
|
-
return {
|
|
129
|
-
describe: (t) => de(e.reports, t),
|
|
130
|
-
validate: (t) => U(e.reports, t),
|
|
131
|
-
prepare: (t) => T(t.signal, s.maxDurationMs, async (a) => {
|
|
132
|
-
const { signal: l, onEvent: m, ...i } = N(t), o = { ...i, ...i.pdf ? { pdf: S(i.pdf) } : {}, taskId: i.taskId ?? C() }, w = m ? (v) => O(m, v, a) : void 0, f = { ...o, signal: a, onEvent: w };
|
|
133
|
-
R(f).runSync("validate", () => q(e, o));
|
|
134
|
-
let n;
|
|
135
|
-
const g = o.pdf?.customFontFaces ?? (o.pdf?.customFontBytes ? { regular: o.pdf.customFontBytes } : void 0);
|
|
136
|
-
if (!e.executor && g) {
|
|
137
|
-
const v = await import("@agile-team/mach-report/pdf");
|
|
138
|
-
P(a), n = v.createFontBytesMeasurer(g);
|
|
139
|
-
}
|
|
140
|
-
const d = e.executor ? await e.executor.prepare(o, a, w) : await r(f, n);
|
|
141
|
-
return V(d, s);
|
|
142
|
-
}),
|
|
143
|
-
exportPrepared: (t) => T(t.signal, s.maxDurationMs, async (a) => {
|
|
144
|
-
const l = Date.now(), { signal: m, onEvent: i, ...o } = t, w = V(oe(t.prepared, s.maxPreparedBytes ?? 64e6, a), s), f = { ...o, xlsx: J(o.xlsx), prepared: w, ...o.pdf ? { pdf: S(o.pdf) } : {}, taskId: o.taskId ?? C() };
|
|
145
|
-
if (f.format !== "pdf" && f.format !== "xlsx") throw new y("config", "不支持的报表导出格式");
|
|
146
|
-
const n = i ? (d) => O(i, d, a) : void 0;
|
|
147
|
-
if (e.executor) {
|
|
148
|
-
if (!e.executor.exportPrepared) throw new y("config", "执行器未实现 exportPrepared;请升级执行器或显式使用本地运行时");
|
|
149
|
-
const d = await e.executor.exportPrepared(f, a, n);
|
|
150
|
-
return x(s, "maxRows", d.stats.rows), x(s, "maxPages", d.stats.pages), x(s, "maxCells", d.stats.cells), x(s, "maxOutputBytes", d.bytes.byteLength), { ...d, stats: { ...d.stats, outputBytes: d.bytes.byteLength } };
|
|
151
|
-
}
|
|
152
|
-
const g = { ...f, signal: a, onEvent: n };
|
|
153
|
-
if (R(g).runSync("validate", () => ne(g)), e.assets) {
|
|
154
|
-
const d = await R(g).run("assets", () => j(w.plan, { ...e.assets, signal: a }));
|
|
155
|
-
w.plan = d.plan, w.diagnostics.push(...I(d.diagnostics));
|
|
156
|
-
}
|
|
157
|
-
return _(g, s, l);
|
|
158
|
-
}),
|
|
159
|
-
export: (t) => T(t.signal, s.maxDurationMs, async (a) => {
|
|
160
|
-
const { signal: l, onEvent: m, ...i } = N(t), o = { ...i, xlsx: J(i.xlsx), ...i.pdf ? { pdf: S(i.pdf) } : {}, taskId: i.taskId ?? C() }, w = m ? (g) => O(m, g, a) : void 0, f = { ...o, signal: a, onEvent: w };
|
|
161
|
-
if (R(f).runSync("validate", () => q(e, o)), o.format !== "pdf" && o.format !== "xlsx") throw new y("config", "不支持的报表导出格式");
|
|
162
|
-
const n = e.executor ? await e.executor.export(o, a, w) : await c(f);
|
|
163
|
-
return x(s, "maxRows", n.stats.rows), x(s, "maxPages", n.stats.pages), x(s, "maxCells", n.stats.cells), x(s, "maxOutputBytes", n.bytes.byteLength), { ...n, stats: { ...n.stats, outputBytes: n.bytes.byteLength } };
|
|
164
|
-
})
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
export {
|
|
168
|
-
ye as c,
|
|
169
|
-
V as e
|
|
170
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var J=Object.create;var D=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var W=(e,t,a,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of N(t))!X.call(e,s)&&s!==a&&D(e,s,{get:()=>t[s],enumerable:!(c=V(t,s))||c.enumerable});return e};var E=(e,t,a)=>(a=e!=null?J(U(e)):{},W(t||!e||!e.__esModule?D(a,"default",{value:e,enumerable:!0}):a,e));const n=require("./json-snapshot-D7PE1NsU.cjs"),F=require("./report-params-WDGrA4oP.cjs"),k=require("./param-validation-C3HlcLLO.cjs"),o=require("./sha256-BshdOkCC.cjs"),z=require("./template-registry-CpysHAxy.cjs"),G=require("./tree-CLpxYbKa.cjs"),M=require("./assets-Dfs2ElxI.cjs"),b=require("./prepared-Ch1x_Gog.cjs");function I(e=[]){return e.map(({code:t,message:a,severity:c,pageIndex:s,componentIndex:r})=>({code:t,message:a,severity:c,path:r<0?`$.pages.${s}`:`$.pages.${s}.components.${r}`}))}async function q(e,t,a=Date.now()){const c=e.prepared;if(e.fidelity==="strict"&&c.diagnostics.some(f=>f.code==="asset-render-failed"||f.code==="asset-budget-exceeded"))throw new n.ReportSourceError("validate","严格输出拒绝已有资产渲染降级,请修复组件后重新准备报表。");const s=e.format==="pdf"?await import("@agile-team/mach-report/pdf"):void 0;o.throwIfAborted(e.signal);const r=e.pdf?.customFontFaces??(e.pdf?.customFontBytes?{regular:e.pdf.customFontBytes}:void 0),u=s&&r?s.createFontBytesMeasurer(r):void 0,m=n.createReportTaskReporter(e),p=await m.run("encode",async()=>{let f;if(e.format==="pdf"){o.throwIfAborted(e.signal);const i=await s.renderPlanToPdf(c.plan,{...e.pdf,...u?{measurer:u}:{},fidelity:e.fidelity,signal:e.signal,onProgress:(w,l)=>m.progress("encode",w,l)});f=i.bytes,c.diagnostics.push(...I(i.diagnostics)),c.diagnostics.push(...i.fidelityWarnings.map(w=>({code:"pdf-fidelity",message:w,severity:"warning"})),...i.pageErrors.map(w=>({code:"pdf-page",message:w,severity:"error"}))),i.unsupportedTextCount&&c.diagnostics.push({code:"pdf-font",message:`${i.unsupportedTextCount} 段文本包含当前字体不支持的字符`,severity:"warning"})}else{const{renderPlanToXlsx:i}=await import("@agile-team/mach-report/xlsx");o.throwIfAborted(e.signal);const w=await i(c.plan,{...e.xlsx,fidelity:e.fidelity,signal:e.signal,onProgress:(l,h)=>m.progress("encode",l,h)});f=new Uint8Array(w.buffer),c.diagnostics.push(...I(w.diagnostics)),c.diagnostics.push(...w.warnings.map(l=>({code:"xlsx-fidelity",message:l,severity:"warning"})))}return o.throwIfAborted(e.signal),f});o.assertBudget(t,"maxOutputBytes",p.byteLength);const{plan:d,...y}=c;return{...y,bytes:p,format:e.format,contentType:e.format==="pdf"?"application/pdf":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",stats:{...y.stats,durationMs:Date.now()-a,outputBytes:p.byteLength}}}function A(e){return{...e,reportIds:[...e.reportIds],...e.params?{params:{...e.params}}:{}}}function $(e,t){if(t.length===0)throw new n.ReportSourceError("config","缺少报表 ID");return t.map(a=>{if(!Object.prototype.hasOwnProperty.call(e,a))throw new n.ReportSourceError("config",`未注册报表 ${a}`);return e[a]})}function T(e){return e.grid?.cells.reduce((t,a)=>t+a.reduce((c,s)=>c+(s?1+(s.children?.reduce((r,u)=>r+T(u),0)??0):0),0),0)??0}function Q(e,t,a){return e.pages.reduce((c,s)=>c+s.components.reduce((r,u)=>u.kind!=="list"?r+T(u):r+n.estimateListLayoutCells(u,t,a),0),0)}function H(e,t=Object.keys(e)){return $(e,t).map((a,c)=>{const s=t[c],r=F.getReportParamDefs(e,[s]);return{id:s,params:JSON.parse(JSON.stringify(r)),paramsSchema:k.reportParamsJsonSchema(r),datasetsSchema:Object.fromEntries(Object.entries(a.dataSchema??{}).map(([u,m])=>[u,n.templateDatasetJsonSchema(typeof a.template=="function"?void 0:a.template,u,m)])),capabilities:{save:!!a.provider?.save,export:!!a.provider?.export,templates:!!a.provider?.templates}}})}function j(e,t){$(e,t.reportIds);const a=k.validateReportParams(F.getReportParamDefs(e,t.reportIds),t.params),c=t.reportIds.flatMap(r=>k.validateReportParams(F.getReportParamDefs(e,[r]),t.params).issues),s=new Map(c.map(r=>[JSON.stringify(r),r]));return{...a,ok:s.size===0,issues:[...s.values()]}}function O(e,t){const a=z.validateRenderPlan(e.plan);if(!a.ok)throw new n.ReportSourceError("validate",`执行器返回无效计划:${a.errors[0]?.path}`);const c=e.plan.pages.length,s=e.plan.pages.reduce((r,u)=>r+u.components.reduce((m,p)=>m+T(p),0),0);return o.assertBudget(t,"maxRows",e.stats.rows),o.assertBudget(t,"maxPages",c),o.assertBudget(t,"maxCells",s),{...e,stats:{...e.stats,pages:c,cells:s}}}function L(e,t){const a=j(e.reports,t);if(!a.ok)throw new k.ReportParamValidationError(a.issues)}function K(e){const t={...o.DEFAULT_REPORT_RUNTIME_BUDGET,...e.budget};o.validateBudget(t);const a=async(s,r)=>{const u=Date.now();let m=0,p=0;const d=[],y={},f=[],i=Object.fromEntries(Object.entries(e.reports).map(([g,x])=>[g,{...x,pagination:{...e.pagination,...x.pagination,...r?{measurer:r}:{}},dataValidation:{...x.dataValidation,maxRows:Math.min(t.maxRows??1e5,x.dataValidation?.maxRows??1/0),maxCells:Math.min(t.maxCells??2e6,x.dataValidation?.maxCells??1/0)}}])),l=await n.createReportSource(i,{maxPages:t.maxPages,maxCells:t.maxCells,onDatasets:(g,x,v)=>{try{m+=n.templateDatasetRowCount(v,x,{maxRows:t.maxRows,signal:s.signal})}catch(R){throw R instanceof G.TreeRowLimitError?new o.ReportRuntimeError("budget",R.message,"$.budget.maxRows"):R}o.assertBudget(t,"maxRows",m),p+=Q(v,x,i[g]?.pagination),o.assertBudget(t,"maxCells",p)}})({...s,params:s.params??{},onWarning:g=>d.push({code:"layout",message:g,severity:"warning"}),onQueryResult:(g,x,v=0)=>{const R=n.reportOccurrenceScope(v,g);Object.defineProperty(y,g,{value:{revision:x.revision,sourceToken:x.sourceToken},enumerable:!0,writable:!0}),f.push({reportId:g,reportIndex:v,reportScope:R,...x.revision===void 0?{}:{revision:x.revision},...x.sourceToken===void 0?{}:{sourceToken:x.sourceToken}}),d.push(...(x.diagnostics??[]).map(P=>({...P,...P.target?{target:{...P.target,reportScope:R,...P.target.tableId?{tableId:JSON.stringify([v,g,P.target.tableId])}:{}}}:{}})))}}).catch(g=>{throw g instanceof n.ReportSourceError&&g.cause instanceof n.PaginatePageLimitError?new o.ReportRuntimeError("budget",g.cause.message,"$.budget.maxPages"):g instanceof n.ReportSourceError&&g.cause instanceof n.PaginateCellLimitError?new o.ReportRuntimeError("budget",g.cause.message,"$.budget.maxCells"):g});o.throwIfAborted(s.signal);const h=e.assets?await n.createReportTaskReporter(s).run("assets",()=>M.resolvePlanAssets(l,{...e.assets,signal:s.signal})):{plan:l,diagnostics:[]},B=h.plan;d.push(...I(h.diagnostics));const C=B.pages.reduce((g,x)=>g+x.components.reduce((v,R)=>v+T(R),0),0);o.assertBudget(t,"maxPages",B.pages.length),o.assertBudget(t,"maxCells",C);const S=b.reportFontFingerprint(s.pdf),_=e.pagination?.measurer||Object.values(e.reports).some(g=>g.pagination?.measurer);return{plan:B,diagnostics:d,revisions:y,sources:f,layout:{textMetrics:S?"font-bytes":_?"provided":"heuristic",...S?{fontFingerprint:S}:{}},stats:{rows:m,pages:B.pages.length,cells:C,durationMs:Date.now()-u}}},c=async s=>{const r=Date.now();if(s.format!=="pdf"&&s.format!=="xlsx")throw new n.ReportSourceError("config","不支持的报表导出格式");const u=s.format==="pdf"?await import("@agile-team/mach-report/pdf"):void 0;o.throwIfAborted(s.signal);const m=s.pdf?.customFontFaces??(s.pdf?.customFontBytes?{regular:s.pdf.customFontBytes}:void 0),p=u&&m?u.createFontBytesMeasurer(m):void 0,d=await a(s,p);return o.throwIfAborted(s.signal),q({...s,prepared:d},t,r)};return{describe:s=>H(e.reports,s),validate:s=>j(e.reports,s),prepare:s=>o.controlled(s.signal,t.maxDurationMs,async r=>{const{signal:u,onEvent:m,...p}=A(s),d={...p,...p.pdf?{pdf:b.snapshotPdfFonts(p.pdf)}:{},taskId:p.taskId??n.reportTaskId()},y=m?h=>n.notifyReportTaskEvent(m,h,r):void 0,f={...d,signal:r,onEvent:y};n.createReportTaskReporter(f).runSync("validate",()=>L(e,d));let i;const w=d.pdf?.customFontFaces??(d.pdf?.customFontBytes?{regular:d.pdf.customFontBytes}:void 0);if(!e.executor&&w){const h=await import("@agile-team/mach-report/pdf");o.throwIfAborted(r),i=h.createFontBytesMeasurer(w)}const l=e.executor?await e.executor.prepare(d,r,y):await a(f,i);return O(l,t)}),exportPrepared:s=>o.controlled(s.signal,t.maxDurationMs,async r=>{const u=Date.now(),{signal:m,onEvent:p,...d}=s,y=O(b.snapshotPreparedReport(s.prepared,t.maxPreparedBytes??64e6,r),t),f={...d,xlsx:b.snapshotXlsxOptions(d.xlsx),prepared:y,...d.pdf?{pdf:b.snapshotPdfFonts(d.pdf)}:{},taskId:d.taskId??n.reportTaskId()};if(f.format!=="pdf"&&f.format!=="xlsx")throw new n.ReportSourceError("config","不支持的报表导出格式");const i=p?l=>n.notifyReportTaskEvent(p,l,r):void 0;if(e.executor){if(!e.executor.exportPrepared)throw new n.ReportSourceError("config","执行器未实现 exportPrepared;请升级执行器或显式使用本地运行时");const l=await e.executor.exportPrepared(f,r,i);return o.assertBudget(t,"maxRows",l.stats.rows),o.assertBudget(t,"maxPages",l.stats.pages),o.assertBudget(t,"maxCells",l.stats.cells),o.assertBudget(t,"maxOutputBytes",l.bytes.byteLength),{...l,stats:{...l.stats,outputBytes:l.bytes.byteLength}}}const w={...f,signal:r,onEvent:i};if(n.createReportTaskReporter(w).runSync("validate",()=>b.checkPreparedFont(w)),e.assets){const l=await n.createReportTaskReporter(w).run("assets",()=>M.resolvePlanAssets(y.plan,{...e.assets,signal:r}));y.plan=l.plan,y.diagnostics.push(...I(l.diagnostics))}return q(w,t,u)}),export:s=>o.controlled(s.signal,t.maxDurationMs,async r=>{const{signal:u,onEvent:m,...p}=A(s),d={...p,xlsx:b.snapshotXlsxOptions(p.xlsx),...p.pdf?{pdf:b.snapshotPdfFonts(p.pdf)}:{},taskId:p.taskId??n.reportTaskId()},y=m?w=>n.notifyReportTaskEvent(m,w,r):void 0,f={...d,signal:r,onEvent:y};if(n.createReportTaskReporter(f).runSync("validate",()=>L(e,d)),d.format!=="pdf"&&d.format!=="xlsx")throw new n.ReportSourceError("config","不支持的报表导出格式");const i=e.executor?await e.executor.export(d,r,y):await c(f);return o.assertBudget(t,"maxRows",i.stats.rows),o.assertBudget(t,"maxPages",i.stats.pages),o.assertBudget(t,"maxCells",i.stats.cells),o.assertBudget(t,"maxOutputBytes",i.bytes.byteLength),{...i,stats:{...i.stats,outputBytes:i.bytes.byteLength}}})}}exports.createReportRuntime=K;exports.enforcePrepared=O;
|
package/dist/sha256-BshdOkCC.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const R=Object.freeze({maxRows:1e5,maxPages:1e4,maxCells:2e6,maxOutputBytes:1e8,maxPreparedBytes:64e6,maxDurationMs:12e4});class f extends Error{constructor(t,r,n){super(r),this.code=t,this.path=n,this.name="ReportRuntimeError"}}function l(e){if(!e?.aborted)return;if(e.reason instanceof f)throw e.reason;const t=new Error("报表执行已取消");throw t.name="AbortError",Object.defineProperty(t,"cause",{value:e.reason}),t}function D(e,t,r){if(!Number.isFinite(r)||r<0)throw new f("budget",`${t} 的执行统计无效`,`$.budget.${t}`);const n=e[t];if(n!==void 0&&r>n)throw new f("budget",`${t} 超出预算 ${n}(实际 ${r})`,`$.budget.${t}`)}function p(e){for(const[t,r]of Object.entries(e)){if(r!==void 0&&(!Number.isFinite(r)||r<=0))throw new f("budget",`${t} 应为正有限数字`,`$.budget.${t}`);if(t!=="maxDurationMs"&&r!==void 0&&!Number.isSafeInteger(r))throw new f("budget",`${t} 应为正安全整数`,`$.budget.${t}`);if(t==="maxDurationMs"&&r!==void 0&&r>2147483647)throw new f("budget","maxDurationMs 不能超过 2147483647",`$.budget.${t}`)}}async function T(e,t,r){const n=new AbortController,o=()=>n.abort(e?.reason);e?.addEventListener("abort",o,{once:!0}),e?.aborted&&o();const s=Date.now(),i=t===void 0?void 0:setTimeout(()=>n.abort(new f("timeout",`报表执行超过 ${t}ms`)),t);let a;try{l(n.signal);const d=new Promise((u,m)=>{a=()=>{try{l(n.signal)}catch(w){m(w)}},n.signal.addEventListener("abort",a,{once:!0})}),b=await Promise.race([r(n.signal),d]);if(l(n.signal),t!==void 0&&Date.now()-s>t)throw new f("timeout",`报表执行超过 ${t}ms`);return b}finally{i!==void 0&&clearTimeout(i),a&&n.signal.removeEventListener("abort",a),e?.removeEventListener("abort",o)}}const L=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),c=(e,t)=>e>>>t|e<<32-t;function h(e,t,r){const n=new DataView(e.buffer,e.byteOffset+t,64);for(let o=0;o<16;o++)r[o]=n.getUint32(o*4);for(let o=16;o<64;o++){const s=r[o-15],i=r[o-2],a=c(s,7)^c(s,18)^s>>>3,d=c(i,17)^c(i,19)^i>>>10;r[o]=r[o-16]+a+r[o-7]+d}}function v(e,t){let r=e[0],n=e[1],o=e[2],s=e[3],i=e[4],a=e[5],d=e[6],b=e[7];for(let u=0;u<64;u++){const m=c(i,6)^c(i,11)^c(i,25),w=i&a^~i&d,g=b+m+w+L[u]+t[u]>>>0,$=c(r,2)^c(r,13)^c(r,22),A=r&n^r&o^n&o,U=$+A>>>0;b=d,d=a,a=i,i=s+g>>>0,s=o,o=n,n=r,r=g+U>>>0}e[0]=e[0]+r,e[1]=e[1]+n,e[2]=e[2]+o,e[3]=e[3]+s,e[4]=e[4]+i,e[5]=e[5]+a,e[6]=e[6]+d,e[7]=e[7]+b}function y(e){const t=new Uint8Array(Math.ceil((e.byteLength+9)/64)*64);t.set(e),t[e.byteLength]=128;const r=new DataView(t.buffer);return r.setUint32(t.length-8,Math.floor(e.byteLength/536870912)),r.setUint32(t.length-4,e.byteLength*8>>>0),t}const x=()=>new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),E=e=>Array.from(e,t=>t.toString(16).padStart(8,"0")).join("");function B(e){const t=y(e),r=x(),n=new Uint32Array(64);for(let o=0;o<t.length;o+=64)h(t,o,n),v(r,n);return E(r)}async function O(e){const t=y(e),r=x(),n=new Uint32Array(64);for(let o=0;o<t.length;o+=64)o>0&&o%262144===0&&await new Promise(s=>setTimeout(s,0)),h(t,o,n),v(r,n);return E(r)}exports.DEFAULT_REPORT_RUNTIME_BUDGET=R;exports.ReportRuntimeError=f;exports.assertBudget=D;exports.controlled=T;exports.portableSha256Hex=B;exports.portableSha256HexAsync=O;exports.throwIfAborted=l;exports.validateBudget=p;
|
package/dist/sha256-DTG-Gq8i.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
const p = Object.freeze({ maxRows: 1e5, maxPages: 1e4, maxCells: 2e6, maxOutputBytes: 1e8, maxPreparedBytes: 64e6, maxDurationMs: 12e4 });
|
|
2
|
-
class d extends Error {
|
|
3
|
-
constructor(t, r, o) {
|
|
4
|
-
super(r), this.code = t, this.path = o, this.name = "ReportRuntimeError";
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
function w(e) {
|
|
8
|
-
if (!e?.aborted) return;
|
|
9
|
-
if (e.reason instanceof d) throw e.reason;
|
|
10
|
-
const t = new Error("报表执行已取消");
|
|
11
|
-
throw t.name = "AbortError", Object.defineProperty(t, "cause", { value: e.reason }), t;
|
|
12
|
-
}
|
|
13
|
-
function R(e, t, r) {
|
|
14
|
-
if (!Number.isFinite(r) || r < 0) throw new d("budget", `${t} 的执行统计无效`, `$.budget.${t}`);
|
|
15
|
-
const o = e[t];
|
|
16
|
-
if (o !== void 0 && r > o) throw new d("budget", `${t} 超出预算 ${o}(实际 ${r})`, `$.budget.${t}`);
|
|
17
|
-
}
|
|
18
|
-
function L(e) {
|
|
19
|
-
for (const [t, r] of Object.entries(e)) {
|
|
20
|
-
if (r !== void 0 && (!Number.isFinite(r) || r <= 0)) throw new d("budget", `${t} 应为正有限数字`, `$.budget.${t}`);
|
|
21
|
-
if (t !== "maxDurationMs" && r !== void 0 && !Number.isSafeInteger(r)) throw new d("budget", `${t} 应为正安全整数`, `$.budget.${t}`);
|
|
22
|
-
if (t === "maxDurationMs" && r !== void 0 && r > 2147483647) throw new d("budget", "maxDurationMs 不能超过 2147483647", `$.budget.${t}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
async function O(e, t, r) {
|
|
26
|
-
const o = new AbortController(), n = () => o.abort(e?.reason);
|
|
27
|
-
e?.addEventListener("abort", n, { once: !0 }), e?.aborted && n();
|
|
28
|
-
const s = Date.now(), i = t === void 0 ? void 0 : setTimeout(() => o.abort(new d("timeout", `报表执行超过 ${t}ms`)), t);
|
|
29
|
-
let a;
|
|
30
|
-
try {
|
|
31
|
-
w(o.signal);
|
|
32
|
-
const f = new Promise((u, m) => {
|
|
33
|
-
a = () => {
|
|
34
|
-
try {
|
|
35
|
-
w(o.signal);
|
|
36
|
-
} catch (l) {
|
|
37
|
-
m(l);
|
|
38
|
-
}
|
|
39
|
-
}, o.signal.addEventListener("abort", a, { once: !0 });
|
|
40
|
-
}), b = await Promise.race([r(o.signal), f]);
|
|
41
|
-
if (w(o.signal), t !== void 0 && Date.now() - s > t) throw new d("timeout", `报表执行超过 ${t}ms`);
|
|
42
|
-
return b;
|
|
43
|
-
} finally {
|
|
44
|
-
i !== void 0 && clearTimeout(i), a && o.signal.removeEventListener("abort", a), e?.removeEventListener("abort", n);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const U = new Uint32Array([
|
|
48
|
-
1116352408,
|
|
49
|
-
1899447441,
|
|
50
|
-
3049323471,
|
|
51
|
-
3921009573,
|
|
52
|
-
961987163,
|
|
53
|
-
1508970993,
|
|
54
|
-
2453635748,
|
|
55
|
-
2870763221,
|
|
56
|
-
3624381080,
|
|
57
|
-
310598401,
|
|
58
|
-
607225278,
|
|
59
|
-
1426881987,
|
|
60
|
-
1925078388,
|
|
61
|
-
2162078206,
|
|
62
|
-
2614888103,
|
|
63
|
-
3248222580,
|
|
64
|
-
3835390401,
|
|
65
|
-
4022224774,
|
|
66
|
-
264347078,
|
|
67
|
-
604807628,
|
|
68
|
-
770255983,
|
|
69
|
-
1249150122,
|
|
70
|
-
1555081692,
|
|
71
|
-
1996064986,
|
|
72
|
-
2554220882,
|
|
73
|
-
2821834349,
|
|
74
|
-
2952996808,
|
|
75
|
-
3210313671,
|
|
76
|
-
3336571891,
|
|
77
|
-
3584528711,
|
|
78
|
-
113926993,
|
|
79
|
-
338241895,
|
|
80
|
-
666307205,
|
|
81
|
-
773529912,
|
|
82
|
-
1294757372,
|
|
83
|
-
1396182291,
|
|
84
|
-
1695183700,
|
|
85
|
-
1986661051,
|
|
86
|
-
2177026350,
|
|
87
|
-
2456956037,
|
|
88
|
-
2730485921,
|
|
89
|
-
2820302411,
|
|
90
|
-
3259730800,
|
|
91
|
-
3345764771,
|
|
92
|
-
3516065817,
|
|
93
|
-
3600352804,
|
|
94
|
-
4094571909,
|
|
95
|
-
275423344,
|
|
96
|
-
430227734,
|
|
97
|
-
506948616,
|
|
98
|
-
659060556,
|
|
99
|
-
883997877,
|
|
100
|
-
958139571,
|
|
101
|
-
1322822218,
|
|
102
|
-
1537002063,
|
|
103
|
-
1747873779,
|
|
104
|
-
1955562222,
|
|
105
|
-
2024104815,
|
|
106
|
-
2227730452,
|
|
107
|
-
2361852424,
|
|
108
|
-
2428436474,
|
|
109
|
-
2756734187,
|
|
110
|
-
3204031479,
|
|
111
|
-
3329325298
|
|
112
|
-
]), c = (e, t) => e >>> t | e << 32 - t;
|
|
113
|
-
function h(e, t, r) {
|
|
114
|
-
const o = new DataView(e.buffer, e.byteOffset + t, 64);
|
|
115
|
-
for (let n = 0; n < 16; n++) r[n] = o.getUint32(n * 4);
|
|
116
|
-
for (let n = 16; n < 64; n++) {
|
|
117
|
-
const s = r[n - 15], i = r[n - 2], a = c(s, 7) ^ c(s, 18) ^ s >>> 3, f = c(i, 17) ^ c(i, 19) ^ i >>> 10;
|
|
118
|
-
r[n] = r[n - 16] + a + r[n - 7] + f;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
function v(e, t) {
|
|
122
|
-
let r = e[0], o = e[1], n = e[2], s = e[3], i = e[4], a = e[5], f = e[6], b = e[7];
|
|
123
|
-
for (let u = 0; u < 64; u++) {
|
|
124
|
-
const m = c(i, 6) ^ c(i, 11) ^ c(i, 25), l = i & a ^ ~i & f, g = b + m + l + U[u] + t[u] >>> 0, A = c(r, 2) ^ c(r, 13) ^ c(r, 22), E = r & o ^ r & n ^ o & n, D = A + E >>> 0;
|
|
125
|
-
b = f, f = a, a = i, i = s + g >>> 0, s = n, n = o, o = r, r = g + D >>> 0;
|
|
126
|
-
}
|
|
127
|
-
e[0] = e[0] + r, e[1] = e[1] + o, e[2] = e[2] + n, e[3] = e[3] + s, e[4] = e[4] + i, e[5] = e[5] + a, e[6] = e[6] + f, e[7] = e[7] + b;
|
|
128
|
-
}
|
|
129
|
-
function y(e) {
|
|
130
|
-
const t = new Uint8Array(Math.ceil((e.byteLength + 9) / 64) * 64);
|
|
131
|
-
t.set(e), t[e.byteLength] = 128;
|
|
132
|
-
const r = new DataView(t.buffer);
|
|
133
|
-
return r.setUint32(t.length - 8, Math.floor(e.byteLength / 536870912)), r.setUint32(t.length - 4, e.byteLength * 8 >>> 0), t;
|
|
134
|
-
}
|
|
135
|
-
const $ = () => new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]), x = (e) => Array.from(e, (t) => t.toString(16).padStart(8, "0")).join("");
|
|
136
|
-
function P(e) {
|
|
137
|
-
const t = y(e), r = $(), o = new Uint32Array(64);
|
|
138
|
-
for (let n = 0; n < t.length; n += 64)
|
|
139
|
-
h(t, n, o), v(r, o);
|
|
140
|
-
return x(r);
|
|
141
|
-
}
|
|
142
|
-
async function T(e) {
|
|
143
|
-
const t = y(e), r = $(), o = new Uint32Array(64);
|
|
144
|
-
for (let n = 0; n < t.length; n += 64)
|
|
145
|
-
n > 0 && n % 262144 === 0 && await new Promise((s) => setTimeout(s, 0)), h(t, n, o), v(r, o);
|
|
146
|
-
return x(r);
|
|
147
|
-
}
|
|
148
|
-
export {
|
|
149
|
-
p as D,
|
|
150
|
-
d as R,
|
|
151
|
-
T as a,
|
|
152
|
-
R as b,
|
|
153
|
-
O as c,
|
|
154
|
-
P as p,
|
|
155
|
-
w as t,
|
|
156
|
-
L as v
|
|
157
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
function d(e) {
|
|
2
|
-
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
3
|
-
}
|
|
4
|
-
function o(e, f, s) {
|
|
5
|
-
typeof e == "string" ? s.push({ field: e, path: f }) : Array.isArray(e) && e.forEach((i, r) => o(i, `${f}[${r}]`, s));
|
|
6
|
-
}
|
|
7
|
-
function c(e, f, s) {
|
|
8
|
-
if (Array.isArray(e)) {
|
|
9
|
-
e.forEach((i, r) => c(i, `${f}[${r}]`, s));
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
if (d(e))
|
|
13
|
-
for (const [i, r] of Object.entries(e))
|
|
14
|
-
["field", "weightField"].includes(i) ? o(r, `${f}.${i}`, s) : i !== "value" && i !== "style" && c(r, `${f}.${i}`, s);
|
|
15
|
-
}
|
|
16
|
-
function n(e, f, s) {
|
|
17
|
-
Array.isArray(e) && e.forEach((i, r) => {
|
|
18
|
-
if (!d(i)) return;
|
|
19
|
-
typeof i.field == "string" && i.valueField !== void 0 && i.valueField !== i.field && s.summaries.add(i.field);
|
|
20
|
-
const l = i.valueField === void 0 ? "field" : "valueField";
|
|
21
|
-
o(i[l], `${f}[${r}].${l}`, s.fields), i.valueField !== void 0 && i.valueField === i.field && o(i.field, `${f}[${r}].field`, s.fields), o(i.weightField, `${f}[${r}].weightField`, s.fields);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
function u(e, f, s) {
|
|
25
|
-
for (const r of ["rowKey", "revisionField", "sourceTokenField"]) o(e[r], `${f}.${r}`, s.fields);
|
|
26
|
-
if (!e.matrix && Array.isArray(e.columns) && e.columns.forEach((r, l) => {
|
|
27
|
-
d(r) && (typeof r.field == "string" && s.fields.push({ field: r.field, path: `${f}.columns[${l}].field`, summary: !0 }), c(r.rules, `${f}.columns[${l}].rules`, s.fields), c(r.visibleWhen, `${f}.columns[${l}].visibleWhen`, s.fields));
|
|
28
|
-
}), c(e.rowVisibleWhen, `${f}.rowVisibleWhen`, s.fields), Array.isArray(e.computed) && e.computed.forEach((r, l) => {
|
|
29
|
-
d(r) && (typeof r.field == "string" && s.generated.add(r.field), c(r.expression, `${f}.computed[${l}].expression`, s.fields), o(r.dependsOn, `${f}.computed[${l}].dependsOn`, s.fields), o(r.groupBy, `${f}.computed[${l}].groupBy`, s.fields));
|
|
30
|
-
}), (Array.isArray(e.groups) ? e.groups.map((r, l) => ({ group: r, path: `${f}.groups[${l}]` })) : e.groupBy ? [{ group: e.groupBy, path: `${f}.groupBy` }] : []).forEach(({ group: r, path: l }) => {
|
|
31
|
-
d(r) && (o(r.field, `${l}.field`, s.fields), o(r.subtotal, `${l}.subtotal`, s.fields), n(r.aggregates, `${l}.aggregates`, s));
|
|
32
|
-
}), d(e.grandTotal) && (o(e.grandTotal.fields, `${f}.grandTotal.fields`, s.fields), n(e.grandTotal.aggregates, `${f}.grandTotal.aggregates`, s)), d(e.matrix) && (o(e.matrix.rowFields, `${f}.matrix.rowFields`, s.fields), o(e.matrix.columnFields, `${f}.matrix.columnFields`, s.fields), n(e.matrix.measures, `${f}.matrix.measures`, s)), d(e.tree)) {
|
|
33
|
-
for (const r of ["idField", "parentField", "labelField"]) o(e.tree[r], `${f}.tree.${r}`, s.fields);
|
|
34
|
-
n(e.tree.aggregates, `${f}.tree.aggregates`, s);
|
|
35
|
-
}
|
|
36
|
-
d(e.detail) && o(e.detail.parentKey, `${f}.detail.parentKey`, s.fields);
|
|
37
|
-
}
|
|
38
|
-
function a(e) {
|
|
39
|
-
const f = [], s = e.repeat, i = s ? { dataset: s.dataset, path: "$.template.repeat", fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() } : void 0;
|
|
40
|
-
i && s && (o(s.rowKey, "$.template.repeat.rowKey", i.fields), typeof s.copies == "object" && o(s.copies.field, "$.template.repeat.copies.field", i.fields), f.push(i));
|
|
41
|
-
function r(l, $) {
|
|
42
|
-
if (Array.isArray(l)) {
|
|
43
|
-
l.forEach((t, y) => r(t, `${$}[${y}]`));
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (d(l)) {
|
|
47
|
-
if (i && d(l.binding) && o(l.binding.field, `${$}.binding.field`, i.fields), typeof l.dataset == "string" && Array.isArray(l.columns)) {
|
|
48
|
-
const t = { dataset: l.dataset, path: $, fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() };
|
|
49
|
-
u(l, $, t), typeof l.foreignKey == "string" && o(l.foreignKey, `${$}.foreignKey`, t.fields), f.push(t);
|
|
50
|
-
}
|
|
51
|
-
for (const [t, y] of Object.entries(l)) r(y, `${$}.${t}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return r(e, "$.template"), f;
|
|
55
|
-
}
|
|
56
|
-
export {
|
|
57
|
-
a as c
|
|
58
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function d(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function o(e,i,r){typeof e=="string"?r.push({field:e,path:i}):Array.isArray(e)&&e.forEach((f,s)=>o(f,`${i}[${s}]`,r))}function c(e,i,r){if(Array.isArray(e)){e.forEach((f,s)=>c(f,`${i}[${s}]`,r));return}if(d(e))for(const[f,s]of Object.entries(e))["field","weightField"].includes(f)?o(s,`${i}.${f}`,r):f!=="value"&&f!=="style"&&c(s,`${i}.${f}`,r)}function n(e,i,r){Array.isArray(e)&&e.forEach((f,s)=>{if(!d(f))return;typeof f.field=="string"&&f.valueField!==void 0&&f.valueField!==f.field&&r.summaries.add(f.field);const l=f.valueField===void 0?"field":"valueField";o(f[l],`${i}[${s}].${l}`,r.fields),f.valueField!==void 0&&f.valueField===f.field&&o(f.field,`${i}[${s}].field`,r.fields),o(f.weightField,`${i}[${s}].weightField`,r.fields)})}function a(e,i,r){for(const s of["rowKey","revisionField","sourceTokenField"])o(e[s],`${i}.${s}`,r.fields);if(!e.matrix&&Array.isArray(e.columns)&&e.columns.forEach((s,l)=>{d(s)&&(typeof s.field=="string"&&r.fields.push({field:s.field,path:`${i}.columns[${l}].field`,summary:!0}),c(s.rules,`${i}.columns[${l}].rules`,r.fields),c(s.visibleWhen,`${i}.columns[${l}].visibleWhen`,r.fields))}),c(e.rowVisibleWhen,`${i}.rowVisibleWhen`,r.fields),Array.isArray(e.computed)&&e.computed.forEach((s,l)=>{d(s)&&(typeof s.field=="string"&&r.generated.add(s.field),c(s.expression,`${i}.computed[${l}].expression`,r.fields),o(s.dependsOn,`${i}.computed[${l}].dependsOn`,r.fields),o(s.groupBy,`${i}.computed[${l}].groupBy`,r.fields))}),(Array.isArray(e.groups)?e.groups.map((s,l)=>({group:s,path:`${i}.groups[${l}]`})):e.groupBy?[{group:e.groupBy,path:`${i}.groupBy`}]:[]).forEach(({group:s,path:l})=>{d(s)&&(o(s.field,`${l}.field`,r.fields),o(s.subtotal,`${l}.subtotal`,r.fields),n(s.aggregates,`${l}.aggregates`,r))}),d(e.grandTotal)&&(o(e.grandTotal.fields,`${i}.grandTotal.fields`,r.fields),n(e.grandTotal.aggregates,`${i}.grandTotal.aggregates`,r)),d(e.matrix)&&(o(e.matrix.rowFields,`${i}.matrix.rowFields`,r.fields),o(e.matrix.columnFields,`${i}.matrix.columnFields`,r.fields),n(e.matrix.measures,`${i}.matrix.measures`,r)),d(e.tree)){for(const s of["idField","parentField","labelField"])o(e.tree[s],`${i}.tree.${s}`,r.fields);n(e.tree.aggregates,`${i}.tree.aggregates`,r)}d(e.detail)&&o(e.detail.parentKey,`${i}.detail.parentKey`,r.fields)}function u(e){const i=[],r=e.repeat,f=r?{dataset:r.dataset,path:"$.template.repeat",fields:[],generated:new Set,summaries:new Set}:void 0;f&&r&&(o(r.rowKey,"$.template.repeat.rowKey",f.fields),typeof r.copies=="object"&&o(r.copies.field,"$.template.repeat.copies.field",f.fields),i.push(f));function s(l,$){if(Array.isArray(l)){l.forEach((t,y)=>s(t,`${$}[${y}]`));return}if(d(l)){if(f&&d(l.binding)&&o(l.binding.field,`${$}.binding.field`,f.fields),typeof l.dataset=="string"&&Array.isArray(l.columns)){const t={dataset:l.dataset,path:$,fields:[],generated:new Set,summaries:new Set};a(l,$,t),typeof l.foreignKey=="string"&&o(l.foreignKey,`${$}.foreignKey`,t.fields),i.push(t)}for(const[t,y]of Object.entries(l))s(y,`${$}.${t}`)}}return s(e,"$.template"),i}exports.collectTemplateDatasetBindings=u;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const oe=require("./matrix-gTHpDTGm.cjs"),H=require("./computed-C2GD3XcE.cjs"),x=require("./component-tree-DkGLEfZC.cjs"),ae=require("./code-options-BUTChiZZ.cjs"),J=require("./param-validation-C3HlcLLO.cjs"),j=require("./tree-CLpxYbKa.cjs");function fe(e,i,t){e!==void 0&&(typeof e!="string"||!e.trim()||e.length>4096)&&t.push({path:i,message:"来源范围应为不超过 4096 字符的非空字符串"})}function W(e,i,t){e.editable!==void 0&&typeof e.editable!="boolean"&&t.push({path:`${i}.editable`,message:"编辑控制应为布尔值"}),e.valueType!==void 0&&!["text","number","boolean"].includes(e.valueType)&&t.push({path:`${i}.valueType`,message:"编辑类型应为 text、number 或 boolean"})}function re(e,i,t){W(e,i,t),e.indentMm!==void 0&&(typeof e.indentMm!="number"||!Number.isFinite(e.indentMm)||e.indentMm<0)&&t.push({path:`${i}.indentMm`,message:"单元格缩进应为有限非负数"}),e.derived!==void 0&&typeof e.derived!="boolean"&&t.push({path:`${i}.derived`,message:"派生结果标记应为布尔值"}),G(e.source,`${i}.source`,t,!0),e.formula!==void 0&&typeof e.formula!="string"&&t.push({path:`${i}.formula`,message:"单元格公式应为字符串"})}function G(e,i,t,s=!1){if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e)){t.push({path:i,message:"业务来源应为对象"});return}const n=e;fe(n.sourceScope,`${i}.sourceScope`,t);for(const o of["datasetId",...s?["field"]:[]])(typeof n[o]!="string"||!n[o].trim())&&t.push({path:`${i}.${o}`,message:"业务标识应为非空字符串"});for(const o of["rowKey","revision"]){const a=n[o];a===void 0&&!(s&&o==="rowKey")||typeof a!="string"&&!(typeof a=="number"&&Number.isFinite(a))&&t.push({path:`${i}.${o}`,message:"业务键及修订号应为字符串或有限数字"})}n.sourceToken!==void 0&&typeof n.sourceToken!="string"&&t.push({path:`${i}.sourceToken`,message:"来源令牌应为字符串"})}const de=new Set(["text","image","barcode","qrcode","chart","line","rect","ellipse"]);function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function k(e){return e===null?"null":typeof e=="string"?JSON.stringify(e.slice(0,120)):["number","boolean","undefined"].includes(typeof e)?String(e):`[${typeof e}]`}function ue(e,i,t,s){const n=e[i];(typeof n!="number"||!Number.isFinite(n))&&s.push({path:`${t}.${i}`,message:`应为有限数字,实际 ${k(n)}`})}function he(e,i,t){if(e!==void 0){const s=`${i}.table`;if(!g(e))t.push({path:s,message:"逻辑表来源应为对象"});else{G(e.source,`${s}.source`,t),(typeof e.id!="string"||!e.id.trim())&&t.push({path:`${s}.id`,message:"逻辑表 ID 应为非空字符串"});const n=e.role;["header","body","group-header","subtotal","grand-total"].includes(n)||t.push({path:`${s}.role`,message:"未知逻辑表行角色"});const o=e.rowIndex;(typeof o!="number"||!Number.isInteger(o)||(n==="header"?o!==-1:o<0))&&t.push({path:`${s}.rowIndex`,message:"表头索引应为 -1,内容行索引应为非负整数"}),(!Array.isArray(e.columnKeys)||e.columnKeys.some(a=>typeof a!="string"))&&t.push({path:`${s}.columnKeys`,message:"逻辑列字段应为字符串数组"}),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${s}.layout`,message:"布局应为 page 或 wide"}),e.title!==void 0&&typeof e.title!="string"&&t.push({path:`${s}.title`,message:"逻辑表名称应为字符串"})}}}function me(e,i,t,s){if(e!==void 0)if(!g(e)||!Array.isArray(e.cells))t.push({path:`${i}.grid.cells`,message:"grid.cells 应为二维数组"});else{const n=e.paddingMm;n!==void 0&&(typeof n!="number"||!Number.isFinite(n)||n<0)&&t.push({path:`${i}.grid.paddingMm`,message:"单元格内距应为有限非负数"}),e.cells.forEach((o,a)=>{if(!Array.isArray(o)){t.push({path:`${i}.grid.cells.${a}`,message:"行应为数组"});return}o.forEach((f,r)=>{if(f==null)return;const d=`${i}.grid.cells.${a}.${r}`;if(!g(f)){t.push({path:d,message:"网格单元格应为对象或 null"});return}re(f,d,t),U(f.richParagraphs,d,t),Array.isArray(f.children)&&f.children.forEach((u,p)=>{I(u,`${i}.grid.cells.${a}.${r}.children.${p}`,t,s)})})})}}function S(e,i,t,s){e!==void 0&&!i.includes(e)&&s.push({path:t,message:"未知富文本属性值"})}function O(e,i,t,s,n=0){for(const o of i){const a=e[o];a!==void 0&&(typeof a!="number"||!Number.isFinite(a)||a<n)&&s.push({path:`${t}.${o}`,message:"富文本数值应为范围内有限数字"})}}function ce(e,i,t){if(e!==void 0){if(!g(e)){t.push({path:i,message:"富文本样式应为对象"});return}for(const s of["fontFamily","color","backgroundColor","lineColor","borderColor"])e[s]!==void 0&&typeof e[s]!="string"&&t.push({path:`${i}.${s}`,message:"富文本样式应为字符串"});for(const s of["bold","italic","underline","borderTop","borderRight","borderBottom","borderLeft"])e[s]!==void 0&&typeof e[s]!="boolean"&&t.push({path:`${i}.${s}`,message:"富文本样式应为布尔值"});O(e,["fontSize","fontSizePx","lineWidthPt","lineHeight","opacity"],i,t),O(e,["letterSpacing","rotateDeg"],i,t,-1/0),typeof e.opacity=="number"&&e.opacity>1&&t.push({path:`${i}.opacity`,message:"透明度不能大于1"}),S(e.align,["left","center","right","justify"],`${i}.align`,t),S(e.verticalAlign,["top","middle","bottom"],`${i}.verticalAlign`,t)}}function ge(e,i,t){if(!g(e)){t.push({path:i,message:"富文本片段应为对象"});return}S(e.kind,["text","field"],`${i}.kind`,t);for(const s of["text","field"])e[s]!==void 0&&typeof e[s]!="string"&&t.push({path:`${i}.${s}`,message:"富文本内容应为字符串"});ce(e.style,`${i}.style`,t)}function U(e,i,t){if(e!==void 0){if(!Array.isArray(e)){t.push({path:`${i}.richParagraphs`,message:"richParagraphs 应为数组"});return}e.forEach((s,n)=>{const o=`${i}.richParagraphs.${n}`;if(!g(s)||!Array.isArray(s.segments)){t.push({path:o,message:"段落缺少 segments 数组"});return}S(s.align,["left","center","right","justify"],`${o}.align`,t),O(s,["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"],o,t),s.segments.forEach((a,f)=>ge(a,`${o}.segments.${f}`,t))})}}function F(e,i,t,s=[]){const n=x.componentTreeIssue([e],i);if(n){t.push(n);return}I(e,i,t,s)}function I(e,i,t,s=[]){if(!g(e)){t.push({path:i,message:"组件应为对象"});return}const n=e.kind;typeof n!="string"?t.push({path:`${i}.kind`,message:"组件缺少 kind 字符串"}):de.has(n)||s.push({path:`${i}.kind`,message:`未知组件类型 ${k(n)},将以兜底方式渲染`});for(const o of["leftMm","topMm","widthMm","heightMm"])ue(e,o,i,t);typeof e.leftMm=="number"&&e.leftMm<-100&&t.push({path:`${i}.leftMm`,message:"几何数值异常(leftMm<-100)"});for(const o of["widthMm","heightMm"])typeof e[o]=="number"&&e[o]<0&&t.push({path:`${i}.${o}`,message:"组件尺寸不能为负数"});he(e.table,i,t),pe(e.code,n,i,t),e.pageAnchor!==void 0&&!["header","footer"].includes(e.pageAnchor)&&t.push({path:`${i}.pageAnchor`,message:"页面锚点应为 header 或 footer"}),e.lineDirection!==void 0&&!["down","up"].includes(e.lineDirection)&&t.push({path:`${i}.lineDirection`,message:"线段方向应为 down 或 up"}),me(e.grid,i,t,s),U(e.richParagraphs,i,t)}function pe(e,i,t,s){if(e!==void 0)for(const n of ae.codeOptionIssues(e,i))s.push({path:`${t}.code${n.path?`.${n.path}`:""}`,message:n.message})}function q(e,i,t){if(!g(e))return;e.binding!==void 0&&t.push({path:`${i}.binding`,message:"渲染计划不允许未解析字段绑定"});const s=e.grid;!g(s)||!Array.isArray(s.cells)||s.cells.forEach((n,o)=>{Array.isArray(n)&&n.forEach((a,f)=>{!g(a)||!Array.isArray(a.children)||a.children.forEach((r,d)=>q(r,`${i}.grid.cells.${o}.${f}.children.${d}`,t))})})}function B(e,i,t,s=[]){if(!g(e)){t.push({path:i,message:"页应为对象"});return}const n=e.pageWidthMm,o=e.pageHeightMm;(typeof n!="number"||!Number.isFinite(n)||n<=0)&&t.push({path:`${i}.pageWidthMm`,message:`页宽非法: ${k(n)}`}),(typeof o!="number"||!(o>0&&o<5e3))&&t.push({path:`${i}.pageHeightMm`,message:`页高非法: ${k(o)}`}),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${i}.layout`,message:"布局应为 page 或 wide"});const a=e.components;if(!Array.isArray(a))t.push({path:`${i}.components`,message:"components 应为数组"});else if(Array.isArray(a)){const f=x.componentTreeIssue(a,`${i}.components`);if(f){t.push(f);return}a.forEach((r,d)=>{I(r,`${i}.components.${d}`,t,s),q(r,`${i}.components.${d}`,t)})}}function z(e){const i=[],t=[],s=g(e)?e.pages:void 0;if(g(e)&&e.requiresRecalculation!==void 0&&typeof e.requiresRecalculation!="boolean"&&i.push({path:"$.requiresRecalculation",message:"重算能力要求应为布尔值"}),!Array.isArray(s))i.push({path:"$.pages",message:e==null?"渲染计划为空":"渲染计划缺少 pages 数组"});else{const n=x.renderTreeIssue(s);if(n)return{ok:!1,errors:[...i,n],warnings:t};s.forEach((a,f)=>B(a,`$.pages.${f}`,i,t)),s.length>2e3&&t.push({path:"$.pages",message:`页数异常大(${s.length} 页),渲染与打印耗时可能显著增加`});const o=s.reduce((a,f)=>a+(g(f)&&Array.isArray(f.components)?f.components.length:0),0);o>5e4&&t.push({path:"$.pages",message:`组件总数异常大(${o} 个),可能触发浏览器性能限制`})}return{ok:i.length===0,errors:i,warnings:t}}function ye(e){const i=z(e);if(!i.ok){const t=i.errors.slice(0,3).map(s=>`${s.path}: ${s.message}`).join("; ");throw new Error(`渲染计划校验失败(${i.errors.length} 处): ${t}`)}return e.pages}function _(e){return e.kind==="list"?e.id:e.nid}function le(e){return e.kind==="list"?!1:e.pageAnchor!==void 0||e.kind==="text"&&typeof e.text=="string"&&/\{(?:page|totalPages)\}/.test(e.text)}function $e(e,i){const t=e.filter(n=>i.componentIds.includes(_(n)??""));if(t.filter(n=>n.kind==="list"&&n.cardinality!=="record").length&&t.length!==1)throw new Error("纵向重复区域必须独占流式分段,不能与静态或单记录区域并排");for(const n of t){const o=n.kind==="list"?n.topMm+(n.rowHeightMm??0):n.topMm+n.heightMm;if(n.topMm<i.topMm-.001||o>i.topMm+i.heightMm+.001)throw new Error("流式分段应完整包含其组件的原始纵向范围")}}function be(e,i){if(!i)return e.map(s=>({components:[s]}));const t=new Map(e.map(s=>[_(s),s]));return i.bands.map(s=>({band:s,components:s.componentIds.map(n=>{const o=t.get(n);if(!o)throw new Error(`流式区域引用不存在的组件:${n}`);return o})}))}function X(e,i){if(!i||!Array.isArray(i.bands)||!i.bands.length||i.bands.length>1e4)throw new Error("流式排版应包含 1–10000 个区域");const t=new Set,s=new Set;for(const n of e){if(le(n))continue;const o=_(n);if(!o||t.has(o))throw new Error("流式排版组件应具有唯一标识");t.add(o)}if(Ae(e,i,t,s),s.size!==t.size)throw new Error("流式排版必须显式包含每个非锚点组件")}function Ae(e,i,t,s){let n=-1/0;for(const o of i.bands){if(!Number.isFinite(o.topMm)||!Number.isFinite(o.heightMm)||o.topMm<0||o.heightMm<=0||o.topMm<n-.001)throw new Error("流式区域应按原始位置排序,尺寸有效且不重叠");if(!Array.isArray(o.componentIds)||!o.componentIds.length)throw new Error("流式区域不能没有组件");for(const a of o.componentIds){if(!t.has(a)||s.has(a))throw new Error(`流式区域组件缺失、重复或包含页锚点:${a}`);s.add(a)}$e(e,o),n=o.topMm+o.heightMm}}const we=new Set(["__proto__","prototype","constructor"]);function l(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function E(e){return typeof e=="string"&&!!e.trim()&&!we.has(e)}function v(e,i,t,s){for(const n of Object.keys(e))i.includes(n)||s.push({path:`${t}.${n}`,message:"存在未知配置字段"})}function Me(e,i,t){if(e!==void 0){if(!l(e)||!["number","percent","date"].includes(String(e.kind))){t.push({path:i,message:"绑定格式应为 number、percent 或 date"});return}v(e,e.kind==="date"?["kind","pattern"]:e.kind==="number"?["kind","digits","thousands"]:["kind","digits"],i,t),e.digits!==void 0&&(!Number.isInteger(e.digits)||Number(e.digits)<0||Number(e.digits)>100)&&t.push({path:`${i}.digits`,message:"精度应为 0..100 整数"}),e.thousands!==void 0&&typeof e.thousands!="boolean"&&t.push({path:`${i}.thousands`,message:"千分位开关应为布尔值"}),e.pattern!==void 0&&typeof e.pattern!="string"&&t.push({path:`${i}.pattern`,message:"日期格式应为字符串"})}}function Ee(e,i,t){const s=e.binding;if(s===void 0)return;const n=`${i}.binding`;if(!l(s)){t.push({path:n,message:"字段绑定应为对象"});return}(!["text","image","barcode","qrcode"].includes(String(e.kind))||e.grid!==void 0)&&t.push({path:n,message:"绑定仅支持独立文本、图片、条码与二维码组件"}),v(s,["field","format","prefix","suffix","emptyText"],n,t),E(s.field)||t.push({path:`${n}.field`,message:"绑定字段应为安全的非空字段名(按字面读取自有字段)"});for(const o of["prefix","suffix","emptyText"])s[o]!==void 0&&typeof s[o]!="string"&&t.push({path:`${n}.${o}`,message:"应为字符串"});Me(s.format,`${n}.format`,t),e.kind==="image"&&["format","prefix","suffix"].some(o=>s[o]!==void 0)&&t.push({path:n,message:"图片绑定直接读取 PNG/JPEG data URL,不支持文本格式或前后缀"})}function Ne(e,i){if(!l(e)){i.push({path:"$.repeat",message:"逐记录配置应为对象"});return}v(e,["dataset","rowKey","copies"],"$.repeat",i),E(e.dataset)||i.push({path:"$.repeat.dataset",message:"数据集应为安全的非空名称"}),e.rowKey!==void 0&&!E(e.rowKey)&&i.push({path:"$.repeat.rowKey",message:"业务主键应为安全的非空字段名"});const t=e.copies;t!==void 0&&(l(t)?(v(t,["field"],"$.repeat.copies",i),E(t.field)||i.push({path:"$.repeat.copies.field",message:"复制数字段应为安全的非空字段名"})):(!Number.isSafeInteger(t)||Number(t)<1||Number(t)>1e3)&&i.push({path:"$.repeat.copies",message:"每条记录复制数应为 1..1000 整数"}))}function Y(e,i,t,s){if(!l(e))return;Ee(e,i,s),e.binding!==void 0&&!t&&s.push({path:`${i}.binding`,message:"字段绑定需要模板 repeat 数据集;普通报表请使用列表字段"}),t&&e.kind==="list"&&s.push({path:i,message:"逐记录标签使用固定组件;动态列表请使用普通报表模板"});const n=e.grid;l(n)&&Array.isArray(n.cells)&&n.cells.forEach((o,a)=>{Array.isArray(o)&&o.forEach((f,r)=>{l(f)&&Array.isArray(f.children)&&f.children.forEach((d,u)=>Y(d,`${i}.grid.cells.${a}.${r}.children.${u}`,t,s))})})}function Q(e,i){const t=e.repeat!==void 0;t&&Ne(e.repeat,i),Array.isArray(e.pages)&&e.pages.forEach((s,n)=>{if(!l(s))return;const o=`$.pages.${n}`;t&&(s.layout==="wide"||s.flow!==void 0)&&i.push({path:o,message:"逐记录标签仅支持固定尺寸页面,不支持宽表或流式分区"}),Array.isArray(s.components)&&s.components.forEach((a,f)=>{const r=`${o}.components.${f}`;if(Y(a,r,t,i),!t||!l(a))return;const{leftMm:d,topMm:u,widthMm:p,heightMm:y}=a;[d,u,p,y,s.widthMm,s.heightMm].every(A=>typeof A=="number"&&Number.isFinite(A))&&(Number(d)<0||Number(u)<0||Number(d)+Number(p)>Number(s.widthMm)+.001||Number(u)+Number(y)>Number(s.heightMm)+.001)&&i.push({path:r,message:"标签组件超出纸张边界,请调整位置或尺寸"})})})}function Z(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function P(e,i,t){if(e!==void 0){if(!Z(e)){t.push({path:i,message:"条件应为对象"});return}(typeof e.field!="string"||!e.field.trim())&&t.push({path:`${i}.field`,message:"条件需要字段"}),e.numeric!==void 0&&e.numeric!=="number"&&e.numeric!=="decimal"&&t.push({path:`${i}.numeric`,message:"未知条件数值模式"}),[">",">=","<","<=","==","!="].includes(e.op)||t.push({path:`${i}.op`,message:"未知条件运算符"}),typeof e.value!="string"&&!(typeof e.value=="number"&&Number.isFinite(e.value))&&t.push({path:`${i}.value`,message:"条件值应为字符串或有限数字"})}}function ee(e,i,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>2048){t.push({path:i,message:"聚合应为数组且最多 2048 项"});return}const s=new Set;e.forEach((n,o)=>{const a=`${i}.${o}`;if(!Z(n)){t.push({path:a,message:"聚合应为对象"});return}const f=n.field;typeof f!="string"||!f.trim()||s.has(f)?t.push({path:`${a}.field`,message:"聚合输出字段应非空且唯一"}):s.add(f),n.numeric!==void 0&&n.numeric!=="number"&&n.numeric!=="decimal"&&t.push({path:`${a}.numeric`,message:"数值模式应为 number 或 decimal"}),n.digits!==void 0&&(!Number.isInteger(n.digits)||Number(n.digits)<0||Number(n.digits)>100)&&t.push({path:`${a}.digits`,message:"小数位应为 0–100 的整数"});try{H.createAggregateAccumulator({...n,field:n.valueField??f})}catch(r){t.push({path:a,message:r instanceof Error?r.message:String(r)})}})}function ke(e,i,t){if(e===void 0)return;const s=H.validateComputedFields(e);for(const n of s.errors)t.push({path:i,message:n})}function Se(e,i,t){if(e!==void 0)try{oe.validateMatrixOptions(e)}catch(s){t.push({path:i,message:s instanceof Error?s.message:String(s)})}}function ve(e,i,t){if(e.tree===void 0)return;const s=`${i}.tree`;try{j.validateTreeOptions(e.tree);const n=e.tree;if(e.matrix||e.detail||e.groupBy||Array.isArray(e.groups)&&e.groups.length||e.rowVisibleWhen)throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");if(e.rowKey!==void 0&&e.rowKey!==n.idField)throw new Error("树形 rowKey 应与 idField 一致");if(!Array.isArray(e.columns)||!e.columns.some(o=>o&&o.field===n.labelField&&!o.hidden))throw new Error("树形布局需要可见的标签列");Array.isArray(e.computed)&&j.validateTreeComputed(n,e.computed)}catch(n){t.push({path:s,message:n instanceof Error?n.message:String(n)})}}const L="1.0";class w extends Error{constructor(i){super(`模板校验失败:${i.slice(0,3).map(t=>`${t.path}: ${t.message}`).join("; ")}`),this.errors=i,this.name="ReportTemplateError"}}const Re=new Set(["__proto__","prototype","constructor"]),xe=new Set(["schemaVersion","id","name","revision","description","template"]),Te=new Set(["left","center","right","justify"]),N=2e5,Oe=64,C=1e7;function h(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Pe(e,i,t){const s=Object.getPrototypeOf(e),n=Array.isArray(e);if(n?s!==Array.prototype:s!==Object.prototype&&s!==null)return t.push({path:i,message:"模板对象必须使用普通 JSON 对象原型"}),!1;if(n){const o=Object.keys(e);if(o.length!==e.length||o.some(a=>!/^(0|[1-9]\d*)$/.test(a)||Number(a)>=e.length))return t.push({path:i,message:"模板数组不能包含空位或额外属性"}),!1}return Object.getOwnPropertySymbols(e).length>0?(t.push({path:i,message:"模板不能包含 Symbol 键"}),!1):!0}function Fe(e,i,t,s){return Re.has(e)?(s.push({path:t,message:"模板不能包含可能污染原型的键"}),!1):i.get||i.set||!i.enumerable?(s.push({path:t,message:"模板不能包含访问器或不可枚举字段"}),!1):!0}function Ie(e){return e===null||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e)}function D(e,i){const t=new Set;let s=0,n=0,o=!1;const a=(f,r,d)=>{if(!o){if(++s>N){s===N+1&&i.push({path:r,message:"模板超过 JSON 节点安全上限"});return}if(d>Oe){i.push({path:r,message:"模板嵌套层级过深"});return}if(typeof f=="string"){n+=f.length,n>C&&(o=!0,i.push({path:r,message:"模板文本超过 1000 万字符的安全上限"}));return}if(!Ie(f)){if(!f||typeof f!="object"){i.push({path:r,message:"模板只允许 JSON 值,不允许函数、undefined 或非有限数字"});return}if(t.has(f)){i.push({path:r,message:"模板不能包含循环引用"});return}if(Pe(f,r,i)){t.add(f);for(const[u,p]of Object.entries(Object.getOwnPropertyDescriptors(f))){if(Array.isArray(f)&&u==="length")continue;const y=`${r}.${u}`;if(Fe(u,p,y,i)&&a(p.value,y,d+1),s>N||o)break}t.delete(f)}}}};a(e,"$",0)}function m(e,i,t,s,n=!1){const o=e[i];o===void 0&&!n||(typeof o!="string"||n&&!o.trim())&&s.push({path:`${t}.${i}`,message:n?"应为非空字符串":"应为字符串"})}function c(e,i,t,s,n=0,o=!1){const a=e[i];a===void 0&&!o||(typeof a!="number"||!Number.isFinite(a)||a<n)&&s.push({path:`${t}.${i}`,message:`应为大于等于 ${n} 的有限数字`})}function b(e,i,t,s){e[i]!==void 0&&typeof e[i]!="boolean"&&s.push({path:`${t}.${i}`,message:"应为布尔值"})}function M(e,i,t,s=!1){e!==void 0&&!Te.has(e)&&!(s&&e==="auto")&&t.push({path:i,message:`未知对齐方式${s?"(支持 auto)":""}`})}function $(e,i,t){if(e!==void 0){if(!h(e)){t.push({path:i,message:"样式应为对象"});return}M(e.align,`${i}.align`,t),e.verticalAlign!==void 0&&!["top","middle","bottom"].includes(e.verticalAlign)&&t.push({path:`${i}.verticalAlign`,message:"未知垂直对齐方式"});for(const s of["fontSize","fontSizePx","lineWidthPt","lineHeight"])c(e,s,i,t);for(const s of["letterSpacing","rotateDeg"])c(e,s,i,t,-1/0);c(e,"opacity",i,t),typeof e.opacity=="number"&&e.opacity>1&&t.push({path:`${i}.opacity`,message:"透明度不能大于 1"});for(const s of["bold","italic","underline","borderTop","borderRight","borderBottom","borderLeft"])b(e,s,i,t);for(const s of["fontFamily","color","backgroundColor","lineColor","borderColor"])m(e,s,i,t)}}function _e(e,i,t){if(e===void 0)return;if(!Array.isArray(e)){t.push({path:i,message:"参数定义应为数组"});return}const s=new Set,n=t.length;e.forEach((o,a)=>{const f=`${i}.${a}`;if(!h(o)){t.push({path:f,message:"参数定义应为对象"});return}m(o,"field",f,t,!0),typeof o.field=="string"&&(s.has(o.field)&&t.push({path:`${f}.field`,message:"参数名重复"}),s.add(o.field)),o.type!==void 0&&!["text","number","date","month","year","dateRange","select"].includes(o.type)&&t.push({path:`${f}.type`,message:"未知参数类型"});for(const r of["label","defaultValue","placeholder"])m(o,r,f,t);b(o,"required",f,t);for(const r of["minLength","maxLength"]){const d=o[r];d!==void 0&&(typeof d!="number"||!Number.isSafeInteger(d)||d<0)&&t.push({path:`${f}.${r}`,message:"长度边界应为非负整数"})}Le(o,f,t),o.options!==void 0&&(Array.isArray(o.options)?o.options.forEach((r,d)=>{const u=`${f}.options.${d}`;if(!h(r))t.push({path:u,message:"选项应为对象"});else for(const p of["label","value"])typeof r[p]!="string"&&t.push({path:`${u}.${p}`,message:"选项标签与值应为字符串(允许空白选项)"})}):t.push({path:`${f}.options`,message:"选项应为数组"}))}),t.length===n&&t.push(...J.validateReportParamDefinitions(e).map(o=>({path:o.path.replace("$.paramDefs",i),message:o.message})))}function Le(e,i,t){for(const o of["min","max"]){const a=e[o];if(a===void 0)continue;J.isReportTemporalBound(e.type,a)||e.type==="number"&&typeof a=="number"&&Number.isFinite(a)||t.push({path:`${i}.${o}`,message:"数字使用有限数字边界,日期/月/年使用对应规范字符串边界"})}const s=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;(s||n)&&t.push({path:i,message:"最小边界不能大于最大边界"}),typeof e.minLength=="number"&&typeof e.maxLength=="number"&&e.minLength>e.maxLength&&t.push({path:i,message:"最小长度不能大于最大长度"})}function te(e,i,t){if(!Array.isArray(e)||e.length===0){t.push({path:i,message:"列表至少需要一列"});return}e.every(s=>h(s)&&s.hidden===!0)&&t.push({path:i,message:"列表至少需要一列可见列"}),e.forEach((s,n)=>{const o=`${i}.${n}`;if(!h(s)){t.push({path:o,message:"列应为对象"});return}if(W(s,o,t),b(s,"hidden",o,t),P(s.visibleWhen,`${o}.visibleWhen`,t),typeof s.header!="string"&&t.push({path:`${o}.header`,message:"表头应为字符串(允许空白表头)"}),m(s,"field",o,t,!0),c(s,"widthMm",o,t,Number.MIN_VALUE,!0),$(s.style,`${o}.style`,t),$(s.headerStyle,`${o}.headerStyle`,t),M(s.align,`${o}.align`,t,!0),M(s.headerAlign,`${o}.headerAlign`,t),s.semanticRole!==void 0&&!["identifier","dimension","measure","date","text"].includes(s.semanticRole)&&t.push({path:`${o}.semanticRole`,message:"未知列语义"}),s.format!==void 0)if(!h(s.format)||!["number","percent","date"].includes(s.format.kind))t.push({path:`${o}.format`,message:"未知列格式"});else{const a=s.format.digits;a!==void 0&&(typeof a!="number"||!Number.isInteger(a)||a<0||a>100)&&t.push({path:`${o}.format.digits`,message:"小数位应为 0–100 的整数"}),b(s.format,"thousands",`${o}.format`,t),m(s.format,"pattern",`${o}.format`,t)}s.rules!==void 0&&(Array.isArray(s.rules)?s.rules.forEach((a,f)=>{const r=`${o}.rules.${f}`;if(!h(a)||!h(a.when)){t.push({path:r,message:"条件格式缺少 when 对象"});return}P(a.when,`${r}.when`,t),m(a.when,"field",`${r}.when`,t,!0),[">",">=","<","<=","==","!="].includes(a.when.op)||t.push({path:`${r}.when.op`,message:"未知条件运算符"}),typeof a.when.value!="number"&&typeof a.when.value!="string"&&t.push({path:`${r}.when.value`,message:"条件值应为数字或字符串"}),$(a.style,`${r}.style`,t)}):t.push({path:`${o}.rules`,message:"条件格式应为数组"}))})}function ie(e,i,t){if(e!==void 0){if(!h(e)){t.push({path:i,message:"分组应为对象"});return}m(e,"field",i,t,!0);for(const s of["headerTemplate","subtotalLabel"])m(e,s,i,t);for(const s of["headerStyle","subtotalStyle"])$(e[s],`${i}.${s}`,t);b(e,"keepWithNext",i,t),b(e,"repeatHeader",i,t),ee(e.aggregates,`${i}.aggregates`,t),e.subtotal!==void 0&&(!Array.isArray(e.subtotal)||e.subtotal.some(s=>typeof s!="string"))&&t.push({path:`${i}.subtotal`,message:"小计字段应为字符串数组"})}}function Ce(e,i,t){if(!(e===void 0||typeof e=="boolean")){if(!h(e)){t.push({path:i,message:"合计应为布尔值或对象"});return}m(e,"label",i,t),ee(e.aggregates,`${i}.aggregates`,t),$(e.style,`${i}.style`,t),e.fields!==void 0&&(!Array.isArray(e.fields)||e.fields.some(s=>typeof s!="string"))&&t.push({path:`${i}.fields`,message:"合计字段应为字符串数组"})}}function De(e,i,t,s){const n={kind:"rect",leftMm:0,topMm:0,widthMm:1,heightMm:1,grid:e};if(F(n,t,s,[]),V(n,t,s),!h(e)||!Array.isArray(e.cells))return;const o=e.cells,a=Array.isArray(i)?i.length:0;if(o.length*a>N){s.push({path:t,message:"表头逻辑网格超过 20 万格安全上限"});return}e.cells.length||s.push({path:`${t}.cells`,message:"表头至少需要一行"}),Array.isArray(e.colWidthsMm)&&e.colWidthsMm.length!==a&&s.push({path:`${t}.colWidthsMm`,message:"表头列宽数量应与列表列数一致"}),Array.isArray(e.rowHeightsMm)&&e.rowHeightsMm.length!==e.cells.length&&s.push({path:`${t}.rowHeightsMm`,message:"表头行高数量应与行数一致"}),Ve(o,a,t,s)}function Ve(e,i,t,s){const n=new Set;e.forEach((o,a)=>{if(!Array.isArray(o))return;let f=0;o.forEach((r,d)=>{for(;n.has(`${a}:${f}`);)f++;const u=h(r)&&typeof r.colSpan=="number"?r.colSpan:1,p=h(r)&&typeof r.rowSpan=="number"?r.rowSpan:1;(f+u>i||a+p>e.length)&&s.push({path:`${t}.cells.${a}.${d}`,message:"表头合并区域超出表头边界"});for(let y=a;y<Math.min(e.length,a+p);y++)for(let A=f;A<Math.min(i,f+u);A++)n.has(`${y}:${A}`)&&s.push({path:`${t}.cells.${a}.${d}`,message:"表头合并区域重叠"}),n.add(`${y}:${A}`);f+=u})})}function je(e,i,t){if(ve(e,i,t),ke(e.computed,`${i}.computed`,t),Se(e.matrix,`${i}.matrix`,t),e.matrix&&(e.detail||e.groupBy||Array.isArray(e.groups)&&e.groups.length||e.grandTotal)&&t.push({path:`${i}.matrix`,message:"矩阵请使用自身 totals 汇总,不能同时配置普通分组、总计或主从明细"}),P(e.rowVisibleWhen,`${i}.rowVisibleWhen`,t),e.groups!==void 0&&(!Array.isArray(e.groups)||e.groups.length>16?t.push({path:`${i}.groups`,message:"分组应为数组,最多 16 级"}):e.groups.forEach((o,a)=>ie(o,`${i}.groups.${a}`,t))),e.detail===void 0)return;const s=e.detail,n=`${i}.detail`;if(!h(s)){t.push({path:n,message:"主从关联应为对象"});return}for(const o of["dataset","parentKey","foreignKey"])m(s,o,n,t,!0);for(const o of["rowKey","revisionField","sourceTokenField"])m(s,o,n,t,s[o]!==void 0);m(s,"label",n,t),b(s,"header",n,t),c(s,"rowHeightMm",n,t,Number.MIN_VALUE),te(s.columns,`${n}.columns`,t),s.unmatched!==void 0&&s.unmatched!=="error"&&s.unmatched!=="ignore"&&t.push({path:`${n}.unmatched`,message:"未关联明细策略应为 error 或 ignore"})}function Ke(e,i,t){for(const s of["leftMm","topMm"])c(e,s,i,t,-1/0,!0);c(e,"widthMm",i,t,Number.MIN_VALUE,!0),m(e,"dataset",i,t,!0),m(e,"title",i,t);for(const s of["rowKey","revisionField","sourceTokenField"])m(e,s,i,t,e[s]!==void 0);e.headerGrid!==void 0&&De(e.headerGrid,e.columns,`${i}.headerGrid`,t),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${i}.layout`,message:"布局应为 page 或 wide"}),te(e.columns,`${i}.columns`,t);for(const s of["fontSizePt","rowHeightMm"])c(e,s,i,t,Number.MIN_VALUE);c(e,"paddingMm",i,t);for(const s of["header","headerBold","headerEveryPage","border"])b(e,s,i,t);e.cardinality!==void 0&&e.cardinality!=="record"&&t.push({path:`${i}.cardinality`,message:"单记录区域类型应为 record"}),m(e,"headerBackgroundColor",i,t),M(e.align,`${i}.align`,t,!0),M(e.headerAlign,`${i}.headerAlign`,t),$(e.headerStyle,`${i}.headerStyle`,t),je(e,i,t),ie(e.groupBy,`${i}.groupBy`,t),Ce(e.grandTotal,`${i}.grandTotal`,t)}function K(e,i,t){Array.isArray(e.richParagraphs)&&e.richParagraphs.forEach((s,n)=>{if(!h(s))return;const o=`${i}.richParagraphs.${n}`;M(s.align,`${o}.align`,t);for(const a of["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"])c(s,a,o,t);Array.isArray(s.segments)&&s.segments.forEach((a,f)=>{const r=`${o}.segments.${f}`;if(!h(a)){t.push({path:r,message:"富文本片段应为对象"});return}a.kind!==void 0&&a.kind!=="text"&&a.kind!=="field"&&t.push({path:`${r}.kind`,message:"未知富文本片段类型"});for(const d of["text","field"])m(a,d,r,t);$(a.style,`${r}.style`,t)})})}function V(e,i,t){$(e.style,`${i}.style`,t);for(const n of["text","rawText","imageData","fallbackText","nid","rkey"])m(e,n,i,t);if(e.lines!==void 0&&(!Array.isArray(e.lines)||e.lines.some(n=>typeof n!="string"))&&t.push({path:`${i}.lines`,message:"文本行应为字符串数组"}),K(e,i,t),!h(e.grid))return;const s=e.grid;c(s,"gapMm",`${i}.grid`,t),c(s,"paddingMm",`${i}.grid`,t);for(const n of["colWidthsMm","rowHeightsMm"]){const o=s[n];o!==void 0&&(!Array.isArray(o)||o.some(a=>typeof a!="number"||!Number.isFinite(a)||a<0))&&t.push({path:`${i}.grid.${n}`,message:"网格尺寸应为有限非负数字数组"})}Array.isArray(s.cells)&&s.cells.forEach((n,o)=>{Array.isArray(n)&&n.forEach((a,f)=>{const r=`${i}.grid.cells.${o}.${f}`;if(a!==null){if(!h(a)){t.push({path:r,message:"网格单元格应为对象或 null"});return}for(const d of["text","rawText","numberFormat"])m(a,d,r,t);for(const d of["colSpan","rowSpan"]){const u=a[d];u!==void 0&&(typeof u!="number"||!Number.isInteger(u)||u<=0)&&t.push({path:`${r}.${d}`,message:"跨度应为正整数"})}a.value!==void 0&&a.value!==null&&!["string","number","boolean"].includes(typeof a.value)&&t.push({path:`${r}.value`,message:"Excel 原始值应为字符串、数字、布尔值或 null"}),$(a.style,`${r}.style`,t),K(a,r,t),a.children!==void 0&&(Array.isArray(a.children)?a.children.forEach((d,u)=>{h(d)&&V(d,`${r}.children.${u}`,t)}):t.push({path:`${r}.children`,message:"嵌套组件应为数组"}))}})})}function He(e,i,t){if(!(e.flow===void 0||!Array.isArray(e.components)))try{X(e.components,e.flow)}catch(s){t.push({path:`${i}.flow`,message:s instanceof Error?s.message:String(s)})}}function se(e){const i=[],t=[];return D(e,i),i.length?{ok:!1,errors:i,warnings:t}:(h(e)?(e.schemaVersion!==void 0&&e.schemaVersion!==x.RENDER_PLAN_SCHEMA_VERSION&&i.push({path:"$.schemaVersion",message:"不支持的模板 schemaVersion"}),_e(e.params,"$.params",i),Q(e,i),!Array.isArray(e.pages)||e.pages.length===0?i.push({path:"$.pages",message:"模板至少需要一页"}):e.pages.forEach((s,n)=>{const o=`$.pages.${n}`;if(!h(s)){i.push({path:o,message:"页应为对象"});return}c(s,"widthMm",o,i,Number.MIN_VALUE,!0),c(s,"heightMm",o,i,Number.MIN_VALUE,!0),s.layout!==void 0&&s.layout!=="page"&&s.layout!=="wide"&&i.push({path:`${o}.layout`,message:"布局应为 page 或 wide"}),typeof s.heightMm=="number"&&s.heightMm>=5e3&&i.push({path:`${o}.heightMm`,message:"页高应小于 5000mm"});for(const a of["marginTopMm","marginBottomMm","marginLeftMm","marginRightMm"])c(s,a,o,i);typeof s.widthMm=="number"&&Number(s.marginLeftMm??0)+Number(s.marginRightMm??0)>=s.widthMm&&i.push({path:o,message:"横向页边距占满页面"}),typeof s.heightMm=="number"&&Number(s.marginTopMm??0)+Number(s.marginBottomMm??0)>=s.heightMm&&i.push({path:o,message:"纵向页边距占满页面"}),Array.isArray(s.components)?s.components.forEach((a,f)=>{const r=`${o}.components.${f}`;h(a)&&a.kind==="list"?Ke(a,r,i):(F(a,r,i,t),h(a)&&V(a,r,i))}):i.push({path:`${o}.components`,message:"组件应为数组"}),He(s,o,i)})):i.push({path:"$",message:"模板应为对象"}),{ok:i.length===0,errors:i,warnings:t})}function ne(e){const i=[],t=[];if(D(e,i),i.length)return{ok:!1,errors:i,warnings:t};if(!h(e))i.push({path:"$",message:"模板文档应为对象"});else{for(const n of Object.keys(e))xe.has(n)||i.push({path:`$.${n}`,message:"模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据"});e.schemaVersion!==L&&i.push({path:"$.schemaVersion",message:"不支持的模板文档版本"});for(const n of["id","name"])m(e,n,"$",i,!0);for(const n of["revision","description"])m(e,n,"$",i);const s=se(e.template);i.push(...s.errors.map(n=>({...n,path:`$.template${n.path.slice(1)}`}))),t.push(...s.warnings.map(n=>({...n,path:`$.template${n.path.slice(1)}`})))}return{ok:i.length===0,errors:i,warnings:t}}function T(e){const i=ne(e);if(!i.ok)throw new w(i.errors)}function Je(e){const i=[];if(D(e,i),i.length)throw new w(i);const t={...e,schemaVersion:e.schemaVersion??L};return T(t),R(t)}function We(e){let i=e;if(typeof e=="string"){if(e.length>C)throw new w([{path:"$",message:"模板 JSON 超过 1000 万字符的导出/导入上限"}]);try{i=JSON.parse(e)}catch{throw new w([{path:"$",message:"模板 JSON 语法无效"}])}}return T(i),R(i)}function Ge(e){T(e);const i=JSON.stringify(e,null,2);if(i.length>C)throw new w([{path:"$",message:"模板 JSON 超过 1000 万字符的导出/导入上限"}]);return i}function R(e){return JSON.parse(JSON.stringify(e))}function Ue(e=[]){const i=new Map,t={get:s=>{const n=i.get(s);return n?R(n):void 0},list:()=>Array.from(i.values(),({template:s,...n})=>({...n})),register:(s,n={})=>{if(T(s),i.has(s.id)&&!n.replace)throw new w([{path:"$.id",message:`模板 ID ${s.id} 已注册;更新需显式 replace:true`}]);i.set(s.id,R(s))},remove:s=>i.delete(s)};for(const s of e)t.register(s);return t}exports.REPORT_TEMPLATE_DOCUMENT_VERSION=L;exports.ReportTemplateError=w;exports.assertRenderPlan=ye;exports.createTemplateRegistry=Ue;exports.defineReportTemplate=Je;exports.parseReportTemplate=We;exports.reportFlowGroups=be;exports.serializeReportTemplate=Ge;exports.validateComponent=F;exports.validatePage=B;exports.validateRenderPlan=z;exports.validateReportPageFlow=X;exports.validateReportTemplate=se;exports.validateReportTemplateDocument=ne;exports.validateTemplateRepeat=Q;
|
package/dist/tree-CLpxYbKa.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const s=require("./computed-C2GD3XcE.cjs");class g extends Error{constructor(r){super(`树节点超出行数预算 ${r}`),this.limit=r,this.code="tree-row-limit",this.name="TreeRowLimitError"}}function u(e,r,i,t){const n=e??r;if(!Number.isInteger(n)||n<1||n>i)throw new Error(`${t}应为 1–${i} 的整数`);return n}function w(e){return{rows:u(e.maxRows,1e5,1e6,"树行数预算"),depth:u(e.maxDepth,64,256,"树深度预算"),visits:u(e.maxAggregationVisits,1e6,1e7,"树聚合访问预算")}}function m(e){return typeof e=="string"&&!!e.trim()}function c(e){return m(e)&&!["__proto__","prototype","constructor"].includes(e)}function E(e){if(m(e)||typeof e=="number"&&Number.isFinite(e))return e;throw new Error("树节点业务键应为非空字符串或有限数字")}function p(e){return JSON.stringify([typeof e,e])}function F(e){return[e.idField,...e.input==="flat"?[e.parentField??""]:[e.childrenField??"children"]]}function y(e,r){const i=F(e);if(r?.some(t=>t.scope&&t.scope!=="row"||i.includes(t.field)))throw new Error("树形布局仅支持不覆盖结构键的当前行计算")}function h(e){if(!e?.aborted)return;const r=new Error("树报表处理已取消");throw r.name="AbortError",r}function k(e){const r=e.aggregates??[];if(!Array.isArray(r)||r.length>32)throw new Error("树聚合最多 32 项");if(e.parentValues!=="leaf-aggregate"&&r.length)throw new Error("树聚合需显式选择 leaf-aggregate 父级取值策略");if(e.parentValues==="leaf-aggregate"&&!r.length)throw new Error("叶子聚合策略至少需要一个聚合字段");const i=new Set;for(const t of r){if(!t||!c(t.field)||i.has(t.field))throw new Error("树聚合输出字段应安全、非空且唯一");for(const n of[t.valueField,t.weightField])if(n!==void 0&&!c(n))throw new Error("树聚合来源字段应安全且非空");if([...F(e),e.labelField].includes(t.field))throw new Error("树聚合不能覆盖结构键或标签字段");i.add(t.field),s.createAggregateAccumulator({...t,field:t.valueField??t.field})}}function N(e){if(!c(e.idField)||!c(e.labelField))throw new Error("树需要安全的业务键和标签字段");if(e.input==="flat"&&(!c(e.parentField)||e.parentField===e.idField))throw new Error("扁平树需要独立的父键字段");if(e.childrenField!==void 0&&!c(e.childrenField))throw new Error("子节点字段应安全且非空");if(e.input==="nested"&&[e.idField,e.labelField].includes(e.childrenField??"children"))throw new Error("子节点字段不能覆盖业务键或标签字段")}function v(e){if(!e||typeof e!="object"||!["flat","nested"].includes(e.input))throw new Error("树输入应为 flat 或 nested");if(N(e),e.orphan!==void 0&&!["error","root"].includes(e.orphan))throw new Error("树孤儿策略应为 error 或 root");if(e.parentValues!==void 0&&!["source","leaf-aggregate"].includes(e.parentValues))throw new Error("未知树父级取值策略");if(e.indentMm!==void 0&&(!Number.isFinite(e.indentMm)||e.indentMm<0||e.indentMm>20))throw new Error("树每级缩进应为 0–20 mm");w(e),k(e)}function A(e,r,i,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("树节点应为对象");if(i.size>=t.rows)throw new g(t.rows);const n=E(e[r.idField]),l=p(n);if(i.has(l))throw new Error(`树节点业务键重复:${String(n)}`);const o={original:e,row:e,key:n,depth:0,children:[]};return i.set(l,o),o}function $(e,r,i,t,n){for(const o of e)h(n),A(o,r,i,t);const l=[];for(const o of i.values()){h(n);const a=o.row[r.parentField];if(a==null){l.push(o);continue}const d=i.get(p(E(a)));if(!d){if(r.orphan!=="root")throw new Error(`树节点 ${String(o.key)} 的父节点不存在`);l.push(o);continue}if(d===o)throw new Error("树节点不能以自身为父节点");o.parent=d,d.children.push(o)}return l}function M(e,r,i,t,n){const l=[],o=[{rows:e,next:0}];for(;o.length;){h(n);const a=o[o.length-1];if(a.next>=a.rows.length){o.pop();continue}const d=A(a.rows[a.next++],r,i,t);if(d.parent=a.parent,d.depth=o.length-1,o.length>t.depth)throw new Error(`树节点超出深度预算 ${t.depth}`);(a.parent?.children??l).push(d);const f=d.row[r.childrenField??"children"];if(f!=null){if(!Array.isArray(f))throw new Error("嵌套树 children 字段应为数组");f.length&&o.push({rows:f,next:0,parent:d})}}return l}function V(e,r,i,t){const n=[],l=[{nodes:e,next:0}];for(;l.length;){h(t);const o=l[l.length-1];if(o.next>=o.nodes.length){l.pop();continue}if(l.length>i.depth)throw new Error(`树节点超出深度预算 ${i.depth}`);const a=o.nodes[o.next++];a.depth=l.length-1,n.push(a),a.children.length&&l.push({nodes:a.children,next:0})}if(n.length!==r)throw new Error("树父子关系存在循环");return n}function S(e,r,i,t){if(r.parentValues!=="leaf-aggregate")return;const n=r.aggregates,l=new Map;for(const a of e)a.children.length&&l.set(a,n.map(d=>s.createAggregateAccumulator({...d,field:d.valueField??d.field})));let o=0;for(const a of e)if(!a.children.length)for(let d=a.parent;d;d=d.parent){if(h(t),o+=n.length,o>i.visits)throw new Error(`树聚合超出访问预算 ${i.visits}`);for(const f of l.get(d))f.add(a.row)}for(const[a,d]of l)a.row={...a.row},n.forEach((f,T)=>{a.row[f.field]=d[T].value()})}function b(e,r,i){if(v(r),h(i),!Array.isArray(e))throw new Error("树数据应为节点数组");const t=w(r),n=new Map,l=r.input==="flat"?$(e,r,n,t,i):M(e,r,n,t,i);return V(l,n.size,t,i)}function x(e,r,i){return b(e,r,i).map(t=>t.original)}function O(e,r,i={}){const t=b(e,r,i.signal);if(y(r,i.computed?.fields),i.computed?.fields.length){const n=s.computeDataset(t.map(l=>l.row),{...i.computed,signal:i.signal}).rows;t.forEach((l,o)=>{l.row=n[o]})}return S(t,r,w(r),i.signal),{rows:t.map(n=>n.row),entries:t.map(n=>({row:n.row,original:n.original,key:n.key,depth:n.depth,hasChildren:!!n.children.length})),leaves:t.filter(n=>!n.children.length).map(n=>n.row)}}exports.TreeRowLimitError=g;exports.createTreeTable=O;exports.flattenTreeInput=x;exports.validateTreeComputed=y;exports.validateTreeOptions=v;
|