eser 4.1.22 → 4.1.26
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/chunks/add-ORJYWG26.js +7 -0
- package/chunks/{anthropic-GBDSASP5.js → anthropic-SL274RBQ.js} +1 -1
- package/chunks/approve-5NJ4JWD3.js +1 -0
- package/chunks/ask-TFJCKH5G.js +2 -0
- package/chunks/block-ADHHHUFZ.js +1 -0
- package/chunks/{browser-6UKLTPJO.js → browser-XCMD2IZQ.js} +1 -1
- package/chunks/{build-VKOO2WEA.js → build-2W7YVR7J.js} +2 -2
- package/chunks/{bun-N3TIWBPP.js → bun-YFFBDKUJ.js} +1 -1
- package/chunks/changelog-gen-LV5VWTZS.js +7 -0
- package/chunks/chunk-2J2PXBOC.js +1 -0
- package/chunks/{chunk-NIX3WX3O.js → chunk-3EFU5R2M.js} +1 -1
- package/chunks/{chunk-7GS5KPVF.js → chunk-3I4JG3PJ.js} +1 -1
- package/chunks/{chunk-7QNRH7OR.js → chunk-3K42AALS.js} +1 -1
- package/chunks/{chunk-TMFPDVYN.js → chunk-3OEM65F2.js} +17 -17
- package/chunks/{chunk-RGUC6KAZ.js → chunk-4H4O3TGK.js} +1 -1
- package/chunks/{chunk-V5HTJPFW.js → chunk-4HAIX3WN.js} +3 -3
- package/chunks/chunk-4VL2RZIN.js +1 -0
- package/chunks/chunk-5AK4OGCO.js +1 -0
- package/chunks/chunk-5MN3MWQN.js +1 -0
- package/chunks/chunk-5RK3346P.js +4 -0
- package/chunks/chunk-6HYGGBEQ.js +1 -0
- package/chunks/{chunk-PLRSDG6G.js → chunk-762C2IM6.js} +1 -1
- package/chunks/{chunk-NZFUFGOC.js → chunk-AAV7D6DF.js} +1 -1
- package/chunks/{chunk-DLVQNMNV.js → chunk-AKJB4CER.js} +1 -1
- package/chunks/{chunk-NSZ4HGDI.js → chunk-ANY26ROY.js} +1 -1
- package/chunks/{chunk-IAWIWTDY.js → chunk-AYSPDG4K.js} +1 -1
- package/chunks/{chunk-DOV5776P.js → chunk-BCHXUKWW.js} +2 -2
- package/chunks/{chunk-3DMTTLUJ.js → chunk-BDTJR6UH.js} +1 -1
- package/chunks/{chunk-BP2MZX2P.js → chunk-C3PZVQ3Z.js} +1 -1
- package/chunks/{chunk-M5TBBQQC.js → chunk-CKD2KOHA.js} +3 -3
- package/chunks/chunk-CPRLAMEG.js +1 -0
- package/chunks/chunk-DWYVBWBP.js +91 -0
- package/chunks/{chunk-PBSR4XR2.js → chunk-ETMOOGY2.js} +1 -1
- package/chunks/chunk-G34MS4XJ.js +1 -0
- package/chunks/chunk-GVSBZ6JV.js +1 -0
- package/chunks/{chunk-C3OSYHJY.js → chunk-H4OFOQQ2.js} +1 -1
- package/chunks/{chunk-XWYLEYLY.js → chunk-HTBLWLKV.js} +1 -1
- package/chunks/chunk-JOXKA7TJ.js +7 -0
- package/chunks/{chunk-JQHMDTPL.js → chunk-KAEAT6A4.js} +1 -1
- package/chunks/chunk-LO424HF3.js +60 -0
- package/chunks/chunk-LOFP256P.js +1 -0
- package/chunks/{chunk-4HNB3UTC.js → chunk-MBC2JM7F.js} +1 -1
- package/chunks/{chunk-2R4MK2KR.js → chunk-MYSTBVWT.js} +1 -1
- package/chunks/chunk-NGZZAQ7G.js +1 -0
- package/chunks/chunk-NLNSK3KE.js +1 -0
- package/chunks/chunk-NT2MQK7O.js +6 -0
- package/chunks/{chunk-SJQWPBMJ.js → chunk-NTPOK5H6.js} +1 -1
- package/chunks/{chunk-DZD6MI45.js → chunk-PO3SXFUE.js} +1 -1
- package/chunks/chunk-Q54LOR4S.js +2 -0
- package/chunks/{chunk-5C7ZQN6X.js → chunk-QIODVVTY.js} +1 -1
- package/chunks/{chunk-ZY72QNKZ.js → chunk-QIYWONJL.js} +1 -1
- package/chunks/chunk-QZY4BKI7.js +1 -0
- package/chunks/chunk-RBB5ITAS.js +2 -0
- package/chunks/chunk-RYLOB2JU.js +1 -0
- package/chunks/{chunk-VFMYWG2I.js → chunk-SBOTNOWZ.js} +1 -1
- package/chunks/{chunk-Z7742D7Q.js → chunk-SG4G3OOO.js} +1 -1
- package/chunks/{chunk-FGDJVQG3.js → chunk-TTYO2XJO.js} +1 -1
- package/chunks/{chunk-EW5NCPPE.js → chunk-TUTRX7VR.js} +3 -3
- package/chunks/{chunk-UJX2S56V.js → chunk-TXL6YOFL.js} +1 -1
- package/chunks/{chunk-4Q3SEHPE.js → chunk-U47ABJCC.js} +1 -1
- package/chunks/chunk-U65FD6J3.js +1 -0
- package/chunks/{chunk-7M3ONEMO.js → chunk-UKYKMDYU.js} +1 -1
- package/chunks/{chunk-DRQWYJMH.js → chunk-UNL4H5EY.js} +1 -1
- package/chunks/{chunk-ATLUGTI7.js → chunk-V2N5L24J.js} +2 -2
- package/chunks/chunk-VVHXAOEH.js +1 -0
- package/chunks/{chunk-HPVL4BVQ.js → chunk-W3REWI3H.js} +2 -2
- package/chunks/{chunk-MQH4XBFN.js → chunk-XMCQMTAA.js} +1 -1
- package/chunks/chunk-YMY2URYM.js +1 -0
- package/chunks/{chunk-XJ3VEVYL.js → chunk-YQU3TEIG.js} +1 -1
- package/chunks/chunk-YWCEHTZB.js +2 -0
- package/chunks/chunk-YXSB6RET.js +1 -0
- package/chunks/chunk-Z4WPWVC7.js +10 -0
- package/chunks/chunk-ZED5RIVL.js +1 -0
- package/chunks/chunk-ZH37DSUQ.js +1 -0
- package/chunks/claude-code-K37KYX7W.js +1 -0
- package/chunks/clone-PAQMCIA3.js +5 -0
- package/chunks/{commitmsg-SQRQONCS.js → commitmsg-ZGOEO5YG.js} +2 -2
- package/chunks/{deno-PZXN5K3J.js → deno-MMJLKXAE.js} +1 -1
- package/chunks/{dev-FLO2KEPZ.js → dev-JHAHGTZP.js} +2 -2
- package/chunks/file-tools-shared-77P7MI54.js +1 -0
- package/chunks/gemini-ARTUPDPZ.js +1 -0
- package/chunks/gh-SXEDNWHD.js +4 -0
- package/chunks/{gh-contributors-5SHGJHAQ.js → gh-contributors-G3QZZAUO.js} +3 -3
- package/chunks/init-3GXDO32O.js +1 -0
- package/chunks/init-IPZHDMAH.js +12 -0
- package/chunks/install-VY2L6NDB.js +2 -0
- package/chunks/kiro-XQDHURLU.js +1 -0
- package/chunks/{list-MN7OUE52.js → list-2RZIQZGH.js} +1 -1
- package/chunks/{list-B7L4FZKG.js → list-DSVIPH45.js} +1 -1
- package/chunks/{list-UZKWSA4S.js → list-V2HZCPDN.js} +1 -1
- package/chunks/load-config-KG4RTCR2.js +1 -0
- package/chunks/{main-WVXCURBF.js → main-FQFNY7SM.js} +2 -2
- package/chunks/manifest-5CYL3HR3.js +1 -0
- package/chunks/mod-5ACKR2OE.js +1 -0
- package/chunks/{mod-PEAFMI6F.js → mod-CUIGNRIK.js} +1 -1
- package/chunks/mod-NSY6WUYH.js +27 -0
- package/chunks/mod-QJMMYECF.js +10 -0
- package/chunks/mod-T76TRJWM.js +1 -0
- package/chunks/{mod-CI56JMO4.js → mod-TLLZ3NAM.js} +2 -2
- package/chunks/mod-TSU5UWXA.js +1 -0
- package/chunks/{mod-JTBNNSZZ.js → mod-U6LEXPVR.js} +1 -1
- package/chunks/{mod-MKMQWZ6G.js → mod-VZPKQ7DG.js} +1 -1
- package/chunks/mod-WYRORC72.js +1 -0
- package/chunks/new-EAETGSIR.js +4 -0
- package/chunks/next-F2BIIAZC.js +3 -0
- package/chunks/{node-VPHAK3FD.js → node-SMAAGOR3.js} +1 -1
- package/chunks/ollama-6JZ2IKR7.js +1 -0
- package/chunks/opencode-CHIAJALZ.js +1 -0
- package/chunks/recipe-applier-R4YJPGQR.js +1 -0
- package/chunks/registry-fetcher-J6X32PGP.js +1 -0
- package/chunks/{release-YJOLKWDT.js → release-6PVE4O6P.js} +2 -2
- package/chunks/release-notes-734LKEJB.js +3 -0
- package/chunks/release-tag-YX727TXO.js +1 -0
- package/chunks/reset-PAPDZIDC.js +1 -0
- package/chunks/rule-4GNOR3GE.js +2 -0
- package/chunks/{run-7JXDS75G.js → run-ES4BLQQX.js} +1 -1
- package/chunks/{scripts-RSK5XDRW.js → scripts-COIXD5AD.js} +1 -1
- package/chunks/{serve-U6IXMGXQ.js → serve-B4V2BCWM.js} +2 -2
- package/chunks/{server-PXE4DB3V.js → server-RYWDAYED.js} +1 -1
- package/chunks/spec-SNAUMQSR.js +1 -0
- package/chunks/status-CY5IKIYS.js +1 -0
- package/chunks/sync-OAPV43JS.js +1 -0
- package/chunks/system-5A6DQLM5.js +1 -0
- package/chunks/system-5LLFPIWV.js +1 -0
- package/chunks/update-O75M4SDJ.js +5 -0
- package/chunks/validate-bom-6G7EYFOP.js +1 -0
- package/chunks/validate-case-conflict-OWHWRTSQ.js +1 -0
- package/chunks/validate-circular-deps-TCYSZKME.js +1 -0
- package/chunks/validate-commit-msg-UPJJ7E4M.js +1 -0
- package/chunks/validate-docs-ZTCE5XLF.js +1 -0
- package/chunks/validate-eof-6RMNMAWI.js +1 -0
- package/chunks/validate-export-names-5ZVQ4PGM.js +1 -0
- package/chunks/validate-filenames-5YB27RN4.js +1 -0
- package/chunks/validate-json-6CLTN4AN.js +1 -0
- package/chunks/validate-large-files-KEMHYWKH.js +1 -0
- package/chunks/validate-licenses-WIVY6G5Z.js +1 -0
- package/chunks/validate-line-endings-KNFYAVBG.js +1 -0
- package/chunks/validate-merge-conflict-PYKGIFY5.js +1 -0
- package/chunks/validate-mod-exports-X5UZPD7J.js +1 -0
- package/chunks/validate-package-configs-SYKEIB53.js +1 -0
- package/chunks/validate-secrets-BWDFWN64.js +1 -0
- package/chunks/validate-shebangs-MP6VTLWO.js +1 -0
- package/chunks/validate-submodules-RQXISWKG.js +1 -0
- package/chunks/validate-symlinks-IPRYMDZD.js +1 -0
- package/chunks/validate-toml-KJZK7QVM.js +1 -0
- package/chunks/validate-trailing-whitespace-RO42VWQG.js +1 -0
- package/chunks/validate-yaml-H7G726ZM.js +1 -0
- package/chunks/versions-KW5UTMNV.js +1 -0
- package/chunks/vertexai-TPGIAJNA.js +1 -0
- package/chunks/workerd-LKKH32SO.js +1 -0
- package/eser.js +1 -1
- package/package.json +1 -1
- package/chunks/add-4LRHVBEC.js +0 -7
- package/chunks/approve-364KOMLB.js +0 -1
- package/chunks/ask-752YJEHO.js +0 -2
- package/chunks/block-JVJQU723.js +0 -1
- package/chunks/changelog-gen-ZCNNOY7G.js +0 -7
- package/chunks/chunk-2TRQKCFC.js +0 -1
- package/chunks/chunk-3TYZYY77.js +0 -1
- package/chunks/chunk-4HMEWMWL.js +0 -1
- package/chunks/chunk-5O7V5P53.js +0 -1
- package/chunks/chunk-5UGVJVIQ.js +0 -1
- package/chunks/chunk-6YRN6OJC.js +0 -2
- package/chunks/chunk-BKVQBSFV.js +0 -6
- package/chunks/chunk-CDLEA2PD.js +0 -1
- package/chunks/chunk-GRTR6TNJ.js +0 -1
- package/chunks/chunk-H2JGLZIR.js +0 -1
- package/chunks/chunk-HGNGFAAY.js +0 -60
- package/chunks/chunk-HVMMNGY5.js +0 -7
- package/chunks/chunk-L2BYHWDC.js +0 -1
- package/chunks/chunk-LRL56YFE.js +0 -1
- package/chunks/chunk-LU3DHXOC.js +0 -2
- package/chunks/chunk-NADES3GN.js +0 -1
- package/chunks/chunk-QIUIPRJP.js +0 -1
- package/chunks/chunk-R6F4EK2B.js +0 -4
- package/chunks/chunk-SCCNNGD4.js +0 -2
- package/chunks/chunk-SCULX2ND.js +0 -1
- package/chunks/chunk-VGFZXQMW.js +0 -1
- package/chunks/chunk-WE7PSSAQ.js +0 -91
- package/chunks/chunk-X4ZCYXOT.js +0 -1
- package/chunks/chunk-XMTGT2NJ.js +0 -10
- package/chunks/chunk-Y6DLCHJN.js +0 -1
- package/chunks/chunk-YUXQ7JNG.js +0 -1
- package/chunks/chunk-ZTLJ775S.js +0 -1
- package/chunks/claude-code-PWTLM554.js +0 -1
- package/chunks/clone-DASXIL35.js +0 -5
- package/chunks/file-tools-shared-ESMPLZVJ.js +0 -1
- package/chunks/gemini-I6F5N7PS.js +0 -1
- package/chunks/gh-Y4BXDXR5.js +0 -4
- package/chunks/init-GXBXQGGV.js +0 -1
- package/chunks/init-UFJL24PW.js +0 -12
- package/chunks/install-Q2KQZM62.js +0 -2
- package/chunks/kiro-NMTIFMT4.js +0 -1
- package/chunks/load-config-TSM3AAQ6.js +0 -1
- package/chunks/manifest-VJQJG2LS.js +0 -1
- package/chunks/mod-3PJAIZ2O.js +0 -1
- package/chunks/mod-7X3BOO5H.js +0 -1
- package/chunks/mod-FKPTF5D5.js +0 -1
- package/chunks/mod-GZ6BSK2P.js +0 -1
- package/chunks/mod-QODEWK3G.js +0 -9
- package/chunks/mod-STKIZYZ3.js +0 -27
- package/chunks/new-W5YBJFGW.js +0 -4
- package/chunks/next-773GX25N.js +0 -3
- package/chunks/ollama-DQ5VM4HI.js +0 -1
- package/chunks/opencode-IZMQZ4ZK.js +0 -1
- package/chunks/recipe-applier-F2REROYS.js +0 -1
- package/chunks/registry-fetcher-ZJ76EHBA.js +0 -1
- package/chunks/release-notes-Z53AFCII.js +0 -3
- package/chunks/release-tag-QRIKYVQB.js +0 -1
- package/chunks/reset-5LQGIOGB.js +0 -1
- package/chunks/rule-K42YEAMO.js +0 -2
- package/chunks/spec-5446CSQC.js +0 -1
- package/chunks/status-HK3P6J6G.js +0 -1
- package/chunks/sync-4FSA5257.js +0 -1
- package/chunks/system-3MH6OCP6.js +0 -1
- package/chunks/system-KWFBSQYQ.js +0 -1
- package/chunks/update-QD5S73WT.js +0 -5
- package/chunks/validate-bom-IVALGNGE.js +0 -1
- package/chunks/validate-case-conflict-LKECKLD5.js +0 -1
- package/chunks/validate-circular-deps-PXFPCBXA.js +0 -1
- package/chunks/validate-commit-msg-77CBKGOF.js +0 -1
- package/chunks/validate-docs-3UGB7LN7.js +0 -1
- package/chunks/validate-eof-ZSIYNHO5.js +0 -1
- package/chunks/validate-export-names-BPSCBX7B.js +0 -1
- package/chunks/validate-filenames-G4XJ2LHN.js +0 -1
- package/chunks/validate-json-YRCFW2O7.js +0 -1
- package/chunks/validate-large-files-MWWSFDOE.js +0 -1
- package/chunks/validate-licenses-Q2YA2MND.js +0 -1
- package/chunks/validate-line-endings-C6NHWHGI.js +0 -1
- package/chunks/validate-merge-conflict-KTBL4FUY.js +0 -1
- package/chunks/validate-mod-exports-LQIIQRIS.js +0 -1
- package/chunks/validate-package-configs-36PYXIWC.js +0 -1
- package/chunks/validate-secrets-UFDJ7ITY.js +0 -1
- package/chunks/validate-shebangs-3UO4MDMZ.js +0 -1
- package/chunks/validate-submodules-YA654D3B.js +0 -1
- package/chunks/validate-symlinks-R2PNE5TG.js +0 -1
- package/chunks/validate-toml-7H2N5AKI.js +0 -1
- package/chunks/validate-trailing-whitespace-HXO7M3ED.js +0 -1
- package/chunks/validate-yaml-ZJJCQVBB.js +0 -1
- package/chunks/versions-CWT5S7G4.js +0 -1
- package/chunks/vertexai-2SMP54AR.js +0 -1
- package/chunks/workerd-NXKZMQPV.js +0 -1
- /package/chunks/{chunk-QXTK62N4.js → chunk-ACQUINWH.js} +0 -0
- /package/chunks/{chunk-VTQ72OK7.js → chunk-FDZP7B5Y.js} +0 -0
- /package/chunks/{chunk-4OIKB2P5.js → chunk-T7K64JD5.js} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{a as N,b as x,c as H}from"./chunk-NLNSK3KE.js";import{f as C}from"./chunk-Q54LOR4S.js";import{a as E,d as $}from"./chunk-NUSNMQPL.js";import{f as S}from"./chunk-5AK4OGCO.js";import{f as b,h,k as I}from"./chunk-TTYO2XJO.js";import{d as o,e as k,f as g,g as A,j as y}from"./chunk-PLJNPQFC.js";import{a as v}from"./chunk-HPPFA3XU.js";import{a as d,b as c,c as R}from"./chunk-DQAEQEXD.js";import{t as w}from"./chunk-YXSB6RET.js";import"./chunk-SG4G3OOO.js";import"./chunk-FDZP7B5Y.js";import"./chunk-ACQUINWH.js";import"./chunk-DXB73IDG.js";var _=r=>E(async e=>{try{let t=await S(r.registrySource,{verbose:r.verbose,local:r.local}),s=t.recipes.find(n=>n.name===r.recipeName);if(s===void 0)return c({_tag:"RecipeNotFound",message:`Recipe '${r.recipeName}' not found. Run \`eser kit list\` to see available recipes.`});let a=await N(r.cwd),i=x(s,a);for(let n of i.warnings)e.out.writeln(A(`Warning: ${n}`));let l=await C(r.recipeName,t.recipes,{cwd:r.cwd,registryUrl:t.registryUrl,force:r.force,skipExisting:r.skipExisting,dryRun:r.dryRun,verbose:r.verbose,variables:r.variables}),m=0,p=0;for(let n of l.recipes)m+=n.result.written.length,p+=n.result.skipped.length;e.out.writeln(g(`\u2713 Added ${m} file(s)`)),l.recipes.length>1&&e.out.writeln(o(` Applied ${l.recipes.length} recipes (including dependencies)`)),p>0&&e.out.writeln(o(` Skipped ${p} existing file(s)`));let f=l.recipes.find(n=>n.name===r.recipeName);if(f!==void 0)for(let n of f.result.written)e.out.writeln(` \u2192 ${n}`);let u;if(!r.noInstall&&!r.dryRun&&i.instructions.length>0){e.out.writeln(o(`
|
|
2
|
+
Installing dependencies...`)),u=await H(i.instructions,r.cwd,{verbose:r.verbose});for(let n of u)n.success?e.out.writeln(g(` \u2713 ${n.command}`)):e.out.writeln(k(` \u2717 ${n.command}: ${n.error}`))}else if(i.instructions.length>0){e.out.writeln(o(`
|
|
3
|
+
Dependencies (run manually):`));for(let n of i.instructions)e.out.writeln(o(` ${n}`))}return d({recipe:s,chainResult:l,depInfo:i,installResults:u})}catch(t){let s=t instanceof Error?t.message:String(t);return c({_tag:"ApplyError",message:s})}});var j=r=>{let e={};for(let t of r){let[s,...a]=String(t).split("=");s!==void 0&&s!==""&&(e[s]=a.join("="))}return e},B=async r=>{let e=v(r??[],{string:["registry","var"],boolean:["dry-run","force","skip-existing","verbose","local","no-install"],collect:["var"]}),t=e._[0],s=b({renderer:I.ansi(),sink:h.stdout()});if(t===void 0)return s.writeln("Usage: eser kit add <recipe> [--registry <url>] [--dry-run] [--var key=value]"),s.writeln(),s.writeln("Run ",o("`eser kit list`")," to see available recipes."),await s.close(),d(void 0);let a=e["dry-run"]===!0;a?s.writeln(y(`
|
|
4
|
+
Dry run: ${t}
|
|
5
|
+
`)):s.writeln(y(`
|
|
6
|
+
Adding ${t}...
|
|
7
|
+
`));let i=await $(_({recipeName:t,cwd:w.process.cwd(),registrySource:e.registry,local:e.local===!0,dryRun:a,force:e.force===!0,skipExisting:e["skip-existing"]===!0,verbose:e.verbose===!0,noInstall:e["no-install"]===!0,variables:j(e.var)}),{out:s});return await s.close(),R(i)?d(void 0):c({exitCode:1})};export{B as main};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"./chunk-
|
|
1
|
+
import{a,b}from"./chunk-TXL6YOFL.js";import"./chunk-5MN3MWQN.js";import"./chunk-OLM5RTFK.js";import"./chunk-DXB73IDG.js";export{a as AnthropicModel,b as anthropicFactory};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as w}from"./chunk-LXVBR775.js";import{d as h,e as u}from"./chunk-NT2MQK7O.js";import{f as m,h as c,k as d}from"./chunk-TTYO2XJO.js";import{c as r,d as o,e as i,f as p,j as l}from"./chunk-PLJNPQFC.js";import{a}from"./chunk-DQAEQEXD.js";import{t as n}from"./chunk-YXSB6RET.js";import"./chunk-SG4G3OOO.js";import"./chunk-FDZP7B5Y.js";import"./chunk-ACQUINWH.js";import"./chunk-DXB73IDG.js";var D=async g=>{let e=m({renderer:d.ansi(),sink:c.stdout()}),t=n.process.cwd(),s=await h(t);if(s.phase==="SPEC_DRAFT"){let f=w(s);await u(t,f),e.writeln(p("\u2714")," Spec approved. Phase: ",l("BUILDING")),e.writeln("Run ",r("noskills next")," to start building.")}else s.phase==="DISCOVERY"&&s.discovery.completed?(e.writeln(o("Discovery complete. Spec draft already generated.")),e.writeln("Review the spec and run ",r("noskills approve")," again when in SPEC_DRAFT phase.")):e.writeln(i(`Cannot approve in phase: ${s.phase}`));return await e.close(),a(void 0)};export{D as main};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as _,b as $}from"./chunk-6FMPNAZ3.js";import{a as F}from"./chunk-5MN3MWQN.js";import{d as x,f as v,g as I,h as y,k as P}from"./chunk-TTYO2XJO.js";import{d as O,e as L,g as R}from"./chunk-OBIEQJDE.js";import{a as T}from"./chunk-USCAYIWL.js";import"./chunk-PLJNPQFC.js";import"./chunk-OLM5RTFK.js";import{b as S}from"./chunk-BCHXUKWW.js";import{a as C,b as g}from"./chunk-DQAEQEXD.js";import{t as m}from"./chunk-YXSB6RET.js";import"./chunk-SG4G3OOO.js";import"./chunk-FDZP7B5Y.js";import"./chunk-ACQUINWH.js";import"./chunk-DXB73IDG.js";var k=(e,t,n)=>{let i=e.streamText(t,n);return{name:`ai-text/${e.provider}/${e.modelId}`,readable:new ReadableStream({async start(o){try{for await(let s of i)s.kind==="content_delta"&&o.enqueue(x(s.textDelta));o.close()}catch(s){o.error(s)}}})}};var Y={cc:"claude-code",ol:"ollama",oc:"opencode",oai:"openai",ant:"anthropic",gem:"gemini",vtx:"vertexai"},q={"claude-code":"Claude Code",ollama:"Ollama",opencode:"OpenCode",kiro:"Kiro",anthropic:"Anthropic API",openai:"OpenAI API",gemini:"Gemini API",vertexai:"Vertex AI"},H=e=>Y[e]??e,K=async e=>{if(e){let t=m.process.stderr.getWriter(),n=v({renderer:P.ansi(),sink:y.writable(new WritableStream({async write(i){await t.write(new TextEncoder().encode(String(i.data)))},close(){t.releaseLock()}}))});await O.configure({sinks:{stderr:R.getOutputSink(n)},loggers:[{category:["ai"],lowestLevel:T.Debug,sinks:["stderr"]}]})}return L.getLogger(["ai","ask"])},M=async e=>{await e.info("Auto-detecting AI provider...");try{if(await S`which claude`.noThrow().code()===0)return await e.info("Claude Code detected."),"claude-code"}catch{}try{if((await fetch("http://localhost:11434/api/version",{signal:AbortSignal.timeout(1e3)})).ok)return await e.info("Ollama detected at localhost:11434."),"ollama"}catch{}try{if(await S`which opencode`.noThrow().code()===0)return await e.info("OpenCode detected."),"opencode"}catch{}if(m.capabilities.env){if(m.env.has("ANTHROPIC_API_KEY"))return await e.info("Anthropic API key detected."),"anthropic";if(m.env.has("OPENAI_API_KEY"))return await e.info("OpenAI API key detected."),"openai"}throw new Error("No AI provider detected. Install claude, ollama, or set ANTHROPIC_API_KEY / OPENAI_API_KEY.")},U=async e=>{switch(e){case"claude-code":return(await import("./claude-code-K37KYX7W.js")).claudeCodeFactory;case"ollama":return(await import("./ollama-6JZ2IKR7.js")).ollamaFactory;case"opencode":return(await import("./opencode-CHIAJALZ.js")).openCodeFactory;case"kiro":return(await import("./kiro-XQDHURLU.js")).kiroFactory;case"anthropic":return(await import("./anthropic-SL274RBQ.js")).anthropicFactory;case"openai":return(await import("./openai-XMIVMDDL.js")).openaiFactory;case"gemini":return(await import("./gemini-ARTUPDPZ.js")).geminiFactory;case"vertexai":return(await import("./vertexai-TPGIAJNA.js")).vertexaiFactory;default:throw new Error(`Unknown provider: ${e}`)}},le=async e=>{let t=e??[],n=null,i=null,o=null,s=!1,p=!1,A=[],a=0;for(;a<t.length;){let r=t[a];if(r==="-p"||r==="--provider"){n=t[a+1]??null,a+=2;continue}if(r==="-m"||r==="--model"){i=t[a+1]??null,a+=2;continue}if(r==="--max-tokens"){let c=t[a+1];c!==void 0&&(o=Number(c)),a+=2;continue}if(r==="--json"){s=!0,a+=1;continue}if(r==="-v"||r==="--verbose"){p=!0,a+=1;continue}r.startsWith("-")||A.push(r),a+=1}let f=A.join(" ");if(f.length===0)return g({message:'Usage: ai ask "your prompt" [-p provider] [-m model] [--verbose]',exitCode:1});let d=await K(p);try{let r=n!==null?H(n):await M(d),c=q[r]??r,E=i??z(r);await d.info(`Using ${c} (${E})`);let N=await U(r),w=new _({factories:[N]});await w.addModel("default",{provider:r,model:E});let h=w.getDefault();if(h===null)return g({message:"Failed to initialize model",exitCode:1});let b=[F("user",f)];if(await d.info(`Sending prompt (${f.length} chars)...`),s){let u=await h.generateText({messages:b,maxTokens:o??void 0});await d.info(`Response received (${$(u).length} chars)`);let l=v({sink:y.stdout()});l.writeln(JSON.stringify(u,null,2)),await l.close()}else{let u=k(h,{messages:b,maxTokens:o??void 0});await I().from(u).to(V()).run();let l=m.process.stdout.getWriter();await l.write(new TextEncoder().encode(`
|
|
2
|
+
`)),l.releaseLock()}return await w.close(),C(void 0)}catch(r){let c=r instanceof Error?r.message:String(r);return await d.error(c),p&&r instanceof Error&&r.cause!==void 0&&await d.debug(`Cause: ${String(r.cause)}`),g({message:c,exitCode:1})}},j=12,G=e=>new Promise(t=>setTimeout(t,e)),V=(e=j)=>{let t=new TextEncoder;return{name:"typewriter",writable:new WritableStream({async write(n){let i=String(n.data),o=m.process.stdout.getWriter();for(let s of i)await o.write(t.encode(s)),await G(e);o.releaseLock()}})}},z=e=>{switch(e){case"claude-code":return"claude-sonnet-4-20250514";case"ollama":return"llama3";case"opencode":return"default";case"kiro":return"default";case"anthropic":return"claude-sonnet-4-20250514";case"openai":return"gpt-4o";case"gemini":return"gemini-2.0-flash";case"vertexai":return"gemini-2.0-flash";default:return"default"}};export{le as main};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as h}from"./chunk-LXVBR775.js";import{d as w,e as f}from"./chunk-NT2MQK7O.js";import{f as c,h as d,k as u}from"./chunk-TTYO2XJO.js";import{c as i,d as l,e as m,g as p}from"./chunk-PLJNPQFC.js";import{a as o,b as n}from"./chunk-DQAEQEXD.js";import{t as a}from"./chunk-YXSB6RET.js";import"./chunk-SG4G3OOO.js";import"./chunk-FDZP7B5Y.js";import"./chunk-ACQUINWH.js";import"./chunk-DXB73IDG.js";var A=async k=>{let e=c({renderer:u.ansi(),sink:d.stdout()}),t=a.process.cwd(),r=k?.join(" ")??"No reason given",s=await w(t);if(s.phase!=="BUILDING")return e.writeln(m(`Cannot block in phase: ${s.phase}`)),await e.close(),n({exitCode:1});let g=h(s,r);return await f(t,g),e.writeln(p("\u26A0")," Spec blocked: ",l(r)),e.writeln("Resolve with: ",i('noskills next --answer="resolution"')),await e.close(),o(void 0)};export{A as main};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as s}from"./chunk-
|
|
1
|
+
import{b as s}from"./chunk-FDZP7B5Y.js";import{a as r}from"./chunk-ACQUINWH.js";import"./chunk-DXB73IDG.js";var o={fs:!1,fsSync:!1,exec:!1,process:!1,env:!1,stdin:!1,stdout:!1,kv:!1},t=e=>()=>{throw new r(e,"browser")},n=()=>{let e=t("fs");return{readFile:e,readTextFile:e,writeFile:e,writeTextFile:e,exists:e,stat:e,lstat:e,mkdir:e,ensureDir:e,remove:e,readDir:e,copyFile:e,rename:e,makeTempDir:e,realPath:e,watch:e,walk:e,chmod:e}},i=()=>{let e=t("exec");return{spawn:e,exec:e,execJson:e,spawnChild:e}},a=()=>{let e=t("process");return{exit:e,setExitCode:e,cwd:e,chdir:e,hostname:e,execPath:e,get args(){throw new r("process","browser")},get pid(){throw new r("process","browser")},get stdin(){throw new r("process","browser")},get stdout(){throw new r("process","browser")},get stderr(){throw new r("process","browser")}}},c=()=>({get:()=>{},set:()=>{},delete:()=>{},has:()=>!1,toObject:()=>({})}),l=()=>({name:"browser",version:globalThis.navigator?.userAgent??"unknown",capabilities:o,fs:n(),path:s,exec:i(),env:c(),process:a()});export{o as BROWSER_CAPABILITIES,l as createBrowserRuntime};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{f as d,h as g,k as m}from"./chunk-
|
|
1
|
+
import{f as d,h as g,k as m}from"./chunk-TTYO2XJO.js";import{b as c,d as L,g as C,j as u}from"./chunk-PLJNPQFC.js";import"./chunk-ZOZYBQX2.js";import{a as v}from"./chunk-DWYVBWBP.js";import"./chunk-HPPFA3XU.js";import{a as y}from"./chunk-DQAEQEXD.js";import"./chunk-YXSB6RET.js";import"./chunk-SG4G3OOO.js";import"./chunk-FDZP7B5Y.js";import"./chunk-ACQUINWH.js";import"./chunk-DXB73IDG.js";var V=["trace","debug","info","warn","error","fatal"],N=async x=>{let{flags:o}=v(x??[],[{name:"out-dir",type:"string",default:"dist",description:"Output directory"},{name:"clean",type:"boolean",description:"Clean output first"},{name:"no-minify",type:"boolean",description:"Disable minification"},{name:"analyze",type:"boolean",description:"Analyze bundle size"},{name:"log-level",type:"string",default:"info",description:"Log level"}]),t=d({renderer:m.ansi(),sink:g.stdout()});t.writeln(u(`
|
|
2
2
|
\u{1F4E6} Building for production...
|
|
3
|
-
`));let e=await import("./mod-6P2JPEHC.js"),{
|
|
3
|
+
`));let e=await import("./mod-6P2JPEHC.js"),{runtime:n}=await import("./mod-WYRORC72.js"),i=n.process.cwd(),p=o["out-dir"],S=!o["no-minify"],h=o.clean,k=o.analyze,f=o["log-level"]??"info",b=V.includes(f.toLowerCase())?f.toLowerCase():"info",z={trace:e.Severities.Trace,debug:e.Severities.Debug,info:e.Severities.Info,warn:e.Severities.Warning,error:e.Severities.Error,fatal:e.Severities.Critical},D=d({renderer:m.ansi(),sink:g.stdout()});await e.config.configure({sinks:{console:e.sinks.getOutputSink(D)},loggers:[{category:["laroux-bundler"],lowestLevel:z[b],sinks:["console"]}]});let[{build:A,createBuildContext:E},{loadConfig:O},{reactPlugin:B},{createTailwindPlugin:P}]=await Promise.all([import("./system-5A6DQLM5.js"),import("./load-config-KG4RTCR2.js"),import("./mod-TLLZ3NAM.js"),import("./mod-U6LEXPVR.js")]),T=e.logger.getLogger(["laroux-bundler","cli"]),s=await O(i),r={projectRoot:i,srcDir:n.path.resolve(i,s.srcDir),distDir:n.path.resolve(i,p),logLevel:b,fonts:s.fonts,images:s.images,cssModuleTypes:s.cssModuleTypes,noCssModuleAutoReference:s.noCssModuleAutoReference,browserShims:s.browserShims,serverExternals:s.build.serverExternals,build:{...s.build,minify:S}};if(h)try{await n.fs.remove(r.distDir,{recursive:!0}),T.debug(`Cleaned ${r.distDir}`)}catch{}let R=P({globalCssPath:n.path.resolve(i,"src/app/styles/global.css")}),j=E(r,{framework:B,css:R,bundlerBackend:"rolldown"});if(await A(j),await e.config.reset(),k){t.writeln(u(`
|
|
4
4
|
\u{1F4CA} Bundle Analysis:
|
|
5
5
|
`));try{let M=`${p}/client/manifest.json`,$=await n.fs.readTextFile(M),w=JSON.parse($);t.writeln(c("Chunks:"));for(let[a,l]of Object.entries(w.files)){let I=(l.size/1024).toFixed(2);t.writeln(c(` ${a.padEnd(30)} ${I.padStart(8)} KB`))}let F=Object.values(w.files).reduce((a,l)=>a+l.size,0);t.writeln(L(`
|
|
6
6
|
Total: ${(F/1024).toFixed(2)} KB`))}catch{t.writeln(C("Could not analyze build (manifest.json not found)"))}}return await t.close(),y(void 0)};export{N as main};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as F}from"./chunk-
|
|
1
|
+
import{b as F}from"./chunk-T7K64JD5.js";import{b as v,d as b}from"./chunk-ACQUINWH.js";import"./chunk-DXB73IDG.js";import*as n from"node:fs/promises";import*as O from"node:fs";import*as o from"node:path";import*as w from"node:os";import m from"node:process";import{Readable as x,Writable as k}from"node:stream";var E={fs:!0,fsSync:!0,exec:!0,process:!0,env:!0,stdin:!0,stdout:!0,kv:!1},R=()=>{let s=e=>({isFile:e.isFile(),isDirectory:e.isDirectory(),isSymlink:e.isSymbolicLink(),size:e.size,mtime:e.mtime,atime:e.atime,birthtime:e.birthtime}),a=(e,t)=>{throw e instanceof Error&&"code"in e&&e.code==="ENOENT"?new v(t):e};return{async readFile(e,t){try{let r=await n.readFile(e,{signal:t?.signal});return new Uint8Array(r)}catch(r){return a(r,e)}},async readTextFile(e,t){try{return await n.readFile(e,{encoding:"utf-8",signal:t?.signal})}catch(r){return a(r,e)}},async writeFile(e,t,r){let d=r?.append?"a":"w";await n.writeFile(e,t,{signal:r?.signal,mode:r?.mode,flag:d})},async writeTextFile(e,t,r){let d=r?.append?"a":"w";await n.writeFile(e,t,{encoding:"utf-8",signal:r?.signal,mode:r?.mode,flag:d})},async exists(e){try{return await n.access(e),!0}catch{return!1}},async stat(e){try{let t=await n.stat(e);return s(t)}catch(t){return a(t,e)}},async lstat(e){try{let t=await n.lstat(e);return s(t)}catch(t){return a(t,e)}},async mkdir(e,t){await n.mkdir(e,{recursive:t?.recursive??!1,mode:t?.mode})},async ensureDir(e){await n.mkdir(e,{recursive:!0})},async remove(e,t){try{await n.rm(e,{recursive:t?.recursive??!1,force:!1})}catch(r){a(r,e)}},async*readDir(e){try{let t=await n.readdir(e,{withFileTypes:!0});for(let r of t)yield{name:r.name,isFile:r.isFile(),isDirectory:r.isDirectory(),isSymlink:r.isSymbolicLink()}}catch(t){a(t,e)}},async copyFile(e,t){await n.copyFile(e,t)},async rename(e,t){await n.rename(e,t)},async makeTempDir(e){let t=e?.dir??w.tmpdir(),r=e?.prefix??"",d=e?.suffix??"",i=await n.mkdtemp(o.join(t,r));if(d){let c=i+d;return await n.rename(i,c),c}return i},async realPath(e){try{return await n.realpath(e)}catch(t){throw t instanceof Error&&"code"in t&&t.code==="ENOENT"?new v(e):t}},watch(e,t){let r=t?.recursive??!0,d=[],i=[],c=[],u=!1,h=l=>{u||(c.length>0?c.shift()({value:l,done:!1}):i.push(l))};for(let l of e)try{let P=O.watch(l,{recursive:r},(y,f)=>{f!==null&&h({kind:y==="rename"?"create":"modify",paths:[o.join(l,f)]})});d.push(P)}catch{}return{close:()=>{u=!0;for(let l of d)l.close();for(let l of c)l({value:void 0,done:!0});c=[]},[Symbol.asyncIterator]:()=>({next:()=>u?Promise.resolve({value:void 0,done:!0}):i.length>0?Promise.resolve({value:i.shift(),done:!1}):new Promise(l=>{c.push(l)})})}},async chmod(e,t){await n.chmod(e,t)},async*walk(e,t){let r=t?.includeDirs??!0,d=t?.includeFiles??!0,i=t?.exts,c=t?.skip,u=async function*(h){let l=await n.readdir(h,{withFileTypes:!0});for(let P of l){let y=o.join(h,P.name);if(c?.some(p=>p.test(y)))continue;let f=P.isSymbolicLink();if(P.isDirectory())r&&(yield{path:y,name:P.name,isFile:!1,isDirectory:!0,isSymlink:f}),yield*u(y);else if(P.isFile()||f){if(!d||i&&!i.some(p=>P.name.endsWith(p.startsWith(".")?p:`.${p}`)))continue;yield{path:y,name:P.name,isFile:P.isFile(),isDirectory:!1,isSymlink:f}}}};yield*u(e)}}},S=()=>({join:o.join,resolve:o.resolve,dirname:o.dirname,basename:o.basename,extname:o.extname,normalize:o.normalize,isAbsolute:o.isAbsolute,relative:o.relative,parse:o.parse,format:o.format,sep:o.sep,delimiter:o.delimiter}),g=async s=>{if(!s)return new Uint8Array(0);let a=[],e=s.getReader();try{for(;;){let{done:i,value:c}=await e.read();if(i)break;a.push(c)}}finally{e.releaseLock()}let t=a.reduce((i,c)=>i+c.length,0),r=new Uint8Array(t),d=0;for(let i of a)r.set(i,d),d+=i.length;return r},A=()=>({async spawn(s,a=[],e){let[t,r,d]=F(e),i=Bun.spawn([s,...a],{cwd:e?.cwd,env:e?.env,stdin:t,stdout:r,stderr:d}),[c,u,h]=await Promise.all([i.exited,g(i.stdout),g(i.stderr)]);return{success:c===0,code:c,stdout:u,stderr:h}},async exec(s,a=[],e){let t=await this.spawn(s,a,e);if(!t.success){let r=new TextDecoder().decode(t.stderr);throw new b(s,t.code,r)}return new TextDecoder().decode(t.stdout).trim()},async execJson(s,a=[],e){let t=await this.exec(s,a,e);return JSON.parse(t)},spawnChild(s,a=[],e){let[t,r,d]=F(e),i=Bun.spawn([s,...a],{cwd:e?.cwd,env:e?.env,stdin:t,stdout:r,stderr:d}),c=i.exited.then(u=>({success:u===0,code:u,signal:void 0}));return{pid:i.pid,stdin:i.stdin,stdout:i.stdout,stderr:i.stderr,status:c,output:async()=>{let[u,h,l]=await Promise.all([c,g(i.stdout),g(i.stderr)]);return{success:u.success,code:u.code,stdout:h,stderr:l}},kill:u=>{i.kill(u)}}}}),W=()=>({get(s){return m.env[s]},set(s,a){m.env[s]=a},delete(s){delete m.env[s]},has(s){return s in m.env},toObject(){let s={};for(let[a,e]of Object.entries(m.env))e!==void 0&&(s[a]=e);return s}}),D=()=>({exit(s){m.exit(s)},setExitCode(s){m.exitCode=s},cwd(){return m.cwd()},chdir(s){m.chdir(s)},hostname(){return w.hostname()},execPath(){return m.execPath},args:m.argv.slice(2),pid:m.pid,stdin:x.toWeb(m.stdin),stdout:k.toWeb(m.stdout),stderr:k.toWeb(m.stderr)}),C=()=>{let s=R(),a=S(),e=A(),t=W(),r=D();return{name:"bun",version:Bun.version,capabilities:E,fs:s,path:a,exec:e,env:t,process:r}};export{E as BUN_CAPABILITIES,C as createBunRuntime};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{a as $,b as G}from"./chunk-C3PZVQ3Z.js";import{a as N}from"./chunk-RBB5ITAS.js";import"./chunk-V2N5L24J.js";import"./chunk-Y6DZEK4W.js";import"./chunk-34GCQZ3Z.js";import"./chunk-3APERFKY.js";import{a as E}from"./chunk-6U2VEZEM.js";import{a as w,b as A}from"./chunk-KAEAT6A4.js";import"./chunk-ZH37DSUQ.js";import"./chunk-LOFP256P.js";import"./chunk-ZF2XYULB.js";import"./chunk-4S7QYPS6.js";import{f as R}from"./chunk-NUSNMQPL.js";import"./chunk-GXPLME3K.js";import"./chunk-2J2PXBOC.js";import"./chunk-TTYO2XJO.js";import"./chunk-USCAYIWL.js";import{b as u,e as h,f as y,g as v,h as x}from"./chunk-PLJNPQFC.js";import"./chunk-BCHXUKWW.js";import{a as C}from"./chunk-HPPFA3XU.js";import{g as p}from"./chunk-DQAEQEXD.js";import"./chunk-WUJUQPHI.js";import"./chunk-A2GDVOQP.js";import"./chunk-GLSCZGXA.js";import"./chunk-ZE5T64HQ.js";import{v as m}from"./chunk-YXSB6RET.js";import"./chunk-SG4G3OOO.js";import"./chunk-FDZP7B5Y.js";import"./chunk-ACQUINWH.js";import"./chunk-DXB73IDG.js";var f=w(),S={feat:"Added",fix:"Fixed",refactor:"Changed",perf:"Changed",docs:"Changed",revert:"Removed"},O=new Set(["chore","ci","test"]),T=/^(\w+)(?:\(([^)]+)\))?!?:\s{1,5}(.+)$/,P=/\s{0,100}\(take\s{1,100}[IVXLCDM\d]+\)\s{0,100}\.?$/i,I=(n,t)=>{let o=n.match(T);if(o!==null)return{type:o[1].toLowerCase(),scope:o[2],message:o[3].trim(),hash:t}},b=n=>n.replace(P,"").trim(),k=n=>{let t=[];for(let o of n){let e=I(o.subject,o.hash);e!==void 0&&t.push(e)}return t},L=n=>{let t=new Set,o=[];for(let e of n){let s=b(e.message),a=s.replace(/[.\s]{1,20}$/,"").toLowerCase(),l=`${e.type}:${a}`;t.has(l)||(t.add(l),o.push({...e,message:s}))}return o},M=n=>{let t=new Map;for(let o of n){if(O.has(o.type))continue;let e=S[o.type];if(e===void 0)continue;let s=t.get(e);s!==void 0?s.push(o):t.set(e,[o])}return t},H=n=>n.scope!==void 0?`- **${n.scope}:** ${n.message}`:`- ${n.message}`,F=(n,t)=>{let o=M(t);if(o.size===0)return"";let e=new Date().toISOString().split("T")[0],s=[`## ${n} - ${e}`],a=["Added","Changed","Fixed","Removed"];for(let l of a){let r=o.get(l);if(!(r===void 0||r.length===0)){s.push("",`### ${l}`,"");for(let d of r)s.push(H(d))}}return s.join(`
|
|
2
|
+
`)},j=(n,t,o)=>{let e=n.split(`
|
|
3
|
+
`);if(o!==void 0){let r=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),d=new RegExp(`^##\\s+${r}\\b`),i=e.findIndex(g=>d.test(g));if(i!==-1){let g=e.length;for(let c=i+1;c<e.length;c++)if(/^##\s+/.test(e[c])){g=c;break}return e.splice(i,g-i,t),e.join(`
|
|
4
|
+
`)}}let s=e.findIndex(r=>/^##\s+\[Unreleased\]/i.test(r));if(s===-1){let r=e.findIndex((i,g)=>g>0&&i.startsWith("## ")),d=r===-1?e.length:r;return e.splice(d,0,"",t,""),e.join(`
|
|
5
|
+
`)}let a=-1;for(let r=s+1;r<e.length;r++)if(/^##\s+/.test(e[r])){a=r;break}let l=a===-1?e.length:a;return e.splice(l,0,t,""),e.join(`
|
|
6
|
+
`)},V=async(n={})=>{let{root:t=".",dryRun:o=!1}=n,e=await N({root:t});if(e===void 0||e==="")throw new Error("VERSION file is missing or empty.");let s;try{s=await $()}catch{throw new Error("No git tags found. Create an initial tag first (e.g., git tag v0.0.0).")}let a=await G(s,"HEAD");if(a.length===0)throw new Error(`No commits found since ${s}. Nothing to release.`);let l=k(a),r=L(l),d=F(e,r);if(d==="")throw new Error("No user-facing changes found (all commits are chore/ci/test). Nothing to add to CHANGELOG.");if(!o){let i=m.runtime.path.join(t,"CHANGELOG.md"),g;try{g=await m.runtime.fs.readTextFile(i)}catch{throw new Error(`CHANGELOG.md not found at ${i}. Create one first.`)}let c=j(g,d,e);await m.runtime.fs.writeTextFile(i,c)}return{version:e,commitCount:a.length,entryCount:r.filter(i=>!O.has(i.type)).length,content:d,dryRun:o}},D=n=>R.fromPromise(()=>V(n)),_=n=>p.ok({dryRun:n.flags["dry-run"]===!0}),z=n=>{if(p.isFail(n))return f.writeln(h("\u2717"),u(" "+(n.error instanceof Error?n.error.message:String(n.error)))),p.fail({exitCode:1});let{value:t}=n;return t.dryRun?(f.writeln(v("\u26A0"),u(" [DRY RUN] Generated changelog preview:")),f.writeln(x("\u2139"),u(`
|
|
7
|
+
${t.content}`))):f.writeln(y("\u2713"),u(` Added ${t.entryCount} entries to CHANGELOG.md for v${t.version}`)),p.ok(void 0)},B=E.createTrigger({handler:D,adaptInput:_,adaptOutput:z}),ee=async n=>{let t=C(n??[],{boolean:["dry-run"],alias:{n:"dry-run"}}),o=A("changelog-gen",t);return await B(o)};export{L as deduplicateCommits,V as generateChangelog,D as generateChangelogHandler,F as generateChangelogSection,M as groupBySection,B as handleCli,j as insertIntoChangelog,ee as main,I as parseConventionalCommit,k as parseConventionalCommits,b as stripTakeSuffix};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=/\.(?:[cm]?[jt]sx?)$/,o=["tsx","jsx","ts","js","mts","mjs","cts","cjs"];function r(t,s){return t.replace(e,s)}var c=(t,s)=>s.some(n=>t.endsWith(`.${n}`));export{e as a,o as b,r as c,c as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as y,d as h,e as k,f as T}from"./chunk-
|
|
1
|
+
import{c as y,d as h,e as k,f as T}from"./chunk-762C2IM6.js";import{a as u,e as p}from"./chunk-OLM5RTFK.js";var c=class{capabilities=["text_generation","streaming","tool_calling","vision","audio","structured_output","reasoning"];provider="gemini";modelId;client;config;constructor(e,t){this.client=e,this.config=t,this.modelId=t.model}async generateText(e,t){let a=C(this.config,e);try{let n=await this.client.models.generateContent({model:this.config.model,...a,config:{...a.config,httpOptions:t!==void 0?{signal:t}:void 0}});return k(n,this.modelId)}catch(n){throw S(n)}}async*streamText(e,t){let a=C(this.config,e);try{let n=await this.client.models.generateContentStream({model:this.config.model,...a,config:{...a.config,httpOptions:t!==void 0?{signal:t}:void 0}}),r=0,i=0;for await(let l of n){let g=l?.candidates??[];if(g.length>0){let f=g[0],R=f?.content?.parts??[];for(let s of R)s.text!==void 0&&(yield{kind:"content_delta",textDelta:s.text}),s.functionCall!==void 0&&(yield{kind:"tool_call_delta",toolCall:{id:s.functionCall.name,name:s.functionCall.name,arguments:s.functionCall.args??{}}});let d=f?.finishReason;if(d!=null){let s=l?.usageMetadata;r=s?.promptTokenCount??r,i=s?.candidatesTokenCount??i;let m="end_turn";d==="MAX_TOKENS"&&(m="max_tokens"),yield{kind:"message_done",stopReason:m,usage:{inputTokens:r,outputTokens:i,totalTokens:r+i}}}}}}catch(n){yield{kind:"error",error:S(n)}}}async close(){}getRawClient(){return this.client}},v={provider:"gemini",async createModel(o){let{GoogleGenAI:e}=await import("./node-RWYXITVV.js"),t=new e({apiKey:o.apiKey});return new c(t,o)}},C=(o,e)=>{let{contents:t,systemInstruction:a}=y(e.messages),n={maxOutputTokens:e.maxTokens??o.maxTokens};e.temperature!==void 0&&(n.temperature=e.temperature),e.topP!==void 0&&(n.topP=e.topP),e.stopWords!==void 0&&(n.stopSequences=e.stopWords),e.responseFormat!==void 0&&e.responseFormat.type==="json_schema"&&(n.responseMimeType="application/json",n.responseSchema=e.responseFormat.jsonSchema),e.thinkingBudget!==void 0&&(n.thinkingConfig={thinkingBudget:e.thinkingBudget});let r={contents:t,config:n},i=e.system??a;return i!=null&&(r.systemInstruction=i),e.tools!==void 0&&(r.tools=h(e.tools)),e.safetySettings!==void 0&&(r.safetySettings=e.safetySettings),r},S=o=>{if(o instanceof u)return o;let e=o instanceof Error?o:new Error(String(o)),t=T(o);return p("gemini",t,e)};export{c as a,v as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"./chunk-GXPLME3K.js";import{t}from"./chunk-
|
|
1
|
+
import{a as s}from"./chunk-GXPLME3K.js";import{t}from"./chunk-YXSB6RET.js";import{b as a}from"./chunk-ACQUINWH.js";var i=[".manifest.yml",".manifest.yaml"],l=async o=>{for(let e of i){let n=t.path.join(o,e);try{let r=await t.fs.readTextFile(n);return s(r)}catch(r){if(r instanceof a)continue;throw r}}return null},m=async o=>{for(let e of i){let n=t.path.join(o,e);try{return await t.fs.stat(n),n}catch{continue}}return null};export{i as a,l as b,m as c};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as i}from"./chunk-OLM5RTFK.js";import{a as d,b as c}from"./chunk-
|
|
1
|
+
import{a as i}from"./chunk-OLM5RTFK.js";import{a as d,b as c}from"./chunk-BCHXUKWW.js";var y=async(r,t)=>{let e=t.properties?.binPath;if(e!==void 0)return e;try{let n=await c`which ${r}`.noThrow().text();if(n.length>0)return n}catch{}throw new i(`Binary "${r}" not found. Set properties.binPath in config or ensure it is on PATH.`,{provider:r})},f=(r,t,e)=>{let s=new d(r,[...t],{stdin:"null",stdout:"piped",stderr:"piped",cwd:e?.cwd,env:e?.env}).child();if(e?.signal!==void 0){let o=e.signal;o.aborted?s.kill("SIGTERM"):o.addEventListener("abort",()=>{s.kill("SIGTERM")},{once:!0})}return{stdout:s.stdout,stderr:s.stderr,waitForExit:async()=>{let o=await s.status;return{code:o.code,success:o.success}},kill:o=>{s.kill(o??"SIGTERM")}}},a=new TextDecoder;async function*m(r){let t=r.getReader(),e="";try{let n=await t.read();for(;n.done!==!0;){e+=a.decode(n.value,{stream:!0});let o=e.split(`
|
|
2
2
|
`);e=o.pop()??"";for(let u of o){let l=u.trim();if(l.length!==0)try{yield JSON.parse(l)}catch{}}n=await t.read()}let s=e.trim();if(s.length>0)try{yield JSON.parse(s)}catch{}}finally{t.releaseLock()}}var h=async(r,t)=>{let e=r.getReader(),n=[],s=await e.read();for(;s.done!==!0;)n.push(a.decode(s.value,{stream:!0})),s=await e.read();return e.releaseLock(),{content:[{kind:"text",text:n.join("").trim()}],stopReason:"end_turn",usage:{inputTokens:0,outputTokens:0,totalTokens:0},modelId:t}},w=async r=>{let t=r.getReader(),e=[],n=await t.read();for(;n.done!==!0;)e.push(a.decode(n.value,{stream:!0})),n=await t.read();return t.releaseLock(),e.join("").trim()},x=(r,t,e)=>{if(t===0)return null;let n=e.length>0?`${r} exited with code ${t}: ${e}`:`${r} exited with code ${t}`;return t===1?new i(n,{provider:r}):t===126||t===127?new i(`${r} binary not found or not executable (exit code ${t})`,{provider:r}):new i(n,{provider:r})},b=(r,t)=>{let e=[];t!==void 0&&(e.push(t),e.push(""));for(let n of r)for(let s of n.content)s.kind==="text"&&e.push(s.text);return e.join(`
|
|
3
3
|
`)};export{y as a,f as b,m as c,h as d,w as e,x as f,b as g};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{a as ge,b as me,d as X,e as
|
|
1
|
+
import{a as ge,b as me,d as X,e as Ye,f as et,g as tt,h as U}from"./chunk-5RK3346P.js";import{n as $e}from"./chunk-UKYKMDYU.js";import{a as nt}from"./chunk-4H4O3TGK.js";import{c as fe}from"./chunk-V2N5L24J.js";import{a as pe,b as re,c as z,d as Be}from"./chunk-2J2PXBOC.js";import{e as S}from"./chunk-OBIEQJDE.js";import{c as Qe,t as o}from"./chunk-YXSB6RET.js";import{a as H}from"./chunk-FDZP7B5Y.js";var I=S.getLogger(["laroux-bundler","server-action-transform"]);function mn(e,t){return`${e.replace(/\.[cm]?[jt]sx?$/,"")}#${t}`}function hn(e,t){let n=mn(e,t);return`Object.defineProperties(${t}, {
|
|
2
2
|
$$typeof: { value: Symbol.for("react.server.reference"), enumerable: false },
|
|
3
3
|
$$id: { value: "${n}", enumerable: false },
|
|
4
4
|
$$bound: { value: null, enumerable: false, writable: true }
|
|
5
|
-
});`}async function
|
|
5
|
+
});`}async function yn(e,t){let n;try{n=await o.fs.readTextFile(e)}catch(u){return I.warn(`Failed to read file: ${e}`,{error:u}),null}if(!ge(n,"use server"))return I.debug(`Skipping ${e} - no file-level "use server"`),null;let r=me(n);if(r.length===0)return I.debug(`Skipping ${e} - no exports found`),null;let s=r.filter(u=>u!=="default");if(s.length===0)return I.debug(`Skipping ${e} - only default export`),null;I.debug(`Transforming ${e} with ${s.length} export(s)`);let i=s.map(u=>hn(t,u)).join(`
|
|
6
6
|
`),a=n.split(`
|
|
7
7
|
`);a.push(""),a.push("// Auto-generated React server reference markers"),a.push(i);let c=a.join(`
|
|
8
|
-
`);return await o.fs.writeTextFile(e,c),I.debug(`Transformed ${e}: marked ${s.length} action(s) with server reference symbols`),s}async function
|
|
8
|
+
`);return await o.fs.writeTextFile(e,c),I.debug(`Transformed ${e}: marked ${s.length} action(s) with server reference symbols`),s}async function rt(e){if(I.debug(`Scanning for server actions in: ${e}`),!await o.fs.exists(e))return I.debug(`Directory does not exist: ${e}`),[];let n=await X(e,{projectRoot:e});if(n.length===0)return I.debug("No server action files found"),[];I.info(`Found ${n.length} server action file(s) to transform`);let r=[];for(let s of n){let i=await yn(s.filePath,s.relativePath);i!==null&&i.length>0&&r.push({filePath:s.filePath,relativePath:s.relativePath,transformedActions:i})}return I.info(`Transformed ${r.length} server action file(s)`),r}var L=S.getLogger(["laroux-bundler","client-action-stub"]);function xn(e,t){return`${e.replace(/\.[cm]?[jt]sx?$/,"")}#${t}`}function wn(e,t){let n=xn(e,t);return`export const ${t} = Object.assign(
|
|
9
9
|
async function ${t}(...args) {
|
|
10
10
|
if (typeof globalThis.__callServer !== "function") {
|
|
11
11
|
throw new Error("Server actions not initialized. Ensure client bootstrap provides __callServer.");
|
|
@@ -17,7 +17,7 @@ import{a as ge,b as me,d as X,e as Qe,f as Ye,g as et,h as U}from"./chunk-R6F4EK
|
|
|
17
17
|
$$id: "${n}",
|
|
18
18
|
$$bound: null
|
|
19
19
|
}
|
|
20
|
-
);`}function
|
|
20
|
+
);`}function bn(e,t){let n=`/**
|
|
21
21
|
* Auto-generated client stubs for server actions
|
|
22
22
|
* Original file: ${e}
|
|
23
23
|
*
|
|
@@ -25,10 +25,10 @@ import{a as ge,b as me,d as X,e as Qe,f as Ye,g as et,h as U}from"./chunk-R6F4EK
|
|
|
25
25
|
* Action ID format: path/to/file#exportName
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
`,r=t.map(s=>
|
|
28
|
+
`,r=t.map(s=>wn(e,s)).join(`
|
|
29
29
|
|
|
30
30
|
`);return n+r+`
|
|
31
|
-
`}async function bn(e,t){let n;try{n=await o.fs.readTextFile(e)}catch(a){return L.warn(`Failed to read file: ${e}`,{error:a}),null}if(!ge(n,"use server"))return null;let r=me(n);if(r.length===0)return L.debug(`Skipping ${e} - no exports found`),null;let s=r.filter(a=>a!=="default");if(s.length===0)return L.debug(`Skipping ${e} - only default export`),null;L.debug(`Generating stubs for ${e} with ${s.length} export(s)`);let i=wn(t,s);return await o.fs.writeTextFile(e,i),L.debug(`Generated client stubs: ${s.join(", ")}`),s}async function rt(e,t){if(L.debug(`Scanning for server actions in: ${e}`),!await o.fs.exists(e))return L.debug(`Directory does not exist: ${e}`),[];let r=await X(e,{projectRoot:t});if(r.length===0)return L.debug("No server action files found"),[];L.info(`Found ${r.length} server action file(s) to generate stubs for`);let s=[];for(let i of r){let a=await bn(i.filePath,i.relativePath);a!==null&&a.length>0&&s.push({filePath:i.filePath,relativePath:i.relativePath,exportedActions:a})}return L.info(`Generated stubs for ${s.length} server action file(s)`),s}var V="0123456789ABCDEFGHJKMNPQRSTVWXYZ",se=V.length,$e=Math.pow(2,48)-1,Ee=10,ot=16,Cn=Ee+ot;function st(e,t,n){return e.substring(0,t)+n+e.substring(t+1)}function he(e){if(!Number.isInteger(e)||e<0||e>$e)throw new RangeError(`Time must be a positive integer less than ${$e}`);let t="";for(let n=Ee;n>0;n--){let r=e%se;t=V[r]+t,e=Math.floor(e/se)}return t}function Oe(){let e="",t=crypto.getRandomValues(new Uint8Array(ot));for(let n of t)e+=V[n%se];return e}function vn(e){let t=e.length,n,r,s=se-1;for(;--t>=0;){if(n=e[t],r=V.indexOf(n),r===-1)throw new TypeError("Incorrectly encoded string");if(r===s){e=st(e,t,V[0]);continue}return st(e,t,V[r+1])}throw new Error("Cannot increment this string")}function it(e=Oe){let t=0,n;return function(s=Date.now()){if(s<=t){let a=n=vn(n);return he(t)+a}t=s;let i=n=e();return he(s)+i}}var Nr=it();function at(e=Date.now()){return he(e)+Oe()}var lt={name:"noop",analyzeClientComponents:()=>Promise.resolve([]),getAllComponents:()=>Promise.resolve([]),transformClientComponents:()=>Promise.resolve([])};var oe=class extends Error{constructor(n,r,s){super(n);this.code=r;this.hint=s;this.name="BuildError"}},ut={cssError:e=>new oe(`CSS processing failed: ${e}`,"BUILD104","Check your CSS files and configuration."),moduleNotFound:e=>new oe(`Module not found: ${e}`,"BUILD100","Check that the file exists and the import path is correct."),buildFailed:e=>new oe(`Build failed: ${e}`,"BUILD101","Check the error details above and fix any syntax or type errors.")};import{transform as Sn}from"lightningcss";var ie=S.getLogger(["laroux-bundler","css"]);async function De(e){let{input:t,output:n,minify:r=!1,projectRoot:s,plugin:i}=e;if(!await o.fs.exists(t)){ie.warn(`CSS input file not found: ${t}`);return}let a=o.path.resolve(n,"..");await o.fs.ensureDir(a);let c=await o.fs.readTextFile(t);ie.debug(`Processing CSS: ${t} \u2192 ${n}`);let u={projectRoot:s,cssPath:t,isModule:!1};try{(i?.shouldProcess?.(c,u)??!!i)&&i?.compile?c=await i.compile(c,u):c=await ct(c,r),await o.fs.writeTextFile(n,c),ie.debug(`\u2713 CSS processed successfully: ${n}`)}catch(l){let p=l instanceof Error?l.message:String(l);throw ie.error(`CSS processing failed: ${p}`),ut.cssError(p)}}function ct(e,t){try{let n=Sn({filename:"styles.css",code:new TextEncoder().encode(e),minify:t,targets:{chrome:5898240,firefox:5767168,safari:917504},unusedSymbols:[]});return new TextDecoder().decode(n.code)}catch(n){return ie.warn(`Lightning CSS post-processing failed: ${n instanceof Error?n.message:String(n)}`),e}}var Te=S.getLogger(["laroux-bundler","import-map"]),Rn=new Set(["npm:","jsr:","node:"]),Pn=new Set(["npm:","jsr:","node:","http:","https:","file:","data:"]),kn=12;function Z(e){if(URL.canParse(e))return new URL(e).protocol;let t=e.indexOf(":");return t>0&&t<kn?e.slice(0,t+1):null}function ae(e){return e.startsWith("./")||e.startsWith("../")||e.startsWith("/")}function ye(e){let t=Z(e);return t!==null&&Pn.has(t)?!1:!ae(e)}function Mn(e){let t=Z(e);return t==="npm:"||t===null&&!ae(e)}function Fn(e){return Z(e)==="jsr:"}function Bn(e){return ae(e)||Z(e)==="file:"}function $n(e){let t=[];for(let[n,r]of Object.entries(e))t.push({specifier:n,target:r,source:"deno.json",isNpmPackage:Mn(r),isJsrPackage:Fn(r),isLocalPath:Bn(r)});return t}function En(e){let t=[];for(let[n,r]of Object.entries(e)){let s=Z(r);s==="workspace:"||s==="file:"||t.push({specifier:n,target:`npm:${n}@${r}`,source:"package.json",isNpmPackage:!0,isJsrPackage:!1,isLocalPath:!1})}return t}async function On(e){let t=o.path.join(e,"deno.json");try{if(!await o.fs.exists(t)){let s=o.path.join(e,"deno.jsonc");if(!await o.fs.exists(s))return null;let a=await o.fs.readTextFile(s);return JSON.parse(a)}let r=await o.fs.readTextFile(t);return JSON.parse(r)}catch(n){return Te.debug(`Failed to load deno.json: ${n instanceof Error?n.message:String(n)}`),null}}async function Dn(e){let t=o.path.join(e,"package.json");try{if(!await o.fs.exists(t))return null;let r=await o.fs.readTextFile(t);return JSON.parse(r)}catch(n){return Te.debug(`Failed to load package.json: ${n instanceof Error?n.message:String(n)}`),null}}async function dt(e){let t=new Map,n=[],r=await On(e),s=await Dn(e);if(s!==null){let i={...s.peerDependencies,...s.devDependencies,...s.dependencies};for(let a of En(i))t.set(a.specifier,a),(a.isNpmPackage||a.isJsrPackage)&&n.push(a.specifier)}if(r?.imports!==void 0)for(let i of $n(r.imports))t.set(i.specifier,i),(i.isNpmPackage||i.isJsrPackage)&&(n.includes(i.specifier)||n.push(i.specifier));return Te.debug(`Loaded import map: ${t.size} entries, ${n.length} externals`),{entries:t,externals:n,projectRoot:e,hasDenoJson:r!==null,hasPackageJson:s!==null}}function pt(e,t){let n=t.entries.get(e);if(n!==void 0)return n.target;for(let[r,s]of t.entries){if(r.endsWith("/")&&e.startsWith(r)){let i=e.slice(r.length);return s.target.endsWith("/")?`${s.target}${i}`:`${s.target}/${i}`}if(e.startsWith(`${r}/`)){let i=e.slice(r.length);return`${s.target}${i}`}}return null}function ft(e,t){let n=Z(e);if(n!==null&&Rn.has(n))return!0;let r=t.entries.get(e);if(r!==void 0)return r.isNpmPackage||r.isJsrPackage;for(let[s,i]of t.entries)if(e.startsWith(`${s}/`))return i.isNpmPackage||i.isJsrPackage;return!1}async function Tn(e,t){let n=o.path.join(t,"node_modules",".deno");try{if(!(await o.fs.stat(n).catch(()=>null))?.isDirectory)return null;let s=e.split("/"),i=e.startsWith("@")?s.slice(0,2).join("/"):s[0]??e,a=e.startsWith("@")?s.slice(2).join("/"):s.slice(1).join("/");for await(let c of o.fs.readDir(n))if(c.isDirectory&&c.name.startsWith(`${i}@`)){let u=o.path.join(n,c.name,"node_modules",i);if(!(await o.fs.stat(u).catch(()=>null))?.isDirectory)continue;if(a){let m=o.path.join(u,a);if(await o.fs.stat(m).catch(()=>null))return m;let y=`${m}.js`;if(await o.fs.stat(y).catch(()=>null))return y;continue}let p=await fe({baseDir:u});if(p!==void 0){let m;if(p.exports!==void 0){let h=p.exports.value;if(typeof h=="string")m=h;else if(typeof h=="object"&&h["."]!==void 0){let y=h["."];if(typeof y=="string")m=y;else if(typeof y=="object"){let C=y;m=C.import??C.module??C.default??C.require}}}if(m===void 0)for(let h of p._loadedFiles){let y=h.content,C=y.module,R=y.main;if(m=C??R,m!==void 0)break}return m??="index.js",o.path.join(u,m)}let f=o.path.join(u,"index.js");if(await o.fs.stat(f).catch(()=>null))return f}}catch{}return null}var M=S.getLogger(["laroux-bundler","import-map-resolver"]);function gt(e){let t=e.cache??new Map,n=e.importMap??null,r=e.autoMarkExternal??!0,s=e.externals??[],i=c=>{for(let u of s)if(c===u||c.startsWith(`${u}/`))return!0;return!1},a={...e.browserShims.jsr,...e.browserShims.nodeBuiltins};return{name:"import-map-resolver",async setup(c){n===null&&(n=await dt(e.projectRoot),M.debug(`Loaded import map: ${n.entries.size} entries, ${n.externals.length} externals`)),c.onResolve({filter:/^[^./]/},async u=>{let l=u.path;if(!ye(l))return{};let p=t.get(l);if(p!==void 0)return p==="external"?{external:!0}:{path:p};if(i(l))return t.set(l,"external"),M.debug(`Marking ${l} as external (explicit)`),{external:!0};if(a[l]!==void 0)return M.debug(`Using browser shim for ${l}`),{path:`\0virtual:${l}`,namespace:"browser-shim"};let f=pt(l,n);if(f!==null){if(r&&ft(l,n))return t.set(l,"external"),M.debug(`Marking ${l} as external`),{external:!0};try{if(ae(f)){let m=o.path.resolve(n.projectRoot,f);return t.set(l,m),M.debug(`Resolved ${l} \u2192 ${m}`),{path:m}}let d=import.meta.resolve(f);if(d.startsWith("file://")){let m=new URL(d).pathname;return t.set(l,m),M.debug(`Resolved ${l} \u2192 ${m}`),{path:m}}return r?(t.set(l,"external"),M.debug(`Marking ${l} as external (remote: ${d})`),{external:!0}):(M.debug(`Letting bundler resolve ${l} from node_modules`),{})}catch(d){M.debug(`Failed to resolve ${f}: ${d instanceof Error?d.message:String(d)}`)}}if(r&&ye(l))return t.set(l,"external"),M.debug(`Marking ${l} as external (bare import not in import map)`),{external:!0};if(!r&&ye(l)){let d=await Tn(l,e.projectRoot);if(d!==null)return t.set(l,d),M.debug(`Resolved npm transitive dependency ${l} \u2192 ${d}`),{path:d}}return{}}),c.onResolve({filter:/^jsr:/},u=>{let l=u.path,p=t.get(l);if(p!==void 0)return p==="external"?{external:!0}:{path:p};try{let f=import.meta.resolve(l);if(f.startsWith("file://")){let d=new URL(f).pathname;return t.set(l,d),M.debug(`Resolved ${l} \u2192 ${d}`),{path:d}}return t.set(l,"external"),M.debug(`Marking ${l} as external (remote JSR)`),{external:!0}}catch(f){return M.debug(`Failed to resolve ${l}: ${f instanceof Error?f.message:String(f)}`),{}}}),c.onResolve({filter:/^node:/},u=>{let l=u.path;return a[l]!==void 0?(M.debug(`Using browser shim for ${l}`),{path:`\0virtual:${l}`,namespace:"browser-shim"}):(M.warn(`Node builtin ${l} has no browser shim - marking as external`),{external:!0})}),c.onLoad({filter:/.*/,namespace:"browser-shim"},u=>{let l=u.path.replace("\0virtual:",""),p=a[l];return p!==void 0?{contents:p,loader:"js"}:{}})}}}var K=S.getLogger(["laroux-bundler","route-scanner"]),xe=null,je=0,jn=/(?:^|[/\\])(?:_[^/\\]*|.*\.test\.(?:[cm]?[jt]sx?))$/,yt=["page","layout","route","proxy"],Nn=new Set(yt.flatMap(e=>re.map(t=>`${e}.${t}`)));function In(e){for(let t of yt)if(e.startsWith(`${t}.`)&&pe.test(e))return t;return null}function xt(){xe=null,je=0,K.debug("Route cache invalidated")}async function wt(e,t,n=!1){if(!n&&xe)try{if(((await o.fs.stat(e)).mtime?.getTime()??0)<=je)return K.debug("Using cached route scan result"),xe}catch{}K.debug(`Scanning routes in: ${e}`);let r=new Map;for await(let d of tt(e,void 0,jn)){let m=o.path.basename(d);if(!Nn.has(m))continue;let h=o.path.dirname(d),y=r.get(h)??{},C=o.path.join(e,d),R=In(m);R==="page"?y.pagePath=C:R==="layout"?y.layoutPath=C:R==="route"?y.routePath=C:R==="proxy"&&(y.proxyPath=C),r.set(h,y)}let s=[],i=[],a=[],c=d=>{let m=d;for(;m&&m!==".";){let h=o.path.dirname(m);if(h===m)break;let y=r.get(h);if(y?.layoutPath)return o.path.relative(t,y.layoutPath);m=h}};for(let[d,m]of r){let h=An(d);if(m.pagePath){let y=o.path.relative(t,m.pagePath),C=m.layoutPath?o.path.relative(t,m.layoutPath):c(d);s.push({routePath:h,componentPath:y,layoutPath:C,isApiRoute:!1}),K.debug(`Found page: ${h} -> ${y}${C?` (layout: ${C})`:""}`)}if(m.routePath){let y=o.path.relative(t,m.routePath);i.push({routePath:h,componentPath:y,isApiRoute:!0}),K.debug(`Found API route: ${h} -> ${y}`)}if(m.proxyPath){let y=o.path.relative(t,m.proxyPath);a.push({pathPrefix:h||"/",modulePath:y}),K.debug(`Found proxy: ${h||"/"} -> ${y}`)}}let u=mt(s),l=mt(i),p=zn(a);K.debug(`Found ${u.length} page routes, ${l.length} API routes, ${p.length} proxies`);let f={routes:u,apiRoutes:l,proxies:p};try{je=(await o.fs.stat(e)).mtime?.getTime()??0}catch{}return xe=f,f}function An(e){return!e||e==="."||e==="home"?"/":`/${H(e)}`}function mt(e){return e.sort((t,n)=>{let r=ht(t.routePath),s=ht(n.routePath);return r!==s?s-r:n.routePath.length-t.routePath.length})}function ht(e){let t=0,n=e.split("/").filter(Boolean);t+=n.length*10;for(let r of n)r.startsWith("[...")?t-=100:r.startsWith("[")?t-=5:t+=3;return t}function zn(e){return e.sort((t,n)=>n.pathPrefix.length-t.pathPrefix.length)}var _=S.getLogger(["laroux-bundler","route-generator"]);async function bt(e){let{scanResult:t,outputPath:n,projectRoot:r}=e,{routes:s}=t;_.debug(`Generating routes file: ${n}`);let i=[],a=[],c=new Map;for(let l of s){let p=`./${z(l.componentPath,"")}.js`,f=o.path.join(r,l.componentPath),d=Un(l.componentPath),m=await Ln(f,d),h;if(l.layoutPath){let C=o.path.join(r,l.layoutPath),R=_n(l.layoutPath);h=await Wn(C,R)}if(c.has(l.componentPath)||(i.push(`import { ${m} } from "${p}";`),c.set(l.componentPath,m)),l.layoutPath&&h){let C=`./${z(l.layoutPath,"")}.js`;c.has(l.layoutPath)||(i.push(`import { ${h} } from "${C}";`),c.set(l.layoutPath,h))}let y=Jn(l,m,h);a.push(y)}let u=`// AUTO-GENERATED FILE - DO NOT EDIT
|
|
31
|
+
`}async function Cn(e,t){let n;try{n=await o.fs.readTextFile(e)}catch(a){return L.warn(`Failed to read file: ${e}`,{error:a}),null}if(!ge(n,"use server"))return null;let r=me(n);if(r.length===0)return L.debug(`Skipping ${e} - no exports found`),null;let s=r.filter(a=>a!=="default");if(s.length===0)return L.debug(`Skipping ${e} - only default export`),null;L.debug(`Generating stubs for ${e} with ${s.length} export(s)`);let i=bn(t,s);return await o.fs.writeTextFile(e,i),L.debug(`Generated client stubs: ${s.join(", ")}`),s}async function st(e,t){if(L.debug(`Scanning for server actions in: ${e}`),!await o.fs.exists(e))return L.debug(`Directory does not exist: ${e}`),[];let r=await X(e,{projectRoot:t});if(r.length===0)return L.debug("No server action files found"),[];L.info(`Found ${r.length} server action file(s) to generate stubs for`);let s=[];for(let i of r){let a=await Cn(i.filePath,i.relativePath);a!==null&&a.length>0&&s.push({filePath:i.filePath,relativePath:i.relativePath,exportedActions:a})}return L.info(`Generated stubs for ${s.length} server action file(s)`),s}var V="0123456789ABCDEFGHJKMNPQRSTVWXYZ",se=V.length,Ee=Math.pow(2,48)-1,Oe=10,it=16,vn=Oe+it;function ot(e,t,n){return e.substring(0,t)+n+e.substring(t+1)}function he(e){if(!Number.isInteger(e)||e<0||e>Ee)throw new RangeError(`Time must be a positive integer less than ${Ee}`);let t="";for(let n=Oe;n>0;n--){let r=e%se;t=V[r]+t,e=Math.floor(e/se)}return t}function De(){let e="",t=crypto.getRandomValues(new Uint8Array(it));for(let n of t)e+=V[n%se];return e}function Sn(e){let t=e.length,n,r,s=se-1;for(;--t>=0;){if(n=e[t],r=V.indexOf(n),r===-1)throw new TypeError("Incorrectly encoded string");if(r===s){e=ot(e,t,V[0]);continue}return ot(e,t,V[r+1])}throw new Error("Cannot increment this string")}function at(e=De){let t=0,n;return function(s=Date.now()){if(s<=t){let a=n=Sn(n);return he(t)+a}t=s;let i=n=e();return he(s)+i}}var Ir=at();function lt(e=Date.now()){return he(e)+De()}var ut={name:"noop",analyzeClientComponents:()=>Promise.resolve([]),getAllComponents:()=>Promise.resolve([]),transformClientComponents:()=>Promise.resolve([])};var oe=class extends Error{constructor(n,r,s){super(n);this.code=r;this.hint=s;this.name="BuildError"}},ct={cssError:e=>new oe(`CSS processing failed: ${e}`,"BUILD104","Check your CSS files and configuration."),moduleNotFound:e=>new oe(`Module not found: ${e}`,"BUILD100","Check that the file exists and the import path is correct."),buildFailed:e=>new oe(`Build failed: ${e}`,"BUILD101","Check the error details above and fix any syntax or type errors.")};import{transform as Rn}from"lightningcss";var ie=S.getLogger(["laroux-bundler","css"]);async function Te(e){let{input:t,output:n,minify:r=!1,projectRoot:s,plugin:i}=e;if(!await o.fs.exists(t)){ie.warn(`CSS input file not found: ${t}`);return}let a=o.path.resolve(n,"..");await o.fs.ensureDir(a);let c=await o.fs.readTextFile(t);ie.debug(`Processing CSS: ${t} \u2192 ${n}`);let u={projectRoot:s,cssPath:t,isModule:!1};try{(i?.shouldProcess?.(c,u)??!!i)&&i?.compile?c=await i.compile(c,u):c=await dt(c,r),await o.fs.writeTextFile(n,c),ie.debug(`\u2713 CSS processed successfully: ${n}`)}catch(l){let p=l instanceof Error?l.message:String(l);throw ie.error(`CSS processing failed: ${p}`),ct.cssError(p)}}function dt(e,t){try{let n=Rn({filename:"styles.css",code:new TextEncoder().encode(e),minify:t,targets:{chrome:5898240,firefox:5767168,safari:917504},unusedSymbols:[]});return new TextDecoder().decode(n.code)}catch(n){return ie.warn(`Lightning CSS post-processing failed: ${n instanceof Error?n.message:String(n)}`),e}}var je=S.getLogger(["laroux-bundler","import-map"]),Pn=new Set(["npm:","jsr:","node:"]),kn=new Set(["npm:","jsr:","node:","http:","https:","file:","data:"]),Mn=12;function Z(e){if(URL.canParse(e))return new URL(e).protocol;let t=e.indexOf(":");return t>0&&t<Mn?e.slice(0,t+1):null}function ae(e){return e.startsWith("./")||e.startsWith("../")||e.startsWith("/")}function ye(e){let t=Z(e);return t!==null&&kn.has(t)?!1:!ae(e)}function Fn(e){let t=Z(e);return t==="npm:"||t===null&&!ae(e)}function Bn(e){return Z(e)==="jsr:"}function $n(e){return ae(e)||Z(e)==="file:"}function En(e){let t=[];for(let[n,r]of Object.entries(e))t.push({specifier:n,target:r,source:"deno.json",isNpmPackage:Fn(r),isJsrPackage:Bn(r),isLocalPath:$n(r)});return t}function On(e){let t=[];for(let[n,r]of Object.entries(e)){let s=Z(r);s==="workspace:"||s==="file:"||t.push({specifier:n,target:`npm:${n}@${r}`,source:"package.json",isNpmPackage:!0,isJsrPackage:!1,isLocalPath:!1})}return t}async function Dn(e){let t=o.path.join(e,"deno.json");try{if(!await o.fs.exists(t)){let s=o.path.join(e,"deno.jsonc");if(!await o.fs.exists(s))return null;let a=await o.fs.readTextFile(s);return JSON.parse(a)}let r=await o.fs.readTextFile(t);return JSON.parse(r)}catch(n){return je.debug(`Failed to load deno.json: ${n instanceof Error?n.message:String(n)}`),null}}async function Tn(e){let t=o.path.join(e,"package.json");try{if(!await o.fs.exists(t))return null;let r=await o.fs.readTextFile(t);return JSON.parse(r)}catch(n){return je.debug(`Failed to load package.json: ${n instanceof Error?n.message:String(n)}`),null}}async function pt(e){let t=new Map,n=[],r=await Dn(e),s=await Tn(e);if(s!==null){let i={...s.peerDependencies,...s.devDependencies,...s.dependencies};for(let a of On(i))t.set(a.specifier,a),(a.isNpmPackage||a.isJsrPackage)&&n.push(a.specifier)}if(r?.imports!==void 0)for(let i of En(r.imports))t.set(i.specifier,i),(i.isNpmPackage||i.isJsrPackage)&&(n.includes(i.specifier)||n.push(i.specifier));return je.debug(`Loaded import map: ${t.size} entries, ${n.length} externals`),{entries:t,externals:n,projectRoot:e,hasDenoJson:r!==null,hasPackageJson:s!==null}}function ft(e,t){let n=t.entries.get(e);if(n!==void 0)return n.target;for(let[r,s]of t.entries){if(r.endsWith("/")&&e.startsWith(r)){let i=e.slice(r.length);return s.target.endsWith("/")?`${s.target}${i}`:`${s.target}/${i}`}if(e.startsWith(`${r}/`)){let i=e.slice(r.length);return`${s.target}${i}`}}return null}function gt(e,t){let n=Z(e);if(n!==null&&Pn.has(n))return!0;let r=t.entries.get(e);if(r!==void 0)return r.isNpmPackage||r.isJsrPackage;for(let[s,i]of t.entries)if(e.startsWith(`${s}/`))return i.isNpmPackage||i.isJsrPackage;return!1}async function jn(e,t){let n=o.path.join(t,"node_modules",".deno");try{if(!(await o.fs.stat(n).catch(()=>null))?.isDirectory)return null;let s=e.split("/"),i=e.startsWith("@")?s.slice(0,2).join("/"):s[0]??e,a=e.startsWith("@")?s.slice(2).join("/"):s.slice(1).join("/");for await(let c of o.fs.readDir(n))if(c.isDirectory&&c.name.startsWith(`${i}@`)){let u=o.path.join(n,c.name,"node_modules",i);if(!(await o.fs.stat(u).catch(()=>null))?.isDirectory)continue;if(a){let m=o.path.join(u,a);if(await o.fs.stat(m).catch(()=>null))return m;let y=`${m}.js`;if(await o.fs.stat(y).catch(()=>null))return y;continue}let p=await fe({baseDir:u});if(p!==void 0){let m;if(p.exports!==void 0){let h=p.exports.value;if(typeof h=="string")m=h;else if(typeof h=="object"&&h["."]!==void 0){let y=h["."];if(typeof y=="string")m=y;else if(typeof y=="object"){let C=y;m=C.import??C.module??C.default??C.require}}}if(m===void 0)for(let h of p._loadedFiles){let y=h.content,C=y.module,R=y.main;if(m=C??R,m!==void 0)break}return m??="index.js",o.path.join(u,m)}let f=o.path.join(u,"index.js");if(await o.fs.stat(f).catch(()=>null))return f}}catch{}return null}var M=S.getLogger(["laroux-bundler","import-map-resolver"]);function mt(e){let t=e.cache??new Map,n=e.importMap??null,r=e.autoMarkExternal??!0,s=e.externals??[],i=c=>{for(let u of s)if(c===u||c.startsWith(`${u}/`))return!0;return!1},a={...e.browserShims.jsr,...e.browserShims.nodeBuiltins};return{name:"import-map-resolver",async setup(c){n===null&&(n=await pt(e.projectRoot),M.debug(`Loaded import map: ${n.entries.size} entries, ${n.externals.length} externals`)),c.onResolve({filter:/^[^./]/},async u=>{let l=u.path;if(!ye(l))return{};let p=t.get(l);if(p!==void 0)return p==="external"?{external:!0}:{path:p};if(i(l))return t.set(l,"external"),M.debug(`Marking ${l} as external (explicit)`),{external:!0};if(a[l]!==void 0)return M.debug(`Using browser shim for ${l}`),{path:`\0virtual:${l}`,namespace:"browser-shim"};let f=ft(l,n);if(f!==null){if(r&>(l,n))return t.set(l,"external"),M.debug(`Marking ${l} as external`),{external:!0};try{if(ae(f)){let m=o.path.resolve(n.projectRoot,f);return t.set(l,m),M.debug(`Resolved ${l} \u2192 ${m}`),{path:m}}let d=import.meta.resolve(f);if(d.startsWith("file://")){let m=new URL(d).pathname;return t.set(l,m),M.debug(`Resolved ${l} \u2192 ${m}`),{path:m}}return r?(t.set(l,"external"),M.debug(`Marking ${l} as external (remote: ${d})`),{external:!0}):(M.debug(`Letting bundler resolve ${l} from node_modules`),{})}catch(d){M.debug(`Failed to resolve ${f}: ${d instanceof Error?d.message:String(d)}`)}}if(r&&ye(l))return t.set(l,"external"),M.debug(`Marking ${l} as external (bare import not in import map)`),{external:!0};if(!r&&ye(l)){let d=await jn(l,e.projectRoot);if(d!==null)return t.set(l,d),M.debug(`Resolved npm transitive dependency ${l} \u2192 ${d}`),{path:d}}return{}}),c.onResolve({filter:/^jsr:/},u=>{let l=u.path,p=t.get(l);if(p!==void 0)return p==="external"?{external:!0}:{path:p};try{let f=import.meta.resolve(l);if(f.startsWith("file://")){let d=new URL(f).pathname;return t.set(l,d),M.debug(`Resolved ${l} \u2192 ${d}`),{path:d}}return t.set(l,"external"),M.debug(`Marking ${l} as external (remote JSR)`),{external:!0}}catch(f){return M.debug(`Failed to resolve ${l}: ${f instanceof Error?f.message:String(f)}`),{}}}),c.onResolve({filter:/^node:/},u=>{let l=u.path;return a[l]!==void 0?(M.debug(`Using browser shim for ${l}`),{path:`\0virtual:${l}`,namespace:"browser-shim"}):(M.warn(`Node builtin ${l} has no browser shim - marking as external`),{external:!0})}),c.onLoad({filter:/.*/,namespace:"browser-shim"},u=>{let l=u.path.replace("\0virtual:",""),p=a[l];return p!==void 0?{contents:p,loader:"js"}:{}})}}}var K=S.getLogger(["laroux-bundler","route-scanner"]),xe=null,Ne=0,Nn=/(?:^|[/\\])(?:_[^/\\]*|.*\.test\.(?:[cm]?[jt]sx?))$/,xt=["page","layout","route","proxy"],In=new Set(xt.flatMap(e=>re.map(t=>`${e}.${t}`)));function An(e){for(let t of xt)if(e.startsWith(`${t}.`)&&pe.test(e))return t;return null}function wt(){xe=null,Ne=0,K.debug("Route cache invalidated")}async function bt(e,t,n=!1){if(!n&&xe)try{if(((await o.fs.stat(e)).mtime?.getTime()??0)<=Ne)return K.debug("Using cached route scan result"),xe}catch{}K.debug(`Scanning routes in: ${e}`);let r=new Map;for await(let d of nt(e,void 0,Nn)){let m=o.path.basename(d);if(!In.has(m))continue;let h=o.path.dirname(d),y=r.get(h)??{},C=o.path.join(e,d),R=An(m);R==="page"?y.pagePath=C:R==="layout"?y.layoutPath=C:R==="route"?y.routePath=C:R==="proxy"&&(y.proxyPath=C),r.set(h,y)}let s=[],i=[],a=[],c=d=>{let m=d;for(;m&&m!==".";){let h=o.path.dirname(m);if(h===m)break;let y=r.get(h);if(y?.layoutPath)return o.path.relative(t,y.layoutPath);m=h}};for(let[d,m]of r){let h=zn(d);if(m.pagePath){let y=o.path.relative(t,m.pagePath),C=m.layoutPath?o.path.relative(t,m.layoutPath):c(d);s.push({routePath:h,componentPath:y,layoutPath:C,isApiRoute:!1}),K.debug(`Found page: ${h} -> ${y}${C?` (layout: ${C})`:""}`)}if(m.routePath){let y=o.path.relative(t,m.routePath);i.push({routePath:h,componentPath:y,isApiRoute:!0}),K.debug(`Found API route: ${h} -> ${y}`)}if(m.proxyPath){let y=o.path.relative(t,m.proxyPath);a.push({pathPrefix:h||"/",modulePath:y}),K.debug(`Found proxy: ${h||"/"} -> ${y}`)}}let u=ht(s),l=ht(i),p=Ln(a);K.debug(`Found ${u.length} page routes, ${l.length} API routes, ${p.length} proxies`);let f={routes:u,apiRoutes:l,proxies:p};try{Ne=(await o.fs.stat(e)).mtime?.getTime()??0}catch{}return xe=f,f}function zn(e){return!e||e==="."||e==="home"?"/":`/${H(e)}`}function ht(e){return e.sort((t,n)=>{let r=yt(t.routePath),s=yt(n.routePath);return r!==s?s-r:n.routePath.length-t.routePath.length})}function yt(e){let t=0,n=e.split("/").filter(Boolean);t+=n.length*10;for(let r of n)r.startsWith("[...")?t-=100:r.startsWith("[")?t-=5:t+=3;return t}function Ln(e){return e.sort((t,n)=>n.pathPrefix.length-t.pathPrefix.length)}var _=S.getLogger(["laroux-bundler","route-generator"]);async function Ct(e){let{scanResult:t,outputPath:n,projectRoot:r}=e,{routes:s}=t;_.debug(`Generating routes file: ${n}`);let i=[],a=[],c=new Map;for(let l of s){let p=`./${z(l.componentPath,"")}.js`,f=o.path.join(r,l.componentPath),d=_n(l.componentPath),m=await Wn(f,d),h;if(l.layoutPath){let C=o.path.join(r,l.layoutPath),R=Jn(l.layoutPath);h=await Un(C,R)}if(c.has(l.componentPath)||(i.push(`import { ${m} } from "${p}";`),c.set(l.componentPath,m)),l.layoutPath&&h){let C=`./${z(l.layoutPath,"")}.js`;c.has(l.layoutPath)||(i.push(`import { ${h} } from "${C}";`),c.set(l.layoutPath,h))}let y=Gn(l,m,h);a.push(y)}let u=`// AUTO-GENERATED FILE - DO NOT EDIT
|
|
32
32
|
// Generated by laroux-bundler/route-generator.ts
|
|
33
33
|
// Run build to regenerate
|
|
34
34
|
|
|
@@ -44,7 +44,7 @@ export const generatedRoutes: RouteDefinition[] = [
|
|
|
44
44
|
${a.map(l=>` ${l}`).join(`,
|
|
45
45
|
`)},
|
|
46
46
|
];
|
|
47
|
-
`;await o.fs.writeTextFile(n,u),_.debug(`Generated ${s.length} route(s)`)}async function
|
|
47
|
+
`;await o.fs.writeTextFile(n,u),_.debug(`Generated ${s.length} route(s)`)}async function vt(e,t,n){let{apiRoutes:r}=e;if(r.length===0){_.debug("No API routes found, skipping generation");return}_.debug(`Generating API routes file: ${t}`);let s=[];for(let a of r){let c=o.path.dirname(t),u=Mt(c,o.path.join(n,a.componentPath));s.push(` { path: "${a.routePath}", modulePath: "${u}" }`)}let i=`// AUTO-GENERATED FILE - DO NOT EDIT
|
|
48
48
|
// Generated by laroux-bundler/route-generator.ts
|
|
49
49
|
|
|
50
50
|
export type ApiRouteDefinition = {
|
|
@@ -59,7 +59,7 @@ export const apiRoutes: ApiRouteDefinition[] = [
|
|
|
59
59
|
${s.join(`,
|
|
60
60
|
`)},
|
|
61
61
|
];
|
|
62
|
-
`;await o.fs.writeTextFile(t,i),_.debug(`Generated ${r.length} API route(s)`)}async function
|
|
62
|
+
`;await o.fs.writeTextFile(t,i),_.debug(`Generated ${r.length} API route(s)`)}async function St(e,t,n){let{proxies:r}=e;if(r.length===0){_.debug("No proxies found, skipping generation");return}_.debug(`Generating proxy registry file: ${t}`);let s=[];for(let a of r){let c=o.path.dirname(t),u=Mt(c,o.path.join(n,a.modulePath));s.push(` { pathPrefix: "${a.pathPrefix}", modulePath: "${u}" }`)}let i=`// AUTO-GENERATED FILE - DO NOT EDIT
|
|
63
63
|
// Generated by laroux-bundler/route-generator.ts
|
|
64
64
|
|
|
65
65
|
export type ProxyDefinition = {
|
|
@@ -75,19 +75,19 @@ export const proxyRegistry: ProxyDefinition[] = [
|
|
|
75
75
|
${s.join(`,
|
|
76
76
|
`)},
|
|
77
77
|
];
|
|
78
|
-
`;await o.fs.writeTextFile(t,i),_.debug(`Generated ${r.length} proxy definition(s)`)}async function
|
|
79
|
-
`),i.unshift(p)}let a=t.platform==="browser"?"browser":"deno",c=t.sourcemap===!0?"external":t.sourcemap===!1?void 0:t.sourcemap,u={entrypoints:i,outputDir:n,format:"esm",codeSplitting:t.codeSplitting,minify:t.minify,platform:a,sourcemap:c};t.external!==void 0&&(u.external=t.external),ve.debug("Calling Deno.bundle",{entrypoints:i.slice(0,3),outputDir:n,external:u.external,platform:u.platform});let l=await Deno.bundle(u);if(ve.debug("Deno.bundle result",{success:l.success,errors:l.errors?.length??0}),!l.success){let f=(l.errors??[]).map(d=>({message:d.text??this.extractErrorMessage(d),severity:"error"}));return Q(f)}return await this.processOutput(n,t,s,r)}catch(r){return Q([{message:r instanceof Error?r.message:String(r),severity:"fatal"}])}finally{try{await o.fs.remove(n,{recursive:!0})}catch{}}}watch(t,n){let r=!0,s=Object.values(t.entrypoints).map(u=>o.path.dirname(u)),i=[...new Set(s)],a=Deno.watchFs(i,{recursive:!0});return(async()=>{for await(let u of a){if(!r)break;let l=await this.bundle(t);n(l)}})().catch(u=>{console.error("Watch loop error:",u)}),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,s){let i=this.options.entryName??"main",a=new Map,c={},u={},l=null,p=0,f=new Map,d=new Map;for(let b=0;b<s.length;b++){let w=s[b],x=r[b];if(w!==void 0&&x!==void 0){let P=o.path.basename(w).replace(/\.[^.]+$/,"");f.set(P,x),d.set(z(w,".js"),x)}}let m=o.path.join(t,"dist"),h=t;try{(await o.fs.stat(m)).isDirectory&&(h=m)}catch{}let y=[];ve.debug(`Scanning output dir: ${h}`);let C=async(b,w="")=>{for await(let x of o.fs.readDir(b)){let P=o.path.join(b,x.name),F=w?`${w}/${x.name}`:x.name;x.isDirectory?await C(P,F):x.isFile&&(x.name.endsWith(".js")||x.name.endsWith(".map"))&&y.push({name:F,path:P})}};if(await C(h),h!==t){for await(let b of o.fs.readDir(t))if(b.isFile&&(b.name.endsWith(".js")||b.name.endsWith(".map"))&&(b.name.startsWith("chunk-")||b.name.endsWith(".map"))){let w=o.path.join(t,b.name);y.some(x=>x.path===w)||y.push({name:b.name,path:w})}}ve.debug(`Found ${y.length} output files`,y.map(b=>b.name));let R=new Map;for(let b of y)if(b.name.endsWith(".map")){let w=await o.fs.readFile(b.path),x=b.name;b.name.startsWith("_client-entry")?x=`${i}.js.map`:b.name.startsWith("_build-id-entry")&&(x="build-id.js.map"),R.set(x,w)}for(let b of y){if(b.name.endsWith(".map"))continue;let w=await o.fs.readTextFile(b.path);n.basePath!==void 0&&(w=w.replace(/\/_lime\/alive/g,`${n.basePath}/_lime/alive`)),n.define!==void 0&&(w=
|
|
80
|
-
//# sourceMappingURL=${i}.js.map`));let F=new TextEncoder().encode(w),de=await this.computeHash(F),D=this.parseImports(w),Me=`${x}.map`,Y=R.get(Me);a.set(x,{path:x,code:F,map:Y,size:F.length,hash:de,isEntry:!x.startsWith("chunk-")}),p+=F.length,c[x]={bytes:F.length,inputs:{},imports:D.map(j=>({path:j,kind:"import-statement"}))}}for(let[b,w]of R)if(!a.has(b)){let x=await this.computeHash(w);a.set(b,{path:b,code:w,size:w.length,hash:x,isEntry:!1}),p+=w.length}if(n.outputDir!==void 0){await o.fs.mkdir(n.outputDir,{recursive:!0});for(let[b,w]of a){let x=o.path.join(n.outputDir,b),P=o.path.dirname(x);P!==n.outputDir&&await o.fs.mkdir(P,{recursive:!0}),await o.fs.writeFile(x,w.code)}}for(let[b,w]of Object.entries(n.entrypoints)){if(b==="client"||b==="main")continue;let x=await this.findEntrypointChunks(b,h,t,a);x.length>0&&(u[w]=x)}return Ce(a,{metafile:{inputs:{},outputs:c},entrypointManifest:u,entrypoint:l??"main.js",totalSize:p})}async findEntrypointChunks(t,n,r,s){let i=z(t,".js"),a=o.path.join(n,i),c=null;try{c=await o.fs.readTextFile(a)}catch{try{let u=o.path.join(r,"dist",i);c=await o.fs.readTextFile(u)}catch{}}return c!==null?this.extractChunksFromProxyFile(c,s):this.findChunksForComponentName(t,s)}findChunksForComponentName(t,n){let r=[],s=o.path.basename(t).replace(/\.[^.]+$/,""),i=s.charAt(0).toUpperCase()+s.slice(1).replace(/-([a-z])/g,(a,c)=>c.toUpperCase());for(let[a,c]of n){if(!a.startsWith("chunk-")||!a.endsWith(".js"))continue;let u=new TextDecoder().decode(c.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(f=>f.test(u))){r.unshift(a);let f=/from\s*["']\.?\/?([^"']*chunk-[A-Z0-9]+\.js)["']/gi,d;for(;(d=f.exec(u))!==null;){let m=o.path.basename(d[1]??"");m&&!r.includes(m)&&r.push(m)}break}}return r}extractChunksFromProxyFile(t,n){let r=[],s=/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=s.exec(t))!==null;){let u=a[1];if(u!==void 0){let l=o.path.basename(u);r.includes(l)||r.push(l)}}for(;(a=i.exec(t))!==null;){let u=a[1];if(u!==void 0){let l=o.path.basename(u);r.includes(l)||r.push(l)}}let c=t.match(/export\s*\{([\w\s,]+)\}/);if(c!==null){let p=c[1]?.match(/(\w+)(?:\s+as\s+\w+)?/)?.[1]??null;if(p!==null){let f=null;for(let[d,m]of n){if(!d.startsWith("chunk-")||!d.endsWith(".js"))continue;let h=new TextDecoder().decode(m.code);if([new RegExp(`export\\s*\\{[^}]*\\b${p}\\b[^}]*\\}`),new RegExp(`export\\s+(?:function|const|let|var|class)\\s+${p}\\b`),new RegExp(`\\b\\w+\\s+as\\s+${p}\\b`)].some(R=>R.test(h))){f=d;break}}if(f!==null){let d=r.indexOf(f);d>0?(r.splice(d,1),r.unshift(f)):d===-1&&r.unshift(f)}}}return r}async computeHash(t){let n=await crypto.subtle.digest("SHA-256",t);return be(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,s;for(;(s=r.exec(t))!==null;){let a=s[1];if(a!==void 0&&(a.startsWith("./")||a.startsWith("../")||a.startsWith("/"))){let c=a.startsWith("./")?a.slice(2):a.startsWith("../")?a:a.slice(1);n.push(c)}}let i=/import\s*\(\s*["']([^"']+)["']\s*\)/g;for(;(s=i.exec(t))!==null;){let a=s[1];if(a!==void 0&&(a.startsWith("./")||a.startsWith("../")||a.startsWith("/"))){let c=a.startsWith("./")?a.slice(2):a.startsWith("../")?a:a.slice(1);n.push(c)}}return[...new Set(n)]}};function Xn(e,t){let n=Object.keys(t);if(n.length===0)return e;n.sort((a,c)=>c.length-a.length);let r=!1;for(let a of n)if(e.includes(a)){r=!0;break}if(!r)return e;let s=n.map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),i=new RegExp(`\\b(${s.join("|")})\\b`,"g");return e.replace(i,a=>t[a]??a)}var Ae=(e={})=>new Se(e);function Zn(e){let t=Object.keys(e).sort((s,i)=>i.length-s.length);if(t.length===0)return{name:"define"};let n=t.map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),r=new RegExp(`\\b(${n.join("|")})\\b`,"g");return{name:"define",transform(s,i){if(i.includes("node_modules"))return null;let a=!1;for(let u of t)if(s.includes(u)){a=!0;break}if(!a)return null;let c=s.replace(r,u=>e[u]??u);return c===s?null:{code:c}}}}var Re=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(Zn(t.define));let s=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:s}}),a=t.sourcemap===!0?!0:t.sourcemap==="inline"?"inline":t.sourcemap==="external"?!0:void 0,c={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(l=>({name:l.name,test:l.test,priority:l.priority??0}))}}:{}},u=await i.write(c);return await i.close(),await this.processRolldownOutput(u,t)}catch(n){return Q([{message:n instanceof Error?n.message:String(n),severity:"fatal"}])}}async watch(t,n){let s=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 s.on("event",async i=>{if(i.code==="BUNDLE_END"){let a=await this.bundle(t);n(a)}else i.code==="ERROR"&&n(Q([{message:i.error?.message??"Watch error",severity:"error"}]))}),{stop:async()=>{await s.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 s=t.watch(r);return Promise.resolve(s)}};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},s={resolvers:[],loaders:[],transformers:[]},i=n.setup({onResolve:(a,c)=>{s.resolvers.push({options:a,callback:c})},onLoad:(a,c)=>{s.loaders.push({options:a,callback:c})},onTransform:(a,c)=>{s.transformers.push({options:a,callback:c})}});return i instanceof Promise&&(r.buildStart=async function(){await i}),r.resolveId=async(a,c)=>{for(let u of s.resolvers)if(u.options.filter.test(a)){let l=await u.callback({path:a,importer:c??"",namespace:u.options.namespace??"file",kind:"import-statement"});if(l?.path!==void 0||l?.external===!0)return{id:l.path??a,external:l.external}}return null},r.load=async a=>{for(let c of s.loaders)if(c.options.filter.test(a)){let u=await c.callback({path:a,namespace:c.options.namespace??"file"});if(u?.contents!==void 0)return{code:typeof u.contents=="string"?u.contents:new TextDecoder().decode(u.contents)}}return null},r.transform=async(a,c)=>{let u=a;for(let l of s.transformers)if(l.options.filter.test(c)){let p=await l.callback({path:c,code:u});p?.code!==void 0&&(u=p.code)}return u!==a?{code:u}:null},r})}async processRolldownOutput(t,n){let s=`${this.options.entryName??"main"}.js`,i=new Map,a={},c={},u=null,l=0;for(let d of t.output)if(d.type==="chunk"){let m=d.code;n.basePath!==void 0&&(m=m.replace(/\/_lime\/alive/g,`${n.basePath}/_lime/alive`));let h=new TextEncoder().encode(m),y=await this.computeHash(h),C={path:d.fileName,code:h,size:h.length,hash:y,isEntry:d.isEntry,...d.map!==void 0?{map:new TextEncoder().encode(JSON.stringify(d.map))}:{}};if(i.set(d.fileName,C),l+=h.length,d.isEntry&&(d.fileName===s||u===null)&&(u=d.fileName),d.isEntry&&d.facadeModuleId!==void 0){let R=[d.fileName];if(d.imports!==void 0)for(let E of d.imports)R.includes(E)||R.push(E);c[d.facadeModuleId]=R}a[d.fileName]={bytes:h.length,inputs:{},imports:(d.imports??[]).map(R=>({path:R,kind:"import-statement"})),...d.isEntry&&d.facadeModuleId!==void 0?{entryPoint:d.facadeModuleId}:{}}}else if(d.type==="asset"){let m=typeof d.source=="string"?new TextEncoder().encode(d.source):d.source,h=await this.computeHash(m);i.set(d.fileName,{path:d.fileName,code:m,size:m.length,hash:h}),l+=m.length}return Ce(i,{metafile:{inputs:{},outputs:a},entrypointManifest:c,entrypoint:u??s,totalSize:l})}async computeHash(t){let n=await crypto.subtle.digest("SHA-256",t);return be(new Uint8Array(n)).slice(0,16)}},ze=(e={})=>new Re(e);function Pe(e,t){if(typeof e=="object"&&e!==null&&"backend"in e){let r=e;return Pe(r.backend,r.options)}let n=e??"rolldown";switch(n){case"rolldown":return ze(t);case"deno-bundler":return Ae(t);default:throw new Error(`Unknown bundler backend: ${n}`)}}var O=S.getLogger(["laroux-bundler","bundler"]);function Qn(e,t){let n={},r=0;for(let[s,i]of e.outputs)n[s]={fileName:s,size:i.size},r+=i.size;return{entrypoint:e.entrypoint??"client.js",outputs:n,manifest:t,totalSize:e.totalSize??r}}function Yn(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],s=n[n.length-1];return{chunkCount:t.length,largestChunk:r?{name:r.fileName,size:r.size}:{name:"",size:0},smallestChunk:s?{name:s.fileName,size:s.size}:{name:"",size:0},averageChunkSize:t.length>0?e.totalSize/t.length:0}}function It(e){let t=Yn(e);O.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 At(e,t,n){O.info(`\u{1F4E6} Using bundler backend: ${n}`),O.debug(`Bundling with @eser/bundler (${n})...`),O.debug(` Entrypoints: ${e.entrypoints.length}`),O.debug(` Output: ${e.outputDir}`),O.debug(`Creating bundler: ${n}`);let r=Pe(n,{entryName:"client"}),s={};for(let l=0;l<e.entrypoints.length;l++){let p=e.entrypoints[l];if(p!==void 0)if(l===0)s.client=p;else{let f=t.find(d=>d.filePath===p);f!==void 0?s[f.relativePath]=p:s[`entry-${l}`]=p}}let i=e.sourcemap===!0||e.sourcemap==="external"||e.sourcemap==="inline",a={entrypoints:s,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},c=await r.bundle(a);if(!c.success){let l=c.errors?.map(p=>p.message).join(`
|
|
81
|
-
`)??"Unknown error";throw new Error(`Bundle failed: ${l}`)}let u={};for(let l of t){let p=c.entrypointManifest?.[l.filePath]??[];p.length>0&&(u[l.filePath]=[...p])}return O.debug(` Outputs: ${c.outputs.size} files`),O.debug(` Total size: ${((c.totalSize??0)/1024).toFixed(2)} KB`),
|
|
82
|
-
`)??"Unknown error";throw new Error(`Server bundle failed: ${c}`)}let a=new Map;for(let[c,u]of i.outputs)if(u.isEntry&&i.entrypointManifest!==void 0){for(let[l,p]of Object.entries(i.entrypointManifest))if(p.includes(c)){a.set(l,c);break}}return O.debug(` Outputs: ${i.outputs.size} files`),O.debug(` Total size: ${((i.totalSize??0)/1024).toFixed(2)} KB`),{outputMap:a,totalSize:i.totalSize??0,fileCount:i.outputs.size}}var $=S.getLogger(["laroux-bundler","chunk-manifest"]),
|
|
78
|
+
`;await o.fs.writeTextFile(t,i),_.debug(`Generated ${r.length} proxy definition(s)`)}async function Rt(e){try{let t=await o.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 s=t.matchAll(/export\s+const\s+(\w+)\s*=/g);for(let i of s)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 Wn(e,t){let n=await Rt(e);if(n.length===0)return t;let r=n.find(i=>i!=="default"&&i.endsWith("Page"));if(r)return r;let s=n.find(i=>i!=="default");return s||t}async function Un(e,t){let n=await Rt(e);if(n.length===0)return t;let r=n.find(i=>i!=="default"&&i.endsWith("Layout"));if(r)return r;let s=n.find(i=>i!=="default");return s||t}function _n(e){let t=o.path.basename(o.path.dirname(e));return`${kt(Pt(t))}Page`}function Jn(e){let t=o.path.basename(o.path.dirname(e));return`${kt(Pt(t))}Layout`}function Pt(e){return e.startsWith("[...")?e.slice(4,-1):e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e}function kt(e){return e.split(/[-_\s]+/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}function Mt(e,t){let n=H(o.path.relative(e,t));return n.startsWith(".")?n:`./${n}`}function Gn(e,t,n){let r=[`path: "${e.routePath}"`,`component: ${t}`];return n&&r.push(`layout: ${n}`),`{ ${r.join(", ")} }`}var Hn=/(?:node_modules|\/\.|^\.|\\\.)/,W=S.getLogger(["laroux-bundler","virtual-source"]),we="_bundle_src";function Vn(e,t){return o.path.relative(t,e)}async function Ft(e){let{projectRoot:t,distDir:n,srcDir:r,changedFiles:s}=e,i=Vn(r,t),a=o.path.resolve(n,we),c=o.path.resolve(a,i);W.debug(`Creating virtual source: ${a}`),W.debug(` Virtual src subdir: ${c}`);let u=await o.fs.exists(c);if(s&&s.size>0&&u)W.debug(`Incremental update: ${s.size} file(s) changed`),await Kn(s,r,c),W.debug(`Virtual source updated incrementally: ${s.size} file(s)`);else{try{await Ye(a)}catch{}await qn(r,c,t),W.debug(`Virtual source created: ${a}`)}return{virtualSrcDir:a,cleanup:async()=>{W.debug(`Cleaning up virtual source: ${a}`);try{await o.fs.remove(a,{recursive:!0}),W.debug("Virtual source cleaned up")}catch(l){W.warn("Failed to clean up virtual source:",{error:l})}}}}async function Kn(e,t,n){let r=[...re,"json","css"],s=0,i=0;for(let a of e){if(!a.startsWith(t)||!Be(a,r))continue;let c=o.path.relative(t,a),u=o.path.resolve(n,c);try{await o.fs.stat(a),await et(o.path.dirname(u)),await U(a,u,{overwrite:!0}),s++}catch{try{await o.fs.remove(u),i++}catch{}}}(s>0||i>0)&&W.debug(`Incremental update: ${s} copied, ${i} deleted`)}async function qn(e,t,n){let r=0,s=[...re,"json","css"];for await(let i of tt(e,{includeDirs:!1})){if(!Be(i.path,s))continue;let a=o.path.relative(e,i.path);if(Hn.test(a))continue;let c=o.path.resolve(t,a);await o.fs.ensureDir(o.path.dirname(c)),await U(i.path,c),r++}W.debug(`Copied ${r} source file(s) to virtual source`)}function le(e,t,n,r){let s=o.path.relative(t,e),i=r??o.path.basename(t);return o.path.resolve(n,i,s)}function Bt(e,t,n){return e.map(r=>{let s=le(r.filePath,t,n),i=`${we}/${r.relativePath}`;return{...r,filePath:s,relativePath:i}})}var J=S.getLogger(["laroux-bundler","build-cache"]),Ae=class{clientComponentCache=new Map;cssModuleCache=new Map;routeCache=null;getClientComponent(t,n){let r=this.clientComponentCache.get(t);return r&&r.mtime>=n?(J.debug(`Cache hit: client component ${t}`),r):null}setClientComponent(t,n,r,s){this.clientComponentCache.set(t,{isClient:n,exportNames:r,mtime:s})}getCssModuleResult(t,n){let r=this.cssModuleCache.get(t);return r&&r.mtime>=n?(J.debug(`Cache hit: CSS module ${t}`),r):null}setCssModuleResult(t,n,r,s){this.cssModuleCache.set(t,{code:n,exports:r,mtime:s})}getRouteCache(t){return this.routeCache&&this.routeCache.mtime>=t?(J.debug("Cache hit: route scan"),this.routeCache):null}setRouteCache(t,n,r,s){this.routeCache={routes:t,apiRoutes:n,proxies:r,mtime:s}}invalidateFile(t){this.clientComponentCache.has(t)&&(this.clientComponentCache.delete(t),J.debug(`Invalidated: client component ${t}`)),this.cssModuleCache.has(t)&&(this.cssModuleCache.delete(t),J.debug(`Invalidated: CSS module ${t}`)),(t.includes("/routes/")||t.includes("\\routes\\"))&&(this.routeCache=null,wt(),J.debug("Invalidated: route cache"))}invalidateFiles(t){for(let n of t)this.invalidateFile(n)}clear(){this.clientComponentCache.clear(),this.cssModuleCache.clear(),this.routeCache=null,J.debug("All caches cleared")}getStats(){return{clientComponents:this.clientComponentCache.size,cssModules:this.cssModuleCache.size,hasRoutes:this.routeCache!==null}}},Ie=null;function $t(){return Ie||(Ie=new Ae,J.debug("Created global build cache")),Ie}var Xn=new TextEncoder().encode("0123456789abcdef"),Et=new Uint8Array(128).fill(16);Xn.forEach((e,t)=>Et[e]=t);new TextEncoder().encode("ABCDEF").forEach((e,t)=>Et[e]=t+10);function Ot(e){return e*2}function Dt(e,t,n,r){for(;t<e.length;++t){let s=e[t];e[n++]=r[s>>4],e[n++]=r[s&15]}return n}function Tt(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 jt=new TextEncoder().encode("0123456789abcdef"),Nt=new Uint8Array(128).fill(16);jt.forEach((e,t)=>Nt[e]=t);new TextEncoder().encode("ABCDEF").forEach((e,t)=>Nt[e]=t+10);function be(e){typeof e=="string"?e=new TextEncoder().encode(e):e instanceof ArrayBuffer?e=new Uint8Array(e).slice():e=e.slice();let[t,n]=Tt(e,Ot(e.length));return Dt(t,n,0,jt),new TextDecoder().decode(t)}var Ce=(e,t)=>({success:!0,outputs:e,metafile:t?.metafile,entrypointManifest:t?.entrypointManifest,entrypoint:t?.entrypoint,totalSize:t?.totalSize}),Q=e=>({success:!1,outputs:new Map,errors:e});var ve=S.getLogger(["bundler","deno-bundler"]),Se=class{name="deno-bundler";options;constructor(t={}){this.options=t}async bundle(t){let n=await o.fs.makeTempDir({prefix:"deno-bundle-"});try{let r=Object.values(t.entrypoints),s=Object.keys(t.entrypoints),i=[...r];if(this.options.buildId!==void 0){let p=o.path.join(n,"_build-id-entry.ts");await o.fs.writeTextFile(p,`export const BUILD_ID = "${this.options.buildId}";
|
|
79
|
+
`),i.unshift(p)}let a=t.platform==="browser"?"browser":"deno",c=t.sourcemap===!0?"external":t.sourcemap===!1?void 0:t.sourcemap,u={entrypoints:i,outputDir:n,format:"esm",codeSplitting:t.codeSplitting,minify:t.minify,platform:a,sourcemap:c};t.external!==void 0&&(u.external=t.external),ve.debug("Calling Deno.bundle",{entrypoints:i.slice(0,3),outputDir:n,external:u.external,platform:u.platform});let l=await Deno.bundle(u);if(ve.debug("Deno.bundle result",{success:l.success,errors:l.errors?.length??0}),!l.success){let f=(l.errors??[]).map(d=>({message:d.text??this.extractErrorMessage(d),severity:"error"}));return Q(f)}return await this.processOutput(n,t,s,r)}catch(r){return Q([{message:r instanceof Error?r.message:String(r),severity:"fatal"}])}finally{try{await o.fs.remove(n,{recursive:!0})}catch{}}}watch(t,n){let r=!0,s=Object.values(t.entrypoints).map(u=>o.path.dirname(u)),i=[...new Set(s)],a=Deno.watchFs(i,{recursive:!0});return(async()=>{for await(let u of a){if(!r)break;let l=await this.bundle(t);n(l)}})().catch(u=>{console.error("Watch loop error:",u)}),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,s){let i=this.options.entryName??"main",a=new Map,c={},u={},l=null,p=0,f=new Map,d=new Map;for(let b=0;b<s.length;b++){let w=s[b],x=r[b];if(w!==void 0&&x!==void 0){let P=o.path.basename(w).replace(/\.[^.]+$/,"");f.set(P,x),d.set(z(w,".js"),x)}}let m=o.path.join(t,"dist"),h=t;try{(await o.fs.stat(m)).isDirectory&&(h=m)}catch{}let y=[];ve.debug(`Scanning output dir: ${h}`);let C=async(b,w="")=>{for await(let x of o.fs.readDir(b)){let P=o.path.join(b,x.name),F=w?`${w}/${x.name}`:x.name;x.isDirectory?await C(P,F):x.isFile&&(x.name.endsWith(".js")||x.name.endsWith(".map"))&&y.push({name:F,path:P})}};if(await C(h),h!==t){for await(let b of o.fs.readDir(t))if(b.isFile&&(b.name.endsWith(".js")||b.name.endsWith(".map"))&&(b.name.startsWith("chunk-")||b.name.endsWith(".map"))){let w=o.path.join(t,b.name);y.some(x=>x.path===w)||y.push({name:b.name,path:w})}}ve.debug(`Found ${y.length} output files`,y.map(b=>b.name));let R=new Map;for(let b of y)if(b.name.endsWith(".map")){let w=await o.fs.readFile(b.path),x=b.name;b.name.startsWith("_client-entry")?x=`${i}.js.map`:b.name.startsWith("_build-id-entry")&&(x="build-id.js.map"),R.set(x,w)}for(let b of y){if(b.name.endsWith(".map"))continue;let w=await o.fs.readTextFile(b.path);n.basePath!==void 0&&(w=w.replace(/\/_lime\/alive/g,`${n.basePath}/_lime/alive`)),n.define!==void 0&&(w=Zn(w,n.define)),w=w.replace(/from\s*["']\.\.\/chunk-/g,'from"./chunk-'),w=w.replace(/from\s*["']\.\.chunk-/g,'from"./chunk-'),w=w.replace(/import\s*\(["']\.\.\/chunk-/g,'import("./chunk-'),w=w.replace(/import\s*\(["']\.\.chunk-/g,'import("./chunk-');let x=b.name,P=x.startsWith("_client-entry");if(P)x=`${i}.js`,l=`${i}.js`;else if(x.startsWith("_build-id-entry"))x="build-id.js";else if(!x.startsWith("chunk-")){let j;for(let[ee,Fe]of d)if(ee.endsWith(x)){j=Fe;break}if(j===void 0){let ee=o.path.basename(x).replace(/\.js$/,"");j=f.get(ee)}j!==void 0&&(x=`${j}.js`)}P&&R.has(`${i}.js.map`)&&(w=w.replace(/\/\/# sourceMappingURL=.*$/m,`//# sourceMappingURL=${i}.js.map`),w.includes("//# sourceMappingURL=")||(w+=`
|
|
80
|
+
//# sourceMappingURL=${i}.js.map`));let F=new TextEncoder().encode(w),de=await this.computeHash(F),D=this.parseImports(w),Me=`${x}.map`,Y=R.get(Me);a.set(x,{path:x,code:F,map:Y,size:F.length,hash:de,isEntry:!x.startsWith("chunk-")}),p+=F.length,c[x]={bytes:F.length,inputs:{},imports:D.map(j=>({path:j,kind:"import-statement"}))}}for(let[b,w]of R)if(!a.has(b)){let x=await this.computeHash(w);a.set(b,{path:b,code:w,size:w.length,hash:x,isEntry:!1}),p+=w.length}if(n.outputDir!==void 0){await o.fs.mkdir(n.outputDir,{recursive:!0});for(let[b,w]of a){let x=o.path.join(n.outputDir,b),P=o.path.dirname(x);P!==n.outputDir&&await o.fs.mkdir(P,{recursive:!0}),await o.fs.writeFile(x,w.code)}}for(let[b,w]of Object.entries(n.entrypoints)){if(b==="client"||b==="main")continue;let x=await this.findEntrypointChunks(b,h,t,a);x.length>0&&(u[w]=x)}return Ce(a,{metafile:{inputs:{},outputs:c},entrypointManifest:u,entrypoint:l??"main.js",totalSize:p})}async findEntrypointChunks(t,n,r,s){let i=z(t,".js"),a=o.path.join(n,i),c=null;try{c=await o.fs.readTextFile(a)}catch{try{let u=o.path.join(r,"dist",i);c=await o.fs.readTextFile(u)}catch{}}return c!==null?this.extractChunksFromProxyFile(c,s):this.findChunksForComponentName(t,s)}findChunksForComponentName(t,n){let r=[],s=o.path.basename(t).replace(/\.[^.]+$/,""),i=s.charAt(0).toUpperCase()+s.slice(1).replace(/-([a-z])/g,(a,c)=>c.toUpperCase());for(let[a,c]of n){if(!a.startsWith("chunk-")||!a.endsWith(".js"))continue;let u=new TextDecoder().decode(c.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(f=>f.test(u))){r.unshift(a);let f=/from\s*["']\.?\/?([^"']*chunk-[A-Z0-9]+\.js)["']/gi,d;for(;(d=f.exec(u))!==null;){let m=o.path.basename(d[1]??"");m&&!r.includes(m)&&r.push(m)}break}}return r}extractChunksFromProxyFile(t,n){let r=[],s=/import(?:\{[\w\s,]{0,500}\})?\s{0,100}from\s{0,100}["']([\w./-]*chunk-[A-Z0-9]+\.js)["']/gi,i=/import\s{0,100}["']([\w./-]*chunk-[A-Z0-9]+\.js)["']/gi,a;for(;(a=s.exec(t))!==null;){let u=a[1];if(u!==void 0){let l=o.path.basename(u);r.includes(l)||r.push(l)}}for(;(a=i.exec(t))!==null;){let u=a[1];if(u!==void 0){let l=o.path.basename(u);r.includes(l)||r.push(l)}}let c=t.match(/export\s*\{([\w\s,]+)\}/);if(c!==null){let p=c[1]?.match(/(\w+)(?:\s+as\s+\w+)?/)?.[1]??null;if(p!==null){let f=null;for(let[d,m]of n){if(!d.startsWith("chunk-")||!d.endsWith(".js"))continue;let h=new TextDecoder().decode(m.code);if([new RegExp(`export\\s*\\{[^}]*\\b${p}\\b[^}]*\\}`),new RegExp(`export\\s+(?:function|const|let|var|class)\\s+${p}\\b`),new RegExp(`\\b\\w+\\s+as\\s+${p}\\b`)].some(R=>R.test(h))){f=d;break}}if(f!==null){let d=r.indexOf(f);d>0?(r.splice(d,1),r.unshift(f)):d===-1&&r.unshift(f)}}}return r}async computeHash(t){let n=await crypto.subtle.digest("SHA-256",t);return be(new Uint8Array(n)).slice(0,16)}parseImports(t){let n=[],r=/import\s{1,100}[^\n"']{1,500}\s{1,100}from\s{0,100}["']([\w./@-]+)["']/g,s;for(;(s=r.exec(t))!==null;){let a=s[1];if(a!==void 0&&(a.startsWith("./")||a.startsWith("../")||a.startsWith("/"))){let c=a.startsWith("./")?a.slice(2):a.startsWith("../")?a:a.slice(1);n.push(c)}}let i=/import\s*\(\s*["']([^"']+)["']\s*\)/g;for(;(s=i.exec(t))!==null;){let a=s[1];if(a!==void 0&&(a.startsWith("./")||a.startsWith("../")||a.startsWith("/"))){let c=a.startsWith("./")?a.slice(2):a.startsWith("../")?a:a.slice(1);n.push(c)}}return[...new Set(n)]}};function Zn(e,t){let n=Object.keys(t);if(n.length===0)return e;n.sort((a,c)=>c.length-a.length);let r=!1;for(let a of n)if(e.includes(a)){r=!0;break}if(!r)return e;let s=n.map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),i=new RegExp(`\\b(${s.join("|")})\\b`,"g");return e.replace(i,a=>t[a]??a)}var ze=(e={})=>new Se(e);function Qn(e){let t=Object.keys(e).sort((s,i)=>i.length-s.length);if(t.length===0)return{name:"define"};let n=t.map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),r=new RegExp(`\\b(${n.join("|")})\\b`,"g");return{name:"define",transform(s,i){if(i.includes("node_modules"))return null;let a=!1;for(let u of t)if(s.includes(u)){a=!0;break}if(!a)return null;let c=s.replace(r,u=>e[u]??u);return c===s?null:{code:c}}}}var Re=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(Qn(t.define));let s=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:s}}),a=t.sourcemap===!0?!0:t.sourcemap==="inline"?"inline":t.sourcemap==="external"?!0:void 0,c={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(l=>({name:l.name,test:l.test,priority:l.priority??0}))}}:{}},u=await i.write(c);return await i.close(),await this.processRolldownOutput(u,t)}catch(n){return Q([{message:n instanceof Error?n.message:String(n),severity:"fatal"}])}}async watch(t,n){let s=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 s.on("event",async i=>{if(i.code==="BUNDLE_END"){let a=await this.bundle(t);n(a)}else i.code==="ERROR"&&n(Q([{message:i.error?.message??"Watch error",severity:"error"}]))}),{stop:async()=>{await s.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 s=t.watch(r);return Promise.resolve(s)}};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},s={resolvers:[],loaders:[],transformers:[]},i=n.setup({onResolve:(a,c)=>{s.resolvers.push({options:a,callback:c})},onLoad:(a,c)=>{s.loaders.push({options:a,callback:c})},onTransform:(a,c)=>{s.transformers.push({options:a,callback:c})}});return i instanceof Promise&&(r.buildStart=async function(){await i}),r.resolveId=async(a,c)=>{for(let u of s.resolvers)if(u.options.filter.test(a)){let l=await u.callback({path:a,importer:c??"",namespace:u.options.namespace??"file",kind:"import-statement"});if(l?.path!==void 0||l?.external===!0)return{id:l.path??a,external:l.external}}return null},r.load=async a=>{for(let c of s.loaders)if(c.options.filter.test(a)){let u=await c.callback({path:a,namespace:c.options.namespace??"file"});if(u?.contents!==void 0)return{code:typeof u.contents=="string"?u.contents:new TextDecoder().decode(u.contents)}}return null},r.transform=async(a,c)=>{let u=a;for(let l of s.transformers)if(l.options.filter.test(c)){let p=await l.callback({path:c,code:u});p?.code!==void 0&&(u=p.code)}return u!==a?{code:u}:null},r})}async processRolldownOutput(t,n){let s=`${this.options.entryName??"main"}.js`,i=new Map,a={},c={},u=null,l=0;for(let d of t.output)if(d.type==="chunk"){let m=d.code;n.basePath!==void 0&&(m=m.replace(/\/_lime\/alive/g,`${n.basePath}/_lime/alive`));let h=new TextEncoder().encode(m),y=await this.computeHash(h),C={path:d.fileName,code:h,size:h.length,hash:y,isEntry:d.isEntry,...d.map!==void 0?{map:new TextEncoder().encode(JSON.stringify(d.map))}:{}};if(i.set(d.fileName,C),l+=h.length,d.isEntry&&(d.fileName===s||u===null)&&(u=d.fileName),d.isEntry&&d.facadeModuleId!==void 0){let R=[d.fileName];if(d.imports!==void 0)for(let E of d.imports)R.includes(E)||R.push(E);c[d.facadeModuleId]=R}a[d.fileName]={bytes:h.length,inputs:{},imports:(d.imports??[]).map(R=>({path:R,kind:"import-statement"})),...d.isEntry&&d.facadeModuleId!==void 0?{entryPoint:d.facadeModuleId}:{}}}else if(d.type==="asset"){let m=typeof d.source=="string"?new TextEncoder().encode(d.source):d.source,h=await this.computeHash(m);i.set(d.fileName,{path:d.fileName,code:m,size:m.length,hash:h}),l+=m.length}return Ce(i,{metafile:{inputs:{},outputs:a},entrypointManifest:c,entrypoint:u??s,totalSize:l})}async computeHash(t){let n=await crypto.subtle.digest("SHA-256",t);return be(new Uint8Array(n)).slice(0,16)}},Le=(e={})=>new Re(e);function Pe(e,t){if(typeof e=="object"&&e!==null&&"backend"in e){let r=e;return Pe(r.backend,r.options)}let n=e??"rolldown";switch(n){case"rolldown":return Le(t);case"deno-bundler":return ze(t);default:throw new Error(`Unknown bundler backend: ${n}`)}}var O=S.getLogger(["laroux-bundler","bundler"]);function Yn(e,t){let n={},r=0;for(let[s,i]of e.outputs)n[s]={fileName:s,size:i.size},r+=i.size;return{entrypoint:e.entrypoint??"client.js",outputs:n,manifest:t,totalSize:e.totalSize??r}}function er(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],s=n[n.length-1];return{chunkCount:t.length,largestChunk:r?{name:r.fileName,size:r.size}:{name:"",size:0},smallestChunk:s?{name:s.fileName,size:s.size}:{name:"",size:0},averageChunkSize:t.length>0?e.totalSize/t.length:0}}function At(e){let t=er(e);O.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 zt(e,t,n){O.info(`\u{1F4E6} Using bundler backend: ${n}`),O.debug(`Bundling with @eser/bundler (${n})...`),O.debug(` Entrypoints: ${e.entrypoints.length}`),O.debug(` Output: ${e.outputDir}`),O.debug(`Creating bundler: ${n}`);let r=Pe(n,{entryName:"client"}),s={};for(let l=0;l<e.entrypoints.length;l++){let p=e.entrypoints[l];if(p!==void 0)if(l===0)s.client=p;else{let f=t.find(d=>d.filePath===p);f!==void 0?s[f.relativePath]=p:s[`entry-${l}`]=p}}let i=e.sourcemap===!0||e.sourcemap==="external"||e.sourcemap==="inline",a={entrypoints:s,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},c=await r.bundle(a);if(!c.success){let l=c.errors?.map(p=>p.message).join(`
|
|
81
|
+
`)??"Unknown error";throw new Error(`Bundle failed: ${l}`)}let u={};for(let l of t){let p=c.entrypointManifest?.[l.filePath]??[];p.length>0&&(u[l.filePath]=[...p])}return O.debug(` Outputs: ${c.outputs.size} files`),O.debug(` Total size: ${((c.totalSize??0)/1024).toFixed(2)} KB`),Yn(c,u)}async function Lt(e,t){O.info(`\u{1F4E6} Bundling server components with ${t}`),O.debug(` Entrypoints: ${e.entrypoints.length}`),O.debug(` Output: ${e.outputDir}`),O.debug(` Externals: ${e.externals?.length??0}`);let n=Pe(t,{entryName:"server"}),r={};for(let c of e.entrypoints){let u=c.replace(e.projectRoot,"").replace(/^\//,"");u=z(u,""),r[u]=c}let s={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(s);if(!i.success){let c=i.errors?.map(u=>u.message).join(`
|
|
82
|
+
`)??"Unknown error";throw new Error(`Server bundle failed: ${c}`)}let a=new Map;for(let[c,u]of i.outputs)if(u.isEntry&&i.entrypointManifest!==void 0){for(let[l,p]of Object.entries(i.entrypointManifest))if(p.includes(c)){a.set(l,c);break}}return O.debug(` Outputs: ${i.outputs.size} files`),O.debug(` Total size: ${((i.totalSize??0)/1024).toFixed(2)} KB`),{outputMap:a,totalSize:i.totalSize??0,fileCount:i.outputs.size}}var $=S.getLogger(["laroux-bundler","chunk-manifest"]),tr="1.0";function Ut(e,t,n,r,s="info",i=!1){$.debug("\u{1F4CB} Generating chunk manifest...");let a={version:tr,buildId:e,timestamp:t,entrypoint:n.entrypoint,logLevel:s,hmrEnabled:i,chunks:{},files:{}};for(let[u,l]of Object.entries(n.outputs))a.files[l.fileName]={name:l.fileName,size:l.size,hash:sr(l.fileName)??void 0};let c=[];for(let u of r){let l=nr(u,n),[p,...f]=l;if(!p){$.warn(`No chunks found for ${u.relativePath}`);continue}let d=[p,...f];for(let y of d)a.files[y]||c.push(`${u.relativePath} references ${y}, but it's not in bundle outputs`);let m=or(u.relativePath);a.chunks[m]={main:Wt(p),deps:f.map(Wt),size:rr(l,a.files)};let h=u.exportNames[0]??"default";h!=="default"&&(a.chunks[m].exportName=h),$.debug(` ${m} \u2192 main: ${p}, deps: [${f.join(", ")}]`)}if(c.length>0){$.error("\u274C Chunk manifest validation failed!"),$.error(" Missing chunks:");for(let u of c)$.error(` - ${u}`);throw $.error(` Available files: ${Object.keys(a.files).join(", ")}`),new Error(`Chunk manifest validation failed: ${c.length} chunk(s) referenced but not found in bundle outputs`)}return $.debug("\u2705 Manifest generated"),$.debug(` Components: ${Object.keys(a.chunks).length}`),$.debug(` Chunks: ${Object.keys(a.files).length}`),$.debug(" Validation: All referenced chunks exist"),a}function nr(e,t){let n=t.manifest[e.filePath];if(!n||n.length===0)throw $.error(`\u274C No chunk mapping found for component: ${e.filePath}`),$.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 rr(e,t){return e.reduce((n,r)=>{let s=t[r];return n+(s?.size??0)},0)}function sr(e){return e.match(/-([a-f0-9]+)\./i)?.[1]??null}function Wt(e){return e.replace(/^chunk-/,"").replace(/\.js$/,"")}function or(e){let t=`${we}/`;return e.startsWith(t)?e.slice(t.length):e}async function _t(e,t){await o.fs.writeTextFile(t,JSON.stringify(e,null,2)),$.debug(`\u{1F4DD} Chunk manifest saved: ${t}`)}function Jt(e){$.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 ue={minify:!0,sourceMaps:!1,codeSplitting:!0,define:{"process.env.NODE_ENV":'"production"',"process.env.DEBUG":'"false"'}},_s={minify:!1,sourceMaps:!0,codeSplitting:!1,define:{"process.env.NODE_ENV":'"development"',"process.env.DEBUG":'"false"'}};import{transform as ar}from"lightningcss";import{Buffer as Gt}from"node:buffer";function lr(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 Ht(e){if(e==null)throw new TypeError(`Expected Uint8Array from Lightning CSS, got ${e===null?"null":"undefined"}`);if(Qe("node")&&typeof Gt<"u"&&Gt.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 Vt(e,t={}){let{filename:n="styles.css",minify:r=!1,targets:s,cssModules:i=!1,unusedSymbols:a=[]}=t,c={filename:n,code:new TextEncoder().encode(e),minify:r,targets:lr(s),cssModules:i,unusedSymbols:[...a]},u=ar(c),l;if(u.exports!==null&&u.exports!==void 0){l={};for(let[p,f]of Object.entries(u.exports))l[p]={name:f.name,composes:f.composes?.map(d=>({name:d.name,from:d.from!==void 0?String(d.from):void 0}))}}return{code:Ht(u.code),map:u.map!=null?Ht(u.map):void 0,exports:l}}function We(e,t,n={}){return Vt(e,{...n,filename:t,cssModules:!0})}async function Ue(e,t={}){let{generateDts:n=!1,minify:r=!0,targets:s,tailwind:i}=t,a=await o.fs.readTextFile(e);if(i!==void 0){let f=await i.compile(a,e);f!==null&&(a=f.code)}let c=o.path.basename(e),u=We(a,c,{minify:r,targets:s,nesting:!0}),l={};if(u.exports!==void 0)for(let[f,d]of Object.entries(u.exports))l[f]=d.name;let p=n?_e(l):void 0;return{code:u.code,exports:l,dts:p}}function _e(e){return`// This file is auto-generated by CSS modules processor
|
|
83
83
|
declare const styles: {
|
|
84
84
|
${Object.keys(e).map(r=>` readonly ${r}: string;`).join(`
|
|
85
85
|
`)}
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
export default styles;
|
|
89
|
-
`}var lr="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36";async function Vt(e,t){let n=await fetch(e);if(!n.ok)throw new Error(`Failed to download font from ${e}: ${n.status}`);let r=e.split("/"),s=r[r.length-1]??"font.woff2",i=s.includes(".")?s:`${s}.woff2`,a=o.path.join(t,i),c=await n.arrayBuffer();await o.fs.ensureDir(t),await o.fs.writeFile(a,new Uint8Array(c));let u=i.endsWith(".woff2")?"woff2":i.endsWith(".woff")?"woff":"truetype";return{url:e,localPath:a,filename:i,format:u}}async function Kt(e,t){return await Promise.all(e.map(n=>Vt(n,t)))}function qt(e){let t=[],n=/url\((["']?)([^"')]+)\1\)/g,r;for(;(r=n.exec(e))!==null;){let s=r[2];s!==void 0&&(s.includes(".woff2")||s.includes(".woff")||s.includes(".ttf"))&&t.push(s)}return t}async function Xt(e){let t=await fetch(e,{headers:{"User-Agent":lr}});if(!t.ok)throw new Error(`Failed to fetch Google Fonts CSS: ${t.status} ${t.statusText}`);return await t.text()}function Zt(e,t,n){let r=e;for(let s of t){let i=`${n}/${s.filename}`;r=r.replace(s.url,i)}return r}function Qt(e,t){return e.map(n=>`<link rel="preload" href="${`${t}/${n.filename}`}" as="font" type="font/${n.format}" crossorigin="anonymous" />`)}function _e(e){let t=e.match(/family=([^&]+)/);if(t===null)return[];let n=t[1];return n===void 0?[]:n.split("|").map(r=>{let s=r.split(":")[0]??r;return decodeURIComponent(s.replace(/\+/g," "))})}async function Je(e,t){let{outputDir:n,publicPath:r="/fonts",maxPreloadFonts:s=2}=t,i=await Xt(e),a=qt(i);if(a.length===0)return{fontFaceCSS:i,preloadHints:[],files:[],totalSize:0};let c=await Kt(a,n),u=0;for(let d of c)try{let m=await o.fs.stat(d.localPath);u+=m.size}catch{}let l=Zt(i,c,r),p=c.slice(0,Math.min(s,c.length)),f=Qt(p,r);return{fontFaceCSS:l,preloadHints:f,files:c,totalSize:u}}var q=S.getLogger(["laroux-bundler","font-optimizer"]);async function Ge(e,t,n="/fonts"){let r=_e(e);q.info(`\u{1F524} Optimizing Google Fonts: ${r.join(", ")||"unknown"}`),q.debug(` URL: ${e}`),q.debug(` Output: ${t}`),q.debug(` Public path: ${n}`);let s=await Je(e,{outputDir:t,publicPath:n,maxPreloadFonts:2});return q.info(` \u2705 Downloaded ${s.files.length} font file(s)`),q.debug(` Total size: ${(s.totalSize/1024).toFixed(2)} KB`),q.debug(` Generated ${s.preloadHints.length} preload hint(s) for critical fonts`),s}function Yt(e){return e.filter(t=>t.provider==="google")}function en(e){let t=Yt(e);if(t.length===0)return"";let r=t.map(i=>{let a=i.family.replace(/\s+/g,"+");if(i.weights&&i.weights.length>0){let c=i.styles??["normal"];if(c.includes("italic")&&c.includes("normal")){let u=[];for(let l of c){let p=l==="italic"?"1":"0";for(let f of i.weights)u.push(`${p},${f}`)}a+=`:ital,wght@${u.join(";")}`}else c.includes("italic")?a+=`:ital,wght@${i.weights.map(u=>`1,${u}`).join(";")}`:a+=`:wght@${i.weights.join(";")}`}return a}).map(i=>`family=${i}`).join("&"),s=t[0]?.display??"swap";return`https://fonts.googleapis.com/css2?${r}&display=${s}`}function He(e){return Yt(e).length===0?[]:[en(e)]}var ce=S.getLogger(["laroux-bundler","css-modules"]);async function cr(e,t={}){let{generateDTS:n=!1,projectRoot:r,minify:s=!0,plugin:i,globalCssPath:a="src/app/styles/global.css"}=t;ce.debug(`Processing CSS module: ${e}`);let c=await o.fs.readTextFile(e),u={projectRoot:r??o.process.cwd(),cssPath:e,isModule:!0},l=i??Be({globalCssPath:a}),p=c;if(l.shouldProcess?.(c,u)??!0){let d=l.preprocess?.(c,u);d!==void 0&&(p=await Promise.resolve(d))}let f=e.replace(/\.module\.css$/,".temp.module.css");await o.fs.writeTextFile(f,p);try{let d=await We(f,{generateDts:n,minify:s}),m=o.path.basename(e);return ce.debug(`Processed ${Object.keys(d.exports).length} class(es) in ${m}`),d}finally{await o.fs.remove(f).catch(()=>{})}}async function Ve(e,t={}){let{cache:n,projectRoot:r,minify:s=!0,globalCssPath:i="src/app/styles/global.css",...a}=t;ce.debug(`Processing ${e.length} CSS module(s)`);let c=Be({globalCssPath:i}),u=0,l=0;try{let p=await Promise.all(e.map(async f=>{if(n!==void 0)try{let h=(await o.fs.stat(f)).mtime?.getTime()??0,y=n.getCssModuleResult(f,h);if(y!=null)return u++,[f,{code:y.code,exports:y.exports}]}catch{}l++;let d=await cr(f,{...a,projectRoot:r,minify:s,plugin:c,globalCssPath:i});if(n!==void 0)try{let h=(await o.fs.stat(f)).mtime?.getTime()??0;n.setCssModuleResult(f,d.code,d.exports,h)}catch{}return[f,d]}));return n!==void 0&&(u>0||l>0)&&ce.debug(`CSS modules: ${u} cache hits, ${l} processed`),new Map(p)}finally{}}async function tn(e,t,n,r){let s=o.path.basename(e,".module.css"),i=e.startsWith(n)?n:r?.projectRoot??o.process.cwd(),a=o.path.relative(i,e),c=o.path.dirname(a),u=o.path.resolve(n,c);if(await o.fs.mkdir(u,{recursive:!0}),r?.skipCss!==!0){let p=o.path.resolve(u,`${s}.module.css`);await o.fs.writeTextFile(p,t.code)}let l=o.path.resolve(u,`${s}.module.css.json`);if(await o.fs.writeTextFile(l,JSON.stringify(t.exports,null,2)),t.dts!==void 0){let p=o.path.resolve(u,`${s}.module.css.d.ts`);await o.fs.writeTextFile(p,t.dts)}ce.debug(`Saved CSS module outputs to ${u}`)}var nn=S.getLogger(["laroux-bundler","server-externals"]);function dr(e,t){for(let n of t)if(e===n||e.startsWith(`${n}/`))return!0;return!1}function rn(e){let{externals:t}=e,n=t.map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),r=new RegExp(`^(${n.join("|")})($|\\/)`);return nn.debug(`Server externals plugin initialized with ${t.length} packages: ${t.join(", ")}`),{name:"server-externals",setup(s){s.onResolve({filter:r},i=>{let a=i.path;return dr(a,t)?(nn.debug(`Marking as external: ${a}`),{external:!0}):{}})}}}var g=S.getLogger(["laroux-bundler","build"]),ln="manifest.json",un="module-map.json",G="server",ke="client";function ii(e,t){let n=e.projectRoot,r=e.srcDir,s=e.distDir,i="",a=o.path.resolve(s,ln);return{config:e,projectRoot:n,srcDir:r,distDir:s,clientEntry:i,chunkManifestFile:a,bundlerBackend:t?.bundlerBackend,plugin:t?.framework??lt,cssPlugin:t?.css}}async function cn(e,t){let{srcDir:n,distDir:r,projectRoot:s}=e,i=performance.now(),a=at();g.info("\u{1F680} Starting RSC build..."),g.debug(`\u{1F194} Build ID: ${a}`);try{if(t?.cssOnly){g.debug("\u26A1 CSS-only rebuild (fast path)");let v=Date.now(),k=o.path.resolve(r,ke),T=e.cssPlugin;if(!T)return g.warn("\u26A0\uFE0F No CSS plugin provided, skipping CSS processing"),{success:!0,clientBundle:"",moduleMap:{},clientComponents:0,duration:performance.now()-i,timestamp:v};let N=await Ke(n);await sn(T,n,s,k),N.length>0&&await on(s,k,e.config,{cssModulePaths:N,cache:e.cache});let ne=performance.now()-i;return g.info(`\u26A1 CSS rebuild completed (${ne.toFixed(0)}ms)`),{success:!0,clientBundle:"",moduleMap:{},clientComponents:0,duration:ne,timestamp:v}}await Cr(r,t?.skipCss),await o.fs.ensureDir(r);let c=Date.now();g.debug("\u{1F50D} Step 3: Parallel scanning (routes, components, CSS modules)...");let u=o.path.resolve(n,"app/routes"),{plugin:l}=e,[p,f,d]=await Promise.all([wt(u,s),l.analyzeClientComponents?l.analyzeClientComponents(n,s,e.cache):Promise.resolve([]),Ke(n)]),m=o.path.resolve(r,G);await o.fs.ensureDir(m);let h=o.path.resolve(m,"_generated-routes.ts"),y=o.path.relative(s,n);if(await bt({scanResult:p,outputPath:h,projectRoot:s,srcDirName:y}),g.debug(`\u2713 Generated ${p.routes.length} page route(s) to dist/`),p.apiRoutes.length>0){let v=o.path.resolve(r,"server","api-routes.ts");await o.fs.ensureDir(o.path.dirname(v)),await Ct(p,v,s),g.debug(`\u2713 Generated ${p.apiRoutes.length} API route(s)`)}if(p.proxies.length>0){let v=o.path.resolve(r,"server","proxy-registry.ts");await o.fs.ensureDir(o.path.dirname(v)),await vt(p,v,s),g.debug(`\u2713 Generated ${p.proxies.length} proxy definition(s)`)}f.length===0&&g.warn("\u26A0\uFE0F Warning: No client components found!"),g.debug("\u{1F504} Step 4: Transforming client components...");let C=l.transformClientComponents?await l.transformClientComponents(f,o.path.resolve(r,G),s):[];l.generateTransformManifest&&await l.generateTransformManifest(C,o.path.resolve(r,"transform-manifest.json"),s),g.debug("\u270F\uFE0F Step 5: Rewriting server component imports...");let R=l.getAllComponents?await l.getAllComponents(n):[],E=new Set(f.map(v=>v.filePath)),A=R.filter(v=>!E.has(v));l.rewriteServerComponents&&await l.rewriteServerComponents(A,C,d,o.path.resolve(r,G),s),g.debug("\u{1F504} Step 5b: Transforming server actions with React symbols...");let b=o.path.resolve(r,G),w=await nt(b);if(w.length>0){let v=w.reduce((k,T)=>k+T.transformedActions.length,0);g.info(` \u2705 Transformed ${w.length} file(s) with ${v} action(s)`)}g.debug("\u{1F5FA}\uFE0F Step 6: Generating module map...");let x=o.path.resolve(r,ke);await o.fs.ensureDir(x);let P=l.createModuleMap?await l.createModuleMap(f):{};l.saveModuleMap&&await l.saveModuleMap(P,o.path.resolve(x,un)),l.createClientManifest&&await l.createClientManifest(f);let F=e.cssPlugin;!t?.skipCss&&F?(g.debug("\u{1F3A8} Step 7: Processing CSS with CSS plugin + Lightning CSS..."),await sn(F,n,s,x)):F?g.debug("\u23ED\uFE0F Skipping CSS processing (JS-only change)"):g.debug("\u23ED\uFE0F No CSS plugin provided, skipping CSS processing"),g.debug("\u{1F4C1} Step 8: Creating virtual source for bundling...");let de=await Mt({projectRoot:s,distDir:r,srcDir:n,changedFiles:t?.changedFiles}),D=de.virtualSrcDir;g.debug("\u{1F50C} Step 8b: Generating client action stubs in virtual source...");let Me=o.path.join(D,y),Y=await rt(Me,D);if(Y.length>0){let v=Y.reduce((k,T)=>k+T.exportedActions.length,0);g.info(` \u2705 Generated ${Y.length} stub file(s) with ${v} action(s)`)}let j;if(!t?.skipCss){g.debug("\u{1F3A8} Step 9: Processing CSS Modules to virtual source...");let v=d.map(N=>le(N,n,D)),k=await on(s,D,e.config,{skipCss:!0,cssModulePaths:v,cache:e.cache});j=new Map;let T=o.path.join(D,y);for(let[N,ne]of k){let pn=o.path.relative(T,N),fn=o.path.resolve(n,pn);j.set(fn,ne)}v.length>0&&(g.debug("\u270F\uFE0F Step 10: Rewriting CSS module imports in virtual source..."),l.rewriteCssModuleImports&&await l.rewriteCssModuleImports(T,v,s))}g.debug("\u{1F4E6} Step 11: Bundling client code from virtual source...");let ee=Ft(f,n,D),Fe=await gr({...e,srcDir:D},ee,a,c);if(!t?.skipCss&&d.length>0&&(g.debug(`\u{1F4CB} Step 12: Copying ${d.length} CSS Module JSON file(s) to client/...`),await an(d.map(v=>le(v,n,D)),D,x),g.debug(`\u{1F4CB} Step 13: Copying ${d.length} CSS Module JSON file(s) to server/...`),await an(d.map(v=>le(v,n,D)),D,o.path.resolve(r,G)),g.debug("\u{1F3A8} Step 14: Appending CSS modules to styles.css..."),await Sr(d,s,x,j)),g.debug("\u{1F9F9} Step 15: Cleaning up virtual source..."),await de.cleanup(),F){g.debug("\u2728 Step 16: Extracting critical CSS...");let v=await wr(F,x);v&&g.debug(` Critical: ${v.criticalPath}, Deferred: ${v.deferredPath}`),g.debug("\u{1F3A8} Step 17: Generating universal CSS...");let k=await br(F,x);k&&g.debug(` Universal: ${k}`)}g.debug("\u{1F524} Step 18: Optimizing Fonts..."),await vr(x,e.config.fonts),g.debug("\u{1F5BC}\uFE0F Step 19: Optimizing Images..."),await Rr(s,x,e.config),g.debug("\u{1F310} Step 20: Copying translation files..."),await xr(n,o.path.resolve(r,G),s);let te=o.path.resolve(r,G);if(await hr(s,te),g.info(`\u{1F4E6} Step 22: Server bundling check - components: ${A.length}`),A.length>0){g.info(`\u{1F4E6} Step 22: Bundling ${A.length} server component(s) with rolldown...`);let v=[];for(let k of A){let T=o.path.relative(s,k),N=o.path.join(te,T);await o.fs.exists(N)&&v.push(N)}if(g.info(` Found ${v.length} server entrypoints to bundle`),v.length>0){let k=e.config.serverExternals,T=rn({externals:k}),N=await zt({entrypoints:v,outputDir:te,projectRoot:te,sourcemap:!1,minify:!1,externals:k,plugins:[T]},e.bundlerBackend??"deno-bundler");g.info(` \u2705 Bundled ${N.fileCount} server file(s)`)}}g.debug("\u{1F4CB} Step 22b: Generating server actions manifest...");let qe=(await X(n,{projectRoot:s})).map(v=>z(v.relativePath,".js")),dn=o.path.resolve(te,"actions-manifest.json");await o.fs.writeTextFile(dn,JSON.stringify({actions:qe},null,2)),g.debug(`\u2713 Generated actions manifest: ${qe.length} action file(s)`),await yr(s,r);let Xe=performance.now()-i;return g.info("\u{1F4CA} Build Summary:"),g.info(` Client components: ${f.length}`),g.info(` Build time: ${Xe.toFixed(0)}ms`),{success:!0,clientBundle:Fe,moduleMap:P,clientComponents:f.length,duration:Xe,timestamp:c}}catch(c){let u=c instanceof Error?c.message:String(c),l=c instanceof Error?c.stack:null;return g.error("\u274C Build failed:"),g.error(` Error: ${u}`),l!==null&&g.error(` Stack trace:
|
|
90
|
-
${l}`),{success:!1,clientBundle:"",moduleMap:{},clientComponents:0,duration:performance.now()-i,timestamp:Date.now()}}}async function
|
|
89
|
+
`}var ur="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36";async function Kt(e,t){let n=await fetch(e);if(!n.ok)throw new Error(`Failed to download font from ${e}: ${n.status}`);let r=e.split("/"),s=r[r.length-1]??"font.woff2",i=s.includes(".")?s:`${s}.woff2`,a=o.path.join(t,i),c=await n.arrayBuffer();await o.fs.ensureDir(t),await o.fs.writeFile(a,new Uint8Array(c));let u=i.endsWith(".woff2")?"woff2":i.endsWith(".woff")?"woff":"truetype";return{url:e,localPath:a,filename:i,format:u}}async function qt(e,t){return await Promise.all(e.map(n=>Kt(n,t)))}function Xt(e){let t=[],n=/url\((["']?)([^"')]+)\1\)/g,r;for(;(r=n.exec(e))!==null;){let s=r[2];s!==void 0&&(s.includes(".woff2")||s.includes(".woff")||s.includes(".ttf"))&&t.push(s)}return t}async function Zt(e){let t=await fetch(e,{headers:{"User-Agent":ur}});if(!t.ok)throw new Error(`Failed to fetch Google Fonts CSS: ${t.status} ${t.statusText}`);return await t.text()}function Qt(e,t,n){let r=e;for(let s of t){let i=`${n}/${s.filename}`;r=r.replace(s.url,i)}return r}function Yt(e,t){return e.map(n=>`<link rel="preload" href="${`${t}/${n.filename}`}" as="font" type="font/${n.format}" crossorigin="anonymous" />`)}function Je(e){let t=e.match(/family=([^&]+)/);if(t===null)return[];let n=t[1];return n===void 0?[]:n.split("|").map(r=>{let s=r.split(":")[0]??r;return decodeURIComponent(s.replace(/\+/g," "))})}async function Ge(e,t){let{outputDir:n,publicPath:r="/fonts",maxPreloadFonts:s=2}=t,i=await Zt(e),a=Xt(i);if(a.length===0)return{fontFaceCSS:i,preloadHints:[],files:[],totalSize:0};let c=await qt(a,n),u=0;for(let d of c)try{let m=await o.fs.stat(d.localPath);u+=m.size}catch{}let l=Qt(i,c,r),p=c.slice(0,Math.min(s,c.length)),f=Yt(p,r);return{fontFaceCSS:l,preloadHints:f,files:c,totalSize:u}}var q=S.getLogger(["laroux-bundler","font-optimizer"]);async function He(e,t,n="/fonts"){let r=Je(e);q.info(`\u{1F524} Optimizing Google Fonts: ${r.join(", ")||"unknown"}`),q.debug(` URL: ${e}`),q.debug(` Output: ${t}`),q.debug(` Public path: ${n}`);let s=await Ge(e,{outputDir:t,publicPath:n,maxPreloadFonts:2});return q.info(` \u2705 Downloaded ${s.files.length} font file(s)`),q.debug(` Total size: ${(s.totalSize/1024).toFixed(2)} KB`),q.debug(` Generated ${s.preloadHints.length} preload hint(s) for critical fonts`),s}function en(e){return e.filter(t=>t.provider==="google")}function tn(e){let t=en(e);if(t.length===0)return"";let r=t.map(i=>{let a=i.family.replace(/\s+/g,"+");if(i.weights&&i.weights.length>0){let c=i.styles??["normal"];if(c.includes("italic")&&c.includes("normal")){let u=[];for(let l of c){let p=l==="italic"?"1":"0";for(let f of i.weights)u.push(`${p},${f}`)}a+=`:ital,wght@${u.join(";")}`}else c.includes("italic")?a+=`:ital,wght@${i.weights.map(u=>`1,${u}`).join(";")}`:a+=`:wght@${i.weights.join(";")}`}return a}).map(i=>`family=${i}`).join("&"),s=t[0]?.display??"swap";return`https://fonts.googleapis.com/css2?${r}&display=${s}`}function Ve(e){return en(e).length===0?[]:[tn(e)]}var ce=S.getLogger(["laroux-bundler","css-modules"]);async function dr(e,t={}){let{generateDTS:n=!1,projectRoot:r,minify:s=!0,plugin:i,globalCssPath:a="src/app/styles/global.css"}=t;ce.debug(`Processing CSS module: ${e}`);let c=await o.fs.readTextFile(e),u={projectRoot:r??o.process.cwd(),cssPath:e,isModule:!0},l=i??$e({globalCssPath:a}),p=c;if(l.shouldProcess?.(c,u)??!0){let d=l.preprocess?.(c,u);d!==void 0&&(p=await Promise.resolve(d))}let f=e.replace(/\.module\.css$/,".temp.module.css");await o.fs.writeTextFile(f,p);try{let d=await Ue(f,{generateDts:n,minify:s}),m=o.path.basename(e);return ce.debug(`Processed ${Object.keys(d.exports).length} class(es) in ${m}`),d}finally{await o.fs.remove(f).catch(()=>{})}}async function Ke(e,t={}){let{cache:n,projectRoot:r,minify:s=!0,globalCssPath:i="src/app/styles/global.css",...a}=t;ce.debug(`Processing ${e.length} CSS module(s)`);let c=$e({globalCssPath:i}),u=0,l=0;try{let p=await Promise.all(e.map(async f=>{if(n!==void 0)try{let h=(await o.fs.stat(f)).mtime?.getTime()??0,y=n.getCssModuleResult(f,h);if(y!=null)return u++,[f,{code:y.code,exports:y.exports}]}catch{}l++;let d=await dr(f,{...a,projectRoot:r,minify:s,plugin:c,globalCssPath:i});if(n!==void 0)try{let h=(await o.fs.stat(f)).mtime?.getTime()??0;n.setCssModuleResult(f,d.code,d.exports,h)}catch{}return[f,d]}));return n!==void 0&&(u>0||l>0)&&ce.debug(`CSS modules: ${u} cache hits, ${l} processed`),new Map(p)}finally{}}async function nn(e,t,n,r){let s=o.path.basename(e,".module.css"),i=e.startsWith(n)?n:r?.projectRoot??o.process.cwd(),a=o.path.relative(i,e),c=o.path.dirname(a),u=o.path.resolve(n,c);if(await o.fs.mkdir(u,{recursive:!0}),r?.skipCss!==!0){let p=o.path.resolve(u,`${s}.module.css`);await o.fs.writeTextFile(p,t.code)}let l=o.path.resolve(u,`${s}.module.css.json`);if(await o.fs.writeTextFile(l,JSON.stringify(t.exports,null,2)),t.dts!==void 0){let p=o.path.resolve(u,`${s}.module.css.d.ts`);await o.fs.writeTextFile(p,t.dts)}ce.debug(`Saved CSS module outputs to ${u}`)}var rn=S.getLogger(["laroux-bundler","server-externals"]);function pr(e,t){for(let n of t)if(e===n||e.startsWith(`${n}/`))return!0;return!1}function sn(e){let{externals:t}=e,n=t.map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),r=new RegExp(`^(${n.join("|")})($|\\/)`);return rn.debug(`Server externals plugin initialized with ${t.length} packages: ${t.join(", ")}`),{name:"server-externals",setup(s){s.onResolve({filter:r},i=>{let a=i.path;return pr(a,t)?(rn.debug(`Marking as external: ${a}`),{external:!0}):{}})}}}var g=S.getLogger(["laroux-bundler","build"]),un="manifest.json",cn="module-map.json",G="server",ke="client";function ai(e,t){let n=e.projectRoot,r=e.srcDir,s=e.distDir,i="",a=o.path.resolve(s,un);return{config:e,projectRoot:n,srcDir:r,distDir:s,clientEntry:i,chunkManifestFile:a,bundlerBackend:t?.bundlerBackend,plugin:t?.framework??ut,cssPlugin:t?.css}}async function dn(e,t){let{srcDir:n,distDir:r,projectRoot:s}=e,i=performance.now(),a=lt();g.info("\u{1F680} Starting RSC build..."),g.debug(`\u{1F194} Build ID: ${a}`);try{if(t?.cssOnly){g.debug("\u26A1 CSS-only rebuild (fast path)");let v=Date.now(),k=o.path.resolve(r,ke),T=e.cssPlugin;if(!T)return g.warn("\u26A0\uFE0F No CSS plugin provided, skipping CSS processing"),{success:!0,clientBundle:"",moduleMap:{},clientComponents:0,duration:performance.now()-i,timestamp:v};let N=await qe(n);await on(T,n,s,k),N.length>0&&await an(s,k,e.config,{cssModulePaths:N,cache:e.cache});let ne=performance.now()-i;return g.info(`\u26A1 CSS rebuild completed (${ne.toFixed(0)}ms)`),{success:!0,clientBundle:"",moduleMap:{},clientComponents:0,duration:ne,timestamp:v}}await vr(r,t?.skipCss),await o.fs.ensureDir(r);let c=Date.now();g.debug("\u{1F50D} Step 3: Parallel scanning (routes, components, CSS modules)...");let u=o.path.resolve(n,"app/routes"),{plugin:l}=e,[p,f,d]=await Promise.all([bt(u,s),l.analyzeClientComponents?l.analyzeClientComponents(n,s,e.cache):Promise.resolve([]),qe(n)]),m=o.path.resolve(r,G);await o.fs.ensureDir(m);let h=o.path.resolve(m,"_generated-routes.ts"),y=o.path.relative(s,n);if(await Ct({scanResult:p,outputPath:h,projectRoot:s,srcDirName:y}),g.debug(`\u2713 Generated ${p.routes.length} page route(s) to dist/`),p.apiRoutes.length>0){let v=o.path.resolve(r,"server","api-routes.ts");await o.fs.ensureDir(o.path.dirname(v)),await vt(p,v,s),g.debug(`\u2713 Generated ${p.apiRoutes.length} API route(s)`)}if(p.proxies.length>0){let v=o.path.resolve(r,"server","proxy-registry.ts");await o.fs.ensureDir(o.path.dirname(v)),await St(p,v,s),g.debug(`\u2713 Generated ${p.proxies.length} proxy definition(s)`)}f.length===0&&g.warn("\u26A0\uFE0F Warning: No client components found!"),g.debug("\u{1F504} Step 4: Transforming client components...");let C=l.transformClientComponents?await l.transformClientComponents(f,o.path.resolve(r,G),s):[];l.generateTransformManifest&&await l.generateTransformManifest(C,o.path.resolve(r,"transform-manifest.json"),s),g.debug("\u270F\uFE0F Step 5: Rewriting server component imports...");let R=l.getAllComponents?await l.getAllComponents(n):[],E=new Set(f.map(v=>v.filePath)),A=R.filter(v=>!E.has(v));l.rewriteServerComponents&&await l.rewriteServerComponents(A,C,d,o.path.resolve(r,G),s),g.debug("\u{1F504} Step 5b: Transforming server actions with React symbols...");let b=o.path.resolve(r,G),w=await rt(b);if(w.length>0){let v=w.reduce((k,T)=>k+T.transformedActions.length,0);g.info(` \u2705 Transformed ${w.length} file(s) with ${v} action(s)`)}g.debug("\u{1F5FA}\uFE0F Step 6: Generating module map...");let x=o.path.resolve(r,ke);await o.fs.ensureDir(x);let P=l.createModuleMap?await l.createModuleMap(f):{};l.saveModuleMap&&await l.saveModuleMap(P,o.path.resolve(x,cn)),l.createClientManifest&&await l.createClientManifest(f);let F=e.cssPlugin;!t?.skipCss&&F?(g.debug("\u{1F3A8} Step 7: Processing CSS with CSS plugin + Lightning CSS..."),await on(F,n,s,x)):F?g.debug("\u23ED\uFE0F Skipping CSS processing (JS-only change)"):g.debug("\u23ED\uFE0F No CSS plugin provided, skipping CSS processing"),g.debug("\u{1F4C1} Step 8: Creating virtual source for bundling...");let de=await Ft({projectRoot:s,distDir:r,srcDir:n,changedFiles:t?.changedFiles}),D=de.virtualSrcDir;g.debug("\u{1F50C} Step 8b: Generating client action stubs in virtual source...");let Me=o.path.join(D,y),Y=await st(Me,D);if(Y.length>0){let v=Y.reduce((k,T)=>k+T.exportedActions.length,0);g.info(` \u2705 Generated ${Y.length} stub file(s) with ${v} action(s)`)}let j;if(!t?.skipCss){g.debug("\u{1F3A8} Step 9: Processing CSS Modules to virtual source...");let v=d.map(N=>le(N,n,D)),k=await an(s,D,e.config,{skipCss:!0,cssModulePaths:v,cache:e.cache});j=new Map;let T=o.path.join(D,y);for(let[N,ne]of k){let fn=o.path.relative(T,N),gn=o.path.resolve(n,fn);j.set(gn,ne)}v.length>0&&(g.debug("\u270F\uFE0F Step 10: Rewriting CSS module imports in virtual source..."),l.rewriteCssModuleImports&&await l.rewriteCssModuleImports(T,v,s))}g.debug("\u{1F4E6} Step 11: Bundling client code from virtual source...");let ee=Bt(f,n,D),Fe=await mr({...e,srcDir:D},ee,a,c);if(!t?.skipCss&&d.length>0&&(g.debug(`\u{1F4CB} Step 12: Copying ${d.length} CSS Module JSON file(s) to client/...`),await ln(d.map(v=>le(v,n,D)),D,x),g.debug(`\u{1F4CB} Step 13: Copying ${d.length} CSS Module JSON file(s) to server/...`),await ln(d.map(v=>le(v,n,D)),D,o.path.resolve(r,G)),g.debug("\u{1F3A8} Step 14: Appending CSS modules to styles.css..."),await Rr(d,s,x,j)),g.debug("\u{1F9F9} Step 15: Cleaning up virtual source..."),await de.cleanup(),F){g.debug("\u2728 Step 16: Extracting critical CSS...");let v=await br(F,x);v&&g.debug(` Critical: ${v.criticalPath}, Deferred: ${v.deferredPath}`),g.debug("\u{1F3A8} Step 17: Generating universal CSS...");let k=await Cr(F,x);k&&g.debug(` Universal: ${k}`)}g.debug("\u{1F524} Step 18: Optimizing Fonts..."),await Sr(x,e.config.fonts),g.debug("\u{1F5BC}\uFE0F Step 19: Optimizing Images..."),await Pr(s,x,e.config),g.debug("\u{1F310} Step 20: Copying translation files..."),await wr(n,o.path.resolve(r,G),s);let te=o.path.resolve(r,G);if(await yr(s,te),g.info(`\u{1F4E6} Step 22: Server bundling check - components: ${A.length}`),A.length>0){g.info(`\u{1F4E6} Step 22: Bundling ${A.length} server component(s) with rolldown...`);let v=[];for(let k of A){let T=o.path.relative(s,k),N=o.path.join(te,T);await o.fs.exists(N)&&v.push(N)}if(g.info(` Found ${v.length} server entrypoints to bundle`),v.length>0){let k=e.config.serverExternals,T=sn({externals:k}),N=await Lt({entrypoints:v,outputDir:te,projectRoot:te,sourcemap:!1,minify:!1,externals:k,plugins:[T]},e.bundlerBackend??"deno-bundler");g.info(` \u2705 Bundled ${N.fileCount} server file(s)`)}}g.debug("\u{1F4CB} Step 22b: Generating server actions manifest...");let Xe=(await X(n,{projectRoot:s})).map(v=>z(v.relativePath,".js")),pn=o.path.resolve(te,"actions-manifest.json");await o.fs.writeTextFile(pn,JSON.stringify({actions:Xe},null,2)),g.debug(`\u2713 Generated actions manifest: ${Xe.length} action file(s)`),await xr(s,r);let Ze=performance.now()-i;return g.info("\u{1F4CA} Build Summary:"),g.info(` Client components: ${f.length}`),g.info(` Build time: ${Ze.toFixed(0)}ms`),{success:!0,clientBundle:Fe,moduleMap:P,clientComponents:f.length,duration:Ze,timestamp:c}}catch(c){let u=c instanceof Error?c.message:String(c),l=c instanceof Error?c.stack:null;return g.error("\u274C Build failed:"),g.error(` Error: ${u}`),l!==null&&g.error(` Stack trace:
|
|
90
|
+
${l}`),{success:!1,clientBundle:"",moduleMap:{},clientComponents:0,duration:performance.now()-i,timestamp:Date.now()}}}async function li(e){return await fr(e)?(g.info("\u{1F504} Build needed, running build..."),await dn(e)):(g.info("\u2705 Build is up-to-date, skipping..."),await gr(e))}async function fr(e){let{distDir:t,chunkManifestFile:n,srcDir:r,clientEntry:s,projectRoot:i}=e;if(!await o.fs.exists(t)||!await o.fs.exists(n))return!0;let a=await o.fs.readTextFile(n),u=JSON.parse(a).timestamp,l=[];for await(let p of o.fs.readDir(r))p.isFile&&pe.test(p.name)&&l.push(o.path.resolve(r,p.name));l.push(s);for(let p of l)try{let f=await o.fs.stat(p);if(f.mtime&&f.mtime.getTime()>u)return g.debug(` Changed: ${o.path.relative(i,p)}`),!0}catch{}return!1}async function gr(e){let{chunkManifestFile:t,distDir:n}=e,r=await o.fs.readTextFile(t),s=JSON.parse(r),i=await o.fs.readTextFile(o.path.resolve(n,cn)),a=JSON.parse(i);return{success:!0,clientBundle:o.path.resolve(n,"client.js"),moduleMap:a,clientComponents:Object.keys(a).length,duration:0,timestamp:s.timestamp}}function ui(e,t){let{srcDir:n,distDir:r,projectRoot:s}=e;g.debug("\u{1F441}\uFE0F Watch mode enabled, monitoring for changes...");let i=$t(),a={...e,cache:i},c=o.path.relative(s,r),u=[n],l=o.fs.watch(u),p=!1,f=!1,d=new Set,m=null,h=50;async function y(){if(p){f=!0;return}p=!0;do{f=!1;try{let C=Array.from(d);i.invalidateFiles(C.map(P=>o.path.resolve(s,P)));let R=C.some(P=>P.endsWith(".css")),E=C.some(P=>P.match(/\.(tsx?|jsx?)$/)),A=R&&!E,b=!R&&E,w=new Set(C.map(P=>o.path.resolve(s,P))),x=await dn(a,{skipCss:b,cssOnly:A,changedFiles:w});x.changedFiles=Array.from(d),g.debug(`\u2705 Rebuild complete (${x.duration.toFixed(0)}ms)`),t(x),d.clear()}catch(C){g.error("\u274C Rebuild failed:",{error:C})}}while(f);p=!1}return(async()=>{for await(let C of l)if(C.kind==="modify"||C.kind==="create"||C.kind==="remove"){let R=C.paths[0];if(!R)continue;let E=o.path.relative(s,R);if(!E.match(/\.(tsx?|jsx?|css)$/))continue;let A=H(E),b=H(c);if(A.startsWith(`${b}/`)||E.includes(".temp."))continue;g.debug(`\u{1F504} File changed: ${E}`),d.add(E),m!==null&&clearTimeout(m),m=setTimeout(()=>{m=null,y()},h)}})(),l}async function mr(e,t,n,r){let{config:s,projectRoot:i,distDir:a}=e,{plugin:c}=e;if(!c.createClientEntry)throw new Error("Framework plugin must implement createClientEntry");let u=await c.createClientEntry(t,i,a);try{let l=t.map(C=>C.filePath),p=o.path.resolve(a,ke),f=mt({projectRoot:i,browserShims:s.browserShims,autoMarkExternal:!1}),d={...ue.define};if(!e.bundlerBackend)throw new Error("Bundler backend is required for client bundling");let m=await zt({entrypoints:[u,...l],outputDir:p,projectRoot:i,minify:ue.minify,splitting:ue.codeSplitting,platform:"browser",sourcemap:ue.sourceMaps,plugins:[f],define:d},t,e.bundlerBackend),h=Ut(n,r,m,t,s.logLevel,!1),y=o.path.resolve(p,un);await _t(h,y);try{await o.fs.remove(u)}catch{}return At(m),Jt(h),o.path.resolve(a,m.entrypoint)}catch(l){try{await o.fs.remove(u)}catch{}throw l}}function hr(e,t){for(let[n,r]of Object.entries(e))typeof r=="string"&&(r.startsWith("./")||r.startsWith("../"))&&(e[n]=o.path.join(t,r))}async function yr(e,t){let n=await fe({baseDir:e});if(n===void 0){g.debug("No config files found to copy");return}let r=o.path.relative(t,e),s=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&&hr(a.imports,r);let c=o.path.join(t,i.fileType);await o.fs.writeTextFile(c,JSON.stringify(a,null,2)),s++}catch(a){g.debug(`Failed to copy ${i.fileType}: ${a instanceof Error?a.message:String(a)}`)}if(s>0){let i=s===1?"config file":"config files";g.info(` \u{1F4CB} Copied ${s} ${i} to dist/server for import resolution`)}}async function xr(e,t){let n=o.path.resolve(e,"public");if(await o.fs.exists(n))for await(let r of o.fs.readDir(n)){let s=o.path.resolve(n,r.name),i=o.path.resolve(t,r.name);await U(s,i,{overwrite:!0})}}async function wr(e,t,n){let r=0,s=o.path.relative(n,e),i=o.path.resolve(e,"app/messages"),a=o.path.resolve(t,s,"app/messages");if(await o.fs.exists(i)){await o.fs.ensureDir(a);for await(let l of o.fs.readDir(i))if(l.isFile&&l.name.endsWith(".json")){let p=o.path.resolve(i,l.name),f=o.path.resolve(a,l.name);await U(p,f,{overwrite:!0}),r++}}let c=o.path.resolve(e,"lib/i18n/messages"),u=o.path.resolve(t,s,"lib/i18n/messages");if(await o.fs.exists(c)){await o.fs.ensureDir(u);for await(let l of o.fs.readDir(c))if(l.isFile&&l.name.endsWith(".json")){let p=o.path.resolve(c,l.name),f=o.path.resolve(u,l.name);await U(p,f,{overwrite:!0}),r++}}r>0?g.debug(`\u2713 Copied ${r} translation file(s)`):g.debug("No messages directories found, skipping translation files")}async function on(e,t,n,r){let s=o.path.resolve(t,"app/styles/global.css"),i=o.path.resolve(r,"styles.css");if(!await o.fs.exists(s)){g.debug("No CSS source file found, skipping CSS processing");return}try{await Te({input:s,output:i,minify:!0,projectRoot:n,plugin:e}),g.debug("\u2713 CSS processed")}catch(a){throw g.error("CSS processing failed:",{error:a}),a}}async function br(e,t){if(!e.extractCriticalCss)return g.debug("CSS plugin doesn't support critical CSS extraction, skipping"),null;let n=o.path.resolve(t,"styles.css");if(!await o.fs.exists(n))return g.debug("No styles.css found, skipping critical CSS extraction"),null;try{let r=await o.fs.readTextFile(n),i=e.extractCriticalCss(r,`
|
|
91
91
|
<!DOCTYPE html>
|
|
92
92
|
<html lang="en">
|
|
93
93
|
<head></head>
|
|
@@ -122,6 +122,6 @@ ${l}`),{success:!1,clientBundle:"",moduleMap:{},clientComponents:0,duration:perf
|
|
|
122
122
|
</div>
|
|
123
123
|
</body>
|
|
124
124
|
</html>
|
|
125
|
-
`,{forceInclude:[/^\.flex/,/^\.grid/,/^\.block/,/^\.inline/,/^\.items-/,/^\.justify-/,/^\.gap-/,/^\.space-/,/^\.min-h-/,/^\.max-w-/,/^\.w-/,/^\.h-/,/^\.mx-/,/^\.my-/,/^\.px-/,/^\.py-/,/^\.p-/,/^\.m-/,/^\.mt-/,/^\.mb-/,/^\.ml-/,/^\.mr-/,/^\.pt-/,/^\.pb-/,/^\.pl-/,/^\.pr-/,/^\.sm:/,/^\.md:/,/^\.lg:/,/^\.xl:/,/^\.2xl:/,/^\.bg-neutral-/,/^\.bg-surface/,/^\.bg-primary-/,/^\.text-neutral-/,/^\.text-primary-/,/^\.text-white/,/^\.border/,/^\.rounded/,/^\.text-sm/,/^\.text-lg/,/^\.text-xl/,/^\.text-2xl/,/^\.text-3xl/,/^\.text-4xl/,/^\.text-5xl/,/^\.font-/,/^\.leading-/,/^\.overflow-/,/^\.visible/,/^\.invisible/,/^\.hidden/,/^\.relative/,/^\.absolute/,/^\.fixed/,/^\.sticky/,/^\.shadow/,/^html/,/^body/,/^#root/,/^\*/]}),a=o.path.resolve(t,"styles.critical.css"),c=o.path.resolve(t,"styles.deferred.css");await o.fs.writeTextFile(a,i.critical),await o.fs.writeTextFile(c,i.deferred);let u=i.stats;return u?g.debug(`\u2713 Critical CSS extracted: ${u.criticalSize} bytes critical, ${u.deferredSize} bytes deferred`):g.debug("\u2713 Critical CSS extracted"),{criticalPath:a,deferredPath:c}}catch(r){return g.error("Critical CSS extraction failed:",{error:r}),null}}async function
|
|
125
|
+
`,{forceInclude:[/^\.flex/,/^\.grid/,/^\.block/,/^\.inline/,/^\.items-/,/^\.justify-/,/^\.gap-/,/^\.space-/,/^\.min-h-/,/^\.max-w-/,/^\.w-/,/^\.h-/,/^\.mx-/,/^\.my-/,/^\.px-/,/^\.py-/,/^\.p-/,/^\.m-/,/^\.mt-/,/^\.mb-/,/^\.ml-/,/^\.mr-/,/^\.pt-/,/^\.pb-/,/^\.pl-/,/^\.pr-/,/^\.sm:/,/^\.md:/,/^\.lg:/,/^\.xl:/,/^\.2xl:/,/^\.bg-neutral-/,/^\.bg-surface/,/^\.bg-primary-/,/^\.text-neutral-/,/^\.text-primary-/,/^\.text-white/,/^\.border/,/^\.rounded/,/^\.text-sm/,/^\.text-lg/,/^\.text-xl/,/^\.text-2xl/,/^\.text-3xl/,/^\.text-4xl/,/^\.text-5xl/,/^\.font-/,/^\.leading-/,/^\.overflow-/,/^\.visible/,/^\.invisible/,/^\.hidden/,/^\.relative/,/^\.absolute/,/^\.fixed/,/^\.sticky/,/^\.shadow/,/^html/,/^body/,/^#root/,/^\*/]}),a=o.path.resolve(t,"styles.critical.css"),c=o.path.resolve(t,"styles.deferred.css");await o.fs.writeTextFile(a,i.critical),await o.fs.writeTextFile(c,i.deferred);let u=i.stats;return u?g.debug(`\u2713 Critical CSS extracted: ${u.criticalSize} bytes critical, ${u.deferredSize} bytes deferred`):g.debug("\u2713 Critical CSS extracted"),{criticalPath:a,deferredPath:c}}catch(r){return g.error("Critical CSS extraction failed:",{error:r}),null}}async function Cr(e,t){if(!e.extractUniversalCss)return g.debug("CSS plugin doesn't support universal CSS extraction, skipping"),null;let n=o.path.resolve(t,"styles.css");if(!await o.fs.exists(n))return g.debug("No styles.css found, skipping universal CSS generation"),null;try{let r=await o.fs.readTextFile(n),s=e.extractUniversalCss(r),i=o.path.resolve(t,"styles.universal.css");return await o.fs.writeTextFile(i,s.css),g.debug(`\u2713 Universal CSS generated: ${s.css.length} bytes`),i}catch(r){return g.error("Universal CSS generation failed:",{error:r}),null}}async function vr(e,t){if(await o.fs.exists(e))if(t){g.debug("\u{1F9F9} Cleaning build directory (preserving CSS)");let n=o.path.resolve(e,G);await o.fs.exists(n)&&await o.fs.remove(n,{recursive:!0});let r=o.path.resolve(e,ke);if(await o.fs.exists(r))for await(let s of o.fs.readDir(r)){if(s.name.endsWith(".css")||s.name==="fonts"||s.name==="fonts.css"||s.name==="font-preloads.json")continue;let i=o.path.resolve(r,s.name);await o.fs.remove(i,{recursive:!0})}}else await o.fs.remove(e,{recursive:!0}),g.debug("\u{1F9F9} Cleaned build directory")}async function Sr(e,t){let r=Ve(t)[0];if(!r){g.debug("\u2713 No fonts configured, skipping font optimization");return}let s=o.path.resolve(e,"fonts"),i="/fonts";try{let a=await He(r,s,i),c=o.path.resolve(e,"fonts.css");await o.fs.writeTextFile(c,a.fontFaceCSS);let u=o.path.resolve(e,"font-preloads.json");await o.fs.writeTextFile(u,JSON.stringify(a.preloadHints,null,2)),g.debug(`\u2713 Fonts optimized: ${a.files.length} file(s), ${(a.totalSize/1024).toFixed(2)} KB`)}catch(a){g.error("Font optimization failed:",{error:a}),g.warn("Continuing build without font optimization")}}async function qe(e){let t=[];async function n(r){for await(let s of o.fs.readDir(r)){let i=o.path.resolve(r,s.name);s.isDirectory?await n(i):s.isFile&&s.name.endsWith(".module.css")&&t.push(i)}}return await n(e),t}async function an(e,t,n,r){let s=r?.cssModulePaths??await qe(n.srcDir);if(s.length===0)return g.debug("No CSS modules found, skipping CSS module processing"),new Map;g.debug(`Found ${s.length} CSS module(s)`);try{let i=await Ke(s,{generateDTS:n.cssModuleTypes,projectRoot:e,cache:r?.cache});for(let[a,c]of i)await nn(a,c,t,{skipCss:r?.skipCss,projectRoot:e});return g.debug(`\u2713 Processed ${s.length} CSS module(s)${n.cssModuleTypes?" with TypeScript definitions":""}`),i}catch(i){throw g.error("CSS module processing failed:",{error:i}),i}}async function ln(e,t,n){let r=0;for(let s of e){let i=o.path.relative(t,s),a=o.path.basename(s)+".json",c=o.path.join(t,o.path.dirname(i),a),u=o.path.join(n,o.path.dirname(i),a);await o.fs.ensureDir(o.path.dirname(u));try{await U(c,u,{overwrite:!0}),r++}catch(l){g.warn(` \u26A0 Failed to copy JSON for ${o.path.relative(t,s)}:`,{error:l})}}r>0&&g.debug(`\u2713 Copied ${r} CSS module JSON file(s)`)}async function Rr(e,t,n,r){if(e.length===0)return;let s;r?s=r:s=await Ke(e,{generateDTS:!1,projectRoot:t});let i=[];for(let[,a]of s)i.push(a.code);if(i.length>0){let a=o.path.resolve(n,"styles.css"),c="";try{c=await o.fs.readTextFile(a)}catch{}c=c.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"");let u=i.map(p=>p.replace(/\x1B\[[0-9;]*[a-zA-Z]/g,"")),l=c+`
|
|
126
126
|
`+u.join(`
|
|
127
|
-
`);await o.fs.writeTextFile(a,l),g.debug(`\u2713 Appended ${i.length} CSS module(s) to styles.css`)}}async function
|
|
127
|
+
`);await o.fs.writeTextFile(a,l),g.debug(`\u2713 Appended ${i.length} CSS module(s) to styles.css`)}}async function Pr(e,t,n){let{optimizeImages:r,scanImages:s}=await import("./mod-TSU5UWXA.js"),i=o.path.resolve(e,"public"),a=o.path.resolve(i,"images");if(!await o.fs.exists(a)){g.debug("\u2713 No images directory found, skipping image optimization");return}if((await s(a)).length===0){g.debug("\u2713 No images found, skipping image optimization");return}try{let u=o.path.resolve(t,"images"),l=await r(a,u,"/images",{formats:n.images.formats,widths:n.images.widths,quality:n.images.quality,generateBlurPlaceholder:n.images.placeholder==="blur"}),p=Object.keys(l.images).length;p>0&&g.debug(`\u2713 Optimized ${p} image(s)`)}catch(u){g.error("Image optimization failed:",{error:u}),g.warn("Continuing build without image optimization")}}export{Pe as a,_s as b,ai as c,dn as d,li as e,ui as f};
|