@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
package/dist/index.cjs CHANGED
@@ -148,8 +148,8 @@ function toViteModuleId(filePath, root) {
148
148
  }
149
149
  async function fileExists(filePath) {
150
150
  try {
151
- const fs9 = await import("fs/promises");
152
- await fs9.access(filePath);
151
+ const fs10 = await import("fs/promises");
152
+ await fs10.access(filePath);
153
153
  return true;
154
154
  } catch {
155
155
  return false;
@@ -673,13 +673,13 @@ function defineIntegrationAPI(api3) {
673
673
  }
674
674
  function operation(method, pathOrOptions, maybeOptions = {}) {
675
675
  const hasExplicitPath = typeof pathOrOptions === "string";
676
- const path32 = hasExplicitPath ? pathOrOptions : "";
676
+ const path33 = hasExplicitPath ? pathOrOptions : "";
677
677
  const options = hasExplicitPath ? maybeOptions : {
678
678
  ...maybeOptions,
679
679
  ...pathOrOptions
680
680
  };
681
681
  return defineIntegrationAPIOperation({
682
- path: path32,
682
+ path: path33,
683
683
  method,
684
684
  __pathless: !hasExplicitPath,
685
685
  ...options
@@ -691,26 +691,26 @@ function get(pathOrOptions, maybeOptions = {}) {
691
691
  function isOperation(value) {
692
692
  return !!value && typeof value === "object" && value.kind === "farm-integration-api-operation";
693
693
  }
694
- function bindRoutePath(path32, api3) {
694
+ function bindRoutePath(path33, api3) {
695
695
  const entries = Object.entries(api3).map(([key, value]) => {
696
696
  if (isOperation(value)) {
697
697
  return [
698
698
  key,
699
699
  {
700
700
  ...value,
701
- path: path32,
701
+ path: path33,
702
702
  __pathless: false
703
703
  }
704
704
  ];
705
705
  }
706
706
  if (value && typeof value === "object") {
707
- return [key, bindRoutePath(path32, value)];
707
+ return [key, bindRoutePath(path33, value)];
708
708
  }
709
709
  return [key, value];
710
710
  });
711
711
  return Object.fromEntries(entries);
712
712
  }
713
- function route(path32, definitionOrOperation, ...operations) {
713
+ function route(path33, definitionOrOperation, ...operations) {
714
714
  if (isOperation(definitionOrOperation)) {
715
715
  const allOperations = [definitionOrOperation, ...operations];
716
716
  return Object.fromEntries(
@@ -718,13 +718,13 @@ function route(path32, definitionOrOperation, ...operations) {
718
718
  operation2.method.toLowerCase(),
719
719
  {
720
720
  ...operation2,
721
- path: path32,
721
+ path: path33,
722
722
  __pathless: false
723
723
  }
724
724
  ])
725
725
  );
726
726
  }
727
- return bindRoutePath(path32, definitionOrOperation);
727
+ return bindRoutePath(path33, definitionOrOperation);
728
728
  }
729
729
  function normalizeRouteSegment(segment) {
730
730
  if (!segment) {
@@ -745,8 +745,8 @@ function normalizeRouteSegment(segment) {
745
745
  function camelCaseRouteSegment(segment) {
746
746
  return segment.replace(/-([a-zA-Z0-9])/g, (_match, value) => value.toUpperCase());
747
747
  }
748
- function getRouteClientSegments(path32) {
749
- const segments = path32.split("/").filter(Boolean);
748
+ function getRouteClientSegments(path33) {
749
+ const segments = path33.split("/").filter(Boolean);
750
750
  if (segments.length === 0) {
751
751
  return ["index"];
752
752
  }
@@ -1113,11 +1113,11 @@ function resolveFarmServerHealthConfig(config) {
1113
1113
  return Object.freeze({ enabled: true, livenessPath, readinessPath });
1114
1114
  }
1115
1115
  function normalizeHealthPath(value, optionName) {
1116
- const path32 = value.trim();
1117
- if (!path32.startsWith("/") || path32.includes("?") || path32.includes("#") || path32.includes("*")) {
1116
+ const path33 = value.trim();
1117
+ if (!path33.startsWith("/") || path33.includes("?") || path33.includes("#") || path33.includes("*")) {
1118
1118
  throw new TypeError(`${optionName} must be an absolute pathname without a query or wildcard`);
1119
1119
  }
1120
- return path32.length > 1 ? path32.replace(/\/+$/, "") || "/" : path32;
1120
+ return path33.length > 1 ? path33.replace(/\/+$/, "") || "/" : path33;
1121
1121
  }
1122
1122
  function parseBodySizeLimit(value, optionName = "bodySizeLimit") {
1123
1123
  if (typeof value === "number") {
@@ -1214,7 +1214,7 @@ async function readNodeRequestBody(request, limit) {
1214
1214
  request.resume?.();
1215
1215
  throw error;
1216
1216
  }
1217
- return await new Promise((resolve6, reject) => {
1217
+ return await new Promise((resolve7, reject) => {
1218
1218
  const chunks = [];
1219
1219
  let total = 0;
1220
1220
  let settled = false;
@@ -1243,7 +1243,7 @@ async function readNodeRequestBody(request, limit) {
1243
1243
  if (settled) return;
1244
1244
  settled = true;
1245
1245
  cleanup();
1246
- resolve6(Buffer.concat(chunks, total));
1246
+ resolve7(Buffer.concat(chunks, total));
1247
1247
  }, "onEnd");
1248
1248
  const onError = /* @__PURE__ */ __name((error) => rejectOnce(error), "onError");
1249
1249
  request.on("data", onData);
@@ -1458,9 +1458,9 @@ function getFarmIntegrationPluginOwner(plugin) {
1458
1458
  const value = plugin[FARM_INTEGRATION_PLUGIN_OWNER];
1459
1459
  return value && typeof value === "object" ? value : void 0;
1460
1460
  }
1461
- function defineTypedIntegrationRoute(method, path32, input) {
1461
+ function defineTypedIntegrationRoute(method, path33, input) {
1462
1462
  return {
1463
- path: path32,
1463
+ path: path33,
1464
1464
  method,
1465
1465
  middleware: input.middleware,
1466
1466
  before: input.before,
@@ -1470,7 +1470,7 @@ function defineTypedIntegrationRoute(method, path32, input) {
1470
1470
  input: normalizeIntegrationRouteInputSchemas(input),
1471
1471
  handler: input.handler,
1472
1472
  __operation: defineIntegrationAPIOperation({
1473
- path: path32,
1473
+ path: path33,
1474
1474
  method,
1475
1475
  bodyFormat: input.bodyFormat,
1476
1476
  responseFormat: input.responseFormat,
@@ -1482,52 +1482,52 @@ function defineTypedIntegrationRoute(method, path32, input) {
1482
1482
  }
1483
1483
  function createIntegrationRouteFactory() {
1484
1484
  return {
1485
- get(path32, input) {
1485
+ get(path33, input) {
1486
1486
  return defineTypedIntegrationRoute(
1487
1487
  "GET",
1488
- path32,
1488
+ path33,
1489
1489
  input
1490
1490
  );
1491
1491
  },
1492
- post(path32, input) {
1492
+ post(path33, input) {
1493
1493
  return defineTypedIntegrationRoute(
1494
1494
  "POST",
1495
- path32,
1495
+ path33,
1496
1496
  {
1497
1497
  bodyFormat: "json",
1498
1498
  ...input
1499
1499
  }
1500
1500
  );
1501
1501
  },
1502
- put(path32, input) {
1502
+ put(path33, input) {
1503
1503
  return defineTypedIntegrationRoute(
1504
1504
  "PUT",
1505
- path32,
1505
+ path33,
1506
1506
  {
1507
1507
  bodyFormat: "json",
1508
1508
  ...input
1509
1509
  }
1510
1510
  );
1511
1511
  },
1512
- patch(path32, input) {
1513
- return defineTypedIntegrationRoute("PATCH", path32, {
1512
+ patch(path33, input) {
1513
+ return defineTypedIntegrationRoute("PATCH", path33, {
1514
1514
  bodyFormat: "json",
1515
1515
  ...input
1516
1516
  });
1517
1517
  },
1518
- delete(path32, input) {
1519
- return defineTypedIntegrationRoute("DELETE", path32, {
1518
+ delete(path33, input) {
1519
+ return defineTypedIntegrationRoute("DELETE", path33, {
1520
1520
  bodyFormat: "json",
1521
1521
  ...input
1522
1522
  });
1523
1523
  },
1524
- options(path32, input) {
1525
- return defineTypedIntegrationRoute("OPTIONS", path32, input);
1524
+ options(path33, input) {
1525
+ return defineTypedIntegrationRoute("OPTIONS", path33, input);
1526
1526
  },
1527
- head(path32, input) {
1527
+ head(path33, input) {
1528
1528
  return defineTypedIntegrationRoute(
1529
1529
  "HEAD",
1530
- path32,
1530
+ path33,
1531
1531
  input
1532
1532
  );
1533
1533
  }
@@ -1874,8 +1874,8 @@ async function parseIntegrationConfigSchema(integration, schema, value) {
1874
1874
  function createIntegrationConfigValidationError(integration, error) {
1875
1875
  const issues = Array.isArray(error.issues) && error.issues.length > 0 ? error.issues.map((issue) => {
1876
1876
  const normalizedPath = normalizeIntegrationValidationPath(issue.path);
1877
- const path32 = normalizedPath.length ? `${normalizedPath.join(".")}: ` : "";
1878
- return `${path32}${issue.message || "Invalid config"}`;
1877
+ const path33 = normalizedPath.length ? `${normalizedPath.join(".")}: ` : "";
1878
+ return `${path33}${issue.message || "Invalid config"}`;
1879
1879
  }).join("; ") : error.message || "Invalid config";
1880
1880
  return new Error(`Integration "${integration.type}" config validation failed: ${issues}`);
1881
1881
  }
@@ -2572,8 +2572,8 @@ function normalizeIntegrationValidationIssues(source, error) {
2572
2572
  }
2573
2573
  ];
2574
2574
  }
2575
- function normalizeIntegrationValidationPath(path32) {
2576
- return (path32 || []).map((segment) => {
2575
+ function normalizeIntegrationValidationPath(path33) {
2576
+ return (path33 || []).map((segment) => {
2577
2577
  const key = typeof segment === "object" && segment !== null && "key" in segment ? segment.key : segment;
2578
2578
  return typeof key === "symbol" ? key.description || key.toString() : key;
2579
2579
  });
@@ -4008,22 +4008,22 @@ async function prepareFarmWorkflowsForNitro(config) {
4008
4008
  }
4009
4009
  const root = config.root || process.cwd();
4010
4010
  const distDir = config.distDir || ".farm";
4011
- const fs9 = await import("fs/promises");
4012
- const path32 = await import("path");
4013
- const generatedDir = path32.join(root, distDir, ".nitro", "farm-workflows");
4014
- await fs9.mkdir(generatedDir, { recursive: true });
4011
+ const fs10 = await import("fs/promises");
4012
+ const path33 = await import("path");
4013
+ const generatedDir = path33.join(root, distDir, ".nitro", "farm-workflows");
4014
+ await fs10.mkdir(generatedDir, { recursive: true });
4015
4015
  const tasks = {};
4016
4016
  const scheduledTasks = createScheduledTasks(workflows);
4017
4017
  for (const workflow of workflows) {
4018
- const wrapperPath = path32.join(generatedDir, `${safeFileName(workflow.id)}.mjs`);
4019
- await fs9.writeFile(wrapperPath, createNitroTaskWrapper(workflow), "utf8");
4018
+ const wrapperPath = path33.join(generatedDir, `${safeFileName(workflow.id)}.mjs`);
4019
+ await fs10.writeFile(wrapperPath, createNitroTaskWrapper(workflow), "utf8");
4020
4020
  tasks[workflow.id] = {
4021
4021
  handler: wrapperPath,
4022
4022
  description: workflow.description || `Farm workflow ${workflow.id}`
4023
4023
  };
4024
4024
  }
4025
- const handlerPath = path32.join(generatedDir, "http-handler.mjs");
4026
- await fs9.writeFile(
4025
+ const handlerPath = path33.join(generatedDir, "http-handler.mjs");
4026
+ await fs10.writeFile(
4027
4027
  handlerPath,
4028
4028
  createNitroWorkflowHTTPHandler(
4029
4029
  workflowConfig,
@@ -4032,8 +4032,8 @@ async function prepareFarmWorkflowsForNitro(config) {
4032
4032
  ),
4033
4033
  "utf8"
4034
4034
  );
4035
- const manifestPath = path32.join(generatedDir, "manifest.json");
4036
- await fs9.writeFile(
4035
+ const manifestPath = path33.join(generatedDir, "manifest.json");
4036
+ await fs10.writeFile(
4037
4037
  manifestPath,
4038
4038
  JSON.stringify(
4039
4039
  {
@@ -4114,22 +4114,22 @@ function resolveWorkflowDefinition(module2) {
4114
4114
  return null;
4115
4115
  }
4116
4116
  async function findWorkflowFiles(root, dirs) {
4117
- const fs9 = await import("fs/promises");
4118
- const path32 = await import("path");
4117
+ const fs10 = await import("fs/promises");
4118
+ const path33 = await import("path");
4119
4119
  const files = [];
4120
4120
  for (const dir of dirs) {
4121
- const absoluteDir = path32.isAbsolute(dir) ? dir : path32.join(root, dir);
4121
+ const absoluteDir = path33.isAbsolute(dir) ? dir : path33.join(root, dir);
4122
4122
  if (!await pathExists(absoluteDir)) continue;
4123
4123
  await walkWorkflowDir(absoluteDir, files);
4124
4124
  }
4125
4125
  return files.sort();
4126
4126
  }
4127
4127
  async function walkWorkflowDir(dir, files) {
4128
- const fs9 = await import("fs/promises");
4129
- const path32 = await import("path");
4130
- const entries = await fs9.readdir(dir, { withFileTypes: true });
4128
+ const fs10 = await import("fs/promises");
4129
+ const path33 = await import("path");
4130
+ const entries = await fs10.readdir(dir, { withFileTypes: true });
4131
4131
  for (const entry of entries) {
4132
- const filePath = path32.join(dir, entry.name);
4132
+ const filePath = path33.join(dir, entry.name);
4133
4133
  if (entry.isDirectory()) {
4134
4134
  if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
4135
4135
  await walkWorkflowDir(filePath, files);
@@ -4141,20 +4141,20 @@ async function walkWorkflowDir(dir, files) {
4141
4141
  }
4142
4142
  }
4143
4143
  async function pathExists(filePath) {
4144
- const fs9 = await import("fs/promises");
4145
- return fs9.access(filePath).then(() => true).catch(() => false);
4144
+ const fs10 = await import("fs/promises");
4145
+ return fs10.access(filePath).then(() => true).catch(() => false);
4146
4146
  }
4147
4147
  function isWorkflowFile(fileName) {
4148
4148
  return /\.(?:ts|tsx|js|jsx|mjs|cjs)$/.test(fileName) && !/\.d\.[cm]?ts$/.test(fileName);
4149
4149
  }
4150
4150
  async function loadWorkflowModule(filePath, root) {
4151
- const fs9 = await import("fs/promises");
4152
- const path32 = await import("path");
4151
+ const fs10 = await import("fs/promises");
4152
+ const path33 = await import("path");
4153
4153
  const { pathToFileURL: pathToFileURL5 } = await import("url");
4154
4154
  const { build: build2 } = await import("esbuild");
4155
- const outDir = path32.join(root, ".farm", ".workflow-loader");
4156
- await fs9.mkdir(outDir, { recursive: true });
4157
- const outfile = path32.join(
4155
+ const outDir = path33.join(root, ".farm", ".workflow-loader");
4156
+ await fs10.mkdir(outDir, { recursive: true });
4157
+ const outfile = path33.join(
4158
4158
  outDir,
4159
4159
  `workflow-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`
4160
4160
  );
@@ -4178,7 +4178,7 @@ async function loadWorkflowModule(filePath, root) {
4178
4178
  `${pathToFileURL5(outfile).href}?t=${Date.now()}`
4179
4179
  );
4180
4180
  } finally {
4181
- await fs9.unlink(outfile).catch(() => void 0);
4181
+ await fs10.unlink(outfile).catch(() => void 0);
4182
4182
  }
4183
4183
  }
4184
4184
  function workflowIdFromFile(root, filePath) {
@@ -4448,14 +4448,14 @@ async function prepareFarmCronForNitro(config) {
4448
4448
  const cron = isResolvedCronConfig(config.cron) ? config.cron : resolveCronConfig(config.cron);
4449
4449
  const root = config.root || process.cwd();
4450
4450
  const distDir = config.distDir || ".farm";
4451
- const fs9 = await import("fs/promises");
4452
- const path32 = await import("path");
4453
- const manifestPath = path32.join(root, distDir, FARM_CRON_MANIFEST);
4454
- const generatedDir = path32.join(root, distDir, ".nitro", "farm-cron");
4451
+ const fs10 = await import("fs/promises");
4452
+ const path33 = await import("path");
4453
+ const manifestPath = path33.join(root, distDir, FARM_CRON_MANIFEST);
4454
+ const generatedDir = path33.join(root, distDir, ".nitro", "farm-cron");
4455
4455
  if (!cron.enabled) {
4456
4456
  await Promise.all([
4457
- fs9.rm(manifestPath, { force: true }),
4458
- fs9.rm(generatedDir, { recursive: true, force: true })
4457
+ fs10.rm(manifestPath, { force: true }),
4458
+ fs10.rm(generatedDir, { recursive: true, force: true })
4459
4459
  ]);
4460
4460
  return {
4461
4461
  jobs: [],
@@ -4463,21 +4463,21 @@ async function prepareFarmCronForNitro(config) {
4463
4463
  scheduledTasks: {}
4464
4464
  };
4465
4465
  }
4466
- await fs9.rm(generatedDir, { recursive: true, force: true });
4467
- await fs9.mkdir(generatedDir, { recursive: true });
4466
+ await fs10.rm(generatedDir, { recursive: true, force: true });
4467
+ await fs10.mkdir(generatedDir, { recursive: true });
4468
4468
  const tasks = {};
4469
4469
  for (const job of cron.jobs) {
4470
4470
  const taskName = getFarmCronTaskName(job.name);
4471
- const wrapperPath = path32.join(generatedDir, `${safeFileName2(job.name)}.mjs`);
4472
- await fs9.writeFile(wrapperPath, createNitroCronTaskWrapper(job, cron.secretEnv), "utf8");
4471
+ const wrapperPath = path33.join(generatedDir, `${safeFileName2(job.name)}.mjs`);
4472
+ await fs10.writeFile(wrapperPath, createNitroCronTaskWrapper(job, cron.secretEnv), "utf8");
4473
4473
  tasks[taskName] = {
4474
4474
  handler: wrapperPath,
4475
4475
  description: job.description || `Farm cron ${job.name}`
4476
4476
  };
4477
4477
  }
4478
4478
  const manifest = createFarmCronManifest(cron);
4479
- await fs9.mkdir(path32.dirname(manifestPath), { recursive: true });
4480
- await fs9.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
4479
+ await fs10.mkdir(path33.dirname(manifestPath), { recursive: true });
4480
+ await fs10.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
4481
4481
  `, "utf8");
4482
4482
  return {
4483
4483
  jobs: cron.jobs,
@@ -4578,7 +4578,7 @@ function normalizeCronJob(name, job) {
4578
4578
  if (!job || typeof job !== "object" || Array.isArray(job)) {
4579
4579
  throw new TypeError(`Farm cron ${JSON.stringify(name)} must be a configuration object.`);
4580
4580
  }
4581
- const path32 = normalizeCronPath(name, job.path);
4581
+ const path33 = normalizeCronPath(name, job.path);
4582
4582
  const rawSchedule = Array.isArray(job.schedule) ? job.schedule : [job.schedule];
4583
4583
  const schedule = [...new Set(rawSchedule.map((value) => normalizeCronExpression(name, value)))];
4584
4584
  if (schedule.length === 0) {
@@ -4587,7 +4587,7 @@ function normalizeCronJob(name, job) {
4587
4587
  return {
4588
4588
  name,
4589
4589
  schedule,
4590
- path: path32,
4590
+ path: path33,
4591
4591
  description: job.description?.trim() || void 0
4592
4592
  };
4593
4593
  }
@@ -4595,13 +4595,13 @@ function normalizeCronPath(name, value) {
4595
4595
  if (typeof value !== "string" || !value.trim().startsWith("/")) {
4596
4596
  throw new TypeError(`Farm cron ${JSON.stringify(name)} path must start with "/".`);
4597
4597
  }
4598
- const path32 = value.trim();
4599
- if (path32.startsWith("//") || path32.includes("?") || path32.includes("#")) {
4598
+ const path33 = value.trim();
4599
+ if (path33.startsWith("//") || path33.includes("?") || path33.includes("#")) {
4600
4600
  throw new TypeError(
4601
4601
  `Farm cron ${JSON.stringify(name)} path must be an application pathname without a host, query, or hash.`
4602
4602
  );
4603
4603
  }
4604
- return path32.length > 1 ? path32.replace(/\/+$/, "") : path32;
4604
+ return path33.length > 1 ? path33.replace(/\/+$/, "") : path33;
4605
4605
  }
4606
4606
  function normalizeCronExpression(name, value) {
4607
4607
  if (typeof value !== "string") {
@@ -5733,7 +5733,7 @@ var init_server_action_security = __esm({
5733
5733
 
5734
5734
  // src/image-config.ts
5735
5735
  function resolveFarmImageConfig(config) {
5736
- const path32 = normalizeImagePath(config?.path ?? DEFAULT_FARM_IMAGE_PATH);
5736
+ const path33 = normalizeImagePath(config?.path ?? DEFAULT_FARM_IMAGE_PATH);
5737
5737
  const deviceSizes = normalizeIntegerList(
5738
5738
  config?.deviceSizes ?? DEFAULT_FARM_IMAGE_DEVICE_SIZES,
5739
5739
  "images.deviceSizes"
@@ -5761,7 +5761,7 @@ function resolveFarmImageConfig(config) {
5761
5761
  );
5762
5762
  return Object.freeze({
5763
5763
  provider: config?.provider ?? "auto",
5764
- path: path32,
5764
+ path: path33,
5765
5765
  domains: Object.freeze([
5766
5766
  ...new Set(
5767
5767
  (config?.domains ?? []).map((domain) => domain.trim().toLowerCase()).filter(Boolean)
@@ -5800,11 +5800,11 @@ function getPublicFarmImageConfig(config) {
5800
5800
  };
5801
5801
  }
5802
5802
  function normalizeImagePath(value) {
5803
- const path32 = value.trim().replace(/\/+$/, "") || "/";
5804
- if (!path32.startsWith("/") || path32.includes("?") || path32.includes("#")) {
5803
+ const path33 = value.trim().replace(/\/+$/, "") || "/";
5804
+ if (!path33.startsWith("/") || path33.includes("?") || path33.includes("#")) {
5805
5805
  throw new TypeError("images.path must be an absolute pathname without a query or hash");
5806
5806
  }
5807
- return path32;
5807
+ return path33;
5808
5808
  }
5809
5809
  function normalizeIntegerList(values, name, max) {
5810
5810
  if (values.length === 0) {
@@ -7208,7 +7208,7 @@ function normalizePositiveDuration(value, fallback, name) {
7208
7208
  return Math.floor(value);
7209
7209
  }
7210
7210
  function delay(ms) {
7211
- return new Promise((resolve6) => setTimeout(resolve6, ms));
7211
+ return new Promise((resolve7) => setTimeout(resolve7, ms));
7212
7212
  }
7213
7213
  function normalizeCacheOptionsTags(options) {
7214
7214
  const tags = /* @__PURE__ */ new Set();
@@ -7792,7 +7792,7 @@ function getProgrammaticRouteSearchClientOptions(search) {
7792
7792
  if (search.temporary?.length) options.temporary = [...search.temporary];
7793
7793
  return Object.keys(options).length > 0 ? options : void 0;
7794
7794
  }
7795
- function resolveProgrammaticRouteSearch(searchConfig, rawSearch, path32, routePath) {
7795
+ function resolveProgrammaticRouteSearch(searchConfig, rawSearch, path33, routePath) {
7796
7796
  const schema = getProgrammaticRouteSearchSchema(searchConfig);
7797
7797
  const search = parseProgrammaticSchema(schema, rawSearch, "search", routePath);
7798
7798
  const options = getProgrammaticRouteSearchOptions(searchConfig);
@@ -7801,7 +7801,7 @@ function resolveProgrammaticRouteSearch(searchConfig, rawSearch, path32, routePa
7801
7801
  schema,
7802
7802
  rawSearch,
7803
7803
  parsedSearch: search,
7804
- path: path32
7804
+ path: path33
7805
7805
  });
7806
7806
  return { search, canonicalPath };
7807
7807
  }
@@ -7880,8 +7880,8 @@ function normalizeComparableValue(value) {
7880
7880
  }
7881
7881
  return value;
7882
7882
  }
7883
- function createRoute(path32, options) {
7884
- return routesBuilder.page(path32, options);
7883
+ function createRoute(path33, options) {
7884
+ return routesBuilder.page(path33, options);
7885
7885
  }
7886
7886
  function isProgrammaticRoutesFileName(fileName) {
7887
7887
  const normalized = fileName.replace(/\\/g, "/");
@@ -7971,7 +7971,7 @@ function createRouteModuleFromProgrammaticPage(route2) {
7971
7971
  mod.__farmRouteData = route2.data;
7972
7972
  mod.__farmRouteParsesProps = true;
7973
7973
  mod.__farmResolveRouteProps = (props) => resolveProgrammaticRouteProps(route2, props);
7974
- mod.__farmResolveRouteCanonicalPath = (rawSearch, path32) => resolveProgrammaticRouteSearch(route2.search, rawSearch, path32, route2.path).canonicalPath;
7974
+ mod.__farmResolveRouteCanonicalPath = (rawSearch, path33) => resolveProgrammaticRouteSearch(route2.search, rawSearch, path33, route2.path).canonicalPath;
7975
7975
  }
7976
7976
  if (route2.pending || route2.error || route2.notFound) {
7977
7977
  mod.__farmRouteComponents = {
@@ -8369,25 +8369,25 @@ var init_routes = __esm({
8369
8369
  ];
8370
8370
  __name(defineRoutes, "defineRoutes");
8371
8371
  routesBuilder = {
8372
- page(path32, options) {
8372
+ page(path33, options) {
8373
8373
  return normalizeProgrammaticRoute({
8374
8374
  kind: "page",
8375
- path: path32,
8375
+ path: path33,
8376
8376
  ...options
8377
8377
  });
8378
8378
  },
8379
- layout(path32, options) {
8379
+ layout(path33, options) {
8380
8380
  return normalizeProgrammaticRoute({
8381
8381
  kind: "layout",
8382
- path: path32,
8382
+ path: path33,
8383
8383
  ...options
8384
8384
  });
8385
8385
  },
8386
- api(path32, options) {
8386
+ api(path33, options) {
8387
8387
  const { render, runtime, regions, maxDuration, ...methods } = options;
8388
8388
  return normalizeProgrammaticRoute({
8389
8389
  kind: "api",
8390
- path: path32,
8390
+ path: path33,
8391
8391
  render,
8392
8392
  runtime,
8393
8393
  regions,
@@ -8758,6 +8758,35 @@ function getIslandStrategyExport(content) {
8758
8758
  function stripUseClientDirective(content) {
8759
8759
  return content.replace(/^\s*(["'])use client\1\s*;?\s*/, "");
8760
8760
  }
8761
+ function hasAsyncDefaultExport(content) {
8762
+ if (!content) return false;
8763
+ const tokens = tokenizeModuleSource(content);
8764
+ for (let index = 0; index < tokens.length - 2; index++) {
8765
+ const token = tokens[index];
8766
+ if (token.kind !== "identifier" || token.value !== "export") continue;
8767
+ if (tokens[index - 1]?.value === ".") continue;
8768
+ if (tokens[index + 1]?.value !== "default") continue;
8769
+ const exported = tokens[index + 2];
8770
+ if (exported.kind === "identifier" && exported.value === "async") {
8771
+ return true;
8772
+ }
8773
+ if (exported.kind === "identifier" && !["function", "class"].includes(exported.value) && tokens[index + 3]?.value !== "(" && isAsyncLocalDeclaration(tokens, exported.value)) {
8774
+ return true;
8775
+ }
8776
+ }
8777
+ return false;
8778
+ }
8779
+ function isAsyncLocalDeclaration(tokens, name) {
8780
+ for (let index = 0; index < tokens.length - 2; index++) {
8781
+ if (tokens[index].value === "async" && tokens[index + 1]?.value === "function" && tokens[index + 2]?.value === name) {
8782
+ return true;
8783
+ }
8784
+ if (tokens[index].value === name && tokens[index + 1]?.value === "=" && tokens[index + 2]?.value === "async") {
8785
+ return true;
8786
+ }
8787
+ }
8788
+ return false;
8789
+ }
8761
8790
  function parseClientModuleMetadata(content, inspectIslandExport) {
8762
8791
  if (!content) {
8763
8792
  return {
@@ -8811,6 +8840,14 @@ function inspectClientModuleMetadata(resolvedPath, root, visited, inspectIslandE
8811
8840
  }
8812
8841
  }
8813
8842
  const shouldHydrate = parsed.hasHydrateExport || importsClientBoundary;
8843
+ if (shouldHydrate && hasAsyncDefaultExport(content)) {
8844
+ return {
8845
+ isClientComponent: false,
8846
+ shouldHydrate: false,
8847
+ islandStrategy: null,
8848
+ suppressedAsyncHydration: true
8849
+ };
8850
+ }
8814
8851
  return {
8815
8852
  isClientComponent: false,
8816
8853
  shouldHydrate,
@@ -9111,6 +9148,8 @@ var init_client_component = __esm({
9111
9148
  __name(isIslandExportStart, "isIslandExportStart");
9112
9149
  __name(getIslandStrategyExport, "getIslandStrategyExport");
9113
9150
  __name(stripUseClientDirective, "stripUseClientDirective");
9151
+ __name(hasAsyncDefaultExport, "hasAsyncDefaultExport");
9152
+ __name(isAsyncLocalDeclaration, "isAsyncLocalDeclaration");
9114
9153
  __name(parseClientModuleMetadata, "parseClientModuleMetadata");
9115
9154
  __name(getClientModuleMetadata, "getClientModuleMetadata");
9116
9155
  __name(inspectClientModuleMetadata, "inspectClientModuleMetadata");
@@ -9671,6 +9710,7 @@ var init_route_manager = __esm({
9671
9710
  shouldHydrate: metadata.shouldHydrate,
9672
9711
  isClientComponent: metadata.isClientComponent,
9673
9712
  islandStrategy: metadata.islandStrategy,
9713
+ suppressedAsyncHydration: metadata.suppressedAsyncHydration,
9674
9714
  search: getProgrammaticRouteSearchClientOptions(programmaticPage?.search),
9675
9715
  segments: entry.route.segments.map((seg) => ({
9676
9716
  segment: seg.segment,
@@ -10424,12 +10464,12 @@ function isFarmRouteActive(pattern, pathname, options = {}) {
10424
10464
  }
10425
10465
  function normalizeRouteInput(input, index) {
10426
10466
  const route2 = typeof input === "string" ? { path: input } : input;
10427
- const path32 = normalizePathname2(route2.path);
10428
- const segments = parseRoutePattern(path32);
10467
+ const path33 = normalizePathname2(route2.path);
10468
+ const segments = parseRoutePattern(path33);
10429
10469
  return {
10430
10470
  route: {
10431
10471
  ...route2,
10432
- path: path32
10472
+ path: path33
10433
10473
  },
10434
10474
  segments,
10435
10475
  score: scoreSegments(segments),
@@ -10860,8 +10900,8 @@ function getControlledDeferred(id, controllers) {
10860
10900
  if (existing) return existing;
10861
10901
  let nativeResolve;
10862
10902
  let nativeReject;
10863
- const promise = new Promise((resolve6, reject) => {
10864
- nativeResolve = resolve6;
10903
+ const promise = new Promise((resolve7, reject) => {
10904
+ nativeResolve = resolve7;
10865
10905
  nativeReject = reject;
10866
10906
  });
10867
10907
  promise.status = "pending";
@@ -11075,8 +11115,8 @@ function createFarmDeploymentMismatchError(response, clientDeploymentId) {
11075
11115
  getFarmResponseDeploymentId(response) || "unknown"
11076
11116
  );
11077
11117
  }
11078
- function createFarmDeploymentCookie(deploymentId, path32 = "/", secure = false) {
11079
- const normalizedPath = path32.startsWith("/") ? path32 : `/${path32}`;
11118
+ function createFarmDeploymentCookie(deploymentId, path33 = "/", secure = false) {
11119
+ const normalizedPath = path33.startsWith("/") ? path33 : `/${path33}`;
11080
11120
  return [
11081
11121
  `${FARM_DEPLOYMENT_COOKIE}=${encodeURIComponent(deploymentId)}`,
11082
11122
  `Path=${normalizedPath}`,
@@ -11257,11 +11297,11 @@ function readPageState() {
11257
11297
  if (!state || typeof state !== "object") return null;
11258
11298
  return state[FARM_PAGE_STATE_KEY] ?? null;
11259
11299
  }
11260
- function createHistoryState(path32, pageState, currentState, interceptFrom) {
11300
+ function createHistoryState(path33, pageState, currentState, interceptFrom) {
11261
11301
  const base = currentState && typeof currentState === "object" ? { ...currentState } : {};
11262
11302
  const nextState = {
11263
11303
  ...base,
11264
- path: path32,
11304
+ path: path33,
11265
11305
  [FARM_PAGE_STATE_KEY]: pageState
11266
11306
  };
11267
11307
  if (interceptFrom === null) {
@@ -11271,9 +11311,9 @@ function createHistoryState(path32, pageState, currentState, interceptFrom) {
11271
11311
  }
11272
11312
  return nextState;
11273
11313
  }
11274
- function getPageDataCacheKey(path32, interceptFrom) {
11275
- return interceptFrom ? `${path32}
11276
- intercept:${interceptFrom}` : path32;
11314
+ function getPageDataCacheKey(path33, interceptFrom) {
11315
+ return interceptFrom ? `${path33}
11316
+ intercept:${interceptFrom}` : path33;
11277
11317
  }
11278
11318
  function createNavigationLocation(url) {
11279
11319
  return {
@@ -11283,8 +11323,8 @@ function createNavigationLocation(url) {
11283
11323
  hash: url.hash
11284
11324
  };
11285
11325
  }
11286
- function getScrollElementStorageKey(path32, key) {
11287
- return `farm-scroll-${path32}:${key}`;
11326
+ function getScrollElementStorageKey(path33, key) {
11327
+ return `farm-scroll-${path33}:${key}`;
11288
11328
  }
11289
11329
  var FARM_PAGE_STATE_KEY, FARM_INTERCEPT_FROM_KEY, IDLE_NAVIGATION_STATE, routerInstance, _SPARouter, SPARouter;
11290
11330
  var init_spa_router = __esm({
@@ -11570,13 +11610,13 @@ var init_spa_router = __esm({
11570
11610
  /**
11571
11611
  * Fetch page data from cache or server
11572
11612
  */
11573
- async fetchPageData(path32, recover = true, interceptFrom) {
11574
- const cacheKey = getPageDataCacheKey(path32, interceptFrom);
11613
+ async fetchPageData(path33, recover = true, interceptFrom) {
11614
+ const cacheKey = getPageDataCacheKey(path33, interceptFrom);
11575
11615
  const cached = this.cache.get(cacheKey);
11576
11616
  if (cached && Date.now() - cached.timestamp < this.options.cacheMaxAge) {
11577
11617
  return cached.data;
11578
11618
  }
11579
- const response = await fetch(`/__farm/page-data?path=${encodeURIComponent(path32)}`, {
11619
+ const response = await fetch(`/__farm/page-data?path=${encodeURIComponent(path33)}`, {
11580
11620
  headers: createFarmDeploymentRequestHeaders(this.options.deploymentId, {
11581
11621
  Accept: "application/x-farm-deferred+json, application/json",
11582
11622
  "X-Farm-SPA": "1",
@@ -11590,7 +11630,7 @@ var init_spa_router = __esm({
11590
11630
  );
11591
11631
  dispatchDeploymentMismatch(error);
11592
11632
  if (recover) {
11593
- window.location.assign(path32);
11633
+ window.location.assign(path33);
11594
11634
  }
11595
11635
  throw error;
11596
11636
  }
@@ -11609,16 +11649,16 @@ var init_spa_router = __esm({
11609
11649
  */
11610
11650
  async handlePopState(event) {
11611
11651
  if (document.documentElement.dataset.farmDocsRuntime === "true") return;
11612
- const path32 = window.location.pathname + window.location.search;
11652
+ const path33 = window.location.pathname + window.location.search;
11613
11653
  if (await this.shouldBlockNavigation({
11614
- from: event.state?.path || path32,
11615
- to: path32,
11654
+ from: event.state?.path || path33,
11655
+ to: path33,
11616
11656
  action: "pop"
11617
11657
  })) {
11618
11658
  return;
11619
11659
  }
11620
11660
  this.startNavigation({
11621
- from: event.state?.path || path32,
11661
+ from: event.state?.path || path33,
11622
11662
  to: createNavigationLocation(new URL(window.location.href)),
11623
11663
  action: "pop"
11624
11664
  });
@@ -11630,7 +11670,7 @@ var init_spa_router = __esm({
11630
11670
  action: "pop"
11631
11671
  });
11632
11672
  const interceptFrom = typeof event.state?.[FARM_INTERCEPT_FROM_KEY] === "string" ? event.state[FARM_INTERCEPT_FROM_KEY] : void 0;
11633
- const pageData = await this.fetchPageData(path32, true, interceptFrom);
11673
+ const pageData = await this.fetchPageData(path33, true, interceptFrom);
11634
11674
  if (clientNavigation) {
11635
11675
  await this.clientPlugins?.markNavigationLoaded(clientNavigation, pageData);
11636
11676
  }
@@ -11661,8 +11701,8 @@ var init_spa_router = __esm({
11661
11701
  /**
11662
11702
  * Check if URL is cached
11663
11703
  */
11664
- isCached(path32, interceptFrom) {
11665
- const cached = this.cache.get(getPageDataCacheKey(path32, interceptFrom));
11704
+ isCached(path33, interceptFrom) {
11705
+ const cached = this.cache.get(getPageDataCacheKey(path33, interceptFrom));
11666
11706
  return cached !== void 0 && Date.now() - cached.timestamp < this.options.cacheMaxAge;
11667
11707
  }
11668
11708
  /**
@@ -11716,15 +11756,15 @@ var init_spa_router = __esm({
11716
11756
  /**
11717
11757
  * Save scroll position for a path
11718
11758
  */
11719
- saveScrollPosition(path32) {
11759
+ saveScrollPosition(path33) {
11720
11760
  try {
11721
11761
  sessionStorage.setItem(
11722
- `farm-scroll-${path32}`,
11762
+ `farm-scroll-${path33}`,
11723
11763
  JSON.stringify({ x: window.scrollX, y: window.scrollY })
11724
11764
  );
11725
11765
  for (const [key, element] of this.scrollElements) {
11726
11766
  sessionStorage.setItem(
11727
- getScrollElementStorageKey(path32, key),
11767
+ getScrollElementStorageKey(path33, key),
11728
11768
  JSON.stringify({ x: element.scrollLeft, y: element.scrollTop })
11729
11769
  );
11730
11770
  }
@@ -11734,22 +11774,22 @@ var init_spa_router = __esm({
11734
11774
  /**
11735
11775
  * Restore scroll position for a path
11736
11776
  */
11737
- restoreScrollPosition(path32) {
11777
+ restoreScrollPosition(path33) {
11738
11778
  try {
11739
- const saved = sessionStorage.getItem(`farm-scroll-${path32}`);
11779
+ const saved = sessionStorage.getItem(`farm-scroll-${path33}`);
11740
11780
  if (saved) {
11741
11781
  const { x, y } = JSON.parse(saved);
11742
11782
  setTimeout(() => window.scrollTo(x, y), 0);
11743
11783
  }
11744
11784
  for (const [key, element] of this.scrollElements) {
11745
- this.restoreScrollElement(path32, key, element);
11785
+ this.restoreScrollElement(path33, key, element);
11746
11786
  }
11747
11787
  } catch {
11748
11788
  }
11749
11789
  }
11750
- restoreScrollElement(path32, key, element) {
11790
+ restoreScrollElement(path33, key, element) {
11751
11791
  try {
11752
- const saved = sessionStorage.getItem(getScrollElementStorageKey(path32, key));
11792
+ const saved = sessionStorage.getItem(getScrollElementStorageKey(path33, key));
11753
11793
  if (!saved) return;
11754
11794
  const { x, y } = JSON.parse(saved);
11755
11795
  setTimeout(() => {
@@ -14325,12 +14365,208 @@ body {
14325
14365
  }
14326
14366
  });
14327
14367
 
14368
+ // src/theme/config.ts
14369
+ function resolveFarmThemeConfig(config, basePath = "/") {
14370
+ if (config && "enabled" in config) {
14371
+ return config;
14372
+ }
14373
+ if (!config) {
14374
+ return {
14375
+ enabled: false,
14376
+ default: "system",
14377
+ storageKey: DEFAULT_FARM_THEME_STORAGE_KEY,
14378
+ cookiePath: normalizeCookiePath(basePath)
14379
+ };
14380
+ }
14381
+ const storageKey = config.storageKey?.trim() || DEFAULT_FARM_THEME_STORAGE_KEY;
14382
+ if (!STORAGE_KEY_PATTERN.test(storageKey)) {
14383
+ throw new Error(
14384
+ "theme.storageKey may only contain letters, numbers, dots, underscores, and hyphens."
14385
+ );
14386
+ }
14387
+ const defaultTheme = config.default ?? "system";
14388
+ if (defaultTheme !== "light" && defaultTheme !== "dark" && defaultTheme !== "system") {
14389
+ throw new Error('theme.default must be "light", "dark", or "system".');
14390
+ }
14391
+ return {
14392
+ enabled: true,
14393
+ default: defaultTheme,
14394
+ storageKey,
14395
+ cookiePath: normalizeCookiePath(basePath)
14396
+ };
14397
+ }
14398
+ function normalizeCookiePath(basePath) {
14399
+ const normalized = `/${basePath}`.replace(/\/{2,}/g, "/");
14400
+ if (normalized === "/") return normalized;
14401
+ return normalized.replace(/\/$/, "");
14402
+ }
14403
+ var DEFAULT_FARM_THEME_STORAGE_KEY, STORAGE_KEY_PATTERN;
14404
+ var init_config2 = __esm({
14405
+ "src/theme/config.ts"() {
14406
+ "use strict";
14407
+ DEFAULT_FARM_THEME_STORAGE_KEY = "farm-theme";
14408
+ STORAGE_KEY_PATTERN = /^[A-Za-z0-9._-]+$/;
14409
+ __name(resolveFarmThemeConfig, "resolveFarmThemeConfig");
14410
+ __name(normalizeCookiePath, "normalizeCookiePath");
14411
+ }
14412
+ });
14413
+
14414
+ // src/theme/server-runtime.ts
14415
+ function createFarmThemeDocumentParts(input, basePath = "/", serverTheme) {
14416
+ const config = resolveFarmThemeConfig(input, basePath);
14417
+ if (!config.enabled) return { attributes: "", head: "" };
14418
+ const hydrationTheme = serverTheme ?? config.default;
14419
+ const initialTheme = hydrationTheme === "system" ? "light" : hydrationTheme;
14420
+ const script = createFarmThemeBootstrapScript(config, hydrationTheme);
14421
+ return {
14422
+ attributes: ` data-theme="${initialTheme}"`,
14423
+ 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>`
14424
+ };
14425
+ }
14426
+ function createFarmThemeBootstrapScript(config, serverTheme = config.default) {
14427
+ return `(function(config,serverTheme){
14428
+ var isTheme=function(value){return value==="light"||value==="dark"||value==="system";};
14429
+ var decode=function(value){try{return decodeURIComponent(value);}catch(_error){return value;}};
14430
+ 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());}};
14431
+ var media=window.matchMedia("(prefers-color-scheme: dark)");
14432
+ var resolveTheme=function(theme){return theme==="system"?(media.matches?"dark":"light"):theme;};
14433
+ var storedTheme=readCookie();
14434
+ var preference=isTheme(storedTheme)?storedTheme:config.default;
14435
+ var serverSnapshot={theme:serverTheme,resolvedTheme:serverTheme==="system"?undefined:serverTheme,mounted:false};
14436
+ 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;};
14437
+ var emit=function(){var snapshot=apply();window.dispatchEvent(new CustomEvent("farm:themechange",{detail:snapshot}));};
14438
+ 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){}};
14439
+ var setTheme=function(theme){if(!isTheme(theme))throw new TypeError("Unknown FARMJS theme: "+String(theme));preference=theme;persist(theme);emit();};
14440
+ var initialSnapshot={theme:preference,resolvedTheme:resolveTheme(preference),mounted:true};
14441
+ window.__FARM_THEME__={config:config,serverSnapshot:serverSnapshot,snapshot:initialSnapshot,setTheme:setTheme};
14442
+ document.documentElement.dataset.theme=initialSnapshot.resolvedTheme;
14443
+ var handleSystemChange=function(){if(preference==="system")emit();};
14444
+ if(typeof media.addEventListener==="function")media.addEventListener("change",handleSystemChange);else if(typeof media.addListener==="function")media.addListener(handleSystemChange);
14445
+ window.addEventListener("storage",function(event){if(event.key!==config.storageKey||!isTheme(event.newValue))return;preference=event.newValue;persist(preference);emit();});
14446
+ })(${serializeInlineValue(config)},${serializeInlineValue(serverTheme)});`;
14447
+ }
14448
+ function serializeInlineValue(value) {
14449
+ return JSON.stringify(value).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
14450
+ }
14451
+ var THEME_SCRIPT_ID, THEME_STYLE_ID;
14452
+ var init_server_runtime = __esm({
14453
+ "src/theme/server-runtime.ts"() {
14454
+ "use strict";
14455
+ init_config2();
14456
+ THEME_SCRIPT_ID = "farm-theme-script";
14457
+ THEME_STYLE_ID = "farm-theme-style";
14458
+ __name(createFarmThemeDocumentParts, "createFarmThemeDocumentParts");
14459
+ __name(createFarmThemeBootstrapScript, "createFarmThemeBootstrapScript");
14460
+ __name(serializeInlineValue, "serializeInlineValue");
14461
+ }
14462
+ });
14463
+
14464
+ // src/theme/bridge.ts
14465
+ function _setFarmThemeServerSnapshotResolver(resolver) {
14466
+ globalThis[FARM_THEME_SERVER_SNAPSHOT_RESOLVER] = resolver;
14467
+ }
14468
+ function getFarmThemeServerSnapshot() {
14469
+ return globalThis[FARM_THEME_SERVER_SNAPSHOT_RESOLVER]?.() ?? FALLBACK_SERVER_SNAPSHOT;
14470
+ }
14471
+ var FALLBACK_SERVER_SNAPSHOT, FARM_THEME_SERVER_SNAPSHOT_RESOLVER;
14472
+ var init_bridge2 = __esm({
14473
+ "src/theme/bridge.ts"() {
14474
+ "use strict";
14475
+ FALLBACK_SERVER_SNAPSHOT = Object.freeze({
14476
+ theme: "system",
14477
+ resolvedTheme: void 0,
14478
+ mounted: false
14479
+ });
14480
+ FARM_THEME_SERVER_SNAPSHOT_RESOLVER = /* @__PURE__ */ Symbol.for("farm.js.theme.server-snapshot-resolver");
14481
+ __name(_setFarmThemeServerSnapshotResolver, "_setFarmThemeServerSnapshotResolver");
14482
+ __name(getFarmThemeServerSnapshot, "getFarmThemeServerSnapshot");
14483
+ }
14484
+ });
14485
+
14486
+ // src/theme/server.ts
14487
+ function _setDefaultFarmThemeConfig(config, basePath = "/") {
14488
+ defaultThemeConfig = resolveFarmThemeConfig(config, basePath);
14489
+ }
14490
+ function getTheme(request = getCurrentRequest()) {
14491
+ return readFarmThemePreference(request, defaultThemeConfig);
14492
+ }
14493
+ function getThemeSnapshot(request = getCurrentRequest()) {
14494
+ const theme = readFarmThemePreference(request, defaultThemeConfig);
14495
+ return {
14496
+ theme,
14497
+ resolvedTheme: theme === "system" ? void 0 : theme,
14498
+ mounted: false
14499
+ };
14500
+ }
14501
+ function readFarmThemePreference(request, config) {
14502
+ if (!config.enabled) return config.default;
14503
+ const stored = readCookie3(request.headers.get("cookie"), config.storageKey);
14504
+ return isFarmThemePreference(stored) ? stored : config.default;
14505
+ }
14506
+ function readCookie3(cookieHeader, name) {
14507
+ if (!cookieHeader) return void 0;
14508
+ for (const entry of cookieHeader.split(";")) {
14509
+ const separator = entry.indexOf("=");
14510
+ if (separator < 0) continue;
14511
+ const key = decodeCookieValue(entry.slice(0, separator).trim());
14512
+ if (key !== name) continue;
14513
+ return decodeCookieValue(entry.slice(separator + 1).trim());
14514
+ }
14515
+ return void 0;
14516
+ }
14517
+ function decodeCookieValue(value) {
14518
+ try {
14519
+ return decodeURIComponent(value);
14520
+ } catch {
14521
+ return value;
14522
+ }
14523
+ }
14524
+ function isFarmThemePreference(value) {
14525
+ return value === "light" || value === "dark" || value === "system";
14526
+ }
14527
+ var defaultThemeConfig;
14528
+ var init_server3 = __esm({
14529
+ "src/theme/server.ts"() {
14530
+ "use strict";
14531
+ init_request();
14532
+ init_bridge2();
14533
+ init_config2();
14534
+ defaultThemeConfig = resolveFarmThemeConfig(void 0);
14535
+ __name(_setDefaultFarmThemeConfig, "_setDefaultFarmThemeConfig");
14536
+ __name(getTheme, "getTheme");
14537
+ __name(getThemeSnapshot, "getThemeSnapshot");
14538
+ __name(readFarmThemePreference, "readFarmThemePreference");
14539
+ __name(readCookie3, "readCookie");
14540
+ __name(decodeCookieValue, "decodeCookieValue");
14541
+ __name(isFarmThemePreference, "isFarmThemePreference");
14542
+ _setFarmThemeServerSnapshotResolver(() => {
14543
+ try {
14544
+ return getThemeSnapshot();
14545
+ } catch {
14546
+ const theme = defaultThemeConfig.default;
14547
+ return {
14548
+ theme,
14549
+ resolvedTheme: theme === "system" ? void 0 : theme,
14550
+ mounted: false
14551
+ };
14552
+ }
14553
+ });
14554
+ }
14555
+ });
14556
+
14328
14557
  // src/server/renderer.ts
14558
+ function warnSuppressedAsyncHydrationOnce(modulePath) {
14559
+ if (warnedSuppressedAsyncHydrationModules.has(modulePath)) return;
14560
+ warnedSuppressedAsyncHydrationModules.add(modulePath);
14561
+ logger.warn(
14562
+ `${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.`
14563
+ );
14564
+ }
14329
14565
  function hasRequestHeader(req, name) {
14330
14566
  const value = req.headers[name.toLowerCase()];
14331
14567
  return Array.isArray(value) ? value.length > 0 : Boolean(value);
14332
14568
  }
14333
- function serializeInlineValue(value) {
14569
+ function serializeInlineValue2(value) {
14334
14570
  return JSON.stringify(value).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
14335
14571
  }
14336
14572
  function escapeHtmlAttribute2(value) {
@@ -14417,7 +14653,7 @@ function createDocumentFooter(options) {
14417
14653
  }
14418
14654
  function createDeferredHydrationScript(records) {
14419
14655
  if (records.length === 0) return "";
14420
- return `<script>window.__FARM_DEFERRED_DATA__=${serializeInlineValue(
14656
+ return `<script>window.__FARM_DEFERRED_DATA__=${serializeInlineValue2(
14421
14657
  snapshotDeferredData(records)
14422
14658
  )};</script>`;
14423
14659
  }
@@ -14480,7 +14716,7 @@ function createRouteStateProps(input) {
14480
14716
  context: input.pluginExposedContext.size > 0 ? { data: input.pluginExposedContext } : void 0
14481
14717
  };
14482
14718
  }
14483
- var import_react5, import_server2, fs2, path9, import_stream, cachedClerkProvider, importRuntimeModule, _FarmRouteErrorBoundary, FarmRouteErrorBoundary, _ServerRenderer, ServerRenderer;
14719
+ var import_react5, import_server2, fs2, path9, import_stream, cachedClerkProvider, importRuntimeModule, warnedSuppressedAsyncHydrationModules, _FarmRouteErrorBoundary, FarmRouteErrorBoundary, _ServerRenderer, ServerRenderer;
14484
14720
  var init_renderer = __esm({
14485
14721
  "src/server/renderer.ts"() {
14486
14722
  "use strict";
@@ -14510,10 +14746,14 @@ var init_renderer = __esm({
14510
14746
  init_font_vite();
14511
14747
  init_metadata_image();
14512
14748
  init_not_found();
14749
+ init_server_runtime();
14750
+ init_server3();
14513
14751
  cachedClerkProvider = null;
14514
14752
  importRuntimeModule = new Function("specifier", "return import(specifier);");
14753
+ warnedSuppressedAsyncHydrationModules = /* @__PURE__ */ new Set();
14754
+ __name(warnSuppressedAsyncHydrationOnce, "warnSuppressedAsyncHydrationOnce");
14515
14755
  __name(hasRequestHeader, "hasRequestHeader");
14516
- __name(serializeInlineValue, "serializeInlineValue");
14756
+ __name(serializeInlineValue2, "serializeInlineValue");
14517
14757
  __name(escapeHtmlAttribute2, "escapeHtmlAttribute");
14518
14758
  __name(appendResponseHeader, "appendResponseHeader");
14519
14759
  __name(appendResponseVary, "appendResponseVary");
@@ -15032,6 +15272,9 @@ var init_renderer = __esm({
15032
15272
  })
15033
15273
  );
15034
15274
  const shouldHydrate = moduleMetadata.shouldHydrate;
15275
+ if (moduleMetadata.suppressedAsyncHydration) {
15276
+ warnSuppressedAsyncHydrationOnce(route2.modulePath);
15277
+ }
15035
15278
  const layoutHydrationMetadata = layouts.map((layout2) => {
15036
15279
  const manifestEntry = routeManifest.layouts.find(
15037
15280
  (entry) => entry.pattern === layout2.pattern
@@ -15529,7 +15772,7 @@ var init_renderer = __esm({
15529
15772
  }
15530
15773
  }
15531
15774
  async renderWithSSR(element, req, res, clearMiddlewareData, options = {}) {
15532
- return new Promise((resolve6, reject) => {
15775
+ return new Promise((resolve7, reject) => {
15533
15776
  const streamStartTime = Date.now();
15534
15777
  const observabilityRoute = options.observabilityRoute || req.__FARM_ROUTE__ || req.url || "/";
15535
15778
  const deploymentId = this.getDeploymentId();
@@ -15601,9 +15844,9 @@ var init_renderer = __esm({
15601
15844
  slots: routeSlotPayload
15602
15845
  });
15603
15846
  const propsScript = `<script>
15604
- window.__FARM_PROPS__ = ${serializeInlineValue(deferredProps.data.page)};
15605
- window.__FARM_ROUTE_SLOTS__ = ${serializeInlineValue(deferredProps.data.slots)};
15606
- window.__FARM_DEPLOYMENT_ID__ = ${serializeInlineValue(deploymentId)};
15847
+ window.__FARM_PROPS__ = ${serializeInlineValue2(deferredProps.data.page)};
15848
+ window.__FARM_ROUTE_SLOTS__ = ${serializeInlineValue2(deferredProps.data.slots)};
15849
+ window.__FARM_DEPLOYMENT_ID__ = ${serializeInlineValue2(deploymentId)};
15607
15850
  window.__FARM_PATH__ = ${JSON.stringify(req.__FARM_ROUTE__ || req.url || "/")};
15608
15851
  window.__FARM_IS_CLIENT__ = ${JSON.stringify(isClientComponent)};
15609
15852
  window.__FARM_PAGE_SHOULD_HYDRATE__ = ${JSON.stringify(
@@ -15621,7 +15864,7 @@ window.__FARM_LOADING_MODULE__ = ${JSON.stringify(
15621
15864
  )};
15622
15865
  window.__FARM_MANIFEST__ = ${JSON.stringify(clientManifest)};
15623
15866
  window.__FARM_INTEGRATION_API_MANIFEST__ = ${JSON.stringify(getRegisteredIntegrationAPIManifest())};
15624
- ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue(getFarmI18nClientSnapshot())};` : ""}
15867
+ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue2(getFarmI18nClientSnapshot())};` : ""}
15625
15868
  </script>`;
15626
15869
  const hydrationClickQueueScript = isClientComponent || req.__FARM_SHOULD_HYDRATE__ === true || req.__FARM_HAS_HYDRATABLE_ROUTE_SLOTS__ === true ? createPreHydrationClickQueueScript() : "";
15627
15870
  const {
@@ -15632,6 +15875,11 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue(g
15632
15875
  const i18nSnapshot = getFarmI18nClientSnapshot();
15633
15876
  const i18nAlternateTags = i18nSnapshot ? renderI18nAlternateLinks(req.__FARM_ROUTE__ || req.url || "/", i18nSnapshot) : "";
15634
15877
  const fontHead = renderFarmFontDevHead(this.config.root || process.cwd());
15878
+ const themeDocument = createFarmThemeDocumentParts(
15879
+ this.config.theme,
15880
+ this.config.basePath,
15881
+ getTheme()
15882
+ );
15635
15883
  const streamRoot = import_react5.default.createElement("div", { style: { display: "contents" } }, element);
15636
15884
  const { pipe } = (0, import_server2.renderToPipeableStream)(streamRoot, {
15637
15885
  onShellReady() {
@@ -15645,8 +15893,9 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue(g
15645
15893
  console.log(`[FARM STREAM] onShellReady at ${shellReadyMs}ms`);
15646
15894
  }
15647
15895
  const shell = `<!DOCTYPE html>
15648
- <html lang="${escapeHtmlAttribute2(i18nSnapshot?.locale || "en")}"${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}>
15896
+ <html lang="${escapeHtmlAttribute2(i18nSnapshot?.locale || "en")}"${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}${themeDocument.attributes}>
15649
15897
  <head>
15898
+ ${themeDocument.head}
15650
15899
  <meta charset="utf-8">
15651
15900
  <meta name="viewport" content="width=device-width, initial-scale=1">
15652
15901
  <meta name="farm-deployment-id" content="${escapeHtmlAttribute2(deploymentId)}">
@@ -15723,7 +15972,7 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue(g
15723
15972
  route: observabilityRoute,
15724
15973
  durationMs: Date.now() - streamStartTime
15725
15974
  });
15726
- resolve6();
15975
+ resolve7();
15727
15976
  }
15728
15977
  });
15729
15978
  res.write(shell);
@@ -15848,15 +16097,21 @@ ${getFarmI18nClientSnapshot() ? `window.__FARM_I18N__ = ${serializeInlineValue(g
15848
16097
  const i18nSnapshot = getFarmI18nClientSnapshot();
15849
16098
  const clientScript = isClientComponent ? ` <script type="module" src="/@farm/client.js"></script>` : "";
15850
16099
  const integrationManifestScript = `<script>
15851
- window.__FARM_DEPLOYMENT_ID__ = ${serializeInlineValue(this.getDeploymentId())};
16100
+ window.__FARM_DEPLOYMENT_ID__ = ${serializeInlineValue2(this.getDeploymentId())};
15852
16101
  window.__FARM_INTEGRATION_API_MANIFEST__ = ${JSON.stringify(getRegisteredIntegrationAPIManifest())};
15853
- ${i18nSnapshot ? `window.__FARM_I18N__ = ${serializeInlineValue(i18nSnapshot)};` : ""}
16102
+ ${i18nSnapshot ? `window.__FARM_I18N__ = ${serializeInlineValue2(i18nSnapshot)};` : ""}
15854
16103
  </script>`;
15855
16104
  const alternateLinks = i18nSnapshot ? renderI18nAlternateLinks(requestPath, i18nSnapshot) : "";
15856
16105
  const fontHead = renderFarmFontDevHead(this.config.root || process.cwd());
16106
+ const themeDocument = createFarmThemeDocumentParts(
16107
+ this.config.theme,
16108
+ this.config.basePath,
16109
+ getTheme()
16110
+ );
15857
16111
  return `<!DOCTYPE html>
15858
- <html lang="${escapeHtmlAttribute2(i18nSnapshot?.locale || "en")}"${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}>
16112
+ <html lang="${escapeHtmlAttribute2(i18nSnapshot?.locale || "en")}"${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}${themeDocument.attributes}>
15859
16113
  <head>
16114
+ ${themeDocument.head}
15860
16115
  <meta charset="utf-8">
15861
16116
  <meta name="viewport" content="width=device-width, initial-scale=1">
15862
16117
  <meta name="farm-deployment-id" content="${escapeHtmlAttribute2(this.getDeploymentId())}">
@@ -16218,6 +16473,8 @@ var init_app = __esm({
16218
16473
  init_auth_config();
16219
16474
  init_preload();
16220
16475
  init_security();
16476
+ init_config2();
16477
+ init_server3();
16221
16478
  defaultDocsConfig = {
16222
16479
  enabled: false,
16223
16480
  entry: "/docs",
@@ -16228,6 +16485,7 @@ var init_app = __esm({
16228
16485
  constructor(config = {}, viteServer) {
16229
16486
  this.config = this.normalizeConfig(config);
16230
16487
  configureFarmObservability(this.config.observability);
16488
+ _setDefaultFarmThemeConfig(this.config.theme);
16231
16489
  this.i18nRuntime = createFarmI18nRuntime(this.config.i18n);
16232
16490
  _setDefaultFarmI18nRuntime(this.i18nRuntime);
16233
16491
  this.viteServer = viteServer;
@@ -16286,6 +16544,7 @@ var init_app = __esm({
16286
16544
  security: resolveFarmSecurityConfig(config.security),
16287
16545
  images: resolveFarmImageConfig(config.images),
16288
16546
  performance: resolveFarmPerformanceConfig(config.performance),
16547
+ theme: resolveFarmThemeConfig(config.theme, config.basePath || "/"),
16289
16548
  i18n: isResolvedI18nConfig(config.i18n) ? config.i18n : resolveFarmI18nConfig(config.i18n, {
16290
16549
  root,
16291
16550
  mode: process.env.NODE_ENV === "production" ? "production" : "development"
@@ -16973,15 +17232,15 @@ function isEndpointFailure(value) {
16973
17232
  return value instanceof EndpointFailure;
16974
17233
  }
16975
17234
  function createEndpoint(pathOrOptions, optionsOrHandler, maybeHandler) {
16976
- let path32;
17235
+ let path33;
16977
17236
  let options;
16978
17237
  let handler;
16979
17238
  if (typeof pathOrOptions === "string") {
16980
- path32 = pathOrOptions;
17239
+ path33 = pathOrOptions;
16981
17240
  options = optionsOrHandler;
16982
17241
  handler = maybeHandler;
16983
17242
  } else {
16984
- path32 = "";
17243
+ path33 = "";
16985
17244
  options = pathOrOptions;
16986
17245
  handler = optionsOrHandler;
16987
17246
  }
@@ -17008,13 +17267,13 @@ function createEndpoint(pathOrOptions, optionsOrHandler, maybeHandler) {
17008
17267
  ...betterCallOptions
17009
17268
  } = options;
17010
17269
  const endpoint2 = (0, import_better_call.createEndpoint)(
17011
- path32 || "/__farm_auto_path__",
17270
+ path33 || "/__farm_auto_path__",
17012
17271
  betterCallOptions,
17013
17272
  wrappedHandler
17014
17273
  );
17015
- endpoint2.__path = path32 || void 0;
17274
+ endpoint2.__path = path33 || void 0;
17016
17275
  endpoint2.__method = options.method || "GET";
17017
- endpoint2.__autoPath = !path32;
17276
+ endpoint2.__autoPath = !path33;
17018
17277
  endpoint2.__handler = wrappedHandler;
17019
17278
  endpoint2.__farmInvoke = (ctx) => runEndpointMiddleware(middleware2, ctx, handler, error, options.invalidates);
17020
17279
  endpoint2.__middleware = middleware2;
@@ -18725,11 +18984,11 @@ var init_type_generator = __esm({
18725
18984
  routeGroups.get(key).push(route2);
18726
18985
  }
18727
18986
  const nestedStructure = {};
18728
- for (const [path32, routeList] of routeGroups) {
18987
+ for (const [path33, routeList] of routeGroups) {
18729
18988
  const route2 = routeList[0];
18730
18989
  const importPath = this.getRouteImportPath(route2, options.outFile);
18731
18990
  const routeName = this.pathToRouteName(route2.path);
18732
- const cleanPath = path32 === "/api" ? "" : path32.replace(/^\/api\//, "");
18991
+ const cleanPath = path33 === "/api" ? "" : path33.replace(/^\/api\//, "");
18733
18992
  const parts = cleanPath ? cleanPath.split("/") : [];
18734
18993
  const allMethods = routeList.flatMap((r) => r.methods);
18735
18994
  for (const method of allMethods) {
@@ -18788,8 +19047,8 @@ ${typeExports}
18788
19047
  const relativeImport = (0, import_path7.relative)((0, import_path7.dirname)(outFile), route2.filePath).replace(/\\/g, "/").replace(/\.(ts|tsx|js|jsx)$/, "");
18789
19048
  return relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`;
18790
19049
  }
18791
- pathToRouteName(path32) {
18792
- return (path32 === "/api" ? "root" : path32.replace(/^\/api\//, "")).replace(/\//g, "_").replace(/[^a-zA-Z0-9_]/g, "");
19050
+ pathToRouteName(path33) {
19051
+ return (path33 === "/api" ? "root" : path33.replace(/^\/api\//, "")).replace(/\//g, "_").replace(/[^a-zA-Z0-9_]/g, "");
18793
19052
  }
18794
19053
  structureToTypeString(obj, indent) {
18795
19054
  const spaces = " ".repeat(indent);
@@ -18809,15 +19068,15 @@ ${typeExports}
18809
19068
  toTypePropertyKey(key) {
18810
19069
  return /^[$A-Z_][0-9A-Z_$]*$/i.test(key) ? key : JSON.stringify(key);
18811
19070
  }
18812
- getBaseExportName(path32) {
18813
- const cleanPath = path32.replace(/^\/api\//, "");
19071
+ getBaseExportName(path33) {
19072
+ const cleanPath = path33.replace(/^\/api\//, "");
18814
19073
  if (cleanPath === "") {
18815
19074
  return "api";
18816
19075
  }
18817
19076
  return cleanPath;
18818
19077
  }
18819
- getExportName(path32, method) {
18820
- const cleanPath = path32.replace(/^\/api\//, "");
19078
+ getExportName(path33, method) {
19079
+ const cleanPath = path33.replace(/^\/api\//, "");
18821
19080
  if (cleanPath === "") {
18822
19081
  return method.toLowerCase();
18823
19082
  }
@@ -19853,7 +20112,7 @@ var init_environment_vite = __esm({
19853
20112
  var version;
19854
20113
  var init_package = __esm({
19855
20114
  "package.json"() {
19856
- version = "0.1.0-beta.22";
20115
+ version = "0.1.0-beta.24";
19857
20116
  }
19858
20117
  });
19859
20118
 
@@ -19890,8 +20149,8 @@ function reportAfterError(state, error) {
19890
20149
  function createAfterRequestState(reportError = defaultAfterErrorReporter) {
19891
20150
  let resolveResponseFinished;
19892
20151
  let responseFinished = false;
19893
- const responseFinishedPromise = new Promise((resolve6) => {
19894
- resolveResponseFinished = resolve6;
20152
+ const responseFinishedPromise = new Promise((resolve7) => {
20153
+ resolveResponseFinished = resolve7;
19895
20154
  });
19896
20155
  const state = {
19897
20156
  completion: Promise.resolve(),
@@ -19998,8 +20257,8 @@ function after(callback) {
19998
20257
  throw new Error("after() cannot schedule work after the request lifecycle has completed.");
19999
20258
  }
20000
20259
  let start;
20001
- const ready = new Promise((resolve6) => {
20002
- start = resolve6;
20260
+ const ready = new Promise((resolve7) => {
20261
+ start = resolve7;
20003
20262
  });
20004
20263
  const result = ready.then(callback);
20005
20264
  state.tasks.push({ result, start });
@@ -20065,6 +20324,40 @@ var init_after = __esm({
20065
20324
  }
20066
20325
  });
20067
20326
 
20327
+ // src/dev-static.ts
20328
+ function devServableFileExists(pathname, baseDirs) {
20329
+ let decodedPathname;
20330
+ try {
20331
+ decodedPathname = decodeURIComponent(pathname);
20332
+ } catch {
20333
+ return false;
20334
+ }
20335
+ const relativePathname = decodedPathname.replace(/^\/+/, "");
20336
+ if (!relativePathname) return false;
20337
+ for (const baseDir of baseDirs) {
20338
+ if (typeof baseDir !== "string" || baseDir.length === 0) continue;
20339
+ const resolvedBase = path17.resolve(baseDir);
20340
+ const candidate = path17.resolve(resolvedBase, relativePathname);
20341
+ if (!candidate.startsWith(resolvedBase + path17.sep)) continue;
20342
+ try {
20343
+ if (fs7.existsSync(candidate) && fs7.statSync(candidate).isFile()) {
20344
+ return true;
20345
+ }
20346
+ } catch {
20347
+ }
20348
+ }
20349
+ return false;
20350
+ }
20351
+ var fs7, path17;
20352
+ var init_dev_static = __esm({
20353
+ "src/dev-static.ts"() {
20354
+ "use strict";
20355
+ fs7 = __toESM(require("fs"));
20356
+ path17 = __toESM(require("path"));
20357
+ __name(devServableFileExists, "devServableFileExists");
20358
+ }
20359
+ });
20360
+
20068
20361
  // src/image-vite.ts
20069
20362
  function farmImageImportsPlugin() {
20070
20363
  return {
@@ -20753,6 +21046,36 @@ var init_fonts = __esm({
20753
21046
  }
20754
21047
  });
20755
21048
 
21049
+ // src/theme/vite.ts
21050
+ function createFarmThemeCssPlugin(input, basePath = "/") {
21051
+ const config = resolveFarmThemeConfig(input, basePath);
21052
+ return {
21053
+ name: "farm:theme-css",
21054
+ enforce: "pre",
21055
+ transform(code, id) {
21056
+ if (!config.enabled || !/\.css(?:\?.*)?$/.test(id) || !/@import\s+["']tailwindcss["']/.test(code) || /@custom-variant\s+dark\b/.test(code)) {
21057
+ return null;
21058
+ }
21059
+ return {
21060
+ code: `${code.trimEnd()}
21061
+
21062
+ ${FARM_DARK_VARIANT}
21063
+ `,
21064
+ map: null
21065
+ };
21066
+ }
21067
+ };
21068
+ }
21069
+ var FARM_DARK_VARIANT;
21070
+ var init_vite = __esm({
21071
+ "src/theme/vite.ts"() {
21072
+ "use strict";
21073
+ init_config2();
21074
+ FARM_DARK_VARIANT = '@custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));';
21075
+ __name(createFarmThemeCssPlugin, "createFarmThemeCssPlugin");
21076
+ }
21077
+ });
21078
+
20756
21079
  // src/docs/last-modified.ts
20757
21080
  function normalizeRelativePath(value) {
20758
21081
  return value.replace(/\\/g, "/").replace(/^\.\/+/, "");
@@ -24524,37 +24847,37 @@ function sanitizeDocsConfig(config) {
24524
24847
  return cloneSerializable(config) || {};
24525
24848
  }
24526
24849
  async function findDocsConfigPath(rootDir, configPath) {
24527
- const { existsSync: existsSync17 } = await import("fs");
24850
+ const { existsSync: existsSync18 } = await import("fs");
24528
24851
  const root = import_path9.default.resolve(rootDir || process.cwd());
24529
24852
  if (configPath) {
24530
24853
  const resolvedPath = import_path9.default.isAbsolute(configPath) ? configPath : import_path9.default.join(root, configPath);
24531
- if (!existsSync17(resolvedPath)) {
24854
+ if (!existsSync18(resolvedPath)) {
24532
24855
  throw new Error(`Could not find docs config at ${configPath}.`);
24533
24856
  }
24534
24857
  return import_path9.default.resolve(resolvedPath);
24535
24858
  }
24536
24859
  for (const filename of DOCS_CONFIG_FILENAMES) {
24537
24860
  const resolvedPath = import_path9.default.join(root, filename);
24538
- if (existsSync17(resolvedPath)) {
24861
+ if (existsSync18(resolvedPath)) {
24539
24862
  return resolvedPath;
24540
24863
  }
24541
24864
  }
24542
24865
  return void 0;
24543
24866
  }
24544
24867
  async function loadDocsConfig(rootDir, configPath) {
24545
- const fs9 = await import("fs/promises");
24868
+ const fs10 = await import("fs/promises");
24546
24869
  const { pathToFileURL: pathToFileURL5 } = await import("url");
24547
24870
  const root = import_path9.default.resolve(rootDir || process.cwd());
24548
24871
  const resolvedPath = await findDocsConfigPath(root, configPath);
24549
24872
  if (!resolvedPath) return void 0;
24550
24873
  try {
24551
24874
  if (resolvedPath.endsWith(".json")) {
24552
- const content = await fs9.readFile(resolvedPath, "utf8");
24875
+ const content = await fs10.readFile(resolvedPath, "utf8");
24553
24876
  return { config: JSON.parse(content), configPath: resolvedPath };
24554
24877
  }
24555
24878
  const { build: build2 } = await import("esbuild");
24556
24879
  const configCacheDir = import_path9.default.join(root, ".farm", ".config-loader");
24557
- await fs9.mkdir(configCacheDir, { recursive: true });
24880
+ await fs10.mkdir(configCacheDir, { recursive: true });
24558
24881
  const modulePath = import_path9.default.join(
24559
24882
  configCacheDir,
24560
24883
  `docs-config-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`
@@ -24580,7 +24903,7 @@ async function loadDocsConfig(rootDir, configPath) {
24580
24903
  moduleUrl
24581
24904
  );
24582
24905
  } finally {
24583
- await fs9.unlink(modulePath).catch(() => void 0);
24906
+ await fs10.unlink(modulePath).catch(() => void 0);
24584
24907
  }
24585
24908
  return {
24586
24909
  config: importedConfig.default || importedConfig,
@@ -24730,6 +25053,7 @@ async function resolveConfig(userConfig, mode) {
24730
25053
  routeRules,
24731
25054
  images: resolveFarmImageConfig(userConfig.images),
24732
25055
  performance: resolveFarmPerformanceConfig(userConfig.performance),
25056
+ theme: resolveFarmThemeConfig(userConfig.theme, userConfig.basePath || "/"),
24733
25057
  publicDir: userConfig.publicDir || "public",
24734
25058
  i18n: resolveFarmI18nConfig(userConfig.i18n, { root, mode }),
24735
25059
  openapi: {
@@ -24770,7 +25094,7 @@ async function resolveConfig(userConfig, mode) {
24770
25094
  return resolved;
24771
25095
  }
24772
25096
  async function loadConfig(rootDir, configPath, mode = process.env.NODE_ENV === "production" ? "production" : "development", loadEnvironment) {
24773
- const { existsSync: existsSync17 } = await import("fs");
25097
+ const { existsSync: existsSync18 } = await import("fs");
24774
25098
  const loadEnv = loadEnvironment || (await import("vite")).loadEnv;
24775
25099
  const root = rootDir || process.cwd();
24776
25100
  const loadedEnv = loadEnv(mode, root, "");
@@ -24794,7 +25118,7 @@ async function loadConfig(rootDir, configPath, mode = process.env.NODE_ENV === "
24794
25118
  try {
24795
25119
  const absolutePath = relativePath2.startsWith("/") ? relativePath2 : import_path9.default.join(root, relativePath2);
24796
25120
  const normalizedPath = import_path9.default.resolve(absolutePath);
24797
- if (!existsSync17(normalizedPath)) {
25121
+ if (!existsSync18(normalizedPath)) {
24798
25122
  continue;
24799
25123
  }
24800
25124
  const loadedConfig = await loadFarmConfigFile(normalizedPath, { root });
@@ -24807,7 +25131,7 @@ async function loadConfig(rootDir, configPath, mode = process.env.NODE_ENV === "
24807
25131
  return void 0;
24808
25132
  }
24809
25133
  var import_path9, FARM_RESOLVED_CUSTOM_CONTEXT, DOCS_CONFIG_FILENAMES;
24810
- var init_config2 = __esm({
25134
+ var init_config3 = __esm({
24811
25135
  "src/config.ts"() {
24812
25136
  "use strict";
24813
25137
  init_integrations();
@@ -24828,6 +25152,7 @@ var init_config2 = __esm({
24828
25152
  init_auth_config();
24829
25153
  init_preload();
24830
25154
  init_security();
25155
+ init_config2();
24831
25156
  init_config_entry();
24832
25157
  FARM_RESOLVED_CUSTOM_CONTEXT = /* @__PURE__ */ Symbol.for("farm.resolvedCustomContext");
24833
25158
  __name(hasCustomFarmRouteContext, "hasCustomFarmRouteContext");
@@ -25332,7 +25657,7 @@ var init_api = __esm({
25332
25657
  "src/docs/api.ts"() {
25333
25658
  "use strict";
25334
25659
  import_docs2 = require("@farming-labs/docs");
25335
- init_config2();
25660
+ init_config3();
25336
25661
  init_handler();
25337
25662
  __name(isRecord4, "isRecord");
25338
25663
  __name(isResolvedDocsConfig2, "isResolvedDocsConfig");
@@ -25626,8 +25951,8 @@ var init_generator = __esm({
25626
25951
  }
25627
25952
  routeGroups.get(key).push(route2);
25628
25953
  }
25629
- for (const [path32, routeList] of routeGroups) {
25630
- const openAPIPath = this.convertToOpenAPIPath(path32);
25954
+ for (const [path33, routeList] of routeGroups) {
25955
+ const openAPIPath = this.convertToOpenAPIPath(path33);
25631
25956
  spec.paths[openAPIPath] = {};
25632
25957
  for (const route2 of routeList) {
25633
25958
  for (const method of route2.methods) {
@@ -25641,8 +25966,8 @@ var init_generator = __esm({
25641
25966
  /**
25642
25967
  * Convert Farm.js API path to OpenAPI path format
25643
25968
  */
25644
- convertToOpenAPIPath(path32) {
25645
- return path32.replace(/^\/api/, "");
25969
+ convertToOpenAPIPath(path33) {
25970
+ return path33.replace(/^\/api/, "");
25646
25971
  }
25647
25972
  /**
25648
25973
  * Extract request body schema from endpoint
@@ -25804,8 +26129,8 @@ var init_generator = __esm({
25804
26129
  /**
25805
26130
  * Generate operation summary
25806
26131
  */
25807
- generateSummary(path32, method) {
25808
- const cleanPath = path32.replace(/^\/api\//, "");
26132
+ generateSummary(path33, method) {
26133
+ const cleanPath = path33.replace(/^\/api\//, "");
25809
26134
  const pathParts = cleanPath.split("/");
25810
26135
  const lastPart = pathParts[pathParts.length - 1];
25811
26136
  const action = method === "GET" ? "Get" : method === "POST" ? "Create" : method === "PUT" ? "Update" : method === "DELETE" ? "Delete" : method === "PATCH" ? "Update" : method;
@@ -25814,22 +26139,22 @@ var init_generator = __esm({
25814
26139
  /**
25815
26140
  * Generate operation description
25816
26141
  */
25817
- generateDescription(path32, method) {
25818
- const cleanPath = path32.replace(/^\/api\//, "");
26142
+ generateDescription(path33, method) {
26143
+ const cleanPath = path33.replace(/^\/api\//, "");
25819
26144
  return `${method} ${cleanPath} endpoint`;
25820
26145
  }
25821
26146
  /**
25822
26147
  * Generate operation ID
25823
26148
  */
25824
- generateOperationId(path32, method) {
25825
- const cleanPath = path32.replace(/^\/api\//, "").replace(/\//g, "_");
26149
+ generateOperationId(path33, method) {
26150
+ const cleanPath = path33.replace(/^\/api\//, "").replace(/\//g, "_");
25826
26151
  return `${method.toLowerCase()}_${cleanPath}`;
25827
26152
  }
25828
26153
  /**
25829
26154
  * Generate tags for grouping operations
25830
26155
  */
25831
- generateTags(path32) {
25832
- const cleanPath = path32.replace(/^\/api\//, "");
26156
+ generateTags(path33) {
26157
+ const cleanPath = path33.replace(/^\/api\//, "");
25833
26158
  const pathParts = cleanPath.split("/");
25834
26159
  if (pathParts.length > 1) {
25835
26160
  return [pathParts[0]];
@@ -25841,13 +26166,13 @@ var init_generator = __esm({
25841
26166
  */
25842
26167
  async generateSpecFile(routes, outputPath) {
25843
26168
  const spec = await this.generateSpec(routes);
25844
- const fs9 = require("fs");
25845
- const path32 = require("path");
25846
- const dir = path32.dirname(outputPath);
25847
- if (!fs9.existsSync(dir)) {
25848
- fs9.mkdirSync(dir, { recursive: true });
26169
+ const fs10 = require("fs");
26170
+ const path33 = require("path");
26171
+ const dir = path33.dirname(outputPath);
26172
+ if (!fs10.existsSync(dir)) {
26173
+ fs10.mkdirSync(dir, { recursive: true });
25849
26174
  }
25850
- fs9.writeFileSync(outputPath, JSON.stringify(spec, null, 2));
26175
+ fs10.writeFileSync(outputPath, JSON.stringify(spec, null, 2));
25851
26176
  }
25852
26177
  };
25853
26178
  __name(_OpenAPIGenerator, "OpenAPIGenerator");
@@ -26317,7 +26642,7 @@ var init_devtools = __esm({
26317
26642
  "src/devtools.ts"() {
26318
26643
  "use strict";
26319
26644
  import_node_path14 = __toESM(require("path"));
26320
- init_config2();
26645
+ init_config3();
26321
26646
  init_cron();
26322
26647
  init_route_runtime();
26323
26648
  __name(normalizePath, "normalizePath");
@@ -28135,18 +28460,18 @@ function isPotentialProgrammaticRouteSourceFile(normalizedFile, srcDirSlug) {
28135
28460
  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");
28136
28461
  }
28137
28462
  function fileContainsProgrammaticPageRoute(file) {
28138
- if (!fs7.existsSync(file)) {
28463
+ if (!fs8.existsSync(file)) {
28139
28464
  return false;
28140
28465
  }
28141
28466
  try {
28142
- return scanProgrammaticPagePaths(fs7.readFileSync(file, "utf8")).length > 0;
28467
+ return scanProgrammaticPagePaths(fs8.readFileSync(file, "utf8")).length > 0;
28143
28468
  } catch {
28144
28469
  return false;
28145
28470
  }
28146
28471
  }
28147
28472
  function rewriteEarlySsrRelativeImports(options) {
28148
28473
  const cleanId = options.id.split("?", 1)[0];
28149
- if (!path25.isAbsolute(cleanId) || cleanId.replace(/\\/g, "/").includes("/node_modules/")) {
28474
+ if (!path26.isAbsolute(cleanId) || cleanId.replace(/\\/g, "/").includes("/node_modules/")) {
28150
28475
  return null;
28151
28476
  }
28152
28477
  const replacements = [];
@@ -28166,7 +28491,7 @@ function rewriteEarlySsrRelativeImports(options) {
28166
28491
  const suffixIndex = source.value.search(/[?#]/);
28167
28492
  const sourcePath = suffixIndex === -1 ? source.value : source.value.slice(0, suffixIndex);
28168
28493
  const suffix = suffixIndex === -1 ? "" : source.value.slice(suffixIndex);
28169
- const resolvedPath = path25.resolve(path25.dirname(cleanId), sourcePath);
28494
+ const resolvedPath = path26.resolve(path26.dirname(cleanId), sourcePath);
28170
28495
  replacements.push({
28171
28496
  start: source.start,
28172
28497
  end: source.end,
@@ -28241,7 +28566,7 @@ function farmPlugin(options = {}, initialPluginManager) {
28241
28566
  ...layerRoots.length ? {
28242
28567
  server: {
28243
28568
  fs: {
28244
- allow: [path25.resolve(options.root || process.cwd()), ...layerRoots]
28569
+ allow: [path26.resolve(options.root || process.cwd()), ...layerRoots]
28245
28570
  }
28246
28571
  }
28247
28572
  } : {}
@@ -28272,13 +28597,13 @@ function farmPlugin(options = {}, initialPluginManager) {
28272
28597
  },
28273
28598
  server
28274
28599
  );
28275
- const globalsCSSPath = path25.join(server.config.root, "src/app/globals.css");
28276
- if (!fs7.existsSync(globalsCSSPath)) {
28277
- const appDir = path25.join(server.config.root, "src/app");
28278
- if (!fs7.existsSync(appDir)) {
28279
- fs7.mkdirSync(appDir, { recursive: true });
28600
+ const globalsCSSPath = path26.join(server.config.root, "src/app/globals.css");
28601
+ if (!fs8.existsSync(globalsCSSPath)) {
28602
+ const appDir = path26.join(server.config.root, "src/app");
28603
+ if (!fs8.existsSync(appDir)) {
28604
+ fs8.mkdirSync(appDir, { recursive: true });
28280
28605
  }
28281
- fs7.writeFileSync(globalsCSSPath, defaultGlobalCSS);
28606
+ fs8.writeFileSync(globalsCSSPath, defaultGlobalCSS);
28282
28607
  }
28283
28608
  await farmApp.initialize();
28284
28609
  const farmConfig = farmApp.getConfig();
@@ -28297,10 +28622,10 @@ function farmPlugin(options = {}, initialPluginManager) {
28297
28622
  });
28298
28623
  }
28299
28624
  const sourceRoots = getFarmSourceRoots(farmConfig);
28300
- server.watcher.add(sourceRoots.map((source) => path25.join(source.root, source.srcDir)));
28625
+ server.watcher.add(sourceRoots.map((source) => path26.join(source.root, source.srcDir)));
28301
28626
  if (farmConfig.i18n.enabled) {
28302
28627
  server.watcher.add(
28303
- farmConfig.i18n.messages.includes("{locale}") ? path25.dirname(farmConfig.i18n.messages) : farmConfig.i18n.messages
28628
+ farmConfig.i18n.messages.includes("{locale}") ? path26.dirname(farmConfig.i18n.messages) : farmConfig.i18n.messages
28304
28629
  );
28305
28630
  }
28306
28631
  const workflowConfig = farmConfig.workflows;
@@ -28310,7 +28635,7 @@ function farmPlugin(options = {}, initialPluginManager) {
28310
28635
  ...farmDocsDevRuntime?.getFarmDocsRouteTypeEntries(farmConfig.docs) ?? []
28311
28636
  ], "getExtraRouteTypes");
28312
28637
  const appDirSlugs = sourceRoots.map(
28313
- (source) => path25.join(source.root, source.srcDir, "app").replace(/\\/g, "/")
28638
+ (source) => path26.join(source.root, source.srcDir, "app").replace(/\\/g, "/")
28314
28639
  );
28315
28640
  const generateTypeArtifacts = /* @__PURE__ */ __name(async (reason, selection = ALL_TYPE_ARTIFACTS, log = false) => {
28316
28641
  try {
@@ -28350,7 +28675,7 @@ function farmPlugin(options = {}, initialPluginManager) {
28350
28675
  }, "generateTypeArtifacts");
28351
28676
  await generateTypeArtifacts("startup");
28352
28677
  const srcDirSlugs = sourceRoots.map(
28353
- (source) => path25.join(source.root, source.srcDir).replace(/\\/g, "/")
28678
+ (source) => path26.join(source.root, source.srcDir).replace(/\\/g, "/")
28354
28679
  );
28355
28680
  const layerConfigFiles = new Set(
28356
28681
  farmConfig.layers.map((layer) => layer.configFile?.replace(/\\/g, "/")).filter((file) => Boolean(file))
@@ -28468,7 +28793,7 @@ function farmPlugin(options = {}, initialPluginManager) {
28468
28793
  await apiRouteManager.discoverRoutes();
28469
28794
  let discoveredWorkflows = [];
28470
28795
  const hasWorkflowDirectory = workflowConfig.enabled && workflowConfig.dirs.some(
28471
- (dir) => fs7.existsSync(path25.isAbsolute(dir) ? dir : path25.join(farmConfig.root, dir))
28796
+ (dir) => fs8.existsSync(path26.isAbsolute(dir) ? dir : path26.join(farmConfig.root, dir))
28472
28797
  );
28473
28798
  if (hasWorkflowDirectory) {
28474
28799
  const { createFarmWorkflowRequestHandler: createFarmWorkflowRequestHandler2, discoverFarmWorkflows: discoverFarmWorkflows2 } = await loadFarmWorkflowsDevRuntime();
@@ -28702,12 +29027,12 @@ window.__FARM_MANIFEST__ = ${inlineValue({
28702
29027
  }
28703
29028
  }
28704
29029
  const farmDocsFontPath = farmDocsFontAssets.get(requestPathname);
28705
- if ((requestMethod === "GET" || requestMethod === "HEAD") && farmDocsFontPath && fs7.existsSync(farmDocsFontPath)) {
29030
+ if ((requestMethod === "GET" || requestMethod === "HEAD") && farmDocsFontPath && fs8.existsSync(farmDocsFontPath)) {
28706
29031
  res.statusCode = 200;
28707
29032
  res.setHeader("Content-Type", "font/woff2");
28708
29033
  res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
28709
29034
  if (requestMethod === "HEAD") res.end();
28710
- else fs7.createReadStream(farmDocsFontPath).pipe(res);
29035
+ else fs8.createReadStream(farmDocsFontPath).pipe(res);
28711
29036
  return;
28712
29037
  }
28713
29038
  if (requestMethod === "GET" && (requestPathname === FARM_DEVTOOLS_PATH || requestPathname === `${FARM_DEVTOOLS_PATH}.json`)) {
@@ -28805,7 +29130,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
28805
29130
  return null;
28806
29131
  }
28807
29132
  return {
28808
- source: await fs7.promises.readFile(sourcePath, "utf8"),
29133
+ source: await fs8.promises.readFile(sourcePath, "utf8"),
28809
29134
  filePath: sourcePath
28810
29135
  };
28811
29136
  }, "resolveSource")
@@ -29140,9 +29465,17 @@ window.__FARM_MANIFEST__ = ${inlineValue({
29140
29465
  res.end(JSON.stringify({ error: "API route not found", pathname: pathname2 }));
29141
29466
  return;
29142
29467
  }
29143
- if (req.url?.startsWith("/@") || req.url?.startsWith("/node_modules") || requestPathname.includes(".") && !requestPathname.endsWith(".html")) {
29468
+ if (req.url?.startsWith("/@") || req.url?.startsWith("/node_modules")) {
29144
29469
  return next();
29145
29470
  }
29471
+ if (requestPathname.includes(".") && !requestPathname.endsWith(".html")) {
29472
+ const matchesAppRoute = Boolean(
29473
+ farmApp?.getRouteManager()?.matchRoute(requestPathname)?.route
29474
+ );
29475
+ if (!matchesAppRoute || devServableFileExists(requestPathname, [server.config.publicDir, server.config.root])) {
29476
+ return next();
29477
+ }
29478
+ }
29146
29479
  if (req.url?.startsWith("/__farm/page-data")) {
29147
29480
  const urlObj = new URL(req.url, `http://${req.headers.host || "localhost:3000"}`);
29148
29481
  const targetPath = urlObj.searchParams.get("path") || "/";
@@ -29848,8 +30181,8 @@ if (import.meta.hot) {
29848
30181
  }
29849
30182
  logger.info(`Found ${ssgPages.length} SSG pages, ${ssrRoutes.length} SSR routes`);
29850
30183
  logger.info("Pre-rendering SSG pages...");
29851
- const outDir = path25.join(server?.config.root || process.cwd(), options.outDir || "dist");
29852
- const clientDir = path25.join(outDir, "client");
30184
+ const outDir = path26.join(server?.config.root || process.cwd(), options.outDir || "dist");
30185
+ const clientDir = path26.join(outDir, "client");
29853
30186
  for (const page2 of ssgPages) {
29854
30187
  try {
29855
30188
  const staticRequest = new Request(new URL(page2.urlPath, "http://farm.static"));
@@ -29901,9 +30234,9 @@ if (import.meta.hot) {
29901
30234
  <script type="module" src="/assets/client.js"></script>
29902
30235
  </body>
29903
30236
  </html>`;
29904
- const outputPath = page2.urlPath === "/" ? path25.join(clientDir, "index.html") : path25.join(clientDir, page2.urlPath + ".html");
29905
- fs7.mkdirSync(path25.dirname(outputPath), { recursive: true });
29906
- fs7.writeFileSync(outputPath, fullHtml);
30237
+ const outputPath = page2.urlPath === "/" ? path26.join(clientDir, "index.html") : path26.join(clientDir, page2.urlPath + ".html");
30238
+ fs8.mkdirSync(path26.dirname(outputPath), { recursive: true });
30239
+ fs8.writeFileSync(outputPath, fullHtml);
29907
30240
  const revalidateInfo = page2.revalidate ? ` (revalidate: ${page2.revalidate}s)` : "";
29908
30241
  logger.success(` \u2713 ${page2.urlPath}${revalidateInfo}`);
29909
30242
  });
@@ -29911,8 +30244,8 @@ if (import.meta.hot) {
29911
30244
  logger.error(` \u2717 ${page2.urlPath}: ${error}`);
29912
30245
  }
29913
30246
  }
29914
- const manifestPath = path25.join(outDir, "__ssg_manifest.json");
29915
- fs7.writeFileSync(
30247
+ const manifestPath = path26.join(outDir, "__ssg_manifest.json");
30248
+ fs8.writeFileSync(
29916
30249
  manifestPath,
29917
30250
  JSON.stringify(
29918
30251
  ssgPages.map((p) => ({
@@ -29947,9 +30280,9 @@ if (import.meta.hot) {
29947
30280
  }
29948
30281
  const currentFarmConfig = farmApp?.getConfig();
29949
30282
  const normalizedFile = file.replace(/\\/g, "/");
29950
- const currentSrcRoot = currentFarmConfig ? getFarmSourceRoots(currentFarmConfig).map((source) => path25.join(source.root, source.srcDir).replace(/\\/g, "/")).find((sourceRoot) => normalizedFile.startsWith(`${sourceRoot}/`)) || null : null;
30283
+ const currentSrcRoot = currentFarmConfig ? getFarmSourceRoots(currentFarmConfig).map((source) => path26.join(source.root, source.srcDir).replace(/\\/g, "/")).find((sourceRoot) => normalizedFile.startsWith(`${sourceRoot}/`)) || null : null;
29951
30284
  if (currentSrcRoot && normalizedFile.startsWith(`${currentSrcRoot}/`) && isProgrammaticRoutesFileName(normalizedFile)) {
29952
- logUpdate("PAGE", `updated ${path25.basename(file)}`);
30285
+ logUpdate("PAGE", `updated ${path26.basename(file)}`);
29953
30286
  for (const mod of modules) {
29954
30287
  server2.moduleGraph.invalidateModule(mod);
29955
30288
  }
@@ -31129,6 +31462,19 @@ async function tryHydrateImportedPage(
31129
31462
  const PageComponent = pageModule?.default;
31130
31463
  if (!PageComponent) return false;
31131
31464
 
31465
+ if (
31466
+ typeof PageComponent === 'function' &&
31467
+ PageComponent.constructor &&
31468
+ PageComponent.constructor.name === 'AsyncFunction'
31469
+ ) {
31470
+ console.warn(
31471
+ '[Farm.js] Skipping hydration for ' + modulePath +
31472
+ ': async server components cannot run in the browser. ' +
31473
+ 'Server-rendered HTML is preserved; move interactive UI into a "use client" child of a synchronous page.'
31474
+ );
31475
+ return false;
31476
+ }
31477
+
31132
31478
  currentPageComponent = PageComponent;
31133
31479
  currentPageProps = await buildRouteComponentProps(
31134
31480
  pageModule,
@@ -31295,14 +31641,22 @@ async function renderPage(pageData) {
31295
31641
  if (!doc.documentElement || !doc.body) return false;
31296
31642
 
31297
31643
  resetReactRoots();
31644
+ const activeFarmTheme =
31645
+ window.__FARM_THEME__?.snapshot?.resolvedTheme ||
31646
+ document.documentElement.getAttribute('data-theme');
31298
31647
  Array.from(document.documentElement.attributes).forEach(function(attr) {
31648
+ if (attr.name === 'data-theme') return;
31299
31649
  if (!doc.documentElement.hasAttribute(attr.name)) {
31300
31650
  document.documentElement.removeAttribute(attr.name);
31301
31651
  }
31302
31652
  });
31303
31653
  Array.from(doc.documentElement.attributes).forEach(function(attr) {
31654
+ if (attr.name === 'data-theme') return;
31304
31655
  document.documentElement.setAttribute(attr.name, attr.value);
31305
31656
  });
31657
+ if (activeFarmTheme) {
31658
+ document.documentElement.setAttribute('data-theme', activeFarmTheme);
31659
+ }
31306
31660
 
31307
31661
  document.head.innerHTML = doc.head ? doc.head.innerHTML : '';
31308
31662
  document.body.innerHTML = doc.body.innerHTML;
@@ -31311,6 +31665,7 @@ async function renderPage(pageData) {
31311
31665
 
31312
31666
  setTimeout(function() {
31313
31667
  Array.from(document.querySelectorAll('script')).forEach(function(script) {
31668
+ if (script.id === 'farm-theme-script') return;
31314
31669
  const freshScript = document.createElement('script');
31315
31670
  Array.from(script.attributes).forEach(function(attr) {
31316
31671
  freshScript.setAttribute(attr.name, attr.value);
@@ -31670,7 +32025,7 @@ function generateClientManifest(bundle) {
31670
32025
  }
31671
32026
  async function defineConfig2(config = {}) {
31672
32027
  const tailwindcss = (await import("@tailwindcss/vite")).default;
31673
- const appRoot = path25.resolve(config.root || process.cwd());
32028
+ const appRoot = path26.resolve(config.root || process.cwd());
31674
32029
  if (config.extends?.length) {
31675
32030
  const { config: layeredConfig } = await Promise.resolve().then(() => (init_layers(), layers_exports)).then(
31676
32031
  ({ resolveFarmLayers: resolveFarmLayers2 }) => resolveFarmLayers2(config, {
@@ -31805,6 +32160,7 @@ async function defineConfig2(config = {}) {
31805
32160
  };
31806
32161
  return {
31807
32162
  plugins: [
32163
+ createFarmThemeCssPlugin(config.theme, config.basePath),
31808
32164
  tailwindcss(),
31809
32165
  viteBrowserExternalPlugin,
31810
32166
  farmI18nClientBridgePlugin(),
@@ -31876,8 +32232,8 @@ async function defineConfig2(config = {}) {
31876
32232
  }
31877
32233
  };
31878
32234
  }
31879
- var fs7, path25, ALL_TYPE_ARTIFACTS, createEmptyTypeArtifactSelection, FARM_I18N_CLIENT_BRIDGE_ID, EMPTY_FARM_DOCS_SEARCH_CLIENT_RUNTIME, FARM_CONFIG_FILENAMES;
31880
- var init_vite = __esm({
32235
+ var fs8, path26, ALL_TYPE_ARTIFACTS, createEmptyTypeArtifactSelection, FARM_I18N_CLIENT_BRIDGE_ID, EMPTY_FARM_DOCS_SEARCH_CLIENT_RUNTIME, FARM_CONFIG_FILENAMES;
32236
+ var init_vite2 = __esm({
31881
32237
  "src/vite.ts"() {
31882
32238
  "use strict";
31883
32239
  init_app();
@@ -31895,13 +32251,14 @@ var init_vite = __esm({
31895
32251
  init_integrations();
31896
32252
  init_route_context();
31897
32253
  init_devtools_config();
31898
- fs7 = __toESM(require("fs"));
31899
- path25 = __toESM(require("path"));
32254
+ fs8 = __toESM(require("fs"));
32255
+ path26 = __toESM(require("path"));
31900
32256
  init_layers();
31901
32257
  init_environment_vite();
31902
32258
  init_version();
31903
32259
  init_deferred();
31904
32260
  init_after();
32261
+ init_dev_static();
31905
32262
  init_deployment();
31906
32263
  init_image_config();
31907
32264
  init_image_vite();
@@ -31914,6 +32271,7 @@ var init_vite = __esm({
31914
32271
  init_fonts();
31915
32272
  init_server_http();
31916
32273
  init_cli_colors();
32274
+ init_vite();
31917
32275
  ALL_TYPE_ARTIFACTS = {
31918
32276
  routes: true,
31919
32277
  api: true,
@@ -32013,7 +32371,7 @@ var init_plugin = __esm({
32013
32371
  init_env();
32014
32372
  init_request_context();
32015
32373
  init_plugin_integration_context();
32016
- init_vite();
32374
+ init_vite2();
32017
32375
  _FarmRuntimeShutdownError = class _FarmRuntimeShutdownError extends Error {
32018
32376
  constructor(message, errors) {
32019
32377
  super(message);
@@ -33577,6 +33935,7 @@ __export(src_exports, {
33577
33935
  getServerActionInvalidations: () => getServerActionInvalidations,
33578
33936
  getServerActionSignal: () => getServerActionSignal,
33579
33937
  getStorage: () => getStorage,
33938
+ getTheme: () => getTheme2,
33580
33939
  globFiles: () => globFiles,
33581
33940
  hasFarmRouteRuntimeControls: () => hasFarmRouteRuntimeControls,
33582
33941
  hasISR: () => hasISR,
@@ -33693,6 +34052,7 @@ __export(src_exports, {
33693
34052
  resolveFarmLayoutFonts: () => resolveFarmLayoutFonts,
33694
34053
  resolveFarmRouteRuleRuntimeConfig: () => resolveFarmRouteRuleRuntimeConfig,
33695
34054
  resolveFarmRouteRuntimeConfig: () => resolveFarmRouteRuntimeConfig,
34055
+ resolveFarmThemeConfig: () => resolveFarmThemeConfig,
33696
34056
  resolveIntegrationOrmRuntimeClient: () => resolveIntegrationOrmRuntimeClient,
33697
34057
  resolveIntegrationPlugins: () => resolveIntegrationPlugins,
33698
34058
  resolveMarkdownConfig: () => resolveMarkdownConfig,
@@ -33719,12 +34079,14 @@ __export(src_exports, {
33719
34079
  segmentsToPattern: () => segmentsToPattern,
33720
34080
  serverEnv: () => serverEnv,
33721
34081
  setEnv: () => setEnv,
34082
+ setTheme: () => setTheme,
33722
34083
  snapshotDeferredData: () => snapshotDeferredData,
33723
34084
  sqliteStorage: () => sqliteStorage,
33724
34085
  storageCacheAdapter: () => storageCacheAdapter,
33725
34086
  titleFromMarkdown: () => titleFromMarkdown,
33726
34087
  toFormData: () => toFormData,
33727
34088
  toViteModuleId: () => toViteModuleId,
34089
+ toggleTheme: () => toggleTheme,
33728
34090
  unstable_cache: () => unstable_cache,
33729
34091
  unwrapMiddleware: () => unwrapMiddleware,
33730
34092
  updateTag: () => updateTag,
@@ -33740,6 +34102,7 @@ __export(src_exports, {
33740
34102
  useSearchParams: () => useSearchParams,
33741
34103
  useServerFn: () => useServerFn,
33742
34104
  useServerQuery: () => useServerQuery,
34105
+ useTheme: () => useTheme,
33743
34106
  validateServerActionRequest: () => validateServerActionRequest,
33744
34107
  vercelBlobStorage: () => vercelBlobStorage,
33745
34108
  vercelKVStorage: () => vercelKVStorage,
@@ -33769,7 +34132,7 @@ __name(FarmProvider, "FarmProvider");
33769
34132
  // src/index.ts
33770
34133
  init_request();
33771
34134
  init_plugin();
33772
- init_config2();
34135
+ init_config3();
33773
34136
  init_layers();
33774
34137
 
33775
34138
  // src/hmr.ts
@@ -35020,8 +35383,8 @@ function createAPIClient(options = {}) {
35020
35383
  const inflightState = /* @__PURE__ */ new Map();
35021
35384
  const routeMeta = /* @__PURE__ */ new WeakMap();
35022
35385
  let requestCounter = 0;
35023
- const fetchClient = /* @__PURE__ */ __name(async (path32, requestOptions = {}) => {
35024
- const url = new URL(path32, baseURL);
35386
+ const fetchClient = /* @__PURE__ */ __name(async (path33, requestOptions = {}) => {
35387
+ const url = new URL(path33, baseURL);
35025
35388
  if (requestOptions.query) {
35026
35389
  Object.entries(requestOptions.query).forEach(([key, value]) => {
35027
35390
  if (value !== void 0 && value !== null) {
@@ -35056,7 +35419,7 @@ function createAPIClient(options = {}) {
35056
35419
  }
35057
35420
  return { response, data };
35058
35421
  }, "fetchClient");
35059
- const request = /* @__PURE__ */ __name(async (path32, method, input = {}, clientOptions) => {
35422
+ const request = /* @__PURE__ */ __name(async (path33, method, input = {}, clientOptions) => {
35060
35423
  const methodUpper = method.toUpperCase();
35061
35424
  const requestId = `${Date.now()}-${++requestCounter}`;
35062
35425
  const cacheOptions = clientOptions?.cache ? {
@@ -35065,7 +35428,7 @@ function createAPIClient(options = {}) {
35065
35428
  } : void 0;
35066
35429
  const configuredCacheKey = clientOptions?.key ?? cacheOptions?.key;
35067
35430
  const cacheKey = normalizeFarmClientCacheKey(
35068
- configuredCacheKey ?? buildCacheKey(methodUpper, path32, input, baseURL)
35431
+ configuredCacheKey ?? buildCacheKey(methodUpper, path33, input, baseURL)
35069
35432
  );
35070
35433
  const now2 = Date.now();
35071
35434
  const emitStatus = /* @__PURE__ */ __name((phase, payload) => {
@@ -35147,13 +35510,13 @@ function createAPIClient(options = {}) {
35147
35510
  requestId,
35148
35511
  method: methodUpper,
35149
35512
  key: cacheKey,
35150
- path: path32,
35513
+ path: path33,
35151
35514
  input,
35152
35515
  attempt,
35153
35516
  timestamp: Date.now()
35154
35517
  });
35155
35518
  try {
35156
- const { response, data } = await fetchClient(path32, {
35519
+ const { response, data } = await fetchClient(path33, {
35157
35520
  ...input,
35158
35521
  method: methodUpper
35159
35522
  });
@@ -35162,7 +35525,7 @@ function createAPIClient(options = {}) {
35162
35525
  requestId,
35163
35526
  method: methodUpper,
35164
35527
  key: cacheKey,
35165
- path: path32,
35528
+ path: path33,
35166
35529
  input,
35167
35530
  attempt,
35168
35531
  timestamp: Date.now(),
@@ -35185,7 +35548,7 @@ function createAPIClient(options = {}) {
35185
35548
  requestId,
35186
35549
  method: methodUpper,
35187
35550
  key: cacheKey,
35188
- path: path32,
35551
+ path: path33,
35189
35552
  input,
35190
35553
  attempt,
35191
35554
  timestamp: Date.now(),
@@ -35200,7 +35563,7 @@ function createAPIClient(options = {}) {
35200
35563
  attempt += 1;
35201
35564
  const delay2 = typeof clientOptions?.retry?.delay === "function" ? clientOptions.retry.delay(attempt) : clientOptions?.retry?.delay ?? 0;
35202
35565
  if (delay2 > 0) {
35203
- await new Promise((resolve6) => setTimeout(resolve6, delay2));
35566
+ await new Promise((resolve7) => setTimeout(resolve7, delay2));
35204
35567
  }
35205
35568
  }
35206
35569
  })();
@@ -35290,17 +35653,17 @@ function createAPIClient(options = {}) {
35290
35653
  );
35291
35654
  }
35292
35655
  __name(createAPIClient, "createAPIClient");
35293
- function createNestedProxy(path32, client, routeMeta, baseURL, sameOrigin, rootAliases) {
35656
+ function createNestedProxy(path33, client, routeMeta, baseURL, sameOrigin, rootAliases) {
35294
35657
  const target = /* @__PURE__ */ __name(() => {
35295
35658
  }, "target");
35296
35659
  const proxy = new Proxy(target, {
35297
35660
  // When accessing a property (api.hello)
35298
35661
  get(_target, prop) {
35299
35662
  if (prop === FARM_API_ROUTE_REF_SYMBOL) {
35300
- return path32.length > 0;
35663
+ return path33.length > 0;
35301
35664
  }
35302
35665
  if (prop === FARM_API_ROUTE_META_SYMBOL) {
35303
- const metadata = resolveRouteMeta({ path: path32, baseURL });
35666
+ const metadata = resolveRouteMeta({ path: path33, baseURL });
35304
35667
  return Object.freeze({
35305
35668
  path: metadata.routePath,
35306
35669
  method: metadata.method,
@@ -35308,14 +35671,14 @@ function createNestedProxy(path32, client, routeMeta, baseURL, sameOrigin, rootA
35308
35671
  sameOrigin
35309
35672
  });
35310
35673
  }
35311
- if (path32.length === 0 && typeof prop === "string" && rootAliases && prop in rootAliases) {
35674
+ if (path33.length === 0 && typeof prop === "string" && rootAliases && prop in rootAliases) {
35312
35675
  return rootAliases[prop];
35313
35676
  }
35314
35677
  if (typeof prop !== "string") {
35315
35678
  return Reflect.get(_target, prop);
35316
35679
  }
35317
35680
  return createNestedProxy(
35318
- [...path32, prop],
35681
+ [...path33, prop],
35319
35682
  client,
35320
35683
  routeMeta,
35321
35684
  baseURL,
@@ -35325,21 +35688,21 @@ function createNestedProxy(path32, client, routeMeta, baseURL, sameOrigin, rootA
35325
35688
  },
35326
35689
  // When calling as a function
35327
35690
  apply(_target, _thisArg, args) {
35328
- const lastPart = path32[path32.length - 1];
35691
+ const lastPart = path33[path33.length - 1];
35329
35692
  const httpMethods = ["get", "post", "put", "delete", "patch", "options", "head"];
35330
35693
  if (httpMethods.includes(lastPart)) {
35331
- const routePath = "/api/" + path32.slice(0, -1).join("/");
35694
+ const routePath = "/api/" + path33.slice(0, -1).join("/");
35332
35695
  const method = lastPart.toUpperCase();
35333
35696
  const [options, clientOptions] = args;
35334
35697
  return client(routePath, method, options, clientOptions);
35335
35698
  } else {
35336
- const routePath = "/api/" + path32.join("/");
35699
+ const routePath = "/api/" + path33.join("/");
35337
35700
  const [options, clientOptions] = args;
35338
35701
  return client(routePath, options?.method || "GET", options, clientOptions);
35339
35702
  }
35340
35703
  }
35341
35704
  });
35342
- routeMeta.set(proxy, { path: [...path32], baseURL });
35705
+ routeMeta.set(proxy, { path: [...path33], baseURL });
35343
35706
  return proxy;
35344
35707
  }
35345
35708
  __name(createNestedProxy, "createNestedProxy");
@@ -35379,9 +35742,9 @@ function createServerAPIClient(endpoints, options = {}) {
35379
35742
  return endpoints;
35380
35743
  }
35381
35744
  __name(createServerAPIClient, "createServerAPIClient");
35382
- function buildCacheKey(method, path32, input, baseURL) {
35745
+ function buildCacheKey(method, path33, input, baseURL) {
35383
35746
  const keyInput = input && typeof input === "object" ? { query: input.query, body: input.body } : input;
35384
- const url = new URL(path32, baseURL);
35747
+ const url = new URL(path33, baseURL);
35385
35748
  return `${method}:${url.origin}${url.pathname}:${stableStringify(keyInput ?? {})}`;
35386
35749
  }
35387
35750
  __name(buildCacheKey, "buildCacheKey");
@@ -35610,18 +35973,18 @@ function farmApiPlugin(options = {}) {
35610
35973
  enforce: "pre",
35611
35974
  configureServer(server) {
35612
35975
  const discoverFileRoutes = /* @__PURE__ */ __name(async (apiDir) => {
35613
- const fs9 = await import("fs");
35614
- const path32 = await import("path");
35615
- if (!fs9.existsSync(apiDir)) {
35976
+ const fs10 = await import("fs");
35977
+ const path33 = await import("path");
35978
+ if (!fs10.existsSync(apiDir)) {
35616
35979
  log("No api directory found");
35617
35980
  return;
35618
35981
  }
35619
35982
  const findRouteFiles = /* @__PURE__ */ __name((dir) => {
35620
35983
  const files = [];
35621
- if (!fs9.existsSync(dir)) return files;
35622
- const entries = fs9.readdirSync(dir, { withFileTypes: true });
35984
+ if (!fs10.existsSync(dir)) return files;
35985
+ const entries = fs10.readdirSync(dir, { withFileTypes: true });
35623
35986
  for (const entry of entries) {
35624
- const fullPath = path32.join(dir, entry.name);
35987
+ const fullPath = path33.join(dir, entry.name);
35625
35988
  if (entry.isDirectory()) {
35626
35989
  files.push(...findRouteFiles(fullPath));
35627
35990
  } else if (entry.name === "route.ts" || entry.name === "route.tsx" || entry.name === "route.js") {
@@ -35634,7 +35997,7 @@ function farmApiPlugin(options = {}) {
35634
35997
  apiRoutesCache.clear();
35635
35998
  for (const filePath of routeFiles) {
35636
35999
  try {
35637
- const relativePath2 = path32.relative(apiDir, path32.dirname(filePath));
36000
+ const relativePath2 = path33.relative(apiDir, path33.dirname(filePath));
35638
36001
  const routePath = "/api/" + (relativePath2 === "." ? "" : relativePath2.replace(/\\/g, "/"));
35639
36002
  const routeModule = await server.ssrLoadModule(filePath);
35640
36003
  const endpoints = {};
@@ -35660,15 +36023,15 @@ function farmApiPlugin(options = {}) {
35660
36023
  }
35661
36024
  }, "discoverFileRoutes");
35662
36025
  const discoverRootRoutes = /* @__PURE__ */ __name(async () => {
35663
- const fs9 = await import("fs");
35664
- const path32 = await import("path");
36026
+ const fs10 = await import("fs");
36027
+ const path33 = await import("path");
35665
36028
  const routesFiles = [
35666
- path32.join(server.config.root, srcDir, "routes.ts"),
35667
- path32.join(server.config.root, srcDir, "routes.tsx"),
35668
- path32.join(server.config.root, srcDir, "routes.js")
36029
+ path33.join(server.config.root, srcDir, "routes.ts"),
36030
+ path33.join(server.config.root, srcDir, "routes.tsx"),
36031
+ path33.join(server.config.root, srcDir, "routes.js")
35669
36032
  ];
35670
36033
  for (const routesFile of routesFiles) {
35671
- if (fs9.existsSync(routesFile)) {
36034
+ if (fs10.existsSync(routesFile)) {
35672
36035
  try {
35673
36036
  const routesModule = await server.ssrLoadModule(routesFile);
35674
36037
  for (const [exportName, exportValue] of Object.entries(routesModule)) {
@@ -35688,8 +36051,8 @@ function farmApiPlugin(options = {}) {
35688
36051
  }
35689
36052
  }, "discoverRootRoutes");
35690
36053
  const discoverProgrammaticRoutes = /* @__PURE__ */ __name(async () => {
35691
- const path32 = await import("path");
35692
- const srcRoot = path32.join(server.config.root, srcDir);
36054
+ const path33 = await import("path");
36055
+ const srcRoot = path33.join(server.config.root, srcDir);
35693
36056
  const routeFiles = findProgrammaticRouteFilesInDir(srcRoot);
35694
36057
  for (const routeFile of routeFiles) {
35695
36058
  try {
@@ -35713,8 +36076,8 @@ function farmApiPlugin(options = {}) {
35713
36076
  }
35714
36077
  }, "discoverProgrammaticRoutes");
35715
36078
  const initializeDiscovery = /* @__PURE__ */ __name(async () => {
35716
- const path32 = await import("path");
35717
- const apiDir = path32.join(server.config.root, srcDir, "api");
36079
+ const path33 = await import("path");
36080
+ const apiDir = path33.join(server.config.root, srcDir, "api");
35718
36081
  log(`Discovering API routes in: ${apiDir}`);
35719
36082
  await discoverFileRoutes(apiDir);
35720
36083
  await discoverRootRoutes();
@@ -35882,9 +36245,9 @@ function farmApiPlugin(options = {}) {
35882
36245
  }
35883
36246
  } else {
35884
36247
  try {
35885
- const path32 = await import("path");
35886
- const apiDir = path32.join(server.config.root, srcDir, "api");
35887
- const relativePath2 = path32.relative(apiDir, path32.dirname(file));
36248
+ const path33 = await import("path");
36249
+ const apiDir = path33.join(server.config.root, srcDir, "api");
36250
+ const relativePath2 = path33.relative(apiDir, path33.dirname(file));
35888
36251
  const routePath = "/api/" + (relativePath2 === "." ? "" : relativePath2.replace(/\\/g, "/"));
35889
36252
  const routeModule = await server.ssrLoadModule(file);
35890
36253
  const endpoints = {};
@@ -36325,8 +36688,8 @@ var _MiddlewareChainImpl = class _MiddlewareChainImpl {
36325
36688
  /**
36326
36689
  * Set the base path for this middleware chain (called by manager when loading)
36327
36690
  */
36328
- setBasePath(path32) {
36329
- this.basePath = path32 === "/" ? "/" : path32.endsWith("/") ? path32.slice(0, -1) : path32;
36691
+ setBasePath(path33) {
36692
+ this.basePath = path33 === "/" ? "/" : path33.endsWith("/") ? path33.slice(0, -1) : path33;
36330
36693
  }
36331
36694
  use(fn) {
36332
36695
  this.handlers.push(fn);
@@ -37292,6 +37655,9 @@ init_cron();
37292
37655
  init_env();
37293
37656
  init_env_types();
37294
37657
 
37658
+ // src/theme/index.ts
37659
+ init_config2();
37660
+
37295
37661
  // src/environment.ts
37296
37662
  var _FarmEnvironmentError = class _FarmEnvironmentError extends Error {
37297
37663
  constructor(api3, expected, actual) {
@@ -38000,12 +38366,12 @@ function useServerQuery(query, input, options = {}) {
38000
38366
  const mountedKeyRef = (0, import_react9.useRef)(void 0);
38001
38367
  inputRef.current = input;
38002
38368
  optionsRef.current = options;
38003
- const subscribe = (0, import_react9.useCallback)(
38369
+ const subscribe2 = (0, import_react9.useCallback)(
38004
38370
  (listener) => cache.subscribe(key, listener),
38005
38371
  [cache, key]
38006
38372
  );
38007
38373
  const getSnapshot = (0, import_react9.useCallback)(() => cache.get(key), [cache, key]);
38008
- const entry = (0, import_react9.useSyncExternalStore)(subscribe, getSnapshot, () => void 0);
38374
+ const entry = (0, import_react9.useSyncExternalStore)(subscribe2, getSnapshot, () => void 0);
38009
38375
  const run = (0, import_react9.useCallback)(
38010
38376
  (force = false) => fetchServerQuery(query, inputRef.current, {
38011
38377
  ...optionsRef.current,
@@ -38131,7 +38497,7 @@ init_deployment();
38131
38497
  init_generate_route_types();
38132
38498
 
38133
38499
  // src/build/index.ts
38134
- init_config2();
38500
+ init_config3();
38135
38501
  var import_path14 = __toESM(require("path"));
38136
38502
  init_utils();
38137
38503
  init_app();
@@ -38139,7 +38505,7 @@ init_route_manager2();
38139
38505
  init_layers();
38140
38506
 
38141
38507
  // src/nitro/universal-build.ts
38142
- init_config2();
38508
+ init_config3();
38143
38509
  init_client_plugin_build();
38144
38510
  var import_os = __toESM(require("os"));
38145
38511
  var import_path12 = __toESM(require("path"));
@@ -38213,10 +38579,10 @@ async function createFarmRouteRuntimeManifest(options) {
38213
38579
  }
38214
38580
  __name(createFarmRouteRuntimeManifest, "createFarmRouteRuntimeManifest");
38215
38581
  async function writeFarmRouteRuntimeManifest(directory, manifest) {
38216
- const fs9 = await import("fs/promises");
38582
+ const fs10 = await import("fs/promises");
38217
38583
  const manifestPath = import_path10.default.join(directory, FARM_ROUTE_RUNTIME_MANIFEST);
38218
- await fs9.mkdir(directory, { recursive: true });
38219
- await fs9.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
38584
+ await fs10.mkdir(directory, { recursive: true });
38585
+ await fs10.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
38220
38586
  `);
38221
38587
  return manifestPath;
38222
38588
  }
@@ -38262,7 +38628,7 @@ __name(normalizeManifestSource, "normalizeManifestSource");
38262
38628
  // src/nitro/vercel-route-runtime.ts
38263
38629
  var import_path11 = __toESM(require("path"));
38264
38630
  init_route_runtime();
38265
- async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs9) {
38631
+ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs10) {
38266
38632
  const dynamicRoutes = manifest.routes.filter(
38267
38633
  (route2) => route2.rendering === "dynamic" && route2.runtime !== "edge"
38268
38634
  );
@@ -38293,8 +38659,8 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs9) {
38293
38659
  groupIndex += 1;
38294
38660
  const functionName = `__farm_runtime_${groupIndex}`;
38295
38661
  const functionDir = import_path11.default.join(functionsDir, `${functionName}.func`);
38296
- await fs9.cp(baseFunctionDir, functionDir, { recursive: true, force: true });
38297
- await configureVercelFunction(functionDir, group.config, fs9);
38662
+ await fs10.cp(baseFunctionDir, functionDir, { recursive: true, force: true });
38663
+ await configureVercelFunction(functionDir, group.config, fs10);
38298
38664
  destinations.set(key, `/${functionName}`);
38299
38665
  }
38300
38666
  const routes = [];
@@ -38341,15 +38707,15 @@ function farmRoutePatternToVercelSource(pattern) {
38341
38707
  return source || "/";
38342
38708
  }
38343
38709
  __name(farmRoutePatternToVercelSource, "farmRoutePatternToVercelSource");
38344
- async function configureVercelFunction(functionDir, config, fs9) {
38710
+ async function configureVercelFunction(functionDir, config, fs10) {
38345
38711
  const configPath = import_path11.default.join(functionDir, ".vc-config.json");
38346
- const current = JSON.parse(await fs9.readFile(configPath, "utf8"));
38712
+ const current = JSON.parse(await fs10.readFile(configPath, "utf8"));
38347
38713
  const next = {
38348
38714
  ...current,
38349
38715
  ...config.regions?.length ? { regions: config.regions } : {},
38350
38716
  ...config.maxDuration ? { maxDuration: config.maxDuration } : {}
38351
38717
  };
38352
- await fs9.writeFile(configPath, `${JSON.stringify(next, null, 2)}
38718
+ await fs10.writeFile(configPath, `${JSON.stringify(next, null, 2)}
38353
38719
  `);
38354
38720
  }
38355
38721
  __name(configureVercelFunction, "configureVercelFunction");
@@ -38675,6 +39041,7 @@ __name(withVite5TransformContext, "withVite5TransformContext");
38675
39041
  init_font_vite();
38676
39042
  init_vite_config();
38677
39043
  init_not_found();
39044
+ init_vite();
38678
39045
  var import_meta = {};
38679
39046
  function preloadFarmNitroRuntime() {
38680
39047
  return import("nitro").then(
@@ -38990,7 +39357,7 @@ function hasProjectPostcssConfig(root) {
38990
39357
  }
38991
39358
  __name(hasProjectPostcssConfig, "hasProjectPostcssConfig");
38992
39359
  async function findFarmConfigPath(root) {
38993
- const fs9 = await import("fs/promises");
39360
+ const fs10 = await import("fs/promises");
38994
39361
  const candidates = [
38995
39362
  "farm.config.ts",
38996
39363
  "farm.config.mts",
@@ -39004,7 +39371,7 @@ async function findFarmConfigPath(root) {
39004
39371
  for (const candidate of candidates) {
39005
39372
  const resolvedPath = import_path12.default.join(root, candidate);
39006
39373
  try {
39007
- await fs9.access(resolvedPath);
39374
+ await fs10.access(resolvedPath);
39008
39375
  return resolvedPath;
39009
39376
  } catch {
39010
39377
  }
@@ -39031,13 +39398,13 @@ function hasFarmServerRuntimePlugins(config) {
39031
39398
  }
39032
39399
  __name(hasFarmServerRuntimePlugins, "hasFarmServerRuntimePlugins");
39033
39400
  async function discoverMiddlewareRoutes(appDir) {
39034
- const fs9 = await import("fs/promises");
39401
+ const fs10 = await import("fs/promises");
39035
39402
  const appDirs = Array.isArray(appDir) ? [...appDir] : [appDir];
39036
39403
  const routes = /* @__PURE__ */ new Map();
39037
39404
  async function walk(dir, routePath, discovered) {
39038
39405
  let entries;
39039
39406
  try {
39040
- entries = await fs9.readdir(dir, { withFileTypes: true });
39407
+ entries = await fs10.readdir(dir, { withFileTypes: true });
39041
39408
  } catch {
39042
39409
  return;
39043
39410
  }
@@ -39118,12 +39485,12 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
39118
39485
  })
39119
39486
  );
39120
39487
  logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
39121
- const fs9 = await import("fs/promises");
39488
+ const fs10 = await import("fs/promises");
39122
39489
  const layoutRoutes = [];
39123
39490
  const appDir = import_path12.default.join(root, srcDir, "app");
39124
39491
  async function findLayoutsForClient(dir, routePrefix = "/") {
39125
39492
  try {
39126
- const entries = await fs9.readdir(dir, { withFileTypes: true });
39493
+ const entries = await fs10.readdir(dir, { withFileTypes: true });
39127
39494
  for (const entry of entries) {
39128
39495
  if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?)$/)) {
39129
39496
  layoutRoutes.push({
@@ -39257,7 +39624,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
39257
39624
  }
39258
39625
  __name(buildUniversal, "buildUniversal");
39259
39626
  async function writeSSRAssetsToClient(bundle, outputDir) {
39260
- const fs9 = await import("fs/promises");
39627
+ const fs10 = await import("fs/promises");
39261
39628
  for (const [fileName, output] of Object.entries(bundle)) {
39262
39629
  if (output.type !== "asset") continue;
39263
39630
  if (fileName === "farm-fonts.css") {
@@ -39265,29 +39632,29 @@ async function writeSSRAssetsToClient(bundle, outputDir) {
39265
39632
  continue;
39266
39633
  }
39267
39634
  const filePath = import_path12.default.join(outputDir, fileName);
39268
- await fs9.mkdir(import_path12.default.dirname(filePath), { recursive: true });
39269
- await fs9.writeFile(filePath, output.source);
39635
+ await fs10.mkdir(import_path12.default.dirname(filePath), { recursive: true });
39636
+ await fs10.writeFile(filePath, output.source);
39270
39637
  }
39271
39638
  }
39272
39639
  __name(writeSSRAssetsToClient, "writeSSRAssetsToClient");
39273
39640
  async function copyFarmDocsFontAssetsToClient(root, outputDir) {
39274
- const fs9 = await import("fs/promises");
39641
+ const fs10 = await import("fs/promises");
39275
39642
  await Promise.all(
39276
39643
  resolveFarmDocsFontAssets(root).map(async ({ sourcePath, url }) => {
39277
39644
  const targetPath = import_path12.default.join(outputDir, url.replace(/^\/+/, ""));
39278
- await fs9.mkdir(import_path12.default.dirname(targetPath), { recursive: true });
39279
- await fs9.copyFile(sourcePath, targetPath);
39645
+ await fs10.mkdir(import_path12.default.dirname(targetPath), { recursive: true });
39646
+ await fs10.copyFile(sourcePath, targetPath);
39280
39647
  })
39281
39648
  );
39282
39649
  }
39283
39650
  __name(copyFarmDocsFontAssetsToClient, "copyFarmDocsFontAssetsToClient");
39284
39651
  async function mergeBuiltFontCss(outputDir, fontCssSource) {
39285
- const fs9 = await import("fs/promises");
39652
+ const fs10 = await import("fs/promises");
39286
39653
  const fontCssPath = import_path12.default.join(outputDir, "farm-fonts.css");
39287
39654
  let fontCss = fontCssSource;
39288
39655
  if (fontCss === void 0) {
39289
39656
  try {
39290
- fontCss = await fs9.readFile(fontCssPath);
39657
+ fontCss = await fs10.readFile(fontCssPath);
39291
39658
  } catch {
39292
39659
  return;
39293
39660
  }
@@ -39295,12 +39662,12 @@ async function mergeBuiltFontCss(outputDir, fontCssSource) {
39295
39662
  const clientCssPath = import_path12.default.join(outputDir, "farm-client.css");
39296
39663
  let clientCss = "";
39297
39664
  try {
39298
- clientCss = await fs9.readFile(clientCssPath, "utf8");
39665
+ clientCss = await fs10.readFile(clientCssPath, "utf8");
39299
39666
  } catch {
39300
39667
  }
39301
39668
  const normalizedFontCss = typeof fontCss === "string" ? fontCss : Buffer.from(fontCss).toString("utf8");
39302
- await fs9.writeFile(fontCssPath, normalizedFontCss);
39303
- await fs9.writeFile(clientCssPath, mergeFarmFontCss(clientCss, normalizedFontCss));
39669
+ await fs10.writeFile(fontCssPath, normalizedFontCss);
39670
+ await fs10.writeFile(clientCssPath, mergeFarmFontCss(clientCss, normalizedFontCss));
39304
39671
  }
39305
39672
  __name(mergeBuiltFontCss, "mergeBuiltFontCss");
39306
39673
  var _IncompleteClientBuildOutputError = class _IncompleteClientBuildOutputError extends Error {
@@ -39312,11 +39679,11 @@ var _IncompleteClientBuildOutputError = class _IncompleteClientBuildOutputError
39312
39679
  __name(_IncompleteClientBuildOutputError, "IncompleteClientBuildOutputError");
39313
39680
  var IncompleteClientBuildOutputError = _IncompleteClientBuildOutputError;
39314
39681
  async function validateClientBuildOutput(root, srcDir, outputDir) {
39315
- const fs9 = await import("fs/promises");
39682
+ const fs10 = await import("fs/promises");
39316
39683
  const clientEntryPath = import_path12.default.join(outputDir, "farm-client.js");
39317
39684
  let clientEntrySize = 0;
39318
39685
  try {
39319
- const clientEntry = await fs9.stat(clientEntryPath);
39686
+ const clientEntry = await fs10.stat(clientEntryPath);
39320
39687
  if (clientEntry.isFile()) clientEntrySize = clientEntry.size;
39321
39688
  } catch {
39322
39689
  }
@@ -39327,12 +39694,12 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
39327
39694
  const globalsCssPath = import_path12.default.join(root, srcDir, "app", "globals.css");
39328
39695
  let expectsCss = false;
39329
39696
  try {
39330
- const globalsCss = await fs9.readFile(globalsCssPath, "utf8");
39697
+ const globalsCss = await fs10.readFile(globalsCssPath, "utf8");
39331
39698
  expectsCss = globalsCss.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
39332
39699
  } catch {
39333
39700
  }
39334
39701
  try {
39335
- const clientCss = await fs9.stat(clientCssPath);
39702
+ const clientCss = await fs10.stat(clientCssPath);
39336
39703
  if (expectsCss && (!clientCss.isFile() || clientCss.size === 0)) {
39337
39704
  throw new IncompleteClientBuildOutputError("farm-client.css is empty");
39338
39705
  }
@@ -39341,15 +39708,15 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
39341
39708
  if (expectsCss) {
39342
39709
  throw new IncompleteClientBuildOutputError("farm-client.css is missing");
39343
39710
  }
39344
- await fs9.writeFile(clientCssPath, "");
39711
+ await fs10.writeFile(clientCssPath, "");
39345
39712
  }
39346
39713
  }
39347
39714
  __name(validateClientBuildOutput, "validateClientBuildOutput");
39348
39715
  async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = []) {
39349
39716
  const viteBuild = productionVite.build;
39350
- const { farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite(), vite_exports));
39717
+ const { farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite2(), vite_exports));
39351
39718
  const { PluginManager: PluginManager2 } = await Promise.resolve().then(() => (init_plugin(), plugin_exports));
39352
- const fs9 = await import("fs/promises");
39719
+ const fs10 = await import("fs/promises");
39353
39720
  const pluginManager = new PluginManager2({
39354
39721
  config,
39355
39722
  isDev: false,
@@ -39385,6 +39752,11 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
39385
39752
  const applicableClientLayouts = clientLayouts.filter(
39386
39753
  (layout2) => layout2.shouldHydrate && layoutAppliesToRoute(layout2.pattern, route2.pattern)
39387
39754
  );
39755
+ if (metadata.suppressedAsyncHydration) {
39756
+ logger.warn(
39757
+ `\u26A0\uFE0F ${route2.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.`
39758
+ );
39759
+ }
39388
39760
  if (metadata.shouldHydrate || applicableClientLayouts.length > 0) {
39389
39761
  const relativePath2 = route2.modulePath.replace(root, "").replace(/^\//, "");
39390
39762
  const hydrationStrategies = [
@@ -39443,8 +39815,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
39443
39815
  `\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout2) => layout2.shouldHydrate).length} layouts, and ${clientRouteSlots.length} slots`
39444
39816
  );
39445
39817
  const clientEntryRoot = import_path12.default.join(root, ".farm", "tmp");
39446
- await fs9.mkdir(clientEntryRoot, { recursive: true });
39447
- const clientEntryDir = await fs9.mkdtemp(import_path12.default.join(clientEntryRoot, "client-entry-"));
39818
+ await fs10.mkdir(clientEntryRoot, { recursive: true });
39819
+ const clientEntryDir = await fs10.mkdtemp(import_path12.default.join(clientEntryRoot, "client-entry-"));
39448
39820
  const clientEntryPath = import_path12.default.join(clientEntryDir, "farm-client-entry.tsx");
39449
39821
  const clientHydrationCode = generateClientHydrationEntry(
39450
39822
  clientPages,
@@ -39458,7 +39830,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
39458
39830
  config.i18n,
39459
39831
  config.plugins
39460
39832
  );
39461
- await fs9.writeFile(clientEntryPath, clientHydrationCode);
39833
+ await fs10.writeFile(clientEntryPath, clientHydrationCode);
39462
39834
  const hasScopedPostcssConfig = hasProjectPostcssConfig(root);
39463
39835
  let postcssSearchPath;
39464
39836
  let tailwindVitePlugin = void 0;
@@ -39466,7 +39838,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
39466
39838
  logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
39467
39839
  } else {
39468
39840
  const postcssConfigPath = import_path12.default.join(clientEntryDir, "postcss.config.cjs");
39469
- await fs9.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
39841
+ await fs10.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
39470
39842
  postcssSearchPath = clientEntryDir;
39471
39843
  try {
39472
39844
  const tailwindVite = (await import("@tailwindcss/vite")).default;
@@ -39539,6 +39911,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
39539
39911
  }
39540
39912
  },
39541
39913
  plugins: [
39914
+ createFarmThemeCssPlugin(config.theme, config.basePath),
39542
39915
  ...tailwindVitePlugin ? [tailwindVitePlugin] : [],
39543
39916
  // Plugin to redirect @farm.js/core imports to client-only exports
39544
39917
  {
@@ -39610,7 +39983,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
39610
39983
  await validateClientBuildOutput(root, srcDir, outputDir);
39611
39984
  } finally {
39612
39985
  try {
39613
- await fs9.rm(clientEntryDir, { recursive: true, force: true });
39986
+ await fs10.rm(clientEntryDir, { recursive: true, force: true });
39614
39987
  } catch {
39615
39988
  }
39616
39989
  }
@@ -40261,6 +40634,13 @@ async function createMatchedHydrationElement(matched, pathname, searchParams) {
40261
40634
  if (matched.route.pageShouldHydrate) {
40262
40635
  const Component = await loadRouteComponent(matched.route);
40263
40636
  if (!Component) return null;
40637
+ if (typeof Component === "function" && Component.constructor && Component.constructor.name === "AsyncFunction") {
40638
+ console.warn(
40639
+ "[Farm.js] Skipping hydration for " + pathname +
40640
+ ": async server components cannot run in the browser. Server-rendered HTML is preserved."
40641
+ );
40642
+ return null;
40643
+ }
40264
40644
  const props = { params: params, searchParams: Promise.resolve(searchParams) };
40265
40645
  pageElement = React.createElement(Component, props);
40266
40646
  } else if (hydrateLayouts) {
@@ -40916,9 +41296,9 @@ void hydrate();
40916
41296
  __name(generateClientHydrationEntry, "generateClientHydrationEntry");
40917
41297
  async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots) {
40918
41298
  const viteBuild = productionVite.build;
40919
- const { farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite(), vite_exports));
41299
+ const { farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite2(), vite_exports));
40920
41300
  const { PluginManager: PluginManager2 } = await Promise.resolve().then(() => (init_plugin(), plugin_exports));
40921
- const fs9 = await import("fs/promises");
41301
+ const fs10 = await import("fs/promises");
40922
41302
  const pluginManager = new PluginManager2({
40923
41303
  config,
40924
41304
  isDev: false,
@@ -40929,8 +41309,8 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
40929
41309
  let postcssConfigDir;
40930
41310
  let tailwindVitePlugin = void 0;
40931
41311
  if (!hasScopedPostcssConfig) {
40932
- postcssConfigDir = await fs9.mkdtemp(import_path12.default.join(import_os.default.tmpdir(), "farm-postcss-"));
40933
- await fs9.writeFile(
41312
+ postcssConfigDir = await fs10.mkdtemp(import_path12.default.join(import_os.default.tmpdir(), "farm-postcss-"));
41313
+ await fs10.writeFile(
40934
41314
  import_path12.default.join(postcssConfigDir, "postcss.config.cjs"),
40935
41315
  "module.exports = { plugins: [] };\n"
40936
41316
  );
@@ -40960,7 +41340,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
40960
41340
  fileName: entry.fileName,
40961
41341
  sourceType: "static",
40962
41342
  staticInfo: entry.staticInfo,
40963
- data: (await fs9.readFile(entry.modulePath)).toString("base64")
41343
+ data: (await fs10.readFile(entry.modulePath)).toString("base64")
40964
41344
  });
40965
41345
  continue;
40966
41346
  }
@@ -41010,7 +41390,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
41010
41390
  for (const ext of notFoundExtensions) {
41011
41391
  const checkPath = import_path12.default.join(sourceAppDir, `not-found${ext}`);
41012
41392
  try {
41013
- await fs9.access(checkPath);
41393
+ await fs10.access(checkPath);
41014
41394
  notFoundPath = checkPath;
41015
41395
  break;
41016
41396
  } catch {
@@ -41157,6 +41537,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
41157
41537
  __FARM_PUBLIC_ENV__: JSON.stringify(config.env?.public || {})
41158
41538
  },
41159
41539
  plugins: [
41540
+ createFarmThemeCssPlugin(config.theme, config.basePath),
41160
41541
  ...tailwindVitePlugin ? [tailwindVitePlugin] : [],
41161
41542
  ...!useExternalMetadataImageRuntime && metadataImageRoutes.some((image) => image.sourceType === "module") ? [createMetadataImageWasmPlugin()] : [],
41162
41543
  {
@@ -41221,7 +41602,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
41221
41602
  } finally {
41222
41603
  if (postcssConfigDir) {
41223
41604
  try {
41224
- await fs9.rm(postcssConfigDir, { recursive: true, force: true });
41605
+ await fs10.rm(postcssConfigDir, { recursive: true, force: true });
41225
41606
  } catch {
41226
41607
  }
41227
41608
  }
@@ -41370,15 +41751,19 @@ function generateVirtualEntryCode(apiRoutes, pageRoutes, layoutRoutes, routeSlot
41370
41751
  _runWithCurrentRequest,
41371
41752
  _runWithMiddlewareContext,
41372
41753
  _runWithMiddlewareData,
41754
+ _setDefaultFarmThemeConfig,
41373
41755
  addMetadataImageReference,
41756
+ applyFarmThemeDocument,
41374
41757
  appendFarmLinkHeader,
41375
41758
  applyProductionMiddlewareHeaders,
41376
41759
  configureFarmCache,
41377
41760
  configureFarmObservability,
41378
41761
  createFarmCacheKey,
41762
+ createFarmThemeDocumentParts,
41379
41763
  createFarmLocaleCookie,
41380
41764
  createFarmProductionLifecycle,
41381
41765
  createProductionMiddlewareRunner,
41766
+ getTheme as getFarmTheme,
41382
41767
  emitFarmEvent,
41383
41768
  getFarmDataCache,
41384
41769
  getFarmLocaleVaryHeaders,
@@ -41573,6 +41958,8 @@ configureFarmObservability(farmObservabilityConfig);
41573
41958
  configureFarmCache(farmResolvedRuntimeConfig.cache);
41574
41959
  const farmI18nConfig = ${JSON.stringify(config.i18n)};
41575
41960
  const farmServerConfig = ${JSON.stringify(config.server)};
41961
+ const farmThemeConfig = ${JSON.stringify(config.theme)};
41962
+ _setDefaultFarmThemeConfig(farmThemeConfig);
41576
41963
  export const farmProductionLifecycle = createFarmProductionLifecycle({
41577
41964
  server: farmServerConfig,
41578
41965
  start: () => farmPluginRuntime?.startRuntime(),
@@ -43409,7 +43796,13 @@ async function handleFarmRequestInContext(
43409
43796
  !farmI18nSnapshot &&
43410
43797
  !pprCacheKey
43411
43798
  ) {
43799
+ const farmThemeDocument = createFarmThemeDocumentParts(
43800
+ farmThemeConfig,
43801
+ farmResolvedRuntimeConfig.basePath,
43802
+ getFarmTheme(request)
43803
+ );
43412
43804
  const streamPrefix = '<!DOCTYPE html>\\n<html lang="en">\\n<head>\\n' +
43805
+ farmThemeDocument.head + '\\n' +
43413
43806
  ' <meta charset="utf-8">\\n' +
43414
43807
  ' <meta name="viewport" content="width=device-width, initial-scale=1">\\n' +
43415
43808
  (hasFavicon ? '' : ' <link rel="icon" href="data:,">\\n') +
@@ -43425,9 +43818,13 @@ async function handleFarmRequestInContext(
43425
43818
  ) + '\\n' +
43426
43819
  ' <script type="module" src="/farm-client.js"></script>\\n' +
43427
43820
  '</body>\\n</html>';
43821
+ const themedStreamPrefix = streamPrefix.replace(
43822
+ '<html lang="en">',
43823
+ '<html lang="en"' + farmThemeDocument.attributes + '>'
43824
+ );
43428
43825
  const streamedDocument = createFarmDocumentStream(
43429
43826
  renderedPage.stream,
43430
- streamPrefix,
43827
+ themedStreamPrefix,
43431
43828
  streamSuffix,
43432
43829
  function() {
43433
43830
  if (pprBypassReason === "refresh") {
@@ -43510,6 +43907,12 @@ async function handleFarmRequestInContext(
43510
43907
  </html>\`;
43511
43908
  }
43512
43909
  fullHtml = applyFarmI18nDocument(fullHtml, pathname, farmI18nSnapshot);
43910
+ fullHtml = applyFarmThemeDocument(
43911
+ fullHtml,
43912
+ farmThemeConfig,
43913
+ farmResolvedRuntimeConfig.basePath,
43914
+ getFarmTheme(request)
43915
+ );
43513
43916
 
43514
43917
  if (pageStatus === 200 && pprCacheKey && request.method.toUpperCase() !== "HEAD") {
43515
43918
  await pprShellCache.setAsync(
@@ -43636,10 +44039,15 @@ async function handleFarmRequestInContext(
43636
44039
  const errorHtml = ${hasMiddlewareRuntime ? `await _runWithMiddlewareData(middlewareData, () =>
43637
44040
  _runWithMiddlewareContext(middlewareContext, renderErrorElement)
43638
44041
  )` : "await renderErrorElement()"};
43639
- const errorDocument = applyFarmI18nDocument(
43640
- createFarmErrorDocument(errorHtml, "Application Error"),
43641
- pathname,
43642
- getFarmI18nSnapshot()
44042
+ const errorDocument = applyFarmThemeDocument(
44043
+ applyFarmI18nDocument(
44044
+ createFarmErrorDocument(errorHtml, "Application Error"),
44045
+ pathname,
44046
+ getFarmI18nSnapshot()
44047
+ ),
44048
+ farmThemeConfig,
44049
+ farmResolvedRuntimeConfig.basePath,
44050
+ getFarmTheme(request)
43643
44051
  );
43644
44052
  emitFarmEvent({
43645
44053
  type: "render.complete",
@@ -43664,10 +44072,15 @@ async function handleFarmRequestInContext(
43664
44072
  const errorMessage = "Internal Server Error";
43665
44073
  const fallbackHtml = '<main><h1>Application Error</h1><p>' +
43666
44074
  escapeFarmHtmlAttribute(errorMessage) + '</p></main>';
43667
- const fallbackDocument = applyFarmI18nDocument(
43668
- createFarmErrorDocument(fallbackHtml, "Application Error"),
43669
- pathname,
43670
- getFarmI18nSnapshot()
44075
+ const fallbackDocument = applyFarmThemeDocument(
44076
+ applyFarmI18nDocument(
44077
+ createFarmErrorDocument(fallbackHtml, "Application Error"),
44078
+ pathname,
44079
+ getFarmI18nSnapshot()
44080
+ ),
44081
+ farmThemeConfig,
44082
+ farmResolvedRuntimeConfig.basePath,
44083
+ getFarmTheme(request)
43671
44084
  );
43672
44085
  return applyProductionMiddlewareHeaders(new Response(
43673
44086
  fallbackDocument,
@@ -43765,6 +44178,12 @@ async function handleFarmRequestInContext(
43765
44178
  </html>\`;
43766
44179
  }
43767
44180
  fullHtml = applyFarmI18nDocument(fullHtml, pathname, getFarmI18nSnapshot());
44181
+ fullHtml = applyFarmThemeDocument(
44182
+ fullHtml,
44183
+ farmThemeConfig,
44184
+ farmResolvedRuntimeConfig.basePath,
44185
+ getFarmTheme(request)
44186
+ );
43768
44187
 
43769
44188
  emitFarmEvent({
43770
44189
  type: "render.complete",
@@ -43783,8 +44202,14 @@ async function handleFarmRequestInContext(
43783
44202
  }), middlewareHeaders);
43784
44203
  } catch (error) {
43785
44204
  console.error("404 render error:", error);
43786
- return applyProductionMiddlewareHeaders(new Response(
44205
+ const fallbackDocument = applyFarmThemeDocument(
43787
44206
  \`<!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>\`,
44207
+ farmThemeConfig,
44208
+ farmResolvedRuntimeConfig.basePath,
44209
+ getFarmTheme(request)
44210
+ );
44211
+ return applyProductionMiddlewareHeaders(new Response(
44212
+ fallbackDocument,
43788
44213
  {
43789
44214
  status: 404,
43790
44215
  headers: { "Content-Type": "text/html", "x-farm-preload-buffered": "1" },
@@ -44072,7 +44497,7 @@ function getPhysicalPrerenderBypassReason(options) {
44072
44497
  }
44073
44498
  __name(getPhysicalPrerenderBypassReason, "getPhysicalPrerenderBypassReason");
44074
44499
  async function buildNitroUniversal(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, ssrBundle, ssrEntryFile, clientOutputDir, routeRuntimeManifest, configuredHeaderRoutes, nitroRuntimeResultPromise, pluginManager) {
44075
- const [fs9, nitroRuntimeResult] = await Promise.all([
44500
+ const [fs10, nitroRuntimeResult] = await Promise.all([
44076
44501
  import("fs/promises"),
44077
44502
  nitroRuntimeResultPromise
44078
44503
  ]);
@@ -44150,11 +44575,11 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
44150
44575
  }
44151
44576
  const scheduledTasks = mergeScheduledTasks(farmWorkflows.scheduledTasks, farmCron.scheduledTasks);
44152
44577
  const cloudflareCronConfig = createFarmCronCloudflareConfig(farmCron.jobs);
44153
- await fs9.mkdir(ssrOutputDir, { recursive: true });
44578
+ await fs10.mkdir(ssrOutputDir, { recursive: true });
44154
44579
  for (const [fileName, output] of Object.entries(ssrBundle)) {
44155
44580
  const filePath = import_path12.default.join(ssrOutputDir, fileName);
44156
- await fs9.mkdir(import_path12.default.dirname(filePath), { recursive: true });
44157
- await fs9.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
44581
+ await fs10.mkdir(import_path12.default.dirname(filePath), { recursive: true });
44582
+ await fs10.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
44158
44583
  }
44159
44584
  const nitroEntryPath = import_path12.default.join(ssrOutputDir, "nitro-entry.mjs");
44160
44585
  const nitroEntryCode = `
@@ -44220,10 +44645,10 @@ export default async function farmNitroEventHandler(event) {
44220
44645
  return response
44221
44646
  }
44222
44647
  `.trim();
44223
- await fs9.writeFile(nitroEntryPath, nitroEntryCode);
44648
+ await fs10.writeFile(nitroEntryPath, nitroEntryCode);
44224
44649
  const farmNodeServerEntryPath = preset === "node-server" ? import_path12.default.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
44225
44650
  if (farmNodeServerEntryPath) {
44226
- await fs9.writeFile(
44651
+ await fs10.writeFile(
44227
44652
  farmNodeServerEntryPath,
44228
44653
  createFarmNodeServerEntry({
44229
44654
  nitroEntryFile: import_path12.default.basename(nitroEntryPath),
@@ -44423,9 +44848,9 @@ export default async function farmNitroEventHandler(event) {
44423
44848
  import_path12.default.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
44424
44849
  {},
44425
44850
  false,
44426
- fs9
44851
+ fs10
44427
44852
  );
44428
- await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile, fs9);
44853
+ await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile, fs10);
44429
44854
  });
44430
44855
  });
44431
44856
  }
@@ -44457,17 +44882,17 @@ export default async function farmNitroEventHandler(event) {
44457
44882
  import_path12.default.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
44458
44883
  configuredEsbuildOptions,
44459
44884
  effectiveMinify,
44460
- fs9
44885
+ fs10
44461
44886
  ) : Promise.resolve(),
44462
- imageRuntime === "node" ? copySharpRuntime(config, root, import_path12.default.join(outputDir, "server"), fs9) : Promise.resolve(),
44463
- useExternalMetadataImageRuntime ? copyMetadataImageRuntime(root, import_path12.default.join(outputDir, "server"), fs9) : Promise.resolve()
44887
+ imageRuntime === "node" ? copySharpRuntime(config, root, import_path12.default.join(outputDir, "server"), fs10) : Promise.resolve(),
44888
+ useExternalMetadataImageRuntime ? copyMetadataImageRuntime(root, import_path12.default.join(outputDir, "server"), fs10) : Promise.resolve()
44464
44889
  ]);
44465
44890
  const failedCopy = copyResults.find(
44466
44891
  (result) => result.status === "rejected"
44467
44892
  );
44468
44893
  if (failedCopy) throw failedCopy.reason;
44469
44894
  if (canReusePrebuiltSSR) {
44470
- await registerPrebuiltSSRPackageImport(import_path12.default.join(outputDir, "server"), ssrEntryFile, fs9);
44895
+ await registerPrebuiltSSRPackageImport(import_path12.default.join(outputDir, "server"), ssrEntryFile, fs10);
44471
44896
  logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
44472
44897
  }
44473
44898
  if (useRolldownBuilder) {
@@ -44482,12 +44907,12 @@ export default async function farmNitroEventHandler(event) {
44482
44907
  });
44483
44908
  }
44484
44909
  if (isVercel) {
44485
- await postProcessVercelOutput(root, outputDir, fs9, config, farmWorkflows, routeRuntimeManifest);
44910
+ await postProcessVercelOutput(root, outputDir, fs10, config, farmWorkflows, routeRuntimeManifest);
44486
44911
  }
44487
44912
  logger.success(`\u2705 Nitro build completed with preset: ${preset}`);
44488
44913
  }
44489
44914
  __name(buildNitroUniversal, "buildNitroUniversal");
44490
- async function copyPrebuiltSSRBundle(ssrBundle, targetDir, configuredEsbuildOptions, minify, fs9) {
44915
+ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, configuredEsbuildOptions, minify, fs10) {
44491
44916
  const {
44492
44917
  include: _include,
44493
44918
  exclude: _exclude,
@@ -44504,13 +44929,13 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, configuredEsbuildOpti
44504
44929
  "node18"
44505
44930
  );
44506
44931
  const transform = minify || hasConfiguredTransforms ? (await import("esbuild")).transform : null;
44507
- await fs9.rm(targetDir, { recursive: true, force: true });
44932
+ await fs10.rm(targetDir, { recursive: true, force: true });
44508
44933
  await Promise.all(
44509
44934
  Object.entries(ssrBundle).map(async ([fileName, output]) => {
44510
44935
  const targetPath = import_path12.default.join(targetDir, fileName);
44511
- await fs9.mkdir(import_path12.default.dirname(targetPath), { recursive: true });
44936
+ await fs10.mkdir(import_path12.default.dirname(targetPath), { recursive: true });
44512
44937
  if (output.type === "asset") {
44513
- await fs9.writeFile(targetPath, output.source);
44938
+ await fs10.writeFile(targetPath, output.source);
44514
44939
  return;
44515
44940
  }
44516
44941
  let code = output.code;
@@ -44521,14 +44946,14 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, configuredEsbuildOpti
44521
44946
  });
44522
44947
  code = result.code;
44523
44948
  }
44524
- await fs9.writeFile(targetPath, code);
44949
+ await fs10.writeFile(targetPath, code);
44525
44950
  })
44526
44951
  );
44527
44952
  }
44528
44953
  __name(copyPrebuiltSSRBundle, "copyPrebuiltSSRBundle");
44529
- async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs9) {
44954
+ async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs10) {
44530
44955
  const packagePath = import_path12.default.join(serverDir, "package.json");
44531
- const packageJSON = await fs9.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
44956
+ const packageJSON = await fs10.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
44532
44957
  if (error.code === "ENOENT") return { type: "module" };
44533
44958
  throw error;
44534
44959
  });
@@ -44538,38 +44963,38 @@ async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs9) {
44538
44963
  ...existingImports,
44539
44964
  [FARM_SSR_PACKAGE_IMPORT]: `./${outputEntry}`
44540
44965
  };
44541
- await fs9.mkdir(serverDir, { recursive: true });
44542
- await fs9.writeFile(packagePath, `${JSON.stringify(packageJSON, null, 2)}
44966
+ await fs10.mkdir(serverDir, { recursive: true });
44967
+ await fs10.writeFile(packagePath, `${JSON.stringify(packageJSON, null, 2)}
44543
44968
  `);
44544
44969
  }
44545
44970
  __name(registerPrebuiltSSRPackageImport, "registerPrebuiltSSRPackageImport");
44546
- async function postProcessVercelOutput(root, outputDir, fs9, config, farmWorkflows, routeRuntimeManifest) {
44971
+ async function postProcessVercelOutput(root, outputDir, fs10, config, farmWorkflows, routeRuntimeManifest) {
44547
44972
  const serverDir = import_path12.default.join(outputDir, "server");
44548
44973
  const functionsDir = import_path12.default.join(outputDir, "functions");
44549
44974
  const nitroFuncDir = import_path12.default.join(functionsDir, "__nitro.func");
44550
44975
  const staticDir = import_path12.default.join(outputDir, "static");
44551
44976
  const publicDir = import_path12.default.join(outputDir, "public");
44552
- await fs9.mkdir(nitroFuncDir, { recursive: true });
44553
- const serverContents = await fs9.readdir(serverDir);
44977
+ await fs10.mkdir(nitroFuncDir, { recursive: true });
44978
+ const serverContents = await fs10.readdir(serverDir);
44554
44979
  for (const file of serverContents) {
44555
44980
  const src = import_path12.default.join(serverDir, file);
44556
44981
  const dest = import_path12.default.join(nitroFuncDir, file);
44557
- await fs9.rename(src, dest);
44982
+ await fs10.rename(src, dest);
44558
44983
  }
44559
- await fs9.rmdir(serverDir);
44984
+ await fs10.rmdir(serverDir);
44560
44985
  try {
44561
- await fs9.rename(publicDir, staticDir);
44986
+ await fs10.rename(publicDir, staticDir);
44562
44987
  } catch {
44563
44988
  }
44564
- await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs9);
44565
- await copyPrismaClientForVercel(root, nitroFuncDir, fs9);
44989
+ await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs10);
44990
+ await copyPrismaClientForVercel(root, nitroFuncDir, fs10);
44566
44991
  const configPath = import_path12.default.join(outputDir, "config.json");
44567
- const configContent = await fs9.readFile(configPath, "utf-8");
44992
+ const configContent = await fs10.readFile(configPath, "utf-8");
44568
44993
  const vercelConfig = JSON.parse(configContent);
44569
44994
  const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
44570
44995
  outputDir,
44571
44996
  routeRuntimeManifest,
44572
- fs9
44997
+ fs10
44573
44998
  );
44574
44999
  vercelConfig.routes = [
44575
45000
  // Apply the header before the filesystem handler. `continue` lets Vercel
@@ -44604,24 +45029,24 @@ async function postProcessVercelOutput(root, outputDir, fs9, config, farmWorkflo
44604
45029
  vercelConfigWithWorkflowCrons,
44605
45030
  config.cron.jobs
44606
45031
  );
44607
- await fs9.writeFile(configPath, JSON.stringify(vercelConfigWithCrons, null, 2));
45032
+ await fs10.writeFile(configPath, JSON.stringify(vercelConfigWithCrons, null, 2));
44608
45033
  logger.info("\u2705 Post-processed Vercel output for Build Output API v3");
44609
45034
  }
44610
45035
  __name(postProcessVercelOutput, "postProcessVercelOutput");
44611
- async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs9) {
45036
+ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs10) {
44612
45037
  const docsContentDir = resolveBuildDocsContentDir(config, root);
44613
45038
  if (!docsContentDir) return;
44614
45039
  const bundledContentDir = import_path12.default.join(nitroFuncDir, "chunks", "nitro", "farm-docs-content");
44615
45040
  const lastModifiedManifest = createFarmDocsLastModifiedManifest(docsContentDir, {
44616
45041
  fallback: "now"
44617
45042
  });
44618
- await fs9.rm(bundledContentDir, { recursive: true, force: true });
44619
- await fs9.mkdir(import_path12.default.dirname(bundledContentDir), { recursive: true });
44620
- await fs9.cp(docsContentDir, bundledContentDir, {
45043
+ await fs10.rm(bundledContentDir, { recursive: true, force: true });
45044
+ await fs10.mkdir(import_path12.default.dirname(bundledContentDir), { recursive: true });
45045
+ await fs10.cp(docsContentDir, bundledContentDir, {
44621
45046
  recursive: true,
44622
45047
  force: true
44623
45048
  });
44624
- await fs9.writeFile(
45049
+ await fs10.writeFile(
44625
45050
  import_path12.default.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
44626
45051
  `${JSON.stringify(lastModifiedManifest, null, 2)}
44627
45052
  `
@@ -44629,7 +45054,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs9) {
44629
45054
  logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${import_path12.default.relative(root, docsContentDir)}`);
44630
45055
  }
44631
45056
  __name(copyFarmDocsContentForVercel, "copyFarmDocsContentForVercel");
44632
- async function copySharpRuntime(config, root, nitroFuncDir, fs9) {
45057
+ async function copySharpRuntime(config, root, nitroFuncDir, fs10) {
44633
45058
  if (config.images.provider === "none") return;
44634
45059
  const projectRequire = (0, import_module3.createRequire)(import_path12.default.join(root, "package.json"));
44635
45060
  let sharpRequire = projectRequire;
@@ -44653,18 +45078,18 @@ async function copySharpRuntime(config, root, nitroFuncDir, fs9) {
44653
45078
  async function copyPackageOnce(packageName, parentRequire) {
44654
45079
  const packageJsonPath = resolvePackageJson(parentRequire, packageName);
44655
45080
  if (!packageJsonPath) return;
44656
- const packageJson = JSON.parse(await fs9.readFile(packageJsonPath, "utf8"));
45081
+ const packageJson = JSON.parse(await fs10.readFile(packageJsonPath, "utf8"));
44657
45082
  const packageDir = import_path12.default.dirname(packageJsonPath);
44658
45083
  const targetDir = import_path12.default.join(targetNodeModules, ...packageName.split("/"));
44659
45084
  copiedPackages.set(packageName, String(packageJson.version || "*"));
44660
- await fs9.mkdir(import_path12.default.dirname(targetDir), { recursive: true });
45085
+ await fs10.mkdir(import_path12.default.dirname(targetDir), { recursive: true });
44661
45086
  const packageRequire = (0, import_module3.createRequire)(packageJsonPath);
44662
45087
  const dependencies = {
44663
45088
  ...packageJson.dependencies,
44664
45089
  ...packageJson.optionalDependencies
44665
45090
  };
44666
45091
  await Promise.all([
44667
- fs9.cp(packageDir, targetDir, {
45092
+ fs10.cp(packageDir, targetDir, {
44668
45093
  recursive: true,
44669
45094
  force: true,
44670
45095
  dereference: true,
@@ -44683,16 +45108,16 @@ async function copySharpRuntime(config, root, nitroFuncDir, fs9) {
44683
45108
  );
44684
45109
  }
44685
45110
  const functionPackagePath = import_path12.default.join(nitroFuncDir, "package.json");
44686
- const functionPackage = JSON.parse(await fs9.readFile(functionPackagePath, "utf8"));
45111
+ const functionPackage = JSON.parse(await fs10.readFile(functionPackagePath, "utf8"));
44687
45112
  functionPackage.dependencies = {
44688
45113
  ...functionPackage.dependencies,
44689
45114
  ...Object.fromEntries([...copiedPackages].sort(([left], [right]) => left.localeCompare(right)))
44690
45115
  };
44691
- await fs9.writeFile(functionPackagePath, JSON.stringify(functionPackage, null, 2));
45116
+ await fs10.writeFile(functionPackagePath, JSON.stringify(functionPackage, null, 2));
44692
45117
  logger.info(`\u{1F5BC}\uFE0F Bundled Sharp image runtime (${copiedPackages.size} packages)`);
44693
45118
  }
44694
45119
  __name(copySharpRuntime, "copySharpRuntime");
44695
- async function copyMetadataImageRuntime(root, nitroFuncDir, fs9) {
45120
+ async function copyMetadataImageRuntime(root, nitroFuncDir, fs10) {
44696
45121
  const projectRequire = (0, import_module3.createRequire)(import_path12.default.join(root, "package.json"));
44697
45122
  let runtimeRequire = projectRequire;
44698
45123
  let packageJsonPath = resolvePackageJson(runtimeRequire, "@vercel/og");
@@ -44708,23 +45133,23 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs9) {
44708
45133
  "Generated metadata images require @vercel/og. Reinstall @farm.js/core with production dependencies."
44709
45134
  );
44710
45135
  }
44711
- const packageJson = JSON.parse(await fs9.readFile(packageJsonPath, "utf8"));
45136
+ const packageJson = JSON.parse(await fs10.readFile(packageJsonPath, "utf8"));
44712
45137
  const packageDir = import_path12.default.dirname(packageJsonPath);
44713
45138
  const targetDir = import_path12.default.join(nitroFuncDir, "node_modules", "@vercel", "og");
44714
- await fs9.mkdir(import_path12.default.dirname(targetDir), { recursive: true });
44715
- await fs9.cp(packageDir, targetDir, {
45139
+ await fs10.mkdir(import_path12.default.dirname(targetDir), { recursive: true });
45140
+ await fs10.cp(packageDir, targetDir, {
44716
45141
  recursive: true,
44717
45142
  force: true,
44718
45143
  dereference: true,
44719
45144
  mode: import_fs5.constants.COPYFILE_FICLONE
44720
45145
  });
44721
45146
  const functionPackagePath = import_path12.default.join(nitroFuncDir, "package.json");
44722
- const functionPackage = JSON.parse(await fs9.readFile(functionPackagePath, "utf8"));
45147
+ const functionPackage = JSON.parse(await fs10.readFile(functionPackagePath, "utf8"));
44723
45148
  functionPackage.dependencies = {
44724
45149
  ...functionPackage.dependencies,
44725
45150
  "@vercel/og": String(packageJson.version || "0.11.1")
44726
45151
  };
44727
- await fs9.writeFile(functionPackagePath, JSON.stringify(functionPackage, null, 2));
45152
+ await fs10.writeFile(functionPackagePath, JSON.stringify(functionPackage, null, 2));
44728
45153
  logger.info("\u{1F5BC}\uFE0F Bundled generated metadata image runtime");
44729
45154
  }
44730
45155
  __name(copyMetadataImageRuntime, "copyMetadataImageRuntime");
@@ -44738,7 +45163,7 @@ function resolvePackageJson(parentRequire, packageName) {
44738
45163
  return null;
44739
45164
  }
44740
45165
  __name(resolvePackageJson, "resolvePackageJson");
44741
- async function copyPrismaClientForVercel(root, nitroFuncDir, fs9) {
45166
+ async function copyPrismaClientForVercel(root, nitroFuncDir, fs10) {
44742
45167
  const projectRequire = (0, import_module3.createRequire)(import_path12.default.join(root, "package.json"));
44743
45168
  let prismaClientDir;
44744
45169
  try {
@@ -44748,7 +45173,7 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs9) {
44748
45173
  }
44749
45174
  const generatedClientDir = import_path12.default.join(prismaClientDir, "..", "..", ".prisma", "client");
44750
45175
  try {
44751
- await fs9.access(generatedClientDir);
45176
+ await fs10.access(generatedClientDir);
44752
45177
  } catch {
44753
45178
  return;
44754
45179
  }
@@ -44756,20 +45181,20 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs9) {
44756
45181
  const targetPrismaScopeDir = import_path12.default.join(targetNodeModules, "@prisma");
44757
45182
  const targetGeneratedDir = import_path12.default.join(targetNodeModules, ".prisma", "client");
44758
45183
  const targetClientDir = import_path12.default.join(targetPrismaScopeDir, "client");
44759
- await fs9.mkdir(targetPrismaScopeDir, { recursive: true });
44760
- await fs9.cp(prismaClientDir, targetClientDir, {
45184
+ await fs10.mkdir(targetPrismaScopeDir, { recursive: true });
45185
+ await fs10.cp(prismaClientDir, targetClientDir, {
44761
45186
  recursive: true,
44762
45187
  force: true
44763
45188
  });
44764
- await fs9.cp(generatedClientDir, targetGeneratedDir, {
45189
+ await fs10.cp(generatedClientDir, targetGeneratedDir, {
44765
45190
  recursive: true,
44766
45191
  force: true
44767
45192
  });
44768
45193
  const functionPackagePath = import_path12.default.join(nitroFuncDir, "package.json");
44769
45194
  const clientPackagePath = import_path12.default.join(prismaClientDir, "package.json");
44770
45195
  const [functionPackageContent, clientPackageContent] = await Promise.all([
44771
- fs9.readFile(functionPackagePath, "utf-8"),
44772
- fs9.readFile(clientPackagePath, "utf-8")
45196
+ fs10.readFile(functionPackagePath, "utf-8"),
45197
+ fs10.readFile(clientPackagePath, "utf-8")
44773
45198
  ]);
44774
45199
  const functionPackage = JSON.parse(functionPackageContent);
44775
45200
  const clientPackage = JSON.parse(clientPackageContent);
@@ -44777,7 +45202,7 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs9) {
44777
45202
  ...functionPackage.dependencies,
44778
45203
  "@prisma/client": clientPackage.version
44779
45204
  };
44780
- await fs9.writeFile(functionPackagePath, JSON.stringify(functionPackage, null, 2));
45205
+ await fs10.writeFile(functionPackagePath, JSON.stringify(functionPackage, null, 2));
44781
45206
  }
44782
45207
  __name(copyPrismaClientForVercel, "copyPrismaClientForVercel");
44783
45208
 
@@ -45011,7 +45436,7 @@ async function createProjectModuleServer(createViteServer, config, root) {
45011
45436
  }
45012
45437
  __name(createProjectModuleServer, "createProjectModuleServer");
45013
45438
  async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
45014
- const { farmI18nClientBridgePlugin: farmI18nClientBridgePlugin2, farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite(), vite_exports));
45439
+ const { farmI18nClientBridgePlugin: farmI18nClientBridgePlugin2, farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite2(), vite_exports));
45015
45440
  const { PluginManager: PluginManager2 } = await Promise.resolve().then(() => (init_plugin(), plugin_exports));
45016
45441
  const pluginManager = new PluginManager2({
45017
45442
  config,
@@ -45038,7 +45463,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
45038
45463
  }
45039
45464
  __name(buildClient2, "buildClient");
45040
45465
  async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
45041
- const { farmI18nClientBridgePlugin: farmI18nClientBridgePlugin2, farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite(), vite_exports));
45466
+ const { farmI18nClientBridgePlugin: farmI18nClientBridgePlugin2, farmPlugin: farmPlugin2 } = await Promise.resolve().then(() => (init_vite2(), vite_exports));
45042
45467
  const { PluginManager: PluginManager2 } = await Promise.resolve().then(() => (init_plugin(), plugin_exports));
45043
45468
  const pluginManager = new PluginManager2({
45044
45469
  config,
@@ -45099,10 +45524,10 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
45099
45524
  const manifestPath = import_path14.default.join(publicOutputDir, "farm-client-manifest.json");
45100
45525
  const assetsDir = import_path14.default.join(publicOutputDir, "assets");
45101
45526
  const manifestExists = await import("fs/promises").then(
45102
- (fs9) => fs9.access(manifestPath).then(() => true).catch(() => false)
45527
+ (fs10) => fs10.access(manifestPath).then(() => true).catch(() => false)
45103
45528
  );
45104
45529
  const assetsExist = await import("fs/promises").then(
45105
- (fs9) => fs9.access(assetsDir).then(() => true).catch(() => false)
45530
+ (fs10) => fs10.access(assetsDir).then(() => true).catch(() => false)
45106
45531
  );
45107
45532
  if (manifestExists && assetsExist) {
45108
45533
  logger.info("\u2705 Verified client assets are present");
@@ -45684,8 +46109,74 @@ function createStore(initialState, extend) {
45684
46109
  }
45685
46110
  __name(createStore, "createStore");
45686
46111
 
45687
- // src/client/link.tsx
46112
+ // src/theme/client.tsx
45688
46113
  var import_react13 = require("react");
46114
+ init_bridge2();
46115
+ var FALLBACK_CLIENT_SNAPSHOT = Object.freeze({
46116
+ theme: "system",
46117
+ resolvedTheme: "light",
46118
+ mounted: true
46119
+ });
46120
+ var cachedClientSnapshot = FALLBACK_CLIENT_SNAPSHOT;
46121
+ function snapshotsMatch(left, right) {
46122
+ return left.theme === right.theme && left.resolvedTheme === right.resolvedTheme && left.mounted === right.mounted;
46123
+ }
46124
+ __name(snapshotsMatch, "snapshotsMatch");
46125
+ function getClientSnapshot() {
46126
+ const next = typeof window === "undefined" ? FALLBACK_CLIENT_SNAPSHOT : window.__FARM_THEME__?.snapshot;
46127
+ if (!next) return cachedClientSnapshot;
46128
+ if (!snapshotsMatch(cachedClientSnapshot, next)) cachedClientSnapshot = next;
46129
+ return cachedClientSnapshot;
46130
+ }
46131
+ __name(getClientSnapshot, "getClientSnapshot");
46132
+ function getHydrationSnapshot() {
46133
+ if (typeof window !== "undefined" && window.__FARM_THEME__?.serverSnapshot) {
46134
+ return window.__FARM_THEME__.serverSnapshot;
46135
+ }
46136
+ return getFarmThemeServerSnapshot();
46137
+ }
46138
+ __name(getHydrationSnapshot, "getHydrationSnapshot");
46139
+ function subscribe(listener) {
46140
+ if (typeof window === "undefined") return () => {
46141
+ };
46142
+ const handleThemeChange = /* @__PURE__ */ __name(() => {
46143
+ getClientSnapshot();
46144
+ listener();
46145
+ }, "handleThemeChange");
46146
+ window.addEventListener("farm:themechange", handleThemeChange);
46147
+ return () => window.removeEventListener("farm:themechange", handleThemeChange);
46148
+ }
46149
+ __name(subscribe, "subscribe");
46150
+ function getTheme2() {
46151
+ return getClientSnapshot();
46152
+ }
46153
+ __name(getTheme2, "getTheme");
46154
+ function setTheme(theme) {
46155
+ const runtime = typeof window === "undefined" ? void 0 : window.__FARM_THEME__;
46156
+ if (!runtime) {
46157
+ throw new Error("The FARMJS theme runtime is not enabled. Add `theme` to farm.config.ts.");
46158
+ }
46159
+ runtime.setTheme(theme);
46160
+ }
46161
+ __name(setTheme, "setTheme");
46162
+ function toggleTheme() {
46163
+ const next = getClientSnapshot().resolvedTheme === "dark" ? "light" : "dark";
46164
+ setTheme(next);
46165
+ return next;
46166
+ }
46167
+ __name(toggleTheme, "toggleTheme");
46168
+ function useTheme() {
46169
+ const snapshot = (0, import_react13.useSyncExternalStore)(subscribe, getClientSnapshot, getHydrationSnapshot);
46170
+ return {
46171
+ ...snapshot,
46172
+ setTheme,
46173
+ toggleTheme
46174
+ };
46175
+ }
46176
+ __name(useTheme, "useTheme");
46177
+
46178
+ // src/client/link.tsx
46179
+ var import_react14 = require("react");
45689
46180
  init_router();
45690
46181
  init_client_runtime();
45691
46182
  var import_jsx_runtime5 = require("react/jsx-runtime");
@@ -45747,9 +46238,9 @@ function LinkInner({
45747
46238
  onTouchStart,
45748
46239
  ...props
45749
46240
  }, ref) {
45750
- const elementRef = (0, import_react13.useRef)(null);
45751
- const intentTimeoutRef = (0, import_react13.useRef)(null);
45752
- const hasPrefetched = (0, import_react13.useRef)(false);
46241
+ const elementRef = (0, import_react14.useRef)(null);
46242
+ const intentTimeoutRef = (0, import_react14.useRef)(null);
46243
+ const hasPrefetched = (0, import_react14.useRef)(false);
45753
46244
  const { intent, viewport, render } = normalizePrefetch(prefetch2);
45754
46245
  const baseHref = resolveLinkHref(href, params, {
45755
46246
  query,
@@ -45758,17 +46249,17 @@ function LinkInner({
45758
46249
  });
45759
46250
  const resolvedHref = localizeActiveFarmHref(baseHref, locale);
45760
46251
  const isExternal = isExternalUrl(resolvedHref);
45761
- const doPrefetch = (0, import_react13.useCallback)(() => {
46252
+ const doPrefetch = (0, import_react14.useCallback)(() => {
45762
46253
  if (isExternal || hasPrefetched.current) return;
45763
46254
  const router = getRouter2();
45764
46255
  if (!router) return;
45765
46256
  hasPrefetched.current = true;
45766
46257
  router.prefetch(resolvedHref);
45767
46258
  }, [resolvedHref, isExternal]);
45768
- (0, import_react13.useEffect)(() => {
46259
+ (0, import_react14.useEffect)(() => {
45769
46260
  hasPrefetched.current = false;
45770
46261
  }, [resolvedHref]);
45771
- (0, import_react13.useEffect)(() => {
46262
+ (0, import_react14.useEffect)(() => {
45772
46263
  const element = elementRef.current;
45773
46264
  if (!element || isExternal) return;
45774
46265
  const router = getRouter2();
@@ -45778,7 +46269,7 @@ function LinkInner({
45778
46269
  return () => router.unobserveForPrefetch(element);
45779
46270
  }
45780
46271
  }, [resolvedHref, viewport, isExternal]);
45781
- (0, import_react13.useEffect)(() => {
46272
+ (0, import_react14.useEffect)(() => {
45782
46273
  if (!render || isExternal) return;
45783
46274
  let cancelled = false;
45784
46275
  let timeoutId = null;
@@ -45800,7 +46291,7 @@ function LinkInner({
45800
46291
  }
45801
46292
  };
45802
46293
  }, [render, isExternal, resolvedHref]);
45803
- (0, import_react13.useEffect)(() => {
46294
+ (0, import_react14.useEffect)(() => {
45804
46295
  return () => {
45805
46296
  if (intentTimeoutRef.current) {
45806
46297
  clearTimeout(intentTimeoutRef.current);
@@ -45808,13 +46299,13 @@ function LinkInner({
45808
46299
  }
45809
46300
  };
45810
46301
  }, []);
45811
- const cancelIntent = (0, import_react13.useCallback)(() => {
46302
+ const cancelIntent = (0, import_react14.useCallback)(() => {
45812
46303
  if (intentTimeoutRef.current) {
45813
46304
  clearTimeout(intentTimeoutRef.current);
45814
46305
  intentTimeoutRef.current = null;
45815
46306
  }
45816
46307
  }, []);
45817
- const scheduleIntentPrefetch = (0, import_react13.useCallback)(() => {
46308
+ const scheduleIntentPrefetch = (0, import_react14.useCallback)(() => {
45818
46309
  if (isExternal || !intent || hasPrefetched.current) return;
45819
46310
  cancelIntent();
45820
46311
  intentTimeoutRef.current = setTimeout(() => {
@@ -45822,42 +46313,42 @@ function LinkInner({
45822
46313
  doPrefetch();
45823
46314
  }, prefetchDelay);
45824
46315
  }, [intent, isExternal, prefetchDelay, doPrefetch, cancelIntent]);
45825
- const handleMouseEnter = (0, import_react13.useCallback)(
46316
+ const handleMouseEnter = (0, import_react14.useCallback)(
45826
46317
  (event) => {
45827
46318
  onMouseEnter?.(event);
45828
46319
  scheduleIntentPrefetch();
45829
46320
  },
45830
46321
  [onMouseEnter, scheduleIntentPrefetch]
45831
46322
  );
45832
- const handleMouseLeave = (0, import_react13.useCallback)(
46323
+ const handleMouseLeave = (0, import_react14.useCallback)(
45833
46324
  (event) => {
45834
46325
  onMouseLeave?.(event);
45835
46326
  cancelIntent();
45836
46327
  },
45837
46328
  [onMouseLeave, cancelIntent]
45838
46329
  );
45839
- const handleTouchStart = (0, import_react13.useCallback)(
46330
+ const handleTouchStart = (0, import_react14.useCallback)(
45840
46331
  (event) => {
45841
46332
  onTouchStart?.(event);
45842
46333
  scheduleIntentPrefetch();
45843
46334
  },
45844
46335
  [onTouchStart, scheduleIntentPrefetch]
45845
46336
  );
45846
- const handleFocus = (0, import_react13.useCallback)(
46337
+ const handleFocus = (0, import_react14.useCallback)(
45847
46338
  (event) => {
45848
46339
  onFocus?.(event);
45849
46340
  scheduleIntentPrefetch();
45850
46341
  },
45851
46342
  [onFocus, scheduleIntentPrefetch]
45852
46343
  );
45853
- const handleBlur = (0, import_react13.useCallback)(
46344
+ const handleBlur = (0, import_react14.useCallback)(
45854
46345
  (event) => {
45855
46346
  onBlur?.(event);
45856
46347
  cancelIntent();
45857
46348
  },
45858
46349
  [onBlur, cancelIntent]
45859
46350
  );
45860
- const handleClick = (0, import_react13.useCallback)(
46351
+ const handleClick = (0, import_react14.useCallback)(
45861
46352
  (event) => {
45862
46353
  onClick?.(event);
45863
46354
  if (event.defaultPrevented) return;
@@ -45882,7 +46373,7 @@ function LinkInner({
45882
46373
  },
45883
46374
  [resolvedHref, replace, scroll, viewTransition, target, isExternal, onClick]
45884
46375
  );
45885
- const setRefs = (0, import_react13.useCallback)(
46376
+ const setRefs = (0, import_react14.useCallback)(
45886
46377
  (node) => {
45887
46378
  elementRef.current = node;
45888
46379
  if (typeof ref === "function") ref(node);
@@ -45911,7 +46402,7 @@ function LinkInner({
45911
46402
  );
45912
46403
  }
45913
46404
  __name(LinkInner, "LinkInner");
45914
- var LinkWithRef = (0, import_react13.forwardRef)(LinkInner);
46405
+ var LinkWithRef = (0, import_react14.forwardRef)(LinkInner);
45915
46406
  LinkWithRef.displayName = "Link";
45916
46407
  var Link = LinkWithRef;
45917
46408
  function resolveLinkHref(href, params, options) {
@@ -46299,10 +46790,10 @@ var _FarmClientPluginManager = class _FarmClientPluginManager {
46299
46790
  if (session.signal.aborted) return Promise.resolve();
46300
46791
  const clientWindow = this.options.window;
46301
46792
  const schedule = clientWindow?.requestAnimationFrame ? (callback) => clientWindow.requestAnimationFrame(() => clientWindow.requestAnimationFrame(callback)) : (callback) => setTimeout(callback, 0);
46302
- return new Promise((resolve6) => {
46793
+ return new Promise((resolve7) => {
46303
46794
  schedule(() => {
46304
46795
  if (session.signal.aborted || this.closed) {
46305
- resolve6();
46796
+ resolve7();
46306
46797
  return;
46307
46798
  }
46308
46799
  void this.runHook(
@@ -46316,7 +46807,7 @@ var _FarmClientPluginManager = class _FarmClientPluginManager {
46316
46807
  if (this.currentNavigation?.session === session) {
46317
46808
  this.currentNavigation = void 0;
46318
46809
  }
46319
- resolve6();
46810
+ resolve7();
46320
46811
  });
46321
46812
  });
46322
46813
  });
@@ -46851,6 +47342,7 @@ __name(decodeCookiePart, "decodeCookiePart");
46851
47342
  getServerActionInvalidations,
46852
47343
  getServerActionSignal,
46853
47344
  getStorage,
47345
+ getTheme,
46854
47346
  globFiles,
46855
47347
  hasFarmRouteRuntimeControls,
46856
47348
  hasISR,
@@ -46967,6 +47459,7 @@ __name(decodeCookiePart, "decodeCookiePart");
46967
47459
  resolveFarmLayoutFonts,
46968
47460
  resolveFarmRouteRuleRuntimeConfig,
46969
47461
  resolveFarmRouteRuntimeConfig,
47462
+ resolveFarmThemeConfig,
46970
47463
  resolveIntegrationOrmRuntimeClient,
46971
47464
  resolveIntegrationPlugins,
46972
47465
  resolveMarkdownConfig,
@@ -46993,12 +47486,14 @@ __name(decodeCookiePart, "decodeCookiePart");
46993
47486
  segmentsToPattern,
46994
47487
  serverEnv,
46995
47488
  setEnv,
47489
+ setTheme,
46996
47490
  snapshotDeferredData,
46997
47491
  sqliteStorage,
46998
47492
  storageCacheAdapter,
46999
47493
  titleFromMarkdown,
47000
47494
  toFormData,
47001
47495
  toViteModuleId,
47496
+ toggleTheme,
47002
47497
  unstable_cache,
47003
47498
  unwrapMiddleware,
47004
47499
  updateTag,
@@ -47014,6 +47509,7 @@ __name(decodeCookiePart, "decodeCookiePart");
47014
47509
  useSearchParams,
47015
47510
  useServerFn,
47016
47511
  useServerQuery,
47512
+ useTheme,
47017
47513
  validateServerActionRequest,
47018
47514
  vercelBlobStorage,
47019
47515
  vercelKVStorage,