@farm.js/core 0.1.19 → 0.1.21

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 (165) hide show
  1. package/dist/agent-runtime.d.mts +2 -3
  2. package/dist/agent-runtime.d.ts +2 -3
  3. package/dist/api/route-manager.cjs +5 -5
  4. package/dist/api/route-manager.d.mts +2 -3
  5. package/dist/api/route-manager.d.ts +2 -3
  6. package/dist/api/route-manager.mjs +4 -4
  7. package/dist/api.cjs +6 -6
  8. package/dist/api.d.mts +3 -4
  9. package/dist/api.d.ts +3 -4
  10. package/dist/api.mjs +5 -5
  11. package/dist/{app-BHY_10Lm.d.ts → app-DAyPE-gr.d.ts} +11 -4
  12. package/dist/{app-BMk0do23.d.mts → app-D_6nTit-.d.mts} +11 -4
  13. package/dist/app-markdown.d.mts +3 -4
  14. package/dist/app-markdown.d.ts +3 -4
  15. package/dist/{chunk-FS7FLPOG.mjs → chunk-2J7W2WND.mjs} +3 -2
  16. package/dist/{chunk-YS3TRKCG.mjs → chunk-2M435BUE.mjs} +6 -1
  17. package/dist/{chunk-WJ3HK3LJ.cjs → chunk-2QLBIPFT.cjs} +4 -4
  18. package/dist/{chunk-FJSWYIR7.cjs → chunk-3IL5UC5I.cjs} +2 -2
  19. package/dist/chunk-43FMW62B.mjs +67 -0
  20. package/dist/{chunk-WZXN4R5Y.mjs → chunk-53G3OLTA.mjs} +106 -75
  21. package/dist/{chunk-FVZGEVTO.mjs → chunk-5L6NBNHI.mjs} +123 -41
  22. package/dist/{chunk-A7T6345N.mjs → chunk-5UX4C5QI.mjs} +10 -7
  23. package/dist/chunk-75WGQVQA.cjs +46 -0
  24. package/dist/{chunk-AFOD3LYZ.cjs → chunk-B3WK4DTX.cjs} +10 -9
  25. package/dist/{chunk-AORPIPNB.cjs → chunk-BHJUZ64B.cjs} +18 -14
  26. package/dist/chunk-BMWDEBXO.cjs +67 -0
  27. package/dist/{chunk-ATERBVHQ.mjs → chunk-CQHFU55R.mjs} +5 -4
  28. package/dist/{chunk-XSKZORAS.cjs → chunk-DX4VKYAJ.cjs} +5 -5
  29. package/dist/{chunk-7WPA7GBZ.mjs → chunk-GHFS7RUB.mjs} +1 -1
  30. package/dist/{chunk-NZ2JVBT2.mjs → chunk-GZ3ZPTQV.mjs} +2 -2
  31. package/dist/{chunk-RKQVJN2O.mjs → chunk-JIKGGIOL.mjs} +1 -1
  32. package/dist/{chunk-OXSIH4D6.cjs → chunk-KNPRCKXK.cjs} +6 -1
  33. package/dist/{chunk-XDGMADQM.cjs → chunk-L7ARWZYT.cjs} +384 -353
  34. package/dist/{chunk-2ANEVVF7.mjs → chunk-NRS46D4L.mjs} +1 -1
  35. package/dist/{chunk-A72YEUZ3.mjs → chunk-OCE65DDM.mjs} +1 -1
  36. package/dist/{chunk-2GNATDDE.mjs → chunk-PKO4FCTL.mjs} +1 -1
  37. package/dist/{chunk-UDBJCUPA.mjs → chunk-PUCUVI7K.mjs} +11 -7
  38. package/dist/{chunk-RFYO7QUD.cjs → chunk-Q2TUENW2.cjs} +1 -1
  39. package/dist/{chunk-GDSHDTJ4.cjs → chunk-Q5B3KJBP.cjs} +2 -2
  40. package/dist/{chunk-TSWW5BVH.mjs → chunk-QMV4QELL.mjs} +1 -1
  41. package/dist/{chunk-V4AICMQA.mjs → chunk-RMIJFZU3.mjs} +26 -2
  42. package/dist/{chunk-NSFC3LHB.cjs → chunk-RWXZKZXB.cjs} +255 -173
  43. package/dist/{chunk-MKB2EGIR.cjs → chunk-SOR334EB.cjs} +3 -2
  44. package/dist/{chunk-57J3Y7Y3.mjs → chunk-TIKNUAU7.mjs} +3 -2
  45. package/dist/chunk-VVBO3QH7.mjs +46 -0
  46. package/dist/{chunk-QBPKKQTD.mjs → chunk-W7MZXRXM.mjs} +19 -4
  47. package/dist/{chunk-Y53ZSFN6.cjs → chunk-WM6HL7E7.cjs} +4 -3
  48. package/dist/{chunk-GPVTX3HT.cjs → chunk-XFFQSD2F.cjs} +2 -2
  49. package/dist/{chunk-62YJ2IEB.cjs → chunk-XI3GWPUS.cjs} +23 -20
  50. package/dist/{chunk-KVFPGF2M.cjs → chunk-YJJLXIIS.cjs} +7 -7
  51. package/dist/{chunk-U5BMPGS3.cjs → chunk-YP5JZ4LF.cjs} +32 -8
  52. package/dist/{chunk-S27FMYAM.cjs → chunk-ZE6ONQ5R.cjs} +28 -13
  53. package/dist/{client-plugins-JXXmZliS.d.mts → client-plugins-CWrhb1ir.d.mts} +26 -3
  54. package/dist/{client-plugins-C089bQhN.d.ts → client-plugins-DPf0qZey.d.ts} +26 -3
  55. package/dist/client-plugins.d.mts +2 -3
  56. package/dist/client-plugins.d.ts +2 -3
  57. package/dist/client.cjs +4 -4
  58. package/dist/client.d.mts +9 -38
  59. package/dist/client.d.ts +9 -38
  60. package/dist/client.mjs +3 -3
  61. package/dist/config.d.mts +2 -3
  62. package/dist/config.d.ts +2 -3
  63. package/dist/{devtools-FY5R7TQ4.mjs → devtools-MTB5SA2B.mjs} +3 -3
  64. package/dist/{devtools-5KGPDVKL.cjs → devtools-R6MDDAZK.cjs} +7 -7
  65. package/dist/docs.cjs +6 -5
  66. package/dist/docs.d.mts +2 -2
  67. package/dist/docs.d.ts +2 -2
  68. package/dist/docs.mjs +5 -4
  69. package/dist/index.cjs +21 -20
  70. package/dist/index.d.mts +14 -14
  71. package/dist/index.d.ts +14 -14
  72. package/dist/index.mjs +20 -19
  73. package/dist/integrations.d.mts +2 -3
  74. package/dist/integrations.d.ts +2 -3
  75. package/dist/internal/app-markdown-runtime.d.mts +2 -3
  76. package/dist/internal/app-markdown-runtime.d.ts +2 -3
  77. package/dist/internal/build-runtime.cjs +15 -14
  78. package/dist/internal/build-runtime.d.mts +4 -5
  79. package/dist/internal/build-runtime.d.ts +4 -5
  80. package/dist/internal/build-runtime.mjs +14 -13
  81. package/dist/internal/cli-runtime.cjs +7 -7
  82. package/dist/internal/cli-runtime.mjs +6 -6
  83. package/dist/internal/client-error-overlay.cjs +4 -4
  84. package/dist/internal/client-error-overlay.mjs +1 -1
  85. package/dist/internal/compression-runtime.d.mts +2 -3
  86. package/dist/internal/compression-runtime.d.ts +2 -3
  87. package/dist/internal/config-runtime.cjs +4 -4
  88. package/dist/internal/config-runtime.d.mts +3 -4
  89. package/dist/internal/config-runtime.d.ts +3 -4
  90. package/dist/internal/config-runtime.mjs +3 -3
  91. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  92. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  93. package/dist/internal/production-runtime.cjs +2 -2
  94. package/dist/internal/production-runtime.d.mts +8 -9
  95. package/dist/internal/production-runtime.d.ts +8 -9
  96. package/dist/internal/production-runtime.mjs +1 -1
  97. package/dist/{metadata-C1Z9vLbb.d.mts → metadata-CO9fRyyJ.d.mts} +1 -1
  98. package/dist/{metadata-BcNJP4fq.d.ts → metadata-zY9wltwH.d.ts} +1 -1
  99. package/dist/middleware.cjs +4 -4
  100. package/dist/middleware.d.mts +4 -11
  101. package/dist/middleware.d.ts +4 -11
  102. package/dist/middleware.mjs +3 -3
  103. package/dist/navigation.cjs +5 -5
  104. package/dist/navigation.d.mts +42 -3
  105. package/dist/navigation.d.ts +42 -3
  106. package/dist/navigation.mjs +4 -4
  107. package/dist/{nitro-CVZ36JM5.mjs → nitro-4LFVTT24.mjs} +2 -2
  108. package/dist/{nitro-4I2MYLY2.cjs → nitro-TSGDUJMN.cjs} +3 -3
  109. package/dist/plugin.cjs +17 -11
  110. package/dist/plugin.d.mts +3 -4
  111. package/dist/plugin.d.ts +3 -4
  112. package/dist/plugin.mjs +17 -11
  113. package/dist/{production-runtime-jcrTlRTb.d.mts → production-runtime-CywsHwnG.d.mts} +1 -1
  114. package/dist/{production-runtime-oKmC0WU-.d.ts → production-runtime-lkfwujwK.d.ts} +1 -1
  115. package/dist/query/client.cjs +6 -6
  116. package/dist/query/client.mjs +2 -2
  117. package/dist/{render-plan-DOB9cV-h.d.ts → render-plan-DHF0GeWo.d.ts} +1 -1
  118. package/dist/{render-plan-BLIfc4jt.d.mts → render-plan-LVy6sGQe.d.mts} +1 -1
  119. package/dist/renderer-client.cjs +5 -5
  120. package/dist/renderer-client.d.mts +4 -5
  121. package/dist/renderer-client.d.ts +4 -5
  122. package/dist/renderer-client.mjs +2 -2
  123. package/dist/renderer.d.mts +3 -0
  124. package/dist/renderer.d.ts +3 -0
  125. package/dist/{request-Cr53NRHr.d.mts → request-6AkmhEYE.d.mts} +1 -1
  126. package/dist/{request-Dt2gNuQD.d.ts → request-BYxlRqA9.d.ts} +1 -1
  127. package/dist/request.d.mts +3 -4
  128. package/dist/request.d.ts +3 -4
  129. package/dist/{route-rendering-CWYd8Mv1.d.ts → route-rendering-CWaKiUbS.d.ts} +1 -1
  130. package/dist/{route-rendering-CeFBEAoZ.d.mts → route-rendering-Dd8Jmml7.d.mts} +1 -1
  131. package/dist/router-B2m4fvve.d.ts +50 -0
  132. package/dist/router-xwEE112q.d.mts +50 -0
  133. package/dist/routes.cjs +3 -3
  134. package/dist/routes.d.mts +2 -3
  135. package/dist/routes.d.ts +2 -3
  136. package/dist/routes.mjs +2 -2
  137. package/dist/server-plugins.d.mts +3 -4
  138. package/dist/server-plugins.d.ts +3 -4
  139. package/dist/server.cjs +25 -24
  140. package/dist/server.d.mts +8 -9
  141. package/dist/server.d.ts +8 -9
  142. package/dist/server.mjs +12 -11
  143. package/dist/{spa-router-CQWiYGxS.d.mts → spa-router-DVEHQnWo.d.mts} +3 -3
  144. package/dist/{spa-router-Wjiw-8hB.d.ts → spa-router-Y8rrXTVK.d.ts} +3 -3
  145. package/dist/testing.cjs +6 -6
  146. package/dist/testing.d.mts +2 -3
  147. package/dist/testing.d.ts +2 -3
  148. package/dist/testing.mjs +5 -5
  149. package/dist/{types-D-1WTE72.d.mts → types-DFbjpjXX.d.mts} +8 -0
  150. package/dist/{types-D-1WTE72.d.ts → types-DFbjpjXX.d.ts} +8 -0
  151. package/dist/{utils-uUxF0K0P.d.mts → utils-DSPx34-A.d.mts} +1 -1
  152. package/dist/{utils-B0XJmG_b.d.ts → utils-Dvuny_08.d.ts} +1 -1
  153. package/dist/version.cjs +2 -2
  154. package/dist/version.mjs +1 -1
  155. package/dist/vite.cjs +12 -11
  156. package/dist/vite.d.mts +2 -3
  157. package/dist/vite.d.ts +2 -3
  158. package/dist/vite.mjs +11 -10
  159. package/package.json +3 -3
  160. package/dist/chunk-7GNWGLWB.mjs +0 -14
  161. package/dist/chunk-VQDBNVOO.cjs +0 -14
  162. package/dist/navigation-errors-Dvwpzaer.d.mts +0 -13
  163. package/dist/navigation-errors-Dvwpzaer.d.ts +0 -13
  164. /package/dist/{chunk-IAMRBF3Z.cjs → chunk-N4RLRSWW.cjs} +0 -0
  165. /package/dist/{chunk-BNGS6KJ6.mjs → chunk-YOYF2E4U.mjs} +0 -0
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  compileFarmDocsAdapterEdgeManifest,
9
9
  createFarmDocsAPIHandler
