@agile-team/mach-report 2.4.1 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -13
- package/dist/ReportPreview-Dk-28QAi.js +2946 -0
- package/dist/ReportPreview-FSvcBLjH.cjs +6 -0
- package/dist/_plugin-vue_export-helper-BHFhmbuH.cjs +1 -0
- package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
- package/dist/analytics.cjs +1 -0
- package/dist/analytics.d.cts +276 -0
- package/dist/analytics.d.ts +276 -0
- package/dist/analytics.js +223 -0
- package/dist/assets-66UBlhES.cjs +1 -0
- package/dist/assets-NVA_sftu.js +163 -0
- package/dist/capabilities-CNjIirfo.js +36 -0
- package/dist/capabilities-D4xeVYSR.cjs +1 -0
- package/dist/designer.cjs +1 -0
- package/dist/designer.d.cts +753 -0
- package/dist/designer.d.ts +753 -0
- package/dist/designer.js +372 -0
- package/dist/grid-geometry-BNptEcMm.js +65 -0
- package/dist/grid-geometry-CZ_cYB6O.cjs +1 -0
- package/dist/index.cjs +8 -5
- package/dist/index.d.cts +413 -8
- package/dist/index.d.ts +413 -8
- package/dist/index.js +1016 -1501
- package/dist/param-validation-BWNjLcN0.js +116 -0
- package/dist/param-validation-CiTxFeZ8.cjs +1 -0
- package/dist/pdf.cjs +48 -48
- package/dist/pdf.d.cts +111 -1
- package/dist/pdf.d.ts +111 -1
- package/dist/pdf.js +3931 -3868
- package/dist/{plugin-DwKr8oF6.cjs → plugin-BqBkn_kI.cjs} +1 -1
- package/dist/{plugin-CKnSVuVe.js → plugin-Ds10VnQO.js} +2 -2
- package/dist/render-plan-CckPEQyf.cjs +1 -0
- package/dist/{render-plan-CXBWRog4.js → render-plan-uzZYYSy1.js} +11 -10
- package/dist/report-params-B_VCihAh.js +12 -0
- package/dist/report-params-CjWrjPl6.cjs +1 -0
- package/dist/report-source-B9bENO0F.js +750 -0
- package/dist/report-source-BbNkkBDy.cjs +1 -0
- package/dist/server/node.d.cts +297 -0
- package/dist/server/node.d.ts +297 -0
- package/dist/server-node.cjs +1 -0
- package/dist/server-node.js +270 -0
- package/dist/server.cjs +1 -0
- package/dist/server.d.cts +643 -0
- package/dist/server.d.ts +643 -0
- package/dist/server.js +237 -0
- package/dist/style-CpwiOPyB.cjs +1 -0
- package/dist/style-Dv5o_x6b.js +67 -0
- package/dist/style.css +1 -1
- package/dist/template-registry-DWExx0gU.cjs +1 -0
- package/dist/template-registry-NpOakidD.js +354 -0
- package/dist/textwrap-CnGsEum6.cjs +4 -0
- package/dist/textwrap-DOl04hCQ.js +110 -0
- package/dist/validate-DfHPD8wX.cjs +1 -0
- package/dist/validate-S6CgIm5d.js +148 -0
- package/dist/vue/async.d.cts +694 -54
- package/dist/vue/async.d.ts +694 -54
- package/dist/vue/index.d.cts +1212 -111
- package/dist/vue/index.d.ts +1212 -111
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +167 -80
- package/dist/worker.cjs +1 -0
- package/dist/worker.d.cts +302 -0
- package/dist/worker.d.ts +302 -0
- package/dist/worker.js +133 -0
- package/dist/xlsx/node.d.cts +47 -0
- package/dist/xlsx/node.d.ts +47 -0
- package/dist/xlsx-node.cjs +221 -0
- package/dist/xlsx-node.js +36409 -0
- package/dist/xlsx.cjs +20 -20
- package/dist/xlsx.d.cts +78 -1
- package/dist/xlsx.d.ts +78 -1
- package/dist/xlsx.js +5974 -5831
- package/package.json +62 -2
- package/dist/ReportPreview-BVTpw9Tb.cjs +0 -6
- package/dist/ReportPreview-XF8iSUG1.js +0 -1910
- package/dist/grid-geometry-BNIvw52m.cjs +0 -1
- package/dist/grid-geometry-C8hGoe9o.js +0 -130
- package/dist/render-plan-CCTL4F9v.cjs +0 -1
- package/dist/report-params-B3Fia6JO.js +0 -10
- package/dist/report-params-D1gZ1DME.cjs +0 -1
- package/dist/textwrap-nH0UYU6D.js +0 -108
- package/dist/textwrap-oD-t4b4B.cjs +0 -4
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const p=require("./render-plan-CCTL4F9v.cjs"),F=25.4,x=96;function T(o=x){return o/F}function D(o,t=x){return(o||0)*T(t)}function O(o,t=x){return o/T(t)}function B(o,t=x){return o*t/72}function k(o,t){const s=10**t;return Math.round(o*s)/s}const $={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}};function y(o,t=96,s=p.DEFAULT_FONT_PT){if(o?.fontSizePx!=null)return{fontSizePt:o.fontSizePx*72/t,fontSizePx:o.fontSizePx};const c=o?.fontSize??s;return{fontSizePt:c,fontSizePx:B(c,t)}}function N(o,t=p.DEFAULT_STROKE_COLOR){return{color:o?.borderColor??o?.lineColor??t,widthPt:o?.lineWidthPt??p.DEFAULT_BORDER_PT}}function U(o,t=p.DEFAULT_TEXT_COLOR){return o?.color??t}function G(o){return o?.lineHeight??p.LINE_HEIGHT}function K(o){const t=o?.borderTop!==!1,s=o?.borderRight!==!1,c=o?.borderBottom!==!1,l=o?.borderLeft!==!1;return{top:t,right:s,bottom:c,left:l,inner:t||s||c||l}}function W(o,t){const s={...o,...t};return t?.fontSize!=null&&t.fontSizePx==null&&delete s.fontSizePx,t?.fontSizePx!=null&&t.fontSize==null&&delete s.fontSize,s}function Z(o,t){const s=o.length;if(s===0)return[];const c=o.reduce((h,f)=>h+f,0),l=c>0&&t>0?t/c:1,i=[];let m=0;for(let h=0;h<s;h++){const f=Math.max(0,o[h]*l);i.push({pos:m,size:f}),m+=f}return i}function b(o,t,s){return o?.length?Z(o,t):Array.from({length:s},(c,l)=>({pos:t*l/s,size:t/s}))}function q(o,t,s){const c=o.cells??[],l=Math.max(c.length,1),i=o.colWidthsMm?.length??Math.max(1,...c.map(n=>Array.isArray(n)?n.length:0)),m=b(o.colWidthsMm,t,i),h=n=>n<=0?0:n>=i?m[m.length-1].pos+m[m.length-1].size:m[n].pos,f=b(o.rowHeightsMm,s,l),d=n=>n<=0?0:n>=l?f[f.length-1].pos+f[f.length-1].size:f[n].pos,w=new Set,E=(n,r)=>`${n}:${r}`,_=[],z=new Set,C=new Set,v=(n,r)=>`v${n}:${r}`,A=(n,r)=>`h${n}:${r}`;c.forEach((n,r)=>{if(!Array.isArray(n))return;let e=0;for(const S of n){for(;e<i&&w.has(E(r,e));)e++;if(e>=i)break;const H=Math.max(1,Math.min(S?.colSpan??1,i-e)),I=Math.max(1,S?.rowSpan??1),g=Math.min(l,r+I),P=Math.min(i,e+H);for(let u=r;u<g;u++)for(let a=e;a<P;a++)w.add(E(u,a));for(let u=e+1;u<P;u++)for(let a=r;a<g;a++)z.add(v(u,a));for(let u=r+1;u<g;u++)for(let a=e;a<P;a++)C.add(A(u,a));const L=h(e),R=d(r);_.push({ri:r,ci:e,cell:S??{},xMm:L,yMm:R,widthMm:h(P)-L,heightMm:d(g)-R}),e=P}});const M=[];for(let n=1;n<i;n++){let r=-1;for(let e=0;e<=l;e++){const S=e<l&&!z.has(v(n,e));S&&r<0&&(r=e),!S&&r>=0&&(M.push({kind:"v",pos:h(n),from:d(r),to:d(e)}),r=-1)}}for(let n=1;n<l;n++){let r=-1;for(let e=0;e<=i;e++){const S=e<i&&!C.has(A(n,e));S&&r<0&&(r=e),!S&&r>=0&&(M.push({kind:"h",pos:d(n),from:h(r),to:h(e)}),r=-1)}}return{columns:m,rows:f,cells:_,edges:M}}exports.CSS_DPI=x;exports.MM_PER_INCH=F;exports.PAPER_SIZES=$;exports.mergeComponentStyles=W;exports.mmToPx=D;exports.mmToPxFactor=T;exports.ptToPx=B;exports.pxToMm=O;exports.resolveBoxBorders=K;exports.resolveFontSize=y;exports.resolveGridLayout=q;exports.resolveLineHeight=G;exports.resolveStroke=N;exports.resolveTextColor=U;exports.round=k;
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { D as F, d as O, a as B, L as H, c as $ } from "./render-plan-CXBWRog4.js";
|
|
2
|
-
const k = 25.4, M = 96;
|
|
3
|
-
function R(t = M) {
|
|
4
|
-
return t / k;
|
|
5
|
-
}
|
|
6
|
-
function K(t, o = M) {
|
|
7
|
-
return (t || 0) * R(o);
|
|
8
|
-
}
|
|
9
|
-
function N(t, o = M) {
|
|
10
|
-
return t / R(o);
|
|
11
|
-
}
|
|
12
|
-
function I(t, o = M) {
|
|
13
|
-
return t * o / 72;
|
|
14
|
-
}
|
|
15
|
-
function W(t, o) {
|
|
16
|
-
const s = 10 ** o;
|
|
17
|
-
return Math.round(t * s) / s;
|
|
18
|
-
}
|
|
19
|
-
const G = {
|
|
20
|
-
a3: { widthMm: 297, heightMm: 420 },
|
|
21
|
-
a4: { widthMm: 210, heightMm: 297 },
|
|
22
|
-
a5: { widthMm: 148, heightMm: 210 },
|
|
23
|
-
b4: { widthMm: 250, heightMm: 353 },
|
|
24
|
-
b5: { widthMm: 176, heightMm: 250 }
|
|
25
|
-
};
|
|
26
|
-
function X(t, o = 96, s = F) {
|
|
27
|
-
if (t?.fontSizePx != null)
|
|
28
|
-
return { fontSizePt: t.fontSizePx * 72 / o, fontSizePx: t.fontSizePx };
|
|
29
|
-
const c = t?.fontSize ?? s;
|
|
30
|
-
return { fontSizePt: c, fontSizePx: I(c, o) };
|
|
31
|
-
}
|
|
32
|
-
function Z(t, o = O) {
|
|
33
|
-
return {
|
|
34
|
-
color: t?.borderColor ?? t?.lineColor ?? o,
|
|
35
|
-
widthPt: t?.lineWidthPt ?? $
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function j(t, o = B) {
|
|
39
|
-
return t?.color ?? o;
|
|
40
|
-
}
|
|
41
|
-
function q(t) {
|
|
42
|
-
return t?.lineHeight ?? H;
|
|
43
|
-
}
|
|
44
|
-
function J(t) {
|
|
45
|
-
const o = t?.borderTop !== !1, s = t?.borderRight !== !1, c = t?.borderBottom !== !1, i = t?.borderLeft !== !1;
|
|
46
|
-
return { top: o, right: s, bottom: c, left: i, inner: o || s || c || i };
|
|
47
|
-
}
|
|
48
|
-
function Q(t, o) {
|
|
49
|
-
const s = { ...t, ...o };
|
|
50
|
-
return o?.fontSize != null && o.fontSizePx == null && delete s.fontSizePx, o?.fontSizePx != null && o.fontSize == null && delete s.fontSize, s;
|
|
51
|
-
}
|
|
52
|
-
function U(t, o) {
|
|
53
|
-
const s = t.length;
|
|
54
|
-
if (s === 0) return [];
|
|
55
|
-
const c = t.reduce((l, f) => l + f, 0), i = c > 0 && o > 0 ? o / c : 1, a = [];
|
|
56
|
-
let m = 0;
|
|
57
|
-
for (let l = 0; l < s; l++) {
|
|
58
|
-
const f = Math.max(0, t[l] * i);
|
|
59
|
-
a.push({ pos: m, size: f }), m += f;
|
|
60
|
-
}
|
|
61
|
-
return a;
|
|
62
|
-
}
|
|
63
|
-
function b(t, o, s) {
|
|
64
|
-
return t?.length ? U(t, o) : Array.from({ length: s }, (c, i) => ({
|
|
65
|
-
pos: o * i / s,
|
|
66
|
-
size: o / s
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
function V(t, o, s) {
|
|
70
|
-
const c = t.cells ?? [], i = Math.max(c.length, 1), a = t.colWidthsMm?.length ?? Math.max(1, ...c.map((n) => Array.isArray(n) ? n.length : 0)), m = b(t.colWidthsMm, o, a), l = (n) => n <= 0 ? 0 : n >= a ? m[m.length - 1].pos + m[m.length - 1].size : m[n].pos, f = b(t.rowHeightsMm, s, i), S = (n) => n <= 0 ? 0 : n >= i ? f[f.length - 1].pos + f[f.length - 1].size : f[n].pos, x = /* @__PURE__ */ new Set(), w = (n, r) => `${n}:${r}`, T = [], z = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Set(), _ = (n, r) => `v${n}:${r}`, A = (n, r) => `h${n}:${r}`;
|
|
71
|
-
c.forEach((n, r) => {
|
|
72
|
-
if (!Array.isArray(n)) return;
|
|
73
|
-
let e = 0;
|
|
74
|
-
for (const d of n) {
|
|
75
|
-
for (; e < a && x.has(w(r, e)); ) e++;
|
|
76
|
-
if (e >= a) break;
|
|
77
|
-
const v = Math.max(1, Math.min(d?.colSpan ?? 1, a - e)), D = Math.max(1, d?.rowSpan ?? 1), g = Math.min(i, r + D), p = Math.min(a, e + v);
|
|
78
|
-
for (let h = r; h < g; h++)
|
|
79
|
-
for (let u = e; u < p; u++)
|
|
80
|
-
x.add(w(h, u));
|
|
81
|
-
for (let h = e + 1; h < p; h++)
|
|
82
|
-
for (let u = r; u < g; u++) z.add(_(h, u));
|
|
83
|
-
for (let h = r + 1; h < g; h++)
|
|
84
|
-
for (let u = e; u < p; u++) E.add(A(h, u));
|
|
85
|
-
const C = l(e), L = S(r);
|
|
86
|
-
T.push({
|
|
87
|
-
ri: r,
|
|
88
|
-
ci: e,
|
|
89
|
-
cell: d ?? {},
|
|
90
|
-
xMm: C,
|
|
91
|
-
yMm: L,
|
|
92
|
-
widthMm: l(p) - C,
|
|
93
|
-
heightMm: S(g) - L
|
|
94
|
-
}), e = p;
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
const P = [];
|
|
98
|
-
for (let n = 1; n < a; n++) {
|
|
99
|
-
let r = -1;
|
|
100
|
-
for (let e = 0; e <= i; e++) {
|
|
101
|
-
const d = e < i && !z.has(_(n, e));
|
|
102
|
-
d && r < 0 && (r = e), !d && r >= 0 && (P.push({ kind: "v", pos: l(n), from: S(r), to: S(e) }), r = -1);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
for (let n = 1; n < i; n++) {
|
|
106
|
-
let r = -1;
|
|
107
|
-
for (let e = 0; e <= a; e++) {
|
|
108
|
-
const d = e < a && !E.has(A(n, e));
|
|
109
|
-
d && r < 0 && (r = e), !d && r >= 0 && (P.push({ kind: "h", pos: S(n), from: l(r), to: l(e) }), r = -1);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return { columns: m, rows: f, cells: T, edges: P };
|
|
113
|
-
}
|
|
114
|
-
export {
|
|
115
|
-
M as C,
|
|
116
|
-
k as M,
|
|
117
|
-
G as P,
|
|
118
|
-
W as a,
|
|
119
|
-
q as b,
|
|
120
|
-
Z as c,
|
|
121
|
-
J as d,
|
|
122
|
-
V as e,
|
|
123
|
-
K as f,
|
|
124
|
-
j as g,
|
|
125
|
-
R as h,
|
|
126
|
-
N as i,
|
|
127
|
-
Q as m,
|
|
128
|
-
I as p,
|
|
129
|
-
X as r
|
|
130
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const T="#333333",n="#000000",_="1.0.0-mach",t=_;function R(E){return(E.kind==="image"||E.kind==="barcode"||E.kind==="qrcode"||E.kind==="chart")&&!!E.imageData}function A(E){return E.kind==="text"&&Array.isArray(E.richParagraphs)&&E.richParagraphs.length>0}exports.DEFAULT_BORDER_PT=.75;exports.DEFAULT_FONT_PT=10.5;exports.DEFAULT_STROKE_COLOR=T;exports.DEFAULT_TEXT_COLOR=n;exports.LINE_HEIGHT=1.35;exports.RENDER_PLAN_SCHEMA_VERSION=t;exports.SCHEMA_VERSION_MACH=_;exports.isImageBackedComponent=R;exports.isRichText=A;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
function s(e, f) {
|
|
2
|
-
const a = /* @__PURE__ */ new Set();
|
|
3
|
-
return f.flatMap((r) => {
|
|
4
|
-
const t = Object.prototype.hasOwnProperty.call(e, r) ? e[r] : void 0;
|
|
5
|
-
return (t?.params ?? (typeof t?.template == "function" ? [] : t?.template.params) ?? []).filter((n) => a.has(n.field) ? !1 : (a.add(n.field), !0));
|
|
6
|
-
});
|
|
7
|
-
}
|
|
8
|
-
export {
|
|
9
|
-
s as g
|
|
10
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function f(e,s){const a=new Set;return s.flatMap(r=>{const t=Object.prototype.hasOwnProperty.call(e,r)?e[r]:void 0;return(t?.params??(typeof t?.template=="function"?[]:t?.template.params)??[]).filter(n=>a.has(n.field)?!1:(a.add(n.field),!0))})}exports.getReportParamDefs=f;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
const l = /[\u3000-\u9fff\uff00-\uffef]/, s = new Uint8Array(128);
|
|
2
|
-
{
|
|
3
|
-
for (const t of "iljtf.,:;'`|!()[]") s[t.charCodeAt(0)] = 1;
|
|
4
|
-
for (const t of "mwMW@") s[t.charCodeAt(0)] = 2;
|
|
5
|
-
for (let t = 48; t <= 57; t++) s[t] = 3;
|
|
6
|
-
for (let t = 65; t <= 90; t++) s[t] = 4;
|
|
7
|
-
s[32] = 5;
|
|
8
|
-
}
|
|
9
|
-
const d = [0.54, 0.26, 0.95, 0.59, 0.67, 0.3];
|
|
10
|
-
function M(t) {
|
|
11
|
-
const e = t.charCodeAt(0);
|
|
12
|
-
return e < 128 ? d[s[e]] : l.test(t) ? 1 : /[A-Z]/.test(t) ? 0.67 : 0.54;
|
|
13
|
-
}
|
|
14
|
-
const a = {
|
|
15
|
-
measureMm(t, e) {
|
|
16
|
-
const { fontSizePt: i, bold: f = !1, letterSpacingPt: o = 0 } = e, c = 25.4 / 72;
|
|
17
|
-
let r = 0;
|
|
18
|
-
for (const n of t)
|
|
19
|
-
r += M(n);
|
|
20
|
-
return f && (r *= 1.04), (r * i + o * t.length) * c;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
function p() {
|
|
24
|
-
return a;
|
|
25
|
-
}
|
|
26
|
-
function x(t, e) {
|
|
27
|
-
return a.measureMm(t, e);
|
|
28
|
-
}
|
|
29
|
-
function A(t) {
|
|
30
|
-
let e;
|
|
31
|
-
return {
|
|
32
|
-
measureMm(i, f) {
|
|
33
|
-
if (e === void 0 && (e = t()), !e) return a.measureMm(i, f);
|
|
34
|
-
const o = f.fontSizePt * 96 / 72;
|
|
35
|
-
return e.font = `${f.bold ? "bold " : ""}${o}px sans-serif`, e.measureText(i).width * 25.4 / 96;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function w(t, e, i) {
|
|
40
|
-
const f = [];
|
|
41
|
-
let o = "", c = 0;
|
|
42
|
-
const r = () => {
|
|
43
|
-
o && (f.push({ text: o, widthMm: c, cjk: !1 }), o = "", c = 0);
|
|
44
|
-
};
|
|
45
|
-
for (const n of t) {
|
|
46
|
-
if (n === `
|
|
47
|
-
`) {
|
|
48
|
-
r(), f.push({ text: `
|
|
49
|
-
`, widthMm: 0, cjk: !1, br: !0 });
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (n === " ") {
|
|
53
|
-
r(), f.push({ text: n, widthMm: i.measureMm(n, e), cjk: !1, space: !0 });
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
if (l.test(n)) {
|
|
57
|
-
r(), f.push({ text: n, widthMm: i.measureMm(n, e), cjk: !0 });
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
o += n, c += i.measureMm(n, e);
|
|
61
|
-
}
|
|
62
|
-
return r(), f;
|
|
63
|
-
}
|
|
64
|
-
function T(t, e, i, f = a) {
|
|
65
|
-
if (!t) return [""];
|
|
66
|
-
t = t.replace(/\r\n?/g, `
|
|
67
|
-
`);
|
|
68
|
-
const o = [];
|
|
69
|
-
let c = "", r = 0;
|
|
70
|
-
const n = () => {
|
|
71
|
-
o.push(c), c = "", r = 0;
|
|
72
|
-
};
|
|
73
|
-
for (const u of w(t, i, f)) {
|
|
74
|
-
if (u.br) {
|
|
75
|
-
n();
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
if (r + u.widthMm <= e) {
|
|
79
|
-
c += u.text, r += u.widthMm;
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
if (u.space) {
|
|
83
|
-
n();
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (u.cjk) {
|
|
87
|
-
c.length > 0 && n(), c = u.text, r = u.widthMm;
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (c.length > 0 && n(), u.widthMm <= e) {
|
|
91
|
-
c = u.text, r = u.widthMm;
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
for (const h of u.text) {
|
|
95
|
-
const m = f.measureMm(h, i);
|
|
96
|
-
r + m > e && c.length > 0 && n(), c += h, r += m;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return n(), o;
|
|
100
|
-
}
|
|
101
|
-
export {
|
|
102
|
-
A as a,
|
|
103
|
-
p as b,
|
|
104
|
-
M as c,
|
|
105
|
-
a as h,
|
|
106
|
-
x as m,
|
|
107
|
-
T as w
|
|
108
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";const M=/[\u3000-\u9fff\uff00-\uffef]/,o=new Uint8Array(128);{for(const t of"iljtf.,:;'`|!()[]")o[t.charCodeAt(0)]=1;for(const t of"mwMW@")o[t.charCodeAt(0)]=2;for(let t=48;t<=57;t++)o[t]=3;for(let t=65;t<=90;t++)o[t]=4;o[32]=5}const d=[.54,.26,.95,.59,.67,.3];function l(t){const e=t.charCodeAt(0);return e<128?d[o[e]]:M.test(t)?1:/[A-Z]/.test(t)?.67:.54}const a={measureMm(t,e){const{fontSizePt:s,bold:u=!1,letterSpacingPt:f=0}=e,c=25.4/72;let n=0;for(const r of t)n+=l(r);return u&&(n*=1.04),(n*s+f*t.length)*c}};function w(){return a}function p(t,e){return a.measureMm(t,e)}function x(t){let e;return{measureMm(s,u){if(e===void 0&&(e=t()),!e)return a.measureMm(s,u);const f=u.fontSizePt*96/72;return e.font=`${u.bold?"bold ":""}${f}px sans-serif`,e.measureText(s).width*25.4/96}}}function T(t,e,s){const u=[];let f="",c=0;const n=()=>{f&&(u.push({text:f,widthMm:c,cjk:!1}),f="",c=0)};for(const r of t){if(r===`
|
|
2
|
-
`){n(),u.push({text:`
|
|
3
|
-
`,widthMm:0,cjk:!1,br:!0});continue}if(r===" "){n(),u.push({text:r,widthMm:s.measureMm(r,e),cjk:!1,space:!0});continue}if(M.test(r)){n(),u.push({text:r,widthMm:s.measureMm(r,e),cjk:!0});continue}f+=r,c+=s.measureMm(r,e)}return n(),u}function A(t,e,s,u=a){if(!t)return[""];t=t.replace(/\r\n?/g,`
|
|
4
|
-
`);const f=[];let c="",n=0;const r=()=>{f.push(c),c="",n=0};for(const i of T(t,s,u)){if(i.br){r();continue}if(n+i.widthMm<=e){c+=i.text,n+=i.widthMm;continue}if(i.space){r();continue}if(i.cjk){c.length>0&&r(),c=i.text,n=i.widthMm;continue}if(c.length>0&&r(),i.widthMm<=e){c=i.text,n=i.widthMm;continue}for(const h of i.text){const m=u.measureMm(h,s);n+m>e&&c.length>0&&r(),c+=h,n+=m}}return r(),f}exports.charWidthEm=l;exports.createCanvasMeasurer=x;exports.createHeuristicMeasurer=w;exports.heuristicMeasurer=a;exports.measureTextMm=p;exports.wrapText=A;
|