@agile-team/mach-report 0.6.0 → 0.8.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-BQE0C_37.cjs +6 -0
- package/dist/ReportPreview-D8X75aLV.js +825 -0
- package/dist/format.d.ts +35 -0
- package/dist/grid-geometry-BXpOxznT.cjs +1 -0
- package/dist/grid-geometry-Bs8QXz1X.js +65 -0
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +811 -606
- package/dist/layout/paginate.d.ts +29 -0
- package/dist/pdf.cjs +46 -46
- package/dist/pdf.js +12 -11
- package/dist/plugin-7W2Zy3Xc.cjs +1 -0
- package/dist/plugin-Bc6Px9Lq.js +92 -0
- package/dist/style-6ihHKVCM.js +192 -0
- package/dist/style-Xq08-IsV.cjs +3 -0
- package/dist/style.css +1 -1
- package/dist/vue/ReportPreview.d.ts +40 -3
- package/dist/vue/ReportToolbar.d.ts +15 -0
- package/dist/vue/adapters.d.ts +3 -0
- package/dist/vue/async.d.cts +209 -64
- package/dist/vue/async.d.ts +209 -64
- package/dist/vue/composables/useHighlight.d.ts +8 -0
- package/dist/vue/composables/usePrintExport.d.ts +7 -0
- package/dist/vue/config.d.ts +9 -0
- 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 +278 -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 +39 -29
- package/dist/xlsx/render-xlsx.d.ts +20 -0
- package/dist/xlsx.cjs +30 -0
- package/dist/xlsx.d.cts +5 -0
- package/dist/xlsx.d.ts +5 -0
- package/dist/xlsx.js +22647 -0
- package/package.json +13 -2
- 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/style-B3vxGDZd.cjs +0 -3
- package/dist/style-B7Xfo5I-.js +0 -255
package/dist/pdf.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { g as L1 } from "./_commonjsHelpers-DaMA6jEr.js";
|
|
2
|
-
import { h as N1, i as U1, c as xo, d as hl, b as dl,
|
|
2
|
+
import { h as N1, i as U1, c as xo, d as hl, b as dl, L as vu, a as Ed, w as z1 } from "./style-6ihHKVCM.js";
|
|
3
|
+
import { r as j1 } from "./grid-geometry-Bs8QXz1X.js";
|
|
3
4
|
var pu = {}, vl;
|
|
4
5
|
function Hn() {
|
|
5
6
|
return vl || (vl = 1, (function(t) {
|
|
@@ -35924,7 +35925,7 @@ function FE(t) {
|
|
|
35924
35925
|
}
|
|
35925
35926
|
return e;
|
|
35926
35927
|
}
|
|
35927
|
-
async function
|
|
35928
|
+
async function OE(t, e = {}) {
|
|
35928
35929
|
const r = await Gn.create();
|
|
35929
35930
|
r.registerFontkit(wi);
|
|
35930
35931
|
const n = [], i = [];
|
|
@@ -35933,7 +35934,7 @@ async function TE(t, e = {}) {
|
|
|
35933
35934
|
subset: !0
|
|
35934
35935
|
}) : void 0) ?? s, l = /* @__PURE__ */ new Map();
|
|
35935
35936
|
function h(w, x, T) {
|
|
35936
|
-
return w ?
|
|
35937
|
+
return w ? z1(w, x, { fontSizePt: T }, o) : [];
|
|
35937
35938
|
}
|
|
35938
35939
|
function d(w) {
|
|
35939
35940
|
const x = l.get(w);
|
|
@@ -35967,7 +35968,7 @@ async function TE(t, e = {}) {
|
|
|
35967
35968
|
});
|
|
35968
35969
|
}
|
|
35969
35970
|
function g(w, x, T, A, R) {
|
|
35970
|
-
const P =
|
|
35971
|
+
const P = j1(x, T.widthMm, T.heightMm), I = hl(T.style), B = xo(T.style), j = ii(B.color, [0.2, 0.2, 0.2]), W = Math.max(0.1, B.widthPt);
|
|
35971
35972
|
for (const N of P.cells) {
|
|
35972
35973
|
const V = N.cell.style?.backgroundColor;
|
|
35973
35974
|
V && w.drawRectangle({
|
|
@@ -36121,7 +36122,7 @@ async function CE(t, e) {
|
|
|
36121
36122
|
}
|
|
36122
36123
|
}
|
|
36123
36124
|
const bf = /* @__PURE__ */ new Map(), wf = /* @__PURE__ */ new Map();
|
|
36124
|
-
async function
|
|
36125
|
+
async function kE(t) {
|
|
36125
36126
|
const e = bf.get(t);
|
|
36126
36127
|
if (e) return e;
|
|
36127
36128
|
const r = wf.get(t);
|
|
@@ -36131,10 +36132,10 @@ async function OE(t) {
|
|
|
36131
36132
|
if (i)
|
|
36132
36133
|
return bf.set(t, i), i;
|
|
36133
36134
|
try {
|
|
36134
|
-
const a = await fetch(t);
|
|
36135
|
-
if (!
|
|
36136
|
-
const
|
|
36137
|
-
return bf.set(t,
|
|
36135
|
+
const a = typeof AbortSignal < "u" && "timeout" in AbortSignal ? AbortSignal.timeout(15e3) : void 0, o = await fetch(t, a ? { signal: a } : void 0);
|
|
36136
|
+
if (!o.ok) return null;
|
|
36137
|
+
const s = new Uint8Array(await o.arrayBuffer());
|
|
36138
|
+
return bf.set(t, s), CE(t, s), s;
|
|
36138
36139
|
} catch {
|
|
36139
36140
|
return null;
|
|
36140
36141
|
}
|
|
@@ -36147,6 +36148,6 @@ async function OE(t) {
|
|
|
36147
36148
|
}
|
|
36148
36149
|
}
|
|
36149
36150
|
export {
|
|
36150
|
-
|
|
36151
|
-
|
|
36151
|
+
kE as loadFontWithCache,
|
|
36152
|
+
OE as renderPlanToPdf
|
|
36152
36153
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var O=Object.create;var E=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var U=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of b(e))!F.call(r,n)&&n!==t&&E(r,n,{get:()=>e[n],enumerable:!(o=A(e,n))||o.enumerable});return r};var M=(r,e,t)=>(t=r!=null?O(y(r)):{},U(e||!r||!r.__esModule?E(t,"default",{value:r,enumerable:!0}):t,r));const R=require("vue");function m(r){return r==null?[]:Array.isArray(r)?r.map(String).filter(e=>e!==""):String(r).split(",").map(e=>e.trim()).filter(e=>e!=="")}function j(r){return m(r).join(",")}class s extends Error{constructor(e){super(e),this.name="PlanLoadError"}}function P(r={}){const{baseUrl:e="",headers:t,credentials:o,timeoutMs:n=3e4}=r;return async({url:c,method:i,params:a})=>{const h=a&&Object.keys(a).length>0?`?${new URLSearchParams(a)}`:"",l=new AbortController,f=setTimeout(()=>l.abort(),n);let d;try{d=await fetch(`${e}${c}${h}`,{method:i.toUpperCase(),headers:{Accept:"application/json",...t},credentials:o,signal:l.signal})}catch(u){throw u instanceof DOMException&&u.name==="AbortError"?new s(`请求超时(${n}ms): ${c}`):new s(`请求失败(${c}): ${u instanceof Error?u.message:String(u)}`)}finally{clearTimeout(f)}if(!d.ok)throw new s(`HTTP ${d.status} ${c}`);return d.json()}}function p(r){const{request:e,baseUrl:t=""}=r;return async({tempIds:o,furnitureTempId:n,params:c})=>{if(o.length===0)throw new s("缺少报表模板 ID");const i={tempId:o.join(",")};n&&(i.furnitureTempId=n);for(const[l,f]of Object.entries(c||{}))l&&f!=null&&f!==""&&(i[l]=String(f));const a=await e({url:`${t}/report/codePrintReport/gridPlan`,method:"get",params:i});if(a&&a.code!=null&&a.code!==200)throw new s(String(a.message||"预览加载失败"));const h=a?.data?.pages;return{schemaVersion:"jh4j-compatible",pages:Array.isArray(h)?h:[]}}}function _(r={fontUrl:"/simhei.ttf"}){let e=null;return async t=>{e||(e=await import("@agile-team/mach-report/pdf"));const o=r.fontUrl?await e.loadFontWithCache(r.fontUrl):null,{bytes:n}=await e.renderPlanToPdf(t,o?{customFontBytes:o}:{});return n}}const T="mach-report/fetcher",g="mach-report/pdf-exporter",w="mach-report/config",$="mach-report/controller",C=R.defineAsyncComponent(()=>Promise.resolve().then(()=>require("./ReportPreview-BQE0C_37.cjs")).then(r=>r.ReportPreview$1)),H={install(r,e={}){const t=e.fetcher??p({request:e.request??P({baseUrl:e.baseUrl}),baseUrl:e.baseUrl});r.provide(T,t);const o=e.pdfFontUrl??e.config?.defaults?.pdfFontUrl??"/simhei.ttf";r.provide(g,e.pdfExporter??_({fontUrl:o})),r.provide(w,R.computed(()=>e.config??null)),e.globalComponent!==!1&&r.component("MachReportPreview",C)}};exports.MACH_REPORT_CONFIG_KEY=w;exports.MACH_REPORT_CONTROLLER_KEY=$;exports.MACH_REPORT_FETCHER_KEY=T;exports.MACH_REPORT_PDF_EXPORTER_KEY=g;exports.MachReportPreview=C;exports.PlanLoadError=s;exports.createDefaultPdfExporter=_;exports.createFetchRequest=P;exports.createJh4jGridPlanFetcher=p;exports.joinTempIds=j;exports.machReportPlugin=H;exports.normalizeTempIds=m;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { defineAsyncComponent as d, computed as p } from "vue";
|
|
2
|
+
function g(r) {
|
|
3
|
+
return r == null ? [] : Array.isArray(r) ? r.map(String).filter((e) => e !== "") : String(r).split(",").map((e) => e.trim()).filter((e) => e !== "");
|
|
4
|
+
}
|
|
5
|
+
function _(r) {
|
|
6
|
+
return g(r).join(",");
|
|
7
|
+
}
|
|
8
|
+
class u extends Error {
|
|
9
|
+
constructor(e) {
|
|
10
|
+
super(e), this.name = "PlanLoadError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function E(r = {}) {
|
|
14
|
+
const { baseUrl: e = "", headers: o, credentials: t, timeoutMs: a = 3e4 } = r;
|
|
15
|
+
return async ({ url: s, method: c, params: n }) => {
|
|
16
|
+
const h = n && Object.keys(n).length > 0 ? `?${new URLSearchParams(n)}` : "", i = new AbortController(), l = setTimeout(() => i.abort(), a);
|
|
17
|
+
let m;
|
|
18
|
+
try {
|
|
19
|
+
m = await fetch(`${e}${s}${h}`, {
|
|
20
|
+
method: c.toUpperCase(),
|
|
21
|
+
headers: { Accept: "application/json", ...o },
|
|
22
|
+
credentials: t,
|
|
23
|
+
signal: i.signal
|
|
24
|
+
});
|
|
25
|
+
} catch (f) {
|
|
26
|
+
throw f instanceof DOMException && f.name === "AbortError" ? new u(`请求超时(${a}ms): ${s}`) : new u(`请求失败(${s}): ${f instanceof Error ? f.message : String(f)}`);
|
|
27
|
+
} finally {
|
|
28
|
+
clearTimeout(l);
|
|
29
|
+
}
|
|
30
|
+
if (!m.ok)
|
|
31
|
+
throw new u(`HTTP ${m.status} ${s}`);
|
|
32
|
+
return m.json();
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function P(r) {
|
|
36
|
+
const { request: e, baseUrl: o = "" } = r;
|
|
37
|
+
return async ({ tempIds: t, furnitureTempId: a, params: s }) => {
|
|
38
|
+
if (t.length === 0) throw new u("缺少报表模板 ID");
|
|
39
|
+
const c = { tempId: t.join(",") };
|
|
40
|
+
a && (c.furnitureTempId = a);
|
|
41
|
+
for (const [i, l] of Object.entries(s || {}))
|
|
42
|
+
i && l != null && l !== "" && (c[i] = String(l));
|
|
43
|
+
const n = await e({
|
|
44
|
+
url: `${o}/report/codePrintReport/gridPlan`,
|
|
45
|
+
method: "get",
|
|
46
|
+
params: c
|
|
47
|
+
});
|
|
48
|
+
if (n && n.code != null && n.code !== 200)
|
|
49
|
+
throw new u(String(n.message || "预览加载失败"));
|
|
50
|
+
const h = n?.data?.pages;
|
|
51
|
+
return {
|
|
52
|
+
schemaVersion: "jh4j-compatible",
|
|
53
|
+
pages: Array.isArray(h) ? h : []
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function w(r = { fontUrl: "/simhei.ttf" }) {
|
|
58
|
+
let e = null;
|
|
59
|
+
return async (o) => {
|
|
60
|
+
e || (e = await import("@agile-team/mach-report/pdf"));
|
|
61
|
+
const t = r.fontUrl ? await e.loadFontWithCache(r.fontUrl) : null, { bytes: a } = await e.renderPlanToPdf(o, t ? { customFontBytes: t } : {});
|
|
62
|
+
return a;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const R = "mach-report/fetcher", b = "mach-report/pdf-exporter", y = "mach-report/config", A = "mach-report/controller", U = d(() => import("./ReportPreview-D8X75aLV.js").then((r) => r.k)), C = {
|
|
66
|
+
install(r, e = {}) {
|
|
67
|
+
const o = e.fetcher ?? P({
|
|
68
|
+
request: e.request ?? E({ baseUrl: e.baseUrl }),
|
|
69
|
+
baseUrl: e.baseUrl
|
|
70
|
+
});
|
|
71
|
+
r.provide(R, o);
|
|
72
|
+
const t = e.pdfFontUrl ?? e.config?.defaults?.pdfFontUrl ?? "/simhei.ttf";
|
|
73
|
+
r.provide(
|
|
74
|
+
b,
|
|
75
|
+
e.pdfExporter ?? w({ fontUrl: t })
|
|
76
|
+
), r.provide(y, p(() => e.config ?? null)), e.globalComponent !== !1 && r.component("MachReportPreview", U);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
export {
|
|
80
|
+
A as M,
|
|
81
|
+
u as P,
|
|
82
|
+
y as a,
|
|
83
|
+
R as b,
|
|
84
|
+
b as c,
|
|
85
|
+
U as d,
|
|
86
|
+
w as e,
|
|
87
|
+
E as f,
|
|
88
|
+
P as g,
|
|
89
|
+
_ as j,
|
|
90
|
+
C as m,
|
|
91
|
+
g as n
|
|
92
|
+
};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
const C = 1.35, w = 10.5, x = 0.75, M = "#333333", S = "#000000", _ = "1.0.0-mach", R = "mach-local", I = "jh4j-compatible", L = 25.4, D = 96;
|
|
2
|
+
function m(t = 96) {
|
|
3
|
+
return t / 25.4;
|
|
4
|
+
}
|
|
5
|
+
function b(t, e = 96) {
|
|
6
|
+
return (t || 0) * m(e);
|
|
7
|
+
}
|
|
8
|
+
function H(t, e = 96) {
|
|
9
|
+
return t / m(e);
|
|
10
|
+
}
|
|
11
|
+
function P(t, e = 96) {
|
|
12
|
+
return t * e / 72;
|
|
13
|
+
}
|
|
14
|
+
function k(t, e) {
|
|
15
|
+
const r = 10 ** e;
|
|
16
|
+
return Math.round(t * r) / r;
|
|
17
|
+
}
|
|
18
|
+
const N = {
|
|
19
|
+
a3: { widthMm: 297, heightMm: 420 },
|
|
20
|
+
a4: { widthMm: 210, heightMm: 297 },
|
|
21
|
+
a5: { widthMm: 148, heightMm: 210 },
|
|
22
|
+
b4: { widthMm: 250, heightMm: 353 },
|
|
23
|
+
b5: { widthMm: 176, heightMm: 250 }
|
|
24
|
+
}, E = _;
|
|
25
|
+
function O(t) {
|
|
26
|
+
if (t && t.code != null && t.code !== 200)
|
|
27
|
+
throw new Error(String(t.message || "渲染计划加载失败"));
|
|
28
|
+
const e = t?.data?.pages;
|
|
29
|
+
return {
|
|
30
|
+
schemaVersion: E,
|
|
31
|
+
pages: Array.isArray(e) ? e : []
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function z(t) {
|
|
35
|
+
return (t.kind === "image" || t.kind === "barcode" || t.kind === "qrcode" || t.kind === "chart") && !!t.imageData;
|
|
36
|
+
}
|
|
37
|
+
function p(t) {
|
|
38
|
+
return t.kind === "text" && Array.isArray(t.richParagraphs) && t.richParagraphs.length > 0;
|
|
39
|
+
}
|
|
40
|
+
const l = /[\u3000-\u9fff\uff00-\uffef]/, f = new Uint8Array(128);
|
|
41
|
+
{
|
|
42
|
+
for (const t of "iljtf.,:;'`|!()[]") f[t.charCodeAt(0)] = 1;
|
|
43
|
+
for (const t of "mwMW@") f[t.charCodeAt(0)] = 2;
|
|
44
|
+
for (let t = 48; t <= 57; t++) f[t] = 3;
|
|
45
|
+
for (let t = 65; t <= 90; t++) f[t] = 4;
|
|
46
|
+
f[32] = 5;
|
|
47
|
+
}
|
|
48
|
+
const T = [0.54, 0.26, 0.95, 0.59, 0.67, 0.3];
|
|
49
|
+
function g(t) {
|
|
50
|
+
const e = t.charCodeAt(0);
|
|
51
|
+
return e < 128 ? T[f[e]] : l.test(t) ? 1 : /[A-Z]/.test(t) ? 0.67 : 0.54;
|
|
52
|
+
}
|
|
53
|
+
const u = {
|
|
54
|
+
measureMm(t, e) {
|
|
55
|
+
const { fontSizePt: r, bold: n = !1, letterSpacingPt: c = 0 } = e, s = 25.4 / 72;
|
|
56
|
+
let i = 0;
|
|
57
|
+
for (const o of t)
|
|
58
|
+
i += g(o);
|
|
59
|
+
return n && (i *= 1.04), (i * r + c * t.length) * s;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
function F() {
|
|
63
|
+
return u;
|
|
64
|
+
}
|
|
65
|
+
function j(t, e) {
|
|
66
|
+
return u.measureMm(t, e);
|
|
67
|
+
}
|
|
68
|
+
function v(t) {
|
|
69
|
+
let e;
|
|
70
|
+
return {
|
|
71
|
+
measureMm(r, n) {
|
|
72
|
+
if (e === void 0 && (e = t()), !e) return u.measureMm(r, n);
|
|
73
|
+
const c = n.fontSizePt * 96 / 72;
|
|
74
|
+
return e.font = `${n.bold ? "bold " : ""}${c}px sans-serif`, e.measureText(r).width * 25.4 / 96;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function A(t, e, r) {
|
|
79
|
+
const n = [];
|
|
80
|
+
let c = "", s = 0;
|
|
81
|
+
const i = () => {
|
|
82
|
+
c && (n.push({ text: c, widthMm: s, cjk: !1 }), c = "", s = 0);
|
|
83
|
+
};
|
|
84
|
+
for (const o of t) {
|
|
85
|
+
if (o === `
|
|
86
|
+
`) {
|
|
87
|
+
i(), n.push({ text: `
|
|
88
|
+
`, widthMm: 0, cjk: !1, br: !0 });
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (o === " ") {
|
|
92
|
+
i(), n.push({ text: o, widthMm: r.measureMm(o, e), cjk: !1, space: !0 });
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (l.test(o)) {
|
|
96
|
+
i(), n.push({ text: o, widthMm: r.measureMm(o, e), cjk: !0 });
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
c += o, s += r.measureMm(o, e);
|
|
100
|
+
}
|
|
101
|
+
return i(), n;
|
|
102
|
+
}
|
|
103
|
+
function U(t, e, r, n = u) {
|
|
104
|
+
if (!t) return [""];
|
|
105
|
+
const c = [];
|
|
106
|
+
let s = "", i = 0;
|
|
107
|
+
const o = () => {
|
|
108
|
+
c.push(s), s = "", i = 0;
|
|
109
|
+
};
|
|
110
|
+
for (const a of A(t, r, n)) {
|
|
111
|
+
if (a.br) {
|
|
112
|
+
o();
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (i + a.widthMm <= e) {
|
|
116
|
+
s += a.text, i += a.widthMm;
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (a.space) {
|
|
120
|
+
o();
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (a.cjk) {
|
|
124
|
+
s.length > 0 && o(), s = a.text, i = a.widthMm;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (s.length > 0 && o(), a.widthMm <= e) {
|
|
128
|
+
s = a.text, i = a.widthMm;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
for (const h of a.text) {
|
|
132
|
+
const d = n.measureMm(h, r);
|
|
133
|
+
i + d > e && s.length > 0 && o(), s += h, i += d;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return o(), c;
|
|
137
|
+
}
|
|
138
|
+
function B(t, e = 96, r = 10.5) {
|
|
139
|
+
if (t?.fontSizePx != null)
|
|
140
|
+
return { fontSizePt: t.fontSizePx * 72 / e, fontSizePx: t.fontSizePx };
|
|
141
|
+
const n = t?.fontSize ?? r;
|
|
142
|
+
return { fontSizePt: n, fontSizePx: P(n, e) };
|
|
143
|
+
}
|
|
144
|
+
function V(t, e = M) {
|
|
145
|
+
return {
|
|
146
|
+
color: t?.borderColor ?? t?.lineColor ?? e,
|
|
147
|
+
widthPt: t?.lineWidthPt ?? 0.75
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function W(t, e = S) {
|
|
151
|
+
return t?.color ?? e;
|
|
152
|
+
}
|
|
153
|
+
function J(t) {
|
|
154
|
+
return t?.lineHeight ?? 1.35;
|
|
155
|
+
}
|
|
156
|
+
function q(t) {
|
|
157
|
+
const e = t?.borderTop !== !1, r = t?.borderRight !== !1, n = t?.borderBottom !== !1, c = t?.borderLeft !== !1;
|
|
158
|
+
return { top: e, right: r, bottom: n, left: c, inner: e || r || n || c };
|
|
159
|
+
}
|
|
160
|
+
export {
|
|
161
|
+
D as C,
|
|
162
|
+
w as D,
|
|
163
|
+
C as L,
|
|
164
|
+
L as M,
|
|
165
|
+
N as P,
|
|
166
|
+
E as R,
|
|
167
|
+
I as S,
|
|
168
|
+
B as a,
|
|
169
|
+
p as b,
|
|
170
|
+
V as c,
|
|
171
|
+
q as d,
|
|
172
|
+
J as e,
|
|
173
|
+
W as f,
|
|
174
|
+
S as g,
|
|
175
|
+
u as h,
|
|
176
|
+
z as i,
|
|
177
|
+
x as j,
|
|
178
|
+
M as k,
|
|
179
|
+
R as l,
|
|
180
|
+
b as m,
|
|
181
|
+
_ as n,
|
|
182
|
+
g as o,
|
|
183
|
+
P as p,
|
|
184
|
+
v as q,
|
|
185
|
+
k as r,
|
|
186
|
+
F as s,
|
|
187
|
+
j as t,
|
|
188
|
+
m as u,
|
|
189
|
+
H as v,
|
|
190
|
+
U as w,
|
|
191
|
+
O as x
|
|
192
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";const m="#333333",M="#000000",T="1.0.0-mach",A="mach-local",C="jh4j-compatible";function h(t=96){return t/25.4}function R(t,e=96){return(t||0)*h(e)}function I(t,e=96){return t/h(e)}function S(t,e=96){return t*e/72}function L(t,e){const r=10**e;return Math.round(t*r)/r}const x={a3:{widthMm:297,heightMm:420},a4:{widthMm:210,heightMm:297},a5:{widthMm:148,heightMm:210},b4:{widthMm:250,heightMm:353},b5:{widthMm:176,heightMm:250}},d=T;function H(t){if(t&&t.code!=null&&t.code!==200)throw new Error(String(t.message||"渲染计划加载失败"));const e=t?.data?.pages;return{schemaVersion:d,pages:Array.isArray(e)?e:[]}}function O(t){return(t.kind==="image"||t.kind==="barcode"||t.kind==="qrcode"||t.kind==="chart")&&!!t.imageData}function g(t){return t.kind==="text"&&Array.isArray(t.richParagraphs)&&t.richParagraphs.length>0}const l=/[\u3000-\u9fff\uff00-\uffef]/,f=new Uint8Array(128);{for(const t of"iljtf.,:;'`|!()[]")f[t.charCodeAt(0)]=1;for(const t of"mwMW@")f[t.charCodeAt(0)]=2;for(let t=48;t<=57;t++)f[t]=3;for(let t=65;t<=90;t++)f[t]=4;f[32]=5}const D=[.54,.26,.95,.59,.67,.3];function P(t){const e=t.charCodeAt(0);return e<128?D[f[e]]:l.test(t)?1:/[A-Z]/.test(t)?.67:.54}const a={measureMm(t,e){const{fontSizePt:r,bold:n=!1,letterSpacingPt:u=0}=e,c=25.4/72;let i=0;for(const o of t)i+=P(o);return n&&(i*=1.04),(i*r+u*t.length)*c}};function N(){return a}function w(t,e){return a.measureMm(t,e)}function F(t){let e;return{measureMm(r,n){if(e===void 0&&(e=t()),!e)return a.measureMm(r,n);const u=n.fontSizePt*96/72;return e.font=`${n.bold?"bold ":""}${u}px sans-serif`,e.measureText(r).width*25.4/96}}}function b(t,e,r){const n=[];let u="",c=0;const i=()=>{u&&(n.push({text:u,widthMm:c,cjk:!1}),u="",c=0)};for(const o of t){if(o===`
|
|
2
|
+
`){i(),n.push({text:`
|
|
3
|
+
`,widthMm:0,cjk:!1,br:!0});continue}if(o===" "){i(),n.push({text:o,widthMm:r.measureMm(o,e),cjk:!1,space:!0});continue}if(l.test(o)){i(),n.push({text:o,widthMm:r.measureMm(o,e),cjk:!0});continue}u+=o,c+=r.measureMm(o,e)}return i(),n}function k(t,e,r,n=a){if(!t)return[""];const u=[];let c="",i=0;const o=()=>{u.push(c),c="",i=0};for(const s of b(t,r,n)){if(s.br){o();continue}if(i+s.widthMm<=e){c+=s.text,i+=s.widthMm;continue}if(s.space){o();continue}if(s.cjk){c.length>0&&o(),c=s.text,i=s.widthMm;continue}if(c.length>0&&o(),s.widthMm<=e){c=s.text,i=s.widthMm;continue}for(const _ of s.text){const E=n.measureMm(_,r);i+E>e&&c.length>0&&o(),c+=_,i+=E}}return o(),u}function p(t,e=96,r=10.5){if(t?.fontSizePx!=null)return{fontSizePt:t.fontSizePx*72/e,fontSizePx:t.fontSizePx};const n=t?.fontSize??r;return{fontSizePt:n,fontSizePx:S(n,e)}}function v(t,e=m){return{color:t?.borderColor??t?.lineColor??e,widthPt:t?.lineWidthPt??.75}}function z(t,e=M){return t?.color??e}function U(t){return t?.lineHeight??1.35}function B(t){const e=t?.borderTop!==!1,r=t?.borderRight!==!1,n=t?.borderBottom!==!1,u=t?.borderLeft!==!1;return{top:e,right:r,bottom:n,left:u,inner:e||r||n||u}}exports.CSS_DPI=96;exports.DEFAULT_BORDER_PT=.75;exports.DEFAULT_FONT_PT=10.5;exports.DEFAULT_STROKE_COLOR=m;exports.DEFAULT_TEXT_COLOR=M;exports.LINE_HEIGHT=1.35;exports.MM_PER_INCH=25.4;exports.PAPER_SIZES=x;exports.RENDER_PLAN_SCHEMA_VERSION=d;exports.SCHEMA_VERSION_JH4J=C;exports.SCHEMA_VERSION_LOCAL=A;exports.SCHEMA_VERSION_MACH=T;exports.charWidthEm=P;exports.createCanvasMeasurer=F;exports.createHeuristicMeasurer=N;exports.heuristicMeasurer=a;exports.isImageBackedComponent=O;exports.isRichText=g;exports.measureTextMm=w;exports.mmToPx=R;exports.mmToPxFactor=h;exports.ptToPx=S;exports.pxToMm=I;exports.resolveBoxBorders=B;exports.resolveFontSize=p;exports.resolveLineHeight=U;exports.resolveStroke=v;exports.resolveTextColor=z;exports.round=L;exports.toRenderPlan=H;exports.wrapText=k;
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.mrp-toolbar[data-v-
|
|
1
|
+
.mrp-toolbar[data-v-ad937777]{display:flex;align-items:center;gap:8px;padding:6px 12px;background:var(--mrp-toolbar-bg, #323639);border-bottom:1px solid var(--mrp-toolbar-border, #22252a);flex:none;flex-wrap:wrap}.mrp-title[data-v-ad937777]{font-size:13px;font-weight:600;margin-right:8px;color:var(--mrp-toolbar-fg, #e8e8e8)}.mrp-nav[data-v-ad937777]{background:transparent;color:var(--mrp-btn-fg, #cfcfcf);border:1px solid var(--mrp-btn-border, #4a4d52);border-radius:4px;padding:2px 8px;font-size:12px;cursor:pointer;white-space:nowrap}.mrp-nav[data-v-ad937777]:hover:not(:disabled){background:var(--mrp-btn-hover-bg, #414549);color:var(--mrp-btn-hover-fg, #fff)}.mrp-nav[data-v-ad937777]:disabled{opacity:.4;cursor:not-allowed}.mrp-active[data-v-ad937777]{background:var(--mrp-btn-active-bg, #2d5fb8);border-color:var(--mrp-btn-active-bg, #2d5fb8);color:#fff}.mrp-pageinfo[data-v-ad937777]{font-size:12px;min-width:56px;text-align:center;color:var(--mrp-toolbar-fg, #e8e8e8)}.mrp-spacer[data-v-ad937777]{flex:1}.mrp-search[data-v-ad937777]{display:flex;align-items:center;gap:4px}.mrp-search-input[data-v-ad937777]{background:#22252a;color:#e8e8e8;border:1px solid var(--mrp-btn-border, #4a4d52);border-radius:4px;padding:2px 8px;font-size:12px;width:150px;outline:none}.mrp-search-input[data-v-ad937777]:focus{border-color:var(--mrp-btn-active-bg, #2d5fb8)}.mrp-search-count[data-v-ad937777]{font-size:12px;color:var(--mrp-toolbar-fg, #e8e8e8);min-width:42px;text-align:center}.mach-report-preview[data-v-ee759bc4]{--mrp-shell-bg: #525659;--mrp-shell-fg: #e8e8e8;--mrp-toolbar-bg: #323639;--mrp-toolbar-border: #22252a;--mrp-toolbar-fg: #e8e8e8;--mrp-btn-fg: #cfcfcf;--mrp-btn-border: #4a4d52;--mrp-btn-hover-bg: #414549;--mrp-btn-hover-fg: #ffffff;--mrp-btn-active-bg: #2d5fb8;position:relative;display:flex;flex-direction:column;background:var(--mrp-shell-bg);color:var(--mrp-shell-fg);overflow:hidden}.mrp-main[data-v-ee759bc4]{display:flex;flex:1;min-height:0}.mrp-body[data-v-ee759bc4]{flex:1;overflow:auto;padding:24px;outline:none}.mrp-scale[data-v-ee759bc4]{margin:0 auto}.mrp-scale-inner[data-v-ee759bc4]{display:flex;flex-direction:column;align-items:center}.mrp-page-holder[data-v-ee759bc4]{background:#fff;box-shadow:0 2px 8px #00000059;margin-bottom:var(--v30a2b5ba);flex:none}.mrp-state[data-v-ee759bc4]{padding:40px;text-align:center;color:#bfbfbf;font-size:13px}.mrp-error[data-v-ee759bc4]{color:#ff9d9d}.mrp-retry[data-v-ee759bc4]{margin-left:12px;background:transparent;color:#8fb7ff;border:1px solid #5a7fbf;border-radius:4px;padding:1px 10px;cursor:pointer}.mrp-overlay[data-v-ee759bc4]{position:absolute;inset:0;pointer-events:none}.mrp-page-holder[data-v-ee759bc4] mark.mrp-hit{background:#ffe066;color:#7a5c00;border-radius:2px;padding:0 1px}.mrp-thumbs[data-v-ee759bc4]{width:140px;flex:none;overflow-y:auto;border-left:1px solid var(--mrp-toolbar-border);background:var(--mrp-toolbar-bg);padding:8px;display:flex;flex-direction:column;gap:8px}.mrp-thumb[data-v-ee759bc4]{cursor:pointer;text-align:center}.mrp-thumb-box[data-v-ee759bc4]{width:116px;background:#fff;box-shadow:0 1px 4px #0006;overflow:hidden;border:2px solid transparent}.mrp-thumb-active .mrp-thumb-box[data-v-ee759bc4]{border-color:var(--mrp-btn-active-bg)}.mrp-thumb-no[data-v-ee759bc4]{font-size:11px;color:var(--mrp-toolbar-fg)}.mrp-debug[data-v-ee759bc4]{position:absolute;right:8px;bottom:8px;background:#000000c7;color:#7ee787;font:11px/1.6 ui-monospace,monospace;padding:6px 10px;border-radius:6px;pointer-events:none;white-space:pre}
|
|
@@ -3,7 +3,20 @@ import { PlanFetcher } from './adapters';
|
|
|
3
3
|
import { MachReportMessages } from './config';
|
|
4
4
|
declare function reload(): Promise<void>;
|
|
5
5
|
declare function gotoPage(n: number): void;
|
|
6
|
-
declare
|
|
6
|
+
declare function __VLS_template(): {
|
|
7
|
+
attrs: Partial<{}>;
|
|
8
|
+
slots: {
|
|
9
|
+
default?(_: {}): any;
|
|
10
|
+
};
|
|
11
|
+
refs: {
|
|
12
|
+
viewportRef: HTMLDivElement;
|
|
13
|
+
containerRef: HTMLDivElement;
|
|
14
|
+
thumbsRef: HTMLElement;
|
|
15
|
+
};
|
|
16
|
+
rootEl: HTMLDivElement;
|
|
17
|
+
};
|
|
18
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
19
|
+
declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
7
20
|
tempId: {
|
|
8
21
|
type: PropType<string | string[] | null>;
|
|
9
22
|
default: null;
|
|
@@ -52,6 +65,11 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
52
65
|
type: StringConstructor;
|
|
53
66
|
default: undefined;
|
|
54
67
|
};
|
|
68
|
+
/** 调试面板(也可用 URL ?mrp-debug=1 开启) */
|
|
69
|
+
debug: {
|
|
70
|
+
type: BooleanConstructor;
|
|
71
|
+
default: boolean;
|
|
72
|
+
};
|
|
55
73
|
fetcher: {
|
|
56
74
|
type: PropType<PlanFetcher | null>;
|
|
57
75
|
default: null;
|
|
@@ -63,7 +81,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
63
81
|
openPdfWindow: () => void;
|
|
64
82
|
gotoPage: typeof gotoPage;
|
|
65
83
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
66
|
-
error: (message: string
|
|
84
|
+
error: (message: string, detail?: {
|
|
85
|
+
code: string;
|
|
86
|
+
cause?: unknown;
|
|
87
|
+
} | undefined) => any;
|
|
67
88
|
loaded: (pageCount: number) => any;
|
|
68
89
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
69
90
|
tempId: {
|
|
@@ -114,12 +135,20 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
114
135
|
type: StringConstructor;
|
|
115
136
|
default: undefined;
|
|
116
137
|
};
|
|
138
|
+
/** 调试面板(也可用 URL ?mrp-debug=1 开启) */
|
|
139
|
+
debug: {
|
|
140
|
+
type: BooleanConstructor;
|
|
141
|
+
default: boolean;
|
|
142
|
+
};
|
|
117
143
|
fetcher: {
|
|
118
144
|
type: PropType<PlanFetcher | null>;
|
|
119
145
|
default: null;
|
|
120
146
|
};
|
|
121
147
|
}>> & Readonly<{
|
|
122
|
-
onError?: ((message: string
|
|
148
|
+
onError?: ((message: string, detail?: {
|
|
149
|
+
code: string;
|
|
150
|
+
cause?: unknown;
|
|
151
|
+
} | undefined) => any) | undefined;
|
|
123
152
|
onLoaded?: ((pageCount: number) => any) | undefined;
|
|
124
153
|
}>, {
|
|
125
154
|
height: string;
|
|
@@ -133,9 +162,17 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
133
162
|
messages: Partial<MachReportMessages>;
|
|
134
163
|
autoLoad: boolean;
|
|
135
164
|
preset: string;
|
|
165
|
+
debug: boolean;
|
|
136
166
|
fetcher: PlanFetcher | null;
|
|
137
167
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
|
|
138
168
|
viewportRef: HTMLDivElement;
|
|
139
169
|
containerRef: HTMLDivElement;
|
|
170
|
+
thumbsRef: HTMLElement;
|
|
140
171
|
}, HTMLDivElement>;
|
|
172
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
141
173
|
export default _default;
|
|
174
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
175
|
+
new (): {
|
|
176
|
+
$slots: S;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
@@ -8,6 +8,13 @@ type __VLS_Props = {
|
|
|
8
8
|
showPrint: boolean;
|
|
9
9
|
showPdfWindow: boolean;
|
|
10
10
|
messages: MachReportMessages;
|
|
11
|
+
search: {
|
|
12
|
+
visible: boolean;
|
|
13
|
+
query: string;
|
|
14
|
+
matchIndex: number;
|
|
15
|
+
matchCount: number;
|
|
16
|
+
};
|
|
17
|
+
thumbsVisible: boolean;
|
|
11
18
|
};
|
|
12
19
|
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
13
20
|
print: () => any;
|
|
@@ -15,11 +22,19 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {
|
|
|
15
22
|
goto: (page: number) => any;
|
|
16
23
|
export: (format: "html" | "pdf") => any;
|
|
17
24
|
"pdf-window": () => any;
|
|
25
|
+
"search-input": (query: string) => any;
|
|
26
|
+
"search-nav": (dir: 1 | -1) => any;
|
|
27
|
+
"search-toggle": () => any;
|
|
28
|
+
"thumbs-toggle": () => any;
|
|
18
29
|
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
19
30
|
onPrint?: (() => any) | undefined;
|
|
20
31
|
onZoom?: ((mode: number | "fit") => any) | undefined;
|
|
21
32
|
onGoto?: ((page: number) => any) | undefined;
|
|
22
33
|
onExport?: ((format: "html" | "pdf") => any) | undefined;
|
|
23
34
|
"onPdf-window"?: (() => any) | undefined;
|
|
35
|
+
"onSearch-input"?: ((query: string) => any) | undefined;
|
|
36
|
+
"onSearch-nav"?: ((dir: 1 | -1) => any) | undefined;
|
|
37
|
+
"onSearch-toggle"?: (() => any) | undefined;
|
|
38
|
+
"onThumbs-toggle"?: (() => any) | undefined;
|
|
24
39
|
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
25
40
|
export default _default;
|
package/dist/vue/adapters.d.ts
CHANGED
|
@@ -24,10 +24,13 @@ export interface FetchRequestOptions {
|
|
|
24
24
|
/** 附加请求头(如鉴权 token) */
|
|
25
25
|
headers?: Record<string, string>;
|
|
26
26
|
credentials?: RequestCredentials;
|
|
27
|
+
/** 超时毫秒(默认 30000;超时抛 PlanLoadError) */
|
|
28
|
+
timeoutMs?: number;
|
|
27
29
|
}
|
|
28
30
|
/**
|
|
29
31
|
* 零依赖请求适配器:用全局 fetch 实现 HostRequest 签名,
|
|
30
32
|
* 让宿主无需引入 axios 或手写胶水代码即可接上 jh4j 数据面。
|
|
33
|
+
* 内置超时(AbortController)与网络/HTTP 错误语义。
|
|
31
34
|
*/
|
|
32
35
|
export declare function createFetchRequest(options?: FetchRequestOptions): HostRequest;
|
|
33
36
|
export declare function createJh4jGridPlanFetcher(options: {
|