@agile-team/mach-report 0.8.0 → 0.9.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/LICENSE +107 -0
- package/dist/ReportPreview-D-Us9mrX.cjs +6 -0
- package/dist/ReportPreview-VCx59rSt.js +926 -0
- package/dist/format.d.ts +16 -3
- package/dist/index.cjs +4 -4
- package/dist/index.js +433 -419
- package/dist/layout/paginate.d.ts +1 -2
- package/dist/{plugin-Bc6Px9Lq.js → plugin-Bo8QqzCz.js} +1 -1
- package/dist/{plugin-7W2Zy3Xc.cjs → plugin-Dh1exwdD.cjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/vue/ReportPreview.d.ts +1 -1
- package/dist/vue/ReportToolbar.d.ts +5 -3
- package/dist/vue/async.d.cts +3 -3
- package/dist/vue/async.d.ts +3 -3
- package/dist/vue/composables/usePageWindow.d.ts +0 -3
- package/dist/vue/composables/usePrintExport.d.ts +1 -0
- package/dist/vue/composables/useReportSearch.d.ts +72 -0
- package/dist/vue/config.d.ts +8 -1
- package/dist/vue/plugin.d.ts +3 -3
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +26 -25
- package/dist/xlsx.cjs +4 -4
- package/dist/xlsx.js +31 -30
- package/package.json +3 -1
- package/dist/ReportPreview-BQE0C_37.cjs +0 -6
- package/dist/ReportPreview-D8X75aLV.js +0 -825
package/LICENSE
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
MachReport Source-Available License 1.0
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ChenyCHENYU (Agile Team). All rights reserved.
|
|
4
|
+
|
|
5
|
+
IMPORTANT: The source code is publicly visible for review, but it is not
|
|
6
|
+
open-source software as defined by the Open Source Initiative. Except for the
|
|
7
|
+
limited inspection permission below, no permission is granted unless the
|
|
8
|
+
copyright holder gives you prior written authorization.
|
|
9
|
+
|
|
10
|
+
1. Definitions
|
|
11
|
+
|
|
12
|
+
"Software" means MachReport and all source code, object code, packages,
|
|
13
|
+
documentation, examples, designs, assets, and other materials distributed with
|
|
14
|
+
this license.
|
|
15
|
+
|
|
16
|
+
"Licensor" means ChenyCHENYU (Agile Team), the copyright holder of the
|
|
17
|
+
Software.
|
|
18
|
+
|
|
19
|
+
"Written Authorization" means a durable written permission issued directly by
|
|
20
|
+
the Licensor that identifies the licensee and the permitted scope, purpose,
|
|
21
|
+
environment, term, and any other applicable conditions.
|
|
22
|
+
|
|
23
|
+
2. Limited Inspection Permission
|
|
24
|
+
|
|
25
|
+
You may view the Software on the repository hosting service solely to inspect
|
|
26
|
+
and evaluate it, to link to its public repository, to discuss it, and to submit
|
|
27
|
+
good-faith issue reports. This limited permission does not include permission
|
|
28
|
+
to use, run, build, compile, copy, download for reuse, install, integrate,
|
|
29
|
+
modify, create derivative works from, deploy, distribute, sublicense, sell,
|
|
30
|
+
lease, provide as a service, or otherwise exploit the Software.
|
|
31
|
+
|
|
32
|
+
3. Authorization Required
|
|
33
|
+
|
|
34
|
+
Any use beyond Section 2 requires the Licensor's prior Written Authorization.
|
|
35
|
+
This requirement applies to personal, educational, research, governmental,
|
|
36
|
+
non-profit, internal, evaluation, testing, development, staging, production,
|
|
37
|
+
and commercial use. Possession of a copy, cloning the repository, downloading
|
|
38
|
+
an npm package, receiving the Software from another person, or submitting a
|
|
39
|
+
contribution does not grant any additional rights.
|
|
40
|
+
|
|
41
|
+
The Licensor may grant separate commercial or non-commercial terms in a
|
|
42
|
+
written agreement. If such an agreement conflicts with this license, that
|
|
43
|
+
agreement controls only for the licensee and scope identified in it.
|
|
44
|
+
|
|
45
|
+
4. Restrictions
|
|
46
|
+
|
|
47
|
+
Without prior Written Authorization, you must not, directly or indirectly:
|
|
48
|
+
|
|
49
|
+
a. use, execute, build, compile, install, test, or integrate the Software;
|
|
50
|
+
b. copy, reproduce, modify, adapt, translate, or create derivative works;
|
|
51
|
+
c. publish, distribute, sublicense, sell, rent, lease, transfer, host, or make
|
|
52
|
+
the Software available to any third party;
|
|
53
|
+
d. use the Software to provide a hosted, managed, consulting, outsourcing,
|
|
54
|
+
software-as-a-service, or other service;
|
|
55
|
+
e. remove or alter copyright, authorization, trademark, attribution, or other
|
|
56
|
+
proprietary notices; or
|
|
57
|
+
f. represent the Software as open source or represent that you have received
|
|
58
|
+
authorization when you have not.
|
|
59
|
+
|
|
60
|
+
5. Contributions
|
|
61
|
+
|
|
62
|
+
Submitting a patch, pull request, code, documentation, design, or other
|
|
63
|
+
material to the project does not authorize you to use the Software. Unless a
|
|
64
|
+
separate written contributor agreement applies, by intentionally submitting a
|
|
65
|
+
contribution you represent that you have the right to submit it and grant the
|
|
66
|
+
Licensor a perpetual, worldwide, irrevocable, transferable, sublicensable,
|
|
67
|
+
royalty-free license to use, reproduce, modify, create derivative works from,
|
|
68
|
+
distribute, license, and relicense that contribution as part of the Software.
|
|
69
|
+
|
|
70
|
+
6. Ownership and Trademarks
|
|
71
|
+
|
|
72
|
+
The Software is licensed, not sold. The Licensor and applicable contributors
|
|
73
|
+
retain all right, title, and interest in the Software. No trademark, service
|
|
74
|
+
mark, trade name, logo, or branding rights are granted by this license.
|
|
75
|
+
|
|
76
|
+
7. Termination
|
|
77
|
+
|
|
78
|
+
Any permission granted under this license terminates automatically upon breach.
|
|
79
|
+
On termination, you must immediately stop all use and destroy all copies in
|
|
80
|
+
your possession or control, except where retention is required by law. Sections
|
|
81
|
+
4 through 9 survive termination.
|
|
82
|
+
|
|
83
|
+
8. Disclaimer
|
|
84
|
+
|
|
85
|
+
TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" AND
|
|
86
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
|
|
88
|
+
NON-INFRINGEMENT.
|
|
89
|
+
|
|
90
|
+
9. Limitation of Liability
|
|
91
|
+
|
|
92
|
+
TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE LICENSOR AND CONTRIBUTORS WILL NOT
|
|
93
|
+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|
94
|
+
CONSEQUENTIAL, OR OTHER DAMAGES, OR FOR LOSS OF DATA, PROFITS, REVENUE,
|
|
95
|
+
GOODWILL, OR BUSINESS INTERRUPTION, ARISING FROM OR RELATED TO THE SOFTWARE OR
|
|
96
|
+
THIS LICENSE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
97
|
+
|
|
98
|
+
10. Contact and Authorization
|
|
99
|
+
|
|
100
|
+
See LICENSING.md in the repository for the authorization request process. No
|
|
101
|
+
request, discussion, issue, payment, or contribution constitutes authorization
|
|
102
|
+
unless and until the Licensor issues explicit Written Authorization.
|
|
103
|
+
|
|
104
|
+
涓枃璇存槑锛堜粎涓洪槄璇讳究鍒╋紱濡傛湁鍐茬獊锛屼互鑻辨枃鏉℃涓哄噯锛?
|
|
105
|
+
鏈」鐩簮浠g爜鍏紑鍙煡鐪嬶紝浣嗕笉鏄?OSI 瀹氫箟涓嬬殑寮€婧愯蒋浠躲€傞櫎鏌ョ湅銆侀摼鎺ャ€?璁ㄨ鍜屽杽鎰忔彁浜ら棶棰樺锛屼换浣曚釜浜恒€佹暀鑲层€佺爺绌躲€佸叕鐩娿€佹斂搴溿€佸唴閮ㄣ€佹祴璇曘€?寮€鍙戙€佺敓浜ф垨鍟嗕笟鐢ㄩ€旓紝鍧囬』浜嬪厛鍙栧緱浣滆€呮槑纭殑涔﹂潰鎺堟潈銆傛湭缁忔巿鏉冿紝涓嶅緱
|
|
106
|
+
杩愯銆佹瀯寤恒€佸鍒躲€佷慨鏀广€侀泦鎴愩€侀儴缃层€佸垎鍙戙€佽浆鎺堟潈銆侀攢鍞€佸嚭绉熴€佹墭绠℃垨
|
|
107
|
+
浠ユ湇鍔″舰寮忔彁渚涙湰杞欢銆傚叕寮€浠撳簱銆佸厠闅嗕唬鐮佹垨涓嬭浇 npm 鍖呬笉浠h〃鑾峰緱鎺堟潈銆?
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";const e=require("vue"),U=require("@agile-team/mach-report"),T=require("./plugin-Dh1exwdD.cjs");function pe(t,r,l={}){const n=l.pxPerMm??3.7795275590551185,a=l.gapPx??18,o=e.ref(0),s=e.ref(800),i=e.computed(()=>(t.value?.pages??[]).map(c=>c.pageHeightMm*n)),m=e.computed(()=>{const c=t.value?.pages??[];let p=0,f=0;for(const b of c)p+=b.pageHeightMm*n+a,f=Math.max(f,b.pageWidthMm*n);return{w:f,h:p}}),h=e.computed(()=>U.computePageWindow({pageHeightsPx:i.value,viewportHeightPx:s.value/r.value,scrollTopPx:o.value/r.value,overscan:1,gapPx:a})),g=e.computed(()=>{const c=t.value;if(!c)return[];const{start:p,end:f}=h.value;return f<p?[]:c.pages.slice(p,f+1).map((b,E)=>({page:b,index:p+E}))});function u(c,p){let f=0;return b=>{f||(f=requestAnimationFrame(()=>{if(f=0,o.value=b.scrollTop,s.value=b.clientHeight||800,p.value<=0)return;const E=b.querySelectorAll(".mrp-page-holder");if(!E.length)return;const B=b.getBoundingClientRect().top+56;let $=1;E.forEach(w=>{w.getBoundingClientRect().top<=B&&($=Number(w.dataset.page??1))}),c.value=Math.max(1,Math.min(p.value,$))}))}}return{contentSize:m,windowRange:h,visiblePages:g,makeScrollHandler:u,refreshViewport(c){c&&(s.value=c.clientHeight||800)}}}function fe(t){const r=e.ref(1),l=e.ref("fit");function n(){requestAnimationFrame(()=>{const o=t();!o||!o.viewport||(r.value=Math.min(1,Math.max(.3,(o.viewport.clientWidth-48)/Math.max(1,o.pageWidthPx))))})}function a(o){o==="fit"?(l.value="fit",n()):(l.value="raw",r.value=o/100)}return{zoom:r,zoomMode:l,applyFitZoom:n,setZoom:a}}const X=8;function Q(){return new Promise(t=>setTimeout(t,0))}function Z(t){return`p${Math.round(t.pageWidthMm)}x${Math.round(t.pageHeightMm)}`}function j(t){const r=new Map;t.pages.forEach(s=>{r.has(Z(s))||r.set(Z(s),s)});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
|
+
${[...r.values()].map(s=>`@page ${Z(s)}{size:${Math.round(s.pageWidthMm)}mm ${Math.round(s.pageHeightMm)}mm;margin:0;}`).join(`
|
|
5
|
+
`)}
|
|
6
|
+
body{margin:0;background:#fff;}`}</style></head><body>`,o=t.pages.map(s=>{const i=U.renderPage(s,96,{},document);return i.style.page=Z(s),i.outerHTML});return{head:a,pageChunks:o}}async function Ve(t,r={}){const l={pages:t.flatMap(i=>i.pages)};if(l.pages.length===0)return;const{head:n,pageChunks:a}=j(l),o=document.createElement("iframe");o.style.cssText="position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;",document.body.appendChild(o);let s=!1;try{const i=o.contentDocument;i.open(),i.write(n);for(let m=0;m<a.length;m++)i.write(a[m]),m%X===X-1&&(r.onProgress?.(m+1,a.length),await Q());i.write("</body></html>"),i.close(),await Q(),r.onProgress?.(a.length,a.length),s=!0,o.contentWindow?.focus(),o.contentWindow?.print()}catch(i){r.onError?.(i instanceof Error?`批量打印失败: ${i.message}`:"批量打印失败")}finally{s?setTimeout(()=>o.remove(),6e4):o.remove()}}function ge(t,r){let l=null,n=!1,a=null;function o(){l?.remove(),l=null}function s(u,c){const p=URL.createObjectURL(u),f=document.createElement("a");f.href=p,f.download=c,f.click(),setTimeout(()=>URL.revokeObjectURL(p),1e4)}async function i(){if(n)return;const u=t.value;if(!u||u.pages.length===0)return;n=!0,o();const{head:c,pageChunks:p}=j(u);l=document.createElement("iframe"),l.style.cssText="position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;",document.body.appendChild(l);const f=l;try{const b=f.contentDocument;b.open(),b.write(c);for(let E=0;E<p.length;E++)if(b.write(p[E]),E%X===X-1&&await Q(),f!==l)return;b.write("</body></html>"),b.close(),await Q(),f.contentWindow?.focus(),f.contentWindow?.print()}catch{r.onError("调用打印失败,请改用导出 PDF")}finally{n=!1}}async function m(){if(a)return a;const u=t.value;if(!(!u||u.pages.length===0))return a=(async()=>{try{const c=await r.getPdfExporter()(u);s(new Blob([c],{type:"application/pdf"}),"mach-report.pdf")}catch(c){r.onError(c instanceof Error?`PDF 导出失败: ${c.message}`:"PDF 导出失败")}finally{a=null}})(),a}function h(u){const c=t.value;if(!c||c.pages.length===0)return;if(u==="pdf"){m();return}const{head:p,pageChunks:f}=j(c),b=`${p}${f.join("")}</body></html>`;s(new Blob([b],{type:"text/html;charset=utf-8"}),`mach-report.${u==="html"?"html":u}`)}function g(){const u=t.value;if(!u||u.pages.length===0)return;const{head:c,pageChunks:p}=j(u),f=`${c}${p.join("")}</body></html>`,b=new Blob([f],{type:"text/html;charset=utf-8"}),E=URL.createObjectURL(b),B=window.open(E,"_blank");if(!B){r.onError("浏览器拦截了弹窗,请允许弹窗后重试"),URL.revokeObjectURL(E);return}setTimeout(()=>B.print(),400),setTimeout(()=>URL.revokeObjectURL(E),1e4)}return{print:i,exportAs:h,openPdfWindow:g,releasePrintFrame:o}}const he="mrp-hit";function Le(t){t.querySelectorAll(`mark.${he}`).forEach(l=>{const n=l.parentNode;if(n){for(;l.firstChild;)n.insertBefore(l.firstChild,l);l.remove(),n.normalize()}})}function Oe(t,r){const l=r.trim();if(!l)return 0;const n=l.toLowerCase(),a=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(i){const m=i.parentElement;return!m||m.closest("mark")||/^(SCRIPT|STYLE)$/.test(m.tagName)?NodeFilter.FILTER_REJECT:(i.nodeValue??"").toLowerCase().includes(n)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),o=[];for(let i=a.nextNode();i;i=a.nextNode())o.push(i);let s=0;for(const i of o){const m=i.nodeValue??"",h=m.toLowerCase(),g=i.parentElement;if(!g)continue;const u=document.createDocumentFragment();let c=0,p=h.indexOf(n);for(;p>=0;){p>c&&u.appendChild(document.createTextNode(m.slice(c,p)));const f=document.createElement("mark");f.className=he,f.textContent=m.slice(p,p+l.length),u.appendChild(f),s++,c=p+l.length,p=h.indexOf(n,c)}c<m.length&&u.appendChild(document.createTextNode(m.slice(c))),g.replaceChild(u,i)}return s}function de(t,r){let l=0,n=t.toLowerCase().indexOf(r);for(;n>=0;)l++,n=t.toLowerCase().indexOf(r,n+r.length);return l}function He(t){const{plan:r,gotoPage:l,highlight:n,clearHighlights:a}=t,o=t.debounceMs??200,s=e.ref(!1),i=e.ref(""),m=e.ref(""),h=e.ref(0);let g=null;const u=e.computed(()=>{const w=i.value.trim().toLowerCase(),x=r.value;if(!w||!x)return[];const R=[];return x.pages.forEach((F,K)=>{for(const N of F.components)if(N.grid){for(const D of N.grid.cells??[])for(const O of D??[])if(typeof O?.text=="string")for(let G=0;G<de(O.text,w);G++)R.push(K)}else if(N.kind==="text"&&typeof N.text=="string")for(let D=0;D<de(N.text,w);D++)R.push(K)}),R}),c=e.computed(()=>u.value.length);function p(w){if(m.value=w,g&&clearTimeout(g),w.trim()===""){g=null,i.value="",h.value=0;return}g=setTimeout(()=>{g=null,i.value=m.value,h.value=0;const x=u.value[0];x!=null&&l(x+1)},o)}function f(w){const x=u.value.length;x!==0&&(h.value=(h.value+w+x)%x,l(u.value[h.value]+1))}function b(){s.value=!s.value}function E(w){const x=i.value.trim();x&&n(w,x)}function B(w){a(w)}function $(){m.value="",i.value="",h.value=0,g&&clearTimeout(g),g=null}return{visible:s,query:i,matchIndex:h,matchCount:c,toggle:b,onInput:p,onNav:f,apply:E,clear:B,reset:$}}function We(t,r){const l=e.computed(()=>{if(t.value)return!0;if(typeof location>"u")return!1;try{return new URLSearchParams(location.search).get("mrp-debug")==="1"}catch{return!1}}),n=e.computed(()=>!l.value||!r.plan.value?0:Math.round(JSON.stringify(r.plan.value).length/1024)),a=e.computed(()=>!l.value||!r.plan.value?null:{pages:r.pageCount.value,window:`${r.windowRange.value.start}-${r.windowRange.value.end}`,zoom:`${Math.round(r.zoom.value*100)}%`,loadMs:`${r.loadMs.value}ms`,planKB:n.value});return{enabled:l,debugStats:a}}function Ae(t,r){const{thumbsRoot:l,visible:n,renderThumbCanvas:a}=r;let o=null;function s(h,g){if(!t.value||h.childElementCount>0)return;const u=a(g);u&&(u.style.width="100%",u.style.height="100%",u.style.display="block",h.appendChild(u))}return{schedule:()=>{!n.value||!t.value||!l.value||typeof IntersectionObserver>"u"||(o?.disconnect(),o=new IntersectionObserver(h=>{for(const g of h){if(!g.isIntersecting)continue;const u=g.target;s(u,Number(u.dataset.thumb??1)-1),o?.unobserve(u)}},{root:l.value,rootMargin:"200px"}),l.value.querySelectorAll("[data-thumb]").forEach(h=>{o.observe(h)}))},destroy:()=>{o?.disconnect(),o=null}}}function Ue(){const t=e.shallowRef(0);return{loadMs:t,start(){return typeof performance<"u"?performance.now():0},end(r){t.value=r?Math.round(performance.now()-r):0}}}const je={class:"mrp-toolbar"},qe={class:"mrp-title"},Ke=["disabled"],Ge={class:"mrp-pageinfo"},Ye=["disabled"],Ze={key:1,class:"mrp-search"},Je=["placeholder","value"],Xe={key:0,class:"mrp-search-count"},Qe=["disabled"],_e=["disabled"],et=e.defineComponent({__name:"ReportToolbar",props:{pageCount:{},currentPage:{},zoomMode:{},zoom:{},showExport:{type:Boolean},showPrint:{type:Boolean},showPdfWindow:{type:Boolean},messages:{},search:{},thumbsVisible:{type:Boolean}},emits:["goto","zoom","export","print","pdf-window","search-input","search-nav","search-toggle","thumbs-toggle"],setup(t){const r=t,l=e.ref(null);e.watch(()=>r.search.visible,a=>{a&&e.nextTick(()=>l.value?.focus())});function n(a,o,s){return a.replace("{cur}",String(o)).replace("{total}",String(s))}return(a,o)=>(e.openBlock(),e.createElementBlock("div",je,[e.createElementVNode("span",qe,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]=s=>a.$emit("goto",t.currentPage-1))},e.toDisplayString(t.messages.prevPage),9,Ke),e.createElementVNode("span",Ge,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]=s=>a.$emit("goto",t.currentPage+1))},e.toDisplayString(t.messages.nextPage),9,Ye)],64)):e.createCommentVNode("",!0),o[14]||(o[14]=e.createElementVNode("span",{class:"mrp-spacer"},null,-1)),t.search.visible?(e.openBlock(),e.createElementBlock("div",Ze,[e.createElementVNode("input",{ref_key:"searchInputRef",ref:l,class:"mrp-search-input",type:"text",placeholder:t.messages.searchPlaceholder,value:t.search.query,onInput:o[2]||(o[2]=s=>a.$emit("search-input",s.target.value))},null,40,Je),t.search.query?(e.openBlock(),e.createElementBlock("span",Xe,e.toDisplayString(n(t.messages.matchInfo,t.search.matchIndex+1,t.search.matchCount)),1)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"mrp-nav",type:"button",disabled:t.search.matchCount===0,onClick:o[3]||(o[3]=s=>a.$emit("search-nav",-1))},e.toDisplayString(t.messages.prevMatch),9,Qe),e.createElementVNode("button",{class:"mrp-nav",type:"button",disabled:t.search.matchCount===0,onClick:o[4]||(o[4]=s=>a.$emit("search-nav",1))},e.toDisplayString(t.messages.nextMatch),9,_e)])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:e.normalizeClass(["mrp-nav",{"mrp-active":t.search.visible}]),type:"button",title:"Ctrl+F",onClick:o[5]||(o[5]=s=>a.$emit("search-toggle"))}," 🔍 ",2),e.createElementVNode("button",{class:e.normalizeClass(["mrp-nav",{"mrp-active":t.thumbsVisible}]),type:"button",onClick:o[6]||(o[6]=s=>a.$emit("thumbs-toggle"))}," ▦ "+e.toDisplayString(t.messages.thumbnails),3),e.createElementVNode("button",{class:e.normalizeClass(["mrp-nav",{"mrp-active":t.zoomMode==="fit"}]),type:"button",onClick:o[7]||(o[7]=s=>a.$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[8]||(o[8]=s=>a.$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[9]||(o[9]=s=>a.$emit("zoom",150))}," 150% ",2),t.showExport?(e.openBlock(),e.createElementBlock("button",{key:2,class:"mrp-nav",type:"button",onClick:o[10]||(o[10]=s=>a.$emit("export","html"))},e.toDisplayString(t.messages.exportHtml),1)):e.createCommentVNode("",!0),t.showExport?(e.openBlock(),e.createElementBlock("button",{key:3,class:"mrp-nav",type:"button",onClick:o[11]||(o[11]=s=>a.$emit("export","pdf"))},e.toDisplayString(t.messages.exportPdf),1)):e.createCommentVNode("",!0),t.showPrint?(e.openBlock(),e.createElementBlock("button",{key:4,class:"mrp-nav",type:"button",onClick:o[12]||(o[12]=s=>a.$emit("print"))},e.toDisplayString(t.messages.print),1)):e.createCommentVNode("",!0),t.showPdfWindow?(e.openBlock(),e.createElementBlock("button",{key:5,class:"mrp-nav",type:"button",onClick:o[13]||(o[13]=s=>a.$emit("pdf-window"))},e.toDisplayString(t.messages.pdfWindow),1)):e.createCommentVNode("",!0)]))}}),ve=(t,r)=>{const l=t.__vccOpts||t;for(const[n,a]of r)l[n]=a;return l},be=ve(et,[["__scopeId","data-v-f50c26e8"]]),we={title:"报表预览",prevPage:"‹ 上一页",nextPage:"下一页 ›",pageInfo:"{cur} / {total}",fitWidth:"适宽",exportHtml:"导出 HTML",exportPdf:"导出 PDF",print:"打印",pdfWindow:"PDF 窗口",loading:"报表渲染中…",empty:"暂无预览数据",errorPrefix:"",retry:"重试",searchPlaceholder:"搜索报表内容",matchInfo:"{cur}/{total}",prevMatch:"‹",nextMatch:"›",thumbnails:"缩略图"},ye={shellBg:"#525659",shellFg:"#e8e8e8",toolbarBg:"#323639",toolbarBorder:"#22252a",toolbarFg:"#e8e8e8",btnFg:"#cfcfcf",btnBorder:"#4a4d52",btnHoverBg:"#414549",btnHoverFg:"#ffffff",btnActiveBg:"#2d5fb8"};function tt(t){return t}function ot(t){return t}const L={showExport:!0,showPrint:!0,showPdfWindow:!0,gapPx:18,pdfFontUrl:"/simhei.ttf",logger:console},nt={warn:()=>{},info:()=>{}};function Ee(t,r){const l=r?t?.presets?.[r]:t?.defaultPreset?t?.presets?.[t.defaultPreset]:void 0,n={...t?.defaults,...l};return{showExport:n.showExport??L.showExport,showPrint:n.showPrint??L.showPrint,showPdfWindow:n.showPdfWindow??L.showPdfWindow,gapPx:n.gapPx??L.gapPx,pdfFontUrl:n.pdfFontUrl??L.pdfFontUrl,theme:{...ye,...n.theme},messages:{...we,...n.messages},logger:n.logger??L.logger}}function Pe(t){const r={};return t.shellBg!=null&&(r["--mrp-shell-bg"]=t.shellBg),t.shellFg!=null&&(r["--mrp-shell-fg"]=t.shellFg),t.toolbarBg!=null&&(r["--mrp-toolbar-bg"]=t.toolbarBg),t.toolbarBorder!=null&&(r["--mrp-toolbar-border"]=t.toolbarBorder),t.toolbarFg!=null&&(r["--mrp-toolbar-fg"]=t.toolbarFg),t.btnFg!=null&&(r["--mrp-btn-fg"]=t.btnFg),t.btnBorder!=null&&(r["--mrp-btn-border"]=t.btnBorder),t.btnHoverBg!=null&&(r["--mrp-btn-hover-bg"]=t.btnHoverBg),t.btnHoverFg!=null&&(r["--mrp-btn-hover-fg"]=t.btnHoverFg),t.btnActiveBg!=null&&(r["--mrp-btn-active-bg"]=t.btnActiveBg),r}function rt(t){const r=e.inject(T.MACH_REPORT_CONFIG_KEY,null),l=e.computed(()=>{const n=r?.value??null,a="defaults"in t&&"presets"in t?t:{defaults:t,presets:{}};return n?{defaults:{...n.defaults,...a.defaults},presets:{...n.presets,...a.presets},defaultPreset:a.defaultPreset??n.defaultPreset}:a});e.provide(T.MACH_REPORT_CONFIG_KEY,l)}function ke(){return e.inject(T.MACH_REPORT_CONFIG_KEY,e.computed(()=>null))}class q extends Error{constructor(r,l,n){super(l),this.name="MachReportError",this.code=r,this.cause=n}}function Ce(t){return t instanceof q?{code:t.code,cause:t.cause}:{code:"render",cause:t}}const at={class:"mrp-main"},lt={key:0,class:"mrp-state"},st={key:1,class:"mrp-state mrp-error"},it={key:2,class:"mrp-state"},ut=["data-page"],ct=["onClick"],dt=["data-thumb"],mt={class:"mrp-thumb-no"},pt={class:"mrp-overlay"},ft={key:0,class:"mrp-debug","aria-hidden":"true"},J=96/25.4,me="mach-report:ui",gt=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},debug:{type:Boolean,default:!1},fetcher:{type:Function,default:null}},emits:["loaded","error"],setup(t,{expose:r,emit:l}){e.useCssVars(d=>({v3c509574:f.value+"px"}));const n=t,a=l,o=e.shallowRef(null),s=e.ref(!1),i=e.ref(""),m=e.ref(1),h=e.ref(null),g=e.ref(null),u=e.ref(null),c=e.ref(!1),p=Ue(),f=e.computed(()=>Math.max(0,O.value)),b=e.inject(T.MACH_REPORT_FETCHER_KEY,null),B=e.inject(T.MACH_REPORT_PDF_EXPORTER_KEY,null)??T.createDefaultPdfExporter({fontUrl:"/simhei.ttf"}),$=e.computed(()=>T.normalizeTempIds(n.tempId)),w=e.computed(()=>o.value?.pages.length??0),x=ke(),R=e.computed(()=>Ee(x.value,n.preset)),F=e.computed(()=>({...R.value.messages,...n.messages})),K=e.computed(()=>n.showExport??R.value.showExport),N=e.computed(()=>n.showPrint??R.value.showPrint),D=e.computed(()=>n.showPdfWindow??R.value.showPdfWindow),O=e.computed(()=>n.gapPx??R.value.gapPx),G=e.computed(()=>({height:n.height,...Pe(R.value.theme)})),{zoom:M,zoomMode:z,applyFitZoom:le,setZoom:_}=fe(()=>({viewport:g.value,pageWidthPx:(o.value?.pages[0]?.pageWidthMm??210)*J})),Me=pe(o,M,{pxPerMm:J,gapPx:O.value}),{contentSize:ee,windowRange:H,visiblePages:Re,makeScrollHandler:Se,refreshViewport:se}=Me,Be=Se(m,w);function te(d){z.value="raw",M.value=Math.min(3,Math.max(.3,d))}function oe(){o.value=null,m.value=1,P.reset()}let Y=0;async function I(){const d=++Y,y=n.fetcher??b;if($.value.length===0){i.value="缺少报表模板 ID",oe(),a("error",i.value,{code:"param"});return}if(!y){i.value="未提供渲染数据源 fetcher",oe(),a("error",i.value,{code:"config"});return}s.value=!0,i.value="",oe();const k=p.start();try{const v=await y({tempIds:$.value,furnitureTempId:n.furnitureTempId||void 0,params:{...n.params}});if(d!==Y)return;const C=U.validateRenderPlan(v);if(!C.ok){const W=C.errors.slice(0,3).map(A=>`${A.path}: ${A.message}`).join("; ");throw new q("validate",`渲染计划校验失败(${C.errors.length} 处): ${W}`)}C.warnings.length>0&&R.value.logger.warn("[mach-report] 渲染计划告警:",C.warnings),o.value=v,m.value=1,p.end(k),g.value&&(g.value.scrollTop=0),z.value==="fit"&&le(),a("loaded",v.pages.length)}catch(v){if(d!==Y)return;const C=v instanceof q?v:new q("fetch",v instanceof Error?v.message:"预览加载失败",v);i.value=C.message,a("error",C.message,Ce(C))}finally{d===Y&&(s.value=!1)}}function S(d){if(w.value<=0)return;const y=Math.max(1,Math.min(w.value,d));m.value=y;const k=g.value;if(!k)return;let v=0;for(let C=0;C<y-1;C++)v+=(o.value?.pages[C]?.pageHeightMm??0)*J+f.value;k.scrollTop=v*M.value}const{print:ne,exportAs:re,openPdfWindow:ae,releasePrintFrame:Te}=ge(o,{getPdfExporter:()=>B,onError:d=>a("error",d,{code:"print"})}),$e={reload:I,print:ne,exportAs:re,openPdfWindow:ae,gotoPage:S};e.provide(T.MACH_REPORT_CONTROLLER_KEY,$e);const P=He({plan:o,gotoPage:S,highlight:Oe,clearHighlights:Le});function Ne(d){d.ctrlKey&&(d.preventDefault(),te(M.value*(d.deltaY<0?1.1:1/1.1)))}function Fe(d){if((d.ctrlKey||d.metaKey)&&d.key.toLowerCase()==="f"){d.preventDefault(),P.visible.value||P.toggle();return}switch(d.key){case"PageDown":d.preventDefault(),S(m.value+1);break;case"PageUp":d.preventDefault(),S(m.value-1);break;case"Home":d.preventDefault(),S(1);break;case"End":d.preventDefault(),S(w.value);break;case"+":case"=":d.preventDefault(),te(M.value*1.1);break;case"-":d.preventDefault(),te(M.value/1.1);break}}function De(){try{localStorage.setItem(me,JSON.stringify({zoomMode:z.value==="fit"?"fit":Math.round(M.value*100)}))}catch{}}e.watch([z,M],De),e.watchEffect(()=>{const d=o.value;if(!d)return;const y=h.value;if(!y)return;y.querySelectorAll(".mrp-page-holder").forEach(v=>{const C=Number(v.dataset.page??0)-1,W=d.pages[C];if(!W||v.childElementCount>0){if(v.firstElementChild){const ce=v.firstElementChild;P.clear(ce),P.apply(ce)}return}v.style.width=`${W.pageWidthMm*J}px`;const A=U.renderPage(W,96,{},document);P.apply(A),v.appendChild(A)})},{flush:"post"}),e.watch(()=>P.query.value,d=>{d||h.value?.querySelectorAll(".mrp-page-holder").forEach(y=>{P.clear(y)})});const ie=Ae(o,{thumbsRoot:u,visible:c,renderThumbCanvas:d=>{try{const{canvases:y}=U.renderPlanToCanvas(o.value,{start:d,end:d,dpr:.2});return y[0]??null}catch{return null}}});e.watchEffect(()=>{ie.schedule()},{flush:"post"});const ze=e.computed(()=>n.debug),{debugStats:V}=We(ze,{plan:o,pageCount:w,windowRange:H,zoom:M,loadMs:p.loadMs});function ue(){se(g.value),z.value==="fit"&&le()}function Ie(){try{const d=JSON.parse(localStorage.getItem(me)??"{}");d.zoomMode==="fit"?_("fit"):typeof d.zoomMode=="number"&&_(d.zoomMode)}catch{}}return e.onMounted(()=>{window.addEventListener("resize",ue),se(g.value),Ie(),n.autoLoad&&I()}),e.onUnmounted(()=>{window.removeEventListener("resize",ue),ie.destroy(),P.reset(),Te()}),e.watch(()=>[n.tempId,n.furnitureTempId,JSON.stringify(n.params)],()=>{n.autoLoad&&I()}),e.watch(()=>n.fetcher??b,()=>{n.autoLoad&&I()}),r({reload:I,print:ne,exportAs:re,openPdfWindow:ae,gotoPage:S}),(d,y)=>(e.openBlock(),e.createElementBlock("div",{class:"mach-report-preview",style:e.normalizeStyle(G.value)},[e.createVNode(be,{"page-count":w.value,"current-page":m.value,"zoom-mode":e.unref(z),zoom:e.unref(M),"show-export":K.value,"show-print":N.value,"show-pdf-window":D.value,messages:F.value,search:{visible:e.unref(P).visible.value,query:e.unref(P).query.value,matchIndex:e.unref(P).matchIndex.value,matchCount:e.unref(P).matchCount.value},"thumbs-visible":c.value,onGoto:S,onZoom:e.unref(_),onExport:y[0]||(y[0]=k=>e.unref(re)(k)),onPrint:e.unref(ne),onPdfWindow:e.unref(ae),onSearchInput:e.unref(P).onInput,onSearchNav:e.unref(P).onNav,onSearchToggle:e.unref(P).toggle,onThumbsToggle:y[1]||(y[1]=k=>c.value=!c.value)},null,8,["page-count","current-page","zoom-mode","zoom","show-export","show-print","show-pdf-window","messages","search","thumbs-visible","onZoom","onPrint","onPdfWindow","onSearchInput","onSearchNav","onSearchToggle"]),e.createElementVNode("div",at,[e.createElementVNode("div",{ref_key:"viewportRef",ref:g,class:"mrp-body",tabindex:"0",onWheel:Ne,onKeydown:Fe,onScrollPassive:y[2]||(y[2]=k=>e.unref(Be)(k.target))},[s.value?(e.openBlock(),e.createElementBlock("div",lt,e.toDisplayString(F.value.loading),1)):i.value?(e.openBlock(),e.createElementBlock("div",st,[e.createTextVNode(e.toDisplayString(i.value)+" ",1),e.createElementVNode("button",{class:"mrp-retry",type:"button",onClick:I},e.toDisplayString(F.value.retry),1)])):!o.value||w.value===0?(e.openBlock(),e.createElementBlock("div",it,e.toDisplayString(F.value.empty),1)):(e.openBlock(),e.createElementBlock("div",{key:3,class:"mrp-scale",style:e.normalizeStyle({width:`${e.unref(ee).w*e.unref(M)}px`,height:`${e.unref(ee).h*e.unref(M)}px`})},[e.createElementVNode("div",{ref_key:"containerRef",ref:h,class:"mrp-scale-inner",style:e.normalizeStyle({transform:`scale(${e.unref(M)})`,transformOrigin:"top left",width:`${e.unref(ee).w}px`})},[e.unref(H).padTopPx>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"mrp-spacer-top",style:e.normalizeStyle({height:`${e.unref(H).padTopPx}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Re),k=>(e.openBlock(),e.createElementBlock("div",{key:k.index,class:"mrp-page-holder","data-page":k.index+1},null,8,ut))),128)),e.unref(H).padBottomPx>0?(e.openBlock(),e.createElementBlock("div",{key:1,class:"mrp-spacer-bottom",style:e.normalizeStyle({height:`${e.unref(H).padBottomPx}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0)],4)],4))],544),c.value&&w.value>0?(e.openBlock(),e.createElementBlock("aside",{key:0,ref_key:"thumbsRef",ref:u,class:"mrp-thumbs"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value?.pages??[],(k,v)=>(e.openBlock(),e.createElementBlock("div",{key:v,class:e.normalizeClass(["mrp-thumb",{"mrp-thumb-active":v+1===m.value}]),onClick:C=>S(v+1)},[e.createElementVNode("div",{class:"mrp-thumb-box","data-thumb":v+1,style:e.normalizeStyle({height:`${Math.round(k.pageHeightMm/k.pageWidthMm*116)}px`})},null,12,dt),e.createElementVNode("span",mt,e.toDisplayString(v+1),1)],10,ct))),128))],512)):e.createCommentVNode("",!0)]),e.createElementVNode("div",pt,[e.renderSlot(d.$slots,"default",{},void 0,!0)]),e.unref(V)?(e.openBlock(),e.createElementBlock("div",ft,[y[3]||(y[3]=e.createElementVNode("div",null,"mach-report debug",-1)),e.createElementVNode("div",null,"pages: "+e.toDisplayString(e.unref(V).pages)+" | window: ["+e.toDisplayString(e.unref(V).window)+"]",1),e.createElementVNode("div",null,"zoom: "+e.toDisplayString(e.unref(V).zoom)+" | load: "+e.toDisplayString(e.unref(V).loadMs),1),e.createElementVNode("div",null,"plan: "+e.toDisplayString(e.unref(V).planKB)+"KB",1)])):e.createCommentVNode("",!0)],4))}}),xe=ve(gt,[["__scopeId","data-v-2e98692a"]]),ht=Object.freeze(Object.defineProperty({__proto__:null,default:xe},Symbol.toStringTag,{value:"Module"}));exports.DEFAULT_MESSAGES=we;exports.DEFAULT_THEME=ye;exports.MachReportError=q;exports.ReportPreview=xe;exports.ReportPreview$1=ht;exports.ReportToolbar=be;exports.SILENT_LOGGER=nt;exports.buildPrintDocument=j;exports.defineMachReportConfig=tt;exports.defineMachReportPreset=ot;exports.printPlans=Ve;exports.provideMachReportConfig=rt;exports.resolveConfig=Ee;exports.themeToCssVars=Pe;exports.toErrorDetail=Ce;exports.useMachReportConfig=ke;exports.usePageWindow=pe;exports.usePrintExport=ge;exports.useZoom=fe;
|