@devlusoft/devix 0.1.0 → 0.2.1

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.
Files changed (95) hide show
  1. package/README.md +6 -4
  2. package/dist/cli/build.js +39 -178
  3. package/dist/cli/build.js.map +4 -4
  4. package/dist/cli/dev.js +41 -253
  5. package/dist/cli/dev.js.map +4 -4
  6. package/dist/cli/generate.js +39 -281
  7. package/dist/cli/generate.js.map +4 -4
  8. package/dist/cli/index.js +44 -527
  9. package/dist/cli/index.js.map +4 -4
  10. package/dist/cli/start.js +1 -77
  11. package/dist/cli/start.js.map +4 -4
  12. package/dist/config.js +1 -16
  13. package/dist/config.js.map +2 -2
  14. package/dist/runtime/api-context.d.ts +3 -2
  15. package/dist/runtime/api-context.js +1 -17
  16. package/dist/runtime/api-context.js.map +3 -3
  17. package/dist/runtime/client-router.js +1 -58
  18. package/dist/runtime/client-router.js.map +2 -2
  19. package/dist/runtime/context.js +1 -14
  20. package/dist/runtime/context.js.map +2 -2
  21. package/dist/runtime/error-boundary.js +1 -36
  22. package/dist/runtime/error-boundary.js.map +2 -2
  23. package/dist/runtime/fetch.d.ts +19 -0
  24. package/dist/runtime/fetch.js +2 -0
  25. package/dist/runtime/fetch.js.map +7 -0
  26. package/dist/runtime/head.js +1 -68
  27. package/dist/runtime/head.js.map +2 -2
  28. package/dist/runtime/index.d.ts +7 -1
  29. package/dist/runtime/index.js +1 -299
  30. package/dist/runtime/index.js.map +4 -4
  31. package/dist/runtime/link.js +1 -42
  32. package/dist/runtime/link.js.map +2 -2
  33. package/dist/runtime/metadata.js +1 -21
  34. package/dist/runtime/metadata.js.map +2 -2
  35. package/dist/runtime/router-provider.js +1 -258
  36. package/dist/runtime/router-provider.js.map +2 -2
  37. package/dist/server/api-router.d.ts +1 -0
  38. package/dist/server/api-router.js +1 -63
  39. package/dist/server/api-router.js.map +3 -3
  40. package/dist/server/api.js +1 -122
  41. package/dist/server/api.js.map +3 -3
  42. package/dist/server/collect-css.js +1 -14
  43. package/dist/server/collect-css.js.map +2 -2
  44. package/dist/server/index.js +1 -132
  45. package/dist/server/index.js.map +3 -3
  46. package/dist/server/pages-router.js +1 -63
  47. package/dist/server/pages-router.js.map +2 -2
  48. package/dist/server/render.js +1 -305
  49. package/dist/server/render.js.map +2 -2
  50. package/dist/server/routes.js +1 -41
  51. package/dist/server/routes.js.map +2 -2
  52. package/dist/utils/async.js +1 -13
  53. package/dist/utils/async.js.map +2 -2
  54. package/dist/utils/banner.js +1 -33
  55. package/dist/utils/banner.js.map +2 -2
  56. package/dist/utils/cookies.d.ts +12 -0
  57. package/dist/utils/cookies.js +2 -0
  58. package/dist/utils/cookies.js.map +7 -0
  59. package/dist/utils/duration.js +1 -21
  60. package/dist/utils/duration.js.map +2 -2
  61. package/dist/utils/env.d.ts +1 -0
  62. package/dist/utils/env.js +2 -0
  63. package/dist/utils/env.js.map +7 -0
  64. package/dist/utils/html.js +1 -11
  65. package/dist/utils/html.js.map +2 -2
  66. package/dist/utils/patterns.js +1 -7
  67. package/dist/utils/patterns.js.map +2 -2
  68. package/dist/utils/response.d.ts +6 -0
  69. package/dist/utils/response.js +2 -0
  70. package/dist/utils/response.js.map +7 -0
  71. package/dist/vite/codegen/api.js +6 -12
  72. package/dist/vite/codegen/api.js.map +2 -2
  73. package/dist/vite/codegen/client-routes.js +6 -12
  74. package/dist/vite/codegen/client-routes.js.map +2 -2
  75. package/dist/vite/codegen/context.js +2 -8
  76. package/dist/vite/codegen/context.js.map +2 -2
  77. package/dist/vite/codegen/entry-client.js +4 -10
  78. package/dist/vite/codegen/entry-client.js.map +2 -2
  79. package/dist/vite/codegen/extract-methods.d.ts +4 -0
  80. package/dist/vite/codegen/extract-methods.js +2 -0
  81. package/dist/vite/codegen/extract-methods.js.map +7 -0
  82. package/dist/vite/codegen/render.js +6 -12
  83. package/dist/vite/codegen/render.js.map +2 -2
  84. package/dist/vite/codegen/routes-dts.d.ts +10 -0
  85. package/dist/vite/codegen/routes-dts.js +23 -0
  86. package/dist/vite/codegen/routes-dts.js.map +7 -0
  87. package/dist/vite/codegen/scan-api.d.ts +2 -0
  88. package/dist/vite/codegen/scan-api.js +2 -0
  89. package/dist/vite/codegen/scan-api.js.map +7 -0
  90. package/dist/vite/codegen/write-routes-dts.d.ts +1 -0
  91. package/dist/vite/codegen/write-routes-dts.js +2 -0
  92. package/dist/vite/codegen/write-routes-dts.js.map +7 -0
  93. package/dist/vite/index.js +41 -119
  94. package/dist/vite/index.js.map +4 -4
  95. package/package.json +2 -2
package/dist/cli/dev.js CHANGED
@@ -1,20 +1,6 @@
1
- // src/cli/dev.ts
2
- import { createServer } from "node:http";
3
- import { createServer as createViteServer } from "vite";
4
- import { getRequestListener } from "@hono/node-server";
5
- import { Hono } from "hono";
6
-
7
- // src/vite/index.ts
8
- import { mergeConfig } from "vite";
9
- import react from "@vitejs/plugin-react";
10
- import { fileURLToPath } from "node:url";
11
- import { dirname, resolve } from "node:path";
12
-
13
- // src/vite/codegen/entry-client.ts
14
- function generateEntryClient({ cssUrls }) {
15
- const cssImports = cssUrls.map((u) => `import '${u}'`).join("\n");
16
- return `
17
- ${cssImports}
1
+ import{createServer as xt}from"node:http";import{createServer as yt}from"vite";import{getRequestListener as Rt}from"@hono/node-server";import{Hono as vt}from"hono";import{mergeConfig as lt}from"vite";import ut from"@vitejs/plugin-react";import{fileURLToPath as pt}from"node:url";import{dirname as dt,resolve as f}from"node:path";function b({cssUrls:t}){return`
2
+ ${t.map(r=>`import '${r}'`).join(`
3
+ `)}
18
4
  import "@vitejs/plugin-react/preamble"
19
5
  import React from "react"
20
6
  import {hydrateRoot, createRoot} from 'react-dom/client'
@@ -68,17 +54,12 @@ if (!window.__DEVIX__) {
68
54
  )
69
55
  }
70
56
  }
