@devlusoft/devix 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/build.js CHANGED
@@ -25,6 +25,9 @@ if (!window.__DEVIX__) {
25
25
  const ErrorPage = await loadErrorPage() ?? getDefaultErrorPage()
26
26
  createRoot(root).render(
27
27
  React.createElement(RouterProvider, {
28
+ matchClientRoute,
29
+ loadErrorPage,
30
+ getDefaultErrorPage,
28
31
  clientEntry,
29
32
  initialData: null,
30
33
  initialParams: {},
@@ -41,6 +44,9 @@ if (!window.__DEVIX__) {
41
44
  hydrateRoot(
42
45
  root,
43
46
  React.createElement(RouterProvider, {
47
+ matchClientRoute,
48
+ loadErrorPage,
49
+ getDefaultErrorPage,
44
50
  clientEntry,
45
51
  initialData: loaderData,
46
52
  initialParams: matched.params,
@@ -64,6 +70,9 @@ if (!window.__DEVIX__) {
64
70
  const ErrorPage = await loadErrorPage() ?? getDefaultErrorPage()
65
71
  createRoot(root).render(
66
72
  React.createElement(RouterProvider, {
73
+ matchClientRoute,
74
+ loadErrorPage,
75
+ getDefaultErrorPage,
67
76
  clientEntry,
68
77
  initialData: null,
69
78
  initialParams: {},
@@ -150,8 +159,8 @@ export {}
150
159
  declare module '@devlusoft/devix' {
151
160
  interface ApiRoutes {}
152
161
  }
153
- `;let r=e.map(o=>{let a="../"+o.filePath.replace(/\.(ts|tsx)$/,"");return`import type * as ${o.identifier} from '${a}'`}).join(`
154
- `),i=e.flatMap(o=>o.methods.map(a=>` '${a} ${o.urlPattern}': InferRoute<(typeof ${o.identifier})['${a}']>`)).join(`
162
+ `;let r=e.map(n=>{let a="../"+n.filePath.replace(/\.(ts|tsx)$/,"");return`import type * as ${n.identifier} from '${a}'`}).join(`
163
+ `),i=e.flatMap(n=>n.methods.map(a=>` '${a} ${n.urlPattern}': InferRoute<(typeof ${n.identifier})['${a}']>`)).join(`
155
164
  `);return`// auto-generado por devix \u2014 no editar
156
165
  ${r}
157
166
 
@@ -175,11 +184,11 @@ declare module '@devlusoft/devix' {
175
184
  ${i}
176
185
  }
177
186
  }
178
- `}function Y(e,t){let r=[];for(let i of xe(e)){let o=b(e,i);ye(o).isDirectory()?r.push(...Y(o,t)):/\.(ts|tsx)$/.test(i)&&r.push(he(t,o).replace(/\\/g,"/"))}return r}function A(e,t){let r=b(t,e,"api"),i;try{i=Y(r,t)}catch{return[]}return i.filter(o=>!o.endsWith("middleware.ts")&&!o.endsWith("middleware.tsx")).flatMap(o=>{try{let a=ge(b(t,o),"utf-8"),u=J(a);return u.length===0?[]:[X(o,`${e}/api`,u)]}catch{return[]}})}import{mkdirSync as ve,readFileSync as Re,writeFileSync as _e,existsSync as Ee}from"node:fs";import{join as z}from"node:path";function C(e,t){let r=z(t,".devix"),i=z(r,"routes.d.ts");return ve(r,{recursive:!0}),Ee(i)&&Re(i,"utf-8")===e?!1:(_e(i,e,"utf-8"),!0)}import{parseSync as Ue}from"oxc-parser";function Z({routesPath:e,envPath:t,honoServerPath:r,honoServerStaticPath:i,honoPath:o}){return`
187
+ `}function Y(e,t){let r=[];for(let i of xe(e)){let n=b(e,i);ye(n).isDirectory()?r.push(...Y(n,t)):/\.(ts|tsx)$/.test(i)&&r.push(he(t,n).replace(/\\/g,"/"))}return r}function A(e,t){let r=b(t,e,"api"),i;try{i=Y(r,t)}catch{return[]}return i.filter(n=>!n.endsWith("middleware.ts")&&!n.endsWith("middleware.tsx")).flatMap(n=>{try{let a=ge(b(t,n),"utf-8"),u=J(a);return u.length===0?[]:[X(n,`${e}/api`,u)]}catch{return[]}})}import{mkdirSync as ve,readFileSync as Re,writeFileSync as Ee,existsSync as _e}from"node:fs";import{join as z}from"node:path";function C(e,t){let r=z(t,".devix"),i=z(r,"routes.d.ts");return ve(r,{recursive:!0}),_e(i)&&Re(i,"utf-8")===e?!1:(Ee(i,e,"utf-8"),!0)}import{parseSync as Ue}from"oxc-parser";function Z({routesPath:e,envPath:t,honoServerPath:r,honoServerStaticPath:i,honoPath:n}){return`
179
188
  import { readFileSync } from 'node:fs'
180
189
  import { serve } from '${r}'
181
190
  import { serveStatic } from '${i}'
182
- import { Hono } from '${o}'
191
+ import { Hono } from '${n}'
183
192
  import { resolve, join, dirname } from 'node:path'
184
193
  import { pathToFileURL } from 'node:url'
185
194
  import { registerApiRoutes, registerSsrRoute } from '${e}'
@@ -254,7 +263,7 @@ import { readFileSync } from 'node:fs'
254
263
 
255
264
  process.on('SIGTERM', () => server.close())
256
265
  process.on('SIGINT', () => server.close())
257
- `}import{existsSync as Q,mkdirSync as we,readdirSync as Pe,readFileSync as K,rmSync as Te,statSync as Se,writeFileSync as De}from"node:fs";import{join as x,relative as ee}from"node:path";import{parseSync as $e}from"oxc-parser";function te(e,t){let r=[];for(let i of Pe(e)){let o=x(e,i);Se(o).isDirectory()?r.push(...te(o,t)):/\.(ts|tsx)$/.test(i)&&i!=="layout.tsx"&&i!=="error.tsx"&&r.push(ee(t,o).replace(/\\/g,"/"))}return r}function be(e,t){let r=$e(t,e,{sourceType:"module"});for(let i of r.program.body){if(i.type!=="ExportNamedDeclaration")continue;let o=i.declaration;if(o?.type==="FunctionDeclaration"&&o.id?.name==="loader")return{exists:!0,isAsync:o.async,isReExport:!1};if(o?.type==="VariableDeclaration"){for(let a of o.declarations)if(a.id.type==="Identifier"&&a.id.name==="loader"){let u=a.init;return{exists:!0,isAsync:u?.type==="ArrowFunctionExpression"&&u.async||u?.type==="FunctionExpression"&&u.async,isReExport:!1}}}for(let a of i.specifiers??[])if(a.exported.type==="Identifier"&&a.exported.name==="loader")return{exists:!0,isAsync:!1,isReExport:!0}}return{exists:!1,isAsync:!1,isReExport:!1}}function Ae(e,t){return t?`// auto-generado por devix \u2014 no editar
266
+ `}import{existsSync as Q,mkdirSync as Pe,readdirSync as we,readFileSync as K,rmSync as Te,statSync as Se,writeFileSync as De}from"node:fs";import{join as x,relative as ee}from"node:path";import{parseSync as $e}from"oxc-parser";function te(e,t){let r=[];for(let i of we(e)){let n=x(e,i);Se(n).isDirectory()?r.push(...te(n,t)):/\.(ts|tsx)$/.test(i)&&i!=="layout.tsx"&&i!=="error.tsx"&&r.push(ee(t,n).replace(/\\/g,"/"))}return r}function be(e,t){let r=$e(t,e,{sourceType:"module"});for(let i of r.program.body){if(i.type!=="ExportNamedDeclaration")continue;let n=i.declaration;if(n?.type==="FunctionDeclaration"&&n.id?.name==="loader")return{exists:!0,isAsync:n.async,isReExport:!1};if(n?.type==="VariableDeclaration"){for(let a of n.declarations)if(a.id.type==="Identifier"&&a.id.name==="loader"){let u=a.init;return{exists:!0,isAsync:u?.type==="ArrowFunctionExpression"&&u.async||u?.type==="FunctionExpression"&&u.async,isReExport:!1}}}for(let a of i.specifiers??[])if(a.exported.type==="Identifier"&&a.exported.name==="loader")return{exists:!0,isAsync:!1,isReExport:!0}}return{exists:!1,isAsync:!1,isReExport:!1}}function Ae(e,t){return t?`// auto-generado por devix \u2014 no editar
258
267
  import type { loader } from "${e}"
259
268
  import type { Redirect } from "@devlusoft/devix"
260
269
 
@@ -266,5 +275,5 @@ export type PageParams = NonNullable<Parameters<typeof loader>[0]>["params"]
266
275
  `:`// auto-generado por devix - no editar
267
276
  export type PageData = undefined
268
277
  export type PageParams = Record<string, string>
269
- `}function F(e,t){let r=x(t,e),i=K(r,"utf-8"),o=be(i,r),a=[];o.exists&&!o.isAsync&&!o.isReExport&&a.push(`[devix] ${e}: 'loader' must be async. Use 'export async function loader' or 'export const loader = async (...) => ...'.`);let u=x(t,".devix","pages",e.replace(/\.(tsx?|jsx?)$/,"")),y=x(u,"$types.d.ts"),D=r.replace(/\.(tsx?|jsx?)$/,""),h=ee(u,D).replace(/\\/g,"/"),S=Ae(h,o.exists);return Q(y)&&K(y,"utf-8")===S?{warnings:a}:(we(u,{recursive:!0}),De(y,S,"utf-8"),{warnings:a})}function re(e,t){let r=x(t,".devix","pages",e.replace(/\.(tsx?|jsx?)$/,"")),i=x(r,"$types.d.ts");Q(i)&&Te(i)}function I(e,t){let r=x(t,e,"pages"),i=[],o;try{o=te(r,t)}catch{return{warnings:i}}for(let a of o)try{let u=F(a,t);i.push(...u.warnings)}catch{}return{warnings:i}}var E=Me(Ie(import.meta.url)),M="virtual:devix/entry-client",O="virtual:devix/client-routes",w="virtual:devix/render",P="virtual:devix/api",L="virtual:devix/context",U="virtual:devix/server-entry",ne=new Set(["loader","guard","generateStaticParams","headers"]);function oe(e){let t=e.appDir??"app",r=`${t}/pages`,i=(e.css??[]).map(s=>s.startsWith("/")?s:`/${s.replace(/^\.\//,"")}`),o=p(E,"../server/render.js").replace(/\\/g,"/"),a=p(E,"../server/api.js").replace(/\\/g,"/"),u=p(E,"../runtime/client-router.js").replace(/\\/g,"/"),y=p(E,"../server/routes.js").replace(/\\/g,"/"),D=p(E,"../utils/env.js").replace(/\\/g,"/"),h=Le(import.meta.url),S=h.resolve("@hono/node-server").replace(/\\/g,"/"),ce=h.resolve("@hono/node-server/serve-static").replace(/\\/g,"/"),le=h.resolve("hono").replace(/\\/g,"/"),ue={name:"devix",enforce:"pre",resolveId(s){if(s===M)return`\0${M}`;if(s===O)return`\0${O}`;if(s===w)return`\0${w}`;if(s===P)return`\0${P}`;if(s===L)return`\0${L}`;if(s===U)return`\0${U}`},load(s){if(s===`\0${M}`)return N({cssUrls:i});if(s===`\0${O}`)return k({pagesDir:r,matcherPath:u});if(s===`\0${w}`)return W({pagesDir:r,renderPath:o});if(s===`\0${P}`)return V({apiPath:a,appDir:t});if(s===`\0${L}`)return q();if(s===`\0${U}`)return Z({routesPath:y,envPath:D,honoServerPath:S,honoServerStaticPath:ce,honoPath:le})},transform(s,c,v){if(v?.ssr)return;let g=p(process.cwd(),r);if(!c.startsWith(g))return;let R=Ue(c,s,{sourceType:"module"}),m=[];for(let l of R.program.body){if(l.type!=="ExportNamedDeclaration"||!l.declaration)continue;let n=l.declaration;if(n.type==="FunctionDeclaration"&&n.id&&ne.has(n.id.name)&&m.push({start:l.start,end:l.end,name:n.id.name}),n.type==="VariableDeclaration"){let f=new Set;for(let _ of n.declarations)_.id.type==="Identifier"&&ne.has(_.id.name)&&(f.has(l.start)||(f.add(l.start),m.push({start:l.start,end:l.end,name:_.id.name})))}}if(m.length===0)return;m.sort((l,n)=>n.start-l.start);let d=s;for(let{start:l,end:n,name:f}of m)d=d.slice(0,l)+`export const ${f} = undefined`+d.slice(n);return{code:d,map:null}},buildStart(){let s=process.cwd(),c=A(t,s);C($(c,`${t}/api`),s);let{warnings:v}=I(t,s);for(let g of v)console.warn(g)},configureServer(s){let c=process.cwd(),v=I(t,c);for(let n of v.warnings)console.warn(n);let g=()=>{let n=A(t,c);C($(n,`${t}/api`),c)},R=n=>n.startsWith(p(c,r))&&!n.endsWith("layout.tsx")&&!n.endsWith("error.tsx"),m=n=>Oe(c,n).replace(/\\/g,"/"),d=n=>{let f=s.moduleGraph.getModuleById(`\0${n}`);f&&s.moduleGraph.invalidateModule(f)};s.watcher.add(p(c,"devix.config.ts")),s.watcher.on("change",n=>{n===p(c,"devix.config.ts")&&(console.log("[devix] Config changed, restarting..."),process.exit(75))});let l=n=>{try{let{warnings:f}=F(m(n),c);for(let _ of f)console.warn(_)}catch{}};s.watcher.on("add",n=>{n.startsWith(p(c,r))&&d(w),R(n)&&l(n),n.includes(`${t}/api`)&&(d(P),g())}),s.watcher.on("unlink",n=>{n.startsWith(p(c,r))&&d(w),R(n)&&re(m(n),c),n.includes(`${t}/api`)&&(d(P),g())}),s.watcher.on("change",n=>{R(n)&&l(n),n.includes(`${t}/api`)&&!n.endsWith("middleware.ts")&&g()})}},pe={plugins:[Fe(),ue],publicDir:p(process.cwd(),e.publicDir??"public"),ssr:{noExternal:["@devlusoft/devix"]},...e.envPrefix?{envPrefix:e.envPrefix}:{}};return Ce(pe,e.vite??{})}function ie(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{build as je}from"esbuild";import{join as se}from"node:path";import{unlinkSync as He,writeFileSync as Ne}from"node:fs";import{pathToFileURL as ke}from"node:url";async function ae(e){let t=await je({entryPoints:[se(e,"devix.config.ts")],bundle:!0,write:!1,format:"esm",platform:"node",packages:"external"}),r=se(e,`.devix-config-${Date.now()}.mjs`);Ne(r,t.outputFiles[0].text);try{return(await import(ke(r).href)).default}finally{He(r)}}var T=await ae(process.cwd()),H=oe(T);await j({...H,configFile:!1,build:{outDir:"dist/client",manifest:!0,rolldownOptions:{input:"virtual:devix/entry-client"}}});await j({...H,configFile:!1,build:{ssr:!0,outDir:"dist/server",copyPublicDir:!1,rolldownOptions:{input:{render:"virtual:devix/render",api:"virtual:devix/api"}}}});await j({...H,configFile:!1,build:{ssr:!0,outDir:"dist/server",emptyOutDir:!1,copyPublicDir:!1,rolldownOptions:{input:{index:"virtual:devix/server-entry"}}}});var qe={port:T.port??3e3,host:T.host??!1,loaderTimeout:ie(T.loaderTimeout??1e4),output:T.output??"server"};We(Ve(process.cwd(),"dist/devix.config.json"),JSON.stringify(qe,null,2),"utf-8");
278
+ `}function F(e,t){let r=x(t,e),i=K(r,"utf-8"),n=be(i,r),a=[];n.exists&&!n.isAsync&&!n.isReExport&&a.push(`[devix] ${e}: 'loader' must be async. Use 'export async function loader' or 'export const loader = async (...) => ...'.`);let u=x(t,".devix","pages",e.replace(/\.(tsx?|jsx?)$/,"")),y=x(u,"$types.d.ts"),D=r.replace(/\.(tsx?|jsx?)$/,""),h=ee(u,D).replace(/\\/g,"/"),S=Ae(h,n.exists);return Q(y)&&K(y,"utf-8")===S?{warnings:a}:(Pe(u,{recursive:!0}),De(y,S,"utf-8"),{warnings:a})}function re(e,t){let r=x(t,".devix","pages",e.replace(/\.(tsx?|jsx?)$/,"")),i=x(r,"$types.d.ts");Q(i)&&Te(i)}function I(e,t){let r=x(t,e,"pages"),i=[],n;try{n=te(r,t)}catch{return{warnings:i}}for(let a of n)try{let u=F(a,t);i.push(...u.warnings)}catch{}return{warnings:i}}var _=Me(Ie(import.meta.url)),M="virtual:devix/entry-client",O="virtual:devix/client-routes",P="virtual:devix/render",w="virtual:devix/api",L="virtual:devix/context",U="virtual:devix/server-entry",oe=new Set(["loader","guard","generateStaticParams","headers"]);function ne(e){let t=e.appDir??"app",r=`${t}/pages`,i=(e.css??[]).map(s=>s.startsWith("/")?s:`/${s.replace(/^\.\//,"")}`),n=p(_,"../server/render.js").replace(/\\/g,"/"),a=p(_,"../server/api.js").replace(/\\/g,"/"),u=p(_,"../runtime/client-router.js").replace(/\\/g,"/"),y=p(_,"../server/routes.js").replace(/\\/g,"/"),D=p(_,"../utils/env.js").replace(/\\/g,"/"),h=Le(import.meta.url),S=h.resolve("@hono/node-server").replace(/\\/g,"/"),ce=h.resolve("@hono/node-server/serve-static").replace(/\\/g,"/"),le=h.resolve("hono").replace(/\\/g,"/"),ue={name:"devix",enforce:"pre",resolveId(s){if(s===M)return`\0${M}`;if(s===O)return`\0${O}`;if(s===P)return`\0${P}`;if(s===w)return`\0${w}`;if(s===L)return`\0${L}`;if(s===U)return`\0${U}`},load(s){if(s===`\0${M}`)return N({cssUrls:i});if(s===`\0${O}`)return k({pagesDir:r,matcherPath:u});if(s===`\0${P}`)return W({pagesDir:r,renderPath:n});if(s===`\0${w}`)return V({apiPath:a,appDir:t});if(s===`\0${L}`)return q();if(s===`\0${U}`)return Z({routesPath:y,envPath:D,honoServerPath:S,honoServerStaticPath:ce,honoPath:le})},transform(s,c,v){if(v?.ssr)return;let g=p(process.cwd(),r);if(!c.startsWith(g))return;let R=Ue(c,s,{sourceType:"module"}),m=[];for(let l of R.program.body){if(l.type!=="ExportNamedDeclaration"||!l.declaration)continue;let o=l.declaration;if(o.type==="FunctionDeclaration"&&o.id&&oe.has(o.id.name)&&m.push({start:l.start,end:l.end,name:o.id.name}),o.type==="VariableDeclaration"){let f=new Set;for(let E of o.declarations)E.id.type==="Identifier"&&oe.has(E.id.name)&&(f.has(l.start)||(f.add(l.start),m.push({start:l.start,end:l.end,name:E.id.name})))}}if(m.length===0)return;m.sort((l,o)=>o.start-l.start);let d=s;for(let{start:l,end:o,name:f}of m)d=d.slice(0,l)+`export const ${f} = undefined`+d.slice(o);return{code:d,map:null}},buildStart(){let s=process.cwd(),c=A(t,s);C($(c,`${t}/api`),s);let{warnings:v}=I(t,s);for(let g of v)console.warn(g)},configureServer(s){let c=process.cwd(),v=I(t,c);for(let o of v.warnings)console.warn(o);let g=()=>{let o=A(t,c);C($(o,`${t}/api`),c)},R=o=>o.startsWith(p(c,r))&&!o.endsWith("layout.tsx")&&!o.endsWith("error.tsx"),m=o=>Oe(c,o).replace(/\\/g,"/"),d=o=>{let f=s.moduleGraph.getModuleById(`\0${o}`);f&&s.moduleGraph.invalidateModule(f)};s.watcher.add(p(c,"devix.config.ts")),s.watcher.on("change",o=>{o===p(c,"devix.config.ts")&&(console.log("[devix] Config changed, restarting..."),process.exit(75))});let l=o=>{try{let{warnings:f}=F(m(o),c);for(let E of f)console.warn(E)}catch{}};s.watcher.on("add",o=>{o.startsWith(p(c,r))&&d(P),R(o)&&l(o),o.includes(`${t}/api`)&&(d(w),g())}),s.watcher.on("unlink",o=>{o.startsWith(p(c,r))&&d(P),R(o)&&re(m(o),c),o.includes(`${t}/api`)&&(d(w),g())}),s.watcher.on("change",o=>{R(o)&&l(o),o.includes(`${t}/api`)&&!o.endsWith("middleware.ts")&&g()})}},pe={plugins:[Fe(),ue],publicDir:p(process.cwd(),e.publicDir??"public"),ssr:{noExternal:["@devlusoft/devix"]},...e.envPrefix?{envPrefix:e.envPrefix}:{}};return Ce(pe,e.vite??{})}function ie(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{build as je}from"esbuild";import{join as se}from"node:path";import{unlinkSync as He,writeFileSync as Ne}from"node:fs";import{pathToFileURL as ke}from"node:url";async function ae(e){let t=await je({entryPoints:[se(e,"devix.config.ts")],bundle:!0,write:!1,format:"esm",platform:"node",packages:"external"}),r=se(e,`.devix-config-${Date.now()}.mjs`);Ne(r,t.outputFiles[0].text);try{return(await import(ke(r).href)).default}finally{He(r)}}var T=await ae(process.cwd()),H=ne(T);await j({...H,configFile:!1,build:{outDir:"dist/client",manifest:!0,rolldownOptions:{input:"virtual:devix/entry-client"}}});await j({...H,configFile:!1,build:{ssr:!0,outDir:"dist/server",copyPublicDir:!1,rolldownOptions:{input:{render:"virtual:devix/render",api:"virtual:devix/api"}}}});await j({...H,configFile:!1,build:{ssr:!0,outDir:"dist/server",emptyOutDir:!1,copyPublicDir:!1,rolldownOptions:{input:{index:"virtual:devix/server-entry"}}}});var qe={port:T.port??3e3,host:T.host??!1,loaderTimeout:ie(T.loaderTimeout??1e4),output:T.output??"server"};We(Ve(process.cwd(),"dist/devix.config.json"),JSON.stringify(qe,null,2),"utf-8");
270
279
  //# sourceMappingURL=build.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/cli/build.ts", "../../src/vite/index.ts", "../../src/vite/codegen/entry-client.ts", "../../src/vite/codegen/client-routes.ts", "../../src/vite/codegen/render.ts", "../../src/vite/codegen/api.ts", "../../src/vite/codegen/context.ts", "../../src/vite/codegen/scan-api.ts", "../../src/vite/codegen/extract-methods.ts", "../../src/utils/patterns.ts", "../../src/server/api-router.ts", "../../src/vite/codegen/routes-dts.ts", "../../src/vite/codegen/write-routes-dts.ts", "../../src/vite/codegen/server-entry.ts", "../../src/vite/codegen/page-types.ts", "../../src/utils/duration.ts", "../../src/utils/load-config.ts"],
4
- "sourcesContent": ["import {writeFileSync} from 'node:fs'\nimport {resolve} from 'node:path'\nimport {build} from 'vite'\nimport {devix} from '../vite'\nimport {parseDuration} from '../utils/duration'\nimport {loadConfig} from \"../utils/load-config\";\n\nconst config = await loadConfig(process.cwd())\nconst baseConfig = devix(config)\n\nawait build({\n ...baseConfig,\n configFile: false,\n build: {\n outDir: 'dist/client',\n manifest: true,\n rolldownOptions: {\n input: 'virtual:devix/entry-client',\n },\n },\n})\n\nawait build({\n ...baseConfig,\n configFile: false,\n build: {\n ssr: true,\n outDir: 'dist/server',\n copyPublicDir: false,\n rolldownOptions: {\n input: {\n render: 'virtual:devix/render',\n api: 'virtual:devix/api',\n },\n },\n },\n})\n\nawait build({\n ...baseConfig,\n configFile: false,\n build: {\n ssr: true,\n outDir: 'dist/server',\n emptyOutDir: false,\n copyPublicDir: false,\n rolldownOptions: {\n input: { index: 'virtual:devix/server-entry' },\n },\n },\n})\n\nconst runtimeConfig = {\n port: config.port ?? 3000,\n host: config.host ?? false,\n loaderTimeout: parseDuration(config.loaderTimeout ?? 10_000),\n output: config.output ?? 'server',\n}\n\nwriteFileSync(\n resolve(process.cwd(), 'dist/devix.config.json'),\n JSON.stringify(runtimeConfig, null, 2),\n 'utf-8'\n)\n\n\nexport {}", "import {UserConfig, Plugin, mergeConfig} from 'vite'\nimport type {DevixConfig} from '../config'\nimport react from '@vitejs/plugin-react'\nimport {fileURLToPath} from 'node:url'\nimport {dirname, relative, resolve} from 'node:path'\nimport {createRequire} from 'node:module'\nimport {generateEntryClient} from './codegen/entry-client'\nimport {generateClientRoutes} from './codegen/client-routes'\nimport {generateRender} from './codegen/render'\nimport {generateApi} from './codegen/api'\nimport {generateContext} from \"./codegen/context\";\nimport {scanApiFiles} from \"./codegen/scan-api\";\nimport {generateRoutesDts} from \"./codegen/routes-dts\";\nimport {writeRoutesDts} from \"./codegen/write-routes-dts\";\nimport {parseSync} from 'oxc-parser'\nimport {generateServerEntry} from \"./codegen/server-entry\";\nimport {deletePageTypes, scanAndWritePageTypes, writePageTypes} from \"./codegen/page-types\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\nconst VIRTUAL_ENTRY_CLIENT = 'virtual:devix/entry-client'\nconst VIRTUAL_CLIENT_ROUTES = 'virtual:devix/client-routes'\nconst VIRTUAL_RENDER = 'virtual:devix/render'\nconst VIRTUAL_API = 'virtual:devix/api'\nconst VIRTUAL_CONTEXT = 'virtual:devix/context'\nconst VIRTUAL_SERVER_ENTRY = 'virtual:devix/server-entry'\n\nconst SERVER_EXPORTS = new Set(['loader', 'guard', 'generateStaticParams', 'headers'])\n\nexport function devix(config: DevixConfig): UserConfig {\n const appDir = config.appDir ?? 'app'\n const pagesDir = `${appDir}/pages`\n const cssUrls = (config.css ?? []).map(u => u.startsWith('/') ? u : `/${u.replace(/^\\.\\//, '')}`)\n\n const renderPath = resolve(__dirname, '../server/render.js').replace(/\\\\/g, '/')\n const apiPath = resolve(__dirname, '../server/api.js').replace(/\\\\/g, '/')\n const matcherPath = resolve(__dirname, '../runtime/client-router.js').replace(/\\\\/g, '/')\n const routesPath = resolve(__dirname, '../server/routes.js').replace(/\\\\/g, '/')\n const envPath = resolve(__dirname, '../utils/env.js').replace(/\\\\/g, '/')\n\n const _require = createRequire(import.meta.url)\n const honoServerPath = _require.resolve('@hono/node-server').replace(/\\\\/g, '/')\n const honoServerStaticPath = _require.resolve('@hono/node-server/serve-static').replace(/\\\\/g, '/')\n const honoPath = _require.resolve('hono').replace(/\\\\/g, '/')\n\n const virtualPlugin: Plugin = {\n name: 'devix',\n enforce: 'pre',\n\n resolveId(id) {\n if (id === VIRTUAL_ENTRY_CLIENT) return `\\0${VIRTUAL_ENTRY_CLIENT}`\n if (id === VIRTUAL_CLIENT_ROUTES) return `\\0${VIRTUAL_CLIENT_ROUTES}`\n if (id === VIRTUAL_RENDER) return `\\0${VIRTUAL_RENDER}`\n if (id === VIRTUAL_API) return `\\0${VIRTUAL_API}`\n if (id === VIRTUAL_CONTEXT) return `\\0${VIRTUAL_CONTEXT}`\n if (id === VIRTUAL_SERVER_ENTRY) return `\\0${VIRTUAL_SERVER_ENTRY}`\n },\n\n load(id) {\n if (id === `\\0${VIRTUAL_ENTRY_CLIENT}`)\n return generateEntryClient({cssUrls})\n if (id === `\\0${VIRTUAL_CLIENT_ROUTES}`)\n return generateClientRoutes({pagesDir, matcherPath})\n if (id === `\\0${VIRTUAL_RENDER}`)\n return generateRender({pagesDir, renderPath})\n if (id === `\\0${VIRTUAL_API}`)\n return generateApi({apiPath, appDir})\n if (id === `\\0${VIRTUAL_CONTEXT}`)\n return generateContext()\n if (id === `\\0${VIRTUAL_SERVER_ENTRY}`)\n return generateServerEntry({routesPath, envPath, honoServerPath, honoServerStaticPath, honoPath})\n },\n\n\n transform(code, id, options) {\n if (options?.ssr) return\n\n const resolvedPagesDir = resolve(process.cwd(), pagesDir)\n if (!id.startsWith(resolvedPagesDir)) return\n\n const ast = parseSync(id, code, {sourceType: 'module'})\n\n const replacements: { start: number; end: number; name: string }[] = []\n\n for (const node of ast.program.body) {\n if (node.type !== 'ExportNamedDeclaration' || !node.declaration) continue\n\n const decl = node.declaration\n\n if (decl.type === 'FunctionDeclaration' && decl.id && SERVER_EXPORTS.has(decl.id.name)) {\n replacements.push({start: node.start, end: node.end, name: decl.id.name})\n }\n\n if (decl.type === 'VariableDeclaration') {\n const seen = new Set<number>()\n for (const declarator of decl.declarations) {\n if (declarator.id.type === 'Identifier' && SERVER_EXPORTS.has(declarator.id.name)) {\n if (!seen.has(node.start)) {\n seen.add(node.start)\n replacements.push({start: node.start, end: node.end, name: declarator.id.name})\n }\n }\n }\n }\n }\n\n if (replacements.length === 0) return\n\n replacements.sort((a, b) => b.start - a.start)\n\n let result = code\n for (const {start, end, name} of replacements) {\n result = result.slice(0, start) + `export const ${name} = undefined` + result.slice(end)\n }\n\n return {code: result, map: null}\n },\n\n buildStart() {\n const root = process.cwd()\n const entries = scanApiFiles(appDir, root)\n writeRoutesDts(generateRoutesDts(entries, `${appDir}/api`), root)\n const {warnings} = scanAndWritePageTypes(appDir, root)\n for (const w of warnings) console.warn(w)\n },\n\n configureServer(server) {\n const root = process.cwd()\n\n const initial = scanAndWritePageTypes(appDir, root)\n for (const w of initial.warnings) console.warn(w)\n\n const regenerateDts = () => {\n const entries = scanApiFiles(appDir, root)\n writeRoutesDts(generateRoutesDts(entries, `${appDir}/api`), root)\n }\n\n const isPageFile = (file: string) => file.startsWith(resolve(root, pagesDir)) && !file.endsWith('layout.tsx') && !file.endsWith('error.tsx')\n\n const pageRelPath = (file: string) => relative(root, file).replace(/\\\\/g, '/')\n\n const invalidateVirtualModule = (id: string) => {\n const mod = server.moduleGraph.getModuleById(`\\0${id}`)\n if (mod) server.moduleGraph.invalidateModule(mod)\n }\n\n server.watcher.add(resolve(root, 'devix.config.ts'))\n server.watcher.on('change', (file) => {\n if (file === resolve(root, 'devix.config.ts')) {\n console.log('[devix] Config changed, restarting...')\n process.exit(75)\n }\n })\n\n const writePageTypesAndLog = (file: string) => {\n try {\n const {warnings} = writePageTypes(pageRelPath(file), root)\n for (const w of warnings) console.warn(w)\n } catch {\n /* ignorar archivos no procesables */\n }\n }\n\n server.watcher.on('add', (file) => {\n if (file.startsWith(resolve(root, pagesDir))) invalidateVirtualModule(VIRTUAL_RENDER)\n if (isPageFile(file)) writePageTypesAndLog(file)\n if (file.includes(`${appDir}/api`)) {\n invalidateVirtualModule(VIRTUAL_API)\n regenerateDts()\n }\n })\n server.watcher.on('unlink', (file) => {\n if (file.startsWith(resolve(root, pagesDir))) invalidateVirtualModule(VIRTUAL_RENDER)\n if (isPageFile(file)) deletePageTypes(pageRelPath(file), root)\n if (file.includes(`${appDir}/api`)) {\n invalidateVirtualModule(VIRTUAL_API)\n regenerateDts()\n }\n })\n server.watcher.on('change', (file) => {\n if (isPageFile(file)) writePageTypesAndLog(file)\n if (file.includes(`${appDir}/api`) && !file.endsWith('middleware.ts')) {\n regenerateDts()\n }\n })\n },\n }\n\n const base: UserConfig = {\n plugins: [react(), virtualPlugin],\n publicDir: resolve(process.cwd(), config.publicDir ?? 'public'),\n ssr: {noExternal: ['@devlusoft/devix']},\n ...(config.envPrefix ? {envPrefix: config.envPrefix} : {}),\n }\n\n return mergeConfig(base, config.vite ?? {})\n}", "interface EntryClientOptions {\n cssUrls: string[]\n}\n\nexport function generateEntryClient({ cssUrls }: EntryClientOptions): string {\n const cssImports = cssUrls.map(u => `import '${u}'`).join('\\n')\n\n return `\n${cssImports}\nimport \"@vitejs/plugin-react/preamble\"\nimport React from \"react\"\nimport {hydrateRoot, createRoot} from 'react-dom/client'\nimport {matchClientRoute, loadErrorPage, getDefaultErrorPage} from 'virtual:devix/client-routes'\nimport {RouterProvider} from '@devlusoft/devix'\n\nconst root = document.getElementById('devix-root')\n\nif (!window.__DEVIX__) {\n const ErrorPage = getDefaultErrorPage()\n createRoot(root).render(React.createElement(ErrorPage, {statusCode: 500, message: 'Server error'}))\n} else {\n const {metadata, viewport, clientEntry} = window.__DEVIX__\n const loaderData = window.__LOADER_DATA__\n const layoutsData = window.__LAYOUTS_DATA__ ?? []\n const guardData = window.__GUARD_DATA__ ?? null\n\n const matched = matchClientRoute(window.location.pathname)\n\n if (window.__LOADER_ERROR__) {\n const {statusCode, message, code, data} = window.__LOADER_ERROR__\n const ErrorPage = await loadErrorPage() ?? getDefaultErrorPage()\n createRoot(root).render(\n React.createElement(RouterProvider, {\n clientEntry,\n initialData: null,\n initialParams: {},\n initialPage: () => null,\n initialError: {statusCode, message, code, data},\n initialErrorPage: ErrorPage,\n })\n )\n } else if (matched) {\n const [pageMod, ...layoutMods] = await Promise.all([\n matched.load(),\n ...matched.loadLayouts.map(l => l()),\n ])\n hydrateRoot(\n root,\n React.createElement(RouterProvider, {\n clientEntry,\n initialData: loaderData,\n initialParams: matched.params,\n initialPage: pageMod.default,\n initialLayouts: layoutMods.map(m => m.default),\n initialLayoutsData: layoutsData,\n initialGuardData: guardData,\n initialMeta: metadata,\n initialViewport: viewport,\n })\n )\n\n if (window.location.hash) { \n const id = window.location.hash.slice(1) \n const scrollBehavior = getComputedStyle(document.documentElement).scrollBehavior \n requestAnimationFrame(() => { \n document.getElementById(id)?.scrollIntoView({ behavior: scrollBehavior }) \n }) \n } \n } else {\n const ErrorPage = await loadErrorPage() ?? getDefaultErrorPage()\n createRoot(root).render(\n React.createElement(RouterProvider, {\n clientEntry,\n initialData: null,\n initialParams: {},\n initialPage: () => null,\n initialLayouts: [],\n initialLayoutsData: [],\n initialMeta: null,\n initialError: {statusCode: 404, message: 'Not found'},\n initialErrorPage: ErrorPage,\n })\n )\n }\n}\n`\n}", "interface ClientRoutesOptions {\n pagesDir: string\n matcherPath: string\n}\n\nexport function generateClientRoutes({pagesDir, matcherPath}: ClientRoutesOptions) {\n return `\nimport React from 'react'\nimport { createMatcher } from '${matcherPath}'\nconst pageFiles = import.meta.glob(['/${pagesDir}/**/*.tsx', '!**/error.tsx', '!**/layout.tsx'])\nconst layoutFiles = import.meta.glob('/${pagesDir}/**/layout.tsx')\nconst errorFiles = import.meta.glob('/${pagesDir}/**/error.tsx')\n\nexport const matchClientRoute = createMatcher(pageFiles, layoutFiles)\n\nexport async function loadErrorPage() {\n const key = Object.keys(errorFiles)[0]\n if (!key) return null\n const mod = await errorFiles[key]()\n return mod?.default ?? null\n}\n\nexport function getDefaultErrorPage() {\n return function DefaultError({ statusCode, message }) {\n return React.createElement('main', {\n style: { minHeight: '100dvh', display: 'flex', flexDirection: 'column', \n alignItems: 'center', justifyContent: 'center', gap: '8px',\n fontFamily: 'system-ui, sans-serif' }\n },\n React.createElement('h1', {style: {fontSize: '4rem', fontWeight: 700}}, statusCode),\n React.createElement('p', {style: {color: '#666'}}, message ?? 'An unexpected error occurred'),\n )\n }\n}\n`\n}", "interface RenderOptions {\n pagesDir: string\n renderPath: string\n}\n\nexport function generateRender({pagesDir, renderPath}: RenderOptions): string {\n return `\nimport { render as _render, runLoader as _runLoader, getStaticRoutes as _getStaticRoutes } from '${renderPath}'\n\nconst _pages = import.meta.glob(['/${pagesDir}/**/*.tsx', '!**/error.tsx', '!**/layout.tsx'])\nconst _layouts = import.meta.glob('/${pagesDir}/**/layout.tsx')\n\nconst _glob = {\n pages: _pages,\n layouts: _layouts,\n pagesDir: '/${pagesDir}',\n}\n\nexport function render(url, request, options) {\n return _render(url, request, _glob, options)\n}\n\nexport function runLoader(url, request, options) {\n return _runLoader(url, request, _glob, options)\n}\n\nexport function getStaticRoutes() {\n return _getStaticRoutes(_glob)\n}\n`\n}\n", "interface ApiOptions {\n apiPath: string\n appDir: string\n}\n\nexport function generateApi({apiPath, appDir}: ApiOptions): string {\n return `\nimport { handleApiRequest as _handleApiRequest } from '${apiPath}'\n\nconst _routes = import.meta.glob(['/${appDir}/api/**/*.ts', '!**/middleware.ts'])\nconst _middlewares = import.meta.glob('/${appDir}/api/**/middleware.ts')\n\nconst _glob = {\n routes: _routes,\n middlewares: _middlewares,\n apiDir: '/${appDir}/api',\n}\n\nexport function handleApiRequest(url, request) {\n return _handleApiRequest(url, request, _glob)\n}\n`\n}\n", "export function generateContext(): string {\n return `\nexport {RouterContext} from '@devlusoft/devix/runtime/context'\n`\n}", "import {readFileSync, readdirSync, statSync} from 'node:fs'\nimport {join, relative} from 'node:path'\nimport {extractHttpMethods} from './extract-methods'\nimport {buildRouteEntry} from './routes-dts'\nimport type {RouteEntry} from './routes-dts'\n\nfunction walkDir(dir: string, root: string): string[] {\n const entries: string[] = []\n for (const name of readdirSync(dir)) {\n const full = join(dir, name)\n if (statSync(full).isDirectory()) {\n entries.push(...walkDir(full, root))\n } else if (/\\.(ts|tsx)$/.test(name)) {\n entries.push(relative(root, full).replace(/\\\\/g, '/'))\n }\n }\n return entries\n}\n\nexport function scanApiFiles(appDir: string, projectRoot: string): RouteEntry[] {\n const apiDir = join(projectRoot, appDir, 'api')\n\n let files: string[]\n try {\n files = walkDir(apiDir, projectRoot)\n } catch {\n return []\n }\n\n return files\n .filter(f => !f.endsWith('middleware.ts') && !f.endsWith('middleware.tsx'))\n .flatMap(filePath => {\n try {\n const content = readFileSync(join(projectRoot, filePath), 'utf-8')\n const methods = extractHttpMethods(content)\n if (methods.length === 0) return []\n return [buildRouteEntry(filePath, `${appDir}/api`, methods)]\n } catch {\n return []\n }\n })\n}\n", "const HTTP_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'] as const\nexport type HttpMethod = (typeof HTTP_METHODS)[number]\n\nconst METHOD_EXPORT_RE = /export\\s+(?:const|async\\s+function|function)\\s+(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\\b/g\n\nfunction stripComments(content: string): string {\n return content\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n .replace(/\\/\\/.*$/gm, '')\n}\n\nexport function extractHttpMethods(content: string): HttpMethod[] {\n const found = new Set<HttpMethod>()\n for (const match of stripComments(content).matchAll(METHOD_EXPORT_RE)) {\n found.add(match[1] as HttpMethod)\n }\n return [...found]\n}\n", "export function routePattern(rel: string): string {\n return rel\n .replace(/\\.(tsx|ts|jsx|js)$/, '')\n .replace(/\\(.*?\\)\\//g, '')\n .replace(/^index$|\\/index$/, '')\n .replace(/\\[([^\\]]+)]/g, ':$1')\n || '/'\n}", "import {routePattern} from \"../utils/patterns\";\n\nexport interface ApiRoute {\n path: string\n key: string\n params: string[]\n regex: RegExp\n}\n\nexport interface ApiMiddleware {\n dir: string\n key: string\n}\n\nexport interface ApiResult {\n routes: ApiRoute[]\n middlewares: ApiMiddleware[]\n}\n\nexport function keyToRoutePattern(key: string, apiDir: string): string {\n const rel = key.slice(apiDir.length + 1).replace(/\\\\/g, '/')\n const pattern = routePattern(rel)\n return pattern === '/' ? '/api' : `/api/${pattern}`.replace('/api//', '/api/')\n}\n\nfunction keyToDir(key: string): string {\n return key.slice(0, key.lastIndexOf('/'))\n}\n\nexport function buildRoutes(routeKeys: string[], middlewareKeys: string[], apiDir: string): ApiResult {\n const routes: ApiRoute[] = []\n const middlewares: ApiMiddleware[] = []\n\n for (const key of middlewareKeys) {\n middlewares.push({dir: keyToDir(key), key})\n }\n\n for (const key of routeKeys) {\n const pattern = keyToRoutePattern(key, apiDir)\n const params = [...pattern.matchAll(/:([^/]+)/g)].map(m => m[1])\n const regexStr = pattern\n .replace(/:[^/]+/g, '([^/]+)')\n .replace(/\\//g, '\\\\/')\n routes.push({path: pattern, key, params, regex: new RegExp(`^${regexStr}$`)})\n }\n routes.sort((a, b) => {\n const aScore = (a.path.match(/:/g) || []).length\n const bScore = (b.path.match(/:/g) || []).length\n if (aScore !== bScore) return aScore - bScore\n return b.path.length - a.path.length\n })\n\n return {routes, middlewares}\n}\n\nexport function collectMiddlewareChain(routeKey: string, middlewares: ApiMiddleware[]): ApiMiddleware[] {\n const routeDir = keyToDir(routeKey)\n\n return middlewares\n .filter(mw => routeDir.startsWith(mw.dir))\n .sort((a, b) => a.dir.split('/').length - b.dir.split('/').length)\n}\n\nexport function matchRoute(\n pathname: string,\n routes: ApiRoute[]\n): { route: ApiRoute; params: Record<string, string> } | null {\n for (const route of routes) {\n const match = pathname.match(route.regex)\n if (match) {\n const params: Record<string, string> = {}\n route.params.forEach((name, i) => {\n params[name] = decodeURIComponent(match[i + 1])\n })\n return {route, params}\n }\n }\n return null\n}\n", "import { keyToRoutePattern } from '../../server/api-router'\nimport type { HttpMethod } from './extract-methods'\n\nexport interface RouteEntry {\n filePath: string\n urlPattern: string\n identifier: string\n methods: HttpMethod[]\n}\n\nexport function filePathToIdentifier(filePath: string, apiDir: string): string {\n return '_api_' + filePath\n .slice(`${apiDir}/`.length)\n .replace(/\\.(ts|tsx)$/, '')\n .replace(/[^a-zA-Z0-9]/g, '_')\n}\n\nexport function buildRouteEntry(filePath: string, apiDir: string, methods: HttpMethod[]): RouteEntry {\n return {\n filePath,\n urlPattern: keyToRoutePattern(filePath, apiDir),\n identifier: filePathToIdentifier(filePath, apiDir),\n methods,\n }\n}\n\nexport function generateRoutesDts(entries: RouteEntry[], apiDir: string): string {\n if (entries.length === 0) {\n return `// auto-generado por devix \u2014 no editar\\nexport {}\\ndeclare module '@devlusoft/devix' {\\n interface ApiRoutes {}\\n}\\n`\n }\n\n const imports = entries\n .map(e => {\n const importPath = '../' + e.filePath.replace(/\\.(ts|tsx)$/, '')\n return `import type * as ${e.identifier} from '${importPath}'`\n })\n .join('\\n')\n\n const routeLines = entries.flatMap(e =>\n e.methods.map(m =>\n ` '${m} ${e.urlPattern}': InferRoute<(typeof ${e.identifier})['${m}']>`\n )\n ).join('\\n')\n\n return `// auto-generado por devix \u2014 no editar\n${imports}\n\ntype JsonResponse<T, S extends number = number> = Response & { readonly __body: T; readonly __status: S }\ntype Is2xx<S extends number> = [number] extends [S] ? boolean : S extends 200 | 201 | 202 | 203 | 204 | 205 | 206 ? true : false\ntype UnwrapSuccessJson<T> = T extends JsonResponse<infer U, infer S> ? Is2xx<S> extends false ? never : U : never\ntype UnwrapErrorJson<T> = T extends JsonResponse<infer U, infer S> ? Is2xx<S> extends true ? never : U : never\ntype InferFnSuccess<T> = T extends (...args: any[]) => any ? UnwrapSuccessJson<Awaited<ReturnType<T>>> : never\ntype InferFnErrors<T> = T extends (...args: any[]) => any ? UnwrapErrorJson<Awaited<ReturnType<T>>> : never\ntype InferRoute<T> =\n T extends { readonly __return?: infer TReturn; readonly __body?: infer TBody }\n ? {\n __body: [TBody] extends [undefined] ? never : Exclude<TBody, undefined>\n __response: InferFnSuccess<() => TReturn>\n __errors: InferFnErrors<() => TReturn>\n }\n : InferFnSuccess<T>\n\ndeclare module '@devlusoft/devix' {\n interface ApiRoutes {\n${routeLines}\n }\n}\n`\n}\n", "import {mkdirSync, readFileSync, writeFileSync, existsSync} from 'node:fs'\nimport {join} from 'node:path'\n\nexport function writeRoutesDts(content: string, projectRoot: string): boolean {\n const devixDir = join(projectRoot, '.devix')\n const outPath = join(devixDir, 'routes.d.ts')\n\n mkdirSync(devixDir, {recursive: true})\n\n if (existsSync(outPath) && readFileSync(outPath, 'utf-8') === content) {\n return false\n }\n\n writeFileSync(outPath, content, 'utf-8')\n return true\n}\n", "interface ServerEntryOptions {\n routesPath: string\n envPath: string\n honoServerPath: string\n honoServerStaticPath: string\n honoPath: string\n}\n\nexport function generateServerEntry({ routesPath, envPath, honoServerPath, honoServerStaticPath, honoPath }: ServerEntryOptions): string {\n return `\nimport { readFileSync } from 'node:fs'\n import { serve } from '${honoServerPath}'\n import { serveStatic } from '${honoServerStaticPath}'\n import { Hono } from '${honoPath}'\n import { resolve, join, dirname } from 'node:path'\n import { pathToFileURL } from 'node:url'\n import { registerApiRoutes, registerSsrRoute } from '${routesPath}' \n import { loadDotenv } from '${envPath}'\n \n loadDotenv('production')\n \n const __dir = dirname(process.argv[1])\n\n let renderModule, apiModule, manifest, runtimeConfig \n \n try { \n runtimeConfig = JSON.parse(readFileSync(resolve(__dir, '../devix.config.json'), 'utf-8'))\n if (runtimeConfig.output !== 'static') { \n renderModule = await import(pathToFileURL(resolve(__dir, 'render.js')).href)\n apiModule = await import(pathToFileURL(resolve(__dir, 'api.js')).href) \n } \n manifest = JSON.parse(readFileSync(resolve(__dir, '../client/.vite/manifest.json'), 'utf-8')) \n } catch { \n console.error('[devix] Build not found. Run \"devix build\" first.')\n process.exit(1) \n } \n \n const port = Number(process.env.PORT) || runtimeConfig.port || 3000 \n const host = typeof runtimeConfig.host === 'string'\n ? runtimeConfig.host \n : runtimeConfig.host ? '0.0.0.0' : (process.env.HOST || '0.0.0.0') \n \n const clientRoot = resolve(__dir, '../client') \n const app = new Hono()\n \n if (runtimeConfig.output === 'static') {\n app.get('/_data/*', (c) => {\n const pathname = c.req.path.replace(/^\\\\/_data/, '') || '/' \n const filePath = pathname === '/' \n ? join(clientRoot, '_data/index.json') \n : join(clientRoot, '_data', pathname + '.json') \n try { \n return c.json(JSON.parse(readFileSync(filePath, 'utf-8')))\n } catch { \n return c.json({ error: 'not found' }, 404)\n } \n }) \n }\n\n app.use('/*', serveStatic({ \n root: clientRoot,\n onFound: (_path, c) => { \n c.header('Cache-Control', _path.includes('/assets/') \n ? 'public, immutable, max-age=31536000'\n : 'no-cache') \n } \n })) \n \n if (runtimeConfig.output === 'static') {\n console.log('[devix] Static mode \u2014 serving pre-generated files from dist/client')\n } else {\n let userServerConfig\n try {\n const userConfigMod = await import(pathToFileURL(resolve(process.cwd(), 'devix.config.ts')).href).catch(() =>\n import(pathToFileURL(resolve(process.cwd(), 'devix.config.js')).href))\n userServerConfig = userConfigMod?.default?.server\n } catch {\n /* config sin server \u2014 sigue normal */\n }\n registerApiRoutes(app, { renderModule, apiModule, manifest, server: userServerConfig })\n registerSsrRoute(app, { renderModule, apiModule, manifest, loaderTimeout: runtimeConfig.loaderTimeout, server: userServerConfig })\n } \n \n const server = serve({ fetch: app.fetch, port, hostname: host }, (info) => \n console.log(\\`http://\\${info.address}:\\${info.port}\\`))\n\nprocess.on('SIGTERM', () => server.close())\nprocess.on('SIGINT', () => server.close())\n`\n}", "import {existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync} from \"node:fs\";\nimport {join, relative} from \"node:path\";\nimport {parseSync} from \"oxc-parser\";\n\nfunction walkPages(dir: string, root: string): string[] {\n const entries: string[] = []\n for (const name of readdirSync(dir)) {\n const full = join(dir, name)\n if (statSync(full).isDirectory()) {\n entries.push(...walkPages(full, root))\n } else if (/\\.(ts|tsx)$/.test(name) && name !== 'layout.tsx' && name !== 'error.tsx') {\n entries.push(relative(root, full).replace(/\\\\/g, '/'))\n }\n }\n return entries\n}\n\nexport interface LoaderExportInfo {\n exists: boolean\n isAsync: boolean\n isReExport: boolean\n}\n\nexport function inspectLoaderExport(code: string, filePath: string): LoaderExportInfo {\n const ast = parseSync(filePath, code, {sourceType: 'module'})\n for (const node of ast.program.body) {\n if (node.type !== 'ExportNamedDeclaration') continue\n const decl = node.declaration\n if (decl?.type === 'FunctionDeclaration' && decl.id?.name === 'loader') {\n return {exists: true, isAsync: decl.async, isReExport: false}\n }\n if (decl?.type === 'VariableDeclaration') {\n for (const d of decl.declarations) {\n if (d.id.type === 'Identifier' && d.id.name === 'loader') {\n const init = d.init\n const isAsync =\n (init?.type === 'ArrowFunctionExpression' && init.async) ||\n (init?.type === 'FunctionExpression' && init.async)\n return {exists: true, isAsync, isReExport: false}\n }\n }\n }\n for (const spec of (node.specifiers ?? [])) {\n if (spec.exported.type === 'Identifier' && spec.exported.name === 'loader') {\n return {exists: true, isAsync: false, isReExport: true}\n }\n }\n }\n return {exists: false, isAsync: false, isReExport: false}\n}\n\nexport function hasLoaderExport(code: string, filePath: string): boolean {\n return inspectLoaderExport(code, filePath).exists\n}\n\nexport function generatePageTypesDts(importPath: string, withLoader: boolean): string {\n if (!withLoader) {\n return '// auto-generado por devix - no editar\\nexport type PageData = undefined\\nexport type PageParams = Record<string, string>\\n'\n }\n return `// auto-generado por devix \u2014 no editar\\nimport type { loader } from \"${importPath}\"\\nimport type { Redirect } from \"@devlusoft/devix\"\\n\\nexport type PageData = Exclude<\\n Awaited<ReturnType<NonNullable<typeof loader>>>,\\n Redirect | void | undefined\\n>\\nexport type PageParams = NonNullable<Parameters<typeof loader>[0]>[\"params\"]\\n`\n}\n\nexport interface WritePageTypesResult {\n warnings: string[]\n}\n\nexport function writePageTypes(pageRelPath: string, root: string): WritePageTypesResult {\n const fullPath = join(root, pageRelPath)\n const code = readFileSync(fullPath, 'utf-8')\n const loaderInfo = inspectLoaderExport(code, fullPath)\n const warnings: string[] = []\n\n if (loaderInfo.exists && !loaderInfo.isAsync && !loaderInfo.isReExport) {\n warnings.push(\n `[devix] ${pageRelPath}: 'loader' must be async. ` +\n `Use 'export async function loader' or 'export const loader = async (...) => ...'.`\n )\n }\n\n const typesDir = join(root, '.devix', 'pages', pageRelPath.replace(/\\.(tsx?|jsx?)$/, ''))\n const outPath = join(typesDir, '$types.d.ts')\n\n const pageAbsNoExt = fullPath.replace(/\\.(tsx?|jsx?)$/, '')\n const importPath = relative(typesDir, pageAbsNoExt).replace(/\\\\/g, '/')\n\n const content = generatePageTypesDts(importPath, loaderInfo.exists)\n\n if (existsSync(outPath) && readFileSync(outPath, 'utf-8') === content) return {warnings}\n\n mkdirSync(typesDir, {recursive: true})\n writeFileSync(outPath, content, 'utf-8')\n return {warnings}\n}\n\nexport function deletePageTypes(pageRelPath: string, root: string): void {\n const typesDir = join(root, '.devix', 'pages', pageRelPath.replace(/\\.(tsx?|jsx?)$/, ''))\n const outPath = join(typesDir, '$types.d.ts')\n if (existsSync(outPath)) rmSync(outPath)\n}\n\nexport function scanAndWritePageTypes(appDir: string, root: string): WritePageTypesResult {\n const pagesDir = join(root, appDir, 'pages')\n const warnings: string[] = []\n let files: string[]\n try {\n files = walkPages(pagesDir, root)\n } catch {\n return {warnings}\n }\n for (const file of files) {\n try {\n const result = writePageTypes(file, root)\n warnings.push(...result.warnings)\n } catch {\n /* ignorar archivos no procesables */\n }\n }\n return {warnings}\n}", "export function parseDuration(value: number | string): number {\n if (typeof value === 'number') return value\n const match = value.trim().match(/^(\\d+(?:\\.\\d+)?)\\s*(ms|s|m|h)?$/)\n if (!match) throw new Error(`[devix] Invalid duration: \"${value}\". Use a number (ms) or a string like \"5s\", \"2m\", \"500ms\".`)\n const n = parseFloat(match[1])\n switch (match[2]) {\n case 'h': return n * 3_600_000\n case 'm': return n * 60_000\n case 's': return n * 1_000\n case 'ms':\n default: return n\n }\n}\n", "import {build} from 'esbuild'\nimport type {DevixConfig} from \"../config\"\nimport {join} from \"node:path\"\nimport {unlinkSync, writeFileSync} from \"node:fs\";\nimport {pathToFileURL} from \"node:url\";\n\nexport async function loadConfig(cwd: string): Promise<DevixConfig> {\n const result = await build({\n entryPoints: [join(cwd, 'devix.config.ts')],\n bundle: true,\n write: false,\n format: 'esm',\n platform: 'node',\n packages: 'external',\n })\n\n const tmpFile = join(cwd, `.devix-config-${Date.now()}.mjs`)\n writeFileSync(tmpFile, result.outputFiles[0].text)\n\n try {\n const mod = await import(pathToFileURL(tmpFile).href)\n return mod.default\n } finally {\n unlinkSync(tmpFile)\n }\n}"],
5
- "mappings": "AAAA,OAAQ,iBAAAA,OAAoB,UAC5B,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H,WAAY,GACZ,MAAO,CACH,IAAK,GACL,OAAQ,cACR,cAAe,GACf,gBAAiB,CACb,MAAO,CACH,OAAQ,uBACR,IAAK,mBACT,CACJ,CACJ,CACJ,CAAC,EAED,MAAME,EAAM,CACR,GAAGF,EACH,WAAY,GACZ,MAAO,CACH,IAAK,GACL,OAAQ,cACR,YAAa,GACb,cAAe,GACf,gBAAiB,CACb,MAAO,CAAE,MAAO,4BAA6B,CACjD,CACJ,CACJ,CAAC,EAED,IAAMG,GAAgB,CAClB,KAAML,EAAO,MAAQ,IACrB,KAAMA,EAAO,MAAQ,GACrB,cAAeM,GAAcN,EAAO,eAAiB,GAAM,EAC3D,OAAQA,EAAO,QAAU,QAC7B,EAEAO,GACIC,GAAQ,QAAQ,IAAI,EAAG,wBAAwB,EAC/C,KAAK,UAAUH,GAAe,KAAM,CAAC,EACrC,OACJ",
4
+ "sourcesContent": ["import {writeFileSync} from 'node:fs'\nimport {resolve} from 'node:path'\nimport {build} from 'vite'\nimport {devix} from '../vite'\nimport {parseDuration} from '../utils/duration'\nimport {loadConfig} from \"../utils/load-config\";\n\nconst config = await loadConfig(process.cwd())\nconst baseConfig = devix(config)\n\nawait build({\n ...baseConfig,\n configFile: false,\n build: {\n outDir: 'dist/client',\n manifest: true,\n rolldownOptions: {\n input: 'virtual:devix/entry-client',\n },\n },\n})\n\nawait build({\n ...baseConfig,\n configFile: false,\n build: {\n ssr: true,\n outDir: 'dist/server',\n copyPublicDir: false,\n rolldownOptions: {\n input: {\n render: 'virtual:devix/render',\n api: 'virtual:devix/api',\n },\n },\n },\n})\n\nawait build({\n ...baseConfig,\n configFile: false,\n build: {\n ssr: true,\n outDir: 'dist/server',\n emptyOutDir: false,\n copyPublicDir: false,\n rolldownOptions: {\n input: { index: 'virtual:devix/server-entry' },\n },\n },\n})\n\nconst runtimeConfig = {\n port: config.port ?? 3000,\n host: config.host ?? false,\n loaderTimeout: parseDuration(config.loaderTimeout ?? 10_000),\n output: config.output ?? 'server',\n}\n\nwriteFileSync(\n resolve(process.cwd(), 'dist/devix.config.json'),\n JSON.stringify(runtimeConfig, null, 2),\n 'utf-8'\n)\n\n\nexport {}", "import {UserConfig, Plugin, mergeConfig} from 'vite'\nimport type {DevixConfig} from '../config'\nimport react from '@vitejs/plugin-react'\nimport {fileURLToPath} from 'node:url'\nimport {dirname, relative, resolve} from 'node:path'\nimport {createRequire} from 'node:module'\nimport {generateEntryClient} from './codegen/entry-client'\nimport {generateClientRoutes} from './codegen/client-routes'\nimport {generateRender} from './codegen/render'\nimport {generateApi} from './codegen/api'\nimport {generateContext} from \"./codegen/context\";\nimport {scanApiFiles} from \"./codegen/scan-api\";\nimport {generateRoutesDts} from \"./codegen/routes-dts\";\nimport {writeRoutesDts} from \"./codegen/write-routes-dts\";\nimport {parseSync} from 'oxc-parser'\nimport {generateServerEntry} from \"./codegen/server-entry\";\nimport {deletePageTypes, scanAndWritePageTypes, writePageTypes} from \"./codegen/page-types\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\nconst VIRTUAL_ENTRY_CLIENT = 'virtual:devix/entry-client'\nconst VIRTUAL_CLIENT_ROUTES = 'virtual:devix/client-routes'\nconst VIRTUAL_RENDER = 'virtual:devix/render'\nconst VIRTUAL_API = 'virtual:devix/api'\nconst VIRTUAL_CONTEXT = 'virtual:devix/context'\nconst VIRTUAL_SERVER_ENTRY = 'virtual:devix/server-entry'\n\nconst SERVER_EXPORTS = new Set(['loader', 'guard', 'generateStaticParams', 'headers'])\n\nexport function devix(config: DevixConfig): UserConfig {\n const appDir = config.appDir ?? 'app'\n const pagesDir = `${appDir}/pages`\n const cssUrls = (config.css ?? []).map(u => u.startsWith('/') ? u : `/${u.replace(/^\\.\\//, '')}`)\n\n const renderPath = resolve(__dirname, '../server/render.js').replace(/\\\\/g, '/')\n const apiPath = resolve(__dirname, '../server/api.js').replace(/\\\\/g, '/')\n const matcherPath = resolve(__dirname, '../runtime/client-router.js').replace(/\\\\/g, '/')\n const routesPath = resolve(__dirname, '../server/routes.js').replace(/\\\\/g, '/')\n const envPath = resolve(__dirname, '../utils/env.js').replace(/\\\\/g, '/')\n\n const _require = createRequire(import.meta.url)\n const honoServerPath = _require.resolve('@hono/node-server').replace(/\\\\/g, '/')\n const honoServerStaticPath = _require.resolve('@hono/node-server/serve-static').replace(/\\\\/g, '/')\n const honoPath = _require.resolve('hono').replace(/\\\\/g, '/')\n\n const virtualPlugin: Plugin = {\n name: 'devix',\n enforce: 'pre',\n\n resolveId(id) {\n if (id === VIRTUAL_ENTRY_CLIENT) return `\\0${VIRTUAL_ENTRY_CLIENT}`\n if (id === VIRTUAL_CLIENT_ROUTES) return `\\0${VIRTUAL_CLIENT_ROUTES}`\n if (id === VIRTUAL_RENDER) return `\\0${VIRTUAL_RENDER}`\n if (id === VIRTUAL_API) return `\\0${VIRTUAL_API}`\n if (id === VIRTUAL_CONTEXT) return `\\0${VIRTUAL_CONTEXT}`\n if (id === VIRTUAL_SERVER_ENTRY) return `\\0${VIRTUAL_SERVER_ENTRY}`\n },\n\n load(id) {\n if (id === `\\0${VIRTUAL_ENTRY_CLIENT}`)\n return generateEntryClient({cssUrls})\n if (id === `\\0${VIRTUAL_CLIENT_ROUTES}`)\n return generateClientRoutes({pagesDir, matcherPath})\n if (id === `\\0${VIRTUAL_RENDER}`)\n return generateRender({pagesDir, renderPath})\n if (id === `\\0${VIRTUAL_API}`)\n return generateApi({apiPath, appDir})\n if (id === `\\0${VIRTUAL_CONTEXT}`)\n return generateContext()\n if (id === `\\0${VIRTUAL_SERVER_ENTRY}`)\n return generateServerEntry({routesPath, envPath, honoServerPath, honoServerStaticPath, honoPath})\n },\n\n\n transform(code, id, options) {\n if (options?.ssr) return\n\n const resolvedPagesDir = resolve(process.cwd(), pagesDir)\n if (!id.startsWith(resolvedPagesDir)) return\n\n const ast = parseSync(id, code, {sourceType: 'module'})\n\n const replacements: { start: number; end: number; name: string }[] = []\n\n for (const node of ast.program.body) {\n if (node.type !== 'ExportNamedDeclaration' || !node.declaration) continue\n\n const decl = node.declaration\n\n if (decl.type === 'FunctionDeclaration' && decl.id && SERVER_EXPORTS.has(decl.id.name)) {\n replacements.push({start: node.start, end: node.end, name: decl.id.name})\n }\n\n if (decl.type === 'VariableDeclaration') {\n const seen = new Set<number>()\n for (const declarator of decl.declarations) {\n if (declarator.id.type === 'Identifier' && SERVER_EXPORTS.has(declarator.id.name)) {\n if (!seen.has(node.start)) {\n seen.add(node.start)\n replacements.push({start: node.start, end: node.end, name: declarator.id.name})\n }\n }\n }\n }\n }\n\n if (replacements.length === 0) return\n\n replacements.sort((a, b) => b.start - a.start)\n\n let result = code\n for (const {start, end, name} of replacements) {\n result = result.slice(0, start) + `export const ${name} = undefined` + result.slice(end)\n }\n\n return {code: result, map: null}\n },\n\n buildStart() {\n const root = process.cwd()\n const entries = scanApiFiles(appDir, root)\n writeRoutesDts(generateRoutesDts(entries, `${appDir}/api`), root)\n const {warnings} = scanAndWritePageTypes(appDir, root)\n for (const w of warnings) console.warn(w)\n },\n\n configureServer(server) {\n const root = process.cwd()\n\n const initial = scanAndWritePageTypes(appDir, root)\n for (const w of initial.warnings) console.warn(w)\n\n const regenerateDts = () => {\n const entries = scanApiFiles(appDir, root)\n writeRoutesDts(generateRoutesDts(entries, `${appDir}/api`), root)\n }\n\n const isPageFile = (file: string) => file.startsWith(resolve(root, pagesDir)) && !file.endsWith('layout.tsx') && !file.endsWith('error.tsx')\n\n const pageRelPath = (file: string) => relative(root, file).replace(/\\\\/g, '/')\n\n const invalidateVirtualModule = (id: string) => {\n const mod = server.moduleGraph.getModuleById(`\\0${id}`)\n if (mod) server.moduleGraph.invalidateModule(mod)\n }\n\n server.watcher.add(resolve(root, 'devix.config.ts'))\n server.watcher.on('change', (file) => {\n if (file === resolve(root, 'devix.config.ts')) {\n console.log('[devix] Config changed, restarting...')\n process.exit(75)\n }\n })\n\n const writePageTypesAndLog = (file: string) => {\n try {\n const {warnings} = writePageTypes(pageRelPath(file), root)\n for (const w of warnings) console.warn(w)\n } catch {\n /* ignorar archivos no procesables */\n }\n }\n\n server.watcher.on('add', (file) => {\n if (file.startsWith(resolve(root, pagesDir))) invalidateVirtualModule(VIRTUAL_RENDER)\n if (isPageFile(file)) writePageTypesAndLog(file)\n if (file.includes(`${appDir}/api`)) {\n invalidateVirtualModule(VIRTUAL_API)\n regenerateDts()\n }\n })\n server.watcher.on('unlink', (file) => {\n if (file.startsWith(resolve(root, pagesDir))) invalidateVirtualModule(VIRTUAL_RENDER)\n if (isPageFile(file)) deletePageTypes(pageRelPath(file), root)\n if (file.includes(`${appDir}/api`)) {\n invalidateVirtualModule(VIRTUAL_API)\n regenerateDts()\n }\n })\n server.watcher.on('change', (file) => {\n if (isPageFile(file)) writePageTypesAndLog(file)\n if (file.includes(`${appDir}/api`) && !file.endsWith('middleware.ts')) {\n regenerateDts()\n }\n })\n },\n }\n\n const base: UserConfig = {\n plugins: [react(), virtualPlugin],\n publicDir: resolve(process.cwd(), config.publicDir ?? 'public'),\n ssr: {noExternal: ['@devlusoft/devix']},\n ...(config.envPrefix ? {envPrefix: config.envPrefix} : {}),\n }\n\n return mergeConfig(base, config.vite ?? {})\n}", "interface EntryClientOptions {\n cssUrls: string[]\n}\n\nexport function generateEntryClient({ cssUrls }: EntryClientOptions): string {\n const cssImports = cssUrls.map(u => `import '${u}'`).join('\\n')\n\n return `\n${cssImports}\nimport \"@vitejs/plugin-react/preamble\"\nimport React from \"react\"\nimport {hydrateRoot, createRoot} from 'react-dom/client'\nimport {matchClientRoute, loadErrorPage, getDefaultErrorPage} from 'virtual:devix/client-routes'\nimport {RouterProvider} from '@devlusoft/devix'\n\nconst root = document.getElementById('devix-root')\n\nif (!window.__DEVIX__) {\n const ErrorPage = getDefaultErrorPage()\n createRoot(root).render(React.createElement(ErrorPage, {statusCode: 500, message: 'Server error'}))\n} else {\n const {metadata, viewport, clientEntry} = window.__DEVIX__\n const loaderData = window.__LOADER_DATA__\n const layoutsData = window.__LAYOUTS_DATA__ ?? []\n const guardData = window.__GUARD_DATA__ ?? null\n\n const matched = matchClientRoute(window.location.pathname)\n\n if (window.__LOADER_ERROR__) {\n const {statusCode, message, code, data} = window.__LOADER_ERROR__\n const ErrorPage = await loadErrorPage() ?? getDefaultErrorPage()\n createRoot(root).render(\n React.createElement(RouterProvider, {\n matchClientRoute,\n loadErrorPage,\n getDefaultErrorPage,\n clientEntry,\n initialData: null,\n initialParams: {},\n initialPage: () => null,\n initialError: {statusCode, message, code, data},\n initialErrorPage: ErrorPage,\n })\n )\n } else if (matched) {\n const [pageMod, ...layoutMods] = await Promise.all([\n matched.load(),\n ...matched.loadLayouts.map(l => l()),\n ])\n hydrateRoot(\n root,\n React.createElement(RouterProvider, {\n matchClientRoute,\n loadErrorPage,\n getDefaultErrorPage,\n clientEntry,\n initialData: loaderData,\n initialParams: matched.params,\n initialPage: pageMod.default,\n initialLayouts: layoutMods.map(m => m.default),\n initialLayoutsData: layoutsData,\n initialGuardData: guardData,\n initialMeta: metadata,\n initialViewport: viewport,\n })\n )\n\n if (window.location.hash) { \n const id = window.location.hash.slice(1) \n const scrollBehavior = getComputedStyle(document.documentElement).scrollBehavior \n requestAnimationFrame(() => { \n document.getElementById(id)?.scrollIntoView({ behavior: scrollBehavior }) \n }) \n } \n } else {\n const ErrorPage = await loadErrorPage() ?? getDefaultErrorPage()\n createRoot(root).render(\n React.createElement(RouterProvider, {\n matchClientRoute,\n loadErrorPage,\n getDefaultErrorPage,\n clientEntry,\n initialData: null,\n initialParams: {},\n initialPage: () => null,\n initialLayouts: [],\n initialLayoutsData: [],\n initialMeta: null,\n initialError: {statusCode: 404, message: 'Not found'},\n initialErrorPage: ErrorPage,\n })\n )\n }\n}\n`\n}", "interface ClientRoutesOptions {\n pagesDir: string\n matcherPath: string\n}\n\nexport function generateClientRoutes({pagesDir, matcherPath}: ClientRoutesOptions) {\n return `\nimport React from 'react'\nimport { createMatcher } from '${matcherPath}'\nconst pageFiles = import.meta.glob(['/${pagesDir}/**/*.tsx', '!**/error.tsx', '!**/layout.tsx'])\nconst layoutFiles = import.meta.glob('/${pagesDir}/**/layout.tsx')\nconst errorFiles = import.meta.glob('/${pagesDir}/**/error.tsx')\n\nexport const matchClientRoute = createMatcher(pageFiles, layoutFiles)\n\nexport async function loadErrorPage() {\n const key = Object.keys(errorFiles)[0]\n if (!key) return null\n const mod = await errorFiles[key]()\n return mod?.default ?? null\n}\n\nexport function getDefaultErrorPage() {\n return function DefaultError({ statusCode, message }) {\n return React.createElement('main', {\n style: { minHeight: '100dvh', display: 'flex', flexDirection: 'column', \n alignItems: 'center', justifyContent: 'center', gap: '8px',\n fontFamily: 'system-ui, sans-serif' }\n },\n React.createElement('h1', {style: {fontSize: '4rem', fontWeight: 700}}, statusCode),\n React.createElement('p', {style: {color: '#666'}}, message ?? 'An unexpected error occurred'),\n )\n }\n}\n`\n}", "interface RenderOptions {\n pagesDir: string\n renderPath: string\n}\n\nexport function generateRender({pagesDir, renderPath}: RenderOptions): string {\n return `\nimport { render as _render, runLoader as _runLoader, getStaticRoutes as _getStaticRoutes } from '${renderPath}'\n\nconst _pages = import.meta.glob(['/${pagesDir}/**/*.tsx', '!**/error.tsx', '!**/layout.tsx'])\nconst _layouts = import.meta.glob('/${pagesDir}/**/layout.tsx')\n\nconst _glob = {\n pages: _pages,\n layouts: _layouts,\n pagesDir: '/${pagesDir}',\n}\n\nexport function render(url, request, options) {\n return _render(url, request, _glob, options)\n}\n\nexport function runLoader(url, request, options) {\n return _runLoader(url, request, _glob, options)\n}\n\nexport function getStaticRoutes() {\n return _getStaticRoutes(_glob)\n}\n`\n}\n", "interface ApiOptions {\n apiPath: string\n appDir: string\n}\n\nexport function generateApi({apiPath, appDir}: ApiOptions): string {\n return `\nimport { handleApiRequest as _handleApiRequest } from '${apiPath}'\n\nconst _routes = import.meta.glob(['/${appDir}/api/**/*.ts', '!**/middleware.ts'])\nconst _middlewares = import.meta.glob('/${appDir}/api/**/middleware.ts')\n\nconst _glob = {\n routes: _routes,\n middlewares: _middlewares,\n apiDir: '/${appDir}/api',\n}\n\nexport function handleApiRequest(url, request) {\n return _handleApiRequest(url, request, _glob)\n}\n`\n}\n", "export function generateContext(): string {\n return `\nexport {RouterContext} from '@devlusoft/devix/runtime/context'\n`\n}", "import {readFileSync, readdirSync, statSync} from 'node:fs'\nimport {join, relative} from 'node:path'\nimport {extractHttpMethods} from './extract-methods'\nimport {buildRouteEntry} from './routes-dts'\nimport type {RouteEntry} from './routes-dts'\n\nfunction walkDir(dir: string, root: string): string[] {\n const entries: string[] = []\n for (const name of readdirSync(dir)) {\n const full = join(dir, name)\n if (statSync(full).isDirectory()) {\n entries.push(...walkDir(full, root))\n } else if (/\\.(ts|tsx)$/.test(name)) {\n entries.push(relative(root, full).replace(/\\\\/g, '/'))\n }\n }\n return entries\n}\n\nexport function scanApiFiles(appDir: string, projectRoot: string): RouteEntry[] {\n const apiDir = join(projectRoot, appDir, 'api')\n\n let files: string[]\n try {\n files = walkDir(apiDir, projectRoot)\n } catch {\n return []\n }\n\n return files\n .filter(f => !f.endsWith('middleware.ts') && !f.endsWith('middleware.tsx'))\n .flatMap(filePath => {\n try {\n const content = readFileSync(join(projectRoot, filePath), 'utf-8')\n const methods = extractHttpMethods(content)\n if (methods.length === 0) return []\n return [buildRouteEntry(filePath, `${appDir}/api`, methods)]\n } catch {\n return []\n }\n })\n}\n", "const HTTP_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'] as const\nexport type HttpMethod = (typeof HTTP_METHODS)[number]\n\nconst METHOD_EXPORT_RE = /export\\s+(?:const|async\\s+function|function)\\s+(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\\b/g\n\nfunction stripComments(content: string): string {\n return content\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n .replace(/\\/\\/.*$/gm, '')\n}\n\nexport function extractHttpMethods(content: string): HttpMethod[] {\n const found = new Set<HttpMethod>()\n for (const match of stripComments(content).matchAll(METHOD_EXPORT_RE)) {\n found.add(match[1] as HttpMethod)\n }\n return [...found]\n}\n", "export function routePattern(rel: string): string {\n return rel\n .replace(/\\.(tsx|ts|jsx|js)$/, '')\n .replace(/\\(.*?\\)\\//g, '')\n .replace(/^index$|\\/index$/, '')\n .replace(/\\[([^\\]]+)]/g, ':$1')\n || '/'\n}", "import {routePattern} from \"../utils/patterns\";\n\nexport interface ApiRoute {\n path: string\n key: string\n params: string[]\n regex: RegExp\n}\n\nexport interface ApiMiddleware {\n dir: string\n key: string\n}\n\nexport interface ApiResult {\n routes: ApiRoute[]\n middlewares: ApiMiddleware[]\n}\n\nexport function keyToRoutePattern(key: string, apiDir: string): string {\n const rel = key.slice(apiDir.length + 1).replace(/\\\\/g, '/')\n const pattern = routePattern(rel)\n return pattern === '/' ? '/api' : `/api/${pattern}`.replace('/api//', '/api/')\n}\n\nfunction keyToDir(key: string): string {\n return key.slice(0, key.lastIndexOf('/'))\n}\n\nexport function buildRoutes(routeKeys: string[], middlewareKeys: string[], apiDir: string): ApiResult {\n const routes: ApiRoute[] = []\n const middlewares: ApiMiddleware[] = []\n\n for (const key of middlewareKeys) {\n middlewares.push({dir: keyToDir(key), key})\n }\n\n for (const key of routeKeys) {\n const pattern = keyToRoutePattern(key, apiDir)\n const params = [...pattern.matchAll(/:([^/]+)/g)].map(m => m[1])\n const regexStr = pattern\n .replace(/:[^/]+/g, '([^/]+)')\n .replace(/\\//g, '\\\\/')\n routes.push({path: pattern, key, params, regex: new RegExp(`^${regexStr}$`)})\n }\n routes.sort((a, b) => {\n const aScore = (a.path.match(/:/g) || []).length\n const bScore = (b.path.match(/:/g) || []).length\n if (aScore !== bScore) return aScore - bScore\n return b.path.length - a.path.length\n })\n\n return {routes, middlewares}\n}\n\nexport function collectMiddlewareChain(routeKey: string, middlewares: ApiMiddleware[]): ApiMiddleware[] {\n const routeDir = keyToDir(routeKey)\n\n return middlewares\n .filter(mw => routeDir.startsWith(mw.dir))\n .sort((a, b) => a.dir.split('/').length - b.dir.split('/').length)\n}\n\nexport function matchRoute(\n pathname: string,\n routes: ApiRoute[]\n): { route: ApiRoute; params: Record<string, string> } | null {\n for (const route of routes) {\n const match = pathname.match(route.regex)\n if (match) {\n const params: Record<string, string> = {}\n route.params.forEach((name, i) => {\n params[name] = decodeURIComponent(match[i + 1])\n })\n return {route, params}\n }\n }\n return null\n}\n", "import { keyToRoutePattern } from '../../server/api-router'\nimport type { HttpMethod } from './extract-methods'\n\nexport interface RouteEntry {\n filePath: string\n urlPattern: string\n identifier: string\n methods: HttpMethod[]\n}\n\nexport function filePathToIdentifier(filePath: string, apiDir: string): string {\n return '_api_' + filePath\n .slice(`${apiDir}/`.length)\n .replace(/\\.(ts|tsx)$/, '')\n .replace(/[^a-zA-Z0-9]/g, '_')\n}\n\nexport function buildRouteEntry(filePath: string, apiDir: string, methods: HttpMethod[]): RouteEntry {\n return {\n filePath,\n urlPattern: keyToRoutePattern(filePath, apiDir),\n identifier: filePathToIdentifier(filePath, apiDir),\n methods,\n }\n}\n\nexport function generateRoutesDts(entries: RouteEntry[], apiDir: string): string {\n if (entries.length === 0) {\n return `// auto-generado por devix \u2014 no editar\\nexport {}\\ndeclare module '@devlusoft/devix' {\\n interface ApiRoutes {}\\n}\\n`\n }\n\n const imports = entries\n .map(e => {\n const importPath = '../' + e.filePath.replace(/\\.(ts|tsx)$/, '')\n return `import type * as ${e.identifier} from '${importPath}'`\n })\n .join('\\n')\n\n const routeLines = entries.flatMap(e =>\n e.methods.map(m =>\n ` '${m} ${e.urlPattern}': InferRoute<(typeof ${e.identifier})['${m}']>`\n )\n ).join('\\n')\n\n return `// auto-generado por devix \u2014 no editar\n${imports}\n\ntype JsonResponse<T, S extends number = number> = Response & { readonly __body: T; readonly __status: S }\ntype Is2xx<S extends number> = [number] extends [S] ? boolean : S extends 200 | 201 | 202 | 203 | 204 | 205 | 206 ? true : false\ntype UnwrapSuccessJson<T> = T extends JsonResponse<infer U, infer S> ? Is2xx<S> extends false ? never : U : never\ntype UnwrapErrorJson<T> = T extends JsonResponse<infer U, infer S> ? Is2xx<S> extends true ? never : U : never\ntype InferFnSuccess<T> = T extends (...args: any[]) => any ? UnwrapSuccessJson<Awaited<ReturnType<T>>> : never\ntype InferFnErrors<T> = T extends (...args: any[]) => any ? UnwrapErrorJson<Awaited<ReturnType<T>>> : never\ntype InferRoute<T> =\n T extends { readonly __return?: infer TReturn; readonly __body?: infer TBody }\n ? {\n __body: [TBody] extends [undefined] ? never : Exclude<TBody, undefined>\n __response: InferFnSuccess<() => TReturn>\n __errors: InferFnErrors<() => TReturn>\n }\n : InferFnSuccess<T>\n\ndeclare module '@devlusoft/devix' {\n interface ApiRoutes {\n${routeLines}\n }\n}\n`\n}\n", "import {mkdirSync, readFileSync, writeFileSync, existsSync} from 'node:fs'\nimport {join} from 'node:path'\n\nexport function writeRoutesDts(content: string, projectRoot: string): boolean {\n const devixDir = join(projectRoot, '.devix')\n const outPath = join(devixDir, 'routes.d.ts')\n\n mkdirSync(devixDir, {recursive: true})\n\n if (existsSync(outPath) && readFileSync(outPath, 'utf-8') === content) {\n return false\n }\n\n writeFileSync(outPath, content, 'utf-8')\n return true\n}\n", "interface ServerEntryOptions {\n routesPath: string\n envPath: string\n honoServerPath: string\n honoServerStaticPath: string\n honoPath: string\n}\n\nexport function generateServerEntry({ routesPath, envPath, honoServerPath, honoServerStaticPath, honoPath }: ServerEntryOptions): string {\n return `\nimport { readFileSync } from 'node:fs'\n import { serve } from '${honoServerPath}'\n import { serveStatic } from '${honoServerStaticPath}'\n import { Hono } from '${honoPath}'\n import { resolve, join, dirname } from 'node:path'\n import { pathToFileURL } from 'node:url'\n import { registerApiRoutes, registerSsrRoute } from '${routesPath}' \n import { loadDotenv } from '${envPath}'\n \n loadDotenv('production')\n \n const __dir = dirname(process.argv[1])\n\n let renderModule, apiModule, manifest, runtimeConfig \n \n try { \n runtimeConfig = JSON.parse(readFileSync(resolve(__dir, '../devix.config.json'), 'utf-8'))\n if (runtimeConfig.output !== 'static') { \n renderModule = await import(pathToFileURL(resolve(__dir, 'render.js')).href)\n apiModule = await import(pathToFileURL(resolve(__dir, 'api.js')).href) \n } \n manifest = JSON.parse(readFileSync(resolve(__dir, '../client/.vite/manifest.json'), 'utf-8')) \n } catch { \n console.error('[devix] Build not found. Run \"devix build\" first.')\n process.exit(1) \n } \n \n const port = Number(process.env.PORT) || runtimeConfig.port || 3000 \n const host = typeof runtimeConfig.host === 'string'\n ? runtimeConfig.host \n : runtimeConfig.host ? '0.0.0.0' : (process.env.HOST || '0.0.0.0') \n \n const clientRoot = resolve(__dir, '../client') \n const app = new Hono()\n \n if (runtimeConfig.output === 'static') {\n app.get('/_data/*', (c) => {\n const pathname = c.req.path.replace(/^\\\\/_data/, '') || '/' \n const filePath = pathname === '/' \n ? join(clientRoot, '_data/index.json') \n : join(clientRoot, '_data', pathname + '.json') \n try { \n return c.json(JSON.parse(readFileSync(filePath, 'utf-8')))\n } catch { \n return c.json({ error: 'not found' }, 404)\n } \n }) \n }\n\n app.use('/*', serveStatic({ \n root: clientRoot,\n onFound: (_path, c) => { \n c.header('Cache-Control', _path.includes('/assets/') \n ? 'public, immutable, max-age=31536000'\n : 'no-cache') \n } \n })) \n \n if (runtimeConfig.output === 'static') {\n console.log('[devix] Static mode \u2014 serving pre-generated files from dist/client')\n } else {\n let userServerConfig\n try {\n const userConfigMod = await import(pathToFileURL(resolve(process.cwd(), 'devix.config.ts')).href).catch(() =>\n import(pathToFileURL(resolve(process.cwd(), 'devix.config.js')).href))\n userServerConfig = userConfigMod?.default?.server\n } catch {\n /* config sin server \u2014 sigue normal */\n }\n registerApiRoutes(app, { renderModule, apiModule, manifest, server: userServerConfig })\n registerSsrRoute(app, { renderModule, apiModule, manifest, loaderTimeout: runtimeConfig.loaderTimeout, server: userServerConfig })\n } \n \n const server = serve({ fetch: app.fetch, port, hostname: host }, (info) => \n console.log(\\`http://\\${info.address}:\\${info.port}\\`))\n\nprocess.on('SIGTERM', () => server.close())\nprocess.on('SIGINT', () => server.close())\n`\n}", "import {existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync} from \"node:fs\";\nimport {join, relative} from \"node:path\";\nimport {parseSync} from \"oxc-parser\";\n\nfunction walkPages(dir: string, root: string): string[] {\n const entries: string[] = []\n for (const name of readdirSync(dir)) {\n const full = join(dir, name)\n if (statSync(full).isDirectory()) {\n entries.push(...walkPages(full, root))\n } else if (/\\.(ts|tsx)$/.test(name) && name !== 'layout.tsx' && name !== 'error.tsx') {\n entries.push(relative(root, full).replace(/\\\\/g, '/'))\n }\n }\n return entries\n}\n\nexport interface LoaderExportInfo {\n exists: boolean\n isAsync: boolean\n isReExport: boolean\n}\n\nexport function inspectLoaderExport(code: string, filePath: string): LoaderExportInfo {\n const ast = parseSync(filePath, code, {sourceType: 'module'})\n for (const node of ast.program.body) {\n if (node.type !== 'ExportNamedDeclaration') continue\n const decl = node.declaration\n if (decl?.type === 'FunctionDeclaration' && decl.id?.name === 'loader') {\n return {exists: true, isAsync: decl.async, isReExport: false}\n }\n if (decl?.type === 'VariableDeclaration') {\n for (const d of decl.declarations) {\n if (d.id.type === 'Identifier' && d.id.name === 'loader') {\n const init = d.init\n const isAsync =\n (init?.type === 'ArrowFunctionExpression' && init.async) ||\n (init?.type === 'FunctionExpression' && init.async)\n return {exists: true, isAsync, isReExport: false}\n }\n }\n }\n for (const spec of (node.specifiers ?? [])) {\n if (spec.exported.type === 'Identifier' && spec.exported.name === 'loader') {\n return {exists: true, isAsync: false, isReExport: true}\n }\n }\n }\n return {exists: false, isAsync: false, isReExport: false}\n}\n\nexport function hasLoaderExport(code: string, filePath: string): boolean {\n return inspectLoaderExport(code, filePath).exists\n}\n\nexport function generatePageTypesDts(importPath: string, withLoader: boolean): string {\n if (!withLoader) {\n return '// auto-generado por devix - no editar\\nexport type PageData = undefined\\nexport type PageParams = Record<string, string>\\n'\n }\n return `// auto-generado por devix \u2014 no editar\\nimport type { loader } from \"${importPath}\"\\nimport type { Redirect } from \"@devlusoft/devix\"\\n\\nexport type PageData = Exclude<\\n Awaited<ReturnType<NonNullable<typeof loader>>>,\\n Redirect | void | undefined\\n>\\nexport type PageParams = NonNullable<Parameters<typeof loader>[0]>[\"params\"]\\n`\n}\n\nexport interface WritePageTypesResult {\n warnings: string[]\n}\n\nexport function writePageTypes(pageRelPath: string, root: string): WritePageTypesResult {\n const fullPath = join(root, pageRelPath)\n const code = readFileSync(fullPath, 'utf-8')\n const loaderInfo = inspectLoaderExport(code, fullPath)\n const warnings: string[] = []\n\n if (loaderInfo.exists && !loaderInfo.isAsync && !loaderInfo.isReExport) {\n warnings.push(\n `[devix] ${pageRelPath}: 'loader' must be async. ` +\n `Use 'export async function loader' or 'export const loader = async (...) => ...'.`\n )\n }\n\n const typesDir = join(root, '.devix', 'pages', pageRelPath.replace(/\\.(tsx?|jsx?)$/, ''))\n const outPath = join(typesDir, '$types.d.ts')\n\n const pageAbsNoExt = fullPath.replace(/\\.(tsx?|jsx?)$/, '')\n const importPath = relative(typesDir, pageAbsNoExt).replace(/\\\\/g, '/')\n\n const content = generatePageTypesDts(importPath, loaderInfo.exists)\n\n if (existsSync(outPath) && readFileSync(outPath, 'utf-8') === content) return {warnings}\n\n mkdirSync(typesDir, {recursive: true})\n writeFileSync(outPath, content, 'utf-8')\n return {warnings}\n}\n\nexport function deletePageTypes(pageRelPath: string, root: string): void {\n const typesDir = join(root, '.devix', 'pages', pageRelPath.replace(/\\.(tsx?|jsx?)$/, ''))\n const outPath = join(typesDir, '$types.d.ts')\n if (existsSync(outPath)) rmSync(outPath)\n}\n\nexport function scanAndWritePageTypes(appDir: string, root: string): WritePageTypesResult {\n const pagesDir = join(root, appDir, 'pages')\n const warnings: string[] = []\n let files: string[]\n try {\n files = walkPages(pagesDir, root)\n } catch {\n return {warnings}\n }\n for (const file of files) {\n try {\n const result = writePageTypes(file, root)\n warnings.push(...result.warnings)\n } catch {\n /* ignorar archivos no procesables */\n }\n }\n return {warnings}\n}", "export function parseDuration(value: number | string): number {\n if (typeof value === 'number') return value\n const match = value.trim().match(/^(\\d+(?:\\.\\d+)?)\\s*(ms|s|m|h)?$/)\n if (!match) throw new Error(`[devix] Invalid duration: \"${value}\". Use a number (ms) or a string like \"5s\", \"2m\", \"500ms\".`)\n const n = parseFloat(match[1])\n switch (match[2]) {\n case 'h': return n * 3_600_000\n case 'm': return n * 60_000\n case 's': return n * 1_000\n case 'ms':\n default: return n\n }\n}\n", "import {build} from 'esbuild'\nimport type {DevixConfig} from \"../config\"\nimport {join} from \"node:path\"\nimport {unlinkSync, writeFileSync} from \"node:fs\";\nimport {pathToFileURL} from \"node:url\";\n\nexport async function loadConfig(cwd: string): Promise<DevixConfig> {\n const result = await build({\n entryPoints: [join(cwd, 'devix.config.ts')],\n bundle: true,\n write: false,\n format: 'esm',\n platform: 'node',\n packages: 'external',\n })\n\n const tmpFile = join(cwd, `.devix-config-${Date.now()}.mjs`)\n writeFileSync(tmpFile, result.outputFiles[0].text)\n\n try {\n const mod = await import(pathToFileURL(tmpFile).href)\n return mod.default\n } finally {\n unlinkSync(tmpFile)\n }\n}"],
5
+ "mappings": "AAAA,OAAQ,iBAAAA,OAAoB,UAC5B,OAAQ,WAAAC,OAAc,YACtB,OAAQ,SAAAC,MAAY,OCFpB,OAA4B,eAAAC,OAAkB,OAE9C,OAAOC,OAAW,uBAClB,OAAQ,iBAAAC,OAAoB,WAC5B,OAAQ,WAAAC,GAAS,YAAAC,GAAU,WAAAC,MAAc,YACzC,OAAQ,iBAAAC,OAAoB,cCDrB,SAASC,EAAoB,CAAE,QAAAC,CAAQ,EAA+B,CAGzE,MAAO;AAAA,EAFYA,EAAQ,IAAIC,GAAK,WAAWA,CAAC,GAAG,EAAE,KAAK;AAAA,CAAI,CAGtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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,IAAI,EAAG,wBAAwB,EAC/C,KAAK,UAAUH,GAAe,KAAM,CAAC,EACrC,OACJ",
6
6
  "names": ["writeFileSync", "resolve", "build", "mergeConfig", "react", "fileURLToPath", "dirname", "relative", "resolve", "createRequire", "generateEntryClient", "cssUrls", "u", "generateClientRoutes", "pagesDir", "matcherPath", "generateRender", "pagesDir", "renderPath", "generateApi", "apiPath", "appDir", "generateContext", "readFileSync", "readdirSync", "statSync", "join", "relative", "METHOD_EXPORT_RE", "stripComments", "content", "extractHttpMethods", "found", "match", "routePattern", "rel", "keyToRoutePattern", "key", "apiDir", "rel", "pattern", "routePattern", "filePathToIdentifier", "filePath", "apiDir", "buildRouteEntry", "methods", "keyToRoutePattern", "generateRoutesDts", "entries", "imports", "e", "importPath", "routeLines", "m", "walkDir", "dir", "root", "entries", "name", "readdirSync", "full", "join", "statSync", "relative", "scanApiFiles", "appDir", "projectRoot", "apiDir", "files", "f", "filePath", "content", "readFileSync", "methods", "extractHttpMethods", "buildRouteEntry", "mkdirSync", "readFileSync", "writeFileSync", "existsSync", "join", "writeRoutesDts", "content", "projectRoot", "devixDir", "outPath", "parseSync", "generateServerEntry", "routesPath", "envPath", "honoServerPath", "honoServerStaticPath", "honoPath", "existsSync", "mkdirSync", "readdirSync", "readFileSync", "rmSync", "statSync", "writeFileSync", "join", "relative", "parseSync", "walkPages", "dir", "root", "entries", "name", "full", "inspectLoaderExport", "code", "filePath", "ast", "node", "decl", "d", "init", "spec", "generatePageTypesDts", "importPath", "withLoader", "writePageTypes", "pageRelPath", "root", "fullPath", "join", "code", "readFileSync", "loaderInfo", "inspectLoaderExport", "warnings", "typesDir", "outPath", "pageAbsNoExt", "relative", "content", "existsSync", "mkdirSync", "writeFileSync", "deletePageTypes", "rmSync", "scanAndWritePageTypes", "appDir", "pagesDir", "files", "walkPages", "file", "result", "__dirname", "dirname", "fileURLToPath", "VIRTUAL_ENTRY_CLIENT", "VIRTUAL_CLIENT_ROUTES", "VIRTUAL_RENDER", "VIRTUAL_API", "VIRTUAL_CONTEXT", "VIRTUAL_SERVER_ENTRY", "SERVER_EXPORTS", "devix", "config", "appDir", "pagesDir", "cssUrls", "u", "renderPath", "resolve", "apiPath", "matcherPath", "routesPath", "envPath", "_require", "createRequire", "honoServerPath", "honoServerStaticPath", "honoPath", "virtualPlugin", "id", "generateEntryClient", "generateClientRoutes", "generateRender", "generateApi", "generateContext", "generateServerEntry", "code", "options", "resolvedPagesDir", "ast", "parseSync", "replacements", "node", "decl", "seen", "declarator", "a", "b", "result", "start", "end", "name", "root", "entries", "scanApiFiles", "writeRoutesDts", "generateRoutesDts", "warnings", "scanAndWritePageTypes", "w", "server", "initial", "regenerateDts", "isPageFile", "file", "pageRelPath", "relative", "invalidateVirtualModule", "mod", "writePageTypesAndLog", "writePageTypes", "deletePageTypes", "base", "react", "mergeConfig", "parseDuration", "value", "match", "n", "build", "join", "unlinkSync", "writeFileSync", "pathToFileURL", "loadConfig", "cwd", "result", "tmpFile", "config", "loadConfig", "baseConfig", "devix", "build", "runtimeConfig", "parseDuration", "writeFileSync", "resolve"]
7
7
  }
@@ -25,6 +25,9 @@ if (!window.__DEVIX__) {
25
25
  const ErrorPage = await loadErrorPage() ?? getDefaultErrorPage()
26
26
  createRoot(root).render(
27
27
  React.createElement(RouterProvider, {
28
+ matchClientRoute,
29
+ loadErrorPage,
30
+ getDefaultErrorPage,
28
31
  clientEntry,
29
32
  initialData: null,
30
33
  initialParams: {},
@@ -41,6 +44,9 @@ if (!window.__DEVIX__) {
41
44
  hydrateRoot(
42
45
  root,
43
46
  React.createElement(RouterProvider, {
47
+ matchClientRoute,
48
+ loadErrorPage,
49
+ getDefaultErrorPage,
44
50
  clientEntry,
45
51
  initialData: loaderData,
46
52
  initialParams: matched.params,
@@ -64,6 +70,9 @@ if (!window.__DEVIX__) {
64
70
  const ErrorPage = await loadErrorPage() ?? getDefaultErrorPage()
65
71
  createRoot(root).render(
66
72
  React.createElement(RouterProvider, {
73
+ matchClientRoute,
74
+ loadErrorPage,
75
+ getDefaultErrorPage,
67
76
  clientEntry,
68
77
  initialData: null,
69
78
  initialParams: {},
@@ -145,13 +154,13 @@ export function handleApiRequest(url, request) {
145
154
  }
146
155
  `}function X(){return`
147
156
  export {RouterContext} from '@devlusoft/devix/runtime/context'
148
- `}import{readFileSync as Ce,readdirSync as $e,statSync as De}from"node:fs";import{join as O,relative as Ae}from"node:path";var Te=/export\s+(?:const|async\s+function|function)\s+(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\b/g;function Se(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function Y(e){let t=new Set;for(let r of Se(e).matchAll(Te))t.add(r[1]);return[...t]}function z(e){return e.replace(/\.(tsx|ts|jsx|js)$/,"").replace(/\(.*?\)\//g,"").replace(/^index$|\/index$/,"").replace(/\[([^\]]+)]/g,":$1")||"/"}function K(e,t){let r=e.slice(t.length+1).replace(/\\/g,"/"),n=z(r);return n==="/"?"/api":`/api/${n}`.replace("/api//","/api/")}function be(e,t){return"_api_"+e.slice(`${t}/`.length).replace(/\.(ts|tsx)$/,"").replace(/[^a-zA-Z0-9]/g,"_")}function Z(e,t,r){return{filePath:e,urlPattern:K(e,t),identifier:be(e,t),methods:r}}function I(e,t){if(e.length===0)return`// auto-generado por devix \u2014 no editar
157
+ `}import{readFileSync as Ce,readdirSync as De,statSync as $e}from"node:fs";import{join as O,relative as Ae}from"node:path";var Te=/export\s+(?:const|async\s+function|function)\s+(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\b/g;function Se(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function Y(e){let t=new Set;for(let r of Se(e).matchAll(Te))t.add(r[1]);return[...t]}function z(e){return e.replace(/\.(tsx|ts|jsx|js)$/,"").replace(/\(.*?\)\//g,"").replace(/^index$|\/index$/,"").replace(/\[([^\]]+)]/g,":$1")||"/"}function K(e,t){let r=e.slice(t.length+1).replace(/\\/g,"/"),o=z(r);return o==="/"?"/api":`/api/${o}`.replace("/api//","/api/")}function be(e,t){return"_api_"+e.slice(`${t}/`.length).replace(/\.(ts|tsx)$/,"").replace(/[^a-zA-Z0-9]/g,"_")}function Z(e,t,r){return{filePath:e,urlPattern:K(e,t),identifier:be(e,t),methods:r}}function I(e,t){if(e.length===0)return`// auto-generado por devix \u2014 no editar
149
158
  export {}
150
159
  declare module '@devlusoft/devix' {
151
160
  interface ApiRoutes {}
152
161
  }
153
- `;let r=e.map(o=>{let s="../"+o.filePath.replace(/\.(ts|tsx)$/,"");return`import type * as ${o.identifier} from '${s}'`}).join(`
154
- `),n=e.flatMap(o=>o.methods.map(s=>` '${s} ${o.urlPattern}': InferRoute<(typeof ${o.identifier})['${s}']>`)).join(`
162
+ `;let r=e.map(n=>{let s="../"+n.filePath.replace(/\.(ts|tsx)$/,"");return`import type * as ${n.identifier} from '${s}'`}).join(`
163
+ `),o=e.flatMap(n=>n.methods.map(s=>` '${s} ${n.urlPattern}': InferRoute<(typeof ${n.identifier})['${s}']>`)).join(`
155
164
  `);return`// auto-generado por devix \u2014 no editar
156
165
  ${r}
157
166
 
@@ -172,14 +181,14 @@ type InferRoute<T> =
172
181
 
173
182
  declare module '@devlusoft/devix' {
174
183
  interface ApiRoutes {
175
- ${n}
184
+ ${o}
176
185
  }
177
186
  }
178
- `}function Q(e,t){let r=[];for(let n of $e(e)){let o=O(e,n);De(o).isDirectory()?r.push(...Q(o,t)):/\.(ts|tsx)$/.test(n)&&r.push(Ae(t,o).replace(/\\/g,"/"))}return r}function L(e,t){let r=O(t,e,"api"),n;try{n=Q(r,t)}catch{return[]}return n.filter(o=>!o.endsWith("middleware.ts")&&!o.endsWith("middleware.tsx")).flatMap(o=>{try{let s=Ce(O(t,o),"utf-8"),a=Y(s);return a.length===0?[]:[Z(o,`${e}/api`,a)]}catch{return[]}})}import{mkdirSync as Ie,readFileSync as Oe,writeFileSync as Le,existsSync as Me}from"node:fs";import{join as ee}from"node:path";function M(e,t){let r=ee(t,".devix"),n=ee(r,"routes.d.ts");return Ie(r,{recursive:!0}),Me(n)&&Oe(n,"utf-8")===e?!1:(Le(n,e,"utf-8"),!0)}import{parseSync as ze}from"oxc-parser";function te({routesPath:e,envPath:t,honoServerPath:r,honoServerStaticPath:n,honoPath:o}){return`
187
+ `}function Q(e,t){let r=[];for(let o of De(e)){let n=O(e,o);$e(n).isDirectory()?r.push(...Q(n,t)):/\.(ts|tsx)$/.test(o)&&r.push(Ae(t,n).replace(/\\/g,"/"))}return r}function L(e,t){let r=O(t,e,"api"),o;try{o=Q(r,t)}catch{return[]}return o.filter(n=>!n.endsWith("middleware.ts")&&!n.endsWith("middleware.tsx")).flatMap(n=>{try{let s=Ce(O(t,n),"utf-8"),a=Y(s);return a.length===0?[]:[Z(n,`${e}/api`,a)]}catch{return[]}})}import{mkdirSync as Ie,readFileSync as Oe,writeFileSync as Le,existsSync as Me}from"node:fs";import{join as ee}from"node:path";function M(e,t){let r=ee(t,".devix"),o=ee(r,"routes.d.ts");return Ie(r,{recursive:!0}),Me(o)&&Oe(o,"utf-8")===e?!1:(Le(o,e,"utf-8"),!0)}import{parseSync as ze}from"oxc-parser";function te({routesPath:e,envPath:t,honoServerPath:r,honoServerStaticPath:o,honoPath:n}){return`
179
188
  import { readFileSync } from 'node:fs'
180
189
  import { serve } from '${r}'
181
- import { serveStatic } from '${n}'
182
- import { Hono } from '${o}'
190
+ import { serveStatic } from '${o}'
191
+ import { Hono } from '${n}'
183
192
  import { resolve, join, dirname } from 'node:path'
184
193
  import { pathToFileURL } from 'node:url'
185
194
  import { registerApiRoutes, registerSsrRoute } from '${e}'
@@ -254,7 +263,7 @@ import { readFileSync } from 'node:fs'
254
263
 
255
264
  process.on('SIGTERM', () => server.close())
256
265
  process.on('SIGINT', () => server.close())
257
- `}import{existsSync as ne,mkdirSync as je,readdirSync as Ue,readFileSync as re,rmSync as Fe,statSync as Ne,writeFileSync as ke}from"node:fs";import{join as w,relative as oe}from"node:path";import{parseSync as He}from"oxc-parser";function se(e,t){let r=[];for(let n of Ue(e)){let o=w(e,n);Ne(o).isDirectory()?r.push(...se(o,t)):/\.(ts|tsx)$/.test(n)&&n!=="layout.tsx"&&n!=="error.tsx"&&r.push(oe(t,o).replace(/\\/g,"/"))}return r}function Be(e,t){let r=He(t,e,{sourceType:"module"});for(let n of r.program.body){if(n.type!=="ExportNamedDeclaration")continue;let o=n.declaration;if(o?.type==="FunctionDeclaration"&&o.id?.name==="loader")return{exists:!0,isAsync:o.async,isReExport:!1};if(o?.type==="VariableDeclaration"){for(let s of o.declarations)if(s.id.type==="Identifier"&&s.id.name==="loader"){let a=s.init;return{exists:!0,isAsync:a?.type==="ArrowFunctionExpression"&&a.async||a?.type==="FunctionExpression"&&a.async,isReExport:!1}}}for(let s of n.specifiers??[])if(s.exported.type==="Identifier"&&s.exported.name==="loader")return{exists:!0,isAsync:!1,isReExport:!0}}return{exists:!1,isAsync:!1,isReExport:!1}}function Ve(e,t){return t?`// auto-generado por devix \u2014 no editar
266
+ `}import{existsSync as oe,mkdirSync as je,readdirSync as Ue,readFileSync as re,rmSync as Fe,statSync as Ne,writeFileSync as ke}from"node:fs";import{join as w,relative as ne}from"node:path";import{parseSync as He}from"oxc-parser";function se(e,t){let r=[];for(let o of Ue(e)){let n=w(e,o);Ne(n).isDirectory()?r.push(...se(n,t)):/\.(ts|tsx)$/.test(o)&&o!=="layout.tsx"&&o!=="error.tsx"&&r.push(ne(t,n).replace(/\\/g,"/"))}return r}function Be(e,t){let r=He(t,e,{sourceType:"module"});for(let o of r.program.body){if(o.type!=="ExportNamedDeclaration")continue;let n=o.declaration;if(n?.type==="FunctionDeclaration"&&n.id?.name==="loader")return{exists:!0,isAsync:n.async,isReExport:!1};if(n?.type==="VariableDeclaration"){for(let s of n.declarations)if(s.id.type==="Identifier"&&s.id.name==="loader"){let a=s.init;return{exists:!0,isAsync:a?.type==="ArrowFunctionExpression"&&a.async||a?.type==="FunctionExpression"&&a.async,isReExport:!1}}}for(let s of o.specifiers??[])if(s.exported.type==="Identifier"&&s.exported.name==="loader")return{exists:!0,isAsync:!1,isReExport:!0}}return{exists:!1,isAsync:!1,isReExport:!1}}function Ve(e,t){return t?`// auto-generado por devix \u2014 no editar
258
267
  import type { loader } from "${e}"
259
268
  import type { Redirect } from "@devlusoft/devix"
260
269
 
@@ -266,7 +275,7 @@ export type PageParams = NonNullable<Parameters<typeof loader>[0]>["params"]
266
275
  `:`// auto-generado por devix - no editar
267
276
  export type PageData = undefined
268
277
  export type PageParams = Record<string, string>
269
- `}function j(e,t){let r=w(t,e),n=re(r,"utf-8"),o=Be(n,r),s=[];o.exists&&!o.isAsync&&!o.isReExport&&s.push(`[devix] ${e}: 'loader' must be async. Use 'export async function loader' or 'export const loader = async (...) => ...'.`);let a=w(t,".devix","pages",e.replace(/\.(tsx?|jsx?)$/,"")),f=w(a,"$types.d.ts"),m=r.replace(/\.(tsx?|jsx?)$/,""),l=oe(a,m).replace(/\\/g,"/"),p=Ve(l,o.exists);return ne(f)&&re(f,"utf-8")===p?{warnings:s}:(je(a,{recursive:!0}),ke(f,p,"utf-8"),{warnings:s})}function ie(e,t){let r=w(t,".devix","pages",e.replace(/\.(tsx?|jsx?)$/,"")),n=w(r,"$types.d.ts");ne(n)&&Fe(n)}function U(e,t){let r=w(t,e,"pages"),n=[],o;try{o=se(r,t)}catch{return{warnings:n}}for(let s of o)try{let a=j(s,t);n.push(...a.warnings)}catch{}return{warnings:n}}var C=Ge(Je(import.meta.url)),F="virtual:devix/entry-client",N="virtual:devix/client-routes",$="virtual:devix/render",D="virtual:devix/api",k="virtual:devix/context",H="virtual:devix/server-entry",ae=new Set(["loader","guard","generateStaticParams","headers"]);function ce(e){let t=e.appDir??"app",r=`${t}/pages`,n=(e.css??[]).map(c=>c.startsWith("/")?c:`/${c.replace(/^\.\//,"")}`),o=g(C,"../server/render.js").replace(/\\/g,"/"),s=g(C,"../server/api.js").replace(/\\/g,"/"),a=g(C,"../runtime/client-router.js").replace(/\\/g,"/"),f=g(C,"../server/routes.js").replace(/\\/g,"/"),m=g(C,"../utils/env.js").replace(/\\/g,"/"),l=Ye(import.meta.url),p=l.resolve("@hono/node-server").replace(/\\/g,"/"),Ee=l.resolve("@hono/node-server/serve-static").replace(/\\/g,"/"),we=l.resolve("hono").replace(/\\/g,"/"),_e={name:"devix",enforce:"pre",resolveId(c){if(c===F)return`\0${F}`;if(c===N)return`\0${N}`;if(c===$)return`\0${$}`;if(c===D)return`\0${D}`;if(c===k)return`\0${k}`;if(c===H)return`\0${H}`},load(c){if(c===`\0${F}`)return q({cssUrls:n});if(c===`\0${N}`)return W({pagesDir:r,matcherPath:a});if(c===`\0${$}`)return J({pagesDir:r,renderPath:o});if(c===`\0${D}`)return G({apiPath:s,appDir:t});if(c===`\0${k}`)return X();if(c===`\0${H}`)return te({routesPath:f,envPath:m,honoServerPath:p,honoServerStaticPath:Ee,honoPath:we})},transform(c,u,T){if(T?.ssr)return;let E=g(process.cwd(),r);if(!u.startsWith(E))return;let S=ze(u,c,{sourceType:"module"}),R=[];for(let d of S.program.body){if(d.type!=="ExportNamedDeclaration"||!d.declaration)continue;let i=d.declaration;if(i.type==="FunctionDeclaration"&&i.id&&ae.has(i.id.name)&&R.push({start:d.start,end:d.end,name:i.id.name}),i.type==="VariableDeclaration"){let x=new Set;for(let b of i.declarations)b.id.type==="Identifier"&&ae.has(b.id.name)&&(x.has(d.start)||(x.add(d.start),R.push({start:d.start,end:d.end,name:b.id.name})))}}if(R.length===0)return;R.sort((d,i)=>i.start-d.start);let h=c;for(let{start:d,end:i,name:x}of R)h=h.slice(0,d)+`export const ${x} = undefined`+h.slice(i);return{code:h,map:null}},buildStart(){let c=process.cwd(),u=L(t,c);M(I(u,`${t}/api`),c);let{warnings:T}=U(t,c);for(let E of T)console.warn(E)},configureServer(c){let u=process.cwd(),T=U(t,u);for(let i of T.warnings)console.warn(i);let E=()=>{let i=L(t,u);M(I(i,`${t}/api`),u)},S=i=>i.startsWith(g(u,r))&&!i.endsWith("layout.tsx")&&!i.endsWith("error.tsx"),R=i=>Xe(u,i).replace(/\\/g,"/"),h=i=>{let x=c.moduleGraph.getModuleById(`\0${i}`);x&&c.moduleGraph.invalidateModule(x)};c.watcher.add(g(u,"devix.config.ts")),c.watcher.on("change",i=>{i===g(u,"devix.config.ts")&&(console.log("[devix] Config changed, restarting..."),process.exit(75))});let d=i=>{try{let{warnings:x}=j(R(i),u);for(let b of x)console.warn(b)}catch{}};c.watcher.on("add",i=>{i.startsWith(g(u,r))&&h($),S(i)&&d(i),i.includes(`${t}/api`)&&(h(D),E())}),c.watcher.on("unlink",i=>{i.startsWith(g(u,r))&&h($),S(i)&&ie(R(i),u),i.includes(`${t}/api`)&&(h(D),E())}),c.watcher.on("change",i=>{S(i)&&d(i),i.includes(`${t}/api`)&&!i.endsWith("middleware.ts")&&E()})}},Pe={plugins:[We(),_e],publicDir:g(process.cwd(),e.publicDir??"public"),ssr:{noExternal:["@devlusoft/devix"]},...e.envPrefix?{envPrefix:e.envPrefix}:{}};return qe(Pe,e.vite??{})}function A(e){let t={statusCode:e.statusCode,message:e.message};return e.code!==void 0&&(t.code=e.code),e.data!==void 0&&(t.data=e.data),t}function Ke(e,t){return Ze(t).test(e)}function B(e,t){if(!t||t.length===0)return!1;for(let r of t)if(Ke(e,r))return!0;return!1}function Ze(e){let t="",r=0;for(;r<e.length;){let n=e[r];if(n==="*"&&e[r+1]==="*")t+=".*",r+=2;else if(n==="*")t+="[^/]*",r+=1;else if(n===":"){for(r+=1;r<e.length&&/[a-zA-Z0-9_]/.test(e[r]);)r+=1;t+="[^/]+"}else".+?^$()|[]{}\\".includes(n)?(t+="\\"+n,r+=1):(t+=n,r+=1)}return new RegExp(`^${t}$`)}var le="/_devix/server";function P(e,t,r){let n=A({statusCode:e,message:t,code:r});return new Response(JSON.stringify(n),{status:e,headers:{"Content-Type":"application/json"}})}function Qe(e){if(!e.startsWith(le+"/"))return null;let t=e.slice(le.length+1),r=t.indexOf("/");return r===-1?{namespace:t,path:"/"}:{namespace:t.slice(0,r),path:t.slice(r)}}async function ue(e,t){let r=new URL(e.url),n=Qe(r.pathname);if(!n)return P(404,"Not found","PROXY_NOT_FOUND");let o=t?.[n.namespace];if(!o)return P(404,`Backend "${n.namespace}" not configured`,"BACKEND_NOT_FOUND");if(!B(n.path,o.allowedPaths))return P(403,"Path not allowed","PATH_NOT_ALLOWED");if(B(n.path,o.deniedPaths))return P(403,"Path denied","PATH_DENIED");let s=new URL(n.path+r.search,o.url),a=new Headers;if(o.prepare){let l={request:e,headers:a,url:s};try{let p=await o.prepare(l);if(p instanceof Response)return p}catch(p){return console.error(`[devix] server.${n.namespace}.prepare error:`,p),P(500,"Proxy prepare failed","PREPARE_ERROR")}}if(!a.has("Accept")){let l=e.headers.get("Accept");l&&a.set("Accept",l)}let f=e.headers.get("Content-Type");f&&!a.has("Content-Type")&&a.set("Content-Type",f);let m=null;e.method!=="GET"&&e.method!=="HEAD"&&(m=await e.arrayBuffer(),m.byteLength===0&&(m=null));try{let l=await fetch(s,{method:e.method,headers:a,body:m,redirect:"manual"});return new Response(l.body,{status:l.status,statusText:l.statusText,headers:tt(l.headers)})}catch(l){return console.error(`[devix] server.${n.namespace} fetch error:`,l),P(502,"Bad Gateway","BACKEND_UNREACHABLE")}}var et=new Set(["connection","keep-alive","proxy-authenticate","proxy-authorization","te","trailers","transfer-encoding","upgrade"]);function tt(e){let t=new Headers;return e.forEach((r,n)=>{et.has(n.toLowerCase())||t.set(n,r)}),t}function de(e,{apiModule:t,renderModule:r,loaderTimeout:n,server:o}){o&&e.all("/_devix/server/*",async s=>{try{return await ue(s.req.raw,o)}catch(a){return console.error("[devix] proxy fatal error:",a),s.json({statusCode:500,message:"Internal Server Error"},500)}}),e.all("/api/*",async s=>{try{return await t.handleApiRequest(s.req.url,s.req.raw,o)}catch(a){return console.error(a),s.json({statusCode:500,message:"Internal Server Error"},500)}}),e.get("/_data/*",async s=>{try{let{pathname:a,search:f}=new URL(s.req.url,"http://localhost"),m=a.replace(/^\/_data/,"")+f,l=await r.runLoader(m,s.req.raw,{loaderTimeout:n,server:o});if(l.error)return s.json({statusCode:500,message:"Internal Server Error"},500);if("loaderError"in l){let p=A(l.loaderError);return s.json(p,p.statusCode)}return s.json(l)}catch(a){return console.error(a),s.json({statusCode:500,message:"Internal Server Error"},500)}})}import y from"picocolors";import{networkInterfaces as rt}from"node:os";function nt(e){let t=rt();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 pe(e){let t="0.5.2",r=nt(e);console.log(),console.log(` ${y.bold(y.yellow("devix"))} ${y.dim(`v${t}`)}`),console.log(),console.log(` ${y.green("\u279C")} ${y.bold("Local:")} ${y.cyan(`http://localhost:${e}/`)}`),console.log(r?` ${y.green("\u279C")} ${y.bold("Network:")} ${y.cyan(r)}`:` ${y.green("\u279C")} ${y.bold("Network:")} ${y.dim("use --host to expose")}`),console.log()}async function fe(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 me(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 ot}from"vite";function ge(e){let t=ot(e,process.cwd(),"");for(let[r,n]of Object.entries(t))process.env[r]===void 0&&(process.env[r]=n)}import{build as st}from"esbuild";import{join as ye}from"node:path";import{unlinkSync as it,writeFileSync as at}from"node:fs";import{pathToFileURL as ct}from"node:url";async function he(e){let t=await st({entryPoints:[ye(e,"devix.config.ts")],bundle:!0,write:!1,format:"esm",platform:"node",packages:"external"}),r=ye(e,`.devix-config-${Date.now()}.mjs`);at(r,t.outputFiles[0].text);try{return(await import(ct(r).href)).default}finally{it(r)}}ge("development");var xe="virtual:devix/render",ft="virtual:devix/api",v=await he(process.cwd()),Re=Number(process.env.PORT)||v.port||3e3,mt=typeof v.host=="string"?v.host:v.host?"0.0.0.0":"localhost",_=await ut({...ce(v),configFile:!1,appType:"custom",server:{middlewareMode:!0}}),ve={render:async(...e)=>(await _.ssrLoadModule(xe)).render(...e),runLoader:async(...e)=>(await _.ssrLoadModule(xe)).runLoader(...e)},gt={handleApiRequest:async(...e)=>(await _.ssrLoadModule(ft)).handleApiRequest(...e)},V=new pt;de(V,{renderModule:ve,apiModule:gt,server:v.server});V.get("*",async e=>{try{let{html:t,statusCode:r,headers:n}=await ve.render(e.req.url,e.req.raw,{loaderTimeout:me(v.loaderTimeout??1e4),server:v.server}),s=(await fe(_)).map(l=>`<link rel="stylesheet" href="${l}">`).join(`
278
+ `}function j(e,t){let r=w(t,e),o=re(r,"utf-8"),n=Be(o,r),s=[];n.exists&&!n.isAsync&&!n.isReExport&&s.push(`[devix] ${e}: 'loader' must be async. Use 'export async function loader' or 'export const loader = async (...) => ...'.`);let a=w(t,".devix","pages",e.replace(/\.(tsx?|jsx?)$/,"")),f=w(a,"$types.d.ts"),m=r.replace(/\.(tsx?|jsx?)$/,""),l=ne(a,m).replace(/\\/g,"/"),p=Ve(l,n.exists);return oe(f)&&re(f,"utf-8")===p?{warnings:s}:(je(a,{recursive:!0}),ke(f,p,"utf-8"),{warnings:s})}function ie(e,t){let r=w(t,".devix","pages",e.replace(/\.(tsx?|jsx?)$/,"")),o=w(r,"$types.d.ts");oe(o)&&Fe(o)}function U(e,t){let r=w(t,e,"pages"),o=[],n;try{n=se(r,t)}catch{return{warnings:o}}for(let s of n)try{let a=j(s,t);o.push(...a.warnings)}catch{}return{warnings:o}}var C=Ge(Je(import.meta.url)),F="virtual:devix/entry-client",N="virtual:devix/client-routes",D="virtual:devix/render",$="virtual:devix/api",k="virtual:devix/context",H="virtual:devix/server-entry",ae=new Set(["loader","guard","generateStaticParams","headers"]);function ce(e){let t=e.appDir??"app",r=`${t}/pages`,o=(e.css??[]).map(c=>c.startsWith("/")?c:`/${c.replace(/^\.\//,"")}`),n=g(C,"../server/render.js").replace(/\\/g,"/"),s=g(C,"../server/api.js").replace(/\\/g,"/"),a=g(C,"../runtime/client-router.js").replace(/\\/g,"/"),f=g(C,"../server/routes.js").replace(/\\/g,"/"),m=g(C,"../utils/env.js").replace(/\\/g,"/"),l=Ye(import.meta.url),p=l.resolve("@hono/node-server").replace(/\\/g,"/"),Ee=l.resolve("@hono/node-server/serve-static").replace(/\\/g,"/"),we=l.resolve("hono").replace(/\\/g,"/"),_e={name:"devix",enforce:"pre",resolveId(c){if(c===F)return`\0${F}`;if(c===N)return`\0${N}`;if(c===D)return`\0${D}`;if(c===$)return`\0${$}`;if(c===k)return`\0${k}`;if(c===H)return`\0${H}`},load(c){if(c===`\0${F}`)return q({cssUrls:o});if(c===`\0${N}`)return W({pagesDir:r,matcherPath:a});if(c===`\0${D}`)return J({pagesDir:r,renderPath:n});if(c===`\0${$}`)return G({apiPath:s,appDir:t});if(c===`\0${k}`)return X();if(c===`\0${H}`)return te({routesPath:f,envPath:m,honoServerPath:p,honoServerStaticPath:Ee,honoPath:we})},transform(c,u,T){if(T?.ssr)return;let E=g(process.cwd(),r);if(!u.startsWith(E))return;let S=ze(u,c,{sourceType:"module"}),R=[];for(let d of S.program.body){if(d.type!=="ExportNamedDeclaration"||!d.declaration)continue;let i=d.declaration;if(i.type==="FunctionDeclaration"&&i.id&&ae.has(i.id.name)&&R.push({start:d.start,end:d.end,name:i.id.name}),i.type==="VariableDeclaration"){let x=new Set;for(let b of i.declarations)b.id.type==="Identifier"&&ae.has(b.id.name)&&(x.has(d.start)||(x.add(d.start),R.push({start:d.start,end:d.end,name:b.id.name})))}}if(R.length===0)return;R.sort((d,i)=>i.start-d.start);let y=c;for(let{start:d,end:i,name:x}of R)y=y.slice(0,d)+`export const ${x} = undefined`+y.slice(i);return{code:y,map:null}},buildStart(){let c=process.cwd(),u=L(t,c);M(I(u,`${t}/api`),c);let{warnings:T}=U(t,c);for(let E of T)console.warn(E)},configureServer(c){let u=process.cwd(),T=U(t,u);for(let i of T.warnings)console.warn(i);let E=()=>{let i=L(t,u);M(I(i,`${t}/api`),u)},S=i=>i.startsWith(g(u,r))&&!i.endsWith("layout.tsx")&&!i.endsWith("error.tsx"),R=i=>Xe(u,i).replace(/\\/g,"/"),y=i=>{let x=c.moduleGraph.getModuleById(`\0${i}`);x&&c.moduleGraph.invalidateModule(x)};c.watcher.add(g(u,"devix.config.ts")),c.watcher.on("change",i=>{i===g(u,"devix.config.ts")&&(console.log("[devix] Config changed, restarting..."),process.exit(75))});let d=i=>{try{let{warnings:x}=j(R(i),u);for(let b of x)console.warn(b)}catch{}};c.watcher.on("add",i=>{i.startsWith(g(u,r))&&y(D),S(i)&&d(i),i.includes(`${t}/api`)&&(y($),E())}),c.watcher.on("unlink",i=>{i.startsWith(g(u,r))&&y(D),S(i)&&ie(R(i),u),i.includes(`${t}/api`)&&(y($),E())}),c.watcher.on("change",i=>{S(i)&&d(i),i.includes(`${t}/api`)&&!i.endsWith("middleware.ts")&&E()})}},Pe={plugins:[We(),_e],publicDir:g(process.cwd(),e.publicDir??"public"),ssr:{noExternal:["@devlusoft/devix"]},...e.envPrefix?{envPrefix:e.envPrefix}:{}};return qe(Pe,e.vite??{})}function A(e){let t={statusCode:e.statusCode,message:e.message};return e.code!==void 0&&(t.code=e.code),e.data!==void 0&&(t.data=e.data),t}function Ke(e,t){return Ze(t).test(e)}function B(e,t){if(!t||t.length===0)return!1;for(let r of t)if(Ke(e,r))return!0;return!1}function Ze(e){let t="",r=0;for(;r<e.length;){let o=e[r];if(o==="*"&&e[r+1]==="*")t+=".*",r+=2;else if(o==="*")t+="[^/]*",r+=1;else if(o===":"){for(r+=1;r<e.length&&/[a-zA-Z0-9_]/.test(e[r]);)r+=1;t+="[^/]+"}else".+?^$()|[]{}\\".includes(o)?(t+="\\"+o,r+=1):(t+=o,r+=1)}return new RegExp(`^${t}$`)}var le="/_devix/server";function P(e,t,r){let o=A({statusCode:e,message:t,code:r});return new Response(JSON.stringify(o),{status:e,headers:{"Content-Type":"application/json"}})}function Qe(e){if(!e.startsWith(le+"/"))return null;let t=e.slice(le.length+1),r=t.indexOf("/");return r===-1?{namespace:t,path:"/"}:{namespace:t.slice(0,r),path:t.slice(r)}}async function ue(e,t){let r=new URL(e.url),o=Qe(r.pathname);if(!o)return P(404,"Not found","PROXY_NOT_FOUND");let n=t?.[o.namespace];if(!n)return P(404,`Backend "${o.namespace}" not configured`,"BACKEND_NOT_FOUND");if(!B(o.path,n.allowedPaths))return P(403,"Path not allowed","PATH_NOT_ALLOWED");if(B(o.path,n.deniedPaths))return P(403,"Path denied","PATH_DENIED");let s=new URL(o.path+r.search,n.url),a=new Headers;if(n.prepare){let l={request:e,headers:a,url:s};try{let p=await n.prepare(l);if(p instanceof Response)return p}catch(p){return console.error(`[devix] server.${o.namespace}.prepare error:`,p),P(500,"Proxy prepare failed","PREPARE_ERROR")}}if(!a.has("Accept")){let l=e.headers.get("Accept");l&&a.set("Accept",l)}let f=e.headers.get("Content-Type");f&&!a.has("Content-Type")&&a.set("Content-Type",f);let m=null;e.method!=="GET"&&e.method!=="HEAD"&&(m=await e.arrayBuffer(),m.byteLength===0&&(m=null));try{let l=await fetch(s,{method:e.method,headers:a,body:m,redirect:"manual"});return new Response(l.body,{status:l.status,statusText:l.statusText,headers:tt(l.headers)})}catch(l){return console.error(`[devix] server.${o.namespace} fetch error:`,l),P(502,"Bad Gateway","BACKEND_UNREACHABLE")}}var et=new Set(["connection","keep-alive","proxy-authenticate","proxy-authorization","te","trailers","transfer-encoding","upgrade"]);function tt(e){let t=new Headers;return e.forEach((r,o)=>{et.has(o.toLowerCase())||t.set(o,r)}),t}function de(e,{apiModule:t,renderModule:r,loaderTimeout:o,server:n}){n&&e.all("/_devix/server/*",async s=>{try{return await ue(s.req.raw,n)}catch(a){return console.error("[devix] proxy fatal error:",a),s.json({statusCode:500,message:"Internal Server Error"},500)}}),e.all("/api/*",async s=>{try{return await t.handleApiRequest(s.req.url,s.req.raw,n)}catch(a){return console.error(a),s.json({statusCode:500,message:"Internal Server Error"},500)}}),e.get("/_data/*",async s=>{try{let{pathname:a,search:f}=new URL(s.req.url,"http://localhost"),m=a.replace(/^\/_data/,"")+f,l=await r.runLoader(m,s.req.raw,{loaderTimeout:o,server:n});if(l.error)return s.json({statusCode:500,message:"Internal Server Error"},500);if("loaderError"in l){let p=A(l.loaderError);return s.json(p,p.statusCode)}return s.json(l)}catch(a){return console.error(a),s.json({statusCode:500,message:"Internal Server Error"},500)}})}import h from"picocolors";import{networkInterfaces as rt}from"node:os";function ot(e){let t=rt();for(let r of Object.values(t))for(let o of r??[])if(o.family==="IPv4"&&!o.internal)return`http://${o.address}:${e}/`;return null}function pe(e){let t="0.5.4",r=ot(e);console.log(),console.log(` ${h.bold(h.yellow("devix"))} ${h.dim(`v${t}`)}`),console.log(),console.log(` ${h.green("\u279C")} ${h.bold("Local:")} ${h.cyan(`http://localhost:${e}/`)}`),console.log(r?` ${h.green("\u279C")} ${h.bold("Network:")} ${h.cyan(r)}`:` ${h.green("\u279C")} ${h.bold("Network:")} ${h.dim("use --host to expose")}`),console.log()}async function fe(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 me(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 nt}from"vite";function ge(e){let t=nt(e,process.cwd(),"");for(let[r,o]of Object.entries(t))process.env[r]===void 0&&(process.env[r]=o)}import{build as st}from"esbuild";import{join as he}from"node:path";import{unlinkSync as it,writeFileSync as at}from"node:fs";import{pathToFileURL as ct}from"node:url";async function ye(e){let t=await st({entryPoints:[he(e,"devix.config.ts")],bundle:!0,write:!1,format:"esm",platform:"node",packages:"external"}),r=he(e,`.devix-config-${Date.now()}.mjs`);at(r,t.outputFiles[0].text);try{return(await import(ct(r).href)).default}finally{it(r)}}ge("development");var xe="virtual:devix/render",ft="virtual:devix/api",v=await ye(process.cwd()),Re=Number(process.env.PORT)||v.port||3e3,mt=typeof v.host=="string"?v.host:v.host?"0.0.0.0":"localhost",_=await ut({...ce(v),configFile:!1,appType:"custom",server:{middlewareMode:!0}}),ve={render:async(...e)=>(await _.ssrLoadModule(xe)).render(...e),runLoader:async(...e)=>(await _.ssrLoadModule(xe)).runLoader(...e)},gt={handleApiRequest:async(...e)=>(await _.ssrLoadModule(ft)).handleApiRequest(...e)},V=new pt;de(V,{renderModule:ve,apiModule:gt,server:v.server});V.get("*",async e=>{try{let{html:t,statusCode:r,headers:o}=await ve.render(e.req.url,e.req.raw,{loaderTimeout:me(v.loaderTimeout??1e4),server:v.server}),s=(await fe(_)).map(l=>`<link rel="stylesheet" href="${l}">`).join(`
270
279
  `),a=s?t.replace("</head>",`${s}
271
- </head>`):t,f=await _.transformIndexHtml(e.req.url,`<!DOCTYPE html>${a}`),m=e.html(f,r);for(let[l,p]of Object.entries(n))m.headers.set(l,p);return m}catch(t){return _.ssrFixStacktrace(t),console.error(t),e.text("Internal Server Error",500)}});var yt=dt(V.fetch);lt(async(e,t)=>{await new Promise(r=>_.middlewares(e,t,r)),t.writableEnded||await yt(e,t)}).listen(Re,mt,()=>{pe(Re)});
280
+ </head>`):t,f=await _.transformIndexHtml(e.req.url,`<!DOCTYPE html>${a}`),m=e.html(f,r);for(let[l,p]of Object.entries(o))m.headers.set(l,p);return m}catch(t){return _.ssrFixStacktrace(t),console.error(t),e.text("Internal Server Error",500)}});var ht=dt(V.fetch);lt(async(e,t)=>{await new Promise(r=>_.middlewares(e,t,r)),t.writableEnded||await ht(e,t)}).listen(Re,mt,()=>{pe(Re)});
272
281
  //# sourceMappingURL=dev-server.js.map