@farm.js/core 0.1.70 → 0.1.71

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 (184) hide show
  1. package/dist/{agent-mcp-handler-6T2Z7TB6.cjs → agent-mcp-handler-KE4J3W7S.cjs} +3 -3
  2. package/dist/{agent-mcp-handler-CPU354QQ.mjs → agent-mcp-handler-VIT4GOSR.mjs} +2 -2
  3. package/dist/{agent-mcp.d-DulgFLBt.d.ts → agent-mcp.d-BzNw6JI8.d.ts} +14 -4
  4. package/dist/{agent-mcp.d-TAs1ES2F.d.mts → agent-mcp.d-CgFen3EH.d.mts} +14 -4
  5. package/dist/agent-runtime.d.mts +1 -1
  6. package/dist/agent-runtime.d.ts +1 -1
  7. package/dist/analyzer-LPIVRSTJ.cjs +16 -0
  8. package/dist/{analyzer-QGRBLETM.mjs → analyzer-VK3BAOFI.mjs} +2 -2
  9. package/dist/api/node.d.mts +3 -3
  10. package/dist/api/node.d.ts +3 -3
  11. package/dist/api/route-manager.d.mts +3 -3
  12. package/dist/api/route-manager.d.ts +3 -3
  13. package/dist/api/runtime.d.mts +2 -2
  14. package/dist/api/runtime.d.ts +2 -2
  15. package/dist/api.d.mts +4 -4
  16. package/dist/api.d.ts +4 -4
  17. package/dist/{app-manifest.d-C-nf3Vmm.d.ts → app-manifest.d-DY4JfJxi.d.ts} +1 -1
  18. package/dist/{app-manifest.d-6zXb90o6.d.mts → app-manifest.d-DpDK_B1k.d.mts} +1 -1
  19. package/dist/app-markdown.cjs +5 -3
  20. package/dist/app-markdown.d.mts +3 -3
  21. package/dist/app-markdown.d.ts +3 -3
  22. package/dist/app-markdown.mjs +4 -2
  23. package/dist/{app.d-C2xeMIYT.d.ts → app.d-BeK6bb1c.d.ts} +8 -6
  24. package/dist/{app.d-DF0aundc.d.mts → app.d-D-5UNrFd.d.mts} +8 -6
  25. package/dist/{chunk-HAXFV2CD.mjs → chunk-2CQC5CMD.mjs} +1 -1
  26. package/dist/{chunk-IEN2EFE5.cjs → chunk-2IFT2CSA.cjs} +4 -4
  27. package/dist/{chunk-BPUVDCGG.cjs → chunk-3BQ7QHUH.cjs} +3 -3
  28. package/dist/{chunk-JFVT5ZZV.mjs → chunk-4OD2LXF2.mjs} +1 -1
  29. package/dist/{chunk-CCHJWJGP.mjs → chunk-7BUE2GM6.mjs} +141 -86
  30. package/dist/{chunk-FJ5YCERM.cjs → chunk-7OHJWFLB.cjs} +387 -331
  31. package/dist/{chunk-5R3JQPWD.mjs → chunk-AYVGD3PK.mjs} +1 -1
  32. package/dist/{chunk-K7JMTAFH.cjs → chunk-CSQPMV3Q.cjs} +16 -6
  33. package/dist/{chunk-N62IYXYD.mjs → chunk-DPIGYXSV.mjs} +1 -1
  34. package/dist/{chunk-LECZ5DPZ.cjs → chunk-DPYBVVL3.cjs} +2 -2
  35. package/dist/{chunk-RMOU3PR4.mjs → chunk-GUU3IZSM.mjs} +63 -23
  36. package/dist/{chunk-EDZU7YRK.mjs → chunk-IGXS54GC.mjs} +2 -2
  37. package/dist/{chunk-3WS5AZ3R.mjs → chunk-IYDJNCR7.mjs} +1 -1
  38. package/dist/{chunk-R7254L3R.mjs → chunk-J5ASGNKF.mjs} +23 -0
  39. package/dist/{chunk-75E5FDX2.mjs → chunk-JMFTKNBA.mjs} +10 -10
  40. package/dist/{chunk-DIHBWZDZ.cjs → chunk-JVA4PIYN.cjs} +408 -294
  41. package/dist/{chunk-XYVPTTUT.cjs → chunk-KEB7AGS6.cjs} +4 -4
  42. package/dist/{chunk-TLSSIYAL.mjs → chunk-KQAB5LML.mjs} +10 -3
  43. package/dist/{chunk-M6U6E4F7.cjs → chunk-KWST2O22.cjs} +108 -68
  44. package/dist/{chunk-NSZY3EWG.cjs → chunk-L6E4SHUB.cjs} +31 -8
  45. package/dist/{chunk-MZLJFNMH.cjs → chunk-MEJCP2LX.cjs} +1 -1
  46. package/dist/{chunk-A2TH5MKE.mjs → chunk-MITIAOUQ.mjs} +3 -3
  47. package/dist/{chunk-OCNV4CI2.cjs → chunk-MQ4DYVFS.cjs} +26 -0
  48. package/dist/{chunk-4AC4PXZO.cjs → chunk-N3XO5AL5.cjs} +2 -2
  49. package/dist/{chunk-R2ZHU37O.mjs → chunk-NLRAQXAA.mjs} +26 -0
  50. package/dist/{chunk-32SYRIQ7.cjs → chunk-PLXD2MJV.cjs} +3 -3
  51. package/dist/{chunk-JFPKARWM.cjs → chunk-PMU4U2W2.cjs} +1 -0
  52. package/dist/{chunk-3EXCZJEN.mjs → chunk-QUFENL7Q.mjs} +1 -1
  53. package/dist/{chunk-NYF7A4UW.mjs → chunk-RJUCNO7R.mjs} +1 -1
  54. package/dist/{chunk-K4UGCUXX.cjs → chunk-SXMWVP2L.cjs} +7 -7
  55. package/dist/{chunk-VG6HYT5K.cjs → chunk-TP4RAV7Y.cjs} +9 -9
  56. package/dist/{chunk-I7NUT24Z.cjs → chunk-UISZLYKY.cjs} +2 -2
  57. package/dist/{chunk-KPMLDT3B.mjs → chunk-UQUOSNRN.mjs} +378 -264
  58. package/dist/{chunk-QZHTDVH4.mjs → chunk-V25GSH43.mjs} +1 -1
  59. package/dist/{chunk-65FPDDT4.cjs → chunk-VXB5CMNC.cjs} +2 -2
  60. package/dist/{chunk-5IJRJWJS.mjs → chunk-W2T6NDNP.mjs} +10 -0
  61. package/dist/{chunk-JRF2SKCD.mjs → chunk-X7LGLF33.mjs} +1 -1
  62. package/dist/{chunk-QEWWKYDL.cjs → chunk-YCNHUIPR.cjs} +17 -10
  63. package/dist/{chunk-PJQ5W356.mjs → chunk-Z5ZZAGIH.mjs} +1 -0
  64. package/dist/{chunk-A7HCBHMC.cjs → chunk-ZPUAOKHV.cjs} +3 -3
  65. package/dist/{client-component.d-Bk5qKJM-.d.mts → client-component.d-DwpH251K.d.mts} +2 -2
  66. package/dist/{client-component.d-DNbC4oWI.d.ts → client-component.d-fYupugbZ.d.ts} +2 -2
  67. package/dist/{client-plugins.d-DwUqh4gp.d.ts → client-plugins.d-BxqFfHpM.d.ts} +8 -5
  68. package/dist/{client-plugins.d-Pi9nG0W0.d.mts → client-plugins.d-k3bOT5gz.d.mts} +8 -5
  69. package/dist/client-plugins.d.mts +1 -1
  70. package/dist/client-plugins.d.ts +1 -1
  71. package/dist/client.d.mts +6 -6
  72. package/dist/client.d.ts +6 -6
  73. package/dist/config.d.mts +1 -1
  74. package/dist/config.d.ts +1 -1
  75. package/dist/desktop.d.mts +2 -2
  76. package/dist/desktop.d.ts +2 -2
  77. package/dist/{devtools-CB43AHEP.mjs → devtools-6MXPFPNJ.mjs} +2 -2
  78. package/dist/{devtools-L5DUNDF3.cjs → devtools-O5625KCK.cjs} +3 -3
  79. package/dist/docs.cjs +4 -4
  80. package/dist/docs.d.mts +2 -2
  81. package/dist/docs.d.ts +2 -2
  82. package/dist/docs.mjs +3 -3
  83. package/dist/environment/vite.cjs +3 -3
  84. package/dist/environment/vite.mjs +2 -2
  85. package/dist/{headers.d-CE6OWB-n.d.ts → headers.d-DalIGbVO.d.ts} +1 -1
  86. package/dist/{headers.d-DED1hHh4.d.mts → headers.d-sNT7ZQiU.d.mts} +1 -1
  87. package/dist/index.cjs +20 -18
  88. package/dist/{index.d-c9UwIqDy.d.ts → index.d-BcA-secm.d.ts} +1 -1
  89. package/dist/{index.d-CbvOjJcp.d.mts → index.d-DDHHAv7j.d.mts} +1 -1
  90. package/dist/index.d.mts +18 -18
  91. package/dist/index.d.ts +18 -18
  92. package/dist/index.mjs +19 -17
  93. package/dist/integrations/orm.d.mts +1 -1
  94. package/dist/integrations/orm.d.ts +1 -1
  95. package/dist/integrations.d.mts +1 -1
  96. package/dist/integrations.d.ts +1 -1
  97. package/dist/internal/app-markdown-runtime.cjs +4 -2
  98. package/dist/internal/app-markdown-runtime.d.mts +11 -3
  99. package/dist/internal/app-markdown-runtime.d.ts +11 -3
  100. package/dist/internal/app-markdown-runtime.mjs +3 -1
  101. package/dist/internal/build-runtime.cjs +19 -19
  102. package/dist/internal/build-runtime.d.mts +3 -3
  103. package/dist/internal/build-runtime.d.ts +3 -3
  104. package/dist/internal/build-runtime.mjs +18 -18
  105. package/dist/internal/cli-runtime.cjs +6 -4
  106. package/dist/internal/cli-runtime.mjs +5 -3
  107. package/dist/internal/client-error-overlay.cjs +4 -4
  108. package/dist/internal/client-error-overlay.mjs +1 -1
  109. package/dist/internal/client-runtime.d.mts +4 -4
  110. package/dist/internal/client-runtime.d.ts +4 -4
  111. package/dist/internal/compression-runtime.d.mts +1 -1
  112. package/dist/internal/compression-runtime.d.ts +1 -1
  113. package/dist/internal/config-runtime.cjs +4 -4
  114. package/dist/internal/config-runtime.d.mts +3 -3
  115. package/dist/internal/config-runtime.d.ts +3 -3
  116. package/dist/internal/config-runtime.mjs +3 -3
  117. package/dist/internal/infra-analytics-runtime.cjs +7 -7
  118. package/dist/internal/infra-analytics-runtime.mjs +5 -5
  119. package/dist/internal/native-server-fns.cjs +4 -4
  120. package/dist/internal/native-server-fns.mjs +3 -3
  121. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  122. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  123. package/dist/internal/production-runtime.cjs +6 -6
  124. package/dist/internal/production-runtime.d.mts +14 -9
  125. package/dist/internal/production-runtime.d.ts +14 -9
  126. package/dist/internal/production-runtime.mjs +5 -5
  127. package/dist/markdown.d.mts +1 -1
  128. package/dist/markdown.d.ts +1 -1
  129. package/dist/middleware.d.mts +1 -1
  130. package/dist/middleware.d.ts +1 -1
  131. package/dist/{mount.d-BvWxf8ZE.d.mts → mount.d-C1PONsEe.d.mts} +1 -1
  132. package/dist/{mount.d-DngLY7NL.d.ts → mount.d-D3JOux2V.d.ts} +1 -1
  133. package/dist/{navigation-delegate.d-CMyl1h2l.d.mts → navigation-delegate.d-CJQQHboA.d.mts} +1 -1
  134. package/dist/{navigation-delegate.d-zZogiDfa.d.ts → navigation-delegate.d-CQQPbdkE.d.ts} +1 -1
  135. package/dist/navigation.d.mts +4 -4
  136. package/dist/navigation.d.ts +4 -4
  137. package/dist/{nitro-Y3LGITW3.cjs → nitro-2LMOMIST.cjs} +2 -2
  138. package/dist/{nitro-NSTXT7LB.mjs → nitro-72TFIGGO.mjs} +1 -1
  139. package/dist/{plugin-F2O4BFTK.cjs → plugin-5PIQQVRP.cjs} +2 -2
  140. package/dist/{plugin-VEBRN7A3.mjs → plugin-QZT747YW.mjs} +1 -1
  141. package/dist/plugin.cjs +13 -13
  142. package/dist/plugin.d.mts +4 -4
  143. package/dist/plugin.d.ts +4 -4
  144. package/dist/plugin.mjs +12 -12
  145. package/dist/{render-plan.d-Di1znBDW.d.mts → render-plan.d-CiUj0rq5.d.mts} +1 -1
  146. package/dist/{render-plan.d-DQj2bzd2.d.ts → render-plan.d-DHuJMJRP.d.ts} +1 -1
  147. package/dist/renderer-client.d.mts +4 -4
  148. package/dist/renderer-client.d.ts +4 -4
  149. package/dist/{request.d-CJWzfDYJ.d.mts → request.d-D-F7o7tb.d.mts} +1 -1
  150. package/dist/{request.d-C5vyoYeL.d.ts → request.d-DRUbOmYD.d.ts} +1 -1
  151. package/dist/request.d.mts +2 -2
  152. package/dist/request.d.ts +2 -2
  153. package/dist/{route-rendering.d-C-et2TZ1.d.mts → route-rendering.d-6smgwT2t.d.mts} +1 -1
  154. package/dist/{route-rendering.d-DhsY5M2I.d.ts → route-rendering.d-KwqM_mlK.d.ts} +1 -1
  155. package/dist/{router.d-CJB-Ntni.d.ts → router.d-B6sesMRD.d.ts} +1 -1
  156. package/dist/{router.d-BMDS5s5X.d.mts → router.d-BYmDeDlp.d.mts} +1 -1
  157. package/dist/routes.d.mts +1 -1
  158. package/dist/routes.d.ts +1 -1
  159. package/dist/{rsc-pipeline-NJKLZ3YE.cjs → rsc-pipeline-P4PCWDO2.cjs} +4 -4
  160. package/dist/{rsc-pipeline-AXQJCCHI.mjs → rsc-pipeline-R2GOKIMU.mjs} +3 -3
  161. package/dist/{runtime-JXNEKOSE.mjs → runtime-DP5DYGW5.mjs} +3 -3
  162. package/dist/{runtime-DMW6DDOI.cjs → runtime-WA2Q4SLG.cjs} +5 -5
  163. package/dist/{runtime.d-BonodRI9.d.mts → runtime.d-BFSJf-ww.d.mts} +1 -1
  164. package/dist/{runtime.d-uw4123iI.d.ts → runtime.d-CbdMI0Oy.d.ts} +1 -1
  165. package/dist/server-plugins.d.mts +3 -3
  166. package/dist/server-plugins.d.ts +3 -3
  167. package/dist/server.cjs +33 -33
  168. package/dist/server.d.mts +10 -10
  169. package/dist/server.d.ts +10 -10
  170. package/dist/server.mjs +15 -15
  171. package/dist/{spa-router.d-rha3M95y.d.mts → spa-router.d-D4EDwR20.d.mts} +2 -2
  172. package/dist/{spa-router.d-l0d9pPZj.d.ts → spa-router.d-mC1D5cTN.d.ts} +2 -2
  173. package/dist/testing.d.mts +1 -1
  174. package/dist/testing.d.ts +1 -1
  175. package/dist/{utils.d-BK-PTOF8.d.ts → utils.d-A2X3a6z_.d.ts} +1 -1
  176. package/dist/{utils.d-BzuTobEc.d.mts → utils.d-DxMzteqE.d.mts} +1 -1
  177. package/dist/version.cjs +2 -2
  178. package/dist/version.mjs +1 -1
  179. package/dist/vite.cjs +13 -13
  180. package/dist/vite.d.mts +7 -5
  181. package/dist/vite.d.ts +7 -5
  182. package/dist/vite.mjs +12 -12
  183. package/package.json +2 -2
  184. package/dist/analyzer-GUIRJWZH.cjs +0 -16