10
- } from "./chunk-QBPKKQTD.mjs";
10
+ } from "./chunk-W7MZXRXM.mjs";
11
11
  import {
12
12
  FARM_DOCS_LAST_MODIFIED_MANIFEST,
13
13
  createFarmDocsHandler,
@@ -31,7 +31,7 @@ import {
31
31
  getDeployTargetForPreset,
32
32
  hasCustomFarmRouteContext,
33
33
  resolveDeployOutputPath
34
- } from "./chunk-V4AICMQA.mjs";
34
+ } from "./chunk-RMIJFZU3.mjs";
35
35
  import {
36
36
  resolveFarmInstrumentationFile
37
37
  } from "./chunk-F5D4XEAS.mjs";
@@ -52,7 +52,6 @@ import {
52
52
  farmPluginMayAffectRuntimePath,
53
53
  generateClientCachePersistenceCode,
54
54
  generateFarmClientPluginEntryCode,
55
- generateFarmDocsAdapterClientRuntime,
56
55
  generateFarmIntegrationProviderClientCode,
57
56
  generateFarmIntegrationProviderServerModules,
58
57
  getClientModuleHydrationPlan,
@@ -64,26 +63,30 @@ import {
64
63
  resolveFarmClientCacheAdapterEntry,
65
64
  resolveFarmIsolatedClientHydrationMode,
66
65
  resolveFarmNotFoundComponentPath
67
- } from "./chunk-WZXN4R5Y.mjs";
66
+ } from "./chunk-53G3OLTA.mjs";
68
67
  import {
69
68
  findRequestBoundSourceBlockers,
70
69
  generateFarmTypeArtifacts,
71
70
  parseRouteRenderingDirective,
72
71
  resolveRouteRenderingConfigFromFile
73
- } from "./chunk-2ANEVVF7.mjs";
72
+ } from "./chunk-NRS46D4L.mjs";
74
73
  import {
75
74
  isFarmPreviewDeploymentEnvironment
76
75
  } from "./chunk-BOYNDCZL.mjs";
