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