@farm.js/core 0.1.36 → 0.1.37

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 (234) hide show
  1. package/dist/{agent-mcp-BVExL8rZ.d.mts → agent-mcp-BC0bAGVF.d.mts} +1 -1
  2. package/dist/{agent-mcp-luzfXK-P.d.ts → agent-mcp-jyDHbQKe.d.ts} +1 -1
  3. package/dist/agent-runtime.cjs +3 -3
  4. package/dist/agent-runtime.d.mts +1 -1
  5. package/dist/agent-runtime.d.ts +1 -1
  6. package/dist/agent-runtime.mjs +2 -2
  7. package/dist/api/client.cjs +3 -3
  8. package/dist/api/client.mjs +2 -2
  9. package/dist/api/route-manager.cjs +6 -6
  10. package/dist/api/route-manager.d.mts +3 -3
  11. package/dist/api/route-manager.d.ts +3 -3
  12. package/dist/api/route-manager.mjs +5 -5
  13. package/dist/api/runtime.cjs +4 -4
  14. package/dist/api/runtime.d.mts +2 -2
  15. package/dist/api/runtime.d.ts +2 -2
  16. package/dist/api/runtime.mjs +3 -3
  17. package/dist/api.cjs +9 -8
  18. package/dist/api.d.mts +3 -3
  19. package/dist/api.d.ts +3 -3
  20. package/dist/api.mjs +8 -7
  21. package/dist/{app-Yfa2dsFy.d.ts → app-CKO3iN1c.d.ts} +3 -3
  22. package/dist/{app-BukwkFIu.d.mts → app-Cbkj9ufe.d.mts} +3 -3
  23. package/dist/app-markdown.cjs +5 -3
  24. package/dist/app-markdown.d.mts +3 -3
  25. package/dist/app-markdown.d.ts +3 -3
  26. package/dist/app-markdown.mjs +4 -2
  27. package/dist/{chunk-UVW64BCB.cjs → chunk-3A4KGQYI.cjs} +2 -2
  28. package/dist/{chunk-AO6RYU5N.cjs → chunk-3IP27TCG.cjs} +30 -22
  29. package/dist/{chunk-FDR64H6B.mjs → chunk-3KGDJLJK.mjs} +41 -2
  30. package/dist/{chunk-KXWRO25S.cjs → chunk-4GPOC4LN.cjs} +3 -3
  31. package/dist/{chunk-Z2HLU4IX.cjs → chunk-4GWRFP22.cjs} +23 -2
  32. package/dist/{chunk-276VJSM6.mjs → chunk-4P6ULFMD.mjs} +43 -30
  33. package/dist/{chunk-BPMATOP2.cjs → chunk-5BXGGEC7.cjs} +25 -20
  34. package/dist/{chunk-JNUWCDTF.cjs → chunk-5D2JIPLH.cjs} +2 -2
  35. package/dist/{chunk-AHGECQEW.mjs → chunk-666CKENS.mjs} +1 -1
  36. package/dist/{chunk-BO36SELV.cjs → chunk-6LGFV2CQ.cjs} +2 -2
  37. package/dist/{chunk-2YTDKNH3.cjs → chunk-6TJITR2B.cjs} +192 -120
  38. package/dist/{chunk-JZVADIOD.cjs → chunk-75X755YZ.cjs} +2 -2
  39. package/dist/{chunk-VQLJWDVW.cjs → chunk-7DWNJI73.cjs} +2 -2
  40. package/dist/{chunk-N2NAS2AM.cjs → chunk-7O5M4UKW.cjs} +2 -2
  41. package/dist/{chunk-BJPBQNIE.cjs → chunk-7SQ5SGYZ.cjs} +2 -2
  42. package/dist/{chunk-27ZWSI3W.cjs → chunk-ADOAUDQ6.cjs} +2 -2
  43. package/dist/{chunk-YKX5BK66.cjs → chunk-ATWHHSY2.cjs} +7 -7
  44. package/dist/{chunk-42NHY7HW.cjs → chunk-B5PFZLKV.cjs} +40 -9
  45. package/dist/{chunk-FNO7A7CM.cjs → chunk-BHY547NB.cjs} +34 -16
  46. package/dist/{chunk-4GLOOWKE.mjs → chunk-CQMVIOYP.mjs} +1 -1
  47. package/dist/{chunk-D2BB47NB.cjs → chunk-CVH2BXPY.cjs} +6 -6
  48. package/dist/{chunk-TKSCR644.cjs → chunk-D3C5LBQY.cjs} +2 -2
  49. package/dist/{chunk-PZNL3WEG.mjs → chunk-DMEPTZTI.mjs} +22 -11
  50. package/dist/{chunk-GQ3Z3IZI.cjs → chunk-EMMQ64QW.cjs} +18 -18
  51. package/dist/{chunk-OHLSEQ57.mjs → chunk-EXG5LD6B.mjs} +1 -1
  52. package/dist/{chunk-WZ77PUAM.mjs → chunk-FBOJ55OM.mjs} +1 -1
  53. package/dist/{chunk-OTC5BDGO.mjs → chunk-FGRYBX5X.mjs} +12 -7
  54. package/dist/{chunk-D227TIEN.cjs → chunk-FWE7LEQC.cjs} +13 -13
  55. package/dist/{chunk-3BU22U3M.cjs → chunk-G2TEB74S.cjs} +5 -2
  56. package/dist/{chunk-O6I6VWKK.mjs → chunk-HEVMCTSR.mjs} +1 -1
  57. package/dist/{chunk-W7LF2J2S.mjs → chunk-HMRSWN47.mjs} +1 -1
  58. package/dist/{chunk-JG6DJF5A.mjs → chunk-HZFM2LWQ.mjs} +22 -1
  59. package/dist/{chunk-35GKZR22.mjs → chunk-IAIYV4RZ.mjs} +1 -1
  60. package/dist/{chunk-F2SE2VDO.mjs → chunk-IHQIOZLC.mjs} +1 -1
  61. package/dist/{chunk-2NNMOPDN.mjs → chunk-J3ANCZKA.mjs} +4 -1
  62. package/dist/{chunk-C4SPBWFM.cjs → chunk-JEZO6VUR.cjs} +10 -1
  63. package/dist/{chunk-SC2WYWPF.mjs → chunk-JPNFPAZ4.mjs} +3 -3
  64. package/dist/{chunk-HOXTWRGB.mjs → chunk-K3SAEIM3.mjs} +5 -2
  65. package/dist/{chunk-35WV46VL.mjs → chunk-K4I4O5TS.mjs} +98 -26
  66. package/dist/{chunk-KN7K4VQN.mjs → chunk-KDTBF3UU.mjs} +1 -1
  67. package/dist/{chunk-QORUJDIV.mjs → chunk-KPFKMDM7.mjs} +2 -2
  68. package/dist/{chunk-YSCV4SJF.cjs → chunk-L5H2GSUC.cjs} +4 -4
  69. package/dist/{chunk-YDQZGSDS.mjs → chunk-LBDP3YT3.mjs} +1 -1
  70. package/dist/{chunk-LSZAVSGY.mjs → chunk-LBGILORX.mjs} +1 -1
  71. package/dist/{chunk-ADEA7PN3.cjs → chunk-LOFKRKO7.cjs} +2 -2
  72. package/dist/{chunk-ZWM5KGAA.cjs → chunk-LPFV45AY.cjs} +23 -20
  73. package/dist/{chunk-3KZS4SUS.mjs → chunk-MCIZVNOQ.mjs} +1 -1
  74. package/dist/{chunk-XCMCS4DA.mjs → chunk-ND2CWPOD.mjs} +2 -2
  75. package/dist/{chunk-S6VYG6XU.cjs → chunk-NDILNQ4L.cjs} +2 -2
  76. package/dist/{chunk-BPOF5U4N.mjs → chunk-NFMDCAOS.mjs} +10 -7
  77. package/dist/{chunk-UXFQ3UDA.cjs → chunk-NICDYKBS.cjs} +42 -3
  78. package/dist/{chunk-EZDQRNQ7.mjs → chunk-NNSAQX3U.mjs} +23 -5
  79. package/dist/{chunk-DZ5ZVB2K.cjs → chunk-NQ6QFZWD.cjs} +1 -1
  80. package/dist/{chunk-U4KT7QP3.cjs → chunk-OW67PDDS.cjs} +14 -1
  81. package/dist/{chunk-77GNHH2Z.cjs → chunk-PMQHMWZU.cjs} +3 -3
  82. package/dist/{chunk-NMHWYWDR.cjs → chunk-Q5FYSK45.cjs} +169 -156
  83. package/dist/{chunk-5SJWVY6R.mjs → chunk-QHSH7IH4.mjs} +9 -0
  84. package/dist/{chunk-EWET4D2Y.mjs → chunk-RRMVL6CJ.mjs} +3 -3
  85. package/dist/{chunk-IZY3V5XW.mjs → chunk-S3VWVTVA.mjs} +14 -1
  86. package/dist/{chunk-FFFW3OQ7.cjs → chunk-S6FJO323.cjs} +2 -2
  87. package/dist/chunk-SGBZPZUW.mjs +75 -0
  88. package/dist/{chunk-2ELDTQRN.mjs → chunk-TDNWPAVR.mjs} +1 -1
  89. package/dist/{chunk-IHNIDL6H.cjs → chunk-TO4GJ56K.cjs} +22 -11
  90. package/dist/{chunk-4WCZJQUO.mjs → chunk-TPLJVC7E.mjs} +37 -6
  91. package/dist/{chunk-NRSN7G7E.mjs → chunk-TW4GYDBJ.mjs} +1 -1
  92. package/dist/{chunk-FO427P6I.cjs → chunk-U6MPZ35Q.cjs} +10 -10
  93. package/dist/{chunk-CBJJH36A.cjs → chunk-UJZLSXUB.cjs} +3 -3
  94. package/dist/chunk-UXHS27O6.cjs +75 -0
  95. package/dist/{chunk-DQQOKWYA.cjs → chunk-VR4GD5I3.cjs} +3 -3
  96. package/dist/{chunk-T4OGRVNS.mjs → chunk-VXAWRDK7.mjs} +2 -2
  97. package/dist/{chunk-4NU4GGTC.cjs → chunk-W2YDNK66.cjs} +6 -3
  98. package/dist/{chunk-GQRWBCWK.mjs → chunk-WQ7T2263.mjs} +13 -5
  99. package/dist/chunk-WRPHYQVY.mjs +109 -0
  100. package/dist/chunk-WT4TGLXT.cjs +109 -0
  101. package/dist/{chunk-4E5AEDKY.mjs → chunk-XOPOIFTJ.mjs} +1 -1
  102. package/dist/{chunk-OO7GXVSR.mjs → chunk-YCKO6FRS.mjs} +1 -1
  103. package/dist/{chunk-MKYBIIAQ.mjs → chunk-Z5BEWYVO.mjs} +1 -1
  104. package/dist/{chunk-VILIPRS6.mjs → chunk-Z7LA7MHQ.mjs} +1 -1
  105. package/dist/{client-plugins-r1mOtSC1.d.ts → client-plugins-C8DjftDF.d.ts} +14 -0
  106. package/dist/{client-plugins-C3mK9Pol.d.mts → client-plugins-CV4eJ9De.d.mts} +14 -0
  107. package/dist/client-plugins.d.mts +1 -1
  108. package/dist/client-plugins.d.ts +1 -1
  109. package/dist/client.cjs +8 -8
  110. package/dist/client.d.mts +5 -5
  111. package/dist/client.d.ts +5 -5
  112. package/dist/client.mjs +7 -7
  113. package/dist/config.d.mts +1 -1
  114. package/dist/config.d.ts +1 -1
  115. package/dist/{devtools-JZJJY5CK.cjs → devtools-JXFQNWSH.cjs} +4 -4
  116. package/dist/{devtools-ERIKFEXX.mjs → devtools-KVOY2TCZ.mjs} +3 -3
  117. package/dist/docs.cjs +5 -5
  118. package/dist/docs.d.mts +2 -2
  119. package/dist/docs.d.ts +2 -2
  120. package/dist/docs.mjs +4 -4
  121. package/dist/headers.cjs +4 -4
  122. package/dist/headers.mjs +3 -3
  123. package/dist/i18n/client.cjs +11 -11
  124. package/dist/i18n/client.mjs +3 -3
  125. package/dist/index.cjs +42 -39
  126. package/dist/index.d.mts +14 -14
  127. package/dist/index.d.ts +14 -14
  128. package/dist/index.mjs +41 -38
  129. package/dist/integrations.cjs +3 -3
  130. package/dist/integrations.d.mts +1 -1
  131. package/dist/integrations.d.ts +1 -1
  132. package/dist/integrations.mjs +2 -2
  133. package/dist/internal/app-markdown-runtime.cjs +4 -2
  134. package/dist/internal/app-markdown-runtime.d.mts +19 -5
  135. package/dist/internal/app-markdown-runtime.d.ts +19 -5
  136. package/dist/internal/app-markdown-runtime.mjs +3 -1
  137. package/dist/internal/build-runtime.cjs +25 -23
  138. package/dist/internal/build-runtime.d.mts +3 -3
  139. package/dist/internal/build-runtime.d.ts +3 -3
  140. package/dist/internal/build-runtime.mjs +24 -22
  141. package/dist/internal/cli-runtime.cjs +8 -8
  142. package/dist/internal/cli-runtime.mjs +7 -7
  143. package/dist/internal/client-error-overlay.cjs +4 -4
  144. package/dist/internal/client-error-overlay.mjs +1 -1
  145. package/dist/internal/client-runtime.cjs +2 -2
  146. package/dist/internal/client-runtime.mjs +1 -1
  147. package/dist/internal/compression-runtime.d.mts +1 -1
  148. package/dist/internal/compression-runtime.d.ts +1 -1
  149. package/dist/internal/config-runtime.cjs +4 -4
  150. package/dist/internal/config-runtime.d.mts +2 -2
  151. package/dist/internal/config-runtime.d.ts +2 -2
  152. package/dist/internal/config-runtime.mjs +3 -3
  153. package/dist/internal/infra-analytics-runtime.cjs +5 -5
  154. package/dist/internal/infra-analytics-runtime.mjs +3 -3
  155. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  156. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  157. package/dist/internal/production-runtime.cjs +15 -50
  158. package/dist/internal/production-runtime.d.mts +8 -8
  159. package/dist/internal/production-runtime.d.ts +8 -8
  160. package/dist/internal/production-runtime.mjs +11 -46
  161. package/dist/markdown.d.mts +1 -1
  162. package/dist/markdown.d.ts +1 -1
  163. package/dist/middleware.cjs +8 -8
  164. package/dist/middleware.d.mts +6 -4
  165. package/dist/middleware.d.ts +6 -4
  166. package/dist/middleware.mjs +7 -7
  167. package/dist/navigation.cjs +7 -7
  168. package/dist/navigation.d.mts +4 -4
  169. package/dist/navigation.d.ts +4 -4
  170. package/dist/navigation.mjs +6 -6
  171. package/dist/plugin.cjs +19 -18
  172. package/dist/plugin.d.mts +1 -1
  173. package/dist/plugin.d.ts +1 -1
  174. package/dist/plugin.mjs +18 -17
  175. package/dist/{production-runtime-DPnsggY3.d.ts → production-runtime-C2kkrPVZ.d.ts} +1 -1
  176. package/dist/{production-runtime-CCeVZXst.d.mts → production-runtime-Du_FHb2-.d.mts} +1 -1
  177. package/dist/query/client.cjs +9 -9
  178. package/dist/query/client.mjs +4 -4
  179. package/dist/{render-plan-Cw4f5E_R.d.ts → render-plan-BnnPTpus.d.ts} +1 -1
  180. package/dist/{render-plan-BuGaPFe6.d.mts → render-plan-Cgx7v8tJ.d.mts} +1 -1
  181. package/dist/renderer-client.cjs +12 -12
  182. package/dist/renderer-client.d.mts +3 -3
  183. package/dist/renderer-client.d.ts +3 -3
  184. package/dist/renderer-client.mjs +4 -4
  185. package/dist/{request-Bkg-hERy.d.ts → request-BNWr7r5e.d.ts} +1 -1
  186. package/dist/{request-CsGARcAw.d.mts → request-sKayKcop.d.mts} +1 -1
  187. package/dist/request.cjs +3 -3
  188. package/dist/request.d.mts +2 -2
  189. package/dist/request.d.ts +2 -2
  190. package/dist/request.mjs +2 -2
  191. package/dist/{route-rendering-BUZMH_64.d.ts → route-rendering-Bx4Auw6Q.d.ts} +1 -1
  192. package/dist/{route-rendering-f11yh5dp.d.mts → route-rendering-DWFp3Yq4.d.mts} +1 -1
  193. package/dist/{router-Cp6yRE8A.d.mts → router-BK6K42Ij.d.mts} +1 -1
  194. package/dist/{router-B8CR9GbD.d.ts → router-DnW_2tQi.d.ts} +1 -1
  195. package/dist/routes.cjs +2 -2
  196. package/dist/routes.d.mts +1 -1
  197. package/dist/routes.d.ts +1 -1
  198. package/dist/routes.mjs +1 -1
  199. package/dist/{runtime-CQVsT330.d.ts → runtime-CA3Ei5k_.d.ts} +1 -1
  200. package/dist/{runtime-CAEv36S_.d.mts → runtime-DJDaCMd_.d.mts} +1 -1
  201. package/dist/server-fn.cjs +3 -3
  202. package/dist/server-fn.mjs +2 -2
  203. package/dist/server-plugins.cjs +5 -5
  204. package/dist/server-plugins.d.mts +2 -2
  205. package/dist/server-plugins.d.ts +2 -2
  206. package/dist/server-plugins.mjs +4 -4
  207. package/dist/server-query.cjs +4 -4
  208. package/dist/server-query.mjs +3 -3
  209. package/dist/server.cjs +45 -44
  210. package/dist/server.d.mts +7 -7
  211. package/dist/server.d.ts +7 -7
  212. package/dist/server.mjs +23 -22
  213. package/dist/{spa-router-DwbqGkGj.d.mts → spa-router-D6fUA4Rn.d.mts} +2 -2
  214. package/dist/{spa-router-BuciWGCZ.d.ts → spa-router-Mwbd7g2L.d.ts} +2 -2
  215. package/dist/testing.cjs +8 -8
  216. package/dist/testing.d.mts +1 -1
  217. package/dist/testing.d.ts +1 -1
  218. package/dist/testing.mjs +6 -6
  219. package/dist/theme/server.cjs +4 -4
  220. package/dist/theme/server.mjs +3 -3
  221. package/dist/{utils-CaoWKtYM.d.ts → utils-BwVcAfUR.d.ts} +1 -1
  222. package/dist/{utils-B9V0S_yL.d.mts → utils-p9Hs-jCc.d.mts} +1 -1
  223. package/dist/version.cjs +2 -2
  224. package/dist/version.mjs +1 -1
  225. package/dist/vite.cjs +19 -18
  226. package/dist/vite.d.mts +1 -1
  227. package/dist/vite.d.ts +1 -1
  228. package/dist/vite.mjs +18 -17
  229. package/package.json +1 -1
  230. package/types/middleware.d.ts +5 -1
  231. package/dist/chunk-FXEF4PPL.mjs +0 -47
  232. package/dist/chunk-XD32KALF.cjs +0 -47
  233. /package/dist/{chunk-SJNMVDDF.cjs → chunk-FUCSUGDM.cjs} +0 -0
  234. /package/dist/{chunk-UDNPLXW7.mjs → chunk-MYIZXDZA.mjs} +0 -0