77
76
  import {
78
77
  farmEnvironmentFunctionsPlugin
79
78
  } from "./chunk-ZSH2Y4LN.mjs";
79
+ import {
80
+ generateFarmDocsAdapterClientRuntime,
81
+ getFarmDocsAdapterConfigModule
82
+ } from "./chunk-VVBO3QH7.mjs";
80
83
  import {
81
84
  resolveFarmDocsFontAssets,
82
85
  toFarmDocsPublicFontAssets
83
86
  } from "./chunk-TVGP4BBZ.mjs";
84
87
  import {
85
88
  routeRulesToNitroRouteRules
86
- } from "./chunk-7WPA7GBZ.mjs";
89
+ } from "./chunk-GHFS7RUB.mjs";
87
90
  import {
88
91
  getFarmAppDirectories
89
92
  } from "./chunk-IILNZK5G.mjs";
@@ -124,10 +127,10 @@ import {
124
127
  } from "./chunk-JLCQGPXE.mjs";
125
128
  import {
126
129
  appendMiddlewareRoutePath
127
- } from "./chunk-57J3Y7Y3.mjs";
130
+ } from "./chunk-TIKNUAU7.mjs";
128
131
  import {
129
132
  APIRouteManager
130
- } from "./chunk-ATERBVHQ.mjs";
133
+ } from "./chunk-CQHFU55R.mjs";
131
134
  import {
132
135
  readFarmI18nCatalogs
133
136
  } from "./chunk-FV45CKBC.mjs";
@@ -143,7 +146,7 @@ import {
143
146
  normalizeFarmRouteRuntimeConfig,
144
147
  resolveFarmRouteRuleRuntimeConfig,
145
148
  resolveFarmRouteRuntimeConfig
146
- } from "./chunk-FS7FLPOG.mjs";
149
+ } from "./chunk-2J7W2WND.mjs";
147
150
  import {
148
151
  logger,
149
152
  toPosixPath,
@@ -1576,6 +1579,8 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
1576
1579
  ]);
1577
1580
  const nitroBuilderResultPromise = preloadFarmNitroBuilder();
1578
1581
  logger.info(`\u{1F69C} Building Farm.js application (universal) with preset: ${preset}...`);
1582
+ const rendererBuild = options.rendererBuildLifetime ? void 0 : new AbortController();
1583
+ const rendererBuildLifetime = options.rendererBuildLifetime ?? rendererBuild.signal;
1579
1584
  try {
1580
1585
  const routeRuntimeManifestPromise = options.routeRuntimeManifest ? Promise.resolve(options.routeRuntimeManifest) : createFarmRouteRuntimeManifest({
1581
1586
  config,
@@ -1658,7 +1663,8 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
1658
1663
  layoutRoutes,
1659
1664
  routeSlots,
1660
1665
  isolatedClientBoundaryModules,
1661
- hydrationPlanCache
1666
+ hydrationPlanCache,
1667
+ rendererBuildLifetime
1662
1668
  ), "buildClientBundle");
1663
1669
  const buildSSRBundle = /* @__PURE__ */ __name(() => buildSSRInMemory(
1664
1670
  productionVite,
@@ -1672,7 +1678,8 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
1672
1678
  layoutRoutes,
1673
1679
  routeSlots,
1674
1680
  isolatedClientBoundaryModules,
1675
- hydrationPlanCache
1681
+ hydrationPlanCache,
1682
+ rendererBuildLifetime
1676
1683
  ), "buildSSRBundle");
1677
1684
  let clientBuildResult;
1678
1685
  let ssrBuildResult;
@@ -1708,7 +1715,8 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
1708
1715
  layoutRoutes,
1709
1716
  routeSlots,
1710
1717
  isolatedClientBoundaryModules,
1711
- hydrationPlanCache
1718
+ hydrationPlanCache,
1719
+ rendererBuildLifetime
1712
1720
  );
