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