@@ -10,6 +10,14 @@ function isFarmBlockedNavigationURL(url) {
10
10
  return true;
11
11
  }
12
12
  __name(isFarmBlockedNavigationURL, "isFarmBlockedNavigationURL");
13
+ function isFarmScriptURL(href) {
14
+ try {
15
+ return new URL(href, "http://farm.invalid").protocol === "javascript:";
16
+ } catch {
17
+ return false;
18
+ }
19
+ }
20
+ __name(isFarmScriptURL, "isFarmScriptURL");
13
21
  function isFarmExternalNavigationURL(url, currentOrigin) {
14
22
  return url.protocol !== "http:" && url.protocol !== "https:" || url.origin !== currentOrigin;
15
23
  }
@@ -21,6 +29,7 @@ __name(resolveFarmNavigationURL, "resolveFarmNavigationURL");
21
29
 
22
30
  export {
23
31
  isFarmBlockedNavigationURL,
32
+ isFarmScriptURL,
24
33
  isFarmExternalNavigationURL,
25
34
  resolveFarmNavigationURL
26
35
  };
@@ -12,8 +12,8 @@ import {
12
12
  getFarmRedirectError
13
13
  } from "./chunk-CBBLJMR5.mjs";
14
14
  import {
15
- _resolveCurrentRequest
16
- } from "./chunk-IZY3V5XW.mjs";
15
+ _resolveCurrentRequestForApp
16
+ } from "./chunk-S3VWVTVA.mjs";
17
17
  import {
18
18
  __name
19
19
  } from "./chunk-LPEX4YW6.mjs";
