@agile-team/mach-report 2.11.0 → 2.11.1
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 +3 -3
- package/dist/ExcelBindingWizard-LWX6G1A2.js +1465 -0
- package/dist/ExcelBindingWizard-a4kslPHF.cjs +1 -0
- package/dist/ParamEditor-BLaE5q5W.js +522 -0
- package/dist/ParamEditor-MBBC7lUE.cjs +1 -0
- package/dist/ReportBatchPanel-B5ClP9tm.js +350 -0
- package/dist/ReportBatchPanel-Dc-SDkYA.cjs +1 -0
- package/dist/ReportTemplateLibrary-5fk5CQBO.cjs +1 -0
- package/dist/ReportTemplateLibrary-BZB-XWjj.js +311 -0
- package/dist/designer.cjs +2 -2
- package/dist/designer.d.cts +73 -2
- package/dist/designer.d.ts +73 -2
- package/dist/designer.js +1509 -1407
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +19 -5
- package/dist/index.d.ts +19 -5
- package/dist/index.js +502 -494
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/ExcelBindingWizard-CjIiVox-.cjs +0 -1
- package/dist/ExcelBindingWizard-Dxm-K5HL.js +0 -1240
- package/dist/ParamEditor-D-Hf5xfO.cjs +0 -1
- package/dist/ParamEditor-DRGxzxeO.js +0 -381
- package/dist/ReportBatchPanel-BYgg0EDB.cjs +0 -1
- package/dist/ReportBatchPanel-Bby5yLzU.js +0 -287
- package/dist/ReportTemplateLibrary-C6CO7YCT.cjs +0 -1
- package/dist/ReportTemplateLibrary-DfzDXRvr.js +0 -260
package/dist/index.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { D as Z, a as
|
|
2
|
-
import { b as
|
|
3
|
-
import { e as
|
|
1
|
+
import { D as Z, a as ye } from "./defaults-DXhiM1ZD.js";
|
|
2
|
+
import { b as In, c as $n, d as Nn, L as Ln, S as Dn } from "./defaults-DXhiM1ZD.js";
|
|
3
|
+
import { e as On, f as zn, p as Hn, t as Wn, c as _n } from "./list-cell-ClFra1zS.js";
|
|
4
4
|
import { a as H, r as W, b as Q, c as j, d as Me, m as ie, e as xe, p as O, f as Ee, P as K } from "./style-CQ1PK8ZB.js";
|
|
5
|
-
import { C as
|
|
5
|
+
import { C as Bn, M as Gn, g as Un, h as Vn } from "./style-CQ1PK8ZB.js";
|
|
6
6
|
import { i as ee, a as Se } from "./render-plan-Ck6koX9L.js";
|
|
7
|
-
import { R as
|
|
8
|
-
import { a as
|
|
7
|
+
import { R as Yn } from "./render-plan-Ck6koX9L.js";
|
|
8
|
+
import { a as Xn, v as Jn, b as Zn, c as Qn } from "./validate-7s0yn6ii.js";
|
|
9
9
|
import { v as je } from "./dataset-H5pFuQGU.js";
|
|
10
|
-
import { d as
|
|
11
|
-
import { h as
|
|
12
|
-
import { c as
|
|
10
|
+
import { d as tr } from "./dataset-H5pFuQGU.js";
|
|
11
|
+
import { h as oe, w as Te } from "./textwrap-DE1kgcJB.js";
|
|
12
|
+
import { c as rr, a as ir, b as or, m as ar } from "./textwrap-DE1kgcJB.js";
|
|
13
13
|
import { R as Be, p as Ge } from "./template-review-BdcXSYbx.js";
|
|
14
|
-
import { P as
|
|
14
|
+
import { P as lr, a as cr, b as dr, c as mr, d as hr, e as ur, f as gr, g as fr, h as pr, i as wr, j as br, k as vr, l as yr, m as Mr, n as xr, o as Er, q as Sr, r as Tr, s as Cr, t as Rr, u as Pr, v as Ar, w as kr, x as Ir, y as $r, z as Nr } from "./template-review-BdcXSYbx.js";
|
|
15
15
|
import { r as Ce } from "./grid-geometry-BNptEcMm.js";
|
|
16
|
-
import { r as Re, a as
|
|
17
|
-
import { O as
|
|
16
|
+
import { r as Re, a as ae } from "./assets-DegqDNqY.js";
|
|
17
|
+
import { O as Dr } from "./assets-DegqDNqY.js";
|
|
18
18
|
import { r as G, n as Pe, O as Ue } from "./capabilities-CK_7hizc.js";
|
|
19
|
-
import { i as
|
|
19
|
+
import { i as Or } from "./capabilities-CK_7hizc.js";
|
|
20
20
|
import { o as Ve } from "./progress-7OSZbFok.js";
|
|
21
21
|
import { c as qe } from "./page-window-index-CIuT4BAv.js";
|
|
22
|
-
import { p as
|
|
23
|
-
import { R as
|
|
24
|
-
import { R as
|
|
25
|
-
import { T as
|
|
22
|
+
import { p as I } from "./template-registry-WNXdkiET.js";
|
|
23
|
+
import { R as Hr, a as Wr, c as _r, d as jr, s as Br, v as Gr, b as Ur } from "./template-registry-WNXdkiET.js";
|
|
24
|
+
import { R as qr, a as Yr, f as Kr, i as Xr, b as Jr, c as Zr, p as Qr, r as ei, v as ti, d as ni } from "./param-validation-BlHHXs6u.js";
|
|
25
|
+
import { T as ii, c as oi, v as ai } from "./tree-CqcQ99NM.js";
|
|
26
26
|
const Ye = {
|
|
27
27
|
root: "mr-root",
|
|
28
28
|
page: "mr-page",
|
|
@@ -64,7 +64,7 @@ class Ke {
|
|
|
64
64
|
n && (t.style.cssText = n);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function y(e, t = "unset") {
|
|
68
68
|
return new Ke().add("all", t).add("display", e).add("box-sizing", "border-box");
|
|
69
69
|
}
|
|
70
70
|
function Ae(e, t, n) {
|
|
@@ -77,65 +77,65 @@ function Xe(e, t, n) {
|
|
|
77
77
|
Ae(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);
|
|
78
78
|
}
|
|
79
79
|
function Je(e, t, n, r, i, o) {
|
|
80
|
-
const
|
|
81
|
-
a.className = E("cell", i), a.dataset.mrRowIndex = String(e.ri), a.dataset.mrColumnIndex = String(e.ci), a.setAttribute("role", t.table?.role === "header" ? "columnheader" : "cell"),
|
|
82
|
-
const
|
|
83
|
-
Ae(c,
|
|
80
|
+
const s = e.cell, a = o.createElement("td");
|
|
81
|
+
a.className = E("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);
|
|
82
|
+
const l = xe(t.style, s.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", l.backgroundColor).add("vertical-align", l.verticalAlign ?? "middle");
|
|
83
|
+
Ae(c, l, r), c.applyTo(a);
|
|
84
84
|
const d = o.createElement("div");
|
|
85
|
-
d.className = "mr-cell-content",
|
|
86
|
-
for (const m of
|
|
85
|
+
d.className = "mr-cell-content", y("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(d), s.text != null && d.append(s.text);
|
|
86
|
+
for (const m of s.children ?? []) d.appendChild(ke(m, r, i, o));
|
|
87
87
|
return a.appendChild(d), a;
|
|
88
88
|
}
|
|
89
89
|
function Ze(e, t, n, r) {
|
|
90
90
|
return Re(e, t).map((i) => {
|
|
91
|
-
const o = `${H(i.widthPt * n / 72, 2)}px solid ${i.color}`,
|
|
92
|
-
|
|
91
|
+
const o = `${H(i.widthPt * n / 72, 2)}px solid ${i.color}`, s = r.createElement("div");
|
|
92
|
+
s.className = "mr-grid-edge", s.setAttribute("aria-hidden", "true");
|
|
93
93
|
const a = i.kind === "h";
|
|
94
|
-
return
|
|
94
|
+
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", o).applyTo(s), s;
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
function Qe(e, t, n, r, i) {
|
|
98
98
|
const o = i.createElement("table");
|
|
99
|
-
o.className = E("grid", r), o.setAttribute("role", "table"),
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
const
|
|
99
|
+
o.className = E("grid", r), o.setAttribute("role", "table"), y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(o);
|
|
100
|
+
const s = Ce(e, t.widthMm, t.heightMm), a = i.createElement("tbody");
|
|
101
|
+
y("contents").applyTo(a), o.appendChild(a);
|
|
102
|
+
const l = e.cells.map(() => {
|
|
103
103
|
const d = i.createElement("tr");
|
|
104
|
-
return d.className = E("row", r), d.setAttribute("role", "row"),
|
|
104
|
+
return d.className = E("row", r), d.setAttribute("role", "row"), y("contents").applyTo(d), a.appendChild(d), d;
|
|
105
105
|
});
|
|
106
|
-
for (const d of
|
|
107
|
-
|
|
106
|
+
for (const d of s.cells)
|
|
107
|
+
l[d.ri].appendChild(Je(d, t, e.paddingMm ?? 0.5, n, r, i));
|
|
108
108
|
const c = i.createElement("div");
|
|
109
|
-
return
|
|
109
|
+
return y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(o, ...Ze(s, t, n, i)), c;
|
|
110
110
|
}
|
|
111
111
|
function et(e, t, n, r) {
|
|
112
112
|
const i = r.createElement("div");
|
|
113
|
-
i.className = E("paragraph", n),
|
|
113
|
+
i.className = E("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);
|
|
114
114
|
for (const o of e.segments || []) {
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
const a =
|
|
115
|
+
const s = r.createElement("span");
|
|
116
|
+
s.className = E("segment", n), s.textContent = o.kind === "field" ? o.field ?? "" : o.text ?? "";
|
|
117
|
+
const a = y("inline");
|
|
118
118
|
if (o.style) {
|
|
119
|
-
const
|
|
120
|
-
a.add("color",
|
|
119
|
+
const l = o.style;
|
|
120
|
+
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", `${H(W(l, t).fontSizePx, 2)}px`);
|
|
121
121
|
}
|
|
122
|
-
a.applyTo(
|
|
122
|
+
a.applyTo(s), i.appendChild(s);
|
|
123
123
|
}
|
|
124
124
|
return i;
|
|
125
125
|
}
|
|
126
126
|
function tt(e, t, n, r) {
|
|
127
127
|
if (Se(e)) {
|
|
128
128
|
const i = r.createElement("div");
|
|
129
|
-
i.className = E("rich", n),
|
|
129
|
+
i.className = E("rich", n), y("block").applyTo(i);
|
|
130
130
|
for (const o of e.richParagraphs) i.appendChild(et(o, t, n, r));
|
|
131
131
|
return i;
|
|
132
132
|
}
|
|
133
133
|
if (Array.isArray(e.lines) && e.lines.length > 0) {
|
|
134
134
|
const i = r.createElement("div");
|
|
135
|
-
i.className = E("lines", n),
|
|
135
|
+
i.className = E("lines", n), y("block").applyTo(i);
|
|
136
136
|
for (const o of e.lines) {
|
|
137
|
-
const
|
|
138
|
-
|
|
137
|
+
const s = r.createElement("div");
|
|
138
|
+
s.className = E("line", n), s.textContent = o, y("block").add("white-space", "pre").add("min-height", "1lh").applyTo(s), i.appendChild(s);
|
|
139
139
|
}
|
|
140
140
|
return i;
|
|
141
141
|
}
|
|
@@ -145,74 +145,74 @@ function nt(e, t, n, r) {
|
|
|
145
145
|
const i = r.createElement("div");
|
|
146
146
|
i.className = E("text", n);
|
|
147
147
|
const o = e.style || {};
|
|
148
|
-
return
|
|
148
|
+
return y("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", o.verticalAlign === "middle" ? "center" : o.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(i), i.append(tt(e, t, n, r)), i;
|
|
149
149
|
}
|
|
150
150
|
function rt(e, t, n) {
|
|
151
151
|
const r = n.createElement("img");
|
|
152
|
-
return r.className = E("image", t), r.src = e.imageData,
|
|
152
|
+
return r.className = E("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;
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function ge(e, t, n, r) {
|
|
155
155
|
const i = r.createElement("div");
|
|
156
156
|
i.className = E("shape", n);
|
|
157
|
-
const o = e.style || {},
|
|
158
|
-
return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (a.top && c.add("border-top",
|
|
157
|
+
const o = e.style || {}, s = j(o), a = Me(o), l = `${H(s.widthPt * t / 72, 2)}px solid ${s.color}`, c = y("block");
|
|
158
|
+
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;
|
|
159
159
|
}
|
|
160
160
|
function it(e, t, n) {
|
|
161
161
|
const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), i = ie(e.widthMm, t), o = ie(e.heightMm, t);
|
|
162
162
|
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";
|
|
163
|
-
const
|
|
164
|
-
|
|
163
|
+
const s = n.createElementNS("http://www.w3.org/2000/svg", "line");
|
|
164
|
+
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));
|
|
165
165
|
const a = j({ ...e.style, borderColor: e.style?.lineColor ?? e.style?.borderColor });
|
|
166
|
-
return
|
|
166
|
+
return s.setAttribute("stroke", a.color), s.setAttribute("stroke-width", String(a.widthPt * t / 72)), r.appendChild(s), r;
|
|
167
167
|
}
|
|
168
168
|
function ke(e, t, n, r) {
|
|
169
169
|
const i = r.createElement("div");
|
|
170
170
|
i.className = `${E("comp", n)} mr-kind-${e.kind}`;
|
|
171
|
-
const o =
|
|
171
|
+
const o = y("block").add("position", "absolute").mm("left", e.leftMm, t).mm("top", e.topMm, t).mm("width", e.widthMm, t).mm("height", e.heightMm, t).add("box-sizing", "border-box");
|
|
172
172
|
if (Xe(o, e, t), o.applyTo(i), ee(e))
|
|
173
173
|
return i.appendChild(rt(e, n, r)), i;
|
|
174
174
|
if (e.kind === "text")
|
|
175
175
|
return i.appendChild(nt(e, t, n, r)), i;
|
|
176
176
|
if (e.grid) {
|
|
177
|
-
const a =
|
|
177
|
+
const a = ge(e, t, n, r);
|
|
178
178
|
return a.appendChild(Qe(e.grid, e, t, n, r)), i.appendChild(a), i;
|
|
179
179
|
}
|
|
180
180
|
if (e.kind === "line" && e.lineDirection)
|
|
181
181
|
return i.appendChild(it(e, t, r)), i;
|
|
182
182
|
if (e.kind === "line" || e.kind === "rect" || e.kind === "ellipse")
|
|
183
|
-
return i.appendChild(
|
|
184
|
-
const
|
|
185
|
-
return
|
|
183
|
+
return i.appendChild(ge(e, t, n, r)), i;
|
|
184
|
+
const s = r.createElement("div");
|
|
185
|
+
return s.className = E("unknown", n), y("block").applyTo(s), s.textContent = e.fallbackText ?? `[${e.kind}]`, s.dataset.mrUnsupported = e.kind, s.setAttribute("role", "note"), i.appendChild(s), i;
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function ot(e, t, n, r) {
|
|
188
188
|
const i = r.createElement("div");
|
|
189
|
-
return i.className = E("page", n),
|
|
189
|
+
return i.className = E("page", n), y("block", "initial").add("position", "relative").add("font-family", Z).add("font-size", `${H(W(void 0, t).fontSizePx, 2)}px`).add("line-height", String(Q(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", ye).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(i), e.components.forEach((o, s) => {
|
|
190
190
|
const a = ke(o, t, n, r);
|
|
191
|
-
a.dataset.mrComponentIndex = String(
|
|
191
|
+
a.dataset.mrComponentIndex = String(s), i.appendChild(a);
|
|
192
192
|
}), i;
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function mn(e, t, n = {}) {
|
|
195
195
|
const r = n.dpi ?? 96;
|
|
196
196
|
G(e, "dom", n);
|
|
197
197
|
const i = t.createElement("div");
|
|
198
|
-
return i.className = E("root", n),
|
|
199
|
-
i.appendChild(
|
|
198
|
+
return i.className = E("root", n), y("block").applyTo(i), i.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((o) => {
|
|
199
|
+
i.appendChild(ot(o, r, n, t));
|
|
200
200
|
}), i;
|
|
201
201
|
}
|
|
202
202
|
function R(e) {
|
|
203
203
|
if (e?.aborted) throw e.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
204
204
|
}
|
|
205
|
-
const
|
|
205
|
+
const at = (e, t) => (R(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e) ? new Promise((n, r) => {
|
|
206
206
|
const i = new Image(), o = () => {
|
|
207
|
-
i.onload = null, i.onerror = null, t?.removeEventListener("abort",
|
|
208
|
-
},
|
|
207
|
+
i.onload = null, i.onerror = null, t?.removeEventListener("abort", s);
|
|
208
|
+
}, s = () => {
|
|
209
209
|
o(), i.src = "", r(t?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
210
210
|
};
|
|
211
211
|
i.onload = () => {
|
|
212
212
|
o(), n(i);
|
|
213
213
|
}, i.onerror = () => {
|
|
214
214
|
o(), r(new Error("Image could not be decoded for Canvas output."));
|
|
215
|
-
}, t?.addEventListener("abort",
|
|
215
|
+
}, t?.addEventListener("abort", s, { once: !0 }), i.src = e;
|
|
216
216
|
}) : Promise.reject(new TypeError("Canvas imageData must be an image data URL; provide imageLoader for other sources.")));
|
|
217
217
|
function st(e, t, n) {
|
|
218
218
|
return R(n), n ? new Promise((r, i) => {
|
|
@@ -227,9 +227,9 @@ async function lt(e, t, n) {
|
|
|
227
227
|
return R(n), r;
|
|
228
228
|
}
|
|
229
229
|
function ct(e, t, n, r, i, o) {
|
|
230
|
-
const
|
|
231
|
-
if (a <= 0 ||
|
|
232
|
-
const c = Math.min(i / a, o /
|
|
230
|
+
const s = t, a = s.naturalWidth ?? s.width ?? i, l = s.naturalHeight ?? s.height ?? o;
|
|
231
|
+
if (a <= 0 || l <= 0) throw new RangeError("Decoded Canvas image dimensions must be positive.");
|
|
232
|
+
const c = Math.min(i / a, o / l), d = a * c, m = l * c;
|
|
233
233
|
e.drawImage(t, n + (i - d) / 2, r + (o - m) / 2, d, m);
|
|
234
234
|
}
|
|
235
235
|
function dt(e) {
|
|
@@ -246,90 +246,90 @@ function le(e, t = 96) {
|
|
|
246
246
|
function Ie(e, t, n, r = 64e6) {
|
|
247
247
|
if (!Number.isFinite(t) || t <= 0 || !Number.isFinite(n) || n <= 0) throw new RangeError("Canvas dpr and dpi must be positive finite numbers.");
|
|
248
248
|
if (!Number.isFinite(r) || r <= 0) throw new RangeError("maxCanvasPixels must be positive and finite.");
|
|
249
|
-
const i = le(e, n), o = Math.round(i.widthPx * t),
|
|
250
|
-
if (!Number.isSafeInteger(o) || !Number.isSafeInteger(
|
|
251
|
-
return { width: o, height:
|
|
249
|
+
const i = le(e, n), o = Math.round(i.widthPx * t), s = Math.round(i.heightPx * t);
|
|
250
|
+
if (!Number.isSafeInteger(o) || !Number.isSafeInteger(s) || o * s > r) throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");
|
|
251
|
+
return { width: o, height: s };
|
|
252
252
|
}
|
|
253
253
|
function $e(e, t, n, r) {
|
|
254
|
-
const i = document.createElement("canvas"), { widthPx: o, heightPx:
|
|
255
|
-
i.width = a.width, i.height = a.height, i.style.width = `${o}px`, i.style.height = `${
|
|
256
|
-
const
|
|
257
|
-
if (!
|
|
254
|
+
const i = document.createElement("canvas"), { widthPx: o, heightPx: s } = le(e, n), a = Ie(e, t, n, r);
|
|
255
|
+
i.width = a.width, i.height = a.height, i.style.width = `${o}px`, i.style.height = `${s}px`;
|
|
256
|
+
const l = i.getContext("2d");
|
|
257
|
+
if (!l)
|
|
258
258
|
throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
|
|
259
|
-
return
|
|
259
|
+
return l.scale(t, t), l.fillStyle = "#ffffff", l.fillRect(0, 0, o, s), { canvas: i, ctx: l };
|
|
260
260
|
}
|
|
261
|
-
function
|
|
261
|
+
function hn(e, t = 96) {
|
|
262
262
|
return W(e, t).fontSizePx;
|
|
263
263
|
}
|
|
264
|
-
function Ne(e, t, n, r, i, o,
|
|
265
|
-
e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSizePx}px ${
|
|
266
|
-
const
|
|
267
|
-
`), d = c.length *
|
|
264
|
+
function Ne(e, t, n, r, i, o, s, a = "top") {
|
|
265
|
+
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";
|
|
266
|
+
const l = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
|
|
267
|
+
`), d = c.length * l;
|
|
268
268
|
let m = r;
|
|
269
|
-
a === "middle" ? m = r + (o - d) / 2 : a === "bottom" && (m = r + o - d), c.forEach((h,
|
|
270
|
-
mt(e, h, t, n, m +
|
|
269
|
+
a === "middle" ? m = r + (o - d) / 2 : a === "bottom" && (m = r + o - d), c.forEach((h, u) => {
|
|
270
|
+
mt(e, h, t, n, m + u * l + t.fontSizePx * 0.8, i);
|
|
271
271
|
}), e.textAlign = "left";
|
|
272
272
|
}
|
|
273
273
|
function mt(e, t, n, r, i, o) {
|
|
274
|
-
const
|
|
274
|
+
const s = Array.from(t), a = n.letterSpacingPx ?? 0;
|
|
275
275
|
if (!a) {
|
|
276
276
|
e.textAlign = n.align === "center" ? "center" : n.align === "right" ? "right" : "left";
|
|
277
277
|
const m = n.align === "center" ? r + o / 2 : n.align === "right" ? r + o : r;
|
|
278
278
|
e.fillText(t, m, i);
|
|
279
279
|
return;
|
|
280
280
|
}
|
|
281
|
-
const
|
|
281
|
+
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;
|
|
282
282
|
e.textAlign = "left";
|
|
283
283
|
let d = "";
|
|
284
|
-
|
|
284
|
+
s.forEach((m, h) => {
|
|
285
285
|
e.fillText(m, c + e.measureText(d).width + h * a, i), d += m;
|
|
286
286
|
});
|
|
287
287
|
}
|
|
288
|
-
function ht(e, t, n, r, i, o,
|
|
288
|
+
function ht(e, t, n, r, i, o, s) {
|
|
289
289
|
for (const a of Re(t, n))
|
|
290
|
-
e.strokeStyle = a.color, e.lineWidth = O(a.widthPt,
|
|
290
|
+
e.strokeStyle = a.color, e.lineWidth = O(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();
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function ut(e, t, n, r, i, o) {
|
|
293
293
|
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();
|
|
294
294
|
}
|
|
295
|
-
function
|
|
296
|
-
const m = Ce(t, o / a,
|
|
297
|
-
for (const
|
|
298
|
-
const f =
|
|
299
|
-
f && (e.fillStyle = f, e.fillRect(r +
|
|
295
|
+
function gt(e, t, n, r, i, o, s, a, l, c, d) {
|
|
296
|
+
const m = Ce(t, o / a, s / a);
|
|
297
|
+
for (const u of m.cells) {
|
|
298
|
+
const f = u.cell.style?.backgroundColor ?? n.style?.backgroundColor;
|
|
299
|
+
f && (e.fillStyle = f, e.fillRect(r + u.xMm * a, i + u.yMm * a, u.widthMm * a, u.heightMm * a));
|
|
300
300
|
}
|
|
301
|
-
ht(e, m, n, r, i, a,
|
|
301
|
+
ht(e, m, n, r, i, a, l);
|
|
302
302
|
const h = t.paddingMm ?? 0.5;
|
|
303
|
-
for (const
|
|
304
|
-
const f =
|
|
303
|
+
for (const u of m.cells) {
|
|
304
|
+
const f = u.cell.text ?? "";
|
|
305
305
|
if (!f) continue;
|
|
306
|
-
const b = xe(n.style,
|
|
306
|
+
const b = xe(n.style, u.cell.style), $ = W(b, l), C = u.cell.indentMm ?? 0, S = Math.max(0, u.widthMm - 2 * h - C), A = Te(f, S, { fontSizePt: $.fontSizePt, bold: b.bold, italic: b.italic, fontFamily: b.fontFamily ?? c, letterSpacingPt: b.letterSpacing }, d).join(`
|
|
307
307
|
`);
|
|
308
308
|
Ne(
|
|
309
309
|
e,
|
|
310
310
|
{
|
|
311
311
|
text: A,
|
|
312
|
-
fontSizePx:
|
|
312
|
+
fontSizePx: $.fontSizePx,
|
|
313
313
|
bold: b.bold ?? !1,
|
|
314
314
|
italic: b.italic,
|
|
315
|
-
color: Ee(b,
|
|
315
|
+
color: Ee(b, ye),
|
|
316
316
|
align: b.align ?? "left",
|
|
317
317
|
lineHeight: Q(b),
|
|
318
|
-
letterSpacingPx: O(b.letterSpacing ?? 0,
|
|
318
|
+
letterSpacingPx: O(b.letterSpacing ?? 0, l)
|
|
319
319
|
},
|
|
320
|
-
r + (
|
|
321
|
-
i + (
|
|
320
|
+
r + (u.xMm + h + C) * a,
|
|
321
|
+
i + (u.yMm + h) * a,
|
|
322
322
|
S * a,
|
|
323
|
-
Math.max(0,
|
|
323
|
+
Math.max(0, u.heightMm - 2 * h) * a,
|
|
324
324
|
b.fontFamily ?? c,
|
|
325
325
|
b.verticalAlign ?? "middle"
|
|
326
326
|
);
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
|
-
function ft(e, t, n, r, i, o,
|
|
330
|
-
const c = t.style ?? {}, d = W(c,
|
|
329
|
+
function ft(e, t, n, r, i, o, s, a, l) {
|
|
330
|
+
const c = t.style ?? {}, d = W(c, s), m = Se(t) ? t.richParagraphs.map((h) => h.segments.map((u) => u.text ?? u.field ?? "").join("")).join(`
|
|
331
331
|
`) : t.lines?.length ? t.lines.join(`
|
|
332
|
-
`) : Te(t.text ?? "", t.widthMm, { fontSizePt: d.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? a, letterSpacingPt: c.letterSpacing },
|
|
332
|
+
`) : Te(t.text ?? "", t.widthMm, { fontSizePt: d.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? a, letterSpacingPt: c.letterSpacing }, l).join(`
|
|
333
333
|
`);
|
|
334
334
|
Ne(e, {
|
|
335
335
|
text: m,
|
|
@@ -339,201 +339,201 @@ function ft(e, t, n, r, i, o, l, a, s) {
|
|
|
339
339
|
color: Ee(c),
|
|
340
340
|
align: c.align ?? "left",
|
|
341
341
|
lineHeight: Q(c),
|
|
342
|
-
letterSpacingPx: O(c.letterSpacing ?? 0,
|
|
342
|
+
letterSpacingPx: O(c.letterSpacing ?? 0, s)
|
|
343
343
|
}, n, r, i, o, c.fontFamily ?? a, c.verticalAlign);
|
|
344
344
|
}
|
|
345
|
-
function ce(e, t, n, r, i, o,
|
|
346
|
-
const a = t.leftMm * n,
|
|
345
|
+
function ce(e, t, n, r, i, o, s) {
|
|
346
|
+
const a = t.leftMm * n, l = t.topMm * n, c = t.widthMm * n, d = t.heightMm * n, m = t.style ?? {};
|
|
347
347
|
if (ee(t)) {
|
|
348
|
-
const h =
|
|
349
|
-
h ? ct(e, h, a,
|
|
348
|
+
const h = s?.get(t.imageData);
|
|
349
|
+
h ? ct(e, h, a, l, c, d) : fe(e, t, a, l, c, d);
|
|
350
350
|
return;
|
|
351
351
|
}
|
|
352
352
|
if (t.grid) {
|
|
353
|
-
|
|
353
|
+
gt(e, t.grid, t, a, l, c, d, n, r, i, o);
|
|
354
354
|
return;
|
|
355
355
|
}
|
|
356
356
|
switch (t.kind) {
|
|
357
357
|
case "text": {
|
|
358
|
-
ft(e, t, a,
|
|
358
|
+
ft(e, t, a, l, c, d, r, i, o);
|
|
359
359
|
break;
|
|
360
360
|
}
|
|
361
361
|
case "rect": {
|
|
362
|
-
const h = j(m),
|
|
363
|
-
m.backgroundColor && (e.fillStyle = m.backgroundColor, e.fillRect(a,
|
|
362
|
+
const h = j(m), u = Me(m);
|
|
363
|
+
m.backgroundColor && (e.fillStyle = m.backgroundColor, e.fillRect(a, l, c, d)), u.inner && (e.strokeStyle = h.color, e.lineWidth = O(h.widthPt, r), ut(e, u, a, l, c, d));
|
|
364
364
|
break;
|
|
365
365
|
}
|
|
366
366
|
case "line": {
|
|
367
367
|
const h = j({ ...m, borderColor: m.lineColor ?? m.borderColor });
|
|
368
368
|
e.strokeStyle = h.color, e.lineWidth = O(h.widthPt, r), e.beginPath();
|
|
369
|
-
const
|
|
370
|
-
e.moveTo(a,
|
|
369
|
+
const u = t.lineDirection === "up" ? l + d : t.lineDirection === "down" ? l : l + d / 2, f = t.lineDirection === "up" ? l : t.lineDirection === "down" ? l + d : l + d / 2;
|
|
370
|
+
e.moveTo(a, u), e.lineTo(a + c, f), e.stroke();
|
|
371
371
|
break;
|
|
372
372
|
}
|
|
373
373
|
case "ellipse": {
|
|
374
374
|
const h = j(m);
|
|
375
|
-
e.strokeStyle = h.color, e.lineWidth = O(h.widthPt, r), m.backgroundColor && (e.fillStyle = m.backgroundColor, e.beginPath(), e.ellipse(a + c / 2,
|
|
375
|
+
e.strokeStyle = h.color, e.lineWidth = O(h.widthPt, r), m.backgroundColor && (e.fillStyle = m.backgroundColor, e.beginPath(), e.ellipse(a + c / 2, l + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(a + c / 2, l + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.stroke();
|
|
376
376
|
break;
|
|
377
377
|
}
|
|
378
378
|
default:
|
|
379
|
-
fe(e, t, a,
|
|
379
|
+
fe(e, t, a, l, c, d);
|
|
380
380
|
break;
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
383
|
function fe(e, t, n, r, i, o) {
|
|
384
384
|
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();
|
|
385
385
|
}
|
|
386
|
-
async function
|
|
386
|
+
async function un(e, t = {}) {
|
|
387
387
|
if (typeof document > "u")
|
|
388
388
|
throw new Error("renderPlanToImages 需要浏览器环境(SSR/Node 请在客户端钩子中调用)");
|
|
389
389
|
const { format: n = "png", quality: r = 0.92, ...i } = t;
|
|
390
390
|
if (n !== "png" && n !== "jpeg") throw new TypeError("Image format must be png or jpeg.");
|
|
391
391
|
if (!Number.isFinite(r) || r < 0 || r > 1) throw new RangeError("Image quality must be between 0 and 1.");
|
|
392
392
|
R(t.signal);
|
|
393
|
-
const o = await
|
|
393
|
+
const o = await ae(e, { ...t, format: "canvas" });
|
|
394
394
|
e = o.plan;
|
|
395
|
-
const
|
|
395
|
+
const s = [...o.diagnostics, ...G(e, "canvas", t)], a = n === "jpeg" ? "image/jpeg" : "image/png", l = [], c = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
|
|
396
396
|
for (let d = Math.max(0, t.start ?? 0); d <= c; d++) {
|
|
397
397
|
R(t.signal);
|
|
398
|
-
const m = await Le(e.pages[d], d, i,
|
|
398
|
+
const m = await Le(e.pages[d], d, i, s);
|
|
399
399
|
try {
|
|
400
|
-
|
|
400
|
+
l.push(await pt(m, a, r, t.signal));
|
|
401
401
|
} finally {
|
|
402
402
|
m.width = 0, m.height = 0;
|
|
403
403
|
}
|
|
404
|
-
await Ve(t,
|
|
404
|
+
await Ve(t, l.length, c - Math.max(0, t.start ?? 0) + 1);
|
|
405
405
|
}
|
|
406
|
-
return R(t.signal), { blobs:
|
|
406
|
+
return R(t.signal), { blobs: l, diagnostics: s };
|
|
407
407
|
}
|
|
408
408
|
function pt(e, t, n, r) {
|
|
409
409
|
return R(r), new Promise((i, o) => {
|
|
410
|
-
const
|
|
411
|
-
r?.addEventListener("abort",
|
|
410
|
+
const s = () => o(r?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
411
|
+
r?.addEventListener("abort", s, { once: !0 });
|
|
412
412
|
try {
|
|
413
413
|
e.toBlob((a) => {
|
|
414
|
-
r?.removeEventListener("abort",
|
|
414
|
+
r?.removeEventListener("abort", s), a ? i(a) : o(new Error("Canvas encoding failed; no empty image was emitted."));
|
|
415
415
|
}, t, n);
|
|
416
416
|
} catch (a) {
|
|
417
|
-
r?.removeEventListener("abort",
|
|
417
|
+
r?.removeEventListener("abort", s), o(a);
|
|
418
418
|
}
|
|
419
419
|
});
|
|
420
420
|
}
|
|
421
421
|
function gn(e, t = {}) {
|
|
422
422
|
if (R(t.signal), typeof document > "u")
|
|
423
423
|
throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");
|
|
424
|
-
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * se, o = t.fontFamily ?? Z,
|
|
424
|
+
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * se, o = t.fontFamily ?? Z, s = t.measurer ?? oe, a = Math.max(0, t.start ?? 0), l = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [], d = G(e, "canvas", t), m = wt(e, a, l);
|
|
425
425
|
for (const h of m)
|
|
426
426
|
Pe(h, t), d.push(h);
|
|
427
427
|
if (t.fidelity === "strict" && m.length) throw new Ue(d);
|
|
428
|
-
for (let h = a; h <=
|
|
428
|
+
for (let h = a; h <= l; h++) {
|
|
429
429
|
R(t.signal);
|
|
430
|
-
const
|
|
431
|
-
for (const
|
|
432
|
-
ce(b,
|
|
430
|
+
const u = e.pages[h], { canvas: f, ctx: b } = $e(u, n, r, t.maxCanvasPixels);
|
|
431
|
+
for (const $ of u.components)
|
|
432
|
+
ce(b, $, i, r, o, s);
|
|
433
433
|
c.push(f);
|
|
434
434
|
}
|
|
435
435
|
return { canvases: c, diagnostics: d };
|
|
436
436
|
}
|
|
437
437
|
function wt(e, t, n) {
|
|
438
|
-
return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => r.components.flatMap((o,
|
|
438
|
+
return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => r.components.flatMap((o, s) => ee(o) ? [{
|
|
439
439
|
code: "async-image-required",
|
|
440
440
|
severity: "warning",
|
|
441
441
|
format: "canvas",
|
|
442
442
|
pageIndex: t + i,
|
|
443
|
-
componentIndex:
|
|
443
|
+
componentIndex: s,
|
|
444
444
|
kind: o.kind,
|
|
445
445
|
nid: o.nid,
|
|
446
446
|
message: "Use renderPlanToCanvasAsync or renderPlanToImages to decode and include images."
|
|
447
447
|
}] : []));
|
|
448
448
|
}
|
|
449
|
-
async function
|
|
449
|
+
async function fn(e, t = {}) {
|
|
450
450
|
if (typeof document > "u") throw new Error("renderPlanToCanvasAsync 需要浏览器环境(Node 请使用 PDF 或 XLSX 输出)");
|
|
451
451
|
R(t.signal);
|
|
452
|
-
const n = await
|
|
452
|
+
const n = await ae(e, { ...t, format: "canvas" });
|
|
453
453
|
e = n.plan;
|
|
454
454
|
const r = [...n.diagnostics, ...G(e, "canvas", t)], i = [], o = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
|
|
455
|
-
for (let
|
|
456
|
-
i.push(await Le(e.pages[
|
|
455
|
+
for (let s = Math.max(0, t.start ?? 0); s <= o; s++)
|
|
456
|
+
i.push(await Le(e.pages[s], s, t, r));
|
|
457
457
|
return { canvases: i, diagnostics: r };
|
|
458
458
|
}
|
|
459
459
|
async function Le(e, t, n, r) {
|
|
460
|
-
const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), o = n.dpi ?? 96,
|
|
460
|
+
const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), o = n.dpi ?? 96, s = n.fontFamily ?? Z, a = await De(e, t, n, r);
|
|
461
461
|
R(n.signal);
|
|
462
|
-
const { canvas:
|
|
463
|
-
for (const d of e.components) ce(c, d, o / 25.4, o,
|
|
464
|
-
return
|
|
462
|
+
const { canvas: l, ctx: c } = $e(e, i, o, n.maxCanvasPixels);
|
|
463
|
+
for (const d of e.components) ce(c, d, o / 25.4, o, s, n.measurer ?? oe, a);
|
|
464
|
+
return l;
|
|
465
465
|
}
|
|
466
466
|
async function De(e, t, n, r) {
|
|
467
|
-
const i = n.imageLoader ??
|
|
468
|
-
return lt(e, async (o,
|
|
467
|
+
const i = n.imageLoader ?? at;
|
|
468
|
+
return lt(e, async (o, s) => {
|
|
469
469
|
try {
|
|
470
|
-
return await i(o,
|
|
470
|
+
return await i(o, s);
|
|
471
471
|
} catch (a) {
|
|
472
|
-
if (
|
|
473
|
-
const
|
|
472
|
+
if (s?.aborted) throw a;
|
|
473
|
+
const l = e.components.findIndex((m) => m.imageData === o), c = e.components[l], d = { 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." };
|
|
474
474
|
throw r.push(d), Pe(d, n), a;
|
|
475
475
|
}
|
|
476
476
|
}, n.signal);
|
|
477
477
|
}
|
|
478
|
-
function
|
|
479
|
-
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * se, o = t.fontFamily ?? Z,
|
|
480
|
-
let
|
|
478
|
+
function pn(e, t = {}) {
|
|
479
|
+
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * se, o = t.fontFamily ?? Z, s = t.measurer ?? oe, a = t.overscan ?? 1, l = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, d = e.pages.map((g) => g.pageHeightMm * i), m = Math.max(1, ...e.pages.map((g) => g.pageWidthMm * i)), h = { start: 0, end: -1 };
|
|
480
|
+
let u = null, f = null, b = null, $ = null, C = [], S = 0, A = [], U = 0, _ = new AbortController();
|
|
481
481
|
const me = [];
|
|
482
482
|
function ze() {
|
|
483
|
-
const
|
|
484
|
-
|
|
483
|
+
const g = u;
|
|
484
|
+
g.innerHTML = "", f = document.createElement("div"), f.style.cssText = `width:${m}px;margin:0 auto;`, b = document.createElement("div"), $ = document.createElement("div"), f.appendChild(b), C = [];
|
|
485
485
|
const M = Math.min(e.pages.length, 3 + a * 2);
|
|
486
|
-
for (let
|
|
487
|
-
const
|
|
488
|
-
|
|
486
|
+
for (let D = 0; D < M; D++) {
|
|
487
|
+
const v = document.createElement("div");
|
|
488
|
+
v.style.cssText = `margin:0 auto ${l}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, f.appendChild(v), C.push(v);
|
|
489
489
|
}
|
|
490
|
-
f.appendChild(
|
|
490
|
+
f.appendChild($), g.appendChild(f);
|
|
491
491
|
}
|
|
492
|
-
async function He(
|
|
493
|
-
const
|
|
494
|
-
me.push(...
|
|
495
|
-
const T =
|
|
496
|
-
if (
|
|
492
|
+
async function He(g, M) {
|
|
493
|
+
const D = U, v = await ae(e, { ...t, signal: _.signal, format: "canvas", start: M, end: M });
|
|
494
|
+
me.push(...v.diagnostics);
|
|
495
|
+
const T = v.plan.pages[M], Y = await De(T, M, { ...t, signal: _.signal }, me);
|
|
496
|
+
if (D !== U || !u) return;
|
|
497
497
|
const { widthPx: ne, heightPx: re } = le(T, r);
|
|
498
|
-
let
|
|
499
|
-
(
|
|
500
|
-
const
|
|
501
|
-
|
|
502
|
-
const F =
|
|
498
|
+
let N = g.firstElementChild;
|
|
499
|
+
(!N || N.tagName !== "CANVAS") && (N = document.createElement("canvas"), g.innerHTML = "", g.appendChild(N));
|
|
500
|
+
const ue = Ie(T, n, r, t.maxCanvasPixels);
|
|
501
|
+
N.width = ue.width, N.height = ue.height, N.style.width = `${ne}px`, N.style.height = `${re}px`;
|
|
502
|
+
const F = N.getContext("2d");
|
|
503
503
|
if (F) {
|
|
504
504
|
F.setTransform(1, 0, 0, 1, 0, 0), F.scale(n, n), F.fillStyle = "#ffffff", F.fillRect(0, 0, ne, re);
|
|
505
505
|
for (const _e of T.components)
|
|
506
|
-
ce(F, _e, i, r, o,
|
|
507
|
-
|
|
506
|
+
ce(F, _e, i, r, o, s, Y);
|
|
507
|
+
N.dataset.canvasPage = String(M), g.style.height = `${re}px`, g.style.width = `${ne}px`;
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
|
-
function We(
|
|
511
|
-
U++, h.start =
|
|
512
|
-
const M = e.pages.length - 1 -
|
|
513
|
-
|
|
514
|
-
const
|
|
515
|
-
C.forEach((
|
|
516
|
-
if (T <
|
|
517
|
-
|
|
518
|
-
const Y =
|
|
519
|
-
|
|
510
|
+
function We(g) {
|
|
511
|
+
U++, h.start = g.start, h.end = g.end, b.style.height = `${g.start * l + d.slice(0, g.start).reduce((v, T) => v + T, 0)}px`;
|
|
512
|
+
const M = e.pages.length - 1 - g.end;
|
|
513
|
+
$.style.height = `${M * l + d.slice(g.end + 1).reduce((v, T) => v + T, 0)}px`;
|
|
514
|
+
const D = g.end - g.start + 1;
|
|
515
|
+
C.forEach((v, T) => {
|
|
516
|
+
if (T < D) {
|
|
517
|
+
v.style.display = "";
|
|
518
|
+
const Y = g.start + T;
|
|
519
|
+
v.style.height = `${d[Y] ?? 0}px`;
|
|
520
520
|
} else
|
|
521
|
-
|
|
521
|
+
v.style.display = "none";
|
|
522
522
|
}), A = [];
|
|
523
|
-
for (let
|
|
524
|
-
const T = C[
|
|
523
|
+
for (let v = g.start; v <= g.end; v++) {
|
|
524
|
+
const T = C[v - g.start];
|
|
525
525
|
if (!T) continue;
|
|
526
|
-
T.firstElementChild?.dataset?.canvasPage !== String(
|
|
526
|
+
T.firstElementChild?.dataset?.canvasPage !== String(v) && A.push(v);
|
|
527
527
|
}
|
|
528
528
|
te();
|
|
529
529
|
}
|
|
530
530
|
function te() {
|
|
531
531
|
S || A.length === 0 || (S = requestAnimationFrame(() => {
|
|
532
532
|
S = 0;
|
|
533
|
-
let
|
|
534
|
-
for (; A.length > 0 &&
|
|
535
|
-
const M = A.shift(),
|
|
536
|
-
|
|
533
|
+
let g = Math.max(1, c);
|
|
534
|
+
for (; A.length > 0 && g-- > 0; ) {
|
|
535
|
+
const M = A.shift(), D = C[M - h.start];
|
|
536
|
+
D && He(D, M).catch(() => {
|
|
537
537
|
});
|
|
538
538
|
}
|
|
539
539
|
A.length > 0 && te();
|
|
@@ -542,25 +542,25 @@ function fn(e, t = {}) {
|
|
|
542
542
|
function V() {
|
|
543
543
|
S || (S = requestAnimationFrame(() => {
|
|
544
544
|
S = 0;
|
|
545
|
-
const
|
|
545
|
+
const g = u, M = dt({
|
|
546
546
|
pageHeightsPx: d,
|
|
547
|
-
viewportHeightPx:
|
|
548
|
-
scrollTopPx:
|
|
547
|
+
viewportHeightPx: g.clientHeight,
|
|
548
|
+
scrollTopPx: g.scrollTop,
|
|
549
549
|
overscan: a,
|
|
550
|
-
gapPx:
|
|
550
|
+
gapPx: l
|
|
551
551
|
});
|
|
552
552
|
M.start !== h.start || M.end !== h.end ? We(M) : te();
|
|
553
553
|
}));
|
|
554
554
|
}
|
|
555
555
|
let q = null;
|
|
556
556
|
return {
|
|
557
|
-
attach(
|
|
557
|
+
attach(g) {
|
|
558
558
|
if (typeof document > "u")
|
|
559
559
|
throw new Error("createCanvasPager 需要浏览器环境(SSR 请在客户端钩子中调用 attach)");
|
|
560
|
-
R(t.signal), _ = new AbortController(), t.signal?.addEventListener("abort", he, { once: !0 }), G(e, "canvas", t),
|
|
560
|
+
R(t.signal), _ = new AbortController(), t.signal?.addEventListener("abort", he, { once: !0 }), G(e, "canvas", t), u = g, ze(), g.addEventListener("scroll", V, { passive: !0 }), typeof ResizeObserver < "u" && (q = new ResizeObserver(() => V()), q.observe(g)), V();
|
|
561
561
|
},
|
|
562
562
|
destroy() {
|
|
563
|
-
U++, _.abort(), t.signal?.removeEventListener("abort", he), S && cancelAnimationFrame(S), S = 0, q?.disconnect(), q = null,
|
|
563
|
+
U++, _.abort(), t.signal?.removeEventListener("abort", he), S && cancelAnimationFrame(S), S = 0, q?.disconnect(), q = null, u?.removeEventListener("scroll", V), A = [], f?.remove(), u = null;
|
|
564
564
|
},
|
|
565
565
|
window() {
|
|
566
566
|
return { ...h };
|
|
@@ -608,18 +608,18 @@ class bt {
|
|
|
608
608
|
*/
|
|
609
609
|
page(t = "a4", n = {}, r) {
|
|
610
610
|
this.collect();
|
|
611
|
-
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:
|
|
611
|
+
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 } = Fe(
|
|
612
612
|
t,
|
|
613
613
|
typeof n == "number" ? n : void 0,
|
|
614
614
|
o.landscape
|
|
615
|
-
),
|
|
616
|
-
return this.pending = new
|
|
617
|
-
widthMm:
|
|
615
|
+
), l = o.margins ?? {};
|
|
616
|
+
return this.pending = new vt(this, {
|
|
617
|
+
widthMm: s,
|
|
618
618
|
heightMm: a,
|
|
619
|
-
marginTopMm:
|
|
620
|
-
marginBottomMm:
|
|
621
|
-
marginLeftMm:
|
|
622
|
-
marginRightMm:
|
|
619
|
+
marginTopMm: l.marginTopMm ?? 10,
|
|
620
|
+
marginBottomMm: l.marginBottomMm ?? 10,
|
|
621
|
+
marginLeftMm: l.marginLeftMm ?? 10,
|
|
622
|
+
marginRightMm: l.marginRightMm ?? 10
|
|
623
623
|
}), this.pending;
|
|
624
624
|
}
|
|
625
625
|
collect() {
|
|
@@ -631,7 +631,7 @@ class bt {
|
|
|
631
631
|
return this.templateParams ? { params: this.templateParams, pages: this.pages } : { pages: this.pages };
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
|
-
class
|
|
634
|
+
class vt {
|
|
635
635
|
constructor(t, n) {
|
|
636
636
|
this.parent = t, this.page = n, this.components = [];
|
|
637
637
|
}
|
|
@@ -700,10 +700,10 @@ class yt {
|
|
|
700
700
|
return this.done().build();
|
|
701
701
|
}
|
|
702
702
|
}
|
|
703
|
-
function
|
|
703
|
+
function wn() {
|
|
704
704
|
return new bt();
|
|
705
705
|
}
|
|
706
|
-
function
|
|
706
|
+
function bn(e, t = {}) {
|
|
707
707
|
return je([], e), e.fields.map((n) => ({
|
|
708
708
|
field: n.field,
|
|
709
709
|
header: `${n.label ?? n.field}${n.unit ? ` (${n.unit})` : ""}`,
|
|
@@ -719,7 +719,7 @@ function X(e, t, n) {
|
|
|
719
719
|
if (e !== void 0 && !["left", "center", "right", "justify", ...n ? ["auto"] : []].includes(e))
|
|
720
720
|
throw new Error(`${t} 必须是 left/center/right/justify${n ? "/auto" : ""}`);
|
|
721
721
|
}
|
|
722
|
-
function
|
|
722
|
+
function yt(e) {
|
|
723
723
|
const t = e.layout ?? "page";
|
|
724
724
|
if (t !== "page" && t !== "wide")
|
|
725
725
|
throw new Error("layout 必须是 page 或 wide");
|
|
@@ -759,10 +759,10 @@ function Et(e, t) {
|
|
|
759
759
|
throw new Error("title 必须是字符串");
|
|
760
760
|
const r = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm, i = e.titleGapMm === void 0 ? 4 : e.titleGapMm;
|
|
761
761
|
P(r, "titleHeightMm"), P(i, "titleGapMm", !0);
|
|
762
|
-
const o = e.title !== void 0 && e.title.length > 0,
|
|
763
|
-
if (
|
|
762
|
+
const o = e.title !== void 0 && e.title.length > 0, s = o ? r + i : 0;
|
|
763
|
+
if (s >= t)
|
|
764
764
|
throw new Error("标题高度与间距占满页面,必须为表格保留可用高度");
|
|
765
|
-
return { dataset: n, titleHeightMm: r, hasTitle: o, titleSpaceMm:
|
|
765
|
+
return { dataset: n, titleHeightMm: r, hasTitle: o, titleSpaceMm: s };
|
|
766
766
|
}
|
|
767
767
|
function St(e) {
|
|
768
768
|
if (e.listOptions !== void 0 && (!e.listOptions || typeof e.listOptions != "object" || Array.isArray(e.listOptions)))
|
|
@@ -788,56 +788,56 @@ function Ct(e, t, n, r) {
|
|
|
788
788
|
const { fixedWidthMm: i, maxFlex: o } = Tt(e.columns);
|
|
789
789
|
if (t === "page" && i > r)
|
|
790
790
|
throw new Error(`固定列宽 ${i}mm 超出页面可用宽度 ${r}mm`);
|
|
791
|
-
const
|
|
792
|
-
if (t === "page" && o > 0 &&
|
|
791
|
+
const s = r - i;
|
|
792
|
+
if (t === "page" && o > 0 && s <= 0)
|
|
793
793
|
throw new Error("固定列占满页面可用宽度,自动列需要正的剩余宽度");
|
|
794
794
|
const a = o > 0 ? e.columns.reduce((c, d) => c + (d.widthMm === void 0 ? (d.flex ?? 1) / o : 0), 0) : 0;
|
|
795
795
|
return { columns: e.columns.map(({ widthMm: c, flex: d, ...m }, h) => {
|
|
796
|
-
const
|
|
797
|
-
return P(
|
|
796
|
+
const u = c ?? (t === "wide" ? n * (d ?? 1) : s * ((d ?? 1) / o) / a);
|
|
797
|
+
return P(u, `columns[${h}] 分配后的 widthMm`), { ...m, widthMm: u };
|
|
798
798
|
}), fixedWidthMm: i, maxFlex: o };
|
|
799
799
|
}
|
|
800
|
-
function
|
|
800
|
+
function vn(e) {
|
|
801
801
|
if (!e || typeof e != "object")
|
|
802
802
|
throw new Error("标准明细模板需要 options 对象");
|
|
803
803
|
if (!Array.isArray(e.columns) || e.columns.length === 0)
|
|
804
804
|
throw new Error("columns 至少需要一列");
|
|
805
|
-
const { layout: t, columnWidthMm: n } =
|
|
805
|
+
const { layout: t, columnWidthMm: n } = yt(e), r = Mt(e);
|
|
806
806
|
let i = r.widthMm;
|
|
807
|
-
const o = r.heightMm,
|
|
808
|
-
let a = i -
|
|
809
|
-
const
|
|
810
|
-
if (t === "page" && a <= 0 ||
|
|
807
|
+
const o = r.heightMm, s = xt(e);
|
|
808
|
+
let a = i - s.marginLeftMm - s.marginRightMm;
|
|
809
|
+
const l = o - s.marginTopMm - s.marginBottomMm;
|
|
810
|
+
if (t === "page" && a <= 0 || l <= 0)
|
|
811
811
|
throw new Error("页边距占满纸张,必须保留正的可用宽度和高度");
|
|
812
|
-
const { dataset: c, titleHeightMm: d, hasTitle: m, titleSpaceMm: h } = Et(e,
|
|
813
|
-
t === "wide" && (a = f.reduce((S, A) => S + A.widthMm, 0), P(a, "宽表总列宽"), i = a +
|
|
814
|
-
const C = { widthMm: i, heightMm: o, ...
|
|
812
|
+
const { dataset: c, titleHeightMm: d, hasTitle: m, titleSpaceMm: h } = Et(e, l), u = St(e), { columns: f, fixedWidthMm: b, maxFlex: $ } = Ct(e, t, n, a);
|
|
813
|
+
t === "wide" && (a = f.reduce((S, A) => S + A.widthMm, 0), P(a, "宽表总列宽"), i = a + s.marginLeftMm + s.marginRightMm, P(i, "宽表总宽度"));
|
|
814
|
+
const C = { widthMm: i, heightMm: o, ...s, components: [], ...t === "wide" ? { layout: t } : {} };
|
|
815
815
|
return m && C.components.push({
|
|
816
816
|
kind: "text",
|
|
817
817
|
text: e.title,
|
|
818
|
-
leftMm:
|
|
819
|
-
topMm:
|
|
818
|
+
leftMm: s.marginLeftMm,
|
|
819
|
+
topMm: s.marginTopMm,
|
|
820
820
|
widthMm: a,
|
|
821
821
|
heightMm: d,
|
|
822
822
|
style: { fontSize: 16, bold: !0, align: "center", verticalAlign: "middle", ...e.titleStyle }
|
|
823
823
|
}), C.components.push({
|
|
824
824
|
align: "auto",
|
|
825
825
|
headerAlign: "center",
|
|
826
|
-
...
|
|
826
|
+
...u,
|
|
827
827
|
kind: "list",
|
|
828
828
|
...t === "wide" ? { layout: t } : {},
|
|
829
829
|
...m ? { title: e.title } : {},
|
|
830
830
|
dataset: c,
|
|
831
831
|
columns: f,
|
|
832
|
-
leftMm:
|
|
833
|
-
topMm:
|
|
834
|
-
widthMm: t === "wide" ||
|
|
832
|
+
leftMm: s.marginLeftMm,
|
|
833
|
+
topMm: s.marginTopMm + h,
|
|
834
|
+
widthMm: t === "wide" || $ > 0 ? a : b
|
|
835
835
|
}), e.params === void 0 ? { pages: [C] } : { params: e.params, pages: [C] };
|
|
836
836
|
}
|
|
837
837
|
function yn(e) {
|
|
838
838
|
return e;
|
|
839
839
|
}
|
|
840
|
-
class
|
|
840
|
+
class L extends Error {
|
|
841
841
|
constructor(t, n) {
|
|
842
842
|
super(n), this.code = t, this.name = "ReportTemplateStoreError";
|
|
843
843
|
}
|
|
@@ -852,75 +852,75 @@ function x(e) {
|
|
|
852
852
|
}
|
|
853
853
|
function pe(e) {
|
|
854
854
|
const t = e ? Number(e.revision) : 0;
|
|
855
|
-
if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new
|
|
855
|
+
if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new L("history", "修订号无效或已达上限");
|
|
856
856
|
return String(t + 1);
|
|
857
857
|
}
|
|
858
|
-
function
|
|
859
|
-
const n = async (
|
|
858
|
+
function Mn(e, t = {}) {
|
|
859
|
+
const n = async (s, a) => {
|
|
860
860
|
x(a);
|
|
861
|
-
const
|
|
862
|
-
return x(a),
|
|
863
|
-
}, r = async (
|
|
864
|
-
const
|
|
865
|
-
if ((
|
|
866
|
-
return
|
|
867
|
-
}, i = async (
|
|
868
|
-
if (x(a.signal), !await e.compareAndSwap(
|
|
869
|
-
return k(
|
|
870
|
-
}, o = async (
|
|
861
|
+
const l = await e.read(s, a);
|
|
862
|
+
return x(a), l ? k(l) : void 0;
|
|
863
|
+
}, r = async (s, a) => {
|
|
864
|
+
const l = await n(s, a.signal);
|
|
865
|
+
if ((l?.revision ?? null) !== a.expectedRevision) throw new L("conflict", "模板已变化,请重新读取后提交");
|
|
866
|
+
return l;
|
|
867
|
+
}, i = async (s, a, l) => {
|
|
868
|
+
if (x(a.signal), !await e.compareAndSwap(s.id, a.expectedRevision, k(s), { signal: a.signal, ...l ? { publication: k(l) } : {} })) throw new L("conflict", "模板已被其他请求更新");
|
|
869
|
+
return k(s);
|
|
870
|
+
}, o = async (s, a, l, c) => {
|
|
871
871
|
if (t.beforePublish) {
|
|
872
|
-
x(
|
|
873
|
-
const
|
|
874
|
-
if (!
|
|
875
|
-
x(
|
|
872
|
+
x(l.signal);
|
|
873
|
+
const u = await t.beforePublish({ document: I(a), previous: s.published ? I(s.published) : void 0, signal: l.signal });
|
|
874
|
+
if (!u || u.ok !== !0) throw new L("review", u?.issues?.find((f) => f.severity === "error")?.message ?? "模板发布检查未通过");
|
|
875
|
+
x(l.signal);
|
|
876
876
|
}
|
|
877
|
-
const d = pe(
|
|
878
|
-
return c !== void 0 && (h.restoredFrom = c), i({ id:
|
|
877
|
+
const d = pe(s), m = I({ ...a, revision: d }), h = { revision: d, document: m, publishedAt: (t.now?.() ?? /* @__PURE__ */ new Date()).toISOString() };
|
|
878
|
+
return c !== void 0 && (h.restoredFrom = c), i({ id: s.id, revision: d, publishedRevision: d, published: m }, l, h);
|
|
879
879
|
};
|
|
880
880
|
return {
|
|
881
|
-
list: async (
|
|
882
|
-
x(
|
|
883
|
-
const a = await e.list(
|
|
884
|
-
return x(
|
|
881
|
+
list: async (s) => {
|
|
882
|
+
x(s);
|
|
883
|
+
const a = await e.list(s);
|
|
884
|
+
return x(s), k(a);
|
|
885
885
|
},
|
|
886
|
-
get: async (
|
|
887
|
-
const
|
|
888
|
-
return c ?
|
|
886
|
+
get: async (s, a = {}) => {
|
|
887
|
+
const l = await n(s, a.signal), c = a.draft ? l?.draft : l?.published;
|
|
888
|
+
return c ? I(c) : void 0;
|
|
889
889
|
},
|
|
890
|
-
history: async (
|
|
890
|
+
history: async (s, a) => {
|
|
891
891
|
x(a);
|
|
892
|
-
const
|
|
893
|
-
return x(a), k(
|
|
892
|
+
const l = await e.history(s, a);
|
|
893
|
+
return x(a), k(l);
|
|
894
894
|
},
|
|
895
|
-
saveDraft: async (
|
|
895
|
+
saveDraft: async (s, a) => {
|
|
896
896
|
a = { ...a }, x(a.signal);
|
|
897
|
-
const
|
|
897
|
+
const l = I(t.migrate ? await t.migrate(s) : s), c = await r(l.id, a), d = pe(c);
|
|
898
898
|
return i({
|
|
899
|
-
id:
|
|
899
|
+
id: l.id,
|
|
900
900
|
revision: d,
|
|
901
|
-
draft: { ...
|
|
901
|
+
draft: { ...l, revision: d },
|
|
902
902
|
...c?.publishedRevision ? { publishedRevision: c.publishedRevision, published: c.published } : {}
|
|
903
903
|
}, a);
|
|
904
904
|
},
|
|
905
|
-
publish: async (
|
|
905
|
+
publish: async (s, a) => {
|
|
906
906
|
a = { ...a };
|
|
907
|
-
const
|
|
908
|
-
if (!
|
|
909
|
-
if (!
|
|
910
|
-
return o(
|
|
907
|
+
const l = await r(s, a);
|
|
908
|
+
if (!l) throw new L("missing", "模板不存在");
|
|
909
|
+
if (!l.draft) throw new L("draft", "没有可发布的草稿");
|
|
910
|
+
return o(l, l.draft, a);
|
|
911
911
|
},
|
|
912
|
-
rollback: async (
|
|
913
|
-
|
|
914
|
-
const c = await r(
|
|
915
|
-
if (!c) throw new
|
|
916
|
-
x(
|
|
917
|
-
const d = await e.getVersion(
|
|
918
|
-
if (!d) throw new
|
|
919
|
-
return o(c, d.document,
|
|
912
|
+
rollback: async (s, a, l) => {
|
|
913
|
+
l = { ...l };
|
|
914
|
+
const c = await r(s, l);
|
|
915
|
+
if (!c) throw new L("missing", "模板不存在");
|
|
916
|
+
x(l.signal);
|
|
917
|
+
const d = await e.getVersion(s, a, l.signal);
|
|
918
|
+
if (!d) throw new L("history", "历史修订不存在");
|
|
919
|
+
return o(c, d.document, l, a);
|
|
920
920
|
}
|
|
921
921
|
};
|
|
922
922
|
}
|
|
923
|
-
function
|
|
923
|
+
function xn() {
|
|
924
924
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
925
925
|
return {
|
|
926
926
|
read: async (n, r) => {
|
|
@@ -937,46 +937,54 @@ function Mn() {
|
|
|
937
937
|
},
|
|
938
938
|
compareAndSwap: async (n, r, i, o) => {
|
|
939
939
|
if (x(o.signal), (e.get(n)?.revision ?? null) !== r) return !1;
|
|
940
|
-
if (i.id !== n) throw new
|
|
941
|
-
const
|
|
940
|
+
if (i.id !== n) throw new L("history", "状态 ID 与存储 ID 不一致");
|
|
941
|
+
const s = k(i), a = o.publication;
|
|
942
942
|
if (a) {
|
|
943
|
-
const
|
|
944
|
-
if (
|
|
945
|
-
|
|
943
|
+
const l = t.get(n) ?? /* @__PURE__ */ new Map();
|
|
944
|
+
if (l.has(a.revision) || a.revision !== i.revision || a.document.id !== n) throw new L("history", "发布修订不可覆盖,且必须与状态修订和模板 ID 一致");
|
|
945
|
+
l.set(a.revision, k(a)), t.set(n, l);
|
|
946
946
|
}
|
|
947
|
-
return e.set(n,
|
|
947
|
+
return e.set(n, s), !0;
|
|
948
948
|
}
|
|
949
949
|
};
|
|
950
950
|
}
|
|
951
|
-
function
|
|
952
|
-
const n =
|
|
951
|
+
function Rt(e, t) {
|
|
952
|
+
const n = e.publishedRevision ?? e.published?.revision;
|
|
953
|
+
for (const r of [e.draftRevision, n]) if (r !== void 0 && (typeof r != "string" || !r.trim())) throw new TypeError("模板生命周期修订应为非空字符串");
|
|
954
|
+
if (e.draftRevision !== void 0 && e.draftRevision !== t.revision) throw new TypeError("可编辑文档应与草稿修订一致");
|
|
955
|
+
if (e.published && (e.published.id !== t.id || e.published.revision !== n)) throw new TypeError("发布文档身份或修订不一致");
|
|
956
|
+
if (!e.published && n !== void 0 && n !== t.revision) throw new TypeError("发布修订需要对应的独立文档");
|
|
957
|
+
return { ...e.draftRevision === void 0 ? {} : { draftRevision: e.draftRevision }, ...n === void 0 ? {} : { publishedRevision: n } };
|
|
958
|
+
}
|
|
959
|
+
function En(e, t) {
|
|
960
|
+
const n = I(e);
|
|
953
961
|
if (t.id === n.id) throw new Error("复制模板应使用新的 ID");
|
|
954
962
|
const { revision: r, ...i } = n;
|
|
955
|
-
return
|
|
963
|
+
return I({ ...i, id: t.id, name: t.name });
|
|
956
964
|
}
|
|
957
|
-
function
|
|
965
|
+
function Sn(e) {
|
|
958
966
|
if (!Array.isArray(e) || e.length > 1e3) throw new RangeError("本地模板目录最多 1000 项");
|
|
959
|
-
const t = /* @__PURE__ */ new Map(), n = [];
|
|
960
|
-
for (const
|
|
961
|
-
const
|
|
962
|
-
if (t.has(
|
|
963
|
-
if (
|
|
964
|
-
const { template:
|
|
965
|
-
t.set(i.id, i)
|
|
967
|
+
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = [];
|
|
968
|
+
for (const i of e) {
|
|
969
|
+
const o = I(i.document);
|
|
970
|
+
if (t.has(o.id)) throw new Error(`模板 ID 重复:${o.id}`);
|
|
971
|
+
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("模板分类和标签无效");
|
|
972
|
+
const s = Rt(i, o), { template: a, ...l } = o;
|
|
973
|
+
t.set(o.id, o), i.published ? n.set(o.id, I(i.published)) : s.publishedRevision && n.set(o.id, I(o)), r.push({ ...l, ...s, ...i.category ? { category: i.category } : {}, ...i.tags ? { tags: [...i.tags] } : {} });
|
|
966
974
|
}
|
|
967
|
-
return
|
|
968
|
-
search: async (
|
|
969
|
-
we(r.signal);
|
|
970
|
-
const i = r.limit ?? 30;
|
|
971
|
-
if (!Number.isSafeInteger(i) || i < 1 || i > 100) throw new RangeError("模板每页数量应为 1–100");
|
|
972
|
-
const o = r.query?.trim().toLocaleLowerCase() ?? "", l = n.filter((s) => (!r.category || s.category === r.category) && (!r.cursor || s.id > r.cursor) && (!o || [s.id, s.name, s.description, ...s.tags ?? []].some((c) => c?.toLocaleLowerCase().includes(o)))), a = /* @__PURE__ */ new Map();
|
|
973
|
-
for (const s of n) s.category && a.set(s.category, (a.get(s.category) ?? 0) + 1);
|
|
974
|
-
return JSON.parse(JSON.stringify({ items: l.slice(0, i), ...l.length > i ? { next: l[i - 1].id } : {}, categories: Array.from(a, ([s, c]) => ({ id: s, label: s, count: c })) }));
|
|
975
|
-
},
|
|
976
|
-
get: async (r, i) => {
|
|
975
|
+
return r.sort((i, o) => i.id < o.id ? -1 : 1), {
|
|
976
|
+
search: async (i) => {
|
|
977
977
|
we(i.signal);
|
|
978
|
-
const o =
|
|
979
|
-
|
|
978
|
+
const o = i.limit ?? 30;
|
|
979
|
+
if (!Number.isSafeInteger(o) || o < 1 || o > 100) throw new RangeError("模板每页数量应为 1–100");
|
|
980
|
+
const s = i.query?.trim().toLocaleLowerCase() ?? "", a = r.filter((c) => (!i.category || c.category === i.category) && (!i.cursor || c.id > i.cursor) && (!s || [c.id, c.name, c.description, ...c.tags ?? []].some((d) => d?.toLocaleLowerCase().includes(s)))), l = /* @__PURE__ */ new Map();
|
|
981
|
+
for (const c of r) c.category && l.set(c.category, (l.get(c.category) ?? 0) + 1);
|
|
982
|
+
return JSON.parse(JSON.stringify({ items: a.slice(0, o), ...a.length > o ? { next: a[o - 1].id } : {}, categories: Array.from(l, ([c, d]) => ({ id: c, label: c, count: d })) }));
|
|
983
|
+
},
|
|
984
|
+
get: async (i, o) => {
|
|
985
|
+
we(o.signal);
|
|
986
|
+
const s = o.mode === "published" ? n.get(i) : t.get(i);
|
|
987
|
+
return s ? I(s) : void 0;
|
|
980
988
|
}
|
|
981
989
|
};
|
|
982
990
|
}
|
|
@@ -985,31 +993,31 @@ function we(e) {
|
|
|
985
993
|
const t = new Error("模板目录操作已取消");
|
|
986
994
|
throw t.name = "AbortError", t;
|
|
987
995
|
}
|
|
988
|
-
function
|
|
996
|
+
function Tn(e) {
|
|
989
997
|
return e.map((t) => t.map((n) => /[\t\r\n"]/.test(n) ? `"${n.replace(/"/g, '""')}"` : n).join(" ")).join(`\r
|
|
990
998
|
`);
|
|
991
999
|
}
|
|
992
|
-
function
|
|
1000
|
+
function Pt(e, t) {
|
|
993
1001
|
const n = e[e.length - 1];
|
|
994
1002
|
e.length > 1 && n?.length === 1 && n[0] === "" && /[\r\n]$/.test(t) && e.pop();
|
|
995
1003
|
}
|
|
996
|
-
function
|
|
1004
|
+
function Cn(e, t = 1e4) {
|
|
997
1005
|
if (e.length > 4 * 1024 * 1024) throw new Error("Clipboard text limit exceeded");
|
|
998
1006
|
const n = [[]];
|
|
999
|
-
let r = "", i = !1, o = !1,
|
|
1007
|
+
let r = "", i = !1, o = !1, s = 0;
|
|
1000
1008
|
function a() {
|
|
1001
|
-
if (++
|
|
1009
|
+
if (++s > t) throw new Error("Clipboard cell limit exceeded");
|
|
1002
1010
|
n[n.length - 1].push(r), r = "", o = !1;
|
|
1003
1011
|
}
|
|
1004
|
-
for (let
|
|
1005
|
-
const c = e[
|
|
1012
|
+
for (let l = 0; l < e.length; l++) {
|
|
1013
|
+
const c = e[l];
|
|
1006
1014
|
if (i) {
|
|
1007
1015
|
if (c !== '"') {
|
|
1008
1016
|
r += c;
|
|
1009
1017
|
continue;
|
|
1010
1018
|
}
|
|
1011
|
-
if (e[
|
|
1012
|
-
r += '"',
|
|
1019
|
+
if (e[l + 1] === '"') {
|
|
1020
|
+
r += '"', l++;
|
|
1013
1021
|
continue;
|
|
1014
1022
|
}
|
|
1015
1023
|
i = !1, o = !0;
|
|
@@ -1025,17 +1033,17 @@ function Tn(e, t = 1e4) {
|
|
|
1025
1033
|
}
|
|
1026
1034
|
if (c === "\r" || c === `
|
|
1027
1035
|
`) {
|
|
1028
|
-
a(), n.push([]), c === "\r" && e[
|
|
1029
|
-
` &&
|
|
1036
|
+
a(), n.push([]), c === "\r" && e[l + 1] === `
|
|
1037
|
+
` && l++;
|
|
1030
1038
|
continue;
|
|
1031
1039
|
}
|
|
1032
1040
|
if (o) throw new Error("Invalid quoted clipboard value");
|
|
1033
1041
|
r += c;
|
|
1034
1042
|
}
|
|
1035
1043
|
if (i) throw new Error("Unclosed clipboard quote");
|
|
1036
|
-
return a(),
|
|
1044
|
+
return a(), Pt(n, e), n;
|
|
1037
1045
|
}
|
|
1038
|
-
class
|
|
1046
|
+
class At extends Error {
|
|
1039
1047
|
constructor(t, n, r) {
|
|
1040
1048
|
const i = typeof n.label == "string" ? n.label : "单元格", o = {
|
|
1041
1049
|
definition: `${i}的编辑器配置无效`,
|
|
@@ -1052,46 +1060,46 @@ class Pt extends Error {
|
|
|
1052
1060
|
}
|
|
1053
1061
|
}
|
|
1054
1062
|
function p(e, t, n) {
|
|
1055
|
-
throw new
|
|
1063
|
+
throw new At(t, e, n);
|
|
1056
1064
|
}
|
|
1057
1065
|
function Oe(e) {
|
|
1058
1066
|
if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}$/.test(e) || e.startsWith("0000-")) return !1;
|
|
1059
1067
|
const t = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
|
|
1060
1068
|
return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
|
|
1061
1069
|
}
|
|
1062
|
-
function
|
|
1070
|
+
function kt(e) {
|
|
1063
1071
|
const [t = "", n = "0"] = String(e).toLowerCase().split("e");
|
|
1064
1072
|
return Math.max(0, (t.split(".")[1]?.length ?? 0) - Number(n));
|
|
1065
1073
|
}
|
|
1066
|
-
function kt(e, t) {
|
|
1067
|
-
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 && At(t) > e.precision && p(e, "precision", e.precision);
|
|
1068
|
-
}
|
|
1069
1074
|
function It(e, t) {
|
|
1075
|
+
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 && kt(t) > e.precision && p(e, "precision", e.precision);
|
|
1076
|
+
}
|
|
1077
|
+
function $t(e, t) {
|
|
1070
1078
|
Oe(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);
|
|
1071
1079
|
}
|
|
1072
|
-
function
|
|
1080
|
+
function Nt(e) {
|
|
1073
1081
|
[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");
|
|
1074
1082
|
}
|
|
1075
|
-
function
|
|
1083
|
+
function Lt(e) {
|
|
1076
1084
|
[e.min, e.max].some((t) => t !== void 0 && !Oe(t)) && p(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && p(e, "definition");
|
|
1077
1085
|
}
|
|
1078
|
-
function
|
|
1086
|
+
function Dt(e, t) {
|
|
1079
1087
|
(!Array.isArray(t.options) || !t.options.length) && p(t, "definition");
|
|
1080
1088
|
const n = e.valueType === "text" ? "string" : e.valueType, r = /* @__PURE__ */ new Set();
|
|
1081
1089
|
for (const i of t.options)
|
|
1082
1090
|
(!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);
|
|
1083
1091
|
}
|
|
1084
|
-
function
|
|
1092
|
+
function Ft(e) {
|
|
1085
1093
|
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");
|
|
1086
1094
|
}
|
|
1087
|
-
function
|
|
1088
|
-
(!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && p(t ?? { type: "text" }, "definition"),
|
|
1095
|
+
function Ot(e, t) {
|
|
1096
|
+
(!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && p(t ?? { type: "text" }, "definition"), Ft(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" && Nt(t), t.type === "text" && t.maxLength !== void 0 && (!Number.isInteger(t.maxLength) || t.maxLength < 0) && p(t, "definition"), t.type === "date" && Lt(t), t.type === "enum" && Dt(e, t);
|
|
1089
1097
|
}
|
|
1090
|
-
function
|
|
1098
|
+
function Rn(e, t, n) {
|
|
1091
1099
|
if (!e.editable) throw new Be("readonly");
|
|
1092
|
-
n &&
|
|
1100
|
+
n && Ot(e, n);
|
|
1093
1101
|
const r = Ge(e, t);
|
|
1094
|
-
return n ? (n.required && typeof r == "string" && !r.trim() && p(n, "required"), r === null || r === "" ? (n.required && p(n, "required"), r) : (n.type === "number" &&
|
|
1102
|
+
return n ? (n.required && typeof r == "string" && !r.trim() && p(n, "required"), r === null || r === "" ? (n.required && p(n, "required"), r) : (n.type === "number" && It(n, r), n.type === "date" && $t(n, r), n.type === "text" && n.maxLength !== void 0 && [...String(r)].length > n.maxLength && p(n, "length", n.maxLength), n.type === "enum" && !n.options.some((i) => Object.is(i.value, r)) && p(n, "choice"), r)) : r;
|
|
1095
1103
|
}
|
|
1096
1104
|
class w extends Error {
|
|
1097
1105
|
constructor(t) {
|
|
@@ -1115,86 +1123,86 @@ function be(e, t, n) {
|
|
|
1115
1123
|
if (![t.pageIndex, t.componentIndex, t.rowIndex, t.columnIndex].every((a) => Number.isSafeInteger(a) && a >= 0)) throw new w("selection");
|
|
1116
1124
|
const r = e.pages[t.pageIndex]?.components[t.componentIndex];
|
|
1117
1125
|
if (!r?.grid || t.rowIndex >= r.grid.cells.length) throw new w("selection");
|
|
1118
|
-
const i = r.grid.colWidthsMm?.length ?? r.grid.cells.reduce((a,
|
|
1126
|
+
const i = r.grid.colWidthsMm?.length ?? r.grid.cells.reduce((a, l) => Math.max(a, l.length), 1);
|
|
1119
1127
|
if (t.columnIndex >= i) throw new w("selection");
|
|
1120
|
-
const o = r.table,
|
|
1121
|
-
if (o &&
|
|
1122
|
-
const a =
|
|
1128
|
+
const o = r.table, s = e.pages[n.pageIndex]?.components[n.componentIndex]?.table;
|
|
1129
|
+
if (o && s && o.id === s.id) {
|
|
1130
|
+
const a = s.columnKeys.indexOf(o.columnKeys[t.columnIndex] ?? "");
|
|
1123
1131
|
if (a < 0) throw new w("selection");
|
|
1124
1132
|
return { grid: o.id, row: de(r) + t.rowIndex, column: a };
|
|
1125
1133
|
}
|
|
1126
1134
|
return { grid: `${t.pageIndex}:${t.componentIndex}`, row: t.rowIndex, column: t.columnIndex };
|
|
1127
1135
|
}
|
|
1128
|
-
function
|
|
1136
|
+
function zt(e, t, n) {
|
|
1129
1137
|
const r = be(e, t.anchor, t.anchor), i = be(e, t.focus, t.anchor);
|
|
1130
1138
|
if (r.grid !== i.grid) throw new w("selection");
|
|
1131
1139
|
const o = (Math.abs(r.row - i.row) + 1) * (Math.abs(r.column - i.column) + 1);
|
|
1132
1140
|
if (!Number.isSafeInteger(o) || o > n) throw new w("limit");
|
|
1133
1141
|
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 };
|
|
1134
1142
|
}
|
|
1135
|
-
function
|
|
1143
|
+
function Ht(e) {
|
|
1136
1144
|
if (!e) return !1;
|
|
1137
1145
|
const t = e.replace(/"[^"]*"|\\.|\[(?![hms]+\])[^\]]*\]/gi, "");
|
|
1138
1146
|
return /[ymdhs]/i.test(t);
|
|
1139
1147
|
}
|
|
1140
|
-
function
|
|
1141
|
-
if (e.valueType === "text" || e.valueType === "boolean" ||
|
|
1148
|
+
function Wt(e) {
|
|
1149
|
+
if (e.valueType === "text" || e.valueType === "boolean" || Ht(e.numberFormat)) return null;
|
|
1142
1150
|
const t = e.value;
|
|
1143
1151
|
if (typeof t != "number" || !Number.isFinite(t)) return null;
|
|
1144
1152
|
if (Number.isInteger(t) && !Number.isSafeInteger(t)) throw new w("precision");
|
|
1145
1153
|
return t;
|
|
1146
1154
|
}
|
|
1147
|
-
function
|
|
1155
|
+
function _t(e, t, n) {
|
|
1148
1156
|
if (e.seen.has(n)) return;
|
|
1149
1157
|
e.seen.add(n), e.selected++;
|
|
1150
|
-
const r = t ?
|
|
1158
|
+
const r = t ? Wt(t) : null;
|
|
1151
1159
|
r === null ? e.excluded++ : e.values.push(r);
|
|
1152
1160
|
}
|
|
1153
|
-
function
|
|
1161
|
+
function jt(e, t, n, r) {
|
|
1154
1162
|
return r.origin ? e.table?.id === r.origin.id : `${t}:${n}` === r.grid;
|
|
1155
1163
|
}
|
|
1156
|
-
function
|
|
1164
|
+
function Bt(e, t, n) {
|
|
1157
1165
|
return n.origin ? n.origin.columnKeys.indexOf(e.table.columnKeys[t] ?? "") : t;
|
|
1158
1166
|
}
|
|
1159
|
-
function
|
|
1160
|
-
const i = r.origin ? de(e) + t : t, o =
|
|
1167
|
+
function Gt(e, t, n, r) {
|
|
1168
|
+
const i = r.origin ? de(e) + t : t, o = Bt(e, n, r);
|
|
1161
1169
|
return i < r.rowStart || i > r.rowEnd || o < r.columnStart || o > r.columnEnd ? null : `${r.grid}:${i}:${o}`;
|
|
1162
1170
|
}
|
|
1163
|
-
function
|
|
1171
|
+
function Ut(e, t) {
|
|
1164
1172
|
const n = t.origin ? de(e) : 0, r = Math.max(0, t.rowStart - n), i = Math.min(e.grid.cells.length, t.rowEnd - n + 1);
|
|
1165
1173
|
return i > r ? i : 0;
|
|
1166
1174
|
}
|
|
1167
|
-
async function
|
|
1175
|
+
async function Vt(e, t, n, r, i) {
|
|
1168
1176
|
const o = e.grid;
|
|
1169
1177
|
if (t > r.maxScanned) throw new w("limit");
|
|
1170
|
-
const
|
|
1171
|
-
if (
|
|
1178
|
+
const s = o.colWidthsMm?.length ?? o.cells.reduce((l, c) => Math.max(l, c.length), 1);
|
|
1179
|
+
if (s > r.maxScanned) throw new w("limit");
|
|
1172
1180
|
const a = /* @__PURE__ */ new Map();
|
|
1173
|
-
for (let
|
|
1174
|
-
|
|
1181
|
+
for (let l = 0; l < t; l++) {
|
|
1182
|
+
l > 0 && l % 2048 === 0 && (await r.yieldToHost(), z(r.signal));
|
|
1175
1183
|
let c = 0;
|
|
1176
|
-
for (const d of o.cells[
|
|
1177
|
-
for (await J(r); c <
|
|
1178
|
-
if (c >=
|
|
1179
|
-
const m = Math.max(1, Math.min(d?.colSpan ?? 1,
|
|
1184
|
+
for (const d of o.cells[l]) {
|
|
1185
|
+
for (await J(r); c < s && (a.get(c) ?? 0) > l; ) c++;
|
|
1186
|
+
if (c >= s) break;
|
|
1187
|
+
const m = Math.max(1, Math.min(d?.colSpan ?? 1, s - c)), h = Math.min(o.cells.length, l + Math.max(1, d?.rowSpan ?? 1));
|
|
1180
1188
|
m > 1 && await J(r, m - 1);
|
|
1181
1189
|
for (let f = c; f < c + m; f++) a.set(f, h);
|
|
1182
|
-
const
|
|
1183
|
-
|
|
1190
|
+
const u = Gt(e, l, c, n);
|
|
1191
|
+
u && _t(i, d, u), c += m;
|
|
1184
1192
|
}
|
|
1185
1193
|
}
|
|
1186
1194
|
}
|
|
1187
|
-
async function
|
|
1195
|
+
async function qt(e, t, n) {
|
|
1188
1196
|
const r = { values: [], seen: /* @__PURE__ */ new Set(), excluded: 0, selected: 0 };
|
|
1189
1197
|
for (let i = 0; i < e.pages.length; i++) {
|
|
1190
1198
|
await J(n);
|
|
1191
1199
|
const o = e.pages[i];
|
|
1192
|
-
for (let
|
|
1200
|
+
for (let s = 0; s < o.components.length; s++) {
|
|
1193
1201
|
await J(n);
|
|
1194
|
-
const a = o.components[
|
|
1195
|
-
if (!a.grid || !
|
|
1196
|
-
const
|
|
1197
|
-
|
|
1202
|
+
const a = o.components[s];
|
|
1203
|
+
if (!a.grid || !jt(a, i, s, t) || a.table && a.table.role !== "body") continue;
|
|
1204
|
+
const l = Ut(a, t);
|
|
1205
|
+
l && await Vt(a, l, t, n, r);
|
|
1198
1206
|
}
|
|
1199
1207
|
}
|
|
1200
1208
|
return r;
|
|
@@ -1203,7 +1211,7 @@ function B(e) {
|
|
|
1203
1211
|
if (!Number.isFinite(e)) throw new w("overflow");
|
|
1204
1212
|
return e;
|
|
1205
1213
|
}
|
|
1206
|
-
function
|
|
1214
|
+
function Yt(e) {
|
|
1207
1215
|
let t = 0, n = 0;
|
|
1208
1216
|
for (const r of e) {
|
|
1209
1217
|
const i = r - n, o = B(t + i);
|
|
@@ -1211,209 +1219,209 @@ function qt(e) {
|
|
|
1211
1219
|
}
|
|
1212
1220
|
return t;
|
|
1213
1221
|
}
|
|
1214
|
-
async function
|
|
1222
|
+
async function ve(e, t) {
|
|
1215
1223
|
let n = [...e], r = new Array(e.length);
|
|
1216
1224
|
for (let o = 1; o < e.length; o *= 2) {
|
|
1217
|
-
for (let
|
|
1218
|
-
const a = Math.min(
|
|
1219
|
-
let c =
|
|
1220
|
-
for (let m =
|
|
1221
|
-
r[m] = d >=
|
|
1225
|
+
for (let s = 0; s < e.length; s += o * 2) {
|
|
1226
|
+
const a = Math.min(s + o, e.length), l = Math.min(s + o * 2, e.length);
|
|
1227
|
+
let c = s, d = a;
|
|
1228
|
+
for (let m = s; m < l; m++)
|
|
1229
|
+
r[m] = d >= l || c < a && n[c] <= n[d] ? n[c++] : n[d++], m % 2048 === 0 && (await t.yieldToHost(), z(t.signal));
|
|
1222
1230
|
}
|
|
1223
1231
|
[n, r] = [r, n];
|
|
1224
1232
|
}
|
|
1225
1233
|
const i = Math.floor(n.length / 2);
|
|
1226
1234
|
return n.length % 2 ? n[i] : B(n[i - 1] / 2 + n[i] / 2);
|
|
1227
1235
|
}
|
|
1228
|
-
function
|
|
1229
|
-
const t =
|
|
1236
|
+
function Kt(e) {
|
|
1237
|
+
const t = Yt(e);
|
|
1230
1238
|
let n = 1 / 0, r = -1 / 0;
|
|
1231
1239
|
for (const i of e)
|
|
1232
1240
|
n = Math.min(n, i), r = Math.max(r, i);
|
|
1233
1241
|
return { SUM: t, AVERAGE: t / e.length, AVG: t / e.length, MIN: n, MAX: r, COUNT: e.length };
|
|
1234
1242
|
}
|
|
1235
|
-
function
|
|
1243
|
+
function Xt(e, t) {
|
|
1236
1244
|
if (typeof e != "string" || e.length > 256) throw new w("expression");
|
|
1237
1245
|
const n = e.toUpperCase().match(/(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?|[A-Z_]+|[()+\-*/]|\S/g) ?? [];
|
|
1238
1246
|
if (!n.length || n.length > 64) throw new w("expression");
|
|
1239
1247
|
let r = 0;
|
|
1240
1248
|
function i(a) {
|
|
1241
1249
|
if (a > 16) throw new w("expression");
|
|
1242
|
-
const
|
|
1243
|
-
if (
|
|
1244
|
-
if (
|
|
1250
|
+
const l = n[r++];
|
|
1251
|
+
if (l === "+" || l === "-") return (l === "-" ? -1 : 1) * i(a + 1);
|
|
1252
|
+
if (l === "(") {
|
|
1245
1253
|
const c = o(0, a + 1);
|
|
1246
1254
|
if (n[r++] !== ")") throw new w("expression");
|
|
1247
1255
|
return c;
|
|
1248
1256
|
}
|
|
1249
|
-
if (
|
|
1250
|
-
if (
|
|
1257
|
+
if (l && /^(?:SUM|AVERAGE|AVG|MIN|MAX|COUNT|MEDIAN)$/.test(l) && Object.prototype.hasOwnProperty.call(t, l)) return B(t[l]);
|
|
1258
|
+
if (l && /^(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?$/.test(l)) return B(Number(l));
|
|
1251
1259
|
throw new w("expression");
|
|
1252
1260
|
}
|
|
1253
|
-
function o(a,
|
|
1254
|
-
let c = i(
|
|
1261
|
+
function o(a, l) {
|
|
1262
|
+
let c = i(l);
|
|
1255
1263
|
for (; r < n.length; ) {
|
|
1256
1264
|
const d = n[r], m = d === "+" || d === "-" ? 1 : d === "*" || d === "/" ? 2 : 0;
|
|
1257
1265
|
if (!m || m < a) break;
|
|
1258
1266
|
r++;
|
|
1259
|
-
const h = o(m + 1,
|
|
1267
|
+
const h = o(m + 1, l + 1);
|
|
1260
1268
|
if (d === "/" && h === 0) throw new w("division");
|
|
1261
1269
|
c = B(d === "+" ? c + h : d === "-" ? c - h : d === "*" ? c * h : c / h);
|
|
1262
1270
|
}
|
|
1263
1271
|
return c;
|
|
1264
1272
|
}
|
|
1265
|
-
const
|
|
1273
|
+
const s = o(1, 0);
|
|
1266
1274
|
if (r !== n.length) throw new w("expression");
|
|
1267
|
-
return
|
|
1275
|
+
return s;
|
|
1268
1276
|
}
|
|
1269
|
-
function
|
|
1277
|
+
function Jt(e) {
|
|
1270
1278
|
const t = e.maxCells ?? 1e5, n = e.maxScannedCells ?? 2e5, r = e.precision ?? 2;
|
|
1271
1279
|
if (![t, n].every((i) => Number.isSafeInteger(i) && i >= 1 && i <= 2e6)) throw new w("limit");
|
|
1272
1280
|
if (!Number.isInteger(r) || r < 0 || r > 12) throw new w("precision");
|
|
1273
1281
|
return { maxCells: t, maxScanned: n, precision: r };
|
|
1274
1282
|
}
|
|
1275
|
-
async function
|
|
1276
|
-
const r =
|
|
1283
|
+
async function Pn(e, t, n = {}) {
|
|
1284
|
+
const r = Jt(n), i = { scanned: 0, maxScanned: r.maxScanned, signal: n.signal, yieldToHost: n.yieldToHost ?? (() => new Promise((l) => setTimeout(l, 0))) };
|
|
1277
1285
|
z(i.signal);
|
|
1278
|
-
const o = await
|
|
1279
|
-
if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(
|
|
1286
|
+
const o = await qt(e, zt(e, t, r.maxCells), i), s = n.operation ?? "sum";
|
|
1287
|
+
if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(s)) throw new w("expression");
|
|
1280
1288
|
let a = null;
|
|
1281
|
-
if (
|
|
1289
|
+
if (s === "count") a = o.values.length;
|
|
1282
1290
|
else if (o.values.length)
|
|
1283
|
-
if (
|
|
1291
|
+
if (s === "median") a = await ve(o.values, i);
|
|
1284
1292
|
else {
|
|
1285
|
-
const
|
|
1286
|
-
|
|
1293
|
+
const l = Kt(o.values);
|
|
1294
|
+
s === "expression" ? (/\bMEDIAN\b/i.test(n.expression ?? "") && (l.MEDIAN = await ve(o.values, i)), a = Xt(n.expression ?? "", l)) : a = l[s.toUpperCase()];
|
|
1287
1295
|
}
|
|
1288
1296
|
if (z(i.signal), a !== null && Number.isInteger(a) && !Number.isSafeInteger(a)) throw new w("precision");
|
|
1289
1297
|
return { value: a, formatted: a === null ? "—" : a.toFixed(r.precision), numericCells: o.values.length, excludedCells: o.excluded, selectedCells: o.selected, precision: r.precision };
|
|
1290
1298
|
}
|
|
1291
1299
|
export {
|
|
1292
|
-
|
|
1293
|
-
|
|
1300
|
+
Bn as CSS_DPI,
|
|
1301
|
+
In as DEFAULT_BORDER_PT,
|
|
1294
1302
|
Z as DEFAULT_FONT_FAMILY,
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1303
|
+
$n as DEFAULT_FONT_PT,
|
|
1304
|
+
Nn as DEFAULT_STROKE_COLOR,
|
|
1305
|
+
ye as DEFAULT_TEXT_COLOR,
|
|
1306
|
+
Ln as LINE_HEIGHT,
|
|
1307
|
+
Gn as MM_PER_INCH,
|
|
1308
|
+
Dr as OutputAssetError,
|
|
1301
1309
|
Ue as OutputFidelityError,
|
|
1302
1310
|
K as PAPER_SIZES,
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1311
|
+
vt as PageBuilder,
|
|
1312
|
+
lr as PaginateCellLimitError,
|
|
1313
|
+
cr as PaginatePageLimitError,
|
|
1314
|
+
Yn as RENDER_PLAN_SCHEMA_VERSION,
|
|
1315
|
+
Hr as REPORT_TEMPLATE_DOCUMENT_VERSION,
|
|
1308
1316
|
w as ReportCalculationError,
|
|
1309
1317
|
Be as ReportCellEditError,
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1318
|
+
At as ReportCellFieldError,
|
|
1319
|
+
qr as ReportParamValidationError,
|
|
1320
|
+
dr as ReportSourceError,
|
|
1321
|
+
Wr as ReportTemplateError,
|
|
1322
|
+
L as ReportTemplateStoreError,
|
|
1323
|
+
Dn as SCHEMA_VERSION_MACH,
|
|
1316
1324
|
bt as TemplateBuilder,
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
+
ii as TreeRowLimitError,
|
|
1326
|
+
mr as applyReportCellEdit,
|
|
1327
|
+
hr as applyReportCellEditBatch,
|
|
1328
|
+
ur as applyReportEditResult,
|
|
1329
|
+
Xn as assertRenderPlan,
|
|
1330
|
+
Yr as assertReportParams,
|
|
1331
|
+
Pn as calculateReportSelection,
|
|
1332
|
+
rr as charWidthEm,
|
|
1325
1333
|
E as classOf,
|
|
1326
|
-
|
|
1327
|
-
|
|
1334
|
+
En as cloneReportTemplate,
|
|
1335
|
+
bn as columnsFromContract,
|
|
1328
1336
|
dt as computePageWindow,
|
|
1329
1337
|
gr as countTemplatePages,
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1338
|
+
ir as createCanvasMeasurer,
|
|
1339
|
+
pn as createCanvasPager,
|
|
1340
|
+
or as createHeuristicMeasurer,
|
|
1341
|
+
Sn as createLocalTemplateCatalog,
|
|
1342
|
+
xn as createMemoryTemplateStore,
|
|
1335
1343
|
yn as createProviderReport,
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1344
|
+
fr as createReportCellEdit,
|
|
1345
|
+
pr as createReportCellEditBatch,
|
|
1346
|
+
wr as createReportCellResolver,
|
|
1347
|
+
br as createReportEditSession,
|
|
1348
|
+
vr as createReportSource,
|
|
1349
|
+
vn as createTableTemplate,
|
|
1350
|
+
wn as createTemplate,
|
|
1351
|
+
Mn as createTemplateManager,
|
|
1352
|
+
_r as createTemplateRegistry,
|
|
1353
|
+
oi as createTreeTable,
|
|
1354
|
+
tr as datasetJsonSchema,
|
|
1347
1355
|
yr as defineReport,
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1356
|
+
jr as defineReportTemplate,
|
|
1357
|
+
Mr as diffReportTemplates,
|
|
1358
|
+
xr as estimateListLayoutCells,
|
|
1359
|
+
On as evalStyleRule,
|
|
1360
|
+
Xt as evaluateReportAggregateExpression,
|
|
1361
|
+
Er as formatReportCellEdit,
|
|
1362
|
+
Tn as formatReportClipboard,
|
|
1363
|
+
Kr as formatReportDateRange,
|
|
1364
|
+
zn as formatValue,
|
|
1365
|
+
Sr as getReportCellContext,
|
|
1366
|
+
Tr as getReportEditSession,
|
|
1367
|
+
oe as heuristicMeasurer,
|
|
1368
|
+
Or as inspectOutputCapabilities,
|
|
1361
1369
|
ee as isImageBackedComponent,
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1370
|
+
Xr as isReportDate,
|
|
1371
|
+
Jr as isReportMonth,
|
|
1372
|
+
Zr as isReportYear,
|
|
1365
1373
|
Se as isRichText,
|
|
1366
1374
|
le as measurePageSizePx,
|
|
1367
1375
|
ar as measureTextMm,
|
|
1368
1376
|
xe as mergeComponentStyles,
|
|
1369
1377
|
ie as mmToPx,
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1378
|
+
Un as mmToPxFactor,
|
|
1379
|
+
Cr as paginateTemplate,
|
|
1380
|
+
Rr as paginateTemplatePages,
|
|
1381
|
+
Hn as parseDateLocal,
|
|
1382
|
+
Rn as parseReportCellFieldInput,
|
|
1375
1383
|
Ge as parseReportCellInput,
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1384
|
+
Cn as parseReportClipboard,
|
|
1385
|
+
Qr as parseReportDateRange,
|
|
1386
|
+
I as parseReportTemplate,
|
|
1387
|
+
hn as planFontSizePx,
|
|
1388
|
+
Pr as projectListColumns,
|
|
1381
1389
|
O as ptToPx,
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1390
|
+
Vn as pxToMm,
|
|
1391
|
+
Ar as registerReportEditSession,
|
|
1392
|
+
kr as relocateReportCellEdits,
|
|
1385
1393
|
ke as renderComponent,
|
|
1386
|
-
|
|
1387
|
-
|
|
1394
|
+
ot as renderPage,
|
|
1395
|
+
mn as renderPlan,
|
|
1388
1396
|
gn as renderPlanToCanvas,
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1397
|
+
fn as renderPlanToCanvasAsync,
|
|
1398
|
+
un as renderPlanToImages,
|
|
1399
|
+
Ir as reportCellEditKey,
|
|
1392
1400
|
G as reportOutputDiagnostics,
|
|
1393
|
-
|
|
1401
|
+
ei as reportParamsJsonSchema,
|
|
1394
1402
|
Me as resolveBoxBorders,
|
|
1395
1403
|
W as resolveFontSize,
|
|
1396
1404
|
Ce as resolveGridLayout,
|
|
1397
1405
|
Q as resolveLineHeight,
|
|
1398
1406
|
Fe as resolvePaper,
|
|
1399
|
-
|
|
1407
|
+
ae as resolvePlanAssets,
|
|
1400
1408
|
j as resolveStroke,
|
|
1401
1409
|
Ee as resolveTextColor,
|
|
1402
|
-
|
|
1410
|
+
$r as reviewReportTemplate,
|
|
1403
1411
|
H as round,
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1412
|
+
Br as serializeReportTemplate,
|
|
1413
|
+
Nr as summarizeReportCellEdits,
|
|
1414
|
+
Wn as toExcelNumberFormat,
|
|
1415
|
+
_n as toNumber,
|
|
1416
|
+
Jn as validateComponent,
|
|
1409
1417
|
je as validateDatasetRows,
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1418
|
+
Zn as validatePage,
|
|
1419
|
+
Qn as validateRenderPlan,
|
|
1420
|
+
Ot as validateReportCellFieldDefinition,
|
|
1421
|
+
ti as validateReportParamDefinitions,
|
|
1422
|
+
ni as validateReportParams,
|
|
1423
|
+
Gr as validateReportTemplate,
|
|
1424
|
+
Ur as validateReportTemplateDocument,
|
|
1417
1425
|
ai as validateTreeOptions,
|
|
1418
1426
|
Te as wrapText
|
|
1419
1427
|
};
|