@@ -26,7 +26,7 @@ import {
26
26
  import {
27
27
  collectFarmNativeServerFns,
28
28
  findFarmNativeScreenFiles
29
- } from "./chunk-HAXFV2CD.mjs";
29
+ } from "./chunk-2CQC5CMD.mjs";
30
30
  import {
31
31
  generateNativeMCPPluginSource
32
32
  } from "./chunk-KQH2COEJ.mjs";
@@ -41,7 +41,7 @@ import {
41
41
  hasFarmDocsRuntimeAdapter,
42
42
  listFarmDocsAdapterPages,
43
43
  listFarmDocsPagePaths
44
- } from "./chunk-JFVT5ZZV.mjs";
44
+ } from "./chunk-4OD2LXF2.mjs";
45
45
  import {
46
46
  FARM_DOCS_LAST_MODIFIED_MANIFEST,
47
47
  createFarmDocsHandler,
@@ -65,7 +65,7 @@ import {
65
65
  } from "./chunk-OAEDVXVE.mjs";
66
66
  import {
67
67
  FARM_PRERENDER_ENV
68
- } from "./chunk-3EXCZJEN.mjs";
68
+ } from "./chunk-QUFENL7Q.mjs";
69
69
  import {
70
70
  loadFarmDocsEngine
71
71
  } from "./chunk-VE3FWJBO.mjs";
@@ -74,7 +74,7 @@ import {
74
74
  getDeployTargetForPreset,
75
75
  hasCustomFarmRouteContext,
76
76
  resolveDeployOutputPath
77
- } from "./chunk-3WS5AZ3R.mjs";
77
+ } from "./chunk-IYDJNCR7.mjs";
78
78
  import {
79
79
  resolveFarmInstrumentationFile
80
80
  } from "./chunk-57QAQU4F.mjs";
@@ -110,7 +110,7 @@ import {
110
110
  resolveFarmImageServerRuntime,
111
111
  resolveFarmNotFoundComponentPath,
112
112
  resolveFarmRouteRootStrategy
113
- } from "./chunk-RMOU3PR4.mjs";
113
+ } from "./chunk-GUU3IZSM.mjs";
114
114
  import {
115
115
  generateFarmClientPluginEntryCode,
116
116
  hasFarmServerRuntimePlugins,
@@ -118,12 +118,12 @@ import {
118
118
  } from "./chunk-I4KPA2C6.mjs";
119
119
  import {
120
120
  PluginManager
121
- } from "./chunk-PJQ5W356.mjs";
121
+ } from "./chunk-Z5ZZAGIH.mjs";
122
122
  import {
123
123
  generateFarmTypeArtifacts,
124
124
  readRouteRenderingDirectiveFromFile,
125
125
  resolveRouteRenderingConfigFromFile
126
- } from "./chunk-5IJRJWJS.mjs";
126
+ } from "./chunk-W2T6NDNP.mjs";
127
127
  import {
128
128
  HOISTED_HEAD_ELEMENT,
129
129
  appMiddlewareMayHandlePath,
@@ -150,15 +150,15 @@ import {
150
150
  listFarmBuiltInRoutePaths,
151
151
  resolveFarmApiCatalogInput,
152
152
  resolveFarmAppManifestInput
153
- } from "./chunk-A2TH5MKE.mjs";
153
+ } from "./chunk-MITIAOUQ.mjs";
154
154
  import {
155
155
  FARM_DEFAULT_MCP_PATH,
156
156
  createFarmDefaultMCPServer,
157
157
  farmConfigMountsMCP
158
- } from "./chunk-75E5FDX2.mjs";
158
+ } from "./chunk-JMFTKNBA.mjs";
159
159
  import {
160
160
  isFarmPreviewDeploymentEnvironment
161
- } from "./chunk-QZHTDVH4.mjs";
161
+ } from "./chunk-V25GSH43.mjs";
162
162
  import {
163
163
  FARM_NATIVE_SERVER_FN_PLUGIN
164
164
  } from "./chunk-L4RTTTVE.mjs";
