vite.config.js splits geotiff and shpjs out so they load only when a user opens a Cloud-Optimized GeoTIFF or imports a shapefile, but the built index.html preloaded both on every visit — about 428 kB (152 kB gzipped) nobody had asked for. Two separate causes, both visible in the entry chunk's first line: - it imported Vite's preload helper, used by every dynamic import(), from the geotiff chunk. The helper is a virtual module with no node_modules path, so Rollup had parked it there; needing it at startup dragged the whole chunk in. It now has a chunk of its own, about 1 kB. - it imported JSZip from the shpjs chunk. JSZip reached the bundle through shp-write, which gis-export.js imports for Shapefile export, so it is needed at startup whatever happens; filing it under shpjs pulled that chunk in too. It is now its own chunk, costing the 31 kB it actually is. dist/ rebuilt: index.html now preloads vite-helpers and jszip instead. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
3 lines
2.1 KiB
JavaScript
3 lines
2.1 KiB
JavaScript
import{E as f,a as b}from"./jspdf-BpioTcs4.js";import"./pako-Xa-UToif.js";import"./vite-helpers-BlTxHScW.js";b(f);let s=null;async function x(){if(s)return s;try{const e=new Image;e.crossOrigin="anonymous",await new Promise((r,i)=>{e.onload=r,e.onerror=i,e.src="./app-icons/luspa-pdf.jpg"});const n=document.createElement("canvas");n.width=e.naturalWidth,n.height=e.naturalHeight;const t=n.getContext("2d");return t.fillStyle="#ffffff",t.fillRect(0,0,n.width,n.height),t.drawImage(e,0,0),s=n.toDataURL("image/jpeg",.92),s}catch(e){return console.warn("[PDF] Could not load logo:",e),null}}async function D({title:e,rows:n}){const t=new f({orientation:"portrait",unit:"mm",format:"a4"}),r=t.internal.pageSize.getWidth(),i=[30,26,75],g=await x(),c=28,a=14;let o=14;g&&t.addImage(g,"JPEG",a,o,c,c);const m=a+c+6;t.setFont("helvetica","bold"),t.setFontSize(18),t.setTextColor(...i),t.text("LUPMIS",m,o+11),t.setFont("helvetica","normal"),t.setFontSize(12),t.text(e,m,o+19);const d=new Date,h=d.toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"}),p=d.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});t.setFontSize(9),t.setTextColor(120,120,120),t.text(`${h} ${p}`,r-a,o+11,{align:"right"}),o+=c+6,t.setDrawColor(...i),t.setLineWidth(.5),t.line(a,o,r-a,o),o+=6;const y=n.map(l=>[l.label,l.value]);t.autoTable({startY:o,head:[["Property","Value"]],body:y,margin:{left:a,right:a},styles:{font:"helvetica",fontSize:10,cellPadding:4},headStyles:{fillColor:i,textColor:[255,255,255],fontStyle:"bold"},alternateRowStyles:{fillColor:[245,245,250]},columnStyles:{0:{fontStyle:"bold",cellWidth:50}}});const S=t.lastAutoTable.finalY+10;t.setFontSize(8),t.setTextColor(160,160,160),t.text("Generated by LUPMIS2 Land Use Planning & Management Information System",a,S);const w=t.output("blob"),u=URL.createObjectURL(w);if(!window.open(u,"_blank")){const l=document.createElement("a");l.href=u,l.download=`${e.replace(/\s+/g,"_")}_${d.toISOString().slice(0,10)}.pdf`,document.body.appendChild(l),l.click(),document.body.removeChild(l)}}export{D as exportAnalysisPDF};
|
|
//# sourceMappingURL=pdf-export-Cq3nXOgJ.js.map
|