@agile-team/mach-report 2.22.0 → 2.23.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 +7 -6
- package/dist/{ExcelBindingWizard-CZyppD7I.js → ExcelBindingWizard-D4FLind-.js} +3 -3
- package/dist/{ExcelBindingWizard-CW79I6Gl.cjs → ExcelBindingWizard-D4RS5Bpg.cjs} +1 -1
- package/dist/{ParamEditor-CiYCJI0b.cjs → ParamEditor-C-6C9rd2.cjs} +1 -1
- package/dist/{ParamEditor-DQit-Gdf.js → ParamEditor-CASZt-Ma.js} +2 -2
- package/dist/{ReportBatchPanel-DKTpV7MU.js → ReportBatchPanel-Bq7t8a5r.js} +2 -2
- package/dist/{ReportBatchPanel-Db6TAfG5.cjs → ReportBatchPanel-YVj5IO5y.cjs} +1 -1
- package/dist/ReportLabelStudio-Cqhita1b.cjs +1 -0
- package/dist/{ReportLabelStudio-BYnRqmje.js → ReportLabelStudio-Dj7GXhuv.js} +295 -292
- package/dist/ReportParamPanel-DZbFVmDL.cjs +1 -0
- package/dist/{ReportParamPanel-BHSKVL8k.js → ReportParamPanel-Dgmqro1Y.js} +93 -79
- package/dist/ReportPreview-DeWzG8jQ.js +6257 -0
- package/dist/ReportPreview-FFIryrIr.cjs +6 -0
- package/dist/{ReportTemplateLibrary-DEXH07ND.cjs → ReportTemplateLibrary-BaWodmpm.cjs} +1 -1
- package/dist/{ReportTemplateLibrary-BZuKn0YK.js → ReportTemplateLibrary-DdAAAD2I.js} +1 -1
- package/dist/{RuleEditor-CIQn547x.js → RuleEditor-D2UwQGF6.js} +59 -59
- package/dist/{RuleEditor-zSUmPjKa.cjs → RuleEditor-DcT9xI1v.cjs} +1 -1
- package/dist/TemplateOutlinePanel-CUHFFiNM.cjs +1 -0
- package/dist/{TemplateOutlinePanel-D0PgOSQE.js → TemplateOutlinePanel-DrT7XN0m.js} +2 -2
- package/dist/{TemplateReusePanel-BKlAEF8-.js → TemplateReusePanel-4eejkNqi.js} +2 -2
- package/dist/{TemplateReusePanel-DAy_Hwqz.cjs → TemplateReusePanel-DZMyiX5I.cjs} +1 -1
- package/dist/{TemplateReviewPanel-div-EH_m.js → TemplateReviewPanel-BIhNLeNw.js} +2 -2
- package/dist/{TemplateReviewPanel-CowmHaQQ.cjs → TemplateReviewPanel-DnYImiXu.cjs} +1 -1
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.js +26 -26
- package/dist/artifact-integrity.json +106 -104
- package/dist/assets-D2gHc4Mz.cjs +1 -0
- package/dist/assets-T_gDeFaz.js +132 -0
- package/dist/auto-4pK9HePf.cjs +1 -0
- package/dist/auto-CTIJ6PnR.js +257 -0
- package/dist/capabilities-DiBj4Qgl.cjs +1 -0
- package/dist/capabilities-pg7j7VLT.js +106 -0
- package/dist/charts-Cjw5AYkg.cjs +1 -0
- package/dist/{charts-Dlv8j2AG.js → charts-CxJZ0XaY.js} +1 -1
- package/dist/computed-DK6BruFz.cjs +1 -0
- package/dist/{computed-C8NRZQss.js → computed-f3pOqWLX.js} +381 -301
- package/dist/data-bar-CeZuFmYl.cjs +1 -0
- package/dist/{data-bar-8baGYEZ9.js → data-bar-IkI6VvMQ.js} +1 -1
- package/dist/designer-DhrE7jzw.js +7169 -0
- package/dist/designer-IAZu6kBX.cjs +2 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +98 -45
- package/dist/designer.d.ts +98 -45
- package/dist/designer.js +3 -3
- package/dist/dom-ChE5D-L-.cjs +1 -0
- package/dist/dom-JWrchIre.js +452 -0
- package/dist/dom-cell-address-DLD1mkTB.cjs +1 -0
- package/dist/dom-cell-address-Fn-8nk7D.js +11 -0
- package/dist/{encoding-ncQAvyOv.cjs → encoding-BefcaHdp.cjs} +1 -1
- package/dist/{encoding-DbnhbwI8.js → encoding-CL6rXEkR.js} +2 -2
- package/dist/{font-loader-Di0lQKFf.js → font-loader-BT5baV-o.js} +1 -1
- package/dist/{font-loader-BB372_XN.cjs → font-loader-Ga51c2VC.cjs} +1 -1
- package/dist/grid-strokes-Be24LGuV.cjs +1 -0
- package/dist/grid-strokes-EoY66L2f.js +53 -0
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +944 -1259
- package/dist/json-snapshot-1tvQNzQE.cjs +2 -0
- package/dist/{json-snapshot-DvQbZlD7.js → json-snapshot-OqkPyUk5.js} +763 -776
- package/dist/matrix-B8QWbsGM.cjs +1 -0
- package/dist/matrix-C6e_r_vp.js +302 -0
- package/dist/{pdf-CARdBcuw.cjs → pdf-HiEeXe9H.cjs} +42 -42
- package/dist/{pdf-DmlnL5eB.js → pdf-aobetCsy.js} +20 -20
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.js +2 -2
- package/dist/{plugin-AcAQ2m9X.cjs → plugin-BFANt-i8.cjs} +1 -1
- package/dist/{plugin-w5Nyt08U.js → plugin-DeYYAL6F.js} +1 -1
- package/dist/{prefill-BXBxx5We.js → prefill-Dk4C6S5R.js} +21 -21
- package/dist/prefill-DsUD5OoK.cjs +1 -0
- package/dist/prepared-DCIxhKFo.js +94 -0
- package/dist/prepared-Dv-XM3i1.cjs +1 -0
- package/dist/progress-ByiOxUD3.js +250 -0
- package/dist/progress-WomPRP3B.cjs +1 -0
- package/dist/{protocol-C9ZaylID.cjs → protocol-B9YgfQ_d.cjs} +1 -1
- package/dist/{protocol-fjaeKkjf.js → protocol-DxeUKGYG.js} +3 -3
- package/dist/record-bindings-DatJZv_e.js +200 -0
- package/dist/record-bindings-MBxbeBsi.cjs +1 -0
- package/dist/{region-binding-workflow-aA8nxmkZ.js → region-binding-workflow-DjrXuR1q.js} +2 -2
- package/dist/{region-binding-workflow-BiJQ7NU6.cjs → region-binding-workflow-l7NGfagJ.cjs} +2 -2
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/rich-text-layout-Ciwa6D2o.js +52 -0
- package/dist/rich-text-layout-DK7A_a5r.cjs +3 -0
- package/dist/{runtime-BTtpjF3D.js → runtime-75Y5Oq5B.js} +52 -51
- package/dist/runtime-DKlGd_D4.cjs +1 -0
- package/dist/sbom.cdx.json +1 -1
- package/dist/server-node.cjs +5 -5
- package/dist/server-node.js +1642 -1586
- package/dist/server.cjs +1 -1
- package/dist/server.js +24 -24
- package/dist/style.css +1 -1
- package/dist/{template-catalog-JSxSqk5y.js → template-catalog--cjxzgH7.js} +17 -17
- package/dist/template-catalog-CoT7jm_6.cjs +1 -0
- package/dist/{template-fragments-D2JFj7Du.js → template-fragments-CPpGpQoz.js} +12 -12
- package/dist/template-fragments-GVjpew_q.cjs +1 -0
- package/dist/template-registry-DI59PXVK.cjs +1 -0
- package/dist/{template-registry-Do1Uav2Z.js → template-registry-O0hNIOfB.js} +17 -17
- package/dist/{template-serialization-CU4n_Miu.js → template-serialization-CWmHq7lX.js} +1 -1
- package/dist/{template-serialization-CgqBo6s-.cjs → template-serialization-CqQY4zDg.cjs} +1 -1
- package/dist/{textwrap-CkGjRFT3.js → textwrap-BIjtEWmq.js} +1 -1
- package/dist/textwrap-Cy7o1hIR.cjs +4 -0
- package/dist/vue/async.d.cts +24 -0
- package/dist/vue/async.d.ts +24 -0
- package/dist/vue/index.d.cts +25 -1
- package/dist/vue/index.d.ts +25 -1
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +52 -47
- package/dist/{workbook-session-BvEBRRMz.cjs → workbook-session-C6-SrnCT.cjs} +4 -4
- package/dist/{workbook-session-f0wVlzst.js → workbook-session-C9ZmCBwY.js} +15 -16
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +4 -4
- package/dist/xlsx.cjs +4 -4
- package/dist/xlsx.js +184 -179
- package/package.json +1 -1
- package/dist/ReportLabelStudio-B0i9ohQj.cjs +0 -1
- package/dist/ReportParamPanel-lngONOEz.cjs +0 -1
- package/dist/ReportPreview-BDgKssYR.js +0 -5887
- package/dist/ReportPreview-Dw-4icG6.cjs +0 -6
- package/dist/TemplateOutlinePanel-B5SfGYVN.cjs +0 -1
- package/dist/assets-CxHunY_9.js +0 -232
- package/dist/assets-vbjAGgk8.cjs +0 -1
- package/dist/auto-DcUHlKob.cjs +0 -1
- package/dist/auto-moShblh1.js +0 -240
- package/dist/charts-aCtoswXq.cjs +0 -1
- package/dist/component-tree-1_QCiQJX.js +0 -67
- package/dist/component-tree-BjZIp6w9.cjs +0 -1
- package/dist/computed-4TnxzgIh.cjs +0 -1
- package/dist/data-bar-YltqGTaC.cjs +0 -1
- package/dist/designer-B7jJeAeG.js +0 -6914
- package/dist/designer-BWQVpJeN.cjs +0 -2
- package/dist/grid-geometry-D3SJgWFv.js +0 -136
- package/dist/grid-geometry-D8ReblRV.cjs +0 -1
- package/dist/json-snapshot-nyV63AbB.cjs +0 -2
- package/dist/matrix-0hywp0-F.cjs +0 -1
- package/dist/matrix-Dy-tyY7E.js +0 -381
- package/dist/prefill-DUvejVt1.cjs +0 -1
- package/dist/prepared-YXy-fVLw.cjs +0 -1
- package/dist/prepared-rXCKqdHY.js +0 -88
- package/dist/progress-B0ctFpKf.cjs +0 -1
- package/dist/progress-Hc2vxoCs.js +0 -52
- package/dist/record-bindings-Ct1HkPrc.cjs +0 -1
- package/dist/record-bindings-VZGS-Qd8.js +0 -155
- package/dist/rich-text-layout-K48VHUoW.cjs +0 -3
- package/dist/rich-text-layout-wxBhnAS7.js +0 -102
- package/dist/runtime-Dq0LUsyS.cjs +0 -1
- package/dist/template-catalog-CLAM4w7H.cjs +0 -1
- package/dist/template-fragments-Ca25Jt7e.cjs +0 -1
- package/dist/template-outline-CDWXptuj.js +0 -88
- package/dist/template-outline-K4jGhATu.cjs +0 -1
- package/dist/template-registry-CWnuGqyP.cjs +0 -1
- package/dist/textwrap-OTOUMr4f.cjs +0 -4
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { R as be } from "./
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { c as
|
|
6
|
-
import {
|
|
7
|
-
import { b as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const hr = 4096, Ne = 128 * 1024;
|
|
15
|
-
function gr(e) {
|
|
1
|
+
import { r as te, a as re, L as ye, b as Wt, R as be, j as Vt, m as j, D as We } from "./progress-ByiOxUD3.js";
|
|
2
|
+
import { w as _, h as Ve } from "./textwrap-BIjtEWmq.js";
|
|
3
|
+
import { e as ve, n as H, b as Me, q as N, s as zt, t as Jt } from "./computed-f3pOqWLX.js";
|
|
4
|
+
import { d as ze, R as $, f as W, k as Je, b as _t, i as qt, v as Se, c as Ut, P as Y, l as xe, t as _e, m as qe, h as Ue, n as Xt, o as Yt, D as Qt, e as fe } from "./record-bindings-DatJZv_e.js";
|
|
5
|
+
import { c as Zt, e as er } from "./matrix-C6e_r_vp.js";
|
|
6
|
+
import { f as Xe, d as tr, e as rr, c as Ye } from "./template-serialization-CWmHq7lX.js";
|
|
7
|
+
import { j as nr, r as or, k as ar, b as Qe, v as sr, R as ir } from "./template-registry-O0hNIOfB.js";
|
|
8
|
+
import { g as cr } from "./report-params-D9tBuM9B.js";
|
|
9
|
+
import { a as Oe } from "./param-validation-CnDEd2l-.js";
|
|
10
|
+
import { f as lr, i as dr } from "./number-format-BA_KwrZe.js";
|
|
11
|
+
import { v as Ze, d as ur } from "./dataset-DL83majE.js";
|
|
12
|
+
const fr = 4096, Ae = 128 * 1024;
|
|
13
|
+
function mr(e) {
|
|
16
14
|
const t = /* @__PURE__ */ new Map();
|
|
17
15
|
let r = 0;
|
|
18
16
|
return { measureMm(n, o) {
|
|
@@ -20,8 +18,8 @@ function gr(e) {
|
|
|
20
18
|
if (s !== void 0)
|
|
21
19
|
return t.delete(a), t.set(a, s), s;
|
|
22
20
|
const i = e.measureMm(n, o);
|
|
23
|
-
if (Number.isFinite(i) && a.length <=
|
|
24
|
-
for (; t.size >=
|
|
21
|
+
if (Number.isFinite(i) && a.length <= Ae) {
|
|
22
|
+
for (; t.size >= fr || r + a.length > Ae; ) {
|
|
25
23
|
const c = t.keys().next().value;
|
|
26
24
|
r -= c.length, t.delete(c);
|
|
27
25
|
}
|
|
@@ -30,48 +28,10 @@ function gr(e) {
|
|
|
30
28
|
return i;
|
|
31
29
|
} };
|
|
32
30
|
}
|
|
33
|
-
|
|
34
|
-
constructor(t, r) {
|
|
35
|
-
super(`报表页数超出上限 ${t}(至少 ${r} 页)`), this.limit = t, this.actual = r, this.code = "page-limit", this.name = "PaginatePageLimitError";
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
class Y extends Error {
|
|
39
|
-
constructor(t, r) {
|
|
40
|
-
super(`报表单元格数量超出上限 ${t}(至少 ${r} 格)`), this.limit = t, this.actual = r, this.code = "cell-limit", this.name = "PaginateCellLimitError";
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
class Q extends Error {
|
|
44
|
-
constructor(t, r) {
|
|
45
|
-
super(`报表图表图元数量预计超出上限 ${t}(本次估算 ${r})`), this.limit = t, this.estimated = r, this.code = "chart-component-limit", this.name = "PaginateChartComponentLimitError";
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const Ce = 5e4;
|
|
49
|
-
function oe(e = Ce) {
|
|
50
|
-
if (!Number.isSafeInteger(e) || e < 1 || e > 1e6) throw new RangeError("maxChartComponents 应为 1..1000000 的安全整数");
|
|
51
|
-
}
|
|
52
|
-
function pr(e, t, r) {
|
|
53
|
-
const n = e.chartBinding;
|
|
54
|
-
if (e.kind !== "chart" || e.grid || e.imageData || e.binding || e.pageAnchor) throw new TypeError("绑定图表不能同时设置图片、网格、记录绑定或页眉页脚");
|
|
55
|
-
const o = Object.prototype.hasOwnProperty.call(t, n.dataset) ? t[n.dataset] : void 0;
|
|
56
|
-
if (!Array.isArray(o)) throw new TypeError(`图表数据集 ${n.dataset} 未提供`);
|
|
57
|
-
return { ...er(o, n, r), type: n.type, leftMm: e.leftMm, topMm: e.topMm, widthMm: e.widthMm, heightMm: e.heightMm, title: n.title, showValues: n.showValues };
|
|
58
|
-
}
|
|
59
|
-
function wr(e, t, r = Ce) {
|
|
60
|
-
oe(r);
|
|
61
|
-
let n = 0;
|
|
62
|
-
return Object.assign((a) => {
|
|
63
|
-
if (!a.chartBinding) return [a];
|
|
64
|
-
const s = pr(a, e, t), i = n + (s.categories.length ? Qt(s) : 1);
|
|
65
|
-
if (!Number.isSafeInteger(i)) throw new RangeError("图表图元估算应为有限安全整数");
|
|
66
|
-
if (i > r) throw new Q(r, i);
|
|
67
|
-
const c = s.categories.length ? Zt(s) : [{ kind: "text", leftMm: a.leftMm, topMm: a.topMm, widthMm: a.widthMm, heightMm: a.heightMm, text: "—", style: { align: "center", verticalAlign: "middle", color: "#94a3b8", fontSize: 10 } }];
|
|
68
|
-
return n += c.length, c;
|
|
69
|
-
}, { used: () => n });
|
|
70
|
-
}
|
|
71
|
-
function yr(e, t) {
|
|
31
|
+
function hr(e, t) {
|
|
72
32
|
return { member: "body", subtotal: "subtotal", total: "grand-total" }[e?.rows.get(t)?.kind ?? "member"];
|
|
73
33
|
}
|
|
74
|
-
function
|
|
34
|
+
function gr(e) {
|
|
75
35
|
const t = e.matrix;
|
|
76
36
|
if (!t.hierarchy) return t;
|
|
77
37
|
const r = new Map(e.columns.map((o) => [o.field, o.header])), n = { sum: "求和", count: "计数", avg: "平均", min: "最小", max: "最大", weightedAvg: "加权平均" };
|
|
@@ -84,10 +44,10 @@ function br(e) {
|
|
|
84
44
|
return o.label === void 0 && a ? { ...o, label: `${a}(${n[o.op]})` } : o;
|
|
85
45
|
}) };
|
|
86
46
|
}
|
|
87
|
-
function
|
|
47
|
+
function pr(e, t) {
|
|
88
48
|
if (!e.matrix) return { list: e, rows: t };
|
|
89
49
|
if (e.detail || e.groupBy || e.groups?.length || e.grandTotal) throw new Error("矩阵不能同时配置普通分组、总计或主从明细");
|
|
90
|
-
const r =
|
|
50
|
+
const r = Zt(t, gr(e)), n = r.columns.map((i) => ({ ...i, widthMm: i.semanticRole === "dimension" ? e.matrix.rowWidthMm ?? 40 : e.matrix.columnWidthMm ?? 28, editable: !1, align: i.semanticRole === "dimension" ? "center" : "right" })), o = { ...e, columns: n, headerGrid: r.headerGrid, rowKey: void 0, revisionField: void 0, sourceTokenField: void 0 };
|
|
91
51
|
e.layout === "wide" && (o.widthMm = n.reduce((i, c) => i + c.widthMm, 0));
|
|
92
52
|
const a = r.metadata, s = a ? { rows: new WeakMap(r.rows.map((i, c) => [i, a.rows[c]])), header: {
|
|
93
53
|
columns: a.columns,
|
|
@@ -98,37 +58,37 @@ function vr(e, t) {
|
|
|
98
58
|
} } : void 0;
|
|
99
59
|
return { list: o, rows: r.rows, ...s ? { matrix: s } : {} };
|
|
100
60
|
}
|
|
101
|
-
function
|
|
61
|
+
function wr(e, t) {
|
|
102
62
|
if (!e.matrix?.hierarchy || !e.headerGrid) return e.headerGrid;
|
|
103
|
-
const r = e.paddingMm ?? 1, n = e.headerGrid.cells.map(() => e.rowHeightMm ?? 0), o = e.columns.map((c) => c.widthMm), a =
|
|
104
|
-
for (const { cell: c, ci: l, ri:
|
|
105
|
-
const
|
|
106
|
-
for (let
|
|
107
|
-
s.set(c,
|
|
63
|
+
const r = e.paddingMm ?? 1, n = e.headerGrid.cells.map(() => e.rowHeightMm ?? 0), o = e.columns.map((c) => c.widthMm), a = te({ ...e.headerGrid, colWidthsMm: o }, o.reduce((c, l) => c + l, 0), n.length), s = /* @__PURE__ */ new WeakMap();
|
|
64
|
+
for (const { cell: c, ci: l, ri: u, widthMm: f } of a.cells) {
|
|
65
|
+
const d = { ...ze(e, e.columns[l]), ...c.style }, h = re(d).fontSizePt, v = (_(c.text ?? "", Math.max(1, f - r * 2), { fontSizePt: h, fontFamily: d.fontFamily, bold: d.bold, italic: d.italic, letterSpacingPt: d.letterSpacing }, t).length * h * (d.lineHeight ?? ye) * 25.4 / 72 + r * 2) / (c.rowSpan ?? 1);
|
|
66
|
+
for (let p = u; p < u + (c.rowSpan ?? 1); p++) n[p] = Math.max(n[p] ?? 0, v);
|
|
67
|
+
s.set(c, d);
|
|
108
68
|
}
|
|
109
69
|
const i = e.headerGrid.cells.map((c) => c.map((l) => l ? { ...l, style: s.get(l) } : null));
|
|
110
70
|
return { ...e.headerGrid, cells: i, rowHeightsMm: n };
|
|
111
71
|
}
|
|
112
|
-
function
|
|
72
|
+
function yr(e, t, r) {
|
|
113
73
|
const n = /* @__PURE__ */ new Set(), o = e.cells.map((a, s) => {
|
|
114
74
|
const i = [];
|
|
115
75
|
let c = 0;
|
|
116
76
|
for (const l of a) {
|
|
117
77
|
for (; n.has(`${s}:${c}`); ) c++;
|
|
118
|
-
const
|
|
119
|
-
let
|
|
120
|
-
for (let h = c; h < c +
|
|
121
|
-
t.has(h) &&
|
|
78
|
+
const u = l?.colSpan ?? 1, f = l?.rowSpan ?? 1;
|
|
79
|
+
let d = 0;
|
|
80
|
+
for (let h = c; h < c + u; h++) {
|
|
81
|
+
t.has(h) && d++;
|
|
122
82
|
for (let m = s + 1; m < s + f; m++)
|
|
123
83
|
n.add(`${m}:${h}`);
|
|
124
84
|
}
|
|
125
|
-
|
|
85
|
+
d && i.push(l ? { ...l, colSpan: d } : null), c += u;
|
|
126
86
|
}
|
|
127
87
|
return i;
|
|
128
88
|
});
|
|
129
89
|
return { ...e, cells: o, colWidthsMm: r };
|
|
130
90
|
}
|
|
131
|
-
function
|
|
91
|
+
function br(e) {
|
|
132
92
|
if (!e.columns.some((n) => n.hidden)) return e;
|
|
133
93
|
const t = /* @__PURE__ */ new Set(), r = e.columns.filter((n, o) => n.hidden ? !1 : (t.add(o), !0));
|
|
134
94
|
if (!r.length) throw new Error("列表至少需要一列可见列");
|
|
@@ -136,7 +96,7 @@ function xr(e) {
|
|
|
136
96
|
...e,
|
|
137
97
|
columns: r,
|
|
138
98
|
...e.headerGrid ? {
|
|
139
|
-
headerGrid:
|
|
99
|
+
headerGrid: yr(
|
|
140
100
|
e.headerGrid,
|
|
141
101
|
t,
|
|
142
102
|
r.map((n) => n.widthMm)
|
|
@@ -144,34 +104,34 @@ function xr(e) {
|
|
|
144
104
|
} : {}
|
|
145
105
|
};
|
|
146
106
|
}
|
|
147
|
-
function*
|
|
107
|
+
function* vr(e) {
|
|
148
108
|
const { page: t } = e;
|
|
149
|
-
|
|
109
|
+
nr(t.components, t.flow);
|
|
150
110
|
let r = 0, n = 0;
|
|
151
|
-
for (const o of
|
|
111
|
+
for (const o of or(t.components, t.flow)) {
|
|
152
112
|
e.active();
|
|
153
|
-
const a = o.band, s = o.components.some((
|
|
113
|
+
const a = o.band, s = o.components.some((u) => u.kind === "list" && u.cardinality !== "record"), i = s ? 0 : o.components.reduce((u, f) => Math.max(u, f.topMm - a.topMm + (f.kind === "list" ? e.height(f) : f.heightMm)), a.heightMm);
|
|
154
114
|
let c = Math.max(e.top(), n + a.topMm - r);
|
|
155
115
|
if (!s && i > e.bottom() - e.top() + 1e-3) throw new Error(`静态区域 ${a.componentIds.join(",")} 高度超出单页可用范围`);
|
|
156
116
|
!s && c + i > e.bottom() + 1e-3 && (e.nextPage(), yield* e.takePages(), e.active(), c = e.top());
|
|
157
117
|
let l = c + i;
|
|
158
|
-
for (const
|
|
159
|
-
const f = c +
|
|
160
|
-
|
|
161
|
-
l = s ?
|
|
162
|
-
}), e.active()) : e.append({ ...
|
|
118
|
+
for (const u of o.components) {
|
|
119
|
+
const f = c + u.topMm - a.topMm;
|
|
120
|
+
u.kind === "list" ? (yield* e.list(u, f, (d) => {
|
|
121
|
+
l = s ? d : Math.max(l, d);
|
|
122
|
+
}), e.active()) : e.append({ ...u, topMm: f });
|
|
163
123
|
}
|
|
164
124
|
n = l, r = a.topMm + a.heightMm;
|
|
165
125
|
}
|
|
166
126
|
}
|
|
167
|
-
function
|
|
127
|
+
function Mr(e) {
|
|
168
128
|
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));
|
|
169
129
|
}
|
|
170
|
-
function
|
|
171
|
-
return e.pages.some((t) => t.components.some((r) => r.kind === "list" ?
|
|
130
|
+
function Ce(e) {
|
|
131
|
+
return e.pages.some((t) => t.components.some((r) => r.kind === "list" ? Mr(r) : !!r.chartBinding));
|
|
172
132
|
}
|
|
173
|
-
const
|
|
174
|
-
function
|
|
133
|
+
const Sr = 512, Ke = 256 * 1024;
|
|
134
|
+
function xr() {
|
|
175
135
|
const e = /* @__PURE__ */ new Map();
|
|
176
136
|
let t = 0, r;
|
|
177
137
|
return (n, o, a, s) => {
|
|
@@ -179,109 +139,109 @@ function Pr() {
|
|
|
179
139
|
const i = JSON.stringify([n, o, a.fontSizePt, a.fontFamily, a.bold, a.italic, a.letterSpacingPt]), c = e.get(i);
|
|
180
140
|
if (c)
|
|
181
141
|
return e.delete(i), e.set(i, c), c.lines.slice();
|
|
182
|
-
const l = _(n, o, a, s),
|
|
183
|
-
if (
|
|
184
|
-
for (; e.size >=
|
|
142
|
+
const l = _(n, o, a, s), u = i.length + l.reduce((f, d) => f + d.length, 0);
|
|
143
|
+
if (u <= Ke) {
|
|
144
|
+
for (; e.size >= Sr || t + u > Ke; ) {
|
|
185
145
|
const f = e.keys().next().value;
|
|
186
146
|
t -= e.get(f).units, e.delete(f);
|
|
187
147
|
}
|
|
188
|
-
e.set(i, { lines: l.slice(), units:
|
|
148
|
+
e.set(i, { lines: l.slice(), units: u }), t += u;
|
|
189
149
|
}
|
|
190
150
|
return l;
|
|
191
151
|
};
|
|
192
152
|
}
|
|
193
|
-
const
|
|
194
|
-
function
|
|
153
|
+
const Cr = 1e4, je = 25e4;
|
|
154
|
+
function ke(e) {
|
|
195
155
|
if (e?.aborted) throw e.reason ?? new DOMException("标签生成已取消", "AbortError");
|
|
196
156
|
}
|
|
197
|
-
function
|
|
198
|
-
const n = typeof e.copies == "object" ?
|
|
199
|
-
if (typeof n != "number" || !Number.isSafeInteger(n) || n < 1 || n > 1e3) throw new
|
|
157
|
+
function et(e, t, r) {
|
|
158
|
+
const n = typeof e.copies == "object" ? Je(t, e.copies.field, r) : e.copies ?? 1;
|
|
159
|
+
if (typeof n != "number" || !Number.isSafeInteger(n) || n < 1 || n > 1e3) throw new $(`$.datasets.${r.dataset}[${r.rowIndex}]`, "每条记录复制数必须是 1..1000 的数值型整数", r.rowIndex, typeof e.copies == "object" ? e.copies.field : void 0);
|
|
200
160
|
return n;
|
|
201
161
|
}
|
|
202
|
-
function
|
|
162
|
+
function tt(e, t, r) {
|
|
203
163
|
if (e.rowKey === void 0) return;
|
|
204
|
-
const n =
|
|
164
|
+
const n = Je(t, e.rowKey, r);
|
|
205
165
|
if (typeof n == "string" && n.trim() || typeof n == "number" && Number.isFinite(n)) return n;
|
|
206
|
-
throw new
|
|
166
|
+
throw new $(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`, "业务主键必须是非空字符串或有限数字", r.rowIndex, e.rowKey);
|
|
207
167
|
}
|
|
208
|
-
function
|
|
168
|
+
function kr(e) {
|
|
209
169
|
const t = (r) => 1 + (r.grid?.cells.reduce((n, o) => n + 1 + o.length + o.reduce((a, s) => a + (s?.children?.reduce((i, c) => i + t(c), 0) ?? 0), 0), 0) ?? 0);
|
|
210
170
|
return e.pages.reduce((r, n) => r + n.components.reduce((o, a) => o + t(a), 0), 0);
|
|
211
171
|
}
|
|
212
|
-
function
|
|
172
|
+
function Tr(e, t, r) {
|
|
213
173
|
const n = e.repeat, o = Object.prototype.hasOwnProperty.call(t, n.dataset) ? t[n.dataset] : void 0;
|
|
214
|
-
if (!Array.isArray(o)) throw new
|
|
215
|
-
const a = /* @__PURE__ */ new Set(), s = r.maxPages ??
|
|
174
|
+
if (!Array.isArray(o)) throw new $(`$.datasets.${n.dataset}`, "逐记录标签数据集缺失,应提供对象数组(允许空数组)");
|
|
175
|
+
const a = /* @__PURE__ */ new Set(), s = r.maxPages ?? Cr, i = kr(e);
|
|
216
176
|
let c = 0, l = 0;
|
|
217
|
-
for (const [
|
|
218
|
-
if (
|
|
219
|
-
const
|
|
177
|
+
for (const [u, f] of o.entries()) {
|
|
178
|
+
if (ke(r.signal), !f || typeof f != "object" || Array.isArray(f)) throw new $(`$.datasets.${n.dataset}[${u}]`, "标签记录应为对象", u);
|
|
179
|
+
const d = { rowIndex: u, dataset: n.dataset }, h = tt(n, f, d);
|
|
220
180
|
if (h !== void 0) {
|
|
221
181
|
const v = JSON.stringify([typeof h, h]);
|
|
222
|
-
if (a.has(v)) throw new
|
|
182
|
+
if (a.has(v)) throw new $(`$.datasets.${n.dataset}[${u}].${n.rowKey}`, "业务主键重复;请先确认记录来源,避免重复打印标签", u, n.rowKey);
|
|
223
183
|
a.add(v);
|
|
224
184
|
}
|
|
225
|
-
const m =
|
|
185
|
+
const m = et(n, f, d);
|
|
226
186
|
if (c += m * e.pages.length, l += m * i, c > s) throw new W(s, c);
|
|
227
|
-
if (l >
|
|
187
|
+
if (l > je) throw new $("$.repeat", `标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${je},请分批生成`, u);
|
|
228
188
|
}
|
|
229
189
|
return o;
|
|
230
190
|
}
|
|
231
|
-
function
|
|
191
|
+
function Pr(e, t, r) {
|
|
232
192
|
if (!e.binding) return e;
|
|
233
|
-
const { binding: n, ...o } = e, a =
|
|
193
|
+
const { binding: n, ...o } = e, a = _t(n, t.row, t);
|
|
234
194
|
if (e.kind === "image") {
|
|
235
195
|
if (!a) return;
|
|
236
|
-
if (!
|
|
196
|
+
if (!qt(a)) throw new $(`${r}.binding`, "图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换", t.rowIndex, n.field);
|
|
237
197
|
return { ...o, imageData: a };
|
|
238
198
|
}
|
|
239
199
|
return e.kind === "barcode" || e.kind === "qrcode" ? (delete o.imageData, { ...o, code: { ...o.code, value: a }, fallbackText: a }) : (delete o.lines, delete o.richParagraphs, { ...o, text: a });
|
|
240
200
|
}
|
|
241
|
-
function
|
|
201
|
+
function Er(e, t, r) {
|
|
242
202
|
if (e.kind !== "text" || e.grid || e.richParagraphs?.length) return e;
|
|
243
|
-
const n = e.style ?? {}, o =
|
|
203
|
+
const n = e.style ?? {}, o = re(n).fontSizePt, a = e.text ?? e.lines?.join(`
|
|
244
204
|
`) ?? "";
|
|
245
|
-
if (a.length > 16384) throw new
|
|
246
|
-
const s = t.wrapText(a, e.widthMm, { fontSizePt: o, bold: n.bold, italic: n.italic, fontFamily: n.fontFamily, letterSpacingPt: n.letterSpacing }, t.options.measurer ??
|
|
247
|
-
if (i > e.heightMm + 0.05) throw new
|
|
205
|
+
if (a.length > 16384) throw new $(r, "标签文本超过 16384 字符预算,请缩小字段内容", t.rowIndex);
|
|
206
|
+
const s = t.wrapText(a, e.widthMm, { fontSizePt: o, bold: n.bold, italic: n.italic, fontFamily: n.fontFamily, letterSpacingPt: n.letterSpacing }, t.options.measurer ?? Ve), i = s.length * o * Wt(n) * 25.4 / 72;
|
|
207
|
+
if (i > e.heightMm + 0.05) throw new $(r, `标签文字需要约 ${i.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`, t.rowIndex, e.binding?.field);
|
|
248
208
|
return { ...e, lines: s };
|
|
249
209
|
}
|
|
250
|
-
function
|
|
251
|
-
|
|
252
|
-
const n =
|
|
210
|
+
function rt(e, t, r) {
|
|
211
|
+
ke(t.options.signal);
|
|
212
|
+
const n = Pr(e, t, r);
|
|
253
213
|
if (!n) return;
|
|
254
214
|
let o = n.grid;
|
|
255
|
-
return o && (o = { ...o, cells: o.cells.map((a, s) => a.map((i, c) => i?.children?.length ? { ...i, children: i.children.flatMap((l,
|
|
256
|
-
const f =
|
|
215
|
+
return o && (o = { ...o, cells: o.cells.map((a, s) => a.map((i, c) => i?.children?.length ? { ...i, children: i.children.flatMap((l, u) => {
|
|
216
|
+
const f = rt(l, t, `${r}.grid.cells.${s}.${c}.children.${u}`);
|
|
257
217
|
return f ? [f] : [];
|
|
258
|
-
}) } : i)) }),
|
|
218
|
+
}) } : i)) }), Er(o === n.grid ? n : { ...n, grid: o }, t, r);
|
|
259
219
|
}
|
|
260
|
-
function
|
|
220
|
+
function Rr(e, t, r, n, o, a) {
|
|
261
221
|
return {
|
|
262
222
|
...e,
|
|
263
223
|
components: e.components.flatMap((s, i) => {
|
|
264
|
-
const c =
|
|
224
|
+
const c = rt(s, r, `$.pages.${t}.components.${i}`);
|
|
265
225
|
return c ? [{ ...c, meta: { ...c.meta, labelSource: { pageIndex: t, componentIndex: i } } }] : [];
|
|
266
226
|
}),
|
|
267
227
|
meta: { ...e.meta, record: { dataset: r.dataset, rowIndex: r.rowIndex, ...a === void 0 ? {} : { rowKey: a }, copyIndex: n, copyCount: o, templatePageIndex: t } }
|
|
268
228
|
};
|
|
269
229
|
}
|
|
270
|
-
function*
|
|
230
|
+
function* Ir(e, t, r) {
|
|
271
231
|
const n = [];
|
|
272
|
-
if (
|
|
232
|
+
if (ar(e, n), n.length) throw new $(n[0].path, n[0].message);
|
|
273
233
|
if (!e.repeat) {
|
|
274
234
|
for (const [i, c] of e.pages.entries()) yield { page: c, pageIndex: i };
|
|
275
235
|
return;
|
|
276
236
|
}
|
|
277
|
-
const o = e.repeat, a =
|
|
237
|
+
const o = e.repeat, a = Tr(e, t, r), s = xr();
|
|
278
238
|
for (const [i, c] of a.entries()) {
|
|
279
|
-
const l = { row: c, rowIndex: i, dataset: o.dataset, options: r, wrapText: s },
|
|
280
|
-
for (let
|
|
281
|
-
|
|
239
|
+
const l = { row: c, rowIndex: i, dataset: o.dataset, options: r, wrapText: s }, u = et(o, c, l), f = tt(o, c, l);
|
|
240
|
+
for (let d = 0; d < u; d++) for (const [h, m] of e.pages.entries())
|
|
241
|
+
ke(r.signal), yield { page: Rr(m, h, l, d, u, f), pageIndex: h };
|
|
282
242
|
}
|
|
283
243
|
}
|
|
284
|
-
function
|
|
244
|
+
function $r(e) {
|
|
285
245
|
return {
|
|
286
246
|
widthMm: e.widthMm,
|
|
287
247
|
heightMm: e.heightMm,
|
|
@@ -292,119 +252,119 @@ function Nr(e) {
|
|
|
292
252
|
components: []
|
|
293
253
|
};
|
|
294
254
|
}
|
|
295
|
-
function
|
|
255
|
+
function Q(e, t) {
|
|
296
256
|
const r = t.heightMm - (e.layout === "wide" ? t.marginBottomMm : e.marginBottomMm ?? t.marginBottomMm);
|
|
297
257
|
return e.components.reduce((n, o) => o.kind !== "list" && o.pageAnchor === "footer" ? Math.min(n, o.topMm) : n, r);
|
|
298
258
|
}
|
|
299
259
|
function V(e) {
|
|
300
260
|
return e.components.reduce((t, r) => r.kind !== "list" && r.pageAnchor === "header" ? Math.max(t, r.topMm + r.heightMm) : t, 0);
|
|
301
261
|
}
|
|
302
|
-
function
|
|
262
|
+
function nt(e, t) {
|
|
303
263
|
let r = e.textMetrics.get(t);
|
|
304
264
|
if (!r) {
|
|
305
|
-
const n =
|
|
265
|
+
const n = re(t).fontSizePt;
|
|
306
266
|
r = {
|
|
307
267
|
measureOptions: {
|
|
308
268
|
fontSizePt: n,
|
|
309
|
-
fontFamily: t.fontFamily ??
|
|
269
|
+
fontFamily: t.fontFamily ?? We,
|
|
310
270
|
italic: t.italic,
|
|
311
271
|
bold: t.bold,
|
|
312
272
|
letterSpacingPt: t.letterSpacing
|
|
313
273
|
},
|
|
314
|
-
lineMm: n * (t.lineHeight ??
|
|
274
|
+
lineMm: n * (t.lineHeight ?? ye) * 25.4 / 72
|
|
315
275
|
}, e.textMetrics.set(t, r);
|
|
316
276
|
}
|
|
317
277
|
return r;
|
|
318
278
|
}
|
|
319
|
-
function
|
|
279
|
+
function Fr(e) {
|
|
320
280
|
if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return e;
|
|
321
281
|
}
|
|
322
|
-
function
|
|
323
|
-
const o = e.fontSizePt ??
|
|
282
|
+
function Te(e, t, r = [], n) {
|
|
283
|
+
const o = e.fontSizePt ?? Vt, a = e.paddingMm ?? 1, s = e.columns.map((w) => w.align ?? w.style?.align ?? e.align ?? "left"), i = e.columns.map((w, y) => ({
|
|
324
284
|
...j({
|
|
325
285
|
fontSize: o,
|
|
326
286
|
verticalAlign: "middle"
|
|
327
|
-
},
|
|
328
|
-
align: s[
|
|
329
|
-
})), c = i.map((
|
|
330
|
-
const
|
|
331
|
-
if (
|
|
332
|
-
left: j(
|
|
333
|
-
center: j(
|
|
334
|
-
right: j(
|
|
287
|
+
}, w.style),
|
|
288
|
+
align: s[y] === "auto" ? "left" : s[y]
|
|
289
|
+
})), c = i.map((w, y) => s[y] === "auto" ? { left: w, center: { ...w, align: "center" }, right: { ...w, align: "right" } } : void 0), l = e.columns.map((w, y) => w.rules?.map((x) => {
|
|
290
|
+
const k = c[y];
|
|
291
|
+
if (k) return {
|
|
292
|
+
left: j(k.left, x.style),
|
|
293
|
+
center: j(k.center, x.style),
|
|
294
|
+
right: j(k.right, x.style)
|
|
335
295
|
};
|
|
336
|
-
const
|
|
337
|
-
return { left:
|
|
338
|
-
})),
|
|
339
|
-
let
|
|
340
|
-
for (let
|
|
341
|
-
const
|
|
342
|
-
f[
|
|
343
|
-
e.columns[
|
|
344
|
-
{ fontSizePt: x, fontFamily:
|
|
296
|
+
const T = j(i[y], x.style);
|
|
297
|
+
return { left: T, center: T, right: T };
|
|
298
|
+
})), u = e.columns.map((w) => ze(e, w)), f = e.columns.map((w) => w.header);
|
|
299
|
+
let d = e.rowHeightMm ?? 0;
|
|
300
|
+
for (let w = 0; w < f.length; w++) {
|
|
301
|
+
const y = u[w], x = re(y).fontSizePt, k = _(
|
|
302
|
+
f[w],
|
|
303
|
+
e.columns[w].widthMm - a * 2,
|
|
304
|
+
{ fontSizePt: x, fontFamily: y.fontFamily ?? We, italic: y.italic, bold: y.bold, letterSpacingPt: y.letterSpacing },
|
|
345
305
|
t
|
|
346
|
-
),
|
|
347
|
-
|
|
306
|
+
), T = x * (y.lineHeight ?? ye) * 25.4 / 72;
|
|
307
|
+
d = Math.max(d, Math.max(k.length, 1) * T + a * 2);
|
|
348
308
|
}
|
|
349
|
-
const h = f.map((
|
|
350
|
-
text:
|
|
351
|
-
style:
|
|
352
|
-
})), m = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, v = e.columns.map((
|
|
309
|
+
const h = f.map((w, y) => ({
|
|
310
|
+
text: w,
|
|
311
|
+
style: u[y]
|
|
312
|
+
})), m = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, v = e.columns.map((w) => w.widthMm), p = Or(wr(e, t), v, {
|
|
353
313
|
cells: [h],
|
|
354
314
|
colWidthsMm: v,
|
|
355
|
-
rowHeightsMm: [
|
|
315
|
+
rowHeightsMm: [d],
|
|
356
316
|
paddingMm: a
|
|
357
317
|
});
|
|
358
318
|
return {
|
|
359
319
|
fontSizePt: o,
|
|
360
320
|
paddingMm: a,
|
|
361
|
-
visuals:
|
|
362
|
-
visibility: e.columns.map((
|
|
363
|
-
ruleReaders: e.columns.map((
|
|
321
|
+
visuals: rr(e.columns, r, n),
|
|
322
|
+
visibility: e.columns.map((w) => w.visibleWhen ? H(w.visibleWhen) : void 0),
|
|
323
|
+
ruleReaders: e.columns.map((w) => w.rules?.map((y) => H(y.when))),
|
|
364
324
|
cellStyles: i,
|
|
365
325
|
autoStyles: c,
|
|
366
326
|
ruleStyles: l,
|
|
367
327
|
textMetrics: /* @__PURE__ */ new WeakMap(),
|
|
368
|
-
numberFormats: e.columns.map((
|
|
369
|
-
derivedFields: new Set(e.computed?.map((
|
|
328
|
+
numberFormats: e.columns.map((w) => _e(w.format)),
|
|
329
|
+
derivedFields: new Set(e.computed?.map((w) => w.field)),
|
|
370
330
|
borderStyle: m,
|
|
371
|
-
headerHeightMm:
|
|
372
|
-
headerGrid:
|
|
331
|
+
headerHeightMm: p.rowHeightsMm.reduce((w, y) => w + y, 0),
|
|
332
|
+
headerGrid: p,
|
|
373
333
|
colWidthsMm: v,
|
|
374
334
|
columns: e.columns
|
|
375
335
|
};
|
|
376
336
|
}
|
|
377
|
-
function
|
|
337
|
+
function Or(e, t, r) {
|
|
378
338
|
if (!e) return r;
|
|
379
339
|
if (!e.cells.length) throw new Error("自定义列表表头至少需要一行");
|
|
380
340
|
const n = e.rowHeightsMm ?? e.cells.map(() => r.rowHeightsMm[0]);
|
|
381
341
|
if (n.length !== e.cells.length || n.some((o) => !Number.isFinite(o) || o <= 0)) throw new Error("自定义列表表头行高无效");
|
|
382
342
|
return { ...e, colWidthsMm: t, rowHeightsMm: n };
|
|
383
343
|
}
|
|
384
|
-
function
|
|
344
|
+
function Ar(e, t, r) {
|
|
385
345
|
const n = t.format?.kind === "number" || t.format?.kind === "percent";
|
|
386
346
|
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);
|
|
387
347
|
}
|
|
388
|
-
function
|
|
348
|
+
function z(e, t, r) {
|
|
389
349
|
const n = e.columns, o = e.tree?.rows.get(t);
|
|
390
350
|
let a = e.rowHeightFloorMm;
|
|
391
351
|
const s = new Array(n.length);
|
|
392
352
|
for (let i = 0; i < n.length; i++) {
|
|
393
|
-
const c = n[i], l = e.visibility[i]?.(t) !== !1,
|
|
394
|
-
let
|
|
353
|
+
const c = n[i], l = e.visibility[i]?.(t) !== !1, u = l ? t[c.field] : null, f = e.autoStyles[i] ? qe(u, c.format, c.semanticRole) : "left";
|
|
354
|
+
let d = e.autoStyles[i]?.[f] ?? e.cellStyles[i];
|
|
395
355
|
if (c.rules) {
|
|
396
356
|
for (let x = 0; x < c.rules.length; x++)
|
|
397
357
|
if (e.ruleReaders[i][x](t)) {
|
|
398
|
-
|
|
358
|
+
d = e.ruleStyles[i][x][f];
|
|
399
359
|
break;
|
|
400
360
|
}
|
|
401
361
|
}
|
|
402
|
-
const h = c.format ?
|
|
403
|
-
|
|
404
|
-
const v =
|
|
405
|
-
a = Math.max(a,
|
|
406
|
-
const
|
|
407
|
-
|
|
362
|
+
const h = c.format ? Ue(u, c.format) : xe(u), m = Kr(e, c, o);
|
|
363
|
+
d = jr(e, c, d, o);
|
|
364
|
+
const v = nt(e, d), p = _(h, Math.max(1, c.widthMm - e.paddingMm * 2 - m), v.measureOptions, r);
|
|
365
|
+
a = Math.max(a, p.length * v.lineMm + e.paddingMm * 2);
|
|
366
|
+
const w = Fr(u), y = { text: h, style: d };
|
|
367
|
+
u != null && e.visuals[i]?.apply(y, t), w !== void 0 && (y.value = w), Ar(y, c, e.numberFormats[i]), Nr(y, c, e, o, m), e.derivedFields.has(c.field) && (y.derived = !0, y.editable = !1), l || (y.editable = !1), s[i] = y;
|
|
408
368
|
}
|
|
409
369
|
return {
|
|
410
370
|
grid: { cells: [s], colWidthsMm: e.colWidthsMm, rowHeightsMm: [a], paddingMm: e.paddingMm },
|
|
@@ -412,20 +372,20 @@ function J(e, t, r) {
|
|
|
412
372
|
...e.matrix ? { meta: { matrix: { row: e.matrix.rows.get(t) } } } : {}
|
|
413
373
|
};
|
|
414
374
|
}
|
|
415
|
-
function
|
|
375
|
+
function Kr(e, t, r) {
|
|
416
376
|
return !r || t.field !== e.tree.list.tree.labelField ? 0 : Xt(e.tree.list, t, r, e.paddingMm);
|
|
417
377
|
}
|
|
418
|
-
function
|
|
378
|
+
function jr(e, t, r, n) {
|
|
419
379
|
return !n || t.field !== e.tree.list.tree.labelField || r.align === "left" ? r : { ...r, align: "left" };
|
|
420
380
|
}
|
|
421
|
-
function
|
|
381
|
+
function Nr(e, t, r, n, o = 0) {
|
|
422
382
|
n && (o && (e.indentMm = o), Yt(e, t, n, r.tree.list));
|
|
423
383
|
}
|
|
424
|
-
function
|
|
384
|
+
function ot(e) {
|
|
425
385
|
if (e != null && typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e))) throw new Error("分组字段应为有限 JSON 标量");
|
|
426
386
|
return JSON.stringify([typeof e, e ?? null]);
|
|
427
387
|
}
|
|
428
|
-
function*
|
|
388
|
+
function* at(e, t, r = 0) {
|
|
429
389
|
const n = t[r];
|
|
430
390
|
if (!n) {
|
|
431
391
|
for (const a of e) yield { kind: "row", row: a };
|
|
@@ -433,54 +393,54 @@ function* st(e, t, r = 0) {
|
|
|
433
393
|
}
|
|
434
394
|
const o = /* @__PURE__ */ new Map();
|
|
435
395
|
for (const a of e) {
|
|
436
|
-
const s =
|
|
396
|
+
const s = ot(a[n.field]), i = o.get(s);
|
|
437
397
|
i ? i.push(a) : o.set(s, [a]);
|
|
438
398
|
}
|
|
439
399
|
for (const a of o.values())
|
|
440
|
-
yield { kind: "groupHeader", label: (n.headerTemplate ?? "{value}").replace(/\{value\}/g, xe(a[0][n.field])), firstRow: a[0], group: n, depth: r, rows: a }, yield*
|
|
400
|
+
yield { kind: "groupHeader", label: (n.headerTemplate ?? "{value}").replace(/\{value\}/g, xe(a[0][n.field])), firstRow: a[0], group: n, depth: r, rows: a }, yield* at(a, t, r + 1), (n.subtotal?.length || n.aggregates?.length) && (yield { kind: "subtotal", label: n.subtotalLabel ?? "小计", rows: a, group: n, depth: r }), yield { kind: "groupEnd", depth: r };
|
|
441
401
|
}
|
|
442
|
-
function
|
|
402
|
+
function st(e, t, r, n = []) {
|
|
443
403
|
const o = [...r.filter((a) => !n.some((s) => s.field === a)).map((a) => ({ field: a, op: "sum" })), ...n];
|
|
444
404
|
return new Map(o.map((a) => {
|
|
445
|
-
const s = e.find((c) => c.field === a.field)?.format ?? { kind: "number", thousands: !0 }, i =
|
|
446
|
-
return [a.field, { text:
|
|
405
|
+
const s = e.find((c) => c.field === a.field)?.format ?? { kind: "number", thousands: !0 }, i = Me(t, { ...a, field: a.valueField ?? a.field });
|
|
406
|
+
return [a.field, { text: Ue(i, s), ...i === null ? {} : { value: i }, ...typeof i == "number" ? { numberFormat: _e(s) } : {} }];
|
|
447
407
|
}));
|
|
448
408
|
}
|
|
449
|
-
function
|
|
409
|
+
function it(e, t) {
|
|
450
410
|
const r = e.findIndex((n) => t.includes(n.field));
|
|
451
411
|
return r < 0 ? 1 : r;
|
|
452
412
|
}
|
|
453
413
|
function G(e, t, r, n, o, a) {
|
|
454
414
|
const s = [], i = Math.max(0, Math.min(a, e.columns.length)), c = j({ fontSize: e.fontSizePt }, o);
|
|
455
415
|
i && s.push({ text: r, colSpan: i, style: { bold: !0, ...c } });
|
|
456
|
-
for (let
|
|
457
|
-
const h = e.columns[
|
|
416
|
+
for (let d = i; d < e.columns.length; d++) {
|
|
417
|
+
const h = e.columns[d], m = n.get(h.field), v = e.autoStyles[d]?.[qe(m?.value, h.format)] ?? e.cellStyles[d];
|
|
458
418
|
s.push({ ...m, text: m?.text ?? "", style: j(v, o) });
|
|
459
419
|
}
|
|
460
|
-
const l = { text: r, colSpan: e.columns.length, style: { bold: !0, ...c } },
|
|
420
|
+
const l = { text: r, colSpan: e.columns.length, style: { bold: !0, ...c } }, u = i ? [s] : [[l], s], f = u.map((d) => Lr(e, d, t));
|
|
461
421
|
return {
|
|
462
|
-
grid: { cells:
|
|
463
|
-
heightMm: f.reduce((
|
|
422
|
+
grid: { cells: u, colWidthsMm: e.colWidthsMm, rowHeightsMm: f, paddingMm: e.paddingMm },
|
|
423
|
+
heightMm: f.reduce((d, h) => d + h, 0)
|
|
464
424
|
};
|
|
465
425
|
}
|
|
466
|
-
function
|
|
426
|
+
function Lr(e, t, r) {
|
|
467
427
|
let n = e.rowHeightFloorMm, o = 0;
|
|
468
428
|
for (const a of t) {
|
|
469
429
|
let s = 0;
|
|
470
430
|
const i = o + (a.colSpan ?? 1);
|
|
471
431
|
for (; o < i; o++) s += e.colWidthsMm[o] ?? 0;
|
|
472
|
-
const c =
|
|
432
|
+
const c = nt(e, a.style), l = _(a.text ?? "", s - e.paddingMm * 2, c.measureOptions, r);
|
|
473
433
|
n = Math.max(n, l.length * c.lineMm + e.paddingMm * 2);
|
|
474
434
|
}
|
|
475
435
|
return n;
|
|
476
436
|
}
|
|
477
|
-
function
|
|
478
|
-
const { templatePage: n, current: o, warnings: a, nextId: s, pushCurrent: i } = r, c = () =>
|
|
437
|
+
function Hr(e, t, r) {
|
|
438
|
+
const { templatePage: n, current: o, warnings: a, nextId: s, pushCurrent: i } = r, c = () => Q(n, o), l = Math.max(o.marginTopMm, V(n)), u = n.layout === "wide" ? V(n) : l, f = {
|
|
479
439
|
id: r.tableId,
|
|
480
|
-
columnKeys: e.columns.map((
|
|
440
|
+
columnKeys: e.columns.map((g) => g.field),
|
|
481
441
|
...e.layout === void 0 ? {} : { layout: e.layout },
|
|
482
442
|
...e.title === void 0 ? {} : { title: e.title }
|
|
483
|
-
},
|
|
443
|
+
}, d = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), m = {
|
|
484
444
|
kind: "rect",
|
|
485
445
|
leftMm: e.leftMm,
|
|
486
446
|
topMm: 0,
|
|
@@ -491,53 +451,53 @@ function Wr(e, t, r) {
|
|
|
491
451
|
table: { ...f, role: "header", rowIndex: -1 },
|
|
492
452
|
style: t.borderStyle,
|
|
493
453
|
...e.meta || t.matrix ? { meta: { ...e.meta, ...t.matrix ? { matrix: t.matrix.header } : {} } } : {}
|
|
494
|
-
}, v = (
|
|
454
|
+
}, v = (g) => o.components.push({ ...m, topMm: g });
|
|
495
455
|
if (r.flow && e.header !== !1 && t.headerHeightMm > c() - l + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的表头高度超出单页可用范围`);
|
|
496
|
-
let
|
|
497
|
-
e.header !== !1 && (v(
|
|
498
|
-
function g() {
|
|
499
|
-
const p = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, d);
|
|
500
|
-
return (e.header !== !1 && e.headerEveryPage !== !1 ? p + t.headerHeightMm : d) + [...h.values()].reduce((S, P) => S + P.heightMm, 0);
|
|
501
|
-
}
|
|
456
|
+
let p = Math.max(r.startTop ?? e.topMm, l);
|
|
457
|
+
e.header !== !1 && (v(p), p += t.headerHeightMm + r.mmPerRow);
|
|
502
458
|
function w() {
|
|
503
|
-
const
|
|
504
|
-
return
|
|
459
|
+
const g = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, u);
|
|
460
|
+
return (e.header !== !1 && e.headerEveryPage !== !1 ? g + t.headerHeightMm : u) + [...h.values()].reduce((S, E) => S + E.heightMm, 0);
|
|
505
461
|
}
|
|
506
|
-
function
|
|
507
|
-
|
|
462
|
+
function y() {
|
|
463
|
+
const g = n.layout === "wide" ? 0 : o.marginBottomMm;
|
|
464
|
+
return Math.min(n.heightMm - g, Q(n, o)) - w();
|
|
465
|
+
}
|
|
466
|
+
function x(g) {
|
|
467
|
+
if (p + g <= c()) return;
|
|
508
468
|
i(), o.components = [], o.heightMm = n.heightMm, n.layout === "wide" && (o.marginTopMm = 0, o.marginBottomMm = 0);
|
|
509
|
-
const b = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm,
|
|
510
|
-
e.header !== !1 && e.headerEveryPage !== !1 ? (v(b),
|
|
511
|
-
for (const S of h.values())
|
|
512
|
-
}
|
|
513
|
-
function
|
|
514
|
-
const
|
|
515
|
-
if (r.flow &&
|
|
516
|
-
|
|
517
|
-
}
|
|
518
|
-
function
|
|
519
|
-
const
|
|
520
|
-
S !== "header" &&
|
|
469
|
+
const b = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, u);
|
|
470
|
+
e.header !== !1 && e.headerEveryPage !== !1 ? (v(b), p = b + t.headerHeightMm) : p = u;
|
|
471
|
+
for (const S of h.values()) T(S, "listgr", "group-header");
|
|
472
|
+
}
|
|
473
|
+
function k(g, b, S, E) {
|
|
474
|
+
const P = y();
|
|
475
|
+
if (r.flow && g.heightMm > P + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的单行高度超出单页可用范围`);
|
|
476
|
+
g.heightMm > P && a.push(`列表 ${e.id ?? e.dataset} 行高 ${g.heightMm.toFixed(2)}mm 超出单页可用高度 ${P.toFixed(2)}mm,预览与打印可能截断内容`), x(g.heightMm), T(g, b, S, E);
|
|
477
|
+
}
|
|
478
|
+
function T(g, b, S, E) {
|
|
479
|
+
const P = g.table?.id ?? f.id, R = S === "header" ? -1 : d.get(P) ?? 0;
|
|
480
|
+
S !== "header" && d.set(P, R + g.grid.cells.length), o.components.push({
|
|
521
481
|
kind: "rect",
|
|
522
482
|
leftMm: e.leftMm,
|
|
523
|
-
topMm:
|
|
483
|
+
topMm: p,
|
|
524
484
|
widthMm: e.widthMm,
|
|
525
|
-
heightMm:
|
|
526
|
-
grid:
|
|
485
|
+
heightMm: g.heightMm,
|
|
486
|
+
grid: g.grid,
|
|
527
487
|
nid: s(b),
|
|
528
|
-
table: { ...f, ...
|
|
488
|
+
table: { ...f, ...g.table, role: S, rowIndex: R, ...E ? { source: E } : {} },
|
|
529
489
|
style: t.borderStyle,
|
|
530
|
-
...e.meta ||
|
|
531
|
-
}),
|
|
490
|
+
...e.meta || g.meta ? { meta: { ...e.meta, ...g.meta } } : {}
|
|
491
|
+
}), p += g.heightMm;
|
|
532
492
|
}
|
|
533
|
-
function O(
|
|
534
|
-
|
|
493
|
+
function O(g) {
|
|
494
|
+
g <= y() && x(g);
|
|
535
495
|
}
|
|
536
|
-
return { keepTogether: O, placeGridRow:
|
|
537
|
-
b ? h.set(
|
|
538
|
-
}, bottom: () =>
|
|
496
|
+
return { keepTogether: O, placeGridRow: k, setGroupHeader: (g, b) => {
|
|
497
|
+
b ? h.set(g, b) : h.delete(g);
|
|
498
|
+
}, bottom: () => p };
|
|
539
499
|
}
|
|
540
|
-
function
|
|
500
|
+
function Dr(e, t) {
|
|
541
501
|
if (!e.rowKey) return;
|
|
542
502
|
const r = t[e.rowKey];
|
|
543
503
|
if ((typeof r != "string" || !r.trim()) && !(typeof r == "number" && Number.isFinite(r)))
|
|
@@ -547,168 +507,168 @@ function Vr(e, t) {
|
|
|
547
507
|
if (o !== void 0 && typeof o != "string") throw new Error("来源令牌应为字符串");
|
|
548
508
|
return { datasetId: e.dataset, rowKey: r, ...n === void 0 ? {} : { revision: n }, ...o === void 0 ? {} : { sourceToken: o } };
|
|
549
509
|
}
|
|
550
|
-
function
|
|
510
|
+
function ne(e, t) {
|
|
551
511
|
const r = /* @__PURE__ */ new Map();
|
|
552
512
|
if (!e.rowKey) return r;
|
|
553
513
|
const n = /* @__PURE__ */ new Set();
|
|
554
514
|
for (const o of t) {
|
|
555
|
-
const a =
|
|
515
|
+
const a = Dr(e, o), s = JSON.stringify(a.rowKey);
|
|
556
516
|
if (n.has(s)) throw new Error(`数据集 ${e.dataset} 的业务主键重复:${String(a.rowKey)}`);
|
|
557
517
|
n.add(s), r.set(o, a);
|
|
558
518
|
}
|
|
559
519
|
return r;
|
|
560
520
|
}
|
|
561
|
-
function
|
|
521
|
+
function Br(e, t, r, n, o) {
|
|
562
522
|
if (!e.grandTotal) return;
|
|
563
|
-
const a = typeof e.grandTotal == "object" ? e.grandTotal : void 0, s =
|
|
523
|
+
const a = typeof e.grandTotal == "object" ? e.grandTotal : void 0, s = oe(e)[0], i = a?.fields ?? s?.subtotal ?? [], c = a?.aggregates ?? s?.aggregates ?? [];
|
|
564
524
|
if (i.length === 0 && c.length === 0) {
|
|
565
525
|
n.warnings.push(`列表 ${e.id ?? ""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);
|
|
566
526
|
return;
|
|
567
527
|
}
|
|
568
|
-
const l = G(r, n.measurer, a?.label ?? "合计",
|
|
528
|
+
const l = G(r, n.measurer, a?.label ?? "合计", st(e.columns, t, i, c), a?.style ?? {}, it(e.columns, [...i, ...c.map((u) => u.field)]));
|
|
569
529
|
o.placeGridRow(l, "listgt", "grand-total");
|
|
570
530
|
}
|
|
571
|
-
function
|
|
531
|
+
function K(e) {
|
|
572
532
|
if (e?.aborted) {
|
|
573
533
|
const t = new Error("报表排版已取消");
|
|
574
534
|
throw t.name = "AbortError", t;
|
|
575
535
|
}
|
|
576
536
|
}
|
|
577
|
-
function
|
|
537
|
+
function oe(e) {
|
|
578
538
|
const t = e.groups ?? (e.groupBy ? [e.groupBy] : []);
|
|
579
539
|
if (t.length > 16) throw new Error("列表最多支持 16 级分组");
|
|
580
540
|
return t;
|
|
581
541
|
}
|
|
582
|
-
function
|
|
583
|
-
const t =
|
|
542
|
+
function Pe(e) {
|
|
543
|
+
const t = br(e), r = t.columns.reduce((o, a) => o + a.widthMm, 0), n = r > t.widthMm ? t.widthMm / r : 1;
|
|
584
544
|
return n === 1 ? t : { ...t, columns: t.columns.map((o) => ({ ...o, widthMm: o.widthMm * n })) };
|
|
585
545
|
}
|
|
586
|
-
function
|
|
546
|
+
function Gr(e, t, r) {
|
|
587
547
|
const n = e.detail;
|
|
588
548
|
if (!n) return;
|
|
589
549
|
const o = /* @__PURE__ */ new Set();
|
|
590
550
|
for (const l of t) {
|
|
591
|
-
const
|
|
592
|
-
if (o.has(
|
|
593
|
-
o.add(
|
|
551
|
+
const u = me(l[n.parentKey]);
|
|
552
|
+
if (o.has(u)) throw new Error("主从明细的主表关联键重复");
|
|
553
|
+
o.add(u);
|
|
594
554
|
}
|
|
595
555
|
const a = r.datasets[n.dataset] ?? [], s = /* @__PURE__ */ new Map(), i = [];
|
|
596
556
|
for (const l of a) {
|
|
597
|
-
const
|
|
598
|
-
if (!
|
|
599
|
-
const f =
|
|
557
|
+
const u = l[n.foreignKey];
|
|
558
|
+
if (!ct(u) && n.unmatched === "ignore") continue;
|
|
559
|
+
const f = me(u);
|
|
600
560
|
if (!o.has(f)) {
|
|
601
561
|
if (n.unmatched !== "ignore") throw new Error(`明细数据集 ${n.dataset} 存在未关联的业务键`);
|
|
602
562
|
continue;
|
|
603
563
|
}
|
|
604
|
-
const
|
|
605
|
-
|
|
564
|
+
const d = s.get(f);
|
|
565
|
+
d ? d.push(l) : s.set(f, [l]), i.push(l);
|
|
606
566
|
}
|
|
607
|
-
const c =
|
|
608
|
-
return { list: c, inter: { ...
|
|
567
|
+
const c = Pe({ ...e, id: `${e.id ?? e.dataset}:detail`, dataset: n.dataset, rowKey: n.rowKey, revisionField: n.revisionField, sourceTokenField: n.sourceTokenField, computed: void 0, columns: n.columns, headerGrid: void 0, rowHeightMm: n.rowHeightMm ?? e.rowHeightMm, detail: void 0 });
|
|
568
|
+
return { list: c, inter: { ...Te(c, r.measurer, i, r.signal), rowHeightFloorMm: c.rowHeightMm ?? 0 }, rows: s, sources: ne(c, i) };
|
|
609
569
|
}
|
|
610
|
-
function
|
|
570
|
+
function ct(e) {
|
|
611
571
|
return typeof e == "string" && !!e.trim() || typeof e == "number" && Number.isFinite(e);
|
|
612
572
|
}
|
|
613
|
-
function
|
|
614
|
-
if (!
|
|
615
|
-
return
|
|
573
|
+
function me(e) {
|
|
574
|
+
if (!ct(e)) throw new Error("主从关联键必须是非空字符串或有限数字");
|
|
575
|
+
return ot(e);
|
|
616
576
|
}
|
|
617
|
-
function*
|
|
577
|
+
function* Wr(e, t, r, n, o) {
|
|
618
578
|
if (!r) return;
|
|
619
|
-
const a = r.rows.get(
|
|
579
|
+
const a = r.rows.get(me(t[e.detail.parentKey])) ?? [];
|
|
620
580
|
if (!a.length) return;
|
|
621
581
|
const s = { id: `${n.tableId}:detail`, columnKeys: r.list.columns.map((i) => i.field), title: e.detail.label };
|
|
622
582
|
e.detail.label && o.placeGridRow({ ...G(r.inter, n.measurer, e.detail.label, /* @__PURE__ */ new Map(), {}, r.list.columns.length), table: s }, "listdl", "group-header"), e.detail.header !== !1 && o.placeGridRow({ grid: r.inter.headerGrid, heightMm: r.inter.headerHeightMm, table: s }, "listdh", "header"), yield* n.takePages();
|
|
623
583
|
for (const i of a)
|
|
624
|
-
|
|
584
|
+
K(n.signal), o.placeGridRow({ ...z(r.inter, i, n.measurer), table: s }, "listdr", "body", r.sources.get(i)), yield* n.takePages();
|
|
625
585
|
}
|
|
626
|
-
function
|
|
586
|
+
function lt(e) {
|
|
627
587
|
if (e.matrix || e.detail || e.groups?.length || e.groupBy || e.rowVisibleWhen) throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");
|
|
628
588
|
if (e.rowKey && e.rowKey !== e.tree.idField) throw new Error("树形布局的 rowKey 应与 idField 一致");
|
|
629
589
|
if (!e.columns.some((t) => t.field === e.tree.labelField && !t.hidden)) throw new Error("树形布局需要可见的标签列");
|
|
630
|
-
|
|
590
|
+
tr(e.tree, e.computed);
|
|
631
591
|
}
|
|
632
|
-
function
|
|
633
|
-
|
|
634
|
-
const n =
|
|
592
|
+
function Vr(e, t, r) {
|
|
593
|
+
lt(e);
|
|
594
|
+
const n = Ye(t, e.tree, { signal: r.signal, computed: e.computed?.length ? { fields: e.computed, formula: r.formula } : void 0 }), o = { ...e, rowKey: e.tree.idField }, a = ne(o, n.entries.map((c) => c.original)), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new WeakMap();
|
|
635
595
|
for (const c of n.entries)
|
|
636
596
|
s.set(c.row, a.get(c.original)), i.set(c.row, c);
|
|
637
597
|
return { list: o, rows: n.rows, sources: s, treeRows: i, totalRows: n.leaves };
|
|
638
598
|
}
|
|
639
|
-
function
|
|
599
|
+
function zr(e, t) {
|
|
640
600
|
if (e.cardinality === "record") {
|
|
641
601
|
if (t.length > 1) throw new Error(`单记录区域 ${e.id ?? e.dataset} 仅允许 0 或 1 行数据`);
|
|
642
602
|
if (e.tree || e.matrix || e.detail || e.groups?.length || e.groupBy || e.grandTotal || e.rowVisibleWhen) throw new Error("单记录区域不能配置树、矩阵、主从、分组、总计或行过滤");
|
|
643
603
|
if (!t.length) return { list: { ...e, columns: e.columns.map((r) => ({ ...r, editable: !1 })) }, rows: [{}], sources: /* @__PURE__ */ new Map() };
|
|
644
604
|
}
|
|
645
605
|
}
|
|
646
|
-
function
|
|
606
|
+
function dt(e, t, r) {
|
|
647
607
|
const n = r.prepared.get(e);
|
|
648
608
|
if (n) return n;
|
|
649
|
-
const o =
|
|
609
|
+
const o = zr(e, t);
|
|
650
610
|
if (o)
|
|
651
611
|
return r.prepared.set(e, o), o;
|
|
652
612
|
if (e.tree) {
|
|
653
|
-
const c =
|
|
613
|
+
const c = Vr(e, t, r);
|
|
654
614
|
return r.prepared.set(e, c), c;
|
|
655
615
|
}
|
|
656
|
-
let a = e.computed?.length ?
|
|
616
|
+
let a = e.computed?.length ? ve(t, { fields: e.computed, signal: r.signal, formula: r.formula }).rows : t;
|
|
657
617
|
const s = a === t ? void 0 : new Map(a.map((c, l) => [c, t[l]]));
|
|
658
618
|
e.rowVisibleWhen && (a = a.filter(H(e.rowVisibleWhen)));
|
|
659
|
-
const i =
|
|
619
|
+
const i = pr(e, a);
|
|
660
620
|
if (!e.matrix) {
|
|
661
|
-
const c =
|
|
621
|
+
const c = ne(e, s ? a.map((l) => s.get(l)) : a);
|
|
662
622
|
i.sources = s ? new Map(a.map((l) => [l, c.get(s.get(l))])) : c;
|
|
663
623
|
}
|
|
664
624
|
return r.prepared.set(e, i), i;
|
|
665
625
|
}
|
|
666
|
-
function
|
|
626
|
+
function Jr(e, t, r, n) {
|
|
667
627
|
if (!n.flow) return;
|
|
668
|
-
const { current: o, templatePage: a } = n, s = Math.max(o.marginTopMm, V(a)), i = Math.max(n.startTop ?? e.topMm, s), c = (e.header === !1 ? 0 : t.headerHeightMm) + (r[0] ?
|
|
669
|
-
i + c <=
|
|
628
|
+
const { current: o, templatePage: a } = n, s = Math.max(o.marginTopMm, V(a)), i = Math.max(n.startTop ?? e.topMm, s), c = (e.header === !1 ? 0 : t.headerHeightMm) + (r[0] ? z(t, r[0], n.measurer).heightMm : 0);
|
|
629
|
+
i + c <= Q(a, o) + 1e-3 || i <= s + 1e-3 || (n.pushCurrent(), o.components = [], o.heightMm = a.heightMm, a.layout === "wide" && (o.marginTopMm = 0, o.marginBottomMm = 0), n.startTop = Math.max(o.marginTopMm, V(a)));
|
|
670
630
|
}
|
|
671
|
-
function*
|
|
672
|
-
const n =
|
|
631
|
+
function* _r(e, t, r) {
|
|
632
|
+
const n = dt(e, t, r), o = n.rows;
|
|
673
633
|
e = n.list, e.layout === "wide" && (r.current.widthMm = Math.max(r.current.widthMm, e.leftMm + e.widthMm + r.current.marginRightMm));
|
|
674
|
-
const a = n.sources ??
|
|
675
|
-
|
|
676
|
-
const l =
|
|
634
|
+
const a = n.sources ?? ne(e, o), s = Pe(e), i = oe(s), c = { ...Te(s, r.measurer, o, r.signal), rowHeightFloorMm: s.rowHeightMm ?? 0, matrix: n.matrix, ...n.treeRows ? { tree: { list: s, rows: n.treeRows } } : {} };
|
|
635
|
+
Jr(s, c, o, r);
|
|
636
|
+
const l = Hr(s, c, r), u = Gr(s, o, r);
|
|
677
637
|
let f;
|
|
678
|
-
for (const
|
|
679
|
-
if (
|
|
680
|
-
l.placeGridRow(f ??
|
|
681
|
-
else if (
|
|
682
|
-
const h = G(c, r.measurer,
|
|
683
|
-
f ??=
|
|
684
|
-
const m = i.slice(
|
|
685
|
-
|
|
686
|
-
} else if (
|
|
687
|
-
const h =
|
|
638
|
+
for (const d of at(o, i)) {
|
|
639
|
+
if (K(r.signal), d.kind === "row")
|
|
640
|
+
l.placeGridRow(f ?? z(c, d.row, r.measurer), "listr", hr(n.matrix, d.row), a.get(d.row)), f = void 0, yield* r.takePages(), yield* Wr(s, d.row, u, r, l);
|
|
641
|
+
else if (d.kind === "groupHeader") {
|
|
642
|
+
const h = G(c, r.measurer, d.label, /* @__PURE__ */ new Map(), d.group.headerStyle ?? {}, s.columns.length);
|
|
643
|
+
f ??= z(c, d.firstRow, r.measurer);
|
|
644
|
+
const m = i.slice(d.depth + 1).reduce((v, p) => v + G(c, r.measurer, (p.headerTemplate ?? "{value}").replace(/\{value\}/g, xe(d.firstRow[p.field])), /* @__PURE__ */ new Map(), p.headerStyle ?? {}, s.columns.length).heightMm, 0);
|
|
645
|
+
d.group.keepWithNext !== !1 && l.keepTogether(h.heightMm + m + f.heightMm), l.placeGridRow(h, "listg", "group-header"), d.group.repeatHeader && l.setGroupHeader(d.depth, h);
|
|
646
|
+
} else if (d.kind === "subtotal") {
|
|
647
|
+
const h = d.group.subtotal ?? [], m = d.group.aggregates ?? [], v = G(c, r.measurer, d.label, st(s.columns, d.rows, h, m), d.group.subtotalStyle ?? {}, it(s.columns, [...h, ...m.map((p) => p.field)]));
|
|
688
648
|
l.placeGridRow(v, "listst", "subtotal");
|
|
689
|
-
} else l.setGroupHeader(
|
|
649
|
+
} else l.setGroupHeader(d.depth);
|
|
690
650
|
yield* r.takePages();
|
|
691
651
|
}
|
|
692
|
-
|
|
652
|
+
Br(s, n.totalRows ?? o, c, r, l), r.finished?.(l.bottom()), yield* r.takePages();
|
|
693
653
|
}
|
|
694
|
-
function
|
|
654
|
+
function ae(e) {
|
|
695
655
|
return e.kind !== "list" && (e.pageAnchor !== void 0 || e.kind === "text" && typeof e.text == "string" && (e.text.includes("{page}") || e.text.includes("{totalPages}")));
|
|
696
656
|
}
|
|
697
|
-
function
|
|
657
|
+
function se(e, t) {
|
|
698
658
|
return {
|
|
699
659
|
...e,
|
|
700
660
|
...e.text === void 0 ? {} : { text: t(e.text) },
|
|
701
661
|
...e.lines ? { lines: e.lines.map(t) } : {},
|
|
702
662
|
...e.richParagraphs ? { richParagraphs: e.richParagraphs.map((r) => ({ ...r, segments: r.segments.map((n) => ({ ...n, ...n.text === void 0 ? {} : { text: t(n.text) } })) })) } : {},
|
|
703
|
-
...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) =>
|
|
663
|
+
...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) => se(o, t)) } : {} } : null)) } } : {}
|
|
704
664
|
};
|
|
705
665
|
}
|
|
706
|
-
function
|
|
666
|
+
function qr(e) {
|
|
707
667
|
let t = !1;
|
|
708
|
-
for (const r of e.pages) for (const n of r.components)
|
|
668
|
+
for (const r of e.pages) for (const n of r.components) ae(n) && se(n, (o) => (o.includes("{totalPages}") && (t = !0), o));
|
|
709
669
|
return t;
|
|
710
670
|
}
|
|
711
|
-
function
|
|
671
|
+
function Ur(e, t, r, n, o, a) {
|
|
712
672
|
const s = {
|
|
713
673
|
pageWidthMm: t.widthMm,
|
|
714
674
|
pageHeightMm: t.heightMm,
|
|
@@ -723,38 +683,38 @@ function Zr(e, t, r, n, o, a) {
|
|
|
723
683
|
const l = c.replace(/\{page\}/g, String(n));
|
|
724
684
|
return a === void 0 ? l : l.replace(/\{totalPages\}/g, String(a));
|
|
725
685
|
};
|
|
726
|
-
for (const c of r) s.components.push(
|
|
686
|
+
for (const c of r) s.components.push(se(c, i));
|
|
727
687
|
if (e.layout === "wide") {
|
|
728
|
-
const c = s.components.reduce((l,
|
|
688
|
+
const c = s.components.reduce((l, u) => Math.max(l, u.topMm + u.heightMm), 0);
|
|
729
689
|
s.marginBottomMm = o ? e.marginBottomMm ?? 0 : 0, s.pageHeightMm = Math.max(1, c + s.marginBottomMm);
|
|
730
690
|
}
|
|
731
691
|
return s;
|
|
732
692
|
}
|
|
733
|
-
function
|
|
734
|
-
return e.cells.reduce((t, r) => t + r.reduce((n, o) => n + (o ? 1 + (o.children?.reduce((a, s) => a +
|
|
693
|
+
function Ee(e) {
|
|
694
|
+
return e.cells.reduce((t, r) => t + r.reduce((n, o) => n + (o ? 1 + (o.children?.reduce((a, s) => a + ut(s), 0) ?? 0) : 0), 0), 0);
|
|
735
695
|
}
|
|
736
|
-
function
|
|
737
|
-
return e.grid ?
|
|
696
|
+
function ut(e) {
|
|
697
|
+
return e.grid ? Ee(e.grid) : 0;
|
|
738
698
|
}
|
|
739
|
-
function
|
|
699
|
+
function ie(e) {
|
|
740
700
|
for (const t of ["maxPages", "maxCells", "knownTotalPages"]) if (e[t] !== void 0 && (!Number.isSafeInteger(e[t]) || e[t] < 1)) throw new RangeError(`${t} 应为正安全整数`);
|
|
741
|
-
|
|
701
|
+
Se(e.maxChartComponents);
|
|
742
702
|
}
|
|
743
|
-
function
|
|
744
|
-
const r =
|
|
745
|
-
return (n.header === !1 ? 0 : o.headerHeightMm) + r.rows.reduce((a, s) => a +
|
|
703
|
+
function Xr(e, t) {
|
|
704
|
+
const r = dt(e, t.datasets[e.dataset] ?? [], t), n = Pe(r.list), o = { ...Te(n, t.measurer, r.rows, t.signal), rowHeightFloorMm: n.rowHeightMm ?? 0 };
|
|
705
|
+
return (n.header === !1 ? 0 : o.headerHeightMm) + r.rows.reduce((a, s) => a + z(o, s, t.measurer).heightMm, 0);
|
|
746
706
|
}
|
|
747
|
-
function*
|
|
707
|
+
function* Yr(e) {
|
|
748
708
|
const { templatePage: t, current: r } = e, n = new Map(t.components.map((a, s) => [a, s])), o = (a, s, i) => {
|
|
749
709
|
const c = e.datasets[a.dataset];
|
|
750
|
-
return Array.isArray(c) || e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id ?? ""} 输出为空`),
|
|
710
|
+
return Array.isArray(c) || e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id ?? ""} 输出为空`), _r(a, Array.isArray(c) ? c : [], { ...e, tableId: `${e.tableId}:${n.get(a)}`, startTop: s, finished: i, flow: !!t.flow });
|
|
751
711
|
};
|
|
752
712
|
if (t.flow) {
|
|
753
|
-
yield*
|
|
713
|
+
yield* vr({
|
|
754
714
|
page: t,
|
|
755
|
-
active: () =>
|
|
715
|
+
active: () => K(e.signal),
|
|
756
716
|
top: () => Math.max(r.marginTopMm, V(t)),
|
|
757
|
-
bottom: () =>
|
|
717
|
+
bottom: () => Q(t, r),
|
|
758
718
|
append: (a) => {
|
|
759
719
|
r.components.push(...e.resolveChart(a));
|
|
760
720
|
},
|
|
@@ -762,173 +722,173 @@ function* tn(e) {
|
|
|
762
722
|
e.pushCurrent(), r.components = [], r.heightMm = t.heightMm, t.layout === "wide" && (r.marginTopMm = 0, r.marginBottomMm = 0);
|
|
763
723
|
},
|
|
764
724
|
takePages: e.takePages,
|
|
765
|
-
height: (a) =>
|
|
725
|
+
height: (a) => Xr(a, e),
|
|
766
726
|
list: o
|
|
767
727
|
});
|
|
768
728
|
return;
|
|
769
729
|
}
|
|
770
730
|
for (const a of t.components)
|
|
771
|
-
|
|
731
|
+
ae(a) || (a.kind === "list" ? yield* o(a) : r.components.push(...e.resolveChart(a)));
|
|
772
732
|
}
|
|
773
|
-
function*
|
|
733
|
+
function* J(e, t, r, n, o, a = /* @__PURE__ */ new WeakMap(), s) {
|
|
774
734
|
let i = 0, c = 0, l = 0;
|
|
775
|
-
const
|
|
776
|
-
for (const { pageIndex: h, page: m } of
|
|
777
|
-
|
|
778
|
-
const v =
|
|
779
|
-
let
|
|
780
|
-
const
|
|
781
|
-
if (
|
|
782
|
-
if (r.maxCells !== void 0 && (l += [...v.components, ...
|
|
735
|
+
const u = mr(r.measurer ?? Ve), f = Ut(t, r.signal, r.maxChartComponents), d = (h) => `${h}_${(++i).toString(36)}`;
|
|
736
|
+
for (const { pageIndex: h, page: m } of Ir(e, t, r)) {
|
|
737
|
+
K(r.signal);
|
|
738
|
+
const v = $r(m), p = m.components.filter(ae);
|
|
739
|
+
let w = [];
|
|
740
|
+
const y = (k = !1) => {
|
|
741
|
+
if (K(r.signal), r.maxPages !== void 0 && c >= r.maxPages) throw new W(r.maxPages, c + 1);
|
|
742
|
+
if (r.maxCells !== void 0 && (l += [...v.components, ...p].reduce((T, O) => T + ut(O), 0), l > r.maxCells))
|
|
783
743
|
throw new Y(r.maxCells, l);
|
|
784
|
-
|
|
744
|
+
w.push(Ur(m, v, p, ++c, k, o));
|
|
785
745
|
}, x = () => {
|
|
786
|
-
const
|
|
787
|
-
return
|
|
746
|
+
const k = w;
|
|
747
|
+
return w = [], k;
|
|
788
748
|
};
|
|
789
|
-
yield*
|
|
749
|
+
yield* Yr({
|
|
790
750
|
templatePage: m,
|
|
791
751
|
current: v,
|
|
792
752
|
warnings: n,
|
|
793
|
-
nextId:
|
|
794
|
-
pushCurrent:
|
|
753
|
+
nextId: d,
|
|
754
|
+
pushCurrent: y,
|
|
795
755
|
takePages: x,
|
|
796
756
|
datasets: t,
|
|
797
757
|
resolveChart: f,
|
|
798
758
|
signal: r.signal,
|
|
799
759
|
formula: r.formula,
|
|
800
760
|
prepared: a,
|
|
801
|
-
measurer:
|
|
761
|
+
measurer: u,
|
|
802
762
|
mmPerRow: r.mmPerRow ?? 0,
|
|
803
763
|
tableId: `table:${h}`
|
|
804
|
-
}),
|
|
764
|
+
}), y(!0), yield* x();
|
|
805
765
|
}
|
|
806
766
|
s && (s.chartComponents = f.used());
|
|
807
767
|
}
|
|
808
|
-
function
|
|
809
|
-
|
|
768
|
+
function lo(e, t, r = {}) {
|
|
769
|
+
ie(r);
|
|
810
770
|
let n = 0;
|
|
811
|
-
for (const o of
|
|
771
|
+
for (const o of J(e, t, { ...r, onWarning: void 0 }, [])) n++;
|
|
812
772
|
return n;
|
|
813
773
|
}
|
|
814
|
-
function*
|
|
815
|
-
yield*
|
|
774
|
+
function* uo(e, t, r = {}) {
|
|
775
|
+
yield* Qr(e, t, r);
|
|
816
776
|
}
|
|
817
|
-
function*
|
|
818
|
-
|
|
819
|
-
const o =
|
|
777
|
+
function* Qr(e, t, r, n) {
|
|
778
|
+
ie(r);
|
|
779
|
+
const o = qr(e), a = /* @__PURE__ */ new WeakMap();
|
|
820
780
|
let s = r.knownTotalPages;
|
|
821
781
|
if (o && s === void 0) {
|
|
822
782
|
s = 0;
|
|
823
|
-
for (const l of
|
|
783
|
+
for (const l of J(e, t, r, [], void 0, a)) s++;
|
|
824
784
|
}
|
|
825
785
|
const i = [];
|
|
826
786
|
let c = 0;
|
|
827
|
-
for (const l of
|
|
787
|
+
for (const l of J(e, t, r, i, s, a, n)) {
|
|
828
788
|
for (; c < i.length; c++) r.onWarning?.(i[c]);
|
|
829
789
|
yield l;
|
|
830
790
|
}
|
|
831
791
|
}
|
|
832
|
-
function
|
|
792
|
+
function ft(e, t, r = {}) {
|
|
833
793
|
const n = typeof r == "number" ? { mmPerRow: r } : r;
|
|
834
|
-
|
|
835
|
-
const o = [], a = { chartComponents: 0 }, s = [...
|
|
836
|
-
return
|
|
794
|
+
ie(n);
|
|
795
|
+
const o = [], a = { chartComponents: 0 }, s = [...J(e, t, n, o, n.knownTotalPages, void 0, a)];
|
|
796
|
+
return ht(e, n, s, o, a);
|
|
837
797
|
}
|
|
838
|
-
async function
|
|
839
|
-
|
|
798
|
+
async function mt(e, t, r = {}) {
|
|
799
|
+
ie(r), K(r.signal);
|
|
840
800
|
const n = [], o = [], a = { chartComponents: 0 };
|
|
841
801
|
let s = performance.now(), i = 0;
|
|
842
|
-
for (const c of
|
|
843
|
-
o.push(c), (++i >= 8 || performance.now() - s >= 8) && (await new Promise((l) => setTimeout(l, 0)),
|
|
844
|
-
return
|
|
802
|
+
for (const c of J(e, t, r, n, r.knownTotalPages, void 0, a))
|
|
803
|
+
o.push(c), (++i >= 8 || performance.now() - s >= 8) && (await new Promise((l) => setTimeout(l, 0)), K(r.signal), s = performance.now(), i = 0);
|
|
804
|
+
return K(r.signal), ht(e, r, o, n, a);
|
|
845
805
|
}
|
|
846
|
-
function
|
|
847
|
-
for (const a of r) a.components = a.components.map((s) =>
|
|
848
|
-
return n.forEach((a) => t.onWarning?.(a)), { plan: { schemaVersion: be, ...
|
|
806
|
+
function ht(e, t, r, n, o) {
|
|
807
|
+
for (const a of r) a.components = a.components.map((s) => ae(s) ? se(s, (i) => i.replace(/\{totalPages\}/g, String(r.length))) : s);
|
|
808
|
+
return n.forEach((a) => t.onWarning?.(a)), { plan: { schemaVersion: be, ...Ce(e) ? { requiresRecalculation: !0 } : {}, pages: r }, warnings: n, ...o };
|
|
849
809
|
}
|
|
850
|
-
function
|
|
810
|
+
function Zr(e) {
|
|
851
811
|
const t = e.columns.find((a) => !a.hidden)?.field;
|
|
852
812
|
if (!t) return { groups: 0, total: 0 };
|
|
853
|
-
const r =
|
|
813
|
+
const r = oe(e), n = (a = [], s = []) => a.includes(t) || s.some((i) => i.field === t), o = typeof e.grandTotal == "object" ? e.grandTotal : void 0;
|
|
854
814
|
return { groups: r.filter((a) => n(a.subtotal, a.aggregates)).length, total: Number(n(o?.fields ?? r[0]?.subtotal, o?.aggregates ?? r[0]?.aggregates)) };
|
|
855
815
|
}
|
|
856
|
-
function
|
|
857
|
-
|
|
858
|
-
const n =
|
|
816
|
+
function en(e, t, r) {
|
|
817
|
+
lt(e);
|
|
818
|
+
const n = Xe(t[e.dataset] ?? [], e.tree, r), o = e.columns.filter((s) => !s.hidden).length, a = e.header === !1 ? 0 : e.headerGrid ? Ee(e.headerGrid) : o;
|
|
859
819
|
return n.length * o + a + +!!e.grandTotal * 2 * o;
|
|
860
820
|
}
|
|
861
|
-
function
|
|
862
|
-
if (e.tree) return
|
|
821
|
+
function fo(e, t, r = {}) {
|
|
822
|
+
if (e.tree) return en(e, t, r.signal);
|
|
863
823
|
if (e.matrix) {
|
|
864
824
|
let c = t[e.dataset] ?? [];
|
|
865
|
-
e.computed?.length && (c =
|
|
866
|
-
const l =
|
|
825
|
+
e.computed?.length && (c = ve(c, { fields: e.computed, ...r }).rows), e.rowVisibleWhen && (c = c.filter(H(e.rowVisibleWhen)));
|
|
826
|
+
const l = er(c, e.matrix);
|
|
867
827
|
return l.cells + (e.header === !1 ? 0 : l.columnCount * (e.matrix.hierarchy ? e.matrix.columnFields.length + 1 : 1));
|
|
868
828
|
}
|
|
869
|
-
const n = t[e.dataset]?.length ?? 0, o = e.columns.filter((c) => !c.hidden).length, a =
|
|
829
|
+
const n = t[e.dataset]?.length ?? 0, o = e.columns.filter((c) => !c.hidden).length, a = oe(e).length, s = Zr(e);
|
|
870
830
|
let i = (n * (1 + 2 * a + s.groups) + +!!e.grandTotal * (1 + s.total)) * o;
|
|
871
|
-
if (i += e.header === !1 ? 0 : e.headerGrid ?
|
|
872
|
-
const c = t[e.detail.dataset]?.length ?? 0, l = e.detail.columns.filter((
|
|
831
|
+
if (i += e.header === !1 ? 0 : e.headerGrid ? Ee(e.headerGrid) : o, e.cardinality === "record" && n === 0 && (i += o), e.detail) {
|
|
832
|
+
const c = t[e.detail.dataset]?.length ?? 0, l = e.detail.columns.filter((u) => !u.hidden).length;
|
|
873
833
|
i += (c + n * (+(e.detail.header !== !1) + +!!e.detail.label)) * l;
|
|
874
834
|
}
|
|
875
835
|
if (!Number.isSafeInteger(i)) throw new RangeError("报表单元格估算超出安全整数预算");
|
|
876
836
|
return i;
|
|
877
837
|
}
|
|
878
|
-
class
|
|
838
|
+
class tn extends Error {
|
|
879
839
|
constructor(t) {
|
|
880
840
|
super(t.map((r) => r.message).join(";")), this.issues = t, this.name = "ReportValidationError";
|
|
881
841
|
}
|
|
882
842
|
}
|
|
883
|
-
function
|
|
843
|
+
function Ne(e, t, r) {
|
|
884
844
|
if (!Number.isSafeInteger(e) || e < 1 || e > r) throw new Error(`校验 ${t} 超出预算`);
|
|
885
845
|
return e;
|
|
886
846
|
}
|
|
887
|
-
function
|
|
847
|
+
function rn(e) {
|
|
888
848
|
if (e.aggregates && e.scope !== "dataset") throw new Error("仅数据集规则允许汇总");
|
|
889
849
|
if (e.aggregates && (!Array.isArray(e.aggregates) || e.aggregates.length > 64)) throw new Error("校验汇总最多 64 项");
|
|
890
850
|
const t = /* @__PURE__ */ new Set();
|
|
891
851
|
for (const r of e.aggregates ?? []) {
|
|
892
|
-
if (
|
|
893
|
-
t.add(r.field), r.valueField !== void 0 &&
|
|
852
|
+
if (N(r.field), t.has(r.field)) throw new Error("校验汇总字段重复");
|
|
853
|
+
t.add(r.field), r.valueField !== void 0 && N(r.valueField), r.weightField !== void 0 && N(r.weightField), Me([], { ...r, field: r.valueField ?? r.field });
|
|
894
854
|
}
|
|
895
855
|
}
|
|
896
|
-
function
|
|
856
|
+
function gt(e) {
|
|
897
857
|
if (!Array.isArray(e) || e.length > 256 || Object.keys(e).length !== e.length) throw new Error("校验规则最多 256 条且不允许空位");
|
|
898
858
|
const t = /* @__PURE__ */ new Set();
|
|
899
859
|
return e.map((r) => {
|
|
900
860
|
if (!r || typeof r != "object") throw new Error("校验规则应为声明式对象");
|
|
901
|
-
if (
|
|
902
|
-
if (t.add(r.id), r.field !== void 0 &&
|
|
861
|
+
if (N(r.id), t.has(r.id)) throw new Error("校验规则 id 重复");
|
|
862
|
+
if (t.add(r.id), r.field !== void 0 && N(r.field), r.dataset !== void 0 && N(r.dataset), typeof r.message != "string" || !r.message.trim() || r.message.length > 2048) throw new Error("校验规则需要有界提示文案");
|
|
903
863
|
if (r.severity !== void 0 && !["error", "warning"].includes(r.severity)) throw new Error("未知校验严重程度");
|
|
904
864
|
if (r.scope !== void 0 && !["row", "dataset"].includes(r.scope)) throw new Error("未知校验范围");
|
|
905
|
-
|
|
865
|
+
rn(r);
|
|
906
866
|
const n = { nodes: 0 }, o = H(r.assert, n), a = r.when ? H(r.when, n) : void 0;
|
|
907
867
|
return { rule: r, assert: o, when: a, checks: n.nodes };
|
|
908
868
|
});
|
|
909
869
|
}
|
|
910
|
-
function
|
|
870
|
+
function Le(e) {
|
|
911
871
|
if (e?.aborted) {
|
|
912
872
|
const t = new Error("报表校验已取消");
|
|
913
873
|
throw t.name = "AbortError", t;
|
|
914
874
|
}
|
|
915
875
|
}
|
|
916
|
-
function
|
|
876
|
+
function nn(e, t, r, n) {
|
|
917
877
|
const o = n && Object.prototype.hasOwnProperty.call(t, n) ? t[n] : void 0;
|
|
918
878
|
if (o !== void 0 && typeof o != "string" && !(typeof o == "number" && Number.isFinite(o))) throw new Error("校验定位需要稳定的文本或数值业务键");
|
|
919
879
|
return { ruleId: e.id, rowIndex: r, ...o === void 0 ? {} : { rowKey: o }, field: e.field, severity: e.severity ?? "error", message: e.message };
|
|
920
880
|
}
|
|
921
|
-
function
|
|
881
|
+
function on(e, t) {
|
|
922
882
|
const r = t.computed?.length ? { fields: t.computed, formula: t.formula, signal: t.signal } : void 0;
|
|
923
883
|
if (t.tree) {
|
|
924
|
-
const o =
|
|
884
|
+
const o = Ye(e, t.tree, { signal: t.signal, computed: r });
|
|
925
885
|
if (o.rows.length > 1e5) throw new Error("校验展开后数据最多 100000 行");
|
|
926
886
|
return { rows: o.rows, summaryRows: o.leaves, rowKey: t.tree.idField };
|
|
927
887
|
}
|
|
928
|
-
const n = r ?
|
|
888
|
+
const n = r ? ve(e, r).rows : e;
|
|
929
889
|
return { rows: n, summaryRows: n, rowKey: t.rowKey };
|
|
930
890
|
}
|
|
931
|
-
function
|
|
891
|
+
function an(e, t) {
|
|
932
892
|
const r = /* @__PURE__ */ new Set();
|
|
933
893
|
e.forEach((n) => {
|
|
934
894
|
if (!n || typeof n != "object" || Array.isArray(n)) throw new Error("校验数据行应为对象");
|
|
@@ -939,49 +899,49 @@ function dn(e, t) {
|
|
|
939
899
|
r.add(o);
|
|
940
900
|
});
|
|
941
901
|
}
|
|
942
|
-
function
|
|
943
|
-
return
|
|
902
|
+
function mo(e, t) {
|
|
903
|
+
return pt(e, t, { checks: 0 });
|
|
944
904
|
}
|
|
945
|
-
function
|
|
905
|
+
function pt(e, t, r) {
|
|
946
906
|
if (!Array.isArray(e) || e.length > 1e5) throw new Error("校验数据最多 100000 行");
|
|
947
|
-
|
|
948
|
-
const n =
|
|
949
|
-
t.rowKey !== void 0 &&
|
|
950
|
-
const a =
|
|
951
|
-
|
|
952
|
-
const l =
|
|
953
|
-
if (r.checks +=
|
|
907
|
+
Le(t.signal);
|
|
908
|
+
const n = Ne(t.maxChecks ?? 2e6, "maxChecks", 1e7), o = Ne(t.maxIssues ?? 1e3, "maxIssues", 1e4);
|
|
909
|
+
t.rowKey !== void 0 && N(t.rowKey);
|
|
910
|
+
const a = on(e, t), { rows: s, summaryRows: i, rowKey: c } = a;
|
|
911
|
+
an(s, c);
|
|
912
|
+
const l = gt(t.rules), u = l.reduce((d, h) => d + (h.rule.scope === "dataset" ? h.checks + i.length * (h.rule.aggregates?.length ?? 0) : s.length * h.checks), 0);
|
|
913
|
+
if (r.checks += u, r.checks > n) throw new Error("整批校验超出 maxChecks 预算");
|
|
954
914
|
const f = [];
|
|
955
|
-
for (const
|
|
956
|
-
(
|
|
957
|
-
if (
|
|
958
|
-
if (!(
|
|
915
|
+
for (const d of l)
|
|
916
|
+
(d.rule.scope === "dataset" ? [Object.fromEntries((d.rule.aggregates ?? []).map((m) => [m.field, Me(i, { ...m, field: m.valueField ?? m.field })]))] : s).forEach((m, v) => {
|
|
917
|
+
if (Le(t.signal), !m || typeof m != "object" || Array.isArray(m)) throw new Error("校验数据行应为对象");
|
|
918
|
+
if (!(d.when && !d.when(m) || d.assert(m))) {
|
|
959
919
|
if (f.length >= o) throw new Error("校验问题超出 maxIssues 预算,请缩小范围");
|
|
960
|
-
f.push(
|
|
920
|
+
f.push(nn(d.rule, m, d.rule.scope === "dataset" ? void 0 : v, d.rule.scope === "dataset" ? void 0 : c));
|
|
961
921
|
}
|
|
962
922
|
});
|
|
963
923
|
return f;
|
|
964
924
|
}
|
|
965
|
-
function
|
|
925
|
+
function sn(e, t = "allow") {
|
|
966
926
|
if (!["allow", "block"].includes(t)) throw new Error("未知校验警告策略");
|
|
967
927
|
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("校验问题结构无效");
|
|
968
|
-
if (e.some((r) => r.severity === "error" || t === "block")) throw new
|
|
928
|
+
if (e.some((r) => r.severity === "error" || t === "block")) throw new tn(e);
|
|
969
929
|
}
|
|
970
|
-
function
|
|
930
|
+
function He(e, t, r) {
|
|
971
931
|
const n = e.get(t);
|
|
972
932
|
if (n && JSON.stringify(n) !== JSON.stringify(r)) throw new Error("同一数据集的校验计算/业务键存在歧义,请统一绑定");
|
|
973
933
|
e.set(t, r);
|
|
974
934
|
}
|
|
975
|
-
function
|
|
976
|
-
|
|
935
|
+
function cn(e, t, r, n = []) {
|
|
936
|
+
gt(t.rules);
|
|
977
937
|
const o = [], a = { checks: 0 };
|
|
978
938
|
for (const [i, c] of e.entries()) {
|
|
979
939
|
const l = /* @__PURE__ */ new Map();
|
|
980
|
-
for (const
|
|
981
|
-
f.kind === "list" && (
|
|
982
|
-
for (const [
|
|
983
|
-
const
|
|
984
|
-
if (
|
|
940
|
+
for (const u of c.template.pages) for (const f of u.components)
|
|
941
|
+
f.kind === "list" && (He(l, f.dataset, { rowKey: f.tree?.idField ?? f.rowKey, computed: f.computed, tree: f.tree }), f.detail && He(l, f.detail.dataset, { rowKey: f.detail.rowKey }));
|
|
942
|
+
for (const [u, f] of l) {
|
|
943
|
+
const d = t.rules.filter((h) => !h.dataset || h.dataset === u);
|
|
944
|
+
if (d.length && (o.push(...pt(c.datasets[u] ?? [], { ...t, rules: d, ...f, formula: n[i], signal: r }, a).map((h) => ({ ...h, dataset: u, sourceScope: c.sourceScope }))), o.length > (t.maxIssues ?? 1e3)))
|
|
985
945
|
throw new Error("整批候选校验问题超出 maxIssues 预算");
|
|
986
946
|
}
|
|
987
947
|
}
|
|
@@ -989,31 +949,31 @@ function fn(e, t, r, n = []) {
|
|
|
989
949
|
if (t.rules.some((i) => i.dataset && !s.has(i.dataset))) throw new Error("校验目标数据集不存在");
|
|
990
950
|
return o;
|
|
991
951
|
}
|
|
992
|
-
function
|
|
952
|
+
function wt(e) {
|
|
993
953
|
return !e || typeof e != "object" ? !1 : [e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex].every((t) => Number.isInteger(t) && t >= 0);
|
|
994
954
|
}
|
|
995
|
-
function
|
|
955
|
+
function yt(e, t, r) {
|
|
996
956
|
const n = e.grid;
|
|
997
957
|
if (!n) return null;
|
|
998
958
|
const o = n.cells[t];
|
|
999
959
|
if (!o) return null;
|
|
1000
|
-
const s =
|
|
960
|
+
const s = te(n, e.widthMm, e.heightMm).cells.filter((c) => c.ri === t).findIndex((c) => c.ci === r), i = o[s];
|
|
1001
961
|
return i ? { cell: i, sourceColumnIndex: s } : null;
|
|
1002
962
|
}
|
|
1003
|
-
function
|
|
963
|
+
function ln(e) {
|
|
1004
964
|
return e.value !== void 0 ? e.value : e.rawText ?? e.text ?? null;
|
|
1005
965
|
}
|
|
1006
|
-
function
|
|
966
|
+
function dn(e, t) {
|
|
1007
967
|
return e.valueType ? e.valueType : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t === null && e.numberFormat && /[0#?]/.test(e.numberFormat) ? "number" : "text";
|
|
1008
968
|
}
|
|
1009
|
-
function
|
|
969
|
+
function un(e, t) {
|
|
1010
970
|
if (e.derived) return "derived";
|
|
1011
971
|
if (e.editable === !1) return "cell";
|
|
1012
972
|
if (e.formula !== void 0) return "formula";
|
|
1013
973
|
if (e.children?.length || e.richParagraphs?.length) return "complex";
|
|
1014
974
|
if (t.table && t.table.role !== "body" && e.editable !== !0) return "structure";
|
|
1015
975
|
}
|
|
1016
|
-
function
|
|
976
|
+
function fn(e, t) {
|
|
1017
977
|
const r = e.table;
|
|
1018
978
|
if (r)
|
|
1019
979
|
return {
|
|
@@ -1023,45 +983,45 @@ function pn(e, t) {
|
|
|
1023
983
|
columnKey: r.columnKeys[t.columnIndex]
|
|
1024
984
|
};
|
|
1025
985
|
}
|
|
1026
|
-
function
|
|
986
|
+
function mn(e, t, r) {
|
|
1027
987
|
if (e.derived) return;
|
|
1028
988
|
if (e.source) return { ...e.source };
|
|
1029
989
|
const n = t.table?.source, o = t.table?.columnKeys[r.columnIndex];
|
|
1030
990
|
if (!(!n || n.rowKey === void 0 || o === void 0))
|
|
1031
991
|
return { ...n, rowKey: n.rowKey, field: o };
|
|
1032
992
|
}
|
|
1033
|
-
function
|
|
1034
|
-
const n =
|
|
993
|
+
function bt(e, t, r) {
|
|
994
|
+
const n = ln(r), o = un(r, e);
|
|
1035
995
|
return {
|
|
1036
996
|
address: { ...t },
|
|
1037
997
|
cell: r,
|
|
1038
998
|
component: e,
|
|
1039
999
|
value: n,
|
|
1040
|
-
valueType:
|
|
1041
|
-
table:
|
|
1042
|
-
source:
|
|
1000
|
+
valueType: dn(r, n),
|
|
1001
|
+
table: fn(e, t),
|
|
1002
|
+
source: mn(r, e, t),
|
|
1043
1003
|
editable: o === void 0,
|
|
1044
1004
|
readOnlyReason: o
|
|
1045
1005
|
};
|
|
1046
1006
|
}
|
|
1047
|
-
function
|
|
1048
|
-
if (!
|
|
1007
|
+
function Re(e, t) {
|
|
1008
|
+
if (!wt(t)) return null;
|
|
1049
1009
|
const r = e.pages[t.pageIndex]?.components[t.componentIndex];
|
|
1050
1010
|
if (!r) return null;
|
|
1051
|
-
const n =
|
|
1052
|
-
return n ?
|
|
1011
|
+
const n = yt(r, t.rowIndex, t.columnIndex);
|
|
1012
|
+
return n ? bt(r, t, n.cell) : null;
|
|
1053
1013
|
}
|
|
1054
1014
|
function D(e) {
|
|
1055
1015
|
const t = /* @__PURE__ */ new Map();
|
|
1056
1016
|
return (r) => {
|
|
1057
|
-
if (!
|
|
1017
|
+
if (!wt(r)) return null;
|
|
1058
1018
|
const n = e.pages[r.pageIndex]?.components[r.componentIndex];
|
|
1059
1019
|
if (!n?.grid) return null;
|
|
1060
1020
|
let o = t.get(n);
|
|
1061
1021
|
if (!o) {
|
|
1062
1022
|
const s = /* @__PURE__ */ new Map();
|
|
1063
1023
|
o = /* @__PURE__ */ new Map();
|
|
1064
|
-
for (const i of
|
|
1024
|
+
for (const i of te(n.grid, n.widthMm, n.heightMm).cells) {
|
|
1065
1025
|
const c = s.get(i.ri) ?? 0;
|
|
1066
1026
|
s.set(i.ri, c + 1);
|
|
1067
1027
|
const l = n.grid.cells[i.ri]?.[c];
|
|
@@ -1070,7 +1030,7 @@ function D(e) {
|
|
|
1070
1030
|
t.set(n, o);
|
|
1071
1031
|
}
|
|
1072
1032
|
const a = o.get(`${r.rowIndex}:${r.columnIndex}`);
|
|
1073
|
-
return a ?
|
|
1033
|
+
return a ? bt(n, r, a) : null;
|
|
1074
1034
|
};
|
|
1075
1035
|
}
|
|
1076
1036
|
class M extends Error {
|
|
@@ -1078,20 +1038,20 @@ class M extends Error {
|
|
|
1078
1038
|
super(`Invalid report cell edit: ${t}`), this.code = t, this.name = "ReportCellEditError";
|
|
1079
1039
|
}
|
|
1080
1040
|
}
|
|
1081
|
-
function
|
|
1041
|
+
function hn(e, t) {
|
|
1082
1042
|
let r = e.trim();
|
|
1083
1043
|
const n = t && r.endsWith("%");
|
|
1084
1044
|
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 M("number");
|
|
1085
1045
|
return Number(r) / (n ? 100 : 1);
|
|
1086
1046
|
}
|
|
1087
|
-
function
|
|
1047
|
+
function gn(e, t) {
|
|
1088
1048
|
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
1089
1049
|
if (typeof e != "string" && typeof e != "number") throw new M("number");
|
|
1090
|
-
const r = typeof e == "number" ? e :
|
|
1050
|
+
const r = typeof e == "number" ? e : hn(e, dr(t.cell.numberFormat));
|
|
1091
1051
|
if (!Number.isFinite(r) || Number.isInteger(r) && !Number.isSafeInteger(r)) throw new M("number");
|
|
1092
1052
|
return r;
|
|
1093
1053
|
}
|
|
1094
|
-
function
|
|
1054
|
+
function pn(e) {
|
|
1095
1055
|
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
1096
1056
|
if (typeof e == "boolean") return e;
|
|
1097
1057
|
const t = String(e).trim().toLowerCase();
|
|
@@ -1099,24 +1059,24 @@ function vn(e) {
|
|
|
1099
1059
|
if (["false", "no", "否", "0"].includes(t)) return !1;
|
|
1100
1060
|
throw new M("boolean");
|
|
1101
1061
|
}
|
|
1102
|
-
function
|
|
1103
|
-
return e.valueType === "number" ?
|
|
1062
|
+
function vt(e, t) {
|
|
1063
|
+
return e.valueType === "number" ? gn(t, e) : e.valueType === "boolean" ? pn(t) : t === null ? null : String(t);
|
|
1104
1064
|
}
|
|
1105
|
-
function
|
|
1065
|
+
function wn(e, t) {
|
|
1106
1066
|
const r = t.cell.text, o = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((a) => a.includes(r ?? ""));
|
|
1107
1067
|
return o ? o[e ? 0 : 1] : String(e);
|
|
1108
1068
|
}
|
|
1109
1069
|
function q(e, t) {
|
|
1110
|
-
return t === null ? "" : typeof t == "boolean" ?
|
|
1070
|
+
return t === null ? "" : typeof t == "boolean" ? wn(t, e) : typeof t == "number" ? lr(t, e.cell.numberFormat) : String(t);
|
|
1111
1071
|
}
|
|
1112
|
-
function
|
|
1113
|
-
const n =
|
|
1072
|
+
function ho(e, t, r) {
|
|
1073
|
+
const n = Re(e, t);
|
|
1114
1074
|
if (!n) throw new M("missing");
|
|
1115
1075
|
return U(n, r);
|
|
1116
1076
|
}
|
|
1117
1077
|
function U(e, t) {
|
|
1118
1078
|
if (!e.editable) throw new M("readonly");
|
|
1119
|
-
const r =
|
|
1079
|
+
const r = vt(e, t);
|
|
1120
1080
|
return {
|
|
1121
1081
|
address: { ...e.address },
|
|
1122
1082
|
table: e.table,
|
|
@@ -1127,33 +1087,33 @@ function U(e, t) {
|
|
|
1127
1087
|
text: q(e, r)
|
|
1128
1088
|
};
|
|
1129
1089
|
}
|
|
1130
|
-
function
|
|
1090
|
+
function yn(e, t) {
|
|
1131
1091
|
const r = e.table, n = t.table;
|
|
1132
1092
|
return !r || !n || r.columnKey === void 0 ? !1 : r.id === n.id && r.rowIndex === n.rowIndex && r.role === n.role && r.columnKey === n.columnKey;
|
|
1133
1093
|
}
|
|
1134
|
-
function
|
|
1135
|
-
const n = e.grid, { rowIndex: o, columnIndex: a } = t.address, s =
|
|
1136
|
-
return c[s.sourceColumnIndex] =
|
|
1094
|
+
function Mt(e, t, r) {
|
|
1095
|
+
const n = e.grid, { rowIndex: o, columnIndex: a } = t.address, s = yt(e, o, a), i = [...n.cells], c = [...i[o]], l = q(t, r.value), u = { ...s.cell, value: r.value, text: l, rawText: l };
|
|
1096
|
+
return c[s.sourceColumnIndex] = u, i[o] = c, { ...e, grid: { ...n, cells: i } };
|
|
1137
1097
|
}
|
|
1138
|
-
function
|
|
1098
|
+
function bn(e, t) {
|
|
1139
1099
|
const r = e.table?.columnKeys, n = t.table?.columnKey;
|
|
1140
1100
|
return r && n !== void 0 ? r.flatMap((o, a) => o === n ? [a] : []) : [];
|
|
1141
1101
|
}
|
|
1142
|
-
function
|
|
1102
|
+
function vn(e, t, r, n, o, a) {
|
|
1143
1103
|
const s = t.table, i = o.table;
|
|
1144
1104
|
if (!s || !i || s.id !== i.id || s.role !== i.role || !t.grid) return t;
|
|
1145
1105
|
const c = i.rowIndex - s.rowIndex;
|
|
1146
1106
|
if (c < 0 || c >= t.grid.cells.length) return t;
|
|
1147
1107
|
let l = t;
|
|
1148
|
-
for (const
|
|
1149
|
-
const f =
|
|
1150
|
-
f?.editable &&
|
|
1108
|
+
for (const u of bn(t, o)) {
|
|
1109
|
+
const f = Re(e, { pageIndex: r, componentIndex: n, rowIndex: c, columnIndex: u });
|
|
1110
|
+
f?.editable && yn(o, f) && (l = Mt(l, f, a));
|
|
1151
1111
|
}
|
|
1152
1112
|
return l;
|
|
1153
1113
|
}
|
|
1154
|
-
function
|
|
1114
|
+
function Mn(e, t, r, n, o, a) {
|
|
1155
1115
|
const s = o.address;
|
|
1156
|
-
return o.table?.columnKey !== void 0 ?
|
|
1116
|
+
return o.table?.columnKey !== void 0 ? vn(e, t, r, n, o, a) : s.pageIndex === r && s.componentIndex === n ? Mt(t, o, a) : t;
|
|
1157
1117
|
}
|
|
1158
1118
|
function Ie(e, t) {
|
|
1159
1119
|
const r = t.source;
|
|
@@ -1161,21 +1121,21 @@ function Ie(e, t) {
|
|
|
1161
1121
|
const n = e.source;
|
|
1162
1122
|
return !n || ["sourceScope", "datasetId", "rowKey", "field", "revision", "sourceToken"].some((o) => !Object.is(n[o], r[o]));
|
|
1163
1123
|
}
|
|
1164
|
-
function
|
|
1165
|
-
const r =
|
|
1124
|
+
function go(e, t) {
|
|
1125
|
+
const r = Re(e, t.address);
|
|
1166
1126
|
if (!r) throw new M("missing");
|
|
1167
1127
|
if (!r.editable) throw new M("readonly");
|
|
1168
1128
|
if (Ie(r, t)) throw new M("conflict");
|
|
1169
1129
|
if (!Object.is(r.value, t.previousValue) || (r.cell.text ?? "") !== t.previousText) throw new M("conflict");
|
|
1170
|
-
const n =
|
|
1130
|
+
const n = vt(r, t.value), o = { ...t, value: n, text: q(r, n) };
|
|
1171
1131
|
if (Object.is(n, r.value) && o.text === r.cell.text) return e;
|
|
1172
1132
|
const a = e.pages.map((s, i) => {
|
|
1173
|
-
const c = s.components.map((l,
|
|
1174
|
-
return c.every((l,
|
|
1133
|
+
const c = s.components.map((l, u) => Mn(e, l, i, u, r, o));
|
|
1134
|
+
return c.every((l, u) => l === s.components[u]) ? s : { ...s, components: c };
|
|
1175
1135
|
});
|
|
1176
1136
|
return { ...e, pages: a };
|
|
1177
1137
|
}
|
|
1178
|
-
function
|
|
1138
|
+
function St(e) {
|
|
1179
1139
|
const t = [];
|
|
1180
1140
|
for (const r of e.template.pages) for (const n of r.components)
|
|
1181
1141
|
n.kind === "list" && (t.push(n.tree ? { ...n, rowKey: n.tree.idField } : n), n.detail && t.push({ ...n.detail, relation: { detail: n.detail, parentRows: e.datasets[n.dataset] ?? [] } }));
|
|
@@ -1184,34 +1144,34 @@ function xt(e) {
|
|
|
1184
1144
|
function B(e) {
|
|
1185
1145
|
return JSON.stringify([e.sourceScope, e.datasetId]);
|
|
1186
1146
|
}
|
|
1187
|
-
function
|
|
1147
|
+
function De(e) {
|
|
1188
1148
|
return JSON.stringify([e.sourceScope, e.datasetId, e.rowKey]);
|
|
1189
1149
|
}
|
|
1190
|
-
function
|
|
1150
|
+
function xt(e) {
|
|
1191
1151
|
const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
|
|
1192
1152
|
return e.forEach((n, o) => {
|
|
1193
|
-
for (const a of
|
|
1153
|
+
for (const a of St(n)) {
|
|
1194
1154
|
if (!a.rowKey) continue;
|
|
1195
1155
|
const s = a.relation, i = s ? new Set(s.parentRows.map((c) => JSON.stringify(c[s.detail.parentKey]))) : void 0;
|
|
1196
1156
|
(n.datasets[a.dataset] ?? []).forEach((c, l) => {
|
|
1197
1157
|
if (s && !i.has(JSON.stringify(c[s.detail.foreignKey]))) return;
|
|
1198
|
-
const
|
|
1199
|
-
if (typeof
|
|
1158
|
+
const u = c[a.rowKey];
|
|
1159
|
+
if (typeof u != "string" && typeof u != "number") return;
|
|
1200
1160
|
const f = `${o}:${a.dataset}:${l}:${a.rowKey}`;
|
|
1201
1161
|
if (r.has(f)) return;
|
|
1202
1162
|
r.add(f);
|
|
1203
|
-
const
|
|
1204
|
-
h.push({ partIndex: o, dataset: a.dataset, rowIndex: l, row: c, binding: a }), t.set(
|
|
1163
|
+
const d = De({ sourceScope: n.sourceScope, datasetId: a.dataset, rowKey: u }), h = t.get(d) ?? [];
|
|
1164
|
+
h.push({ partIndex: o, dataset: a.dataset, rowIndex: l, row: c, binding: a }), t.set(d, h);
|
|
1205
1165
|
});
|
|
1206
1166
|
}
|
|
1207
1167
|
}), (n) => {
|
|
1208
|
-
const o = t.get(
|
|
1168
|
+
const o = t.get(De(n));
|
|
1209
1169
|
if (!o?.length) throw new M("missing");
|
|
1210
1170
|
if (new Set(o.map((a) => `${a.partIndex}:${a.dataset}`)).size !== o.length) throw new M("conflict");
|
|
1211
1171
|
return o;
|
|
1212
1172
|
};
|
|
1213
1173
|
}
|
|
1214
|
-
function
|
|
1174
|
+
function Ct(e, t) {
|
|
1215
1175
|
const r = e.map((o) => ({ ...o, datasets: { ...o.datasets } })), n = /* @__PURE__ */ new Set();
|
|
1216
1176
|
for (const { row: o, field: a, value: s } of t) {
|
|
1217
1177
|
const i = r[o.partIndex], c = JSON.stringify([o.partIndex, o.dataset]);
|
|
@@ -1223,26 +1183,26 @@ function kt(e, t) {
|
|
|
1223
1183
|
}
|
|
1224
1184
|
return r;
|
|
1225
1185
|
}
|
|
1226
|
-
function
|
|
1186
|
+
function Sn(e, t, r) {
|
|
1227
1187
|
const n = [], o = /* @__PURE__ */ new Set();
|
|
1228
1188
|
return e.forEach((a, s) => {
|
|
1229
|
-
for (const i of
|
|
1189
|
+
for (const i of St(a))
|
|
1230
1190
|
t.has(B({ sourceScope: a.sourceScope, datasetId: i.dataset })) && (a.datasets[i.dataset] ?? []).forEach((c, l) => {
|
|
1231
|
-
const
|
|
1232
|
-
for (const [f,
|
|
1233
|
-
if (!f ||
|
|
1191
|
+
const u = { partIndex: s, dataset: i.dataset, rowIndex: l, row: c, binding: i };
|
|
1192
|
+
for (const [f, d] of [[i.revisionField, r.revision], [i.sourceTokenField, r.sourceToken]]) {
|
|
1193
|
+
if (!f || d === void 0) continue;
|
|
1234
1194
|
const h = `${s}:${i.dataset}:${l}:${f}`;
|
|
1235
|
-
o.has(h) || (o.add(h), n.push({ row:
|
|
1195
|
+
o.has(h) || (o.add(h), n.push({ row: u, field: f, value: d }));
|
|
1236
1196
|
}
|
|
1237
1197
|
});
|
|
1238
1198
|
}), n;
|
|
1239
1199
|
}
|
|
1240
|
-
function
|
|
1200
|
+
function xn(e, t, r) {
|
|
1241
1201
|
if (!r || r.revision === void 0 && r.sourceToken === void 0) return e;
|
|
1242
1202
|
const n = new Set(t.edits.flatMap((o) => o.source ? [B(o.source)] : []));
|
|
1243
|
-
return
|
|
1203
|
+
return kt(e, new Map([...n].map((o) => [o, r])));
|
|
1244
1204
|
}
|
|
1245
|
-
function
|
|
1205
|
+
function kt(e, t) {
|
|
1246
1206
|
if (!t.size) return e;
|
|
1247
1207
|
function r(a) {
|
|
1248
1208
|
const s = a.datasetId && t.get(B({ ...a, datasetId: a.datasetId }));
|
|
@@ -1250,14 +1210,14 @@ function Tt(e, t) {
|
|
|
1250
1210
|
}
|
|
1251
1211
|
function n(a) {
|
|
1252
1212
|
const s = a.map((i) => {
|
|
1253
|
-
const c = i.table?.source ? r(i.table.source) : void 0, l = i.table && c !== i.table.source ? { ...i.table, source: c } : i.table,
|
|
1254
|
-
const h =
|
|
1213
|
+
const c = i.table?.source ? r(i.table.source) : void 0, l = i.table && c !== i.table.source ? { ...i.table, source: c } : i.table, u = i.grid?.cells.map((d) => {
|
|
1214
|
+
const h = d.map((m) => {
|
|
1255
1215
|
if (!m) return m;
|
|
1256
|
-
const v = m.source ? r(m.source) : void 0,
|
|
1257
|
-
return v === m.source &&
|
|
1216
|
+
const v = m.source ? r(m.source) : void 0, p = m.children ? n(m.children) : void 0;
|
|
1217
|
+
return v === m.source && p === m.children ? m : { ...m, source: v, children: p };
|
|
1258
1218
|
});
|
|
1259
|
-
return h.some((m, v) => m !==
|
|
1260
|
-
}), f = i.grid &&
|
|
1219
|
+
return h.some((m, v) => m !== d[v]) ? h : d;
|
|
1220
|
+
}), f = i.grid && u?.some((d, h) => d !== i.grid.cells[h]) ? { ...i.grid, cells: u } : i.grid;
|
|
1261
1221
|
return l !== i.table || f !== i.grid ? { ...i, table: l, grid: f } : i;
|
|
1262
1222
|
});
|
|
1263
1223
|
return s.some((i, c) => i !== a[c]) ? s : a;
|
|
@@ -1268,33 +1228,33 @@ function Tt(e, t) {
|
|
|
1268
1228
|
});
|
|
1269
1229
|
return o.some((a, s) => a !== e.pages[s]) ? { ...e, pages: o } : e;
|
|
1270
1230
|
}
|
|
1271
|
-
function
|
|
1231
|
+
function Cn(e) {
|
|
1272
1232
|
return JSON.stringify([e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex]);
|
|
1273
1233
|
}
|
|
1274
|
-
function
|
|
1234
|
+
function Be(e) {
|
|
1275
1235
|
const t = e.table;
|
|
1276
|
-
return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) :
|
|
1236
|
+
return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) : Cn(e.address);
|
|
1277
1237
|
}
|
|
1278
|
-
function
|
|
1238
|
+
function kn(e, t) {
|
|
1279
1239
|
if (!t.length) return e;
|
|
1280
|
-
const r = new Map(t.map((c) => [
|
|
1281
|
-
function s(c, l,
|
|
1240
|
+
const r = new Map(t.map((c) => [Be(c), c])), n = new Set(t.flatMap((c) => c.table ? [c.table.id] : [])), o = new Set(t.map((c) => `${c.address.pageIndex}:${c.address.componentIndex}`)), a = D(e);
|
|
1241
|
+
function s(c, l, u) {
|
|
1282
1242
|
const f = c.grid;
|
|
1283
|
-
if (!f || !o.has(`${l}:${
|
|
1284
|
-
const
|
|
1285
|
-
for (const m of
|
|
1243
|
+
if (!f || !o.has(`${l}:${u}`) && !n.has(c.table?.id ?? "")) return c;
|
|
1244
|
+
const d = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
1245
|
+
for (const m of te(f, c.widthMm, c.heightMm).cells) {
|
|
1286
1246
|
const v = h.get(m.ri) ?? 0;
|
|
1287
1247
|
h.set(m.ri, v + 1);
|
|
1288
|
-
const
|
|
1289
|
-
if (!
|
|
1290
|
-
const
|
|
1291
|
-
Object.is(
|
|
1248
|
+
const p = a({ pageIndex: l, componentIndex: u, rowIndex: m.ri, columnIndex: m.ci }), w = p && r.get(Be(p));
|
|
1249
|
+
if (!w || !p.editable) continue;
|
|
1250
|
+
const y = d.get(m.ri) ?? [...f.cells[m.ri]], x = q(p, w.value);
|
|
1251
|
+
Object.is(p.value, w.value) && x === p.cell.text || (y[v] = { ...m.cell, value: w.value, text: x, rawText: x }, d.set(m.ri, y));
|
|
1292
1252
|
}
|
|
1293
|
-
return
|
|
1253
|
+
return d.size ? { ...c, grid: { ...f, cells: f.cells.map((m, v) => d.get(v) ?? m) } } : c;
|
|
1294
1254
|
}
|
|
1295
1255
|
const i = e.pages.map((c, l) => {
|
|
1296
|
-
const
|
|
1297
|
-
return
|
|
1256
|
+
const u = c.components.map((f, d) => s(f, l, d));
|
|
1257
|
+
return u.every((f, d) => f === c.components[d]) ? c : { ...c, components: u };
|
|
1298
1258
|
});
|
|
1299
1259
|
return i.every((c, l) => c === e.pages[l]) ? e : { ...e, pages: i };
|
|
1300
1260
|
}
|
|
@@ -1306,19 +1266,19 @@ function F(e) {
|
|
|
1306
1266
|
const n = e.address;
|
|
1307
1267
|
return JSON.stringify([n.pageIndex, n.componentIndex, n.rowIndex, n.columnIndex]);
|
|
1308
1268
|
}
|
|
1309
|
-
function
|
|
1269
|
+
function po(e, t, r) {
|
|
1310
1270
|
if (typeof r != "string" || !r.trim() || !Array.isArray(t)) throw new M("missing");
|
|
1311
1271
|
if (t.length > 1e4) throw new M("limit");
|
|
1312
1272
|
const n = /* @__PURE__ */ new Set(), o = D(e), a = t.map(({ address: s, value: i }) => {
|
|
1313
1273
|
const c = o(s);
|
|
1314
1274
|
if (!c) throw new M("missing");
|
|
1315
|
-
const l = U(c, i),
|
|
1316
|
-
if (n.has(
|
|
1317
|
-
return n.add(
|
|
1275
|
+
const l = U(c, i), u = F(l);
|
|
1276
|
+
if (n.has(u)) throw new M("duplicate");
|
|
1277
|
+
return n.add(u), l;
|
|
1318
1278
|
});
|
|
1319
1279
|
return { requestId: r, edits: a };
|
|
1320
1280
|
}
|
|
1321
|
-
function
|
|
1281
|
+
function wo(e, t) {
|
|
1322
1282
|
if (t.edits.length > 1e4) throw new M("limit");
|
|
1323
1283
|
const r = D(e), n = /* @__PURE__ */ new Set(), o = t.edits.map((a) => {
|
|
1324
1284
|
const s = r(a.address);
|
|
@@ -1328,9 +1288,9 @@ function vo(e, t) {
|
|
|
1328
1288
|
if (n.add(i), Ie(s, a) || !Object.is(s.value, a.previousValue) || (s.cell.text ?? "") !== a.previousText) throw new M("conflict");
|
|
1329
1289
|
return U(s, a.value);
|
|
1330
1290
|
});
|
|
1331
|
-
return
|
|
1291
|
+
return kn(e, o);
|
|
1332
1292
|
}
|
|
1333
|
-
function
|
|
1293
|
+
function yo(e) {
|
|
1334
1294
|
const t = /* @__PURE__ */ new Map();
|
|
1335
1295
|
for (const r of e) {
|
|
1336
1296
|
const n = F(r), o = t.get(n), a = o ? { ...r, previousValue: o.previousValue, previousText: o.previousText } : { ...r };
|
|
@@ -1338,7 +1298,7 @@ function Mo(e) {
|
|
|
1338
1298
|
}
|
|
1339
1299
|
return [...t.values()];
|
|
1340
1300
|
}
|
|
1341
|
-
function
|
|
1301
|
+
function Tt(e) {
|
|
1342
1302
|
const t = /* @__PURE__ */ new Map(), r = D(e);
|
|
1343
1303
|
return e.pages.forEach((n, o) => n.components.forEach((a, s) => {
|
|
1344
1304
|
if (!(!a.grid || a.table?.role !== "body"))
|
|
@@ -1348,23 +1308,23 @@ function Pt(e) {
|
|
|
1348
1308
|
}
|
|
1349
1309
|
})), t;
|
|
1350
1310
|
}
|
|
1351
|
-
function
|
|
1352
|
-
const n =
|
|
1311
|
+
function bo(e, t, r) {
|
|
1312
|
+
const n = Tt(e), o = D(e);
|
|
1353
1313
|
return t.map((a) => {
|
|
1354
1314
|
const s = a.source ? n.get(F(a)) : o(a.address);
|
|
1355
1315
|
if (!s || F(s) !== F(a)) throw new M("missing");
|
|
1356
1316
|
return { address: { ...s.address }, value: a[r] };
|
|
1357
1317
|
});
|
|
1358
1318
|
}
|
|
1359
|
-
function
|
|
1319
|
+
function Pt(e, t) {
|
|
1360
1320
|
if (++e.nodes > 1e6 || t > 128) throw new M("limit");
|
|
1361
1321
|
}
|
|
1362
|
-
function
|
|
1322
|
+
function Z(e, t) {
|
|
1363
1323
|
const r = Object.getOwnPropertyDescriptor(e, t);
|
|
1364
1324
|
if (!r || r.get || r.set) throw new M("conflict");
|
|
1365
1325
|
return r.value;
|
|
1366
1326
|
}
|
|
1367
|
-
function
|
|
1327
|
+
function $e(e) {
|
|
1368
1328
|
if (Object.getOwnPropertyDescriptor(e, "toJSON")) throw new M("conflict");
|
|
1369
1329
|
const t = Object.getPrototypeOf(e);
|
|
1370
1330
|
if (Array.isArray(e) && (t !== Array.prototype || Object.keys(e).length !== e.length)) throw new M("conflict");
|
|
@@ -1375,12 +1335,12 @@ function Fe(e) {
|
|
|
1375
1335
|
if (e instanceof Date || Array.isArray(e) && !/^(0|[1-9]\d*)$/.test(r)) throw new M("conflict");
|
|
1376
1336
|
}
|
|
1377
1337
|
}
|
|
1378
|
-
function
|
|
1379
|
-
if (
|
|
1338
|
+
function Et(e, t, r, n, o) {
|
|
1339
|
+
if (Pt(n, o), typeof e == "function" || typeof e == "symbol") throw new M("conflict");
|
|
1380
1340
|
if (e === null || typeof e != "object") return;
|
|
1381
|
-
if (
|
|
1341
|
+
if ($e(e), r.has(e)) throw new M("conflict");
|
|
1382
1342
|
r.add(e);
|
|
1383
|
-
const a = Object.keys(e), s = a.map((i) =>
|
|
1343
|
+
const a = Object.keys(e), s = a.map((i) => Z(e, i));
|
|
1384
1344
|
t.push({
|
|
1385
1345
|
object: e,
|
|
1386
1346
|
prototype: Object.getPrototypeOf(e),
|
|
@@ -1389,56 +1349,56 @@ function Rt(e, t, r, n, o) {
|
|
|
1389
1349
|
...e instanceof Date ? { date: Date.prototype.getTime.call(e) } : {},
|
|
1390
1350
|
...Array.isArray(e) ? { length: e.length } : {}
|
|
1391
1351
|
});
|
|
1392
|
-
for (const i of s)
|
|
1352
|
+
for (const i of s) Et(i, t, r, n, o + 1);
|
|
1393
1353
|
r.delete(e);
|
|
1394
1354
|
}
|
|
1395
|
-
function
|
|
1355
|
+
function Tn(e) {
|
|
1396
1356
|
const { object: t, keys: r, values: n } = e;
|
|
1397
|
-
if (
|
|
1357
|
+
if ($e(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;
|
|
1398
1358
|
const o = Object.keys(t);
|
|
1399
|
-
return o.length === r.length && r.every((a, s) => o[s] === a && Object.is(
|
|
1359
|
+
return o.length === r.length && r.every((a, s) => o[s] === a && Object.is(Z(t, a), n[s]));
|
|
1400
1360
|
}
|
|
1401
|
-
function
|
|
1361
|
+
function Pn(e) {
|
|
1402
1362
|
const t = [];
|
|
1403
|
-
return
|
|
1363
|
+
return Et(e, t, /* @__PURE__ */ new Set(), { nodes: 0 }, 0), () => {
|
|
1404
1364
|
try {
|
|
1405
|
-
return t.every(
|
|
1365
|
+
return t.every(Tn);
|
|
1406
1366
|
} catch {
|
|
1407
1367
|
return !1;
|
|
1408
1368
|
}
|
|
1409
1369
|
};
|
|
1410
1370
|
}
|
|
1411
|
-
function
|
|
1412
|
-
if (
|
|
1371
|
+
function ee(e, t, r, n = !1) {
|
|
1372
|
+
if (Pt(t, r), n) {
|
|
1413
1373
|
if (typeof e == "function" || typeof e == "symbol") throw new M("conflict");
|
|
1414
|
-
e !== null && typeof e == "object" &&
|
|
1374
|
+
e !== null && typeof e == "object" && $e(e);
|
|
1415
1375
|
}
|
|
1416
1376
|
if (e === null || typeof e != "object") return e;
|
|
1417
1377
|
if (e instanceof Date) return new Date(Date.prototype.getTime.call(e));
|
|
1418
1378
|
if (Array.isArray(e)) {
|
|
1419
1379
|
const o = [];
|
|
1420
|
-
for (let a = 0; a < e.length; a++) o[a] =
|
|
1380
|
+
for (let a = 0; a < e.length; a++) o[a] = ee(Z(e, String(a)), t, r + 1, n);
|
|
1421
1381
|
return o;
|
|
1422
1382
|
}
|
|
1423
|
-
return Object.fromEntries(Object.keys(e).map((o) => [o,
|
|
1383
|
+
return Object.fromEntries(Object.keys(e).map((o) => [o, ee(Z(e, o), t, r + 1, n)]));
|
|
1424
1384
|
}
|
|
1425
|
-
function
|
|
1426
|
-
return
|
|
1385
|
+
function En(e) {
|
|
1386
|
+
return ee(e, { nodes: 0 }, 0, !0);
|
|
1427
1387
|
}
|
|
1428
|
-
function
|
|
1429
|
-
const t =
|
|
1430
|
-
for (const r of t) for (const n of Object.values(r.datasets))
|
|
1388
|
+
function Rn(e) {
|
|
1389
|
+
const t = ee(e, { nodes: 0 }, 0);
|
|
1390
|
+
for (const r of t) for (const n of Object.values(r.datasets)) Jt(n);
|
|
1431
1391
|
return t;
|
|
1432
1392
|
}
|
|
1433
|
-
async function
|
|
1434
|
-
return (await
|
|
1393
|
+
async function In(e, t, r = {}) {
|
|
1394
|
+
return (await Rt(e, t, r)).plan;
|
|
1435
1395
|
}
|
|
1436
|
-
async function
|
|
1437
|
-
return
|
|
1396
|
+
async function Rt(e, t, r = {}) {
|
|
1397
|
+
return mt(e, t, { ...r, knownTotalPages: void 0 });
|
|
1438
1398
|
}
|
|
1439
|
-
const
|
|
1440
|
-
function
|
|
1441
|
-
return
|
|
1399
|
+
const he = /* @__PURE__ */ new WeakMap();
|
|
1400
|
+
function vo(e) {
|
|
1401
|
+
return he.get(e);
|
|
1442
1402
|
}
|
|
1443
1403
|
function X(e) {
|
|
1444
1404
|
if (e?.aborted) {
|
|
@@ -1449,7 +1409,7 @@ function X(e) {
|
|
|
1449
1409
|
function It(e, t) {
|
|
1450
1410
|
return e[t] === void 0 ? "" : e[t];
|
|
1451
1411
|
}
|
|
1452
|
-
function
|
|
1412
|
+
function $n(e, t) {
|
|
1453
1413
|
if (t.edits.length > 1e4) throw new M("limit");
|
|
1454
1414
|
const r = D(e), n = /* @__PURE__ */ new Set(), o = [], a = t.edits.map((s) => {
|
|
1455
1415
|
const i = r(s.address);
|
|
@@ -1461,8 +1421,8 @@ function Nn(e, t) {
|
|
|
1461
1421
|
});
|
|
1462
1422
|
return { batch: { requestId: t.requestId, edits: a }, contexts: o };
|
|
1463
1423
|
}
|
|
1464
|
-
function
|
|
1465
|
-
const r =
|
|
1424
|
+
function Fn(e, t) {
|
|
1425
|
+
const r = xt(e);
|
|
1466
1426
|
return t.flatMap((n) => {
|
|
1467
1427
|
if (!n.source) throw new M("missing");
|
|
1468
1428
|
return r(n.source).map((o) => {
|
|
@@ -1472,16 +1432,16 @@ function jn(e, t) {
|
|
|
1472
1432
|
});
|
|
1473
1433
|
});
|
|
1474
1434
|
}
|
|
1475
|
-
function
|
|
1435
|
+
function de(e, t, r) {
|
|
1476
1436
|
const n = { ...e, value: t, source: { ...e.source, ...r?.revision === void 0 ? {} : { revision: r.revision }, ...r?.sourceToken === void 0 ? {} : { sourceToken: r.sourceToken } } };
|
|
1477
1437
|
return n.cell = { ...e.cell, value: n.value, text: q(n, n.value) }, n;
|
|
1478
1438
|
}
|
|
1479
|
-
function
|
|
1439
|
+
function On(e, t, r) {
|
|
1480
1440
|
if (!r || r.revision === void 0 && r.sourceToken === void 0) return [...e];
|
|
1481
1441
|
const n = new Set(t.edits.flatMap((o) => o.source ? [B(o.source)] : []));
|
|
1482
|
-
return
|
|
1442
|
+
return Ct(e, Sn(e, n, r));
|
|
1483
1443
|
}
|
|
1484
|
-
function
|
|
1444
|
+
function An(e, t, r) {
|
|
1485
1445
|
const n = new Set(t.edits.map((o) => B(o.source)));
|
|
1486
1446
|
for (const o of n) e.set(o, {
|
|
1487
1447
|
...e.get(o),
|
|
@@ -1490,74 +1450,74 @@ function Ln(e, t, r) {
|
|
|
1490
1450
|
});
|
|
1491
1451
|
return n;
|
|
1492
1452
|
}
|
|
1493
|
-
function
|
|
1453
|
+
function $t(e, t) {
|
|
1494
1454
|
let r = t.parts;
|
|
1495
1455
|
const n = t.rebuild, o = [...t.validationFormulas ?? []];
|
|
1496
|
-
let a =
|
|
1456
|
+
let a = Pn(r), s = e, i;
|
|
1497
1457
|
const c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
1498
|
-
function
|
|
1458
|
+
function u(h) {
|
|
1499
1459
|
if (h !== s) throw new M("conflict");
|
|
1500
1460
|
if (i) return i;
|
|
1501
1461
|
if (!a?.()) throw new M("conflict");
|
|
1502
|
-
return
|
|
1503
|
-
}
|
|
1504
|
-
async function f(h, m, v,
|
|
1505
|
-
X(
|
|
1506
|
-
const
|
|
1507
|
-
X(
|
|
1508
|
-
let
|
|
1509
|
-
function
|
|
1510
|
-
return A = !0,
|
|
1462
|
+
return Rn(r);
|
|
1463
|
+
}
|
|
1464
|
+
async function f(h, m, v, p = {}) {
|
|
1465
|
+
X(p.signal), m = { requestId: m.requestId, edits: m.edits.map((b) => ({ ...b, address: { ...b.address }, source: b.source ? { ...b.source } : void 0, table: b.table ? { ...b.table } : void 0 })) }, v = v.map((b) => ({ ...b, address: { ...b.address }, source: b.source ? { ...b.source } : void 0, table: b.table ? { ...b.table } : void 0, cell: { ...b.cell } })), await new Promise((b) => setTimeout(b, 0)), X(p.signal);
|
|
1466
|
+
const w = u(h), y = Ct(w, Fn(w, m.edits)), x = kt(await n(y, p.signal), l);
|
|
1467
|
+
X(p.signal);
|
|
1468
|
+
let k = !1, T = [], O = "allow", A = !1;
|
|
1469
|
+
function g(b) {
|
|
1470
|
+
return A = !0, T = Object.freeze(cn(y, b, p.signal, o).map((S) => Object.freeze({ ...S }))), A = !1, O = b.warningPolicy ?? "allow", T;
|
|
1511
1471
|
}
|
|
1512
|
-
return
|
|
1513
|
-
return
|
|
1514
|
-
}, validate:
|
|
1515
|
-
if (X(
|
|
1472
|
+
return p.validation && g(p.validation), { plan: x, get validationIssues() {
|
|
1473
|
+
return T;
|
|
1474
|
+
}, validate: g, commit(b) {
|
|
1475
|
+
if (X(p.signal), k || s !== h) throw new M("conflict");
|
|
1516
1476
|
if (b?.conflicts?.length) throw new M("conflict");
|
|
1517
1477
|
if (A) throw new Error("候选规则校验未完成,不能提交");
|
|
1518
|
-
|
|
1519
|
-
const S =
|
|
1478
|
+
sn(T, O);
|
|
1479
|
+
const S = On(y, m, b), E = xn(x, m, b);
|
|
1520
1480
|
if (b) {
|
|
1521
|
-
const
|
|
1522
|
-
for (const [R, L] of c)
|
|
1481
|
+
const P = An(l, m, b);
|
|
1482
|
+
for (const [R, L] of c) P.has(B(L.source)) && c.set(R, de(L, L.value, b));
|
|
1523
1483
|
}
|
|
1524
|
-
return v.forEach((
|
|
1484
|
+
return v.forEach((P, R) => c.set(F(P), de(P, m.edits[R].value, b))), k = !0, i = S, r = void 0, a = void 0, s = E, he.set(s, d), s;
|
|
1525
1485
|
} };
|
|
1526
1486
|
}
|
|
1527
|
-
const
|
|
1487
|
+
const d = {
|
|
1528
1488
|
get plan() {
|
|
1529
1489
|
return s;
|
|
1530
1490
|
},
|
|
1531
1491
|
async prepare(h, m, v) {
|
|
1532
|
-
const
|
|
1533
|
-
return f(h,
|
|
1492
|
+
const p = $n(h, m);
|
|
1493
|
+
return f(h, p.batch, p.contexts, v);
|
|
1534
1494
|
},
|
|
1535
|
-
async prepareHistory(h, m, v,
|
|
1536
|
-
if (!
|
|
1537
|
-
const
|
|
1495
|
+
async prepareHistory(h, m, v, p, w) {
|
|
1496
|
+
if (!p.trim() || m.length > 1e4) throw new M("limit");
|
|
1497
|
+
const y = u(h), x = xt(y), k = Tt(h), T = /* @__PURE__ */ new Set(), A = m.map((S) => {
|
|
1538
1498
|
if (!S.source) throw new M("missing");
|
|
1539
|
-
const
|
|
1540
|
-
if (
|
|
1541
|
-
|
|
1542
|
-
const
|
|
1543
|
-
if (!
|
|
1544
|
-
const R = x(
|
|
1545
|
-
return
|
|
1546
|
-
}).map((S,
|
|
1547
|
-
return { batch:
|
|
1499
|
+
const E = F(S);
|
|
1500
|
+
if (T.has(E)) throw new M("duplicate");
|
|
1501
|
+
T.add(E);
|
|
1502
|
+
const P = k.get(E) ?? c.get(E);
|
|
1503
|
+
if (!P?.source) throw new M("missing");
|
|
1504
|
+
const R = x(P.source)[0];
|
|
1505
|
+
return de(P, It(R.row, P.source.field));
|
|
1506
|
+
}).map((S, E) => ({ context: S, edit: U(S, m[E][v]) })).filter(({ edit: S }) => !Object.is(S.previousValue, S.value)), g = { requestId: p, edits: A.map(({ edit: S }) => S) }, b = A.map(({ context: S }) => S);
|
|
1507
|
+
return { batch: g, contexts: b, prepared: await f(h, g, b, w) };
|
|
1548
1508
|
}
|
|
1549
1509
|
};
|
|
1550
|
-
return
|
|
1510
|
+
return he.set(e, d), d;
|
|
1551
1511
|
}
|
|
1552
|
-
function
|
|
1553
|
-
const t =
|
|
1554
|
-
return
|
|
1512
|
+
function Mo(e) {
|
|
1513
|
+
const t = ft(e.template, e.datasets, e.pagination).plan;
|
|
1514
|
+
return $t(t, { validationFormulas: [e.pagination?.formula], parts: [{ template: e.template, datasets: e.datasets }], rebuild: (r, n) => In(r[0].template, r[0].datasets, { ...e.pagination, signal: n }) });
|
|
1555
1515
|
}
|
|
1556
|
-
let
|
|
1557
|
-
function
|
|
1558
|
-
return `report-${Date.now()}-${++
|
|
1516
|
+
let Kn = 0;
|
|
1517
|
+
function jn() {
|
|
1518
|
+
return `report-${Date.now()}-${++Kn}`;
|
|
1559
1519
|
}
|
|
1560
|
-
function
|
|
1520
|
+
function Ge(e, t, r) {
|
|
1561
1521
|
if (!r?.aborted)
|
|
1562
1522
|
try {
|
|
1563
1523
|
const n = e?.({ ...t });
|
|
@@ -1566,14 +1526,14 @@ function We(e, t, r) {
|
|
|
1566
1526
|
} catch {
|
|
1567
1527
|
}
|
|
1568
1528
|
}
|
|
1569
|
-
function
|
|
1570
|
-
const t = e.taskId ??
|
|
1571
|
-
|
|
1529
|
+
function Nn(e) {
|
|
1530
|
+
const t = e.taskId ?? jn(), r = (n, o, a) => {
|
|
1531
|
+
Ge(e.onEvent, { taskId: t, ...e.correlationId === void 0 ? {} : { correlationId: e.correlationId }, stage: n, status: o, ...a === void 0 ? {} : { reportId: a } }, e.signal);
|
|
1572
1532
|
};
|
|
1573
1533
|
return {
|
|
1574
1534
|
taskId: t,
|
|
1575
1535
|
progress(n, o, a) {
|
|
1576
|
-
|
|
1536
|
+
Ge(e.onEvent, { taskId: t, ...e.correlationId === void 0 ? {} : { correlationId: e.correlationId }, stage: n, status: "started", completed: o, total: a }, e.signal);
|
|
1577
1537
|
},
|
|
1578
1538
|
async run(n, o, a) {
|
|
1579
1539
|
r(n, "started", a);
|
|
@@ -1595,25 +1555,25 @@ function Bn(e) {
|
|
|
1595
1555
|
}
|
|
1596
1556
|
};
|
|
1597
1557
|
}
|
|
1598
|
-
function
|
|
1558
|
+
function Ft(e) {
|
|
1599
1559
|
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
1600
1560
|
const t = e, r = (n) => typeof n == "string" && n.trim().length > 0 && n.length <= 256;
|
|
1601
1561
|
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);
|
|
1602
1562
|
}
|
|
1603
|
-
function
|
|
1563
|
+
function Ln(e) {
|
|
1604
1564
|
return e === "missing-source" || e === "not-applicable" || e === "not-calculable";
|
|
1605
1565
|
}
|
|
1606
|
-
function
|
|
1607
|
-
return e.target !== void 0 && !
|
|
1566
|
+
function Hn(e) {
|
|
1567
|
+
return e.target !== void 0 && !Ft(e.target) ? !1 : e.valueState === void 0 || Ln(e.valueState) && e.target !== void 0;
|
|
1608
1568
|
}
|
|
1609
|
-
function
|
|
1610
|
-
if (
|
|
1569
|
+
function So(e, t) {
|
|
1570
|
+
if (Ze([], e), !Ft(t)) throw new Error("数据说明目标无效");
|
|
1611
1571
|
const r = e.fields.find((o) => o.field === t.field);
|
|
1612
1572
|
if (!r) throw new Error("数据说明字段未在契约中声明");
|
|
1613
1573
|
const n = [];
|
|
1614
1574
|
return r.description && n.push({ code: "field-definition", severity: "info", message: r.description, target: { ...t } }), r.calculation && n.push({ code: "field-calculation", severity: "info", message: r.calculation.description, target: { ...t } }), n;
|
|
1615
1575
|
}
|
|
1616
|
-
function
|
|
1576
|
+
function Ot(e, t, r = {}) {
|
|
1617
1577
|
const n = /* @__PURE__ */ new Map();
|
|
1618
1578
|
for (const a of e.pages) for (const s of a.components) {
|
|
1619
1579
|
if (s.kind !== "list" || s.tree?.input !== "nested") continue;
|
|
@@ -1625,26 +1585,26 @@ function At(e, t, r = {}) {
|
|
|
1625
1585
|
const o = { ...t };
|
|
1626
1586
|
for (const [a, s] of n) {
|
|
1627
1587
|
const i = Math.min(s.maxRows ?? 1e5, r.maxRows ?? 1 / 0);
|
|
1628
|
-
o[a] =
|
|
1588
|
+
o[a] = Xe(t[a] ?? [], { ...s, maxRows: i }, r.signal);
|
|
1629
1589
|
}
|
|
1630
1590
|
return o;
|
|
1631
1591
|
}
|
|
1632
|
-
function
|
|
1633
|
-
return Object.values(
|
|
1592
|
+
function xo(e, t, r = {}) {
|
|
1593
|
+
return Object.values(Ot(e, t, r)).reduce((n, o) => n + o.length, 0);
|
|
1634
1594
|
}
|
|
1635
|
-
function
|
|
1636
|
-
const n =
|
|
1595
|
+
function Co(e, t, r) {
|
|
1596
|
+
const n = ur(r), o = e?.pages.flatMap((i) => i.components).find((i) => i.kind === "list" && i.dataset === t && i.tree?.input === "nested");
|
|
1637
1597
|
if (!o || o.kind !== "list" || !o.tree) return n;
|
|
1638
1598
|
const a = n.items, s = o.tree.childrenField ?? "children";
|
|
1639
1599
|
return { ...n, items: { $ref: "#/$defs/treeNode" }, $defs: { treeNode: { ...a, properties: { ...a.properties, [s]: { anyOf: [{ type: "null" }, { type: "array", items: { $ref: "#/$defs/treeNode" } }] } } } } };
|
|
1640
1600
|
}
|
|
1641
|
-
function
|
|
1601
|
+
function At(e, t) {
|
|
1642
1602
|
return JSON.stringify([e, t]);
|
|
1643
1603
|
}
|
|
1644
|
-
function jt(e, t, r) {
|
|
1645
|
-
return r === void 0 ? Nt(e, t) : JSON.stringify(["shared", r]);
|
|
1646
|
-
}
|
|
1647
1604
|
function Kt(e, t, r) {
|
|
1605
|
+
return r === void 0 ? At(e, t) : JSON.stringify(["shared", r]);
|
|
1606
|
+
}
|
|
1607
|
+
function jt(e, t, r) {
|
|
1648
1608
|
return e.map((n) => {
|
|
1649
1609
|
const o = n.table ? {
|
|
1650
1610
|
...n.table,
|
|
@@ -1653,7 +1613,7 @@ function Kt(e, t, r) {
|
|
|
1653
1613
|
} : void 0, a = n.grid?.cells.map((s) => s.map((i) => !i || !i.source && !i.children ? i : {
|
|
1654
1614
|
...i,
|
|
1655
1615
|
...i.source ? { source: { ...i.source, sourceScope: t } } : {},
|
|
1656
|
-
...i.children ? { children:
|
|
1616
|
+
...i.children ? { children: jt(i.children, t, r) } : {}
|
|
1657
1617
|
}));
|
|
1658
1618
|
return o || a ? {
|
|
1659
1619
|
...n,
|
|
@@ -1662,51 +1622,51 @@ function Kt(e, t, r) {
|
|
|
1662
1622
|
} : n;
|
|
1663
1623
|
});
|
|
1664
1624
|
}
|
|
1665
|
-
function
|
|
1666
|
-
return
|
|
1625
|
+
function ge(e) {
|
|
1626
|
+
return Se(e.maxChartComponents), { maxPages: e.maxPages, maxCells: e.maxCells, maxChartComponents: e.maxChartComponents ?? Qt, usedPages: 0, usedCells: 0, usedChartComponents: 0 };
|
|
1667
1627
|
}
|
|
1668
|
-
function
|
|
1628
|
+
function Dn(e, t) {
|
|
1669
1629
|
if (!e.repeat) return !1;
|
|
1670
1630
|
const r = Object.prototype.hasOwnProperty.call(t, e.repeat.dataset) ? t[e.repeat.dataset] : void 0;
|
|
1671
1631
|
return Array.isArray(r) && r.length === 0;
|
|
1672
1632
|
}
|
|
1673
|
-
function
|
|
1633
|
+
function Bn(e) {
|
|
1674
1634
|
const t = (r) => r.grid?.cells.reduce((n, o) => n + o.reduce((a, s) => a + (s ? 1 + (s.children?.reduce((i, c) => i + t(c), 0) ?? 0) : 0), 0), 0) ?? 0;
|
|
1675
1635
|
return e.pages.reduce((r, n) => r + n.components.reduce((o, a) => o + t(a), 0), 0);
|
|
1676
1636
|
}
|
|
1677
|
-
function
|
|
1637
|
+
function pe(e, t) {
|
|
1678
1638
|
return e === void 0 ? void 0 : e - t;
|
|
1679
1639
|
}
|
|
1680
|
-
function
|
|
1640
|
+
function ue(e, t) {
|
|
1681
1641
|
return e === void 0 ? t : Math.max(1, Math.min(e, t ?? e));
|
|
1682
1642
|
}
|
|
1683
|
-
function
|
|
1684
|
-
|
|
1685
|
-
const a =
|
|
1686
|
-
if (a !== void 0 && a < 1 && r.pages.length && !
|
|
1687
|
-
if (s < 1 && r.pages.some((i) => i.components.some((c) => c.kind !== "list" && c.chartBinding))) throw new
|
|
1643
|
+
function Nt(e, t, r, n, o) {
|
|
1644
|
+
Se(e?.maxChartComponents);
|
|
1645
|
+
const a = pe(t.maxPages, t.usedPages), s = t.maxChartComponents - t.usedChartComponents;
|
|
1646
|
+
if (a !== void 0 && a < 1 && r.pages.length && !Dn(r, n)) throw new W(0, 1);
|
|
1647
|
+
if (s < 1 && r.pages.some((i) => i.components.some((c) => c.kind !== "list" && c.chartBinding))) throw new fe(s, 1);
|
|
1688
1648
|
return {
|
|
1689
1649
|
...e,
|
|
1690
1650
|
signal: o ?? e?.signal,
|
|
1691
|
-
maxPages:
|
|
1692
|
-
maxCells:
|
|
1693
|
-
maxChartComponents:
|
|
1651
|
+
maxPages: ue(a, e?.maxPages),
|
|
1652
|
+
maxCells: ue(pe(t.maxCells, t.usedCells), e?.maxCells),
|
|
1653
|
+
maxChartComponents: ue(s, e?.maxChartComponents)
|
|
1694
1654
|
};
|
|
1695
1655
|
}
|
|
1696
|
-
function
|
|
1697
|
-
const r =
|
|
1656
|
+
function Lt(e, t) {
|
|
1657
|
+
const r = Bn(t.plan), n = pe(e.maxCells, e.usedCells);
|
|
1698
1658
|
if (n !== void 0 && r > n) throw new Y(n, r);
|
|
1699
1659
|
e.usedPages += t.plan.pages.length, e.usedCells += r, e.usedChartComponents += t.chartComponents;
|
|
1700
1660
|
}
|
|
1701
|
-
function
|
|
1702
|
-
return e instanceof W && t.maxPages !== void 0 && (e.limit === t.maxPages - t.usedPages || e.limit === 0) ? new W(t.maxPages, t.usedPages + e.actual) : e instanceof Y && t.maxCells !== void 0 ? new Y(t.maxCells, t.usedCells + e.actual) : e instanceof
|
|
1661
|
+
function Ht(e, t) {
|
|
1662
|
+
return e instanceof W && t.maxPages !== void 0 && (e.limit === t.maxPages - t.usedPages || e.limit === 0) ? new W(t.maxPages, t.usedPages + e.actual) : e instanceof Y && t.maxCells !== void 0 ? new Y(t.maxCells, t.usedCells + e.actual) : e instanceof fe && e.limit === t.maxChartComponents - t.usedChartComponents ? new fe(t.maxChartComponents, t.usedChartComponents + e.estimated) : e;
|
|
1703
1663
|
}
|
|
1704
|
-
function
|
|
1664
|
+
function ko(e) {
|
|
1705
1665
|
if (!("mapData" in e)) return e;
|
|
1706
1666
|
const { load: t, mapData: r, ...n } = e;
|
|
1707
1667
|
return { ...n, load: async (o) => {
|
|
1708
1668
|
const a = await t(o);
|
|
1709
|
-
|
|
1669
|
+
I(o.signal);
|
|
1710
1670
|
try {
|
|
1711
1671
|
return r(a, o);
|
|
1712
1672
|
} catch (s) {
|
|
@@ -1719,17 +1679,17 @@ class C extends Error {
|
|
|
1719
1679
|
super(r), this.name = "ReportSourceError", this.code = t, this.cause = n;
|
|
1720
1680
|
}
|
|
1721
1681
|
}
|
|
1722
|
-
function
|
|
1682
|
+
function ce(e) {
|
|
1723
1683
|
const t = new Error("报表加载已取消");
|
|
1724
1684
|
return t.name = "AbortError", Object.defineProperty(t, "cause", { value: e.reason }), t;
|
|
1725
1685
|
}
|
|
1726
|
-
function
|
|
1727
|
-
if (e?.aborted) throw
|
|
1686
|
+
function I(e) {
|
|
1687
|
+
if (e?.aborted) throw ce(e);
|
|
1728
1688
|
}
|
|
1729
|
-
function
|
|
1689
|
+
function we(e, t) {
|
|
1730
1690
|
return t ? new Promise((r, n) => {
|
|
1731
1691
|
const o = () => t.removeEventListener("abort", a), a = () => {
|
|
1732
|
-
o(), n(
|
|
1692
|
+
o(), n(ce(t));
|
|
1733
1693
|
};
|
|
1734
1694
|
t.addEventListener("abort", a, { once: !0 }), t.aborted && a(), Promise.resolve(e).then(
|
|
1735
1695
|
(s) => {
|
|
@@ -1741,111 +1701,111 @@ function ye(e, t) {
|
|
|
1741
1701
|
);
|
|
1742
1702
|
}) : Promise.resolve(e);
|
|
1743
1703
|
}
|
|
1744
|
-
function
|
|
1704
|
+
function Gn(e, t) {
|
|
1745
1705
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
1746
1706
|
throw new C("validate", `报表 ${t} 的数据集应为对象`);
|
|
1747
1707
|
for (const [r, n] of Object.entries(e))
|
|
1748
1708
|
if (!Array.isArray(n) || n.some((o) => !o || typeof o != "object" || Array.isArray(o)))
|
|
1749
1709
|
throw new C("validate", `报表 ${t} 的数据集 ${r} 应为对象数组`);
|
|
1750
1710
|
}
|
|
1751
|
-
async function
|
|
1711
|
+
async function Wn(e, t, r) {
|
|
1752
1712
|
const { reportId: n, signal: o } = t;
|
|
1753
1713
|
try {
|
|
1754
|
-
const a = await
|
|
1755
|
-
|
|
1756
|
-
const s =
|
|
1714
|
+
const a = await we(e(t), o);
|
|
1715
|
+
I(o);
|
|
1716
|
+
const s = sr(a);
|
|
1757
1717
|
if (!s.ok)
|
|
1758
1718
|
throw new C("validate", `报表 ${n} 模板校验失败:${s.errors.slice(0, 3).map((i) => `${i.path}: ${i.message}`).join("; ")}`);
|
|
1759
1719
|
return r.push(...s.warnings.map((i) => `${n}: ${i.path}: ${i.message}`)), a;
|
|
1760
1720
|
} catch (a) {
|
|
1761
|
-
throw o?.aborted ?
|
|
1721
|
+
throw o?.aborted ? ce(o) : a instanceof C ? a : a instanceof ir ? new C("validate", `报表 ${n} 模板校验失败:${a.message}`, a) : new C("fetch", `报表 ${n} 模板加载失败:${a instanceof Error ? a.message : String(a)}`, a);
|
|
1762
1722
|
}
|
|
1763
1723
|
}
|
|
1764
|
-
async function
|
|
1724
|
+
async function Vn(e, t, r, n) {
|
|
1765
1725
|
const o = t.signal;
|
|
1766
1726
|
let a;
|
|
1767
1727
|
try {
|
|
1768
|
-
if (e.load) a = await
|
|
1728
|
+
if (e.load) a = await we(e.load(t), o);
|
|
1769
1729
|
else if (e.provider) {
|
|
1770
|
-
const s = await
|
|
1771
|
-
|
|
1730
|
+
const s = await we(e.provider.query(t), o);
|
|
1731
|
+
I(o), zn(s, r), a = s.datasets, n?.(r, s);
|
|
1772
1732
|
} else a = e.datasets ?? {};
|
|
1773
1733
|
} catch (s) {
|
|
1774
|
-
throw o?.aborted ?
|
|
1734
|
+
throw o?.aborted ? ce(o) : s instanceof C ? s : new C("fetch", `报表 ${r} 取数失败:${s instanceof Error ? s.message : String(s)}`, s);
|
|
1775
1735
|
}
|
|
1776
|
-
return
|
|
1736
|
+
return I(o), a;
|
|
1777
1737
|
}
|
|
1778
|
-
function
|
|
1738
|
+
function zn(e, t) {
|
|
1779
1739
|
if (!e || typeof e != "object" || Array.isArray(e)) throw new C("validate", `报表 ${t} Provider 应返回 datasets 结果对象`);
|
|
1780
1740
|
for (const r of ["revision", "sourceToken"])
|
|
1781
1741
|
if (e[r] !== void 0 && typeof e[r] != "string") throw new C("validate", `报表 ${t} Provider ${r} 应为字符串`);
|
|
1782
1742
|
if (e.diagnostics !== void 0 && (!Array.isArray(e.diagnostics) || e.diagnostics.some((r) => !r || typeof r.code != "string" || typeof r.message != "string" || !["info", "warning", "error"].includes(r.severity))))
|
|
1783
1743
|
throw new C("validate", `报表 ${t} Provider diagnostics 不符合结构化诊断契约`);
|
|
1784
|
-
if (e.diagnostics?.some((r) => !
|
|
1744
|
+
if (e.diagnostics?.some((r) => !Hn(r)))
|
|
1785
1745
|
throw new C("validate", `报表 ${t} Provider 数据说明缺少有效的字段身份或值状态`);
|
|
1786
1746
|
}
|
|
1787
|
-
function
|
|
1747
|
+
function Jn(e, t, r, n, o) {
|
|
1788
1748
|
try {
|
|
1789
|
-
t =
|
|
1749
|
+
t = Ot(n, t, { maxRows: e.dataValidation?.maxRows, signal: o });
|
|
1790
1750
|
} catch (a) {
|
|
1791
1751
|
throw new C("validate", `报表 ${r} 树形数据无效:${a instanceof Error ? a.message : String(a)}`, a);
|
|
1792
1752
|
}
|
|
1793
1753
|
for (const [a, s] of Object.entries(e.dataSchema ?? {})) {
|
|
1794
1754
|
let i;
|
|
1795
1755
|
try {
|
|
1796
|
-
i =
|
|
1756
|
+
i = Ze(Object.prototype.hasOwnProperty.call(t, a) ? t[a] : void 0, s, { ...e.dataValidation, path: `$.datasets.${a}` });
|
|
1797
1757
|
} catch (c) {
|
|
1798
1758
|
throw new C("config", `报表 ${r} 数据集 ${a} 字段契约配置无效`, c);
|
|
1799
1759
|
}
|
|
1800
1760
|
if (!i.ok) throw new C("validate", `报表 ${r} 数据集 ${a} 不符合字段契约:${i.issues[0]?.message}`, { issues: i.issues });
|
|
1801
1761
|
}
|
|
1802
1762
|
}
|
|
1803
|
-
async function
|
|
1763
|
+
async function _n(e, t, r, n, o) {
|
|
1804
1764
|
try {
|
|
1805
1765
|
let a;
|
|
1806
1766
|
try {
|
|
1807
|
-
a =
|
|
1767
|
+
a = En(e);
|
|
1808
1768
|
} catch {
|
|
1809
1769
|
}
|
|
1810
|
-
const s = a ?? e, i =
|
|
1811
|
-
return
|
|
1770
|
+
const s = a ?? e, i = Nt(t.pagination, n, s.template, s.datasets, o), c = a ? await mt(s.template, s.datasets, i) : ft(s.template, s.datasets, i);
|
|
1771
|
+
return Lt(n, c), { result: c, part: s };
|
|
1812
1772
|
} catch (a) {
|
|
1813
|
-
|
|
1814
|
-
const s =
|
|
1773
|
+
I(o);
|
|
1774
|
+
const s = Ht(a, n);
|
|
1815
1775
|
throw new C("validate", `报表 ${r} 排版失败:${s instanceof Error ? s.message : String(s)}`, s);
|
|
1816
1776
|
}
|
|
1817
1777
|
}
|
|
1818
|
-
function
|
|
1778
|
+
function Dt(e, t, r, n, o) {
|
|
1819
1779
|
const a = /* @__PURE__ */ new Map(), s = (i) => {
|
|
1820
1780
|
let c = a.get(i);
|
|
1821
1781
|
return c === void 0 && (c = JSON.stringify([r, n, i]), a.set(i, c)), c;
|
|
1822
1782
|
};
|
|
1823
1783
|
for (const i of t.pages) e.push({
|
|
1824
1784
|
...i,
|
|
1825
|
-
meta: { ...i.meta, reportScope:
|
|
1826
|
-
components:
|
|
1785
|
+
meta: { ...i.meta, reportScope: At(r, n) },
|
|
1786
|
+
components: jt(i.components, o ?? Kt(r, n), s)
|
|
1827
1787
|
});
|
|
1828
1788
|
}
|
|
1829
|
-
async function
|
|
1830
|
-
const a = [], s =
|
|
1831
|
-
for (const [l,
|
|
1832
|
-
|
|
1789
|
+
async function qn(e, t, r, n, o) {
|
|
1790
|
+
const a = [], s = ge(n);
|
|
1791
|
+
for (const [l, u] of e.entries()) {
|
|
1792
|
+
I(o);
|
|
1833
1793
|
try {
|
|
1834
|
-
const f = await
|
|
1835
|
-
|
|
1794
|
+
const f = await Rt(u.template, u.datasets, Nt(t[l]?.pagination, s, u.template, u.datasets, o));
|
|
1795
|
+
Lt(s, f), Dt(a, f.plan, l, r[l], u.sourceScope);
|
|
1836
1796
|
} catch (f) {
|
|
1837
|
-
throw
|
|
1797
|
+
throw Ht(f, s);
|
|
1838
1798
|
}
|
|
1839
1799
|
}
|
|
1840
|
-
const i = { schemaVersion: be, ...e.some((l) =>
|
|
1800
|
+
const i = { schemaVersion: be, ...e.some((l) => Ce(l.template)) ? { requiresRecalculation: !0 } : {}, pages: a }, c = Qe(i);
|
|
1841
1801
|
if (!c.ok) throw new C("validate", `重算渲染计划校验失败:${c.errors[0]?.message}`);
|
|
1842
1802
|
return i;
|
|
1843
1803
|
}
|
|
1844
|
-
function
|
|
1804
|
+
function To(e, t = {}) {
|
|
1845
1805
|
if (t.maxPages !== void 0 && (!Number.isSafeInteger(t.maxPages) || t.maxPages < 1)) throw new C("config", "maxPages 应为正安全整数");
|
|
1846
1806
|
if (t.maxCells !== void 0 && (!Number.isSafeInteger(t.maxCells) || t.maxCells < 1)) throw new C("config", "maxCells 应为正安全整数");
|
|
1847
1807
|
try {
|
|
1848
|
-
|
|
1808
|
+
ge(t);
|
|
1849
1809
|
} catch (o) {
|
|
1850
1810
|
throw new C("config", "maxChartComponents 应为 1..1000000 的安全整数", o);
|
|
1851
1811
|
}
|
|
@@ -1856,128 +1816,155 @@ function Ro(e, t = {}) {
|
|
|
1856
1816
|
return a;
|
|
1857
1817
|
}
|
|
1858
1818
|
return Object.assign(async ({ reportIds: o, params: a, signal: s, onWarning: i, onQueryResult: c, ...l }) => {
|
|
1859
|
-
|
|
1860
|
-
const
|
|
1819
|
+
I(s);
|
|
1820
|
+
const u = Nn({ ...l, signal: s }), f = [...o], d = { ...a };
|
|
1861
1821
|
if (f.length === 0) throw new C("config", "缺少报表 ID");
|
|
1862
|
-
const h = f.map(r), m =
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
))), v = [],
|
|
1866
|
-
for (const [
|
|
1867
|
-
|
|
1868
|
-
const S = f[
|
|
1869
|
-
|
|
1870
|
-
const R = await
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
}, S),
|
|
1874
|
-
const L =
|
|
1875
|
-
|
|
1822
|
+
const h = f.map(r), m = u.runSync("validate", () => h.map((g) => Oe(
|
|
1823
|
+
g.params ?? (typeof g.template == "function" ? [] : g.template.params) ?? [],
|
|
1824
|
+
d
|
|
1825
|
+
))), v = [], p = [], w = ge(t), y = [];
|
|
1826
|
+
for (const [g, b] of h.entries()) {
|
|
1827
|
+
I(s);
|
|
1828
|
+
const S = f[g], E = { reportId: S, params: m[g], signal: s }, P = typeof b.template == "function" ? await u.run("query", () => Wn(b.template, E, y), S) : b.template;
|
|
1829
|
+
E.params = u.runSync("validate", () => Oe(b.params ?? P.params ?? [], E.params), S);
|
|
1830
|
+
const R = await u.run("query", () => Vn(b, E, S, (le, Gt) => c?.(le, Gt, g)), S);
|
|
1831
|
+
u.runSync("validate", () => {
|
|
1832
|
+
Gn(R, S), t.onDatasets?.(S, R, P), Jn(b, R, S, P, s);
|
|
1833
|
+
}, S), I(s);
|
|
1834
|
+
const L = Kt(g, S, b.sourceScope), { result: Fe, part: Bt } = await u.run("layout", () => _n({ template: P, datasets: R, sourceScope: L }, b, S, w, s), S);
|
|
1835
|
+
p.push(Bt), Dt(v, Fe.plan, g, S, L), y.push(...Fe.warnings.map((le) => `${S}: ${le}`));
|
|
1876
1836
|
}
|
|
1877
|
-
|
|
1878
|
-
const x = { schemaVersion: be, ...
|
|
1879
|
-
const
|
|
1880
|
-
if (!
|
|
1881
|
-
return
|
|
1837
|
+
I(s);
|
|
1838
|
+
const x = { schemaVersion: be, ...p.some((g) => Ce(g.template)) ? { requiresRecalculation: !0 } : {}, pages: v }, k = u.runSync("validate", () => {
|
|
1839
|
+
const g = Qe(x);
|
|
1840
|
+
if (!g.ok) throw new C("validate", `渲染计划校验失败:${g.errors.slice(0, 3).map((b) => `${b.path}: ${b.message}`).join("; ")}`);
|
|
1841
|
+
return g;
|
|
1882
1842
|
});
|
|
1883
|
-
|
|
1884
|
-
const
|
|
1843
|
+
y.push(...k.warnings.map((g) => `${g.path}: ${g.message}`));
|
|
1844
|
+
const T = h.map((g) => ({ ...g, pagination: { ...g.pagination } })), O = { maxPages: t.maxPages, maxCells: t.maxCells, maxChartComponents: t.maxChartComponents };
|
|
1885
1845
|
try {
|
|
1886
|
-
|
|
1846
|
+
$t(x, { parts: p, validationFormulas: T.map((g) => g.pagination?.formula), rebuild: (g, b) => qn(g, T, f, O, b) });
|
|
1887
1847
|
} catch {
|
|
1888
|
-
|
|
1848
|
+
y.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算");
|
|
1889
1849
|
}
|
|
1890
|
-
const A = i ?? t.onWarning ?? ((
|
|
1891
|
-
for (const
|
|
1892
|
-
|
|
1893
|
-
return
|
|
1850
|
+
const A = i ?? t.onWarning ?? ((g) => console.warn("[mach-report]", g));
|
|
1851
|
+
for (const g of y)
|
|
1852
|
+
I(s), A(g);
|
|
1853
|
+
return I(s), x;
|
|
1894
1854
|
}, {
|
|
1895
|
-
getParamDefs: (o) =>
|
|
1855
|
+
getParamDefs: (o) => cr(e, o)
|
|
1896
1856
|
});
|
|
1897
1857
|
}
|
|
1898
|
-
|
|
1858
|
+
const Un = /* @__PURE__ */ new Set([8, 9, 10, 12, 13]);
|
|
1859
|
+
function Xn(e, t) {
|
|
1860
|
+
const r = Array.isArray(e), n = Object.getPrototypeOf(e);
|
|
1861
|
+
if (n !== (r ? Array.prototype : Object.prototype) && !(n === null && !r) || Object.getOwnPropertySymbols(e).length) throw t("input", "快照应为普通 JSON 对象");
|
|
1862
|
+
const o = Object.getOwnPropertyNames(e).filter((a) => !(r && a === "length"));
|
|
1863
|
+
if (r && (o.length !== e.length || o.some((a, s) => a !== String(s)))) throw t("input", "快照数组应为连续数组");
|
|
1864
|
+
return { array: r, keys: o };
|
|
1865
|
+
}
|
|
1866
|
+
function Yn(e) {
|
|
1867
|
+
if (/^[\u0020-\u007e]*$/.test(e) && !/["\\]/.test(e)) return e.length + 2;
|
|
1868
|
+
let t = 2;
|
|
1869
|
+
for (let r = 0; r < e.length; r++) {
|
|
1870
|
+
const n = e.charCodeAt(r);
|
|
1871
|
+
if (n < 32) t += Un.has(n) ? 2 : 6;
|
|
1872
|
+
else if (n === 34 || n === 92) t += 2;
|
|
1873
|
+
else if (n < 128) t++;
|
|
1874
|
+
else if (n < 2048) t += 2;
|
|
1875
|
+
else if (n >= 55296 && n <= 57343) {
|
|
1876
|
+
const o = e.charCodeAt(r + 1);
|
|
1877
|
+
n <= 56319 && o >= 56320 && o <= 57343 ? (t += 4, r++) : t += 6;
|
|
1878
|
+
} else t += 3;
|
|
1879
|
+
}
|
|
1880
|
+
return t;
|
|
1881
|
+
}
|
|
1882
|
+
function Po(e, t) {
|
|
1899
1883
|
const r = t.maxNodes ?? 1e6;
|
|
1900
1884
|
if (![t.maxBytes, r].every((d) => Number.isSafeInteger(d) && d > 0)) throw t.error("budget", "快照预算应为正安全整数");
|
|
1901
1885
|
let n = 0, o = 0;
|
|
1902
|
-
const a = /* @__PURE__ */ new Set();
|
|
1903
|
-
function
|
|
1886
|
+
const a = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map();
|
|
1887
|
+
function i(d) {
|
|
1888
|
+
if (d.length + 2 > t.maxBytes - o) throw t.error("budget", "快照超过字节预算");
|
|
1889
|
+
const h = s.get(d);
|
|
1890
|
+
if (h !== void 0) return h;
|
|
1891
|
+
const m = Yn(d);
|
|
1892
|
+
return d.length <= 256 && s.size < 4096 && s.set(d, m), m;
|
|
1893
|
+
}
|
|
1894
|
+
function c(d) {
|
|
1904
1895
|
if (o += d, o > t.maxBytes) throw t.error("budget", "快照超过字节预算");
|
|
1905
1896
|
}
|
|
1906
|
-
function
|
|
1907
|
-
if (++n > r ||
|
|
1897
|
+
function l(d, h) {
|
|
1898
|
+
if (++n > r || h > 64) throw t.error("budget", "快照节点或深度超过预算");
|
|
1908
1899
|
if (n % 1024 === 0 && t.check?.(), typeof d == "string")
|
|
1909
|
-
return
|
|
1900
|
+
return c(i(d)), d;
|
|
1910
1901
|
if (d === null || typeof d == "boolean" || typeof d == "number" && Number.isFinite(d))
|
|
1911
|
-
return
|
|
1902
|
+
return c(String(d).length), typeof d == "number" && Object.is(d, -0) ? 0 : d;
|
|
1912
1903
|
if (!d || typeof d != "object" || a.has(d)) throw t.error("input", "快照应为无循环的有限 JSON 值");
|
|
1913
|
-
return
|
|
1914
|
-
}
|
|
1915
|
-
function
|
|
1916
|
-
const
|
|
1917
|
-
|
|
1918
|
-
const
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1904
|
+
return u(d, h);
|
|
1905
|
+
}
|
|
1906
|
+
function u(d, h) {
|
|
1907
|
+
const { array: m, keys: v } = Xn(d, t.error);
|
|
1908
|
+
a.add(d), c(2);
|
|
1909
|
+
const p = m ? [] : {};
|
|
1910
|
+
let w = 0;
|
|
1911
|
+
for (const y of v) {
|
|
1912
|
+
const x = Object.getOwnPropertyDescriptor(d, y);
|
|
1913
|
+
if (x.get || x.set || !x.enumerable || ["__proto__", "constructor", "prototype"].includes(y)) throw t.error("input", "快照不允许访问器或危险键");
|
|
1914
|
+
if (x.value === void 0 && !m) continue;
|
|
1915
|
+
c((w++ ? 1 : 0) + (m ? 0 : i(y) + 1));
|
|
1916
|
+
const k = l(x.value === void 0 ? null : x.value, h + 1);
|
|
1917
|
+
y in p ? Object.defineProperty(p, y, { value: k, enumerable: !0, configurable: !0, writable: !0 }) : p[y] = k;
|
|
1927
1918
|
}
|
|
1928
|
-
return a.delete(d),
|
|
1919
|
+
return a.delete(d), p;
|
|
1929
1920
|
}
|
|
1930
1921
|
t.check?.();
|
|
1931
|
-
const
|
|
1932
|
-
|
|
1933
|
-
return JSON.parse(l);
|
|
1922
|
+
const f = l(e, 0);
|
|
1923
|
+
return t.check?.(), f;
|
|
1934
1924
|
}
|
|
1935
1925
|
export {
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1926
|
+
br as A,
|
|
1927
|
+
$t as B,
|
|
1928
|
+
bo as C,
|
|
1929
|
+
Cr as D,
|
|
1930
|
+
F as E,
|
|
1931
|
+
yo as F,
|
|
1932
|
+
mo as G,
|
|
1933
|
+
Ge as H,
|
|
1934
|
+
Ot as I,
|
|
1935
|
+
xo as J,
|
|
1936
|
+
Kt as K,
|
|
1937
|
+
Ie as L,
|
|
1938
|
+
U as M,
|
|
1939
|
+
Nn as N,
|
|
1940
|
+
Co as O,
|
|
1941
|
+
jn as P,
|
|
1942
|
+
At as Q,
|
|
1953
1943
|
C as R,
|
|
1954
|
-
Po as S,
|
|
1955
|
-
Dn as T,
|
|
1956
|
-
Nt as U,
|
|
1957
1944
|
M as a,
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1945
|
+
tn as b,
|
|
1946
|
+
go as c,
|
|
1947
|
+
ko as d,
|
|
1948
|
+
wo as e,
|
|
1949
|
+
xn as f,
|
|
1950
|
+
kt as g,
|
|
1951
|
+
sn as h,
|
|
1952
|
+
lo as i,
|
|
1953
|
+
ho as j,
|
|
1954
|
+
po as k,
|
|
1955
|
+
D as l,
|
|
1956
|
+
Mo as m,
|
|
1957
|
+
To as n,
|
|
1958
|
+
fo as o,
|
|
1959
|
+
vt as p,
|
|
1960
|
+
So as q,
|
|
1961
|
+
q as r,
|
|
1962
|
+
Po as s,
|
|
1963
|
+
Re as t,
|
|
1964
|
+
vo as u,
|
|
1965
|
+
Hn as v,
|
|
1966
|
+
Ft as w,
|
|
1967
|
+
Ln as x,
|
|
1968
|
+
ft as y,
|
|
1969
|
+
uo as z
|
|
1983
1970
|
};
|