eser 4.1.23 → 4.1.27
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-QDUA5G5K.js +9 -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-O2MNBI7V.js → chunk-EBYJBBYV.js} +1 -1
- 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-LOFP256P.js +1 -0
- 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/chunk-ZO7RUTSQ.js +60 -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-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-WX4P6LGJ.js +1 -0
- 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-3BKLVESS.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-JWO27FMA.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-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-RUZDG5PT.js +0 -60
- 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-FKPTF5D5.js +0 -1
- package/chunks/mod-GZ6BSK2P.js +0 -1
- package/chunks/mod-QODEWK3G.js +0 -9
- package/chunks/mod-S33TIBIC.js +0 -1
- 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-DTVAUBIX.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
|
@@ -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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as c}from"./chunk-
|
|
1
|
+
import{b as c}from"./chunk-2J2PXBOC.js";import{t as u}from"./chunk-YXSB6RET.js";var n=e=>{let a=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,".*").replace(/\*/g,"[^/]*");return new RegExp(`^${a}$`)};async function*f(e,a,s){let o=u.fs.walk(e,{includeDirs:!1,includeFiles:!0,exts:c,skip:[s]});for await(let r of o){let t=u.path.relative(e,r.path);a!==void 0&&!n(a).test(t)||(yield t)}}var F=new RegExp("[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]"),A=new RegExp("[\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65]");export{f as a};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as E,b as A,c as I}from"./chunk-
|
|
2
|
-
`).length,p=null,
|
|
3
|
-
`)[0]?.trim();return(!t||t.startsWith("@"))&&e.push("empty-description"),i&&!$.test(s)&&e.push("missing-example"),e},F=async(s={})=>{let{root:n=".",requireExamples:i=!1}=s,e=await E(n),t=[],o=0,c=0;for(let p of e){let y=await I(p.path);for(let
|
|
1
|
+
import{a as E,b as A,c as I}from"./chunk-AKJB4CER.js";import{a as w}from"./chunk-6U2VEZEM.js";import{a as v}from"./chunk-KAEAT6A4.js";import{f as D}from"./chunk-NUSNMQPL.js";import{b as l,e as g,f as k,g as C,h}from"./chunk-PLJNPQFC.js";import{g as a}from"./chunk-DQAEQEXD.js";import{v as b}from"./chunk-YXSB6RET.js";var u=v(),O=/\/\*\*\s*([\s\S]*?)\s*\*\//g,R=/export\s+(const|function|class|type|interface)\s+(\w+)/g,$=/@example/,S=s=>{let n=[],i;for(R.lastIndex=0;(i=R.exec(s))!==null;){let e=i.index,t=i[2];if(t===void 0)continue;let c=s.substring(0,e).split(`
|
|
2
|
+
`).length,p=null,m=[...s.substring(0,e).matchAll(O)];if(m.length>0){let r=m[m.length-1];if(r!==void 0){let d=(r.index??0)+r[0].length,f=s.substring(d,e);/^\s*$/.test(f)&&(p=r[1]??null)}}n.push({jsdoc:p,symbolName:t,line:c})}return n},_=(s,n,i)=>{let e=[];if(s===null)return e.push("missing-description"),e;let t=s.split(`
|
|
3
|
+
`)[0]?.trim();return(!t||t.startsWith("@"))&&e.push("empty-description"),i&&!$.test(s)&&e.push("missing-example"),e},F=async(s={})=>{let{root:n=".",requireExamples:i=!1}=s,e=await E(n),t=[],o=0,c=0;for(let p of e){let y=await I(p.path);for(let m of y){let r=A(m,p.path),d;try{d=await b.runtime.fs.readTextFile(r)}catch{continue}o++;let f=S(d);for(let{jsdoc:T,symbolName:x,line:P}of f){c++;let M=_(T,x,i);for(let N of M)t.push({file:r,symbol:x,issue:N,line:P})}}}return{isValid:t.length===0,issues:t,filesChecked:o,symbolsChecked:c}},J=s=>{switch(s){case"missing-description":return"Missing JSDoc documentation";case"missing-param":return"Missing @param documentation";case"missing-returns":return"Missing @returns documentation";case"missing-example":return"Missing @example";case"empty-description":return"Empty description"}},j=s=>D.fromPromise(()=>F(s)),V=s=>a.ok({root:"."}),q=s=>{if(a.isFail(s))return u.writeln(g("\u2717"),l(" "+String(s.error))),a.fail({exitCode:1});let{value:n}=s;if(u.writeln(h("\u2139"),l(` Checked ${n.filesChecked} files, ${n.symbolsChecked} symbols.`)),!n.isValid){u.writeln(g("\u2717"),l(` Found ${n.issues.length} documentation issues:`));let i=new Map;for(let e of n.issues){let t=i.get(e.file)??[];t.push(e),i.set(e.file,t)}for(let[e,t]of i){u.writeln(C("\u26A0"),l(" "+e));for(let o of t){let c=o.line!==void 0?`:${o.line}`:"";u.writeln(h("\u2139"),l(` ${o.symbol}${c}: ${J(o.issue)}`))}}return a.fail({exitCode:1})}return u.writeln(k("\u2713"),l(" All documentation is valid.")),a.ok(void 0)},B=w.createTrigger({handler:j,adaptInput:V,adaptOutput:q}),Q=async s=>await B({command:"validate-docs",args:[],flags:{}});export{F as a,j as b,B as c,Q as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-SBOTNOWZ.js";import{v as a}from"./chunk-YXSB6RET.js";var s=i({name:"validate-symlinks",description:"Detect broken symlinks",canFix:!1,stacks:[],defaults:{},async checkAll(n){let o=[];for(let t of n)if(t.isSymlink)try{await a.runtime.fs.stat(t.path)}catch{o.push({path:t.path,message:"broken symlink \u2014 target not found"})}return o}}),l=s.run,c=s.validator,m=s.main;export{s as a,l as b,c,m as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as c}from"./chunk-YXSB6RET.js";var h=["registry/v1"],w=["file","folder"],m=["local","github"],R=r=>r==="project"||r==="structure"||r==="utility",$=r=>{if(typeof r!="object"||r===null)return!1;let e=r;return!(typeof e.source!="string"||typeof e.target!="string"||e.kind!==void 0&&!w.includes(e.kind)||e.provider!==void 0&&!m.includes(e.provider))},b=r=>{if(typeof r!="object"||r===null)return!1;let e=r;return!(e.go!==void 0&&!Array.isArray(e.go)||e.jsr!==void 0&&!Array.isArray(e.jsr)||e.npm!==void 0&&!Array.isArray(e.npm))},E=r=>{if(typeof r!="object"||r===null)return!1;let e=r;return!(typeof e.name!="string"||e.name===""||typeof e.description!="string"||e.default!==void 0&&typeof e.default!="string"||e.prompt!==void 0&&typeof e.prompt!="string")},d=r=>{if(typeof r!="object"||r===null)return!1;let e=r;if(typeof e.name!="string"||e.name===""||typeof e.description!="string"||typeof e.language!="string"||!R(e.scale)||!Array.isArray(e.files)||e.files.length===0)return!1;for(let t of e.files)if(!$(t))return!1;if(e.dependencies!==void 0&&!b(e.dependencies)||e.tags!==void 0&&!Array.isArray(e.tags))return!1;if(e.requires!==void 0){if(!Array.isArray(e.requires))return!1;for(let t of e.requires)if(typeof t!="string")return!1}if(e.variables!==void 0){if(!Array.isArray(e.variables))return!1;for(let t of e.variables)if(!E(t))return!1}if(e.postInstall!==void 0){if(!Array.isArray(e.postInstall))return!1;for(let t of e.postInstall)if(typeof t!="string")return!1}return!0},p=r=>{if(typeof r!="object"||r===null)throw new Error("Registry manifest must be a JSON object");let e=r;if(e.$schema!==void 0){let i=String(e.$schema);h.some(s=>i.includes(s))||console.warn(`Warning: Registry uses unknown schema "${i}". This CLI supports v1.`)}if(typeof e.name!="string"||e.name==="")throw new Error("Registry manifest requires a non-empty 'name' field");if(typeof e.description!="string")throw new Error("Registry manifest requires a 'description' field");if(typeof e.author!="string")throw new Error("Registry manifest requires an 'author' field");if(typeof e.registryUrl!="string"||e.registryUrl==="")throw new Error("Registry manifest requires a non-empty 'registryUrl' field");if(!Array.isArray(e.recipes))throw new Error("Registry manifest requires a 'recipes' array");for(let i of e.recipes)if(!d(i)){let o=typeof i=="object"&&i!==null?i.name??"<unknown>":"<invalid>";throw new Error(`Invalid recipe definition: '${o}'`)}let t=e.recipes,n=new Set;for(let i of t){if(n.has(i.name))throw new Error(`Duplicate recipe name '${i.name}' in registry`);n.add(i.name)}return r},u=r=>{if(!d(r))throw new Error("Invalid recipe definition");return r},y=(r,e)=>{let t=r.replace(/\/{1,20}$/,""),n=e.replace(/^\/{1,20}/,"");return`${t}/${n}`};var S=3e4,k="https://raw.githubusercontent.com/eser/stack/main/etc/registry/eser-registry.json",A="etc/registry/eser-registry.json",l=async r=>await globalThis.fetch(r,{signal:AbortSignal.timeout(S)}),P=async()=>{let r=c.process.cwd();for(let e=0;e<10;e++){let t=`${r}/${A}`;try{return await c.fs.stat(t),t}catch{let n=r.replace(/\/[^/]+$/,"");if(n===r)break;r=n}}},U=async(r,e)=>{let t=r??k;if(e?.local===!0&&r===void 0){let s=await P();s!==void 0&&(t=s,e?.verbose===!0&&console.log(`Using local registry: ${s}`))}let n=t.startsWith("http://")||t.startsWith("https://");e?.verbose===!0&&console.log(`Fetching registry from: ${t}`);let i;if(n){let s=await l(t);if(!s.ok)throw new Error(`Could not reach registry at ${t}. HTTP ${s.status}`);i=await s.text()}else try{i=await c.fs.readTextFile(t)}catch{throw new Error(`Could not read registry file at ${t}`)}let o;try{o=JSON.parse(i)}catch{throw new Error(`Registry at ${t} is not valid JSON`)}return p(o)},_=async(r,e)=>{let t=y(r,e),n=await l(t);if(!n.ok)throw new Error(`Could not fetch recipe file at ${t}. HTTP ${n.status}`);return await n.text()},T=r=>{let e=r.match(/^https:\/\/raw\.githubusercontent\.com\/([^/]+)\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(e!==null)return{owner:e[1],repo:e[2],ref:e[3],basePath:e[4]??""}},L=async(r,e)=>{let t=T(r);if(t===void 0)throw new Error(`Cannot fetch folder: registry URL '${r}' is not a GitHub raw URL`);let n=t.basePath?`${t.basePath}/${e}`.replace(/\/+/g,"/"):e,i=`https://api.github.com/repos/${t.owner}/${t.repo}/contents/${n}?ref=${t.ref}`,o=await l(i);if(!o.ok)throw new Error(`Could not list folder '${n}' from ${t.owner}/${t.repo}. HTTP ${o.status}`);let s=await o.json();if(!Array.isArray(s))throw new Error(`Expected directory listing for '${n}', got a file instead`);let g=s.filter(a=>a.type==="file").map(async a=>{if(a.download_url===null)throw new Error(`File '${a.path}' has no download URL (may be too large)`);let f=await l(a.download_url);if(!f.ok)throw new Error(`Could not fetch file '${a.path}'. HTTP ${f.status}`);return{path:a.path.startsWith(n)?a.path.slice(n.length).replace(/^\//,""):a.path,content:await f.text()}});return await Promise.all(g)},O=async(r,e,t="main",n="recipe.json")=>{let i=`https://raw.githubusercontent.com/${r}/${e}/${t}/${n}`,o=await l(i);if(!o.ok)throw new Error(`Could not fetch recipe from ${r}/${e}@${t}/${n}. HTTP ${o.status}`);let s;try{s=JSON.parse(await o.text())}catch{throw new Error(`Recipe file at ${r}/${e}@${t}/${n} is not valid JSON`)}return u(s)};export{S as a,k as b,A as c,l as d,P as e,U as f,_ as g,T as h,L as i,O as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=(t,e)=>({role:t,content:[{kind:"text",text:e}]});var l="data:",i=";base64,",u=t=>t.startsWith(l),d=t=>{if(!t.startsWith(l))return null;let e=t.slice(l.length),o=e.indexOf(i);if(o===-1)return null;let s=e.slice(0,o),g=e.slice(o+i.length),r=atob(g),a=new Uint8Array(r.length);for(let n=0;n<r.length;n++)a[n]=r.charCodeAt(n);return{mimeType:s,data:a}},p={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp",mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",flac:"audio/flac",m4a:"audio/mp4",webm:"audio/webm",pdf:"application/pdf",json:"application/json",txt:"text/plain"},m=t=>{let e=t.split("?")[0]??t,o=e.lastIndexOf(".");if(o===-1)return null;let s=e.slice(o+1).toLowerCase();return p[s]??null};export{c as a,u as b,d as c,m as d};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{b as k}from"./chunk-2J2PXBOC.js";import{d as F,f as T,h as C,j as d,k as L,n as u}from"./chunk-GLSCZGXA.js";import{a as g}from"./chunk-ZE5T64HQ.js";import{t as D}from"./chunk-YXSB6RET.js";var R={USE_CLIENT:"use client",USE_SERVER:"use server",USE_STRICT:"use strict"},M=[/node_modules/,/\.test\./,/\.spec\./],G=(t,e)=>{let r=t.split(`
|
|
2
|
+
`),i=e.toLowerCase(),o=!1;for(let s=0;s<Math.min(50,r.length);s++){let n=r[s]?.trim()??"";if(o){n.includes("*/")&&(o=!1);continue}if(n===""||n.startsWith("//"))continue;if(n.startsWith("/*")){n.includes("*/")||(o=!0);continue}let f=`"${i}";`,a=`'${i}';`,l=n.toLowerCase();if(l===f||l===a)return!0;if(n.startsWith("import")||n.startsWith("export")||n.startsWith("const")||n.startsWith("let")||n.startsWith("var")||n.startsWith("function")||n.startsWith("class"))break}return!1},W=t=>{let e=new Set,r=t.matchAll(/export\s+(?:async\s+)?function\s+(\w+)/g);for(let n of r)n[1]!==void 0&&e.add(n[1]);let i=t.matchAll(/export\s{1,100}(?:const|let)\s{1,100}(\w+)\s{0,100}=/g);for(let n of i)n[1]!==void 0&&e.add(n[1]);let o=t.matchAll(/export\s{1,100}class\s{1,100}(\w+)/g);for(let n of o)n[1]!==void 0&&e.add(n[1]);/export\s+default\s+/.test(t)&&e.add("default");let s=t.matchAll(/export\s*\{([\w\s,]+)\}/g);for(let n of s)if(n[1]!==void 0){let f=n[1].split(",").map(a=>{let l=a.trim().split(/ {1,10}as {1,10}/);return(l[1]??l[0])?.trim()});for(let a of f)a!==void 0&&a!==""&&e.add(a)}return[...e]},O=async t=>{try{return await D.fs.readTextFile(t)}catch{return null}},Q=async(t,e,r={})=>{let i=r.extensions??k,o=r.skip??M,s=r.projectRoot??t,n=[];for await(let f of D.fs.walk(t,{exts:[...i],skip:[...o]})){if(!f.isFile)continue;let a=await O(f.path);if(a!==null&&G(a,e)){let l=D.path.relative(s,f.path),m=W(a);n.push({filePath:f.path,relativePath:l,directive:e,exports:m})}}return n},Y=(t,e={})=>Q(t,R.USE_CLIENT,e),X=(t,e)=>{let r=`"${e}"`,i=`'${e}'`;return t.includes(r)||t.includes(i)},Z=async(t,e={})=>{let r=e.extensions??k,i=e.skip??M,o=e.projectRoot??t,s=[];for await(let n of D.fs.walk(t,{exts:[...r],skip:[...i]})){if(!n.isFile)continue;let f=await O(n.path);if(f!==null&&X(f,R.USE_SERVER)){let a=D.path.relative(o,n.path),l=W(f);s.push({filePath:n.path,relativePath:a,directive:R.USE_SERVER,exports:l})}}return s};function w(t){return t.isFile?"file":t.isDirectory?"dir":t.isSymlink?"symlink":void 0}async function x(t){try{let e=await Deno.stat(t);_(e);return}catch(e){if(!(e instanceof Deno.errors.NotFound))throw e}try{await Deno.mkdir(t,{recursive:!0})}catch(e){if(!(e instanceof Deno.errors.AlreadyExists))throw e;let r=await Deno.stat(t);_(r)}}function _(t){if(!t.isDirectory)throw new Error(`Failed to ensure directory exists: expected 'dir', got '${w(t)}'`)}function c(t){return t instanceof URL?C(t):t}function P(t,e,r=T){if(t=c(t),e=c(e),u(t)===u(e))return!1;let i=t.split(r),o=e.split(r);return i.every((s,n)=>o[n]===s)}function S(t,e){if(t===null)throw new Error(`${e} is unavailable`)}async function I(t,e,r){let i;try{i=await Deno.lstat(e)}catch(o){if(o instanceof Deno.errors.NotFound)return;throw o}if(r.isFolder&&!i.isDirectory)throw new Error(`Cannot overwrite non-directory '${e}' with directory '${t}'`);if(!r.overwrite)throw new Deno.errors.AlreadyExists(`'${e}' already exists.`);return i}async function N(t,e,r){if(await I(t,e,r),await Deno.copyFile(t,e),r.preserveTimestamps){let i=await Deno.stat(t);S(i.atime,"statInfo.atime"),S(i.mtime,"statInfo.mtime"),await Deno.utime(e,i.atime,i.mtime)}}async function U(t,e,r){await I(t,e,r);let i=await Deno.readLink(t),o=w(await Deno.lstat(t));if(g?await Deno.symlink(i,e,{type:o==="dir"?"dir":"file"}):await Deno.symlink(i,e),r.preserveTimestamps){let s=await Deno.lstat(t);S(s.atime,"statInfo.atime"),S(s.mtime,"statInfo.mtime"),await Deno.utime(e,s.atime,s.mtime)}}async function j(t,e,r){if(await I(t,e,{...r,isFolder:!0})||await x(e),r.preserveTimestamps){let s=await Deno.stat(t);S(s.atime,"statInfo.atime"),S(s.mtime,"statInfo.mtime"),await Deno.utime(e,s.atime,s.mtime)}t=c(t),e=c(e);let o=[];for await(let s of Deno.readDir(t)){let n=d(t,s.name),f=d(e,F(n));s.isSymlink?o.push(U(n,f,r)):s.isDirectory?o.push(j(n,f,r)):s.isFile&&o.push(N(n,f,r))}await Promise.all(o)}async function wt(t,e,r={}){if(t=u(c(t)),e=u(c(e)),t===e)throw new Error("Source and destination cannot be the same");let i=await Deno.lstat(t);if(i.isDirectory&&P(t,e))throw new Error(`Cannot copy '${t}' to a subdirectory of itself: '${e}'`);i.isSymlink?await U(t,e,r):i.isDirectory?await j(t,e,r):i.isFile&&await N(t,e,r)}async function Ft(t){try{let e=await Array.fromAsync(Deno.readDir(t));await Promise.all(e.map(r=>{if(r&&r.name){let i=d(c(t),r.name);return Deno.remove(i,{recursive:!0})}}))}catch(e){if(!(e instanceof Deno.errors.NotFound))throw e;await Deno.mkdir(t,{recursive:!0})}}async function A(t){t=c(t),t=L(t);let e=F(t),r=await Deno.stat(t);return{path:t,name:e,isFile:r.isFile,isDirectory:r.isDirectory,isSymlink:r.isSymlink}}function E(t,e,r,i){return!(e&&!e.some(o=>t.endsWith(o))||r&&!r.some(o=>!!t.match(o))||i&&i.some(o=>!!t.match(o)))}async function*V(t,e){let{maxDepth:r=1/0,includeFiles:i=!0,includeDirs:o=!0,includeSymlinks:s=!0,followSymlinks:n=!1,canonicalize:f=!0,exts:a=void 0,match:l=void 0,skip:m=void 0}=e??{};if(!(r<0)&&(t=c(t),a&&(a=a.map(y=>y.startsWith(".")?y:`.${y}`)),o&&E(t,a,l,m)&&(yield await A(t)),!(r<1||!E(t,void 0,void 0,m))))for await(let y of Deno.readDir(t)){let p=d(t,y.name),{isSymlink:v,isDirectory:$}=y;if(v){if(!n){s&&E(p,a,l,m)&&(yield{path:p,...y});continue}let h=await Deno.realPath(p);f&&(p=h),{isSymlink:v,isDirectory:$}=await Deno.lstat(h)}if(v||$){let h={maxDepth:r-1,includeFiles:i,includeDirs:o,includeSymlinks:s,followSymlinks:n};a!==void 0&&(h.exts=a),l!==void 0&&(h.match=l),m!==void 0&&(h.skip=m),yield*V(p,h)}else i&&E(p,a,l,m)&&(yield{path:p,...y})}}var ue=globalThis.Deno?.build.os==="windows"?"`":"\\";var B=`
|
|
3
|
+
`,J=`\r
|
|
4
|
+
`,xe=globalThis.Deno?.build.os==="windows"?J:B;export{G as a,W as b,Y as c,Z as d,Ft as e,x as f,V as g,wt as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-SBOTNOWZ.js";import{a as r}from"./chunk-3APERFKY.js";var t=i({name:"validate-toml",description:"Validate TOML syntax",canFix:!1,stacks:[],defaults:{},extensions:["toml"],checkFile(e,o){if(o===void 0)return[];try{return r(o),[]}catch(a){let s=a instanceof Error?a.message:"invalid TOML";return[{path:e.path,message:s}]}}}),p=t.run,d=t.validator,u=t.main;export{t as a,p as b,d as c,u as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as l,c as p,d as u}from"./chunk-
|
|
1
|
+
import{b as l,c as p,d as u}from"./chunk-5MN3MWQN.js";var f=e=>e==="assistant"?"model":e==="tool"?"user":e,g=e=>{switch(e.kind){case"text":return{text:e.text};case"image":{if(e.image.data!==void 0)return{inlineData:{mimeType:e.image.mimeType??"image/png",data:d(e.image.data)}};if(e.image.url!==void 0){if(l(e.image.url)){let t=p(e.image.url);if(t!==null)return{inlineData:{mimeType:t.mimeType,data:d(t.data)}}}return{fileData:{mimeType:e.image.mimeType??u(e.image.url)??"image/png",fileUri:e.image.url}}}return{text:"[unsupported image]"}}case"audio":return e.audio.data!==void 0?{inlineData:{mimeType:e.audio.mimeType??"audio/mpeg",data:d(e.audio.data)}}:e.audio.url!==void 0?{fileData:{mimeType:e.audio.mimeType??u(e.audio.url)??"audio/mpeg",fileUri:e.audio.url}}:{text:"[unsupported audio]"};case"file":return{fileData:{mimeType:e.file.mimeType??"application/octet-stream",fileUri:e.file.uri}};case"tool_call":return{functionCall:{name:e.toolCall.name,args:e.toolCall.arguments}};case"tool_result":return{functionResponse:{name:e.toolResult.toolCallId,response:{content:e.toolResult.content}}}}},T=e=>{let t=null,n=[];for(let a of e){if(a.role==="system"){let o=[];for(let r of a.content)r.kind==="text"&&o.push(r.text);t=o.join(`
|
|
2
2
|
`);continue}let s=a.content.map(g);n.push({role:f(a.role),parts:s})}return{contents:n,systemInstruction:t}},x=e=>e.map(t=>({functionDeclarations:[{name:t.name,description:t.description,parameters:t.parameters}]})),C=(e,t)=>{let n=[],a="end_turn",s=e?.candidates??[];if(s.length>0){let r=s[0],c=r?.content?.parts??[];for(let i of c)i.text!==void 0&&n.push({kind:"text",text:i.text}),i.functionCall!==void 0&&(n.push({kind:"tool_call",toolCall:{id:i.functionCall.name,name:i.functionCall.name,arguments:i.functionCall.args??{}}}),a="tool_use");let m=r?.finishReason;m==="MAX_TOKENS"?a="max_tokens":m==="STOP"&&(a="end_turn")}let o=e?.usageMetadata;return{content:n,stopReason:a,usage:{inputTokens:o?.promptTokenCount??0,outputTokens:o?.candidatesTokenCount??0,totalTokens:o?.totalTokenCount??0},modelId:t,rawResponse:e}},R=e=>e?.status!==void 0?e.status:e?.code!==void 0?e.code:500,d=e=>{let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)};export{f as a,g as b,T as c,x as d,C as e,R as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as h,b as u,c as S,d as k,e as g,f as m,g as f}from"./chunk-
|
|
1
|
+
import{a as h,b as u,c as S,d as k,e as g,f as m,g as f}from"./chunk-3K42AALS.js";import{a as c}from"./chunk-OLM5RTFK.js";var y=class{capabilities=["text_generation","streaming"];provider="opencode";modelId;binary;config;constructor(e,r){this.binary=e,this.config=r,this.modelId=r.model}async generateText(e,r){let o=w(this.config,e,"json"),i=f(e.messages,e.system);o.push("-p",i);let s=u(this.binary,o,{signal:r}),l=g(s.stderr),t=await k(s.stdout,this.modelId),p=await s.waitForExit(),a=await l,d=m("opencode",p.code,a);if(d!==null)throw d;return t}async*streamText(e,r){let o=w(this.config,e,"stream-json"),i=f(e.messages,e.system);o.push("-p",i);let s=u(this.binary,o,{signal:r}),l=g(s.stderr);try{for await(let d of S(s.stdout)){let x=v(d);x!==null&&(yield x)}let t=await s.waitForExit(),p=await l,a=m("opencode",t.code,p);a!==null&&(yield{kind:"error",error:a})}catch(t){t instanceof c?yield{kind:"error",error:t}:yield{kind:"error",error:new c(t instanceof Error?t.message:String(t),{provider:"opencode",cause:t instanceof Error?t:void 0})}}}close(){return Promise.resolve()}getRawClient(){return null}},b={provider:"opencode",async createModel(n){let e=await h("opencode",n);return new y(e,n)}},w=(n,e,r)=>{let o=["--output-format",r];o.push("--model",n.model),e.maxTokens!==void 0&&o.push("--max-tokens",String(e.maxTokens));let i=n.properties?.args;return i!==void 0&&o.push(...i),o},v=n=>{if(n===null||typeof n!="object")return null;let e=n;if(e.type==="content_block_delta"||e.type==="assistant"){let r=e.delta?.text??e.message?.content?.[0]?.text;return r!==void 0?{kind:"content_delta",textDelta:r}:null}return e.type==="result"||e.done===!0?{kind:"message_done",stopReason:"end_turn",usage:{inputTokens:e.usage?.input_tokens??0,outputTokens:e.usage?.output_tokens??0,totalTokens:(e.usage?.input_tokens??0)+(e.usage?.output_tokens??0)}}:e.type==="error"?{kind:"error",error:new c(e.error?.message??"Unknown OpenCode error",{provider:"opencode"})}:e.content!==void 0&&typeof e.content=="string"?{kind:"content_delta",textDelta:e.content}:null};export{y as a,b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as a,f as
|
|
1
|
+
import{d as a,f as g}from"./chunk-V2N5L24J.js";import{b as i}from"./chunk-2J2PXBOC.js";import{t as s}from"./chunk-YXSB6RET.js";var u=async(n=".")=>{let[t,r]=await g(n);return r.map(e=>({name:e.name,version:e.version,path:a(e.config),config:e.config,entrypoints:c(e.config)}))},c=n=>{let t=n.exports?.value;if(t==null)return[];if(typeof t=="string")return[t];if(t!==null&&typeof t=="object"){let r=[];for(let e of Object.values(t))typeof e=="string"&&r.push(e);return r}return[]},d=(n,t)=>s.path.isAbsolute(n)?n:s.path.resolve(t,n),k=async n=>{let t=[];for await(let r of s.fs.walk(n,{exts:i,includeDirs:!1,skip:[/node_modules/,/\.git/]})){let e=s.path.relative(n,r.path),o=s.path.basename(e);o.endsWith("_test.ts")||o.endsWith("_bench.ts")||o.startsWith("_")||e.includes("testdata/")||t.push(`./${e}`)}return t.sort()};export{u as a,d as b,k as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n}from"./chunk-
|
|
1
|
+
import{a as n}from"./chunk-SBOTNOWZ.js";var e=n({name:"validate-case-conflict",description:"Detect filenames that differ only by case",canFix:!1,stacks:[],defaults:{},checkAll(r){let o=new Map,s=[];for(let t of r){let a=t.path.toLowerCase(),i=o.get(a);i!==void 0?s.push({path:t.path,message:`case conflict with "${i}"`}):o.set(a,t.path)}return s}}),f=e.run,m=e.validator,d=e.main;export{e as a,f as b,m as c,d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as C,c as E}from"./chunk-
|
|
1
|
+
import{a as C,c as E}from"./chunk-AKJB4CER.js";import{a as k}from"./chunk-6U2VEZEM.js";import{a as x}from"./chunk-KAEAT6A4.js";import{f as h}from"./chunk-NUSNMQPL.js";import{b as i,e as d,f,g as u,h as g}from"./chunk-PLJNPQFC.js";import{g as n}from"./chunk-DQAEQEXD.js";import{v as c}from"./chunk-YXSB6RET.js";var l=x(),b=t=>{let e=new Set,r=/export\s+\*\s+from\s+["']([^"']+)["']/g,a=/export\s+\{[^}]*\}\s+from\s+["']([^"']+)["']/g,o=/export\s+type\s+\{[^}]*\}\s+from\s+["']([^"']+)["']/g;for(let s of t.matchAll(r))s[1]!==void 0&&e.add(s[1]);for(let s of t.matchAll(a))s[1]!==void 0&&e.add(s[1]);for(let s of t.matchAll(o))s[1]!==void 0&&e.add(s[1]);return e},y=t=>{let e=t.startsWith("./")?t.slice(2):t;return e.endsWith(".ts")&&(e=e.slice(0,-3)),e},O=t=>!(t==="mod.ts"||t.endsWith("_test.ts")||t.endsWith("_bench.ts")||t.startsWith("_")||t.includes("/")),P=async(t={})=>{let{root:e=".",failFast:r=!1}=t,a=await C(e),o=[];for(let s of a){let v=c.runtime.path.join(s.path,"mod.ts"),m;try{m=await c.runtime.fs.readTextFile(v)}catch{continue}let M=b(m),w=new Set([...M].map(p=>y(p))),A=await E(s.path);for(let p of A){let R=c.runtime.path.basename(p);if(!O(R))continue;let F=y(p);if(!w.has(F)&&(o.push({packageName:s.name,file:p}),r))return{isComplete:!1,missingExports:o,packagesChecked:a.length}}}return{isComplete:o.length===0,missingExports:o,packagesChecked:a.length}},W=t=>h.fromPromise(()=>P(t)),_=t=>n.ok({root:"."}),z=t=>{if(n.isFail(t))return l.writeln(d("\u2717"),i(" "+String(t.error))),n.fail({exitCode:1});let{value:e}=t;if(l.writeln(g("\u2139"),i(` Checked ${e.packagesChecked} packages.`)),!e.isComplete){l.writeln(d("\u2717"),i(` Found ${e.missingExports.length} missing exports:`));for(let r of e.missingExports)l.writeln(u("\u26A0"),i(` ${r.packageName}: ${r.file}`));return n.fail({exitCode:1})}return l.writeln(f("\u2713"),i(" All mod.ts exports are complete.")),n.ok(void 0)},S=k.createTrigger({handler:W,adaptInput:_,adaptOutput:z}),N=async t=>await S({command:"validate-mod-exports",args:[],flags:{}});export{P as a,W as b,S as c,N as d};
|