@teamvelix/velix 5.2.5 → 5.2.7

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.
@@ -1,7 +1,7 @@
1
1
  // build/index.ts
2
2
  import esbuild from "esbuild";
3
- import fs4 from "fs";
4
- import path4 from "path";
3
+ import fs5 from "fs";
4
+ import path5 from "path";
5
5
 
6
6
  // config.ts
7
7
  import fs from "fs";
@@ -348,7 +348,7 @@ function buildTree(routes) {
348
348
  }
349
349
 
350
350
  // version.ts
351
- var VERSION = "5.2.3";
351
+ var VERSION = "5.2.7";
352
352
 
353
353
  // logger.ts
354
354
  var colors = {
@@ -398,14 +398,14 @@ var logger = {
398
398
  if (pagesDir) console.log(` ${c.bold}App:${c.reset} ${c.dim}${pagesDir}${c.reset}`);
399
399
  console.log("");
400
400
  },
401
- request(method, path5, status, time, extra = {}) {
401
+ request(method, path6, status, time, extra = {}) {
402
402
  const statusColor = getStatusColor(status);
403
403
  const timeStr = fmtTime(time);
404
404
  let badge = `${c.dim}\u25CB${c.reset}`;
405
405
  if (extra.type === "dynamic" || extra.type === "ssr") badge = `${c.white}\u0192${c.reset}`;
406
406
  else if (extra.type === "api") badge = `${c.cyan}\u03BB${c.reset}`;
407
407
  const statusStr = `${statusColor}${status}${c.reset}`;
408
- console.log(` ${badge} ${c.white}${method}${c.reset} ${path5} ${statusStr} ${c.dim}${timeStr}${c.reset}`);
408
+ console.log(` ${badge} ${c.white}${method}${c.reset} ${path6} ${statusStr} ${c.dim}${timeStr}${c.reset}`);
409
409
  },
410
410
  info(msg) {
411
411
  console.log(` ${c.cyan}\u2139${c.reset} ${msg}`);
@@ -433,10 +433,10 @@ var logger = {
433
433
  plugin(name) {
434
434
  console.log(` ${c.cyan}\u25C6${c.reset} Plugin ${c.dim}${name}${c.reset}`);
435
435
  },
436
- route(path5, type) {
436
+ route(path6, type) {
437
437
  const typeLabel = type === "api" ? "\u03BB" : type === "dynamic" ? "\u0192" : "\u25CB";
438
438
  const color = type === "api" ? c.cyan : type === "dynamic" ? c.white : c.dim;
439
- console.log(` ${color}${typeLabel}${c.reset} ${path5}`);
439
+ console.log(` ${color}${typeLabel}${c.reset} ${path6}`);
440
440
  },
441
441
  divider() {
442
442
  console.log(`${c.dim} \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500${c.reset}`);
@@ -462,16 +462,158 @@ var logger = {
462
462
  };
463
463
  var logger_default = logger;
464
464
 
465
+ // plugins/index.ts
466
+ import fs4 from "fs";
467
+ import path4 from "path";
468
+ import { pathToFileURL as pathToFileURL2 } from "url";
469
+ var PluginHooks = {
470
+ CONFIG: "config",
471
+ SERVER_START: "server:start",
472
+ REQUEST: "request",
473
+ RESPONSE: "response",
474
+ ROUTES_LOADED: "routes:loaded",
475
+ BEFORE_RENDER: "render:before",
476
+ AFTER_RENDER: "render:after",
477
+ BUILD_START: "build:start",
478
+ BUILD_END: "build:end"
479
+ };
480
+ var PluginManager = class {
481
+ plugins = [];
482
+ hooks = /* @__PURE__ */ new Map();
483
+ /**
484
+ * Register a plugin
485
+ */
486
+ register(plugin) {
487
+ this.plugins.push(plugin);
488
+ if (plugin.hooks) {
489
+ for (const [hookName, handler] of Object.entries(plugin.hooks)) {
490
+ if (handler) {
491
+ const existing = this.hooks.get(hookName) || [];
492
+ existing.push(handler);
493
+ this.hooks.set(hookName, existing);
494
+ }
495
+ }
496
+ }
497
+ }
498
+ /**
499
+ * Run a hook with arguments
500
+ */
501
+ async runHook(hookName, ...args) {
502
+ const handlers = this.hooks.get(hookName) || [];
503
+ for (const handler of handlers) {
504
+ await handler(...args);
505
+ }
506
+ }
507
+ /**
508
+ * Run a waterfall hook — each handler transforms the first argument
509
+ */
510
+ async runWaterfallHook(hookName, value, ...args) {
511
+ const handlers = this.hooks.get(hookName) || [];
512
+ let result = value;
513
+ for (const handler of handlers) {
514
+ const transformed = await handler(result, ...args);
515
+ if (transformed !== void 0) result = transformed;
516
+ }
517
+ return result;
518
+ }
519
+ /**
520
+ * Get all registered plugins
521
+ */
522
+ getPlugins() {
523
+ return [...this.plugins];
524
+ }
525
+ /**
526
+ * Check if a plugin is registered
527
+ */
528
+ hasPlugin(name) {
529
+ return this.plugins.some((p) => p.name === name);
530
+ }
531
+ };
532
+ var pluginManager = new PluginManager();
533
+ async function loadPlugins(projectRoot, config) {
534
+ const pluginEntries = config.plugins || [];
535
+ for (const entry of pluginEntries) {
536
+ try {
537
+ if (typeof entry === "string") {
538
+ const localPath = path4.join(projectRoot, "plugins", entry + ".ts");
539
+ const localPathJs = path4.join(projectRoot, "plugins", entry + ".js");
540
+ const localPathDir = path4.join(projectRoot, "plugins", entry, "index.ts");
541
+ let pluginPath = null;
542
+ if (fs4.existsSync(localPath)) pluginPath = localPath;
543
+ else if (fs4.existsSync(localPathJs)) pluginPath = localPathJs;
544
+ else if (fs4.existsSync(localPathDir)) pluginPath = localPathDir;
545
+ if (pluginPath) {
546
+ const url = pathToFileURL2(pluginPath).href;
547
+ const mod = await import(`${url}?t=${Date.now()}`);
548
+ const plugin = mod.default || mod;
549
+ if (plugin.name) {
550
+ pluginManager.register(plugin);
551
+ }
552
+ } else {
553
+ try {
554
+ const mod = await import(entry);
555
+ const plugin = mod.default || mod;
556
+ if (plugin.name) pluginManager.register(plugin);
557
+ } catch {
558
+ console.warn(`\u26A0 Plugin not found: ${entry}`);
559
+ }
560
+ }
561
+ } else if (typeof entry === "object" && entry !== null && "name" in entry) {
562
+ pluginManager.register(entry);
563
+ }
564
+ } catch (err) {
565
+ const error = err;
566
+ console.warn(`\u26A0 Failed to load plugin: ${error?.message || String(error)}`);
567
+ }
568
+ }
569
+ }
570
+ function definePlugin(definition) {
571
+ return definition;
572
+ }
573
+ var builtinPlugins = {
574
+ /**
575
+ * Security headers plugin
576
+ */
577
+ security: definePlugin({
578
+ name: "velix:security",
579
+ hooks: {
580
+ [PluginHooks.RESPONSE]: (_req, res) => {
581
+ const response = res;
582
+ if (!response.headersSent) {
583
+ response.setHeader("X-Content-Type-Options", "nosniff");
584
+ response.setHeader("X-Frame-Options", "DENY");
585
+ response.setHeader("X-XSS-Protection", "1; mode=block");
586
+ }
587
+ }
588
+ }
589
+ }),
590
+ /**
591
+ * Request logging plugin
592
+ */
593
+ logger: definePlugin({
594
+ name: "velix:logger",
595
+ hooks: {
596
+ [PluginHooks.RESPONSE]: (req, _res, duration) => {
597
+ const request = req;
598
+ console.log(` ${request.method} ${request.url} ${duration}ms`);
599
+ }
600
+ }
601
+ })
602
+ };
603
+
465
604
  // build/index.ts
466
605
  async function build(options = {}) {
467
606
  const projectRoot = options.projectRoot || process.cwd();
468
607
  const config = await loadConfig(projectRoot);
469
608
  const resolved = resolvePaths(config, projectRoot);
609
+ await loadPlugins(projectRoot, config);
610
+ await pluginManager.runHook(PluginHooks.CONFIG, config);
470
611
  const outDir = options.outDir || resolved.resolvedOutDir;
471
612
  const startTime = Date.now();
472
613
  logger_default.logo();
473
614
  logger_default.info("Building for production...");
474
615
  logger_default.blank();
616
+ await pluginManager.runHook(PluginHooks.BUILD_START);
475
617
  cleanDir(outDir);
476
618
  const appDir = resolved.resolvedAppDir;
477
619
  const routes = buildRouteTree(appDir);
@@ -481,7 +623,7 @@ async function build(options = {}) {
481
623
  return;
482
624
  }
483
625
  try {
484
- const serverOutDir = path4.join(outDir, "server");
626
+ const serverOutDir = path5.join(outDir, "server");
485
627
  ensureDir(serverOutDir);
486
628
  await esbuild.build({
487
629
  entryPoints: sourceFiles,
@@ -503,10 +645,10 @@ async function build(options = {}) {
503
645
  process.exit(1);
504
646
  }
505
647
  try {
506
- const clientOutDir = path4.join(outDir, "client");
648
+ const clientOutDir = path5.join(outDir, "client");
507
649
  ensureDir(clientOutDir);
508
650
  const clientFiles = sourceFiles.filter((f) => {
509
- const content = fs4.readFileSync(f, "utf-8");
651
+ const content = fs5.readFileSync(f, "utf-8");
510
652
  const firstLine = content.split("\n")[0]?.trim();
511
653
  return firstLine === "'use client'" || firstLine === '"use client"' || firstLine === "'use island'" || firstLine === '"use island"';
512
654
  });
@@ -536,8 +678,8 @@ async function build(options = {}) {
536
678
  process.exit(1);
537
679
  }
538
680
  const publicDir = resolved.resolvedPublicDir;
539
- if (fs4.existsSync(publicDir)) {
540
- const publicOutDir = path4.join(outDir, "public");
681
+ if (fs5.existsSync(publicDir)) {
682
+ const publicOutDir = path5.join(outDir, "public");
541
683
  ensureDir(publicOutDir);
542
684
  copyDirRecursive(publicDir, publicOutDir);
543
685
  logger_default.success("Static assets copied");
@@ -551,7 +693,7 @@ async function build(options = {}) {
551
693
  })),
552
694
  api: routes.api.map((r) => ({ path: r.path }))
553
695
  };
554
- fs4.writeFileSync(path4.join(outDir, "manifest.json"), JSON.stringify(manifest, null, 2));
696
+ fs5.writeFileSync(path5.join(outDir, "manifest.json"), JSON.stringify(manifest, null, 2));
555
697
  const elapsed = Date.now() - startTime;
556
698
  const totalSize = getDirSize(outDir);
557
699
  logger_default.blank();
@@ -566,25 +708,26 @@ async function build(options = {}) {
566
708
  logger_default.build({ time: elapsed });
567
709
  logger_default.info(`Output: ${outDir} (${formatBytes(totalSize)})`);
568
710
  logger_default.blank();
711
+ await pluginManager.runHook(PluginHooks.BUILD_END, { time: elapsed });
569
712
  }
570
713
  function copyDirRecursive(src, dest) {
571
714
  ensureDir(dest);
572
- const entries = fs4.readdirSync(src, { withFileTypes: true });
715
+ const entries = fs5.readdirSync(src, { withFileTypes: true });
573
716
  for (const entry of entries) {
574
- const srcPath = path4.join(src, entry.name);
575
- const destPath = path4.join(dest, entry.name);
717
+ const srcPath = path5.join(src, entry.name);
718
+ const destPath = path5.join(dest, entry.name);
576
719
  if (entry.isDirectory()) copyDirRecursive(srcPath, destPath);
577
- else fs4.copyFileSync(srcPath, destPath);
720
+ else fs5.copyFileSync(srcPath, destPath);
578
721
  }
579
722
  }
580
723
  function getDirSize(dir) {
581
724
  let size = 0;
582
- if (!fs4.existsSync(dir)) return size;
583
- const entries = fs4.readdirSync(dir, { withFileTypes: true });
725
+ if (!fs5.existsSync(dir)) return size;
726
+ const entries = fs5.readdirSync(dir, { withFileTypes: true });
584
727
  for (const entry of entries) {
585
- const fullPath = path4.join(dir, entry.name);
728
+ const fullPath = path5.join(dir, entry.name);
586
729
  if (entry.isDirectory()) size += getDirSize(fullPath);
587
- else size += fs4.statSync(fullPath).size;
730
+ else size += fs5.statSync(fullPath).size;
588
731
  }
589
732
  return size;
590
733
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../build/index.ts","../../config.ts","../../router/index.ts","../../utils.ts","../../version.ts","../../logger.ts","../../runtime/start-build.ts"],"sourcesContent":["/**\n * Velix v5 Build System\n * Production build using esbuild\n */\n\nimport esbuild from 'esbuild';\nimport fs from 'fs';\nimport path from 'path';\nimport { loadConfig, resolvePaths } from '../config.js';\nimport { buildRouteTree } from '../router/index.js';\nimport { ensureDir, cleanDir, findFiles, formatBytes, formatTime } from '../utils.js';\nimport logger from '../logger.js';\nimport { VERSION } from '../version.js';\n\nexport interface BuildOptions {\n projectRoot?: string;\n outDir?: string;\n minify?: boolean;\n sourcemap?: boolean;\n}\n\n/**\n * Build the Velix application for production\n */\nexport async function build(options: BuildOptions = {}) {\n const projectRoot = options.projectRoot || process.cwd();\n const config = await loadConfig(projectRoot);\n const resolved = resolvePaths(config, projectRoot);\n\n const outDir = options.outDir || resolved.resolvedOutDir;\n const startTime = Date.now();\n\n logger.logo();\n logger.info('Building for production...');\n logger.blank();\n\n // Clean output directory\n cleanDir(outDir);\n\n const appDir = resolved.resolvedAppDir;\n const routes = buildRouteTree(appDir);\n\n // Collect all source files\n const sourceFiles = findFiles(appDir, /\\.(tsx?|jsx?)$/);\n\n if (sourceFiles.length === 0) {\n logger.warn('No source files found in app/ directory');\n return;\n }\n\n // Build server bundle\n try {\n const serverOutDir = path.join(outDir, 'server');\n ensureDir(serverOutDir);\n\n await esbuild.build({\n entryPoints: sourceFiles,\n outdir: serverOutDir,\n bundle: false,\n format: 'esm',\n platform: 'node',\n target: config.build.target,\n minify: options.minify ?? config.build.minify,\n sourcemap: options.sourcemap ?? config.build.sourcemap,\n jsx: 'automatic',\n logLevel: 'silent',\n treeShaking: true,\n legalComments: 'none',\n });\n\n logger.success('Server bundle built');\n } catch (err: any) {\n logger.error('Server build failed', err);\n process.exit(1);\n }\n\n // Build client bundle (client components and islands)\n try {\n const clientOutDir = path.join(outDir, 'client');\n ensureDir(clientOutDir);\n\n const clientFiles = sourceFiles.filter(f => {\n const content = fs.readFileSync(f, 'utf-8');\n const firstLine = content.split('\\n')[0]?.trim();\n return firstLine === \"'use client'\" || firstLine === '\"use client\"' ||\n firstLine === \"'use island'\" || firstLine === '\"use island\"';\n });\n\n if (clientFiles.length > 0) {\n await esbuild.build({\n entryPoints: clientFiles,\n outdir: clientOutDir,\n bundle: true,\n format: 'esm',\n platform: 'browser',\n target: ['es2022'],\n minify: options.minify ?? config.build.minify,\n sourcemap: options.sourcemap ?? config.build.sourcemap,\n splitting: config.build.splitting,\n jsx: 'automatic',\n logLevel: 'silent',\n external: ['react', 'react-dom'],\n treeShaking: true,\n legalComments: 'none',\n drop: options.minify ?? config.build.minify ? ['console', 'debugger'] : [],\n chunkNames: 'chunks/[name]-[hash]',\n });\n\n logger.success(`Client bundle built (${clientFiles.length} components)`);\n }\n } catch (err: any) {\n logger.error('Client build failed', err);\n process.exit(1);\n }\n\n // Copy public directory\n const publicDir = resolved.resolvedPublicDir;\n if (fs.existsSync(publicDir)) {\n const publicOutDir = path.join(outDir, 'public');\n ensureDir(publicOutDir);\n copyDirRecursive(publicDir, publicOutDir);\n logger.success('Static assets copied');\n }\n\n // Generate build manifest\n const manifest = {\n version: VERSION,\n buildTime: new Date().toISOString(),\n routes: routes.appRoutes.map(r => ({\n path: r.path,\n type: r.path.includes(':') ? 'dynamic' : 'static',\n })),\n api: routes.api.map(r => ({ path: r.path })),\n };\n\n fs.writeFileSync(path.join(outDir, 'manifest.json'), JSON.stringify(manifest, null, 2));\n\n const elapsed = Date.now() - startTime;\n const totalSize = getDirSize(outDir);\n\n logger.blank();\n logger.divider();\n logger.blank();\n\n // Log routes\n routes.appRoutes.forEach(r => {\n const type = r.path.includes(':') || r.path.includes('*') ? 'dynamic' : 'static';\n logger.route(r.path, type);\n });\n routes.api.forEach(r => logger.route(r.path, 'api'));\n\n logger.blank();\n logger.build({ time: elapsed });\n logger.info(`Output: ${outDir} (${formatBytes(totalSize)})`);\n logger.blank();\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\nfunction copyDirRecursive(src: string, dest: string) {\n ensureDir(dest);\n const entries = fs.readdirSync(src, { withFileTypes: true });\n for (const entry of entries) {\n const srcPath = path.join(src, entry.name);\n const destPath = path.join(dest, entry.name);\n if (entry.isDirectory()) copyDirRecursive(srcPath, destPath);\n else fs.copyFileSync(srcPath, destPath);\n }\n}\n\nfunction getDirSize(dir: string): number {\n let size = 0;\n if (!fs.existsSync(dir)) return size;\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n if (entry.isDirectory()) size += getDirSize(fullPath);\n else size += fs.statSync(fullPath).size;\n }\n return size;\n}\n\nexport default { build };\n","/**\n * Velix v5 Configuration System\n * Handles loading, validation, and merging of velix.config.ts\n */\n\nimport fs from 'fs';\nimport path from 'path';\nimport { pathToFileURL } from 'url';\nimport { z } from 'zod';\nimport pc from 'picocolors';\n\n// ============================================================================\n// Configuration Schema (Zod validation)\n// ============================================================================\n\nconst AppConfigSchema = z.object({\n name: z.string().default('Velix App'),\n url: z.string().url().optional(),\n}).default({});\n\nconst ServerConfigSchema = z.object({\n port: z.number().min(1).max(65535).default(3000),\n host: z.string().default('localhost'),\n}).default({});\n\nconst RoutingConfigSchema = z.object({\n trailingSlash: z.boolean().default(false),\n}).default({});\n\nconst SEOConfigSchema = z.object({\n sitemap: z.boolean().default(true),\n robots: z.boolean().default(true),\n openGraph: z.boolean().default(true),\n}).default({});\n\nconst BuildConfigSchema = z.object({\n target: z.string().default('es2022'),\n minify: z.boolean().default(true),\n sourcemap: z.boolean().default(true),\n splitting: z.boolean().default(true),\n outDir: z.string().default('.velix'),\n}).default({});\n\nconst ExperimentalConfigSchema = z.object({\n islands: z.boolean().default(true),\n streaming: z.boolean().default(true),\n}).default({});\n\nconst PluginSchema = z.union([\n z.string(),\n z.object({\n name: z.string()\n }).passthrough(),\n]);\n\nexport const VelixConfigSchema = z.object({\n // App identity\n app: AppConfigSchema,\n\n // DevTools toggle\n devtools: z.boolean().default(true),\n\n // Server options\n server: ServerConfigSchema,\n\n // Routing options\n routing: RoutingConfigSchema,\n\n // SEO configuration\n seo: SEOConfigSchema,\n\n // Build options\n build: BuildConfigSchema,\n\n // Experimental features\n experimental: ExperimentalConfigSchema,\n\n // Plugins\n plugins: z.array(PluginSchema).default([]),\n\n // Directories (resolved automatically)\n appDir: z.string().default('app'),\n publicDir: z.string().default('public'),\n\n // Stylesheets\n styles: z.array(z.string()).default([]),\n\n // Favicon\n favicon: z.string().nullable().default(null),\n});\n\nexport type VelixConfig = z.infer<typeof VelixConfigSchema>;\n\n// ============================================================================\n// Default configuration\n// ============================================================================\n\nexport const defaultConfig: VelixConfig = VelixConfigSchema.parse({});\n\n// ============================================================================\n// defineConfig helper\n// ============================================================================\n\n/**\n * Helper function to define configuration with full type support.\n * Use this in your velix.config.ts file.\n *\n * @example\n * ```ts\n * import { defineConfig } from \"velix\";\n *\n * export default defineConfig({\n * app: { name: \"My App\" },\n * server: { port: 3000 },\n * seo: { sitemap: true }\n * });\n * ```\n */\nexport function defineConfig(config: Partial<VelixConfig>): Partial<VelixConfig> {\n return config;\n}\n\n// ============================================================================\n// Config Loader\n// ============================================================================\n\n/**\n * Loads and validates configuration from velix.config.ts\n */\nexport async function loadConfig(projectRoot: string): Promise<VelixConfig> {\n const configPathTs = path.join(projectRoot, 'velix.config.ts');\n const configPathJs = path.join(projectRoot, 'velix.config.js');\n // Support legacy config for migration\n const configPathLegacyTs = path.join(projectRoot, 'flexireact.config.ts');\n const configPathLegacyJs = path.join(projectRoot, 'flexireact.config.js');\n\n let configPath: string | null = null;\n if (fs.existsSync(configPathTs)) configPath = configPathTs;\n else if (fs.existsSync(configPathJs)) configPath = configPathJs;\n else if (fs.existsSync(configPathLegacyTs)) configPath = configPathLegacyTs;\n else if (fs.existsSync(configPathLegacyJs)) configPath = configPathLegacyJs;\n\n let userConfig: Partial<VelixConfig> = {};\n\n if (configPath) {\n try {\n const configUrl = pathToFileURL(configPath).href;\n const module = await import(`${configUrl}?t=${Date.now()}`);\n userConfig = module.default || module;\n } catch (error: any) {\n console.warn(pc.yellow(`⚠ Failed to load config: ${error.message}`));\n }\n }\n\n // Merge and validate with Zod\n const merged = deepMerge(defaultConfig, userConfig as Record<string, any>);\n\n try {\n return VelixConfigSchema.parse(merged);\n } catch (err: unknown) {\n if (err instanceof z.ZodError) {\n console.error(pc.red('✖ Configuration validation failed:'));\n for (const issue of err.issues) {\n console.error(pc.dim(` - ${issue.path.join('.')}: ${issue.message}`));\n }\n process.exit(1);\n }\n throw err;\n }\n}\n\n// ============================================================================\n// Path Resolution\n// ============================================================================\n\n/**\n * Resolves all paths in config relative to project root\n */\nexport function resolvePaths(config: VelixConfig, projectRoot: string): VelixConfig & { resolvedAppDir: string; resolvedPublicDir: string; resolvedOutDir: string } {\n return {\n ...config,\n resolvedAppDir: path.resolve(projectRoot, config.appDir),\n resolvedPublicDir: path.resolve(projectRoot, config.publicDir),\n resolvedOutDir: path.resolve(projectRoot, config.build.outDir),\n };\n}\n\n// ============================================================================\n// Utility: Deep merge\n// ============================================================================\n\nfunction deepMerge(target: Record<string, any>, source: Record<string, any>): Record<string, any> {\n const result = { ...target };\n\n for (const key in source) {\n if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {\n result[key] = deepMerge(target[key] || {}, source[key]);\n } else {\n result[key] = source[key];\n }\n }\n\n return result;\n}\n","/**\n * Velix v5 Router\n * File-based routing using the app/ directory convention\n *\n * Supports:\n * - app/page.tsx → /\n * - app/dashboard/page.tsx → /dashboard\n * - app/blog/[slug]/page.tsx → /blog/:slug\n * - app/(group)/page.tsx → / (route groups)\n * - app/[...slug]/page.tsx → catch-all routes\n * - layout.tsx, loading.tsx, error.tsx, not-found.tsx\n */\n\nimport fs from 'fs';\nimport path from 'path';\nimport { isServerComponent, isClientComponent, isIsland } from '../utils.js';\nimport type { Route, RouteTree as TypedRouteTree, RouteTreeNode } from '../types.js';\n\n// ============================================================================\n// Route Types\n// ============================================================================\n\nexport const RouteType = {\n PAGE: 'page',\n API: 'api',\n LAYOUT: 'layout',\n LOADING: 'loading',\n ERROR: 'error',\n NOT_FOUND: 'not-found'\n} as const;\n\n// ============================================================================\n// Build Route Tree\n// ============================================================================\n\n/**\n * Builds the complete route tree from the app/ directory\n */\nexport function buildRouteTree(appDir: string) {\n const projectRoot = path.dirname(appDir);\n\n const routes: {\n pages: Route[];\n api: Route[];\n layouts: Map<string, string>;\n tree: RouteTreeNode;\n appRoutes: Route[];\n rootLayout?: string;\n } = {\n pages: [],\n api: [],\n layouts: new Map(),\n tree: { children: {}, routes: [] },\n appRoutes: [],\n };\n\n // Scan app/ directory\n if (fs.existsSync(appDir)) {\n scanAppDirectory(appDir, appDir, routes);\n }\n\n // Scan server/api/ for API routes\n const serverApiDir = path.join(projectRoot, 'server', 'api');\n if (fs.existsSync(serverApiDir)) {\n scanApiDirectory(serverApiDir, serverApiDir, routes);\n }\n\n // Check for root layout\n const rootLayoutTsx = path.join(appDir, 'layout.tsx');\n const rootLayoutJsx = path.join(appDir, 'layout.jsx');\n if (fs.existsSync(rootLayoutTsx)) routes.rootLayout = rootLayoutTsx;\n else if (fs.existsSync(rootLayoutJsx)) routes.rootLayout = rootLayoutJsx;\n\n // Build route tree for nested routes\n routes.tree = buildTree(routes.appRoutes);\n\n return routes;\n}\n\n// ============================================================================\n// App Directory Scanner\n// ============================================================================\n\n/**\n * Scans app/ directory for file-based routing\n * Supports: page.tsx, layout.tsx, loading.tsx, error.tsx, not-found.tsx, [param].tsx\n */\nfunction scanAppDirectory(\n baseDir: string,\n currentDir: string,\n routes: { appRoutes: Route[] },\n parentSegments: string[] = [],\n parentLayout: string | null = null,\n parentMiddleware: string | null = null\n) {\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\n\n // Find special files in current directory\n const specialFiles: Record<string, string | null> = {\n page: null,\n layout: null,\n loading: null,\n error: null,\n notFound: null,\n template: null,\n middleware: null\n };\n\n for (const entry of entries) {\n if (entry.isFile()) {\n const name = entry.name.replace(/\\.(jsx|js|tsx|ts)$/, '');\n const fullPath = path.join(currentDir, entry.name);\n const ext = path.extname(entry.name);\n\n // Only process relevant extensions\n if (!['.tsx', '.jsx', '.ts', '.js'].includes(ext)) continue;\n\n if (name === 'page') specialFiles.page = fullPath;\n if (name === 'layout') specialFiles.layout = fullPath;\n if (name === 'loading') specialFiles.loading = fullPath;\n if (name === 'error') specialFiles.error = fullPath;\n if (name === 'not-found') specialFiles.notFound = fullPath;\n if (name === 'template') specialFiles.template = fullPath;\n if (name === 'middleware' || name === '_middleware') specialFiles.middleware = fullPath;\n\n // Handle [param].tsx files directly in app/ (alternative to [param]/page.tsx)\n if (name.startsWith('[') && name.endsWith(']') && ['.tsx', '.jsx'].includes(ext)) {\n const paramName = name.slice(1, -1);\n let segmentName: string;\n\n if (paramName.startsWith('...')) {\n segmentName = '*' + paramName.slice(3);\n } else {\n segmentName = ':' + paramName;\n }\n\n const routePath = '/' + [...parentSegments, segmentName].join('/');\n\n routes.appRoutes.push({\n type: RouteType.PAGE,\n path: routePath.replace(/\\/+/g, '/'),\n filePath: fullPath,\n pattern: createRoutePattern(routePath),\n segments: [...parentSegments, segmentName],\n layout: specialFiles.layout || parentLayout,\n loading: specialFiles.loading,\n error: specialFiles.error,\n notFound: specialFiles.notFound,\n template: specialFiles.template,\n middleware: specialFiles.middleware || parentMiddleware,\n isServerComponent: isServerComponent(fullPath),\n isClientComponent: isClientComponent(fullPath),\n isIsland: isIsland(fullPath),\n });\n }\n }\n }\n\n // If there's a page.tsx, create a route for this directory\n if (specialFiles.page) {\n const routePath = '/' + parentSegments.join('/') || '/';\n\n routes.appRoutes.push({\n type: RouteType.PAGE,\n path: routePath.replace(/\\/+/g, '/') || '/',\n filePath: specialFiles.page,\n pattern: createRoutePattern(routePath || '/'),\n segments: parentSegments,\n layout: specialFiles.layout || parentLayout,\n loading: specialFiles.loading,\n error: specialFiles.error,\n notFound: specialFiles.notFound,\n template: specialFiles.template,\n middleware: specialFiles.middleware || parentMiddleware,\n isServerComponent: isServerComponent(specialFiles.page),\n isClientComponent: isClientComponent(specialFiles.page),\n isIsland: isIsland(specialFiles.page),\n });\n }\n\n // Recursively scan subdirectories\n for (const entry of entries) {\n if (entry.isDirectory()) {\n const fullPath = path.join(currentDir, entry.name);\n\n // Skip special directories\n if (entry.name.startsWith('_') || entry.name.startsWith('.')) continue;\n\n // Handle route groups (parentheses) — don't add to URL\n const isGroup = entry.name.startsWith('(') && entry.name.endsWith(')');\n\n // Handle dynamic segments [param]\n let segmentName = entry.name;\n if (entry.name.startsWith('[') && entry.name.endsWith(']')) {\n segmentName = ':' + entry.name.slice(1, -1);\n if (entry.name.startsWith('[...')) {\n segmentName = '*' + entry.name.slice(4, -1);\n }\n if (entry.name.startsWith('[[...')) {\n segmentName = '*' + entry.name.slice(5, -2);\n }\n }\n\n const newSegments = isGroup ? parentSegments : [...parentSegments, segmentName];\n const newLayout = specialFiles.layout || parentLayout;\n const newMiddleware = specialFiles.middleware || parentMiddleware;\n\n scanAppDirectory(baseDir, fullPath, routes, newSegments, newLayout, newMiddleware);\n }\n }\n}\n\n// ============================================================================\n// API Directory Scanner (server/api/)\n// ============================================================================\n\nfunction scanApiDirectory(baseDir: string, currentDir: string, routes: { api: Route[] }, parentSegments: string[] = []) {\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(currentDir, entry.name);\n\n if (entry.isDirectory()) {\n scanApiDirectory(baseDir, fullPath, routes, [...parentSegments, entry.name]);\n } else if (entry.isFile()) {\n const ext = path.extname(entry.name);\n if (!['.ts', '.js'].includes(ext)) continue;\n\n const baseName = path.basename(entry.name, ext);\n // route.ts maps to the parent path, other names become segments\n const apiSegments = baseName === 'route' || baseName === 'index'\n ? parentSegments\n : [...parentSegments, baseName];\n\n const apiPath = '/api/' + apiSegments.join('/');\n\n routes.api.push({\n type: RouteType.API,\n path: apiPath.replace(/\\/+/g, '/') || '/api',\n filePath: fullPath,\n pattern: createRoutePattern(apiPath),\n segments: ['api', ...apiSegments].filter(Boolean),\n });\n }\n }\n}\n\n// ============================================================================\n// Route Matching\n// ============================================================================\n\n/**\n * Creates regex pattern for route matching\n */\nfunction createRoutePattern(routePath: string): RegExp {\n let pattern = routePath\n .replace(/\\*[^/]*/g, '(.*)') // Catch-all\n .replace(/:[^/]+/g, '([^/]+)') // Dynamic segments\n .replace(/\\//g, '\\\\/');\n\n return new RegExp(`^${pattern}$`);\n}\n\n/**\n * Matches URL path against routes\n */\nexport function matchRoute(urlPath: string, routes: Route[]) {\n const normalizedPath = urlPath === '' ? '/' : urlPath.split('?')[0];\n\n for (const route of routes) {\n const match = normalizedPath.match(route.pattern);\n if (match) {\n const params = extractParams(route.path, match);\n return { ...route, params };\n }\n }\n\n return null;\n}\n\n/**\n * Extracts parameters from route match\n */\nfunction extractParams(routePath: string, match: RegExpMatchArray): Record<string, string> {\n const params: Record<string, string> = {};\n const paramNames: string[] = [];\n\n const paramRegex = /:([^/]+)|\\*([^/]*)/g;\n let paramMatch;\n while ((paramMatch = paramRegex.exec(routePath)) !== null) {\n paramNames.push(paramMatch[1] || paramMatch[2] || 'splat');\n }\n\n paramNames.forEach((name, index) => {\n params[name] = match[index + 1];\n });\n\n return params;\n}\n\n// ============================================================================\n// Layout Resolution\n// ============================================================================\n\n/**\n * Finds all layouts that apply to a route\n */\nexport function findRouteLayouts(route: Route, layoutsMap: Map<string, string>): Array<{ name: string; filePath: string | undefined }> {\n const layouts: Array<{ name: string; filePath: string | undefined }> = [];\n\n // Check for segment-based layouts\n for (const segment of route.segments) {\n if (layoutsMap.has(segment)) {\n layouts.push({ name: segment, filePath: layoutsMap.get(segment) });\n }\n }\n\n // Check for route-specific layout\n if (route.layout) {\n layouts.push({ name: 'route', filePath: route.layout });\n }\n\n // Check for root layout\n if (layoutsMap.has('root')) {\n layouts.unshift({ name: 'root', filePath: layoutsMap.get('root') });\n }\n\n return layouts;\n}\n\n// ============================================================================\n// Tree Building\n// ============================================================================\n\nfunction buildTree(routes: Route[]): RouteTreeNode {\n const tree: RouteTreeNode = { children: {}, routes: [] };\n\n for (const route of routes) {\n let current = tree;\n for (const segment of route.segments) {\n if (!current.children[segment]) {\n current.children[segment] = { children: {}, routes: [] };\n }\n current = current.children[segment];\n }\n current.routes.push(route);\n }\n\n return tree;\n}\n\n// ============================================================================\n// Default Export\n// ============================================================================\n\nexport default {\n buildRouteTree,\n matchRoute,\n findRouteLayouts,\n RouteType\n};\n","/**\n * Velix v5 Utility Functions\n */\n\nimport fs from 'fs';\nimport path from 'path';\nimport crypto from 'crypto';\n\n/**\n * Generates a unique hash for cache busting\n */\nexport function generateHash(content: string): string {\n return crypto.createHash('md5').update(content).digest('hex').slice(0, 8);\n}\n\n/**\n * Escapes HTML special characters\n */\nexport function escapeHtml(str: string): string {\n const htmlEntities: Record<string, string> = {\n '&': '&amp;', '<': '&lt;', '>': '&gt;',\n '\"': '&quot;', \"'\": '&#39;'\n };\n return String(str).replace(/[&<>\"']/g, char => htmlEntities[char]);\n}\n\n/**\n * Recursively finds all files matching a pattern\n */\nexport function findFiles(dir: string, pattern: RegExp, files: string[] = []): string[] {\n if (!fs.existsSync(dir)) return files;\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n if (entry.isDirectory()) findFiles(fullPath, pattern, files);\n else if (pattern.test(entry.name)) files.push(fullPath);\n }\n return files;\n}\n\n/**\n * Ensures a directory exists\n */\nexport function ensureDir(dir: string): void {\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n}\n\n/**\n * Cleans a directory\n */\nexport function cleanDir(dir: string): void {\n if (fs.existsSync(dir)) fs.rmSync(dir, { recursive: true, force: true });\n fs.mkdirSync(dir, { recursive: true });\n}\n\n/**\n * Copies a directory recursively\n */\nexport function copyDir(src: string, dest: string): void {\n ensureDir(dest);\n const entries = fs.readdirSync(src, { withFileTypes: true });\n for (const entry of entries) {\n const srcPath = path.join(src, entry.name);\n const destPath = path.join(dest, entry.name);\n if (entry.isDirectory()) copyDir(srcPath, destPath);\n else fs.copyFileSync(srcPath, destPath);\n }\n}\n\n/**\n * Debounce function for file watching\n */\nexport function debounce<T extends (...args: unknown[]) => unknown>(fn: T, delay: number): (...args: Parameters<T>) => void {\n let timeout: ReturnType<typeof setTimeout> | undefined;\n return (...args: Parameters<T>) => {\n clearTimeout(timeout);\n timeout = setTimeout(() => fn(...args), delay);\n };\n}\n\n/**\n * Formats bytes to human-readable string\n */\nexport function formatBytes(bytes: number): string {\n if (bytes === 0) return '0 B';\n const k = 1024;\n const sizes = ['B', 'KB', 'MB', 'GB'];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];\n}\n\n/**\n * Formats milliseconds to human-readable string\n */\nexport function formatTime(ms: number): string {\n if (ms < 1000) return `${ms}ms`;\n return `${(ms / 1000).toFixed(2)}s`;\n}\n\n/**\n * Creates a deferred promise\n */\nexport function createDeferred<T>() {\n let resolve: (value: T | PromiseLike<T>) => void;\n let reject: (reason?: unknown) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve: resolve!, reject: reject! };\n}\n\n/**\n * Sleep utility\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n\n/**\n * Check if a file is a server component (has 'use server' directive)\n */\nexport function isServerComponent(filePath: string): boolean {\n try {\n const content = fs.readFileSync(filePath, 'utf-8');\n const firstLine = content.split('\\n')[0].trim();\n return firstLine === \"'use server'\" || firstLine === '\"use server\"';\n } catch { return false; }\n}\n\n/**\n * Check if a file is a client component (has 'use client' directive)\n */\nexport function isClientComponent(filePath: string): boolean {\n try {\n const content = fs.readFileSync(filePath, 'utf-8');\n const firstLine = content.split('\\n')[0].trim();\n return firstLine === \"'use client'\" || firstLine === '\"use client\"';\n } catch { return false; }\n}\n\n/**\n * Check if a component is an island (has 'use island' directive)\n */\nexport function isIsland(filePath: string): boolean {\n try {\n const content = fs.readFileSync(filePath, 'utf-8');\n const firstLine = content.split('\\n')[0].trim();\n return firstLine === \"'use island'\" || firstLine === '\"use island\"';\n } catch { return false; }\n}\n","/**\n * Velix version — single source of truth.\n * Update this file only when releasing a new version.\n */\nexport const VERSION = '5.2.3';\n","/**\n * Velix v5 Logger\n * Minimalist, professional output inspired by modern CLIs\n */\n\nimport { VERSION } from './version.js';\n\nconst colors = {\n reset: '\\x1b[0m',\n bold: '\\x1b[1m',\n dim: '\\x1b[2m',\n red: '\\x1b[31m',\n green: '\\x1b[32m',\n yellow: '\\x1b[33m',\n blue: '\\x1b[34m',\n magenta: '\\x1b[35m',\n cyan: '\\x1b[36m',\n white: '\\x1b[37m',\n gray: '\\x1b[90m',\n};\n\nconst c = colors;\n\nfunction getTime() {\n const now = new Date();\n const hours = String(now.getHours()).padStart(2, '0');\n const minutes = String(now.getMinutes()).padStart(2, '0');\n const seconds = String(now.getSeconds()).padStart(2, '0');\n return `${c.dim}${hours}:${minutes}:${seconds}${c.reset}`;\n}\n\nfunction getStatusColor(status: number) {\n if (status >= 500) return c.red;\n if (status >= 400) return c.yellow;\n if (status >= 300) return c.cyan;\n if (status >= 200) return c.green;\n return c.white;\n}\n\nfunction fmtTime(ms: number) {\n if (ms < 1) return `${c.gray}<1ms${c.reset}`;\n if (ms < 100) return `${c.green}${ms}ms${c.reset}`;\n if (ms < 500) return `${c.yellow}${ms}ms${c.reset}`;\n return `${c.red}${ms}ms${c.reset}`;\n}\n\nconst LOGO = `\n ${c.cyan}▲${c.reset} ${c.bold}Velix${c.reset} ${c.dim}v${VERSION}${c.reset}\n`;\n\nexport const logger = {\n logo() {\n console.log(LOGO);\n console.log(`${c.dim} ──────────────────────────────────────────────${c.reset}`);\n console.log('');\n },\n\n serverStart(config: { port: number | string; host: string; mode: string; pagesDir?: string }, startTime = Date.now()) {\n const { port, host, mode, pagesDir } = config;\n const elapsed = Date.now() - startTime;\n\n console.log(LOGO);\n console.log(` ${c.green}✔${c.reset} ${c.bold}Ready${c.reset} in ${elapsed}ms`);\n console.log('');\n console.log(` ${c.bold}Local:${c.reset} ${c.cyan}http://${host}:${port}${c.reset}`);\n console.log(` ${c.bold}Mode:${c.reset} ${mode === 'development' ? c.yellow : c.green}${mode}${c.reset}`);\n if (pagesDir) console.log(` ${c.bold}App:${c.reset} ${c.dim}${pagesDir}${c.reset}`);\n console.log('');\n },\n\n request(method: string, path: string, status: number, time: number, extra: { type?: string } = {}) {\n const statusColor = getStatusColor(status);\n const timeStr = fmtTime(time);\n\n let badge = `${c.dim}○${c.reset}`;\n if (extra.type === 'dynamic' || extra.type === 'ssr') badge = `${c.white}ƒ${c.reset}`;\n else if (extra.type === 'api') badge = `${c.cyan}λ${c.reset}`;\n\n const statusStr = `${statusColor}${status}${c.reset}`;\n console.log(` ${badge} ${c.white}${method}${c.reset} ${path} ${statusStr} ${c.dim}${timeStr}${c.reset}`);\n },\n\n info(msg: string) { console.log(` ${c.cyan}ℹ${c.reset} ${msg}`); },\n success(msg: string) { console.log(` ${c.green}✔${c.reset} ${msg}`); },\n warn(msg: string) { console.log(` ${c.yellow}⚠${c.reset} ${c.yellow}${msg}${c.reset}`); },\n\n error(msg: string, err: Error | null = null) {\n console.log(` ${c.red}✖${c.reset} ${c.red}${msg}${c.reset}`);\n if (err?.stack) {\n console.log('');\n console.log(`${c.dim}${err.stack.split('\\n').slice(1, 4).join('\\n')}${c.reset}`);\n console.log('');\n }\n },\n\n compile(file: string, time: number) {\n console.log(` ${c.white}●${c.reset} Compiling ${c.dim}${file}${c.reset} ${c.dim}(${time}ms)${c.reset}`);\n },\n\n hmr(file: string) {\n console.log(` ${c.green}↻${c.reset} Fast Refresh ${c.dim}${file}${c.reset}`);\n },\n\n plugin(name: string) {\n console.log(` ${c.cyan}◆${c.reset} Plugin ${c.dim}${name}${c.reset}`);\n },\n\n route(path: string, type: string) {\n const typeLabel = type === 'api' ? 'λ' : type === 'dynamic' ? 'ƒ' : '○';\n const color = type === 'api' ? c.cyan : type === 'dynamic' ? c.white : c.dim;\n console.log(` ${color}${typeLabel}${c.reset} ${path}`);\n },\n\n divider() { console.log(`${c.dim} ──────────────────────────────────────────────${c.reset}`); },\n blank() { console.log(''); },\n\n portInUse(port: number | string) {\n this.error(`Port ${port} is already in use.`);\n this.blank();\n console.log(` ${c.dim}Try:${c.reset}`);\n console.log(` 1. Kill the process on port ${port}`);\n console.log(` 2. Use a different port via PORT env var`);\n this.blank();\n },\n\n build(stats: { time: number }) {\n this.blank();\n console.log(` ${c.green}✔${c.reset} Build completed`);\n this.blank();\n console.log(` ${c.dim}Total time:${c.reset} ${c.white}${stats.time}ms${c.reset}`);\n this.blank();\n },\n};\n\nexport default logger;\n","/**\n * Velix v5 — Build Script\n * Build the application for production\n */\n\nimport { build } from '../build/index.js';\nimport logger from '../logger.js';\n\nbuild().catch(err => {\n logger.error('Build failed', err);\n process.exit(1);\n});\n"],"mappings":";AAKA,OAAO,aAAa;AACpB,OAAOA,SAAQ;AACf,OAAOC,WAAU;;;ACFjB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAC9B,SAAS,SAAS;AAClB,OAAO,QAAQ;AAMf,IAAM,kBAAk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AAS,iBAAiB,KAAa,MAAc;AACnD,YAAU,IAAI;AACd,QAAM,UAAUC,IAAG,YAAY,KAAK,EAAE,eAAe,KAAK,CAAC;AAC3D,aAAW,SAAS,SAAS;AAC3B,UAAM,UAAUD,MAAK,KAAK,KAAK,MAAM,IAAI;AACzC,UAAM,WAAWA,MAAK,KAAK,MAAM,MAAM,IAAI;AAC3C,QAAI,MAAM,YAAY,EAAG,kBAAiB,SAAS,QAAQ;AAAA,QACtD,CAAAC,IAAG,aAAa,SAAS,QAAQ;AAAA,EACxC;AACF;AAEA,SAAS,WAAW,KAAqB;AACvC,MAAI,OAAO;AACX,MAAI,CAACA,IAAG,WAAW,GAAG,EAAG,QAAO;AAChC,QAAM,UAAUA,IAAG,YAAY,KAAK,EAAE,eAAe,KAAK,CAAC;AAC3D,aAAW,SAAS,SAAS;AAC3B,UAAM,WAAWD,MAAK,KAAK,KAAK,MAAM,IAAI;AAC1C,QAAI,MAAM,YAAY,EAAG,SAAQ,WAAW,QAAQ;AAAA,QAC/C,SAAQC,IAAG,SAAS,QAAQ,EAAE;AAAA,EACrC;AACA,SAAO;AACT;;;AM9KA,MAAM,EAAE,MAAM,SAAO;AACnB,iBAAO,MAAM,gBAAgB,GAAG;AAChC,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["fs","path","fs","path","fs","path","fs","path","fs","path","fs","path","path","fs"]}
1
+ {"version":3,"sources":["../../build/index.ts","../../config.ts","../../router/index.ts","../../utils.ts","../../version.ts","../../logger.ts","../../plugins/index.ts","../../runtime/start-build.ts"],"sourcesContent":["/**\n * Velix v5 Build System\n * Production build using esbuild\n */\n\nimport esbuild from 'esbuild';\nimport fs from 'fs';\nimport path from 'path';\nimport { loadConfig, resolvePaths } from '../config.js';\nimport { buildRouteTree } from '../router/index.js';\nimport { ensureDir, cleanDir, findFiles, formatBytes, formatTime } from '../utils.js';\nimport logger from '../logger.js';\nimport { VERSION } from '../version.js';\nimport { pluginManager, loadPlugins, PluginHooks } from '../plugins/index.js';\n\nexport interface BuildOptions {\n projectRoot?: string;\n outDir?: string;\n minify?: boolean;\n sourcemap?: boolean;\n}\n\n/**\n * Build the Velix application for production\n */\nexport async function build(options: BuildOptions = {}) {\n const projectRoot = options.projectRoot || process.cwd();\n const config = await loadConfig(projectRoot);\n const resolved = resolvePaths(config, projectRoot);\n\n // Load plugins and run config hook\n await loadPlugins(projectRoot, config);\n await pluginManager.runHook(PluginHooks.CONFIG, config);\n\n const outDir = options.outDir || resolved.resolvedOutDir;\n const startTime = Date.now();\n\n logger.logo();\n logger.info('Building for production...');\n logger.blank();\n\n // Run build:start hook (e.g., Tailwind CSS build)\n await pluginManager.runHook(PluginHooks.BUILD_START);\n\n // Clean output directory\n cleanDir(outDir);\n\n const appDir = resolved.resolvedAppDir;\n const routes = buildRouteTree(appDir);\n\n // Collect all source files\n const sourceFiles = findFiles(appDir, /\\.(tsx?|jsx?)$/);\n\n if (sourceFiles.length === 0) {\n logger.warn('No source files found in app/ directory');\n return;\n }\n\n // Build server bundle\n try {\n const serverOutDir = path.join(outDir, 'server');\n ensureDir(serverOutDir);\n\n await esbuild.build({\n entryPoints: sourceFiles,\n outdir: serverOutDir,\n bundle: false,\n format: 'esm',\n platform: 'node',\n target: config.build.target,\n minify: options.minify ?? config.build.minify,\n sourcemap: options.sourcemap ?? config.build.sourcemap,\n jsx: 'automatic',\n logLevel: 'silent',\n treeShaking: true,\n legalComments: 'none',\n });\n\n logger.success('Server bundle built');\n } catch (err: any) {\n logger.error('Server build failed', err);\n process.exit(1);\n }\n\n // Build client bundle (client components and islands)\n try {\n const clientOutDir = path.join(outDir, 'client');\n ensureDir(clientOutDir);\n\n const clientFiles = sourceFiles.filter(f => {\n const content = fs.readFileSync(f, 'utf-8');\n const firstLine = content.split('\\n')[0]?.trim();\n return firstLine === \"'use client'\" || firstLine === '\"use client\"' ||\n firstLine === \"'use island'\" || firstLine === '\"use island\"';\n });\n\n if (clientFiles.length > 0) {\n await esbuild.build({\n entryPoints: clientFiles,\n outdir: clientOutDir,\n bundle: true,\n format: 'esm',\n platform: 'browser',\n target: ['es2022'],\n minify: options.minify ?? config.build.minify,\n sourcemap: options.sourcemap ?? config.build.sourcemap,\n splitting: config.build.splitting,\n jsx: 'automatic',\n logLevel: 'silent',\n external: ['react', 'react-dom'],\n treeShaking: true,\n legalComments: 'none',\n drop: options.minify ?? config.build.minify ? ['console', 'debugger'] : [],\n chunkNames: 'chunks/[name]-[hash]',\n });\n\n logger.success(`Client bundle built (${clientFiles.length} components)`);\n }\n } catch (err: any) {\n logger.error('Client build failed', err);\n process.exit(1);\n }\n\n // Copy public directory\n const publicDir = resolved.resolvedPublicDir;\n if (fs.existsSync(publicDir)) {\n const publicOutDir = path.join(outDir, 'public');\n ensureDir(publicOutDir);\n copyDirRecursive(publicDir, publicOutDir);\n logger.success('Static assets copied');\n }\n\n // Generate build manifest\n const manifest = {\n version: VERSION,\n buildTime: new Date().toISOString(),\n routes: routes.appRoutes.map(r => ({\n path: r.path,\n type: r.path.includes(':') ? 'dynamic' : 'static',\n })),\n api: routes.api.map(r => ({ path: r.path })),\n };\n\n fs.writeFileSync(path.join(outDir, 'manifest.json'), JSON.stringify(manifest, null, 2));\n\n const elapsed = Date.now() - startTime;\n const totalSize = getDirSize(outDir);\n\n logger.blank();\n logger.divider();\n logger.blank();\n\n // Log routes\n routes.appRoutes.forEach(r => {\n const type = r.path.includes(':') || r.path.includes('*') ? 'dynamic' : 'static';\n logger.route(r.path, type);\n });\n routes.api.forEach(r => logger.route(r.path, 'api'));\n\n logger.blank();\n logger.build({ time: elapsed });\n logger.info(`Output: ${outDir} (${formatBytes(totalSize)})`);\n logger.blank();\n\n // Run build:end hook\n await pluginManager.runHook(PluginHooks.BUILD_END, { time: elapsed });\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\nfunction copyDirRecursive(src: string, dest: string) {\n ensureDir(dest);\n const entries = fs.readdirSync(src, { withFileTypes: true });\n for (const entry of entries) {\n const srcPath = path.join(src, entry.name);\n const destPath = path.join(dest, entry.name);\n if (entry.isDirectory()) copyDirRecursive(srcPath, destPath);\n else fs.copyFileSync(srcPath, destPath);\n }\n}\n\nfunction getDirSize(dir: string): number {\n let size = 0;\n if (!fs.existsSync(dir)) return size;\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n if (entry.isDirectory()) size += getDirSize(fullPath);\n else size += fs.statSync(fullPath).size;\n }\n return size;\n}\n\nexport default { build };\n","/**\n * Velix v5 Configuration System\n * Handles loading, validation, and merging of velix.config.ts\n */\n\nimport fs from 'fs';\nimport path from 'path';\nimport { pathToFileURL } from 'url';\nimport { z } from 'zod';\nimport pc from 'picocolors';\n\n// ============================================================================\n// Configuration Schema (Zod validation)\n// ============================================================================\n\nconst AppConfigSchema = z.object({\n name: z.string().default('Velix App'),\n url: z.string().url().optional(),\n}).default({});\n\nconst ServerConfigSchema = z.object({\n port: z.number().min(1).max(65535).default(3000),\n host: z.string().default('localhost'),\n}).default({});\n\nconst RoutingConfigSchema = z.object({\n trailingSlash: z.boolean().default(false),\n}).default({});\n\nconst SEOConfigSchema = z.object({\n sitemap: z.boolean().default(true),\n robots: z.boolean().default(true),\n openGraph: z.boolean().default(true),\n}).default({});\n\nconst BuildConfigSchema = z.object({\n target: z.string().default('es2022'),\n minify: z.boolean().default(true),\n sourcemap: z.boolean().default(true),\n splitting: z.boolean().default(true),\n outDir: z.string().default('.velix'),\n}).default({});\n\nconst ExperimentalConfigSchema = z.object({\n islands: z.boolean().default(true),\n streaming: z.boolean().default(true),\n}).default({});\n\nconst PluginSchema = z.union([\n z.string(),\n z.object({\n name: z.string()\n }).passthrough(),\n]);\n\nexport const VelixConfigSchema = z.object({\n // App identity\n app: AppConfigSchema,\n\n // DevTools toggle\n devtools: z.boolean().default(true),\n\n // Server options\n server: ServerConfigSchema,\n\n // Routing options\n routing: RoutingConfigSchema,\n\n // SEO configuration\n seo: SEOConfigSchema,\n\n // Build options\n build: BuildConfigSchema,\n\n // Experimental features\n experimental: ExperimentalConfigSchema,\n\n // Plugins\n plugins: z.array(PluginSchema).default([]),\n\n // Directories (resolved automatically)\n appDir: z.string().default('app'),\n publicDir: z.string().default('public'),\n\n // Stylesheets\n styles: z.array(z.string()).default([]),\n\n // Favicon\n favicon: z.string().nullable().default(null),\n});\n\nexport type VelixConfig = z.infer<typeof VelixConfigSchema>;\n\n// ============================================================================\n// Default configuration\n// ============================================================================\n\nexport const defaultConfig: VelixConfig = VelixConfigSchema.parse({});\n\n// ============================================================================\n// defineConfig helper\n// ============================================================================\n\n/**\n * Helper function to define configuration with full type support.\n * Use this in your velix.config.ts file.\n *\n * @example\n * ```ts\n * import { defineConfig } from \"velix\";\n *\n * export default defineConfig({\n * app: { name: \"My App\" },\n * server: { port: 3000 },\n * seo: { sitemap: true }\n * });\n * ```\n */\nexport function defineConfig(config: Partial<VelixConfig>): Partial<VelixConfig> {\n return config;\n}\n\n// ============================================================================\n// Config Loader\n// ============================================================================\n\n/**\n * Loads and validates configuration from velix.config.ts\n */\nexport async function loadConfig(projectRoot: string): Promise<VelixConfig> {\n const configPathTs = path.join(projectRoot, 'velix.config.ts');\n const configPathJs = path.join(projectRoot, 'velix.config.js');\n // Support legacy config for migration\n const configPathLegacyTs = path.join(projectRoot, 'flexireact.config.ts');\n const configPathLegacyJs = path.join(projectRoot, 'flexireact.config.js');\n\n let configPath: string | null = null;\n if (fs.existsSync(configPathTs)) configPath = configPathTs;\n else if (fs.existsSync(configPathJs)) configPath = configPathJs;\n else if (fs.existsSync(configPathLegacyTs)) configPath = configPathLegacyTs;\n else if (fs.existsSync(configPathLegacyJs)) configPath = configPathLegacyJs;\n\n let userConfig: Partial<VelixConfig> = {};\n\n if (configPath) {\n try {\n const configUrl = pathToFileURL(configPath).href;\n const module = await import(`${configUrl}?t=${Date.now()}`);\n userConfig = module.default || module;\n } catch (error: any) {\n console.warn(pc.yellow(`⚠ Failed to load config: ${error.message}`));\n }\n }\n\n // Merge and validate with Zod\n const merged = deepMerge(defaultConfig, userConfig as Record<string, any>);\n\n try {\n return VelixConfigSchema.parse(merged);\n } catch (err: unknown) {\n if (err instanceof z.ZodError) {\n console.error(pc.red('✖ Configuration validation failed:'));\n for (const issue of err.issues) {\n console.error(pc.dim(` - ${issue.path.join('.')}: ${issue.message}`));\n }\n process.exit(1);\n }\n throw err;\n }\n}\n\n// ============================================================================\n// Path Resolution\n// ============================================================================\n\n/**\n * Resolves all paths in config relative to project root\n */\nexport function resolvePaths(config: VelixConfig, projectRoot: string): VelixConfig & { resolvedAppDir: string; resolvedPublicDir: string; resolvedOutDir: string } {\n return {\n ...config,\n resolvedAppDir: path.resolve(projectRoot, config.appDir),\n resolvedPublicDir: path.resolve(projectRoot, config.publicDir),\n resolvedOutDir: path.resolve(projectRoot, config.build.outDir),\n };\n}\n\n// ============================================================================\n// Utility: Deep merge\n// ============================================================================\n\nfunction deepMerge(target: Record<string, any>, source: Record<string, any>): Record<string, any> {\n const result = { ...target };\n\n for (const key in source) {\n if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {\n result[key] = deepMerge(target[key] || {}, source[key]);\n } else {\n result[key] = source[key];\n }\n }\n\n return result;\n}\n","/**\n * Velix v5 Router\n * File-based routing using the app/ directory convention\n *\n * Supports:\n * - app/page.tsx → /\n * - app/dashboard/page.tsx → /dashboard\n * - app/blog/[slug]/page.tsx → /blog/:slug\n * - app/(group)/page.tsx → / (route groups)\n * - app/[...slug]/page.tsx → catch-all routes\n * - layout.tsx, loading.tsx, error.tsx, not-found.tsx\n */\n\nimport fs from 'fs';\nimport path from 'path';\nimport { isServerComponent, isClientComponent, isIsland } from '../utils.js';\nimport type { Route, RouteTree as TypedRouteTree, RouteTreeNode } from '../types.js';\n\n// ============================================================================\n// Route Types\n// ============================================================================\n\nexport const RouteType = {\n PAGE: 'page',\n API: 'api',\n LAYOUT: 'layout',\n LOADING: 'loading',\n ERROR: 'error',\n NOT_FOUND: 'not-found'\n} as const;\n\n// ============================================================================\n// Build Route Tree\n// ============================================================================\n\n/**\n * Builds the complete route tree from the app/ directory\n */\nexport function buildRouteTree(appDir: string) {\n const projectRoot = path.dirname(appDir);\n\n const routes: {\n pages: Route[];\n api: Route[];\n layouts: Map<string, string>;\n tree: RouteTreeNode;\n appRoutes: Route[];\n rootLayout?: string;\n } = {\n pages: [],\n api: [],\n layouts: new Map(),\n tree: { children: {}, routes: [] },\n appRoutes: [],\n };\n\n // Scan app/ directory\n if (fs.existsSync(appDir)) {\n scanAppDirectory(appDir, appDir, routes);\n }\n\n // Scan server/api/ for API routes\n const serverApiDir = path.join(projectRoot, 'server', 'api');\n if (fs.existsSync(serverApiDir)) {\n scanApiDirectory(serverApiDir, serverApiDir, routes);\n }\n\n // Check for root layout\n const rootLayoutTsx = path.join(appDir, 'layout.tsx');\n const rootLayoutJsx = path.join(appDir, 'layout.jsx');\n if (fs.existsSync(rootLayoutTsx)) routes.rootLayout = rootLayoutTsx;\n else if (fs.existsSync(rootLayoutJsx)) routes.rootLayout = rootLayoutJsx;\n\n // Build route tree for nested routes\n routes.tree = buildTree(routes.appRoutes);\n\n return routes;\n}\n\n// ============================================================================\n// App Directory Scanner\n// ============================================================================\n\n/**\n * Scans app/ directory for file-based routing\n * Supports: page.tsx, layout.tsx, loading.tsx, error.tsx, not-found.tsx, [param].tsx\n */\nfunction scanAppDirectory(\n baseDir: string,\n currentDir: string,\n routes: { appRoutes: Route[] },\n parentSegments: string[] = [],\n parentLayout: string | null = null,\n parentMiddleware: string | null = null\n) {\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\n\n // Find special files in current directory\n const specialFiles: Record<string, string | null> = {\n page: null,\n layout: null,\n loading: null,\n error: null,\n notFound: null,\n template: null,\n middleware: null\n };\n\n for (const entry of entries) {\n if (entry.isFile()) {\n const name = entry.name.replace(/\\.(jsx|js|tsx|ts)$/, '');\n const fullPath = path.join(currentDir, entry.name);\n const ext = path.extname(entry.name);\n\n // Only process relevant extensions\n if (!['.tsx', '.jsx', '.ts', '.js'].includes(ext)) continue;\n\n if (name === 'page') specialFiles.page = fullPath;\n if (name === 'layout') specialFiles.layout = fullPath;\n if (name === 'loading') specialFiles.loading = fullPath;\n if (name === 'error') specialFiles.error = fullPath;\n if (name === 'not-found') specialFiles.notFound = fullPath;\n if (name === 'template') specialFiles.template = fullPath;\n if (name === 'middleware' || name === '_middleware') specialFiles.middleware = fullPath;\n\n // Handle [param].tsx files directly in app/ (alternative to [param]/page.tsx)\n if (name.startsWith('[') && name.endsWith(']') && ['.tsx', '.jsx'].includes(ext)) {\n const paramName = name.slice(1, -1);\n let segmentName: string;\n\n if (paramName.startsWith('...')) {\n segmentName = '*' + paramName.slice(3);\n } else {\n segmentName = ':' + paramName;\n }\n\n const routePath = '/' + [...parentSegments, segmentName].join('/');\n\n routes.appRoutes.push({\n type: RouteType.PAGE,\n path: routePath.replace(/\\/+/g, '/'),\n filePath: fullPath,\n pattern: createRoutePattern(routePath),\n segments: [...parentSegments, segmentName],\n layout: specialFiles.layout || parentLayout,\n loading: specialFiles.loading,\n error: specialFiles.error,\n notFound: specialFiles.notFound,\n template: specialFiles.template,\n middleware: specialFiles.middleware || parentMiddleware,\n isServerComponent: isServerComponent(fullPath),\n isClientComponent: isClientComponent(fullPath),\n isIsland: isIsland(fullPath),\n });\n }\n }\n }\n\n // If there's a page.tsx, create a route for this directory\n if (specialFiles.page) {\n const routePath = '/' + parentSegments.join('/') || '/';\n\n routes.appRoutes.push({\n type: RouteType.PAGE,\n path: routePath.replace(/\\/+/g, '/') || '/',\n filePath: specialFiles.page,\n pattern: createRoutePattern(routePath || '/'),\n segments: parentSegments,\n layout: specialFiles.layout || parentLayout,\n loading: specialFiles.loading,\n error: specialFiles.error,\n notFound: specialFiles.notFound,\n template: specialFiles.template,\n middleware: specialFiles.middleware || parentMiddleware,\n isServerComponent: isServerComponent(specialFiles.page),\n isClientComponent: isClientComponent(specialFiles.page),\n isIsland: isIsland(specialFiles.page),\n });\n }\n\n // Recursively scan subdirectories\n for (const entry of entries) {\n if (entry.isDirectory()) {\n const fullPath = path.join(currentDir, entry.name);\n\n // Skip special directories\n if (entry.name.startsWith('_') || entry.name.startsWith('.')) continue;\n\n // Handle route groups (parentheses) — don't add to URL\n const isGroup = entry.name.startsWith('(') && entry.name.endsWith(')');\n\n // Handle dynamic segments [param]\n let segmentName = entry.name;\n if (entry.name.startsWith('[') && entry.name.endsWith(']')) {\n segmentName = ':' + entry.name.slice(1, -1);\n if (entry.name.startsWith('[...')) {\n segmentName = '*' + entry.name.slice(4, -1);\n }\n if (entry.name.startsWith('[[...')) {\n segmentName = '*' + entry.name.slice(5, -2);\n }\n }\n\n const newSegments = isGroup ? parentSegments : [...parentSegments, segmentName];\n const newLayout = specialFiles.layout || parentLayout;\n const newMiddleware = specialFiles.middleware || parentMiddleware;\n\n scanAppDirectory(baseDir, fullPath, routes, newSegments, newLayout, newMiddleware);\n }\n }\n}\n\n// ============================================================================\n// API Directory Scanner (server/api/)\n// ============================================================================\n\nfunction scanApiDirectory(baseDir: string, currentDir: string, routes: { api: Route[] }, parentSegments: string[] = []) {\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(currentDir, entry.name);\n\n if (entry.isDirectory()) {\n scanApiDirectory(baseDir, fullPath, routes, [...parentSegments, entry.name]);\n } else if (entry.isFile()) {\n const ext = path.extname(entry.name);\n if (!['.ts', '.js'].includes(ext)) continue;\n\n const baseName = path.basename(entry.name, ext);\n // route.ts maps to the parent path, other names become segments\n const apiSegments = baseName === 'route' || baseName === 'index'\n ? parentSegments\n : [...parentSegments, baseName];\n\n const apiPath = '/api/' + apiSegments.join('/');\n\n routes.api.push({\n type: RouteType.API,\n path: apiPath.replace(/\\/+/g, '/') || '/api',\n filePath: fullPath,\n pattern: createRoutePattern(apiPath),\n segments: ['api', ...apiSegments].filter(Boolean),\n });\n }\n }\n}\n\n// ============================================================================\n// Route Matching\n// ============================================================================\n\n/**\n * Creates regex pattern for route matching\n */\nfunction createRoutePattern(routePath: string): RegExp {\n let pattern = routePath\n .replace(/\\*[^/]*/g, '(.*)') // Catch-all\n .replace(/:[^/]+/g, '([^/]+)') // Dynamic segments\n .replace(/\\//g, '\\\\/');\n\n return new RegExp(`^${pattern}$`);\n}\n\n/**\n * Matches URL path against routes\n */\nexport function matchRoute(urlPath: string, routes: Route[]) {\n const normalizedPath = urlPath === '' ? '/' : urlPath.split('?')[0];\n\n for (const route of routes) {\n const match = normalizedPath.match(route.pattern);\n if (match) {\n const params = extractParams(route.path, match);\n return { ...route, params };\n }\n }\n\n return null;\n}\n\n/**\n * Extracts parameters from route match\n */\nfunction extractParams(routePath: string, match: RegExpMatchArray): Record<string, string> {\n const params: Record<string, string> = {};\n const paramNames: string[] = [];\n\n const paramRegex = /:([^/]+)|\\*([^/]*)/g;\n let paramMatch;\n while ((paramMatch = paramRegex.exec(routePath)) !== null) {\n paramNames.push(paramMatch[1] || paramMatch[2] || 'splat');\n }\n\n paramNames.forEach((name, index) => {\n params[name] = match[index + 1];\n });\n\n return params;\n}\n\n// ============================================================================\n// Layout Resolution\n// ============================================================================\n\n/**\n * Finds all layouts that apply to a route\n */\nexport function findRouteLayouts(route: Route, layoutsMap: Map<string, string>): Array<{ name: string; filePath: string | undefined }> {\n const layouts: Array<{ name: string; filePath: string | undefined }> = [];\n\n // Check for segment-based layouts\n for (const segment of route.segments) {\n if (layoutsMap.has(segment)) {\n layouts.push({ name: segment, filePath: layoutsMap.get(segment) });\n }\n }\n\n // Check for route-specific layout\n if (route.layout) {\n layouts.push({ name: 'route', filePath: route.layout });\n }\n\n // Check for root layout\n if (layoutsMap.has('root')) {\n layouts.unshift({ name: 'root', filePath: layoutsMap.get('root') });\n }\n\n return layouts;\n}\n\n// ============================================================================\n// Tree Building\n// ============================================================================\n\nfunction buildTree(routes: Route[]): RouteTreeNode {\n const tree: RouteTreeNode = { children: {}, routes: [] };\n\n for (const route of routes) {\n let current = tree;\n for (const segment of route.segments) {\n if (!current.children[segment]) {\n current.children[segment] = { children: {}, routes: [] };\n }\n current = current.children[segment];\n }\n current.routes.push(route);\n }\n\n return tree;\n}\n\n// ============================================================================\n// Default Export\n// ============================================================================\n\nexport default {\n buildRouteTree,\n matchRoute,\n findRouteLayouts,\n RouteType\n};\n","/**\n * Velix v5 Utility Functions\n */\n\nimport fs from 'fs';\nimport path from 'path';\nimport crypto from 'crypto';\n\n/**\n * Generates a unique hash for cache busting\n */\nexport function generateHash(content: string): string {\n return crypto.createHash('md5').update(content).digest('hex').slice(0, 8);\n}\n\n/**\n * Escapes HTML special characters\n */\nexport function escapeHtml(str: string): string {\n const htmlEntities: Record<string, string> = {\n '&': '&amp;', '<': '&lt;', '>': '&gt;',\n '\"': '&quot;', \"'\": '&#39;'\n };\n return String(str).replace(/[&<>\"']/g, char => htmlEntities[char]);\n}\n\n/**\n * Recursively finds all files matching a pattern\n */\nexport function findFiles(dir: string, pattern: RegExp, files: string[] = []): string[] {\n if (!fs.existsSync(dir)) return files;\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n if (entry.isDirectory()) findFiles(fullPath, pattern, files);\n else if (pattern.test(entry.name)) files.push(fullPath);\n }\n return files;\n}\n\n/**\n * Ensures a directory exists\n */\nexport function ensureDir(dir: string): void {\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n}\n\n/**\n * Cleans a directory\n */\nexport function cleanDir(dir: string): void {\n if (fs.existsSync(dir)) fs.rmSync(dir, { recursive: true, force: true });\n fs.mkdirSync(dir, { recursive: true });\n}\n\n/**\n * Copies a directory recursively\n */\nexport function copyDir(src: string, dest: string): void {\n ensureDir(dest);\n const entries = fs.readdirSync(src, { withFileTypes: true });\n for (const entry of entries) {\n const srcPath = path.join(src, entry.name);\n const destPath = path.join(dest, entry.name);\n if (entry.isDirectory()) copyDir(srcPath, destPath);\n else fs.copyFileSync(srcPath, destPath);\n }\n}\n\n/**\n * Debounce function for file watching\n */\nexport function debounce<T extends (...args: unknown[]) => unknown>(fn: T, delay: number): (...args: Parameters<T>) => void {\n let timeout: ReturnType<typeof setTimeout> | undefined;\n return (...args: Parameters<T>) => {\n clearTimeout(timeout);\n timeout = setTimeout(() => fn(...args), delay);\n };\n}\n\n/**\n * Formats bytes to human-readable string\n */\nexport function formatBytes(bytes: number): string {\n if (bytes === 0) return '0 B';\n const k = 1024;\n const sizes = ['B', 'KB', 'MB', 'GB'];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];\n}\n\n/**\n * Formats milliseconds to human-readable string\n */\nexport function formatTime(ms: number): string {\n if (ms < 1000) return `${ms}ms`;\n return `${(ms / 1000).toFixed(2)}s`;\n}\n\n/**\n * Creates a deferred promise\n */\nexport function createDeferred<T>() {\n let resolve: (value: T | PromiseLike<T>) => void;\n let reject: (reason?: unknown) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve: resolve!, reject: reject! };\n}\n\n/**\n * Sleep utility\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n\n/**\n * Check if a file is a server component (has 'use server' directive)\n */\nexport function isServerComponent(filePath: string): boolean {\n try {\n const content = fs.readFileSync(filePath, 'utf-8');\n const firstLine = content.split('\\n')[0].trim();\n return firstLine === \"'use server'\" || firstLine === '\"use server\"';\n } catch { return false; }\n}\n\n/**\n * Check if a file is a client component (has 'use client' directive)\n */\nexport function isClientComponent(filePath: string): boolean {\n try {\n const content = fs.readFileSync(filePath, 'utf-8');\n const firstLine = content.split('\\n')[0].trim();\n return firstLine === \"'use client'\" || firstLine === '\"use client\"';\n } catch { return false; }\n}\n\n/**\n * Check if a component is an island (has 'use island' directive)\n */\nexport function isIsland(filePath: string): boolean {\n try {\n const content = fs.readFileSync(filePath, 'utf-8');\n const firstLine = content.split('\\n')[0].trim();\n return firstLine === \"'use island'\" || firstLine === '\"use island\"';\n } catch { return false; }\n}\n","/**\r\n * Velix version — single source of truth.\r\n * Update this file only when releasing a new version.\r\n */\r\nexport const VERSION = '5.2.7';\r\n","/**\n * Velix v5 Logger\n * Minimalist, professional output inspired by modern CLIs\n */\n\nimport { VERSION } from './version.js';\n\nconst colors = {\n reset: '\\x1b[0m',\n bold: '\\x1b[1m',\n dim: '\\x1b[2m',\n red: '\\x1b[31m',\n green: '\\x1b[32m',\n yellow: '\\x1b[33m',\n blue: '\\x1b[34m',\n magenta: '\\x1b[35m',\n cyan: '\\x1b[36m',\n white: '\\x1b[37m',\n gray: '\\x1b[90m',\n};\n\nconst c = colors;\n\nfunction getTime() {\n const now = new Date();\n const hours = String(now.getHours()).padStart(2, '0');\n const minutes = String(now.getMinutes()).padStart(2, '0');\n const seconds = String(now.getSeconds()).padStart(2, '0');\n return `${c.dim}${hours}:${minutes}:${seconds}${c.reset}`;\n}\n\nfunction getStatusColor(status: number) {\n if (status >= 500) return c.red;\n if (status >= 400) return c.yellow;\n if (status >= 300) return c.cyan;\n if (status >= 200) return c.green;\n return c.white;\n}\n\nfunction fmtTime(ms: number) {\n if (ms < 1) return `${c.gray}<1ms${c.reset}`;\n if (ms < 100) return `${c.green}${ms}ms${c.reset}`;\n if (ms < 500) return `${c.yellow}${ms}ms${c.reset}`;\n return `${c.red}${ms}ms${c.reset}`;\n}\n\nconst LOGO = `\n ${c.cyan}▲${c.reset} ${c.bold}Velix${c.reset} ${c.dim}v${VERSION}${c.reset}\n`;\n\nexport const logger = {\n logo() {\n console.log(LOGO);\n console.log(`${c.dim} ──────────────────────────────────────────────${c.reset}`);\n console.log('');\n },\n\n serverStart(config: { port: number | string; host: string; mode: string; pagesDir?: string }, startTime = Date.now()) {\n const { port, host, mode, pagesDir } = config;\n const elapsed = Date.now() - startTime;\n\n console.log(LOGO);\n console.log(` ${c.green}✔${c.reset} ${c.bold}Ready${c.reset} in ${elapsed}ms`);\n console.log('');\n console.log(` ${c.bold}Local:${c.reset} ${c.cyan}http://${host}:${port}${c.reset}`);\n console.log(` ${c.bold}Mode:${c.reset} ${mode === 'development' ? c.yellow : c.green}${mode}${c.reset}`);\n if (pagesDir) console.log(` ${c.bold}App:${c.reset} ${c.dim}${pagesDir}${c.reset}`);\n console.log('');\n },\n\n request(method: string, path: string, status: number, time: number, extra: { type?: string } = {}) {\n const statusColor = getStatusColor(status);\n const timeStr = fmtTime(time);\n\n let badge = `${c.dim}○${c.reset}`;\n if (extra.type === 'dynamic' || extra.type === 'ssr') badge = `${c.white}ƒ${c.reset}`;\n else if (extra.type === 'api') badge = `${c.cyan}λ${c.reset}`;\n\n const statusStr = `${statusColor}${status}${c.reset}`;\n console.log(` ${badge} ${c.white}${method}${c.reset} ${path} ${statusStr} ${c.dim}${timeStr}${c.reset}`);\n },\n\n info(msg: string) { console.log(` ${c.cyan}ℹ${c.reset} ${msg}`); },\n success(msg: string) { console.log(` ${c.green}✔${c.reset} ${msg}`); },\n warn(msg: string) { console.log(` ${c.yellow}⚠${c.reset} ${c.yellow}${msg}${c.reset}`); },\n\n error(msg: string, err: Error | null = null) {\n console.log(` ${c.red}✖${c.reset} ${c.red}${msg}${c.reset}`);\n if (err?.stack) {\n console.log('');\n console.log(`${c.dim}${err.stack.split('\\n').slice(1, 4).join('\\n')}${c.reset}`);\n console.log('');\n }\n },\n\n compile(file: string, time: number) {\n console.log(` ${c.white}●${c.reset} Compiling ${c.dim}${file}${c.reset} ${c.dim}(${time}ms)${c.reset}`);\n },\n\n hmr(file: string) {\n console.log(` ${c.green}↻${c.reset} Fast Refresh ${c.dim}${file}${c.reset}`);\n },\n\n plugin(name: string) {\n console.log(` ${c.cyan}◆${c.reset} Plugin ${c.dim}${name}${c.reset}`);\n },\n\n route(path: string, type: string) {\n const typeLabel = type === 'api' ? 'λ' : type === 'dynamic' ? 'ƒ' : '○';\n const color = type === 'api' ? c.cyan : type === 'dynamic' ? c.white : c.dim;\n console.log(` ${color}${typeLabel}${c.reset} ${path}`);\n },\n\n divider() { console.log(`${c.dim} ──────────────────────────────────────────────${c.reset}`); },\n blank() { console.log(''); },\n\n portInUse(port: number | string) {\n this.error(`Port ${port} is already in use.`);\n this.blank();\n console.log(` ${c.dim}Try:${c.reset}`);\n console.log(` 1. Kill the process on port ${port}`);\n console.log(` 2. Use a different port via PORT env var`);\n this.blank();\n },\n\n build(stats: { time: number }) {\n this.blank();\n console.log(` ${c.green}✔${c.reset} Build completed`);\n this.blank();\n console.log(` ${c.dim}Total time:${c.reset} ${c.white}${stats.time}ms${c.reset}`);\n this.blank();\n },\n};\n\nexport default logger;\n","/**\n * Velix v5 Plugin System\n * Extensible hook-based plugin architecture\n */\n\nimport fs from 'fs';\nimport path from 'path';\nimport { pathToFileURL } from 'url';\n\n// ============================================================================\n// Plugin Hooks\n// ============================================================================\n\nexport const PluginHooks = {\n CONFIG: 'config',\n SERVER_START: 'server:start',\n REQUEST: 'request',\n RESPONSE: 'response',\n ROUTES_LOADED: 'routes:loaded',\n BEFORE_RENDER: 'render:before',\n AFTER_RENDER: 'render:after',\n BUILD_START: 'build:start',\n BUILD_END: 'build:end',\n} as const;\n\nexport type PluginHook = typeof PluginHooks[keyof typeof PluginHooks];\n\n// ============================================================================\n// Plugin Interface\n// ============================================================================\n\nexport interface PluginHookArgs {\n [PluginHooks.CONFIG]: [config: import('../config.js').VelixConfig];\n [PluginHooks.SERVER_START]: [context: { config: import('../config.js').VelixConfig; isDev: boolean; projectRoot: string }, isDev: boolean];\n [PluginHooks.REQUEST]: [req: import('http').IncomingMessage, res: import('http').ServerResponse];\n [PluginHooks.RESPONSE]: [req: import('http').IncomingMessage, res: import('http').ServerResponse, duration: number];\n [PluginHooks.ROUTES_LOADED]: [routes: import('../types.js').RouteTree];\n [PluginHooks.BEFORE_RENDER]: [html: string, context: { route: import('../types.js').Route; config: import('../config.js').VelixConfig; isDev: boolean }];\n [PluginHooks.AFTER_RENDER]: [html: string, context: { route: import('../types.js').Route; config: import('../config.js').VelixConfig; isDev: boolean }];\n [PluginHooks.BUILD_START]: [];\n [PluginHooks.BUILD_END]: [stats: { time: number }];\n}\n\nexport interface VelixPluginDefinition {\n name: string;\n version?: string;\n setup?: (config: import('../config.js').VelixConfig) => void | Promise<void>;\n hooks?: { [K in PluginHook]?: (...args: PluginHookArgs[K]) => unknown };\n [key: string]: unknown; // Allow for Zod passthrough and extra properties\n}\n\n// ============================================================================\n// Plugin Manager\n// ============================================================================\n\nexport class PluginManager {\n private plugins: VelixPluginDefinition[] = [];\n private hooks: Map<string, Array<(...args: any[]) => any>> = new Map();\n\n /**\n * Register a plugin\n */\n register(plugin: VelixPluginDefinition) {\n this.plugins.push(plugin);\n\n // Register hooks\n if (plugin.hooks) {\n for (const [hookName, handler] of Object.entries(plugin.hooks)) {\n if (handler) {\n const existing = this.hooks.get(hookName) || [];\n existing.push(handler);\n this.hooks.set(hookName, existing);\n }\n }\n }\n }\n\n /**\n * Run a hook with arguments\n */\n async runHook<K extends PluginHook>(hookName: K, ...args: PluginHookArgs[K]): Promise<void> {\n const handlers = this.hooks.get(hookName) || [];\n for (const handler of handlers) {\n await handler(...args);\n }\n }\n\n /**\n * Run a waterfall hook — each handler transforms the first argument\n */\n async runWaterfallHook<K extends PluginHook>(hookName: K, value: PluginHookArgs[K][0], ...args: PluginHookArgs[K] extends [unknown, ...infer Rest] ? Rest : []): Promise<PluginHookArgs[K][0]> {\n const handlers = this.hooks.get(hookName) || [];\n let result = value;\n for (const handler of handlers) {\n const transformed = await handler(result, ...args);\n if (transformed !== undefined) result = transformed;\n }\n return result;\n }\n\n /**\n * Get all registered plugins\n */\n getPlugins(): VelixPluginDefinition[] {\n return [...this.plugins];\n }\n\n /**\n * Check if a plugin is registered\n */\n hasPlugin(name: string): boolean {\n return this.plugins.some(p => p.name === name);\n }\n}\n\n// ============================================================================\n// Global Instance\n// ============================================================================\n\nexport const pluginManager = new PluginManager();\n\n// ============================================================================\n// Plugin Loader\n// ============================================================================\n\n/**\n * Load plugins from project configuration\n */\nexport async function loadPlugins(projectRoot: string, config: { plugins?: unknown[] }): Promise<void> {\n const pluginEntries = config.plugins || [];\n\n for (const entry of pluginEntries) {\n try {\n if (typeof entry === 'string') {\n // Load plugin by name (from plugins/ dir or node_modules)\n const localPath = path.join(projectRoot, 'plugins', entry + '.ts');\n const localPathJs = path.join(projectRoot, 'plugins', entry + '.js');\n const localPathDir = path.join(projectRoot, 'plugins', entry, 'index.ts');\n\n let pluginPath: string | null = null;\n if (fs.existsSync(localPath)) pluginPath = localPath;\n else if (fs.existsSync(localPathJs)) pluginPath = localPathJs;\n else if (fs.existsSync(localPathDir)) pluginPath = localPathDir;\n\n if (pluginPath) {\n const url = pathToFileURL(pluginPath).href;\n const mod = await import(`${url}?t=${Date.now()}`);\n const plugin = mod.default || mod;\n if (plugin.name) {\n pluginManager.register(plugin);\n }\n } else {\n // Try node_modules\n try {\n const mod = await import(entry);\n const plugin = mod.default || mod;\n if (plugin.name) pluginManager.register(plugin);\n } catch {\n console.warn(`⚠ Plugin not found: ${entry}`);\n }\n }\n } else if (typeof entry === 'object' && entry !== null && 'name' in entry) {\n // Inline plugin definition\n pluginManager.register(entry as VelixPluginDefinition);\n }\n } catch (err: unknown) {\n const error = err as Error;\n console.warn(`⚠ Failed to load plugin: ${error?.message || String(error)}`);\n }\n }\n}\n\n// ============================================================================\n// Plugin Definition Helper\n// ============================================================================\n\n/**\n * Helper to define a Velix plugin with type safety.\n *\n * @example\n * ```ts\n * export default definePlugin({\n * name: 'my-plugin',\n * hooks: {\n * 'server:start': (server) => {\n * console.log('Server started!');\n * }\n * }\n * });\n * ```\n */\nexport function definePlugin(definition: VelixPluginDefinition): VelixPluginDefinition {\n return definition;\n}\n\n// ============================================================================\n// Built-in Plugins\n// ============================================================================\n\nexport const builtinPlugins = {\n /**\n * Security headers plugin\n */\n security: definePlugin({\n name: 'velix:security',\n hooks: {\n [PluginHooks.RESPONSE]: (_req: unknown, res: unknown) => {\n const response = res as import('http').ServerResponse;\n if (!response.headersSent) {\n response.setHeader('X-Content-Type-Options', 'nosniff');\n response.setHeader('X-Frame-Options', 'DENY');\n response.setHeader('X-XSS-Protection', '1; mode=block');\n }\n }\n }\n }),\n\n /**\n * Request logging plugin\n */\n logger: definePlugin({\n name: 'velix:logger',\n hooks: {\n [PluginHooks.RESPONSE]: (req: unknown, _res: unknown, duration: unknown) => {\n const request = req as import('http').IncomingMessage;\n console.log(` ${request.method} ${request.url} ${duration}ms`);\n }\n }\n }),\n};\n","/**\n * Velix v5 — Build Script\n * Build the application for production\n */\n\nimport { build } from '../build/index.js';\nimport logger from '../logger.js';\n\nbuild().catch(err => {\n logger.error('Build failed', err);\n process.exit(1);\n});\n"],"mappings":";AAKA,OAAO,aAAa;AACpB,OAAOA,SAAQ;AACf,OAAOC,WAAU;;;ACFjB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAC9B,SAAS,SAAS;AAClB,OAAO,QAAQ;AAMf,IAAM,kBAAkB,EAAE,OAAO;AAAA,EAC/B,MAAM,EAAE,OAAO,EAAE,QAAQ,WAAW;AAAA,EACpC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AACjC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAEb,IAAM,qBAAqB,EAAE,OAAO;AAAA,EAClC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,KAAK,EAAE,QAAQ,GAAI;AAAA,EAC/C,MAAM,EAAE,OAAO,EAAE,QAAQ,WAAW;AACtC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAEb,IAAM,sBAAsB,EAAE,OAAO;AAAA,EACnC,eAAe,EAAE,QAAQ,EAAE,QAAQ,KAAK;AAC1C,CAAC,EAAE,QAAQ,CAAC,CAAC;AAEb,IAAM,kBAAkB,EAAE,OAAO;AAAA,EAC/B,SAAS,EAAE,QAAQ,EAAE,QAAQ,IAAI;AAAA,EACjC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,IAAI;AAAA,EAChC,WAA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