@farm.js/core 0.1.31 → 0.1.34
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.
- package/README.md +1 -1
- package/dist/agent-runtime.cjs +69 -14
- package/dist/agent-runtime.d.mts +1 -1
- package/dist/agent-runtime.d.ts +1 -1
- package/dist/agent-runtime.mjs +58 -3
- package/dist/api/route-manager.cjs +16 -13
- package/dist/api/route-manager.d.mts +1 -1
- package/dist/api/route-manager.d.ts +1 -1
- package/dist/api/route-manager.mjs +15 -12
- package/dist/api/runtime.cjs +9 -7
- package/dist/api/runtime.d.mts +1 -1
- package/dist/api/runtime.d.ts +1 -1
- package/dist/api/runtime.mjs +8 -6
- package/dist/api.cjs +19 -16
- package/dist/api.d.mts +2 -2
- package/dist/api.d.ts +2 -2
- package/dist/api.mjs +18 -15
- package/dist/{app-sUJ3jnTZ.d.ts → app-DgotYGbq.d.ts} +3 -3
- package/dist/app-markdown.cjs +8 -6
- package/dist/app-markdown.d.mts +3 -3
- package/dist/app-markdown.d.ts +3 -3
- package/dist/app-markdown.mjs +7 -5
- package/dist/{app-DAuUTIZf.d.mts → app-q4rmZlXK.d.mts} +3 -3
- package/dist/cache.cjs +2 -2
- package/dist/cache.d.mts +10 -1
- package/dist/cache.d.ts +10 -1
- package/dist/cache.mjs +1 -1
- package/dist/{chunk-YZTASLPQ.cjs → chunk-27ZWSI3W.cjs} +2 -2
- package/dist/{chunk-WBIH66JK.mjs → chunk-2ELDTQRN.mjs} +5 -2
- package/dist/{chunk-K7CELQLK.cjs → chunk-2F2ER724.cjs} +54 -29
- package/dist/{chunk-NRVGEI5I.mjs → chunk-2NNMOPDN.mjs} +4 -210
- package/dist/chunk-2NQQ5H5G.cjs +86 -0
- package/dist/{chunk-IFI5FXEZ.cjs → chunk-36MK5YCW.cjs} +334 -163
- package/dist/chunk-3BU22U3M.cjs +237 -0
- package/dist/{chunk-MM5D6VLP.mjs → chunk-3KZS4SUS.mjs} +33 -14
- package/dist/chunk-3SDFA7UF.cjs +701 -0
- package/dist/{chunk-4IEPYMHF.mjs → chunk-3UEVPCGW.mjs} +1 -1
- package/dist/{chunk-5LJCOSKT.mjs → chunk-3VSKDFAT.mjs} +1 -1
- package/dist/{chunk-5HGR3W6O.mjs → chunk-5SJWVY6R.mjs} +8 -0
- package/dist/{chunk-X7WVQMIB.mjs → chunk-657WJNRY.mjs} +10 -4
- package/dist/{chunk-MKMBQSNQ.mjs → chunk-6VVL3MHY.mjs} +3 -3
- package/dist/{chunk-QZRVZSPN.cjs → chunk-77GNHH2Z.cjs} +3 -3
- package/dist/{chunk-KZLND3D2.cjs → chunk-7BT4H4P7.cjs} +7 -5
- package/dist/{chunk-A777V5WU.cjs → chunk-7M52YUMY.cjs} +2 -2
- package/dist/{chunk-VUMAE7NC.mjs → chunk-7Y6ZNFPX.mjs} +81 -30
- package/dist/{chunk-MXDTKXO6.cjs → chunk-A5FGU2WU.cjs} +74 -23
- package/dist/{chunk-7QOCTYBS.mjs → chunk-AGC75XAE.mjs} +37 -1
- package/dist/{chunk-4ZQQL4IU.mjs → chunk-AHGECQEW.mjs} +1 -1
- package/dist/{chunk-RG3ZOTG5.cjs → chunk-AI7QMY7O.cjs} +10 -3
- package/dist/{chunk-O3DTUAX2.mjs → chunk-AQZFOP7S.mjs} +6 -77
- package/dist/{chunk-WNLBF77X.cjs → chunk-ATK2R4CH.cjs} +14 -12
- package/dist/{chunk-SORB3MAR.cjs → chunk-AWC4VUZL.cjs} +17 -17
- package/dist/{chunk-YMCXWPWK.mjs → chunk-BCMSYSN2.mjs} +4 -1
- package/dist/{chunk-FYRBX5IY.cjs → chunk-BTAG7LI7.cjs} +2 -2
- package/dist/{chunk-I6XDAKWQ.mjs → chunk-BTHHUD7Q.mjs} +14 -0
- package/dist/chunk-C4SPBWFM.cjs +26 -0
- package/dist/{chunk-JATSG2ZO.mjs → chunk-CLJYVZAD.mjs} +4 -2
- package/dist/{chunk-J3LOGE4T.cjs → chunk-DQQOKWYA.cjs} +5 -5
- package/dist/{chunk-JLRDISQL.cjs → chunk-DZ4DTRJ5.cjs} +7 -7
- package/dist/chunk-E5GNDG5F.mjs +701 -0
- package/dist/{chunk-E76XC6ZG.mjs → chunk-EZDQRNQ7.mjs} +2 -2
- package/dist/{chunk-TOVMYGYW.mjs → chunk-F2SE2VDO.mjs} +1 -1
- package/dist/{chunk-BSPQVJ4A.mjs → chunk-FDR64H6B.mjs} +13 -0
- package/dist/{chunk-5OVTOKGH.cjs → chunk-FFFW3OQ7.cjs} +2 -2
- package/dist/{chunk-D4JE5NNV.cjs → chunk-FNO7A7CM.cjs} +5 -5
- package/dist/chunk-FZ6YYU2W.mjs +65 -0
- package/dist/{chunk-PZNCMPJF.cjs → chunk-G26MUMKL.cjs} +14 -8
- package/dist/{chunk-IXUY2F5U.mjs → chunk-GCXWJJKH.mjs} +4 -7
- package/dist/{chunk-JLCQGPXE.mjs → chunk-GNSDTTWZ.mjs} +50 -61
- package/dist/{chunk-TEN4FIZU.mjs → chunk-GOABMOX3.mjs} +151 -3
- package/dist/{chunk-HBTUGXHS.cjs → chunk-HLJ6MBUZ.cjs} +7 -4
- package/dist/{chunk-GZYH4OER.mjs → chunk-HR5KPHC2.mjs} +1 -1
- package/dist/{chunk-ZCU4NZ3M.cjs → chunk-IE7XCHH3.cjs} +4 -4
- package/dist/{chunk-I26CZYPV.cjs → chunk-IHNIDL6H.cjs} +50 -7
- package/dist/{chunk-2FQHH5SC.mjs → chunk-IHNMMXHV.mjs} +49 -24
- package/dist/{chunk-VHJGDMCG.cjs → chunk-IWZKTWHZ.cjs} +2 -2
- package/dist/{chunk-DGXN3L4D.mjs → chunk-JDPAKVS4.mjs} +4 -4
- package/dist/chunk-JG6DJF5A.mjs +238 -0
- package/dist/{chunk-5TISYEQF.mjs → chunk-JM5XPKWH.mjs} +10 -3
- package/dist/{chunk-BJJATPEC.mjs → chunk-KN7K4VQN.mjs} +1 -1
- package/dist/{chunk-WPYFSQKK.cjs → chunk-KNBBQHO2.cjs} +15 -1
- package/dist/{chunk-XWAWFQFS.cjs → chunk-KXWRO25S.cjs} +7 -4
- package/dist/{chunk-QG5HNS7P.mjs → chunk-LHODW25H.mjs} +2 -2
- package/dist/{chunk-BXFWA23T.mjs → chunk-LMJ7VRHZ.mjs} +3 -3
- package/dist/{chunk-WG2KHOMN.mjs → chunk-LR5QSC2P.mjs} +380 -209
- package/dist/chunk-LSKZMJMP.cjs +65 -0
- package/dist/{chunk-2N5PX3LS.mjs → chunk-LYV44OIR.mjs} +7 -1
- package/dist/{chunk-5MKEDGLD.cjs → chunk-M64YUMA4.cjs} +11 -6
- package/dist/{chunk-EXLKRR4U.cjs → chunk-MIDIZJZC.cjs} +12 -12
- package/dist/{chunk-ES4B2IXW.cjs → chunk-MOKLYNHV.cjs} +2 -2
- package/dist/{chunk-IV6CQY7O.mjs → chunk-MSSFIQGM.mjs} +63 -13
- package/dist/{chunk-KH7BN726.cjs → chunk-N4UOK6ZI.cjs} +8 -2
- package/dist/{chunk-6VYZOPOT.mjs → chunk-NGVORZVZ.mjs} +1 -1
- package/dist/{chunk-JNGIWIY6.mjs → chunk-NPC7VWJE.mjs} +2 -2
- package/dist/{chunk-ILWLPEVO.mjs → chunk-NRSN7G7E.mjs} +2 -2
- package/dist/{chunk-AHAJGAYD.mjs → chunk-O27L4YAA.mjs} +1 -1
- package/dist/{chunk-VYZSOYR4.cjs → chunk-ODBZYBAB.cjs} +1 -1
- package/dist/{chunk-YVGAEAA5.cjs → chunk-P64MIF5B.cjs} +154 -6
- package/dist/{chunk-DFLLARUK.cjs → chunk-PQDFUSXD.cjs} +14 -14
- package/dist/{chunk-F6XEGFHO.mjs → chunk-PXKIEXZD.mjs} +10 -0
- package/dist/{chunk-S5GDHOE4.mjs → chunk-PZNL3WEG.mjs} +48 -5
- package/dist/{chunk-FV45CKBC.mjs → chunk-QCFBDFRS.mjs} +1 -1
- package/dist/{chunk-75BRBIFP.cjs → chunk-QCVE2OCI.cjs} +5 -8
- package/dist/{chunk-6ZCMSZ5U.mjs → chunk-QE6VAKLT.mjs} +1 -1
- package/dist/{chunk-75DYEVXI.cjs → chunk-QGYRXFU2.cjs} +9 -9
- package/dist/{chunk-CTV2TTNP.cjs → chunk-QJ3J6MZT.cjs} +16 -87
- package/dist/{chunk-O6XNAMBV.mjs → chunk-QLQ32WC4.mjs} +8 -3
- package/dist/{chunk-IMB4PIAR.cjs → chunk-SJVKK4JE.cjs} +839 -420
- package/dist/{chunk-3FCFQP5V.cjs → chunk-TA5G2HWD.cjs} +21 -21
- package/dist/{chunk-Z5HIWVDP.cjs → chunk-TDFPACVX.cjs} +62 -73
- package/dist/{chunk-ND224OE2.cjs → chunk-TKSCR644.cjs} +34 -15
- package/dist/{chunk-UAFSBWNT.mjs → chunk-U4PTAHW3.mjs} +64 -13
- package/dist/{chunk-ZHVYQL3H.cjs → chunk-U74I55WB.cjs} +86 -35
- package/dist/chunk-UBO4SGH4.mjs +86 -0
- package/dist/{chunk-IQXFRNY2.cjs → chunk-UFDAAQFX.cjs} +2 -2
- package/dist/{chunk-X7KZBF63.cjs → chunk-UX5S4JEO.cjs} +40 -4
- package/dist/{chunk-5ZSWG4UX.cjs → chunk-UXFQ3UDA.cjs} +14 -1
- package/dist/{chunk-L4DVIHOC.mjs → chunk-VCCUOMQN.mjs} +1 -1
- package/dist/{chunk-4V7GIE2U.mjs → chunk-VHANUNEG.mjs} +2 -2
- package/dist/{chunk-FXUUWYAX.cjs → chunk-VKNHTSAP.cjs} +10 -0
- package/dist/{chunk-2AKFKCHA.mjs → chunk-W7LF2J2S.mjs} +1 -1
- package/dist/{chunk-MNUGPHLN.mjs → chunk-WNNYOOIB.mjs} +5 -3
- package/dist/{chunk-VA62MHFV.mjs → chunk-X242HVD5.mjs} +1 -1
- package/dist/{chunk-UJ2C4ICS.cjs → chunk-XJXBIP67.cjs} +4 -4
- package/dist/{chunk-6L6DQR5W.mjs → chunk-XV5DJTBX.mjs} +539 -121
- package/dist/{chunk-KJ2TIHZZ.cjs → chunk-XXJU7FCC.cjs} +3 -2
- package/dist/{chunk-DYEJQTDN.cjs → chunk-YSCV4SJF.cjs} +4 -4
- package/dist/{chunk-2SDO73HK.cjs → chunk-YWN746US.cjs} +64 -14
- package/dist/chunk-Z2HLU4IX.cjs +238 -0
- package/dist/{chunk-2FXWWUE5.cjs → chunk-Z2YLTERK.cjs} +4 -4
- package/dist/{chunk-CUMINO7Z.cjs → chunk-ZHPHJPQP.cjs} +4 -4
- package/dist/{chunk-FJZ3DQLK.mjs → chunk-ZKP7C2B6.mjs} +4 -4
- package/dist/{chunk-JBC2FKRW.mjs → chunk-ZUSJDQ2Q.mjs} +2 -1
- package/dist/{client-plugins-BX2ptm4H.d.mts → client-plugins-CLObcuCq.d.mts} +26 -2
- package/dist/{client-plugins-BmxM5KW_.d.ts → client-plugins-DZjHC4Mi.d.ts} +26 -2
- package/dist/client-plugins.d.mts +1 -1
- package/dist/client-plugins.d.ts +1 -1
- package/dist/client.cjs +8 -8
- package/dist/client.d.mts +5 -5
- package/dist/client.d.ts +5 -5
- package/dist/client.mjs +7 -7
- package/dist/config.d.mts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/{devtools-EWRDHCD5.cjs → devtools-HU6Y2MNV.cjs} +11 -9
- package/dist/{devtools-BPBCYOU6.mjs → devtools-RNXCTS4R.mjs} +10 -8
- package/dist/docs.cjs +13 -11
- package/dist/docs.d.mts +5 -0
- package/dist/docs.d.ts +5 -0
- package/dist/docs.mjs +12 -10
- package/dist/environment/vite.cjs +2 -2
- package/dist/environment/vite.mjs +1 -1
- package/dist/headers.cjs +4 -4
- package/dist/headers.mjs +3 -3
- package/dist/i18n/client.cjs +14 -13
- package/dist/i18n/client.mjs +5 -4
- package/dist/i18n/index.cjs +3 -2
- package/dist/i18n/index.mjs +2 -1
- package/dist/i18n/server.cjs +6 -5
- package/dist/i18n/server.mjs +5 -4
- package/dist/image/server.cjs +2 -2
- package/dist/image/server.mjs +1 -1
- package/dist/image/sharp.cjs +9 -9
- package/dist/image/sharp.mjs +1 -1
- package/dist/index.cjs +67 -55
- package/dist/index.d.mts +14 -14
- package/dist/index.d.ts +14 -14
- package/dist/index.mjs +70 -58
- package/dist/integrations.cjs +6 -3
- package/dist/integrations.d.mts +1 -1
- package/dist/integrations.d.ts +1 -1
- package/dist/integrations.mjs +7 -4
- package/dist/internal/app-markdown-runtime.cjs +7 -5
- package/dist/internal/app-markdown-runtime.d.mts +14 -3
- package/dist/internal/app-markdown-runtime.d.ts +14 -3
- package/dist/internal/app-markdown-runtime.mjs +6 -4
- package/dist/internal/build-runtime.cjs +38 -35
- package/dist/internal/build-runtime.d.mts +3 -3
- package/dist/internal/build-runtime.d.ts +3 -3
- package/dist/internal/build-runtime.mjs +37 -34
- package/dist/internal/cli-runtime.cjs +20 -17
- package/dist/internal/cli-runtime.mjs +19 -16
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/client-runtime.cjs +4 -2
- package/dist/internal/client-runtime.d.mts +9 -1
- package/dist/internal/client-runtime.d.ts +9 -1
- package/dist/internal/client-runtime.mjs +3 -1
- package/dist/internal/compression-runtime.d.mts +1 -1
- package/dist/internal/compression-runtime.d.ts +1 -1
- package/dist/internal/config-runtime.cjs +11 -9
- package/dist/internal/config-runtime.d.mts +2 -2
- package/dist/internal/config-runtime.d.ts +2 -2
- package/dist/internal/config-runtime.mjs +10 -8
- package/dist/internal/infra-analytics-runtime.cjs +4 -4
- package/dist/internal/infra-analytics-runtime.mjs +2 -2
- package/dist/internal/product-telemetry-runtime.cjs +2 -2
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-runtime.cjs +20 -14
- package/dist/internal/production-runtime.d.mts +115 -8
- package/dist/internal/production-runtime.d.ts +115 -8
- package/dist/internal/production-runtime.mjs +19 -13
- package/dist/internal/request-cookies.cjs +4 -2
- package/dist/internal/request-cookies.d.mts +9 -1
- package/dist/internal/request-cookies.d.ts +9 -1
- package/dist/internal/request-cookies.mjs +3 -1
- package/dist/markdown.cjs +4 -4
- package/dist/markdown.d.mts +1 -1
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.mjs +3 -3
- package/dist/{metadata-DsEaK7mQ.d.mts → metadata-2HSU2i_w.d.mts} +1 -1
- package/dist/{metadata-fwZ3gfG6.d.ts → metadata-Cjs8JMRM.d.ts} +1 -1
- package/dist/middleware.cjs +18 -8
- package/dist/middleware.d.mts +24 -5
- package/dist/middleware.d.ts +24 -5
- package/dist/middleware.mjs +18 -8
- package/dist/navigation.cjs +6 -6
- package/dist/navigation.d.mts +4 -4
- package/dist/navigation.d.ts +4 -4
- package/dist/navigation.mjs +5 -5
- package/dist/{nitro-NAKCRVHX.mjs → nitro-4XGPNIK4.mjs} +3 -3
- package/dist/{nitro-VYDZGYFY.cjs → nitro-HSAQFXSS.cjs} +4 -4
- package/dist/plugin.cjs +33 -30
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.mjs +32 -29
- package/dist/{production-runtime-DNkpFnmg.d.ts → production-runtime-BU5ETAK9.d.ts} +8 -1
- package/dist/{production-runtime-Baqgwtvc.d.mts → production-runtime-CysZl3EV.d.mts} +8 -1
- package/dist/query/client.cjs +7 -7
- package/dist/query/client.mjs +3 -3
- package/dist/{render-plan-DhwQnmmX.d.mts → render-plan-CKr4ltOd.d.mts} +1 -1
- package/dist/{render-plan-rkIK9wd9.d.ts → render-plan-D72O1qm4.d.ts} +1 -1
- package/dist/renderer-client.cjs +39 -19
- package/dist/renderer-client.d.mts +3 -3
- package/dist/renderer-client.d.ts +3 -3
- package/dist/renderer-client.mjs +28 -8
- package/dist/{request-CFy1BltJ.d.mts → request-Be83WafN.d.mts} +7 -2
- package/dist/{request-BcY4RYPC.d.ts → request-DbyOYI2j.d.ts} +7 -2
- package/dist/request.cjs +2 -2
- package/dist/request.d.mts +2 -2
- package/dist/request.d.ts +2 -2
- package/dist/request.mjs +1 -1
- package/dist/{route-rendering-BkS0TBlB.d.mts → route-rendering-BG56SzvJ.d.mts} +1 -1
- package/dist/{route-rendering-D4XpMjam.d.ts → route-rendering-CtVMpV-k.d.ts} +1 -1
- package/dist/{router-C4zPlC3V.d.mts → router-ALUvm8gC.d.mts} +1 -1
- package/dist/{router-Cq7BcZxg.d.ts → router-D94-SDlW.d.ts} +1 -1
- package/dist/routes.cjs +3 -3
- package/dist/routes.d.mts +1 -1
- package/dist/routes.d.ts +1 -1
- package/dist/routes.mjs +2 -2
- package/dist/server-fn.cjs +3 -3
- package/dist/server-fn.mjs +2 -2
- package/dist/server-plugins.cjs +4 -4
- package/dist/server-plugins.d.mts +2 -2
- package/dist/server-plugins.d.ts +2 -2
- package/dist/server-plugins.mjs +3 -3
- package/dist/server-query-client.cjs +3 -3
- package/dist/server-query-client.mjs +2 -2
- package/dist/server-query.cjs +4 -4
- package/dist/server-query.mjs +3 -3
- package/dist/server.cjs +60 -57
- package/dist/server.d.mts +7 -7
- package/dist/server.d.ts +7 -7
- package/dist/server.mjs +37 -34
- package/dist/{spa-router-B1HI3X9k.d.ts → spa-router-CxK3USIz.d.ts} +2 -2
- package/dist/{spa-router-DzPZH-AO.d.mts → spa-router-DbxNRKOB.d.mts} +2 -2
- package/dist/testing.cjs +19 -17
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.mjs +16 -14
- package/dist/theme/server.cjs +4 -3
- package/dist/theme/server.mjs +3 -2
- package/dist/{utils-DMD1Hzta.d.ts → utils-311Y8eoK.d.ts} +1 -1
- package/dist/{utils-CEBktlBG.d.mts → utils-4wVRcpOw.d.mts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +33 -30
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.mjs +32 -29
- package/package.json +2 -2
- package/dist/chunk-22GUSVNJ.cjs +0 -351
- package/dist/chunk-SWN467MP.cjs +0 -18
- package/dist/chunk-XGC343EY.cjs +0 -443
- package/dist/chunk-ZSH2Y4LN.mjs +0 -351
- /package/dist/{chunk-SUIBNSNO.cjs → chunk-SJNMVDDF.cjs} +0 -0
- /package/dist/{chunk-LNZ7JZUS.mjs → chunk-UDNPLXW7.mjs} +0 -0
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
compileFarmDocsAdapterEdgeManifest,
|
|
12
12
|
createFarmDocsAPIHandler
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-U4PTAHW3.mjs";
|
|
14
14
|
import {
|
|
15
15
|
FARM_DOCS_LAST_MODIFIED_MANIFEST,
|
|
16
16
|
createFarmDocsHandler,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
loadFarmDocsPage,
|
|
21
21
|
resolveFarmDocsContentDir,
|
|
22
22
|
toFarmDocsMarkdownPage
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-O27L4YAA.mjs";
|
|
24
24
|
import {
|
|
25
25
|
generateFarmDocsSearchClientRuntime,
|
|
26
26
|
isFarmDocsSearchEnabled,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
} from "./chunk-UP4CW6WP.mjs";
|
|
29
29
|
import {
|
|
30
30
|
FARM_PRERENDER_ENV
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-3KZS4SUS.mjs";
|
|
32
32
|
import {
|
|
33
33
|
loadFarmDocsEngine
|
|
34
34
|
} from "./chunk-2VQKKQ6D.mjs";
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
getDeployTargetForPreset,
|
|
38
38
|
hasCustomFarmRouteContext,
|
|
39
39
|
resolveDeployOutputPath
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-ZKP7C2B6.mjs";
|
|
41
41
|
import {
|
|
42
42
|
resolveFarmInstrumentationFile
|
|
43
43
|
} from "./chunk-ZZSRYEYU.mjs";
|
|
@@ -50,6 +50,7 @@ import {
|
|
|
50
50
|
HOISTED_HEAD_ELEMENT,
|
|
51
51
|
PluginManager,
|
|
52
52
|
SHARP_INSTALL_HINT,
|
|
53
|
+
collectFarmWebMCPTools,
|
|
53
54
|
createFarmApp,
|
|
54
55
|
createFarmSourceAlias,
|
|
55
56
|
createFarmThemeCssPlugin,
|
|
@@ -69,27 +70,30 @@ import {
|
|
|
69
70
|
mergeFarmFontCss,
|
|
70
71
|
mergeFarmProductionViteConfig,
|
|
71
72
|
mergeFarmViteConfig,
|
|
73
|
+
resolveFarmAppPackages,
|
|
72
74
|
resolveFarmClientCacheAdapterEntry,
|
|
73
75
|
resolveFarmImageProviderForRuntime,
|
|
74
76
|
resolveFarmIsolatedClientHydrationMode,
|
|
75
77
|
resolveFarmNotFoundComponentPath
|
|
76
|
-
} from "./chunk-
|
|
78
|
+
} from "./chunk-XV5DJTBX.mjs";
|
|
77
79
|
import {
|
|
78
80
|
findRequestBoundSourceBlockers,
|
|
79
81
|
generateFarmTypeArtifacts,
|
|
80
82
|
parseRouteRenderingDirective,
|
|
81
83
|
resolveRouteRenderingConfigFromFile
|
|
82
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-AQZFOP7S.mjs";
|
|
83
85
|
import {
|
|
84
86
|
FARM_API_CATALOG_PATH,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
FARM_APP_MANIFEST_PATH,
|
|
88
|
+
resolveFarmApiCatalogInput,
|
|
89
|
+
resolveFarmAppManifestInput
|
|
90
|
+
} from "./chunk-GOABMOX3.mjs";
|
|
87
91
|
import {
|
|
88
92
|
isFarmPreviewDeploymentEnvironment
|
|
89
93
|
} from "./chunk-BOYNDCZL.mjs";
|
|
90
94
|
import {
|
|
91
95
|
farmEnvironmentFunctionsPlugin
|
|
92
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-E5GNDG5F.mjs";
|
|
93
97
|
import {
|
|
94
98
|
generateFarmDocsAdapterClientRuntime,
|
|
95
99
|
getFarmDocsAdapterConfigModule
|
|
@@ -115,7 +119,7 @@ import {
|
|
|
115
119
|
} from "./chunk-DAATZTKJ.mjs";
|
|
116
120
|
import {
|
|
117
121
|
applyFarmCspHashesToHtml
|
|
118
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-NGVORZVZ.mjs";
|
|
119
123
|
import {
|
|
120
124
|
applyFarmCronVercelCrons,
|
|
121
125
|
createFarmCronCloudflareConfig,
|
|
@@ -127,14 +131,14 @@ import {
|
|
|
127
131
|
} from "./chunk-4OOBRCJX.mjs";
|
|
128
132
|
import {
|
|
129
133
|
isFarmMarkdownPageFile
|
|
130
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-AGC75XAE.mjs";
|
|
131
135
|
import {
|
|
132
136
|
resolveFarmMdxComponentsModulePath,
|
|
133
137
|
resolveMdxConfig
|
|
134
138
|
} from "./chunk-FA2W42OV.mjs";
|
|
135
139
|
import {
|
|
136
140
|
getFarmMarkdownAlternatePath
|
|
137
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-ZUSJDQ2Q.mjs";
|
|
138
142
|
import {
|
|
139
143
|
applyFarmWorkflowVercelCrons,
|
|
140
144
|
prepareFarmWorkflowsForNitro
|
|
@@ -142,23 +146,26 @@ import {
|
|
|
142
146
|
import {
|
|
143
147
|
getFarmIntegrationPluginServerRuntime,
|
|
144
148
|
getIntegrationProviders
|
|
145
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-GNSDTTWZ.mjs";
|
|
146
150
|
import {
|
|
147
|
-
|
|
148
|
-
|
|
151
|
+
appendMiddlewareDirectory,
|
|
152
|
+
appendMiddlewareRoutePath,
|
|
153
|
+
compareMiddlewareRouteLocations
|
|
154
|
+
} from "./chunk-7Y6ZNFPX.mjs";
|
|
155
|
+
import {
|
|
156
|
+
compileMiddlewareConfig,
|
|
157
|
+
matchesCompiledMiddlewareConfig,
|
|
158
|
+
matchesMiddlewareRoute
|
|
159
|
+
} from "./chunk-JG6DJF5A.mjs";
|
|
149
160
|
import {
|
|
150
161
|
APIRouteManager
|
|
151
|
-
} from "./chunk-
|
|
162
|
+
} from "./chunk-LMJ7VRHZ.mjs";
|
|
152
163
|
import {
|
|
153
164
|
readFarmI18nCatalogs
|
|
154
|
-
} from "./chunk-
|
|
165
|
+
} from "./chunk-QCFBDFRS.mjs";
|
|
155
166
|
import {
|
|
156
167
|
VERCEL_OG_INSTALL_HINT
|
|
157
168
|
} from "./chunk-YOZYCI6Z.mjs";
|
|
158
|
-
import {
|
|
159
|
-
resolveFarmAPIServerBasePath,
|
|
160
|
-
resolveFarmAPIServerRoutePath
|
|
161
|
-
} from "./chunk-I6XDAKWQ.mjs";
|
|
162
169
|
import {
|
|
163
170
|
createFarmRouteRuntimeKey,
|
|
164
171
|
getFarmRouteRuntimeConfig,
|
|
@@ -173,6 +180,10 @@ import {
|
|
|
173
180
|
toPosixPath,
|
|
174
181
|
toViteModuleId
|
|
175
182
|
} from "./chunk-KI3MESHB.mjs";
|
|
183
|
+
import {
|
|
184
|
+
resolveFarmAPIServerBasePath,
|
|
185
|
+
resolveFarmAPIServerRoutePath
|
|
186
|
+
} from "./chunk-BTHHUD7Q.mjs";
|
|
176
187
|
import {
|
|
177
188
|
getFarmPresetRuntime
|
|
178
189
|
} from "./chunk-2A3EQHXX.mjs";
|
|
@@ -184,8 +195,8 @@ import {
|
|
|
184
195
|
} from "./chunk-LPEX4YW6.mjs";
|
|
185
196
|
|
|
186
197
|
// src/build/index.ts
|
|
187
|
-
import
|
|
188
|
-
import { existsSync as
|
|
198
|
+
import path7 from "path";
|
|
199
|
+
import { existsSync as existsSync3 } from "fs";
|
|
189
200
|
|
|
190
201
|
// src/nitro/client-css-href.ts
|
|
191
202
|
import path from "path";
|
|
@@ -239,8 +250,8 @@ __name(resolveHashedClientJsSrc, "resolveHashedClientJsSrc");
|
|
|
239
250
|
|
|
240
251
|
// src/nitro/universal-build.ts
|
|
241
252
|
import os from "os";
|
|
242
|
-
import
|
|
243
|
-
import { constants as fsConstants, existsSync, readFileSync, realpathSync } from "fs";
|
|
253
|
+
import path6 from "path";
|
|
254
|
+
import { constants as fsConstants, existsSync as existsSync2, readFileSync, realpathSync } from "fs";
|
|
244
255
|
import { fileURLToPath } from "url";
|
|
245
256
|
import { builtinModules, createRequire } from "module";
|
|
246
257
|
import { isDeepStrictEqual } from "util";
|
|
@@ -707,6 +718,47 @@ function buildFarmVercelRoutes(options) {
|
|
|
707
718
|
}
|
|
708
719
|
__name(buildFarmVercelRoutes, "buildFarmVercelRoutes");
|
|
709
720
|
|
|
721
|
+
// src/nitro/netlify-entry.ts
|
|
722
|
+
import { existsSync } from "fs";
|
|
723
|
+
import path5 from "path";
|
|
724
|
+
function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
|
|
725
|
+
const entry = path5.join(
|
|
726
|
+
path5.dirname(nitroRuntimeEntry),
|
|
727
|
+
"..",
|
|
728
|
+
"presets",
|
|
729
|
+
"netlify",
|
|
730
|
+
"runtime",
|
|
731
|
+
"netlify.mjs"
|
|
732
|
+
);
|
|
733
|
+
if (!existsSync(entry)) {
|
|
734
|
+
throw new Error(
|
|
735
|
+
`[Farm.js] Could not find Nitro's Netlify function entry at ${entry}. Farm wraps it so private responses are never cached by Netlify's CDN; reinstall dependencies or report the installed Nitro version.`
|
|
736
|
+
);
|
|
737
|
+
}
|
|
738
|
+
return entry.split(path5.sep).join("/");
|
|
739
|
+
}
|
|
740
|
+
__name(resolveNitroNetlifyEntry, "resolveNitroNetlifyEntry");
|
|
741
|
+
function createFarmNetlifyEntry(options) {
|
|
742
|
+
return `
|
|
743
|
+
import nitroNetlifyHandler from ${JSON.stringify(options.nitroNetlifyEntry)};
|
|
744
|
+
|
|
745
|
+
const PRIVATE_CACHE_DIRECTIVE = /(?:^|,)\\s*(?:private|no-store)\\s*(?:[,=]|$)/i;
|
|
746
|
+
|
|
747
|
+
export default async function farmNetlifyHandler(request, context) {
|
|
748
|
+
const response = await nitroNetlifyHandler(request, context);
|
|
749
|
+
if (
|
|
750
|
+
response &&
|
|
751
|
+
response.headers.has("netlify-cdn-cache-control") &&
|
|
752
|
+
PRIVATE_CACHE_DIRECTIVE.test(response.headers.get("cache-control") || "")
|
|
753
|
+
) {
|
|
754
|
+
response.headers.delete("netlify-cdn-cache-control");
|
|
755
|
+
}
|
|
756
|
+
return response;
|
|
757
|
+
}
|
|
758
|
+
`.trim();
|
|
759
|
+
}
|
|
760
|
+
__name(createFarmNetlifyEntry, "createFarmNetlifyEntry");
|
|
761
|
+
|
|
710
762
|
// src/nitro/node-server-entry.ts
|
|
711
763
|
function createFarmNodeServerEntry(options) {
|
|
712
764
|
const serverConfig = JSON.stringify(options.server);
|
|
@@ -984,18 +1036,18 @@ function preloadFarmNitroBuilder() {
|
|
|
984
1036
|
}
|
|
985
1037
|
__name(preloadFarmNitroBuilder, "preloadFarmNitroBuilder");
|
|
986
1038
|
var _filename = typeof import.meta.url !== "undefined" ? fileURLToPath(import.meta.url) : "";
|
|
987
|
-
var _dirname =
|
|
1039
|
+
var _dirname = path6.dirname(_filename);
|
|
988
1040
|
function findFarmCoreRoot(from) {
|
|
989
|
-
let dir =
|
|
990
|
-
while (dir !==
|
|
991
|
-
const manifest =
|
|
992
|
-
if (
|
|
1041
|
+
let dir = path6.dirname(from);
|
|
1042
|
+
while (dir !== path6.dirname(dir)) {
|
|
1043
|
+
const manifest = path6.join(dir, "package.json");
|
|
1044
|
+
if (existsSync2(manifest)) {
|
|
993
1045
|
try {
|
|
994
1046
|
if (JSON.parse(readFileSync(manifest, "utf8")).name === "@farm.js/core") return dir;
|
|
995
1047
|
} catch {
|
|
996
1048
|
}
|
|
997
1049
|
}
|
|
998
|
-
dir =
|
|
1050
|
+
dir = path6.dirname(dir);
|
|
999
1051
|
}
|
|
1000
1052
|
return null;
|
|
1001
1053
|
}
|
|
@@ -1007,16 +1059,16 @@ function toModulePath(file) {
|
|
|
1007
1059
|
}
|
|
1008
1060
|
__name(toModulePath, "toModulePath");
|
|
1009
1061
|
function findInstalledPackageDir(name, from) {
|
|
1010
|
-
for (let dir = from; ; dir =
|
|
1011
|
-
const candidate =
|
|
1012
|
-
if (
|
|
1062
|
+
for (let dir = from; ; dir = path6.dirname(dir)) {
|
|
1063
|
+
const candidate = path6.join(dir, "node_modules", name);
|
|
1064
|
+
if (existsSync2(path6.join(candidate, "package.json"))) {
|
|
1013
1065
|
try {
|
|
1014
1066
|
return realpathSync(candidate);
|
|
1015
1067
|
} catch {
|
|
1016
1068
|
return null;
|
|
1017
1069
|
}
|
|
1018
1070
|
}
|
|
1019
|
-
if (dir ===
|
|
1071
|
+
if (dir === path6.dirname(dir)) return null;
|
|
1020
1072
|
}
|
|
1021
1073
|
}
|
|
1022
1074
|
__name(findInstalledPackageDir, "findInstalledPackageDir");
|
|
@@ -1028,7 +1080,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1028
1080
|
seen.add(dir);
|
|
1029
1081
|
let manifest;
|
|
1030
1082
|
try {
|
|
1031
|
-
manifest = JSON.parse(readFileSync(
|
|
1083
|
+
manifest = JSON.parse(readFileSync(path6.join(dir, "package.json"), "utf8"));
|
|
1032
1084
|
} catch {
|
|
1033
1085
|
return;
|
|
1034
1086
|
}
|
|
@@ -1039,7 +1091,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1039
1091
|
if (farmCoreRoot) visit(realpathSync(farmCoreRoot));
|
|
1040
1092
|
queue.push({ name: "@farm.js/core", from: root });
|
|
1041
1093
|
try {
|
|
1042
|
-
const manifest = JSON.parse(readFileSync(
|
|
1094
|
+
const manifest = JSON.parse(readFileSync(path6.join(root, "package.json"), "utf8"));
|
|
1043
1095
|
for (const field of ["dependencies", "devDependencies"]) {
|
|
1044
1096
|
for (const name of Object.keys(manifest[field] ?? {})) {
|
|
1045
1097
|
if (name.startsWith("@farm.js/")) queue.push({ name, from: root });
|
|
@@ -1106,15 +1158,15 @@ var FARM_SSR_PACKAGE_IMPORT = "#farm-ssr-entry";
|
|
|
1106
1158
|
var FARM_SSR_OUTPUT_DIR = "farm-ssr";
|
|
1107
1159
|
var FARM_CLIENT_BUILD_TARGET = ["es2020", "edge88", "firefox78", "chrome87", "safari14"];
|
|
1108
1160
|
function resolveNitroRuntimeDependency(root, specifier) {
|
|
1109
|
-
return createRequire(resolveNitroPackageEntry(root)).resolve(specifier).split(
|
|
1161
|
+
return createRequire(resolveNitroPackageEntry(root)).resolve(specifier).split(path6.sep).join("/");
|
|
1110
1162
|
}
|
|
1111
1163
|
__name(resolveNitroRuntimeDependency, "resolveNitroRuntimeDependency");
|
|
1112
1164
|
function resolveNitroInternalRuntimeAliases(root) {
|
|
1113
|
-
const runtimeDir =
|
|
1165
|
+
const runtimeDir = path6.dirname(resolveNitroPackageEntry(root));
|
|
1114
1166
|
return Object.fromEntries(
|
|
1115
1167
|
["app", "error/hooks", "runtime-config", "shutdown", "task"].map((moduleName) => [
|
|
1116
1168
|
`#nitro/runtime/${moduleName}`,
|
|
1117
|
-
|
|
1169
|
+
path6.join(runtimeDir, "internal", `${moduleName}.mjs`).split(path6.sep).join("/")
|
|
1118
1170
|
])
|
|
1119
1171
|
);
|
|
1120
1172
|
}
|
|
@@ -1125,7 +1177,7 @@ function createPrerenderRuntimeResolverPlugin(root, resolveNitroEntry = resolveN
|
|
|
1125
1177
|
name: "farm-prerender-runtime-resolver",
|
|
1126
1178
|
async resolveId(id, _importer, options) {
|
|
1127
1179
|
if (options.custom?.farmPrerenderRuntimeResolve) return null;
|
|
1128
|
-
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") ||
|
|
1180
|
+
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") || path6.isAbsolute(id) || NODE_BUILTIN_MODULES.has(id)) {
|
|
1129
1181
|
return null;
|
|
1130
1182
|
}
|
|
1131
1183
|
if (nitroEntry === void 0) {
|
|
@@ -1146,7 +1198,7 @@ function createPrerenderRuntimeResolverPlugin(root, resolveNitroEntry = resolveN
|
|
|
1146
1198
|
}
|
|
1147
1199
|
__name(createPrerenderRuntimeResolverPlugin, "createPrerenderRuntimeResolverPlugin");
|
|
1148
1200
|
function resolveNitroPackageEntry(root) {
|
|
1149
|
-
const projectRequire = createRequire(
|
|
1201
|
+
const projectRequire = createRequire(path6.join(root, "package.json"));
|
|
1150
1202
|
let runtimeRequire = projectRequire;
|
|
1151
1203
|
try {
|
|
1152
1204
|
runtimeRequire = createRequire(projectRequire.resolve("@farm.js/core"));
|
|
@@ -1221,7 +1273,7 @@ function createFarmReactWebServerAlias(hasEdgeBuild) {
|
|
|
1221
1273
|
__name(createFarmReactWebServerAlias, "createFarmReactWebServerAlias");
|
|
1222
1274
|
function hasReactDomEdgeServerBuild(root) {
|
|
1223
1275
|
try {
|
|
1224
|
-
createRequire(
|
|
1276
|
+
createRequire(path6.join(root, "package.json")).resolve("react-dom/server.edge");
|
|
1225
1277
|
return true;
|
|
1226
1278
|
} catch {
|
|
1227
1279
|
return false;
|
|
@@ -1279,7 +1331,7 @@ function createMetadataImageWasmPlugin() {
|
|
|
1279
1331
|
return null;
|
|
1280
1332
|
}
|
|
1281
1333
|
const requestPath = source.slice(0, -"?module".length);
|
|
1282
|
-
const resolvedPath =
|
|
1334
|
+
const resolvedPath = path6.isAbsolute(requestPath) ? requestPath : path6.resolve(path6.dirname(importer.split("?", 1)[0]), requestPath);
|
|
1283
1335
|
return `${FARM_METADATA_IMAGE_WASM_PREFIX}${resolvedPath}`;
|
|
1284
1336
|
},
|
|
1285
1337
|
load(id) {
|
|
@@ -1305,11 +1357,11 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
1305
1357
|
for (const importId of [...output.imports, ...output.dynamicImports]) {
|
|
1306
1358
|
const normalizedImportId = importId.replace(/\\/g, "/");
|
|
1307
1359
|
const normalizedId = normalizedImportId.replace(/^\.\//, "");
|
|
1308
|
-
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ?
|
|
1360
|
+
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ? path6.posix.normalize(path6.posix.join(path6.posix.dirname(fileName), normalizedImportId)) : null;
|
|
1309
1361
|
if (emittedFiles.has(normalizedId) || resolvedRelativeId !== null && emittedFiles.has(resolvedRelativeId) || NODE_BUILTIN_MODULES.has(importId) || importId.startsWith("node:")) {
|
|
1310
1362
|
continue;
|
|
1311
1363
|
}
|
|
1312
|
-
if (
|
|
1364
|
+
if (path6.isAbsolute(importId) || /^[A-Za-z]:[\\/]/.test(importId) || importId.startsWith("#") || importId.startsWith("\0")) {
|
|
1313
1365
|
externalPackages.add(importId);
|
|
1314
1366
|
continue;
|
|
1315
1367
|
}
|
|
@@ -1322,15 +1374,15 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
1322
1374
|
}
|
|
1323
1375
|
__name(collectSSRExternalPackages, "collectSSRExternalPackages");
|
|
1324
1376
|
function createExternalSSRBundlePlugin(nitroEntryPath, ssrOutputDir, ssrEntryFile) {
|
|
1325
|
-
const resolvedNitroEntry =
|
|
1326
|
-
const resolvedSSREntry =
|
|
1377
|
+
const resolvedNitroEntry = path6.resolve(nitroEntryPath);
|
|
1378
|
+
const resolvedSSREntry = path6.resolve(ssrOutputDir, ssrEntryFile);
|
|
1327
1379
|
return {
|
|
1328
1380
|
name: "farm-externalize-prebuilt-ssr",
|
|
1329
1381
|
resolveId(source, importer) {
|
|
1330
|
-
if (!importer ||
|
|
1382
|
+
if (!importer || path6.resolve(importer) !== resolvedNitroEntry) {
|
|
1331
1383
|
return null;
|
|
1332
1384
|
}
|
|
1333
|
-
const resolvedImport =
|
|
1385
|
+
const resolvedImport = path6.resolve(path6.dirname(importer), source);
|
|
1334
1386
|
if (resolvedImport !== resolvedSSREntry) return null;
|
|
1335
1387
|
return { id: FARM_SSR_PACKAGE_IMPORT, external: true };
|
|
1336
1388
|
}
|
|
@@ -1344,6 +1396,11 @@ function hasRollupPlugins(plugins) {
|
|
|
1344
1396
|
return Boolean(plugins);
|
|
1345
1397
|
}
|
|
1346
1398
|
__name(hasRollupPlugins, "hasRollupPlugins");
|
|
1399
|
+
function hasFarmServerCacheConfig(cache) {
|
|
1400
|
+
if (!cache || typeof cache !== "object") return false;
|
|
1401
|
+
return cache.adapter !== void 0 || cache.namespace !== void 0 || cache.maxEntries !== void 0 || cache.lease !== void 0;
|
|
1402
|
+
}
|
|
1403
|
+
__name(hasFarmServerCacheConfig, "hasFarmServerCacheConfig");
|
|
1347
1404
|
function hasFarmRuntimeConfigModule(config, configModulePath) {
|
|
1348
1405
|
return Boolean(configModulePath || (config.layers || []).some((layer) => layer.configFile));
|
|
1349
1406
|
}
|
|
@@ -1453,14 +1510,14 @@ function resolveBuildDocsContentDir(config, root) {
|
|
|
1453
1510
|
if (!config.docs?.enabled) return null;
|
|
1454
1511
|
const configuredContentDir = config.docs.contentDir || config.docs.config.contentDir;
|
|
1455
1512
|
if (typeof configuredContentDir === "string" && configuredContentDir.trim()) {
|
|
1456
|
-
const contentDir =
|
|
1457
|
-
return
|
|
1513
|
+
const contentDir = path6.isAbsolute(configuredContentDir) ? configuredContentDir : path6.join(root, configuredContentDir);
|
|
1514
|
+
return existsSync2(contentDir) ? contentDir : null;
|
|
1458
1515
|
}
|
|
1459
1516
|
const entryDir = config.docs.config.entry || trimSlashes(config.docs.entry) || "docs";
|
|
1460
|
-
const appDocsDir =
|
|
1461
|
-
if (
|
|
1462
|
-
const rootDocsDir =
|
|
1463
|
-
return
|
|
1517
|
+
const appDocsDir = path6.join(root, config.srcDir || "src", "app", entryDir);
|
|
1518
|
+
if (existsSync2(appDocsDir)) return appDocsDir;
|
|
1519
|
+
const rootDocsDir = path6.join(root, entryDir);
|
|
1520
|
+
return existsSync2(rootDocsDir) ? rootDocsDir : null;
|
|
1464
1521
|
}
|
|
1465
1522
|
__name(resolveBuildDocsContentDir, "resolveBuildDocsContentDir");
|
|
1466
1523
|
function hasProjectPostcssConfig(root) {
|
|
@@ -1477,7 +1534,7 @@ function hasProjectPostcssConfig(root) {
|
|
|
1477
1534
|
".postcssrc.mjs",
|
|
1478
1535
|
".postcssrc.ts"
|
|
1479
1536
|
];
|
|
1480
|
-
const projectRequire = createRequire(
|
|
1537
|
+
const projectRequire = createRequire(path6.join(root, "package.json"));
|
|
1481
1538
|
return candidates.some((file) => {
|
|
1482
1539
|
try {
|
|
1483
1540
|
projectRequire.resolve(`./${file}`);
|
|
@@ -1501,7 +1558,7 @@ async function findFarmConfigPath(root) {
|
|
|
1501
1558
|
"config.mjs"
|
|
1502
1559
|
];
|
|
1503
1560
|
for (const candidate of candidates) {
|
|
1504
|
-
const resolvedPath =
|
|
1561
|
+
const resolvedPath = path6.join(root, candidate);
|
|
1505
1562
|
try {
|
|
1506
1563
|
await fs.access(resolvedPath);
|
|
1507
1564
|
return resolvedPath;
|
|
@@ -1543,7 +1600,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
1543
1600
|
const fs = await import("fs/promises");
|
|
1544
1601
|
const appDirs = Array.isArray(appDir) ? [...appDir] : [appDir];
|
|
1545
1602
|
const routes = /* @__PURE__ */ new Map();
|
|
1546
|
-
async function walk(dir, routePath, discovered) {
|
|
1603
|
+
async function walk(dir, routePath, directory, discovered) {
|
|
1547
1604
|
let entries;
|
|
1548
1605
|
try {
|
|
1549
1606
|
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
@@ -1556,30 +1613,31 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
1556
1613
|
if (middlewareFile) {
|
|
1557
1614
|
discovered.push({
|
|
1558
1615
|
path: routePath,
|
|
1559
|
-
|
|
1616
|
+
directory,
|
|
1617
|
+
filePath: path6.join(dir, middlewareFile.name)
|
|
1560
1618
|
});
|
|
1561
1619
|
}
|
|
1562
1620
|
for (const entry of entries) {
|
|
1563
1621
|
if (!entry.isDirectory() || entry.name.startsWith(".") || entry.name.startsWith("_")) {
|
|
1564
1622
|
continue;
|
|
1565
1623
|
}
|
|
1566
|
-
|
|
1567
|
-
|
|
1624
|
+
await walk(
|
|
1625
|
+
path6.join(dir, entry.name),
|
|
1626
|
+
appendMiddlewareRoutePath(routePath, entry.name),
|
|
1627
|
+
appendMiddlewareDirectory(directory, entry.name),
|
|
1628
|
+
discovered
|
|
1629
|
+
);
|
|
1568
1630
|
}
|
|
1569
1631
|
}
|
|
1570
1632
|
__name(walk, "walk");
|
|
1571
1633
|
for (const sourceAppDir of appDirs) {
|
|
1572
1634
|
const discovered = [];
|
|
1573
|
-
await walk(sourceAppDir, "/", discovered);
|
|
1635
|
+
await walk(sourceAppDir, "/", "", discovered);
|
|
1574
1636
|
for (const route of discovered) {
|
|
1575
|
-
routes.set(route.
|
|
1637
|
+
routes.set(route.directory, route);
|
|
1576
1638
|
}
|
|
1577
1639
|
}
|
|
1578
|
-
return Array.from(routes.values()).sort((
|
|
1579
|
-
const depthA = a.path.split("/").filter(Boolean).length;
|
|
1580
|
-
const depthB = b.path.split("/").filter(Boolean).length;
|
|
1581
|
-
return depthA - depthB || a.path.localeCompare(b.path);
|
|
1582
|
-
});
|
|
1640
|
+
return Array.from(routes.values()).sort(compareMiddlewareRouteLocations).map(({ path: routePath, filePath }) => ({ path: routePath, filePath }));
|
|
1583
1641
|
}
|
|
1584
1642
|
__name(discoverMiddlewareRoutes, "discoverMiddlewareRoutes");
|
|
1585
1643
|
function assertFarmDocsRuntimeSupported(config, preset) {
|
|
@@ -1641,7 +1699,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1641
1699
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
|
|
1642
1700
|
const fs = await import("fs/promises");
|
|
1643
1701
|
const layoutRoutes = [];
|
|
1644
|
-
const appDir =
|
|
1702
|
+
const appDir = path6.join(root, srcDir, "app");
|
|
1645
1703
|
async function findLayoutsForClient(dir, routePrefix = "/") {
|
|
1646
1704
|
try {
|
|
1647
1705
|
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
@@ -1649,11 +1707,11 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1649
1707
|
if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?|vue|svelte)$/)) {
|
|
1650
1708
|
layoutRoutes.push({
|
|
1651
1709
|
pattern: routePrefix,
|
|
1652
|
-
modulePath:
|
|
1710
|
+
modulePath: path6.join(dir, entry.name)
|
|
1653
1711
|
});
|
|
1654
1712
|
} else if (entry.isDirectory() && !entry.name.startsWith(".") && !entry.name.startsWith("_")) {
|
|
1655
1713
|
const childPrefix = routePrefix === "/" ? `/${entry.name}` : `${routePrefix}/${entry.name}`;
|
|
1656
|
-
await findLayoutsForClient(
|
|
1714
|
+
await findLayoutsForClient(path6.join(dir, entry.name), childPrefix);
|
|
1657
1715
|
}
|
|
1658
1716
|
}
|
|
1659
1717
|
} catch {
|
|
@@ -1670,7 +1728,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1670
1728
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes and ${layoutRoutes.length} layouts`);
|
|
1671
1729
|
const isolatedClientBoundaryModules = routeManager.getIsolatedClientBoundaryModules(root);
|
|
1672
1730
|
const hydrationPlanCache = /* @__PURE__ */ new Map();
|
|
1673
|
-
const clientOutputDir =
|
|
1731
|
+
const clientOutputDir = path6.join(root, distDir, "client");
|
|
1674
1732
|
const [productionViteResult] = await productionViteResultPromise;
|
|
1675
1733
|
if (productionViteResult.status === "rejected") {
|
|
1676
1734
|
await routeRuntimeManifestResultPromise;
|
|
@@ -1779,10 +1837,10 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1779
1837
|
lifecyclePluginManager
|
|
1780
1838
|
);
|
|
1781
1839
|
const runtimeManifestPath = await writeFarmRouteRuntimeManifest(
|
|
1782
|
-
|
|
1840
|
+
path6.join(root, distDir),
|
|
1783
1841
|
routeRuntimeManifest
|
|
1784
1842
|
);
|
|
1785
|
-
logger.info(`\u{1F4CB} Route runtime manifest: ${
|
|
1843
|
+
logger.info(`\u{1F4CB} Route runtime manifest: ${path6.relative(root, runtimeManifestPath)}`);
|
|
1786
1844
|
} catch (error) {
|
|
1787
1845
|
if (lifecyclePluginManager) {
|
|
1788
1846
|
await lifecyclePluginManager.runHookParallel("onError", {
|
|
@@ -1809,8 +1867,8 @@ async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
|
1809
1867
|
await mergeBuiltFontCss(outputDir, output.source);
|
|
1810
1868
|
continue;
|
|
1811
1869
|
}
|
|
1812
|
-
const filePath =
|
|
1813
|
-
await fs.mkdir(
|
|
1870
|
+
const filePath = path6.join(outputDir, fileName);
|
|
1871
|
+
await fs.mkdir(path6.dirname(filePath), { recursive: true });
|
|
1814
1872
|
await fs.writeFile(filePath, output.source);
|
|
1815
1873
|
}
|
|
1816
1874
|
}
|
|
@@ -1819,8 +1877,8 @@ async function copyFarmDocsFontAssetsToClient(root, outputDir) {
|
|
|
1819
1877
|
const fs = await import("fs/promises");
|
|
1820
1878
|
await Promise.all(
|
|
1821
1879
|
resolveFarmDocsFontAssets(root).map(async ({ sourcePath, url }) => {
|
|
1822
|
-
const targetPath =
|
|
1823
|
-
await fs.mkdir(
|
|
1880
|
+
const targetPath = path6.join(outputDir, url.replace(/^\/+/, ""));
|
|
1881
|
+
await fs.mkdir(path6.dirname(targetPath), { recursive: true });
|
|
1824
1882
|
await fs.copyFile(sourcePath, targetPath);
|
|
1825
1883
|
})
|
|
1826
1884
|
);
|
|
@@ -1828,7 +1886,7 @@ async function copyFarmDocsFontAssetsToClient(root, outputDir) {
|
|
|
1828
1886
|
__name(copyFarmDocsFontAssetsToClient, "copyFarmDocsFontAssetsToClient");
|
|
1829
1887
|
async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
1830
1888
|
const fs = await import("fs/promises");
|
|
1831
|
-
const fontCssPath =
|
|
1889
|
+
const fontCssPath = path6.join(outputDir, "farm-fonts.css");
|
|
1832
1890
|
let fontCss = fontCssSource;
|
|
1833
1891
|
if (fontCss === void 0) {
|
|
1834
1892
|
try {
|
|
@@ -1837,7 +1895,7 @@ async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
|
1837
1895
|
return;
|
|
1838
1896
|
}
|
|
1839
1897
|
}
|
|
1840
|
-
const clientCssPath =
|
|
1898
|
+
const clientCssPath = path6.join(outputDir, "farm-client.css");
|
|
1841
1899
|
let clientCss = "";
|
|
1842
1900
|
try {
|
|
1843
1901
|
clientCss = await fs.readFile(clientCssPath, "utf8");
|
|
@@ -1859,7 +1917,7 @@ var IncompleteClientBuildOutputError = _IncompleteClientBuildOutputError;
|
|
|
1859
1917
|
async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
1860
1918
|
const fs = await import("fs/promises");
|
|
1861
1919
|
const fingerprinted = await findFingerprintedClientEntry(outputDir);
|
|
1862
|
-
const clientEntryPath =
|
|
1920
|
+
const clientEntryPath = path6.join(outputDir, fingerprinted ?? "farm-client.js");
|
|
1863
1921
|
let clientEntrySize = 0;
|
|
1864
1922
|
try {
|
|
1865
1923
|
const clientEntry = await fs.stat(clientEntryPath);
|
|
@@ -1869,8 +1927,8 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
1869
1927
|
if (clientEntrySize === 0) {
|
|
1870
1928
|
throw new IncompleteClientBuildOutputError("farm-client.js is missing or empty");
|
|
1871
1929
|
}
|
|
1872
|
-
const clientCssPath =
|
|
1873
|
-
const globalsCssPath =
|
|
1930
|
+
const clientCssPath = path6.join(outputDir, "farm-client.css");
|
|
1931
|
+
const globalsCssPath = path6.join(root, srcDir, "app", "globals.css");
|
|
1874
1932
|
let expectsCss = false;
|
|
1875
1933
|
try {
|
|
1876
1934
|
const globalsCss = await fs.readFile(globalsCssPath, "utf8");
|
|
@@ -1892,7 +1950,7 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
1892
1950
|
}
|
|
1893
1951
|
__name(validateClientBuildOutput, "validateClientBuildOutput");
|
|
1894
1952
|
function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, options = {}) {
|
|
1895
|
-
const key = `${
|
|
1953
|
+
const key = `${path6.resolve(root)}\0${mode}\0${options.asyncOwnerIslands === true}\0${path6.resolve(modulePath)}`;
|
|
1896
1954
|
let plan = cache.get(key);
|
|
1897
1955
|
if (!plan) {
|
|
1898
1956
|
plan = getClientModuleHydrationPlan(modulePath, root, mode, options);
|
|
@@ -2128,10 +2186,10 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2128
2186
|
logger.info(
|
|
2129
2187
|
`\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout) => layout.shouldHydrate || layout.hasIsolatedClientBoundaries).length} layouts, and ${clientRouteSlots.length} slots`
|
|
2130
2188
|
);
|
|
2131
|
-
const clientEntryRoot =
|
|
2189
|
+
const clientEntryRoot = path6.join(root, ".farm", "tmp");
|
|
2132
2190
|
await fs.mkdir(clientEntryRoot, { recursive: true });
|
|
2133
|
-
const clientEntryDir = await fs.mkdtemp(
|
|
2134
|
-
const clientEntryPath =
|
|
2191
|
+
const clientEntryDir = await fs.mkdtemp(path6.join(clientEntryRoot, "client-entry-"));
|
|
2192
|
+
const clientEntryPath = path6.join(clientEntryDir, "farm-client-entry.tsx");
|
|
2135
2193
|
const clientHydrationCode = generateClientHydrationEntry(
|
|
2136
2194
|
clientPages,
|
|
2137
2195
|
clientLayouts,
|
|
@@ -2163,7 +2221,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2163
2221
|
if (hasScopedPostcssConfig) {
|
|
2164
2222
|
logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
|
|
2165
2223
|
} else {
|
|
2166
|
-
const postcssConfigPath =
|
|
2224
|
+
const postcssConfigPath = path6.join(clientEntryDir, "postcss.config.cjs");
|
|
2167
2225
|
await fs.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
|
|
2168
2226
|
postcssSearchPath = clientEntryDir;
|
|
2169
2227
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
@@ -2322,12 +2380,12 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2322
2380
|
__name(buildClient, "buildClient");
|
|
2323
2381
|
function toBakedMarkdownSourcePath(root, filePath) {
|
|
2324
2382
|
if (!filePath) return "";
|
|
2325
|
-
if (!
|
|
2326
|
-
const relative =
|
|
2327
|
-
if (!relative || relative.startsWith("..") ||
|
|
2328
|
-
return
|
|
2383
|
+
if (!path6.isAbsolute(filePath)) return filePath.split(path6.sep).join("/");
|
|
2384
|
+
const relative = path6.relative(root, filePath);
|
|
2385
|
+
if (!relative || relative.startsWith("..") || path6.isAbsolute(relative)) {
|
|
2386
|
+
return path6.basename(filePath);
|
|
2329
2387
|
}
|
|
2330
|
-
return relative.split(
|
|
2388
|
+
return relative.split(path6.sep).join("/");
|
|
2331
2389
|
}
|
|
2332
2390
|
__name(toBakedMarkdownSourcePath, "toBakedMarkdownSourcePath");
|
|
2333
2391
|
function generateUniversalRouterStateRuntime() {
|
|
@@ -3084,8 +3142,8 @@ __farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot
|
|
|
3084
3142
|
root,
|
|
3085
3143
|
renderer.componentExtensions ?? []
|
|
3086
3144
|
);
|
|
3087
|
-
const globalsCssPath =
|
|
3088
|
-
const cssImport =
|
|
3145
|
+
const globalsCssPath = path6.join(root, srcDir, "app", "globals.css");
|
|
3146
|
+
const cssImport = existsSync2(globalsCssPath) ? `import ${JSON.stringify(toImportPath(globalsCssPath))};` : "";
|
|
3089
3147
|
const layoutImportStatements = [];
|
|
3090
3148
|
const layoutRegistrations = [];
|
|
3091
3149
|
layoutRoutes.forEach((layout, index) => {
|
|
@@ -3151,7 +3209,7 @@ function isFarmDocsPath() {
|
|
|
3151
3209
|
// Farm.js Client Runtime (no client components)
|
|
3152
3210
|
${cssImport}
|
|
3153
3211
|
${layoutImports}
|
|
3154
|
-
import { createClientCancellation, createClientPluginManager, getHashTargetElement, installChunkErrorRecovery, isFarmExternalNavigationURL, reconcileFarmDocumentHead, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
3212
|
+
import { createClientCancellation, createClientPluginManager, getHashTargetElement, installChunkErrorRecovery, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
3155
3213
|
import { createFarmDeploymentMismatchError, createFarmDeploymentRequestHeaders, isFarmDeploymentMismatchResponse } from "@farm.js/core/deployment";
|
|
3156
3214
|
${clientPluginEntry.imports}
|
|
3157
3215
|
${clientCachePersistence.imports}
|
|
@@ -3175,6 +3233,7 @@ ${generateUniversalRouterStateProperties()}
|
|
|
3175
3233
|
|
|
3176
3234
|
navigate: async function(href, options = {}) {
|
|
3177
3235
|
const url = new URL(href, window.location.href);
|
|
3236
|
+
if (isFarmBlockedNavigationURL(url)) return;
|
|
3178
3237
|
if (isFarmExternalNavigationURL(url, window.location.origin)) {
|
|
3179
3238
|
this.cancelActiveNavigation();
|
|
3180
3239
|
if (options.replace || options.action === "replace") window.location.replace(href);
|
|
@@ -3498,7 +3557,7 @@ ${layoutImports}
|
|
|
3498
3557
|
${rendererClientImports}
|
|
3499
3558
|
${isolatedHydrationImport}
|
|
3500
3559
|
${providerClientCode.imports}
|
|
3501
|
-
import { createClientCancellation, createClientPluginManager, getHashTargetElement, installChunkErrorRecovery, isFarmExternalNavigationURL, reconcileFarmDocumentHead, scheduleFarmIslandHydration, searchParamsToObject, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
3560
|
+
import { createClientCancellation, createClientPluginManager, getHashTargetElement, installChunkErrorRecovery, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, scheduleFarmIslandHydration, searchParamsToObject, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
3502
3561
|
import { createFarmDeploymentMismatchError, createFarmDeploymentRequestHeaders, isFarmDeploymentMismatchResponse } from "@farm.js/core/deployment";
|
|
3503
3562
|
import { createFarmRouter, isFarmRouteActive, matchFarmRoute } from "@farm.js/core/router";
|
|
3504
3563
|
${clientPluginEntry.imports}
|
|
@@ -3614,7 +3673,7 @@ async function loadRouteComponent(route) {
|
|
|
3614
3673
|
return route.Component;
|
|
3615
3674
|
}
|
|
3616
3675
|
|
|
3617
|
-
async function createMatchedHydrationRoute(matched, pathname, searchParams, serverHtml) {
|
|
3676
|
+
async function createMatchedHydrationRoute(matched, pathname, searchParams, serverHtml, serverProps) {
|
|
3618
3677
|
const hydrateLayouts = hasHydratableLayout(pathname);
|
|
3619
3678
|
const params = matched.params;
|
|
3620
3679
|
let pageElement = null;
|
|
@@ -3622,15 +3681,30 @@ async function createMatchedHydrationRoute(matched, pathname, searchParams, serv
|
|
|
3622
3681
|
if (matched.route.pageShouldHydrate) {
|
|
3623
3682
|
const Component = await loadRouteComponent(matched.route);
|
|
3624
3683
|
if (!Component) return null;
|
|
3625
|
-
|
|
3684
|
+
// A programmatic page whose guard and data run only on the server renders
|
|
3685
|
+
// from the props the server resolved for this document. Without them (a
|
|
3686
|
+
// rejected guard, deferred data) its server-rendered HTML is kept.
|
|
3687
|
+
if (Component.__farmServerProps === true) {
|
|
3688
|
+
if (!serverProps || serverProps.__farmRoutePropsResolved !== true) return null;
|
|
3689
|
+
const middleware = serverProps.middleware;
|
|
3690
|
+
const props = {
|
|
3691
|
+
...serverProps,
|
|
3692
|
+
...(middleware && middleware.data && !(middleware.data instanceof Map)
|
|
3693
|
+
? { middleware: { ...middleware, data: new Map(Object.entries(middleware.data)) } }
|
|
3694
|
+
: {}),
|
|
3695
|
+
searchParams: Promise.resolve(serverProps.search ?? searchParams),
|
|
3696
|
+
};
|
|
3697
|
+
pageElement = React.createElement(Component, props);
|
|
3698
|
+
} else if (typeof Component === "function" && Component.constructor && Component.constructor.name === "AsyncFunction") {
|
|
3626
3699
|
console.warn(
|
|
3627
3700
|
"[Farm.js] Skipping hydration for " + pathname +
|
|
3628
3701
|
": async server components cannot run in the browser. Server-rendered HTML is preserved."
|
|
3629
3702
|
);
|
|
3630
3703
|
return null;
|
|
3704
|
+
} else {
|
|
3705
|
+
const props = { params: params, searchParams: Promise.resolve(searchParams) };
|
|
3706
|
+
pageElement = React.createElement(Component, props);
|
|
3631
3707
|
}
|
|
3632
|
-
const props = { params: params, searchParams: Promise.resolve(searchParams) };
|
|
3633
|
-
pageElement = React.createElement(Component, props);
|
|
3634
3708
|
} else if (hydrateLayouts) {
|
|
3635
3709
|
const serverPage = document.getElementById("__farm_page__");
|
|
3636
3710
|
pageElement = createLayoutPageBoundary(
|
|
@@ -3701,6 +3775,32 @@ function findClientRouteSlot(slot) {
|
|
|
3701
3775
|
});
|
|
3702
3776
|
}
|
|
3703
3777
|
|
|
3778
|
+
/**
|
|
3779
|
+
* The page props a fetched document embeds in its bootstrap script, which a
|
|
3780
|
+
* client navigation does not execute. The JSON ends at the first statement
|
|
3781
|
+
* boundary where it parses, so the separator inside a string cannot cut it.
|
|
3782
|
+
*/
|
|
3783
|
+
function readPagePropsPayload(doc) {
|
|
3784
|
+
const prefix = "window.__FARM_PROPS__=";
|
|
3785
|
+
const separator = ";window.__FARM_INTEGRATION_API_MANIFEST__=";
|
|
3786
|
+
for (const script of doc.querySelectorAll("script:not([src])")) {
|
|
3787
|
+
const source = script.textContent || "";
|
|
3788
|
+
if (!source.startsWith(prefix)) continue;
|
|
3789
|
+
for (
|
|
3790
|
+
let end = source.indexOf(separator, prefix.length);
|
|
3791
|
+
end !== -1;
|
|
3792
|
+
end = source.indexOf(separator, end + 1)
|
|
3793
|
+
) {
|
|
3794
|
+
try {
|
|
3795
|
+
return JSON.parse(source.slice(prefix.length, end));
|
|
3796
|
+
} catch {
|
|
3797
|
+
// The separator was inside a string value; try the next one.
|
|
3798
|
+
}
|
|
3799
|
+
}
|
|
3800
|
+
}
|
|
3801
|
+
return undefined;
|
|
3802
|
+
}
|
|
3803
|
+
|
|
3704
3804
|
function readRouteSlotPayload(doc) {
|
|
3705
3805
|
const script = doc.getElementById("__farm_route_slots_data__");
|
|
3706
3806
|
if (!script?.textContent) return [];
|
|
@@ -3897,6 +3997,8 @@ async function hydrate() {
|
|
|
3897
3997
|
matched,
|
|
3898
3998
|
pathname,
|
|
3899
3999
|
searchParams,
|
|
4000
|
+
undefined,
|
|
4001
|
+
window.__FARM_PROPS__,
|
|
3900
4002
|
);
|
|
3901
4003
|
if (!routeState) return;
|
|
3902
4004
|
const shouldHydrate = !isHydrated && Boolean(container.innerHTML.trim());
|
|
@@ -4011,6 +4113,7 @@ ${generateUniversalRouterStateProperties()}
|
|
|
4011
4113
|
|
|
4012
4114
|
navigate: async function(href, options = {}) {
|
|
4013
4115
|
const url = new URL(href, window.location.href);
|
|
4116
|
+
if (isFarmBlockedNavigationURL(url)) return;
|
|
4014
4117
|
if (isFarmExternalNavigationURL(url, window.location.origin)) {
|
|
4015
4118
|
this.cancelActiveNavigation();
|
|
4016
4119
|
if (options.replace || options.action === "replace") window.location.replace(href);
|
|
@@ -4243,6 +4346,7 @@ ${generateUniversalRouterStateProperties()}
|
|
|
4243
4346
|
if (isFarmLocaleDocumentChange(doc)) return false;
|
|
4244
4347
|
if (doc.getElementById("nd-docs-layout")) return false;
|
|
4245
4348
|
const nextRouteSlots = readRouteSlotPayload(doc);
|
|
4349
|
+
const nextPageProps = readPagePropsPayload(doc);
|
|
4246
4350
|
const isNavigationCurrent = () =>
|
|
4247
4351
|
this.isCurrentNavigation(navigation, clientNavigation);
|
|
4248
4352
|
|
|
@@ -4273,6 +4377,7 @@ ${generateUniversalRouterStateProperties()}
|
|
|
4273
4377
|
newPathname,
|
|
4274
4378
|
searchParams,
|
|
4275
4379
|
nextPage ? nextPage.innerHTML : "",
|
|
4380
|
+
nextPageProps,
|
|
4276
4381
|
);
|
|
4277
4382
|
if (!isNavigationCurrent()) return false;
|
|
4278
4383
|
if (routeState) {
|
|
@@ -4308,6 +4413,8 @@ ${generateUniversalRouterStateProperties()}
|
|
|
4308
4413
|
matched,
|
|
4309
4414
|
newPathname,
|
|
4310
4415
|
searchParams,
|
|
4416
|
+
undefined,
|
|
4417
|
+
nextPageProps,
|
|
4311
4418
|
);
|
|
4312
4419
|
if (!isNavigationCurrent()) return false;
|
|
4313
4420
|
if (routeState) {
|
|
@@ -4474,9 +4581,9 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4474
4581
|
buildLifetime: rendererBuildLifetime
|
|
4475
4582
|
});
|
|
4476
4583
|
if (!hasScopedPostcssConfig) {
|
|
4477
|
-
postcssConfigDir = await fs.mkdtemp(
|
|
4584
|
+
postcssConfigDir = await fs.mkdtemp(path6.join(os.tmpdir(), "farm-postcss-"));
|
|
4478
4585
|
await fs.writeFile(
|
|
4479
|
-
|
|
4586
|
+
path6.join(postcssConfigDir, "postcss.config.cjs"),
|
|
4480
4587
|
"module.exports = { plugins: [] };\n"
|
|
4481
4588
|
);
|
|
4482
4589
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
@@ -4601,7 +4708,8 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
4601
4708
|
const hasRouteContextConfig = hasCustomFarmRouteContext(config);
|
|
4602
4709
|
const hasServerRuntimePlugins = hasFarmServerRuntimePlugins(config);
|
|
4603
4710
|
const hasPluginRoutes = hasFarmPluginRoutes(config);
|
|
4604
|
-
const
|
|
4711
|
+
const hasServerCacheConfig = hasFarmServerCacheConfig(config.cache);
|
|
4712
|
+
const configModulePath = hasServerRuntimeIntegrations || hasObservabilityHandler || hasMdxComponentConfig || hasMiddlewareConfig || hasRouteContextConfig || hasServerRuntimePlugins || hasPluginRoutes || hasServerCacheConfig || hasIntegrationProviders ? await findFarmConfigPath(root) : null;
|
|
4605
4713
|
const hasRuntimeConfigModule = hasFarmRuntimeConfigModule(config, configModulePath);
|
|
4606
4714
|
const hasRuntimeIntegrationConfig = hasRuntimeConfigModule && hasAnyConfiguredIntegrations;
|
|
4607
4715
|
const hasConfiguredRuntimePlugins = Boolean(
|
|
@@ -5475,6 +5583,7 @@ function isolateFarmRouteServerPage(element) { return element; }`;
|
|
|
5475
5583
|
const notFoundImport = notFoundPath ? `import * as CustomNotFound from ${toVirtualEntryImportSpecifier(notFoundPath)};` : "";
|
|
5476
5584
|
const apiRouteHelpersImport = apiRoutes.length > 0 ? `import { mergePluginAPIRoutes, getAllowedAPIRouteMethods, invokeAPIRouteEndpoint, createStaticAPIRouteMatcherAtBasePath, resolveAPIRouteEndpoint } from "@farm.js/core/api/runtime";` : "";
|
|
5477
5585
|
const productionRuntimeImport = `import {
|
|
5586
|
+
_getRequestReadCount,
|
|
5478
5587
|
_runWithAfterRequest,
|
|
5479
5588
|
_runWithCurrentRequest,
|
|
5480
5589
|
_runWithAPIRequestRuntime,
|
|
@@ -5500,6 +5609,7 @@ function isolateFarmRouteServerPage(element) { return element; }`;
|
|
|
5500
5609
|
createFarmMetadataRouteResponse,
|
|
5501
5610
|
createFarmAgentRobots,
|
|
5502
5611
|
createFarmApiCatalogResponse,
|
|
5612
|
+
createFarmAppManifestResponse,
|
|
5503
5613
|
collectFarmLlmsTxtPages,
|
|
5504
5614
|
createFarmDefaultLlmsTxt,
|
|
5505
5615
|
createFarmLlmsMarkdownReader,
|
|
@@ -5568,9 +5678,9 @@ import * as farmDocsConfigModule from ${toVirtualEntryImportSpecifier(docsConfig
|
|
|
5568
5678
|
import { dirname as farmDocsDirname, join as farmDocsJoin } from "node:path";
|
|
5569
5679
|
import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
|
|
5570
5680
|
const markdownHandlerImport = config.md?.enabled ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
|
|
5571
|
-
const appMarkdownImport = hasMarkdownPages ? `import { createFarmMarkdownRouteModule, createFarmMarkdownSourceResponse } from "@farm.js/core/internal/app-markdown-runtime";` : "const createFarmMarkdownSourceResponse = null;";
|
|
5681
|
+
const appMarkdownImport = hasMarkdownPages ? `import { createFarmMarkdownRouteModule, createFarmMarkdownSourceResponse, isFarmMarkdownPublicSourceResponse } from "@farm.js/core/internal/app-markdown-runtime";` : "const createFarmMarkdownSourceResponse = null;\nconst isFarmMarkdownPublicSourceResponse = null;";
|
|
5572
5682
|
const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
|
|
5573
|
-
const mdxComponentsPath = typeof config.mdx?.components === "string" ?
|
|
5683
|
+
const mdxComponentsPath = typeof config.mdx?.components === "string" ? path6.isAbsolute(config.mdx.components) ? config.mdx.components : path6.join(config.root, config.mdx.components) : null;
|
|
5574
5684
|
const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from ${toVirtualEntryImportSpecifier(mdxComponentsPath)};` : "";
|
|
5575
5685
|
const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
|
|
5576
5686
|
const layerConfigImports = layerConfigPaths.map(
|
|
@@ -6014,10 +6124,17 @@ const farmDocsAPIHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDo
|
|
|
6014
6124
|
|
|
6015
6125
|
// API routes bundled at build time
|
|
6016
6126
|
const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
|
|
6017
|
-
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path:
|
|
6127
|
+
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path8, methods }) => ({ path: path8, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)} })` : ""};
|
|
6018
6128
|
const farmLocalAPIBasePath = ${JSON.stringify(resolveFarmAPIServerBasePath(config.api))};
|
|
6019
6129
|
const farmOpenAPIReference = ${JSON.stringify(openAPIReference)};
|
|
6020
6130
|
${config.agent?.apiCatalog ? `const farmApiCatalogInput = ${JSON.stringify(resolveFarmApiCatalogInput(config))};
|
|
6131
|
+
` : ""}${config.analytics !== false ? `const farmAppManifestInput = ${JSON.stringify(
|
|
6132
|
+
resolveFarmAppManifestInput(config, {
|
|
6133
|
+
build: config.deploymentId,
|
|
6134
|
+
packages: resolveFarmAppPackages(config.root),
|
|
6135
|
+
webmcpTools: config.plugins.some(({ name }) => name === "farm:webmcp") ? collectFarmWebMCPTools(config.root, config.srcDir) : []
|
|
6136
|
+
})
|
|
6137
|
+
)};
|
|
6021
6138
|
` : ""}
|
|
6022
6139
|
function isFarmLocalAPIPathname(pathname) {
|
|
6023
6140
|
return farmLocalAPIBasePath !== "/" &&
|
|
@@ -6086,9 +6203,12 @@ function getFarmI18nSnapshot() {
|
|
|
6086
6203
|
return ${config.i18n.enabled ? "getFarmI18nClientSnapshot()" : "undefined"};
|
|
6087
6204
|
}
|
|
6088
6205
|
|
|
6206
|
+
// The locale step strips farmI18nConfig.basePath itself. Stripping it first as
|
|
6207
|
+
// well removed it twice, so /console/console/secret served /secret while
|
|
6208
|
+
// middleware and integration guards, which strip it once, saw /console/secret.
|
|
6089
6209
|
function getFarmRoutePathname(pathname) {
|
|
6090
6210
|
return farmI18nRuntime
|
|
6091
|
-
? stripFarmLocaleFromPathname(
|
|
6211
|
+
? stripFarmLocaleFromPathname(pathname, farmI18nConfig)
|
|
6092
6212
|
: stripFarmBasePath(pathname);
|
|
6093
6213
|
}
|
|
6094
6214
|
|
|
@@ -7030,6 +7150,7 @@ const farmMiddlewareRunner = ${hasMiddlewareRuntime ? `createProductionMiddlewar
|
|
|
7030
7150
|
modules: fileMiddlewareModules,
|
|
7031
7151
|
i18n: farmI18nConfig,
|
|
7032
7152
|
server: farmServerConfig,
|
|
7153
|
+
apiBasePath: farmLocalAPIBasePath,
|
|
7033
7154
|
})` : "null"};
|
|
7034
7155
|
|
|
7035
7156
|
${apiHandlerCode}
|
|
@@ -7450,6 +7571,12 @@ function getPPRHeaders(status, config) {
|
|
|
7450
7571
|
return headers;
|
|
7451
7572
|
}
|
|
7452
7573
|
|
|
7574
|
+
function hasFarmUnserializableRouteData(data) {
|
|
7575
|
+
const isPromise = (value) => Boolean(value) && typeof value.then === "function";
|
|
7576
|
+
if (isPromise(data)) return true;
|
|
7577
|
+
return Boolean(data) && typeof data === "object" && Object.values(data).some(isPromise);
|
|
7578
|
+
}
|
|
7579
|
+
|
|
7453
7580
|
function getRouteSharedCacheControl(route, pprCanCache) {
|
|
7454
7581
|
if (!route || !route.module) {
|
|
7455
7582
|
return null;
|
|
@@ -7662,7 +7789,8 @@ async function handleFarmRequestInContext(
|
|
|
7662
7789
|
|
|
7663
7790
|
${hasMarkdownPages ? `
|
|
7664
7791
|
// The raw markdown source of a page route is the page's content in another
|
|
7665
|
-
// representation;
|
|
7792
|
+
// representation; it is only served for a page an anonymous visitor may open,
|
|
7793
|
+
// which renderPage asks the app with the page's own path.
|
|
7666
7794
|
const markdownSourceResponse = await createFarmMarkdownSourceResponse?.({
|
|
7667
7795
|
request: cloneFarmRequestWithContext(request),
|
|
7668
7796
|
config: farmMdxConfig,
|
|
@@ -7670,9 +7798,12 @@ async function handleFarmRequestInContext(
|
|
|
7670
7798
|
const match = matchPageRoute(getFarmRoutePathname(targetPathname));
|
|
7671
7799
|
return match?.route?.markdownSource || null;
|
|
7672
7800
|
},
|
|
7801
|
+
renderPage: (targetRequest) => handleFarmRequest(targetRequest, adapterContext),
|
|
7673
7802
|
});
|
|
7674
7803
|
if (markdownSourceResponse) {
|
|
7675
|
-
return
|
|
7804
|
+
return isFarmMarkdownPublicSourceResponse(markdownSourceResponse)
|
|
7805
|
+
? markdownSourceResponse
|
|
7806
|
+
: applyProductionMiddlewareHeaders(markdownSourceResponse, middlewareHeaders);
|
|
7676
7807
|
}
|
|
7677
7808
|
` : ""}
|
|
7678
7809
|
|
|
@@ -7775,6 +7906,17 @@ async function handleFarmRequestInContext(
|
|
|
7775
7906
|
return applyProductionMiddlewareHeaders(applicationMetadataResponse, middlewareHeaders);
|
|
7776
7907
|
}
|
|
7777
7908
|
` : ""}
|
|
7909
|
+
${config.analytics !== false ? `
|
|
7910
|
+
// /.well-known/farmjs: the app's manifest, only for a request Farm Infra signed.
|
|
7911
|
+
if (normalizeRuntimePath(routePathname) === ${JSON.stringify(FARM_APP_MANIFEST_PATH)}) {
|
|
7912
|
+
const farmAppManifest = await createFarmAppManifestResponse(request, farmAppManifestInput, {
|
|
7913
|
+
development: false,
|
|
7914
|
+
});
|
|
7915
|
+
if (farmAppManifest) {
|
|
7916
|
+
return applyProductionMiddlewareHeaders(farmAppManifest, middlewareHeaders);
|
|
7917
|
+
}
|
|
7918
|
+
}
|
|
7919
|
+
` : ""}
|
|
7778
7920
|
${config.agent?.apiCatalog ? `
|
|
7779
7921
|
// agent.apiCatalog: list the OpenAPI and MCP surfaces at the RFC 9727 path.
|
|
7780
7922
|
if (normalizeRuntimePath(routePathname) === ${JSON.stringify(FARM_API_CATALOG_PATH)}) {
|
|
@@ -7913,6 +8055,9 @@ async function handleFarmRequestInContext(
|
|
|
7913
8055
|
emitFarmEvent({ type: "ppr.shell.miss", route: pathname, key: pprCacheKey });
|
|
7914
8056
|
}
|
|
7915
8057
|
|
|
8058
|
+
// Reads from here on belong to the page render, not to middleware.
|
|
8059
|
+
const requestReadsBeforeRender = _getRequestReadCount();
|
|
8060
|
+
|
|
7916
8061
|
// Get the page component and metadata
|
|
7917
8062
|
let PageComponent = route.module.default;
|
|
7918
8063
|
let pageStatus = 200;
|
|
@@ -7972,6 +8117,10 @@ async function handleFarmRequestInContext(
|
|
|
7972
8117
|
});
|
|
7973
8118
|
}
|
|
7974
8119
|
let pageProps;
|
|
8120
|
+
// A rejected guard or loader renders the route's notFound/error
|
|
8121
|
+
// component, and the route's generateMetadata must not run for it:
|
|
8122
|
+
// it would describe the resource the caller was refused.
|
|
8123
|
+
let routeStateRejected = false;
|
|
7975
8124
|
try {
|
|
7976
8125
|
// Resolve top-level route state before starting the HTTP stream so
|
|
7977
8126
|
// redirects, notFound(), and failures keep their real status. Route
|
|
@@ -8006,6 +8155,7 @@ async function handleFarmRequestInContext(
|
|
|
8006
8155
|
} catch (routeStateError) {
|
|
8007
8156
|
if (isFarmRedirectError(routeStateError)) throw routeStateError;
|
|
8008
8157
|
|
|
8158
|
+
routeStateRejected = true;
|
|
8009
8159
|
const routeComponents = route.module.__farmRouteComponents;
|
|
8010
8160
|
const routeStateProps = {
|
|
8011
8161
|
...rawPageProps,
|
|
@@ -8095,7 +8245,9 @@ async function handleFarmRequestInContext(
|
|
|
8095
8245
|
...(pageProps.__farmCanonicalPath
|
|
8096
8246
|
? { __farmCanonicalPath: pageProps.__farmCanonicalPath }
|
|
8097
8247
|
: {}),
|
|
8098
|
-
|
|
8248
|
+
// Deferred values do not survive JSON, so the browser cannot render
|
|
8249
|
+
// a page from these props while one is still in flight.
|
|
8250
|
+
...(pageProps.__farmRoutePropsResolved && !hasFarmUnserializableRouteData(pageProps.data)
|
|
8099
8251
|
? { __farmRoutePropsResolved: true }
|
|
8100
8252
|
: {}),
|
|
8101
8253
|
path: pathname,
|
|
@@ -8217,7 +8369,7 @@ async function handleFarmRequestInContext(
|
|
|
8217
8369
|
// the request's resolved Suspense content. Until the production runtime
|
|
8218
8370
|
// can persist and resume the partial shell itself, buffer streamed PPR
|
|
8219
8371
|
// responses for late status errors but do not cache their dynamic HTML.
|
|
8220
|
-
|
|
8372
|
+
let shouldCachePPRShell = Boolean(pprCacheKey && !renderedPage.stream);
|
|
8221
8373
|
if (!shouldCachePPRShell && pprCacheKey) {
|
|
8222
8374
|
pprCanCache = false;
|
|
8223
8375
|
emitFarmEvent({
|
|
@@ -8241,7 +8393,7 @@ async function handleFarmRequestInContext(
|
|
|
8241
8393
|
}
|
|
8242
8394
|
}
|
|
8243
8395
|
mergedMetadata = mergeMetadata(mergedMetadata, pageMetadata);
|
|
8244
|
-
if (typeof route.module.generateMetadata === "function") {
|
|
8396
|
+
if (!routeStateRejected && typeof route.module.generateMetadata === "function") {
|
|
8245
8397
|
mergedMetadata = mergeMetadata(
|
|
8246
8398
|
mergedMetadata,
|
|
8247
8399
|
await route.module.generateMetadata(pageProps),
|
|
@@ -8275,6 +8427,17 @@ async function handleFarmRequestInContext(
|
|
|
8275
8427
|
getFarmMarkdownAlternatePath(farmMarkdownConfig, pathname),
|
|
8276
8428
|
);` : ""}
|
|
8277
8429
|
|
|
8430
|
+
// headers(), cookies(), or getCurrentRequest() read during the render,
|
|
8431
|
+
// in the page, a layout, metadata, or anything they import, makes this
|
|
8432
|
+
// HTML one visitor's: never a shared PPR shell or CDN response.
|
|
8433
|
+
const renderReadRequest = _getRequestReadCount() !== requestReadsBeforeRender;
|
|
8434
|
+
if (renderReadRequest && shouldCachePPRShell) {
|
|
8435
|
+
shouldCachePPRShell = false;
|
|
8436
|
+
pprCanCache = false;
|
|
8437
|
+
emitFarmEvent({ type: "ppr.shell.bypass", route: pathname, reason: "request-read" });
|
|
8438
|
+
emitFarmEvent({ type: "cache.bypass", route: pathname, reason: "request-read" });
|
|
8439
|
+
}
|
|
8440
|
+
|
|
8278
8441
|
const renderedMetadata = renderMetadataHead(mergedMetadata, { pathname, jsonLd: ${JSON.stringify(config.agent?.jsonLd ?? false)} });
|
|
8279
8442
|
const title = renderedMetadata.title;
|
|
8280
8443
|
const metaTags = renderedMetadata.tags;
|
|
@@ -8286,6 +8449,7 @@ async function handleFarmRequestInContext(
|
|
|
8286
8449
|
);
|
|
8287
8450
|
const hasRequestScopedRender = Boolean(
|
|
8288
8451
|
pageStatus >= 400 ||
|
|
8452
|
+
renderReadRequest ||
|
|
8289
8453
|
request.headers.get("x-farm-intercept-from") ||
|
|
8290
8454
|
hasPrivateRequestHeaders ||
|
|
8291
8455
|
hasConfiguredRouteContext ||
|
|
@@ -9037,23 +9201,20 @@ function configMiddlewareMayHandlePath(config, pathname) {
|
|
|
9037
9201
|
if (!hasFarmMiddlewareConfig(config)) return false;
|
|
9038
9202
|
const entries = Array.isArray(config) ? config : [config];
|
|
9039
9203
|
return entries.some((entry) => {
|
|
9040
|
-
if (entry.exclude
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
});
|
|
9204
|
+
if (!entry.matcher && !entry.exclude) return true;
|
|
9205
|
+
const matchers = entry.matcher ? (Array.isArray(entry.matcher) ? entry.matcher : [entry.matcher]).map(
|
|
9206
|
+
(matcher) => (
|
|
9207
|
+
// A request-aware matcher cannot be proven safe at build time.
|
|
9208
|
+
typeof matcher === "function" ? () => true : matcher
|
|
9209
|
+
)
|
|
9210
|
+
) : void 0;
|
|
9211
|
+
const compiled = compileMiddlewareConfig({ matcher: matchers, exclude: entry.exclude });
|
|
9212
|
+
return matchesCompiledMiddlewareConfig(pathname, compiled, {}).matched;
|
|
9049
9213
|
});
|
|
9050
9214
|
}
|
|
9051
9215
|
__name(configMiddlewareMayHandlePath, "configMiddlewareMayHandlePath");
|
|
9052
9216
|
function appMiddlewareMayHandlePath(middlewareRoutes, pathname) {
|
|
9053
|
-
return middlewareRoutes.some((route) =>
|
|
9054
|
-
if (route.path === "/") return true;
|
|
9055
|
-
return middlewarePatternMatches(route.path, pathname) || middlewarePatternMatches(`${route.path}/**`, pathname);
|
|
9056
|
-
});
|
|
9217
|
+
return middlewareRoutes.some((route) => matchesMiddlewareRoute(pathname, route).matched);
|
|
9057
9218
|
}
|
|
9058
9219
|
__name(appMiddlewareMayHandlePath, "appMiddlewareMayHandlePath");
|
|
9059
9220
|
function routePatternSpecificity(pattern) {
|
|
@@ -9120,8 +9281,8 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
9120
9281
|
const isVercel = preset === "vercel" || preset === "vercel-edge";
|
|
9121
9282
|
const isCloudflareWorker = preset === "cloudflare-module";
|
|
9122
9283
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
9123
|
-
const runtimeServerOutputDir = isVercel ?
|
|
9124
|
-
const ssrOutputDir =
|
|
9284
|
+
const runtimeServerOutputDir = isVercel ? path6.join(outputDir, "functions", "__nitro.func") : path6.join(outputDir, "server");
|
|
9285
|
+
const ssrOutputDir = path6.join(root, distDir, "ssr");
|
|
9125
9286
|
const imageRuntime = resolveImageRuntime(config, preset);
|
|
9126
9287
|
const hasGeneratedMetadataImages = Array.from(routeManager.getMetadataImages().values()).some(
|
|
9127
9288
|
(image) => image.sourceType === "module"
|
|
@@ -9205,11 +9366,11 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
9205
9366
|
}
|
|
9206
9367
|
await fs.mkdir(ssrOutputDir, { recursive: true });
|
|
9207
9368
|
for (const [fileName, output] of Object.entries(ssrBundle)) {
|
|
9208
|
-
const filePath =
|
|
9209
|
-
await fs.mkdir(
|
|
9369
|
+
const filePath = path6.join(ssrOutputDir, fileName);
|
|
9370
|
+
await fs.mkdir(path6.dirname(filePath), { recursive: true });
|
|
9210
9371
|
await fs.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
|
|
9211
9372
|
}
|
|
9212
|
-
const nitroEntryPath =
|
|
9373
|
+
const nitroEntryPath = path6.join(ssrOutputDir, "nitro-entry.mjs");
|
|
9213
9374
|
const nodeAdapterModule = preset === "node-server" ? resolveNitroRuntimeDependency(root, "srvx/node") : null;
|
|
9214
9375
|
const nitroEntryCode = `
|
|
9215
9376
|
// Farm.js Nitro Entry
|
|
@@ -9362,18 +9523,27 @@ function toFarmNodeResponse(request, response) {
|
|
|
9362
9523
|
}` : ""}
|
|
9363
9524
|
`.trim();
|
|
9364
9525
|
await fs.writeFile(nitroEntryPath, nitroEntryCode);
|
|
9365
|
-
const farmNodeServerEntryPath = preset === "node-server" ?
|
|
9526
|
+
const farmNodeServerEntryPath = preset === "node-server" ? path6.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
|
|
9366
9527
|
if (farmNodeServerEntryPath && nodeAdapterModule) {
|
|
9367
9528
|
await fs.writeFile(
|
|
9368
9529
|
farmNodeServerEntryPath,
|
|
9369
9530
|
createFarmNodeServerEntry({
|
|
9370
|
-
nitroEntryFile:
|
|
9531
|
+
nitroEntryFile: path6.basename(nitroEntryPath),
|
|
9371
9532
|
nodeAdapterModule,
|
|
9372
9533
|
server: config.server,
|
|
9373
9534
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/node")
|
|
9374
9535
|
})
|
|
9375
9536
|
);
|
|
9376
9537
|
}
|
|
9538
|
+
const farmNetlifyEntryPath = preset === "netlify" ? path6.join(ssrOutputDir, "farm-netlify-entry.mjs") : null;
|
|
9539
|
+
if (farmNetlifyEntryPath) {
|
|
9540
|
+
await fs.writeFile(
|
|
9541
|
+
farmNetlifyEntryPath,
|
|
9542
|
+
createFarmNetlifyEntry({
|
|
9543
|
+
nitroNetlifyEntry: resolveNitroNetlifyEntry(resolveNitroPackageEntry(root))
|
|
9544
|
+
})
|
|
9545
|
+
);
|
|
9546
|
+
}
|
|
9377
9547
|
const prebuiltSSRPlugin = createExternalSSRBundlePlugin(
|
|
9378
9548
|
nitroEntryPath,
|
|
9379
9549
|
ssrOutputDir,
|
|
@@ -9399,6 +9569,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
9399
9569
|
let nitroConfig = {
|
|
9400
9570
|
preset,
|
|
9401
9571
|
...farmNodeServerEntryPath ? { entry: farmNodeServerEntryPath } : {},
|
|
9572
|
+
...farmNetlifyEntryPath ? { entry: farmNetlifyEntryPath } : {},
|
|
9402
9573
|
rootDir: root,
|
|
9403
9574
|
// Farm registers every handler, task, and plugin explicitly. Scanning the
|
|
9404
9575
|
// project root would bundle an app's own `middleware/`, `api/`, `routes/`,
|
|
@@ -9406,7 +9577,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
9406
9577
|
// `src` directory), as Nitro handlers outside Farm's aliases.
|
|
9407
9578
|
serverDir: false,
|
|
9408
9579
|
serverEntry: false,
|
|
9409
|
-
buildDir:
|
|
9580
|
+
buildDir: path6.join(root, distDir, ".nitro"),
|
|
9410
9581
|
alias: resolveNitroInternalRuntimeAliases(root),
|
|
9411
9582
|
compatibilityDate: "2024-12-01",
|
|
9412
9583
|
output: resolveFarmNitroOutputConfig(preset, outputDir),
|
|
@@ -9482,7 +9653,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
9482
9653
|
if (pluginManager) {
|
|
9483
9654
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
9484
9655
|
}
|
|
9485
|
-
const expectedServerDir =
|
|
9656
|
+
const expectedServerDir = path6.join(outputDir, "server");
|
|
9486
9657
|
const customRollupKeys = Object.keys(nitroConfig.rollupConfig || {}).filter(
|
|
9487
9658
|
(key) => key !== "external" && key !== "plugins"
|
|
9488
9659
|
);
|
|
@@ -9495,9 +9666,9 @@ function toFarmNodeResponse(request, response) {
|
|
|
9495
9666
|
snapshotSSRRebundleOptions(nitroConfig)
|
|
9496
9667
|
);
|
|
9497
9668
|
const requestedBuilder = nitroConfig.builder ?? process.env.NITRO_BUILDER;
|
|
9498
|
-
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 &&
|
|
9669
|
+
const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 && path6.resolve(nitroConfig.output?.serverDir || "") === path6.resolve(expectedServerDir) && Boolean(
|
|
9499
9670
|
nitroConfig.handlers?.some(
|
|
9500
|
-
(handler) =>
|
|
9671
|
+
(handler) => path6.resolve(handler?.handler || "") === nitroEntryPath
|
|
9501
9672
|
)
|
|
9502
9673
|
);
|
|
9503
9674
|
const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
|
|
@@ -9558,7 +9729,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
9558
9729
|
nitroInstance.routing.sync();
|
|
9559
9730
|
});
|
|
9560
9731
|
}
|
|
9561
|
-
if (farmNodeServerEntryPath) {
|
|
9732
|
+
if (farmNodeServerEntryPath || farmNetlifyEntryPath) {
|
|
9562
9733
|
nitroInstance.hooks.hook("prerender:config", (prerendererConfig) => {
|
|
9563
9734
|
delete prerendererConfig.entry;
|
|
9564
9735
|
});
|
|
@@ -9584,10 +9755,10 @@ function toFarmNodeResponse(request, response) {
|
|
|
9584
9755
|
});
|
|
9585
9756
|
}
|
|
9586
9757
|
prerenderer.hooks.hook("compiled", async () => {
|
|
9587
|
-
const prerenderServerDir =
|
|
9758
|
+
const prerenderServerDir = path6.join(outputDir, "server");
|
|
9588
9759
|
await copyPrebuiltSSRBundle(
|
|
9589
9760
|
ssrBundle,
|
|
9590
|
-
|
|
9761
|
+
path6.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
|
|
9591
9762
|
null,
|
|
9592
9763
|
fs
|
|
9593
9764
|
);
|
|
@@ -9660,7 +9831,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
9660
9831
|
const copyResults = await Promise.allSettled([
|
|
9661
9832
|
prebuiltSSRFilesResult.value ? writeSSRBundleFiles(
|
|
9662
9833
|
prebuiltSSRFilesResult.value,
|
|
9663
|
-
|
|
9834
|
+
path6.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
|
|
9664
9835
|
fs
|
|
9665
9836
|
) : Promise.resolve(),
|
|
9666
9837
|
runtimeCopyPromise
|
|
@@ -9670,7 +9841,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
9670
9841
|
);
|
|
9671
9842
|
if (failedCopy) throw failedCopy.reason;
|
|
9672
9843
|
if (canReusePrebuiltSSR) {
|
|
9673
|
-
await registerPrebuiltSSRPackageImport(
|
|
9844
|
+
await registerPrebuiltSSRPackageImport(path6.join(outputDir, "server"), ssrEntryFile, fs);
|
|
9674
9845
|
logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
|
|
9675
9846
|
}
|
|
9676
9847
|
if (useRolldownBuilder) {
|
|
@@ -9695,11 +9866,11 @@ function resolveFarmNitroOutputConfig(preset, outputDir) {
|
|
|
9695
9866
|
return {
|
|
9696
9867
|
dir: outputDir,
|
|
9697
9868
|
...preset === "node-server" ? {
|
|
9698
|
-
serverDir:
|
|
9699
|
-
publicDir:
|
|
9869
|
+
serverDir: path6.join(outputDir, "server"),
|
|
9870
|
+
publicDir: path6.join(outputDir, "public")
|
|
9700
9871
|
} : isVercel ? {
|
|
9701
|
-
serverDir:
|
|
9702
|
-
publicDir:
|
|
9872
|
+
serverDir: path6.join(outputDir, "functions", "__nitro.func"),
|
|
9873
|
+
publicDir: path6.join(outputDir, "static")
|
|
9703
9874
|
} : {}
|
|
9704
9875
|
};
|
|
9705
9876
|
}
|
|
@@ -9717,8 +9888,8 @@ async function writeSSRBundleFiles(files, targetDir, fs) {
|
|
|
9717
9888
|
await fs.rm(targetDir, { recursive: true, force: true });
|
|
9718
9889
|
await Promise.all(
|
|
9719
9890
|
files.map(async ({ fileName, contents }) => {
|
|
9720
|
-
const targetPath =
|
|
9721
|
-
await fs.mkdir(
|
|
9891
|
+
const targetPath = path6.join(targetDir, fileName);
|
|
9892
|
+
await fs.mkdir(path6.dirname(targetPath), { recursive: true });
|
|
9722
9893
|
await fs.writeFile(targetPath, contents);
|
|
9723
9894
|
})
|
|
9724
9895
|
);
|
|
@@ -9729,7 +9900,7 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions, fs) {
|
|
|
9729
9900
|
}
|
|
9730
9901
|
__name(copyPrebuiltSSRBundle, "copyPrebuiltSSRBundle");
|
|
9731
9902
|
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs) {
|
|
9732
|
-
const packagePath =
|
|
9903
|
+
const packagePath = path6.join(serverDir, "package.json");
|
|
9733
9904
|
const packageJSON = await fs.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
9734
9905
|
if (error.code === "ENOENT") return { type: "module" };
|
|
9735
9906
|
throw error;
|
|
@@ -9760,18 +9931,18 @@ async function moveVercelOutputPath(src, dest, fs) {
|
|
|
9760
9931
|
}
|
|
9761
9932
|
__name(moveVercelOutputPath, "moveVercelOutputPath");
|
|
9762
9933
|
async function postProcessVercelOutput(root, outputDir, fs, config, farmWorkflows, routeRuntimeManifest) {
|
|
9763
|
-
const serverDir =
|
|
9764
|
-
const functionsDir =
|
|
9765
|
-
const nitroFuncDir =
|
|
9766
|
-
const staticDir =
|
|
9767
|
-
const publicDir =
|
|
9934
|
+
const serverDir = path6.join(outputDir, "server");
|
|
9935
|
+
const functionsDir = path6.join(outputDir, "functions");
|
|
9936
|
+
const nitroFuncDir = path6.join(functionsDir, "__nitro.func");
|
|
9937
|
+
const staticDir = path6.join(outputDir, "static");
|
|
9938
|
+
const publicDir = path6.join(outputDir, "public");
|
|
9768
9939
|
await fs.mkdir(nitroFuncDir, { recursive: true });
|
|
9769
9940
|
const serverContents = await fs.readdir(serverDir).catch((error) => {
|
|
9770
9941
|
if (error.code === "ENOENT") return [];
|
|
9771
9942
|
throw error;
|
|
9772
9943
|
});
|
|
9773
9944
|
for (const file of serverContents) {
|
|
9774
|
-
await moveVercelOutputPath(
|
|
9945
|
+
await moveVercelOutputPath(path6.join(serverDir, file), path6.join(nitroFuncDir, file), fs);
|
|
9775
9946
|
}
|
|
9776
9947
|
if (serverContents.length > 0) await fs.rm(serverDir, { recursive: true, force: true });
|
|
9777
9948
|
try {
|
|
@@ -9781,7 +9952,7 @@ async function postProcessVercelOutput(root, outputDir, fs, config, farmWorkflow
|
|
|
9781
9952
|
}
|
|
9782
9953
|
await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs);
|
|
9783
9954
|
await copyPrismaClientForVercel(root, nitroFuncDir, fs);
|
|
9784
|
-
const configPath =
|
|
9955
|
+
const configPath = path6.join(outputDir, "config.json");
|
|
9785
9956
|
const configContent = await fs.readFile(configPath, "utf-8");
|
|
9786
9957
|
const vercelConfig = JSON.parse(configContent);
|
|
9787
9958
|
const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
|
|
@@ -9809,22 +9980,22 @@ __name(postProcessVercelOutput, "postProcessVercelOutput");
|
|
|
9809
9980
|
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs) {
|
|
9810
9981
|
const docsContentDir = resolveBuildDocsContentDir(config, root);
|
|
9811
9982
|
if (!docsContentDir) return;
|
|
9812
|
-
const bundledContentDir =
|
|
9983
|
+
const bundledContentDir = path6.join(nitroFuncDir, "farm-docs-content");
|
|
9813
9984
|
const lastModifiedManifest = createFarmDocsLastModifiedManifest(docsContentDir, {
|
|
9814
9985
|
fallback: "now"
|
|
9815
9986
|
});
|
|
9816
9987
|
await fs.rm(bundledContentDir, { recursive: true, force: true });
|
|
9817
|
-
await fs.mkdir(
|
|
9988
|
+
await fs.mkdir(path6.dirname(bundledContentDir), { recursive: true });
|
|
9818
9989
|
await fs.cp(docsContentDir, bundledContentDir, {
|
|
9819
9990
|
recursive: true,
|
|
9820
9991
|
force: true
|
|
9821
9992
|
});
|
|
9822
9993
|
await fs.writeFile(
|
|
9823
|
-
|
|
9994
|
+
path6.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
|
|
9824
9995
|
`${JSON.stringify(lastModifiedManifest, null, 2)}
|
|
9825
9996
|
`
|
|
9826
9997
|
);
|
|
9827
|
-
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${
|
|
9998
|
+
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path6.relative(root, docsContentDir)}`);
|
|
9828
9999
|
}
|
|
9829
10000
|
__name(copyFarmDocsContentForVercel, "copyFarmDocsContentForVercel");
|
|
9830
10001
|
function resolveServerFunctionPlatform(preset) {
|
|
@@ -9845,7 +10016,7 @@ function platformFieldAllows(field, value) {
|
|
|
9845
10016
|
__name(platformFieldAllows, "platformFieldAllows");
|
|
9846
10017
|
async function stageSharpRuntime(config, root, distDir, fs, preset) {
|
|
9847
10018
|
const functionPlatform = resolveServerFunctionPlatform(preset);
|
|
9848
|
-
const projectRequire = createRequire(
|
|
10019
|
+
const projectRequire = createRequire(path6.join(root, "package.json"));
|
|
9849
10020
|
let sharpRequire = projectRequire;
|
|
9850
10021
|
if (!resolvePackageJson(projectRequire, "sharp")) {
|
|
9851
10022
|
try {
|
|
@@ -9855,10 +10026,10 @@ async function stageSharpRuntime(config, root, distDir, fs, preset) {
|
|
|
9855
10026
|
}
|
|
9856
10027
|
const copiedPackages = /* @__PURE__ */ new Map();
|
|
9857
10028
|
const packageCopies = /* @__PURE__ */ new Map();
|
|
9858
|
-
const stageRoot =
|
|
10029
|
+
const stageRoot = path6.join(root, distDir, "tmp");
|
|
9859
10030
|
await fs.mkdir(stageRoot, { recursive: true });
|
|
9860
|
-
const stageDir = await fs.mkdtemp(
|
|
9861
|
-
const targetNodeModules =
|
|
10031
|
+
const stageDir = await fs.mkdtemp(path6.join(stageRoot, "sharp-runtime-"));
|
|
10032
|
+
const targetNodeModules = path6.join(stageDir, "node_modules");
|
|
9862
10033
|
function copyPackage(packageName, parentRequire) {
|
|
9863
10034
|
const activeCopy = packageCopies.get(packageName);
|
|
9864
10035
|
if (activeCopy) return activeCopy;
|
|
@@ -9872,10 +10043,10 @@ async function stageSharpRuntime(config, root, distDir, fs, preset) {
|
|
|
9872
10043
|
if (!packageJsonPath) return;
|
|
9873
10044
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
|
|
9874
10045
|
if (functionPlatform && !packageSupportsPlatform(packageJson, functionPlatform)) return;
|
|
9875
|
-
const packageDir =
|
|
9876
|
-
const targetDir =
|
|
10046
|
+
const packageDir = path6.dirname(packageJsonPath);
|
|
10047
|
+
const targetDir = path6.join(targetNodeModules, ...packageName.split("/"));
|
|
9877
10048
|
copiedPackages.set(packageName, String(packageJson.version || "*"));
|
|
9878
|
-
await fs.mkdir(
|
|
10049
|
+
await fs.mkdir(path6.dirname(targetDir), { recursive: true });
|
|
9879
10050
|
const packageRequire = createRequire(packageJsonPath);
|
|
9880
10051
|
const dependencies = {
|
|
9881
10052
|
...packageJson.dependencies,
|
|
@@ -9912,8 +10083,8 @@ async function stageSharpRuntime(config, root, distDir, fs, preset) {
|
|
|
9912
10083
|
}
|
|
9913
10084
|
__name(stageSharpRuntime, "stageSharpRuntime");
|
|
9914
10085
|
async function installStagedSharpRuntime(staged, nitroFuncDir, fs) {
|
|
9915
|
-
const stagedNodeModules =
|
|
9916
|
-
const targetNodeModules =
|
|
10086
|
+
const stagedNodeModules = path6.join(staged.stageDir, "node_modules");
|
|
10087
|
+
const targetNodeModules = path6.join(nitroFuncDir, "node_modules");
|
|
9917
10088
|
try {
|
|
9918
10089
|
await mergeStagedDirectory(stagedNodeModules, targetNodeModules, fs);
|
|
9919
10090
|
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs);
|
|
@@ -9943,8 +10114,8 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs) {
|
|
|
9943
10114
|
const entries = await fs.readdir(sourceDir, { withFileTypes: true });
|
|
9944
10115
|
await settleAllOrThrow(
|
|
9945
10116
|
entries.map(async (entry) => {
|
|
9946
|
-
const sourcePath =
|
|
9947
|
-
const targetPath =
|
|
10117
|
+
const sourcePath = path6.join(sourceDir, entry.name);
|
|
10118
|
+
const targetPath = path6.join(targetDir, entry.name);
|
|
9948
10119
|
try {
|
|
9949
10120
|
await fs.rename(sourcePath, targetPath);
|
|
9950
10121
|
return;
|
|
@@ -9972,14 +10143,14 @@ __name(mergeStagedDirectory, "mergeStagedDirectory");
|
|
|
9972
10143
|
function assertMetadataImageRuntimeInstalled(root, metadataImageRoutes) {
|
|
9973
10144
|
const generated = metadataImageRoutes.find((image) => image.sourceType === "module");
|
|
9974
10145
|
if (!generated || resolveMetadataImageRuntimePackageJson(root)) return;
|
|
9975
|
-
const file = generated.modulePath ? toPosixPath(
|
|
10146
|
+
const file = generated.modulePath ? toPosixPath(path6.relative(root, generated.modulePath)) : "";
|
|
9976
10147
|
throw new Error(
|
|
9977
10148
|
`${file || "A generated metadata image"} renders with @vercel/og, which is not installed. ${VERCEL_OG_INSTALL_HINT}`
|
|
9978
10149
|
);
|
|
9979
10150
|
}
|
|
9980
10151
|
__name(assertMetadataImageRuntimeInstalled, "assertMetadataImageRuntimeInstalled");
|
|
9981
10152
|
function resolveMetadataImageRuntimePackageJson(root) {
|
|
9982
|
-
const projectRequire = createRequire(
|
|
10153
|
+
const projectRequire = createRequire(path6.join(root, "package.json"));
|
|
9983
10154
|
const packageJsonPath = resolvePackageJson(projectRequire, "@vercel/og");
|
|
9984
10155
|
if (packageJsonPath) return packageJsonPath;
|
|
9985
10156
|
try {
|
|
@@ -9993,9 +10164,9 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs) {
|
|
|
9993
10164
|
const packageJsonPath = resolveMetadataImageRuntimePackageJson(root);
|
|
9994
10165
|
if (!packageJsonPath) return;
|
|
9995
10166
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
|
|
9996
|
-
const packageDir =
|
|
9997
|
-
const targetDir =
|
|
9998
|
-
await fs.mkdir(
|
|
10167
|
+
const packageDir = path6.dirname(packageJsonPath);
|
|
10168
|
+
const targetDir = path6.join(nitroFuncDir, "node_modules", "@vercel", "og");
|
|
10169
|
+
await fs.mkdir(path6.dirname(targetDir), { recursive: true });
|
|
9999
10170
|
await fs.cp(packageDir, targetDir, {
|
|
10000
10171
|
recursive: true,
|
|
10001
10172
|
force: true,
|
|
@@ -10012,7 +10183,7 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs) {
|
|
|
10012
10183
|
}
|
|
10013
10184
|
__name(copyMetadataImageRuntime, "copyMetadataImageRuntime");
|
|
10014
10185
|
async function readNitroOutputPackage(outputDir, fs) {
|
|
10015
|
-
const packagePath =
|
|
10186
|
+
const packagePath = path6.join(outputDir, "package.json");
|
|
10016
10187
|
return fs.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
10017
10188
|
if (error.code === "ENOENT") return {};
|
|
10018
10189
|
throw error;
|
|
@@ -10022,7 +10193,7 @@ __name(readNitroOutputPackage, "readNitroOutputPackage");
|
|
|
10022
10193
|
async function writeNitroOutputPackage(outputDir, packageJson, fs) {
|
|
10023
10194
|
await fs.mkdir(outputDir, { recursive: true });
|
|
10024
10195
|
await fs.writeFile(
|
|
10025
|
-
|
|
10196
|
+
path6.join(outputDir, "package.json"),
|
|
10026
10197
|
`${JSON.stringify(packageJson, null, 2)}
|
|
10027
10198
|
`
|
|
10028
10199
|
);
|
|
@@ -10039,18 +10210,18 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
10039
10210
|
}
|
|
10040
10211
|
}
|
|
10041
10212
|
try {
|
|
10042
|
-
let directory =
|
|
10043
|
-
while (directory !==
|
|
10044
|
-
const candidate =
|
|
10045
|
-
if (
|
|
10213
|
+
let directory = path6.dirname(metadataModule ?? parentRequire.resolve(packageName));
|
|
10214
|
+
while (directory !== path6.dirname(directory)) {
|
|
10215
|
+
const candidate = path6.join(directory, "package.json");
|
|
10216
|
+
if (existsSync2(candidate)) {
|
|
10046
10217
|
try {
|
|
10047
10218
|
const manifest = JSON.parse(readFileSync(candidate, "utf8"));
|
|
10048
10219
|
if (manifest.name === packageName) return candidate;
|
|
10049
10220
|
} catch {
|
|
10050
10221
|
}
|
|
10051
10222
|
}
|
|
10052
|
-
if (
|
|
10053
|
-
directory =
|
|
10223
|
+
if (path6.basename(directory) === "node_modules") break;
|
|
10224
|
+
directory = path6.dirname(directory);
|
|
10054
10225
|
}
|
|
10055
10226
|
} catch {
|
|
10056
10227
|
}
|
|
@@ -10058,23 +10229,23 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
10058
10229
|
}
|
|
10059
10230
|
__name(resolvePackageJson, "resolvePackageJson");
|
|
10060
10231
|
async function copyPrismaClientForVercel(root, nitroFuncDir, fs) {
|
|
10061
|
-
const projectRequire = createRequire(
|
|
10232
|
+
const projectRequire = createRequire(path6.join(root, "package.json"));
|
|
10062
10233
|
let prismaClientDir;
|
|
10063
10234
|
try {
|
|
10064
|
-
prismaClientDir =
|
|
10235
|
+
prismaClientDir = path6.dirname(projectRequire.resolve("@prisma/client/default.js"));
|
|
10065
10236
|
} catch {
|
|
10066
10237
|
return;
|
|
10067
10238
|
}
|
|
10068
|
-
const generatedClientDir =
|
|
10239
|
+
const generatedClientDir = path6.join(prismaClientDir, "..", "..", ".prisma", "client");
|
|
10069
10240
|
try {
|
|
10070
10241
|
await fs.access(generatedClientDir);
|
|
10071
10242
|
} catch {
|
|
10072
10243
|
return;
|
|
10073
10244
|
}
|
|
10074
|
-
const targetNodeModules =
|
|
10075
|
-
const targetPrismaScopeDir =
|
|
10076
|
-
const targetGeneratedDir =
|
|
10077
|
-
const targetClientDir =
|
|
10245
|
+
const targetNodeModules = path6.join(nitroFuncDir, "node_modules");
|
|
10246
|
+
const targetPrismaScopeDir = path6.join(targetNodeModules, "@prisma");
|
|
10247
|
+
const targetGeneratedDir = path6.join(targetNodeModules, ".prisma", "client");
|
|
10248
|
+
const targetClientDir = path6.join(targetPrismaScopeDir, "client");
|
|
10078
10249
|
await fs.mkdir(targetPrismaScopeDir, { recursive: true });
|
|
10079
10250
|
await fs.cp(prismaClientDir, targetClientDir, {
|
|
10080
10251
|
recursive: true,
|
|
@@ -10084,7 +10255,7 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs) {
|
|
|
10084
10255
|
recursive: true,
|
|
10085
10256
|
force: true
|
|
10086
10257
|
});
|
|
10087
|
-
const clientPackagePath =
|
|
10258
|
+
const clientPackagePath = path6.join(prismaClientDir, "package.json");
|
|
10088
10259
|
const [functionPackage, clientPackageContent] = await Promise.all([
|
|
10089
10260
|
readNitroOutputPackage(nitroFuncDir, fs),
|
|
10090
10261
|
fs.readFile(clientPackagePath, "utf-8")
|
|
@@ -10243,9 +10414,9 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
10243
10414
|
} else {
|
|
10244
10415
|
const { build: legacyViteBuild } = await import("vite");
|
|
10245
10416
|
logger.info("\u{1F4E6} Building client bundle...");
|
|
10246
|
-
await buildClient2(legacyViteBuild, config, root, srcDir,
|
|
10417
|
+
await buildClient2(legacyViteBuild, config, root, srcDir, path7.join(root, distDir, "client"));
|
|
10247
10418
|
logger.info("\u{1F4E6} Building SSR bundle...");
|
|
10248
|
-
await buildSSR(legacyViteBuild, config, root, srcDir,
|
|
10419
|
+
await buildSSR(legacyViteBuild, config, root, srcDir, path7.join(root, distDir, "server"));
|
|
10249
10420
|
logger.info(`\u{1F680} Building server with Nitro (preset: ${preset})...`);
|
|
10250
10421
|
await buildNitro(
|
|
10251
10422
|
config,
|
|
@@ -10425,17 +10596,17 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
|
10425
10596
|
}
|
|
10426
10597
|
__name(buildSSR, "buildSSR");
|
|
10427
10598
|
function resolveLegacyPageEntry(config, root, srcDir) {
|
|
10428
|
-
const appDir =
|
|
10599
|
+
const appDir = path7.join(root, srcDir, "app");
|
|
10429
10600
|
for (const extension of getFarmRendererComponentExtensions(config.renderer)) {
|
|
10430
|
-
const candidate =
|
|
10431
|
-
if (
|
|
10601
|
+
const candidate = path7.join(appDir, `page${extension}`);
|
|
10602
|
+
if (existsSync3(candidate)) return candidate;
|
|
10432
10603
|
}
|
|
10433
|
-
return
|
|
10604
|
+
return path7.join(appDir, "page.tsx");
|
|
10434
10605
|
}
|
|
10435
10606
|
__name(resolveLegacyPageEntry, "resolveLegacyPageEntry");
|
|
10436
10607
|
async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
|
|
10437
10608
|
const [{ createNitroConfig }, { createNitro, build: nitroBuild }] = await Promise.all([
|
|
10438
|
-
import("./nitro-
|
|
10609
|
+
import("./nitro-4XGPNIK4.mjs"),
|
|
10439
10610
|
import("nitro/builder")
|
|
10440
10611
|
]);
|
|
10441
10612
|
let nitroConfig = await createNitroConfig(
|
|
@@ -10449,18 +10620,18 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
10449
10620
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
10450
10621
|
}
|
|
10451
10622
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
10452
|
-
const serverOutputDir =
|
|
10453
|
-
const publicOutputDir =
|
|
10623
|
+
const serverOutputDir = path7.join(outputDir, "server");
|
|
10624
|
+
const publicOutputDir = path7.join(outputDir, "public");
|
|
10454
10625
|
const { mkdir, cp } = await import("fs/promises");
|
|
10455
10626
|
await mkdir(serverOutputDir, { recursive: true });
|
|
10456
10627
|
await mkdir(publicOutputDir, { recursive: true });
|
|
10457
|
-
const clientDir =
|
|
10628
|
+
const clientDir = path7.join(root, distDir, "client");
|
|
10458
10629
|
try {
|
|
10459
10630
|
await mkdir(publicOutputDir, { recursive: true });
|
|
10460
10631
|
await cp(clientDir, publicOutputDir, { recursive: true });
|
|
10461
10632
|
logger.info("\u{1F4E6} Copied client assets to public directory");
|
|
10462
|
-
const manifestPath =
|
|
10463
|
-
const assetsDir =
|
|
10633
|
+
const manifestPath = path7.join(publicOutputDir, "farm-client-manifest.json");
|
|
10634
|
+
const assetsDir = path7.join(publicOutputDir, "assets");
|
|
10464
10635
|
const manifestExists = await import("fs/promises").then(
|
|
10465
10636
|
(fs) => fs.access(manifestPath).then(() => true).catch(() => false)
|
|
10466
10637
|
);
|
|
@@ -10476,8 +10647,8 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
10476
10647
|
logger.error(`\u274C Failed to copy client assets: ${error}`);
|
|
10477
10648
|
throw error;
|
|
10478
10649
|
}
|
|
10479
|
-
const serverDir =
|
|
10480
|
-
const nitroServerDir =
|
|
10650
|
+
const serverDir = path7.join(root, distDir, "server");
|
|
10651
|
+
const nitroServerDir = path7.join(root, distDir, ".nitro", "server", "farm");
|
|
10481
10652
|
try {
|
|
10482
10653
|
await mkdir(nitroServerDir, { recursive: true });
|
|
10483
10654
|
await cp(serverDir, nitroServerDir, { recursive: true });
|
|
@@ -10486,7 +10657,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
10486
10657
|
logger.warn(`Could not copy SSR bundles: ${error}`);
|
|
10487
10658
|
}
|
|
10488
10659
|
const nitro = await createNitro(nitroConfig);
|
|
10489
|
-
const registryPath =
|
|
10660
|
+
const registryPath = path7.join(root, distDir, ".nitro", "server", "farm-registry.ts");
|
|
10490
10661
|
try {
|
|
10491
10662
|
const { farmRegistry } = await import(
|
|
10492
10663
|
/* @vite-ignore */
|
|
@@ -10503,7 +10674,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
10503
10674
|
}
|
|
10504
10675
|
farmRegistry.routePaths = routePaths;
|
|
10505
10676
|
try {
|
|
10506
|
-
const clientManifestPath =
|
|
10677
|
+
const clientManifestPath = path7.join(root, distDir, "client", "farm-client-manifest.json");
|
|
10507
10678
|
const { readFile } = await import("fs/promises");
|
|
10508
10679
|
const manifestContent = await readFile(clientManifestPath, "utf-8");
|
|
10509
10680
|
farmRegistry.clientManifest = JSON.parse(manifestContent);
|