@agile-team/mach-report 0.5.0 → 0.6.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.
Files changed (71) hide show
  1. package/dist/ReportPreview-DWLjYi_p.js +527 -0
  2. package/dist/ReportPreview-rBtmbu3W.cjs +6 -0
  3. package/dist/_commonjsHelpers-DKOUU3wS.cjs +1 -0
  4. package/dist/_commonjsHelpers-DaMA6jEr.js +8 -0
  5. package/dist/builder/template-builder.d.ts +53 -0
  6. package/dist/compat/jh4j-template.d.ts +12 -0
  7. package/dist/defaults.d.ts +27 -0
  8. package/dist/index.cjs +6 -1663
  9. package/dist/index.d.cts +13 -344
  10. package/dist/index.d.ts +13 -344
  11. package/dist/index.js +727 -1419
  12. package/dist/layout/paginate.d.ts +51 -0
  13. package/dist/layout/textwrap.d.ts +36 -0
  14. package/dist/manager/api.d.ts +45 -0
  15. package/dist/manager/index.d.ts +2 -0
  16. package/dist/manager/types.d.ts +50 -0
  17. package/dist/manager.cjs +1 -122
  18. package/dist/manager.d.cts +5 -97
  19. package/dist/manager.d.ts +5 -97
  20. package/dist/manager.js +66 -81
  21. package/dist/pdf/font-loader.d.ts +5 -0
  22. package/dist/pdf/index.d.ts +2 -0
  23. package/dist/pdf/render-pdf.d.ts +25 -0
  24. package/dist/pdf.cjs +84 -52530
  25. package/dist/pdf.d.cts +4 -31
  26. package/dist/pdf.d.ts +4 -31
  27. package/dist/pdf.js +22843 -39218
  28. package/dist/plugin-BIJxGHZX.cjs +1 -0
  29. package/dist/plugin-DrV67_VW.js +89 -0
  30. package/dist/render/canvas.d.ts +61 -0
  31. package/dist/render/dom.d.ts +10 -0
  32. package/dist/render/grid-geometry.d.ts +41 -0
  33. package/dist/render/style.d.ts +33 -0
  34. package/dist/render/window.d.ts +23 -0
  35. package/dist/schema/render-plan.d.ts +96 -0
  36. package/dist/schema/validate.d.ts +15 -0
  37. package/dist/sql/ast-check.d.ts +14 -0
  38. package/dist/sql/compile.d.ts +31 -0
  39. package/dist/sql/expr.d.ts +21 -0
  40. package/dist/sql/index.d.ts +4 -0
  41. package/dist/sql/tokenizer.d.ts +25 -0
  42. package/dist/sql.cjs +68 -45207
  43. package/dist/sql.d.cts +3 -93
  44. package/dist/sql.d.ts +3 -93
  45. package/dist/sql.js +37213 -41613
  46. package/dist/style-B3vxGDZd.cjs +3 -0
  47. package/dist/style-B7Xfo5I-.js +255 -0
  48. package/dist/style.css +1 -0
  49. package/dist/units.d.ts +11 -0
  50. package/dist/vue/ReportPreview.d.ts +141 -0
  51. package/dist/vue/ReportToolbar.d.ts +25 -0
  52. package/dist/vue/adapters.d.ts +37 -0
  53. package/dist/vue/async.d.cts +146 -0
  54. package/dist/vue/async.d.ts +146 -0
  55. package/dist/vue/composables/usePageWindow.d.ts +28 -0
  56. package/dist/vue/composables/usePrintExport.d.ts +19 -0
  57. package/dist/vue/composables/useZoom.d.ts +15 -0
  58. package/dist/vue/config.d.ts +79 -0
  59. package/dist/vue/index.d.cts +11 -0
  60. package/dist/vue/index.d.ts +11 -0
  61. package/dist/vue/injection-keys.d.ts +12 -0
  62. package/dist/vue/local-adapter.d.ts +12 -0
  63. package/dist/vue/pdf-exporter.d.ts +13 -0
  64. package/dist/vue/plugin.d.ts +34 -0
  65. package/dist/vue-async.cjs +1 -0
  66. package/dist/vue-async.js +17 -0
  67. package/dist/vue.cjs +1 -0
  68. package/dist/vue.js +44 -0
  69. package/package.json +44 -6
  70. package/dist/textwrap-DWzM7pt1.d.cts +0 -135
  71. package/dist/textwrap-DWzM7pt1.d.ts +0 -135
