@farm.js/core 0.1.37 → 0.1.39

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 (250) hide show
  1. package/dist/{agent-mcp-BC0bAGVF.d.mts → agent-mcp-BhneNPb4.d.mts} +1 -1
  2. package/dist/{agent-mcp-jyDHbQKe.d.ts → agent-mcp-HcTYQmNX.d.ts} +1 -1
  3. package/dist/{agent-mcp-handler-SJAHFSPI.cjs → agent-mcp-handler-MRGP3WJ3.cjs} +5 -5
  4. package/dist/{agent-mcp-handler-LPJ2CADR.mjs → agent-mcp-handler-OLRMZONF.mjs} +4 -4
  5. package/dist/agent-runtime.cjs +3 -3
  6. package/dist/agent-runtime.d.mts +1 -1
  7. package/dist/agent-runtime.d.ts +1 -1
  8. package/dist/agent-runtime.mjs +2 -2
  9. package/dist/api/client.cjs +3 -3
  10. package/dist/api/client.mjs +2 -2
  11. package/dist/api/route-manager.cjs +5 -5
  12. package/dist/api/route-manager.d.mts +3 -3
  13. package/dist/api/route-manager.d.ts +3 -3
  14. package/dist/api/route-manager.mjs +4 -4
  15. package/dist/api/runtime.cjs +4 -4
  16. package/dist/api/runtime.d.mts +2 -2
  17. package/dist/api/runtime.d.ts +2 -2
  18. package/dist/api/runtime.mjs +3 -3
  19. package/dist/api.cjs +7 -7
  20. package/dist/api.d.mts +3 -3
  21. package/dist/api.d.ts +3 -3
  22. package/dist/api.mjs +6 -6
  23. package/dist/{app-CKO3iN1c.d.ts → app-CMkoghtp.d.ts} +21 -3
  24. package/dist/{app-Cbkj9ufe.d.mts → app-DVzmmbNO.d.mts} +21 -3
  25. package/dist/app-markdown.cjs +4 -4
  26. package/dist/app-markdown.d.mts +2 -2
  27. package/dist/app-markdown.d.ts +2 -2
  28. package/dist/app-markdown.mjs +3 -3
  29. package/dist/chunk-2ZYGC6SS.cjs +576 -0
  30. package/dist/{chunk-75X755YZ.cjs → chunk-34UCJRQO.cjs} +2 -2
  31. package/dist/{chunk-CVH2BXPY.cjs → chunk-3LOLJTFV.cjs} +6 -6
  32. package/dist/{chunk-4GPOC4LN.cjs → chunk-472NCAZ7.cjs} +3 -3
  33. package/dist/{chunk-O6WAEAX3.mjs → chunk-5BWWFHR2.mjs} +70 -15
  34. package/dist/{chunk-6LGFV2CQ.cjs → chunk-5OKBARDN.cjs} +2 -2
  35. package/dist/{chunk-3IP27TCG.cjs → chunk-5PWXMJOH.cjs} +19 -19
  36. package/dist/{chunk-WT4TGLXT.cjs → chunk-5ULKUBIA.cjs} +6 -6
  37. package/dist/{chunk-WRPHYQVY.mjs → chunk-677THUVP.mjs} +1 -1
  38. package/dist/chunk-6BK3K2GB.mjs +318 -0
  39. package/dist/{chunk-HEVMCTSR.mjs → chunk-6HB6V3R7.mjs} +1 -1
  40. package/dist/{chunk-NICDYKBS.cjs → chunk-6XWDE2P2.cjs} +22 -4
  41. package/dist/{chunk-CXEN47J3.mjs → chunk-73WX6PRY.mjs} +25 -0
  42. package/dist/{chunk-EXG5LD6B.mjs → chunk-75HN5IZ3.mjs} +21 -9
  43. package/dist/{chunk-7O5M4UKW.cjs → chunk-A657YSP4.cjs} +2 -2
  44. package/dist/{chunk-LBDP3YT3.mjs → chunk-ARC7I3O2.mjs} +1 -1
  45. package/dist/{chunk-Q5FYSK45.cjs → chunk-AS2VPMEE.cjs} +640 -521
  46. package/dist/{chunk-Z5BEWYVO.mjs → chunk-ATSDUUFK.mjs} +27 -1
  47. package/dist/{chunk-EMMQ64QW.cjs → chunk-B5J2YVG7.cjs} +16 -16
  48. package/dist/{chunk-FWE7LEQC.cjs → chunk-BD3D7EZV.cjs} +4 -4
  49. package/dist/{chunk-Z7LA7MHQ.mjs → chunk-BFJTHYTN.mjs} +1 -1
  50. package/dist/{chunk-UJZLSXUB.cjs → chunk-BWIQR4DH.cjs} +30 -4
  51. package/dist/{chunk-W2YDNK66.cjs → chunk-BXDJXFQG.cjs} +4 -4
  52. package/dist/{chunk-MCIZVNOQ.mjs → chunk-BZHXGVMA.mjs} +1 -1
  53. package/dist/{chunk-7DWNJI73.cjs → chunk-CIOT4HGT.cjs} +37 -19
  54. package/dist/{chunk-KDTBF3UU.mjs → chunk-CNNOLE4O.mjs} +1 -1
  55. package/dist/{chunk-TDNWPAVR.mjs → chunk-CUM5NYL5.mjs} +1 -1
  56. package/dist/{chunk-HITLGIAO.cjs → chunk-CY2ZQ5C6.cjs} +7 -6
  57. package/dist/{chunk-KPFKMDM7.mjs → chunk-EGCTIS5F.mjs} +2 -2
  58. package/dist/{chunk-VR4GD5I3.cjs → chunk-EIPC3FDA.cjs} +12 -4
  59. package/dist/{chunk-B5PFZLKV.cjs → chunk-EKN7NSZO.cjs} +25 -8
  60. package/dist/{chunk-6SJ2KJTA.mjs → chunk-EPYU2EBL.mjs} +1 -1
  61. package/dist/{chunk-LBGILORX.mjs → chunk-GKBWWRBG.mjs} +101 -10
  62. package/dist/{chunk-PTZ2TVNE.cjs → chunk-H5CLOUZS.cjs} +5 -5
  63. package/dist/{chunk-DTSROJ5J.mjs → chunk-HD5CF3OE.mjs} +1 -1
  64. package/dist/{chunk-3A4KGQYI.cjs → chunk-HRETEZ2Z.cjs} +27 -15
  65. package/dist/{chunk-ATWHHSY2.cjs → chunk-HRSAQ23K.cjs} +7 -7
  66. package/dist/{chunk-IAIYV4RZ.mjs → chunk-HXRYZWTA.mjs} +1 -1
  67. package/dist/{chunk-4P6ULFMD.mjs → chunk-HYTZYOW2.mjs} +222 -103
  68. package/dist/{chunk-HMRSWN47.mjs → chunk-INL3THCU.mjs} +1 -1
  69. package/dist/{chunk-FBOJ55OM.mjs → chunk-IVLZZZEI.mjs} +1 -1
  70. package/dist/{chunk-ENLZ4R3Y.mjs → chunk-J7K2NZD6.mjs} +7 -6
  71. package/dist/{chunk-PMQHMWZU.cjs → chunk-JCYYXBAJ.cjs} +3 -3
  72. package/dist/{chunk-K3SAEIM3.mjs → chunk-KTSUBU2E.mjs} +2 -2
  73. package/dist/{chunk-LPFV45AY.cjs → chunk-LMPAPBUA.cjs} +19 -19
  74. package/dist/{chunk-EK4QAEFZ.cjs → chunk-LZESP4IR.cjs} +25 -0
  75. package/dist/{chunk-TW4GYDBJ.mjs → chunk-MLY2RP5R.mjs} +10 -2
  76. package/dist/{chunk-BHY547NB.cjs → chunk-NBBEQLOK.cjs} +9 -9
  77. package/dist/{chunk-WQ7T2263.mjs → chunk-OAHTRMIC.mjs} +3 -3
  78. package/dist/{chunk-HZFM2LWQ.mjs → chunk-P3PLW4FR.mjs} +34 -2
  79. package/dist/{chunk-UH6QN5NL.mjs → chunk-P664ZVTV.mjs} +2 -2
  80. package/dist/{chunk-TE2G5ION.cjs → chunk-PGZDEPTM.cjs} +88 -33
  81. package/dist/{chunk-3KGDJLJK.mjs → chunk-POSPE3IO.mjs} +19 -1
  82. package/dist/{chunk-FGRYBX5X.mjs → chunk-PVZE2JGJ.mjs} +2 -2
  83. package/dist/{chunk-TPLJVC7E.mjs → chunk-QFW2IH5E.mjs} +23 -6
  84. package/dist/{chunk-5BXGGEC7.cjs → chunk-QG775BRV.cjs} +17 -17
  85. package/dist/{chunk-S3VWVTVA.mjs → chunk-QRKIMN7T.mjs} +13 -1
  86. package/dist/chunk-QTXBII4Z.cjs +632 -0
  87. package/dist/{chunk-NQ6QFZWD.cjs → chunk-QUCXCDE2.cjs} +1 -1
  88. package/dist/{chunk-NFMDCAOS.mjs → chunk-QYMZOOC5.mjs} +3 -3
  89. package/dist/{chunk-CI6E3UOH.cjs → chunk-RG4A6LB2.cjs} +7 -7
  90. package/dist/{chunk-LOFKRKO7.cjs → chunk-RVXFINNS.cjs} +113 -22
  91. package/dist/{chunk-7SQ5SGYZ.cjs → chunk-RW63BOV7.cjs} +2 -2
  92. package/dist/{chunk-U6MPZ35Q.cjs → chunk-RWFLWR5J.cjs} +8 -8
  93. package/dist/{chunk-EUV4YR3V.cjs → chunk-SGBJ247Q.cjs} +18 -2
  94. package/dist/{chunk-J3ANCZKA.mjs → chunk-SKVTP5PR.mjs} +1 -1
  95. package/dist/{chunk-YCKO6FRS.mjs → chunk-SOP2EAA6.mjs} +1 -1
  96. package/dist/{chunk-ND2CWPOD.mjs → chunk-TS4JHGUJ.mjs} +1 -1
  97. package/dist/chunk-U6QLDL3G.mjs +576 -0
  98. package/dist/{chunk-OW67PDDS.cjs → chunk-ULASELLA.cjs} +13 -1
  99. package/dist/{chunk-4GWRFP22.cjs → chunk-UPJLHLJU.cjs} +35 -3
  100. package/dist/{chunk-WWIKMBRN.mjs → chunk-VNGH5MLF.mjs} +17 -1
  101. package/dist/{chunk-NNSAQX3U.mjs → chunk-VT4WFRHA.mjs} +1 -1
  102. package/dist/{chunk-JPNFPAZ4.mjs → chunk-VWBHM3F6.mjs} +2 -2
  103. package/dist/{chunk-ADOAUDQ6.cjs → chunk-VXEEATVD.cjs} +2 -2
  104. package/dist/{chunk-RRMVL6CJ.mjs → chunk-W36M2BQ4.mjs} +1 -1
  105. package/dist/{chunk-4WQ6PGSJ.cjs → chunk-WEW2JVA4.cjs} +4 -4
  106. package/dist/{chunk-4E5WBPEG.mjs → chunk-WFRT7JPX.mjs} +8 -533
  107. package/dist/{chunk-VXAWRDK7.mjs → chunk-WLL43JMO.mjs} +1 -1
  108. package/dist/chunk-WW46B6HA.cjs +318 -0
  109. package/dist/{chunk-D3C5LBQY.cjs → chunk-WXJLNP33.cjs} +2 -2
  110. package/dist/{chunk-NDILNQ4L.cjs → chunk-XKG2BLFN.cjs} +2 -2
  111. package/dist/{chunk-6TJITR2B.cjs → chunk-YFYUYWL7.cjs} +870 -751
  112. package/dist/{chunk-XOPOIFTJ.mjs → chunk-YKZRDB5Z.mjs} +25 -7
  113. package/dist/{chunk-K4I4O5TS.mjs → chunk-ZUPXLIGB.mjs} +790 -671
  114. package/dist/{chunk-G2TEB74S.cjs → chunk-ZXH4TS3F.cjs} +2 -2
  115. package/dist/{client-plugins-CV4eJ9De.d.mts → client-plugins-CsCuCLBz.d.mts} +58 -7
  116. package/dist/{client-plugins-C8DjftDF.d.ts → client-plugins-D0ke-Hc8.d.ts} +58 -7
  117. package/dist/client-plugins.d.mts +1 -1
  118. package/dist/client-plugins.d.ts +1 -1
  119. package/dist/client.cjs +7 -7
  120. package/dist/client.d.mts +5 -5
  121. package/dist/client.d.ts +5 -5
  122. package/dist/client.mjs +6 -6
  123. package/dist/config.d.mts +1 -1
  124. package/dist/config.d.ts +1 -1
  125. package/dist/{devtools-KVOY2TCZ.mjs → devtools-5AFIPVUJ.mjs} +8 -6
  126. package/dist/{devtools-JXFQNWSH.cjs → devtools-LW4QQ5J3.cjs} +9 -7
  127. package/dist/docs.cjs +12 -10
  128. package/dist/docs.d.mts +20 -2
  129. package/dist/docs.d.ts +20 -2
  130. package/dist/docs.mjs +11 -9
  131. package/dist/headers.cjs +6 -4
  132. package/dist/headers.d.mts +11 -1
  133. package/dist/headers.d.ts +11 -1
  134. package/dist/headers.mjs +5 -3
  135. package/dist/index.cjs +55 -42
  136. package/dist/index.d.mts +15 -15
  137. package/dist/index.d.ts +15 -15
  138. package/dist/index.mjs +55 -42
  139. package/dist/integrations.cjs +5 -3
  140. package/dist/integrations.d.mts +1 -1
  141. package/dist/integrations.d.ts +1 -1
  142. package/dist/integrations.mjs +4 -2
  143. package/dist/internal/app-markdown-runtime.cjs +3 -3
  144. package/dist/internal/app-markdown-runtime.d.mts +2 -2
  145. package/dist/internal/app-markdown-runtime.d.ts +2 -2
  146. package/dist/internal/app-markdown-runtime.mjs +2 -2
  147. package/dist/internal/build-runtime.cjs +30 -29
  148. package/dist/internal/build-runtime.d.mts +3 -3
  149. package/dist/internal/build-runtime.d.ts +3 -3
  150. package/dist/internal/build-runtime.mjs +29 -28
  151. package/dist/internal/cli-runtime.cjs +11 -9
  152. package/dist/internal/cli-runtime.mjs +10 -8
  153. package/dist/internal/client-error-overlay.cjs +4 -4
  154. package/dist/internal/client-error-overlay.mjs +1 -1
  155. package/dist/internal/compression-runtime.d.mts +1 -1
  156. package/dist/internal/compression-runtime.d.ts +1 -1
  157. package/dist/internal/config-runtime.cjs +9 -7
  158. package/dist/internal/config-runtime.d.mts +2 -2
  159. package/dist/internal/config-runtime.d.ts +2 -2
  160. package/dist/internal/config-runtime.mjs +8 -6
  161. package/dist/internal/docs-precompiled-runtime.cjs +19 -13
  162. package/dist/internal/docs-precompiled-runtime.d.mts +5 -0
  163. package/dist/internal/docs-precompiled-runtime.d.ts +5 -0
  164. package/dist/internal/docs-precompiled-runtime.mjs +14 -8
  165. package/dist/internal/infra-analytics-runtime.cjs +5 -5
  166. package/dist/internal/infra-analytics-runtime.mjs +3 -3
  167. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  168. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  169. package/dist/internal/production-node-env.cjs +6 -2
  170. package/dist/internal/production-node-env.d.mts +10 -1
  171. package/dist/internal/production-node-env.d.ts +10 -1
  172. package/dist/internal/production-node-env.mjs +5 -1
  173. package/dist/internal/production-runtime.cjs +38 -16
  174. package/dist/internal/production-runtime.d.mts +51 -11
  175. package/dist/internal/production-runtime.d.ts +51 -11
  176. package/dist/internal/production-runtime.mjs +40 -18
  177. package/dist/markdown.cjs +8 -2
  178. package/dist/markdown.d.mts +1 -1
  179. package/dist/markdown.d.ts +1 -1
  180. package/dist/markdown.mjs +7 -1
  181. package/dist/middleware.cjs +10 -8
  182. package/dist/middleware.d.mts +24 -4
  183. package/dist/middleware.d.ts +24 -4
  184. package/dist/middleware.mjs +10 -8
  185. package/dist/navigation.cjs +6 -6
  186. package/dist/navigation.d.mts +4 -4
  187. package/dist/navigation.d.ts +4 -4
  188. package/dist/navigation.mjs +5 -5
  189. package/dist/plugin.cjs +23 -22
  190. package/dist/plugin.d.mts +1 -1
  191. package/dist/plugin.d.ts +1 -1
  192. package/dist/plugin.mjs +22 -21
  193. package/dist/{production-runtime-C2kkrPVZ.d.ts → production-runtime-BaI3WHnV.d.ts} +1 -1
  194. package/dist/{production-runtime-Du_FHb2-.d.mts → production-runtime-DfRP0cV0.d.mts} +1 -1
  195. package/dist/query/client.cjs +8 -8
  196. package/dist/query/client.mjs +3 -3
  197. package/dist/{render-plan-BnnPTpus.d.ts → render-plan-CfIdJKAf.d.ts} +1 -1
  198. package/dist/{render-plan-Cgx7v8tJ.d.mts → render-plan-Dg8RBYFa.d.mts} +1 -1
  199. package/dist/renderer-client.cjs +5 -5
  200. package/dist/renderer-client.d.mts +3 -3
  201. package/dist/renderer-client.d.ts +3 -3
  202. package/dist/renderer-client.mjs +2 -2
  203. package/dist/renderer.d.mts +13 -4
  204. package/dist/renderer.d.ts +13 -4
  205. package/dist/{request-BNWr7r5e.d.ts → request-CEbHIIl4.d.ts} +4 -2
  206. package/dist/{request-sKayKcop.d.mts → request-DfE02G_A.d.mts} +4 -2
  207. package/dist/request.cjs +3 -3
  208. package/dist/request.d.mts +2 -2
  209. package/dist/request.d.ts +2 -2
  210. package/dist/request.mjs +2 -2
  211. package/dist/{route-rendering-DWFp3Yq4.d.mts → route-rendering-BHyOfXjD.d.mts} +1 -1
  212. package/dist/{route-rendering-Bx4Auw6Q.d.ts → route-rendering-C4oHbv6C.d.ts} +1 -1
  213. package/dist/{router-BK6K42Ij.d.mts → router-DwhA61SB.d.mts} +1 -1
  214. package/dist/{router-DnW_2tQi.d.ts → router-uRN_29Em.d.ts} +1 -1
  215. package/dist/routes.d.mts +1 -1
  216. package/dist/routes.d.ts +1 -1
  217. package/dist/{runtime-DJDaCMd_.d.mts → runtime-BEdHhN4C.d.mts} +1 -1
  218. package/dist/{runtime-CA3Ei5k_.d.ts → runtime-COk03hmx.d.ts} +1 -1
  219. package/dist/server-fn.cjs +3 -3
  220. package/dist/server-fn.mjs +2 -2
  221. package/dist/server-plugins.cjs +5 -5
  222. package/dist/server-plugins.d.mts +2 -2
  223. package/dist/server-plugins.d.ts +2 -2
  224. package/dist/server-plugins.mjs +4 -4
  225. package/dist/server-query.cjs +4 -4
  226. package/dist/server-query.mjs +3 -3
  227. package/dist/server.cjs +49 -48
  228. package/dist/server.d.mts +7 -7
  229. package/dist/server.d.ts +7 -7
  230. package/dist/server.mjs +27 -26
  231. package/dist/{spa-router-Mwbd7g2L.d.ts → spa-router-DrVOBVGg.d.ts} +2 -2
  232. package/dist/{spa-router-D6fUA4Rn.d.mts → spa-router-w4aFOuyn.d.mts} +2 -2
  233. package/dist/testing.cjs +5 -5
  234. package/dist/testing.d.mts +1 -1
  235. package/dist/testing.d.ts +1 -1
  236. package/dist/testing.mjs +4 -4
  237. package/dist/theme/server.cjs +4 -4
  238. package/dist/theme/server.mjs +3 -3
  239. package/dist/{utils-p9Hs-jCc.d.mts → utils-BtYehqeU.d.mts} +1 -1
  240. package/dist/{utils-BwVcAfUR.d.ts → utils-Dhuqwmd2.d.ts} +1 -1
  241. package/dist/version.cjs +2 -2
  242. package/dist/version.mjs +1 -1
  243. package/dist/vite.cjs +23 -22
  244. package/dist/vite.d.mts +1 -1
  245. package/dist/vite.d.ts +1 -1
  246. package/dist/vite.mjs +22 -21
  247. package/package.json +1 -1
  248. package/dist/chunk-655RLQQL.mjs +0 -43
  249. package/dist/chunk-MRMI32SN.cjs +0 -1157
  250. package/dist/chunk-MT763TDW.cjs +0 -43
