@lolyjs/core 0.2.0-alpha.32 → 0.2.0-alpha.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -9871,7 +9871,7 @@ var require_built3 = __commonJS({
9871
9871
  });
9872
9872
 
9873
9873
  // modules/cli/index.ts
9874
- import path30 from "path";
9874
+ import path31 from "path";
9875
9875
  import process2 from "process";
9876
9876
 
9877
9877
  // modules/router/loader-pages.ts
@@ -12399,7 +12399,7 @@ function buildClientBundle(projectRoot) {
12399
12399
  }
12400
12400
 
12401
12401
  // modules/build/ssg/builder.ts
12402
- import path21 from "path";
12402
+ import path22 from "path";
12403
12403
 
12404
12404
  // modules/build/ssg/path.ts
12405
12405
  import path15 from "path";
@@ -12435,8 +12435,8 @@ function pathToOutDir(baseDir, urlPath) {
12435
12435
  }
12436
12436
 
12437
12437
  // modules/build/ssg/renderer.ts
12438
- import fs16 from "fs";
12439
- import path20 from "path";
12438
+ import fs17 from "fs";
12439
+ import path21 from "path";
12440
12440
  import { renderToString } from "react-dom/server";
12441
12441
 
12442
12442
  // modules/rendering/createDocumentTree/index.ts
@@ -12991,12 +12991,12 @@ var DEFAULT_IGNORED_PATHS = [
12991
12991
  /^\/sockjs-node/
12992
12992
  // Hot reload websocket
12993
12993
  ];