@@ -118,7 +118,7 @@ function createServerFn(options) {
118
118
  throw labelInputErrors && isSchemaValidationFailure(cause) ? new ServerFnInputError(cause) : cause;
119
119
  }
120
120
  const executionContext = getServerActionExecutionContext();
121
- const request = executionContext?.request ?? _resolveCurrentRequest();
121
+ const request = executionContext?.request ?? _resolveCurrentRequestForApp();
122
122
  const signal = executionContext?.signal ?? request?.signal ?? getServerActionSignal();
123
123
  const handlerContext = {
124
124
  input,
@@ -4,6 +4,7 @@ import {
4
4
 
5
5
  // src/server/request-bridge.ts
6
6
  var CURRENT_REQUEST_RESOLVER_KEY = /* @__PURE__ */ Symbol.for("farm.currentRequestResolver");
7
+ var APP_REQUEST_VIEW_KEY = /* @__PURE__ */ Symbol.for("farm.appRequestView");
7
8
  function getGlobalState() {
8
9
  return globalThis;
9
10
  }
@@ -16,8 +17,20 @@ function _resolveCurrentRequest() {
16
17
  return getGlobalState()[CURRENT_REQUEST_RESOLVER_KEY]?.();
17
18
  }
18
19
  __name(_resolveCurrentRequest, "_resolveCurrentRequest");
20
+ function _setAppRequestView(view) {
21
+ getGlobalState()[APP_REQUEST_VIEW_KEY] = view;
22
+ }
23
+ __name(_setAppRequestView, "_setAppRequestView");
24
+ function _resolveCurrentRequestForApp() {
25
+ const request = _resolveCurrentRequest();
26
+ const view = getGlobalState()[APP_REQUEST_VIEW_KEY];
27
+ return request && view ? view(request) : request;
28
+ }
29
+ __name(_resolveCurrentRequestForApp, "_resolveCurrentRequestForApp");
19
30
 
20
31
  export {
21
32
  _setCurrentRequestResolver,
22
- _resolveCurrentRequest
33
+ _resolveCurrentRequest,
34
+ _setAppRequestView,
35
+ _resolveCurrentRequestForApp
23
36
  };
@@ -1,6 +1,6 @@
1
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
2
 
3
- var _chunkC4SPBWFMcjs = require('./chunk-C4SPBWFM.cjs');
3
+ var _chunkJEZO6VURcjs = require('./chunk-JEZO6VUR.cjs');
4
4
 
5
5
 
6
6
  var _chunkLIUGYUX3cjs = require('./chunk-LIUGYUX3.cjs');
@@ -48,7 +48,7 @@ function isFarmLocaleChangeHref(href) {
48
48
  const snapshot = getFarmI18nClientState();
49
49
  if (!snapshot || typeof window === "undefined") return false;
50
50
  if (snapshot.routing === "none") return false;
51
- const target = _chunkC4SPBWFMcjs.resolveFarmNavigationURL.call(void 0, href, window.location.href);
51
+ const target = _chunkJEZO6VURcjs.resolveFarmNavigationURL.call(void 0, href, window.location.href);
52
52
  const match = _chunkBIDYX3SLcjs.resolveFarmLocalePath.call(void 0, target.pathname, snapshot);
53
53
  const targetLocale = match.locale || snapshot.defaultLocale;
54
54
  return targetLocale !== snapshot.locale;
@@ -0,0 +1,75 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-LPEX4YW6.mjs";
4
+
5
+ // src/api/dev-dispatch.ts
6
+ import http from "http";
7
+ import https from "https";
8
+ import { Readable } from "stream";
9
+ function createFarmDevServerDispatch(server) {
10
+ return (request) => new Promise((resolve, reject) => {
11
+ const address = server.httpServer?.address();
12
+ if (!address || typeof address === "string") {
13
+ throw new Error(
14
+ "Farm cannot dispatch an app endpoint request: the Vite dev server has no listening HTTP server."
15
+ );
16
+ }
17
+ const url = new URL(request.url);
18
+ const headers = {};
19
+ request.headers.forEach((value, name) => {
20
+ headers[name] = value;
21
+ });
22
+ headers.host = url.host;
23
+ const secure = Boolean(server.config.server.https);
24
+ const outgoing = (secure ? https : http).request(
25
+ {
26
+ host: loopbackAddress(address),
27
+ port: address.port,
28
+ method: request.method,
29
+ path: `${url.pathname}${url.search}`,
30
+ headers,
31
+ signal: request.signal,
32
+ // The listener is this process's own dev server, often with a self-signed certificate.
33
+ ...secure ? { rejectUnauthorized: false } : {}
34
+ },
35
+ (incoming) => {
36
+ const responseHeaders = new Headers();
37
+ for (const [name, value] of Object.entries(incoming.headers)) {
38
+ if (value === void 0) continue;
39
+ for (const entry of Array.isArray(value) ? value : [value]) {
40
+ responseHeaders.append(name, entry);
41
+ }
42
+ }
43
+ const status = incoming.statusCode ?? 502;
44
+ const hasBody = request.method !== "HEAD" && status !== 204 && status !== 205 && status !== 304;
45
+ if (!hasBody) incoming.resume();
46
+ try {
47
+ resolve(
48
+ new Response(
49
+ hasBody ? Readable.toWeb(incoming) : null,
50
+ { status, statusText: incoming.statusMessage, headers: responseHeaders }
51
+ )
52
+ );
53
+ } catch (error) {
54
+ incoming.destroy();
55
+ reject(error);
56
+ }
57
+ }
58
+ );
59
+ outgoing.on("error", reject);
60
+ if (request.body) {
61
+ Readable.fromWeb(request.body).on("error", (error) => outgoing.destroy(error)).pipe(outgoing);
62
+ } else {
63
+ outgoing.end();
64
+ }
65
+ });
66
+ }
67
+ __name(createFarmDevServerDispatch, "createFarmDevServerDispatch");
68
+ function loopbackAddress({ address }) {
69
+ return address === "0.0.0.0" ? "127.0.0.1" : address === "::" ? "::1" : address;
70
+ }
71
+ __name(loopbackAddress, "loopbackAddress");
72
+
73
+ export {
74
+ createFarmDevServerDispatch
75
+ };
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-JM5XPKWH.mjs";
10
10
  import {
11
11
  getCurrentRequestOrNull
12
- } from "./chunk-FDR64H6B.mjs";
12
+ } from "./chunk-3KGDJLJK.mjs";
13
13
  import {
14
14
  __name
15
15
  } from "./chunk-LPEX4YW6.mjs";
@@ -569,6 +569,10 @@ async function resolveProgrammaticRouteData(route, dataHooks, context) {
569
569
  if (routeDataKey == null) {
570
570
  return dataHooks.main(context);
571
571
  }
572
+ const revalidate = normalizeProgrammaticRouteStaleTime(dataHooks.staleTime, route.path);
573
+ if (revalidate === 0) {
574
+ return dataHooks.main(context);
575
+ }
572
576
  const cacheKey = _chunkNYJMY3JAcjs.createFarmCacheKey.call(void 0, ["route-data", routeDataKey]);
573
577
  const cacheOptions = {
574
578
  tags: [
@@ -579,7 +583,7 @@ async function resolveProgrammaticRouteData(route, dataHooks, context) {
579
583
  ...typeof context.path === "string" ? [context.path] : [],
580
584
  ...await resolveProgrammaticRouteDataKeys(dataHooks.paths, context)
581
585
  ],
582
- revalidate: normalizeProgrammaticRouteStaleTime(dataHooks.staleTime)
586
+ revalidate
583
587
  };
584
588
  return _chunkYWN746UScjs.getFarmDataCache.call(void 0, ).getOrSet(cacheKey, () => dataHooks.main(context), cacheOptions);
585
589
  }
@@ -590,20 +594,26 @@ async function resolveProgrammaticRouteDataKeys(input, context) {
590
594
  return value.filter((item) => typeof item === "string" && item.trim().length > 0);
591
595
  }
592
596
  _chunkS3JO3N4Hcjs.__name.call(void 0, resolveProgrammaticRouteDataKeys, "resolveProgrammaticRouteDataKeys");
593
- function normalizeProgrammaticRouteStaleTime(staleTime) {
597
+ function normalizeProgrammaticRouteStaleTime(staleTime, routePath) {
594
598
  if (staleTime === void 0) return void 0;
595
599
  if (staleTime === false) return false;
600
+ let milliseconds;
596
601
  if (typeof staleTime === "number") {
597
- if (!Number.isFinite(staleTime) || staleTime <= 0) return void 0;
598
- return Math.max(1, Math.ceil(staleTime / 1e3));
602
+ milliseconds = staleTime;
603
+ } else {
604
+ const match = typeof staleTime === "string" && staleTime.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)$/);
605
+ if (!match) {
606
+ throw new TypeError(
607
+ `Route "${routePath}" data.staleTime must be milliseconds or a duration like "250ms", "30s", "5m", or "1h".`
608
+ );
609
+ }
610
+ const unit = match[2];
611
+ milliseconds = Number(match[1]) * (unit === "ms" ? 1 : unit === "s" ? 1e3 : unit === "m" ? 6e4 : 36e5);
612
+ }
613
+ if (!Number.isFinite(milliseconds) || milliseconds < 0) {
614
+ throw new TypeError(`Route "${routePath}" data.staleTime must be a non-negative duration.`);
599
615
  }
600
- const match = staleTime.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)$/);
601
- if (!match) return void 0;
602
- const value = Number(match[1]);
603
- if (!Number.isFinite(value) || value <= 0) return void 0;
604
- const unit = match[2];
605
- const milliseconds = unit === "ms" ? value : unit === "s" ? value * 1e3 : unit === "m" ? value * 6e4 : value * 36e5;
606
- return Math.max(1, Math.ceil(milliseconds / 1e3));
616
+ return milliseconds === 0 ? 0 : Math.max(1, Math.ceil(milliseconds / 1e3));
607
617
  }