@@ -0,0 +1,318 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-LPEX4YW6.mjs";
4
+
5
+ // src/nitro/node-server-entry.ts
6
+ var FARM_NODE_ENV_MODULE_FILE = "farm-node-env.mjs";
7
+ var FARM_NODE_ENV_MODULE_SOURCE = `if (!process.env.NODE_ENV) process.env.NODE_ENV = "production";
8
+ `;
9
+ function createFarmNodeServerEntry(options) {
10
+ const serverConfig = JSON.stringify(options.server);
11
+ const nitroEntryImport = `./${options.nitroEntryFile.replace(/^\.\//, "")}`;
12
+ return `
13
+ import "./${FARM_NODE_ENV_MODULE_FILE}";
14
+ import "#nitro/virtual/polyfills";
15
+ import { NodeRequest, serve } from ${JSON.stringify(options.nodeAdapterModule)};
16
+ import wsAdapter from ${JSON.stringify(options.websocketAdapterModule)};
17
+ import { resolveWebsocketHooks, useNitroApp, useNitroHooks } from "#nitro/runtime/app";
18
+ import { useRuntimeConfig } from "#nitro/runtime/runtime-config";
19
+ import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
20
+ import { setupCloseHooks } from "#nitro/runtime/shutdown";
21
+ import { startScheduleRunner } from "#nitro/runtime/task";
22
+ import { tracingSrvxPlugins } from "#nitro/virtual/tracing";
23
+ import { farmProductionLifecycle } from ${JSON.stringify(nitroEntryImport)};
24
+
25
+ const farmServerConfig = ${serverConfig};
26
+ if (!process.env.NITRO_SHUTDOWN_TIMEOUT) {
27
+ process.env.NITRO_SHUTDOWN_TIMEOUT = String(farmServerConfig.gracefulShutdownTimeout);
28
+ }
29
+ const shutdownConfig = {
30
+ disabled: Boolean(process.env.NITRO_SHUTDOWN_DISABLED),
31
+ signals: (process.env.NITRO_SHUTDOWN_SIGNALS || "SIGTERM SIGINT")
32
+ .split(" ")
33
+ .map((signal) => signal.trim())
34
+ .filter(Boolean),
35
+ timeout: Number.parseInt(process.env.NITRO_SHUTDOWN_TIMEOUT || "", 10) || 30000,
36
+ forceExit: !process.env.NITRO_SHUTDOWN_NO_FORCE_EXIT,
37
+ };
38
+
39
+ const nitroApp = useNitroApp();
40
+ useNitroHooks().hook("close", async () => {
41
+ try {
42
+ await farmProductionLifecycle.close("production-server-closed");
43
+ } catch (error) {
44
+ process.exitCode = 1;
45
+ throw error;
46
+ }
47
+ });
48
+
49
+ let startupSignal;
50
+ let resolveStartupSignal;
51
+ const startupSignalPromise = new Promise((resolve) => {
52
+ resolveStartupSignal = resolve;
53
+ });
54
+ const startupSignalListeners = new Map();
55
+ if (!shutdownConfig.disabled) {
56
+ for (const signal of shutdownConfig.signals) {
57
+ const listener = (receivedSignal) => {
58
+ if (!startupSignal) {
59
+ startupSignal = receivedSignal;
60
+ resolveStartupSignal(receivedSignal);
61
+ }
62
+ farmProductionLifecycle.beginDrain(receivedSignal);
63
+ };
64
+ startupSignalListeners.set(signal, listener);
65
+ process.once(signal, listener);
66
+ }
67
+ }
68
+
69
+ try {
70
+ await Promise.race([
71
+ Promise.resolve().then(() => farmProductionLifecycle.start()),
72
+ startupSignalPromise,
73
+ ]);
74
+ } catch (error) {
75
+ await farmProductionLifecycle.close("production-start-failed").catch((closeError) => {
76
+ console.error("[Farm] Runtime cleanup after startup failure failed:", closeError);
77
+ });
78
+ throw error;
79
+ } finally {
80
+ for (const [signal, listener] of startupSignalListeners) {
81
+ process.removeListener(signal, listener);
82
+ }
83
+ }
84
+
85
+ if (startupSignal) {
86
+ let startupCloseTimer;
87
+ const startupCloseCompleted = await Promise.race([
88
+ Promise.resolve()
89
+ .then(() => farmProductionLifecycle.close(startupSignal))
90
+ .then(
91
+ () => true,
92
+ (error) => {
93
+ console.error("[Farm] Runtime shutdown during startup failed:", error);
94
+ process.exitCode = 1;
95
+ return true;
96
+ },
97
+ ),
98
+ new Promise((resolve) => {
99
+ startupCloseTimer = setTimeout(() => resolve(false), farmServerConfig.gracefulShutdownTimeout);
100
+ }),
101
+ ]);
102
+ clearTimeout(startupCloseTimer);
103
+ if (!startupCloseCompleted) {
104
+ console.warn("[Farm] Runtime startup did not settle before shutdown; forcing cleanup");
105
+ let forcedCloseTimer;
106
+ const forcedCloseCompleted = await Promise.race([
107
+ Promise.resolve()
108
+ .then(() => farmProductionLifecycle.forceClose(startupSignal))
109
+ .then(
110
+ () => true,
111
+ (error) => {
112
+ console.error("[Farm] Forced runtime shutdown during startup failed:", error);
113
+ process.exitCode = 1;
114
+ return true;
115
+ },
116
+ ),
117
+ new Promise((resolve) => {
118
+ forcedCloseTimer = setTimeout(
119
+ () => resolve(false),
120
+ farmServerConfig.gracefulShutdownTimeout,
121
+ );
122
+ }),
123
+ ]);
124
+ clearTimeout(forcedCloseTimer);
125
+ if (!forcedCloseCompleted) {
126
+ console.error("[Farm] Forced runtime shutdown during startup timed out");
127
+ process.exitCode = 1;
128
+ }
129
+ }
130
+ process.exit(process.exitCode || 0);
131
+ }
132
+
133
+ const cert = process.env.NITRO_SSL_CERT;
134
+ const key = process.env.NITRO_SSL_KEY;
135
+ const configuredPort = Number(process.env.NITRO_PORT || process.env.PORT);
136
+ const port = Number.isFinite(configuredPort) && configuredPort > 0 ? configuredPort : 3000;
137
+ const host = process.env.NITRO_HOST || process.env.HOST;
138
+ const socketPath = process.env.NITRO_UNIX_SOCKET;
139
+ const server = serve({
140
+ manual: true,
141
+ silent: true,
142
+ gracefulShutdown: false,
143
+ port,
144
+ hostname: host,
145
+ node: socketPath ? { path: socketPath } : undefined,
146
+ tls: cert && key ? { cert, key } : undefined,
147
+ fetch: nitroApp.fetch,
148
+ plugins: [...tracingSrvxPlugins],
149
+ });
150
+ const nodeServer = server.node?.server;
151
+ if (!nodeServer) throw new Error("[Farm] Nitro did not create a Node server");
152
+
153
+ nodeServer.headersTimeout = farmServerConfig.headersTimeout;
154
+ nodeServer.requestTimeout = farmServerConfig.requestTimeout;
155
+ nodeServer.keepAliveTimeout = farmServerConfig.keepAliveTimeout;
156
+
157
+ let isShuttingDown = false;
158
+ nodeServer.on("request", (_request, response) => {
159
+ response.once("finish", () => {
160
+ if (isShuttingDown) nodeServer.closeIdleConnections?.();
161
+ });
162
+ });
163
+
164
+ if (import.meta._websocket) {
165
+ const { handleUpgrade } = wsAdapter({ resolve: resolveWebsocketHooks });
166
+ nodeServer.on("upgrade", (request, socket, head) => {
167
+ handleUpgrade(
168
+ request,
169
+ socket,
170
+ head,
171
+ new NodeRequest({ req: request, upgrade: { socket, head } }),
172
+ );
173
+ });
174
+ }
175
+
176
+ setupCloseHooks(server);
177
+ trapUnhandledErrors();
178
+
179
+ let shutdownPromise;
180
+ async function shutdown(signal) {
181
+ isShuttingDown = true;
182
+ farmProductionLifecycle.beginDrain(signal);
183
+
184
+ const gracefulClose = server.close().then(
185
+ () => true,
186
+ (error) => {
187
+ console.error("[Farm] Runtime shutdown failed:", error);
188
+ process.exitCode = 1;
189
+ return true;
190
+ },
191
+ );
192
+ nodeServer.closeIdleConnections?.();
193
+ let gracefulTimer;
194
+ const gracefullyClosed = await Promise.race([
195
+ gracefulClose,
196
+ new Promise((resolve) => {
197
+ gracefulTimer = setTimeout(() => resolve(false), shutdownConfig.timeout);
198
+ }),
199
+ ]);
200
+ clearTimeout(gracefulTimer);
201
+
202
+ if (!gracefullyClosed) {
203
+ console.warn("[Farm] Graceful shutdown timed out; forcing cleanup");
204
+ void server.close(true).catch((error) => {
205
+ console.error("[Farm] Forced server shutdown failed:", error);
206
+ process.exitCode = 1;
207
+ });
208
+
209
+ let forceTimer;
210
+ const forceClosed = await Promise.race([
211
+ Promise.resolve()
212
+ .then(() => farmProductionLifecycle.forceClose("production-server-closed"))
213
+ .then(
214
+ () => true,
215
+ (error) => {
216
+ console.error("[Farm] Forced runtime shutdown failed:", error);
217
+ process.exitCode = 1;
218
+ return true;
219
+ },
220
+ ),
221
+ new Promise((resolve) => {
222
+ forceTimer = setTimeout(() => resolve(false), shutdownConfig.timeout);
223
+ }),
224
+ ]);
225
+ clearTimeout(forceTimer);
226
+ if (!forceClosed) {
227
+ console.error("[Farm] Forced runtime shutdown timed out");
228
+ process.exitCode = 1;
229
+ }
230
+ }
231
+
232
+ if (shutdownConfig.forceExit) process.exit(process.exitCode || 0);
233
+ }
234
+
235
+ if (!shutdownConfig.disabled) {
236
+ for (const signal of shutdownConfig.signals) {
237
+ process.once(signal, (receivedSignal) => {
238
+ shutdownPromise ||= shutdown(receivedSignal);
239
+ });
240
+ }
241
+ }
242
+
243
+ try {
244
+ await server.serve();
245
+ const protocol = cert && key ? "https" : "http";
246
+ const addressInfo = nodeServer.address();
247
+ if (typeof addressInfo === "string") {
248
+ console.log(\`Listening on unix socket \${addressInfo}\`);
249
+ } else if (addressInfo) {
250
+ const configuredBaseURL = useRuntimeConfig().app.baseURL || "";
251
+ const baseURL = configuredBaseURL.endsWith("/")
252
+ ? configuredBaseURL.slice(0, -1)
253
+ : configuredBaseURL;
254
+ const address = addressInfo.family === "IPv6"
255
+ ? \`[\${addressInfo.address}]\`
256
+ : addressInfo.address;
257
+ console.log(\`Listening on \${protocol}://\${address}:\${addressInfo.port}\${baseURL}\`);
258
+ }
259
+ } catch (error) {
260
+ console.error(error);
261
+ process.exitCode = 1;
262
+ await farmProductionLifecycle.close("production-listen-error").catch((closeError) => {
263
+ console.error("[Farm] Runtime cleanup after listen failure failed:", closeError);
264
+ });
265
+ throw error;
266
+ }
267
+
268
+ if (import.meta._tasks) {
269
+ startScheduleRunner({ waitUntil: server.waitUntil });
270
+ }
271
+
272
+ export default {};
273
+ `.trim();
274
+ }
275
+ __name(createFarmNodeServerEntry, "createFarmNodeServerEntry");
276
+
277
+ // src/build/production-node-env.ts
278
+ var productionNodeEnvStateKey = /* @__PURE__ */ Symbol.for("@farm.js/core/production-node-env-state");
279
+ function getProductionNodeEnvState() {
280
+ return Reflect.get(globalThis, productionNodeEnvStateKey);
281
+ }
282
+ __name(getProductionNodeEnvState, "getProductionNodeEnvState");
283
+ async function withProductionNodeEnv(operation) {
284
+ let state = getProductionNodeEnvState();
285
+ if (state) {
286
+ state.depth += 1;
287
+ } else {
288
+ state = {
289
+ depth: 1,
290
+ original: process.env.NODE_ENV
291
+ };
292
+ Reflect.set(globalThis, productionNodeEnvStateKey, state);
293
+ }
294
+ process.env.NODE_ENV = "production";
295
+ try {
296
+ return await operation();
297
+ } finally {
298
+ state.depth -= 1;
299
+ if (state.depth > 0) {
300
+ process.env.NODE_ENV = "production";
301
+ } else {
302
+ Reflect.deleteProperty(globalThis, productionNodeEnvStateKey);
303
+ if (state.original === void 0) {
304
+ delete process.env.NODE_ENV;
305
+ } else {
306
+ process.env.NODE_ENV = state.original;
307
+ }
308
+ }
309
+ }
310
+ }
311
+ __name(withProductionNodeEnv, "withProductionNodeEnv");
312
+
313
+ export {
314
+ FARM_NODE_ENV_MODULE_FILE,
315
+ FARM_NODE_ENV_MODULE_SOURCE,
316
+ createFarmNodeServerEntry,
317
+ withProductionNodeEnv
318
+ };
@@ -34,7 +34,7 @@ import {
34
34
  } from "./chunk-4SIYUGRY.mjs";