71
- `;
72
- }
73
-
74
- // src/vite/codegen/client-routes.ts
75
- function generateClientRoutes({ pagesDir, matcherPath }) {
76
- return `
57
+ `}function L({pagesDir:t,matcherPath:e}){return`
77
58
  import React from 'react'
78
- import { createMatcher } from '${matcherPath}'
79
- const pageFiles = import.meta.glob(['/${pagesDir}/**/*.tsx', '!**/error.tsx', '!**/layout.tsx'])
80
- const layoutFiles = import.meta.glob('/${pagesDir}/**/layout.tsx')
81
- const errorFiles = import.meta.glob('/${pagesDir}/**/error.tsx')
59
+ import { createMatcher } from '${e}'
60
+ const pageFiles = import.meta.glob(['/${t}/**/*.tsx', '!**/error.tsx', '!**/layout.tsx'])
61
+ const layoutFiles = import.meta.glob('/${t}/**/layout.tsx')
62
+ const errorFiles = import.meta.glob('/${t}/**/error.tsx')
82
63
 
83
64
  export const matchClientRoute = createMatcher(pageFiles, layoutFiles)
84
65
 
@@ -101,21 +82,16 @@ export function getDefaultErrorPage() {
101
82
  )
102
83
  }
103
84
  }
104
- `;
105
- }
85
+ `}function M({pagesDir:t,renderPath:e}){return`
86
+ import { render as _render, runLoader as _runLoader, getStaticRoutes as _getStaticRoutes } from '${e}'
106
87
 
107
- // src/vite/codegen/render.ts
108
- function generateRender({ pagesDir, renderPath }) {
109
- return `
110
- import { render as _render, runLoader as _runLoader, getStaticRoutes as _getStaticRoutes } from '${renderPath}'
111
-
112
- const _pages = import.meta.glob(['/${pagesDir}/**/*.tsx', '!**/error.tsx', '!**/layout.tsx'])
113
- const _layouts = import.meta.glob('/${pagesDir}/**/layout.tsx')
88
+ const _pages = import.meta.glob(['/${t}/**/*.tsx', '!**/error.tsx', '!**/layout.tsx'])
89
+ const _layouts = import.meta.glob('/${t}/**/layout.tsx')
114
90
 
115
91
  const _glob = {
116
92
  pages: _pages,
117
93
  layouts: _layouts,
118
- pagesDir: '/${pagesDir}',
94
+ pagesDir: '/${t}',
119
95
  }
120
96
 
121
97
  export function render(url, request, options) {
@@ -129,233 +105,45 @@ export function runLoader(url, request, options) {
129
105
  export function getStaticRoutes() {
130
106
  return _getStaticRoutes(_glob)
131
107
  }
132
- `;
133
- }
108
+ `}function O({apiPath:t,appDir:e}){return`
109
+ import { handleApiRequest as _handleApiRequest } from '${t}'
134
110
 
135
- // src/vite/codegen/api.ts
136
- function generateApi({ apiPath, appDir }) {
137
- return `
138
- import { handleApiRequest as _handleApiRequest } from '${apiPath}'
139
-
140
- const _routes = import.meta.glob(['/${appDir}/api/**/*.ts', '!**/middleware.ts'])
141
- const _middlewares = import.meta.glob('/${appDir}/api/**/middleware.ts')
111
+ const _routes = import.meta.glob(['/${e}/api/**/*.ts', '!**/middleware.ts'])
112
+ const _middlewares = import.meta.glob('/${e}/api/**/middleware.ts')
142
113
 
143
114
  const _glob = {
144
115
  routes: _routes,
145
116
  middlewares: _middlewares,
146
- apiDir: '/${appDir}/api',
117
+ apiDir: '/${e}/api',
147
118
  }
148
119
 
149
120
  export function handleApiRequest(url, request) {
150
121
  return _handleApiRequest(url, request, _glob)
151
122
  }
152
- `;
153
- }
154
-
155
- // src/server/pages-router.ts
156
- var cache = null;
157
- function invalidatePagesCache() {
158
- cache = null;
159
- }
160
-
161
- // src/server/api-router.ts
162
- var cache2 = null;
163
- function invalidateApiCache() {
164
- cache2 = null;
165
- }
166
-
167
- // src/vite/codegen/context.ts
168
- function generateContext() {
169
- return `
123
+ `}function x(t){return t.replace(/\.(tsx|ts|jsx|js)$/,"").replace(/\(.*?\)\//g,"").replace(/^index$|\/index$/,"").replace(/\[([^\]]+)]/g,":$1")||"/"}var J=null;function y(){J=null}function I(t,e){let r=t.slice(e.length+1).replace(/\\/g,"/"),o=x(r);return o==="/"?"/api":`/api/${o}`.replace("/api//","/api/")}var Z=null;function R(){Z=null}function k(){return`
170
124
  export {RouterContext} from '@devlusoft/devix/runtime/context'
171
- `;
172
- }
173
-
174
- // src/vite/index.ts
175
- var __dirname = dirname(fileURLToPath(import.meta.url));
176
- var VIRTUAL_ENTRY_CLIENT = "virtual:devix/entry-client";
177
- var VIRTUAL_CLIENT_ROUTES = "virtual:devix/client-routes";
178
- var VIRTUAL_RENDER = "virtual:devix/render";
179
- var VIRTUAL_API = "virtual:devix/api";
180
- var VIRTUAL_CONTEXT = "virtual:devix/context";
181
- function devix(config2) {
182
- const appDir = config2.appDir ?? "app";
183
- const pagesDir = `${appDir}/pages`;
184
- const cssUrls = (config2.css ?? []).map((u) => u.startsWith("/") ? u : `/${u.replace(/^\.\//, "")}`);
185
- const renderPath = resolve(__dirname, "../server/render.js").replace(/\\/g, "/");
186
- const apiPath = resolve(__dirname, "../server/api.js").replace(/\\/g, "/");
187
- const matcherPath = resolve(__dirname, "../runtime/client-router.js").replace(/\\/g, "/");
188
- const virtualPlugin = {
189
- name: "devix",
190
- enforce: "pre",
191
- resolveId(id) {
192
- if (id === VIRTUAL_ENTRY_CLIENT) return `\0${VIRTUAL_ENTRY_CLIENT}`;
193
- if (id === VIRTUAL_CLIENT_ROUTES) return `\0${VIRTUAL_CLIENT_ROUTES}`;
194
- if (id === VIRTUAL_RENDER) return `\0${VIRTUAL_RENDER}`;
195
- if (id === VIRTUAL_API) return `\0${VIRTUAL_API}`;
196
- if (id === VIRTUAL_CONTEXT) return `\0${VIRTUAL_CONTEXT}`;
197
- },
198
- load(id) {
199
- if (id === `\0${VIRTUAL_ENTRY_CLIENT}`)
200
- return generateEntryClient({ cssUrls });
201
- if (id === `\0${VIRTUAL_CLIENT_ROUTES}`)
202
- return generateClientRoutes({ pagesDir, matcherPath });
203
- if (id === `\0${VIRTUAL_RENDER}`)
204
- return generateRender({ pagesDir, renderPath });
205
- if (id === `\0${VIRTUAL_API}`)
206
- return generateApi({ apiPath, appDir });
207
- if (id === `\0${VIRTUAL_CONTEXT}`)
208
- return generateContext();
209
- },
210
- configureServer(server) {
211
- server.watcher.on("add", (file) => {
212
- if (file.startsWith(resolve(process.cwd(), pagesDir))) invalidatePagesCache();
213
- if (file.includes(`${appDir}/api`)) invalidateApiCache();
214
- });
215
- server.watcher.on("unlink", (file) => {
216
- if (file.startsWith(resolve(process.cwd(), pagesDir))) invalidatePagesCache();
217
- if (file.includes(`${appDir}/api`)) invalidateApiCache();
218
- });
219
- }
220
- };
221
- const base = {
222
- plugins: [react(), virtualPlugin],
223
- ssr: { noExternal: ["@devlusoft/devix"] },
224
- ...config2.envPrefix ? { envPrefix: config2.envPrefix } : {}
225
- };
226
- return mergeConfig(base, config2.vite ?? {});
227
- }
228
-
229
- // src/server/routes.ts
230
- function registerApiRoutes(app2, { apiModule: apiModule2, renderModule: renderModule2, loaderTimeout }) {
231
- app2.all("/api/*", async (c) => {
232
- try {
233
- return await apiModule2.handleApiRequest(c.req.url, c.req.raw);
234
- } catch (e) {
235
- console.error(e);
236
- return c.json({ error: "internal error" }, 500);
237
- }
238
- });
239
- app2.get("/_data/*", async (c) => {
240
- try {
241
- const { pathname, search } = new URL(c.req.url, "http://localhost");
242
- const url = pathname.replace(/^\/_data/, "") + search;
243
- const data = await renderModule2.runLoader(url, c.req.raw, { loaderTimeout });
244
- return c.json(data);
245
- } catch (e) {
246
- console.error(e);
247
- return c.json({ error: "internal error" }, 500);
248
- }
249
- });
250
- }
251
-
252
- // src/utils/banner.ts
253
- import pc from "picocolors";
254
- import { networkInterfaces } from "node:os";
255
- import { createRequire } from "node:module";
256
- function getNetworkUrl(port2) {
257
- const nets = networkInterfaces();
258
- for (const interfaces of Object.values(nets)) {
259
- for (const net of interfaces ?? []) {
260
- if (net.family === "IPv4" && !net.internal) {
261
- return `http://${net.address}:${port2}/`;
262
- }
263
- }
264
- }
265
- return null;
266
- }
267
- function printDevBanner(port2) {
268
- const req = createRequire(import.meta.url);
269
- const version = req("../../package.json").version;
270
- const networkUrl = getNetworkUrl(port2);
271
- console.log();
272
- console.log(` ${pc.bold(pc.yellow("devix"))} ${pc.dim(`v${version}`)}`);
273
- console.log();
274
- console.log(` ${pc.green("\u279C")} ${pc.bold("Local:")} ${pc.cyan(`http://localhost:${port2}/`)}`);
275
- if (networkUrl) {
276
- console.log(` ${pc.green("\u279C")} ${pc.bold("Network:")} ${pc.cyan(networkUrl)}`);
277
- } else {
278
- console.log(` ${pc.green("\u279C")} ${pc.bold("Network:")} ${pc.dim("use --host to expose")}`);
279
- }
280
- console.log();
281
- }
282
-
283
- // src/server/collect-css.ts
284
- async function collectCss(vite2) {
285
- const cssUrls = /* @__PURE__ */ new Set();
286
- for (const [, mod] of vite2.moduleGraph.idToModuleMap) {
287
- if (!mod.id) continue;
288
- if (mod.id.endsWith(".css") || mod.id.includes(".css?")) {
289
- cssUrls.add(mod.url);
290
- }
125
+ `}import{readFileSync as et,readdirSync as rt,statSync as ot}from"node:fs";import{join as w,relative as nt}from"node:path";var K=/export\s+(?:const|async\s+function|function)\s+(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\b/g;function Q(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function U(t){let e=new Set;for(let r of Q(t).matchAll(K))e.add(r[1]);return[...e]}function tt(t,e){return"_api_"+t.slice(`${e}/`.length).replace(/\.(ts|tsx)$/,"").replace(/[^a-zA-Z0-9]/g,"_")}function q(t,e,r){return{filePath:t,urlPattern:I(t,e),identifier:tt(t,e),methods:r}}function v(t,e){if(t.length===0)return`// auto-generado por devix \u2014 no editar
126
+ declare module '@devlusoft/devix' {
127
+ interface ApiRoutes {}
128
+ }
129
+ `;let r=t.map(n=>{let s="../"+n.filePath.replace(/\.(ts|tsx)$/,"");return`import type * as ${n.identifier} from '${s}'`}).join(`
130
+ `),o=t.flatMap(n=>n.methods.map(s=>` '${s} ${n.urlPattern}': InferRoute<(typeof ${n.identifier})['${s}']>`)).join(`
131
+ `);return`// auto-generado por devix \u2014 no editar
132
+ ${r}
133
+
134
+ type JsonResponse<T> = Response & { readonly __body: T }
135
+ type InferRoute<T> = T extends (...args: any[]) => any
136
+ ? Awaited<ReturnType<T>> extends JsonResponse<infer U>
137
+ ? U
138
+ : Exclude<Awaited<ReturnType<T>>, Response | null | void>
139
+ : never
140
+
141
+ declare module '@devlusoft/devix' {
142
+ interface ApiRoutes {
143
+ ${o}
291
144
  }
292
- return [...cssUrls];
293
145
  }
294
-
295
- // src/utils/duration.ts
296
- function parseDuration(value) {
297
- if (typeof value === "number") return value;
298
- const match = value.trim().match(/^(\d+(?:\.\d+)?)\s*(ms|s|m|h)?$/);
299
- if (!match) throw new Error(`[devix] Invalid duration: "${value}". Use a number (ms) or a string like "5s", "2m", "500ms".`);
300
- const n = parseFloat(match[1]);
301
- switch (match[2]) {
302
- case "h":
303
- return n * 36e5;
304
- case "m":
305
- return n * 6e4;
306
- case "s":
307
- return n * 1e3;
308
- case "ms":
309
- default:
310
- return n;
311
- }
312
- }
313
-
314
- // src/cli/dev.ts
315
- var VIRTUAL_RENDER2 = "virtual:devix/render";
316
- var VIRTUAL_API2 = "virtual:devix/api";
317
- var config = (await import(`${process.cwd()}/devix.config.ts`)).default;
318
- var port = Number(process.env.PORT) || config.port || 3e3;
319
- var host = typeof config.host === "string" ? config.host : config.host ? "0.0.0.0" : "localhost";
320
- var vite = await createViteServer({
321
- ...devix(config),
322
- configFile: false,
323
- appType: "custom",
324
- server: { middlewareMode: true }
325
- });
326
- var renderModule = {
327
- render: async (...args) => (await vite.ssrLoadModule(VIRTUAL_RENDER2)).render(...args),
328
- runLoader: async (...args) => (await vite.ssrLoadModule(VIRTUAL_RENDER2)).runLoader(...args)
329
- };
330
- var apiModule = {
331
- handleApiRequest: async (...args) => (await vite.ssrLoadModule(VIRTUAL_API2)).handleApiRequest(...args)
332
- };
333
- var app = new Hono();
334
- registerApiRoutes(app, { renderModule, apiModule });
335
- app.get("*", async (c) => {
336
- try {
337
- const { html, statusCode, headers } = await renderModule.render(c.req.url, c.req.raw, { loaderTimeout: parseDuration(config.loaderTimeout ?? 1e4) });
338
- const cssUrls = await collectCss(vite);
339
- const cssLinks = cssUrls.map((url) => `<link rel="stylesheet" href="${url}">`).join("\n");
340
- const htmlWithCss = cssLinks ? html.replace("</head>", `${cssLinks}
341
- </head>`) : html;
342
- const transformed = await vite.transformIndexHtml(c.req.url, `<!DOCTYPE html>${htmlWithCss}`);
343
- const res = c.html(transformed, statusCode);
344
- for (const [key, value] of Object.entries(headers)) {
345
- res.headers.set(key, value);
346
- }
347
- return res;
348
- } catch (e) {
349
- vite.ssrFixStacktrace(e);
350
- console.error(e);
351
- return c.text("Internal Server Error", 500);
352
- }
353
- });
354
- var honoHandler = getRequestListener(app.fetch);
355
- createServer(async (req, res) => {
356
- await new Promise((resolve2) => vite.middlewares(req, res, resolve2));
357
- if (!res.writableEnded) await honoHandler(req, res);
358
- }).listen(port, host, () => {
359
- printDevBanner(port);
360
- });
146
+ `}function H(t,e){let r=[];for(let o of rt(t)){let n=w(t,o);ot(n).isDirectory()?r.push(...H(n,e)):/\.(ts|tsx)$/.test(o)&&r.push(nt(e,n).replace(/\\/g,"/"))}return r}function E(t,e){let r=w(e,t,"api"),o;try{o=H(r,e)}catch{return[]}return o.filter(n=>!n.endsWith("middleware.ts")&&!n.endsWith("middleware.tsx")).flatMap(n=>{try{let s=et(w(e,n),"utf-8"),l=U(s);return l.length===0?[]:[q(n,`${t}/api`,l)]}catch{return[]}})}import{mkdirSync as it,readFileSync as st,writeFileSync as at,existsSync as ct}from"node:fs";import{join as j}from"node:path";function $(t,e){let r=j(e,".devix"),o=j(r,"routes.d.ts");return it(r,{recursive:!0}),ct(o)&&st(o,"utf-8")===t?!1:(at(o,t,"utf-8"),!0)}var P=dt(pt(import.meta.url)),_="virtual:devix/entry-client",T="virtual:devix/client-routes",A="virtual:devix/render",D="virtual:devix/api",C="virtual:devix/context";function F(t){let e=t.appDir??"app",r=`${e}/pages`,o=(t.css??[]).map(i=>i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`),n=f(P,"../server/render.js").replace(/\\/g,"/"),s=f(P,"../server/api.js").replace(/\\/g,"/"),l=f(P,"../runtime/client-router.js").replace(/\\/g,"/"),g={name:"devix",enforce:"pre",resolveId(i){if(i===_)return`\0${_}`;if(i===T)return`\0${T}`;if(i===A)return`\0${A}`;if(i===D)return`\0${D}`;if(i===C)return`\0${C}`},load(i){if(i===`\0${_}`)return b({cssUrls:o});if(i===`\0${T}`)return L({pagesDir:r,matcherPath:l});if(i===`\0${A}`)return M({pagesDir:r,renderPath:n});if(i===`\0${D}`)return O({apiPath:s,appDir:e});if(i===`\0${C}`)return k()},buildStart(){let i=process.cwd(),u=E(e,i);$(v(u,`${e}/api`),i)},configureServer(i){let u=process.cwd(),h=()=>{let c=E(e,u);$(v(c,`${e}/api`),u)};i.watcher.on("add",c=>{c.startsWith(f(u,r))&&y(),c.includes(`${e}/api`)&&(R(),h())}),i.watcher.on("unlink",c=>{c.startsWith(f(u,r))&&y(),c.includes(`${e}/api`)&&(R(),h())}),i.watcher.on("change",c=>{c.includes(`${e}/api`)&&!c.endsWith("middleware.ts")&&h()})}},d={plugins:[ut(),g],ssr:{noExternal:["@devlusoft/devix"]},...t.envPrefix?{envPrefix:t.envPrefix}:{}};return lt(d,t.vite??{})}function N(t,{apiModule:e,renderModule:r,loaderTimeout:o}){t.all("/api/*",async n=>{try{return await e.handleApiRequest(n.req.url,n.req.raw)}catch(s){return console.error(s),n.json({error:"internal error"},500)}}),t.get("/_data/*",async n=>{try{let{pathname:s,search:l}=new URL(n.req.url,"http://localhost"),g=s.replace(/^\/_data/,"")+l,d=await r.runLoader(g,n.req.raw,{loaderTimeout:o});return n.json(d)}catch(s){return console.error(s),n.json({error:"internal error"},500)}})}import a from"picocolors";import{networkInterfaces as mt}from"node:os";import{createRequire as gt}from"node:module";function ft(t){let e=mt();for(let r of Object.values(e))for(let o of r??[])if(o.family==="IPv4"&&!o.internal)return`http://${o.address}:${t}/`;return null}function V(t){let r=gt(import.meta.url)("../../package.json").version,o=ft(t);console.log(),console.log(` ${a.bold(a.yellow("devix"))} ${a.dim(`v${r}`)}`),console.log(),console.log(` ${a.green("\u279C")} ${a.bold("Local:")} ${a.cyan(`http://localhost:${t}/`)}`),console.log(o?` ${a.green("\u279C")} ${a.bold("Network:")} ${a.cyan(o)}`:` ${a.green("\u279C")} ${a.bold("Network:")} ${a.dim("use --host to expose")}`),console.log()}async function W(t){let e=new Set;for(let[,r]of t.moduleGraph.idToModuleMap)r.id&&(r.id.endsWith(".css")||r.id.includes(".css?"))&&e.add(r.url);return[...e]}function X(t){if(typeof t=="number")return t;let e=t.trim().match(/^(\d+(?:\.\d+)?)\s*(ms|s|m|h)?$/);if(!e)throw new Error(`[devix] Invalid duration: "${t}". Use a number (ms) or a string like "5s", "2m", "500ms".`);let r=parseFloat(e[1]);switch(e[2]){case"h":return r*36e5;case"m":return r*6e4;case"s":return r*1e3;default:return r}}import{loadEnv as ht}from"vite";function Y(t){let e=ht(t,process.cwd(),"");for(let[r,o]of Object.entries(e))process.env[r]===void 0&&(process.env[r]=o)}Y("development");var B="virtual:devix/render",wt="virtual:devix/api",m=(await import(`${process.cwd()}/devix.config.ts`)).default,G=Number(process.env.PORT)||m.port||3e3,Et=typeof m.host=="string"?m.host:m.host?"0.0.0.0":"localhost",p=await yt({...F(m),configFile:!1,appType:"custom",server:{middlewareMode:!0}}),z={render:async(...t)=>(await p.ssrLoadModule(B)).render(...t),runLoader:async(...t)=>(await p.ssrLoadModule(B)).runLoader(...t)},$t={handleApiRequest:async(...t)=>(await p.ssrLoadModule(wt)).handleApiRequest(...t)},S=new vt;N(S,{renderModule:z,apiModule:$t});S.get("*",async t=>{try{let{html:e,statusCode:r,headers:o}=await z.render(t.req.url,t.req.raw,{loaderTimeout:X(m.loaderTimeout??1e4)}),s=(await W(p)).map(i=>`<link rel="stylesheet" href="${i}">`).join(`
147
+ `),l=s?e.replace("</head>",`${s}
148
+ </head>`):e,g=await p.transformIndexHtml(t.req.url,`<!DOCTYPE html>${l}`),d=t.html(g,r);for(let[i,u]of Object.entries(o))d.headers.set(i,u);return d}catch(e){return p.ssrFixStacktrace(e),console.error(e),t.text("Internal Server Error",500)}});var Pt=Rt(S.fetch);xt(async(t,e)=>{await new Promise(r=>p.middlewares(t,e,r)),e.writableEnded||await Pt(t,e)}).listen(G,Et,()=>{V(G)});
361
149
  //# sourceMappingURL=dev.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/cli/dev.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/server/pages-router.ts", "../../src/server/api-router.ts", "../../src/vite/codegen/context.ts", "../../src/server/routes.ts", "../../src/utils/banner.ts", "../../src/server/collect-css.ts", "../../src/utils/duration.ts"],
4
- "sourcesContent": ["import {createServer} from 'node:http'\nimport {createServer as createViteServer} from 'vite'\nimport {getRequestListener} from '@hono/node-server'\nimport {Hono} from 'hono'\nimport type {DevixConfig} from '../config'\nimport {devix} from '../vite'\nimport {registerApiRoutes} from '../server/routes'\nimport {printDevBanner} from \"../utils/banner\";\nimport {collectCss} from \"../server/collect-css\";\nimport {parseDuration} from \"../utils/duration\";\n\nconst VIRTUAL_RENDER = 'virtual:devix/render'\nconst VIRTUAL_API = 'virtual:devix/api'\n\nconst config: DevixConfig = (await import(`${process.cwd()}/devix.config.ts`)).default\nconst port = Number(process.env.PORT) || config.port || 3000\nconst host = typeof config.host === 'string' ? config.host : config.host ? '0.0.0.0' : 'localhost'\n\nconst vite = await createViteServer({\n ...devix(config),\n configFile: false,\n appType: 'custom',\n server: {middlewareMode: true},\n})\n\nconst renderModule = {\n render: async (...args: any[]) => (await vite.ssrLoadModule(VIRTUAL_RENDER)).render(...args),\n runLoader: async (...args: any[]) => (await vite.ssrLoadModule(VIRTUAL_RENDER)).runLoader(...args),\n}\n\nconst apiModule = {\n handleApiRequest: async (...args: any[]) => (await vite.ssrLoadModule(VIRTUAL_API)).handleApiRequest(...args),\n}\n\nconst app = new Hono()\n\nregisterApiRoutes(app, {renderModule, apiModule})\n\napp.get('*', async (c) => {\n try {\n const {html, statusCode, headers} = await renderModule.render(c.req.url, c.req.raw, {loaderTimeout: parseDuration(config.loaderTimeout ?? 10_000)})\n\n const cssUrls = await collectCss(vite)\n const cssLinks = cssUrls.map(url => `<link rel=\"stylesheet\" href=\"${url}\">`).join('\\n')\n\n const htmlWithCss = cssLinks ? html.replace('</head>', `${cssLinks}\\n</head>`) : html\n const transformed = await vite.transformIndexHtml(c.req.url, `<!DOCTYPE html>${htmlWithCss}`)\n\n const res = c.html(transformed, statusCode)\n for (const [key, value] of Object.entries(headers as Record<string, string>)) {\n res.headers.set(key, value)\n }\n return res\n } catch (e) {\n vite.ssrFixStacktrace(e as Error)\n console.error(e)\n return c.text('Internal Server Error', 500)\n }\n})\n\nconst honoHandler = getRequestListener(app.fetch)\n\ncreateServer(async (req, res) => {\n await new Promise<void>(resolve => vite.middlewares(req, res, resolve))\n if (!res.writableEnded) await honoHandler(req, res)\n}).listen(port, host, () => {\n printDevBanner(port)\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, resolve} from 'node:path'\nimport {generateEntryClient} from './codegen/entry-client'\nimport {generateClientRoutes} from './codegen/client-routes'\nimport {generateRender} from './codegen/render'\nimport {generateApi} from './codegen/api'\nimport {invalidatePagesCache} from \"../server/pages-router\";\nimport {invalidateApiCache} from \"../server/api-router\";\nimport {generateContext} from \"./codegen/context\";\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'\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\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 },\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 },\n\n configureServer(server) {\n server.watcher.on('add', (file) => {\n if (file.startsWith(resolve(process.cwd(), pagesDir))) invalidatePagesCache()\n if (file.includes(`${appDir}/api`)) invalidateApiCache()\n })\n server.watcher.on('unlink', (file) => {\n if (file.startsWith(resolve(process.cwd(), pagesDir))) invalidatePagesCache()\n if (file.includes(`${appDir}/api`)) invalidateApiCache()\n })\n },\n }\n\n const base: UserConfig = {\n plugins: [react(), virtualPlugin],\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\n const matched = matchClientRoute(window.location.pathname)\n\n 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 initialMeta: metadata,\n initialViewport: viewport,\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", "import {routePattern} from \"../utils/patterns\";\n\nexport interface Page {\n path: string\n key: string\n params: string[]\n regex: RegExp\n}\n\nexport interface Layout {\n dir: string\n key: string\n}\n\nexport interface PagesResult {\n pages: Page[]\n layouts: Layout[]\n}\n\nfunction keyToRoutePattern(key: string, pagesDir: string): string {\n const rel = key.slice(pagesDir.length + 1).replace(/\\\\/g, '/')\n const pattern = routePattern(rel)\n return pattern === \"/\" ? \"/\" : `/${pattern}`\n}\n\nfunction keyToDir(key: string): string {\n return key.slice(0, key.lastIndexOf('/'))\n}\n\nlet cache: PagesResult | null = null\n\nexport function invalidatePagesCache() {\n cache = null\n}\n\nexport function buildPages(pageKeys: string[], layoutKeys: string[], pagesDir: string): PagesResult {\n if (cache) return cache\n\n const pages: Page[] = []\n const layouts: Layout[] = []\n\n for (const key of layoutKeys) {\n layouts.push({dir: keyToDir(key), key})\n }\n\n for (const key of pageKeys) {\n const pattern = keyToRoutePattern(key, pagesDir)\n const params = [...pattern.matchAll(/:([^/]+)/g)].map(m => m[1])\n const regexStr = pattern\n .replace(/:[^/]+/g, '([^/]+)')\n .replace(/\\//g, '\\\\/')\n pages.push({path: pattern, key, params, regex: new RegExp(`^${regexStr}$`)})\n }\n\n pages.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 cache = {pages, layouts}\n return cache\n}\n\nexport function collectLayoutChain(pageKey: string, layouts: Layout[]): Layout[] {\n const pageDir = keyToDir(pageKey)\n\n return layouts\n .filter(layout => pageDir.startsWith(layout.dir))\n .sort((a, b) => a.dir.split('/').length - b.dir.split('/').length)\n}\n\nexport function matchPage(pathname: string, pages: Page[]): {\n page: Page\n params: Record<string, string>\n} | null {\n for (const page of pages) {\n const match = pathname.match(page.regex)\n if (match) {\n const params: Record<string, string> = {}\n page.params.forEach((name, i) => {\n params[name] = decodeURIComponent(match[i + 1])\n })\n return {page, params}\n }\n }\n return null\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\nfunction 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\nlet cache: ApiResult | null = null\n\nexport function invalidateApiCache() {\n cache = null\n}\n\nexport function buildRoutes(routeKeys: string[], middlewareKeys: string[], apiDir: string): ApiResult {\n if (cache) return cache\n\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 cache = {routes, middlewares}\n return cache\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", "export function generateContext(): string {\n return `\nexport {RouterContext} from '@devlusoft/devix/runtime/context'\n`\n}", "import type {Hono} from 'hono'\nimport type {Manifest} from 'vite'\n\ninterface ServerOptions {\n renderModule: any\n apiModule: any\n manifest?: Manifest\n loaderTimeout?: number\n}\n\nexport function registerApiRoutes(app: Hono, {apiModule, renderModule, loaderTimeout}: ServerOptions) {\n app.all('/api/*', async (c) => {\n try {\n return await apiModule.handleApiRequest(c.req.url, c.req.raw)\n } catch (e) {\n console.error(e)\n return c.json({error: 'internal error'}, 500)\n }\n })\n\n app.get('/_data/*', async (c) => {\n try {\n const {pathname, search} = new URL(c.req.url, 'http://localhost')\n const url = pathname.replace(/^\\/_data/, '') + search\n\n const data = await renderModule.runLoader(url, c.req.raw, {loaderTimeout})\n return c.json(data)\n } catch (e) {\n console.error(e)\n return c.json({error: 'internal error'}, 500)\n }\n })\n}\n\nexport function registerSsrRoute(app: Hono, {renderModule, manifest, loaderTimeout}: ServerOptions) {\n app.get('*', async (c) => {\n try {\n const {html, statusCode, headers} = await renderModule.render(c.req.url, c.req.raw, {manifest, loaderTimeout})\n const res = c.html(`<!DOCTYPE html>${html}`, statusCode)\n for (const [key, value] of Object.entries(headers as Record<string, string>)) {\n res.headers.set(key, value)\n }\n return res\n } catch (e) {\n console.error(e)\n return c.text('Internal Server Error', 500)\n }\n })\n}", "import pc from 'picocolors'\nimport {networkInterfaces} from 'node:os'\nimport {createRequire} from 'node:module'\n\nfunction getNetworkUrl(port: number): string | null {\n const nets = networkInterfaces()\n for (const interfaces of Object.values(nets)) {\n for (const net of interfaces ?? []) {\n if (net.family === 'IPv4' && !net.internal) {\n return `http://${net.address}:${port}/`\n }\n }\n }\n return null\n}\n\nexport function printDevBanner(port: number) {\n const req = createRequire(import.meta.url)\n const version = req('../../package.json').version\n const networkUrl = getNetworkUrl(port)\n\n console.log()\n console.log(` ${pc.bold(pc.yellow('devix'))} ${pc.dim(`v${version}`)}`)\n console.log()\n console.log(` ${pc.green('\u279C')} ${pc.bold('Local:')} ${pc.cyan(`http://localhost:${port}/`)}`)\n if (networkUrl) {\n console.log(` ${pc.green('\u279C')} ${pc.bold('Network:')} ${pc.cyan(networkUrl)}`)\n } else {\n console.log(` ${pc.green('\u279C')} ${pc.bold('Network:')} ${pc.dim('use --host to expose')}`)\n }\n console.log()\n}", "import type {ViteDevServer} from 'vite'\n\nexport async function collectCss(vite: ViteDevServer): Promise<string[]> {\n const cssUrls = new Set<string>()\n\n for (const [, mod] of vite.moduleGraph.idToModuleMap) {\n if (!mod.id) continue\n if (mod.id.endsWith('.css') || mod.id.includes('.css?')) {\n cssUrls.add(mod.url)\n }\n }\n\n return [...cssUrls]\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"],
5
- "mappings": ";AAAA,SAAQ,oBAAmB;AAC3B,SAAQ,gBAAgB,wBAAuB;AAC/C,SAAQ,0BAAyB;AACjC,SAAQ,YAAW;;;ACHnB,SAA4B,mBAAkB;AAE9C,OAAO,WAAW;AAClB,SAAQ,qBAAoB;AAC5B,SAAQ,SAAS,eAAc;;;ACAxB,SAAS,oBAAoB,EAAC,QAAO,GAA+B;AACvE,QAAM,aAAa,QAAQ,IAAI,OAAK,WAAW,CAAC,GAAG,EAAE,KAAK,IAAI;AAE9D,SAAO;AAAA,EACT,UAAU;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;AAAA;AAAA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,MAAM,MAAM,MAAM;AACxB,iBAAe,IAAI;AACvB,CAAC;",
6
- "names": ["cache", "config", "app", "apiModule", "renderModule", "port", "vite", "VIRTUAL_RENDER", "VIRTUAL_API", "resolve"]
3
+ "sources": ["../../src/cli/dev.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/utils/patterns.ts", "../../src/server/pages-router.ts", "../../src/server/api-router.ts", "../../src/vite/codegen/context.ts", "../../src/vite/codegen/scan-api.ts", "../../src/vite/codegen/extract-methods.ts", "../../src/vite/codegen/routes-dts.ts", "../../src/vite/codegen/write-routes-dts.ts", "../../src/server/routes.ts", "../../src/utils/banner.ts", "../../src/server/collect-css.ts", "../../src/utils/duration.ts", "../../src/utils/env.ts"],
4
+ "sourcesContent": ["import {createServer} from 'node:http'\nimport {createServer as createViteServer} from 'vite'\nimport {getRequestListener} from '@hono/node-server'\nimport {Hono} from 'hono'\nimport type {DevixConfig} from '../config'\nimport {devix} from '../vite'\nimport {registerApiRoutes} from '../server/routes'\nimport {printDevBanner} from \"../utils/banner\";\nimport {collectCss} from \"../server/collect-css\";\nimport {parseDuration} from \"../utils/duration\";\nimport {loadDotenv} from \"../utils/env\";\n\nloadDotenv('development')\n\nconst VIRTUAL_RENDER = 'virtual:devix/render'\nconst VIRTUAL_API = 'virtual:devix/api'\n\nconst config: DevixConfig = (await import(`${process.cwd()}/devix.config.ts`)).default\nconst port = Number(process.env.PORT) || config.port || 3000\nconst host = typeof config.host === 'string' ? config.host : config.host ? '0.0.0.0' : 'localhost'\n\nconst vite = await createViteServer({\n ...devix(config),\n configFile: false,\n appType: 'custom',\n server: {middlewareMode: true},\n})\n\nconst renderModule = {\n render: async (...args: any[]) => (await vite.ssrLoadModule(VIRTUAL_RENDER)).render(...args),\n runLoader: async (...args: any[]) => (await vite.ssrLoadModule(VIRTUAL_RENDER)).runLoader(...args),\n}\n\nconst apiModule = {\n handleApiRequest: async (...args: any[]) => (await vite.ssrLoadModule(VIRTUAL_API)).handleApiRequest(...args),\n}\n\nconst app = new Hono()\n\nregisterApiRoutes(app, {renderModule, apiModule})\n\napp.get('*', async (c) => {\n try {\n const {html, statusCode, headers} = await renderModule.render(c.req.url, c.req.raw, {loaderTimeout: parseDuration(config.loaderTimeout ?? 10_000)})\n\n const cssUrls = await collectCss(vite)\n const cssLinks = cssUrls.map(url => `<link rel=\"stylesheet\" href=\"${url}\">`).join('\\n')\n\n const htmlWithCss = cssLinks ? html.replace('</head>', `${cssLinks}\\n</head>`) : html\n const transformed = await vite.transformIndexHtml(c.req.url, `<!DOCTYPE html>${htmlWithCss}`)\n\n const res = c.html(transformed, statusCode)\n for (const [key, value] of Object.entries(headers as Record<string, string>)) {\n res.headers.set(key, value)\n }\n return res\n } catch (e) {\n vite.ssrFixStacktrace(e as Error)\n console.error(e)\n return c.text('Internal Server Error', 500)\n }\n})\n\nconst honoHandler = getRequestListener(app.fetch)\n\ncreateServer(async (req, res) => {\n await new Promise<void>(resolve => vite.middlewares(req, res, resolve))\n if (!res.writableEnded) await honoHandler(req, res)\n}).listen(port, host, () => {\n printDevBanner(port)\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, resolve} from 'node:path'\nimport {generateEntryClient} from './codegen/entry-client'\nimport {generateClientRoutes} from './codegen/client-routes'\nimport {generateRender} from './codegen/render'\nimport {generateApi} from './codegen/api'\nimport {invalidatePagesCache} from \"../server/pages-router\";\nimport {invalidateApiCache} from \"../server/api-router\";\nimport {generateContext} from \"./codegen/context\";\nimport {scanApiFiles} from \"./codegen/scan-api\";\nimport {generateRoutesDts} from \"./codegen/routes-dts\";\nimport {writeRoutesDts} from \"./codegen/write-routes-dts\";\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'\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\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 },\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 },\n\n buildStart() {\n const root = process.cwd()\n const entries = scanApiFiles(appDir, root)\n writeRoutesDts(generateRoutesDts(entries, `${appDir}/api`), root)\n },\n\n configureServer(server) {\n const root = process.cwd()\n\n const regenerateDts = () => {\n const entries = scanApiFiles(appDir, root)\n writeRoutesDts(generateRoutesDts(entries, `${appDir}/api`), root)\n }\n\n server.watcher.on('add', (file) => {\n if (file.startsWith(resolve(root, pagesDir))) invalidatePagesCache()\n if (file.includes(`${appDir}/api`)) { invalidateApiCache(); regenerateDts() }\n })\n server.watcher.on('unlink', (file) => {\n if (file.startsWith(resolve(root, pagesDir))) invalidatePagesCache()\n if (file.includes(`${appDir}/api`)) { invalidateApiCache(); regenerateDts() }\n })\n server.watcher.on('change', (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 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\n const matched = matchClientRoute(window.location.pathname)\n\n 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 initialMeta: metadata,\n initialViewport: viewport,\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 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 Page {\n path: string\n key: string\n params: string[]\n regex: RegExp\n}\n\nexport interface Layout {\n dir: string\n key: string\n}\n\nexport interface PagesResult {\n pages: Page[]\n layouts: Layout[]\n}\n\nfunction keyToRoutePattern(key: string, pagesDir: string): string {\n const rel = key.slice(pagesDir.length + 1).replace(/\\\\/g, '/')\n const pattern = routePattern(rel)\n return pattern === \"/\" ? \"/\" : `/${pattern}`\n}\n\nfunction keyToDir(key: string): string {\n return key.slice(0, key.lastIndexOf('/'))\n}\n\nlet cache: PagesResult | null = null\n\nexport function invalidatePagesCache() {\n cache = null\n}\n\nexport function buildPages(pageKeys: string[], layoutKeys: string[], pagesDir: string): PagesResult {\n if (cache) return cache\n\n const pages: Page[] = []\n const layouts: Layout[] = []\n\n for (const key of layoutKeys) {\n layouts.push({dir: keyToDir(key), key})\n }\n\n for (const key of pageKeys) {\n const pattern = keyToRoutePattern(key, pagesDir)\n const params = [...pattern.matchAll(/:([^/]+)/g)].map(m => m[1])\n const regexStr = pattern\n .replace(/:[^/]+/g, '([^/]+)')\n .replace(/\\//g, '\\\\/')\n pages.push({path: pattern, key, params, regex: new RegExp(`^${regexStr}$`)})\n }\n\n pages.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 cache = {pages, layouts}\n return cache\n}\n\nexport function collectLayoutChain(pageKey: string, layouts: Layout[]): Layout[] {\n const pageDir = keyToDir(pageKey)\n\n return layouts\n .filter(layout => pageDir.startsWith(layout.dir))\n .sort((a, b) => a.dir.split('/').length - b.dir.split('/').length)\n}\n\nexport function matchPage(pathname: string, pages: Page[]): {\n page: Page\n params: Record<string, string>\n} | null {\n for (const page of pages) {\n const match = pathname.match(page.regex)\n if (match) {\n const params: Record<string, string> = {}\n page.params.forEach((name, i) => {\n params[name] = decodeURIComponent(match[i + 1])\n })\n return {page, params}\n }\n }\n return null\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\nlet cache: ApiResult | null = null\n\nexport function invalidateApiCache() {\n cache = null\n}\n\nexport function buildRoutes(routeKeys: string[], middlewareKeys: string[], apiDir: string): ApiResult {\n if (cache) return cache\n\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 cache = {routes, middlewares}\n return cache\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", "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", "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\\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> = Response & { readonly __body: T }\ntype InferRoute<T> = T extends (...args: any[]) => any\n ? Awaited<ReturnType<T>> extends JsonResponse<infer U>\n ? U\n : Exclude<Awaited<ReturnType<T>>, Response | null | void>\n : never\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", "import type {Hono} from 'hono'\nimport type {Manifest} from 'vite'\n\ninterface ServerOptions {\n renderModule: any\n apiModule: any\n manifest?: Manifest\n loaderTimeout?: number\n}\n\nexport function registerApiRoutes(app: Hono, {apiModule, renderModule, loaderTimeout}: ServerOptions) {\n app.all('/api/*', async (c) => {\n try {\n return await apiModule.handleApiRequest(c.req.url, c.req.raw)\n } catch (e) {\n console.error(e)\n return c.json({error: 'internal error'}, 500)\n }\n })\n\n app.get('/_data/*', async (c) => {\n try {\n const {pathname, search} = new URL(c.req.url, 'http://localhost')\n const url = pathname.replace(/^\\/_data/, '') + search\n\n const data = await renderModule.runLoader(url, c.req.raw, {loaderTimeout})\n return c.json(data)\n } catch (e) {\n console.error(e)\n return c.json({error: 'internal error'}, 500)\n }\n })\n}\n\nexport function registerSsrRoute(app: Hono, {renderModule, manifest, loaderTimeout}: ServerOptions) {\n app.get('*', async (c) => {\n try {\n const {html, statusCode, headers} = await renderModule.render(c.req.url, c.req.raw, {manifest, loaderTimeout})\n const res = c.html(`<!DOCTYPE html>${html}`, statusCode)\n for (const [key, value] of Object.entries(headers as Record<string, string>)) {\n res.headers.set(key, value)\n }\n return res\n } catch (e) {\n console.error(e)\n return c.text('Internal Server Error', 500)\n }\n })\n}", "import pc from 'picocolors'\nimport {networkInterfaces} from 'node:os'\nimport {createRequire} from 'node:module'\n\nfunction getNetworkUrl(port: number): string | null {\n const nets = networkInterfaces()\n for (const interfaces of Object.values(nets)) {\n for (const net of interfaces ?? []) {\n if (net.family === 'IPv4' && !net.internal) {\n return `http://${net.address}:${port}/`\n }\n }\n }\n return null\n}\n\nexport function printDevBanner(port: number) {\n const req = createRequire(import.meta.url)\n const version = req('../../package.json').version\n const networkUrl = getNetworkUrl(port)\n\n console.log()\n console.log(` ${pc.bold(pc.yellow('devix'))} ${pc.dim(`v${version}`)}`)\n console.log()\n console.log(` ${pc.green('\u279C')} ${pc.bold('Local:')} ${pc.cyan(`http://localhost:${port}/`)}`)\n if (networkUrl) {\n console.log(` ${pc.green('\u279C')} ${pc.bold('Network:')} ${pc.cyan(networkUrl)}`)\n } else {\n console.log(` ${pc.green('\u279C')} ${pc.bold('Network:')} ${pc.dim('use --host to expose')}`)\n }\n console.log()\n}", "import type {ViteDevServer} from 'vite'\n\nexport async function collectCss(vite: ViteDevServer): Promise<string[]> {\n const cssUrls = new Set<string>()\n\n for (const [, mod] of vite.moduleGraph.idToModuleMap) {\n if (!mod.id) continue\n if (mod.id.endsWith('.css') || mod.id.includes('.css?')) {\n cssUrls.add(mod.url)\n }\n }\n\n return [...cssUrls]\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 {loadEnv} from 'vite'\n\nexport function loadDotenv(mode: string) {\n const env = loadEnv(mode, process.cwd(), '')\n for (const [key, value] of Object.entries(env)) {\n if (process.env[key] === undefined) {\n process.env[key] = value\n }\n }\n}\n"],
5
+ "mappings": "AAAA,OAAQ,gBAAAA,OAAmB,YAC3B,OAAQ,gBAAgBC,OAAuB,OAC/C,OAAQ,sBAAAC,OAAyB,oBACjC,OAAQ,QAAAC,OAAW,OCHnB,OAA4B,eAAAC,OAAkB,OAE9C,OAAOC,OAAW,uBAClB,OAAQ,iBAAAC,OAAoB,WAC5B,OAAQ,WAAAC,GAAS,WAAAC,MAAc,YCAxB,SAASC,EAAoB,CAAC,QAAAC,CAAO,EAA+B,CAGvE,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;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,CAuDZ,CC1DO,SAASC,EAAqB,CAAC,SAAAC,EAAU,YAAAC,CAAW,EAAwB,CAC/E,MAAO;AAAA;A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AAI,EAAE,KAAK;AAAA,CAAI,EAEhFC,EAAcH,EAAWJ,EAAK,QAAQ,UAAW,GAAGI,CAAQ;AAAA,QAAW,EAAIJ,EAC3EQ,EAAc,MAAMlB,EAAK,mBAAmBS,EAAE,IAAI,IAAK,kBAAkBQ,CAAW,EAAE,EAEtFE,EAAMV,EAAE,KAAKS,EAAaP,CAAU,EAC1C,OAAW,CAACS,EAAKC,CAAK,IAAK,OAAO,QAAQT,CAAiC,EACvEO,EAAI,QAAQ,IAAIC,EAAKC,CAAK,EAE9B,OAAOF,CACX,OAAS,EAAG,CACR,OAAAnB,EAAK,iBAAiB,CAAU,EAChC,QAAQ,MAAM,CAAC,EACRS,EAAE,KAAK,wBAAyB,GAAG,CAC9C,CACJ,CAAC,EAED,IAAMa,GAAcC,GAAmBjB,EAAI,KAAK,EAEhDkB,GAAa,MAAOC,EAAKN,IAAQ,CAC7B,MAAM,IAAI,QAAcO,GAAW1B,EAAK,YAAYyB,EAAKN,EAAKO,CAAO,CAAC,EACjEP,EAAI,eAAe,MAAMG,GAAYG,EAAKN,CAAG,CACtD,CAAC,EAAE,OAAOrB,EAAMC,GAAM,IAAM,CACxB4B,EAAe7B,CAAI,CACvB,CAAC",
6
+ "names": ["createServer", "createViteServer", "getRequestListener", "Hono", "mergeConfig", "react", "fileURLToPath", "dirname", "resolve", "generateEntryClient", "cssUrls", "u", "generateClientRoutes", "pagesDir", "matcherPath", "generateRender", "pagesDir", "renderPath", "generateApi", "apiPath", "appDir", "routePattern", "rel", "cache", "invalidatePagesCache", "keyToRoutePattern", "key", "apiDir", "rel", "pattern", "routePattern", "cache", "invalidateApiCache", "generateContext", "readFileSync", "readdirSync", "statSync", "join", "relative", "METHOD_EXPORT_RE", "stripComments", "content", "extractHttpMethods", "found", "match", "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", "__dirname", "dirname", "fileURLToPath", "VIRTUAL_ENTRY_CLIENT", "VIRTUAL_CLIENT_ROUTES", "VIRTUAL_RENDER", "VIRTUAL_API", "VIRTUAL_CONTEXT", "devix", "config", "appDir", "pagesDir", "cssUrls", "u", "renderPath", "resolve", "apiPath", "matcherPath", "virtualPlugin", "id", "generateEntryClient", "generateClientRoutes", "generateRender", "generateApi", "generateContext", "root", "entries", "scanApiFiles", "writeRoutesDts", "generateRoutesDts", "server", "regenerateDts", "file", "invalidatePagesCache", "invalidateApiCache", "base", "react", "mergeConfig", "registerApiRoutes", "app", "apiModule", "renderModule", "loaderTimeout", "c", "e", "pathname", "search", "url", "data", "pc", "networkInterfaces", "createRequire", "getNetworkUrl", "port", "nets", "interfaces", "net", "printDevBanner", "version", "networkUrl", "collectCss", "vite", "cssUrls", "mod", "parseDuration", "value", "match", "n", "loadEnv", "loadDotenv", "mode", "env", "key", "value", "loadDotenv", "VIRTUAL_RENDER", "VIRTUAL_API", "config", "port", "host", "vite", "createViteServer", "devix", "renderModule", "args", "apiModule", "app", "Hono", "registerApiRoutes", "c", "html", "statusCode", "headers", "parseDuration", "cssLinks", "collectCss", "url", "htmlWithCss", "transformed", "res", "key", "value", "honoHandler", "getRequestListener", "createServer", "req", "resolve", "printDevBanner"]
7
7
  }