@@ -0,0 +1,527 @@
1
+ import { ref as C, computed as g, defineComponent as re, openBlock as w, createElementBlock as b, createElementVNode as M, toDisplayString as x, Fragment as ae, createCommentVNode as T, normalizeClass as G, inject as j, provide as Pe, useCssVars as ye, shallowRef as xe, watchEffect as Ee, onMounted as Me, onUnmounted as $e, watch as te, normalizeStyle as H, createVNode as Re, unref as c, createTextVNode as ke, renderList as Ce } from "vue";
2
+ import { computePageWindow as Fe, renderPage as se, validateRenderPlan as Be } from "@agile-team/mach-report";
3
+ import { M as q, a as Te, b as We, n as ze, c as Se } from "./plugin-DrV67_VW.js";
4
+ function He(e, o, n = {}) {
5
+ const t = n.pxPerMm ?? 3.7795275590551185, r = n.gapPx ?? 18, s = C(0), u = C(800), f = g(
6
+ () => (e.value?.pages ?? []).map((a) => a.pageHeightMm * t)
7
+ ), R = g(() => {
8
+ const a = e.value?.pages ?? [];
9
+ let p = 0, d = 0;
10
+ for (const h of a)
11
+ p += h.pageHeightMm * t + r, d = Math.max(d, h.pageWidthMm * t);
12
+ return { w: d, h: p };
13
+ }), i = g(
14
+ () => Fe({
15
+ pageHeightsPx: f.value,
16
+ viewportHeightPx: u.value / o.value,
17
+ scrollTopPx: s.value / o.value,
18
+ overscan: 1,
19
+ gapPx: r
20
+ })
21
+ ), l = g(() => {
22
+ const a = e.value;
23
+ if (!a) return [];
24
+ const { start: p, end: d } = i.value;
25
+ return d < p ? [] : a.pages.slice(p, d + 1).map((h, $) => ({ page: h, index: p + $ }));
26
+ });
27
+ function v(a, p) {
28
+ let d = 0;
29
+ return (h) => {
30
+ d || (d = requestAnimationFrame(() => {
31
+ if (d = 0, s.value = h.scrollTop, u.value = h.clientHeight || 800, p.value <= 0) return;
32
+ const $ = h.querySelectorAll(".mrp-page-holder");
33
+ if (!$.length) return;
34
+ const D = h.getBoundingClientRect().top + 56;
35
+ let k = 1;
36
+ $.forEach((F) => {
37
+ F.getBoundingClientRect().top <= D && (k = Number(F.dataset.page ?? 1));
38
+ }), a.value = Math.max(1, Math.min(p.value, k));
39
+ }));
40
+ };
41
+ }
42
+ return {
43
+ pageHeightsPx: f,
44
+ contentSize: R,
45
+ windowRange: i,
46
+ visiblePages: l,
47
+ scrollTop: s,
48
+ viewportHeight: u,
49
+ makeScrollHandler: v,
50
+ refreshViewport(a) {
51
+ a && (u.value = a.clientHeight || 800);
52
+ }
53
+ };
54
+ }
55
+ function Le(e) {
56
+ const o = C(1), n = C("fit");
57
+ function t() {
58
+ requestAnimationFrame(() => {
59
+ const s = e();
60
+ !s || !s.viewport || (o.value = Math.min(
61
+ 1,
62
+ Math.max(0.3, (s.viewport.clientWidth - 48) / Math.max(1, s.pageWidthPx))
63
+ ));
64
+ });
65
+ }
66
+ function r(s) {
67
+ s === "fit" ? (n.value = "fit", t()) : (n.value = "raw", o.value = s / 100);
68
+ }
69
+ return { zoom: o, zoomMode: n, applyFitZoom: t, setZoom: r };
70
+ }
71
+ const oe = 8;
72
+ function ne() {
73
+ return new Promise((e) => setTimeout(e, 0));
74
+ }
75
+ function O(e) {
76
+ return `p${Math.round(e.pageWidthMm)}x${Math.round(e.pageHeightMm)}`;
77
+ }
78
+ function Z(e) {
79
+ const o = /* @__PURE__ */ new Map();
80
+ e.pages.forEach((u) => {
81
+ o.has(O(u)) || o.set(O(u), u);
82
+ });
83
+ const r = `<!doctype html><html><head><meta charset="utf-8"><style>${`.mr-page{margin:0 auto;page-break-after:always;}
84
+ .mr-page tr{break-inside:avoid;page-break-inside:avoid;}
85
+ .mr-comp{break-inside:avoid;page-break-inside:avoid;}
86
+ ${[...o.values()].map(
87
+ (u) => `@page ${O(u)}{size:${Math.round(u.pageWidthMm)}mm ${Math.round(u.pageHeightMm)}mm;margin:0;}`
88
+ ).join(`
89
+ `)}
90
+ body{margin:0;background:#fff;}`}</style></head><body>`, s = e.pages.map((u) => {
91
+ const f = se(u, 96, {}, document);
92
+ return f.style.page = O(u), f.outerHTML;
93
+ });
94
+ return { head: r, pageChunks: s };
95
+ }
96
+ function Ae(e, o) {
97
+ let n = null;
98
+ function t() {
99
+ n?.remove(), n = null;
100
+ }
101
+ function r(i, l) {
102
+ const v = URL.createObjectURL(i), a = document.createElement("a");
103
+ a.href = v, a.download = l, a.click(), setTimeout(() => URL.revokeObjectURL(v), 1e4);
104
+ }
105
+ async function s() {
106
+ const i = e.value;
107
+ if (!i || i.pages.length === 0) return;
108
+ t();
109
+ const { head: l, pageChunks: v } = Z(i);
110
+ n = document.createElement("iframe"), n.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(n);
111
+ const a = n;
112
+ try {
113
+ const p = a.contentDocument;
114
+ p.open(), p.write(l);
115
+ for (let d = 0; d < v.length; d++)
116
+ if (p.write(v[d]), d % oe === oe - 1 && await ne(), a !== n) return;
117
+ p.write("</body></html>"), p.close(), await ne(), a.contentWindow?.focus(), a.contentWindow?.print();
118
+ } catch {
119
+ o.onError("调用打印失败,请改用导出 PDF");
120
+ }
121
+ }
122
+ async function u() {
123
+ const i = e.value;
124
+ if (!(!i || i.pages.length === 0))
125
+ try {
126
+ const l = await o.getPdfExporter()(i);
127
+ r(new Blob([l], { type: "application/pdf" }), "mach-report.pdf");
128
+ } catch (l) {
129
+ o.onError(l instanceof Error ? `PDF 导出失败: ${l.message}` : "PDF 导出失败");
130
+ }
131
+ }
132
+ function f(i) {
133
+ const l = e.value;
134
+ if (!l || l.pages.length === 0) return;
135
+ if (i === "pdf") {
136
+ u();
137
+ return;
138
+ }
139
+ const { head: v, pageChunks: a } = Z(l), p = `${v}${a.join("")}</body></html>`;
140
+ r(new Blob([p], { type: "text/html;charset=utf-8" }), `mach-report.${i === "html" ? "html" : i}`);
141
+ }
142
+ function R() {
143
+ const i = e.value;
144
+ if (!i || i.pages.length === 0) return;
145
+ const { head: l, pageChunks: v } = Z(i), a = `${l}${v.join("")}</body></html>`, p = new Blob([a], { type: "text/html;charset=utf-8" }), d = URL.createObjectURL(p), h = window.open(d, "_blank");
146
+ if (!h) {
147
+ o.onError("浏览器拦截了弹窗,请允许弹窗后重试"), URL.revokeObjectURL(d);
148
+ return;
149
+ }
150
+ setTimeout(() => h.print(), 400), setTimeout(() => URL.revokeObjectURL(d), 1e4);
151
+ }
152
+ return {
153
+ print: s,
154
+ exportAs: f,
155
+ openPdfWindow: R,
156
+ releasePrintFrame: t
157
+ };
158
+ }
159
+ const Ie = { class: "mrp-toolbar" }, Oe = { class: "mrp-title" }, Ue = ["disabled"], je = { class: "mrp-pageinfo" }, De = ["disabled"], Ve = /* @__PURE__ */ re({
160
+ __name: "ReportToolbar",
161
+ props: {
162
+ pageCount: {},
163
+ currentPage: {},
164
+ zoomMode: {},
165
+ zoom: {},
166
+ showExport: { type: Boolean },
167
+ showPrint: { type: Boolean },
168
+ showPdfWindow: { type: Boolean },
169
+ messages: {}
170
+ },
171
+ emits: ["goto", "zoom", "export", "print", "pdf-window"],
172
+ setup(e) {
173
+ function o(n, t, r) {
174
+ return n.replace("{cur}", String(t)).replace("{total}", String(r));
175
+ }
176
+ return (n, t) => (w(), b("div", Ie, [
177
+ M("span", Oe, x(e.messages.title), 1),
178
+ e.pageCount > 0 ? (w(), b(ae, { key: 0 }, [
179
+ M("button", {
180
+ class: "mrp-nav",
181
+ type: "button",
182
+ disabled: e.currentPage <= 1,
183
+ onClick: t[0] || (t[0] = (r) => n.$emit("goto", e.currentPage - 1))
184
+ }, x(e.messages.prevPage), 9, Ue),
185
+ M("span", je, x(o(e.messages.pageInfo, e.currentPage, e.pageCount)), 1),
186
+ M("button", {
187
+ class: "mrp-nav",
188
+ type: "button",
189
+ disabled: e.currentPage >= e.pageCount,
190
+ onClick: t[1] || (t[1] = (r) => n.$emit("goto", e.currentPage + 1))
191
+ }, x(e.messages.nextPage), 9, De)
192
+ ], 64)) : T("", !0),
193
+ t[9] || (t[9] = M("span", { class: "mrp-spacer" }, null, -1)),
194
+ M("button", {
195
+ class: G(["mrp-nav", { "mrp-active": e.zoomMode === "fit" }]),
196
+ type: "button",
197
+ onClick: t[2] || (t[2] = (r) => n.$emit("zoom", "fit"))
198
+ }, x(e.messages.fitWidth), 3),
199
+ M("button", {
200
+ class: G(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 100 }]),
201
+ type: "button",
202
+ onClick: t[3] || (t[3] = (r) => n.$emit("zoom", 100))
203
+ }, " 100% ", 2),
204
+ M("button", {
205
+ class: G(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 150 }]),
206
+ type: "button",
207
+ onClick: t[4] || (t[4] = (r) => n.$emit("zoom", 150))
208
+ }, " 150% ", 2),
209
+ e.showExport ? (w(), b("button", {
210
+ key: 1,
211
+ class: "mrp-nav",
212
+ type: "button",
213
+ onClick: t[5] || (t[5] = (r) => n.$emit("export", "html"))
214
+ }, x(e.messages.exportHtml), 1)) : T("", !0),
215
+ e.showExport ? (w(), b("button", {
216
+ key: 2,
217
+ class: "mrp-nav",
218
+ type: "button",
219
+ onClick: t[6] || (t[6] = (r) => n.$emit("export", "pdf"))
220
+ }, x(e.messages.exportPdf), 1)) : T("", !0),
221
+ e.showPrint ? (w(), b("button", {
222
+ key: 3,
223
+ class: "mrp-nav",
224
+ type: "button",
225
+ onClick: t[7] || (t[7] = (r) => n.$emit("print"))
226
+ }, x(e.messages.print), 1)) : T("", !0),
227
+ e.showPdfWindow ? (w(), b("button", {
228
+ key: 4,
229
+ class: "mrp-nav",
230
+ type: "button",
231
+ onClick: t[8] || (t[8] = (r) => n.$emit("pdf-window"))
232
+ }, x(e.messages.pdfWindow), 1)) : T("", !0)
233
+ ]));
234
+ }
235
+ }), le = (e, o) => {
236
+ const n = e.__vccOpts || e;
237
+ for (const [t, r] of o)
238
+ n[t] = r;
239
+ return n;
240
+ }, Ne = /* @__PURE__ */ le(Ve, [["__scopeId", "data-v-2bfb2c61"]]), Ge = {
241
+ title: "报表预览",
242
+ prevPage: "‹ 上一页",
243
+ nextPage: "下一页 ›",
244
+ pageInfo: "{cur} / {total}",
245
+ fitWidth: "适宽",
246
+ exportHtml: "导出 HTML",
247
+ exportPdf: "导出 PDF",
248
+ print: "打印",
249
+ pdfWindow: "PDF 窗口",
250
+ loading: "报表渲染中…",
251
+ empty: "暂无预览数据",
252
+ errorPrefix: "",
253
+ retry: "重试"
254
+ }, Ze = {
255
+ shellBg: "#525659",
256
+ shellFg: "#e8e8e8",
257
+ toolbarBg: "#323639",
258
+ toolbarBorder: "#22252a",
259
+ toolbarFg: "#e8e8e8",
260
+ btnFg: "#cfcfcf",
261
+ btnBorder: "#4a4d52",
262
+ btnHoverBg: "#414549",
263
+ btnHoverFg: "#ffffff",
264
+ btnActiveBg: "#2d5fb8"
265
+ };
266
+ function at(e) {
267
+ return e;
268
+ }
269
+ function st(e) {
270
+ return e;
271
+ }
272
+ const L = {
273
+ showExport: !0,
274
+ showPrint: !0,
275
+ showPdfWindow: !0,
276
+ gapPx: 18,
277
+ pdfFontUrl: "/simhei.ttf"
278
+ };
279
+ function qe(e, o) {
280
+ const n = o ? e?.presets?.[o] : e?.defaultPreset ? e?.presets?.[e.defaultPreset] : void 0, t = { ...e?.defaults, ...n };
281
+ return {
282
+ showExport: t.showExport ?? L.showExport,
283
+ showPrint: t.showPrint ?? L.showPrint,
284
+ showPdfWindow: t.showPdfWindow ?? L.showPdfWindow,
285
+ gapPx: t.gapPx ?? L.gapPx,
286
+ pdfFontUrl: t.pdfFontUrl ?? L.pdfFontUrl,
287
+ theme: { ...Ze, ...t.theme },
288
+ messages: { ...Ge, ...t.messages }
289
+ };
290
+ }
291
+ function Ke(e) {
292
+ const o = {};
293
+ return e.shellBg != null && (o["--mrp-shell-bg"] = e.shellBg), e.shellFg != null && (o["--mrp-shell-fg"] = e.shellFg), e.toolbarBg != null && (o["--mrp-toolbar-bg"] = e.toolbarBg), e.toolbarBorder != null && (o["--mrp-toolbar-border"] = e.toolbarBorder), e.toolbarFg != null && (o["--mrp-toolbar-fg"] = e.toolbarFg), e.btnFg != null && (o["--mrp-btn-fg"] = e.btnFg), e.btnBorder != null && (o["--mrp-btn-border"] = e.btnBorder), e.btnHoverBg != null && (o["--mrp-btn-hover-bg"] = e.btnHoverBg), e.btnHoverFg != null && (o["--mrp-btn-hover-fg"] = e.btnHoverFg), e.btnActiveBg != null && (o["--mrp-btn-active-bg"] = e.btnActiveBg), o;
294
+ }
295
+ function lt(e) {
296
+ const o = j(q, null), n = g(() => {
297
+ const t = o?.value ?? null, r = "defaults" in e && "presets" in e ? e : { defaults: e, presets: {} };
298
+ return t ? {
299
+ defaults: { ...t.defaults, ...r.defaults },
300
+ presets: { ...t.presets, ...r.presets },
301
+ defaultPreset: r.defaultPreset ?? t.defaultPreset
302
+ } : r;
303
+ });
304
+ Pe(q, n);
305
+ }
306
+ function Ye() {
307
+ return j(q, g(() => null));
308
+ }
309
+ const Xe = {
310
+ key: 0,
311
+ class: "mrp-state"
312
+ }, Je = {
313
+ key: 1,
314
+ class: "mrp-state mrp-error"
315
+ }, Qe = {
316
+ key: 2,
317
+ class: "mrp-state"
318
+ }, _e = ["data-page"], U = 96 / 25.4, et = /* @__PURE__ */ re({
319
+ __name: "ReportPreview",
320
+ props: {
321
+ tempId: {
322
+ type: [String, Array],
323
+ default: null
324
+ },
325
+ furnitureTempId: { type: String, default: "" },
326
+ params: {
327
+ type: Object,
328
+ default: () => ({})
329
+ },
330
+ height: { type: String, default: "100vh" },
331
+ autoLoad: { type: Boolean, default: !0 },
332
+ /** 以下显隐/间距不传时走配置中心(preset > defaults > 内置缺省) */
333
+ showExport: { type: Boolean, default: void 0 },
334
+ showPrint: { type: Boolean, default: void 0 },
335
+ showPdfWindow: { type: Boolean, default: void 0 },
336
+ /** 页间距(px);不传走配置中心 */
337
+ gapPx: { type: Number, default: void 0 },
338
+ /** 工具栏/状态文案覆写(不传走配置中心 messages) */
339
+ messages: { type: Object, default: void 0 },
340
+ /** 启用的 preset 名(不传用配置中心 defaultPreset) */
341
+ preset: { type: String, default: void 0 },
342
+ fetcher: {
343
+ type: Function,
344
+ default: null
345
+ }
346
+ },
347
+ emits: ["loaded", "error"],
348
+ setup(e, { expose: o, emit: n }) {
349
+ ye((E) => ({
350
+ v1f6cf76a: v.value + "px"
351
+ }));
352
+ const t = e, r = n, s = xe(null), u = C(!1), f = C(""), R = C(1), i = C(null), l = C(null), v = g(() => Math.max(0, pe.value)), a = j(Te, null), d = j(We, null) ?? Se({ fontUrl: "/simhei.ttf" }), h = g(() => ze(t.tempId)), $ = g(() => s.value?.pages.length ?? 0), D = Ye(), k = g(() => qe(D.value, t.preset)), F = g(() => ({
353
+ ...k.value.messages,
354
+ ...t.messages
355
+ })), ie = g(() => t.showExport ?? k.value.showExport), ue = g(() => t.showPrint ?? k.value.showPrint), de = g(() => t.showPdfWindow ?? k.value.showPdfWindow), pe = g(() => t.gapPx ?? k.value.gapPx), ce = g(() => ({
356
+ height: t.height,
357
+ ...Ke(k.value.theme)
358
+ })), { zoom: W, zoomMode: fe, applyFitZoom: K, setZoom: me } = Le(() => ({
359
+ viewport: l.value,
360
+ pageWidthPx: (s.value?.pages[0]?.pageWidthMm ?? 210) * U
361
+ })), ge = He(s, W, {
362
+ pxPerMm: U,
363
+ gapPx: v.value
364
+ }), { contentSize: V, windowRange: A, visiblePages: ve, makeScrollHandler: he, refreshViewport: Y } = ge, we = he(R, $);
365
+ function N() {
366
+ s.value = null, R.value = 1;
367
+ }
368
+ let I = 0;
369
+ async function S() {
370
+ const E = ++I, P = t.fetcher ?? a;
371
+ if (h.value.length === 0) {
372
+ f.value = "缺少报表模板 ID", N(), r("error", f.value);
373
+ return;
374
+ }
375
+ if (!P) {
376
+ f.value = "未提供渲染数据源 fetcher", N(), r("error", f.value);
377
+ return;
378
+ }
379
+ u.value = !0, f.value = "", N();
380
+ try {
381
+ const m = await P({
382
+ tempIds: h.value,
383
+ furnitureTempId: t.furnitureTempId || void 0,
384
+ params: { ...t.params }
385
+ });
386
+ if (E !== I) return;
387
+ const y = Be(m);
388
+ if (!y.ok) {
389
+ const B = y.errors.slice(0, 3).map((z) => `${z.path}: ${z.message}`).join("; ");
390
+ throw new Error(`渲染计划校验失败(${y.errors.length} 处): ${B}`);
391
+ }
392
+ y.warnings.length > 0 && console.warn("[mach-report] 渲染计划告警:", y.warnings), s.value = m, R.value = 1, l.value && (l.value.scrollTop = 0), K(), r("loaded", m.pages.length);
393
+ } catch (m) {
394
+ if (E !== I) return;
395
+ f.value = m instanceof Error ? m.message : "预览加载失败", r("error", f.value);
396
+ } finally {
397
+ E === I && (u.value = !1);
398
+ }
399
+ }
400
+ function X(E) {
401
+ if ($.value <= 0) return;
402
+ const P = Math.max(1, Math.min($.value, E));
403
+ R.value = P;
404
+ const m = l.value;
405
+ if (!m) return;
406
+ let y = 0;
407
+ for (let B = 0; B < P - 1; B++)
408
+ y += (s.value?.pages[B]?.pageHeightMm ?? 0) * U + v.value;
409
+ m.scrollTop = y * W.value;
410
+ }
411
+ const { print: J, exportAs: Q, openPdfWindow: _, releasePrintFrame: be } = Ae(s, {
412
+ getPdfExporter: () => d,
413
+ onError: (E) => r("error", E)
414
+ });
415
+ Ee(() => {
416
+ const E = s.value;
417
+ if (!E) return;
418
+ const P = i.value;
419
+ if (!P) return;
420
+ P.querySelectorAll(".mrp-page-holder").forEach((y) => {
421
+ const B = Number(y.dataset.page ?? 0) - 1, z = E.pages[B];
422
+ !z || y.childElementCount > 0 || (y.style.width = `${z.pageWidthMm * U}px`, y.appendChild(se(z, 96, {}, document)));
423
+ });
424
+ }, { flush: "post" });
425
+ function ee() {
426
+ Y(l.value), K();
427
+ }
428
+ return Me(() => {
429
+ window.addEventListener("resize", ee), Y(l.value), t.autoLoad && S();
430
+ }), $e(() => {
431
+ window.removeEventListener("resize", ee), be();
432
+ }), te(
433
+ () => [t.tempId, t.furnitureTempId, JSON.stringify(t.params)],
434
+ () => {
435
+ t.autoLoad && S();
436
+ }
437
+ ), te(
438
+ () => t.fetcher ?? a,
439
+ () => {
440
+ t.autoLoad && S();
441
+ }
442
+ ), o({ reload: S, print: J, exportAs: Q, openPdfWindow: _, gotoPage: X }), (E, P) => (w(), b("div", {
443
+ class: "mach-report-preview",
444
+ style: H(ce.value)
445
+ }, [
446
+ Re(Ne, {
447
+ "page-count": $.value,
448
+ "current-page": R.value,
449
+ "zoom-mode": c(fe),
450
+ zoom: c(W),
451
+ "show-export": ie.value,
452
+ "show-print": ue.value,
453
+ "show-pdf-window": de.value,
454
+ messages: F.value,
455
+ onGoto: X,
456
+ onZoom: c(me),
457
+ onExport: P[0] || (P[0] = (m) => c(Q)(m)),
458
+ onPrint: c(J),
459
+ onPdfWindow: c(_)
460
+ }, null, 8, ["page-count", "current-page", "zoom-mode", "zoom", "show-export", "show-print", "show-pdf-window", "messages", "onZoom", "onPrint", "onPdfWindow"]),
461
+ M("div", {
462
+ ref_key: "viewportRef",
463
+ ref: l,
464
+ class: "mrp-body",
465
+ onScrollPassive: P[1] || (P[1] = (m) => c(we)(m.target))
466
+ }, [
467
+ u.value ? (w(), b("div", Xe, x(F.value.loading), 1)) : f.value ? (w(), b("div", Je, [
468
+ ke(x(f.value) + " ", 1),
469
+ M("button", {
470
+ class: "mrp-retry",
471
+ type: "button",
472
+ onClick: S
473
+ }, x(F.value.retry), 1)
474
+ ])) : !s.value || $.value === 0 ? (w(), b("div", Qe, x(F.value.empty), 1)) : (w(), b("div", {
475
+ key: 3,
476
+ class: "mrp-scale",
477
+ style: H({ width: `${c(V).w * c(W)}px`, height: `${c(V).h * c(W)}px` })
478
+ }, [
479
+ M("div", {
480
+ ref_key: "containerRef",
481
+ ref: i,
482
+ class: "mrp-scale-inner",
483
+ style: H({ transform: `scale(${c(W)})`, transformOrigin: "top left", width: `${c(V).w}px` })
484
+ }, [
485
+ c(A).padTopPx > 0 ? (w(), b("div", {
486
+ key: 0,
487
+ class: "mrp-spacer-top",
488
+ style: H({ height: `${c(A).padTopPx}px` }),
489
+ "aria-hidden": "true"
490
+ }, null, 4)) : T("", !0),
491
+ (w(!0), b(ae, null, Ce(c(ve), (m) => (w(), b("div", {
492
+ key: m.index,
493
+ class: "mrp-page-holder",
494
+ "data-page": m.index + 1
495
+ }, null, 8, _e))), 128)),
496
+ c(A).padBottomPx > 0 ? (w(), b("div", {
497
+ key: 1,
498
+ class: "mrp-spacer-bottom",
499
+ style: H({ height: `${c(A).padBottomPx}px` }),
500
+ "aria-hidden": "true"
501
+ }, null, 4)) : T("", !0)
502
+ ], 4)
503
+ ], 4))
504
+ ], 544)
505
+ ], 4));
506
+ }
507
+ }), tt = /* @__PURE__ */ le(et, [["__scopeId", "data-v-a3e8e93b"]]), it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
508
+ __proto__: null,
509
+ default: tt
510
+ }, Symbol.toStringTag, { value: "Module" }));
511
+ export {
512
+ Ge as D,
513
+ tt as R,
514
+ Ze as a,
515
+ Ne as b,
516
+ Z as c,
517
+ at as d,
518
+ st as e,
519
+ He as f,
520
+ Ae as g,
521
+ Le as h,
522
+ it as i,
523
+ lt as p,
524
+ qe as r,
525
+ Ke as t,
526
+ Ye as u
527
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";const e=require("vue"),H=require("@agile-team/mach-report"),B=require("./plugin-BIJxGHZX.cjs");function Z(t,n,r={}){const o=r.pxPerMm??3.7795275590551185,a=r.gapPx??18,s=e.ref(0),c=e.ref(800),f=e.computed(()=>(t.value?.pages??[]).map(l=>l.pageHeightMm*o)),y=e.computed(()=>{const l=t.value?.pages??[];let p=0,d=0;for(const v of l)p+=v.pageHeightMm*o+a,d=Math.max(d,v.pageWidthMm*o);return{w:d,h:p}}),u=e.computed(()=>H.computePageWindow({pageHeightsPx:f.value,viewportHeightPx:c.value/n.value,scrollTopPx:s.value/n.value,overscan:1,gapPx:a})),i=e.computed(()=>{const l=t.value;if(!l)return[];const{start:p,end:d}=u.value;return d<p?[]:l.pages.slice(p,d+1).map((v,b)=>({page:v,index:p+b}))});function g(l,p){let d=0;return v=>{d||(d=requestAnimationFrame(()=>{if(d=0,s.value=v.scrollTop,c.value=v.clientHeight||800,p.value<=0)return;const b=v.querySelectorAll(".mrp-page-holder");if(!b.length)return;const D=v.getBoundingClientRect().top+56;let E=1;b.forEach(x=>{x.getBoundingClientRect().top<=D&&(E=Number(x.dataset.page??1))}),l.value=Math.max(1,Math.min(p.value,E))}))}}return{pageHeightsPx:f,contentSize:y,windowRange:u,visiblePages:i,scrollTop:s,viewportHeight:c,makeScrollHandler:g,refreshViewport(l){l&&(c.value=l.clientHeight||800)}}}function Y(t){const n=e.ref(1),r=e.ref("fit");function o(){requestAnimationFrame(()=>{const s=t();!s||!s.viewport||(n.value=Math.min(1,Math.max(.3,(s.viewport.clientWidth-48)/Math.max(1,s.pageWidthPx))))})}function a(s){s==="fit"?(r.value="fit",o()):(r.value="raw",n.value=s/100)}return{zoom:n,zoomMode:r,applyFitZoom:o,setZoom:a}}const q=8;function K(){return new Promise(t=>setTimeout(t,0))}function T(t){return`p${Math.round(t.pageWidthMm)}x${Math.round(t.pageHeightMm)}`}function W(t){const n=new Map;t.pages.forEach(c=>{n.has(T(c))||n.set(T(c),c)});const a=`<!doctype html><html><head><meta charset="utf-8"><style>${`.mr-page{margin:0 auto;page-break-after:always;}
2
+ .mr-page tr{break-inside:avoid;page-break-inside:avoid;}
3
+ .mr-comp{break-inside:avoid;page-break-inside:avoid;}
4
+ ${[...n.values()].map(c=>`@page ${T(c)}{size:${Math.round(c.pageWidthMm)}mm ${Math.round(c.pageHeightMm)}mm;margin:0;}`).join(`
5
+ `)}
6
+ body{margin:0;background:#fff;}`}</style></head><body>`,s=t.pages.map(c=>{const f=H.renderPage(c,96,{},document);return f.style.page=T(c),f.outerHTML});return{head:a,pageChunks:s}}function X(t,n){let r=null;function o(){r?.remove(),r=null}function a(u,i){const g=URL.createObjectURL(u),l=document.createElement("a");l.href=g,l.download=i,l.click(),setTimeout(()=>URL.revokeObjectURL(g),1e4)}async function s(){const u=t.value;if(!u||u.pages.length===0)return;o();const{head:i,pageChunks:g}=W(u);r=document.createElement("iframe"),r.style.cssText="position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;",document.body.appendChild(r);const l=r;try{const p=l.contentDocument;p.open(),p.write(i);for(let d=0;d<g.length;d++)if(p.write(g[d]),d%q===q-1&&await K(),l!==r)return;p.write("</body></html>"),p.close(),await K(),l.contentWindow?.focus(),l.contentWindow?.print()}catch{n.onError("调用打印失败,请改用导出 PDF")}}async function c(){const u=t.value;if(!(!u||u.pages.length===0))try{const i=await n.getPdfExporter()(u);a(new Blob([i],{type:"application/pdf"}),"mach-report.pdf")}catch(i){n.onError(i instanceof Error?`PDF 导出失败: ${i.message}`:"PDF 导出失败")}}function f(u){const i=t.value;if(!i||i.pages.length===0)return;if(u==="pdf"){c();return}const{head:g,pageChunks:l}=W(i),p=`${g}${l.join("")}</body></html>`;a(new Blob([p],{type:"text/html;charset=utf-8"}),`mach-report.${u==="html"?"html":u}`)}function y(){const u=t.value;if(!u||u.pages.length===0)return;const{head:i,pageChunks:g}=W(u),l=`${i}${g.join("")}</body></html>`,p=new Blob([l],{type:"text/html;charset=utf-8"}),d=URL.createObjectURL(p),v=window.open(d,"_blank");if(!v){n.onError("浏览器拦截了弹窗,请允许弹窗后重试"),URL.revokeObjectURL(d);return}setTimeout(()=>v.print(),400),setTimeout(()=>URL.revokeObjectURL(d),1e4)}return{print:s,exportAs:f,openPdfWindow:y,releasePrintFrame:o}}const he={class:"mrp-toolbar"},we={class:"mrp-title"},Pe=["disabled"],be={class:"mrp-pageinfo"},ye=["disabled"],Ee=e.defineComponent({__name:"ReportToolbar",props:{pageCount:{},currentPage:{},zoomMode:{},zoom:{},showExport:{type:Boolean},showPrint:{type:Boolean},showPdfWindow:{type:Boolean},messages:{}},emits:["goto","zoom","export","print","pdf-window"],setup(t){function n(r,o,a){return r.replace("{cur}",String(o)).replace("{total}",String(a))}return(r,o)=>(e.openBlock(),e.createElementBlock("div",he,[e.createElementVNode("span",we,e.toDisplayString(t.messages.title),1),t.pageCount>0?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("button",{class:"mrp-nav",type:"button",disabled:t.currentPage<=1,onClick:o[0]||(o[0]=a=>r.$emit("goto",t.currentPage-1))},e.toDisplayString(t.messages.prevPage),9,Pe),e.createElementVNode("span",be,e.toDisplayString(n(t.messages.pageInfo,t.currentPage,t.pageCount)),1),e.createElementVNode("button",{class:"mrp-nav",type:"button",disabled:t.currentPage>=t.pageCount,onClick:o[1]||(o[1]=a=>r.$emit("goto",t.currentPage+1))},e.toDisplayString(t.messages.nextPage),9,ye)],64)):e.createCommentVNode("",!0),o[9]||(o[9]=e.createElementVNode("span",{class:"mrp-spacer"},null,-1)),e.createElementVNode("button",{class:e.normalizeClass(["mrp-nav",{"mrp-active":t.zoomMode==="fit"}]),type:"button",onClick:o[2]||(o[2]=a=>r.$emit("zoom","fit"))},e.toDisplayString(t.messages.fitWidth),3),e.createElementVNode("button",{class:e.normalizeClass(["mrp-nav",{"mrp-active":t.zoomMode==="raw"&&Math.round(t.zoom*100)===100}]),type:"button",onClick:o[3]||(o[3]=a=>r.$emit("zoom",100))}," 100% ",2),e.createElementVNode("button",{class:e.normalizeClass(["mrp-nav",{"mrp-active":t.zoomMode==="raw"&&Math.round(t.zoom*100)===150}]),type:"button",onClick:o[4]||(o[4]=a=>r.$emit("zoom",150))}," 150% ",2),t.showExport?(e.openBlock(),e.createElementBlock("button",{key:1,class:"mrp-nav",type:"button",onClick:o[5]||(o[5]=a=>r.$emit("export","html"))},e.toDisplayString(t.messages.exportHtml),1)):e.createCommentVNode("",!0),t.showExport?(e.openBlock(),e.createElementBlock("button",{key:2,class:"mrp-nav",type:"button",onClick:o[6]||(o[6]=a=>r.$emit("export","pdf"))},e.toDisplayString(t.messages.exportPdf),1)):e.createCommentVNode("",!0),t.showPrint?(e.openBlock(),e.createElementBlock("button",{key:3,class:"mrp-nav",type:"button",onClick:o[7]||(o[7]=a=>r.$emit("print"))},e.toDisplayString(t.messages.print),1)):e.createCommentVNode("",!0),t.showPdfWindow?(e.openBlock(),e.createElementBlock("button",{key:4,class:"mrp-nav",type:"button",onClick:o[8]||(o[8]=a=>r.$emit("pdf-window"))},e.toDisplayString(t.messages.pdfWindow),1)):e.createCommentVNode("",!0)]))}}),J=(t,n)=>{const r=t.__vccOpts||t;for(const[o,a]of n)r[o]=a;return r},Q=J(Ee,[["__scopeId","data-v-2bfb2c61"]]),_={title:"报表预览",prevPage:"‹ 上一页",nextPage:"下一页 ›",pageInfo:"{cur} / {total}",fitWidth:"适宽",exportHtml:"导出 HTML",exportPdf:"导出 PDF",print:"打印",pdfWindow:"PDF 窗口",loading:"报表渲染中…",empty:"暂无预览数据",errorPrefix:"",retry:"重试"},ee={shellBg:"#525659",shellFg:"#e8e8e8",toolbarBg:"#323639",toolbarBorder:"#22252a",toolbarFg:"#e8e8e8",btnFg:"#cfcfcf",btnBorder:"#4a4d52",btnHoverBg:"#414549",btnHoverFg:"#ffffff",btnActiveBg:"#2d5fb8"};function xe(t){return t}function ke(t){return t}const $={showExport:!0,showPrint:!0,showPdfWindow:!0,gapPx:18,pdfFontUrl:"/simhei.ttf"};function te(t,n){const r=n?t?.presets?.[n]:t?.defaultPreset?t?.presets?.[t.defaultPreset]:void 0,o={...t?.defaults,...r};return{showExport:o.showExport??$.showExport,showPrint:o.showPrint??$.showPrint,showPdfWindow:o.showPdfWindow??$.showPdfWindow,gapPx:o.gapPx??$.gapPx,pdfFontUrl:o.pdfFontUrl??$.pdfFontUrl,theme:{...ee,...o.theme},messages:{..._,...o.messages}}}function oe(t){const n={};return t.shellBg!=null&&(n["--mrp-shell-bg"]=t.shellBg),t.shellFg!=null&&(n["--mrp-shell-fg"]=t.shellFg),t.toolbarBg!=null&&(n["--mrp-toolbar-bg"]=t.toolbarBg),t.toolbarBorder!=null&&(n["--mrp-toolbar-border"]=t.toolbarBorder),t.toolbarFg!=null&&(n["--mrp-toolbar-fg"]=t.toolbarFg),t.btnFg!=null&&(n["--mrp-btn-fg"]=t.btnFg),t.btnBorder!=null&&(n["--mrp-btn-border"]=t.btnBorder),t.btnHoverBg!=null&&(n["--mrp-btn-hover-bg"]=t.btnHoverBg),t.btnHoverFg!=null&&(n["--mrp-btn-hover-fg"]=t.btnHoverFg),t.btnActiveBg!=null&&(n["--mrp-btn-active-bg"]=t.btnActiveBg),n}function Be(t){const n=e.inject(B.MACH_REPORT_CONFIG_KEY,null),r=e.computed(()=>{const o=n?.value??null,a="defaults"in t&&"presets"in t?t:{defaults:t,presets:{}};return o?{defaults:{...o.defaults,...a.defaults},presets:{...o.presets,...a.presets},defaultPreset:a.defaultPreset??o.defaultPreset}:a});e.provide(B.MACH_REPORT_CONFIG_KEY,r)}function ne(){return e.inject(B.MACH_REPORT_CONFIG_KEY,e.computed(()=>null))}const Me={key:0,class:"mrp-state"},Ce={key:1,class:"mrp-state mrp-error"},Re={key:2,class:"mrp-state"},$e=["data-page"],z=96/25.4,Se=e.defineComponent({__name:"ReportPreview",props:{tempId:{type:[String,Array],default:null},furnitureTempId:{type:String,default:""},params:{type:Object,default:()=>({})},height:{type:String,default:"100vh"},autoLoad:{type:Boolean,default:!0},showExport:{type:Boolean,default:void 0},showPrint:{type:Boolean,default:void 0},showPdfWindow:{type:Boolean,default:void 0},gapPx:{type:Number,default:void 0},messages:{type:Object,default:void 0},preset:{type:String,default:void 0},fetcher:{type:Function,default:null}},emits:["loaded","error"],setup(t,{expose:n,emit:r}){e.useCssVars(P=>({v1f6cf76a:g.value+"px"}));const o=t,a=r,s=e.shallowRef(null),c=e.ref(!1),f=e.ref(""),y=e.ref(1),u=e.ref(null),i=e.ref(null),g=e.computed(()=>Math.max(0,ie.value)),l=e.inject(B.MACH_REPORT_FETCHER_KEY,null),d=e.inject(B.MACH_REPORT_PDF_EXPORTER_KEY,null)??B.createDefaultPdfExporter({fontUrl:"/simhei.ttf"}),v=e.computed(()=>B.normalizeTempIds(o.tempId)),b=e.computed(()=>s.value?.pages.length??0),D=ne(),E=e.computed(()=>te(D.value,o.preset)),x=e.computed(()=>({...E.value.messages,...o.messages})),ae=e.computed(()=>o.showExport??E.value.showExport),le=e.computed(()=>o.showPrint??E.value.showPrint),se=e.computed(()=>o.showPdfWindow??E.value.showPdfWindow),ie=e.computed(()=>o.gapPx??E.value.gapPx),ue=e.computed(()=>({height:o.height,...oe(E.value.theme)})),{zoom:M,zoomMode:ce,applyFitZoom:A,setZoom:de}=Y(()=>({viewport:i.value,pageWidthPx:(s.value?.pages[0]?.pageWidthMm??210)*z})),pe=Z(s,M,{pxPerMm:z,gapPx:g.value}),{contentSize:N,windowRange:S,visiblePages:fe,makeScrollHandler:me,refreshViewport:L}=pe,ge=me(y,b);function V(){s.value=null,y.value=1}let F=0;async function R(){const P=++F,h=o.fetcher??l;if(v.value.length===0){f.value="缺少报表模板 ID",V(),a("error",f.value);return}if(!h){f.value="未提供渲染数据源 fetcher",V(),a("error",f.value);return}c.value=!0,f.value="",V();try{const m=await h({tempIds:v.value,furnitureTempId:o.furnitureTempId||void 0,params:{...o.params}});if(P!==F)return;const w=H.validateRenderPlan(m);if(!w.ok){const k=w.errors.slice(0,3).map(C=>`${C.path}: ${C.message}`).join("; ");throw new Error(`渲染计划校验失败(${w.errors.length} 处): ${k}`)}w.warnings.length>0&&console.warn("[mach-report] 渲染计划告警:",w.warnings),s.value=m,y.value=1,i.value&&(i.value.scrollTop=0),A(),a("loaded",m.pages.length)}catch(m){if(P!==F)return;f.value=m instanceof Error?m.message:"预览加载失败",a("error",f.value)}finally{P===F&&(c.value=!1)}}function O(P){if(b.value<=0)return;const h=Math.max(1,Math.min(b.value,P));y.value=h;const m=i.value;if(!m)return;let w=0;for(let k=0;k<h-1;k++)w+=(s.value?.pages[k]?.pageHeightMm??0)*z+g.value;m.scrollTop=w*M.value}const{print:I,exportAs:j,openPdfWindow:U,releasePrintFrame:ve}=X(s,{getPdfExporter:()=>d,onError:P=>a("error",P)});e.watchEffect(()=>{const P=s.value;if(!P)return;const h=u.value;if(!h)return;h.querySelectorAll(".mrp-page-holder").forEach(w=>{const k=Number(w.dataset.page??0)-1,C=P.pages[k];!C||w.childElementCount>0||(w.style.width=`${C.pageWidthMm*z}px`,w.appendChild(H.renderPage(C,96,{},document)))})},{flush:"post"});function G(){L(i.value),A()}return e.onMounted(()=>{window.addEventListener("resize",G),L(i.value),o.autoLoad&&R()}),e.onUnmounted(()=>{window.removeEventListener("resize",G),ve()}),e.watch(()=>[o.tempId,o.furnitureTempId,JSON.stringify(o.params)],()=>{o.autoLoad&&R()}),e.watch(()=>o.fetcher??l,()=>{o.autoLoad&&R()}),n({reload:R,print:I,exportAs:j,openPdfWindow:U,gotoPage:O}),(P,h)=>(e.openBlock(),e.createElementBlock("div",{class:"mach-report-preview",style:e.normalizeStyle(ue.value)},[e.createVNode(Q,{"page-count":b.value,"current-page":y.value,"zoom-mode":e.unref(ce),zoom:e.unref(M),"show-export":ae.value,"show-print":le.value,"show-pdf-window":se.value,messages:x.value,onGoto:O,onZoom:e.unref(de),onExport:h[0]||(h[0]=m=>e.unref(j)(m)),onPrint:e.unref(I),onPdfWindow:e.unref(U)},null,8,["page-count","current-page","zoom-mode","zoom","show-export","show-print","show-pdf-window","messages","onZoom","onPrint","onPdfWindow"]),e.createElementVNode("div",{ref_key:"viewportRef",ref:i,class:"mrp-body",onScrollPassive:h[1]||(h[1]=m=>e.unref(ge)(m.target))},[c.value?(e.openBlock(),e.createElementBlock("div",Me,e.toDisplayString(x.value.loading),1)):f.value?(e.openBlock(),e.createElementBlock("div",Ce,[e.createTextVNode(e.toDisplayString(f.value)+" ",1),e.createElementVNode("button",{class:"mrp-retry",type:"button",onClick:R},e.toDisplayString(x.value.retry),1)])):!s.value||b.value===0?(e.openBlock(),e.createElementBlock("div",Re,e.toDisplayString(x.value.empty),1)):(e.openBlock(),e.createElementBlock("div",{key:3,class:"mrp-scale",style:e.normalizeStyle({width:`${e.unref(N).w*e.unref(M)}px`,height:`${e.unref(N).h*e.unref(M)}px`})},[e.createElementVNode("div",{ref_key:"containerRef",ref:u,class:"mrp-scale-inner",style:e.normalizeStyle({transform:`scale(${e.unref(M)})`,transformOrigin:"top left",width:`${e.unref(N).w}px`})},[e.unref(S).padTopPx>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"mrp-spacer-top",style:e.normalizeStyle({height:`${e.unref(S).padTopPx}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(fe),m=>(e.openBlock(),e.createElementBlock("div",{key:m.index,class:"mrp-page-holder","data-page":m.index+1},null,8,$e))),128)),e.unref(S).padBottomPx>0?(e.openBlock(),e.createElementBlock("div",{key:1,class:"mrp-spacer-bottom",style:e.normalizeStyle({height:`${e.unref(S).padBottomPx}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0)],4)],4))],544)],4))}}),re=J(Se,[["__scopeId","data-v-a3e8e93b"]]),Fe=Object.freeze(Object.defineProperty({__proto__:null,default:re},Symbol.toStringTag,{value:"Module"}));exports.DEFAULT_MESSAGES=_;exports.DEFAULT_THEME=ee;exports.ReportPreview=re;exports.ReportPreview$1=Fe;exports.ReportToolbar=Q;exports.buildPrintDocument=W;exports.defineMachReportConfig=xe;exports.defineMachReportPreset=ke;exports.provideMachReportConfig=Be;exports.resolveConfig=te;exports.themeToCssVars=oe;exports.useMachReportConfig=ne;exports.usePageWindow=Z;exports.usePrintExport=X;exports.useZoom=Y;
@@ -0,0 +1 @@
1
+ "use strict";var o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}exports.commonjsGlobal=o;exports.getDefaultExportFromCjs=l;
@@ -0,0 +1,8 @@
1
+ var o = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
2
+ function l(e) {
3
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
4
+ }
5
+ export {
6
+ o as c,
7
+ l as g
8
+ };
@@ -0,0 +1,53 @@
1
+ import { ListColumn, ListComponent, ReportTemplate, TemplatePage } from '../layout/paginate';
2
+ import { ComponentStyle, PlanComponent } from '../schema/render-plan';
3
+ import { PAPER_SIZES } from '../units';
4
+ type Geometry = Partial<Pick<PlanComponent, "leftMm" | "topMm" | "widthMm" | "heightMm">>;
5
+ /** 纸张预设名(对齐 PAPER_SIZES 表) */
6
+ export type PaperName = keyof typeof PAPER_SIZES;
7
+ export interface PageOptions {
8
+ /** 横向(宽高互换) */
9
+ landscape?: boolean;
10
+ margins?: Partial<Pick<TemplatePage, "marginTopMm" | "marginBottomMm" | "marginLeftMm" | "marginRightMm">>;
11
+ }
12
+ type PageMargins = Partial<Pick<TemplatePage, "marginTopMm" | "marginBottomMm" | "marginLeftMm" | "marginRightMm">>;
13
+ /** 解析纸张参数:数字按宽高使用;字符串查 PAPER_SIZES 预设;缺省 A4 纵向 */
14
+ export declare function resolvePaper(paper: PaperName | {
15
+ widthMm: number;
16
+ heightMm: number;
17
+ } | number, heightArg?: number, landscape?: boolean): {
18
+ widthMm: number;
19
+ heightMm: number;
20
+ };
21
+ export declare class TemplateBuilder {
22
+ readonly pages: TemplatePage[];
23
+ private pending;
24
+ /**
25
+ * 新建页。纸张支持三种写法:
26
+ * - 预设名:.page("a4", { landscape: true, margins: {...} })
27
+ * - 数字:.page(210, 297)(第三参数兼容旧 margins 对象或新 options)
28
+ * - 对象:.page({ widthMm: 210, heightMm: 297 })
29
+ */
30
+ page(paper?: PaperName | {
31
+ widthMm: number;
32
+ heightMm: number;
33
+ } | number, optionsOrHeight?: number | PageOptions, maybeOptions?: PageOptions | PageMargins): PageBuilder;
34
+ collect(): void;
35
+ build(): ReportTemplate;
36
+ }
37
+ export declare class PageBuilder {
38
+ private readonly parent;
39
+ private readonly page;
40
+ private components;
41
+ constructor(parent: TemplateBuilder, page: Omit<TemplatePage, "components">);
42
+ text(content: string, geometry?: Geometry, style?: ComponentStyle): this;
43
+ list(dataset: string, geometry: Partial<Pick<ListComponent, "leftMm" | "topMm" | "widthMm">>, columns: ListColumn[], options?: Partial<Omit<ListComponent, "kind" | "leftMm" | "topMm" | "widthMm" | "dataset" | "columns">>): this;
44
+ rect(geometry: Required<Pick<PlanComponent, "leftMm" | "topMm" | "widthMm" | "heightMm">>, style?: ComponentStyle): this;
45
+ line(leftMm: number, topMm: number, widthMm: number, style?: ComponentStyle): this;
46
+ barcode(content: string, geometry: Required<Geometry>): this;
47
+ qrcode(content: string, sizeMm: number, leftMm: number, topMm: number): this;
48
+ buildPage(): TemplatePage;
49
+ done(): TemplateBuilder;
50
+ build(): ReportTemplate;
51
+ }
52
+ export declare function createTemplate(): TemplateBuilder;
53
+ export {};
@@ -0,0 +1,12 @@
1
+ import { ReportTemplate } from '../layout/paginate';
2
+ export interface Jh4jImportResult {
3
+ template: ReportTemplate;
4
+ warnings: string[];
5
+ }
6
+ type Raw = Record<string, unknown>;
7
+ /**
8
+ * jh4j 模板 content(exportBackendPrintConfig 产物,见 docs/reverse-findings.md §6)
9
+ * → MachReport ReportTemplate。单向转换,未知结构降级 + 告警,绝不抛错。
10
+ */
11
+ export declare function importJh4jTemplateContent(content: string | Raw): Jh4jImportResult;
12
+ export {};
@@ -0,0 +1,27 @@
1
+ /**
2
+ * 全引擎共享默认值(唯一真相源)。
3
+ *
4
+ * 修改这里的任何常量前请注意消费方:
5
+ * - LINE_HEIGHT:分页行高估算 / Canvas / PDF 三处换算必须一致
6
+ * - DEFAULT_FONT_PT / DEFAULT_BORDER_PT:三后端默认字号与线宽
7
+ * - SCHEMA_VERSION_*:RenderPlan 版本标识(adapter 产出侧使用)
8
+ *
9
+ * 历史:这些值曾散落在 paginate/canvas/pdf/dom 四个文件中各写一份,
10
+ * 是三后端漂移的温床,收敛于此。
11
+ */
12
+ /** 默认行高倍数(基线距 = 字号 × 该系数,与 jh4j 打印口径一致) */
13
+ export declare const LINE_HEIGHT = 1.35;
14
+ /** 默认字号(pt),对齐 jh4j 模板缺省值 */
15
+ export declare const DEFAULT_FONT_PT = 10.5;
16
+ /** 默认边框线宽(pt) */
17
+ export declare const DEFAULT_BORDER_PT = 0.75;
18
+ /** 默认描边色(#333 与 jh4j 网格线一致) */
19
+ export declare const DEFAULT_STROKE_COLOR = "#333333";
20
+ /** 默认文本色 */
21
+ export declare const DEFAULT_TEXT_COLOR = "#000000";
22
+ /** RenderPlan 正式 schema 版本(core 分页引擎产出) */
23
+ export declare const SCHEMA_VERSION_MACH = "1.0.0-mach";
24
+ /** 本地渲染适配器产出版本标识(vue/createLocalFetcher) */
25
+ export declare const SCHEMA_VERSION_LOCAL = "mach-local";
26
+ /** jh4j gridPlan 兼容数据标识(vue/createJh4jGridPlanFetcher) */
27
+ export declare const SCHEMA_VERSION_JH4J = "jh4j-compatible";