@agile-team/mach-report 0.6.0 → 0.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/dist/ReportPreview-CrVeTKu1.cjs +6 -0
- package/dist/ReportPreview-DgsOdO4y.js +559 -0
- package/dist/index.cjs +5 -5
- package/dist/index.js +531 -510
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.js +4 -4
- package/dist/plugin-Cl-IqCqx.cjs +1 -0
- package/dist/plugin-Dp3kKWiQ.js +92 -0
- package/dist/style.css +1 -1
- package/dist/vue/ReportPreview.d.ts +27 -3
- package/dist/vue/adapters.d.ts +3 -0
- package/dist/vue/async.d.cts +193 -64
- package/dist/vue/async.d.ts +193 -64
- package/dist/vue/controller.d.ts +24 -0
- package/dist/vue/errors.d.ts +16 -0
- package/dist/vue/index.d.cts +2 -0
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/injection-keys.d.ts +2 -0
- package/dist/vue/plugin.d.ts +262 -2
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +41 -32
- package/package.json +1 -1
- package/dist/ReportPreview-DWLjYi_p.js +0 -527
- package/dist/ReportPreview-rBtmbu3W.cjs +0 -6
- package/dist/plugin-BIJxGHZX.cjs +0 -1
- package/dist/plugin-DrV67_VW.js +0 -89
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { h as
|
|
2
|
-
import { C as
|
|
3
|
-
const
|
|
1
|
+
import { h as J, R as se, D as j, w as G, L as q, i as le, r as _, m as de, a as W, b as Z, c as F, d as V, p as O, e as he, f as Q, g as ce, j as me, P as K } from "./style-B7Xfo5I-.js";
|
|
2
|
+
import { C as Ue, k as Ke, l as Ye, M as Xe, S as Ze, n as Qe, o as et, q as tt, s as nt, t as it, u as rt, v as ot, x as at, y as st } from "./style-B7Xfo5I-.js";
|
|
3
|
+
const ge = /* @__PURE__ */ new Set([
|
|
4
4
|
"text",
|
|
5
5
|
"image",
|
|
6
6
|
"barcode",
|
|
@@ -10,161 +10,177 @@ const mt = /* @__PURE__ */ new Set([
|
|
|
10
10
|
"rect",
|
|
11
11
|
"ellipse"
|
|
12
12
|
]);
|
|
13
|
-
function L(
|
|
14
|
-
return typeof
|
|
13
|
+
function L(e) {
|
|
14
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const r =
|
|
18
|
-
r != null && (typeof r != "number" || !Number.isFinite(r)) &&
|
|
16
|
+
function fe(e, n, i, t) {
|
|
17
|
+
const r = e[n];
|
|
18
|
+
r != null && (typeof r != "number" || !Number.isFinite(r)) && t.push({ path: `${i}.${n}`, message: `应为有限数字,实际 ${JSON.stringify(r)}` });
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
if (!L(
|
|
20
|
+
function ee(e, n, i, t = []) {
|
|
21
|
+
if (!L(e)) {
|
|
22
22
|
i.push({ path: n, message: "组件应为对象" });
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
const r =
|
|
26
|
-
typeof r != "string" ? i.push({ path: `${n}.kind`, message: "组件缺少 kind 字符串" }) :
|
|
25
|
+
const r = e.kind;
|
|
26
|
+
typeof r != "string" ? i.push({ path: `${n}.kind`, message: "组件缺少 kind 字符串" }) : ge.has(r) || t.push({
|
|
27
27
|
path: `${n}.kind`,
|
|
28
28
|
message: `未知组件类型 ${JSON.stringify(r)},将以兜底方式渲染`
|
|
29
29
|
});
|
|
30
30
|
for (const o of ["leftMm", "topMm", "widthMm", "heightMm"])
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
31
|
+
fe(e, o, n, i);
|
|
32
|
+
e.leftMm != null && e.widthMm != null && (e.leftMm < -100 || e.widthMm < 0) && i.push({ path: n, message: "几何数值异常(leftMm<-100 或 widthMm<0)" });
|
|
33
|
+
const s = e.grid;
|
|
34
|
+
s !== void 0 && (!L(s) || !Array.isArray(s.cells) ? i.push({ path: `${n}.grid.cells`, message: "grid.cells 应为二维数组" }) : s.cells.forEach((o, l) => {
|
|
35
35
|
if (!Array.isArray(o)) {
|
|
36
|
-
i.push({ path: `${n}.grid.cells.${
|
|
36
|
+
i.push({ path: `${n}.grid.cells.${l}`, message: "行应为数组" });
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
o.forEach((d, h) => {
|
|
40
40
|
d != null && L(d) && Array.isArray(d.children) && d.children.forEach((c, m) => {
|
|
41
|
-
|
|
41
|
+
ee(c, `${n}.grid.cells.${l}.${h}.children.${m}`, i, t);
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
}));
|
|
45
|
-
const a =
|
|
46
|
-
a !== void 0 && (Array.isArray(a) ? a.forEach((o,
|
|
47
|
-
(!L(o) || !Array.isArray(o.segments)) && i.push({ path: `${n}.richParagraphs.${
|
|
45
|
+
const a = e.richParagraphs;
|
|
46
|
+
a !== void 0 && (Array.isArray(a) ? a.forEach((o, l) => {
|
|
47
|
+
(!L(o) || !Array.isArray(o.segments)) && i.push({ path: `${n}.richParagraphs.${l}`, message: "段落缺少 segments 数组" });
|
|
48
48
|
}) : i.push({ path: `${n}.richParagraphs`, message: "richParagraphs 应为数组" }));
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
if (!L(
|
|
50
|
+
function ue(e, n, i, t = []) {
|
|
51
|
+
if (!L(e)) {
|
|
52
52
|
i.push({ path: n, message: "页应为对象" });
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
const r =
|
|
56
|
-
(typeof r != "number" || !(r > 0 && r < 3e3)) && i.push({ path: `${n}.pageWidthMm`, message: `页宽非法: ${JSON.stringify(r)}` }), (typeof
|
|
57
|
-
const a =
|
|
55
|
+
const r = e.pageWidthMm, s = e.pageHeightMm;
|
|
56
|
+
(typeof r != "number" || !(r > 0 && r < 3e3)) && i.push({ path: `${n}.pageWidthMm`, message: `页宽非法: ${JSON.stringify(r)}` }), (typeof s != "number" || !(s > 0 && s < 5e3)) && i.push({ path: `${n}.pageHeightMm`, message: `页高非法: ${JSON.stringify(s)}` });
|
|
57
|
+
const a = e.components;
|
|
58
58
|
a !== void 0 && !Array.isArray(a) ? i.push({ path: `${n}.components`, message: "components 应为数组" }) : Array.isArray(a) && a.forEach(
|
|
59
|
-
(o,
|
|
59
|
+
(o, l) => ee(o, `${n}.components.${l}`, i, t)
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
const n = [], i = [],
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
function pe(e) {
|
|
63
|
+
const n = [], i = [], t = L(e) ? e.pages : void 0;
|
|
64
|
+
if (!Array.isArray(t))
|
|
65
|
+
n.push({
|
|
66
|
+
path: "$.pages",
|
|
67
|
+
message: e == null ? "渲染计划为空" : "渲染计划缺少 pages 数组"
|
|
68
|
+
});
|
|
69
|
+
else {
|
|
70
|
+
t.forEach((s, a) => ue(s, `$.pages.${a}`, n, i)), t.length > 2e3 && i.push({
|
|
71
|
+
path: "$.pages",
|
|
72
|
+
message: `页数异常大(${t.length} 页),渲染与打印耗时可能显著增加`
|
|
73
|
+
});
|
|
74
|
+
const r = t.reduce(
|
|
75
|
+
(s, a) => s + (L(a) && Array.isArray(a.components) ? a.components.length : 0),
|
|
76
|
+
0
|
|
77
|
+
);
|
|
78
|
+
r > 5e4 && i.push({
|
|
79
|
+
path: "$.pages",
|
|
80
|
+
message: `组件总数异常大(${r} 个),可能触发浏览器性能限制`
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return { ok: n.length === 0, errors: n, warnings: i };
|
|
68
84
|
}
|
|
69
|
-
function
|
|
70
|
-
const n =
|
|
85
|
+
function _e(e) {
|
|
86
|
+
const n = pe(e);
|
|
71
87
|
if (!n.ok) {
|
|
72
|
-
const i = n.errors.slice(0, 3).map((
|
|
88
|
+
const i = n.errors.slice(0, 3).map((t) => `${t.path}: ${t.message}`).join("; ");
|
|
73
89
|
throw new Error(`渲染计划校验失败(${n.errors.length} 处): ${i}`);
|
|
74
90
|
}
|
|
75
|
-
return
|
|
91
|
+
return e.pages;
|
|
76
92
|
}
|
|
77
|
-
function
|
|
93
|
+
function Y(e) {
|
|
78
94
|
return {
|
|
79
|
-
widthMm:
|
|
80
|
-
heightMm:
|
|
81
|
-
marginTopMm:
|
|
82
|
-
marginBottomMm:
|
|
83
|
-
marginLeftMm:
|
|
84
|
-
marginRightMm:
|
|
95
|
+
widthMm: e.widthMm,
|
|
96
|
+
heightMm: e.heightMm,
|
|
97
|
+
marginTopMm: e.marginTopMm ?? 0,
|
|
98
|
+
marginBottomMm: e.marginBottomMm ?? 0,
|
|
99
|
+
marginLeftMm: e.marginLeftMm ?? 0,
|
|
100
|
+
marginRightMm: e.marginRightMm ?? 0,
|
|
85
101
|
components: []
|
|
86
102
|
};
|
|
87
103
|
}
|
|
88
|
-
function
|
|
89
|
-
return n.heightMm - (
|
|
104
|
+
function Me(e, n) {
|
|
105
|
+
return n.heightMm - (e.marginBottomMm ?? n.marginBottomMm);
|
|
90
106
|
}
|
|
91
|
-
function
|
|
92
|
-
const
|
|
93
|
-
return Math.max(
|
|
107
|
+
function be(e, n) {
|
|
108
|
+
const t = (e.fontSizePt ?? j) * q * 25.4 / 72, r = (e.paddingMm ?? 1) * 2;
|
|
109
|
+
return Math.max(e.rowHeightMm ?? 0, n * t + r);
|
|
94
110
|
}
|
|
95
|
-
function
|
|
96
|
-
if (
|
|
97
|
-
if (typeof
|
|
98
|
-
if (typeof
|
|
99
|
-
if (typeof
|
|
100
|
-
if (
|
|
111
|
+
function ye(e) {
|
|
112
|
+
if (e == null) return "";
|
|
113
|
+
if (typeof e == "string") return e;
|
|
114
|
+
if (typeof e == "number") return String(e);
|
|
115
|
+
if (typeof e == "boolean") return e ? "是" : "否";
|
|
116
|
+
if (e instanceof Date) return e.toISOString().slice(0, 10);
|
|
101
117
|
try {
|
|
102
|
-
return JSON.stringify(
|
|
118
|
+
return JSON.stringify(e);
|
|
103
119
|
} catch {
|
|
104
|
-
return String(
|
|
120
|
+
return String(e);
|
|
105
121
|
}
|
|
106
122
|
}
|
|
107
|
-
function
|
|
108
|
-
const i =
|
|
123
|
+
function we(e, n) {
|
|
124
|
+
const i = e.fontSizePt ?? j, t = e.paddingMm ?? 1, r = e.columns.map(
|
|
109
125
|
(m) => m.style ? { align: "left", verticalAlign: "middle", ...m.style } : { align: "left", verticalAlign: "middle" }
|
|
110
|
-
),
|
|
126
|
+
), s = e.columns.map(
|
|
111
127
|
(m) => ({
|
|
112
|
-
bold:
|
|
128
|
+
bold: e.headerBold ?? !0,
|
|
113
129
|
align: "center",
|
|
114
130
|
verticalAlign: "middle",
|
|
115
|
-
backgroundColor:
|
|
131
|
+
backgroundColor: e.headerBackgroundColor,
|
|
116
132
|
...m.style || {}
|
|
117
133
|
})
|
|
118
|
-
), a =
|
|
119
|
-
(m,
|
|
134
|
+
), a = e.columns.map((m) => m.header), o = a.map(
|
|
135
|
+
(m, u) => G(
|
|
120
136
|
m,
|
|
121
|
-
|
|
122
|
-
{ fontSizePt: i, bold:
|
|
137
|
+
e.columns[u].widthMm - t * 2,
|
|
138
|
+
{ fontSizePt: i, bold: e.headerBold ?? !0 },
|
|
123
139
|
n
|
|
124
140
|
)
|
|
125
|
-
),
|
|
141
|
+
), l = Math.max(...o.map((m) => m.length), 1), d = be(e, l), h = a.map((m, u) => ({
|
|
126
142
|
text: m,
|
|
127
|
-
style:
|
|
128
|
-
})), c =
|
|
143
|
+
style: s[u]
|
|
144
|
+
})), c = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 };
|
|
129
145
|
return {
|
|
130
146
|
fontSizePt: i,
|
|
131
|
-
paddingMm:
|
|
147
|
+
paddingMm: t,
|
|
132
148
|
cellStyles: r,
|
|
133
149
|
borderStyle: c,
|
|
134
150
|
headerHeightMm: d,
|
|
135
151
|
headerGrid: { cells: [h], rowHeightsMm: [d] },
|
|
136
|
-
columns:
|
|
152
|
+
columns: e.columns
|
|
137
153
|
};
|
|
138
154
|
}
|
|
139
|
-
function
|
|
140
|
-
const
|
|
141
|
-
let
|
|
142
|
-
for (let h = 0; h <
|
|
143
|
-
r[h] =
|
|
144
|
-
const a = new Array(
|
|
145
|
-
for (let h = 0; h <
|
|
146
|
-
const c =
|
|
155
|
+
function Se(e, n, i) {
|
|
156
|
+
const t = e.columns, r = new Array(t.length);
|
|
157
|
+
let s = 1;
|
|
158
|
+
for (let h = 0; h < t.length; h++)
|
|
159
|
+
r[h] = ye(n[t[h].field]);
|
|
160
|
+
const a = new Array(t.length);
|
|
161
|
+
for (let h = 0; h < t.length; h++) {
|
|
162
|
+
const c = G(
|
|
147
163
|
r[h],
|
|
148
|
-
|
|
149
|
-
{ fontSizePt:
|
|
164
|
+
t[h].widthMm - e.paddingMm * 2,
|
|
165
|
+
{ fontSizePt: e.fontSizePt },
|
|
150
166
|
i
|
|
151
167
|
);
|
|
152
|
-
a[h] = c, c.length >
|
|
153
|
-
}
|
|
154
|
-
const o =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
), d = new Array(
|
|
158
|
-
for (let h = 0; h <
|
|
159
|
-
d[h] = { text: r[h], style:
|
|
160
|
-
return { grid: { cells: [d], rowHeightsMm: [
|
|
161
|
-
}
|
|
162
|
-
function
|
|
163
|
-
const
|
|
164
|
-
let
|
|
165
|
-
const d = (h) => `${h}_${(++
|
|
166
|
-
for (const h of
|
|
167
|
-
const c =
|
|
168
|
+
a[h] = c, c.length > s && (s = c.length);
|
|
169
|
+
}
|
|
170
|
+
const o = e.fontSizePt * q * 25.4 / 72, l = Math.max(
|
|
171
|
+
e.rowHeightFloorMm,
|
|
172
|
+
s * o + e.paddingMm * 2
|
|
173
|
+
), d = new Array(t.length);
|
|
174
|
+
for (let h = 0; h < t.length; h++)
|
|
175
|
+
d[h] = { text: r[h], style: e.cellStyles[h] };
|
|
176
|
+
return { grid: { cells: [d], rowHeightsMm: [l] }, heightMm: l };
|
|
177
|
+
}
|
|
178
|
+
function We(e, n, i = {}) {
|
|
179
|
+
const t = typeof i == "number" ? { mmPerRow: i } : i, r = t.mmPerRow ?? 0, s = t.measurer ?? J, a = [], o = [];
|
|
180
|
+
let l = 0;
|
|
181
|
+
const d = (h) => `${h}_${(++l).toString(36)}`;
|
|
182
|
+
for (const h of e.pages) {
|
|
183
|
+
const c = Y(h), m = () => Me(h, c), u = c.marginTopMm, g = () => {
|
|
168
184
|
o.push({
|
|
169
185
|
pageWidthMm: c.widthMm,
|
|
170
186
|
pageHeightMm: c.heightMm,
|
|
@@ -175,17 +191,17 @@ function _t(t, n, i = {}) {
|
|
|
175
191
|
components: c.components
|
|
176
192
|
});
|
|
177
193
|
};
|
|
178
|
-
for (const
|
|
179
|
-
if (
|
|
180
|
-
c.components.push(
|
|
194
|
+
for (const M of h.components) {
|
|
195
|
+
if (M.kind !== "list") {
|
|
196
|
+
c.components.push(M);
|
|
181
197
|
continue;
|
|
182
198
|
}
|
|
183
|
-
const p =
|
|
184
|
-
Array.isArray(
|
|
185
|
-
const
|
|
186
|
-
...
|
|
187
|
-
rowHeightFloorMm:
|
|
188
|
-
},
|
|
199
|
+
const p = M, k = n[p.dataset];
|
|
200
|
+
Array.isArray(k) || a.push(`数据集 ${p.dataset} 未提供数据,列表 ${p.id ?? ""} 输出为空`);
|
|
201
|
+
const T = Array.isArray(k) ? k : [], E = p.columns.reduce((f, b) => f + b.widthMm, 0), w = E > p.widthMm ? p.widthMm / E : 1, I = w === 1 ? p : { ...p, columns: p.columns.map((f) => ({ ...f, widthMm: f.widthMm * w })) }, R = {
|
|
202
|
+
...we(I, s),
|
|
203
|
+
rowHeightFloorMm: I.rowHeightMm ?? 0
|
|
204
|
+
}, D = {
|
|
189
205
|
kind: "rect",
|
|
190
206
|
leftMm: p.leftMm,
|
|
191
207
|
topMm: 0,
|
|
@@ -195,38 +211,38 @@ function _t(t, n, i = {}) {
|
|
|
195
211
|
nid: d("listh"),
|
|
196
212
|
style: R.borderStyle
|
|
197
213
|
};
|
|
198
|
-
let
|
|
199
|
-
const
|
|
200
|
-
|
|
214
|
+
let $ = p.topMm;
|
|
215
|
+
const B = (f, b) => {
|
|
216
|
+
f.components.push({ ...D, topMm: b });
|
|
201
217
|
};
|
|
202
|
-
|
|
203
|
-
for (let
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
218
|
+
B(c, $), $ += R.headerHeightMm + r;
|
|
219
|
+
for (let f = 0; f < T.length; f++) {
|
|
220
|
+
const b = Se(R, T[f], s);
|
|
221
|
+
if ($ + b.heightMm > m()) {
|
|
206
222
|
g();
|
|
207
|
-
const
|
|
208
|
-
c.components =
|
|
223
|
+
const P = Y(h);
|
|
224
|
+
c.components = P.components, c.heightMm = P.heightMm, I.headerEveryPage !== !1 ? (B(c, p.topMm), $ = p.topMm + R.headerHeightMm) : $ = u;
|
|
209
225
|
}
|
|
210
226
|
c.components.push({
|
|
211
227
|
kind: "rect",
|
|
212
228
|
leftMm: p.leftMm,
|
|
213
|
-
topMm:
|
|
229
|
+
topMm: $,
|
|
214
230
|
widthMm: p.widthMm,
|
|
215
|
-
heightMm:
|
|
216
|
-
grid:
|
|
231
|
+
heightMm: b.heightMm,
|
|
232
|
+
grid: b.grid,
|
|
217
233
|
nid: d("listr"),
|
|
218
234
|
style: R.borderStyle
|
|
219
|
-
}),
|
|
235
|
+
}), $ += b.heightMm;
|
|
220
236
|
}
|
|
221
237
|
}
|
|
222
238
|
g();
|
|
223
239
|
}
|
|
224
240
|
return {
|
|
225
|
-
plan: { schemaVersion:
|
|
241
|
+
plan: { schemaVersion: se, pages: o },
|
|
226
242
|
warnings: a
|
|
227
243
|
};
|
|
228
244
|
}
|
|
229
|
-
const
|
|
245
|
+
const Te = {
|
|
230
246
|
root: "mr-root",
|
|
231
247
|
page: "mr-page",
|
|
232
248
|
comp: "mr-comp",
|
|
@@ -243,23 +259,23 @@ const St = {
|
|
|
243
259
|
cell: "mr-cell",
|
|
244
260
|
unknown: "mr-unknown"
|
|
245
261
|
};
|
|
246
|
-
function
|
|
247
|
-
return n?.classNames?.[
|
|
262
|
+
function C(e, n) {
|
|
263
|
+
return n?.classNames?.[e] ?? Te[e];
|
|
248
264
|
}
|
|
249
|
-
class
|
|
265
|
+
class H {
|
|
250
266
|
constructor() {
|
|
251
267
|
this.props = [];
|
|
252
268
|
}
|
|
253
269
|
add(n, i) {
|
|
254
270
|
return i == null || i === !1 || i === "" ? this : (this.props.push([n, String(i)]), this);
|
|
255
271
|
}
|
|
256
|
-
mm(n, i,
|
|
257
|
-
return this.add(n, `${
|
|
272
|
+
mm(n, i, t, r = 2) {
|
|
273
|
+
return this.add(n, `${_(de(i, t), r)}px`);
|
|
258
274
|
}
|
|
259
275
|
toString() {
|
|
260
276
|
let n = "";
|
|
261
|
-
for (const [i,
|
|
262
|
-
n += `${i}:${
|
|
277
|
+
for (const [i, t] of this.props)
|
|
278
|
+
n += `${i}:${t};`;
|
|
263
279
|
return n;
|
|
264
280
|
}
|
|
265
281
|
applyTo(n) {
|
|
@@ -267,58 +283,58 @@ class $ {
|
|
|
267
283
|
i && (n.style.cssText = i);
|
|
268
284
|
}
|
|
269
285
|
}
|
|
270
|
-
function
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
const r =
|
|
274
|
-
|
|
286
|
+
function te(e, n, i) {
|
|
287
|
+
const t = n.style || {};
|
|
288
|
+
e.add("color", t.color).add("background-color", t.backgroundColor).add("font-family", t.fontFamily).add("font-weight", t.bold ? "700" : void 0).add("font-style", t.italic ? "italic" : void 0).add("text-decoration", t.underline ? "underline" : void 0).add("letter-spacing", t.letterSpacing != null ? `${t.letterSpacing}pt` : void 0).add("opacity", t.opacity != null ? String(t.opacity) : void 0).add("transform", t.rotateDeg ? `rotate(${t.rotateDeg}deg)` : void 0);
|
|
289
|
+
const r = W(t, i);
|
|
290
|
+
e.add("font-size", `${_(r.fontSizePx, 2)}px`);
|
|
275
291
|
}
|
|
276
|
-
function
|
|
277
|
-
const
|
|
278
|
-
if (
|
|
292
|
+
function ve(e, n, i, t, r) {
|
|
293
|
+
const s = r.createElement("table");
|
|
294
|
+
if (s.className = C("grid", t), new H().add("width", "100%").add("height", "100%").add("border-collapse", "collapse").add("table-layout", e.colWidthsMm ? "fixed" : "auto").applyTo(s), e.colWidthsMm) {
|
|
279
295
|
const d = r.createElement("colgroup");
|
|
280
|
-
for (const h of
|
|
296
|
+
for (const h of e.colWidthsMm) {
|
|
281
297
|
const c = r.createElement("col");
|
|
282
|
-
new
|
|
298
|
+
new H().mm("width", h, i).applyTo(c), d.appendChild(c);
|
|
283
299
|
}
|
|
284
|
-
|
|
300
|
+
s.appendChild(d);
|
|
285
301
|
}
|
|
286
|
-
const a =
|
|
287
|
-
return
|
|
302
|
+
const a = V(n.style), o = F(n.style), l = a.inner ? `${_(o.widthPt * i / 72, 2)}px solid ${o.color}` : "";
|
|
303
|
+
return e.cells.forEach((d, h) => {
|
|
288
304
|
const c = r.createElement("tr");
|
|
289
|
-
c.className =
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
const g = new
|
|
293
|
-
if (
|
|
294
|
-
const
|
|
295
|
-
g.add("text-align",
|
|
305
|
+
c.className = C("row", t), e.rowHeightsMm?.[h] != null && new H().mm("height", e.rowHeightsMm[h], i).applyTo(c), (d || []).forEach((m) => {
|
|
306
|
+
const u = r.createElement("td");
|
|
307
|
+
u.className = C("cell", t), m?.colSpan && (u.colSpan = m.colSpan), m?.rowSpan && (u.rowSpan = m.rowSpan);
|
|
308
|
+
const g = new H();
|
|
309
|
+
if (l && g.add("border", l), m?.style) {
|
|
310
|
+
const M = m.style;
|
|
311
|
+
g.add("text-align", M.align).add("vertical-align", M.verticalAlign).add("background-color", M.backgroundColor).add("color", M.color).add("font-weight", M.bold ? "700" : void 0), g.add("font-size", `${_(W(M, i).fontSizePx, 2)}px`);
|
|
296
312
|
}
|
|
297
|
-
if (g.applyTo(
|
|
298
|
-
for (const
|
|
299
|
-
|
|
300
|
-
c.appendChild(
|
|
301
|
-
}),
|
|
302
|
-
}),
|
|
303
|
-
}
|
|
304
|
-
function
|
|
305
|
-
const r =
|
|
306
|
-
r.className =
|
|
307
|
-
const
|
|
313
|
+
if (g.applyTo(u), m?.text != null && (u.textContent = m.text), m?.children?.length)
|
|
314
|
+
for (const M of m.children)
|
|
315
|
+
u.appendChild(ne(M, i, t, r));
|
|
316
|
+
c.appendChild(u);
|
|
317
|
+
}), s.appendChild(c);
|
|
318
|
+
}), s;
|
|
319
|
+
}
|
|
320
|
+
function Ce(e, n, i, t) {
|
|
321
|
+
const r = t.createElement("div");
|
|
322
|
+
r.className = C("text", i);
|
|
323
|
+
const s = e.style || {}, a = new H().add("text-align", s.align).add("display", "flex").add("flex-direction", "column").add(
|
|
308
324
|
"justify-content",
|
|
309
|
-
|
|
325
|
+
s.verticalAlign === "middle" ? "center" : s.verticalAlign === "bottom" ? "flex-end" : "flex-start"
|
|
310
326
|
).add("overflow", "hidden");
|
|
311
|
-
if (
|
|
312
|
-
const o =
|
|
313
|
-
o.className =
|
|
314
|
-
for (const
|
|
315
|
-
const d =
|
|
316
|
-
d.className =
|
|
317
|
-
for (const c of
|
|
318
|
-
const m =
|
|
319
|
-
if (m.className =
|
|
320
|
-
const
|
|
321
|
-
|
|
327
|
+
if (te(a, e, n), a.applyTo(r), Z(e)) {
|
|
328
|
+
const o = t.createElement("div");
|
|
329
|
+
o.className = C("rich", i);
|
|
330
|
+
for (const l of e.richParagraphs) {
|
|
331
|
+
const d = t.createElement("div");
|
|
332
|
+
d.className = C("paragraph", i), new H().add("text-align", l.align).add("line-height", l.lineHeight != null ? String(l.lineHeight) : void 0).mm("margin-top", l.spaceBeforeMm ?? 0, n).mm("margin-bottom", l.spaceAfterMm ?? 0, n).mm("text-indent", l.indentMm ?? 0, n).applyTo(d);
|
|
333
|
+
for (const c of l.segments || []) {
|
|
334
|
+
const m = t.createElement("span");
|
|
335
|
+
if (m.className = C("segment", i), m.textContent = c.kind === "field" ? c.field ?? "" : c.text ?? "", c.style) {
|
|
336
|
+
const u = new H().add("color", c.style.color).add("font-weight", c.style.bold ? "700" : void 0);
|
|
337
|
+
u.add("font-size", `${_(W(c.style, n).fontSizePx, 2)}px`), u.applyTo(m);
|
|
322
338
|
}
|
|
323
339
|
d.appendChild(m);
|
|
324
340
|
}
|
|
@@ -326,148 +342,148 @@ function vt(t, n, i, e) {
|
|
|
326
342
|
}
|
|
327
343
|
return r.appendChild(o), r;
|
|
328
344
|
}
|
|
329
|
-
if (Array.isArray(
|
|
330
|
-
const o =
|
|
331
|
-
o.className =
|
|
332
|
-
for (const
|
|
333
|
-
const d =
|
|
334
|
-
d.className =
|
|
345
|
+
if (Array.isArray(e.lines) && e.lines.length > 0) {
|
|
346
|
+
const o = t.createElement("div");
|
|
347
|
+
o.className = C("lines", i), s.lineHeight != null && new H().add("line-height", String(s.lineHeight)).applyTo(o);
|
|
348
|
+
for (const l of e.lines) {
|
|
349
|
+
const d = t.createElement("div");
|
|
350
|
+
d.className = C("line", i), d.textContent = l, o.appendChild(d);
|
|
335
351
|
}
|
|
336
352
|
return r.appendChild(o), r;
|
|
337
353
|
}
|
|
338
|
-
return r.textContent =
|
|
339
|
-
}
|
|
340
|
-
function
|
|
341
|
-
const
|
|
342
|
-
return
|
|
343
|
-
}
|
|
344
|
-
function
|
|
345
|
-
const r =
|
|
346
|
-
r.className =
|
|
347
|
-
const
|
|
348
|
-
return
|
|
349
|
-
}
|
|
350
|
-
function
|
|
351
|
-
const r =
|
|
352
|
-
r.className = `${
|
|
353
|
-
const
|
|
354
|
-
if (
|
|
355
|
-
return r.appendChild(
|
|
356
|
-
if (
|
|
357
|
-
return r.appendChild(
|
|
358
|
-
if (
|
|
359
|
-
const o =
|
|
360
|
-
return o.appendChild(
|
|
361
|
-
}
|
|
362
|
-
if (
|
|
363
|
-
return r.appendChild(
|
|
364
|
-
const a =
|
|
365
|
-
return a.className =
|
|
366
|
-
}
|
|
367
|
-
function
|
|
368
|
-
const r =
|
|
369
|
-
r.className =
|
|
370
|
-
for (const
|
|
371
|
-
r.appendChild(
|
|
354
|
+
return r.textContent = e.text ?? "", r;
|
|
355
|
+
}
|
|
356
|
+
function ke(e, n, i) {
|
|
357
|
+
const t = i.createElement("img");
|
|
358
|
+
return t.className = C("image", n), t.src = e.imageData, new H().add("width", "100%").add("height", "100%").add("object-fit", "contain").add("display", "block").applyTo(t), t.alt = e.kind, t;
|
|
359
|
+
}
|
|
360
|
+
function X(e, n, i, t) {
|
|
361
|
+
const r = t.createElement("div");
|
|
362
|
+
r.className = C("shape", i);
|
|
363
|
+
const s = e.style || {}, a = F(s), o = V(s), l = `${_(a.widthPt * n / 72, 2)}px solid ${a.color}`, d = new H();
|
|
364
|
+
return e.grid || e.kind === "rect" ? (o.top && d.add("border-top", l), o.right && d.add("border-right", l), o.bottom && d.add("border-bottom", l), o.left && d.add("border-left", l)) : e.kind === "ellipse" ? (o.inner && d.add("border", l).add("border-radius", "50%"), s.backgroundColor && d.add("background-color", s.backgroundColor)) : e.kind === "line" && d.add("height", "0").add("border-top", l), d.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), d.applyTo(r), r;
|
|
365
|
+
}
|
|
366
|
+
function ne(e, n, i, t) {
|
|
367
|
+
const r = t.createElement("div");
|
|
368
|
+
r.className = `${C("comp", i)} mr-kind-${e.kind}`;
|
|
369
|
+
const s = new H().add("position", "absolute").mm("left", e.leftMm, n).mm("top", e.topMm, n).mm("width", e.widthMm, n).mm("height", e.heightMm, n).add("box-sizing", "border-box");
|
|
370
|
+
if (te(s, e, n), s.applyTo(r), le(e))
|
|
371
|
+
return r.appendChild(ke(e, i, t)), r;
|
|
372
|
+
if (e.kind === "text")
|
|
373
|
+
return r.appendChild(Ce(e, n, i, t)), r;
|
|
374
|
+
if (e.grid) {
|
|
375
|
+
const o = X(e, n, i, t);
|
|
376
|
+
return o.appendChild(ve(e.grid, e, n, i, t)), r.appendChild(o), r;
|
|
377
|
+
}
|
|
378
|
+
if (e.kind === "line" || e.kind === "rect" || e.kind === "ellipse" || e.kind === "chart")
|
|
379
|
+
return r.appendChild(X(e, n, i, t)), r;
|
|
380
|
+
const a = t.createElement("div");
|
|
381
|
+
return a.className = C("unknown", i), a.textContent = e.fallbackText ?? "", r.appendChild(a), r;
|
|
382
|
+
}
|
|
383
|
+
function xe(e, n, i, t) {
|
|
384
|
+
const r = t.createElement("div");
|
|
385
|
+
r.className = C("page", i), new H().add("position", "relative").mm("width", e.pageWidthMm, n).mm("height", e.pageHeightMm, n).add("background-color", "#fff").add("overflow", "hidden").add("box-sizing", "border-box").applyTo(r);
|
|
386
|
+
for (const s of e.components)
|
|
387
|
+
r.appendChild(ne(s, n, i, t));
|
|
372
388
|
return r;
|
|
373
389
|
}
|
|
374
|
-
function
|
|
375
|
-
const
|
|
376
|
-
return r.className =
|
|
377
|
-
r.appendChild(
|
|
390
|
+
function Ie(e, n, i = {}) {
|
|
391
|
+
const t = i.dpi ?? 96, r = n.createElement("div");
|
|
392
|
+
return r.className = C("root", i), r.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((s) => {
|
|
393
|
+
r.appendChild(xe(s, t, i, n));
|
|
378
394
|
}), r;
|
|
379
395
|
}
|
|
380
|
-
function
|
|
381
|
-
const { pageHeightsPx: n, viewportHeightPx: i, scrollTopPx:
|
|
396
|
+
function Pe(e) {
|
|
397
|
+
const { pageHeightsPx: n, viewportHeightPx: i, scrollTopPx: t, overscan: r = 1, gapPx: s = 0 } = e, a = n.length;
|
|
382
398
|
if (a === 0)
|
|
383
399
|
return { start: 0, end: -1, padTopPx: 0, padBottomPx: 0 };
|
|
384
|
-
const o = Math.max(0,
|
|
385
|
-
|
|
400
|
+
const o = Math.max(0, s), l = new Array(a + 1);
|
|
401
|
+
l[0] = 0;
|
|
386
402
|
for (let w = 0; w < a; w++)
|
|
387
|
-
|
|
388
|
-
const d =
|
|
389
|
-
let c = 0, m = 0,
|
|
390
|
-
for (; m <=
|
|
391
|
-
const w = m +
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
const g = Math.max(0, Math.min(a - 1, c - r)),
|
|
403
|
+
l[w + 1] = l[w] + Math.max(0, n[w] ?? 0) + o;
|
|
404
|
+
const d = l[a], h = Math.max(0, t);
|
|
405
|
+
let c = 0, m = 0, u = a - 1;
|
|
406
|
+
for (; m <= u; ) {
|
|
407
|
+
const w = m + u >> 1;
|
|
408
|
+
l[w] <= h ? (c = w, m = w + 1) : u = w - 1;
|
|
409
|
+
}
|
|
410
|
+
const g = Math.max(0, Math.min(a - 1, c - r)), M = l[c] + Math.max(0, i);
|
|
395
411
|
let p = a - 1;
|
|
396
|
-
for (m = 0,
|
|
397
|
-
const w = m +
|
|
398
|
-
|
|
412
|
+
for (m = 0, u = a - 1; m <= u; ) {
|
|
413
|
+
const w = m + u >> 1;
|
|
414
|
+
l[w + 1] < M ? m = w + 1 : (p = w, u = w - 1);
|
|
399
415
|
}
|
|
400
|
-
const
|
|
401
|
-
return { start: g, end:
|
|
416
|
+
const k = Math.min(a - 1, p + r), T = l[g], E = Math.max(0, d - l[k + 1]);
|
|
417
|
+
return { start: g, end: k, padTopPx: T, padBottomPx: E };
|
|
402
418
|
}
|
|
403
|
-
const
|
|
404
|
-
function
|
|
405
|
-
const i = n / 96 *
|
|
419
|
+
const U = 96 / 25.4;
|
|
420
|
+
function ie(e, n = 96) {
|
|
421
|
+
const i = n / 96 * U;
|
|
406
422
|
return {
|
|
407
|
-
widthPx: Math.max(1, Math.round(
|
|
408
|
-
heightPx: Math.max(1, Math.round(
|
|
423
|
+
widthPx: Math.max(1, Math.round(e.pageWidthMm * i)),
|
|
424
|
+
heightPx: Math.max(1, Math.round(e.pageHeightMm * i))
|
|
409
425
|
};
|
|
410
426
|
}
|
|
411
|
-
function
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
const a =
|
|
427
|
+
function Ae(e, n, i) {
|
|
428
|
+
const t = document.createElement("canvas"), { widthPx: r, heightPx: s } = ie(e, i);
|
|
429
|
+
t.width = Math.round(r * n), t.height = Math.round(s * n), t.style.width = `${r}px`, t.style.height = `${s}px`;
|
|
430
|
+
const a = t.getContext("2d");
|
|
415
431
|
if (!a)
|
|
416
432
|
throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
|
|
417
|
-
return a.scale(n, n), a.fillStyle = "#ffffff", a.fillRect(0, 0, r,
|
|
418
|
-
}
|
|
419
|
-
function
|
|
420
|
-
return
|
|
421
|
-
}
|
|
422
|
-
function
|
|
423
|
-
|
|
424
|
-
const
|
|
425
|
-
`), h = d.length *
|
|
426
|
-
let c =
|
|
427
|
-
o === "middle" ? c =
|
|
428
|
-
|
|
433
|
+
return a.scale(n, n), a.fillStyle = "#ffffff", a.fillRect(0, 0, r, s), { canvas: t, ctx: a };
|
|
434
|
+
}
|
|
435
|
+
function De(e, n = 96) {
|
|
436
|
+
return W(e, n).fontSizePx;
|
|
437
|
+
}
|
|
438
|
+
function re(e, n, i, t, r, s, a, o = "top") {
|
|
439
|
+
e.font = `${n.bold ? "bold " : ""}${n.fontSizePx}px ${a}`, e.fillStyle = n.color, e.textBaseline = "alphabetic";
|
|
440
|
+
const l = n.fontSizePx * n.lineHeight, d = n.text === "" ? [""] : n.text.split(`
|
|
441
|
+
`), h = d.length * l;
|
|
442
|
+
let c = t;
|
|
443
|
+
o === "middle" ? c = t + (s - h) / 2 : o === "bottom" && (c = t + s - h), d.forEach((m, u) => {
|
|
444
|
+
e.textAlign = n.align === "center" ? "center" : n.align === "right" ? "right" : "left";
|
|
429
445
|
const g = n.align === "center" ? i + r / 2 : n.align === "right" ? i + r : i;
|
|
430
|
-
|
|
431
|
-
}),
|
|
446
|
+
e.fillText(m, g, c + u * l + n.fontSizePx * 0.8, r);
|
|
447
|
+
}), e.textAlign = "left";
|
|
432
448
|
}
|
|
433
|
-
function
|
|
434
|
-
const c =
|
|
449
|
+
function Ee(e, n, i, t, r, s, a, o, l, d, h) {
|
|
450
|
+
const c = ce(n, s / o, a / o), m = V(i.style), u = F(i.style);
|
|
435
451
|
for (const g of c.cells) {
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
|
|
452
|
+
const M = g.cell.style?.backgroundColor;
|
|
453
|
+
M && (e.fillStyle = M, e.fillRect(
|
|
454
|
+
t + g.xMm * o,
|
|
439
455
|
r + g.yMm * o,
|
|
440
456
|
g.widthMm * o,
|
|
441
457
|
g.heightMm * o
|
|
442
458
|
));
|
|
443
459
|
}
|
|
444
460
|
if (m.inner) {
|
|
445
|
-
|
|
461
|
+
e.strokeStyle = u.color, e.lineWidth = O(u.widthPt, l);
|
|
446
462
|
for (const g of c.edges)
|
|
447
|
-
|
|
448
|
-
|
|
463
|
+
e.beginPath(), g.kind === "v" ? (e.moveTo(t + g.pos * o, r + g.from * o), e.lineTo(t + g.pos * o, r + g.to * o)) : (e.moveTo(t + g.from * o, r + g.pos * o), e.lineTo(t + g.to * o, r + g.pos * o)), e.stroke();
|
|
464
|
+
e.beginPath(), m.top && (e.moveTo(t, r), e.lineTo(t + s, r)), m.right && (e.moveTo(t + s, r), e.lineTo(t + s, r + a)), m.bottom && (e.moveTo(t + s, r + a), e.lineTo(t, r + a)), m.left && (e.moveTo(t, r + a), e.lineTo(t, r)), e.stroke();
|
|
449
465
|
}
|
|
450
466
|
for (const g of c.cells) {
|
|
451
|
-
const
|
|
452
|
-
if (!
|
|
453
|
-
const p = g.cell.style,
|
|
454
|
-
|
|
467
|
+
const M = typeof g.cell.text == "string" ? g.cell.text : "";
|
|
468
|
+
if (!M) continue;
|
|
469
|
+
const p = g.cell.style, k = p?.fontSize ?? j, T = G(
|
|
470
|
+
M,
|
|
455
471
|
g.widthMm - 1,
|
|
456
|
-
{ fontSizePt:
|
|
472
|
+
{ fontSizePt: k },
|
|
457
473
|
h
|
|
458
474
|
).join(`
|
|
459
475
|
`);
|
|
460
|
-
|
|
461
|
-
|
|
476
|
+
re(
|
|
477
|
+
e,
|
|
462
478
|
{
|
|
463
|
-
text:
|
|
464
|
-
fontSizePx:
|
|
479
|
+
text: T,
|
|
480
|
+
fontSizePx: W(p, l).fontSizePx,
|
|
465
481
|
bold: p?.bold ?? !1,
|
|
466
|
-
color: p?.color ??
|
|
482
|
+
color: p?.color ?? Q(i.style, me),
|
|
467
483
|
align: p?.align ?? "left",
|
|
468
|
-
lineHeight:
|
|
484
|
+
lineHeight: q
|
|
469
485
|
},
|
|
470
|
-
|
|
486
|
+
t + (g.xMm + 0.5) * o,
|
|
471
487
|
r + g.yMm * o,
|
|
472
488
|
Math.max(0, (g.widthMm - 1) * o),
|
|
473
489
|
g.heightMm * o,
|
|
@@ -476,31 +492,31 @@ function At(t, n, i, e, r, l, a, o, s, d, h) {
|
|
|
476
492
|
);
|
|
477
493
|
}
|
|
478
494
|
}
|
|
479
|
-
function
|
|
480
|
-
const a = n.leftMm * i, o = n.topMm * i,
|
|
495
|
+
function oe(e, n, i, t, r, s) {
|
|
496
|
+
const a = n.leftMm * i, o = n.topMm * i, l = n.widthMm * i, d = n.heightMm * i, h = n.style ?? {};
|
|
481
497
|
if (n.grid) {
|
|
482
|
-
|
|
498
|
+
Ee(e, n.grid, n, a, o, l, d, i, t, r, s);
|
|
483
499
|
return;
|
|
484
500
|
}
|
|
485
501
|
switch (n.kind) {
|
|
486
502
|
case "text": {
|
|
487
|
-
const c = h.fontSize ?? j, m =
|
|
503
|
+
const c = h.fontSize ?? j, m = Z(n) ? n.richParagraphs.map((u) => (u.segments ?? []).map((g) => g.text ?? g.field ?? "").join("")).join(`
|
|
488
504
|
`) : Array.isArray(n.lines) && n.lines.length > 0 ? n.lines.join(`
|
|
489
|
-
`) :
|
|
505
|
+
`) : G(n.text ?? "", n.widthMm, { fontSizePt: c }, s).join(`
|
|
490
506
|
`);
|
|
491
|
-
|
|
492
|
-
|
|
507
|
+
re(
|
|
508
|
+
e,
|
|
493
509
|
{
|
|
494
510
|
text: m,
|
|
495
|
-
fontSizePx:
|
|
511
|
+
fontSizePx: W(h, t).fontSizePx,
|
|
496
512
|
bold: h.bold ?? !1,
|
|
497
|
-
color:
|
|
513
|
+
color: Q(h),
|
|
498
514
|
align: h.align ?? "left",
|
|
499
|
-
lineHeight:
|
|
515
|
+
lineHeight: he(h)
|
|
500
516
|
},
|
|
501
517
|
a,
|
|
502
518
|
o,
|
|
503
|
-
|
|
519
|
+
l,
|
|
504
520
|
d,
|
|
505
521
|
r,
|
|
506
522
|
h.verticalAlign
|
|
@@ -508,256 +524,261 @@ function rt(t, n, i, e, r, l) {
|
|
|
508
524
|
break;
|
|
509
525
|
}
|
|
510
526
|
case "rect": {
|
|
511
|
-
const c =
|
|
512
|
-
h.backgroundColor && (
|
|
527
|
+
const c = F(h), m = V(h);
|
|
528
|
+
h.backgroundColor && (e.fillStyle = h.backgroundColor, e.fillRect(a, o, l, d)), m.inner && (e.strokeStyle = c.color, e.lineWidth = O(c.widthPt, t), e.beginPath(), m.top && (e.moveTo(a, o), e.lineTo(a + l, o)), m.right && (e.moveTo(a + l, o), e.lineTo(a + l, o + d)), m.bottom && (e.moveTo(a + l, o + d), e.lineTo(a, o + d)), m.left && (e.moveTo(a, o + d), e.lineTo(a, o)), e.stroke());
|
|
513
529
|
break;
|
|
514
530
|
}
|
|
515
531
|
case "line": {
|
|
516
|
-
const c =
|
|
517
|
-
|
|
532
|
+
const c = F({ ...h, borderColor: h.lineColor ?? h.borderColor });
|
|
533
|
+
e.strokeStyle = c.color, e.lineWidth = O(c.widthPt, t), e.beginPath(), e.moveTo(a, o + d / 2), e.lineTo(a + l, o + d / 2), e.stroke();
|
|
518
534
|
break;
|
|
519
535
|
}
|
|
520
536
|
case "ellipse": {
|
|
521
|
-
const c =
|
|
522
|
-
|
|
537
|
+
const c = F(h);
|
|
538
|
+
e.strokeStyle = c.color, e.lineWidth = O(c.widthPt, t), h.backgroundColor && (e.fillStyle = h.backgroundColor, e.beginPath(), e.ellipse(a + l / 2, o + d / 2, l / 2, d / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(a + l / 2, o + d / 2, l / 2, d / 2, 0, 0, Math.PI * 2), e.stroke();
|
|
523
539
|
break;
|
|
524
540
|
}
|
|
525
541
|
}
|
|
526
542
|
}
|
|
527
|
-
function
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
543
|
+
function Oe(e, n = {}) {
|
|
544
|
+
if (typeof document > "u")
|
|
545
|
+
throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");
|
|
546
|
+
const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), t = n.dpi ?? 96, r = t / 96 * U, s = n.fontFamily ?? '"Microsoft YaHei", sans-serif', a = n.measurer ?? J, o = Math.max(0, n.start ?? 0), l = Math.min(e.pages.length - 1, n.end ?? e.pages.length - 1), d = [];
|
|
547
|
+
for (let h = o; h <= l; h++) {
|
|
548
|
+
const c = e.pages[h], { canvas: m, ctx: u } = Ae(c, i, t);
|
|
531
549
|
for (const g of c.components)
|
|
532
|
-
|
|
550
|
+
oe(u, g, r, t, s, a);
|
|
533
551
|
d.push(m);
|
|
534
552
|
}
|
|
535
553
|
return { canvases: d };
|
|
536
554
|
}
|
|
537
|
-
function
|
|
538
|
-
const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1),
|
|
539
|
-
let
|
|
555
|
+
function je(e, n = {}) {
|
|
556
|
+
const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), t = n.dpi ?? 96, r = t / 96 * U, s = n.fontFamily ?? '"Microsoft YaHei", sans-serif', a = n.measurer ?? J, o = n.overscan ?? 1, l = n.gapPx ?? 18, d = n.pagesPerFrame ?? 1, h = e.pages.map((f) => f.pageHeightMm * r), c = Math.max(1, ...e.pages.map((f) => f.pageWidthMm * r)), m = { start: 0, end: -1 };
|
|
557
|
+
let u = null, g = null, M = null, p = null, k = [], T = 0, E = [];
|
|
540
558
|
function w() {
|
|
541
|
-
const
|
|
542
|
-
|
|
543
|
-
const
|
|
544
|
-
for (let
|
|
545
|
-
const
|
|
546
|
-
|
|
559
|
+
const f = u;
|
|
560
|
+
f.innerHTML = "", g = document.createElement("div"), g.style.cssText = `width:${c}px;margin:0 auto;`, M = document.createElement("div"), p = document.createElement("div"), g.appendChild(M), k = [];
|
|
561
|
+
const b = Math.min(e.pages.length, 3 + o * 2);
|
|
562
|
+
for (let P = 0; P < b; P++) {
|
|
563
|
+
const y = document.createElement("div");
|
|
564
|
+
y.style.cssText = `margin:0 auto ${l}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, g.appendChild(y), k.push(y);
|
|
547
565
|
}
|
|
548
|
-
g.appendChild(p),
|
|
549
|
-
}
|
|
550
|
-
function
|
|
551
|
-
const
|
|
552
|
-
let A =
|
|
553
|
-
(!A || A.tagName !== "CANVAS") && (A = document.createElement("canvas"),
|
|
554
|
-
const
|
|
555
|
-
if (
|
|
556
|
-
|
|
557
|
-
for (const
|
|
558
|
-
|
|
559
|
-
A.dataset.canvasPage = String(
|
|
566
|
+
g.appendChild(p), f.appendChild(g);
|
|
567
|
+
}
|
|
568
|
+
function I(f, b) {
|
|
569
|
+
const P = e.pages[b], { widthPx: y, heightPx: x } = ie(P, t);
|
|
570
|
+
let A = f.firstElementChild;
|
|
571
|
+
(!A || A.tagName !== "CANVAS") && (A = document.createElement("canvas"), f.innerHTML = "", f.appendChild(A)), A.width = Math.round(y * i), A.height = Math.round(x * i), A.style.width = `${y}px`, A.style.height = `${x}px`;
|
|
572
|
+
const z = A.getContext("2d");
|
|
573
|
+
if (z) {
|
|
574
|
+
z.setTransform(1, 0, 0, 1, 0, 0), z.scale(i, i), z.fillStyle = "#ffffff", z.fillRect(0, 0, y, x);
|
|
575
|
+
for (const ae of P.components)
|
|
576
|
+
oe(z, ae, r, t, s, a);
|
|
577
|
+
A.dataset.canvasPage = String(b), f.style.height = `${x}px`, f.style.width = `${y}px`;
|
|
560
578
|
}
|
|
561
579
|
}
|
|
562
|
-
function R(
|
|
563
|
-
m.start =
|
|
564
|
-
const
|
|
565
|
-
p.style.height = `${
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
if (
|
|
569
|
-
|
|
570
|
-
const A =
|
|
571
|
-
|
|
580
|
+
function R(f) {
|
|
581
|
+
m.start = f.start, m.end = f.end, M.style.height = `${f.start * l + h.slice(0, f.start).reduce((y, x) => y + x, 0)}px`;
|
|
582
|
+
const b = e.pages.length - 1 - f.end;
|
|
583
|
+
p.style.height = `${b * l + h.slice(f.end + 1).reduce((y, x) => y + x, 0)}px`;
|
|
584
|
+
const P = f.end - f.start + 1;
|
|
585
|
+
k.forEach((y, x) => {
|
|
586
|
+
if (x < P) {
|
|
587
|
+
y.style.display = "";
|
|
588
|
+
const A = f.start + x;
|
|
589
|
+
y.style.height = `${h[A] ?? 0}px`;
|
|
572
590
|
} else
|
|
573
|
-
|
|
591
|
+
y.style.display = "none";
|
|
574
592
|
}), E = [];
|
|
575
|
-
for (let
|
|
576
|
-
const
|
|
577
|
-
if (!
|
|
578
|
-
|
|
593
|
+
for (let y = f.start; y <= f.end; y++) {
|
|
594
|
+
const x = k[y - f.start];
|
|
595
|
+
if (!x) continue;
|
|
596
|
+
x.firstElementChild?.dataset?.canvasPage !== String(y) && E.push(y);
|
|
579
597
|
}
|
|
580
|
-
|
|
581
|
-
}
|
|
582
|
-
function
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
let
|
|
586
|
-
for (; E.length > 0 &&
|
|
587
|
-
const
|
|
588
|
-
|
|
598
|
+
D();
|
|
599
|
+
}
|
|
600
|
+
function D() {
|
|
601
|
+
T || E.length === 0 || (T = requestAnimationFrame(() => {
|
|
602
|
+
T = 0;
|
|
603
|
+
let f = Math.max(1, d);
|
|
604
|
+
for (; E.length > 0 && f-- > 0; ) {
|
|
605
|
+
const b = E.shift(), P = k[b - m.start];
|
|
606
|
+
P && I(P, b);
|
|
589
607
|
}
|
|
590
|
-
E.length > 0 &&
|
|
608
|
+
E.length > 0 && D();
|
|
591
609
|
}));
|
|
592
610
|
}
|
|
593
|
-
function
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
const
|
|
611
|
+
function $() {
|
|
612
|
+
T || (T = requestAnimationFrame(() => {
|
|
613
|
+
T = 0;
|
|
614
|
+
const f = u, b = Pe({
|
|
597
615
|
pageHeightsPx: h,
|
|
598
|
-
viewportHeightPx:
|
|
599
|
-
scrollTopPx:
|
|
616
|
+
viewportHeightPx: f.clientHeight,
|
|
617
|
+
scrollTopPx: f.scrollTop,
|
|
600
618
|
overscan: o,
|
|
601
|
-
gapPx:
|
|
619
|
+
gapPx: l
|
|
602
620
|
});
|
|
603
|
-
|
|
621
|
+
b.start !== m.start || b.end !== m.end ? R(b) : D();
|
|
604
622
|
}));
|
|
605
623
|
}
|
|
624
|
+
let B = null;
|
|
606
625
|
return {
|
|
607
|
-
attach(
|
|
608
|
-
|
|
626
|
+
attach(f) {
|
|
627
|
+
if (typeof document > "u")
|
|
628
|
+
throw new Error("createCanvasPager 需要浏览器环境(SSR 请在客户端钩子中调用 attach)");
|
|
629
|
+
u = f, w(), f.addEventListener("scroll", $, { passive: !0 }), typeof ResizeObserver < "u" && (B = new ResizeObserver(() => $()), B.observe(f)), $();
|
|
609
630
|
},
|
|
610
631
|
destroy() {
|
|
611
|
-
|
|
632
|
+
T && cancelAnimationFrame(T), T = 0, B?.disconnect(), B = null, u?.removeEventListener("scroll", $), E = [], g?.remove(), u = null;
|
|
612
633
|
},
|
|
613
634
|
window() {
|
|
614
635
|
return { ...m };
|
|
615
636
|
}
|
|
616
637
|
};
|
|
617
638
|
}
|
|
618
|
-
function
|
|
619
|
-
return typeof
|
|
639
|
+
function S(e, n) {
|
|
640
|
+
return typeof e == "number" && Number.isFinite(e) ? e : n;
|
|
620
641
|
}
|
|
621
|
-
function
|
|
622
|
-
return typeof
|
|
642
|
+
function v(e, n = "") {
|
|
643
|
+
return typeof e == "string" ? e : n;
|
|
623
644
|
}
|
|
624
|
-
function
|
|
625
|
-
return typeof
|
|
645
|
+
function N(e) {
|
|
646
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
626
647
|
}
|
|
627
|
-
function
|
|
628
|
-
return
|
|
648
|
+
function $e(e) {
|
|
649
|
+
return e === "Center" ? "center" : e === "Right" ? "right" : "left";
|
|
629
650
|
}
|
|
630
|
-
function
|
|
631
|
-
return
|
|
651
|
+
function He(e) {
|
|
652
|
+
return e === "Center" ? "middle" : e === "Bottom" ? "bottom" : "top";
|
|
632
653
|
}
|
|
633
|
-
function
|
|
634
|
-
const n = parseFloat(
|
|
654
|
+
function Re(e) {
|
|
655
|
+
const n = parseFloat(v(e.FontSize, "10.5"));
|
|
635
656
|
return {
|
|
636
657
|
fontSize: Number.isFinite(n) ? n : 10.5,
|
|
637
|
-
fontFamily:
|
|
638
|
-
bold:
|
|
639
|
-
italic:
|
|
640
|
-
underline:
|
|
641
|
-
color:
|
|
642
|
-
backgroundColor:
|
|
643
|
-
align:
|
|
644
|
-
verticalAlign:
|
|
658
|
+
fontFamily: v(e.FontFamily, "黑体") || void 0,
|
|
659
|
+
bold: v(e.FontWeight) === "bold" || void 0,
|
|
660
|
+
italic: v(e.FontStyle) === "italic" || void 0,
|
|
661
|
+
underline: e.Underline === !0 || void 0,
|
|
662
|
+
color: v(e.FontColor) || void 0,
|
|
663
|
+
backgroundColor: v(e.BackgroundColor) || void 0,
|
|
664
|
+
align: $e(v(e.HorAlignment, "Left")),
|
|
665
|
+
verticalAlign: He(v(e.VertAlignment, "Top")),
|
|
645
666
|
lineHeight: (() => {
|
|
646
|
-
const i = parseFloat(
|
|
667
|
+
const i = parseFloat(v(e.RowSpace, "1"));
|
|
647
668
|
return Number.isFinite(i) && i !== 1 ? i : void 0;
|
|
648
669
|
})(),
|
|
649
|
-
borderColor:
|
|
650
|
-
borderTop:
|
|
651
|
-
borderRight:
|
|
652
|
-
borderBottom:
|
|
653
|
-
borderLeft:
|
|
670
|
+
borderColor: v(e.BorderColor) || void 0,
|
|
671
|
+
borderTop: e.BorderTop !== !1,
|
|
672
|
+
borderRight: e.BorderRight !== !1,
|
|
673
|
+
borderBottom: e.BorderBottom !== !1,
|
|
674
|
+
borderLeft: e.BorderLeft !== !1
|
|
654
675
|
};
|
|
655
676
|
}
|
|
656
|
-
function
|
|
657
|
-
const i =
|
|
677
|
+
function Be(e, n) {
|
|
678
|
+
const i = v(e.uitype), t = {
|
|
658
679
|
kind: "text",
|
|
659
|
-
leftMm:
|
|
660
|
-
topMm:
|
|
661
|
-
widthMm:
|
|
662
|
-
heightMm:
|
|
663
|
-
nid:
|
|
664
|
-
style:
|
|
680
|
+
leftMm: S(e.left, 0),
|
|
681
|
+
topMm: S(e.top, 0),
|
|
682
|
+
widthMm: S(e.width, 40),
|
|
683
|
+
heightMm: S(e.height, 8),
|
|
684
|
+
nid: v(e.nid) || void 0,
|
|
685
|
+
style: Re(e)
|
|
665
686
|
};
|
|
666
687
|
switch (i) {
|
|
667
688
|
case "text": {
|
|
668
|
-
|
|
669
|
-
const r =
|
|
670
|
-
|
|
671
|
-
const
|
|
672
|
-
return Array.isArray(
|
|
689
|
+
t.kind = "text";
|
|
690
|
+
const r = e.Text ?? e.text ?? e.Value;
|
|
691
|
+
t.text = r == null ? "" : String(r);
|
|
692
|
+
const s = e.Lines ?? e.lines;
|
|
693
|
+
return Array.isArray(s) && (t.lines = s.map((a) => String(a))), t;
|
|
673
694
|
}
|
|
674
695
|
case "richtext":
|
|
675
|
-
return
|
|
696
|
+
return t.kind = "text", t.text = v(e.Text), n.push(`富文本 ${t.nid ?? ""} 导入为纯文本(版式细节可能损失)`), t;
|
|
676
697
|
case "image":
|
|
677
698
|
case "barcode":
|
|
678
699
|
case "qrcode":
|
|
679
700
|
case "chart":
|
|
680
|
-
return
|
|
701
|
+
return t.kind = i === "image" ? "image" : i, t.fallbackText = `[${i}]`, n.push(`图片类组件 ${t.nid ?? ""} 需运行时数据(imageData),已导入为占位`), t;
|
|
681
702
|
case "table": {
|
|
682
|
-
|
|
683
|
-
const r =
|
|
703
|
+
t.kind = "rect";
|
|
704
|
+
const r = e.Cells ?? e.cells;
|
|
684
705
|
if (Array.isArray(r)) {
|
|
685
|
-
const
|
|
706
|
+
const s = {
|
|
686
707
|
cells: r.map(
|
|
687
708
|
(a) => Array.isArray(a) ? a.map((o) => ({
|
|
688
|
-
text:
|
|
689
|
-
colSpan:
|
|
709
|
+
text: N(o) ? v(o.Text ?? o.text) : "",
|
|
710
|
+
colSpan: N(o) ? S(o.ColSpan, 1) : 1
|
|
690
711
|
})) : []
|
|
691
712
|
)
|
|
692
713
|
};
|
|
693
|
-
|
|
714
|
+
t.grid = s;
|
|
694
715
|
} else
|
|
695
|
-
|
|
696
|
-
return
|
|
716
|
+
t.fallbackText = "[table]", n.push(`表格 ${t.nid ?? ""} 缺少 Cells,导入为空框`);
|
|
717
|
+
return t;
|
|
697
718
|
}
|
|
698
719
|
case "subreport":
|
|
699
|
-
return n.push(`子报表 ${
|
|
720
|
+
return n.push(`子报表 ${t.nid ?? ""} 暂不支持导入,已跳过`), null;
|
|
700
721
|
default:
|
|
701
|
-
return
|
|
722
|
+
return v(e.ShapeType) === "hline" || i === "hline" || i === "vline" ? (t.kind = "line", t) : i === "rect" || i === "oval" || i === "shape" ? (t.kind = i === "oval" ? "ellipse" : "rect", t) : (n.push(`未知组件类型 ${i},已跳过`), null);
|
|
702
723
|
}
|
|
703
724
|
}
|
|
704
|
-
function
|
|
725
|
+
function Ge(e) {
|
|
705
726
|
const n = [];
|
|
706
727
|
let i = null;
|
|
707
|
-
if (typeof
|
|
728
|
+
if (typeof e == "string")
|
|
708
729
|
try {
|
|
709
|
-
const d = JSON.parse(
|
|
710
|
-
|
|
730
|
+
const d = JSON.parse(e);
|
|
731
|
+
N(d) && (i = d);
|
|
711
732
|
} catch {
|
|
712
733
|
return {
|
|
713
734
|
template: { pages: [] },
|
|
714
735
|
warnings: ["content 不是合法 JSON"]
|
|
715
736
|
};
|
|
716
737
|
}
|
|
717
|
-
else
|
|
738
|
+
else N(e) && (i = e);
|
|
718
739
|
if (!i)
|
|
719
740
|
return { template: { pages: [] }, warnings: ["content 为空"] };
|
|
720
|
-
const
|
|
721
|
-
top:
|
|
722
|
-
bottom:
|
|
723
|
-
left:
|
|
724
|
-
right:
|
|
725
|
-
}, o = Array.isArray(i.children) ? i.children.filter((d) =>
|
|
741
|
+
const t = N(i.GlobalConfig) ? i.GlobalConfig : {}, r = S(t.paperWidthMm, 210), s = S(t.paperHeightMm, 297), a = {
|
|
742
|
+
top: S(t.marginTop, 10),
|
|
743
|
+
bottom: S(t.marginBottom, 10),
|
|
744
|
+
left: S(t.marginLeft, 10),
|
|
745
|
+
right: S(t.marginRight, 10)
|
|
746
|
+
}, o = Array.isArray(i.children) ? i.children.filter((d) => N(d) && v(d.uitype) === "page") : [];
|
|
726
747
|
o.length === 0 && n.push("content 中没有 uitype=page 的页节点");
|
|
727
|
-
const
|
|
748
|
+
const l = o.map((d) => {
|
|
728
749
|
const h = d, c = Array.isArray(h.children) ? h.children : [], m = [];
|
|
729
|
-
for (const
|
|
730
|
-
if (!
|
|
731
|
-
const g =
|
|
750
|
+
for (const u of c) {
|
|
751
|
+
if (!N(u)) continue;
|
|
752
|
+
const g = Be(u, n);
|
|
732
753
|
g && m.push(g);
|
|
733
754
|
}
|
|
734
755
|
return {
|
|
735
|
-
widthMm:
|
|
736
|
-
heightMm:
|
|
737
|
-
marginTopMm:
|
|
738
|
-
marginBottomMm:
|
|
739
|
-
marginLeftMm:
|
|
740
|
-
marginRightMm:
|
|
756
|
+
widthMm: S(h.width, r),
|
|
757
|
+
heightMm: S(h.DesignHeight, s),
|
|
758
|
+
marginTopMm: S(h.MarginTop, a.top),
|
|
759
|
+
marginBottomMm: S(h.MarginBottom, a.bottom),
|
|
760
|
+
marginLeftMm: S(h.MarginLeft, a.left),
|
|
761
|
+
marginRightMm: S(h.MarginRight, a.right),
|
|
741
762
|
components: m
|
|
742
763
|
};
|
|
743
764
|
});
|
|
744
|
-
return
|
|
765
|
+
return l.length === 0 && (n.push("转换结果为空页,已回退一张空白页"), l.push({
|
|
745
766
|
widthMm: r,
|
|
746
|
-
heightMm:
|
|
767
|
+
heightMm: s,
|
|
747
768
|
...a,
|
|
748
769
|
components: []
|
|
749
|
-
})), { template: { pages:
|
|
750
|
-
}
|
|
751
|
-
function
|
|
752
|
-
let
|
|
753
|
-
if (typeof
|
|
754
|
-
const
|
|
755
|
-
if (!
|
|
756
|
-
|
|
757
|
-
} else typeof
|
|
758
|
-
return i ? { widthMm: r, heightMm:
|
|
759
|
-
}
|
|
760
|
-
class
|
|
770
|
+
})), { template: { pages: l }, warnings: n };
|
|
771
|
+
}
|
|
772
|
+
function Ne(e, n, i) {
|
|
773
|
+
let t, r;
|
|
774
|
+
if (typeof e == "string") {
|
|
775
|
+
const s = K[e];
|
|
776
|
+
if (!s) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(K).join("/")})`);
|
|
777
|
+
t = s.widthMm, r = s.heightMm;
|
|
778
|
+
} else typeof e == "number" ? (t = e, r = n ?? 297) : (t = e.widthMm, r = e.heightMm);
|
|
779
|
+
return i ? { widthMm: r, heightMm: t } : { widthMm: t, heightMm: r };
|
|
780
|
+
}
|
|
781
|
+
class Le {
|
|
761
782
|
constructor() {
|
|
762
783
|
this.pages = [], this.pending = null;
|
|
763
784
|
}
|
|
@@ -767,20 +788,20 @@ class Nt {
|
|
|
767
788
|
* - 数字:.page(210, 297)(第三参数兼容旧 margins 对象或新 options)
|
|
768
789
|
* - 对象:.page({ widthMm: 210, heightMm: 297 })
|
|
769
790
|
*/
|
|
770
|
-
page(n = "a4", i = {},
|
|
791
|
+
page(n = "a4", i = {}, t) {
|
|
771
792
|
this.collect();
|
|
772
|
-
const
|
|
793
|
+
const s = t != null && !("margins" in t) && !("landscape" in t) && ("marginTopMm" in t || "marginBottomMm" in t || "marginLeftMm" in t || "marginRightMm" in t) ? { margins: t } : t ?? {}, { widthMm: a, heightMm: o } = Ne(
|
|
773
794
|
n,
|
|
774
795
|
typeof i == "number" ? i : void 0,
|
|
775
|
-
|
|
776
|
-
),
|
|
777
|
-
return this.pending = new
|
|
796
|
+
s.landscape
|
|
797
|
+
), l = s.margins ?? {};
|
|
798
|
+
return this.pending = new ze(this, {
|
|
778
799
|
widthMm: a,
|
|
779
800
|
heightMm: o,
|
|
780
|
-
marginTopMm:
|
|
781
|
-
marginBottomMm:
|
|
782
|
-
marginLeftMm:
|
|
783
|
-
marginRightMm:
|
|
801
|
+
marginTopMm: l.marginTopMm ?? 10,
|
|
802
|
+
marginBottomMm: l.marginBottomMm ?? 10,
|
|
803
|
+
marginLeftMm: l.marginLeftMm ?? 10,
|
|
804
|
+
marginRightMm: l.marginRightMm ?? 10
|
|
784
805
|
}), this.pending;
|
|
785
806
|
}
|
|
786
807
|
collect() {
|
|
@@ -792,11 +813,11 @@ class Nt {
|
|
|
792
813
|
return { pages: this.pages };
|
|
793
814
|
}
|
|
794
815
|
}
|
|
795
|
-
class
|
|
816
|
+
class ze {
|
|
796
817
|
constructor(n, i) {
|
|
797
818
|
this.parent = n, this.page = i, this.components = [];
|
|
798
819
|
}
|
|
799
|
-
text(n, i = {},
|
|
820
|
+
text(n, i = {}, t = {}) {
|
|
800
821
|
return this.components.push({
|
|
801
822
|
kind: "text",
|
|
802
823
|
leftMm: i.leftMm ?? 0,
|
|
@@ -804,29 +825,29 @@ class Lt {
|
|
|
804
825
|
widthMm: i.widthMm ?? 60,
|
|
805
826
|
heightMm: i.heightMm ?? 8,
|
|
806
827
|
text: n,
|
|
807
|
-
style:
|
|
828
|
+
style: t
|
|
808
829
|
}), this;
|
|
809
830
|
}
|
|
810
|
-
list(n, i,
|
|
831
|
+
list(n, i, t, r = {}) {
|
|
811
832
|
return this.components.push({
|
|
812
833
|
kind: "list",
|
|
813
834
|
leftMm: i.leftMm ?? 10,
|
|
814
835
|
topMm: i.topMm ?? 30,
|
|
815
836
|
widthMm: i.widthMm ?? 180,
|
|
816
837
|
dataset: n,
|
|
817
|
-
columns:
|
|
838
|
+
columns: t,
|
|
818
839
|
...r
|
|
819
840
|
}), this;
|
|
820
841
|
}
|
|
821
842
|
rect(n, i = {}) {
|
|
822
843
|
return this.components.push({ kind: "rect", ...n, style: i }), this;
|
|
823
844
|
}
|
|
824
|
-
line(n, i,
|
|
845
|
+
line(n, i, t, r = {}) {
|
|
825
846
|
return this.components.push({
|
|
826
847
|
kind: "line",
|
|
827
848
|
leftMm: n,
|
|
828
849
|
topMm: i,
|
|
829
|
-
widthMm:
|
|
850
|
+
widthMm: t,
|
|
830
851
|
heightMm: 0.5,
|
|
831
852
|
style: r
|
|
832
853
|
}), this;
|
|
@@ -841,10 +862,10 @@ class Lt {
|
|
|
841
862
|
fallbackText: n
|
|
842
863
|
}), this;
|
|
843
864
|
}
|
|
844
|
-
qrcode(n, i,
|
|
865
|
+
qrcode(n, i, t, r) {
|
|
845
866
|
return this.components.push({
|
|
846
867
|
kind: "qrcode",
|
|
847
|
-
leftMm:
|
|
868
|
+
leftMm: t,
|
|
848
869
|
topMm: r,
|
|
849
870
|
widthMm: i,
|
|
850
871
|
heightMm: i,
|
|
@@ -861,59 +882,59 @@ class Lt {
|
|
|
861
882
|
return this.done().build();
|
|
862
883
|
}
|
|
863
884
|
}
|
|
864
|
-
function
|
|
865
|
-
return new
|
|
885
|
+
function Ve() {
|
|
886
|
+
return new Le();
|
|
866
887
|
}
|
|
867
888
|
export {
|
|
868
|
-
|
|
869
|
-
|
|
889
|
+
Ue as CSS_DPI,
|
|
890
|
+
Ke as DEFAULT_BORDER_PT,
|
|
870
891
|
j as DEFAULT_FONT_PT,
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
892
|
+
Ye as DEFAULT_STROKE_COLOR,
|
|
893
|
+
me as DEFAULT_TEXT_COLOR,
|
|
894
|
+
q as LINE_HEIGHT,
|
|
895
|
+
Xe as MM_PER_INCH,
|
|
896
|
+
K as PAPER_SIZES,
|
|
897
|
+
ze as PageBuilder,
|
|
898
|
+
se as RENDER_PLAN_SCHEMA_VERSION,
|
|
899
|
+
Ze as SCHEMA_VERSION_JH4J,
|
|
900
|
+
Qe as SCHEMA_VERSION_LOCAL,
|
|
901
|
+
et as SCHEMA_VERSION_MACH,
|
|
902
|
+
Le as TemplateBuilder,
|
|
903
|
+
_e as assertRenderPlan,
|
|
904
|
+
tt as charWidthEm,
|
|
905
|
+
C as classOf,
|
|
906
|
+
Pe as computePageWindow,
|
|
907
|
+
nt as createCanvasMeasurer,
|
|
908
|
+
je as createCanvasPager,
|
|
909
|
+
it as createHeuristicMeasurer,
|
|
910
|
+
Ve as createTemplate,
|
|
911
|
+
J as heuristicMeasurer,
|
|
912
|
+
Ge as importJh4jTemplateContent,
|
|
913
|
+
le as isImageBackedComponent,
|
|
914
|
+
Z as isRichText,
|
|
915
|
+
ie as measurePageSizePx,
|
|
916
|
+
rt as measureTextMm,
|
|
917
|
+
de as mmToPx,
|
|
918
|
+
ot as mmToPxFactor,
|
|
919
|
+
We as paginateTemplate,
|
|
920
|
+
De as planFontSizePx,
|
|
921
|
+
O as ptToPx,
|
|
922
|
+
at as pxToMm,
|
|
923
|
+
ne as renderComponent,
|
|
924
|
+
xe as renderPage,
|
|
925
|
+
Ie as renderPlan,
|
|
926
|
+
Oe as renderPlanToCanvas,
|
|
927
|
+
V as resolveBoxBorders,
|
|
928
|
+
W as resolveFontSize,
|
|
929
|
+
ce as resolveGridLayout,
|
|
930
|
+
he as resolveLineHeight,
|
|
931
|
+
Ne as resolvePaper,
|
|
932
|
+
F as resolveStroke,
|
|
933
|
+
Q as resolveTextColor,
|
|
934
|
+
_ as round,
|
|
935
|
+
st as toRenderPlan,
|
|
936
|
+
ee as validateComponent,
|
|
937
|
+
ue as validatePage,
|
|
938
|
+
pe as validateRenderPlan,
|
|
939
|
+
G as wrapText
|
|
919
940
|
};
|