@agile-team/mach-report 2.13.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 +20 -7
- package/THIRD_PARTY_NOTICES.md +3 -1
- package/dist/ExcelBindingWizard-BKH1nGNS.js +1485 -0
- package/dist/ExcelBindingWizard-Bs43BGNp.cjs +1 -0
- package/dist/ParamEditor-Da4akw6V.cjs +1 -0
- package/dist/ParamEditor-DoAhzJsm.js +594 -0
- package/dist/{ReportBatchPanel-CW2HV9I8.js → ReportBatchPanel-BMf6boMA.js} +39 -39
- package/dist/ReportBatchPanel-wP9m9Pj1.cjs +1 -0
- package/dist/ReportPreview-ChV19HBp.js +4619 -0
- package/dist/ReportPreview-DbLvvOUT.cjs +6 -0
- package/dist/{ReportTemplateLibrary-BZB-XWjj.js → ReportTemplateLibrary-C9wutIiT.js} +1 -1
- package/dist/ReportTemplateLibrary-Sxr3eD0J.cjs +1 -0
- package/dist/RuleEditor-C_Clasvd.js +2037 -0
- package/dist/RuleEditor-XhGHK8DE.cjs +1 -0
- package/dist/TemplateOutlinePanel-D6Bkny59.js +96 -0
- package/dist/TemplateOutlinePanel-JTSR53vJ.cjs +1 -0
- package/dist/TemplateReusePanel-Kx35S0Ql.cjs +1 -0
- package/dist/TemplateReusePanel-rVuK1kTz.js +388 -0
- package/dist/TemplateReviewPanel-B0ar9_zf.js +592 -0
- package/dist/TemplateReviewPanel-Dn6X9UmY.cjs +1 -0
- 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 -2
- package/dist/designer.d.cts +432 -17
- package/dist/designer.d.ts +432 -17
- package/dist/designer.js +21 -4312
- package/dist/drill-ByJviLXS.js +145 -0
- package/dist/drill-DYTxuL3A.cjs +1 -0
- package/dist/font-loader-B_UkxpzC.cjs +1 -0
- package/dist/font-loader-Q3bQjmrI.js +297 -0
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +239 -5
- package/dist/index.d.ts +239 -5
- package/dist/index.js +939 -893
- 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-BwNyeGpt.js +36352 -0
- package/dist/pdf-CvvrjPQg.cjs +103 -0
- package/dist/pdf.cjs +1 -101
- package/dist/pdf.d.cts +18 -3
- package/dist/pdf.d.ts +18 -3
- package/dist/pdf.js +9 -36579
- package/dist/plugin-Ca_XZG3l.js +22 -0
- package/dist/{plugin-DzS6pxTA.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-D-5jQlTj.js → record-bindings-Do_b3h4V.js} +1 -1
- package/dist/{region-binding-workflow-CcUq8W2Q.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 +66 -12
- package/dist/server/node.d.ts +66 -12
- package/dist/server-node.cjs +1 -1
- package/dist/server-node.js +405 -381
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +878 -15
- package/dist/server.d.ts +878 -15
- package/dist/server.js +1034 -534
- 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-BGbQLGlV.js +187 -0
- package/dist/template-fragments-DcKeiylI.cjs +1 -0
- package/dist/template-outline-BwRV_eRo.cjs +1 -0
- package/dist/template-outline-cnWfT_LK.js +88 -0
- package/dist/{template-registry-BjE1VS6g.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/{useLocalDraft-C07SYRnC.js → useLocalDraft-BnhcxXk_.js} +1 -1
- package/dist/{useLocalDraft-Yiw1wFgI.cjs → useLocalDraft-CioIfDb6.cjs} +1 -1
- package/dist/vue/async.d.cts +190 -15
- package/dist/vue/async.d.ts +190 -15
- package/dist/vue/index.d.cts +274 -24
- package/dist/vue/index.d.ts +274 -24
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +5 -5
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +90 -81
- package/dist/{workbook-session-DNa2RHNG.cjs → workbook-session-Bjv1YCRK.cjs} +18 -18
- package/dist/{workbook-session-BPb3TMnT.js → workbook-session-BvToI-Fd.js} +5440 -5288
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +66 -12
- package/dist/worker.d.ts +66 -12
- package/dist/worker.js +61 -56
- 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/ExcelBindingWizard-CeAf4QSE.js +0 -1465
- package/dist/ExcelBindingWizard-y0mT-AHR.cjs +0 -1
- package/dist/ParamEditor-BLaE5q5W.js +0 -522
- package/dist/ParamEditor-MBBC7lUE.cjs +0 -1
- package/dist/ReportBatchPanel-Fp1ePFag.cjs +0 -1
- package/dist/ReportPreview-BN6fk7Wz.cjs +0 -6
- package/dist/ReportPreview-D2Jkyh1U.js +0 -4243
- package/dist/ReportTemplateLibrary-5fk5CQBO.cjs +0 -1
- package/dist/RuleEditor-ChRzNQuF.cjs +0 -1
- package/dist/RuleEditor-DzAmW5YH.js +0 -2024
- package/dist/TemplateReviewPanel-BKofGrV9.js +0 -222
- package/dist/TemplateReviewPanel-DwtOcLue.cjs +0 -1
- package/dist/assets-C2U-e-Sz.cjs +0 -4
- package/dist/assets-Q0wUwNrV.js +0 -217
- package/dist/batch-Bt3Fd27Z.cjs +0 -1
- package/dist/batch-mRqhhhjt.js +0 -364
- package/dist/capabilities-CK_7hizc.js +0 -63
- package/dist/capabilities-CsZ-pNHR.cjs +0 -1
- package/dist/config-Bb7RiIO5.cjs +0 -1
- package/dist/config-XVwG87IA.js +0 -529
- 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/plugin-D4wizDXB.js +0 -22
- 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-registry-D3SjENi6.cjs +0 -1
- package/dist/template-review-DGwWOoCv.cjs +0 -2
- package/dist/template-review-PgEe_Wr9.js +0 -1742
- package/dist/validate-BJ5HIWY8.cjs +0 -1
- package/dist/validate-DbgEM1Hh.js +0 -163
package/dist/index.js
CHANGED
|
@@ -1,28 +1,36 @@
|
|
|
1
|
-
import { D as
|
|
2
|
-
import { b as
|
|
3
|
-
import { R as
|
|
4
|
-
import { a as
|
|
5
|
-
import { C as
|
|
6
|
-
import { i as
|
|
7
|
-
import { R as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { r as
|
|
16
|
-
import { r as
|
|
17
|
-
import { r as
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
|
|
1
|
+
import { D as te, a as Te } from "./defaults-DXhiM1ZD.js";
|
|
2
|
+
import { b as Yn, c as Kn, d as Jn, L as Xn, S as Zn } from "./defaults-DXhiM1ZD.js";
|
|
3
|
+
import { R as er, e as tr, f as nr, p as rr, b as ar, t as ir, d as or } from "./record-bindings-Do_b3h4V.js";
|
|
4
|
+
import { a as j, r as _, b as ne, c as G, d as Ce, m as se, e as Re, p as W, f as Pe, P as Z } from "./style-CQ1PK8ZB.js";
|
|
5
|
+
import { C as lr, M as cr, g as mr, h as dr } from "./style-CQ1PK8ZB.js";
|
|
6
|
+
import { i as re, a as Ae } from "./render-plan-Ck6koX9L.js";
|
|
7
|
+
import { R as gr } from "./render-plan-Ck6koX9L.js";
|
|
8
|
+
import { v as $e, R as ke, p as U, a as Je } from "./template-registry-BtaKPELV.js";
|
|
9
|
+
import { b as ur, c as pr, d as wr, e as br, s as Mr, f as yr, g as vr, h as xr } from "./template-registry-BtaKPELV.js";
|
|
10
|
+
import { v as Xe } from "./dataset-H5pFuQGU.js";
|
|
11
|
+
import { d as Sr } from "./dataset-H5pFuQGU.js";
|
|
12
|
+
import { h as le, w as Ie } from "./textwrap-DE1kgcJB.js";
|
|
13
|
+
import { c as Cr, a as Rr, b as Pr, m as Ar } from "./textwrap-DE1kgcJB.js";
|
|
14
|
+
import { R as ce, d as Ze, s as Qe } from "./json-snapshot-DFb2eWkf.js";
|
|
15
|
+
import { D as kr, P as Ir, a as Nr, b as Lr, c as Dr, e as Fr, f as Or, g as Hr, h as zr, i as Wr, p as Br, j as jr, k as _r, r as Ur, l as Gr } from "./json-snapshot-DFb2eWkf.js";
|
|
16
|
+
import { r as Ne } from "./grid-geometry-BNptEcMm.js";
|
|
17
|
+
import { r as Le } from "./grid-strokes-DyyG1q_o.js";
|
|
18
|
+
import { r as q, n as De, O as et } from "./capabilities-DskCHs3V.js";
|
|
19
|
+
import { i as qr } from "./capabilities-DskCHs3V.js";
|
|
20
|
+
import { o as tt } from "./progress-D-OTpEav.js";
|
|
21
|
+
import { r as me } from "./assets-DEaz4qsp.js";
|
|
22
|
+
import { O as Kr } from "./assets-DEaz4qsp.js";
|
|
23
|
+
import { c as nt } from "./drill-ByJviLXS.js";
|
|
24
|
+
import { R as Xr, a as Zr, m as Qr, r as ea, v as ta } from "./drill-ByJviLXS.js";
|
|
25
|
+
import { R as ra, a as aa, f as ia, i as oa, b as sa, c as la, p as ca, r as ma, v as da, d as ha } from "./param-validation-Do7Eg8Zv.js";
|
|
26
|
+
import { c as fa, a as ua, d as pa, r as wa, b as ba } from "./template-catalog-j2B1MJlL.js";
|
|
27
|
+
import { h as ya, i as va, a as xa } from "./data-explanation-B8MZRYVS.js";
|
|
28
|
+
import { c as Sa, i as Ta, t as Ca } from "./template-outline-cnWfT_LK.js";
|
|
29
|
+
import { a as Pa, c as Aa, i as $a, b as ka } from "./template-fragments-BGbQLGlV.js";
|
|
30
|
+
import { R as rt, p as at } from "./batch-CGyt-b2W.js";
|
|
31
|
+
import { a as Na, b as La, c as Da, d as Fa, e as Oa, f as Ha, g as za, r as Wa, s as Ba } from "./batch-CGyt-b2W.js";
|
|
32
|
+
import { T as _a, c as Ua, v as Ga } from "./tree-CjVZLRw7.js";
|
|
33
|
+
const it = {
|
|
26
34
|
root: "mr-root",
|
|
27
35
|
page: "mr-page",
|
|
28
36
|
comp: "mr-comp",
|
|
@@ -39,18 +47,18 @@ const Qe = {
|
|
|
39
47
|
cell: "mr-cell",
|
|
40
48
|
unknown: "mr-unknown"
|
|
41
49
|
};
|
|
42
|
-
function
|
|
43
|
-
return t?.classNames?.[e] ??
|
|
50
|
+
function T(e, t) {
|
|
51
|
+
return t?.classNames?.[e] ?? it[e];
|
|
44
52
|
}
|
|
45
|
-
class
|
|
53
|
+
class ot {
|
|
46
54
|
constructor() {
|
|
47
55
|
this.props = [];
|
|
48
56
|
}
|
|
49
57
|
add(t, n) {
|
|
50
58
|
return n == null || n === !1 || n === "" ? this : (this.props.push([t, String(n)]), this);
|
|
51
59
|
}
|
|
52
|
-
mm(t, n, r,
|
|
53
|
-
return this.add(t, `${
|
|
60
|
+
mm(t, n, r, a = 2) {
|
|
61
|
+
return this.add(t, `${j(se(n, r), a)}px`);
|
|
54
62
|
}
|
|
55
63
|
toString() {
|
|
56
64
|
let t = "";
|
|
@@ -64,521 +72,521 @@ class et {
|
|
|
64
72
|
}
|
|
65
73
|
}
|
|
66
74
|
function y(e, t = "unset") {
|
|
67
|
-
return new
|
|
75
|
+
return new ot().add("all", t).add("display", e).add("box-sizing", "border-box");
|
|
68
76
|
}
|
|
69
|
-
function
|
|
70
|
-
e.add("color", t.color).add("font-family", t.fontFamily).add("font-weight", t.bold != null ? t.bold ? "700" : "400" : void 0).add("font-style", t.italic != null ? t.italic ? "italic" : "normal" : void 0).add("text-decoration", t.underline != null ? t.underline ? "underline" : "none" : void 0).add("letter-spacing", t.letterSpacing != null ? `${t.letterSpacing}pt` : void 0).add("line-height", String(
|
|
77
|
+
function Fe(e, t, n) {
|
|
78
|
+
e.add("color", t.color).add("font-family", t.fontFamily).add("font-weight", t.bold != null ? t.bold ? "700" : "400" : void 0).add("font-style", t.italic != null ? t.italic ? "italic" : "normal" : void 0).add("text-decoration", t.underline != null ? t.underline ? "underline" : "none" : void 0).add("letter-spacing", t.letterSpacing != null ? `${t.letterSpacing}pt` : void 0).add("line-height", String(ne(t))).add("text-align", t.align);
|
|
71
79
|
const r = _(t, n);
|
|
72
|
-
e.add("font-size", `${
|
|
80
|
+
e.add("font-size", `${j(r.fontSizePx, 2)}px`);
|
|
73
81
|
}
|
|
74
|
-
function
|
|
82
|
+
function st(e, t, n) {
|
|
75
83
|
const r = t.style ?? {};
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
function
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
for (const
|
|
86
|
-
return
|
|
87
|
-
}
|
|
88
|
-
function
|
|
89
|
-
return
|
|
90
|
-
const o = `${
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
return y("block").add("position", "absolute").add("pointer-events", "none").mm("left",
|
|
84
|
+
Fe(e, r, n), e.add("background-color", r.backgroundColor).add("opacity", r.opacity != null ? String(r.opacity) : void 0).add("transform", r.rotateDeg ? `rotate(${r.rotateDeg}deg)` : void 0);
|
|
85
|
+
}
|
|
86
|
+
function lt(e, t, n, r, a, o) {
|
|
87
|
+
const l = e.cell, i = o.createElement("td");
|
|
88
|
+
i.className = T("cell", a), i.dataset.mrRowIndex = String(e.ri), i.dataset.mrColumnIndex = String(e.ci), i.setAttribute("role", t.table?.role === "header" ? "columnheader" : "cell"), l.colSpan && (i.colSpan = l.colSpan), l.rowSpan && (i.rowSpan = l.rowSpan);
|
|
89
|
+
const s = Re(t.style, l.style), c = y("block").add("position", "absolute").mm("left", e.xMm, r).mm("top", e.yMm, r).mm("width", e.widthMm, r).mm("height", e.heightMm, r).add("background-color", s.backgroundColor).add("vertical-align", s.verticalAlign ?? "middle");
|
|
90
|
+
Fe(c, s, r), c.applyTo(i);
|
|
91
|
+
const m = o.createElement("div");
|
|
92
|
+
m.className = "mr-cell-content", y("flex").add("position", "absolute").mm("left", n + (l.indentMm ?? 0), r).mm("right", n, r).mm("top", n, r).mm("bottom", n, r).add("flex-direction", "column").add("justify-content", s.verticalAlign === "top" ? "flex-start" : s.verticalAlign === "bottom" ? "flex-end" : "center").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(m), l.text != null && m.append(l.text);
|
|
93
|
+
for (const d of l.children ?? []) m.appendChild(Oe(d, r, a, o));
|
|
94
|
+
return i.appendChild(m), i;
|
|
95
|
+
}
|
|
96
|
+
function ct(e, t, n, r) {
|
|
97
|
+
return Le(e, t).map((a) => {
|
|
98
|
+
const o = `${j(a.widthPt * n / 72, 2)}px solid ${a.color}`, l = r.createElement("div");
|
|
99
|
+
l.className = "mr-grid-edge", l.setAttribute("aria-hidden", "true");
|
|
100
|
+
const i = a.kind === "h";
|
|
101
|
+
return y("block").add("position", "absolute").add("pointer-events", "none").mm("left", i ? a.from : a.pos, n).mm("top", i ? a.pos : a.from, n).mm("width", i ? a.to - a.from : 0, n).mm("height", i ? 0 : a.to - a.from, n).add(i ? "border-top" : "border-left", o).applyTo(l), l;
|
|
94
102
|
});
|
|
95
103
|
}
|
|
96
|
-
function
|
|
97
|
-
const o =
|
|
98
|
-
o.className =
|
|
99
|
-
const
|
|
100
|
-
y("contents").applyTo(
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
return
|
|
104
|
+
function mt(e, t, n, r, a) {
|
|
105
|
+
const o = a.createElement("table");
|
|
106
|
+
o.className = T("grid", r), o.setAttribute("role", "table"), y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(o);
|
|
107
|
+
const l = Ne(e, t.widthMm, t.heightMm), i = a.createElement("tbody");
|
|
108
|
+
y("contents").applyTo(i), o.appendChild(i);
|
|
109
|
+
const s = e.cells.map(() => {
|
|
110
|
+
const m = a.createElement("tr");
|
|
111
|
+
return m.className = T("row", r), m.setAttribute("role", "row"), y("contents").applyTo(m), i.appendChild(m), m;
|
|
104
112
|
});
|
|
105
|
-
for (const
|
|
106
|
-
|
|
107
|
-
const c =
|
|
108
|
-
return y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(o, ...
|
|
109
|
-
}
|
|
110
|
-
function
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
+
for (const m of l.cells)
|
|
114
|
+
s[m.ri].appendChild(lt(m, t, e.paddingMm ?? 0.5, n, r, a));
|
|
115
|
+
const c = a.createElement("div");
|
|
116
|
+
return y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(o, ...ct(l, t, n, a)), c;
|
|
117
|
+
}
|
|
118
|
+
function dt(e, t, n, r) {
|
|
119
|
+
const a = r.createElement("div");
|
|
120
|
+
a.className = T("paragraph", n), y("block").add("text-align", e.align).add("line-height", e.lineHeight != null ? String(e.lineHeight) : void 0).mm("margin-top", e.spaceBeforeMm ?? 0, t).mm("margin-bottom", e.spaceAfterMm ?? 0, t).mm("text-indent", e.indentMm ?? 0, t).applyTo(a);
|
|
113
121
|
for (const o of e.segments || []) {
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
const
|
|
122
|
+
const l = r.createElement("span");
|
|
123
|
+
l.className = T("segment", n), l.textContent = o.kind === "field" ? o.field ?? "" : o.text ?? "";
|
|
124
|
+
const i = y("inline");
|
|
117
125
|
if (o.style) {
|
|
118
|
-
const
|
|
119
|
-
|
|
126
|
+
const s = o.style;
|
|
127
|
+
i.add("color", s.color).add("font-family", s.fontFamily).add("font-weight", s.bold != null ? s.bold ? "700" : "400" : void 0).add("font-style", s.italic != null ? s.italic ? "italic" : "normal" : void 0).add("text-decoration", s.underline != null ? s.underline ? "underline" : "none" : void 0), (s.fontSize != null || s.fontSizePx != null) && i.add("font-size", `${j(_(s, t).fontSizePx, 2)}px`);
|
|
120
128
|
}
|
|
121
|
-
|
|
129
|
+
i.applyTo(l), a.appendChild(l);
|
|
122
130
|
}
|
|
123
|
-
return
|
|
124
|
-
}
|
|
125
|
-
function
|
|
126
|
-
if (
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
for (const o of e.richParagraphs)
|
|
130
|
-
return
|
|
131
|
+
return a;
|
|
132
|
+
}
|
|
133
|
+
function ht(e, t, n, r) {
|
|
134
|
+
if (Ae(e)) {
|
|
135
|
+
const a = r.createElement("div");
|
|
136
|
+
a.className = T("rich", n), y("block").applyTo(a);
|
|
137
|
+
for (const o of e.richParagraphs) a.appendChild(dt(o, t, n, r));
|
|
138
|
+
return a;
|
|
131
139
|
}
|
|
132
140
|
if (Array.isArray(e.lines) && e.lines.length > 0) {
|
|
133
|
-
const
|
|
134
|
-
|
|
141
|
+
const a = r.createElement("div");
|
|
142
|
+
a.className = T("lines", n), y("block").applyTo(a);
|
|
135
143
|
for (const o of e.lines) {
|
|
136
|
-
const
|
|
137
|
-
|
|
144
|
+
const l = r.createElement("div");
|
|
145
|
+
l.className = T("line", n), l.textContent = o, y("block").add("white-space", "pre").add("min-height", "1lh").applyTo(l), a.appendChild(l);
|
|
138
146
|
}
|
|
139
|
-
return
|
|
147
|
+
return a;
|
|
140
148
|
}
|
|
141
149
|
return e.text ?? "";
|
|
142
150
|
}
|
|
143
|
-
function
|
|
144
|
-
const
|
|
145
|
-
|
|
151
|
+
function gt(e, t, n, r) {
|
|
152
|
+
const a = r.createElement("div");
|
|
153
|
+
a.className = T("text", n);
|
|
146
154
|
const o = e.style || {};
|
|
147
|
-
return y("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", o.verticalAlign === "middle" ? "center" : o.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(
|
|
155
|
+
return y("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", o.verticalAlign === "middle" ? "center" : o.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(a), a.append(ht(e, t, n, r)), a;
|
|
148
156
|
}
|
|
149
|
-
function
|
|
157
|
+
function ft(e, t, n) {
|
|
150
158
|
const r = n.createElement("img");
|
|
151
|
-
return r.className =
|
|
152
|
-
}
|
|
153
|
-
function
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
const o = e.style || {},
|
|
157
|
-
return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (
|
|
158
|
-
}
|
|
159
|
-
function
|
|
160
|
-
const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"),
|
|
161
|
-
r.setAttribute("width", String(Math.max(1,
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
return
|
|
166
|
-
}
|
|
167
|
-
function
|
|
168
|
-
const
|
|
169
|
-
|
|
159
|
+
return r.className = T("image", t), r.src = e.imageData, y("block").add("width", "100%").add("height", "100%").add("object-fit", "contain").applyTo(r), r.alt = e.kind, r;
|
|
160
|
+
}
|
|
161
|
+
function be(e, t, n, r) {
|
|
162
|
+
const a = r.createElement("div");
|
|
163
|
+
a.className = T("shape", n);
|
|
164
|
+
const o = e.style || {}, l = G(o), i = Ce(o), s = `${j(l.widthPt * t / 72, 2)}px solid ${l.color}`, c = y("block");
|
|
165
|
+
return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (i.top && c.add("border-top", s), i.right && c.add("border-right", s), i.bottom && c.add("border-bottom", s), i.left && c.add("border-left", s)) : e.kind === "ellipse" ? (i.inner && c.add("border", s).add("border-radius", "50%"), o.backgroundColor && c.add("background-color", o.backgroundColor)) : e.kind === "line" && c.add("height", "0").add("border-top", s), c.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), c.applyTo(a), a;
|
|
166
|
+
}
|
|
167
|
+
function ut(e, t, n) {
|
|
168
|
+
const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), a = se(e.widthMm, t), o = se(e.heightMm, t);
|
|
169
|
+
r.setAttribute("width", String(Math.max(1, a))), r.setAttribute("height", String(Math.max(1, o))), r.setAttribute("aria-hidden", "true"), r.style.overflow = "visible", r.style.display = "block";
|
|
170
|
+
const l = n.createElementNS("http://www.w3.org/2000/svg", "line");
|
|
171
|
+
l.setAttribute("x1", "0"), l.setAttribute("x2", String(a)), l.setAttribute("y1", e.lineDirection === "up" ? String(o) : "0"), l.setAttribute("y2", e.lineDirection === "up" ? "0" : String(o));
|
|
172
|
+
const i = G({ ...e.style, borderColor: e.style?.lineColor ?? e.style?.borderColor });
|
|
173
|
+
return l.setAttribute("stroke", i.color), l.setAttribute("stroke-width", String(i.widthPt * t / 72)), r.appendChild(l), r;
|
|
174
|
+
}
|
|
175
|
+
function Oe(e, t, n, r) {
|
|
176
|
+
const a = r.createElement("div");
|
|
177
|
+
a.className = `${T("comp", n)} mr-kind-${e.kind}`;
|
|
170
178
|
const o = y("block").add("position", "absolute").mm("left", e.leftMm, t).mm("top", e.topMm, t).mm("width", e.widthMm, t).mm("height", e.heightMm, t).add("box-sizing", "border-box");
|
|
171
|
-
if (
|
|
172
|
-
return
|
|
179
|
+
if (st(o, e, t), o.applyTo(a), re(e))
|
|
180
|
+
return a.appendChild(ft(e, n, r)), a;
|
|
173
181
|
if (e.kind === "text")
|
|
174
|
-
return
|
|
182
|
+
return a.appendChild(gt(e, t, n, r)), a;
|
|
175
183
|
if (e.grid) {
|
|
176
|
-
const
|
|
177
|
-
return
|
|
184
|
+
const i = be(e, t, n, r);
|
|
185
|
+
return i.appendChild(mt(e.grid, e, t, n, r)), a.appendChild(i), a;
|
|
178
186
|
}
|
|
179
187
|
if (e.kind === "line" && e.lineDirection)
|
|
180
|
-
return
|
|
188
|
+
return a.appendChild(ut(e, t, r)), a;
|
|
181
189
|
if (e.kind === "line" || e.kind === "rect" || e.kind === "ellipse")
|
|
182
|
-
return
|
|
183
|
-
const
|
|
184
|
-
return
|
|
185
|
-
}
|
|
186
|
-
function
|
|
187
|
-
const
|
|
188
|
-
return
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
}),
|
|
192
|
-
}
|
|
193
|
-
function
|
|
190
|
+
return a.appendChild(be(e, t, n, r)), a;
|
|
191
|
+
const l = r.createElement("div");
|
|
192
|
+
return l.className = T("unknown", n), y("block").applyTo(l), l.textContent = e.fallbackText ?? `[${e.kind}]`, l.dataset.mrUnsupported = e.kind, l.setAttribute("role", "note"), a.appendChild(l), a;
|
|
193
|
+
}
|
|
194
|
+
function pt(e, t, n, r) {
|
|
195
|
+
const a = r.createElement("div");
|
|
196
|
+
return a.className = T("page", n), y("block", "initial").add("position", "relative").add("font-family", te).add("font-size", `${j(_(void 0, t).fontSizePx, 2)}px`).add("line-height", String(ne(void 0))).add("white-space", "pre-wrap").add("direction", "ltr").mm("width", e.pageWidthMm, t).mm("height", e.pageHeightMm, t).add("background-color", "#fff").add("color", Te).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(a), e.components.forEach((o, l) => {
|
|
197
|
+
const i = Oe(o, t, n, r);
|
|
198
|
+
i.dataset.mrComponentIndex = String(l), a.appendChild(i);
|
|
199
|
+
}), a;
|
|
200
|
+
}
|
|
201
|
+
function Rn(e, t, n = {}) {
|
|
194
202
|
const r = n.dpi ?? 96;
|
|
195
|
-
|
|
196
|
-
const
|
|
197
|
-
return
|
|
198
|
-
|
|
199
|
-
}),
|
|
203
|
+
q(e, "dom", n);
|
|
204
|
+
const a = t.createElement("div");
|
|
205
|
+
return a.className = T("root", n), y("block").applyTo(a), a.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((o) => {
|
|
206
|
+
a.appendChild(pt(o, r, n, t));
|
|
207
|
+
}), a;
|
|
200
208
|
}
|
|
201
|
-
function
|
|
209
|
+
function $(e) {
|
|
202
210
|
if (e?.aborted) throw e.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
203
211
|
}
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
},
|
|
208
|
-
o(),
|
|
212
|
+
const wt = (e, t) => ($(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e) ? new Promise((n, r) => {
|
|
213
|
+
const a = new Image(), o = () => {
|
|
214
|
+
a.onload = null, a.onerror = null, t?.removeEventListener("abort", l);
|
|
215
|
+
}, l = () => {
|
|
216
|
+
o(), a.src = "", r(t?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
209
217
|
};
|
|
210
|
-
|
|
211
|
-
o(), n(
|
|
212
|
-
},
|
|
218
|
+
a.onload = () => {
|
|
219
|
+
o(), n(a);
|
|
220
|
+
}, a.onerror = () => {
|
|
213
221
|
o(), r(new Error("Image could not be decoded for Canvas output."));
|
|
214
|
-
}, t?.addEventListener("abort",
|
|
222
|
+
}, t?.addEventListener("abort", l, { once: !0 }), a.src = e;
|
|
215
223
|
}) : Promise.reject(new TypeError("Canvas imageData must be an image data URL; provide imageLoader for other sources.")));
|
|
216
|
-
function
|
|
217
|
-
return
|
|
218
|
-
const o = () =>
|
|
219
|
-
n.addEventListener("abort", o, { once: !0 }), Promise.resolve().then(() => e(t, n)).then(r,
|
|
224
|
+
function bt(e, t, n) {
|
|
225
|
+
return $(n), n ? new Promise((r, a) => {
|
|
226
|
+
const o = () => a(n.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
227
|
+
n.addEventListener("abort", o, { once: !0 }), Promise.resolve().then(() => e(t, n)).then(r, a).finally(() => n.removeEventListener("abort", o));
|
|
220
228
|
}) : e(t);
|
|
221
229
|
}
|
|
222
|
-
async function
|
|
230
|
+
async function Mt(e, t, n) {
|
|
223
231
|
const r = /* @__PURE__ */ new Map();
|
|
224
|
-
for (const
|
|
225
|
-
!
|
|
226
|
-
return
|
|
227
|
-
}
|
|
228
|
-
function
|
|
229
|
-
const
|
|
230
|
-
if (
|
|
231
|
-
const c = Math.min(
|
|
232
|
-
e.drawImage(t, n + (
|
|
233
|
-
}
|
|
234
|
-
function
|
|
235
|
-
return
|
|
236
|
-
}
|
|
237
|
-
const
|
|
238
|
-
function
|
|
239
|
-
const n = t / 96 *
|
|
232
|
+
for (const a of e.components)
|
|
233
|
+
!re(a) || r.has(a.imageData) || r.set(a.imageData, await bt(t, a.imageData, n));
|
|
234
|
+
return $(n), r;
|
|
235
|
+
}
|
|
236
|
+
function yt(e, t, n, r, a, o) {
|
|
237
|
+
const l = t, i = l.naturalWidth ?? l.width ?? a, s = l.naturalHeight ?? l.height ?? o;
|
|
238
|
+
if (i <= 0 || s <= 0) throw new RangeError("Decoded Canvas image dimensions must be positive.");
|
|
239
|
+
const c = Math.min(a / i, o / s), m = i * c, d = s * c;
|
|
240
|
+
e.drawImage(t, n + (a - m) / 2, r + (o - d) / 2, m, d);
|
|
241
|
+
}
|
|
242
|
+
function vt(e) {
|
|
243
|
+
return nt(e.pageHeightsPx, e.gapPx).window(e.viewportHeightPx, e.scrollTopPx, e.overscan);
|
|
244
|
+
}
|
|
245
|
+
const de = 96 / 25.4;
|
|
246
|
+
function he(e, t = 96) {
|
|
247
|
+
const n = t / 96 * de;
|
|
240
248
|
return {
|
|
241
249
|
widthPx: Math.max(1, Math.round(e.pageWidthMm * n)),
|
|
242
250
|
heightPx: Math.max(1, Math.round(e.pageHeightMm * n))
|
|
243
251
|
};
|
|
244
252
|
}
|
|
245
|
-
function
|
|
253
|
+
function He(e, t, n, r = 64e6) {
|
|
246
254
|
if (!Number.isFinite(t) || t <= 0 || !Number.isFinite(n) || n <= 0) throw new RangeError("Canvas dpr and dpi must be positive finite numbers.");
|
|
247
255
|
if (!Number.isFinite(r) || r <= 0) throw new RangeError("maxCanvasPixels must be positive and finite.");
|
|
248
|
-
const
|
|
249
|
-
if (!Number.isSafeInteger(o) || !Number.isSafeInteger(
|
|
250
|
-
return { width: o, height:
|
|
251
|
-
}
|
|
252
|
-
function
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
if (!
|
|
256
|
+
const a = he(e, n), o = Math.round(a.widthPx * t), l = Math.round(a.heightPx * t);
|
|
257
|
+
if (!Number.isSafeInteger(o) || !Number.isSafeInteger(l) || o * l > r) throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");
|
|
258
|
+
return { width: o, height: l };
|
|
259
|
+
}
|
|
260
|
+
function ze(e, t, n, r) {
|
|
261
|
+
const a = document.createElement("canvas"), { widthPx: o, heightPx: l } = he(e, n), i = He(e, t, n, r);
|
|
262
|
+
a.width = i.width, a.height = i.height, a.style.width = `${o}px`, a.style.height = `${l}px`;
|
|
263
|
+
const s = a.getContext("2d");
|
|
264
|
+
if (!s)
|
|
257
265
|
throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
|
|
258
|
-
return
|
|
266
|
+
return s.scale(t, t), s.fillStyle = "#ffffff", s.fillRect(0, 0, o, l), { canvas: a, ctx: s };
|
|
259
267
|
}
|
|
260
|
-
function
|
|
268
|
+
function Pn(e, t = 96) {
|
|
261
269
|
return _(e, t).fontSizePx;
|
|
262
270
|
}
|
|
263
|
-
function
|
|
264
|
-
e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSizePx}px ${
|
|
265
|
-
const
|
|
266
|
-
`),
|
|
267
|
-
let
|
|
268
|
-
|
|
269
|
-
|
|
271
|
+
function We(e, t, n, r, a, o, l, i = "top") {
|
|
272
|
+
e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSizePx}px ${l}`, "letterSpacing" in e && (e.letterSpacing = "0px"), e.fillStyle = t.color, e.textBaseline = "alphabetic";
|
|
273
|
+
const s = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
|
|
274
|
+
`), m = c.length * s;
|
|
275
|
+
let d = r;
|
|
276
|
+
i === "middle" ? d = r + (o - m) / 2 : i === "bottom" && (d = r + o - m), c.forEach((h, g) => {
|
|
277
|
+
xt(e, h, t, n, d + g * s + t.fontSizePx * 0.8, a);
|
|
270
278
|
}), e.textAlign = "left";
|
|
271
279
|
}
|
|
272
|
-
function
|
|
273
|
-
const
|
|
274
|
-
if (!
|
|
280
|
+
function xt(e, t, n, r, a, o) {
|
|
281
|
+
const l = Array.from(t), i = n.letterSpacingPx ?? 0;
|
|
282
|
+
if (!i) {
|
|
275
283
|
e.textAlign = n.align === "center" ? "center" : n.align === "right" ? "right" : "left";
|
|
276
|
-
const
|
|
277
|
-
e.fillText(t,
|
|
284
|
+
const d = n.align === "center" ? r + o / 2 : n.align === "right" ? r + o : r;
|
|
285
|
+
e.fillText(t, d, a);
|
|
278
286
|
return;
|
|
279
287
|
}
|
|
280
|
-
const
|
|
288
|
+
const s = e.measureText(t).width + Math.max(0, l.length - 1) * i, c = n.align === "center" ? r + (o - s) / 2 : n.align === "right" ? r + o - s : r;
|
|
281
289
|
e.textAlign = "left";
|
|
282
|
-
let
|
|
283
|
-
|
|
284
|
-
e.fillText(
|
|
290
|
+
let m = "";
|
|
291
|
+
l.forEach((d, h) => {
|
|
292
|
+
e.fillText(d, c + e.measureText(m).width + h * i, a), m += d;
|
|
285
293
|
});
|
|
286
294
|
}
|
|
287
|
-
function
|
|
288
|
-
for (const
|
|
289
|
-
e.strokeStyle =
|
|
295
|
+
function Et(e, t, n, r, a, o, l) {
|
|
296
|
+
for (const i of Le(t, n))
|
|
297
|
+
e.strokeStyle = i.color, e.lineWidth = W(i.widthPt, l), e.beginPath(), i.kind === "v" ? (e.moveTo(r + i.pos * o, a + i.from * o), e.lineTo(r + i.pos * o, a + i.to * o)) : (e.moveTo(r + i.from * o, a + i.pos * o), e.lineTo(r + i.to * o, a + i.pos * o)), e.stroke();
|
|
290
298
|
}
|
|
291
|
-
function
|
|
292
|
-
e.beginPath(), t.top && (e.moveTo(n, r), e.lineTo(n +
|
|
299
|
+
function St(e, t, n, r, a, o) {
|
|
300
|
+
e.beginPath(), t.top && (e.moveTo(n, r), e.lineTo(n + a, r)), t.right && (e.moveTo(n + a, r), e.lineTo(n + a, r + o)), t.bottom && (e.moveTo(n + a, r + o), e.lineTo(n, r + o)), t.left && (e.moveTo(n, r + o), e.lineTo(n, r)), e.stroke();
|
|
293
301
|
}
|
|
294
|
-
function
|
|
295
|
-
const
|
|
296
|
-
for (const g of
|
|
302
|
+
function Tt(e, t, n, r, a, o, l, i, s, c, m) {
|
|
303
|
+
const d = Ne(t, o / i, l / i);
|
|
304
|
+
for (const g of d.cells) {
|
|
297
305
|
const f = g.cell.style?.backgroundColor ?? n.style?.backgroundColor;
|
|
298
|
-
f && (e.fillStyle = f, e.fillRect(r + g.xMm *
|
|
306
|
+
f && (e.fillStyle = f, e.fillRect(r + g.xMm * i, a + g.yMm * i, g.widthMm * i, g.heightMm * i));
|
|
299
307
|
}
|
|
300
|
-
|
|
308
|
+
Et(e, d, n, r, a, i, s);
|
|
301
309
|
const h = t.paddingMm ?? 0.5;
|
|
302
|
-
for (const g of
|
|
310
|
+
for (const g of d.cells) {
|
|
303
311
|
const f = g.cell.text ?? "";
|
|
304
312
|
if (!f) continue;
|
|
305
|
-
const
|
|
313
|
+
const w = Re(n.style, g.cell.style), C = _(w, s), x = g.cell.indentMm ?? 0, v = Math.max(0, g.widthMm - 2 * h - x), R = Ie(f, v, { fontSizePt: C.fontSizePt, bold: w.bold, italic: w.italic, fontFamily: w.fontFamily ?? c, letterSpacingPt: w.letterSpacing }, m).join(`
|
|
306
314
|
`);
|
|
307
|
-
|
|
315
|
+
We(
|
|
308
316
|
e,
|
|
309
317
|
{
|
|
310
|
-
text:
|
|
311
|
-
fontSizePx:
|
|
312
|
-
bold:
|
|
313
|
-
italic:
|
|
314
|
-
color:
|
|
315
|
-
align:
|
|
316
|
-
lineHeight:
|
|
317
|
-
letterSpacingPx:
|
|
318
|
+
text: R,
|
|
319
|
+
fontSizePx: C.fontSizePx,
|
|
320
|
+
bold: w.bold ?? !1,
|
|
321
|
+
italic: w.italic,
|
|
322
|
+
color: Pe(w, Te),
|
|
323
|
+
align: w.align ?? "left",
|
|
324
|
+
lineHeight: ne(w),
|
|
325
|
+
letterSpacingPx: W(w.letterSpacing ?? 0, s)
|
|
318
326
|
},
|
|
319
|
-
r + (g.xMm + h +
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
Math.max(0, g.heightMm - 2 * h) *
|
|
323
|
-
|
|
324
|
-
|
|
327
|
+
r + (g.xMm + h + x) * i,
|
|
328
|
+
a + (g.yMm + h) * i,
|
|
329
|
+
v * i,
|
|
330
|
+
Math.max(0, g.heightMm - 2 * h) * i,
|
|
331
|
+
w.fontFamily ?? c,
|
|
332
|
+
w.verticalAlign ?? "middle"
|
|
325
333
|
);
|
|
326
334
|
}
|
|
327
335
|
}
|
|
328
|
-
function
|
|
329
|
-
const c = t.style ?? {},
|
|
336
|
+
function Ct(e, t, n, r, a, o, l, i, s) {
|
|
337
|
+
const c = t.style ?? {}, m = _(c, l), d = Ae(t) ? t.richParagraphs.map((h) => h.segments.map((g) => g.text ?? g.field ?? "").join("")).join(`
|
|
330
338
|
`) : t.lines?.length ? t.lines.join(`
|
|
331
|
-
`) :
|
|
339
|
+
`) : Ie(t.text ?? "", t.widthMm, { fontSizePt: m.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? i, letterSpacingPt: c.letterSpacing }, s).join(`
|
|
332
340
|
`);
|
|
333
|
-
|
|
334
|
-
text:
|
|
335
|
-
fontSizePx:
|
|
341
|
+
We(e, {
|
|
342
|
+
text: d,
|
|
343
|
+
fontSizePx: m.fontSizePx,
|
|
336
344
|
bold: c.bold ?? !1,
|
|
337
345
|
italic: c.italic,
|
|
338
|
-
color:
|
|
346
|
+
color: Pe(c),
|
|
339
347
|
align: c.align ?? "left",
|
|
340
|
-
lineHeight:
|
|
341
|
-
letterSpacingPx:
|
|
342
|
-
}, n, r,
|
|
343
|
-
}
|
|
344
|
-
function
|
|
345
|
-
const
|
|
346
|
-
if (
|
|
347
|
-
const h =
|
|
348
|
-
h ?
|
|
348
|
+
lineHeight: ne(c),
|
|
349
|
+
letterSpacingPx: W(c.letterSpacing ?? 0, l)
|
|
350
|
+
}, n, r, a, o, c.fontFamily ?? i, c.verticalAlign);
|
|
351
|
+
}
|
|
352
|
+
function ge(e, t, n, r, a, o, l) {
|
|
353
|
+
const i = t.leftMm * n, s = t.topMm * n, c = t.widthMm * n, m = t.heightMm * n, d = t.style ?? {};
|
|
354
|
+
if (re(t)) {
|
|
355
|
+
const h = l?.get(t.imageData);
|
|
356
|
+
h ? yt(e, h, i, s, c, m) : Me(e, t, i, s, c, m);
|
|
349
357
|
return;
|
|
350
358
|
}
|
|
351
359
|
if (t.grid) {
|
|
352
|
-
|
|
360
|
+
Tt(e, t.grid, t, i, s, c, m, n, r, a, o);
|
|
353
361
|
return;
|
|
354
362
|
}
|
|
355
363
|
switch (t.kind) {
|
|
356
364
|
case "text": {
|
|
357
|
-
|
|
365
|
+
Ct(e, t, i, s, c, m, r, a, o);
|
|
358
366
|
break;
|
|
359
367
|
}
|
|
360
368
|
case "rect": {
|
|
361
|
-
const h =
|
|
362
|
-
|
|
369
|
+
const h = G(d), g = Ce(d);
|
|
370
|
+
d.backgroundColor && (e.fillStyle = d.backgroundColor, e.fillRect(i, s, c, m)), g.inner && (e.strokeStyle = h.color, e.lineWidth = W(h.widthPt, r), St(e, g, i, s, c, m));
|
|
363
371
|
break;
|
|
364
372
|
}
|
|
365
373
|
case "line": {
|
|
366
|
-
const h =
|
|
367
|
-
e.strokeStyle = h.color, e.lineWidth =
|
|
368
|
-
const g = t.lineDirection === "up" ?
|
|
369
|
-
e.moveTo(
|
|
374
|
+
const h = G({ ...d, borderColor: d.lineColor ?? d.borderColor });
|
|
375
|
+
e.strokeStyle = h.color, e.lineWidth = W(h.widthPt, r), e.beginPath();
|
|
376
|
+
const g = t.lineDirection === "up" ? s + m : t.lineDirection === "down" ? s : s + m / 2, f = t.lineDirection === "up" ? s : t.lineDirection === "down" ? s + m : s + m / 2;
|
|
377
|
+
e.moveTo(i, g), e.lineTo(i + c, f), e.stroke();
|
|
370
378
|
break;
|
|
371
379
|
}
|
|
372
380
|
case "ellipse": {
|
|
373
|
-
const h =
|
|
374
|
-
e.strokeStyle = h.color, e.lineWidth =
|
|
381
|
+
const h = G(d);
|
|
382
|
+
e.strokeStyle = h.color, e.lineWidth = W(h.widthPt, r), d.backgroundColor && (e.fillStyle = d.backgroundColor, e.beginPath(), e.ellipse(i + c / 2, s + m / 2, c / 2, m / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(i + c / 2, s + m / 2, c / 2, m / 2, 0, 0, Math.PI * 2), e.stroke();
|
|
375
383
|
break;
|
|
376
384
|
}
|
|
377
385
|
default:
|
|
378
|
-
|
|
386
|
+
Me(e, t, i, s, c, m);
|
|
379
387
|
break;
|
|
380
388
|
}
|
|
381
389
|
}
|
|
382
|
-
function
|
|
383
|
-
e.save(), e.strokeStyle = "#94a3b8", e.strokeRect(n, r,
|
|
390
|
+
function Me(e, t, n, r, a, o) {
|
|
391
|
+
e.save(), e.strokeStyle = "#94a3b8", e.strokeRect(n, r, a, o), e.fillStyle = "#64748b", e.font = "12px sans-serif", e.fillText(t.fallbackText ?? `[${t.kind}]`, n + 3, r + 14), e.restore();
|
|
384
392
|
}
|
|
385
|
-
async function
|
|
393
|
+
async function An(e, t = {}) {
|
|
386
394
|
if (typeof document > "u")
|
|
387
395
|
throw new Error("renderPlanToImages 需要浏览器环境(SSR/Node 请在客户端钩子中调用)");
|
|
388
|
-
const { format: n = "png", quality: r = 0.92, ...
|
|
396
|
+
const { format: n = "png", quality: r = 0.92, ...a } = t;
|
|
389
397
|
if (n !== "png" && n !== "jpeg") throw new TypeError("Image format must be png or jpeg.");
|
|
390
398
|
if (!Number.isFinite(r) || r < 0 || r > 1) throw new RangeError("Image quality must be between 0 and 1.");
|
|
391
|
-
|
|
392
|
-
const o = await
|
|
399
|
+
$(t.signal);
|
|
400
|
+
const o = await me(e, { ...t, format: "canvas" });
|
|
393
401
|
e = o.plan;
|
|
394
|
-
const
|
|
395
|
-
for (let
|
|
396
|
-
|
|
397
|
-
const
|
|
402
|
+
const l = [...o.diagnostics, ...q(e, "canvas", t)], i = n === "jpeg" ? "image/jpeg" : "image/png", s = [], c = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
|
|
403
|
+
for (let m = Math.max(0, t.start ?? 0); m <= c; m++) {
|
|
404
|
+
$(t.signal);
|
|
405
|
+
const d = await Be(e.pages[m], m, a, l);
|
|
398
406
|
try {
|
|
399
|
-
|
|
407
|
+
s.push(await Rt(d, i, r, t.signal));
|
|
400
408
|
} finally {
|
|
401
|
-
|
|
409
|
+
d.width = 0, d.height = 0;
|
|
402
410
|
}
|
|
403
|
-
await
|
|
411
|
+
await tt(t, s.length, c - Math.max(0, t.start ?? 0) + 1);
|
|
404
412
|
}
|
|
405
|
-
return
|
|
413
|
+
return $(t.signal), { blobs: s, diagnostics: l };
|
|
406
414
|
}
|
|
407
|
-
function
|
|
408
|
-
return
|
|
409
|
-
const
|
|
410
|
-
r?.addEventListener("abort",
|
|
415
|
+
function Rt(e, t, n, r) {
|
|
416
|
+
return $(r), new Promise((a, o) => {
|
|
417
|
+
const l = () => o(r?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
418
|
+
r?.addEventListener("abort", l, { once: !0 });
|
|
411
419
|
try {
|
|
412
|
-
e.toBlob((
|
|
413
|
-
r?.removeEventListener("abort",
|
|
420
|
+
e.toBlob((i) => {
|
|
421
|
+
r?.removeEventListener("abort", l), i ? a(i) : o(new Error("Canvas encoding failed; no empty image was emitted."));
|
|
414
422
|
}, t, n);
|
|
415
|
-
} catch (
|
|
416
|
-
r?.removeEventListener("abort",
|
|
423
|
+
} catch (i) {
|
|
424
|
+
r?.removeEventListener("abort", l), o(i);
|
|
417
425
|
}
|
|
418
426
|
});
|
|
419
427
|
}
|
|
420
|
-
function
|
|
421
|
-
if (
|
|
428
|
+
function $n(e, t = {}) {
|
|
429
|
+
if ($(t.signal), typeof document > "u")
|
|
422
430
|
throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");
|
|
423
|
-
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96,
|
|
424
|
-
for (const h of
|
|
425
|
-
|
|
426
|
-
if (t.fidelity === "strict" &&
|
|
427
|
-
for (let h =
|
|
428
|
-
|
|
429
|
-
const g = e.pages[h], { canvas: f, ctx:
|
|
430
|
-
for (const
|
|
431
|
-
|
|
431
|
+
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, a = r / 96 * de, o = t.fontFamily ?? te, l = t.measurer ?? le, i = Math.max(0, t.start ?? 0), s = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [], m = q(e, "canvas", t), d = Pt(e, i, s);
|
|
432
|
+
for (const h of d)
|
|
433
|
+
De(h, t), m.push(h);
|
|
434
|
+
if (t.fidelity === "strict" && d.length) throw new et(m);
|
|
435
|
+
for (let h = i; h <= s; h++) {
|
|
436
|
+
$(t.signal);
|
|
437
|
+
const g = e.pages[h], { canvas: f, ctx: w } = ze(g, n, r, t.maxCanvasPixels);
|
|
438
|
+
for (const C of g.components)
|
|
439
|
+
ge(w, C, a, r, o, l);
|
|
432
440
|
c.push(f);
|
|
433
441
|
}
|
|
434
|
-
return { canvases: c, diagnostics:
|
|
442
|
+
return { canvases: c, diagnostics: m };
|
|
435
443
|
}
|
|
436
|
-
function
|
|
437
|
-
return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r,
|
|
444
|
+
function Pt(e, t, n) {
|
|
445
|
+
return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, a) => r.components.flatMap((o, l) => re(o) ? [{
|
|
438
446
|
code: "async-image-required",
|
|
439
447
|
severity: "warning",
|
|
440
448
|
format: "canvas",
|
|
441
|
-
pageIndex: t +
|
|
442
|
-
componentIndex:
|
|
449
|
+
pageIndex: t + a,
|
|
450
|
+
componentIndex: l,
|
|
443
451
|
kind: o.kind,
|
|
444
452
|
nid: o.nid,
|
|
445
453
|
message: "Use renderPlanToCanvasAsync or renderPlanToImages to decode and include images."
|
|
446
454
|
}] : []));
|
|
447
455
|
}
|
|
448
|
-
async function
|
|
456
|
+
async function kn(e, t = {}) {
|
|
449
457
|
if (typeof document > "u") throw new Error("renderPlanToCanvasAsync 需要浏览器环境(Node 请使用 PDF 或 XLSX 输出)");
|
|
450
|
-
|
|
451
|
-
const n = await
|
|
458
|
+
$(t.signal);
|
|
459
|
+
const n = await me(e, { ...t, format: "canvas" });
|
|
452
460
|
e = n.plan;
|
|
453
|
-
const r = [...n.diagnostics, ...
|
|
454
|
-
for (let
|
|
455
|
-
|
|
456
|
-
return { canvases:
|
|
457
|
-
}
|
|
458
|
-
async function
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
const { canvas:
|
|
462
|
-
for (const
|
|
463
|
-
return
|
|
461
|
+
const r = [...n.diagnostics, ...q(e, "canvas", t)], a = [], o = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
|
|
462
|
+
for (let l = Math.max(0, t.start ?? 0); l <= o; l++)
|
|
463
|
+
a.push(await Be(e.pages[l], l, t, r));
|
|
464
|
+
return { canvases: a, diagnostics: r };
|
|
465
|
+
}
|
|
466
|
+
async function Be(e, t, n, r) {
|
|
467
|
+
const a = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), o = n.dpi ?? 96, l = n.fontFamily ?? te, i = await je(e, t, n, r);
|
|
468
|
+
$(n.signal);
|
|
469
|
+
const { canvas: s, ctx: c } = ze(e, a, o, n.maxCanvasPixels);
|
|
470
|
+
for (const m of e.components) ge(c, m, o / 25.4, o, l, n.measurer ?? le, i);
|
|
471
|
+
return s;
|
|
464
472
|
}
|
|
465
|
-
async function
|
|
466
|
-
const
|
|
467
|
-
return
|
|
473
|
+
async function je(e, t, n, r) {
|
|
474
|
+
const a = n.imageLoader ?? wt;
|
|
475
|
+
return Mt(e, async (o, l) => {
|
|
468
476
|
try {
|
|
469
|
-
return await
|
|
470
|
-
} catch (
|
|
471
|
-
if (
|
|
472
|
-
const
|
|
473
|
-
throw r.push(
|
|
477
|
+
return await a(o, l);
|
|
478
|
+
} catch (i) {
|
|
479
|
+
if (l?.aborted) throw i;
|
|
480
|
+
const s = e.components.findIndex((d) => d.imageData === o), c = e.components[s], m = { code: "image-decode-failed", severity: "warning", format: "canvas", pageIndex: t, componentIndex: s, kind: c.kind, nid: c.nid, message: "Image decoding failed; raster output was cancelled instead of omitting the image." };
|
|
481
|
+
throw r.push(m), De(m, n), i;
|
|
474
482
|
}
|
|
475
483
|
}, n.signal);
|
|
476
484
|
}
|
|
477
|
-
function
|
|
478
|
-
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96,
|
|
479
|
-
let g = null, f = null,
|
|
480
|
-
const
|
|
481
|
-
function
|
|
485
|
+
function In(e, t = {}) {
|
|
486
|
+
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, a = r / 96 * de, o = t.fontFamily ?? te, l = t.measurer ?? le, i = t.overscan ?? 1, s = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, m = e.pages.map((u) => u.pageHeightMm * a), d = Math.max(1, ...e.pages.map((u) => u.pageWidthMm * a)), h = { start: 0, end: -1 };
|
|
487
|
+
let g = null, f = null, w = null, C = null, x = [], v = 0, R = [], H = 0, N = new AbortController();
|
|
488
|
+
const ue = [];
|
|
489
|
+
function Ve() {
|
|
482
490
|
const u = g;
|
|
483
|
-
u.innerHTML = "", f = document.createElement("div"), f.style.cssText = `width:${
|
|
484
|
-
const
|
|
485
|
-
for (let
|
|
486
|
-
const
|
|
487
|
-
|
|
491
|
+
u.innerHTML = "", f = document.createElement("div"), f.style.cssText = `width:${d}px;margin:0 auto;`, w = document.createElement("div"), C = document.createElement("div"), f.appendChild(w), x = [];
|
|
492
|
+
const E = Math.min(e.pages.length, 3 + i * 2);
|
|
493
|
+
for (let F = 0; F < E; F++) {
|
|
494
|
+
const M = document.createElement("div");
|
|
495
|
+
M.style.cssText = `margin:0 auto ${s}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, f.appendChild(M), x.push(M);
|
|
488
496
|
}
|
|
489
|
-
f.appendChild(
|
|
497
|
+
f.appendChild(C), u.appendChild(f);
|
|
490
498
|
}
|
|
491
|
-
async function
|
|
492
|
-
const
|
|
493
|
-
|
|
494
|
-
const
|
|
495
|
-
if (
|
|
496
|
-
const { widthPx:
|
|
497
|
-
let
|
|
498
|
-
(
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
const
|
|
502
|
-
if (
|
|
503
|
-
|
|
504
|
-
for (const
|
|
505
|
-
|
|
506
|
-
|
|
499
|
+
async function qe(u, E) {
|
|
500
|
+
const F = H, M = await me(e, { ...t, signal: N.signal, format: "canvas", start: E, end: E });
|
|
501
|
+
ue.push(...M.diagnostics);
|
|
502
|
+
const P = M.plan.pages[E], J = await je(P, E, { ...t, signal: N.signal }, ue);
|
|
503
|
+
if (F !== H || !g) return;
|
|
504
|
+
const { widthPx: ie, heightPx: oe } = he(P, r);
|
|
505
|
+
let L = u.firstElementChild;
|
|
506
|
+
(!L || L.tagName !== "CANVAS") && (L = document.createElement("canvas"), u.innerHTML = "", u.appendChild(L));
|
|
507
|
+
const we = He(P, n, r, t.maxCanvasPixels);
|
|
508
|
+
L.width = we.width, L.height = we.height, L.style.width = `${ie}px`, L.style.height = `${oe}px`;
|
|
509
|
+
const z = L.getContext("2d");
|
|
510
|
+
if (z) {
|
|
511
|
+
z.setTransform(1, 0, 0, 1, 0, 0), z.scale(n, n), z.fillStyle = "#ffffff", z.fillRect(0, 0, ie, oe);
|
|
512
|
+
for (const Ke of P.components)
|
|
513
|
+
ge(z, Ke, a, r, o, l, J);
|
|
514
|
+
L.dataset.canvasPage = String(E), u.style.height = `${oe}px`, u.style.width = `${ie}px`;
|
|
507
515
|
}
|
|
508
516
|
}
|
|
509
|
-
function
|
|
510
|
-
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
if (
|
|
516
|
-
|
|
517
|
-
const
|
|
518
|
-
|
|
517
|
+
function Ye(u) {
|
|
518
|
+
H++, h.start = u.start, h.end = u.end, w.style.height = `${u.start * s + m.slice(0, u.start).reduce((M, P) => M + P, 0)}px`;
|
|
519
|
+
const E = e.pages.length - 1 - u.end;
|
|
520
|
+
C.style.height = `${E * s + m.slice(u.end + 1).reduce((M, P) => M + P, 0)}px`;
|
|
521
|
+
const F = u.end - u.start + 1;
|
|
522
|
+
x.forEach((M, P) => {
|
|
523
|
+
if (P < F) {
|
|
524
|
+
M.style.display = "";
|
|
525
|
+
const J = u.start + P;
|
|
526
|
+
M.style.height = `${m[J] ?? 0}px`;
|
|
519
527
|
} else
|
|
520
|
-
|
|
521
|
-
}),
|
|
522
|
-
for (let
|
|
523
|
-
const
|
|
524
|
-
if (!
|
|
525
|
-
|
|
528
|
+
M.style.display = "none";
|
|
529
|
+
}), R = [];
|
|
530
|
+
for (let M = u.start; M <= u.end; M++) {
|
|
531
|
+
const P = x[M - u.start];
|
|
532
|
+
if (!P) continue;
|
|
533
|
+
P.firstElementChild?.dataset?.canvasPage !== String(M) && R.push(M);
|
|
526
534
|
}
|
|
527
|
-
|
|
535
|
+
ae();
|
|
528
536
|
}
|
|
529
|
-
function
|
|
530
|
-
|
|
531
|
-
|
|
537
|
+
function ae() {
|
|
538
|
+
v || R.length === 0 || (v = requestAnimationFrame(() => {
|
|
539
|
+
v = 0;
|
|
532
540
|
let u = Math.max(1, c);
|
|
533
|
-
for (;
|
|
534
|
-
const
|
|
535
|
-
|
|
541
|
+
for (; R.length > 0 && u-- > 0; ) {
|
|
542
|
+
const E = R.shift(), F = x[E - h.start];
|
|
543
|
+
F && qe(F, E).catch(() => {
|
|
536
544
|
});
|
|
537
545
|
}
|
|
538
|
-
|
|
546
|
+
R.length > 0 && ae();
|
|
539
547
|
}));
|
|
540
548
|
}
|
|
541
|
-
function
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
const u = g,
|
|
545
|
-
pageHeightsPx:
|
|
549
|
+
function Y() {
|
|
550
|
+
v || (v = requestAnimationFrame(() => {
|
|
551
|
+
v = 0;
|
|
552
|
+
const u = g, E = vt({
|
|
553
|
+
pageHeightsPx: m,
|
|
546
554
|
viewportHeightPx: u.clientHeight,
|
|
547
555
|
scrollTopPx: u.scrollTop,
|
|
548
|
-
overscan:
|
|
549
|
-
gapPx:
|
|
556
|
+
overscan: i,
|
|
557
|
+
gapPx: s
|
|
550
558
|
});
|
|
551
|
-
|
|
559
|
+
E.start !== h.start || E.end !== h.end ? Ye(E) : ae();
|
|
552
560
|
}));
|
|
553
561
|
}
|
|
554
|
-
let
|
|
562
|
+
let K = null;
|
|
555
563
|
return {
|
|
556
564
|
attach(u) {
|
|
557
565
|
if (typeof document > "u")
|
|
558
566
|
throw new Error("createCanvasPager 需要浏览器环境(SSR 请在客户端钩子中调用 attach)");
|
|
559
|
-
|
|
567
|
+
$(t.signal), N = new AbortController(), t.signal?.addEventListener("abort", pe, { once: !0 }), q(e, "canvas", t), g = u, Ve(), u.addEventListener("scroll", Y, { passive: !0 }), typeof ResizeObserver < "u" && (K = new ResizeObserver(() => Y()), K.observe(u)), Y();
|
|
560
568
|
},
|
|
561
569
|
destroy() {
|
|
562
|
-
|
|
570
|
+
H++, N.abort(), t.signal?.removeEventListener("abort", pe), v && cancelAnimationFrame(v), v = 0, K?.disconnect(), K = null, g?.removeEventListener("scroll", Y), R = [], f?.remove(), g = null;
|
|
563
571
|
},
|
|
564
572
|
window() {
|
|
565
573
|
return { ...h };
|
|
566
574
|
}
|
|
567
575
|
};
|
|
568
|
-
function
|
|
569
|
-
|
|
576
|
+
function pe() {
|
|
577
|
+
N.abort(t.signal?.reason);
|
|
570
578
|
}
|
|
571
579
|
}
|
|
572
580
|
function _e(e, t, n) {
|
|
573
|
-
let r,
|
|
581
|
+
let r, a;
|
|
574
582
|
if (typeof e == "string") {
|
|
575
|
-
const o =
|
|
576
|
-
if (!o) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(
|
|
577
|
-
r = o.widthMm,
|
|
578
|
-
} else typeof e == "number" ? (r = e,
|
|
579
|
-
return n ? { widthMm:
|
|
583
|
+
const o = Z[e];
|
|
584
|
+
if (!o) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(Z).join("/")})`);
|
|
585
|
+
r = o.widthMm, a = o.heightMm;
|
|
586
|
+
} else typeof e == "number" ? (r = e, a = t ?? 297) : (r = e.widthMm, a = e.heightMm);
|
|
587
|
+
return n ? { widthMm: a, heightMm: r } : { widthMm: r, heightMm: a };
|
|
580
588
|
}
|
|
581
|
-
class
|
|
589
|
+
class At {
|
|
582
590
|
constructor() {
|
|
583
591
|
this.pages = [], this.pending = null, this.templateParams = void 0;
|
|
584
592
|
}
|
|
@@ -611,18 +619,18 @@ class Et {
|
|
|
611
619
|
*/
|
|
612
620
|
page(t = "a4", n = {}, r) {
|
|
613
621
|
this.collect();
|
|
614
|
-
const o = r != null && !("margins" in r) && !("landscape" in r) && ("marginTopMm" in r || "marginBottomMm" in r || "marginLeftMm" in r || "marginRightMm" in r) ? { margins: r } : typeof n == "number" ? r ?? {} : n, { widthMm:
|
|
622
|
+
const o = r != null && !("margins" in r) && !("landscape" in r) && ("marginTopMm" in r || "marginBottomMm" in r || "marginLeftMm" in r || "marginRightMm" in r) ? { margins: r } : typeof n == "number" ? r ?? {} : n, { widthMm: l, heightMm: i } = _e(
|
|
615
623
|
t,
|
|
616
624
|
typeof n == "number" ? n : void 0,
|
|
617
625
|
o.landscape
|
|
618
|
-
),
|
|
619
|
-
return this.pending = new
|
|
620
|
-
widthMm:
|
|
621
|
-
heightMm:
|
|
622
|
-
marginTopMm:
|
|
623
|
-
marginBottomMm:
|
|
624
|
-
marginLeftMm:
|
|
625
|
-
marginRightMm:
|
|
626
|
+
), s = o.margins ?? {};
|
|
627
|
+
return this.pending = new $t(this, {
|
|
628
|
+
widthMm: l,
|
|
629
|
+
heightMm: i,
|
|
630
|
+
marginTopMm: s.marginTopMm ?? 10,
|
|
631
|
+
marginBottomMm: s.marginBottomMm ?? 10,
|
|
632
|
+
marginLeftMm: s.marginLeftMm ?? 10,
|
|
633
|
+
marginRightMm: s.marginRightMm ?? 10
|
|
626
634
|
}), this.pending;
|
|
627
635
|
}
|
|
628
636
|
collect() {
|
|
@@ -638,7 +646,7 @@ class Et {
|
|
|
638
646
|
};
|
|
639
647
|
}
|
|
640
648
|
}
|
|
641
|
-
class
|
|
649
|
+
class $t {
|
|
642
650
|
constructor(t, n) {
|
|
643
651
|
this.parent = t, this.page = n, this.components = [];
|
|
644
652
|
}
|
|
@@ -653,7 +661,7 @@ class Tt {
|
|
|
653
661
|
style: r
|
|
654
662
|
}), this;
|
|
655
663
|
}
|
|
656
|
-
list(t, n, r,
|
|
664
|
+
list(t, n, r, a = {}) {
|
|
657
665
|
return this.components.push({
|
|
658
666
|
kind: "list",
|
|
659
667
|
leftMm: n.leftMm ?? 10,
|
|
@@ -661,20 +669,20 @@ class Tt {
|
|
|
661
669
|
widthMm: n.widthMm ?? 180,
|
|
662
670
|
dataset: t,
|
|
663
671
|
columns: r,
|
|
664
|
-
...
|
|
672
|
+
...a
|
|
665
673
|
}), this;
|
|
666
674
|
}
|
|
667
675
|
rect(t, n = {}) {
|
|
668
676
|
return this.components.push({ kind: "rect", ...t, style: n }), this;
|
|
669
677
|
}
|
|
670
|
-
line(t, n, r,
|
|
678
|
+
line(t, n, r, a = {}) {
|
|
671
679
|
return this.components.push({
|
|
672
680
|
kind: "line",
|
|
673
681
|
leftMm: t,
|
|
674
682
|
topMm: n,
|
|
675
683
|
widthMm: r,
|
|
676
684
|
heightMm: 0.5,
|
|
677
|
-
style:
|
|
685
|
+
style: a
|
|
678
686
|
}), this;
|
|
679
687
|
}
|
|
680
688
|
barcode(t, n) {
|
|
@@ -687,11 +695,11 @@ class Tt {
|
|
|
687
695
|
fallbackText: t
|
|
688
696
|
}), this;
|
|
689
697
|
}
|
|
690
|
-
qrcode(t, n, r,
|
|
698
|
+
qrcode(t, n, r, a) {
|
|
691
699
|
return this.components.push({
|
|
692
700
|
kind: "qrcode",
|
|
693
701
|
leftMm: r,
|
|
694
|
-
topMm:
|
|
702
|
+
topMm: a,
|
|
695
703
|
widthMm: n,
|
|
696
704
|
heightMm: n,
|
|
697
705
|
fallbackText: t
|
|
@@ -707,26 +715,26 @@ class Tt {
|
|
|
707
715
|
return this.done().build();
|
|
708
716
|
}
|
|
709
717
|
}
|
|
710
|
-
function
|
|
711
|
-
return new
|
|
718
|
+
function Nn() {
|
|
719
|
+
return new At();
|
|
712
720
|
}
|
|
713
|
-
function
|
|
714
|
-
return
|
|
721
|
+
function Ln(e, t = {}) {
|
|
722
|
+
return Xe([], e), e.fields.map((n) => ({
|
|
715
723
|
field: n.field,
|
|
716
724
|
header: `${n.label ?? n.field}${n.unit ? ` (${n.unit})` : ""}`,
|
|
717
725
|
semanticRole: n.semanticRole ?? (n.type === "number" || n.type === "decimal" ? "measure" : n.type === "date" ? "date" : n.enum ? "dimension" : "text"),
|
|
718
726
|
...t[n.field]
|
|
719
727
|
}));
|
|
720
728
|
}
|
|
721
|
-
function
|
|
729
|
+
function k(e, t, n = !1) {
|
|
722
730
|
if (!Number.isFinite(e) || (n ? e < 0 : e <= 0))
|
|
723
731
|
throw new Error(`${t} 必须是有限${n ? "非负" : "正"}数`);
|
|
724
732
|
}
|
|
725
|
-
function
|
|
733
|
+
function Q(e, t, n) {
|
|
726
734
|
if (e !== void 0 && !["left", "center", "right", "justify", ...n ? ["auto"] : []].includes(e))
|
|
727
735
|
throw new Error(`${t} 必须是 left/center/right/justify${n ? "/auto" : ""}`);
|
|
728
736
|
}
|
|
729
|
-
function
|
|
737
|
+
function kt(e) {
|
|
730
738
|
const t = e.layout ?? "page";
|
|
731
739
|
if (t !== "page" && t !== "wide")
|
|
732
740
|
throw new Error("layout 必须是 page 或 wide");
|
|
@@ -735,18 +743,18 @@ function St(e) {
|
|
|
735
743
|
if (t !== "wide" && e.columnWidthMm !== void 0)
|
|
736
744
|
throw new Error('columnWidthMm 仅适用于 layout: "wide"');
|
|
737
745
|
const n = e.columnWidthMm ?? 30;
|
|
738
|
-
return
|
|
746
|
+
return k(n, "columnWidthMm"), { layout: t, columnWidthMm: n };
|
|
739
747
|
}
|
|
740
|
-
function
|
|
748
|
+
function It(e) {
|
|
741
749
|
const t = e.paper === void 0 ? "a4" : e.paper;
|
|
742
750
|
if (typeof t != "string" && (typeof t != "object" || t === null) || e.landscape !== void 0 && typeof e.landscape != "boolean")
|
|
743
751
|
throw new Error("paper 必须是纸张预设名或 { widthMm, heightMm } 对象,landscape 必须是布尔值");
|
|
744
|
-
if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(
|
|
745
|
-
throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(
|
|
746
|
-
const n = _e(t, void 0, e.landscape), r = n.widthMm,
|
|
747
|
-
return
|
|
752
|
+
if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(Z, t))
|
|
753
|
+
throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(Z).join("/")})`);
|
|
754
|
+
const n = _e(t, void 0, e.landscape), r = n.widthMm, a = n.heightMm;
|
|
755
|
+
return k(r, "纸张 widthMm"), k(a, "纸张 heightMm"), { widthMm: r, heightMm: a };
|
|
748
756
|
}
|
|
749
|
-
function
|
|
757
|
+
function Nt(e) {
|
|
750
758
|
if (e.margins !== void 0 && (!e.margins || typeof e.margins != "object" || Array.isArray(e.margins)))
|
|
751
759
|
throw new Error("margins 必须是页边距对象");
|
|
752
760
|
const t = e.margins ?? {}, n = {
|
|
@@ -755,722 +763,760 @@ function Rt(e) {
|
|
|
755
763
|
marginLeftMm: t.marginLeftMm === void 0 ? 10 : t.marginLeftMm,
|
|
756
764
|
marginRightMm: t.marginRightMm === void 0 ? 10 : t.marginRightMm
|
|
757
765
|
};
|
|
758
|
-
for (const [r,
|
|
766
|
+
for (const [r, a] of Object.entries(n)) k(a, r, !0);
|
|
759
767
|
return n;
|
|
760
768
|
}
|
|
761
|
-
function
|
|
769
|
+
function Lt(e, t) {
|
|
762
770
|
const n = e.dataset === void 0 ? "detail" : e.dataset;
|
|
763
771
|
if (typeof n != "string" || !n.trim())
|
|
764
772
|
throw new Error("dataset 必须是非空字符串");
|
|
765
773
|
if (e.title !== void 0 && typeof e.title != "string")
|
|
766
774
|
throw new Error("title 必须是字符串");
|
|
767
|
-
const r = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm,
|
|
768
|
-
|
|
769
|
-
const o = e.title !== void 0 && e.title.length > 0,
|
|
770
|
-
if (
|
|
775
|
+
const r = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm, a = e.titleGapMm === void 0 ? 4 : e.titleGapMm;
|
|
776
|
+
k(r, "titleHeightMm"), k(a, "titleGapMm", !0);
|
|
777
|
+
const o = e.title !== void 0 && e.title.length > 0, l = o ? r + a : 0;
|
|
778
|
+
if (l >= t)
|
|
771
779
|
throw new Error("标题高度与间距占满页面,必须为表格保留可用高度");
|
|
772
|
-
return { dataset: n, titleHeightMm: r, hasTitle: o, titleSpaceMm:
|
|
780
|
+
return { dataset: n, titleHeightMm: r, hasTitle: o, titleSpaceMm: l };
|
|
773
781
|
}
|
|
774
|
-
function
|
|
782
|
+
function Dt(e) {
|
|
775
783
|
if (e.listOptions !== void 0 && (!e.listOptions || typeof e.listOptions != "object" || Array.isArray(e.listOptions)))
|
|
776
784
|
throw new Error("listOptions 必须是列表配置对象");
|
|
777
785
|
const t = e.listOptions ?? {};
|
|
778
|
-
|
|
786
|
+
Q(t.align, "listOptions.align", !0), Q(t.headerAlign, "listOptions.headerAlign", !1);
|
|
779
787
|
for (const n of ["fontSizePt", "rowHeightMm", "paddingMm"]) {
|
|
780
788
|
const r = t[n];
|
|
781
|
-
r !== void 0 &&
|
|
789
|
+
r !== void 0 && k(r, `listOptions.${n}`, n === "paddingMm");
|
|
782
790
|
}
|
|
783
791
|
return t;
|
|
784
792
|
}
|
|
785
|
-
function
|
|
793
|
+
function Ft(e) {
|
|
786
794
|
let t = 0, n = 0;
|
|
787
|
-
for (const [r,
|
|
788
|
-
if (!
|
|
795
|
+
for (const [r, a] of e.entries()) {
|
|
796
|
+
if (!a || typeof a.header != "string" || typeof a.field != "string" || !a.field.trim())
|
|
789
797
|
throw new Error(`columns[${r}] 需要字符串 header 与非空 field`);
|
|
790
|
-
|
|
798
|
+
Q(a.align, `columns[${r}].align`, !0), Q(a.headerAlign, `columns[${r}].headerAlign`, !1), a.flex !== void 0 && k(a.flex, `columns[${r}].flex`), a.widthMm !== void 0 ? (k(a.widthMm, `columns[${r}].widthMm`), t += a.widthMm) : n = Math.max(n, a.flex ?? 1);
|
|
791
799
|
}
|
|
792
800
|
return { fixedWidthMm: t, maxFlex: n };
|
|
793
801
|
}
|
|
794
|
-
function
|
|
795
|
-
const { fixedWidthMm:
|
|
796
|
-
if (t === "page" &&
|
|
797
|
-
throw new Error(`固定列宽 ${
|
|
798
|
-
const
|
|
799
|
-
if (t === "page" && o > 0 &&
|
|
802
|
+
function Ot(e, t, n, r) {
|
|
803
|
+
const { fixedWidthMm: a, maxFlex: o } = Ft(e.columns);
|
|
804
|
+
if (t === "page" && a > r)
|
|
805
|
+
throw new Error(`固定列宽 ${a}mm 超出页面可用宽度 ${r}mm`);
|
|
806
|
+
const l = r - a;
|
|
807
|
+
if (t === "page" && o > 0 && l <= 0)
|
|
800
808
|
throw new Error("固定列占满页面可用宽度,自动列需要正的剩余宽度");
|
|
801
|
-
const
|
|
802
|
-
return { columns: e.columns.map(({ widthMm: c, flex:
|
|
803
|
-
const g = c ?? (t === "wide" ? n * (
|
|
804
|
-
return
|
|
805
|
-
}), fixedWidthMm:
|
|
809
|
+
const i = o > 0 ? e.columns.reduce((c, m) => c + (m.widthMm === void 0 ? (m.flex ?? 1) / o : 0), 0) : 0;
|
|
810
|
+
return { columns: e.columns.map(({ widthMm: c, flex: m, ...d }, h) => {
|
|
811
|
+
const g = c ?? (t === "wide" ? n * (m ?? 1) : l * ((m ?? 1) / o) / i);
|
|
812
|
+
return k(g, `columns[${h}] 分配后的 widthMm`), { ...d, widthMm: g };
|
|
813
|
+
}), fixedWidthMm: a, maxFlex: o };
|
|
806
814
|
}
|
|
807
|
-
function
|
|
815
|
+
function Dn(e) {
|
|
808
816
|
if (!e || typeof e != "object")
|
|
809
817
|
throw new Error("标准明细模板需要 options 对象");
|
|
810
818
|
if (!Array.isArray(e.columns) || e.columns.length === 0)
|
|
811
819
|
throw new Error("columns 至少需要一列");
|
|
812
|
-
const { layout: t, columnWidthMm: n } =
|
|
813
|
-
let
|
|
814
|
-
const o = r.heightMm,
|
|
815
|
-
let
|
|
816
|
-
const
|
|
817
|
-
if (t === "page" &&
|
|
820
|
+
const { layout: t, columnWidthMm: n } = kt(e), r = It(e);
|
|
821
|
+
let a = r.widthMm;
|
|
822
|
+
const o = r.heightMm, l = Nt(e);
|
|
823
|
+
let i = a - l.marginLeftMm - l.marginRightMm;
|
|
824
|
+
const s = o - l.marginTopMm - l.marginBottomMm;
|
|
825
|
+
if (t === "page" && i <= 0 || s <= 0)
|
|
818
826
|
throw new Error("页边距占满纸张,必须保留正的可用宽度和高度");
|
|
819
|
-
const { dataset: c, titleHeightMm:
|
|
820
|
-
t === "wide" && (
|
|
821
|
-
const
|
|
822
|
-
return
|
|
827
|
+
const { dataset: c, titleHeightMm: m, hasTitle: d, titleSpaceMm: h } = Lt(e, s), g = Dt(e), { columns: f, fixedWidthMm: w, maxFlex: C } = Ot(e, t, n, i);
|
|
828
|
+
t === "wide" && (i = f.reduce((v, R) => v + R.widthMm, 0), k(i, "宽表总列宽"), a = i + l.marginLeftMm + l.marginRightMm, k(a, "宽表总宽度"));
|
|
829
|
+
const x = { widthMm: a, heightMm: o, ...l, components: [], ...t === "wide" ? { layout: t } : {} };
|
|
830
|
+
return d && x.components.push({
|
|
823
831
|
kind: "text",
|
|
824
832
|
text: e.title,
|
|
825
|
-
leftMm:
|
|
826
|
-
topMm:
|
|
827
|
-
widthMm:
|
|
828
|
-
heightMm:
|
|
833
|
+
leftMm: l.marginLeftMm,
|
|
834
|
+
topMm: l.marginTopMm,
|
|
835
|
+
widthMm: i,
|
|
836
|
+
heightMm: m,
|
|
829
837
|
style: { fontSize: 16, bold: !0, align: "center", verticalAlign: "middle", ...e.titleStyle }
|
|
830
|
-
}),
|
|
838
|
+
}), x.components.push({
|
|
831
839
|
align: "auto",
|
|
832
840
|
headerAlign: "center",
|
|
833
841
|
...g,
|
|
834
842
|
kind: "list",
|
|
835
843
|
...t === "wide" ? { layout: t } : {},
|
|
836
|
-
...
|
|
844
|
+
...d ? { title: e.title } : {},
|
|
837
845
|
dataset: c,
|
|
838
846
|
columns: f,
|
|
839
|
-
leftMm:
|
|
840
|
-
topMm:
|
|
841
|
-
widthMm: t === "wide" ||
|
|
842
|
-
}), e.params === void 0 ? { pages: [
|
|
847
|
+
leftMm: l.marginLeftMm,
|
|
848
|
+
topMm: l.marginTopMm + h,
|
|
849
|
+
widthMm: t === "wide" || C > 0 ? i : w
|
|
850
|
+
}), e.params === void 0 ? { pages: [x] } : { params: e.params, pages: [x] };
|
|
843
851
|
}
|
|
844
|
-
function
|
|
852
|
+
function Fn(e) {
|
|
845
853
|
if (e.components !== void 0 && e.pages !== void 0) throw new TypeError("标签 components 与 pages 只能选择一种");
|
|
846
|
-
const { dataset: t, rowKey: n, copies: r, params:
|
|
854
|
+
const { dataset: t, rowKey: n, copies: r, params: a } = e, o = e.pages ?? [{ components: e.components ?? [] }], l = {
|
|
847
855
|
repeat: { dataset: t, ...n === void 0 ? {} : { rowKey: n }, ...r === void 0 ? {} : { copies: r } },
|
|
848
|
-
...
|
|
849
|
-
pages: o.map((
|
|
850
|
-
widthMm:
|
|
851
|
-
heightMm:
|
|
856
|
+
...a === void 0 ? {} : { params: a },
|
|
857
|
+
pages: o.map((s) => ({
|
|
858
|
+
widthMm: s.widthMm ?? e.widthMm ?? 80,
|
|
859
|
+
heightMm: s.heightMm ?? e.heightMm ?? 55,
|
|
852
860
|
marginTopMm: 0,
|
|
853
861
|
marginRightMm: 0,
|
|
854
862
|
marginBottomMm: 0,
|
|
855
863
|
marginLeftMm: 0,
|
|
856
|
-
components:
|
|
857
|
-
...
|
|
864
|
+
components: s.components,
|
|
865
|
+
...s.meta === void 0 ? {} : { meta: s.meta }
|
|
858
866
|
}))
|
|
859
|
-
},
|
|
860
|
-
if (!
|
|
861
|
-
return JSON.parse(JSON.stringify(
|
|
867
|
+
}, i = $e(l);
|
|
868
|
+
if (!i.ok) throw new ke(i.errors);
|
|
869
|
+
return JSON.parse(JSON.stringify(l));
|
|
862
870
|
}
|
|
863
|
-
function
|
|
871
|
+
function Ht(e) {
|
|
864
872
|
if (!e || typeof e != "object" || !e.repeat)
|
|
865
|
-
throw new
|
|
866
|
-
const t =
|
|
867
|
-
if (!t.ok) throw new
|
|
873
|
+
throw new ce("config", "defineLabelReport 需要带 repeat 的固定标签模板");
|
|
874
|
+
const t = $e(e);
|
|
875
|
+
if (!t.ok) throw new ke(t.errors);
|
|
868
876
|
return e.repeat.dataset;
|
|
869
877
|
}
|
|
870
|
-
function
|
|
871
|
-
if (!Array.isArray(e)) throw new
|
|
878
|
+
function ye(e, t) {
|
|
879
|
+
if (!Array.isArray(e)) throw new ce("validate", "标签数据应为对象数组;请从业务响应中提取行数组");
|
|
872
880
|
return { [t]: e };
|
|
873
881
|
}
|
|
874
|
-
function
|
|
875
|
-
const { template: t, rows: n, load: r, dataSchema:
|
|
882
|
+
function On(e) {
|
|
883
|
+
const { template: t, rows: n, load: r, dataSchema: a, params: o, pagination: l, dataValidation: i } = e, s = Ht(t);
|
|
876
884
|
if (n !== void 0 == (r !== void 0) || r !== void 0 && typeof r != "function")
|
|
877
|
-
throw new
|
|
878
|
-
const c = { template: t, params: o, pagination:
|
|
879
|
-
return r ?
|
|
885
|
+
throw new ce("config", "标签报表应且只能配置 rows 或 load 其中一种数据来源");
|
|
886
|
+
const c = { template: t, params: o, pagination: l, dataValidation: i, ...a === void 0 ? {} : { dataSchema: { [s]: a } } };
|
|
887
|
+
return r ? Ze({ ...c, load: r, mapData: (m) => ye(m, s) }) : { ...c, datasets: ye(n, s) };
|
|
880
888
|
}
|
|
881
|
-
function
|
|
889
|
+
function Hn(e) {
|
|
882
890
|
return e;
|
|
883
891
|
}
|
|
884
|
-
class
|
|
892
|
+
class D extends Error {
|
|
885
893
|
constructor(t, n) {
|
|
886
894
|
super(n), this.code = t, this.name = "ReportTemplateStoreError";
|
|
887
895
|
}
|
|
888
896
|
}
|
|
889
|
-
function
|
|
897
|
+
function I(e) {
|
|
890
898
|
return JSON.parse(JSON.stringify(e));
|
|
891
899
|
}
|
|
892
|
-
function
|
|
900
|
+
function S(e) {
|
|
893
901
|
if (!e?.aborted) return;
|
|
894
902
|
const t = new Error("模板操作已取消");
|
|
895
903
|
throw t.name = "AbortError", t;
|
|
896
904
|
}
|
|
897
905
|
function ve(e) {
|
|
898
906
|
const t = e ? Number(e.revision) : 0;
|
|
899
|
-
if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new
|
|
907
|
+
if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new D("history", "修订号无效或已达上限");
|
|
900
908
|
return String(t + 1);
|
|
901
909
|
}
|
|
902
|
-
function
|
|
903
|
-
const n = async (
|
|
904
|
-
|
|
905
|
-
const
|
|
906
|
-
return
|
|
907
|
-
}, r = async (
|
|
908
|
-
const
|
|
909
|
-
if ((
|
|
910
|
-
return
|
|
911
|
-
},
|
|
912
|
-
if (
|
|
913
|
-
return
|
|
914
|
-
}, o = async (
|
|
910
|
+
function zn(e, t = {}) {
|
|
911
|
+
const n = async (l, i) => {
|
|
912
|
+
S(i);
|
|
913
|
+
const s = await e.read(l, i);
|
|
914
|
+
return S(i), s ? I(s) : void 0;
|
|
915
|
+
}, r = async (l, i) => {
|
|
916
|
+
const s = await n(l, i.signal);
|
|
917
|
+
if ((s?.revision ?? null) !== i.expectedRevision) throw new D("conflict", "模板已变化,请重新读取后提交");
|
|
918
|
+
return s;
|
|
919
|
+
}, a = async (l, i, s) => {
|
|
920
|
+
if (S(i.signal), !await e.compareAndSwap(l.id, i.expectedRevision, I(l), { signal: i.signal, ...s ? { publication: I(s) } : {} })) throw new D("conflict", "模板已被其他请求更新");
|
|
921
|
+
return I(l);
|
|
922
|
+
}, o = async (l, i, s, c) => {
|
|
915
923
|
if (t.beforePublish) {
|
|
916
|
-
|
|
917
|
-
const g = await t.beforePublish({ document:
|
|
918
|
-
if (!g || g.ok !== !0) throw new
|
|
919
|
-
|
|
924
|
+
S(s.signal);
|
|
925
|
+
const g = await t.beforePublish({ document: U(i), previous: l.published ? U(l.published) : void 0, signal: s.signal });
|
|
926
|
+
if (!g || g.ok !== !0) throw new D("review", g?.issues?.find((f) => f.severity === "error")?.message ?? "模板发布检查未通过");
|
|
927
|
+
S(s.signal);
|
|
920
928
|
}
|
|
921
|
-
const
|
|
922
|
-
return c !== void 0 && (h.restoredFrom = c),
|
|
929
|
+
const m = ve(l), d = U({ ...i, revision: m }), h = { revision: m, document: d, publishedAt: (t.now?.() ?? /* @__PURE__ */ new Date()).toISOString() };
|
|
930
|
+
return c !== void 0 && (h.restoredFrom = c), a({ id: l.id, revision: m, publishedRevision: m, published: d }, s, h);
|
|
923
931
|
};
|
|
924
932
|
return {
|
|
925
|
-
list: async (
|
|
926
|
-
|
|
927
|
-
const
|
|
928
|
-
return
|
|
933
|
+
list: async (l) => {
|
|
934
|
+
S(l);
|
|
935
|
+
const i = await e.list(l);
|
|
936
|
+
return S(l), I(i);
|
|
929
937
|
},
|
|
930
|
-
get: async (
|
|
931
|
-
const
|
|
932
|
-
return c ?
|
|
938
|
+
get: async (l, i = {}) => {
|
|
939
|
+
const s = await n(l, i.signal), c = i.draft ? s?.draft : s?.published;
|
|
940
|
+
return c ? U(c) : void 0;
|
|
933
941
|
},
|
|
934
|
-
history: async (
|
|
935
|
-
|
|
936
|
-
const
|
|
937
|
-
return
|
|
942
|
+
history: async (l, i) => {
|
|
943
|
+
S(i);
|
|
944
|
+
const s = await e.history(l, i);
|
|
945
|
+
return S(i), I(s);
|
|
938
946
|
},
|
|
939
|
-
saveDraft: async (
|
|
940
|
-
|
|
941
|
-
const
|
|
942
|
-
return
|
|
943
|
-
id:
|
|
944
|
-
revision:
|
|
945
|
-
draft: { ...
|
|
947
|
+
saveDraft: async (l, i) => {
|
|
948
|
+
i = { ...i }, S(i.signal);
|
|
949
|
+
const s = U(t.migrate ? await t.migrate(l) : l), c = await r(s.id, i), m = ve(c);
|
|
950
|
+
return a({
|
|
951
|
+
id: s.id,
|
|
952
|
+
revision: m,
|
|
953
|
+
draft: { ...s, revision: m },
|
|
946
954
|
...c?.publishedRevision ? { publishedRevision: c.publishedRevision, published: c.published } : {}
|
|
947
|
-
},
|
|
955
|
+
}, i);
|
|
948
956
|
},
|
|
949
|
-
publish: async (
|
|
950
|
-
|
|
951
|
-
const
|
|
952
|
-
if (!
|
|
953
|
-
if (!
|
|
954
|
-
return o(
|
|
957
|
+
publish: async (l, i) => {
|
|
958
|
+
i = { ...i };
|
|
959
|
+
const s = await r(l, i);
|
|
960
|
+
if (!s) throw new D("missing", "模板不存在");
|
|
961
|
+
if (!s.draft) throw new D("draft", "没有可发布的草稿");
|
|
962
|
+
return o(s, s.draft, i);
|
|
955
963
|
},
|
|
956
|
-
rollback: async (
|
|
957
|
-
|
|
958
|
-
const c = await r(
|
|
959
|
-
if (!c) throw new
|
|
960
|
-
|
|
961
|
-
const
|
|
962
|
-
if (!
|
|
963
|
-
return o(c,
|
|
964
|
+
rollback: async (l, i, s) => {
|
|
965
|
+
s = { ...s };
|
|
966
|
+
const c = await r(l, s);
|
|
967
|
+
if (!c) throw new D("missing", "模板不存在");
|
|
968
|
+
S(s.signal);
|
|
969
|
+
const m = await e.getVersion(l, i, s.signal);
|
|
970
|
+
if (!m) throw new D("history", "历史修订不存在");
|
|
971
|
+
return o(c, m.document, s, i);
|
|
964
972
|
}
|
|
965
973
|
};
|
|
966
974
|
}
|
|
967
|
-
function
|
|
975
|
+
function Wn() {
|
|
968
976
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
969
977
|
return {
|
|
970
978
|
read: async (n, r) => {
|
|
971
|
-
|
|
972
|
-
const
|
|
973
|
-
return
|
|
979
|
+
S(r);
|
|
980
|
+
const a = e.get(n);
|
|
981
|
+
return a ? I(a) : void 0;
|
|
974
982
|
},
|
|
975
|
-
list: async (n) => (
|
|
976
|
-
history: async (n, r) => (
|
|
977
|
-
getVersion: async (n, r,
|
|
978
|
-
|
|
983
|
+
list: async (n) => (S(n), Array.from(e.values(), ({ id: r, revision: a, publishedRevision: o }) => ({ id: r, revision: a, ...o ? { publishedRevision: o } : {} }))),
|
|
984
|
+
history: async (n, r) => (S(r), Array.from(t.get(n)?.values() ?? [], (a) => I(a))),
|
|
985
|
+
getVersion: async (n, r, a) => {
|
|
986
|
+
S(a);
|
|
979
987
|
const o = t.get(n)?.get(r);
|
|
980
|
-
return o ?
|
|
988
|
+
return o ? I(o) : void 0;
|
|
981
989
|
},
|
|
982
|
-
compareAndSwap: async (n, r,
|
|
983
|
-
if (
|
|
984
|
-
if (
|
|
985
|
-
const
|
|
986
|
-
if (
|
|
987
|
-
const
|
|
988
|
-
if (
|
|
989
|
-
|
|
990
|
+
compareAndSwap: async (n, r, a, o) => {
|
|
991
|
+
if (S(o.signal), (e.get(n)?.revision ?? null) !== r) return !1;
|
|
992
|
+
if (a.id !== n) throw new D("history", "状态 ID 与存储 ID 不一致");
|
|
993
|
+
const l = I(a), i = o.publication;
|
|
994
|
+
if (i) {
|
|
995
|
+
const s = t.get(n) ?? /* @__PURE__ */ new Map();
|
|
996
|
+
if (s.has(i.revision) || i.revision !== a.revision || i.document.id !== n) throw new D("history", "发布修订不可覆盖,且必须与状态修订和模板 ID 一致");
|
|
997
|
+
s.set(i.revision, I(i)), t.set(n, s);
|
|
990
998
|
}
|
|
991
|
-
return e.set(n,
|
|
999
|
+
return e.set(n, l), !0;
|
|
992
1000
|
}
|
|
993
1001
|
};
|
|
994
1002
|
}
|
|
995
|
-
function
|
|
996
|
-
const n = e.publishedRevision ?? e.published?.revision;
|
|
997
|
-
for (const r of [e.draftRevision, n]) if (r !== void 0 && (typeof r != "string" || !r.trim())) throw new TypeError("模板生命周期修订应为非空字符串");
|
|
998
|
-
if (e.draftRevision !== void 0 && e.draftRevision !== t.revision) throw new TypeError("可编辑文档应与草稿修订一致");
|
|
999
|
-
if (e.published && (e.published.id !== t.id || e.published.revision !== n)) throw new TypeError("发布文档身份或修订不一致");
|
|
1000
|
-
if (!e.published && n !== void 0 && n !== t.revision) throw new TypeError("发布修订需要对应的独立文档");
|
|
1001
|
-
return { ...e.draftRevision === void 0 ? {} : { draftRevision: e.draftRevision }, ...n === void 0 ? {} : { publishedRevision: n } };
|
|
1002
|
-
}
|
|
1003
|
-
function In(e, t) {
|
|
1004
|
-
const n = I(e);
|
|
1005
|
-
if (t.id === n.id) throw new Error("复制模板应使用新的 ID");
|
|
1006
|
-
const { revision: r, ...i } = n;
|
|
1007
|
-
return I({ ...i, id: t.id, name: t.name });
|
|
1008
|
-
}
|
|
1009
|
-
function Nn(e) {
|
|
1010
|
-
if (!Array.isArray(e) || e.length > 1e3) throw new RangeError("本地模板目录最多 1000 项");
|
|
1011
|
-
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = [];
|
|
1012
|
-
for (const i of e) {
|
|
1013
|
-
const o = I(i.document);
|
|
1014
|
-
if (t.has(o.id)) throw new Error(`模板 ID 重复:${o.id}`);
|
|
1015
|
-
if (i.category !== void 0 && (typeof i.category != "string" || i.category.length > 128) || i.tags !== void 0 && (!Array.isArray(i.tags) || i.tags.length > 20 || i.tags.some((c) => typeof c != "string" || c.length > 128))) throw new TypeError("模板分类和标签无效");
|
|
1016
|
-
const s = $t(i, o), { template: a, ...l } = o;
|
|
1017
|
-
t.set(o.id, o), i.published ? n.set(o.id, I(i.published)) : s.publishedRevision && n.set(o.id, I(o)), r.push({ ...l, ...s, ...i.category ? { category: i.category } : {}, ...i.tags ? { tags: [...i.tags] } : {} });
|
|
1018
|
-
}
|
|
1019
|
-
return r.sort((i, o) => i.id < o.id ? -1 : 1), {
|
|
1020
|
-
search: async (i) => {
|
|
1021
|
-
be(i.signal);
|
|
1022
|
-
const o = i.limit ?? 30;
|
|
1023
|
-
if (!Number.isSafeInteger(o) || o < 1 || o > 100) throw new RangeError("模板每页数量应为 1–100");
|
|
1024
|
-
const s = i.query?.trim().toLocaleLowerCase() ?? "", a = r.filter((c) => (!i.category || c.category === i.category) && (!i.cursor || c.id > i.cursor) && (!s || [c.id, c.name, c.description, ...c.tags ?? []].some((d) => d?.toLocaleLowerCase().includes(s)))), l = /* @__PURE__ */ new Map();
|
|
1025
|
-
for (const c of r) c.category && l.set(c.category, (l.get(c.category) ?? 0) + 1);
|
|
1026
|
-
return JSON.parse(JSON.stringify({ items: a.slice(0, o), ...a.length > o ? { next: a[o - 1].id } : {}, categories: Array.from(l, ([c, d]) => ({ id: c, label: c, count: d })) }));
|
|
1027
|
-
},
|
|
1028
|
-
get: async (i, o) => {
|
|
1029
|
-
be(o.signal);
|
|
1030
|
-
const s = o.mode === "published" ? n.get(i) : t.get(i);
|
|
1031
|
-
return s ? I(s) : void 0;
|
|
1032
|
-
}
|
|
1033
|
-
};
|
|
1034
|
-
}
|
|
1035
|
-
function be(e) {
|
|
1036
|
-
if (!e?.aborted) return;
|
|
1037
|
-
const t = new Error("模板目录操作已取消");
|
|
1038
|
-
throw t.name = "AbortError", t;
|
|
1039
|
-
}
|
|
1040
|
-
function $n(e) {
|
|
1003
|
+
function Bn(e) {
|
|
1041
1004
|
return e.map((t) => t.map((n) => /[\t\r\n"]/.test(n) ? `"${n.replace(/"/g, '""')}"` : n).join(" ")).join(`\r
|
|
1042
1005
|
`);
|
|
1043
1006
|
}
|
|
1044
|
-
function
|
|
1007
|
+
function zt(e, t) {
|
|
1045
1008
|
const n = e[e.length - 1];
|
|
1046
1009
|
e.length > 1 && n?.length === 1 && n[0] === "" && /[\r\n]$/.test(t) && e.pop();
|
|
1047
1010
|
}
|
|
1048
|
-
function
|
|
1011
|
+
function jn(e, t = 1e4) {
|
|
1049
1012
|
if (e.length > 4 * 1024 * 1024) throw new Error("Clipboard text limit exceeded");
|
|
1050
1013
|
const n = [[]];
|
|
1051
|
-
let r = "",
|
|
1052
|
-
function
|
|
1053
|
-
if (++
|
|
1014
|
+
let r = "", a = !1, o = !1, l = 0;
|
|
1015
|
+
function i() {
|
|
1016
|
+
if (++l > t) throw new Error("Clipboard cell limit exceeded");
|
|
1054
1017
|
n[n.length - 1].push(r), r = "", o = !1;
|
|
1055
1018
|
}
|
|
1056
|
-
for (let
|
|
1057
|
-
const c = e[
|
|
1058
|
-
if (
|
|
1019
|
+
for (let s = 0; s < e.length; s++) {
|
|
1020
|
+
const c = e[s];
|
|
1021
|
+
if (a) {
|
|
1059
1022
|
if (c !== '"') {
|
|
1060
1023
|
r += c;
|
|
1061
1024
|
continue;
|
|
1062
1025
|
}
|
|
1063
|
-
if (e[
|
|
1064
|
-
r += '"',
|
|
1026
|
+
if (e[s + 1] === '"') {
|
|
1027
|
+
r += '"', s++;
|
|
1065
1028
|
continue;
|
|
1066
1029
|
}
|
|
1067
|
-
|
|
1030
|
+
a = !1, o = !0;
|
|
1068
1031
|
continue;
|
|
1069
1032
|
}
|
|
1070
1033
|
if (c === '"' && !r && !o) {
|
|
1071
|
-
|
|
1034
|
+
a = !0;
|
|
1072
1035
|
continue;
|
|
1073
1036
|
}
|
|
1074
1037
|
if (c === " ") {
|
|
1075
|
-
|
|
1038
|
+
i();
|
|
1076
1039
|
continue;
|
|
1077
1040
|
}
|
|
1078
1041
|
if (c === "\r" || c === `
|
|
1079
1042
|
`) {
|
|
1080
|
-
|
|
1081
|
-
` &&
|
|
1043
|
+
i(), n.push([]), c === "\r" && e[s + 1] === `
|
|
1044
|
+
` && s++;
|
|
1082
1045
|
continue;
|
|
1083
1046
|
}
|
|
1084
1047
|
if (o) throw new Error("Invalid quoted clipboard value");
|
|
1085
1048
|
r += c;
|
|
1086
1049
|
}
|
|
1087
|
-
if (
|
|
1088
|
-
return
|
|
1050
|
+
if (a) throw new Error("Unclosed clipboard quote");
|
|
1051
|
+
return i(), zt(n, e), n;
|
|
1089
1052
|
}
|
|
1090
|
-
class
|
|
1053
|
+
class Wt extends Error {
|
|
1091
1054
|
constructor(t, n, r) {
|
|
1092
|
-
const
|
|
1093
|
-
definition: `${
|
|
1094
|
-
type: `${
|
|
1095
|
-
required: `${
|
|
1096
|
-
min: `${
|
|
1097
|
-
max: `${
|
|
1098
|
-
precision: `${
|
|
1099
|
-
length: `${
|
|
1100
|
-
choice: `${
|
|
1101
|
-
date: `${
|
|
1055
|
+
const a = typeof n.label == "string" ? n.label : "单元格", o = {
|
|
1056
|
+
definition: `${a}的编辑器配置无效`,
|
|
1057
|
+
type: `${a}的编辑器与数据类型不一致`,
|
|
1058
|
+
required: `${a}不能为空`,
|
|
1059
|
+
min: `${a}不能小于 ${r}`,
|
|
1060
|
+
max: `${a}不能大于 ${r}`,
|
|
1061
|
+
precision: `${a}最多保留 ${r} 位小数`,
|
|
1062
|
+
length: `${a}最多允许 ${r} 个字符`,
|
|
1063
|
+
choice: `${a}请选择有效选项`,
|
|
1064
|
+
date: `${a}请输入有效日期(YYYY-MM-DD)`
|
|
1102
1065
|
};
|
|
1103
1066
|
super(o[t]), this.code = t, this.field = n, this.expected = r, this.name = "ReportCellFieldError";
|
|
1104
1067
|
}
|
|
1105
1068
|
}
|
|
1106
1069
|
function p(e, t, n) {
|
|
1107
|
-
throw new
|
|
1070
|
+
throw new Wt(t, e, n);
|
|
1108
1071
|
}
|
|
1109
|
-
function
|
|
1072
|
+
function Ue(e) {
|
|
1110
1073
|
if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}$/.test(e) || e.startsWith("0000-")) return !1;
|
|
1111
1074
|
const t = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
|
|
1112
1075
|
return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
|
|
1113
1076
|
}
|
|
1114
|
-
function
|
|
1077
|
+
function Bt(e) {
|
|
1115
1078
|
const [t = "", n = "0"] = String(e).toLowerCase().split("e");
|
|
1116
1079
|
return Math.max(0, (t.split(".")[1]?.length ?? 0) - Number(n));
|
|
1117
1080
|
}
|
|
1118
|
-
function
|
|
1119
|
-
e.min !== void 0 && t < e.min && p(e, "min", e.min), e.max !== void 0 && t > e.max && p(e, "max", e.max), e.precision !== void 0 &&
|
|
1081
|
+
function jt(e, t) {
|
|
1082
|
+
e.min !== void 0 && t < e.min && p(e, "min", e.min), e.max !== void 0 && t > e.max && p(e, "max", e.max), e.precision !== void 0 && Bt(t) > e.precision && p(e, "precision", e.precision);
|
|
1120
1083
|
}
|
|
1121
|
-
function
|
|
1122
|
-
|
|
1084
|
+
function _t(e, t) {
|
|
1085
|
+
Ue(t) || p(e, "date"), e.min !== void 0 && t < e.min && p(e, "min", e.min), e.max !== void 0 && t > e.max && p(e, "max", e.max);
|
|
1123
1086
|
}
|
|
1124
|
-
function
|
|
1087
|
+
function Ut(e) {
|
|
1125
1088
|
[e.min, e.max].some((t) => t !== void 0 && !Number.isFinite(t)) && p(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && p(e, "definition"), e.precision !== void 0 && (!Number.isInteger(e.precision) || e.precision < 0 || e.precision > 15) && p(e, "definition");
|
|
1126
1089
|
}
|
|
1127
|
-
function
|
|
1128
|
-
[e.min, e.max].some((t) => t !== void 0 && !
|
|
1090
|
+
function Gt(e) {
|
|
1091
|
+
[e.min, e.max].some((t) => t !== void 0 && !Ue(t)) && p(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && p(e, "definition");
|
|
1129
1092
|
}
|
|
1130
|
-
function
|
|
1093
|
+
function Vt(e, t) {
|
|
1131
1094
|
(!Array.isArray(t.options) || !t.options.length) && p(t, "definition");
|
|
1132
1095
|
const n = e.valueType === "text" ? "string" : e.valueType, r = /* @__PURE__ */ new Set();
|
|
1133
|
-
for (const
|
|
1134
|
-
(!
|
|
1096
|
+
for (const a of t.options)
|
|
1097
|
+
(!a || typeof a.value !== n || typeof a.value == "number" && !Number.isFinite(a.value)) && p(t, "definition"), a.label !== void 0 && typeof a.label != "string" && p(t, "definition"), r.has(a.value) && p(t, "definition"), r.add(a.value);
|
|
1135
1098
|
}
|
|
1136
|
-
function
|
|
1099
|
+
function qt(e) {
|
|
1137
1100
|
e.required !== void 0 && typeof e.required != "boolean" && p(e, "definition"), [e.label, e.hint, e.unit].some((t) => t !== void 0 && typeof t != "string") && p(e, "definition"), e.type === "boolean" && [e.trueLabel, e.falseLabel].some((t) => t !== void 0 && typeof t != "string") && p(e, "definition");
|
|
1138
1101
|
}
|
|
1139
|
-
function
|
|
1140
|
-
(!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && p(t ?? { type: "text" }, "definition"),
|
|
1102
|
+
function Yt(e, t) {
|
|
1103
|
+
(!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && p(t ?? { type: "text" }, "definition"), qt(t), (t.type === "number" || t.type === "boolean") && e.valueType !== t.type && p(t, "type"), (t.type === "text" || t.type === "date") && e.valueType !== "text" && p(t, "type"), t.type === "number" && Ut(t), t.type === "text" && t.maxLength !== void 0 && (!Number.isInteger(t.maxLength) || t.maxLength < 0) && p(t, "definition"), t.type === "date" && Gt(t), t.type === "enum" && Vt(e, t);
|
|
1141
1104
|
}
|
|
1142
|
-
function
|
|
1143
|
-
if (!e.editable) throw new
|
|
1144
|
-
n &&
|
|
1145
|
-
const r =
|
|
1146
|
-
return n ? (n.required && typeof r == "string" && !r.trim() && p(n, "required"), r === null || r === "" ? (n.required && p(n, "required"), r) : (n.type === "number" &&
|
|
1105
|
+
function _n(e, t, n) {
|
|
1106
|
+
if (!e.editable) throw new rt("readonly");
|
|
1107
|
+
n && Yt(e, n);
|
|
1108
|
+
const r = at(e, t);
|
|
1109
|
+
return n ? (n.required && typeof r == "string" && !r.trim() && p(n, "required"), r === null || r === "" ? (n.required && p(n, "required"), r) : (n.type === "number" && jt(n, r), n.type === "date" && _t(n, r), n.type === "text" && n.maxLength !== void 0 && [...String(r)].length > n.maxLength && p(n, "length", n.maxLength), n.type === "enum" && !n.options.some((a) => Object.is(a.value, r)) && p(n, "choice"), r)) : r;
|
|
1147
1110
|
}
|
|
1148
|
-
class
|
|
1111
|
+
class b extends Error {
|
|
1149
1112
|
constructor(t) {
|
|
1150
1113
|
super(`Report calculation: ${t}`), this.code = t, this.name = "ReportCalculationError";
|
|
1151
1114
|
}
|
|
1152
1115
|
}
|
|
1153
|
-
function
|
|
1116
|
+
function B(e) {
|
|
1154
1117
|
if (!e?.aborted) return;
|
|
1155
1118
|
const t = new Error("Calculation cancelled");
|
|
1156
1119
|
throw t.name = "AbortError", t;
|
|
1157
1120
|
}
|
|
1158
|
-
async function
|
|
1121
|
+
async function ee(e, t = 1) {
|
|
1159
1122
|
const n = Math.floor(e.scanned / 2048);
|
|
1160
|
-
if (e.scanned += t, e.scanned > e.maxScanned) throw new
|
|
1161
|
-
|
|
1123
|
+
if (e.scanned += t, e.scanned > e.maxScanned) throw new b("limit");
|
|
1124
|
+
B(e.signal), Math.floor(e.scanned / 2048) > n && (await e.yieldToHost(), B(e.signal));
|
|
1162
1125
|
}
|
|
1163
|
-
function
|
|
1126
|
+
function fe(e) {
|
|
1164
1127
|
return e.table?.role === "header" ? -Math.max(1, e.grid?.cells.length ?? 1) : e.table?.rowIndex ?? 0;
|
|
1165
1128
|
}
|
|
1166
|
-
function
|
|
1167
|
-
if (![t.pageIndex, t.componentIndex, t.rowIndex, t.columnIndex].every((
|
|
1129
|
+
function xe(e, t, n) {
|
|
1130
|
+
if (![t.pageIndex, t.componentIndex, t.rowIndex, t.columnIndex].every((i) => Number.isSafeInteger(i) && i >= 0)) throw new b("selection");
|
|
1168
1131
|
const r = e.pages[t.pageIndex]?.components[t.componentIndex];
|
|
1169
|
-
if (!r?.grid || t.rowIndex >= r.grid.cells.length) throw new
|
|
1170
|
-
const
|
|
1171
|
-
if (t.columnIndex >=
|
|
1172
|
-
const o = r.table,
|
|
1173
|
-
if (o &&
|
|
1174
|
-
const
|
|
1175
|
-
if (
|
|
1176
|
-
return { grid: o.id, row:
|
|
1132
|
+
if (!r?.grid || t.rowIndex >= r.grid.cells.length) throw new b("selection");
|
|
1133
|
+
const a = r.grid.colWidthsMm?.length ?? r.grid.cells.reduce((i, s) => Math.max(i, s.length), 1);
|
|
1134
|
+
if (t.columnIndex >= a) throw new b("selection");
|
|
1135
|
+
const o = r.table, l = e.pages[n.pageIndex]?.components[n.componentIndex]?.table;
|
|
1136
|
+
if (o && l && o.id === l.id) {
|
|
1137
|
+
const i = l.columnKeys.indexOf(o.columnKeys[t.columnIndex] ?? "");
|
|
1138
|
+
if (i < 0) throw new b("selection");
|
|
1139
|
+
return { grid: o.id, row: fe(r) + t.rowIndex, column: i };
|
|
1177
1140
|
}
|
|
1178
1141
|
return { grid: `${t.pageIndex}:${t.componentIndex}`, row: t.rowIndex, column: t.columnIndex };
|
|
1179
1142
|
}
|
|
1180
|
-
function
|
|
1181
|
-
const r =
|
|
1182
|
-
if (r.grid !==
|
|
1183
|
-
const o = (Math.abs(r.row -
|
|
1184
|
-
if (!Number.isSafeInteger(o) || o > n) throw new
|
|
1185
|
-
return { grid: r.grid, rowStart: Math.min(r.row,
|
|
1143
|
+
function Kt(e, t, n) {
|
|
1144
|
+
const r = xe(e, t.anchor, t.anchor), a = xe(e, t.focus, t.anchor);
|
|
1145
|
+
if (r.grid !== a.grid) throw new b("selection");
|
|
1146
|
+
const o = (Math.abs(r.row - a.row) + 1) * (Math.abs(r.column - a.column) + 1);
|
|
1147
|
+
if (!Number.isSafeInteger(o) || o > n) throw new b("limit");
|
|
1148
|
+
return { grid: r.grid, rowStart: Math.min(r.row, a.row), rowEnd: Math.max(r.row, a.row), columnStart: Math.min(r.column, a.column), columnEnd: Math.max(r.column, a.column), origin: e.pages[t.anchor.pageIndex].components[t.anchor.componentIndex].table };
|
|
1186
1149
|
}
|
|
1187
|
-
function
|
|
1150
|
+
function Jt(e) {
|
|
1188
1151
|
if (!e) return !1;
|
|
1189
1152
|
const t = e.replace(/"[^"]*"|\\.|\[(?![hms]+\])[^\]]*\]/gi, "");
|
|
1190
1153
|
return /[ymdhs]/i.test(t);
|
|
1191
1154
|
}
|
|
1192
|
-
function
|
|
1193
|
-
if (e.valueType === "text" || e.valueType === "boolean" ||
|
|
1155
|
+
function Xt(e) {
|
|
1156
|
+
if (e.valueType === "text" || e.valueType === "boolean" || Jt(e.numberFormat)) return null;
|
|
1194
1157
|
const t = e.value;
|
|
1195
1158
|
if (typeof t != "number" || !Number.isFinite(t)) return null;
|
|
1196
|
-
if (Number.isInteger(t) && !Number.isSafeInteger(t)) throw new
|
|
1159
|
+
if (Number.isInteger(t) && !Number.isSafeInteger(t)) throw new b("precision");
|
|
1197
1160
|
return t;
|
|
1198
1161
|
}
|
|
1199
|
-
function
|
|
1162
|
+
function Zt(e, t, n) {
|
|
1200
1163
|
if (e.seen.has(n)) return;
|
|
1201
1164
|
e.seen.add(n), e.selected++;
|
|
1202
|
-
const r = t ?
|
|
1165
|
+
const r = t ? Xt(t) : null;
|
|
1203
1166
|
r === null ? e.excluded++ : e.values.push(r);
|
|
1204
1167
|
}
|
|
1205
|
-
function
|
|
1168
|
+
function Qt(e, t, n, r) {
|
|
1206
1169
|
return r.origin ? e.table?.id === r.origin.id : `${t}:${n}` === r.grid;
|
|
1207
1170
|
}
|
|
1208
|
-
function
|
|
1171
|
+
function en(e, t, n) {
|
|
1209
1172
|
return n.origin ? n.origin.columnKeys.indexOf(e.table.columnKeys[t] ?? "") : t;
|
|
1210
1173
|
}
|
|
1211
|
-
function
|
|
1212
|
-
const
|
|
1213
|
-
return
|
|
1174
|
+
function tn(e, t, n, r) {
|
|
1175
|
+
const a = r.origin ? fe(e) + t : t, o = en(e, n, r);
|
|
1176
|
+
return a < r.rowStart || a > r.rowEnd || o < r.columnStart || o > r.columnEnd ? null : `${r.grid}:${a}:${o}`;
|
|
1214
1177
|
}
|
|
1215
|
-
function
|
|
1216
|
-
const n = t.origin ?
|
|
1217
|
-
return
|
|
1178
|
+
function nn(e, t) {
|
|
1179
|
+
const n = t.origin ? fe(e) : 0, r = Math.max(0, t.rowStart - n), a = Math.min(e.grid.cells.length, t.rowEnd - n + 1);
|
|
1180
|
+
return a > r ? a : 0;
|
|
1218
1181
|
}
|
|
1219
|
-
async function
|
|
1182
|
+
async function rn(e, t, n, r, a) {
|
|
1220
1183
|
const o = e.grid;
|
|
1221
|
-
if (t > r.maxScanned) throw new
|
|
1222
|
-
const
|
|
1223
|
-
if (
|
|
1224
|
-
const
|
|
1225
|
-
for (let
|
|
1226
|
-
|
|
1184
|
+
if (t > r.maxScanned) throw new b("limit");
|
|
1185
|
+
const l = o.colWidthsMm?.length ?? o.cells.reduce((s, c) => Math.max(s, c.length), 1);
|
|
1186
|
+
if (l > r.maxScanned) throw new b("limit");
|
|
1187
|
+
const i = /* @__PURE__ */ new Map();
|
|
1188
|
+
for (let s = 0; s < t; s++) {
|
|
1189
|
+
s > 0 && s % 2048 === 0 && (await r.yieldToHost(), B(r.signal));
|
|
1227
1190
|
let c = 0;
|
|
1228
|
-
for (const
|
|
1229
|
-
for (await
|
|
1230
|
-
if (c >=
|
|
1231
|
-
const
|
|
1232
|
-
|
|
1233
|
-
for (let f = c; f < c +
|
|
1234
|
-
const g =
|
|
1235
|
-
g &&
|
|
1191
|
+
for (const m of o.cells[s]) {
|
|
1192
|
+
for (await ee(r); c < l && (i.get(c) ?? 0) > s; ) c++;
|
|
1193
|
+
if (c >= l) break;
|
|
1194
|
+
const d = Math.max(1, Math.min(m?.colSpan ?? 1, l - c)), h = Math.min(o.cells.length, s + Math.max(1, m?.rowSpan ?? 1));
|
|
1195
|
+
d > 1 && await ee(r, d - 1);
|
|
1196
|
+
for (let f = c; f < c + d; f++) i.set(f, h);
|
|
1197
|
+
const g = tn(e, s, c, n);
|
|
1198
|
+
g && Zt(a, m, g), c += d;
|
|
1236
1199
|
}
|
|
1237
1200
|
}
|
|
1238
1201
|
}
|
|
1239
|
-
async function
|
|
1202
|
+
async function an(e, t, n) {
|
|
1240
1203
|
const r = { values: [], seen: /* @__PURE__ */ new Set(), excluded: 0, selected: 0 };
|
|
1241
|
-
for (let
|
|
1242
|
-
await
|
|
1243
|
-
const o = e.pages[
|
|
1244
|
-
for (let
|
|
1245
|
-
await
|
|
1246
|
-
const
|
|
1247
|
-
if (!
|
|
1248
|
-
const
|
|
1249
|
-
|
|
1204
|
+
for (let a = 0; a < e.pages.length; a++) {
|
|
1205
|
+
await ee(n);
|
|
1206
|
+
const o = e.pages[a];
|
|
1207
|
+
for (let l = 0; l < o.components.length; l++) {
|
|
1208
|
+
await ee(n);
|
|
1209
|
+
const i = o.components[l];
|
|
1210
|
+
if (!i.grid || !Qt(i, a, l, t) || i.table && i.table.role !== "body") continue;
|
|
1211
|
+
const s = nn(i, t);
|
|
1212
|
+
s && await rn(i, s, t, n, r);
|
|
1250
1213
|
}
|
|
1251
1214
|
}
|
|
1252
1215
|
return r;
|
|
1253
1216
|
}
|
|
1254
|
-
function
|
|
1255
|
-
if (!Number.isFinite(e)) throw new
|
|
1217
|
+
function V(e) {
|
|
1218
|
+
if (!Number.isFinite(e)) throw new b("overflow");
|
|
1256
1219
|
return e;
|
|
1257
1220
|
}
|
|
1258
|
-
function
|
|
1221
|
+
function on(e) {
|
|
1259
1222
|
let t = 0, n = 0;
|
|
1260
1223
|
for (const r of e) {
|
|
1261
|
-
const
|
|
1262
|
-
n = o - t -
|
|
1224
|
+
const a = r - n, o = V(t + a);
|
|
1225
|
+
n = o - t - a, t = o;
|
|
1263
1226
|
}
|
|
1264
1227
|
return t;
|
|
1265
1228
|
}
|
|
1266
|
-
async function
|
|
1229
|
+
async function Ee(e, t) {
|
|
1267
1230
|
let n = [...e], r = new Array(e.length);
|
|
1268
1231
|
for (let o = 1; o < e.length; o *= 2) {
|
|
1269
|
-
for (let
|
|
1270
|
-
const
|
|
1271
|
-
let c =
|
|
1272
|
-
for (let
|
|
1273
|
-
r[
|
|
1232
|
+
for (let l = 0; l < e.length; l += o * 2) {
|
|
1233
|
+
const i = Math.min(l + o, e.length), s = Math.min(l + o * 2, e.length);
|
|
1234
|
+
let c = l, m = i;
|
|
1235
|
+
for (let d = l; d < s; d++)
|
|
1236
|
+
r[d] = m >= s || c < i && n[c] <= n[m] ? n[c++] : n[m++], d % 2048 === 0 && (await t.yieldToHost(), B(t.signal));
|
|
1274
1237
|
}
|
|
1275
1238
|
[n, r] = [r, n];
|
|
1276
1239
|
}
|
|
1277
|
-
const
|
|
1278
|
-
return n.length % 2 ? n[
|
|
1240
|
+
const a = Math.floor(n.length / 2);
|
|
1241
|
+
return n.length % 2 ? n[a] : V(n[a - 1] / 2 + n[a] / 2);
|
|
1279
1242
|
}
|
|
1280
|
-
function
|
|
1281
|
-
const t =
|
|
1243
|
+
function sn(e) {
|
|
1244
|
+
const t = on(e);
|
|
1282
1245
|
let n = 1 / 0, r = -1 / 0;
|
|
1283
|
-
for (const
|
|
1284
|
-
n = Math.min(n,
|
|
1246
|
+
for (const a of e)
|
|
1247
|
+
n = Math.min(n, a), r = Math.max(r, a);
|
|
1285
1248
|
return { SUM: t, AVERAGE: t / e.length, AVG: t / e.length, MIN: n, MAX: r, COUNT: e.length };
|
|
1286
1249
|
}
|
|
1287
|
-
function
|
|
1288
|
-
if (typeof e != "string" || e.length > 256) throw new
|
|
1250
|
+
function ln(e, t) {
|
|
1251
|
+
if (typeof e != "string" || e.length > 256) throw new b("expression");
|
|
1289
1252
|
const n = e.toUpperCase().match(/(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?|[A-Z_]+|[()+\-*/]|\S/g) ?? [];
|
|
1290
|
-
if (!n.length || n.length > 64) throw new
|
|
1253
|
+
if (!n.length || n.length > 64) throw new b("expression");
|
|
1291
1254
|
let r = 0;
|
|
1292
|
-
function i
|
|
1293
|
-
if (
|
|
1294
|
-
const
|
|
1295
|
-
if (
|
|
1296
|
-
if (
|
|
1297
|
-
const c = o(0,
|
|
1298
|
-
if (n[r++] !== ")") throw new
|
|
1255
|
+
function a(i) {
|
|
1256
|
+
if (i > 16) throw new b("expression");
|
|
1257
|
+
const s = n[r++];
|
|
1258
|
+
if (s === "+" || s === "-") return (s === "-" ? -1 : 1) * a(i + 1);
|
|
1259
|
+
if (s === "(") {
|
|
1260
|
+
const c = o(0, i + 1);
|
|
1261
|
+
if (n[r++] !== ")") throw new b("expression");
|
|
1299
1262
|
return c;
|
|
1300
1263
|
}
|
|
1301
|
-
if (
|
|
1302
|
-
if (
|
|
1303
|
-
throw new
|
|
1264
|
+
if (s && /^(?:SUM|AVERAGE|AVG|MIN|MAX|COUNT|MEDIAN)$/.test(s) && Object.prototype.hasOwnProperty.call(t, s)) return V(t[s]);
|
|
1265
|
+
if (s && /^(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?$/.test(s)) return V(Number(s));
|
|
1266
|
+
throw new b("expression");
|
|
1304
1267
|
}
|
|
1305
|
-
function o(
|
|
1306
|
-
let c =
|
|
1268
|
+
function o(i, s) {
|
|
1269
|
+
let c = a(s);
|
|
1307
1270
|
for (; r < n.length; ) {
|
|
1308
|
-
const
|
|
1309
|
-
if (!
|
|
1271
|
+
const m = n[r], d = m === "+" || m === "-" ? 1 : m === "*" || m === "/" ? 2 : 0;
|
|
1272
|
+
if (!d || d < i) break;
|
|
1310
1273
|
r++;
|
|
1311
|
-
const h = o(
|
|
1312
|
-
if (
|
|
1313
|
-
c =
|
|
1274
|
+
const h = o(d + 1, s + 1);
|
|
1275
|
+
if (m === "/" && h === 0) throw new b("division");
|
|
1276
|
+
c = V(m === "+" ? c + h : m === "-" ? c - h : m === "*" ? c * h : c / h);
|
|
1314
1277
|
}
|
|
1315
1278
|
return c;
|
|
1316
1279
|
}
|
|
1317
|
-
const
|
|
1318
|
-
if (r !== n.length) throw new
|
|
1319
|
-
return
|
|
1280
|
+
const l = o(1, 0);
|
|
1281
|
+
if (r !== n.length) throw new b("expression");
|
|
1282
|
+
return l;
|
|
1320
1283
|
}
|
|
1321
|
-
function
|
|
1284
|
+
function cn(e) {
|
|
1322
1285
|
const t = e.maxCells ?? 1e5, n = e.maxScannedCells ?? 2e5, r = e.precision ?? 2;
|
|
1323
|
-
if (![t, n].every((
|
|
1324
|
-
if (!Number.isInteger(r) || r < 0 || r > 12) throw new
|
|
1286
|
+
if (![t, n].every((a) => Number.isSafeInteger(a) && a >= 1 && a <= 2e6)) throw new b("limit");
|
|
1287
|
+
if (!Number.isInteger(r) || r < 0 || r > 12) throw new b("precision");
|
|
1325
1288
|
return { maxCells: t, maxScanned: n, precision: r };
|
|
1326
1289
|
}
|
|
1327
|
-
async function
|
|
1328
|
-
const r =
|
|
1329
|
-
|
|
1330
|
-
const o = await
|
|
1331
|
-
if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(
|
|
1332
|
-
let
|
|
1333
|
-
if (
|
|
1290
|
+
async function Un(e, t, n = {}) {
|
|
1291
|
+
const r = cn(n), a = { scanned: 0, maxScanned: r.maxScanned, signal: n.signal, yieldToHost: n.yieldToHost ?? (() => new Promise((s) => setTimeout(s, 0))) };
|
|
1292
|
+
B(a.signal);
|
|
1293
|
+
const o = await an(e, Kt(e, t, r.maxCells), a), l = n.operation ?? "sum";
|
|
1294
|
+
if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(l)) throw new b("expression");
|
|
1295
|
+
let i = null;
|
|
1296
|
+
if (l === "count") i = o.values.length;
|
|
1334
1297
|
else if (o.values.length)
|
|
1335
|
-
if (
|
|
1298
|
+
if (l === "median") i = await Ee(o.values, a);
|
|
1336
1299
|
else {
|
|
1337
|
-
const
|
|
1338
|
-
|
|
1300
|
+
const s = sn(o.values);
|
|
1301
|
+
l === "expression" ? (/\bMEDIAN\b/i.test(n.expression ?? "") && (s.MEDIAN = await Ee(o.values, a)), i = ln(n.expression ?? "", s)) : i = s[l.toUpperCase()];
|
|
1339
1302
|
}
|
|
1340
|
-
if (
|
|
1341
|
-
return { value:
|
|
1303
|
+
if (B(a.signal), i !== null && Number.isInteger(i) && !Number.isSafeInteger(i)) throw new b("precision");
|
|
1304
|
+
return { value: i, formatted: i === null ? "—" : i.toFixed(r.precision), numericCells: o.values.length, excludedCells: o.excluded, selectedCells: o.selected, precision: r.precision };
|
|
1305
|
+
}
|
|
1306
|
+
class A extends Error {
|
|
1307
|
+
constructor(t, n) {
|
|
1308
|
+
super(t), this.path = n, this.code = "label-sheet", this.name = "LabelSheetError";
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
function X(e) {
|
|
1312
|
+
if (e?.aborted) {
|
|
1313
|
+
const t = new Error("标签拼版已取消");
|
|
1314
|
+
throw t.name = "AbortError", t;
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
function O(e, t, n = !1) {
|
|
1318
|
+
if (!Number.isFinite(e) || e <= 0 || n && !Number.isSafeInteger(e)) throw new A("应为正有限数字,数量应为安全整数", t);
|
|
1319
|
+
return e;
|
|
1320
|
+
}
|
|
1321
|
+
function Se(e, t) {
|
|
1322
|
+
if (!Number.isFinite(e) || e < 0) throw new A("应为非负有限数字", t);
|
|
1323
|
+
return e;
|
|
1324
|
+
}
|
|
1325
|
+
function mn(e) {
|
|
1326
|
+
const t = typeof e.marginMm == "object" ? e.marginMm : { top: e.marginMm ?? 0, left: e.marginMm ?? 0, bottom: e.marginMm ?? 0, right: e.marginMm ?? 0 }, n = typeof e.gapMm == "object" ? e.gapMm : { horizontal: e.gapMm ?? 0, vertical: e.gapMm ?? 0 };
|
|
1327
|
+
for (const r of ["top", "left", "bottom", "right"]) Se(t?.[r], `$.marginMm.${r}`);
|
|
1328
|
+
for (const r of ["horizontal", "vertical"]) Se(n?.[r], `$.gapMm.${r}`);
|
|
1329
|
+
return { margin: t, gap: n };
|
|
1330
|
+
}
|
|
1331
|
+
function dn(e) {
|
|
1332
|
+
const t = e.paper === void 0 || e.paper === "a4" ? { widthMm: 210, heightMm: 297 } : e.paper;
|
|
1333
|
+
O(t.widthMm, "$.paper.widthMm"), O(t.heightMm, "$.paper.heightMm");
|
|
1334
|
+
const n = O(e.columns, "$.columns", !0), r = O(e.rows, "$.rows", !0), a = n * r;
|
|
1335
|
+
if (a > 1e3) throw new A("每张纸不能超过 1000 个位置", "$.columns");
|
|
1336
|
+
const { margin: o, gap: l } = mn(e), i = e.startSlot ?? 0, s = e.offsetMm ?? { x: 0, y: 0 };
|
|
1337
|
+
if (!Number.isSafeInteger(i) || i < 0 || i >= a) throw new A("起始位置应在首张纸的有效位置内", "$.startSlot");
|
|
1338
|
+
if (!Number.isFinite(s.x) || !Number.isFinite(s.y)) throw new A("校准偏移应为有限毫米值", "$.offsetMm");
|
|
1339
|
+
return { paper: t, columns: n, rows: r, capacity: a, margin: o, gap: l, startSlot: i, offset: s };
|
|
1340
|
+
}
|
|
1341
|
+
function Ge(e) {
|
|
1342
|
+
return 1 + (e.grid?.cells.reduce((t, n) => t + n.length + 1 + n.reduce((r, a) => r + (a?.children?.reduce((o, l) => o + Ge(l), 0) ?? 0), 0), 0) ?? 0);
|
|
1343
|
+
}
|
|
1344
|
+
function hn(e, t, n) {
|
|
1345
|
+
if (!Je(e).ok) throw new A("标签计划无效", "$.plan");
|
|
1346
|
+
const r = e.pages[0];
|
|
1347
|
+
if (!r) return;
|
|
1348
|
+
const { paper: a, columns: o, rows: l, margin: i, gap: s, offset: c } = n;
|
|
1349
|
+
if (i.left + c.x < 0 || i.top + c.y < 0 || i.left + c.x + o * r.pageWidthMm + (o - 1) * s.horizontal + i.right > a.widthMm + 1e-6 || i.top + c.y + l * r.pageHeightMm + (l - 1) * s.vertical + i.bottom > a.heightMm + 1e-6) throw new A("标签、间距、边距及校准偏移超过纸张尺寸;不会自动缩小标签", "$.paper");
|
|
1350
|
+
let m = 0;
|
|
1351
|
+
for (const [d, h] of e.pages.entries()) {
|
|
1352
|
+
if (X(t.signal), h.layout === "wide" || h.pageWidthMm !== r.pageWidthMm || h.pageHeightMm !== r.pageHeightMm) throw new A("拼版需要尺寸相同的固定标签页面", `$.pages.${d}`);
|
|
1353
|
+
if (m += h.components.reduce((g, f) => g + Ge(f), 0), m > O(t.maxComponents ?? 25e4, "$.maxComponents", !0)) throw new A("拼版组件总量超过预算", "$.maxComponents");
|
|
1354
|
+
for (const g of h.components) if (g.leftMm < 0 || g.topMm < 0 || g.leftMm + g.widthMm > h.pageWidthMm + 1e-6 || g.topMm + g.heightMm > h.pageHeightMm + 1e-6) throw new A("标签内容超出标签边界", `$.pages.${d}.components`);
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
function Gn(e, t) {
|
|
1358
|
+
X(t.signal);
|
|
1359
|
+
const n = dn(t), { paper: r, columns: a, capacity: o, margin: l, gap: i, startSlot: s, offset: c } = n, m = e.pages.length ? Math.ceil((s + e.pages.length) / o) : 0;
|
|
1360
|
+
if (m > O(t.maxSheets ?? 1e4, "$.maxSheets", !0)) throw new A("拼版纸张数量超过预算", "$.maxSheets");
|
|
1361
|
+
O(t.maxComponents ?? 25e4, "$.maxComponents", !0), hn(e, t, n);
|
|
1362
|
+
const d = Qe(e, { maxBytes: O(t.maxSnapshotBytes ?? 64e6, "$.maxSnapshotBytes", !0), check: () => X(t.signal), error: (g, f) => new A(f, "$.maxSnapshotBytes") }), h = Array.from({ length: m }, () => ({ pageWidthMm: r.widthMm, pageHeightMm: r.heightMm, components: [], meta: { labelSheet: { columns: a, rows: n.rows, slots: [] } } }));
|
|
1363
|
+
for (const [g, f] of d.pages.entries()) {
|
|
1364
|
+
X(t.signal);
|
|
1365
|
+
const w = s + g, C = w % o, x = h[Math.floor(w / o)], v = l.left + c.x + C % a * (f.pageWidthMm + i.horizontal), R = l.top + c.y + Math.floor(C / a) * (f.pageHeightMm + i.vertical), H = { sourcePageIndex: g, slotIndex: C, xMm: v, yMm: R, widthMm: f.pageWidthMm, heightMm: f.pageHeightMm, ...f.meta ? { sourceMeta: f.meta } : {} };
|
|
1366
|
+
x.meta.labelSheet.slots.push(H), x.components.push(...f.components.map((N) => ({ ...N, leftMm: N.leftMm + v, topMm: N.topMm + R, meta: { ...N.meta, labelSheet: H } })));
|
|
1367
|
+
}
|
|
1368
|
+
return { ...d, pages: h };
|
|
1342
1369
|
}
|
|
1343
1370
|
export {
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1371
|
+
lr as CSS_DPI,
|
|
1372
|
+
Yn as DEFAULT_BORDER_PT,
|
|
1373
|
+
te as DEFAULT_FONT_FAMILY,
|
|
1374
|
+
Kn as DEFAULT_FONT_PT,
|
|
1375
|
+
kr as DEFAULT_LABEL_PAGE_LIMIT,
|
|
1376
|
+
Jn as DEFAULT_STROKE_COLOR,
|
|
1377
|
+
Te as DEFAULT_TEXT_COLOR,
|
|
1378
|
+
Xn as LINE_HEIGHT,
|
|
1379
|
+
A as LabelSheetError,
|
|
1380
|
+
cr as MM_PER_INCH,
|
|
1381
|
+
Kr as OutputAssetError,
|
|
1382
|
+
et as OutputFidelityError,
|
|
1383
|
+
Z as PAPER_SIZES,
|
|
1384
|
+
$t as PageBuilder,
|
|
1385
|
+
Ir as PaginateCellLimitError,
|
|
1386
|
+
Nr as PaginatePageLimitError,
|
|
1387
|
+
gr as RENDER_PLAN_SCHEMA_VERSION,
|
|
1388
|
+
ur as REPORT_TEMPLATE_DOCUMENT_VERSION,
|
|
1389
|
+
er as ReportBindingError,
|
|
1390
|
+
b as ReportCalculationError,
|
|
1391
|
+
rt as ReportCellEditError,
|
|
1392
|
+
Wt as ReportCellFieldError,
|
|
1393
|
+
Xr as ReportDrillError,
|
|
1394
|
+
ra as ReportParamValidationError,
|
|
1395
|
+
ce as ReportSourceError,
|
|
1396
|
+
ke as ReportTemplateError,
|
|
1397
|
+
D as ReportTemplateStoreError,
|
|
1398
|
+
Zn as SCHEMA_VERSION_MACH,
|
|
1399
|
+
At as TemplateBuilder,
|
|
1400
|
+
_a as TreeRowLimitError,
|
|
1401
|
+
Na as applyReportCellEdit,
|
|
1402
|
+
La as applyReportCellEditBatch,
|
|
1403
|
+
Pa as applyReportDocumentStyle,
|
|
1404
|
+
Lr as applyReportEditResult,
|
|
1405
|
+
Dr as applyReportSourceMetadata,
|
|
1406
|
+
pr as assertRenderPlan,
|
|
1407
|
+
aa as assertReportParams,
|
|
1408
|
+
Un as calculateReportSelection,
|
|
1409
|
+
Aa as captureTemplateFragment,
|
|
1410
|
+
Cr as charWidthEm,
|
|
1411
|
+
T as classOf,
|
|
1412
|
+
fa as cloneReportTemplate,
|
|
1413
|
+
Sa as collectTemplateOutline,
|
|
1414
|
+
Ln as columnsFromContract,
|
|
1415
|
+
vt as computePageWindow,
|
|
1416
|
+
Fr as countTemplatePages,
|
|
1417
|
+
Rr as createCanvasMeasurer,
|
|
1418
|
+
In as createCanvasPager,
|
|
1419
|
+
Pr as createHeuristicMeasurer,
|
|
1420
|
+
Fn as createLabelTemplate,
|
|
1421
|
+
ua as createLocalTemplateCatalog,
|
|
1422
|
+
Wn as createMemoryTemplateStore,
|
|
1423
|
+
Hn as createProviderReport,
|
|
1424
|
+
Da as createReportCellEdit,
|
|
1425
|
+
Fa as createReportCellEditBatch,
|
|
1426
|
+
Oa as createReportCellResolver,
|
|
1427
|
+
Zr as createReportDrillRequest,
|
|
1428
|
+
Or as createReportEditSession,
|
|
1429
|
+
Hr as createReportSource,
|
|
1430
|
+
Dn as createTableTemplate,
|
|
1431
|
+
Nn as createTemplate,
|
|
1432
|
+
zn as createTemplateManager,
|
|
1433
|
+
wr as createTemplateRegistry,
|
|
1434
|
+
Ua as createTreeTable,
|
|
1435
|
+
Sr as datasetJsonSchema,
|
|
1436
|
+
On as defineLabelReport,
|
|
1437
|
+
Ze as defineReport,
|
|
1438
|
+
br as defineReportTemplate,
|
|
1439
|
+
pa as diffReportTemplates,
|
|
1440
|
+
zr as estimateListLayoutCells,
|
|
1441
|
+
tr as evalStyleRule,
|
|
1442
|
+
ln as evaluateReportAggregateExpression,
|
|
1443
|
+
Ha as formatReportCellEdit,
|
|
1444
|
+
Bn as formatReportClipboard,
|
|
1445
|
+
ia as formatReportDateRange,
|
|
1446
|
+
nr as formatValue,
|
|
1447
|
+
za as getReportCellContext,
|
|
1448
|
+
Wr as getReportEditSession,
|
|
1449
|
+
ya as hasValidDataExplanation,
|
|
1450
|
+
le as heuristicMeasurer,
|
|
1451
|
+
Gn as imposeLabelSheets,
|
|
1452
|
+
$a as insertTemplateFragment,
|
|
1453
|
+
qr as inspectOutputCapabilities,
|
|
1454
|
+
Ta as inspectTemplateFieldUsage,
|
|
1455
|
+
ka as inspectTemplateFragmentBindings,
|
|
1456
|
+
re as isImageBackedComponent,
|
|
1457
|
+
va as isReportDataTarget,
|
|
1458
|
+
oa as isReportDate,
|
|
1459
|
+
sa as isReportMonth,
|
|
1460
|
+
xa as isReportValueState,
|
|
1461
|
+
la as isReportYear,
|
|
1462
|
+
Ae as isRichText,
|
|
1463
|
+
Qr as matchReportDrillActions,
|
|
1464
|
+
he as measurePageSizePx,
|
|
1465
|
+
Ar as measureTextMm,
|
|
1466
|
+
Re as mergeComponentStyles,
|
|
1467
|
+
se as mmToPx,
|
|
1468
|
+
mr as mmToPxFactor,
|
|
1469
|
+
Br as paginateTemplate,
|
|
1470
|
+
jr as paginateTemplatePages,
|
|
1471
|
+
rr as parseDateLocal,
|
|
1472
|
+
_n as parseReportCellFieldInput,
|
|
1473
|
+
at as parseReportCellInput,
|
|
1474
|
+
jn as parseReportClipboard,
|
|
1475
|
+
ca as parseReportDateRange,
|
|
1476
|
+
U as parseReportTemplate,
|
|
1477
|
+
Pn as planFontSizePx,
|
|
1478
|
+
_r as projectListColumns,
|
|
1479
|
+
W as ptToPx,
|
|
1480
|
+
dr as pxToMm,
|
|
1481
|
+
Ur as registerReportEditSession,
|
|
1482
|
+
Gr as relocateReportCellEdits,
|
|
1483
|
+
Oe as renderComponent,
|
|
1484
|
+
pt as renderPage,
|
|
1485
|
+
Rn as renderPlan,
|
|
1486
|
+
$n as renderPlanToCanvas,
|
|
1487
|
+
kn as renderPlanToCanvasAsync,
|
|
1488
|
+
An as renderPlanToImages,
|
|
1489
|
+
Wa as reportCellEditKey,
|
|
1490
|
+
q as reportOutputDiagnostics,
|
|
1491
|
+
ma as reportParamsJsonSchema,
|
|
1492
|
+
Ce as resolveBoxBorders,
|
|
1493
|
+
ar as resolveComponentBinding,
|
|
1452
1494
|
_ as resolveFontSize,
|
|
1453
|
-
|
|
1454
|
-
|
|
1495
|
+
Ne as resolveGridLayout,
|
|
1496
|
+
ne as resolveLineHeight,
|
|
1455
1497
|
_e as resolvePaper,
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1498
|
+
me as resolvePlanAssets,
|
|
1499
|
+
ea as resolveReportDrillReturn,
|
|
1500
|
+
G as resolveStroke,
|
|
1501
|
+
Pe as resolveTextColor,
|
|
1502
|
+
wa as reviewReportTemplate,
|
|
1503
|
+
ba as reviewReportTemplateAsync,
|
|
1504
|
+
j as round,
|
|
1505
|
+
Mr as serializeReportTemplate,
|
|
1506
|
+
Ba as summarizeReportCellEdits,
|
|
1507
|
+
Ca as templatePathLocation,
|
|
1508
|
+
ir as toExcelNumberFormat,
|
|
1509
|
+
or as toNumber,
|
|
1510
|
+
yr as validateComponent,
|
|
1511
|
+
Xe as validateDatasetRows,
|
|
1512
|
+
vr as validatePage,
|
|
1513
|
+
Je as validateRenderPlan,
|
|
1514
|
+
Yt as validateReportCellFieldDefinition,
|
|
1515
|
+
ta as validateReportDrillActions,
|
|
1516
|
+
da as validateReportParamDefinitions,
|
|
1517
|
+
ha as validateReportParams,
|
|
1518
|
+
$e as validateReportTemplate,
|
|
1519
|
+
xr as validateReportTemplateDocument,
|
|
1520
|
+
Ga as validateTreeOptions,
|
|
1521
|
+
Ie as wrapText
|
|
1476
1522
|
};
|