@agile-team/mach-report 2.14.0 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -11
- package/THIRD_PARTY_NOTICES.md +3 -1
- package/dist/{ExcelBindingWizard-CvsWR8Ga.js → ExcelBindingWizard-BKH1nGNS.js} +3 -3
- package/dist/{ExcelBindingWizard-CLT2p7P3.cjs → ExcelBindingWizard-Bs43BGNp.cjs} +1 -1
- package/dist/ParamEditor-Da4akw6V.cjs +1 -0
- package/dist/ParamEditor-DoAhzJsm.js +594 -0
- package/dist/{ReportBatchPanel-LqVgiqp7.js → ReportBatchPanel-BMf6boMA.js} +39 -39
- package/dist/{ReportBatchPanel-DkxTzBkD.cjs → ReportBatchPanel-wP9m9Pj1.cjs} +1 -1
- package/dist/ReportPreview-ChV19HBp.js +4619 -0
- package/dist/ReportPreview-DbLvvOUT.cjs +6 -0
- package/dist/{ReportTemplateLibrary-MjWEtc7X.js → ReportTemplateLibrary-C9wutIiT.js} +1 -1
- package/dist/{ReportTemplateLibrary-cQ1sqNYo.cjs → ReportTemplateLibrary-Sxr3eD0J.cjs} +1 -1
- package/dist/{RuleEditor-ChuXMlei.js → RuleEditor-C_Clasvd.js} +5 -5
- package/dist/{RuleEditor-BaR6xUiI.cjs → RuleEditor-XhGHK8DE.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-Dci6aRn1.js → TemplateOutlinePanel-D6Bkny59.js} +2 -2
- package/dist/{TemplateOutlinePanel-BHKP89Xz.cjs → TemplateOutlinePanel-JTSR53vJ.cjs} +1 -1
- package/dist/{TemplateReusePanel-CY5eO2Sh.cjs → TemplateReusePanel-Kx35S0Ql.cjs} +1 -1
- package/dist/{TemplateReusePanel-B7Gmyc1z.js → TemplateReusePanel-rVuK1kTz.js} +2 -2
- package/dist/{TemplateReviewPanel-DjlX3xpt.js → TemplateReviewPanel-B0ar9_zf.js} +2 -2
- package/dist/{TemplateReviewPanel-JvZe9_4G.cjs → TemplateReviewPanel-Dn6X9UmY.cjs} +1 -1
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.d.cts +3 -1
- package/dist/analytics.d.ts +3 -1
- package/dist/analytics.js +154 -60
- package/dist/artifact-integrity.json +135 -0
- package/dist/assets-B9ImAi6_.cjs +1 -0
- package/dist/assets-DEaz4qsp.js +124 -0
- package/dist/batch-BaP6pWDE.cjs +1 -0
- package/dist/batch-BfZHN1do.js +220 -0
- package/dist/batch-CGyt-b2W.js +273 -0
- package/dist/batch-CLpELXBl.cjs +1 -0
- package/dist/capabilities-CAh2Nrue.cjs +1 -0
- package/dist/capabilities-DskCHs3V.js +69 -0
- package/dist/codes.d.cts +2 -0
- package/dist/codes.d.ts +2 -0
- package/dist/{computed-Bvk0W15F.js → computed-C-4C2S5h.js} +3 -3
- package/dist/config-BVsJXSqS.js +842 -0
- package/dist/config-D10us76d.cjs +1 -0
- package/dist/data-explanation-B8MZRYVS.js +16 -0
- package/dist/data-explanation-DE55G30w.cjs +1 -0
- package/dist/designer-2bDlcNXQ.js +5136 -0
- package/dist/designer-BT7XCdbW.cjs +2 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +144 -16
- package/dist/designer.d.ts +144 -16
- package/dist/designer.js +1 -1
- package/dist/drill-ByJviLXS.js +145 -0
- package/dist/drill-DYTxuL3A.cjs +1 -0
- package/dist/{font-loader-vhCT8znW.cjs → font-loader-B_UkxpzC.cjs} +1 -1
- package/dist/{font-loader-DHto6Lra.js → font-loader-Q3bQjmrI.js} +1 -1
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +82 -4
- package/dist/index.d.ts +82 -4
- package/dist/index.js +785 -820
- package/dist/json-snapshot-DFb2eWkf.js +1416 -0
- package/dist/json-snapshot-WWSGlaHG.cjs +2 -0
- package/dist/licenses/_bwip-js_generic-4.11.4.txt +24 -0
- package/dist/licenses/_fast-csv_format-4.3.5.txt +22 -0
- package/dist/licenses/_fast-csv_parse-4.3.6.txt +22 -0
- package/dist/licenses/_pdf-lib_fontkit-1.1.1.txt +326 -0
- package/dist/licenses/_pdf-lib_standard-fonts-1.0.0.txt +22 -0
- package/dist/licenses/_pdf-lib_upng-1.0.1.txt +22 -0
- package/dist/licenses/_types_node-14.18.63.txt +22 -0
- package/dist/licenses/_types_pako-2.0.3.txt +22 -0
- package/dist/licenses/_types_pegjs-0.10.6.txt +22 -0
- package/dist/licenses/archiver-5.3.2.txt +23 -0
- package/dist/licenses/archiver-utils-2.1.0.txt +23 -0
- package/dist/licenses/archiver-utils-3.0.4.txt +23 -0
- package/dist/licenses/async-3.2.6.txt +20 -0
- package/dist/licenses/balanced-match-1.0.2.txt +22 -0
- package/dist/licenses/base64-js-1.5.1.txt +22 -0
- package/dist/licenses/big-integer-1.6.52.txt +25 -0
- package/dist/licenses/binary-0.3.0.txt +178 -0
- package/dist/licenses/bl-4.1.0.txt +14 -0
- package/dist/licenses/bluebird-3.4.7.txt +22 -0
- package/dist/licenses/brace-expansion-1.1.21.txt +22 -0
- package/dist/licenses/brace-expansion-2.1.7.txt +22 -0
- package/dist/licenses/buffer-5.7.1.txt +22 -0
- package/dist/licenses/buffer-crc32-0.2.13.txt +20 -0
- package/dist/licenses/buffer-indexof-polyfill-1.0.2.txt +23 -0
- package/dist/licenses/buffers-0.1.1.txt +140 -0
- package/dist/licenses/chainsaw-0.1.0.txt +184 -0
- package/dist/licenses/compress-commons-4.1.2.txt +23 -0
- package/dist/licenses/concat-map-0.0.1.txt +19 -0
- package/dist/licenses/core-util-is-1.0.3.txt +20 -0
- package/dist/licenses/crc-32-1.2.2.txt +202 -0
- package/dist/licenses/crc32-stream-4.0.3.txt +23 -0
- package/dist/licenses/dayjs-1.11.23.txt +22 -0
- package/dist/licenses/duplexer2-0.1.4.txt +27 -0
- package/dist/licenses/end-of-stream-1.4.5.txt +22 -0
- package/dist/licenses/exceljs-4.4.0.txt +23 -0
- package/dist/licenses/fast-csv-4.3.6.txt +22 -0
- package/dist/licenses/fast-png-6.4.0.txt +22 -0
- package/dist/licenses/fs-constants-1.0.0.txt +22 -0
- package/dist/licenses/fs.realpath-1.0.0.txt +44 -0
- package/dist/licenses/fstream-1.0.12.txt +16 -0
- package/dist/licenses/glob-7.2.3.txt +22 -0
- package/dist/licenses/graceful-fs-4.2.11.txt +16 -0
- package/dist/licenses/ieee754-1.2.1.txt +12 -0
- package/dist/licenses/immediate-3.0.6.txt +21 -0
- package/dist/licenses/inflight-1.0.6.txt +16 -0
- package/dist/licenses/inherits-2.0.4.txt +17 -0
- package/dist/licenses/iobuffer-5.4.0.txt +23 -0
- package/dist/licenses/isarray-1.0.0.txt +61 -0
- package/dist/licenses/jszip-3.10.2.txt +652 -0
- package/dist/licenses/lazystream-1.0.1.txt +24 -0
- package/dist/licenses/lie-3.3.0.txt +8 -0
- package/dist/licenses/listenercount-1.0.1.txt +6 -0
- package/dist/licenses/lodash.defaults-4.2.0.txt +48 -0
- package/dist/licenses/lodash.difference-4.5.0.txt +48 -0
- package/dist/licenses/lodash.escaperegexp-4.1.2.txt +48 -0
- package/dist/licenses/lodash.flatten-4.4.0.txt +48 -0
- package/dist/licenses/lodash.groupby-4.6.0.txt +48 -0
- package/dist/licenses/lodash.isboolean-3.0.3.txt +23 -0
- package/dist/licenses/lodash.isequal-4.5.0.txt +48 -0
- package/dist/licenses/lodash.isfunction-3.0.9.txt +48 -0
- package/dist/licenses/lodash.isnil-4.0.0.txt +23 -0
- package/dist/licenses/lodash.isplainobject-4.0.6.txt +48 -0
- package/dist/licenses/lodash.isundefined-3.0.1.txt +23 -0
- package/dist/licenses/lodash.union-4.6.0.txt +48 -0
- package/dist/licenses/lodash.uniq-4.5.0.txt +48 -0
- package/dist/licenses/minimatch-3.1.5.txt +16 -0
- package/dist/licenses/minimatch-5.1.9.txt +16 -0
- package/dist/licenses/minimist-1.2.8.txt +19 -0
- package/dist/licenses/mkdirp-0.5.6.txt +22 -0
- package/dist/licenses/node-sql-parser-5.4.0.txt +202 -0
- package/dist/licenses/normalize-path-3.0.0.txt +22 -0
- package/dist/licenses/once-1.4.0.txt +16 -0
- package/dist/licenses/pako-1.0.11.txt +22 -0
- package/dist/licenses/pako-2.2.0.txt +22 -0
- package/dist/licenses/path-is-absolute-1.0.1.txt +22 -0
- package/dist/licenses/pdf-lib-1.17.1.txt +22 -0
- package/dist/licenses/process-nextick-args-2.0.1.txt +20 -0
- package/dist/licenses/readable-stream-2.3.8.txt +48 -0
- package/dist/licenses/readable-stream-3.6.2.txt +48 -0
- package/dist/licenses/readdir-glob-1.1.3.txt +202 -0
- package/dist/licenses/rimraf-2.7.1.txt +16 -0
- package/dist/licenses/safe-buffer-5.1.2.txt +22 -0
- package/dist/licenses/safe-buffer-5.2.1.txt +22 -0
- package/dist/licenses/saxes-5.0.1.txt +397 -0
- package/dist/licenses/setimmediate-1.0.5.txt +21 -0
- package/dist/licenses/string_decoder-1.1.1.txt +49 -0
- package/dist/licenses/string_decoder-1.3.0.txt +49 -0
- package/dist/licenses/tar-stream-2.2.0.txt +22 -0
- package/dist/licenses/tmp-0.2.7.txt +22 -0
- package/dist/licenses/traverse-0.3.9.txt +25 -0
- package/dist/licenses/tslib-1.14.1.txt +13 -0
- package/dist/licenses/unzipper-0.10.14.txt +26 -0
- package/dist/licenses/util-deprecate-1.0.2.txt +25 -0
- package/dist/licenses/uuid-11.1.1.txt +10 -0
- package/dist/licenses/wrappy-1.0.2.txt +16 -0
- package/dist/licenses/xmlchars-2.2.0.txt +19 -0
- package/dist/licenses/zip-stream-4.1.1.txt +23 -0
- package/dist/matrix-CGRGkn5s.js +112 -0
- package/dist/matrix-gEO7ZM_u.cjs +1 -0
- package/dist/media-B7vnpD8k.cjs +1 -0
- package/dist/media-Y90dHK9z.js +70 -0
- package/dist/param-validation-C3HlcLLO.cjs +1 -0
- package/dist/param-validation-Do7Eg8Zv.js +181 -0
- package/dist/{pdf-8UPQebOE.js → pdf-BwNyeGpt.js} +4385 -4321
- package/dist/{pdf-AyJGb22z.cjs → pdf-CvvrjPQg.cjs} +51 -49
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.d.cts +18 -3
- package/dist/pdf.d.ts +18 -3
- package/dist/pdf.js +2 -2
- package/dist/{plugin-BGKf-Tqg.js → plugin-Ca_XZG3l.js} +2 -2
- package/dist/{plugin-CktLH_Iy.cjs → plugin-DHO7X8z2.cjs} +1 -1
- package/dist/prepared-CFy9B75C.cjs +1 -0
- package/dist/prepared-ajM-H-9B.js +69 -0
- package/dist/progress-B0ctFpKf.cjs +1 -0
- package/dist/progress-D-OTpEav.js +52 -0
- package/dist/record-bindings-By_UKZ2g.cjs +1 -0
- package/dist/record-bindings-Do_b3h4V.js +196 -0
- package/dist/{region-binding-workflow-DEJbhpCv.js → region-binding-workflow-BMhK_TjP.js} +1 -1
- package/dist/{region-binding-workflow-BzfbxRiR.cjs → region-binding-workflow-DIYJdCUr.cjs} +1 -1
- package/dist/{report-params-B44imUd4.js → report-params-B1RzkhJj.js} +1 -1
- package/dist/{report-params-SJfhKgaX.cjs → report-params-WDGrA4oP.cjs} +1 -1
- package/dist/sbom.cdx.json +3982 -0
- package/dist/server/node.d.cts +20 -1
- package/dist/server/node.d.ts +20 -1
- package/dist/server-node.cjs +1 -1
- package/dist/server-node.js +247 -237
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +772 -4
- package/dist/server.d.ts +772 -4
- package/dist/server.js +885 -645
- package/dist/sha256-ArEYjaTI.cjs +1 -0
- package/dist/sha256-DPEuJ3nh.js +155 -0
- package/dist/style.css +1 -1
- package/dist/template-bindings-C2SpvsMU.js +58 -0
- package/dist/template-bindings-CEtWyiLX.cjs +1 -0
- package/dist/template-catalog-FJE_c9Qe.cjs +1 -0
- package/dist/template-catalog-j2B1MJlL.js +414 -0
- package/dist/{template-fragments-CLkGo6To.js → template-fragments-BGbQLGlV.js} +21 -21
- package/dist/{template-fragments-DFUpq5QM.cjs → template-fragments-DcKeiylI.cjs} +1 -1
- package/dist/{template-outline-B3xVkzSv.cjs → template-outline-BwRV_eRo.cjs} +1 -1
- package/dist/{template-outline-CFenM1PV.js → template-outline-cnWfT_LK.js} +3 -3
- package/dist/{template-registry-COXDEJEM.js → template-registry-BtaKPELV.js} +364 -201
- package/dist/template-registry-Co1zPq5e.cjs +1 -0
- package/dist/textwrap-CWHyzkBH.cjs +4 -0
- package/dist/textwrap-DE1kgcJB.js +110 -0
- package/dist/{tree-CqcQ99NM.js → tree-CjVZLRw7.js} +1 -1
- package/dist/vue/async.d.cts +123 -14
- package/dist/vue/async.d.ts +123 -14
- package/dist/vue/index.d.cts +158 -22
- package/dist/vue/index.d.ts +158 -22
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +80 -78
- package/dist/{workbook-session-DNa2RHNG.cjs → workbook-session-Bjv1YCRK.cjs} +18 -18
- package/dist/{workbook-session-BfK1yHOO.js → workbook-session-BvToI-Fd.js} +5440 -5288
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +20 -1
- package/dist/worker.d.ts +20 -1
- package/dist/worker.js +33 -32
- package/dist/xlsx-node.cjs +34 -34
- package/dist/xlsx-node.js +878 -870
- package/dist/xlsx.cjs +3 -4
- package/dist/xlsx.d.cts +22 -10
- package/dist/xlsx.d.ts +22 -10
- package/dist/xlsx.js +261 -253
- package/package.json +2 -2
- package/dist/ParamEditor-CflQV3eQ.js +0 -526
- package/dist/ParamEditor-vIDzvpPV.cjs +0 -1
- package/dist/ReportPreview-CvbqLUzM.cjs +0 -6
- package/dist/ReportPreview-D_ywJ_-H.js +0 -4533
- package/dist/assets-C2U-e-Sz.cjs +0 -4
- package/dist/assets-Q0wUwNrV.js +0 -217
- package/dist/batch-DzaTNLWI.js +0 -371
- package/dist/batch-xMkqYiTr.cjs +0 -1
- package/dist/capabilities-CK_7hizc.js +0 -63
- package/dist/capabilities-CsZ-pNHR.cjs +0 -1
- package/dist/config-0UIohTS7.cjs +0 -1
- package/dist/config-Dt9NtCPl.js +0 -566
- package/dist/data-explanation-BktvER5B.cjs +0 -1
- package/dist/data-explanation-C_J6jYNi.js +0 -16
- package/dist/designer-Ci1LizA9.js +0 -5020
- package/dist/designer-rtmVIIdN.cjs +0 -2
- package/dist/json-snapshot-BeFT3Tso.js +0 -1952
- package/dist/json-snapshot-D1NTP2oI.cjs +0 -2
- package/dist/matrix-DVyWiYsd.cjs +0 -1
- package/dist/matrix-yZsGnldA.js +0 -227
- package/dist/page-window-index-CIuT4BAv.js +0 -43
- package/dist/page-window-index-DEjnM6IB.cjs +0 -1
- package/dist/param-validation-BlHHXs6u.js +0 -153
- package/dist/param-validation-DCK039V1.cjs +0 -1
- package/dist/progress-7OSZbFok.js +0 -39
- package/dist/progress-BnLiS5eH.cjs +0 -1
- package/dist/task-events-DQ276fn2.cjs +0 -1
- package/dist/task-events-Dpsvf_t2.js +0 -47
- package/dist/template-bindings-BJR4k7qZ.cjs +0 -1
- package/dist/template-bindings-Daui7hLF.js +0 -252
- package/dist/template-registry-D3SjENi6.cjs +0 -1
- package/dist/validate-BJ5HIWY8.cjs +0 -1
- package/dist/validate-CkQBWCeg.js +0 -163
|
@@ -1,1952 +0,0 @@
|
|
|
1
|
-
import { R as Y } from "./render-plan-Ck6koX9L.js";
|
|
2
|
-
import { v as Ae } from "./validate-CkQBWCeg.js";
|
|
3
|
-
import { g as Tt } from "./report-params-B44imUd4.js";
|
|
4
|
-
import { e as Pt, r as It, f as Rt, v as kt, R as Et, p as ce } from "./template-registry-COXDEJEM.js";
|
|
5
|
-
import { a as Te, d as Ct } from "./param-validation-BlHHXs6u.js";
|
|
6
|
-
import { r as me } from "./grid-geometry-BNptEcMm.js";
|
|
7
|
-
import { f as Ot, i as Ft } from "./number-format-BA_KwrZe.js";
|
|
8
|
-
import { c as At } from "./task-events-Dpsvf_t2.js";
|
|
9
|
-
import { h as jt } from "./data-explanation-C_J6jYNi.js";
|
|
10
|
-
import { d as Nt, v as je } from "./dataset-H5pFuQGU.js";
|
|
11
|
-
import { c as Kt, D as Ne, L as Ke } from "./defaults-DXhiM1ZD.js";
|
|
12
|
-
import { w as Q, h as Le } from "./assets-Q0wUwNrV.js";
|
|
13
|
-
import { R as E, h as He, b as Lt, i as Ht, e as B, l as ge, c as Bt, t as Be, j as De, f as We, k as Dt, m as Wt, g as Ge } from "./template-bindings-Daui7hLF.js";
|
|
14
|
-
import { d as Ve, b as Gt } from "./computed-Bvk0W15F.js";
|
|
15
|
-
import { e as Vt, a as Jt } from "./matrix-yZsGnldA.js";
|
|
16
|
-
import { f as Je, a as zt, c as _t } from "./tree-CqcQ99NM.js";
|
|
17
|
-
import { r as pe, b as qt, e as A } from "./style-CQ1PK8ZB.js";
|
|
18
|
-
import { i as Ut } from "./capabilities-CK_7hizc.js";
|
|
19
|
-
function Xt(e, t, r) {
|
|
20
|
-
const n = /* @__PURE__ */ new Set(), o = e.cells.map((a, s) => {
|
|
21
|
-
const c = [];
|
|
22
|
-
let i = 0;
|
|
23
|
-
for (const l of a) {
|
|
24
|
-
for (; n.has(`${s}:${i}`); ) i++;
|
|
25
|
-
const d = l?.colSpan ?? 1, u = l?.rowSpan ?? 1;
|
|
26
|
-
let f = 0;
|
|
27
|
-
for (let m = i; m < i + d; m++) {
|
|
28
|
-
t.has(m) && f++;
|
|
29
|
-
for (let p = s + 1; p < s + u; p++)
|
|
30
|
-
n.add(`${p}:${m}`);
|
|
31
|
-
}
|
|
32
|
-
f && c.push(l ? { ...l, colSpan: f } : null), i += d;
|
|
33
|
-
}
|
|
34
|
-
return c;
|
|
35
|
-
});
|
|
36
|
-
return { ...e, cells: o, colWidthsMm: r };
|
|
37
|
-
}
|
|
38
|
-
function Yt(e) {
|
|
39
|
-
if (!e.columns.some((n) => n.hidden)) return e;
|
|
40
|
-
const t = /* @__PURE__ */ new Set(), r = e.columns.filter((n, o) => n.hidden ? !1 : (t.add(o), !0));
|
|
41
|
-
if (!r.length) throw new Error("列表至少需要一列可见列");
|
|
42
|
-
return {
|
|
43
|
-
...e,
|
|
44
|
-
columns: r,
|
|
45
|
-
...e.headerGrid ? {
|
|
46
|
-
headerGrid: Xt(
|
|
47
|
-
e.headerGrid,
|
|
48
|
-
t,
|
|
49
|
-
r.map((n) => n.widthMm)
|
|
50
|
-
)
|
|
51
|
-
} : {}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function* Qt(e) {
|
|
55
|
-
const { page: t } = e;
|
|
56
|
-
Pt(t.components, t.flow);
|
|
57
|
-
let r = 0, n = 0;
|
|
58
|
-
for (const o of It(t.components, t.flow)) {
|
|
59
|
-
e.active();
|
|
60
|
-
const a = o.band, s = o.components.some((d) => d.kind === "list" && d.cardinality !== "record"), c = s ? 0 : o.components.reduce((d, u) => Math.max(d, u.topMm - a.topMm + (u.kind === "list" ? e.height(u) : u.heightMm)), a.heightMm);
|
|
61
|
-
let i = Math.max(e.top(), n + a.topMm - r);
|
|
62
|
-
if (!s && c > e.bottom() - e.top() + 1e-3) throw new Error(`静态区域 ${a.componentIds.join(",")} 高度超出单页可用范围`);
|
|
63
|
-
!s && i + c > e.bottom() + 1e-3 && (e.nextPage(), yield* e.takePages(), e.active(), i = e.top());
|
|
64
|
-
let l = i + c;
|
|
65
|
-
for (const d of o.components) {
|
|
66
|
-
const u = i + d.topMm - a.topMm;
|
|
67
|
-
d.kind === "list" ? (yield* e.list(d, u, (f) => {
|
|
68
|
-
l = s ? f : Math.max(l, f);
|
|
69
|
-
}), e.active()) : e.append({ ...d, topMm: u });
|
|
70
|
-
}
|
|
71
|
-
n = l, r = a.topMm + a.heightMm;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function Zt(e) {
|
|
75
|
-
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));
|
|
76
|
-
}
|
|
77
|
-
function Z(e) {
|
|
78
|
-
return e.pages.some((t) => t.components.some((r) => r.kind === "list" && Zt(r)));
|
|
79
|
-
}
|
|
80
|
-
const er = 512, Pe = 256 * 1024;
|
|
81
|
-
function tr() {
|
|
82
|
-
const e = /* @__PURE__ */ new Map();
|
|
83
|
-
let t = 0, r;
|
|
84
|
-
return (n, o, a, s) => {
|
|
85
|
-
s !== r && (e.clear(), t = 0, r = s);
|
|
86
|
-
const c = JSON.stringify([n, o, a.fontSizePt, a.fontFamily, a.bold, a.italic, a.letterSpacingPt]), i = e.get(c);
|
|
87
|
-
if (i)
|
|
88
|
-
return e.delete(c), e.set(c, i), i.lines.slice();
|
|
89
|
-
const l = Q(n, o, a, s), d = c.length + l.reduce((u, f) => u + f.length, 0);
|
|
90
|
-
if (d <= Pe) {
|
|
91
|
-
for (; e.size >= er || t + d > Pe; ) {
|
|
92
|
-
const u = e.keys().next().value;
|
|
93
|
-
t -= e.get(u).units, e.delete(u);
|
|
94
|
-
}
|
|
95
|
-
e.set(c, { lines: l.slice(), units: d }), t += d;
|
|
96
|
-
}
|
|
97
|
-
return l;
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
class K extends Error {
|
|
101
|
-
constructor(t, r) {
|
|
102
|
-
super(`报表页数超出上限 ${t}(至少 ${r} 页)`), this.limit = t, this.actual = r, this.code = "page-limit", this.name = "PaginatePageLimitError";
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
class D extends Error {
|
|
106
|
-
constructor(t, r) {
|
|
107
|
-
super(`报表单元格数量超出上限 ${t}(至少 ${r} 格)`), this.limit = t, this.actual = r, this.code = "cell-limit", this.name = "PaginateCellLimitError";
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
const rr = 1e4, Ie = 25e4;
|
|
111
|
-
function he(e) {
|
|
112
|
-
if (e?.aborted) throw e.reason ?? new DOMException("标签生成已取消", "AbortError");
|
|
113
|
-
}
|
|
114
|
-
function ze(e, t, r) {
|
|
115
|
-
const n = typeof e.copies == "object" ? He(t, e.copies.field, r) : e.copies ?? 1;
|
|
116
|
-
if (typeof n != "number" || !Number.isSafeInteger(n) || n < 1 || n > 1e3) throw new E(`$.datasets.${r.dataset}[${r.rowIndex}]`, "每条记录复制数必须是 1..1000 的数值型整数", r.rowIndex, typeof e.copies == "object" ? e.copies.field : void 0);
|
|
117
|
-
return n;
|
|
118
|
-
}
|
|
119
|
-
function _e(e, t, r) {
|
|
120
|
-
if (e.rowKey === void 0) return;
|
|
121
|
-
const n = He(t, e.rowKey, r);
|
|
122
|
-
if (typeof n == "string" && n.trim() || typeof n == "number" && Number.isFinite(n)) return n;
|
|
123
|
-
throw new E(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`, "业务主键必须是非空字符串或有限数字", r.rowIndex, e.rowKey);
|
|
124
|
-
}
|
|
125
|
-
function nr(e) {
|
|
126
|
-
const t = (r) => 1 + (r.grid?.cells.reduce((n, o) => n + 1 + o.length + o.reduce((a, s) => a + (s?.children?.reduce((c, i) => c + t(i), 0) ?? 0), 0), 0) ?? 0);
|
|
127
|
-
return e.pages.reduce((r, n) => r + n.components.reduce((o, a) => o + t(a), 0), 0);
|
|
128
|
-
}
|
|
129
|
-
function or(e, t, r) {
|
|
130
|
-
const n = e.repeat, o = Object.prototype.hasOwnProperty.call(t, n.dataset) ? t[n.dataset] : void 0;
|
|
131
|
-
if (!Array.isArray(o)) throw new E(`$.datasets.${n.dataset}`, "逐记录标签数据集缺失,应提供对象数组(允许空数组)");
|
|
132
|
-
const a = /* @__PURE__ */ new Set(), s = r.maxPages ?? rr, c = nr(e);
|
|
133
|
-
let i = 0, l = 0;
|
|
134
|
-
for (const [d, u] of o.entries()) {
|
|
135
|
-
if (he(r.signal), !u || typeof u != "object" || Array.isArray(u)) throw new E(`$.datasets.${n.dataset}[${d}]`, "标签记录应为对象", d);
|
|
136
|
-
const f = { rowIndex: d, dataset: n.dataset }, m = _e(n, u, f);
|
|
137
|
-
if (m !== void 0) {
|
|
138
|
-
const g = JSON.stringify([typeof m, m]);
|
|
139
|
-
if (a.has(g)) throw new E(`$.datasets.${n.dataset}[${d}].${n.rowKey}`, "业务主键重复;请先确认记录来源,避免重复打印标签", d, n.rowKey);
|
|
140
|
-
a.add(g);
|
|
141
|
-
}
|
|
142
|
-
const p = ze(n, u, f);
|
|
143
|
-
if (i += p * e.pages.length, l += p * c, i > s) throw new K(s, i);
|
|
144
|
-
if (l > Ie) throw new E("$.repeat", `标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${Ie},请分批生成`, d);
|
|
145
|
-
}
|
|
146
|
-
return o;
|
|
147
|
-
}
|
|
148
|
-
function ar(e, t, r) {
|
|
149
|
-
if (!e.binding) return e;
|
|
150
|
-
const { binding: n, ...o } = e, a = Lt(n, t.row, t);
|
|
151
|
-
if (e.kind === "image") {
|
|
152
|
-
if (!a) return;
|
|
153
|
-
if (!Ht(a)) throw new E(`${r}.binding`, "图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换", t.rowIndex, n.field);
|
|
154
|
-
return { ...o, imageData: a };
|
|
155
|
-
}
|
|
156
|
-
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 });
|
|
157
|
-
}
|
|
158
|
-
function sr(e, t, r) {
|
|
159
|
-
if (e.kind !== "text" || e.grid || e.richParagraphs?.length) return e;
|
|
160
|
-
const n = e.style ?? {}, o = pe(n).fontSizePt, a = e.text ?? e.lines?.join(`
|
|
161
|
-
`) ?? "";
|
|
162
|
-
if (a.length > 16384) throw new E(r, "标签文本超过 16384 字符预算,请缩小字段内容", t.rowIndex);
|
|
163
|
-
const s = t.wrapText(a, e.widthMm, { fontSizePt: o, bold: n.bold, italic: n.italic, fontFamily: n.fontFamily, letterSpacingPt: n.letterSpacing }, t.options.measurer ?? Le), c = s.length * o * qt(n) * 25.4 / 72;
|
|
164
|
-
if (c > e.heightMm + 0.05) throw new E(r, `标签文字需要约 ${c.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`, t.rowIndex, e.binding?.field);
|
|
165
|
-
return { ...e, lines: s };
|
|
166
|
-
}
|
|
167
|
-
function qe(e, t, r) {
|
|
168
|
-
he(t.options.signal);
|
|
169
|
-
const n = ar(e, t, r);
|
|
170
|
-
if (!n) return;
|
|
171
|
-
let o = n.grid;
|
|
172
|
-
return o && (o = { ...o, cells: o.cells.map((a, s) => a.map((c, i) => c?.children?.length ? { ...c, children: c.children.flatMap((l, d) => {
|
|
173
|
-
const u = qe(l, t, `${r}.grid.cells.${s}.${i}.children.${d}`);
|
|
174
|
-
return u ? [u] : [];
|
|
175
|
-
}) } : c)) }), sr(o === n.grid ? n : { ...n, grid: o }, t, r);
|
|
176
|
-
}
|
|
177
|
-
function ir(e, t, r, n, o, a) {
|
|
178
|
-
return {
|
|
179
|
-
...e,
|
|
180
|
-
components: e.components.flatMap((s, c) => {
|
|
181
|
-
const i = qe(s, r, `$.pages.${t}.components.${c}`);
|
|
182
|
-
return i ? [{ ...i, meta: { ...i.meta, labelSource: { pageIndex: t, componentIndex: c } } }] : [];
|
|
183
|
-
}),
|
|
184
|
-
meta: { ...e.meta, record: { dataset: r.dataset, rowIndex: r.rowIndex, ...a === void 0 ? {} : { rowKey: a }, copyIndex: n, copyCount: o, templatePageIndex: t } }
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
function* cr(e, t, r) {
|
|
188
|
-
const n = [];
|
|
189
|
-
if (Rt(e, n), n.length) throw new E(n[0].path, n[0].message);
|
|
190
|
-
if (!e.repeat) {
|
|
191
|
-
for (const [c, i] of e.pages.entries()) yield { page: i, pageIndex: c };
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
const o = e.repeat, a = or(e, t, r), s = tr();
|
|
195
|
-
for (const [c, i] of a.entries()) {
|
|
196
|
-
const l = { row: i, rowIndex: c, dataset: o.dataset, options: r, wrapText: s }, d = ze(o, i, l), u = _e(o, i, l);
|
|
197
|
-
for (let f = 0; f < d; f++) for (const [m, p] of e.pages.entries())
|
|
198
|
-
he(r.signal), yield { page: ir(p, m, l, f, d, u), pageIndex: m };
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
function lr(e) {
|
|
202
|
-
return {
|
|
203
|
-
widthMm: e.widthMm,
|
|
204
|
-
heightMm: e.heightMm,
|
|
205
|
-
marginTopMm: e.marginTopMm ?? 0,
|
|
206
|
-
marginBottomMm: e.marginBottomMm ?? 0,
|
|
207
|
-
marginLeftMm: e.marginLeftMm ?? 0,
|
|
208
|
-
marginRightMm: e.marginRightMm ?? 0,
|
|
209
|
-
components: []
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
function U(e, t) {
|
|
213
|
-
const r = t.heightMm - (e.layout === "wide" ? t.marginBottomMm : e.marginBottomMm ?? t.marginBottomMm);
|
|
214
|
-
return e.components.reduce((n, o) => o.kind !== "list" && o.pageAnchor === "footer" ? Math.min(n, o.topMm) : n, r);
|
|
215
|
-
}
|
|
216
|
-
function G(e) {
|
|
217
|
-
return e.components.reduce((t, r) => r.kind !== "list" && r.pageAnchor === "header" ? Math.max(t, r.topMm + r.heightMm) : t, 0);
|
|
218
|
-
}
|
|
219
|
-
function Ue(e, t) {
|
|
220
|
-
let r = e.textMetrics.get(t);
|
|
221
|
-
if (!r) {
|
|
222
|
-
const n = pe(t).fontSizePt;
|
|
223
|
-
r = {
|
|
224
|
-
measureOptions: {
|
|
225
|
-
fontSizePt: n,
|
|
226
|
-
fontFamily: t.fontFamily ?? Ne,
|
|
227
|
-
italic: t.italic,
|
|
228
|
-
bold: t.bold,
|
|
229
|
-
letterSpacingPt: t.letterSpacing
|
|
230
|
-
},
|
|
231
|
-
lineMm: n * (t.lineHeight ?? Ke) * 25.4 / 72
|
|
232
|
-
}, e.textMetrics.set(t, r);
|
|
233
|
-
}
|
|
234
|
-
return r;
|
|
235
|
-
}
|
|
236
|
-
function dr(e) {
|
|
237
|
-
if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return e;
|
|
238
|
-
}
|
|
239
|
-
function we(e, t) {
|
|
240
|
-
const r = e.fontSizePt ?? Kt, n = e.paddingMm ?? 1, o = e.columns.map((g) => g.align ?? g.style?.align ?? e.align ?? "left"), a = e.columns.map((g, w) => ({
|
|
241
|
-
...A({
|
|
242
|
-
fontSize: r,
|
|
243
|
-
verticalAlign: "middle"
|
|
244
|
-
}, g.style),
|
|
245
|
-
align: o[w] === "auto" ? "left" : o[w]
|
|
246
|
-
})), s = a.map((g, w) => o[w] === "auto" ? { left: g, center: { ...g, align: "center" }, right: { ...g, align: "right" } } : void 0), c = e.columns.map((g, w) => g.rules?.map((v) => {
|
|
247
|
-
const M = s[w];
|
|
248
|
-
if (M) return {
|
|
249
|
-
left: A(M.left, v.style),
|
|
250
|
-
center: A(M.center, v.style),
|
|
251
|
-
right: A(M.right, v.style)
|
|
252
|
-
};
|
|
253
|
-
const y = A(a[w], v.style);
|
|
254
|
-
return { left: y, center: y, right: y };
|
|
255
|
-
})), i = e.columns.map((g) => Bt(e, g)), l = e.columns.map((g) => g.header);
|
|
256
|
-
let d = e.rowHeightMm ?? 0;
|
|
257
|
-
for (let g = 0; g < l.length; g++) {
|
|
258
|
-
const w = i[g], v = pe(w).fontSizePt, M = Q(
|
|
259
|
-
l[g],
|
|
260
|
-
e.columns[g].widthMm - n * 2,
|
|
261
|
-
{ fontSizePt: v, fontFamily: w.fontFamily ?? Ne, italic: w.italic, bold: w.bold, letterSpacingPt: w.letterSpacing },
|
|
262
|
-
t
|
|
263
|
-
), y = v * (w.lineHeight ?? Ke) * 25.4 / 72;
|
|
264
|
-
d = Math.max(d, Math.max(M.length, 1) * y + n * 2);
|
|
265
|
-
}
|
|
266
|
-
const u = l.map((g, w) => ({
|
|
267
|
-
text: g,
|
|
268
|
-
style: i[w]
|
|
269
|
-
})), f = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, m = e.columns.map((g) => g.widthMm), p = ur(e.headerGrid, m, {
|
|
270
|
-
cells: [u],
|
|
271
|
-
colWidthsMm: m,
|
|
272
|
-
rowHeightsMm: [d],
|
|
273
|
-
paddingMm: n
|
|
274
|
-
});
|
|
275
|
-
return {
|
|
276
|
-
fontSizePt: r,
|
|
277
|
-
paddingMm: n,
|
|
278
|
-
cellStyles: a,
|
|
279
|
-
autoStyles: s,
|
|
280
|
-
ruleStyles: c,
|
|
281
|
-
textMetrics: /* @__PURE__ */ new WeakMap(),
|
|
282
|
-
numberFormats: e.columns.map((g) => Be(g.format)),
|
|
283
|
-
derivedFields: new Set(e.computed?.map((g) => g.field)),
|
|
284
|
-
borderStyle: f,
|
|
285
|
-
headerHeightMm: p.rowHeightsMm.reduce((g, w) => g + w, 0),
|
|
286
|
-
headerGrid: p,
|
|
287
|
-
colWidthsMm: m,
|
|
288
|
-
columns: e.columns
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
function ur(e, t, r) {
|
|
292
|
-
if (!e) return r;
|
|
293
|
-
if (!e.cells.length) throw new Error("自定义列表表头至少需要一行");
|
|
294
|
-
const n = e.rowHeightsMm ?? e.cells.map(() => r.rowHeightsMm[0]);
|
|
295
|
-
if (n.length !== e.cells.length || n.some((o) => !Number.isFinite(o) || o <= 0)) throw new Error("自定义列表表头行高无效");
|
|
296
|
-
return { ...e, colWidthsMm: t, rowHeightsMm: n };
|
|
297
|
-
}
|
|
298
|
-
function fr(e, t, r) {
|
|
299
|
-
const n = t.format?.kind === "number" || t.format?.kind === "percent";
|
|
300
|
-
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);
|
|
301
|
-
}
|
|
302
|
-
function V(e, t, r) {
|
|
303
|
-
const n = e.columns, o = e.tree?.rows.get(t);
|
|
304
|
-
let a = e.rowHeightFloorMm;
|
|
305
|
-
const s = new Array(n.length);
|
|
306
|
-
for (let c = 0; c < n.length; c++) {
|
|
307
|
-
const i = n[c], l = i.visibleWhen && !B(t, i.visibleWhen) ? null : t[i.field], d = e.autoStyles[c] ? De(l, i.format, i.semanticRole) : "left";
|
|
308
|
-
let u = e.autoStyles[c]?.[d] ?? e.cellStyles[c];
|
|
309
|
-
if (i.rules)
|
|
310
|
-
for (let M = 0; M < i.rules.length; M++) {
|
|
311
|
-
const y = i.rules[M];
|
|
312
|
-
if (B(t, y.when)) {
|
|
313
|
-
u = e.ruleStyles[c][M][d];
|
|
314
|
-
break;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
const f = i.format ? We(l, i.format) : ge(l), m = mr(e, i, o);
|
|
318
|
-
u = gr(e, i, u, o);
|
|
319
|
-
const p = Ue(e, u), g = Q(f, Math.max(1, i.widthMm - e.paddingMm * 2 - m), p.measureOptions, r);
|
|
320
|
-
a = Math.max(a, g.length * p.lineMm + e.paddingMm * 2);
|
|
321
|
-
const w = dr(l), v = { text: f, style: u };
|
|
322
|
-
w !== void 0 && (v.value = w), fr(v, i, e.numberFormats[c]), pr(v, i, e, o, m), e.derivedFields.has(i.field) && (v.derived = !0, v.editable = !1), i.visibleWhen && l === null && !B(t, i.visibleWhen) && (v.editable = !1), s[c] = v;
|
|
323
|
-
}
|
|
324
|
-
return {
|
|
325
|
-
grid: { cells: [s], colWidthsMm: e.colWidthsMm, rowHeightsMm: [a], paddingMm: e.paddingMm },
|
|
326
|
-
heightMm: a
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
function mr(e, t, r) {
|
|
330
|
-
return !r || t.field !== e.tree.list.tree.labelField ? 0 : Dt(e.tree.list, t, r, e.paddingMm);
|
|
331
|
-
}
|
|
332
|
-
function gr(e, t, r, n) {
|
|
333
|
-
return !n || t.field !== e.tree.list.tree.labelField || r.align === "left" ? r : { ...r, align: "left" };
|
|
334
|
-
}
|
|
335
|
-
function pr(e, t, r, n, o = 0) {
|
|
336
|
-
n && (o && (e.indentMm = o), Wt(e, t, n, r.tree.list));
|
|
337
|
-
}
|
|
338
|
-
function Xe(e) {
|
|
339
|
-
if (e != null && typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e))) throw new Error("分组字段应为有限 JSON 标量");
|
|
340
|
-
return JSON.stringify([typeof e, e ?? null]);
|
|
341
|
-
}
|
|
342
|
-
function* Ye(e, t, r = 0) {
|
|
343
|
-
const n = t[r];
|
|
344
|
-
if (!n) {
|
|
345
|
-
for (const a of e) yield { kind: "row", row: a };
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
const o = /* @__PURE__ */ new Map();
|
|
349
|
-
for (const a of e) {
|
|
350
|
-
const s = Xe(a[n.field]), c = o.get(s);
|
|
351
|
-
c ? c.push(a) : o.set(s, [a]);
|
|
352
|
-
}
|
|
353
|
-
for (const a of o.values())
|
|
354
|
-
yield { kind: "groupHeader", label: (n.headerTemplate ?? "{value}").replace(/\{value\}/g, ge(a[0][n.field])), firstRow: a[0], group: n, depth: r, rows: a }, yield* Ye(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 };
|
|
355
|
-
}
|
|
356
|
-
function Qe(e, t, r, n = []) {
|
|
357
|
-
const o = [...r.filter((a) => !n.some((s) => s.field === a)).map((a) => ({ field: a, op: "sum" })), ...n];
|
|
358
|
-
return new Map(o.map((a) => {
|
|
359
|
-
const s = e.find((i) => i.field === a.field)?.format ?? { kind: "number", thousands: !0 }, c = Gt(t, { ...a, field: a.valueField ?? a.field });
|
|
360
|
-
return [a.field, { text: We(c, s), ...c === null ? {} : { value: c }, ...typeof c == "number" ? { numberFormat: Be(s) } : {} }];
|
|
361
|
-
}));
|
|
362
|
-
}
|
|
363
|
-
function Ze(e, t) {
|
|
364
|
-
const r = e.findIndex((n) => t.includes(n.field));
|
|
365
|
-
return r < 0 ? 1 : r;
|
|
366
|
-
}
|
|
367
|
-
function W(e, t, r, n, o, a) {
|
|
368
|
-
const s = [], c = Math.max(0, Math.min(a, e.columns.length)), i = A({ fontSize: e.fontSizePt }, o);
|
|
369
|
-
c && s.push({ text: r, colSpan: c, style: { bold: !0, ...i } });
|
|
370
|
-
for (let f = c; f < e.columns.length; f++) {
|
|
371
|
-
const m = e.columns[f], p = n.get(m.field), g = e.autoStyles[f]?.[De(p?.value, m.format)] ?? e.cellStyles[f];
|
|
372
|
-
s.push({ ...p, text: p?.text ?? "", style: A(g, o) });
|
|
373
|
-
}
|
|
374
|
-
const l = { text: r, colSpan: e.columns.length, style: { bold: !0, ...i } }, d = c ? [s] : [[l], s], u = d.map((f) => hr(e, f, t));
|
|
375
|
-
return {
|
|
376
|
-
grid: { cells: d, colWidthsMm: e.colWidthsMm, rowHeightsMm: u, paddingMm: e.paddingMm },
|
|
377
|
-
heightMm: u.reduce((f, m) => f + m, 0)
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
function hr(e, t, r) {
|
|
381
|
-
let n = e.rowHeightFloorMm, o = 0;
|
|
382
|
-
for (const a of t) {
|
|
383
|
-
let s = 0;
|
|
384
|
-
const c = o + (a.colSpan ?? 1);
|
|
385
|
-
for (; o < c; o++) s += e.colWidthsMm[o] ?? 0;
|
|
386
|
-
const i = Ue(e, a.style), l = Q(a.text ?? "", s - e.paddingMm * 2, i.measureOptions, r);
|
|
387
|
-
n = Math.max(n, l.length * i.lineMm + e.paddingMm * 2);
|
|
388
|
-
}
|
|
389
|
-
return n;
|
|
390
|
-
}
|
|
391
|
-
function wr(e, t, r) {
|
|
392
|
-
const { templatePage: n, current: o, warnings: a, nextId: s, pushCurrent: c } = r, i = () => U(n, o), l = Math.max(o.marginTopMm, G(n)), d = n.layout === "wide" ? G(n) : l, u = {
|
|
393
|
-
id: r.tableId,
|
|
394
|
-
columnKeys: e.columns.map((h) => h.field),
|
|
395
|
-
...e.layout === void 0 ? {} : { layout: e.layout },
|
|
396
|
-
...e.title === void 0 ? {} : { title: e.title }
|
|
397
|
-
}, f = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), p = {
|
|
398
|
-
kind: "rect",
|
|
399
|
-
leftMm: e.leftMm,
|
|
400
|
-
topMm: 0,
|
|
401
|
-
widthMm: e.widthMm,
|
|
402
|
-
heightMm: t.headerHeightMm,
|
|
403
|
-
grid: t.headerGrid,
|
|
404
|
-
nid: s("listh"),
|
|
405
|
-
table: { ...u, role: "header", rowIndex: -1 },
|
|
406
|
-
style: t.borderStyle,
|
|
407
|
-
...e.meta ? { meta: e.meta } : {}
|
|
408
|
-
}, g = (h) => o.components.push({ ...p, topMm: h });
|
|
409
|
-
if (r.flow && e.header !== !1 && t.headerHeightMm > i() - l + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的表头高度超出单页可用范围`);
|
|
410
|
-
let w = Math.max(r.startTop ?? e.topMm, l);
|
|
411
|
-
e.header !== !1 && (g(w), w += t.headerHeightMm + r.mmPerRow);
|
|
412
|
-
function v() {
|
|
413
|
-
const h = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, d);
|
|
414
|
-
return (e.header !== !1 && e.headerEveryPage !== !1 ? h + t.headerHeightMm : d) + [...m.values()].reduce(($, T) => $ + T.heightMm, 0);
|
|
415
|
-
}
|
|
416
|
-
function M() {
|
|
417
|
-
const h = n.layout === "wide" ? 0 : o.marginBottomMm;
|
|
418
|
-
return Math.min(n.heightMm - h, U(n, o)) - v();
|
|
419
|
-
}
|
|
420
|
-
function y(h) {
|
|
421
|
-
if (w + h <= i()) return;
|
|
422
|
-
c(), o.components = [], o.heightMm = n.heightMm, n.layout === "wide" && (o.marginTopMm = 0, o.marginBottomMm = 0);
|
|
423
|
-
const x = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, d);
|
|
424
|
-
e.header !== !1 && e.headerEveryPage !== !1 ? (g(x), w = x + t.headerHeightMm) : w = d;
|
|
425
|
-
for (const $ of m.values()) O($, "listgr", "group-header");
|
|
426
|
-
}
|
|
427
|
-
function j(h, x, $, T) {
|
|
428
|
-
const P = M();
|
|
429
|
-
if (r.flow && h.heightMm > P + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的单行高度超出单页可用范围`);
|
|
430
|
-
h.heightMm > P && a.push(`列表 ${e.id ?? e.dataset} 行高 ${h.heightMm.toFixed(2)}mm 超出单页可用高度 ${P.toFixed(2)}mm,预览与打印可能截断内容`), y(h.heightMm), O(h, x, $, T);
|
|
431
|
-
}
|
|
432
|
-
function O(h, x, $, T) {
|
|
433
|
-
const P = h.table?.id ?? u.id, F = $ === "header" ? -1 : f.get(P) ?? 0;
|
|
434
|
-
$ !== "header" && f.set(P, F + h.grid.cells.length), o.components.push({
|
|
435
|
-
kind: "rect",
|
|
436
|
-
leftMm: e.leftMm,
|
|
437
|
-
topMm: w,
|
|
438
|
-
widthMm: e.widthMm,
|
|
439
|
-
heightMm: h.heightMm,
|
|
440
|
-
grid: h.grid,
|
|
441
|
-
nid: s(x),
|
|
442
|
-
table: { ...u, ...h.table, role: $, rowIndex: F, ...T ? { source: T } : {} },
|
|
443
|
-
style: t.borderStyle,
|
|
444
|
-
...e.meta ? { meta: e.meta } : {}
|
|
445
|
-
}), w += h.heightMm;
|
|
446
|
-
}
|
|
447
|
-
function I(h) {
|
|
448
|
-
h <= M() && y(h);
|
|
449
|
-
}
|
|
450
|
-
return { keepTogether: I, placeGridRow: j, setGroupHeader: (h, x) => {
|
|
451
|
-
x ? m.set(h, x) : m.delete(h);
|
|
452
|
-
}, bottom: () => w };
|
|
453
|
-
}
|
|
454
|
-
function yr(e, t) {
|
|
455
|
-
if (!e.rowKey) return;
|
|
456
|
-
const r = t[e.rowKey];
|
|
457
|
-
if ((typeof r != "string" || !r.trim()) && !(typeof r == "number" && Number.isFinite(r)))
|
|
458
|
-
throw new Error(`数据集 ${e.dataset} 的 ${e.rowKey} 应为稳定的字符串或有限数字主键`);
|
|
459
|
-
const n = e.revisionField ? t[e.revisionField] : void 0, o = e.sourceTokenField ? t[e.sourceTokenField] : void 0;
|
|
460
|
-
if (n !== void 0 && typeof n != "string" && !(typeof n == "number" && Number.isFinite(n))) throw new Error("业务修订号应为字符串或有限数字");
|
|
461
|
-
if (o !== void 0 && typeof o != "string") throw new Error("来源令牌应为字符串");
|
|
462
|
-
return { datasetId: e.dataset, rowKey: r, ...n === void 0 ? {} : { revision: n }, ...o === void 0 ? {} : { sourceToken: o } };
|
|
463
|
-
}
|
|
464
|
-
function ee(e, t) {
|
|
465
|
-
const r = /* @__PURE__ */ new Map();
|
|
466
|
-
if (!e.rowKey) return r;
|
|
467
|
-
const n = /* @__PURE__ */ new Set();
|
|
468
|
-
for (const o of t) {
|
|
469
|
-
const a = yr(e, o), s = JSON.stringify(a.rowKey);
|
|
470
|
-
if (n.has(s)) throw new Error(`数据集 ${e.dataset} 的业务主键重复:${String(a.rowKey)}`);
|
|
471
|
-
n.add(s), r.set(o, a);
|
|
472
|
-
}
|
|
473
|
-
return r;
|
|
474
|
-
}
|
|
475
|
-
function br(e, t, r, n, o) {
|
|
476
|
-
if (!e.grandTotal) return;
|
|
477
|
-
const a = typeof e.grandTotal == "object" ? e.grandTotal : void 0, s = te(e)[0], c = a?.fields ?? s?.subtotal ?? [], i = a?.aggregates ?? s?.aggregates ?? [];
|
|
478
|
-
if (c.length === 0 && i.length === 0) {
|
|
479
|
-
n.warnings.push(`列表 ${e.id ?? ""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);
|
|
480
|
-
return;
|
|
481
|
-
}
|
|
482
|
-
const l = W(r, n.measurer, a?.label ?? "合计", Qe(e.columns, t, c, i), a?.style ?? {}, Ze(e.columns, [...c, ...i.map((d) => d.field)]));
|
|
483
|
-
o.placeGridRow(l, "listgt", "grand-total");
|
|
484
|
-
}
|
|
485
|
-
function J(e) {
|
|
486
|
-
if (e?.aborted) {
|
|
487
|
-
const t = new Error("报表排版已取消");
|
|
488
|
-
throw t.name = "AbortError", t;
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
function te(e) {
|
|
492
|
-
const t = e.groups ?? (e.groupBy ? [e.groupBy] : []);
|
|
493
|
-
if (t.length > 16) throw new Error("列表最多支持 16 级分组");
|
|
494
|
-
return t;
|
|
495
|
-
}
|
|
496
|
-
function ye(e) {
|
|
497
|
-
const t = Yt(e), r = t.columns.reduce((o, a) => o + a.widthMm, 0), n = r > t.widthMm ? t.widthMm / r : 1;
|
|
498
|
-
return n === 1 ? t : { ...t, columns: t.columns.map((o) => ({ ...o, widthMm: o.widthMm * n })) };
|
|
499
|
-
}
|
|
500
|
-
function vr(e, t, r) {
|
|
501
|
-
const n = e.detail;
|
|
502
|
-
if (!n) return;
|
|
503
|
-
const o = /* @__PURE__ */ new Set();
|
|
504
|
-
for (const l of t) {
|
|
505
|
-
const d = le(l[n.parentKey]);
|
|
506
|
-
if (o.has(d)) throw new Error("主从明细的主表关联键重复");
|
|
507
|
-
o.add(d);
|
|
508
|
-
}
|
|
509
|
-
const a = r.datasets[n.dataset] ?? [], s = /* @__PURE__ */ new Map(), c = [];
|
|
510
|
-
for (const l of a) {
|
|
511
|
-
const d = l[n.foreignKey];
|
|
512
|
-
if (!et(d) && n.unmatched === "ignore") continue;
|
|
513
|
-
const u = le(d);
|
|
514
|
-
if (!o.has(u)) {
|
|
515
|
-
if (n.unmatched !== "ignore") throw new Error(`明细数据集 ${n.dataset} 存在未关联的业务键`);
|
|
516
|
-
continue;
|
|
517
|
-
}
|
|
518
|
-
const f = s.get(u);
|
|
519
|
-
f ? f.push(l) : s.set(u, [l]), c.push(l);
|
|
520
|
-
}
|
|
521
|
-
const i = ye({ ...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 });
|
|
522
|
-
return { list: i, inter: { ...we(i, r.measurer), rowHeightFloorMm: i.rowHeightMm ?? 0 }, rows: s, sources: ee(i, c) };
|
|
523
|
-
}
|
|
524
|
-
function et(e) {
|
|
525
|
-
return typeof e == "string" && !!e.trim() || typeof e == "number" && Number.isFinite(e);
|
|
526
|
-
}
|
|
527
|
-
function le(e) {
|
|
528
|
-
if (!et(e)) throw new Error("主从关联键必须是非空字符串或有限数字");
|
|
529
|
-
return Xe(e);
|
|
530
|
-
}
|
|
531
|
-
function* Mr(e, t, r, n, o) {
|
|
532
|
-
if (!r) return;
|
|
533
|
-
const a = r.rows.get(le(t[e.detail.parentKey])) ?? [];
|
|
534
|
-
if (!a.length) return;
|
|
535
|
-
const s = { id: `${n.tableId}:detail`, columnKeys: r.list.columns.map((c) => c.field), title: e.detail.label };
|
|
536
|
-
e.detail.label && o.placeGridRow({ ...W(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();
|
|
537
|
-
for (const c of a)
|
|
538
|
-
J(n.signal), o.placeGridRow({ ...V(r.inter, c, n.measurer), table: s }, "listdr", "body", r.sources.get(c)), yield* n.takePages();
|
|
539
|
-
}
|
|
540
|
-
function xr(e, t) {
|
|
541
|
-
if (!e.matrix) return { list: e, rows: t };
|
|
542
|
-
if (e.detail || e.groupBy || e.groups?.length || e.grandTotal) throw new Error("矩阵不能同时配置普通分组、总计或主从明细");
|
|
543
|
-
const r = Jt(t, e.matrix), n = r.columns.map((a, s) => ({ ...a, widthMm: s === 0 ? e.matrix.rowWidthMm ?? 40 : e.matrix.columnWidthMm ?? 28, editable: !1, align: s === 0 ? "center" : "right" })), o = { ...e, columns: n, headerGrid: void 0, rowKey: void 0, revisionField: void 0, sourceTokenField: void 0 };
|
|
544
|
-
return e.layout === "wide" && (o.widthMm = n.reduce((a, s) => a + s.widthMm, 0)), { list: o, rows: r.rows };
|
|
545
|
-
}
|
|
546
|
-
function tt(e) {
|
|
547
|
-
if (e.matrix || e.detail || e.groups?.length || e.groupBy || e.rowVisibleWhen) throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");
|
|
548
|
-
if (e.rowKey && e.rowKey !== e.tree.idField) throw new Error("树形布局的 rowKey 应与 idField 一致");
|
|
549
|
-
if (!e.columns.some((t) => t.field === e.tree.labelField && !t.hidden)) throw new Error("树形布局需要可见的标签列");
|
|
550
|
-
zt(e.tree, e.computed);
|
|
551
|
-
}
|
|
552
|
-
function $r(e, t, r) {
|
|
553
|
-
tt(e);
|
|
554
|
-
const n = _t(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 = ee(o, n.entries.map((i) => i.original)), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new WeakMap();
|
|
555
|
-
for (const i of n.entries)
|
|
556
|
-
s.set(i.row, a.get(i.original)), c.set(i.row, i);
|
|
557
|
-
return { list: o, rows: n.rows, sources: s, treeRows: c, totalRows: n.leaves };
|
|
558
|
-
}
|
|
559
|
-
function Sr(e, t) {
|
|
560
|
-
if (e.cardinality === "record") {
|
|
561
|
-
if (t.length > 1) throw new Error(`单记录区域 ${e.id ?? e.dataset} 仅允许 0 或 1 行数据`);
|
|
562
|
-
if (e.tree || e.matrix || e.detail || e.groups?.length || e.groupBy || e.grandTotal || e.rowVisibleWhen) throw new Error("单记录区域不能配置树、矩阵、主从、分组、总计或行过滤");
|
|
563
|
-
if (!t.length) return { list: { ...e, columns: e.columns.map((r) => ({ ...r, editable: !1 })) }, rows: [{}], sources: /* @__PURE__ */ new Map() };
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
function rt(e, t, r) {
|
|
567
|
-
const n = r.prepared.get(e);
|
|
568
|
-
if (n) return n;
|
|
569
|
-
const o = Sr(e, t);
|
|
570
|
-
if (o)
|
|
571
|
-
return r.prepared.set(e, o), o;
|
|
572
|
-
if (e.tree) {
|
|
573
|
-
const i = $r(e, t, r);
|
|
574
|
-
return r.prepared.set(e, i), i;
|
|
575
|
-
}
|
|
576
|
-
let a = e.computed?.length ? Ve(t, { fields: e.computed, signal: r.signal, formula: r.formula }).rows : t;
|
|
577
|
-
const s = a === t ? void 0 : new Map(a.map((i, l) => [i, t[l]]));
|
|
578
|
-
e.rowVisibleWhen && (a = a.filter((i) => B(i, e.rowVisibleWhen)));
|
|
579
|
-
const c = xr(e, a);
|
|
580
|
-
if (!e.matrix) {
|
|
581
|
-
const i = ee(e, s ? a.map((l) => s.get(l)) : a);
|
|
582
|
-
c.sources = s ? new Map(a.map((l) => [l, i.get(s.get(l))])) : i;
|
|
583
|
-
}
|
|
584
|
-
return r.prepared.set(e, c), c;
|
|
585
|
-
}
|
|
586
|
-
function Tr(e, t, r, n) {
|
|
587
|
-
if (!n.flow) return;
|
|
588
|
-
const { current: o, templatePage: a } = n, s = Math.max(o.marginTopMm, G(a)), c = Math.max(n.startTop ?? e.topMm, s), i = (e.header === !1 ? 0 : t.headerHeightMm) + (r[0] ? V(t, r[0], n.measurer).heightMm : 0);
|
|
589
|
-
c + i <= U(a, o) + 1e-3 || c <= 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, G(a)));
|
|
590
|
-
}
|
|
591
|
-
function* Pr(e, t, r) {
|
|
592
|
-
const n = rt(e, t, r), o = n.rows;
|
|
593
|
-
e = n.list, e.layout === "wide" && (r.current.widthMm = Math.max(r.current.widthMm, e.leftMm + e.widthMm + r.current.marginRightMm));
|
|
594
|
-
const a = n.sources ?? ee(e, o), s = ye(e), c = te(s), i = { ...we(s, r.measurer), rowHeightFloorMm: s.rowHeightMm ?? 0, ...n.treeRows ? { tree: { list: s, rows: n.treeRows } } : {} };
|
|
595
|
-
Tr(s, i, o, r);
|
|
596
|
-
const l = wr(s, i, r), d = vr(s, o, r);
|
|
597
|
-
let u;
|
|
598
|
-
for (const f of Ye(o, c)) {
|
|
599
|
-
if (J(r.signal), f.kind === "row")
|
|
600
|
-
l.placeGridRow(u ?? V(i, f.row, r.measurer), "listr", "body", a.get(f.row)), u = void 0, yield* r.takePages(), yield* Mr(s, f.row, d, r, l);
|
|
601
|
-
else if (f.kind === "groupHeader") {
|
|
602
|
-
const m = W(i, r.measurer, f.label, /* @__PURE__ */ new Map(), f.group.headerStyle ?? {}, s.columns.length);
|
|
603
|
-
u ??= V(i, f.firstRow, r.measurer);
|
|
604
|
-
const p = c.slice(f.depth + 1).reduce((g, w) => g + W(i, r.measurer, (w.headerTemplate ?? "{value}").replace(/\{value\}/g, ge(f.firstRow[w.field])), /* @__PURE__ */ new Map(), w.headerStyle ?? {}, s.columns.length).heightMm, 0);
|
|
605
|
-
f.group.keepWithNext !== !1 && l.keepTogether(m.heightMm + p + u.heightMm), l.placeGridRow(m, "listg", "group-header"), f.group.repeatHeader && l.setGroupHeader(f.depth, m);
|
|
606
|
-
} else if (f.kind === "subtotal") {
|
|
607
|
-
const m = f.group.subtotal ?? [], p = f.group.aggregates ?? [], g = W(i, r.measurer, f.label, Qe(s.columns, f.rows, m, p), f.group.subtotalStyle ?? {}, Ze(s.columns, [...m, ...p.map((w) => w.field)]));
|
|
608
|
-
l.placeGridRow(g, "listst", "subtotal");
|
|
609
|
-
} else l.setGroupHeader(f.depth);
|
|
610
|
-
yield* r.takePages();
|
|
611
|
-
}
|
|
612
|
-
br(s, n.totalRows ?? o, i, r, l), r.finished?.(l.bottom()), yield* r.takePages();
|
|
613
|
-
}
|
|
614
|
-
function re(e) {
|
|
615
|
-
return e.kind !== "list" && (e.pageAnchor !== void 0 || e.kind === "text" && typeof e.text == "string" && (e.text.includes("{page}") || e.text.includes("{totalPages}")));
|
|
616
|
-
}
|
|
617
|
-
function ne(e, t) {
|
|
618
|
-
return {
|
|
619
|
-
...e,
|
|
620
|
-
...e.text === void 0 ? {} : { text: t(e.text) },
|
|
621
|
-
...e.lines ? { lines: e.lines.map(t) } : {},
|
|
622
|
-
...e.richParagraphs ? { richParagraphs: e.richParagraphs.map((r) => ({ ...r, segments: r.segments.map((n) => ({ ...n, ...n.text === void 0 ? {} : { text: t(n.text) } })) })) } : {},
|
|
623
|
-
...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) => ne(o, t)) } : {} } : null)) } } : {}
|
|
624
|
-
};
|
|
625
|
-
}
|
|
626
|
-
function Ir(e) {
|
|
627
|
-
let t = !1;
|
|
628
|
-
for (const r of e.pages) for (const n of r.components) re(n) && ne(n, (o) => (o.includes("{totalPages}") && (t = !0), o));
|
|
629
|
-
return t;
|
|
630
|
-
}
|
|
631
|
-
function Rr(e, t, r, n, o, a) {
|
|
632
|
-
const s = {
|
|
633
|
-
pageWidthMm: t.widthMm,
|
|
634
|
-
pageHeightMm: t.heightMm,
|
|
635
|
-
...e.layout === void 0 ? {} : { layout: e.layout },
|
|
636
|
-
marginTopMm: t.marginTopMm,
|
|
637
|
-
marginBottomMm: t.marginBottomMm,
|
|
638
|
-
marginLeftMm: t.marginLeftMm,
|
|
639
|
-
marginRightMm: t.marginRightMm,
|
|
640
|
-
components: t.components,
|
|
641
|
-
...e.meta ? { meta: e.meta } : {}
|
|
642
|
-
}, c = (i) => {
|
|
643
|
-
const l = i.replace(/\{page\}/g, String(n));
|
|
644
|
-
return a === void 0 ? l : l.replace(/\{totalPages\}/g, String(a));
|
|
645
|
-
};
|
|
646
|
-
for (const i of r) s.components.push(ne(i, c));
|
|
647
|
-
if (e.layout === "wide") {
|
|
648
|
-
const i = s.components.reduce((l, d) => Math.max(l, d.topMm + d.heightMm), 0);
|
|
649
|
-
s.marginBottomMm = o ? e.marginBottomMm ?? 0 : 0, s.pageHeightMm = Math.max(1, i + s.marginBottomMm);
|
|
650
|
-
}
|
|
651
|
-
return s;
|
|
652
|
-
}
|
|
653
|
-
function be(e) {
|
|
654
|
-
return e.cells.reduce((t, r) => t + r.reduce((n, o) => n + (o ? 1 + (o.children?.reduce((a, s) => a + nt(s), 0) ?? 0) : 0), 0), 0);
|
|
655
|
-
}
|
|
656
|
-
function nt(e) {
|
|
657
|
-
return e.grid ? be(e.grid) : 0;
|
|
658
|
-
}
|
|
659
|
-
function ve(e) {
|
|
660
|
-
for (const t of ["maxPages", "maxCells", "knownTotalPages"]) if (e[t] !== void 0 && (!Number.isSafeInteger(e[t]) || e[t] < 1)) throw new RangeError(`${t} 应为正安全整数`);
|
|
661
|
-
}
|
|
662
|
-
function kr(e, t) {
|
|
663
|
-
const r = rt(e, t.datasets[e.dataset] ?? [], t), n = ye(r.list), o = { ...we(n, t.measurer), rowHeightFloorMm: n.rowHeightMm ?? 0 };
|
|
664
|
-
return (n.header === !1 ? 0 : o.headerHeightMm) + r.rows.reduce((a, s) => a + V(o, s, t.measurer).heightMm, 0);
|
|
665
|
-
}
|
|
666
|
-
function* Er(e) {
|
|
667
|
-
const { templatePage: t, current: r } = e, n = new Map(t.components.map((a, s) => [a, s])), o = (a, s, c) => {
|
|
668
|
-
const i = e.datasets[a.dataset];
|
|
669
|
-
return Array.isArray(i) || e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id ?? ""} 输出为空`), Pr(a, Array.isArray(i) ? i : [], { ...e, tableId: `${e.tableId}:${n.get(a)}`, startTop: s, finished: c, flow: !!t.flow });
|
|
670
|
-
};
|
|
671
|
-
if (t.flow) {
|
|
672
|
-
yield* Qt({
|
|
673
|
-
page: t,
|
|
674
|
-
active: () => J(e.signal),
|
|
675
|
-
top: () => Math.max(r.marginTopMm, G(t)),
|
|
676
|
-
bottom: () => U(t, r),
|
|
677
|
-
append: (a) => {
|
|
678
|
-
r.components.push(a);
|
|
679
|
-
},
|
|
680
|
-
nextPage: () => {
|
|
681
|
-
e.pushCurrent(), r.components = [], r.heightMm = t.heightMm, t.layout === "wide" && (r.marginTopMm = 0, r.marginBottomMm = 0);
|
|
682
|
-
},
|
|
683
|
-
takePages: e.takePages,
|
|
684
|
-
height: (a) => kr(a, e),
|
|
685
|
-
list: o
|
|
686
|
-
});
|
|
687
|
-
return;
|
|
688
|
-
}
|
|
689
|
-
for (const a of t.components)
|
|
690
|
-
re(a) || (a.kind === "list" ? yield* o(a) : r.components.push(a));
|
|
691
|
-
}
|
|
692
|
-
function* X(e, t, r, n, o, a = /* @__PURE__ */ new WeakMap()) {
|
|
693
|
-
let s = 0, c = 0, i = 0;
|
|
694
|
-
const l = (d) => `${d}_${(++s).toString(36)}`;
|
|
695
|
-
for (const { pageIndex: d, page: u } of cr(e, t, r)) {
|
|
696
|
-
J(r.signal);
|
|
697
|
-
const f = lr(u), m = u.components.filter(re);
|
|
698
|
-
let p = [];
|
|
699
|
-
const g = (v = !1) => {
|
|
700
|
-
if (J(r.signal), r.maxPages !== void 0 && c >= r.maxPages) throw new K(r.maxPages, c + 1);
|
|
701
|
-
if (r.maxCells !== void 0 && (i += [...f.components, ...m].reduce((M, y) => M + nt(y), 0), i > r.maxCells))
|
|
702
|
-
throw new D(r.maxCells, i);
|
|
703
|
-
p.push(Rr(u, f, m, ++c, v, o));
|
|
704
|
-
}, w = () => {
|
|
705
|
-
const v = p;
|
|
706
|
-
return p = [], v;
|
|
707
|
-
};
|
|
708
|
-
yield* Er({
|
|
709
|
-
templatePage: u,
|
|
710
|
-
current: f,
|
|
711
|
-
warnings: n,
|
|
712
|
-
nextId: l,
|
|
713
|
-
pushCurrent: g,
|
|
714
|
-
takePages: w,
|
|
715
|
-
datasets: t,
|
|
716
|
-
signal: r.signal,
|
|
717
|
-
formula: r.formula,
|
|
718
|
-
prepared: a,
|
|
719
|
-
measurer: r.measurer ?? Le,
|
|
720
|
-
mmPerRow: r.mmPerRow ?? 0,
|
|
721
|
-
tableId: `table:${d}`
|
|
722
|
-
}), g(!0), yield* w();
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
function Bn(e, t, r = {}) {
|
|
726
|
-
ve(r);
|
|
727
|
-
let n = 0;
|
|
728
|
-
for (const o of X(e, t, { ...r, onWarning: void 0 }, [])) n++;
|
|
729
|
-
return n;
|
|
730
|
-
}
|
|
731
|
-
function* Cr(e, t, r = {}) {
|
|
732
|
-
ve(r);
|
|
733
|
-
const n = Ir(e), o = /* @__PURE__ */ new WeakMap();
|
|
734
|
-
let a = r.knownTotalPages;
|
|
735
|
-
if (n && a === void 0) {
|
|
736
|
-
a = 0;
|
|
737
|
-
for (const i of X(e, t, r, [], void 0, o)) a++;
|
|
738
|
-
}
|
|
739
|
-
const s = [];
|
|
740
|
-
let c = 0;
|
|
741
|
-
for (const i of X(e, t, r, s, a, o)) {
|
|
742
|
-
for (; c < s.length; c++) r.onWarning?.(s[c]);
|
|
743
|
-
yield i;
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
function Me(e, t, r = {}) {
|
|
747
|
-
const n = typeof r == "number" ? { mmPerRow: r } : r;
|
|
748
|
-
ve(n);
|
|
749
|
-
const o = [], a = [...X(e, t, n, o, n.knownTotalPages)];
|
|
750
|
-
for (const s of a) s.components = s.components.map((c) => re(c) ? ne(c, (i) => i.replace(/\{totalPages\}/g, String(a.length))) : c);
|
|
751
|
-
return o.forEach((s) => n.onWarning?.(s)), { plan: { schemaVersion: Y, ...Z(e) ? { requiresRecalculation: !0 } : {}, pages: a }, warnings: o };
|
|
752
|
-
}
|
|
753
|
-
function Or(e) {
|
|
754
|
-
const t = e.columns.find((a) => !a.hidden)?.field;
|
|
755
|
-
if (!t) return { groups: 0, total: 0 };
|
|
756
|
-
const r = te(e), n = (a = [], s = []) => a.includes(t) || s.some((c) => c.field === t), o = typeof e.grandTotal == "object" ? e.grandTotal : void 0;
|
|
757
|
-
return { groups: r.filter((a) => n(a.subtotal, a.aggregates)).length, total: Number(n(o?.fields ?? r[0]?.subtotal, o?.aggregates ?? r[0]?.aggregates)) };
|
|
758
|
-
}
|
|
759
|
-
function Fr(e, t, r) {
|
|
760
|
-
tt(e);
|
|
761
|
-
const n = Je(t[e.dataset] ?? [], e.tree, r), o = e.columns.filter((s) => !s.hidden).length, a = e.header === !1 ? 0 : e.headerGrid ? be(e.headerGrid) : o;
|
|
762
|
-
return n.length * o + a + +!!e.grandTotal * 2 * o;
|
|
763
|
-
}
|
|
764
|
-
function Dn(e, t, r = {}) {
|
|
765
|
-
if (e.tree) return Fr(e, t, r.signal);
|
|
766
|
-
if (e.matrix) {
|
|
767
|
-
let i = t[e.dataset] ?? [];
|
|
768
|
-
e.computed?.length && (i = Ve(i, { fields: e.computed, ...r }).rows), e.rowVisibleWhen && (i = i.filter((d) => B(d, e.rowVisibleWhen)));
|
|
769
|
-
const l = Vt(i, e.matrix);
|
|
770
|
-
return l.cells + l.columnCount;
|
|
771
|
-
}
|
|
772
|
-
const n = t[e.dataset]?.length ?? 0, o = e.columns.filter((i) => !i.hidden).length, a = te(e).length, s = Or(e);
|
|
773
|
-
let c = (n * (1 + 2 * a + s.groups) + +!!e.grandTotal * (1 + s.total)) * o;
|
|
774
|
-
if (c += e.header === !1 ? 0 : e.headerGrid ? be(e.headerGrid) : o, e.cardinality === "record" && n === 0 && (c += o), e.detail) {
|
|
775
|
-
const i = t[e.detail.dataset]?.length ?? 0, l = e.detail.columns.filter((d) => !d.hidden).length;
|
|
776
|
-
c += (i + n * (+(e.detail.header !== !1) + +!!e.detail.label)) * l;
|
|
777
|
-
}
|
|
778
|
-
if (!Number.isSafeInteger(c)) throw new RangeError("报表单元格估算超出安全整数预算");
|
|
779
|
-
return c;
|
|
780
|
-
}
|
|
781
|
-
function ot(e) {
|
|
782
|
-
return !e || typeof e != "object" ? !1 : [e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex].every((t) => Number.isInteger(t) && t >= 0);
|
|
783
|
-
}
|
|
784
|
-
function at(e, t, r) {
|
|
785
|
-
const n = e.grid;
|
|
786
|
-
if (!n) return null;
|
|
787
|
-
const o = n.cells[t];
|
|
788
|
-
if (!o) return null;
|
|
789
|
-
const s = me(n, e.widthMm, e.heightMm).cells.filter((i) => i.ri === t).findIndex((i) => i.ci === r), c = o[s];
|
|
790
|
-
return c ? { cell: c, sourceColumnIndex: s } : null;
|
|
791
|
-
}
|
|
792
|
-
function Ar(e) {
|
|
793
|
-
return e.value !== void 0 ? e.value : e.rawText ?? e.text ?? null;
|
|
794
|
-
}
|
|
795
|
-
function jr(e, t) {
|
|
796
|
-
return e.valueType ? e.valueType : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t === null && e.numberFormat && /[0#?]/.test(e.numberFormat) ? "number" : "text";
|
|
797
|
-
}
|
|
798
|
-
function Nr(e, t) {
|
|
799
|
-
if (e.derived) return "derived";
|
|
800
|
-
if (e.editable === !1) return "cell";
|
|
801
|
-
if (e.formula !== void 0) return "formula";
|
|
802
|
-
if (e.children?.length) return "complex";
|
|
803
|
-
if (t.table && t.table.role !== "body" && e.editable !== !0) return "structure";
|
|
804
|
-
}
|
|
805
|
-
function Kr(e, t) {
|
|
806
|
-
const r = e.table;
|
|
807
|
-
if (r)
|
|
808
|
-
return {
|
|
809
|
-
id: r.id,
|
|
810
|
-
rowIndex: r.rowIndex + t.rowIndex,
|
|
811
|
-
role: r.role,
|
|
812
|
-
columnKey: r.columnKeys[t.columnIndex]
|
|
813
|
-
};
|
|
814
|
-
}
|
|
815
|
-
function Lr(e, t, r) {
|
|
816
|
-
if (e.derived) return;
|
|
817
|
-
if (e.source) return { ...e.source };
|
|
818
|
-
const n = t.table?.source, o = t.table?.columnKeys[r.columnIndex];
|
|
819
|
-
if (!(!n || n.rowKey === void 0 || o === void 0))
|
|
820
|
-
return { ...n, rowKey: n.rowKey, field: o };
|
|
821
|
-
}
|
|
822
|
-
function st(e, t, r) {
|
|
823
|
-
const n = Ar(r), o = Nr(r, e);
|
|
824
|
-
return {
|
|
825
|
-
address: { ...t },
|
|
826
|
-
cell: r,
|
|
827
|
-
component: e,
|
|
828
|
-
value: n,
|
|
829
|
-
valueType: jr(r, n),
|
|
830
|
-
table: Kr(e, t),
|
|
831
|
-
source: Lr(r, e, t),
|
|
832
|
-
editable: o === void 0,
|
|
833
|
-
readOnlyReason: o
|
|
834
|
-
};
|
|
835
|
-
}
|
|
836
|
-
function xe(e, t) {
|
|
837
|
-
if (!ot(t)) return null;
|
|
838
|
-
const r = e.pages[t.pageIndex]?.components[t.componentIndex];
|
|
839
|
-
if (!r) return null;
|
|
840
|
-
const n = at(r, t.rowIndex, t.columnIndex);
|
|
841
|
-
return n ? st(r, t, n.cell) : null;
|
|
842
|
-
}
|
|
843
|
-
function H(e) {
|
|
844
|
-
const t = /* @__PURE__ */ new Map();
|
|
845
|
-
return (r) => {
|
|
846
|
-
if (!ot(r)) return null;
|
|
847
|
-
const n = e.pages[r.pageIndex]?.components[r.componentIndex];
|
|
848
|
-
if (!n?.grid) return null;
|
|
849
|
-
let o = t.get(n);
|
|
850
|
-
if (!o) {
|
|
851
|
-
const s = /* @__PURE__ */ new Map();
|
|
852
|
-
o = /* @__PURE__ */ new Map();
|
|
853
|
-
for (const c of me(n.grid, n.widthMm, n.heightMm).cells) {
|
|
854
|
-
const i = s.get(c.ri) ?? 0;
|
|
855
|
-
s.set(c.ri, i + 1);
|
|
856
|
-
const l = n.grid.cells[c.ri]?.[i];
|
|
857
|
-
l && o.set(`${c.ri}:${c.ci}`, l);
|
|
858
|
-
}
|
|
859
|
-
t.set(n, o);
|
|
860
|
-
}
|
|
861
|
-
const a = o.get(`${r.rowIndex}:${r.columnIndex}`);
|
|
862
|
-
return a ? st(n, r, a) : null;
|
|
863
|
-
};
|
|
864
|
-
}
|
|
865
|
-
class b extends Error {
|
|
866
|
-
constructor(t) {
|
|
867
|
-
super(`Invalid report cell edit: ${t}`), this.code = t, this.name = "ReportCellEditError";
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
function Hr(e, t) {
|
|
871
|
-
let r = e.trim();
|
|
872
|
-
const n = t && r.endsWith("%");
|
|
873
|
-
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 b("number");
|
|
874
|
-
return Number(r) / (n ? 100 : 1);
|
|
875
|
-
}
|
|
876
|
-
function Br(e, t) {
|
|
877
|
-
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
878
|
-
if (typeof e != "string" && typeof e != "number") throw new b("number");
|
|
879
|
-
const r = typeof e == "number" ? e : Hr(e, Ft(t.cell.numberFormat));
|
|
880
|
-
if (!Number.isFinite(r) || Number.isInteger(r) && !Number.isSafeInteger(r)) throw new b("number");
|
|
881
|
-
return r;
|
|
882
|
-
}
|
|
883
|
-
function Dr(e) {
|
|
884
|
-
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
885
|
-
if (typeof e == "boolean") return e;
|
|
886
|
-
const t = String(e).trim().toLowerCase();
|
|
887
|
-
if (["true", "yes", "是", "1"].includes(t)) return !0;
|
|
888
|
-
if (["false", "no", "否", "0"].includes(t)) return !1;
|
|
889
|
-
throw new b("boolean");
|
|
890
|
-
}
|
|
891
|
-
function it(e, t) {
|
|
892
|
-
return e.valueType === "number" ? Br(t, e) : e.valueType === "boolean" ? Dr(t) : t === null ? null : String(t);
|
|
893
|
-
}
|
|
894
|
-
function Wr(e, t) {
|
|
895
|
-
const r = t.cell.text, o = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((a) => a.includes(r ?? ""));
|
|
896
|
-
return o ? o[e ? 0 : 1] : String(e);
|
|
897
|
-
}
|
|
898
|
-
function z(e, t) {
|
|
899
|
-
return t === null ? "" : typeof t == "boolean" ? Wr(t, e) : typeof t == "number" ? Ot(t, e.cell.numberFormat) : String(t);
|
|
900
|
-
}
|
|
901
|
-
function Wn(e, t, r) {
|
|
902
|
-
const n = xe(e, t);
|
|
903
|
-
if (!n) throw new b("missing");
|
|
904
|
-
return _(n, r);
|
|
905
|
-
}
|
|
906
|
-
function _(e, t) {
|
|
907
|
-
if (!e.editable) throw new b("readonly");
|
|
908
|
-
const r = it(e, t);
|
|
909
|
-
return {
|
|
910
|
-
address: { ...e.address },
|
|
911
|
-
table: e.table,
|
|
912
|
-
source: e.source,
|
|
913
|
-
previousValue: e.value,
|
|
914
|
-
previousText: e.cell.text ?? "",
|
|
915
|
-
value: r,
|
|
916
|
-
text: z(e, r)
|
|
917
|
-
};
|
|
918
|
-
}
|
|
919
|
-
function Gr(e, t) {
|
|
920
|
-
const r = e.table, n = t.table;
|
|
921
|
-
return !r || !n || r.columnKey === void 0 ? !1 : r.id === n.id && r.rowIndex === n.rowIndex && r.role === n.role && r.columnKey === n.columnKey;
|
|
922
|
-
}
|
|
923
|
-
function ct(e, t, r) {
|
|
924
|
-
const n = e.grid, { rowIndex: o, columnIndex: a } = t.address, s = at(e, o, a), c = [...n.cells], i = [...c[o]], l = z(t, r.value), d = { ...s.cell, value: r.value, text: l, rawText: l };
|
|
925
|
-
return i[s.sourceColumnIndex] = d, c[o] = i, { ...e, grid: { ...n, cells: c } };
|
|
926
|
-
}
|
|
927
|
-
function Vr(e, t) {
|
|
928
|
-
const r = e.table?.columnKeys, n = t.table?.columnKey;
|
|
929
|
-
return r && n !== void 0 ? r.flatMap((o, a) => o === n ? [a] : []) : [];
|
|
930
|
-
}
|
|
931
|
-
function Jr(e, t, r, n, o, a) {
|
|
932
|
-
const s = t.table, c = o.table;
|
|
933
|
-
if (!s || !c || s.id !== c.id || s.role !== c.role || !t.grid) return t;
|
|
934
|
-
const i = c.rowIndex - s.rowIndex;
|
|
935
|
-
if (i < 0 || i >= t.grid.cells.length) return t;
|
|
936
|
-
let l = t;
|
|
937
|
-
for (const d of Vr(t, o)) {
|
|
938
|
-
const u = xe(e, { pageIndex: r, componentIndex: n, rowIndex: i, columnIndex: d });
|
|
939
|
-
u?.editable && Gr(o, u) && (l = ct(l, u, a));
|
|
940
|
-
}
|
|
941
|
-
return l;
|
|
942
|
-
}
|
|
943
|
-
function zr(e, t, r, n, o, a) {
|
|
944
|
-
const s = o.address;
|
|
945
|
-
return o.table?.columnKey !== void 0 ? Jr(e, t, r, n, o, a) : s.pageIndex === r && s.componentIndex === n ? ct(t, o, a) : t;
|
|
946
|
-
}
|
|
947
|
-
function $e(e, t) {
|
|
948
|
-
const r = t.source;
|
|
949
|
-
if (!r) return !1;
|
|
950
|
-
const n = e.source;
|
|
951
|
-
return !n || ["datasetId", "rowKey", "field", "revision", "sourceToken"].some((o) => !Object.is(n[o], r[o]));
|
|
952
|
-
}
|
|
953
|
-
function Gn(e, t) {
|
|
954
|
-
const r = xe(e, t.address);
|
|
955
|
-
if (!r) throw new b("missing");
|
|
956
|
-
if (!r.editable) throw new b("readonly");
|
|
957
|
-
if ($e(r, t)) throw new b("conflict");
|
|
958
|
-
if (!Object.is(r.value, t.previousValue) || (r.cell.text ?? "") !== t.previousText) throw new b("conflict");
|
|
959
|
-
const n = it(r, t.value), o = { ...t, value: n, text: z(r, n) };
|
|
960
|
-
if (Object.is(n, r.value) && o.text === r.cell.text) return e;
|
|
961
|
-
const a = e.pages.map((s, c) => {
|
|
962
|
-
const i = s.components.map((l, d) => zr(e, l, c, d, r, o));
|
|
963
|
-
return i.every((l, d) => l === s.components[d]) ? s : { ...s, components: i };
|
|
964
|
-
});
|
|
965
|
-
return { ...e, pages: a };
|
|
966
|
-
}
|
|
967
|
-
function _r(e, t, r) {
|
|
968
|
-
if (!r || r.revision === void 0 && r.sourceToken === void 0) return e;
|
|
969
|
-
const n = new Set(t.edits.flatMap((s) => s.source ? [s.source.datasetId] : []));
|
|
970
|
-
if (!n.size) return e;
|
|
971
|
-
function o(s) {
|
|
972
|
-
return !s.datasetId || !n.has(s.datasetId) || (r.revision === void 0 || Object.is(r.revision, s.revision)) && (r.sourceToken === void 0 || r.sourceToken === s.sourceToken) ? s : { ...s, ...r.revision !== void 0 ? { revision: r.revision } : {}, ...r.sourceToken !== void 0 ? { sourceToken: r.sourceToken } : {} };
|
|
973
|
-
}
|
|
974
|
-
const a = e.pages.map((s) => {
|
|
975
|
-
const c = s.components.map((i) => {
|
|
976
|
-
const l = i.table?.source ? o(i.table.source) : void 0, d = i.table && l !== i.table.source ? { ...i.table, source: l } : i.table, u = i.grid?.cells.map((m) => {
|
|
977
|
-
const p = m.map((g) => {
|
|
978
|
-
if (!g?.source) return g;
|
|
979
|
-
const w = o(g.source);
|
|
980
|
-
return w === g.source ? g : { ...g, source: w };
|
|
981
|
-
});
|
|
982
|
-
return p.some((g, w) => g !== m[w]) ? p : m;
|
|
983
|
-
}), f = i.grid && u?.some((m, p) => m !== i.grid.cells[p]) ? { ...i.grid, cells: u } : i.grid;
|
|
984
|
-
return d !== i.table || f !== i.grid ? { ...i, table: d, grid: f } : i;
|
|
985
|
-
});
|
|
986
|
-
return c.some((i, l) => i !== s.components[l]) ? { ...s, components: c } : s;
|
|
987
|
-
});
|
|
988
|
-
return a.some((s, c) => s !== e.pages[c]) ? { ...e, pages: a } : e;
|
|
989
|
-
}
|
|
990
|
-
function qr(e) {
|
|
991
|
-
return JSON.stringify([e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex]);
|
|
992
|
-
}
|
|
993
|
-
function Re(e) {
|
|
994
|
-
const t = e.table;
|
|
995
|
-
return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) : qr(e.address);
|
|
996
|
-
}
|
|
997
|
-
function Ur(e, t) {
|
|
998
|
-
if (!t.length) return e;
|
|
999
|
-
const r = new Map(t.map((i) => [Re(i), i])), n = new Set(t.flatMap((i) => i.table ? [i.table.id] : [])), o = new Set(t.map((i) => `${i.address.pageIndex}:${i.address.componentIndex}`)), a = H(e);
|
|
1000
|
-
function s(i, l, d) {
|
|
1001
|
-
const u = i.grid;
|
|
1002
|
-
if (!u || !o.has(`${l}:${d}`) && !n.has(i.table?.id ?? "")) return i;
|
|
1003
|
-
const f = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
|
|
1004
|
-
for (const p of me(u, i.widthMm, i.heightMm).cells) {
|
|
1005
|
-
const g = m.get(p.ri) ?? 0;
|
|
1006
|
-
m.set(p.ri, g + 1);
|
|
1007
|
-
const w = a({ pageIndex: l, componentIndex: d, rowIndex: p.ri, columnIndex: p.ci }), v = w && r.get(Re(w));
|
|
1008
|
-
if (!v || !w.editable) continue;
|
|
1009
|
-
const M = f.get(p.ri) ?? [...u.cells[p.ri]], y = z(w, v.value);
|
|
1010
|
-
Object.is(w.value, v.value) && y === w.cell.text || (M[g] = { ...p.cell, value: v.value, text: y, rawText: y }, f.set(p.ri, M));
|
|
1011
|
-
}
|
|
1012
|
-
return f.size ? { ...i, grid: { ...u, cells: u.cells.map((p, g) => f.get(g) ?? p) } } : i;
|
|
1013
|
-
}
|
|
1014
|
-
const c = e.pages.map((i, l) => {
|
|
1015
|
-
const d = i.components.map((u, f) => s(u, l, f));
|
|
1016
|
-
return d.every((u, f) => u === i.components[f]) ? i : { ...i, components: d };
|
|
1017
|
-
});
|
|
1018
|
-
return c.every((i, l) => i === e.pages[l]) ? e : { ...e, pages: c };
|
|
1019
|
-
}
|
|
1020
|
-
function C(e) {
|
|
1021
|
-
const t = e.source;
|
|
1022
|
-
if (t) return JSON.stringify([t.datasetId, t.rowKey, t.field]);
|
|
1023
|
-
const r = e.table;
|
|
1024
|
-
if (r?.columnKey !== void 0) return JSON.stringify([r.id, r.role, r.rowIndex, r.columnKey]);
|
|
1025
|
-
const n = e.address;
|
|
1026
|
-
return JSON.stringify([n.pageIndex, n.componentIndex, n.rowIndex, n.columnIndex]);
|
|
1027
|
-
}
|
|
1028
|
-
function Vn(e, t, r) {
|
|
1029
|
-
if (typeof r != "string" || !r.trim() || !Array.isArray(t)) throw new b("missing");
|
|
1030
|
-
if (t.length > 1e4) throw new b("limit");
|
|
1031
|
-
const n = /* @__PURE__ */ new Set(), o = H(e), a = t.map(({ address: s, value: c }) => {
|
|
1032
|
-
const i = o(s);
|
|
1033
|
-
if (!i) throw new b("missing");
|
|
1034
|
-
const l = _(i, c), d = C(l);
|
|
1035
|
-
if (n.has(d)) throw new b("duplicate");
|
|
1036
|
-
return n.add(d), l;
|
|
1037
|
-
});
|
|
1038
|
-
return { requestId: r, edits: a };
|
|
1039
|
-
}
|
|
1040
|
-
function Jn(e, t) {
|
|
1041
|
-
if (t.edits.length > 1e4) throw new b("limit");
|
|
1042
|
-
const r = H(e), n = /* @__PURE__ */ new Set(), o = t.edits.map((a) => {
|
|
1043
|
-
const s = r(a.address);
|
|
1044
|
-
if (!s) throw new b("missing");
|
|
1045
|
-
const c = C(a);
|
|
1046
|
-
if (n.has(c)) throw new b("duplicate");
|
|
1047
|
-
if (n.add(c), $e(s, a) || !Object.is(s.value, a.previousValue) || (s.cell.text ?? "") !== a.previousText) throw new b("conflict");
|
|
1048
|
-
return _(s, a.value);
|
|
1049
|
-
});
|
|
1050
|
-
return Ur(e, o);
|
|
1051
|
-
}
|
|
1052
|
-
function zn(e) {
|
|
1053
|
-
const t = /* @__PURE__ */ new Map();
|
|
1054
|
-
for (const r of e) {
|
|
1055
|
-
const n = C(r), o = t.get(n), a = o ? { ...r, previousValue: o.previousValue, previousText: o.previousText } : { ...r };
|
|
1056
|
-
Object.is(a.previousValue, a.value) ? t.delete(n) : t.set(n, a);
|
|
1057
|
-
}
|
|
1058
|
-
return [...t.values()];
|
|
1059
|
-
}
|
|
1060
|
-
function L(e, t) {
|
|
1061
|
-
for (let r = 0; r < t.length; r++) {
|
|
1062
|
-
const n = t.charCodeAt(r);
|
|
1063
|
-
e.first = Math.imul(e.first ^ n, 16777619), e.second = Math.imul(e.second, 33) ^ n, e.count++;
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
function Xr(e, t, r) {
|
|
1067
|
-
const n = Object.getOwnPropertyDescriptor(e, t);
|
|
1068
|
-
if (!n || n.get || n.set) throw new b("conflict");
|
|
1069
|
-
L(r, `${t.length}:${t}`), lt(n.value, r);
|
|
1070
|
-
}
|
|
1071
|
-
function Yr(e, t) {
|
|
1072
|
-
if (Object.getOwnPropertyDescriptor(e, "toJSON")) throw new b("conflict");
|
|
1073
|
-
if (t.active.has(e)) throw new b("conflict");
|
|
1074
|
-
if (t.active.add(e), e instanceof Date) L(t, `date:${Date.prototype.getTime.call(e)};`);
|
|
1075
|
-
else {
|
|
1076
|
-
const r = Object.getPrototypeOf(e);
|
|
1077
|
-
if (!Array.isArray(e) && r !== Object.prototype && r !== null) throw new b("conflict");
|
|
1078
|
-
const n = Object.keys(e);
|
|
1079
|
-
L(t, `${Array.isArray(e) ? "array" : "object"}:${Array.isArray(e) ? e.length : n.length}:{`), n.forEach((o) => Xr(e, o, t)), L(t, "}");
|
|
1080
|
-
}
|
|
1081
|
-
t.active.delete(e);
|
|
1082
|
-
}
|
|
1083
|
-
function lt(e, t) {
|
|
1084
|
-
if (++t.nodes > 1e6) throw new b("limit");
|
|
1085
|
-
if (e === null) {
|
|
1086
|
-
L(t, "null;");
|
|
1087
|
-
return;
|
|
1088
|
-
}
|
|
1089
|
-
if (typeof e == "object") {
|
|
1090
|
-
Yr(e, t);
|
|
1091
|
-
return;
|
|
1092
|
-
}
|
|
1093
|
-
if (typeof e == "function" || typeof e == "symbol") throw new b("conflict");
|
|
1094
|
-
const r = String(e);
|
|
1095
|
-
L(t, `${typeof e}:${r.length}:${r};`);
|
|
1096
|
-
}
|
|
1097
|
-
function ke(e) {
|
|
1098
|
-
const t = { first: 2166136261, second: 5381, count: 0, nodes: 0, active: /* @__PURE__ */ new Set() };
|
|
1099
|
-
return lt(e, t), `${t.count}:${t.first >>> 0}:${t.second >>> 0}`;
|
|
1100
|
-
}
|
|
1101
|
-
function de(e, t, r) {
|
|
1102
|
-
if (++r.nodes > 1e6) throw new b("limit");
|
|
1103
|
-
if (typeof e == "string" && (r.text += e.length, r.text > 32 * 1024 * 1024))
|
|
1104
|
-
throw new b("limit");
|
|
1105
|
-
if (e === null || typeof e != "object") return e;
|
|
1106
|
-
if (t.has(e)) throw new b("conflict");
|
|
1107
|
-
if (e instanceof Date) return new Date(Date.prototype.getTime.call(e));
|
|
1108
|
-
t.add(e);
|
|
1109
|
-
const n = Array.isArray(e) ? e.map((o) => de(o, t, r)) : Object.fromEntries(Object.entries(e).map(([o, a]) => [o, de(a, t, r)]));
|
|
1110
|
-
return t.delete(e), n;
|
|
1111
|
-
}
|
|
1112
|
-
function Qr(e) {
|
|
1113
|
-
return de(e, /* @__PURE__ */ new Set(), { nodes: 0, text: 0 });
|
|
1114
|
-
}
|
|
1115
|
-
function dt(e) {
|
|
1116
|
-
const t = [];
|
|
1117
|
-
for (const r of e.template.pages) for (const n of r.components)
|
|
1118
|
-
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] ?? [] } }));
|
|
1119
|
-
return t;
|
|
1120
|
-
}
|
|
1121
|
-
function Ee(e) {
|
|
1122
|
-
return JSON.stringify([e.datasetId, e.rowKey]);
|
|
1123
|
-
}
|
|
1124
|
-
function ut(e) {
|
|
1125
|
-
const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
|
|
1126
|
-
return e.forEach((n, o) => {
|
|
1127
|
-
for (const a of dt(n)) {
|
|
1128
|
-
if (!a.rowKey) continue;
|
|
1129
|
-
const s = a.relation, c = s ? new Set(s.parentRows.map((i) => JSON.stringify(i[s.detail.parentKey]))) : void 0;
|
|
1130
|
-
(n.datasets[a.dataset] ?? []).forEach((i, l) => {
|
|
1131
|
-
if (s && !c.has(JSON.stringify(i[s.detail.foreignKey]))) return;
|
|
1132
|
-
const d = i[a.rowKey];
|
|
1133
|
-
if (typeof d != "string" && typeof d != "number") return;
|
|
1134
|
-
const u = `${o}:${a.dataset}:${l}:${a.rowKey}`;
|
|
1135
|
-
if (r.has(u)) return;
|
|
1136
|
-
r.add(u);
|
|
1137
|
-
const f = Ee({ datasetId: a.dataset, rowKey: d }), m = t.get(f) ?? [];
|
|
1138
|
-
m.push({ partIndex: o, dataset: a.dataset, rowIndex: l, row: i, binding: a }), t.set(f, m);
|
|
1139
|
-
});
|
|
1140
|
-
}
|
|
1141
|
-
}), (n) => {
|
|
1142
|
-
const o = t.get(Ee(n));
|
|
1143
|
-
if (!o?.length) throw new b("missing");
|
|
1144
|
-
if (new Set(o.map((a) => `${a.partIndex}:${a.dataset}`)).size !== o.length) throw new b("conflict");
|
|
1145
|
-
return o;
|
|
1146
|
-
};
|
|
1147
|
-
}
|
|
1148
|
-
function ft(e, t) {
|
|
1149
|
-
const r = e.map((o) => ({ ...o, datasets: { ...o.datasets } })), n = /* @__PURE__ */ new Set();
|
|
1150
|
-
for (const { row: o, field: a, value: s } of t) {
|
|
1151
|
-
const c = r[o.partIndex], i = `${o.partIndex}:${o.dataset}`;
|
|
1152
|
-
n.has(i) || (c.datasets[o.dataset] = [...c.datasets[o.dataset]], n.add(i)), c.datasets[o.dataset][o.rowIndex] = { ...c.datasets[o.dataset][o.rowIndex], [a]: s };
|
|
1153
|
-
}
|
|
1154
|
-
return r;
|
|
1155
|
-
}
|
|
1156
|
-
function Zr(e, t, r) {
|
|
1157
|
-
const n = [], o = /* @__PURE__ */ new Set();
|
|
1158
|
-
return e.forEach((a, s) => {
|
|
1159
|
-
for (const c of dt(a))
|
|
1160
|
-
t.has(c.dataset) && (a.datasets[c.dataset] ?? []).forEach((i, l) => {
|
|
1161
|
-
const d = { partIndex: s, dataset: c.dataset, rowIndex: l, row: i, binding: c };
|
|
1162
|
-
for (const [u, f] of [[c.revisionField, r.revision], [c.sourceTokenField, r.sourceToken]]) {
|
|
1163
|
-
if (!u || f === void 0) continue;
|
|
1164
|
-
const m = `${s}:${c.dataset}:${l}:${u}`;
|
|
1165
|
-
o.has(m) || (o.add(m), n.push({ row: d, field: u, value: f }));
|
|
1166
|
-
}
|
|
1167
|
-
});
|
|
1168
|
-
}), n;
|
|
1169
|
-
}
|
|
1170
|
-
function mt(e) {
|
|
1171
|
-
const t = /* @__PURE__ */ new Map(), r = H(e);
|
|
1172
|
-
return e.pages.forEach((n, o) => n.components.forEach((a, s) => {
|
|
1173
|
-
if (!(!a.grid || a.table?.role !== "body"))
|
|
1174
|
-
for (let c = 0; c < a.grid.cells.length; c++) for (let i = 0; i < a.table.columnKeys.length; i++) {
|
|
1175
|
-
const l = r({ pageIndex: o, componentIndex: s, rowIndex: c, columnIndex: i });
|
|
1176
|
-
l?.source && l.editable && t.set(C(l), l);
|
|
1177
|
-
}
|
|
1178
|
-
})), t;
|
|
1179
|
-
}
|
|
1180
|
-
function _n(e, t, r) {
|
|
1181
|
-
const n = mt(e), o = H(e);
|
|
1182
|
-
return t.map((a) => {
|
|
1183
|
-
const s = a.source ? n.get(C(a)) : o(a.address);
|
|
1184
|
-
if (!s || C(s) !== C(a)) throw new b("missing");
|
|
1185
|
-
return { address: { ...s.address }, value: a[r] };
|
|
1186
|
-
});
|
|
1187
|
-
}
|
|
1188
|
-
async function gt(e, t, r = {}) {
|
|
1189
|
-
const n = [], o = { ...r, knownTotalPages: void 0 };
|
|
1190
|
-
for (const a of Cr(e, t, o))
|
|
1191
|
-
n.push(a), n.length % 8 === 0 && await new Promise((s) => setTimeout(s, 0));
|
|
1192
|
-
if (r.signal?.aborted) {
|
|
1193
|
-
const a = new Error("报表重算已取消");
|
|
1194
|
-
throw a.name = "AbortError", a;
|
|
1195
|
-
}
|
|
1196
|
-
return { schemaVersion: Y, ...Z(e) ? { requiresRecalculation: !0 } : {}, pages: n };
|
|
1197
|
-
}
|
|
1198
|
-
const ue = /* @__PURE__ */ new WeakMap();
|
|
1199
|
-
function qn(e) {
|
|
1200
|
-
return ue.get(e);
|
|
1201
|
-
}
|
|
1202
|
-
function q(e) {
|
|
1203
|
-
if (e?.aborted) {
|
|
1204
|
-
const t = new Error("报表重算已取消");
|
|
1205
|
-
throw t.name = "AbortError", t;
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
function pt(e, t) {
|
|
1209
|
-
return e[t] === void 0 ? "" : e[t];
|
|
1210
|
-
}
|
|
1211
|
-
function en(e, t) {
|
|
1212
|
-
if (t.edits.length > 1e4) throw new b("limit");
|
|
1213
|
-
const r = H(e), n = /* @__PURE__ */ new Set(), o = [], a = t.edits.map((s) => {
|
|
1214
|
-
const c = r(s.address);
|
|
1215
|
-
if (!c?.source) throw new b("missing");
|
|
1216
|
-
const i = C(s);
|
|
1217
|
-
if (n.has(i)) throw new b("duplicate");
|
|
1218
|
-
if (n.add(i), $e(c, s) || !Object.is(c.value, s.previousValue) || (c.cell.text ?? "") !== s.previousText) throw new b("conflict");
|
|
1219
|
-
return o.push(c), _(c, s.value);
|
|
1220
|
-
});
|
|
1221
|
-
return { batch: { requestId: t.requestId, edits: a }, contexts: o };
|
|
1222
|
-
}
|
|
1223
|
-
function tn(e, t) {
|
|
1224
|
-
const r = ut(e);
|
|
1225
|
-
return t.flatMap((n) => {
|
|
1226
|
-
if (!n.source) throw new b("missing");
|
|
1227
|
-
return r(n.source).map((o) => {
|
|
1228
|
-
if (!Object.is(pt(o.row, n.source.field), n.previousValue)) throw new b("conflict");
|
|
1229
|
-
if (o.binding.rowKey === n.source.field) throw new b("readonly");
|
|
1230
|
-
return { row: o, field: n.source.field, value: n.value };
|
|
1231
|
-
});
|
|
1232
|
-
});
|
|
1233
|
-
}
|
|
1234
|
-
function ie(e, t, r) {
|
|
1235
|
-
const n = { ...e, value: t, source: { ...e.source, ...r?.revision === void 0 ? {} : { revision: r.revision }, ...r?.sourceToken === void 0 ? {} : { sourceToken: r.sourceToken } } };
|
|
1236
|
-
return n.cell = { ...e.cell, value: n.value, text: z(n, n.value) }, n;
|
|
1237
|
-
}
|
|
1238
|
-
function rn(e, t, r) {
|
|
1239
|
-
if (!r || r.revision === void 0 && r.sourceToken === void 0) return [...e];
|
|
1240
|
-
const n = new Set(t.edits.flatMap((o) => o.source ? [o.source.datasetId] : []));
|
|
1241
|
-
return ft(e, Zr(e, n, r));
|
|
1242
|
-
}
|
|
1243
|
-
function ht(e, t) {
|
|
1244
|
-
let r = t.parts;
|
|
1245
|
-
const n = t.rebuild, o = ke(r);
|
|
1246
|
-
let a = e, s;
|
|
1247
|
-
const c = /* @__PURE__ */ new Map();
|
|
1248
|
-
function i(u) {
|
|
1249
|
-
if (u !== a) throw new b("conflict");
|
|
1250
|
-
if (s) return s;
|
|
1251
|
-
if (ke(r) !== o) throw new b("conflict");
|
|
1252
|
-
return Qr(r);
|
|
1253
|
-
}
|
|
1254
|
-
async function l(u, f, m, p = {}) {
|
|
1255
|
-
q(p.signal), f = { requestId: f.requestId, edits: f.edits.map((y) => ({ ...y, address: { ...y.address }, source: y.source ? { ...y.source } : void 0, table: y.table ? { ...y.table } : void 0 })) }, m = m.map((y) => ({ ...y, address: { ...y.address }, source: y.source ? { ...y.source } : void 0, table: y.table ? { ...y.table } : void 0, cell: { ...y.cell } })), await new Promise((y) => setTimeout(y, 0)), q(p.signal);
|
|
1256
|
-
const g = i(u), w = ft(g, tn(g, f.edits)), v = await n(w, p.signal);
|
|
1257
|
-
q(p.signal);
|
|
1258
|
-
let M = !1;
|
|
1259
|
-
return { plan: v, commit(y) {
|
|
1260
|
-
if (q(p.signal), M || a !== u) throw new b("conflict");
|
|
1261
|
-
if (y?.conflicts?.length) throw new b("conflict");
|
|
1262
|
-
const j = rn(w, f, y), O = _r(v, f, y);
|
|
1263
|
-
if (y) {
|
|
1264
|
-
const I = new Set(f.edits.map((R) => R.source.datasetId));
|
|
1265
|
-
for (const [R, h] of c) I.has(h.source.datasetId) && c.set(R, ie(h, h.value, y));
|
|
1266
|
-
}
|
|
1267
|
-
return m.forEach((I, R) => c.set(C(I), ie(I, f.edits[R].value, y))), M = !0, s = j, r = void 0, a = O, ue.set(a, d), a;
|
|
1268
|
-
} };
|
|
1269
|
-
}
|
|
1270
|
-
const d = {
|
|
1271
|
-
get plan() {
|
|
1272
|
-
return a;
|
|
1273
|
-
},
|
|
1274
|
-
async prepare(u, f, m) {
|
|
1275
|
-
const p = en(u, f);
|
|
1276
|
-
return l(u, p.batch, p.contexts, m);
|
|
1277
|
-
},
|
|
1278
|
-
async prepareHistory(u, f, m, p, g) {
|
|
1279
|
-
if (!p.trim() || f.length > 1e4) throw new b("limit");
|
|
1280
|
-
const w = i(u), v = ut(w), M = mt(u), y = /* @__PURE__ */ new Set(), O = f.map((h) => {
|
|
1281
|
-
if (!h.source) throw new b("missing");
|
|
1282
|
-
const x = C(h);
|
|
1283
|
-
if (y.has(x)) throw new b("duplicate");
|
|
1284
|
-
y.add(x);
|
|
1285
|
-
const $ = M.get(x) ?? c.get(x);
|
|
1286
|
-
if (!$?.source) throw new b("missing");
|
|
1287
|
-
const T = v($.source)[0];
|
|
1288
|
-
return ie($, pt(T.row, $.source.field));
|
|
1289
|
-
}).map((h, x) => ({ context: h, edit: _(h, f[x][m]) })).filter(({ edit: h }) => !Object.is(h.previousValue, h.value)), I = { requestId: p, edits: O.map(({ edit: h }) => h) }, R = O.map(({ context: h }) => h);
|
|
1290
|
-
return { batch: I, contexts: R, prepared: await l(u, I, R, g) };
|
|
1291
|
-
}
|
|
1292
|
-
};
|
|
1293
|
-
return ue.set(e, d), d;
|
|
1294
|
-
}
|
|
1295
|
-
function Un(e) {
|
|
1296
|
-
const t = Me(e.template, e.datasets, e.pagination).plan;
|
|
1297
|
-
return ht(t, { parts: [{ template: e.template, datasets: e.datasets }], rebuild: (r, n) => gt(r[0].template, r[0].datasets, { ...e.pagination, signal: n }) });
|
|
1298
|
-
}
|
|
1299
|
-
function Se(e, t, r = {}) {
|
|
1300
|
-
const n = /* @__PURE__ */ new Map();
|
|
1301
|
-
for (const a of e.pages) for (const s of a.components) {
|
|
1302
|
-
if (s.kind !== "list" || s.tree?.input !== "nested") continue;
|
|
1303
|
-
const c = n.get(s.dataset);
|
|
1304
|
-
if (c && (c.childrenField ?? "children") !== (s.tree.childrenField ?? "children")) throw new Error("同一数据集的嵌套树应使用相同 childrenField");
|
|
1305
|
-
n.set(s.dataset, s.tree);
|
|
1306
|
-
}
|
|
1307
|
-
if (!n.size) return t;
|
|
1308
|
-
const o = { ...t };
|
|
1309
|
-
for (const [a, s] of n) {
|
|
1310
|
-
const c = Math.min(s.maxRows ?? 1e5, r.maxRows ?? 1 / 0);
|
|
1311
|
-
o[a] = Je(t[a] ?? [], { ...s, maxRows: c }, r.signal);
|
|
1312
|
-
}
|
|
1313
|
-
return o;
|
|
1314
|
-
}
|
|
1315
|
-
function nn(e, t, r = {}) {
|
|
1316
|
-
return Object.values(Se(e, t, r)).reduce((n, o) => n + o.length, 0);
|
|
1317
|
-
}
|
|
1318
|
-
function Xn(e, t, r) {
|
|
1319
|
-
const n = Nt(r), o = e?.pages.flatMap((c) => c.components).find((c) => c.kind === "list" && c.dataset === t && c.tree?.input === "nested");
|
|
1320
|
-
if (!o || o.kind !== "list" || !o.tree) return n;
|
|
1321
|
-
const a = n.items, s = o.tree.childrenField ?? "children";
|
|
1322
|
-
return { ...n, items: { $ref: "#/$defs/treeNode" }, $defs: { treeNode: { ...a, properties: { ...a.properties, [s]: { anyOf: [{ type: "null" }, { type: "array", items: { $ref: "#/$defs/treeNode" } }] } } } } };
|
|
1323
|
-
}
|
|
1324
|
-
function Yn(e) {
|
|
1325
|
-
if (!("mapData" in e)) return e;
|
|
1326
|
-
const { load: t, mapData: r, ...n } = e;
|
|
1327
|
-
return { ...n, load: async (o) => {
|
|
1328
|
-
const a = await t(o);
|
|
1329
|
-
k(o.signal);
|
|
1330
|
-
try {
|
|
1331
|
-
return r(a, o);
|
|
1332
|
-
} catch (s) {
|
|
1333
|
-
throw new S("validate", `报表 ${o.reportId} 数据映射失败`, s);
|
|
1334
|
-
}
|
|
1335
|
-
} };
|
|
1336
|
-
}
|
|
1337
|
-
class S extends Error {
|
|
1338
|
-
constructor(t, r, n) {
|
|
1339
|
-
super(r), this.name = "ReportSourceError", this.code = t, this.cause = n;
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
|
-
function oe(e) {
|
|
1343
|
-
const t = new Error("报表加载已取消");
|
|
1344
|
-
return t.name = "AbortError", Object.defineProperty(t, "cause", { value: e.reason }), t;
|
|
1345
|
-
}
|
|
1346
|
-
function k(e) {
|
|
1347
|
-
if (e?.aborted) throw oe(e);
|
|
1348
|
-
}
|
|
1349
|
-
function fe(e, t) {
|
|
1350
|
-
return t ? new Promise((r, n) => {
|
|
1351
|
-
const o = () => t.removeEventListener("abort", a), a = () => {
|
|
1352
|
-
o(), n(oe(t));
|
|
1353
|
-
};
|
|
1354
|
-
t.addEventListener("abort", a, { once: !0 }), t.aborted && a(), Promise.resolve(e).then(
|
|
1355
|
-
(s) => {
|
|
1356
|
-
o(), r(s);
|
|
1357
|
-
},
|
|
1358
|
-
(s) => {
|
|
1359
|
-
o(), n(s);
|
|
1360
|
-
}
|
|
1361
|
-
);
|
|
1362
|
-
}) : Promise.resolve(e);
|
|
1363
|
-
}
|
|
1364
|
-
function on(e, t) {
|
|
1365
|
-
if (!e || typeof e != "object" || Array.isArray(e))
|
|
1366
|
-
throw new S("validate", `报表 ${t} 的数据集应为对象`);
|
|
1367
|
-
for (const [r, n] of Object.entries(e))
|
|
1368
|
-
if (!Array.isArray(n) || n.some((o) => !o || typeof o != "object" || Array.isArray(o)))
|
|
1369
|
-
throw new S("validate", `报表 ${t} 的数据集 ${r} 应为对象数组`);
|
|
1370
|
-
}
|
|
1371
|
-
async function an(e, t, r) {
|
|
1372
|
-
const { reportId: n, signal: o } = t;
|
|
1373
|
-
try {
|
|
1374
|
-
const a = await fe(e(t), o);
|
|
1375
|
-
k(o);
|
|
1376
|
-
const s = kt(a);
|
|
1377
|
-
if (!s.ok)
|
|
1378
|
-
throw new S("validate", `报表 ${n} 模板校验失败:${s.errors.slice(0, 3).map((c) => `${c.path}: ${c.message}`).join("; ")}`);
|
|
1379
|
-
return r.push(...s.warnings.map((c) => `${n}: ${c.path}: ${c.message}`)), a;
|
|
1380
|
-
} catch (a) {
|
|
1381
|
-
throw o?.aborted ? oe(o) : a instanceof S ? a : a instanceof Et ? new S("validate", `报表 ${n} 模板校验失败:${a.message}`, a) : new S("fetch", `报表 ${n} 模板加载失败:${a instanceof Error ? a.message : String(a)}`, a);
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
async function sn(e, t, r, n) {
|
|
1385
|
-
const o = t.signal;
|
|
1386
|
-
let a;
|
|
1387
|
-
try {
|
|
1388
|
-
if (e.load) a = await fe(e.load(t), o);
|
|
1389
|
-
else if (e.provider) {
|
|
1390
|
-
const s = await fe(e.provider.query(t), o);
|
|
1391
|
-
k(o), cn(s, r), a = s.datasets, n?.(r, s);
|
|
1392
|
-
} else a = e.datasets ?? {};
|
|
1393
|
-
} catch (s) {
|
|
1394
|
-
throw o?.aborted ? oe(o) : s instanceof S ? s : new S("fetch", `报表 ${r} 取数失败:${s instanceof Error ? s.message : String(s)}`, s);
|
|
1395
|
-
}
|
|
1396
|
-
return k(o), a;
|
|
1397
|
-
}
|
|
1398
|
-
function cn(e, t) {
|
|
1399
|
-
if (!e || typeof e != "object" || Array.isArray(e)) throw new S("validate", `报表 ${t} Provider 应返回 datasets 结果对象`);
|
|
1400
|
-
for (const r of ["revision", "sourceToken"])
|
|
1401
|
-
if (e[r] !== void 0 && typeof e[r] != "string") throw new S("validate", `报表 ${t} Provider ${r} 应为字符串`);
|
|
1402
|
-
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))))
|
|
1403
|
-
throw new S("validate", `报表 ${t} Provider diagnostics 不符合结构化诊断契约`);
|
|
1404
|
-
if (e.diagnostics?.some((r) => !jt(r)))
|
|
1405
|
-
throw new S("validate", `报表 ${t} Provider 数据说明缺少有效的字段身份或值状态`);
|
|
1406
|
-
}
|
|
1407
|
-
function ln(e, t, r, n, o) {
|
|
1408
|
-
try {
|
|
1409
|
-
t = Se(n, t, { maxRows: e.dataValidation?.maxRows, signal: o });
|
|
1410
|
-
} catch (a) {
|
|
1411
|
-
throw new S("validate", `报表 ${r} 树形数据无效:${a instanceof Error ? a.message : String(a)}`, a);
|
|
1412
|
-
}
|
|
1413
|
-
for (const [a, s] of Object.entries(e.dataSchema ?? {})) {
|
|
1414
|
-
let c;
|
|
1415
|
-
try {
|
|
1416
|
-
c = je(Object.prototype.hasOwnProperty.call(t, a) ? t[a] : void 0, s, { ...e.dataValidation, path: `$.datasets.${a}` });
|
|
1417
|
-
} catch (i) {
|
|
1418
|
-
throw new S("config", `报表 ${r} 数据集 ${a} 字段契约配置无效`, i);
|
|
1419
|
-
}
|
|
1420
|
-
if (!c.ok) throw new S("validate", `报表 ${r} 数据集 ${a} 不符合字段契约:${c.issues[0]?.message}`, { issues: c.issues });
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
function wt(e, t) {
|
|
1424
|
-
if (!e.repeat) return !1;
|
|
1425
|
-
const r = Object.prototype.hasOwnProperty.call(t, e.repeat.dataset) ? t[e.repeat.dataset] : void 0;
|
|
1426
|
-
return Array.isArray(r) && r.length === 0;
|
|
1427
|
-
}
|
|
1428
|
-
function yt(e) {
|
|
1429
|
-
const t = (r) => r.grid?.cells.reduce((n, o) => n + o.reduce((a, s) => a + (s ? 1 + (s.children?.reduce((c, i) => c + t(i), 0) ?? 0) : 0), 0), 0) ?? 0;
|
|
1430
|
-
return e.pages.reduce((r, n) => r + n.components.reduce((o, a) => o + t(a), 0), 0);
|
|
1431
|
-
}
|
|
1432
|
-
function bt(e, t, r, n) {
|
|
1433
|
-
return {
|
|
1434
|
-
...e,
|
|
1435
|
-
signal: n ?? e?.signal,
|
|
1436
|
-
...t === void 0 ? {} : { maxPages: Math.max(1, Math.min(t, e?.maxPages ?? t)) },
|
|
1437
|
-
...r === void 0 ? {} : { maxCells: Math.max(1, Math.min(r, e?.maxCells ?? r)) }
|
|
1438
|
-
};
|
|
1439
|
-
}
|
|
1440
|
-
function dn(e, t, r, n, o, a) {
|
|
1441
|
-
const s = o.maxPages === void 0 ? void 0 : o.maxPages - o.usedPages, c = o.maxCells === void 0 ? void 0 : o.maxCells - o.usedCells;
|
|
1442
|
-
try {
|
|
1443
|
-
if (s !== void 0 && s < 1 && e.pages.length && !wt(e, t)) throw new K(0, 1);
|
|
1444
|
-
const i = bt(r.pagination, s, c, a), l = Me(e, t, i), d = yt(l.plan);
|
|
1445
|
-
if (c !== void 0 && d > c) throw new D(c, d);
|
|
1446
|
-
return { ...l, cells: d };
|
|
1447
|
-
} catch (i) {
|
|
1448
|
-
let l = i;
|
|
1449
|
-
throw i instanceof K && o.maxPages !== void 0 && i.limit === s && (l = new K(o.maxPages, o.usedPages + i.actual)), i instanceof D && o.maxCells !== void 0 && (l = new D(o.maxCells, o.usedCells + i.actual)), new S("validate", `报表 ${n} 排版失败:${l instanceof Error ? l.message : String(l)}`, l);
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
function vt(e, t, r, n) {
|
|
1453
|
-
const o = /* @__PURE__ */ new Map(), a = (s) => {
|
|
1454
|
-
let c = o.get(s);
|
|
1455
|
-
return c === void 0 && (c = JSON.stringify([r, n, s]), o.set(s, c)), c;
|
|
1456
|
-
};
|
|
1457
|
-
for (const s of t.pages) e.push({
|
|
1458
|
-
...s,
|
|
1459
|
-
meta: { ...s.meta, reportScope: JSON.stringify([r, n]) },
|
|
1460
|
-
components: s.components.map((c) => c.table ? {
|
|
1461
|
-
...c,
|
|
1462
|
-
table: { ...c.table, id: a(c.table.id) }
|
|
1463
|
-
} : c)
|
|
1464
|
-
});
|
|
1465
|
-
}
|
|
1466
|
-
async function un(e, t, r, n, o) {
|
|
1467
|
-
const a = [];
|
|
1468
|
-
let s = 0;
|
|
1469
|
-
for (const [l, d] of e.entries()) {
|
|
1470
|
-
k(o);
|
|
1471
|
-
const u = n.maxPages === void 0 ? void 0 : n.maxPages - a.length, f = n.maxCells === void 0 ? void 0 : n.maxCells - s;
|
|
1472
|
-
if (u !== void 0 && u < 1 && d.template.pages.length && !wt(d.template, d.datasets)) throw new K(n.maxPages, a.length + 1);
|
|
1473
|
-
const m = await gt(d.template, d.datasets, bt(t[l]?.pagination, u, f, o));
|
|
1474
|
-
if (s += yt(m), n.maxCells !== void 0 && s > n.maxCells) throw new D(n.maxCells, s);
|
|
1475
|
-
vt(a, m, l, r[l]);
|
|
1476
|
-
}
|
|
1477
|
-
const c = { schemaVersion: Y, ...e.some((l) => Z(l.template)) ? { requiresRecalculation: !0 } : {}, pages: a }, i = Ae(c);
|
|
1478
|
-
if (!i.ok) throw new S("validate", `重算渲染计划校验失败:${i.errors[0]?.message}`);
|
|
1479
|
-
return c;
|
|
1480
|
-
}
|
|
1481
|
-
function Qn(e, t = {}) {
|
|
1482
|
-
if (t.maxPages !== void 0 && (!Number.isSafeInteger(t.maxPages) || t.maxPages < 1)) throw new S("config", "maxPages 应为正安全整数");
|
|
1483
|
-
if (t.maxCells !== void 0 && (!Number.isSafeInteger(t.maxCells) || t.maxCells < 1)) throw new S("config", "maxCells 应为正安全整数");
|
|
1484
|
-
function r(o) {
|
|
1485
|
-
const a = Object.prototype.hasOwnProperty.call(e, o) ? e[o] : void 0;
|
|
1486
|
-
if (!a) throw new S("config", `未注册报表 ${o}`);
|
|
1487
|
-
return a;
|
|
1488
|
-
}
|
|
1489
|
-
return Object.assign(async ({ reportIds: o, params: a, signal: s, onWarning: c, onQueryResult: i, ...l }) => {
|
|
1490
|
-
k(s);
|
|
1491
|
-
const d = At({ ...l, signal: s }), u = [...o], f = { ...a };
|
|
1492
|
-
if (u.length === 0) throw new S("config", "缺少报表 ID");
|
|
1493
|
-
const m = u.map(r), p = d.runSync("validate", () => m.map((h) => Te(
|
|
1494
|
-
h.params ?? (typeof h.template == "function" ? [] : h.template.params) ?? [],
|
|
1495
|
-
f
|
|
1496
|
-
))), g = [], w = [];
|
|
1497
|
-
let v = 0;
|
|
1498
|
-
const M = [];
|
|
1499
|
-
for (const [h, x] of m.entries()) {
|
|
1500
|
-
k(s);
|
|
1501
|
-
const $ = u[h], T = { reportId: $, params: p[h], signal: s }, P = typeof x.template == "function" ? await d.run("query", () => an(x.template, T, M), $) : x.template;
|
|
1502
|
-
T.params = d.runSync("validate", () => Te(x.params ?? P.params ?? [], T.params), $);
|
|
1503
|
-
const F = await d.run("query", () => sn(x, T, $, (se, St) => i?.(se, St, h)), $);
|
|
1504
|
-
d.runSync("validate", () => {
|
|
1505
|
-
on(F, $), t.onDatasets?.($, F, P), ln(x, F, $, P, s);
|
|
1506
|
-
}, $), k(s);
|
|
1507
|
-
const ae = d.runSync("layout", () => dn(P, F, x, $, { maxPages: t.maxPages, usedPages: g.length, maxCells: t.maxCells, usedCells: v }, s), $);
|
|
1508
|
-
v += ae.cells, w.push({ template: P, datasets: F }), vt(g, ae.plan, h, $), M.push(...ae.warnings.map((se) => `${$}: ${se}`));
|
|
1509
|
-
}
|
|
1510
|
-
k(s);
|
|
1511
|
-
const y = { schemaVersion: Y, ...w.some((h) => Z(h.template)) ? { requiresRecalculation: !0 } : {}, pages: g }, j = d.runSync("validate", () => {
|
|
1512
|
-
const h = Ae(y);
|
|
1513
|
-
if (!h.ok) throw new S("validate", `渲染计划校验失败:${h.errors.slice(0, 3).map((x) => `${x.path}: ${x.message}`).join("; ")}`);
|
|
1514
|
-
return h;
|
|
1515
|
-
});
|
|
1516
|
-
M.push(...j.warnings.map((h) => `${h.path}: ${h.message}`));
|
|
1517
|
-
const O = m.map((h) => ({ ...h, pagination: { ...h.pagination } })), I = { maxPages: t.maxPages, maxCells: t.maxCells };
|
|
1518
|
-
try {
|
|
1519
|
-
ht(y, { parts: w, rebuild: (h, x) => un(h, O, u, I, x) });
|
|
1520
|
-
} catch {
|
|
1521
|
-
M.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算");
|
|
1522
|
-
}
|
|
1523
|
-
const R = c ?? t.onWarning ?? ((h) => console.warn("[mach-report]", h));
|
|
1524
|
-
for (const h of M)
|
|
1525
|
-
k(s), R(h);
|
|
1526
|
-
return k(s), y;
|
|
1527
|
-
}, {
|
|
1528
|
-
getParamDefs: (o) => Tt(e, o)
|
|
1529
|
-
});
|
|
1530
|
-
}
|
|
1531
|
-
function Ce(e) {
|
|
1532
|
-
if (e === void 0) return;
|
|
1533
|
-
const t = typeof e == "string" ? e : JSON.stringify(e);
|
|
1534
|
-
return t.length > 160 ? t.slice(0, 157) + "…" : t;
|
|
1535
|
-
}
|
|
1536
|
-
function fn(e) {
|
|
1537
|
-
return /\.(?:repeat|binding)(?:\.|$)/.test(e) ? /\.format(?:\.|$)/.test(e) ? "format" : "binding" : /\.tree\.(?:idField|parentField|childrenField|labelField|input)$/.test(e) ? "binding" : /\.tree\.parentValues$/.test(e) ? "calculation" : /\.tree\.indentMm$/.test(e) ? "format" : /\.(?:computed|computeOptions|groups|groupBy|aggregates|grandTotal)(?:\.|\[|$)/.test(e) ? "calculation" : /\.(?:dataset|field|rowKey|revisionField|sourceTokenField|foreignKey|parentKey)$/.test(e) ? "binding" : /\.(?:style|headerStyle|format|rules|align|headerAlign|semanticRole|unit)(?:\.|\[|$)/.test(e) ? "format" : e.startsWith("$.template") ? "structure" : "metadata";
|
|
1538
|
-
}
|
|
1539
|
-
function Oe(e) {
|
|
1540
|
-
const t = /* @__PURE__ */ new Map();
|
|
1541
|
-
for (const r of e) {
|
|
1542
|
-
if (!r || typeof r != "object" || !("field" in r) || typeof r.field != "string" || t.has(r.field)) return;
|
|
1543
|
-
t.set(r.field, r);
|
|
1544
|
-
}
|
|
1545
|
-
return t;
|
|
1546
|
-
}
|
|
1547
|
-
function mn(e, t, r) {
|
|
1548
|
-
return !e.startsWith("$.template.params") || t === "moved" ? !1 : /\.(?:type|required|min|max|minLength|maxLength|options|defaultValue)(?:\[|$)/.test(e) ? !0 : t !== "added" ? !1 : Array.isArray(r) ? r.some((n) => !!n && typeof n == "object" && "required" in n && n.required === !0) : !!r && typeof r == "object" && "required" in r && r.required === !0;
|
|
1549
|
-
}
|
|
1550
|
-
function gn(e, t, r = {}) {
|
|
1551
|
-
const n = ce(e), o = ce(t), a = r.maxChanges ?? 500;
|
|
1552
|
-
if (!Number.isSafeInteger(a) || a < 1 || a > 1e4) throw new RangeError("maxChanges must be between 1 and 10000");
|
|
1553
|
-
const s = { changes: [], totalChanges: 0, breakingChanges: 0, truncated: !1 };
|
|
1554
|
-
function c(d, u, f, m) {
|
|
1555
|
-
const p = fn(u), g = d !== "moved" && (p === "binding" || u === "$.id" || d === "removed" && p === "structure" || mn(u, d, m));
|
|
1556
|
-
s.totalChanges++, g && s.breakingChanges++, s.changes.length < a && s.changes.push({ kind: d, category: p, path: u, before: Ce(f), after: Ce(m), breaking: g });
|
|
1557
|
-
}
|
|
1558
|
-
function i(d, u, f) {
|
|
1559
|
-
const m = Oe(d), p = Oe(u);
|
|
1560
|
-
if (!m || !p) return !1;
|
|
1561
|
-
const g = new Map(u.map((w, v) => [w.field, v]));
|
|
1562
|
-
Array.from(m).forEach(([w, v], M) => {
|
|
1563
|
-
const y = `${f}[${JSON.stringify(w)}]`;
|
|
1564
|
-
p.has(w) ? (g.get(w) !== M && c("moved", y, M, g.get(w)), l(v, p.get(w), y)) : c("removed", y, v, void 0);
|
|
1565
|
-
});
|
|
1566
|
-
for (const [w, v] of p) m.has(w) || c("added", `${f}[${JSON.stringify(w)}]`, void 0, v);
|
|
1567
|
-
return !0;
|
|
1568
|
-
}
|
|
1569
|
-
function l(d, u, f) {
|
|
1570
|
-
if (!(Object.is(d, u) || f === "$.revision")) {
|
|
1571
|
-
if (d === void 0 || u === void 0) {
|
|
1572
|
-
c(d === void 0 ? "added" : "removed", f, d, u);
|
|
1573
|
-
return;
|
|
1574
|
-
}
|
|
1575
|
-
if (Array.isArray(d) && Array.isArray(u)) {
|
|
1576
|
-
if ((f.endsWith(".columns") || f.endsWith(".params")) && i(d, u, f)) return;
|
|
1577
|
-
for (let m = 0; m < Math.max(d.length, u.length); m++) l(d[m], u[m], `${f}[${m}]`);
|
|
1578
|
-
} else if (d && u && typeof d == "object" && typeof u == "object" && !Array.isArray(d) && !Array.isArray(u)) {
|
|
1579
|
-
const m = d, p = u;
|
|
1580
|
-
for (const g of /* @__PURE__ */ new Set([...Object.keys(m), ...Object.keys(p)])) l(m[g], p[g], `${f}.${g}`);
|
|
1581
|
-
} else c("modified", f, d, u);
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
return l(n, o, "$"), s.truncated = s.totalChanges > s.changes.length, s;
|
|
1585
|
-
}
|
|
1586
|
-
function pn(e, t, r) {
|
|
1587
|
-
for (const n of Ge(e)) {
|
|
1588
|
-
const o = Object.prototype.hasOwnProperty.call(
|
|
1589
|
-
t,
|
|
1590
|
-
n.dataset
|
|
1591
|
-
) ? t[n.dataset] : void 0;
|
|
1592
|
-
if (!o) {
|
|
1593
|
-
r.push({
|
|
1594
|
-
code: "dataset",
|
|
1595
|
-
severity: "error",
|
|
1596
|
-
path: `${n.path}.dataset`,
|
|
1597
|
-
message: `未声明数据集 ${n.dataset}`
|
|
1598
|
-
});
|
|
1599
|
-
continue;
|
|
1600
|
-
}
|
|
1601
|
-
const a = new Set(o.fields.map((s) => s.field));
|
|
1602
|
-
n.fields.forEach(({ field: s, path: c, summary: i }) => {
|
|
1603
|
-
!a.has(s) && !n.generated.has(s) && !(i && n.summaries.has(s)) && r.push({
|
|
1604
|
-
code: "field",
|
|
1605
|
-
severity: "error",
|
|
1606
|
-
path: c,
|
|
1607
|
-
field: s,
|
|
1608
|
-
message: `数据集 ${n.dataset} 缺少字段 ${s}`
|
|
1609
|
-
});
|
|
1610
|
-
});
|
|
1611
|
-
}
|
|
1612
|
-
}
|
|
1613
|
-
function hn(e, t, r, n) {
|
|
1614
|
-
const o = r.maxSampleRows ?? 1e3;
|
|
1615
|
-
let a;
|
|
1616
|
-
try {
|
|
1617
|
-
a = Se(t, e.datasets, {
|
|
1618
|
-
maxRows: o
|
|
1619
|
-
});
|
|
1620
|
-
} catch (i) {
|
|
1621
|
-
return n.push({
|
|
1622
|
-
code: "sample",
|
|
1623
|
-
severity: "error",
|
|
1624
|
-
path: "$.fixtures",
|
|
1625
|
-
fixture: e.name,
|
|
1626
|
-
message: i instanceof Error ? i.message : String(i)
|
|
1627
|
-
}), !1;
|
|
1628
|
-
}
|
|
1629
|
-
const s = Object.values(a).reduce(
|
|
1630
|
-
(i, l) => i + l.length,
|
|
1631
|
-
0
|
|
1632
|
-
);
|
|
1633
|
-
if (s > o)
|
|
1634
|
-
return n.push({
|
|
1635
|
-
code: "sample",
|
|
1636
|
-
severity: "error",
|
|
1637
|
-
path: "$.fixtures",
|
|
1638
|
-
fixture: e.name,
|
|
1639
|
-
message: `样例 ${s} 行超过预算 ${o},请显式选择验收样例`
|
|
1640
|
-
}), !1;
|
|
1641
|
-
const c = new Set(
|
|
1642
|
-
Ge(t).map((i) => i.dataset)
|
|
1643
|
-
);
|
|
1644
|
-
for (const [i, l] of Object.entries(r.dataSchemas ?? {}).filter(
|
|
1645
|
-
([d]) => c.has(d)
|
|
1646
|
-
))
|
|
1647
|
-
try {
|
|
1648
|
-
const d = je(a[i], l, {
|
|
1649
|
-
path: `$.datasets.${i}`,
|
|
1650
|
-
maxRows: o
|
|
1651
|
-
});
|
|
1652
|
-
if (n.push(
|
|
1653
|
-
...d.issues.map((u) => ({
|
|
1654
|
-
...u,
|
|
1655
|
-
code: "sample",
|
|
1656
|
-
severity: "error",
|
|
1657
|
-
fixture: e.name
|
|
1658
|
-
}))
|
|
1659
|
-
), !d.ok) return !1;
|
|
1660
|
-
} catch (d) {
|
|
1661
|
-
return n.push({
|
|
1662
|
-
code: "dataset",
|
|
1663
|
-
severity: "error",
|
|
1664
|
-
path: `$.dataSchemas.${i}`,
|
|
1665
|
-
message: String(d)
|
|
1666
|
-
}), !1;
|
|
1667
|
-
}
|
|
1668
|
-
return !0;
|
|
1669
|
-
}
|
|
1670
|
-
function wn(e, t) {
|
|
1671
|
-
const r = e.pages[t.pageIndex]?.components[t.componentIndex]?.meta?.labelSource;
|
|
1672
|
-
if (r && typeof r == "object" && "pageIndex" in r && "componentIndex" in r && typeof r.pageIndex == "number" && typeof r.componentIndex == "number")
|
|
1673
|
-
return {
|
|
1674
|
-
path: `$.template.pages[${r.pageIndex}].components[${r.componentIndex}]`,
|
|
1675
|
-
pageIndex: r.pageIndex,
|
|
1676
|
-
componentIndex: r.componentIndex
|
|
1677
|
-
};
|
|
1678
|
-
const n = e.pages[t.pageIndex]?.meta?.record;
|
|
1679
|
-
if (n && typeof n == "object" && "templatePageIndex" in n && typeof n.templatePageIndex == "number")
|
|
1680
|
-
return {
|
|
1681
|
-
path: `$.template.pages[${n.templatePageIndex}].components[${t.componentIndex}]`,
|
|
1682
|
-
pageIndex: n.templatePageIndex,
|
|
1683
|
-
componentIndex: t.componentIndex
|
|
1684
|
-
};
|
|
1685
|
-
}
|
|
1686
|
-
function yn(e, t, r) {
|
|
1687
|
-
const n = wn(t, r);
|
|
1688
|
-
if (n) return n;
|
|
1689
|
-
const o = t.pages[r.pageIndex]?.components[r.componentIndex], a = /^table:(\d+):(\d+)(?::|$)/.exec(o?.table?.id ?? "");
|
|
1690
|
-
if (a)
|
|
1691
|
-
return {
|
|
1692
|
-
path: `$.template.pages[${a[1]}].components[${a[2]}]`,
|
|
1693
|
-
pageIndex: Number(a[1]),
|
|
1694
|
-
componentIndex: Number(a[2])
|
|
1695
|
-
};
|
|
1696
|
-
for (const [s, c] of e.pages.entries()) {
|
|
1697
|
-
const i = c.components.findIndex(
|
|
1698
|
-
(l) => l === o || o?.nid !== void 0 && "nid" in l && l.nid === o.nid
|
|
1699
|
-
);
|
|
1700
|
-
if (i >= 0)
|
|
1701
|
-
return {
|
|
1702
|
-
path: `$.template.pages[${s}].components[${i}]`,
|
|
1703
|
-
pageIndex: s,
|
|
1704
|
-
componentIndex: i
|
|
1705
|
-
};
|
|
1706
|
-
}
|
|
1707
|
-
return { path: "$.template" };
|
|
1708
|
-
}
|
|
1709
|
-
function bn(e, t, r, n, o) {
|
|
1710
|
-
const a = Ct(
|
|
1711
|
-
e.template.params ?? [],
|
|
1712
|
-
t.params ?? {}
|
|
1713
|
-
);
|
|
1714
|
-
if (o.issues.push(
|
|
1715
|
-
...a.issues.map((s) => ({
|
|
1716
|
-
...s,
|
|
1717
|
-
code: "params",
|
|
1718
|
-
severity: "error",
|
|
1719
|
-
fixture: t.name,
|
|
1720
|
-
path: s.path.replace(/^\$\.params/, `$.fixtures[${r}].params`)
|
|
1721
|
-
}))
|
|
1722
|
-
), !!a.ok && hn(t, e.template, n, o.issues))
|
|
1723
|
-
try {
|
|
1724
|
-
const { plan: s, warnings: c } = Me(
|
|
1725
|
-
e.template,
|
|
1726
|
-
t.datasets,
|
|
1727
|
-
{
|
|
1728
|
-
maxPages: n.maxPages ?? 100,
|
|
1729
|
-
maxCells: n.maxCells ?? 25e4
|
|
1730
|
-
}
|
|
1731
|
-
), i = (n.formats ?? ["pdf", "xlsx"]).flatMap(
|
|
1732
|
-
(l) => Ut(s, l)
|
|
1733
|
-
);
|
|
1734
|
-
o.issues.push(
|
|
1735
|
-
...c.map((l) => ({
|
|
1736
|
-
code: "layout",
|
|
1737
|
-
severity: "warning",
|
|
1738
|
-
path: "$.template",
|
|
1739
|
-
fixture: t.name,
|
|
1740
|
-
message: l
|
|
1741
|
-
}))
|
|
1742
|
-
), o.issues.push(
|
|
1743
|
-
...i.map((l) => ({
|
|
1744
|
-
code: "output",
|
|
1745
|
-
severity: n.strictOutputs ? "error" : "warning",
|
|
1746
|
-
...yn(e.template, s, l),
|
|
1747
|
-
fixture: t.name,
|
|
1748
|
-
message: `${l.format}: ${l.message}`,
|
|
1749
|
-
diagnostic: l
|
|
1750
|
-
}))
|
|
1751
|
-
), o.samples.push({
|
|
1752
|
-
name: t.name,
|
|
1753
|
-
pages: s.pages.length,
|
|
1754
|
-
rows: nn(e.template, t.datasets),
|
|
1755
|
-
diagnostics: i
|
|
1756
|
-
});
|
|
1757
|
-
} catch (s) {
|
|
1758
|
-
o.issues.push({
|
|
1759
|
-
code: "layout",
|
|
1760
|
-
severity: "error",
|
|
1761
|
-
path: "$.template",
|
|
1762
|
-
fixture: t.name,
|
|
1763
|
-
message: s instanceof Error ? s.message : String(s)
|
|
1764
|
-
});
|
|
1765
|
-
}
|
|
1766
|
-
}
|
|
1767
|
-
function vn(e) {
|
|
1768
|
-
for (const [r, n] of [
|
|
1769
|
-
["maxPages", e.maxPages],
|
|
1770
|
-
["maxCells", e.maxCells],
|
|
1771
|
-
["maxSampleRows", e.maxSampleRows]
|
|
1772
|
-
])
|
|
1773
|
-
if (n !== void 0 && (!Number.isSafeInteger(n) || n < 1))
|
|
1774
|
-
throw new RangeError(`${r} must be a positive safe integer`);
|
|
1775
|
-
if ((e.fixtures?.length ?? 0) > 20)
|
|
1776
|
-
throw new RangeError("At most 20 review fixtures are allowed");
|
|
1777
|
-
const t = /* @__PURE__ */ new Set();
|
|
1778
|
-
for (const r of e.fixtures ?? []) {
|
|
1779
|
-
if (typeof r.name != "string" || !r.name.trim() || r.name.length > 120 || t.has(r.name))
|
|
1780
|
-
throw new Error(
|
|
1781
|
-
"Review fixtures require unique non-empty names of at most 120 characters"
|
|
1782
|
-
);
|
|
1783
|
-
t.add(r.name);
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
function* Mt(e, t, r) {
|
|
1787
|
-
let n;
|
|
1788
|
-
yield {
|
|
1789
|
-
stage: "template",
|
|
1790
|
-
run: () => {
|
|
1791
|
-
vn(t), n = ce(e);
|
|
1792
|
-
}
|
|
1793
|
-
};
|
|
1794
|
-
const o = t.previous;
|
|
1795
|
-
o && (yield {
|
|
1796
|
-
stage: "baseline",
|
|
1797
|
-
run: () => {
|
|
1798
|
-
r.changes = gn(o, n), r.changes.breakingChanges && !t.allowBreakingChanges && r.issues.push({
|
|
1799
|
-
code: "compatibility",
|
|
1800
|
-
severity: "error",
|
|
1801
|
-
path: "$.template",
|
|
1802
|
-
message: `${r.changes.breakingChanges} 项字段或结构变更需要明确确认兼容性`
|
|
1803
|
-
});
|
|
1804
|
-
}
|
|
1805
|
-
}), t.dataSchemas && (yield {
|
|
1806
|
-
stage: "bindings",
|
|
1807
|
-
run: () => pn(n.template, t.dataSchemas, r.issues)
|
|
1808
|
-
});
|
|
1809
|
-
for (const [a, s] of (t.fixtures ?? []).entries())
|
|
1810
|
-
yield {
|
|
1811
|
-
stage: "fixture",
|
|
1812
|
-
fixture: s.name,
|
|
1813
|
-
run: () => bn(n, s, a, t, r)
|
|
1814
|
-
};
|
|
1815
|
-
t.fixtures?.length || r.issues.push({
|
|
1816
|
-
code: "sample",
|
|
1817
|
-
severity: "warning",
|
|
1818
|
-
path: "$.fixtures",
|
|
1819
|
-
message: "未提供验收样例,仅完成结构和字段检查,尚未验证排版与输出"
|
|
1820
|
-
});
|
|
1821
|
-
}
|
|
1822
|
-
function xt(e) {
|
|
1823
|
-
return e.ok = e.issues.every((t) => t.severity !== "error"), e;
|
|
1824
|
-
}
|
|
1825
|
-
function $t(e, t) {
|
|
1826
|
-
e.issues.push({
|
|
1827
|
-
code: "template",
|
|
1828
|
-
severity: "error",
|
|
1829
|
-
path: "$",
|
|
1830
|
-
message: t instanceof Error ? t.message : String(t)
|
|
1831
|
-
});
|
|
1832
|
-
}
|
|
1833
|
-
function Zn(e, t = {}) {
|
|
1834
|
-
const r = { ok: !1, issues: [], samples: [] };
|
|
1835
|
-
try {
|
|
1836
|
-
for (const n of Mt(e, t, r)) n.run();
|
|
1837
|
-
} catch (n) {
|
|
1838
|
-
$t(r, n);
|
|
1839
|
-
}
|
|
1840
|
-
return xt(r);
|
|
1841
|
-
}
|
|
1842
|
-
function N(e) {
|
|
1843
|
-
if (e?.aborted)
|
|
1844
|
-
throw e.reason ?? new DOMException("Template review was aborted", "AbortError");
|
|
1845
|
-
}
|
|
1846
|
-
function Mn(e) {
|
|
1847
|
-
return N(e), new Promise((t, r) => {
|
|
1848
|
-
const n = () => {
|
|
1849
|
-
clearTimeout(o), e?.removeEventListener("abort", n), r(
|
|
1850
|
-
e?.reason ?? new DOMException("Template review was aborted", "AbortError")
|
|
1851
|
-
);
|
|
1852
|
-
}, o = setTimeout(() => {
|
|
1853
|
-
e?.removeEventListener("abort", n), t();
|
|
1854
|
-
}, 0);
|
|
1855
|
-
e?.addEventListener("abort", n, { once: !0 }), e?.aborted && n();
|
|
1856
|
-
});
|
|
1857
|
-
}
|
|
1858
|
-
function Fe(e, t) {
|
|
1859
|
-
try {
|
|
1860
|
-
e.onProgress?.(t);
|
|
1861
|
-
} catch {
|
|
1862
|
-
}
|
|
1863
|
-
}
|
|
1864
|
-
async function eo(e, t = {}) {
|
|
1865
|
-
const r = { ok: !1, issues: [], samples: [] }, n = t.fixtures?.length ?? 0;
|
|
1866
|
-
let o = 0;
|
|
1867
|
-
N(t.signal);
|
|
1868
|
-
try {
|
|
1869
|
-
const a = Mt(e, t, r), s = a.next();
|
|
1870
|
-
s.done || (s.value.run(), Fe(t, {
|
|
1871
|
-
completed: o,
|
|
1872
|
-
total: n,
|
|
1873
|
-
stage: s.value.stage
|
|
1874
|
-
})), N(t.signal);
|
|
1875
|
-
for (const c of a)
|
|
1876
|
-
await Mn(t.signal), N(t.signal), c.run(), c.stage === "fixture" && o++, Fe(t, {
|
|
1877
|
-
completed: o,
|
|
1878
|
-
total: n,
|
|
1879
|
-
stage: c.stage,
|
|
1880
|
-
...c.fixture ? { fixture: c.fixture } : {}
|
|
1881
|
-
}), N(t.signal);
|
|
1882
|
-
} catch (a) {
|
|
1883
|
-
N(t.signal), $t(r, a);
|
|
1884
|
-
}
|
|
1885
|
-
return xt(r);
|
|
1886
|
-
}
|
|
1887
|
-
function to(e, t) {
|
|
1888
|
-
let r = 0, n = 0;
|
|
1889
|
-
const o = /* @__PURE__ */ new Set();
|
|
1890
|
-
function a(i, l) {
|
|
1891
|
-
if (++r > 1e6 || l > 64) throw t.error("budget", "快照节点或深度超过预算");
|
|
1892
|
-
if (r % 1024 === 0 && t.check?.(), typeof i == "string" && (n += i.length, n > t.maxBytes))
|
|
1893
|
-
throw t.error("budget", "快照文本超过预算");
|
|
1894
|
-
if (i === null || ["string", "boolean"].includes(typeof i) || typeof i == "number" && Number.isFinite(i)) return i;
|
|
1895
|
-
if (!i || typeof i != "object" || o.has(i)) throw t.error("input", "快照应为无循环的有限 JSON 值");
|
|
1896
|
-
return s(i, l);
|
|
1897
|
-
}
|
|
1898
|
-
function s(i, l) {
|
|
1899
|
-
const d = Array.isArray(i), u = Object.getPrototypeOf(i);
|
|
1900
|
-
if (u !== (d ? Array.prototype : Object.prototype) && !(u === null && !d) || Object.getOwnPropertySymbols(i).length) throw t.error("input", "快照应为普通 JSON 对象");
|
|
1901
|
-
const f = Object.getOwnPropertyNames(i).filter((p) => !(d && p === "length"));
|
|
1902
|
-
if (d && (f.length !== i.length || f.some((p, g) => p !== String(g)))) throw t.error("input", "快照数组应为连续数组");
|
|
1903
|
-
o.add(i);
|
|
1904
|
-
const m = /* @__PURE__ */ Object.create(null);
|
|
1905
|
-
for (const p of f) {
|
|
1906
|
-
if (n += p.length, n > t.maxBytes) throw t.error("budget", "快照文本超过预算");
|
|
1907
|
-
const g = Object.getOwnPropertyDescriptor(i, p);
|
|
1908
|
-
if (g.get || g.set || !g.enumerable || ["__proto__", "constructor", "prototype"].includes(p)) throw t.error("input", "快照不允许访问器或危险键");
|
|
1909
|
-
g.value !== void 0 && (m[p] = a(g.value, l + 1));
|
|
1910
|
-
}
|
|
1911
|
-
return o.delete(i), d ? f.map((p) => m[p]) : m;
|
|
1912
|
-
}
|
|
1913
|
-
t.check?.();
|
|
1914
|
-
const c = JSON.stringify(a(e, 0));
|
|
1915
|
-
if (new TextEncoder().encode(c).byteLength > t.maxBytes) throw t.error("budget", "快照超过字节预算");
|
|
1916
|
-
return JSON.parse(c);
|
|
1917
|
-
}
|
|
1918
|
-
export {
|
|
1919
|
-
eo as A,
|
|
1920
|
-
zn as B,
|
|
1921
|
-
Xn as C,
|
|
1922
|
-
rr as D,
|
|
1923
|
-
nn as E,
|
|
1924
|
-
D as P,
|
|
1925
|
-
S as R,
|
|
1926
|
-
b as a,
|
|
1927
|
-
K as b,
|
|
1928
|
-
Gn as c,
|
|
1929
|
-
Yn as d,
|
|
1930
|
-
Jn as e,
|
|
1931
|
-
_r as f,
|
|
1932
|
-
Bn as g,
|
|
1933
|
-
Wn as h,
|
|
1934
|
-
Vn as i,
|
|
1935
|
-
H as j,
|
|
1936
|
-
Un as k,
|
|
1937
|
-
Qn as l,
|
|
1938
|
-
gn as m,
|
|
1939
|
-
Dn as n,
|
|
1940
|
-
z as o,
|
|
1941
|
-
it as p,
|
|
1942
|
-
xe as q,
|
|
1943
|
-
qn as r,
|
|
1944
|
-
to as s,
|
|
1945
|
-
Me as t,
|
|
1946
|
-
Cr as u,
|
|
1947
|
-
Yt as v,
|
|
1948
|
-
ht as w,
|
|
1949
|
-
_n as x,
|
|
1950
|
-
C as y,
|
|
1951
|
-
Zn as z
|
|
1952
|
-
};
|