35
35
  import {
36
36
  _runWithCurrentRequest
37
- } from "./chunk-3KGDJLJK.mjs";
37
+ } from "./chunk-POSPE3IO.mjs";
38
38
  import {
39
39
  __name
40
40
  } from "./chunk-LPEX4YW6.mjs";
@@ -1,7 +1,8 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
3
 
4
- var _chunkOW67PDDScjs = require('./chunk-OW67PDDS.cjs');
4
+
5
+ var _chunkULASELLAcjs = require('./chunk-ULASELLA.cjs');
5
6
 
6
7
 
7
8
  var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
@@ -66,8 +67,24 @@ function getAppRequestView(request) {
66
67
  return view;
67
68
  }
68
69
  _chunkS3JO3N4Hcjs.__name.call(void 0, getAppRequestView, "getAppRequestView");
69
- _chunkOW67PDDScjs._setCurrentRequestResolver.call(void 0, () => requestStore.getStore());
70
- _chunkOW67PDDScjs._setAppRequestView.call(void 0, getAppRequestView);
70
+ _chunkULASELLAcjs._setCurrentRequestResolver.call(void 0, () => requestStore.getStore());
71
+ var CSP_NONCE_STORAGE_KEY = /* @__PURE__ */ Symbol.for("@farm.js/core/csp-nonce-storage");
72
+ function getCspNonceStore() {
73
+ const runtime = globalThis;
74
+ const existing = runtime[CSP_NONCE_STORAGE_KEY];
75
+ if (existing instanceof _async_hooks.AsyncLocalStorage) return existing;
76
+ const storage = new (0, _async_hooks.AsyncLocalStorage)();
77
+ runtime[CSP_NONCE_STORAGE_KEY] = storage;
78
+ return storage;
79
+ }
80
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getCspNonceStore, "getCspNonceStore");
81
+ var cspNonceStore = getCspNonceStore();
82
+ _chunkULASELLAcjs._setCspNonceResolver.call(void 0, () => cspNonceStore.getStore());
83
+ function _runWithFarmCspNonce(nonce, fn) {
84
+ return nonce ? cspNonceStore.run(nonce, fn) : fn();
85
+ }
86
+ _chunkS3JO3N4Hcjs.__name.call(void 0, _runWithFarmCspNonce, "_runWithFarmCspNonce");
87
+ _chunkULASELLAcjs._setAppRequestView.call(void 0, getAppRequestView);
71
88
  function resolveFarmRequestURL(req, options = {}) {
72
89
  if (options.origin) {
73
90
  return new URL(req.url || "/", options.origin);
@@ -176,4 +193,5 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, getCurrentRequestOrNull, "getCurrentReques
176
193
 
177
194
 
178
195
 
179
- exports.resolveFarmRequestURL = resolveFarmRequestURL; exports.resolveFarmWebRequestOrigin = resolveFarmWebRequestOrigin; exports.createWebRequestFromFarmRequest = createWebRequestFromFarmRequest; exports._runWithCurrentRequest = _runWithCurrentRequest; exports.getCurrentRequest = getCurrentRequest; exports._getRequestReadCount = _getRequestReadCount; exports.getCurrentRequestOrNull = getCurrentRequestOrNull;
196
+
197
+ exports._runWithFarmCspNonce = _runWithFarmCspNonce; exports.resolveFarmRequestURL = resolveFarmRequestURL; exports.resolveFarmWebRequestOrigin = resolveFarmWebRequestOrigin; exports.createWebRequestFromFarmRequest = createWebRequestFromFarmRequest; exports._runWithCurrentRequest = _runWithCurrentRequest; exports.getCurrentRequest = getCurrentRequest; exports._getRequestReadCount = _getRequestReadCount; exports.getCurrentRequestOrNull = getCurrentRequestOrNull;
@@ -304,6 +304,13 @@ function appendOpenGraph(tags, input, metadataBase, page) {
304
304
  appendMetaProperty(tags, "og:image:alt", image.alt);
305
305
  appendMetaProperty(tags, "og:image:type", image.type);
306
306
  }
307
+ for (const video of normalizeMetadataVideos(openGraph.videos, metadataBase)) {
308
+ appendMetaProperty(tags, "og:video", video.url);
309
+ appendMetaProperty(tags, "og:video:secure_url", video.secureUrl);
310
+ appendMetaProperty(tags, "og:video:type", video.type);
311
+ appendMetaProperty(tags, "og:video:width", video.width);
312
+ appendMetaProperty(tags, "og:video:height", video.height);
313
+ }
307
314
  if (openGraph.type === "article") {
308
315
  appendMetaProperty(tags, "article:published_time", normalizeDate(openGraph.publishedTime));
309
316
  appendMetaProperty(tags, "article:modified_time", normalizeDate(openGraph.modifiedTime));
@@ -432,6 +439,24 @@ function normalizeMetadataImages(value, metadataBase) {
432
439
  }).filter((item) => item !== null);
433
440
  }
434
441
  __name(normalizeMetadataImages, "normalizeMetadataImages");
442
+ function normalizeMetadataVideos(value, metadataBase) {
443
+ return normalizeArray(value).map((item) => {
444
+ if (typeof item === "string") {
445
+ return { url: resolveMetadataUrl(item, metadataBase) || item };
446
+ }
447
+ if (!isRecord(item)) return null;
448
+ const url = resolveMetadataUrl(item.url, metadataBase);
449
+ if (!url) return null;
450
+ return {
451
+ url,
452
+ secureUrl: resolveMetadataUrl(item.secureUrl, metadataBase) || void 0,
453
+ width: normalizeNumber(item.width),
454
+ height: normalizeNumber(item.height),
455
+ type: typeof item.type === "string" ? item.type : void 0
456
+ };
457
+ }).filter((item) => item !== null);
458
+ }
459
+ __name(normalizeMetadataVideos, "normalizeMetadataVideos");
435
460
  function normalizeArray(value) {
436
461
  if (value == null) return [];
437
462
  return Array.isArray(value) ? value : [value];
@@ -22,17 +22,19 @@ import {
22
22
  resolveFarmRenderer
23
23
  } from "./chunk-DAATZTKJ.mjs";
24
24
  import {
25
- farmCspBlocksFrameworkInlineScripts,
26
- getFarmSecurityHeader,
27
25
  resolveFarmAgentCrawlers,
28
26
  resolveFarmAgentSitemap,
29
27
  resolveFarmNoindexPreviews,
30
- resolveFarmPerformanceConfig,
31
- resolveFarmSecurityConfig
32
- } from "./chunk-4E5WBPEG.mjs";
28
+ resolveFarmPerformanceConfig
29
+ } from "./chunk-WFRT7JPX.mjs";
33
30
  import {
34
31
  resolveFarmLlmsTxtConfig
35
- } from "./chunk-DTSROJ5J.mjs";
32
+ } from "./chunk-HD5CF3OE.mjs";
33
+ import {
34
+ farmCspBlocksFrameworkInlineScripts,
35
+ getFarmSecurityHeader,
36
+ resolveFarmSecurityConfig
37
+ } from "./chunk-U6QLDL3G.mjs";
36
38
  import {
37
39
  resolveFarmImageConfig
38
40
  } from "./chunk-G2KY33I6.mjs";
