@devlusoft/devix 0.4.1-beta.12 → 0.4.1-beta.13

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.
@@ -228,7 +228,7 @@ import { readFileSync } from 'node:fs'
228
228
 
229
229
  process.on('SIGTERM', () => server.close())
230
230
  process.on('SIGINT', () => server.close())
231
- `}var _=Ae(Ce(import.meta.url)),I="virtual:devix/entry-client",L="virtual:devix/client-routes",O="virtual:devix/render",j="virtual:devix/api",U="virtual:devix/context",F="virtual:devix/server-entry",Z=new Set(["loader","guard","generateStaticParams","headers"]);function K(e){let t=e.appDir??"app",r=`${t}/pages`,n=(e.css??[]).map(i=>i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`),o=p(_,"../server/render.js").replace(/\\/g,"/"),s=p(_,"../server/api.js").replace(/\\/g,"/"),m=p(_,"../runtime/client-router.js").replace(/\\/g,"/"),x=p(_,"../server/routes.js").replace(/\\/g,"/"),f=p(_,"../utils/env.js").replace(/\\/g,"/"),g=be(import.meta.url),P=g.resolve("@hono/node-server").replace(/\\/g,"/"),le=g.resolve("@hono/node-server/serve-static").replace(/\\/g,"/"),ue=g.resolve("hono").replace(/\\/g,"/"),pe={name:"devix",enforce:"pre",resolveId(i){if(i===I)return`\0${I}`;if(i===L)return`\0${L}`;if(i===O)return`\0${O}`;if(i===j)return`\0${j}`;if(i===U)return`\0${U}`;if(i===F)return`\0${F}`},load(i){if(i===`\0${I}`)return H({cssUrls:n});if(i===`\0${L}`)return q({pagesDir:r,matcherPath:m});if(i===`\0${O}`)return N({pagesDir:r,renderPath:o});if(i===`\0${j}`)return V({apiPath:s,appDir:t});if(i===`\0${U}`)return B();if(i===`\0${F}`)return z({routesPath:x,envPath:f,honoServerPath:P,honoServerStaticPath:le,honoPath:ue})},transform(i,u,v){if(v?.ssr)return;let a=p(process.cwd(),r);if(!u.startsWith(a))return;let me=Me(u,i,{sourceType:"module"}),R=[];for(let c of me.program.body){if(c.type!=="ExportNamedDeclaration"||!c.declaration)continue;let d=c.declaration;if(d.type==="FunctionDeclaration"&&d.id&&Z.has(d.id.name)&&R.push({start:c.start,end:c.end,name:d.id.name}),d.type==="VariableDeclaration"){let E=new Set;for(let $ of d.declarations)$.id.type==="Identifier"&&Z.has($.id.name)&&(E.has(c.start)||(E.add(c.start),R.push({start:c.start,end:c.end,name:$.id.name})))}}if(R.length===0)return;R.sort((c,d)=>d.start-c.start);let w=i;for(let{start:c,end:d,name:E}of R)w=w.slice(0,c)+`export const ${E} = undefined`+w.slice(d);return{code:w,map:null}},buildStart(){let i=process.cwd(),u=b(t,i);M(C(u,`${t}/api`),i)},configureServer(i){let u=process.cwd(),v=()=>{let a=b(t,u);M(C(a,`${t}/api`),u)};i.watcher.add(p(u,"devix.config.ts")),i.watcher.on("change",a=>{a===p(u,"devix.config.ts")&&(console.log("[devix] Config changed, restarting..."),process.exit(75))}),i.watcher.on("add",a=>{a.startsWith(p(u,r))&&S(),a.includes(`${t}/api`)&&(D(),v())}),i.watcher.on("unlink",a=>{a.startsWith(p(u,r))&&S(),a.includes(`${t}/api`)&&(D(),v())}),i.watcher.on("change",a=>{a.includes(`${t}/api`)&&!a.endsWith("middleware.ts")&&v()})}},de={plugins:[De(),pe],publicDir:p(process.cwd(),e.publicDir??"public"),ssr:{noExternal:["@devlusoft/devix"]},...e.envPrefix?{envPrefix:e.envPrefix}:{}};return Se(de,e.vite??{})}function Q(e,{apiModule:t,renderModule:r,loaderTimeout:n}){e.all("/api/*",async o=>{try{return await t.handleApiRequest(o.req.url,o.req.raw)}catch(s){return console.error(s),o.json({error:"internal error"},500)}}),e.get("/_data/*",async o=>{try{let{pathname:s,search:m}=new URL(o.req.url,"http://localhost"),x=s.replace(/^\/_data/,"")+m,f=await r.runLoader(x,o.req.raw,{loaderTimeout:n});return f.error?o.json({error:"internal error"},500):o.json(f)}catch(s){return console.error(s),o.json({error:"internal error"},500)}})}import l from"picocolors";import{networkInterfaces as Ie}from"node:os";function Le(e){let t=Ie();for(let r of Object.values(t))for(let n of r??[])if(n.family==="IPv4"&&!n.internal)return`http://${n.address}:${e}/`;return null}function ee(e){let t="0.4.1-beta.12",r=Le(e);console.log(),console.log(` ${l.bold(l.yellow("devix"))} ${l.dim(`v${t}`)}`),console.log(),console.log(` ${l.green("\u279C")} ${l.bold("Local:")} ${l.cyan(`http://localhost:${e}/`)}`),console.log(r?` ${l.green("\u279C")} ${l.bold("Network:")} ${l.cyan(r)}`:` ${l.green("\u279C")} ${l.bold("Network:")} ${l.dim("use --host to expose")}`),console.log()}async function te(e){let t=new Set;for(let[,r]of e.moduleGraph.idToModuleMap)r.id&&(r.id.endsWith(".css")||r.id.includes(".css?"))&&r.url.startsWith("/")&&t.add(r.url);return[...t]}function re(e){if(typeof e=="number")return e;let t=e.trim().match(/^(\d+(?:\.\d+)?)\s*(ms|s|m|h)?$/);if(!t)throw new Error(`[devix] Invalid duration: "${e}". Use a number (ms) or a string like "5s", "2m", "500ms".`);let r=parseFloat(t[1]);switch(t[2]){case"h":return r*36e5;case"m":return r*6e4;case"s":return r*1e3;default:return r}}import{loadEnv as Oe}from"vite";function oe(e){let t=Oe(e,process.cwd(),"");for(let[r,n]of Object.entries(t))process.env[r]===void 0&&(process.env[r]=n)}import{build as je}from"esbuild";import{join as ne}from"node:path";import{unlinkSync as Ue,writeFileSync as Fe}from"node:fs";import{pathToFileURL as ke}from"node:url";async function ie(e){let t=await je({entryPoints:[ne(e,"devix.config.ts")],bundle:!0,write:!1,format:"esm",platform:"node",packages:"external"}),r=ne(e,`.devix-config-${Date.now()}.mjs`);Fe(r,t.outputFiles[0].text);try{return(await import(ke(r).href)).default}finally{Ue(r)}}oe("development");var se="virtual:devix/render",We="virtual:devix/api",y=await ie(process.cwd()),ae=Number(process.env.PORT)||y.port||3e3,Be=typeof y.host=="string"?y.host:y.host?"0.0.0.0":"localhost",h=await qe({...K(y),configFile:!1,appType:"custom",server:{middlewareMode:!0}}),ce={render:async(...e)=>(await h.ssrLoadModule(se)).render(...e),runLoader:async(...e)=>(await h.ssrLoadModule(se)).runLoader(...e)},Je={handleApiRequest:async(...e)=>(await h.ssrLoadModule(We)).handleApiRequest(...e)},k=new Ve;Q(k,{renderModule:ce,apiModule:Je});k.get("*",async e=>{try{let{html:t,statusCode:r,headers:n}=await ce.render(e.req.url,e.req.raw,{loaderTimeout:re(y.loaderTimeout??1e4)}),s=(await te(h)).map(g=>`<link rel="stylesheet" href="${g}">`).join(`
231
+ `}var _=Ae(Ce(import.meta.url)),I="virtual:devix/entry-client",L="virtual:devix/client-routes",O="virtual:devix/render",j="virtual:devix/api",U="virtual:devix/context",F="virtual:devix/server-entry",Z=new Set(["loader","guard","generateStaticParams","headers"]);function K(e){let t=e.appDir??"app",r=`${t}/pages`,n=(e.css??[]).map(i=>i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`),o=p(_,"../server/render.js").replace(/\\/g,"/"),s=p(_,"../server/api.js").replace(/\\/g,"/"),m=p(_,"../runtime/client-router.js").replace(/\\/g,"/"),x=p(_,"../server/routes.js").replace(/\\/g,"/"),f=p(_,"../utils/env.js").replace(/\\/g,"/"),g=be(import.meta.url),P=g.resolve("@hono/node-server").replace(/\\/g,"/"),le=g.resolve("@hono/node-server/serve-static").replace(/\\/g,"/"),ue=g.resolve("hono").replace(/\\/g,"/"),pe={name:"devix",enforce:"pre",resolveId(i){if(i===I)return`\0${I}`;if(i===L)return`\0${L}`;if(i===O)return`\0${O}`;if(i===j)return`\0${j}`;if(i===U)return`\0${U}`;if(i===F)return`\0${F}`},load(i){if(i===`\0${I}`)return H({cssUrls:n});if(i===`\0${L}`)return q({pagesDir:r,matcherPath:m});if(i===`\0${O}`)return N({pagesDir:r,renderPath:o});if(i===`\0${j}`)return V({apiPath:s,appDir:t});if(i===`\0${U}`)return B();if(i===`\0${F}`)return z({routesPath:x,envPath:f,honoServerPath:P,honoServerStaticPath:le,honoPath:ue})},transform(i,u,v){if(v?.ssr)return;let a=p(process.cwd(),r);if(!u.startsWith(a))return;let me=Me(u,i,{sourceType:"module"}),R=[];for(let c of me.program.body){if(c.type!=="ExportNamedDeclaration"||!c.declaration)continue;let d=c.declaration;if(d.type==="FunctionDeclaration"&&d.id&&Z.has(d.id.name)&&R.push({start:c.start,end:c.end,name:d.id.name}),d.type==="VariableDeclaration"){let E=new Set;for(let $ of d.declarations)$.id.type==="Identifier"&&Z.has($.id.name)&&(E.has(c.start)||(E.add(c.start),R.push({start:c.start,end:c.end,name:$.id.name})))}}if(R.length===0)return;R.sort((c,d)=>d.start-c.start);let w=i;for(let{start:c,end:d,name:E}of R)w=w.slice(0,c)+`export const ${E} = undefined`+w.slice(d);return{code:w,map:null}},buildStart(){let i=process.cwd(),u=b(t,i);M(C(u,`${t}/api`),i)},configureServer(i){let u=process.cwd(),v=()=>{let a=b(t,u);M(C(a,`${t}/api`),u)};i.watcher.add(p(u,"devix.config.ts")),i.watcher.on("change",a=>{a===p(u,"devix.config.ts")&&(console.log("[devix] Config changed, restarting..."),process.exit(75))}),i.watcher.on("add",a=>{a.startsWith(p(u,r))&&S(),a.includes(`${t}/api`)&&(D(),v())}),i.watcher.on("unlink",a=>{a.startsWith(p(u,r))&&S(),a.includes(`${t}/api`)&&(D(),v())}),i.watcher.on("change",a=>{a.includes(`${t}/api`)&&!a.endsWith("middleware.ts")&&v()})}},de={plugins:[De(),pe],publicDir:p(process.cwd(),e.publicDir??"public"),ssr:{noExternal:["@devlusoft/devix"]},...e.envPrefix?{envPrefix:e.envPrefix}:{}};return Se(de,e.vite??{})}function Q(e,{apiModule:t,renderModule:r,loaderTimeout:n}){e.all("/api/*",async o=>{try{return await t.handleApiRequest(o.req.url,o.req.raw)}catch(s){return console.error(s),o.json({error:"internal error"},500)}}),e.get("/_data/*",async o=>{try{let{pathname:s,search:m}=new URL(o.req.url,"http://localhost"),x=s.replace(/^\/_data/,"")+m,f=await r.runLoader(x,o.req.raw,{loaderTimeout:n});return f.error?o.json({error:"internal error"},500):o.json(f)}catch(s){return console.error(s),o.json({error:"internal error"},500)}})}import l from"picocolors";import{networkInterfaces as Ie}from"node:os";function Le(e){let t=Ie();for(let r of Object.values(t))for(let n of r??[])if(n.family==="IPv4"&&!n.internal)return`http://${n.address}:${e}/`;return null}function ee(e){let t="0.4.1-beta.13",r=Le(e);console.log(),console.log(` ${l.bold(l.yellow("devix"))} ${l.dim(`v${t}`)}`),console.log(),console.log(` ${l.green("\u279C")} ${l.bold("Local:")} ${l.cyan(`http://localhost:${e}/`)}`),console.log(r?` ${l.green("\u279C")} ${l.bold("Network:")} ${l.cyan(r)}`:` ${l.green("\u279C")} ${l.bold("Network:")} ${l.dim("use --host to expose")}`),console.log()}async function te(e){let t=new Set;for(let[,r]of e.moduleGraph.idToModuleMap)r.id&&(r.id.endsWith(".css")||r.id.includes(".css?"))&&r.url.startsWith("/")&&t.add(r.url);return[...t]}function re(e){if(typeof e=="number")return e;let t=e.trim().match(/^(\d+(?:\.\d+)?)\s*(ms|s|m|h)?$/);if(!t)throw new Error(`[devix] Invalid duration: "${e}". Use a number (ms) or a string like "5s", "2m", "500ms".`);let r=parseFloat(t[1]);switch(t[2]){case"h":return r*36e5;case"m":return r*6e4;case"s":return r*1e3;default:return r}}import{loadEnv as Oe}from"vite";function oe(e){let t=Oe(e,process.cwd(),"");for(let[r,n]of Object.entries(t))process.env[r]===void 0&&(process.env[r]=n)}import{build as je}from"esbuild";import{join as ne}from"node:path";import{unlinkSync as Ue,writeFileSync as Fe}from"node:fs";import{pathToFileURL as ke}from"node:url";async function ie(e){let t=await je({entryPoints:[ne(e,"devix.config.ts")],bundle:!0,write:!1,format:"esm",platform:"node",packages:"external"}),r=ne(e,`.devix-config-${Date.now()}.mjs`);Fe(r,t.outputFiles[0].text);try{return(await import(ke(r).href)).default}finally{Ue(r)}}oe("development");var se="virtual:devix/render",We="virtual:devix/api",y=await ie(process.cwd()),ae=Number(process.env.PORT)||y.port||3e3,Be=typeof y.host=="string"?y.host:y.host?"0.0.0.0":"localhost",h=await qe({...K(y),configFile:!1,appType:"custom",server:{middlewareMode:!0}}),ce={render:async(...e)=>(await h.ssrLoadModule(se)).render(...e),runLoader:async(...e)=>(await h.ssrLoadModule(se)).runLoader(...e)},Je={handleApiRequest:async(...e)=>(await h.ssrLoadModule(We)).handleApiRequest(...e)},k=new Ve;Q(k,{renderModule:ce,apiModule:Je});k.get("*",async e=>{try{let{html:t,statusCode:r,headers:n}=await ce.render(e.req.url,e.req.raw,{loaderTimeout:re(y.loaderTimeout??1e4)}),s=(await te(h)).map(g=>`<link rel="stylesheet" href="${g}">`).join(`
232
232
  `),m=s?t.replace("</head>",`${s}
233
233
  </head>`):t,x=await h.transformIndexHtml(e.req.url,`<!DOCTYPE html>${m}`),f=e.html(x,r);for(let[g,P]of Object.entries(n))f.headers.set(g,P);return f}catch(t){return h.ssrFixStacktrace(t),console.error(t),e.text("Internal Server Error",500)}});var Xe=Ne(k.fetch);He(async(e,t)=>{await new Promise(r=>h.middlewares(e,t,r)),t.writableEnded||await Xe(e,t)}).listen(ae,Be,()=>{ee(ae)});
234
234
  //# sourceMappingURL=dev-server.js.map
package/dist/cli/index.js CHANGED
@@ -229,7 +229,7 @@ import { readFileSync } from 'node:fs'
229
229
 
230
230
  process.on('SIGTERM', () => server.close())
231
231
  process.on('SIGINT', () => server.close())
232
- `}var Ee=s(()=>{"use strict"});import{mergeConfig as vt}from"vite";import xt from"@vitejs/plugin-react";import{fileURLToPath as yt}from"node:url";import{dirname as Rt,resolve as d}from"node:path";import{createRequire as wt}from"node:module";import{parseSync as _t}from"oxc-parser";function $e(e){let t=e.appDir??"app",r=`${t}/pages`,n=(e.css??[]).map(i=>i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`),o=d(w,"../server/render.js").replace(/\\/g,"/"),a=d(w,"../server/api.js").replace(/\\/g,"/"),u=d(w,"../runtime/client-router.js").replace(/\\/g,"/"),v=d(w,"../server/routes.js").replace(/\\/g,"/"),g=d(w,"../utils/env.js").replace(/\\/g,"/"),x=wt(import.meta.url),b=x.resolve("@hono/node-server").replace(/\\/g,"/"),Ge=x.resolve("@hono/node-server/serve-static").replace(/\\/g,"/"),Xe=x.resolve("hono").replace(/\\/g,"/"),Ye={name:"devix",enforce:"pre",resolveId(i){if(i===H)return`\0${H}`;if(i===q)return`\0${q}`;if(i===N)return`\0${N}`;if(i===V)return`\0${V}`;if(i===J)return`\0${J}`;if(i===B)return`\0${B}`},load(i){if(i===`\0${H}`)return ie({cssUrls:n});if(i===`\0${q}`)return ae({pagesDir:r,matcherPath:u});if(i===`\0${N}`)return le({pagesDir:r,renderPath:o});if(i===`\0${V}`)return pe({apiPath:a,appDir:t});if(i===`\0${J}`)return ge();if(i===`\0${B}`)return Pe({routesPath:v,envPath:g,honoServerPath:b,honoServerStaticPath:Ge,honoPath:Xe})},transform(i,p,y){if(y?.ssr)return;let c=d(process.cwd(),r);if(!p.startsWith(c))return;let Ze=_t(p,i,{sourceType:"module"}),R=[];for(let l of Ze.program.body){if(l.type!=="ExportNamedDeclaration"||!l.declaration)continue;let m=l.declaration;if(m.type==="FunctionDeclaration"&&m.id&&Te.has(m.id.name)&&R.push({start:l.start,end:l.end,name:m.id.name}),m.type==="VariableDeclaration"){let T=new Set;for(let D of m.declarations)D.id.type==="Identifier"&&Te.has(D.id.name)&&(T.has(l.start)||(T.add(l.start),R.push({start:l.start,end:l.end,name:D.id.name})))}}if(R.length===0)return;R.sort((l,m)=>m.start-l.start);let E=i;for(let{start:l,end:m,name:T}of R)E=E.slice(0,l)+`export const ${T} = undefined`+E.slice(m);return{code:E,map:null}},buildStart(){let i=process.cwd(),p=k(t,i);U(F(p,`${t}/api`),i)},configureServer(i){let p=process.cwd(),y=()=>{let c=k(t,p);U(F(c,`${t}/api`),p)};i.watcher.add(d(p,"devix.config.ts")),i.watcher.on("change",c=>{c===d(p,"devix.config.ts")&&(console.log("[devix] Config changed, restarting..."),process.exit(75))}),i.watcher.on("add",c=>{c.startsWith(d(p,r))&&O(),c.includes(`${t}/api`)&&(M(),y())}),i.watcher.on("unlink",c=>{c.startsWith(d(p,r))&&O(),c.includes(`${t}/api`)&&(M(),y())}),i.watcher.on("change",c=>{c.includes(`${t}/api`)&&!c.endsWith("middleware.ts")&&y()})}},ze={plugins:[xt(),Ye],publicDir:d(process.cwd(),e.publicDir??"public"),ssr:{noExternal:["@devlusoft/devix"]},...e.envPrefix?{envPrefix:e.envPrefix}:{}};return vt(ze,e.vite??{})}var w,H,q,N,V,J,B,Te,be=s(()=>{"use strict";se();ce();ue();de();me();j();he();we();I();Se();Ee();w=Rt(yt(import.meta.url)),H="virtual:devix/entry-client",q="virtual:devix/client-routes",N="virtual:devix/render",V="virtual:devix/api",J="virtual:devix/context",B="virtual:devix/server-entry",Te=new Set(["loader","guard","generateStaticParams","headers"])});function De(e){if(typeof e=="number")return e;let t=e.trim().match(/^(\d+(?:\.\d+)?)\s*(ms|s|m|h)?$/);if(!t)throw new Error(`[devix] Invalid duration: "${e}". Use a number (ms) or a string like "5s", "2m", "500ms".`);let r=parseFloat(t[1]);switch(t[2]){case"h":return r*36e5;case"m":return r*6e4;case"s":return r*1e3;default:return r}}var Ce=s(()=>{"use strict"});import{build as St}from"esbuild";import{join as Ae}from"node:path";import{unlinkSync as Pt,writeFileSync as Et}from"node:fs";import{pathToFileURL as Tt}from"node:url";async function $(e){let t=await St({entryPoints:[Ae(e,"devix.config.ts")],bundle:!0,write:!1,format:"esm",platform:"node",packages:"external"}),r=Ae(e,`.devix-config-${Date.now()}.mjs`);Et(r,t.outputFiles[0].text);try{return(await import(Tt(r).href)).default}finally{Pt(r)}}var W=s(()=>{"use strict"});var Oe={};import{writeFileSync as $t}from"node:fs";import{resolve as bt}from"node:path";import{build as G}from"vite";var _,X,Dt,Y=s(async()=>{"use strict";be();Ce();W();_=await $(process.cwd()),X=$e(_);await G({...X,configFile:!1,build:{outDir:"dist/client",manifest:!0,rolldownOptions:{input:"virtual:devix/entry-client"}}});await G({...X,configFile:!1,build:{ssr:!0,outDir:"dist/server",copyPublicDir:!1,rolldownOptions:{input:{render:"virtual:devix/render",api:"virtual:devix/api"}}}});await G({...X,configFile:!1,build:{ssr:!0,outDir:"dist/server",emptyOutDir:!1,copyPublicDir:!1,rolldownOptions:{input:{index:"virtual:devix/server-entry"}}}});Dt={port:_.port??3e3,host:_.host??!1,loaderTimeout:De(_.loaderTimeout??1e4),output:_.output??"server"};$t(bt(process.cwd(),"dist/devix.config.json"),JSON.stringify(Dt,null,2),"utf-8")});var jt={};import{readFileSync as Ct,mkdirSync as Me,writeFileSync as je,rmSync as At}from"node:fs";import{resolve as K,join as h}from"node:path";import{pathToFileURL as Ot}from"node:url";var Ie,Mt,z,Fe,Z,Le=s(async()=>{"use strict";W();Ie=await $(process.cwd());Ie.output!=="static"&&console.warn('[devix] Tip: set output: "static" in devix.config.ts to skip the SSR server at runtime.');await Y().then(()=>Oe);Mt=Date.now(),z=await import(Ot(K(process.cwd(),"dist/server/render.js")).href+`?t=${Mt}`),Fe=JSON.parse(Ct(K(process.cwd(),"dist/client/.vite/manifest.json"),"utf-8")),Z=await z.getStaticRoutes();console.log(`[devix] Generating ${Z.length} static page${Z.length===1?"":"s"}...`);for(let e of Z){let t=`http://localhost${e}`,{html:r,statusCode:n}=await z.render(t,new Request(t),{manifest:Fe});if(n!==200){console.warn(`[devix] Skipping ${e} \u2014 status ${n}`);continue}let o=e==="/"?h(process.cwd(),"dist/client/index.html"):h(process.cwd(),"dist/client",e,"index.html");Me(h(o,".."),{recursive:!0}),je(o,`<!DOCTYPE html>${r}`,"utf-8");let a=await z.runLoader(t,new Request(t),{manifest:Fe}),u=e==="/"?h(process.cwd(),"dist/client/_data/index.json"):h(process.cwd(),"dist/client/_data",`${e}.json`);Me(h(u,".."),{recursive:!0}),je(u,JSON.stringify(a),"utf-8"),console.log(` \u2713 ${e}`)}console.log("[devix] Generation complete.");Ie.output==="static"&&(At(K(process.cwd(),"dist/server"),{recursive:!0,force:!0}),console.log("[devix] Removed dist/server (not needed in static mode)"))});function ke(e,{apiModule:t,renderModule:r,loaderTimeout:n}){e.all("/api/*",async o=>{try{return await t.handleApiRequest(o.req.url,o.req.raw)}catch(a){return console.error(a),o.json({error:"internal error"},500)}}),e.get("/_data/*",async o=>{try{let{pathname:a,search:u}=new URL(o.req.url,"http://localhost"),v=a.replace(/^\/_data/,"")+u,g=await r.runLoader(v,o.req.raw,{loaderTimeout:n});return g.error?o.json({error:"internal error"},500):o.json(g)}catch(a){return console.error(a),o.json({error:"internal error"},500)}})}function Ue(e,{renderModule:t,manifest:r,loaderTimeout:n}){e.get("*",async o=>{try{let{html:a,statusCode:u,headers:v}=await t.render(o.req.url,o.req.raw,{manifest:r,loaderTimeout:n}),g=o.html(`<!DOCTYPE html>${a}`,u);for(let[x,b]of Object.entries(v))g.headers.set(x,b);return g}catch(a){return console.error(a),o.text("Internal Server Error",500)}})}var He=s(()=>{"use strict"});import{loadEnv as Ft}from"vite";function qe(e){let t=Ft(e,process.cwd(),"");for(let[r,n]of Object.entries(t))process.env[r]===void 0&&(process.env[r]=n)}var Ne=s(()=>{"use strict"});var qt={};import{readFileSync as Q}from"node:fs";import{serve as It}from"@hono/node-server";import{serveStatic as Lt}from"@hono/node-server/serve-static";import{Hono as kt}from"hono";import{resolve as Ve,join as S}from"node:path";import{pathToFileURL as Je}from"node:url";var ee,te,re,f,Ut,Ht,P,oe,Be=s(async()=>{"use strict";He();Ne();qe("production");try{f=JSON.parse(Q(S(process.cwd(),"dist/devix.config.json"),"utf-8")),f.output!=="static"&&(ee=await import(Je(Ve(process.cwd(),"dist/server/render.js")).href),te=await import(Je(Ve(process.cwd(),"dist/server/api.js")).href)),re=JSON.parse(Q(S(process.cwd(),"dist/client/.vite/manifest.json"),"utf-8"))}catch{console.error('[devix] Build not found. Run "devix build" first.'),process.exit(1)}Ut=Number(process.env.PORT)||f.port||3e3,Ht=typeof f.host=="string"?f.host:f.host?"0.0.0.0":process.env.HOST||"0.0.0.0",P=new kt,oe=S(process.cwd(),"dist/client");f.output==="static"&&P.get("/_data/*",e=>{let t=e.req.path.replace(/^\/_data/,"")||"/",r=t==="/"?S(oe,"_data/index.json"):S(oe,"_data",`${t}.json`);try{let n=Q(r,"utf-8");return e.json(JSON.parse(n))}catch{return e.json({error:"not found"},404)}});P.use("/*",Lt({root:oe,onFound:(e,t)=>{t.header("Cache-Control",e.includes("/assets/")?"public, immutable, max-age=31536000":"no-cache")}}));f.output==="static"?console.log("[devix] Static mode \u2014 serving pre-generated files from dist/client"):(ke(P,{renderModule:ee,apiModule:te,manifest:re}),Ue(P,{renderModule:ee,apiModule:te,manifest:re,loaderTimeout:f.loaderTimeout}));It({fetch:P.fetch,port:Ut,hostname:Ht},e=>console.log(`http://${e.address}:${e.port}`))});var We=process.argv[2];switch(We){case"dev":await Promise.resolve().then(()=>(ne(),ot));break;case"build":await Y().then(()=>Oe);break;case"generate":await Le().then(()=>jt);break;case"start":await Be().then(()=>qt);break;case"--version":case"-v":{console.log("0.4.1-beta.12");break}case"--help":case"-h":console.log(`
232
+ `}var Ee=s(()=>{"use strict"});import{mergeConfig as vt}from"vite";import xt from"@vitejs/plugin-react";import{fileURLToPath as yt}from"node:url";import{dirname as Rt,resolve as d}from"node:path";import{createRequire as wt}from"node:module";import{parseSync as _t}from"oxc-parser";function $e(e){let t=e.appDir??"app",r=`${t}/pages`,n=(e.css??[]).map(i=>i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`),o=d(w,"../server/render.js").replace(/\\/g,"/"),a=d(w,"../server/api.js").replace(/\\/g,"/"),u=d(w,"../runtime/client-router.js").replace(/\\/g,"/"),v=d(w,"../server/routes.js").replace(/\\/g,"/"),g=d(w,"../utils/env.js").replace(/\\/g,"/"),x=wt(import.meta.url),b=x.resolve("@hono/node-server").replace(/\\/g,"/"),Ge=x.resolve("@hono/node-server/serve-static").replace(/\\/g,"/"),Xe=x.resolve("hono").replace(/\\/g,"/"),Ye={name:"devix",enforce:"pre",resolveId(i){if(i===H)return`\0${H}`;if(i===q)return`\0${q}`;if(i===N)return`\0${N}`;if(i===V)return`\0${V}`;if(i===J)return`\0${J}`;if(i===B)return`\0${B}`},load(i){if(i===`\0${H}`)return ie({cssUrls:n});if(i===`\0${q}`)return ae({pagesDir:r,matcherPath:u});if(i===`\0${N}`)return le({pagesDir:r,renderPath:o});if(i===`\0${V}`)return pe({apiPath:a,appDir:t});if(i===`\0${J}`)return ge();if(i===`\0${B}`)return Pe({routesPath:v,envPath:g,honoServerPath:b,honoServerStaticPath:Ge,honoPath:Xe})},transform(i,p,y){if(y?.ssr)return;let c=d(process.cwd(),r);if(!p.startsWith(c))return;let Ze=_t(p,i,{sourceType:"module"}),R=[];for(let l of Ze.program.body){if(l.type!=="ExportNamedDeclaration"||!l.declaration)continue;let m=l.declaration;if(m.type==="FunctionDeclaration"&&m.id&&Te.has(m.id.name)&&R.push({start:l.start,end:l.end,name:m.id.name}),m.type==="VariableDeclaration"){let T=new Set;for(let D of m.declarations)D.id.type==="Identifier"&&Te.has(D.id.name)&&(T.has(l.start)||(T.add(l.start),R.push({start:l.start,end:l.end,name:D.id.name})))}}if(R.length===0)return;R.sort((l,m)=>m.start-l.start);let E=i;for(let{start:l,end:m,name:T}of R)E=E.slice(0,l)+`export const ${T} = undefined`+E.slice(m);return{code:E,map:null}},buildStart(){let i=process.cwd(),p=k(t,i);U(F(p,`${t}/api`),i)},configureServer(i){let p=process.cwd(),y=()=>{let c=k(t,p);U(F(c,`${t}/api`),p)};i.watcher.add(d(p,"devix.config.ts")),i.watcher.on("change",c=>{c===d(p,"devix.config.ts")&&(console.log("[devix] Config changed, restarting..."),process.exit(75))}),i.watcher.on("add",c=>{c.startsWith(d(p,r))&&O(),c.includes(`${t}/api`)&&(M(),y())}),i.watcher.on("unlink",c=>{c.startsWith(d(p,r))&&O(),c.includes(`${t}/api`)&&(M(),y())}),i.watcher.on("change",c=>{c.includes(`${t}/api`)&&!c.endsWith("middleware.ts")&&y()})}},ze={plugins:[xt(),Ye],publicDir:d(process.cwd(),e.publicDir??"public"),ssr:{noExternal:["@devlusoft/devix"]},...e.envPrefix?{envPrefix:e.envPrefix}:{}};return vt(ze,e.vite??{})}var w,H,q,N,V,J,B,Te,be=s(()=>{"use strict";se();ce();ue();de();me();j();he();we();I();Se();Ee();w=Rt(yt(import.meta.url)),H="virtual:devix/entry-client",q="virtual:devix/client-routes",N="virtual:devix/render",V="virtual:devix/api",J="virtual:devix/context",B="virtual:devix/server-entry",Te=new Set(["loader","guard","generateStaticParams","headers"])});function De(e){if(typeof e=="number")return e;let t=e.trim().match(/^(\d+(?:\.\d+)?)\s*(ms|s|m|h)?$/);if(!t)throw new Error(`[devix] Invalid duration: "${e}". Use a number (ms) or a string like "5s", "2m", "500ms".`);let r=parseFloat(t[1]);switch(t[2]){case"h":return r*36e5;case"m":return r*6e4;case"s":return r*1e3;default:return r}}var Ce=s(()=>{"use strict"});import{build as St}from"esbuild";import{join as Ae}from"node:path";import{unlinkSync as Pt,writeFileSync as Et}from"node:fs";import{pathToFileURL as Tt}from"node:url";async function $(e){let t=await St({entryPoints:[Ae(e,"devix.config.ts")],bundle:!0,write:!1,format:"esm",platform:"node",packages:"external"}),r=Ae(e,`.devix-config-${Date.now()}.mjs`);Et(r,t.outputFiles[0].text);try{return(await import(Tt(r).href)).default}finally{Pt(r)}}var W=s(()=>{"use strict"});var Oe={};import{writeFileSync as $t}from"node:fs";import{resolve as bt}from"node:path";import{build as G}from"vite";var _,X,Dt,Y=s(async()=>{"use strict";be();Ce();W();_=await $(process.cwd()),X=$e(_);await G({...X,configFile:!1,build:{outDir:"dist/client",manifest:!0,rolldownOptions:{input:"virtual:devix/entry-client"}}});await G({...X,configFile:!1,build:{ssr:!0,outDir:"dist/server",copyPublicDir:!1,rolldownOptions:{input:{render:"virtual:devix/render",api:"virtual:devix/api"}}}});await G({...X,configFile:!1,build:{ssr:!0,outDir:"dist/server",emptyOutDir:!1,copyPublicDir:!1,rolldownOptions:{input:{index:"virtual:devix/server-entry"}}}});Dt={port:_.port??3e3,host:_.host??!1,loaderTimeout:De(_.loaderTimeout??1e4),output:_.output??"server"};$t(bt(process.cwd(),"dist/devix.config.json"),JSON.stringify(Dt,null,2),"utf-8")});var jt={};import{readFileSync as Ct,mkdirSync as Me,writeFileSync as je,rmSync as At}from"node:fs";import{resolve as K,join as h}from"node:path";import{pathToFileURL as Ot}from"node:url";var Ie,Mt,z,Fe,Z,Le=s(async()=>{"use strict";W();Ie=await $(process.cwd());Ie.output!=="static"&&console.warn('[devix] Tip: set output: "static" in devix.config.ts to skip the SSR server at runtime.');await Y().then(()=>Oe);Mt=Date.now(),z=await import(Ot(K(process.cwd(),"dist/server/render.js")).href+`?t=${Mt}`),Fe=JSON.parse(Ct(K(process.cwd(),"dist/client/.vite/manifest.json"),"utf-8")),Z=await z.getStaticRoutes();console.log(`[devix] Generating ${Z.length} static page${Z.length===1?"":"s"}...`);for(let e of Z){let t=`http://localhost${e}`,{html:r,statusCode:n}=await z.render(t,new Request(t),{manifest:Fe});if(n!==200){console.warn(`[devix] Skipping ${e} \u2014 status ${n}`);continue}let o=e==="/"?h(process.cwd(),"dist/client/index.html"):h(process.cwd(),"dist/client",e,"index.html");Me(h(o,".."),{recursive:!0}),je(o,`<!DOCTYPE html>${r}`,"utf-8");let a=await z.runLoader(t,new Request(t),{manifest:Fe}),u=e==="/"?h(process.cwd(),"dist/client/_data/index.json"):h(process.cwd(),"dist/client/_data",`${e}.json`);Me(h(u,".."),{recursive:!0}),je(u,JSON.stringify(a),"utf-8"),console.log(` \u2713 ${e}`)}console.log("[devix] Generation complete.");Ie.output==="static"&&(At(K(process.cwd(),"dist/server"),{recursive:!0,force:!0}),console.log("[devix] Removed dist/server (not needed in static mode)"))});function ke(e,{apiModule:t,renderModule:r,loaderTimeout:n}){e.all("/api/*",async o=>{try{return await t.handleApiRequest(o.req.url,o.req.raw)}catch(a){return console.error(a),o.json({error:"internal error"},500)}}),e.get("/_data/*",async o=>{try{let{pathname:a,search:u}=new URL(o.req.url,"http://localhost"),v=a.replace(/^\/_data/,"")+u,g=await r.runLoader(v,o.req.raw,{loaderTimeout:n});return g.error?o.json({error:"internal error"},500):o.json(g)}catch(a){return console.error(a),o.json({error:"internal error"},500)}})}function Ue(e,{renderModule:t,manifest:r,loaderTimeout:n}){e.get("*",async o=>{try{let{html:a,statusCode:u,headers:v}=await t.render(o.req.url,o.req.raw,{manifest:r,loaderTimeout:n}),g=o.html(`<!DOCTYPE html>${a}`,u);for(let[x,b]of Object.entries(v))g.headers.set(x,b);return g}catch(a){return console.error(a),o.text("Internal Server Error",500)}})}var He=s(()=>{"use strict"});import{loadEnv as Ft}from"vite";function qe(e){let t=Ft(e,process.cwd(),"");for(let[r,n]of Object.entries(t))process.env[r]===void 0&&(process.env[r]=n)}var Ne=s(()=>{"use strict"});var qt={};import{readFileSync as Q}from"node:fs";import{serve as It}from"@hono/node-server";import{serveStatic as Lt}from"@hono/node-server/serve-static";import{Hono as kt}from"hono";import{resolve as Ve,join as S}from"node:path";import{pathToFileURL as Je}from"node:url";var ee,te,re,f,Ut,Ht,P,oe,Be=s(async()=>{"use strict";He();Ne();qe("production");try{f=JSON.parse(Q(S(process.cwd(),"dist/devix.config.json"),"utf-8")),f.output!=="static"&&(ee=await import(Je(Ve(process.cwd(),"dist/server/render.js")).href),te=await import(Je(Ve(process.cwd(),"dist/server/api.js")).href)),re=JSON.parse(Q(S(process.cwd(),"dist/client/.vite/manifest.json"),"utf-8"))}catch{console.error('[devix] Build not found. Run "devix build" first.'),process.exit(1)}Ut=Number(process.env.PORT)||f.port||3e3,Ht=typeof f.host=="string"?f.host:f.host?"0.0.0.0":process.env.HOST||"0.0.0.0",P=new kt,oe=S(process.cwd(),"dist/client");f.output==="static"&&P.get("/_data/*",e=>{let t=e.req.path.replace(/^\/_data/,"")||"/",r=t==="/"?S(oe,"_data/index.json"):S(oe,"_data",`${t}.json`);try{let n=Q(r,"utf-8");return e.json(JSON.parse(n))}catch{return e.json({error:"not found"},404)}});P.use("/*",Lt({root:oe,onFound:(e,t)=>{t.header("Cache-Control",e.includes("/assets/")?"public, immutable, max-age=31536000":"no-cache")}}));f.output==="static"?console.log("[devix] Static mode \u2014 serving pre-generated files from dist/client"):(ke(P,{renderModule:ee,apiModule:te,manifest:re}),Ue(P,{renderModule:ee,apiModule:te,manifest:re,loaderTimeout:f.loaderTimeout}));It({fetch:P.fetch,port:Ut,hostname:Ht},e=>console.log(`http://${e.address}:${e.port}`))});var We=process.argv[2];switch(We){case"dev":await Promise.resolve().then(()=>(ne(),ot));break;case"build":await Y().then(()=>Oe);break;case"generate":await Le().then(()=>jt);break;case"start":await Be().then(()=>qt);break;case"--version":case"-v":{console.log("0.4.1-beta.13");break}case"--help":case"-h":console.log(`
233
233
  devix \u2014 a lightweight SSR framework
234
234
 
235
235
  Usage:
@@ -1,2 +1,2 @@
1
- import o from"picocolors";import{networkInterfaces as r}from"node:os";function s(e){let l=r();for(let n of Object.values(l))for(let t of n??[])if(t.family==="IPv4"&&!t.internal)return`http://${t.address}:${e}/`;return null}function $(e){let l="0.4.1-beta.12",n=s(e);console.log(),console.log(` ${o.bold(o.yellow("devix"))} ${o.dim(`v${l}`)}`),console.log(),console.log(` ${o.green("\u279C")} ${o.bold("Local:")} ${o.cyan(`http://localhost:${e}/`)}`),console.log(n?` ${o.green("\u279C")} ${o.bold("Network:")} ${o.cyan(n)}`:` ${o.green("\u279C")} ${o.bold("Network:")} ${o.dim("use --host to expose")}`),console.log()}export{$ as printDevBanner};
1
+ import o from"picocolors";import{networkInterfaces as r}from"node:os";function s(e){let l=r();for(let n of Object.values(l))for(let t of n??[])if(t.family==="IPv4"&&!t.internal)return`http://${t.address}:${e}/`;return null}function $(e){let l="0.4.1-beta.13",n=s(e);console.log(),console.log(` ${o.bold(o.yellow("devix"))} ${o.dim(`v${l}`)}`),console.log(),console.log(` ${o.green("\u279C")} ${o.bold("Local:")} ${o.cyan(`http://localhost:${e}/`)}`),console.log(n?` ${o.green("\u279C")} ${o.bold("Network:")} ${o.cyan(n)}`:` ${o.green("\u279C")} ${o.bold("Network:")} ${o.dim("use --host to expose")}`),console.log()}export{$ as printDevBanner};
2
2
  //# sourceMappingURL=banner.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devlusoft/devix",
3
- "version": "0.4.1-beta.12",
3
+ "version": "0.4.1-beta.13",
4
4
  "type": "module",
5
5
  "description": "A lightweight React SSR meta-framework — devix",
6
6
  "author": "devlusoft",
@@ -62,6 +62,7 @@
62
62
  "dependencies": {
63
63
  "@hono/node-server": "1.19.11",
64
64
  "@vitejs/plugin-react": "6.0.1",
65
+ "esbuild": "0.27.4",
65
66
  "hono": "4.12.8",
66
67
  "picocolors": "1.1.1",
67
68
  "oxc-parser": "0.121.0"
@@ -71,7 +72,6 @@
71
72
  "@types/node": "25.5.0",
72
73
  "@types/react": "19.2.14",
73
74
  "@types/react-dom": "19.2.3",
74
- "esbuild": "0.27.4",
75
75
  "jsdom": "29.0.0",
76
76
  "react": "19.2.4",
77
77
  "react-dom": "19.2.4",