1713
1721
  } catch (retryError) {
1714
1722
  if (!(retryError instanceof IncompleteClientBuildOutputError)) throw retryError;
@@ -1763,6 +1771,8 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
1763
1771
  }
1764
1772
  logger.error(`\u274C Build failed: ${error}`);
1765
1773
  throw error;
1774
+ } finally {
1775
+ rendererBuild?.abort();
1766
1776
  }
1767
1777
  }
1768
1778
  __name(buildUniversal, "buildUniversal");
@@ -1866,7 +1876,7 @@ function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, optio
1866
1876
  return { ...plan, isolatedBoundaries: [...plan.isolatedBoundaries] };
1867
1877
  }
1868
1878
  __name(getCachedClientModuleHydrationPlan, "getCachedClientModuleHydrationPlan");
1869
- async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map()) {
1879
+ async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map(), rendererBuildLifetime) {
1870
1880
  const viteBuild = productionVite.build;
1871
1881
  const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
1872
1882
  const { PluginManager: PluginManager2 } = await import("./plugin.mjs");
@@ -2114,14 +2124,16 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2114
2124
  config.trailingSlash,
2115
2125
  getIntegrationProviders(config.integrations),
2116
2126
  config.basePath,
2117
- generateClientCachePersistenceCode(resolveFarmClientCacheAdapterEntry(root, config.cache))
2127
+ generateClientCachePersistenceCode(resolveFarmClientCacheAdapterEntry(root, config.cache)),
2128
+ adapterOwnsDocsRuntime ? getFarmDocsAdapterConfigModule(config.docs) : void 0
2118
2129
  );
2119
2130
  await fs.writeFile(clientEntryPath, clientHydrationCode);
2120
2131
  const hasScopedPostcssConfig = hasProjectPostcssConfig(root);
2121
2132
  let postcssSearchPath;
2122
2133
  let tailwindVitePlugin = void 0;
2123
2134
  const rendererVitePlugins = await loadFarmRendererVitePlugins(config.renderer, root, {
2124
- ssr: false
2135
+ ssr: false,
2136
+ buildLifetime: rendererBuildLifetime
2125
2137
  });
2126
2138
  if (hasScopedPostcssConfig) {
2127
2139
  logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
@@ -3034,7 +3046,7 @@ function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlot
3034
3046
  secure: false
3035
3047
  },
3036
3048
  direction: {}
