@farm.js/core 0.1.66 → 0.1.67
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/dist/{agent-mcp-handler-QLFDDTYN.mjs → agent-mcp-handler-AZ7QW4UP.mjs} +5 -5
- package/dist/{agent-mcp-handler-OXT73ZBY.cjs → agent-mcp-handler-FER4MQDF.cjs} +6 -6
- package/dist/{agent-mcp.d-QD2WZ9BS.d.ts → agent-mcp.d-BFu9xHAi.d.ts} +1 -1
- package/dist/{agent-mcp.d-CO_ABmNK.d.mts → agent-mcp.d-DWyWkTSy.d.mts} +1 -1
- package/dist/agent-runtime.cjs +6 -5
- package/dist/agent-runtime.d.mts +6 -6
- package/dist/agent-runtime.d.ts +6 -6
- package/dist/agent-runtime.mjs +5 -4
- package/dist/analyzer-KVZGVY5Q.cjs +16 -0
- package/dist/{analyzer-4UFP4HVP.mjs → analyzer-TTIIXXMQ.mjs} +2 -2
- package/dist/api/client.cjs +12 -2
- package/dist/api/client.d.mts +4 -4
- package/dist/api/client.d.ts +4 -4
- package/dist/api/client.mjs +12 -2
- package/dist/api/client.native.cjs +12 -2
- package/dist/api/client.native.d.mts +5 -5
- package/dist/api/client.native.d.ts +5 -5
- package/dist/api/client.native.mjs +12 -2
- package/dist/api/node.cjs +223 -0
- package/dist/api/node.d.mts +59 -0
- package/dist/api/node.d.ts +59 -0
- package/dist/api/node.mjs +223 -0
- package/dist/api/route-manager.cjs +11 -11
- package/dist/api/route-manager.d.mts +10 -9
- package/dist/api/route-manager.d.ts +10 -9
- package/dist/api/route-manager.mjs +10 -10
- package/dist/api/runtime.cjs +11 -7
- package/dist/api/runtime.d.mts +7 -7
- package/dist/api/runtime.d.ts +7 -7
- package/dist/api/runtime.mjs +10 -6
- package/dist/{api-client.d-BNLXNCXJ.d.mts → api-client.d-Bp35zMqR.d.mts} +1 -1
- package/dist/{api-client.d-ddQBNGtu.d.ts → api-client.d-CFI_xL0V.d.ts} +1 -1
- package/dist/api.cjs +17 -13
- package/dist/api.d.mts +11 -10
- package/dist/api.d.ts +11 -10
- package/dist/api.mjs +16 -12
- package/dist/{app-manifest.d-BpKxiU_E.d.mts → app-manifest.d-CRmjN5j9.d.mts} +1 -1
- package/dist/{app-manifest.d-DDmNkYQQ.d.ts → app-manifest.d-CwfhGrVR.d.ts} +1 -1
- package/dist/app-markdown.cjs +5 -5
- package/dist/app-markdown.d.mts +7 -7
- package/dist/app-markdown.d.ts +7 -7
- package/dist/app-markdown.mjs +4 -4
- package/dist/{app.d-x68Cwr0_.d.ts → app.d-BX9LVTiP.d.ts} +50 -9
- package/dist/{app.d-kuoVWhWM.d.mts → app.d-uBBUxwyV.d.mts} +50 -9
- package/dist/{chunk-V56632LA.cjs → chunk-22IWL4YD.cjs} +19 -5
- package/dist/{chunk-RY4ABNPE.cjs → chunk-23PVOIPT.cjs} +3 -3
- package/dist/{chunk-5C7XMKQ4.cjs → chunk-2AFW7673.cjs} +6 -1
- package/dist/{chunk-SYW346ZN.cjs → chunk-2LHZD3OP.cjs} +1 -21
- package/dist/{chunk-ZZI56IUY.mjs → chunk-2ZOYOYEE.mjs} +13 -13
- package/dist/{chunk-RVGSVQWT.mjs → chunk-3T5TLFCQ.mjs} +10 -5
- package/dist/{chunk-XBSKPLHF.cjs → chunk-3T7ALZJF.cjs} +2 -2
- package/dist/{chunk-7ONGIFYX.cjs → chunk-4DRINDGN.cjs} +319 -138
- package/dist/{chunk-O6L3YYPM.cjs → chunk-4E57QHPW.cjs} +8 -16
- package/dist/{chunk-WKPBIT5Q.cjs → chunk-4HGLJOXZ.cjs} +6 -6
- package/dist/{chunk-JGAE5XPL.cjs → chunk-4JX3M4C6.cjs} +2 -1
- package/dist/{chunk-CJNAUEVC.mjs → chunk-4QENVMG7.mjs} +1 -1
- package/dist/{chunk-CHYTADNK.cjs → chunk-556H7JCE.cjs} +65 -48
- package/dist/{chunk-OLIGNTWU.cjs → chunk-5NFQ6AZI.cjs} +7 -7
- package/dist/{chunk-6HRAK7I5.mjs → chunk-5OFNUETM.mjs} +8 -2
- package/dist/{chunk-TZVUF5JJ.mjs → chunk-5TA63JD3.mjs} +4 -4
- package/dist/{chunk-RD623KW4.cjs → chunk-67MZTLTF.cjs} +21 -3
- package/dist/chunk-6I4BFRE7.cjs +51 -0
- package/dist/{chunk-4TVPYN32.cjs → chunk-6R53ZWX2.cjs} +7 -7
- package/dist/{chunk-MGKW5XZE.cjs → chunk-6SQZXRJ2.cjs} +7 -7
- package/dist/{chunk-MPJEIHW2.cjs → chunk-6V5YWI4W.cjs} +2 -2
- package/dist/{chunk-BM2LH2JM.mjs → chunk-6YBYX4K4.mjs} +13 -12
- package/dist/{chunk-X3XUZWRB.mjs → chunk-724MGMIL.mjs} +17 -3
- package/dist/{chunk-K5EW7GUU.mjs → chunk-7BIW7VCW.mjs} +13 -5
- package/dist/{chunk-HPP2II4Z.mjs → chunk-7PJARAQQ.mjs} +1 -1
- package/dist/{chunk-LEJDW34D.cjs → chunk-7PPLTD3P.cjs} +3 -3
- package/dist/{chunk-TGULJSHD.mjs → chunk-AJNBTOVQ.mjs} +20 -9
- package/dist/{chunk-FBEBSAVI.cjs → chunk-AKIQ54FK.cjs} +82 -63
- package/dist/{chunk-2NGZFOKG.mjs → chunk-AOIUYHPH.mjs} +2 -2
- package/dist/{chunk-ZEXE4TGY.mjs → chunk-AQDLVHNF.mjs} +230 -110
- package/dist/{chunk-NKRZLQUK.mjs → chunk-AQIO3RNL.mjs} +1 -1
- package/dist/chunk-AQIRXBBY.cjs +26 -0
- package/dist/chunk-AZ6IW6SF.mjs +28 -0
- package/dist/{chunk-QMDU6QHN.mjs → chunk-B6RBJJ5G.mjs} +1 -1
- package/dist/{chunk-I32V5CZL.cjs → chunk-BDYM2TN3.cjs} +28 -17
- package/dist/{chunk-JLDNXURZ.cjs → chunk-BZWTBELF.cjs} +32 -32
- package/dist/{chunk-ITV4QQL2.cjs → chunk-C6CUUBY5.cjs} +14 -3
- package/dist/{chunk-YN6BHOYY.cjs → chunk-CL52PD6D.cjs} +10 -3
- package/dist/{chunk-UBMHQVWN.mjs → chunk-CO3YMZFD.mjs} +1 -1
- package/dist/{chunk-XURDCXNH.cjs → chunk-CSLHNBPS.cjs} +6 -6
- package/dist/{chunk-CNNBFGL5.cjs → chunk-DB2HSHQA.cjs} +14 -14
- package/dist/{chunk-XQSYOVCW.cjs → chunk-DBYNZIIQ.cjs} +13 -5
- package/dist/{chunk-DVKH2RVN.cjs → chunk-DCXSIEFE.cjs} +40 -41
- package/dist/{chunk-D4MRNBVF.cjs → chunk-DGOFR7D5.cjs} +2 -2
- package/dist/{chunk-QTD6EMN2.mjs → chunk-DQ2DI3Y7.mjs} +11 -4
- package/dist/chunk-DXZ57EPE.mjs +375 -0
- package/dist/{chunk-SA7MLSP4.mjs → chunk-E3HDJCWF.mjs} +3 -3
- package/dist/{chunk-BYRZ5VTH.mjs → chunk-E6CD45JK.mjs} +30 -31
- package/dist/{chunk-752XUZIM.cjs → chunk-EGIY4A7V.cjs} +6 -6
- package/dist/chunk-EIVGPQN5.mjs +51 -0
- package/dist/{chunk-KPAJWD3N.mjs → chunk-EYPSKXO4.mjs} +1 -1
- package/dist/{chunk-E552H232.cjs → chunk-F43OG25P.cjs} +1 -1
- package/dist/{chunk-UAQD67HM.mjs → chunk-F7JKVHU2.mjs} +1 -1
- package/dist/{chunk-QISW423S.cjs → chunk-FPBOAG6N.cjs} +2 -2
- package/dist/{chunk-2C5L5RPM.cjs → chunk-FT6KJHS3.cjs} +71 -38
- package/dist/{chunk-ES2LD2YD.mjs → chunk-GCRT6GJG.mjs} +18 -0
- package/dist/{chunk-5OJVKXFV.cjs → chunk-GDM3ZD2O.cjs} +10 -8
- package/dist/{chunk-EMDGXYUD.mjs → chunk-GJ7QVFAG.mjs} +16 -7
- package/dist/{chunk-TGSEVBPO.mjs → chunk-GJEC5S4V.mjs} +11 -0
- package/dist/{chunk-672ISQIG.mjs → chunk-GTV2ABO7.mjs} +218 -37
- package/dist/{chunk-MPIGW42F.mjs → chunk-H37MDCPR.mjs} +1 -1
- package/dist/{chunk-HNAISJFD.cjs → chunk-HDPT6OYE.cjs} +9 -3
- package/dist/{chunk-25T5VXOE.mjs → chunk-HFHJJXSV.mjs} +106 -19
- package/dist/{chunk-ZNH6NR3H.cjs → chunk-HJZZSBVK.cjs} +2 -2
- package/dist/{chunk-BIF5MLTH.cjs → chunk-HM7AGSKU.cjs} +1 -1
- package/dist/{chunk-GL7N5UHF.cjs → chunk-HNVAZGQD.cjs} +20 -9
- package/dist/{chunk-SK7QSNWE.mjs → chunk-HP2DQGQH.mjs} +1 -1
- package/dist/{chunk-435QJNC2.mjs → chunk-HRPTMX5C.mjs} +4 -4
- package/dist/{chunk-K7OZAVOI.mjs → chunk-IFR74W6S.mjs} +46 -13
- package/dist/{chunk-5A77OEIG.cjs → chunk-IHTDLCDJ.cjs} +5 -5
- package/dist/{chunk-VQJHT2ND.mjs → chunk-IRA2CZAY.mjs} +2 -2
- package/dist/{chunk-OYZXVBZP.cjs → chunk-IUKBPBM7.cjs} +2 -1
- package/dist/chunk-J6TZRYCO.cjs +22 -0
- package/dist/{chunk-WYAXRIYP.cjs → chunk-J7JHVCWA.cjs} +8 -8
- package/dist/chunk-JSOCDYER.cjs +375 -0
- package/dist/{chunk-TKK5QHKZ.mjs → chunk-JVM3DKZE.mjs} +3 -3
- package/dist/{chunk-UPYIFH2H.cjs → chunk-JWLRBDDC.cjs} +2 -2
- package/dist/{chunk-BQWBHWEW.mjs → chunk-JWSI5WO4.mjs} +1 -1
- package/dist/{chunk-OLGQZRW6.mjs → chunk-JZBU7V4D.mjs} +37 -17
- package/dist/{chunk-ONG4RDW3.mjs → chunk-JZGL2PIH.mjs} +13 -3
- package/dist/chunk-K63OWRY2.mjs +22 -0
- package/dist/{chunk-TUPKMMXT.mjs → chunk-K6HIIWUB.mjs} +1 -1
- package/dist/{chunk-MESQF2JC.mjs → chunk-K6SXMVXO.mjs} +2 -2
- package/dist/{chunk-L2JG337G.cjs → chunk-K6VFYFOY.cjs} +33 -31
- package/dist/{chunk-3CCAICF7.cjs → chunk-KCY52OUQ.cjs} +4 -4
- package/dist/{chunk-EZ34EHQP.mjs → chunk-KI3MU7B5.mjs} +1 -1
- package/dist/{chunk-GHNW564E.mjs → chunk-KSZK34HU.mjs} +30 -10
- package/dist/{chunk-RFKTJTWZ.mjs → chunk-KWFNUODD.mjs} +2 -1
- package/dist/{chunk-ECKQFEX2.mjs → chunk-LENKRGBV.mjs} +8 -6
- package/dist/{chunk-752IHQTD.cjs → chunk-LPIZMU7D.cjs} +12 -12
- package/dist/{chunk-HEPJIKKQ.cjs → chunk-MCSRMEQV.cjs} +2 -2
- package/dist/{chunk-DQF3QLOH.mjs → chunk-ME7RVELR.mjs} +3 -2
- package/dist/{chunk-E4UDLFWR.cjs → chunk-N5DQMOAG.cjs} +588 -677
- package/dist/{chunk-O4F3JUST.mjs → chunk-NDDRTFN4.mjs} +4 -0
- package/dist/{chunk-CBOEJ5Z4.cjs → chunk-OB3IFUK6.cjs} +133 -46
- package/dist/{chunk-R62SF5R4.mjs → chunk-OB45EAQL.mjs} +6 -1
- package/dist/{chunk-SYXPWJ7N.cjs → chunk-OFBLGH6V.cjs} +17 -18
- package/dist/{chunk-VQ4NWOWO.mjs → chunk-OGVTUGMU.mjs} +5 -13
- package/dist/{chunk-3UZVPO72.mjs → chunk-OIOPQ25L.mjs} +6 -7
- package/dist/{chunk-2XGBJSDV.cjs → chunk-OO7DYIJD.cjs} +73 -24
- package/dist/{chunk-27FPUFWR.mjs → chunk-P2NBQ5JI.mjs} +1 -1
- package/dist/{chunk-HZPKJRYA.cjs → chunk-PDFFYZAT.cjs} +2 -2
- package/dist/{chunk-GSVJ3IIF.cjs → chunk-PHCJJJZV.cjs} +2 -2
- package/dist/{chunk-EVMXPJCB.mjs → chunk-PKMUQ7LM.mjs} +2 -1
- package/dist/{chunk-4OSOLDPL.cjs → chunk-PL6RTBDE.cjs} +2 -2
- package/dist/{chunk-OAJOQU5J.mjs → chunk-PLJKJJ2H.mjs} +82 -63
- package/dist/{chunk-WMTBBQHY.cjs → chunk-PPX7UOFY.cjs} +271 -151
- package/dist/{chunk-6XQSPIN6.cjs → chunk-PWKAX5MS.cjs} +13 -3
- package/dist/{chunk-7XGWBPQQ.cjs → chunk-Q37INCXG.cjs} +13 -8
- package/dist/{chunk-OP7LHY4Y.cjs → chunk-Q5UX55YA.cjs} +1445 -601
- package/dist/{chunk-NHQM2Q4I.cjs → chunk-QGQP6QKO.cjs} +2 -2
- package/dist/{chunk-IT6WRNGB.cjs → chunk-QITSS4TD.cjs} +1381 -626
- package/dist/{chunk-4ZJ5C7UJ.cjs → chunk-QIXEU2WV.cjs} +19 -10
- package/dist/{chunk-HCGWDRZO.mjs → chunk-QJVW76JG.mjs} +17 -6
- package/dist/{chunk-FJWN7RV4.cjs → chunk-QO43L7Z4.cjs} +38 -8
- package/dist/{chunk-ZIHWAN55.cjs → chunk-RE5E2G5S.cjs} +1 -1
- package/dist/chunk-RWR7SMD7.cjs +50 -0
- package/dist/{chunk-7PTISZSQ.cjs → chunk-S7MWSFFP.cjs} +4 -0
- package/dist/chunk-SD6JGJOM.mjs +50 -0
- package/dist/{chunk-7H4SVNC4.cjs → chunk-SPP3EZTJ.cjs} +46 -26
- package/dist/{chunk-E4RDMG3K.mjs → chunk-TEG6HJVF.mjs} +4 -4
- package/dist/{chunk-WAY6LOQH.mjs → chunk-TEJ67GD2.mjs} +1 -1
- package/dist/{chunk-IFTGERT3.mjs → chunk-TTXIITYA.mjs} +49 -0
- package/dist/{chunk-ZFWYCVKS.mjs → chunk-TY5KCYDE.mjs} +22 -4
- package/dist/{chunk-W2ZXMMHA.mjs → chunk-UHE5JUKB.mjs} +1 -1
- package/dist/{chunk-OB7VKCUZ.mjs → chunk-UHNSY2PQ.mjs} +1302 -458
- package/dist/{chunk-UJ3R2AH2.cjs → chunk-UPOYKX4S.cjs} +5 -5
- package/dist/{chunk-2DLGV2ZG.mjs → chunk-UTUS6JUH.mjs} +1 -21
- package/dist/{chunk-WVYRLP5E.mjs → chunk-V5MQMQ2P.mjs} +1 -1
- package/dist/{chunk-VBCQ5WOI.cjs → chunk-V5RTHYJB.cjs} +30 -10
- package/dist/{chunk-WFWFECDW.mjs → chunk-VK54PDQ6.mjs} +25 -5
- package/dist/{chunk-LQNW3ABP.cjs → chunk-VX2HZGC7.cjs} +14 -14
- package/dist/{chunk-XBSLKXBL.mjs → chunk-WDD5CTZW.mjs} +49 -32
- package/dist/{chunk-EMNKZGF4.mjs → chunk-WGHY3OL5.mjs} +354 -443
- package/dist/{chunk-A2MN5PQJ.mjs → chunk-WMLSZAKN.mjs} +9 -9
- package/dist/{chunk-3EEET2Q5.cjs → chunk-WUTFJOV7.cjs} +32 -12
- package/dist/chunk-WVQNXXNE.cjs +28 -0
- package/dist/{chunk-Y5TOT5F6.cjs → chunk-X3MHKLCO.cjs} +5 -5
- package/dist/{chunk-Z7P2BTZ3.cjs → chunk-XGTFLG73.cjs} +30 -12
- package/dist/{chunk-AZUUKA66.mjs → chunk-XNZWMXCF.mjs} +1090 -335
- package/dist/{chunk-FIR62CR3.mjs → chunk-XUES6OET.mjs} +1 -1
- package/dist/{chunk-XCXHQBMM.mjs → chunk-Y2LU4LE5.mjs} +1 -1
- package/dist/{chunk-5J45H65F.mjs → chunk-Y5LEPEVH.mjs} +1 -1
- package/dist/{chunk-BT4SEFLC.cjs → chunk-YAEN3L2F.cjs} +3 -2
- package/dist/chunk-YFTGIHNC.mjs +26 -0
- package/dist/{chunk-KL7SHLQB.mjs → chunk-YGJ5P3TJ.mjs} +31 -1
- package/dist/{chunk-O75GQVUK.mjs → chunk-YQYTQJZN.mjs} +1 -1
- package/dist/{chunk-X4K7TYN6.cjs → chunk-YVTS3S3F.cjs} +24 -23
- package/dist/{chunk-72KABRWN.mjs → chunk-ZJGFAW5U.mjs} +5 -3
- package/dist/{chunk-TNBJ4LZG.mjs → chunk-ZPKJPM7K.mjs} +4 -4
- package/dist/client/lifecycle.cjs +2 -2
- package/dist/client/lifecycle.d.mts +1 -1
- package/dist/client/lifecycle.d.ts +1 -1
- package/dist/client/lifecycle.mjs +1 -1
- package/dist/{client-component.d-D74pqdea.d.mts → client-component.d-CDRvRmbU.d.mts} +2 -2
- package/dist/{client-component.d-D8VcypQA.d.ts → client-component.d-DWRKyAp5.d.ts} +2 -2
- package/dist/client-plugins.cjs +2 -2
- package/dist/{client-plugins.d-D4-6hNx7.d.mts → client-plugins.d-BNILjfX3.d.mts} +94 -140
- package/dist/{client-plugins.d-CXElzotB.d.ts → client-plugins.d-CrKZiNSN.d.ts} +94 -140
- package/dist/client-plugins.d.mts +6 -6
- package/dist/client-plugins.d.ts +6 -6
- package/dist/client-plugins.mjs +1 -1
- package/dist/client.cjs +11 -9
- package/dist/client.d.mts +13 -13
- package/dist/client.d.ts +13 -13
- package/dist/client.mjs +10 -8
- package/dist/{config.d-qt-mE8O5.d.mts → config.d-BKIhJtmr.d.mts} +7 -2
- package/dist/{config.d-qt-mE8O5.d.ts → config.d-BKIhJtmr.d.ts} +7 -2
- package/dist/config.d.mts +6 -6
- package/dist/config.d.ts +6 -6
- package/dist/cron.cjs +2 -2
- package/dist/cron.mjs +1 -1
- package/dist/deferred.cjs +2 -2
- package/dist/deferred.mjs +1 -1
- package/dist/deployment.cjs +2 -2
- package/dist/deployment.mjs +1 -1
- package/dist/desktop.d.mts +7 -7
- package/dist/desktop.d.ts +7 -7
- package/dist/{devtools-N2JQCMXB.cjs → devtools-RZVT4JVN.cjs} +36 -32
- package/dist/{devtools-NZUVNUP3.mjs → devtools-UFQYT3VA.mjs} +31 -27
- package/dist/docs.cjs +26 -25
- package/dist/docs.d.mts +20 -8
- package/dist/docs.d.ts +20 -8
- package/dist/docs.mjs +25 -24
- package/dist/env-types.cjs +3 -3
- package/dist/env-types.mjs +2 -2
- package/dist/environment/vite.cjs +5 -5
- package/dist/environment/vite.mjs +4 -4
- package/dist/headers.cjs +3 -3
- package/dist/headers.mjs +2 -2
- package/dist/image/server.d.mts +1 -1
- package/dist/image/server.d.ts +1 -1
- package/dist/image/sharp.d.mts +1 -1
- package/dist/image/sharp.d.ts +1 -1
- package/dist/{image-config.d-CeDgNyX4.d.mts → image-config.d-ByhQ0TT7.d.mts} +3 -1
- package/dist/{image-config.d-CeDgNyX4.d.ts → image-config.d-ByhQ0TT7.d.ts} +3 -1
- package/dist/image.cjs +6 -6
- package/dist/image.d.mts +1 -1
- package/dist/image.d.ts +1 -1
- package/dist/image.mjs +1 -1
- package/dist/index.cjs +142 -127
- package/dist/{index.d-SSgYDv4D.d.mts → index.d-Bdm6866n.d.mts} +1 -1
- package/dist/{index.d-A_x10zGS.d.ts → index.d-Dey5T14f.d.ts} +1 -1
- package/dist/index.d.mts +31 -82
- package/dist/index.d.ts +31 -82
- package/dist/index.mjs +213 -198
- package/dist/{integration-orm-52GPGTHO.cjs → integrations/orm.cjs} +5 -5
- package/dist/integrations/orm.d.mts +33 -0
- package/dist/integrations/orm.d.ts +33 -0
- package/dist/{integration-orm-CO23MSFE.mjs → integrations/orm.mjs} +5 -5
- package/dist/integrations.cjs +6 -5
- package/dist/integrations.d.mts +6 -6
- package/dist/integrations.d.ts +6 -6
- package/dist/integrations.mjs +5 -4
- package/dist/internal/app-markdown-runtime.cjs +4 -4
- package/dist/internal/app-markdown-runtime.d.mts +17 -8
- package/dist/internal/app-markdown-runtime.d.ts +17 -8
- package/dist/internal/app-markdown-runtime.mjs +3 -3
- package/dist/internal/build-runtime.cjs +68 -66
- package/dist/internal/build-runtime.d.mts +8 -8
- package/dist/internal/build-runtime.d.ts +8 -8
- package/dist/internal/build-runtime.mjs +67 -65
- package/dist/internal/cli-runtime.cjs +45 -44
- package/dist/internal/cli-runtime.mjs +44 -43
- package/dist/internal/client-error-overlay.cjs +6 -6
- package/dist/internal/client-error-overlay.mjs +2 -2
- package/dist/internal/client-runtime.cjs +60 -6
- package/dist/internal/client-runtime.d.mts +40 -11
- package/dist/internal/client-runtime.d.ts +40 -11
- package/dist/internal/client-runtime.mjs +58 -4
- package/dist/internal/compression-runtime.d.mts +6 -6
- package/dist/internal/compression-runtime.d.ts +6 -6
- package/dist/internal/config-runtime.cjs +25 -24
- package/dist/internal/config-runtime.d.mts +9 -9
- package/dist/internal/config-runtime.d.ts +9 -9
- package/dist/internal/config-runtime.mjs +24 -23
- package/dist/internal/docs-precompiled-runtime.cjs +16 -5
- package/dist/internal/docs-precompiled-runtime.d.mts +7 -0
- package/dist/internal/docs-precompiled-runtime.d.ts +7 -0
- package/dist/internal/docs-precompiled-runtime.mjs +15 -4
- package/dist/internal/infra-analytics-runtime.cjs +11 -11
- package/dist/internal/infra-analytics-runtime.mjs +9 -9
- package/dist/internal/islands-runtime.cjs +33 -4
- package/dist/internal/islands-runtime.d.mts +1 -1
- package/dist/internal/islands-runtime.d.ts +1 -1
- package/dist/internal/islands-runtime.mjs +31 -2
- package/dist/internal/native-server-fns.cjs +5 -5
- package/dist/internal/native-server-fns.mjs +4 -4
- package/dist/internal/product-telemetry-runtime.cjs +3 -3
- package/dist/internal/product-telemetry-runtime.mjs +2 -2
- package/dist/internal/production-runtime.cjs +53 -39
- package/dist/internal/production-runtime.d.mts +16 -15
- package/dist/internal/production-runtime.d.ts +16 -15
- package/dist/internal/production-runtime.mjs +68 -54
- package/dist/internal/react-cache.cjs +3 -3
- package/dist/internal/react-cache.mjs +1 -1
- package/dist/{lifecycle.d-C2aLBOwu.d.ts → lifecycle.d-keQs5Swc.d.mts} +7 -1
- package/dist/{lifecycle.d-C2aLBOwu.d.mts → lifecycle.d-keQs5Swc.d.ts} +7 -1
- package/dist/{manager-H5ZM3HAM.mjs → manager-JIA66YJ2.mjs} +4 -3
- package/dist/manager-JOHU6BQI.cjs +15 -0
- package/dist/markdown.cjs +7 -3
- package/dist/markdown.d.mts +6 -6
- package/dist/markdown.d.ts +6 -6
- package/dist/markdown.mjs +6 -2
- package/dist/middleware.cjs +10 -10
- package/dist/middleware.d.mts +8 -8
- package/dist/middleware.d.ts +8 -8
- package/dist/middleware.mjs +9 -9
- package/dist/mobile.d.mts +4 -4
- package/dist/mobile.d.ts +4 -4
- package/dist/mount.d-BP0nLYQO.d.mts +38 -0
- package/dist/mount.d-CkiPky_F.d.ts +38 -0
- package/dist/{native-server-fn-handler-GLRHAYWV.mjs → native-server-fn-handler-EP5AFJYE.mjs} +5 -5
- package/dist/{native-server-fn-handler-J5MYRXN6.cjs → native-server-fn-handler-QRTXGZA4.cjs} +6 -6
- package/dist/{native-tree-7LPH57Z4.cjs → native-tree-W2SSJB3Y.cjs} +4 -4
- package/dist/{native-tree-VV6WN3GX.mjs → native-tree-Y5YQANW7.mjs} +3 -3
- package/dist/{navigation-delegate.d-DQVYKoaZ.d.mts → navigation-delegate.d-CdBP-hkZ.d.mts} +1 -1
- package/dist/{navigation-delegate.d-GghbHJuK.d.ts → navigation-delegate.d-DchcGzAQ.d.ts} +1 -1
- package/dist/navigation.cjs +8 -7
- package/dist/navigation.d.mts +9 -9
- package/dist/navigation.d.ts +9 -9
- package/dist/navigation.mjs +7 -6
- package/dist/{nitro-DD4QCA66.mjs → nitro-55YOZWRA.mjs} +11 -11
- package/dist/{nitro-VRDX2H4M.cjs → nitro-EEX2J3KB.cjs} +13 -13
- package/dist/{plugin-53SY5YBS.mjs → plugin-SAS22JL7.mjs} +4 -3
- package/dist/{plugin-HZIBL3DW.cjs → plugin-WIU4GDD4.cjs} +5 -4
- package/dist/plugin.cjs +61 -59
- package/dist/plugin.d.mts +8 -8
- package/dist/plugin.d.ts +8 -8
- package/dist/plugin.mjs +60 -58
- package/dist/{production-runtime.d-Bzns3NW9.d.ts → production-runtime.d-Dou_Htas.d.ts} +1 -1
- package/dist/{production-runtime.d-DiFa5vHW.d.mts → production-runtime.d-VwsBzIee.d.mts} +1 -1
- package/dist/query/client.cjs +9 -7
- package/dist/query/client.mjs +5 -3
- package/dist/{render-plan.d-CL_Ikfg_.d.ts → render-plan.d-D8UakAIk.d.ts} +1 -1
- package/dist/{render-plan.d-CcF0MeCf.d.mts → render-plan.d-LKymStDJ.d.mts} +1 -1
- package/dist/renderer/none/server.cjs +35 -0
- package/dist/renderer/none/server.d.mts +21 -0
- package/dist/renderer/none/server.d.ts +21 -0
- package/dist/renderer/none/server.mjs +35 -0
- package/dist/renderer/react/server.cjs +2 -2
- package/dist/renderer/react/server.mjs +3 -3
- package/dist/renderer-client.cjs +8 -6
- package/dist/renderer-client.d.mts +9 -9
- package/dist/renderer-client.d.ts +9 -9
- package/dist/renderer-client.mjs +5 -3
- package/dist/renderer.cjs +6 -2
- package/dist/renderer.d.mts +20 -2
- package/dist/renderer.d.ts +20 -2
- package/dist/renderer.mjs +5 -1
- package/dist/request.cjs +2 -2
- package/dist/{request.d-B1RnTLri.d.ts → request.d-B928QjWy.d.ts} +1 -1
- package/dist/{request.d-DarDOCk9.d.mts → request.d-KG-4d2eG.d.mts} +1 -1
- package/dist/request.d.mts +7 -7
- package/dist/request.d.ts +7 -7
- package/dist/request.mjs +1 -1
- package/dist/{route-rendering.d-BTUYCIj4.d.ts → route-rendering.d-DoEe_w9t.d.ts} +1 -1
- package/dist/{route-rendering.d-D_2Ual0-.d.mts → route-rendering.d-NIHQeb4m.d.mts} +1 -1
- package/dist/{route.d-BaVH3V0w.d.mts → route.d-DrXkpvcg.d.mts} +1 -1
- package/dist/{route.d-DBTEqifW.d.ts → route.d-hs-_cyHn.d.ts} +1 -1
- package/dist/{router.d-Cuv1jntg.d.mts → router.d-B8PkJSGp.d.mts} +1 -1
- package/dist/{router.d-CMANF6da.d.ts → router.d-DYnRHQwz.d.ts} +1 -1
- package/dist/routes.cjs +3 -3
- package/dist/{routes.d-c2HKfrfL.d.mts → routes.d-DgZ_jgGG.d.mts} +1 -1
- package/dist/{routes.d-B6yFe6jm.d.ts → routes.d-uUBZyWoK.d.ts} +1 -1
- package/dist/routes.d.mts +6 -6
- package/dist/routes.d.ts +6 -6
- package/dist/routes.mjs +2 -2
- package/dist/{rsc-pipeline-7PNVJSTR.mjs → rsc-pipeline-4OJ5ZQNZ.mjs} +26 -25
- package/dist/{rsc-pipeline-Z7QBZOIJ.cjs → rsc-pipeline-7K5H2RPH.cjs} +27 -26
- package/dist/{runtime-QQHX4BP3.mjs → runtime-U7O3HZOZ.mjs} +60 -34
- package/dist/{runtime-FKFCUHSK.cjs → runtime-X52Q7JFR.cjs} +70 -44
- package/dist/{runtime.d-wvh4ngU0.d.mts → runtime.d-BxQIzwfy.d.mts} +11 -3
- package/dist/{runtime.d-C3RQUj6_.d.ts → runtime.d-DP7mEkEF.d.ts} +11 -3
- package/dist/{schema-dev-notice-JMXEQWIQ.mjs → schema-dev-notice-C2JINRZI.mjs} +3 -2
- package/dist/{schema-dev-notice-PLBFDTOF.cjs → schema-dev-notice-X7GG7QVB.cjs} +5 -4
- package/dist/schema.cjs +6 -2
- package/dist/schema.d-Dny9pnrm.d.mts +298 -0
- package/dist/schema.d-Dny9pnrm.d.ts +298 -0
- package/dist/schema.d.mts +1 -115
- package/dist/schema.d.ts +1 -115
- package/dist/schema.mjs +5 -1
- package/dist/server-fn-client.d.mts +2 -2
- package/dist/server-fn-client.d.ts +2 -2
- package/dist/server-fn.cjs +5 -5
- package/dist/server-fn.mjs +4 -4
- package/dist/server-plugins.cjs +7 -7
- package/dist/server-plugins.d.mts +16 -10
- package/dist/server-plugins.d.ts +16 -10
- package/dist/server-plugins.mjs +8 -8
- package/dist/server-query.cjs +6 -6
- package/dist/server-query.mjs +5 -5
- package/dist/server.cjs +160 -120
- package/dist/server.d.mts +20 -14
- package/dist/server.d.ts +20 -14
- package/dist/server.mjs +138 -98
- package/dist/{spa-router.d-WU_qS5gJ.d.mts → spa-router.d-BgHPVMhz.d.mts} +15 -5
- package/dist/{spa-router.d-m8H_Kl_B.d.ts → spa-router.d-DsFDHTsv.d.ts} +15 -5
- package/dist/testing.cjs +17 -17
- package/dist/testing.d.mts +6 -6
- package/dist/testing.d.ts +6 -6
- package/dist/testing.mjs +13 -13
- package/dist/theme/server.cjs +3 -3
- package/dist/theme/server.mjs +2 -2
- package/dist/{utils.d-W9IiEqmW.d.mts → utils.d-BKyKDBR1.d.mts} +1 -1
- package/dist/{utils.d-C9dQD5Zg.d.ts → utils.d-zxAVcf_V.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +63 -61
- package/dist/vite.d.mts +32 -12
- package/dist/vite.d.ts +32 -12
- package/dist/vite.mjs +62 -60
- package/dist/workflows.cjs +4 -4
- package/dist/workflows.mjs +3 -3
- package/package.json +31 -1
- package/dist/analyzer-H7SIX6BJ.cjs +0 -16
- package/dist/chunk-5YPBFMBN.cjs +0 -19
- package/dist/chunk-OM7WILES.mjs +0 -100
- package/dist/chunk-Q5B4LNON.mjs +0 -19
- package/dist/chunk-QPJ4MZTO.mjs +0 -60
- package/dist/chunk-R53QDV6T.cjs +0 -100
- package/dist/chunk-UYTAP4FQ.cjs +0 -60
- package/dist/manager-2LUKNX2N.cjs +0 -14
- /package/dist/{chunk-QGOZLGVP.mjs → chunk-I6FIAWNT.mjs} +0 -0
- /package/dist/{chunk-XPIPMWY3.cjs → chunk-K5NI5YQR.cjs} +0 -0
- /package/dist/{chunk-NWUHS6GV.cjs → chunk-QEJWNXRI.cjs} +0 -0
- /package/dist/{chunk-FSXSQQTV.mjs → chunk-TXE4SAMV.mjs} +0 -0
- /package/dist/{chunk-ZXK2EYQW.cjs → chunk-UUQNJDGH.cjs} +0 -0
- /package/dist/{chunk-46P5KNTE.mjs → chunk-VZBAW44S.mjs} +0 -0
|
@@ -7,9 +7,6 @@ import {
|
|
|
7
7
|
hasFarmMobileClientEntry,
|
|
8
8
|
removeFarmMobileClientManifest
|
|
9
9
|
} from "./chunk-TM2E623I.mjs";
|
|
10
|
-
import {
|
|
11
|
-
loadFarmProductionVite
|
|
12
|
-
} from "./chunk-PSUYE5HR.mjs";
|
|
13
10
|
import {
|
|
14
11
|
FARM_COMPILE_CACHE_DIR,
|
|
15
12
|
FARM_DESKTOP_ENV_MODULE_FILE,
|
|
@@ -22,23 +19,26 @@ import {
|
|
|
22
19
|
createFarmNodeServerEntry,
|
|
23
20
|
withProductionNodeEnv
|
|
24
21
|
} from "./chunk-5FE5YT2N.mjs";
|
|
22
|
+
import {
|
|
23
|
+
loadFarmProductionVite
|
|
24
|
+
} from "./chunk-PSUYE5HR.mjs";
|
|
25
|
+
import {
|
|
26
|
+
collectFarmNativeServerFns,
|
|
27
|
+
findFarmNativeScreenFiles
|
|
28
|
+
} from "./chunk-HP2DQGQH.mjs";
|
|
25
29
|
import {
|
|
26
30
|
generateNativeMCPPluginSource
|
|
27
31
|
} from "./chunk-KQH2COEJ.mjs";
|
|
28
32
|
import {
|
|
29
33
|
FARM_MOBILE_SESSION_PLUGIN
|
|
30
34
|
} from "./chunk-B4CWYGCG.mjs";
|
|
31
|
-
import {
|
|
32
|
-
collectFarmNativeServerFns,
|
|
33
|
-
findFarmNativeScreenFiles
|
|
34
|
-
} from "./chunk-SK7QSNWE.mjs";
|
|
35
35
|
import {
|
|
36
36
|
assertFarmDocsAdapterServesNoGuardedPages,
|
|
37
37
|
compileFarmDocsAdapterEdgeManifest,
|
|
38
38
|
createFarmDocsAPIHandler,
|
|
39
39
|
hasFarmDocsRuntimeAdapter,
|
|
40
40
|
listFarmDocsAdapterPages
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-E6CD45JK.mjs";
|
|
42
42
|
import {
|
|
43
43
|
FARM_DOCS_LAST_MODIFIED_MANIFEST,
|
|
44
44
|
createFarmDocsHandler,
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
loadFarmDocsPage,
|
|
51
51
|
resolveFarmDocsContentDir,
|
|
52
52
|
toFarmDocsMarkdownPage
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-AQDLVHNF.mjs";
|
|
54
54
|
import {
|
|
55
55
|
generateFarmDocsSearchClientRuntime,
|
|
56
56
|
isFarmDocsSearchEnabled,
|
|
@@ -58,7 +58,7 @@ import {
|
|
|
58
58
|
} from "./chunk-ALEUMLJN.mjs";
|
|
59
59
|
import {
|
|
60
60
|
FARM_PRERENDER_ENV
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-JVM3DKZE.mjs";
|
|
62
62
|
import {
|
|
63
63
|
loadFarmDocsEngine
|
|
64
64
|
} from "./chunk-VE3FWJBO.mjs";
|
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
getDeployTargetForPreset,
|
|
68
68
|
hasCustomFarmRouteContext,
|
|
69
69
|
resolveDeployOutputPath
|
|
70
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-WDD5CTZW.mjs";
|
|
71
71
|
import {
|
|
72
72
|
resolveFarmInstrumentationFile
|
|
73
73
|
} from "./chunk-N35YPV4N.mjs";
|
|
@@ -88,7 +88,6 @@ import {
|
|
|
88
88
|
farmDocsClientConfigPlugin,
|
|
89
89
|
farmFontImportsPlugin,
|
|
90
90
|
generateClientCachePersistenceCode,
|
|
91
|
-
generateFarmClientPluginEntryCode,
|
|
92
91
|
generateFarmIntegrationProviderClientCode,
|
|
93
92
|
generateFarmIntegrationProviderServerModules,
|
|
94
93
|
mergeFarmFontCss,
|
|
@@ -100,18 +99,19 @@ import {
|
|
|
100
99
|
resolveFarmImageServerRuntime,
|
|
101
100
|
resolveFarmNotFoundComponentPath,
|
|
102
101
|
resolveFarmRouteRootStrategy
|
|
103
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-WGHY3OL5.mjs";
|
|
104
103
|
import {
|
|
104
|
+
generateFarmClientPluginEntryCode,
|
|
105
105
|
loadTailwindVitePlugin
|
|
106
|
-
} from "./chunk-
|
|
106
|
+
} from "./chunk-DXZ57EPE.mjs";
|
|
107
107
|
import {
|
|
108
108
|
PluginManager
|
|
109
|
-
} from "./chunk-
|
|
109
|
+
} from "./chunk-KSZK34HU.mjs";
|
|
110
110
|
import {
|
|
111
111
|
generateFarmTypeArtifacts,
|
|
112
112
|
readRouteRenderingDirectiveFromFile,
|
|
113
113
|
resolveRouteRenderingConfigFromFile
|
|
114
|
-
} from "./chunk-
|
|
114
|
+
} from "./chunk-6YBYX4K4.mjs";
|
|
115
115
|
import {
|
|
116
116
|
HOISTED_HEAD_ELEMENT,
|
|
117
117
|
appMiddlewareMayHandlePath,
|
|
@@ -124,7 +124,7 @@ import {
|
|
|
124
124
|
layoutsCanCoverSamePage,
|
|
125
125
|
routeBoundaryCoversDirectory,
|
|
126
126
|
stripRouteGroups
|
|
127
|
-
} from "./chunk-
|
|
127
|
+
} from "./chunk-ZPKJPM7K.mjs";
|
|
128
128
|
import {
|
|
129
129
|
FARM_NATIVE_TREE_CONTENT_TYPE
|
|
130
130
|
} from "./chunk-LLZSYFOM.mjs";
|
|
@@ -138,15 +138,15 @@ import {
|
|
|
138
138
|
listFarmBuiltInRoutePaths,
|
|
139
139
|
resolveFarmApiCatalogInput,
|
|
140
140
|
resolveFarmAppManifestInput
|
|
141
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-HRPTMX5C.mjs";
|
|
142
142
|
import {
|
|
143
143
|
FARM_DEFAULT_MCP_PATH,
|
|
144
144
|
createFarmDefaultMCPServer,
|
|
145
145
|
farmConfigMountsMCP
|
|
146
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-K6SXMVXO.mjs";
|
|
147
147
|
import {
|
|
148
148
|
isFarmPreviewDeploymentEnvironment
|
|
149
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-V5MQMQ2P.mjs";
|
|
150
150
|
import {
|
|
151
151
|
FARM_NATIVE_SERVER_FN_PLUGIN
|
|
152
152
|
} from "./chunk-L4RTTTVE.mjs";
|
|
@@ -160,10 +160,11 @@ import {
|
|
|
160
160
|
getClientModuleMetadata,
|
|
161
161
|
getFarmClientHydrationPlanOptions,
|
|
162
162
|
resolveFarmIsolatedClientHydrationMode,
|
|
163
|
+
resolvePackageClientBoundaryCacheFile,
|
|
163
164
|
usePackageClientBoundaryCacheFile,
|
|
164
165
|
usesFarmServerTree,
|
|
165
166
|
withPackageClientBoundaryCache
|
|
166
|
-
} from "./chunk-
|
|
167
|
+
} from "./chunk-GTV2ABO7.mjs";
|
|
167
168
|
import {
|
|
168
169
|
generateFarmDocsAdapterClientRuntime,
|
|
169
170
|
getFarmDocsAdapterConfigModule
|
|
@@ -174,14 +175,14 @@ import {
|
|
|
174
175
|
} from "./chunk-NRNAHZ57.mjs";
|
|
175
176
|
import {
|
|
176
177
|
routeRulesToNitroRouteRules
|
|
177
|
-
} from "./chunk-
|
|
178
|
+
} from "./chunk-724MGMIL.mjs";
|
|
178
179
|
import {
|
|
179
180
|
applyFarmCspHashesToHtml,
|
|
180
181
|
createFarmCspNonce
|
|
181
182
|
} from "./chunk-22W4FNTG.mjs";
|
|
182
183
|
import {
|
|
183
184
|
resolveFarmServerComponentsMode
|
|
184
|
-
} from "./chunk-
|
|
185
|
+
} from "./chunk-4QENVMG7.mjs";
|
|
185
186
|
import {
|
|
186
187
|
getFarmAppDirectories
|
|
187
188
|
} from "./chunk-52Y3C3HG.mjs";
|
|
@@ -190,46 +191,47 @@ import {
|
|
|
190
191
|
getFarmRendererCapabilities,
|
|
191
192
|
getFarmRendererComponentExtensions,
|
|
192
193
|
getFarmRendererStreamingCapabilitiesForRuntime,
|
|
194
|
+
isFarmRendererDisabled,
|
|
193
195
|
isReactRenderer,
|
|
194
196
|
loadFarmRendererVitePlugins,
|
|
195
197
|
resolveFarmRendererAppSetup
|
|
196
|
-
} from "./chunk-
|
|
198
|
+
} from "./chunk-GCRT6GJG.mjs";
|
|
199
|
+
import {
|
|
200
|
+
applyFarmCronVercelCrons,
|
|
201
|
+
createFarmCronCloudflareConfig,
|
|
202
|
+
mergeScheduledTasks,
|
|
203
|
+
prepareFarmCronForNitro
|
|
204
|
+
} from "./chunk-ME7RVELR.mjs";
|
|
205
|
+
import {
|
|
206
|
+
resolveServerActionsConfig
|
|
207
|
+
} from "./chunk-E46NXBNJ.mjs";
|
|
197
208
|
import {
|
|
198
209
|
createBundledEnv
|
|
199
210
|
} from "./chunk-N33DLJBC.mjs";
|
|
200
211
|
import {
|
|
201
212
|
isFarmMarkdownPageFile
|
|
202
|
-
} from "./chunk-
|
|
213
|
+
} from "./chunk-3T5TLFCQ.mjs";
|
|
203
214
|
import {
|
|
204
215
|
resolveFarmMdxComponentsModulePath,
|
|
205
216
|
resolveMdxConfig
|
|
206
217
|
} from "./chunk-UIJOLBUL.mjs";
|
|
207
218
|
import {
|
|
208
219
|
getFarmMarkdownAlternatePath
|
|
209
|
-
} from "./chunk-
|
|
220
|
+
} from "./chunk-IFR74W6S.mjs";
|
|
210
221
|
import {
|
|
211
222
|
applyFarmWorkflowVercelCrons,
|
|
212
223
|
prepareFarmWorkflowsForNitro
|
|
213
|
-
} from "./chunk-
|
|
214
|
-
import {
|
|
215
|
-
applyFarmCronVercelCrons,
|
|
216
|
-
createFarmCronCloudflareConfig,
|
|
217
|
-
mergeScheduledTasks,
|
|
218
|
-
prepareFarmCronForNitro
|
|
219
|
-
} from "./chunk-DQF3QLOH.mjs";
|
|
220
|
-
import {
|
|
221
|
-
resolveServerActionsConfig
|
|
222
|
-
} from "./chunk-E46NXBNJ.mjs";
|
|
223
|
-
import {
|
|
224
|
-
_collectFarmStorageModules
|
|
225
|
-
} from "./chunk-TJVUTGED.mjs";
|
|
224
|
+
} from "./chunk-5TA63JD3.mjs";
|
|
226
225
|
import {
|
|
227
226
|
getFarmIntegrationPluginServerRuntime,
|
|
228
227
|
getIntegrationProviders
|
|
229
|
-
} from "./chunk-
|
|
228
|
+
} from "./chunk-AJNBTOVQ.mjs";
|
|
230
229
|
import {
|
|
231
230
|
FARM_INTEGRATION_API_BASE_PATH_KEY
|
|
232
231
|
} from "./chunk-M53MIIXY.mjs";
|
|
232
|
+
import {
|
|
233
|
+
_collectFarmStorageModules
|
|
234
|
+
} from "./chunk-TJVUTGED.mjs";
|
|
233
235
|
import {
|
|
234
236
|
appendMiddlewareDirectory,
|
|
235
237
|
appendMiddlewareRoutePath,
|
|
@@ -237,7 +239,7 @@ import {
|
|
|
237
239
|
} from "./chunk-MMK4MZUN.mjs";
|
|
238
240
|
import {
|
|
239
241
|
APIRouteManager
|
|
240
|
-
} from "./chunk-
|
|
242
|
+
} from "./chunk-OIOPQ25L.mjs";
|
|
241
243
|
import {
|
|
242
244
|
readFarmI18nCatalogs
|
|
243
245
|
} from "./chunk-DU4VHHPJ.mjs";
|
|
@@ -252,7 +254,7 @@ import {
|
|
|
252
254
|
normalizeFarmRouteRuntimeConfig,
|
|
253
255
|
resolveFarmRouteRuleRuntimeConfig,
|
|
254
256
|
resolveFarmRouteRuntimeConfig
|
|
255
|
-
} from "./chunk-
|
|
257
|
+
} from "./chunk-PKMUQ7LM.mjs";
|
|
256
258
|
import {
|
|
257
259
|
logger,
|
|
258
260
|
toPosixPath,
|
|
@@ -264,19 +266,23 @@ import {
|
|
|
264
266
|
} from "./chunk-2I6PUKWJ.mjs";
|
|
265
267
|
import {
|
|
266
268
|
FARM_VERSION
|
|
267
|
-
} from "./chunk-
|
|
269
|
+
} from "./chunk-H37MDCPR.mjs";
|
|
268
270
|
import {
|
|
269
271
|
getFarmPresetRuntime
|
|
270
|
-
} from "./chunk-
|
|
272
|
+
} from "./chunk-F7JKVHU2.mjs";
|
|
271
273
|
import {
|
|
272
274
|
_runWithFarmCspNonce
|
|
273
|
-
} from "./chunk-
|
|
275
|
+
} from "./chunk-5OFNUETM.mjs";
|
|
276
|
+
import {
|
|
277
|
+
normalizeFarmBasePath,
|
|
278
|
+
stripFarmBasePath
|
|
279
|
+
} from "./chunk-SF3JB56B.mjs";
|
|
274
280
|
import {
|
|
275
281
|
compareRoutePatternSpecificity
|
|
276
282
|
} from "./chunk-AYP2YFVN.mjs";
|
|
277
283
|
|
|
278
284
|
// src/build/index.ts
|
|
279
|
-
import
|
|
285
|
+
import path12 from "path";
|
|
280
286
|
import { existsSync as existsSync3 } from "fs";
|
|
281
287
|
|
|
282
288
|
// src/nitro/universal-build.ts
|
|
@@ -341,7 +347,7 @@ async function resolveHashedClientJsSrc(clientOutputDir) {
|
|
|
341
347
|
|
|
342
348
|
// src/nitro/universal-build.ts
|
|
343
349
|
import os from "os";
|
|
344
|
-
import
|
|
350
|
+
import path11 from "path";
|
|
345
351
|
import { constants as fsConstants, existsSync as existsSync2, readFileSync, realpathSync as realpathSync2, statSync } from "fs";
|
|
346
352
|
import { fileURLToPath } from "url";
|
|
347
353
|
import { builtinModules, createRequire } from "module";
|
|
@@ -365,13 +371,23 @@ function sanitizeCompiledValue(value, absolutePaths) {
|
|
|
365
371
|
return sanitized;
|
|
366
372
|
}
|
|
367
373
|
async function compileResponse(response, absolutePaths) {
|
|
374
|
+
const headers = Array.from(response.headers.entries()).map(([key, value]) => [
|
|
375
|
+
key,
|
|
376
|
+
sanitizeCompiledValue(value, absolutePaths)
|
|
377
|
+
]);
|
|
378
|
+
if (/^image\/(?!svg)/i.test(response.headers.get("content-type") || "")) {
|
|
379
|
+
return {
|
|
380
|
+
status: response.status,
|
|
381
|
+
statusText: response.statusText,
|
|
382
|
+
headers,
|
|
383
|
+
body: Buffer.from(await response.arrayBuffer()).toString("base64"),
|
|
384
|
+
bodyEncoding: "base64"
|
|
385
|
+
};
|
|
386
|
+
}
|
|
368
387
|
return {
|
|
369
388
|
status: response.status,
|
|
370
389
|
statusText: response.statusText,
|
|
371
|
-
headers
|
|
372
|
-
key,
|
|
373
|
-
sanitizeCompiledValue(value, absolutePaths)
|
|
374
|
-
]),
|
|
390
|
+
headers,
|
|
375
391
|
body: sanitizeCompiledValue(await response.text(), absolutePaths)
|
|
376
392
|
};
|
|
377
393
|
}
|
|
@@ -381,11 +397,11 @@ function getDocsTitle(docs) {
|
|
|
381
397
|
function loadPages(contentDir, docs) {
|
|
382
398
|
return discoverFarmDocsPages(contentDir, docs).map((page) => loadFarmDocsPage(contentDir, docs, page.slug)).filter((page) => Boolean(page)).sort((a, b) => a.href.localeCompare(b.href));
|
|
383
399
|
}
|
|
384
|
-
function findSocialImagePath(html) {
|
|
400
|
+
function findSocialImagePath(html, basePath) {
|
|
385
401
|
const match = /<meta\s+property=["']og:image["']\s+content=["']([^"']+)["']/i.exec(html) || /<meta\s+content=["']([^"']+)["']\s+property=["']og:image["']/i.exec(html);
|
|
386
402
|
if (!match?.[1]) return null;
|
|
387
403
|
try {
|
|
388
|
-
return new URL(match[1], FARM_DOCS_COMPILED_ORIGIN).pathname;
|
|
404
|
+
return stripFarmBasePath(new URL(match[1], FARM_DOCS_COMPILED_ORIGIN).pathname, basePath);
|
|
389
405
|
} catch {
|
|
390
406
|
return null;
|
|
391
407
|
}
|
|
@@ -399,6 +415,7 @@ async function addHandlerRoute(routes, pathname, handler, absolutePaths) {
|
|
|
399
415
|
async function compileFarmDocsManifest(docs, options) {
|
|
400
416
|
const contentDir = resolveFarmDocsContentDir(docs, options);
|
|
401
417
|
const pages = loadPages(contentDir, docs);
|
|
418
|
+
const basePath = normalizeFarmBasePath(options.basePath);
|
|
402
419
|
const absolutePaths = [
|
|
403
420
|
path2.resolve(options.root),
|
|
404
421
|
path2.resolve(contentDir),
|
|
@@ -411,13 +428,15 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
411
428
|
fontAssets: options.fontAssets,
|
|
412
429
|
fontStylesheetHref: options.fontStylesheetHref,
|
|
413
430
|
globalStylesheetHref: options.globalStylesheetHref,
|
|
414
|
-
isPathGuarded: options.isPathGuarded
|
|
431
|
+
isPathGuarded: options.isPathGuarded,
|
|
432
|
+
basePath
|
|
415
433
|
});
|
|
416
434
|
const apiHandler = createFarmDocsAPIHandler({
|
|
417
435
|
rootDir: options.root,
|
|
418
436
|
srcDir: options.srcDir,
|
|
419
437
|
docs,
|
|
420
|
-
isPathGuarded: options.isPathGuarded
|
|
438
|
+
isPathGuarded: options.isPathGuarded,
|
|
439
|
+
basePath
|
|
421
440
|
});
|
|
422
441
|
const publicPages = pages.filter((page) => !options.isPathGuarded?.(page.href));
|
|
423
442
|
const routes = {};
|
|
@@ -427,7 +446,7 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
427
446
|
const markdownPath = getFarmDocsMarkdownPath(page.href);
|
|
428
447
|
await addHandlerRoute(routes, markdownPath, handler, absolutePaths);
|
|
429
448
|
if (htmlResponse) {
|
|
430
|
-
const socialImagePath = findSocialImagePath(await htmlResponse.text());
|
|
449
|
+
const socialImagePath = findSocialImagePath(await htmlResponse.text(), basePath);
|
|
431
450
|
if (socialImagePath && !routes[normalizePathname(socialImagePath)]) {
|
|
432
451
|
await addHandlerRoute(routes, socialImagePath, handler, absolutePaths);
|
|
433
452
|
}
|
|
@@ -500,6 +519,7 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
500
519
|
protocol: 1,
|
|
501
520
|
originPlaceholder: FARM_DOCS_COMPILED_ORIGIN,
|
|
502
521
|
entry: docs.entry,
|
|
522
|
+
...basePath ? { basePath } : {},
|
|
503
523
|
routes,
|
|
504
524
|
api: {
|
|
505
525
|
static: apiStatic,
|
|
@@ -508,7 +528,7 @@ async function compileFarmDocsManifest(docs, options) {
|
|
|
508
528
|
post: await compileResponse(postResponse, absolutePaths),
|
|
509
529
|
search: {
|
|
510
530
|
pages: publicPages.map((page) => ({
|
|
511
|
-
...toFarmDocsMarkdownPage(page),
|
|
531
|
+
...toFarmDocsMarkdownPage(page, basePath),
|
|
512
532
|
sourcePath: `farm-docs:${page.slug || "index"}`
|
|
513
533
|
})),
|
|
514
534
|
search: searchConfig ?? true,
|
|
@@ -773,7 +793,7 @@ function validateFarmRouteRuntimeDeployment(manifest, preset) {
|
|
|
773
793
|
`Route "${route.pattern}" requires the ${route.runtime} runtime, but preset "${preset}" emits ${runtime} functions. Choose a compatible preset or change the route runtime.`
|
|
774
794
|
);
|
|
775
795
|
}
|
|
776
|
-
if (route.regions?.length && preset !== "vercel"
|
|
796
|
+
if (route.regions?.length && preset !== "vercel") {
|
|
777
797
|
warnings.add(
|
|
778
798
|
`Preset "${preset}" does not map per-route regions; Farm kept them in ${FARM_ROUTE_RUNTIME_MANIFEST} for deployment adapters.`
|
|
779
799
|
);
|
|
@@ -939,12 +959,127 @@ function buildFarmVercelRoutes(options) {
|
|
|
939
959
|
];
|
|
940
960
|
}
|
|
941
961
|
|
|
962
|
+
// src/nitro/ssr-public-assets.ts
|
|
963
|
+
import path7 from "path";
|
|
964
|
+
var SERVER_FILE_URL_RE = /new\s+URL\(\s*(["'`])([^"'`\\]+)\1\s*,\s*import\.meta\.url\s*\)/g;
|
|
965
|
+
function resolveBundleFileName(chunkFileName, relativeUrl) {
|
|
966
|
+
if (relativeUrl.startsWith("/") || /^[a-z][a-z\d+.-]*:/i.test(relativeUrl)) return null;
|
|
967
|
+
let relativePath = relativeUrl.replace(/[?#].*$/, "");
|
|
968
|
+
try {
|
|
969
|
+
relativePath = decodeURI(relativePath);
|
|
970
|
+
} catch {
|
|
971
|
+
}
|
|
972
|
+
const fileName = path7.posix.normalize(
|
|
973
|
+
path7.posix.join(path7.posix.dirname(chunkFileName), relativePath)
|
|
974
|
+
);
|
|
975
|
+
return fileName.startsWith("../") ? null : fileName;
|
|
976
|
+
}
|
|
977
|
+
function replaceServerFileReferences(bundle, chunkFileName, code, replace) {
|
|
978
|
+
return code.replace(SERVER_FILE_URL_RE, (reference, _quote, relativeUrl) => {
|
|
979
|
+
const target = resolveBundleFileName(chunkFileName, relativeUrl);
|
|
980
|
+
return target && bundle[target]?.type === "asset" ? replace(target) : reference;
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
function collectServerReadSSRAssets(bundle) {
|
|
984
|
+
const assets = /* @__PURE__ */ new Set();
|
|
985
|
+
for (const [fileName, output] of Object.entries(bundle)) {
|
|
986
|
+
if (output.type !== "chunk" || !output.code.includes("import.meta.url")) continue;
|
|
987
|
+
replaceServerFileReferences(bundle, fileName, output.code, (assetFileName) => {
|
|
988
|
+
assets.add(assetFileName);
|
|
989
|
+
return "";
|
|
990
|
+
});
|
|
991
|
+
}
|
|
992
|
+
return assets;
|
|
993
|
+
}
|
|
994
|
+
function collectServerOnlySSRAssets(bundle) {
|
|
995
|
+
const serverOnly = /* @__PURE__ */ new Set();
|
|
996
|
+
const publicReferenceSources = [];
|
|
997
|
+
for (const [fileName, output] of Object.entries(bundle)) {
|
|
998
|
+
if (output.type !== "chunk") continue;
|
|
999
|
+
if (!output.code.includes("import.meta.url")) {
|
|
1000
|
+
publicReferenceSources.push(output.code);
|
|
1001
|
+
continue;
|
|
1002
|
+
}
|
|
1003
|
+
publicReferenceSources.push(
|
|
1004
|
+
replaceServerFileReferences(bundle, fileName, output.code, (assetFileName) => {
|
|
1005
|
+
serverOnly.add(assetFileName);
|
|
1006
|
+
return "";
|
|
1007
|
+
})
|
|
1008
|
+
);
|
|
1009
|
+
}
|
|
1010
|
+
if (serverOnly.size === 0) return serverOnly;
|
|
1011
|
+
for (const output of Object.values(bundle)) {
|
|
1012
|
+
if (output.type === "asset" && typeof output.source === "string") {
|
|
1013
|
+
publicReferenceSources.push(output.source);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
for (const fileName of serverOnly) {
|
|
1017
|
+
const name = path7.posix.basename(fileName);
|
|
1018
|
+
if (publicReferenceSources.some((source) => source.includes(name))) {
|
|
1019
|
+
serverOnly.delete(fileName);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
return serverOnly;
|
|
1023
|
+
}
|
|
1024
|
+
function canReadServerFiles(preset) {
|
|
1025
|
+
return getFarmPresetRuntime(preset) !== "edge" && !preset.startsWith("cloudflare");
|
|
1026
|
+
}
|
|
1027
|
+
function assertServerReadSSRAssetsSupported(bundle, preset, root) {
|
|
1028
|
+
if (canReadServerFiles(preset)) return;
|
|
1029
|
+
const assets = [...collectServerReadSSRAssets(bundle)];
|
|
1030
|
+
if (assets.length === 0) return;
|
|
1031
|
+
const sources = assets.map((fileName) => {
|
|
1032
|
+
const output = bundle[fileName];
|
|
1033
|
+
const original = output?.type === "asset" ? output.originalFileNames?.[0] : void 0;
|
|
1034
|
+
if (!original) return fileName;
|
|
1035
|
+
return path7.relative(root, path7.resolve(root, original)).split(path7.sep).join("/");
|
|
1036
|
+
});
|
|
1037
|
+
throw new Error(
|
|
1038
|
+
`The "${preset}" preset cannot run server code that imports ${sources.join(", ")}. Server code reads such a file from beside the server bundle, and this edge runtime deploys no such file (Cloudflare Workers and Vercel Edge also refuse to compile WebAssembly from bytes). Load it in the browser instead, from client code with the @farm.js/wasm plugin or a "?url" import, or deploy to a Node target such as node-server, bun, vercel or netlify.`
|
|
1039
|
+
);
|
|
1040
|
+
}
|
|
1041
|
+
function createServerReadSSRAssetsPlugin(bundle, ssrOutputDir) {
|
|
1042
|
+
if (collectServerReadSSRAssets(bundle).size === 0) return null;
|
|
1043
|
+
let referenceIds = /* @__PURE__ */ new Map();
|
|
1044
|
+
return {
|
|
1045
|
+
name: "farm-server-read-ssr-assets",
|
|
1046
|
+
buildStart() {
|
|
1047
|
+
referenceIds = /* @__PURE__ */ new Map();
|
|
1048
|
+
},
|
|
1049
|
+
transform(code, id) {
|
|
1050
|
+
if (!code.includes("import.meta.url")) return null;
|
|
1051
|
+
const chunkFileName = path7.relative(ssrOutputDir, id.split("?", 1)[0]).split(path7.sep).join("/");
|
|
1052
|
+
if (bundle[chunkFileName]?.type !== "chunk") return null;
|
|
1053
|
+
let changed = false;
|
|
1054
|
+
const transformed = replaceServerFileReferences(
|
|
1055
|
+
bundle,
|
|
1056
|
+
chunkFileName,
|
|
1057
|
+
code,
|
|
1058
|
+
(assetFileName) => {
|
|
1059
|
+
let referenceId = referenceIds.get(assetFileName);
|
|
1060
|
+
if (!referenceId) {
|
|
1061
|
+
referenceId = this.emitFile({
|
|
1062
|
+
type: "asset",
|
|
1063
|
+
fileName: assetFileName,
|
|
1064
|
+
source: bundle[assetFileName].source
|
|
1065
|
+
});
|
|
1066
|
+
referenceIds.set(assetFileName, referenceId);
|
|
1067
|
+
}
|
|
1068
|
+
changed = true;
|
|
1069
|
+
return `new URL(import.meta.ROLLUP_FILE_URL_${referenceId})`;
|
|
1070
|
+
}
|
|
1071
|
+
);
|
|
1072
|
+
return changed ? { code: transformed, map: null } : null;
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
|
|
942
1077
|
// src/nitro/netlify-entry.ts
|
|
943
1078
|
import { existsSync } from "fs";
|
|
944
|
-
import
|
|
1079
|
+
import path8 from "path";
|
|
945
1080
|
function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
|
|
946
|
-
const entry =
|
|
947
|
-
|
|
1081
|
+
const entry = path8.join(
|
|
1082
|
+
path8.dirname(nitroRuntimeEntry),
|
|
948
1083
|
"..",
|
|
949
1084
|
"presets",
|
|
950
1085
|
"netlify",
|
|
@@ -956,7 +1091,7 @@ function resolveNitroNetlifyEntry(nitroRuntimeEntry) {
|
|
|
956
1091
|
`[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.`
|
|
957
1092
|
);
|
|
958
1093
|
}
|
|
959
|
-
return entry.split(
|
|
1094
|
+
return entry.split(path8.sep).join("/");
|
|
960
1095
|
}
|
|
961
1096
|
function createFarmNetlifyEntry(options) {
|
|
962
1097
|
return `
|
|
@@ -997,7 +1132,7 @@ export default async function farmNetlifyHandler(request, context) {
|
|
|
997
1132
|
|
|
998
1133
|
// src/build/strip-platform-config.ts
|
|
999
1134
|
import { realpathSync } from "fs";
|
|
1000
|
-
import
|
|
1135
|
+
import path9 from "path";
|
|
1001
1136
|
var PLATFORM_CONFIG_KEYS = /* @__PURE__ */ new Set(["desktop", "mobile"]);
|
|
1002
1137
|
var CONFIG_FACTORIES = /* @__PURE__ */ new Set(["defineConfig", "defineFarmConfig"]);
|
|
1003
1138
|
function isConfigObject(node) {
|
|
@@ -1071,11 +1206,11 @@ function realPath(file) {
|
|
|
1071
1206
|
try {
|
|
1072
1207
|
return realpathSync(file);
|
|
1073
1208
|
} catch {
|
|
1074
|
-
return
|
|
1209
|
+
return path9.resolve(file);
|
|
1075
1210
|
}
|
|
1076
1211
|
}
|
|
1077
1212
|
function farmStripPlatformConfigPlugin(configFiles) {
|
|
1078
|
-
const files = new Set(configFiles.flatMap((file) => [
|
|
1213
|
+
const files = new Set(configFiles.flatMap((file) => [path9.resolve(file), realPath(file)]));
|
|
1079
1214
|
return {
|
|
1080
1215
|
name: "farm:strip-platform-config",
|
|
1081
1216
|
// Before the TypeScript transform, so its import elision also drops imports only the
|
|
@@ -1083,9 +1218,9 @@ function farmStripPlatformConfigPlugin(configFiles) {
|
|
|
1083
1218
|
enforce: "pre",
|
|
1084
1219
|
async transform(code, id) {
|
|
1085
1220
|
const file = id.split("?", 1)[0];
|
|
1086
|
-
if (!files.has(
|
|
1221
|
+
if (!files.has(path9.resolve(file)) && !files.has(realPath(file))) return null;
|
|
1087
1222
|
const { parseAst } = await import("rolldown/parseAst");
|
|
1088
|
-
const extension =
|
|
1223
|
+
const extension = path9.extname(file).slice(1);
|
|
1089
1224
|
const lang = /^[cm]?tsx?$/.test(extension) ? extension.endsWith("x") ? "tsx" : "ts" : extension.endsWith("x") ? "jsx" : "js";
|
|
1090
1225
|
const stripped = stripPlatformConfigSource(code, (source) => parseAst(source, { lang }));
|
|
1091
1226
|
return stripped === null ? null : { code: stripped, map: null };
|
|
@@ -1095,7 +1230,7 @@ function farmStripPlatformConfigPlugin(configFiles) {
|
|
|
1095
1230
|
|
|
1096
1231
|
// src/nitro/client-sourcemaps.ts
|
|
1097
1232
|
import fs3 from "fs/promises";
|
|
1098
|
-
import
|
|
1233
|
+
import path10 from "path";
|
|
1099
1234
|
var FARM_CLIENT_SOURCEMAPS_DIR = "client-sourcemaps";
|
|
1100
1235
|
function resolveFarmClientSourcemap(sourcemap) {
|
|
1101
1236
|
return sourcemap ? "hidden" : false;
|
|
@@ -1116,8 +1251,8 @@ function createFarmPrivateClientSourcemapsPlugin(options) {
|
|
|
1116
1251
|
async writeBundle() {
|
|
1117
1252
|
await fs3.rm(options.outDir, { recursive: true, force: true });
|
|
1118
1253
|
for (const [fileName, source] of maps) {
|
|
1119
|
-
const target =
|
|
1120
|
-
await fs3.mkdir(
|
|
1254
|
+
const target = path10.join(options.outDir, fileName);
|
|
1255
|
+
await fs3.mkdir(path10.dirname(target), { recursive: true });
|
|
1121
1256
|
await fs3.writeFile(target, source);
|
|
1122
1257
|
}
|
|
1123
1258
|
}
|
|
@@ -1200,7 +1335,7 @@ async function readFarmNativeStylesheets(clientOutputDir, clientCssHref) {
|
|
|
1200
1335
|
try {
|
|
1201
1336
|
return {
|
|
1202
1337
|
[clientCssHref]: await fs4.readFile(
|
|
1203
|
-
|
|
1338
|
+
path11.join(clientOutputDir, clientCssHref.slice(1)),
|
|
1204
1339
|
"utf8"
|
|
1205
1340
|
)
|
|
1206
1341
|
};
|
|
@@ -1215,18 +1350,18 @@ function preloadFarmNitroBuilder() {
|
|
|
1215
1350
|
);
|
|
1216
1351
|
}
|
|
1217
1352
|
var _filename = typeof import.meta.url !== "undefined" ? fileURLToPath(import.meta.url) : "";
|
|
1218
|
-
var _dirname =
|
|
1353
|
+
var _dirname = path11.dirname(_filename);
|
|
1219
1354
|
function findFarmCoreRoot(from) {
|
|
1220
|
-
let dir =
|
|
1221
|
-
while (dir !==
|
|
1222
|
-
const manifest =
|
|
1355
|
+
let dir = path11.dirname(from);
|
|
1356
|
+
while (dir !== path11.dirname(dir)) {
|
|
1357
|
+
const manifest = path11.join(dir, "package.json");
|
|
1223
1358
|
if (existsSync2(manifest)) {
|
|
1224
1359
|
try {
|
|
1225
1360
|
if (JSON.parse(readFileSync(manifest, "utf8")).name === "@farm.js/core") return dir;
|
|
1226
1361
|
} catch {
|
|
1227
1362
|
}
|
|
1228
1363
|
}
|
|
1229
|
-
dir =
|
|
1364
|
+
dir = path11.dirname(dir);
|
|
1230
1365
|
}
|
|
1231
1366
|
return null;
|
|
1232
1367
|
}
|
|
@@ -1236,16 +1371,16 @@ function toModulePath(file) {
|
|
|
1236
1371
|
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
1237
1372
|
}
|
|
1238
1373
|
function findInstalledPackageDir(name, from) {
|
|
1239
|
-
for (let dir = from; ; dir =
|
|
1240
|
-
const candidate =
|
|
1241
|
-
if (existsSync2(
|
|
1374
|
+
for (let dir = from; ; dir = path11.dirname(dir)) {
|
|
1375
|
+
const candidate = path11.join(dir, "node_modules", name);
|
|
1376
|
+
if (existsSync2(path11.join(candidate, "package.json"))) {
|
|
1242
1377
|
try {
|
|
1243
1378
|
return realpathSync2(candidate);
|
|
1244
1379
|
} catch {
|
|
1245
1380
|
return null;
|
|
1246
1381
|
}
|
|
1247
1382
|
}
|
|
1248
|
-
if (dir ===
|
|
1383
|
+
if (dir === path11.dirname(dir)) return null;
|
|
1249
1384
|
}
|
|
1250
1385
|
}
|
|
1251
1386
|
function collectFarmDependencyDirs(root) {
|
|
@@ -1256,7 +1391,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1256
1391
|
seen.add(dir);
|
|
1257
1392
|
let manifest;
|
|
1258
1393
|
try {
|
|
1259
|
-
manifest = JSON.parse(readFileSync(
|
|
1394
|
+
manifest = JSON.parse(readFileSync(path11.join(dir, "package.json"), "utf8"));
|
|
1260
1395
|
} catch {
|
|
1261
1396
|
return;
|
|
1262
1397
|
}
|
|
@@ -1267,7 +1402,7 @@ function collectFarmDependencyDirs(root) {
|
|
|
1267
1402
|
if (farmCoreRoot) visit(realpathSync2(farmCoreRoot));
|
|
1268
1403
|
queue.push({ name: "@farm.js/core", from: root });
|
|
1269
1404
|
try {
|
|
1270
|
-
const manifest = JSON.parse(readFileSync(
|
|
1405
|
+
const manifest = JSON.parse(readFileSync(path11.join(root, "package.json"), "utf8"));
|
|
1271
1406
|
for (const field of ["dependencies", "devDependencies"]) {
|
|
1272
1407
|
for (const name of Object.keys(manifest[field] ?? {})) {
|
|
1273
1408
|
if (name.startsWith("@farm.js/")) queue.push({ name, from: root });
|
|
@@ -1334,17 +1469,17 @@ var FARM_SSR_PACKAGE_IMPORT = "#farm-ssr-entry";
|
|
|
1334
1469
|
var FARM_SSR_OUTPUT_DIR = "farm-ssr";
|
|
1335
1470
|
var FARM_CLIENT_BUILD_TARGET = ["es2020", "edge88", "firefox78", "chrome87", "safari14"];
|
|
1336
1471
|
function resolveNitroRuntimeDependency(root, specifier) {
|
|
1337
|
-
return createRequire(resolveNitroPackageEntry(root)).resolve(specifier).split(
|
|
1472
|
+
return createRequire(resolveNitroPackageEntry(root)).resolve(specifier).split(path11.sep).join("/");
|
|
1338
1473
|
}
|
|
1339
1474
|
function resolveNitroInternalRuntimeAliases(root) {
|
|
1340
1475
|
const nitroEntry = resolveNitroPackageEntry(root);
|
|
1341
|
-
const runtimeDir =
|
|
1476
|
+
const runtimeDir = path11.dirname(nitroEntry);
|
|
1342
1477
|
const nitroRequire = createRequire(nitroEntry);
|
|
1343
1478
|
return {
|
|
1344
1479
|
...Object.fromEntries(
|
|
1345
1480
|
["app", "error/hooks", "runtime-config", "shutdown", "task"].map((moduleName) => [
|
|
1346
1481
|
`#nitro/runtime/${moduleName}`,
|
|
1347
|
-
|
|
1482
|
+
path11.join(runtimeDir, "internal", `${moduleName}.mjs`).split(path11.sep).join("/")
|
|
1348
1483
|
])
|
|
1349
1484
|
),
|
|
1350
1485
|
// Farm's generated workflow and cron wrappers live under `.farm/` and
|
|
@@ -1353,7 +1488,7 @@ function resolveNitroInternalRuntimeAliases(root) {
|
|
|
1353
1488
|
...Object.fromEntries(
|
|
1354
1489
|
["nitro/app", "nitro/h3", "nitro/task"].map((specifier) => [
|
|
1355
1490
|
specifier,
|
|
1356
|
-
nitroRequire.resolve(specifier).split(
|
|
1491
|
+
nitroRequire.resolve(specifier).split(path11.sep).join("/")
|
|
1357
1492
|
])
|
|
1358
1493
|
)
|
|
1359
1494
|
};
|
|
@@ -1364,7 +1499,7 @@ function createPrerenderRuntimeResolverPlugin(root, resolveNitroEntry = resolveN
|
|
|
1364
1499
|
name: "farm-prerender-runtime-resolver",
|
|
1365
1500
|
async resolveId(id, _importer, options) {
|
|
1366
1501
|
if (options.custom?.farmPrerenderRuntimeResolve) return null;
|
|
1367
|
-
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") ||
|
|
1502
|
+
if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") || path11.isAbsolute(id) || NODE_BUILTIN_MODULES.has(id)) {
|
|
1368
1503
|
return null;
|
|
1369
1504
|
}
|
|
1370
1505
|
if (nitroEntry === void 0) {
|
|
@@ -1387,7 +1522,7 @@ function createFarmStorageModuleRegistration(config) {
|
|
|
1387
1522
|
const modules = _collectFarmStorageModules(config.storage);
|
|
1388
1523
|
if (modules.length === 0) return "";
|
|
1389
1524
|
const root = config.root || process.cwd();
|
|
1390
|
-
const projectRequire = createRequire(
|
|
1525
|
+
const projectRequire = createRequire(path11.join(root, "package.json"));
|
|
1391
1526
|
let runtimeRequire = projectRequire;
|
|
1392
1527
|
try {
|
|
1393
1528
|
runtimeRequire = createRequire(projectRequire.resolve("@farm.js/core"));
|
|
@@ -1414,7 +1549,7 @@ ${loaders.join("\n")}
|
|
|
1414
1549
|
});` : "";
|
|
1415
1550
|
}
|
|
1416
1551
|
function resolveNitroPackageEntry(root) {
|
|
1417
|
-
const projectRequire = createRequire(
|
|
1552
|
+
const projectRequire = createRequire(path11.join(root, "package.json"));
|
|
1418
1553
|
let runtimeRequire = projectRequire;
|
|
1419
1554
|
try {
|
|
1420
1555
|
runtimeRequire = createRequire(projectRequire.resolve("@farm.js/core"));
|
|
@@ -1484,7 +1619,7 @@ function createFarmReactWebServerAlias(hasEdgeBuild) {
|
|
|
1484
1619
|
}
|
|
1485
1620
|
function hasReactDomEdgeServerBuild(root) {
|
|
1486
1621
|
try {
|
|
1487
|
-
createRequire(
|
|
1622
|
+
createRequire(path11.join(root, "package.json")).resolve("react-dom/server.edge");
|
|
1488
1623
|
return true;
|
|
1489
1624
|
} catch {
|
|
1490
1625
|
return false;
|
|
@@ -1496,8 +1631,17 @@ function shouldAliasReactServerToWebBuild(renderer, preset) {
|
|
|
1496
1631
|
function isCloudflareImagePreset(preset) {
|
|
1497
1632
|
return preset === "cloudflare" || preset === "cloudflare-pages" || preset === "cloudflare-module";
|
|
1498
1633
|
}
|
|
1634
|
+
function getEdgeMetadataImageRuntime(preset) {
|
|
1635
|
+
if (isCloudflareImagePreset(preset)) {
|
|
1636
|
+
return { condition: "workerd", wasm: "module", runtime: "Cloudflare Workers" };
|
|
1637
|
+
}
|
|
1638
|
+
if (preset === "netlify-edge") {
|
|
1639
|
+
return { condition: "edge", wasm: "bytes", runtime: "Netlify Edge Functions" };
|
|
1640
|
+
}
|
|
1641
|
+
return null;
|
|
1642
|
+
}
|
|
1499
1643
|
function shouldUseExternalMetadataImageRuntime(preset, usesImageRuntime) {
|
|
1500
|
-
return usesImageRuntime &&
|
|
1644
|
+
return usesImageRuntime && !getEdgeMetadataImageRuntime(preset);
|
|
1501
1645
|
}
|
|
1502
1646
|
function isNitroRollupExternal(id) {
|
|
1503
1647
|
const normalizedId = id.replace(/\\/g, "/");
|
|
@@ -1518,9 +1662,9 @@ function createReactProductionModePlugin() {
|
|
|
1518
1662
|
}
|
|
1519
1663
|
var FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID = "\0farm-omitted-metadata-image-runtime";
|
|
1520
1664
|
function isFarmCoreModule(file) {
|
|
1521
|
-
let dir =
|
|
1522
|
-
while (dir !==
|
|
1523
|
-
const manifest =
|
|
1665
|
+
let dir = path11.dirname(file.split("?", 1)[0]);
|
|
1666
|
+
while (dir !== path11.dirname(dir)) {
|
|
1667
|
+
const manifest = path11.join(dir, "package.json");
|
|
1524
1668
|
if (existsSync2(manifest)) {
|
|
1525
1669
|
try {
|
|
1526
1670
|
return JSON.parse(readFileSync(manifest, "utf8")).name === "@farm.js/core";
|
|
@@ -1528,7 +1672,7 @@ function isFarmCoreModule(file) {
|
|
|
1528
1672
|
return false;
|
|
1529
1673
|
}
|
|
1530
1674
|
}
|
|
1531
|
-
dir =
|
|
1675
|
+
dir = path11.dirname(dir);
|
|
1532
1676
|
}
|
|
1533
1677
|
return false;
|
|
1534
1678
|
}
|
|
@@ -1537,7 +1681,7 @@ function createOmittedMetadataImageRuntimePlugin(externalizeOtherImports) {
|
|
|
1537
1681
|
name: "farm-omitted-metadata-image-runtime",
|
|
1538
1682
|
resolveId(source, importer) {
|
|
1539
1683
|
if (source !== "@vercel/og") return null;
|
|
1540
|
-
const fromCoreRuntime = importer !== void 0 && isFarmCoreModule(importer) && !/^og\.[cm]?[jt]sx?$/.test(
|
|
1684
|
+
const fromCoreRuntime = importer !== void 0 && isFarmCoreModule(importer) && !/^og\.[cm]?[jt]sx?$/.test(path11.basename(importer.split("?", 1)[0]));
|
|
1541
1685
|
if (fromCoreRuntime) return FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID;
|
|
1542
1686
|
return externalizeOtherImports ? { id: source, external: true } : null;
|
|
1543
1687
|
},
|
|
@@ -1553,6 +1697,66 @@ export class ImageResponse {
|
|
|
1553
1697
|
}
|
|
1554
1698
|
};
|
|
1555
1699
|
}
|
|
1700
|
+
function readVercelOgManifest(file) {
|
|
1701
|
+
let dir = path11.dirname(file.split("?", 1)[0]);
|
|
1702
|
+
while (dir !== path11.dirname(dir)) {
|
|
1703
|
+
const manifestPath = path11.join(dir, "package.json");
|
|
1704
|
+
if (existsSync2(manifestPath)) {
|
|
1705
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
1706
|
+
return manifest.name === "@vercel/og" ? { dir, manifest } : null;
|
|
1707
|
+
}
|
|
1708
|
+
dir = path11.dirname(dir);
|
|
1709
|
+
}
|
|
1710
|
+
return null;
|
|
1711
|
+
}
|
|
1712
|
+
function resolveVercelOgConditionEntry(resolvedId, condition) {
|
|
1713
|
+
const vercelOg = readVercelOgManifest(resolvedId);
|
|
1714
|
+
const entry = vercelOg?.manifest.exports?.["."]?.[condition];
|
|
1715
|
+
const file = typeof entry === "string" ? entry : entry?.default;
|
|
1716
|
+
return vercelOg && typeof file === "string" ? path11.join(vercelOg.dir, file) : null;
|
|
1717
|
+
}
|
|
1718
|
+
function createEdgeMetadataImageRuntimePlugin({
|
|
1719
|
+
condition,
|
|
1720
|
+
wasm
|
|
1721
|
+
}) {
|
|
1722
|
+
return {
|
|
1723
|
+
name: "farm-edge-metadata-image-runtime",
|
|
1724
|
+
async resolveId(source, importer, options) {
|
|
1725
|
+
if (source === "@vercel/og") {
|
|
1726
|
+
const resolved = await this.resolve(source, importer, { ...options, skipSelf: true });
|
|
1727
|
+
if (!resolved || resolved.external) return resolved;
|
|
1728
|
+
const edgeEntry = resolveVercelOgConditionEntry(resolved.id, condition);
|
|
1729
|
+
return edgeEntry ? { ...resolved, id: edgeEntry } : resolved;
|
|
1730
|
+
}
|
|
1731
|
+
if (wasm !== "module" || !source.endsWith(".wasm?module") || !importer?.replace(/\\/g, "/").includes("/@vercel/og/")) {
|
|
1732
|
+
return null;
|
|
1733
|
+
}
|
|
1734
|
+
const resolvedPath = path11.resolve(path11.dirname(importer.split("?", 1)[0]), source);
|
|
1735
|
+
return { id: toPosixPath(resolvedPath), external: "absolute" };
|
|
1736
|
+
}
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
var VERCEL_OG_FONT_FETCH = /fetch\(\s*new URL\(\s*(["'`])(\.\/[^"'`]+\.ttf)\1\s*,\s*import\.meta\.url\s*\)\s*\)/g;
|
|
1740
|
+
function createVercelOgFontInlinePlugin(runtime = "Cloudflare Workers") {
|
|
1741
|
+
return {
|
|
1742
|
+
name: "farm-vercel-og-font-inline",
|
|
1743
|
+
transform(code, id) {
|
|
1744
|
+
const file = id.split("?", 1)[0];
|
|
1745
|
+
if (!/\.[cm]?js$/.test(file) || !file.replace(/\\/g, "/").includes("/@vercel/og/")) {
|
|
1746
|
+
return null;
|
|
1747
|
+
}
|
|
1748
|
+
const inlined = code.replace(VERCEL_OG_FONT_FETCH, (_match, _quote, request) => {
|
|
1749
|
+
const encoded = readFileSync(path11.resolve(path11.dirname(file), request)).toString("base64");
|
|
1750
|
+
return `Promise.resolve({ arrayBuffer: () => Uint8Array.from(atob(${JSON.stringify(encoded)}), (character) => character.charCodeAt(0)).buffer })`;
|
|
1751
|
+
});
|
|
1752
|
+
if (inlined !== code) return { code: inlined, map: null };
|
|
1753
|
+
const version = readVercelOgManifest(file)?.manifest.version ?? "(unknown version)";
|
|
1754
|
+
this.error(
|
|
1755
|
+
`@vercel/og ${version} cannot be bundled for ${runtime}: ${file} does not load its default font with fetch(new URL("./<font>.ttf", import.meta.url)), the pattern Farm inlines because an edge function cannot fetch it. Install a @vercel/og version whose edge build does, such as 1.0.1.`
|
|
1756
|
+
);
|
|
1757
|
+
}
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1556
1760
|
function createMetadataImageWasmPlugin() {
|
|
1557
1761
|
return {
|
|
1558
1762
|
name: "farm-metadata-image-wasm",
|
|
@@ -1561,7 +1765,7 @@ function createMetadataImageWasmPlugin() {
|
|
|
1561
1765
|
return null;
|
|
1562
1766
|
}
|
|
1563
1767
|
const requestPath = source.slice(0, -"?module".length);
|
|
1564
|
-
const resolvedPath =
|
|
1768
|
+
const resolvedPath = path11.isAbsolute(requestPath) ? requestPath : path11.resolve(path11.dirname(importer.split("?", 1)[0]), requestPath);
|
|
1565
1769
|
return `${FARM_METADATA_IMAGE_WASM_PREFIX}${resolvedPath}`;
|
|
1566
1770
|
},
|
|
1567
1771
|
load(id) {
|
|
@@ -1586,11 +1790,11 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
1586
1790
|
for (const importId of [...output.imports, ...output.dynamicImports]) {
|
|
1587
1791
|
const normalizedImportId = importId.replace(/\\/g, "/");
|
|
1588
1792
|
const normalizedId = normalizedImportId.replace(/^\.\//, "");
|
|
1589
|
-
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ?
|
|
1793
|
+
const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ? path11.posix.normalize(path11.posix.join(path11.posix.dirname(fileName), normalizedImportId)) : null;
|
|
1590
1794
|
if (emittedFiles.has(normalizedId) || resolvedRelativeId !== null && emittedFiles.has(resolvedRelativeId) || NODE_BUILTIN_MODULES.has(importId) || importId.startsWith("node:")) {
|
|
1591
1795
|
continue;
|
|
1592
1796
|
}
|
|
1593
|
-
if (
|
|
1797
|
+
if (path11.isAbsolute(importId) || /^[A-Za-z]:[\\/]/.test(importId) || importId.startsWith("#") || importId.startsWith("\0")) {
|
|
1594
1798
|
externalPackages.add(importId);
|
|
1595
1799
|
continue;
|
|
1596
1800
|
}
|
|
@@ -1602,15 +1806,15 @@ function collectSSRExternalPackages(ssrBundle) {
|
|
|
1602
1806
|
return externalPackages;
|
|
1603
1807
|
}
|
|
1604
1808
|
function createExternalSSRBundlePlugin(nitroEntryPath, ssrOutputDir, ssrEntryFile) {
|
|
1605
|
-
const resolvedNitroEntry =
|
|
1606
|
-
const resolvedSSREntry =
|
|
1809
|
+
const resolvedNitroEntry = path11.resolve(nitroEntryPath);
|
|
1810
|
+
const resolvedSSREntry = path11.resolve(ssrOutputDir, ssrEntryFile);
|
|
1607
1811
|
return {
|
|
1608
1812
|
name: "farm-externalize-prebuilt-ssr",
|
|
1609
1813
|
resolveId(source, importer) {
|
|
1610
|
-
if (!importer ||
|
|
1814
|
+
if (!importer || path11.resolve(importer) !== resolvedNitroEntry) {
|
|
1611
1815
|
return null;
|
|
1612
1816
|
}
|
|
1613
|
-
const resolvedImport =
|
|
1817
|
+
const resolvedImport = path11.resolve(path11.dirname(importer), source);
|
|
1614
1818
|
if (resolvedImport !== resolvedSSREntry) return null;
|
|
1615
1819
|
return { id: FARM_SSR_PACKAGE_IMPORT, external: true };
|
|
1616
1820
|
}
|
|
@@ -1743,13 +1947,13 @@ function trimSlashes(value) {
|
|
|
1743
1947
|
function resolveBuildDocsContentDir(docs, root, srcDir) {
|
|
1744
1948
|
const configuredContentDir = docs.contentDir || docs.config.contentDir;
|
|
1745
1949
|
if (typeof configuredContentDir === "string" && configuredContentDir.trim()) {
|
|
1746
|
-
const contentDir =
|
|
1950
|
+
const contentDir = path11.isAbsolute(configuredContentDir) ? configuredContentDir : path11.join(root, configuredContentDir);
|
|
1747
1951
|
return existsSync2(contentDir) ? contentDir : null;
|
|
1748
1952
|
}
|
|
1749
1953
|
const entryDir = docs.config.entry || trimSlashes(docs.entry) || "docs";
|
|
1750
|
-
const appDocsDir =
|
|
1954
|
+
const appDocsDir = path11.join(root, srcDir || "src", "app", entryDir);
|
|
1751
1955
|
if (existsSync2(appDocsDir)) return appDocsDir;
|
|
1752
|
-
const rootDocsDir =
|
|
1956
|
+
const rootDocsDir = path11.join(root, entryDir);
|
|
1753
1957
|
return existsSync2(rootDocsDir) ? rootDocsDir : null;
|
|
1754
1958
|
}
|
|
1755
1959
|
function hasProjectPostcssConfig(root) {
|
|
@@ -1766,7 +1970,7 @@ function hasProjectPostcssConfig(root) {
|
|
|
1766
1970
|
".postcssrc.mjs",
|
|
1767
1971
|
".postcssrc.ts"
|
|
1768
1972
|
];
|
|
1769
|
-
const projectRequire = createRequire(
|
|
1973
|
+
const projectRequire = createRequire(path11.join(root, "package.json"));
|
|
1770
1974
|
return candidates.some((file) => {
|
|
1771
1975
|
try {
|
|
1772
1976
|
projectRequire.resolve(`./${file}`);
|
|
@@ -1789,7 +1993,7 @@ async function findFarmConfigPath(root) {
|
|
|
1789
1993
|
"config.mjs"
|
|
1790
1994
|
];
|
|
1791
1995
|
for (const candidate of candidates) {
|
|
1792
|
-
const resolvedPath =
|
|
1996
|
+
const resolvedPath = path11.join(root, candidate);
|
|
1793
1997
|
try {
|
|
1794
1998
|
await fs4.access(resolvedPath);
|
|
1795
1999
|
return resolvedPath;
|
|
@@ -1834,7 +2038,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
1834
2038
|
discovered.push({
|
|
1835
2039
|
path: routePath,
|
|
1836
2040
|
directory,
|
|
1837
|
-
filePath:
|
|
2041
|
+
filePath: path11.join(dir, middlewareFile.name)
|
|
1838
2042
|
});
|
|
1839
2043
|
}
|
|
1840
2044
|
for (const entry of entries) {
|
|
@@ -1842,7 +2046,7 @@ async function discoverMiddlewareRoutes(appDir) {
|
|
|
1842
2046
|
continue;
|
|
1843
2047
|
}
|
|
1844
2048
|
await walk(
|
|
1845
|
-
|
|
2049
|
+
path11.join(dir, entry.name),
|
|
1846
2050
|
appendMiddlewareRoutePath(routePath, entry.name),
|
|
1847
2051
|
appendMiddlewareDirectory(directory, entry.name),
|
|
1848
2052
|
discovered
|
|
@@ -1918,7 +2122,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1918
2122
|
logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
|
|
1919
2123
|
const fs4 = await import("fs/promises");
|
|
1920
2124
|
const layoutRoutes = [];
|
|
1921
|
-
const appDir =
|
|
2125
|
+
const appDir = path11.join(root, srcDir, "app");
|
|
1922
2126
|
async function findLayoutsForClient(dir, routePrefix = "/") {
|
|
1923
2127
|
try {
|
|
1924
2128
|
const entries = await fs4.readdir(dir, { withFileTypes: true });
|
|
@@ -1926,11 +2130,11 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
|
|
|
1926
2130
|
if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?|vue|svelte)$/)) {
|
|
1927
2131
|
layoutRoutes.push({
|
|
1928
2132
|
pattern: routePrefix,
|
|
1929
|
-
modulePath:
|
|
2133
|
+
modulePath: path11.join(dir, entry.name)
|
|
1930
2134
|
});
|
|
1931
2135
|
} else if (entry.isDirectory() && !entry.name.startsWith(".") && !entry.name.startsWith("_")) {
|
|
1932
2136
|
const childPrefix = routePrefix === "/" ? `/${entry.name}` : `${routePrefix}/${entry.name}`;
|
|
1933
|
-
await findLayoutsForClient(
|
|
2137
|
+
await findLayoutsForClient(path11.join(dir, entry.name), childPrefix);
|
|
1934
2138
|
}
|
|
1935
2139
|
}
|
|
1936
2140
|
} catch {
|
|
@@ -1954,7 +2158,7 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
1954
2158
|
);
|
|
1955
2159
|
}
|
|
1956
2160
|
const hydrationPlanCache = /* @__PURE__ */ new Map();
|
|
1957
|
-
const clientOutputDir =
|
|
2161
|
+
const clientOutputDir = path11.join(root, distDir, "client");
|
|
1958
2162
|
const [productionViteResult] = await productionViteResultPromise;
|
|
1959
2163
|
if (productionViteResult.status === "rejected") {
|
|
1960
2164
|
await routeRuntimeManifestResultPromise;
|
|
@@ -1963,21 +2167,29 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
1963
2167
|
const productionVite = productionViteResult.value;
|
|
1964
2168
|
logger.info("\u26A1 Building application bundles with Vite Rolldown");
|
|
1965
2169
|
const mobileClient = shouldBuildFarmMobileClient(config);
|
|
1966
|
-
const
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
2170
|
+
const rendererDisabled = isFarmRendererDisabled(config.renderer);
|
|
2171
|
+
const buildClientBundle = async () => {
|
|
2172
|
+
if (rendererDisabled) {
|
|
2173
|
+
await fs4.rm(clientOutputDir, { recursive: true, force: true });
|
|
2174
|
+
await fs4.mkdir(clientOutputDir, { recursive: true });
|
|
2175
|
+
return;
|
|
2176
|
+
}
|
|
2177
|
+
return buildClient(
|
|
2178
|
+
productionVite,
|
|
2179
|
+
config,
|
|
2180
|
+
root,
|
|
2181
|
+
srcDir,
|
|
2182
|
+
clientOutputDir,
|
|
2183
|
+
pageRoutes,
|
|
2184
|
+
layoutRoutes,
|
|
2185
|
+
routeSlots,
|
|
2186
|
+
isolatedClientBoundaryModules,
|
|
2187
|
+
hydrationPlanCache,
|
|
2188
|
+
rendererBuildLifetime,
|
|
2189
|
+
routeManager.getProgrammaticClientRoutes(),
|
|
2190
|
+
mobileClient
|
|
2191
|
+
);
|
|
2192
|
+
};
|
|
1981
2193
|
const buildSSRBundle = () => buildSSRInMemory(
|
|
1982
2194
|
productionVite,
|
|
1983
2195
|
config,
|
|
@@ -1995,12 +2207,14 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
1995
2207
|
);
|
|
1996
2208
|
let clientBuildResult;
|
|
1997
2209
|
let ssrBuildResult;
|
|
1998
|
-
if (config.renderer.buildConcurrency === "serial") {
|
|
2210
|
+
if (!rendererDisabled && config.renderer.buildConcurrency === "serial") {
|
|
1999
2211
|
logger.info(`\u{1F4E6} Building client and SSR bundles serially for ${config.renderer.name}...`);
|
|
2000
2212
|
[clientBuildResult] = await Promise.allSettled([buildClientBundle()]);
|
|
2001
2213
|
[ssrBuildResult] = await Promise.allSettled([buildSSRBundle()]);
|
|
2002
2214
|
} else {
|
|
2003
|
-
logger.info(
|
|
2215
|
+
logger.info(
|
|
2216
|
+
rendererDisabled ? "\u{1F4E6} Building the server bundle (renderer: false, no client bundle)..." : "\u{1F4E6} Building client and SSR bundles in parallel..."
|
|
2217
|
+
);
|
|
2004
2218
|
[clientBuildResult, ssrBuildResult] = await Promise.allSettled([
|
|
2005
2219
|
buildClientBundle(),
|
|
2006
2220
|
buildSSRBundle()
|
|
@@ -2046,6 +2260,7 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2046
2260
|
logger.warn(warning);
|
|
2047
2261
|
}
|
|
2048
2262
|
const { bundle: ssrBundle, entryFile: ssrEntryFile, configuredHeaderRoutes } = ssrResult;
|
|
2263
|
+
assertServerReadSSRAssetsSupported(ssrBundle, preset, root);
|
|
2049
2264
|
await writeSSRAssetsToClient(ssrBundle, clientOutputDir);
|
|
2050
2265
|
if (config.docs.enabled) {
|
|
2051
2266
|
await copyFarmDocsFontAssetsToClient(root, clientOutputDir);
|
|
@@ -2068,10 +2283,10 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
|
|
|
2068
2283
|
lifecyclePluginManager
|
|
2069
2284
|
);
|
|
2070
2285
|
const runtimeManifestPath = await writeFarmRouteRuntimeManifest(
|
|
2071
|
-
|
|
2286
|
+
path11.join(root, distDir),
|
|
2072
2287
|
routeRuntimeManifest
|
|
2073
2288
|
);
|
|
2074
|
-
logger.info(`\u{1F4CB} Route runtime manifest: ${
|
|
2289
|
+
logger.info(`\u{1F4CB} Route runtime manifest: ${path11.relative(root, runtimeManifestPath)}`);
|
|
2075
2290
|
} catch (error) {
|
|
2076
2291
|
if (lifecyclePluginManager) {
|
|
2077
2292
|
await lifecyclePluginManager.runHookParallel("onError", {
|
|
@@ -2105,14 +2320,15 @@ function varyFarmNitroCacheRulesByShell(rules) {
|
|
|
2105
2320
|
}
|
|
2106
2321
|
async function writeSSRAssetsToClient(bundle, outputDir) {
|
|
2107
2322
|
const fs4 = await import("fs/promises");
|
|
2323
|
+
const serverOnlyAssets = collectServerOnlySSRAssets(bundle);
|
|
2108
2324
|
for (const [fileName, output] of Object.entries(bundle)) {
|
|
2109
|
-
if (output.type !== "asset") continue;
|
|
2325
|
+
if (output.type !== "asset" || serverOnlyAssets.has(fileName)) continue;
|
|
2110
2326
|
if (fileName === "farm-fonts.css") {
|
|
2111
2327
|
await mergeBuiltFontCss(outputDir, output.source);
|
|
2112
2328
|
continue;
|
|
2113
2329
|
}
|
|
2114
|
-
const filePath =
|
|
2115
|
-
await fs4.mkdir(
|
|
2330
|
+
const filePath = path11.join(outputDir, fileName);
|
|
2331
|
+
await fs4.mkdir(path11.dirname(filePath), { recursive: true });
|
|
2116
2332
|
await fs4.writeFile(filePath, output.source);
|
|
2117
2333
|
}
|
|
2118
2334
|
}
|
|
@@ -2120,15 +2336,15 @@ async function copyFarmDocsFontAssetsToClient(root, outputDir) {
|
|
|
2120
2336
|
const fs4 = await import("fs/promises");
|
|
2121
2337
|
await Promise.all(
|
|
2122
2338
|
resolveFarmDocsFontAssets(root).map(async ({ sourcePath, url }) => {
|
|
2123
|
-
const targetPath =
|
|
2124
|
-
await fs4.mkdir(
|
|
2339
|
+
const targetPath = path11.join(outputDir, url.replace(/^\/+/, ""));
|
|
2340
|
+
await fs4.mkdir(path11.dirname(targetPath), { recursive: true });
|
|
2125
2341
|
await fs4.copyFile(sourcePath, targetPath);
|
|
2126
2342
|
})
|
|
2127
2343
|
);
|
|
2128
2344
|
}
|
|
2129
2345
|
async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
2130
2346
|
const fs4 = await import("fs/promises");
|
|
2131
|
-
const fontCssPath =
|
|
2347
|
+
const fontCssPath = path11.join(outputDir, "farm-fonts.css");
|
|
2132
2348
|
let fontCss = fontCssSource;
|
|
2133
2349
|
if (fontCss === void 0) {
|
|
2134
2350
|
try {
|
|
@@ -2137,7 +2353,7 @@ async function mergeBuiltFontCss(outputDir, fontCssSource) {
|
|
|
2137
2353
|
return;
|
|
2138
2354
|
}
|
|
2139
2355
|
}
|
|
2140
|
-
const clientCssPath =
|
|
2356
|
+
const clientCssPath = path11.join(outputDir, "farm-client.css");
|
|
2141
2357
|
let clientCss = "";
|
|
2142
2358
|
try {
|
|
2143
2359
|
clientCss = await fs4.readFile(clientCssPath, "utf8");
|
|
@@ -2156,7 +2372,7 @@ var IncompleteClientBuildOutputError = class extends Error {
|
|
|
2156
2372
|
async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
2157
2373
|
const fs4 = await import("fs/promises");
|
|
2158
2374
|
const fingerprinted = await findFingerprintedClientEntry(outputDir);
|
|
2159
|
-
const clientEntryPath =
|
|
2375
|
+
const clientEntryPath = path11.join(outputDir, fingerprinted ?? "farm-client.js");
|
|
2160
2376
|
let clientEntrySize = 0;
|
|
2161
2377
|
try {
|
|
2162
2378
|
const clientEntry = await fs4.stat(clientEntryPath);
|
|
@@ -2166,8 +2382,8 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
2166
2382
|
if (clientEntrySize === 0) {
|
|
2167
2383
|
throw new IncompleteClientBuildOutputError("farm-client.js is missing or empty");
|
|
2168
2384
|
}
|
|
2169
|
-
const clientCssPath =
|
|
2170
|
-
const globalsCssPath =
|
|
2385
|
+
const clientCssPath = path11.join(outputDir, "farm-client.css");
|
|
2386
|
+
const globalsCssPath = path11.join(root, srcDir, "app", "globals.css");
|
|
2171
2387
|
let expectsCss = false;
|
|
2172
2388
|
try {
|
|
2173
2389
|
const globalsCss = await fs4.readFile(globalsCssPath, "utf8");
|
|
@@ -2188,7 +2404,7 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
|
|
|
2188
2404
|
}
|
|
2189
2405
|
}
|
|
2190
2406
|
function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, options = {}) {
|
|
2191
|
-
const key = `${
|
|
2407
|
+
const key = `${path11.resolve(root)}\0${mode}\0${options.asyncOwnerIslands === true}\0${options.serverOwners === true}\0${options.serverTreeLayouts === true}\0${path11.resolve(modulePath)}`;
|
|
2192
2408
|
let plan = cache.get(key);
|
|
2193
2409
|
if (!plan) {
|
|
2194
2410
|
plan = getClientModuleHydrationPlan(modulePath, root, mode, options);
|
|
@@ -2197,10 +2413,10 @@ function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, optio
|
|
|
2197
2413
|
return { ...plan, isolatedBoundaries: [...plan.isolatedBoundaries] };
|
|
2198
2414
|
}
|
|
2199
2415
|
async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map(), rendererBuildLifetime, programmaticClientRoutes, mobile = false) {
|
|
2200
|
-
if (!mobile) await removeFarmMobileClientManifest(
|
|
2416
|
+
if (!mobile) await removeFarmMobileClientManifest(path11.dirname(outputDir));
|
|
2201
2417
|
const viteBuild = productionVite.build;
|
|
2202
2418
|
const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
2203
|
-
const { PluginManager: PluginManager2 } = await import("./plugin-
|
|
2419
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-SAS22JL7.mjs");
|
|
2204
2420
|
const fs4 = await import("fs/promises");
|
|
2205
2421
|
const pluginManager = new PluginManager2({
|
|
2206
2422
|
config,
|
|
@@ -2364,6 +2580,16 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2364
2580
|
);
|
|
2365
2581
|
}
|
|
2366
2582
|
}
|
|
2583
|
+
const serverSlotPlans = islandsMode ? routeSlots.flatMap((slot) => {
|
|
2584
|
+
const plan = getCachedClientModuleHydrationPlan(
|
|
2585
|
+
slot.modulePath,
|
|
2586
|
+
root,
|
|
2587
|
+
isolatedMode,
|
|
2588
|
+
hydrationPlanCache,
|
|
2589
|
+
{ ...pagePlanOptions, serverOwners: true }
|
|
2590
|
+
);
|
|
2591
|
+
return plan.isClientComponent ? [] : [{ slot, plan }];
|
|
2592
|
+
}) : [];
|
|
2367
2593
|
for (const { route, metadata } of routePlans) {
|
|
2368
2594
|
if (isAdapterDocsRoute(route.pattern)) continue;
|
|
2369
2595
|
try {
|
|
@@ -2375,7 +2601,10 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2375
2601
|
`\u26A0\uFE0F ${describeSuppressedAsyncHydration(route.pattern, metadata.fallbackReason)}`
|
|
2376
2602
|
);
|
|
2377
2603
|
}
|
|
2378
|
-
|
|
2604
|
+
const slotBoundaries = serverSlotPlans.filter(
|
|
2605
|
+
({ slot }) => layoutAppliesToRoute(slot.ownerDirectory ?? slot.ownerPattern, routeDirectory(route))
|
|
2606
|
+
).flatMap(({ plan }) => plan.isolatedBoundaries);
|
|
2607
|
+
if (metadata.shouldHydrate || metadata.hasIsolatedClientBoundaries || applicableClientLayouts.length > 0 || slotBoundaries.length > 0) {
|
|
2379
2608
|
const relativePath = route.modulePath.replace(root, "").replace(/^\//, "");
|
|
2380
2609
|
const islandStrategy = resolveFarmRouteRootStrategy(
|
|
2381
2610
|
route,
|
|
@@ -2389,9 +2618,10 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2389
2618
|
relativePath,
|
|
2390
2619
|
pageShouldHydrate: metadata.shouldHydrate,
|
|
2391
2620
|
islandStrategy,
|
|
2392
|
-
hasIsolatedClientBoundaries: metadata.hasIsolatedClientBoundaries || applicableClientLayouts.some((layout) => layout.hasIsolatedClientBoundaries),
|
|
2621
|
+
hasIsolatedClientBoundaries: metadata.hasIsolatedClientBoundaries || applicableClientLayouts.some((layout) => layout.hasIsolatedClientBoundaries) || slotBoundaries.length > 0,
|
|
2393
2622
|
isolatedBoundaries: [
|
|
2394
2623
|
...metadata.hasIsolatedClientBoundaries ? metadata.isolatedBoundaries : [],
|
|
2624
|
+
...slotBoundaries,
|
|
2395
2625
|
...applicableClientLayouts.filter((layout) => layout.hasIsolatedClientBoundaries || layout.serverTreeLayout).flatMap((layout) => layout.isolatedBoundaries)
|
|
2396
2626
|
],
|
|
2397
2627
|
// The server renders a server tree only below a hydrating layout.
|
|
@@ -2431,7 +2661,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2431
2661
|
}
|
|
2432
2662
|
const clientRouteSlots = routeSlots.filter((slot) => {
|
|
2433
2663
|
try {
|
|
2434
|
-
|
|
2664
|
+
const metadata = getClientModuleMetadata(slot.modulePath, root);
|
|
2665
|
+
return metadata.shouldHydrate && (!islandsMode || metadata.isClientComponent);
|
|
2435
2666
|
} catch (error) {
|
|
2436
2667
|
logger.warn(`\u26A0\uFE0F Could not inspect route slot ${slot.modulePath}: ${error}`);
|
|
2437
2668
|
return false;
|
|
@@ -2441,10 +2672,10 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2441
2672
|
`\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout) => layout.shouldHydrate || layout.hasIsolatedClientBoundaries).length} layouts, and ${clientRouteSlots.length} slots`
|
|
2442
2673
|
);
|
|
2443
2674
|
const buildTarget = async (platform) => {
|
|
2444
|
-
const clientEntryRoot =
|
|
2675
|
+
const clientEntryRoot = path11.join(root, ".farm", "tmp");
|
|
2445
2676
|
await fs4.mkdir(clientEntryRoot, { recursive: true });
|
|
2446
|
-
const clientEntryDir = await fs4.mkdtemp(
|
|
2447
|
-
const clientEntryPath =
|
|
2677
|
+
const clientEntryDir = await fs4.mkdtemp(path11.join(clientEntryRoot, "client-entry-"));
|
|
2678
|
+
const clientEntryPath = path11.join(clientEntryDir, "farm-client-entry.tsx");
|
|
2448
2679
|
const clientHydrationCode = generateClientHydrationEntry(
|
|
2449
2680
|
clientPages,
|
|
2450
2681
|
clientLayouts,
|
|
@@ -2475,10 +2706,14 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2475
2706
|
) : []
|
|
2476
2707
|
);
|
|
2477
2708
|
const entryName = platform === "mobile" ? FARM_MOBILE_CLIENT_ENTRY_NAME : "farm-client";
|
|
2478
|
-
|
|
2709
|
+
const clientEntry = islandsMode && platform === "web" && clientHydrationCode.includes("/*farm-router-stub*/") ? splitFarmClientRouter(clientHydrationCode) : { entry: clientHydrationCode, router: void 0 };
|
|
2710
|
+
await fs4.writeFile(clientEntryPath, clientEntry.entry);
|
|
2711
|
+
if (clientEntry.router !== void 0) {
|
|
2712
|
+
await fs4.writeFile(path11.join(clientEntryDir, "farm-client-router.tsx"), clientEntry.router);
|
|
2713
|
+
}
|
|
2479
2714
|
const clientInput = { [entryName]: clientEntryPath };
|
|
2480
2715
|
if (platform === "web" && canBootFarmIslandsClient(config)) {
|
|
2481
|
-
const clientBootPath =
|
|
2716
|
+
const clientBootPath = path11.join(clientEntryDir, "farm-client-boot.tsx");
|
|
2482
2717
|
await fs4.writeFile(
|
|
2483
2718
|
clientBootPath,
|
|
2484
2719
|
'import { startFarmIslandsBoot } from "@farm.js/core/internal/islands-boot";\nstartFarmIslandsBoot();\n'
|
|
@@ -2495,7 +2730,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2495
2730
|
if (hasScopedPostcssConfig) {
|
|
2496
2731
|
logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
|
|
2497
2732
|
} else {
|
|
2498
|
-
const postcssConfigPath =
|
|
2733
|
+
const postcssConfigPath = path11.join(clientEntryDir, "postcss.config.cjs");
|
|
2499
2734
|
await fs4.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
|
|
2500
2735
|
postcssSearchPath = clientEntryDir;
|
|
2501
2736
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
@@ -2551,24 +2786,24 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2551
2786
|
plugins: [
|
|
2552
2787
|
createFarmThemeCssPlugin(config.theme, config.basePath),
|
|
2553
2788
|
createFarmPrivateClientSourcemapsPlugin({
|
|
2554
|
-
outDir:
|
|
2555
|
-
|
|
2789
|
+
outDir: path11.join(
|
|
2790
|
+
path11.dirname(outputDir),
|
|
2556
2791
|
platform === "mobile" ? `${FARM_CLIENT_SOURCEMAPS_DIR}-mobile` : FARM_CLIENT_SOURCEMAPS_DIR
|
|
2557
2792
|
)
|
|
2558
2793
|
}),
|
|
2559
2794
|
// The web client's preload manifests; the mobile client records its files instead.
|
|
2560
2795
|
platform === "mobile" ? createFarmMobileClientManifestPlugin({
|
|
2561
|
-
buildDir:
|
|
2796
|
+
buildDir: path11.dirname(outputDir),
|
|
2562
2797
|
entryName
|
|
2563
2798
|
}) : createFarmClientModulePreloadPlugin({
|
|
2564
2799
|
root,
|
|
2565
|
-
buildDir:
|
|
2800
|
+
buildDir: path11.dirname(outputDir),
|
|
2566
2801
|
entryName: "farm-client"
|
|
2567
2802
|
}),
|
|
2568
2803
|
...adapterOwnsDocsRuntime && platform === "web" ? [
|
|
2569
2804
|
createFarmDocsModulePreloadPlugin({
|
|
2570
2805
|
root,
|
|
2571
|
-
buildDir:
|
|
2806
|
+
buildDir: path11.dirname(outputDir),
|
|
2572
2807
|
importer: clientEntryPath,
|
|
2573
2808
|
entryName: "farm-client",
|
|
2574
2809
|
modules: [
|
|
@@ -2658,8 +2893,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2658
2893
|
};
|
|
2659
2894
|
await viteBuild(mergeFarmProductionViteConfig(clientViteConfig, config.vite));
|
|
2660
2895
|
if (platform === "mobile") {
|
|
2661
|
-
await fs4.rm(
|
|
2662
|
-
if (!await hasFarmMobileClientEntry(
|
|
2896
|
+
await fs4.rm(path11.join(outputDir, `${entryName}.css`), { force: true });
|
|
2897
|
+
if (!await hasFarmMobileClientEntry(path11.dirname(outputDir), outputDir)) {
|
|
2663
2898
|
throw new IncompleteClientBuildOutputError(
|
|
2664
2899
|
`${FARM_MOBILE_CLIENT_ENTRY_NAME}.js is missing or empty`
|
|
2665
2900
|
);
|
|
@@ -2680,12 +2915,12 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
|
|
|
2680
2915
|
}
|
|
2681
2916
|
function toBakedMarkdownSourcePath(root, filePath) {
|
|
2682
2917
|
if (!filePath) return "";
|
|
2683
|
-
if (!
|
|
2684
|
-
const relative =
|
|
2685
|
-
if (!relative || relative.startsWith("..") ||
|
|
2686
|
-
return
|
|
2918
|
+
if (!path11.isAbsolute(filePath)) return filePath.split(path11.sep).join("/");
|
|
2919
|
+
const relative = path11.relative(root, filePath);
|
|
2920
|
+
if (!relative || relative.startsWith("..") || path11.isAbsolute(relative)) {
|
|
2921
|
+
return path11.basename(filePath);
|
|
2687
2922
|
}
|
|
2688
|
-
return relative.split(
|
|
2923
|
+
return relative.split(path11.sep).join("/");
|
|
2689
2924
|
}
|
|
2690
2925
|
function generateUniversalRouterStateRuntime(streamNavigations = false) {
|
|
2691
2926
|
return `
|
|
@@ -2700,6 +2935,7 @@ const IDLE_NAVIGATION_STATE = {
|
|
|
2700
2935
|
startedAt: null,
|
|
2701
2936
|
};
|
|
2702
2937
|
|
|
2938
|
+
/*farm-router-start*/
|
|
2703
2939
|
function createNavigationLocation(url) {
|
|
2704
2940
|
return {
|
|
2705
2941
|
href: url.href,
|
|
@@ -2769,6 +3005,7 @@ function readHistoryIndex(state) {
|
|
|
2769
3005
|
return Number.isSafeInteger(value) ? value : null;
|
|
2770
3006
|
}
|
|
2771
3007
|
|
|
3008
|
+
/*farm-router-end*/
|
|
2772
3009
|
function hasAbsoluteNavigationHref(href) {
|
|
2773
3010
|
return /^[a-zA-Z][a-zA-Z\\d+.-]*:/.test(href) || href.startsWith("//");
|
|
2774
3011
|
}
|
|
@@ -3063,7 +3300,8 @@ ${streamNavigations ? ` // A streamed navigation swaps in the page's shell; its
|
|
|
3063
3300
|
this.activeViewportPrefetches += 1;
|
|
3064
3301
|
let prefetchResult;
|
|
3065
3302
|
try {
|
|
3066
|
-
|
|
3303
|
+
// Through the installed router, so the lazy router's stand-in sees viewport prefetches too.
|
|
3304
|
+
prefetchResult = (window.__FARM_SPA_ROUTER__ || this).prefetch(task.href);
|
|
3067
3305
|
} catch {
|
|
3068
3306
|
prefetchResult = undefined;
|
|
3069
3307
|
}
|
|
@@ -3466,6 +3704,188 @@ ${streamNavigations ? ` if (streamShell && response.body) {
|
|
|
3466
3704
|
},
|
|
3467
3705
|
`.trim();
|
|
3468
3706
|
}
|
|
3707
|
+
var FARM_LAZY_ROUTER_STUB = `let farmLoadedRouter = null;
|
|
3708
|
+
let farmRouterLoading = null;
|
|
3709
|
+
const farmRouterReady = [];
|
|
3710
|
+
const farmRouterObserved = new Set();
|
|
3711
|
+
|
|
3712
|
+
function loadFarmRouter() {
|
|
3713
|
+
return farmRouterLoading || (farmRouterLoading = import("./farm-client-router").then(function(module) {
|
|
3714
|
+
farmLoadedRouter = module.spaRouter;
|
|
3715
|
+
// The router module installs itself as the global; this object stays it, so a reference taken
|
|
3716
|
+
// before the router loaded, or a method wrapped on it, keeps working afterwards.
|
|
3717
|
+
window.__FARM_SPA_ROUTER__ = spaRouter;
|
|
3718
|
+
for (const ready of farmRouterReady.splice(0)) ready(farmLoadedRouter);
|
|
3719
|
+
if (farmRouterViewport) farmRouterViewport.disconnect();
|
|
3720
|
+
for (const element of farmRouterObserved) farmLoadedRouter.observeForPrefetch(element);
|
|
3721
|
+
farmRouterObserved.clear();
|
|
3722
|
+
return farmLoadedRouter;
|
|
3723
|
+
}, function(error) {
|
|
3724
|
+
farmRouterLoading = null;
|
|
3725
|
+
throw error;
|
|
3726
|
+
}));
|
|
3727
|
+
}
|
|
3728
|
+
|
|
3729
|
+
let farmRouterViewport = null;
|
|
3730
|
+
function farmRouterViewportObserver() {
|
|
3731
|
+
return farmRouterViewport || (farmRouterViewport = new IntersectionObserver(function(entries) {
|
|
3732
|
+
if (!entries.some(function(entry) { return entry.isIntersecting; })) return;
|
|
3733
|
+
farmRouterViewport.disconnect();
|
|
3734
|
+
void loadFarmRouter().catch(function() {});
|
|
3735
|
+
}, { rootMargin: "50px" }));
|
|
3736
|
+
}
|
|
3737
|
+
|
|
3738
|
+
function farmRouterCall(name, beforeLoad) {
|
|
3739
|
+
return function() {
|
|
3740
|
+
const args = arguments;
|
|
3741
|
+
if (farmLoadedRouter) return farmLoadedRouter[name].apply(farmLoadedRouter, args);
|
|
3742
|
+
if (beforeLoad) return beforeLoad.apply(null, args);
|
|
3743
|
+
return loadFarmRouter().then(function(router) { return router[name].apply(router, args); });
|
|
3744
|
+
};
|
|
3745
|
+
}
|
|
3746
|
+
|
|
3747
|
+
function farmRouterSubscribe(name, loadNow) {
|
|
3748
|
+
return function() {
|
|
3749
|
+
const args = arguments;
|
|
3750
|
+
if (farmLoadedRouter) return farmLoadedRouter[name].apply(farmLoadedRouter, args);
|
|
3751
|
+
let active = true;
|
|
3752
|
+
let cleanup;
|
|
3753
|
+
farmRouterReady.push(function(router) {
|
|
3754
|
+
if (active) cleanup = router[name].apply(router, args);
|
|
3755
|
+
});
|
|
3756
|
+
if (loadNow) void loadFarmRouter().catch(function() {});
|
|
3757
|
+
return function() {
|
|
3758
|
+
active = false;
|
|
3759
|
+
if (cleanup) cleanup();
|
|
3760
|
+
};
|
|
3761
|
+
};
|
|
3762
|
+
}
|
|
3763
|
+
|
|
3764
|
+
const farmRouterStandIn = {
|
|
3765
|
+
get currentPath() {
|
|
3766
|
+
return farmLoadedRouter ? farmLoadedRouter.currentPath : window.location.pathname + window.location.search;
|
|
3767
|
+
},
|
|
3768
|
+
navigate: function(href, options) {
|
|
3769
|
+
if (farmLoadedRouter) return farmLoadedRouter.navigate(href, options);
|
|
3770
|
+
return loadFarmRouter().then(function(router) {
|
|
3771
|
+
return router.navigate(href, options);
|
|
3772
|
+
}, function() {
|
|
3773
|
+
if (options && (options.replace || options.action === "replace")) window.location.replace(href);
|
|
3774
|
+
else window.location.assign(href);
|
|
3775
|
+
});
|
|
3776
|
+
},
|
|
3777
|
+
refresh: farmRouterCall("refresh"),
|
|
3778
|
+
prefetch: farmRouterCall("prefetch"),
|
|
3779
|
+
// A watched link loads the router once it nears the viewport, which then prefetches it.
|
|
3780
|
+
observeForPrefetch: farmRouterCall("observeForPrefetch", function(element) {
|
|
3781
|
+
if (!("IntersectionObserver" in window)) return;
|
|
3782
|
+
farmRouterObserved.add(element);
|
|
3783
|
+
farmRouterViewportObserver().observe(element);
|
|
3784
|
+
}),
|
|
3785
|
+
unobserveForPrefetch: farmRouterCall("unobserveForPrefetch", function(element) {
|
|
3786
|
+
farmRouterObserved.delete(element);
|
|
3787
|
+
if (farmRouterViewport) farmRouterViewport.unobserve(element);
|
|
3788
|
+
}),
|
|
3789
|
+
pushState: farmRouterCall("pushState"),
|
|
3790
|
+
replaceState: farmRouterCall("replaceState"),
|
|
3791
|
+
handlePopState: farmRouterCall("handlePopState"),
|
|
3792
|
+
getNavigationState: farmRouterCall("getNavigationState", function() { return IDLE_NAVIGATION_STATE; }),
|
|
3793
|
+
shouldBlockUnload: farmRouterCall("shouldBlockUnload", function() { return false; }),
|
|
3794
|
+
saveScrollPosition: farmRouterCall("saveScrollPosition", function() {}),
|
|
3795
|
+
subscribeNavigation: farmRouterSubscribe("subscribeNavigation", false),
|
|
3796
|
+
addBlocker: farmRouterSubscribe("addBlocker", true),
|
|
3797
|
+
registerScrollElement: farmRouterSubscribe("registerScrollElement", true),
|
|
3798
|
+
};
|
|
3799
|
+
// Members only the router has, such as its fetch helpers, read and write through to it once loaded.
|
|
3800
|
+
const spaRouter = new Proxy(farmRouterStandIn, {
|
|
3801
|
+
get: function(target, key) {
|
|
3802
|
+
if (key in target || !farmLoadedRouter) return target[key];
|
|
3803
|
+
return farmLoadedRouter[key];
|
|
3804
|
+
},
|
|
3805
|
+
set: function(target, key, value) {
|
|
3806
|
+
if (key in target || !farmLoadedRouter) target[key] = value;
|
|
3807
|
+
else farmLoadedRouter[key] = value;
|
|
3808
|
+
return true;
|
|
3809
|
+
},
|
|
3810
|
+
has: function(target, key) {
|
|
3811
|
+
return key in target || (farmLoadedRouter !== null && key in farmLoadedRouter);
|
|
3812
|
+
},
|
|
3813
|
+
});
|
|
3814
|
+
window.__FARM_SPA_ROUTER__ = spaRouter;
|
|
3815
|
+
|
|
3816
|
+
// Links in server components have no handlers of their own, so intent is read from the document.
|
|
3817
|
+
const farmRouterIntentEvents = ["mouseover", "pointerdown", "focusin"];
|
|
3818
|
+
function farmRouterIntent(event) {
|
|
3819
|
+
const anchor = event.target instanceof Element ? event.target.closest("a[href]") : null;
|
|
3820
|
+
const href = anchor && anchor.getAttribute("href");
|
|
3821
|
+
if (!href || href.startsWith("#") || hasAbsoluteNavigationHref(href)) return;
|
|
3822
|
+
for (const type of farmRouterIntentEvents) document.removeEventListener(type, farmRouterIntent, true);
|
|
3823
|
+
void loadFarmRouter().catch(function() {});
|
|
3824
|
+
}
|
|
3825
|
+
for (const type of farmRouterIntentEvents) document.addEventListener(type, farmRouterIntent, true);
|
|
3826
|
+
`;
|
|
3827
|
+
function bindingPattern(name) {
|
|
3828
|
+
return new RegExp(`(?<![\\w$])(?<![^.]\\.)${name.replace(/\$/g, "\\$")}(?![\\w$])`);
|
|
3829
|
+
}
|
|
3830
|
+
function readFarmEntryDeclarations(source) {
|
|
3831
|
+
const names = /* @__PURE__ */ new Set();
|
|
3832
|
+
const pattern = /^(?:async\s+)?function\*?\s+([\w$]+)|^(?:const|let|var|class)\s+([\w$]+)/gm;
|
|
3833
|
+
for (const match of source.matchAll(pattern)) names.add(match[1] ?? match[2]);
|
|
3834
|
+
return names;
|
|
3835
|
+
}
|
|
3836
|
+
function readFarmEntryImports(source) {
|
|
3837
|
+
const bindings = [];
|
|
3838
|
+
for (const match of source.matchAll(/^import\s+([^"';]+?)\s+from\s+(["'][^"']+["'])/gm)) {
|
|
3839
|
+
const from = match[2];
|
|
3840
|
+
const named = /\{([^}]*)\}/.exec(match[1]);
|
|
3841
|
+
for (const specifier of named?.[1]?.split(",") ?? []) {
|
|
3842
|
+
const [imported, local] = specifier.trim().split(/\s+as\s+/);
|
|
3843
|
+
if (imported)
|
|
3844
|
+
bindings.push({ local: local ?? imported, clause: `{ ${specifier.trim()} }`, from });
|
|
3845
|
+
}
|
|
3846
|
+
const outside = match[1].replace(/\{[^}]*\}/, "").replace(/,/g, " ").trim();
|
|
3847
|
+
const namespace = /\*\s+as\s+([\w$]+)/.exec(outside);
|
|
3848
|
+
if (namespace) bindings.push({ local: namespace[1], clause: `* as ${namespace[1]}`, from });
|
|
3849
|
+
else if (outside) bindings.push({ local: outside, clause: outside, from });
|
|
3850
|
+
}
|
|
3851
|
+
return bindings;
|
|
3852
|
+
}
|
|
3853
|
+
function splitFarmClientRouter(code) {
|
|
3854
|
+
const regions = [];
|
|
3855
|
+
const eager = code.replace(
|
|
3856
|
+
/\/\*farm-router-start\*\/([\s\S]*?)\/\*farm-router-end\*\/\n?/g,
|
|
3857
|
+
(_, body2) => {
|
|
3858
|
+
regions.push(body2);
|
|
3859
|
+
return "";
|
|
3860
|
+
}
|
|
3861
|
+
);
|
|
3862
|
+
const body = regions.join("\n");
|
|
3863
|
+
const moved = readFarmEntryDeclarations(body);
|
|
3864
|
+
const usedByRouter = (name) => !moved.has(name) && bindingPattern(name).test(body);
|
|
3865
|
+
const eagerCode = eager.replace(/^import\s[^;]*;/gm, "");
|
|
3866
|
+
const usedByEntry = (name) => bindingPattern(name).test(eagerCode);
|
|
3867
|
+
const bindings = readFarmEntryImports(eager).filter((binding) => usedByRouter(binding.local));
|
|
3868
|
+
const imports = bindings.filter((binding) => !usedByEntry(binding.local));
|
|
3869
|
+
const reexported = bindings.filter((binding) => usedByEntry(binding.local)).map((binding) => binding.local);
|
|
3870
|
+
const shared = [
|
|
3871
|
+
.../* @__PURE__ */ new Set([
|
|
3872
|
+
...reexported,
|
|
3873
|
+
...[...readFarmEntryDeclarations(eager)].filter((name) => usedByRouter(name))
|
|
3874
|
+
])
|
|
3875
|
+
];
|
|
3876
|
+
return {
|
|
3877
|
+
entry: `${eager.replace("/*farm-router-stub*/", FARM_LAZY_ROUTER_STUB)}
|
|
3878
|
+
export { ${shared.join(", ")} };
|
|
3879
|
+
`,
|
|
3880
|
+
router: [
|
|
3881
|
+
...imports.map((binding) => `import ${binding.clause} from ${binding.from};`),
|
|
3882
|
+
`import { ${shared.join(", ")} } from "./farm-client-entry";`,
|
|
3883
|
+
body,
|
|
3884
|
+
"export { spaRouter };",
|
|
3885
|
+
""
|
|
3886
|
+
].join("\n")
|
|
3887
|
+
};
|
|
3888
|
+
}
|
|
3469
3889
|
var FARM_SEGMENT_NAVIGATION_SERVER_RUNTIME = `
|
|
3470
3890
|
function getFarmLayoutKey(pattern, params) {
|
|
3471
3891
|
return pattern.replace(/\\[\\[?\\.\\.\\.([^\\]]+)\\]?\\]|\\[([^\\]]+)\\]/g, function(match, rest, name) {
|
|
@@ -3530,7 +3950,7 @@ __farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot
|
|
|
3530
3950
|
root,
|
|
3531
3951
|
renderer.componentExtensions ?? []
|
|
3532
3952
|
);
|
|
3533
|
-
const globalsCssPath =
|
|
3953
|
+
const globalsCssPath = path11.join(root, srcDir, "app", "globals.css");
|
|
3534
3954
|
const serverStyleModules = [];
|
|
3535
3955
|
const cssImport = [
|
|
3536
3956
|
...existsSync2(globalsCssPath) ? [globalsCssPath] : [],
|
|
@@ -3629,7 +4049,7 @@ function isFarmDocsPath() {
|
|
|
3629
4049
|
// Farm.js Client Runtime (no client components)
|
|
3630
4050
|
${cssImport}
|
|
3631
4051
|
${layoutImports}
|
|
3632
|
-
import { createClientCancellation, createClientPluginManager, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
4052
|
+
import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
3633
4053
|
import { createFarmDeploymentMismatchError, createFarmDeploymentRequestHeaders, isFarmDeploymentMismatchResponse } from "@farm.js/core/deployment";
|
|
3634
4054
|
${clientPluginEntry.imports}
|
|
3635
4055
|
${clientCachePersistence.imports}
|
|
@@ -3860,7 +4280,7 @@ ${generateUniversalRouterStateProperties()}
|
|
|
3860
4280
|
}
|
|
3861
4281
|
};
|
|
3862
4282
|
|
|
3863
|
-
const farmClientRuntime = createClientPluginManager(
|
|
4283
|
+
const farmClientRuntime = ${clientPluginEntry.empty ? "createPluginlessClientRuntime()" : `createClientPluginManager(
|
|
3864
4284
|
${clientPluginEntry.registrations},
|
|
3865
4285
|
{
|
|
3866
4286
|
router: spaRouter,
|
|
@@ -3868,7 +4288,7 @@ const farmClientRuntime = createClientPluginManager(
|
|
|
3868
4288
|
isProd: true,
|
|
3869
4289
|
deploymentId: window.__FARM_DEPLOYMENT_ID__,
|
|
3870
4290
|
},
|
|
3871
|
-
);
|
|
4291
|
+
)`};
|
|
3872
4292
|
window.__FARM_CLIENT_RUNTIME__ = farmClientRuntime;
|
|
3873
4293
|
void farmClientRuntime.start();
|
|
3874
4294
|
|
|
@@ -4003,7 +4423,7 @@ ${layoutImports}
|
|
|
4003
4423
|
${rendererClientImports}
|
|
4004
4424
|
${isolatedHydrationImport}
|
|
4005
4425
|
${providerClientCode.imports}
|
|
4006
|
-
import { createClientCancellation, createClientPluginManager, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, scheduleFarmIslandHydration, createFarmSearchParams, searchParamsToObject, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
4426
|
+
import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, scheduleFarmIslandHydration, createFarmSearchParams, searchParamsToObject, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
|
|
4007
4427
|
import { createFarmDeploymentMismatchError, createFarmDeploymentRequestHeaders, isFarmDeploymentMismatchResponse } from "@farm.js/core/deployment";
|
|
4008
4428
|
import { createFarmRouter, isFarmRouteActive, matchFarmRoute } from "@farm.js/core/router";
|
|
4009
4429
|
${clientPluginEntry.imports}
|
|
@@ -4263,6 +4683,7 @@ function renderFarmRoute(root, route) {
|
|
|
4263
4683
|
else root.render(route.element);
|
|
4264
4684
|
}
|
|
4265
4685
|
|
|
4686
|
+
/*farm-router-start*/
|
|
4266
4687
|
function matchesRoutePrefix(pathname, pattern) {
|
|
4267
4688
|
return pattern === "/" ||
|
|
4268
4689
|
isFarmRouteActive(pattern, getFarmRoutePathname(pathname), { exact: false });
|
|
@@ -4277,6 +4698,7 @@ function matchInterceptedRouteSlot(pathname, from) {
|
|
|
4277
4698
|
return null;
|
|
4278
4699
|
}
|
|
4279
4700
|
|
|
4701
|
+
/*farm-router-end*/
|
|
4280
4702
|
function routeSlotKey(slot) {
|
|
4281
4703
|
return slot.ownerPattern + ":" + slot.name;
|
|
4282
4704
|
}
|
|
@@ -4296,6 +4718,7 @@ function findClientRouteSlot(slot) {
|
|
|
4296
4718
|
* client navigation does not execute. The JSON ends at the first statement
|
|
4297
4719
|
* boundary where it parses, so the separator inside a string cannot cut it.
|
|
4298
4720
|
*/
|
|
4721
|
+
/*farm-router-start*/
|
|
4299
4722
|
function readPagePropsPayload(doc) {
|
|
4300
4723
|
const prefix = "window.__FARM_PROPS__=";
|
|
4301
4724
|
const separator = ";window.__FARM_INTEGRATION_API_MANIFEST__=";
|
|
@@ -4328,7 +4751,47 @@ function readRouteSlotPayload(doc) {
|
|
|
4328
4751
|
}
|
|
4329
4752
|
}
|
|
4330
4753
|
|
|
4754
|
+
/**
|
|
4755
|
+
* The settled defer() values a fetched document writes after its body, which a client
|
|
4756
|
+
* navigation does not execute either. Undefined when the document has none.
|
|
4757
|
+
*/
|
|
4758
|
+
function readDeferredDataPayload(doc) {
|
|
4759
|
+
const prefix = "window.__FARM_DEFERRED_DATA__=";
|
|
4760
|
+
for (const script of doc.querySelectorAll("script:not([src])")) {
|
|
4761
|
+
const source = (script.textContent || "").trim();
|
|
4762
|
+
if (!source.startsWith(prefix)) continue;
|
|
4763
|
+
try {
|
|
4764
|
+
return JSON.parse(source.slice(prefix.length).replace(/;$/, ""));
|
|
4765
|
+
} catch {
|
|
4766
|
+
return undefined;
|
|
4767
|
+
}
|
|
4768
|
+
}
|
|
4769
|
+
return undefined;
|
|
4770
|
+
}
|
|
4771
|
+
|
|
4772
|
+
/*farm-router-end*/
|
|
4773
|
+
// defer() values arrive as references, settled by the snapshot the server writes once the
|
|
4774
|
+
// document has rendered, and revived as promises the way development revives them. The page
|
|
4775
|
+
// and its slots share one id space. The server writes references only with a snapshot, so a
|
|
4776
|
+
// document without one has nothing to revive and never loads the reviver.
|
|
4777
|
+
async function reviveFarmDeferredPayload(page, slots, settlements) {
|
|
4778
|
+
if (!settlements) return { page: page, slots: slots };
|
|
4779
|
+
const { reviveDeferredData } = await import("@farm.js/core/deferred");
|
|
4780
|
+
return reviveDeferredData({ page: page, slots: slots }, settlements);
|
|
4781
|
+
}
|
|
4782
|
+
|
|
4783
|
+
/*farm-router-start*/
|
|
4784
|
+
function readFarmDocumentPayload(doc) {
|
|
4785
|
+
return reviveFarmDeferredPayload(
|
|
4786
|
+
readPagePropsPayload(doc),
|
|
4787
|
+
readRouteSlotPayload(doc),
|
|
4788
|
+
readDeferredDataPayload(doc),
|
|
4789
|
+
);
|
|
4790
|
+
}
|
|
4791
|
+
|
|
4792
|
+
/*farm-router-end*/
|
|
4331
4793
|
const routeSlotRoots = new Map();
|
|
4794
|
+
/*farm-router-start*/
|
|
4332
4795
|
let activeRouteInterception = null;
|
|
4333
4796
|
|
|
4334
4797
|
function resetRouteSlotRoots() {
|
|
@@ -4339,6 +4802,7 @@ function resetRouteSlotRoots() {
|
|
|
4339
4802
|
activeRouteInterception = null;
|
|
4340
4803
|
}
|
|
4341
4804
|
|
|
4805
|
+
/*farm-router-end*/
|
|
4342
4806
|
function renderClientRouteSlot(slot, registration, mode) {
|
|
4343
4807
|
const container = document.getElementById(slot.containerId);
|
|
4344
4808
|
if (!container || !registration?.Component) return false;
|
|
@@ -4383,6 +4847,7 @@ function hydrateInitialRouteSlots() {
|
|
|
4383
4847
|
}
|
|
4384
4848
|
}
|
|
4385
4849
|
|
|
4850
|
+
/*farm-router-start*/
|
|
4386
4851
|
function renderRouteInterception(slot, registration, from, nextDocument) {
|
|
4387
4852
|
const container = document.getElementById(slot.containerId);
|
|
4388
4853
|
if (!container || !registration?.Component) return false;
|
|
@@ -4428,13 +4893,22 @@ function clearRouteInterception(destination) {
|
|
|
4428
4893
|
return destination === active.from;
|
|
4429
4894
|
}
|
|
4430
4895
|
|
|
4896
|
+
/*farm-router-end*/
|
|
4431
4897
|
// State
|
|
4432
4898
|
let reactRoot = null;
|
|
4433
4899
|
let reactRootContainer = null;
|
|
4434
|
-
let currentPathname = null;
|
|
4435
4900
|
let isHydrated = false;
|
|
4436
4901
|
let pendingPageHydrationController = null;
|
|
4437
4902
|
|
|
4903
|
+
function setFarmReactRoot(root, container) {
|
|
4904
|
+
reactRoot = root;
|
|
4905
|
+
reactRootContainer = container;
|
|
4906
|
+
}
|
|
4907
|
+
|
|
4908
|
+
function setFarmHydrated() {
|
|
4909
|
+
isHydrated = true;
|
|
4910
|
+
}
|
|
4911
|
+
|
|
4438
4912
|
${generateUniversalRouterStateRuntime(islandValues)}
|
|
4439
4913
|
|
|
4440
4914
|
function cancelPendingPageHydration() {
|
|
@@ -4451,7 +4925,14 @@ function resetReactRoot() {
|
|
|
4451
4925
|
isHydrated = false;
|
|
4452
4926
|
}
|
|
4453
4927
|
|
|
4454
|
-
${islandValues ? FARM_DOCUMENT_PARSED_RUNTIME
|
|
4928
|
+
${islandValues ? `${FARM_DOCUMENT_PARSED_RUNTIME}// A deferred reference in the payload, settled by the snapshot that follows the body.
|
|
4929
|
+
function hasFarmDeferredReference(value) {
|
|
4930
|
+
if (!value || typeof value !== "object") return false;
|
|
4931
|
+
if (typeof value.$farmDeferred === "string") return true;
|
|
4932
|
+
return Object.values(value).some(hasFarmDeferredReference);
|
|
4933
|
+
}
|
|
4934
|
+
|
|
4935
|
+
` : ""}// Hydrate client components
|
|
4455
4936
|
async function hydrate() {
|
|
4456
4937
|
await window.__FARM_PPR_REFRESH_PROMISE__;
|
|
4457
4938
|
// A PPR refresh that is still retrying must not replace DOM once hydration starts.
|
|
@@ -4464,10 +4945,19 @@ async function hydrate() {
|
|
|
4464
4945
|
!matched ||
|
|
4465
4946
|
!matched.route.hasIsolatedClientBoundaries ||
|
|
4466
4947
|
matched.route.pageShouldHydrate ||
|
|
4467
|
-
hasHydratableLayout(pathname)
|
|
4948
|
+
hasHydratableLayout(pathname) ||
|
|
4949
|
+
hasFarmDeferredReference(window.__FARM_ROUTE_SLOTS__)
|
|
4468
4950
|
) {
|
|
4469
4951
|
await farmDocumentParsed();
|
|
4470
4952
|
}` : ""}
|
|
4953
|
+
// The snapshot follows the body: this entry runs after it, or waited for it above.
|
|
4954
|
+
const initialPayload = await reviveFarmDeferredPayload(
|
|
4955
|
+
window.__FARM_PROPS__,
|
|
4956
|
+
window.__FARM_ROUTE_SLOTS__,
|
|
4957
|
+
window.__FARM_DEFERRED_DATA__,
|
|
4958
|
+
);
|
|
4959
|
+
window.__FARM_PROPS__ = initialPayload.page;
|
|
4960
|
+
window.__FARM_ROUTE_SLOTS__ = initialPayload.slots;
|
|
4471
4961
|
|
|
4472
4962
|
if (await hydrateFarmDocsAdapterRuntime()) {
|
|
4473
4963
|
return;
|
|
@@ -4486,7 +4976,13 @@ async function hydrate() {
|
|
|
4486
4976
|
) {
|
|
4487
4977
|
// Not cancelled by a navigation: an island it removes is disposed with its DOM, and one in a
|
|
4488
4978
|
// layout it keeps still waits for its trigger, with any click it already holds.
|
|
4979
|
+
const hydrationSession = await farmClientRuntime.beginHydration({
|
|
4980
|
+
container: document.getElementById("root") || document.body,
|
|
4981
|
+
mode: "hydrate",
|
|
4982
|
+
});
|
|
4983
|
+
// Each island reports and recovers its own failure, so this resolves once they are live.
|
|
4489
4984
|
await hydrateFarmIsolatedClientBoundaries(document);
|
|
4985
|
+
await farmClientRuntime.completeHydration(hydrationSession);
|
|
4490
4986
|
return;
|
|
4491
4987
|
}` : ""}
|
|
4492
4988
|
|
|
@@ -4547,7 +5043,6 @@ async function hydrate() {
|
|
|
4547
5043
|
}
|
|
4548
5044
|
renderFarmRoute(reactRoot, routeState);
|
|
4549
5045
|
}
|
|
4550
|
-
currentPathname = pathname;
|
|
4551
5046
|
await farmClientRuntime.completeHydration(hydrationSession);
|
|
4552
5047
|
} catch (error) {
|
|
4553
5048
|
await farmClientRuntime.failHydration(hydrationSession, error);
|
|
@@ -4568,6 +5063,7 @@ async function hydrate() {
|
|
|
4568
5063
|
}
|
|
4569
5064
|
}
|
|
4570
5065
|
|
|
5066
|
+
/*farm-router-start*/
|
|
4571
5067
|
// A layout boundary is the same layout when its key matches: islands mode keys it by pattern and
|
|
4572
5068
|
// params, so a layout whose params change renders again. Other modes compare patterns.
|
|
4573
5069
|
function getLayoutIdentity(boundary) {
|
|
@@ -4663,6 +5159,47 @@ async function streamFarmNavigation(stream, root, isCurrent) {
|
|
|
4663
5159
|
${isolatedHydrationEnabled ? "farmIsolatedHydrationRuntime.endStream?.(root);\n if (!queued) run();" : ""}
|
|
4664
5160
|
}` : ""}
|
|
4665
5161
|
|
|
5162
|
+
// Suspense content streams, so a fresh response holds its fallback where the live DOM holds the
|
|
5163
|
+
// result. Compare without it.
|
|
5164
|
+
function removeSuspenseContent(root) {
|
|
5165
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_COMMENT);
|
|
5166
|
+
const comments = [];
|
|
5167
|
+
while (walker.nextNode()) comments.push(walker.currentNode);
|
|
5168
|
+
let depth = 0;
|
|
5169
|
+
let start = null;
|
|
5170
|
+
for (const comment of comments) {
|
|
5171
|
+
if (comment.data === "$" || comment.data === "$?" || comment.data === "$!") {
|
|
5172
|
+
if (depth++ === 0) start = comment;
|
|
5173
|
+
} else if (comment.data === "/$" && depth > 0 && --depth === 0) {
|
|
5174
|
+
const range = document.createRange();
|
|
5175
|
+
range.setStartAfter(start);
|
|
5176
|
+
range.setEndBefore(comment);
|
|
5177
|
+
range.deleteContents();
|
|
5178
|
+
start.data = "$";
|
|
5179
|
+
}
|
|
5180
|
+
}
|
|
5181
|
+
}
|
|
5182
|
+
|
|
5183
|
+
// A layout's own server output, without what it wraps and without its islands, whose live DOM
|
|
5184
|
+
// always differs from fresh HTML.
|
|
5185
|
+
function getLayoutShell(root, patterns, index) {
|
|
5186
|
+
const shell = findLayoutBoundary(root, patterns[index])?.cloneNode(true);
|
|
5187
|
+
if (!shell) return null;
|
|
5188
|
+
const inner = index + 1 < patterns.length
|
|
5189
|
+
? findLayoutBoundary(shell, patterns[index + 1])
|
|
5190
|
+
: shell.querySelector("#__farm_page__");
|
|
5191
|
+
inner?.replaceChildren();
|
|
5192
|
+
removeSuspenseContent(shell);
|
|
5193
|
+
shell.querySelectorAll("script").forEach(function(script) { script.remove(); });
|
|
5194
|
+
shell.querySelectorAll("f-island").forEach(function(island) {
|
|
5195
|
+
island.replaceChildren();
|
|
5196
|
+
Array.from(island.attributes).forEach(function(attribute) {
|
|
5197
|
+
island.removeAttribute(attribute.name);
|
|
5198
|
+
});
|
|
5199
|
+
});
|
|
5200
|
+
return shell.innerHTML;
|
|
5201
|
+
}
|
|
5202
|
+
|
|
4666
5203
|
function replaceSharedLayoutBoundary(currentRoot, nextRoot, refresh = false) {
|
|
4667
5204
|
const currentPatterns = getLayoutPatterns(currentRoot);
|
|
4668
5205
|
const nextPatterns = getLayoutPatterns(nextRoot);
|
|
@@ -4670,7 +5207,11 @@ function replaceSharedLayoutBoundary(currentRoot, nextRoot, refresh = false) {
|
|
|
4670
5207
|
while (
|
|
4671
5208
|
sharedCount < currentPatterns.length &&
|
|
4672
5209
|
sharedCount < nextPatterns.length &&
|
|
4673
|
-
currentPatterns[sharedCount] === nextPatterns[sharedCount]
|
|
5210
|
+
currentPatterns[sharedCount] === nextPatterns[sharedCount] &&
|
|
5211
|
+
// A refresh renders every layout again: start at the first one whose output changed.
|
|
5212
|
+
(!refresh ||
|
|
5213
|
+
getLayoutShell(currentRoot, currentPatterns, sharedCount) ===
|
|
5214
|
+
getLayoutShell(nextRoot, nextPatterns, sharedCount))
|
|
4674
5215
|
) sharedCount++;
|
|
4675
5216
|
|
|
4676
5217
|
const nextTreeRoot = nextPatterns.length
|
|
@@ -4819,7 +5360,8 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
4819
5360
|
const html = await this.fetchPage(to, from, false, true, navigation.controller.signal);
|
|
4820
5361
|
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
4821
5362
|
const doc = new DOMParser().parseFromString(html, "text/html");
|
|
4822
|
-
const slotPayload =
|
|
5363
|
+
const slotPayload = (await readFarmDocumentPayload(doc)).slots;
|
|
5364
|
+
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
4823
5365
|
const selectedSlot = slotPayload.find(function(slot) {
|
|
4824
5366
|
return slot.interception &&
|
|
4825
5367
|
slot.name === intercepted.slot.name &&
|
|
@@ -4881,11 +5423,9 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
4881
5423
|
if (container) {
|
|
4882
5424
|
if (reactRoot && reactRootContainer !== container) resetReactRoot();
|
|
4883
5425
|
if (!reactRoot) {
|
|
4884
|
-
|
|
4885
|
-
reactRootContainer = container;
|
|
5426
|
+
setFarmReactRoot(createRoot(container), container);
|
|
4886
5427
|
}
|
|
4887
5428
|
renderFarmRoute(reactRoot, routeState);
|
|
4888
|
-
currentPathname = pathname;
|
|
4889
5429
|
}
|
|
4890
5430
|
this.currentPath = to;
|
|
4891
5431
|
});
|
|
@@ -4904,6 +5444,11 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
4904
5444
|
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
4905
5445
|
await this.runViewTransition(options.viewTransition, async () => {
|
|
4906
5446
|
if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
|
|
5447
|
+
// The history entry comes first, as on the client-render path: swapContent shows the
|
|
5448
|
+
// page and its title, then waits for its islands, and a Back pressed meanwhile must
|
|
5449
|
+
// leave the page on screen, not the one before it. Its islands also hydrate at their URL.
|
|
5450
|
+
this.writeHistoryEntry(action, url.pathname + url.search, options.state, url);
|
|
5451
|
+
this.currentPath = to;
|
|
4907
5452
|
let swappedHtml = html;
|
|
4908
5453
|
let swapped = await this.swapContent(
|
|
4909
5454
|
html,
|
|
@@ -4937,9 +5482,6 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
4937
5482
|
throw new Error("Farm could not swap the target document");
|
|
4938
5483
|
}
|
|
4939
5484
|
this.takeNavigationStream(swappedHtml);
|
|
4940
|
-
this.writeHistoryEntry(action, url.pathname + url.search, options.state, url);
|
|
4941
|
-
currentPathname = pathname;
|
|
4942
|
-
this.currentPath = to;
|
|
4943
5485
|
});
|
|
4944
5486
|
}
|
|
4945
5487
|
|
|
@@ -4993,10 +5535,12 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
4993
5535
|
const doc = parser.parseFromString(html, "text/html");
|
|
4994
5536
|
if (isFarmLocaleDocumentChange(doc)) return false;
|
|
4995
5537
|
if (doc.getElementById("nd-docs-layout")) return false;
|
|
4996
|
-
const nextRouteSlots = readRouteSlotPayload(doc);
|
|
4997
|
-
const nextPageProps = readPagePropsPayload(doc);
|
|
4998
5538
|
const isNavigationCurrent = () =>
|
|
4999
5539
|
this.isCurrentNavigation(navigation, clientNavigation);
|
|
5540
|
+
const nextPayload = await readFarmDocumentPayload(doc);
|
|
5541
|
+
if (!isNavigationCurrent()) return false;
|
|
5542
|
+
const nextRouteSlots = nextPayload.slots;
|
|
5543
|
+
const nextPageProps = nextPayload.page;
|
|
5000
5544
|
|
|
5001
5545
|
reconcileFarmDocumentHead(doc);
|
|
5002
5546
|
|
|
@@ -5040,7 +5584,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5040
5584
|
if (routeState) {
|
|
5041
5585
|
renderFarmRoute(reactRoot, routeState);
|
|
5042
5586
|
window.__FARM_ROUTE_SLOTS__ = nextRouteSlots;
|
|
5043
|
-
|
|
5587
|
+
setFarmHydrated();
|
|
5044
5588
|
return true;
|
|
5045
5589
|
}
|
|
5046
5590
|
}
|
|
@@ -5080,9 +5624,8 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5080
5624
|
);
|
|
5081
5625
|
if (!isNavigationCurrent()) return false;
|
|
5082
5626
|
if (routeState) {
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
isHydrated = true;
|
|
5627
|
+
setFarmReactRoot(hydrateFarmRoute(pageContainer, routeState), pageContainer);
|
|
5628
|
+
setFarmHydrated();
|
|
5086
5629
|
}
|
|
5087
5630
|
${isolatedHydrationEnabled ? `if (matched.route.hasIsolatedClientBoundaries && !hydrateLayouts) {
|
|
5088
5631
|
await hydrateFarmIsolatedClientBoundaries(
|
|
@@ -5166,7 +5709,9 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
|
|
|
5166
5709
|
}
|
|
5167
5710
|
};
|
|
5168
5711
|
|
|
5169
|
-
|
|
5712
|
+
/*farm-router-end*/
|
|
5713
|
+
/*farm-router-stub*/
|
|
5714
|
+
const farmClientRuntime = ${clientPluginEntry.empty ? "createPluginlessClientRuntime()" : `createClientPluginManager(
|
|
5170
5715
|
${clientPluginEntry.registrations},
|
|
5171
5716
|
{
|
|
5172
5717
|
router: spaRouter,
|
|
@@ -5174,13 +5719,15 @@ const farmClientRuntime = createClientPluginManager(
|
|
|
5174
5719
|
isProd: true,
|
|
5175
5720
|
deploymentId: window.__FARM_DEPLOYMENT_ID__,
|
|
5176
5721
|
},
|
|
5177
|
-
);
|
|
5722
|
+
)`};
|
|
5178
5723
|
window.__FARM_CLIENT_RUNTIME__ = farmClientRuntime;
|
|
5179
5724
|
void farmClientRuntime.start();
|
|
5180
5725
|
|
|
5181
5726
|
// Expose router globally
|
|
5727
|
+
/*farm-router-start*/
|
|
5182
5728
|
spaRouter.initializeHistory();
|
|
5183
5729
|
window.__FARM_SPA_ROUTER__ = spaRouter;
|
|
5730
|
+
/*farm-router-end*/
|
|
5184
5731
|
|
|
5185
5732
|
window.addEventListener("beforeunload", function(event) {
|
|
5186
5733
|
if (spaRouter.shouldBlockUnload()) {
|
|
@@ -5226,7 +5773,7 @@ void hydrate();
|
|
|
5226
5773
|
async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime) {
|
|
5227
5774
|
const viteBuild = productionVite.build;
|
|
5228
5775
|
const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
5229
|
-
const { PluginManager: PluginManager2 } = await import("./plugin-
|
|
5776
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-SAS22JL7.mjs");
|
|
5230
5777
|
const fs4 = await import("fs/promises");
|
|
5231
5778
|
const pluginManager = new PluginManager2({
|
|
5232
5779
|
config,
|
|
@@ -5242,9 +5789,9 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
5242
5789
|
buildLifetime: rendererBuildLifetime
|
|
5243
5790
|
});
|
|
5244
5791
|
if (!hasScopedPostcssConfig) {
|
|
5245
|
-
postcssConfigDir = await fs4.mkdtemp(
|
|
5792
|
+
postcssConfigDir = await fs4.mkdtemp(path11.join(os.tmpdir(), "farm-postcss-"));
|
|
5246
5793
|
await fs4.writeFile(
|
|
5247
|
-
|
|
5794
|
+
path11.join(postcssConfigDir, "postcss.config.cjs"),
|
|
5248
5795
|
"module.exports = { plugins: [] };\n"
|
|
5249
5796
|
);
|
|
5250
5797
|
tailwindVitePlugin = await loadTailwindVitePlugin({
|
|
@@ -5329,10 +5876,11 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
5329
5876
|
const appDirs = getFarmAppDirectories(config);
|
|
5330
5877
|
let openAPIReference = null;
|
|
5331
5878
|
if (config.openapi.enabled && config.openapi.route) {
|
|
5332
|
-
const { OpenAPIManager, renderOpenAPIReferenceHTML } = await import("./manager-
|
|
5879
|
+
const { OpenAPIManager, renderOpenAPIReferenceHTML } = await import("./manager-JIA66YJ2.mjs");
|
|
5333
5880
|
const openAPIManager = new OpenAPIManager(appDirs, config.openapi, {
|
|
5334
5881
|
mode: "production",
|
|
5335
|
-
apiBaseURL: config.api.baseURL
|
|
5882
|
+
apiBaseURL: config.api.baseURL,
|
|
5883
|
+
loadModule: (filePath) => apiRouteManager.loadModule(filePath)
|
|
5336
5884
|
});
|
|
5337
5885
|
const spec = await openAPIManager.generateSpec();
|
|
5338
5886
|
if (!spec) {
|
|
@@ -5406,7 +5954,8 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
5406
5954
|
fontAssets: toFarmDocsPublicFontAssets(resolveFarmDocsFontAssets(root)),
|
|
5407
5955
|
fontStylesheetHref: "/farm-fonts.css",
|
|
5408
5956
|
globalStylesheetHref: FARM_CLIENT_CSS_HREF_PLACEHOLDER,
|
|
5409
|
-
isPathGuarded: (pathname) => guardedPaths.has(pathname)
|
|
5957
|
+
isPathGuarded: (pathname) => guardedPaths.has(pathname),
|
|
5958
|
+
basePath: config.basePath
|
|
5410
5959
|
});
|
|
5411
5960
|
})()
|
|
5412
5961
|
) : null;
|
|
@@ -5443,6 +5992,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
5443
5992
|
);
|
|
5444
5993
|
const virtualEntryId = "\0virtual:farm-ssr-entry";
|
|
5445
5994
|
const useExternalMetadataImageRuntime = shouldUseExternalMetadataImageRuntime(preset, true);
|
|
5995
|
+
const edgeMetadataImageRuntime = getEdgeMetadataImageRuntime(preset);
|
|
5446
5996
|
const omitCoreMetadataImageRuntime = !metadataImageRoutes.some(
|
|
5447
5997
|
(image) => image.sourceType === "module"
|
|
5448
5998
|
);
|
|
@@ -5558,13 +6108,22 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
5558
6108
|
...tailwindVitePlugin ? [tailwindVitePlugin] : [],
|
|
5559
6109
|
...rendererVitePlugins,
|
|
5560
6110
|
...config.vite.plugins || [],
|
|
5561
|
-
|
|
6111
|
+
// On an edge preset any server module may import @vercel/og.
|
|
6112
|
+
...(edgeMetadataImageRuntime ? edgeMetadataImageRuntime.wasm === "bytes" : !useExternalMetadataImageRuntime && metadataImageRoutes.some((image) => image.sourceType === "module")) ? [{ ...createMetadataImageWasmPlugin(), enforce: "pre" }] : [],
|
|
5562
6113
|
...omitCoreMetadataImageRuntime ? [
|
|
5563
6114
|
{
|
|
5564
6115
|
...createOmittedMetadataImageRuntimePlugin(useExternalMetadataImageRuntime),
|
|
5565
6116
|
enforce: "pre"
|
|
5566
6117
|
}
|
|
5567
6118
|
] : [],
|
|
6119
|
+
// After the stub above, which must take core's own import first.
|
|
6120
|
+
...edgeMetadataImageRuntime ? [
|
|
6121
|
+
{
|
|
6122
|
+
...createEdgeMetadataImageRuntimePlugin(edgeMetadataImageRuntime),
|
|
6123
|
+
enforce: "pre"
|
|
6124
|
+
},
|
|
6125
|
+
createVercelOgFontInlinePlugin(edgeMetadataImageRuntime.runtime)
|
|
6126
|
+
] : [],
|
|
5568
6127
|
{ ...createReactProductionModePlugin(), enforce: "pre" },
|
|
5569
6128
|
farmServerOnlyEntriesPlugin(),
|
|
5570
6129
|
farmPlugin({ ...config, isolatedClientBoundaryModules }, pluginManager),
|
|
@@ -5640,7 +6199,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
|
|
|
5640
6199
|
}
|
|
5641
6200
|
function readFarmAppPackageIdentity(root) {
|
|
5642
6201
|
try {
|
|
5643
|
-
return JSON.parse(readFileSync(
|
|
6202
|
+
return JSON.parse(readFileSync(path11.join(root, "package.json"), "utf8"));
|
|
5644
6203
|
} catch {
|
|
5645
6204
|
return {};
|
|
5646
6205
|
}
|
|
@@ -5775,17 +6334,33 @@ function matchLocalIntegrationRequest(request) {
|
|
|
5775
6334
|
});` : "return null;"}
|
|
5776
6335
|
}
|
|
5777
6336
|
|
|
5778
|
-
async function handleIntegrationRequest(request, ranMiddleware, clientAddress) {
|
|
5779
|
-
${options.hasServerRuntimeIntegrations ? `
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
6337
|
+
async function handleIntegrationRequest(request, ranMiddleware, clientAddress, reportRuntimeError) {
|
|
6338
|
+
${options.hasServerRuntimeIntegrations ? `try {
|
|
6339
|
+
return await dispatchIntegrationRequests(
|
|
6340
|
+
serverRuntimeIntegrations,
|
|
6341
|
+
{
|
|
6342
|
+
config: integrationRuntimeConfig,
|
|
6343
|
+
isDev: false,
|
|
6344
|
+
isProd: true,
|
|
6345
|
+
},
|
|
6346
|
+
request,
|
|
6347
|
+
{ ranMiddleware, clientAddress },
|
|
6348
|
+
);
|
|
6349
|
+
} catch (error) {
|
|
6350
|
+
// Integration middleware on any other request keeps failing that request.
|
|
6351
|
+
if (!matchLocalIntegrationRequest(request)) throw error;
|
|
6352
|
+
// A throwing integration route answers 500, as an API route does: a plugin's
|
|
6353
|
+
// runtime.error observes the throw, and runtime.after still sees this 500.
|
|
6354
|
+
console.error("[Integration Error] " + new URL(request.url).pathname + ":", error);
|
|
6355
|
+
await reportRuntimeError?.(error);
|
|
6356
|
+
return {
|
|
6357
|
+
response: new Response(JSON.stringify({ error: "Internal Server Error" }), {
|
|
6358
|
+
status: 500,
|
|
6359
|
+
headers: { "Content-Type": "application/json" },
|
|
6360
|
+
}),
|
|
6361
|
+
setCookies: [],
|
|
6362
|
+
};
|
|
6363
|
+
}` : `return { response: null, setCookies: [] };`}
|
|
5789
6364
|
}
|
|
5790
6365
|
|
|
5791
6366
|
// Merge Set-Cookie values forwarded by a passthrough integration middleware
|
|
@@ -6046,6 +6621,7 @@ if (typeof ReactDOMServer.configureApp !== "function") {
|
|
|
6046
6621
|
ReactDOMServer.configureApp(__farmAppSetup);`;
|
|
6047
6622
|
}
|
|
6048
6623
|
function generateVirtualEntryCode(apiRoutes, pageRoutes, layoutRoutes, routeSlots, errorRoutes, metadataImageRoutes, applicationMetadataRoutes, middlewareRoutes, redirectRoutes, configuredRewriteRoutes, configuredHeaderRoutes, openAPIReference, notFoundPath, instrumentationPath, config, farmDocsPrecompiledManifest, configModulePath, hasServerRuntimeIntegrations, hasRuntimeIntegrationConfig, hasConfiguredRuntimePlugins, hasServerRuntimePlugins, preset, i18nCatalogs, isolatedClientBoundaryModules, hydrationPlanCache, mobileShellLoadingRoutes = []) {
|
|
6624
|
+
const farmRendererDisabled = isFarmRendererDisabled(config.renderer);
|
|
6049
6625
|
const farmIslandsMode = resolveFarmServerComponentsMode(config.experimental?.serverComponents) === "islands";
|
|
6050
6626
|
const farmClientBoot = canBootFarmIslandsClient(config);
|
|
6051
6627
|
const farmMobileClient = shouldBuildFarmMobileClient(config);
|
|
@@ -6327,6 +6903,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
6327
6903
|
containerId: ${JSON.stringify(slot.containerId)},
|
|
6328
6904
|
interception: ${JSON.stringify(slot.interception)},
|
|
6329
6905
|
fallback: ${JSON.stringify(slot.fallback)},
|
|
6906
|
+
hydrates: ${!farmIslandsMode || getClientModuleMetadata(slot.modulePath, config.root).isClientComponent},
|
|
6330
6907
|
module: ${varName},
|
|
6331
6908
|
}`);
|
|
6332
6909
|
});
|
|
@@ -6432,6 +7009,9 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
6432
7009
|
applyFarmCspNonceToResponse,
|
|
6433
7010
|
createFarmCspNonce,
|
|
6434
7011
|
stampFarmCspNonce,
|
|
7012
|
+
isDeferred,
|
|
7013
|
+
prepareDeferredData,
|
|
7014
|
+
snapshotDeferredData,
|
|
6435
7015
|
applyFarmPreviewRobotsTag,
|
|
6436
7016
|
applyFarmThemeDocument,
|
|
6437
7017
|
appendFarmLinkHeader,
|
|
@@ -6457,9 +7037,12 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
|
|
|
6457
7037
|
collectFarmLlmsTxtPages,
|
|
6458
7038
|
createFarmDefaultLlmsTxt,
|
|
6459
7039
|
createFarmLlmsMarkdownReader,
|
|
7040
|
+
isFarmPageNoIndex,
|
|
6460
7041
|
listFarmMCPLlmsTxtLinks,
|
|
7042
|
+
readFarmLlmsMarkdownFrom,
|
|
6461
7043
|
registerFarmMCPServer,
|
|
6462
7044
|
renderFarmLlmsFullTxt,
|
|
7045
|
+
resolveFarmAgentOrigin,
|
|
6463
7046
|
createFarmLlmsFullRenderer,
|
|
6464
7047
|
createFarmThemeDocumentParts,
|
|
6465
7048
|
createFarmLocaleCookie,
|
|
@@ -6592,7 +7175,7 @@ import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
|
|
|
6592
7175
|
const markdownHandlerImport = config.md?.enabled ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
|
|
6593
7176
|
const appMarkdownImport = hasMarkdownPages ? `import { FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS, createFarmMarkdownRouteModule, createFarmMarkdownSourceResponse, isFarmMarkdownPublicSourceResponse } from "@farm.js/core/internal/app-markdown-runtime";` : "const createFarmMarkdownSourceResponse = null;\nconst isFarmMarkdownPublicSourceResponse = null;";
|
|
6594
7177
|
const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, FARM_MARKDOWN_PAGE_CHECK_HEADER, _isFarmMarkdownPageCheck, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
|
|
6595
|
-
const mdxComponentsPath = typeof config.mdx?.components === "string" ?
|
|
7178
|
+
const mdxComponentsPath = typeof config.mdx?.components === "string" ? path11.isAbsolute(config.mdx.components) ? config.mdx.components : path11.join(config.root, config.mdx.components) : null;
|
|
6596
7179
|
const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from ${toVirtualEntryImportSpecifier(mdxComponentsPath)};` : "";
|
|
6597
7180
|
const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
|
|
6598
7181
|
const layerConfigImports = layerConfigPaths.map(
|
|
@@ -6644,7 +7227,7 @@ function matchLocalAPIRequest(request) {
|
|
|
6644
7227
|
return matchBuiltAPIRoute(new URL(request.url).pathname);
|
|
6645
7228
|
}
|
|
6646
7229
|
|
|
6647
|
-
async function handleAPIRequest(request) {
|
|
7230
|
+
async function handleAPIRequest(request, reportRuntimeError) {
|
|
6648
7231
|
const url = new URL(request.url);
|
|
6649
7232
|
const method = request.method.toUpperCase();
|
|
6650
7233
|
const match = matchLocalAPIRequest(request);
|
|
@@ -6711,6 +7294,8 @@ async function handleAPIRequest(request) {
|
|
|
6711
7294
|
error,
|
|
6712
7295
|
});
|
|
6713
7296
|
console.error(\`[API Error] \${url.pathname}:\`, error);
|
|
7297
|
+
// A plugin's runtime.error observes the throw; runtime.after still sees this 500.
|
|
7298
|
+
await reportRuntimeError?.(error);
|
|
6714
7299
|
return new Response(
|
|
6715
7300
|
JSON.stringify({ error: "Internal Server Error" }),
|
|
6716
7301
|
{ status: 500, headers: { "Content-Type": "application/json" } }
|
|
@@ -7050,6 +7635,7 @@ globalThis.__FARM_DOCS_RUNTIME_CONFIG__ = {
|
|
|
7050
7635
|
srcDir: ${JSON.stringify(config.srcDir)},
|
|
7051
7636
|
docs: farmDocsResolvedConfig,
|
|
7052
7637
|
guardedPaths: farmDocsGuardedPaths,
|
|
7638
|
+
basePath: ${JSON.stringify(config.basePath)},
|
|
7053
7639
|
};
|
|
7054
7640
|
const farmDocsPrecompiledRuntime = ${hasPrecompiledDocs ? `createFarmDocsPrecompiledRuntime(${JSON.stringify(farmDocsPrecompiledManifest)})` : "null"};
|
|
7055
7641
|
// Filled in from the client build once it has finished (see buildNitroUniversal).
|
|
@@ -7105,12 +7691,13 @@ const farmDocsHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsP
|
|
|
7105
7691
|
// The client stylesheet carries globals.css under a content-hashed name.
|
|
7106
7692
|
globalStylesheetHref: ${JSON.stringify(FARM_CLIENT_CSS_HREF_PLACEHOLDER)},
|
|
7107
7693
|
isPathGuarded: isFarmDocsPathGuarded,
|
|
7694
|
+
basePath: ${JSON.stringify(config.basePath)},
|
|
7108
7695
|
})` : "null"};
|
|
7109
|
-
const farmDocsAPIHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleAPIRequest" : adapterOwnsDocsRuntime ? "null" : `createFarmDocsAPIHandler({ rootDir: farmDocsRuntimeRoot, srcDir: ${JSON.stringify(config.srcDir)}, docs: farmDocsResolvedConfig, isPathGuarded: isFarmDocsPathGuarded })` : "null"};
|
|
7696
|
+
const farmDocsAPIHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleAPIRequest" : adapterOwnsDocsRuntime ? "null" : `createFarmDocsAPIHandler({ rootDir: farmDocsRuntimeRoot, srcDir: ${JSON.stringify(config.srcDir)}, docs: farmDocsResolvedConfig, isPathGuarded: isFarmDocsPathGuarded, basePath: ${JSON.stringify(config.basePath)} })` : "null"};
|
|
7110
7697
|
|
|
7111
7698
|
// API routes bundled at build time
|
|
7112
7699
|
const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
|
|
7113
|
-
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path:
|
|
7700
|
+
]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path13, methods }) => ({ path: path13, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)}, dispatch: dispatchFarmPluginAPIRequest })` : ""};
|
|
7114
7701
|
// A plugin calling an app endpoint (an MCP tool, say) goes through the whole
|
|
7115
7702
|
// pipeline, so the endpoint's middleware and integration guards run for it.
|
|
7116
7703
|
function dispatchFarmPluginAPIRequest(request) {
|
|
@@ -7130,6 +7717,9 @@ function fetchFarmInnerRequest(request, context) {
|
|
|
7130
7717
|
return fetch(new Request(request, { headers }), context);
|
|
7131
7718
|
}
|
|
7132
7719
|
const farmLocalAPIBasePath = ${JSON.stringify(resolveFarmAPIServerBasePath(config.api))};
|
|
7720
|
+
// Reports a failure Farm answers itself (an API or integration route's 500) to the plugin
|
|
7721
|
+
// runtime request.
|
|
7722
|
+
const farmRuntimeErrorSlot = Symbol("farm.runtime.error.slot");
|
|
7133
7723
|
const farmOpenAPIReference = ${JSON.stringify(openAPIReference)};
|
|
7134
7724
|
${config.agent?.apiCatalog ? `const farmApiCatalogInput = ${JSON.stringify(resolveFarmApiCatalogInput(config))};
|
|
7135
7725
|
` : ""}${config.agent?.manifest !== false ? `const farmAppManifestInput = ${JSON.stringify(
|
|
@@ -7252,6 +7842,17 @@ function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, page
|
|
|
7252
7842
|
'</script>' + stampFarmCspNonce('<script>' + source + '</script>');
|
|
7253
7843
|
}
|
|
7254
7844
|
|
|
7845
|
+
// The settled defer() values the bootstrap script's props refer to, as development writes them.
|
|
7846
|
+
// It runs once the document has rendered: React has awaited every value a component read.
|
|
7847
|
+
function renderFarmDeferredDataScript(records) {
|
|
7848
|
+
if (!records || records.length === 0) return "";
|
|
7849
|
+
return stampFarmCspNonce(
|
|
7850
|
+
'<script>window.__FARM_DEFERRED_DATA__=' +
|
|
7851
|
+
serializeFarmInlineValue(snapshotDeferredData(records)) +
|
|
7852
|
+
';</script>'
|
|
7853
|
+
);
|
|
7854
|
+
}
|
|
7855
|
+
|
|
7255
7856
|
function renderFarmRendererHydrationScript() {
|
|
7256
7857
|
return typeof ReactDOMServer.generateHydrationScript === "function"
|
|
7257
7858
|
? stampFarmCspNonce(ReactDOMServer.generateHydrationScript())
|
|
@@ -7313,6 +7914,27 @@ function createFarmFlushToken() {
|
|
|
7313
7914
|
return token;
|
|
7314
7915
|
}
|
|
7315
7916
|
|
|
7917
|
+
async function farmKeptLayoutsRender(ReactDOMServer, layouts, keptCount, params) {
|
|
7918
|
+
let element = null;
|
|
7919
|
+
for (let index = keptCount - 1; index >= 0; index--) {
|
|
7920
|
+
const Layout = layouts[index].module.default;
|
|
7921
|
+
if (Layout) element = React.createElement(Layout, { children: element, params });
|
|
7922
|
+
}
|
|
7923
|
+
try {
|
|
7924
|
+
const rendered = await renderFarmElement(
|
|
7925
|
+
ReactDOMServer,
|
|
7926
|
+
wrapWithFarmIntegrationProviders(element),
|
|
7927
|
+
);
|
|
7928
|
+
if (rendered.stream) {
|
|
7929
|
+
const reader = rendered.stream.getReader();
|
|
7930
|
+
while (!(await reader.read()).done);
|
|
7931
|
+
}
|
|
7932
|
+
return rendered.streamErrors.length === 0;
|
|
7933
|
+
} catch {
|
|
7934
|
+
return false;
|
|
7935
|
+
}
|
|
7936
|
+
}
|
|
7937
|
+
|
|
7316
7938
|
async function renderFarmElement(ReactDOMServer, element, routeKey, flushToken = "") {
|
|
7317
7939
|
// Written after each React flush in a streamed navigation (flushToken): the browser swaps in
|
|
7318
7940
|
// the shell, then adds each Suspense boundary as soon as the flush that completed it ends.
|
|
@@ -8291,7 +8913,8 @@ function createFarmAgentRobotsResponse(request) {
|
|
|
8291
8913
|
// Static pages a path-specific guard covers (non-root middleware.ts, a config or
|
|
8292
8914
|
// integration middleware matcher naming the path), decided at build time.
|
|
8293
8915
|
// sitemap.xml, llms.txt and the default MCP server never list them, nor a page behind
|
|
8294
|
-
// a route guard
|
|
8916
|
+
// a route guard, nor one that renders noindex through its own robots or, without one,
|
|
8917
|
+
// its nearest layout's.
|
|
8295
8918
|
const farmAgentGuardedPages = new Set(${JSON.stringify(
|
|
8296
8919
|
pageRoutes.map((route) => route.pattern).filter(
|
|
8297
8920
|
(pattern) => !pattern.includes("[") && farmPathGuardCoversPage(
|
|
@@ -8306,7 +8929,15 @@ const farmAgentGuardedPages = new Set(${JSON.stringify(
|
|
|
8306
8929
|
function getFarmAgentListedPageRoutes() {
|
|
8307
8930
|
return pageRoutes.filter(
|
|
8308
8931
|
(route) =>
|
|
8309
|
-
!
|
|
8932
|
+
!route.pattern.includes("[") &&
|
|
8933
|
+
!farmAgentGuardedPages.has(route.pattern) &&
|
|
8934
|
+
!(route.module && route.module.__farmRouteGuard) &&
|
|
8935
|
+
!isFarmPageNoIndex(
|
|
8936
|
+
route.module && route.module.metadata,
|
|
8937
|
+
getApplicableLayouts(route.pattern, route.directory || route.pattern).map(
|
|
8938
|
+
(layout) => layout.module && layout.module.metadata,
|
|
8939
|
+
),
|
|
8940
|
+
),
|
|
8310
8941
|
);
|
|
8311
8942
|
}
|
|
8312
8943
|
${servesAgentSitemap ? `// sitemap.xml from agent.sitemap, built the same way as in development. Each page's
|
|
@@ -8373,9 +9004,21 @@ async function handleFarmDefaultMCP(request) {
|
|
|
8373
9004
|
// gets its own request context, as for a direct request.
|
|
8374
9005
|
const farmDefaultMCPReadMarkdown = createFarmLlmsMarkdownReader((page) => fetch(page));
|
|
8375
9006
|
` : ""}
|
|
9007
|
+
// The origin llms.txt and llms-full.txt link to: the root layout's metadataBase, else the
|
|
9008
|
+
// request's origin, as for the sitemap and in development.
|
|
9009
|
+
function getFarmAgentOrigin(request) {
|
|
9010
|
+
const rootLayout = layoutRoutes.find((layout) => layout.pattern === "/");
|
|
9011
|
+
return resolveFarmAgentOrigin(
|
|
9012
|
+
rootLayout && rootLayout.module && rootLayout.module.metadata
|
|
9013
|
+
? rootLayout.module.metadata.metadataBase
|
|
9014
|
+
: undefined,
|
|
9015
|
+
new URL(request.url).origin,
|
|
9016
|
+
);
|
|
9017
|
+
}
|
|
9018
|
+
|
|
8376
9019
|
// Static pages and root metadata for llms.txt, built the same way as in development.
|
|
8377
9020
|
function createFarmLlmsTxtContext(request, full) {
|
|
8378
|
-
const origin =
|
|
9021
|
+
const origin = getFarmAgentOrigin(request);
|
|
8379
9022
|
const pages = collectFarmLlmsTxtPages(
|
|
8380
9023
|
getFarmAgentListedPageRoutes().map((route) => ({ pattern: route.pattern, metadata: route.module && route.module.metadata })),
|
|
8381
9024
|
{
|
|
@@ -8406,7 +9049,11 @@ function createFarmLlmsTxtContext(request, full) {
|
|
|
8406
9049
|
? {
|
|
8407
9050
|
markdown: request.method.toUpperCase() === "HEAD"
|
|
8408
9051
|
? async () => null
|
|
8409
|
-
:
|
|
9052
|
+
: readFarmLlmsMarkdownFrom(
|
|
9053
|
+
new URL(request.url).origin,
|
|
9054
|
+
origin,
|
|
9055
|
+
createFarmLlmsMarkdownReader((page) => fetch(page)),
|
|
9056
|
+
),
|
|
8410
9057
|
}
|
|
8411
9058
|
: {}),
|
|
8412
9059
|
};
|
|
@@ -8441,7 +9088,7 @@ async function handleApplicationMetadataRouteRequest(request, routePathname) {
|
|
|
8441
9088
|
})
|
|
8442
9089
|
: routeModule.default;
|
|
8443
9090
|
const body = isLlmsFull && !(value instanceof Response)
|
|
8444
|
-
? await renderFarmLlmsFullTxt(value, { origin:
|
|
9091
|
+
? await renderFarmLlmsFullTxt(value, { origin: getFarmAgentOrigin(request), readMarkdown: llmsContext.markdown })
|
|
8445
9092
|
: value;
|
|
8446
9093
|
return createFarmMetadataRouteResponse(match.metadata.kind, body, routeModule, { method, request });
|
|
8447
9094
|
} catch (error) {
|
|
@@ -8460,10 +9107,12 @@ function matchRedirectRoute(pathname, locale, search) {
|
|
|
8460
9107
|
const params = matchRuntimePathPattern(redirect.source, pathname);
|
|
8461
9108
|
if (!params) continue;
|
|
8462
9109
|
const destination = interpolateRedirectDestination(redirect.destination, params);
|
|
9110
|
+
// Sources match the app-relative path, so an internal destination is app-relative
|
|
9111
|
+
// too: send the browser to it inside the basePath, as a localized one already is.
|
|
8463
9112
|
const localizedDestination =
|
|
8464
9113
|
locale && destination.startsWith("/") && !destination.startsWith("//")
|
|
8465
9114
|
? localizeFarmHref(destination, locale, farmI18nConfig)
|
|
8466
|
-
: destination;
|
|
9115
|
+
: applyFarmBasePath(destination);
|
|
8467
9116
|
return {
|
|
8468
9117
|
destination: appendFarmRedirectQuery(localizedDestination, search),
|
|
8469
9118
|
statusCode: redirect.statusCode ?? (redirect.permanent ? 308 : 307),
|
|
@@ -8642,11 +9291,13 @@ function hasLocalRequestRoute(request, routePathname) {
|
|
|
8642
9291
|
return true;
|
|
8643
9292
|
}
|
|
8644
9293
|
${config.docs?.enabled ? `const docsPath = normalizeRuntimePath(farmDocsResolvedConfig?.entry || "/docs");
|
|
9294
|
+
// The docs answer below the basePath; their API stays at /api/docs, as API routes do.
|
|
9295
|
+
const docsRoutePathname = stripFarmBasePath(pathname);
|
|
8645
9296
|
if (
|
|
8646
9297
|
isFarmDocsAPIRequest(pathname) ||
|
|
8647
9298
|
docsPath === "/" ||
|
|
8648
|
-
|
|
8649
|
-
|
|
9299
|
+
docsRoutePathname === docsPath ||
|
|
9300
|
+
docsRoutePathname.startsWith(docsPath + "/")
|
|
8650
9301
|
) {
|
|
8651
9302
|
return true;
|
|
8652
9303
|
}` : ""}
|
|
@@ -8990,8 +9641,10 @@ function getPPRHeaders(status, config) {
|
|
|
8990
9641
|
return headers;
|
|
8991
9642
|
}
|
|
8992
9643
|
|
|
9644
|
+
// defer() values reach the browser as references its snapshot settles; other promises do not.
|
|
8993
9645
|
function hasFarmUnserializableRouteData(data) {
|
|
8994
|
-
const isPromise = (value) =>
|
|
9646
|
+
const isPromise = (value) =>
|
|
9647
|
+
Boolean(value) && typeof value.then === "function" && !isDeferred(value);
|
|
8995
9648
|
if (isPromise(data)) return true;
|
|
8996
9649
|
return Boolean(data) && typeof data === "object" && Object.values(data).some(isPromise);
|
|
8997
9650
|
}
|
|
@@ -9064,6 +9717,7 @@ async function handleFarmRequest(request, adapterContext) {
|
|
|
9064
9717
|
return applyMarkdownNegotiationHeaders(response, {
|
|
9065
9718
|
config: farmMarkdownConfig,
|
|
9066
9719
|
pathname: requestUrl.pathname,
|
|
9720
|
+
routePathname: getFarmRoutePathname,
|
|
9067
9721
|
});
|
|
9068
9722
|
}` : ""}
|
|
9069
9723
|
return response;
|
|
@@ -9185,6 +9839,7 @@ async function resolveFarmRequestInContext(
|
|
|
9185
9839
|
cloneFarmRequestWithContext(request),
|
|
9186
9840
|
farmIntegrationRanMiddleware,
|
|
9187
9841
|
adapterContext?.clientAddress,
|
|
9842
|
+
adapterContext?.[farmRuntimeErrorSlot],
|
|
9188
9843
|
);
|
|
9189
9844
|
if (integrationDispatch.response) {
|
|
9190
9845
|
return integrationDispatch.response;
|
|
@@ -9198,9 +9853,27 @@ async function resolveFarmRequestInContext(
|
|
|
9198
9853
|
|
|
9199
9854
|
${hasMiddlewareRuntime ? `
|
|
9200
9855
|
const requestBeforeMiddleware = request;
|
|
9201
|
-
|
|
9202
|
-
|
|
9203
|
-
|
|
9856
|
+
let middlewareResult;
|
|
9857
|
+
try {
|
|
9858
|
+
middlewareResult = await farmMiddlewareRunner(request, {
|
|
9859
|
+
clientAddress: adapterContext?.clientAddress,
|
|
9860
|
+
});
|
|
9861
|
+
} catch (error) {
|
|
9862
|
+
// The runner emitted middleware.error. The request is answered below like any
|
|
9863
|
+
// failed request; a plugin's runtime.error observes the throw, as for an API route.
|
|
9864
|
+
console.error("Middleware error:", error);
|
|
9865
|
+
await adapterContext?.[farmRuntimeErrorSlot]?.(error);
|
|
9866
|
+
middlewareResult = {
|
|
9867
|
+
request,
|
|
9868
|
+
response: null,
|
|
9869
|
+
data: new Map(),
|
|
9870
|
+
context: new Map(),
|
|
9871
|
+
headers: new Headers(),
|
|
9872
|
+
guarded: true,
|
|
9873
|
+
failed: true,
|
|
9874
|
+
error,
|
|
9875
|
+
};
|
|
9876
|
+
}
|
|
9204
9877
|
if (middlewareResult.response) {
|
|
9205
9878
|
return middlewareResult.response;
|
|
9206
9879
|
}
|
|
@@ -9214,6 +9887,7 @@ async function resolveFarmRequestInContext(
|
|
|
9214
9887
|
cloneFarmRequestWithContext(request),
|
|
9215
9888
|
farmIntegrationRanMiddleware,
|
|
9216
9889
|
adapterContext?.clientAddress,
|
|
9890
|
+
adapterContext?.[farmRuntimeErrorSlot],
|
|
9217
9891
|
);
|
|
9218
9892
|
farmIntegrationSetCookies = [...farmIntegrationSetCookies, ...rewrittenDispatch.setCookies];
|
|
9219
9893
|
if (rewrittenDispatch.response) {
|
|
@@ -9242,6 +9916,26 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
9242
9916
|
// request instead of the original outer-handler value.
|
|
9243
9917
|
const runResolvedRequest = async () => {
|
|
9244
9918
|
if (middlewareResult.notFound) return renderFarmNotFoundResponse();
|
|
9919
|
+
if (middlewareResult.failed) {${farmRendererDisabled ? `
|
|
9920
|
+
return renderFarmErrorJSONResponse();` : `
|
|
9921
|
+
if (isFarmLocalAPIPathname(pathname)) return renderFarmErrorJSONResponse();
|
|
9922
|
+
// No page was selected, so only the root error boundary and layouts apply.
|
|
9923
|
+
const errorResponse = await renderFarmErrorResponse(middlewareResult.error, "/", {}, null);${config.md?.enabled ? `
|
|
9924
|
+
// An agent asking for Markdown reads the error document as Markdown, as it
|
|
9925
|
+
// does when a page throws. The helper answers null when Markdown is off.
|
|
9926
|
+
const markdownErrorResponse = await createMarkdownMirrorResponse({
|
|
9927
|
+
request,
|
|
9928
|
+
requestUrl: url,
|
|
9929
|
+
config: farmMarkdownConfig,
|
|
9930
|
+
routePathname: getFarmRoutePathname,
|
|
9931
|
+
routeExists: (targetPathname) =>
|
|
9932
|
+
Boolean(matchPageRoute(getFarmRoutePathname(targetPathname))),
|
|
9933
|
+
renderPage: async () => errorResponse,
|
|
9934
|
+
apiServerBasePath: farmLocalAPIBasePath,
|
|
9935
|
+
});
|
|
9936
|
+
if (markdownErrorResponse) return markdownErrorResponse;` : ""}
|
|
9937
|
+
return errorResponse;`}
|
|
9938
|
+
}
|
|
9245
9939
|
` : `
|
|
9246
9940
|
${hasServerRuntimeIntegrations ? `
|
|
9247
9941
|
// An integration guard (protectedRoutes) that let the request through.
|
|
@@ -9317,6 +10011,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
9317
10011
|
const markdownSourceResponse = await createFarmMarkdownSourceResponse?.({
|
|
9318
10012
|
request: cloneFarmRequestWithContext(request),
|
|
9319
10013
|
config: farmMdxConfig,
|
|
10014
|
+
routePathname: getFarmRoutePathname,
|
|
9320
10015
|
resolveSource: (targetPathname) => {
|
|
9321
10016
|
const match = matchPageRoute(getFarmRoutePathname(targetPathname));
|
|
9322
10017
|
return match?.route?.markdownSource || null;
|
|
@@ -9368,6 +10063,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
9368
10063
|
// Middleware and configured rewrites have already resolved this URL.
|
|
9369
10064
|
requestUrl: url,
|
|
9370
10065
|
config: farmMarkdownConfig,
|
|
10066
|
+
routePathname: getFarmRoutePathname,
|
|
9371
10067
|
routeExists: (targetPathname) =>
|
|
9372
10068
|
Boolean(matchPageRoute(getFarmRoutePathname(targetPathname))),
|
|
9373
10069
|
renderPage: (targetRequest) => fetchFarmInnerRequest(targetRequest, adapterContext),
|
|
@@ -9383,7 +10079,10 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
9383
10079
|
// Clone only for an API request: cloning a Request costs more than the match,
|
|
9384
10080
|
// and handleAPIRequest returns null without one.
|
|
9385
10081
|
if (matchLocalAPIRequest(request)) {
|
|
9386
|
-
const apiResponse = await handleAPIRequest(
|
|
10082
|
+
const apiResponse = await handleAPIRequest(
|
|
10083
|
+
cloneFarmRequestWithContext(request),
|
|
10084
|
+
adapterContext?.[farmRuntimeErrorSlot],
|
|
10085
|
+
);
|
|
9387
10086
|
if (apiResponse) {
|
|
9388
10087
|
return applyProductionMiddlewareHeaders(apiResponse, middlewareHeaders);
|
|
9389
10088
|
}
|
|
@@ -9506,13 +10205,14 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
9506
10205
|
: ${config.agent?.llmsTxt?.full ? `normalizeRuntimePath(routePathname) === "/llms-full.txt" ? "llms-full" : ` : ""}null;
|
|
9507
10206
|
if (farmGeneratedLlmsKind) {
|
|
9508
10207
|
const llmsContext = createFarmLlmsTxtContext(request, farmGeneratedLlmsKind === "llms-full");
|
|
10208
|
+
// Renders are shared per origin the request reached, which is where pages are read.
|
|
9509
10209
|
const llmsOrigin = new URL(request.url).origin;
|
|
9510
10210
|
// A page that times out is left out, the shared render is not reused, and
|
|
9511
10211
|
// the partial response is not cacheable.
|
|
9512
10212
|
let llmsComplete = true;
|
|
9513
10213
|
const renderLlmsFull = (shared) =>
|
|
9514
10214
|
renderFarmLlmsFullTxt(llmsContext.defaults, {
|
|
9515
|
-
origin:
|
|
10215
|
+
origin: getFarmAgentOrigin(request),
|
|
9516
10216
|
readMarkdown: llmsContext.markdown,
|
|
9517
10217
|
onIncomplete: () => {
|
|
9518
10218
|
llmsComplete = false;
|
|
@@ -9561,7 +10261,11 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
9561
10261
|
const matchedRoute = matchPageRoute(routePathname);
|
|
9562
10262
|
${farmIslandsMode ? `// Islands mode: a form or client component posting a server action to this page.
|
|
9563
10263
|
if (matchedRoute && request.method === "POST") {
|
|
9564
|
-
const actionResponse = await
|
|
10264
|
+
const actionResponse = await _runWithMiddlewareData(middlewareData || {}, () =>
|
|
10265
|
+
_runWithMiddlewareContext(middlewareContext || {}, () =>
|
|
10266
|
+
handleFarmFormActionRequest(request, farmFormActionsConfig)
|
|
10267
|
+
)
|
|
10268
|
+
);
|
|
9565
10269
|
if (actionResponse) return applyProductionMiddlewareHeaders(actionResponse, middlewareHeaders);
|
|
9566
10270
|
}` : ""}
|
|
9567
10271
|
if (matchedRoute) {${farmMobileShells ? `
|
|
@@ -9612,7 +10316,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
9612
10316
|
? 0
|
|
9613
10317
|
: countFarmKeptLayouts(request, farmSegmentLayouts, params);
|
|
9614
10318
|
// The root layout always renders, so keeping one layout keeps nothing.
|
|
9615
|
-
|
|
10319
|
+
let farmKeptLayouts = farmKeptLayoutCount > 1 ? farmKeptLayoutCount : 0;` : `let farmKeptLayouts = 0;`}
|
|
9616
10320
|
${farmMobileShells ? "const pprConfig = farmShellLoading ? { enabled: false } : resolvePPRConfig(route);" : "const pprConfig = resolvePPRConfig(route);"}
|
|
9617
10321
|
const pprBypassReason = pprConfig.enabled
|
|
9618
10322
|
? getPPRShellBypassReason(request, middlewareData, middlewareContext)
|
|
@@ -9856,8 +10560,8 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
9856
10560
|
...(pageProps.__farmCanonicalPath
|
|
9857
10561
|
? { __farmCanonicalPath: pageProps.__farmCanonicalPath }
|
|
9858
10562
|
: {}),
|
|
9859
|
-
//
|
|
9860
|
-
// a page from these props
|
|
10563
|
+
// A promise that is not a defer() value does not survive JSON, so
|
|
10564
|
+
// the browser cannot render a page from these props.
|
|
9861
10565
|
...(pageProps.__farmRoutePropsResolved && !hasFarmUnserializableRouteData(pageProps.data)
|
|
9862
10566
|
? { __farmRoutePropsResolved: true }
|
|
9863
10567
|
: {}),
|
|
@@ -9882,6 +10586,17 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
9882
10586
|
},
|
|
9883
10587
|
};
|
|
9884
10588
|
});
|
|
10589
|
+
// defer() values go to the browser as references (one id space for the page and its
|
|
10590
|
+
// slots), settled by renderFarmDeferredDataScript once the document has rendered.
|
|
10591
|
+
const farmDeferredData = prepareDeferredData({
|
|
10592
|
+
page: clientPageProps,
|
|
10593
|
+
slots: routeSlotPayload,
|
|
10594
|
+
});
|
|
10595
|
+
// A page without defer() values sends its props as they are: references, and escaped
|
|
10596
|
+
// look-alikes, only ever come with a snapshot, so the browser has nothing to revive.
|
|
10597
|
+
if (farmDeferredData.records.length === 0) {
|
|
10598
|
+
farmDeferredData.data = { page: clientPageProps, slots: routeSlotPayload };
|
|
10599
|
+
}
|
|
9885
10600
|
|
|
9886
10601
|
${farmIslandsMode ? `// Islands mode: a route a shared cache may store (a PPR shell, a static page) renders
|
|
9887
10602
|
// whole for every request, so a cache hit stays a hit. Other routes leave out what the
|
|
@@ -9900,12 +10615,26 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
9900
10615
|
// A navigation the browser streams marks where each React flush ends, so the browser
|
|
9901
10616
|
// shows the page before its Suspense content arrives (FARM_FLUSH_MARKER). The marker
|
|
9902
10617
|
// carries a random token sent in the F-Flush header: page content cannot forge one.
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
|
|
10618
|
+
// A page with defer() data arrives whole: the browser revives its props from the
|
|
10619
|
+
// snapshot after the body, which a shell swapped in first would not have yet.
|
|
10620
|
+
const farmFlushToken =
|
|
10621
|
+
request.headers.get("f-stream") === "flush" && farmDeferredData.records.length === 0
|
|
10622
|
+
? createFarmFlushToken()
|
|
10623
|
+
: "";` : `const farmLayoutKeyOf = null;
|
|
9906
10624
|
const farmPayloadOnlyNavigation = false;
|
|
9907
10625
|
const farmFlushToken = "";`}
|
|
9908
10626
|
const renderPageElement = async () => {
|
|
10627
|
+
// The browser chooses which layouts it says it keeps, so a kept layout still runs: a
|
|
10628
|
+
// guard in it decides this request. Only its markup is left out. A layout that fails
|
|
10629
|
+
// here renders whole, so notFound() and redirect() answer as on any other request.
|
|
10630
|
+
if (
|
|
10631
|
+
farmKeptLayouts > 0 &&
|
|
10632
|
+
!(await farmKeptLayoutsRender(ReactDOMServer, applicableLayouts, farmKeptLayouts, params))
|
|
10633
|
+
) {
|
|
10634
|
+
farmKeptLayouts = 0;
|
|
10635
|
+
pprCanCache = false;
|
|
10636
|
+
}
|
|
10637
|
+
|
|
9909
10638
|
// First, render the page content
|
|
9910
10639
|
let pageElement;
|
|
9911
10640
|
|
|
@@ -9986,9 +10715,11 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
9986
10715
|
"data-farm-route-slot": slot.name,
|
|
9987
10716
|
"data-farm-slot-owner": slot.ownerPattern,
|
|
9988
10717
|
},
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
10718
|
+
slot.hydrates
|
|
10719
|
+
? wrapFarmRouteClientGraph(
|
|
10720
|
+
React.createElement(slot.module.default, slot.props),
|
|
10721
|
+
)
|
|
10722
|
+
: React.createElement(slot.module.default, slot.props),
|
|
9992
10723
|
);
|
|
9993
10724
|
}
|
|
9994
10725
|
// Islands mode: a layout around a client provider, and the server layouts on its
|
|
@@ -10102,7 +10833,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10102
10833
|
// using the public path the .md request will be resolved against.
|
|
10103
10834
|
mergedMetadata = addMetadataMarkdownAlternate(
|
|
10104
10835
|
mergedMetadata,
|
|
10105
|
-
getFarmMarkdownAlternatePath(farmMarkdownConfig, pathname),
|
|
10836
|
+
getFarmMarkdownAlternatePath(farmMarkdownConfig, pathname, { routePathname: getFarmRoutePathname }),
|
|
10106
10837
|
);` : ""}
|
|
10107
10838
|
|
|
10108
10839
|
// headers(), cookies(), or getCurrentRequest() read during the render,
|
|
@@ -10231,11 +10962,16 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10231
10962
|
const farmClientScripts = function(early) {
|
|
10232
10963
|
return ' ' + renderFarmClientBootstrapScript(
|
|
10233
10964
|
pageProps.__farmCanonicalPath,
|
|
10234
|
-
|
|
10235
|
-
|
|
10965
|
+
farmDeferredData.data.slots,
|
|
10966
|
+
farmDeferredData.data.page
|
|
10236
10967
|
) + '\\n' +
|
|
10237
10968
|
' ' + renderFarmClientEntryScript(early) + '\\n';
|
|
10238
10969
|
};
|
|
10970
|
+
// Written as the stream ends, when the values the page read have settled.
|
|
10971
|
+
const farmDeferredDataScript = function() {
|
|
10972
|
+
const script = renderFarmDeferredDataScript(farmDeferredData.records);
|
|
10973
|
+
return script ? ' ' + script + '\\n' : '';
|
|
10974
|
+
};
|
|
10239
10975
|
const farmEarlyClientScripts = ${farmIslandsMode ? "farmClientScripts(true)" : '""'};
|
|
10240
10976
|
const streamPrefix = '<!DOCTYPE html>\\n<html lang="en">\\n<head>\\n' +
|
|
10241
10977
|
farmThemeDocument.head + '\\n' +
|
|
@@ -10247,9 +10983,10 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10247
10983
|
' <link rel="modulepreload" href="/__farm_client_js_src__">' + renderFarmClientModulePreloads(null, route.clientModule) + '\\n' +
|
|
10248
10984
|
renderFarmRendererHydrationScript() + '\\n' +
|
|
10249
10985
|
'</head>\\n<body>\\n' + farmEarlyClientScripts + ' <div id="root">';
|
|
10250
|
-
const
|
|
10251
|
-
|
|
10252
|
-
'</body>\\n</html>';
|
|
10986
|
+
const streamClientScripts = farmEarlyClientScripts ? '' : farmClientScripts();
|
|
10987
|
+
const streamSuffix = function() {
|
|
10988
|
+
return '</div>\\n' + farmDeferredDataScript() + streamClientScripts + '</body>\\n</html>';
|
|
10989
|
+
};
|
|
10253
10990
|
const themedStreamPrefix = streamPrefix.replace(
|
|
10254
10991
|
'<html lang="en">',
|
|
10255
10992
|
() => '<html lang="en"' + farmThemeDocument.attributes + '>'
|
|
@@ -10325,6 +11062,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10325
11062
|
async function(rootOpened) {
|
|
10326
11063
|
return (await lateNavigationRecovery()) +
|
|
10327
11064
|
(rootOpened ? '</div>\\n' : '') +
|
|
11065
|
+
farmDeferredDataScript() +
|
|
10328
11066
|
(farmEarlyClientScripts ? '' : farmClientScripts());
|
|
10329
11067
|
},
|
|
10330
11068
|
onStreamComplete
|
|
@@ -10333,7 +11071,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10333
11071
|
renderedPage.stream,
|
|
10334
11072
|
themedStreamPrefix,
|
|
10335
11073
|
async function() {
|
|
10336
|
-
return (await lateNavigationRecovery()) + streamSuffix;
|
|
11074
|
+
return (await lateNavigationRecovery()) + streamSuffix();
|
|
10337
11075
|
},
|
|
10338
11076
|
onStreamComplete
|
|
10339
11077
|
);
|
|
@@ -10379,9 +11117,9 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10379
11117
|
/<\\/body>/i,
|
|
10380
11118
|
() => ' ' + renderFarmClientBootstrapScript(
|
|
10381
11119
|
pageProps.__farmCanonicalPath,
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
) + '\\n' +
|
|
11120
|
+
farmDeferredData.data.slots,
|
|
11121
|
+
farmDeferredData.data.page
|
|
11122
|
+
) + renderFarmDeferredDataScript(farmDeferredData.records) + '\\n' +
|
|
10385
11123
|
' ' + farmEntryScript + '\\n</body>',
|
|
10386
11124
|
);
|
|
10387
11125
|
} else {
|
|
@@ -10398,7 +11136,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10398
11136
|
</head>
|
|
10399
11137
|
<body>
|
|
10400
11138
|
<div id="root">\${html}</div>
|
|
10401
|
-
\${renderFarmClientBootstrapScript(pageProps.__farmCanonicalPath,
|
|
11139
|
+
\${renderFarmClientBootstrapScript(pageProps.__farmCanonicalPath, farmDeferredData.data.slots, farmDeferredData.data.page)}\${renderFarmDeferredDataScript(farmDeferredData.records)}
|
|
10402
11140
|
\${farmEntryScript}
|
|
10403
11141
|
</body>
|
|
10404
11142
|
</html>\`;
|
|
@@ -10504,106 +11242,7 @@ ${hasServerRuntimeIntegrations ? `
|
|
|
10504
11242
|
|
|
10505
11243
|
emitFarmEvent({ type: "render.error", route: pathname, error });
|
|
10506
11244
|
console.error("SSR Error:", error);
|
|
10507
|
-
|
|
10508
|
-
const errorStatusText = getDefaultErrorStatusText(errorStatus);
|
|
10509
|
-
|
|
10510
|
-
const errorBoundaryMatch = getMatchingErrorBoundary(routePathname);
|
|
10511
|
-
if (errorBoundaryMatch?.route.module?.default) {
|
|
10512
|
-
try {
|
|
10513
|
-
const searchParamsObj = searchParamsToObject(url.searchParams);
|
|
10514
|
-
const ErrorComponent = errorBoundaryMatch.route.module.default;
|
|
10515
|
-
let errorElement = React.createElement(ErrorComponent, {
|
|
10516
|
-
error,
|
|
10517
|
-
reset: function() {},
|
|
10518
|
-
params,
|
|
10519
|
-
search: searchParamsObj,
|
|
10520
|
-
searchParams: createFarmSearchParams(searchParamsObj),
|
|
10521
|
-
path: pathname,
|
|
10522
|
-
...(middlewareData?.size ? { middleware: { data: middlewareData } } : {}),
|
|
10523
|
-
});
|
|
10524
|
-
|
|
10525
|
-
const applicableLayouts = getApplicableLayouts(routePathname);
|
|
10526
|
-
for (let i = applicableLayouts.length - 1; i >= 0; i--) {
|
|
10527
|
-
const LayoutComponent = applicableLayouts[i].module.default;
|
|
10528
|
-
if (LayoutComponent) {
|
|
10529
|
-
errorElement = React.createElement(LayoutComponent, {
|
|
10530
|
-
children: errorElement,
|
|
10531
|
-
params,
|
|
10532
|
-
});
|
|
10533
|
-
}
|
|
10534
|
-
}
|
|
10535
|
-
|
|
10536
|
-
errorElement = wrapWithFarmIntegrationProviders(errorElement);
|
|
10537
|
-
|
|
10538
|
-
const renderErrorElement = () =>
|
|
10539
|
-
renderFarmElementToString(ReactDOMServer, errorElement);
|
|
10540
|
-
const errorHtml = ${hasMiddlewareRuntime ? `await _runWithMiddlewareData(middlewareData, () =>
|
|
10541
|
-
_runWithMiddlewareContext(middlewareContext, renderErrorElement)
|
|
10542
|
-
)` : "await renderErrorElement()"};
|
|
10543
|
-
const errorDocument = applyFarmThemeDocument(
|
|
10544
|
-
applyFarmI18nDocument(
|
|
10545
|
-
createFarmErrorDocument(errorHtml, "Application Error"),
|
|
10546
|
-
pathname,
|
|
10547
|
-
getFarmI18nSnapshot(),
|
|
10548
|
-
request
|
|
10549
|
-
),
|
|
10550
|
-
farmThemeConfig,
|
|
10551
|
-
farmResolvedRuntimeConfig.basePath,
|
|
10552
|
-
getFarmTheme(request)
|
|
10553
|
-
);
|
|
10554
|
-
emitFarmEvent({
|
|
10555
|
-
type: "render.complete",
|
|
10556
|
-
route: pathname,
|
|
10557
|
-
pathname,
|
|
10558
|
-
status: errorStatus,
|
|
10559
|
-
durationMs: Date.now() - requestStartTime,
|
|
10560
|
-
});
|
|
10561
|
-
return rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(farmOwnedHtmlResponse(errorDocument, {
|
|
10562
|
-
status: errorStatus,
|
|
10563
|
-
headers: {
|
|
10564
|
-
"Content-Type": "text/html; charset=utf-8",
|
|
10565
|
-
"Cache-Control": "private, no-store",
|
|
10566
|
-
"x-farm-preload-buffered": getFarmBufferedPreloadMarker(errorDocument),
|
|
10567
|
-
},
|
|
10568
|
-
}), middlewareHeaders), errorDocument);
|
|
10569
|
-
} catch (boundaryError) {
|
|
10570
|
-
console.error("Route error boundary failed:", boundaryError);
|
|
10571
|
-
}
|
|
10572
|
-
}
|
|
10573
|
-
|
|
10574
|
-
const fallbackHtml = stampFarmCspNonce(createDefaultErrorMarkup({
|
|
10575
|
-
statusCode: errorStatus,
|
|
10576
|
-
statusText: errorStatusText,
|
|
10577
|
-
requestPath: pathname,
|
|
10578
|
-
method: request.method,
|
|
10579
|
-
development: false,
|
|
10580
|
-
mode: "production",
|
|
10581
|
-
}));
|
|
10582
|
-
const fallbackDocument = applyFarmThemeDocument(
|
|
10583
|
-
applyFarmI18nDocument(
|
|
10584
|
-
createFarmErrorDocument(
|
|
10585
|
-
fallbackHtml,
|
|
10586
|
-
errorStatus + " - " + errorStatusText
|
|
10587
|
-
),
|
|
10588
|
-
pathname,
|
|
10589
|
-
getFarmI18nSnapshot(),
|
|
10590
|
-
request
|
|
10591
|
-
),
|
|
10592
|
-
farmThemeConfig,
|
|
10593
|
-
farmResolvedRuntimeConfig.basePath,
|
|
10594
|
-
getFarmTheme(request)
|
|
10595
|
-
);
|
|
10596
|
-
return rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(farmOwnedHtmlResponse(
|
|
10597
|
-
fallbackDocument,
|
|
10598
|
-
{
|
|
10599
|
-
status: errorStatus,
|
|
10600
|
-
headers: {
|
|
10601
|
-
"Content-Type": "text/html; charset=utf-8",
|
|
10602
|
-
"Cache-Control": "private, no-store",
|
|
10603
|
-
"x-farm-preload-buffered": getFarmBufferedPreloadMarker(fallbackDocument),
|
|
10604
|
-
},
|
|
10605
|
-
}
|
|
10606
|
-
), middlewareHeaders), fallbackDocument);
|
|
11245
|
+
return renderFarmErrorResponse(error, routePathname, params);
|
|
10607
11246
|
}
|
|
10608
11247
|
}
|
|
10609
11248
|
|
|
@@ -10622,10 +11261,136 @@ ${servesDefaultMCP ? `
|
|
|
10622
11261
|
// 404 fallback - render proper HTML page
|
|
10623
11262
|
return renderFarmNotFoundResponse();
|
|
10624
11263
|
|
|
11264
|
+
// Hoisted: a page that throws and a middleware failure answer with the same error
|
|
11265
|
+
// document. The error boundary and layouts are those of errorRoutePathname.
|
|
11266
|
+
async function renderFarmErrorResponse(error, errorRoutePathname, params, errorDirectory) {
|
|
11267
|
+
const errorStatus = resolveDefaultErrorStatus(error);
|
|
11268
|
+
const errorStatusText = getDefaultErrorStatusText(errorStatus);
|
|
11269
|
+
|
|
11270
|
+
const errorBoundaryMatch = getMatchingErrorBoundary(errorRoutePathname);
|
|
11271
|
+
if (errorBoundaryMatch?.route.module?.default) {
|
|
11272
|
+
try {
|
|
11273
|
+
const searchParamsObj = searchParamsToObject(url.searchParams);
|
|
11274
|
+
const ErrorComponent = errorBoundaryMatch.route.module.default;
|
|
11275
|
+
let errorElement = React.createElement(ErrorComponent, {
|
|
11276
|
+
error,
|
|
11277
|
+
reset: function() {},
|
|
11278
|
+
params,
|
|
11279
|
+
search: searchParamsObj,
|
|
11280
|
+
searchParams: createFarmSearchParams(searchParamsObj),
|
|
11281
|
+
path: pathname,
|
|
11282
|
+
...(middlewareData?.size ? { middleware: { data: middlewareData } } : {}),
|
|
11283
|
+
});
|
|
11284
|
+
|
|
11285
|
+
const applicableLayouts = getApplicableLayouts(errorRoutePathname, errorDirectory);
|
|
11286
|
+
for (let i = applicableLayouts.length - 1; i >= 0; i--) {
|
|
11287
|
+
const LayoutComponent = applicableLayouts[i].module.default;
|
|
11288
|
+
if (LayoutComponent) {
|
|
11289
|
+
errorElement = React.createElement(LayoutComponent, {
|
|
11290
|
+
children: errorElement,
|
|
11291
|
+
params,
|
|
11292
|
+
});
|
|
11293
|
+
}
|
|
11294
|
+
}
|
|
11295
|
+
|
|
11296
|
+
errorElement = wrapWithFarmIntegrationProviders(errorElement);
|
|
11297
|
+
|
|
11298
|
+
const renderErrorElement = () =>
|
|
11299
|
+
renderFarmElementToString(ReactDOMServer, errorElement);
|
|
11300
|
+
const errorHtml = ${hasMiddlewareRuntime ? `await _runWithMiddlewareData(middlewareData, () =>
|
|
11301
|
+
_runWithMiddlewareContext(middlewareContext, renderErrorElement)
|
|
11302
|
+
)` : "await renderErrorElement()"};
|
|
11303
|
+
const errorDocument = applyFarmThemeDocument(
|
|
11304
|
+
applyFarmI18nDocument(
|
|
11305
|
+
createFarmErrorDocument(errorHtml, "Application Error"),
|
|
11306
|
+
pathname,
|
|
11307
|
+
getFarmI18nSnapshot(),
|
|
11308
|
+
request
|
|
11309
|
+
),
|
|
11310
|
+
farmThemeConfig,
|
|
11311
|
+
farmResolvedRuntimeConfig.basePath,
|
|
11312
|
+
getFarmTheme(request)
|
|
11313
|
+
);
|
|
11314
|
+
emitFarmEvent({
|
|
11315
|
+
type: "render.complete",
|
|
11316
|
+
route: pathname,
|
|
11317
|
+
pathname,
|
|
11318
|
+
status: errorStatus,
|
|
11319
|
+
durationMs: Date.now() - requestStartTime,
|
|
11320
|
+
});
|
|
11321
|
+
return rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(farmOwnedHtmlResponse(errorDocument, {
|
|
11322
|
+
status: errorStatus,
|
|
11323
|
+
headers: {
|
|
11324
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
11325
|
+
"Cache-Control": "private, no-store",
|
|
11326
|
+
"x-farm-preload-buffered": getFarmBufferedPreloadMarker(errorDocument),
|
|
11327
|
+
},
|
|
11328
|
+
}), middlewareHeaders), errorDocument);
|
|
11329
|
+
} catch (boundaryError) {
|
|
11330
|
+
console.error("Route error boundary failed:", boundaryError);
|
|
11331
|
+
}
|
|
11332
|
+
}
|
|
11333
|
+
|
|
11334
|
+
const fallbackHtml = stampFarmCspNonce(createDefaultErrorMarkup({
|
|
11335
|
+
statusCode: errorStatus,
|
|
11336
|
+
statusText: errorStatusText,
|
|
11337
|
+
requestPath: pathname,
|
|
11338
|
+
method: request.method,
|
|
11339
|
+
development: false,
|
|
11340
|
+
mode: "production",
|
|
11341
|
+
}));
|
|
11342
|
+
const fallbackDocument = applyFarmThemeDocument(
|
|
11343
|
+
applyFarmI18nDocument(
|
|
11344
|
+
createFarmErrorDocument(
|
|
11345
|
+
fallbackHtml,
|
|
11346
|
+
errorStatus + " - " + errorStatusText
|
|
11347
|
+
),
|
|
11348
|
+
pathname,
|
|
11349
|
+
getFarmI18nSnapshot(),
|
|
11350
|
+
request
|
|
11351
|
+
),
|
|
11352
|
+
farmThemeConfig,
|
|
11353
|
+
farmResolvedRuntimeConfig.basePath,
|
|
11354
|
+
getFarmTheme(request)
|
|
11355
|
+
);
|
|
11356
|
+
return rememberFarmBufferedHtml(applyProductionMiddlewareHeaders(farmOwnedHtmlResponse(
|
|
11357
|
+
fallbackDocument,
|
|
11358
|
+
{
|
|
11359
|
+
status: errorStatus,
|
|
11360
|
+
headers: {
|
|
11361
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
11362
|
+
"Cache-Control": "private, no-store",
|
|
11363
|
+
"x-farm-preload-buffered": getFarmBufferedPreloadMarker(fallbackDocument),
|
|
11364
|
+
},
|
|
11365
|
+
}
|
|
11366
|
+
), middlewareHeaders), fallbackDocument);
|
|
11367
|
+
}
|
|
11368
|
+
${hasMiddlewareRuntime ? `
|
|
11369
|
+
// A request no page answers fails with the JSON a throwing API route answers.
|
|
11370
|
+
function renderFarmErrorJSONResponse() {
|
|
11371
|
+
return applyProductionMiddlewareHeaders(farmOwnedResponse(
|
|
11372
|
+
JSON.stringify({ error: "Internal Server Error" }),
|
|
11373
|
+
{ status: 500, headers: { "Content-Type": "application/json" } }
|
|
11374
|
+
), middlewareHeaders);
|
|
11375
|
+
}
|
|
11376
|
+
` : ""}
|
|
10625
11377
|
// Hoisted: page and middleware notFound() answer with the same page.
|
|
10626
11378
|
async function renderFarmNotFoundResponse() {
|
|
10627
11379
|
emitFarmEvent({ type: "route.notFound", pathname });
|
|
10628
|
-
|
|
11380
|
+
${farmRendererDisabled ? `
|
|
11381
|
+
// renderer: false has no pages to render, so a miss answers like an API miss.
|
|
11382
|
+
emitFarmEvent({
|
|
11383
|
+
type: "render.complete",
|
|
11384
|
+
route: pathname,
|
|
11385
|
+
pathname,
|
|
11386
|
+
status: 404,
|
|
11387
|
+
durationMs: Date.now() - requestStartTime,
|
|
11388
|
+
});
|
|
11389
|
+
return applyProductionMiddlewareHeaders(farmOwnedResponse(
|
|
11390
|
+
JSON.stringify({ error: "Not found", pathname }),
|
|
11391
|
+
{ status: 404, headers: { "Content-Type": "application/json" } }
|
|
11392
|
+
), middlewareHeaders);
|
|
11393
|
+
` : ""}
|
|
10629
11394
|
// Agents that navigate in Markdown (a \`.md\` URL or \`Accept: text/markdown\`)
|
|
10630
11395
|
// get a Markdown error body instead of the HTML not-found shell.
|
|
10631
11396
|
if (farmRequestWantsMarkdown(pathname, request.headers.get("accept"))) {
|
|
@@ -10821,7 +11586,23 @@ async function handleFarmPluginRequest(request, runtimeOptions, adapterContext)
|
|
|
10821
11586
|
}
|
|
10822
11587
|
|
|
10823
11588
|
${generatePreloadResponseRuntimeSource()}
|
|
10824
|
-
|
|
11589
|
+
${hasPluginRuntime ? `
|
|
11590
|
+
// The 500 a request answers when a plugin runtime hook throws, as in farm dev: the generic JSON
|
|
11591
|
+
// body on an API path or with renderer: false, plain text for a page.
|
|
11592
|
+
function createFarmRuntimeHookErrorResponse(request, error) {
|
|
11593
|
+
console.error("Plugin runtime error:", error);${farmRendererDisabled ? "" : `
|
|
11594
|
+
if (!isFarmLocalAPIPathname(new URL(request.url).pathname)) {
|
|
11595
|
+
return farmOwnedResponse("Internal Server Error", {
|
|
11596
|
+
status: 500,
|
|
11597
|
+
headers: { "Content-Type": "text/plain; charset=utf-8" },
|
|
11598
|
+
});
|
|
11599
|
+
}`}
|
|
11600
|
+
return farmOwnedResponse(JSON.stringify({ error: "Internal Server Error" }), {
|
|
11601
|
+
status: 500,
|
|
11602
|
+
headers: { "Content-Type": "application/json" },
|
|
11603
|
+
});
|
|
11604
|
+
}
|
|
11605
|
+
` : ""}
|
|
10825
11606
|
// Export as Web Standard fetch API
|
|
10826
11607
|
export async function fetch(request, context) {${imageRuntime === "none" ? "" : `
|
|
10827
11608
|
// The image optimizer's fetch of a local source is not a loopback visitor.
|
|
@@ -10896,11 +11677,14 @@ async function handleFarmFetch(request, context) {
|
|
|
10896
11677
|
const runRequest = () => farmPluginRuntime
|
|
10897
11678
|
? farmPluginRuntime.runRuntimeRequest(
|
|
10898
11679
|
request,
|
|
10899
|
-
(runtimeRequest) =>
|
|
11680
|
+
(runtimeRequest, runtimeScope) =>
|
|
10900
11681
|
_runWithCurrentRequest(runtimeRequest, () =>
|
|
10901
11682
|
prepareResponse(
|
|
10902
11683
|
runtimeRequest,
|
|
10903
|
-
handleFarmPluginRequest(runtimeRequest, runtimeOptions,
|
|
11684
|
+
handleFarmPluginRequest(runtimeRequest, runtimeOptions, {
|
|
11685
|
+
...context,
|
|
11686
|
+
[farmRuntimeErrorSlot]: runtimeScope.reportError,
|
|
11687
|
+
}),
|
|
10904
11688
|
)
|
|
10905
11689
|
),
|
|
10906
11690
|
{
|
|
@@ -10909,6 +11693,11 @@ async function handleFarmFetch(request, context) {
|
|
|
10909
11693
|
? context.waitUntil.bind(context)
|
|
10910
11694
|
: undefined,
|
|
10911
11695
|
},
|
|
11696
|
+
).catch((error) =>
|
|
11697
|
+
// A runtime hook threw, or something it wraps: runtime.error and onError observed
|
|
11698
|
+
// it, and the remaining runtime.after hooks were skipped. Answer the 500 farm dev
|
|
11699
|
+
// answers, with the headers() config, instead of Nitro's own error response.
|
|
11700
|
+
prepareResponse(request, createFarmRuntimeHookErrorResponse(request, error))
|
|
10912
11701
|
)
|
|
10913
11702
|
: ${hasInfraAnalyticsRuntime && !hasPluginRuntime ? `farmAnalyticsOptions
|
|
10914
11703
|
? farmInfraAnalytics.record(
|
|
@@ -11078,11 +11867,11 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
11078
11867
|
]);
|
|
11079
11868
|
if (nitroBuilderResult.status === "rejected") throw nitroBuilderResult.reason;
|
|
11080
11869
|
const nitroBuilder = nitroBuilderResult.value;
|
|
11081
|
-
const isVercel = preset === "vercel"
|
|
11870
|
+
const isVercel = preset === "vercel";
|
|
11082
11871
|
const isCloudflareWorker = preset === "cloudflare-module";
|
|
11083
11872
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
11084
|
-
const runtimeServerOutputDir = isVercel ?
|
|
11085
|
-
const ssrOutputDir =
|
|
11873
|
+
const runtimeServerOutputDir = isVercel ? path11.join(outputDir, "functions", "__nitro.func") : path11.join(outputDir, "server");
|
|
11874
|
+
const ssrOutputDir = path11.join(root, distDir, "ssr");
|
|
11086
11875
|
const imageRuntime = resolveFarmImageServerRuntime(config.images, preset);
|
|
11087
11876
|
const hasGeneratedMetadataImages = Array.from(routeManager.getMetadataImages().values()).some(
|
|
11088
11877
|
(image) => image.sourceType === "module"
|
|
@@ -11192,15 +11981,15 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
11192
11981
|
resolveHashedClientCssHref(clientOutputDir),
|
|
11193
11982
|
resolveHashedClientJsSrc(clientOutputDir),
|
|
11194
11983
|
resolveClientBootSrc(clientOutputDir),
|
|
11195
|
-
readFarmDocsModulePreloads(
|
|
11196
|
-
readFarmClientModulePreloads(
|
|
11984
|
+
readFarmDocsModulePreloads(path11.join(root, distDir)),
|
|
11985
|
+
readFarmClientModulePreloads(path11.join(root, distDir))
|
|
11197
11986
|
]);
|
|
11198
11987
|
let nativeStylesheets;
|
|
11199
11988
|
const encodedDocsModulePreloads = encodeFarmDocsModulePreloads(docsModulePreloads);
|
|
11200
11989
|
const encodedClientModulePreloads = encodeFarmClientModulePreloads(clientModulePreloads);
|
|
11201
11990
|
const encodedMobileShellClient = shouldBuildFarmMobileClient(config) ? encodeFarmMobileShellClient(
|
|
11202
11991
|
await finalizeFarmMobileClient({
|
|
11203
|
-
buildDir:
|
|
11992
|
+
buildDir: path11.join(root, distDir),
|
|
11204
11993
|
clientOutputDir,
|
|
11205
11994
|
webEntry: clientJsSrc,
|
|
11206
11995
|
webBoot: clientBootSrc,
|
|
@@ -11239,12 +12028,12 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
|
|
|
11239
12028
|
await fs4.mkdir(ssrOutputDir, { recursive: true });
|
|
11240
12029
|
await Promise.all(
|
|
11241
12030
|
Object.entries(ssrBundle).map(async ([fileName, output]) => {
|
|
11242
|
-
const filePath =
|
|
11243
|
-
await fs4.mkdir(
|
|
12031
|
+
const filePath = path11.join(ssrOutputDir, fileName);
|
|
12032
|
+
await fs4.mkdir(path11.dirname(filePath), { recursive: true });
|
|
11244
12033
|
await fs4.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
|
|
11245
12034
|
})
|
|
11246
12035
|
);
|
|
11247
|
-
const nitroEntryPath =
|
|
12036
|
+
const nitroEntryPath = path11.join(ssrOutputDir, "nitro-entry.mjs");
|
|
11248
12037
|
const nodeAdapterModule = preset === "node-server" ? resolveNitroRuntimeDependency(root, "srvx/node") : null;
|
|
11249
12038
|
const hasNitroCacheRouteRules = hasFarmNitroCacheRouteRule(config.routeRules);
|
|
11250
12039
|
const nitroEntryCode = `
|
|
@@ -11452,20 +12241,20 @@ function toFarmNodeResponse(request, response) {
|
|
|
11452
12241
|
);
|
|
11453
12242
|
}
|
|
11454
12243
|
await fs4.writeFile(
|
|
11455
|
-
|
|
12244
|
+
path11.join(ssrOutputDir, FARM_DESKTOP_ENV_MODULE_FILE),
|
|
11456
12245
|
FARM_DESKTOP_ENV_MODULE_SOURCE
|
|
11457
12246
|
);
|
|
11458
12247
|
}
|
|
11459
|
-
const farmNodeServerEntryPath = preset === "node-server" ?
|
|
12248
|
+
const farmNodeServerEntryPath = preset === "node-server" ? path11.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
|
|
11460
12249
|
if (farmNodeServerEntryPath && nodeAdapterModule) {
|
|
11461
12250
|
await fs4.writeFile(
|
|
11462
|
-
|
|
12251
|
+
path11.join(ssrOutputDir, FARM_NODE_ENV_MODULE_FILE),
|
|
11463
12252
|
FARM_NODE_ENV_MODULE_SOURCE
|
|
11464
12253
|
);
|
|
11465
12254
|
await fs4.writeFile(
|
|
11466
12255
|
farmNodeServerEntryPath,
|
|
11467
12256
|
createFarmNodeServerEntry({
|
|
11468
|
-
nitroEntryFile:
|
|
12257
|
+
nitroEntryFile: path11.basename(nitroEntryPath),
|
|
11469
12258
|
nodeAdapterModule,
|
|
11470
12259
|
server: config.server,
|
|
11471
12260
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/node"),
|
|
@@ -11473,12 +12262,12 @@ function toFarmNodeResponse(request, response) {
|
|
|
11473
12262
|
})
|
|
11474
12263
|
);
|
|
11475
12264
|
}
|
|
11476
|
-
const farmBunServerEntryPath = preset === "bun" ?
|
|
12265
|
+
const farmBunServerEntryPath = preset === "bun" ? path11.join(ssrOutputDir, "farm-bun-server-entry.mjs") : null;
|
|
11477
12266
|
if (farmBunServerEntryPath) {
|
|
11478
12267
|
await fs4.writeFile(
|
|
11479
12268
|
farmBunServerEntryPath,
|
|
11480
12269
|
createFarmBunServerEntry({
|
|
11481
|
-
nitroEntryFile:
|
|
12270
|
+
nitroEntryFile: path11.basename(nitroEntryPath),
|
|
11482
12271
|
bunAdapterModule: resolveNitroRuntimeDependency(root, "srvx/bun"),
|
|
11483
12272
|
server: config.server,
|
|
11484
12273
|
websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/bun"),
|
|
@@ -11486,7 +12275,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
11486
12275
|
})
|
|
11487
12276
|
);
|
|
11488
12277
|
}
|
|
11489
|
-
const farmNetlifyEntryPath = preset === "netlify" ?
|
|
12278
|
+
const farmNetlifyEntryPath = preset === "netlify" ? path11.join(ssrOutputDir, "farm-netlify-entry.mjs") : null;
|
|
11490
12279
|
if (farmNetlifyEntryPath) {
|
|
11491
12280
|
await fs4.writeFile(
|
|
11492
12281
|
farmNetlifyEntryPath,
|
|
@@ -11495,6 +12284,17 @@ function toFarmNodeResponse(request, response) {
|
|
|
11495
12284
|
})
|
|
11496
12285
|
);
|
|
11497
12286
|
}
|
|
12287
|
+
const farmCloudflareEnvPath = preset === "cloudflare-pages" ? path11.join(ssrOutputDir, "farm-cloudflare-env.mjs") : null;
|
|
12288
|
+
if (farmCloudflareEnvPath) {
|
|
12289
|
+
await fs4.writeFile(
|
|
12290
|
+
farmCloudflareEnvPath,
|
|
12291
|
+
`export default function farmCloudflareEnv(event) {
|
|
12292
|
+
const env = event.req.runtime?.cloudflare?.env
|
|
12293
|
+
if (env) globalThis.__env__ = env
|
|
12294
|
+
}
|
|
12295
|
+
`
|
|
12296
|
+
);
|
|
12297
|
+
}
|
|
11498
12298
|
const prebuiltSSRPlugin = createExternalSSRBundlePlugin(
|
|
11499
12299
|
nitroEntryPath,
|
|
11500
12300
|
ssrOutputDir,
|
|
@@ -11531,7 +12331,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
11531
12331
|
// `src` directory), as Nitro handlers outside Farm's aliases.
|
|
11532
12332
|
serverDir: false,
|
|
11533
12333
|
serverEntry: false,
|
|
11534
|
-
buildDir:
|
|
12334
|
+
buildDir: path11.join(root, distDir, ".nitro"),
|
|
11535
12335
|
alias: resolveNitroInternalRuntimeAliases(root),
|
|
11536
12336
|
compatibilityDate: "2024-12-01",
|
|
11537
12337
|
output: resolveFarmNitroOutputConfig(preset, outputDir),
|
|
@@ -11579,6 +12379,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
11579
12379
|
} : {},
|
|
11580
12380
|
// Use serverHandlers to define our workflow handler first, then the catch-all handler.
|
|
11581
12381
|
handlers: [
|
|
12382
|
+
...farmCloudflareEnvPath ? [{ route: "/**", middleware: true, handler: toPosixPath(farmCloudflareEnvPath) }] : [],
|
|
11582
12383
|
...farmWorkflows.handlerPath ? [
|
|
11583
12384
|
{
|
|
11584
12385
|
route: `${config.workflows.route}/**`,
|
|
@@ -11602,7 +12403,10 @@ function toFarmNodeResponse(request, response) {
|
|
|
11602
12403
|
rollupConfig: {
|
|
11603
12404
|
external: nitroRollupExternal,
|
|
11604
12405
|
plugins: [
|
|
11605
|
-
|
|
12406
|
+
// On Cloudflare, Nitro imports @vercel/og's `?module` wasm files as
|
|
12407
|
+
// precompiled modules, and bundles @vercel/og itself when the SSR
|
|
12408
|
+
// graph kept it external.
|
|
12409
|
+
...isCloudflareImagePreset(preset) ? [createVercelOgFontInlinePlugin()] : hasGeneratedMetadataImages && !useExternalMetadataImageRuntime ? [createMetadataImageWasmPlugin()] : [],
|
|
11606
12410
|
// Workers bundle React here rather than loading it from node_modules.
|
|
11607
12411
|
// Unenv rewrites `process` before Nitro's own replacements run, so
|
|
11608
12412
|
// React's development builds would otherwise ship next to production.
|
|
@@ -11619,7 +12423,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
11619
12423
|
if (pluginManager) {
|
|
11620
12424
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
11621
12425
|
}
|
|
11622
|
-
const expectedServerDir =
|
|
12426
|
+
const expectedServerDir = path11.join(outputDir, "server");
|
|
11623
12427
|
const customRollupKeys = Object.keys(nitroConfig.rollupConfig || {}).filter(
|
|
11624
12428
|
(key) => key !== "external" && key !== "plugins"
|
|
11625
12429
|
);
|
|
@@ -11632,9 +12436,9 @@ function toFarmNodeResponse(request, response) {
|
|
|
11632
12436
|
snapshotSSRRebundleOptions(nitroConfig)
|
|
11633
12437
|
);
|
|
11634
12438
|
const requestedBuilder = nitroConfig.builder ?? process.env.NITRO_BUILDER;
|
|
11635
|
-
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 &&
|
|
12439
|
+
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 && path11.resolve(nitroConfig.output?.serverDir || "") === path11.resolve(expectedServerDir) && Boolean(
|
|
11636
12440
|
nitroConfig.handlers?.some(
|
|
11637
|
-
(handler) =>
|
|
12441
|
+
(handler) => path11.resolve(handler?.handler || "") === nitroEntryPath
|
|
11638
12442
|
)
|
|
11639
12443
|
);
|
|
11640
12444
|
const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
|
|
@@ -11644,13 +12448,14 @@ function toFarmNodeResponse(request, response) {
|
|
|
11644
12448
|
const keepServerNames = !(config.docs?.enabled && config.docs.adapter?.server);
|
|
11645
12449
|
const useFarmServerMinifier = shouldMinify && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig;
|
|
11646
12450
|
const serverChunkMinifier = useFarmServerMinifier ? createServerChunkMinifyPlugin({ keepNames: keepServerNames, target: "esnext" }) : null;
|
|
11647
|
-
|
|
12451
|
+
const ssrRollupPlugin = canReusePrebuiltSSR ? prebuiltSSRPlugin : createServerReadSSRAssetsPlugin(ssrBundle, ssrOutputDir);
|
|
12452
|
+
if (ssrRollupPlugin) {
|
|
11648
12453
|
const configuredRollupPlugins = nitroConfig.rollupConfig?.plugins;
|
|
11649
12454
|
nitroConfig.rollupConfig = {
|
|
11650
12455
|
...nitroConfig.rollupConfig,
|
|
11651
12456
|
plugins: [
|
|
11652
12457
|
...Array.isArray(configuredRollupPlugins) ? configuredRollupPlugins : configuredRollupPlugins ? [configuredRollupPlugins] : [],
|
|
11653
|
-
|
|
12458
|
+
ssrRollupPlugin
|
|
11654
12459
|
]
|
|
11655
12460
|
};
|
|
11656
12461
|
}
|
|
@@ -11675,7 +12480,9 @@ function toFarmNodeResponse(request, response) {
|
|
|
11675
12480
|
if (config.md?.enabled) {
|
|
11676
12481
|
nitroInstance.hooks.hook("prerender:generate", (route) => {
|
|
11677
12482
|
if (!route.contents || !route.contentType?.toLowerCase().includes("html")) return;
|
|
11678
|
-
const alternatePath = getFarmMarkdownAlternatePath(config.md, route.route
|
|
12483
|
+
const alternatePath = getFarmMarkdownAlternatePath(config.md, route.route, {
|
|
12484
|
+
routePathname: (pathname) => routeManager.toRoutePathname(pathname)
|
|
12485
|
+
});
|
|
11679
12486
|
if (!alternatePath) return;
|
|
11680
12487
|
const routeRule = nitroInstance.options.routeRules[route.route] || {};
|
|
11681
12488
|
const alternate = `<${alternatePath}>; rel="alternate"; type="text/markdown"`;
|
|
@@ -11738,10 +12545,10 @@ function toFarmNodeResponse(request, response) {
|
|
|
11738
12545
|
});
|
|
11739
12546
|
}
|
|
11740
12547
|
prerenderer.hooks.hook("compiled", async () => {
|
|
11741
|
-
const prerenderServerDir =
|
|
12548
|
+
const prerenderServerDir = path11.join(outputDir, "server");
|
|
11742
12549
|
await copyPrebuiltSSRBundle(
|
|
11743
12550
|
ssrBundle,
|
|
11744
|
-
|
|
12551
|
+
path11.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
|
|
11745
12552
|
null,
|
|
11746
12553
|
fs4
|
|
11747
12554
|
);
|
|
@@ -11817,7 +12624,7 @@ function toFarmNodeResponse(request, response) {
|
|
|
11817
12624
|
const copyResults = await Promise.allSettled([
|
|
11818
12625
|
prebuiltSSRFilesResult.value ? writeSSRBundleFiles(
|
|
11819
12626
|
prebuiltSSRFilesResult.value,
|
|
11820
|
-
|
|
12627
|
+
path11.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
|
|
11821
12628
|
fs4
|
|
11822
12629
|
) : Promise.resolve(),
|
|
11823
12630
|
runtimeCopyPromise
|
|
@@ -11827,14 +12634,17 @@ function toFarmNodeResponse(request, response) {
|
|
|
11827
12634
|
);
|
|
11828
12635
|
if (failedCopy) throw failedCopy.reason;
|
|
11829
12636
|
if (canReusePrebuiltSSR) {
|
|
11830
|
-
await registerPrebuiltSSRPackageImport(
|
|
12637
|
+
await registerPrebuiltSSRPackageImport(path11.join(outputDir, "server"), ssrEntryFile, fs4);
|
|
11831
12638
|
logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
|
|
11832
12639
|
}
|
|
11833
12640
|
if (useRolldownBuilder) {
|
|
11834
12641
|
logger.info("\u26A1 Built the Node adapter with Rolldown");
|
|
11835
12642
|
}
|
|
11836
12643
|
if (preset === "node-server" && !desktopServerEntry) {
|
|
11837
|
-
await installFarmCompileCacheLauncher(
|
|
12644
|
+
await installFarmCompileCacheLauncher(path11.join(outputDir, "server"), fs4);
|
|
12645
|
+
}
|
|
12646
|
+
if (preset.startsWith("cloudflare")) {
|
|
12647
|
+
await populateCloudflareProcessEnv(nitroInstance.options.output.serverDir, fs4);
|
|
11838
12648
|
}
|
|
11839
12649
|
if (pluginManager) {
|
|
11840
12650
|
await pluginManager.runHookParallel("afterNitroBuild", {
|
|
@@ -11858,18 +12668,48 @@ function toFarmNodeResponse(request, response) {
|
|
|
11858
12668
|
logger.success(`\u2705 Nitro build completed with preset: ${preset}`);
|
|
11859
12669
|
}
|
|
11860
12670
|
function resolveFarmNitroOutputConfig(preset, outputDir) {
|
|
11861
|
-
const isVercel = preset === "vercel"
|
|
12671
|
+
const isVercel = preset === "vercel";
|
|
11862
12672
|
return {
|
|
11863
12673
|
dir: outputDir,
|
|
11864
12674
|
...preset === "node-server" ? {
|
|
11865
|
-
serverDir:
|
|
11866
|
-
publicDir:
|
|
12675
|
+
serverDir: path11.join(outputDir, "server"),
|
|
12676
|
+
publicDir: path11.join(outputDir, "public")
|
|
11867
12677
|
} : isVercel ? {
|
|
11868
|
-
serverDir:
|
|
11869
|
-
publicDir:
|
|
12678
|
+
serverDir: path11.join(outputDir, "functions", "__nitro.func"),
|
|
12679
|
+
publicDir: path11.join(outputDir, "static")
|
|
11870
12680
|
} : {}
|
|
11871
12681
|
};
|
|
11872
12682
|
}
|
|
12683
|
+
var CLOUDFLARE_POPULATE_PROCESS_ENV_FLAG = "nodejs_compat_populate_process_env";
|
|
12684
|
+
var CLOUDFLARE_DO_NOT_POPULATE_PROCESS_ENV_FLAG = "nodejs_compat_do_not_populate_process_env";
|
|
12685
|
+
var CLOUDFLARE_POPULATE_PROCESS_ENV_DATE = "2025-04-01";
|
|
12686
|
+
function resolveCloudflareProcessEnvFlags(wrangler) {
|
|
12687
|
+
const date = wrangler.compatibility_date;
|
|
12688
|
+
const flags = wrangler.compatibility_flags;
|
|
12689
|
+
if (typeof date !== "string" || date >= CLOUDFLARE_POPULATE_PROCESS_ENV_DATE) return void 0;
|
|
12690
|
+
if (!Array.isArray(flags) || !flags.includes("nodejs_compat")) return void 0;
|
|
12691
|
+
if (flags.includes(CLOUDFLARE_POPULATE_PROCESS_ENV_FLAG) || flags.includes(CLOUDFLARE_DO_NOT_POPULATE_PROCESS_ENV_FLAG)) {
|
|
12692
|
+
return void 0;
|
|
12693
|
+
}
|
|
12694
|
+
return [...flags, CLOUDFLARE_POPULATE_PROCESS_ENV_FLAG];
|
|
12695
|
+
}
|
|
12696
|
+
async function populateCloudflareProcessEnv(serverDir, fs4) {
|
|
12697
|
+
const wranglerPath = path11.join(serverDir, "wrangler.json");
|
|
12698
|
+
let source;
|
|
12699
|
+
try {
|
|
12700
|
+
source = await fs4.readFile(wranglerPath, "utf8");
|
|
12701
|
+
} catch (error) {
|
|
12702
|
+
if (error.code === "ENOENT") return;
|
|
12703
|
+
throw error;
|
|
12704
|
+
}
|
|
12705
|
+
const wrangler = JSON.parse(source);
|
|
12706
|
+
const flags = resolveCloudflareProcessEnvFlags(wrangler);
|
|
12707
|
+
if (!flags) return;
|
|
12708
|
+
await fs4.writeFile(
|
|
12709
|
+
wranglerPath,
|
|
12710
|
+
JSON.stringify({ ...wrangler, compatibility_flags: flags }, null, 2)
|
|
12711
|
+
);
|
|
12712
|
+
}
|
|
11873
12713
|
function prepareSSRBundleFiles(ssrBundle, minifyOptions) {
|
|
11874
12714
|
return Promise.all(
|
|
11875
12715
|
Object.entries(ssrBundle).map(async ([fileName, output]) => ({
|
|
@@ -11882,8 +12722,8 @@ async function writeSSRBundleFiles(files, targetDir, fs4) {
|
|
|
11882
12722
|
await fs4.rm(targetDir, { recursive: true, force: true });
|
|
11883
12723
|
await Promise.all(
|
|
11884
12724
|
files.map(async ({ fileName, contents }) => {
|
|
11885
|
-
const targetPath =
|
|
11886
|
-
await fs4.mkdir(
|
|
12725
|
+
const targetPath = path11.join(targetDir, fileName);
|
|
12726
|
+
await fs4.mkdir(path11.dirname(targetPath), { recursive: true });
|
|
11887
12727
|
await fs4.writeFile(targetPath, contents);
|
|
11888
12728
|
})
|
|
11889
12729
|
);
|
|
@@ -11892,8 +12732,8 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions, fs4) {
|
|
|
11892
12732
|
await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir, fs4);
|
|
11893
12733
|
}
|
|
11894
12734
|
async function installFarmCompileCacheLauncher(serverDir, fs4) {
|
|
11895
|
-
const entryPath =
|
|
11896
|
-
const serverPath =
|
|
12735
|
+
const entryPath = path11.join(serverDir, "index.mjs");
|
|
12736
|
+
const serverPath = path11.join(serverDir, FARM_SERVER_MODULE_FILE);
|
|
11897
12737
|
const entry = await fs4.readFile(entryPath, "utf8").catch((error) => {
|
|
11898
12738
|
if (error.code === "ENOENT") return null;
|
|
11899
12739
|
throw error;
|
|
@@ -11902,11 +12742,11 @@ async function installFarmCompileCacheLauncher(serverDir, fs4) {
|
|
|
11902
12742
|
if (entry.includes(`./${FARM_SERVER_MODULE_FILE}`)) return false;
|
|
11903
12743
|
await fs4.rename(entryPath, serverPath);
|
|
11904
12744
|
await fs4.writeFile(entryPath, createFarmCompileCacheLauncher(FARM_SERVER_MODULE_FILE));
|
|
11905
|
-
await fs4.rm(
|
|
12745
|
+
await fs4.rm(path11.join(serverDir, FARM_COMPILE_CACHE_DIR), { recursive: true, force: true });
|
|
11906
12746
|
return true;
|
|
11907
12747
|
}
|
|
11908
12748
|
async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs4) {
|
|
11909
|
-
const packagePath =
|
|
12749
|
+
const packagePath = path11.join(serverDir, "package.json");
|
|
11910
12750
|
const packageJSON = await fs4.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
11911
12751
|
if (error.code === "ENOENT") return { type: "module" };
|
|
11912
12752
|
throw error;
|
|
@@ -11935,18 +12775,18 @@ async function moveVercelOutputPath(src, dest, fs4) {
|
|
|
11935
12775
|
await fs4.rm(src, { recursive: true, force: true });
|
|
11936
12776
|
}
|
|
11937
12777
|
async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflows, routeRuntimeManifest, cronJobs) {
|
|
11938
|
-
const serverDir =
|
|
11939
|
-
const functionsDir =
|
|
11940
|
-
const nitroFuncDir =
|
|
11941
|
-
const staticDir =
|
|
11942
|
-
const publicDir =
|
|
12778
|
+
const serverDir = path11.join(outputDir, "server");
|
|
12779
|
+
const functionsDir = path11.join(outputDir, "functions");
|
|
12780
|
+
const nitroFuncDir = path11.join(functionsDir, "__nitro.func");
|
|
12781
|
+
const staticDir = path11.join(outputDir, "static");
|
|
12782
|
+
const publicDir = path11.join(outputDir, "public");
|
|
11943
12783
|
await fs4.mkdir(nitroFuncDir, { recursive: true });
|
|
11944
12784
|
const serverContents = await fs4.readdir(serverDir).catch((error) => {
|
|
11945
12785
|
if (error.code === "ENOENT") return [];
|
|
11946
12786
|
throw error;
|
|
11947
12787
|
});
|
|
11948
12788
|
for (const file of serverContents) {
|
|
11949
|
-
await moveVercelOutputPath(
|
|
12789
|
+
await moveVercelOutputPath(path11.join(serverDir, file), path11.join(nitroFuncDir, file), fs4);
|
|
11950
12790
|
}
|
|
11951
12791
|
if (serverContents.length > 0) await fs4.rm(serverDir, { recursive: true, force: true });
|
|
11952
12792
|
try {
|
|
@@ -11956,7 +12796,7 @@ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflo
|
|
|
11956
12796
|
}
|
|
11957
12797
|
await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4);
|
|
11958
12798
|
await copyPrismaClientForVercel(root, nitroFuncDir, fs4);
|
|
11959
|
-
const configPath =
|
|
12799
|
+
const configPath = path11.join(outputDir, "config.json");
|
|
11960
12800
|
const configContent = await fs4.readFile(configPath, "utf-8");
|
|
11961
12801
|
const vercelConfig = JSON.parse(configContent);
|
|
11962
12802
|
const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
|
|
@@ -11984,7 +12824,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4) {
|
|
|
11984
12824
|
mainRoot,
|
|
11985
12825
|
root,
|
|
11986
12826
|
config.srcDir,
|
|
11987
|
-
|
|
12827
|
+
path11.join(nitroFuncDir, "farm-docs-content"),
|
|
11988
12828
|
fs4
|
|
11989
12829
|
);
|
|
11990
12830
|
for (const [index, docsRoot] of extraRoots.entries()) {
|
|
@@ -11992,7 +12832,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4) {
|
|
|
11992
12832
|
docsRoot,
|
|
11993
12833
|
root,
|
|
11994
12834
|
config.srcDir,
|
|
11995
|
-
|
|
12835
|
+
path11.join(nitroFuncDir, "farm-docs-roots", String(index)),
|
|
11996
12836
|
fs4
|
|
11997
12837
|
);
|
|
11998
12838
|
}
|
|
@@ -12003,18 +12843,24 @@ async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir, fs
|
|
|
12003
12843
|
const lastModifiedManifest = createFarmDocsLastModifiedManifest(docsContentDir, {
|
|
12004
12844
|
fallback: "now"
|
|
12005
12845
|
});
|
|
12846
|
+
const undatedPages = lastModifiedManifest.unknown?.length ?? 0;
|
|
12847
|
+
if (undatedPages > 0) {
|
|
12848
|
+
logger.warn(
|
|
12849
|
+
`${undatedPages} docs page(s) were last changed before this shallow clone's Git history, so they show no "Last updated" date. Build from a full clone (git fetch --unshallow) or set lastModified in the page's frontmatter.`
|
|
12850
|
+
);
|
|
12851
|
+
}
|
|
12006
12852
|
await fs4.rm(bundledContentDir, { recursive: true, force: true });
|
|
12007
|
-
await fs4.mkdir(
|
|
12853
|
+
await fs4.mkdir(path11.dirname(bundledContentDir), { recursive: true });
|
|
12008
12854
|
await fs4.cp(docsContentDir, bundledContentDir, {
|
|
12009
12855
|
recursive: true,
|
|
12010
12856
|
force: true
|
|
12011
12857
|
});
|
|
12012
12858
|
await fs4.writeFile(
|
|
12013
|
-
|
|
12859
|
+
path11.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
|
|
12014
12860
|
`${JSON.stringify(lastModifiedManifest, null, 2)}
|
|
12015
12861
|
`
|
|
12016
12862
|
);
|
|
12017
|
-
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${
|
|
12863
|
+
logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path11.relative(root, docsContentDir)}`);
|
|
12018
12864
|
}
|
|
12019
12865
|
function resolveServerFunctionPlatform(preset) {
|
|
12020
12866
|
return preset === "vercel" || preset === "netlify" ? { os: "linux", cpu: "x64", libc: "glibc" } : null;
|
|
@@ -12031,7 +12877,7 @@ function platformFieldAllows(field, value) {
|
|
|
12031
12877
|
}
|
|
12032
12878
|
async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
12033
12879
|
const functionPlatform = resolveServerFunctionPlatform(preset);
|
|
12034
|
-
const projectRequire = createRequire(
|
|
12880
|
+
const projectRequire = createRequire(path11.join(root, "package.json"));
|
|
12035
12881
|
let sharpRequire = projectRequire;
|
|
12036
12882
|
if (!resolvePackageJson(projectRequire, "sharp")) {
|
|
12037
12883
|
try {
|
|
@@ -12041,10 +12887,10 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
12041
12887
|
}
|
|
12042
12888
|
const copiedPackages = /* @__PURE__ */ new Map();
|
|
12043
12889
|
const packageCopies = /* @__PURE__ */ new Map();
|
|
12044
|
-
const stageRoot =
|
|
12890
|
+
const stageRoot = path11.join(root, distDir, "tmp");
|
|
12045
12891
|
await fs4.mkdir(stageRoot, { recursive: true });
|
|
12046
|
-
const stageDir = await fs4.mkdtemp(
|
|
12047
|
-
const targetNodeModules =
|
|
12892
|
+
const stageDir = await fs4.mkdtemp(path11.join(stageRoot, "sharp-runtime-"));
|
|
12893
|
+
const targetNodeModules = path11.join(stageDir, "node_modules");
|
|
12048
12894
|
function copyPackage(packageName, parentRequire) {
|
|
12049
12895
|
const activeCopy = packageCopies.get(packageName);
|
|
12050
12896
|
if (activeCopy) return activeCopy;
|
|
@@ -12057,10 +12903,10 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
12057
12903
|
if (!packageJsonPath) return;
|
|
12058
12904
|
const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf8"));
|
|
12059
12905
|
if (functionPlatform && !packageSupportsPlatform(packageJson, functionPlatform)) return;
|
|
12060
|
-
const packageDir =
|
|
12061
|
-
const targetDir =
|
|
12906
|
+
const packageDir = path11.dirname(packageJsonPath);
|
|
12907
|
+
const targetDir = path11.join(targetNodeModules, ...packageName.split("/"));
|
|
12062
12908
|
copiedPackages.set(packageName, String(packageJson.version || "*"));
|
|
12063
|
-
await fs4.mkdir(
|
|
12909
|
+
await fs4.mkdir(path11.dirname(targetDir), { recursive: true });
|
|
12064
12910
|
const packageRequire = createRequire(packageJsonPath);
|
|
12065
12911
|
const dependencies = {
|
|
12066
12912
|
...packageJson.dependencies,
|
|
@@ -12095,8 +12941,8 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
|
|
|
12095
12941
|
};
|
|
12096
12942
|
}
|
|
12097
12943
|
async function installStagedSharpRuntime(staged, nitroFuncDir, fs4) {
|
|
12098
|
-
const stagedNodeModules =
|
|
12099
|
-
const targetNodeModules =
|
|
12944
|
+
const stagedNodeModules = path11.join(staged.stageDir, "node_modules");
|
|
12945
|
+
const targetNodeModules = path11.join(nitroFuncDir, "node_modules");
|
|
12100
12946
|
try {
|
|
12101
12947
|
await mergeStagedDirectory(stagedNodeModules, targetNodeModules, fs4);
|
|
12102
12948
|
const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs4);
|
|
@@ -12124,8 +12970,8 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs4) {
|
|
|
12124
12970
|
const entries = await fs4.readdir(sourceDir, { withFileTypes: true });
|
|
12125
12971
|
await settleAllOrThrow(
|
|
12126
12972
|
entries.map(async (entry) => {
|
|
12127
|
-
const sourcePath =
|
|
12128
|
-
const targetPath =
|
|
12973
|
+
const sourcePath = path11.join(sourceDir, entry.name);
|
|
12974
|
+
const targetPath = path11.join(targetDir, entry.name);
|
|
12129
12975
|
try {
|
|
12130
12976
|
await fs4.rename(sourcePath, targetPath);
|
|
12131
12977
|
return;
|
|
@@ -12152,13 +12998,13 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs4) {
|
|
|
12152
12998
|
function assertMetadataImageRuntimeInstalled(root, metadataImageRoutes) {
|
|
12153
12999
|
const generated = metadataImageRoutes.find((image) => image.sourceType === "module");
|
|
12154
13000
|
if (!generated || resolveMetadataImageRuntimePackageJson(root)) return;
|
|
12155
|
-
const file = generated.modulePath ? toPosixPath(
|
|
13001
|
+
const file = generated.modulePath ? toPosixPath(path11.relative(root, generated.modulePath)) : "";
|
|
12156
13002
|
throw new Error(
|
|
12157
13003
|
`${file || "A generated metadata image"} renders with @vercel/og, which is not installed. ${VERCEL_OG_INSTALL_HINT}`
|
|
12158
13004
|
);
|
|
12159
13005
|
}
|
|
12160
13006
|
function resolveMetadataImageRuntimePackageJson(root) {
|
|
12161
|
-
const projectRequire = createRequire(
|
|
13007
|
+
const projectRequire = createRequire(path11.join(root, "package.json"));
|
|
12162
13008
|
const packageJsonPath = resolvePackageJson(projectRequire, "@vercel/og");
|
|
12163
13009
|
if (packageJsonPath) return packageJsonPath;
|
|
12164
13010
|
try {
|
|
@@ -12171,9 +13017,9 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs4) {
|
|
|
12171
13017
|
const packageJsonPath = resolveMetadataImageRuntimePackageJson(root);
|
|
12172
13018
|
if (!packageJsonPath) return;
|
|
12173
13019
|
const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf8"));
|
|
12174
|
-
const packageDir =
|
|
12175
|
-
const targetDir =
|
|
12176
|
-
await fs4.mkdir(
|
|
13020
|
+
const packageDir = path11.dirname(packageJsonPath);
|
|
13021
|
+
const targetDir = path11.join(nitroFuncDir, "node_modules", "@vercel", "og");
|
|
13022
|
+
await fs4.mkdir(path11.dirname(targetDir), { recursive: true });
|
|
12177
13023
|
await fs4.cp(packageDir, targetDir, {
|
|
12178
13024
|
recursive: true,
|
|
12179
13025
|
force: true,
|
|
@@ -12189,7 +13035,7 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs4) {
|
|
|
12189
13035
|
logger.info("\u{1F5BC}\uFE0F Bundled generated metadata image runtime");
|
|
12190
13036
|
}
|
|
12191
13037
|
async function readNitroOutputPackage(outputDir, fs4) {
|
|
12192
|
-
const packagePath =
|
|
13038
|
+
const packagePath = path11.join(outputDir, "package.json");
|
|
12193
13039
|
return fs4.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
|
|
12194
13040
|
if (error.code === "ENOENT") return {};
|
|
12195
13041
|
throw error;
|
|
@@ -12198,7 +13044,7 @@ async function readNitroOutputPackage(outputDir, fs4) {
|
|
|
12198
13044
|
async function writeNitroOutputPackage(outputDir, packageJson, fs4) {
|
|
12199
13045
|
await fs4.mkdir(outputDir, { recursive: true });
|
|
12200
13046
|
await fs4.writeFile(
|
|
12201
|
-
|
|
13047
|
+
path11.join(outputDir, "package.json"),
|
|
12202
13048
|
`${JSON.stringify(packageJson, null, 2)}
|
|
12203
13049
|
`
|
|
12204
13050
|
);
|
|
@@ -12214,9 +13060,9 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
12214
13060
|
}
|
|
12215
13061
|
}
|
|
12216
13062
|
try {
|
|
12217
|
-
let directory =
|
|
12218
|
-
while (directory !==
|
|
12219
|
-
const candidate =
|
|
13063
|
+
let directory = path11.dirname(metadataModule ?? parentRequire.resolve(packageName));
|
|
13064
|
+
while (directory !== path11.dirname(directory)) {
|
|
13065
|
+
const candidate = path11.join(directory, "package.json");
|
|
12220
13066
|
if (existsSync2(candidate)) {
|
|
12221
13067
|
try {
|
|
12222
13068
|
const manifest = JSON.parse(readFileSync(candidate, "utf8"));
|
|
@@ -12224,31 +13070,31 @@ function resolvePackageJson(parentRequire, packageName) {
|
|
|
12224
13070
|
} catch {
|
|
12225
13071
|
}
|
|
12226
13072
|
}
|
|
12227
|
-
if (
|
|
12228
|
-
directory =
|
|
13073
|
+
if (path11.basename(directory) === "node_modules") break;
|
|
13074
|
+
directory = path11.dirname(directory);
|
|
12229
13075
|
}
|
|
12230
13076
|
} catch {
|
|
12231
13077
|
}
|
|
12232
13078
|
return null;
|
|
12233
13079
|
}
|
|
12234
13080
|
async function copyPrismaClientForVercel(root, nitroFuncDir, fs4) {
|
|
12235
|
-
const projectRequire = createRequire(
|
|
13081
|
+
const projectRequire = createRequire(path11.join(root, "package.json"));
|
|
12236
13082
|
let prismaClientDir;
|
|
12237
13083
|
try {
|
|
12238
|
-
prismaClientDir =
|
|
13084
|
+
prismaClientDir = path11.dirname(projectRequire.resolve("@prisma/client/default.js"));
|
|
12239
13085
|
} catch {
|
|
12240
13086
|
return;
|
|
12241
13087
|
}
|
|
12242
|
-
const generatedClientDir =
|
|
13088
|
+
const generatedClientDir = path11.join(prismaClientDir, "..", "..", ".prisma", "client");
|
|
12243
13089
|
try {
|
|
12244
13090
|
await fs4.access(generatedClientDir);
|
|
12245
13091
|
} catch {
|
|
12246
13092
|
return;
|
|
12247
13093
|
}
|
|
12248
|
-
const targetNodeModules =
|
|
12249
|
-
const targetPrismaScopeDir =
|
|
12250
|
-
const targetGeneratedDir =
|
|
12251
|
-
const targetClientDir =
|
|
13094
|
+
const targetNodeModules = path11.join(nitroFuncDir, "node_modules");
|
|
13095
|
+
const targetPrismaScopeDir = path11.join(targetNodeModules, "@prisma");
|
|
13096
|
+
const targetGeneratedDir = path11.join(targetNodeModules, ".prisma", "client");
|
|
13097
|
+
const targetClientDir = path11.join(targetPrismaScopeDir, "client");
|
|
12252
13098
|
await fs4.mkdir(targetPrismaScopeDir, { recursive: true });
|
|
12253
13099
|
await fs4.cp(prismaClientDir, targetClientDir, {
|
|
12254
13100
|
recursive: true,
|
|
@@ -12258,7 +13104,7 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs4) {
|
|
|
12258
13104
|
recursive: true,
|
|
12259
13105
|
force: true
|
|
12260
13106
|
});
|
|
12261
|
-
const clientPackagePath =
|
|
13107
|
+
const clientPackagePath = path11.join(prismaClientDir, "package.json");
|
|
12262
13108
|
const [functionPackage, clientPackageContent] = await Promise.all([
|
|
12263
13109
|
readNitroOutputPackage(nitroFuncDir, fs4),
|
|
12264
13110
|
fs4.readFile(clientPackagePath, "utf-8")
|
|
@@ -12376,9 +13222,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
12376
13222
|
if (config.docs?.enabled) await loadFarmDocsEngine();
|
|
12377
13223
|
pluginManager.updateContext({ config });
|
|
12378
13224
|
const { root, preset, srcDir, distDir, deployOutputDir } = targets;
|
|
12379
|
-
usePackageClientBoundaryCacheFile(
|
|
12380
|
-
path11.resolve(root, distDir, "cache", "client-boundaries.json")
|
|
12381
|
-
);
|
|
13225
|
+
usePackageClientBoundaryCacheFile(resolvePackageClientBoundaryCacheFile(root, distDir));
|
|
12382
13226
|
logger.info(`\u{1F69C} Building Farm.js application with preset: ${preset}...`);
|
|
12383
13227
|
await pluginManager.setupPlugins();
|
|
12384
13228
|
await pluginManager.runHookParallel("beforeBundle", {
|
|
@@ -12446,9 +13290,9 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
|
|
|
12446
13290
|
} else {
|
|
12447
13291
|
const { build: legacyViteBuild } = await import("vite");
|
|
12448
13292
|
logger.info("\u{1F4E6} Building client bundle...");
|
|
12449
|
-
await buildClient2(legacyViteBuild, config, root, srcDir,
|
|
13293
|
+
await buildClient2(legacyViteBuild, config, root, srcDir, path12.join(root, distDir, "client"));
|
|
12450
13294
|
logger.info("\u{1F4E6} Building SSR bundle...");
|
|
12451
|
-
await buildSSR(legacyViteBuild, config, root, srcDir,
|
|
13295
|
+
await buildSSR(legacyViteBuild, config, root, srcDir, path12.join(root, distDir, "server"));
|
|
12452
13296
|
logger.info(`\u{1F680} Building server with Nitro (preset: ${preset})...`);
|
|
12453
13297
|
await buildNitro(
|
|
12454
13298
|
config,
|
|
@@ -12577,7 +13421,7 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
|
|
|
12577
13421
|
}
|
|
12578
13422
|
async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
|
|
12579
13423
|
const { farmI18nClientBridgePlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
|
|
12580
|
-
const { PluginManager: PluginManager2 } = await import("./plugin-
|
|
13424
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-SAS22JL7.mjs");
|
|
12581
13425
|
const pluginManager = new PluginManager2({
|
|
12582
13426
|
config,
|
|
12583
13427
|
isDev: false,
|
|
@@ -12604,7 +13448,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
|
|
|
12604
13448
|
}
|
|
12605
13449
|
async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
12606
13450
|
const { farmI18nClientBridgePlugin, farmPlugin } = await import("./vite.mjs");
|
|
12607
|
-
const { PluginManager: PluginManager2 } = await import("./plugin-
|
|
13451
|
+
const { PluginManager: PluginManager2 } = await import("./plugin-SAS22JL7.mjs");
|
|
12608
13452
|
const pluginManager = new PluginManager2({
|
|
12609
13453
|
config,
|
|
12610
13454
|
isDev: false,
|
|
@@ -12636,16 +13480,16 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
|
|
|
12636
13480
|
});
|
|
12637
13481
|
}
|
|
12638
13482
|
function resolveLegacyPageEntry(config, root, srcDir) {
|
|
12639
|
-
const appDir =
|
|
13483
|
+
const appDir = path12.join(root, srcDir, "app");
|
|
12640
13484
|
for (const extension of getFarmRendererComponentExtensions(config.renderer)) {
|
|
12641
|
-
const candidate =
|
|
13485
|
+
const candidate = path12.join(appDir, `page${extension}`);
|
|
12642
13486
|
if (existsSync3(candidate)) return candidate;
|
|
12643
13487
|
}
|
|
12644
|
-
return
|
|
13488
|
+
return path12.join(appDir, "page.tsx");
|
|
12645
13489
|
}
|
|
12646
13490
|
async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
|
|
12647
13491
|
const [{ createNitroConfig }, { createNitro, build: nitroBuild }] = await Promise.all([
|
|
12648
|
-
import("./nitro-
|
|
13492
|
+
import("./nitro-55YOZWRA.mjs"),
|
|
12649
13493
|
import("nitro/builder")
|
|
12650
13494
|
]);
|
|
12651
13495
|
let nitroConfig = await createNitroConfig(
|
|
@@ -12659,18 +13503,18 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
12659
13503
|
nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
|
|
12660
13504
|
}
|
|
12661
13505
|
const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
|
|
12662
|
-
const serverOutputDir =
|
|
12663
|
-
const publicOutputDir =
|
|
13506
|
+
const serverOutputDir = path12.join(outputDir, "server");
|
|
13507
|
+
const publicOutputDir = path12.join(outputDir, "public");
|
|
12664
13508
|
const { mkdir, cp } = await import("fs/promises");
|
|
12665
13509
|
await mkdir(serverOutputDir, { recursive: true });
|
|
12666
13510
|
await mkdir(publicOutputDir, { recursive: true });
|
|
12667
|
-
const clientDir =
|
|
13511
|
+
const clientDir = path12.join(root, distDir, "client");
|
|
12668
13512
|
try {
|
|
12669
13513
|
await mkdir(publicOutputDir, { recursive: true });
|
|
12670
13514
|
await cp(clientDir, publicOutputDir, { recursive: true });
|
|
12671
13515
|
logger.info("\u{1F4E6} Copied client assets to public directory");
|
|
12672
|
-
const manifestPath =
|
|
12673
|
-
const assetsDir =
|
|
13516
|
+
const manifestPath = path12.join(publicOutputDir, "farm-client-manifest.json");
|
|
13517
|
+
const assetsDir = path12.join(publicOutputDir, "assets");
|
|
12674
13518
|
const manifestExists = await import("fs/promises").then(
|
|
12675
13519
|
(fs4) => fs4.access(manifestPath).then(() => true).catch(() => false)
|
|
12676
13520
|
);
|
|
@@ -12686,8 +13530,8 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
12686
13530
|
logger.error(`\u274C Failed to copy client assets: ${error}`);
|
|
12687
13531
|
throw error;
|
|
12688
13532
|
}
|
|
12689
|
-
const serverDir =
|
|
12690
|
-
const nitroServerDir =
|
|
13533
|
+
const serverDir = path12.join(root, distDir, "server");
|
|
13534
|
+
const nitroServerDir = path12.join(root, distDir, ".nitro", "server", "farm");
|
|
12691
13535
|
try {
|
|
12692
13536
|
await mkdir(nitroServerDir, { recursive: true });
|
|
12693
13537
|
await cp(serverDir, nitroServerDir, { recursive: true });
|
|
@@ -12696,7 +13540,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
12696
13540
|
logger.warn(`Could not copy SSR bundles: ${error}`);
|
|
12697
13541
|
}
|
|
12698
13542
|
const nitro = await createNitro(nitroConfig);
|
|
12699
|
-
const registryPath =
|
|
13543
|
+
const registryPath = path12.join(root, distDir, ".nitro", "server", "farm-registry.ts");
|
|
12700
13544
|
try {
|
|
12701
13545
|
const { farmRegistry } = await import(
|
|
12702
13546
|
/* @vite-ignore */
|
|
@@ -12713,7 +13557,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
|
|
|
12713
13557
|
}
|
|
12714
13558
|
farmRegistry.routePaths = routePaths;
|
|
12715
13559
|
try {
|
|
12716
|
-
const clientManifestPath =
|
|
13560
|
+
const clientManifestPath = path12.join(root, distDir, "client", "farm-client-manifest.json");
|
|
12717
13561
|
const { readFile } = await import("fs/promises");
|
|
12718
13562
|
const manifestContent = await readFile(clientManifestPath, "utf-8");
|
|
12719
13563
|
farmRegistry.clientManifest = JSON.parse(manifestContent);
|