@@ -176,7 +176,7 @@ import {
176
176
  usePackageClientBoundaryCacheFile,
177
177
  usesFarmServerTree,
178
178
  withPackageClientBoundaryCache
179
- } from "./chunk-JRF2SKCD.mjs";
179
+ } from "./chunk-X7LGLF33.mjs";
180
180
  import {
181
181
  generateFarmDocsAdapterClientRuntime,
182
182
  getFarmDocsAdapterConfigModule
@@ -188,7 +188,7 @@ import {
188
188
  import {
189
189
  nitroRouteRulesBelowBasePath,
190
190
  routeRulesToNitroRouteRules
191
- } from "./chunk-R2ZHU37O.mjs";
191
+ } from "./chunk-NLRAQXAA.mjs";
192
192
  import {
193
193
  applyFarmCspHashesToHtml,
194
194
  createFarmCspNonce
@@ -223,7 +223,7 @@ import {
223
223
  } from "./chunk-N33DLJBC.mjs";
224
224
  import {
225
225
  isFarmMarkdownPageFile
226
- } from "./chunk-R7254L3R.mjs";
226
+ } from "./chunk-J5ASGNKF.mjs";
227
227
  import {
228
228
  resolveFarmMdxComponentsModulePath,
229
229
  resolveMdxConfig
@@ -264,6 +264,7 @@ import {
264
264
  } from "./chunk-NR63PD3P.mjs";
265
265
  import {
266
266
  createFarmRouteRuntimeKey,
267
+ farmRouteRuleMatches,
267
268
  getFarmRouteRuntimeConfig,
268
269
  hasFarmRouteRuntimeControls,
269
270
  mergeFarmRouteRuntimeConfigs,
@@ -282,7 +283,7 @@ import {
282
283
  } from "./chunk-2I6PUKWJ.mjs";
283
284
  import {
284
285
  FARM_VERSION
285
- } from "./chunk-NYF7A4UW.mjs";
286
+ } from "./chunk-RJUCNO7R.mjs";
286
287
  import {
287
288
  normalizeFarmTrailingSlashPathname
288
289
  } from "./chunk-4O26BPUY.mjs";
@@ -303,7 +304,7 @@ import {
303
304
  } from "./chunk-AYP2YFVN.mjs";
304
305
 
305
306
  // src/build/index.ts
306
- import path13 from "path";
307
+ import path14 from "path";
307
308
  import { existsSync as existsSync3 } from "fs";
308
309
 
309
310
  // src/nitro/universal-build.ts
@@ -368,7 +369,7 @@ async function resolveHashedClientJsSrc(clientOutputDir) {
368
369
 
369
370
  // src/nitro/universal-build.ts
370
371
  import os from "os";
371
- import path12 from "path";
372
+ import path13 from "path";
372
373
  import { constants as fsConstants, existsSync as existsSync2, readFileSync, realpathSync as realpathSync2, statSync } from "fs";
373
374
  import { fileURLToPath } from "url";
374
375
  import { builtinModules, createRequire as createRequire2 } from "module";
@@ -612,6 +613,7 @@ function collectFarmClientModulePreloads(bundle, options) {
612
613
  function createFarmClientModulePreloadPlugin(options) {
613
614
  return {
614
615
  name: "farm-client-module-preloads",
616
+ enforce: "post",
615
617
  async generateBundle(_output, bundle) {
616
618
  await fs.mkdir(options.buildDir, { recursive: true });
617
619
  await fs.writeFile(
@@ -686,6 +688,8 @@ function createFarmDocsModulePreloadPlugin(options) {
686
688
  let runtimeModuleIds = [];
687
689
  return {
688
690
  name: "farm-docs-module-preloads",
691
+ // After Vite's CSS plugin deletes stylesheet-only chunks (see client-module-preloads.ts).
692
+ enforce: "post",
689
693
  async buildStart() {
690
694
  const resolved = await Promise.all(
691
695
  options.modules.map((specifier) => this.resolve(specifier, options.importer))
@@ -950,12 +954,65 @@ function escapeRegExp(value) {
950
954
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
951
955
  }
952
956
 
953
- // src/nitro/vercel-assets.ts
957
+ // src/nitro/immutable-assets.ts
958
+ import path7 from "path";
954
959
  var FARM_IMMUTABLE_ASSET_CACHE_CONTROL = "public, max-age=31536000, immutable";
960
+ var FARM_IMMUTABLE_ASSET_MAX_AGE = 31536e3;
961
+ var FARM_IMMUTABLE_ASSET_PATH_SOURCE = "^/(?:(?:assets|chunks)/(?:.+/)*[^/]+|farm-(?:mobile-)?client(?:-boot)?)-h(?:[a-fA-F0-9]{8}|[a-fA-F0-9]{12}|[a-fA-F0-9]{16})\\.(?!(?:[hH][tT][mM][lL]?)$)[^/]+$";
962
+ var FARM_IMMUTABLE_ASSET_PATH = new RegExp(FARM_IMMUTABLE_ASSET_PATH_SOURCE);
963
+ function isFarmImmutableAssetPath(pathname) {
964
+ return FARM_IMMUTABLE_ASSET_PATH.test(pathname);
965
+ }
966
+ var FARM_HASHED_ASSET_DIRS = ["assets", "chunks"];
967
+ var LITERAL_ROUTE_PATH = /^\/[\w.~@/-]+$/;
968
+ function planFarmImmutableAssets(options) {
969
+ const cacheRulePatterns = Object.entries(options.routeRules ?? {}).filter(
970
+ ([, rule]) => Object.keys(rule?.headers ?? {}).some((name) => name.toLowerCase() === "cache-control")
971
+ ).map(([pattern]) => pattern);
972
+ const isImmutable = (file) => isFarmImmutableAssetPath(file) && !cacheRulePatterns.some((pattern) => farmRouteRuleMatches(pattern, file));
973
+ const routeDirs = new Set(
974
+ (options.routePaths ?? []).map((routePath) => routePath.split("/").filter(Boolean)[0])
975
+ );
976
+ const plan = { publicAssets: [], routeRules: {} };
977
+ const addRule = (file) => {
978
+ if (!LITERAL_ROUTE_PATH.test(file)) return;
979
+ plan.routeRules[file] = { headers: { "cache-control": FARM_IMMUTABLE_ASSET_CACHE_CONTROL } };
980
+ };
981
+ const dirFiles = /* @__PURE__ */ new Map();
982
+ for (const file of options.files) {
983
+ const dir = file.split("/")[1];
984
+ if (file.split("/").length > 2 && FARM_HASHED_ASSET_DIRS.includes(dir)) {
985
+ dirFiles.set(dir, [...dirFiles.get(dir) ?? [], file]);
986
+ } else if (isImmutable(file)) {
987
+ addRule(file);
988
+ }
989
+ }
990
+ for (const [dir, files] of dirFiles) {
991
+ if (!routeDirs.has(dir) && files.every(isImmutable)) {
992
+ plan.publicAssets.push({
993
+ dir: path7.join(options.clientOutputDir, dir),
994
+ baseURL: `/${dir}`,
995
+ maxAge: FARM_IMMUTABLE_ASSET_MAX_AGE
996
+ });
997
+ } else {
998
+ for (const file of files) if (isImmutable(file)) addRule(file);
999
+ }
1000
+ }
1001
+ return plan;
1002
+ }
1003
+ async function listFarmClientOutputFiles(dir) {
1004
+ const fs4 = await import("fs/promises");
1005
+ const entries = await fs4.readdir(dir, { recursive: true, withFileTypes: true }).catch(() => []);
1006
+ return entries.filter((entry) => entry.isFile()).map((entry) => {
1007
+ const relative = path7.relative(dir, path7.join(entry.parentPath, entry.name));
1008
+ return `/${relative.split(path7.sep).join("/")}`;
1009
+ });
1010
+ }
1011
+
1012
+ // src/nitro/vercel-assets.ts
955
1013
  function createFarmVercelImmutableAssetRoute() {
956
- const fingerprint = "-h(?:[a-fA-F0-9]{8}|[a-fA-F0-9]{12}|[a-fA-F0-9]{16})";
957
1014
  return {
958
- src: `^/(?:(?:assets|chunks)/(?:.+/)*[^/]+|farm-client)${fingerprint}\\.(?!(?:[hH][tT][mM][lL]?)$)[^/]+$`,
1015
+ src: FARM_IMMUTABLE_ASSET_PATH_SOURCE,
959
1016
  headers: {
960
1017
  "Cache-Control": FARM_IMMUTABLE_ASSET_CACHE_CONTROL
961
1018
  },
@@ -995,7 +1052,7 @@ function createFarmVercelCanonicalSlashRoutes(publicPaths) {
995
1052
  }
996
1053
 
997
1054
  // src/nitro/ssr-public-assets.ts
998
- import path7 from "path";
1055
+ import path8 from "path";
999
1056
  var SERVER_FILE_URL_RE = /new\s+URL\(\s*(["'`])([^"'`\\]+)\1\s*,\s*import\.meta\.url\s*\)/g;
1000
1057
  function resolveBundleFileName(chunkFileName, relativeUrl) {
1001
1058
  if (relativeUrl.startsWith("/") || /^[a-z][a-z\d+.-]*:/i.test(relativeUrl)) return null;
@@ -1004,8 +1061,8 @@ function resolveBundleFileName(chunkFileName, relativeUrl) {
1004
1061
  relativePath = decodeURI(relativePath);
1005
1062
  } catch {
1006
1063
  }
1007
- const fileName = path7.posix.normalize(
1008
- path7.posix.join(path7.posix.dirname(chunkFileName), relativePath)
1064
+ const fileName = path8.posix.normalize(
1065
+ path8.posix.join(path8.posix.dirname(chunkFileName), relativePath)
1009
1066
  );
1010
1067
  return fileName.startsWith("../") ? null : fileName;
1011
1068
  }
@@ -1049,7 +1106,7 @@ function collectServerOnlySSRAssets(bundle) {
1049
1106
  }
1050
1107
  }
1051
1108
  for (const fileName of serverOnly) {
1052
- const name = path7.posix.basename(fileName);
1109
+ const name = path8.posix.basename(fileName);
1053
1110
  if (publicReferenceSources.some((source) => source.includes(name))) {
1054
1111
  serverOnly.delete(fileName);
1055
1112
  }
@@ -1067,7 +1124,7 @@ function assertServerReadSSRAssetsSupported(bundle, preset, root) {
1067
1124
  const output = bundle[fileName];
1068
1125
  const original = output?.type === "asset" ? output.originalFileNames?.[0] : void 0;
1069
1126
  if (!original) return fileName;
1070
- return path7.relative(root, path7.resolve(root, original)).split(path7.sep).join("/");
1127
+ return path8.relative(root, path8.resolve(root, original)).split(path8.sep).join("/");
1071
1128
  });
1072
1129
  throw new Error(
1073
1130
  `The "${preset}" preset cannot run server code that imports ${sources.join(", ")}. Server code reads such a file from beside the server bundle, and this edge runtime deploys no such file (Cloudflare Workers and Vercel Edge also refuse to compile WebAssembly from bytes). Load it in the browser instead, from client code with the @farm.js/wasm plugin or a "?url" import, or deploy to a Node target such as node-server, bun, vercel or netlify.`
@@ -1083,7 +1140,7 @@ function createServerReadSSRAssetsPlugin(bundle, ssrOutputDir) {
1083
1140
  },
1084
1141
  transform(code, id) {
1085
1142
  if (!code.includes("import.meta.url")) return null;
1086
- const chunkFileName = path7.relative(ssrOutputDir, id.split("?", 1)[0]).split(path7.sep).join("/");
1143
+ const chunkFileName = path8.relative(ssrOutputDir, id.split("?", 1)[0]).split(path8.sep).join("/");
1087
1144
  if (bundle[chunkFileName]?.type !== "chunk") return null;
1088
1145
  let changed = false;
1089
1146
  const transformed = replaceServerFileReferences(
@@ -1111,10 +1168,10 @@ function createServerReadSSRAssetsPlugin(bundle, ssrOutputDir) {
1111
1168
 
1112
1169
  // src/nitro/netlify-entry.ts
1113
1170
  import { existsSync } from "fs";
1114
- import path8 from "path";
1171
+ import path9 from "path";
1115
1172
  function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
1116
- const entry = path8.join(
1117
- path8.dirname(nitroRuntimeEntry),
1173
+ const entry = path9.join(
1174
+ path9.dirname(nitroRuntimeEntry),
1118
1175
  "..",
1119
1176
  "presets",
1120
1177
  "netlify",
@@ -1126,7 +1183,7 @@ function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
1126
1183
  `[Farm.js] Could not find Nitro's Netlify function entry at ${entry}. Farm wraps it so private responses are never cached by Netlify's CDN; reinstall dependencies or report the installed Nitro version.`
1127
1184
  );
1128
1185
  }
1129
- return entry.split(path8.sep).join("/");
1186
+ return entry.split(path9.sep).join("/");
1130
1187
  }
1131
1188
  function createFarmNetlifyEntry(options) {
1132
1189
  return `
@@ -1176,7 +1233,7 @@ export default async function farmNetlifyHandler(request, context) {
1176
1233
 
1177
1234
  // src/build/strip-platform-config.ts
1178
1235
  import { realpathSync } from "fs";
1179
- import path9 from "path";
1236
+ import path10 from "path";
1180
1237
  var PLATFORM_CONFIG_KEYS = /* @__PURE__ */ new Set(["desktop", "mobile"]);
1181
1238
  var CONFIG_FACTORIES = /* @__PURE__ */ new Set(["defineConfig", "defineFarmConfig"]);
1182
1239
  function isConfigObject(node) {
@@ -1250,11 +1307,11 @@ function realPath(file) {
1250
1307
  try {
1251
1308
  return realpathSync(file);
1252
1309
  } catch {
1253
- return path9.resolve(file);
1310
+ return path10.resolve(file);
1254
1311
  }
1255
1312
  }
1256
1313
  function farmStripPlatformConfigPlugin(configFiles) {
1257
- const files = new Set(configFiles.flatMap((file) => [path9.resolve(file), realPath(file)]));
1314
+ const files = new Set(configFiles.flatMap((file) => [path10.resolve(file), realPath(file)]));
1258
1315
  return {
1259
1316
  name: "farm:strip-platform-config",
1260
1317
  // Before the TypeScript transform, so its import elision also drops imports only the
@@ -1264,9 +1321,9 @@ function farmStripPlatformConfigPlugin(configFiles) {
1264
1321
  filter: { id: fileNamePattern(configFiles) },
1265
1322
  async handler(code, id) {
1266
1323
  const file = id.split("?", 1)[0];
1267
- if (!files.has(path9.resolve(file)) && !files.has(realPath(file))) return null;
1324
+ if (!files.has(path10.resolve(file)) && !files.has(realPath(file))) return null;
1268
1325
  const { parseAst } = await import("rolldown/parseAst");
1269
- const extension = path9.extname(file).slice(1);
1326
+ const extension = path10.extname(file).slice(1);
1270
1327
  const lang = /^[cm]?tsx?$/.test(extension) ? extension.endsWith("x") ? "tsx" : "ts" : extension.endsWith("x") ? "jsx" : "js";
1271
1328
  const stripped = stripPlatformConfigSource(code, (source) => parseAst(source, { lang }));
1272
1329
  return stripped === null ? null : { code: stripped, map: null };
@@ -1277,7 +1334,7 @@ function farmStripPlatformConfigPlugin(configFiles) {
1277
1334
 
1278
1335
  // src/nitro/client-sourcemaps.ts
1279
1336
  import fs3 from "fs/promises";
1280
- import path10 from "path";
1337
+ import path11 from "path";
1281
1338
  var FARM_CLIENT_SOURCEMAPS_DIR = "client-sourcemaps";
1282
1339
  function resolveFarmClientSourcemap(sourcemap) {
1283
1340
  return sourcemap ? "hidden" : false;
@@ -1298,8 +1355,8 @@ function createFarmPrivateClientSourcemapsPlugin(options) {
1298
1355
  async writeBundle() {
1299
1356
  await fs3.rm(options.outDir, { recursive: true, force: true });
1300
1357
  for (const [fileName, source] of maps) {
1301
- const target = path10.join(options.outDir, fileName);
1302
- await fs3.mkdir(path10.dirname(target), { recursive: true });
1358
+ const target = path11.join(options.outDir, fileName);
1359
+ await fs3.mkdir(path11.dirname(target), { recursive: true });
1303
1360
  await fs3.writeFile(target, source);
1304
1361
  }
1305
1362
  }
@@ -1382,7 +1439,7 @@ async function readMiddlewareFileConfig(filePath) {
1382
1439
 
1383
1440
  // src/nitro/vercel-edge-middleware.ts
1384
1441
  import { createRequire, isBuiltin } from "module";
1385
- import path11 from "path";
1442
+ import path12 from "path";
1386
1443
  import { gzipSync } from "zlib";
1387
1444
  var FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION = "_farm_middleware";
1388
1445
  var FARM_VERCEL_EDGE_NOT_FOUND_PATH = "/__farm/not-found";
@@ -1438,21 +1495,21 @@ ${modules.join("\n")}
1438
1495
  `;
1439
1496
  }
1440
1497
  async function resolveFarmCoreDir(root, fs4) {
1441
- const runtimeEntry = createRequire(path11.join(root, "package.json")).resolve(
1498
+ const runtimeEntry = createRequire(path12.join(root, "package.json")).resolve(
1442
1499
  "@farm.js/core/internal/vercel-edge-middleware"
1443
1500
  );
1444
- return fs4.realpath(path11.resolve(path11.dirname(runtimeEntry), "..", ".."));
1501
+ return fs4.realpath(path12.resolve(path12.dirname(runtimeEntry), "..", ".."));
1445
1502
  }
1446
1503
  function edgeNodeModulesPlugin(coreDir, unsupported) {
1447
1504
  const streamStub = "\0farm-edge-node-stream";
1448
- const corePrefix = coreDir + path11.sep;
1505
+ const corePrefix = coreDir + path12.sep;
1449
1506
  return {
1450
1507
  name: "farm-vercel-edge-node-modules",
1451
1508
  resolveId(source, importer) {
1452
1509
  if (!isBuiltin(source)) return null;
1453
1510
  const name = source.replace(/^node:/, "").split("/")[0];
1454
1511
  if (EDGE_NODE_MODULES.has(name)) return { id: `node:${name}`, external: true };
1455
- if (name === "stream" && importer && path11.resolve(importer).startsWith(corePrefix)) {
1512
+ if (name === "stream" && importer && path12.resolve(importer).startsWith(corePrefix)) {
1456
1513
  return streamStub;
1457
1514
  }
1458
1515
  unsupported.add(`${source} (imported by ${importer ?? "the entry"})`);
@@ -1466,13 +1523,13 @@ function edgeNodeModulesPlugin(coreDir, unsupported) {
1466
1523
  }
1467
1524
  async function writeFarmVercelEdgeMiddlewareFunction(options) {
1468
1525
  const { root, outputDir, buildDir, config, routes, guardedPages, fs: fs4 } = options;
1469
- const functionDir = path11.join(
1526
+ const functionDir = path12.join(
1470
1527
  outputDir,
1471
1528
  "functions",
1472
1529
  `${FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION}.func`
1473
1530
  );
1474
- const entryPath = path11.join(buildDir, "vercel-edge-middleware-entry.mjs");
1475
- await fs4.mkdir(path11.dirname(entryPath), { recursive: true });
1531
+ const entryPath = path12.join(buildDir, "vercel-edge-middleware-entry.mjs");
1532
+ await fs4.mkdir(path12.dirname(entryPath), { recursive: true });
1476
1533
  await fs4.writeFile(
1477
1534
  entryPath,
1478
1535
  generateFarmVercelEdgeMiddlewareEntry(routes, config, guardedPages)
@@ -1521,9 +1578,9 @@ Remove them from the middleware (Edge provides ${[...EDGE_NODE_MODULES].join(",
1521
1578
  }
1522
1579
  await fs4.rm(functionDir, { recursive: true, force: true });
1523
1580
  await fs4.mkdir(functionDir, { recursive: true });
1524
- await fs4.writeFile(path11.join(functionDir, "index.js"), code);
1581
+ await fs4.writeFile(path12.join(functionDir, "index.js"), code);
1525
1582
  await fs4.writeFile(
1526
- path11.join(functionDir, ".vc-config.json"),
1583
+ path12.join(functionDir, ".vc-config.json"),
1527
1584
  `${JSON.stringify({ runtime: "edge", entrypoint: "index.js" }, null, 2)}
1528
1585
  `
1529
1586
  );
@@ -1545,7 +1602,7 @@ async function readFarmNativeStylesheets(clientOutputDir, clientCssHref) {
1545
1602
  try {
1546
1603
  return {
1547
1604
  [clientCssHref]: await fs4.readFile(
1548
- path12.join(clientOutputDir, clientCssHref.slice(1)),
1605
+ path13.join(clientOutputDir, clientCssHref.slice(1)),
1549
1606
  "utf8"
1550
1607
  )
1551
1608
  };
@@ -1560,18 +1617,18 @@ function preloadFarmNitroBuilder() {
1560
1617
  );
1561
1618
  }
1562
1619
  var _filename = typeof import.meta.url !== "undefined" ? fileURLToPath(import.meta.url) : "";
1563
- var _dirname = path12.dirname(_filename);
1620
+ var _dirname = path13.dirname(_filename);
1564
1621
  function findFarmCoreRoot(from) {
1565
- let dir = path12.dirname(from);
1566
- while (dir !== path12.dirname(dir)) {
1567
- const manifest = path12.join(dir, "package.json");
1622
+ let dir = path13.dirname(from);
1623
+ while (dir !== path13.dirname(dir)) {
1624
+ const manifest = path13.join(dir, "package.json");
1568
1625
  if (existsSync2(manifest)) {
1569
1626
  try {
1570
1627
  if (JSON.parse(readFileSync(manifest, "utf8")).name === "@farm.js/core") return dir;
1571
1628
  } catch {
1572
1629
  }
1573
1630
  }
1574
- dir = path12.dirname(dir);
1631
+ dir = path13.dirname(dir);
1575
1632
  }
1576
1633
  return null;
1577
1634
  }
@@ -1581,16 +1638,16 @@ function toModulePath(file) {
1581
1638
  return process.platform === "win32" ? normalized.toLowerCase() : normalized;
1582
1639
  }
1583
1640
  function findInstalledPackageDir(name, from) {
1584
- for (let dir = from; ; dir = path12.dirname(dir)) {
1585
- const candidate = path12.join(dir, "node_modules", name);
1586
- if (existsSync2(path12.join(candidate, "package.json"))) {
1641
+ for (let dir = from; ; dir = path13.dirname(dir)) {
1642
+ const candidate = path13.join(dir, "node_modules", name);
1643
+ if (existsSync2(path13.join(candidate, "package.json"))) {
1587
1644
  try {
1588
1645
  return realpathSync2(candidate);
1589
1646
  } catch {
1590
1647
  return null;
1591
1648
  }
1592
1649
  }
1593
- if (dir === path12.dirname(dir)) return null;
1650
+ if (dir === path13.dirname(dir)) return null;
1594
1651
  }
1595
1652
  }
1596
1653
  function collectFarmDependencyDirs(root) {
@@ -1601,7 +1658,7 @@ function collectFarmDependencyDirs(root) {
1601
1658
  seen.add(dir);
1602
1659
  let manifest;
1603
1660
  try {
1604
- manifest = JSON.parse(readFileSync(path12.join(dir, "package.json"), "utf8"));
1661
+ manifest = JSON.parse(readFileSync(path13.join(dir, "package.json"), "utf8"));
1605
1662
  } catch {
1606
1663
  return;
1607
1664
  }
@@ -1612,7 +1669,7 @@ function collectFarmDependencyDirs(root) {
1612
1669
  if (farmCoreRoot) visit(realpathSync2(farmCoreRoot));
1613
1670
  queue.push({ name: "@farm.js/core", from: root });
1614
1671
  try {
1615
- const manifest = JSON.parse(readFileSync(path12.join(root, "package.json"), "utf8"));
1672
+ const manifest = JSON.parse(readFileSync(path13.join(root, "package.json"), "utf8"));
1616
1673
  for (const field of ["dependencies", "devDependencies"]) {
1617
1674
  for (const name of Object.keys(manifest[field] ?? {})) {
1618
1675
  if (name.startsWith("@farm.js/")) queue.push({ name, from: root });
@@ -1679,17 +1736,17 @@ var FARM_SSR_PACKAGE_IMPORT = "#farm-ssr-entry";
1679
1736
  var FARM_SSR_OUTPUT_DIR = "farm-ssr";
1680
1737
  var FARM_CLIENT_BUILD_TARGET = ["es2020", "edge88", "firefox78", "chrome87", "safari14"];
1681
1738
  function resolveNitroRuntimeDependency(root, specifier) {
1682
- return createRequire2(resolveNitroPackageEntry(root)).resolve(specifier).split(path12.sep).join("/");
1739
+ return createRequire2(resolveNitroPackageEntry(root)).resolve(specifier).split(path13.sep).join("/");
1683
1740
  }
1684
1741
  function resolveNitroInternalRuntimeAliases(root) {
1685
1742
  const nitroEntry = resolveNitroPackageEntry(root);
1686
- const runtimeDir = path12.dirname(nitroEntry);
1743
+ const runtimeDir = path13.dirname(nitroEntry);
1687
1744
  const nitroRequire = createRequire2(nitroEntry);
1688
1745
  return {
1689
1746
  ...Object.fromEntries(
1690
1747
  ["app", "error/hooks", "runtime-config", "shutdown", "task"].map((moduleName) => [
1691
1748
  `#nitro/runtime/${moduleName}`,
1692
- path12.join(runtimeDir, "internal", `${moduleName}.mjs`).split(path12.sep).join("/")
1749
+ path13.join(runtimeDir, "internal", `${moduleName}.mjs`).split(path13.sep).join("/")
1693
1750
  ])
1694
1751
  ),
1695
1752
  // Farm's generated workflow and cron wrappers live under `.farm/` and
@@ -1698,7 +1755,7 @@ function resolveNitroInternalRuntimeAliases(root) {
1698
1755
  ...Object.fromEntries(
1699
1756
  ["nitro/app", "nitro/h3", "nitro/task"].map((specifier) => [
1700
1757
  specifier,
1701
- nitroRequire.resolve(specifier).split(path12.sep).join("/")
1758
+ nitroRequire.resolve(specifier).split(path13.sep).join("/")
1702
1759
  ])
1703
1760
  )
1704
1761
  };
@@ -1709,7 +1766,7 @@ function createPrerenderRuntimeResolverPlugin(root, resolveNitroEntry = resolveN
1709
1766
  name: "farm-prerender-runtime-resolver",
1710
1767
  async resolveId(id, _importer, options) {
1711
1768
  if (options.custom?.farmPrerenderRuntimeResolve) return null;
1712
- if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") || path12.isAbsolute(id) || NODE_BUILTIN_MODULES.has(id)) {
1769
+ if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") || path13.isAbsolute(id) || NODE_BUILTIN_MODULES.has(id)) {
1713
1770
  return null;
1714
1771
  }
1715
1772
  if (nitroEntry === void 0) {
@@ -1732,7 +1789,7 @@ function createFarmStorageModuleRegistration(config) {
1732
1789
  const modules = _collectFarmStorageModules(config.storage);
1733
1790
  if (modules.length === 0) return "";
1734
1791
  const root = config.root || process.cwd();
1735
- const projectRequire = createRequire2(path12.join(root, "package.json"));
1792
+ const projectRequire = createRequire2(path13.join(root, "package.json"));
1736
1793
  let runtimeRequire = projectRequire;
1737
1794
  try {
1738
1795
  runtimeRequire = createRequire2(projectRequire.resolve("@farm.js/core"));
@@ -1759,7 +1816,7 @@ ${loaders.join("\n")}
1759
1816
  });` : "";
1760
1817
  }
1761
1818
  function resolveNitroPackageEntry(root) {
1762
- const projectRequire = createRequire2(path12.join(root, "package.json"));
1819
+ const projectRequire = createRequire2(path13.join(root, "package.json"));
1763
1820
  let runtimeRequire = projectRequire;
1764
1821
  try {
1765
1822
  runtimeRequire = createRequire2(projectRequire.resolve("@farm.js/core"));
@@ -1829,7 +1886,7 @@ function createFarmReactWebServerAlias(hasEdgeBuild) {
1829
1886
  }
1830
1887
  function hasReactDomEdgeServerBuild(root) {
1831
1888
  try {
1832
- createRequire2(path12.join(root, "package.json")).resolve("react-dom/server.edge");
1889
+ createRequire2(path13.join(root, "package.json")).resolve("react-dom/server.edge");
1833
1890
  return true;
1834
1891
  } catch {
1835
1892
  return false;
@@ -1860,9 +1917,9 @@ function isNitroRollupExternal(id) {
1860
1917
  var FARM_METADATA_IMAGE_WASM_PREFIX = "\0farm-metadata-image-wasm:";
1861
1918
  var FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID = "\0farm-omitted-metadata-image-runtime";
1862
1919
  function isFarmCoreModule(file) {
1863
- let dir = path12.dirname(file.split("?", 1)[0]);
1864
- while (dir !== path12.dirname(dir)) {
1865
- const manifest = path12.join(dir, "package.json");
1920
+ let dir = path13.dirname(file.split("?", 1)[0]);
1921
+ while (dir !== path13.dirname(dir)) {
1922
+ const manifest = path13.join(dir, "package.json");
1866
1923
  if (existsSync2(manifest)) {
1867
1924
  try {
1868
1925
  return JSON.parse(readFileSync(manifest, "utf8")).name === "@farm.js/core";
@@ -1870,7 +1927,7 @@ function isFarmCoreModule(file) {
1870
1927
  return false;
1871
1928
  }
1872
1929
  }
1873
- dir = path12.dirname(dir);
1930
+ dir = path13.dirname(dir);
1874
1931
  }
1875
1932
  return false;
1876
1933
  }
@@ -1881,7 +1938,7 @@ function createOmittedMetadataImageRuntimePlugin(externalizeOtherImports) {
1881
1938
  filter: { id: exactIdPattern(["@vercel/og"]) },
1882
1939
  handler(source, importer) {
1883
1940
  if (source !== "@vercel/og") return null;
1884
- const fromCoreRuntime = importer !== void 0 && isFarmCoreModule(importer) && !/^og\.[cm]?[jt]sx?$/.test(path12.basename(importer.split("?", 1)[0]));
1941
+ const fromCoreRuntime = importer !== void 0 && isFarmCoreModule(importer) && !/^og\.[cm]?[jt]sx?$/.test(path13.basename(importer.split("?", 1)[0]));
1885
1942
  if (fromCoreRuntime) return FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID;
1886
1943
  return externalizeOtherImports ? { id: source, external: true } : null;
1887
1944
  }
@@ -1902,14 +1959,14 @@ export class ImageResponse {
1902
1959
  };
1903
1960
  }
1904
1961
  function readVercelOgManifest(file) {
1905
- let dir = path12.dirname(file.split("?", 1)[0]);
1906
- while (dir !== path12.dirname(dir)) {
1907
- const manifestPath = path12.join(dir, "package.json");
1962
+ let dir = path13.dirname(file.split("?", 1)[0]);
1963
+ while (dir !== path13.dirname(dir)) {
1964
+ const manifestPath = path13.join(dir, "package.json");
1908
1965
  if (existsSync2(manifestPath)) {
1909
1966
  const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
1910
1967
  return manifest.name === "@vercel/og" ? { dir, manifest } : null;
1911
1968
  }
1912
- dir = path12.dirname(dir);
1969
+ dir = path13.dirname(dir);
1913
1970
  }
1914
1971
  return null;
1915
1972
  }
@@ -1917,7 +1974,7 @@ function resolveVercelOgConditionEntry(resolvedId, condition) {
1917
1974
  const vercelOg = readVercelOgManifest(resolvedId);
1918
1975
  const entry = vercelOg?.manifest.exports?.["."]?.[condition];
1919
1976
  const file = typeof entry === "string" ? entry : entry?.default;
1920
- return vercelOg && typeof file === "string" ? path12.join(vercelOg.dir, file) : null;
1977
+ return vercelOg && typeof file === "string" ? path13.join(vercelOg.dir, file) : null;
1921
1978
  }
1922
1979
  function createEdgeMetadataImageRuntimePlugin({
1923
1980
  condition,
@@ -1935,7 +1992,7 @@ function createEdgeMetadataImageRuntimePlugin({
1935
1992
  if (wasm !== "module" || !source.endsWith(".wasm?module") || !importer?.replace(/\\/g, "/").includes("/@vercel/og/")) {
1936
1993
  return null;
1937
1994
  }
1938
- const resolvedPath = path12.resolve(path12.dirname(importer.split("?", 1)[0]), source);
1995
+ const resolvedPath = path13.resolve(path13.dirname(importer.split("?", 1)[0]), source);
1939
1996
  return { id: toPosixPath(resolvedPath), external: "absolute" };
1940
1997
  }
1941
1998
  };
@@ -1950,7 +2007,7 @@ function createVercelOgFontInlinePlugin(runtime = "Cloudflare Workers") {
1950
2007
  return null;
1951
2008
  }
1952
2009
  const inlined = code.replace(VERCEL_OG_FONT_FETCH, (_match, _quote, request) => {
1953
- const encoded = readFileSync(path12.resolve(path12.dirname(file), request)).toString("base64");
2010
+ const encoded = readFileSync(path13.resolve(path13.dirname(file), request)).toString("base64");
1954
2011
  return `Promise.resolve({ arrayBuffer: () => Uint8Array.from(atob(${JSON.stringify(encoded)}), (character) => character.charCodeAt(0)).buffer })`;
1955
2012
  });
1956
2013
  if (inlined !== code) return { code: inlined, map: null };
@@ -1969,7 +2026,7 @@ function createMetadataImageWasmPlugin() {
1969
2026
  return null;
1970
2027
  }
1971
2028
  const requestPath = source.slice(0, -"?module".length);
1972
- const resolvedPath = path12.isAbsolute(requestPath) ? requestPath : path12.resolve(path12.dirname(importer.split("?", 1)[0]), requestPath);
2029
+ const resolvedPath = path13.isAbsolute(requestPath) ? requestPath : path13.resolve(path13.dirname(importer.split("?", 1)[0]), requestPath);
1973
2030
  return `${FARM_METADATA_IMAGE_WASM_PREFIX}${resolvedPath}`;
1974
2031
  },
1975
2032
  load(id) {
@@ -1994,11 +2051,11 @@ function collectSSRExternalPackages(ssrBundle) {
1994
2051
  for (const importId of [...output.imports, ...output.dynamicImports]) {
1995
2052
  const normalizedImportId = importId.replace(/\\/g, "/");
1996
2053
  const normalizedId = normalizedImportId.replace(/^\.\//, "");
1997
- const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ? path12.posix.normalize(path12.posix.join(path12.posix.dirname(fileName), normalizedImportId)) : null;
2054
+ const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ? path13.posix.normalize(path13.posix.join(path13.posix.dirname(fileName), normalizedImportId)) : null;
1998
2055
  if (emittedFiles.has(normalizedId) || resolvedRelativeId !== null && emittedFiles.has(resolvedRelativeId) || NODE_BUILTIN_MODULES.has(importId) || importId.startsWith("node:")) {
1999
2056
  continue;
2000
2057
  }
2001
- if (path12.isAbsolute(importId) || /^[A-Za-z]:[\\/]/.test(importId) || importId.startsWith("#") || importId.startsWith("\0")) {
2058
+ if (path13.isAbsolute(importId) || /^[A-Za-z]:[\\/]/.test(importId) || importId.startsWith("#") || importId.startsWith("\0")) {
2002
2059
  externalPackages.add(importId);
2003
2060
  continue;
2004
2061
  }
@@ -2010,15 +2067,15 @@ function collectSSRExternalPackages(ssrBundle) {
2010
2067
  return externalPackages;
2011
2068
  }
2012
2069
  function createExternalSSRBundlePlugin(nitroEntryPath, ssrOutputDir, ssrEntryFile) {
2013
- const resolvedNitroEntry = path12.resolve(nitroEntryPath);
2014
- const resolvedSSREntry = path12.resolve(ssrOutputDir, ssrEntryFile);
2070
+ const resolvedNitroEntry = path13.resolve(nitroEntryPath);
2071
+ const resolvedSSREntry = path13.resolve(ssrOutputDir, ssrEntryFile);
2015
2072
  return {
2016
2073
  name: "farm-externalize-prebuilt-ssr",
2017
2074
  resolveId(source, importer) {
2018
- if (!importer || path12.resolve(importer) !== resolvedNitroEntry) {
2075
+ if (!importer || path13.resolve(importer) !== resolvedNitroEntry) {
2019
2076
  return null;
2020
2077
  }
2021
- const resolvedImport = path12.resolve(path12.dirname(importer), source);
2078
+ const resolvedImport = path13.resolve(path13.dirname(importer), source);
2022
2079
  if (resolvedImport !== resolvedSSREntry) return null;
2023
2080
  return { id: FARM_SSR_PACKAGE_IMPORT, external: true };
2024
2081
  }
@@ -2151,13 +2208,13 @@ function trimSlashes(value) {
2151
2208
  function resolveBuildDocsContentDir(docs, root, srcDir) {
2152
2209
  const configuredContentDir = docs.contentDir || docs.config.contentDir;
2153
2210
  if (typeof configuredContentDir === "string" && configuredContentDir.trim()) {
2154
- const contentDir = path12.isAbsolute(configuredContentDir) ? configuredContentDir : path12.join(root, configuredContentDir);
2211
+ const contentDir = path13.isAbsolute(configuredContentDir) ? configuredContentDir : path13.join(root, configuredContentDir);
2155
2212
  return existsSync2(contentDir) ? contentDir : null;
2156
2213
  }
2157
2214
  const entryDir = docs.config.entry || trimSlashes(docs.entry) || "docs";
2158
- const appDocsDir = path12.join(root, srcDir || "src", "app", entryDir);
2215
+ const appDocsDir = path13.join(root, srcDir || "src", "app", entryDir);
2159
2216
  if (existsSync2(appDocsDir)) return appDocsDir;
2160
- const rootDocsDir = path12.join(root, entryDir);
2217
+ const rootDocsDir = path13.join(root, entryDir);
2161
2218
  return existsSync2(rootDocsDir) ? rootDocsDir : null;
2162
2219
  }
2163
2220
  function hasProjectPostcssConfig(root) {
@@ -2174,7 +2231,7 @@ function hasProjectPostcssConfig(root) {
2174
2231
  ".postcssrc.mjs",
2175
2232
  ".postcssrc.ts"
2176
2233
  ];
2177
- const projectRequire = createRequire2(path12.join(root, "package.json"));
2234
+ const projectRequire = createRequire2(path13.join(root, "package.json"));
2178
2235
  return candidates.some((file) => {
2179
2236
  try {
2180
2237
  projectRequire.resolve(`./${file}`);
@@ -2197,7 +2254,7 @@ async function findFarmConfigPath(root) {
2197
2254
  "config.mjs"
2198
2255
  ];
2199
2256
  for (const candidate of candidates) {
2200
- const resolvedPath = path12.join(root, candidate);
2257
+ const resolvedPath = path13.join(root, candidate);
2201
2258
  try {
2202
2259
  await fs4.access(resolvedPath);
2203
2260
  return resolvedPath;
@@ -2234,7 +2291,7 @@ async function discoverMiddlewareRoutes(appDir) {
2234
2291
  discovered.push({
2235
2292
  path: routePath,
2236
2293
  directory,
2237
- filePath: path12.join(dir, middlewareFile.name)
2294
+ filePath: path13.join(dir, middlewareFile.name)
2238
2295
  });
2239
2296
  }
2240
2297
  for (const entry of entries) {
@@ -2242,7 +2299,7 @@ async function discoverMiddlewareRoutes(appDir) {
2242
2299
  continue;
2243
2300
  }
2244
2301
  await walk(
2245
- path12.join(dir, entry.name),
2302
+ path13.join(dir, entry.name),
2246
2303
  appendMiddlewareRoutePath(routePath, entry.name),
2247
2304
  appendMiddlewareDirectory(directory, entry.name),
2248
2305
  discovered
@@ -2272,7 +2329,6 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
2272
2329
  assertFarmDocsRuntimeSupported(config, preset);
2273
2330
  const srcDir = config.srcDir || "src";
2274
2331
  const distDir = config.distDir || ".farm";
2275
- const deployOutputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
2276
2332
  const lifecyclePluginManager = options.pluginManager;
2277
2333
  const productionViteResultPromise = Promise.allSettled([
2278
2334
  Promise.resolve(options.productionVite ?? loadFarmProductionVite())
@@ -2318,7 +2374,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
2318
2374
  logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
2319
2375
  const fs4 = await import("fs/promises");
2320
2376
  const layoutRoutes = [];
2321
- const appDir = path12.join(root, srcDir, "app");
2377
+ const appDir = path13.join(root, srcDir, "app");
2322
2378
  async function findLayoutsForClient(dir, routePrefix = "/") {
2323
2379
  try {
2324
2380
  const entries = await fs4.readdir(dir, { withFileTypes: true });
@@ -2326,11 +2382,11 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
2326
2382
  if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?|vue|svelte)$/)) {
2327
2383
  layoutRoutes.push({
2328
2384
  pattern: routePrefix,
2329
- modulePath: path12.join(dir, entry.name)
2385
+ modulePath: path13.join(dir, entry.name)
2330
2386
  });
2331
2387
  } else if (entry.isDirectory() && !entry.name.startsWith(".") && !entry.name.startsWith("_")) {
2332
2388
  const childPrefix = routePrefix === "/" ? `/${entry.name}` : `${routePrefix}/${entry.name}`;
2333
- await findLayoutsForClient(path12.join(dir, entry.name), childPrefix);
2389
+ await findLayoutsForClient(path13.join(dir, entry.name), childPrefix);
2334
2390
  }
2335
2391
  }
2336
2392
  } catch {
@@ -2354,7 +2410,7 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
2354
2410
  );
2355
2411
  }
2356
2412
  const hydrationPlanCache = /* @__PURE__ */ new Map();
2357
- const clientOutputDir = path12.join(root, distDir, "client");
2413
+ const clientOutputDir = path13.join(root, distDir, "client");
2358
2414
  const [productionViteResult] = await productionViteResultPromise;
2359
2415
  if (productionViteResult.status === "rejected") {
2360
2416
  await routeRuntimeManifestResultPromise;
@@ -2479,10 +2535,10 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
2479
2535
  lifecyclePluginManager
2480
2536
  );
2481
2537
  const runtimeManifestPath = await writeFarmRouteRuntimeManifest(
2482
- path12.join(root, distDir),
2538
+ path13.join(root, distDir),
2483
2539
  routeRuntimeManifest
2484
2540
  );
2485
- logger.info(`\u{1F4CB} Route runtime manifest: ${path12.relative(root, runtimeManifestPath)}`);
2541
+ logger.info(`\u{1F4CB} Route runtime manifest: ${path13.relative(root, runtimeManifestPath)}`);
2486
2542
  } catch (error) {
2487
2543
  if (lifecyclePluginManager) {
2488
2544
  await lifecyclePluginManager.runHookParallel("onError", {
@@ -2526,8 +2582,8 @@ async function writeSSRAssetsToClient(bundle, outputDir) {
2526
2582
  await mergeBuiltFontCss(outputDir, output.source);
2527
2583
  continue;
2528
2584
  }
2529
- const filePath = path12.join(outputDir, fileName);
2530
- await fs4.mkdir(path12.dirname(filePath), { recursive: true });
2585
+ const filePath = path13.join(outputDir, fileName);
2586
+ await fs4.mkdir(path13.dirname(filePath), { recursive: true });
2531
2587
  await fs4.writeFile(filePath, output.source);
2532
2588
  }
2533
2589
  }
@@ -2535,15 +2591,15 @@ async function copyFarmDocsFontAssetsToClient(root, outputDir) {
2535
2591
  const fs4 = await import("fs/promises");
2536
2592
  await Promise.all(
2537
2593
  resolveFarmDocsFontAssets(root).map(async ({ sourcePath, url }) => {
2538
- const targetPath = path12.join(outputDir, url.replace(/^\/+/, ""));
2539
- await fs4.mkdir(path12.dirname(targetPath), { recursive: true });
2594
+ const targetPath = path13.join(outputDir, url.replace(/^\/+/, ""));
2595
+ await fs4.mkdir(path13.dirname(targetPath), { recursive: true });
2540
2596
  await fs4.copyFile(sourcePath, targetPath);
2541
2597
  })
2542
2598
  );
2543
2599
  }
2544
2600
  async function mergeBuiltFontCss(outputDir, fontCssSource) {
2545
2601
  const fs4 = await import("fs/promises");
2546
- const fontCssPath = path12.join(outputDir, "farm-fonts.css");
2602
+ const fontCssPath = path13.join(outputDir, "farm-fonts.css");
2547
2603
  let fontCss = fontCssSource;
2548
2604
  if (fontCss === void 0) {
2549
2605
  try {
@@ -2552,7 +2608,7 @@ async function mergeBuiltFontCss(outputDir, fontCssSource) {
2552
2608
  return;
2553
2609
  }
2554
2610
  }
2555
- const clientCssPath = path12.join(outputDir, "farm-client.css");
2611
+ const clientCssPath = path13.join(outputDir, "farm-client.css");
2556
2612
  let clientCss = "";
2557
2613
  try {
2558
2614
  clientCss = await fs4.readFile(clientCssPath, "utf8");
@@ -2578,7 +2634,7 @@ var IncompleteClientBuildOutputError = class extends Error {
2578
2634
  async function validateClientBuildOutput(root, srcDir, outputDir) {
2579
2635
  const fs4 = await import("fs/promises");
2580
2636
  const fingerprinted = await findFingerprintedClientEntry(outputDir);
2581
- const clientEntryPath = path12.join(outputDir, fingerprinted ?? "farm-client.js");
2637
+ const clientEntryPath = path13.join(outputDir, fingerprinted ?? "farm-client.js");
2582
2638
  let clientEntrySize = 0;
2583
2639
  try {
2584
2640
  const clientEntry = await fs4.stat(clientEntryPath);
@@ -2588,8 +2644,8 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
2588
2644
  if (clientEntrySize === 0) {
2589
2645
  throw new IncompleteClientBuildOutputError("farm-client.js is missing or empty");
2590
2646
  }
2591
- const clientCssPath = path12.join(outputDir, "farm-client.css");
2592
- const globalsCssPath = path12.join(root, srcDir, "app", "globals.css");
2647
+ const clientCssPath = path13.join(outputDir, "farm-client.css");
2648
+ const globalsCssPath = path13.join(root, srcDir, "app", "globals.css");
2593
2649
  let expectsCss = false;
2594
2650
  try {
2595
2651
  const globalsCss = await fs4.readFile(globalsCssPath, "utf8");
@@ -2610,7 +2666,7 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
2610
2666
  }
2611
2667
  }
2612
2668
  function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, options = {}) {
2613
- const key = `${path12.resolve(root)}\0${mode}\0${options.asyncOwnerIslands === true}\0${options.serverOwners === true}\0${options.serverTreeLayouts === true}\0${path12.resolve(modulePath)}`;
2669
+ const key = `${path13.resolve(root)}\0${mode}\0${options.asyncOwnerIslands === true}\0${options.serverOwners === true}\0${options.serverTreeLayouts === true}\0${path13.resolve(modulePath)}`;
2614
2670
  let plan = cache.get(key);
2615
2671
  if (!plan) {
2616
2672
  plan = getClientModuleHydrationPlan(modulePath, root, mode, options);
@@ -2619,10 +2675,10 @@ function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, optio
2619
2675
  return { ...plan, isolatedBoundaries: [...plan.isolatedBoundaries] };
2620
2676
  }
2621
2677
  async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map(), rendererBuildLifetime, programmaticClientRoutes, mobile = false) {
2622
- if (!mobile) await removeFarmMobileClientManifest(path12.dirname(outputDir));
2678
+ if (!mobile) await removeFarmMobileClientManifest(path13.dirname(outputDir));
2623
2679
  const viteBuild = productionVite.build;
2624
2680
  const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
2625
- const { PluginManager: PluginManager2 } = await import("./plugin-VEBRN7A3.mjs");
2681
+ const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
2626
2682
  const fs4 = await import("fs/promises");
2627
2683
  const pluginManager = new PluginManager2({
2628
2684
  config,
@@ -2879,10 +2935,10 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2879
2935
  `\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout) => layout.shouldHydrate || layout.hasIsolatedClientBoundaries).length} layouts, and ${clientRouteSlots.length} slots`
2880
2936
  );
2881
2937
  const buildTarget = async (platform) => {
2882
- const clientEntryRoot = path12.join(root, ".farm", "tmp");
2938
+ const clientEntryRoot = path13.join(root, ".farm", "tmp");
2883
2939
  await fs4.mkdir(clientEntryRoot, { recursive: true });
2884
- const clientEntryDir = await fs4.mkdtemp(path12.join(clientEntryRoot, "client-entry-"));
2885
- const clientEntryPath = path12.join(clientEntryDir, "farm-client-entry.tsx");
2940
+ const clientEntryDir = await fs4.mkdtemp(path13.join(clientEntryRoot, "client-entry-"));
2941
+ const clientEntryPath = path13.join(clientEntryDir, "farm-client-entry.tsx");
2886
2942
  const clientHydrationCode = generateClientHydrationEntry(
2887
2943
  clientPages,
2888
2944
  clientLayouts,
@@ -2916,11 +2972,11 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2916
2972
  const clientEntry = islandsMode && platform === "web" && clientHydrationCode.includes("/*farm-router-stub*/") ? splitFarmClientRouter(clientHydrationCode) : { entry: clientHydrationCode, router: void 0 };
2917
2973
  await fs4.writeFile(clientEntryPath, clientEntry.entry);
2918
2974
  if (clientEntry.router !== void 0) {
2919
- await fs4.writeFile(path12.join(clientEntryDir, "farm-client-router.tsx"), clientEntry.router);
2975
+ await fs4.writeFile(path13.join(clientEntryDir, "farm-client-router.tsx"), clientEntry.router);
2920
2976
  }
2921
2977
  const clientInput = { [entryName]: clientEntryPath };
2922
2978
  if (platform === "web" && canBootFarmIslandsClient(config)) {
2923
- const clientBootPath = path12.join(clientEntryDir, "farm-client-boot.tsx");
2979
+ const clientBootPath = path13.join(clientEntryDir, "farm-client-boot.tsx");
2924
2980
  await fs4.writeFile(
2925
2981
  clientBootPath,
2926
2982
  'import { startFarmIslandsBoot } from "@farm.js/core/internal/islands-boot";\nstartFarmIslandsBoot();\n'
@@ -2937,7 +2993,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2937
2993
  if (hasScopedPostcssConfig) {
2938
2994
  logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
2939
2995
  } else {
2940
- const postcssConfigPath = path12.join(clientEntryDir, "postcss.config.cjs");
2996
+ const postcssConfigPath = path13.join(clientEntryDir, "postcss.config.cjs");
2941
2997
  await fs4.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
2942
2998
  postcssSearchPath = clientEntryDir;
2943
2999
  tailwindVitePlugin = await loadTailwindVitePlugin({
@@ -2993,24 +3049,24 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2993
3049
  plugins: [
2994
3050
  createFarmThemeCssPlugin(config.theme, config.basePath),
2995
3051
  createFarmPrivateClientSourcemapsPlugin({
2996
- outDir: path12.join(
2997
- path12.dirname(outputDir),
3052
+ outDir: path13.join(
3053
+ path13.dirname(outputDir),
2998
3054
  platform === "mobile" ? `${FARM_CLIENT_SOURCEMAPS_DIR}-mobile` : FARM_CLIENT_SOURCEMAPS_DIR
2999
3055
  )
3000
3056
  }),
3001
3057
  // The web client's preload manifests; the mobile client records its files instead.
3002
3058
  platform === "mobile" ? createFarmMobileClientManifestPlugin({
3003
- buildDir: path12.dirname(outputDir),
3059
+ buildDir: path13.dirname(outputDir),
3004
3060
  entryName
3005
3061
  }) : createFarmClientModulePreloadPlugin({
3006
3062
  root,
3007
- buildDir: path12.dirname(outputDir),
3063
+ buildDir: path13.dirname(outputDir),
3008
3064
  entryName: "farm-client"
3009
3065
  }),
3010
3066
  ...adapterOwnsDocsRuntime && platform === "web" ? [
3011
3067
  createFarmDocsModulePreloadPlugin({
3012
3068
  root,
3013
- buildDir: path12.dirname(outputDir),
3069
+ buildDir: path13.dirname(outputDir),
3014
3070
  importer: clientEntryPath,
3015
3071
  entryName: "farm-client",
3016
3072
  modules: [
@@ -3114,10 +3170,12 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3114
3170
  ]
3115
3171
  }
3116
3172
  };
3117
- await viteBuild(mergeFarmProductionViteConfig(clientViteConfig, config.vite));
3173
+ await viteBuild(
3174
+ mergeFarmProductionViteConfig(clientViteConfig, config.vite, { clientOutput: true })
3175
+ );
3118
3176
  if (platform === "mobile") {
3119
- await fs4.rm(path12.join(outputDir, `${entryName}.css`), { force: true });
3120
- if (!await hasFarmMobileClientEntry(path12.dirname(outputDir), outputDir)) {
3177
+ await fs4.rm(path13.join(outputDir, `${entryName}.css`), { force: true });
3178
+ if (!await hasFarmMobileClientEntry(path13.dirname(outputDir), outputDir)) {
3121
3179
  throw new IncompleteClientBuildOutputError(
3122
3180
  `${FARM_MOBILE_CLIENT_ENTRY_NAME}.js is missing or empty`
3123
3181
  );
@@ -3138,12 +3196,12 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3138
3196
  }
3139
3197
  function toBakedMarkdownSourcePath(root, filePath) {
3140
3198
  if (!filePath) return "";
3141
- if (!path12.isAbsolute(filePath)) return filePath.split(path12.sep).join("/");
3142
- const relative = path12.relative(root, filePath);
3143
- if (!relative || relative.startsWith("..") || path12.isAbsolute(relative)) {
3144
- return path12.basename(filePath);
3199
+ if (!path13.isAbsolute(filePath)) return filePath.split(path13.sep).join("/");
3200
+ const relative = path13.relative(root, filePath);
3201
+ if (!relative || relative.startsWith("..") || path13.isAbsolute(relative)) {
3202
+ return path13.basename(filePath);
3145
3203
  }
3146
- return relative.split(path12.sep).join("/");
3204
+ return relative.split(path13.sep).join("/");
3147
3205
  }
3148
3206
  function generateUniversalRouterStateRuntime(streamNavigations = false) {
3149
3207
  return `
@@ -4188,7 +4246,7 @@ __farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot
4188
4246
  root,
4189
4247
  renderer.componentExtensions ?? []
4190
4248
  );
4191
- const globalsCssPath = path12.join(root, srcDir, "app", "globals.css");
4249
+ const globalsCssPath = path13.join(root, srcDir, "app", "globals.css");
4192
4250
  const serverStyleModules = [];
4193
4251
  const cssImport = [
4194
4252
  ...existsSync2(globalsCssPath) ? [globalsCssPath] : [],
@@ -4628,7 +4686,8 @@ async function createFarmServerTreePageElement(source, pathname) {
4628
4686
  return await createFarmServerTreeElement(React, source, {
4629
4687
  load: loadFarmIsolatedBoundary,
4630
4688
  ServerHtml: FarmServerPage,
4631
- key: pathname,
4689
+ // No key: the next page of the same layout updates this one in place, as React Server
4690
+ // Components do, instead of unmounting it and building every node again.
4632
4691
  });
4633
4692
  } catch (error) {
4634
4693
  console.warn("[Farm.js] Could not rebuild the server tree of " + pathname + "; its server HTML was kept.", error);
@@ -6024,7 +6083,7 @@ void hydrate();
6024
6083
  async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime) {
6025
6084
  const viteBuild = productionVite.build;
6026
6085
  const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
6027
- const { PluginManager: PluginManager2 } = await import("./plugin-VEBRN7A3.mjs");
6086
+ const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
6028
6087
  const fs4 = await import("fs/promises");
6029
6088
  const pluginManager = new PluginManager2({
6030
6089
  config,
@@ -6040,9 +6099,9 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6040
6099
  buildLifetime: rendererBuildLifetime
6041
6100
  });
6042
6101
  if (!hasScopedPostcssConfig) {
6043
- postcssConfigDir = await fs4.mkdtemp(path12.join(os.tmpdir(), "farm-postcss-"));
6102
+ postcssConfigDir = await fs4.mkdtemp(path13.join(os.tmpdir(), "farm-postcss-"));
6044
6103
  await fs4.writeFile(
6045
- path12.join(postcssConfigDir, "postcss.config.cjs"),
6104
+ path13.join(postcssConfigDir, "postcss.config.cjs"),
6046
6105
  "module.exports = { plugins: [] };\n"
6047
6106
  );
6048
6107
  tailwindVitePlugin = await loadTailwindVitePlugin({
@@ -6465,7 +6524,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6465
6524
  }
6466
6525
  function readFarmAppPackageIdentity(root) {
6467
6526
  try {
6468
- return JSON.parse(readFileSync(path12.join(root, "package.json"), "utf8"));
6527
+ return JSON.parse(readFileSync(path13.join(root, "package.json"), "utf8"));
6469
6528
  } catch {
6470
6529
  return {};
6471
6530
  }
@@ -7075,10 +7134,12 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7075
7134
  orderedPageRoutes.forEach((route, index) => {
7076
7135
  const varName = `pageRoute${index}`;
7077
7136
  if (isFarmMarkdownPageFile(route.modulePath)) {
7137
+ const renderingDirective2 = readRouteRenderingDirectiveFromFile(route.modulePath);
7078
7138
  pageRegistrations.push(`
7079
7139
  {
7080
7140
  pattern: ${JSON.stringify(route.pattern)},${route.directory ? `
7081
- directory: ${JSON.stringify(route.directory)},` : ""}
7141
+ directory: ${JSON.stringify(route.directory)},` : ""}${renderingDirective2 ? `
7142
+ rendering: ${JSON.stringify(renderingDirective2)},` : ""}
7082
7143
  module: createFarmMarkdownRouteModule({
7083
7144
  source: ${JSON.stringify(route.source ?? "")},
7084
7145
  filePath: ${JSON.stringify(toBakedMarkdownSourcePath(config.root, route.modulePath))},
@@ -7453,7 +7514,7 @@ import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
7453
7514
  const markdownHandlerImport = config.md?.enabled ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
7454
7515
  const appMarkdownImport = hasMarkdownPages ? `import { FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS, createFarmMarkdownRouteModule, createFarmMarkdownSourceResponse, isFarmMarkdownPublicSourceResponse } from "@farm.js/core/internal/app-markdown-runtime";` : "const createFarmMarkdownSourceResponse = null;\nconst isFarmMarkdownPublicSourceResponse = null;";
7455
7516
  const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, FARM_MARKDOWN_PAGE_CHECK_HEADER, _isFarmMarkdownPageCheck, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
7456
- const mdxComponentsPath = typeof config.mdx?.components === "string" ? path12.isAbsolute(config.mdx.components) ? config.mdx.components : path12.join(config.root, config.mdx.components) : null;
7517
+ const mdxComponentsPath = typeof config.mdx?.components === "string" ? path13.isAbsolute(config.mdx.components) ? config.mdx.components : path13.join(config.root, config.mdx.components) : null;
7457
7518
  const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from ${toVirtualEntryImportSpecifier(mdxComponentsPath)};` : "";
7458
7519
  const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
7459
7520
  const layerConfigImports = layerConfigPaths.map(
@@ -7992,7 +8053,7 @@ const farmDocsAPIHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDo
7992
8053
 
7993
8054
  // API routes bundled at build time
7994
8055
  const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
7995
- ]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path14, methods }) => ({ path: path14, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)}, dispatch: dispatchFarmPluginAPIRequest })` : ""};
8056
+ ]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path15, methods }) => ({ path: path15, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)}, dispatch: dispatchFarmPluginAPIRequest })` : ""};
7996
8057
  // A plugin calling an app endpoint (an MCP tool, say) goes through the whole
7997
8058
  // pipeline, so the endpoint's middleware and integration guards run for it.
7998
8059
  function dispatchFarmPluginAPIRequest(request) {
@@ -8831,8 +8892,9 @@ const farmClientEntryPreloadTags = farmClientModulePreloads
8831
8892
  ? farmClientModulePreloads.entry.map(renderFarmClientModulePreload).join("")
8832
8893
  : "";
8833
8894
  // The client modules a document's markup loads: its islands' boundaries and the
8834
- // client references of its server tree.
8835
- const FARM_CLIENT_MODULE_REFERENCE_PATTERN = /<f-island src="([^"]+)"|"r":"(\\/[^"]+)"/g;
8895
+ // client references of its server tree. An island with a deferred strategy loads its
8896
+ // module on its own trigger, so it is not preloaded.
8897
+ const FARM_CLIENT_MODULE_REFERENCE_PATTERN = /<f-island src="([^"]+)"([^>]*)>|"r":"(\\/[^"]+)"/g;
8836
8898
 
8837
8899
  function renderFarmClientModulePreload(index) {
8838
8900
  return '\\n <link rel="modulepreload" href="/' +
@@ -8860,7 +8922,10 @@ function renderFarmClientModulePreloads(markup, pageModule) {
8860
8922
  };
8861
8923
  add(pageModule);
8862
8924
  if (typeof markup === "string") {
8863
- for (const match of markup.matchAll(FARM_CLIENT_MODULE_REFERENCE_PATTERN)) add(match[1] || match[2]);
8925
+ for (const match of markup.matchAll(FARM_CLIENT_MODULE_REFERENCE_PATTERN)) {
8926
+ if (match[1] && FARM_DEFERRED_ISLAND_STRATEGY.test(match[2])) continue;
8927
+ add(match[1] || match[3]);
8928
+ }
8864
8929
  }
8865
8930
  return tags;
8866
8931
  }
@@ -9263,16 +9328,20 @@ function getFarmDefaultMCPServer() {
9263
9328
  }
9264
9329
  async function handleFarmDefaultMCP(request) {
9265
9330
  const origin = new URL(request.url).origin;
9331
+ // Pages are linked on metadataBase, as sitemap.xml and llms.txt link them.
9332
+ const metadataBase = getFarmRootMetadataBase();
9266
9333
  return handleFarmDefaultMCPRequest(request, {
9267
9334
  server: getFarmDefaultMCPServer(),
9268
9335
  basePath: ${JSON.stringify(config.basePath)},
9269
9336
  i18n: farmI18nConfig,
9337
+ metadataBase,
9270
9338
  // Each page at the URL it answers at, as in development and as the sitemap lists it.
9271
9339
  listPages: () =>
9272
9340
  collectFarmDefaultMCPPages(
9273
9341
  getFarmAgentListedPageRoutes().map((route) => ({ pattern: route.pattern, module: route.module })),
9274
9342
  {
9275
9343
  origin,
9344
+ metadataBase,
9276
9345
  basePath: ${JSON.stringify(config.basePath)},
9277
9346
  markdown: farmMarkdownConfig,${config.trailingSlash ? "\n trailingSlash: true," : ""}
9278
9347
  i18n: farmI18nConfig,
@@ -9288,16 +9357,16 @@ async function handleFarmDefaultMCP(request) {
9288
9357
  // gets its own request context, as for a direct request.
9289
9358
  const farmDefaultMCPReadMarkdown = createFarmLlmsMarkdownReader((page) => fetch(page));
9290
9359
  ` : ""}
9291
- // The origin llms.txt and llms-full.txt link to: the root layout's metadataBase, else the
9292
- // request's origin, as for the sitemap and in development.
9360
+ // The origin llms.txt, llms-full.txt and list_pages link to: the root layout's metadataBase,
9361
+ // else the request's origin, as for the sitemap and in development.
9293
9362
  function getFarmAgentOrigin(request) {
9363
+ return resolveFarmAgentOrigin(getFarmRootMetadataBase(), new URL(request.url).origin);
9364
+ }
9365
+ function getFarmRootMetadataBase() {
9294
9366
  const rootLayout = layoutRoutes.find((layout) => layout.pattern === "/");
9295
- return resolveFarmAgentOrigin(
9296
- rootLayout && rootLayout.module && rootLayout.module.metadata
9297
- ? rootLayout.module.metadata.metadataBase
9298
- : undefined,
9299
- new URL(request.url).origin,
9300
- );
9367
+ return rootLayout && rootLayout.module && rootLayout.module.metadata
9368
+ ? rootLayout.module.metadata.metadataBase
9369
+ : undefined;
9301
9370
  }
9302
9371
 
9303
9372
  // Static pages and root metadata for llms.txt, built the same way as in development.
@@ -10682,6 +10751,12 @@ ${hasServerRuntimeIntegrations ? `
10682
10751
 
10683
10752
  // Reads from here on belong to the page render, not to middleware.
10684
10753
  const requestReadsBeforeRender = _getRequestReadCount();
10754
+ // A swr or cache route rule stores this page by URL for every visitor. Nitro hands Farm the
10755
+ // request without its cookies, Authorization, or any header the rule does not key on, so a
10756
+ // render that reads nothing of the request is that shared page, whatever its route config.
10757
+ const farmRouteRuleCached =
10758
+ Boolean(adapterContext?.routeRuleCache) &&
10759
+ (request.method === "GET" || request.method === "HEAD");
10685
10760
 
10686
10761
  // Get the page component and metadata
10687
10762
  let PageComponent = route.module.default;
@@ -10915,7 +10990,8 @@ ${hasServerRuntimeIntegrations ? `
10915
10990
  ${farmIslandsMode ? `// Islands mode: a route a shared cache may store (a PPR shell, a static page) renders
10916
10991
  // whole for every request, so a cache hit stays a hit. Other routes leave out what the
10917
10992
  // navigating browser keeps: the layouts it shows and the values it holds.
10918
- const farmSharedCacheableRoute = Boolean(getRouteSharedCacheControl(route, pprCanCache));
10993
+ const farmSharedCacheableRoute =
10994
+ farmRouteRuleCached || Boolean(getRouteSharedCacheControl(route, pprCanCache));
10919
10995
  if (farmSharedCacheableRoute) ignoreFarmHeldValues();
10920
10996
  const farmLayoutKeyOf = getFarmLayoutKey;
10921
10997
  // A navigation the browser renders in its layout's React root rebuilds a server-tree page
@@ -11180,6 +11256,24 @@ ${hasServerRuntimeIntegrations ? `
11180
11256
  middlewareData?.size ||
11181
11257
  middlewareContext?.size
11182
11258
  );
11259
+ if (farmRouteRuleCached && (renderedPage.stream || hasRequestScopedRender)) {
11260
+ // The route rule's cache refuses a private page: say why it renders on every request.
11261
+ emitFarmEvent({
11262
+ type: "cache.bypass",
11263
+ route: pathname,
11264
+ reason: pageStatus >= 400
11265
+ ? "error-status"
11266
+ : renderReadRequest
11267
+ ? "request-read"
11268
+ : middlewareData?.size || middlewareContext?.size
11269
+ ? "middleware-data"
11270
+ : hasConfiguredRouteContext
11271
+ ? "route-context"
11272
+ : renderedPage.stream
11273
+ ? "suspense-stream"
11274
+ : "request-scoped",
11275
+ });
11276
+ }
11183
11277
  const sharedCacheControl = getRouteSharedCacheControl(route, pprCanCache);
11184
11278
  const responseHeaders = {
11185
11279
  "Content-Type": "text/html; charset=utf-8",
@@ -11189,8 +11283,16 @@ ${hasServerRuntimeIntegrations ? `
11189
11283
  };
11190
11284
  // An error status or a request-scoped render is never shareable, even when
11191
11285
  // the PPR shell headers would otherwise grant a shared max-age.
11192
- if (renderedPage.stream || hasRequestScopedRender || !sharedCacheControl) {
11286
+ if (
11287
+ renderedPage.stream ||
11288
+ hasRequestScopedRender ||
11289
+ (!sharedCacheControl && !farmRouteRuleCached)
11290
+ ) {
11193
11291
  responseHeaders["Cache-Control"] = "private, no-store";
11292
+ } else if (responseHeaders["Cache-Control"] == null) {
11293
+ // A page with no policy of its own under a swr or cache route rule: the rule's cache
11294
+ // stores it and sends the rule's Cache-Control.
11295
+ delete responseHeaders["Cache-Control"];
11194
11296
  }
11195
11297
  const farmI18nSnapshot = getFarmI18nSnapshot();${farmIslandsMode ? `
11196
11298
  // Islands mode: a navigation that names the values it holds, or the layouts it shows,
@@ -12248,8 +12350,8 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
12248
12350
  const isVercel = preset === "vercel";
12249
12351
  const isCloudflareWorker = preset === "cloudflare-module";
12250
12352
  const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
12251
- const runtimeServerOutputDir = isVercel ? path12.join(outputDir, "functions", "__nitro.func") : path12.join(outputDir, "server");
12252
- const ssrOutputDir = path12.join(root, distDir, "ssr");
12353
+ const runtimeServerOutputDir = isVercel ? path13.join(outputDir, "functions", "__nitro.func") : path13.join(outputDir, "server");
12354
+ const ssrOutputDir = path13.join(root, distDir, "ssr");
12253
12355
  const imageRuntime = resolveFarmImageServerRuntime(config.images, preset);
12254
12356
  const hasGeneratedMetadataImages = Array.from(routeManager.getMetadataImages().values()).some(
12255
12357
  (image) => image.sourceType === "module"
@@ -12371,15 +12473,15 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
12371
12473
  resolveHashedClientCssHref(clientOutputDir),
12372
12474
  resolveHashedClientJsSrc(clientOutputDir),
12373
12475
  resolveClientBootSrc(clientOutputDir),
12374
- readFarmDocsModulePreloads(path12.join(root, distDir)),
12375
- readFarmClientModulePreloads(path12.join(root, distDir))
12476
+ readFarmDocsModulePreloads(path13.join(root, distDir)),
12477
+ readFarmClientModulePreloads(path13.join(root, distDir))
12376
12478
  ]);
12377
12479
  let nativeStylesheets;
12378
12480
  const encodedDocsModulePreloads = encodeFarmDocsModulePreloads(docsModulePreloads);
12379
12481
  const encodedClientModulePreloads = encodeFarmClientModulePreloads(clientModulePreloads);
12380
12482
  const encodedMobileShellClient = shouldBuildFarmMobileClient(config) ? encodeFarmMobileShellClient(
12381
12483
  await finalizeFarmMobileClient({
12382
- buildDir: path12.join(root, distDir),
12484
+ buildDir: path13.join(root, distDir),
12383
12485
  clientOutputDir,
12384
12486
  webEntry: clientJsSrc,
12385
12487
  webBoot: clientBootSrc,
@@ -12418,12 +12520,12 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
12418
12520
  await fs4.mkdir(ssrOutputDir, { recursive: true });
12419
12521
  await Promise.all(
12420
12522
  Object.entries(ssrBundle).map(async ([fileName, output]) => {
12421
- const filePath = path12.join(ssrOutputDir, fileName);
12422
- await fs4.mkdir(path12.dirname(filePath), { recursive: true });
12523
+ const filePath = path13.join(ssrOutputDir, fileName);
12524
+ await fs4.mkdir(path13.dirname(filePath), { recursive: true });
12423
12525
  await fs4.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
12424
12526
  })
12425
12527
  );
12426
- const nitroEntryPath = path12.join(ssrOutputDir, "nitro-entry.mjs");
12528
+ const nitroEntryPath = path13.join(ssrOutputDir, "nitro-entry.mjs");
12427
12529
  const nodeAdapterModule = preset === "node-server" ? resolveNitroRuntimeDependency(root, "srvx/node") : null;
12428
12530
  const hasNitroCacheRouteRules = hasFarmNitroCacheRouteRule(config.routeRules);
12429
12531
  const nitroEntryCode = `
@@ -12601,7 +12703,9 @@ ${hasNitroCacheRouteRules ? " let farmGuardedResponse = false\n" : ""} const r
12601
12703
  }${hasNitroCacheRouteRules ? `
12602
12704
  const farmCacheControl = response.headers.get('cache-control')
12603
12705
  if (
12604
- farmGuardedResponse &&
12706
+ // A guarded response, or any response Farm kept private under a swr or cache rule: the
12707
+ // rule's cache does not store it, and the rule's public Cache-Control must not reach a CDN.
12708
+ (farmGuardedResponse || event.context?.routeRules?.cache) &&
12605
12709
  farmCacheControl &&
12606
12710
  FARM_PRIVATE_CACHE_DIRECTIVE.test(farmCacheControl)
12607
12711
  ) {
@@ -12639,20 +12743,20 @@ function toFarmNodeResponse(request, response) {
12639
12743
  );
12640
12744
  }
12641
12745
  await fs4.writeFile(
12642
- path12.join(ssrOutputDir, FARM_DESKTOP_ENV_MODULE_FILE),
12746
+ path13.join(ssrOutputDir, FARM_DESKTOP_ENV_MODULE_FILE),
12643
12747
  FARM_DESKTOP_ENV_MODULE_SOURCE
12644
12748
  );
12645
12749
  }
12646
- const farmNodeServerEntryPath = preset === "node-server" ? path12.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
12750
+ const farmNodeServerEntryPath = preset === "node-server" ? path13.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
12647
12751
  if (farmNodeServerEntryPath && nodeAdapterModule) {
12648
12752
  await fs4.writeFile(
12649
- path12.join(ssrOutputDir, FARM_NODE_ENV_MODULE_FILE),
12753
+ path13.join(ssrOutputDir, FARM_NODE_ENV_MODULE_FILE),
12650
12754
  FARM_NODE_ENV_MODULE_SOURCE
12651
12755
  );
12652
12756
  await fs4.writeFile(
12653
12757
  farmNodeServerEntryPath,
12654
12758
  createFarmNodeServerEntry({
12655
- nitroEntryFile: path12.basename(nitroEntryPath),
12759
+ nitroEntryFile: path13.basename(nitroEntryPath),
12656
12760
  nodeAdapterModule,
12657
12761
  server: config.server,
12658
12762
  websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/node"),
@@ -12660,12 +12764,12 @@ function toFarmNodeResponse(request, response) {
12660
12764
  })
12661
12765
  );
12662
12766
  }
12663
- const farmBunServerEntryPath = preset === "bun" ? path12.join(ssrOutputDir, "farm-bun-server-entry.mjs") : null;
12767
+ const farmBunServerEntryPath = preset === "bun" ? path13.join(ssrOutputDir, "farm-bun-server-entry.mjs") : null;
12664
12768
  if (farmBunServerEntryPath) {
12665
12769
  await fs4.writeFile(
12666
12770
  farmBunServerEntryPath,
12667
12771
  createFarmBunServerEntry({
12668
- nitroEntryFile: path12.basename(nitroEntryPath),
12772
+ nitroEntryFile: path13.basename(nitroEntryPath),
12669
12773
  bunAdapterModule: resolveNitroRuntimeDependency(root, "srvx/bun"),
12670
12774
  server: config.server,
12671
12775
  websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/bun"),
@@ -12673,7 +12777,7 @@ function toFarmNodeResponse(request, response) {
12673
12777
  })
12674
12778
  );
12675
12779
  }
12676
- const farmNetlifyEntryPath = preset === "netlify" ? path12.join(ssrOutputDir, "farm-netlify-entry.mjs") : null;
12780
+ const farmNetlifyEntryPath = preset === "netlify" ? path13.join(ssrOutputDir, "farm-netlify-entry.mjs") : null;
12677
12781
  if (farmNetlifyEntryPath) {
12678
12782
  await fs4.writeFile(
12679
12783
  farmNetlifyEntryPath,
@@ -12682,7 +12786,7 @@ function toFarmNodeResponse(request, response) {
12682
12786
  })
12683
12787
  );
12684
12788
  }
12685
- const farmCloudflareEnvPath = preset === "cloudflare-pages" ? path12.join(ssrOutputDir, "farm-cloudflare-env.mjs") : null;
12789
+ const farmCloudflareEnvPath = preset === "cloudflare-pages" ? path13.join(ssrOutputDir, "farm-cloudflare-env.mjs") : null;
12686
12790
  if (farmCloudflareEnvPath) {
12687
12791
  await fs4.writeFile(
12688
12792
  farmCloudflareEnvPath,
@@ -12701,7 +12805,8 @@ function toFarmNodeResponse(request, response) {
12701
12805
  const configuredNitroRouteRules = nitroRouteRulesBelowBasePath(
12702
12806
  varyFarmNitroCacheRules(routeRulesToNitroRouteRules(config.routeRules), [
12703
12807
  ...config.md.enabled ? ["accept"] : [],
12704
- ...shouldBuildFarmMobileClient(config) ? ["x-farm-shell"] : []
12808
+ ...shouldBuildFarmMobileClient(config) ? ["x-farm-shell"] : [],
12809
+ ...resolveFarmServerComponentsMode(config.experimental?.serverComponents) === "islands" ? ["f-layouts"] : []
12705
12810
  ]),
12706
12811
  config.basePath,
12707
12812
  resolveFarmAPIServerBasePath(config.api)
@@ -12729,6 +12834,18 @@ function toFarmNodeResponse(request, response) {
12729
12834
  ];
12730
12835
  })
12731
12836
  );
12837
+ const immutableAssets = isVercel ? { publicAssets: [], routeRules: {} } : planFarmImmutableAssets({
12838
+ clientOutputDir,
12839
+ files: await listFarmClientOutputFiles(clientOutputDir),
12840
+ routeRules: configuredNitroRouteRules,
12841
+ routePaths: [
12842
+ ...[...routeManager.getRoutes().keys()].map(
12843
+ (pattern) => applyFarmBasePath(pattern, config.basePath)
12844
+ ),
12845
+ ...apiRouteManager.getRoutes().keys(),
12846
+ resolveFarmAPIServerBasePath(config.api)
12847
+ ]
12848
+ });
12732
12849
  let nitroConfig = {
12733
12850
  preset,
12734
12851
  ...farmNodeServerEntryPath ? { entry: farmNodeServerEntryPath } : {},
@@ -12743,17 +12860,13 @@ function toFarmNodeResponse(request, response) {
12743
12860
  // `src` directory), as Nitro handlers outside Farm's aliases.
12744
12861
  serverDir: false,
12745
12862
  serverEntry: false,
12746
- buildDir: path12.join(root, distDir, ".nitro"),
12863
+ buildDir: path13.join(root, distDir, ".nitro"),
12747
12864
  alias: resolveNitroInternalRuntimeAliases(root),
12748
12865
  compatibilityDate: "2024-12-01",
12749
12866
  output: resolveFarmNitroOutputConfig(preset, outputDir),
12750
- publicAssets: [
12751
- {
12752
- dir: clientOutputDir,
12753
- maxAge: 31536e3,
12754
- baseURL: "/"
12755
- }
12756
- ],
12867
+ // Nitro gives the root directory no Cache-Control on any preset (it falls through to the
12868
+ // app), so public files keep revalidating; the hashed directories carry their own maxAge.
12869
+ publicAssets: [{ dir: clientOutputDir, baseURL: "/" }, ...immutableAssets.publicAssets],
12757
12870
  // A self-hosted Node server sends static files itself, so precompress them
12758
12871
  // with gzip and let Nitro serve that by Accept-Encoding. Brotli at Nitro's
12759
12872
  // fixed top quality cost a docs app ~20 s of build CPU for a small further
@@ -12807,6 +12920,7 @@ function toFarmNodeResponse(request, response) {
12807
12920
  "/**": {
12808
12921
  prerender: false
12809
12922
  },
12923
+ ...immutableAssets.routeRules,
12810
12924
  ...configuredNitroRouteRules,
12811
12925
  // Exact user rules must retain their runtime settings without replacing
12812
12926
  // the headers and prerender marker generated for a safe physical page.
@@ -12835,7 +12949,7 @@ function toFarmNodeResponse(request, response) {
12835
12949
  if (pluginManager) {
12836
12950
  nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
12837
12951
  }
12838
- const expectedServerDir = path12.join(outputDir, "server");
12952
+ const expectedServerDir = path13.join(outputDir, "server");
12839
12953
  const customRollupKeys = Object.keys(nitroConfig.rollupConfig || {}).filter(
12840
12954
  (key) => key !== "external" && key !== "plugins"
12841
12955
  );
@@ -12850,10 +12964,10 @@ function toFarmNodeResponse(request, response) {
12850
12964
  const requestedBuilder = nitroConfig.builder ?? process.env.NITRO_BUILDER;
12851
12965
  const nitroBuildIsFarms = (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 && Boolean(
12852
12966
  nitroConfig.handlers?.some(
12853
- (handler) => path12.resolve(handler?.handler || "") === nitroEntryPath
12967
+ (handler) => path13.resolve(handler?.handler || "") === nitroEntryPath
12854
12968
  )
12855
12969
  );
12856
- const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && nitroBuildIsFarms && path12.resolve(nitroConfig.output?.serverDir || "") === path12.resolve(expectedServerDir);
12970
+ const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && nitroBuildIsFarms && path13.resolve(nitroConfig.output?.serverDir || "") === path13.resolve(expectedServerDir);
12857
12971
  const prerenderReusesPrebuiltSSR = prerenderRoutes.length > 0 && ssrExternalsArePackaged && nitroBuildIsFarms;
12858
12972
  const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
12859
12973
  if (selectRolldownBuilder) nitroConfig.builder = "rolldown";
@@ -12959,8 +13073,8 @@ function toFarmNodeResponse(request, response) {
12959
13073
  };
12960
13074
  prerendererConfig.output = {
12961
13075
  ...prerendererConfig.output,
12962
- serverDir: path12.join(
12963
- prerendererConfig.buildDir ?? path12.join(root, distDir, ".nitro"),
13076
+ serverDir: path13.join(
13077
+ prerendererConfig.buildDir ?? path13.join(root, distDir, ".nitro"),
12964
13078
  "prerender"
12965
13079
  )
12966
13080
  };
@@ -12979,7 +13093,7 @@ function toFarmNodeResponse(request, response) {
12979
13093
  const prerenderServerDir = prerenderer.options.output.serverDir;
12980
13094
  await copyPrebuiltSSRBundle(
12981
13095
  ssrBundle,
12982
- path12.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
13096
+ path13.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
12983
13097
  null,
12984
13098
  fs4
12985
13099
  );
@@ -13055,7 +13169,7 @@ function toFarmNodeResponse(request, response) {
13055
13169
  const copyResults = await Promise.allSettled([
13056
13170
  prebuiltSSRFilesResult.value ? writeSSRBundleFiles(
13057
13171
  prebuiltSSRFilesResult.value,
13058
- path12.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
13172
+ path13.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
13059
13173
  fs4
13060
13174
  ) : Promise.resolve(),
13061
13175
  runtimeCopyPromise
@@ -13065,14 +13179,14 @@ function toFarmNodeResponse(request, response) {
13065
13179
  );
13066
13180
  if (failedCopy) throw failedCopy.reason;
13067
13181
  if (canReusePrebuiltSSR) {
13068
- await registerPrebuiltSSRPackageImport(path12.join(outputDir, "server"), ssrEntryFile, fs4);
13182
+ await registerPrebuiltSSRPackageImport(path13.join(outputDir, "server"), ssrEntryFile, fs4);
13069
13183
  logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
13070
13184
  }
13071
13185
  if (useRolldownBuilder) {
13072
13186
  logger.info("\u26A1 Built the Node adapter with Rolldown");
13073
13187
  }
13074
13188
  if (preset === "node-server" && !desktopServerEntry) {
13075
- await installFarmCompileCacheLauncher(path12.join(outputDir, "server"), fs4);
13189
+ await installFarmCompileCacheLauncher(path13.join(outputDir, "server"), fs4);
13076
13190
  }
13077
13191
  if (preset.startsWith("cloudflare")) {
13078
13192
  await populateCloudflareProcessEnv(nitroInstance.options.output.serverDir, fs4);
@@ -13095,7 +13209,7 @@ function toFarmNodeResponse(request, response) {
13095
13209
  routeRuntimeManifest,
13096
13210
  farmCron.provider === "host" ? farmCron.jobs : [],
13097
13211
  {
13098
- buildDir: path12.join(root, distDir),
13212
+ buildDir: path13.join(root, distDir),
13099
13213
  middlewareRoutes: edgeMiddlewareRoutes,
13100
13214
  guardedPages: edgeGuardedPrerenderRoutes
13101
13215
  },
@@ -13109,16 +13223,16 @@ function resolveFarmNitroOutputConfig(preset, outputDir) {
13109
13223
  return {
13110
13224
  dir: outputDir,
13111
13225
  ...preset === "node-server" ? {
13112
- serverDir: path12.join(outputDir, "server"),
13113
- publicDir: path12.join(outputDir, "public")
13226
+ serverDir: path13.join(outputDir, "server"),
13227
+ publicDir: path13.join(outputDir, "public")
13114
13228
  } : isVercel ? {
13115
- serverDir: path12.join(outputDir, "functions", "__nitro.func"),
13116
- publicDir: path12.join(outputDir, "static")
13229
+ serverDir: path13.join(outputDir, "functions", "__nitro.func"),
13230
+ publicDir: path13.join(outputDir, "static")
13117
13231
  } : {}
13118
13232
  };
13119
13233
  }
13120
13234
  async function populateCloudflareProcessEnv(serverDir, fs4) {
13121
- const wranglerPath = path12.join(serverDir, "wrangler.json");
13235
+ const wranglerPath = path13.join(serverDir, "wrangler.json");
13122
13236
  let source;
13123
13237
  try {
13124
13238
  source = await fs4.readFile(wranglerPath, "utf8");
@@ -13146,8 +13260,8 @@ async function writeSSRBundleFiles(files, targetDir, fs4) {
13146
13260
  await fs4.rm(targetDir, { recursive: true, force: true });
13147
13261
  await Promise.all(
13148
13262
  files.map(async ({ fileName, contents }) => {
13149
- const targetPath = path12.join(targetDir, fileName);
13150
- await fs4.mkdir(path12.dirname(targetPath), { recursive: true });
13263
+ const targetPath = path13.join(targetDir, fileName);
13264
+ await fs4.mkdir(path13.dirname(targetPath), { recursive: true });
13151
13265
  await fs4.writeFile(targetPath, contents);
13152
13266
  })
13153
13267
  );
@@ -13156,8 +13270,8 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions, fs4) {
13156
13270
  await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir, fs4);
13157
13271
  }
13158
13272
  async function installFarmCompileCacheLauncher(serverDir, fs4) {
13159
- const entryPath = path12.join(serverDir, "index.mjs");
13160
- const serverPath = path12.join(serverDir, FARM_SERVER_MODULE_FILE);
13273
+ const entryPath = path13.join(serverDir, "index.mjs");
13274
+ const serverPath = path13.join(serverDir, FARM_SERVER_MODULE_FILE);
13161
13275
  const entry = await fs4.readFile(entryPath, "utf8").catch((error) => {
13162
13276
  if (error.code === "ENOENT") return null;
13163
13277
  throw error;
@@ -13166,11 +13280,11 @@ async function installFarmCompileCacheLauncher(serverDir, fs4) {
13166
13280
  if (entry.includes(`./${FARM_SERVER_MODULE_FILE}`)) return false;
13167
13281
  await fs4.rename(entryPath, serverPath);
13168
13282
  await fs4.writeFile(entryPath, createFarmCompileCacheLauncher(FARM_SERVER_MODULE_FILE));
13169
- await fs4.rm(path12.join(serverDir, FARM_COMPILE_CACHE_DIR), { recursive: true, force: true });
13283
+ await fs4.rm(path13.join(serverDir, FARM_COMPILE_CACHE_DIR), { recursive: true, force: true });
13170
13284
  return true;
13171
13285
  }
13172
13286
  async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs4) {
13173
- const packagePath = path12.join(serverDir, "package.json");
13287
+ const packagePath = path13.join(serverDir, "package.json");
13174
13288
  const packageJSON = await fs4.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
13175
13289
  if (error.code === "ENOENT") return { type: "module" };
13176
13290
  throw error;
@@ -13199,18 +13313,18 @@ async function moveVercelOutputPath(src, dest, fs4) {
13199
13313
  await fs4.rm(src, { recursive: true, force: true });
13200
13314
  }
13201
13315
  async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflows, routeRuntimeManifest, cronJobs, edgeMiddleware, prerenderedPages) {
13202
- const serverDir = path12.join(outputDir, "server");
13203
- const functionsDir = path12.join(outputDir, "functions");
13204
- const nitroFuncDir = path12.join(functionsDir, "__nitro.func");
13205
- const staticDir = path12.join(outputDir, "static");
13206
- const publicDir = path12.join(outputDir, "public");
13316
+ const serverDir = path13.join(outputDir, "server");
13317
+ const functionsDir = path13.join(outputDir, "functions");
13318
+ const nitroFuncDir = path13.join(functionsDir, "__nitro.func");
13319
+ const staticDir = path13.join(outputDir, "static");
13320
+ const publicDir = path13.join(outputDir, "public");
13207
13321
  await fs4.mkdir(nitroFuncDir, { recursive: true });
13208
13322
  const serverContents = await fs4.readdir(serverDir).catch((error) => {
13209
13323
  if (error.code === "ENOENT") return [];
13210
13324
  throw error;
13211
13325
  });
13212
13326
  for (const file of serverContents) {
13213
- await moveVercelOutputPath(path12.join(serverDir, file), path12.join(nitroFuncDir, file), fs4);
13327
+ await moveVercelOutputPath(path13.join(serverDir, file), path13.join(nitroFuncDir, file), fs4);
13214
13328
  }
13215
13329
  if (serverContents.length > 0) await fs4.rm(serverDir, { recursive: true, force: true });
13216
13330
  try {
@@ -13220,7 +13334,7 @@ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflo
13220
13334
  }
13221
13335
  await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4);
13222
13336
  await copyPrismaClientForVercel(root, nitroFuncDir, fs4);
13223
- const configPath = path12.join(outputDir, "config.json");
13337
+ const configPath = path13.join(outputDir, "config.json");
13224
13338
  const configContent = await fs4.readFile(configPath, "utf-8");
13225
13339
  const vercelConfig = JSON.parse(configContent);
13226
13340
  const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
@@ -13264,7 +13378,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4) {
13264
13378
  mainRoot,
13265
13379
  root,
13266
13380
  config.srcDir,
13267
- path12.join(nitroFuncDir, "farm-docs-content"),
13381
+ path13.join(nitroFuncDir, "farm-docs-content"),
13268
13382
  fs4
13269
13383
  );
13270
13384
  for (const [index, docsRoot] of extraRoots.entries()) {
@@ -13272,7 +13386,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4) {
13272
13386
  docsRoot,
13273
13387
  root,
13274
13388
  config.srcDir,
13275
- path12.join(nitroFuncDir, "farm-docs-roots", String(index)),
13389
+ path13.join(nitroFuncDir, "farm-docs-roots", String(index)),
13276
13390
  fs4
13277
13391
  );
13278
13392
  }
@@ -13290,18 +13404,18 @@ async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir, fs
13290
13404
  );
13291
13405
  }
13292
13406
  await fs4.rm(bundledContentDir, { recursive: true, force: true });
13293
- await fs4.mkdir(path12.dirname(bundledContentDir), { recursive: true });
13407
+ await fs4.mkdir(path13.dirname(bundledContentDir), { recursive: true });
13294
13408
  await fs4.cp(docsContentDir, bundledContentDir, {
13295
13409
  recursive: true,
13296
13410
  force: true,
13297
13411
  dereference: true
13298
13412
  });
13299
13413
  await fs4.writeFile(
13300
- path12.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
13414
+ path13.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
13301
13415
  `${JSON.stringify(lastModifiedManifest, null, 2)}
13302
13416
  `
13303
13417
  );
13304
- logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path12.relative(root, docsContentDir)}`);
13418
+ logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path13.relative(root, docsContentDir)}`);
13305
13419
  }
13306
13420
  function resolveServerFunctionPlatform(preset) {
13307
13421
  return preset === "vercel" || preset === "netlify" ? { os: "linux", cpu: "x64", libc: "glibc" } : null;
@@ -13318,7 +13432,7 @@ function platformFieldAllows(field, value) {
13318
13432
  }
13319
13433
  async function stageSharpRuntime(config, root, distDir, fs4, preset) {
13320
13434
  const functionPlatform = resolveServerFunctionPlatform(preset);
13321
- const projectRequire = createRequire2(path12.join(root, "package.json"));
13435
+ const projectRequire = createRequire2(path13.join(root, "package.json"));
13322
13436
  let sharpRequire = projectRequire;
13323
13437
  if (!resolvePackageJson(projectRequire, "sharp")) {
13324
13438
  try {
@@ -13328,10 +13442,10 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
13328
13442
  }
13329
13443
  const copiedPackages = /* @__PURE__ */ new Map();
13330
13444
  const packageCopies = /* @__PURE__ */ new Map();
13331
- const stageRoot = path12.join(root, distDir, "tmp");
13445
+ const stageRoot = path13.join(root, distDir, "tmp");
13332
13446
  await fs4.mkdir(stageRoot, { recursive: true });
13333
- const stageDir = await fs4.mkdtemp(path12.join(stageRoot, "sharp-runtime-"));
13334
- const targetNodeModules = path12.join(stageDir, "node_modules");
13447
+ const stageDir = await fs4.mkdtemp(path13.join(stageRoot, "sharp-runtime-"));
13448
+ const targetNodeModules = path13.join(stageDir, "node_modules");
13335
13449
  function copyPackage(packageName, parentRequire) {
13336
13450
  const activeCopy = packageCopies.get(packageName);
13337
13451
  if (activeCopy) return activeCopy;
@@ -13344,10 +13458,10 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
13344
13458
  if (!packageJsonPath) return;
13345
13459
  const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf8"));
13346
13460
  if (functionPlatform && !packageSupportsPlatform(packageJson, functionPlatform)) return;
13347
- const packageDir = path12.dirname(packageJsonPath);
13348
- const targetDir = path12.join(targetNodeModules, ...packageName.split("/"));
13461
+ const packageDir = path13.dirname(packageJsonPath);
13462
+ const targetDir = path13.join(targetNodeModules, ...packageName.split("/"));
13349
13463
  copiedPackages.set(packageName, String(packageJson.version || "*"));
13350
- await fs4.mkdir(path12.dirname(targetDir), { recursive: true });
13464
+ await fs4.mkdir(path13.dirname(targetDir), { recursive: true });
13351
13465
  const packageRequire = createRequire2(packageJsonPath);
13352
13466
  const dependencies = {
13353
13467
  ...packageJson.dependencies,
@@ -13382,8 +13496,8 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
13382
13496
  };
13383
13497
  }
13384
13498
  async function installStagedSharpRuntime(staged, nitroFuncDir, fs4) {
13385
- const stagedNodeModules = path12.join(staged.stageDir, "node_modules");
13386
- const targetNodeModules = path12.join(nitroFuncDir, "node_modules");
13499
+ const stagedNodeModules = path13.join(staged.stageDir, "node_modules");
13500
+ const targetNodeModules = path13.join(nitroFuncDir, "node_modules");
13387
13501
  try {
13388
13502
  await mergeStagedDirectory(stagedNodeModules, targetNodeModules, fs4);
13389
13503
  const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs4);
@@ -13411,8 +13525,8 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs4) {
13411
13525
  const entries = await fs4.readdir(sourceDir, { withFileTypes: true });
13412
13526
  await settleAllOrThrow(
13413
13527
  entries.map(async (entry) => {
13414
- const sourcePath = path12.join(sourceDir, entry.name);
13415
- const targetPath = path12.join(targetDir, entry.name);
13528
+ const sourcePath = path13.join(sourceDir, entry.name);
13529
+ const targetPath = path13.join(targetDir, entry.name);
13416
13530
  try {
13417
13531
  await fs4.rename(sourcePath, targetPath);
13418
13532
  return;
@@ -13439,13 +13553,13 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs4) {
13439
13553
  function assertMetadataImageRuntimeInstalled(root, metadataImageRoutes) {
13440
13554
  const generated = metadataImageRoutes.find((image) => image.sourceType === "module");
13441
13555
  if (!generated || resolveMetadataImageRuntimePackageJson(root)) return;
13442
- const file = generated.modulePath ? toPosixPath(path12.relative(root, generated.modulePath)) : "";
13556
+ const file = generated.modulePath ? toPosixPath(path13.relative(root, generated.modulePath)) : "";
13443
13557
  throw new Error(
13444
13558
  `${file || "A generated metadata image"} renders with @vercel/og, which is not installed. ${VERCEL_OG_INSTALL_HINT}`
13445
13559
  );
13446
13560
  }
13447
13561
  function resolveMetadataImageRuntimePackageJson(root) {
13448
- const projectRequire = createRequire2(path12.join(root, "package.json"));
13562
+ const projectRequire = createRequire2(path13.join(root, "package.json"));
13449
13563
  const packageJsonPath = resolvePackageJson(projectRequire, "@vercel/og");
13450
13564
  if (packageJsonPath) return packageJsonPath;
13451
13565
  try {
@@ -13458,9 +13572,9 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs4) {
13458
13572
  const packageJsonPath = resolveMetadataImageRuntimePackageJson(root);
13459
13573
  if (!packageJsonPath) return;
13460
13574
  const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf8"));
13461
- const packageDir = path12.dirname(packageJsonPath);
13462
- const targetDir = path12.join(nitroFuncDir, "node_modules", "@vercel", "og");
13463
- await fs4.mkdir(path12.dirname(targetDir), { recursive: true });
13575
+ const packageDir = path13.dirname(packageJsonPath);
13576
+ const targetDir = path13.join(nitroFuncDir, "node_modules", "@vercel", "og");
13577
+ await fs4.mkdir(path13.dirname(targetDir), { recursive: true });
13464
13578
  await fs4.cp(packageDir, targetDir, {
13465
13579
  recursive: true,
13466
13580
  force: true,
@@ -13476,7 +13590,7 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs4) {
13476
13590
  logger.info("\u{1F5BC}\uFE0F Bundled generated metadata image runtime");
13477
13591
  }
13478
13592
  async function readNitroOutputPackage(outputDir, fs4) {
13479
- const packagePath = path12.join(outputDir, "package.json");
13593
+ const packagePath = path13.join(outputDir, "package.json");
13480
13594
  return fs4.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
13481
13595
  if (error.code === "ENOENT") return {};
13482
13596
  throw error;
@@ -13485,7 +13599,7 @@ async function readNitroOutputPackage(outputDir, fs4) {
13485
13599
  async function writeNitroOutputPackage(outputDir, packageJson, fs4) {
13486
13600
  await fs4.mkdir(outputDir, { recursive: true });
13487
13601
  await fs4.writeFile(
13488
- path12.join(outputDir, "package.json"),
13602
+ path13.join(outputDir, "package.json"),
13489
13603
  `${JSON.stringify(packageJson, null, 2)}
13490
13604
  `
13491
13605
  );
@@ -13501,9 +13615,9 @@ function resolvePackageJson(parentRequire, packageName) {
13501
13615
  }
13502
13616
  }
13503
13617
  try {
13504
- let directory = path12.dirname(metadataModule ?? parentRequire.resolve(packageName));
13505
- while (directory !== path12.dirname(directory)) {
13506
- const candidate = path12.join(directory, "package.json");
13618
+ let directory = path13.dirname(metadataModule ?? parentRequire.resolve(packageName));
13619
+ while (directory !== path13.dirname(directory)) {
13620
+ const candidate = path13.join(directory, "package.json");
13507
13621
  if (existsSync2(candidate)) {
13508
13622
  try {
13509
13623
  const manifest = JSON.parse(readFileSync(candidate, "utf8"));
@@ -13511,23 +13625,23 @@ function resolvePackageJson(parentRequire, packageName) {
13511
13625
  } catch {
13512
13626
  }
13513
13627
  }
13514
- if (path12.basename(directory) === "node_modules") break;
13515
- directory = path12.dirname(directory);
13628
+ if (path13.basename(directory) === "node_modules") break;
13629
+ directory = path13.dirname(directory);
13516
13630
  }
13517
13631
  } catch {
13518
13632
  }
13519
13633
  return null;
13520
13634
  }
13521
13635
  async function resolveProjectInstalledPackageDir(root, packageName, fs4) {
13522
- let directory = path12.resolve(root);
13636
+ let directory = path13.resolve(root);
13523
13637
  while (true) {
13524
- const candidate = path12.join(directory, "node_modules", ...packageName.split("/"));
13638
+ const candidate = path13.join(directory, "node_modules", ...packageName.split("/"));
13525
13639
  try {
13526
13640
  const packageDir = await fs4.realpath(candidate);
13527
- if ((await fs4.stat(path12.join(packageDir, "package.json"))).isFile()) return packageDir;
13641
+ if ((await fs4.stat(path13.join(packageDir, "package.json"))).isFile()) return packageDir;
13528
13642
  } catch {
13529
13643
  }
13530
- const parent = path12.dirname(directory);
13644
+ const parent = path13.dirname(directory);
13531
13645
  if (parent === directory) return null;
13532
13646
  directory = parent;
13533
13647
  }
@@ -13535,16 +13649,16 @@ async function resolveProjectInstalledPackageDir(root, packageName, fs4) {
13535
13649
  async function copyPrismaClientForVercel(root, nitroFuncDir, fs4) {
13536
13650
  const prismaClientDir = await resolveProjectInstalledPackageDir(root, "@prisma/client", fs4);
13537
13651
  if (!prismaClientDir) return;
13538
- const generatedClientDir = path12.join(prismaClientDir, "..", "..", ".prisma", "client");
13652
+ const generatedClientDir = path13.join(prismaClientDir, "..", "..", ".prisma", "client");
13539
13653
  try {
13540
13654
  await fs4.access(generatedClientDir);
13541
13655
  } catch {
13542
13656
  return;
13543
13657
  }
13544
- const targetNodeModules = path12.join(nitroFuncDir, "node_modules");
13545
- const targetPrismaScopeDir = path12.join(targetNodeModules, "@prisma");
13546
- const targetGeneratedDir = path12.join(targetNodeModules, ".prisma", "client");
13547
- const targetClientDir = path12.join(targetPrismaScopeDir, "client");
13658
+ const targetNodeModules = path13.join(nitroFuncDir, "node_modules");
13659
+ const targetPrismaScopeDir = path13.join(targetNodeModules, "@prisma");
13660
+ const targetGeneratedDir = path13.join(targetNodeModules, ".prisma", "client");
13661
+ const targetClientDir = path13.join(targetPrismaScopeDir, "client");
13548
13662
  await fs4.mkdir(targetPrismaScopeDir, { recursive: true });
13549
13663
  await fs4.cp(prismaClientDir, targetClientDir, {
13550
13664
  recursive: true,
@@ -13554,7 +13668,7 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs4) {
13554
13668
  recursive: true,
13555
13669
  force: true
13556
13670
  });
13557
- const clientPackagePath = path12.join(prismaClientDir, "package.json");
13671
+ const clientPackagePath = path13.join(prismaClientDir, "package.json");
13558
13672
  const [functionPackage, clientPackageContent] = await Promise.all([
13559
13673
  readNitroOutputPackage(nitroFuncDir, fs4),
13560
13674
  fs4.readFile(clientPackagePath, "utf-8")
@@ -13740,9 +13854,9 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
13740
13854
  } else {
13741
13855
  const { build: legacyViteBuild } = await import("vite");
13742
13856
  logger.info("\u{1F4E6} Building client bundle...");
13743
- await buildClient2(legacyViteBuild, config, root, srcDir, path13.join(root, distDir, "client"));
13857
+ await buildClient2(legacyViteBuild, config, root, srcDir, path14.join(root, distDir, "client"));
13744
13858
  logger.info("\u{1F4E6} Building SSR bundle...");
13745
- await buildSSR(legacyViteBuild, config, root, srcDir, path13.join(root, distDir, "server"));
13859
+ await buildSSR(legacyViteBuild, config, root, srcDir, path14.join(root, distDir, "server"));
13746
13860
  logger.info(`\u{1F680} Building server with Nitro (preset: ${preset})...`);
13747
13861
  await buildNitro(
13748
13862
  config,
@@ -13844,8 +13958,8 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
13844
13958
  root,
13845
13959
  // Vite keys its pre-bundled dependencies on the config, mode included, so this server and
13846
13960
  // `farm dev` sharing one cache would each rebuild it after the other ran.
13847
- cacheDir: path13.join(
13848
- path13.resolve(root, viteConfig.cacheDir ?? path13.join("node_modules", ".vite")),
13961
+ cacheDir: path14.join(
13962
+ path14.resolve(root, viteConfig.cacheDir ?? path14.join("node_modules", ".vite")),
13849
13963
  "farm-build"
13850
13964
  ),
13851
13965
  configFile: false,
@@ -13879,7 +13993,7 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
13879
13993
  }
13880
13994
  async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
13881
13995
  const { farmI18nClientBridgePlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
13882
- const { PluginManager: PluginManager2 } = await import("./plugin-VEBRN7A3.mjs");
13996
+ const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
13883
13997
  const pluginManager = new PluginManager2({
13884
13998
  config,
13885
13999
  isDev: false,
@@ -13906,7 +14020,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
13906
14020
  }
13907
14021
  async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
13908
14022
  const { farmI18nClientBridgePlugin, farmPlugin } = await import("./vite.mjs");
13909
- const { PluginManager: PluginManager2 } = await import("./plugin-VEBRN7A3.mjs");
14023
+ const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
13910
14024
  const pluginManager = new PluginManager2({
13911
14025
  config,
13912
14026
  isDev: false,
@@ -13938,16 +14052,16 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
13938
14052
  });
13939
14053
  }
13940
14054
  function resolveLegacyPageEntry(config, root, srcDir) {
13941
- const appDir = path13.join(root, srcDir, "app");
14055
+ const appDir = path14.join(root, srcDir, "app");
13942
14056
  for (const extension of getFarmRendererComponentExtensions(config.renderer)) {
13943
- const candidate = path13.join(appDir, `page${extension}`);
14057
+ const candidate = path14.join(appDir, `page${extension}`);
13944
14058
  if (existsSync3(candidate)) return candidate;
13945
14059
  }
13946
- return path13.join(appDir, "page.tsx");
14060
+ return path14.join(appDir, "page.tsx");
13947
14061
  }
13948
14062
  async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
13949
14063
  const [{ createNitroConfig }, { createNitro, build: nitroBuild }] = await Promise.all([
13950
- import("./nitro-NSTXT7LB.mjs"),
14064
+ import("./nitro-72TFIGGO.mjs"),
13951
14065
  import("nitro/builder")
13952
14066
  ]);
13953
14067
  let nitroConfig = await createNitroConfig(
@@ -13961,18 +14075,18 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
13961
14075
  nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
13962
14076
  }
13963
14077
  const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
13964
- const serverOutputDir = path13.join(outputDir, "server");
13965
- const publicOutputDir = path13.join(outputDir, "public");
14078
+ const serverOutputDir = path14.join(outputDir, "server");
14079
+ const publicOutputDir = path14.join(outputDir, "public");
13966
14080
  const { mkdir, cp } = await import("fs/promises");
13967
14081
  await mkdir(serverOutputDir, { recursive: true });
13968
14082
  await mkdir(publicOutputDir, { recursive: true });
13969
- const clientDir = path13.join(root, distDir, "client");
14083
+ const clientDir = path14.join(root, distDir, "client");
13970
14084
  try {
13971
14085
  await mkdir(publicOutputDir, { recursive: true });
13972
14086
  await cp(clientDir, publicOutputDir, { recursive: true });
13973
14087
  logger.info("\u{1F4E6} Copied client assets to public directory");
13974
- const manifestPath = path13.join(publicOutputDir, "farm-client-manifest.json");
13975
- const assetsDir = path13.join(publicOutputDir, "assets");
14088
+ const manifestPath = path14.join(publicOutputDir, "farm-client-manifest.json");
14089
+ const assetsDir = path14.join(publicOutputDir, "assets");
13976
14090
  const manifestExists = await import("fs/promises").then(
13977
14091
  (fs4) => fs4.access(manifestPath).then(() => true).catch(() => false)
13978
14092
  );
@@ -13988,8 +14102,8 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
13988
14102
  logger.error(`\u274C Failed to copy client assets: ${error}`);
13989
14103
  throw error;
13990
14104
  }
13991
- const serverDir = path13.join(root, distDir, "server");
13992
- const nitroServerDir = path13.join(root, distDir, ".nitro", "server", "farm");
14105
+ const serverDir = path14.join(root, distDir, "server");
14106
+ const nitroServerDir = path14.join(root, distDir, ".nitro", "server", "farm");
13993
14107
  try {
13994
14108
  await mkdir(nitroServerDir, { recursive: true });
13995
14109
  await cp(serverDir, nitroServerDir, { recursive: true });
@@ -13998,7 +14112,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
13998
14112
  logger.warn(`Could not copy SSR bundles: ${error}`);
13999
14113
  }
14000
14114
  const nitro = await createNitro(nitroConfig);
14001
- const registryPath = path13.join(root, distDir, ".nitro", "server", "farm-registry.ts");
14115
+ const registryPath = path14.join(root, distDir, ".nitro", "server", "farm-registry.ts");
14002
14116
  try {
14003
14117
  const { farmRegistry } = await import(
14004
14118
  /* @vite-ignore */
@@ -14015,7 +14129,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
14015
14129
  }
14016
14130
  farmRegistry.routePaths = routePaths;
14017
14131
  try {
14018
- const clientManifestPath = path13.join(root, distDir, "client", "farm-client-manifest.json");
14132
+ const clientManifestPath = path14.join(root, distDir, "client", "farm-client-manifest.json");
14019
14133
  const { readFile } = await import("fs/promises");
14020
14134
  const manifestContent = await readFile(clientManifestPath, "utf-8");
14021
14135
  farmRegistry.clientManifest = JSON.parse(manifestContent);