@stacksjs/stx 0.2.195 → 0.2.197
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/chunk-0ae6chzd.js +4 -0
- package/dist/chunk-0w0mrtme.js +2 -0
- package/dist/chunk-0y46fbkx.js +3 -0
- package/dist/chunk-118a77bs.js +4471 -0
- package/dist/chunk-12nvcvtn.js +3 -0
- package/dist/chunk-14ynv5ah.js +2 -0
- package/dist/chunk-1e25ksp6.js +3 -0
- package/dist/chunk-1mhc4g86.js +43 -0
- package/dist/chunk-1thssz8x.js +2 -0
- package/dist/chunk-1yk07x7b.js +2 -0
- package/dist/chunk-2zkj69dg.js +13 -0
- package/dist/chunk-338316c2.js +2 -0
- package/dist/chunk-3952ykhb.js +1655 -0
- package/dist/chunk-3es366z4.js +3 -0
- package/dist/chunk-3m49eb4v.js +2 -0
- package/dist/chunk-3nmpfsw5.js +2 -0
- package/dist/chunk-3vy1q9da.js +2 -0
- package/dist/chunk-4a4h28pp.js +3022 -0
- package/dist/chunk-4pf61rcb.js +2 -0
- package/dist/chunk-5anpcnde.js +2 -0
- package/dist/chunk-5mkkre22.js +505 -0
- package/dist/chunk-5n0dt838.js +2 -0
- package/dist/chunk-5s2y052b.js +2 -0
- package/dist/chunk-5v64c8tr.js +2 -0
- package/dist/chunk-5xd7vge2.js +2 -0
- package/dist/chunk-6bxcjdp4.js +2 -0
- package/dist/chunk-6msvxnbr.js +2 -0
- package/dist/chunk-7kger0se.js +1280 -0
- package/dist/chunk-7ry55nms.js +3 -0
- package/dist/chunk-7s0wfa4e.js +24 -0
- package/dist/chunk-7w4c5w2b.js +2 -0
- package/dist/chunk-8src5smc.js +15 -0
- package/dist/chunk-937effkz.js +2 -0
- package/dist/chunk-9b82d4g5.js +3 -0
- package/dist/chunk-9xh78snm.js +3 -0
- package/dist/chunk-a2899x2t.js +2 -0
- package/dist/chunk-abpw3b39.js +2 -0
- package/dist/chunk-avwj12at.js +194 -0
- package/dist/chunk-b6jhznkh.js +71 -0
- package/dist/chunk-bpa2jeyw.js +3 -0
- package/dist/chunk-cbc56wpd.js +3 -0
- package/dist/chunk-dhpy0h9y.js +2 -0
- package/dist/chunk-dtmwr674.js +302 -0
- package/dist/chunk-dxfcyj8t.js +2 -0
- package/dist/chunk-e0460y7f.js +29 -0
- package/dist/chunk-ede7zpjf.js +2 -0
- package/dist/chunk-ehfzp7xe.js +2 -0
- package/dist/chunk-fd77g6t6.js +2 -0
- package/dist/chunk-fnkxbnka.js +30 -0
- package/dist/chunk-fvjh7rx0.js +84 -0
- package/dist/chunk-g19skgmw.js +18 -0
- package/dist/chunk-gcnrdgrq.js +3 -0
- package/dist/chunk-h2wpnxrh.js +8 -0
- package/dist/chunk-hb83d0qc.js +2 -0
- package/dist/chunk-hncp9gz6.js +8 -0
- package/dist/chunk-ht51fz7w.js +4 -0
- package/dist/chunk-hyrjade7.js +321 -0
- package/dist/chunk-hyyzp99b.js +2 -0
- package/dist/chunk-jpbk42j7.js +2 -0
- package/dist/chunk-jr5tp4ks.js +2 -0
- package/dist/chunk-k03b9z9e.js +898 -0
- package/dist/chunk-kjr22neh.js +3 -0
- package/dist/chunk-mjt5e2jy.js +2 -0
- package/dist/chunk-mkm91b6w.js +2 -0
- package/dist/chunk-mtr2f82n.js +2 -0
- package/dist/chunk-n8zpm7xb.js +397 -0
- package/dist/chunk-ndnc7k2n.js +22 -0
- package/dist/chunk-nenge2m2.js +2 -0
- package/dist/chunk-nngpktr2.js +2 -0
- package/dist/chunk-nsjyn31z.js +2 -0
- package/dist/chunk-nye9brje.js +147 -0
- package/dist/chunk-p5kp35dy.js +2 -0
- package/dist/chunk-pw0rzgpv.js +3 -0
- package/dist/chunk-q020t182.js +2 -0
- package/dist/chunk-q4gp9egt.js +4 -0
- package/dist/chunk-q8szpd6w.js +3 -0
- package/dist/chunk-q9n5swx7.js +3 -0
- package/dist/chunk-qpcwahse.js +2 -0
- package/dist/chunk-qz75kx6n.js +231 -0
- package/dist/chunk-r41nsgym.js +116 -0
- package/dist/chunk-r4qnvxhv.js +18 -0
- package/dist/chunk-r6p4ws0a.js +3809 -0
- package/dist/chunk-rdf7d42n.js +2 -0
- package/dist/chunk-rs2fa3g1.js +2 -0
- package/dist/chunk-ryjpp51z.js +499 -0
- package/dist/chunk-s018d32j.js +30 -0
- package/dist/chunk-spn8e3b3.js +2 -0
- package/dist/chunk-sry9atvv.js +2 -0
- package/dist/chunk-st5qggks.js +3 -0
- package/dist/chunk-tywvd1zc.js +11 -0
- package/dist/chunk-v3ryxw4v.js +2 -0
- package/dist/chunk-va9k88da.js +2 -0
- package/dist/chunk-vgk5v31k.js +216 -0
- package/dist/chunk-vj320kyr.js +2 -0
- package/dist/chunk-vr3qtsj4.js +2 -0
- package/dist/chunk-w0ng9e1m.js +341 -0
- package/dist/chunk-w29sv5jf.js +2 -0
- package/dist/chunk-whq99ytc.js +7987 -0
- package/dist/chunk-wnaddtv3.js +288 -0
- package/dist/chunk-wtengj6h.js +2 -0
- package/dist/chunk-x0ks1fer.js +1194 -0
- package/dist/chunk-x0zh76yv.js +4 -0
- package/dist/chunk-x13f5bbe.js +358 -0
- package/dist/chunk-xfp10a23.js +2 -0
- package/dist/chunk-xp3fp266.js +11 -0
- package/dist/chunk-xz019t7t.js +2 -0
- package/dist/chunk-y35rktea.js +12 -0
- package/dist/chunk-y4hkqsgw.js +4 -0
- package/dist/chunk-yab6d6kb.js +28 -0
- package/dist/chunk-yckd6ks5.js +3 -0
- package/dist/chunk-ycn1vnv2.js +5 -0
- package/dist/chunk-yf3bmmkk.js +8 -0
- package/dist/chunk-ygr11tgz.js +3 -0
- package/dist/chunk-ymccpdg6.js +351 -0
- package/dist/chunk-yr2wc2pa.js +3 -0
- package/dist/chunk-yv340gxj.js +2 -0
- package/dist/chunk-z2sp0k8d.js +3 -0
- package/dist/chunk-z5cm0bwn.js +11 -0
- package/dist/chunk-zda3hvde.js +14 -0
- package/dist/chunk-zgvga8rc.js +5 -0
- package/dist/chunk-zqbw8zqq.js +3 -0
- package/dist/cli.js +108 -27481
- package/dist/craft-entry.js +9 -5
- package/dist/craft.js +7 -18503
- package/dist/database.js +2 -2
- package/dist/pwa.js +8 -16603
- package/dist/ssg.js +52 -15512
- package/dist/visual-testing.js +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ui as a,Vi as b}from"./chunk-z5cm0bwn.js";import"./chunk-ht51fz7w.js";import"./chunk-r6p4ws0a.js";import"./chunk-8src5smc.js";import"./chunk-gcnrdgrq.js";import"./chunk-xp3fp266.js";import"./chunk-nye9brje.js";import"./chunk-tywvd1zc.js";import"./chunk-cbc56wpd.js";import"./chunk-x0zh76yv.js";import"./chunk-0ae6chzd.js";import"./chunk-kjr22neh.js";import"./chunk-3952ykhb.js";import"./chunk-dtmwr674.js";import"./chunk-pw0rzgpv.js";export{a as getStoreScript,b as clearStoreCache};
|
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import"./chunk-pw0rzgpv.js";import v from"fs";import H from"path";import{gzipSync as z}from"zlib";import{createHash as g}from"crypto";var D={".js":"js",".mjs":"js",".cjs":"js",".ts":"js",".jsx":"js",".tsx":"js",".css":"css",".scss":"css",".sass":"css",".less":"css",".html":"html",".htm":"html",".png":"image",".jpg":"image",".jpeg":"image",".gif":"image",".svg":"image",".webp":"image",".avif":"image",".ico":"image",".woff":"font",".woff2":"font",".ttf":"font",".eot":"font",".otf":"font"},b=[/node_modules/,/vendor/,/bower_components/,/\.min\./],B=[/index\.(js|ts|html)$/,/main\.(js|ts)$/,/app\.(js|ts)$/,/entry\.(js|ts)$/];async function L(X,Z={}){let{includeSourceMaps:Q=!1,parseImports:$=!0,detectDuplicates:U=!0,topModulesCount:K=20}=Z;if(!v.existsSync(X))throw Error(`Build directory not found: ${X}`);if(!v.statSync(X).isDirectory())throw Error(`Not a directory: ${X}`);let q=await k(X,Q),J=[],F=[];for(let A of q)try{let O=await f(A,X,$);J.push(O)}catch(O){F.push(`Failed to process ${A}: ${O}`)}let Y=c(J,X),V=J.reduce((A,O)=>A+O.size,0),_=J.reduce((A,O)=>A+O.gzipSize,0),w=m(J),G=U?p(J):[],C=[...J].sort((A,O)=>O.size-A.size).slice(0,K);return{timestamp:Date.now(),buildDir:H.resolve(X),chunks:Y,totalSize:V,totalGzipSize:_,moduleCount:J.length,duplicates:G,byType:w,largestModules:C,warnings:F}}async function k(X,Z){let Q=[];async function $(U){let K=await v.promises.readdir(U,{withFileTypes:!0});for(let j of K){let q=H.join(U,j.name);if(j.isDirectory()){if(!j.name.startsWith(".")&&j.name!=="node_modules")await $(q)}else if(j.isFile()){if(!Z&&j.name.endsWith(".map"))continue;Q.push(q)}}}return await $(X),Q}async function f(X,Z,Q){let $=await v.promises.readFile(X),U=H.relative(Z,X),K=H.extname(X).toLowerCase(),j=$.length,q=y($),J=h($,K),F=g("md5").update($).digest("hex").slice(0,8),Y=D[K]||"other",V=[];if(Q&&Y==="js")V.push(...d($.toString("utf-8")));return{id:U,path:U,size:j,gzipSize:q,parsedSize:J,extension:K,type:Y,imports:V,importedBy:[],hash:F}}function y(X){try{let Z=z(X,{level:9}).length;return Math.min(Z,X.length)}catch{return X.length}}function h(X,Z){if(Z.includes(".min.")||X.length<1000)return X.length;let $=D[Z];if($==="js")return Math.round(X.length*0.6);if($==="css")return Math.round(X.length*0.7);return X.length}function d(X){let Z=[],Q=/import\s+(?:[\w*{}\s,]+\s+from\s+)?['"]([^'"]+)['"]/g,$;while(($=Q.exec(X))!==null)Z.push($[1]);let U=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;while(($=U.exec(X))!==null)Z.push($[1]);let K=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;while(($=K.exec(X))!==null)Z.push($[1]);return[...new Set(Z)]}function c(X,Z){let Q=new Map;for(let U of X){let K=U.path.split(H.sep),j;if(K.length===1)j=H.basename(U.path,U.extension);else j=K[0];let q=Q.get(j)||[];q.push(U),Q.set(j,q)}let $=[];for(let[U,K]of Q){let j=K.reduce((Y,V)=>Y+V.size,0),q=K.reduce((Y,V)=>Y+V.gzipSize,0),J=K.some((Y)=>B.some((V)=>V.test(Y.path))),F=K.some((Y)=>b.some((V)=>V.test(Y.path)));$.push({name:U,files:K.map((Y)=>Y.path),modules:K,size:j,gzipSize:q,isEntry:J,isVendor:F})}return $.sort((U,K)=>K.size-U.size)}function m(X){let Z={js:{count:0,size:0,gzipSize:0},css:{count:0,size:0,gzipSize:0},html:{count:0,size:0,gzipSize:0},image:{count:0,size:0,gzipSize:0},font:{count:0,size:0,gzipSize:0},other:{count:0,size:0,gzipSize:0}};for(let Q of X)Z[Q.type].count++,Z[Q.type].size+=Q.size,Z[Q.type].gzipSize+=Q.gzipSize;return Z}function p(X){let Z=new Map;for(let $ of X){let U=Z.get($.hash)||[];U.push($),Z.set($.hash,U)}let Q=[];for(let[,$]of Z)if($.length>1){let U=$[0];Q.push({path:U.path,count:$.length,wastedBytes:U.size*($.length-1),locations:$.map((K)=>K.path)})}return Q.sort(($,U)=>U.wastedBytes-$.wastedBytes)}function W(X){if(X<1024)return`${X} B`;if(X<1048576)return`${(X/1024).toFixed(2)} KB`;return`${(X/1048576).toFixed(2)} MB`}function I(X){let Z=X.match(/^([\d.]+)\s*(B|KB|MB|GB)?$/i);if(!Z)return 0;let Q=Number.parseFloat(Z[1]);switch((Z[2]||"B").toUpperCase()){case"KB":return Q*1024;case"MB":return Q*1024*1024;case"GB":return Q*1024*1024*1024;default:return Q}}function E(X,Z){if(Z===0)return"0%";return`${(X/Z*100).toFixed(1)}%`}function R(X,Z){switch(Z.format){case"json":return u(X,Z);case"markdown":return l(X,Z);case"text":default:return r(X,Z)}}function u(X,Z){let Q=N(X,Z);return JSON.stringify({timestamp:X.timestamp,buildDir:X.buildDir,summary:{totalSize:X.totalSize,totalSizeFormatted:W(X.totalSize),totalGzipSize:X.totalGzipSize,totalGzipSizeFormatted:W(X.totalGzipSize),moduleCount:X.moduleCount,chunkCount:X.chunks.length,duplicateCount:X.duplicates.length},byType:Object.fromEntries(Object.entries(X.byType).map(([$,U])=>[$,{...U,sizeFormatted:W(U.size),gzipSizeFormatted:W(U.gzipSize)}])),chunks:X.chunks.map(($)=>({name:$.name,size:$.size,sizeFormatted:W($.size),gzipSize:$.gzipSize,gzipSizeFormatted:W($.gzipSize),moduleCount:$.modules.length,isEntry:$.isEntry,isVendor:$.isVendor})),largestModules:X.largestModules.slice(0,Z.topModules||10).map(($)=>({path:$.path,size:$.size,sizeFormatted:W($.size),gzipSize:$.gzipSize,gzipSizeFormatted:W($.gzipSize),type:$.type})),duplicates:X.duplicates,analysis:Q,warnings:X.warnings},null,2)}function r(X,Z){let Q=[],$=Z.showGzip!==!1;if(Q.push(""),Q.push("Bundle Analysis Report"),Q.push("\u2550".repeat(50)),Q.push(""),Q.push("Summary"),Q.push("\u2500".repeat(50)),$)Q.push(`Total Size: ${W(X.totalSize)} (${W(X.totalGzipSize)} gzip)`);else Q.push(`Total Size: ${W(X.totalSize)}`);if(Q.push(`Modules: ${X.moduleCount}`),Q.push(`Chunks: ${X.chunks.length}`),X.duplicates.length>0)Q.push(`Duplicates: ${X.duplicates.length}`);if(Q.push(""),Z.threshold&&X.totalSize>Z.threshold)Q.push(`\u26A0\uFE0F Bundle exceeds threshold of ${W(Z.threshold)}!`),Q.push("");Q.push("Size by Type"),Q.push("\u2500".repeat(50));let U=["js","css","html","image","font","other"];for(let j of U){let q=X.byType[j];if(q.count>0){let J=E(q.size,X.totalSize),F=$?` (${W(q.gzipSize)} gzip)`:"";Q.push(` ${j.padEnd(8)} ${W(q.size).padStart(12)}${F} ${J.padStart(6)} (${q.count} files)`)}}Q.push(""),Q.push("Chunks"),Q.push("\u2500".repeat(50));for(let j of X.chunks.slice(0,10)){let q=[];if(j.isEntry)q.push("entry");if(j.isVendor)q.push("vendor");let J=q.length>0?` [${q.join(", ")}]`:"",F=$?` (${W(j.gzipSize)} gzip)`:"";Q.push(` ${j.name.padEnd(20)} ${W(j.size).padStart(12)}${F}${J}`)}if(X.chunks.length>10)Q.push(` ... and ${X.chunks.length-10} more chunks`);Q.push("");let K=Z.topModules||10;Q.push(`Largest Modules (Top ${K})`),Q.push("\u2500".repeat(50));for(let j=0;j<Math.min(K,X.largestModules.length);j++){let q=X.largestModules[j],J=$?` (${W(q.gzipSize)} gzip)`:"";Q.push(` ${(j+1).toString().padStart(2)}. ${q.path}`),Q.push(` ${W(q.size)}${J}`)}if(Q.push(""),X.duplicates.length>0){Q.push("Duplicate Modules"),Q.push("\u2500".repeat(50));for(let j of X.duplicates.slice(0,5))Q.push(` ${j.path}`),Q.push(` ${j.count} copies, wasting ${W(j.wastedBytes)}`);if(X.duplicates.length>5)Q.push(` ... and ${X.duplicates.length-5} more duplicates`);Q.push("")}if(Z.recommendations!==!1){let j=N(X,Z);if(j.recommendations.length>0){Q.push("Recommendations"),Q.push("\u2500".repeat(50));for(let q of j.recommendations.slice(0,5)){let J=q.impact==="high"?"\u26A1":q.impact==="medium"?"\uD83D\uDCCA":"\uD83D\uDCA1";Q.push(` ${J} ${q.title}`),Q.push(` ${q.description}`)}Q.push("")}}if(X.warnings.length>0){Q.push("Warnings"),Q.push("\u2500".repeat(50));for(let j of X.warnings)Q.push(` \u26A0\uFE0F ${j}`);Q.push("")}return Q.join(`
|
|
3
|
+
`)}function l(X,Z){let Q=[],$=Z.showGzip!==!1;if(Q.push("# Bundle Analysis Report"),Q.push(""),Q.push(`Generated: ${new Date(X.timestamp).toISOString()}`),Q.push(""),Q.push("## Summary"),Q.push(""),Q.push("| Metric | Value |"),Q.push("|--------|-------|"),Q.push(`| Total Size | ${W(X.totalSize)} |`),$)Q.push(`| Gzip Size | ${W(X.totalGzipSize)} |`);Q.push(`| Modules | ${X.moduleCount} |`),Q.push(`| Chunks | ${X.chunks.length} |`),Q.push(`| Duplicates | ${X.duplicates.length} |`),Q.push(""),Q.push("## Size by Type"),Q.push(""),Q.push("| Type | Size | Gzip | % | Files |"),Q.push("|------|------|------|---|-------|");let U=["js","css","html","image","font","other"];for(let j of U){let q=X.byType[j];if(q.count>0)Q.push(`| ${j} | ${W(q.size)} | ${W(q.gzipSize)} | ${E(q.size,X.totalSize)} | ${q.count} |`)}Q.push(""),Q.push("## Chunks"),Q.push(""),Q.push("| Name | Size | Gzip | Modules | Type |"),Q.push("|------|------|------|---------|------|");for(let j of X.chunks.slice(0,15)){let q=j.isEntry?"Entry":j.isVendor?"Vendor":"-";Q.push(`| ${j.name} | ${W(j.size)} | ${W(j.gzipSize)} | ${j.modules.length} | ${q} |`)}Q.push("");let K=Z.topModules||10;Q.push(`## Largest Modules (Top ${K})`),Q.push(""),Q.push("| # | Path | Size | Gzip |"),Q.push("|---|------|------|------|");for(let j=0;j<Math.min(K,X.largestModules.length);j++){let q=X.largestModules[j];Q.push(`| ${j+1} | \`${q.path}\` | ${W(q.size)} | ${W(q.gzipSize)} |`)}if(Q.push(""),X.duplicates.length>0){Q.push("## Duplicates"),Q.push(""),Q.push("| Path | Copies | Wasted |"),Q.push("|------|--------|--------|");for(let j of X.duplicates.slice(0,10))Q.push(`| \`${j.path}\` | ${j.count} | ${W(j.wastedBytes)} |`);Q.push("")}if(Z.recommendations!==!1){let j=N(X,Z);if(j.recommendations.length>0){Q.push("## Recommendations"),Q.push("");for(let q of j.recommendations)Q.push(`### ${q.title}`),Q.push(""),Q.push(q.description),Q.push(""),Q.push(`- **Impact:** ${q.impact}`),Q.push(`- **Effort:** ${q.effort}`),Q.push("")}}return Q.join(`
|
|
4
|
+
`)}function N(X,Z){let Q=[],$=[];if(Z.threshold&&X.totalSize>Z.threshold)Q.push({severity:"error",message:`Bundle size (${W(X.totalSize)}) exceeds threshold (${W(Z.threshold)})`});if(X.totalSize>1048576)Q.push({severity:"warning",message:`Bundle is over 1MB (${W(X.totalSize)})`,details:"Large bundles can significantly impact load time"});if(X.duplicates.length>0){let q=X.duplicates.reduce((J,F)=>J+F.wastedBytes,0);Q.push({severity:"warning",message:`${X.duplicates.length} duplicate modules found, wasting ${W(q)}`}),$.push({title:"Remove Duplicate Modules",description:"Consider using import aliases or ensuring consistent package versions to eliminate duplicates.",impact:"medium",effort:"low"})}if(X.byType.js.size/X.totalSize>0.8&&X.totalSize>512000)$.push({title:"Code Splitting",description:"Over 80% of your bundle is JavaScript. Consider splitting code by route or feature.",impact:"high",effort:"medium"});let K=X.largestModules.filter((q)=>q.size>102400);if(K.length>0){Q.push({severity:"info",message:`${K.length} modules are over 100KB`});for(let q of K){if(q.path.includes("lodash")&&!q.path.includes("lodash-es"))$.push({title:"Use lodash-es instead of lodash",description:"lodash-es supports tree-shaking and can significantly reduce bundle size.",impact:"high",effort:"low"});if(q.path.includes("moment"))$.push({title:"Replace moment.js",description:"Consider using date-fns or dayjs for smaller date handling libraries.",impact:"high",effort:"medium"})}}if(X.byType.image.size>512000)$.push({title:"Optimize Images",description:`Images account for ${W(X.byType.image.size)}. Consider using WebP/AVIF formats and responsive images.`,impact:"high",effort:"low"});let j=100;if(X.totalSize>1048576)j-=20;else if(X.totalSize>512000)j-=10;if(j-=Math.min(20,X.duplicates.length*2),j-=Math.min(15,K.length*3),Z.threshold&&X.totalSize>Z.threshold)j-=25;return{score:Math.max(0,j),issues:Q,recommendations:$}}var i={lodash:{alternative:"lodash-es or individual imports",savings:"~70%"},moment:{alternative:"date-fns or dayjs",savings:"~90%"},"chart.js":{alternative:"chart.js with tree-shaking",savings:"~50%"},"highlight.js":{alternative:"Selective language imports",savings:"~80%"},fontawesome:{alternative:"Individual icon imports",savings:"~90%"},"material-ui":{alternative:"Named imports from @mui/*",savings:"~60%"}};function n(X){for(let[Z,Q]of Object.entries(i))if(X.includes(Z))return{title:`Optimize ${Z}`,description:`Consider using ${Q.alternative}. Potential savings: ${Q.savings}`,impact:"high",effort:"low"};return null}var o={default:{js:"#f7df1e",css:"#264de4",html:"#e34c26",image:"#4caf50",font:"#9c27b0",other:"#607d8b",vendor:"#ff5722"},pastel:{js:"#fff3b0",css:"#b0d4ff",html:"#ffb0b0",image:"#b0ffb0",font:"#e0b0ff",other:"#d0d0d0",vendor:"#ffcfb0"},monochrome:{js:"#333333",css:"#555555",html:"#777777",image:"#999999",font:"#bbbbbb",other:"#dddddd",vendor:"#444444"}};function x(X,Z={}){let{title:Q="Bundle Analysis",gzip:$=!0,colorScheme:U="default"}=Z,K=o[U],j=a(X),q=JSON.stringify(j);return`<!DOCTYPE html>
|
|
5
|
+
<html lang="en">
|
|
6
|
+
<head>
|
|
7
|
+
<meta charset="UTF-8">
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
9
|
+
<title>${M(Q)}</title>
|
|
10
|
+
<style>
|
|
11
|
+
* {
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
margin: 0;
|
|
14
|
+
padding: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
body {
|
|
18
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
19
|
+
background: #1a1a2e;
|
|
20
|
+
color: #eee;
|
|
21
|
+
min-height: 100vh;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.header {
|
|
25
|
+
background: #16213e;
|
|
26
|
+
padding: 1rem 2rem;
|
|
27
|
+
display: flex;
|
|
28
|
+
justify-content: space-between;
|
|
29
|
+
align-items: center;
|
|
30
|
+
border-bottom: 1px solid #0f3460;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.header h1 {
|
|
34
|
+
font-size: 1.5rem;
|
|
35
|
+
font-weight: 500;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.stats {
|
|
39
|
+
display: flex;
|
|
40
|
+
gap: 2rem;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.stat {
|
|
44
|
+
text-align: center;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.stat-value {
|
|
48
|
+
font-size: 1.25rem;
|
|
49
|
+
font-weight: bold;
|
|
50
|
+
color: #e94560;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.stat-label {
|
|
54
|
+
font-size: 0.75rem;
|
|
55
|
+
color: #888;
|
|
56
|
+
text-transform: uppercase;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.controls {
|
|
60
|
+
background: #16213e;
|
|
61
|
+
padding: 0.75rem 2rem;
|
|
62
|
+
display: flex;
|
|
63
|
+
gap: 1rem;
|
|
64
|
+
align-items: center;
|
|
65
|
+
border-bottom: 1px solid #0f3460;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.controls label {
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
gap: 0.5rem;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.controls input[type="checkbox"] {
|
|
76
|
+
width: 1rem;
|
|
77
|
+
height: 1rem;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.search-box {
|
|
81
|
+
flex: 1;
|
|
82
|
+
max-width: 300px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.search-box input {
|
|
86
|
+
width: 100%;
|
|
87
|
+
padding: 0.5rem 1rem;
|
|
88
|
+
border: 1px solid #0f3460;
|
|
89
|
+
border-radius: 4px;
|
|
90
|
+
background: #1a1a2e;
|
|
91
|
+
color: #eee;
|
|
92
|
+
font-size: 0.875rem;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.search-box input:focus {
|
|
96
|
+
outline: none;
|
|
97
|
+
border-color: #e94560;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.breadcrumb {
|
|
101
|
+
background: #16213e;
|
|
102
|
+
padding: 0.5rem 2rem;
|
|
103
|
+
display: flex;
|
|
104
|
+
gap: 0.5rem;
|
|
105
|
+
align-items: center;
|
|
106
|
+
font-size: 0.875rem;
|
|
107
|
+
border-bottom: 1px solid #0f3460;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.breadcrumb-item {
|
|
111
|
+
color: #888;
|
|
112
|
+
cursor: pointer;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.breadcrumb-item:hover {
|
|
116
|
+
color: #e94560;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.breadcrumb-item.active {
|
|
120
|
+
color: #eee;
|
|
121
|
+
cursor: default;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.breadcrumb-sep {
|
|
125
|
+
color: #444;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
#treemap {
|
|
129
|
+
width: 100%;
|
|
130
|
+
height: calc(100vh - 180px);
|
|
131
|
+
min-height: 400px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.tooltip {
|
|
135
|
+
position: fixed;
|
|
136
|
+
background: #16213e;
|
|
137
|
+
border: 1px solid #0f3460;
|
|
138
|
+
border-radius: 4px;
|
|
139
|
+
padding: 0.75rem 1rem;
|
|
140
|
+
pointer-events: none;
|
|
141
|
+
z-index: 1000;
|
|
142
|
+
max-width: 400px;
|
|
143
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.tooltip-title {
|
|
147
|
+
font-weight: bold;
|
|
148
|
+
margin-bottom: 0.5rem;
|
|
149
|
+
word-break: break-all;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.tooltip-row {
|
|
153
|
+
display: flex;
|
|
154
|
+
justify-content: space-between;
|
|
155
|
+
gap: 2rem;
|
|
156
|
+
font-size: 0.875rem;
|
|
157
|
+
color: #888;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.tooltip-row span:last-child {
|
|
161
|
+
color: #eee;
|
|
162
|
+
font-weight: 500;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.legend {
|
|
166
|
+
position: fixed;
|
|
167
|
+
bottom: 1rem;
|
|
168
|
+
right: 1rem;
|
|
169
|
+
background: #16213e;
|
|
170
|
+
border: 1px solid #0f3460;
|
|
171
|
+
border-radius: 4px;
|
|
172
|
+
padding: 0.75rem 1rem;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.legend-title {
|
|
176
|
+
font-size: 0.75rem;
|
|
177
|
+
color: #888;
|
|
178
|
+
margin-bottom: 0.5rem;
|
|
179
|
+
text-transform: uppercase;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.legend-item {
|
|
183
|
+
display: flex;
|
|
184
|
+
align-items: center;
|
|
185
|
+
gap: 0.5rem;
|
|
186
|
+
font-size: 0.75rem;
|
|
187
|
+
margin-bottom: 0.25rem;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.legend-color {
|
|
191
|
+
width: 12px;
|
|
192
|
+
height: 12px;
|
|
193
|
+
border-radius: 2px;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.node {
|
|
197
|
+
cursor: pointer;
|
|
198
|
+
transition: opacity 0.2s;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.node:hover {
|
|
202
|
+
opacity: 0.8;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.node-label {
|
|
206
|
+
font-size: 11px;
|
|
207
|
+
fill: #000;
|
|
208
|
+
pointer-events: none;
|
|
209
|
+
text-anchor: middle;
|
|
210
|
+
}
|
|
211
|
+
</style>
|
|
212
|
+
</head>
|
|
213
|
+
<body>
|
|
214
|
+
<div class="header">
|
|
215
|
+
<h1>${M(Q)}</h1>
|
|
216
|
+
<div class="stats">
|
|
217
|
+
<div class="stat">
|
|
218
|
+
<div class="stat-value" id="total-size">${W(X.totalSize)}</div>
|
|
219
|
+
<div class="stat-label">Total Size</div>
|
|
220
|
+
</div>
|
|
221
|
+
<div class="stat">
|
|
222
|
+
<div class="stat-value" id="gzip-size">${W(X.totalGzipSize)}</div>
|
|
223
|
+
<div class="stat-label">Gzip Size</div>
|
|
224
|
+
</div>
|
|
225
|
+
<div class="stat">
|
|
226
|
+
<div class="stat-value">${X.moduleCount}</div>
|
|
227
|
+
<div class="stat-label">Modules</div>
|
|
228
|
+
</div>
|
|
229
|
+
<div class="stat">
|
|
230
|
+
<div class="stat-value">${X.chunks.length}</div>
|
|
231
|
+
<div class="stat-label">Chunks</div>
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
</div>
|
|
235
|
+
|
|
236
|
+
<div class="controls">
|
|
237
|
+
<div class="search-box">
|
|
238
|
+
<input type="text" id="search" placeholder="Search modules...">
|
|
239
|
+
</div>
|
|
240
|
+
<label>
|
|
241
|
+
<input type="checkbox" id="show-gzip" ${$?"checked":""}>
|
|
242
|
+
Show Gzip Size
|
|
243
|
+
</label>
|
|
244
|
+
</div>
|
|
245
|
+
|
|
246
|
+
<div class="breadcrumb" id="breadcrumb">
|
|
247
|
+
<span class="breadcrumb-item active">root</span>
|
|
248
|
+
</div>
|
|
249
|
+
|
|
250
|
+
<div id="treemap"></div>
|
|
251
|
+
|
|
252
|
+
<div class="tooltip" id="tooltip" style="display: none;"></div>
|
|
253
|
+
|
|
254
|
+
<div class="legend">
|
|
255
|
+
<div class="legend-title">File Types</div>
|
|
256
|
+
<div class="legend-item">
|
|
257
|
+
<div class="legend-color" style="background: ${K.js}"></div>
|
|
258
|
+
<span>JavaScript</span>
|
|
259
|
+
</div>
|
|
260
|
+
<div class="legend-item">
|
|
261
|
+
<div class="legend-color" style="background: ${K.css}"></div>
|
|
262
|
+
<span>CSS</span>
|
|
263
|
+
</div>
|
|
264
|
+
<div class="legend-item">
|
|
265
|
+
<div class="legend-color" style="background: ${K.html}"></div>
|
|
266
|
+
<span>HTML</span>
|
|
267
|
+
</div>
|
|
268
|
+
<div class="legend-item">
|
|
269
|
+
<div class="legend-color" style="background: ${K.image}"></div>
|
|
270
|
+
<span>Images</span>
|
|
271
|
+
</div>
|
|
272
|
+
<div class="legend-item">
|
|
273
|
+
<div class="legend-color" style="background: ${K.font}"></div>
|
|
274
|
+
<span>Fonts</span>
|
|
275
|
+
</div>
|
|
276
|
+
<div class="legend-item">
|
|
277
|
+
<div class="legend-color" style="background: ${K.other}"></div>
|
|
278
|
+
<span>Other</span>
|
|
279
|
+
</div>
|
|
280
|
+
</div>
|
|
281
|
+
|
|
282
|
+
<script src="https://d3js.org/d3.v7.min.js"></script>
|
|
283
|
+
<script>
|
|
284
|
+
const data = ${q};
|
|
285
|
+
const colors = ${JSON.stringify(K)};
|
|
286
|
+
|
|
287
|
+
let showGzip = ${$};
|
|
288
|
+
let currentRoot = data;
|
|
289
|
+
let searchTerm = '';
|
|
290
|
+
|
|
291
|
+
const container = document.getElementById('treemap');
|
|
292
|
+
const tooltip = document.getElementById('tooltip');
|
|
293
|
+
const breadcrumb = document.getElementById('breadcrumb');
|
|
294
|
+
const searchInput = document.getElementById('search');
|
|
295
|
+
const showGzipCheckbox = document.getElementById('show-gzip');
|
|
296
|
+
|
|
297
|
+
function formatSize(bytes) {
|
|
298
|
+
if (bytes < 1024) return bytes + ' B';
|
|
299
|
+
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(2) + ' KB';
|
|
300
|
+
return (bytes / (1024 * 1024)).toFixed(2) + ' MB';
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function getColor(d) {
|
|
304
|
+
if (d.data.type) {
|
|
305
|
+
return colors[d.data.type] || colors.other;
|
|
306
|
+
}
|
|
307
|
+
if (d.data.name.includes('node_modules') || d.data.name.includes('vendor')) {
|
|
308
|
+
return colors.vendor;
|
|
309
|
+
}
|
|
310
|
+
return colors.other;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function getSizeValue(d) {
|
|
314
|
+
return showGzip ? d.data.gzipSize : d.data.size;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function render() {
|
|
318
|
+
container.innerHTML = '';
|
|
319
|
+
|
|
320
|
+
const width = container.clientWidth;
|
|
321
|
+
const height = container.clientHeight;
|
|
322
|
+
|
|
323
|
+
const hierarchy = d3.hierarchy(currentRoot)
|
|
324
|
+
.sum(d => {
|
|
325
|
+
if (searchTerm && d.name && !d.name.toLowerCase().includes(searchTerm.toLowerCase())) {
|
|
326
|
+
return 0;
|
|
327
|
+
}
|
|
328
|
+
return d.children ? 0 : getSizeValue({ data: d });
|
|
329
|
+
})
|
|
330
|
+
.sort((a, b) => getSizeValue(b) - getSizeValue(a));
|
|
331
|
+
|
|
332
|
+
const treemap = d3.treemap()
|
|
333
|
+
.size([width, height])
|
|
334
|
+
.paddingOuter(3)
|
|
335
|
+
.paddingTop(19)
|
|
336
|
+
.paddingInner(1)
|
|
337
|
+
.round(true);
|
|
338
|
+
|
|
339
|
+
const root = treemap(hierarchy);
|
|
340
|
+
|
|
341
|
+
const svg = d3.select(container)
|
|
342
|
+
.append('svg')
|
|
343
|
+
.attr('width', width)
|
|
344
|
+
.attr('height', height);
|
|
345
|
+
|
|
346
|
+
const node = svg.selectAll('g')
|
|
347
|
+
.data(root.descendants().filter(d => d.depth > 0))
|
|
348
|
+
.join('g')
|
|
349
|
+
.attr('transform', d => \`translate(\${d.x0},\${d.y0})\`);
|
|
350
|
+
|
|
351
|
+
node.append('rect')
|
|
352
|
+
.attr('class', 'node')
|
|
353
|
+
.attr('width', d => Math.max(0, d.x1 - d.x0))
|
|
354
|
+
.attr('height', d => Math.max(0, d.y1 - d.y0))
|
|
355
|
+
.attr('fill', d => getColor(d))
|
|
356
|
+
.attr('stroke', '#1a1a2e')
|
|
357
|
+
.attr('stroke-width', 1)
|
|
358
|
+
.on('click', (event, d) => {
|
|
359
|
+
if (d.children) {
|
|
360
|
+
zoomIn(d.data);
|
|
361
|
+
}
|
|
362
|
+
})
|
|
363
|
+
.on('mouseover', (event, d) => showTooltip(event, d))
|
|
364
|
+
.on('mousemove', (event) => moveTooltip(event))
|
|
365
|
+
.on('mouseout', hideTooltip);
|
|
366
|
+
|
|
367
|
+
node.append('text')
|
|
368
|
+
.attr('class', 'node-label')
|
|
369
|
+
.attr('x', d => (d.x1 - d.x0) / 2)
|
|
370
|
+
.attr('y', d => (d.y1 - d.y0) / 2 + 4)
|
|
371
|
+
.text(d => {
|
|
372
|
+
const width = d.x1 - d.x0;
|
|
373
|
+
const height = d.y1 - d.y0;
|
|
374
|
+
if (width < 40 || height < 20) return '';
|
|
375
|
+
const name = d.data.name;
|
|
376
|
+
const maxLen = Math.floor(width / 7);
|
|
377
|
+
return name.length > maxLen ? name.slice(0, maxLen - 2) + '..' : name;
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
// Group headers
|
|
381
|
+
node.filter(d => d.children)
|
|
382
|
+
.append('text')
|
|
383
|
+
.attr('x', 4)
|
|
384
|
+
.attr('y', 14)
|
|
385
|
+
.attr('fill', '#000')
|
|
386
|
+
.attr('font-size', '12px')
|
|
387
|
+
.attr('font-weight', 'bold')
|
|
388
|
+
.text(d => {
|
|
389
|
+
const width = d.x1 - d.x0;
|
|
390
|
+
const name = d.data.name;
|
|
391
|
+
const maxLen = Math.floor(width / 7);
|
|
392
|
+
return name.length > maxLen ? name.slice(0, maxLen - 2) + '..' : name;
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function showTooltip(event, d) {
|
|
397
|
+
const size = d.data.size || d.value;
|
|
398
|
+
const gzipSize = d.data.gzipSize || Math.round(size * 0.3);
|
|
399
|
+
const path = d.data.path || d.data.name;
|
|
400
|
+
|
|
401
|
+
tooltip.innerHTML = \`
|
|
402
|
+
<div class="tooltip-title">\${path}</div>
|
|
403
|
+
<div class="tooltip-row">
|
|
404
|
+
<span>Size</span>
|
|
405
|
+
<span>\${formatSize(size)}</span>
|
|
406
|
+
</div>
|
|
407
|
+
<div class="tooltip-row">
|
|
408
|
+
<span>Gzip</span>
|
|
409
|
+
<span>\${formatSize(gzipSize)}</span>
|
|
410
|
+
</div>
|
|
411
|
+
\${d.data.type ? \`<div class="tooltip-row"><span>Type</span><span>\${d.data.type}</span></div>\` : ''}
|
|
412
|
+
\${d.children ? \`<div class="tooltip-row"><span>Children</span><span>\${d.children.length}</span></div>\` : ''}
|
|
413
|
+
\`;
|
|
414
|
+
tooltip.style.display = 'block';
|
|
415
|
+
moveTooltip(event);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function moveTooltip(event) {
|
|
419
|
+
const x = event.clientX + 10;
|
|
420
|
+
const y = event.clientY + 10;
|
|
421
|
+
tooltip.style.left = x + 'px';
|
|
422
|
+
tooltip.style.top = y + 'px';
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function hideTooltip() {
|
|
426
|
+
tooltip.style.display = 'none';
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function zoomIn(node) {
|
|
430
|
+
currentRoot = node;
|
|
431
|
+
updateBreadcrumb();
|
|
432
|
+
render();
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function zoomOut(index) {
|
|
436
|
+
let node = data;
|
|
437
|
+
const parts = getBreadcrumbParts();
|
|
438
|
+
for (let i = 1; i <= index; i++) {
|
|
439
|
+
const child = node.children?.find(c => c.name === parts[i]);
|
|
440
|
+
if (child) node = child;
|
|
441
|
+
}
|
|
442
|
+
currentRoot = node;
|
|
443
|
+
updateBreadcrumb();
|
|
444
|
+
render();
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function getBreadcrumbParts() {
|
|
448
|
+
const parts = ['root'];
|
|
449
|
+
let node = currentRoot;
|
|
450
|
+
const path = [];
|
|
451
|
+
|
|
452
|
+
function findPath(current, target, currentPath) {
|
|
453
|
+
if (current === target) {
|
|
454
|
+
path.push(...currentPath);
|
|
455
|
+
return true;
|
|
456
|
+
}
|
|
457
|
+
if (current.children) {
|
|
458
|
+
for (const child of current.children) {
|
|
459
|
+
if (findPath(child, target, [...currentPath, child.name])) {
|
|
460
|
+
return true;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if (currentRoot !== data) {
|
|
468
|
+
findPath(data, currentRoot, []);
|
|
469
|
+
parts.push(...path);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
return parts;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
function updateBreadcrumb() {
|
|
476
|
+
const parts = getBreadcrumbParts();
|
|
477
|
+
breadcrumb.innerHTML = parts.map((part, i) => {
|
|
478
|
+
const isLast = i === parts.length - 1;
|
|
479
|
+
const sep = i > 0 ? '<span class="breadcrumb-sep">/</span>' : '';
|
|
480
|
+
return \`\${sep}<span class="breadcrumb-item \${isLast ? 'active' : ''}" onclick="zoomOut(\${i})">\${part}</span>\`;
|
|
481
|
+
}).join('');
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
searchInput.addEventListener('input', (e) => {
|
|
485
|
+
searchTerm = e.target.value;
|
|
486
|
+
render();
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
showGzipCheckbox.addEventListener('change', (e) => {
|
|
490
|
+
showGzip = e.target.checked;
|
|
491
|
+
render();
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
window.addEventListener('resize', render);
|
|
495
|
+
|
|
496
|
+
render();
|
|
497
|
+
</script>
|
|
498
|
+
</body>
|
|
499
|
+
</html>`}function a(X){let Z={name:"root",size:X.totalSize,gzipSize:X.totalGzipSize,children:[]};for(let Q of X.chunks){let $={name:Q.name,size:Q.size,gzipSize:Q.gzipSize,children:[]};for(let U of Q.modules)e($,U);Z.children.push($)}return Z}function e(X,Z){let Q=Z.path.split("/"),$=X;for(let K=0;K<Q.length-1;K++){let j=Q[K],q=$.children?.find((J)=>J.name===j);if(!q){if(q={name:j,size:0,gzipSize:0,children:[]},!$.children)$.children=[];$.children.push(q)}$=q}let U=Q[Q.length-1];if(!$.children)$.children=[];$.children.push({name:U,path:Z.path,size:Z.size,gzipSize:Z.gzipSize,type:Z.type}),s(X,Z.size,Z.gzipSize)}function s(X,Z,Q){}function M(X){return X.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function T(X){let Z=process.platform,Q=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";Bun.spawn([Q,X],{stdio:["ignore","ignore","ignore"]})}import P from"fs";import S from"path";async function CQ(X={}){let{directory:Z="dist",output:Q,format:$="html",open:U=!0,gzip:K=!0,threshold:j,recommendations:q=!0,topModules:J=20,parseImports:F=!0}=X,V=await L(Z,{parseImports:F,detectDuplicates:!0,topModulesCount:J}),_=j?typeof j==="string"?I(j):j:void 0,w=_?V.totalSize>_:!1,G,C;if($==="html"){let A={title:`Bundle Analysis - ${S.basename(S.resolve(Z))}`,gzip:K};if(G=x(V,A),C=Q||S.join(Z,"bundle-report.html"),await P.promises.writeFile(C,G),U)T(C)}else if(G=R(V,{format:$,threshold:_,recommendations:q,topModules:J,showGzip:K}),Q)C=Q,await P.promises.writeFile(C,G);return{stats:V,report:G,outputPath:C,exceedsThreshold:w}}async function GQ(X){let Z=await L(X,{parseImports:!1,detectDuplicates:!1,topModulesCount:0});return{totalSize:Z.totalSize,totalSizeFormatted:W(Z.totalSize),gzipSize:Z.totalGzipSize,gzipSizeFormatted:W(Z.totalGzipSize),moduleCount:Z.moduleCount,chunkCount:Z.chunks.length}}export{E as percentage,I as parseSize,T as openInBrowser,n as getModuleRecommendation,GQ as getBundleSummary,x as generateTreemap,R as generateReport,W as formatBytes,L as collectBundleStats,N as analyzeBundle,CQ as analyze};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Rp as R,cm as E,dm as M}from"./chunk-r6p4ws0a.js";import{Wt as m,Yt as d,Zt as p}from"./chunk-3952ykhb.js";import{eu as g,hu as u}from"./chunk-pw0rzgpv.js";var f=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function C(w,J,z){let B={fullTag:z,content:J,attrs:w};if(/\bserver\b/.test(w))return{...B,type:"server"};if(/\bdata-stx-scoped\b/.test(w))return{...B,type:"client"};if(f.test(J))return{...B,type:"signals"};if(/\bclient\b/.test(w)||/\btype\s*=\s*["']module["']/.test(w)||/\bsrc\s*=/.test(w))return{...B,type:"client"};return{...B,type:"server"}}var S=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function P(w){let J=[],z=[],B=[],Y=0;while(Y<w.length){let Q=w.indexOf("<",Y);if(Q===-1)break;let U=M(w,Q);if(U>Q){Y=U;continue}let X=E(w,Q);if(X>Q){let $=w.slice(Q,X),j=S.exec($);if(j){let F=C(j[1],j[2],$);switch(F.type){case"signals":J.push(F);break;case"client":z.push(F);break;case"server":B.push(F);break}}Y=X;continue}Y=Q+(w.startsWith("<!--",Q)?4:1)}return{signals:J,client:z,server:B}}import L from"path";m();var c="stx-page-head:",i=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,A=null;function h(){if(A!==null)return A;try{let{getRouterScript:w}=(p(),g(d));A=`<script>${w()}</script>`}catch{A=""}return A}async function e(w,J){if(J===!1)return null;if(J&&typeof J==="string"){let B=L.resolve(w,J);if(await Bun.file(B).exists())return B;return null}let z=L.join(w,"app.stx");if(await Bun.file(z).exists())return z;return null}async function t(w,J){try{let z=await Bun.file(w).text(),B=z,Y=z.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(Y)B=Y[1].trim();let Q=P(z),U=[...Q.client.map((Z)=>Z.fullTag),...Q.signals.map((Z)=>Z.fullTag)],X=[],$=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,j;while((j=$.exec(z))!==null)X.push(j[0]);let F=B;for(let Z of Q.server)F=F.replace(Z.fullTag,"");for(let Z of Q.client)F=F.replace(Z.fullTag,"");F=F.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let V="<!--__STX_PAGE_SLOT__-->";if(F=F.replace(/<slot\s*\/>/gi,V).replace(/<slot\s*>\s*<\/slot>/gi,V),!F.includes(V))return console.warn(`[stx] Shell ${w} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:W,extractVariables:G,defaultConfig:_,loadStxConfig:v}=await import("./chunk-hyyzp99b.js"),k=await v(),H={__filename:w,__dirname:L.dirname(w)};for(let Z of U){let K=Z.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(K&&!Z.includes("client")&&!Z.includes('type="module"'))await G(K[1],H,w)}let N=await W(F,H,w,{..._,...k,...J},new Set),q=N.indexOf(V);if(q===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:N.substring(0,q),afterSlot:N.substring(q+V.length),filePath:w,shellScripts:U,shellStyles:X}}catch(z){return console.error(`[stx] Error processing shell ${w}:`,z),null}}function ww(w,J,z){let B,Y="",Q=J.match(i);if(Q){J=J.replace(Q[0],"");try{let F=Buffer.from(Q[1],"base64").toString("utf8"),V=F.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(V)B=V[1].trim();Y=F.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let U=z||B||"stx App",X=h(),$="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
|
|
3
|
+
<html lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<title>${U}</title>
|
|
8
|
+
${Y?` ${Y}
|
|
9
|
+
`:""} ${w.shellStyles.join(`
|
|
10
|
+
`)}
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
${w.beforeSlot}
|
|
14
|
+
<div data-stx-content>${J}</div>
|
|
15
|
+
${w.afterSlot}
|
|
16
|
+
${w.shellScripts.filter((F)=>!F.includes("server")).join(`
|
|
17
|
+
`)}
|
|
18
|
+
${$}
|
|
19
|
+
${X}
|
|
20
|
+
</body>
|
|
21
|
+
</html>`}function x(w,J={}){let z=w.trim();if(!R(z))return w;let B=[],Y=z.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(Y){let $=Y[1],j=/<style\b[^>]*>[\s\S]*?<\/style>/gi,F;while((F=j.exec($))!==null)B.push(F[0])}if(J.preserveHead&&Y){let $=[],j=/<title\b[^>]*>[\s\S]*?<\/title>|<meta\b[^>]*>|<link\b[^>]*>/gi,F;while((F=j.exec(Y[1]))!==null){if(/<meta\b[^>]*(?:\bcharset|name="viewport")/i.test(F[0]))continue;$.push(F[0])}if($.length>0)B.unshift(`<!--${c}${Buffer.from($.join(`
|
|
22
|
+
`),"utf8").toString("base64")}-->`)}let Q=z.match(/<body\b[^>]*>/i),U=z.lastIndexOf("</body>");if(Q&&U!==-1){let $=Q.index+Q[0].length,j=z.slice($,U).trim();if(B.length>0)return B.join(`
|
|
23
|
+
`)+`
|
|
24
|
+
`+j;return j}let X=z;if(X=X.replace(/<!DOCTYPE\b[^>]*>/i,""),X=X.replace(/<html\b[^>]*>/i,""),X=X.replace(/<\/html\s*>/i,""),Y)X=X.replace(/<head\b[^>]*>[\s\S]*?<\/head>/i,B.join(`
|
|
25
|
+
`));return X=X.replace(/<body\b[^>]*>/i,""),X=X.replace(/<\/body\s*>/i,""),X.trim()}function zw(w){return w.headers.get("X-STX-Router")==="true"}function Bw(w,J="main"){let z=w.trim(),B=[],Y=[],Q=z.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(Q){let q=Q[1],Z=/<style\b[^>]*>[\s\S]*?<\/style>/gi,K;while((K=Z.exec(q))!==null)B.push(K[0]);let I=/<script\b[^>]*data-stx-route-params[^>]*>[\s\S]*?<\/script>/gi;while((K=I.exec(q))!==null)Y.push(K[0])}let U=J.replace(/^[.#]/,"").toLowerCase(),X=new RegExp(`<${U}\\b[^>]*>`,"i"),$=z.match(X);if(!$||$.index===void 0)return x(w);let j=$.index+$[0].length,F=new RegExp(`<${U}\\b[^>]*>`,"gi"),V=new RegExp(`</${U}\\s*>`,"gi");F.lastIndex=j,V.lastIndex=j;let W=1,G=-1;while(W>0){let q=F.exec(z),Z=V.exec(z);if(!Z)break;if(q&&q.index<Z.index)W++,V.lastIndex=q.index+q[0].length;else if(W--,G=Z.index,W>0)F.lastIndex=Z.index+Z[0].length}if(G===-1)return x(w);let _=z.slice(j,G).trim(),v=[],k=z.match(/<body\b[^>]*>/i),H=z.lastIndexOf("</body>");if(k&&k.index!==void 0&&H!==-1){let Z=[[k.index+k[0].length,$.index],[G+`</${U}>`.length,H]],K=/<script\b[^>]*>[\s\S]*?<\/script>/gi;for(let[I,D]of Z){if(I>=D)continue;let T=z.slice(I,D),O;K.lastIndex=0;while((O=K.exec(T))!==null)v.push(O[0])}}let N=[];if(B.length>0)N.push(B.join(`
|
|
26
|
+
`));if(Y.length>0)N.push(Y.join(`
|
|
27
|
+
`));if(v.length>0)N.push(v.join(`
|
|
28
|
+
`));return N.push(_),N.join(`
|
|
29
|
+
`)}import b from"fs";import y from"path";function Yw(w,J,z){return{version:1,buildTime:new Date().toISOString(),routes:w,assets:J,outputDir:z}}function Zw(w,J){let z=y.join(J,"manifest.json");b.writeFileSync(z,JSON.stringify(w,null,2))}function $w(w){let J=y.join(w,"manifest.json");if(!b.existsSync(J))return null;try{let z=b.readFileSync(J,"utf-8"),B=JSON.parse(z);if(B.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${B.version}`),null;return B}catch(z){return console.warn("[stx] Failed to load manifest:",z),null}}
|
|
30
|
+
export{C as Jg,P as Kg,e as Lg,t as Mg,ww as Ng,x as Og,zw as Pg,Bw as Qg,Yw as Rg,Zw as Sg,$w as Tg};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Broadcast as D,BroadcastServer as U}from"ts-broadcasting";import{channel as b}from"ts-broadcasting";import{Broadcast as N,BroadcastServer as p}from"ts-broadcasting";var z=null,H=[];function X(){return z}async function Y(j){if(z)return z;let k=j.driver??"bun",q=j.host??"0.0.0.0",G=j.port??6001,J=j.scheme??"ws",E={verbose:j.verbose??!1,driver:k,default:k,connections:{[k]:{driver:k,host:q,port:G,scheme:J}}};return z=new U(E),D.setServer(z),await z.start(),z}async function Z(){for(let j of H)clearInterval(j);if(H.length=0,!z)return;await z.stop(),z=null}async function $(j){let k=await import(j),q=k.default??k;if(typeof q!=="function")throw Error(`routes/channels.ts must export a default function, got ${typeof q}`);let G=0;return q({channel(E,A){if(G++,A.authorize&&z)z.channels.channel(E,A.authorize);if(A.interval&&A.data){let L=A.event??`${E}.updated`,M=A.data,Q=setInterval(async()=>{try{let T=await M();V(E,L,T)}catch{}},A.interval);H.push(Q)}}}),G}var K=!1;function F(){if(z)return!0;if(!K)K=!0,console.warn("[stx] broadcast() called before server started \u2014 messages will be sent once broadcasting is ready");return!1}function V(j,k,q){if(!F())return;D.send(j,k,q)}function x(j,k,q){if(!F())return;D.toUser(j,k,q)}function C(j,k,q){if(!F())return;D.toUsers(j,k,q)}function S(j,k,q){if(!F())return;D.send(`private-${j}`,k,q)}function w(j,k,q){if(!F())return;D.presence(j,k,q)}
|
|
3
|
+
export{X as Ug,Y as Vg,Z as Wg,$ as Xg,V as Yg,x as Zg,C as _g,S as $g,w as ah,b as bh,N as ch,p as dh};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ls as Jq}from"./chunk-cbc56wpd.js";import{hu as Gq}from"./chunk-pw0rzgpv.js";import $ from"path";import{hasLocalConfig as Uq}from"bunfig";var a={fg:{light:"gray-900",dark:"gray-100",description:"Primary text"},"fg-strong":{light:"gray-700",dark:"gray-300",description:"Labels, secondary headings"},"fg-muted":{light:"gray-600",dark:"gray-400",description:"Supporting text"},"fg-soft":{light:"gray-500",dark:"gray-400",description:"De-emphasised text"},"fg-subtle":{light:"gray-400",dark:"gray-500",description:"Placeholders, disabled text"},surface:{light:"gray-50",dark:"gray-800",description:"Page and panel background"},"surface-raised":{light:"gray-100",dark:"gray-700",description:"Cards, popovers"},"surface-sunken":{light:"gray-200",dark:"gray-700",description:"Wells, track backgrounds"},line:{light:"gray-200",dark:"gray-700",description:"Default border, divider"},"line-strong":{light:"gray-300",dark:"gray-600",description:"Input border, focus ring track"},accent:{light:"indigo-600",dark:"indigo-400",description:"Primary action, selected state"},info:{light:"blue-600",dark:"blue-400",description:"Informational emphasis, links"},danger:{light:"red-600",dark:"red-400",description:"Errors, destructive actions"},success:{light:"green-600",dark:"green-400",description:"Confirmation"},warning:{light:"yellow-500",dark:"yellow-400",description:"Caution"},"accent-solid":{light:"indigo-600",dark:"indigo-500",description:"Primary button fill"},"info-solid":{light:"blue-600",dark:"blue-500",description:"Informational fill"},"danger-solid":{light:"red-600",dark:"red-500",description:"Destructive button fill"},"success-solid":{light:"green-600",dark:"green-500",description:"Confirmation fill"}};function m(G){return`--stx-${G}`}function p(G,q){let Q=q.lastIndexOf("-");if(Q===-1)return typeof G[q]==="string"?G[q]:void 0;let J=G[q.slice(0,Q)];if(!J||typeof J!=="object")return;let Y=J[q.slice(Q+1)];return typeof Y==="string"?Y:void 0}function o(G){let q={};for(let[Q,J]of Object.entries(a)){let Y=p(G,J.light);if(Y===void 0)continue;q[Q]=`var(${m(Q)}, ${Y})`}return q}function t(G){let q=[],Q=[];for(let[J,Y]of Object.entries(a)){let Z=p(G,Y.light),U=p(G,Y.dark);if(Z===void 0)continue;if(q.push(` ${m(J)}: ${Z};`),U!==void 0)Q.push(` ${m(J)}: ${U};`)}if(q.length===0)return"";return["/* stx role tokens \u2014 override any of these to re-theme by meaning. */",":root {",...q,"}",".dark {",...Q,"}",""].join(`
|
|
3
|
+
`)}function s(G){return typeof G==="object"&&G!==null&&!Array.isArray(G)}function g(G,q){let Q={...G};for(let[J,Y]of Object.entries(q))Q[J]=s(Y)&&s(Q[J])?g(Q[J],Y):Y;return Q}function e(G={},q={}){let Q=G.theme||{},J=q.theme||{},{extend:Y,...Z}=J,{extend:U,...z}=Q,X=z.colors||{};z.colors={...X,...o(X)};let A=g(z,Z),L=g(U||{},Y||{});if(Object.keys(L).length>0)A.extend=L;let H=[...G.safelist||[],...q.safelist||[]],E={...G.shortcuts||{},...q.shortcuts||{}},P=[...G.preflights||[],...q.preflights||[]];return{config:{...G,...q,theme:A,safelist:H,shortcuts:E,...P.length>0?{preflights:P}:{},content:[],output:""},safelist:H,shortcuts:E,includePreflight:q.preflight!==!1,minify:q.minify===!0,tokenCSS:t(X)}}var W={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"};var F=null,C=!1,_=null,b="",K=!1,Qq=256,V=new Map,O=new Map,j=null,d=null;function S(G){return Bun.hash(G).toString(16).padStart(16,"0").slice(0,16)}function u(G,q){if(V.has(G))V.delete(G);else if(V.size>=Qq)V.delete(V.keys().next().value);V.set(G,q)}function Wq(G){let q=S(G);if(O.has(q))O.delete(q);else if(O.size>=Qq)O.delete(O.keys().next().value);return O.set(q,G),q}function Dq(G){let q=O.get(G);if(q===void 0)return;return O.delete(G),O.set(G,q),q}async function Xq(G){if(!j)return null;try{let q=Bun.file($.join(j,`cw-${S(G)}.css`));if(!await q.exists())return null;return await q.text()}catch{return null}}async function zq(G,q){if(!j)return;try{if(!fs.existsSync(j))fs.mkdirSync(j,{recursive:!0});await Bun.write($.join(j,`cw-${S(G)}.css`),q)}catch{}}async function qq(G){try{let q=await import(G);if(q&&q.CSSGenerator)return{CSSGenerator:q.CSSGenerator,config:q.config,build:q.build,defaultConfig:q.defaultConfig,extractClasses:q.extractClasses}}catch{}return null}function Iq(){let G=[],q=process.cwd();while(q!==$.dirname(q))G.push($.join(q,"node_modules","@cwcss","crosswind","dist","index.js")),G.push($.join(q,"node_modules","@cwcss","crosswind","src","index.ts")),G.push($.join(q,"pantry","@cwcss","crosswind","dist","index.js")),G.push($.join(q,"pantry","@cwcss","crosswind","src","index.ts")),G.push($.join(q,"node_modules","@stacksjs","crosswind","dist","index.js")),G.push($.join(q,"pantry","@stacksjs","crosswind","dist","index.js")),q=$.dirname(q);return G}function Oq(){let G=[],q=process.env.HOME||process.env.USERPROFILE||"";if(q){let Q=[$.join(q,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),$.join(q,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),$.join(q,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),$.join(q,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),$.join(q,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),$.join(q,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];G.push(...Q)}return G.push($.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),G.push($.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),G}async function Yq(){if(C)return F;C=!0;try{let G=async(Y)=>{for(let Z of Y){if(!await Bun.file(Z).exists())continue;let U=await qq(Z);if(U){if(!process.env.STACKS_DEV_QUIET)console.log(`${W.green}[Crosswind]${W.reset} CSS engine loaded from ${$.dirname($.dirname(Z))}`);return U}}return null};if(process.env.CROSSWIND_SRC){let Y=$.resolve(process.env.CROSSWIND_SRC),Z=await G([Y]);if(!Z)throw Error(`CROSSWIND_SRC did not resolve to a Crosswind module: ${Y}`);return F=Z,F}let q=await G(Iq());if(q)return F=q,F;let Q=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of Q){let Z=await qq(Y);if(Z){if(F=Z,!process.env.STACKS_DEV_QUIET)console.log(`${W.green}[Crosswind]${W.reset} CSS engine loaded`);return F}}let J=await G(Oq());if(J)return F=J,F;throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${W.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${W.reset}`),console.warn(`${W.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${W.reset}`),null}}function Sq(){V.clear(),O.clear()}function xq(){F=null,C=!1,_=null,b="",V.clear(),O.clear(),d=null}async function Zq(G){try{if(!Uq({name:"crosswind",cwd:G}))return null;let{loadConfigWithResult:q}=await import("bunfig"),Q=await q({name:"crosswind",cwd:G,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Q?.path||!Q.config||Object.keys(Q.config).length===0)return null;let J=$.relative(G,Q.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${W.green}[Crosswind]${W.reset} Loaded config from ${J||Q.path}`);return Q.config}catch(q){if(q instanceof Error&&q.name==="ConfigNotFoundError")return null;return console.warn(`${W.yellow}[Crosswind]${W.reset} Failed to load crosswind config:`,q instanceof Error?q.message:q),null}}async function _q(G){let q=null;try{let{loadStxConfig:Q}=await import("./chunk-q020t182.js"),J=await Q(G);if(J.css)if(typeof J.css==="string"){let Y=$.isAbsolute(J.css)?J.css:$.resolve(G,J.css);if(await Bun.file(Y).exists()){let Z=await import(Y);q=Z.default||Z,console.log(`${W.green}[Crosswind]${W.reset} Loaded config from stx.config.ts \u2192 ${J.css}`)}}else{if(q={...J.css,content:J.css.content||[],preflight:J.css.preflight??!0,minify:J.css.minify??!1},J.css.config){let Y=$.isAbsolute(J.css.config)?J.css.config:$.resolve(G,J.css.config);if(await Bun.file(Y).exists()){let Z=await import(Y);q={...Z.default||Z,...q}}}console.log(`${W.green}[Crosswind]${W.reset} Using inline CSS config from stx.config.ts`)}}catch{}return q||await Zq(G)}function Fq(G){try{let q=new WeakSet;return S(JSON.stringify(G??{},(Q,J)=>{if(typeof J==="function")return`[fn]${String(J)}`;if(typeof J==="object"&&J!==null){if(q.has(J))return"[circular]";q.add(J)}return J})??"")}catch{return"unhashable"}}async function Nq(G){if(K)return b;K=!0;try{let q=await Yq();if(!q||!q.build)return K=!1,"";if(!_)_=await Zq(G);if(!_)return K=!1,"";let Q=q.defaultConfig?.theme||{},J=_.theme||{},Y={...q.defaultConfig,..._,theme:{...Q,...J,extend:{...Q.extend||{},...J.extend||{}}}},Z=performance.now(),U=await q.build(Y),z=performance.now()-Z;if(b=U.css,console.log(`${W.cyan}[Crosswind]${W.reset} Built ${U.classes.size} classes in ${z.toFixed(1)}ms`),Y.output){let X=$.isAbsolute(Y.output)?Y.output:$.join(G,Y.output),A=$.dirname(X);if(!fs.existsSync(A))fs.mkdirSync(A,{recursive:!0});await Bun.write(X,U.css)}return K=!1,U.css}catch(q){return console.error(`${W.red}[Crosswind]${W.reset} Build error:`,q),K=!1,b}}async function kq(G){_=null,await Nq(G)}function wq(){return b}function Vq(G){let q=new Set,Q=/class\s*=\s*["']([^"']+)["']/gi,J=Q.exec(G);while(J!==null){for(let U of J[1].split(/\s+/))if(U.trim())q.add(U.trim());J=Q.exec(G)}let Y=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,Z=Y.exec(G);while(Z!==null){let U=Z[1].match(/'([^']+)'/g);if(U){for(let z of U)for(let X of z.slice(1,-1).split(/\s+/))if(X.trim())q.add(X.trim())}Z=Y.exec(G)}return q}async function jq(G,q){try{let Q=await Yq();if(!Q)return"";let J=typeof Q.extractClasses==="function"?Q.extractClasses(G):Vq(G);if(J.size===0)return"";let Y=q?$.resolve(q):process.cwd();if(!j)j=Jq(Y,"cache");let Z=[...J].sort().join(" "),U=`${d||"default"}::${Z}`,z=V.get(U);if(z!==void 0)return u(U,z),z;let X=await Xq(U);if(X!==null)return u(U,X),X;if(!_)_=await _q(Y),d=Fq(_);let A=Q.defaultConfig||Q.config,L=_||{},H=e(A,L),{safelist:E,includePreflight:P,minify:x,tokenCSS:$q}=H,h=H.config,R=new Q.CSSGenerator(h);for(let I of E)R.generate(I);for(let I of J)R.generate(I);let N=R.toCSS(P,x),i=h.shortcuts||L.shortcuts||{};for(let[I,k]of Object.entries(i)){if(!J.has(I)&&!E.includes(I))continue;let w=k.split(/\s+/).filter(Boolean);for(let T of w)R.generate(T)}N=R.toCSS(P,x);let B=N.split(`
|
|
4
|
+
`);for(let[I,k]of Object.entries(i)){if(!J.has(I)&&!E.includes(I))continue;let w=k.split(/\s+/).filter(Boolean),T=[],y=[];for(let v of w){let c=v.startsWith("dark:"),n=`.${(c?v.slice(5):v).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let M=0;M<B.length;M++){let l=B[M].trim();if(l===`${n} {`||l.startsWith(`${n} {`)){let D=M,r="";while(D<B.length){if(r+=B[D],B[D].includes("}"))break;D++}let f=r.match(/\{([^}]+)\}/);if(f)if(c)y.push(f[1].trim());else T.push(f[1].trim());break}}}if(T.length)N+=`
|
|
5
|
+
.${I} { ${T.join(" ")} }`;if(y.length)N+=`
|
|
6
|
+
@media (prefers-color-scheme: dark) { .dark .${I} { ${y.join(" ")} } }`}return N=$q+N,u(U,N),zq(U,N),N}catch(Q){return console.warn("Failed to generate Crosswind CSS:",Q),""}}async function yq(G,q,Q=!1){let J=await jq(G,q);if(!J)return G;let Y=Q?`<link data-crosswind="generated" rel="stylesheet" href="/_stx/crosswind.${Wq(J)}.css">`:`<style data-crosswind="generated">
|
|
7
|
+
${J}
|
|
8
|
+
</style>`,Z=/(?:<style\b[^>]*\bdata-crosswind=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-crosswind=(?:"generated"|'generated')[^>]*>)/g;if(Z.test(G)){let U=!1;return G.replace(Z,()=>{if(U)return"";return U=!0,Y})}if(G.includes("</head>"))return G.replace("</head>",`${Y}
|
|
9
|
+
</head>`);if(G.includes("<body"))return G.replace(/<body([^>]*)>/,`<body$1>
|
|
10
|
+
${Y}`);return Y+G}
|
|
11
|
+
export{g as rs,e as ss,W as ts,Dq as us,Yq as vs,Sq as ws,xq as xs,Zq as ys,_q as zs,Fq as As,Nq as Bs,kq as Cs,wq as Ds,Vq as Es,jq as Fs,yq as Gs};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{jj as a,kj as b,lj as c,mj as d,nj as e,oj as f,pj as g,qj as h,rj as i,sj as j,tj as k,uj as l,vj as m,wj as n}from"./chunk-avwj12at.js";import"./chunk-r6p4ws0a.js";import"./chunk-8src5smc.js";import"./chunk-gcnrdgrq.js";import"./chunk-xp3fp266.js";import"./chunk-nye9brje.js";import"./chunk-tywvd1zc.js";import"./chunk-cbc56wpd.js";import"./chunk-x0zh76yv.js";import"./chunk-0ae6chzd.js";import"./chunk-kjr22neh.js";import"./chunk-3952ykhb.js";import"./chunk-dtmwr674.js";import"./chunk-pw0rzgpv.js";export{i as streamingSuspenseDirective,m as streamToResponse,g as streamTemplateSimple,a as streamTemplate,d as renderStreamingPage,k as registerStreamingDirectives,e as processStreamDirectives,l as processSectionDirectives,j as islandDirective,n as generateHydrationRuntime,f as extractStreamBoundaries,h as createStreamRenderer,b as buildSuspenseResolveScript,c as SUSPENSE_RESOLVER_RUNTIME};
|