12994
- function shouldIgnorePath(path31, ignoredPaths) {
12994
+ function shouldIgnorePath(path32, ignoredPaths) {
12995
12995
  return ignoredPaths.some((pattern) => {
12996
12996
  if (typeof pattern === "string") {
12997
- return path31 === pattern || path31.startsWith(pattern);
12997
+ return path32 === pattern || path32.startsWith(pattern);
12998
12998
  }
12999
- return pattern.test(path31);
12999
+ return pattern.test(path32);
13000
13000
  });
13001
13001
  }
13002
13002
  function requestLoggerMiddleware(options = {}) {
@@ -13166,25 +13166,89 @@ function handleNotFound(res, urlPath) {
13166
13166
  }
13167
13167
  }
13168
13168
 
13169
- // modules/server/handlers/ssg.ts
13170
- import fs15 from "fs";
13169
+ // modules/server/global-middleware.ts
13171
13170
  import path18 from "path";
13171
+ import fs15 from "fs";
13172
+ var cachedGlobalMiddlewares = null;
13173
+ async function loadGlobalMiddlewares(projectRoot) {
13174
+ if (cachedGlobalMiddlewares !== null) {
13175
+ return cachedGlobalMiddlewares;
13176
+ }
13177
+ const globalMiddlewareFile = path18.join(projectRoot, "global.middleware.ts");
13178
+ const globalMiddlewareFileJs = path18.join(projectRoot, "global.middleware.js");
13179
+ const file = fs15.existsSync(globalMiddlewareFile) ? globalMiddlewareFile : fs15.existsSync(globalMiddlewareFileJs) ? globalMiddlewareFileJs : null;
13180
+ if (!file) {
13181
+ cachedGlobalMiddlewares = [];
13182
+ return cachedGlobalMiddlewares;
13183
+ }
13184
+ if (file.endsWith(".ts") || file.endsWith(".tsx")) {
13185
+ try {
13186
+ __require("tsx/cjs");
13187
+ } catch (e) {
13188
+ }
13189
+ }
13190
+ try {
13191
+ const mod = __require(file);
13192
+ const middlewares = mod?.globalMiddlewares;
13193
+ if (Array.isArray(middlewares)) {
13194
+ const validMiddlewares = [];
13195
+ for (let i = 0; i < middlewares.length; i++) {
13196
+ const mw = middlewares[i];
13197
+ if (typeof mw === "function") {
13198
+ validMiddlewares.push(mw);
13199
+ } else {
13200
+ console.warn(
13201
+ `[framework][global-middleware] Middleware at index ${i} in global.middleware.ts is not a function, skipping`
13202
+ );
13203
+ }
13204
+ }
13205
+ cachedGlobalMiddlewares = validMiddlewares;
13206
+ return cachedGlobalMiddlewares;
13207
+ } else if (middlewares !== void 0) {
13208
+ console.warn(
13209
+ "[framework][global-middleware] globalMiddlewares must be an array in global.middleware.ts, ignoring invalid value"
13210
+ );
13211
+ }
13212
+ } catch (error) {
13213
+ console.error("[framework][global-middleware] Error loading global.middleware.ts:", error);
13214
+ }
13215
+ cachedGlobalMiddlewares = [];
13216
+ return cachedGlobalMiddlewares;
13217
+ }
13218
+ async function runGlobalMiddlewares(ctx, globalMiddlewares) {
13219
+ for (const mw of globalMiddlewares) {
13220
+ try {
13221
+ await Promise.resolve(mw(ctx, async () => {
13222
+ }));
13223
+ } catch (error) {
13224
+ console.error("[framework][global-middleware] Error in global middleware:", error);
13225
+ continue;
13226
+ }
13227
+ if (ctx.res.headersSent) {
13228
+ return;
13229
+ }
13230
+ }
13231
+ }
13232
+
13233
+ // modules/server/handlers/ssg.ts
13234
+ import fs16 from "fs";
13235
+ import path19 from "path";
13172
13236
  var logger2 = createModuleLogger("ssg");
13173
13237
  function getSsgDirForPath(baseDir, urlPath) {
13174
13238
  const clean = urlPath === "/" ? "" : urlPath.replace(/^\/+/, "");
13175
- return path18.join(baseDir, clean);
13239
+ return path19.join(baseDir, clean);
13176
13240
  }
13177
13241
  function getSsgHtmlPath(baseDir, urlPath) {
13178
13242
  const dir = getSsgDirForPath(baseDir, urlPath);
13179
- return path18.join(dir, "index.html");
13243
+ return path19.join(dir, "index.html");
13180
13244
  }
13181
13245
  function getSsgDataPath(baseDir, urlPath) {
13182
13246
  const dir = getSsgDirForPath(baseDir, urlPath);
13183
- return path18.join(dir, "data.json");
13247
+ return path19.join(dir, "data.json");
13184
13248
  }
13185
13249
  function tryServeSsgHtml(res, ssgOutDir, urlPath) {
13186
13250
  const ssgHtmlPath = getSsgHtmlPath(ssgOutDir, urlPath);
13187
- if (!fs15.existsSync(ssgHtmlPath)) {
13251
+ if (!fs16.existsSync(ssgHtmlPath)) {
13188
13252
  return false;
13189
13253
  }
13190
13254
  logger2.info("Serving SSG HTML", { urlPath, ssgHtmlPath });
@@ -13194,17 +13258,17 @@ function tryServeSsgHtml(res, ssgOutDir, urlPath) {
13194
13258
  );
13195
13259
  res.statusCode = 200;
13196
13260
  res.setHeader("Content-Type", "text/html; charset=utf-8");
13197
- const stream = fs15.createReadStream(ssgHtmlPath, { encoding: "utf-8" });
13261
+ const stream = fs16.createReadStream(ssgHtmlPath, { encoding: "utf-8" });
13198
13262
  stream.pipe(res);
13199
13263
  return true;
13200
13264
  }
13201
13265
  function tryServeSsgData(res, ssgOutDir, urlPath) {
13202
13266
  const ssgDataPath = getSsgDataPath(ssgOutDir, urlPath);
13203
- if (!fs15.existsSync(ssgDataPath)) {
13267
+ if (!fs16.existsSync(ssgDataPath)) {
13204
13268
  return false;
13205
13269
  }
13206
13270
  try {
13207
- const raw = fs15.readFileSync(ssgDataPath, "utf-8");
13271
+ const raw = fs16.readFileSync(ssgDataPath, "utf-8");
13208
13272
  res.setHeader("Content-Type", "application/json; charset=utf-8");
13209
13273
  res.status(200).end(raw);
13210
13274
  return true;
@@ -13270,7 +13334,7 @@ function sanitizeQuery(query) {
13270
13334
  }
13271
13335
 
13272
13336
  // modules/server/handlers/pages.ts
13273
- import path19 from "path";
13337
+ import path20 from "path";
13274
13338
  function mergeMetadata(base, override) {
13275
13339
  if (!base && !override) return null;
13276
13340
  if (!base) return override;
@@ -13328,7 +13392,7 @@ async function renderNotFoundPage(notFoundPage, req, res, urlPath, finalUrlPath,
13328
13392
  } catch (error) {
13329
13393
  const reqLogger = getRequestLogger(req);
13330
13394
  const layoutFile = notFoundPage.layoutFiles[i];
13331
- const relativeLayoutPath = layoutFile ? path19.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
13395
+ const relativeLayoutPath = layoutFile ? path20.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
13332
13396
  reqLogger.error("Layout middleware failed for not-found page", error instanceof Error ? error : new Error(String(error)), {
13333
13397
  layoutIndex: i,
13334
13398
  layoutFile: relativeLayoutPath
@@ -13357,7 +13421,7 @@ async function renderNotFoundPage(notFoundPage, req, res, urlPath, finalUrlPath,
13357
13421
  } catch (error) {
13358
13422
  const reqLogger = getRequestLogger(req);
13359
13423
  const layoutFile = notFoundPage.layoutFiles[i];
13360
- const relativeLayoutPath = layoutFile ? path19.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
13424
+ const relativeLayoutPath = layoutFile ? path20.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
13361
13425
  reqLogger.warn("Layout server hook failed for not-found page", {
13362
13426
  error: error instanceof Error ? error.message : String(error),
13363
13427
  stack: error instanceof Error ? error.stack : void 0,
@@ -13594,6 +13658,11 @@ async function handlePageRequestInternal(options) {
13594
13658
  Redirect: (destination, permanent = false) => new RedirectResponse(destination, permanent),
13595
13659
  NotFound: () => new NotFoundResponse()
13596
13660
  };
13661
+ const globalMiddlewares = await loadGlobalMiddlewares(projectRoot || process.cwd());
13662
+ await runGlobalMiddlewares(ctx, globalMiddlewares);
13663
+ if (res.headersSent) {
13664
+ return;
13665
+ }
13597
13666
  await runRouteMiddlewares(route, ctx);
13598
13667
  if (res.headersSent) {
13599
13668
  return;
@@ -13614,7 +13683,7 @@ async function handlePageRequestInternal(options) {
13614
13683
  );
13615
13684
  } catch (error) {
13616
13685
  const layoutFile = route.layoutFiles[i];
13617
- const relativeLayoutPath = layoutFile ? path19.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
13686
+ const relativeLayoutPath = layoutFile ? path20.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
13618
13687
  reqLogger.error("Layout middleware failed", error instanceof Error ? error : new Error(String(error)), {
13619
13688
  route: route.pattern,
13620
13689
  layoutIndex: i,
@@ -13680,7 +13749,7 @@ async function handlePageRequestInternal(options) {
13680
13749
  }
13681
13750
  } catch (error) {
13682
13751
  const layoutFile = route.layoutFiles[i];
13683
- const relativeLayoutPath = layoutFile ? path19.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
13752
+ const relativeLayoutPath = layoutFile ? path20.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
13684
13753
  reqLogger.warn("Layout server hook failed", {
13685
13754
  error: error instanceof Error ? error.message : String(error),
13686
13755
  stack: error instanceof Error ? error.stack : void 0,
@@ -13743,7 +13812,7 @@ async function handlePageRequestInternal(options) {
13743
13812
  pageLoaderResult2.theme = theme;
13744
13813
  }
13745
13814
  } catch (error) {
13746
- const relativePagePath = route.pageFile ? path19.relative(projectRoot || process.cwd(), route.pageFile) : "unknown";
13815
+ const relativePagePath = route.pageFile ? path20.relative(projectRoot || process.cwd(), route.pageFile) : "unknown";
13747
13816
  reqLogger.error("Page server hook failed", {
13748
13817
  error: error instanceof Error ? error.message : String(error),
13749
13818
  stack: error instanceof Error ? error.stack : void 0,
@@ -13913,7 +13982,7 @@ async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks
13913
13982
  );
13914
13983
  } catch (error2) {
13915
13984
  const layoutFile = errorPage.layoutFiles[i];
13916
- const relativeLayoutPath = layoutFile ? path19.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
13985
+ const relativeLayoutPath = layoutFile ? path20.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
13917
13986
  reqLogger.error("Layout middleware failed for error page", error2 instanceof Error ? error2 : new Error(String(error2)), {
13918
13987
  layoutIndex: i,
13919
13988
  layoutFile: relativeLayoutPath
@@ -13953,7 +14022,7 @@ async function renderErrorPageWithStream(errorPage, req, res, error, routeChunks
13953
14022
  }
13954
14023
  } catch (err) {
13955
14024
  const layoutFile = errorPage.layoutFiles[i];
13956
- const relativeLayoutPath = layoutFile ? path19.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
14025
+ const relativeLayoutPath = layoutFile ? path20.relative(projectRoot || process.cwd(), layoutFile) : "unknown";
13957
14026
  reqLogger.warn("Layout server hook failed for error page", {
13958
14027
  error: err instanceof Error ? err.message : String(err),
13959
14028
  stack: err instanceof Error ? err.stack : void 0,
@@ -14249,16 +14318,16 @@ async function renderStaticRoute(projectRoot, ssgOutDir, route, urlPath, params,
14249
14318
  const html = "<!DOCTYPE html>" + renderToString(documentTree);
14250
14319
  const dir = pathToOutDir(ssgOutDir, urlPath);
14251
14320
  ensureDir(dir);
14252
- const htmlFile = path20.join(dir, "index.html");
14253
- const dataFile = path20.join(dir, "data.json");
14254
- fs16.writeFileSync(htmlFile, html, "utf-8");
14255
- fs16.writeFileSync(dataFile, JSON.stringify(initialData, null, 2), "utf-8");
14321
+ const htmlFile = path21.join(dir, "index.html");
14322
+ const dataFile = path21.join(dir, "data.json");
14323
+ fs17.writeFileSync(htmlFile, html, "utf-8");
14324
+ fs17.writeFileSync(dataFile, JSON.stringify(initialData, null, 2), "utf-8");
14256
14325
  }
14257
14326
 
14258
14327
  // modules/build/ssg/builder.ts
14259
14328
  init_globals();
14260
14329
  async function buildStaticPages(projectRoot, routes, config) {
14261
- const ssgOutDir = path21.join(projectRoot, BUILD_FOLDER_NAME, "ssg");
14330
+ const ssgOutDir = path22.join(projectRoot, BUILD_FOLDER_NAME, "ssg");
14262
14331
  ensureDir(ssgOutDir);
14263
14332
  for (const route of routes) {
14264
14333
  if (route.dynamic !== "force-static") continue;
@@ -14313,27 +14382,27 @@ async function buildStaticPages(projectRoot, routes, config) {
14313
14382
  }
14314
14383
 
14315
14384
  // modules/build/bundler/server.ts
14316
- import path23 from "path";
14317
- import fs18 from "fs";
14385
+ import path24 from "path";
14386
+ import fs19 from "fs";
14318
14387
  import esbuild from "esbuild";
14319
14388
 
14320
14389
  // modules/server/utils/server-dir.ts
14321
14390
  init_globals();
14322
- import fs17 from "fs";
14323
- import path22 from "path";
14391
+ import fs18 from "fs";
14392
+ import path23 from "path";
14324
14393
  var getServerFile = async (projectRoot, fileName) => {
14325
- const fileTS = path22.join(projectRoot, `${fileName}.ts`);
14326
- const fileJS = path22.join(projectRoot, BUILD_FOLDER_NAME, "server", `${fileName}.js`);
14394
+ const fileTS = path23.join(projectRoot, `${fileName}.ts`);
14395
+ const fileJS = path23.join(projectRoot, BUILD_FOLDER_NAME, "server", `${fileName}.js`);
14327
14396
  const isDev = process.env.NODE_ENV === "development";
14328
14397
  let mod = null;
14329
14398
  if (isDev) {
14330
- if (!fs17.existsSync(fileTS)) {
14399
+ if (!fs18.existsSync(fileTS)) {
14331
14400
  return null;
14332
14401
  }
14333
14402
  __require("tsx/cjs");
14334
14403
  mod = __require(fileTS);
14335
14404
  } else {
14336
- if (!fs17.existsSync(fileJS)) {
14405
+ if (!fs18.existsSync(fileJS)) {
14337
14406
  return null;
14338
14407
  }
14339
14408
  mod = __require(fileJS);
@@ -14515,29 +14584,29 @@ init_globals();
14515
14584
  var SERVER_FILES = [INIT_FILE_NAME, CONFIG_FILE_NAME];
14516
14585
  function createPathAliasPlugin(projectRoot, outDir) {
14517
14586
  const aliases = loadAliasesFromTsconfig(projectRoot);
14518
- const tsconfigPath = path23.join(projectRoot, "tsconfig.json");
14587
+ const tsconfigPath = path24.join(projectRoot, "tsconfig.json");
14519
14588
  let baseUrl = ".";
14520
- if (fs18.existsSync(tsconfigPath)) {
14589
+ if (fs19.existsSync(tsconfigPath)) {
14521
14590
  try {
14522
- const tsconfig = JSON.parse(fs18.readFileSync(tsconfigPath, "utf-8"));
14591
+ const tsconfig = JSON.parse(fs19.readFileSync(tsconfigPath, "utf-8"));
14523
14592
  baseUrl = tsconfig.compilerOptions?.baseUrl ?? ".";
14524
14593
  } catch {
14525
14594
  }
14526
14595
  }
14527
14596
  function resolveAliasToRelative(importPath, sourceFile) {
14528
- if (importPath.startsWith(".") || importPath.startsWith("/") || path23.isAbsolute(importPath) || importPath.includes("node_modules")) {
14597
+ if (importPath.startsWith(".") || importPath.startsWith("/") || path24.isAbsolute(importPath) || importPath.includes("node_modules")) {
14529
14598
  return null;
14530
14599
  }
14531
14600
  for (const [aliasKey, aliasPath] of Object.entries(aliases)) {
14532
14601
  if (importPath.startsWith(aliasKey + "/") || importPath === aliasKey) {
14533
14602
  const restPath = importPath.startsWith(aliasKey + "/") ? importPath.slice(aliasKey.length + 1) : "";
14534
- const resolvedPath = restPath ? path23.join(aliasPath, restPath) : aliasPath;
14603
+ const resolvedPath = restPath ? path24.join(aliasPath, restPath) : aliasPath;
14535
14604
  let actualPath = null;
14536
14605
  const extensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
14537
- if (fs18.existsSync(resolvedPath) && fs18.statSync(resolvedPath).isDirectory()) {
14606
+ if (fs19.existsSync(resolvedPath) && fs19.statSync(resolvedPath).isDirectory()) {
14538
14607
  for (const ext of extensions) {
14539
- const indexPath = path23.join(resolvedPath, `index${ext}`);
14540
- if (fs18.existsSync(indexPath)) {
14608
+ const indexPath = path24.join(resolvedPath, `index${ext}`);
14609
+ if (fs19.existsSync(indexPath)) {
14541
14610
  actualPath = indexPath;
14542
14611
  break;
14543
14612
  }
@@ -14545,20 +14614,20 @@ function createPathAliasPlugin(projectRoot, outDir) {
14545
14614
  } else {
14546
14615
  for (const ext of extensions) {
14547
14616
  const filePath = resolvedPath + ext;
14548
- if (fs18.existsSync(filePath)) {
14617
+ if (fs19.existsSync(filePath)) {
14549
14618
  actualPath = filePath;
14550
14619
  break;
14551
14620
  }
14552
14621
  }
14553
- if (!actualPath && fs18.existsSync(resolvedPath)) {
14622
+ if (!actualPath && fs19.existsSync(resolvedPath)) {
14554
14623
  actualPath = resolvedPath;
14555
14624
  }
14556
14625
  }
14557
14626
  if (actualPath) {
14558
- const relativePath = path23.relative(outDir, actualPath);
14627
+ const relativePath = path24.relative(outDir, actualPath);
14559
14628
  const normalizedPath = relativePath.replace(/\\/g, "/");
14560
14629
  const finalPath = normalizedPath.startsWith(".") ? normalizedPath : `./${normalizedPath}`;
14561
- const ext = path23.extname(finalPath);
14630
+ const ext = path24.extname(finalPath);
14562
14631
  const pathWithoutExt = ext === ".json" ? finalPath : finalPath.slice(0, -ext.length);
14563
14632
  return pathWithoutExt;
14564
14633
  }
@@ -14570,13 +14639,13 @@ function createPathAliasPlugin(projectRoot, outDir) {
14570
14639
  name: "path-alias-resolver",
14571
14640
  setup(build) {
14572
14641
  build.onLoad({ filter: /\.(ts|tsx|js|jsx)$/ }, (args) => {
14573
- const fileName = path23.basename(args.path);
14642
+ const fileName = path24.basename(args.path);
14574
14643
  const isServerFile = SERVER_FILES.some((f) => fileName === `${f}.ts` || fileName === `${f}.tsx` || fileName === `${f}.js` || fileName === `${f}.jsx`);
14575
- const isInProjectRoot = path23.dirname(args.path) === projectRoot;
14644
+ const isInProjectRoot = path24.dirname(args.path) === projectRoot;
14576
14645
  if (!isServerFile || !isInProjectRoot) {
14577
14646
  return null;
14578
14647
  }
14579
- const contents = fs18.readFileSync(args.path, "utf-8");
14648
+ const contents = fs19.readFileSync(args.path, "utf-8");
14580
14649
  let transformed = contents;
14581
14650
  const aliasPatterns = Object.keys(aliases).sort((a, b) => b.length - a.length);
14582
14651
  for (const aliasKey of aliasPatterns) {
@@ -14596,7 +14665,7 @@ function createPathAliasPlugin(projectRoot, outDir) {
14596
14665
  }
14597
14666
  return {
14598
14667
  contents: transformed,
14599
- loader: path23.extname(args.path).slice(1)
14668
+ loader: path24.extname(args.path).slice(1)
14600
14669
  };
14601
14670
  });
14602
14671
  build.onResolve({ filter: /.*/ }, (args) => {
@@ -14615,9 +14684,9 @@ function createPathAliasPlugin(projectRoot, outDir) {
14615
14684
  function collectAppSources(appDir) {
14616
14685
  const entries = [];
14617
14686
  function walk(dir) {
14618
- const items = fs18.readdirSync(dir, { withFileTypes: true });
14687
+ const items = fs19.readdirSync(dir, { withFileTypes: true });
14619
14688
  for (const item of items) {
14620
- const full = path23.join(dir, item.name);
14689
+ const full = path24.join(dir, item.name);
14621
14690
  if (item.isDirectory()) {
14622
14691
  walk(full);
14623
14692
  continue;
@@ -14634,7 +14703,7 @@ function collectAppSources(appDir) {
14634
14703
  return entries;
14635
14704
  }
14636
14705
  async function buildServerApp(projectRoot, appDir) {
14637
- const outDir = path23.join(projectRoot, BUILD_FOLDER_NAME, "server");
14706
+ const outDir = path24.join(projectRoot, BUILD_FOLDER_NAME, "server");
14638
14707
  const entryPoints = collectAppSources(appDir);
14639
14708
  ensureDir(outDir);
14640
14709
  if (entryPoints.length === 0) {
@@ -14652,14 +14721,14 @@ async function buildServerApp(projectRoot, appDir) {
14652
14721
  bundle: true,
14653
14722
  splitting: false,
14654
14723
  logLevel: "info",
14655
- tsconfig: path23.join(projectRoot, "tsconfig.json"),
14724
+ tsconfig: path24.join(projectRoot, "tsconfig.json"),
14656
14725
  packages: "external"
14657
14726
  });
14658
14727
  const pathAliasPlugin = createPathAliasPlugin(projectRoot, outDir);
14659
14728
  for (const fileName of SERVER_FILES) {
14660
- const initTS = path23.join(projectRoot, `${fileName}.ts`);
14661
- const initJS = path23.join(outDir, `${fileName}.js`);
14662
- if (fs18.existsSync(initTS)) {
14729
+ const initTS = path24.join(projectRoot, `${fileName}.ts`);
14730
+ const initJS = path24.join(outDir, `${fileName}.js`);
14731
+ if (fs19.existsSync(initTS)) {
14663
14732
  await esbuild.build({
14664
14733
  entryPoints: [initTS],
14665
14734
  outfile: initJS,
@@ -14670,7 +14739,7 @@ async function buildServerApp(projectRoot, appDir) {
14670
14739
  sourcemap: true,
14671
14740
  bundle: false,
14672
14741
  logLevel: "info",
14673
- tsconfig: path23.join(projectRoot, "tsconfig.json"),
14742
+ tsconfig: path24.join(projectRoot, "tsconfig.json"),
14674
14743
  plugins: [pathAliasPlugin]
14675
14744
  });
14676
14745
  }
@@ -14683,8 +14752,8 @@ init_globals();
14683
14752
 
14684
14753
  // src/config.ts
14685
14754
  init_globals();
14686
- import path24 from "path";
14687
- import fs19 from "fs";
14755
+ import path25 from "path";
14756
+ import fs20 from "fs";
14688
14757
  var DEFAULT_CONFIG2 = {
14689
14758
  directories: {
14690
14759
  app: "app",
@@ -14750,8 +14819,8 @@ function validateConfig(config, projectRoot) {
14750
14819
  if (!config.directories.app || typeof config.directories.app !== "string") {
14751
14820
  errors.push("config.directories.app must be a non-empty string");
14752
14821
  } else {
14753
- const appDir = path24.join(projectRoot, config.directories.app);
14754
- if (!fs19.existsSync(appDir) && process.env.NODE_ENV !== "test") {
14822
+ const appDir = path25.join(projectRoot, config.directories.app);
14823
+ if (!fs20.existsSync(appDir) && process.env.NODE_ENV !== "test") {
14755
14824
  errors.push(
14756
14825
  `App directory not found: ${config.directories.app}
14757
14826
  Expected at: ${appDir}
@@ -14855,17 +14924,17 @@ function validateConfig(config, projectRoot) {
14855
14924
  }
14856
14925
  function loadConfig(projectRoot) {
14857
14926
  const configFiles = [
14858
- path24.join(projectRoot, "loly.config.ts"),
14859
- path24.join(projectRoot, "loly.config.js"),
14860
- path24.join(projectRoot, "loly.config.json")
14927
+ path25.join(projectRoot, "loly.config.ts"),
14928
+ path25.join(projectRoot, "loly.config.js"),
14929
+ path25.join(projectRoot, "loly.config.json")
14861
14930
  ];
14862
14931
  let userConfig = {};
14863
14932
  let loadedConfigFile = null;
14864
14933
  for (const configFile of configFiles) {
14865
- if (fs19.existsSync(configFile)) {
14934
+ if (fs20.existsSync(configFile)) {
14866
14935
  try {
14867
14936
  if (configFile.endsWith(".json")) {
14868
- const content = fs19.readFileSync(configFile, "utf-8");
14937
+ const content = fs20.readFileSync(configFile, "utf-8");
14869
14938
  userConfig = JSON.parse(content);
14870
14939
  } else {
14871
14940
  if (process.env.NODE_ENV === "development") {
@@ -14874,12 +14943,12 @@ function loadConfig(projectRoot) {
14874
14943
  const mod = __require(configFile);
14875
14944
  userConfig = typeof mod.default === "function" ? mod.default(process.env.NODE_ENV) : mod.default || mod.config || mod;
14876
14945
  }
14877
- loadedConfigFile = path24.relative(projectRoot, configFile);
14946
+ loadedConfigFile = path25.relative(projectRoot, configFile);
14878
14947
  break;
14879
14948
  } catch (error) {
14880
14949
  const errorMessage = error instanceof Error ? error.message : String(error);
14881
14950
  throw new ConfigValidationError(
14882
- `Failed to load configuration from ${path24.relative(projectRoot, configFile)}:
14951
+ `Failed to load configuration from ${path25.relative(projectRoot, configFile)}:
14883
14952
  ${errorMessage}
14884
14953
  \u{1F4A1} Suggestion: Check that your config file exports a valid configuration object`
14885
14954
  );
@@ -14903,13 +14972,13 @@ ${error.message}`;
14903
14972
  return config;
14904
14973
  }
14905
14974
  function getAppDir(projectRoot, config) {
14906
- return path24.resolve(projectRoot, config.directories.app);
14975
+ return path25.resolve(projectRoot, config.directories.app);
14907
14976
  }
14908
14977
  function getBuildDir(projectRoot, config) {
14909
- return path24.join(projectRoot, config.directories.build);
14978
+ return path25.join(projectRoot, config.directories.build);
14910
14979
  }
14911
14980
  function getStaticDir(projectRoot, config) {
14912
- return path24.resolve(projectRoot, config.directories.static);
14981
+ return path25.resolve(projectRoot, config.directories.static);
14913
14982
  }
14914
14983
 
14915
14984
  // modules/build/index.ts
@@ -14962,13 +15031,13 @@ async function buildApp(options = {}) {
14962
15031
  }
14963
15032
 
14964
15033
  // src/server.ts
14965
- import fs21 from "fs";
14966
- import path29 from "path";
15034
+ import fs22 from "fs";
15035
+ import path30 from "path";
14967
15036
 
14968
15037
  // modules/server/setup.ts
14969
15038
  import express from "express";
14970
- import path27 from "path";
14971
- import fs20 from "fs";
15039
+ import path28 from "path";
15040
+ import fs21 from "fs";
14972
15041
 
14973
15042
  // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
14974
15043
  import { stat as statcb } from "fs";
@@ -15046,7 +15115,7 @@ var ReaddirpStream = class extends Readable {
15046
15115
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
15047
15116
  const statMethod = opts.lstat ? lstat : stat;
15048
15117
  if (wantBigintFsStats) {
15049
- this._stat = (path31) => statMethod(path31, { bigint: true });
15118
+ this._stat = (path32) => statMethod(path32, { bigint: true });
15050
15119
  } else {
15051
15120
  this._stat = statMethod;
15052
15121
  }
@@ -15071,8 +15140,8 @@ var ReaddirpStream = class extends Readable {
15071
15140
  const par = this.parent;
15072
15141
  const fil = par && par.files;
15073
15142
  if (fil && fil.length > 0) {
15074
- const { path: path31, depth } = par;
15075
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path31));
15143
+ const { path: path32, depth } = par;
15144
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path32));
15076
15145
  const awaited = await Promise.all(slice);
15077
15146
  for (const entry of awaited) {
15078
15147
  if (!entry)
@@ -15112,20 +15181,20 @@ var ReaddirpStream = class extends Readable {
15112
15181
  this.reading = false;
15113
15182
  }
15114
15183
  }
15115
- async _exploreDir(path31, depth) {
15184
+ async _exploreDir(path32, depth) {
15116
15185
  let files;
15117
15186
  try {
15118
- files = await readdir(path31, this._rdOptions);
15187
+ files = await readdir(path32, this._rdOptions);
15119
15188
  } catch (error) {
15120
15189
  this._onError(error);
15121
15190
  }
15122
- return { files, depth, path: path31 };
15191
+ return { files, depth, path: path32 };
15123
15192
  }
15124
- async _formatEntry(dirent, path31) {
15193
+ async _formatEntry(dirent, path32) {
15125
15194
  let entry;
15126
15195
  const basename3 = this._isDirent ? dirent.name : dirent;
15127
15196
  try {
15128
- const fullPath = presolve(pjoin(path31, basename3));
15197
+ const fullPath = presolve(pjoin(path32, basename3));
15129
15198
  entry = { path: prelative(this._root, fullPath), fullPath, basename: basename3 };
15130
15199
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
15131
15200
  } catch (err) {
@@ -15525,16 +15594,16 @@ var delFromSet = (main, prop, item) => {
15525
15594
  };
15526
15595
  var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
15527
15596
  var FsWatchInstances = /* @__PURE__ */ new Map();
15528
- function createFsWatchInstance(path31, options, listener, errHandler, emitRaw) {
15597
+ function createFsWatchInstance(path32, options, listener, errHandler, emitRaw) {
15529
15598
  const handleEvent = (rawEvent, evPath) => {
15530
- listener(path31);
15531
- emitRaw(rawEvent, evPath, { watchedPath: path31 });
15532
- if (evPath && path31 !== evPath) {
15533
- fsWatchBroadcast(sysPath.resolve(path31, evPath), KEY_LISTENERS, sysPath.join(path31, evPath));
15599
+ listener(path32);
15600
+ emitRaw(rawEvent, evPath, { watchedPath: path32 });
15601
+ if (evPath && path32 !== evPath) {
15602
+ fsWatchBroadcast(sysPath.resolve(path32, evPath), KEY_LISTENERS, sysPath.join(path32, evPath));
15534
15603
  }
15535
15604
  };
15536
15605
  try {
15537
- return fs_watch(path31, {
15606
+ return fs_watch(path32, {
15538
15607
  persistent: options.persistent
15539
15608
  }, handleEvent);
15540
15609
  } catch (error) {
@@ -15550,12 +15619,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
15550
15619
  listener(val1, val2, val3);
15551
15620
  });
15552
15621
  };
15553
- var setFsWatchListener = (path31, fullPath, options, handlers) => {
15622
+ var setFsWatchListener = (path32, fullPath, options, handlers) => {
15554
15623
  const { listener, errHandler, rawEmitter } = handlers;
15555
15624
  let cont = FsWatchInstances.get(fullPath);
15556
15625
  let watcher;
15557
15626
  if (!options.persistent) {
15558
- watcher = createFsWatchInstance(path31, options, listener, errHandler, rawEmitter);
15627
+ watcher = createFsWatchInstance(path32, options, listener, errHandler, rawEmitter);
15559
15628
  if (!watcher)
15560
15629
  return;
15561
15630
  return watcher.close.bind(watcher);
@@ -15566,7 +15635,7 @@ var setFsWatchListener = (path31, fullPath, options, handlers) => {
15566
15635
  addAndConvert(cont, KEY_RAW, rawEmitter);
15567
15636
  } else {
15568
15637
  watcher = createFsWatchInstance(
15569
- path31,
15638
+ path32,
15570
15639
  options,
15571
15640
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
15572
15641
  errHandler,
@@ -15581,7 +15650,7 @@ var setFsWatchListener = (path31, fullPath, options, handlers) => {
15581
15650
  cont.watcherUnusable = true;
15582
15651
  if (isWindows && error.code === "EPERM") {
15583
15652
  try {
15584
- const fd = await open(path31, "r");
15653
+ const fd = await open(path32, "r");
15585
15654
  await fd.close();
15586
15655
  broadcastErr(error);
15587
15656
  } catch (err) {
@@ -15612,7 +15681,7 @@ var setFsWatchListener = (path31, fullPath, options, handlers) => {
15612
15681
  };
15613
15682
  };
15614
15683
  var FsWatchFileInstances = /* @__PURE__ */ new Map();
15615
- var setFsWatchFileListener = (path31, fullPath, options, handlers) => {
15684
+ var setFsWatchFileListener = (path32, fullPath, options, handlers) => {
15616
15685
  const { listener, rawEmitter } = handlers;
15617
15686
  let cont = FsWatchFileInstances.get(fullPath);
15618
15687
  const copts = cont && cont.options;
@@ -15634,7 +15703,7 @@ var setFsWatchFileListener = (path31, fullPath, options, handlers) => {
15634
15703
  });
15635
15704
  const currmtime = curr.mtimeMs;
15636
15705
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
15637
- foreach(cont.listeners, (listener2) => listener2(path31, curr));
15706
+ foreach(cont.listeners, (listener2) => listener2(path32, curr));
15638
15707
  }
15639
15708
  })
15640
15709
  };
@@ -15662,13 +15731,13 @@ var NodeFsHandler = class {
15662
15731
  * @param listener on fs change
15663
15732
  * @returns closer for the watcher instance
15664
15733
  */
15665
- _watchWithNodeFs(path31, listener) {
15734
+ _watchWithNodeFs(path32, listener) {
15666
15735
  const opts = this.fsw.options;
15667
- const directory = sysPath.dirname(path31);
15668
- const basename3 = sysPath.basename(path31);
15736
+ const directory = sysPath.dirname(path32);
15737
+ const basename3 = sysPath.basename(path32);
15669
15738
  const parent = this.fsw._getWatchedDir(directory);
15670
15739
  parent.add(basename3);
15671
- const absolutePath = sysPath.resolve(path31);
15740
+ const absolutePath = sysPath.resolve(path32);
15672
15741
  const options = {
15673
15742
  persistent: opts.persistent
15674
15743
  };
@@ -15678,12 +15747,12 @@ var NodeFsHandler = class {
15678
15747
  if (opts.usePolling) {
15679
15748
  const enableBin = opts.interval !== opts.binaryInterval;
15680
15749
  options.interval = enableBin && isBinaryPath(basename3) ? opts.binaryInterval : opts.interval;
15681
- closer = setFsWatchFileListener(path31, absolutePath, options, {
15750
+ closer = setFsWatchFileListener(path32, absolutePath, options, {
15682
15751
  listener,
15683
15752
  rawEmitter: this.fsw._emitRaw
15684
15753
  });
15685
15754
  } else {
15686
- closer = setFsWatchListener(path31, absolutePath, options, {
15755
+ closer = setFsWatchListener(path32, absolutePath, options, {
15687
15756
  listener,
15688
15757
  errHandler: this._boundHandleError,
15689
15758
  rawEmitter: this.fsw._emitRaw
@@ -15705,7 +15774,7 @@ var NodeFsHandler = class {
15705
15774
  let prevStats = stats;
15706
15775
  if (parent.has(basename3))
15707
15776
  return;
15708
- const listener = async (path31, newStats) => {
15777
+ const listener = async (path32, newStats) => {
15709
15778
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
15710
15779
  return;
15711
15780
  if (!newStats || newStats.mtimeMs === 0) {
@@ -15719,11 +15788,11 @@ var NodeFsHandler = class {
15719
15788
  this.fsw._emit(EV.CHANGE, file, newStats2);
15720
15789
  }
15721
15790
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
15722
- this.fsw._closeFile(path31);
15791
+ this.fsw._closeFile(path32);
15723
15792
  prevStats = newStats2;
15724
15793
  const closer2 = this._watchWithNodeFs(file, listener);
15725
15794
  if (closer2)
15726
- this.fsw._addPathCloser(path31, closer2);
15795
+ this.fsw._addPathCloser(path32, closer2);
15727
15796
  } else {
15728
15797
  prevStats = newStats2;
15729
15798
  }
@@ -15755,7 +15824,7 @@ var NodeFsHandler = class {
15755
15824
  * @param item basename of this item
15756
15825
  * @returns true if no more processing is needed for this entry.
15757
15826
  */
15758
- async _handleSymlink(entry, directory, path31, item) {
15827
+ async _handleSymlink(entry, directory, path32, item) {
15759
15828
  if (this.fsw.closed) {
15760
15829
  return;
15761
15830
  }
@@ -15765,7 +15834,7 @@ var NodeFsHandler = class {
15765
15834
  this.fsw._incrReadyCount();
15766
15835
  let linkPath;
15767
15836
  try {
15768
- linkPath = await fsrealpath(path31);
15837
+ linkPath = await fsrealpath(path32);
15769
15838
  } catch (e) {
15770
15839
  this.fsw._emitReady();
15771
15840
  return true;
@@ -15775,12 +15844,12 @@ var NodeFsHandler = class {
15775
15844
  if (dir.has(item)) {
15776
15845
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
15777
15846
  this.fsw._symlinkPaths.set(full, linkPath);
15778
- this.fsw._emit(EV.CHANGE, path31, entry.stats);
15847
+ this.fsw._emit(EV.CHANGE, path32, entry.stats);
15779
15848
  }
15780
15849
  } else {
15781
15850
  dir.add(item);
15782
15851
  this.fsw._symlinkPaths.set(full, linkPath);
15783
- this.fsw._emit(EV.ADD, path31, entry.stats);
15852
+ this.fsw._emit(EV.ADD, path32, entry.stats);
15784
15853
  }
15785
15854
  this.fsw._emitReady();
15786
15855
  return true;
@@ -15809,9 +15878,9 @@ var NodeFsHandler = class {
15809
15878
  return;
15810
15879
  }
15811
15880
  const item = entry.path;
15812
- let path31 = sysPath.join(directory, item);
15881
+ let path32 = sysPath.join(directory, item);
15813
15882
  current.add(item);
15814
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path31, item)) {
15883
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path32, item)) {
15815
15884
  return;
15816
15885
  }
15817
15886
  if (this.fsw.closed) {
@@ -15820,8 +15889,8 @@ var NodeFsHandler = class {
15820
15889
  }
15821
15890
  if (item === target || !target && !previous.has(item)) {
15822
15891
  this.fsw._incrReadyCount();
15823
- path31 = sysPath.join(dir, sysPath.relative(dir, path31));
15824
- this._addToNodeFs(path31, initialAdd, wh, depth + 1);
15892
+ path32 = sysPath.join(dir, sysPath.relative(dir, path32));
15893
+ this._addToNodeFs(path32, initialAdd, wh, depth + 1);
15825
15894
  }
15826
15895
  }).on(EV.ERROR, this._boundHandleError);
15827
15896
  return new Promise((resolve3, reject) => {
@@ -15890,13 +15959,13 @@ var NodeFsHandler = class {
15890
15959
  * @param depth Child path actually targeted for watch
15891
15960
  * @param target Child path actually targeted for watch
15892
15961
  */
15893
- async _addToNodeFs(path31, initialAdd, priorWh, depth, target) {
15962
+ async _addToNodeFs(path32, initialAdd, priorWh, depth, target) {
15894
15963
  const ready = this.fsw._emitReady;
15895
- if (this.fsw._isIgnored(path31) || this.fsw.closed) {
15964
+ if (this.fsw._isIgnored(path32) || this.fsw.closed) {
15896
15965
  ready();
15897
15966
  return false;
15898
15967
  }
15899
- const wh = this.fsw._getWatchHelpers(path31);
15968
+ const wh = this.fsw._getWatchHelpers(path32);
15900
15969
  if (priorWh) {
15901
15970
  wh.filterPath = (entry) => priorWh.filterPath(entry);
15902
15971
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -15912,8 +15981,8 @@ var NodeFsHandler = class {
15912
15981
  const follow = this.fsw.options.followSymlinks;
15913
15982
  let closer;
15914
15983
  if (stats.isDirectory()) {
15915
- const absPath = sysPath.resolve(path31);
15916
- const targetPath = follow ? await fsrealpath(path31) : path31;
15984
+ const absPath = sysPath.resolve(path32);
15985
+ const targetPath = follow ? await fsrealpath(path32) : path32;
15917
15986
  if (this.fsw.closed)
15918
15987
  return;
15919
15988
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -15923,29 +15992,29 @@ var NodeFsHandler = class {
15923
15992
  this.fsw._symlinkPaths.set(absPath, targetPath);
15924
15993
  }
15925
15994
  } else if (stats.isSymbolicLink()) {
15926
- const targetPath = follow ? await fsrealpath(path31) : path31;
15995
+ const targetPath = follow ? await fsrealpath(path32) : path32;
15927
15996
  if (this.fsw.closed)
15928
15997
  return;
15929
15998
  const parent = sysPath.dirname(wh.watchPath);
15930
15999
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
15931
16000
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
15932
- closer = await this._handleDir(parent, stats, initialAdd, depth, path31, wh, targetPath);
16001
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path32, wh, targetPath);
15933
16002
  if (this.fsw.closed)
15934
16003
  return;
15935
16004
  if (targetPath !== void 0) {
15936
- this.fsw._symlinkPaths.set(sysPath.resolve(path31), targetPath);
16005
+ this.fsw._symlinkPaths.set(sysPath.resolve(path32), targetPath);
15937
16006
  }
15938
16007
  } else {
15939
16008
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
15940
16009
  }
15941
16010
  ready();
15942
16011
  if (closer)
15943
- this.fsw._addPathCloser(path31, closer);
16012
+ this.fsw._addPathCloser(path32, closer);
15944
16013
  return false;
15945
16014
  } catch (error) {
15946
16015
  if (this.fsw._handleError(error)) {
15947
16016
  ready();
15948
- return path31;
16017
+ return path32;
15949
16018
  }
15950
16019
  }
15951
16020
  }
@@ -15988,26 +16057,26 @@ function createPattern(matcher) {
15988
16057
  }
15989
16058
  return () => false;
15990
16059
  }
15991
- function normalizePath(path31) {
15992
- if (typeof path31 !== "string")
16060
+ function normalizePath(path32) {
16061
+ if (typeof path32 !== "string")
15993
16062
  throw new Error("string expected");
15994
- path31 = sysPath2.normalize(path31);
15995
- path31 = path31.replace(/\\/g, "/");
16063
+ path32 = sysPath2.normalize(path32);
16064
+ path32 = path32.replace(/\\/g, "/");
15996
16065
  let prepend = false;
15997
- if (path31.startsWith("//"))
16066
+ if (path32.startsWith("//"))
15998
16067
  prepend = true;
15999
16068
  const DOUBLE_SLASH_RE2 = /\/\//;
16000
- while (path31.match(DOUBLE_SLASH_RE2))
16001
- path31 = path31.replace(DOUBLE_SLASH_RE2, "/");
16069
+ while (path32.match(DOUBLE_SLASH_RE2))
16070
+ path32 = path32.replace(DOUBLE_SLASH_RE2, "/");
16002
16071
  if (prepend)
16003
- path31 = "/" + path31;
16004
- return path31;
16072
+ path32 = "/" + path32;
16073
+ return path32;
16005
16074
  }
16006
16075
  function matchPatterns(patterns, testString, stats) {
16007
- const path31 = normalizePath(testString);
16076
+ const path32 = normalizePath(testString);
16008
16077
  for (let index = 0; index < patterns.length; index++) {
16009
16078
  const pattern = patterns[index];
16010
- if (pattern(path31, stats)) {
16079
+ if (pattern(path32, stats)) {
16011
16080
  return true;
16012
16081
  }
16013
16082
  }
@@ -16047,19 +16116,19 @@ var toUnix = (string) => {
16047
16116
  }
16048
16117
  return str;
16049
16118
  };
16050
- var normalizePathToUnix = (path31) => toUnix(sysPath2.normalize(toUnix(path31)));
16051
- var normalizeIgnored = (cwd = "") => (path31) => {
16052
- if (typeof path31 === "string") {
16053
- return normalizePathToUnix(sysPath2.isAbsolute(path31) ? path31 : sysPath2.join(cwd, path31));
16119
+ var normalizePathToUnix = (path32) => toUnix(sysPath2.normalize(toUnix(path32)));
16120
+ var normalizeIgnored = (cwd = "") => (path32) => {
16121
+ if (typeof path32 === "string") {
16122
+ return normalizePathToUnix(sysPath2.isAbsolute(path32) ? path32 : sysPath2.join(cwd, path32));
16054
16123
  } else {
16055
- return path31;
16124
+ return path32;
16056
16125
  }
16057
16126
  };
16058
- var getAbsolutePath = (path31, cwd) => {
16059
- if (sysPath2.isAbsolute(path31)) {
16060
- return path31;
16127
+ var getAbsolutePath = (path32, cwd) => {
16128
+ if (sysPath2.isAbsolute(path32)) {
16129
+ return path32;
16061
16130
  }
16062
- return sysPath2.join(cwd, path31);
16131
+ return sysPath2.join(cwd, path32);
16063
16132
  };
16064
16133
  var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
16065
16134
  var DirEntry = class {
@@ -16114,10 +16183,10 @@ var DirEntry = class {
16114
16183
  var STAT_METHOD_F = "stat";
16115
16184
  var STAT_METHOD_L = "lstat";
16116
16185
  var WatchHelper = class {
16117
- constructor(path31, follow, fsw) {
16186
+ constructor(path32, follow, fsw) {
16118
16187
  this.fsw = fsw;
16119
- const watchPath = path31;
16120
- this.path = path31 = path31.replace(REPLACER_RE, "");
16188
+ const watchPath = path32;
16189
+ this.path = path32 = path32.replace(REPLACER_RE, "");
16121
16190
  this.watchPath = watchPath;
16122
16191
  this.fullWatchPath = sysPath2.resolve(watchPath);
16123
16192
  this.dirParts = [];
@@ -16239,20 +16308,20 @@ var FSWatcher = class extends EventEmitter {
16239
16308
  this._closePromise = void 0;
16240
16309
  let paths = unifyPaths(paths_);
16241
16310
  if (cwd) {
16242
- paths = paths.map((path31) => {
16243
- const absPath = getAbsolutePath(path31, cwd);
16311
+ paths = paths.map((path32) => {
16312
+ const absPath = getAbsolutePath(path32, cwd);
16244
16313
  return absPath;
16245
16314
  });
16246
16315
  }
16247
- paths.forEach((path31) => {
16248
- this._removeIgnoredPath(path31);
16316
+ paths.forEach((path32) => {
16317
+ this._removeIgnoredPath(path32);
16249
16318
  });
16250
16319
  this._userIgnored = void 0;
16251
16320
  if (!this._readyCount)
16252
16321
  this._readyCount = 0;
16253
16322
  this._readyCount += paths.length;
16254
- Promise.all(paths.map(async (path31) => {
16255
- const res = await this._nodeFsHandler._addToNodeFs(path31, !_internal, void 0, 0, _origAdd);
16323
+ Promise.all(paths.map(async (path32) => {
16324
+ const res = await this._nodeFsHandler._addToNodeFs(path32, !_internal, void 0, 0, _origAdd);
16256
16325
  if (res)
16257
16326
  this._emitReady();
16258
16327
  return res;
@@ -16274,17 +16343,17 @@ var FSWatcher = class extends EventEmitter {
16274
16343
  return this;
16275
16344
  const paths = unifyPaths(paths_);
16276
16345
  const { cwd } = this.options;
16277
- paths.forEach((path31) => {
16278
- if (!sysPath2.isAbsolute(path31) && !this._closers.has(path31)) {
16346
+ paths.forEach((path32) => {
16347
+ if (!sysPath2.isAbsolute(path32) && !this._closers.has(path32)) {
16279
16348
  if (cwd)
16280
- path31 = sysPath2.join(cwd, path31);
16281
- path31 = sysPath2.resolve(path31);
16349
+ path32 = sysPath2.join(cwd, path32);
16350
+ path32 = sysPath2.resolve(path32);
16282
16351
  }
16283
- this._closePath(path31);
16284
- this._addIgnoredPath(path31);
16285
- if (this._watched.has(path31)) {
16352
+ this._closePath(path32);
16353
+ this._addIgnoredPath(path32);
16354
+ if (this._watched.has(path32)) {
16286
16355
  this._addIgnoredPath({
16287
- path: path31,
16356
+ path: path32,
16288
16357
  recursive: true
16289
16358
  });
16290
16359
  }
@@ -16348,38 +16417,38 @@ var FSWatcher = class extends EventEmitter {
16348
16417
  * @param stats arguments to be passed with event
16349
16418
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
16350
16419
  */
16351
- async _emit(event, path31, stats) {
16420
+ async _emit(event, path32, stats) {
16352
16421
  if (this.closed)
16353
16422
  return;
16354
16423
  const opts = this.options;
16355
16424
  if (isWindows)
16356
- path31 = sysPath2.normalize(path31);
16425
+ path32 = sysPath2.normalize(path32);
16357
16426
  if (opts.cwd)
16358
- path31 = sysPath2.relative(opts.cwd, path31);
16359
- const args = [path31];
16427
+ path32 = sysPath2.relative(opts.cwd, path32);
16428
+ const args = [path32];
16360
16429
  if (stats != null)
16361
16430
  args.push(stats);
16362
16431
  const awf = opts.awaitWriteFinish;
16363
16432
  let pw;
16364
- if (awf && (pw = this._pendingWrites.get(path31))) {
16433
+ if (awf && (pw = this._pendingWrites.get(path32))) {
16365
16434
  pw.lastChange = /* @__PURE__ */ new Date();
16366
16435
  return this;
16367
16436
  }
16368
16437
  if (opts.atomic) {
16369
16438
  if (event === EVENTS.UNLINK) {
16370
- this._pendingUnlinks.set(path31, [event, ...args]);
16439
+ this._pendingUnlinks.set(path32, [event, ...args]);
16371
16440
  setTimeout(() => {
16372
- this._pendingUnlinks.forEach((entry, path32) => {
16441
+ this._pendingUnlinks.forEach((entry, path33) => {
16373
16442
  this.emit(...entry);
16374
16443
  this.emit(EVENTS.ALL, ...entry);
16375
- this._pendingUnlinks.delete(path32);
16444
+ this._pendingUnlinks.delete(path33);
16376
16445
  });
16377
16446
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
16378
16447
  return this;
16379
16448
  }
16380
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path31)) {
16449
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path32)) {
16381
16450
  event = EVENTS.CHANGE;
16382
- this._pendingUnlinks.delete(path31);
16451
+ this._pendingUnlinks.delete(path32);
16383
16452
  }
16384
16453
  }
16385
16454
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -16397,16 +16466,16 @@ var FSWatcher = class extends EventEmitter {
16397
16466
  this.emitWithAll(event, args);
16398
16467
  }
16399
16468
  };
16400
- this._awaitWriteFinish(path31, awf.stabilityThreshold, event, awfEmit);
16469
+ this._awaitWriteFinish(path32, awf.stabilityThreshold, event, awfEmit);
16401
16470
  return this;
16402
16471
  }
16403
16472
  if (event === EVENTS.CHANGE) {
16404
- const isThrottled = !this._throttle(EVENTS.CHANGE, path31, 50);
16473
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path32, 50);
16405
16474
  if (isThrottled)
16406
16475
  return this;
16407
16476
  }
16408
16477
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
16409
- const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path31) : path31;
16478
+ const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path32) : path32;
16410
16479
  let stats2;
16411
16480
  try {
16412
16481
  stats2 = await stat3(fullPath);
@@ -16437,23 +16506,23 @@ var FSWatcher = class extends EventEmitter {
16437
16506
  * @param timeout duration of time to suppress duplicate actions
16438
16507
  * @returns tracking object or false if action should be suppressed
16439
16508
  */
16440
- _throttle(actionType, path31, timeout) {
16509
+ _throttle(actionType, path32, timeout) {
16441
16510
  if (!this._throttled.has(actionType)) {
16442
16511
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
16443
16512
  }
16444
16513
  const action = this._throttled.get(actionType);
16445
16514
  if (!action)
16446
16515
  throw new Error("invalid throttle");
16447
- const actionPath = action.get(path31);
16516
+ const actionPath = action.get(path32);
16448
16517
  if (actionPath) {
16449
16518
  actionPath.count++;
16450
16519
  return false;
16451
16520
  }
16452
16521
  let timeoutObject;
16453
16522
  const clear = () => {
16454
- const item = action.get(path31);
16523
+ const item = action.get(path32);
16455
16524
  const count = item ? item.count : 0;
16456
- action.delete(path31);
16525
+ action.delete(path32);
16457
16526
  clearTimeout(timeoutObject);
16458
16527
  if (item)
16459
16528
  clearTimeout(item.timeoutObject);
@@ -16461,7 +16530,7 @@ var FSWatcher = class extends EventEmitter {
16461
16530
  };
16462
16531
  timeoutObject = setTimeout(clear, timeout);
16463
16532
  const thr = { timeoutObject, clear, count: 0 };
16464
- action.set(path31, thr);
16533
+ action.set(path32, thr);
16465
16534
  return thr;
16466
16535
  }
16467
16536
  _incrReadyCount() {
@@ -16475,44 +16544,44 @@ var FSWatcher = class extends EventEmitter {
16475
16544
  * @param event
16476
16545
  * @param awfEmit Callback to be called when ready for event to be emitted.
16477
16546
  */
16478
- _awaitWriteFinish(path31, threshold, event, awfEmit) {
16547
+ _awaitWriteFinish(path32, threshold, event, awfEmit) {
16479
16548
  const awf = this.options.awaitWriteFinish;
16480
16549
  if (typeof awf !== "object")
16481
16550
  return;
16482
16551
  const pollInterval = awf.pollInterval;
16483
16552
  let timeoutHandler;
16484
- let fullPath = path31;
16485
- if (this.options.cwd && !sysPath2.isAbsolute(path31)) {
16486
- fullPath = sysPath2.join(this.options.cwd, path31);
16553
+ let fullPath = path32;
16554
+ if (this.options.cwd && !sysPath2.isAbsolute(path32)) {
16555
+ fullPath = sysPath2.join(this.options.cwd, path32);
16487
16556
  }
16488
16557
  const now = /* @__PURE__ */ new Date();
16489
16558
  const writes = this._pendingWrites;
16490
16559
  function awaitWriteFinishFn(prevStat) {
16491
16560
  statcb(fullPath, (err, curStat) => {
16492
- if (err || !writes.has(path31)) {
16561
+ if (err || !writes.has(path32)) {
16493
16562
  if (err && err.code !== "ENOENT")
16494
16563
  awfEmit(err);
16495
16564
  return;
16496
16565
  }
16497
16566
  const now2 = Number(/* @__PURE__ */ new Date());
16498
16567
  if (prevStat && curStat.size !== prevStat.size) {
16499
- writes.get(path31).lastChange = now2;
16568
+ writes.get(path32).lastChange = now2;
16500
16569
  }
16501
- const pw = writes.get(path31);
16570
+ const pw = writes.get(path32);
16502
16571
  const df = now2 - pw.lastChange;
16503
16572
  if (df >= threshold) {
16504
- writes.delete(path31);
16573
+ writes.delete(path32);
16505
16574
  awfEmit(void 0, curStat);
16506
16575
  } else {
16507
16576
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
16508
16577
  }
16509
16578
  });
16510
16579
  }
16511
- if (!writes.has(path31)) {
16512
- writes.set(path31, {
16580
+ if (!writes.has(path32)) {
16581
+ writes.set(path32, {
16513
16582
  lastChange: now,
16514
16583
  cancelWait: () => {
16515
- writes.delete(path31);
16584
+ writes.delete(path32);
16516
16585
  clearTimeout(timeoutHandler);
16517
16586
  return event;
16518
16587
  }
@@ -16523,8 +16592,8 @@ var FSWatcher = class extends EventEmitter {
16523
16592
  /**
16524
16593
  * Determines whether user has asked to ignore this path.
16525
16594
  */
16526
- _isIgnored(path31, stats) {
16527
- if (this.options.atomic && DOT_RE.test(path31))
16595
+ _isIgnored(path32, stats) {
16596
+ if (this.options.atomic && DOT_RE.test(path32))
16528
16597
  return true;
16529
16598
  if (!this._userIgnored) {
16530
16599
  const { cwd } = this.options;
@@ -16534,17 +16603,17 @@ var FSWatcher = class extends EventEmitter {
16534
16603
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
16535
16604
  this._userIgnored = anymatch(list, void 0);
16536
16605
  }
16537
- return this._userIgnored(path31, stats);
16606
+ return this._userIgnored(path32, stats);
16538
16607
  }
16539
- _isntIgnored(path31, stat4) {
16540
- return !this._isIgnored(path31, stat4);
16608
+ _isntIgnored(path32, stat4) {
16609
+ return !this._isIgnored(path32, stat4);
16541
16610
  }
16542
16611
  /**
16543
16612
  * Provides a set of common helpers and properties relating to symlink handling.
16544
16613
  * @param path file or directory pattern being watched
16545
16614
  */
16546
- _getWatchHelpers(path31) {
16547
- return new WatchHelper(path31, this.options.followSymlinks, this);
16615
+ _getWatchHelpers(path32) {
16616
+ return new WatchHelper(path32, this.options.followSymlinks, this);
16548
16617
  }
16549
16618
  // Directory helpers
16550
16619
  // -----------------
@@ -16576,63 +16645,63 @@ var FSWatcher = class extends EventEmitter {
16576
16645
  * @param item base path of item/directory
16577
16646
  */
16578
16647
  _remove(directory, item, isDirectory) {
16579
- const path31 = sysPath2.join(directory, item);
16580
- const fullPath = sysPath2.resolve(path31);
16581
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path31) || this._watched.has(fullPath);
16582
- if (!this._throttle("remove", path31, 100))
16648
+ const path32 = sysPath2.join(directory, item);
16649
+ const fullPath = sysPath2.resolve(path32);
16650
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path32) || this._watched.has(fullPath);
16651
+ if (!this._throttle("remove", path32, 100))
16583
16652
  return;
16584
16653
  if (!isDirectory && this._watched.size === 1) {
16585
16654
  this.add(directory, item, true);
16586
16655
  }
16587
- const wp = this._getWatchedDir(path31);
16656
+ const wp = this._getWatchedDir(path32);
16588
16657
  const nestedDirectoryChildren = wp.getChildren();
16589
- nestedDirectoryChildren.forEach((nested) => this._remove(path31, nested));
16658
+ nestedDirectoryChildren.forEach((nested) => this._remove(path32, nested));
16590
16659
  const parent = this._getWatchedDir(directory);
16591
16660
  const wasTracked = parent.has(item);
16592
16661
  parent.remove(item);
16593
16662
  if (this._symlinkPaths.has(fullPath)) {
16594
16663
  this._symlinkPaths.delete(fullPath);
16595
16664
  }
16596
- let relPath = path31;
16665
+ let relPath = path32;
16597
16666
  if (this.options.cwd)
16598
- relPath = sysPath2.relative(this.options.cwd, path31);
16667
+ relPath = sysPath2.relative(this.options.cwd, path32);
16599
16668
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
16600
16669
  const event = this._pendingWrites.get(relPath).cancelWait();
16601
16670
  if (event === EVENTS.ADD)
16602
16671
  return;
16603
16672
  }
16604
- this._watched.delete(path31);
16673
+ this._watched.delete(path32);
16605
16674
  this._watched.delete(fullPath);
16606
16675
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
16607
- if (wasTracked && !this._isIgnored(path31))
16608
- this._emit(eventName, path31);
16609
- this._closePath(path31);
16676
+ if (wasTracked && !this._isIgnored(path32))
16677
+ this._emit(eventName, path32);
16678
+ this._closePath(path32);
16610
16679
  }
16611
16680
  /**
16612
16681
  * Closes all watchers for a path
16613
16682
  */
16614
- _closePath(path31) {
16615
- this._closeFile(path31);
16616
- const dir = sysPath2.dirname(path31);
16617
- this._getWatchedDir(dir).remove(sysPath2.basename(path31));
16683
+ _closePath(path32) {
16684
+ this._closeFile(path32);
16685
+ const dir = sysPath2.dirname(path32);
16686
+ this._getWatchedDir(dir).remove(sysPath2.basename(path32));
16618
16687
  }
16619
16688
  /**
16620
16689
  * Closes only file-specific watchers
16621
16690
  */
16622
- _closeFile(path31) {
16623
- const closers = this._closers.get(path31);
16691
+ _closeFile(path32) {
16692
+ const closers = this._closers.get(path32);
16624
16693
  if (!closers)
16625
16694
  return;
16626
16695
  closers.forEach((closer) => closer());
16627
- this._closers.delete(path31);
16696
+ this._closers.delete(path32);
16628
16697
  }
16629
- _addPathCloser(path31, closer) {
16698
+ _addPathCloser(path32, closer) {
16630
16699
  if (!closer)
16631
16700
  return;
16632
- let list = this._closers.get(path31);
16701
+ let list = this._closers.get(path32);
16633
16702
  if (!list) {
16634
16703
  list = [];
16635
- this._closers.set(path31, list);
16704
+ this._closers.set(path32, list);
16636
16705
  }
16637
16706
  list.push(closer);
16638
16707
  }
@@ -16663,7 +16732,7 @@ var esm_default = { watch, FSWatcher };
16663
16732
 
16664
16733
  // modules/dev/hot-reload-client/index.ts
16665
16734
  init_globals();
16666
- import path25 from "path";
16735
+ import path26 from "path";
16667
16736
  function setupHotReload({
16668
16737
  app,
16669
16738
  appDir,
@@ -16704,7 +16773,7 @@ function setupHotReload({
16704
16773
  });
16705
16774
  });
16706
16775
  console.log(`[hot-reload-server] \u2705 SSE endpoint registered at ${route}`);
16707
- const resolvedProjectRoot = projectRoot ? path25.resolve(projectRoot) : path25.dirname(path25.resolve(appDir));
16776
+ const resolvedProjectRoot = projectRoot ? path26.resolve(projectRoot) : path26.dirname(path26.resolve(appDir));
16708
16777
  const watcher = esm_default.watch(resolvedProjectRoot, {
16709
16778
  ignoreInitial: true,
16710
16779
  ignored: [
@@ -16744,11 +16813,11 @@ function setupHotReload({
16744
16813
  let broadcastTimeout = null;
16745
16814
  const BROADCAST_DEBOUNCE_MS = 300;
16746
16815
  async function broadcastReload(reason, filePath) {
16747
- const normalizedPath = path25.normalize(filePath);
16816
+ const normalizedPath = path26.normalize(filePath);
16748
16817
  if (normalizedPath.includes(BUILD_FOLDER_NAME) || normalizedPath.includes(".loly") || normalizedPath.endsWith(".map") || normalizedPath.endsWith(".log") || normalizedPath.includes("route-chunks.json") || normalizedPath.includes("routes-client.ts") || normalizedPath.includes("/client/route-")) {
16749
16818
  return;
16750
16819
  }
16751
- const rel = path25.relative(appDir, filePath);
16820
+ const rel = path26.relative(appDir, filePath);
16752
16821
  console.log(`[hot-reload] ${reason}: ${rel}`);
16753
16822
  if (broadcastTimeout) {
16754
16823
  clearTimeout(broadcastTimeout);
@@ -16798,9 +16867,9 @@ data: reload:${rel}
16798
16867
  }
16799
16868
 
16800
16869
  // modules/dev/hot-reload-server/index.ts
16801
- import path26 from "path";
16870
+ import path27 from "path";
16802
16871
  function clearAppRequireCache(appDir) {
16803
- const appDirNormalized = path26.resolve(appDir);
16872
+ const appDirNormalized = path27.resolve(appDir);
16804
16873
  for (const id of Object.keys(__require.cache)) {
16805
16874
  if (id.startsWith(appDirNormalized)) {
16806
16875
  delete __require.cache[id];
@@ -16813,7 +16882,7 @@ init_globals();
16813
16882
  function setupStaticFiles(app, projectRoot, config) {
16814
16883
  if (!config) return;
16815
16884
  const staticDir = getStaticDir(projectRoot, config);
16816
- if (fs20.existsSync(staticDir)) {
16885
+ if (fs21.existsSync(staticDir)) {
16817
16886
  app.use(
16818
16887
  express.static(staticDir, {
16819
16888
  // In production, add caching headers for better performance
@@ -16839,7 +16908,7 @@ function setupServer(app, options) {
16839
16908
  var getRoutes = getRoutes2;
16840
16909
  const { outDir, waitForBuild } = startClientBundler(projectRoot, "development");
16841
16910
  const onFileChange = async (filePath) => {
16842
- const rel = path27.relative(appDir, filePath);
16911
+ const rel = path28.relative(appDir, filePath);
16843
16912
  const isPageFile = filePath.includes("page.tsx") || filePath.includes("page.ts") || filePath.includes("layout.tsx") || filePath.includes("layout.ts") || filePath.includes("_not-found") || filePath.includes("_error");
16844
16913
  const isTsFile = filePath.endsWith(".ts") || filePath.endsWith(".tsx");
16845
16914
  if (isTsFile) {
@@ -16875,8 +16944,8 @@ function setupServer(app, options) {
16875
16944
  const wssRoutes = routeLoader.loadWssRoutes();
16876
16945
  const notFoundPage = routeLoader.loadNotFoundRoute();
16877
16946
  const errorPage = routeLoader.loadErrorRoute();
16878
- const buildDir = config ? getBuildDir(projectRoot, config) : path27.join(projectRoot, BUILD_FOLDER_NAME);
16879
- const clientOutDir = path27.join(buildDir, "client");
16947
+ const buildDir = config ? getBuildDir(projectRoot, config) : path28.join(projectRoot, BUILD_FOLDER_NAME);
16948
+ const clientOutDir = path28.join(buildDir, "client");
16880
16949
  app.use(
16881
16950
  "/static",
16882
16951
  express.static(clientOutDir, {
@@ -17003,11 +17072,11 @@ function createStrictRateLimiterFromConfig(config) {
17003
17072
  }
17004
17073
 
17005
17074
  // modules/server/middleware/auto-rate-limit.ts
17006
- function matchesStrictPattern(path31, patterns) {
17075
+ function matchesStrictPattern(path32, patterns) {
17007
17076
  for (const pattern of patterns) {
17008
17077
  const regexPattern = pattern.replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\//g, "\\/");
17009
17078
  const regex = new RegExp(`^${regexPattern}$`);
17010
- if (regex.test(path31)) {
17079
+ if (regex.test(path32)) {
17011
17080
  return true;
17012
17081
  }
17013
17082
  }
@@ -17172,7 +17241,7 @@ async function handleApiRequest(options) {
17172
17241
 
17173
17242
  // modules/server/routes.ts
17174
17243
  init_globals();
17175
- import path28 from "path";
17244
+ import path29 from "path";
17176
17245
  var cachedRewriteLoader = null;
17177
17246
  var cachedProjectRoot = null;
17178
17247
  var cachedIsDev = null;
@@ -17200,8 +17269,8 @@ function setupRoutes(options) {
17200
17269
  } = options;
17201
17270
  const routeChunks = routeLoader.loadRouteChunks();
17202
17271
  const rewriteLoader = getRewriteLoader(projectRoot, isDev);
17203
- const ssgOutDir = path28.join(
17204
- config ? getBuildDir(projectRoot, config) : path28.join(projectRoot, BUILD_FOLDER_NAME),
17272
+ const ssgOutDir = path29.join(
17273
+ config ? getBuildDir(projectRoot, config) : path29.join(projectRoot, BUILD_FOLDER_NAME),
17205
17274
  "ssg"
17206
17275
  );
17207
17276
  app.all("/api/*", async (req, res) => {
@@ -18430,8 +18499,8 @@ var setupApplication = async ({
18430
18499
 
18431
18500
  // src/server.ts
18432
18501
  import dotenv2 from "dotenv";
18433
- var envPath = path29.join(process.cwd(), ".env");
18434
- if (fs21.existsSync(envPath)) {
18502
+ var envPath = path30.join(process.cwd(), ".env");
18503
+ if (fs22.existsSync(envPath)) {
18435
18504
  dotenv2.config({ path: envPath });
18436
18505
  } else {
18437
18506
  dotenv2.config();
@@ -18452,8 +18521,8 @@ async function startServer(options = {}) {
18452
18521
  }
18453
18522
  const port = options.port ?? (process.env.PORT ? parseInt(process.env.PORT, 10) : void 0) ?? config.server.port;
18454
18523
  const host = process.env.HOST ?? (!isDev ? "0.0.0.0" : void 0) ?? config.server.host;
18455
- const appDir = options.appDir ?? (isDev ? getAppDir(projectRoot, config) : path29.join(getBuildDir(projectRoot, config), "server"));
18456
- if (!isDev && !fs21.existsSync(appDir)) {
18524
+ const appDir = options.appDir ?? (isDev ? getAppDir(projectRoot, config) : path30.join(getBuildDir(projectRoot, config), "server"));
18525
+ if (!isDev && !fs22.existsSync(appDir)) {
18457
18526
  logger4.error("Compiled directory not found", void 0, {
18458
18527
  buildDir: config.directories.build,
18459
18528
  appDir,
@@ -18649,7 +18718,7 @@ async function run() {
18649
18718
  }
18650
18719
  const args = parseArgs(argv.slice(1));
18651
18720
  const projectRoot = process2.cwd();
18652
- const appDir = path30.resolve(projectRoot, args.appDir || "app");
18721
+ const appDir = path31.resolve(projectRoot, args.appDir || "app");
18653
18722
  const port = typeof args.port === "string" && args.port.trim().length > 0 ? Number(args.port) : 3e3;
18654
18723
  switch (command) {
18655
18724
  case "dev": {