@farm.js/core 0.1.30 → 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-HPQC2LHF.cjs → chunk-36MK5YCW.cjs} +342 -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-6G3ZZ2IE.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-ZDILFMWN.cjs → chunk-A5FGU2WU.cjs} +74 -23
- package/dist/{chunk-BZ3CHOFX.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-BZAGKCKB.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-D234YWNA.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-IVLUJUT4.mjs → chunk-LR5QSC2P.mjs} +388 -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-YMUE7L3D.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-PQD2AI3B.mjs → chunk-O27L4YAA.mjs} +1 -1
- package/dist/{chunk-X5TXZFMN.cjs → chunk-ODBZYBAB.cjs} +1 -1
- package/dist/{chunk-NPPL5YDT.cjs → chunk-P64MIF5B.cjs} +154 -6
- package/dist/{chunk-JFHKNFEO.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-GIWC4CFJ.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-2UABTL3Y.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-NXG66MR7.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-K6V52QMI.mjs → chunk-X242HVD5.mjs} +1 -1
- package/dist/{chunk-UJ2C4ICS.cjs → chunk-XJXBIP67.cjs} +4 -4
- package/dist/{chunk-S4K74WI4.mjs → chunk-XV5DJTBX.mjs} +539 -121
- package/dist/{chunk-6CNX6Q3K.cjs → chunk-XXJU7FCC.cjs} +9 -5
- 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-Q5JFU33Q.cjs → chunk-Z2YLTERK.cjs} +4 -4
- package/dist/{chunk-XLTV4VOG.cjs → chunk-ZHPHJPQP.cjs} +4 -4
- package/dist/{chunk-7CXKSRKL.mjs → chunk-ZKP7C2B6.mjs} +4 -4
- package/dist/{chunk-ATXI6LGT.mjs → chunk-ZUSJDQ2Q.mjs} +8 -4
- 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-GGVPZHJX.cjs → devtools-HU6Y2MNV.cjs} +11 -9
- package/dist/{devtools-THVNPI2M.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(
|
|
@@ -5986,6 +6096,9 @@ const farmDocsHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsP
|
|
|
5986
6096
|
contentDir: farmDocsResolvedConfig.contentDir || farmDocsResolvedConfig.config?.contentDir,
|
|
5987
6097
|
}, {
|
|
5988
6098
|
rootDir: farmDocsRuntimeRoot,
|
|
6099
|
+
// A production build's content cannot change, so the adapter reads its
|
|
6100
|
+
// navigation once instead of scanning the content directory per request.
|
|
6101
|
+
immutableContent: true,
|
|
5989
6102
|
clientEntry: "/__farm_client_js_src__",
|
|
5990
6103
|
// Font CSS is merged into the client stylesheet; farm-fonts.css only exists when the
|
|
5991
6104
|
// app has fonts, so linking it separately 404'd for apps without them.
|
|
@@ -6011,10 +6124,17 @@ const farmDocsAPIHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDo
|
|
|
6011
6124
|
|
|
6012
6125
|
// API routes bundled at build time
|
|
6013
6126
|
const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
|
|
6014
|
-
]${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)} })` : ""};
|
|
6015
6128
|
const farmLocalAPIBasePath = ${JSON.stringify(resolveFarmAPIServerBasePath(config.api))};
|
|
6016
6129
|
const farmOpenAPIReference = ${JSON.stringify(openAPIReference)};
|
|
6017
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
|
+
)};
|
|
6018
6138
|
` : ""}
|
|
6019
6139
|
function isFarmLocalAPIPathname(pathname) {
|
|
6020
6140
|
return farmLocalAPIBasePath !== "/" &&
|
|
@@ -6083,9 +6203,12 @@ function getFarmI18nSnapshot() {
|
|
|
6083
6203
|
return ${config.i18n.enabled ? "getFarmI18nClientSnapshot()" : "undefined"};
|
|
6084
6204
|
}
|
|
6085
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.
|
|
6086
6209
|
function getFarmRoutePathname(pathname) {
|
|
6087
6210
|
return farmI18nRuntime
|
|
6088
|
-
? stripFarmLocaleFromPathname(
|
|
6211
|
+
? stripFarmLocaleFromPathname(pathname, farmI18nConfig)
|
|
6089
6212
|
: stripFarmBasePath(pathname);
|
|
6090
6213
|
}
|
|
6091
6214
|
|
|
@@ -7027,6 +7150,7 @@ const farmMiddlewareRunner = ${hasMiddlewareRuntime ? `createProductionMiddlewar
|
|
|
7027
7150
|
modules: fileMiddlewareModules,
|
|
7028
7151
|
i18n: farmI18nConfig,
|
|
7029
7152
|
server: farmServerConfig,
|
|
7153
|
+
apiBasePath: farmLocalAPIBasePath,
|
|
7030
7154
|
})` : "null"};
|
|
7031
7155
|
|
|
7032
7156
|
${apiHandlerCode}
|
|
@@ -7447,6 +7571,12 @@ function getPPRHeaders(status, config) {
|
|
|
7447
7571
|
return headers;
|
|
7448
7572
|
}
|
|
7449
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
|
+
|
|
7450
7580
|
function getRouteSharedCacheControl(route, pprCanCache) {
|
|
7451
7581
|
if (!route || !route.module) {
|
|
7452
7582
|
return null;
|
|
@@ -7659,7 +7789,8 @@ async function handleFarmRequestInContext(
|
|
|
7659
7789
|
|
|
7660
7790
|
${hasMarkdownPages ? `
|
|
7661
7791
|
// The raw markdown source of a page route is the page's content in another
|
|
7662
|
-
// 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.
|
|
7663
7794
|
const markdownSourceResponse = await createFarmMarkdownSourceResponse?.({
|
|
7664
7795
|
request: cloneFarmRequestWithContext(request),
|
|
7665
7796
|
config: farmMdxConfig,
|
|
@@ -7667,9 +7798,12 @@ async function handleFarmRequestInContext(
|
|
|
7667
7798
|
const match = matchPageRoute(getFarmRoutePathname(targetPathname));
|
|
7668
7799
|
return match?.route?.markdownSource || null;
|
|
7669
7800
|
},
|
|
7801
|
+
renderPage: (targetRequest) => handleFarmRequest(targetRequest, adapterContext),
|
|
7670
7802
|
});
|
|
7671
7803
|
if (markdownSourceResponse) {
|
|
7672
|
-
return
|
|
7804
|
+
return isFarmMarkdownPublicSourceResponse(markdownSourceResponse)
|
|
7805
|
+
? markdownSourceResponse
|
|
7806
|
+
: applyProductionMiddlewareHeaders(markdownSourceResponse, middlewareHeaders);
|
|
7673
7807
|
}
|
|
7674
7808
|
` : ""}
|
|
7675
7809
|
|
|
@@ -7772,6 +7906,17 @@ async function handleFarmRequestInContext(
|
|
|
7772
7906
|
return applyProductionMiddlewareHeaders(applicationMetadataResponse, middlewareHeaders);
|
|
7773
7907
|
}
|
|
7774
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
|
+
` : ""}
|
|
7775
7920
|
${config.agent?.apiCatalog ? `
|
|
7776
7921
|
// agent.apiCatalog: list the OpenAPI and MCP surfaces at the RFC 9727 path.
|
|
7777
7922
|
if (normalizeRuntimePath(routePathname) === ${JSON.stringify(FARM_API_CATALOG_PATH)}) {
|
|
@@ -7910,6 +8055,9 @@ async function handleFarmRequestInContext(
|
|
|
7910
8055
|
emitFarmEvent({ type: "ppr.shell.miss", route: pathname, key: pprCacheKey });
|
|
7911
8056
|
}
|
|
7912
8057
|
|
|
8058
|
+
// Reads from here on belong to the page render, not to middleware.
|
|
8059
|
+
const requestReadsBeforeRender = _getRequestReadCount();
|
|
8060
|
+
|
|
7913
8061
|
// Get the page component and metadata
|
|
7914
8062
|
let PageComponent = route.module.default;
|
|
7915
8063
|
let pageStatus = 200;
|
|
@@ -7969,6 +8117,10 @@ async function handleFarmRequestInContext(
|
|
|
7969
8117
|
});
|
|
7970
8118
|
}
|
|
7971
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;
|
|
7972
8124
|
try {
|
|
7973
8125
|
// Resolve top-level route state before starting the HTTP stream so
|
|
7974
8126
|
// redirects, notFound(), and failures keep their real status. Route
|
|
@@ -8003,6 +8155,7 @@ async function handleFarmRequestInContext(
|
|
|
8003
8155
|
} catch (routeStateError) {
|
|
8004
8156
|
if (isFarmRedirectError(routeStateError)) throw routeStateError;
|
|
8005
8157
|
|
|
8158
|
+
routeStateRejected = true;
|
|
8006
8159
|
const routeComponents = route.module.__farmRouteComponents;
|
|
8007
8160
|
const routeStateProps = {
|
|
8008
8161
|
...rawPageProps,
|
|
@@ -8092,7 +8245,9 @@ async function handleFarmRequestInContext(
|
|
|
8092
8245
|
...(pageProps.__farmCanonicalPath
|
|
8093
8246
|
? { __farmCanonicalPath: pageProps.__farmCanonicalPath }
|
|
8094
8247
|
: {}),
|
|
8095
|
-
|
|
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)
|
|
8096
8251
|
? { __farmRoutePropsResolved: true }
|
|
8097
8252
|
: {}),
|
|
8098
8253
|
path: pathname,
|
|
@@ -8214,7 +8369,7 @@ async function handleFarmRequestInContext(
|
|
|
8214
8369
|
// the request's resolved Suspense content. Until the production runtime
|
|
8215
8370
|
// can persist and resume the partial shell itself, buffer streamed PPR
|
|
8216
8371
|
// responses for late status errors but do not cache their dynamic HTML.
|
|
8217
|
-
|
|
8372
|
+
let shouldCachePPRShell = Boolean(pprCacheKey && !renderedPage.stream);
|
|
8218
8373
|
if (!shouldCachePPRShell && pprCacheKey) {
|
|
8219
8374
|
pprCanCache = false;
|
|
8220
8375
|
emitFarmEvent({
|
|
@@ -8238,7 +8393,7 @@ async function handleFarmRequestInContext(
|
|
|
8238
8393
|
}
|
|
8239
8394
|
}
|
|
8240
8395
|
mergedMetadata = mergeMetadata(mergedMetadata, pageMetadata);
|
|
8241
|
-
if (typeof route.module.generateMetadata === "function") {
|
|
8396
|
+
if (!routeStateRejected && typeof route.module.generateMetadata === "function") {
|
|
8242
8397
|
mergedMetadata = mergeMetadata(
|
|
8243
8398
|
mergedMetadata,
|
|
8244
8399
|
await route.module.generateMetadata(pageProps),
|
|
@@ -8272,6 +8427,17 @@ async function handleFarmRequestInContext(
|
|
|
8272
8427
|
getFarmMarkdownAlternatePath(farmMarkdownConfig, pathname),
|
|
8273
8428
|
);` : ""}
|
|
8274
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
|
+
|
|
8275
8441
|
const renderedMetadata = renderMetadataHead(mergedMetadata, { pathname, jsonLd: ${JSON.stringify(config.agent?.jsonLd ?? false)} });
|
|
8276
8442
|
const title = renderedMetadata.title;
|
|
8277
8443
|
const metaTags = renderedMetadata.tags;
|
|
@@ -8283,6 +8449,7 @@ async function handleFarmRequestInContext(
|
|
|
8283
8449
|
);
|
|
8284
8450
|
const hasRequestScopedRender = Boolean(
|
|
8285
8451
|
pageStatus >= 400 ||
|
|
8452
|
+
renderReadRequest ||
|
|
8286
8453
|
request.headers.get("x-farm-intercept-from") ||
|
|
8287
8454
|
hasPrivateRequestHeaders ||
|
|
8288
8455
|
hasConfiguredRouteContext ||
|
|
@@ -9034,23 +9201,20 @@ function configMiddlewareMayHandlePath(config, pathname) {
|
|
|
9034
9201
|
if (!hasFarmMiddlewareConfig(config)) return false;
|
|
9035
9202
|
const entries = Array.isArray(config) ? config : [config];
|
|
9036
9203
|
return entries.some((entry) => {
|
|
9037
|
-
if (entry.exclude
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
});
|
|
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;
|
|
9046
9213
|
});
|
|
9047
9214
|
}
|
|
9048
9215
|
__name(configMiddlewareMayHandlePath, "configMiddlewareMayHandlePath");
|
|
9049
9216
|
function appMiddlewareMayHandlePath(middlewareRoutes, pathname) {
|
|
9050
|
-
return middlewareRoutes.some((route) =>
|
|
9051
|
-
if (route.path === "/") return true;
|
|
9052
|
-
return middlewarePatternMatches(route.path, pathname) || middlewarePatternMatches(`${route.path}/**`, pathname);
|
|
9053
|
-
});
|
|
9217
|
+
return middlewareRoutes.some((route) => matchesMiddlewareRoute(pathname, route).matched);
|
|
9054
9218
|
}
|
|
9055
9219
|
__name(appMiddlewareMayHandlePath, "appMiddlewareMayHandlePath");
|
|
9056
9220
|
function routePatternSpecificity(pattern) {
|
|
@@ -9117,8 +9281,8 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
9117
9281
|
const isVercel = preset === "vercel" || preset === "vercel-edge";
|
|
9118
9282
|
const isCloudflareWorker = preset === "cloudflare-module";
|
|
9119
9283
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
9120
|
-
const runtimeServerOutputDir = isVercel ?
|
|
9121
|
-
const ssrOutputDir =
|
|
9284
|
+
const runtimeServerOutputDir = isVercel ? path6.join(outputDir, "functions", "__nitro.func") : path6.join(outputDir, "server");
|
|
9285
|
+
const ssrOutputDir = path6.join(root, distDir, "ssr");
|
|
9122
9286
|
const imageRuntime = resolveImageRuntime(config, preset);
|
|
9123
9287
|
const hasGeneratedMetadataImages = Array.from(routeManager.getMetadataImages().values()).some(
|
|
9124
9288
|
(image) => image.sourceType === "module"
|
|
@@ -9202,11 +9366,11 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
9202
9366
|
}
|
|
9203
9367
|
await fs.mkdir(ssrOutputDir, { recursive: true });
|
|
9204
9368
|
for (const [fileName, output] of Object.entries(ssrBundle)) {
|
|
9205
|
-
const filePath =
|
|
9206
|
-
await fs.mkdir(
|
|
9369
|
+
const filePath = path6.join(ssrOutputDir, fileName);
|
|
9370
|
+
await fs.mkdir(path6.dirname(filePath), { recursive: true });
|
|
9207
9371
|
await fs.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
|
|
9208
9372
|
}
|
|
9209
|
-
const nitroEntryPath =
|
|
9373
|
+
const nitroEntryPath = path6.join(ssrOutputDir, "nitro-entry.mjs");
|
|
9210
9374
|
const nodeAdapterModule = preset === "node-server" ? resolveNitroRuntimeDependency(root, "srvx/node") : null;
|
|
9211
9375
|
const nitroEntryCode = `
|
|
9212
9376
|
// Farm.js Nitro Entry
|
|
@@ -9359,18 +9523,27 @@ function toFarmNodeResponse(request, response) {
|
|
|
9359
9523
|
}` : ""}
|
|
9360
9524
|
`.trim();
|
|
9361
9525
|
await fs.writeFile(nitroEntryPath, nitroEntryCode);
|
|
9362
|
-
const farmNodeServerEntryPath = preset === "node-server" ?
|
|
9526
|
+
const farmNodeServerEntryPath = preset === "node-server" ? path6.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
|
|
9363
9527
|
if (farmNodeServerEntryPath && nodeAdapterModule) {
|
|
9364
9528
|
await fs.writeFile(
|
|
9365
9529
|
farmNodeServerEntryPath,
|
|
9366
9530
|
createFarmNodeServerEntry({
|
|
9367
|
-
nitroEntryFile:
|
|
9531
|
+
nitroEntryFile: path6.basename(nitroEntryPath),
|
|
9368
9532
|
nodeAdapterModule,
|
|
9369
9533
|
server: config.server,
|
|
9370
9534
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/node")
|
|
9371
9535
|
})
|
|
9372
9536
|
);
|
|
9373
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
|
+
}
|
|
9374
9547
|
const prebuiltSSRPlugin = createExternalSSRBundlePlugin(
|
|
9375
9548
|
nitroEntryPath,
|
|
9376
9549
|
ssrOutputDir,
|
|
@@ -9396,6 +9569,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
9396
9569
|
let nitroConfig = {
|
|
9397
9570
|
preset,
|
|
9398
9571
|
...farmNodeServerEntryPath ? { entry: farmNodeServerEntryPath } : {},
|
|
9572
|
+
...farmNetlifyEntryPath ? { entry: farmNetlifyEntryPath } : {},
|
|
9399
9573
|
rootDir: root,
|
|
9400
9574
|
// Farm registers every handler, task, and plugin explicitly. Scanning the
|
|
9401
9575
|
// project root would bundle an app's own `middleware/`, `api/`, `routes/`,
|
|
@@ -9403,7 +9577,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
9403
9577
|
// `src` directory), as Nitro handlers outside Farm's aliases.
|
|
9404
9578
|
serverDir: false,
|
|
9405
9579
|
serverEntry: false,
|
|
9406
|
-
buildDir:
|
|
9580
|
+
buildDir: path6.join(root, distDir, ".nitro"),
|
|
9407
9581
|
alias: resolveNitroInternalRuntimeAliases(root),
|
|
9408
9582
|
compatibilityDate: "2024-12-01",
|
|
9409
9583
|
output: resolveFarmNitroOutputConfig(preset, outputDir),
|
|
@@ -9414,6 +9588,11 @@ function toFarmNodeResponse(request, response) {
|
|
|
9414
9588
|
baseURL: "/"
|
|
9415
9589
|
}
|
|
9416
9590
|
],
|
|
9591
|
+
// A self-hosted Node server sends static files itself, so precompress them
|
|
9592
|
+
// with gzip and let Nitro serve that by Accept-Encoding. Brotli at Nitro's
|
|
9593
|
+
// fixed top quality cost a docs app ~20 s of build CPU for a small further
|
|
9594
|
+
// saving. Serverless and edge targets sit behind a CDN that compresses.
|
|
9595
|
+
...preset === "node-server" ? { compressPublicAssets: { gzip: true } } : {},
|
|
9417
9596
|
...prerenderRoutes.length > 0 ? {
|
|
9418
9597
|
prerender: {
|
|
9419
9598
|
crawlLinks: false,
|
|
@@ -9474,7 +9653,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
9474
9653
|
if (pluginManager) {
|
|
9475
9654
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
9476
9655
|
}
|
|
9477
|
-
const expectedServerDir =
|
|
9656
|
+
const expectedServerDir = path6.join(outputDir, "server");
|
|
9478
9657
|
const customRollupKeys = Object.keys(nitroConfig.rollupConfig || {}).filter(
|
|
9479
9658
|
(key) => key !== "external" && key !== "plugins"
|
|
9480
9659
|
);
|
|
@@ -9487,9 +9666,9 @@ function toFarmNodeResponse(request, response) {
|
|
|
9487
9666
|
snapshotSSRRebundleOptions(nitroConfig)
|
|
9488
9667
|
);
|
|
9489
9668
|
const requestedBuilder = nitroConfig.builder ?? process.env.NITRO_BUILDER;
|
|
9490
|
-
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(
|
|
9491
9670
|
nitroConfig.handlers?.some(
|
|
9492
|
-
(handler) =>
|
|
9671
|
+
(handler) => path6.resolve(handler?.handler || "") === nitroEntryPath
|
|
9493
9672
|
)
|
|
9494
9673
|
);
|
|
9495
9674
|
const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
|
|
@@ -9550,7 +9729,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
9550
9729
|
nitroInstance.routing.sync();
|
|
9551
9730
|
});
|
|
9552
9731
|
}
|
|
9553
|
-
if (farmNodeServerEntryPath) {
|
|
9732
|
+
if (farmNodeServerEntryPath || farmNetlifyEntryPath) {
|
|
9554
9733
|
nitroInstance.hooks.hook("prerender:config", (prerendererConfig) => {
|
|
9555
9734
|
delete prerendererConfig.entry;
|
|
9556
9735
|
});
|
|
@@ -9576,10 +9755,10 @@ function toFarmNodeResponse(request, response) {
|
|
|
9576
9755
|
});
|
|
9577
9756
|
}
|
|
9578
9757
|
prerenderer.hooks.hook("compiled", async () => {
|
|
9579
|
-
const prerenderServerDir =
|
|
9758
|
+
const prerenderServerDir = path6.join(outputDir, "server");
|
|
9580
9759
|
await copyPrebuiltSSRBundle(
|
|
9581
9760
|
ssrBundle,
|
|
9582
|
-
|
|
9761
|
+
path6.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
|
|
9583
9762
|
null,
|
|
9584
9763
|
fs
|
|
9585
9764
|
);
|
|
@@ -9652,7 +9831,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
9652
9831
|
const copyResults = await Promise.allSettled([
|
|
9653
9832
|
prebuiltSSRFilesResult.value ? writeSSRBundleFiles(
|
|
9654
9833
|
prebuiltSSRFilesResult.value,
|
|
9655
|
-
|
|
9834
|
+
path6.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
|
|
9656
9835
|
fs
|
|
9657
9836
|
) : Promise.resolve(),
|
|
9658
9837
|
runtimeCopyPromise
|
|
@@ -9662,7 +9841,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
9662
9841
|
);
|
|
9663
9842
|
if (failedCopy) throw failedCopy.reason;
|
|
9664
9843
|
if (canReusePrebuiltSSR) {
|
|
9665
|
-
await registerPrebuiltSSRPackageImport(
|
|
9844
|
+
await registerPrebuiltSSRPackageImport(path6.join(outputDir, "server"), ssrEntryFile, fs);
|
|
9666
9845
|
logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
|
|
9667
9846
|
}
|
|
9668
9847
|
if (useRolldownBuilder) {
|
|
@@ -9687,11 +9866,11 @@ function resolveFarmNitroOutputConfig(preset, outputDir) {
|
|
|
9687
9866
|
return {
|
|
9688
9867
|
dir: outputDir,
|
|
9689
9868
|
...preset === "node-server" ? {
|
|
9690
|
-
serverDir:
|
|
9691
|
-
publicDir:
|
|
9869
|
+
serverDir: path6.join(outputDir, "server"),
|
|
9870
|
+
publicDir: path6.join(outputDir, "public")
|
|
9692
9871
|
} : isVercel ? {
|
|
9693
|
-
serverDir:
|
|
9694
|
-
publicDir:
|
|
9872
|
+
serverDir: path6.join(outputDir, "functions", "__nitro.func"),
|
|
9873
|
+
publicDir: path6.join(outputDir, "static")
|
|
9695
9874
|
} : {}
|
|
9696
9875
|
};
|
|
9697
9876
|
}
|
|
@@ -9709,8 +9888,8 @@ async function writeSSRBundleFiles(files, targetDir, fs) {
|
|
|
9709
9888
|
await fs.rm(targetDir, { recursive: true, force: true });
|
|
9710
9889
|
await Promise.all(
|
|
9711
9890
|
files.map(async ({ fileName, contents }) => {
|
|
9712
|
-
const targetPath =
|
|
9713
|
-
await fs.mkdir(
|
|
9891
|
+
const targetPath = path6.join(targetDir, fileName);
|
|
9892
|
+
await fs.mkdir(path6.dirname(targetPath), { recursive: true });
|
|
9714
9893
|
await fs.writeFile(targetPath, contents);
|
|
9715
9894
|
})
|
|
9716
9895
|
);
|
|
@@ -9721,7 +9900,7 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions, fs) {
|
|
|
9721
9900
|
}
|
|
9722
9901
|
__name(copyPrebuiltSSRBundle, "copyPrebuiltSSRBundle");
|
|
9723
9902
|
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs) {
|
|
9724
|
-
const packagePath =
|
|
9903
|
+
const packagePath = path6.join(serverDir, "package.json");
|
|
9725
9904
|
const packageJSON = await fs.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
9726
9905
|
if (error.code === "ENOENT") return { type: "module" };
|
|
9727
9906
|
throw error;
|
|
@@ -9752,18 +9931,18 @@ async function moveVercelOutputPath(src, dest, fs) {
|
|
|
9752
9931
|
}
|
|
9753
9932
|
__name(moveVercelOutputPath, "moveVercelOutputPath");
|
|
9754
9933
|
async function postProcessVercelOutput(root, outputDir, fs, config, farmWorkflows, routeRuntimeManifest) {
|
|
9755
|
-
const serverDir =
|
|
9756
|
-
const functionsDir =
|
|
9757
|
-
const nitroFuncDir =
|
|
9758
|
-
const staticDir =
|
|
9759
|
-
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");
|
|
9760
9939
|
await fs.mkdir(nitroFuncDir, { recursive: true });
|
|
9761
9940
|
const serverContents = await fs.readdir(serverDir).catch((error) => {
|
|
9762
9941
|
if (error.code === "ENOENT") return [];
|
|
9763
9942
|
throw error;
|
|
9764
9943
|
});
|
|
9765
9944
|
for (const file of serverContents) {
|
|
9766
|
-
await moveVercelOutputPath(
|
|
9945
|
+
await moveVercelOutputPath(path6.join(serverDir, file), path6.join(nitroFuncDir, file), fs);
|
|
9767
9946
|
}
|
|
9768
9947
|
if (serverContents.length > 0) await fs.rm(serverDir, { recursive: true, force: true });
|
|
9769
9948
|
try {
|
|
@@ -9773,7 +9952,7 @@ async function postProcessVercelOutput(root, outputDir, fs, config, farmWorkflow
|
|
|
9773
9952
|
}
|
|
9774
9953
|
await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs);
|
|
9775
9954
|
await copyPrismaClientForVercel(root, nitroFuncDir, fs);
|
|
9776
|
-
const configPath =
|
|
9955
|
+
const configPath = path6.join(outputDir, "config.json");
|
|
9777
9956
|
const configContent = await fs.readFile(configPath, "utf-8");
|
|
9778
9957
|
const vercelConfig = JSON.parse(configContent);
|
|
9779
9958
|
const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
|
|
@@ -9801,22 +9980,22 @@ __name(postProcessVercelOutput, "postProcessVercelOutput");
|
|
|
9801
9980
|
async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs) {
|
|
9802
9981
|
const docsContentDir = resolveBuildDocsContentDir(config, root);
|
|
9803
9982
|
if (!docsContentDir) return;
|
|
9804
|
-
const bundledContentDir =
|
|
9983
|
+
const bundledContentDir = path6.join(nitroFuncDir, "farm-docs-content");
|
|
9805
9984
|
const lastModifiedManifest = createFarmDocsLastModifiedManifest(docsContentDir, {
|
|
9806
9985
|
fallback: "now"
|
|
9807
9986
|
});
|
|
9808
9987
|
await fs.rm(bundledContentDir, { recursive: true, force: true });
|
|
9809
|
-
await fs.mkdir(
|
|
9988
|
+
await fs.mkdir(path6.dirname(bundledContentDir), { recursive: true });
|
|
9810
9989
|
await fs.cp(docsContentDir, bundledContentDir, {
|
|
9811
9990
|
recursive: true,
|
|
9812
9991
|
force: true
|
|
9813
9992
|
});
|
|
9814
9993
|
await fs.writeFile(
|
|
9815
|
-
|
|
9994
|
+
path6.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
|
|
9816
9995
|
`${JSON.stringify(lastModifiedManifest, null, 2)}
|
|
9817
9996
|
`
|
|
9818
9997
|
);
|
|
9819
|
-
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${
|
|
9998
|
+
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path6.relative(root, docsContentDir)}`);
|
|
9820
9999
|
}
|
|
9821
10000
|
__name(copyFarmDocsContentForVercel, "copyFarmDocsContentForVercel");
|
|
9822
10001
|
function resolveServerFunctionPlatform(preset) {
|
|
@@ -9837,7 +10016,7 @@ function platformFieldAllows(field, value) {
|
|
|
9837
10016
|
__name(platformFieldAllows, "platformFieldAllows");
|
|
9838
10017
|
async function stageSharpRuntime(config, root, distDir, fs, preset) {
|
|
9839
10018
|
const functionPlatform = resolveServerFunctionPlatform(preset);
|
|
9840
|
-
const projectRequire = createRequire(
|
|
10019
|
+
const projectRequire = createRequire(path6.join(root, "package.json"));
|
|
9841
10020
|
let sharpRequire = projectRequire;
|
|
9842
10021
|
if (!resolvePackageJson(projectRequire, "sharp")) {
|
|
9843
10022
|
try {
|
|
@@ -9847,10 +10026,10 @@ async function stageSharpRuntime(config, root, distDir, fs, preset) {
|
|
|
9847
10026
|
}
|
|
9848
10027
|
const copiedPackages = /* @__PURE__ */ new Map();
|
|
9849
10028
|
const packageCopies = /* @__PURE__ */ new Map();
|
|
9850
|
-
const stageRoot =
|
|
10029
|
+
const stageRoot = path6.join(root, distDir, "tmp");
|
|
9851
10030
|
await fs.mkdir(stageRoot, { recursive: true });
|
|
9852
|
-
const stageDir = await fs.mkdtemp(
|
|
9853
|
-
const targetNodeModules =
|
|
10031
|
+
const stageDir = await fs.mkdtemp(path6.join(stageRoot, "sharp-runtime-"));
|
|
10032
|
+
const targetNodeModules = path6.join(stageDir, "node_modules");
|
|
9854
10033
|
function copyPackage(packageName, parentRequire) {
|
|
9855
10034
|
const activeCopy = packageCopies.get(packageName);
|
|
9856
10035
|
if (activeCopy) return activeCopy;
|
|
@@ -9864,10 +10043,10 @@ async function stageSharpRuntime(config, root, distDir, fs, preset) {
|
|
|
9864
10043
|
if (!packageJsonPath) return;
|
|
9865
10044
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
|
|
9866
10045
|
if (functionPlatform && !packageSupportsPlatform(packageJson, functionPlatform)) return;
|
|
9867
|
-
const packageDir =
|
|
9868
|
-
const targetDir =
|
|
10046
|
+
const packageDir = path6.dirname(packageJsonPath);
|
|
10047
|
+
const targetDir = path6.join(targetNodeModules, ...packageName.split("/"));
|
|
9869
10048
|
copiedPackages.set(packageName, String(packageJson.version || "*"));
|
|
9870
|
-
await fs.mkdir(
|
|
10049
|
+
await fs.mkdir(path6.dirname(targetDir), { recursive: true });
|
|
9871
10050
|
const packageRequire = createRequire(packageJsonPath);
|
|
9872
10051
|
const dependencies = {
|
|
9873
10052
|
...packageJson.dependencies,
|
|
@@ -9904,8 +10083,8 @@ async function stageSharpRuntime(config, root, distDir, fs, preset) {
|
|
|
9904
10083
|
}
|
|
9905
10084
|
__name(stageSharpRuntime, "stageSharpRuntime");
|
|
9906
10085
|
async function installStagedSharpRuntime(staged, nitroFuncDir, fs) {
|
|
9907
|
-
const stagedNodeModules =
|
|
9908
|
-
const targetNodeModules =
|
|
10086
|
+
const stagedNodeModules = path6.join(staged.stageDir, "node_modules");
|
|
10087
|
+
const targetNodeModules = path6.join(nitroFuncDir, "node_modules");
|
|
9909
10088
|
try {
|
|
9910
10089
|
await mergeStagedDirectory(stagedNodeModules, targetNodeModules, fs);
|
|
9911
10090
|
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs);
|
|
@@ -9935,8 +10114,8 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs) {
|
|
|
9935
10114
|
const entries = await fs.readdir(sourceDir, { withFileTypes: true });
|
|
9936
10115
|
await settleAllOrThrow(
|
|
9937
10116
|
entries.map(async (entry) => {
|
|
9938
|
-
const sourcePath =
|
|
9939
|
-
const targetPath =
|
|
10117
|
+
const sourcePath = path6.join(sourceDir, entry.name);
|
|
10118
|
+
const targetPath = path6.join(targetDir, entry.name);
|
|
9940
10119
|
try {
|
|
9941
10120
|
await fs.rename(sourcePath, targetPath);
|
|
9942
10121
|
return;
|
|
@@ -9964,14 +10143,14 @@ __name(mergeStagedDirectory, "mergeStagedDirectory");
|
|
|
9964
10143
|
function assertMetadataImageRuntimeInstalled(root, metadataImageRoutes) {
|
|
9965
10144
|
const generated = metadataImageRoutes.find((image) => image.sourceType === "module");
|
|
9966
10145
|
if (!generated || resolveMetadataImageRuntimePackageJson(root)) return;
|
|
9967
|
-
const file = generated.modulePath ? toPosixPath(
|
|
10146
|
+
const file = generated.modulePath ? toPosixPath(path6.relative(root, generated.modulePath)) : "";
|
|
9968
10147
|
throw new Error(
|
|
9969
10148
|
`${file || "A generated metadata image"} renders with @vercel/og, which is not installed. ${VERCEL_OG_INSTALL_HINT}`
|
|
9970
10149
|
);
|
|
9971
10150
|
}
|
|
9972
10151
|
__name(assertMetadataImageRuntimeInstalled, "assertMetadataImageRuntimeInstalled");
|
|
9973
10152
|
function resolveMetadataImageRuntimePackageJson(root) {
|
|
9974
|
-
const projectRequire = createRequire(
|
|
10153
|
+
const projectRequire = createRequire(path6.join(root, "package.json"));
|
|
9975
10154
|
const packageJsonPath = resolvePackageJson(projectRequire, "@vercel/og");
|
|
9976
10155
|
if (packageJsonPath) return packageJsonPath;
|
|
9977
10156
|
try {
|
|
@@ -9985,9 +10164,9 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs) {
|
|
|
9985
10164
|
const packageJsonPath = resolveMetadataImageRuntimePackageJson(root);
|
|
9986
10165
|
if (!packageJsonPath) return;
|
|
9987
10166
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
|
|
9988
|
-
const packageDir =
|
|
9989
|
-
const targetDir =
|
|
9990
|
-
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 });
|
|
9991
10170
|
await fs.cp(packageDir, targetDir, {
|
|
9992
10171
|
recursive: true,
|
|
9993
10172
|
force: true,
|
|
@@ -10004,7 +10183,7 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs) {
|
|
|
10004
10183
|
}
|
|
10005
10184
|
__name(copyMetadataImageRuntime, "copyMetadataImageRuntime");
|
|
10006
10185
|
async function readNitroOutputPackage(outputDir, fs) {
|
|
10007
|
-
const packagePath =
|
|
10186
|
+
const packagePath = path6.join(outputDir, "package.json");
|
|
10008
10187
|
return fs.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
10009
10188
|
if (error.code === "ENOENT") return {};
|
|
10010
10189
|
throw error;
|
|
@@ -10014,7 +10193,7 @@ __name(readNitroOutputPackage, "readNitroOutputPackage");
|
|
|
10014
10193
|
async function writeNitroOutputPackage(outputDir, packageJson, fs) {
|
|
10015
10194
|
await fs.mkdir(outputDir, { recursive: true });
|
|
10016
10195
|
await fs.writeFile(
|
|
10017
|
-
|
|
10196
|
+
path6.join(outputDir, "package.json"),
|
|
10018
10197
|
`${JSON.stringify(packageJson, null, 2)}
|
|
10019
10198
|
`
|
|
10020
10199
|
);
|
|
@@ -10031,18 +10210,18 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
10031
10210
|
}
|
|
10032
10211
|
}
|
|
10033
10212
|
try {
|
|
10034
|
-
let directory =
|
|
10035
|
-
while (directory !==
|
|
10036
|
-
const candidate =
|
|
10037
|
-
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)) {
|
|
10038
10217
|
try {
|
|
10039
10218
|
const manifest = JSON.parse(readFileSync(candidate, "utf8"));
|
|
10040
10219
|
if (manifest.name === packageName) return candidate;
|
|
10041
10220
|
} catch {
|
|
10042
10221
|
}
|
|
10043
10222
|
}
|
|
10044
|
-
if (
|
|
10045
|
-
directory =
|
|
10223
|
+
if (path6.basename(directory) === "node_modules") break;
|
|
10224
|
+
directory = path6.dirname(directory);
|
|
10046
10225
|
}
|
|
10047
10226
|
} catch {
|
|
10048
10227
|
}
|
|
@@ -10050,23 +10229,23 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
10050
10229
|
}
|
|
10051
10230
|
__name(resolvePackageJson, "resolvePackageJson");
|
|
10052
10231
|
async function copyPrismaClientForVercel(root, nitroFuncDir, fs) {
|
|
10053
|
-
const projectRequire = createRequire(
|
|
10232
|
+
const projectRequire = createRequire(path6.join(root, "package.json"));
|
|
10054
10233
|
let prismaClientDir;
|
|
10055
10234
|
try {
|
|
10056
|
-
prismaClientDir =
|
|
10235
|
+
prismaClientDir = path6.dirname(projectRequire.resolve("@prisma/client/default.js"));
|
|
10057
10236
|
} catch {
|
|
10058
10237
|
return;
|
|
10059
10238
|
}
|
|
10060
|
-
const generatedClientDir =
|
|
10239
|
+
const generatedClientDir = path6.join(prismaClientDir, "..", "..", ".prisma", "client");
|
|
10061
10240
|
try {
|
|
10062
10241
|
await fs.access(generatedClientDir);
|
|
10063
10242
|
} catch {
|
|
10064
10243
|
return;
|
|
10065
10244
|
}
|
|
10066
|
-
const targetNodeModules =
|
|
10067
|
-
const targetPrismaScopeDir =
|
|
10068
|
-
const targetGeneratedDir =
|
|
10069
|
-
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");
|
|
10070
10249
|
await fs.mkdir(targetPrismaScopeDir, { recursive: true });
|
|
10071
10250
|
await fs.cp(prismaClientDir, targetClientDir, {
|
|
10072
10251
|
recursive: true,
|
|
@@ -10076,7 +10255,7 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs) {
|
|
|
10076
10255
|
recursive: true,
|
|
10077
10256
|
force: true
|
|
10078
10257
|
});
|
|
10079
|
-
const clientPackagePath =
|
|
10258
|
+
const clientPackagePath = path6.join(prismaClientDir, "package.json");
|
|
10080
10259
|
const [functionPackage, clientPackageContent] = await Promise.all([
|
|
10081
10260
|
readNitroOutputPackage(nitroFuncDir, fs),
|
|
10082
10261
|
fs.readFile(clientPackagePath, "utf-8")
|
|
@@ -10235,9 +10414,9 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
10235
10414
|
} else {
|
|
10236
10415
|
const { build: legacyViteBuild } = await import("vite");
|
|
10237
10416
|
logger.info("\u{1F4E6} Building client bundle...");
|
|
10238
|
-
await buildClient2(legacyViteBuild, config, root, srcDir,
|
|
10417
|
+
await buildClient2(legacyViteBuild, config, root, srcDir, path7.join(root, distDir, "client"));
|
|
10239
10418
|
logger.info("\u{1F4E6} Building SSR bundle...");
|
|
10240
|
-
await buildSSR(legacyViteBuild, config, root, srcDir,
|
|
10419
|
+
await buildSSR(legacyViteBuild, config, root, srcDir, path7.join(root, distDir, "server"));
|
|
10241
10420
|
logger.info(`\u{1F680} Building server with Nitro (preset: ${preset})...`);
|
|
10242
10421
|
await buildNitro(
|
|
10243
10422
|
config,
|
|
@@ -10417,17 +10596,17 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
|
10417
10596
|
}
|
|
10418
10597
|
__name(buildSSR, "buildSSR");
|
|
10419
10598
|
function resolveLegacyPageEntry(config, root, srcDir) {
|
|
10420
|
-
const appDir =
|
|
10599
|
+
const appDir = path7.join(root, srcDir, "app");
|
|
10421
10600
|
for (const extension of getFarmRendererComponentExtensions(config.renderer)) {
|
|
10422
|
-
const candidate =
|
|
10423
|
-
if (
|
|
10601
|
+
const candidate = path7.join(appDir, `page${extension}`);
|
|
10602
|
+
if (existsSync3(candidate)) return candidate;
|
|
10424
10603
|
}
|
|
10425
|
-
return
|
|
10604
|
+
return path7.join(appDir, "page.tsx");
|
|
10426
10605
|
}
|
|
10427
10606
|
__name(resolveLegacyPageEntry, "resolveLegacyPageEntry");
|
|
10428
10607
|
async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
|
|
10429
10608
|
const [{ createNitroConfig }, { createNitro, build: nitroBuild }] = await Promise.all([
|
|
10430
|
-
import("./nitro-
|
|
10609
|
+
import("./nitro-4XGPNIK4.mjs"),
|
|
10431
10610
|
import("nitro/builder")
|
|
10432
10611
|
]);
|
|
10433
10612
|
let nitroConfig = await createNitroConfig(
|
|
@@ -10441,18 +10620,18 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
10441
10620
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
10442
10621
|
}
|
|
10443
10622
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
10444
|
-
const serverOutputDir =
|
|
10445
|
-
const publicOutputDir =
|
|
10623
|
+
const serverOutputDir = path7.join(outputDir, "server");
|
|
10624
|
+
const publicOutputDir = path7.join(outputDir, "public");
|
|
10446
10625
|
const { mkdir, cp } = await import("fs/promises");
|
|
10447
10626
|
await mkdir(serverOutputDir, { recursive: true });
|
|
10448
10627
|
await mkdir(publicOutputDir, { recursive: true });
|
|
10449
|
-
const clientDir =
|
|
10628
|
+
const clientDir = path7.join(root, distDir, "client");
|
|
10450
10629
|
try {
|
|
10451
10630
|
await mkdir(publicOutputDir, { recursive: true });
|
|
10452
10631
|
await cp(clientDir, publicOutputDir, { recursive: true });
|
|
10453
10632
|
logger.info("\u{1F4E6} Copied client assets to public directory");
|
|
10454
|
-
const manifestPath =
|
|
10455
|
-
const assetsDir =
|
|
10633
|
+
const manifestPath = path7.join(publicOutputDir, "farm-client-manifest.json");
|
|
10634
|
+
const assetsDir = path7.join(publicOutputDir, "assets");
|
|
10456
10635
|
const manifestExists = await import("fs/promises").then(
|
|
10457
10636
|
(fs) => fs.access(manifestPath).then(() => true).catch(() => false)
|
|
10458
10637
|
);
|
|
@@ -10468,8 +10647,8 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
10468
10647
|
logger.error(`\u274C Failed to copy client assets: ${error}`);
|
|
10469
10648
|
throw error;
|
|
10470
10649
|
}
|
|
10471
|
-
const serverDir =
|
|
10472
|
-
const nitroServerDir =
|
|
10650
|
+
const serverDir = path7.join(root, distDir, "server");
|
|
10651
|
+
const nitroServerDir = path7.join(root, distDir, ".nitro", "server", "farm");
|
|
10473
10652
|
try {
|
|
10474
10653
|
await mkdir(nitroServerDir, { recursive: true });
|
|
10475
10654
|
await cp(serverDir, nitroServerDir, { recursive: true });
|
|
@@ -10478,7 +10657,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
10478
10657
|
logger.warn(`Could not copy SSR bundles: ${error}`);
|
|
10479
10658
|
}
|
|
10480
10659
|
const nitro = await createNitro(nitroConfig);
|
|
10481
|
-
const registryPath =
|
|
10660
|
+
const registryPath = path7.join(root, distDir, ".nitro", "server", "farm-registry.ts");
|
|
10482
10661
|
try {
|
|
10483
10662
|
const { farmRegistry } = await import(
|
|
10484
10663
|
/* @vite-ignore */
|
|
@@ -10495,7 +10674,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
10495
10674
|
}
|
|
10496
10675
|
farmRegistry.routePaths = routePaths;
|
|
10497
10676
|
try {
|
|
10498
|
-
const clientManifestPath =
|
|
10677
|
+
const clientManifestPath = path7.join(root, distDir, "client", "farm-client-manifest.json");
|
|
10499
10678
|
const { readFile } = await import("fs/promises");
|
|
10500
10679
|
const manifestContent = await readFile(clientManifestPath, "utf-8");
|
|
10501
10680
|
farmRegistry.clientManifest = JSON.parse(manifestContent);
|