@farm.js/core 0.1.0-beta.33 → 0.1.0-beta.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/{chunk-EL644GWT.mjs → chunk-7JLDC7IO.mjs} +17 -4
  2. package/dist/chunk-7JLDC7IO.mjs.map +1 -0
  3. package/dist/{chunk-5PDVNNUQ.mjs → chunk-BNTDKO7T.mjs} +8 -4
  4. package/dist/chunk-BNTDKO7T.mjs.map +1 -0
  5. package/dist/{chunk-4TI6B4AY.mjs → chunk-HLN7NPNQ.mjs} +220 -154
  6. package/dist/chunk-HLN7NPNQ.mjs.map +1 -0
  7. package/dist/{chunk-NETDSCXV.mjs → chunk-IU42657J.mjs} +2 -2
  8. package/dist/{chunk-GKEYR7EK.mjs → chunk-IZFFEFOH.mjs} +2 -2
  9. package/dist/{chunk-GKEYR7EK.mjs.map → chunk-IZFFEFOH.mjs.map} +1 -1
  10. package/dist/{chunk-QGRLI3KV.mjs → chunk-O4IEAI32.mjs} +2 -2
  11. package/dist/{chunk-DV5ZT2JO.mjs → chunk-S7SW4LTM.mjs} +4 -4
  12. package/dist/client/lifecycle.mjs +2 -2
  13. package/dist/client-plugins.cjs +1 -1
  14. package/dist/client-plugins.cjs.map +1 -1
  15. package/dist/client-plugins.mjs +2 -2
  16. package/dist/client.cjs +1 -1
  17. package/dist/client.cjs.map +1 -1
  18. package/dist/client.mjs +2 -2
  19. package/dist/{devtools-BF6URGGF.mjs → devtools-G4S3JRIH.mjs} +3 -3
  20. package/dist/docs.cjs +13 -1
  21. package/dist/docs.cjs.map +1 -1
  22. package/dist/docs.mjs +3 -3
  23. package/dist/index.cjs +437 -352
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.mjs +7 -7
  26. package/dist/internal/build-runtime.cjs +414 -329
  27. package/dist/internal/build-runtime.cjs.map +1 -1
  28. package/dist/internal/build-runtime.mjs +6 -6
  29. package/dist/internal/client-runtime.cjs +1 -1
  30. package/dist/internal/client-runtime.cjs.map +1 -1
  31. package/dist/internal/client-runtime.mjs +2 -2
  32. package/dist/internal/config-runtime.cjs +17 -3
  33. package/dist/internal/config-runtime.cjs.map +1 -1
  34. package/dist/internal/config-runtime.mjs +2 -2
  35. package/dist/plugin.cjs +16 -3
  36. package/dist/plugin.cjs.map +1 -1
  37. package/dist/plugin.mjs +3 -3
  38. package/dist/renderer.cjs +7 -3
  39. package/dist/renderer.cjs.map +1 -1
  40. package/dist/renderer.d.mts +9 -0
  41. package/dist/renderer.d.ts +9 -0
  42. package/dist/renderer.mjs +1 -1
  43. package/dist/server.cjs +23 -6
  44. package/dist/server.cjs.map +1 -1
  45. package/dist/server.mjs +4 -4
  46. package/dist/version.cjs +1 -1
  47. package/dist/version.cjs.map +1 -1
  48. package/dist/version.mjs +1 -1
  49. package/dist/vite.cjs +21 -5
  50. package/dist/vite.cjs.map +1 -1
  51. package/dist/vite.mjs +3 -3
  52. package/package.json +3 -3
  53. package/dist/chunk-4TI6B4AY.mjs.map +0 -1
  54. package/dist/chunk-5PDVNNUQ.mjs.map +0 -1
  55. package/dist/chunk-EL644GWT.mjs.map +0 -1
  56. /package/dist/{chunk-NETDSCXV.mjs.map → chunk-IU42657J.mjs.map} +0 -0
  57. /package/dist/{chunk-QGRLI3KV.mjs.map → chunk-O4IEAI32.mjs.map} +0 -0
  58. /package/dist/{chunk-DV5ZT2JO.mjs.map → chunk-S7SW4LTM.mjs.map} +0 -0
  59. /package/dist/{devtools-BF6URGGF.mjs.map → devtools-G4S3JRIH.mjs.map} +0 -0
@@ -283,11 +283,11 @@ function resolveFarmServerHealthConfig(config) {
283
283
  return Object.freeze({ enabled: true, livenessPath, readinessPath });
284
284
  }
