eser 4.0.40 → 4.0.42
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/eser.js +3 -3
- package/package.json +1 -1
package/eser.js
CHANGED
|
@@ -122,7 +122,7 @@ ${o.join(`,
|
|
|
122
122
|
];
|
|
123
123
|
`;await S.fs.writeTextFile(t,i),Xc.debug(`Generated ${r.length} proxy definition(s)`)}async function NI(e){try{let t=await S.fs.readTextFile(e),n=[],r=t.matchAll(/export\s+(?:async\s+)?function\s+(\w+)/g);for(let i of r)i[1]!==void 0&&n.push(i[1]);let o=t.matchAll(/export\s+const\s+(\w+)\s*=/g);for(let i of o)i[1]!==void 0&&n.push(i[1]);return t.match(/export\s+default\s+/)&&n.push("default"),[...new Set(n)]}catch{return[]}}async function z8(e,t){let n=await NI(e);if(n.length===0)return t;let r=n.find(i=>i!=="default"&&i.endsWith("Page"));if(r)return r;let o=n.find(i=>i!=="default");return o||t}async function W8(e,t){let n=await NI(e);if(n.length===0)return t;let r=n.find(i=>i!=="default"&&i.endsWith("Layout"));if(r)return r;let o=n.find(i=>i!=="default");return o||t}function H8(e){let t=S.path.basename(S.path.dirname(e));return`${UI(BI(t))}Page`}function G8(e){let t=S.path.basename(S.path.dirname(e));return`${UI(BI(t))}Layout`}function BI(e){return e.startsWith("[...")?e.slice(4,-1):e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e}function UI(e){return e.split(/[-_\s]+/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}function zI(e,t){let n=pl(S.path.relative(e,t));return n.startsWith(".")?n:`./${n}`}function Y8(e,t,n){let r=[`path: "${e.routePath}"`,`component: ${t}`];return n&&r.push(`layout: ${n}`),`{ ${r.join(", ")} }`}var Xc,WI=P(()=>{ye();Ke();pa();Xc=de.getLogger(["laroux-bundler","route-generator"])});function X8(e,t){return S.path.relative(t,e)}async function HI(e){let{projectRoot:t,distDir:n,srcDir:r,changedFiles:o}=e,i=X8(r,t),a=S.path.resolve(n,Ax),f=S.path.resolve(a,i);bl.debug(`Creating virtual source: ${a}`),bl.debug(` Virtual src subdir: ${f}`);let d=await S.fs.exists(f);if(o&&o.size>0&&d)bl.debug(`Incremental update: ${o.size} file(s) changed`),await J8(o,r,f),bl.debug(`Virtual source updated incrementally: ${o.size} file(s)`);else{try{await YM(a)}catch{}await Z8(r,f,t),bl.debug(`Virtual source created: ${a}`)}return{virtualSrcDir:a,cleanup:async()=>{bl.debug(`Cleaning up virtual source: ${a}`);try{await S.fs.remove(a,{recursive:!0}),bl.debug("Virtual source cleaned up")}catch(p){bl.warn("Failed to clean up virtual source:",{error:p})}}}}async function J8(e,t,n){let r=[...ho.map(a=>`.${a}`),".json",".css"],o=0,i=0;for(let a of e){if(!a.startsWith(t))continue;let f=S.path.extname(a);if(!r.includes(f))continue;let d=S.path.relative(t,a),p=S.path.resolve(n,d);try{await S.fs.stat(a),await ld(S.path.dirname(p)),await xl(a,p,{overwrite:!0}),o++}catch{try{await S.fs.remove(p),i++}catch{}}}(o>0||i>0)&&bl.debug(`Incremental update: ${o} copied, ${i} deleted`)}async function Z8(e,t,n){let r=0,o=[...ho.map(i=>`.${i}`),".json",".css"];for await(let i of Uo(e,{includeDirs:!1})){let a=S.path.extname(i.path);if(!o.includes(a))continue;let f=S.path.relative(e,i.path);if(V8.test(f))continue;let d=S.path.resolve(t,f);await S.fs.ensureDir(S.path.dirname(d)),await xl(i.path,d),r++}bl.debug(`Copied ${r} source file(s) to virtual source`)}function Bg(e,t,n,r){let o=S.path.relative(t,e),i=r??S.path.basename(t);return S.path.resolve(n,i,o)}function GI(e,t,n){return e.map(r=>{let o=Bg(r.filePath,t,n),i=`${Ax}/${r.relativePath}`;return{...r,filePath:o,relativePath:i}})}var V8,bl,Ax,MS=P(()=>{ye();pa();Mg();Ke();V8=/(?:node_modules|\/\.|^\.|\\\.)/,bl=de.getLogger(["laroux-bundler","virtual-source"]),Ax="_bundle_src"});function YI(){return IS||(IS=new _S,Jc.debug("Created global build cache")),IS}var Jc,_S,IS,VI=P(()=>{Ke();OS();Jc=de.getLogger(["laroux-bundler","build-cache"]),_S=class{clientComponentCache=new Map;cssModuleCache=new Map;routeCache=null;getClientComponent(t,n){let r=this.clientComponentCache.get(t);return r&&r.mtime>=n?(Jc.debug(`Cache hit: client component ${t}`),r):null}setClientComponent(t,n,r,o){this.clientComponentCache.set(t,{isClient:n,exportNames:r,mtime:o})}getCssModuleResult(t,n){let r=this.cssModuleCache.get(t);return r&&r.mtime>=n?(Jc.debug(`Cache hit: CSS module ${t}`),r):null}setCssModuleResult(t,n,r,o){this.cssModuleCache.set(t,{code:n,exports:r,mtime:o})}getRouteCache(t){return this.routeCache&&this.routeCache.mtime>=t?(Jc.debug("Cache hit: route scan"),this.routeCache):null}setRouteCache(t,n,r,o){this.routeCache={routes:t,apiRoutes:n,proxies:r,mtime:o}}invalidateFile(t){this.clientComponentCache.has(t)&&(this.clientComponentCache.delete(t),Jc.debug(`Invalidated: client component ${t}`)),this.cssModuleCache.has(t)&&(this.cssModuleCache.delete(t),Jc.debug(`Invalidated: CSS module ${t}`)),(t.includes("/routes/")||t.includes("\\routes\\"))&&(this.routeCache=null,MI(),Jc.debug("Invalidated: route cache"))}invalidateFiles(t){for(let n of t)this.invalidateFile(n)}clear(){this.clientComponentCache.clear(),this.cssModuleCache.clear(),this.routeCache=null,Jc.debug("All caches cleared")}getStats(){return{clientComponents:this.clientComponentCache.size,cssModules:this.cssModuleCache.size,hasRoutes:this.routeCache!==null}}},IS=null});function JI(e){return e*2}function ZI(e,t,n,r){for(;t<e.length;++t){let o=e[t];e[n++]=r[o>>4],e[n++]=r[o&15]}return n}var Q8,XI,QI=P(()=>{Q8=new TextEncoder().encode("0123456789abcdef"),XI=new Uint8Array(128).fill(16);Q8.forEach((e,t)=>XI[e]=t);new TextEncoder().encode("ABCDEF").forEach((e,t)=>XI[e]=t+10)});function KI(e,t){let n=e.length;if(e.byteOffset){let r=new Uint8Array(e.buffer);r.set(e),e=r.subarray(0,n)}return e=new Uint8Array(e.buffer.transfer(t)),e.set(e.subarray(0,n),t-n),[e,t-n]}var jI=P(()=>{});function Ox(e){typeof e=="string"?e=new TextEncoder().encode(e):e instanceof ArrayBuffer?e=new Uint8Array(e).slice():e=e.slice();let[t,n]=KI(e,JI(e.length));return ZI(t,n,0,qI),new TextDecoder().decode(t)}var qI,$I,DS=P(()=>{QI();jI();qI=new TextEncoder().encode("0123456789abcdef"),$I=new Uint8Array(128).fill(16);qI.forEach((e,t)=>$I[e]=t);new TextEncoder().encode("ABCDEF").forEach((e,t)=>$I[e]=t+10)});var Mx,rp,LS=P(()=>{"use strict";Mx=(e,t)=>({success:!0,outputs:e,metafile:t?.metafile,entrypointManifest:t?.entrypointManifest,entrypoint:t?.entrypoint,totalSize:t?.totalSize}),rp=e=>({success:!1,outputs:new Map,errors:e})});function K8(e,t){let n=Object.keys(t);if(n.length===0)return e;n.sort((a,f)=>f.length-a.length);let r=!1;for(let a of n)if(e.includes(a)){r=!0;break}if(!r)return e;let o=n.map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),i=new RegExp(`\\b(${o.join("|")})\\b`,"g");return e.replace(i,a=>t[a]??a)}var Ix,_x,NS,BS=P(()=>{"use strict";DS();Ke();ye();pa();LS();Ix=de.getLogger(["bundler","deno-bundler"]),_x=class{name="deno-bundler";options;constructor(t={}){this.options=t}async bundle(t){let n=await S.fs.makeTempDir({prefix:"deno-bundle-"});try{let r=Object.values(t.entrypoints),o=Object.keys(t.entrypoints),i=[...r];if(this.options.buildId!==void 0){let m=S.path.join(n,"_build-id-entry.ts");await S.fs.writeTextFile(m,`export const BUILD_ID = "${this.options.buildId}";
|
|
124
124
|
`),i.unshift(m)}let a=t.platform==="browser"?"browser":"deno",f=t.sourcemap===!0?"external":t.sourcemap===!1?void 0:t.sourcemap,d={entrypoints:i,outputDir:n,format:"esm",codeSplitting:t.codeSplitting,minify:t.minify,platform:a,sourcemap:f};t.external!==void 0&&(d.external=t.external),Ix.debug("Calling Deno.bundle",{entrypoints:i.slice(0,3),outputDir:n,external:d.external,platform:d.platform});let p=await Deno.bundle(d);if(Ix.debug("Deno.bundle result",{success:p.success,errors:p.errors?.length??0}),!p.success){let y=(p.errors??[]).map(b=>({message:b.text??this.extractErrorMessage(b),severity:"error"}));return rp(y)}return await this.processOutput(n,t,o,r)}catch(r){return rp([{message:r instanceof Error?r.message:String(r),severity:"fatal"}])}finally{try{await S.fs.remove(n,{recursive:!0})}catch{}}}watch(t,n){let r=!0,o=Object.values(t.entrypoints).map(d=>S.path.dirname(d)),i=[...new Set(o)],a=Deno.watchFs(i,{recursive:!0});return(async()=>{for await(let d of a){if(!r)break;let p=await this.bundle(t);n(p)}})().catch(d=>{console.error("Watch loop error:",d)}),Promise.resolve({stop:()=>(r=!1,a.close(),Promise.resolve())})}extractErrorMessage(t){return t==null?"Unknown error":typeof t=="object"&&"message"in t?String(t.message):String(t)}async processOutput(t,n,r,o){let i=this.options.entryName??"main",a=new Map,f={},d={},p=null,m=0,y=new Map,b=new Map;for(let Y=0;Y<o.length;Y++){let z=o[Y],M=r[Y];if(z!==void 0&&M!==void 0){let Z=S.path.basename(z).replace(/\.[^.]+$/,"");y.set(Z,M),b.set(cs(z,".js"),M)}}let w=S.path.join(t,"dist"),F=t;try{(await S.fs.stat(w)).isDirectory&&(F=w)}catch{}let O=[];Ix.debug(`Scanning output dir: ${F}`);let D=async(Y,z="")=>{for await(let M of S.fs.readDir(Y)){let Z=S.path.join(Y,M.name),me=z?`${z}/${M.name}`:M.name;M.isDirectory?await D(Z,me):M.isFile&&(M.name.endsWith(".js")||M.name.endsWith(".map"))&&O.push({name:me,path:Z})}};if(await D(F),F!==t){for await(let Y of S.fs.readDir(t))if(Y.isFile&&(Y.name.endsWith(".js")||Y.name.endsWith(".map"))&&(Y.name.startsWith("chunk-")||Y.name.endsWith(".map"))){let z=S.path.join(t,Y.name);O.some(M=>M.path===z)||O.push({name:Y.name,path:z})}}Ix.debug(`Found ${O.length} output files`,O.map(Y=>Y.name));let U=new Map;for(let Y of O)if(Y.name.endsWith(".map")){let z=await S.fs.readFile(Y.path),M=Y.name;Y.name.startsWith("_client-entry")?M=`${i}.js.map`:Y.name.startsWith("_build-id-entry")&&(M="build-id.js.map"),U.set(M,z)}for(let Y of O){if(Y.name.endsWith(".map"))continue;let z=await S.fs.readTextFile(Y.path);n.basePath!==void 0&&(z=z.replace(/\/_lime\/alive/g,`${n.basePath}/_lime/alive`)),n.define!==void 0&&(z=K8(z,n.define)),z=z.replace(/from\s*["']\.\.\/chunk-/g,'from"./chunk-'),z=z.replace(/from\s*["']\.\.chunk-/g,'from"./chunk-'),z=z.replace(/import\s*\(["']\.\.\/chunk-/g,'import("./chunk-'),z=z.replace(/import\s*\(["']\.\.chunk-/g,'import("./chunk-');let M=Y.name,Z=M.startsWith("_client-entry");if(Z)M=`${i}.js`,p=`${i}.js`;else if(M.startsWith("_build-id-entry"))M="build-id.js";else if(!M.startsWith("chunk-")){let be;for(let[he,Te]of b)if(he.endsWith(M)){be=Te;break}if(be===void 0){let he=S.path.basename(M).replace(/\.js$/,"");be=y.get(he)}be!==void 0&&(M=`${be}.js`)}Z&&U.has(`${i}.js.map`)&&(z=z.replace(/\/\/# sourceMappingURL=.*$/m,`//# sourceMappingURL=${i}.js.map`),z.includes("//# sourceMappingURL=")||(z+=`
|
|
125
|
-
//# sourceMappingURL=${i}.js.map`));let me=new TextEncoder().encode(z),ge=await this.computeHash(me),ee=this.parseImports(z),fe=`${M}.map`,le=U.get(fe);a.set(M,{path:M,code:me,map:le,size:me.length,hash:ge,isEntry:!M.startsWith("chunk-")}),m+=me.length,f[M]={bytes:me.length,inputs:{},imports:ee.map(be=>({path:be,kind:"import-statement"}))}}for(let[Y,z]of U)if(!a.has(Y)){let M=await this.computeHash(z);a.set(Y,{path:Y,code:z,size:z.length,hash:M,isEntry:!1}),m+=z.length}if(n.outputDir!==void 0){await S.fs.mkdir(n.outputDir,{recursive:!0});for(let[Y,z]of a){let M=S.path.join(n.outputDir,Y),Z=S.path.dirname(M);Z!==n.outputDir&&await S.fs.mkdir(Z,{recursive:!0}),await S.fs.writeFile(M,z.code)}}for(let[Y,z]of Object.entries(n.entrypoints)){if(Y==="client"||Y==="main")continue;let M=await this.findEntrypointChunks(Y,F,t,a);M.length>0&&(d[z]=M)}return Mx(a,{metafile:{inputs:{},outputs:f},entrypointManifest:d,entrypoint:p??"main.js",totalSize:m})}async findEntrypointChunks(t,n,r,o){let i=cs(t,".js"),a=S.path.join(n,i),f=null;try{f=await S.fs.readTextFile(a)}catch{try{let d=S.path.join(r,"dist",i);f=await S.fs.readTextFile(d)}catch{}}return f!==null?this.extractChunksFromProxyFile(f,o):this.findChunksForComponentName(t,o)}findChunksForComponentName(t,n){let r=[],o=S.path.basename(t).replace(/\.[^.]+$/,""),i=o.charAt(0).toUpperCase()+o.slice(1).replace(/-([a-z])/g,(a,f)=>f.toUpperCase());for(let[a,f]of n){if(!a.startsWith("chunk-")||!a.endsWith(".js"))continue;let d=new TextDecoder().decode(f.code);if([new RegExp(`export\\s*\\{[^}]*\\b${i}\\b[^}]*\\}`),new RegExp(`export\\s+(?:function|const|let|var|class)\\s+${i}\\b`),new RegExp(`\\b\\w+\\s+as\\s+${i}\\b`)].some(y=>y.test(d))){r.unshift(a);let y=/from\s*["']\.?\/?([^"']*chunk-[A-Z0-9]+\.js)["']/gi,b;for(;(b=y.exec(d))!==null;){let w=S.path.basename(b[1]??"");w&&!r.includes(w)&&r.push(w)}break}}return r}extractChunksFromProxyFile(t,n){let r=[],o=/import(?:\{[\w\s,]*\})?\s*from\s*["']([\w./-]*chunk-[A-Z0-9]+\.js)["']/gi,i=/import\s*["']([\w./-]*chunk-[A-Z0-9]+\.js)["']/gi,a;for(;(a=o.exec(t))!==null;){let d=a[1];if(d!==void 0){let p=S.path.basename(d);r.includes(p)||r.push(p)}}for(;(a=i.exec(t))!==null;){let d=a[1];if(d!==void 0){let p=S.path.basename(d);r.includes(p)||r.push(p)}}let f=t.match(/export\s*\{([\w\s,]+)\}/);if(f!==null){let m=f[1]?.match(/(\w+)(?:\s+as\s+\w+)?/)?.[1]??null;if(m!==null){let y=null;for(let[b,w]of n){if(!b.startsWith("chunk-")||!b.endsWith(".js"))continue;let F=new TextDecoder().decode(w.code);if([new RegExp(`export\\s*\\{[^}]*\\b${m}\\b[^}]*\\}`),new RegExp(`export\\s+(?:function|const|let|var|class)\\s+${m}\\b`),new RegExp(`\\b\\w+\\s+as\\s+${m}\\b`)].some(U=>U.test(F))){y=b;break}}if(y!==null){let b=r.indexOf(y);b>0?(r.splice(b,1),r.unshift(y)):b===-1&&r.unshift(y)}}}return r}async computeHash(t){let n=await crypto.subtle.digest("SHA-256",t);return Ox(new Uint8Array(n)).slice(0,16)}parseImports(t){let n=[],r=/import\s{1,10}(?:[\w\s{},*]{1,500})\s{1,10}from\s{0,10}["']([\w./@-]+)["']/g,o;for(;(o=r.exec(t))!==null;){let a=o[1];if(a!==void 0&&(a.startsWith("./")||a.startsWith("../")||a.startsWith("/"))){let f=a.startsWith("./")?a.slice(2):a.startsWith("../")?a:a.slice(1);n.push(f)}}let i=/import\s*\(\s*["']([^"']+)["']\s*\)/g;for(;(o=i.exec(t))!==null;){let a=o[1];if(a!==void 0&&(a.startsWith("./")||a.startsWith("../")||a.startsWith("/"))){let f=a.startsWith("./")?a.slice(2):a.startsWith("../")?a:a.slice(1);n.push(f)}}return[...new Set(n)]}};NS=(e={})=>new _x(e)});function j8(e){let t=Object.keys(e).sort((o,i)=>i.length-o.length);if(t.length===0)return{name:"define"};let n=t.map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),r=new RegExp(`\\b(${n.join("|")})\\b`,"g");return{name:"define",transform(o,i){if(i.includes("node_modules"))return null;let a=!1;for(let d of t)if(o.includes(d)){a=!0;break}if(!a)return null;let f=o.replace(r,d=>e[d]??d);return f===o?null:{code:f}}}}var Dx,US,zS=P(()=>{"use strict";DS();LS();Dx=class{name="rolldown";options;rolldownModule=null;constructor(t={}){this.options=t}async bundle(t){try{let n=await this.loadRolldown(),r=this.adaptPlugins(t.plugins);t.define!==void 0&&Object.keys(t.define).length>0&&r.push(j8(t.define));let o=await n.rolldown({input:t.entrypoints,external:t.external,plugins:r}),i=t.sourcemap===!0?!0:t.sourcemap==="inline"?"inline":t.sourcemap==="external"?!0:void 0,a={dir:t.outputDir,format:t.format,entryFileNames:"[name].js",chunkFileNames:"chunk-[hash].js",sourcemap:i,minify:t.minify,...this.options.advancedChunks!==void 0?{advancedChunks:{minSize:this.options.advancedChunks.minSize??2e4,groups:this.options.advancedChunks.groups?.map(d=>({name:d.name,test:d.test,priority:d.priority??0}))}}:{}},f=await o.write(a);return await o.close(),await this.processRolldownOutput(f,t)}catch(n){return rp([{message:n instanceof Error?n.message:String(n),severity:"fatal"}])}}async watch(t,n){let o=await(await this.loadRolldown()).watch({input:t.entrypoints,external:t.external,plugins:this.adaptPlugins(t.plugins),output:{dir:t.outputDir,format:t.format,entryFileNames:"[name].js",chunkFileNames:"chunk-[hash].js",sourcemap:t.sourcemap===!0||t.sourcemap==="external",minify:t.minify}});return o.on("event",async i=>{if(i.code==="BUNDLE_END"){let a=await this.bundle(t);n(a)}else i.code==="ERROR"&&n(rp([{message:i.error?.message??"Watch error",severity:"error"}]))}),{stop:async()=>{await o.close()}}}async loadRolldown(){if(this.rolldownModule!==null)return this.rolldownModule;try{let t=await import("npm:rolldown@latest"),n={rolldown:r=>t.rolldown(r),watch:r=>{let o=t.watch(r);return Promise.resolve(o)}};return this.rolldownModule=n,n}catch(t){throw new Error(`Failed to load Rolldown. Make sure it's installed: ${t instanceof Error?t.message:String(t)}`)}}adaptPlugins(t){return t===void 0||t.length===0?[]:t.map(n=>{let r={name:n.name},o={resolvers:[],loaders:[],transformers:[]},i=n.setup({onResolve:(a,f)=>{o.resolvers.push({options:a,callback:f})},onLoad:(a,f)=>{o.loaders.push({options:a,callback:f})},onTransform:(a,f)=>{o.transformers.push({options:a,callback:f})}});return i instanceof Promise&&(r.buildStart=async function(){await i}),r.resolveId=async(a,f)=>{for(let d of o.resolvers)if(d.options.filter.test(a)){let p=await d.callback({path:a,importer:f??"",namespace:d.options.namespace??"file",kind:"import-statement"});if(p?.path!==void 0||p?.external===!0)return{id:p.path??a,external:p.external}}return null},r.load=async a=>{for(let f of o.loaders)if(f.options.filter.test(a)){let d=await f.callback({path:a,namespace:f.options.namespace??"file"});if(d?.contents!==void 0)return{code:typeof d.contents=="string"?d.contents:new TextDecoder().decode(d.contents)}}return null},r.transform=async(a,f)=>{let d=a;for(let p of o.transformers)if(p.options.filter.test(f)){let m=await p.callback({path:f,code:d});m?.code!==void 0&&(d=m.code)}return d!==a?{code:d}:null},r})}async processRolldownOutput(t,n){let o=`${this.options.entryName??"main"}.js`,i=new Map,a={},f={},d=null,p=0;for(let b of t.output)if(b.type==="chunk"){let w=b.code;n.basePath!==void 0&&(w=w.replace(/\/_lime\/alive/g,`${n.basePath}/_lime/alive`));let F=new TextEncoder().encode(w),O=await this.computeHash(F),D={path:b.fileName,code:F,size:F.length,hash:O,isEntry:b.isEntry,...b.map!==void 0?{map:new TextEncoder().encode(JSON.stringify(b.map))}:{}};if(i.set(b.fileName,D),p+=F.length,b.isEntry&&(b.fileName===o||d===null)&&(d=b.fileName),b.isEntry&&b.facadeModuleId!==void 0){let U=[b.fileName];if(b.imports!==void 0)for(let H of b.imports)U.includes(H)||U.push(H);f[b.facadeModuleId]=U}a[b.fileName]={bytes:F.length,inputs:{},imports:(b.imports??[]).map(U=>({path:U,kind:"import-statement"})),...b.isEntry&&b.facadeModuleId!==void 0?{entryPoint:b.facadeModuleId}:{}}}else if(b.type==="asset"){let w=typeof b.source=="string"?new TextEncoder().encode(b.source):b.source,F=await this.computeHash(w);i.set(b.fileName,{path:b.fileName,code:w,size:w.length,hash:F}),p+=w.length}return Mx(i,{metafile:{inputs:{},outputs:a},entrypointManifest:f,entrypoint:d??o,totalSize:p})}async computeHash(t){let n=await crypto.subtle.digest("SHA-256",t);return Ox(new Uint8Array(n)).slice(0,16)}},US=(e={})=>new Dx(e)});function op(e,t){if(typeof e=="object"&&e!==null&&"backend"in e){let r=e;return op(r.backend,r.options)}let n=e??"rolldown";switch(n){case"rolldown":return US(t);case"deno-bundler":return NS(t);default:throw new Error(`Unknown bundler backend: ${n}`)}}var WS=P(()=>{BS();zS();BS();zS()});function q8(e,t){let n={},r=0;for(let[o,i]of e.outputs)n[o]={fileName:o,size:i.size},r+=i.size;return{entrypoint:e.entrypoint??"client.js",outputs:n,manifest:t,totalSize:e.totalSize??r}}function $8(e){let t=Object.values(e.outputs);if(t.length===0)return{chunkCount:0,largestChunk:{name:"",size:0},smallestChunk:{name:"",size:0},averageChunkSize:0};let n=t.sort((i,a)=>a.size-i.size),r=n[0],o=n[n.length-1];return{chunkCount:t.length,largestChunk:r?{name:r.fileName,size:r.size}:{name:"",size:0},smallestChunk:o?{name:o.fileName,size:o.size}:{name:"",size:0},averageChunkSize:t.length>0?e.totalSize/t.length:0}}function t_(e){let t=$8(e);ha.debug("\u{1F4CA} Bundle Statistics:",{totalSizeKB:(e.totalSize/1024).toFixed(2),chunkCount:t.chunkCount,largestChunk:{name:t.largestChunk.name,sizeKB:(t.largestChunk.size/1024).toFixed(2)},smallestChunk:{name:t.smallestChunk.name,sizeKB:(t.smallestChunk.size/1024).toFixed(2)},averageChunkSizeKB:(t.averageChunkSize/1024).toFixed(2)})}async function n_(e,t,n){ha.info(`\u{1F4E6} Using bundler backend: ${n}`),ha.debug(`Bundling with @eser/bundler (${n})...`),ha.debug(` Entrypoints: ${e.entrypoints.length}`),ha.debug(` Output: ${e.outputDir}`),ha.debug(`Creating bundler: ${n}`);let r=op(n,{entryName:"client"}),o={};for(let p=0;p<e.entrypoints.length;p++){let m=e.entrypoints[p];if(m!==void 0)if(p===0)o.client=m;else{let y=t.find(b=>b.filePath===m);y!==void 0?o[y.relativePath]=m:o[`entry-${p}`]=m}}let i=e.sourcemap===!0||e.sourcemap==="external"||e.sourcemap==="inline",a={entrypoints:o,outputDir:e.outputDir,format:"esm",platform:e.platform==="deno"?"node":"browser",codeSplitting:e.splitting!==!1,minify:e.minify??!1,sourcemap:i,plugins:e.plugins,define:e.define},f=await r.bundle(a);if(!f.success){let p=f.errors?.map(m=>m.message).join(`
|
|
125
|
+
//# sourceMappingURL=${i}.js.map`));let me=new TextEncoder().encode(z),ge=await this.computeHash(me),ee=this.parseImports(z),fe=`${M}.map`,le=U.get(fe);a.set(M,{path:M,code:me,map:le,size:me.length,hash:ge,isEntry:!M.startsWith("chunk-")}),m+=me.length,f[M]={bytes:me.length,inputs:{},imports:ee.map(be=>({path:be,kind:"import-statement"}))}}for(let[Y,z]of U)if(!a.has(Y)){let M=await this.computeHash(z);a.set(Y,{path:Y,code:z,size:z.length,hash:M,isEntry:!1}),m+=z.length}if(n.outputDir!==void 0){await S.fs.mkdir(n.outputDir,{recursive:!0});for(let[Y,z]of a){let M=S.path.join(n.outputDir,Y),Z=S.path.dirname(M);Z!==n.outputDir&&await S.fs.mkdir(Z,{recursive:!0}),await S.fs.writeFile(M,z.code)}}for(let[Y,z]of Object.entries(n.entrypoints)){if(Y==="client"||Y==="main")continue;let M=await this.findEntrypointChunks(Y,F,t,a);M.length>0&&(d[z]=M)}return Mx(a,{metafile:{inputs:{},outputs:f},entrypointManifest:d,entrypoint:p??"main.js",totalSize:m})}async findEntrypointChunks(t,n,r,o){let i=cs(t,".js"),a=S.path.join(n,i),f=null;try{f=await S.fs.readTextFile(a)}catch{try{let d=S.path.join(r,"dist",i);f=await S.fs.readTextFile(d)}catch{}}return f!==null?this.extractChunksFromProxyFile(f,o):this.findChunksForComponentName(t,o)}findChunksForComponentName(t,n){let r=[],o=S.path.basename(t).replace(/\.[^.]+$/,""),i=o.charAt(0).toUpperCase()+o.slice(1).replace(/-([a-z])/g,(a,f)=>f.toUpperCase());for(let[a,f]of n){if(!a.startsWith("chunk-")||!a.endsWith(".js"))continue;let d=new TextDecoder().decode(f.code);if([new RegExp(`export\\s*\\{[^}]*\\b${i}\\b[^}]*\\}`),new RegExp(`export\\s+(?:function|const|let|var|class)\\s+${i}\\b`),new RegExp(`\\b\\w+\\s+as\\s+${i}\\b`)].some(y=>y.test(d))){r.unshift(a);let y=/from\s*["']\.?\/?([^"']*chunk-[A-Z0-9]+\.js)["']/gi,b;for(;(b=y.exec(d))!==null;){let w=S.path.basename(b[1]??"");w&&!r.includes(w)&&r.push(w)}break}}return r}extractChunksFromProxyFile(t,n){let r=[],o=/import(?:\{[\w\s,]*\})?\s*from\s*["']([\w./-]*chunk-[A-Z0-9]+\.js)["']/gi,i=/import\s*["']([\w./-]*chunk-[A-Z0-9]+\.js)["']/gi,a;for(;(a=o.exec(t))!==null;){let d=a[1];if(d!==void 0){let p=S.path.basename(d);r.includes(p)||r.push(p)}}for(;(a=i.exec(t))!==null;){let d=a[1];if(d!==void 0){let p=S.path.basename(d);r.includes(p)||r.push(p)}}let f=t.match(/export\s*\{([\w\s,]+)\}/);if(f!==null){let m=f[1]?.match(/(\w+)(?:\s+as\s+\w+)?/)?.[1]??null;if(m!==null){let y=null;for(let[b,w]of n){if(!b.startsWith("chunk-")||!b.endsWith(".js"))continue;let F=new TextDecoder().decode(w.code);if([new RegExp(`export\\s*\\{[^}]*\\b${m}\\b[^}]*\\}`),new RegExp(`export\\s+(?:function|const|let|var|class)\\s+${m}\\b`),new RegExp(`\\b\\w+\\s+as\\s+${m}\\b`)].some(U=>U.test(F))){y=b;break}}if(y!==null){let b=r.indexOf(y);b>0?(r.splice(b,1),r.unshift(y)):b===-1&&r.unshift(y)}}}return r}async computeHash(t){let n=await crypto.subtle.digest("SHA-256",t);return Ox(new Uint8Array(n)).slice(0,16)}parseImports(t){let n=[],r=/import\s{1,10}(?:[\w\s{},*]{1,500})\s{1,10}from\s{0,10}["']([\w./@-]+)["']/g,o;for(;(o=r.exec(t))!==null;){let a=o[1];if(a!==void 0&&(a.startsWith("./")||a.startsWith("../")||a.startsWith("/"))){let f=a.startsWith("./")?a.slice(2):a.startsWith("../")?a:a.slice(1);n.push(f)}}let i=/import\s*\(\s*["']([^"']+)["']\s*\)/g;for(;(o=i.exec(t))!==null;){let a=o[1];if(a!==void 0&&(a.startsWith("./")||a.startsWith("../")||a.startsWith("/"))){let f=a.startsWith("./")?a.slice(2):a.startsWith("../")?a:a.slice(1);n.push(f)}}return[...new Set(n)]}};NS=(e={})=>new _x(e)});function j8(e){let t=Object.keys(e).sort((o,i)=>i.length-o.length);if(t.length===0)return{name:"define"};let n=t.map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),r=new RegExp(`\\b(${n.join("|")})\\b`,"g");return{name:"define",transform(o,i){if(i.includes("node_modules"))return null;let a=!1;for(let d of t)if(o.includes(d)){a=!0;break}if(!a)return null;let f=o.replace(r,d=>e[d]??d);return f===o?null:{code:f}}}}var Dx,US,zS=P(()=>{"use strict";DS();LS();Dx=class{name="rolldown";options;rolldownModule=null;constructor(t={}){this.options=t}async bundle(t){try{let n=await this.loadRolldown(),r=this.adaptPlugins(t.plugins);t.define!==void 0&&Object.keys(t.define).length>0&&r.push(j8(t.define));let o=t.projectRoot!==void 0?[`${t.projectRoot}/node_modules`,"node_modules"]:["node_modules"],i=await n.rolldown({input:t.entrypoints,external:t.external,plugins:r,resolve:{modules:o}}),a=t.sourcemap===!0?!0:t.sourcemap==="inline"?"inline":t.sourcemap==="external"?!0:void 0,f={dir:t.outputDir,format:t.format,entryFileNames:"[name].js",chunkFileNames:"chunk-[hash].js",sourcemap:a,minify:t.minify,...this.options.advancedChunks!==void 0?{advancedChunks:{minSize:this.options.advancedChunks.minSize??2e4,groups:this.options.advancedChunks.groups?.map(p=>({name:p.name,test:p.test,priority:p.priority??0}))}}:{}},d=await i.write(f);return await i.close(),await this.processRolldownOutput(d,t)}catch(n){return rp([{message:n instanceof Error?n.message:String(n),severity:"fatal"}])}}async watch(t,n){let o=await(await this.loadRolldown()).watch({input:t.entrypoints,external:t.external,plugins:this.adaptPlugins(t.plugins),output:{dir:t.outputDir,format:t.format,entryFileNames:"[name].js",chunkFileNames:"chunk-[hash].js",sourcemap:t.sourcemap===!0||t.sourcemap==="external",minify:t.minify}});return o.on("event",async i=>{if(i.code==="BUNDLE_END"){let a=await this.bundle(t);n(a)}else i.code==="ERROR"&&n(rp([{message:i.error?.message??"Watch error",severity:"error"}]))}),{stop:async()=>{await o.close()}}}async loadRolldown(){if(this.rolldownModule!==null)return this.rolldownModule;try{let t=await import("npm:rolldown@latest"),n={rolldown:r=>t.rolldown(r),watch:r=>{let o=t.watch(r);return Promise.resolve(o)}};return this.rolldownModule=n,n}catch(t){throw new Error(`Failed to load Rolldown. Make sure it's installed: ${t instanceof Error?t.message:String(t)}`)}}adaptPlugins(t){return t===void 0||t.length===0?[]:t.map(n=>{let r={name:n.name},o={resolvers:[],loaders:[],transformers:[]},i=n.setup({onResolve:(a,f)=>{o.resolvers.push({options:a,callback:f})},onLoad:(a,f)=>{o.loaders.push({options:a,callback:f})},onTransform:(a,f)=>{o.transformers.push({options:a,callback:f})}});return i instanceof Promise&&(r.buildStart=async function(){await i}),r.resolveId=async(a,f)=>{for(let d of o.resolvers)if(d.options.filter.test(a)){let p=await d.callback({path:a,importer:f??"",namespace:d.options.namespace??"file",kind:"import-statement"});if(p?.path!==void 0||p?.external===!0)return{id:p.path??a,external:p.external}}return null},r.load=async a=>{for(let f of o.loaders)if(f.options.filter.test(a)){let d=await f.callback({path:a,namespace:f.options.namespace??"file"});if(d?.contents!==void 0)return{code:typeof d.contents=="string"?d.contents:new TextDecoder().decode(d.contents)}}return null},r.transform=async(a,f)=>{let d=a;for(let p of o.transformers)if(p.options.filter.test(f)){let m=await p.callback({path:f,code:d});m?.code!==void 0&&(d=m.code)}return d!==a?{code:d}:null},r})}async processRolldownOutput(t,n){let o=`${this.options.entryName??"main"}.js`,i=new Map,a={},f={},d=null,p=0;for(let b of t.output)if(b.type==="chunk"){let w=b.code;n.basePath!==void 0&&(w=w.replace(/\/_lime\/alive/g,`${n.basePath}/_lime/alive`));let F=new TextEncoder().encode(w),O=await this.computeHash(F),D={path:b.fileName,code:F,size:F.length,hash:O,isEntry:b.isEntry,...b.map!==void 0?{map:new TextEncoder().encode(JSON.stringify(b.map))}:{}};if(i.set(b.fileName,D),p+=F.length,b.isEntry&&(b.fileName===o||d===null)&&(d=b.fileName),b.isEntry&&b.facadeModuleId!==void 0){let U=[b.fileName];if(b.imports!==void 0)for(let H of b.imports)U.includes(H)||U.push(H);f[b.facadeModuleId]=U}a[b.fileName]={bytes:F.length,inputs:{},imports:(b.imports??[]).map(U=>({path:U,kind:"import-statement"})),...b.isEntry&&b.facadeModuleId!==void 0?{entryPoint:b.facadeModuleId}:{}}}else if(b.type==="asset"){let w=typeof b.source=="string"?new TextEncoder().encode(b.source):b.source,F=await this.computeHash(w);i.set(b.fileName,{path:b.fileName,code:w,size:w.length,hash:F}),p+=w.length}return Mx(i,{metafile:{inputs:{},outputs:a},entrypointManifest:f,entrypoint:d??o,totalSize:p})}async computeHash(t){let n=await crypto.subtle.digest("SHA-256",t);return Ox(new Uint8Array(n)).slice(0,16)}},US=(e={})=>new Dx(e)});function op(e,t){if(typeof e=="object"&&e!==null&&"backend"in e){let r=e;return op(r.backend,r.options)}let n=e??"rolldown";switch(n){case"rolldown":return US(t);case"deno-bundler":return NS(t);default:throw new Error(`Unknown bundler backend: ${n}`)}}var WS=P(()=>{BS();zS();BS();zS()});function q8(e,t){let n={},r=0;for(let[o,i]of e.outputs)n[o]={fileName:o,size:i.size},r+=i.size;return{entrypoint:e.entrypoint??"client.js",outputs:n,manifest:t,totalSize:e.totalSize??r}}function $8(e){let t=Object.values(e.outputs);if(t.length===0)return{chunkCount:0,largestChunk:{name:"",size:0},smallestChunk:{name:"",size:0},averageChunkSize:0};let n=t.sort((i,a)=>a.size-i.size),r=n[0],o=n[n.length-1];return{chunkCount:t.length,largestChunk:r?{name:r.fileName,size:r.size}:{name:"",size:0},smallestChunk:o?{name:o.fileName,size:o.size}:{name:"",size:0},averageChunkSize:t.length>0?e.totalSize/t.length:0}}function t_(e){let t=$8(e);ha.debug("\u{1F4CA} Bundle Statistics:",{totalSizeKB:(e.totalSize/1024).toFixed(2),chunkCount:t.chunkCount,largestChunk:{name:t.largestChunk.name,sizeKB:(t.largestChunk.size/1024).toFixed(2)},smallestChunk:{name:t.smallestChunk.name,sizeKB:(t.smallestChunk.size/1024).toFixed(2)},averageChunkSizeKB:(t.averageChunkSize/1024).toFixed(2)})}async function n_(e,t,n){ha.info(`\u{1F4E6} Using bundler backend: ${n}`),ha.debug(`Bundling with @eser/bundler (${n})...`),ha.debug(` Entrypoints: ${e.entrypoints.length}`),ha.debug(` Output: ${e.outputDir}`),ha.debug(`Creating bundler: ${n}`);let r=op(n,{entryName:"client"}),o={};for(let p=0;p<e.entrypoints.length;p++){let m=e.entrypoints[p];if(m!==void 0)if(p===0)o.client=m;else{let y=t.find(b=>b.filePath===m);y!==void 0?o[y.relativePath]=m:o[`entry-${p}`]=m}}let i=e.sourcemap===!0||e.sourcemap==="external"||e.sourcemap==="inline",a={entrypoints:o,outputDir:e.outputDir,projectRoot:e.projectRoot,format:"esm",platform:e.platform==="deno"?"node":"browser",codeSplitting:e.splitting!==!1,minify:e.minify??!1,sourcemap:i,plugins:e.plugins,define:e.define},f=await r.bundle(a);if(!f.success){let p=f.errors?.map(m=>m.message).join(`
|
|
126
126
|
`)??"Unknown error";throw new Error(`Bundle failed: ${p}`)}let d={};for(let p of t){let m=f.entrypointManifest?.[p.filePath]??[];m.length>0&&(d[p.filePath]=[...m])}return ha.debug(` Outputs: ${f.outputs.size} files`),ha.debug(` Total size: ${((f.totalSize??0)/1024).toFixed(2)} KB`),q8(f,d)}async function r_(e,t){ha.info(`\u{1F4E6} Bundling server components with ${t}`),ha.debug(` Entrypoints: ${e.entrypoints.length}`),ha.debug(` Output: ${e.outputDir}`),ha.debug(` Externals: ${e.externals?.length??0}`);let n=op(t,{entryName:"server"}),r={};for(let f of e.entrypoints){let d=f.replace(e.projectRoot,"").replace(/^\//,"");d=cs(d,""),r[d]=f}let o={entrypoints:r,outputDir:e.outputDir,format:"esm",platform:"node",codeSplitting:!1,minify:e.minify??!1,sourcemap:e.sourcemap??!1,external:e.externals,plugins:e.plugins},i=await n.bundle(o);if(!i.success){let f=i.errors?.map(d=>d.message).join(`
|
|
127
127
|
`)??"Unknown error";throw new Error(`Server bundle failed: ${f}`)}let a=new Map;for(let[f,d]of i.outputs)if(d.isEntry&&i.entrypointManifest!==void 0){for(let[p,m]of Object.entries(i.entrypointManifest))if(m.includes(f)){a.set(p,f);break}}return ha.debug(` Outputs: ${i.outputs.size} files`),ha.debug(` Total size: ${((i.totalSize??0)/1024).toFixed(2)} KB`),{outputMap:a,totalSize:i.totalSize??0,fileCount:i.outputs.size}}var ha,o_=P(()=>{Ke();pa();WS();ha=de.getLogger(["laroux-bundler","bundler"])});function a_(e,t,n,r,o="info",i=!1){Li.debug("\u{1F4CB} Generating chunk manifest...");let a={version:e4,buildId:e,timestamp:t,entrypoint:n.entrypoint,logLevel:o,hmrEnabled:i,chunks:{},files:{}};for(let[d,p]of Object.entries(n.outputs))a.files[p.fileName]={name:p.fileName,size:p.size,hash:r4(p.fileName)??void 0};let f=[];for(let d of r){let p=t4(d,n),[m,...y]=p;if(!m){Li.warn(`No chunks found for ${d.relativePath}`);continue}let b=[m,...y];for(let O of b)a.files[O]||f.push(`${d.relativePath} references ${O}, but it's not in bundle outputs`);let w=o4(d.relativePath);a.chunks[w]={main:i_(m),deps:y.map(i_),size:n4(p,a.files)};let F=d.exportNames[0]??"default";F!=="default"&&(a.chunks[w].exportName=F),Li.debug(` ${w} \u2192 main: ${m}, deps: [${y.join(", ")}]`)}if(f.length>0){Li.error("\u274C Chunk manifest validation failed!"),Li.error(" Missing chunks:");for(let d of f)Li.error(` - ${d}`);throw Li.error(` Available files: ${Object.keys(a.files).join(", ")}`),new Error(`Chunk manifest validation failed: ${f.length} chunk(s) referenced but not found in bundle outputs`)}return Li.debug("\u2705 Manifest generated"),Li.debug(` Components: ${Object.keys(a.chunks).length}`),Li.debug(` Chunks: ${Object.keys(a.files).length}`),Li.debug(" Validation: All referenced chunks exist"),a}function t4(e,t){let n=t.manifest[e.filePath];if(!n||n.length===0)throw Li.error(`\u274C No chunk mapping found for component: ${e.filePath}`),Li.error(` Available mappings: ${Object.keys(t.manifest).join(", ")}`),new Error(`Chunk manifest incomplete: No chunks found for ${e.relativePath}. This indicates the bundler failed to analyze the component's dependencies.`);return n}function n4(e,t){return e.reduce((n,r)=>{let o=t[r];return n+(o?.size??0)},0)}function r4(e){return e.match(/-([a-f0-9]+)\./i)?.[1]??null}function i_(e){return e.replace(/^chunk-/,"").replace(/\.js$/,"")}function o4(e){let t=`${Ax}/`;return e.startsWith(t)?e.slice(t.length):e}async function s_(e,t){await S.fs.writeTextFile(t,JSON.stringify(e,null,2)),Li.debug(`\u{1F4DD} Chunk manifest saved: ${t}`)}function l_(e){Li.debug("\u{1F4E6} Chunk Manifest:",{entrypoint:e.entrypoint,components:Object.keys(e.chunks).length,files:Object.keys(e.files).length,chunks:Object.fromEntries(Object.entries(e.chunks).map(([t,n])=>[t,{main:n.main,deps:n.deps,exportName:n.exportName,sizeKB:(n.size/1024).toFixed(2)}]))})}var Li,e4,c_=P(()=>{ye();MS();Ke();Li=de.getLogger(["laroux-bundler","chunk-manifest"]),e4="1.0"});var Ug,HS,GS=P(()=>{Ug={minify:!0,sourceMaps:!1,codeSplitting:!0,define:{"process.env.NODE_ENV":'"production"',"process.env.DEBUG":'"false"'}},HS={minify:!1,sourceMaps:!0,codeSplitting:!1,define:{"process.env.NODE_ENV":'"development"',"process.env.DEBUG":'"false"'}}});var YS=P(()=>{"use strict"});var u_=P(()=>{"use strict";ye()});import{transform as a4}from"lightningcss";import{Buffer as d_}from"node:buffer";function s4(e){if(e===void 0)return{chrome:90<<16,firefox:88<<16,safari:917504};let t={};return e.chrome!==void 0&&(t.chrome=e.chrome),e.firefox!==void 0&&(t.firefox=e.firefox),e.safari!==void 0&&(t.safari=e.safari),e.edge!==void 0&&(t.edge=e.edge),t}function f_(e){if(e==null)throw new TypeError(`Expected Uint8Array from Lightning CSS, got ${e===null?"null":"undefined"}`);if(iv("node")&&typeof d_<"u"&&d_.isBuffer(e))return e.toString("utf-8");if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(typeof e=="string")return e;throw new TypeError(`Expected Uint8Array from Lightning CSS, got ${typeof e}`)}function p_(e,t={}){let{filename:n="styles.css",minify:r=!1,targets:o,cssModules:i=!1,unusedSymbols:a=[]}=t,f={filename:n,code:new TextEncoder().encode(e),minify:r,targets:s4(o),cssModules:i,unusedSymbols:[...a]},d=a4(f),p;if(d.exports!==null&&d.exports!==void 0){p={};for(let[m,y]of Object.entries(d.exports))p[m]={name:y.name,composes:y.composes?.map(b=>({name:b.name,from:b.from!==void 0?String(b.from):void 0}))}}return{code:f_(d.code),map:d.map!=null?f_(d.map):void 0,exports:p}}function VS(e,t,n={}){return p_(e,{...n,filename:t,cssModules:!0})}var XS=P(()=>{"use strict";ye();YS()});async function JS(e,t={}){let{generateDts:n=!1,minify:r=!0,targets:o,tailwind:i}=t,a=await S.fs.readTextFile(e);if(i!==void 0){let y=await i.compile(a,e);y!==null&&(a=y.code)}let f=S.path.basename(e),d=VS(a,f,{minify:r,targets:o,nesting:!0}),p={};if(d.exports!==void 0)for(let[y,b]of Object.entries(d.exports))p[y]=b.name;let m=n?ZS(p):void 0;return{code:d.code,exports:p,dts:m}}function ZS(e){return`// This file is auto-generated by CSS modules processor
|
|
128
128
|
declare const styles: {
|
|
@@ -163,7 +163,7 @@ ${Z}
|
|
|
163
163
|
`),f={variableCount:Object.keys(o).length,rulesExtracted:n,size:new TextEncoder().encode(a).length};return M_.debug(`Extracted critical universal CSS: ${f.size} bytes, ${f.rulesExtracted} rules, ${f.variableCount} theme variables`),{css:a,themeVariables:o,stats:f}}function I_(e){return Yg(e).css.replace(/\n+/g,"").replace(/\s*{\s*/g,"{").replace(/\s*}\s*/g,"}").replace(/\s*;\s*/g,";").replace(/\s*:\s*/g,":").replace(/;\}/g,"}")}function __(e){return Ux(e,"theme")}var M_,v4,x4,D_,ok=P(()=>{Ke();M_=de.getLogger(["laroux-bundler","critical-universal-css"]),v4=["html",":host","html, :host","body","#root",".initial-loading","[data-client-component]"],x4=["*","*, ::after, ::before","*, ::after, ::before, ::backdrop, ::file-selector-button","a","button","h1","h2","h3","h4","h5","h6","h1, h2, h3, h4, h5, h6"];D_="html{scrollbar-gutter:stable}*,*::before,*::after{box-sizing:border-box}"});import{Scanner as R4}from"@tailwindcss/oxide";function Vg(e={}){let{globalCssPath:t="src/app/styles/global.css",autoInjectReference:n=!0,detectPatterns:r=[/@tailwind\b/,/@apply\b/,/@import\s+["']tailwindcss/]}=e;return{name:"tailwindcss",shouldProcess(o,i){return r.some(a=>a.test(o))},preprocess(o,i){if(i.isModule&&o.includes("@apply")){let a=o,f=/^@reference\s+/m.test(o);if(n&&!f){let d=S.path.dirname(i.cssPath),p=S.path.resolve(i.projectRoot,t);a=`@reference "${S.path.relative(d,p)}";
|
|
164
164
|
|
|
165
165
|
${o}`}return Nx(a,S.path.dirname(i.cssPath))}return o},async compile(o,i){let a=S.path.dirname(i.cssPath),f=S.path.resolve(i.projectRoot,"src"),d=[];for await(let y of Vc(f,"**/*.{tsx,ts,jsx,js}",/node_modules/)){let b=S.path.resolve(f,y),w=S.path.extname(y),F=await S.fs.readTextFile(b);d.push({content:F,extension:w.slice(1)})}let m=new R4({}).scanFiles(d);return S4.debug(`Scanned ${d.length} files, found ${Array.isArray(m)?m.length:0} candidates`),zg(o,{base:a,candidates:m})},extractCriticalCss(o,i,a){let f=Bx({css:o,html:i,forceInclude:a?.forceInclude,forceExclude:a?.forceExclude});return{critical:f.critical,deferred:f.deferred,stats:{originalSize:f.stats.originalSize,criticalSize:f.stats.criticalSize,deferredSize:f.stats.deferredSize}}},extractUniversalCss(o){let i=Yg(o);return{css:i.css,themeVariables:i.themeVariables}}}}var S4,L_=P(()=>{ye();Ke();Ng();tk();rk();ok();S4=de.getLogger(["laroux-bundler","tailwindcss"])});var zx={};er(zx,{ABOVE_FOLD_PATTERNS:()=>Hg,CRITICAL_LAYERS:()=>Wg,CRITICAL_PROPERTY_PATTERNS:()=>E_,DEFAULT_CRITICAL_UNIVERSAL_CSS:()=>D_,compileTailwind:()=>zg,createTailwindPlugin:()=>Vg,expandApplyDirectives:()=>Nx,extractCriticalPageCss:()=>Bx,extractCriticalUniversalCss:()=>Yg,extractThemeLayer:()=>__,generateAsyncCssLoader:()=>O_,generateCriticalUniversalCss:()=>I_,getDefaultCriticalCssConfig:()=>P_,loadStylesheet:()=>Lx});var Xg=P(()=>{L_();tk();ek();nk();rk();ok()});async function k4(e,t={}){let{generateDTS:n=!1,projectRoot:r,minify:o=!0,plugin:i,globalCssPath:a="src/app/styles/global.css"}=t;Jg.debug(`Processing CSS module: ${e}`);let f=await S.fs.readTextFile(e),d={projectRoot:r??S.process.cwd(),cssPath:e,isModule:!0},p=i??Vg({globalCssPath:a}),m=f;if(p.shouldProcess?.(f,d)??!0){let b=p.preprocess?.(f,d);b!==void 0&&(m=await Promise.resolve(b))}let y=e.replace(/\.module\.css$/,".temp.module.css");await S.fs.writeTextFile(y,m);try{let b=await JS(y,{generateDts:n,minify:o}),w=S.path.basename(e);return Jg.debug(`Processed ${Object.keys(b.exports).length} class(es) in ${w}`),b}finally{await S.fs.remove(y).catch(()=>{})}}async function ik(e,t={}){let{cache:n,projectRoot:r,minify:o=!0,globalCssPath:i="src/app/styles/global.css",...a}=t;Jg.debug(`Processing ${e.length} CSS module(s)`);let f=Vg({globalCssPath:i}),d=0,p=0;try{let m=await Promise.all(e.map(async y=>{if(n!==void 0)try{let F=(await S.fs.stat(y)).mtime?.getTime()??0,O=n.getCssModuleResult(y,F);if(O!=null)return d++,[y,{code:O.code,exports:O.exports}]}catch{}p++;let b=await k4(y,{...a,projectRoot:r,minify:o,plugin:f,globalCssPath:i});if(n!==void 0)try{let F=(await S.fs.stat(y)).mtime?.getTime()??0;n.setCssModuleResult(y,b.code,b.exports,F)}catch{}return[y,b]}));return n!==void 0&&(d>0||p>0)&&Jg.debug(`CSS modules: ${d} cache hits, ${p} processed`),new Map(m)}finally{}}async function N_(e,t,n,r){let o=S.path.basename(e,".module.css"),i=e.startsWith(n)?n:r?.projectRoot??S.process.cwd(),a=S.path.relative(i,e),f=S.path.dirname(a),d=S.path.resolve(n,f);if(await S.fs.mkdir(d,{recursive:!0}),r?.skipCss!==!0){let m=S.path.resolve(d,`${o}.module.css`);await S.fs.writeTextFile(m,t.code)}let p=S.path.resolve(d,`${o}.module.css.json`);if(await S.fs.writeTextFile(p,JSON.stringify(t.exports,null,2)),t.dts!==void 0){let m=S.path.resolve(d,`${o}.module.css.d.ts`);await S.fs.writeTextFile(m,t.dts)}Jg.debug(`Saved CSS module outputs to ${d}`)}var Jg,B_=P(()=>{ye();Ke();jS();Xg();Jg=de.getLogger(["laroux-bundler","css-modules"])});function T4(e,t){for(let n of t)if(e===n||e.startsWith(`${n}/`))return!0;return!1}function z_(e){let{externals:t}=e,n=t.map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),r=new RegExp(`^(${n.join("|")})($|\\/)`);return U_.debug(`Server externals plugin initialized with ${t.length} packages: ${t.join(", ")}`),{name:"server-externals",setup(o){o.onResolve({filter:r},i=>{let a=i.path;return T4(a,t)?(U_.debug(`Marking as external: ${a}`),{external:!0}):{}})}}}var U_,W_=P(()=>{Ke();U_=de.getLogger(["laroux-bundler","server-externals"])});async function H_(){return Wx===null&&(Wx=await import("npm:sharp@^0.33.5")),Wx.default??Wx}async function ak(e){let t=[],n=[".jpg",".jpeg",".png",".gif",".webp"];async function r(o){try{for await(let i of S.fs.readDir(o)){let a=S.path.resolve(o,i.name);if(i.isDirectory)await r(a);else if(i.isFile){let f=S.path.extname(i.name).toLowerCase();n.includes(f)&&t.push(a)}}}catch{}}return await r(e),t}async function P4(e,t){return`data:image/webp;base64,${(await(await H_())(e).resize(t,void 0,{fit:"inside"}).blur(5).webp({quality:20}).toBuffer()).toString("base64")}`}async function sk(e,t,n,r={}){let o=await H_(),i={...E4,...r},a=o(e),f=await a.metadata();if(f.width===void 0||f.height===void 0)throw new Error(`Could not read image dimensions: ${e}`);let d=f.width,p=f.height,m=d/p,y=S.path.basename(e,S.path.extname(e)),b=`${n}/${y}`,w=[];for(let O of i.widths){if(O>d)continue;let D=Math.round(O/m);for(let U of i.formats){let H,J;if(U==="original"){let M=S.path.extname(e).toLowerCase();J=M.replace(".",""),H=S.path.resolve(t,`${y}-${O}w${M}`)}else J=U,H=S.path.resolve(t,`${y}-${O}w.${U}`);await S.fs.ensureDir(S.path.dirname(H));let Y=a.clone().resize(O,D,{fit:"cover"});U==="webp"?Y=Y.webp({quality:i.quality.webp}):U==="avif"?Y=Y.avif({quality:i.quality.avif}):J==="jpg"||J==="jpeg"?Y=Y.jpeg({quality:i.quality.jpeg}):J==="png"&&(Y=Y.png({quality:i.quality.png}));let z=await Y.toBuffer();await S.fs.writeFile(H,z),w.push({path:H,format:J,width:O,height:D,size:z.length})}}let F;return i.generateBlurPlaceholder&&(F=await P4(e,i.placeholderWidth)),{originalPath:e,publicPath:b,originalWidth:d,originalHeight:p,variants:w,blurDataUrl:F,aspectRatio:m}}async function G_(e,t,n="/images",r={}){ip.info(`Scanning for images in ${e}...`);let o=await ak(e);if(o.length===0)return ip.debug("No images found to optimize"),{timestamp:Date.now(),images:{}};ip.info(`Found ${o.length} image(s) to optimize`);let i={},a=0,f=0;for(let y of o)try{let b=await S.fs.stat(y);a+=b.size;let w=await sk(y,t,n,r);i[y]=w;let F=w.variants.reduce((O,D)=>O+D.size,0);f+=F,ip.debug(`Optimized: ${S.path.basename(y)} \u2192 ${w.variants.length} variants`)}catch(b){ip.warn(`Failed to optimize ${y}: ${b instanceof Error?b.message:String(b)}`)}let d={timestamp:Date.now(),images:i},p=S.path.resolve(t,"image-manifest.json");await S.fs.ensureDir(S.path.dirname(p)),await S.fs.writeTextFile(p,JSON.stringify(d,null,2));let m=a>0?((1-f/a)*100).toFixed(1):0;return ip.info(`Image optimization complete: ${o.length} images, ${m}% size reduction`),d}function Y_(e,t="webp"){return e.variants.filter(r=>r.format===t).sort((r,o)=>r.width-o.width).map(r=>`${r.path} ${r.width}w`).join(", ")}function V_(e,t,n="webp"){let r=e.variants.filter(o=>o.format===n).sort((o,i)=>o.width-i.width);return r.find(o=>o.width>=t)??r.at(-1)}var ip,Wx,E4,X_=P(()=>{ye();Ke();ip=de.getLogger(["laroux","image-optimizer"]),Wx=null;E4={formats:["webp","original"],widths:[640,768,1024,1280,1920],quality:{webp:80,avif:75,jpeg:85,png:90},generateBlurPlaceholder:!0,placeholderWidth:10}});var J_={};er(J_,{generateSrcset:()=>Y_,getBestVariant:()=>V_,optimizeImage:()=>sk,optimizeImages:()=>G_,scanImages:()=>ak});var Z_=P(()=>{X_()});var e2={};er(e2,{build:()=>sp,createBuildContext:()=>ap,ensureBuildIsReady:()=>F4,watch:()=>Gx});function ap(e,t){let n=e.projectRoot,r=e.srcDir,o=e.distDir,i="",a=S.path.resolve(o,q_);return{config:e,projectRoot:n,srcDir:r,distDir:o,clientEntry:i,chunkManifestFile:a,bundlerBackend:t?.bundlerBackend,plugin:t?.framework??fI,cssPlugin:t?.css}}async function sp(e,t){let{srcDir:n,distDir:r,projectRoot:o}=e,i=performance.now(),a=cI();se.info("\u{1F680} Starting RSC build..."),se.debug(`\u{1F194} Build ID: ${a}`);try{if(t?.cssOnly){se.debug("\u26A1 CSS-only rebuild (fast path)");let ve=Date.now(),pe=S.path.resolve(r,Hx),Ae=e.cssPlugin;if(!Ae)return se.warn("\u26A0\uFE0F No CSS plugin provided, skipping CSS processing"),{success:!0,clientBundle:"",moduleMap:{},clientComponents:0,duration:performance.now()-i,timestamp:ve};let yt=await lk(n);await Q_(Ae,n,o,pe),yt.length>0&&await K_(o,pe,e.config,{cssModulePaths:yt,cache:e.cache});let zt=performance.now()-i;return se.info(`\u26A1 CSS rebuild completed (${zt.toFixed(0)}ms)`),{success:!0,clientBundle:"",moduleMap:{},clientComponents:0,duration:zt,timestamp:ve}}await U4(r,t?.skipCss),await S.fs.ensureDir(r);let f=Date.now();se.debug("\u{1F50D} Step 3: Parallel scanning (routes, components, CSS modules)...");let d=S.path.resolve(n,"app/routes"),{plugin:p}=e,[m,y,b]=await Promise.all([II(d,o),p.analyzeClientComponents?p.analyzeClientComponents(n,o,e.cache):Promise.resolve([]),lk(n)]),w=S.path.resolve(r,Zc);await S.fs.ensureDir(w);let F=S.path.resolve(w,"_generated-routes.ts"),O=S.path.relative(o,n);if(await _I({scanResult:m,outputPath:F,projectRoot:o,srcDirName:O}),se.debug(`\u2713 Generated ${m.routes.length} page route(s) to dist/`),m.apiRoutes.length>0){let ve=S.path.resolve(r,"server","api-routes.ts");await S.fs.ensureDir(S.path.dirname(ve)),await DI(m,ve,o),se.debug(`\u2713 Generated ${m.apiRoutes.length} API route(s)`)}if(m.proxies.length>0){let ve=S.path.resolve(r,"server","proxy-registry.ts");await S.fs.ensureDir(S.path.dirname(ve)),await LI(m,ve,o),se.debug(`\u2713 Generated ${m.proxies.length} proxy definition(s)`)}y.length===0&&se.warn("\u26A0\uFE0F Warning: No client components found!"),se.debug("\u{1F504} Step 4: Transforming client components...");let D=p.transformClientComponents?await p.transformClientComponents(y,S.path.resolve(r,Zc),o):[];p.generateTransformManifest&&await p.generateTransformManifest(D,S.path.resolve(r,"transform-manifest.json"),o),se.debug("\u270F\uFE0F Step 5: Rewriting server component imports...");let U=p.getAllComponents?await p.getAllComponents(n):[],H=new Set(y.map(ve=>ve.filePath)),J=U.filter(ve=>!H.has(ve));p.rewriteServerComponents&&await p.rewriteServerComponents(J,D,b,S.path.resolve(r,Zc),o),se.debug("\u{1F504} Step 5b: Transforming server actions with React symbols...");let Y=S.path.resolve(r,Zc),z=await zM(Y);if(z.length>0){let ve=z.reduce((pe,Ae)=>pe+Ae.transformedActions.length,0);se.info(` \u2705 Transformed ${z.length} file(s) with ${ve} action(s)`)}se.debug("\u{1F5FA}\uFE0F Step 6: Generating module map...");let M=S.path.resolve(r,Hx);await S.fs.ensureDir(M);let Z=p.createModuleMap?await p.createModuleMap(y):{};p.saveModuleMap&&await p.saveModuleMap(Z,S.path.resolve(M,$_)),p.createClientManifest&&await p.createClientManifest(y);let me=e.cssPlugin;!t?.skipCss&&me?(se.debug("\u{1F3A8} Step 7: Processing CSS with CSS plugin + Lightning CSS..."),await Q_(me,n,o,M)):me?se.debug("\u23ED\uFE0F Skipping CSS processing (JS-only change)"):se.debug("\u23ED\uFE0F No CSS plugin provided, skipping CSS processing"),se.debug("\u{1F4C1} Step 8: Creating virtual source for bundling...");let ge=await HI({projectRoot:o,distDir:r,srcDir:n,changedFiles:t?.changedFiles}),ee=ge.virtualSrcDir;se.debug("\u{1F50C} Step 8b: Generating client action stubs in virtual source...");let fe=S.path.join(ee,O),le=await HM(fe,ee);if(le.length>0){let ve=le.reduce((pe,Ae)=>pe+Ae.exportedActions.length,0);se.info(` \u2705 Generated ${le.length} stub file(s) with ${ve} action(s)`)}let be;if(!t?.skipCss){se.debug("\u{1F3A8} Step 9: Processing CSS Modules to virtual source...");let ve=b.map(yt=>Bg(yt,n,ee)),pe=await K_(o,ee,e.config,{skipCss:!0,cssModulePaths:ve,cache:e.cache});be=new Map;let Ae=S.path.join(ee,O);for(let[yt,zt]of pe){let Ge=S.path.relative(Ae,yt),Ie=S.path.resolve(n,Ge);be.set(Ie,zt)}ve.length>0&&(se.debug("\u270F\uFE0F Step 10: Rewriting CSS module imports in virtual source..."),p.rewriteCssModuleImports&&await p.rewriteCssModuleImports(Ae,ve,o))}se.debug("\u{1F4E6} Step 11: Bundling client code from virtual source...");let he=GI(y,n,ee),Te=await M4({...e,srcDir:ee},he,a,f);if(!t?.skipCss&&b.length>0&&(se.debug(`\u{1F4CB} Step 12: Copying ${b.length} CSS Module JSON file(s) to client/...`),await j_(b.map(ve=>Bg(ve,n,ee)),ee,M),se.debug(`\u{1F4CB} Step 13: Copying ${b.length} CSS Module JSON file(s) to server/...`),await j_(b.map(ve=>Bg(ve,n,ee)),ee,S.path.resolve(r,Zc)),se.debug("\u{1F3A8} Step 14: Appending CSS modules to styles.css..."),await W4(b,o,M,be)),se.debug("\u{1F9F9} Step 15: Cleaning up virtual source..."),await ge.cleanup(),me){se.debug("\u2728 Step 16: Extracting critical CSS...");let ve=await N4(me,M);ve&&se.debug(` Critical: ${ve.criticalPath}, Deferred: ${ve.deferredPath}`),se.debug("\u{1F3A8} Step 17: Generating universal CSS...");let pe=await B4(me,M);pe&&se.debug(` Universal: ${pe}`)}se.debug("\u{1F524} Step 18: Optimizing Fonts..."),await z4(M,e.config.fonts),se.debug("\u{1F5BC}\uFE0F Step 19: Optimizing Images..."),await H4(o,M,e.config),se.debug("\u{1F310} Step 20: Copying translation files..."),await L4(n,S.path.resolve(r,Zc),o);let et=S.path.resolve(r,Zc);if(await _4(o,et),se.info(`\u{1F4E6} Step 22: Server bundling check - components: ${J.length}`),J.length>0){se.info(`\u{1F4E6} Step 22: Bundling ${J.length} server component(s) with rolldown...`);let ve=[];for(let pe of J){let Ae=S.path.relative(o,pe),yt=S.path.join(et,Ae);await S.fs.exists(yt)&&ve.push(yt)}if(se.info(` Found ${ve.length} server entrypoints to bundle`),ve.length>0){let pe=e.config.serverExternals,Ae=z_({externals:pe}),yt=await r_({entrypoints:ve,outputDir:et,projectRoot:et,sourcemap:!1,minify:!1,externals:pe,plugins:[Ae]},e.bundlerBackend??"deno-bundler");se.info(` \u2705 Bundled ${yt.fileCount} server file(s)`)}}se.debug("\u{1F4CB} Step 22b: Generating server actions manifest...");let We=(await qf(n,{projectRoot:o})).map(ve=>cs(ve.relativePath,".js")),sn=S.path.resolve(et,"actions-manifest.json");await S.fs.writeTextFile(sn,JSON.stringify({actions:We},null,2)),se.debug(`\u2713 Generated actions manifest: ${We.length} action file(s)`),await D4(o,r);let Dt=performance.now()-i;return se.info("\u{1F4CA} Build Summary:"),se.info(` Client components: ${y.length}`),se.info(` Build time: ${Dt.toFixed(0)}ms`),{success:!0,clientBundle:Te,moduleMap:Z,clientComponents:y.length,duration:Dt,timestamp:f}}catch(f){let d=f instanceof Error?f.message:String(f),p=f instanceof Error?f.stack:null;return se.error("\u274C Build failed:"),se.error(` Error: ${d}`),p!==null&&se.error(` Stack trace:
|
|
166
|
-
${p}`),{success:!1,clientBundle:"",moduleMap:{},clientComponents:0,duration:performance.now()-i,timestamp:Date.now()}}}async function F4(e){return await A4(e)?(se.info("\u{1F504} Build needed, running build..."),await sp(e)):(se.info("\u2705 Build is up-to-date, skipping..."),await O4(e))}async function A4(e){let{distDir:t,chunkManifestFile:n,srcDir:r,clientEntry:o,projectRoot:i}=e;if(!await S.fs.exists(t)||!await S.fs.exists(n))return!0;let a=await S.fs.readTextFile(n),d=JSON.parse(a).timestamp,p=[];for await(let m of S.fs.readDir(r))m.isFile&&rg.test(m.name)&&p.push(S.path.resolve(r,m.name));p.push(o);for(let m of p)try{let y=await S.fs.stat(m);if(y.mtime&&y.mtime.getTime()>d)return se.debug(` Changed: ${S.path.relative(i,m)}`),!0}catch{}return!1}async function O4(e){let{chunkManifestFile:t,distDir:n}=e,r=await S.fs.readTextFile(t),o=JSON.parse(r),i=await S.fs.readTextFile(S.path.resolve(n,$_)),a=JSON.parse(i);return{success:!0,clientBundle:S.path.resolve(n,"client.js"),moduleMap:a,clientComponents:Object.keys(a).length,duration:0,timestamp:o.timestamp}}function Gx(e,t){let{srcDir:n,distDir:r,projectRoot:o}=e;se.debug("\u{1F441}\uFE0F Watch mode enabled, monitoring for changes...");let i=YI(),a={...e,cache:i},f=S.path.relative(o,r),d=[n],p=S.fs.watch(d),m=!1,y=!1,b=new Set,w=null,F=50;async function O(){if(m){y=!0;return}m=!0;do{y=!1;try{let D=Array.from(b);i.invalidateFiles(D.map(Z=>S.path.resolve(o,Z)));let U=D.some(Z=>Z.endsWith(".css")),H=D.some(Z=>Z.match(/\.(tsx?|jsx?)$/)),J=U&&!H,Y=!U&&H,z=new Set(D.map(Z=>S.path.resolve(o,Z))),M=await sp(a,{skipCss:Y,cssOnly:J,changedFiles:z});M.changedFiles=Array.from(b),se.debug(`\u2705 Rebuild complete (${M.duration.toFixed(0)}ms)`),t(M),b.clear()}catch(D){se.error("\u274C Rebuild failed:",{error:D})}}while(y);m=!1}return(async()=>{for await(let D of p)if(D.kind==="modify"||D.kind==="create"||D.kind==="remove"){let U=D.paths[0];if(!U)continue;let H=S.path.relative(o,U);if(!H.match(/\.(tsx?|jsx?|css)$/))continue;let J=pl(H),Y=pl(f);if(J.startsWith(`${Y}/`)||H.includes(".temp."))continue;se.debug(`\u{1F504} File changed: ${H}`),b.add(H),w!==null&&clearTimeout(w),w=setTimeout(()=>{w=null,O()},F)}})(),p}async function M4(e,t,n,r){let{config:o,projectRoot:i,distDir:a}=e,{plugin:f}=e;if(!f.createClientEntry)throw new Error("Framework plugin must implement createClientEntry");let d=await f.createClientEntry(t,i,a);try{let p=t.map(D=>D.filePath),m=S.path.resolve(a,Hx),y=RI({projectRoot:i,browserShims:o.browserShims,autoMarkExternal:!1}),b={...Ug.define};if(!e.bundlerBackend)throw new Error("Bundler backend is required for client bundling");let w=await n_({entrypoints:[d,...p],outputDir:m,minify:Ug.minify,splitting:Ug.codeSplitting,platform:"browser",sourcemap:Ug.sourceMaps,plugins:[y],define:b},t,e.bundlerBackend),F=a_(n,r,w,t,o.logLevel,!1),O=S.path.resolve(m,q_);await s_(F,O);try{await S.fs.remove(d)}catch{}return t_(w),l_(F),S.path.resolve(a,w.entrypoint)}catch(p){try{await S.fs.remove(d)}catch{}throw p}}function I4(e,t){for(let[n,r]of Object.entries(e))typeof r=="string"&&(r.startsWith("./")||r.startsWith("../"))&&(e[n]=S.path.join(t,r))}async function _4(e,t){let n=await lg({baseDir:e});if(n===void 0){se.debug("No config files found to copy");return}let r=S.path.relative(t,e),o=0;for(let i of n._loadedFiles)try{let a=JSON.parse(JSON.stringify(i.content));a.imports!==void 0&&typeof a.imports=="object"&&a.imports!==null&&I4(a.imports,r);let f=S.path.join(t,i.fileType);await S.fs.writeTextFile(f,JSON.stringify(a,null,2)),o++}catch(a){se.debug(`Failed to copy ${i.fileType}: ${a instanceof Error?a.message:String(a)}`)}if(o>0){let i=o===1?"config file":"config files";se.info(` \u{1F4CB} Copied ${o} ${i} to dist/server for import resolution`)}}async function D4(e,t){let n=S.path.resolve(e,"public");if(await S.fs.exists(n))for await(let r of S.fs.readDir(n)){let o=S.path.resolve(n,r.name),i=S.path.resolve(t,r.name);await xl(o,i,{overwrite:!0})}}async function L4(e,t,n){let r=0,o=S.path.relative(n,e),i=S.path.resolve(e,"app/messages"),a=S.path.resolve(t,o,"app/messages");if(await S.fs.exists(i)){await S.fs.ensureDir(a);for await(let p of S.fs.readDir(i))if(p.isFile&&p.name.endsWith(".json")){let m=S.path.resolve(i,p.name),y=S.path.resolve(a,p.name);await xl(m,y,{overwrite:!0}),r++}}let f=S.path.resolve(e,"lib/i18n/messages"),d=S.path.resolve(t,o,"lib/i18n/messages");if(await S.fs.exists(f)){await S.fs.ensureDir(d);for await(let p of S.fs.readDir(f))if(p.isFile&&p.name.endsWith(".json")){let m=S.path.resolve(f,p.name),y=S.path.resolve(d,p.name);await xl(m,y,{overwrite:!0}),r++}}r>0?se.debug(`\u2713 Copied ${r} translation file(s)`):se.debug("No messages directories found, skipping translation files")}async function Q_(e,t,n,r){let o=S.path.resolve(t,"app/styles/global.css"),i=S.path.resolve(r,"styles.css");if(!await S.fs.exists(o)){se.debug("No CSS source file found, skipping CSS processing");return}try{await TS({input:o,output:i,minify:!0,projectRoot:n,plugin:e}),se.debug("\u2713 CSS processed")}catch(a){throw se.error("CSS processing failed:",{error:a}),a}}async function N4(e,t){if(!e.extractCriticalCss)return se.debug("CSS plugin doesn't support critical CSS extraction, skipping"),null;let n=S.path.resolve(t,"styles.css");if(!await S.fs.exists(n))return se.debug("No styles.css found, skipping critical CSS extraction"),null;try{let r=await S.fs.readTextFile(n),i=e.extractCriticalCss(r,`
|
|
166
|
+
${p}`),{success:!1,clientBundle:"",moduleMap:{},clientComponents:0,duration:performance.now()-i,timestamp:Date.now()}}}async function F4(e){return await A4(e)?(se.info("\u{1F504} Build needed, running build..."),await sp(e)):(se.info("\u2705 Build is up-to-date, skipping..."),await O4(e))}async function A4(e){let{distDir:t,chunkManifestFile:n,srcDir:r,clientEntry:o,projectRoot:i}=e;if(!await S.fs.exists(t)||!await S.fs.exists(n))return!0;let a=await S.fs.readTextFile(n),d=JSON.parse(a).timestamp,p=[];for await(let m of S.fs.readDir(r))m.isFile&&rg.test(m.name)&&p.push(S.path.resolve(r,m.name));p.push(o);for(let m of p)try{let y=await S.fs.stat(m);if(y.mtime&&y.mtime.getTime()>d)return se.debug(` Changed: ${S.path.relative(i,m)}`),!0}catch{}return!1}async function O4(e){let{chunkManifestFile:t,distDir:n}=e,r=await S.fs.readTextFile(t),o=JSON.parse(r),i=await S.fs.readTextFile(S.path.resolve(n,$_)),a=JSON.parse(i);return{success:!0,clientBundle:S.path.resolve(n,"client.js"),moduleMap:a,clientComponents:Object.keys(a).length,duration:0,timestamp:o.timestamp}}function Gx(e,t){let{srcDir:n,distDir:r,projectRoot:o}=e;se.debug("\u{1F441}\uFE0F Watch mode enabled, monitoring for changes...");let i=YI(),a={...e,cache:i},f=S.path.relative(o,r),d=[n],p=S.fs.watch(d),m=!1,y=!1,b=new Set,w=null,F=50;async function O(){if(m){y=!0;return}m=!0;do{y=!1;try{let D=Array.from(b);i.invalidateFiles(D.map(Z=>S.path.resolve(o,Z)));let U=D.some(Z=>Z.endsWith(".css")),H=D.some(Z=>Z.match(/\.(tsx?|jsx?)$/)),J=U&&!H,Y=!U&&H,z=new Set(D.map(Z=>S.path.resolve(o,Z))),M=await sp(a,{skipCss:Y,cssOnly:J,changedFiles:z});M.changedFiles=Array.from(b),se.debug(`\u2705 Rebuild complete (${M.duration.toFixed(0)}ms)`),t(M),b.clear()}catch(D){se.error("\u274C Rebuild failed:",{error:D})}}while(y);m=!1}return(async()=>{for await(let D of p)if(D.kind==="modify"||D.kind==="create"||D.kind==="remove"){let U=D.paths[0];if(!U)continue;let H=S.path.relative(o,U);if(!H.match(/\.(tsx?|jsx?|css)$/))continue;let J=pl(H),Y=pl(f);if(J.startsWith(`${Y}/`)||H.includes(".temp."))continue;se.debug(`\u{1F504} File changed: ${H}`),b.add(H),w!==null&&clearTimeout(w),w=setTimeout(()=>{w=null,O()},F)}})(),p}async function M4(e,t,n,r){let{config:o,projectRoot:i,distDir:a}=e,{plugin:f}=e;if(!f.createClientEntry)throw new Error("Framework plugin must implement createClientEntry");let d=await f.createClientEntry(t,i,a);try{let p=t.map(D=>D.filePath),m=S.path.resolve(a,Hx),y=RI({projectRoot:i,browserShims:o.browserShims,autoMarkExternal:!1}),b={...Ug.define};if(!e.bundlerBackend)throw new Error("Bundler backend is required for client bundling");let w=await n_({entrypoints:[d,...p],outputDir:m,projectRoot:i,minify:Ug.minify,splitting:Ug.codeSplitting,platform:"browser",sourcemap:Ug.sourceMaps,plugins:[y],define:b},t,e.bundlerBackend),F=a_(n,r,w,t,o.logLevel,!1),O=S.path.resolve(m,q_);await s_(F,O);try{await S.fs.remove(d)}catch{}return t_(w),l_(F),S.path.resolve(a,w.entrypoint)}catch(p){try{await S.fs.remove(d)}catch{}throw p}}function I4(e,t){for(let[n,r]of Object.entries(e))typeof r=="string"&&(r.startsWith("./")||r.startsWith("../"))&&(e[n]=S.path.join(t,r))}async function _4(e,t){let n=await lg({baseDir:e});if(n===void 0){se.debug("No config files found to copy");return}let r=S.path.relative(t,e),o=0;for(let i of n._loadedFiles)try{let a=JSON.parse(JSON.stringify(i.content));a.imports!==void 0&&typeof a.imports=="object"&&a.imports!==null&&I4(a.imports,r);let f=S.path.join(t,i.fileType);await S.fs.writeTextFile(f,JSON.stringify(a,null,2)),o++}catch(a){se.debug(`Failed to copy ${i.fileType}: ${a instanceof Error?a.message:String(a)}`)}if(o>0){let i=o===1?"config file":"config files";se.info(` \u{1F4CB} Copied ${o} ${i} to dist/server for import resolution`)}}async function D4(e,t){let n=S.path.resolve(e,"public");if(await S.fs.exists(n))for await(let r of S.fs.readDir(n)){let o=S.path.resolve(n,r.name),i=S.path.resolve(t,r.name);await xl(o,i,{overwrite:!0})}}async function L4(e,t,n){let r=0,o=S.path.relative(n,e),i=S.path.resolve(e,"app/messages"),a=S.path.resolve(t,o,"app/messages");if(await S.fs.exists(i)){await S.fs.ensureDir(a);for await(let p of S.fs.readDir(i))if(p.isFile&&p.name.endsWith(".json")){let m=S.path.resolve(i,p.name),y=S.path.resolve(a,p.name);await xl(m,y,{overwrite:!0}),r++}}let f=S.path.resolve(e,"lib/i18n/messages"),d=S.path.resolve(t,o,"lib/i18n/messages");if(await S.fs.exists(f)){await S.fs.ensureDir(d);for await(let p of S.fs.readDir(f))if(p.isFile&&p.name.endsWith(".json")){let m=S.path.resolve(f,p.name),y=S.path.resolve(d,p.name);await xl(m,y,{overwrite:!0}),r++}}r>0?se.debug(`\u2713 Copied ${r} translation file(s)`):se.debug("No messages directories found, skipping translation files")}async function Q_(e,t,n,r){let o=S.path.resolve(t,"app/styles/global.css"),i=S.path.resolve(r,"styles.css");if(!await S.fs.exists(o)){se.debug("No CSS source file found, skipping CSS processing");return}try{await TS({input:o,output:i,minify:!0,projectRoot:n,plugin:e}),se.debug("\u2713 CSS processed")}catch(a){throw se.error("CSS processing failed:",{error:a}),a}}async function N4(e,t){if(!e.extractCriticalCss)return se.debug("CSS plugin doesn't support critical CSS extraction, skipping"),null;let n=S.path.resolve(t,"styles.css");if(!await S.fs.exists(n))return se.debug("No styles.css found, skipping critical CSS extraction"),null;try{let r=await S.fs.readTextFile(n),i=e.extractCriticalCss(r,`
|
|
167
167
|
<!DOCTYPE html>
|
|
168
168
|
<html lang="en">
|
|
169
169
|
<head></head>
|
|
@@ -764,7 +764,7 @@ To install, add the following to your ${gt(t.rcFile)}:
|
|
|
764
764
|
${Ft(n)}
|
|
765
765
|
`},OE=e=>{let t=e.flags.shell,n;if(t!==void 0){if(!["bash","zsh","fish"].includes(t))return bt({message:`${tn(`Invalid shell: ${t}`)}
|
|
766
766
|
Supported shells: bash, zsh, fish`,exitCode:1});n=t}else n=rc();let o=e.root.completions(n);return t===void 0&&(console.log(`Generating ${gt(n)} completions...`),console.log(jY(n)),console.log(Ft(`--- Completion script ---
|
|
767
|
-
`))),console.log(o),$e(void 0)};var cB=new oi("system").description("Commands related with this CLI").command(new oi("install").description("Install eser CLI globally").run(Gm)).command(new oi("uninstall").description("Uninstall eser CLI globally").run(AE)).command(new oi("update").description("Update eser CLI to the latest version").run(Ym)).command(new oi("completions").description("Generate shell completion scripts").flag({name:"shell",type:"string",description:"Shell type: bash, zsh, or fish"}).run(OE));var ME={name:"@eser/cli",version:"4.0.
|
|
767
|
+
`))),console.log(o),$e(void 0)};var cB=new oi("system").description("Commands related with this CLI").command(new oi("install").description("Install eser CLI globally").run(Gm)).command(new oi("uninstall").description("Uninstall eser CLI globally").run(AE)).command(new oi("update").description("Update eser CLI to the latest version").run(Ym)).command(new oi("completions").description("Generate shell completion scripts").flag({name:"shell",type:"string",description:"Shell type: bash, zsh, or fish"}).run(OE));var ME={name:"@eser/cli",version:"4.0.42",type:"module",exports:"./main.ts",bin:{eser:"./bin.ts"},dependencies:{"@eser/codebase":"workspace:*","@eser/laroux-server":"workspace:*","@eser/logging":"workspace:*","@eser/shell":"workspace:*","@eser/standards":"workspace:*","@std/cli":"npm:@jsr/std__cli@^1.0.25","@std/fmt":"npm:@jsr/std__fmt@^1.0.8"},devDependencies:{esbuild:"^0.24.2"}};var IE=e=>async(t,n)=>await e.parse(t),uB=(e,t)=>async(n,r)=>await e({args:[],flags:r,root:{name:"eser",completions:()=>"",help:()=>""},commandPath:["eser",t]}),$Y=new oi("version").description("Show version number").flag({name:"bare",type:"boolean",description:"Output version number only, without 'eser' prefix"}).run(e=>(e.flags.bare===!0?console.log(ME.version):console.log(`eser ${ME.version}`),Promise.resolve($e(void 0)))),eV={codebase:TO,laroux:IE(eB),system:IE(cB),install:uB(Gm,"install"),update:uB(Ym,"update"),version:IE($Y)},dB=()=>{console.log(`eser - Eser Ozvataf's command-line tooling to access things
|
|
768
768
|
`),console.log(`Usage: eser <command> [subcommand] [options]
|
|
769
769
|
`),console.log("Commands:"),console.log(" codebase Codebase management tools"),console.log(" laroux laroux.js framework commands (init, dev, build, serve)"),console.log(" system Commands related with this CLI"),console.log(" install Install eser CLI globally (alias for system install)"),console.log(" update Update eser CLI to latest version (alias for system update)"),console.log(" version Show version number"),console.log(`
|
|
770
770
|
Options:`),console.log(" -h, --help Show this help message"),console.log(`
|