608
618
  _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeProgrammaticRouteStaleTime, "normalizeProgrammaticRouteStaleTime");
609
619
  function isProgrammaticRoutePropsResolved(value) {
@@ -662,6 +672,7 @@ function normalizeProgrammaticRoute(route) {
662
672
  };
663
673
  }
664
674
  const routeActions = route.kind === "page" ? normalizeProgrammaticRouteActions(route) : void 0;
675
+ normalizeProgrammaticRouteStaleTime(_optionalChain([route, 'access', _11 => _11.data, 'optionalAccess', _12 => _12.staleTime]), route.path);
665
676
  return {
666
677
  ...route,
667
678
  ...routeActions,
@@ -119,7 +119,6 @@ var ANONYMOUS_REQUEST_HEADERS = /* @__PURE__ */ new Set([
119
119
  "cache-control",
120
120
  "connection",
121
121
  "dnt",
122
- "forwarded",
123
122
  "host",
124
123
  "if-match",
125
124
  "if-modified-since",
@@ -141,12 +140,9 @@ var ANONYMOUS_REQUEST_HEADERS = /* @__PURE__ */ new Set([
141
140
  "tracestate",
142
141
  "upgrade-insecure-requests",
143
142
  "user-agent",
144
- "via",
145
- "x-forwarded-for",
146
143
  "x-forwarded-host",
147
144
  "x-forwarded-port",
148
145
  "x-forwarded-proto",
149
- "x-real-ip",
150
146
  "x-request-id"
151
147
  ]);
152
148
  function isAnonymousRequestHeader(name) {
@@ -154,6 +150,36 @@ function isAnonymousRequestHeader(name) {
154
150
  return ANONYMOUS_REQUEST_HEADERS.has(lower) || lower.startsWith("sec-fetch-") || lower.startsWith("sec-ch-");
155
151
  }
156
152
  __name(isAnonymousRequestHeader, "isAnonymousRequestHeader");
153
+ var PAGE_CHECK_DROPPED_HEADERS = /* @__PURE__ */ new Set([
154
+ "accept-encoding",
155
+ "if-match",
156
+ "if-modified-since",
157
+ "if-none-match",
158
+ "if-range",
159
+ "if-unmodified-since",
160
+ "range"
161
+ ]);
162
+ async function anonymousVisitorOpensPage(options, url, targetPathname) {
163
+ const pageUrl = new URL(url);
164
+ pageUrl.pathname = targetPathname;
165
+ const headers = new Headers();
166
+ for (const [name, value] of options.request.headers) {
167
+ if (!PAGE_CHECK_DROPPED_HEADERS.has(name.toLowerCase())) headers.append(name, value);
168
+ }
169
+ headers.set("accept", "text/html");
170
+ const response = await options.renderPage(
171
+ new Request(pageUrl, {
172
+ method: "GET",
173
+ headers,
174
+ redirect: "manual",
175
+ signal: options.request.signal
176
+ })
177
+ );
178
+ void response.body?.cancel().catch(() => {
179
+ });
180
+ return response.status >= 200 && response.status < 300 && Boolean(response.headers.get("content-type")?.toLowerCase().includes("text/html"));
181
+ }
182
+ __name(anonymousVisitorOpensPage, "anonymousVisitorOpensPage");
157
183
  function hasOnlyAnonymousHeaders(headers) {
158
184
  for (const name of headers.keys()) {
159
185
  if (!isAnonymousRequestHeader(name)) return false;
@@ -161,6 +187,7 @@ function hasOnlyAnonymousHeaders(headers) {
161
187
  return true;
162
188
  }
163
189
  __name(hasOnlyAnonymousHeaders, "hasOnlyAnonymousHeaders");
190
+ var FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS = "192.0.2.1";
164
191
  async function createFarmMarkdownSourceResponse(options) {
165
192
  if (options.request.method !== "GET" && options.request.method !== "HEAD") {
166
193
  return null;
@@ -178,7 +205,7 @@ async function createFarmMarkdownSourceResponse(options) {
178
205
  if (!source) {
179
206
  return null;
180
207
  }
181
- const anonymous = hasOnlyAnonymousHeaders(options.request.headers);
208
+ const anonymous = hasOnlyAnonymousHeaders(options.request.headers) && (!options.clientAddress || options.clientAddress === FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS);
182
209
  if (options.renderPage && (hasMarkdownExtension || !anonymous)) {
183
210
  const publicUrl = new URL(url);
184
211
  publicUrl.pathname = targetPathname;
@@ -194,7 +221,7 @@ async function createFarmMarkdownSourceResponse(options) {
194
221
  signal: options.request.signal
195
222
  })
196
223
  );
197
- if (publicResponse.headers.get("X-Farm-Markdown-Route") === targetPathname) {
224
+ if (publicResponse.headers.get("X-Farm-Markdown-Route") === targetPathname && publicResponse.headers.has("X-Farm-Markdown-Source")) {
198
225
  publicSourceResponses.add(publicResponse);
199
226
  return publicResponse;
200
227
  }
@@ -209,6 +236,9 @@ async function createFarmMarkdownSourceResponse(options) {
209
236
  }
210
237
  });
211
238
  }
239
+ if (options.renderPage && !await anonymousVisitorOpensPage(options, url, targetPathname)) {
240
+ return null;
241
+ }
212
242
  const headers = new Headers({
213
243
  "Content-Type": "text/markdown; charset=utf-8",
214
244
  "Content-Location": targetPathname === "/" ? "/index.md" : `${targetPathname}.md`,
@@ -238,5 +268,6 @@ export {
238
268
  createMarkdownMetadata,
239
269
  createFarmMarkdownRouteModule,
240
270
  isFarmMarkdownPublicSourceResponse,
271
+ FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS,
241
272
  createFarmMarkdownSourceResponse
242
273
  };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-JM5XPKWH.mjs";
4
4
  import {
5
5
  getCurrentRequest
6
- } from "./chunk-FDR64H6B.mjs";
6
+ } from "./chunk-3KGDJLJK.mjs";
7
7
  import {
8
8
  __name
9
9
  } from "./chunk-LPEX4YW6.mjs";
@@ -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 _chunkSJNMVDDFcjs = require('./chunk-SJNMVDDF.cjs');
3
+ var _chunkFUCSUGDMcjs = require('./chunk-FUCSUGDM.cjs');
4
4
 
5
5
 
6
6
  var _chunk2CQ74SP6cjs = require('./chunk-2CQ74SP6.cjs');
@@ -17,7 +17,7 @@ var _chunkLYLEZIG3cjs = require('./chunk-LYLEZIG3.cjs');
17
17
 
18
18
 
19
19
 
20
- var _chunkS6VYG6XUcjs = require('./chunk-S6VYG6XU.cjs');
20
+ var _chunkNDILNQ4Lcjs = require('./chunk-NDILNQ4L.cjs');
21
21
 
22
22
 
23
23
  var _chunkWMAPPDMMcjs = require('./chunk-WMAPPDMM.cjs');
@@ -102,7 +102,7 @@ var _APIRouteManager = class _APIRouteManager {
102
102
  await this.loadProgrammaticApiRoutes(appDir);
103
103
  }
104
104
  this.routes = new Map(
105
- _chunkS6VYG6XUcjs.mergePluginAPIRoutes.call(void 0, [...this.routes.values()], this.plugins, void 0, {
105
+ _chunkNDILNQ4Lcjs.mergePluginAPIRoutes.call(void 0, [...this.routes.values()], this.plugins, void 0, {
106
106
  bodySizeLimit: this.bodySizeLimit,
107
107
  dispatch: this.dispatch
108
108
  }).map((route) => [route.path, route])
@@ -150,7 +150,7 @@ var _APIRouteManager = class _APIRouteManager {
150
150
  const routeModule = await this.loadModule(filePath);
151
151
  const endpoints = {};
152
152
  const availableMethods = [];
153
- for (const method of _chunkS6VYG6XUcjs.API_ROUTE_METHODS) {
153
+ for (const method of _chunkNDILNQ4Lcjs.API_ROUTE_METHODS) {
154
154
  if (routeModule[method]) {
155
155
  endpoints[method] = routeModule[method];
156
156
  availableMethods.push(method);
@@ -220,7 +220,7 @@ var _APIRouteManager = class _APIRouteManager {
220
220
  async loadProgrammaticApiRoutes(appDir) {
221
221
  const candidateRoots = [path.dirname(appDir), appDir];
222
222
  const routeFiles = Array.from(
223
- new Set(candidateRoots.flatMap((srcRoot) => _chunkSJNMVDDFcjs.findProgrammaticRouteFilesInDir.call(void 0, srcRoot)))
223
+ new Set(candidateRoots.flatMap((srcRoot) => _chunkFUCSUGDMcjs.findProgrammaticRouteFilesInDir.call(void 0, srcRoot)))
224
224
  );
225
225
  if (routeFiles.length === 0) return;
226
226
  const { getProgrammaticRouteManifest } = await import("./routes.cjs");
@@ -332,7 +332,7 @@ var _APIRouteManager = class _APIRouteManager {
332
332
  const url = new URL(request.url);
333
333
  const pathname = url.pathname;
334
334
  const method = request.method.toUpperCase();
335
- const match = _chunkS6VYG6XUcjs.matchAPIRouteAtBasePath.call(void 0, this.routes, pathname, this.basePath);
335
+ const match = _chunkNDILNQ4Lcjs.matchAPIRouteAtBasePath.call(void 0, this.routes, pathname, this.basePath);
336
336
  if (!match) {
337
337
  return new Response(JSON.stringify({ error: "Not Found" }), {
338
338
  status: 404,
@@ -340,19 +340,19 @@ var _APIRouteManager = class _APIRouteManager {
340
340
  });
341
341
  }
342
342
  const { route, params } = match;
343
- const endpoint = _chunkS6VYG6XUcjs.resolveAPIRouteEndpoint.call(void 0, route, method);
343
+ const endpoint = _chunkNDILNQ4Lcjs.resolveAPIRouteEndpoint.call(void 0, route, method);
344
344
  if (!endpoint) {
345
345
  return new Response(JSON.stringify({ error: "Method Not Allowed" }), {
346
346
  status: 405,
347
347
  headers: {
348
- Allow: _chunkS6VYG6XUcjs.getAllowedAPIRouteMethods.call(void 0, route).join(", "),
348
+ Allow: _chunkNDILNQ4Lcjs.getAllowedAPIRouteMethods.call(void 0, route).join(", "),
349
349
  "Content-Type": "application/json"
350
350
  }
351
351
  });
352
352
  }
353
353
  const invoke = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async () => {
354
354
  try {
355
- return await _chunkS6VYG6XUcjs.invokeAPIRouteEndpoint.call(void 0, endpoint, request, params, this.bodySizeLimit);
355
+ return await _chunkNDILNQ4Lcjs.invokeAPIRouteEndpoint.call(void 0, endpoint, request, params, this.bodySizeLimit);
356
356
  } catch (error) {
357
357
  if (options.throwOnError) throw error;
358
358
  console.error(`[API Error] ${pathname}:`, error);
@@ -374,7 +374,7 @@ var _APIRouteManager = class _APIRouteManager {
374
374
  return Boolean(this.matchRoute(pathname));
375
375
  }
376
376
  matchRoute(pathname) {
377
- return _chunkS6VYG6XUcjs.matchAPIRouteAtBasePath.call(void 0, this.routes, pathname, this.basePath);
377
+ return _chunkNDILNQ4Lcjs.matchAPIRouteAtBasePath.call(void 0, this.routes, pathname, this.basePath);
378
378
  }
379
379
  /**
380
380
  * Get all routes for client type generation
@@ -4,7 +4,7 @@ var _chunkG643DQCHcjs = require('./chunk-G643DQCH.cjs');
4
4
 
5
5
 
6
6
 
7
- var _chunkZ2HLU4IXcjs = require('./chunk-Z2HLU4IX.cjs');
7
+ var _chunk4GWRFP22cjs = require('./chunk-4GWRFP22.cjs');
8
8
 
9
9
 
10
10
 
@@ -2021,13 +2021,13 @@ function resolveIntegrationMiddlewareParams(entry, pathname, config) {
2021
2021
  }
2022
2022
  let compiled = compiledIntegrationGuards.get(entry);
2023
2023
  if (!compiled) {
2024
- compiled = _chunkZ2HLU4IXcjs.compileMiddlewareConfig.call(void 0, {
2024
+ compiled = _chunk4GWRFP22cjs.compileMiddlewareConfig.call(void 0, {
2025
2025
  matcher: typeof entry.matcher === "string" ? entry.matcher : [...entry.matcher]
2026
2026
  });
2027
2027
  compiledIntegrationGuards.set(entry, compiled);
2028
2028
  }
2029
2029
  for (const candidate of candidates) {
2030
- const result = _chunkZ2HLU4IXcjs.matchesCompiledMiddlewareConfig.call(void 0, candidate, compiled, noMiddlewareContext);
2030
+ const result = _chunk4GWRFP22cjs.matchesCompiledMiddlewareConfig.call(void 0, candidate, compiled, noMiddlewareContext);
2031
2031
  if (result.matched) return _nullishCoalesce(result.params, () => ( {}));
2032
2032
  }
2033
2033
  return null;
@@ -0,0 +1,75 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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
+
3
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
4
+
5
+ // src/api/dev-dispatch.ts
6
+ var _http = require('http'); var _http2 = _interopRequireDefault(_http);
7
+ var _https = require('https'); var _https2 = _interopRequireDefault(_https);
8
+ var _stream = require('stream');
9
+ function createFarmDevServerDispatch(server) {
10
+ return (request) => new Promise((resolve, reject) => {
11
+ const address = _optionalChain([server, 'access', _ => _.httpServer, 'optionalAccess', _2 => _2.address, 'call', _3 => _3()]);
12
+ if (!address || typeof address === "string") {
13
+ throw new Error(
14
+ "Farm cannot dispatch an app endpoint request: the Vite dev server has no listening HTTP server."
15
+ );
16
+ }
17
+ const url = new URL(request.url);
18
+ const headers = {};
19
+ request.headers.forEach((value, name) => {
20
+ headers[name] = value;
21
+ });
22
+ headers.host = url.host;
23
+ const secure = Boolean(server.config.server.https);
24
+ const outgoing = (secure ? _https2.default : _http2.default).request(
25
+ {
26
+ host: loopbackAddress(address),
27
+ port: address.port,
28
+ method: request.method,
29
+ path: `${url.pathname}${url.search}`,
30
+ headers,
31
+ signal: request.signal,
32
+ // The listener is this process's own dev server, often with a self-signed certificate.
33
+ ...secure ? { rejectUnauthorized: false } : {}
34
+ },
35
+ (incoming) => {
36
+ const responseHeaders = new Headers();
37
+ for (const [name, value] of Object.entries(incoming.headers)) {
38
+ if (value === void 0) continue;
39
+ for (const entry of Array.isArray(value) ? value : [value]) {
40
+ responseHeaders.append(name, entry);
41
+ }
42
+ }
43
+ const status = _nullishCoalesce(incoming.statusCode, () => ( 502));
44
+ const hasBody = request.method !== "HEAD" && status !== 204 && status !== 205 && status !== 304;
45
+ if (!hasBody) incoming.resume();
46
+ try {
47
+ resolve(
48
+ new Response(
49
+ hasBody ? _stream.Readable.toWeb(incoming) : null,
50
+ { status, statusText: incoming.statusMessage, headers: responseHeaders }
51
+ )
52
+ );
53
+ } catch (error) {
54
+ incoming.destroy();
55
+ reject(error);
56
+ }
57
+ }
58
+ );
59
+ outgoing.on("error", reject);
60
+ if (request.body) {
61
+ _stream.Readable.fromWeb(request.body).on("error", (error) => outgoing.destroy(error)).pipe(outgoing);
62
+ } else {
63
+ outgoing.end();
64
+ }
65
+ });
66
+ }
67
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmDevServerDispatch, "createFarmDevServerDispatch");
68
+ function loopbackAddress({ address }) {
69
+ return address === "0.0.0.0" ? "127.0.0.1" : address === "::" ? "::1" : address;
70
+ }
71
+ _chunkS3JO3N4Hcjs.__name.call(void 0, loopbackAddress, "loopbackAddress");
72
+
73
+
74
+
75
+ exports.createFarmDevServerDispatch = createFarmDevServerDispatch;
@@ -3,18 +3,18 @@
3
3
  var _chunkAI7QMY7Ocjs = require('./chunk-AI7QMY7O.cjs');
4
4
 
5
5
 
6
- var _chunkUXFQ3UDAcjs = require('./chunk-UXFQ3UDA.cjs');
6
+ var _chunkNICDYKBScjs = require('./chunk-NICDYKBS.cjs');
7
7
 
8
8
 
9
9
  var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
10
10
 
11
11
  // src/headers.ts
12
12
  function headers() {
13
- return new Headers(_chunkUXFQ3UDAcjs.getCurrentRequest.call(void 0, ).headers);
13
+ return new Headers(_chunkNICDYKBScjs.getCurrentRequest.call(void 0, ).headers);
14
14
  }
15
15
  _chunkS3JO3N4Hcjs.__name.call(void 0, headers, "headers");
16
16
  function cookies() {
17
- const cookieHeader = _chunkUXFQ3UDAcjs.getCurrentRequest.call(void 0, ).headers.get("cookie") || "";
17
+ const cookieHeader = _chunkNICDYKBScjs.getCurrentRequest.call(void 0, ).headers.get("cookie") || "";
18
18
  const parsed = _chunkAI7QMY7Ocjs.parseRequestCookieHeader.call(void 0, cookieHeader);
19
19
  return {
20
20
  get(name) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  findProgrammaticRouteFilesInDir
3
- } from "./chunk-UDNPLXW7.mjs";
3
+ } from "./chunk-MYIZXDZA.mjs";
4
4
  import {
5
5
  isFarmAPIRouteFileName
6
6
  } from "./chunk-CU625VAY.mjs";
@@ -17,7 +17,7 @@ import {
17
17
  matchAPIRouteAtBasePath,
18
18
  mergePluginAPIRoutes,
19
19
  resolveAPIRouteEndpoint
20
- } from "./chunk-O6I6VWKK.mjs";
20
+ } from "./chunk-HEVMCTSR.mjs";
21
21
  import {
22
22
  registerAPIRouteShape
23
23
  } from "./chunk-W3B4PKAW.mjs";
@@ -1,6 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _chunkZWM5KGAAcjs = require('./chunk-ZWM5KGAA.cjs');
3
+ var _chunkLPFV45AYcjs = require('./chunk-LPFV45AY.cjs');
4
+
5
+
6
+ var _chunk4GWRFP22cjs = require('./chunk-4GWRFP22.cjs');
4
7
 
5
8
 
6
9
  var _chunkHLJ6MBUZcjs = require('./chunk-HLJ6MBUZ.cjs');
@@ -210,7 +213,7 @@ var _MiddlewareChainImpl = class _MiddlewareChainImpl {
210
213
  */
211
214
  when(condition, fn) {
212
215
  const conditionalMiddleware = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async (ctx, next) => {
213
- const shouldRun = typeof condition === "function" ? condition(ctx) : condition;
216
+ const shouldRun = typeof condition === "function" ? _chunk4GWRFP22cjs.matchesMiddlewarePredicate.call(void 0, condition, ctx) : condition;
214
217
  if (!shouldRun) {
215
218
  return next();
216
219
  }
@@ -415,7 +418,7 @@ function farmMiddlewarePlugin(options = {}) {
415
418
  mode: server.config.mode === "production" ? "production" : "development",
416
419
  basePath: _nullishCoalesce(options.basePath, () => ( "/"))
417
420
  });
418
- manager = new (0, _chunkZWM5KGAAcjs.MiddlewareManager)(
421
+ manager = new (0, _chunkLPFV45AYcjs.MiddlewareManager)(
419
422
  getMiddlewareAppDirectory(server.config.root, srcDir),
420
423
  server,
421
424
  options.middleware,