@@ -51,7 +53,7 @@ import {
51
53
  } from "./chunk-FA2W42OV.mjs";
52
54
  import {
53
55
  resolveMarkdownConfig
54
- } from "./chunk-WWIKMBRN.mjs";
56
+ } from "./chunk-VNGH5MLF.mjs";
55
57
  import {
56
58
  bundleNodeModule
57
59
  } from "./chunk-SFGWNC43.mjs";
@@ -63,7 +65,10 @@ import {
63
65
  } from "./chunk-AELACLOB.mjs";
64
66
  import {
65
67
  resolveIntegrationPlugins
66
- } from "./chunk-Z5BEWYVO.mjs";
68
+ } from "./chunk-ATSDUUFK.mjs";
69
+ import {
70
+ compileMiddlewareConfig
71
+ } from "./chunk-P3PLW4FR.mjs";
67
72
  import {
68
73
  resolveFarmServerConfig
69
74
  } from "./chunk-ZMMBIVQM.mjs";
@@ -657,6 +662,13 @@ function validateRedirectConfigs(redirects, field) {
657
662
  return redirects;
658
663
  }
659
664
  __name(validateRedirectConfigs, "validateRedirectConfigs");
665
+ function validateMiddlewareConfig(middleware) {
666
+ for (const entry of Array.isArray(middleware) ? middleware : middleware ? [middleware] : []) {
667
+ compileMiddlewareConfig({ matcher: entry.matcher, exclude: entry.exclude });
668
+ }
669
+ return middleware;
670
+ }
671
+ __name(validateMiddlewareConfig, "validateMiddlewareConfig");
660
672
  function validateConfigRouteSources(routes, field) {
661
673
  for (const [index, route] of routes.entries()) {
662
674
  validateConfigRouteSource(route.source, `${field}[${index}].source`);
@@ -805,7 +817,7 @@ async function resolveConfig(userConfig, mode) {
805
817
  publicDir: userConfig.publicDir || "public",
806
818
  i18n: resolveFarmI18nConfig(userConfig.i18n, { root, mode, basePath }),
807
819
  openapi,
808
- middleware: userConfig.middleware || {},
820
+ middleware: validateMiddlewareConfig(userConfig.middleware) || {},
809
821
  notFound: userConfig.notFound || {},
810
822
  context: userConfig.context || (() => void 0),
811
823
  server: resolveFarmServerConfig(userConfig.server),
@@ -27,7 +27,7 @@ var _chunkE2ROOWQCcjs = require('./chunk-E2ROOWQC.cjs');
27
27
  var _chunkJSROZYYOcjs = require('./chunk-JSROZYYO.cjs');
28
28
 
29
29
 
30
- var _chunkUJZLSXUBcjs = require('./chunk-UJZLSXUB.cjs');
30
+ var _chunkBWIQR4DHcjs = require('./chunk-BWIQR4DH.cjs');
31
31
 
32
32
 
33
33
  var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
@@ -119,7 +119,7 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, withTimeout, "withTimeout");
119
119
  var formatSeconds = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (ms) => ms < 1e3 ? `${ms}ms` : `${Number((ms / 1e3).toFixed(1))}s`, "formatSeconds");
120
120
  function collectSchemaOwners(config) {
121
121
  const owners = [];
122
- const integrationSchemas = _chunkUJZLSXUBcjs.getIntegrationSchemas.call(void 0, config.integrations);
122
+ const integrationSchemas = _chunkBWIQR4DHcjs.getIntegrationSchemas.call(void 0, config.integrations);
123
123
  let integrationClient;
124
124
  for (const [name, schema] of Object.entries(integrationSchemas)) {
125
125
  owners.push({
@@ -34,7 +34,7 @@ import {
34
34
  } from "./chunk-4SIYUGRY.mjs";
35
35
  import {
36
36
  _resolveCurrentRequest
37
- } from "./chunk-S3VWVTVA.mjs";
37
+ } from "./chunk-QRKIMN7T.mjs";
38
38
  import {
39
39
  __name
40
40
  } from "./chunk-LPEX4YW6.mjs";