@agile-team/mach-report 2.25.1 → 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 +4 -2
- package/dist/ReportPreview-D1ZC5kzz.js +7317 -0
- package/dist/ReportPreview-DAU-V3Ov.cjs +6 -0
- package/dist/artifact-integrity.json +35 -35
- package/dist/{auto-mPK9W0y5.cjs → auto-DjmvmcX-.cjs} +1 -1
- package/dist/{auto-D7x7QsWD.js → auto-j7mr8Kvc.js} +82 -82
- package/dist/{encoding-Amq3XrtU.js → encoding-BWEMdzFG.js} +2 -2
- package/dist/{encoding-DRVXs5xm.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 +5 -5
- package/dist/{json-snapshot-CBVWZvyC.js → json-snapshot-DdzALe8q.js} +811 -774
- package/dist/json-snapshot-L_gJ7KRS.cjs +2 -0
- package/dist/{plugin-DHe8y5pD.cjs → plugin-D5BRHlne.cjs} +1 -1
- package/dist/{plugin-BdCplNe1.js → plugin-FWhTnjr0.js} +1 -1
- package/dist/{prefill-Cw4ZYGXZ.cjs → prefill-DZymomY6.cjs} +1 -1
- package/dist/{prefill-Buy4NJ15.js → prefill-m01IM1hl.js} +1 -1
- package/dist/{prepared-BlNeOjoO.cjs → prepared-BHu8bIdj.cjs} +1 -1
- package/dist/{prepared-CBJ7BkK0.js → prepared-DO5pe6Ed.js} +1 -1
- package/dist/{protocol-CB19KXGr.js → protocol-CZddmu2n.js} +2 -2
- package/dist/{protocol-BU_4sXP0.cjs → protocol-CymmHWmL.cjs} +1 -1
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/{runtime-B5d_lQNQ.js → runtime-D8AlfJ6S.js} +82 -75
- 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 +1978 -1935
- package/dist/server.cjs +1 -1
- package/dist/server.js +5 -5
- package/dist/{template-catalog-CM6U_RlD.js → template-catalog-DLu814zA.js} +1 -1
- package/dist/{template-catalog-Cj66M84u.cjs → template-catalog-Lil5Ryt-.cjs} +1 -1
- 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/worker.cjs +1 -1
- package/dist/worker.js +4 -4
- package/package.json +1 -1
- package/dist/ReportPreview-CnxaDTCO.js +0 -7170
- package/dist/ReportPreview-DqFBcsJQ.cjs +0 -6
- package/dist/json-snapshot-DCFEtfFw.cjs +0 -2
- package/dist/runtime-BRx8Agqr.cjs +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { r 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
|
|
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 hr(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 >=
|
|
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 hr(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,18 +58,18 @@ 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
|
-
const r = e.paddingMm ?? 1, n = e.headerGrid.cells.map(() => e.rowHeightMm ?? 0), o = e.columns.map((c) => c.widthMm), a =
|
|
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
64
|
for (const { cell: c, ci: l, ri: d, widthMm: f } of a.cells) {
|
|
65
|
-
const u = { ...
|
|
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
66
|
for (let y = d; y < d + (c.rowSpan ?? 1); y++) n[y] = Math.max(n[y] ?? 0, b);
|
|
67
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;
|
|
@@ -88,7 +88,7 @@ function vr(e, t, r) {
|
|
|
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,11 +104,11 @@ 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
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);
|
|
@@ -124,14 +124,14 @@ function* Sr(e) {
|
|
|
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,9 +139,9 @@ 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 (d <=
|
|
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
|
}
|
|
@@ -150,100 +150,100 @@ function kr() {
|
|
|
150
150
|
return l;
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
|
-
const Tr = 1e4,
|
|
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 ?? Tr, i =
|
|
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
177
|
for (const [d, f] of o.entries()) {
|
|
178
|
-
if (
|
|
179
|
-
const u = { rowIndex: d, dataset: n.dataset }, m =
|
|
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 g =
|
|
186
|
-
if (c += g * e.pages.length, l += g * i, c > s) throw new
|
|
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
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 =
|
|
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 } }
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
|
-
function*
|
|
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 }, d =
|
|
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
240
|
for (let u = 0; u < d; u++) for (const [m, g] of e.pages.entries())
|
|
241
|
-
|
|
241
|
+
Ae(r.signal), yield { page: Or(g, m, l, u, d, f), pageIndex: m };
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
-
const
|
|
245
|
-
function
|
|
246
|
-
if (e === void 0) return
|
|
244
|
+
const Ar = Object.freeze({}), jr = 16;
|
|
245
|
+
function Kr(e) {
|
|
246
|
+
if (e === void 0) return Ar;
|
|
247
247
|
try {
|
|
248
248
|
const t = Object.getPrototypeOf(e);
|
|
249
249
|
if (t !== Object.prototype && t !== null || Object.getOwnPropertySymbols(e).length) return;
|
|
@@ -260,23 +260,23 @@ function jr(e) {
|
|
|
260
260
|
return;
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
-
function
|
|
263
|
+
function Nr(e, t) {
|
|
264
264
|
const r = Object.keys(t);
|
|
265
265
|
return r.length === Object.keys(e).length && r.every((n) => Object.prototype.hasOwnProperty.call(e, n) && Object.is(e[n], t[n]));
|
|
266
266
|
}
|
|
267
|
-
function
|
|
267
|
+
function Lr(e) {
|
|
268
268
|
const t = [];
|
|
269
269
|
return (r, n, o, a) => {
|
|
270
|
-
if (!Number.isInteger(r) || r < 0 || r >=
|
|
271
|
-
const s =
|
|
270
|
+
if (!Number.isInteger(r) || r < 0 || r >= jr) return e(o, a);
|
|
271
|
+
const s = Kr(a);
|
|
272
272
|
if (!s) return e(o, a);
|
|
273
273
|
const i = t[r];
|
|
274
|
-
if (i?.firstRow === n && i.label === o &&
|
|
274
|
+
if (i?.firstRow === n && i.label === o && Nr(i.style, s)) return i.row;
|
|
275
275
|
const c = e(o, a);
|
|
276
276
|
return t[r] = { firstRow: n, label: o, style: s, row: c }, c;
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
|
-
function
|
|
279
|
+
function Hr(e) {
|
|
280
280
|
return {
|
|
281
281
|
widthMm: e.widthMm,
|
|
282
282
|
heightMm: e.heightMm,
|
|
@@ -287,64 +287,64 @@ function Lr(e) {
|
|
|
287
287
|
components: []
|
|
288
288
|
};
|
|
289
289
|
}
|
|
290
|
-
function
|
|
290
|
+
function se(e, t) {
|
|
291
291
|
const r = t.heightMm - (e.layout === "wide" ? t.marginBottomMm : e.marginBottomMm ?? t.marginBottomMm);
|
|
292
292
|
return e.components.reduce((n, o) => o.kind !== "list" && o.pageAnchor === "footer" ? Math.min(n, o.topMm) : n, r);
|
|
293
293
|
}
|
|
294
|
-
function
|
|
294
|
+
function Y(e) {
|
|
295
295
|
return e.components.reduce((t, r) => r.kind !== "list" && r.pageAnchor === "header" ? Math.max(t, r.topMm + r.heightMm) : t, 0);
|
|
296
296
|
}
|
|
297
|
-
function
|
|
297
|
+
function lt(e, t) {
|
|
298
298
|
let r = e.textMetrics.get(t);
|
|
299
299
|
if (!r) {
|
|
300
|
-
const n =
|
|
300
|
+
const n = te(t).fontSizePt;
|
|
301
301
|
r = {
|
|
302
302
|
measureOptions: {
|
|
303
303
|
fontSizePt: n,
|
|
304
|
-
fontFamily: t.fontFamily ??
|
|
304
|
+
fontFamily: t.fontFamily ?? Te,
|
|
305
305
|
italic: t.italic,
|
|
306
306
|
bold: t.bold,
|
|
307
307
|
letterSpacingPt: t.letterSpacing
|
|
308
308
|
},
|
|
309
|
-
lineMm: n * (t.lineHeight ??
|
|
309
|
+
lineMm: n * (t.lineHeight ?? ke) * 25.4 / 72
|
|
310
310
|
}, e.textMetrics.set(t, r);
|
|
311
311
|
}
|
|
312
312
|
return r;
|
|
313
313
|
}
|
|
314
|
-
function
|
|
314
|
+
function Dr(e) {
|
|
315
315
|
if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return e;
|
|
316
316
|
}
|
|
317
|
-
function
|
|
318
|
-
const o = e.fontSizePt ??
|
|
319
|
-
...
|
|
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({
|
|
320
320
|
fontSize: o,
|
|
321
321
|
verticalAlign: "middle"
|
|
322
|
-
},
|
|
322
|
+
}, p.style),
|
|
323
323
|
align: s[h] === "auto" ? "left" : s[h]
|
|
324
|
-
})), c = i.map((
|
|
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
325
|
const T = c[h];
|
|
326
326
|
if (T) return {
|
|
327
|
-
left:
|
|
328
|
-
center:
|
|
329
|
-
right:
|
|
327
|
+
left: L(T.left, S.style),
|
|
328
|
+
center: L(T.center, S.style),
|
|
329
|
+
right: L(T.right, S.style)
|
|
330
330
|
};
|
|
331
|
-
const
|
|
332
|
-
return { left:
|
|
333
|
-
})), d = e.columns.map((
|
|
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
334
|
let u = e.rowHeightMm ?? 0;
|
|
335
|
-
for (let
|
|
336
|
-
const h = d[
|
|
337
|
-
f[
|
|
338
|
-
e.columns[
|
|
339
|
-
{ fontSizePt: S, fontFamily: h.fontFamily ??
|
|
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 },
|
|
340
340
|
t
|
|
341
|
-
),
|
|
342
|
-
u = Math.max(u, Math.max(T.length, 1) *
|
|
341
|
+
), R = S * (h.lineHeight ?? ke) * 25.4 / 72;
|
|
342
|
+
u = Math.max(u, Math.max(T.length, 1) * R + a * 2);
|
|
343
343
|
}
|
|
344
|
-
const m = f.map((
|
|
345
|
-
text:
|
|
344
|
+
const m = f.map((p, h) => ({
|
|
345
|
+
text: p,
|
|
346
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((
|
|
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, {
|
|
348
348
|
cells: [m],
|
|
349
349
|
colWidthsMm: b,
|
|
350
350
|
rowHeightsMm: [u],
|
|
@@ -353,39 +353,39 @@ function Fe(e, t, r = [], n) {
|
|
|
353
353
|
return {
|
|
354
354
|
fontSizePt: o,
|
|
355
355
|
paddingMm: a,
|
|
356
|
-
visuals:
|
|
357
|
-
visibility: e.columns.map((
|
|
358
|
-
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))),
|
|
359
359
|
cellStyles: i,
|
|
360
360
|
autoStyles: c,
|
|
361
361
|
ruleStyles: l,
|
|
362
362
|
textMetrics: /* @__PURE__ */ new WeakMap(),
|
|
363
|
-
numberFormats: e.columns.map((
|
|
364
|
-
derivedFields: new Set(e.computed?.map((
|
|
363
|
+
numberFormats: e.columns.map((p) => et(p.format)),
|
|
364
|
+
derivedFields: new Set(e.computed?.map((p) => p.field)),
|
|
365
365
|
borderStyle: g,
|
|
366
|
-
headerHeightMm: y.rowHeightsMm.reduce((
|
|
366
|
+
headerHeightMm: y.rowHeightsMm.reduce((p, h) => p + h, 0),
|
|
367
367
|
headerGrid: y,
|
|
368
368
|
colWidthsMm: b,
|
|
369
369
|
columns: e.columns
|
|
370
370
|
};
|
|
371
371
|
}
|
|
372
|
-
function
|
|
372
|
+
function Br(e, t, r) {
|
|
373
373
|
if (!e) return r;
|
|
374
374
|
if (!e.cells.length) throw new Error("自定义列表表头至少需要一行");
|
|
375
375
|
const n = e.rowHeightsMm ?? e.cells.map(() => r.rowHeightsMm[0]);
|
|
376
376
|
if (n.length !== e.cells.length || n.some((o) => !Number.isFinite(o) || o <= 0)) throw new Error("自定义列表表头行高无效");
|
|
377
377
|
return { ...e, colWidthsMm: t, rowHeightsMm: n };
|
|
378
378
|
}
|
|
379
|
-
function
|
|
379
|
+
function Gr(e, t, r) {
|
|
380
380
|
const n = t.format?.kind === "number" || t.format?.kind === "percent";
|
|
381
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);
|
|
382
382
|
}
|
|
383
|
-
function
|
|
383
|
+
function Q(e, t, r) {
|
|
384
384
|
const n = e.columns, o = e.tree?.rows.get(t);
|
|
385
385
|
let a = e.rowHeightFloorMm;
|
|
386
386
|
const s = new Array(n.length);
|
|
387
387
|
for (let i = 0; i < n.length; i++) {
|
|
388
|
-
const c = n[i], l = e.visibility[i]?.(t) !== !1, d = l ? t[c.field] : null, f = e.autoStyles[i] ?
|
|
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
389
|
let u = e.autoStyles[i]?.[f] ?? e.cellStyles[i];
|
|
390
390
|
if (c.rules) {
|
|
391
391
|
for (let S = 0; S < c.rules.length; S++)
|
|
@@ -394,12 +394,12 @@ function X(e, t, r) {
|
|
|
394
394
|
break;
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
-
const m = c.format ?
|
|
398
|
-
u =
|
|
399
|
-
const b =
|
|
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
400
|
a = Math.max(a, y.length * b.lineMm + e.paddingMm * 2);
|
|
401
|
-
const
|
|
402
|
-
d != null && e.visuals[i]?.apply(h, t),
|
|
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;
|
|
403
403
|
}
|
|
404
404
|
return {
|
|
405
405
|
grid: { cells: [s], colWidthsMm: e.colWidthsMm, rowHeightsMm: [a], paddingMm: e.paddingMm },
|
|
@@ -407,20 +407,20 @@ function X(e, t, r) {
|
|
|
407
407
|
...e.matrix ? { meta: { matrix: { row: e.matrix.rows.get(t) } } } : {}
|
|
408
408
|
};
|
|
409
409
|
}
|
|
410
|
-
function
|
|
411
|
-
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);
|
|
412
412
|
}
|
|
413
|
-
function
|
|
413
|
+
function Vr(e, t, r, n) {
|
|
414
414
|
return !n || t.field !== e.tree.list.tree.labelField || r.align === "left" ? r : { ...r, align: "left" };
|
|
415
415
|
}
|
|
416
|
-
function
|
|
417
|
-
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));
|
|
418
418
|
}
|
|
419
|
-
function
|
|
419
|
+
function dt(e) {
|
|
420
420
|
if (e != null && typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e))) throw new Error("分组字段应为有限 JSON 标量");
|
|
421
421
|
return JSON.stringify([typeof e, e ?? null]);
|
|
422
422
|
}
|
|
423
|
-
function*
|
|
423
|
+
function* ut(e, t, r = 0) {
|
|
424
424
|
const n = t[r];
|
|
425
425
|
if (!n) {
|
|
426
426
|
for (const a of e) yield { kind: "row", row: a };
|
|
@@ -428,51 +428,51 @@ function* lt(e, t, r = 0) {
|
|
|
428
428
|
}
|
|
429
429
|
const o = /* @__PURE__ */ new Map();
|
|
430
430
|
for (const a of e) {
|
|
431
|
-
const s =
|
|
431
|
+
const s = dt(a[n.field]), i = o.get(s);
|
|
432
432
|
i ? i.push(a) : o.set(s, [a]);
|
|
433
433
|
}
|
|
434
434
|
for (const a of o.values())
|
|
435
|
-
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 };
|
|
436
436
|
}
|
|
437
|
-
function
|
|
437
|
+
function ft(e, t, r, n = []) {
|
|
438
438
|
const o = [...r.filter((a) => !n.some((s) => s.field === a)).map((a) => ({ field: a, op: "sum" })), ...n];
|
|
439
439
|
return new Map(o.map((a) => {
|
|
440
|
-
const s = e.find((c) => c.field === a.field)?.format ?? { kind: "number", thousands: !0 }, i =
|
|
441
|
-
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) } : {} }];
|
|
442
442
|
}));
|
|
443
443
|
}
|
|
444
|
-
function
|
|
444
|
+
function mt(e, t) {
|
|
445
445
|
const r = e.findIndex((n) => t.includes(n.field));
|
|
446
446
|
return r < 0 ? 1 : r;
|
|
447
447
|
}
|
|
448
|
-
function
|
|
449
|
-
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);
|
|
450
450
|
i && s.push({ text: r, colSpan: i, style: { bold: !0, ...c } });
|
|
451
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]?.[
|
|
453
|
-
s.push({ ...g, text: g?.text ?? "", style:
|
|
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) });
|
|
454
454
|
}
|
|
455
|
-
const l = { text: r, colSpan: e.columns.length, style: { bold: !0, ...c } }, d = i ? [s] : [[l], s], f = d.map((u) =>
|
|
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));
|
|
456
456
|
return {
|
|
457
457
|
grid: { cells: d, colWidthsMm: e.colWidthsMm, rowHeightsMm: f, paddingMm: e.paddingMm },
|
|
458
458
|
heightMm: f.reduce((u, m) => u + m, 0)
|
|
459
459
|
};
|
|
460
460
|
}
|
|
461
|
-
function
|
|
461
|
+
function _r(e, t, r) {
|
|
462
462
|
let n = e.rowHeightFloorMm, o = 0;
|
|
463
463
|
for (const a of t) {
|
|
464
464
|
let s = 0;
|
|
465
465
|
const i = o + (a.colSpan ?? 1);
|
|
466
466
|
for (; o < i; o++) s += e.colWidthsMm[o] ?? 0;
|
|
467
|
-
const c =
|
|
467
|
+
const c = lt(e, a.style), l = D(a.text ?? "", s - e.paddingMm * 2, c.measureOptions, r);
|
|
468
468
|
n = Math.max(n, l.length * c.lineMm + e.paddingMm * 2);
|
|
469
469
|
}
|
|
470
470
|
return n;
|
|
471
471
|
}
|
|
472
|
-
function
|
|
473
|
-
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 = {
|
|
474
474
|
id: r.tableId,
|
|
475
|
-
columnKeys: e.columns.map((
|
|
475
|
+
columnKeys: e.columns.map((w) => w.field),
|
|
476
476
|
...e.layout === void 0 ? {} : { layout: e.layout },
|
|
477
477
|
...e.title === void 0 ? {} : { title: e.title }
|
|
478
478
|
}, u = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), g = {
|
|
@@ -486,53 +486,53 @@ function _r(e, t, r) {
|
|
|
486
486
|
table: { ...f, role: "header", rowIndex: -1 },
|
|
487
487
|
style: t.borderStyle,
|
|
488
488
|
...e.meta || t.matrix ? { meta: { ...e.meta, ...t.matrix ? { matrix: t.matrix.header } : {} } } : {}
|
|
489
|
-
}, b = (
|
|
489
|
+
}, b = (w) => o.components.push({ ...g, topMm: w });
|
|
490
490
|
if (r.flow && e.header !== !1 && t.headerHeightMm > c() - l + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的表头高度超出单页可用范围`);
|
|
491
491
|
let y = Math.max(r.startTop ?? e.topMm, l);
|
|
492
492
|
e.header !== !1 && (b(y), y += t.headerHeightMm + r.mmPerRow);
|
|
493
|
-
function
|
|
494
|
-
const
|
|
495
|
-
return (e.header !== !1 && e.headerEveryPage !== !1 ?
|
|
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
496
|
}
|
|
497
497
|
function h() {
|
|
498
|
-
const
|
|
499
|
-
return Math.min(n.heightMm -
|
|
498
|
+
const w = n.layout === "wide" ? 0 : o.marginBottomMm;
|
|
499
|
+
return Math.min(n.heightMm - w, se(n, o)) - p();
|
|
500
500
|
}
|
|
501
|
-
function S(
|
|
502
|
-
if (y +
|
|
501
|
+
function S(w) {
|
|
502
|
+
if (y + w <= c()) return;
|
|
503
503
|
i(), o.components = [], o.heightMm = n.heightMm, n.layout === "wide" && (o.marginTopMm = 0, o.marginBottomMm = 0);
|
|
504
|
-
const
|
|
505
|
-
e.header !== !1 && e.headerEveryPage !== !1 ? (b(
|
|
506
|
-
for (const
|
|
507
|
-
}
|
|
508
|
-
function T(
|
|
509
|
-
const
|
|
510
|
-
if (r.flow &&
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
function
|
|
514
|
-
const
|
|
515
|
-
|
|
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({
|
|
516
516
|
kind: "rect",
|
|
517
517
|
leftMm: e.leftMm,
|
|
518
518
|
topMm: y,
|
|
519
519
|
widthMm: e.widthMm,
|
|
520
|
-
heightMm:
|
|
521
|
-
grid:
|
|
522
|
-
nid: s(
|
|
523
|
-
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 } : {} },
|
|
524
524
|
style: t.borderStyle,
|
|
525
|
-
...e.meta ||
|
|
526
|
-
}), y +=
|
|
525
|
+
...e.meta || w.meta ? { meta: { ...e.meta, ...w.meta } } : {}
|
|
526
|
+
}), y += w.heightMm;
|
|
527
527
|
}
|
|
528
|
-
function
|
|
529
|
-
|
|
528
|
+
function O(w) {
|
|
529
|
+
w <= h() && S(w);
|
|
530
530
|
}
|
|
531
|
-
return { keepTogether:
|
|
532
|
-
|
|
531
|
+
return { keepTogether: O, placeGridRow: T, setGroupHeader: (w, x) => {
|
|
532
|
+
x ? m.set(w, x) : m.delete(w);
|
|
533
533
|
}, bottom: () => y };
|
|
534
534
|
}
|
|
535
|
-
function
|
|
535
|
+
function Ur(e, t) {
|
|
536
536
|
if (!e.rowKey) return;
|
|
537
537
|
const r = t[e.rowKey];
|
|
538
538
|
if ((typeof r != "string" || !r.trim()) && !(typeof r == "number" && Number.isFinite(r)))
|
|
@@ -542,12 +542,12 @@ function Jr(e, t) {
|
|
|
542
542
|
if (o !== void 0 && typeof o != "string") throw new Error("来源令牌应为字符串");
|
|
543
543
|
return { datasetId: e.dataset, rowKey: r, ...n === void 0 ? {} : { revision: n }, ...o === void 0 ? {} : { sourceToken: o } };
|
|
544
544
|
}
|
|
545
|
-
function
|
|
545
|
+
function le(e, t) {
|
|
546
546
|
const r = /* @__PURE__ */ new Map();
|
|
547
547
|
if (!e.rowKey) return r;
|
|
548
548
|
const n = /* @__PURE__ */ new Set();
|
|
549
549
|
for (const o of t) {
|
|
550
|
-
const a =
|
|
550
|
+
const a = Ur(e, o), s = JSON.stringify(a.rowKey);
|
|
551
551
|
if (n.has(s)) throw new Error(`数据集 ${e.dataset} 的业务主键重复:${String(a.rowKey)}`);
|
|
552
552
|
n.add(s), r.set(o, a);
|
|
553
553
|
}
|
|
@@ -555,43 +555,43 @@ function ce(e, t) {
|
|
|
555
555
|
}
|
|
556
556
|
function qr(e, t, r, n, o) {
|
|
557
557
|
if (!e.grandTotal) return;
|
|
558
|
-
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 ?? [];
|
|
559
559
|
if (i.length === 0 && c.length === 0) {
|
|
560
560
|
n.warnings.push(`列表 ${e.id ?? ""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);
|
|
561
561
|
return;
|
|
562
562
|
}
|
|
563
|
-
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)]));
|
|
564
564
|
o.placeGridRow(l, "listgt", "grand-total");
|
|
565
565
|
}
|
|
566
|
-
function
|
|
566
|
+
function K(e) {
|
|
567
567
|
if (e?.aborted) {
|
|
568
568
|
const t = new Error("报表排版已取消");
|
|
569
569
|
throw t.name = "AbortError", t;
|
|
570
570
|
}
|
|
571
571
|
}
|
|
572
|
-
function
|
|
572
|
+
function de(e) {
|
|
573
573
|
const t = e.groups ?? (e.groupBy ? [e.groupBy] : []);
|
|
574
574
|
if (t.length > 16) throw new Error("列表最多支持 16 级分组");
|
|
575
575
|
return t;
|
|
576
576
|
}
|
|
577
|
-
function
|
|
578
|
-
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;
|
|
579
579
|
return n === 1 ? t : { ...t, columns: t.columns.map((o) => ({ ...o, widthMm: o.widthMm * n })) };
|
|
580
580
|
}
|
|
581
|
-
function
|
|
581
|
+
function Xr(e, t, r) {
|
|
582
582
|
const n = e.detail;
|
|
583
583
|
if (!n) return;
|
|
584
584
|
const o = /* @__PURE__ */ new Set();
|
|
585
585
|
for (const l of t) {
|
|
586
|
-
const d =
|
|
586
|
+
const d = ye(l[n.parentKey]);
|
|
587
587
|
if (o.has(d)) throw new Error("主从明细的主表关联键重复");
|
|
588
588
|
o.add(d);
|
|
589
589
|
}
|
|
590
590
|
const a = r.datasets[n.dataset] ?? [], s = /* @__PURE__ */ new Map(), i = [];
|
|
591
591
|
for (const l of a) {
|
|
592
592
|
const d = l[n.foreignKey];
|
|
593
|
-
if (!
|
|
594
|
-
const f =
|
|
593
|
+
if (!gt(d) && n.unmatched === "ignore") continue;
|
|
594
|
+
const f = ye(d);
|
|
595
595
|
if (!o.has(f)) {
|
|
596
596
|
if (n.unmatched !== "ignore") throw new Error(`明细数据集 ${n.dataset} 存在未关联的业务键`);
|
|
597
597
|
continue;
|
|
@@ -599,118 +599,118 @@ function Ur(e, t, r) {
|
|
|
599
599
|
const u = s.get(f);
|
|
600
600
|
u ? u.push(l) : s.set(f, [l]), i.push(l);
|
|
601
601
|
}
|
|
602
|
-
const c =
|
|
603
|
-
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) };
|
|
604
604
|
}
|
|
605
|
-
function
|
|
605
|
+
function gt(e) {
|
|
606
606
|
return typeof e == "string" && !!e.trim() || typeof e == "number" && Number.isFinite(e);
|
|
607
607
|
}
|
|
608
|
-
function
|
|
609
|
-
if (!
|
|
610
|
-
return
|
|
608
|
+
function ye(e) {
|
|
609
|
+
if (!gt(e)) throw new Error("主从关联键必须是非空字符串或有限数字");
|
|
610
|
+
return dt(e);
|
|
611
611
|
}
|
|
612
|
-
function*
|
|
612
|
+
function* Yr(e, t, r, n, o) {
|
|
613
613
|
if (!r) return;
|
|
614
|
-
const a = r.rows.get(
|
|
614
|
+
const a = r.rows.get(ye(t[e.detail.parentKey])) ?? [];
|
|
615
615
|
if (!a.length) return;
|
|
616
616
|
const s = { id: `${n.tableId}:detail`, columnKeys: r.list.columns.map((i) => i.field), title: e.detail.label };
|
|
617
|
-
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();
|
|
618
618
|
for (const i of a)
|
|
619
|
-
|
|
619
|
+
K(n.signal), o.placeGridRow({ ...Q(r.inter, i, n.measurer), table: s }, "listdr", "body", r.sources.get(i)), yield* n.takePages();
|
|
620
620
|
}
|
|
621
|
-
function
|
|
621
|
+
function ht(e) {
|
|
622
622
|
if (e.matrix || e.detail || e.groups?.length || e.groupBy || e.rowVisibleWhen) throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");
|
|
623
623
|
if (e.rowKey && e.rowKey !== e.tree.idField) throw new Error("树形布局的 rowKey 应与 idField 一致");
|
|
624
624
|
if (!e.columns.some((t) => t.field === e.tree.labelField && !t.hidden)) throw new Error("树形布局需要可见的标签列");
|
|
625
|
-
|
|
625
|
+
or(e.tree, e.computed);
|
|
626
626
|
}
|
|
627
|
-
function
|
|
628
|
-
|
|
629
|
-
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();
|
|
630
630
|
for (const c of n.entries)
|
|
631
631
|
s.set(c.row, a.get(c.original)), i.set(c.row, c);
|
|
632
632
|
return { list: o, rows: n.rows, sources: s, treeRows: i, totalRows: n.leaves };
|
|
633
633
|
}
|
|
634
|
-
function
|
|
634
|
+
function Zr(e, t) {
|
|
635
635
|
if (e.cardinality === "record") {
|
|
636
636
|
if (t.length > 1) throw new Error(`单记录区域 ${e.id ?? e.dataset} 仅允许 0 或 1 行数据`);
|
|
637
637
|
if (e.tree || e.matrix || e.detail || e.groups?.length || e.groupBy || e.grandTotal || e.rowVisibleWhen) throw new Error("单记录区域不能配置树、矩阵、主从、分组、总计或行过滤");
|
|
638
638
|
if (!t.length) return { list: { ...e, columns: e.columns.map((r) => ({ ...r, editable: !1 })) }, rows: [{}], sources: /* @__PURE__ */ new Map() };
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
|
-
function
|
|
641
|
+
function pt(e, t, r) {
|
|
642
642
|
const n = r.prepared.get(e);
|
|
643
643
|
if (n) return n;
|
|
644
|
-
const o =
|
|
644
|
+
const o = Zr(e, t);
|
|
645
645
|
if (o)
|
|
646
646
|
return r.prepared.set(e, o), o;
|
|
647
647
|
if (e.tree) {
|
|
648
|
-
const c =
|
|
648
|
+
const c = Qr(e, t, r);
|
|
649
649
|
return r.prepared.set(e, c), c;
|
|
650
650
|
}
|
|
651
|
-
let a = e.computed?.length ?
|
|
651
|
+
let a = e.computed?.length ? Re(t, { fields: e.computed, signal: r.signal, formula: r.formula }).rows : t;
|
|
652
652
|
const s = a === t ? void 0 : new Map(a.map((c, l) => [c, t[l]]));
|
|
653
|
-
e.rowVisibleWhen && (a = a.filter(
|
|
654
|
-
const i =
|
|
653
|
+
e.rowVisibleWhen && (a = a.filter(W(e.rowVisibleWhen)));
|
|
654
|
+
const i = br(e, a);
|
|
655
655
|
if (!e.matrix) {
|
|
656
|
-
const c =
|
|
656
|
+
const c = le(e, s ? a.map((l) => s.get(l)) : a);
|
|
657
657
|
i.sources = s ? new Map(a.map((l) => [l, c.get(s.get(l))])) : c;
|
|
658
658
|
}
|
|
659
659
|
return r.prepared.set(e, i), i;
|
|
660
660
|
}
|
|
661
|
-
function
|
|
661
|
+
function en(e, t, r, n) {
|
|
662
662
|
if (!n.flow) return;
|
|
663
|
-
const { current: o, templatePage: a } = n, s = Math.max(o.marginTopMm,
|
|
664
|
-
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)));
|
|
665
665
|
}
|
|
666
|
-
function*
|
|
667
|
-
const n =
|
|
666
|
+
function* tn(e, t, r) {
|
|
667
|
+
const n = pt(e, t, r), o = n.rows;
|
|
668
668
|
e = n.list, e.layout === "wide" && (r.current.widthMm = Math.max(r.current.widthMm, e.leftMm + e.widthMm + r.current.marginRightMm));
|
|
669
|
-
const a = n.sources ??
|
|
670
|
-
|
|
671
|
-
const l =
|
|
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
672
|
let u;
|
|
673
|
-
for (const m of
|
|
674
|
-
if (
|
|
675
|
-
l.placeGridRow(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
676
|
else if (m.kind === "groupHeader") {
|
|
677
677
|
const g = f(m.depth, m.firstRow, m.label, m.group.headerStyle);
|
|
678
678
|
if (m.group.keepWithNext !== !1) {
|
|
679
|
-
u ??=
|
|
679
|
+
u ??= Q(c, m.firstRow, r.measurer);
|
|
680
680
|
let b = 0;
|
|
681
681
|
for (let y = m.depth + 1; y < i.length; y++) {
|
|
682
|
-
const
|
|
683
|
-
b += f(y, m.firstRow, h,
|
|
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
684
|
}
|
|
685
685
|
l.keepTogether(g.heightMm + b + u.heightMm);
|
|
686
686
|
}
|
|
687
687
|
l.placeGridRow(g, "listg", "group-header"), m.group.repeatHeader && l.setGroupHeader(m.depth, g);
|
|
688
688
|
} else if (m.kind === "subtotal") {
|
|
689
|
-
const g = m.group.subtotal ?? [], b = m.group.aggregates ?? [], y =
|
|
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
690
|
l.placeGridRow(y, "listst", "subtotal");
|
|
691
691
|
} else l.setGroupHeader(m.depth);
|
|
692
692
|
yield* r.takePages();
|
|
693
693
|
}
|
|
694
694
|
qr(s, n.totalRows ?? o, c, r, l), r.finished?.(l.bottom()), yield* r.takePages();
|
|
695
695
|
}
|
|
696
|
-
function
|
|
696
|
+
function ue(e) {
|
|
697
697
|
return e.kind !== "list" && (e.pageAnchor !== void 0 || e.kind === "text" && typeof e.text == "string" && (e.text.includes("{page}") || e.text.includes("{totalPages}")));
|
|
698
698
|
}
|
|
699
|
-
function
|
|
699
|
+
function fe(e, t) {
|
|
700
700
|
return {
|
|
701
701
|
...e,
|
|
702
702
|
...e.text === void 0 ? {} : { text: t(e.text) },
|
|
703
703
|
...e.lines ? { lines: e.lines.map(t) } : {},
|
|
704
704
|
...e.richParagraphs ? { richParagraphs: e.richParagraphs.map((r) => ({ ...r, segments: r.segments.map((n) => ({ ...n, ...n.text === void 0 ? {} : { text: t(n.text) } })) })) } : {},
|
|
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) =>
|
|
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)) } } : {}
|
|
706
706
|
};
|
|
707
707
|
}
|
|
708
|
-
function
|
|
708
|
+
function rn(e) {
|
|
709
709
|
let t = !1;
|
|
710
|
-
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));
|
|
711
711
|
return t;
|
|
712
712
|
}
|
|
713
|
-
function
|
|
713
|
+
function nn(e, t, r, n, o, a) {
|
|
714
714
|
const s = {
|
|
715
715
|
pageWidthMm: t.widthMm,
|
|
716
716
|
pageHeightMm: t.heightMm,
|
|
@@ -725,38 +725,38 @@ function rn(e, t, r, n, o, a) {
|
|
|
725
725
|
const l = c.replace(/\{page\}/g, String(n));
|
|
726
726
|
return a === void 0 ? l : l.replace(/\{totalPages\}/g, String(a));
|
|
727
727
|
};
|
|
728
|
-
for (const c of r) s.components.push(
|
|
728
|
+
for (const c of r) s.components.push(fe(c, i));
|
|
729
729
|
if (e.layout === "wide") {
|
|
730
730
|
const c = s.components.reduce((l, d) => Math.max(l, d.topMm + d.heightMm), 0);
|
|
731
731
|
s.marginBottomMm = o ? e.marginBottomMm ?? 0 : 0, s.pageHeightMm = Math.max(1, c + s.marginBottomMm);
|
|
732
732
|
}
|
|
733
733
|
return s;
|
|
734
734
|
}
|
|
735
|
-
function
|
|
736
|
-
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);
|
|
737
737
|
}
|
|
738
|
-
function
|
|
739
|
-
return e.grid ?
|
|
738
|
+
function wt(e) {
|
|
739
|
+
return e.grid ? Ne(e.grid) : 0;
|
|
740
740
|
}
|
|
741
|
-
function
|
|
741
|
+
function me(e) {
|
|
742
742
|
for (const t of ["maxPages", "maxCells", "knownTotalPages"]) if (e[t] !== void 0 && (!Number.isSafeInteger(e[t]) || e[t] < 1)) throw new RangeError(`${t} 应为正安全整数`);
|
|
743
|
-
|
|
743
|
+
Ie(e.maxChartComponents);
|
|
744
744
|
}
|
|
745
|
-
function
|
|
746
|
-
const r =
|
|
747
|
-
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);
|
|
748
748
|
}
|
|
749
|
-
function*
|
|
749
|
+
function* an(e) {
|
|
750
750
|
const { templatePage: t, current: r } = e, n = new Map(t.components.map((a, s) => [a, s])), o = (a, s, i) => {
|
|
751
751
|
const c = e.datasets[a.dataset];
|
|
752
|
-
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 });
|
|
753
753
|
};
|
|
754
754
|
if (t.flow) {
|
|
755
|
-
yield*
|
|
755
|
+
yield* xr({
|
|
756
756
|
page: t,
|
|
757
|
-
active: () =>
|
|
758
|
-
top: () => Math.max(r.marginTopMm,
|
|
759
|
-
bottom: () =>
|
|
757
|
+
active: () => K(e.signal),
|
|
758
|
+
top: () => Math.max(r.marginTopMm, Y(t)),
|
|
759
|
+
bottom: () => se(t, r),
|
|
760
760
|
append: (a) => {
|
|
761
761
|
r.components.push(...e.resolveChart(a));
|
|
762
762
|
},
|
|
@@ -764,31 +764,31 @@ function* on(e) {
|
|
|
764
764
|
e.pushCurrent(), r.components = [], r.heightMm = t.heightMm, t.layout === "wide" && (r.marginTopMm = 0, r.marginBottomMm = 0);
|
|
765
765
|
},
|
|
766
766
|
takePages: e.takePages,
|
|
767
|
-
height: (a) =>
|
|
767
|
+
height: (a) => on(a, e),
|
|
768
768
|
list: o
|
|
769
769
|
});
|
|
770
770
|
return;
|
|
771
771
|
}
|
|
772
772
|
for (const a of t.components)
|
|
773
|
-
|
|
773
|
+
ue(a) || (a.kind === "list" ? yield* o(a) : r.components.push(...e.resolveChart(a)));
|
|
774
774
|
}
|
|
775
|
-
function*
|
|
775
|
+
function* Z(e, t, r, n, o, a = /* @__PURE__ */ new WeakMap(), s) {
|
|
776
776
|
let i = 0, c = 0, l = 0;
|
|
777
|
-
const d =
|
|
778
|
-
for (const { pageIndex: m, page: g } of
|
|
779
|
-
|
|
780
|
-
const b =
|
|
781
|
-
let
|
|
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
782
|
const h = (T = !1) => {
|
|
783
|
-
if (
|
|
784
|
-
if (r.maxCells !== void 0 && (l += [...b.components, ...y].reduce((
|
|
785
|
-
throw new
|
|
786
|
-
|
|
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));
|
|
787
787
|
}, S = () => {
|
|
788
|
-
const T =
|
|
789
|
-
return
|
|
788
|
+
const T = p;
|
|
789
|
+
return p = [], T;
|
|
790
790
|
};
|
|
791
|
-
yield*
|
|
791
|
+
yield* an({
|
|
792
792
|
templatePage: g,
|
|
793
793
|
current: b,
|
|
794
794
|
warnings: n,
|
|
@@ -807,130 +807,130 @@ function* Y(e, t, r, n, o, a = /* @__PURE__ */ new WeakMap(), s) {
|
|
|
807
807
|
}
|
|
808
808
|
s && (s.chartComponents = f.used());
|
|
809
809
|
}
|
|
810
|
-
function
|
|
811
|
-
|
|
810
|
+
function $o(e, t, r = {}) {
|
|
811
|
+
me(r);
|
|
812
812
|
let n = 0;
|
|
813
|
-
for (const o of
|
|
813
|
+
for (const o of Z(e, t, { ...r, onWarning: void 0 }, [])) n++;
|
|
814
814
|
return n;
|
|
815
815
|
}
|
|
816
|
-
function*
|
|
817
|
-
yield*
|
|
816
|
+
function* Oo(e, t, r = {}) {
|
|
817
|
+
yield* sn(e, t, r);
|
|
818
818
|
}
|
|
819
|
-
function*
|
|
820
|
-
|
|
821
|
-
const o =
|
|
819
|
+
function* sn(e, t, r, n) {
|
|
820
|
+
me(r);
|
|
821
|
+
const o = rn(e), a = /* @__PURE__ */ new WeakMap();
|
|
822
822
|
let s = r.knownTotalPages;
|
|
823
823
|
if (o && s === void 0) {
|
|
824
824
|
s = 0;
|
|
825
|
-
for (const l of
|
|
825
|
+
for (const l of Z(e, t, r, [], void 0, a)) s++;
|
|
826
826
|
}
|
|
827
827
|
const i = [];
|
|
828
828
|
let c = 0;
|
|
829
|
-
for (const l of
|
|
829
|
+
for (const l of Z(e, t, r, i, s, a, n)) {
|
|
830
830
|
for (; c < i.length; c++) r.onWarning?.(i[c]);
|
|
831
831
|
yield l;
|
|
832
832
|
}
|
|
833
833
|
}
|
|
834
|
-
function
|
|
834
|
+
function yt(e, t, r = {}) {
|
|
835
835
|
const n = typeof r == "number" ? { mmPerRow: r } : r;
|
|
836
|
-
|
|
837
|
-
const o = [], a = { chartComponents: 0 }, s = [...
|
|
838
|
-
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);
|
|
839
839
|
}
|
|
840
|
-
async function
|
|
841
|
-
|
|
840
|
+
async function bt(e, t, r = {}) {
|
|
841
|
+
me(r), K(r.signal);
|
|
842
842
|
const n = [], o = [], a = { chartComponents: 0 };
|
|
843
843
|
let s = performance.now(), i = 0;
|
|
844
|
-
for (const c of
|
|
845
|
-
o.push(c), (++i >= 8 || performance.now() - s >= 8) && (await new Promise((l) => setTimeout(l, 0)),
|
|
846
|
-
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);
|
|
847
847
|
}
|
|
848
|
-
function
|
|
849
|
-
for (const a of r) a.components = a.components.map((s) =>
|
|
850
|
-
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 };
|
|
851
851
|
}
|
|
852
|
-
function
|
|
852
|
+
function cn(e) {
|
|
853
853
|
const t = e.columns.find((a) => !a.hidden)?.field;
|
|
854
854
|
if (!t) return { groups: 0, total: 0 };
|
|
855
|
-
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;
|
|
856
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)) };
|
|
857
857
|
}
|
|
858
|
-
function
|
|
859
|
-
|
|
860
|
-
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;
|
|
861
861
|
return n.length * o + a + +!!e.grandTotal * 2 * o;
|
|
862
862
|
}
|
|
863
|
-
function
|
|
864
|
-
if (e.tree) return
|
|
863
|
+
function Fo(e, t, r = {}) {
|
|
864
|
+
if (e.tree) return ln(e, t, r.signal);
|
|
865
865
|
if (e.matrix) {
|
|
866
866
|
let c = t[e.dataset] ?? [];
|
|
867
|
-
e.computed?.length && (c =
|
|
868
|
-
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);
|
|
869
869
|
return l.cells + (e.header === !1 ? 0 : l.columnCount * (e.matrix.hierarchy ? e.matrix.columnFields.length + 1 : 1));
|
|
870
870
|
}
|
|
871
|
-
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);
|
|
872
872
|
let i = (n * (1 + 2 * a + s.groups) + +!!e.grandTotal * (1 + s.total)) * o;
|
|
873
|
-
if (i += e.header === !1 ? 0 : e.headerGrid ?
|
|
873
|
+
if (i += e.header === !1 ? 0 : e.headerGrid ? Ne(e.headerGrid) : o, e.cardinality === "record" && n === 0 && (i += o), e.detail) {
|
|
874
874
|
const c = t[e.detail.dataset]?.length ?? 0, l = e.detail.columns.filter((d) => !d.hidden).length;
|
|
875
875
|
i += (c + n * (+(e.detail.header !== !1) + +!!e.detail.label)) * l;
|
|
876
876
|
}
|
|
877
877
|
if (!Number.isSafeInteger(i)) throw new RangeError("报表单元格估算超出安全整数预算");
|
|
878
878
|
return i;
|
|
879
879
|
}
|
|
880
|
-
class
|
|
880
|
+
class dn extends Error {
|
|
881
881
|
constructor(t) {
|
|
882
882
|
super(t.map((r) => r.message).join(";")), this.issues = t, this.name = "ReportValidationError";
|
|
883
883
|
}
|
|
884
884
|
}
|
|
885
|
-
function
|
|
885
|
+
function Je(e, t, r) {
|
|
886
886
|
if (!Number.isSafeInteger(e) || e < 1 || e > r) throw new Error(`校验 ${t} 超出预算`);
|
|
887
887
|
return e;
|
|
888
888
|
}
|
|
889
|
-
function
|
|
889
|
+
function un(e) {
|
|
890
890
|
if (e.aggregates && e.scope !== "dataset") throw new Error("仅数据集规则允许汇总");
|
|
891
891
|
if (e.aggregates && (!Array.isArray(e.aggregates) || e.aggregates.length > 64)) throw new Error("校验汇总最多 64 项");
|
|
892
892
|
const t = /* @__PURE__ */ new Set();
|
|
893
893
|
for (const r of e.aggregates ?? []) {
|
|
894
|
-
if (
|
|
895
|
-
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 });
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
|
-
function
|
|
898
|
+
function Mt(e) {
|
|
899
899
|
if (!Array.isArray(e) || e.length > 256 || Object.keys(e).length !== e.length) throw new Error("校验规则最多 256 条且不允许空位");
|
|
900
900
|
const t = /* @__PURE__ */ new Set();
|
|
901
901
|
return e.map((r) => {
|
|
902
902
|
if (!r || typeof r != "object") throw new Error("校验规则应为声明式对象");
|
|
903
|
-
if (
|
|
904
|
-
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("校验规则需要有界提示文案");
|
|
905
905
|
if (r.severity !== void 0 && !["error", "warning"].includes(r.severity)) throw new Error("未知校验严重程度");
|
|
906
906
|
if (r.scope !== void 0 && !["row", "dataset"].includes(r.scope)) throw new Error("未知校验范围");
|
|
907
|
-
|
|
908
|
-
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;
|
|
909
909
|
return { rule: r, assert: o, when: a, checks: n.nodes };
|
|
910
910
|
});
|
|
911
911
|
}
|
|
912
|
-
function
|
|
912
|
+
function Ue(e) {
|
|
913
913
|
if (e?.aborted) {
|
|
914
914
|
const t = new Error("报表校验已取消");
|
|
915
915
|
throw t.name = "AbortError", t;
|
|
916
916
|
}
|
|
917
917
|
}
|
|
918
|
-
function
|
|
918
|
+
function fn(e, t, r, n) {
|
|
919
919
|
const o = n && Object.prototype.hasOwnProperty.call(t, n) ? t[n] : void 0;
|
|
920
920
|
if (o !== void 0 && typeof o != "string" && !(typeof o == "number" && Number.isFinite(o))) throw new Error("校验定位需要稳定的文本或数值业务键");
|
|
921
921
|
return { ruleId: e.id, rowIndex: r, ...o === void 0 ? {} : { rowKey: o }, field: e.field, severity: e.severity ?? "error", message: e.message };
|
|
922
922
|
}
|
|
923
|
-
function
|
|
923
|
+
function mn(e, t) {
|
|
924
924
|
const r = t.computed?.length ? { fields: t.computed, formula: t.formula, signal: t.signal } : void 0;
|
|
925
925
|
if (t.tree) {
|
|
926
|
-
const o =
|
|
926
|
+
const o = ot(e, t.tree, { signal: t.signal, computed: r });
|
|
927
927
|
if (o.rows.length > 1e5) throw new Error("校验展开后数据最多 100000 行");
|
|
928
928
|
return { rows: o.rows, summaryRows: o.leaves, rowKey: t.tree.idField };
|
|
929
929
|
}
|
|
930
|
-
const n = r ?
|
|
930
|
+
const n = r ? Re(e, r).rows : e;
|
|
931
931
|
return { rows: n, summaryRows: n, rowKey: t.rowKey };
|
|
932
932
|
}
|
|
933
|
-
function
|
|
933
|
+
function gn(e, t) {
|
|
934
934
|
const r = /* @__PURE__ */ new Set();
|
|
935
935
|
e.forEach((n) => {
|
|
936
936
|
if (!n || typeof n != "object" || Array.isArray(n)) throw new Error("校验数据行应为对象");
|
|
@@ -941,49 +941,49 @@ function mn(e, t) {
|
|
|
941
941
|
r.add(o);
|
|
942
942
|
});
|
|
943
943
|
}
|
|
944
|
-
function
|
|
945
|
-
return
|
|
944
|
+
function Ao(e, t) {
|
|
945
|
+
return St(e, t, { checks: 0 });
|
|
946
946
|
}
|
|
947
|
-
function
|
|
947
|
+
function St(e, t, r) {
|
|
948
948
|
if (!Array.isArray(e) || e.length > 1e5) throw new Error("校验数据最多 100000 行");
|
|
949
|
-
|
|
950
|
-
const n =
|
|
951
|
-
t.rowKey !== void 0 &&
|
|
952
|
-
const a =
|
|
953
|
-
|
|
954
|
-
const l =
|
|
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
955
|
if (r.checks += d, r.checks > n) throw new Error("整批校验超出 maxChecks 预算");
|
|
956
956
|
const f = [];
|
|
957
957
|
for (const u of l)
|
|
958
|
-
(u.rule.scope === "dataset" ? [Object.fromEntries((u.rule.aggregates ?? []).map((g) => [g.field,
|
|
959
|
-
if (
|
|
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
960
|
if (!(u.when && !u.when(g) || u.assert(g))) {
|
|
961
961
|
if (f.length >= o) throw new Error("校验问题超出 maxIssues 预算,请缩小范围");
|
|
962
|
-
f.push(
|
|
962
|
+
f.push(fn(u.rule, g, u.rule.scope === "dataset" ? void 0 : b, u.rule.scope === "dataset" ? void 0 : c));
|
|
963
963
|
}
|
|
964
964
|
});
|
|
965
965
|
return f;
|
|
966
966
|
}
|
|
967
|
-
function
|
|
967
|
+
function hn(e, t = "allow") {
|
|
968
968
|
if (!["allow", "block"].includes(t)) throw new Error("未知校验警告策略");
|
|
969
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("校验问题结构无效");
|
|
970
|
-
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);
|
|
971
971
|
}
|
|
972
|
-
function
|
|
972
|
+
function qe(e, t, r) {
|
|
973
973
|
const n = e.get(t);
|
|
974
974
|
if (n && JSON.stringify(n) !== JSON.stringify(r)) throw new Error("同一数据集的校验计算/业务键存在歧义,请统一绑定");
|
|
975
975
|
e.set(t, r);
|
|
976
976
|
}
|
|
977
|
-
function
|
|
978
|
-
|
|
977
|
+
function pn(e, t, r, n = []) {
|
|
978
|
+
Mt(t.rules);
|
|
979
979
|
const o = [], a = { checks: 0 };
|
|
980
980
|
for (const [i, c] of e.entries()) {
|
|
981
981
|
const l = /* @__PURE__ */ new Map();
|
|
982
982
|
for (const d of c.template.pages) for (const f of d.components)
|
|
983
|
-
f.kind === "list" && (
|
|
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
984
|
for (const [d, f] of l) {
|
|
985
985
|
const u = t.rules.filter((m) => !m.dataset || m.dataset === d);
|
|
986
|
-
if (u.length && (o.push(...
|
|
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)))
|
|
987
987
|
throw new Error("整批候选校验问题超出 maxIssues 预算");
|
|
988
988
|
}
|
|
989
989
|
}
|
|
@@ -991,31 +991,31 @@ function hn(e, t, r, n = []) {
|
|
|
991
991
|
if (t.rules.some((i) => i.dataset && !s.has(i.dataset))) throw new Error("校验目标数据集不存在");
|
|
992
992
|
return o;
|
|
993
993
|
}
|
|
994
|
-
function
|
|
994
|
+
function xt(e) {
|
|
995
995
|
return !e || typeof e != "object" ? !1 : [e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex].every((t) => Number.isInteger(t) && t >= 0);
|
|
996
996
|
}
|
|
997
|
-
function
|
|
997
|
+
function Pt(e, t, r) {
|
|
998
998
|
const n = e.grid;
|
|
999
999
|
if (!n) return null;
|
|
1000
1000
|
const o = n.cells[t];
|
|
1001
1001
|
if (!o) return null;
|
|
1002
|
-
const s =
|
|
1002
|
+
const s = q(n, e.widthMm, e.heightMm).cells.filter((c) => c.ri === t).findIndex((c) => c.ci === r), i = o[s];
|
|
1003
1003
|
return i ? { cell: i, sourceColumnIndex: s } : null;
|
|
1004
1004
|
}
|
|
1005
|
-
function
|
|
1005
|
+
function wn(e) {
|
|
1006
1006
|
return e.value !== void 0 ? e.value : e.rawText ?? e.text ?? null;
|
|
1007
1007
|
}
|
|
1008
|
-
function
|
|
1008
|
+
function yn(e, t) {
|
|
1009
1009
|
return e.valueType ? e.valueType : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t === null && e.numberFormat && /[0#?]/.test(e.numberFormat) ? "number" : "text";
|
|
1010
1010
|
}
|
|
1011
|
-
function
|
|
1011
|
+
function bn(e, t) {
|
|
1012
1012
|
if (e.derived) return "derived";
|
|
1013
1013
|
if (e.editable === !1) return "cell";
|
|
1014
1014
|
if (e.formula !== void 0) return "formula";
|
|
1015
1015
|
if (e.children?.length || e.richParagraphs?.length) return "complex";
|
|
1016
1016
|
if (t.table && t.table.role !== "body" && e.editable !== !0) return "structure";
|
|
1017
1017
|
}
|
|
1018
|
-
function
|
|
1018
|
+
function vn(e, t) {
|
|
1019
1019
|
const r = e.table;
|
|
1020
1020
|
if (r)
|
|
1021
1021
|
return {
|
|
@@ -1025,41 +1025,41 @@ function bn(e, t) {
|
|
|
1025
1025
|
columnKey: r.columnKeys[t.columnIndex]
|
|
1026
1026
|
};
|
|
1027
1027
|
}
|
|
1028
|
-
function
|
|
1028
|
+
function Mn(e, t, r) {
|
|
1029
1029
|
if (e.derived) return;
|
|
1030
1030
|
if (e.source) return { ...e.source };
|
|
1031
1031
|
const n = t.table?.source, o = t.table?.columnKeys[r.columnIndex];
|
|
1032
1032
|
if (!(!n || n.rowKey === void 0 || o === void 0))
|
|
1033
1033
|
return { ...n, rowKey: n.rowKey, field: o };
|
|
1034
1034
|
}
|
|
1035
|
-
function
|
|
1036
|
-
const n =
|
|
1035
|
+
function be(e, t, r) {
|
|
1036
|
+
const n = wn(r), o = bn(r, e);
|
|
1037
1037
|
return {
|
|
1038
1038
|
address: { ...t },
|
|
1039
1039
|
cell: r,
|
|
1040
1040
|
component: e,
|
|
1041
1041
|
value: n,
|
|
1042
|
-
valueType:
|
|
1043
|
-
table:
|
|
1044
|
-
source:
|
|
1042
|
+
valueType: yn(r, n),
|
|
1043
|
+
table: vn(e, t),
|
|
1044
|
+
source: Mn(r, e, t),
|
|
1045
1045
|
editable: o === void 0,
|
|
1046
1046
|
readOnlyReason: o
|
|
1047
1047
|
};
|
|
1048
1048
|
}
|
|
1049
|
-
function
|
|
1050
|
-
if (!
|
|
1049
|
+
function Le(e, t) {
|
|
1050
|
+
if (!xt(t)) return null;
|
|
1051
1051
|
const r = e.pages[t.pageIndex]?.components[t.componentIndex];
|
|
1052
1052
|
if (!r) return null;
|
|
1053
|
-
const n =
|
|
1054
|
-
return n ?
|
|
1053
|
+
const n = Pt(r, t.rowIndex, t.columnIndex);
|
|
1054
|
+
return n ? be(r, t, n.cell) : null;
|
|
1055
1055
|
}
|
|
1056
|
-
function
|
|
1056
|
+
function Sn(e, t = !0) {
|
|
1057
1057
|
const r = /* @__PURE__ */ new Map();
|
|
1058
1058
|
function n(i) {
|
|
1059
1059
|
if (!i.grid) return;
|
|
1060
1060
|
let c = r.get(i);
|
|
1061
1061
|
if (!c) {
|
|
1062
|
-
const l =
|
|
1062
|
+
const l = q(i.grid, i.widthMm, i.heightMm), d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
1063
1063
|
for (const u of l.cells) {
|
|
1064
1064
|
const m = d.get(u.ri) ?? 0;
|
|
1065
1065
|
d.set(u.ri, m + 1);
|
|
@@ -1071,73 +1071,73 @@ function Mn(e, t = !0) {
|
|
|
1071
1071
|
return c;
|
|
1072
1072
|
}
|
|
1073
1073
|
function o(i) {
|
|
1074
|
-
if (!
|
|
1074
|
+
if (!xt(i)) return null;
|
|
1075
1075
|
const c = e.pages[i.pageIndex]?.components[i.componentIndex];
|
|
1076
1076
|
if (!c) return null;
|
|
1077
1077
|
const l = n(c)?.cells.get(`${i.rowIndex}:${i.columnIndex}`);
|
|
1078
|
-
return l ?
|
|
1078
|
+
return l ? be(c, i, l) : null;
|
|
1079
1079
|
}
|
|
1080
1080
|
function* a(i, c) {
|
|
1081
1081
|
const l = e.pages[i]?.components[c], d = l && n(l);
|
|
1082
1082
|
if (d)
|
|
1083
1083
|
for (const f of s(l).cells) {
|
|
1084
1084
|
const u = d.cells.get(`${f.ri}:${f.ci}`);
|
|
1085
|
-
u && (yield
|
|
1085
|
+
u && (yield be(l, { pageIndex: i, componentIndex: c, rowIndex: f.ri, columnIndex: f.ci }, u));
|
|
1086
1086
|
}
|
|
1087
1087
|
}
|
|
1088
1088
|
function s(i) {
|
|
1089
1089
|
const c = n(i);
|
|
1090
|
-
return c && (c.layout ??
|
|
1090
|
+
return c && (c.layout ?? q(i.grid, i.widthMm, i.heightMm));
|
|
1091
1091
|
}
|
|
1092
1092
|
return { resolve: o, entries: a, layout: s };
|
|
1093
1093
|
}
|
|
1094
|
-
function
|
|
1095
|
-
return
|
|
1094
|
+
function z(e) {
|
|
1095
|
+
return Sn(e, !1).resolve;
|
|
1096
1096
|
}
|
|
1097
|
-
class
|
|
1097
|
+
class v extends Error {
|
|
1098
1098
|
constructor(t) {
|
|
1099
1099
|
super(`Invalid report cell edit: ${t}`), this.code = t, this.name = "ReportCellEditError";
|
|
1100
1100
|
}
|
|
1101
1101
|
}
|
|
1102
|
-
function
|
|
1102
|
+
function xn(e, t) {
|
|
1103
1103
|
let r = e.trim();
|
|
1104
1104
|
const n = t && r.endsWith("%");
|
|
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
|
|
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");
|
|
1106
1106
|
return Number(r) / (n ? 100 : 1);
|
|
1107
1107
|
}
|
|
1108
|
-
function
|
|
1108
|
+
function Pn(e, t) {
|
|
1109
1109
|
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
1110
|
-
if (typeof e != "string" && typeof e != "number") throw new
|
|
1111
|
-
const r = typeof e == "number" ? e :
|
|
1112
|
-
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");
|
|
1113
1113
|
return r;
|
|
1114
1114
|
}
|
|
1115
|
-
function
|
|
1115
|
+
function kn(e) {
|
|
1116
1116
|
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
1117
1117
|
if (typeof e == "boolean") return e;
|
|
1118
1118
|
const t = String(e).trim().toLowerCase();
|
|
1119
1119
|
if (["true", "yes", "是", "1"].includes(t)) return !0;
|
|
1120
1120
|
if (["false", "no", "否", "0"].includes(t)) return !1;
|
|
1121
|
-
throw new
|
|
1121
|
+
throw new v("boolean");
|
|
1122
1122
|
}
|
|
1123
|
-
function
|
|
1124
|
-
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);
|
|
1125
1125
|
}
|
|
1126
|
-
function
|
|
1126
|
+
function Cn(e, t) {
|
|
1127
1127
|
const r = t.cell.text, o = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((a) => a.includes(r ?? ""));
|
|
1128
1128
|
return o ? o[e ? 0 : 1] : String(e);
|
|
1129
1129
|
}
|
|
1130
|
-
function
|
|
1131
|
-
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);
|
|
1132
1132
|
}
|
|
1133
|
-
function
|
|
1134
|
-
const n =
|
|
1135
|
-
if (!n) throw new
|
|
1136
|
-
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);
|
|
1137
1137
|
}
|
|
1138
|
-
function
|
|
1139
|
-
if (!e.editable) throw new
|
|
1140
|
-
const r =
|
|
1138
|
+
function ne(e, t) {
|
|
1139
|
+
if (!e.editable) throw new v("readonly");
|
|
1140
|
+
const r = kt(e, t);
|
|
1141
1141
|
return {
|
|
1142
1142
|
address: { ...e.address },
|
|
1143
1143
|
table: e.table,
|
|
@@ -1145,18 +1145,18 @@ function ee(e, t) {
|
|
|
1145
1145
|
previousValue: e.value,
|
|
1146
1146
|
previousText: e.cell.text ?? "",
|
|
1147
1147
|
value: r,
|
|
1148
|
-
text:
|
|
1148
|
+
text: re(e, r)
|
|
1149
1149
|
};
|
|
1150
1150
|
}
|
|
1151
1151
|
function Tn(e, t) {
|
|
1152
1152
|
const r = e.table, n = t.table;
|
|
1153
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;
|
|
1154
1154
|
}
|
|
1155
|
-
function
|
|
1156
|
-
const n = e.grid, { rowIndex: o, columnIndex: a } = t.address, s =
|
|
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
1157
|
return c[s.sourceColumnIndex] = d, i[o] = c, { ...e, grid: { ...n, cells: i } };
|
|
1158
1158
|
}
|
|
1159
|
-
function
|
|
1159
|
+
function Rn(e, t) {
|
|
1160
1160
|
const r = e.table?.columnKeys, n = t.table?.columnKey;
|
|
1161
1161
|
return r && n !== void 0 ? r.flatMap((o, a) => o === n ? [a] : []) : [];
|
|
1162
1162
|
}
|
|
@@ -1166,52 +1166,52 @@ function En(e, t, r, n, o, a) {
|
|
|
1166
1166
|
const c = i.rowIndex - s.rowIndex;
|
|
1167
1167
|
if (c < 0 || c >= t.grid.cells.length) return t;
|
|
1168
1168
|
let l = t;
|
|
1169
|
-
for (const d of
|
|
1170
|
-
const f =
|
|
1171
|
-
f?.editable && Tn(o, f) && (l =
|
|
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));
|
|
1172
1172
|
}
|
|
1173
1173
|
return l;
|
|
1174
1174
|
}
|
|
1175
|
-
function
|
|
1175
|
+
function In(e, t, r, n, o, a) {
|
|
1176
1176
|
const s = o.address;
|
|
1177
|
-
return o.table?.columnKey !== void 0 ? En(e, t, r, n, o, a) : s.pageIndex === r && s.componentIndex === n ?
|
|
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;
|
|
1178
1178
|
}
|
|
1179
|
-
function
|
|
1179
|
+
function He(e, t) {
|
|
1180
1180
|
const r = t.source;
|
|
1181
1181
|
if (!r) return !1;
|
|
1182
1182
|
const n = e.source;
|
|
1183
1183
|
return !n || ["sourceScope", "datasetId", "rowKey", "field", "revision", "sourceToken"].some((o) => !Object.is(n[o], r[o]));
|
|
1184
1184
|
}
|
|
1185
|
-
function
|
|
1186
|
-
const r =
|
|
1187
|
-
if (!r) throw new
|
|
1188
|
-
if (!r.editable) throw new
|
|
1189
|
-
if (
|
|
1190
|
-
if (!Object.is(r.value, t.previousValue) || (r.cell.text ?? "") !== t.previousText) throw new
|
|
1191
|
-
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) };
|
|
1192
1192
|
if (Object.is(n, r.value) && o.text === r.cell.text) return e;
|
|
1193
1193
|
const a = e.pages.map((s, i) => {
|
|
1194
|
-
const c = s.components.map((l, d) =>
|
|
1194
|
+
const c = s.components.map((l, d) => In(e, l, i, d, r, o));
|
|
1195
1195
|
return c.every((l, d) => l === s.components[d]) ? s : { ...s, components: c };
|
|
1196
1196
|
});
|
|
1197
1197
|
return { ...e, pages: a };
|
|
1198
1198
|
}
|
|
1199
|
-
function
|
|
1199
|
+
function Tt(e) {
|
|
1200
1200
|
const t = [];
|
|
1201
1201
|
for (const r of e.template.pages) for (const n of r.components)
|
|
1202
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] ?? [] } }));
|
|
1203
1203
|
return t;
|
|
1204
1204
|
}
|
|
1205
|
-
function
|
|
1205
|
+
function _(e) {
|
|
1206
1206
|
return JSON.stringify([e.sourceScope, e.datasetId]);
|
|
1207
1207
|
}
|
|
1208
|
-
function
|
|
1208
|
+
function ce(e) {
|
|
1209
1209
|
return JSON.stringify([e.sourceScope, e.datasetId, e.rowKey]);
|
|
1210
1210
|
}
|
|
1211
|
-
function
|
|
1211
|
+
function Rt(e) {
|
|
1212
1212
|
const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
|
|
1213
1213
|
return e.forEach((n, o) => {
|
|
1214
|
-
for (const a of
|
|
1214
|
+
for (const a of Tt(n)) {
|
|
1215
1215
|
if (!a.rowKey) continue;
|
|
1216
1216
|
const s = a.relation, i = s ? new Set(s.parentRows.map((c) => JSON.stringify(c[s.detail.parentKey]))) : void 0;
|
|
1217
1217
|
(n.datasets[a.dataset] ?? []).forEach((c, l) => {
|
|
@@ -1221,18 +1221,18 @@ function Tt(e) {
|
|
|
1221
1221
|
const f = `${o}:${a.dataset}:${l}:${a.rowKey}`;
|
|
1222
1222
|
if (r.has(f)) return;
|
|
1223
1223
|
r.add(f);
|
|
1224
|
-
const u =
|
|
1224
|
+
const u = ce({ sourceScope: n.sourceScope, datasetId: a.dataset, rowKey: d }), m = t.get(u) ?? [];
|
|
1225
1225
|
m.push({ partIndex: o, dataset: a.dataset, rowIndex: l, row: c, binding: a }), t.set(u, m);
|
|
1226
1226
|
});
|
|
1227
1227
|
}
|
|
1228
1228
|
}), (n) => {
|
|
1229
|
-
const o = t.get(
|
|
1230
|
-
if (!o?.length) throw new
|
|
1231
|
-
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");
|
|
1232
1232
|
return o;
|
|
1233
1233
|
};
|
|
1234
1234
|
}
|
|
1235
|
-
function
|
|
1235
|
+
function Et(e, t) {
|
|
1236
1236
|
const r = e.map((o) => ({ ...o, datasets: { ...o.datasets } })), n = /* @__PURE__ */ new Map();
|
|
1237
1237
|
for (const { row: o, field: a, value: s } of t) {
|
|
1238
1238
|
const i = r[o.partIndex], c = JSON.stringify([o.partIndex, o.dataset]);
|
|
@@ -1245,15 +1245,15 @@ function Ct(e, t) {
|
|
|
1245
1245
|
}
|
|
1246
1246
|
for (const o of n.keys()) {
|
|
1247
1247
|
const [a, s] = JSON.parse(o);
|
|
1248
|
-
|
|
1248
|
+
Ut(e[a].datasets[s], r[a].datasets[s]);
|
|
1249
1249
|
}
|
|
1250
1250
|
return r;
|
|
1251
1251
|
}
|
|
1252
|
-
function
|
|
1252
|
+
function $n(e, t, r) {
|
|
1253
1253
|
const n = [], o = /* @__PURE__ */ new Set();
|
|
1254
1254
|
return e.forEach((a, s) => {
|
|
1255
|
-
for (const i of
|
|
1256
|
-
t.has(
|
|
1255
|
+
for (const i of Tt(a))
|
|
1256
|
+
t.has(_({ sourceScope: a.sourceScope, datasetId: i.dataset })) && (a.datasets[i.dataset] ?? []).forEach((c, l) => {
|
|
1257
1257
|
const d = { partIndex: s, dataset: i.dataset, rowIndex: l, row: c, binding: i };
|
|
1258
1258
|
for (const [f, u] of [[i.revisionField, r.revision], [i.sourceTokenField, r.sourceToken]]) {
|
|
1259
1259
|
if (!f || u === void 0) continue;
|
|
@@ -1263,15 +1263,15 @@ function In(e, t, r) {
|
|
|
1263
1263
|
});
|
|
1264
1264
|
}), n;
|
|
1265
1265
|
}
|
|
1266
|
-
function
|
|
1266
|
+
function On(e, t, r) {
|
|
1267
1267
|
if (!r || r.revision === void 0 && r.sourceToken === void 0) return e;
|
|
1268
|
-
const n = new Set(t.edits.flatMap((o) => o.source ? [
|
|
1269
|
-
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])));
|
|
1270
1270
|
}
|
|
1271
|
-
function
|
|
1271
|
+
function It(e, t) {
|
|
1272
1272
|
if (!t.size) return e;
|
|
1273
1273
|
function r(a) {
|
|
1274
|
-
const s = a.datasetId && t.get(
|
|
1274
|
+
const s = a.datasetId && t.get(_({ ...a, datasetId: a.datasetId }));
|
|
1275
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 } : {} };
|
|
1276
1276
|
}
|
|
1277
1277
|
function n(a) {
|
|
@@ -1294,27 +1294,27 @@ function Et(e, t) {
|
|
|
1294
1294
|
});
|
|
1295
1295
|
return o.some((a, s) => a !== e.pages[s]) ? { ...e, pages: o } : e;
|
|
1296
1296
|
}
|
|
1297
|
-
function
|
|
1297
|
+
function Fn(e) {
|
|
1298
1298
|
return JSON.stringify([e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex]);
|
|
1299
1299
|
}
|
|
1300
|
-
function
|
|
1300
|
+
function Xe(e) {
|
|
1301
1301
|
const t = e.table;
|
|
1302
|
-
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);
|
|
1303
1303
|
}
|
|
1304
|
-
function
|
|
1304
|
+
function An(e, t) {
|
|
1305
1305
|
if (!t.length) return e;
|
|
1306
|
-
const r = new Map(t.map((c) => [
|
|
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
1307
|
function s(c, l, d) {
|
|
1308
1308
|
const f = c.grid;
|
|
1309
1309
|
if (!f || !o.has(`${l}:${d}`) && !n.has(c.table?.id ?? "")) return c;
|
|
1310
1310
|
const u = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
|
|
1311
|
-
for (const g of
|
|
1311
|
+
for (const g of q(f, c.widthMm, c.heightMm).cells) {
|
|
1312
1312
|
const b = m.get(g.ri) ?? 0;
|
|
1313
1313
|
m.set(g.ri, b + 1);
|
|
1314
|
-
const y = a({ pageIndex: l, componentIndex: d, rowIndex: g.ri, columnIndex: g.ci }),
|
|
1315
|
-
if (!
|
|
1316
|
-
const h = u.get(g.ri) ?? [...f.cells[g.ri]], S =
|
|
1317
|
-
Object.is(y.value,
|
|
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));
|
|
1318
1318
|
}
|
|
1319
1319
|
return u.size ? { ...c, grid: { ...f, cells: f.cells.map((g, b) => u.get(b) ?? g) } } : c;
|
|
1320
1320
|
}
|
|
@@ -1324,7 +1324,7 @@ function Fn(e, t) {
|
|
|
1324
1324
|
});
|
|
1325
1325
|
return i.every((c, l) => c === e.pages[l]) ? e : { ...e, pages: i };
|
|
1326
1326
|
}
|
|
1327
|
-
function
|
|
1327
|
+
function j(e) {
|
|
1328
1328
|
const t = e.source;
|
|
1329
1329
|
if (t) return JSON.stringify([t.sourceScope, t.datasetId, t.rowKey, t.field]);
|
|
1330
1330
|
const r = e.table;
|
|
@@ -1332,82 +1332,82 @@ function F(e) {
|
|
|
1332
1332
|
const n = e.address;
|
|
1333
1333
|
return JSON.stringify([n.pageIndex, n.componentIndex, n.rowIndex, n.columnIndex]);
|
|
1334
1334
|
}
|
|
1335
|
-
function
|
|
1336
|
-
if (typeof r != "string" || !r.trim() || !Array.isArray(t)) throw new
|
|
1337
|
-
if (t.length > 1e4) throw new
|
|
1338
|
-
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 }) => {
|
|
1339
1339
|
const c = o(s);
|
|
1340
|
-
if (!c) throw new
|
|
1341
|
-
const l =
|
|
1342
|
-
if (n.has(d)) throw new
|
|
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
1343
|
return n.add(d), l;
|
|
1344
1344
|
});
|
|
1345
1345
|
return { requestId: r, edits: a };
|
|
1346
1346
|
}
|
|
1347
|
-
function
|
|
1348
|
-
if (t.edits.length > 1e4) throw new
|
|
1349
|
-
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) => {
|
|
1350
1350
|
const s = r(a.address);
|
|
1351
|
-
if (!s) throw new
|
|
1352
|
-
const i =
|
|
1353
|
-
if (n.has(i)) throw new
|
|
1354
|
-
if (n.add(i),
|
|
1355
|
-
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);
|
|
1356
1356
|
});
|
|
1357
|
-
return
|
|
1357
|
+
return An(e, o);
|
|
1358
1358
|
}
|
|
1359
|
-
function
|
|
1359
|
+
function Ho(e) {
|
|
1360
1360
|
const t = /* @__PURE__ */ new Map();
|
|
1361
1361
|
for (const r of e) {
|
|
1362
|
-
const n =
|
|
1362
|
+
const n = j(r), o = t.get(n), a = o ? { ...r, previousValue: o.previousValue, previousText: o.previousText } : { ...r };
|
|
1363
1363
|
Object.is(a.previousValue, a.value) ? t.delete(n) : t.set(n, a);
|
|
1364
1364
|
}
|
|
1365
1365
|
return [...t.values()];
|
|
1366
1366
|
}
|
|
1367
|
-
function
|
|
1368
|
-
const t = /* @__PURE__ */ new Map(), r =
|
|
1367
|
+
function $t(e) {
|
|
1368
|
+
const t = /* @__PURE__ */ new Map(), r = z(e);
|
|
1369
1369
|
return e.pages.forEach((n, o) => n.components.forEach((a, s) => {
|
|
1370
1370
|
if (!(!a.grid || a.table?.role !== "body"))
|
|
1371
1371
|
for (let i = 0; i < a.grid.cells.length; i++) for (let c = 0; c < a.table.columnKeys.length; c++) {
|
|
1372
1372
|
const l = r({ pageIndex: o, componentIndex: s, rowIndex: i, columnIndex: c });
|
|
1373
|
-
l?.source && l.editable && t.set(
|
|
1373
|
+
l?.source && l.editable && t.set(j(l), l);
|
|
1374
1374
|
}
|
|
1375
1375
|
})), t;
|
|
1376
1376
|
}
|
|
1377
|
-
function
|
|
1378
|
-
const n =
|
|
1377
|
+
function Do(e, t, r) {
|
|
1378
|
+
const n = $t(e), o = z(e);
|
|
1379
1379
|
return t.map((a) => {
|
|
1380
|
-
const s = a.source ? n.get(
|
|
1381
|
-
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");
|
|
1382
1382
|
return { address: { ...s.address }, value: a[r] };
|
|
1383
1383
|
});
|
|
1384
1384
|
}
|
|
1385
|
-
function
|
|
1386
|
-
if (++e.nodes > 1e6 || t > 128) throw new
|
|
1385
|
+
function Ot(e, t) {
|
|
1386
|
+
if (++e.nodes > 1e6 || t > 128) throw new v("limit");
|
|
1387
1387
|
}
|
|
1388
|
-
function
|
|
1388
|
+
function ee(e, t) {
|
|
1389
1389
|
const r = Object.getOwnPropertyDescriptor(e, t);
|
|
1390
|
-
if (!r || r.get || r.set) throw new
|
|
1390
|
+
if (!r || r.get || r.set) throw new v("conflict");
|
|
1391
1391
|
return r.value;
|
|
1392
1392
|
}
|
|
1393
|
-
function
|
|
1394
|
-
if (Object.getOwnPropertyDescriptor(e, "toJSON")) throw new
|
|
1393
|
+
function De(e) {
|
|
1394
|
+
if (Object.getOwnPropertyDescriptor(e, "toJSON")) throw new v("conflict");
|
|
1395
1395
|
const t = Object.getPrototypeOf(e);
|
|
1396
|
-
if (Array.isArray(e) && (t !== Array.prototype || Object.keys(e).length !== e.length)) throw new
|
|
1397
|
-
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");
|
|
1398
1398
|
for (const r of Reflect.ownKeys(e))
|
|
1399
1399
|
if (!(Array.isArray(e) && r === "length")) {
|
|
1400
|
-
if (typeof r == "symbol" || !Object.getOwnPropertyDescriptor(e, r)?.enumerable) throw new
|
|
1401
|
-
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");
|
|
1402
1402
|
}
|
|
1403
1403
|
}
|
|
1404
|
-
function
|
|
1405
|
-
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");
|
|
1406
1406
|
if (e === null || typeof e != "object") return;
|
|
1407
|
-
if (
|
|
1407
|
+
if (De(e), r.has(e)) throw new v("conflict");
|
|
1408
1408
|
if (a?.has(e)) return;
|
|
1409
1409
|
a?.add(e), r.add(e);
|
|
1410
|
-
const s = Object.keys(e), i = s.map((c) =>
|
|
1410
|
+
const s = Object.keys(e), i = s.map((c) => ee(e, c));
|
|
1411
1411
|
t.push({
|
|
1412
1412
|
object: e,
|
|
1413
1413
|
prototype: Object.getPrototypeOf(e),
|
|
@@ -1416,114 +1416,130 @@ function $t(e, t, r, n, o, a) {
|
|
|
1416
1416
|
...e instanceof Date ? { date: Date.prototype.getTime.call(e) } : {},
|
|
1417
1417
|
...Array.isArray(e) ? { length: e.length } : {}
|
|
1418
1418
|
});
|
|
1419
|
-
for (const c of i)
|
|
1419
|
+
for (const c of i) Ft(c, t, r, n, o + 1, a);
|
|
1420
1420
|
r.delete(e);
|
|
1421
1421
|
}
|
|
1422
|
-
function
|
|
1422
|
+
function jn(e) {
|
|
1423
1423
|
const { object: t, keys: r, values: n } = e;
|
|
1424
|
-
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;
|
|
1425
1425
|
const o = Object.keys(t);
|
|
1426
|
-
return o.length === r.length && r.every((a, s) => o[s] === a && Object.is(
|
|
1427
|
-
}
|
|
1428
|
-
function jn(e) {
|
|
1429
|
-
return Ot(e);
|
|
1426
|
+
return o.length === r.length && r.every((a, s) => o[s] === a && Object.is(ee(t, a), n[s]));
|
|
1430
1427
|
}
|
|
1431
1428
|
function Kn(e) {
|
|
1432
|
-
return
|
|
1429
|
+
return At(e);
|
|
1433
1430
|
}
|
|
1434
|
-
function
|
|
1431
|
+
function ve(e) {
|
|
1432
|
+
return At(e, /* @__PURE__ */ new Set());
|
|
1433
|
+
}
|
|
1434
|
+
function At(e, t) {
|
|
1435
1435
|
const r = [];
|
|
1436
|
-
return
|
|
1436
|
+
return Ft(e, r, /* @__PURE__ */ new Set(), { nodes: 0 }, 0, t), () => {
|
|
1437
1437
|
try {
|
|
1438
|
-
return r.every(
|
|
1438
|
+
return r.every(jn);
|
|
1439
1439
|
} catch {
|
|
1440
1440
|
return !1;
|
|
1441
1441
|
}
|
|
1442
1442
|
};
|
|
1443
1443
|
}
|
|
1444
|
-
function
|
|
1445
|
-
if (
|
|
1446
|
-
if (typeof e == "function" || typeof e == "symbol") throw new
|
|
1447
|
-
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);
|
|
1448
1448
|
}
|
|
1449
1449
|
if (e === null || typeof e != "object") return e;
|
|
1450
|
-
|
|
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
|
+
}
|
|
1451
1456
|
if (Array.isArray(e)) {
|
|
1452
|
-
const
|
|
1453
|
-
|
|
1454
|
-
|
|
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;
|
|
1455
1461
|
}
|
|
1456
|
-
return
|
|
1462
|
+
return Nn(e, t, r, n, o);
|
|
1457
1463
|
}
|
|
1458
|
-
function Nn(e) {
|
|
1459
|
-
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;
|
|
1460
1470
|
}
|
|
1461
1471
|
function Ln(e) {
|
|
1462
|
-
|
|
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);
|
|
1463
1479
|
for (const r of t) for (const n of Object.values(r.datasets)) qt(n);
|
|
1464
1480
|
return t;
|
|
1465
1481
|
}
|
|
1466
|
-
async function
|
|
1467
|
-
return (await
|
|
1482
|
+
async function Bn(e, t, r = {}) {
|
|
1483
|
+
return (await jt(e, t, r)).plan;
|
|
1468
1484
|
}
|
|
1469
|
-
async function
|
|
1470
|
-
return
|
|
1485
|
+
async function jt(e, t, r = {}) {
|
|
1486
|
+
return bt(e, t, { ...r, knownTotalPages: void 0 });
|
|
1471
1487
|
}
|
|
1472
|
-
function
|
|
1488
|
+
function Gn(e) {
|
|
1473
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);
|
|
1474
1490
|
}
|
|
1475
|
-
function
|
|
1476
|
-
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)));
|
|
1477
1493
|
}
|
|
1478
|
-
function
|
|
1494
|
+
function Vn(e) {
|
|
1479
1495
|
const t = /* @__PURE__ */ new Map();
|
|
1480
1496
|
for (const r of e) {
|
|
1481
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;
|
|
1482
|
-
const n =
|
|
1498
|
+
const n = ce(r.source), o = t.get(n) ?? /* @__PURE__ */ new Map();
|
|
1483
1499
|
o.set(r.source.field, r), t.set(n, o);
|
|
1484
1500
|
}
|
|
1485
1501
|
return t;
|
|
1486
1502
|
}
|
|
1487
|
-
function
|
|
1503
|
+
function Be(e) {
|
|
1488
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;
|
|
1489
1505
|
}
|
|
1490
|
-
function
|
|
1491
|
-
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)))));
|
|
1492
1508
|
}
|
|
1493
|
-
function
|
|
1494
|
-
if (!
|
|
1495
|
-
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;
|
|
1496
1512
|
if (!Number.isFinite(o) || o < 1 || !Number.isFinite(s) || s <= 0) return !1;
|
|
1497
|
-
const i = { fontSizePt: s, fontFamily: a?.fontFamily ??
|
|
1498
|
-
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;
|
|
1499
1515
|
}
|
|
1500
|
-
function
|
|
1516
|
+
function Jn(e, t) {
|
|
1501
1517
|
const r = e.colWidthsMm;
|
|
1502
1518
|
if (!r || r.length !== e.cells[0].length || r.length !== t.table.columnKeys.length) return !1;
|
|
1503
1519
|
const n = r.reduce((o, a) => o + a, 0);
|
|
1504
1520
|
return Number.isFinite(n) && Math.abs(n - t.widthMm) <= Math.max(1e-7, n * 1e-10);
|
|
1505
1521
|
}
|
|
1506
|
-
function
|
|
1522
|
+
function Un(e, t, r) {
|
|
1507
1523
|
const n = e.table?.source;
|
|
1508
1524
|
if (e.table?.role !== "body" || n?.rowKey === void 0) return e;
|
|
1509
|
-
const o = t.get(
|
|
1525
|
+
const o = t.get(ce({ ...n, rowKey: n.rowKey }));
|
|
1510
1526
|
if (!o) return e;
|
|
1511
1527
|
const a = e.grid;
|
|
1512
|
-
if (!a || a.cells.length !== 1 || !
|
|
1528
|
+
if (!a || a.cells.length !== 1 || !Jn(a, e) || e.style?.rotateDeg) return null;
|
|
1513
1529
|
const s = a.cells[0], i = [...s];
|
|
1514
1530
|
for (let c = 0; c < s.length; c++) {
|
|
1515
1531
|
const l = s[c];
|
|
1516
|
-
if (!l || !
|
|
1532
|
+
if (!l || !Be(l)) return null;
|
|
1517
1533
|
const d = o.get(e.table.columnKeys[c]);
|
|
1518
1534
|
if (d) {
|
|
1519
|
-
if (!
|
|
1535
|
+
if (!_n(l, d, a.colWidthsMm[c], a.paddingMm ?? 0.5)) return null;
|
|
1520
1536
|
i[c] = { ...l, value: d.value, text: d.value }, r.add(d);
|
|
1521
1537
|
}
|
|
1522
1538
|
}
|
|
1523
1539
|
return i.some((c, l) => c !== s[l]) ? { ...e, grid: { ...a, cells: [i] } } : e;
|
|
1524
1540
|
}
|
|
1525
|
-
async function
|
|
1526
|
-
const n =
|
|
1541
|
+
async function qn(e, t, r) {
|
|
1542
|
+
const n = Vn(t);
|
|
1527
1543
|
if (!n || !t.length) return null;
|
|
1528
1544
|
const o = /* @__PURE__ */ new Set(), a = [];
|
|
1529
1545
|
let s = 0;
|
|
@@ -1531,7 +1547,7 @@ async function Jn(e, t, r) {
|
|
|
1531
1547
|
const l = [];
|
|
1532
1548
|
for (const d of c.components) {
|
|
1533
1549
|
if (r?.aborted) return null;
|
|
1534
|
-
const f =
|
|
1550
|
+
const f = Un(d, n, o);
|
|
1535
1551
|
if (!f) return null;
|
|
1536
1552
|
l.push(f), ++s % 128 === 0 && await new Promise((u) => setTimeout(u, 0));
|
|
1537
1553
|
}
|
|
@@ -1539,18 +1555,18 @@ async function Jn(e, t, r) {
|
|
|
1539
1555
|
}
|
|
1540
1556
|
if (o.size !== t.length) return null;
|
|
1541
1557
|
const i = { ...e, pages: a };
|
|
1542
|
-
return
|
|
1558
|
+
return Oe(i).ok ? i : null;
|
|
1543
1559
|
}
|
|
1544
|
-
function
|
|
1545
|
-
let n =
|
|
1560
|
+
function Xn(e, t, r) {
|
|
1561
|
+
let n = Wn(t, r), o = e, a;
|
|
1546
1562
|
function s(c) {
|
|
1547
1563
|
if (o = c, a = void 0, !!n) {
|
|
1548
|
-
if (!
|
|
1564
|
+
if (!zn(c)) {
|
|
1549
1565
|
n = !1;
|
|
1550
1566
|
return;
|
|
1551
1567
|
}
|
|
1552
1568
|
try {
|
|
1553
|
-
a =
|
|
1569
|
+
a = ve(c);
|
|
1554
1570
|
} catch {
|
|
1555
1571
|
n = !1;
|
|
1556
1572
|
}
|
|
@@ -1559,58 +1575,76 @@ function qn(e, t, r) {
|
|
|
1559
1575
|
s(e);
|
|
1560
1576
|
async function i(c, l, d) {
|
|
1561
1577
|
if (!n || c !== o || !a?.()) return null;
|
|
1562
|
-
const f = a, u = await
|
|
1578
|
+
const f = a, u = await qn(c, l, d);
|
|
1563
1579
|
return u && f() ? { plan: u, unchanged: f } : null;
|
|
1564
1580
|
}
|
|
1565
1581
|
return { candidate: i, publish: s };
|
|
1566
1582
|
}
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
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
|
+
};
|
|
1570
1600
|
}
|
|
1571
|
-
|
|
1601
|
+
const Me = /* @__PURE__ */ new WeakMap();
|
|
1602
|
+
function Bo(e) {
|
|
1603
|
+
return Me.get(e);
|
|
1604
|
+
}
|
|
1605
|
+
function U(e) {
|
|
1572
1606
|
if (e?.aborted) {
|
|
1573
1607
|
const t = new Error("报表重算已取消");
|
|
1574
1608
|
throw t.name = "AbortError", t;
|
|
1575
1609
|
}
|
|
1576
1610
|
}
|
|
1577
|
-
function
|
|
1611
|
+
function Kt(e, t) {
|
|
1578
1612
|
return e[t] === void 0 ? "" : e[t];
|
|
1579
1613
|
}
|
|
1580
|
-
function
|
|
1581
|
-
if (t.edits.length > 1e4) throw new
|
|
1582
|
-
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) => {
|
|
1583
1617
|
const i = r(s.address);
|
|
1584
|
-
if (!i?.source) throw new
|
|
1585
|
-
const c =
|
|
1586
|
-
if (n.has(c)) throw new
|
|
1587
|
-
if (n.add(c),
|
|
1588
|
-
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);
|
|
1589
1623
|
});
|
|
1590
1624
|
return { batch: { requestId: t.requestId, edits: a }, contexts: o };
|
|
1591
1625
|
}
|
|
1592
|
-
function
|
|
1593
|
-
const r =
|
|
1626
|
+
function Zn(e, t) {
|
|
1627
|
+
const r = Rt(e);
|
|
1594
1628
|
return t.flatMap((n) => {
|
|
1595
|
-
if (!n.source) throw new
|
|
1629
|
+
if (!n.source) throw new v("missing");
|
|
1596
1630
|
return r(n.source).map((o) => {
|
|
1597
|
-
if (!Object.is(
|
|
1598
|
-
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");
|
|
1599
1633
|
return { row: o, field: n.source.field, value: n.value };
|
|
1600
1634
|
});
|
|
1601
1635
|
});
|
|
1602
1636
|
}
|
|
1603
|
-
function
|
|
1637
|
+
function he(e, t, r) {
|
|
1604
1638
|
const n = { ...e, value: t, source: { ...e.source, ...r?.revision === void 0 ? {} : { revision: r.revision }, ...r?.sourceToken === void 0 ? {} : { sourceToken: r.sourceToken } } };
|
|
1605
|
-
return n.cell = { ...e.cell, value: n.value, text:
|
|
1639
|
+
return n.cell = { ...e.cell, value: n.value, text: re(n, n.value) }, n;
|
|
1606
1640
|
}
|
|
1607
|
-
function
|
|
1641
|
+
function eo(e, t, r) {
|
|
1608
1642
|
if (!r || r.revision === void 0 && r.sourceToken === void 0) return [...e];
|
|
1609
|
-
const n = new Set(t.edits.flatMap((o) => o.source ? [
|
|
1610
|
-
return
|
|
1643
|
+
const n = new Set(t.edits.flatMap((o) => o.source ? [_(o.source)] : []));
|
|
1644
|
+
return Et(e, $n(e, n, r));
|
|
1611
1645
|
}
|
|
1612
|
-
function
|
|
1613
|
-
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)));
|
|
1614
1648
|
for (const o of n) e.set(o, {
|
|
1615
1649
|
...e.get(o),
|
|
1616
1650
|
...r.revision !== void 0 ? { revision: r.revision } : {},
|
|
@@ -1618,80 +1652,83 @@ function Qn(e, t, r) {
|
|
|
1618
1652
|
});
|
|
1619
1653
|
return n;
|
|
1620
1654
|
}
|
|
1621
|
-
function
|
|
1622
|
-
return
|
|
1655
|
+
function Go(e, t) {
|
|
1656
|
+
return Ge(e, t);
|
|
1623
1657
|
}
|
|
1624
|
-
function
|
|
1658
|
+
function Ge(e, t, r) {
|
|
1625
1659
|
let n = t.parts;
|
|
1626
|
-
const o = t.rebuild, a = [...t.validationFormulas ?? []], s = r ?
|
|
1627
|
-
let i =
|
|
1660
|
+
const o = t.rebuild, a = [...t.validationFormulas ?? []], s = r ? Xn(e, n, r) : void 0;
|
|
1661
|
+
let i = Kn(n), c = e, l;
|
|
1628
1662
|
const d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
1629
1663
|
function u(b) {
|
|
1630
|
-
if (b !== c) throw new
|
|
1664
|
+
if (b !== c) throw new v("conflict");
|
|
1631
1665
|
if (l) return l;
|
|
1632
|
-
if (!i?.()) throw new
|
|
1633
|
-
return
|
|
1634
|
-
}
|
|
1635
|
-
async function m(b, y,
|
|
1636
|
-
|
|
1637
|
-
const S = u(b), T =
|
|
1638
|
-
|
|
1639
|
-
const
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
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;
|
|
1644
1679
|
}
|
|
1645
|
-
return h.validation &&
|
|
1646
|
-
return
|
|
1647
|
-
},
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
if (
|
|
1651
|
-
if (
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
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));
|
|
1657
1694
|
}
|
|
1658
|
-
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;
|
|
1659
1696
|
} };
|
|
1660
1697
|
}
|
|
1661
1698
|
const g = {
|
|
1662
1699
|
get plan() {
|
|
1663
1700
|
return c;
|
|
1664
1701
|
},
|
|
1665
|
-
async prepare(b, y,
|
|
1666
|
-
const h =
|
|
1667
|
-
return m(b, h.batch, h.contexts,
|
|
1702
|
+
async prepare(b, y, p) {
|
|
1703
|
+
const h = Qn(b, y);
|
|
1704
|
+
return m(b, h.batch, h.contexts, p);
|
|
1668
1705
|
},
|
|
1669
|
-
async prepareHistory(b, y,
|
|
1670
|
-
if (!h.trim() || y.length > 1e4) throw new
|
|
1671
|
-
const T = u(b),
|
|
1672
|
-
if (!
|
|
1673
|
-
const
|
|
1674
|
-
if (
|
|
1675
|
-
|
|
1676
|
-
const
|
|
1677
|
-
if (
|
|
1678
|
-
const
|
|
1679
|
-
return
|
|
1680
|
-
}).map((
|
|
1681
|
-
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) };
|
|
1682
1719
|
}
|
|
1683
1720
|
};
|
|
1684
|
-
return
|
|
1721
|
+
return Me.set(e, g), g;
|
|
1685
1722
|
}
|
|
1686
|
-
function
|
|
1687
|
-
const t =
|
|
1688
|
-
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]);
|
|
1689
1726
|
}
|
|
1690
|
-
let
|
|
1691
|
-
function
|
|
1692
|
-
return `report-${Date.now()}-${++
|
|
1727
|
+
let ro = 0;
|
|
1728
|
+
function no() {
|
|
1729
|
+
return `report-${Date.now()}-${++ro}`;
|
|
1693
1730
|
}
|
|
1694
|
-
function
|
|
1731
|
+
function Ye(e, t, r) {
|
|
1695
1732
|
if (!r?.aborted)
|
|
1696
1733
|
try {
|
|
1697
1734
|
const n = e?.({ ...t });
|
|
@@ -1700,14 +1737,14 @@ function Ue(e, t, r) {
|
|
|
1700
1737
|
} catch {
|
|
1701
1738
|
}
|
|
1702
1739
|
}
|
|
1703
|
-
function
|
|
1704
|
-
const t = e.taskId ??
|
|
1705
|
-
|
|
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);
|
|
1706
1743
|
};
|
|
1707
1744
|
return {
|
|
1708
1745
|
taskId: t,
|
|
1709
1746
|
progress(n, o, a) {
|
|
1710
|
-
|
|
1747
|
+
Ye(e.onEvent, { taskId: t, ...e.correlationId === void 0 ? {} : { correlationId: e.correlationId }, stage: n, status: "started", completed: o, total: a }, e.signal);
|
|
1711
1748
|
},
|
|
1712
1749
|
async run(n, o, a) {
|
|
1713
1750
|
r(n, "started", a);
|
|
@@ -1729,25 +1766,25 @@ function to(e) {
|
|
|
1729
1766
|
}
|
|
1730
1767
|
};
|
|
1731
1768
|
}
|
|
1732
|
-
function
|
|
1769
|
+
function Nt(e) {
|
|
1733
1770
|
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
1734
1771
|
const t = e, r = (n) => typeof n == "string" && n.trim().length > 0 && n.length <= 256;
|
|
1735
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);
|
|
1736
1773
|
}
|
|
1737
|
-
function
|
|
1774
|
+
function ao(e) {
|
|
1738
1775
|
return e === "missing-source" || e === "not-applicable" || e === "not-calculable";
|
|
1739
1776
|
}
|
|
1740
|
-
function
|
|
1741
|
-
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;
|
|
1742
1779
|
}
|
|
1743
|
-
function
|
|
1744
|
-
if (
|
|
1780
|
+
function Vo(e, t) {
|
|
1781
|
+
if (at([], e), !Nt(t)) throw new Error("数据说明目标无效");
|
|
1745
1782
|
const r = e.fields.find((o) => o.field === t.field);
|
|
1746
1783
|
if (!r) throw new Error("数据说明字段未在契约中声明");
|
|
1747
1784
|
const n = [];
|
|
1748
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;
|
|
1749
1786
|
}
|
|
1750
|
-
function
|
|
1787
|
+
function Lt(e, t, r = {}) {
|
|
1751
1788
|
const n = /* @__PURE__ */ new Map();
|
|
1752
1789
|
for (const a of e.pages) for (const s of a.components) {
|
|
1753
1790
|
if (s.kind !== "list" || s.tree?.input !== "nested") continue;
|
|
@@ -1759,26 +1796,26 @@ function Kt(e, t, r = {}) {
|
|
|
1759
1796
|
const o = { ...t };
|
|
1760
1797
|
for (const [a, s] of n) {
|
|
1761
1798
|
const i = Math.min(s.maxRows ?? 1e5, r.maxRows ?? 1 / 0);
|
|
1762
|
-
o[a] =
|
|
1799
|
+
o[a] = nt(t[a] ?? [], { ...s, maxRows: i }, r.signal);
|
|
1763
1800
|
}
|
|
1764
1801
|
return o;
|
|
1765
1802
|
}
|
|
1766
|
-
function
|
|
1767
|
-
return Object.values(
|
|
1803
|
+
function zo(e, t, r = {}) {
|
|
1804
|
+
return Object.values(Lt(e, t, r)).reduce((n, o) => n + o.length, 0);
|
|
1768
1805
|
}
|
|
1769
|
-
function
|
|
1770
|
-
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");
|
|
1771
1808
|
if (!o || o.kind !== "list" || !o.tree) return n;
|
|
1772
1809
|
const a = n.items, s = o.tree.childrenField ?? "children";
|
|
1773
1810
|
return { ...n, items: { $ref: "#/$defs/treeNode" }, $defs: { treeNode: { ...a, properties: { ...a.properties, [s]: { anyOf: [{ type: "null" }, { type: "array", items: { $ref: "#/$defs/treeNode" } }] } } } } };
|
|
1774
1811
|
}
|
|
1775
|
-
function
|
|
1812
|
+
function Ht(e, t) {
|
|
1776
1813
|
return JSON.stringify([e, t]);
|
|
1777
1814
|
}
|
|
1778
|
-
function
|
|
1779
|
-
return r === void 0 ?
|
|
1815
|
+
function Dt(e, t, r) {
|
|
1816
|
+
return r === void 0 ? Ht(e, t) : JSON.stringify(["shared", r]);
|
|
1780
1817
|
}
|
|
1781
|
-
function
|
|
1818
|
+
function Bt(e, t, r) {
|
|
1782
1819
|
return e.map((n) => {
|
|
1783
1820
|
const o = n.table ? {
|
|
1784
1821
|
...n.table,
|
|
@@ -1787,7 +1824,7 @@ function Ht(e, t, r) {
|
|
|
1787
1824
|
} : void 0, a = n.grid?.cells.map((s) => s.map((i) => !i || !i.source && !i.children ? i : {
|
|
1788
1825
|
...i,
|
|
1789
1826
|
...i.source ? { source: { ...i.source, sourceScope: t } } : {},
|
|
1790
|
-
...i.children ? { children:
|
|
1827
|
+
...i.children ? { children: Bt(i.children, t, r) } : {}
|
|
1791
1828
|
}));
|
|
1792
1829
|
return o || a ? {
|
|
1793
1830
|
...n,
|
|
@@ -1796,46 +1833,46 @@ function Ht(e, t, r) {
|
|
|
1796
1833
|
} : n;
|
|
1797
1834
|
});
|
|
1798
1835
|
}
|
|
1799
|
-
function
|
|
1800
|
-
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 };
|
|
1801
1838
|
}
|
|
1802
|
-
function
|
|
1839
|
+
function io(e, t) {
|
|
1803
1840
|
if (!e.repeat) return !1;
|
|
1804
1841
|
const r = Object.prototype.hasOwnProperty.call(t, e.repeat.dataset) ? t[e.repeat.dataset] : void 0;
|
|
1805
1842
|
return Array.isArray(r) && r.length === 0;
|
|
1806
1843
|
}
|
|
1807
|
-
function
|
|
1844
|
+
function co(e) {
|
|
1808
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;
|
|
1809
1846
|
return e.pages.reduce((r, n) => r + n.components.reduce((o, a) => o + t(a), 0), 0);
|
|
1810
1847
|
}
|
|
1811
|
-
function
|
|
1848
|
+
function xe(e, t) {
|
|
1812
1849
|
return e === void 0 ? void 0 : e - t;
|
|
1813
1850
|
}
|
|
1814
|
-
function
|
|
1851
|
+
function pe(e, t) {
|
|
1815
1852
|
return e === void 0 ? t : Math.max(1, Math.min(e, t ?? e));
|
|
1816
1853
|
}
|
|
1817
|
-
function
|
|
1818
|
-
|
|
1819
|
-
const a =
|
|
1820
|
-
if (a !== void 0 && a < 1 && r.pages.length && !
|
|
1821
|
-
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);
|
|
1822
1859
|
return {
|
|
1823
1860
|
...e,
|
|
1824
1861
|
signal: o ?? e?.signal,
|
|
1825
|
-
maxPages:
|
|
1826
|
-
maxCells:
|
|
1827
|
-
maxChartComponents:
|
|
1862
|
+
maxPages: pe(a, e?.maxPages),
|
|
1863
|
+
maxCells: pe(xe(t.maxCells, t.usedCells), e?.maxCells),
|
|
1864
|
+
maxChartComponents: pe(s, e?.maxChartComponents)
|
|
1828
1865
|
};
|
|
1829
1866
|
}
|
|
1830
|
-
function
|
|
1831
|
-
const r =
|
|
1832
|
-
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);
|
|
1833
1870
|
e.usedPages += t.plan.pages.length, e.usedCells += r, e.usedChartComponents += t.chartComponents;
|
|
1834
1871
|
}
|
|
1835
|
-
function
|
|
1836
|
-
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;
|
|
1837
1874
|
}
|
|
1838
|
-
function
|
|
1875
|
+
function Jo(e) {
|
|
1839
1876
|
if (!("mapData" in e)) return e;
|
|
1840
1877
|
const { load: t, mapData: r, ...n } = e;
|
|
1841
1878
|
return { ...n, load: async (o) => {
|
|
@@ -1844,26 +1881,26 @@ function Vo(e) {
|
|
|
1844
1881
|
try {
|
|
1845
1882
|
return r(a, o);
|
|
1846
1883
|
} catch (s) {
|
|
1847
|
-
throw new
|
|
1884
|
+
throw new C("validate", `报表 ${o.reportId} 数据映射失败`, s);
|
|
1848
1885
|
}
|
|
1849
1886
|
} };
|
|
1850
1887
|
}
|
|
1851
|
-
class
|
|
1888
|
+
class C extends Error {
|
|
1852
1889
|
constructor(t, r, n) {
|
|
1853
1890
|
super(r), this.name = "ReportSourceError", this.code = t, this.cause = n;
|
|
1854
1891
|
}
|
|
1855
1892
|
}
|
|
1856
|
-
function
|
|
1893
|
+
function ge(e) {
|
|
1857
1894
|
const t = new Error("报表加载已取消");
|
|
1858
1895
|
return t.name = "AbortError", Object.defineProperty(t, "cause", { value: e.reason }), t;
|
|
1859
1896
|
}
|
|
1860
1897
|
function I(e) {
|
|
1861
|
-
if (e?.aborted) throw
|
|
1898
|
+
if (e?.aborted) throw ge(e);
|
|
1862
1899
|
}
|
|
1863
|
-
function
|
|
1900
|
+
function Pe(e, t) {
|
|
1864
1901
|
return t ? new Promise((r, n) => {
|
|
1865
1902
|
const o = () => t.removeEventListener("abort", a), a = () => {
|
|
1866
|
-
o(), n(
|
|
1903
|
+
o(), n(ge(t));
|
|
1867
1904
|
};
|
|
1868
1905
|
t.addEventListener("abort", a, { once: !0 }), t.aborted && a(), Promise.resolve(e).then(
|
|
1869
1906
|
(s) => {
|
|
@@ -1875,174 +1912,174 @@ function Se(e, t) {
|
|
|
1875
1912
|
);
|
|
1876
1913
|
}) : Promise.resolve(e);
|
|
1877
1914
|
}
|
|
1878
|
-
function
|
|
1915
|
+
function lo(e, t) {
|
|
1879
1916
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
1880
|
-
throw new
|
|
1917
|
+
throw new C("validate", `报表 ${t} 的数据集应为对象`);
|
|
1881
1918
|
for (const [r, n] of Object.entries(e))
|
|
1882
1919
|
if (!Array.isArray(n) || n.some((o) => !o || typeof o != "object" || Array.isArray(o)))
|
|
1883
|
-
throw new
|
|
1920
|
+
throw new C("validate", `报表 ${t} 的数据集 ${r} 应为对象数组`);
|
|
1884
1921
|
}
|
|
1885
|
-
async function
|
|
1922
|
+
async function uo(e, t, r) {
|
|
1886
1923
|
const { reportId: n, signal: o } = t;
|
|
1887
1924
|
try {
|
|
1888
|
-
const a = await
|
|
1925
|
+
const a = await Pe(e(t), o);
|
|
1889
1926
|
I(o);
|
|
1890
|
-
const s =
|
|
1927
|
+
const s = lr(a);
|
|
1891
1928
|
if (!s.ok)
|
|
1892
|
-
throw new
|
|
1929
|
+
throw new C("validate", `报表 ${n} 模板校验失败:${s.errors.slice(0, 3).map((i) => `${i.path}: ${i.message}`).join("; ")}`);
|
|
1893
1930
|
return r.push(...s.warnings.map((i) => `${n}: ${i.path}: ${i.message}`)), a;
|
|
1894
1931
|
} catch (a) {
|
|
1895
|
-
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);
|
|
1896
1933
|
}
|
|
1897
1934
|
}
|
|
1898
|
-
async function
|
|
1935
|
+
async function fo(e, t, r, n) {
|
|
1899
1936
|
const o = t.signal;
|
|
1900
1937
|
let a;
|
|
1901
1938
|
try {
|
|
1902
|
-
if (e.load) a = await
|
|
1939
|
+
if (e.load) a = await Pe(e.load(t), o);
|
|
1903
1940
|
else if (e.provider) {
|
|
1904
|
-
const s = await
|
|
1905
|
-
I(o),
|
|
1941
|
+
const s = await Pe(e.provider.query(t), o);
|
|
1942
|
+
I(o), mo(s, r), a = s.datasets, n?.(r, s);
|
|
1906
1943
|
} else a = e.datasets ?? {};
|
|
1907
1944
|
} catch (s) {
|
|
1908
|
-
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);
|
|
1909
1946
|
}
|
|
1910
1947
|
return I(o), a;
|
|
1911
1948
|
}
|
|
1912
|
-
function
|
|
1913
|
-
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 结果对象`);
|
|
1914
1951
|
for (const r of ["revision", "sourceToken"])
|
|
1915
|
-
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} 应为字符串`);
|
|
1916
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))))
|
|
1917
|
-
throw new
|
|
1918
|
-
if (e.diagnostics?.some((r) => !
|
|
1919
|
-
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 数据说明缺少有效的字段身份或值状态`);
|
|
1920
1957
|
}
|
|
1921
|
-
function
|
|
1958
|
+
function go(e, t, r, n, o) {
|
|
1922
1959
|
try {
|
|
1923
|
-
t =
|
|
1960
|
+
t = Lt(n, t, { maxRows: e.dataValidation?.maxRows, signal: o });
|
|
1924
1961
|
} catch (a) {
|
|
1925
|
-
throw new
|
|
1962
|
+
throw new C("validate", `报表 ${r} 树形数据无效:${a instanceof Error ? a.message : String(a)}`, a);
|
|
1926
1963
|
}
|
|
1927
1964
|
for (const [a, s] of Object.entries(e.dataSchema ?? {})) {
|
|
1928
1965
|
let i;
|
|
1929
1966
|
try {
|
|
1930
|
-
i =
|
|
1967
|
+
i = at(Object.prototype.hasOwnProperty.call(t, a) ? t[a] : void 0, s, { ...e.dataValidation, path: `$.datasets.${a}` });
|
|
1931
1968
|
} catch (c) {
|
|
1932
|
-
throw new
|
|
1969
|
+
throw new C("config", `报表 ${r} 数据集 ${a} 字段契约配置无效`, c);
|
|
1933
1970
|
}
|
|
1934
|
-
if (!i.ok) throw new
|
|
1971
|
+
if (!i.ok) throw new C("validate", `报表 ${r} 数据集 ${a} 不符合字段契约:${i.issues[0]?.message}`, { issues: i.issues });
|
|
1935
1972
|
}
|
|
1936
1973
|
}
|
|
1937
|
-
async function
|
|
1974
|
+
async function ho(e, t, r, n, o) {
|
|
1938
1975
|
try {
|
|
1939
1976
|
let a;
|
|
1940
1977
|
try {
|
|
1941
|
-
a =
|
|
1978
|
+
a = Hn(e);
|
|
1942
1979
|
} catch {
|
|
1943
1980
|
}
|
|
1944
|
-
const s = a ?? e, i =
|
|
1945
|
-
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 };
|
|
1946
1983
|
} catch (a) {
|
|
1947
1984
|
I(o);
|
|
1948
|
-
const s =
|
|
1949
|
-
throw new
|
|
1985
|
+
const s = Vt(a, n);
|
|
1986
|
+
throw new C("validate", `报表 ${r} 排版失败:${s instanceof Error ? s.message : String(s)}`, s);
|
|
1950
1987
|
}
|
|
1951
1988
|
}
|
|
1952
|
-
function
|
|
1989
|
+
function zt(e, t, r, n, o) {
|
|
1953
1990
|
const a = /* @__PURE__ */ new Map(), s = (i) => {
|
|
1954
1991
|
let c = a.get(i);
|
|
1955
1992
|
return c === void 0 && (c = JSON.stringify([r, n, i]), a.set(i, c)), c;
|
|
1956
1993
|
};
|
|
1957
1994
|
for (const i of t.pages) e.push({
|
|
1958
1995
|
...i,
|
|
1959
|
-
meta: { ...i.meta, reportScope:
|
|
1960
|
-
components:
|
|
1996
|
+
meta: { ...i.meta, reportScope: Ht(r, n) },
|
|
1997
|
+
components: Bt(i.components, o ?? Dt(r, n), s)
|
|
1961
1998
|
});
|
|
1962
1999
|
}
|
|
1963
|
-
async function
|
|
1964
|
-
const a = [], s =
|
|
2000
|
+
async function po(e, t, r, n, o) {
|
|
2001
|
+
const a = [], s = Se(n);
|
|
1965
2002
|
for (const [l, d] of e.entries()) {
|
|
1966
2003
|
I(o);
|
|
1967
2004
|
try {
|
|
1968
|
-
const f = await
|
|
1969
|
-
|
|
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);
|
|
1970
2007
|
} catch (f) {
|
|
1971
|
-
throw
|
|
2008
|
+
throw Vt(f, s);
|
|
1972
2009
|
}
|
|
1973
2010
|
}
|
|
1974
|
-
const i = { schemaVersion:
|
|
1975
|
-
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}`);
|
|
1976
2013
|
return i;
|
|
1977
2014
|
}
|
|
1978
|
-
function
|
|
1979
|
-
if (t.maxPages !== void 0 && (!Number.isSafeInteger(t.maxPages) || t.maxPages < 1)) throw new
|
|
1980
|
-
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 应为正安全整数");
|
|
1981
2018
|
try {
|
|
1982
|
-
|
|
2019
|
+
Se(t);
|
|
1983
2020
|
} catch (o) {
|
|
1984
|
-
throw new
|
|
2021
|
+
throw new C("config", "maxChartComponents 应为 1..1000000 的安全整数", o);
|
|
1985
2022
|
}
|
|
1986
2023
|
function r(o) {
|
|
1987
2024
|
const a = Object.prototype.hasOwnProperty.call(e, o) ? e[o] : void 0;
|
|
1988
|
-
if (!a) throw new
|
|
1989
|
-
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 字符的非空字符串");
|
|
1990
2027
|
return a;
|
|
1991
2028
|
}
|
|
1992
2029
|
return Object.assign(async ({ reportIds: o, params: a, signal: s, onWarning: i, onQueryResult: c, ...l }) => {
|
|
1993
2030
|
I(s);
|
|
1994
|
-
const d =
|
|
1995
|
-
if (f.length === 0) throw new
|
|
1996
|
-
const m = f.map(r), g = d.runSync("validate", () => m.map((
|
|
1997
|
-
|
|
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) ?? [],
|
|
1998
2035
|
u
|
|
1999
|
-
))), b = [], y = [],
|
|
2000
|
-
for (const [
|
|
2036
|
+
))), b = [], y = [], p = Se(t), h = [];
|
|
2037
|
+
for (const [w, x] of m.entries()) {
|
|
2001
2038
|
I(s);
|
|
2002
|
-
const
|
|
2003
|
-
|
|
2004
|
-
const
|
|
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);
|
|
2005
2042
|
d.runSync("validate", () => {
|
|
2006
|
-
|
|
2007
|
-
},
|
|
2008
|
-
const
|
|
2009
|
-
y.push(
|
|
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}`));
|
|
2010
2047
|
}
|
|
2011
2048
|
I(s);
|
|
2012
|
-
const S = { schemaVersion:
|
|
2013
|
-
const
|
|
2014
|
-
if (!
|
|
2015
|
-
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;
|
|
2016
2053
|
});
|
|
2017
|
-
h.push(...T.warnings.map((
|
|
2018
|
-
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 };
|
|
2019
2056
|
try {
|
|
2020
|
-
|
|
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));
|
|
2021
2058
|
} catch {
|
|
2022
2059
|
h.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算");
|
|
2023
2060
|
}
|
|
2024
|
-
const
|
|
2025
|
-
for (const
|
|
2026
|
-
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);
|
|
2027
2064
|
return I(s), S;
|
|
2028
2065
|
}, {
|
|
2029
|
-
getParamDefs: (o) =>
|
|
2066
|
+
getParamDefs: (o) => ur(e, o)
|
|
2030
2067
|
});
|
|
2031
2068
|
}
|
|
2032
|
-
const
|
|
2033
|
-
function
|
|
2069
|
+
const wo = /* @__PURE__ */ new Set([8, 9, 10, 12, 13]);
|
|
2070
|
+
function yo(e, t) {
|
|
2034
2071
|
const r = Array.isArray(e), n = Object.getPrototypeOf(e);
|
|
2035
2072
|
if (n !== (r ? Array.prototype : Object.prototype) && !(n === null && !r) || Object.getOwnPropertySymbols(e).length) throw t("input", "快照应为普通 JSON 对象");
|
|
2036
2073
|
const o = Object.getOwnPropertyNames(e).filter((a) => !(r && a === "length"));
|
|
2037
2074
|
if (r && (o.length !== e.length || o.some((a, s) => a !== String(s)))) throw t("input", "快照数组应为连续数组");
|
|
2038
2075
|
return { array: r, keys: o };
|
|
2039
2076
|
}
|
|
2040
|
-
function
|
|
2077
|
+
function bo(e) {
|
|
2041
2078
|
if (/^[\u0020-\u007e]*$/.test(e) && !/["\\]/.test(e)) return e.length + 2;
|
|
2042
2079
|
let t = 2;
|
|
2043
2080
|
for (let r = 0; r < e.length; r++) {
|
|
2044
2081
|
const n = e.charCodeAt(r);
|
|
2045
|
-
if (n < 32) t +=
|
|
2082
|
+
if (n < 32) t += wo.has(n) ? 2 : 6;
|
|
2046
2083
|
else if (n === 34 || n === 92) t += 2;
|
|
2047
2084
|
else if (n < 128) t++;
|
|
2048
2085
|
else if (n < 2048) t += 2;
|
|
@@ -2053,7 +2090,7 @@ function po(e) {
|
|
|
2053
2090
|
}
|
|
2054
2091
|
return t;
|
|
2055
2092
|
}
|
|
2056
|
-
function
|
|
2093
|
+
function qo(e, t) {
|
|
2057
2094
|
const r = t.maxNodes ?? 1e6;
|
|
2058
2095
|
if (![t.maxBytes, r].every((u) => Number.isSafeInteger(u) && u > 0)) throw t.error("budget", "快照预算应为正安全整数");
|
|
2059
2096
|
let n = 0, o = 0;
|
|
@@ -2062,7 +2099,7 @@ function _o(e, t) {
|
|
|
2062
2099
|
if (u.length + 2 > t.maxBytes - o) throw t.error("budget", "快照超过字节预算");
|
|
2063
2100
|
const m = s.get(u);
|
|
2064
2101
|
if (m !== void 0) return m;
|
|
2065
|
-
const g =
|
|
2102
|
+
const g = bo(u);
|
|
2066
2103
|
return u.length <= 256 && s.size < 4096 && s.set(u, g), g;
|
|
2067
2104
|
}
|
|
2068
2105
|
function c(u) {
|
|
@@ -2078,15 +2115,15 @@ function _o(e, t) {
|
|
|
2078
2115
|
return d(u, m);
|
|
2079
2116
|
}
|
|
2080
2117
|
function d(u, m) {
|
|
2081
|
-
const { array: g, keys: b } =
|
|
2118
|
+
const { array: g, keys: b } = yo(u, t.error);
|
|
2082
2119
|
a.add(u), c(2);
|
|
2083
2120
|
const y = g ? [] : {};
|
|
2084
|
-
let
|
|
2121
|
+
let p = 0;
|
|
2085
2122
|
for (const h of b) {
|
|
2086
2123
|
const S = Object.getOwnPropertyDescriptor(u, h);
|
|
2087
2124
|
if (S.get || S.set || !S.enumerable || ["__proto__", "constructor", "prototype"].includes(h)) throw t.error("input", "快照不允许访问器或危险键");
|
|
2088
2125
|
if (S.value === void 0 && !g) continue;
|
|
2089
|
-
c((
|
|
2126
|
+
c((p++ ? 1 : 0) + (g ? 0 : i(h) + 1));
|
|
2090
2127
|
const T = l(S.value === void 0 ? null : S.value, m + 1);
|
|
2091
2128
|
h in y ? Object.defineProperty(y, h, { value: T, enumerable: !0, configurable: !0, writable: !0 }) : y[h] = T;
|
|
2092
2129
|
}
|
|
@@ -2097,49 +2134,49 @@ function _o(e, t) {
|
|
|
2097
2134
|
return t.check?.(), f;
|
|
2098
2135
|
}
|
|
2099
2136
|
export {
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2137
|
+
Sr as A,
|
|
2138
|
+
Go as B,
|
|
2139
|
+
Do as C,
|
|
2103
2140
|
Tr as D,
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
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
|
|
2145
2182
|
};
|