@farm.js/core 0.1.0-beta.22 → 0.1.0-beta.24

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 (132) hide show
  1. package/dist/agent-runtime.d.mts +2 -1
  2. package/dist/agent-runtime.d.ts +2 -1
  3. package/dist/{app-DwsTpyNZ.d.mts → app-DrFCUMHY.d.mts} +6 -3
  4. package/dist/app-markdown.d.mts +2 -1
  5. package/dist/app-markdown.d.ts +2 -1
  6. package/dist/{app-BB8GCH1g.d.ts → app-pwvKG2B1.d.ts} +6 -3
  7. package/dist/chunk-4IVNW5QD.mjs +82 -0
  8. package/dist/chunk-4IVNW5QD.mjs.map +1 -0
  9. package/dist/chunk-D42BNPZH.mjs +79 -0
  10. package/dist/chunk-D42BNPZH.mjs.map +1 -0
  11. package/dist/{chunk-LLPN5SEZ.mjs → chunk-DVPRBMU2.mjs} +2 -2
  12. package/dist/chunk-GQVQESLY.mjs +25 -0
  13. package/dist/chunk-GQVQESLY.mjs.map +1 -0
  14. package/dist/chunk-H53KVQUU.mjs +48 -0
  15. package/dist/chunk-H53KVQUU.mjs.map +1 -0
  16. package/dist/chunk-HCGQYYHI.mjs +1 -0
  17. package/dist/chunk-HCGQYYHI.mjs.map +1 -0
  18. package/dist/{chunk-XBKXKJX5.mjs → chunk-HVJHNKSP.mjs} +220 -63
  19. package/dist/chunk-HVJHNKSP.mjs.map +1 -0
  20. package/dist/{chunk-ZP73P4VR.mjs → chunk-HXE4VGH2.mjs} +79 -20
  21. package/dist/chunk-HXE4VGH2.mjs.map +1 -0
  22. package/dist/{chunk-UCYWGN2P.mjs → chunk-OHNSROHS.mjs} +1 -1
  23. package/dist/{chunk-FRPWCMMG.mjs → chunk-SBWOTAX4.mjs} +63 -2
  24. package/dist/chunk-SBWOTAX4.mjs.map +1 -0
  25. package/dist/{chunk-DAUR3WUZ.mjs → chunk-WO466YX5.mjs} +2 -2
  26. package/dist/chunk-WO466YX5.mjs.map +1 -0
  27. package/dist/{chunk-CEVMYGDL.mjs → chunk-YD5IRKVS.mjs} +13 -9
  28. package/dist/chunk-YD5IRKVS.mjs.map +1 -0
  29. package/dist/{client-plugins-QQntVkrv.d.mts → client-plugins-CCilIb_G.d.mts} +6 -2
  30. package/dist/{client-plugins-CbRum1fj.d.ts → client-plugins-DuuleQKk.d.ts} +6 -2
  31. package/dist/client-plugins.d.mts +2 -1
  32. package/dist/client-plugins.d.ts +2 -1
  33. package/dist/client.cjs +122 -35
  34. package/dist/client.cjs.map +1 -1
  35. package/dist/client.d.mts +2 -0
  36. package/dist/client.d.ts +2 -0
  37. package/dist/client.mjs +13 -2
  38. package/dist/config.d.mts +2 -1
  39. package/dist/config.d.ts +2 -1
  40. package/dist/{devtools-52FYXIEK.mjs → devtools-326RBQCN.mjs} +7 -6
  41. package/dist/{devtools-52FYXIEK.mjs.map → devtools-326RBQCN.mjs.map} +1 -1
  42. package/dist/docs.cjs.map +1 -1
  43. package/dist/docs.mjs +6 -5
  44. package/dist/index.cjs +910 -414
  45. package/dist/index.cjs.map +1 -1
  46. package/dist/index.d.mts +10 -7
  47. package/dist/index.d.ts +10 -7
  48. package/dist/index.mjs +66 -49
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/integrations.d.mts +2 -1
  51. package/dist/integrations.d.ts +2 -1
  52. package/dist/internal/build-runtime.cjs +720 -297
  53. package/dist/internal/build-runtime.cjs.map +1 -1
  54. package/dist/internal/build-runtime.d.mts +4 -3
  55. package/dist/internal/build-runtime.d.ts +4 -3
  56. package/dist/internal/build-runtime.mjs +15 -12
  57. package/dist/internal/config-runtime.cjs +41 -0
  58. package/dist/internal/config-runtime.cjs.map +1 -1
  59. package/dist/internal/config-runtime.d.mts +3 -2
  60. package/dist/internal/config-runtime.d.ts +3 -2
  61. package/dist/internal/config-runtime.mjs +5 -4
  62. package/dist/internal/production-runtime.cjs +178 -0
  63. package/dist/internal/production-runtime.cjs.map +1 -1
  64. package/dist/internal/production-runtime.d.mts +20 -6
  65. package/dist/internal/production-runtime.d.ts +20 -6
  66. package/dist/internal/production-runtime.mjs +13 -1
  67. package/dist/internal/production-runtime.mjs.map +1 -1
  68. package/dist/{metadata-B5jBJHq1.d.ts → metadata-DyPRG0wX.d.ts} +1 -1
  69. package/dist/{metadata-BxOJ4FJl.d.mts → metadata-_GHcAySx.d.mts} +1 -1
  70. package/dist/middleware.d.mts +4 -3
  71. package/dist/middleware.d.ts +4 -3
  72. package/dist/plugin.cjs +461 -155
  73. package/dist/plugin.cjs.map +1 -1
  74. package/dist/plugin.d.mts +2 -1
  75. package/dist/plugin.d.ts +2 -1
  76. package/dist/plugin.mjs +11 -8
  77. package/dist/{production-runtime-Bxua86uR.d.mts → production-runtime-C4cO3esK.d.mts} +1 -1
  78. package/dist/{production-runtime-CZqXjRVi.d.ts → production-runtime-DrEy8kBO.d.ts} +1 -1
  79. package/dist/{request-7V0GaZK_.d.mts → request-B2PpOxYK.d.mts} +1 -1
  80. package/dist/{request-B5XYBv5a.d.ts → request-D40lt6aN.d.ts} +1 -1
  81. package/dist/request.d.mts +3 -2
  82. package/dist/request.d.ts +3 -2
  83. package/dist/routes.d.mts +2 -1
  84. package/dist/routes.d.ts +2 -1
  85. package/dist/server-plugins.d.mts +3 -2
  86. package/dist/server-plugins.d.ts +3 -2
  87. package/dist/server.cjs +490 -167
  88. package/dist/server.cjs.map +1 -1
  89. package/dist/server.d.mts +8 -6
  90. package/dist/server.d.ts +8 -6
  91. package/dist/server.mjs +20 -11
  92. package/dist/server.mjs.map +1 -1
  93. package/dist/testing.d.mts +2 -1
  94. package/dist/testing.d.ts +2 -1
  95. package/dist/theme/client.cjs +115 -0
  96. package/dist/theme/client.cjs.map +1 -0
  97. package/dist/theme/client.d.mts +17 -0
  98. package/dist/theme/client.d.ts +17 -0
  99. package/dist/theme/client.mjs +16 -0
  100. package/dist/theme/client.mjs.map +1 -0
  101. package/dist/theme/index.cjs +71 -0
  102. package/dist/theme/index.cjs.map +1 -0
  103. package/dist/theme/index.d.mts +6 -0
  104. package/dist/theme/index.d.ts +6 -0
  105. package/dist/theme/index.mjs +9 -0
  106. package/dist/theme/index.mjs.map +1 -0
  107. package/dist/theme/server.cjs +191 -0
  108. package/dist/theme/server.cjs.map +1 -0
  109. package/dist/theme/server.d.mts +8 -0
  110. package/dist/theme/server.d.ts +8 -0
  111. package/dist/theme/server.mjs +18 -0
  112. package/dist/theme/server.mjs.map +1 -0
  113. package/dist/types-CsR8fpgF.d.mts +30 -0
  114. package/dist/types-CsR8fpgF.d.ts +30 -0
  115. package/dist/{utils-xTFxzu47.d.ts → utils-3sQgfkya.d.ts} +1 -1
  116. package/dist/{utils-s9pN0Yep.d.mts → utils-Bop7bly-.d.mts} +1 -1
  117. package/dist/version.cjs +1 -1
  118. package/dist/version.cjs.map +1 -1
  119. package/dist/version.mjs +1 -1
  120. package/dist/vite.cjs +485 -157
  121. package/dist/vite.cjs.map +1 -1
  122. package/dist/vite.d.mts +2 -1
  123. package/dist/vite.d.ts +2 -1
  124. package/dist/vite.mjs +11 -8
  125. package/package.json +25 -1
  126. package/dist/chunk-CEVMYGDL.mjs.map +0 -1
  127. package/dist/chunk-DAUR3WUZ.mjs.map +0 -1
  128. package/dist/chunk-FRPWCMMG.mjs.map +0 -1
  129. package/dist/chunk-XBKXKJX5.mjs.map +0 -1
  130. package/dist/chunk-ZP73P4VR.mjs.map +0 -1
  131. /package/dist/{chunk-LLPN5SEZ.mjs.map → chunk-DVPRBMU2.mjs.map} +0 -0
  132. /package/dist/{chunk-UCYWGN2P.mjs.map → chunk-OHNSROHS.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 path31 = value.trim();
287
- if (!path31.startsWith("/") || path31.includes("?") || path31.includes("#") || path31.includes("*")) {
286
+ const path32 = value.trim();
287
+ if (!path32.startsWith("/") || path32.includes("?") || path32.includes("#") || path32.includes("*")) {
288
288
  throw new TypeError(`${optionName} must be an absolute pathname without a query or wildcard`);
289
289
  }
290
- return path31.length > 1 ? path31.replace(/\/+$/, "") || "/" : path31;
290
+ return path32.length > 1 ? path32.replace(/\/+$/, "") || "/" : path32;
291
291
  }
292
292
  function parseBodySizeLimit(value, optionName = "bodySizeLimit") {
293
293
  if (typeof value === "number") {
@@ -384,7 +384,7 @@ async function readNodeRequestBody(request, limit) {
384
384
  request.resume?.();
385
385
  throw error;
386
386
  }
387
- return await new Promise((resolve6, reject) => {
387
+ return await new Promise((resolve7, reject) => {
388
388
  const chunks = [];
389
389
  let total = 0;
390
390
  let settled = false;
@@ -413,7 +413,7 @@ async function readNodeRequestBody(request, limit) {
413
413
  if (settled) return;
414
414
  settled = true;
415
415
  cleanup();
416
- resolve6(Buffer.concat(chunks, total));
416
+ resolve7(Buffer.concat(chunks, total));
417
417
  }, "onEnd");
418
418
  const onError = /* @__PURE__ */ __name((error) => rejectOnce(error), "onError");
419
419
  request.on("data", onData);
@@ -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, path31, input) {
1089
+ function defineTypedIntegrationRoute(method, path32, input) {
1090
1090
  return {
1091
- path: path31,
1091
+ path: path32,
1092
1092
  method,
1093
1093
  middleware: input.middleware,
1094
1094
  before: input.before,
@@ -1098,7 +1098,7 @@ function defineTypedIntegrationRoute(method, path31, input) {
1098
1098
  input: normalizeIntegrationRouteInputSchemas(input),
1099
1099
  handler: input.handler,
1100
1100
  __operation: defineIntegrationAPIOperation({
1101
- path: path31,
1101
+ path: path32,
1102
1102
  method,
1103
1103
  bodyFormat: input.bodyFormat,
1104
1104
  responseFormat: input.responseFormat,
@@ -1110,52 +1110,52 @@ function defineTypedIntegrationRoute(method, path31, input) {
1110
1110
  }
1111
1111
  function createIntegrationRouteFactory() {
1112
1112
  return {
1113
- get(path31, input) {
1113
+ get(path32, input) {
1114
1114
  return defineTypedIntegrationRoute(
1115
1115
  "GET",
1116
- path31,
1116
+ path32,
1117
1117
  input
1118
1118
  );
1119
1119
  },
1120
- post(path31, input) {
1120
+ post(path32, input) {
1121
1121
  return defineTypedIntegrationRoute(
1122
1122
  "POST",
1123
- path31,
1123
+ path32,
1124
1124
  {
1125
1125
  bodyFormat: "json",
1126
1126
  ...input
1127
1127
  }
1128
1128
  );
1129
1129
  },
1130
- put(path31, input) {
1130
+ put(path32, input) {
1131
1131
  return defineTypedIntegrationRoute(
1132
1132
  "PUT",
1133
- path31,
1133
+ path32,
1134
1134
  {
1135
1135
  bodyFormat: "json",
1136
1136
  ...input
1137
1137
  }
1138
1138
  );
1139
1139
  },
1140
- patch(path31, input) {
1141
- return defineTypedIntegrationRoute("PATCH", path31, {
1140
+ patch(path32, input) {
1141
+ return defineTypedIntegrationRoute("PATCH", path32, {
1142
1142
  bodyFormat: "json",
1143
1143
  ...input
1144
1144
  });
1145
1145
  },
1146
- delete(path31, input) {
1147
- return defineTypedIntegrationRoute("DELETE", path31, {
1146
+ delete(path32, input) {
1147
+ return defineTypedIntegrationRoute("DELETE", path32, {
1148
1148
  bodyFormat: "json",
1149
1149
  ...input
1150
1150
  });
1151
1151
  },
1152
- options(path31, input) {
1153
- return defineTypedIntegrationRoute("OPTIONS", path31, input);
1152
+ options(path32, input) {
1153
+ return defineTypedIntegrationRoute("OPTIONS", path32, input);
1154
1154
  },
1155
- head(path31, input) {
1155
+ head(path32, input) {
1156
1156
  return defineTypedIntegrationRoute(
1157
1157
  "HEAD",
1158
- path31,
1158
+ path32,
1159
1159
  input
1160
1160
  );
1161
1161
  }
@@ -1429,8 +1429,8 @@ async function parseIntegrationConfigSchema(integration, schema, value) {
1429
1429
  function createIntegrationConfigValidationError(integration, error) {
1430
1430
  const issues = Array.isArray(error.issues) && error.issues.length > 0 ? error.issues.map((issue) => {
1431
1431
  const normalizedPath = normalizeIntegrationValidationPath(issue.path);
1432
- const path31 = normalizedPath.length ? `${normalizedPath.join(".")}: ` : "";
1433
- return `${path31}${issue.message || "Invalid config"}`;
1432
+ const path32 = normalizedPath.length ? `${normalizedPath.join(".")}: ` : "";
1433
+ return `${path32}${issue.message || "Invalid config"}`;
1434
1434
  }).join("; ") : error.message || "Invalid config";
1435
1435
  return new Error(`Integration "${integration.type}" config validation failed: ${issues}`);
1436
1436
  }
@@ -2127,8 +2127,8 @@ function normalizeIntegrationValidationIssues(source, error) {
2127
2127
  }
2128
2128
  ];
2129
2129
  }
2130
- function normalizeIntegrationValidationPath(path31) {
2131
- return (path31 || []).map((segment) => {
2130
+ function normalizeIntegrationValidationPath(path32) {
2131
+ return (path32 || []).map((segment) => {
2132
2132
  const key = typeof segment === "object" && segment !== null && "key" in segment ? segment.key : segment;
2133
2133
  return typeof key === "symbol" ? key.description || key.toString() : key;
2134
2134
  });
@@ -3341,22 +3341,22 @@ async function prepareFarmWorkflowsForNitro(config) {
3341
3341
  }
3342
3342
  const root = config.root || process.cwd();
3343
3343
  const distDir = config.distDir || ".farm";
3344
- const fs8 = await import("fs/promises");
3345
- const path31 = await import("path");
3346
- const generatedDir = path31.join(root, distDir, ".nitro", "farm-workflows");
3347
- await fs8.mkdir(generatedDir, { recursive: true });
3344
+ const fs9 = await import("fs/promises");
3345
+ const path32 = await import("path");
3346
+ const generatedDir = path32.join(root, distDir, ".nitro", "farm-workflows");
3347
+ await fs9.mkdir(generatedDir, { recursive: true });
3348
3348
  const tasks = {};
3349
3349
  const scheduledTasks = createScheduledTasks(workflows);
3350
3350
  for (const workflow of workflows) {
3351
- const wrapperPath = path31.join(generatedDir, `${safeFileName(workflow.id)}.mjs`);
3352
- await fs8.writeFile(wrapperPath, createNitroTaskWrapper(workflow), "utf8");
3351
+ const wrapperPath = path32.join(generatedDir, `${safeFileName(workflow.id)}.mjs`);
3352
+ await fs9.writeFile(wrapperPath, createNitroTaskWrapper(workflow), "utf8");
3353
3353
  tasks[workflow.id] = {
3354
3354
  handler: wrapperPath,
3355
3355
  description: workflow.description || `Farm workflow ${workflow.id}`
3356
3356
  };
3357
3357
  }
3358
- const handlerPath = path31.join(generatedDir, "http-handler.mjs");
3359
- await fs8.writeFile(
3358
+ const handlerPath = path32.join(generatedDir, "http-handler.mjs");
3359
+ await fs9.writeFile(
3360
3360
  handlerPath,
3361
3361
  createNitroWorkflowHTTPHandler(
3362
3362
  workflowConfig,
@@ -3365,8 +3365,8 @@ async function prepareFarmWorkflowsForNitro(config) {
3365
3365
  ),
3366
3366
  "utf8"
3367
3367
  );
3368
- const manifestPath = path31.join(generatedDir, "manifest.json");
3369
- await fs8.writeFile(
3368
+ const manifestPath = path32.join(generatedDir, "manifest.json");
3369
+ await fs9.writeFile(
3370
3370
  manifestPath,
3371
3371
  JSON.stringify(
3372
3372
  {
@@ -3447,22 +3447,22 @@ function resolveWorkflowDefinition(module2) {
3447
3447
  return null;
3448
3448
  }
3449
3449
  async function findWorkflowFiles(root, dirs) {
3450
- const fs8 = await import("fs/promises");
3451
- const path31 = await import("path");
3450
+ const fs9 = await import("fs/promises");
3451
+ const path32 = await import("path");
3452
3452
  const files = [];
3453
3453
  for (const dir of dirs) {
3454
- const absoluteDir = path31.isAbsolute(dir) ? dir : path31.join(root, dir);
3454
+ const absoluteDir = path32.isAbsolute(dir) ? dir : path32.join(root, dir);
3455
3455
  if (!await pathExists(absoluteDir)) continue;
3456
3456
  await walkWorkflowDir(absoluteDir, files);
3457
3457
  }
3458
3458
  return files.sort();
3459
3459
  }
3460
3460
  async function walkWorkflowDir(dir, files) {
3461
- const fs8 = await import("fs/promises");
3462
- const path31 = await import("path");
3463
- const entries = await fs8.readdir(dir, { withFileTypes: true });
3461
+ const fs9 = await import("fs/promises");
3462
+ const path32 = await import("path");
3463
+ const entries = await fs9.readdir(dir, { withFileTypes: true });
3464
3464
  for (const entry of entries) {
3465
- const filePath = path31.join(dir, entry.name);
3465
+ const filePath = path32.join(dir, entry.name);
3466
3466
  if (entry.isDirectory()) {
3467
3467
  if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
3468
3468
  await walkWorkflowDir(filePath, files);
@@ -3474,20 +3474,20 @@ async function walkWorkflowDir(dir, files) {
3474
3474
  }
3475
3475
  }
3476
3476
  async function pathExists(filePath) {
3477
- const fs8 = await import("fs/promises");
3478
- return fs8.access(filePath).then(() => true).catch(() => false);
3477
+ const fs9 = await import("fs/promises");
3478
+ return fs9.access(filePath).then(() => true).catch(() => false);
3479
3479
  }
3480
3480
  function isWorkflowFile(fileName) {
3481
3481
  return /\.(?:ts|tsx|js|jsx|mjs|cjs)$/.test(fileName) && !/\.d\.[cm]?ts$/.test(fileName);
3482
3482
  }
3483
3483
  async function loadWorkflowModule(filePath, root) {
3484
- const fs8 = await import("fs/promises");
3485
- const path31 = await import("path");
3484
+ const fs9 = await import("fs/promises");
3485
+ const path32 = await import("path");
3486
3486
  const { pathToFileURL: pathToFileURL5 } = await import("url");
3487
3487
  const { build: build2 } = await import("esbuild");
3488
- const outDir = path31.join(root, ".farm", ".workflow-loader");
3489
- await fs8.mkdir(outDir, { recursive: true });
3490
- const outfile = path31.join(
3488
+ const outDir = path32.join(root, ".farm", ".workflow-loader");
3489
+ await fs9.mkdir(outDir, { recursive: true });
3490
+ const outfile = path32.join(
3491
3491
  outDir,
3492
3492
  `workflow-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`
3493
3493
  );
@@ -3511,7 +3511,7 @@ async function loadWorkflowModule(filePath, root) {
3511
3511
  `${pathToFileURL5(outfile).href}?t=${Date.now()}`
3512
3512
  );
3513
3513
  } finally {
3514
- await fs8.unlink(outfile).catch(() => void 0);
3514
+ await fs9.unlink(outfile).catch(() => void 0);
3515
3515
  }
3516
3516
  }
3517
3517
  function workflowIdFromFile(root, filePath) {
@@ -3781,14 +3781,14 @@ async function prepareFarmCronForNitro(config) {
3781
3781
  const cron = isResolvedCronConfig(config.cron) ? config.cron : resolveCronConfig(config.cron);
3782
3782
  const root = config.root || process.cwd();
3783
3783
  const distDir = config.distDir || ".farm";
3784
- const fs8 = await import("fs/promises");
3785
- const path31 = await import("path");
3786
- const manifestPath = path31.join(root, distDir, FARM_CRON_MANIFEST);
3787
- const generatedDir = path31.join(root, distDir, ".nitro", "farm-cron");
3784
+ const fs9 = await import("fs/promises");
3785
+ const path32 = await import("path");
3786
+ const manifestPath = path32.join(root, distDir, FARM_CRON_MANIFEST);
3787
+ const generatedDir = path32.join(root, distDir, ".nitro", "farm-cron");
3788
3788
  if (!cron.enabled) {
3789
3789
  await Promise.all([
3790
- fs8.rm(manifestPath, { force: true }),
3791
- fs8.rm(generatedDir, { recursive: true, force: true })
3790
+ fs9.rm(manifestPath, { force: true }),
3791
+ fs9.rm(generatedDir, { recursive: true, force: true })
3792
3792
  ]);
3793
3793
  return {
3794
3794
  jobs: [],
@@ -3796,21 +3796,21 @@ async function prepareFarmCronForNitro(config) {
3796
3796
  scheduledTasks: {}
3797
3797
  };
3798
3798
  }
3799
- await fs8.rm(generatedDir, { recursive: true, force: true });
3800
- await fs8.mkdir(generatedDir, { recursive: true });
3799
+ await fs9.rm(generatedDir, { recursive: true, force: true });
3800
+ await fs9.mkdir(generatedDir, { recursive: true });
3801
3801
  const tasks = {};
3802
3802
  for (const job of cron.jobs) {
3803
3803
  const taskName = getFarmCronTaskName(job.name);
3804
- const wrapperPath = path31.join(generatedDir, `${safeFileName2(job.name)}.mjs`);
3805
- await fs8.writeFile(wrapperPath, createNitroCronTaskWrapper(job, cron.secretEnv), "utf8");
3804
+ const wrapperPath = path32.join(generatedDir, `${safeFileName2(job.name)}.mjs`);
3805
+ await fs9.writeFile(wrapperPath, createNitroCronTaskWrapper(job, cron.secretEnv), "utf8");
3806
3806
  tasks[taskName] = {
3807
3807
  handler: wrapperPath,
3808
3808
  description: job.description || `Farm cron ${job.name}`
3809
3809
  };
3810
3810
  }
3811
3811
  const manifest = createFarmCronManifest(cron);
3812
- await fs8.mkdir(path31.dirname(manifestPath), { recursive: true });
3813
- await fs8.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
3812
+ await fs9.mkdir(path32.dirname(manifestPath), { recursive: true });
3813
+ await fs9.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
3814
3814
  `, "utf8");
3815
3815
  return {
3816
3816
  jobs: cron.jobs,
@@ -3891,7 +3891,7 @@ function normalizeCronJob(name, job) {
3891
3891
  if (!job || typeof job !== "object" || Array.isArray(job)) {
3892
3892
  throw new TypeError(`Farm cron ${JSON.stringify(name)} must be a configuration object.`);
3893
3893
  }
3894
- const path31 = normalizeCronPath(name, job.path);
3894
+ const path32 = normalizeCronPath(name, job.path);
3895
3895
  const rawSchedule = Array.isArray(job.schedule) ? job.schedule : [job.schedule];
3896
3896
  const schedule = [...new Set(rawSchedule.map((value) => normalizeCronExpression(name, value)))];
3897
3897
  if (schedule.length === 0) {
@@ -3900,7 +3900,7 @@ function normalizeCronJob(name, job) {
3900
3900
  return {
3901
3901
  name,
3902
3902
  schedule,
3903
- path: path31,
3903
+ path: path32,
3904
3904
  description: job.description?.trim() || void 0
3905
3905
  };
3906
3906
  }
@@ -3908,13 +3908,13 @@ function normalizeCronPath(name, value) {
3908
3908
  if (typeof value !== "string" || !value.trim().startsWith("/")) {
3909
3909
  throw new TypeError(`Farm cron ${JSON.stringify(name)} path must start with "/".`);
3910
3910
  }
3911
- const path31 = value.trim();
3912
- if (path31.startsWith("//") || path31.includes("?") || path31.includes("#")) {
3911
+ const path32 = value.trim();
3912
+ if (path32.startsWith("//") || path32.includes("?") || path32.includes("#")) {
3913
3913
  throw new TypeError(
3914
3914
  `Farm cron ${JSON.stringify(name)} path must be an application pathname without a host, query, or hash.`
3915
3915
  );
3916
3916
  }
3917
- return path31.length > 1 ? path31.replace(/\/+$/, "") : path31;
3917
+ return path32.length > 1 ? path32.replace(/\/+$/, "") : path32;
3918
3918
  }
3919
3919
  function normalizeCronExpression(name, value) {
3920
3920
  if (typeof value !== "string") {
@@ -5298,8 +5298,8 @@ function createFarmDeploymentMismatchResponse(mismatch) {
5298
5298
  }
5299
5299
  );
5300
5300
  }
5301
- function createFarmDeploymentCookie(deploymentId, path31 = "/", secure = false) {
5302
- const normalizedPath = path31.startsWith("/") ? path31 : `/${path31}`;
5301
+ function createFarmDeploymentCookie(deploymentId, path32 = "/", secure = false) {
5302
+ const normalizedPath = path32.startsWith("/") ? path32 : `/${path32}`;
5303
5303
  return [
5304
5304
  `${FARM_DEPLOYMENT_COOKIE}=${encodeURIComponent(deploymentId)}`,
5305
5305
  `Path=${normalizedPath}`,
@@ -5371,7 +5371,7 @@ var init_devtools_config = __esm({
5371
5371
 
5372
5372
  // src/image-config.ts
5373
5373
  function resolveFarmImageConfig(config) {
5374
- const path31 = normalizeImagePath(config?.path ?? DEFAULT_FARM_IMAGE_PATH);
5374
+ const path32 = normalizeImagePath(config?.path ?? DEFAULT_FARM_IMAGE_PATH);
5375
5375
  const deviceSizes = normalizeIntegerList(
5376
5376
  config?.deviceSizes ?? DEFAULT_FARM_IMAGE_DEVICE_SIZES,
5377
5377
  "images.deviceSizes"
@@ -5399,7 +5399,7 @@ function resolveFarmImageConfig(config) {
5399
5399
  );
5400
5400
  return Object.freeze({
5401
5401
  provider: config?.provider ?? "auto",
5402
- path: path31,
5402
+ path: path32,
5403
5403
  domains: Object.freeze([
5404
5404
  ...new Set(
5405
5405
  (config?.domains ?? []).map((domain) => domain.trim().toLowerCase()).filter(Boolean)
@@ -5438,11 +5438,11 @@ function getPublicFarmImageConfig(config) {
5438
5438
  };
5439
5439
  }
5440
5440
  function normalizeImagePath(value) {
5441
- const path31 = value.trim().replace(/\/+$/, "") || "/";
5442
- if (!path31.startsWith("/") || path31.includes("?") || path31.includes("#")) {
5441
+ const path32 = value.trim().replace(/\/+$/, "") || "/";
5442
+ if (!path32.startsWith("/") || path32.includes("?") || path32.includes("#")) {
5443
5443
  throw new TypeError("images.path must be an absolute pathname without a query or hash");
5444
5444
  }
5445
- return path31;
5445
+ return path32;
5446
5446
  }
5447
5447
  function normalizeIntegerList(values, name, max) {
5448
5448
  if (values.length === 0) {
@@ -5920,6 +5920,52 @@ var init_security = __esm({
5920
5920
  }
5921
5921
  });
5922
5922
 
5923
+ // src/theme/config.ts
5924
+ function resolveFarmThemeConfig(config, basePath = "/") {
5925
+ if (config && "enabled" in config) {
5926
+ return config;
5927
+ }
5928
+ if (!config) {
5929
+ return {
5930
+ enabled: false,
5931
+ default: "system",
5932
+ storageKey: DEFAULT_FARM_THEME_STORAGE_KEY,
5933
+ cookiePath: normalizeCookiePath(basePath)
5934
+ };
5935
+ }
5936
+ const storageKey = config.storageKey?.trim() || DEFAULT_FARM_THEME_STORAGE_KEY;
5937
+ if (!STORAGE_KEY_PATTERN.test(storageKey)) {
5938
+ throw new Error(
5939
+ "theme.storageKey may only contain letters, numbers, dots, underscores, and hyphens."
5940
+ );
5941
+ }
5942
+ const defaultTheme = config.default ?? "system";
5943
+ if (defaultTheme !== "light" && defaultTheme !== "dark" && defaultTheme !== "system") {
5944
+ throw new Error('theme.default must be "light", "dark", or "system".');
5945
+ }
5946
+ return {
5947
+ enabled: true,
5948
+ default: defaultTheme,
5949
+ storageKey,
5950
+ cookiePath: normalizeCookiePath(basePath)
5951
+ };
5952
+ }
5953
+ function normalizeCookiePath(basePath) {
5954
+ const normalized = `/${basePath}`.replace(/\/{2,}/g, "/");
5955
+ if (normalized === "/") return normalized;
5956
+ return normalized.replace(/\/$/, "");
5957
+ }
5958
+ var DEFAULT_FARM_THEME_STORAGE_KEY, STORAGE_KEY_PATTERN;
5959
+ var init_config2 = __esm({
5960
+ "src/theme/config.ts"() {
5961
+ "use strict";
5962
+ DEFAULT_FARM_THEME_STORAGE_KEY = "farm-theme";
5963
+ STORAGE_KEY_PATTERN = /^[A-Za-z0-9._-]+$/;
5964
+ __name(resolveFarmThemeConfig, "resolveFarmThemeConfig");
5965
+ __name(normalizeCookiePath, "normalizeCookiePath");
5966
+ }
5967
+ });
5968
+
5923
5969
  // src/config-entry.ts
5924
5970
  var init_config_entry = __esm({
5925
5971
  "src/config-entry.ts"() {
@@ -6040,37 +6086,37 @@ function sanitizeDocsConfig(config) {
6040
6086
  return cloneSerializable(config) || {};
6041
6087
  }
6042
6088
  async function findDocsConfigPath(rootDir, configPath) {
6043
- const { existsSync: existsSync17 } = await import("fs");
6089
+ const { existsSync: existsSync18 } = await import("fs");
6044
6090
  const root = import_path2.default.resolve(rootDir || process.cwd());
6045
6091
  if (configPath) {
6046
6092
  const resolvedPath = import_path2.default.isAbsolute(configPath) ? configPath : import_path2.default.join(root, configPath);
6047
- if (!existsSync17(resolvedPath)) {
6093
+ if (!existsSync18(resolvedPath)) {
6048
6094
  throw new Error(`Could not find docs config at ${configPath}.`);
6049
6095
  }
6050
6096
  return import_path2.default.resolve(resolvedPath);
6051
6097
  }
6052
6098
  for (const filename of DOCS_CONFIG_FILENAMES) {
6053
6099
  const resolvedPath = import_path2.default.join(root, filename);
6054
- if (existsSync17(resolvedPath)) {
6100
+ if (existsSync18(resolvedPath)) {
6055
6101
  return resolvedPath;
6056
6102
  }
6057
6103
  }
6058
6104
  return void 0;
6059
6105
  }
6060
6106
  async function loadDocsConfig(rootDir, configPath) {
6061
- const fs8 = await import("fs/promises");
6107
+ const fs9 = await import("fs/promises");
6062
6108
  const { pathToFileURL: pathToFileURL5 } = await import("url");
6063
6109
  const root = import_path2.default.resolve(rootDir || process.cwd());
6064
6110
  const resolvedPath = await findDocsConfigPath(root, configPath);
6065
6111
  if (!resolvedPath) return void 0;
6066
6112
  try {
6067
6113
  if (resolvedPath.endsWith(".json")) {
6068
- const content = await fs8.readFile(resolvedPath, "utf8");
6114
+ const content = await fs9.readFile(resolvedPath, "utf8");
6069
6115
  return { config: JSON.parse(content), configPath: resolvedPath };
6070
6116
  }
6071
6117
  const { build: build2 } = await import("esbuild");
6072
6118
  const configCacheDir = import_path2.default.join(root, ".farm", ".config-loader");
6073
- await fs8.mkdir(configCacheDir, { recursive: true });
6119
+ await fs9.mkdir(configCacheDir, { recursive: true });
6074
6120
  const modulePath = import_path2.default.join(
6075
6121
  configCacheDir,
6076
6122
  `docs-config-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`
@@ -6096,7 +6142,7 @@ async function loadDocsConfig(rootDir, configPath) {
6096
6142
  moduleUrl
6097
6143
  );
6098
6144
  } finally {
6099
- await fs8.unlink(modulePath).catch(() => void 0);
6145
+ await fs9.unlink(modulePath).catch(() => void 0);
6100
6146
  }
6101
6147
  return {
6102
6148
  config: importedConfig.default || importedConfig,
@@ -6246,6 +6292,7 @@ async function resolveConfig(userConfig, mode) {
6246
6292
  routeRules,
6247
6293
  images: resolveFarmImageConfig(userConfig.images),
6248
6294
  performance: resolveFarmPerformanceConfig(userConfig.performance),
6295
+ theme: resolveFarmThemeConfig(userConfig.theme, userConfig.basePath || "/"),
6249
6296
  publicDir: userConfig.publicDir || "public",
6250
6297
  i18n: resolveFarmI18nConfig(userConfig.i18n, { root, mode }),
6251
6298
  openapi: {
@@ -6286,7 +6333,7 @@ async function resolveConfig(userConfig, mode) {
6286
6333
  return resolved;
6287
6334
  }
6288
6335
  async function loadConfig(rootDir, configPath, mode = process.env.NODE_ENV === "production" ? "production" : "development", loadEnvironment) {
6289
- const { existsSync: existsSync17 } = await import("fs");
6336
+ const { existsSync: existsSync18 } = await import("fs");
6290
6337
  const loadEnv = loadEnvironment || (await import("vite")).loadEnv;
6291
6338
  const root = rootDir || process.cwd();
6292
6339
  const loadedEnv = loadEnv(mode, root, "");
@@ -6310,7 +6357,7 @@ async function loadConfig(rootDir, configPath, mode = process.env.NODE_ENV === "
6310
6357
  try {
6311
6358
  const absolutePath = relativePath2.startsWith("/") ? relativePath2 : import_path2.default.join(root, relativePath2);
6312
6359
  const normalizedPath = import_path2.default.resolve(absolutePath);
6313
- if (!existsSync17(normalizedPath)) {
6360
+ if (!existsSync18(normalizedPath)) {
6314
6361
  continue;
6315
6362
  }
6316
6363
  const loadedConfig = await loadFarmConfigFile(normalizedPath, { root });
@@ -6323,7 +6370,7 @@ async function loadConfig(rootDir, configPath, mode = process.env.NODE_ENV === "
6323
6370
  return void 0;
6324
6371
  }
6325
6372
  var import_path2, FARM_RESOLVED_CUSTOM_CONTEXT, DOCS_CONFIG_FILENAMES;
6326
- var init_config2 = __esm({
6373
+ var init_config3 = __esm({
6327
6374
  "src/config.ts"() {
6328
6375
  "use strict";
6329
6376
  init_integrations();
@@ -6344,6 +6391,7 @@ var init_config2 = __esm({
6344
6391
  init_auth_config();
6345
6392
  init_preload();
6346
6393
  init_security();
6394
+ init_config2();
6347
6395
  init_config_entry();
6348
6396
  FARM_RESOLVED_CUSTOM_CONTEXT = /* @__PURE__ */ Symbol.for("farm.resolvedCustomContext");
6349
6397
  __name(hasCustomFarmRouteContext, "hasCustomFarmRouteContext");
@@ -6486,8 +6534,8 @@ function toViteModuleId(filePath, root) {
6486
6534
  }
6487
6535
  async function fileExists(filePath) {
6488
6536
  try {
6489
- const fs8 = await import("fs/promises");
6490
- await fs8.access(filePath);
6537
+ const fs9 = await import("fs/promises");
6538
+ await fs9.access(filePath);
6491
6539
  return true;
6492
6540
  } catch {
6493
6541
  return false;
@@ -7356,7 +7404,7 @@ function normalizePositiveDuration(value, fallback, name) {
7356
7404
  return Math.floor(value);
7357
7405
  }
7358
7406
  function delay(ms) {
7359
- return new Promise((resolve6) => setTimeout(resolve6, ms));
7407
+ return new Promise((resolve7) => setTimeout(resolve7, ms));
7360
7408
  }
7361
7409
  function normalizeCacheOptionsTags(options) {
7362
7410
  const tags = /* @__PURE__ */ new Set();
@@ -7916,7 +7964,7 @@ function getProgrammaticRouteSearchClientOptions(search) {
7916
7964
  if (search.temporary?.length) options.temporary = [...search.temporary];
7917
7965
  return Object.keys(options).length > 0 ? options : void 0;
7918
7966
  }
7919
- function resolveProgrammaticRouteSearch(searchConfig, rawSearch, path31, routePath) {
7967
+ function resolveProgrammaticRouteSearch(searchConfig, rawSearch, path32, routePath) {
7920
7968
  const schema = getProgrammaticRouteSearchSchema(searchConfig);
7921
7969
  const search = parseProgrammaticSchema(schema, rawSearch, "search", routePath);
7922
7970
  const options = getProgrammaticRouteSearchOptions(searchConfig);
@@ -7925,7 +7973,7 @@ function resolveProgrammaticRouteSearch(searchConfig, rawSearch, path31, routePa
7925
7973
  schema,
7926
7974
  rawSearch,
7927
7975
  parsedSearch: search,
7928
- path: path31
7976
+ path: path32
7929
7977
  });
7930
7978
  return { search, canonicalPath };
7931
7979
  }
@@ -8092,7 +8140,7 @@ function createRouteModuleFromProgrammaticPage(route) {
8092
8140
  mod.__farmRouteData = route.data;
8093
8141
  mod.__farmRouteParsesProps = true;
8094
8142
  mod.__farmResolveRouteProps = (props) => resolveProgrammaticRouteProps(route, props);
8095
- mod.__farmResolveRouteCanonicalPath = (rawSearch, path31) => resolveProgrammaticRouteSearch(route.search, rawSearch, path31, route.path).canonicalPath;
8143
+ mod.__farmResolveRouteCanonicalPath = (rawSearch, path32) => resolveProgrammaticRouteSearch(route.search, rawSearch, path32, route.path).canonicalPath;
8096
8144
  }
8097
8145
  if (route.pending || route.error || route.notFound) {
8098
8146
  mod.__farmRouteComponents = {
@@ -8490,25 +8538,25 @@ var init_routes = __esm({
8490
8538
  ];
8491
8539
  __name(defineRoutes, "defineRoutes");
8492
8540
  routesBuilder = {
8493
- page(path31, options) {
8541
+ page(path32, options) {
8494
8542
  return normalizeProgrammaticRoute({
8495
8543
  kind: "page",
8496
- path: path31,
8544
+ path: path32,
8497
8545
  ...options
8498
8546
  });
8499
8547
  },
8500
- layout(path31, options) {
8548
+ layout(path32, options) {
8501
8549
  return normalizeProgrammaticRoute({
8502
8550
  kind: "layout",
8503
- path: path31,
8551
+ path: path32,
8504
8552
  ...options
8505
8553
  });
8506
8554
  },
8507
- api(path31, options) {
8555
+ api(path32, options) {
8508
8556
  const { render, runtime, regions, maxDuration, ...methods } = options;
8509
8557
  return normalizeProgrammaticRoute({
8510
8558
  kind: "api",
8511
- path: path31,
8559
+ path: path32,
8512
8560
  render,
8513
8561
  runtime,
8514
8562
  regions,
@@ -8878,6 +8926,35 @@ function getIslandStrategyExport(content) {
8878
8926
  function stripUseClientDirective(content) {
8879
8927
  return content.replace(/^\s*(["'])use client\1\s*;?\s*/, "");
8880
8928
  }
8929
+ function hasAsyncDefaultExport(content) {
8930
+ if (!content) return false;
8931
+ const tokens = tokenizeModuleSource(content);
8932
+ for (let index = 0; index < tokens.length - 2; index++) {
8933
+ const token = tokens[index];
8934
+ if (token.kind !== "identifier" || token.value !== "export") continue;
8935
+ if (tokens[index - 1]?.value === ".") continue;
8936
+ if (tokens[index + 1]?.value !== "default") continue;
8937
+ const exported = tokens[index + 2];
8938
+ if (exported.kind === "identifier" && exported.value === "async") {
8939
+ return true;
8940
+ }
8941
+ if (exported.kind === "identifier" && !["function", "class"].includes(exported.value) && tokens[index + 3]?.value !== "(" && isAsyncLocalDeclaration(tokens, exported.value)) {
8942
+ return true;
8943
+ }
8944
+ }
8945
+ return false;
8946
+ }
8947
+ function isAsyncLocalDeclaration(tokens, name) {
8948
+ for (let index = 0; index < tokens.length - 2; index++) {
8949
+ if (tokens[index].value === "async" && tokens[index + 1]?.value === "function" && tokens[index + 2]?.value === name) {
8950
+ return true;
8951
+ }
8952
+ if (tokens[index].value === name && tokens[index + 1]?.value === "=" && tokens[index + 2]?.value === "async") {
8953
+ return true;
8954
+ }
8955
+ }
8956
+ return false;
8957
+ }
8881
8958
  function parseClientModuleMetadata(content, inspectIslandExport) {
8882
8959
  if (!content) {
8883
8960
  return {
@@ -8931,6 +9008,14 @@ function inspectClientModuleMetadata(resolvedPath, root, visited, inspectIslandE
8931
9008
  }
8932
9009
  }
8933
9010
  const shouldHydrate = parsed.hasHydrateExport || importsClientBoundary;
9011
+ if (shouldHydrate && hasAsyncDefaultExport(content)) {
9012
+ return {
9013
+ isClientComponent: false,
9014
+ shouldHydrate: false,
9015
+ islandStrategy: null,
9016
+ suppressedAsyncHydration: true
9017
+ };
9018
+ }
8934
9019
  return {
8935
9020
  isClientComponent: false,
8936
9021
  shouldHydrate,
@@ -9231,6 +9316,8 @@ var init_client_component = __esm({
9231
9316
  __name(isIslandExportStart, "isIslandExportStart");
9232
9317
  __name(getIslandStrategyExport, "getIslandStrategyExport");
9233
9318
  __name(stripUseClientDirective, "stripUseClientDirective");
9319
+ __name(hasAsyncDefaultExport, "hasAsyncDefaultExport");
9320
+ __name(isAsyncLocalDeclaration, "isAsyncLocalDeclaration");
9234
9321
  __name(parseClientModuleMetadata, "parseClientModuleMetadata");
9235
9322
  __name(getClientModuleMetadata, "getClientModuleMetadata");
9236
9323
  __name(inspectClientModuleMetadata, "inspectClientModuleMetadata");
@@ -9791,6 +9878,7 @@ var init_route_manager = __esm({
9791
9878
  shouldHydrate: metadata.shouldHydrate,
9792
9879
  isClientComponent: metadata.isClientComponent,
9793
9880
  islandStrategy: metadata.islandStrategy,
9881
+ suppressedAsyncHydration: metadata.suppressedAsyncHydration,
9794
9882
  search: getProgrammaticRouteSearchClientOptions(programmaticPage?.search),
9795
9883
  segments: entry.route.segments.map((seg) => ({
9796
9884
  segment: seg.segment,
@@ -10442,6 +10530,15 @@ function createWebRequestFromFarmRequest(req) {
10442
10530
  async function _runWithCurrentRequest(request, fn) {
10443
10531
  return requestStore.run(request, fn);
10444
10532
  }
10533
+ function getCurrentRequest() {
10534
+ const request = requestStore.getStore();
10535
+ if (!request) {
10536
+ throw new Error(
10537
+ "No current request is available. getCurrentRequest() can only be used during server rendering."
10538
+ );
10539
+ }
10540
+ return request;
10541
+ }
10445
10542
  var import_node_async_hooks2, REQUEST_STORAGE_KEY, requestStore;
10446
10543
  var init_request = __esm({
10447
10544
  "src/server/request.ts"() {
@@ -10454,6 +10551,7 @@ var init_request = __esm({
10454
10551
  _setCurrentRequestResolver(() => requestStore.getStore());
10455
10552
  __name(createWebRequestFromFarmRequest, "createWebRequestFromFarmRequest");
10456
10553
  __name(_runWithCurrentRequest, "_runWithCurrentRequest");
10554
+ __name(getCurrentRequest, "getCurrentRequest");
10457
10555
  }
10458
10556
  });
10459
10557
 
@@ -12961,12 +13059,158 @@ body {
12961
13059
  }
12962
13060
  });
12963
13061
 
13062
+ // src/theme/server-runtime.ts
13063
+ function createFarmThemeDocumentParts(input, basePath = "/", serverTheme) {
13064
+ const config = resolveFarmThemeConfig(input, basePath);
13065
+ if (!config.enabled) return { attributes: "", head: "" };
13066
+ const hydrationTheme = serverTheme ?? config.default;
13067
+ const initialTheme = hydrationTheme === "system" ? "light" : hydrationTheme;
13068
+ const script = createFarmThemeBootstrapScript(config, hydrationTheme);
13069
+ return {
13070
+ attributes: ` data-theme="${initialTheme}"`,
13071
+ head: `<style id="${THEME_STYLE_ID}">:root[data-theme="light"]{color-scheme:light}:root[data-theme="dark"]{color-scheme:dark}</style><script id="${THEME_SCRIPT_ID}">${script}</script>`
13072
+ };
13073
+ }
13074
+ function createFarmThemeBootstrapScript(config, serverTheme = config.default) {
13075
+ return `(function(config,serverTheme){
13076
+ var isTheme=function(value){return value==="light"||value==="dark"||value==="system";};
13077
+ var decode=function(value){try{return decodeURIComponent(value);}catch(_error){return value;}};
13078
+ var readCookie=function(){var entries=document.cookie.split(";");for(var index=0;index<entries.length;index++){var entry=entries[index];var separator=entry.indexOf("=");if(separator<0)continue;if(decode(entry.slice(0,separator).trim())===config.storageKey)return decode(entry.slice(separator+1).trim());}};
13079
+ var media=window.matchMedia("(prefers-color-scheme: dark)");
13080
+ var resolveTheme=function(theme){return theme==="system"?(media.matches?"dark":"light"):theme;};
13081
+ var storedTheme=readCookie();
13082
+ var preference=isTheme(storedTheme)?storedTheme:config.default;
13083
+ var serverSnapshot={theme:serverTheme,resolvedTheme:serverTheme==="system"?undefined:serverTheme,mounted:false};
13084
+ var apply=function(){var resolvedTheme=resolveTheme(preference);document.documentElement.dataset.theme=resolvedTheme;var snapshot={theme:preference,resolvedTheme:resolvedTheme,mounted:true};if(window.__FARM_THEME__)window.__FARM_THEME__.snapshot=snapshot;return snapshot;};
13085
+ var emit=function(){var snapshot=apply();window.dispatchEvent(new CustomEvent("farm:themechange",{detail:snapshot}));};
13086
+ var persist=function(theme){var secure=window.location.protocol==="https:"?"; Secure":"";document.cookie=encodeURIComponent(config.storageKey)+"="+encodeURIComponent(theme)+"; Path="+config.cookiePath+"; Max-Age=31536000; SameSite=Lax"+secure;try{localStorage.setItem(config.storageKey,theme);}catch(_error){}};
13087
+ var setTheme=function(theme){if(!isTheme(theme))throw new TypeError("Unknown FARMJS theme: "+String(theme));preference=theme;persist(theme);emit();};
13088
+ var initialSnapshot={theme:preference,resolvedTheme:resolveTheme(preference),mounted:true};
13089
+ window.__FARM_THEME__={config:config,serverSnapshot:serverSnapshot,snapshot:initialSnapshot,setTheme:setTheme};
13090
+ document.documentElement.dataset.theme=initialSnapshot.resolvedTheme;
13091
+ var handleSystemChange=function(){if(preference==="system")emit();};
13092
+ if(typeof media.addEventListener==="function")media.addEventListener("change",handleSystemChange);else if(typeof media.addListener==="function")media.addListener(handleSystemChange);
13093
+ window.addEventListener("storage",function(event){if(event.key!==config.storageKey||!isTheme(event.newValue))return;preference=event.newValue;persist(preference);emit();});
13094
+ })(${serializeInlineValue(config)},${serializeInlineValue(serverTheme)});`;
13095
+ }
13096
+ function serializeInlineValue(value) {
13097
+ return JSON.stringify(value).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
13098
+ }
13099
+ var THEME_SCRIPT_ID, THEME_STYLE_ID;
13100
+ var init_server_runtime = __esm({
13101
+ "src/theme/server-runtime.ts"() {
13102
+ "use strict";
13103
+ init_config2();
13104
+ THEME_SCRIPT_ID = "farm-theme-script";
13105
+ THEME_STYLE_ID = "farm-theme-style";
13106
+ __name(createFarmThemeDocumentParts, "createFarmThemeDocumentParts");
13107
+ __name(createFarmThemeBootstrapScript, "createFarmThemeBootstrapScript");
13108
+ __name(serializeInlineValue, "serializeInlineValue");
13109
+ }
13110
+ });
13111
+
13112
+ // src/theme/bridge.ts
13113
+ function _setFarmThemeServerSnapshotResolver(resolver) {
13114
+ globalThis[FARM_THEME_SERVER_SNAPSHOT_RESOLVER] = resolver;
13115
+ }
13116
+ var FALLBACK_SERVER_SNAPSHOT, FARM_THEME_SERVER_SNAPSHOT_RESOLVER;
13117
+ var init_bridge2 = __esm({
13118
+ "src/theme/bridge.ts"() {
13119
+ "use strict";
13120
+ FALLBACK_SERVER_SNAPSHOT = Object.freeze({
13121
+ theme: "system",
13122
+ resolvedTheme: void 0,
13123
+ mounted: false
13124
+ });
13125
+ FARM_THEME_SERVER_SNAPSHOT_RESOLVER = /* @__PURE__ */ Symbol.for("farm.js.theme.server-snapshot-resolver");
13126
+ __name(_setFarmThemeServerSnapshotResolver, "_setFarmThemeServerSnapshotResolver");
13127
+ }
13128
+ });
13129
+
13130
+ // src/theme/server.ts
13131
+ function _setDefaultFarmThemeConfig(config, basePath = "/") {
13132
+ defaultThemeConfig = resolveFarmThemeConfig(config, basePath);
13133
+ }
13134
+ function getTheme(request = getCurrentRequest()) {
13135
+ return readFarmThemePreference(request, defaultThemeConfig);
13136
+ }
13137
+ function getThemeSnapshot(request = getCurrentRequest()) {
13138
+ const theme = readFarmThemePreference(request, defaultThemeConfig);
13139
+ return {
13140
+ theme,
13141
+ resolvedTheme: theme === "system" ? void 0 : theme,
13142
+ mounted: false
13143
+ };
13144
+ }
13145
+ function readFarmThemePreference(request, config) {
13146
+ if (!config.enabled) return config.default;
13147
+ const stored = readCookie3(request.headers.get("cookie"), config.storageKey);
13148
+ return isFarmThemePreference(stored) ? stored : config.default;
13149
+ }
13150
+ function readCookie3(cookieHeader, name) {
13151
+ if (!cookieHeader) return void 0;
13152
+ for (const entry of cookieHeader.split(";")) {
13153
+ const separator = entry.indexOf("=");
13154
+ if (separator < 0) continue;
13155
+ const key = decodeCookieValue(entry.slice(0, separator).trim());
13156
+ if (key !== name) continue;
13157
+ return decodeCookieValue(entry.slice(separator + 1).trim());
13158
+ }
13159
+ return void 0;
13160
+ }
13161
+ function decodeCookieValue(value) {
13162
+ try {
13163
+ return decodeURIComponent(value);
13164
+ } catch {
13165
+ return value;
13166
+ }
13167
+ }
13168
+ function isFarmThemePreference(value) {
13169
+ return value === "light" || value === "dark" || value === "system";
13170
+ }
13171
+ var defaultThemeConfig;
13172
+ var init_server3 = __esm({
13173
+ "src/theme/server.ts"() {
13174
+ "use strict";
13175
+ init_request();
13176
+ init_bridge2();
13177
+ init_config2();
13178
+ defaultThemeConfig = resolveFarmThemeConfig(void 0);
13179
+ __name(_setDefaultFarmThemeConfig, "_setDefaultFarmThemeConfig");
13180
+ __name(getTheme, "getTheme");
13181
+ __name(getThemeSnapshot, "getThemeSnapshot");
13182
+ __name(readFarmThemePreference, "readFarmThemePreference");
13183
+ __name(readCookie3, "readCookie");
13184
+ __name(decodeCookieValue, "decodeCookieValue");
13185
+ __name(isFarmThemePreference, "isFarmThemePreference");
13186
+ _setFarmThemeServerSnapshotResolver(() => {
13187
+ try {
13188
+ return getThemeSnapshot();
13189
+ } catch {
13190
+ const theme = defaultThemeConfig.default;
13191
+ return {
13192
+ theme,
13193
+ resolvedTheme: theme === "system" ? void 0 : theme,
13194
+ mounted: false
13195
+ };
13196
+ }
13197
+ });
13198
+ }
13199
+ });
13200
+
12964
13201
  // src/server/renderer.ts
13202
+ function warnSuppressedAsyncHydrationOnce(modulePath) {
13203
+ if (warnedSuppressedAsyncHydrationModules.has(modulePath)) return;
13204
+ warnedSuppressedAsyncHydrationModules.add(modulePath);
13205
+ logger.warn(
13206
+ `${modulePath} is an async server component that imports client components. React cannot hydrate async components in the browser, so this route stays server-rendered and its client imports are not interactive. Move the interactive UI into a "use client" child rendered by a synchronous page, or enable experimental server components support.`
13207
+ );
13208
+ }
12965
13209
  function hasRequestHeader(req, name) {
12966
13210
  const value = req.headers[name.toLowerCase()];
12967
13211
  return Array.isArray(value) ? value.length > 0 : Boolean(value);
12968
13212
  }
12969
- function serializeInlineValue(value) {
13213
+ function serializeInlineValue2(value) {
12970
13214
  return JSON.stringify(value).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
12971
13215
  }
12972
13216
  function escapeHtmlAttribute2(value) {
@@ -13053,7 +13297,7 @@ function createDocumentFooter(options) {
13053
13297
  }
13054
13298
  function createDeferredHydrationScript(records) {
13055
13299
  if (records.length === 0) return "";
13056
- return `<script>window.__FARM_DEFERRED_DATA__=${serializeInlineValue(
13300
+ return `<script>window.__FARM_DEFERRED_DATA__=${serializeInlineValue2(
13057
13301
  snapshotDeferredData(records)
13058
13302
  )};</script>`;
13059
13303
  }
@@ -13116,7 +13360,7 @@ function createRouteStateProps(input) {
13116
13360
  context: input.pluginExposedContext.size > 0 ? { data: input.pluginExposedContext } : void 0
13117
13361
  };
13118
13362
  }
13119
- var import_react5, import_server2, fs2, path11, import_stream, cachedClerkProvider, importRuntimeModule, _FarmRouteErrorBoundary, FarmRouteErrorBoundary, _ServerRenderer, ServerRenderer;
13363
+ var import_react5, import_server2, fs2, path11, import_stream, cachedClerkProvider, importRuntimeModule, warnedSuppressedAsyncHydrationModules, _FarmRouteErrorBoundary, FarmRouteErrorBoundary, _ServerRenderer, ServerRenderer;
13120
13364
  var init_renderer = __esm({
13121
13365
  "src/server/renderer.ts"() {
13122
13366
  "use strict";
@@ -13146,10 +13390,14 @@ var init_renderer = __esm({
13146
13390
  init_font_vite();
13147
13391
  init_metadata_image();
13148
13392
  init_not_found();
13393
+ init_server_runtime();
13394
+ init_server3();
13149
13395
  cachedClerkProvider = null;
13150
13396
  importRuntimeModule = new Function("specifier", "return import(specifier);");
13397
+ warnedSuppressedAsyncHydrationModules = /* @__PURE__ */ new Set();
13398
+ __name(warnSuppressedAsyncHydrationOnce, "warnSuppressedAsyncHydrationOnce");
13151
13399
  __name(hasRequestHeader, "hasRequestHeader");
13152
- __name(serializeInlineValue, "serializeInlineValue");
13400
+ __name(serializeInlineValue2, "serializeInlineValue");
13153
13401
  __name(escapeHtmlAttribute2, "escapeHtmlAttribute");
13154
13402
  __name(appendResponseHeader, "appendResponseHeader");
13155
13403
  __name(appendResponseVary, "appendResponseVary");
@@ -13668,6 +13916,9 @@ var init_renderer = __esm({
13668
13916
  })
13669
13917
  );
13670
13918
  const shouldHydrate = moduleMetadata.shouldHydrate;
13919
+ if (moduleMetadata.suppressedAsyncHydration) {
13920
+ warnSuppressedAsyncHydrationOnce(route.modulePath);
13921
+ }
13671
13922
  const layoutHydrationMetadata = layouts.map((layout2) => {
13672
13923
  const manifestEntry = routeManifest.layouts.find(
13673
13924
  (entry) => entry.pattern === layout2.pattern
@@ -14165,7 +14416,7 @@ var init_renderer = __esm({
14165
14416
  }
14166
14417
  }
14167
14418
  async renderWithSSR(element, req, res, clearMiddlewareData, options = {}) {
14168
- return new Promise((resolve6, reject) => {
14419
+ return new Promise((resolve7, reject) => {
14169
14420
  const streamStartTime = Date.now();
14170
14421
  const observabilityRoute = options.observabilityRoute || req.__FARM_ROUTE__ || req.url || "/";
14171
14422
  const deploymentId = this.getDeploymentId();
@@ -14237,9 +14488,9 @@ var init_renderer = __esm({
14237
14488
  slots: routeSlotPayload
14238
14489
  });
14239
14490
  const propsScript = `<script>
14240
- window.__FARM_PROPS__ = ${serializeInlineValue(deferredProps.data.page)};
14241
- window.__FARM_ROUTE_SLOTS__ = ${serializeInlineValue(deferredProps.data.slots)};
14242
- window.__FARM_DEPLOYMENT_ID__ = ${serializeInlineValue(deploymentId)};
14491
+ window.__FARM_PROPS__ = ${serializeInlineValue2(deferredProps.data.page)};
14492
+ window.__FARM_ROUTE_SLOTS__ = ${serializeInlineValue2(deferredProps.data.slots)};
14493
+ window.__FARM_DEPLOYMENT_ID__ = ${serializeInlineValue2(deploymentId)};
14243
14494
  window.__FARM_PATH__ = ${JSON.stringify(req.__FARM_ROUTE__ || req.url || "/")};
14244
14495
  window.__FARM_IS_CLIENT__ = ${JSON.stringify(isClientComponent)};
14245
14496
  window.__FARM_PAGE_SHOULD_HYDRATE__ = ${JSON.stringify(
@@ -14257,7 +14508,7 @@ window.__FARM_LOADING_MODULE__ = ${JSON.stringify(
14257
14508
  )};
14258
14509
  window.__FARM_MANIFEST__ = ${JSON.stringify(clientManifest)};
14259
14510
  window.__FARM_INTEGRATION_API_MANIFEST__ = ${JSON.stringify(getRegisteredIntegrationAPIManifest())};
14260
- ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue(getFarmI18nClientSnapshot())};` : ""}
14511
+ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue2(getFarmI18nClientSnapshot())};` : ""}
14261
14512
  </script>`;
14262
14513
  const hydrationClickQueueScript = isClientComponent || req.__FARM_SHOULD_HYDRATE__ === true || req.__FARM_HAS_HYDRATABLE_ROUTE_SLOTS__ === true ? createPreHydrationClickQueueScript() : "";
14263
14514
  const {
@@ -14268,6 +14519,11 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue(g
14268
14519
  const i18nSnapshot = getFarmI18nClientSnapshot();
14269
14520
  const i18nAlternateTags = i18nSnapshot ? renderI18nAlternateLinks(req.__FARM_ROUTE__ || req.url || "/", i18nSnapshot) : "";
14270
14521
  const fontHead = renderFarmFontDevHead(this.config.root || process.cwd());
14522
+ const themeDocument = createFarmThemeDocumentParts(
14523
+ this.config.theme,
14524
+ this.config.basePath,
14525
+ getTheme()
14526
+ );
14271
14527
  const streamRoot = import_react5.default.createElement("div", { style: { display: "contents" } }, element);
14272
14528
  const { pipe } = (0, import_server2.renderToPipeableStream)(streamRoot, {
14273
14529
  onShellReady() {
@@ -14281,8 +14537,9 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue(g
14281
14537
  console.log(`[FARM STREAM] onShellReady at ${shellReadyMs}ms`);
14282
14538
  }
14283
14539
  const shell = `<!DOCTYPE html>
14284
- <html lang="${escapeHtmlAttribute2(i18nSnapshot?.locale || "en")}"${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}>
14540
+ <html lang="${escapeHtmlAttribute2(i18nSnapshot?.locale || "en")}"${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}${themeDocument.attributes}>
14285
14541
  <head>
14542
+ ${themeDocument.head}
14286
14543
  <meta charset="utf-8">
14287
14544
  <meta name="viewport" content="width=device-width, initial-scale=1">
14288
14545
  <meta name="farm-deployment-id" content="${escapeHtmlAttribute2(deploymentId)}">
@@ -14359,7 +14616,7 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue(g
14359
14616
  route: observabilityRoute,
14360
14617
  durationMs: Date.now() - streamStartTime
14361
14618
  });
14362
- resolve6();
14619
+ resolve7();
14363
14620
  }
14364
14621
  });
14365
14622
  res.write(shell);
@@ -14484,15 +14741,21 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue(g
14484
14741
  const i18nSnapshot = getFarmI18nClientSnapshot();
14485
14742
  const clientScript = isClientComponent ? ` <script type="module" src="/@farm/client.js"></script>` : "";
14486
14743
  const integrationManifestScript = `<script>
14487
- window.__FARM_DEPLOYMENT_ID__ = ${serializeInlineValue(this.getDeploymentId())};
14744
+ window.__FARM_DEPLOYMENT_ID__ = ${serializeInlineValue2(this.getDeploymentId())};
14488
14745
  window.__FARM_INTEGRATION_API_MANIFEST__ = ${JSON.stringify(getRegisteredIntegrationAPIManifest())};
14489
- ${i18nSnapshot ? `window.__FARM_I18N__ = ${serializeInlineValue(i18nSnapshot)};` : ""}
14746
+ ${i18nSnapshot ? `window.__FARM_I18N__ = ${serializeInlineValue2(i18nSnapshot)};` : ""}
14490
14747
  </script>`;
14491
14748
  const alternateLinks = i18nSnapshot ? renderI18nAlternateLinks(requestPath, i18nSnapshot) : "";
14492
14749
  const fontHead = renderFarmFontDevHead(this.config.root || process.cwd());
14750
+ const themeDocument = createFarmThemeDocumentParts(
14751
+ this.config.theme,
14752
+ this.config.basePath,
14753
+ getTheme()
14754
+ );
14493
14755
  return `<!DOCTYPE html>
14494
- <html lang="${escapeHtmlAttribute2(i18nSnapshot?.locale || "en")}"${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}>
14756
+ <html lang="${escapeHtmlAttribute2(i18nSnapshot?.locale || "en")}"${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}${themeDocument.attributes}>
14495
14757
  <head>
14758
+ ${themeDocument.head}
14496
14759
  <meta charset="utf-8">
14497
14760
  <meta name="viewport" content="width=device-width, initial-scale=1">
14498
14761
  <meta name="farm-deployment-id" content="${escapeHtmlAttribute2(this.getDeploymentId())}">
@@ -14576,6 +14839,8 @@ var init_app = __esm({
14576
14839
  init_auth_config();
14577
14840
  init_preload();
14578
14841
  init_security();
14842
+ init_config2();
14843
+ init_server3();
14579
14844
  defaultDocsConfig = {
14580
14845
  enabled: false,
14581
14846
  entry: "/docs",
@@ -14586,6 +14851,7 @@ var init_app = __esm({
14586
14851
  constructor(config = {}, viteServer) {
14587
14852
  this.config = this.normalizeConfig(config);
14588
14853
  configureFarmObservability(this.config.observability);
14854
+ _setDefaultFarmThemeConfig(this.config.theme);
14589
14855
  this.i18nRuntime = createFarmI18nRuntime(this.config.i18n);
14590
14856
  _setDefaultFarmI18nRuntime(this.i18nRuntime);
14591
14857
  this.viteServer = viteServer;
@@ -14644,6 +14910,7 @@ var init_app = __esm({
14644
14910
  security: resolveFarmSecurityConfig(config.security),
14645
14911
  images: resolveFarmImageConfig(config.images),
14646
14912
  performance: resolveFarmPerformanceConfig(config.performance),
14913
+ theme: resolveFarmThemeConfig(config.theme, config.basePath || "/"),
14647
14914
  i18n: isResolvedI18nConfig(config.i18n) ? config.i18n : resolveFarmI18nConfig(config.i18n, {
14648
14915
  root,
14649
14916
  mode: process.env.NODE_ENV === "production" ? "production" : "development"
@@ -16409,6 +16676,36 @@ var init_vite_config = __esm({
16409
16676
  }
16410
16677
  });
16411
16678
 
16679
+ // src/theme/vite.ts
16680
+ function createFarmThemeCssPlugin(input, basePath = "/") {
16681
+ const config = resolveFarmThemeConfig(input, basePath);
16682
+ return {
16683
+ name: "farm:theme-css",
16684
+ enforce: "pre",
16685
+ transform(code, id) {
16686
+ if (!config.enabled || !/\.css(?:\?.*)?$/.test(id) || !/@import\s+["']tailwindcss["']/.test(code) || /@custom-variant\s+dark\b/.test(code)) {
16687
+ return null;
16688
+ }
16689
+ return {
16690
+ code: `${code.trimEnd()}
16691
+
16692
+ ${FARM_DARK_VARIANT}
16693
+ `,
16694
+ map: null
16695
+ };
16696
+ }
16697
+ };
16698
+ }
16699
+ var FARM_DARK_VARIANT;
16700
+ var init_vite = __esm({
16701
+ "src/theme/vite.ts"() {
16702
+ "use strict";
16703
+ init_config2();
16704
+ FARM_DARK_VARIANT = '@custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));';
16705
+ __name(createFarmThemeCssPlugin, "createFarmThemeCssPlugin");
16706
+ }
16707
+ });
16708
+
16412
16709
  // src/default-styles.ts
16413
16710
  var defaultGlobalCSS;
16414
16711
  var init_default_styles = __esm({
@@ -17302,11 +17599,11 @@ var init_type_generator = __esm({
17302
17599
  routeGroups.get(key).push(route);
17303
17600
  }
17304
17601
  const nestedStructure = {};
17305
- for (const [path31, routeList] of routeGroups) {
17602
+ for (const [path32, routeList] of routeGroups) {
17306
17603
  const route = routeList[0];
17307
17604
  const importPath = this.getRouteImportPath(route, options.outFile);
17308
17605
  const routeName = this.pathToRouteName(route.path);
17309
- const cleanPath = path31 === "/api" ? "" : path31.replace(/^\/api\//, "");
17606
+ const cleanPath = path32 === "/api" ? "" : path32.replace(/^\/api\//, "");
17310
17607
  const parts = cleanPath ? cleanPath.split("/") : [];
17311
17608
  const allMethods = routeList.flatMap((r) => r.methods);
17312
17609
  for (const method of allMethods) {
@@ -17365,8 +17662,8 @@ ${typeExports}
17365
17662
  const relativeImport = (0, import_path10.relative)((0, import_path10.dirname)(outFile), route.filePath).replace(/\\/g, "/").replace(/\.(ts|tsx|js|jsx)$/, "");
17366
17663
  return relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`;
17367
17664
  }
17368
- pathToRouteName(path31) {
17369
- return (path31 === "/api" ? "root" : path31.replace(/^\/api\//, "")).replace(/\//g, "_").replace(/[^a-zA-Z0-9_]/g, "");
17665
+ pathToRouteName(path32) {
17666
+ return (path32 === "/api" ? "root" : path32.replace(/^\/api\//, "")).replace(/\//g, "_").replace(/[^a-zA-Z0-9_]/g, "");
17370
17667
  }
17371
17668
  structureToTypeString(obj, indent) {
17372
17669
  const spaces = " ".repeat(indent);
@@ -17386,15 +17683,15 @@ ${typeExports}
17386
17683
  toTypePropertyKey(key) {
17387
17684
  return /^[$A-Z_][0-9A-Z_$]*$/i.test(key) ? key : JSON.stringify(key);
17388
17685
  }
17389
- getBaseExportName(path31) {
17390
- const cleanPath = path31.replace(/^\/api\//, "");
17686
+ getBaseExportName(path32) {
17687
+ const cleanPath = path32.replace(/^\/api\//, "");
17391
17688
  if (cleanPath === "") {
17392
17689
  return "api";
17393
17690
  }
17394
17691
  return cleanPath;
17395
17692
  }
17396
- getExportName(path31, method) {
17397
- const cleanPath = path31.replace(/^\/api\//, "");
17693
+ getExportName(path32, method) {
17694
+ const cleanPath = path32.replace(/^\/api\//, "");
17398
17695
  if (cleanPath === "") {
17399
17696
  return method.toLowerCase();
17400
17697
  }
@@ -18081,7 +18378,7 @@ var init_type_artifacts = __esm({
18081
18378
  var version;
18082
18379
  var init_package = __esm({
18083
18380
  "package.json"() {
18084
- version = "0.1.0-beta.22";
18381
+ version = "0.1.0-beta.24";
18085
18382
  }
18086
18383
  });
18087
18384
 
@@ -18118,8 +18415,8 @@ function reportAfterError(state, error) {
18118
18415
  function createAfterRequestState(reportError = defaultAfterErrorReporter) {
18119
18416
  let resolveResponseFinished;
18120
18417
  let responseFinished = false;
18121
- const responseFinishedPromise = new Promise((resolve6) => {
18122
- resolveResponseFinished = resolve6;
18418
+ const responseFinishedPromise = new Promise((resolve7) => {
18419
+ resolveResponseFinished = resolve7;
18123
18420
  });
18124
18421
  const state = {
18125
18422
  completion: Promise.resolve(),
@@ -18202,6 +18499,40 @@ var init_after = __esm({
18202
18499
  }
18203
18500
  });
18204
18501
 
18502
+ // src/dev-static.ts
18503
+ function devServableFileExists(pathname, baseDirs) {
18504
+ let decodedPathname;
18505
+ try {
18506
+ decodedPathname = decodeURIComponent(pathname);
18507
+ } catch {
18508
+ return false;
18509
+ }
18510
+ const relativePathname = decodedPathname.replace(/^\/+/, "");
18511
+ if (!relativePathname) return false;
18512
+ for (const baseDir of baseDirs) {
18513
+ if (typeof baseDir !== "string" || baseDir.length === 0) continue;
18514
+ const resolvedBase = path24.resolve(baseDir);
18515
+ const candidate = path24.resolve(resolvedBase, relativePathname);
18516
+ if (!candidate.startsWith(resolvedBase + path24.sep)) continue;
18517
+ try {
18518
+ if (fs7.existsSync(candidate) && fs7.statSync(candidate).isFile()) {
18519
+ return true;
18520
+ }
18521
+ } catch {
18522
+ }
18523
+ }
18524
+ return false;
18525
+ }
18526
+ var fs7, path24;
18527
+ var init_dev_static = __esm({
18528
+ "src/dev-static.ts"() {
18529
+ "use strict";
18530
+ fs7 = __toESM(require("fs"));
18531
+ path24 = __toESM(require("path"));
18532
+ __name(devServableFileExists, "devServableFileExists");
18533
+ }
18534
+ });
18535
+
18205
18536
  // src/image-vite.ts
18206
18537
  function farmImageImportsPlugin() {
18207
18538
  return {
@@ -22495,7 +22826,7 @@ var init_api = __esm({
22495
22826
  "src/docs/api.ts"() {
22496
22827
  "use strict";
22497
22828
  import_docs2 = require("@farming-labs/docs");
22498
- init_config2();
22829
+ init_config3();
22499
22830
  init_handler();
22500
22831
  __name(isRecord4, "isRecord");
22501
22832
  __name(isResolvedDocsConfig2, "isResolvedDocsConfig");
@@ -22789,8 +23120,8 @@ var init_generator = __esm({
22789
23120
  }
22790
23121
  routeGroups.get(key).push(route);
22791
23122
  }
22792
- for (const [path31, routeList] of routeGroups) {
22793
- const openAPIPath = this.convertToOpenAPIPath(path31);
23123
+ for (const [path32, routeList] of routeGroups) {
23124
+ const openAPIPath = this.convertToOpenAPIPath(path32);
22794
23125
  spec.paths[openAPIPath] = {};
22795
23126
  for (const route of routeList) {
22796
23127
  for (const method of route.methods) {
@@ -22804,8 +23135,8 @@ var init_generator = __esm({
22804
23135
  /**
22805
23136
  * Convert Farm.js API path to OpenAPI path format
22806
23137
  */
22807
- convertToOpenAPIPath(path31) {
22808
- return path31.replace(/^\/api/, "");
23138
+ convertToOpenAPIPath(path32) {
23139
+ return path32.replace(/^\/api/, "");
22809
23140
  }
22810
23141
  /**
22811
23142
  * Extract request body schema from endpoint
@@ -22967,8 +23298,8 @@ var init_generator = __esm({
22967
23298
  /**
22968
23299
  * Generate operation summary
22969
23300
  */
22970
- generateSummary(path31, method) {
22971
- const cleanPath = path31.replace(/^\/api\//, "");
23301
+ generateSummary(path32, method) {
23302
+ const cleanPath = path32.replace(/^\/api\//, "");
22972
23303
  const pathParts = cleanPath.split("/");
22973
23304
  const lastPart = pathParts[pathParts.length - 1];
22974
23305
  const action = method === "GET" ? "Get" : method === "POST" ? "Create" : method === "PUT" ? "Update" : method === "DELETE" ? "Delete" : method === "PATCH" ? "Update" : method;
@@ -22977,22 +23308,22 @@ var init_generator = __esm({
22977
23308
  /**
22978
23309
  * Generate operation description
22979
23310
  */
22980
- generateDescription(path31, method) {
22981
- const cleanPath = path31.replace(/^\/api\//, "");
23311
+ generateDescription(path32, method) {
23312
+ const cleanPath = path32.replace(/^\/api\//, "");
22982
23313
  return `${method} ${cleanPath} endpoint`;
22983
23314
  }
22984
23315
  /**
22985
23316
  * Generate operation ID
22986
23317
  */
22987
- generateOperationId(path31, method) {
22988
- const cleanPath = path31.replace(/^\/api\//, "").replace(/\//g, "_");
23318
+ generateOperationId(path32, method) {
23319
+ const cleanPath = path32.replace(/^\/api\//, "").replace(/\//g, "_");
22989
23320
  return `${method.toLowerCase()}_${cleanPath}`;
22990
23321
  }
22991
23322
  /**
22992
23323
  * Generate tags for grouping operations
22993
23324
  */
22994
- generateTags(path31) {
22995
- const cleanPath = path31.replace(/^\/api\//, "");
23325
+ generateTags(path32) {
23326
+ const cleanPath = path32.replace(/^\/api\//, "");
22996
23327
  const pathParts = cleanPath.split("/");
22997
23328
  if (pathParts.length > 1) {
22998
23329
  return [pathParts[0]];
@@ -23004,13 +23335,13 @@ var init_generator = __esm({
23004
23335
  */
23005
23336
  async generateSpecFile(routes, outputPath) {
23006
23337
  const spec = await this.generateSpec(routes);
23007
- const fs8 = require("fs");
23008
- const path31 = require("path");
23009
- const dir = path31.dirname(outputPath);
23010
- if (!fs8.existsSync(dir)) {
23011
- fs8.mkdirSync(dir, { recursive: true });
23338
+ const fs9 = require("fs");
23339
+ const path32 = require("path");
23340
+ const dir = path32.dirname(outputPath);
23341
+ if (!fs9.existsSync(dir)) {
23342
+ fs9.mkdirSync(dir, { recursive: true });
23012
23343
  }
23013
- fs8.writeFileSync(outputPath, JSON.stringify(spec, null, 2));
23344
+ fs9.writeFileSync(outputPath, JSON.stringify(spec, null, 2));
23014
23345
  }
23015
23346
  };
23016
23347
  __name(_OpenAPIGenerator, "OpenAPIGenerator");
@@ -23480,7 +23811,7 @@ var init_devtools = __esm({
23480
23811
  "src/devtools.ts"() {
23481
23812
  "use strict";
23482
23813
  import_node_path14 = __toESM(require("path"));
23483
- init_config2();
23814
+ init_config3();
23484
23815
  init_cron();
23485
23816
  init_route_runtime();
23486
23817
  __name(normalizePath, "normalizePath");
@@ -25298,18 +25629,18 @@ function isPotentialProgrammaticRouteSourceFile(normalizedFile, srcDirSlug) {
25298
25629
  return normalizedFile.startsWith(`${srcDirSlug}/`) && /\.(ts|tsx|js|jsx)$/.test(normalizedFile) && !normalizedFile.endsWith(".d.ts") && !normalizedFile.endsWith("/farm-routes.d.ts") && !normalizedFile.endsWith("/farm-env.d.ts") && !normalizedFile.endsWith("/lib/api.generated.ts");
25299
25630
  }
25300
25631
  function fileContainsProgrammaticPageRoute(file) {
25301
- if (!fs7.existsSync(file)) {
25632
+ if (!fs8.existsSync(file)) {
25302
25633
  return false;
25303
25634
  }
25304
25635
  try {
25305
- return scanProgrammaticPagePaths(fs7.readFileSync(file, "utf8")).length > 0;
25636
+ return scanProgrammaticPagePaths(fs8.readFileSync(file, "utf8")).length > 0;
25306
25637
  } catch {
25307
25638
  return false;
25308
25639
  }
25309
25640
  }
25310
25641
  function rewriteEarlySsrRelativeImports(options) {
25311
25642
  const cleanId = options.id.split("?", 1)[0];
25312
- if (!path27.isAbsolute(cleanId) || cleanId.replace(/\\/g, "/").includes("/node_modules/")) {
25643
+ if (!path28.isAbsolute(cleanId) || cleanId.replace(/\\/g, "/").includes("/node_modules/")) {
25313
25644
  return null;
25314
25645
  }
25315
25646
  const replacements = [];
@@ -25329,7 +25660,7 @@ function rewriteEarlySsrRelativeImports(options) {
25329
25660
  const suffixIndex = source.value.search(/[?#]/);
25330
25661
  const sourcePath = suffixIndex === -1 ? source.value : source.value.slice(0, suffixIndex);
25331
25662
  const suffix = suffixIndex === -1 ? "" : source.value.slice(suffixIndex);
25332
- const resolvedPath = path27.resolve(path27.dirname(cleanId), sourcePath);
25663
+ const resolvedPath = path28.resolve(path28.dirname(cleanId), sourcePath);
25333
25664
  replacements.push({
25334
25665
  start: source.start,
25335
25666
  end: source.end,
@@ -25404,7 +25735,7 @@ function farmPlugin(options = {}, initialPluginManager) {
25404
25735
  ...layerRoots.length ? {
25405
25736
  server: {
25406
25737
  fs: {
25407
- allow: [path27.resolve(options.root || process.cwd()), ...layerRoots]
25738
+ allow: [path28.resolve(options.root || process.cwd()), ...layerRoots]
25408
25739
  }
25409
25740
  }
25410
25741
  } : {}
@@ -25435,13 +25766,13 @@ function farmPlugin(options = {}, initialPluginManager) {
25435
25766
  },
25436
25767
  server
25437
25768
  );
25438
- const globalsCSSPath = path27.join(server.config.root, "src/app/globals.css");
25439
- if (!fs7.existsSync(globalsCSSPath)) {
25440
- const appDir = path27.join(server.config.root, "src/app");
25441
- if (!fs7.existsSync(appDir)) {
25442
- fs7.mkdirSync(appDir, { recursive: true });
25769
+ const globalsCSSPath = path28.join(server.config.root, "src/app/globals.css");
25770
+ if (!fs8.existsSync(globalsCSSPath)) {
25771
+ const appDir = path28.join(server.config.root, "src/app");
25772
+ if (!fs8.existsSync(appDir)) {
25773
+ fs8.mkdirSync(appDir, { recursive: true });
25443
25774
  }
25444
- fs7.writeFileSync(globalsCSSPath, defaultGlobalCSS);
25775
+ fs8.writeFileSync(globalsCSSPath, defaultGlobalCSS);
25445
25776
  }
25446
25777
  await farmApp.initialize();
25447
25778
  const farmConfig = farmApp.getConfig();
@@ -25460,10 +25791,10 @@ function farmPlugin(options = {}, initialPluginManager) {
25460
25791
  });
25461
25792
  }
25462
25793
  const sourceRoots = getFarmSourceRoots(farmConfig);
25463
- server.watcher.add(sourceRoots.map((source) => path27.join(source.root, source.srcDir)));
25794
+ server.watcher.add(sourceRoots.map((source) => path28.join(source.root, source.srcDir)));
25464
25795
  if (farmConfig.i18n.enabled) {
25465
25796
  server.watcher.add(
25466
- farmConfig.i18n.messages.includes("{locale}") ? path27.dirname(farmConfig.i18n.messages) : farmConfig.i18n.messages
25797
+ farmConfig.i18n.messages.includes("{locale}") ? path28.dirname(farmConfig.i18n.messages) : farmConfig.i18n.messages
25467
25798
  );
25468
25799
  }
25469
25800
  const workflowConfig = farmConfig.workflows;
@@ -25473,7 +25804,7 @@ function farmPlugin(options = {}, initialPluginManager) {
25473
25804
  ...farmDocsDevRuntime?.getFarmDocsRouteTypeEntries(farmConfig.docs) ?? []
25474
25805
  ], "getExtraRouteTypes");
25475
25806
  const appDirSlugs = sourceRoots.map(
25476
- (source) => path27.join(source.root, source.srcDir, "app").replace(/\\/g, "/")
25807
+ (source) => path28.join(source.root, source.srcDir, "app").replace(/\\/g, "/")
25477
25808
  );
25478
25809
  const generateTypeArtifacts = /* @__PURE__ */ __name(async (reason, selection = ALL_TYPE_ARTIFACTS, log = false) => {
25479
25810
  try {
@@ -25513,7 +25844,7 @@ function farmPlugin(options = {}, initialPluginManager) {
25513
25844
  }, "generateTypeArtifacts");
25514
25845
  await generateTypeArtifacts("startup");
25515
25846
  const srcDirSlugs = sourceRoots.map(
25516
- (source) => path27.join(source.root, source.srcDir).replace(/\\/g, "/")
25847
+ (source) => path28.join(source.root, source.srcDir).replace(/\\/g, "/")
25517
25848
  );
25518
25849
  const layerConfigFiles = new Set(
25519
25850
  farmConfig.layers.map((layer) => layer.configFile?.replace(/\\/g, "/")).filter((file) => Boolean(file))
@@ -25631,7 +25962,7 @@ function farmPlugin(options = {}, initialPluginManager) {
25631
25962
  await apiRouteManager.discoverRoutes();
25632
25963
  let discoveredWorkflows = [];
25633
25964
  const hasWorkflowDirectory = workflowConfig.enabled && workflowConfig.dirs.some(
25634
- (dir) => fs7.existsSync(path27.isAbsolute(dir) ? dir : path27.join(farmConfig.root, dir))
25965
+ (dir) => fs8.existsSync(path28.isAbsolute(dir) ? dir : path28.join(farmConfig.root, dir))
25635
25966
  );
25636
25967
  if (hasWorkflowDirectory) {
25637
25968
  const { createFarmWorkflowRequestHandler: createFarmWorkflowRequestHandler2, discoverFarmWorkflows: discoverFarmWorkflows2 } = await loadFarmWorkflowsDevRuntime();
@@ -25865,12 +26196,12 @@ window.__FARM_MANIFEST__ = ${inlineValue({
25865
26196
  }
25866
26197
  }
25867
26198
  const farmDocsFontPath = farmDocsFontAssets.get(requestPathname);
25868
- if ((requestMethod === "GET" || requestMethod === "HEAD") && farmDocsFontPath && fs7.existsSync(farmDocsFontPath)) {
26199
+ if ((requestMethod === "GET" || requestMethod === "HEAD") && farmDocsFontPath && fs8.existsSync(farmDocsFontPath)) {
25869
26200
  res.statusCode = 200;
25870
26201
  res.setHeader("Content-Type", "font/woff2");
25871
26202
  res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
25872
26203
  if (requestMethod === "HEAD") res.end();
25873
- else fs7.createReadStream(farmDocsFontPath).pipe(res);
26204
+ else fs8.createReadStream(farmDocsFontPath).pipe(res);
25874
26205
  return;
25875
26206
  }
25876
26207
  if (requestMethod === "GET" && (requestPathname === FARM_DEVTOOLS_PATH || requestPathname === `${FARM_DEVTOOLS_PATH}.json`)) {
@@ -25968,7 +26299,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
25968
26299
  return null;
25969
26300
  }
25970
26301
  return {
25971
- source: await fs7.promises.readFile(sourcePath, "utf8"),
26302
+ source: await fs8.promises.readFile(sourcePath, "utf8"),
25972
26303
  filePath: sourcePath
25973
26304
  };
25974
26305
  }, "resolveSource")
@@ -26303,9 +26634,17 @@ window.__FARM_MANIFEST__ = ${inlineValue({
26303
26634
  res.end(JSON.stringify({ error: "API route not found", pathname: pathname2 }));
26304
26635
  return;
26305
26636
  }
26306
- if (req.url?.startsWith("/@") || req.url?.startsWith("/node_modules") || requestPathname.includes(".") && !requestPathname.endsWith(".html")) {
26637
+ if (req.url?.startsWith("/@") || req.url?.startsWith("/node_modules")) {
26307
26638
  return next();
26308
26639
  }
26640
+ if (requestPathname.includes(".") && !requestPathname.endsWith(".html")) {
26641
+ const matchesAppRoute = Boolean(
26642
+ farmApp?.getRouteManager()?.matchRoute(requestPathname)?.route
26643
+ );
26644
+ if (!matchesAppRoute || devServableFileExists(requestPathname, [server.config.publicDir, server.config.root])) {
26645
+ return next();
26646
+ }
26647
+ }
26309
26648
  if (req.url?.startsWith("/__farm/page-data")) {
26310
26649
  const urlObj = new URL(req.url, `http://${req.headers.host || "localhost:3000"}`);
26311
26650
  const targetPath = urlObj.searchParams.get("path") || "/";
@@ -27011,8 +27350,8 @@ if (import.meta.hot) {
27011
27350
  }
27012
27351
  logger.info(`Found ${ssgPages.length} SSG pages, ${ssrRoutes.length} SSR routes`);
27013
27352
  logger.info("Pre-rendering SSG pages...");
27014
- const outDir = path27.join(server?.config.root || process.cwd(), options.outDir || "dist");
27015
- const clientDir = path27.join(outDir, "client");
27353
+ const outDir = path28.join(server?.config.root || process.cwd(), options.outDir || "dist");
27354
+ const clientDir = path28.join(outDir, "client");
27016
27355
  for (const page2 of ssgPages) {
27017
27356
  try {
27018
27357
  const staticRequest = new Request(new URL(page2.urlPath, "http://farm.static"));
@@ -27064,9 +27403,9 @@ if (import.meta.hot) {
27064
27403
  <script type="module" src="/assets/client.js"></script>
27065
27404
  </body>
27066
27405
  </html>`;
27067
- const outputPath = page2.urlPath === "/" ? path27.join(clientDir, "index.html") : path27.join(clientDir, page2.urlPath + ".html");
27068
- fs7.mkdirSync(path27.dirname(outputPath), { recursive: true });
27069
- fs7.writeFileSync(outputPath, fullHtml);
27406
+ const outputPath = page2.urlPath === "/" ? path28.join(clientDir, "index.html") : path28.join(clientDir, page2.urlPath + ".html");
27407
+ fs8.mkdirSync(path28.dirname(outputPath), { recursive: true });
27408
+ fs8.writeFileSync(outputPath, fullHtml);
27070
27409
  const revalidateInfo = page2.revalidate ? ` (revalidate: ${page2.revalidate}s)` : "";
27071
27410
  logger.success(` \u2713 ${page2.urlPath}${revalidateInfo}`);
27072
27411
  });
@@ -27074,8 +27413,8 @@ if (import.meta.hot) {
27074
27413
  logger.error(` \u2717 ${page2.urlPath}: ${error}`);
27075
27414
  }
27076
27415
  }
27077
- const manifestPath = path27.join(outDir, "__ssg_manifest.json");
27078
- fs7.writeFileSync(
27416
+ const manifestPath = path28.join(outDir, "__ssg_manifest.json");
27417
+ fs8.writeFileSync(
27079
27418
  manifestPath,
27080
27419
  JSON.stringify(
27081
27420
  ssgPages.map((p) => ({
@@ -27110,9 +27449,9 @@ if (import.meta.hot) {
27110
27449
  }
27111
27450
  const currentFarmConfig = farmApp?.getConfig();
27112
27451
  const normalizedFile = file.replace(/\\/g, "/");
27113
- const currentSrcRoot = currentFarmConfig ? getFarmSourceRoots(currentFarmConfig).map((source) => path27.join(source.root, source.srcDir).replace(/\\/g, "/")).find((sourceRoot) => normalizedFile.startsWith(`${sourceRoot}/`)) || null : null;
27452
+ const currentSrcRoot = currentFarmConfig ? getFarmSourceRoots(currentFarmConfig).map((source) => path28.join(source.root, source.srcDir).replace(/\\/g, "/")).find((sourceRoot) => normalizedFile.startsWith(`${sourceRoot}/`)) || null : null;
27114
27453
  if (currentSrcRoot && normalizedFile.startsWith(`${currentSrcRoot}/`) && isProgrammaticRoutesFileName(normalizedFile)) {
27115
- logUpdate("PAGE", `updated ${path27.basename(file)}`);
27454
+ logUpdate("PAGE", `updated ${path28.basename(file)}`);
27116
27455
  for (const mod of modules) {
27117
27456
  server2.moduleGraph.invalidateModule(mod);
27118
27457
  }
@@ -28292,6 +28631,19 @@ async function tryHydrateImportedPage(
28292
28631
  const PageComponent = pageModule?.default;
28293
28632
  if (!PageComponent) return false;
28294
28633
 
28634
+ if (
28635
+ typeof PageComponent === 'function' &&
28636
+ PageComponent.constructor &&
28637
+ PageComponent.constructor.name === 'AsyncFunction'
28638
+ ) {
28639
+ console.warn(
28640
+ '[Farm.js] Skipping hydration for ' + modulePath +
28641
+ ': async server components cannot run in the browser. ' +
28642
+ 'Server-rendered HTML is preserved; move interactive UI into a "use client" child of a synchronous page.'
28643
+ );
28644
+ return false;
28645
+ }
28646
+
28295
28647
  currentPageComponent = PageComponent;
28296
28648
  currentPageProps = await buildRouteComponentProps(
28297
28649
  pageModule,
@@ -28458,14 +28810,22 @@ async function renderPage(pageData) {
28458
28810
  if (!doc.documentElement || !doc.body) return false;
28459
28811
 
28460
28812
  resetReactRoots();
28813
+ const activeFarmTheme =
28814
+ window.__FARM_THEME__?.snapshot?.resolvedTheme ||
28815
+ document.documentElement.getAttribute('data-theme');
28461
28816
  Array.from(document.documentElement.attributes).forEach(function(attr) {
28817
+ if (attr.name === 'data-theme') return;
28462
28818
  if (!doc.documentElement.hasAttribute(attr.name)) {
28463
28819
  document.documentElement.removeAttribute(attr.name);
28464
28820
  }
28465
28821
  });
28466
28822
  Array.from(doc.documentElement.attributes).forEach(function(attr) {
28823
+ if (attr.name === 'data-theme') return;
28467
28824
  document.documentElement.setAttribute(attr.name, attr.value);
28468
28825
  });
28826
+ if (activeFarmTheme) {
28827
+ document.documentElement.setAttribute('data-theme', activeFarmTheme);
28828
+ }
28469
28829
 
28470
28830
  document.head.innerHTML = doc.head ? doc.head.innerHTML : '';
28471
28831
  document.body.innerHTML = doc.body.innerHTML;
@@ -28474,6 +28834,7 @@ async function renderPage(pageData) {
28474
28834
 
28475
28835
  setTimeout(function() {
28476
28836
  Array.from(document.querySelectorAll('script')).forEach(function(script) {
28837
+ if (script.id === 'farm-theme-script') return;
28477
28838
  const freshScript = document.createElement('script');
28478
28839
  Array.from(script.attributes).forEach(function(attr) {
28479
28840
  freshScript.setAttribute(attr.name, attr.value);
@@ -28833,7 +29194,7 @@ function generateClientManifest(bundle) {
28833
29194
  }
28834
29195
  async function defineConfig2(config = {}) {
28835
29196
  const tailwindcss = (await import("@tailwindcss/vite")).default;
28836
- const appRoot = path27.resolve(config.root || process.cwd());
29197
+ const appRoot = path28.resolve(config.root || process.cwd());
28837
29198
  if (config.extends?.length) {
28838
29199
  const { config: layeredConfig } = await Promise.resolve().then(() => (init_layers(), layers_exports)).then(
28839
29200
  ({ resolveFarmLayers: resolveFarmLayers2 }) => resolveFarmLayers2(config, {
@@ -28968,6 +29329,7 @@ async function defineConfig2(config = {}) {
28968
29329
  };
28969
29330
  return {
28970
29331
  plugins: [
29332
+ createFarmThemeCssPlugin(config.theme, config.basePath),
28971
29333
  tailwindcss(),
28972
29334
  viteBrowserExternalPlugin,
28973
29335
  farmI18nClientBridgePlugin(),
@@ -29039,8 +29401,8 @@ async function defineConfig2(config = {}) {
29039
29401
  }
29040
29402
  };
29041
29403
  }
29042
- var fs7, path27, ALL_TYPE_ARTIFACTS, createEmptyTypeArtifactSelection, FARM_I18N_CLIENT_BRIDGE_ID, EMPTY_FARM_DOCS_SEARCH_CLIENT_RUNTIME, FARM_CONFIG_FILENAMES;
29043
- var init_vite = __esm({
29404
+ var fs8, path28, ALL_TYPE_ARTIFACTS, createEmptyTypeArtifactSelection, FARM_I18N_CLIENT_BRIDGE_ID, EMPTY_FARM_DOCS_SEARCH_CLIENT_RUNTIME, FARM_CONFIG_FILENAMES;
29405
+ var init_vite2 = __esm({
29044
29406
  "src/vite.ts"() {
29045
29407
  "use strict";
29046
29408
  init_app();
@@ -29058,13 +29420,14 @@ var init_vite = __esm({
29058
29420
  init_integrations();
29059
29421
  init_route_context();
29060
29422
  init_devtools_config();
29061
- fs7 = __toESM(require("fs"));
29062
- path27 = __toESM(require("path"));
29423
+ fs8 = __toESM(require("fs"));
29424
+ path28 = __toESM(require("path"));
29063
29425
  init_layers();
29064
29426
  init_environment_vite();
29065
29427
  init_version();
29066
29428
  init_deferred();
29067
29429
  init_after();
29430
+ init_dev_static();
29068
29431
  init_deployment();
29069
29432
  init_image_config();
29070
29433
  init_image_vite();
@@ -29077,6 +29440,7 @@ var init_vite = __esm({
29077
29440
  init_fonts();
29078
29441
  init_server_http();
29079
29442
  init_cli_colors();
29443
+ init_vite();
29080
29444
  ALL_TYPE_ARTIFACTS = {
29081
29445
  routes: true,
29082
29446
  api: true,
@@ -29176,7 +29540,7 @@ var init_plugin = __esm({
29176
29540
  init_env();
29177
29541
  init_request_context();
29178
29542
  init_plugin_integration_context();
29179
- init_vite();
29543
+ init_vite2();
29180
29544
  _FarmRuntimeShutdownError = class _FarmRuntimeShutdownError extends Error {
29181
29545
  constructor(message, errors) {
29182
29546
  super(message);
@@ -30521,7 +30885,7 @@ __export(build_runtime_exports, {
30521
30885
  module.exports = __toCommonJS(build_runtime_exports);
30522
30886
 
30523
30887
  // src/build/index.ts
30524
- init_config2();
30888
+ init_config3();
30525
30889
  var import_path14 = __toESM(require("path"));
30526
30890
  init_utils();
30527
30891
  init_app();
@@ -30529,7 +30893,7 @@ init_route_manager2();
30529
30893
  init_layers();
30530
30894
 
30531
30895
  // src/nitro/universal-build.ts
30532
- init_config2();
30896
+ init_config3();
30533
30897
  init_client_plugin_build();
30534
30898
  var import_os = __toESM(require("os"));
30535
30899
  var import_path12 = __toESM(require("path"));
@@ -30603,10 +30967,10 @@ async function createFarmRouteRuntimeManifest(options) {
30603
30967
  }
30604
30968
  __name(createFarmRouteRuntimeManifest, "createFarmRouteRuntimeManifest");
30605
30969
  async function writeFarmRouteRuntimeManifest(directory, manifest) {
30606
- const fs8 = await import("fs/promises");
30970
+ const fs9 = await import("fs/promises");
30607
30971
  const manifestPath = import_path8.default.join(directory, FARM_ROUTE_RUNTIME_MANIFEST);
30608
- await fs8.mkdir(directory, { recursive: true });
30609
- await fs8.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
30972
+ await fs9.mkdir(directory, { recursive: true });
30973
+ await fs9.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
30610
30974
  `);
30611
30975
  return manifestPath;
30612
30976
  }
@@ -30652,7 +31016,7 @@ __name(normalizeManifestSource, "normalizeManifestSource");
30652
31016
  // src/nitro/vercel-route-runtime.ts
30653
31017
  var import_path9 = __toESM(require("path"));
30654
31018
  init_route_runtime();
30655
- async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs8) {
31019
+ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs9) {
30656
31020
  const dynamicRoutes = manifest.routes.filter(
30657
31021
  (route) => route.rendering === "dynamic" && route.runtime !== "edge"
30658
31022
  );
@@ -30683,8 +31047,8 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs8) {
30683
31047
  groupIndex += 1;
30684
31048
  const functionName = `__farm_runtime_${groupIndex}`;
30685
31049
  const functionDir = import_path9.default.join(functionsDir, `${functionName}.func`);
30686
- await fs8.cp(baseFunctionDir, functionDir, { recursive: true, force: true });
30687
- await configureVercelFunction(functionDir, group.config, fs8);
31050
+ await fs9.cp(baseFunctionDir, functionDir, { recursive: true, force: true });
31051
+ await configureVercelFunction(functionDir, group.config, fs9);
30688
31052
  destinations.set(key, `/${functionName}`);
30689
31053
  }
30690
31054
  const routes = [];
@@ -30731,15 +31095,15 @@ function farmRoutePatternToVercelSource(pattern) {
30731
31095
  return source || "/";
30732
31096
  }
30733
31097
  __name(farmRoutePatternToVercelSource, "farmRoutePatternToVercelSource");
30734
- async function configureVercelFunction(functionDir, config, fs8) {
31098
+ async function configureVercelFunction(functionDir, config, fs9) {
30735
31099
  const configPath = import_path9.default.join(functionDir, ".vc-config.json");
30736
- const current = JSON.parse(await fs8.readFile(configPath, "utf8"));
31100
+ const current = JSON.parse(await fs9.readFile(configPath, "utf8"));
30737
31101
  const next = {
30738
31102
  ...current,
30739
31103
  ...config.regions?.length ? { regions: config.regions } : {},
30740
31104
  ...config.maxDuration ? { maxDuration: config.maxDuration } : {}
30741
31105
  };
30742
- await fs8.writeFile(configPath, `${JSON.stringify(next, null, 2)}
31106
+ await fs9.writeFile(configPath, `${JSON.stringify(next, null, 2)}
30743
31107
  `);
30744
31108
  }
30745
31109
  __name(configureVercelFunction, "configureVercelFunction");
@@ -31065,6 +31429,7 @@ __name(withVite5TransformContext, "withVite5TransformContext");
31065
31429
  init_font_vite();
31066
31430
  init_vite_config();
31067
31431
  init_not_found();
31432
+ init_vite();
31068
31433
  var import_meta = {};
31069
31434
  function preloadFarmNitroRuntime() {
31070
31435
  return import("nitro").then(
@@ -31380,7 +31745,7 @@ function hasProjectPostcssConfig(root) {
31380
31745
  }
31381
31746
  __name(hasProjectPostcssConfig, "hasProjectPostcssConfig");
31382
31747
  async function findFarmConfigPath(root) {
31383
- const fs8 = await import("fs/promises");
31748
+ const fs9 = await import("fs/promises");
31384
31749
  const candidates = [
31385
31750
  "farm.config.ts",
31386
31751
  "farm.config.mts",
@@ -31394,7 +31759,7 @@ async function findFarmConfigPath(root) {
31394
31759
  for (const candidate of candidates) {
31395
31760
  const resolvedPath = import_path12.default.join(root, candidate);
31396
31761
  try {
31397
- await fs8.access(resolvedPath);
31762
+ await fs9.access(resolvedPath);
31398
31763
  return resolvedPath;
31399
31764
  } catch {
31400
31765
  }
@@ -31421,13 +31786,13 @@ function hasFarmServerRuntimePlugins(config) {
31421
31786
  }
31422
31787
  __name(hasFarmServerRuntimePlugins, "hasFarmServerRuntimePlugins");
31423
31788
  async function discoverMiddlewareRoutes(appDir) {
31424
- const fs8 = await import("fs/promises");
31789
+ const fs9 = await import("fs/promises");
31425
31790
  const appDirs = Array.isArray(appDir) ? [...appDir] : [appDir];
31426
31791
  const routes = /* @__PURE__ */ new Map();
31427
31792
  async function walk(dir, routePath, discovered) {
31428
31793
  let entries;
31429
31794
  try {
31430
- entries = await fs8.readdir(dir, { withFileTypes: true });
31795
+ entries = await fs9.readdir(dir, { withFileTypes: true });
31431
31796
  } catch {
31432
31797
  return;
31433
31798
  }
@@ -31508,12 +31873,12 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
31508
31873
  })
31509
31874
  );
31510
31875
  logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
31511
- const fs8 = await import("fs/promises");
31876
+ const fs9 = await import("fs/promises");
31512
31877
  const layoutRoutes = [];
31513
31878
  const appDir = import_path12.default.join(root, srcDir, "app");
31514
31879
  async function findLayoutsForClient(dir, routePrefix = "/") {
31515
31880
  try {
31516
- const entries = await fs8.readdir(dir, { withFileTypes: true });
31881
+ const entries = await fs9.readdir(dir, { withFileTypes: true });
31517
31882
  for (const entry of entries) {
31518
31883
  if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?)$/)) {
31519
31884
  layoutRoutes.push({
@@ -31647,7 +32012,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
31647
32012
  }
31648
32013
  __name(buildUniversal, "buildUniversal");
31649
32014
  async function writeSSRAssetsToClient(bundle, outputDir) {
31650
- const fs8 = await import("fs/promises");
32015
+ const fs9 = await import("fs/promises");
31651
32016
  for (const [fileName, output] of Object.entries(bundle)) {
31652
32017
  if (output.type !== "asset") continue;
31653
32018
  if (fileName === "farm-fonts.css") {
@@ -31655,29 +32020,29 @@ async function writeSSRAssetsToClient(bundle, outputDir) {
31655
32020
  continue;
31656
32021
  }
31657
32022
  const filePath = import_path12.default.join(outputDir, fileName);
31658
- await fs8.mkdir(import_path12.default.dirname(filePath), { recursive: true });
31659
- await fs8.writeFile(filePath, output.source);
32023
+ await fs9.mkdir(import_path12.default.dirname(filePath), { recursive: true });
32024
+ await fs9.writeFile(filePath, output.source);
31660
32025
  }
31661
32026
  }
31662
32027
  __name(writeSSRAssetsToClient, "writeSSRAssetsToClient");
31663
32028
  async function copyFarmDocsFontAssetsToClient(root, outputDir) {
31664
- const fs8 = await import("fs/promises");
32029
+ const fs9 = await import("fs/promises");
31665
32030
  await Promise.all(
31666
32031
  resolveFarmDocsFontAssets(root).map(async ({ sourcePath, url }) => {
31667
32032
  const targetPath = import_path12.default.join(outputDir, url.replace(/^\/+/, ""));
31668
- await fs8.mkdir(import_path12.default.dirname(targetPath), { recursive: true });
31669
- await fs8.copyFile(sourcePath, targetPath);
32033
+ await fs9.mkdir(import_path12.default.dirname(targetPath), { recursive: true });
32034
+ await fs9.copyFile(sourcePath, targetPath);
31670
32035
  })
31671
32036
  );
31672
32037
  }
31673
32038
  __name(copyFarmDocsFontAssetsToClient, "copyFarmDocsFontAssetsToClient");
31674
32039
  async function mergeBuiltFontCss(outputDir, fontCssSource) {
31675
- const fs8 = await import("fs/promises");
32040
+ const fs9 = await import("fs/promises");
31676
32041
  const fontCssPath = import_path12.default.join(outputDir, "farm-fonts.css");
31677
32042
  let fontCss = fontCssSource;
31678
32043
  if (fontCss === void 0) {
31679
32044
  try {
31680
- fontCss = await fs8.readFile(fontCssPath);
32045
+ fontCss = await fs9.readFile(fontCssPath);
31681
32046
  } catch {
31682
32047
  return;
31683
32048
  }
@@ -31685,12 +32050,12 @@ async function mergeBuiltFontCss(outputDir, fontCssSource) {
31685
32050
  const clientCssPath = import_path12.default.join(outputDir, "farm-client.css");
31686
32051
  let clientCss = "";
31687
32052
  try {
31688
- clientCss = await fs8.readFile(clientCssPath, "utf8");
32053
+ clientCss = await fs9.readFile(clientCssPath, "utf8");
31689
32054
  } catch {
31690
32055
  }
31691
32056
  const normalizedFontCss = typeof fontCss === "string" ? fontCss : Buffer.from(fontCss).toString("utf8");
31692
- await fs8.writeFile(fontCssPath, normalizedFontCss);
31693
- await fs8.writeFile(clientCssPath, mergeFarmFontCss(clientCss, normalizedFontCss));
32057
+ await fs9.writeFile(fontCssPath, normalizedFontCss);
32058
+ await fs9.writeFile(clientCssPath, mergeFarmFontCss(clientCss, normalizedFontCss));
31694
32059
  }
31695
32060
  __name(mergeBuiltFontCss, "mergeBuiltFontCss");
31696
32061
  var _IncompleteClientBuildOutputError = class _IncompleteClientBuildOutputError extends Error {
@@ -31702,11 +32067,11 @@ var _IncompleteClientBuildOutputError = class _IncompleteClientBuildOutputError
31702
32067
  __name(_IncompleteClientBuildOutputError, "IncompleteClientBuildOutputError");
31703
32068
  var IncompleteClientBuildOutputError = _IncompleteClientBuildOutputError;
31704
32069
  async function validateClientBuildOutput(root, srcDir, outputDir) {
31705
- const fs8 = await import("fs/promises");
32070
+ const fs9 = await import("fs/promises");
31706
32071
  const clientEntryPath = import_path12.default.join(outputDir, "farm-client.js");
31707
32072
  let clientEntrySize = 0;
31708
32073
  try {
31709
- const clientEntry = await fs8.stat(clientEntryPath);
32074
+ const clientEntry = await fs9.stat(clientEntryPath);
31710
32075
  if (clientEntry.isFile()) clientEntrySize = clientEntry.size;
31711
32076
  } catch {
31712
32077
  }
@@ -31717,12 +32082,12 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
31717
32082
  const globalsCssPath = import_path12.default.join(root, srcDir, "app", "globals.css");
31718
32083
  let expectsCss = false;
31719
32084
  try {
31720
- const globalsCss = await fs8.readFile(globalsCssPath, "utf8");
32085
+ const globalsCss = await fs9.readFile(globalsCssPath, "utf8");
31721
32086
  expectsCss = globalsCss.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
31722
32087
  } catch {
31723
32088
  }
31724
32089
  try {
31725
- const clientCss = await fs8.stat(clientCssPath);
32090
+ const clientCss = await fs9.stat(clientCssPath);
31726
32091
  if (expectsCss && (!clientCss.isFile() || clientCss.size === 0)) {
31727
32092
  throw new IncompleteClientBuildOutputError("farm-client.css is empty");
31728
32093
  }
@@ -31731,15 +32096,15 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
31731
32096
  if (expectsCss) {
31732
32097
  throw new IncompleteClientBuildOutputError("farm-client.css is missing");
31733
32098
  }
31734
- await fs8.writeFile(clientCssPath, "");
32099
+ await fs9.writeFile(clientCssPath, "");
31735
32100
  }
31736
32101
  }
31737
32102
  __name(validateClientBuildOutput, "validateClientBuildOutput");
31738
32103
  async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = []) {
31739
32104
  const viteBuild = productionVite.build;
31740
- const { farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite(), vite_exports));
32105
+ const { farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite2(), vite_exports));
31741
32106
  const { PluginManager: PluginManager2 } = await Promise.resolve().then(() => (init_plugin(), plugin_exports));
31742
- const fs8 = await import("fs/promises");
32107
+ const fs9 = await import("fs/promises");
31743
32108
  const pluginManager = new PluginManager2({
31744
32109
  config,
31745
32110
  isDev: false,
@@ -31775,6 +32140,11 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
31775
32140
  const applicableClientLayouts = clientLayouts.filter(
31776
32141
  (layout2) => layout2.shouldHydrate && layoutAppliesToRoute(layout2.pattern, route.pattern)
31777
32142
  );
32143
+ if (metadata.suppressedAsyncHydration) {
32144
+ logger.warn(
32145
+ `\u26A0\uFE0F ${route.pattern} is an async server component that imports client components; React cannot hydrate async components, so the route stays server-rendered and its client imports are not interactive.`
32146
+ );
32147
+ }
31778
32148
  if (metadata.shouldHydrate || applicableClientLayouts.length > 0) {
31779
32149
  const relativePath2 = route.modulePath.replace(root, "").replace(/^\//, "");
31780
32150
  const hydrationStrategies = [
@@ -31833,8 +32203,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
31833
32203
  `\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout2) => layout2.shouldHydrate).length} layouts, and ${clientRouteSlots.length} slots`
31834
32204
  );
31835
32205
  const clientEntryRoot = import_path12.default.join(root, ".farm", "tmp");
31836
- await fs8.mkdir(clientEntryRoot, { recursive: true });
31837
- const clientEntryDir = await fs8.mkdtemp(import_path12.default.join(clientEntryRoot, "client-entry-"));
32206
+ await fs9.mkdir(clientEntryRoot, { recursive: true });
32207
+ const clientEntryDir = await fs9.mkdtemp(import_path12.default.join(clientEntryRoot, "client-entry-"));
31838
32208
  const clientEntryPath = import_path12.default.join(clientEntryDir, "farm-client-entry.tsx");
31839
32209
  const clientHydrationCode = generateClientHydrationEntry(
31840
32210
  clientPages,
@@ -31848,7 +32218,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
31848
32218
  config.i18n,
31849
32219
  config.plugins
31850
32220
  );
31851
- await fs8.writeFile(clientEntryPath, clientHydrationCode);
32221
+ await fs9.writeFile(clientEntryPath, clientHydrationCode);
31852
32222
  const hasScopedPostcssConfig = hasProjectPostcssConfig(root);
31853
32223
  let postcssSearchPath;
31854
32224
  let tailwindVitePlugin = void 0;
@@ -31856,7 +32226,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
31856
32226
  logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
31857
32227
  } else {
31858
32228
  const postcssConfigPath = import_path12.default.join(clientEntryDir, "postcss.config.cjs");
31859
- await fs8.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
32229
+ await fs9.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
31860
32230
  postcssSearchPath = clientEntryDir;
31861
32231
  try {
31862
32232
  const tailwindVite = (await import("@tailwindcss/vite")).default;
@@ -31929,6 +32299,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
31929
32299
  }
31930
32300
  },
31931
32301
  plugins: [
32302
+ createFarmThemeCssPlugin(config.theme, config.basePath),
31932
32303
  ...tailwindVitePlugin ? [tailwindVitePlugin] : [],
31933
32304
  // Plugin to redirect @farm.js/core imports to client-only exports
31934
32305
  {
@@ -32000,7 +32371,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
32000
32371
  await validateClientBuildOutput(root, srcDir, outputDir);
32001
32372
  } finally {
32002
32373
  try {
32003
- await fs8.rm(clientEntryDir, { recursive: true, force: true });
32374
+ await fs9.rm(clientEntryDir, { recursive: true, force: true });
32004
32375
  } catch {
32005
32376
  }
32006
32377
  }
@@ -32651,6 +33022,13 @@ async function createMatchedHydrationElement(matched, pathname, searchParams) {
32651
33022
  if (matched.route.pageShouldHydrate) {
32652
33023
  const Component = await loadRouteComponent(matched.route);
32653
33024
  if (!Component) return null;
33025
+ if (typeof Component === "function" && Component.constructor && Component.constructor.name === "AsyncFunction") {
33026
+ console.warn(
33027
+ "[Farm.js] Skipping hydration for " + pathname +
33028
+ ": async server components cannot run in the browser. Server-rendered HTML is preserved."
33029
+ );
33030
+ return null;
33031
+ }
32654
33032
  const props = { params: params, searchParams: Promise.resolve(searchParams) };
32655
33033
  pageElement = React.createElement(Component, props);
32656
33034
  } else if (hydrateLayouts) {
@@ -33306,9 +33684,9 @@ void hydrate();
33306
33684
  __name(generateClientHydrationEntry, "generateClientHydrationEntry");
33307
33685
  async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots) {
33308
33686
  const viteBuild = productionVite.build;
33309
- const { farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite(), vite_exports));
33687
+ const { farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite2(), vite_exports));
33310
33688
  const { PluginManager: PluginManager2 } = await Promise.resolve().then(() => (init_plugin(), plugin_exports));
33311
- const fs8 = await import("fs/promises");
33689
+ const fs9 = await import("fs/promises");
33312
33690
  const pluginManager = new PluginManager2({
33313
33691
  config,
33314
33692
  isDev: false,
@@ -33319,8 +33697,8 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
33319
33697
  let postcssConfigDir;
33320
33698
  let tailwindVitePlugin = void 0;
33321
33699
  if (!hasScopedPostcssConfig) {
33322
- postcssConfigDir = await fs8.mkdtemp(import_path12.default.join(import_os.default.tmpdir(), "farm-postcss-"));
33323
- await fs8.writeFile(
33700
+ postcssConfigDir = await fs9.mkdtemp(import_path12.default.join(import_os.default.tmpdir(), "farm-postcss-"));
33701
+ await fs9.writeFile(
33324
33702
  import_path12.default.join(postcssConfigDir, "postcss.config.cjs"),
33325
33703
  "module.exports = { plugins: [] };\n"
33326
33704
  );
@@ -33350,7 +33728,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
33350
33728
  fileName: entry.fileName,
33351
33729
  sourceType: "static",
33352
33730
  staticInfo: entry.staticInfo,
33353
- data: (await fs8.readFile(entry.modulePath)).toString("base64")
33731
+ data: (await fs9.readFile(entry.modulePath)).toString("base64")
33354
33732
  });
33355
33733
  continue;
33356
33734
  }
@@ -33400,7 +33778,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
33400
33778
  for (const ext of notFoundExtensions) {
33401
33779
  const checkPath = import_path12.default.join(sourceAppDir, `not-found${ext}`);
33402
33780
  try {
33403
- await fs8.access(checkPath);
33781
+ await fs9.access(checkPath);
33404
33782
  notFoundPath = checkPath;
33405
33783
  break;
33406
33784
  } catch {
@@ -33547,6 +33925,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
33547
33925
  __FARM_PUBLIC_ENV__: JSON.stringify(config.env?.public || {})
33548
33926
  },
33549
33927
  plugins: [
33928
+ createFarmThemeCssPlugin(config.theme, config.basePath),
33550
33929
  ...tailwindVitePlugin ? [tailwindVitePlugin] : [],
33551
33930
  ...!useExternalMetadataImageRuntime && metadataImageRoutes.some((image) => image.sourceType === "module") ? [createMetadataImageWasmPlugin()] : [],
33552
33931
  {
@@ -33611,7 +33990,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
33611
33990
  } finally {
33612
33991
  if (postcssConfigDir) {
33613
33992
  try {
33614
- await fs8.rm(postcssConfigDir, { recursive: true, force: true });
33993
+ await fs9.rm(postcssConfigDir, { recursive: true, force: true });
33615
33994
  } catch {
33616
33995
  }
33617
33996
  }
@@ -33760,15 +34139,19 @@ function generateVirtualEntryCode(apiRoutes, pageRoutes, layoutRoutes, routeSlot
33760
34139
  _runWithCurrentRequest,
33761
34140
  _runWithMiddlewareContext,
33762
34141
  _runWithMiddlewareData,
34142
+ _setDefaultFarmThemeConfig,
33763
34143
  addMetadataImageReference,
34144
+ applyFarmThemeDocument,
33764
34145
  appendFarmLinkHeader,
33765
34146
  applyProductionMiddlewareHeaders,
33766
34147
  configureFarmCache,
33767
34148
  configureFarmObservability,
33768
34149
  createFarmCacheKey,
34150
+ createFarmThemeDocumentParts,
33769
34151
  createFarmLocaleCookie,
33770
34152
  createFarmProductionLifecycle,
33771
34153
  createProductionMiddlewareRunner,
34154
+ getTheme as getFarmTheme,
33772
34155
  emitFarmEvent,
33773
34156
  getFarmDataCache,
33774
34157
  getFarmLocaleVaryHeaders,
@@ -33963,6 +34346,8 @@ configureFarmObservability(farmObservabilityConfig);
33963
34346
  configureFarmCache(farmResolvedRuntimeConfig.cache);
33964
34347
  const farmI18nConfig = ${JSON.stringify(config.i18n)};
33965
34348
  const farmServerConfig = ${JSON.stringify(config.server)};
34349
+ const farmThemeConfig = ${JSON.stringify(config.theme)};
34350
+ _setDefaultFarmThemeConfig(farmThemeConfig);
33966
34351
  export const farmProductionLifecycle = createFarmProductionLifecycle({
33967
34352
  server: farmServerConfig,
33968
34353
  start: () => farmPluginRuntime?.startRuntime(),
@@ -35799,7 +36184,13 @@ async function handleFarmRequestInContext(
35799
36184
  !farmI18nSnapshot &&
35800
36185
  !pprCacheKey
35801
36186
  ) {
36187
+ const farmThemeDocument = createFarmThemeDocumentParts(
36188
+ farmThemeConfig,
36189
+ farmResolvedRuntimeConfig.basePath,
36190
+ getFarmTheme(request)
36191
+ );
35802
36192
  const streamPrefix = '<!DOCTYPE html>\\n<html lang="en">\\n<head>\\n' +
36193
+ farmThemeDocument.head + '\\n' +
35803
36194
  ' <meta charset="utf-8">\\n' +
35804
36195
  ' <meta name="viewport" content="width=device-width, initial-scale=1">\\n' +
35805
36196
  (hasFavicon ? '' : ' <link rel="icon" href="data:,">\\n') +
@@ -35815,9 +36206,13 @@ async function handleFarmRequestInContext(
35815
36206
  ) + '\\n' +
35816
36207
  ' <script type="module" src="/farm-client.js"></script>\\n' +
35817
36208
  '</body>\\n</html>';
36209
+ const themedStreamPrefix = streamPrefix.replace(
36210
+ '<html lang="en">',
36211
+ '<html lang="en"' + farmThemeDocument.attributes + '>'
36212
+ );
35818
36213
  const streamedDocument = createFarmDocumentStream(
35819
36214
  renderedPage.stream,
35820
- streamPrefix,
36215
+ themedStreamPrefix,
35821
36216
  streamSuffix,
35822
36217
  function() {
35823
36218
  if (pprBypassReason === "refresh") {
@@ -35900,6 +36295,12 @@ async function handleFarmRequestInContext(
35900
36295
  </html>\`;
35901
36296
  }
35902
36297
  fullHtml = applyFarmI18nDocument(fullHtml, pathname, farmI18nSnapshot);
36298
+ fullHtml = applyFarmThemeDocument(
36299
+ fullHtml,
36300
+ farmThemeConfig,
36301
+ farmResolvedRuntimeConfig.basePath,
36302
+ getFarmTheme(request)
36303
+ );
35903
36304
 
35904
36305
  if (pageStatus === 200 && pprCacheKey && request.method.toUpperCase() !== "HEAD") {
35905
36306
  await pprShellCache.setAsync(
@@ -36026,10 +36427,15 @@ async function handleFarmRequestInContext(
36026
36427
  const errorHtml = ${hasMiddlewareRuntime ? `await _runWithMiddlewareData(middlewareData, () =>
36027
36428
  _runWithMiddlewareContext(middlewareContext, renderErrorElement)
36028
36429
  )` : "await renderErrorElement()"};
36029
- const errorDocument = applyFarmI18nDocument(
36030
- createFarmErrorDocument(errorHtml, "Application Error"),
36031
- pathname,
36032
- getFarmI18nSnapshot()
36430
+ const errorDocument = applyFarmThemeDocument(
36431
+ applyFarmI18nDocument(
36432
+ createFarmErrorDocument(errorHtml, "Application Error"),
36433
+ pathname,
36434
+ getFarmI18nSnapshot()
36435
+ ),
36436
+ farmThemeConfig,
36437
+ farmResolvedRuntimeConfig.basePath,
36438
+ getFarmTheme(request)
36033
36439
  );
36034
36440
  emitFarmEvent({
36035
36441
  type: "render.complete",
@@ -36054,10 +36460,15 @@ async function handleFarmRequestInContext(
36054
36460
  const errorMessage = "Internal Server Error";
36055
36461
  const fallbackHtml = '<main><h1>Application Error</h1><p>' +
36056
36462
  escapeFarmHtmlAttribute(errorMessage) + '</p></main>';
36057
- const fallbackDocument = applyFarmI18nDocument(
36058
- createFarmErrorDocument(fallbackHtml, "Application Error"),
36059
- pathname,
36060
- getFarmI18nSnapshot()
36463
+ const fallbackDocument = applyFarmThemeDocument(
36464
+ applyFarmI18nDocument(
36465
+ createFarmErrorDocument(fallbackHtml, "Application Error"),
36466
+ pathname,
36467
+ getFarmI18nSnapshot()
36468
+ ),
36469
+ farmThemeConfig,
36470
+ farmResolvedRuntimeConfig.basePath,
36471
+ getFarmTheme(request)
36061
36472
  );
36062
36473
  return applyProductionMiddlewareHeaders(new Response(
36063
36474
  fallbackDocument,
@@ -36155,6 +36566,12 @@ async function handleFarmRequestInContext(
36155
36566
  </html>\`;
36156
36567
  }
36157
36568
  fullHtml = applyFarmI18nDocument(fullHtml, pathname, getFarmI18nSnapshot());
36569
+ fullHtml = applyFarmThemeDocument(
36570
+ fullHtml,
36571
+ farmThemeConfig,
36572
+ farmResolvedRuntimeConfig.basePath,
36573
+ getFarmTheme(request)
36574
+ );
36158
36575
 
36159
36576
  emitFarmEvent({
36160
36577
  type: "render.complete",
@@ -36173,8 +36590,14 @@ async function handleFarmRequestInContext(
36173
36590
  }), middlewareHeaders);
36174
36591
  } catch (error) {
36175
36592
  console.error("404 render error:", error);
36176
- return applyProductionMiddlewareHeaders(new Response(
36593
+ const fallbackDocument = applyFarmThemeDocument(
36177
36594
  \`<!DOCTYPE html><html><head><title>404</title></head><body><h1>404 - Page Not Found</h1><p>The page \${pathname} doesn't exist.</p><a href="/">Go Home</a></body></html>\`,
36595
+ farmThemeConfig,
36596
+ farmResolvedRuntimeConfig.basePath,
36597
+ getFarmTheme(request)
36598
+ );
36599
+ return applyProductionMiddlewareHeaders(new Response(
36600
+ fallbackDocument,
36178
36601
  {
36179
36602
  status: 404,
36180
36603
  headers: { "Content-Type": "text/html", "x-farm-preload-buffered": "1" },
@@ -36462,7 +36885,7 @@ function getPhysicalPrerenderBypassReason(options) {
36462
36885
  }
36463
36886
  __name(getPhysicalPrerenderBypassReason, "getPhysicalPrerenderBypassReason");
36464
36887
  async function buildNitroUniversal(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, ssrBundle, ssrEntryFile, clientOutputDir, routeRuntimeManifest, configuredHeaderRoutes, nitroRuntimeResultPromise, pluginManager) {
36465
- const [fs8, nitroRuntimeResult] = await Promise.all([
36888
+ const [fs9, nitroRuntimeResult] = await Promise.all([
36466
36889
  import("fs/promises"),
36467
36890
  nitroRuntimeResultPromise
36468
36891
  ]);
@@ -36540,11 +36963,11 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
36540
36963
  }
36541
36964
  const scheduledTasks = mergeScheduledTasks(farmWorkflows.scheduledTasks, farmCron.scheduledTasks);
36542
36965
  const cloudflareCronConfig = createFarmCronCloudflareConfig(farmCron.jobs);
36543
- await fs8.mkdir(ssrOutputDir, { recursive: true });
36966
+ await fs9.mkdir(ssrOutputDir, { recursive: true });
36544
36967
  for (const [fileName, output] of Object.entries(ssrBundle)) {
36545
36968
  const filePath = import_path12.default.join(ssrOutputDir, fileName);
36546
- await fs8.mkdir(import_path12.default.dirname(filePath), { recursive: true });
36547
- await fs8.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
36969
+ await fs9.mkdir(import_path12.default.dirname(filePath), { recursive: true });
36970
+ await fs9.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
36548
36971
  }
36549
36972
  const nitroEntryPath = import_path12.default.join(ssrOutputDir, "nitro-entry.mjs");
36550
36973
  const nitroEntryCode = `
@@ -36610,10 +37033,10 @@ export default async function farmNitroEventHandler(event) {
36610
37033
  return response
36611
37034
  }
36612
37035
  `.trim();
36613
- await fs8.writeFile(nitroEntryPath, nitroEntryCode);
37036
+ await fs9.writeFile(nitroEntryPath, nitroEntryCode);
36614
37037
  const farmNodeServerEntryPath = preset === "node-server" ? import_path12.default.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
36615
37038
  if (farmNodeServerEntryPath) {
36616
- await fs8.writeFile(
37039
+ await fs9.writeFile(
36617
37040
  farmNodeServerEntryPath,
36618
37041
  createFarmNodeServerEntry({
36619
37042
  nitroEntryFile: import_path12.default.basename(nitroEntryPath),
@@ -36813,9 +37236,9 @@ export default async function farmNitroEventHandler(event) {
36813
37236
  import_path12.default.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
36814
37237
  {},
36815
37238
  false,
36816
- fs8
37239
+ fs9
36817
37240
  );
36818
- await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile, fs8);
37241
+ await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile, fs9);
36819
37242
  });
36820
37243
  });
36821
37244
  }
@@ -36847,17 +37270,17 @@ export default async function farmNitroEventHandler(event) {
36847
37270
  import_path12.default.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
36848
37271
  configuredEsbuildOptions,
36849
37272
  effectiveMinify,
36850
- fs8
37273
+ fs9
36851
37274
  ) : Promise.resolve(),
36852
- imageRuntime === "node" ? copySharpRuntime(config, root, import_path12.default.join(outputDir, "server"), fs8) : Promise.resolve(),
36853
- useExternalMetadataImageRuntime ? copyMetadataImageRuntime(root, import_path12.default.join(outputDir, "server"), fs8) : Promise.resolve()
37275
+ imageRuntime === "node" ? copySharpRuntime(config, root, import_path12.default.join(outputDir, "server"), fs9) : Promise.resolve(),
37276
+ useExternalMetadataImageRuntime ? copyMetadataImageRuntime(root, import_path12.default.join(outputDir, "server"), fs9) : Promise.resolve()
36854
37277
  ]);
36855
37278
  const failedCopy = copyResults.find(
36856
37279
  (result) => result.status === "rejected"
36857
37280
  );
36858
37281
  if (failedCopy) throw failedCopy.reason;
36859
37282
  if (canReusePrebuiltSSR) {
36860
- await registerPrebuiltSSRPackageImport(import_path12.default.join(outputDir, "server"), ssrEntryFile, fs8);
37283
+ await registerPrebuiltSSRPackageImport(import_path12.default.join(outputDir, "server"), ssrEntryFile, fs9);
36861
37284
  logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
36862
37285
  }
36863
37286
  if (useRolldownBuilder) {
@@ -36872,12 +37295,12 @@ export default async function farmNitroEventHandler(event) {
36872
37295
  });
36873
37296
  }
36874
37297
  if (isVercel) {
36875
- await postProcessVercelOutput(root, outputDir, fs8, config, farmWorkflows, routeRuntimeManifest);
37298
+ await postProcessVercelOutput(root, outputDir, fs9, config, farmWorkflows, routeRuntimeManifest);
36876
37299
  }
36877
37300
  logger.success(`\u2705 Nitro build completed with preset: ${preset}`);
36878
37301
  }
36879
37302
  __name(buildNitroUniversal, "buildNitroUniversal");
36880
- async function copyPrebuiltSSRBundle(ssrBundle, targetDir, configuredEsbuildOptions, minify, fs8) {
37303
+ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, configuredEsbuildOptions, minify, fs9) {
36881
37304
  const {
36882
37305
  include: _include,
36883
37306
  exclude: _exclude,
@@ -36894,13 +37317,13 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, configuredEsbuildOpti
36894
37317
  "node18"
36895
37318
  );
36896
37319
  const transform = minify || hasConfiguredTransforms ? (await import("esbuild")).transform : null;
36897
- await fs8.rm(targetDir, { recursive: true, force: true });
37320
+ await fs9.rm(targetDir, { recursive: true, force: true });
36898
37321
  await Promise.all(
36899
37322
  Object.entries(ssrBundle).map(async ([fileName, output]) => {
36900
37323
  const targetPath = import_path12.default.join(targetDir, fileName);
36901
- await fs8.mkdir(import_path12.default.dirname(targetPath), { recursive: true });
37324
+ await fs9.mkdir(import_path12.default.dirname(targetPath), { recursive: true });
36902
37325
  if (output.type === "asset") {
36903
- await fs8.writeFile(targetPath, output.source);
37326
+ await fs9.writeFile(targetPath, output.source);
36904
37327
  return;
36905
37328
  }
36906
37329
  let code = output.code;
@@ -36911,14 +37334,14 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, configuredEsbuildOpti
36911
37334
  });
36912
37335
  code = result.code;
36913
37336
  }
36914
- await fs8.writeFile(targetPath, code);
37337
+ await fs9.writeFile(targetPath, code);
36915
37338
  })
36916
37339
  );
36917
37340
  }
36918
37341
  __name(copyPrebuiltSSRBundle, "copyPrebuiltSSRBundle");
36919
- async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs8) {
37342
+ async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs9) {
36920
37343
  const packagePath = import_path12.default.join(serverDir, "package.json");
36921
- const packageJSON = await fs8.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
37344
+ const packageJSON = await fs9.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
36922
37345
  if (error.code === "ENOENT") return { type: "module" };
36923
37346
  throw error;
36924
37347
  });
@@ -36928,38 +37351,38 @@ async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs8) {
36928
37351
  ...existingImports,
36929
37352
  [FARM_SSR_PACKAGE_IMPORT]: `./${outputEntry}`
36930
37353
  };
36931
- await fs8.mkdir(serverDir, { recursive: true });
36932
- await fs8.writeFile(packagePath, `${JSON.stringify(packageJSON, null, 2)}
37354
+ await fs9.mkdir(serverDir, { recursive: true });
37355
+ await fs9.writeFile(packagePath, `${JSON.stringify(packageJSON, null, 2)}
36933
37356
  `);
36934
37357
  }
36935
37358
  __name(registerPrebuiltSSRPackageImport, "registerPrebuiltSSRPackageImport");
36936
- async function postProcessVercelOutput(root, outputDir, fs8, config, farmWorkflows, routeRuntimeManifest) {
37359
+ async function postProcessVercelOutput(root, outputDir, fs9, config, farmWorkflows, routeRuntimeManifest) {
36937
37360
  const serverDir = import_path12.default.join(outputDir, "server");
36938
37361
  const functionsDir = import_path12.default.join(outputDir, "functions");
36939
37362
  const nitroFuncDir = import_path12.default.join(functionsDir, "__nitro.func");
36940
37363
  const staticDir = import_path12.default.join(outputDir, "static");
36941
37364
  const publicDir = import_path12.default.join(outputDir, "public");
36942
- await fs8.mkdir(nitroFuncDir, { recursive: true });
36943
- const serverContents = await fs8.readdir(serverDir);
37365
+ await fs9.mkdir(nitroFuncDir, { recursive: true });
37366
+ const serverContents = await fs9.readdir(serverDir);
36944
37367
  for (const file of serverContents) {
36945
37368
  const src = import_path12.default.join(serverDir, file);
36946
37369
  const dest = import_path12.default.join(nitroFuncDir, file);
36947
- await fs8.rename(src, dest);
37370
+ await fs9.rename(src, dest);
36948
37371
  }
36949
- await fs8.rmdir(serverDir);
37372
+ await fs9.rmdir(serverDir);
36950
37373
  try {
36951
- await fs8.rename(publicDir, staticDir);
37374
+ await fs9.rename(publicDir, staticDir);
36952
37375
  } catch {
36953
37376
  }
36954
- await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs8);
36955
- await copyPrismaClientForVercel(root, nitroFuncDir, fs8);
37377
+ await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs9);
37378
+ await copyPrismaClientForVercel(root, nitroFuncDir, fs9);
36956
37379
  const configPath = import_path12.default.join(outputDir, "config.json");
36957
- const configContent = await fs8.readFile(configPath, "utf-8");
37380
+ const configContent = await fs9.readFile(configPath, "utf-8");
36958
37381
  const vercelConfig = JSON.parse(configContent);
36959
37382
  const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
36960
37383
  outputDir,
36961
37384
  routeRuntimeManifest,
36962
- fs8
37385
+ fs9
36963
37386
  );
36964
37387
  vercelConfig.routes = [
36965
37388
  // Apply the header before the filesystem handler. `continue` lets Vercel
@@ -36994,24 +37417,24 @@ async function postProcessVercelOutput(root, outputDir, fs8, config, farmWorkflo
36994
37417
  vercelConfigWithWorkflowCrons,
36995
37418
  config.cron.jobs
36996
37419
  );
36997
- await fs8.writeFile(configPath, JSON.stringify(vercelConfigWithCrons, null, 2));
37420
+ await fs9.writeFile(configPath, JSON.stringify(vercelConfigWithCrons, null, 2));
36998
37421
  logger.info("\u2705 Post-processed Vercel output for Build Output API v3");
36999
37422
  }
37000
37423
  __name(postProcessVercelOutput, "postProcessVercelOutput");
37001
- async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs8) {
37424
+ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs9) {
37002
37425
  const docsContentDir = resolveBuildDocsContentDir(config, root);
37003
37426
  if (!docsContentDir) return;
37004
37427
  const bundledContentDir = import_path12.default.join(nitroFuncDir, "chunks", "nitro", "farm-docs-content");
37005
37428
  const lastModifiedManifest = createFarmDocsLastModifiedManifest(docsContentDir, {
37006
37429
  fallback: "now"
37007
37430
  });
37008
- await fs8.rm(bundledContentDir, { recursive: true, force: true });
37009
- await fs8.mkdir(import_path12.default.dirname(bundledContentDir), { recursive: true });
37010
- await fs8.cp(docsContentDir, bundledContentDir, {
37431
+ await fs9.rm(bundledContentDir, { recursive: true, force: true });
37432
+ await fs9.mkdir(import_path12.default.dirname(bundledContentDir), { recursive: true });
37433
+ await fs9.cp(docsContentDir, bundledContentDir, {
37011
37434
  recursive: true,
37012
37435
  force: true
37013
37436
  });
37014
- await fs8.writeFile(
37437
+ await fs9.writeFile(
37015
37438
  import_path12.default.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
37016
37439
  `${JSON.stringify(lastModifiedManifest, null, 2)}
37017
37440
  `
@@ -37019,7 +37442,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs8) {
37019
37442
  logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${import_path12.default.relative(root, docsContentDir)}`);
37020
37443
  }
37021
37444
  __name(copyFarmDocsContentForVercel, "copyFarmDocsContentForVercel");
37022
- async function copySharpRuntime(config, root, nitroFuncDir, fs8) {
37445
+ async function copySharpRuntime(config, root, nitroFuncDir, fs9) {
37023
37446
  if (config.images.provider === "none") return;
37024
37447
  const projectRequire = (0, import_module2.createRequire)(import_path12.default.join(root, "package.json"));
37025
37448
  let sharpRequire = projectRequire;
@@ -37043,18 +37466,18 @@ async function copySharpRuntime(config, root, nitroFuncDir, fs8) {
37043
37466
  async function copyPackageOnce(packageName, parentRequire) {
37044
37467
  const packageJsonPath = resolvePackageJson(parentRequire, packageName);
37045
37468
  if (!packageJsonPath) return;
37046
- const packageJson = JSON.parse(await fs8.readFile(packageJsonPath, "utf8"));
37469
+ const packageJson = JSON.parse(await fs9.readFile(packageJsonPath, "utf8"));
37047
37470
  const packageDir = import_path12.default.dirname(packageJsonPath);
37048
37471
  const targetDir = import_path12.default.join(targetNodeModules, ...packageName.split("/"));
37049
37472
  copiedPackages.set(packageName, String(packageJson.version || "*"));
37050
- await fs8.mkdir(import_path12.default.dirname(targetDir), { recursive: true });
37473
+ await fs9.mkdir(import_path12.default.dirname(targetDir), { recursive: true });
37051
37474
  const packageRequire = (0, import_module2.createRequire)(packageJsonPath);
37052
37475
  const dependencies = {
37053
37476
  ...packageJson.dependencies,
37054
37477
  ...packageJson.optionalDependencies
37055
37478
  };
37056
37479
  await Promise.all([
37057
- fs8.cp(packageDir, targetDir, {
37480
+ fs9.cp(packageDir, targetDir, {
37058
37481
  recursive: true,
37059
37482
  force: true,
37060
37483
  dereference: true,
@@ -37073,16 +37496,16 @@ async function copySharpRuntime(config, root, nitroFuncDir, fs8) {
37073
37496
  );
37074
37497
  }
37075
37498
  const functionPackagePath = import_path12.default.join(nitroFuncDir, "package.json");
37076
- const functionPackage = JSON.parse(await fs8.readFile(functionPackagePath, "utf8"));
37499
+ const functionPackage = JSON.parse(await fs9.readFile(functionPackagePath, "utf8"));
37077
37500
  functionPackage.dependencies = {
37078
37501
  ...functionPackage.dependencies,
37079
37502
  ...Object.fromEntries([...copiedPackages].sort(([left], [right]) => left.localeCompare(right)))
37080
37503
  };
37081
- await fs8.writeFile(functionPackagePath, JSON.stringify(functionPackage, null, 2));
37504
+ await fs9.writeFile(functionPackagePath, JSON.stringify(functionPackage, null, 2));
37082
37505
  logger.info(`\u{1F5BC}\uFE0F Bundled Sharp image runtime (${copiedPackages.size} packages)`);
37083
37506
  }
37084
37507
  __name(copySharpRuntime, "copySharpRuntime");
37085
- async function copyMetadataImageRuntime(root, nitroFuncDir, fs8) {
37508
+ async function copyMetadataImageRuntime(root, nitroFuncDir, fs9) {
37086
37509
  const projectRequire = (0, import_module2.createRequire)(import_path12.default.join(root, "package.json"));
37087
37510
  let runtimeRequire = projectRequire;
37088
37511
  let packageJsonPath = resolvePackageJson(runtimeRequire, "@vercel/og");
@@ -37098,23 +37521,23 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs8) {
37098
37521
  "Generated metadata images require @vercel/og. Reinstall @farm.js/core with production dependencies."
37099
37522
  );
37100
37523
  }
37101
- const packageJson = JSON.parse(await fs8.readFile(packageJsonPath, "utf8"));
37524
+ const packageJson = JSON.parse(await fs9.readFile(packageJsonPath, "utf8"));
37102
37525
  const packageDir = import_path12.default.dirname(packageJsonPath);
37103
37526
  const targetDir = import_path12.default.join(nitroFuncDir, "node_modules", "@vercel", "og");
37104
- await fs8.mkdir(import_path12.default.dirname(targetDir), { recursive: true });
37105
- await fs8.cp(packageDir, targetDir, {
37527
+ await fs9.mkdir(import_path12.default.dirname(targetDir), { recursive: true });
37528
+ await fs9.cp(packageDir, targetDir, {
37106
37529
  recursive: true,
37107
37530
  force: true,
37108
37531
  dereference: true,
37109
37532
  mode: import_fs5.constants.COPYFILE_FICLONE
37110
37533
  });
37111
37534
  const functionPackagePath = import_path12.default.join(nitroFuncDir, "package.json");
37112
- const functionPackage = JSON.parse(await fs8.readFile(functionPackagePath, "utf8"));
37535
+ const functionPackage = JSON.parse(await fs9.readFile(functionPackagePath, "utf8"));
37113
37536
  functionPackage.dependencies = {
37114
37537
  ...functionPackage.dependencies,
37115
37538
  "@vercel/og": String(packageJson.version || "0.11.1")
37116
37539
  };
37117
- await fs8.writeFile(functionPackagePath, JSON.stringify(functionPackage, null, 2));
37540
+ await fs9.writeFile(functionPackagePath, JSON.stringify(functionPackage, null, 2));
37118
37541
  logger.info("\u{1F5BC}\uFE0F Bundled generated metadata image runtime");
37119
37542
  }
37120
37543
  __name(copyMetadataImageRuntime, "copyMetadataImageRuntime");
@@ -37128,7 +37551,7 @@ function resolvePackageJson(parentRequire, packageName) {
37128
37551
  return null;
37129
37552
  }
37130
37553
  __name(resolvePackageJson, "resolvePackageJson");
37131
- async function copyPrismaClientForVercel(root, nitroFuncDir, fs8) {
37554
+ async function copyPrismaClientForVercel(root, nitroFuncDir, fs9) {
37132
37555
  const projectRequire = (0, import_module2.createRequire)(import_path12.default.join(root, "package.json"));
37133
37556
  let prismaClientDir;
37134
37557
  try {
@@ -37138,7 +37561,7 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs8) {
37138
37561
  }
37139
37562
  const generatedClientDir = import_path12.default.join(prismaClientDir, "..", "..", ".prisma", "client");
37140
37563
  try {
37141
- await fs8.access(generatedClientDir);
37564
+ await fs9.access(generatedClientDir);
37142
37565
  } catch {
37143
37566
  return;
37144
37567
  }
@@ -37146,20 +37569,20 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs8) {
37146
37569
  const targetPrismaScopeDir = import_path12.default.join(targetNodeModules, "@prisma");
37147
37570
  const targetGeneratedDir = import_path12.default.join(targetNodeModules, ".prisma", "client");
37148
37571
  const targetClientDir = import_path12.default.join(targetPrismaScopeDir, "client");
37149
- await fs8.mkdir(targetPrismaScopeDir, { recursive: true });
37150
- await fs8.cp(prismaClientDir, targetClientDir, {
37572
+ await fs9.mkdir(targetPrismaScopeDir, { recursive: true });
37573
+ await fs9.cp(prismaClientDir, targetClientDir, {
37151
37574
  recursive: true,
37152
37575
  force: true
37153
37576
  });
37154
- await fs8.cp(generatedClientDir, targetGeneratedDir, {
37577
+ await fs9.cp(generatedClientDir, targetGeneratedDir, {
37155
37578
  recursive: true,
37156
37579
  force: true
37157
37580
  });
37158
37581
  const functionPackagePath = import_path12.default.join(nitroFuncDir, "package.json");
37159
37582
  const clientPackagePath = import_path12.default.join(prismaClientDir, "package.json");
37160
37583
  const [functionPackageContent, clientPackageContent] = await Promise.all([
37161
- fs8.readFile(functionPackagePath, "utf-8"),
37162
- fs8.readFile(clientPackagePath, "utf-8")
37584
+ fs9.readFile(functionPackagePath, "utf-8"),
37585
+ fs9.readFile(clientPackagePath, "utf-8")
37163
37586
  ]);
37164
37587
  const functionPackage = JSON.parse(functionPackageContent);
37165
37588
  const clientPackage = JSON.parse(clientPackageContent);
@@ -37167,7 +37590,7 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs8) {
37167
37590
  ...functionPackage.dependencies,
37168
37591
  "@prisma/client": clientPackage.version
37169
37592
  };
37170
- await fs8.writeFile(functionPackagePath, JSON.stringify(functionPackage, null, 2));
37593
+ await fs9.writeFile(functionPackagePath, JSON.stringify(functionPackage, null, 2));
37171
37594
  }
37172
37595
  __name(copyPrismaClientForVercel, "copyPrismaClientForVercel");
37173
37596
 
@@ -37401,7 +37824,7 @@ async function createProjectModuleServer(createViteServer, config, root) {
37401
37824
  }
37402
37825
  __name(createProjectModuleServer, "createProjectModuleServer");
37403
37826
  async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
37404
- const { farmI18nClientBridgePlugin: farmI18nClientBridgePlugin2, farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite(), vite_exports));
37827
+ const { farmI18nClientBridgePlugin: farmI18nClientBridgePlugin2, farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite2(), vite_exports));
37405
37828
  const { PluginManager: PluginManager2 } = await Promise.resolve().then(() => (init_plugin(), plugin_exports));
37406
37829
  const pluginManager = new PluginManager2({
37407
37830
  config,
@@ -37428,7 +37851,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
37428
37851
  }
37429
37852
  __name(buildClient2, "buildClient");
37430
37853
  async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
37431
- const { farmI18nClientBridgePlugin: farmI18nClientBridgePlugin2, farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite(), vite_exports));
37854
+ const { farmI18nClientBridgePlugin: farmI18nClientBridgePlugin2, farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite2(), vite_exports));
37432
37855
  const { PluginManager: PluginManager2 } = await Promise.resolve().then(() => (init_plugin(), plugin_exports));
37433
37856
  const pluginManager = new PluginManager2({
37434
37857
  config,
@@ -37489,10 +37912,10 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
37489
37912
  const manifestPath = import_path14.default.join(publicOutputDir, "farm-client-manifest.json");
37490
37913
  const assetsDir = import_path14.default.join(publicOutputDir, "assets");
37491
37914
  const manifestExists = await import("fs/promises").then(
37492
- (fs8) => fs8.access(manifestPath).then(() => true).catch(() => false)
37915
+ (fs9) => fs9.access(manifestPath).then(() => true).catch(() => false)
37493
37916
  );
37494
37917
  const assetsExist = await import("fs/promises").then(
37495
- (fs8) => fs8.access(assetsDir).then(() => true).catch(() => false)
37918
+ (fs9) => fs9.access(assetsDir).then(() => true).catch(() => false)
37496
37919
  );
37497
37920
  if (manifestExists && assetsExist) {
37498
37921
  logger.info("\u2705 Verified client assets are present");
@@ -37553,7 +37976,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
37553
37976
  __name(buildNitro, "buildNitro");
37554
37977
 
37555
37978
  // src/nitro/build-runtime.ts
37556
- init_config2();
37979
+ init_config3();
37557
37980
  init_utils();
37558
37981
  // Annotate the CommonJS export names for ESM import in node:
37559
37982
  0 && (module.exports = {