3037
- }, plugins = [], renderer = REACT_RENDERER, publicRuntimeConfig = void 0, trailingSlash = false, integrationProviders = [], basePath = "/", clientCachePersistence = { imports: "", init: "" }) {
3049
+ }, plugins = [], renderer = REACT_RENDERER, publicRuntimeConfig = void 0, trailingSlash = false, integrationProviders = [], basePath = "/", clientCachePersistence = { imports: "", init: "" }, docsConfigModule) {
3038
3050
  const toImportPath = /* @__PURE__ */ __name((targetPath) => targetPath.replace(/\\/g, "/"), "toImportPath");
3039
3051
  const clientPluginEntry = generateFarmClientPluginEntryCode(
3040
3052
  plugins,
@@ -3107,7 +3119,10 @@ function isFarmDocsPath() {
3107
3119
  return false;
3108
3120
  }
3109
3121
  `;
3110
- const docsAdapterRuntime = generateFarmDocsAdapterClientRuntime(docsAdapterReact);
3122
+ const docsAdapterRuntime = generateFarmDocsAdapterClientRuntime(
3123
+ docsAdapterReact,
3124
+ docsConfigModule
3125
+ );
3111
3126
  if (clientPages.length === 0 && clientRouteSlots.length === 0 && !providerClientCode.hasProviders) {
3112
3127
  return `
3113
3128
  // Farm.js Client Runtime (no client components)
@@ -4417,7 +4432,7 @@ void hydrate();
4417
4432
  `.trim();
4418
4433
  }
4419
4434
  __name(generateClientHydrationEntry, "generateClientHydrationEntry");
4420
- async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache) {
4435
+ async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime) {
4421
4436
  const viteBuild = productionVite.build;
4422
4437
  const { farmPlugin } = await import("./vite.mjs");
4423
4438
  const { PluginManager: PluginManager2 } = await import("./plugin.mjs");
@@ -4432,7 +4447,8 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
4432
4447
  let postcssConfigDir;
4433
4448
  let tailwindVitePlugin = void 0;
4434
4449
  const rendererVitePlugins = await loadFarmRendererVitePlugins(config.renderer, root, {
4435
- ssr: true
4450
+ ssr: true,
4451
+ buildLifetime: rendererBuildLifetime
4436
4452
  });
4437
4453
  if (!hasScopedPostcssConfig) {
4438
4454
  postcssConfigDir = await fs.mkdtemp(path5.join(os.tmpdir(), "farm-postcss-"));
@@ -4820,7 +4836,10 @@ function generateFarmDocsRuntimeConfigExpression(docs, precompiled = false) {
4820
4836
  ...docs,
4821
4837
  contentDir: void 0,
4822
4838
  ...precompiled ? { configPath: void 0 } : {},
4823
- config: void 0
4839
+ config: void 0,
4840
+ // React elements and functions do not survive JSON. The server bundle imports the
4841
+ // config module for those instead (see farmDocsConfigModule).
4842
+ runtimeConfig: void 0
4824
4843
  };
4825
4844
  const nestedConfig = {
4826
4845
  ...docs.config,
@@ -4841,7 +4860,7 @@ function generateFarmDocsRuntimeConfigExpression(docs, precompiled = false) {
4841
4860
  contentDir: farmDocsBundledContentDir,
4842
4861
  },
4843
4862
  }
4844
- : ${JSON.stringify(docs)}`;
4863
+ : ${JSON.stringify({ ...docs, runtimeConfig: void 0 })}`;
4845
4864
  }
4846
4865
  __name(generateFarmDocsRuntimeConfigExpression, "generateFarmDocsRuntimeConfigExpression");
4847
4866
  function toVirtualEntryImportSpecifier(modulePath) {
@@ -5115,6 +5134,7 @@ function generateVirtualEntryCode(apiRoutes, pageRoutes, layoutRoutes, routeSlot
5115
5134
  const adapterOwnsDocsRuntime = Boolean(
5116
5135
  isReactRenderer(config.renderer) && config.docs?.enabled && config.docs.adapter?.server && config.docs.adapter.react
5117
5136
  );
5137
+ const docsConfigModulePath = adapterOwnsDocsRuntime && !hasPrecompiledDocs && config.docs.configPath && !config.docs.configPath.endsWith(".json") ? config.docs.configPath : void 0;
5118
5138
  const hasIsolatedClientGraphRuntime = isReactRenderer(config.renderer) && isolatedClientBoundaryModules.size > 0;
5119
5139
  const rendererStreamingCapabilities = getFarmRendererStreamingCapabilitiesForRuntime(
5120
5140
  config.renderer,
@@ -5475,7 +5495,8 @@ const isFarmDocsAPIRequest = (requestOrPathname) => {
5475
5495
  return pathname === apiPath || pathname.startsWith(apiPath + "/");
5476
5496
  };` : adapterOwnsDocsRuntime ? `import { isFarmDocsAPIRequest } from "@farm.js/core/docs";
5477
5497
  import { createFarmDocsRuntimeHandler as createFarmDocsAdapterRuntimeHandler } from ${JSON.stringify(config.docs.adapter.server)};
5478
- import * as FarmDocsAdapterReact from ${JSON.stringify(config.docs.adapter.react)};` : `import { createFarmDocsAPIHandler, createFarmDocsHandler, isFarmDocsAPIRequest } from "@farm.js/core/docs";` : "";
5498
+ import * as FarmDocsAdapterReact from ${JSON.stringify(config.docs.adapter.react)};${docsConfigModulePath ? `
5499
+ import * as farmDocsConfigModule from ${toVirtualEntryImportSpecifier(docsConfigModulePath)};` : ""}` : `import { createFarmDocsAPIHandler, createFarmDocsHandler, isFarmDocsAPIRequest } from "@farm.js/core/docs";` : "";
5479
5500
  const docsFontImport = config.docs?.enabled && !hasPrecompiledDocs ? `import { resolveFarmLayoutFonts } from "@farm.js/core/font";` : "";
5480
5501
  const docsRuntimeImport = config.docs?.enabled && !hasPrecompiledDocs ? `import { existsSync as farmDocsExistsSync } from "node:fs";
5481
5502
  import { dirname as farmDocsDirname, join as farmDocsJoin } from "node:path";
@@ -5892,7 +5913,7 @@ globalThis.__FARM_DOCS_RUNTIME_CONFIG__ = {
5892
5913
  };
5893
5914
  const farmDocsPrecompiledRuntime = ${hasPrecompiledDocs ? `createFarmDocsPrecompiledRuntime(${JSON.stringify(farmDocsPrecompiledManifest)})` : "null"};
5894
5915
  const farmDocsHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleDocsRequest" : adapterOwnsDocsRuntime ? `createFarmDocsAdapterRuntimeHandler({
5895
- ...farmDocsResolvedConfig.config,
5916
+ ${docsConfigModulePath ? "...(farmDocsConfigModule.default || farmDocsConfigModule),\n ...farmDocsResolvedConfig.configOverrides," : "...farmDocsResolvedConfig.config,"}
5896
5917
  entry: farmDocsResolvedConfig.config?.entry || String(farmDocsResolvedConfig.entry || "/docs").replace(/^\\/+|\\/+$/g, "") || "docs",
5897
5918
  docsPath: farmDocsResolvedConfig.entry,
5898
5919
  contentDir: farmDocsResolvedConfig.contentDir || farmDocsResolvedConfig.config?.contentDir,
@@ -6312,13 +6333,32 @@ function createFarmDocumentStream(contentStream, prefix, suffix, onComplete) {
6312
6333
  }
6313
6334
 
6314
6335
  function stripFarmDocumentWrappers(markup) {
6315
- let output = markup.replace(/^\\s+/, "");
6336
+ return peelFarmDocumentPrefix(markup).inner;
6337
+ }
6338
+
6339
+ // Farm's display:contents wrappers, and the head elements React 19 hoists in front of them
6340
+ // (charset, viewport, preloads, titles) when the layout's <html> is not the render root.
6341
+ function peelFarmDocumentPrefix(markup) {
6342
+ let inner = markup.replace(/^\\s+/, "");
6343
+ let hoisted = "";
6316
6344
  const wrapper = /^<div\\b[^>]*style=["']display\\s*:\\s*contents["'][^>]*>/i;
6345
+ const hoistable = /^(?:<(?:meta|link|base)\\b[^>]*>|<title\\b[^>]*>[\\s\\S]*?<\\/title>)/i;
6317
6346
  let match;
6318
- while ((match = wrapper.exec(output))) {
6319
- output = output.slice(match[0].length).replace(/^\\s+/, "");
6347
+ while ((match = wrapper.exec(inner) || hoistable.exec(inner))) {
6348
+ if (!/^<div/i.test(match[0])) hoisted += match[0];
6349
+ inner = inner.slice(match[0].length).replace(/^\\s+/, "");
6320
6350
  }
6321
- return output;
6351
+ return { inner: inner, hoisted: hoisted };
6352
+ }
6353
+
6354
+ function restoreFarmHoistedHead(document, hoisted) {
6355
+ if (!hoisted) return document;
6356
+ if (/<head[\\s>]/i.test(document)) {
6357
+ return document.replace(/<head\\b[^>]*>/i, function(open) { return open + hoisted; });
6358
+ }
6359
+ return document.replace(/<html\\b[^>]*>/i, function(open) {
6360
+ return open + "<head>" + hoisted + "</head>";
6361
+ });
6322
6362
  }
6323
6363
 
6324
6364
  function opensFarmFullDocument(markup) {
@@ -6328,6 +6368,7 @@ function opensFarmFullDocument(markup) {
6328
6368
 
6329
6369
  function extractFarmFullDocument(markup) {
6330
6370
  if (!opensFarmFullDocument(markup)) return null;
6371
+ const hoisted = peelFarmDocumentPrefix(markup).hoisted;
6331
6372
  const start = markup.search(/<!doctype|<html[\\s>]/i);
6332
6373
  const lower = markup.toLowerCase();
6333
6374
  let closeIndex = lower.lastIndexOf("</html>");
@@ -6355,7 +6396,7 @@ function extractFarmFullDocument(markup) {
6355
6396
  return streamedTail + "</body>";
6356
6397
  });
6357
6398
  }
6358
- return document;
6399
+ return restoreFarmHoistedHead(document, hoisted);
6359
6400
  }
6360
6401
 
6361
6402
  function ensureFarmDocumentHead(markup) {
@@ -9380,7 +9421,7 @@ export default async function farmNitroEventHandler(event) {
9380
9421
  else process.env[FARM_PRERENDER_ENV] = previousPrerender;
9381
9422
  }
9382
9423
  }
9383
- const sharpRuntimeStagePromise = imageRuntime === "node" ? stageSharpRuntime(config, root, distDir, fs) : Promise.resolve(null);
9424
+ const sharpRuntimeStagePromise = imageRuntime === "node" ? stageSharpRuntime(config, root, distDir, fs, preset) : Promise.resolve(null);
9384
9425
  const [nitroBuildResult, sharpRuntimeStageResult] = await Promise.allSettled([
9385
9426
  nitroBuilder.build(nitroInstance),
9386
9427
  sharpRuntimeStagePromise
@@ -9398,7 +9439,7 @@ export default async function farmNitroEventHandler(event) {
9398
9439
  if (sharpRuntimeStageResult.status === "rejected") {
9399
9440
  throw sharpRuntimeStageResult.reason;
9400
9441
  }
9401
- const stagedSharpRuntime = sharpRuntimeStageResult.value ?? (imageRuntime === "node" ? await stageSharpRuntime(config, root, distDir, fs) : null);
9442
+ const stagedSharpRuntime = sharpRuntimeStageResult.value ?? (imageRuntime === "node" ? await stageSharpRuntime(config, root, distDir, fs, preset) : null);
9402
9443
  const runtimeCopyPromise = (async () => {
9403
9444
  if (stagedSharpRuntime) {
9404
9445
  await installStagedSharpRuntime(stagedSharpRuntime, runtimeServerOutputDir, fs);
@@ -9594,7 +9635,24 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs) {
9594
9635
  logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path5.relative(root, docsContentDir)}`);
9595
9636
  }
9596
9637
  __name(copyFarmDocsContentForVercel, "copyFarmDocsContentForVercel");
9597
- async function stageSharpRuntime(config, root, distDir, fs) {
9638
+ function resolveServerFunctionPlatform(preset) {
9639
+ return preset === "vercel" || preset === "netlify" ? { os: "linux", cpu: "x64", libc: "glibc" } : null;
9640
+ }
9641
+ __name(resolveServerFunctionPlatform, "resolveServerFunctionPlatform");
9642
+ function packageSupportsPlatform(packageJson, platform) {
9643
+ return platformFieldAllows(packageJson.os, platform.os) && platformFieldAllows(packageJson.cpu, platform.cpu) && platformFieldAllows(packageJson.libc, platform.libc);
9644
+ }
9645
+ __name(packageSupportsPlatform, "packageSupportsPlatform");
9646
+ function platformFieldAllows(field, value) {
9647
+ if (!Array.isArray(field)) return true;
9648
+ const entries = field.filter((entry) => typeof entry === "string");
9649
+ if (entries.includes(`!${value}`)) return false;
9650
+ const allowed = entries.filter((entry) => !entry.startsWith("!"));
9651
+ return allowed.length === 0 || allowed.includes(value);
9652
+ }
9653
+ __name(platformFieldAllows, "platformFieldAllows");
9654
+ async function stageSharpRuntime(config, root, distDir, fs, preset) {
9655
+ const functionPlatform = resolveServerFunctionPlatform(preset);
9598
9656
  const projectRequire = createRequire(path5.join(root, "package.json"));
9599
9657
  let sharpRequire = projectRequire;
9600
9658
  if (!resolvePackageJson(projectRequire, "sharp")) {
@@ -9621,6 +9679,7 @@ async function stageSharpRuntime(config, root, distDir, fs) {
9621
9679
  const packageJsonPath = resolvePackageJson(parentRequire, packageName);
9622
9680
  if (!packageJsonPath) return;
9623
9681
  const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
9682
+ if (functionPlatform && !packageSupportsPlatform(packageJson, functionPlatform)) return;
9624
9683
  const packageDir = path5.dirname(packageJsonPath);
9625
9684
  const targetDir = path5.join(targetNodeModules, ...packageName.split("/"));
9626
9685
  copiedPackages.set(packageName, String(packageJson.version || "*"));
@@ -9630,7 +9689,7 @@ async function stageSharpRuntime(config, root, distDir, fs) {
9630
9689
  ...packageJson.dependencies,
9631
9690
  ...packageJson.optionalDependencies
9632
9691
  };
9633
- await Promise.all([
9692
+ await settleAllOrThrow([
9634
9693
  fs.cp(packageDir, targetDir, {
9635
9694
  recursive: true,
9636
9695
  force: true,
@@ -9681,10 +9740,18 @@ async function installStagedSharpRuntime(staged, nitroFuncDir, fs) {
9681
9740
  );
9682
9741
  }
9683
9742
  __name(installStagedSharpRuntime, "installStagedSharpRuntime");
9743
+ async function settleAllOrThrow(operations) {
9744
+ const results = await Promise.allSettled(operations);
9745
+ const failure = results.find(
9746
+ (result) => result.status === "rejected"
9747
+ );
9748
+ if (failure) throw failure.reason;
9749
+ }
9750
+ __name(settleAllOrThrow, "settleAllOrThrow");
9684
9751
  async function mergeStagedDirectory(sourceDir, targetDir, fs) {
9685
9752
  await fs.mkdir(targetDir, { recursive: true });
9686
9753
  const entries = await fs.readdir(sourceDir, { withFileTypes: true });
9687
- await Promise.all(
9754
+ await settleAllOrThrow(
9688
9755
  entries.map(async (entry) => {
9689
9756
  const sourcePath = path5.join(sourceDir, entry.name);
9690
9757
  const targetPath = path5.join(targetDir, entry.name);
@@ -9765,14 +9832,17 @@ async function writeNitroOutputPackage(outputDir, packageJson, fs) {
9765
9832
  }
9766
9833
  __name(writeNitroOutputPackage, "writeNitroOutputPackage");
9767
9834
  function resolvePackageJson(parentRequire, packageName) {
9835
+ let metadataModule;
9768
9836
  for (const request of [`${packageName}/package.json`, `${packageName}/package`]) {
9769
9837
  try {
9770
- return parentRequire.resolve(request);
9838
+ const resolved = parentRequire.resolve(request);
9839
+ if (resolved.endsWith(".json")) return resolved;
9840
+ metadataModule ?? (metadataModule = resolved);
9771
9841
  } catch {
9772
9842
  }
9773
9843
  }
9774
9844
  try {
9775
- let directory = path5.dirname(parentRequire.resolve(packageName));
9845
+ let directory = path5.dirname(metadataModule ?? parentRequire.resolve(packageName));
9776
9846
  while (directory !== path5.dirname(directory)) {
9777
9847
  const candidate = path5.join(directory, "package.json");
9778
9848
  if (existsSync(candidate)) {
@@ -9879,6 +9949,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
9879
9949
  });
9880
9950
  pluginManager.addPlugins(config.plugins || []);
9881
9951
  let projectModuleServer;
9952
+ const rendererBuild = new AbortController();
9882
9953
  try {
9883
9954
  await pluginManager.runHookParallel("init");
9884
9955
  config = await pluginManager.runHookSerial("config", config);
@@ -9914,7 +9985,12 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
9914
9985
  if (productionViteResult?.status === "rejected") throw productionViteResult.reason;
9915
9986
  const productionVite = productionViteResult?.value;
9916
9987
  const createViteServer = productionVite ? productionVite.createServer : (await import("vite")).createServer;
9917
- projectModuleServer = await createProjectModuleServer(createViteServer, config, root);
9988
+ projectModuleServer = await createProjectModuleServer(
9989
+ createViteServer,
9990
+ config,
9991
+ root,
9992
+ rendererBuild.signal
9993
+ );
9918
9994
  const farmApp = createFarmApp(config, projectModuleServer);
9919
9995
  await farmApp.initialize();
9920
9996
  const routeManager = farmApp.getRouteManager();
@@ -9956,7 +10032,8 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
9956
10032
  preset,
9957
10033
  root,
9958
10034
  pluginManager,
9959
- productionVite
10035
+ productionVite,
10036
+ rendererBuildLifetime: rendererBuild.signal
9960
10037
  });
9961
10038
  } else {
9962
10039
  const { build: legacyViteBuild } = await import("vite");
@@ -10008,13 +10085,18 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
10008
10085
  logger.error(`\u274C Build failed: ${error}`);
10009
10086
  throw error;
10010
10087
  } finally {
10011
- await projectModuleServer?.close();
10088
+ try {
10089
+ await projectModuleServer?.close();
10090
+ } finally {
10091
+ rendererBuild.abort();
10092
+ }
10012
10093
  }
10013
10094
  }
10014
10095
  __name(buildWithProductionNodeEnv, "buildWithProductionNodeEnv");
10015
- async function createProjectModuleServer(createViteServer, config, root) {
10096
+ async function createProjectModuleServer(createViteServer, config, root, buildLifetime) {
10016
10097
  const rendererVitePlugins = await loadFarmRendererVitePlugins(config.renderer, root, {
10017
- ssr: true
10098
+ ssr: true,
10099
+ buildLifetime
10018
10100
  });
10019
10101
  const viteConfig = mergeFarmViteConfig(
10020
10102
  {
@@ -10148,7 +10230,7 @@ function resolveLegacyPageEntry(config, root, srcDir) {
10148
10230
  __name(resolveLegacyPageEntry, "resolveLegacyPageEntry");
10149
10231
  async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
10150
10232
  const [{ createNitroConfig }, { createNitro, build: nitroBuild }] = await Promise.all([
10151
- import("./nitro-CVZ36JM5.mjs"),
10233
+ import("./nitro-4LFVTT24.mjs"),
10152
10234
  import("nitro/builder")
10153
10235
  ]);
10154
10236
  let nitroConfig = await createNitroConfig(
@@ -7,7 +7,7 @@ import {
7
7
  notifyHistoryChange,
8
8
  readPageState,
9
9
  subscribeHistoryChange
10
- } from "./chunk-RKQVJN2O.mjs";
10
+ } from "./chunk-JIKGGIOL.mjs";
11
11
  import {
12
12
  getFarmI18nClientState
13
13
  } from "./chunk-TOVMYGYW.mjs";
@@ -49,12 +49,15 @@ function shouldBlockUnload(options) {
49
49
  }
50
50
  }
51
51
  __name(shouldBlockUnload, "shouldBlockUnload");
52
- function navigateViaRouter(href, basePath, replace) {
52
+ function navigateViaRouter(href, basePath, replace, options = {}) {
53
53
  if (typeof window === "undefined") return;
54
54
  const url = applyFarmBasePath(href, basePath);
55
55
  const spaRouter = getInstalledFarmSPARouter();
56
56
  if (spaRouter) {
57
- void spaRouter.navigate(url, { replace });
57
+ void spaRouter.navigate(url, {
58
+ replace,
59
+ ...options.scroll === void 0 ? {} : { scroll: options.scroll }
60
+ });
58
61
  return;
59
62
  }
60
63
  if (replace) {
@@ -85,11 +88,11 @@ function useRouter(options = {}) {
85
88
  const unsubscribe = subscribeHistoryChange(handlePopState);
86
89
  return unsubscribe;
87
90
  }, [basePath, routeMatcher]);
88
- const push = /* @__PURE__ */ __name((href) => {
89
- navigateViaRouter(href, basePath, false);
91
+ const push = /* @__PURE__ */ __name((href, navigateOptions) => {
92
+ navigateViaRouter(href, basePath, false, navigateOptions);
90
93
  }, "push");
91
- const replace = /* @__PURE__ */ __name((href) => {
92
- navigateViaRouter(href, basePath, true);
94
+ const replace = /* @__PURE__ */ __name((href, navigateOptions) => {
95
+ navigateViaRouter(href, basePath, true, navigateOptions);
93
96
  }, "replace");
94
97
  const pushState = /* @__PURE__ */ __name((pageState, href) => {
95
98
  if (typeof window === "undefined") return;
@@ -0,0 +1,46 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
4
+
5
+ // src/docs/adapter-client.ts
6
+ function getFarmDocsAdapterConfigModule(docs) {
7
+ if (!_optionalChain([docs, 'optionalAccess', _ => _.enabled]) || !_optionalChain([docs, 'access', _2 => _2.adapter, 'optionalAccess', _3 => _3.react]) || !docs.configPath) return void 0;
8
+ return docs.configPath.endsWith(".json") ? void 0 : docs.configPath.replace(/\\/g, "/");
9
+ }
10
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getFarmDocsAdapterConfigModule, "getFarmDocsAdapterConfigModule");
11
+ function generateFarmDocsAdapterClientRuntime(reactModule, configModule) {
12
+ if (!reactModule) {
13
+ return `
14
+ async function hydrateFarmDocsAdapterRuntime() {
15
+ return false;
16
+ }
17
+ `;
18
+ }
19
+ return `
20
+ async function hydrateFarmDocsAdapterRuntime() {
21
+ const runtime = window.__FARM_DOCS_ADAPTER__;
22
+ if (!runtime) return false;
23
+ const FarmDocsAdapterReact = await import(${JSON.stringify(reactModule)});
24
+ if (typeof FarmDocsAdapterReact.hydrateFarmDocs !== "function") {
25
+ throw new Error("The configured Farm docs adapter does not export hydrateFarmDocs().");
26
+ }
27
+ // The docs server flags pages whose config holds what its JSON copy cannot (icons,
28
+ // MDX components, callbacks); the adapter restores those from the module itself.
29
+ const configModule = runtime.configModule
30
+ ? ${configModule ? `await import(${JSON.stringify(configModule)})` : "undefined"}
31
+ : undefined;
32
+ FarmDocsAdapterReact.hydrateFarmDocs({
33
+ config: runtime.config || {},
34
+ data: runtime.data,
35
+ ...(configModule ? { configModule: configModule.default ?? configModule } : {}),
36
+ });
37
+ return true;
38
+ }
39
+ `;
40
+ }
41
+ _chunkS3JO3N4Hcjs.__name.call(void 0, generateFarmDocsAdapterClientRuntime, "generateFarmDocsAdapterClientRuntime");
42
+
43
+
44
+
45
+
46
+ exports.getFarmDocsAdapterConfigModule = getFarmDocsAdapterConfigModule; exports.generateFarmDocsAdapterClientRuntime = generateFarmDocsAdapterClientRuntime;
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkIAMRBF3Zcjs = require('./chunk-IAMRBF3Z.cjs');
3
+ var _chunkN4RLRSWWcjs = require('./chunk-N4RLRSWW.cjs');
4
4
 
5
5
 
6
6
  var _chunk2CQ74SP6cjs = require('./chunk-2CQ74SP6.cjs');
@@ -24,10 +24,11 @@ var _chunk6V4TDWECcjs = require('./chunk-6V4TDWEC.cjs');
24
24
 
25
25
 
26
26
 
27
- var _chunkMKB2EGIRcjs = require('./chunk-MKB2EGIR.cjs');
27
+ var _chunkSOR334EBcjs = require('./chunk-SOR334EB.cjs');
28
28
 
29
29
 
30
- var _chunkVQDBNVOOcjs = require('./chunk-VQDBNVOO.cjs');
30
+
31
+ var _chunkBMWDEBXOcjs = require('./chunk-BMWDEBXO.cjs');
31
32
 
32
33
 
33
34
  var _chunk5QIKR7RRcjs = require('./chunk-5QIKR7RR.cjs');
@@ -152,8 +153,8 @@ var _APIRouteManager = class _APIRouteManager {
152
153
  }
153
154
  }
154
155
  }
155
- const runtimeConfig = _chunkMKB2EGIRcjs.normalizeFarmRouteRuntimeConfig.call(void 0,
156
- _chunkMKB2EGIRcjs.getFarmRouteRuntimeConfig.call(void 0, routeModule),
156
+ const runtimeConfig = _chunkSOR334EBcjs.normalizeFarmRouteRuntimeConfig.call(void 0,
157
+ _chunkSOR334EBcjs.getFarmRouteRuntimeConfig.call(void 0, routeModule),
157
158
  `API route "${routePath}"`
158
159
  );
159
160
  this.registerRouteShape(routePath, filePath, appDir);
@@ -206,7 +207,7 @@ var _APIRouteManager = class _APIRouteManager {
206
207
  async loadProgrammaticApiRoutes(appDir) {
207
208
  const candidateRoots = [path.dirname(appDir), appDir];
208
209
  const routeFiles = Array.from(
209
- new Set(candidateRoots.flatMap((srcRoot) => _chunkIAMRBF3Zcjs.findProgrammaticRouteFilesInDir.call(void 0, srcRoot)))
210
+ new Set(candidateRoots.flatMap((srcRoot) => _chunkN4RLRSWWcjs.findProgrammaticRouteFilesInDir.call(void 0, srcRoot)))
210
211
  );
211
212
  if (routeFiles.length === 0) return;
212
213
  const { getProgrammaticRouteManifest } = await import("./routes.cjs");
@@ -251,11 +252,11 @@ var _APIRouteManager = class _APIRouteManager {
251
252
  }
252
253
  async loadModule(filePath) {
253
254
  if (this.viteServer) {
254
- return await this.viteServer.ssrLoadModule(filePath);
255
+ return await _chunkBMWDEBXOcjs.loadFarmDevModule.call(void 0, this.viteServer, filePath);
255
256
  }
256
257
  return await import(
257
258
  /* @vite-ignore */
258
- _chunkVQDBNVOOcjs.toFileModuleUrl.call(void 0, filePath)
259
+ _chunkBMWDEBXOcjs.toFileModuleUrl.call(void 0, filePath)
259
260
  );
260
261
  }
261
262
  addEndpoint(routePath, filePath, method, endpoint, appDir, runtimeConfig = {}) {
@@ -292,7 +293,7 @@ var _APIRouteManager = class _APIRouteManager {
292
293
  }
293
294
  addProgrammaticApiRoute(filePath, route, appDir) {
294
295
  const modulePath = _chunk6V4TDWECcjs.createProgrammaticRouteModuleId.call(void 0, filePath, "api", route.path);
295
- const runtimeConfig = _chunkMKB2EGIRcjs.normalizeFarmRouteRuntimeConfig.call(void 0, route, `API route "${route.path}"`);
296
+ const runtimeConfig = _chunkSOR334EBcjs.normalizeFarmRouteRuntimeConfig.call(void 0, route, `API route "${route.path}"`);
296
297
  for (const [method, endpoint] of Object.entries(route.methods)) {
297
298
  if (endpoint) {
298
299
  this.addEndpoint(route.path, modulePath, method, endpoint, appDir, runtimeConfig);