@agile-team/mach-report 2.6.1 → 2.7.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 +37 -4
- package/dist/ReportPreview-BdvoqdOd.cjs +6 -0
- package/dist/ReportPreview-COFkbeEM.js +3719 -0
- package/dist/{assets-NVA_sftu.js → assets-B9qJku3V.js} +54 -57
- package/dist/assets-RZan7EyL.cjs +1 -0
- package/dist/capabilities-joSutDF8.js +63 -0
- package/dist/capabilities-xGTpnPjJ.cjs +1 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +869 -753
- package/dist/designer.d.ts +869 -753
- package/dist/designer.js +490 -234
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +86 -3
- package/dist/index.d.ts +86 -3
- package/dist/index.js +582 -508
- package/dist/pdf.cjs +30 -30
- package/dist/pdf.d.cts +11 -3
- package/dist/pdf.d.ts +11 -3
- package/dist/pdf.js +1501 -1500
- package/dist/{plugin-BqBkn_kI.cjs → plugin-9t_ZFwhz.cjs} +1 -1
- package/dist/{plugin-Ds10VnQO.js → plugin-s8Ay8kKk.js} +1 -1
- package/dist/progress-DD964VAB.js +102 -0
- package/dist/progress-KvhwXZ1Q.cjs +1 -0
- package/dist/{report-source-B9bENO0F.js → report-source-BXHNy_AD.js} +337 -332
- package/dist/report-source-CCAvFE3t.cjs +1 -0
- package/dist/server/node.d.cts +26 -3
- package/dist/server/node.d.ts +26 -3
- package/dist/server-node.cjs +1 -1
- package/dist/server-node.js +125 -92
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +28 -3
- package/dist/server.d.ts +28 -3
- package/dist/server.js +172 -164
- package/dist/style.css +1 -1
- package/dist/task-events-DQ276fn2.cjs +1 -0
- package/dist/task-events-Dpsvf_t2.js +47 -0
- package/dist/vue/async.d.cts +1507 -2083
- package/dist/vue/async.d.ts +1507 -2083
- package/dist/vue/index.d.cts +2376 -3310
- package/dist/vue/index.d.ts +2376 -3310
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +131 -107
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +26 -3
- package/dist/worker.d.ts +26 -3
- package/dist/worker.js +110 -85
- package/dist/xlsx.cjs +14 -14
- package/dist/xlsx.d.cts +11 -3
- package/dist/xlsx.d.ts +11 -3
- package/dist/xlsx.js +656 -652
- package/package.json +2 -2
- package/dist/ReportPreview-Dk-28QAi.js +0 -2946
- package/dist/ReportPreview-FSvcBLjH.cjs +0 -6
- package/dist/assets-66UBlhES.cjs +0 -1
- package/dist/capabilities-CNjIirfo.js +0 -36
- package/dist/capabilities-D4xeVYSR.cjs +0 -1
- package/dist/grid-geometry-BNptEcMm.js +0 -65
- package/dist/grid-geometry-CZ_cYB6O.cjs +0 -1
- package/dist/report-source-BbNkkBDy.cjs +0 -1
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { i as J, D as
|
|
2
|
-
import { c as
|
|
3
|
-
import { v as
|
|
4
|
-
import { P as
|
|
5
|
-
import { r as
|
|
6
|
-
import { C as
|
|
7
|
-
import { a as
|
|
8
|
-
import { h as
|
|
9
|
-
import { c as
|
|
10
|
-
import { r as
|
|
11
|
-
import { r as
|
|
12
|
-
import { O as
|
|
13
|
-
import { r as
|
|
14
|
-
import { i as
|
|
15
|
-
import { c as
|
|
16
|
-
import { p as
|
|
17
|
-
import { R as
|
|
18
|
-
import { R as
|
|
19
|
-
import { f as
|
|
20
|
-
const
|
|
1
|
+
import { i as J, D as Y, a as Me, b as xe } from "./render-plan-uzZYYSy1.js";
|
|
2
|
+
import { c as On, d as zn, e as jn, L as Hn, R as Wn, S as Bn } from "./render-plan-uzZYYSy1.js";
|
|
3
|
+
import { v as Ge } from "./report-source-BXHNy_AD.js";
|
|
4
|
+
import { P as Kn, R as Vn, c as qn, d as Gn, a as Un, e as Jn, f as Yn, p as Xn, b as Qn, t as Zn, g as er } from "./report-source-BXHNy_AD.js";
|
|
5
|
+
import { r as O, a as z, b as X, c as H, d as Te, m as re, e as Ee, p as D, f as Se, P as G } from "./style-Dv5o_x6b.js";
|
|
6
|
+
import { C as nr, M as rr, g as ir, h as or } from "./style-Dv5o_x6b.js";
|
|
7
|
+
import { a as sr, v as lr, b as cr, c as dr } from "./validate-S6CgIm5d.js";
|
|
8
|
+
import { h as ie, w as Ce } from "./textwrap-DOl04hCQ.js";
|
|
9
|
+
import { c as mr, a as fr, b as hr, m as gr } from "./textwrap-DOl04hCQ.js";
|
|
10
|
+
import { r as W, o as Ue } from "./progress-DD964VAB.js";
|
|
11
|
+
import { r as Pe, a as oe } from "./assets-B9qJku3V.js";
|
|
12
|
+
import { O as wr } from "./assets-B9qJku3V.js";
|
|
13
|
+
import { r as B, n as ke, O as Je } from "./capabilities-joSutDF8.js";
|
|
14
|
+
import { i as vr } from "./capabilities-joSutDF8.js";
|
|
15
|
+
import { c as Ye } from "./page-window-index-CIuT4BAv.js";
|
|
16
|
+
import { p as ne } from "./template-registry-NpOakidD.js";
|
|
17
|
+
import { R as Mr, a as xr, c as Tr, d as Er, s as Sr, v as Cr, b as Pr } from "./template-registry-NpOakidD.js";
|
|
18
|
+
import { R as Rr, a as Ir, i as Ar, r as $r, v as Nr, b as Lr } from "./param-validation-BWNjLcN0.js";
|
|
19
|
+
import { f as Xe, i as Qe } from "./number-format-BA_KwrZe.js";
|
|
20
|
+
const Ze = {
|
|
21
21
|
root: "mr-root",
|
|
22
22
|
page: "mr-page",
|
|
23
23
|
comp: "mr-comp",
|
|
@@ -34,10 +34,10 @@ const Je = {
|
|
|
34
34
|
cell: "mr-cell",
|
|
35
35
|
unknown: "mr-unknown"
|
|
36
36
|
};
|
|
37
|
-
function
|
|
38
|
-
return t?.classNames?.[e] ??
|
|
37
|
+
function S(e, t) {
|
|
38
|
+
return t?.classNames?.[e] ?? Ze[e];
|
|
39
39
|
}
|
|
40
|
-
class
|
|
40
|
+
class et {
|
|
41
41
|
constructor() {
|
|
42
42
|
this.props = [];
|
|
43
43
|
}
|
|
@@ -45,7 +45,7 @@ class qe {
|
|
|
45
45
|
return n == null || n === !1 || n === "" ? this : (this.props.push([t, String(n)]), this);
|
|
46
46
|
}
|
|
47
47
|
mm(t, n, r, i = 2) {
|
|
48
|
-
return this.add(t, `${
|
|
48
|
+
return this.add(t, `${O(re(n, r), i)}px`);
|
|
49
49
|
}
|
|
50
50
|
toString() {
|
|
51
51
|
let t = "";
|
|
@@ -58,145 +58,145 @@ class qe {
|
|
|
58
58
|
n && (t.style.cssText = n);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
function
|
|
62
|
-
return new
|
|
61
|
+
function y(e, t = "unset") {
|
|
62
|
+
return new et().add("all", t).add("display", e).add("box-sizing", "border-box");
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function Re(e, t, n) {
|
|
65
65
|
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(X(t))).add("text-align", t.align);
|
|
66
|
-
const r =
|
|
67
|
-
e.add("font-size", `${
|
|
66
|
+
const r = z(t, n);
|
|
67
|
+
e.add("font-size", `${O(r.fontSizePx, 2)}px`);
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function tt(e, t, n) {
|
|
70
70
|
const r = t.style ?? {};
|
|
71
|
-
|
|
71
|
+
Re(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);
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function nt(e, t, n, r, i, l) {
|
|
74
74
|
const o = e.cell, a = l.createElement("td");
|
|
75
|
-
a.className =
|
|
76
|
-
const s =
|
|
77
|
-
|
|
75
|
+
a.className = S("cell", i), a.dataset.mrRowIndex = String(e.ri), a.dataset.mrColumnIndex = String(e.ci), a.setAttribute("role", t.table?.role === "header" ? "columnheader" : "cell"), o.colSpan && (a.colSpan = o.colSpan), o.rowSpan && (a.rowSpan = o.rowSpan);
|
|
76
|
+
const s = Ee(t.style, o.style), c = y("block").add("position", "absolute").mm("left", e.xMm, r).mm("top", e.yMm, r).mm("width", e.widthMm, r).mm("height", e.heightMm, r).add("background-color", s.backgroundColor).add("vertical-align", s.verticalAlign ?? "middle");
|
|
77
|
+
Re(c, s, r), c.applyTo(a);
|
|
78
78
|
const d = l.createElement("div");
|
|
79
|
-
d.className = "mr-cell-content",
|
|
80
|
-
for (const u of o.children ?? []) d.appendChild(
|
|
79
|
+
d.className = "mr-cell-content", y("flex").add("position", "absolute").mm("left", n, r).mm("right", n, r).mm("top", n, r).mm("bottom", n, r).add("flex-direction", "column").add("justify-content", s.verticalAlign === "top" ? "flex-start" : s.verticalAlign === "bottom" ? "flex-end" : "center").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(d), o.text != null && d.append(o.text);
|
|
80
|
+
for (const u of o.children ?? []) d.appendChild(Ie(u, r, i, l));
|
|
81
81
|
return a.appendChild(d), a;
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
return
|
|
85
|
-
const l = `${
|
|
83
|
+
function rt(e, t, n, r) {
|
|
84
|
+
return Pe(e, t).map((i) => {
|
|
85
|
+
const l = `${O(i.widthPt * n / 72, 2)}px solid ${i.color}`, o = r.createElement("div");
|
|
86
86
|
o.className = "mr-grid-edge", o.setAttribute("aria-hidden", "true");
|
|
87
87
|
const a = i.kind === "h";
|
|
88
|
-
return
|
|
88
|
+
return y("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", l).applyTo(o), o;
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function it(e, t, n, r, i) {
|
|
92
92
|
const l = i.createElement("table");
|
|
93
|
-
l.className =
|
|
94
|
-
const o =
|
|
95
|
-
|
|
93
|
+
l.className = S("grid", r), l.setAttribute("role", "table"), y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(l);
|
|
94
|
+
const o = W(e, t.widthMm, t.heightMm), a = i.createElement("tbody");
|
|
95
|
+
y("contents").applyTo(a), l.appendChild(a);
|
|
96
96
|
const s = e.cells.map(() => {
|
|
97
97
|
const d = i.createElement("tr");
|
|
98
|
-
return d.className =
|
|
98
|
+
return d.className = S("row", r), d.setAttribute("role", "row"), y("contents").applyTo(d), a.appendChild(d), d;
|
|
99
99
|
});
|
|
100
100
|
for (const d of o.cells)
|
|
101
|
-
s[d.ri].appendChild(
|
|
101
|
+
s[d.ri].appendChild(nt(d, t, e.paddingMm ?? 0.5, n, r, i));
|
|
102
102
|
const c = i.createElement("div");
|
|
103
|
-
return
|
|
103
|
+
return y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(l, ...rt(o, t, n, i)), c;
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function ot(e, t, n, r) {
|
|
106
106
|
const i = r.createElement("div");
|
|
107
|
-
i.className =
|
|
107
|
+
i.className = S("paragraph", n), y("block").add("text-align", e.align).add("line-height", e.lineHeight != null ? String(e.lineHeight) : void 0).mm("margin-top", e.spaceBeforeMm ?? 0, t).mm("margin-bottom", e.spaceAfterMm ?? 0, t).mm("text-indent", e.indentMm ?? 0, t).applyTo(i);
|
|
108
108
|
for (const l of e.segments || []) {
|
|
109
109
|
const o = r.createElement("span");
|
|
110
|
-
o.className =
|
|
111
|
-
const a =
|
|
110
|
+
o.className = S("segment", n), o.textContent = l.kind === "field" ? l.field ?? "" : l.text ?? "";
|
|
111
|
+
const a = y("inline");
|
|
112
112
|
if (l.style) {
|
|
113
113
|
const s = l.style;
|
|
114
|
-
a.add("color", s.color).add("font-family", s.fontFamily).add("font-weight", s.bold != null ? s.bold ? "700" : "400" : void 0).add("font-style", s.italic != null ? s.italic ? "italic" : "normal" : void 0).add("text-decoration", s.underline != null ? s.underline ? "underline" : "none" : void 0), (s.fontSize != null || s.fontSizePx != null) && a.add("font-size", `${
|
|
114
|
+
a.add("color", s.color).add("font-family", s.fontFamily).add("font-weight", s.bold != null ? s.bold ? "700" : "400" : void 0).add("font-style", s.italic != null ? s.italic ? "italic" : "normal" : void 0).add("text-decoration", s.underline != null ? s.underline ? "underline" : "none" : void 0), (s.fontSize != null || s.fontSizePx != null) && a.add("font-size", `${O(z(s, t).fontSizePx, 2)}px`);
|
|
115
115
|
}
|
|
116
116
|
a.applyTo(o), i.appendChild(o);
|
|
117
117
|
}
|
|
118
118
|
return i;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
121
|
-
if (
|
|
120
|
+
function at(e, t, n, r) {
|
|
121
|
+
if (xe(e)) {
|
|
122
122
|
const i = r.createElement("div");
|
|
123
|
-
i.className =
|
|
124
|
-
for (const l of e.richParagraphs) i.appendChild(
|
|
123
|
+
i.className = S("rich", n), y("block").applyTo(i);
|
|
124
|
+
for (const l of e.richParagraphs) i.appendChild(ot(l, t, n, r));
|
|
125
125
|
return i;
|
|
126
126
|
}
|
|
127
127
|
if (Array.isArray(e.lines) && e.lines.length > 0) {
|
|
128
128
|
const i = r.createElement("div");
|
|
129
|
-
i.className =
|
|
129
|
+
i.className = S("lines", n), y("block").applyTo(i);
|
|
130
130
|
for (const l of e.lines) {
|
|
131
131
|
const o = r.createElement("div");
|
|
132
|
-
o.className =
|
|
132
|
+
o.className = S("line", n), o.textContent = l, y("block").add("white-space", "pre").add("min-height", "1lh").applyTo(o), i.appendChild(o);
|
|
133
133
|
}
|
|
134
134
|
return i;
|
|
135
135
|
}
|
|
136
136
|
return e.text ?? "";
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function st(e, t, n, r) {
|
|
139
139
|
const i = r.createElement("div");
|
|
140
|
-
i.className =
|
|
140
|
+
i.className = S("text", n);
|
|
141
141
|
const l = e.style || {};
|
|
142
|
-
return
|
|
142
|
+
return y("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", l.verticalAlign === "middle" ? "center" : l.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(i), i.append(at(e, t, n, r)), i;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function lt(e, t, n) {
|
|
145
145
|
const r = n.createElement("img");
|
|
146
|
-
return r.className =
|
|
146
|
+
return r.className = S("image", t), r.src = e.imageData, y("block").add("width", "100%").add("height", "100%").add("object-fit", "contain").applyTo(r), r.alt = e.kind, r;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function we(e, t, n, r) {
|
|
149
149
|
const i = r.createElement("div");
|
|
150
|
-
i.className =
|
|
151
|
-
const l = e.style || {}, o =
|
|
150
|
+
i.className = S("shape", n);
|
|
151
|
+
const l = e.style || {}, o = H(l), a = Te(l), s = `${O(o.widthPt * t / 72, 2)}px solid ${o.color}`, c = y("block");
|
|
152
152
|
return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (a.top && c.add("border-top", s), a.right && c.add("border-right", s), a.bottom && c.add("border-bottom", s), a.left && c.add("border-left", s)) : e.kind === "ellipse" ? (a.inner && c.add("border", s).add("border-radius", "50%"), l.backgroundColor && c.add("background-color", l.backgroundColor)) : e.kind === "line" && c.add("height", "0").add("border-top", s), c.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), c.applyTo(i), i;
|
|
153
153
|
}
|
|
154
|
-
function
|
|
155
|
-
const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), i =
|
|
154
|
+
function ct(e, t, n) {
|
|
155
|
+
const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), i = re(e.widthMm, t), l = re(e.heightMm, t);
|
|
156
156
|
r.setAttribute("width", String(Math.max(1, i))), r.setAttribute("height", String(Math.max(1, l))), r.setAttribute("aria-hidden", "true"), r.style.overflow = "visible", r.style.display = "block";
|
|
157
157
|
const o = n.createElementNS("http://www.w3.org/2000/svg", "line");
|
|
158
158
|
o.setAttribute("x1", "0"), o.setAttribute("x2", String(i)), o.setAttribute("y1", e.lineDirection === "up" ? String(l) : "0"), o.setAttribute("y2", e.lineDirection === "up" ? "0" : String(l));
|
|
159
|
-
const a =
|
|
159
|
+
const a = H({ ...e.style, borderColor: e.style?.lineColor ?? e.style?.borderColor });
|
|
160
160
|
return o.setAttribute("stroke", a.color), o.setAttribute("stroke-width", String(a.widthPt * t / 72)), r.appendChild(o), r;
|
|
161
161
|
}
|
|
162
|
-
function
|
|
162
|
+
function Ie(e, t, n, r) {
|
|
163
163
|
const i = r.createElement("div");
|
|
164
|
-
i.className = `${
|
|
165
|
-
const l =
|
|
166
|
-
if (
|
|
167
|
-
return i.appendChild(
|
|
164
|
+
i.className = `${S("comp", n)} mr-kind-${e.kind}`;
|
|
165
|
+
const l = y("block").add("position", "absolute").mm("left", e.leftMm, t).mm("top", e.topMm, t).mm("width", e.widthMm, t).mm("height", e.heightMm, t).add("box-sizing", "border-box");
|
|
166
|
+
if (tt(l, e, t), l.applyTo(i), J(e))
|
|
167
|
+
return i.appendChild(lt(e, n, r)), i;
|
|
168
168
|
if (e.kind === "text")
|
|
169
|
-
return i.appendChild(
|
|
169
|
+
return i.appendChild(st(e, t, n, r)), i;
|
|
170
170
|
if (e.grid) {
|
|
171
|
-
const a =
|
|
172
|
-
return a.appendChild(
|
|
171
|
+
const a = we(e, t, n, r);
|
|
172
|
+
return a.appendChild(it(e.grid, e, t, n, r)), i.appendChild(a), i;
|
|
173
173
|
}
|
|
174
174
|
if (e.kind === "line" && e.lineDirection)
|
|
175
|
-
return i.appendChild(
|
|
175
|
+
return i.appendChild(ct(e, t, r)), i;
|
|
176
176
|
if (e.kind === "line" || e.kind === "rect" || e.kind === "ellipse")
|
|
177
|
-
return i.appendChild(
|
|
177
|
+
return i.appendChild(we(e, t, n, r)), i;
|
|
178
178
|
const o = r.createElement("div");
|
|
179
|
-
return o.className =
|
|
179
|
+
return o.className = S("unknown", n), y("block").applyTo(o), o.textContent = e.fallbackText ?? `[${e.kind}]`, o.dataset.mrUnsupported = e.kind, o.setAttribute("role", "note"), i.appendChild(o), i;
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function dt(e, t, n, r) {
|
|
182
182
|
const i = r.createElement("div");
|
|
183
|
-
return i.className =
|
|
184
|
-
const a =
|
|
183
|
+
return i.className = S("page", n), y("block", "initial").add("position", "relative").add("font-family", Y).add("font-size", `${O(z(void 0, t).fontSizePx, 2)}px`).add("line-height", String(X(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", Me).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(i), e.components.forEach((l, o) => {
|
|
184
|
+
const a = Ie(l, t, n, r);
|
|
185
185
|
a.dataset.mrComponentIndex = String(o), i.appendChild(a);
|
|
186
186
|
}), i;
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function hn(e, t, n = {}) {
|
|
189
189
|
const r = n.dpi ?? 96;
|
|
190
|
-
|
|
190
|
+
B(e, "dom", n);
|
|
191
191
|
const i = t.createElement("div");
|
|
192
|
-
return i.className =
|
|
193
|
-
i.appendChild(
|
|
192
|
+
return i.className = S("root", n), y("block").applyTo(i), i.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((l) => {
|
|
193
|
+
i.appendChild(dt(l, r, n, t));
|
|
194
194
|
}), i;
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function R(e) {
|
|
197
197
|
if (e?.aborted) throw e.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
198
198
|
}
|
|
199
|
-
const
|
|
199
|
+
const ut = (e, t) => (R(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e) ? new Promise((n, r) => {
|
|
200
200
|
const i = new Image(), l = () => {
|
|
201
201
|
i.onload = null, i.onerror = null, t?.removeEventListener("abort", o);
|
|
202
202
|
}, o = () => {
|
|
@@ -208,63 +208,63 @@ const at = (e, t) => (A(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.
|
|
|
208
208
|
l(), r(new Error("Image could not be decoded for Canvas output."));
|
|
209
209
|
}, t?.addEventListener("abort", o, { once: !0 }), i.src = e;
|
|
210
210
|
}) : Promise.reject(new TypeError("Canvas imageData must be an image data URL; provide imageLoader for other sources.")));
|
|
211
|
-
function
|
|
212
|
-
return
|
|
211
|
+
function mt(e, t, n) {
|
|
212
|
+
return R(n), n ? new Promise((r, i) => {
|
|
213
213
|
const l = () => i(n.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
214
214
|
n.addEventListener("abort", l, { once: !0 }), Promise.resolve().then(() => e(t, n)).then(r, i).finally(() => n.removeEventListener("abort", l));
|
|
215
215
|
}) : e(t);
|
|
216
216
|
}
|
|
217
|
-
async function
|
|
217
|
+
async function ft(e, t, n) {
|
|
218
218
|
const r = /* @__PURE__ */ new Map();
|
|
219
219
|
for (const i of e.components)
|
|
220
|
-
!J(i) || r.has(i.imageData) || r.set(i.imageData, await
|
|
221
|
-
return
|
|
220
|
+
!J(i) || r.has(i.imageData) || r.set(i.imageData, await mt(t, i.imageData, n));
|
|
221
|
+
return R(n), r;
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function ht(e, t, n, r, i, l) {
|
|
224
224
|
const o = t, a = o.naturalWidth ?? o.width ?? i, s = o.naturalHeight ?? o.height ?? l;
|
|
225
225
|
if (a <= 0 || s <= 0) throw new RangeError("Decoded Canvas image dimensions must be positive.");
|
|
226
226
|
const c = Math.min(i / a, l / s), d = a * c, u = s * c;
|
|
227
227
|
e.drawImage(t, n + (i - d) / 2, r + (l - u) / 2, d, u);
|
|
228
228
|
}
|
|
229
|
-
function
|
|
230
|
-
return
|
|
229
|
+
function gt(e) {
|
|
230
|
+
return Ye(e.pageHeightsPx, e.gapPx).window(e.viewportHeightPx, e.scrollTopPx, e.overscan);
|
|
231
231
|
}
|
|
232
|
-
const
|
|
233
|
-
function
|
|
234
|
-
const n = t / 96 *
|
|
232
|
+
const ae = 96 / 25.4;
|
|
233
|
+
function se(e, t = 96) {
|
|
234
|
+
const n = t / 96 * ae;
|
|
235
235
|
return {
|
|
236
236
|
widthPx: Math.max(1, Math.round(e.pageWidthMm * n)),
|
|
237
237
|
heightPx: Math.max(1, Math.round(e.pageHeightMm * n))
|
|
238
238
|
};
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function Ae(e, t, n, r = 64e6) {
|
|
241
241
|
if (!Number.isFinite(t) || t <= 0 || !Number.isFinite(n) || n <= 0) throw new RangeError("Canvas dpr and dpi must be positive finite numbers.");
|
|
242
242
|
if (!Number.isFinite(r) || r <= 0) throw new RangeError("maxCanvasPixels must be positive and finite.");
|
|
243
|
-
const i =
|
|
243
|
+
const i = se(e, n), l = Math.round(i.widthPx * t), o = Math.round(i.heightPx * t);
|
|
244
244
|
if (!Number.isSafeInteger(l) || !Number.isSafeInteger(o) || l * o > r) throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");
|
|
245
245
|
return { width: l, height: o };
|
|
246
246
|
}
|
|
247
|
-
function
|
|
248
|
-
const i = document.createElement("canvas"), { widthPx: l, heightPx: o } =
|
|
247
|
+
function $e(e, t, n, r) {
|
|
248
|
+
const i = document.createElement("canvas"), { widthPx: l, heightPx: o } = se(e, n), a = Ae(e, t, n, r);
|
|
249
249
|
i.width = a.width, i.height = a.height, i.style.width = `${l}px`, i.style.height = `${o}px`;
|
|
250
250
|
const s = i.getContext("2d");
|
|
251
251
|
if (!s)
|
|
252
252
|
throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
|
|
253
253
|
return s.scale(t, t), s.fillStyle = "#ffffff", s.fillRect(0, 0, l, o), { canvas: i, ctx: s };
|
|
254
254
|
}
|
|
255
|
-
function
|
|
256
|
-
return
|
|
255
|
+
function gn(e, t = 96) {
|
|
256
|
+
return z(e, t).fontSizePx;
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function Ne(e, t, n, r, i, l, o, a = "top") {
|
|
259
259
|
e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSizePx}px ${o}`, "letterSpacing" in e && (e.letterSpacing = "0px"), e.fillStyle = t.color, e.textBaseline = "alphabetic";
|
|
260
260
|
const s = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
|
|
261
261
|
`), d = c.length * s;
|
|
262
262
|
let u = r;
|
|
263
263
|
a === "middle" ? u = r + (l - d) / 2 : a === "bottom" && (u = r + l - d), c.forEach((m, f) => {
|
|
264
|
-
|
|
264
|
+
pt(e, m, t, n, u + f * s + t.fontSizePx * 0.8, i);
|
|
265
265
|
}), e.textAlign = "left";
|
|
266
266
|
}
|
|
267
|
-
function
|
|
267
|
+
function pt(e, t, n, r, i, l) {
|
|
268
268
|
const o = Array.from(t), a = n.letterSpacingPx ?? 0;
|
|
269
269
|
if (!a) {
|
|
270
270
|
e.textAlign = n.align === "center" ? "center" : n.align === "right" ? "right" : "left";
|
|
@@ -279,127 +279,128 @@ function ut(e, t, n, r, i, l) {
|
|
|
279
279
|
e.fillText(u, c + e.measureText(d).width + m * a, i), d += u;
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
for (const a of
|
|
284
|
-
e.strokeStyle = a.color, e.lineWidth =
|
|
282
|
+
function wt(e, t, n, r, i, l, o) {
|
|
283
|
+
for (const a of Pe(t, n))
|
|
284
|
+
e.strokeStyle = a.color, e.lineWidth = D(a.widthPt, o), e.beginPath(), a.kind === "v" ? (e.moveTo(r + a.pos * l, i + a.from * l), e.lineTo(r + a.pos * l, i + a.to * l)) : (e.moveTo(r + a.from * l, i + a.pos * l), e.lineTo(r + a.to * l, i + a.pos * l)), e.stroke();
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function bt(e, t, n, r, i, l) {
|
|
287
287
|
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 + l)), t.bottom && (e.moveTo(n + i, r + l), e.lineTo(n, r + l)), t.left && (e.moveTo(n, r + l), e.lineTo(n, r)), e.stroke();
|
|
288
288
|
}
|
|
289
|
-
function
|
|
290
|
-
const u =
|
|
289
|
+
function vt(e, t, n, r, i, l, o, a, s, c, d) {
|
|
290
|
+
const u = W(t, l / a, o / a);
|
|
291
291
|
for (const f of u.cells) {
|
|
292
|
-
const
|
|
293
|
-
|
|
292
|
+
const h = f.cell.style?.backgroundColor ?? n.style?.backgroundColor;
|
|
293
|
+
h && (e.fillStyle = h, e.fillRect(r + f.xMm * a, i + f.yMm * a, f.widthMm * a, f.heightMm * a));
|
|
294
294
|
}
|
|
295
|
-
|
|
295
|
+
wt(e, u, n, r, i, a, s);
|
|
296
296
|
const m = t.paddingMm ?? 0.5;
|
|
297
297
|
for (const f of u.cells) {
|
|
298
|
-
const
|
|
299
|
-
if (!
|
|
300
|
-
const
|
|
298
|
+
const h = f.cell.text ?? "";
|
|
299
|
+
if (!h) continue;
|
|
300
|
+
const g = Ee(n.style, f.cell.style), b = z(g, s), x = Math.max(0, f.widthMm - 2 * m), T = Ce(h, x, { fontSizePt: b.fontSizePt, bold: g.bold, italic: g.italic, fontFamily: g.fontFamily ?? c, letterSpacingPt: g.letterSpacing }, d).join(`
|
|
301
301
|
`);
|
|
302
|
-
|
|
302
|
+
Ne(
|
|
303
303
|
e,
|
|
304
304
|
{
|
|
305
|
-
text:
|
|
306
|
-
fontSizePx:
|
|
307
|
-
bold:
|
|
308
|
-
italic:
|
|
309
|
-
color:
|
|
310
|
-
align:
|
|
311
|
-
lineHeight: X(
|
|
312
|
-
letterSpacingPx:
|
|
305
|
+
text: T,
|
|
306
|
+
fontSizePx: b.fontSizePx,
|
|
307
|
+
bold: g.bold ?? !1,
|
|
308
|
+
italic: g.italic,
|
|
309
|
+
color: Se(g, Me),
|
|
310
|
+
align: g.align ?? "left",
|
|
311
|
+
lineHeight: X(g),
|
|
312
|
+
letterSpacingPx: D(g.letterSpacing ?? 0, s)
|
|
313
313
|
},
|
|
314
314
|
r + (f.xMm + m) * a,
|
|
315
315
|
i + (f.yMm + m) * a,
|
|
316
|
-
|
|
316
|
+
x * a,
|
|
317
317
|
Math.max(0, f.heightMm - 2 * m) * a,
|
|
318
|
-
|
|
319
|
-
|
|
318
|
+
g.fontFamily ?? c,
|
|
319
|
+
g.verticalAlign ?? "middle"
|
|
320
320
|
);
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
function
|
|
324
|
-
const c = t.style ?? {}, d =
|
|
323
|
+
function yt(e, t, n, r, i, l, o, a, s) {
|
|
324
|
+
const c = t.style ?? {}, d = z(c, o), u = xe(t) ? t.richParagraphs.map((m) => m.segments.map((f) => f.text ?? f.field ?? "").join("")).join(`
|
|
325
325
|
`) : t.lines?.length ? t.lines.join(`
|
|
326
|
-
`) :
|
|
326
|
+
`) : Ce(t.text ?? "", t.widthMm, { fontSizePt: d.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? a, letterSpacingPt: c.letterSpacing }, s).join(`
|
|
327
327
|
`);
|
|
328
|
-
|
|
328
|
+
Ne(e, {
|
|
329
329
|
text: u,
|
|
330
330
|
fontSizePx: d.fontSizePx,
|
|
331
331
|
bold: c.bold ?? !1,
|
|
332
332
|
italic: c.italic,
|
|
333
|
-
color:
|
|
333
|
+
color: Se(c),
|
|
334
334
|
align: c.align ?? "left",
|
|
335
335
|
lineHeight: X(c),
|
|
336
|
-
letterSpacingPx:
|
|
336
|
+
letterSpacingPx: D(c.letterSpacing ?? 0, o)
|
|
337
337
|
}, n, r, i, l, c.fontFamily ?? a, c.verticalAlign);
|
|
338
338
|
}
|
|
339
|
-
function
|
|
339
|
+
function le(e, t, n, r, i, l, o) {
|
|
340
340
|
const a = t.leftMm * n, s = t.topMm * n, c = t.widthMm * n, d = t.heightMm * n, u = t.style ?? {};
|
|
341
341
|
if (J(t)) {
|
|
342
342
|
const m = o?.get(t.imageData);
|
|
343
|
-
m ?
|
|
343
|
+
m ? ht(e, m, a, s, c, d) : be(e, t, a, s, c, d);
|
|
344
344
|
return;
|
|
345
345
|
}
|
|
346
346
|
if (t.grid) {
|
|
347
|
-
|
|
347
|
+
vt(e, t.grid, t, a, s, c, d, n, r, i, l);
|
|
348
348
|
return;
|
|
349
349
|
}
|
|
350
350
|
switch (t.kind) {
|
|
351
351
|
case "text": {
|
|
352
|
-
|
|
352
|
+
yt(e, t, a, s, c, d, r, i, l);
|
|
353
353
|
break;
|
|
354
354
|
}
|
|
355
355
|
case "rect": {
|
|
356
|
-
const m =
|
|
357
|
-
u.backgroundColor && (e.fillStyle = u.backgroundColor, e.fillRect(a, s, c, d)), f.inner && (e.strokeStyle = m.color, e.lineWidth =
|
|
356
|
+
const m = H(u), f = Te(u);
|
|
357
|
+
u.backgroundColor && (e.fillStyle = u.backgroundColor, e.fillRect(a, s, c, d)), f.inner && (e.strokeStyle = m.color, e.lineWidth = D(m.widthPt, r), bt(e, f, a, s, c, d));
|
|
358
358
|
break;
|
|
359
359
|
}
|
|
360
360
|
case "line": {
|
|
361
|
-
const m =
|
|
362
|
-
e.strokeStyle = m.color, e.lineWidth =
|
|
363
|
-
const f = t.lineDirection === "up" ? s + d : t.lineDirection === "down" ? s : s + d / 2,
|
|
364
|
-
e.moveTo(a, f), e.lineTo(a + c,
|
|
361
|
+
const m = H({ ...u, borderColor: u.lineColor ?? u.borderColor });
|
|
362
|
+
e.strokeStyle = m.color, e.lineWidth = D(m.widthPt, r), e.beginPath();
|
|
363
|
+
const f = t.lineDirection === "up" ? s + d : t.lineDirection === "down" ? s : s + d / 2, h = t.lineDirection === "up" ? s : t.lineDirection === "down" ? s + d : s + d / 2;
|
|
364
|
+
e.moveTo(a, f), e.lineTo(a + c, h), e.stroke();
|
|
365
365
|
break;
|
|
366
366
|
}
|
|
367
367
|
case "ellipse": {
|
|
368
|
-
const m =
|
|
369
|
-
e.strokeStyle = m.color, e.lineWidth =
|
|
368
|
+
const m = H(u);
|
|
369
|
+
e.strokeStyle = m.color, e.lineWidth = D(m.widthPt, r), u.backgroundColor && (e.fillStyle = u.backgroundColor, e.beginPath(), e.ellipse(a + c / 2, s + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(a + c / 2, s + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.stroke();
|
|
370
370
|
break;
|
|
371
371
|
}
|
|
372
372
|
default:
|
|
373
|
-
|
|
373
|
+
be(e, t, a, s, c, d);
|
|
374
374
|
break;
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
|
-
function
|
|
377
|
+
function be(e, t, n, r, i, l) {
|
|
378
378
|
e.save(), e.strokeStyle = "#94a3b8", e.strokeRect(n, r, i, l), e.fillStyle = "#64748b", e.font = "12px sans-serif", e.fillText(t.fallbackText ?? `[${t.kind}]`, n + 3, r + 14), e.restore();
|
|
379
379
|
}
|
|
380
|
-
async function
|
|
380
|
+
async function pn(e, t = {}) {
|
|
381
381
|
if (typeof document > "u")
|
|
382
382
|
throw new Error("renderPlanToImages 需要浏览器环境(SSR/Node 请在客户端钩子中调用)");
|
|
383
383
|
const { format: n = "png", quality: r = 0.92, ...i } = t;
|
|
384
384
|
if (n !== "png" && n !== "jpeg") throw new TypeError("Image format must be png or jpeg.");
|
|
385
385
|
if (!Number.isFinite(r) || r < 0 || r > 1) throw new RangeError("Image quality must be between 0 and 1.");
|
|
386
|
-
|
|
387
|
-
const l = await
|
|
386
|
+
R(t.signal);
|
|
387
|
+
const l = await oe(e, { ...t, format: "canvas" });
|
|
388
388
|
e = l.plan;
|
|
389
|
-
const o = [...l.diagnostics, ...
|
|
389
|
+
const o = [...l.diagnostics, ...B(e, "canvas", t)], a = n === "jpeg" ? "image/jpeg" : "image/png", s = [], c = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
|
|
390
390
|
for (let d = Math.max(0, t.start ?? 0); d <= c; d++) {
|
|
391
|
-
|
|
392
|
-
const u = await
|
|
391
|
+
R(t.signal);
|
|
392
|
+
const u = await Le(e.pages[d], d, i, o);
|
|
393
393
|
try {
|
|
394
|
-
s.push(await
|
|
394
|
+
s.push(await Mt(u, a, r, t.signal));
|
|
395
395
|
} finally {
|
|
396
396
|
u.width = 0, u.height = 0;
|
|
397
397
|
}
|
|
398
|
+
await Ue(t, s.length, c - Math.max(0, t.start ?? 0) + 1);
|
|
398
399
|
}
|
|
399
|
-
return
|
|
400
|
+
return R(t.signal), { blobs: s, diagnostics: o };
|
|
400
401
|
}
|
|
401
|
-
function
|
|
402
|
-
return
|
|
402
|
+
function Mt(e, t, n, r) {
|
|
403
|
+
return R(r), new Promise((i, l) => {
|
|
403
404
|
const o = () => l(r?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
404
405
|
r?.addEventListener("abort", o, { once: !0 });
|
|
405
406
|
try {
|
|
@@ -411,148 +412,159 @@ function pt(e, t, n, r) {
|
|
|
411
412
|
}
|
|
412
413
|
});
|
|
413
414
|
}
|
|
414
|
-
function
|
|
415
|
-
if (typeof document > "u")
|
|
415
|
+
function wn(e, t = {}) {
|
|
416
|
+
if (R(t.signal), typeof document > "u")
|
|
416
417
|
throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");
|
|
417
|
-
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 *
|
|
418
|
-
for (
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
c.push(f);
|
|
418
|
+
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * ae, l = t.fontFamily ?? Y, o = t.measurer ?? ie, a = Math.max(0, t.start ?? 0), s = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [], d = B(e, "canvas", t), u = xt(e, a, s);
|
|
419
|
+
for (const m of u)
|
|
420
|
+
ke(m, t), d.push(m);
|
|
421
|
+
if (t.fidelity === "strict" && u.length) throw new Je(d);
|
|
422
|
+
for (let m = a; m <= s; m++) {
|
|
423
|
+
R(t.signal);
|
|
424
|
+
const f = e.pages[m], { canvas: h, ctx: g } = $e(f, n, r, t.maxCanvasPixels);
|
|
425
|
+
for (const b of f.components)
|
|
426
|
+
le(g, b, i, r, l, o);
|
|
427
|
+
c.push(h);
|
|
428
428
|
}
|
|
429
429
|
return { canvases: c, diagnostics: d };
|
|
430
430
|
}
|
|
431
|
-
|
|
431
|
+
function xt(e, t, n) {
|
|
432
|
+
return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => r.components.flatMap((l, o) => J(l) ? [{
|
|
433
|
+
code: "async-image-required",
|
|
434
|
+
severity: "warning",
|
|
435
|
+
format: "canvas",
|
|
436
|
+
pageIndex: t + i,
|
|
437
|
+
componentIndex: o,
|
|
438
|
+
kind: l.kind,
|
|
439
|
+
nid: l.nid,
|
|
440
|
+
message: "Use renderPlanToCanvasAsync or renderPlanToImages to decode and include images."
|
|
441
|
+
}] : []));
|
|
442
|
+
}
|
|
443
|
+
async function bn(e, t = {}) {
|
|
432
444
|
if (typeof document > "u") throw new Error("renderPlanToCanvasAsync 需要浏览器环境(Node 请使用 PDF 或 XLSX 输出)");
|
|
433
|
-
|
|
434
|
-
const n = await
|
|
445
|
+
R(t.signal);
|
|
446
|
+
const n = await oe(e, { ...t, format: "canvas" });
|
|
435
447
|
e = n.plan;
|
|
436
|
-
const r = [...n.diagnostics, ...
|
|
448
|
+
const r = [...n.diagnostics, ...B(e, "canvas", t)], i = [], l = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
|
|
437
449
|
for (let o = Math.max(0, t.start ?? 0); o <= l; o++)
|
|
438
|
-
i.push(await
|
|
450
|
+
i.push(await Le(e.pages[o], o, t, r));
|
|
439
451
|
return { canvases: i, diagnostics: r };
|
|
440
452
|
}
|
|
441
|
-
async function
|
|
442
|
-
const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), l = n.dpi ?? 96, o = n.fontFamily ??
|
|
443
|
-
|
|
444
|
-
const { canvas: s, ctx: c } =
|
|
445
|
-
for (const d of e.components)
|
|
453
|
+
async function Le(e, t, n, r) {
|
|
454
|
+
const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), l = n.dpi ?? 96, o = n.fontFamily ?? Y, a = await Fe(e, t, n, r);
|
|
455
|
+
R(n.signal);
|
|
456
|
+
const { canvas: s, ctx: c } = $e(e, i, l, n.maxCanvasPixels);
|
|
457
|
+
for (const d of e.components) le(c, d, l / 25.4, l, o, n.measurer ?? ie, a);
|
|
446
458
|
return s;
|
|
447
459
|
}
|
|
448
|
-
async function
|
|
449
|
-
const i = n.imageLoader ??
|
|
450
|
-
return
|
|
460
|
+
async function Fe(e, t, n, r) {
|
|
461
|
+
const i = n.imageLoader ?? ut;
|
|
462
|
+
return ft(e, async (l, o) => {
|
|
451
463
|
try {
|
|
452
464
|
return await i(l, o);
|
|
453
465
|
} catch (a) {
|
|
454
466
|
if (o?.aborted) throw a;
|
|
455
467
|
const s = e.components.findIndex((u) => u.imageData === l), c = e.components[s], d = { code: "image-decode-failed", severity: "warning", format: "canvas", pageIndex: t, componentIndex: s, kind: c.kind, nid: c.nid, message: "Image decoding failed; raster output was cancelled instead of omitting the image." };
|
|
456
|
-
throw r.push(d),
|
|
468
|
+
throw r.push(d), ke(d, n), a;
|
|
457
469
|
}
|
|
458
470
|
}, n.signal);
|
|
459
471
|
}
|
|
460
|
-
function
|
|
461
|
-
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 *
|
|
462
|
-
let f = null,
|
|
463
|
-
const
|
|
464
|
-
function
|
|
472
|
+
function vn(e, t = {}) {
|
|
473
|
+
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * ae, l = t.fontFamily ?? Y, o = t.measurer ?? ie, a = t.overscan ?? 1, s = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, d = e.pages.map((p) => p.pageHeightMm * i), u = Math.max(1, ...e.pages.map((p) => p.pageWidthMm * i)), m = { start: 0, end: -1 };
|
|
474
|
+
let f = null, h = null, g = null, b = null, x = [], T = 0, k = [], _ = 0, j = new AbortController();
|
|
475
|
+
const he = [];
|
|
476
|
+
function _e() {
|
|
465
477
|
const p = f;
|
|
466
|
-
p.innerHTML = "",
|
|
478
|
+
p.innerHTML = "", h = document.createElement("div"), h.style.cssText = `width:${u}px;margin:0 auto;`, g = document.createElement("div"), b = document.createElement("div"), h.appendChild(g), x = [];
|
|
467
479
|
const E = Math.min(e.pages.length, 3 + a * 2);
|
|
468
|
-
for (let
|
|
469
|
-
const
|
|
470
|
-
|
|
480
|
+
for (let N = 0; N < E; N++) {
|
|
481
|
+
const v = document.createElement("div");
|
|
482
|
+
v.style.cssText = `margin:0 auto ${s}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, h.appendChild(v), x.push(v);
|
|
471
483
|
}
|
|
472
|
-
|
|
484
|
+
h.appendChild(b), p.appendChild(h);
|
|
473
485
|
}
|
|
474
|
-
async function
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
const
|
|
478
|
-
if (
|
|
479
|
-
const { widthPx:
|
|
480
|
-
let
|
|
481
|
-
(
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
const
|
|
485
|
-
if (
|
|
486
|
-
|
|
487
|
-
for (const
|
|
488
|
-
|
|
489
|
-
|
|
486
|
+
async function Ke(p, E) {
|
|
487
|
+
const N = _, v = await oe(e, { ...t, signal: j.signal, format: "canvas", start: E, end: E });
|
|
488
|
+
he.push(...v.diagnostics);
|
|
489
|
+
const C = v.plan.pages[E], q = await Fe(C, E, { ...t, signal: j.signal }, he);
|
|
490
|
+
if (N !== _ || !f) return;
|
|
491
|
+
const { widthPx: ee, heightPx: te } = se(C, r);
|
|
492
|
+
let $ = p.firstElementChild;
|
|
493
|
+
(!$ || $.tagName !== "CANVAS") && ($ = document.createElement("canvas"), p.innerHTML = "", p.appendChild($));
|
|
494
|
+
const pe = Ae(C, n, r, t.maxCanvasPixels);
|
|
495
|
+
$.width = pe.width, $.height = pe.height, $.style.width = `${ee}px`, $.style.height = `${te}px`;
|
|
496
|
+
const F = $.getContext("2d");
|
|
497
|
+
if (F) {
|
|
498
|
+
F.setTransform(1, 0, 0, 1, 0, 0), F.scale(n, n), F.fillStyle = "#ffffff", F.fillRect(0, 0, ee, te);
|
|
499
|
+
for (const qe of C.components)
|
|
500
|
+
le(F, qe, i, r, l, o, q);
|
|
501
|
+
$.dataset.canvasPage = String(E), p.style.height = `${te}px`, p.style.width = `${ee}px`;
|
|
490
502
|
}
|
|
491
503
|
}
|
|
492
|
-
function
|
|
493
|
-
|
|
504
|
+
function Ve(p) {
|
|
505
|
+
_++, m.start = p.start, m.end = p.end, g.style.height = `${p.start * s + d.slice(0, p.start).reduce((v, C) => v + C, 0)}px`;
|
|
494
506
|
const E = e.pages.length - 1 - p.end;
|
|
495
|
-
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
if (
|
|
499
|
-
|
|
500
|
-
const
|
|
501
|
-
|
|
507
|
+
b.style.height = `${E * s + d.slice(p.end + 1).reduce((v, C) => v + C, 0)}px`;
|
|
508
|
+
const N = p.end - p.start + 1;
|
|
509
|
+
x.forEach((v, C) => {
|
|
510
|
+
if (C < N) {
|
|
511
|
+
v.style.display = "";
|
|
512
|
+
const q = p.start + C;
|
|
513
|
+
v.style.height = `${d[q] ?? 0}px`;
|
|
502
514
|
} else
|
|
503
|
-
|
|
504
|
-
}),
|
|
505
|
-
for (let
|
|
506
|
-
const
|
|
507
|
-
if (!
|
|
508
|
-
|
|
515
|
+
v.style.display = "none";
|
|
516
|
+
}), k = [];
|
|
517
|
+
for (let v = p.start; v <= p.end; v++) {
|
|
518
|
+
const C = x[v - p.start];
|
|
519
|
+
if (!C) continue;
|
|
520
|
+
C.firstElementChild?.dataset?.canvasPage !== String(v) && k.push(v);
|
|
509
521
|
}
|
|
510
|
-
|
|
522
|
+
Z();
|
|
511
523
|
}
|
|
512
|
-
function
|
|
513
|
-
|
|
514
|
-
|
|
524
|
+
function Z() {
|
|
525
|
+
T || k.length === 0 || (T = requestAnimationFrame(() => {
|
|
526
|
+
T = 0;
|
|
515
527
|
let p = Math.max(1, c);
|
|
516
|
-
for (;
|
|
517
|
-
const E =
|
|
518
|
-
|
|
528
|
+
for (; k.length > 0 && p-- > 0; ) {
|
|
529
|
+
const E = k.shift(), N = x[E - m.start];
|
|
530
|
+
N && Ke(N, E).catch(() => {
|
|
519
531
|
});
|
|
520
532
|
}
|
|
521
|
-
|
|
533
|
+
k.length > 0 && Z();
|
|
522
534
|
}));
|
|
523
535
|
}
|
|
524
|
-
function
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
const p = f, E =
|
|
536
|
+
function K() {
|
|
537
|
+
T || (T = requestAnimationFrame(() => {
|
|
538
|
+
T = 0;
|
|
539
|
+
const p = f, E = gt({
|
|
528
540
|
pageHeightsPx: d,
|
|
529
541
|
viewportHeightPx: p.clientHeight,
|
|
530
542
|
scrollTopPx: p.scrollTop,
|
|
531
543
|
overscan: a,
|
|
532
544
|
gapPx: s
|
|
533
545
|
});
|
|
534
|
-
E.start !== m.start || E.end !== m.end ?
|
|
546
|
+
E.start !== m.start || E.end !== m.end ? Ve(E) : Z();
|
|
535
547
|
}));
|
|
536
548
|
}
|
|
537
|
-
let
|
|
549
|
+
let V = null;
|
|
538
550
|
return {
|
|
539
551
|
attach(p) {
|
|
540
552
|
if (typeof document > "u")
|
|
541
553
|
throw new Error("createCanvasPager 需要浏览器环境(SSR 请在客户端钩子中调用 attach)");
|
|
542
|
-
|
|
554
|
+
R(t.signal), j = new AbortController(), t.signal?.addEventListener("abort", ge, { once: !0 }), B(e, "canvas", t), f = p, _e(), p.addEventListener("scroll", K, { passive: !0 }), typeof ResizeObserver < "u" && (V = new ResizeObserver(() => K()), V.observe(p)), K();
|
|
543
555
|
},
|
|
544
556
|
destroy() {
|
|
545
|
-
|
|
557
|
+
_++, j.abort(), t.signal?.removeEventListener("abort", ge), T && cancelAnimationFrame(T), T = 0, V?.disconnect(), V = null, f?.removeEventListener("scroll", K), k = [], h?.remove(), f = null;
|
|
546
558
|
},
|
|
547
559
|
window() {
|
|
548
560
|
return { ...m };
|
|
549
561
|
}
|
|
550
562
|
};
|
|
551
|
-
function
|
|
552
|
-
|
|
563
|
+
function ge() {
|
|
564
|
+
j.abort(t.signal?.reason);
|
|
553
565
|
}
|
|
554
566
|
}
|
|
555
|
-
function
|
|
567
|
+
function De(e, t, n) {
|
|
556
568
|
let r, i;
|
|
557
569
|
if (typeof e == "string") {
|
|
558
570
|
const l = G[e];
|
|
@@ -561,7 +573,7 @@ function Ne(e, t, n) {
|
|
|
561
573
|
} else typeof e == "number" ? (r = e, i = t ?? 297) : (r = e.widthMm, i = e.heightMm);
|
|
562
574
|
return n ? { widthMm: i, heightMm: r } : { widthMm: r, heightMm: i };
|
|
563
575
|
}
|
|
564
|
-
class
|
|
576
|
+
class Tt {
|
|
565
577
|
constructor() {
|
|
566
578
|
this.pages = [], this.pending = null, this.templateParams = void 0;
|
|
567
579
|
}
|
|
@@ -590,12 +602,12 @@ class wt {
|
|
|
590
602
|
*/
|
|
591
603
|
page(t = "a4", n = {}, r) {
|
|
592
604
|
this.collect();
|
|
593
|
-
const l = 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: o, heightMm: a } =
|
|
605
|
+
const l = 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: o, heightMm: a } = De(
|
|
594
606
|
t,
|
|
595
607
|
typeof n == "number" ? n : void 0,
|
|
596
608
|
l.landscape
|
|
597
609
|
), s = l.margins ?? {};
|
|
598
|
-
return this.pending = new
|
|
610
|
+
return this.pending = new Et(this, {
|
|
599
611
|
widthMm: o,
|
|
600
612
|
heightMm: a,
|
|
601
613
|
marginTopMm: s.marginTopMm ?? 10,
|
|
@@ -613,7 +625,7 @@ class wt {
|
|
|
613
625
|
return this.templateParams ? { params: this.templateParams, pages: this.pages } : { pages: this.pages };
|
|
614
626
|
}
|
|
615
627
|
}
|
|
616
|
-
class
|
|
628
|
+
class Et {
|
|
617
629
|
constructor(t, n) {
|
|
618
630
|
this.parent = t, this.page = n, this.components = [];
|
|
619
631
|
}
|
|
@@ -682,18 +694,18 @@ class bt {
|
|
|
682
694
|
return this.done().build();
|
|
683
695
|
}
|
|
684
696
|
}
|
|
685
|
-
function
|
|
686
|
-
return new
|
|
697
|
+
function yn() {
|
|
698
|
+
return new Tt();
|
|
687
699
|
}
|
|
688
|
-
function
|
|
689
|
-
return
|
|
700
|
+
function Mn(e, t = {}) {
|
|
701
|
+
return Ge([], e), e.fields.map((n) => ({
|
|
690
702
|
field: n.field,
|
|
691
703
|
header: `${n.label ?? n.field}${n.unit ? ` (${n.unit})` : ""}`,
|
|
692
704
|
semanticRole: n.semanticRole ?? (n.type === "number" || n.type === "decimal" ? "measure" : n.type === "date" ? "date" : n.enum ? "dimension" : "text"),
|
|
693
705
|
...t[n.field]
|
|
694
706
|
}));
|
|
695
707
|
}
|
|
696
|
-
function
|
|
708
|
+
function I(e, t, n = !1) {
|
|
697
709
|
if (!Number.isFinite(e) || (n ? e < 0 : e <= 0))
|
|
698
710
|
throw new Error(`${t} 必须是有限${n ? "非负" : "正"}数`);
|
|
699
711
|
}
|
|
@@ -701,7 +713,7 @@ function U(e, t, n) {
|
|
|
701
713
|
if (e !== void 0 && !["left", "center", "right", "justify", ...n ? ["auto"] : []].includes(e))
|
|
702
714
|
throw new Error(`${t} 必须是 left/center/right/justify${n ? "/auto" : ""}`);
|
|
703
715
|
}
|
|
704
|
-
function
|
|
716
|
+
function St(e) {
|
|
705
717
|
const t = e.layout ?? "page";
|
|
706
718
|
if (t !== "page" && t !== "wide")
|
|
707
719
|
throw new Error("layout 必须是 page 或 wide");
|
|
@@ -710,18 +722,18 @@ function vt(e) {
|
|
|
710
722
|
if (t !== "wide" && e.columnWidthMm !== void 0)
|
|
711
723
|
throw new Error('columnWidthMm 仅适用于 layout: "wide"');
|
|
712
724
|
const n = e.columnWidthMm ?? 30;
|
|
713
|
-
return
|
|
725
|
+
return I(n, "columnWidthMm"), { layout: t, columnWidthMm: n };
|
|
714
726
|
}
|
|
715
|
-
function
|
|
727
|
+
function Ct(e) {
|
|
716
728
|
const t = e.paper === void 0 ? "a4" : e.paper;
|
|
717
729
|
if (typeof t != "string" && (typeof t != "object" || t === null) || e.landscape !== void 0 && typeof e.landscape != "boolean")
|
|
718
730
|
throw new Error("paper 必须是纸张预设名或 { widthMm, heightMm } 对象,landscape 必须是布尔值");
|
|
719
731
|
if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(G, t))
|
|
720
732
|
throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(G).join("/")})`);
|
|
721
|
-
const n =
|
|
722
|
-
return
|
|
733
|
+
const n = De(t, void 0, e.landscape), r = n.widthMm, i = n.heightMm;
|
|
734
|
+
return I(r, "纸张 widthMm"), I(i, "纸张 heightMm"), { widthMm: r, heightMm: i };
|
|
723
735
|
}
|
|
724
|
-
function
|
|
736
|
+
function Pt(e) {
|
|
725
737
|
if (e.margins !== void 0 && (!e.margins || typeof e.margins != "object" || Array.isArray(e.margins)))
|
|
726
738
|
throw new Error("margins 必须是页边距对象");
|
|
727
739
|
const t = e.margins ?? {}, n = {
|
|
@@ -730,44 +742,44 @@ function Mt(e) {
|
|
|
730
742
|
marginLeftMm: t.marginLeftMm === void 0 ? 10 : t.marginLeftMm,
|
|
731
743
|
marginRightMm: t.marginRightMm === void 0 ? 10 : t.marginRightMm
|
|
732
744
|
};
|
|
733
|
-
for (const [r, i] of Object.entries(n))
|
|
745
|
+
for (const [r, i] of Object.entries(n)) I(i, r, !0);
|
|
734
746
|
return n;
|
|
735
747
|
}
|
|
736
|
-
function
|
|
748
|
+
function kt(e, t) {
|
|
737
749
|
const n = e.dataset === void 0 ? "detail" : e.dataset;
|
|
738
750
|
if (typeof n != "string" || !n.trim())
|
|
739
751
|
throw new Error("dataset 必须是非空字符串");
|
|
740
752
|
if (e.title !== void 0 && typeof e.title != "string")
|
|
741
753
|
throw new Error("title 必须是字符串");
|
|
742
754
|
const r = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm, i = e.titleGapMm === void 0 ? 4 : e.titleGapMm;
|
|
743
|
-
|
|
755
|
+
I(r, "titleHeightMm"), I(i, "titleGapMm", !0);
|
|
744
756
|
const l = e.title !== void 0 && e.title.length > 0, o = l ? r + i : 0;
|
|
745
757
|
if (o >= t)
|
|
746
758
|
throw new Error("标题高度与间距占满页面,必须为表格保留可用高度");
|
|
747
759
|
return { dataset: n, titleHeightMm: r, hasTitle: l, titleSpaceMm: o };
|
|
748
760
|
}
|
|
749
|
-
function
|
|
761
|
+
function Rt(e) {
|
|
750
762
|
if (e.listOptions !== void 0 && (!e.listOptions || typeof e.listOptions != "object" || Array.isArray(e.listOptions)))
|
|
751
763
|
throw new Error("listOptions 必须是列表配置对象");
|
|
752
764
|
const t = e.listOptions ?? {};
|
|
753
765
|
U(t.align, "listOptions.align", !0), U(t.headerAlign, "listOptions.headerAlign", !1);
|
|
754
766
|
for (const n of ["fontSizePt", "rowHeightMm", "paddingMm"]) {
|
|
755
767
|
const r = t[n];
|
|
756
|
-
r !== void 0 &&
|
|
768
|
+
r !== void 0 && I(r, `listOptions.${n}`, n === "paddingMm");
|
|
757
769
|
}
|
|
758
770
|
return t;
|
|
759
771
|
}
|
|
760
|
-
function
|
|
772
|
+
function It(e) {
|
|
761
773
|
let t = 0, n = 0;
|
|
762
774
|
for (const [r, i] of e.entries()) {
|
|
763
775
|
if (!i || typeof i.header != "string" || typeof i.field != "string" || !i.field.trim())
|
|
764
776
|
throw new Error(`columns[${r}] 需要字符串 header 与非空 field`);
|
|
765
|
-
U(i.align, `columns[${r}].align`, !0), U(i.headerAlign, `columns[${r}].headerAlign`, !1), i.flex !== void 0 &&
|
|
777
|
+
U(i.align, `columns[${r}].align`, !0), U(i.headerAlign, `columns[${r}].headerAlign`, !1), i.flex !== void 0 && I(i.flex, `columns[${r}].flex`), i.widthMm !== void 0 ? (I(i.widthMm, `columns[${r}].widthMm`), t += i.widthMm) : n = Math.max(n, i.flex ?? 1);
|
|
766
778
|
}
|
|
767
779
|
return { fixedWidthMm: t, maxFlex: n };
|
|
768
780
|
}
|
|
769
|
-
function
|
|
770
|
-
const { fixedWidthMm: i, maxFlex: l } =
|
|
781
|
+
function At(e, t, n, r) {
|
|
782
|
+
const { fixedWidthMm: i, maxFlex: l } = It(e.columns);
|
|
771
783
|
if (t === "page" && i > r)
|
|
772
784
|
throw new Error(`固定列宽 ${i}mm 超出页面可用宽度 ${r}mm`);
|
|
773
785
|
const o = r - i;
|
|
@@ -776,25 +788,25 @@ function St(e, t, n, r) {
|
|
|
776
788
|
const a = l > 0 ? e.columns.reduce((c, d) => c + (d.widthMm === void 0 ? (d.flex ?? 1) / l : 0), 0) : 0;
|
|
777
789
|
return { columns: e.columns.map(({ widthMm: c, flex: d, ...u }, m) => {
|
|
778
790
|
const f = c ?? (t === "wide" ? n * (d ?? 1) : o * ((d ?? 1) / l) / a);
|
|
779
|
-
return
|
|
791
|
+
return I(f, `columns[${m}] 分配后的 widthMm`), { ...u, widthMm: f };
|
|
780
792
|
}), fixedWidthMm: i, maxFlex: l };
|
|
781
793
|
}
|
|
782
|
-
function
|
|
794
|
+
function xn(e) {
|
|
783
795
|
if (!e || typeof e != "object")
|
|
784
796
|
throw new Error("标准明细模板需要 options 对象");
|
|
785
797
|
if (!Array.isArray(e.columns) || e.columns.length === 0)
|
|
786
798
|
throw new Error("columns 至少需要一列");
|
|
787
|
-
const { layout: t, columnWidthMm: n } =
|
|
799
|
+
const { layout: t, columnWidthMm: n } = St(e), r = Ct(e);
|
|
788
800
|
let i = r.widthMm;
|
|
789
|
-
const l = r.heightMm, o =
|
|
801
|
+
const l = r.heightMm, o = Pt(e);
|
|
790
802
|
let a = i - o.marginLeftMm - o.marginRightMm;
|
|
791
803
|
const s = l - o.marginTopMm - o.marginBottomMm;
|
|
792
804
|
if (t === "page" && a <= 0 || s <= 0)
|
|
793
805
|
throw new Error("页边距占满纸张,必须保留正的可用宽度和高度");
|
|
794
|
-
const { dataset: c, titleHeightMm: d, hasTitle: u, titleSpaceMm: m } =
|
|
795
|
-
t === "wide" && (a =
|
|
796
|
-
const
|
|
797
|
-
return u &&
|
|
806
|
+
const { dataset: c, titleHeightMm: d, hasTitle: u, titleSpaceMm: m } = kt(e, s), f = Rt(e), { columns: h, fixedWidthMm: g, maxFlex: b } = At(e, t, n, a);
|
|
807
|
+
t === "wide" && (a = h.reduce((T, k) => T + k.widthMm, 0), I(a, "宽表总列宽"), i = a + o.marginLeftMm + o.marginRightMm, I(i, "宽表总宽度"));
|
|
808
|
+
const x = { widthMm: i, heightMm: l, ...o, components: [], ...t === "wide" ? { layout: t } : {} };
|
|
809
|
+
return u && x.components.push({
|
|
798
810
|
kind: "text",
|
|
799
811
|
text: e.title,
|
|
800
812
|
leftMm: o.marginLeftMm,
|
|
@@ -802,7 +814,7 @@ function sn(e) {
|
|
|
802
814
|
widthMm: a,
|
|
803
815
|
heightMm: d,
|
|
804
816
|
style: { fontSize: 16, bold: !0, align: "center", verticalAlign: "middle", ...e.titleStyle }
|
|
805
|
-
}),
|
|
817
|
+
}), x.components.push({
|
|
806
818
|
align: "auto",
|
|
807
819
|
headerAlign: "center",
|
|
808
820
|
...f,
|
|
@@ -810,67 +822,67 @@ function sn(e) {
|
|
|
810
822
|
...t === "wide" ? { layout: t } : {},
|
|
811
823
|
...u ? { title: e.title } : {},
|
|
812
824
|
dataset: c,
|
|
813
|
-
columns:
|
|
825
|
+
columns: h,
|
|
814
826
|
leftMm: o.marginLeftMm,
|
|
815
827
|
topMm: o.marginTopMm + m,
|
|
816
|
-
widthMm: t === "wide" ||
|
|
817
|
-
}), e.params === void 0 ? { pages: [
|
|
828
|
+
widthMm: t === "wide" || b > 0 ? a : g
|
|
829
|
+
}), e.params === void 0 ? { pages: [x] } : { params: e.params, pages: [x] };
|
|
818
830
|
}
|
|
819
|
-
function
|
|
831
|
+
function Tn(e) {
|
|
820
832
|
return e;
|
|
821
833
|
}
|
|
822
|
-
class
|
|
834
|
+
class L extends Error {
|
|
823
835
|
constructor(t, n) {
|
|
824
836
|
super(n), this.code = t, this.name = "ReportTemplateStoreError";
|
|
825
837
|
}
|
|
826
838
|
}
|
|
827
|
-
function
|
|
839
|
+
function A(e) {
|
|
828
840
|
return JSON.parse(JSON.stringify(e));
|
|
829
841
|
}
|
|
830
|
-
function
|
|
842
|
+
function P(e) {
|
|
831
843
|
if (!e?.aborted) return;
|
|
832
844
|
const t = new Error("模板操作已取消");
|
|
833
845
|
throw t.name = "AbortError", t;
|
|
834
846
|
}
|
|
835
|
-
function
|
|
847
|
+
function ve(e) {
|
|
836
848
|
const t = e ? Number(e.revision) : 0;
|
|
837
|
-
if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new
|
|
849
|
+
if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new L("history", "修订号无效或已达上限");
|
|
838
850
|
return String(t + 1);
|
|
839
851
|
}
|
|
840
|
-
function
|
|
852
|
+
function En(e, t = {}) {
|
|
841
853
|
const n = async (o, a) => {
|
|
842
|
-
|
|
854
|
+
P(a);
|
|
843
855
|
const s = await e.read(o, a);
|
|
844
|
-
return
|
|
856
|
+
return P(a), s ? A(s) : void 0;
|
|
845
857
|
}, r = async (o, a) => {
|
|
846
858
|
const s = await n(o, a.signal);
|
|
847
|
-
if ((s?.revision ?? null) !== a.expectedRevision) throw new
|
|
859
|
+
if ((s?.revision ?? null) !== a.expectedRevision) throw new L("conflict", "模板已变化,请重新读取后提交");
|
|
848
860
|
return s;
|
|
849
861
|
}, i = async (o, a, s) => {
|
|
850
|
-
if (
|
|
851
|
-
return
|
|
862
|
+
if (P(a.signal), !await e.compareAndSwap(o.id, a.expectedRevision, A(o), { signal: a.signal, ...s ? { publication: A(s) } : {} })) throw new L("conflict", "模板已被其他请求更新");
|
|
863
|
+
return A(o);
|
|
852
864
|
}, l = (o, a, s, c) => {
|
|
853
|
-
const d =
|
|
865
|
+
const d = ve(o), u = ne({ ...a, revision: d }), m = { revision: d, document: u, publishedAt: (t.now?.() ?? /* @__PURE__ */ new Date()).toISOString() };
|
|
854
866
|
return c !== void 0 && (m.restoredFrom = c), i({ id: o.id, revision: d, publishedRevision: d, published: u }, s, m);
|
|
855
867
|
};
|
|
856
868
|
return {
|
|
857
869
|
list: async (o) => {
|
|
858
|
-
|
|
870
|
+
P(o);
|
|
859
871
|
const a = await e.list(o);
|
|
860
|
-
return
|
|
872
|
+
return P(o), A(a);
|
|
861
873
|
},
|
|
862
874
|
get: async (o, a = {}) => {
|
|
863
875
|
const s = await n(o, a.signal), c = a.draft ? s?.draft : s?.published;
|
|
864
|
-
return c ?
|
|
876
|
+
return c ? ne(c) : void 0;
|
|
865
877
|
},
|
|
866
878
|
history: async (o, a) => {
|
|
867
|
-
|
|
879
|
+
P(a);
|
|
868
880
|
const s = await e.history(o, a);
|
|
869
|
-
return
|
|
881
|
+
return P(a), A(s);
|
|
870
882
|
},
|
|
871
883
|
saveDraft: async (o, a) => {
|
|
872
|
-
|
|
873
|
-
const s =
|
|
884
|
+
P(a.signal);
|
|
885
|
+
const s = ne(t.migrate ? await t.migrate(o) : o), c = await r(s.id, a), d = ve(c);
|
|
874
886
|
return i({
|
|
875
887
|
id: s.id,
|
|
876
888
|
revision: d,
|
|
@@ -880,72 +892,72 @@ function cn(e, t = {}) {
|
|
|
880
892
|
},
|
|
881
893
|
publish: async (o, a) => {
|
|
882
894
|
const s = await r(o, a);
|
|
883
|
-
if (!s) throw new
|
|
884
|
-
if (!s.draft) throw new
|
|
895
|
+
if (!s) throw new L("missing", "模板不存在");
|
|
896
|
+
if (!s.draft) throw new L("draft", "没有可发布的草稿");
|
|
885
897
|
return l(s, s.draft, a);
|
|
886
898
|
},
|
|
887
899
|
rollback: async (o, a, s) => {
|
|
888
900
|
const c = await r(o, s);
|
|
889
|
-
if (!c) throw new
|
|
890
|
-
|
|
901
|
+
if (!c) throw new L("missing", "模板不存在");
|
|
902
|
+
P(s.signal);
|
|
891
903
|
const d = await e.getVersion(o, a, s.signal);
|
|
892
|
-
if (!d) throw new
|
|
904
|
+
if (!d) throw new L("history", "历史修订不存在");
|
|
893
905
|
return l(c, d.document, s, a);
|
|
894
906
|
}
|
|
895
907
|
};
|
|
896
908
|
}
|
|
897
|
-
function
|
|
909
|
+
function Sn() {
|
|
898
910
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
899
911
|
return {
|
|
900
912
|
read: async (n, r) => {
|
|
901
|
-
|
|
913
|
+
P(r);
|
|
902
914
|
const i = e.get(n);
|
|
903
|
-
return i ?
|
|
915
|
+
return i ? A(i) : void 0;
|
|
904
916
|
},
|
|
905
|
-
list: async (n) => (
|
|
906
|
-
history: async (n, r) => (
|
|
917
|
+
list: async (n) => (P(n), Array.from(e.values(), ({ id: r, revision: i, publishedRevision: l }) => ({ id: r, revision: i, ...l ? { publishedRevision: l } : {} }))),
|
|
918
|
+
history: async (n, r) => (P(r), Array.from(t.get(n)?.values() ?? [], (i) => A(i))),
|
|
907
919
|
getVersion: async (n, r, i) => {
|
|
908
|
-
|
|
920
|
+
P(i);
|
|
909
921
|
const l = t.get(n)?.get(r);
|
|
910
|
-
return l ?
|
|
922
|
+
return l ? A(l) : void 0;
|
|
911
923
|
},
|
|
912
924
|
compareAndSwap: async (n, r, i, l) => {
|
|
913
|
-
if (
|
|
914
|
-
if (i.id !== n) throw new
|
|
915
|
-
const o =
|
|
925
|
+
if (P(l.signal), (e.get(n)?.revision ?? null) !== r) return !1;
|
|
926
|
+
if (i.id !== n) throw new L("history", "状态 ID 与存储 ID 不一致");
|
|
927
|
+
const o = A(i), a = l.publication;
|
|
916
928
|
if (a) {
|
|
917
929
|
const s = t.get(n) ?? /* @__PURE__ */ new Map();
|
|
918
|
-
if (s.has(a.revision) || a.revision !== i.revision || a.document.id !== n) throw new
|
|
919
|
-
s.set(a.revision,
|
|
930
|
+
if (s.has(a.revision) || a.revision !== i.revision || a.document.id !== n) throw new L("history", "发布修订不可覆盖,且必须与状态修订和模板 ID 一致");
|
|
931
|
+
s.set(a.revision, A(a)), t.set(n, s);
|
|
920
932
|
}
|
|
921
933
|
return e.set(n, o), !0;
|
|
922
934
|
}
|
|
923
935
|
};
|
|
924
936
|
}
|
|
925
|
-
function
|
|
937
|
+
function Oe(e) {
|
|
926
938
|
return !e || typeof e != "object" ? !1 : [e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex].every((t) => Number.isInteger(t) && t >= 0);
|
|
927
939
|
}
|
|
928
|
-
function
|
|
940
|
+
function ze(e, t, n) {
|
|
929
941
|
const r = e.grid;
|
|
930
942
|
if (!r) return null;
|
|
931
943
|
const i = r.cells[t];
|
|
932
944
|
if (!i) return null;
|
|
933
|
-
const o =
|
|
945
|
+
const o = W(r, e.widthMm, e.heightMm).cells.filter((s) => s.ri === t).findIndex((s) => s.ci === n), a = i[o];
|
|
934
946
|
return a ? { cell: a, sourceColumnIndex: o } : null;
|
|
935
947
|
}
|
|
936
|
-
function
|
|
948
|
+
function $t(e) {
|
|
937
949
|
return e.value !== void 0 ? e.value : e.rawText ?? e.text ?? null;
|
|
938
950
|
}
|
|
939
|
-
function
|
|
951
|
+
function Nt(e, t) {
|
|
940
952
|
return e.valueType ? e.valueType : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t === null && e.numberFormat && /[0#?]/.test(e.numberFormat) ? "number" : "text";
|
|
941
953
|
}
|
|
942
|
-
function
|
|
954
|
+
function Lt(e, t) {
|
|
943
955
|
if (e.editable === !1) return "cell";
|
|
944
956
|
if (e.formula !== void 0) return "formula";
|
|
945
957
|
if (e.children?.length) return "complex";
|
|
946
958
|
if (t.table && t.table.role !== "body" && e.editable !== !0) return "structure";
|
|
947
959
|
}
|
|
948
|
-
function
|
|
960
|
+
function Ft(e, t) {
|
|
949
961
|
const n = e.table;
|
|
950
962
|
if (n)
|
|
951
963
|
return {
|
|
@@ -955,44 +967,44 @@ function Rt(e, t) {
|
|
|
955
967
|
columnKey: n.columnKeys[t.columnIndex]
|
|
956
968
|
};
|
|
957
969
|
}
|
|
958
|
-
function
|
|
970
|
+
function Dt(e, t, n) {
|
|
959
971
|
if (e.source) return { ...e.source };
|
|
960
972
|
const r = t.table?.source, i = t.table?.columnKeys[n.columnIndex];
|
|
961
973
|
if (!(!r || r.rowKey === void 0 || i === void 0))
|
|
962
974
|
return { ...r, rowKey: r.rowKey, field: i };
|
|
963
975
|
}
|
|
964
|
-
function
|
|
965
|
-
const r =
|
|
976
|
+
function je(e, t, n) {
|
|
977
|
+
const r = $t(n), i = Lt(n, e);
|
|
966
978
|
return {
|
|
967
979
|
address: { ...t },
|
|
968
980
|
cell: n,
|
|
969
981
|
component: e,
|
|
970
982
|
value: r,
|
|
971
|
-
valueType:
|
|
972
|
-
table:
|
|
973
|
-
source:
|
|
983
|
+
valueType: Nt(n, r),
|
|
984
|
+
table: Ft(e, t),
|
|
985
|
+
source: Dt(n, e, t),
|
|
974
986
|
editable: i === void 0,
|
|
975
987
|
readOnlyReason: i
|
|
976
988
|
};
|
|
977
989
|
}
|
|
978
|
-
function
|
|
979
|
-
if (!
|
|
990
|
+
function ce(e, t) {
|
|
991
|
+
if (!Oe(t)) return null;
|
|
980
992
|
const n = e.pages[t.pageIndex]?.components[t.componentIndex];
|
|
981
993
|
if (!n) return null;
|
|
982
|
-
const r =
|
|
983
|
-
return r ?
|
|
994
|
+
const r = ze(n, t.rowIndex, t.columnIndex);
|
|
995
|
+
return r ? je(n, t, r.cell) : null;
|
|
984
996
|
}
|
|
985
|
-
function
|
|
997
|
+
function de(e) {
|
|
986
998
|
const t = /* @__PURE__ */ new Map();
|
|
987
999
|
return (n) => {
|
|
988
|
-
if (!
|
|
1000
|
+
if (!Oe(n)) return null;
|
|
989
1001
|
const r = e.pages[n.pageIndex]?.components[n.componentIndex];
|
|
990
1002
|
if (!r?.grid) return null;
|
|
991
1003
|
let i = t.get(r);
|
|
992
1004
|
if (!i) {
|
|
993
1005
|
const o = /* @__PURE__ */ new Map();
|
|
994
1006
|
i = /* @__PURE__ */ new Map();
|
|
995
|
-
for (const a of
|
|
1007
|
+
for (const a of W(r.grid, r.widthMm, r.heightMm).cells) {
|
|
996
1008
|
const s = o.get(a.ri) ?? 0;
|
|
997
1009
|
o.set(a.ri, s + 1);
|
|
998
1010
|
const c = r.grid.cells[a.ri]?.[s];
|
|
@@ -1001,7 +1013,7 @@ function ce(e) {
|
|
|
1001
1013
|
t.set(r, i);
|
|
1002
1014
|
}
|
|
1003
1015
|
const l = i.get(`${n.rowIndex}:${n.columnIndex}`);
|
|
1004
|
-
return l ?
|
|
1016
|
+
return l ? je(r, n, l) : null;
|
|
1005
1017
|
};
|
|
1006
1018
|
}
|
|
1007
1019
|
class M extends Error {
|
|
@@ -1009,20 +1021,20 @@ class M extends Error {
|
|
|
1009
1021
|
super(`Invalid report cell edit: ${t}`), this.code = t, this.name = "ReportCellEditError";
|
|
1010
1022
|
}
|
|
1011
1023
|
}
|
|
1012
|
-
function
|
|
1024
|
+
function Ot(e, t) {
|
|
1013
1025
|
let n = e.trim();
|
|
1014
1026
|
const r = t && n.endsWith("%");
|
|
1015
1027
|
if (r && (n = n.slice(0, -1).trim()), /^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?(?:[eE][+-]?\d+)?$/.test(n) && (n = n.replace(/,/g, "")), !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(n)) throw new M("number");
|
|
1016
1028
|
return Number(n) / (r ? 100 : 1);
|
|
1017
1029
|
}
|
|
1018
|
-
function
|
|
1030
|
+
function zt(e, t) {
|
|
1019
1031
|
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
1020
1032
|
if (typeof e != "string" && typeof e != "number") throw new M("number");
|
|
1021
|
-
const n = typeof e == "number" ? e :
|
|
1033
|
+
const n = typeof e == "number" ? e : Ot(e, Qe(t.cell.numberFormat));
|
|
1022
1034
|
if (!Number.isFinite(n) || Number.isInteger(n) && !Number.isSafeInteger(n)) throw new M("number");
|
|
1023
1035
|
return n;
|
|
1024
1036
|
}
|
|
1025
|
-
function
|
|
1037
|
+
function jt(e) {
|
|
1026
1038
|
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
1027
1039
|
if (typeof e == "boolean") return e;
|
|
1028
1040
|
const t = String(e).trim().toLowerCase();
|
|
@@ -1030,24 +1042,24 @@ function Nt(e) {
|
|
|
1030
1042
|
if (["false", "no", "否", "0"].includes(t)) return !1;
|
|
1031
1043
|
throw new M("boolean");
|
|
1032
1044
|
}
|
|
1033
|
-
function
|
|
1034
|
-
return e.valueType === "number" ?
|
|
1045
|
+
function ue(e, t) {
|
|
1046
|
+
return e.valueType === "number" ? zt(t, e) : e.valueType === "boolean" ? jt(t) : t === null ? null : String(t);
|
|
1035
1047
|
}
|
|
1036
|
-
function
|
|
1048
|
+
function Ht(e, t) {
|
|
1037
1049
|
const n = t.cell.text, i = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((l) => l.includes(n ?? ""));
|
|
1038
1050
|
return i ? i[e ? 0 : 1] : String(e);
|
|
1039
1051
|
}
|
|
1040
|
-
function
|
|
1041
|
-
return t === null ? "" : typeof t == "boolean" ?
|
|
1052
|
+
function Q(e, t) {
|
|
1053
|
+
return t === null ? "" : typeof t == "boolean" ? Ht(t, e) : typeof t == "number" ? Xe(t, e.cell.numberFormat) : String(t);
|
|
1042
1054
|
}
|
|
1043
|
-
function
|
|
1044
|
-
const r =
|
|
1055
|
+
function Cn(e, t, n) {
|
|
1056
|
+
const r = ce(e, t);
|
|
1045
1057
|
if (!r) throw new M("missing");
|
|
1046
|
-
return
|
|
1058
|
+
return me(r, n);
|
|
1047
1059
|
}
|
|
1048
|
-
function
|
|
1060
|
+
function me(e, t) {
|
|
1049
1061
|
if (!e.editable) throw new M("readonly");
|
|
1050
|
-
const n =
|
|
1062
|
+
const n = ue(e, t);
|
|
1051
1063
|
return {
|
|
1052
1064
|
address: { ...e.address },
|
|
1053
1065
|
table: e.table,
|
|
@@ -1055,80 +1067,80 @@ function de(e, t) {
|
|
|
1055
1067
|
previousValue: e.value,
|
|
1056
1068
|
previousText: e.cell.text ?? "",
|
|
1057
1069
|
value: n,
|
|
1058
|
-
text:
|
|
1070
|
+
text: Q(e, n)
|
|
1059
1071
|
};
|
|
1060
1072
|
}
|
|
1061
|
-
function
|
|
1073
|
+
function Wt(e, t) {
|
|
1062
1074
|
const n = e.table, r = t.table;
|
|
1063
1075
|
return !n || !r || n.columnKey === void 0 ? !1 : n.id === r.id && n.rowIndex === r.rowIndex && n.role === r.role && n.columnKey === r.columnKey;
|
|
1064
1076
|
}
|
|
1065
|
-
function
|
|
1066
|
-
const r = e.grid, { rowIndex: i, columnIndex: l } = t.address, o =
|
|
1077
|
+
function He(e, t, n) {
|
|
1078
|
+
const r = e.grid, { rowIndex: i, columnIndex: l } = t.address, o = ze(e, i, l), a = [...r.cells], s = [...a[i]], c = Q(t, n.value), d = { ...o.cell, value: n.value, text: c, rawText: c };
|
|
1067
1079
|
return s[o.sourceColumnIndex] = d, a[i] = s, { ...e, grid: { ...r, cells: a } };
|
|
1068
1080
|
}
|
|
1069
|
-
function
|
|
1081
|
+
function Bt(e, t) {
|
|
1070
1082
|
const n = e.table?.columnKeys, r = t.table?.columnKey;
|
|
1071
1083
|
return n && r !== void 0 ? n.flatMap((i, l) => i === r ? [l] : []) : [];
|
|
1072
1084
|
}
|
|
1073
|
-
function
|
|
1085
|
+
function _t(e, t, n, r, i, l) {
|
|
1074
1086
|
const o = t.table, a = i.table;
|
|
1075
1087
|
if (!o || !a || o.id !== a.id || o.role !== a.role || !t.grid) return t;
|
|
1076
1088
|
const s = a.rowIndex - o.rowIndex;
|
|
1077
1089
|
if (s < 0 || s >= t.grid.cells.length) return t;
|
|
1078
1090
|
let c = t;
|
|
1079
|
-
for (const d of
|
|
1080
|
-
const u =
|
|
1081
|
-
u?.editable &&
|
|
1091
|
+
for (const d of Bt(t, i)) {
|
|
1092
|
+
const u = ce(e, { pageIndex: n, componentIndex: r, rowIndex: s, columnIndex: d });
|
|
1093
|
+
u?.editable && Wt(i, u) && (c = He(c, u, l));
|
|
1082
1094
|
}
|
|
1083
1095
|
return c;
|
|
1084
1096
|
}
|
|
1085
|
-
function
|
|
1097
|
+
function Kt(e, t, n, r, i, l) {
|
|
1086
1098
|
const o = i.address;
|
|
1087
|
-
return i.table?.columnKey !== void 0 ?
|
|
1099
|
+
return i.table?.columnKey !== void 0 ? _t(e, t, n, r, i, l) : o.pageIndex === n && o.componentIndex === r ? He(t, i, l) : t;
|
|
1088
1100
|
}
|
|
1089
|
-
function
|
|
1101
|
+
function We(e, t) {
|
|
1090
1102
|
const n = t.source;
|
|
1091
1103
|
if (!n) return !1;
|
|
1092
1104
|
const r = e.source;
|
|
1093
1105
|
return !r || ["datasetId", "rowKey", "field", "revision", "sourceToken"].some((i) => !Object.is(r[i], n[i]));
|
|
1094
1106
|
}
|
|
1095
|
-
function
|
|
1096
|
-
const n =
|
|
1107
|
+
function Pn(e, t) {
|
|
1108
|
+
const n = ce(e, t.address);
|
|
1097
1109
|
if (!n) throw new M("missing");
|
|
1098
1110
|
if (!n.editable) throw new M("readonly");
|
|
1099
|
-
if (
|
|
1111
|
+
if (We(n, t)) throw new M("conflict");
|
|
1100
1112
|
if (!Object.is(n.value, t.previousValue) || (n.cell.text ?? "") !== t.previousText) throw new M("conflict");
|
|
1101
|
-
const r =
|
|
1113
|
+
const r = ue(n, t.value), i = { ...t, value: r, text: Q(n, r) };
|
|
1102
1114
|
if (Object.is(r, n.value) && i.text === n.cell.text) return e;
|
|
1103
1115
|
const l = e.pages.map((o, a) => {
|
|
1104
|
-
const s = o.components.map((c, d) =>
|
|
1116
|
+
const s = o.components.map((c, d) => Kt(e, c, a, d, n, i));
|
|
1105
1117
|
return s.every((c, d) => c === o.components[d]) ? o : { ...o, components: s };
|
|
1106
1118
|
});
|
|
1107
1119
|
return { ...e, pages: l };
|
|
1108
1120
|
}
|
|
1109
|
-
function
|
|
1121
|
+
function Vt(e) {
|
|
1110
1122
|
return JSON.stringify([e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex]);
|
|
1111
1123
|
}
|
|
1112
|
-
function
|
|
1124
|
+
function ye(e) {
|
|
1113
1125
|
const t = e.table;
|
|
1114
|
-
return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) :
|
|
1126
|
+
return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) : Vt(e.address);
|
|
1115
1127
|
}
|
|
1116
|
-
function
|
|
1128
|
+
function qt(e, t) {
|
|
1117
1129
|
if (!t.length) return e;
|
|
1118
|
-
const n = new Map(t.map((s) => [
|
|
1130
|
+
const n = new Map(t.map((s) => [ye(s), s])), r = new Set(t.flatMap((s) => s.table ? [s.table.id] : [])), i = new Set(t.map((s) => `${s.address.pageIndex}:${s.address.componentIndex}`)), l = de(e);
|
|
1119
1131
|
function o(s, c, d) {
|
|
1120
1132
|
const u = s.grid;
|
|
1121
1133
|
if (!u || !i.has(`${c}:${d}`) && !r.has(s.table?.id ?? "")) return s;
|
|
1122
1134
|
const m = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
1123
|
-
for (const
|
|
1124
|
-
const
|
|
1125
|
-
f.set(
|
|
1126
|
-
const
|
|
1127
|
-
if (!
|
|
1128
|
-
const
|
|
1129
|
-
Object.is(
|
|
1135
|
+
for (const h of W(u, s.widthMm, s.heightMm).cells) {
|
|
1136
|
+
const g = f.get(h.ri) ?? 0;
|
|
1137
|
+
f.set(h.ri, g + 1);
|
|
1138
|
+
const b = l({ pageIndex: c, componentIndex: d, rowIndex: h.ri, columnIndex: h.ci }), x = b && n.get(ye(b));
|
|
1139
|
+
if (!x || !b.editable) continue;
|
|
1140
|
+
const T = m.get(h.ri) ?? [...u.cells[h.ri]], k = Q(b, x.value);
|
|
1141
|
+
Object.is(b.value, x.value) && k === b.cell.text || (T[g] = { ...h.cell, value: x.value, text: k, rawText: k }, m.set(h.ri, T));
|
|
1130
1142
|
}
|
|
1131
|
-
return m.size ? { ...s, grid: { ...u, cells: u.cells.map((
|
|
1143
|
+
return m.size ? { ...s, grid: { ...u, cells: u.cells.map((h, g) => m.get(g) ?? h) } } : s;
|
|
1132
1144
|
}
|
|
1133
1145
|
const a = e.pages.map((s, c) => {
|
|
1134
1146
|
const d = s.components.map((u, m) => o(u, c, m));
|
|
@@ -1136,7 +1148,7 @@ function Ht(e, t) {
|
|
|
1136
1148
|
});
|
|
1137
1149
|
return a.every((s, c) => s === e.pages[c]) ? e : { ...e, pages: a };
|
|
1138
1150
|
}
|
|
1139
|
-
function
|
|
1151
|
+
function fe(e) {
|
|
1140
1152
|
const t = e.source;
|
|
1141
1153
|
if (t) return JSON.stringify([t.datasetId, t.rowKey, t.field]);
|
|
1142
1154
|
const n = e.table;
|
|
@@ -1144,47 +1156,47 @@ function ue(e) {
|
|
|
1144
1156
|
const r = e.address;
|
|
1145
1157
|
return JSON.stringify([r.pageIndex, r.componentIndex, r.rowIndex, r.columnIndex]);
|
|
1146
1158
|
}
|
|
1147
|
-
function
|
|
1159
|
+
function kn(e, t, n) {
|
|
1148
1160
|
if (typeof n != "string" || !n.trim() || !Array.isArray(t)) throw new M("missing");
|
|
1149
1161
|
if (t.length > 1e4) throw new M("limit");
|
|
1150
|
-
const r = /* @__PURE__ */ new Set(), i =
|
|
1162
|
+
const r = /* @__PURE__ */ new Set(), i = de(e), l = t.map(({ address: o, value: a }) => {
|
|
1151
1163
|
const s = i(o);
|
|
1152
1164
|
if (!s) throw new M("missing");
|
|
1153
|
-
const c =
|
|
1165
|
+
const c = me(s, a), d = fe(c);
|
|
1154
1166
|
if (r.has(d)) throw new M("duplicate");
|
|
1155
1167
|
return r.add(d), c;
|
|
1156
1168
|
});
|
|
1157
1169
|
return { requestId: n, edits: l };
|
|
1158
1170
|
}
|
|
1159
|
-
function
|
|
1171
|
+
function Rn(e, t) {
|
|
1160
1172
|
if (t.edits.length > 1e4) throw new M("limit");
|
|
1161
|
-
const n =
|
|
1173
|
+
const n = de(e), r = /* @__PURE__ */ new Set(), i = t.edits.map((l) => {
|
|
1162
1174
|
const o = n(l.address);
|
|
1163
1175
|
if (!o) throw new M("missing");
|
|
1164
|
-
const a =
|
|
1176
|
+
const a = fe(l);
|
|
1165
1177
|
if (r.has(a)) throw new M("duplicate");
|
|
1166
|
-
if (r.add(a),
|
|
1167
|
-
return
|
|
1178
|
+
if (r.add(a), We(o, l) || !Object.is(o.value, l.previousValue) || (o.cell.text ?? "") !== l.previousText) throw new M("conflict");
|
|
1179
|
+
return me(o, l.value);
|
|
1168
1180
|
});
|
|
1169
|
-
return
|
|
1181
|
+
return qt(e, i);
|
|
1170
1182
|
}
|
|
1171
|
-
function
|
|
1183
|
+
function In(e) {
|
|
1172
1184
|
const t = /* @__PURE__ */ new Map();
|
|
1173
1185
|
for (const n of e) {
|
|
1174
|
-
const r =
|
|
1186
|
+
const r = fe(n), i = t.get(r), l = i ? { ...n, previousValue: i.previousValue, previousText: i.previousText } : { ...n };
|
|
1175
1187
|
Object.is(l.previousValue, l.value) ? t.delete(r) : t.set(r, l);
|
|
1176
1188
|
}
|
|
1177
1189
|
return [...t.values()];
|
|
1178
1190
|
}
|
|
1179
|
-
function
|
|
1191
|
+
function An(e) {
|
|
1180
1192
|
return e.map((t) => t.map((n) => /[\t\r\n"]/.test(n) ? `"${n.replace(/"/g, '""')}"` : n).join(" ")).join(`\r
|
|
1181
1193
|
`);
|
|
1182
1194
|
}
|
|
1183
|
-
function
|
|
1195
|
+
function Gt(e, t) {
|
|
1184
1196
|
const n = e[e.length - 1];
|
|
1185
1197
|
e.length > 1 && n?.length === 1 && n[0] === "" && /[\r\n]$/.test(t) && e.pop();
|
|
1186
1198
|
}
|
|
1187
|
-
function
|
|
1199
|
+
function $n(e, t = 1e4) {
|
|
1188
1200
|
if (e.length > 4 * 1024 * 1024) throw new Error("Clipboard text limit exceeded");
|
|
1189
1201
|
const n = [[]];
|
|
1190
1202
|
let r = "", i = !1, l = !1, o = 0;
|
|
@@ -1224,9 +1236,9 @@ function wn(e, t = 1e4) {
|
|
|
1224
1236
|
r += c;
|
|
1225
1237
|
}
|
|
1226
1238
|
if (i) throw new Error("Unclosed clipboard quote");
|
|
1227
|
-
return a(),
|
|
1239
|
+
return a(), Gt(n, e), n;
|
|
1228
1240
|
}
|
|
1229
|
-
function
|
|
1241
|
+
function Nn(e, t, n) {
|
|
1230
1242
|
if (!n || n.revision === void 0 && n.sourceToken === void 0) return e;
|
|
1231
1243
|
const r = new Set(t.edits.flatMap((o) => o.source ? [o.source.datasetId] : []));
|
|
1232
1244
|
if (!r.size) return e;
|
|
@@ -1236,118 +1248,180 @@ function bn(e, t, n) {
|
|
|
1236
1248
|
const l = e.pages.map((o) => {
|
|
1237
1249
|
const a = o.components.map((s) => {
|
|
1238
1250
|
const c = s.table?.source ? i(s.table.source) : void 0, d = s.table && c !== s.table.source ? { ...s.table, source: c } : s.table, u = s.grid?.cells.map((f) => {
|
|
1239
|
-
const
|
|
1240
|
-
if (!
|
|
1241
|
-
const
|
|
1242
|
-
return
|
|
1251
|
+
const h = f.map((g) => {
|
|
1252
|
+
if (!g?.source) return g;
|
|
1253
|
+
const b = i(g.source);
|
|
1254
|
+
return b === g.source ? g : { ...g, source: b };
|
|
1243
1255
|
});
|
|
1244
|
-
return
|
|
1245
|
-
}), m = s.grid && u?.some((f,
|
|
1256
|
+
return h.some((g, b) => g !== f[b]) ? h : f;
|
|
1257
|
+
}), m = s.grid && u?.some((f, h) => f !== s.grid.cells[h]) ? { ...s.grid, cells: u } : s.grid;
|
|
1246
1258
|
return d !== s.table || m !== s.grid ? { ...s, table: d, grid: m } : s;
|
|
1247
1259
|
});
|
|
1248
1260
|
return a.some((s, c) => s !== o.components[c]) ? { ...o, components: a } : o;
|
|
1249
1261
|
});
|
|
1250
1262
|
return l.some((o, a) => o !== e.pages[a]) ? { ...e, pages: l } : e;
|
|
1251
1263
|
}
|
|
1264
|
+
class Ut extends Error {
|
|
1265
|
+
constructor(t, n, r) {
|
|
1266
|
+
const i = typeof n.label == "string" ? n.label : "单元格", l = {
|
|
1267
|
+
definition: `${i}的编辑器配置无效`,
|
|
1268
|
+
type: `${i}的编辑器与数据类型不一致`,
|
|
1269
|
+
required: `${i}不能为空`,
|
|
1270
|
+
min: `${i}不能小于 ${r}`,
|
|
1271
|
+
max: `${i}不能大于 ${r}`,
|
|
1272
|
+
precision: `${i}最多保留 ${r} 位小数`,
|
|
1273
|
+
length: `${i}最多允许 ${r} 个字符`,
|
|
1274
|
+
choice: `${i}请选择有效选项`,
|
|
1275
|
+
date: `${i}请输入有效日期(YYYY-MM-DD)`
|
|
1276
|
+
};
|
|
1277
|
+
super(l[t]), this.code = t, this.field = n, this.expected = r, this.name = "ReportCellFieldError";
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
function w(e, t, n) {
|
|
1281
|
+
throw new Ut(t, e, n);
|
|
1282
|
+
}
|
|
1283
|
+
function Be(e) {
|
|
1284
|
+
if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}$/.test(e) || e.startsWith("0000-")) return !1;
|
|
1285
|
+
const t = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
|
|
1286
|
+
return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
|
|
1287
|
+
}
|
|
1288
|
+
function Jt(e) {
|
|
1289
|
+
const [t = "", n = "0"] = String(e).toLowerCase().split("e");
|
|
1290
|
+
return Math.max(0, (t.split(".")[1]?.length ?? 0) - Number(n));
|
|
1291
|
+
}
|
|
1292
|
+
function Yt(e, t) {
|
|
1293
|
+
e.min !== void 0 && t < e.min && w(e, "min", e.min), e.max !== void 0 && t > e.max && w(e, "max", e.max), e.precision !== void 0 && Jt(t) > e.precision && w(e, "precision", e.precision);
|
|
1294
|
+
}
|
|
1295
|
+
function Xt(e, t) {
|
|
1296
|
+
Be(t) || w(e, "date"), e.min !== void 0 && t < e.min && w(e, "min", e.min), e.max !== void 0 && t > e.max && w(e, "max", e.max);
|
|
1297
|
+
}
|
|
1298
|
+
function Qt(e) {
|
|
1299
|
+
[e.min, e.max].some((t) => t !== void 0 && !Number.isFinite(t)) && w(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && w(e, "definition"), e.precision !== void 0 && (!Number.isInteger(e.precision) || e.precision < 0 || e.precision > 15) && w(e, "definition");
|
|
1300
|
+
}
|
|
1301
|
+
function Zt(e) {
|
|
1302
|
+
[e.min, e.max].some((t) => t !== void 0 && !Be(t)) && w(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && w(e, "definition");
|
|
1303
|
+
}
|
|
1304
|
+
function en(e, t) {
|
|
1305
|
+
(!Array.isArray(t.options) || !t.options.length) && w(t, "definition");
|
|
1306
|
+
const n = e.valueType === "text" ? "string" : e.valueType, r = /* @__PURE__ */ new Set();
|
|
1307
|
+
for (const i of t.options)
|
|
1308
|
+
(!i || typeof i.value !== n || typeof i.value == "number" && !Number.isFinite(i.value)) && w(t, "definition"), i.label !== void 0 && typeof i.label != "string" && w(t, "definition"), r.has(i.value) && w(t, "definition"), r.add(i.value);
|
|
1309
|
+
}
|
|
1310
|
+
function tn(e) {
|
|
1311
|
+
e.required !== void 0 && typeof e.required != "boolean" && w(e, "definition"), [e.label, e.hint, e.unit].some((t) => t !== void 0 && typeof t != "string") && w(e, "definition"), e.type === "boolean" && [e.trueLabel, e.falseLabel].some((t) => t !== void 0 && typeof t != "string") && w(e, "definition");
|
|
1312
|
+
}
|
|
1313
|
+
function nn(e, t) {
|
|
1314
|
+
(!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && w(t ?? { type: "text" }, "definition"), tn(t), (t.type === "number" || t.type === "boolean") && e.valueType !== t.type && w(t, "type"), (t.type === "text" || t.type === "date") && e.valueType !== "text" && w(t, "type"), t.type === "number" && Qt(t), t.type === "text" && t.maxLength !== void 0 && (!Number.isInteger(t.maxLength) || t.maxLength < 0) && w(t, "definition"), t.type === "date" && Zt(t), t.type === "enum" && en(e, t);
|
|
1315
|
+
}
|
|
1316
|
+
function Ln(e, t, n) {
|
|
1317
|
+
if (!e.editable) throw new M("readonly");
|
|
1318
|
+
n && nn(e, n);
|
|
1319
|
+
const r = ue(e, t);
|
|
1320
|
+
return n ? (n.required && typeof r == "string" && !r.trim() && w(n, "required"), r === null || r === "" ? (n.required && w(n, "required"), r) : (n.type === "number" && Yt(n, r), n.type === "date" && Xt(n, r), n.type === "text" && n.maxLength !== void 0 && [...String(r)].length > n.maxLength && w(n, "length", n.maxLength), n.type === "enum" && !n.options.some((i) => Object.is(i.value, r)) && w(n, "choice"), r)) : r;
|
|
1321
|
+
}
|
|
1252
1322
|
export {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1323
|
+
nr as CSS_DPI,
|
|
1324
|
+
On as DEFAULT_BORDER_PT,
|
|
1325
|
+
Y as DEFAULT_FONT_FAMILY,
|
|
1326
|
+
zn as DEFAULT_FONT_PT,
|
|
1327
|
+
jn as DEFAULT_STROKE_COLOR,
|
|
1328
|
+
Me as DEFAULT_TEXT_COLOR,
|
|
1329
|
+
Hn as LINE_HEIGHT,
|
|
1330
|
+
rr as MM_PER_INCH,
|
|
1331
|
+
wr as OutputAssetError,
|
|
1332
|
+
Je as OutputFidelityError,
|
|
1262
1333
|
G as PAPER_SIZES,
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1334
|
+
Et as PageBuilder,
|
|
1335
|
+
Kn as PaginatePageLimitError,
|
|
1336
|
+
Wn as RENDER_PLAN_SCHEMA_VERSION,
|
|
1337
|
+
Mr as REPORT_TEMPLATE_DOCUMENT_VERSION,
|
|
1267
1338
|
M as ReportCellEditError,
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1339
|
+
Ut as ReportCellFieldError,
|
|
1340
|
+
Rr as ReportParamValidationError,
|
|
1341
|
+
Vn as ReportSourceError,
|
|
1342
|
+
xr as ReportTemplateError,
|
|
1343
|
+
L as ReportTemplateStoreError,
|
|
1344
|
+
Bn as SCHEMA_VERSION_MACH,
|
|
1345
|
+
Tt as TemplateBuilder,
|
|
1346
|
+
Pn as applyReportCellEdit,
|
|
1347
|
+
Rn as applyReportCellEditBatch,
|
|
1348
|
+
Nn as applyReportEditResult,
|
|
1349
|
+
sr as assertRenderPlan,
|
|
1350
|
+
Ir as assertReportParams,
|
|
1351
|
+
mr as charWidthEm,
|
|
1352
|
+
S as classOf,
|
|
1353
|
+
Mn as columnsFromContract,
|
|
1354
|
+
gt as computePageWindow,
|
|
1355
|
+
fr as createCanvasMeasurer,
|
|
1356
|
+
vn as createCanvasPager,
|
|
1357
|
+
hr as createHeuristicMeasurer,
|
|
1358
|
+
Sn as createMemoryTemplateStore,
|
|
1359
|
+
Tn as createProviderReport,
|
|
1360
|
+
Cn as createReportCellEdit,
|
|
1361
|
+
kn as createReportCellEditBatch,
|
|
1362
|
+
de as createReportCellResolver,
|
|
1363
|
+
qn as createReportSource,
|
|
1364
|
+
xn as createTableTemplate,
|
|
1365
|
+
yn as createTemplate,
|
|
1366
|
+
En as createTemplateManager,
|
|
1367
|
+
Tr as createTemplateRegistry,
|
|
1368
|
+
Gn as datasetJsonSchema,
|
|
1369
|
+
Un as defineReport,
|
|
1370
|
+
Er as defineReportTemplate,
|
|
1371
|
+
Jn as evalStyleRule,
|
|
1372
|
+
Q as formatReportCellEdit,
|
|
1373
|
+
An as formatReportClipboard,
|
|
1374
|
+
Yn as formatValue,
|
|
1375
|
+
ce as getReportCellContext,
|
|
1376
|
+
ie as heuristicMeasurer,
|
|
1377
|
+
vr as inspectOutputCapabilities,
|
|
1306
1378
|
J as isImageBackedComponent,
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1379
|
+
Ar as isReportDate,
|
|
1380
|
+
xe as isRichText,
|
|
1381
|
+
se as measurePageSizePx,
|
|
1382
|
+
gr as measureTextMm,
|
|
1383
|
+
Ee as mergeComponentStyles,
|
|
1384
|
+
re as mmToPx,
|
|
1385
|
+
ir as mmToPxFactor,
|
|
1386
|
+
Xn as paginateTemplate,
|
|
1387
|
+
Qn as parseDateLocal,
|
|
1388
|
+
Ln as parseReportCellFieldInput,
|
|
1389
|
+
ue as parseReportCellInput,
|
|
1390
|
+
$n as parseReportClipboard,
|
|
1391
|
+
ne as parseReportTemplate,
|
|
1392
|
+
gn as planFontSizePx,
|
|
1393
|
+
D as ptToPx,
|
|
1394
|
+
or as pxToMm,
|
|
1395
|
+
Ie as renderComponent,
|
|
1396
|
+
dt as renderPage,
|
|
1397
|
+
hn as renderPlan,
|
|
1398
|
+
wn as renderPlanToCanvas,
|
|
1399
|
+
bn as renderPlanToCanvasAsync,
|
|
1400
|
+
pn as renderPlanToImages,
|
|
1401
|
+
fe as reportCellEditKey,
|
|
1402
|
+
B as reportOutputDiagnostics,
|
|
1403
|
+
$r as reportParamsJsonSchema,
|
|
1404
|
+
Te as resolveBoxBorders,
|
|
1405
|
+
z as resolveFontSize,
|
|
1406
|
+
W as resolveGridLayout,
|
|
1334
1407
|
X as resolveLineHeight,
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1408
|
+
De as resolvePaper,
|
|
1409
|
+
oe as resolvePlanAssets,
|
|
1410
|
+
H as resolveStroke,
|
|
1411
|
+
Se as resolveTextColor,
|
|
1412
|
+
O as round,
|
|
1413
|
+
Sr as serializeReportTemplate,
|
|
1414
|
+
In as summarizeReportCellEdits,
|
|
1415
|
+
Zn as toExcelNumberFormat,
|
|
1416
|
+
er as toNumber,
|
|
1417
|
+
lr as validateComponent,
|
|
1418
|
+
Ge as validateDatasetRows,
|
|
1419
|
+
cr as validatePage,
|
|
1420
|
+
dr as validateRenderPlan,
|
|
1421
|
+
nn as validateReportCellFieldDefinition,
|
|
1422
|
+
Nr as validateReportParamDefinitions,
|
|
1423
|
+
Lr as validateReportParams,
|
|
1424
|
+
Cr as validateReportTemplate,
|
|
1425
|
+
Pr as validateReportTemplateDocument,
|
|
1426
|
+
Ce as wrapText
|
|
1353
1427
|
};
|