285
285
  function normalizeHealthPath(value, optionName) {
286
- const path36 = value.trim();
287
- if (!path36.startsWith("/") || path36.includes("?") || path36.includes("#") || path36.includes("*")) {
286
+ const path37 = value.trim();
287
+ if (!path37.startsWith("/") || path37.includes("?") || path37.includes("#") || path37.includes("*")) {
288
288
  throw new TypeError(`${optionName} must be an absolute pathname without a query or wildcard`);
289
289
  }
290
- return path36.length > 1 ? path36.replace(/\/+$/, "") || "/" : path36;
290
+ return path37.length > 1 ? path37.replace(/\/+$/, "") || "/" : path37;
291
291
  }
292
292
  function parseBodySizeLimit(value, optionName = "bodySizeLimit") {
293
293
  if (typeof value === "number") {
@@ -1086,9 +1086,9 @@ function getFarmIntegrationPluginOwner(plugin) {
1086
1086
  const value = plugin[FARM_INTEGRATION_PLUGIN_OWNER];
1087
1087
  return value && typeof value === "object" ? value : void 0;
1088
1088
  }
1089
- function defineTypedIntegrationRoute(method, path36, input) {
1089
+ function defineTypedIntegrationRoute(method, path37, input) {
1090
1090
  return {
1091
- path: path36,
1091
+ path: path37,
1092
1092
  method,
1093
1093
  middleware: input.middleware,
1094
1094
  before: input.before,
@@ -1098,7 +1098,7 @@ function defineTypedIntegrationRoute(method, path36, input) {
1098
1098
  input: normalizeIntegrationRouteInputSchemas(input),
1099
1099
  handler: input.handler,
1100
1100
  __operation: defineIntegrationAPIOperation({
1101
- path: path36,
1101
+ path: path37,
1102
1102
  method,
1103
1103
  bodyFormat: input.bodyFormat,
1104
1104
  responseFormat: input.responseFormat,
@@ -1110,58 +1110,58 @@ function defineTypedIntegrationRoute(method, path36, input) {
1110
1110
  }
1111
1111
  function createIntegrationRouteFactory() {
1112
1112
  return {
1113
- get(path36, input) {
1113
+ get(path37, input) {
1114
1114
  return defineTypedIntegrationRoute(
1115
1115
  "GET",
1116
- path36,
1116
+ path37,
1117
1117
  input
1118
1118
  );
1119
1119
  },
1120
- post(path36, input) {
1120
+ post(path37, input) {
1121
1121
  return defineTypedIntegrationRoute(
1122
1122
  "POST",
1123
- path36,
1123
+ path37,
1124
1124
  {
1125
1125
  bodyFormat: "json",
1126
1126
  ...input
1127
1127
  }
1128
1128
  );
1129
1129
  },
1130
- query(path36, input) {
1131
- return defineTypedIntegrationRoute("QUERY", path36, {
1130
+ query(path37, input) {
1131
+ return defineTypedIntegrationRoute("QUERY", path37, {
1132
1132
  bodyFormat: "json",
1133
1133
  ...input
1134
1134
  });
1135
1135
  },
1136
- put(path36, input) {
1136
+ put(path37, input) {
1137
1137
  return defineTypedIntegrationRoute(
1138
1138
  "PUT",
1139
- path36,
1139
+ path37,
1140
1140
  {
1141
1141
  bodyFormat: "json",
1142
1142
  ...input
1143
1143
  }
1144
1144
  );
1145
1145
  },
1146
- patch(path36, input) {
1147
- return defineTypedIntegrationRoute("PATCH", path36, {
1146
+ patch(path37, input) {
1147
+ return defineTypedIntegrationRoute("PATCH", path37, {
1148
1148
  bodyFormat: "json",
1149
1149
  ...input
1150
1150
  });
1151
1151
  },
1152
- delete(path36, input) {
1153
- return defineTypedIntegrationRoute("DELETE", path36, {
1152
+ delete(path37, input) {
1153
+ return defineTypedIntegrationRoute("DELETE", path37, {
1154
1154
  bodyFormat: "json",
1155
1155
  ...input
1156
1156
  });
1157
1157
  },
1158
- options(path36, input) {
1159
- return defineTypedIntegrationRoute("OPTIONS", path36, input);
1158
+ options(path37, input) {
1159
+ return defineTypedIntegrationRoute("OPTIONS", path37, input);
1160
1160
  },
1161
- head(path36, input) {
1161
+ head(path37, input) {
1162
1162
  return defineTypedIntegrationRoute(
1163
1163
  "HEAD",
1164
- path36,
1164
+ path37,
1165
1165
  input
1166
1166
  );
1167
1167
  }
@@ -1435,8 +1435,8 @@ async function parseIntegrationConfigSchema(integration, schema, value) {
1435
1435
  function createIntegrationConfigValidationError(integration, error) {
1436
1436
  const issues = Array.isArray(error.issues) && error.issues.length > 0 ? error.issues.map((issue) => {
1437
1437
  const normalizedPath = normalizeIntegrationValidationPath(issue.path);
1438
- const path36 = normalizedPath.length ? `${normalizedPath.join(".")}: ` : "";
1439
- return `${path36}${issue.message || "Invalid config"}`;
1438
+ const path37 = normalizedPath.length ? `${normalizedPath.join(".")}: ` : "";
1439
+ return `${path37}${issue.message || "Invalid config"}`;
1440
1440
  }).join("; ") : error.message || "Invalid config";
1441
1441
  return new Error(`Integration "${integration.type}" config validation failed: ${issues}`);
1442
1442
  }
@@ -2145,8 +2145,8 @@ function normalizeIntegrationValidationIssues(source, error) {
2145
2145
  }
2146
2146
  ];
2147
2147
  }
2148
- function normalizeIntegrationValidationPath(path36) {
2149
- return (path36 || []).map((segment) => {
2148
+ function normalizeIntegrationValidationPath(path37) {
2149
+ return (path37 || []).map((segment) => {
2150
2150
  const key = typeof segment === "object" && segment !== null && "key" in segment ? segment.key : segment;
2151
2151
  return typeof key === "symbol" ? key.description || key.toString() : key;
2152
2152
  });
@@ -3360,20 +3360,20 @@ async function prepareFarmWorkflowsForNitro(config) {
3360
3360
  const root = config.root || process.cwd();
3361
3361
  const distDir = config.distDir || ".farm";
3362
3362
  const fs12 = await import("fs/promises");
3363
- const path36 = await import("path");
3364
- const generatedDir = path36.join(root, distDir, ".nitro", "farm-workflows");
3363
+ const path37 = await import("path");
3364
+ const generatedDir = path37.join(root, distDir, ".nitro", "farm-workflows");
3365
3365
  await fs12.mkdir(generatedDir, { recursive: true });
3366
3366
  const tasks = {};
3367
3367
  const scheduledTasks = createScheduledTasks(workflows);
3368
3368
  for (const workflow of workflows) {
3369
- const wrapperPath = path36.join(generatedDir, `${safeFileName(workflow.id)}.mjs`);
3369
+ const wrapperPath = path37.join(generatedDir, `${safeFileName(workflow.id)}.mjs`);
3370
3370
  await fs12.writeFile(wrapperPath, createNitroTaskWrapper(workflow), "utf8");
3371
3371
  tasks[workflow.id] = {
3372
3372
  handler: wrapperPath,
3373
3373
  description: workflow.description || `Farm workflow ${workflow.id}`
3374
3374
  };
3375
3375
  }
3376
- const handlerPath = path36.join(generatedDir, "http-handler.mjs");
3376
+ const handlerPath = path37.join(generatedDir, "http-handler.mjs");
3377
3377
  await fs12.writeFile(
3378
3378
  handlerPath,
3379
3379
  createNitroWorkflowHTTPHandler(
@@ -3383,7 +3383,7 @@ async function prepareFarmWorkflowsForNitro(config) {
3383
3383
  ),
3384
3384
  "utf8"
3385
3385
  );
3386
- const manifestPath = path36.join(generatedDir, "manifest.json");
3386
+ const manifestPath = path37.join(generatedDir, "manifest.json");
3387
3387
  await fs12.writeFile(
3388
3388
  manifestPath,
3389
3389
  JSON.stringify(
@@ -3466,10 +3466,10 @@ function resolveWorkflowDefinition(module2) {
3466
3466
  }
3467
3467
  async function findWorkflowFiles(root, dirs) {
3468
3468
  const fs12 = await import("fs/promises");
3469
- const path36 = await import("path");
3469
+ const path37 = await import("path");
3470
3470
  const files = [];
3471
3471
  for (const dir of dirs) {
3472
- const absoluteDir = path36.isAbsolute(dir) ? dir : path36.join(root, dir);
3472
+ const absoluteDir = path37.isAbsolute(dir) ? dir : path37.join(root, dir);
3473
3473
  if (!await pathExists(absoluteDir)) continue;
3474
3474
  await walkWorkflowDir(absoluteDir, files);
3475
3475
  }
@@ -3477,10 +3477,10 @@ async function findWorkflowFiles(root, dirs) {
3477
3477
  }
3478
3478
  async function walkWorkflowDir(dir, files) {
3479
3479
  const fs12 = await import("fs/promises");
3480
- const path36 = await import("path");
3480
+ const path37 = await import("path");
3481
3481
  const entries = await fs12.readdir(dir, { withFileTypes: true });
3482
3482
  for (const entry of entries) {
3483
- const filePath = path36.join(dir, entry.name);
3483
+ const filePath = path37.join(dir, entry.name);
3484
3484
  if (entry.isDirectory()) {
3485
3485
  if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
3486
3486
  await walkWorkflowDir(filePath, files);
@@ -3500,12 +3500,12 @@ function isWorkflowFile(fileName) {
3500
3500
  }
3501
3501
  async function loadWorkflowModule(filePath, root) {
3502
3502
  const fs12 = await import("fs/promises");
3503
- const path36 = await import("path");
3503
+ const path37 = await import("path");
3504
3504
  const { pathToFileURL: pathToFileURL9 } = await import("url");
3505
3505
  const { build: build3 } = await import("esbuild");
3506
- const outDir = path36.join(root, ".farm", ".workflow-loader");
3506
+ const outDir = path37.join(root, ".farm", ".workflow-loader");
3507
3507
  await fs12.mkdir(outDir, { recursive: true });
3508
- const outfile = path36.join(
3508
+ const outfile = path37.join(
3509
3509
  outDir,
3510
3510
  `workflow-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`
3511
3511
  );
@@ -3800,9 +3800,9 @@ async function prepareFarmCronForNitro(config) {
3800
3800
  const root = config.root || process.cwd();
3801
3801
  const distDir = config.distDir || ".farm";
3802
3802
  const fs12 = await import("fs/promises");
3803
- const path36 = await import("path");
3804
- const manifestPath = path36.join(root, distDir, FARM_CRON_MANIFEST);
3805
- const generatedDir = path36.join(root, distDir, ".nitro", "farm-cron");
3803
+ const path37 = await import("path");
3804
+ const manifestPath = path37.join(root, distDir, FARM_CRON_MANIFEST);
3805
+ const generatedDir = path37.join(root, distDir, ".nitro", "farm-cron");
3806
3806
  if (!cron.enabled) {
3807
3807
  await Promise.all([
3808
3808
  fs12.rm(manifestPath, { force: true }),
@@ -3819,7 +3819,7 @@ async function prepareFarmCronForNitro(config) {
3819
3819
  const tasks = {};
3820
3820
  for (const job of cron.jobs) {
3821
3821
  const taskName = getFarmCronTaskName(job.name);
3822
- const wrapperPath = path36.join(generatedDir, `${safeFileName2(job.name)}.mjs`);
3822
+ const wrapperPath = path37.join(generatedDir, `${safeFileName2(job.name)}.mjs`);
3823
3823
  await fs12.writeFile(wrapperPath, createNitroCronTaskWrapper(job, cron.secretEnv), "utf8");
3824
3824
  tasks[taskName] = {
3825
3825
  handler: wrapperPath,
@@ -3827,7 +3827,7 @@ async function prepareFarmCronForNitro(config) {
3827
3827
  };
3828
3828
  }
3829
3829
  const manifest = createFarmCronManifest(cron);
3830
- await fs12.mkdir(path36.dirname(manifestPath), { recursive: true });
3830
+ await fs12.mkdir(path37.dirname(manifestPath), { recursive: true });
3831
3831
  await fs12.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
3832
3832
  `, "utf8");
3833
3833
  return {
@@ -3909,7 +3909,7 @@ function normalizeCronJob(name2, job) {
3909
3909
  if (!job || typeof job !== "object" || Array.isArray(job)) {
3910
3910
  throw new TypeError(`Farm cron ${JSON.stringify(name2)} must be a configuration object.`);
3911
3911
  }
3912
- const path36 = normalizeCronPath(name2, job.path);
3912
+ const path37 = normalizeCronPath(name2, job.path);
3913
3913
  const rawSchedule = Array.isArray(job.schedule) ? job.schedule : [job.schedule];
3914
3914
  const schedule = [...new Set(rawSchedule.map((value) => normalizeCronExpression(name2, value)))];
3915
3915
  if (schedule.length === 0) {
@@ -3918,7 +3918,7 @@ function normalizeCronJob(name2, job) {
3918
3918
  return {
3919
3919
  name: name2,
3920
3920
  schedule,
3921
- path: path36,
3921
+ path: path37,
3922
3922
  description: job.description?.trim() || void 0
3923
3923
  };
3924
3924
  }
@@ -3926,13 +3926,13 @@ function normalizeCronPath(name2, value) {
3926
3926
  if (typeof value !== "string" || !value.trim().startsWith("/")) {
3927
3927
  throw new TypeError(`Farm cron ${JSON.stringify(name2)} path must start with "/".`);
3928
3928
  }
3929
- const path36 = value.trim();
3930
- if (path36.startsWith("//") || path36.includes("?") || path36.includes("#")) {
3929
+ const path37 = value.trim();
3930
+ if (path37.startsWith("//") || path37.includes("?") || path37.includes("#")) {
3931
3931
  throw new TypeError(
3932
3932
  `Farm cron ${JSON.stringify(name2)} path must be an application pathname without a host, query, or hash.`
3933
3933
  );
3934
3934
  }
3935
- return path36.length > 1 ? path36.replace(/\/+$/, "") : path36;
3935
+ return path37.length > 1 ? path37.replace(/\/+$/, "") : path37;
3936
3936
  }
3937
3937
  function normalizeCronExpression(name2, value) {
3938
3938
  if (typeof value !== "string") {
@@ -5155,8 +5155,8 @@ function createFarmDeploymentMismatchResponse(mismatch) {
5155
5155
  }
5156
5156
  );
5157
5157
  }
5158
- function createFarmDeploymentCookie(deploymentId, path36 = "/", secure = false) {
5159
- const normalizedPath = path36.startsWith("/") ? path36 : `/${path36}`;
5158
+ function createFarmDeploymentCookie(deploymentId, path37 = "/", secure = false) {
5159
+ const normalizedPath = path37.startsWith("/") ? path37 : `/${path37}`;
5160
5160
  return [
5161
5161
  `${FARM_DEPLOYMENT_COOKIE}=${encodeURIComponent(deploymentId)}`,
5162
5162
  `Path=${normalizedPath}`,
@@ -5228,7 +5228,7 @@ var init_devtools_config = __esm({
5228
5228
 
5229
5229
  // src/image-config.ts
5230
5230
  function resolveFarmImageConfig(config) {
5231
- const path36 = normalizeImagePath(config?.path ?? DEFAULT_FARM_IMAGE_PATH);
5231
+ const path37 = normalizeImagePath(config?.path ?? DEFAULT_FARM_IMAGE_PATH);
5232
5232
  const deviceSizes = normalizeIntegerList(
5233
5233
  config?.deviceSizes ?? DEFAULT_FARM_IMAGE_DEVICE_SIZES,
5234
5234
  "images.deviceSizes"
@@ -5256,7 +5256,7 @@ function resolveFarmImageConfig(config) {
5256
5256
  );
5257
5257
  return Object.freeze({
5258
5258
  provider: config?.provider ?? "auto",
5259
- path: path36,
5259
+ path: path37,
5260
5260
  domains: Object.freeze([
5261
5261
  ...new Set(
5262
5262
  (config?.domains ?? []).map((domain) => domain.trim().toLowerCase()).filter(Boolean)
@@ -5295,11 +5295,11 @@ function getPublicFarmImageConfig(config) {
5295
5295
  };
5296
5296
  }
5297
5297
  function normalizeImagePath(value) {
5298
- const path36 = value.trim().replace(/\/+$/, "") || "/";
5299
- if (!path36.startsWith("/") || path36.includes("?") || path36.includes("#")) {
5298
+ const path37 = value.trim().replace(/\/+$/, "") || "/";
5299
+ if (!path37.startsWith("/") || path37.includes("?") || path37.includes("#")) {
5300
5300
  throw new TypeError("images.path must be an absolute pathname without a query or hash");
5301
5301
  }
5302
- return path36;
5302
+ return path37;
5303
5303
  }
5304
5304
  function normalizeIntegerList(values, name2, max) {
5305
5305
  if (values.length === 0) {
@@ -5859,7 +5859,8 @@ function resolveFarmRenderer(renderer) {
5859
5859
  dedupe: [...resolved.dedupe || []],
5860
5860
  optimizeDeps: [...resolved.optimizeDeps || []],
5861
5861
  buildConcurrency: resolved.buildConcurrency || "parallel",
5862
- capabilities: getFarmRendererCapabilities(resolved)
5862
+ capabilities: getFarmRendererCapabilities(resolved),
5863
+ options: resolved.options ? { ...resolved.options } : void 0
5863
5864
  };
5864
5865
  }
5865
5866
  async function readFarmRendererWebStream(stream) {
@@ -5881,7 +5882,7 @@ function resolveFarmRendererModule(root, specifier) {
5881
5882
  return requireFromApp.resolve(specifier);
5882
5883
  }
5883
5884
  async function loadFarmRendererVitePlugins(renderer, root, options = {}) {
5884
- if (isReactRenderer(renderer)) return [];
5885
+ if (renderer.vite === REACT_RENDERER.vite) return [];
5885
5886
  const modulePath = resolveFarmRendererModule(root, renderer.vite);
5886
5887
  const rendererModule = await import((0, import_node_url3.pathToFileURL)(modulePath).href);
5887
5888
  if (typeof rendererModule.createFarmRendererPlugin !== "function") {
@@ -5889,7 +5890,10 @@ async function loadFarmRendererVitePlugins(renderer, root, options = {}) {
5889
5890
  `Renderer \`${renderer.name}\` module ${renderer.vite} must export createFarmRendererPlugin().`
5890
5891
  );
5891
5892
  }
5892
- const created = await rendererModule.createFarmRendererPlugin(options);
5893
+ const created = await rendererModule.createFarmRendererPlugin({
5894
+ ...options,
5895
+ rendererOptions: renderer.options
5896
+ });
5893
5897
  if (!created) return [];
5894
5898
  return Array.isArray(created) ? [...created] : [created];
5895
5899
  }
@@ -5981,14 +5985,14 @@ function normalizeFarmAPIConfig(config) {
5981
5985
  };
5982
5986
  }
5983
5987
  function normalizeFarmAPIBasePath(value) {
5984
- const path36 = value.trim();
5985
- if (!path36) {
5988
+ const path37 = value.trim();
5989
+ if (!path37) {
5986
5990
  throw new Error("Farm api.basePath cannot be empty.");
5987
5991
  }
5988
- if (path36.includes("?") || path36.includes("#")) {
5992
+ if (path37.includes("?") || path37.includes("#")) {
5989
5993
  throw new Error("Farm api.basePath cannot contain a query string or hash.");
5990
5994
  }
5991
- const normalized = `/${path36.replace(/^\/+|\/+$/g, "")}`;
5995
+ const normalized = `/${path37.replace(/^\/+|\/+$/g, "")}`;
5992
5996
  return normalized === "/" ? "/" : normalized;
5993
5997
  }
5994
5998
  async function resolveConfigValue(value, context2, name2) {
@@ -6074,7 +6078,8 @@ function resolveDeployOutputPath(root, outputDir) {
6074
6078
  function resolveDeployConfig(config, overrides = {}) {
6075
6079
  const deploy = config.deploy || {};
6076
6080
  const distDir = config.distDir || ".farm";
6077
- const target = normalizeDeployTarget(overrides.target || deploy.target);
6081
+ const overrideTarget = normalizeDeployTarget(overrides.target);
6082
+ const target = overrideTarget ? overrideTarget : overrides.preset ? getDeployTargetForPreset(overrides.preset) : normalizeDeployTarget(deploy.target);
6078
6083
  const preset = overrides.preset || deploy.preset || config.preset || getPresetForDeployTarget(target) || "node-server";
6079
6084
  const resolvedTarget = target || getDeployTargetForPreset(preset);
6080
6085
  const platformOutput = resolvedTarget === "vercel" ? deploy.vercel?.outputDirectory : resolvedTarget === "cloudflare" ? deploy.cloudflare?.outputDir : resolvedTarget === "netlify" ? deploy.netlify?.outputDir : void 0;
@@ -6106,6 +6111,14 @@ function normalizeDocsContentDir(value) {
6106
6111
  const normalized = value.replace(/\\/g, "/").replace(/^\/+/, "").replace(/\/+$/, "");
6107
6112
  return normalized || void 0;
6108
6113
  }
6114
+ async function inferDocsContentDir(root, srcDir, entry) {
6115
+ const { existsSync: existsSync20 } = await import("fs");
6116
+ const contentDir = import_path.default.resolve(root, srcDir, "app", entry);
6117
+ if (!existsSync20(contentDir)) return void 0;
6118
+ const relativeContentDir = import_path.default.relative(root, contentDir);
6119
+ if (relativeContentDir.startsWith("..") || import_path.default.isAbsolute(relativeContentDir)) return void 0;
6120
+ return normalizeDocsContentDir(relativeContentDir);
6121
+ }
6109
6122
  function isRecord2(value) {
6110
6123
  return !!value && typeof value === "object" && !Array.isArray(value);
6111
6124
  }
@@ -6257,7 +6270,10 @@ async function resolveDocsConfig(userDocs, options = {}) {
6257
6270
  configuredDocsPath || explicitRoute || (configuredEntry ? `/${configuredEntry}` : void 0)
6258
6271
  );
6259
6272
  const docsEntry = explicitRoute && explicitRoute.startsWith("/") ? docsRouteToEntry(explicitRoute) : docsRouteToEntry(configuredEntry || entryRoute);
6260
- const contentDir = normalizeDocsContentDir(docsOptions.contentDir || mergedDocsConfig.contentDir);
6273
+ const configuredContentDir = normalizeDocsContentDir(
6274
+ docsOptions.contentDir || mergedDocsConfig.contentDir
6275
+ );
6276
+ const contentDir = configuredContentDir || await inferDocsContentDir(root, options.srcDir || "src", docsEntry);
6261
6277
  return {
6262
6278
  enabled: true,
6263
6279
  entry: entryRoute,
@@ -6480,6 +6496,7 @@ var init_config4 = __esm({
6480
6496
  __name(normalizeDocsRoute, "normalizeDocsRoute");
6481
6497
  __name(docsRouteToEntry, "docsRouteToEntry");
6482
6498
  __name(normalizeDocsContentDir, "normalizeDocsContentDir");
6499
+ __name(inferDocsContentDir, "inferDocsContentDir");
6483
6500
  __name(isRecord2, "isRecord");
6484
6501
  __name(cloneSerializable, "cloneSerializable");
6485
6502
  __name(sanitizeDocsConfig, "sanitizeDocsConfig");
@@ -8491,7 +8508,7 @@ function getProgrammaticRouteSearchClientOptions2(search) {
8491
8508
  if (search.temporary?.length) options.temporary = [...search.temporary];
8492
8509
  return Object.keys(options).length > 0 ? options : void 0;
8493
8510
  }
8494
- function resolveProgrammaticRouteSearch(searchConfig, rawSearch, path36, routePath) {
8511
+ function resolveProgrammaticRouteSearch(searchConfig, rawSearch, path37, routePath) {
8495
8512
  const schema = getProgrammaticRouteSearchSchema(searchConfig);
8496
8513
  const search = parseProgrammaticSchema(schema, rawSearch, "search", routePath);
8497
8514
  const options = getProgrammaticRouteSearchOptions(searchConfig);
@@ -8500,7 +8517,7 @@ function resolveProgrammaticRouteSearch(searchConfig, rawSearch, path36, routePa
8500
8517
  schema,
8501
8518
  rawSearch,
8502
8519
  parsedSearch: search,
8503
- path: path36
8520
+ path: path37
8504
8521
  });
8505
8522
  return { search, canonicalPath };
8506
8523
  }
@@ -8579,8 +8596,8 @@ function normalizeComparableValue(value) {
8579
8596
  }
8580
8597
  return value;
8581
8598
  }
8582
- function createRoute(path36, options) {
8583
- return routesBuilder.page(path36, options);
8599
+ function createRoute(path37, options) {
8600
+ return routesBuilder.page(path37, options);
8584
8601
  }
8585
8602
  function isProgrammaticRoutesFileName2(fileName) {
8586
8603
  const normalized = fileName.replace(/\\/g, "/");
@@ -8670,7 +8687,7 @@ function createRouteModuleFromProgrammaticPage(route, rendererRuntime) {
8670
8687
  mod.__farmRouteData = route.data;
8671
8688
  mod.__farmRouteParsesProps = true;
8672
8689
  mod.__farmResolveRouteProps = (props) => resolveProgrammaticRouteProps(route, props);
8673
- mod.__farmResolveRouteCanonicalPath = (rawSearch, path36) => resolveProgrammaticRouteSearch(route.search, rawSearch, path36, route.path).canonicalPath;
8690
+ mod.__farmResolveRouteCanonicalPath = (rawSearch, path37) => resolveProgrammaticRouteSearch(route.search, rawSearch, path37, route.path).canonicalPath;
8674
8691
  }
8675
8692
  if (route.pending || route.error || route.notFound) {
8676
8693
  mod.__farmRouteComponents = {
@@ -9106,25 +9123,25 @@ var init_routes = __esm({
9106
9123
  ];
9107
9124
  __name(defineRoutes, "defineRoutes");
9108
9125
  routesBuilder = {
9109
- page(path36, options) {
9126
+ page(path37, options) {
9110
9127
  return normalizeProgrammaticRoute({
9111
9128
  kind: "page",
9112
- path: path36,
9129
+ path: path37,
9113
9130
  ...options
9114
9131
  });
9115
9132
  },
9116
- layout(path36, options) {
9133
+ layout(path37, options) {
9117
9134
  return normalizeProgrammaticRoute({
9118
9135
  kind: "layout",
9119
- path: path36,
9136
+ path: path37,
9120
9137
  ...options
9121
9138
  });
9122
9139
  },
9123
- api(path36, options) {
9140
+ api(path37, options) {
9124
9141
  const { render, runtime, regions, maxDuration, ...methods } = options;
9125
9142
  return normalizeProgrammaticRoute({
9126
9143
  kind: "api",
9127
- path: path36,
9144
+ path: path37,
9128
9145
  render,
9129
9146
  runtime,
9130
9147
  regions,
@@ -14562,7 +14579,7 @@ var init_server3 = __esm({
14562
14579
  var version;
14563
14580
  var init_package = __esm({
14564
14581
  "package.json"() {
14565
- version = "0.1.0-beta.33";
14582
+ version = "0.1.0-beta.35";
14566
14583
  }
14567
14584
  });
14568
14585
 
@@ -18946,12 +18963,12 @@ var init_cli_colors = __esm({
18946
18963
  function isMiddlewareResponse(value) {
18947
18964
  return value instanceof Response;
18948
18965
  }
18949
- var fs7, path24, _MiddlewareManager, MiddlewareManager;
18966
+ var fs7, path25, _MiddlewareManager, MiddlewareManager;
18950
18967
  var init_manager = __esm({
18951
18968
  "src/middleware/manager.ts"() {
18952
18969
  "use strict";
18953
18970
  fs7 = __toESM(require("fs"));
18954
- path24 = __toESM(require("path"));
18971
+ path25 = __toESM(require("path"));
18955
18972
  init_context();
18956
18973
  init_module();
18957
18974
  init_utils();
@@ -19032,8 +19049,8 @@ var init_manager = __esm({
19032
19049
  const entries = fs7.readdirSync(dir, { withFileTypes: true });
19033
19050
  for (const entry of entries) {
19034
19051
  if (entry.isDirectory() && !entry.name.startsWith(".") && !entry.name.startsWith("_")) {
19035
- const subPath = path24.join(dir, entry.name);
19036
- const subRoutePath = path24.posix.join(routePath, entry.name);
19052
+ const subPath = path25.join(dir, entry.name);
19053
+ const subRoutePath = path25.posix.join(routePath, entry.name);
19037
19054
  await this.discoverInDirectory(subPath, subRoutePath, discovered);
19038
19055
  }
19039
19056
  }
@@ -19044,7 +19061,7 @@ var init_manager = __esm({
19044
19061
  findMiddlewareFile(dir) {
19045
19062
  const extensions = [".ts", ".tsx", ".js", ".jsx"];
19046
19063
  for (const ext of extensions) {
19047
- const filePath = path24.join(dir, `middleware${ext}`);
19064
+ const filePath = path25.join(dir, `middleware${ext}`);
19048
19065
  if (fs7.existsSync(filePath)) {
19049
19066
  return filePath;
19050
19067
  }
@@ -19409,12 +19426,12 @@ var init_write_file_if_changed = __esm({
19409
19426
  });
19410
19427
 
19411
19428
  // src/type-generator.ts
19412
- var import_fs3, import_path10, _APITypeGenerator, APITypeGenerator;
19429
+ var import_fs3, import_path11, _APITypeGenerator, APITypeGenerator;
19413
19430
  var init_type_generator = __esm({
19414
19431
  "src/type-generator.ts"() {
19415
19432
  "use strict";
19416
19433
  import_fs3 = require("fs");
19417
- import_path10 = require("path");
19434
+ import_path11 = require("path");
19418
19435
  init_write_file_if_changed();
19419
19436
  _APITypeGenerator = class _APITypeGenerator {
19420
19437
  constructor(appDir) {
@@ -19426,7 +19443,7 @@ var init_type_generator = __esm({
19426
19443
  scanAPIRoutes() {
19427
19444
  const routes = /* @__PURE__ */ new Map();
19428
19445
  for (const appDir of this.appDirs) {
19429
- const apiDir = (0, import_path10.join)(appDir, "api");
19446
+ const apiDir = (0, import_path11.join)(appDir, "api");
19430
19447
  if (!(0, import_fs3.existsSync)(apiDir)) continue;
19431
19448
  const discovered = [];
19432
19449
  this.scanDirectory(apiDir, appDir, discovered);
@@ -19439,7 +19456,7 @@ var init_type_generator = __esm({
19439
19456
  scanDirectory(dir, appDir, routes, basePath = "") {
19440
19457
  const items = (0, import_fs3.readdirSync)(dir, { withFileTypes: true });
19441
19458
  for (const item of items) {
19442
- const fullPath = (0, import_path10.join)(dir, item.name);
19459
+ const fullPath = (0, import_path11.join)(dir, item.name);
19443
19460
  if (item.isDirectory()) {
19444
19461
  const newBasePath = basePath ? `${basePath}/${item.name}` : item.name;
19445
19462
  this.scanDirectory(fullPath, appDir, routes, newBasePath);
@@ -19458,7 +19475,7 @@ var init_type_generator = __esm({
19458
19475
  if (methods.length === 0) {
19459
19476
  return null;
19460
19477
  }
19461
- const relativePath2 = (0, import_path10.relative)(appDir, filePath);
19478
+ const relativePath2 = (0, import_path11.relative)(appDir, filePath);
19462
19479
  const apiPath = basePath ? `/api/${basePath}` : "/api";
19463
19480
  return {
19464
19481
  path: apiPath,
@@ -19504,11 +19521,11 @@ var init_type_generator = __esm({
19504
19521
  routeGroups.get(key).push(route);
19505
19522
  }
19506
19523
  const nestedStructure = {};
19507
- for (const [path36, routeList] of routeGroups) {
19524
+ for (const [path37, routeList] of routeGroups) {
19508
19525
  const route = routeList[0];
19509
19526
  const importPath = this.getRouteImportPath(route, options.outFile);
19510
19527
  const routeName = this.pathToRouteName(route.path);
19511
- const cleanPath = path36 === "/api" ? "" : path36.replace(/^\/api\//, "");
19528
+ const cleanPath = path37 === "/api" ? "" : path37.replace(/^\/api\//, "");
19512
19529
  const parts = cleanPath ? cleanPath.split("/") : [];
19513
19530
  const allMethods = routeList.flatMap((r) => r.methods);
19514
19531
  for (const method of allMethods) {
@@ -19564,11 +19581,11 @@ ${typeExports}
19564
19581
  if (!outFile) {
19565
19582
  return `../app/${route.relativePath.replace(/\\/g, "/").replace(/\.(ts|tsx|js|jsx)$/, "")}`;
19566
19583
  }
19567
- const relativeImport = (0, import_path10.relative)((0, import_path10.dirname)(outFile), route.filePath).replace(/\\/g, "/").replace(/\.(ts|tsx|js|jsx)$/, "");
19584
+ const relativeImport = (0, import_path11.relative)((0, import_path11.dirname)(outFile), route.filePath).replace(/\\/g, "/").replace(/\.(ts|tsx|js|jsx)$/, "");
19568
19585
  return relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`;
19569
19586
  }
19570
- pathToRouteName(path36) {
19571
- return (path36 === "/api" ? "root" : path36.replace(/^\/api\//, "")).replace(/\//g, "_").replace(/[^a-zA-Z0-9_]/g, "");
19587
+ pathToRouteName(path37) {
19588
+ return (path37 === "/api" ? "root" : path37.replace(/^\/api\//, "")).replace(/\//g, "_").replace(/[^a-zA-Z0-9_]/g, "");
19572
19589
  }
19573
19590
  structureToTypeString(obj, indent) {
19574
19591
  const spaces = " ".repeat(indent);
@@ -19588,15 +19605,15 @@ ${typeExports}
19588
19605
  toTypePropertyKey(key) {
19589
19606
  return /^[$A-Z_][0-9A-Z_$]*$/i.test(key) ? key : JSON.stringify(key);
19590
19607
  }
19591
- getBaseExportName(path36) {
19592
- const cleanPath = path36.replace(/^\/api\//, "");
19608
+ getBaseExportName(path37) {
19609
+ const cleanPath = path37.replace(/^\/api\//, "");
19593
19610
  if (cleanPath === "") {
19594
19611
  return "api";
19595
19612
  }
19596
19613
  return cleanPath;
19597
19614
  }
19598
- getExportName(path36, method) {
19599
- const cleanPath = path36.replace(/^\/api\//, "");
19615
+ getExportName(path37, method) {
19616
+ const cleanPath = path37.replace(/^\/api\//, "");
19600
19617
  if (cleanPath === "") {
19601
19618
  return method.toLowerCase();
19602
19619
  }
@@ -19612,7 +19629,7 @@ ${typeExports}
19612
19629
  generateAPIIndex(outputPath) {
19613
19630
  const routes = this.scanAPIRoutes();
19614
19631
  const content = this.generateAPIRouter(routes);
19615
- (0, import_fs3.mkdirSync)((0, import_path10.dirname)(outputPath), { recursive: true });
19632
+ (0, import_fs3.mkdirSync)((0, import_path11.dirname)(outputPath), { recursive: true });
19616
19633
  writeFileIfChanged(outputPath, content);
19617
19634
  console.log(`\u2705 Generated API types for ${routes.length} routes`);
19618
19635
  }
@@ -19665,12 +19682,12 @@ function createRoutePattern(route) {
19665
19682
  }).join("/");
19666
19683
  }
19667
19684
  async function generateRouteTypes(options) {
19668
- const root = path25.resolve(options.root);
19685
+ const root = path26.resolve(options.root);
19669
19686
  const srcDir = options.srcDir || "src";
19670
19687
  const outFile = options.outFile || DEFAULT_OUT_FILE;
19671
- const outPath = path25.isAbsolute(outFile) ? outFile : path25.join(root, srcDir, outFile);
19688
+ const outPath = path26.isAbsolute(outFile) ? outFile : path26.join(root, srcDir, outFile);
19672
19689
  const content = await createRouteTypeDeclarations(options, outPath);
19673
- fs8.mkdirSync(path25.dirname(outPath), { recursive: true });
19690
+ fs8.mkdirSync(path26.dirname(outPath), { recursive: true });
19674
19691
  writeFileIfChanged(outPath, content);
19675
19692
  return outPath;
19676
19693
  }
@@ -19684,7 +19701,7 @@ async function createRouteTypeDeclarations(options, outPath) {
19684
19701
  const routeModulePatterns = /* @__PURE__ */ new Set();
19685
19702
  const glob = await import("fast-glob");
19686
19703
  for (const source of sourceRoots) {
19687
- const appDir = path25.join(source.root, source.srcDir, "app");
19704
+ const appDir = path26.join(source.root, source.srcDir, "app");
19688
19705
  if (fs8.existsSync(appDir)) {
19689
19706
  const routeModuleFiles = await glob.default(
19690
19707
  `**/{page,layout,loading,error}.{${componentExtensions.join(",")},md,mdx}`,
@@ -19721,7 +19738,7 @@ async function createRouteTypeDeclarations(options, outPath) {
19721
19738
  const routePathType = suppressLintOnLink ? "string" : renderTypeUnion(typeLiterals);
19722
19739
  const routePatternType = suppressLintOnLink ? "string" : renderTypeUnion(patternLiterals);
19723
19740
  const routeModulePatternType = renderTypeUnion(routeModulePatternLiterals);
19724
- const routeTypesImportPath = `./${path25.basename(outPath).replace(/\.d\.ts$/, "")}`;
19741
+ const routeTypesImportPath = `./${path26.basename(outPath).replace(/\.d\.ts$/, "")}`;
19725
19742
  const linkAugmentationBlock = suppressLintOnLink ? "" : `
19726
19743
  declare module "@farm.js/core/client" {
19727
19744
  interface LinkDefaultRoute {
@@ -19768,11 +19785,11 @@ ${renderTypeAlias("RouteModulePattern", routeModulePatternType)}${linkAugmentati
19768
19785
  `;
19769
19786
  return content;
19770
19787
  }
19771
- var path25, fs8, DEFAULT_OUT_FILE;
19788
+ var path26, fs8, DEFAULT_OUT_FILE;
19772
19789
  var init_generate_route_types = __esm({
19773
19790
  "src/routing/generate-route-types.ts"() {
19774
19791
  "use strict";
19775
- path25 = __toESM(require("path"));
19792
+ path26 = __toESM(require("path"));
19776
19793
  fs8 = __toESM(require("fs"));
19777
19794
  init_utils();
19778
19795
  init_route_slots();
@@ -19793,17 +19810,17 @@ var init_generate_route_types = __esm({
19793
19810
 
19794
19811
  // src/env-types.ts
19795
19812
  async function generateEnvTypes(options) {
19796
- const root = path26.resolve(options.root);
19813
+ const root = path27.resolve(options.root);
19797
19814
  const srcDir = options.srcDir || "src";
19798
19815
  const outFile = options.outFile || DEFAULT_OUT_FILE2;
19799
- const outPath = path26.isAbsolute(outFile) ? outFile : path26.join(root, srcDir, outFile);
19816
+ const outPath = path27.isAbsolute(outFile) ? outFile : path27.join(root, srcDir, outFile);
19800
19817
  const content = createEnvTypeDeclarations(options, outPath);
19801
- fs9.mkdirSync(path26.dirname(outPath), { recursive: true });
19818
+ fs9.mkdirSync(path27.dirname(outPath), { recursive: true });
19802
19819
  writeFileIfChanged(outPath, content);
19803
19820
  return outPath;
19804
19821
  }
19805
19822
  function createEnvTypeDeclarations(options, outPath) {
19806
- const root = path26.resolve(options.root);
19823
+ const root = path27.resolve(options.root);
19807
19824
  const configPath = findConfigPath(root, options.configPath);
19808
19825
  const configPaths = [
19809
19826
  ...(options.layerConfigPaths ?? []).filter((value) => fs9.existsSync(value)),
@@ -19866,11 +19883,11 @@ export {};
19866
19883
  }
19867
19884
  function findConfigPath(root, configPath) {
19868
19885
  if (configPath) {
19869
- const resolvedPath = path26.isAbsolute(configPath) ? configPath : path26.join(root, configPath);
19886
+ const resolvedPath = path27.isAbsolute(configPath) ? configPath : path27.join(root, configPath);
19870
19887
  return fs9.existsSync(resolvedPath) ? resolvedPath : null;
19871
19888
  }
19872
19889
  for (const filename of CONFIG_FILENAMES2) {
19873
- const resolvedPath = path26.join(root, filename);
19890
+ const resolvedPath = path27.join(root, filename);
19874
19891
  if (fs9.existsSync(resolvedPath)) {
19875
19892
  return resolvedPath;
19876
19893
  }
@@ -19931,15 +19948,15 @@ export {};
19931
19948
  `;
19932
19949
  }
19933
19950
  function toTypeImportPath(outPath, targetPath) {
19934
- const relativePath2 = path26.relative(path26.dirname(outPath), targetPath).replace(/\\/g, "/").replace(/\.(tsx?|jsx?|mjs|cjs|mts|cts)$/, "");
19951
+ const relativePath2 = path27.relative(path27.dirname(outPath), targetPath).replace(/\\/g, "/").replace(/\.(tsx?|jsx?|mjs|cjs|mts|cts)$/, "");
19935
19952
  return relativePath2.startsWith(".") ? relativePath2 : `./${relativePath2}`;
19936
19953
  }
19937
- var fs9, path26, DEFAULT_OUT_FILE2, CONFIG_FILENAMES2;
19954
+ var fs9, path27, DEFAULT_OUT_FILE2, CONFIG_FILENAMES2;
19938
19955
  var init_env_types = __esm({
19939
19956
  "src/env-types.ts"() {
19940
19957
  "use strict";
19941
19958
  fs9 = __toESM(require("fs"));
19942
- path26 = __toESM(require("path"));
19959
+ path27 = __toESM(require("path"));
19943
19960
  init_write_file_if_changed();
19944
19961
  DEFAULT_OUT_FILE2 = "farm-env.d.ts";
19945
19962
  CONFIG_FILENAMES2 = [
@@ -20074,7 +20091,7 @@ var init_type_generator2 = __esm({
20074
20091
 
20075
20092
  // src/type-artifacts.ts
20076
20093
  async function generateFarmTypeArtifacts(options) {
20077
- const root = (0, import_path11.resolve)(options.root);
20094
+ const root = (0, import_path12.resolve)(options.root);
20078
20095
  const srcDir = options.srcDir || "src";
20079
20096
  const shouldGenerateRoutes = options.routes !== false;
20080
20097
  const shouldGenerateApi = options.api !== false;
@@ -20087,7 +20104,7 @@ async function generateFarmTypeArtifacts(options) {
20087
20104
  apiRoutes: [],
20088
20105
  stalePaths: []
20089
20106
  };
20090
- const unifiedTypesPath = (0, import_path11.join)(root, srcDir, "farm.d.ts");
20107
+ const unifiedTypesPath = (0, import_path12.join)(root, srcDir, "farm.d.ts");
20091
20108
  const shouldRefreshUnifiedTypes = shouldGenerateRoutes && !options.routeTypesOutFile || shouldGenerateEnv && !options.envTypesOutFile || shouldGenerateI18n && !options.i18nTypesOutFile;
20092
20109
  const unifiedSections = [];
20093
20110
  if (shouldRefreshUnifiedTypes && !options.routeTypesOutFile) {
@@ -20123,7 +20140,7 @@ async function generateFarmTypeArtifacts(options) {
20123
20140
  if (shouldGenerateApi) {
20124
20141
  const generator = new APITypeGenerator(appDirs);
20125
20142
  const apiRoutes = generator.scanAPIRoutes();
20126
- const apiTypesPath = options.apiTypesOutFile ? (0, import_path11.resolve)(root, options.apiTypesOutFile) : (0, import_path11.join)(root, srcDir, "lib", "api.generated.ts");
20143
+ const apiTypesPath = options.apiTypesOutFile ? (0, import_path12.resolve)(root, options.apiTypesOutFile) : (0, import_path12.join)(root, srcDir, "lib", "api.generated.ts");
20127
20144
  const content = generator.generateAPIRouter(apiRoutes, { outFile: apiTypesPath });
20128
20145
  writeOrCheckGeneratedFile(apiTypesPath, content, options.check, result.stalePaths);
20129
20146
  result.apiTypesPath = apiTypesPath;
@@ -20223,15 +20240,15 @@ ${unifiedSections.map((section) => section.trimEnd()).join("\n\n")}
20223
20240
  return result;
20224
20241
  }
20225
20242
  function resolveGeneratedPath(root, srcDir, outFile, relativeToSrc = true) {
20226
- if ((0, import_path11.isAbsolute)(outFile)) return (0, import_path11.resolve)(outFile);
20227
- return (0, import_path11.resolve)(root, relativeToSrc ? (0, import_path11.join)(srcDir, outFile) : outFile);
20243
+ if ((0, import_path12.isAbsolute)(outFile)) return (0, import_path12.resolve)(outFile);
20244
+ return (0, import_path12.resolve)(root, relativeToSrc ? (0, import_path12.join)(srcDir, outFile) : outFile);
20228
20245
  }
20229
20246
  function writeOrCheckGeneratedFile(filePath, content, check, stalePaths) {
20230
20247
  if (check) {
20231
20248
  checkGeneratedFile(filePath, content, stalePaths);
20232
20249
  return;
20233
20250
  }
20234
- (0, import_fs4.mkdirSync)((0, import_path11.dirname)(filePath), { recursive: true });
20251
+ (0, import_fs4.mkdirSync)((0, import_path12.dirname)(filePath), { recursive: true });
20235
20252
  writeFileIfChanged(filePath, content);
20236
20253
  }
20237
20254
  function checkGeneratedFile(filePath, content, stalePaths) {
@@ -20241,7 +20258,7 @@ function checkGeneratedFile(filePath, content, stalePaths) {
20241
20258
  }
20242
20259
  function removeLegacyTypeArtifacts(root, srcDir) {
20243
20260
  for (const [fileName, marker] of LEGACY_TYPE_ARTIFACTS) {
20244
- const filePath = (0, import_path11.join)(root, srcDir, fileName);
20261
+ const filePath = (0, import_path12.join)(root, srcDir, fileName);
20245
20262
  if (!(0, import_fs4.existsSync)(filePath)) continue;
20246
20263
  const source = (0, import_fs4.readFileSync)(filePath, "utf8");
20247
20264
  if (source.includes(marker)) {
@@ -20251,17 +20268,17 @@ function removeLegacyTypeArtifacts(root, srcDir) {
20251
20268
  }
20252
20269
  function collectLegacyTypeArtifacts(root, srcDir, stalePaths) {
20253
20270
  for (const [fileName, marker] of LEGACY_TYPE_ARTIFACTS) {
20254
- const filePath = (0, import_path11.join)(root, srcDir, fileName);
20271
+ const filePath = (0, import_path12.join)(root, srcDir, fileName);
20255
20272
  if (!(0, import_fs4.existsSync)(filePath)) continue;
20256
20273
  if ((0, import_fs4.readFileSync)(filePath, "utf8").includes(marker)) stalePaths.push(filePath);
20257
20274
  }
20258
20275
  }
20259
- var import_fs4, import_path11, LEGACY_TYPE_ARTIFACTS;
20276
+ var import_fs4, import_path12, LEGACY_TYPE_ARTIFACTS;
20260
20277
  var init_type_artifacts = __esm({
20261
20278
  "src/type-artifacts.ts"() {
20262
20279
  "use strict";
20263
20280
  import_fs4 = require("fs");
20264
- import_path11 = require("path");
20281
+ import_path12 = require("path");
20265
20282
  init_type_generator();
20266
20283
  init_generate_route_types();
20267
20284
  init_env_types();
@@ -20404,9 +20421,9 @@ function devServableFileExists(pathname, baseDirs) {
20404
20421
  if (!relativePathname) return false;
20405
20422
  for (const baseDir of baseDirs) {
20406
20423
  if (typeof baseDir !== "string" || baseDir.length === 0) continue;
20407
- const resolvedBase = path28.resolve(baseDir);
20408
- const candidate = path28.resolve(resolvedBase, relativePathname);
20409
- if (!candidate.startsWith(resolvedBase + path28.sep)) continue;
20424
+ const resolvedBase = path29.resolve(baseDir);
20425
+ const candidate = path29.resolve(resolvedBase, relativePathname);
20426
+ if (!candidate.startsWith(resolvedBase + path29.sep)) continue;
20410
20427
  try {
20411
20428
  if (fs10.existsSync(candidate) && fs10.statSync(candidate).isFile()) {
20412
20429
  return true;
@@ -20416,12 +20433,12 @@ function devServableFileExists(pathname, baseDirs) {
20416
20433
  }
20417
20434
  return false;
20418
20435
  }
20419
- var fs10, path28;
20436
+ var fs10, path29;
20420
20437
  var init_dev_static = __esm({
20421
20438
  "src/dev-static.ts"() {
20422
20439
  "use strict";
20423
20440
  fs10 = __toESM(require("fs"));
20424
- path28 = __toESM(require("path"));
20441
+ path29 = __toESM(require("path"));
20425
20442
  __name(devServableFileExists, "devServableFileExists");
20426
20443
  }
20427
20444
  });
@@ -23592,8 +23609,8 @@ var init_generator = __esm({
23592
23609
  }
23593
23610
  routeGroups.get(key).push(route);
23594
23611
  }
23595
- for (const [path36, routeList] of routeGroups) {
23596
- const openAPIPath = this.convertToOpenAPIPath(path36);
23612
+ for (const [path37, routeList] of routeGroups) {
23613
+ const openAPIPath = this.convertToOpenAPIPath(path37);
23597
23614
  spec.paths[openAPIPath] = {};
23598
23615
  for (const route of routeList) {
23599
23616
  for (const method of route.methods) {
@@ -23613,8 +23630,8 @@ var init_generator = __esm({
23613
23630
  /**
23614
23631
  * Convert Farm.js API path to OpenAPI path format
23615
23632
  */
23616
- convertToOpenAPIPath(path36) {
23617
- return path36.replace(/^\/api/, "");
23633
+ convertToOpenAPIPath(path37) {
23634
+ return path37.replace(/^\/api/, "");
23618
23635
  }
23619
23636
  /**
23620
23637
  * Extract request body schema from endpoint
@@ -23776,8 +23793,8 @@ var init_generator = __esm({
23776
23793
  /**
23777
23794
  * Generate operation summary
23778
23795
  */
23779
- generateSummary(path36, method) {
23780
- const cleanPath = path36.replace(/^\/api\//, "");
23796
+ generateSummary(path37, method) {
23797
+ const cleanPath = path37.replace(/^\/api\//, "");
23781
23798
  const pathParts = cleanPath.split("/");
23782
23799
  const lastPart = pathParts[pathParts.length - 1];
23783
23800
  const action = method === "GET" ? "Get" : method === "QUERY" ? "Query" : method === "POST" ? "Create" : method === "PUT" ? "Update" : method === "DELETE" ? "Delete" : method === "PATCH" ? "Update" : method;
@@ -23786,22 +23803,22 @@ var init_generator = __esm({
23786
23803
  /**
23787
23804
  * Generate operation description
23788
23805
  */
23789
- generateDescription(path36, method) {
23790
- const cleanPath = path36.replace(/^\/api\//, "");
23806
+ generateDescription(path37, method) {
23807
+ const cleanPath = path37.replace(/^\/api\//, "");
23791
23808
  return `${method} ${cleanPath} endpoint`;
23792
23809
  }
23793
23810
  /**
23794
23811
  * Generate operation ID
23795
23812
  */
23796
- generateOperationId(path36, method) {
23797
- const cleanPath = path36.replace(/^\/api\//, "").replace(/\//g, "_");
23813
+ generateOperationId(path37, method) {
23814
+ const cleanPath = path37.replace(/^\/api\//, "").replace(/\//g, "_");
23798
23815
  return `${method.toLowerCase()}_${cleanPath}`;
23799
23816
  }
23800
23817
  /**
23801
23818
  * Generate tags for grouping operations
23802
23819
  */
23803
- generateTags(path36) {
23804
- const cleanPath = path36.replace(/^\/api\//, "");
23820
+ generateTags(path37) {
23821
+ const cleanPath = path37.replace(/^\/api\//, "");
23805
23822
  const pathParts = cleanPath.split("/");
23806
23823
  if (pathParts.length > 1) {
23807
23824
  return [pathParts[0]];
@@ -23814,8 +23831,8 @@ var init_generator = __esm({
23814
23831
  async generateSpecFile(routes, outputPath) {
23815
23832
  const spec = await this.generateSpec(routes);
23816
23833
  const fs12 = require("fs");
23817
- const path36 = require("path");
23818
- const dir = path36.dirname(outputPath);
23834
+ const path37 = require("path");
23835
+ const dir = path37.dirname(outputPath);
23819
23836
  if (!fs12.existsSync(dir)) {
23820
23837
  fs12.mkdirSync(dir, { recursive: true });
23821
23838
  }
@@ -26133,7 +26150,7 @@ function fileContainsProgrammaticPageRoute(file) {
26133
26150
  }
26134
26151
  function rewriteEarlySsrRelativeImports(options) {
26135
26152
  const cleanId = options.id.split("?", 1)[0];
26136
- if (!path32.isAbsolute(cleanId) || cleanId.replace(/\\/g, "/").includes("/node_modules/")) {
26153
+ if (!path33.isAbsolute(cleanId) || cleanId.replace(/\\/g, "/").includes("/node_modules/")) {
26137
26154
  return null;
26138
26155
  }
26139
26156
  const replacements = [];
@@ -26153,7 +26170,7 @@ function rewriteEarlySsrRelativeImports(options) {
26153
26170
  const suffixIndex = source.value.search(/[?#]/);
26154
26171
  const sourcePath = suffixIndex === -1 ? source.value : source.value.slice(0, suffixIndex);
26155
26172
  const suffix = suffixIndex === -1 ? "" : source.value.slice(suffixIndex);
26156
- const resolvedPath = path32.resolve(path32.dirname(cleanId), sourcePath);
26173
+ const resolvedPath = path33.resolve(path33.dirname(cleanId), sourcePath);
26157
26174
  replacements.push({
26158
26175
  start: source.start,
26159
26176
  end: source.end,
@@ -26228,7 +26245,7 @@ function farmPlugin(options = {}, initialPluginManager) {
26228
26245
  ...layerRoots.length ? {
26229
26246
  server: {
26230
26247
  fs: {
26231
- allow: [path32.resolve(options.root || process.cwd()), ...layerRoots]
26248
+ allow: [path33.resolve(options.root || process.cwd()), ...layerRoots]
26232
26249
  }
26233
26250
  }
26234
26251
  } : {}
@@ -26259,9 +26276,9 @@ function farmPlugin(options = {}, initialPluginManager) {
26259
26276
  },
26260
26277
  server
26261
26278
  );
26262
- const globalsCSSPath = path32.join(server.config.root, "src/app/globals.css");
26279
+ const globalsCSSPath = path33.join(server.config.root, "src/app/globals.css");
26263
26280
  if (!fs11.existsSync(globalsCSSPath)) {
26264
- const appDir = path32.join(server.config.root, "src/app");
26281
+ const appDir = path33.join(server.config.root, "src/app");
26265
26282
  if (!fs11.existsSync(appDir)) {
26266
26283
  fs11.mkdirSync(appDir, { recursive: true });
26267
26284
  }
@@ -26284,10 +26301,10 @@ function farmPlugin(options = {}, initialPluginManager) {
26284
26301
  });
26285
26302
  }
26286
26303
  const sourceRoots = getFarmSourceRoots(farmConfig);
26287
- server.watcher.add(sourceRoots.map((source) => path32.join(source.root, source.srcDir)));
26304
+ server.watcher.add(sourceRoots.map((source) => path33.join(source.root, source.srcDir)));
26288
26305
  if (farmConfig.i18n.enabled) {
26289
26306
  server.watcher.add(
26290
- farmConfig.i18n.messages.includes("{locale}") ? path32.dirname(farmConfig.i18n.messages) : farmConfig.i18n.messages
26307
+ farmConfig.i18n.messages.includes("{locale}") ? path33.dirname(farmConfig.i18n.messages) : farmConfig.i18n.messages
26291
26308
  );
26292
26309
  }
26293
26310
  const workflowConfig = farmConfig.workflows;
@@ -26297,7 +26314,7 @@ function farmPlugin(options = {}, initialPluginManager) {
26297
26314
  ...farmDocsDevRuntime?.getFarmDocsRouteTypeEntries(farmConfig.docs) ?? []
26298
26315
  ], "getExtraRouteTypes");
26299
26316
  const appDirSlugs = sourceRoots.map(
26300
- (source) => path32.join(source.root, source.srcDir, "app").replace(/\\/g, "/")
26317
+ (source) => path33.join(source.root, source.srcDir, "app").replace(/\\/g, "/")
26301
26318
  );
26302
26319
  const generateTypeArtifacts = /* @__PURE__ */ __name(async (reason, selection = ALL_TYPE_ARTIFACTS, log = false) => {
26303
26320
  try {
@@ -26338,7 +26355,7 @@ function farmPlugin(options = {}, initialPluginManager) {
26338
26355
  }, "generateTypeArtifacts");
26339
26356
  await generateTypeArtifacts("startup");
26340
26357
  const srcDirSlugs = sourceRoots.map(
26341
- (source) => path32.join(source.root, source.srcDir).replace(/\\/g, "/")
26358
+ (source) => path33.join(source.root, source.srcDir).replace(/\\/g, "/")
26342
26359
  );
26343
26360
  const layerConfigFiles = new Set(
26344
26361
  farmConfig.layers.map((layer) => layer.configFile?.replace(/\\/g, "/")).filter((file) => Boolean(file))
@@ -26456,7 +26473,7 @@ function farmPlugin(options = {}, initialPluginManager) {
26456
26473
  await apiRouteManager.discoverRoutes();
26457
26474
  let discoveredWorkflows = [];
26458
26475
  const hasWorkflowDirectory = workflowConfig.enabled && workflowConfig.dirs.some(
26459
- (dir) => fs11.existsSync(path32.isAbsolute(dir) ? dir : path32.join(farmConfig.root, dir))
26476
+ (dir) => fs11.existsSync(path33.isAbsolute(dir) ? dir : path33.join(farmConfig.root, dir))
26460
26477
  );
26461
26478
  if (hasWorkflowDirectory) {
26462
26479
  const { createFarmWorkflowRequestHandler: createFarmWorkflowRequestHandler2, discoverFarmWorkflows: discoverFarmWorkflows2 } = await loadFarmWorkflowsDevRuntime();
@@ -27941,8 +27958,8 @@ if (import.meta.hot) {
27941
27958
  }
27942
27959
  logger.info(`Found ${ssgPages.length} SSG pages, ${ssrRoutes.length} SSR routes`);
27943
27960
  logger.info("Pre-rendering SSG pages...");
27944
- const outDir = path32.join(server?.config.root || process.cwd(), options.outDir || "dist");
27945
- const clientDir = path32.join(outDir, "client");
27961
+ const outDir = path33.join(server?.config.root || process.cwd(), options.outDir || "dist");
27962
+ const clientDir = path33.join(outDir, "client");
27946
27963
  for (const page2 of ssgPages) {
27947
27964
  try {
27948
27965
  const staticRequest = new Request(new URL(page2.urlPath, "http://farm.static"));
@@ -27994,8 +28011,8 @@ if (import.meta.hot) {
27994
28011
  <script type="module" src="/assets/client.js"></script>
27995
28012
  </body>
27996
28013
  </html>`;
27997
- const outputPath = page2.urlPath === "/" ? path32.join(clientDir, "index.html") : path32.join(clientDir, page2.urlPath + ".html");
27998
- fs11.mkdirSync(path32.dirname(outputPath), { recursive: true });
28014
+ const outputPath = page2.urlPath === "/" ? path33.join(clientDir, "index.html") : path33.join(clientDir, page2.urlPath + ".html");
28015
+ fs11.mkdirSync(path33.dirname(outputPath), { recursive: true });
27999
28016
  fs11.writeFileSync(outputPath, fullHtml);
28000
28017
  const revalidateInfo = page2.revalidate ? ` (revalidate: ${page2.revalidate}s)` : "";
28001
28018
  logger.success(` \u2713 ${page2.urlPath}${revalidateInfo}`);
@@ -28004,7 +28021,7 @@ if (import.meta.hot) {
28004
28021
  logger.error(` \u2717 ${page2.urlPath}: ${error}`);
28005
28022
  }
28006
28023
  }
28007
- const manifestPath = path32.join(outDir, "__ssg_manifest.json");
28024
+ const manifestPath = path33.join(outDir, "__ssg_manifest.json");
28008
28025
  fs11.writeFileSync(
28009
28026
  manifestPath,
28010
28027
  JSON.stringify(
@@ -28040,9 +28057,9 @@ if (import.meta.hot) {
28040
28057
  }
28041
28058
  const currentFarmConfig = farmApp?.getConfig();
28042
28059
  const normalizedFile = file.replace(/\\/g, "/");
28043
- const currentSrcRoot = currentFarmConfig ? getFarmSourceRoots(currentFarmConfig).map((source) => path32.join(source.root, source.srcDir).replace(/\\/g, "/")).find((sourceRoot) => normalizedFile.startsWith(`${sourceRoot}/`)) || null : null;
28060
+ const currentSrcRoot = currentFarmConfig ? getFarmSourceRoots(currentFarmConfig).map((source) => path33.join(source.root, source.srcDir).replace(/\\/g, "/")).find((sourceRoot) => normalizedFile.startsWith(`${sourceRoot}/`)) || null : null;
28044
28061
  if (currentSrcRoot && normalizedFile.startsWith(`${currentSrcRoot}/`) && isProgrammaticRoutesFileName(normalizedFile)) {
28045
- logUpdate("PAGE", `updated ${path32.basename(file)}`);
28062
+ logUpdate("PAGE", `updated ${path33.basename(file)}`);
28046
28063
  for (const mod of modules) {
28047
28064
  server2.moduleGraph.invalidateModule(mod);
28048
28065
  }
@@ -29835,7 +29852,7 @@ function generateClientManifest(bundle) {
29835
29852
  }
29836
29853
  async function defineConfig2(config = {}) {
29837
29854
  const tailwindcss = (await import("@tailwindcss/vite")).default;
29838
- const appRoot = path32.resolve(config.root || process.cwd());
29855
+ const appRoot = path33.resolve(config.root || process.cwd());
29839
29856
  if (config.extends?.length) {
29840
29857
  const { config: layeredConfig } = await Promise.resolve().then(() => (init_layers(), layers_exports)).then(
29841
29858
  ({ resolveFarmLayers: resolveFarmLayers2 }) => resolveFarmLayers2(config, {
@@ -30049,7 +30066,7 @@ async function defineConfig2(config = {}) {
30049
30066
  }
30050
30067
  };
30051
30068
  }
30052
- var fs11, path32, import_node_url8, ALL_TYPE_ARTIFACTS, createEmptyTypeArtifactSelection, FARM_I18N_CLIENT_BRIDGE_ID, EMPTY_FARM_DOCS_SEARCH_CLIENT_RUNTIME, FARM_CONFIG_FILENAMES;
30069
+ var fs11, path33, import_node_url8, ALL_TYPE_ARTIFACTS, createEmptyTypeArtifactSelection, FARM_I18N_CLIENT_BRIDGE_ID, EMPTY_FARM_DOCS_SEARCH_CLIENT_RUNTIME, FARM_CONFIG_FILENAMES;
30053
30070
  var init_vite2 = __esm({
30054
30071
  "src/vite.ts"() {
30055
30072
  "use strict";
@@ -30070,7 +30087,7 @@ var init_vite2 = __esm({
30070
30087
  init_route_context();
30071
30088
  init_devtools_config();
30072
30089
  fs11 = __toESM(require("fs"));
30073
- path32 = __toESM(require("path"));
30090
+ path33 = __toESM(require("path"));
30074
30091
  import_node_url8 = require("url");
30075
30092
  init_layers();
30076
30093
  init_environment_vite();
@@ -30857,13 +30874,13 @@ async function createNitroConfig(config, routeManager, apiRouteManager, serverRe
30857
30874
  const root = config.root || process.cwd();
30858
30875
  const srcDir = config.srcDir || "src";
30859
30876
  const distDir = ".farm";
30860
- const nitroBuildDir = import_path13.default.join(root, distDir, ".nitro");
30861
- const outputDir = import_path13.default.join(root, distDir, ".output");
30862
- const serverDir = import_path13.default.join(nitroBuildDir, "server");
30877
+ const nitroBuildDir = import_path14.default.join(root, distDir, ".nitro");
30878
+ const outputDir = import_path14.default.join(root, distDir, ".output");
30879
+ const serverDir = import_path14.default.join(nitroBuildDir, "server");
30863
30880
  const { mkdir: mkdir2, writeFile } = await import("fs/promises");
30864
30881
  await mkdir2(serverDir, { recursive: true });
30865
- await mkdir2(import_path13.default.join(serverDir, "api"), { recursive: true });
30866
- await mkdir2(import_path13.default.join(serverDir, "routes"), { recursive: true });
30882
+ await mkdir2(import_path14.default.join(serverDir, "api"), { recursive: true });
30883
+ await mkdir2(import_path14.default.join(serverDir, "routes"), { recursive: true });
30867
30884
  const farmWorkflows = await prepareFarmWorkflowsForNitro({
30868
30885
  ...config,
30869
30886
  distDir
@@ -30874,13 +30891,13 @@ async function createNitroConfig(config, routeManager, apiRouteManager, serverRe
30874
30891
  });
30875
30892
  const scheduledTasks = mergeScheduledTasks(farmWorkflows.scheduledTasks, farmCron.scheduledTasks);
30876
30893
  const cloudflareCronConfig = createFarmCronCloudflareConfig(farmCron.jobs);
30877
- const registryFile = import_path13.default.join(serverDir, "farm-registry.ts");
30894
+ const registryFile = import_path14.default.join(serverDir, "farm-registry.ts");
30878
30895
  const routePaths = {};
30879
30896
  for (const [pattern, entry] of routeManager.getRoutes()) {
30880
30897
  const bundledPath = entry.modulePath.replace(/.*\/src\/app\//, "").replace(/\.(tsx?|jsx?)$/, ".js");
30881
30898
  routePaths[pattern] = bundledPath;
30882
30899
  }
30883
- const clientManifestPath = import_path13.default.join(root, distDir, "client", "farm-client-manifest.json");
30900
+ const clientManifestPath = import_path14.default.join(root, distDir, "client", "farm-client-manifest.json");
30884
30901
  await writeFile(
30885
30902
  registryFile,
30886
30903
  `
@@ -30904,8 +30921,8 @@ export const farmRegistry: {
30904
30921
  `,
30905
30922
  "utf-8"
30906
30923
  );
30907
- const apiHandlerFile = import_path13.default.join(serverDir, "api", "[...].ts");
30908
- await mkdir2(import_path13.default.dirname(apiHandlerFile), { recursive: true });
30924
+ const apiHandlerFile = import_path14.default.join(serverDir, "api", "[...].ts");
30925
+ await mkdir2(import_path14.default.dirname(apiHandlerFile), { recursive: true });
30909
30926
  await writeFile(
30910
30927
  apiHandlerFile,
30911
30928
  `
@@ -31049,8 +31066,8 @@ export default defineEventHandler(async (event: H3Event) => {
31049
31066
  `,
31050
31067
  "utf-8"
31051
31068
  );
31052
- const ssrHandlerFile = import_path13.default.join(serverDir, "routes", "[...].ts");
31053
- await mkdir2(import_path13.default.dirname(ssrHandlerFile), { recursive: true });
31069
+ const ssrHandlerFile = import_path14.default.join(serverDir, "routes", "[...].ts");
31070
+ await mkdir2(import_path14.default.dirname(ssrHandlerFile), { recursive: true });
31054
31071
  await writeFile(
31055
31072
  ssrHandlerFile,
31056
31073
  `
@@ -31417,16 +31434,16 @@ export default defineEventHandler(async (event: H3Event) => {
31417
31434
  // from creating its own .output directory inside .nitro
31418
31435
  dir: outputDir,
31419
31436
  // .farm/.output
31420
- serverDir: import_path13.default.join(outputDir, "server"),
31437
+ serverDir: import_path14.default.join(outputDir, "server"),
31421
31438
  // .farm/.output/server
31422
- publicDir: import_path13.default.join(outputDir, "public")
31439
+ publicDir: import_path14.default.join(outputDir, "public")
31423
31440
  // .farm/.output/public
31424
31441
  },
31425
31442
  // Use Nitro hooks to populate the runtime registry
31426
31443
  // This allows us to pass complex objects (route managers, renderers) at runtime
31427
31444
  hooks: {
31428
31445
  "build:before": /* @__PURE__ */ __name(async (nitro) => {
31429
- const registryPath = import_path13.default.join(serverDir, "farm-registry.ts");
31446
+ const registryPath = import_path14.default.join(serverDir, "farm-registry.ts");
31430
31447
  const { farmRegistry } = await import(
31431
31448
  /* @vite-ignore */
31432
31449
  registryPath
@@ -31438,7 +31455,7 @@ export default defineEventHandler(async (event: H3Event) => {
31438
31455
  }
31439
31456
  farmRegistry.routePaths = routePaths2;
31440
31457
  try {
31441
- const clientManifestPath2 = import_path13.default.join(
31458
+ const clientManifestPath2 = import_path14.default.join(
31442
31459
  root,
31443
31460
  distDir,
31444
31461
  "client",
@@ -31478,12 +31495,12 @@ export default defineEventHandler(async (event: H3Event) => {
31478
31495
  publicAssets: [
31479
31496
  {
31480
31497
  baseURL: "/",
31481
- dir: import_path13.default.join(root, "public")
31498
+ dir: import_path14.default.join(root, "public")
31482
31499
  },
31483
31500
  // Include client build assets
31484
31501
  {
31485
31502
  baseURL: "/",
31486
- dir: import_path13.default.join(root, distDir, "client")
31503
+ dir: import_path14.default.join(root, distDir, "client")
31487
31504
  }
31488
31505
  ],
31489
31506
  // Build configuration
@@ -31517,11 +31534,11 @@ export default defineEventHandler(async (event: H3Event) => {
31517
31534
  function getNitroPreset(preset) {
31518
31535
  return preset || "node-server";
31519
31536
  }
31520
- var import_path13;
31537
+ var import_path14;
31521
31538
  var init_nitro = __esm({
31522
31539
  "src/nitro/index.ts"() {
31523
31540
  "use strict";
31524
- import_path13 = __toESM(require("path"));
31541
+ import_path14 = __toESM(require("path"));
31525
31542
  init_workflows();
31526
31543
  init_cron();
31527
31544
  init_route_rules();
@@ -31543,7 +31560,7 @@ module.exports = __toCommonJS(build_runtime_exports);
31543
31560
 
31544
31561
  // src/build/index.ts
31545
31562
  init_config4();
31546
- var import_path14 = __toESM(require("path"));
31563
+ var import_path15 = __toESM(require("path"));
31547
31564
  var import_node_fs12 = require("fs");
31548
31565
  init_utils();
31549
31566
  init_app();
@@ -31552,9 +31569,61 @@ init_layers();
31552
31569
 
31553
31570
  // src/nitro/universal-build.ts
31554
31571
  init_config4();
31572
+
31573
+ // src/nitro/client-css-href.ts
31574
+ var import_path8 = __toESM(require("path"));
31575
+ var FARM_CLIENT_CSS_HREF_PLACEHOLDER = "/__farm_client_css_href__";
31576
+ var FARM_CLIENT_JS_SRC_PLACEHOLDER = "/__farm_client_js_src__";
31577
+ async function hashAndCopy(sourcePath, destinationDir, hashedName) {
31578
+ const fs12 = await import("fs/promises");
31579
+ try {
31580
+ const bytes = await fs12.readFile(sourcePath);
31581
+ if (bytes.length === 0) return null;
31582
+ const { createHash: createHash5 } = await import("crypto");
31583
+ const hash = createHash5("sha256").update(bytes).digest("hex").slice(0, 8);
31584
+ const name2 = hashedName(hash);
31585
+ await fs12.mkdir(destinationDir, { recursive: true });
31586
+ await fs12.writeFile(import_path8.default.join(destinationDir, name2), bytes);
31587
+ return name2;
31588
+ } catch {
31589
+ return null;
31590
+ }
31591
+ }
31592
+ __name(hashAndCopy, "hashAndCopy");
31593
+ async function resolveHashedClientCssHref(clientOutputDir) {
31594
+ const name2 = await hashAndCopy(
31595
+ import_path8.default.join(clientOutputDir, "farm-client.css"),
31596
+ import_path8.default.join(clientOutputDir, "assets"),
31597
+ (hash) => `farm-client-h${hash}.css`
31598
+ );
31599
+ return name2 ? `/assets/${name2}` : "/farm-client.css";
31600
+ }
31601
+ __name(resolveHashedClientCssHref, "resolveHashedClientCssHref");
31602
+ async function findFingerprintedClientEntry(clientOutputDir) {
31603
+ const fs12 = await import("fs/promises");
31604
+ try {
31605
+ const entries = await fs12.readdir(clientOutputDir);
31606
+ return entries.find((name2) => /^farm-client-h[0-9a-f]+\.js$/.test(name2)) ?? null;
31607
+ } catch {
31608
+ return null;
31609
+ }
31610
+ }
31611
+ __name(findFingerprintedClientEntry, "findFingerprintedClientEntry");
31612
+ async function resolveHashedClientJsSrc(clientOutputDir) {
31613
+ const entryName = await findFingerprintedClientEntry(clientOutputDir);
31614
+ if (!entryName) return "/farm-client.js";
31615
+ const fs12 = await import("fs/promises");
31616
+ const shim = `export * from "./${entryName}";
31617
+ `;
31618
+ await fs12.writeFile(import_path8.default.join(clientOutputDir, "farm-client.js"), shim);
31619
+ return `/${entryName}`;
31620
+ }
31621
+ __name(resolveHashedClientJsSrc, "resolveHashedClientJsSrc");
31622
+
31623
+ // src/nitro/universal-build.ts
31555
31624
  init_client_plugin_build();
31556
31625
  var import_os = __toESM(require("os"));
31557
- var import_path12 = __toESM(require("path"));
31626
+ var import_path13 = __toESM(require("path"));
31558
31627
  var import_fs5 = require("fs");
31559
31628
  var import_url3 = require("url");
31560
31629
  var import_module2 = require("module");
@@ -31572,13 +31641,13 @@ init_search_client();
31572
31641
  init_fonts();
31573
31642
 
31574
31643
  // src/route-runtime-manifest.ts
31575
- var import_path8 = __toESM(require("path"));
31644
+ var import_path9 = __toESM(require("path"));
31576
31645
  init_deployment();
31577
31646
  init_route_runtime();
31578
31647
  init_ssg();
31579
31648
  var FARM_ROUTE_RUNTIME_MANIFEST = "route-runtime-manifest.json";
31580
31649
  async function createFarmRouteRuntimeManifest(options) {
31581
- const root = import_path8.default.resolve(options.root || options.config.root || process.cwd());
31650
+ const root = import_path9.default.resolve(options.root || options.config.root || process.cwd());
31582
31651
  const routes = [];
31583
31652
  for (const [pattern, entry] of options.routeManager.getRoutes()) {
31584
31653
  const routeModule = await options.routeManager.loadRouteModule(entry.modulePath);
@@ -31626,7 +31695,7 @@ async function createFarmRouteRuntimeManifest(options) {
31626
31695
  __name(createFarmRouteRuntimeManifest, "createFarmRouteRuntimeManifest");
31627
31696
  async function writeFarmRouteRuntimeManifest(directory, manifest) {
31628
31697
  const fs12 = await import("fs/promises");
31629
- const manifestPath = import_path8.default.join(directory, FARM_ROUTE_RUNTIME_MANIFEST);
31698
+ const manifestPath = import_path9.default.join(directory, FARM_ROUTE_RUNTIME_MANIFEST);
31630
31699
  await fs12.mkdir(directory, { recursive: true });
31631
31700
  await fs12.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
31632
31701
  `);
@@ -31666,13 +31735,13 @@ function normalizeManifestSource(root, modulePath) {
31666
31735
  const queryIndex = modulePath.indexOf("?");
31667
31736
  const filePath = queryIndex === -1 ? modulePath : modulePath.slice(0, queryIndex);
31668
31737
  const query = queryIndex === -1 ? "" : modulePath.slice(queryIndex);
31669
- const relativePath2 = import_path8.default.isAbsolute(filePath) ? import_path8.default.relative(root, filePath) : filePath;
31738
+ const relativePath2 = import_path9.default.isAbsolute(filePath) ? import_path9.default.relative(root, filePath) : filePath;
31670
31739
  return `${relativePath2.replace(/\\/g, "/")}${query}`;
31671
31740
  }
31672
31741
  __name(normalizeManifestSource, "normalizeManifestSource");
31673
31742
 
31674
31743
  // src/nitro/vercel-route-runtime.ts
31675
- var import_path9 = __toESM(require("path"));
31744
+ var import_path10 = __toESM(require("path"));
31676
31745
  init_route_runtime();
31677
31746
  async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs12) {
31678
31747
  const dynamicRoutes = manifest.routes.filter(
@@ -31693,8 +31762,8 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs12)
31693
31762
  group.routes.push(route);
31694
31763
  groups.set(key, group);
31695
31764
  }
31696
- const functionsDir = import_path9.default.join(outputDir, "functions");
31697
- const baseFunctionDir = import_path9.default.join(functionsDir, "__nitro.func");
31765
+ const functionsDir = import_path10.default.join(outputDir, "functions");
31766
+ const baseFunctionDir = import_path10.default.join(functionsDir, "__nitro.func");
31698
31767
  const destinations = /* @__PURE__ */ new Map();
31699
31768
  let groupIndex = 0;
31700
31769
  for (const [key, group] of groups) {
@@ -31704,7 +31773,7 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs12)
31704
31773
  }
31705
31774
  groupIndex += 1;
31706
31775
  const functionName = `__farm_runtime_${groupIndex}`;
31707
- const functionDir = import_path9.default.join(functionsDir, `${functionName}.func`);
31776
+ const functionDir = import_path10.default.join(functionsDir, `${functionName}.func`);
31708
31777
  await fs12.cp(baseFunctionDir, functionDir, { recursive: true, force: true });
31709
31778
  await configureVercelFunction(functionDir, group.config, fs12);
31710
31779
  destinations.set(key, `/${functionName}`);
@@ -31754,7 +31823,7 @@ function farmRoutePatternToVercelSource(pattern) {
31754
31823
  }
31755
31824
  __name(farmRoutePatternToVercelSource, "farmRoutePatternToVercelSource");
31756
31825
  async function configureVercelFunction(functionDir, config, fs12) {
31757
- const configPath = import_path9.default.join(functionDir, ".vc-config.json");
31826
+ const configPath = import_path10.default.join(functionDir, ".vc-config.json");
31758
31827
  const current = JSON.parse(await fs12.readFile(configPath, "utf8"));
31759
31828
  const next = {
31760
31829
  ...current,
@@ -31803,8 +31872,9 @@ function createFarmVercelImmutableAssetRoute(basePath = "/") {
31803
31872
  const normalizedBasePath = normalizeBasePath3(basePath);
31804
31873
  const escapedBasePath = escapeRegex(normalizedBasePath);
31805
31874
  const prefix = escapedBasePath ? `/${escapedBasePath}` : "";
31875
+ const fingerprint = "-h(?:[a-fA-F0-9]{8}|[a-fA-F0-9]{12}|[a-fA-F0-9]{16})";
31806
31876
  return {
31807
- src: `^${prefix}/(?:assets|chunks)/(?:.+/)*[^/]+-h(?:[a-fA-F0-9]{8}|[a-fA-F0-9]{12}|[a-fA-F0-9]{16})\\.(?!(?:[hH][tT][mM][lL]?)$)[^/]+$`,
31877
+ src: `^${prefix}/(?:(?:assets|chunks)/(?:.+/)*[^/]+|farm-client)${fingerprint}\\.(?!(?:[hH][tT][mM][lL]?)$)[^/]+$`,
31808
31878
  headers: {
31809
31879
  "Cache-Control": FARM_IMMUTABLE_ASSET_CACHE_CONTROL
31810
31880
  },
@@ -32126,7 +32196,7 @@ function preloadFarmNitroRuntime() {
32126
32196
  }
32127
32197
  __name(preloadFarmNitroRuntime, "preloadFarmNitroRuntime");
32128
32198
  var _filename = typeof import_meta.url !== "undefined" ? (0, import_url3.fileURLToPath)(import_meta.url) : "";
32129
- var _dirname = import_path12.default.dirname(_filename);
32199
+ var _dirname = import_path13.default.dirname(_filename);
32130
32200
  var NODE_BUILTIN_MODULES = /* @__PURE__ */ new Set([
32131
32201
  ...import_module2.builtinModules,
32132
32202
  ...import_module2.builtinModules.map((moduleName) => `node:${moduleName}`)
@@ -32155,14 +32225,14 @@ var FARM_SSR_PACKAGE_IMPORT = "#farm-ssr-entry";
32155
32225
  var FARM_SSR_OUTPUT_DIR = "farm-ssr";
32156
32226
  var FARM_CLIENT_BUILD_TARGET = ["es2020", "edge88", "firefox78", "chrome87", "safari14"];
32157
32227
  function resolveNitroRuntimeDependency(root, specifier) {
32158
- const projectRequire = (0, import_module2.createRequire)(import_path12.default.join(root, "package.json"));
32228
+ const projectRequire = (0, import_module2.createRequire)(import_path13.default.join(root, "package.json"));
32159
32229
  let runtimeRequire = projectRequire;
32160
32230
  try {
32161
32231
  runtimeRequire = (0, import_module2.createRequire)(projectRequire.resolve("@farm.js/core"));
32162
32232
  } catch {
32163
32233
  }
32164
32234
  const nitroEntry = runtimeRequire.resolve("nitro");
32165
- return (0, import_module2.createRequire)(nitroEntry).resolve(specifier).split(import_path12.default.sep).join("/");
32235
+ return (0, import_module2.createRequire)(nitroEntry).resolve(specifier).split(import_path13.default.sep).join("/");
32166
32236
  }
32167
32237
  __name(resolveNitroRuntimeDependency, "resolveNitroRuntimeDependency");
32168
32238
  function cloneConfigValue(value, seen = /* @__PURE__ */ new WeakMap()) {
@@ -32256,7 +32326,7 @@ function createMetadataImageWasmPlugin() {
32256
32326
  return null;
32257
32327
  }
32258
32328
  const requestPath = source.slice(0, -"?module".length);
32259
- const resolvedPath = import_path12.default.isAbsolute(requestPath) ? requestPath : import_path12.default.resolve(import_path12.default.dirname(importer.split("?", 1)[0]), requestPath);
32329
+ const resolvedPath = import_path13.default.isAbsolute(requestPath) ? requestPath : import_path13.default.resolve(import_path13.default.dirname(importer.split("?", 1)[0]), requestPath);
32260
32330
  return `${FARM_METADATA_IMAGE_WASM_PREFIX}${resolvedPath}`;
32261
32331
  },
32262
32332
  load(id) {
@@ -32282,11 +32352,11 @@ function collectSSRExternalPackages(ssrBundle) {
32282
32352
  for (const importId of [...output.imports, ...output.dynamicImports]) {
32283
32353
  const normalizedImportId = importId.replace(/\\/g, "/");
32284
32354
  const normalizedId = normalizedImportId.replace(/^\.\//, "");
32285
- const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ? import_path12.default.posix.normalize(import_path12.default.posix.join(import_path12.default.posix.dirname(fileName), normalizedImportId)) : null;
32355
+ const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ? import_path13.default.posix.normalize(import_path13.default.posix.join(import_path13.default.posix.dirname(fileName), normalizedImportId)) : null;
32286
32356
  if (emittedFiles.has(normalizedId) || resolvedRelativeId !== null && emittedFiles.has(resolvedRelativeId) || NODE_BUILTIN_MODULES.has(importId) || importId.startsWith("node:")) {
32287
32357
  continue;
32288
32358
  }
32289
- if (import_path12.default.isAbsolute(importId) || /^[A-Za-z]:[\\/]/.test(importId) || importId.startsWith("#") || importId.startsWith("\0")) {
32359
+ if (import_path13.default.isAbsolute(importId) || /^[A-Za-z]:[\\/]/.test(importId) || importId.startsWith("#") || importId.startsWith("\0")) {
32290
32360
  externalPackages.add(importId);
32291
32361
  continue;
32292
32362
  }
@@ -32299,15 +32369,15 @@ function collectSSRExternalPackages(ssrBundle) {
32299
32369
  }
32300
32370
  __name(collectSSRExternalPackages, "collectSSRExternalPackages");
32301
32371
  function createExternalSSRBundlePlugin(nitroEntryPath, ssrOutputDir, ssrEntryFile) {
32302
- const resolvedNitroEntry = import_path12.default.resolve(nitroEntryPath);
32303
- const resolvedSSREntry = import_path12.default.resolve(ssrOutputDir, ssrEntryFile);
32372
+ const resolvedNitroEntry = import_path13.default.resolve(nitroEntryPath);
32373
+ const resolvedSSREntry = import_path13.default.resolve(ssrOutputDir, ssrEntryFile);
32304
32374
  return {
32305
32375
  name: "farm-externalize-prebuilt-ssr",
32306
32376
  resolveId(source, importer) {
32307
- if (!importer || import_path12.default.resolve(importer) !== resolvedNitroEntry) {
32377
+ if (!importer || import_path13.default.resolve(importer) !== resolvedNitroEntry) {
32308
32378
  return null;
32309
32379
  }
32310
- const resolvedImport = import_path12.default.resolve(import_path12.default.dirname(importer), source);
32380
+ const resolvedImport = import_path13.default.resolve(import_path13.default.dirname(importer), source);
32311
32381
  if (resolvedImport !== resolvedSSREntry) return null;
32312
32382
  return { id: FARM_SSR_PACKAGE_IMPORT, external: true };
32313
32383
  }
@@ -32396,13 +32466,13 @@ function resolveBuildDocsContentDir(config, root) {
32396
32466
  if (!config.docs?.enabled) return null;
32397
32467
  const configuredContentDir = config.docs.contentDir || config.docs.config.contentDir;
32398
32468
  if (typeof configuredContentDir === "string" && configuredContentDir.trim()) {
32399
- const contentDir = import_path12.default.isAbsolute(configuredContentDir) ? configuredContentDir : import_path12.default.join(root, configuredContentDir);
32469
+ const contentDir = import_path13.default.isAbsolute(configuredContentDir) ? configuredContentDir : import_path13.default.join(root, configuredContentDir);
32400
32470
  return (0, import_fs5.existsSync)(contentDir) ? contentDir : null;
32401
32471
  }
32402
32472
  const entryDir = config.docs.config.entry || trimSlashes3(config.docs.entry) || "docs";
32403
- const appDocsDir = import_path12.default.join(root, config.srcDir || "src", "app", entryDir);
32473
+ const appDocsDir = import_path13.default.join(root, config.srcDir || "src", "app", entryDir);
32404
32474
  if ((0, import_fs5.existsSync)(appDocsDir)) return appDocsDir;
32405
- const rootDocsDir = import_path12.default.join(root, entryDir);
32475
+ const rootDocsDir = import_path13.default.join(root, entryDir);
32406
32476
  return (0, import_fs5.existsSync)(rootDocsDir) ? rootDocsDir : null;
32407
32477
  }
32408
32478
  __name(resolveBuildDocsContentDir, "resolveBuildDocsContentDir");
@@ -32420,7 +32490,7 @@ function hasProjectPostcssConfig(root) {
32420
32490
  ".postcssrc.mjs",
32421
32491
  ".postcssrc.ts"
32422
32492
  ];
32423
- const projectRequire = (0, import_module2.createRequire)(import_path12.default.join(root, "package.json"));
32493
+ const projectRequire = (0, import_module2.createRequire)(import_path13.default.join(root, "package.json"));
32424
32494
  return candidates.some((file) => {
32425
32495
  try {
32426
32496
  projectRequire.resolve(`./${file}`);
@@ -32444,7 +32514,7 @@ async function findFarmConfigPath(root) {
32444
32514
  "config.mjs"
32445
32515
  ];
32446
32516
  for (const candidate of candidates) {
32447
- const resolvedPath = import_path12.default.join(root, candidate);
32517
+ const resolvedPath = import_path13.default.join(root, candidate);
32448
32518
  try {
32449
32519
  await fs12.access(resolvedPath);
32450
32520
  return resolvedPath;
@@ -32489,7 +32559,7 @@ async function discoverMiddlewareRoutes(appDir) {
32489
32559
  if (middlewareFile) {
32490
32560
  discovered.push({
32491
32561
  path: routePath,
32492
- filePath: import_path12.default.join(dir, middlewareFile.name)
32562
+ filePath: import_path13.default.join(dir, middlewareFile.name)
32493
32563
  });
32494
32564
  }
32495
32565
  for (const entry of entries) {
@@ -32497,7 +32567,7 @@ async function discoverMiddlewareRoutes(appDir) {
32497
32567
  continue;
32498
32568
  }
32499
32569
  const childRoutePath = routePath === "/" ? `/${entry.name}` : `${routePath}/${entry.name}`;
32500
- await walk(import_path12.default.join(dir, entry.name), childRoutePath, discovered);
32570
+ await walk(import_path13.default.join(dir, entry.name), childRoutePath, discovered);
32501
32571
  }
32502
32572
  }
32503
32573
  __name(walk, "walk");
@@ -32562,7 +32632,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
32562
32632
  logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
32563
32633
  const fs12 = await import("fs/promises");
32564
32634
  const layoutRoutes = [];
32565
- const appDir = import_path12.default.join(root, srcDir, "app");
32635
+ const appDir = import_path13.default.join(root, srcDir, "app");
32566
32636
  async function findLayoutsForClient(dir, routePrefix = "/") {
32567
32637
  try {
32568
32638
  const entries = await fs12.readdir(dir, { withFileTypes: true });
@@ -32570,11 +32640,11 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
32570
32640
  if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?|vue|svelte)$/)) {
32571
32641
  layoutRoutes.push({
32572
32642
  pattern: routePrefix,
32573
- modulePath: import_path12.default.join(dir, entry.name)
32643
+ modulePath: import_path13.default.join(dir, entry.name)
32574
32644
  });
32575
32645
  } else if (entry.isDirectory() && !entry.name.startsWith(".") && !entry.name.startsWith("_")) {
32576
32646
  const childPrefix = routePrefix === "/" ? `/${entry.name}` : `${routePrefix}/${entry.name}`;
32577
- await findLayoutsForClient(import_path12.default.join(dir, entry.name), childPrefix);
32647
+ await findLayoutsForClient(import_path13.default.join(dir, entry.name), childPrefix);
32578
32648
  }
32579
32649
  }
32580
32650
  } catch {
@@ -32589,7 +32659,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
32589
32659
  layoutRoutes.push({ pattern, modulePath: entry.modulePath });
32590
32660
  }
32591
32661
  logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes and ${layoutRoutes.length} layouts`);
32592
- const clientOutputDir = import_path12.default.join(root, distDir, "client");
32662
+ const clientOutputDir = import_path13.default.join(root, distDir, "client");
32593
32663
  const [productionViteResult] = await productionViteResultPromise;
32594
32664
  if (productionViteResult.status === "rejected") {
32595
32665
  await routeRuntimeManifestResultPromise;
@@ -32684,12 +32754,10 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
32684
32754
  lifecyclePluginManager
32685
32755
  );
32686
32756
  const runtimeManifestPath = await writeFarmRouteRuntimeManifest(
32687
- import_path12.default.join(root, distDir),
32757
+ import_path13.default.join(root, distDir),
32688
32758
  routeRuntimeManifest
32689
32759
  );
32690
- logger.info(`\u{1F4CB} Route runtime manifest: ${import_path12.default.relative(root, runtimeManifestPath)}`);
32691
- logger.success("\u2705 Build completed successfully!");
32692
- logger.info(`\u{1F4C1} Output directory: ${deployOutputDir}`);
32760
+ logger.info(`\u{1F4CB} Route runtime manifest: ${import_path13.default.relative(root, runtimeManifestPath)}`);
32693
32761
  } catch (error) {
32694
32762
  if (lifecyclePluginManager) {
32695
32763
  await lifecyclePluginManager.runHookParallel("onError", {
@@ -32714,8 +32782,8 @@ async function writeSSRAssetsToClient(bundle, outputDir) {
32714
32782
  await mergeBuiltFontCss(outputDir, output.source);
32715
32783
  continue;
32716
32784
  }
32717
- const filePath = import_path12.default.join(outputDir, fileName);
32718
- await fs12.mkdir(import_path12.default.dirname(filePath), { recursive: true });
32785
+ const filePath = import_path13.default.join(outputDir, fileName);
32786
+ await fs12.mkdir(import_path13.default.dirname(filePath), { recursive: true });
32719
32787
  await fs12.writeFile(filePath, output.source);
32720
32788
  }
32721
32789
  }
@@ -32724,8 +32792,8 @@ async function copyFarmDocsFontAssetsToClient(root, outputDir) {
32724
32792
  const fs12 = await import("fs/promises");
32725
32793
  await Promise.all(
32726
32794
  resolveFarmDocsFontAssets(root).map(async ({ sourcePath, url }) => {
32727
- const targetPath = import_path12.default.join(outputDir, url.replace(/^\/+/, ""));
32728
- await fs12.mkdir(import_path12.default.dirname(targetPath), { recursive: true });
32795
+ const targetPath = import_path13.default.join(outputDir, url.replace(/^\/+/, ""));
32796
+ await fs12.mkdir(import_path13.default.dirname(targetPath), { recursive: true });
32729
32797
  await fs12.copyFile(sourcePath, targetPath);
32730
32798
  })
32731
32799
  );
@@ -32733,7 +32801,7 @@ async function copyFarmDocsFontAssetsToClient(root, outputDir) {
32733
32801
  __name(copyFarmDocsFontAssetsToClient, "copyFarmDocsFontAssetsToClient");
32734
32802
  async function mergeBuiltFontCss(outputDir, fontCssSource) {
32735
32803
  const fs12 = await import("fs/promises");
32736
- const fontCssPath = import_path12.default.join(outputDir, "farm-fonts.css");
32804
+ const fontCssPath = import_path13.default.join(outputDir, "farm-fonts.css");
32737
32805
  let fontCss = fontCssSource;
32738
32806
  if (fontCss === void 0) {
32739
32807
  try {
@@ -32742,7 +32810,7 @@ async function mergeBuiltFontCss(outputDir, fontCssSource) {
32742
32810
  return;
32743
32811
  }
32744
32812
  }
32745
- const clientCssPath = import_path12.default.join(outputDir, "farm-client.css");
32813
+ const clientCssPath = import_path13.default.join(outputDir, "farm-client.css");
32746
32814
  let clientCss = "";
32747
32815
  try {
32748
32816
  clientCss = await fs12.readFile(clientCssPath, "utf8");
@@ -32763,7 +32831,8 @@ __name(_IncompleteClientBuildOutputError, "IncompleteClientBuildOutputError");
32763
32831
  var IncompleteClientBuildOutputError = _IncompleteClientBuildOutputError;
32764
32832
  async function validateClientBuildOutput(root, srcDir, outputDir) {
32765
32833
  const fs12 = await import("fs/promises");
32766
- const clientEntryPath = import_path12.default.join(outputDir, "farm-client.js");
32834
+ const fingerprinted = await findFingerprintedClientEntry(outputDir);
32835
+ const clientEntryPath = import_path13.default.join(outputDir, fingerprinted ?? "farm-client.js");
32767
32836
  let clientEntrySize = 0;
32768
32837
  try {
32769
32838
  const clientEntry = await fs12.stat(clientEntryPath);
@@ -32773,8 +32842,8 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
32773
32842
  if (clientEntrySize === 0) {
32774
32843
  throw new IncompleteClientBuildOutputError("farm-client.js is missing or empty");
32775
32844
  }
32776
- const clientCssPath = import_path12.default.join(outputDir, "farm-client.css");
32777
- const globalsCssPath = import_path12.default.join(root, srcDir, "app", "globals.css");
32845
+ const clientCssPath = import_path13.default.join(outputDir, "farm-client.css");
32846
+ const globalsCssPath = import_path13.default.join(root, srcDir, "app", "globals.css");
32778
32847
  let expectsCss = false;
32779
32848
  try {
32780
32849
  const globalsCss = await fs12.readFile(globalsCssPath, "utf8");
@@ -32905,10 +32974,10 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
32905
32974
  logger.info(
32906
32975
  `\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout2) => layout2.shouldHydrate).length} layouts, and ${clientRouteSlots.length} slots`
32907
32976
  );
32908
- const clientEntryRoot = import_path12.default.join(root, ".farm", "tmp");
32977
+ const clientEntryRoot = import_path13.default.join(root, ".farm", "tmp");
32909
32978
  await fs12.mkdir(clientEntryRoot, { recursive: true });
32910
- const clientEntryDir = await fs12.mkdtemp(import_path12.default.join(clientEntryRoot, "client-entry-"));
32911
- const clientEntryPath = import_path12.default.join(clientEntryDir, "farm-client-entry.tsx");
32979
+ const clientEntryDir = await fs12.mkdtemp(import_path13.default.join(clientEntryRoot, "client-entry-"));
32980
+ const clientEntryPath = import_path13.default.join(clientEntryDir, "farm-client-entry.tsx");
32912
32981
  const clientHydrationCode = generateClientHydrationEntry(
32913
32982
  clientPages,
32914
32983
  clientLayouts,
@@ -32934,7 +33003,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
32934
33003
  if (hasScopedPostcssConfig) {
32935
33004
  logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
32936
33005
  } else {
32937
- const postcssConfigPath = import_path12.default.join(clientEntryDir, "postcss.config.cjs");
33006
+ const postcssConfigPath = import_path13.default.join(clientEntryDir, "postcss.config.cjs");
32938
33007
  await fs12.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
32939
33008
  postcssSearchPath = clientEntryDir;
32940
33009
  try {
@@ -32967,7 +33036,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
32967
33036
  "farm-client": clientEntryPath
32968
33037
  },
32969
33038
  output: {
32970
- entryFileNames: "[name].js",
33039
+ entryFileNames: "[name]-h[hash].js",
32971
33040
  chunkFileNames: "chunks/[name]-h[hash].js",
32972
33041
  hashCharacters: "hex",
32973
33042
  // Use predictable name for CSS so we can reference it in SSR HTML
@@ -33285,7 +33354,7 @@ function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlot
33285
33354
  );
33286
33355
  const rendererClientImports = isReactRenderer(renderer) ? `import React from "react";
33287
33356
  import { createRoot, hydrateRoot } from "react-dom/client";` : `import React, { createRoot, hydrateRoot } from ${JSON.stringify(renderer.client)};`;
33288
- const globalsCssPath = import_path12.default.join(root, srcDir, "app", "globals.css");
33357
+ const globalsCssPath = import_path13.default.join(root, srcDir, "app", "globals.css");
33289
33358
  const cssImportPath = toImportPath(globalsCssPath);
33290
33359
  const cssImport = `import ${JSON.stringify(cssImportPath)};`;
33291
33360
  const layoutImportStatements = [];
@@ -34554,9 +34623,9 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
34554
34623
  ssr: true
34555
34624
  });
34556
34625
  if (!hasScopedPostcssConfig) {
34557
- postcssConfigDir = await fs12.mkdtemp(import_path12.default.join(import_os.default.tmpdir(), "farm-postcss-"));
34626
+ postcssConfigDir = await fs12.mkdtemp(import_path13.default.join(import_os.default.tmpdir(), "farm-postcss-"));
34558
34627
  await fs12.writeFile(
34559
- import_path12.default.join(postcssConfigDir, "postcss.config.cjs"),
34628
+ import_path13.default.join(postcssConfigDir, "postcss.config.cjs"),
34560
34629
  "module.exports = { plugins: [] };\n"
34561
34630
  );
34562
34631
  try {
@@ -34634,7 +34703,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
34634
34703
  const notFoundExtensions = getFarmRendererComponentExtensions(config.renderer);
34635
34704
  for (const sourceAppDir of appDirs) {
34636
34705
  for (const ext of notFoundExtensions) {
34637
- const checkPath = import_path12.default.join(sourceAppDir, `not-found${ext}`);
34706
+ const checkPath = import_path13.default.join(sourceAppDir, `not-found${ext}`);
34638
34707
  try {
34639
34708
  await fs12.access(checkPath);
34640
34709
  notFoundPath = checkPath;
@@ -35066,7 +35135,7 @@ import { dirname as farmDocsDirname, join as farmDocsJoin } from "node:path";
35066
35135
  import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
35067
35136
  const markdownHandlerImport = config.md?.enabled ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse } from "@farm.js/core/markdown";` : "";
35068
35137
  const appMarkdownImport = hasMarkdownPages ? `import { createFarmMarkdownRouteModule, createFarmMarkdownSourceResponse } from "@farm.js/core/app-markdown";` : "const createFarmMarkdownSourceResponse = null;";
35069
- const mdxComponentsPath = typeof config.mdx?.components === "string" ? import_path12.default.isAbsolute(config.mdx.components) ? config.mdx.components : import_path12.default.join(config.root, config.mdx.components) : null;
35138
+ const mdxComponentsPath = typeof config.mdx?.components === "string" ? import_path13.default.isAbsolute(config.mdx.components) ? config.mdx.components : import_path13.default.join(config.root, config.mdx.components) : null;
35070
35139
  const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from "${mdxComponentsPath.replace(/\\/g, "/")}";` : "";
35071
35140
  const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
35072
35141
  const layerConfigImports = layerConfigPaths.map(
@@ -35341,8 +35410,8 @@ const farmDocsHandler = ${config.docs?.enabled ? adapterOwnsDocsRuntime ? `creat
35341
35410
  contentDir: farmDocsResolvedConfig.contentDir || farmDocsResolvedConfig.config?.contentDir,
35342
35411
  }, {
35343
35412
  rootDir: farmDocsRuntimeRoot,
35344
- clientEntry: "/farm-client.js",
35345
- stylesheets: ["/farm-fonts.css", "/farm-client.css"],
35413
+ clientEntry: "/__farm_client_js_src__",
35414
+ stylesheets: ["/farm-fonts.css", "/__farm_client_css_href__"],
35346
35415
  resolveLayoutFonts: (pathname) =>
35347
35416
  resolveFarmLayoutFonts(
35348
35417
  getApplicableLayouts(getFarmRoutePathname(pathname)).map((layout) => layout.module),
@@ -35351,7 +35420,7 @@ const farmDocsHandler = ${config.docs?.enabled ? adapterOwnsDocsRuntime ? `creat
35351
35420
  })` : `createFarmDocsHandler(farmDocsResolvedConfig, {
35352
35421
  root: farmDocsRuntimeRoot,
35353
35422
  srcDir: ${JSON.stringify(config.srcDir)},
35354
- clientEntry: "/farm-client.js",
35423
+ clientEntry: "/__farm_client_js_src__",
35355
35424
  fontAssets: ${JSON.stringify(farmDocsFontAssets)},
35356
35425
  resolveLayoutFonts: (pathname) =>
35357
35426
  resolveFarmLayoutFonts(
@@ -35694,12 +35763,12 @@ function createFarmErrorDocument(html, title) {
35694
35763
  ' <meta name="viewport" content="width=device-width, initial-scale=1">\\n' +
35695
35764
  ' <link rel="icon" href="data:,">\\n' +
35696
35765
  ' <title>' + escapedTitle + '</title>\\n' +
35697
- ' <link rel="stylesheet" href="/farm-client.css">\\n' +
35766
+ ' <link rel="stylesheet" href="/__farm_client_css_href__">\\n' +
35698
35767
  renderFarmRendererHydrationScript() + '\\n' +
35699
35768
  '</head>\\n<body>\\n' +
35700
35769
  ' <div id="root">' + html + '</div>\\n' +
35701
35770
  ' ' + renderFarmClientBootstrapScript() + '\\n' +
35702
- ' <script type="module" src="/farm-client.js"></script>\\n' +
35771
+ ' <script type="module" src="/__farm_client_js_src__"></script>\\n' +
35703
35772
  '</body>\\n</html>';
35704
35773
  }
35705
35774
 
@@ -35710,7 +35779,7 @@ function createFarmErrorDocument(html, title) {
35710
35779
  .replace(/<\\/body>/i, '</div></body>');
35711
35780
  }
35712
35781
  fullHtml = fullHtml
35713
- .replace(/<head([^>]*)>/i, '<head$1>\\n <link rel="stylesheet" href="/farm-client.css">')
35782
+ .replace(/<head([^>]*)>/i, '<head$1>\\n <link rel="stylesheet" href="/__farm_client_css_href__">')
35714
35783
  .replace(/<\\/head>/i, renderFarmRendererHydrationScript() + '\\n</head>')
35715
35784
  .replace(/<head([^>]*)>([\\s\\S]*?)<\\/head>/i, function(match, attrs, headContent) {
35716
35785
  return headContent.includes("<title")
@@ -35720,7 +35789,7 @@ function createFarmErrorDocument(html, title) {
35720
35789
  .replace(
35721
35790
  /<\\/body>/i,
35722
35791
  ' ' + renderFarmClientBootstrapScript() + '\\n' +
35723
- ' <script type="module" src="/farm-client.js"></script>\\n</body>',
35792
+ ' <script type="module" src="/__farm_client_js_src__"></script>\\n</body>',
35724
35793
  );
35725
35794
  return fullHtml.trim().startsWith("<!DOCTYPE")
35726
35795
  ? fullHtml
@@ -36436,8 +36505,8 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
36436
36505
  bodyMatch[0],
36437
36506
  "<body" + bodyMatch[1] + ">" + rootMarkup + "</body>",
36438
36507
  );
36439
- if (!html.includes('href="/farm-client.css"')) {
36440
- const clientStylesheet = ' <link rel="stylesheet" href="/farm-client.css">\\n';
36508
+ if (!html.includes('href="/__farm_client_css_href__"')) {
36509
+ const clientStylesheet = ' <link rel="stylesheet" href="/__farm_client_css_href__">\\n';
36441
36510
  const firstStyleIndex = html.search(/<style(?:\\s|>)/i);
36442
36511
  html =
36443
36512
  firstStyleIndex >= 0
@@ -36447,10 +36516,10 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
36447
36516
  if (!html.includes('id="__farm_route_slots_data__"')) {
36448
36517
  html = html.replace(/<[/]body>/i, renderFarmClientBootstrapScript() + "\\n</body>");
36449
36518
  }
36450
- if (!html.includes('src="/farm-client.js"')) {
36519
+ if (!html.includes('src="/__farm_client_js_src__"')) {
36451
36520
  html = html.replace(
36452
36521
  /<[/]body>/i,
36453
- ' <script type="module" src="/farm-client.js"></script>\\n</body>',
36522
+ ' <script type="module" src="/__farm_client_js_src__"></script>\\n</body>',
36454
36523
  );
36455
36524
  }
36456
36525
  if (!html.includes('window._$HY')) {
@@ -37180,8 +37249,8 @@ async function handleFarmRequestInContext(
37180
37249
  ' <meta name="viewport" content="width=device-width, initial-scale=1">\\n' +
37181
37250
  (hasFavicon ? '' : ' <link rel="icon" href="data:,">\\n') +
37182
37251
  ' <title>' + title + '</title>' + metaTags + '\\n' +
37183
- ' <link rel="stylesheet" href="/farm-client.css">\\n' +
37184
- ' <link rel="modulepreload" href="/farm-client.js">\\n' +
37252
+ ' <link rel="stylesheet" href="/__farm_client_css_href__">\\n' +
37253
+ ' <link rel="modulepreload" href="/__farm_client_js_src__">\\n' +
37185
37254
  renderFarmRendererHydrationScript() + '\\n' +
37186
37255
  '</head>\\n<body>\\n <div id="root">';
37187
37256
  const streamSuffix = '</div>\\n' +
@@ -37190,7 +37259,7 @@ async function handleFarmRequestInContext(
37190
37259
  routeSlotPayload,
37191
37260
  clientPageProps
37192
37261
  ) + '\\n' +
37193
- ' <script type="module" src="/farm-client.js"></script>\\n' +
37262
+ ' <script type="module" src="/__farm_client_js_src__"></script>\\n' +
37194
37263
  '</body>\\n</html>';
37195
37264
  const themedStreamPrefix = streamPrefix.replace(
37196
37265
  '<html lang="en">',
@@ -37235,7 +37304,7 @@ async function handleFarmRequestInContext(
37235
37304
  // Layout provides full HTML structure - inject CSS and client script
37236
37305
  fullHtml = html
37237
37306
  // Inject CSS link after opening head tag or first meta tag
37238
- .replace(/<head([^>]*)>/i, '<head$1>\\n <link rel="stylesheet" href="/farm-client.css">')
37307
+ .replace(/<head([^>]*)>/i, '<head$1>\\n <link rel="stylesheet" href="/__farm_client_css_href__">')
37239
37308
  .replace(/<\\/head>/i, renderFarmRendererHydrationScript() + '\\n</head>')
37240
37309
  // Inject title if not present and we have one
37241
37310
  .replace(/<head([^>]*)>([\\s\\S]*?)<\\/head>/i, (match, attrs, headContent) => {
@@ -37256,7 +37325,7 @@ async function handleFarmRequestInContext(
37256
37325
  routeSlotPayload,
37257
37326
  clientPageProps
37258
37327
  ) + '\\n' +
37259
- ' <script type="module" src="/farm-client.js"></script>\\n</body>',
37328
+ ' <script type="module" src="/__farm_client_js_src__"></script>\\n</body>',
37260
37329
  );
37261
37330
 
37262
37331
  // Add DOCTYPE if not present
@@ -37272,13 +37341,13 @@ async function handleFarmRequestInContext(
37272
37341
  <meta name="viewport" content="width=device-width, initial-scale=1">
37273
37342
  \${hasFavicon ? "" : '<link rel="icon" href="data:,">'}
37274
37343
  <title>\${title}</title>\${metaTags}
37275
- <link rel="stylesheet" href="/farm-client.css">
37344
+ <link rel="stylesheet" href="/__farm_client_css_href__">
37276
37345
  \${renderFarmRendererHydrationScript()}
37277
37346
  </head>
37278
37347
  <body>
37279
37348
  <div id="root">\${html}</div>
37280
37349
  \${renderFarmClientBootstrapScript(pageProps.__farmCanonicalPath, routeSlotPayload, clientPageProps)}
37281
- <script type="module" src="/farm-client.js"></script>
37350
+ <script type="module" src="/__farm_client_js_src__"></script>
37282
37351
  </body>
37283
37352
  </html>\`;
37284
37353
  }
@@ -37537,12 +37606,12 @@ async function handleFarmRequestInContext(
37537
37606
  let fullHtml;
37538
37607
  if (hasFullDocument) {
37539
37608
  fullHtml = html
37540
- .replace(/<head([^>]*)>/i, '<head$1>\\n <link rel="stylesheet" href="/farm-client.css">')
37609
+ .replace(/<head([^>]*)>/i, '<head$1>\\n <link rel="stylesheet" href="/__farm_client_css_href__">')
37541
37610
  .replace(/<\\/head>/i, renderFarmRendererHydrationScript() + '\\n</head>')
37542
37611
  .replace(
37543
37612
  /<\\/body>/i,
37544
37613
  ' ' + renderFarmClientBootstrapScript() + '\\n' +
37545
- ' <script type="module" src="/farm-client.js"></script>\\n</body>',
37614
+ ' <script type="module" src="/__farm_client_js_src__"></script>\\n</body>',
37546
37615
  );
37547
37616
  if (!fullHtml.trim().startsWith('<!DOCTYPE')) {
37548
37617
  fullHtml = '<!DOCTYPE html>\\n' + fullHtml;
@@ -37554,14 +37623,14 @@ async function handleFarmRequestInContext(
37554
37623
  <meta charset="UTF-8">
37555
37624
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
37556
37625
  <link rel="icon" href="data:,">
37557
- <link rel="stylesheet" href="/farm-client.css">
37626
+ <link rel="stylesheet" href="/__farm_client_css_href__">
37558
37627
  <title>404 - Page Not Found</title>
37559
37628
  \${renderFarmRendererHydrationScript()}
37560
37629
  </head>
37561
37630
  <body>
37562
37631
  <div id="root">\${html}</div>
37563
37632
  \${renderFarmClientBootstrapScript()}
37564
- <script type="module" src="/farm-client.js"></script>
37633
+ <script type="module" src="/__farm_client_js_src__"></script>
37565
37634
  </body>
37566
37635
  </html>\`;
37567
37636
  }
@@ -37898,7 +37967,7 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
37898
37967
  const isVercel = preset === "vercel" || preset === "vercel-edge";
37899
37968
  const isCloudflareWorker = preset === "cloudflare-module";
37900
37969
  const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
37901
- const ssrOutputDir = import_path12.default.join(root, distDir, "ssr");
37970
+ const ssrOutputDir = import_path13.default.join(root, distDir, "ssr");
37902
37971
  const imageRuntime = resolveImageRuntime(config, preset);
37903
37972
  const hasGeneratedMetadataImages = Array.from(routeManager.getMetadataImages().values()).some(
37904
37973
  (image) => image.sourceType === "module"
@@ -37967,13 +38036,26 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
37967
38036
  }
37968
38037
  const scheduledTasks = mergeScheduledTasks(farmWorkflows.scheduledTasks, farmCron.scheduledTasks);
37969
38038
  const cloudflareCronConfig = createFarmCronCloudflareConfig(farmCron.jobs);
38039
+ const [clientCssHref, clientJsSrc] = await Promise.all([
38040
+ resolveHashedClientCssHref(clientOutputDir),
38041
+ resolveHashedClientJsSrc(clientOutputDir)
38042
+ ]);
38043
+ for (const output of Object.values(ssrBundle)) {
38044
+ if (output.type !== "chunk") continue;
38045
+ if (output.code.includes(FARM_CLIENT_CSS_HREF_PLACEHOLDER)) {
38046
+ output.code = output.code.split(FARM_CLIENT_CSS_HREF_PLACEHOLDER).join(clientCssHref);
38047
+ }
38048
+ if (output.code.includes(FARM_CLIENT_JS_SRC_PLACEHOLDER)) {
38049
+ output.code = output.code.split(FARM_CLIENT_JS_SRC_PLACEHOLDER).join(clientJsSrc);
38050
+ }
38051
+ }
37970
38052
  await fs12.mkdir(ssrOutputDir, { recursive: true });
37971
38053
  for (const [fileName, output] of Object.entries(ssrBundle)) {
37972
- const filePath = import_path12.default.join(ssrOutputDir, fileName);
37973
- await fs12.mkdir(import_path12.default.dirname(filePath), { recursive: true });
38054
+ const filePath = import_path13.default.join(ssrOutputDir, fileName);
38055
+ await fs12.mkdir(import_path13.default.dirname(filePath), { recursive: true });
37974
38056
  await fs12.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
37975
38057
  }
37976
- const nitroEntryPath = import_path12.default.join(ssrOutputDir, "nitro-entry.mjs");
38058
+ const nitroEntryPath = import_path13.default.join(ssrOutputDir, "nitro-entry.mjs");
37977
38059
  const nitroEntryCode = `
37978
38060
  // Farm.js Nitro Entry
37979
38061
  // This file adapts Farm's Web fetch handler to Nitro's event handler contract.
@@ -38038,12 +38120,12 @@ export default async function farmNitroEventHandler(event) {
38038
38120
  }
38039
38121
  `.trim();
38040
38122
  await fs12.writeFile(nitroEntryPath, nitroEntryCode);
38041
- const farmNodeServerEntryPath = preset === "node-server" ? import_path12.default.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
38123
+ const farmNodeServerEntryPath = preset === "node-server" ? import_path13.default.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
38042
38124
  if (farmNodeServerEntryPath) {
38043
38125
  await fs12.writeFile(
38044
38126
  farmNodeServerEntryPath,
38045
38127
  createFarmNodeServerEntry({
38046
- nitroEntryFile: import_path12.default.basename(nitroEntryPath),
38128
+ nitroEntryFile: import_path13.default.basename(nitroEntryPath),
38047
38129
  nodeHandlerModule: resolveNitroRuntimeDependency(root, "srvx/node"),
38048
38130
  server: config.server,
38049
38131
  websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/node")
@@ -38077,12 +38159,12 @@ export default async function farmNitroEventHandler(event) {
38077
38159
  ...farmNodeServerEntryPath ? { entry: farmNodeServerEntryPath } : {},
38078
38160
  rootDir: root,
38079
38161
  srcDir: root,
38080
- buildDir: import_path12.default.join(root, distDir, ".nitro"),
38162
+ buildDir: import_path13.default.join(root, distDir, ".nitro"),
38081
38163
  compatibilityDate: "2024-12-01",
38082
38164
  output: {
38083
38165
  dir: outputDir,
38084
- serverDir: import_path12.default.join(outputDir, "server"),
38085
- publicDir: import_path12.default.join(outputDir, "public")
38166
+ serverDir: import_path13.default.join(outputDir, "server"),
38167
+ publicDir: import_path13.default.join(outputDir, "public")
38086
38168
  },
38087
38169
  publicAssets: [
38088
38170
  {
@@ -38167,7 +38249,7 @@ export default async function farmNitroEventHandler(event) {
38167
38249
  if (pluginManager) {
38168
38250
  nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
38169
38251
  }
38170
- const expectedServerDir = import_path12.default.join(outputDir, "server");
38252
+ const expectedServerDir = import_path13.default.join(outputDir, "server");
38171
38253
  const customRollupKeys = Object.keys(nitroConfig.rollupConfig || {}).filter(
38172
38254
  (key) => key !== "external" && key !== "plugins"
38173
38255
  );
@@ -38183,9 +38265,9 @@ export default async function farmNitroEventHandler(event) {
38183
38265
  snapshotSSRRebundleOptions(nitroConfig)
38184
38266
  );
38185
38267
  const requestedBuilder = nitroConfig.builder ?? process.env.NITRO_BUILDER;
38186
- const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourceMap === false && !hasUnsupportedEsbuildOverrides && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 && import_path12.default.resolve(nitroConfig.output?.serverDir || "") === import_path12.default.resolve(expectedServerDir) && Boolean(
38268
+ const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourceMap === false && !hasUnsupportedEsbuildOverrides && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 && import_path13.default.resolve(nitroConfig.output?.serverDir || "") === import_path13.default.resolve(expectedServerDir) && Boolean(
38187
38269
  nitroConfig.handlers?.some(
38188
- (handler) => import_path12.default.resolve(handler?.handler || "") === nitroEntryPath
38270
+ (handler) => import_path13.default.resolve(handler?.handler || "") === nitroEntryPath
38189
38271
  )
38190
38272
  );
38191
38273
  const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
@@ -38197,8 +38279,9 @@ export default async function farmNitroEventHandler(event) {
38197
38279
  ...configuredEsbuildOptions,
38198
38280
  // Function-name helpers are unsafe for provider scripts that serialize a
38199
38281
  // function with toString(); the helper is outside the emitted script scope.
38200
- keepNames: configuredEsbuildOptions.keepNames ?? !(config.docs?.enabled && config.docs.adapter?.server)
38282
+ keepNames: config.docs?.enabled && config.docs.adapter?.server ? false : configuredEsbuildOptions.keepNames ?? true
38201
38283
  };
38284
+ const prebuiltSSREsbuildOptions = config.docs?.enabled && config.docs.adapter?.server ? resolvedEsbuildOptions : configuredEsbuildOptions;
38202
38285
  const effectiveMinify = configuredEsbuildOptions.minify ?? shouldMinify;
38203
38286
  const useFarmEsbuildMinifier = effectiveMinify && nitroConfig.sourceMap === false && !hasUnsupportedEsbuildOverrides && !hasLateBuildMutationConfig;
38204
38287
  const esbuildChunkMinifier = useFarmEsbuildMinifier ? createEsbuildChunkMinifyPlugin(resolvedEsbuildOptions) : null;
@@ -38240,10 +38323,10 @@ export default async function farmNitroEventHandler(event) {
38240
38323
  });
38241
38324
  }
38242
38325
  prerenderer.hooks.hook("compiled", async () => {
38243
- const prerenderServerDir = import_path12.default.join(outputDir, "server");
38326
+ const prerenderServerDir = import_path13.default.join(outputDir, "server");
38244
38327
  await copyPrebuiltSSRBundle(
38245
38328
  ssrBundle,
38246
- import_path12.default.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
38329
+ import_path13.default.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
38247
38330
  {},
38248
38331
  false,
38249
38332
  fs12
@@ -38277,20 +38360,20 @@ export default async function farmNitroEventHandler(event) {
38277
38360
  const copyResults = await Promise.allSettled([
38278
38361
  canReusePrebuiltSSR ? copyPrebuiltSSRBundle(
38279
38362
  ssrBundle,
38280
- import_path12.default.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
38281
- configuredEsbuildOptions,
38363
+ import_path13.default.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
38364
+ prebuiltSSREsbuildOptions,
38282
38365
  effectiveMinify,
38283
38366
  fs12
38284
38367
  ) : Promise.resolve(),
38285
- imageRuntime === "node" ? copySharpRuntime(config, root, import_path12.default.join(outputDir, "server"), fs12) : Promise.resolve(),
38286
- useExternalMetadataImageRuntime ? copyMetadataImageRuntime(root, import_path12.default.join(outputDir, "server"), fs12) : Promise.resolve()
38368
+ imageRuntime === "node" ? copySharpRuntime(config, root, import_path13.default.join(outputDir, "server"), fs12) : Promise.resolve(),
38369
+ useExternalMetadataImageRuntime ? copyMetadataImageRuntime(root, import_path13.default.join(outputDir, "server"), fs12) : Promise.resolve()
38287
38370
  ]);
38288
38371
  const failedCopy = copyResults.find(
38289
38372
  (result) => result.status === "rejected"
38290
38373
  );
38291
38374
  if (failedCopy) throw failedCopy.reason;
38292
38375
  if (canReusePrebuiltSSR) {
38293
- await registerPrebuiltSSRPackageImport(import_path12.default.join(outputDir, "server"), ssrEntryFile, fs12);
38376
+ await registerPrebuiltSSRPackageImport(import_path13.default.join(outputDir, "server"), ssrEntryFile, fs12);
38294
38377
  logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
38295
38378
  }
38296
38379
  if (useRolldownBuilder) {
@@ -38330,8 +38413,8 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, configuredEsbuildOpti
38330
38413
  await fs12.rm(targetDir, { recursive: true, force: true });
38331
38414
  await Promise.all(
38332
38415
  Object.entries(ssrBundle).map(async ([fileName, output]) => {
38333
- const targetPath = import_path12.default.join(targetDir, fileName);
38334
- await fs12.mkdir(import_path12.default.dirname(targetPath), { recursive: true });
38416
+ const targetPath = import_path13.default.join(targetDir, fileName);
38417
+ await fs12.mkdir(import_path13.default.dirname(targetPath), { recursive: true });
38335
38418
  if (output.type === "asset") {
38336
38419
  await fs12.writeFile(targetPath, output.source);
38337
38420
  return;
@@ -38350,7 +38433,7 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, configuredEsbuildOpti
38350
38433
  }
38351
38434
  __name(copyPrebuiltSSRBundle, "copyPrebuiltSSRBundle");
38352
38435
  async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs12) {
38353
- const packagePath = import_path12.default.join(serverDir, "package.json");
38436
+ const packagePath = import_path13.default.join(serverDir, "package.json");
38354
38437
  const packageJSON = await fs12.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
38355
38438
  if (error.code === "ENOENT") return { type: "module" };
38356
38439
  throw error;
@@ -38367,16 +38450,16 @@ async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs12) {
38367
38450
  }
38368
38451
  __name(registerPrebuiltSSRPackageImport, "registerPrebuiltSSRPackageImport");
38369
38452
  async function postProcessVercelOutput(root, outputDir, fs12, config, farmWorkflows, routeRuntimeManifest) {
38370
- const serverDir = import_path12.default.join(outputDir, "server");
38371
- const functionsDir = import_path12.default.join(outputDir, "functions");
38372
- const nitroFuncDir = import_path12.default.join(functionsDir, "__nitro.func");
38373
- const staticDir = import_path12.default.join(outputDir, "static");
38374
- const publicDir = import_path12.default.join(outputDir, "public");
38453
+ const serverDir = import_path13.default.join(outputDir, "server");
38454
+ const functionsDir = import_path13.default.join(outputDir, "functions");
38455
+ const nitroFuncDir = import_path13.default.join(functionsDir, "__nitro.func");
38456
+ const staticDir = import_path13.default.join(outputDir, "static");
38457
+ const publicDir = import_path13.default.join(outputDir, "public");
38375
38458
  await fs12.mkdir(nitroFuncDir, { recursive: true });
38376
38459
  const serverContents = await fs12.readdir(serverDir);
38377
38460
  for (const file of serverContents) {
38378
- const src = import_path12.default.join(serverDir, file);
38379
- const dest = import_path12.default.join(nitroFuncDir, file);
38461
+ const src = import_path13.default.join(serverDir, file);
38462
+ const dest = import_path13.default.join(nitroFuncDir, file);
38380
38463
  await fs12.rename(src, dest);
38381
38464
  }
38382
38465
  await fs12.rmdir(serverDir);
@@ -38386,7 +38469,7 @@ async function postProcessVercelOutput(root, outputDir, fs12, config, farmWorkfl
38386
38469
  }
38387
38470
  await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs12);
38388
38471
  await copyPrismaClientForVercel(root, nitroFuncDir, fs12);
38389
- const configPath = import_path12.default.join(outputDir, "config.json");
38472
+ const configPath = import_path13.default.join(outputDir, "config.json");
38390
38473
  const configContent = await fs12.readFile(configPath, "utf-8");
38391
38474
  const vercelConfig = JSON.parse(configContent);
38392
38475
  const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
@@ -38434,27 +38517,27 @@ __name(postProcessVercelOutput, "postProcessVercelOutput");
38434
38517
  async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs12) {
38435
38518
  const docsContentDir = resolveBuildDocsContentDir(config, root);
38436
38519
  if (!docsContentDir) return;
38437
- const bundledContentDir = import_path12.default.join(nitroFuncDir, "chunks", "nitro", "farm-docs-content");
38520
+ const bundledContentDir = import_path13.default.join(nitroFuncDir, "chunks", "nitro", "farm-docs-content");
38438
38521
  const lastModifiedManifest = createFarmDocsLastModifiedManifest(docsContentDir, {
38439
38522
  fallback: "now"
38440
38523
  });
38441
38524
  await fs12.rm(bundledContentDir, { recursive: true, force: true });
38442
- await fs12.mkdir(import_path12.default.dirname(bundledContentDir), { recursive: true });
38525
+ await fs12.mkdir(import_path13.default.dirname(bundledContentDir), { recursive: true });
38443
38526
  await fs12.cp(docsContentDir, bundledContentDir, {
38444
38527
  recursive: true,
38445
38528
  force: true
38446
38529
  });
38447
38530
  await fs12.writeFile(
38448
- import_path12.default.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
38531
+ import_path13.default.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
38449
38532
  `${JSON.stringify(lastModifiedManifest, null, 2)}
38450
38533
  `
38451
38534
  );
38452
- logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${import_path12.default.relative(root, docsContentDir)}`);
38535
+ logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${import_path13.default.relative(root, docsContentDir)}`);
38453
38536
  }
38454
38537
  __name(copyFarmDocsContentForVercel, "copyFarmDocsContentForVercel");
38455
38538
  async function copySharpRuntime(config, root, nitroFuncDir, fs12) {
38456
38539
  if (config.images.provider === "none") return;
38457
- const projectRequire = (0, import_module2.createRequire)(import_path12.default.join(root, "package.json"));
38540
+ const projectRequire = (0, import_module2.createRequire)(import_path13.default.join(root, "package.json"));
38458
38541
  let sharpRequire = projectRequire;
38459
38542
  if (!resolvePackageJson(projectRequire, "sharp")) {
38460
38543
  try {
@@ -38464,7 +38547,7 @@ async function copySharpRuntime(config, root, nitroFuncDir, fs12) {
38464
38547
  }
38465
38548
  const copiedPackages = /* @__PURE__ */ new Map();
38466
38549
  const packageCopies = /* @__PURE__ */ new Map();
38467
- const targetNodeModules = import_path12.default.join(nitroFuncDir, "node_modules");
38550
+ const targetNodeModules = import_path13.default.join(nitroFuncDir, "node_modules");
38468
38551
  function copyPackage(packageName, parentRequire) {
38469
38552
  const activeCopy = packageCopies.get(packageName);
38470
38553
  if (activeCopy) return activeCopy;
@@ -38477,10 +38560,10 @@ async function copySharpRuntime(config, root, nitroFuncDir, fs12) {
38477
38560
  const packageJsonPath = resolvePackageJson(parentRequire, packageName);
38478
38561
  if (!packageJsonPath) return;
38479
38562
  const packageJson = JSON.parse(await fs12.readFile(packageJsonPath, "utf8"));
38480
- const packageDir = import_path12.default.dirname(packageJsonPath);
38481
- const targetDir = import_path12.default.join(targetNodeModules, ...packageName.split("/"));
38563
+ const packageDir = import_path13.default.dirname(packageJsonPath);
38564
+ const targetDir = import_path13.default.join(targetNodeModules, ...packageName.split("/"));
38482
38565
  copiedPackages.set(packageName, String(packageJson.version || "*"));
38483
- await fs12.mkdir(import_path12.default.dirname(targetDir), { recursive: true });
38566
+ await fs12.mkdir(import_path13.default.dirname(targetDir), { recursive: true });
38484
38567
  const packageRequire = (0, import_module2.createRequire)(packageJsonPath);
38485
38568
  const dependencies = {
38486
38569
  ...packageJson.dependencies,
@@ -38505,7 +38588,7 @@ async function copySharpRuntime(config, root, nitroFuncDir, fs12) {
38505
38588
  "Farm image optimization requires sharp. Reinstall dependencies without omitting optional packages."
38506
38589
  );
38507
38590
  }
38508
- const functionPackagePath = import_path12.default.join(nitroFuncDir, "package.json");
38591
+ const functionPackagePath = import_path13.default.join(nitroFuncDir, "package.json");
38509
38592
  const functionPackage = JSON.parse(await fs12.readFile(functionPackagePath, "utf8"));
38510
38593
  functionPackage.dependencies = {
38511
38594
  ...functionPackage.dependencies,
@@ -38516,7 +38599,7 @@ async function copySharpRuntime(config, root, nitroFuncDir, fs12) {
38516
38599
  }
38517
38600
  __name(copySharpRuntime, "copySharpRuntime");
38518
38601
  async function copyMetadataImageRuntime(root, nitroFuncDir, fs12) {
38519
- const projectRequire = (0, import_module2.createRequire)(import_path12.default.join(root, "package.json"));
38602
+ const projectRequire = (0, import_module2.createRequire)(import_path13.default.join(root, "package.json"));
38520
38603
  let runtimeRequire = projectRequire;
38521
38604
  let packageJsonPath = resolvePackageJson(runtimeRequire, "@vercel/og");
38522
38605
  if (!packageJsonPath) {
@@ -38532,16 +38615,16 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs12) {
38532
38615
  );
38533
38616
  }
38534
38617
  const packageJson = JSON.parse(await fs12.readFile(packageJsonPath, "utf8"));
38535
- const packageDir = import_path12.default.dirname(packageJsonPath);
38536
- const targetDir = import_path12.default.join(nitroFuncDir, "node_modules", "@vercel", "og");
38537
- await fs12.mkdir(import_path12.default.dirname(targetDir), { recursive: true });
38618
+ const packageDir = import_path13.default.dirname(packageJsonPath);
38619
+ const targetDir = import_path13.default.join(nitroFuncDir, "node_modules", "@vercel", "og");
38620
+ await fs12.mkdir(import_path13.default.dirname(targetDir), { recursive: true });
38538
38621
  await fs12.cp(packageDir, targetDir, {
38539
38622
  recursive: true,
38540
38623
  force: true,
38541
38624
  dereference: true,
38542
38625
  mode: import_fs5.constants.COPYFILE_FICLONE
38543
38626
  });
38544
- const functionPackagePath = import_path12.default.join(nitroFuncDir, "package.json");
38627
+ const functionPackagePath = import_path13.default.join(nitroFuncDir, "package.json");
38545
38628
  const functionPackage = JSON.parse(await fs12.readFile(functionPackagePath, "utf8"));
38546
38629
  functionPackage.dependencies = {
38547
38630
  ...functionPackage.dependencies,
@@ -38562,23 +38645,23 @@ function resolvePackageJson(parentRequire, packageName) {
38562
38645
  }
38563
38646
  __name(resolvePackageJson, "resolvePackageJson");
38564
38647
  async function copyPrismaClientForVercel(root, nitroFuncDir, fs12) {
38565
- const projectRequire = (0, import_module2.createRequire)(import_path12.default.join(root, "package.json"));
38648
+ const projectRequire = (0, import_module2.createRequire)(import_path13.default.join(root, "package.json"));
38566
38649
  let prismaClientDir;
38567
38650
  try {
38568
- prismaClientDir = import_path12.default.dirname(projectRequire.resolve("@prisma/client/default.js"));
38651
+ prismaClientDir = import_path13.default.dirname(projectRequire.resolve("@prisma/client/default.js"));
38569
38652
  } catch {
38570
38653
  return;
38571
38654
  }
38572
- const generatedClientDir = import_path12.default.join(prismaClientDir, "..", "..", ".prisma", "client");
38655
+ const generatedClientDir = import_path13.default.join(prismaClientDir, "..", "..", ".prisma", "client");
38573
38656
  try {
38574
38657
  await fs12.access(generatedClientDir);
38575
38658
  } catch {
38576
38659
  return;
38577
38660
  }
38578
- const targetNodeModules = import_path12.default.join(nitroFuncDir, "node_modules");
38579
- const targetPrismaScopeDir = import_path12.default.join(targetNodeModules, "@prisma");
38580
- const targetGeneratedDir = import_path12.default.join(targetNodeModules, ".prisma", "client");
38581
- const targetClientDir = import_path12.default.join(targetPrismaScopeDir, "client");
38661
+ const targetNodeModules = import_path13.default.join(nitroFuncDir, "node_modules");
38662
+ const targetPrismaScopeDir = import_path13.default.join(targetNodeModules, "@prisma");
38663
+ const targetGeneratedDir = import_path13.default.join(targetNodeModules, ".prisma", "client");
38664
+ const targetClientDir = import_path13.default.join(targetPrismaScopeDir, "client");
38582
38665
  await fs12.mkdir(targetPrismaScopeDir, { recursive: true });
38583
38666
  await fs12.cp(prismaClientDir, targetClientDir, {
38584
38667
  recursive: true,
@@ -38588,8 +38671,8 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs12) {
38588
38671
  recursive: true,
38589
38672
  force: true
38590
38673
  });
38591
- const functionPackagePath = import_path12.default.join(nitroFuncDir, "package.json");
38592
- const clientPackagePath = import_path12.default.join(prismaClientDir, "package.json");
38674
+ const functionPackagePath = import_path13.default.join(nitroFuncDir, "package.json");
38675
+ const clientPackagePath = import_path13.default.join(prismaClientDir, "package.json");
38593
38676
  const [functionPackageContent, clientPackageContent] = await Promise.all([
38594
38677
  fs12.readFile(functionPackagePath, "utf-8"),
38595
38678
  fs12.readFile(clientPackagePath, "utf-8")
@@ -38704,7 +38787,9 @@ async function buildWithProductionNodeEnv(config, options) {
38704
38787
  suppressLintOnLink: config.suppressLintOnLink,
38705
38788
  componentExtensions: config.renderer.componentExtensions,
38706
38789
  i18nConfig: config.i18n
38707
- }).catch(() => {
38790
+ }).catch((error) => {
38791
+ const message = error instanceof Error ? error.message : String(error);
38792
+ logger.warn(`Route type generation failed (farm.d.ts may be stale): ${message}`);
38708
38793
  });
38709
38794
  const apiRouteManager = new APIRouteManager(
38710
38795
  getFarmAppDirectories(config),
@@ -38730,9 +38815,9 @@ async function buildWithProductionNodeEnv(config, options) {
38730
38815
  } else {
38731
38816
  const { build: legacyViteBuild } = await import("vite");
38732
38817
  logger.info("\u{1F4E6} Building client bundle...");
38733
- await buildClient2(legacyViteBuild, config, root, srcDir, import_path14.default.join(root, distDir, "client"));
38818
+ await buildClient2(legacyViteBuild, config, root, srcDir, import_path15.default.join(root, distDir, "client"));
38734
38819
  logger.info("\u{1F4E6} Building SSR bundle...");
38735
- await buildSSR(legacyViteBuild, config, root, srcDir, import_path14.default.join(root, distDir, "server"));
38820
+ await buildSSR(legacyViteBuild, config, root, srcDir, import_path15.default.join(root, distDir, "server"));
38736
38821
  logger.info(`\u{1F680} Building server with Nitro (preset: ${preset})...`);
38737
38822
  await buildNitro(
38738
38823
  config,
@@ -38754,7 +38839,7 @@ async function buildWithProductionNodeEnv(config, options) {
38754
38839
  outputDir: deployOutputDir,
38755
38840
  success: true
38756
38841
  });
38757
- logger.success("\u2705 Build completed successfully!");
38842
+ logger.success(`\u2705 Build completed successfully! (preset: ${preset})`);
38758
38843
  logger.info(`\u{1F4C1} Output directory: ${deployOutputDir}`);
38759
38844
  } catch (error) {
38760
38845
  await pluginManager.runHookParallel("onError", {
@@ -38902,12 +38987,12 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
38902
38987
  }
38903
38988
  __name(buildSSR, "buildSSR");
38904
38989
  function resolveLegacyPageEntry(config, root, srcDir) {
38905
- const appDir = import_path14.default.join(root, srcDir, "app");
38990
+ const appDir = import_path15.default.join(root, srcDir, "app");
38906
38991
  for (const extension of getFarmRendererComponentExtensions(config.renderer)) {
38907
- const candidate = import_path14.default.join(appDir, `page${extension}`);
38992
+ const candidate = import_path15.default.join(appDir, `page${extension}`);
38908
38993
  if ((0, import_node_fs12.existsSync)(candidate)) return candidate;
38909
38994
  }
38910
- return import_path14.default.join(appDir, "page.tsx");
38995
+ return import_path15.default.join(appDir, "page.tsx");
38911
38996
  }
38912
38997
  __name(resolveLegacyPageEntry, "resolveLegacyPageEntry");
38913
38998
  async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
@@ -38926,18 +39011,18 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
38926
39011
  nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
38927
39012
  }
38928
39013
  const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
38929
- const serverOutputDir = import_path14.default.join(outputDir, "server");
38930
- const publicOutputDir = import_path14.default.join(outputDir, "public");
39014
+ const serverOutputDir = import_path15.default.join(outputDir, "server");
39015
+ const publicOutputDir = import_path15.default.join(outputDir, "public");
38931
39016
  const { mkdir: mkdir2, cp } = await import("fs/promises");
38932
39017
  await mkdir2(serverOutputDir, { recursive: true });
38933
39018
  await mkdir2(publicOutputDir, { recursive: true });
38934
- const clientDir = import_path14.default.join(root, distDir, "client");
39019
+ const clientDir = import_path15.default.join(root, distDir, "client");
38935
39020
  try {
38936
39021
  await mkdir2(publicOutputDir, { recursive: true });
38937
39022
  await cp(clientDir, publicOutputDir, { recursive: true });
38938
39023
  logger.info("\u{1F4E6} Copied client assets to public directory");
38939
- const manifestPath = import_path14.default.join(publicOutputDir, "farm-client-manifest.json");
38940
- const assetsDir = import_path14.default.join(publicOutputDir, "assets");
39024
+ const manifestPath = import_path15.default.join(publicOutputDir, "farm-client-manifest.json");
39025
+ const assetsDir = import_path15.default.join(publicOutputDir, "assets");
38941
39026
  const manifestExists = await import("fs/promises").then(
38942
39027
  (fs12) => fs12.access(manifestPath).then(() => true).catch(() => false)
38943
39028
  );
@@ -38953,8 +39038,8 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
38953
39038
  logger.error(`\u274C Failed to copy client assets: ${error}`);
38954
39039
  throw error;
38955
39040
  }
38956
- const serverDir = import_path14.default.join(root, distDir, "server");
38957
- const nitroServerDir = import_path14.default.join(root, distDir, ".nitro", "server", "farm");
39041
+ const serverDir = import_path15.default.join(root, distDir, "server");
39042
+ const nitroServerDir = import_path15.default.join(root, distDir, ".nitro", "server", "farm");
38958
39043
  try {
38959
39044
  await mkdir2(nitroServerDir, { recursive: true });
38960
39045
  await cp(serverDir, nitroServerDir, { recursive: true });
@@ -38963,7 +39048,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
38963
39048
  logger.warn(`Could not copy SSR bundles: ${error}`);
38964
39049
  }
38965
39050
  const nitro = await createNitro(nitroConfig);
38966
- const registryPath = import_path14.default.join(root, distDir, ".nitro", "server", "farm-registry.ts");
39051
+ const registryPath = import_path15.default.join(root, distDir, ".nitro", "server", "farm-registry.ts");
38967
39052
  try {
38968
39053
  const { farmRegistry } = await import(
38969
39054
  /* @vite-ignore */
@@ -38980,7 +39065,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
38980
39065
  }
38981
39066
  farmRegistry.routePaths = routePaths;
38982
39067
  try {
38983
- const clientManifestPath = import_path14.default.join(root, distDir, "client", "farm-client-manifest.json");
39068
+ const clientManifestPath = import_path15.default.join(root, distDir, "client", "farm-client-manifest.json");
38984
39069
  const { readFile: readFile7 } = await import("fs/promises");
38985
39070
  const manifestContent = await readFile7(clientManifestPath, "utf-8");
38986
39071
  farmRegistry.clientManifest = JSON.parse(manifestContent);